1 From 0ddc79efb48c97f0e678807fbe2471f122fd41f6 Mon Sep 17 00:00:00 2001
2 From: Maxime Ripard <maxime@cerno.tech>
3 Date: Wed, 28 Apr 2021 11:56:26 +0200
4 Subject: [PATCH] ASoC: hdmi-codec: Rework to support more controls
6 We're going to add more controls to support the IEC958 output, so let's
7 rework the control registration a bit to support more of them.
9 Signed-off-by: Maxime Ripard <maxime@cerno.tech>
11 sound/soc/codecs/hdmi-codec.c | 41 ++++++++++++++++++++++-------------
12 1 file changed, 26 insertions(+), 15 deletions(-)
14 --- a/sound/soc/codecs/hdmi-codec.c
15 +++ b/sound/soc/codecs/hdmi-codec.c
16 @@ -619,21 +619,23 @@ static const struct snd_soc_dai_ops hdmi
17 SNDRV_PCM_FMTBIT_S32_LE | SNDRV_PCM_FMTBIT_S32_BE |\
18 SNDRV_PCM_FMTBIT_IEC958_SUBFRAME_LE)
20 +struct snd_kcontrol_new hdmi_codec_controls[] = {
22 + .access = (SNDRV_CTL_ELEM_ACCESS_READ |
23 + SNDRV_CTL_ELEM_ACCESS_VOLATILE),
24 + .iface = SNDRV_CTL_ELEM_IFACE_PCM,
26 + .info = hdmi_eld_ctl_info,
27 + .get = hdmi_eld_ctl_get,
31 static int hdmi_codec_pcm_new(struct snd_soc_pcm_runtime *rtd,
32 struct snd_soc_dai *dai)
34 struct snd_soc_dai_driver *drv = dai->driver;
35 struct hdmi_codec_priv *hcp = snd_soc_dai_get_drvdata(dai);
36 - struct snd_kcontrol *kctl;
37 - struct snd_kcontrol_new hdmi_eld_ctl = {
38 - .access = SNDRV_CTL_ELEM_ACCESS_READ |
39 - SNDRV_CTL_ELEM_ACCESS_VOLATILE,
40 - .iface = SNDRV_CTL_ELEM_IFACE_PCM,
42 - .info = hdmi_eld_ctl_info,
43 - .get = hdmi_eld_ctl_get,
44 - .device = rtd->pcm->device,
49 ret = snd_pcm_add_chmap_ctls(rtd->pcm, SNDRV_PCM_STREAM_PLAYBACK,
50 @@ -650,12 +652,21 @@ static int hdmi_codec_pcm_new(struct snd
51 hcp->chmap_info->chmap = hdmi_codec_stereo_chmaps;
52 hcp->chmap_idx = HDMI_CODEC_CHMAP_IDX_UNKNOWN;
54 - /* add ELD ctl with the device number corresponding to the PCM stream */
55 - kctl = snd_ctl_new1(&hdmi_eld_ctl, dai->component);
58 + for (i = 0; i < ARRAY_SIZE(hdmi_codec_controls); i++) {
59 + struct snd_kcontrol *kctl;
61 + /* add ELD ctl with the device number corresponding to the PCM stream */
62 + kctl = snd_ctl_new1(&hdmi_codec_controls[i], dai->component);
66 + kctl->id.device = rtd->pcm->device;
67 + ret = snd_ctl_add(rtd->card->snd_card, kctl);
72 - return snd_ctl_add(rtd->card->snd_card, kctl);
76 static int hdmi_dai_probe(struct snd_soc_dai *dai)