1 From 011a6244136c86e03c77866d6ef9b8eac65fc575 Mon Sep 17 00:00:00 2001
2 From: Maxime Ripard <maxime@cerno.tech>
3 Date: Wed, 28 Apr 2021 15:29:51 +0200
4 Subject: [PATCH] ASoC: hdmi-codec: Add iec958 controls
6 Signed-off-by: Maxime Ripard <maxime@cerno.tech>
8 sound/soc/codecs/hdmi-codec.c | 66 +++++++++++++++++++++++++++++++++--
9 1 file changed, 64 insertions(+), 2 deletions(-)
11 --- a/sound/soc/codecs/hdmi-codec.c
12 +++ b/sound/soc/codecs/hdmi-codec.c
13 @@ -278,6 +278,7 @@ struct hdmi_codec_priv {
15 struct snd_soc_jack *jack;
16 unsigned int jack_status;
20 static const struct snd_soc_dapm_widget hdmi_widgets[] = {
21 @@ -385,6 +386,47 @@ static int hdmi_codec_chmap_ctl_get(stru
25 +static int hdmi_codec_iec958_info(struct snd_kcontrol *kcontrol,
26 + struct snd_ctl_elem_info *uinfo)
28 + uinfo->type = SNDRV_CTL_ELEM_TYPE_IEC958;
33 +static int hdmi_codec_iec958_default_get(struct snd_kcontrol *kcontrol,
34 + struct snd_ctl_elem_value *ucontrol)
36 + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol);
37 + struct hdmi_codec_priv *hcp = snd_soc_component_get_drvdata(component);
39 + memcpy(ucontrol->value.iec958.status, hcp->iec_status,
40 + sizeof(hcp->iec_status));
45 +static int hdmi_codec_iec958_default_put(struct snd_kcontrol *kcontrol,
46 + struct snd_ctl_elem_value *ucontrol)
48 + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol);
49 + struct hdmi_codec_priv *hcp = snd_soc_component_get_drvdata(component);
51 + memcpy(hcp->iec_status, ucontrol->value.iec958.status,
52 + sizeof(hcp->iec_status));
57 +static int hdmi_codec_iec958_mask_get(struct snd_kcontrol *kcontrol,
58 + struct snd_ctl_elem_value *ucontrol)
60 + memset(ucontrol->value.iec958.status, 0xff,
61 + sizeof_field(struct hdmi_codec_priv, iec_status));
66 static int hdmi_codec_startup(struct snd_pcm_substream *substream,
67 struct snd_soc_dai *dai)
69 @@ -458,8 +500,9 @@ static int hdmi_codec_hw_params(struct s
70 params_width(params), params_rate(params),
71 params_channels(params));
73 - ret = snd_pcm_create_iec958_consumer_hw_params(params, hp.iec.status,
74 - sizeof(hp.iec.status));
75 + memcpy(hp.iec.status, hcp->iec_status, sizeof(hp->iec_status));
76 + ret = snd_pcm_fill_iec958_consumer_hw_params(params, hp.iec.status,
77 + sizeof(hp.iec.status));
79 dev_err(dai->dev, "Creating IEC958 channel status failed %d\n",
81 @@ -621,6 +664,20 @@ static const struct snd_soc_dai_ops hdmi
83 struct snd_kcontrol_new hdmi_codec_controls[] = {
85 + .access = SNDRV_CTL_ELEM_ACCESS_READ,
86 + .iface = SNDRV_CTL_ELEM_IFACE_PCM,
87 + .name = SNDRV_CTL_NAME_IEC958("", PLAYBACK, MASK),
88 + .info = hdmi_codec_iec958_info,
89 + .get = hdmi_codec_iec958_mask_get,
92 + .iface = SNDRV_CTL_ELEM_IFACE_PCM,
93 + .name = SNDRV_CTL_NAME_IEC958("", PLAYBACK, DEFAULT),
94 + .info = hdmi_codec_iec958_info,
95 + .get = hdmi_codec_iec958_default_get,
96 + .put = hdmi_codec_iec958_default_put,
99 .access = (SNDRV_CTL_ELEM_ACCESS_READ |
100 SNDRV_CTL_ELEM_ACCESS_VOLATILE),
101 .iface = SNDRV_CTL_ELEM_IFACE_PCM,
102 @@ -845,6 +902,11 @@ static int hdmi_codec_probe(struct platf
104 mutex_init(&hcp->lock);
106 + ret = snd_pcm_create_iec958_consumer_default(hcp->iec_status,
107 + sizeof(hcp->iec_status));
111 daidrv = devm_kcalloc(dev, dai_count, sizeof(*daidrv), GFP_KERNEL);