aboutsummaryrefslogtreecommitdiffstats
path: root/sound/soc/omap/rx51.c
diff options
context:
space:
mode:
authorLiam Girdwood <lrg@ti.com>2012-02-03 12:43:09 -0500
committerMark Brown <broonie@opensource.wolfsonmicro.com>2012-02-04 07:40:11 -0500
commit022658beab5581ecc1d325d60857f2fc464da22f (patch)
treec7617e257cf492990c369197d5e144ac15225fd4 /sound/soc/omap/rx51.c
parent83344027cacf1944fe180907fa98ee4116ef33ea (diff)
ASoC: core: Add support for DAI and machine kcontrols.
Currently ASoC can only add kcontrols using codec and platform component device handles. It's also desirable to add kcontrols for DAIs (i.e. McBSP) and for SoC card machine drivers too. This allows the kcontrol to have a direct handle to the parent ASoC component DAI/SoC Card/Platform/Codec device and hence easily get it's private data. This change makes snd_soc_add_controls() static and wraps it in the folowing calls (card and dai are new) :- snd_soc_add_card_controls() snd_soc_add_codec_controls() snd_soc_add_dai_controls() snd_soc_add_platform_controls() This patch also does a lot of small mechanical changes in individual codec drivers to replace snd_soc_add_controls() with snd_soc_add_codec_controls(). It also updates the McBSP DAI driver to use snd_soc_add_dai_controls(). Finally, it updates the existing machine drivers that register controls to either :- 1) Use snd_soc_add_card_controls() where no direct codec control is required. 2) Use snd_soc_add_codec_controls() where there is direct codec control. In the case of 1) above we also update the machine drivers to get the correct component data pointers from the kcontrol (rather than getting the machine pointer via the codec pointer). Signed-off-by: Liam Girdwood <lrg@ti.com> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'sound/soc/omap/rx51.c')
-rw-r--r--sound/soc/omap/rx51.c25
1 files changed, 12 insertions, 13 deletions
diff --git a/sound/soc/omap/rx51.c b/sound/soc/omap/rx51.c
index fada6ef43eea..58936c730a87 100644
--- a/sound/soc/omap/rx51.c
+++ b/sound/soc/omap/rx51.c
@@ -59,9 +59,8 @@ static int rx51_spk_func;
59static int rx51_dmic_func; 59static int rx51_dmic_func;
60static int rx51_jack_func; 60static int rx51_jack_func;
61 61
62static void rx51_ext_control(struct snd_soc_codec *codec) 62static void rx51_ext_control(struct snd_soc_dapm_context *dapm)
63{ 63{
64 struct snd_soc_dapm_context *dapm = &codec->dapm;
65 int hp = 0, hs = 0, tvout = 0; 64 int hp = 0, hs = 0, tvout = 0;
66 65
67 switch (rx51_jack_func) { 66 switch (rx51_jack_func) {
@@ -102,11 +101,11 @@ static int rx51_startup(struct snd_pcm_substream *substream)
102{ 101{
103 struct snd_pcm_runtime *runtime = substream->runtime; 102 struct snd_pcm_runtime *runtime = substream->runtime;
104 struct snd_soc_pcm_runtime *rtd = substream->private_data; 103 struct snd_soc_pcm_runtime *rtd = substream->private_data;
105 struct snd_soc_codec *codec = rtd->codec; 104 struct snd_soc_card *card = rtd->card;
106 105
107 snd_pcm_hw_constraint_minmax(runtime, 106 snd_pcm_hw_constraint_minmax(runtime,
108 SNDRV_PCM_HW_PARAM_CHANNELS, 2, 2); 107 SNDRV_PCM_HW_PARAM_CHANNELS, 2, 2);
109 rx51_ext_control(codec); 108 rx51_ext_control(&card->dapm);
110 109
111 return 0; 110 return 0;
112} 111}
@@ -138,13 +137,13 @@ static int rx51_get_spk(struct snd_kcontrol *kcontrol,
138static int rx51_set_spk(struct snd_kcontrol *kcontrol, 137static int rx51_set_spk(struct snd_kcontrol *kcontrol,
139 struct snd_ctl_elem_value *ucontrol) 138 struct snd_ctl_elem_value *ucontrol)
140{ 139{
141 struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); 140 struct snd_soc_card *card = snd_kcontrol_chip(kcontrol);
142 141
143 if (rx51_spk_func == ucontrol->value.integer.value[0]) 142 if (rx51_spk_func == ucontrol->value.integer.value[0])
144 return 0; 143 return 0;
145 144
146 rx51_spk_func = ucontrol->value.integer.value[0]; 145 rx51_spk_func = ucontrol->value.integer.value[0];
147 rx51_ext_control(codec); 146 rx51_ext_control(&card->dapm);
148 147
149 return 1; 148 return 1;
150} 149}
@@ -184,13 +183,13 @@ static int rx51_get_input(struct snd_kcontrol *kcontrol,
184static int rx51_set_input(struct snd_kcontrol *kcontrol, 183static int rx51_set_input(struct snd_kcontrol *kcontrol,
185 struct snd_ctl_elem_value *ucontrol) 184 struct snd_ctl_elem_value *ucontrol)
186{ 185{
187 struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); 186 struct snd_soc_card *card = snd_kcontrol_chip(kcontrol);
188 187
189 if (rx51_dmic_func == ucontrol->value.integer.value[0]) 188 if (rx51_dmic_func == ucontrol->value.integer.value[0])
190 return 0; 189 return 0;
191 190
192 rx51_dmic_func = ucontrol->value.integer.value[0]; 191 rx51_dmic_func = ucontrol->value.integer.value[0];
193 rx51_ext_control(codec); 192 rx51_ext_control(&card->dapm);
194 193
195 return 1; 194 return 1;
196} 195}
@@ -206,13 +205,13 @@ static int rx51_get_jack(struct snd_kcontrol *kcontrol,
206static int rx51_set_jack(struct snd_kcontrol *kcontrol, 205static int rx51_set_jack(struct snd_kcontrol *kcontrol,
207 struct snd_ctl_elem_value *ucontrol) 206 struct snd_ctl_elem_value *ucontrol)
208{ 207{
209 struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); 208 struct snd_soc_card *card = snd_kcontrol_chip(kcontrol);
210 209
211 if (rx51_jack_func == ucontrol->value.integer.value[0]) 210 if (rx51_jack_func == ucontrol->value.integer.value[0])
212 return 0; 211 return 0;
213 212
214 rx51_jack_func = ucontrol->value.integer.value[0]; 213 rx51_jack_func = ucontrol->value.integer.value[0];
215 rx51_ext_control(codec); 214 rx51_ext_control(&card->dapm);
216 215
217 return 1; 216 return 1;
218} 217}
@@ -297,7 +296,7 @@ static int rx51_aic34_init(struct snd_soc_pcm_runtime *rtd)
297 snd_soc_dapm_nc_pin(dapm, "LINE1R"); 296 snd_soc_dapm_nc_pin(dapm, "LINE1R");
298 297
299 /* Add RX-51 specific controls */ 298 /* Add RX-51 specific controls */
300 err = snd_soc_add_controls(codec, aic34_rx51_controls, 299 err = snd_soc_add_card_controls(rtd->card, aic34_rx51_controls,
301 ARRAY_SIZE(aic34_rx51_controls)); 300 ARRAY_SIZE(aic34_rx51_controls));
302 if (err < 0) 301 if (err < 0)
303 return err; 302 return err;
@@ -314,7 +313,7 @@ static int rx51_aic34_init(struct snd_soc_pcm_runtime *rtd)
314 return err; 313 return err;
315 snd_soc_limit_volume(codec, "TPA6130A2 Headphone Playback Volume", 42); 314 snd_soc_limit_volume(codec, "TPA6130A2 Headphone Playback Volume", 42);
316 315
317 err = omap_mcbsp_st_add_controls(codec, 1); 316 err = omap_mcbsp_st_add_controls(rtd->cpu_dai);
318 if (err < 0) 317 if (err < 0)
319 return err; 318 return err;
320 319
@@ -335,7 +334,7 @@ static int rx51_aic34b_init(struct snd_soc_dapm_context *dapm)
335{ 334{
336 int err; 335 int err;
337 336
338 err = snd_soc_add_controls(dapm->codec, aic34_rx51_controlsb, 337 err = snd_soc_add_card_controls(dapm->card, aic34_rx51_controlsb,
339 ARRAY_SIZE(aic34_rx51_controlsb)); 338 ARRAY_SIZE(aic34_rx51_controlsb));
340 if (err < 0) 339 if (err < 0)
341 return err; 340 return err;