ALSA: dice: remove local frag of force_two_pcms

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>
This commit is contained in:
Takashi Sakamoto
2018-05-02 19:16:51 +09:00
committed by Takashi Iwai
parent bd2b441c57
commit 9c367c01d3
3 changed files with 8 additions and 70 deletions

View 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);