ALSA: oxfw: calculating MIDI ports in stream discover
authorTakashi Sakamoto <o-takashi@sakamocchi.jp>
Sun, 18 Oct 2015 08:09:38 +0000 (17:09 +0900)
committerTakashi Iwai <tiwai@suse.de>
Mon, 19 Oct 2015 10:00:47 +0000 (12:00 +0200)
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>
sound/firewire/oxfw/oxfw-midi.c
sound/firewire/oxfw/oxfw-stream.c

index 37a86cf69cbfd72872766025a87b578c3f44b2fe..8665e1043d41fa380a8a94f213098cbca29d87ef 100644 (file)
@@ -142,29 +142,11 @@ static void set_midi_substream_names(struct snd_oxfw *oxfw,
 
 int snd_oxfw_create_midi(struct snd_oxfw *oxfw)
 {
-       struct snd_oxfw_stream_formation formation;
        struct snd_rawmidi *rmidi;
        struct snd_rawmidi_str *str;
-       u8 *format;
-       int i, err;
-
-       /* If its stream has MIDI conformant data channel, add one MIDI port */
-       for (i = 0; i < SND_OXFW_STREAM_FORMAT_ENTRIES; i++) {
-               format = oxfw->tx_stream_formats[i];
-               if (format != NULL) {
-                       err = snd_oxfw_stream_parse_format(format, &formation);
-                       if (err >= 0 && formation.midi > 0)
-                               oxfw->midi_input_ports = 1;
-               }
-
-               format = oxfw->rx_stream_formats[i];
-               if (format != NULL) {
-                       err = snd_oxfw_stream_parse_format(format, &formation);
-                       if (err >= 0 && formation.midi > 0)
-                               oxfw->midi_output_ports = 1;
-               }
-       }
-       if ((oxfw->midi_input_ports == 0) && (oxfw->midi_output_ports == 0))
+       int err;
+
+       if (oxfw->midi_input_ports == 0 && oxfw->midi_output_ports == 0)
                return 0;
 
        /* create midi ports */
index 2c63058bd24595e3a987ae47a025bdeb66f5f73f..48798084de16a83bf146b9450e6024022e18f23d 100644 (file)
@@ -629,6 +629,9 @@ end:
 int snd_oxfw_stream_discover(struct snd_oxfw *oxfw)
 {
        u8 plugs[AVC_PLUG_INFO_BUF_BYTES];
+       struct snd_oxfw_stream_formation formation;
+       u8 *format;
+       unsigned int i;
        int err;
 
        /* the number of plugs for isoc in/out, ext in/out  */
@@ -648,12 +651,42 @@ int snd_oxfw_stream_discover(struct snd_oxfw *oxfw)
                err = fill_stream_formats(oxfw, AVC_GENERAL_PLUG_DIR_OUT, 0);
                if (err < 0)
                        goto end;
+
+               for (i = 0; i < SND_OXFW_STREAM_FORMAT_ENTRIES; i++) {
+                       format = oxfw->tx_stream_formats[i];
+                       if (format == NULL)
+                               continue;
+                       err = snd_oxfw_stream_parse_format(format, &formation);
+                       if (err < 0)
+                               continue;
+
+                       /* Add one MIDI port. */
+                       if (formation.midi > 0)
+                               oxfw->midi_input_ports = 1;
+               }
+
                oxfw->has_output = true;
        }
 
        /* use iPCR[0] if exists */
-       if (plugs[0] > 0)
+       if (plugs[0] > 0) {
                err = fill_stream_formats(oxfw, AVC_GENERAL_PLUG_DIR_IN, 0);
+               if (err < 0)
+                       goto end;
+
+               for (i = 0; i < SND_OXFW_STREAM_FORMAT_ENTRIES; i++) {
+                       format = oxfw->rx_stream_formats[i];
+                       if (format == NULL)
+                               continue;
+                       err = snd_oxfw_stream_parse_format(format, &formation);
+                       if (err < 0)
+                               continue;
+
+                       /* Add one MIDI port. */
+                       if (formation.midi > 0)
+                               oxfw->midi_output_ports = 1;
+               }
+       }
 end:
        return err;
 }
This page took 0.025424 seconds and 5 git commands to generate.