Skip to content

Commit 3fc90c1

Browse files
Sugar Zhangrkhuangtao
authored andcommitted
ASoC: codec: hdmi-codec: add support for audio mode config
Change-Id: I4813e6204fee894ef4f40b3e3b768a1ad94d0a29 Signed-off-by: Sugar Zhang <sugar.zhang@rock-chips.com>
1 parent 8cc5459 commit 3fc90c1

2 files changed

Lines changed: 50 additions & 0 deletions

File tree

include/sound/hdmi-codec.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,13 @@ struct hdmi_codec_params {
5151
int sample_rate;
5252
int sample_width;
5353
int channels;
54+
int mode;
55+
};
56+
57+
enum {
58+
LPCM = 0,
59+
NLPCM,
60+
HBR,
5461
};
5562

5663
struct hdmi_codec_pdata;

sound/soc/codecs/hdmi-codec.c

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ struct hdmi_codec_priv {
4040
struct device *dev;
4141
struct notifier_block nb;
4242
unsigned int jack_status;
43+
unsigned int mode;
4344
};
4445

4546
static const struct snd_soc_dapm_widget hdmi_widgets[] = {
@@ -78,6 +79,36 @@ static int hdmi_eld_ctl_get(struct snd_kcontrol *kcontrol,
7879
return 0;
7980
}
8081

82+
static int hdmi_audio_mode_info(struct snd_kcontrol *kcontrol,
83+
struct snd_ctl_elem_info *uinfo)
84+
{
85+
uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
86+
uinfo->count = 1;
87+
uinfo->value.integer.min = 0;
88+
uinfo->value.integer.max = HBR;
89+
return 0;
90+
}
91+
92+
static int hdmi_audio_mode_get(struct snd_kcontrol *kcontrol,
93+
struct snd_ctl_elem_value *ucontrol)
94+
{
95+
struct snd_soc_component *component = snd_kcontrol_chip(kcontrol);
96+
struct hdmi_codec_priv *hcp = snd_soc_component_get_drvdata(component);
97+
98+
ucontrol->value.integer.value[0] = hcp->mode;
99+
return 0;
100+
}
101+
102+
static int hdmi_audio_mode_put(struct snd_kcontrol *kcontrol,
103+
struct snd_ctl_elem_value *ucontrol)
104+
{
105+
struct snd_soc_component *component = snd_kcontrol_chip(kcontrol);
106+
struct hdmi_codec_priv *hcp = snd_soc_component_get_drvdata(component);
107+
108+
hcp->mode = ucontrol->value.integer.value[0];
109+
return 0;
110+
}
111+
81112
static const struct snd_kcontrol_new hdmi_controls[] = {
82113
{
83114
.access = SNDRV_CTL_ELEM_ACCESS_READ |
@@ -87,6 +118,17 @@ static const struct snd_kcontrol_new hdmi_controls[] = {
87118
.info = hdmi_eld_ctl_info,
88119
.get = hdmi_eld_ctl_get,
89120
},
121+
{
122+
.access = SNDRV_CTL_ELEM_ACCESS_READ |
123+
SNDRV_CTL_ELEM_ACCESS_WRITE |
124+
SNDRV_CTL_ELEM_ACCESS_VOLATILE,
125+
.iface = SNDRV_CTL_ELEM_IFACE_PCM,
126+
.name = "AUDIO MODE",
127+
.info = hdmi_audio_mode_info,
128+
.get = hdmi_audio_mode_get,
129+
.put = hdmi_audio_mode_put,
130+
},
131+
90132
};
91133

92134
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,
201243
hp.sample_width = params_width(params);
202244
hp.sample_rate = params_rate(params);
203245
hp.channels = params_channels(params);
246+
hp.mode = hcp->mode;
204247

205248
return hcp->hcd.ops->hw_params(dai->dev->parent, hcp->hcd.data,
206249
&hcp->daifmt[dai->id], &hp);

0 commit comments

Comments
 (0)