ASoC: codec: hdmi-codec: add support for audio mode config
authorSugar Zhang <sugar.zhang@rock-chips.com>
Thu, 13 Apr 2017 07:26:40 +0000 (15:26 +0800)
committerHuang, Tao <huangtao@rock-chips.com>
Thu, 13 Apr 2017 11:19:08 +0000 (19:19 +0800)
Change-Id: I4813e6204fee894ef4f40b3e3b768a1ad94d0a29
Signed-off-by: Sugar Zhang <sugar.zhang@rock-chips.com>
include/sound/hdmi-codec.h
sound/soc/codecs/hdmi-codec.c

index 0fd2e3893f6875163b15ef196a4c44f5ad7ed73d..fd0ff40679a347cde3e4584cedcf711964eb60e5 100644 (file)
@@ -51,6 +51,13 @@ struct hdmi_codec_params {
        int sample_rate;
        int sample_width;
        int channels;
        int sample_rate;
        int sample_width;
        int channels;
+       int mode;
+};
+
+enum {
+       LPCM = 0,
+       NLPCM,
+       HBR,
 };
 
 struct hdmi_codec_pdata;
 };
 
 struct hdmi_codec_pdata;
index ad750f446d88a34746935c932ea7350e70135063..5e68357c293b449c7b34ce6eb61dc7af89007279 100644 (file)
@@ -40,6 +40,7 @@ struct hdmi_codec_priv {
        struct device *dev;
        struct notifier_block nb;
        unsigned int jack_status;
        struct device *dev;
        struct notifier_block nb;
        unsigned int jack_status;
+       unsigned int mode;
 };
 
 static const struct snd_soc_dapm_widget hdmi_widgets[] = {
 };
 
 static const struct snd_soc_dapm_widget hdmi_widgets[] = {
@@ -78,6 +79,36 @@ static int hdmi_eld_ctl_get(struct snd_kcontrol *kcontrol,
        return 0;
 }
 
        return 0;
 }
 
+static int hdmi_audio_mode_info(struct snd_kcontrol *kcontrol,
+                               struct snd_ctl_elem_info *uinfo)
+{
+       uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
+       uinfo->count = 1;
+       uinfo->value.integer.min = 0;
+       uinfo->value.integer.max = HBR;
+       return 0;
+}
+
+static int hdmi_audio_mode_get(struct snd_kcontrol *kcontrol,
+                              struct snd_ctl_elem_value *ucontrol)
+{
+       struct snd_soc_component *component = snd_kcontrol_chip(kcontrol);
+       struct hdmi_codec_priv *hcp = snd_soc_component_get_drvdata(component);
+
+       ucontrol->value.integer.value[0] = hcp->mode;
+       return 0;
+}
+
+static int hdmi_audio_mode_put(struct snd_kcontrol *kcontrol,
+                              struct snd_ctl_elem_value *ucontrol)
+{
+       struct snd_soc_component *component = snd_kcontrol_chip(kcontrol);
+       struct hdmi_codec_priv *hcp = snd_soc_component_get_drvdata(component);
+
+       hcp->mode = ucontrol->value.integer.value[0];
+       return 0;
+}
+
 static const struct snd_kcontrol_new hdmi_controls[] = {
        {
                .access = SNDRV_CTL_ELEM_ACCESS_READ |
 static const struct snd_kcontrol_new hdmi_controls[] = {
        {
                .access = SNDRV_CTL_ELEM_ACCESS_READ |
@@ -87,6 +118,17 @@ static const struct snd_kcontrol_new hdmi_controls[] = {
                .info = hdmi_eld_ctl_info,
                .get = hdmi_eld_ctl_get,
        },
                .info = hdmi_eld_ctl_info,
                .get = hdmi_eld_ctl_get,
        },
+       {
+               .access = SNDRV_CTL_ELEM_ACCESS_READ |
+                         SNDRV_CTL_ELEM_ACCESS_WRITE |
+                         SNDRV_CTL_ELEM_ACCESS_VOLATILE,
+               .iface = SNDRV_CTL_ELEM_IFACE_PCM,
+               .name = "AUDIO MODE",
+               .info = hdmi_audio_mode_info,
+               .get = hdmi_audio_mode_get,
+               .put = hdmi_audio_mode_put,
+       },
+
 };
 
 static int hdmi_codec_new_stream(struct snd_pcm_substream *substream,
 };
 
 static int hdmi_codec_new_stream(struct snd_pcm_substream *substream,
@@ -201,6 +243,7 @@ static int hdmi_codec_hw_params(struct snd_pcm_substream *substream,
        hp.sample_width = params_width(params);
        hp.sample_rate = params_rate(params);
        hp.channels = params_channels(params);
        hp.sample_width = params_width(params);
        hp.sample_rate = params_rate(params);
        hp.channels = params_channels(params);
+       hp.mode = hcp->mode;
 
        return hcp->hcd.ops->hw_params(dai->dev->parent, hcp->hcd.data,
                                       &hcp->daifmt[dai->id], &hp);
 
        return hcp->hcd.ops->hw_params(dai->dev->parent, hcp->hcd.data,
                                       &hcp->daifmt[dai->id], &hp);