bcm27xx: add kernel 5.10 support
[openwrt/staging/dedeckeh.git] / target / linux / bcm27xx / patches-5.10 / 950-0632-ASoC-hdmi-codec-Rework-to-support-more-controls.patch
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
5
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.
8
9 Signed-off-by: Maxime Ripard <maxime@cerno.tech>
10 ---
11 sound/soc/codecs/hdmi-codec.c | 41 ++++++++++++++++++++++-------------
12 1 file changed, 26 insertions(+), 15 deletions(-)
13
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)
19
20 +struct snd_kcontrol_new hdmi_codec_controls[] = {
21 + {
22 + .access = (SNDRV_CTL_ELEM_ACCESS_READ |
23 + SNDRV_CTL_ELEM_ACCESS_VOLATILE),
24 + .iface = SNDRV_CTL_ELEM_IFACE_PCM,
25 + .name = "ELD",
26 + .info = hdmi_eld_ctl_info,
27 + .get = hdmi_eld_ctl_get,
28 + },
29 +};
30 +
31 static int hdmi_codec_pcm_new(struct snd_soc_pcm_runtime *rtd,
32 struct snd_soc_dai *dai)
33 {
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,
41 - .name = "ELD",
42 - .info = hdmi_eld_ctl_info,
43 - .get = hdmi_eld_ctl_get,
44 - .device = rtd->pcm->device,
45 - };
46 + unsigned int i;
47 int ret;
48
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;
53
54 - /* add ELD ctl with the device number corresponding to the PCM stream */
55 - kctl = snd_ctl_new1(&hdmi_eld_ctl, dai->component);
56 - if (!kctl)
57 - return -ENOMEM;
58 + for (i = 0; i < ARRAY_SIZE(hdmi_codec_controls); i++) {
59 + struct snd_kcontrol *kctl;
60 +
61 + /* add ELD ctl with the device number corresponding to the PCM stream */
62 + kctl = snd_ctl_new1(&hdmi_codec_controls[i], dai->component);
63 + if (!kctl)
64 + return -ENOMEM;
65 +
66 + kctl->id.device = rtd->pcm->device;
67 + ret = snd_ctl_add(rtd->card->snd_card, kctl);
68 + if (ret < 0)
69 + return ret;
70 + }
71
72 - return snd_ctl_add(rtd->card->snd_card, kctl);
73 + return 0;
74 }
75
76 static int hdmi_dai_probe(struct snd_soc_dai *dai)