Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ASoC: hdmi-codec: Rework to support more controls

We're going to add more controls to support the IEC958 output, so let's
rework the control registration a bit to support more of them.

Signed-off-by: Maxime Ripard <maxime@cerno.tech>
Acked-by: Mark Brown <broonie@kernel.org>
Link: https://lore.kernel.org/r/20210525132354.297468-4-maxime@cerno.tech

+26 -15
+26 -15
sound/soc/codecs/hdmi-codec.c
··· 620 620 SNDRV_PCM_FMTBIT_S32_LE | SNDRV_PCM_FMTBIT_S32_BE |\ 621 621 SNDRV_PCM_FMTBIT_IEC958_SUBFRAME_LE) 622 622 623 + struct snd_kcontrol_new hdmi_codec_controls[] = { 624 + { 625 + .access = (SNDRV_CTL_ELEM_ACCESS_READ | 626 + SNDRV_CTL_ELEM_ACCESS_VOLATILE), 627 + .iface = SNDRV_CTL_ELEM_IFACE_PCM, 628 + .name = "ELD", 629 + .info = hdmi_eld_ctl_info, 630 + .get = hdmi_eld_ctl_get, 631 + }, 632 + }; 633 + 623 634 static int hdmi_codec_pcm_new(struct snd_soc_pcm_runtime *rtd, 624 635 struct snd_soc_dai *dai) 625 636 { 626 637 struct snd_soc_dai_driver *drv = dai->driver; 627 638 struct hdmi_codec_priv *hcp = snd_soc_dai_get_drvdata(dai); 628 - struct snd_kcontrol *kctl; 629 - struct snd_kcontrol_new hdmi_eld_ctl = { 630 - .access = SNDRV_CTL_ELEM_ACCESS_READ | 631 - SNDRV_CTL_ELEM_ACCESS_VOLATILE, 632 - .iface = SNDRV_CTL_ELEM_IFACE_PCM, 633 - .name = "ELD", 634 - .info = hdmi_eld_ctl_info, 635 - .get = hdmi_eld_ctl_get, 636 - .device = rtd->pcm->device, 637 - }; 639 + unsigned int i; 638 640 int ret; 639 641 640 642 ret = snd_pcm_add_chmap_ctls(rtd->pcm, SNDRV_PCM_STREAM_PLAYBACK, ··· 653 651 hcp->chmap_info->chmap = hdmi_codec_stereo_chmaps; 654 652 hcp->chmap_idx = HDMI_CODEC_CHMAP_IDX_UNKNOWN; 655 653 656 - /* add ELD ctl with the device number corresponding to the PCM stream */ 657 - kctl = snd_ctl_new1(&hdmi_eld_ctl, dai->component); 658 - if (!kctl) 659 - return -ENOMEM; 654 + for (i = 0; i < ARRAY_SIZE(hdmi_codec_controls); i++) { 655 + struct snd_kcontrol *kctl; 660 656 661 - return snd_ctl_add(rtd->card->snd_card, kctl); 657 + /* add ELD ctl with the device number corresponding to the PCM stream */ 658 + kctl = snd_ctl_new1(&hdmi_codec_controls[i], dai->component); 659 + if (!kctl) 660 + return -ENOMEM; 661 + 662 + kctl->id.device = rtd->pcm->device; 663 + ret = snd_ctl_add(rtd->card->snd_card, kctl); 664 + if (ret < 0) 665 + return ret; 666 + } 667 + 668 + return 0; 662 669 } 663 670 664 671 static int hdmi_dai_probe(struct snd_soc_dai *dai)