diff options
author | Lars-Peter Clausen <lars@metafoo.de> | 2014-03-12 10:27:39 -0400 |
---|---|---|
committer | Mark Brown <broonie@linaro.org> | 2014-03-13 05:41:00 -0400 |
commit | 079942abb389e6d4197db03299ad13297afd812a (patch) | |
tree | 7439ea02346c311447e629f65bc31288886426ef /sound/soc/pxa | |
parent | 0fbd44ab772890cf5dcda87311575e99d2c000c1 (diff) |
ASoC: pxa: tosa: Convert to table based DAPM and control setup
Use table based setup to register the controls and DAPM widgets and routes. This
on one hand makes the code a bit shorter and cleaner and on the other hand the
board level DAPM elements get registered in the card's DAPM context rather than
in the CODEC's DAPM context.
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Mark Brown <broonie@linaro.org>
Diffstat (limited to 'sound/soc/pxa')
-rw-r--r-- | sound/soc/pxa/tosa.c | 35 |
1 files changed, 13 insertions, 22 deletions
diff --git a/sound/soc/pxa/tosa.c b/sound/soc/pxa/tosa.c index cead1658d10a..4a956d1cb269 100644 --- a/sound/soc/pxa/tosa.c +++ b/sound/soc/pxa/tosa.c | |||
@@ -44,9 +44,8 @@ | |||
44 | static int tosa_jack_func; | 44 | static int tosa_jack_func; |
45 | static int tosa_spk_func; | 45 | static int tosa_spk_func; |
46 | 46 | ||
47 | static void tosa_ext_control(struct snd_soc_codec *codec) | 47 | static void tosa_ext_control(struct snd_soc_dapm_context *dapm) |
48 | { | 48 | { |
49 | struct snd_soc_dapm_context *dapm = &codec->dapm; | ||
50 | 49 | ||
51 | snd_soc_dapm_mutex_lock(dapm); | 50 | snd_soc_dapm_mutex_lock(dapm); |
52 | 51 | ||
@@ -82,10 +81,9 @@ static void tosa_ext_control(struct snd_soc_codec *codec) | |||
82 | static int tosa_startup(struct snd_pcm_substream *substream) | 81 | static int tosa_startup(struct snd_pcm_substream *substream) |
83 | { | 82 | { |
84 | struct snd_soc_pcm_runtime *rtd = substream->private_data; | 83 | struct snd_soc_pcm_runtime *rtd = substream->private_data; |
85 | struct snd_soc_codec *codec = rtd->codec; | ||
86 | 84 | ||
87 | /* check the jack status at stream startup */ | 85 | /* check the jack status at stream startup */ |
88 | tosa_ext_control(codec); | 86 | tosa_ext_control(&rtd->card->dapm); |
89 | 87 | ||
90 | return 0; | 88 | return 0; |
91 | } | 89 | } |
@@ -104,13 +102,13 @@ static int tosa_get_jack(struct snd_kcontrol *kcontrol, | |||
104 | static int tosa_set_jack(struct snd_kcontrol *kcontrol, | 102 | static int tosa_set_jack(struct snd_kcontrol *kcontrol, |
105 | struct snd_ctl_elem_value *ucontrol) | 103 | struct snd_ctl_elem_value *ucontrol) |
106 | { | 104 | { |
107 | struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); | 105 | struct snd_soc_card *card = snd_kcontrol_chip(kcontrol); |
108 | 106 | ||
109 | if (tosa_jack_func == ucontrol->value.integer.value[0]) | 107 | if (tosa_jack_func == ucontrol->value.integer.value[0]) |
110 | return 0; | 108 | return 0; |
111 | 109 | ||
112 | tosa_jack_func = ucontrol->value.integer.value[0]; | 110 | tosa_jack_func = ucontrol->value.integer.value[0]; |
113 | tosa_ext_control(codec); | 111 | tosa_ext_control(&card->dapm); |
114 | return 1; | 112 | return 1; |
115 | } | 113 | } |
116 | 114 | ||
@@ -124,13 +122,13 @@ static int tosa_get_spk(struct snd_kcontrol *kcontrol, | |||
124 | static int tosa_set_spk(struct snd_kcontrol *kcontrol, | 122 | static int tosa_set_spk(struct snd_kcontrol *kcontrol, |
125 | struct snd_ctl_elem_value *ucontrol) | 123 | struct snd_ctl_elem_value *ucontrol) |
126 | { | 124 | { |
127 | struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); | 125 | struct snd_soc_card *card = snd_kcontrol_chip(kcontrol); |
128 | 126 | ||
129 | if (tosa_spk_func == ucontrol->value.integer.value[0]) | 127 | if (tosa_spk_func == ucontrol->value.integer.value[0]) |
130 | return 0; | 128 | return 0; |
131 | 129 | ||
132 | tosa_spk_func = ucontrol->value.integer.value[0]; | 130 | tosa_spk_func = ucontrol->value.integer.value[0]; |
133 | tosa_ext_control(codec); | 131 | tosa_ext_control(&card->dapm); |
134 | return 1; | 132 | return 1; |
135 | } | 133 | } |
136 | 134 | ||
@@ -191,24 +189,10 @@ static int tosa_ac97_init(struct snd_soc_pcm_runtime *rtd) | |||
191 | { | 189 | { |
192 | struct snd_soc_codec *codec = rtd->codec; | 190 | struct snd_soc_codec *codec = rtd->codec; |
193 | struct snd_soc_dapm_context *dapm = &codec->dapm; | 191 | struct snd_soc_dapm_context *dapm = &codec->dapm; |
194 | int err; | ||
195 | 192 | ||
196 | snd_soc_dapm_nc_pin(dapm, "OUT3"); | 193 | snd_soc_dapm_nc_pin(dapm, "OUT3"); |
197 | snd_soc_dapm_nc_pin(dapm, "MONOOUT"); | 194 | snd_soc_dapm_nc_pin(dapm, "MONOOUT"); |
198 | 195 | ||
199 | /* add tosa specific controls */ | ||
200 | err = snd_soc_add_codec_controls(codec, tosa_controls, | ||
201 | ARRAY_SIZE(tosa_controls)); | ||
202 | if (err < 0) | ||
203 | return err; | ||
204 | |||
205 | /* add tosa specific widgets */ | ||
206 | snd_soc_dapm_new_controls(dapm, tosa_dapm_widgets, | ||
207 | ARRAY_SIZE(tosa_dapm_widgets)); | ||
208 | |||
209 | /* set up tosa specific audio path audio_map */ | ||
210 | snd_soc_dapm_add_routes(dapm, audio_map, ARRAY_SIZE(audio_map)); | ||
211 | |||
212 | return 0; | 196 | return 0; |
213 | } | 197 | } |
214 | 198 | ||
@@ -239,6 +223,13 @@ static struct snd_soc_card tosa = { | |||
239 | .owner = THIS_MODULE, | 223 | .owner = THIS_MODULE, |
240 | .dai_link = tosa_dai, | 224 | .dai_link = tosa_dai, |
241 | .num_links = ARRAY_SIZE(tosa_dai), | 225 | .num_links = ARRAY_SIZE(tosa_dai), |
226 | |||
227 | .controls = tosa_controls, | ||
228 | .num_controls = ARRAY_SIZE(tosa_controls), | ||
229 | .dapm_widgets = tosa_dapm_widgets, | ||
230 | .num_dapm_widgets = ARRAY_SIZE(tosa_dapm_widgets), | ||
231 | .dapm_routes = audio_map, | ||
232 | .num_dapm_routes = ARRAY_SIZE(audio_map), | ||
242 | }; | 233 | }; |
243 | 234 | ||
244 | static int tosa_probe(struct platform_device *pdev) | 235 | static int tosa_probe(struct platform_device *pdev) |