aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTakashi Sakamoto <o-takashi@sakamocchi.jp>2015-10-18 04:09:38 -0400
committerTakashi Iwai <tiwai@suse.de>2015-10-19 06:00:47 -0400
commit32056041019aa91c2555cc4c280f9fbca8a1be99 (patch)
treea5db8d3139012c524f04b0a961f2ae5970674262
parent56b1c72a75ec44a98aca8bbd71ac869a6f54e036 (diff)
ALSA: oxfw: calculating MIDI ports in stream discover
Current OXFW driver calculates the number of MIDI ports just before adding ALSA MIDI ports. It's convenient for some devices with quirks to move these codes before handling quirks. This commit implements this idea. Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp> Signed-off-by: Takashi Iwai <tiwai@suse.de>
-rw-r--r--sound/firewire/oxfw/oxfw-midi.c24
-rw-r--r--sound/firewire/oxfw/oxfw-stream.c35
2 files changed, 37 insertions, 22 deletions
diff --git a/sound/firewire/oxfw/oxfw-midi.c b/sound/firewire/oxfw/oxfw-midi.c
index 37a86cf69cbf..8665e1043d41 100644
--- a/sound/firewire/oxfw/oxfw-midi.c
+++ b/sound/firewire/oxfw/oxfw-midi.c
@@ -142,29 +142,11 @@ static void set_midi_substream_names(struct snd_oxfw *oxfw,
142 142
143int snd_oxfw_create_midi(struct snd_oxfw *oxfw) 143int snd_oxfw_create_midi(struct snd_oxfw *oxfw)
144{ 144{
145 struct snd_oxfw_stream_formation formation;
146 struct snd_rawmidi *rmidi; 145 struct snd_rawmidi *rmidi;
147 struct snd_rawmidi_str *str; 146 struct snd_rawmidi_str *str;
148 u8 *format; 147 int err;
149 int i, err; 148
150 149 if (oxfw->midi_input_ports == 0 && oxfw->midi_output_ports == 0)
151 /* If its stream has MIDI conformant data channel, add one MIDI port */
152 for (i = 0; i < SND_OXFW_STREAM_FORMAT_ENTRIES; i++) {
153 format = oxfw->tx_stream_formats[i];
154 if (format != NULL) {
155 err = snd_oxfw_stream_parse_format(format, &formation);
156 if (err >= 0 && formation.midi > 0)
157 oxfw->midi_input_ports = 1;
158 }
159
160 format = oxfw->rx_stream_formats[i];
161 if (format != NULL) {
162 err = snd_oxfw_stream_parse_format(format, &formation);
163 if (err >= 0 && formation.midi > 0)
164 oxfw->midi_output_ports = 1;
165 }
166 }
167 if ((oxfw->midi_input_ports == 0) && (oxfw->midi_output_ports == 0))
168 return 0; 150 return 0;
169 151
170 /* create midi ports */ 152 /* create midi ports */
diff --git a/sound/firewire/oxfw/oxfw-stream.c b/sound/firewire/oxfw/oxfw-stream.c
index 2c63058bd245..48798084de16 100644
--- a/sound/firewire/oxfw/oxfw-stream.c
+++ b/sound/firewire/oxfw/oxfw-stream.c
@@ -629,6 +629,9 @@ end:
629int snd_oxfw_stream_discover(struct snd_oxfw *oxfw) 629int snd_oxfw_stream_discover(struct snd_oxfw *oxfw)
630{ 630{
631 u8 plugs[AVC_PLUG_INFO_BUF_BYTES]; 631 u8 plugs[AVC_PLUG_INFO_BUF_BYTES];
632 struct snd_oxfw_stream_formation formation;
633 u8 *format;
634 unsigned int i;
632 int err; 635 int err;
633 636
634 /* the number of plugs for isoc in/out, ext in/out */ 637 /* the number of plugs for isoc in/out, ext in/out */
@@ -648,12 +651,42 @@ int snd_oxfw_stream_discover(struct snd_oxfw *oxfw)
648 err = fill_stream_formats(oxfw, AVC_GENERAL_PLUG_DIR_OUT, 0); 651 err = fill_stream_formats(oxfw, AVC_GENERAL_PLUG_DIR_OUT, 0);
649 if (err < 0) 652 if (err < 0)
650 goto end; 653 goto end;
654
655 for (i = 0; i < SND_OXFW_STREAM_FORMAT_ENTRIES; i++) {
656 format = oxfw->tx_stream_formats[i];
657 if (format == NULL)
658 continue;
659 err = snd_oxfw_stream_parse_format(format, &formation);
660 if (err < 0)
661 continue;
662
663 /* Add one MIDI port. */
664 if (formation.midi > 0)
665 oxfw->midi_input_ports = 1;
666 }
667
651 oxfw->has_output = true; 668 oxfw->has_output = true;
652 } 669 }
653 670
654 /* use iPCR[0] if exists */ 671 /* use iPCR[0] if exists */
655 if (plugs[0] > 0) 672 if (plugs[0] > 0) {
656 err = fill_stream_formats(oxfw, AVC_GENERAL_PLUG_DIR_IN, 0); 673 err = fill_stream_formats(oxfw, AVC_GENERAL_PLUG_DIR_IN, 0);
674 if (err < 0)
675 goto end;
676
677 for (i = 0; i < SND_OXFW_STREAM_FORMAT_ENTRIES; i++) {
678 format = oxfw->rx_stream_formats[i];
679 if (format == NULL)
680 continue;
681 err = snd_oxfw_stream_parse_format(format, &formation);
682 if (err < 0)
683 continue;
684
685 /* Add one MIDI port. */
686 if (formation.midi > 0)
687 oxfw->midi_output_ports = 1;
688 }
689 }
657end: 690end:
658 return err; 691 return err;
659} 692}