@@ -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
4546static 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+
81112static 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
92134static 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