forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-10-22 8ac6c7a54ed1b98d142dce24b11c6de6a1e239a5
kernel/sound/firewire/fireworks/fireworks_midi.c
....@@ -1,14 +1,13 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * fireworks_midi.c - a part of driver for Fireworks based devices
34 *
45 * Copyright (c) 2009-2010 Clemens Ladisch
56 * Copyright (c) 2013-2014 Takashi Sakamoto
6
- *
7
- * Licensed under the terms of the GNU General Public License, version 2.
87 */
98 #include "fireworks.h"
109
11
-static int midi_capture_open(struct snd_rawmidi_substream *substream)
10
+static int midi_open(struct snd_rawmidi_substream *substream)
1211 {
1312 struct snd_efw *efw = substream->rmidi->private_data;
1413 int err;
....@@ -18,28 +17,13 @@
1817 goto end;
1918
2019 mutex_lock(&efw->mutex);
21
- efw->capture_substreams++;
22
- err = snd_efw_stream_start_duplex(efw, 0);
23
- mutex_unlock(&efw->mutex);
24
- if (err < 0)
25
- snd_efw_stream_lock_release(efw);
26
-
27
-end:
28
- return err;
29
-}
30
-
31
-static int midi_playback_open(struct snd_rawmidi_substream *substream)
32
-{
33
- struct snd_efw *efw = substream->rmidi->private_data;
34
- int err;
35
-
36
- err = snd_efw_stream_lock_try(efw);
37
- if (err < 0)
38
- goto end;
39
-
40
- mutex_lock(&efw->mutex);
41
- efw->playback_substreams++;
42
- err = snd_efw_stream_start_duplex(efw, 0);
20
+ err = snd_efw_stream_reserve_duplex(efw, 0, 0, 0);
21
+ if (err >= 0) {
22
+ ++efw->substreams_counter;
23
+ err = snd_efw_stream_start_duplex(efw);
24
+ if (err < 0)
25
+ --efw->substreams_counter;
26
+ }
4327 mutex_unlock(&efw->mutex);
4428 if (err < 0)
4529 snd_efw_stream_lock_release(efw);
....@@ -47,25 +31,12 @@
4731 return err;
4832 }
4933
50
-static int midi_capture_close(struct snd_rawmidi_substream *substream)
34
+static int midi_close(struct snd_rawmidi_substream *substream)
5135 {
5236 struct snd_efw *efw = substream->rmidi->private_data;
5337
5438 mutex_lock(&efw->mutex);
55
- efw->capture_substreams--;
56
- snd_efw_stream_stop_duplex(efw);
57
- mutex_unlock(&efw->mutex);
58
-
59
- snd_efw_stream_lock_release(efw);
60
- return 0;
61
-}
62
-
63
-static int midi_playback_close(struct snd_rawmidi_substream *substream)
64
-{
65
- struct snd_efw *efw = substream->rmidi->private_data;
66
-
67
- mutex_lock(&efw->mutex);
68
- efw->playback_substreams--;
39
+ --efw->substreams_counter;
6940 snd_efw_stream_stop_duplex(efw);
7041 mutex_unlock(&efw->mutex);
7142
....@@ -121,13 +92,13 @@
12192 int snd_efw_create_midi_devices(struct snd_efw *efw)
12293 {
12394 static const struct snd_rawmidi_ops capture_ops = {
124
- .open = midi_capture_open,
125
- .close = midi_capture_close,
95
+ .open = midi_open,
96
+ .close = midi_close,
12697 .trigger = midi_capture_trigger,
12798 };
12899 static const struct snd_rawmidi_ops playback_ops = {
129
- .open = midi_playback_open,
130
- .close = midi_playback_close,
100
+ .open = midi_open,
101
+ .close = midi_close,
131102 .trigger = midi_playback_trigger,
132103 };
133104 struct snd_rawmidi *rmidi;