]> git.ipfire.org Git - people/arne_f/kernel.git/commitdiff
ALSA: dice: remove local frag of force_two_pcms
authorTakashi Sakamoto <o-takashi@sakamocchi.jp>
Wed, 2 May 2018 10:16:51 +0000 (19:16 +0900)
committerTakashi Iwai <tiwai@suse.de>
Wed, 2 May 2018 14:02:08 +0000 (16:02 +0200)
At present, to add PCM substreams for each of available tx/rx streams,
this driver uses a condition based on model-name. This is not enough
to support unknown models.

In former commits, this driver gains cache of stream formats. For models
which support protocol extension, all of available steam formats are
cached. For known models, hard-coded stream formats are used to generate
the cache. For unknown models, stream formats at current mode of sampling
transmission frequency is cached.

Anyway, at least, the cached formats are used to expose constrains of PCM
substreams for userspace applications. Thus, The cached data can be also
used to add PCM substreams themselves, instead of the name-based
conditions.

This commit obsoletes local frag of force_two_pcms.

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

index 08a173170d5215389f947ba25f79efba9f68383e..80351b29fe0d51e787845bb7620d625080cf509a 100644 (file)
@@ -428,40 +428,18 @@ int snd_dice_create_pcm(struct snd_dice *dice)
                .mmap      = snd_pcm_lib_mmap_vmalloc,
        };
        struct snd_pcm *pcm;
-       unsigned int i, max_capture, max_playback, capture, playback;
+       unsigned int capture, playback;
+       int i, j;
        int err;
 
-       /* Check whether PCM substreams are required. */
-       if (dice->force_two_pcms) {
-               max_capture = max_playback = 2;
-       } else {
-               int j;
-               max_capture = max_playback = 0;
-               for (i = 0; i < MAX_STREAMS; ++i) {
-                       for (j = 0; j < SND_DICE_RATE_MODE_COUNT; ++j) {
-                               if (dice->tx_pcm_chs[i][j] > 0) {
-                                       ++max_capture;
-                                       break;
-                               }
-                       }
-
-                       for (j = 0; j < SND_DICE_RATE_MODE_COUNT; ++j) {
-                               if (dice->rx_pcm_chs[i][j] > 0) {
-                                       ++max_playback;
-                                       break;
-                               }
-                       }
-               }
-       }
-
        for (i = 0; i < MAX_STREAMS; i++) {
                capture = playback = 0;
-               if (i < max_capture)
-                       capture = 1;
-               if (i < max_playback)
-                       playback = 1;
-               if (capture == 0 && playback == 0)
-                       break;
+               for (j = 0; j < SND_DICE_RATE_MODE_COUNT; ++j) {
+                       if (dice->tx_pcm_chs[i][j] > 0)
+                               capture = 1;
+                       if (dice->rx_pcm_chs[i][j] > 0)
+                               playback = 1;
+               }
 
                err = snd_pcm_new(dice->card, "DICE", i, playback, capture,
                                  &pcm);
index 6d55a62ec89ead6259c54304fedd8736d6f212c8..40f7a32e489362f598a593aba2dde3c68ae335c8 100644 (file)
@@ -24,36 +24,6 @@ MODULE_LICENSE("GPL v2");
 
 #define MODEL_ALESIS_IO_BOTH   0x000001
 
-/*
- * Some models support several isochronous channels, while these streams are not
- * always available. In this case, add the model name to this list.
- */
-static bool force_two_pcm_support(struct fw_unit *unit)
-{
-       static const char *const models[] = {
-               /* TC Electronic models. */
-               "StudioKonnekt48",
-               /* Focusrite models. */
-               "SAFFIRE_PRO_40",
-               "LIQUID_SAFFIRE_56",
-               "SAFFIRE_PRO_40_1",
-       };
-       char model[32];
-       unsigned int i;
-       int err;
-
-       err = fw_csr_string(unit->directory, CSR_MODEL, model, sizeof(model));
-       if (err < 0)
-               return false;
-
-       for (i = 0; i < ARRAY_SIZE(models); i++) {
-               if (strcmp(models[i], model) == 0)
-                       break;
-       }
-
-       return i < ARRAY_SIZE(models);
-}
-
 static int check_dice_category(struct fw_unit *unit)
 {
        struct fw_device *device = fw_parent_device(unit);
@@ -79,11 +49,6 @@ static int check_dice_category(struct fw_unit *unit)
                }
        }
 
-       if (vendor == OUI_FOCUSRITE || vendor == OUI_TCELECTRONIC) {
-               if (force_two_pcm_support(unit))
-                       return 0;
-       }
-
        if (vendor == OUI_WEISS)
                category = WEISS_CATEGORY_ID;
        else if (vendor == OUI_LOUD)
@@ -190,9 +155,6 @@ static void do_registration(struct work_struct *work)
        if (err < 0)
                return;
 
-       if (force_two_pcm_support(dice->unit))
-               dice->force_two_pcms = true;
-
        err = snd_dice_transaction_init(dice);
        if (err < 0)
                goto error;
index 4465a5925641f9e98a0ab60e1e8b211ca04f1be7..505b79fea6d974c1e35713da13745a4245f65ce8 100644 (file)
@@ -113,8 +113,6 @@ struct snd_dice {
        bool global_enabled;
        struct completion clock_accepted;
        unsigned int substreams_counter;
-
-       bool force_two_pcms;
 };
 
 enum snd_dice_addr_type {