diff options
author | Peter Ujfalusi <peter.ujfalusi@nokia.com> | 2009-01-08 06:34:29 -0500 |
---|---|---|
committer | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2009-01-08 08:09:52 -0500 |
commit | 741555568f8ba307c626019787c412f4386cafdc (patch) | |
tree | 6d1d8683d13d838e9eeb87899718b8ba5a1fddc4 /sound/soc/soc-dapm.c | |
parent | 227b4dc6432d271eecd0ff0aefe6f0897ec47397 (diff) |
ASoC: Merge the soc_value_enum to soc_enum struct
Merge the recently introduced soc_value_enum structure to the soc_enum.
The value based enums are still handled separately from the normal enum types,
but with the merge some of the newly introduced functions can be removed.
Signed-off-by: Peter Ujfalusi <peter.ujfalusi@nokia.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'sound/soc/soc-dapm.c')
-rw-r--r-- | sound/soc/soc-dapm.c | 80 |
1 files changed, 5 insertions, 75 deletions
diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c index ad0d801677c1..493a4e8aa273 100644 --- a/sound/soc/soc-dapm.c +++ b/sound/soc/soc-dapm.c | |||
@@ -137,7 +137,7 @@ static void dapm_set_path_status(struct snd_soc_dapm_widget *w, | |||
137 | } | 137 | } |
138 | break; | 138 | break; |
139 | case snd_soc_dapm_value_mux: { | 139 | case snd_soc_dapm_value_mux: { |
140 | struct soc_value_enum *e = (struct soc_value_enum *) | 140 | struct soc_enum *e = (struct soc_enum *) |
141 | w->kcontrols[i].private_value; | 141 | w->kcontrols[i].private_value; |
142 | int val, item; | 142 | int val, item; |
143 | 143 | ||
@@ -200,30 +200,6 @@ static int dapm_connect_mux(struct snd_soc_codec *codec, | |||
200 | return -ENODEV; | 200 | return -ENODEV; |
201 | } | 201 | } |
202 | 202 | ||
203 | /* connect value_mux widget to it's interconnecting audio paths */ | ||
204 | static int dapm_connect_value_mux(struct snd_soc_codec *codec, | ||
205 | struct snd_soc_dapm_widget *src, struct snd_soc_dapm_widget *dest, | ||
206 | struct snd_soc_dapm_path *path, const char *control_name, | ||
207 | const struct snd_kcontrol_new *kcontrol) | ||
208 | { | ||
209 | struct soc_value_enum *e = (struct soc_value_enum *) | ||
210 | kcontrol->private_value; | ||
211 | int i; | ||
212 | |||
213 | for (i = 0; i < e->max; i++) { | ||
214 | if (!(strcmp(control_name, e->texts[i]))) { | ||
215 | list_add(&path->list, &codec->dapm_paths); | ||
216 | list_add(&path->list_sink, &dest->sources); | ||
217 | list_add(&path->list_source, &src->sinks); | ||
218 | path->name = (char *)e->texts[i]; | ||
219 | dapm_set_path_status(dest, path, 0); | ||
220 | return 0; | ||
221 | } | ||
222 | } | ||
223 | |||
224 | return -ENODEV; | ||
225 | } | ||
226 | |||
227 | /* connect mixer widget to it's interconnecting audio paths */ | 203 | /* connect mixer widget to it's interconnecting audio paths */ |
228 | static int dapm_connect_mixer(struct snd_soc_codec *codec, | 204 | static int dapm_connect_mixer(struct snd_soc_codec *codec, |
229 | struct snd_soc_dapm_widget *src, struct snd_soc_dapm_widget *dest, | 205 | struct snd_soc_dapm_widget *src, struct snd_soc_dapm_widget *dest, |
@@ -774,45 +750,6 @@ static int dapm_mux_update_power(struct snd_soc_dapm_widget *widget, | |||
774 | return 0; | 750 | return 0; |
775 | } | 751 | } |
776 | 752 | ||
777 | /* test and update the power status of a value_mux widget */ | ||
778 | static int dapm_value_mux_update_power(struct snd_soc_dapm_widget *widget, | ||
779 | struct snd_kcontrol *kcontrol, int mask, | ||
780 | int mux, int val, struct soc_value_enum *e) | ||
781 | { | ||
782 | struct snd_soc_dapm_path *path; | ||
783 | int found = 0; | ||
784 | |||
785 | if (widget->id != snd_soc_dapm_value_mux) | ||
786 | return -ENODEV; | ||
787 | |||
788 | if (!snd_soc_test_bits(widget->codec, e->reg, mask, val)) | ||
789 | return 0; | ||
790 | |||
791 | /* find dapm widget path assoc with kcontrol */ | ||
792 | list_for_each_entry(path, &widget->codec->dapm_paths, list) { | ||
793 | if (path->kcontrol != kcontrol) | ||
794 | continue; | ||
795 | |||
796 | if (!path->name || !e->texts[mux]) | ||
797 | continue; | ||
798 | |||
799 | found = 1; | ||
800 | /* we now need to match the string in the enum to the path */ | ||
801 | if (!(strcmp(path->name, e->texts[mux]))) | ||
802 | path->connect = 1; /* new connection */ | ||
803 | else | ||
804 | path->connect = 0; /* old connection must be | ||
805 | powered down */ | ||
806 | } | ||
807 | |||
808 | if (found) { | ||
809 | dapm_power_widgets(widget->codec, SND_SOC_DAPM_STREAM_NOP); | ||
810 | dump_dapm(widget->codec, "mux power update"); | ||
811 | } | ||
812 | |||
813 | return 0; | ||
814 | } | ||
815 | |||
816 | /* test and update the power status of a mixer or switch widget */ | 753 | /* test and update the power status of a mixer or switch widget */ |
817 | static int dapm_mixer_update_power(struct snd_soc_dapm_widget *widget, | 754 | static int dapm_mixer_update_power(struct snd_soc_dapm_widget *widget, |
818 | struct snd_kcontrol *kcontrol, int reg, | 755 | struct snd_kcontrol *kcontrol, int reg, |
@@ -1045,17 +982,12 @@ static int snd_soc_dapm_add_route(struct snd_soc_codec *codec, | |||
1045 | path->connect = 1; | 982 | path->connect = 1; |
1046 | return 0; | 983 | return 0; |
1047 | case snd_soc_dapm_mux: | 984 | case snd_soc_dapm_mux: |
985 | case snd_soc_dapm_value_mux: | ||
1048 | ret = dapm_connect_mux(codec, wsource, wsink, path, control, | 986 | ret = dapm_connect_mux(codec, wsource, wsink, path, control, |
1049 | &wsink->kcontrols[0]); | 987 | &wsink->kcontrols[0]); |
1050 | if (ret != 0) | 988 | if (ret != 0) |
1051 | goto err; | 989 | goto err; |
1052 | break; | 990 | break; |
1053 | case snd_soc_dapm_value_mux: | ||
1054 | ret = dapm_connect_value_mux(codec, wsource, wsink, path, | ||
1055 | control, &wsink->kcontrols[0]); | ||
1056 | if (ret != 0) | ||
1057 | goto err; | ||
1058 | break; | ||
1059 | case snd_soc_dapm_switch: | 991 | case snd_soc_dapm_switch: |
1060 | case snd_soc_dapm_mixer: | 992 | case snd_soc_dapm_mixer: |
1061 | ret = dapm_connect_mixer(codec, wsource, wsink, path, control); | 993 | ret = dapm_connect_mixer(codec, wsource, wsink, path, control); |
@@ -1382,8 +1314,7 @@ int snd_soc_dapm_get_value_enum_double(struct snd_kcontrol *kcontrol, | |||
1382 | struct snd_ctl_elem_value *ucontrol) | 1314 | struct snd_ctl_elem_value *ucontrol) |
1383 | { | 1315 | { |
1384 | struct snd_soc_dapm_widget *widget = snd_kcontrol_chip(kcontrol); | 1316 | struct snd_soc_dapm_widget *widget = snd_kcontrol_chip(kcontrol); |
1385 | struct soc_value_enum *e = (struct soc_value_enum *) | 1317 | struct soc_enum *e = (struct soc_enum *)kcontrol->private_value; |
1386 | kcontrol->private_value; | ||
1387 | unsigned short reg_val, val, mux; | 1318 | unsigned short reg_val, val, mux; |
1388 | 1319 | ||
1389 | reg_val = snd_soc_read(widget->codec, e->reg); | 1320 | reg_val = snd_soc_read(widget->codec, e->reg); |
@@ -1423,8 +1354,7 @@ int snd_soc_dapm_put_value_enum_double(struct snd_kcontrol *kcontrol, | |||
1423 | struct snd_ctl_elem_value *ucontrol) | 1354 | struct snd_ctl_elem_value *ucontrol) |
1424 | { | 1355 | { |
1425 | struct snd_soc_dapm_widget *widget = snd_kcontrol_chip(kcontrol); | 1356 | struct snd_soc_dapm_widget *widget = snd_kcontrol_chip(kcontrol); |
1426 | struct soc_value_enum *e = (struct soc_value_enum *) | 1357 | struct soc_enum *e = (struct soc_enum *)kcontrol->private_value; |
1427 | kcontrol->private_value; | ||
1428 | unsigned short val, mux; | 1358 | unsigned short val, mux; |
1429 | unsigned short mask; | 1359 | unsigned short mask; |
1430 | int ret = 0; | 1360 | int ret = 0; |
@@ -1443,7 +1373,7 @@ int snd_soc_dapm_put_value_enum_double(struct snd_kcontrol *kcontrol, | |||
1443 | 1373 | ||
1444 | mutex_lock(&widget->codec->mutex); | 1374 | mutex_lock(&widget->codec->mutex); |
1445 | widget->value = val; | 1375 | widget->value = val; |
1446 | dapm_value_mux_update_power(widget, kcontrol, mask, mux, val, e); | 1376 | dapm_mux_update_power(widget, kcontrol, mask, mux, val, e); |
1447 | if (widget->event) { | 1377 | if (widget->event) { |
1448 | if (widget->event_flags & SND_SOC_DAPM_PRE_REG) { | 1378 | if (widget->event_flags & SND_SOC_DAPM_PRE_REG) { |
1449 | ret = widget->event(widget, | 1379 | ret = widget->event(widget, |