To not expose more than in fact is supported by the codec, update CPU DAI initialization procedure to rely on codec capabilities instead of hardcoding them. This includes subformat which is currently ignored. Signed-off-by: Cezary Rojewski <cezary.rojewski@xxxxxxxxx> --- sound/soc/intel/avs/pcm.c | 37 +++++++++++++++---------------------- 1 file changed, 15 insertions(+), 22 deletions(-) diff --git a/sound/soc/intel/avs/pcm.c b/sound/soc/intel/avs/pcm.c index fa9d3292fe82..31737133b991 100644 --- a/sound/soc/intel/avs/pcm.c +++ b/sound/soc/intel/avs/pcm.c @@ -1413,27 +1413,6 @@ int avs_i2s_platform_register(struct avs_dev *adev, const char *name, unsigned l return avs_soc_component_register(adev->dev, name, &avs_component_driver, cpus, cpu_count); } -/* HD-Audio CPU DAI template */ -static const struct snd_soc_dai_driver hda_cpu_dai = { - .ops = &avs_dai_hda_be_ops, - .playback = { - .channels_min = 1, - .channels_max = 8, - .rates = SNDRV_PCM_RATE_8000_192000, - .formats = SNDRV_PCM_FMTBIT_S16_LE | - SNDRV_PCM_FMTBIT_S24_LE | - SNDRV_PCM_FMTBIT_S32_LE, - }, - .capture = { - .channels_min = 1, - .channels_max = 8, - .rates = SNDRV_PCM_RATE_8000_192000, - .formats = SNDRV_PCM_FMTBIT_S16_LE | - SNDRV_PCM_FMTBIT_S24_LE | - SNDRV_PCM_FMTBIT_S32_LE, - }, -}; - static void avs_component_hda_unregister_dais(struct snd_soc_component *component) { struct snd_soc_acpi_mach *mach; @@ -1490,8 +1469,8 @@ static int avs_component_hda_probe(struct snd_soc_component *component) for (i = 0; i < pcm_count; i++, pcm = list_next_entry(pcm, list)) { struct snd_soc_dai *dai; - memcpy(&dais[i], &hda_cpu_dai, sizeof(*dais)); dais[i].id = i; + dais[i].ops = &avs_dai_hda_be_ops; dais[i].name = devm_kasprintf(component->dev, GFP_KERNEL, "%s-cpu%d", cname, i); if (!dais[i].name) { @@ -1507,6 +1486,13 @@ static int avs_component_hda_probe(struct snd_soc_component *component) ret = -ENOMEM; goto exit; } + + dais[i].playback.formats = pcm->stream[0].formats; + dais[i].playback.subformats = pcm->stream[0].subformats; + dais[i].playback.rates = pcm->stream[0].rates; + dais[i].playback.channels_min = pcm->stream[0].channels_min; + dais[i].playback.channels_max = pcm->stream[0].channels_max; + dais[i].playback.sig_bits = pcm->stream[0].maxbps; } if (pcm->stream[1].substreams) { @@ -1517,6 +1503,13 @@ static int avs_component_hda_probe(struct snd_soc_component *component) ret = -ENOMEM; goto exit; } + + dais[i].capture.formats = pcm->stream[1].formats; + dais[i].capture.subformats = pcm->stream[1].subformats; + dais[i].capture.rates = pcm->stream[1].rates; + dais[i].capture.channels_min = pcm->stream[1].channels_min; + dais[i].capture.channels_max = pcm->stream[1].channels_max; + dais[i].capture.sig_bits = pcm->stream[1].maxbps; } dai = snd_soc_register_dai(component, &dais[i], false); -- 2.25.1