ALSA: firewire-motu: add a structure for model-dependent parameters.
authorTakashi Sakamoto <o-takashi@sakamocchi.jp>
Wed, 22 Mar 2017 12:30:13 +0000 (21:30 +0900)
committerTakashi Iwai <tiwai@suse.de>
Tue, 28 Mar 2017 10:33:21 +0000 (12:33 +0200)
MOTU FireWire series doesn't tell drivers their capabilities, thus
the drivers should have and apply model-dependent parameters to detected
models.

This commit adds a structure to represent such parameters. Capabilities
are represented by enumeration except for the number of analog line
in/out. Identification name also be in the structure because the units has
no registers for this purpose.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
sound/firewire/motu/motu.c
sound/firewire/motu/motu.h

index bdd82ddeb6ec2e710d7f2ad85e98b934eafc65c8..e69aa7b5dcdef3d29f3824ff55e2a3b36d53a7c9 100644 (file)
@@ -31,9 +31,11 @@ static void name_card(struct snd_motu *motu)
        }
 
        strcpy(motu->card->driver, "FW-MOTU");
+       strcpy(motu->card->shortname, motu->spec->name);
+       strcpy(motu->card->mixername, motu->spec->name);
        snprintf(motu->card->longname, sizeof(motu->card->longname),
-                "MOTU (version:%d), GUID %08x%08x at %s, S%d",
-                version,
+                "MOTU %s (version:%d), GUID %08x%08x at %s, S%d",
+                motu->spec->name, version,
                 fw_dev->config_rom[3], fw_dev->config_rom[4],
                 dev_name(&motu->unit->device), 100 << fw_dev->max_speed);
 }
@@ -101,6 +103,7 @@ static int motu_probe(struct fw_unit *unit,
        if (motu == NULL)
                return -ENOMEM;
 
+       motu->spec = (const struct snd_motu_spec *)entry->driver_data;
        motu->unit = fw_unit_get(unit);
        dev_set_drvdata(&unit->device, motu);
 
@@ -142,7 +145,7 @@ static void motu_bus_update(struct fw_unit *unit)
                snd_fw_schedule_registration(unit, &motu->dwork);
 }
 
-#define SND_MOTU_DEV_ENTRY(model)                      \
+#define SND_MOTU_DEV_ENTRY(model, data)                        \
 {                                                      \
        .match_flags    = IEEE1394_MATCH_VENDOR_ID |    \
                          IEEE1394_MATCH_MODEL_ID |     \
@@ -150,6 +153,7 @@ static void motu_bus_update(struct fw_unit *unit)
        .vendor_id      = OUI_MOTU,                     \
        .model_id       = model,                        \
        .specifier_id   = OUI_MOTU,                     \
+       .driver_data    = (kernel_ulong_t)data,         \
 }
 
 static const struct ieee1394_device_id motu_id_table[] = {
index eb0ffd56c835fd81e037b211b31165ec6ade3902..cb7324d0d55897ae820a5c2ed01b066cec3e9877 100644 (file)
@@ -29,6 +29,29 @@ struct snd_motu {
 
        bool registered;
        struct delayed_work dwork;
+
+       /* Model dependent information. */
+       const struct snd_motu_spec *spec;
+};
+
+enum snd_motu_spec_flags {
+       SND_MOTU_SPEC_SUPPORT_CLOCK_X2  = 0x0001,
+       SND_MOTU_SPEC_SUPPORT_CLOCK_X4  = 0x0002,
+       SND_MOTU_SPEC_TX_MICINST_CHUNK  = 0x0004,
+       SND_MOTU_SPEC_TX_RETURN_CHUNK   = 0x0008,
+       SND_MOTU_SPEC_TX_REVERB_CHUNK   = 0x0010,
+       SND_MOTU_SPEC_TX_AESEBU_CHUNK   = 0x0020,
+       SND_MOTU_SPEC_HAS_OPT_IFACE_A   = 0x0040,
+       SND_MOTU_SPEC_HAS_OPT_IFACE_B   = 0x0080,
+       SND_MOTU_SPEC_HAS_MIDI          = 0x0100,
+};
+
+struct snd_motu_spec {
+       const char *const name;
+       enum snd_motu_spec_flags flags;
+
+       unsigned char analog_in_ports;
+       unsigned char analog_out_ports;
 };
 
 #endif