UPSTREAM: 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. Bug: 239396464 Change-Id: Ia8c0bf8c997638b5a121ae7356fa1eb27746036f 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 Signed-off-by: Sugar Zhang <sugar.zhang@rock-chips.com> (cherry picked from commit 366b45b974481bea9603843d308aded519aab7dc)
This commit is contained in:
@@ -620,21 +620,23 @@ static const struct snd_soc_dai_ops hdmi_codec_spdif_dai_ops = {
|
|||||||
SNDRV_PCM_FMTBIT_S32_LE | SNDRV_PCM_FMTBIT_S32_BE |\
|
SNDRV_PCM_FMTBIT_S32_LE | SNDRV_PCM_FMTBIT_S32_BE |\
|
||||||
SNDRV_PCM_FMTBIT_IEC958_SUBFRAME_LE)
|
SNDRV_PCM_FMTBIT_IEC958_SUBFRAME_LE)
|
||||||
|
|
||||||
|
struct snd_kcontrol_new hdmi_codec_controls[] = {
|
||||||
|
{
|
||||||
|
.access = (SNDRV_CTL_ELEM_ACCESS_READ |
|
||||||
|
SNDRV_CTL_ELEM_ACCESS_VOLATILE),
|
||||||
|
.iface = SNDRV_CTL_ELEM_IFACE_PCM,
|
||||||
|
.name = "ELD",
|
||||||
|
.info = hdmi_eld_ctl_info,
|
||||||
|
.get = hdmi_eld_ctl_get,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
static int hdmi_codec_pcm_new(struct snd_soc_pcm_runtime *rtd,
|
static int hdmi_codec_pcm_new(struct snd_soc_pcm_runtime *rtd,
|
||||||
struct snd_soc_dai *dai)
|
struct snd_soc_dai *dai)
|
||||||
{
|
{
|
||||||
struct snd_soc_dai_driver *drv = dai->driver;
|
struct snd_soc_dai_driver *drv = dai->driver;
|
||||||
struct hdmi_codec_priv *hcp = snd_soc_dai_get_drvdata(dai);
|
struct hdmi_codec_priv *hcp = snd_soc_dai_get_drvdata(dai);
|
||||||
struct snd_kcontrol *kctl;
|
unsigned int i;
|
||||||
struct snd_kcontrol_new hdmi_eld_ctl = {
|
|
||||||
.access = SNDRV_CTL_ELEM_ACCESS_READ |
|
|
||||||
SNDRV_CTL_ELEM_ACCESS_VOLATILE,
|
|
||||||
.iface = SNDRV_CTL_ELEM_IFACE_PCM,
|
|
||||||
.name = "ELD",
|
|
||||||
.info = hdmi_eld_ctl_info,
|
|
||||||
.get = hdmi_eld_ctl_get,
|
|
||||||
.device = rtd->pcm->device,
|
|
||||||
};
|
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
ret = snd_pcm_add_chmap_ctls(rtd->pcm, SNDRV_PCM_STREAM_PLAYBACK,
|
ret = snd_pcm_add_chmap_ctls(rtd->pcm, SNDRV_PCM_STREAM_PLAYBACK,
|
||||||
@@ -651,12 +653,21 @@ static int hdmi_codec_pcm_new(struct snd_soc_pcm_runtime *rtd,
|
|||||||
hcp->chmap_info->chmap = hdmi_codec_stereo_chmaps;
|
hcp->chmap_info->chmap = hdmi_codec_stereo_chmaps;
|
||||||
hcp->chmap_idx = HDMI_CODEC_CHMAP_IDX_UNKNOWN;
|
hcp->chmap_idx = HDMI_CODEC_CHMAP_IDX_UNKNOWN;
|
||||||
|
|
||||||
|
for (i = 0; i < ARRAY_SIZE(hdmi_codec_controls); i++) {
|
||||||
|
struct snd_kcontrol *kctl;
|
||||||
|
|
||||||
/* add ELD ctl with the device number corresponding to the PCM stream */
|
/* add ELD ctl with the device number corresponding to the PCM stream */
|
||||||
kctl = snd_ctl_new1(&hdmi_eld_ctl, dai->component);
|
kctl = snd_ctl_new1(&hdmi_codec_controls[i], dai->component);
|
||||||
if (!kctl)
|
if (!kctl)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
return snd_ctl_add(rtd->card->snd_card, kctl);
|
kctl->id.device = rtd->pcm->device;
|
||||||
|
ret = snd_ctl_add(rtd->card->snd_card, kctl);
|
||||||
|
if (ret < 0)
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int hdmi_dai_probe(struct snd_soc_dai *dai)
|
static int hdmi_dai_probe(struct snd_soc_dai *dai)
|
||||||
|
Reference in New Issue
Block a user