aboutsummaryrefslogtreecommitdiffstats
path: root/sound/soc/soc-dapm.c
diff options
context:
space:
mode:
Diffstat (limited to 'sound/soc/soc-dapm.c')
-rw-r--r--sound/soc/soc-dapm.c57
1 files changed, 41 insertions, 16 deletions
diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c
index a2f1da8b4646..54b4564b82b4 100644
--- a/sound/soc/soc-dapm.c
+++ b/sound/soc/soc-dapm.c
@@ -54,14 +54,15 @@
54static int dapm_up_seq[] = { 54static int dapm_up_seq[] = {
55 snd_soc_dapm_pre, snd_soc_dapm_micbias, snd_soc_dapm_mic, 55 snd_soc_dapm_pre, snd_soc_dapm_micbias, snd_soc_dapm_mic,
56 snd_soc_dapm_mux, snd_soc_dapm_value_mux, snd_soc_dapm_dac, 56 snd_soc_dapm_mux, snd_soc_dapm_value_mux, snd_soc_dapm_dac,
57 snd_soc_dapm_mixer, snd_soc_dapm_pga, snd_soc_dapm_adc, snd_soc_dapm_hp, 57 snd_soc_dapm_mixer, snd_soc_dapm_mixer_named_ctl, snd_soc_dapm_pga,
58 snd_soc_dapm_spk, snd_soc_dapm_post 58 snd_soc_dapm_adc, snd_soc_dapm_hp, snd_soc_dapm_spk, snd_soc_dapm_post
59}; 59};
60
60static int dapm_down_seq[] = { 61static int dapm_down_seq[] = {
61 snd_soc_dapm_pre, snd_soc_dapm_adc, snd_soc_dapm_hp, snd_soc_dapm_spk, 62 snd_soc_dapm_pre, snd_soc_dapm_adc, snd_soc_dapm_hp, snd_soc_dapm_spk,
62 snd_soc_dapm_pga, snd_soc_dapm_mixer, snd_soc_dapm_dac, snd_soc_dapm_mic, 63 snd_soc_dapm_pga, snd_soc_dapm_mixer_named_ctl, snd_soc_dapm_mixer,
63 snd_soc_dapm_micbias, snd_soc_dapm_mux, snd_soc_dapm_value_mux, 64 snd_soc_dapm_dac, snd_soc_dapm_mic, snd_soc_dapm_micbias,
64 snd_soc_dapm_post 65 snd_soc_dapm_mux, snd_soc_dapm_value_mux, snd_soc_dapm_post
65}; 66};
66 67
67static int dapm_status = 1; 68static int dapm_status = 1;
@@ -101,7 +102,8 @@ static void dapm_set_path_status(struct snd_soc_dapm_widget *w,
101{ 102{
102 switch (w->id) { 103 switch (w->id) {
103 case snd_soc_dapm_switch: 104 case snd_soc_dapm_switch:
104 case snd_soc_dapm_mixer: { 105 case snd_soc_dapm_mixer:
106 case snd_soc_dapm_mixer_named_ctl: {
105 int val; 107 int val;
106 struct soc_mixer_control *mc = (struct soc_mixer_control *) 108 struct soc_mixer_control *mc = (struct soc_mixer_control *)
107 w->kcontrols[i].private_value; 109 w->kcontrols[i].private_value;
@@ -323,15 +325,33 @@ static int dapm_new_mixer(struct snd_soc_codec *codec,
323 if (path->name != (char*)w->kcontrols[i].name) 325 if (path->name != (char*)w->kcontrols[i].name)
324 continue; 326 continue;
325 327
326 /* add dapm control with long name */ 328 /* add dapm control with long name.
327 name_len = 2 + strlen(w->name) 329 * for dapm_mixer this is the concatenation of the
328 + strlen(w->kcontrols[i].name); 330 * mixer and kcontrol name.
331 * for dapm_mixer_named_ctl this is simply the
332 * kcontrol name.
333 */
334 name_len = strlen(w->kcontrols[i].name) + 1;
335 if (w->id == snd_soc_dapm_mixer)
336 name_len += 1 + strlen(w->name);
337
329 path->long_name = kmalloc(name_len, GFP_KERNEL); 338 path->long_name = kmalloc(name_len, GFP_KERNEL);
339
330 if (path->long_name == NULL) 340 if (path->long_name == NULL)
331 return -ENOMEM; 341 return -ENOMEM;
332 342
333 snprintf(path->long_name, name_len, "%s %s", 343 switch (w->id) {
334 w->name, w->kcontrols[i].name); 344 case snd_soc_dapm_mixer:
345 default:
346 snprintf(path->long_name, name_len, "%s %s",
347 w->name, w->kcontrols[i].name);
348 break;
349 case snd_soc_dapm_mixer_named_ctl:
350 snprintf(path->long_name, name_len, "%s",
351 w->kcontrols[i].name);
352 break;
353 }
354
335 path->long_name[name_len - 1] = '\0'; 355 path->long_name[name_len - 1] = '\0';
336 356
337 path->kcontrol = snd_soc_cnew(&w->kcontrols[i], w, 357 path->kcontrol = snd_soc_cnew(&w->kcontrols[i], w,
@@ -687,6 +707,7 @@ static void dbg_dump_dapm(struct snd_soc_codec* codec, const char *action)
687 case snd_soc_dapm_adc: 707 case snd_soc_dapm_adc:
688 case snd_soc_dapm_pga: 708 case snd_soc_dapm_pga:
689 case snd_soc_dapm_mixer: 709 case snd_soc_dapm_mixer:
710 case snd_soc_dapm_mixer_named_ctl:
690 if (w->name) { 711 if (w->name) {
691 in = is_connected_input_ep(w); 712 in = is_connected_input_ep(w);
692 dapm_clear_walk(w->codec); 713 dapm_clear_walk(w->codec);
@@ -760,6 +781,7 @@ static int dapm_mixer_update_power(struct snd_soc_dapm_widget *widget,
760 int found = 0; 781 int found = 0;
761 782
762 if (widget->id != snd_soc_dapm_mixer && 783 if (widget->id != snd_soc_dapm_mixer &&
784 widget->id != snd_soc_dapm_mixer_named_ctl &&
763 widget->id != snd_soc_dapm_switch) 785 widget->id != snd_soc_dapm_switch)
764 return -ENODEV; 786 return -ENODEV;
765 787
@@ -813,6 +835,7 @@ static ssize_t dapm_widget_show(struct device *dev,
813 case snd_soc_dapm_adc: 835 case snd_soc_dapm_adc:
814 case snd_soc_dapm_pga: 836 case snd_soc_dapm_pga:
815 case snd_soc_dapm_mixer: 837 case snd_soc_dapm_mixer:
838 case snd_soc_dapm_mixer_named_ctl:
816 if (w->name) 839 if (w->name)
817 count += sprintf(buf + count, "%s: %s\n", 840 count += sprintf(buf + count, "%s: %s\n",
818 w->name, w->power ? "On":"Off"); 841 w->name, w->power ? "On":"Off");
@@ -876,7 +899,7 @@ static void dapm_free_widgets(struct snd_soc_codec *codec)
876} 899}
877 900
878static int snd_soc_dapm_set_pin(struct snd_soc_codec *codec, 901static int snd_soc_dapm_set_pin(struct snd_soc_codec *codec,
879 char *pin, int status) 902 const char *pin, int status)
880{ 903{
881 struct snd_soc_dapm_widget *w; 904 struct snd_soc_dapm_widget *w;
882 905
@@ -991,6 +1014,7 @@ static int snd_soc_dapm_add_route(struct snd_soc_codec *codec,
991 break; 1014 break;
992 case snd_soc_dapm_switch: 1015 case snd_soc_dapm_switch:
993 case snd_soc_dapm_mixer: 1016 case snd_soc_dapm_mixer:
1017 case snd_soc_dapm_mixer_named_ctl:
994 ret = dapm_connect_mixer(codec, wsource, wsink, path, control); 1018 ret = dapm_connect_mixer(codec, wsource, wsink, path, control);
995 if (ret != 0) 1019 if (ret != 0)
996 goto err; 1020 goto err;
@@ -1068,6 +1092,7 @@ int snd_soc_dapm_new_widgets(struct snd_soc_codec *codec)
1068 switch(w->id) { 1092 switch(w->id) {
1069 case snd_soc_dapm_switch: 1093 case snd_soc_dapm_switch:
1070 case snd_soc_dapm_mixer: 1094 case snd_soc_dapm_mixer:
1095 case snd_soc_dapm_mixer_named_ctl:
1071 dapm_new_mixer(codec, w); 1096 dapm_new_mixer(codec, w);
1072 break; 1097 break;
1073 case snd_soc_dapm_mux: 1098 case snd_soc_dapm_mux:
@@ -1549,7 +1574,7 @@ int snd_soc_dapm_set_bias_level(struct snd_soc_device *socdev,
1549 * NOTE: snd_soc_dapm_sync() needs to be called after this for DAPM to 1574 * NOTE: snd_soc_dapm_sync() needs to be called after this for DAPM to
1550 * do any widget power switching. 1575 * do any widget power switching.
1551 */ 1576 */
1552int snd_soc_dapm_enable_pin(struct snd_soc_codec *codec, char *pin) 1577int snd_soc_dapm_enable_pin(struct snd_soc_codec *codec, const char *pin)
1553{ 1578{
1554 return snd_soc_dapm_set_pin(codec, pin, 1); 1579 return snd_soc_dapm_set_pin(codec, pin, 1);
1555} 1580}
@@ -1564,7 +1589,7 @@ EXPORT_SYMBOL_GPL(snd_soc_dapm_enable_pin);
1564 * NOTE: snd_soc_dapm_sync() needs to be called after this for DAPM to 1589 * NOTE: snd_soc_dapm_sync() needs to be called after this for DAPM to
1565 * do any widget power switching. 1590 * do any widget power switching.
1566 */ 1591 */
1567int snd_soc_dapm_disable_pin(struct snd_soc_codec *codec, char *pin) 1592int snd_soc_dapm_disable_pin(struct snd_soc_codec *codec, const char *pin)
1568{ 1593{
1569 return snd_soc_dapm_set_pin(codec, pin, 0); 1594 return snd_soc_dapm_set_pin(codec, pin, 0);
1570} 1595}
@@ -1584,7 +1609,7 @@ EXPORT_SYMBOL_GPL(snd_soc_dapm_disable_pin);
1584 * NOTE: snd_soc_dapm_sync() needs to be called after this for DAPM to 1609 * NOTE: snd_soc_dapm_sync() needs to be called after this for DAPM to
1585 * do any widget power switching. 1610 * do any widget power switching.
1586 */ 1611 */
1587int snd_soc_dapm_nc_pin(struct snd_soc_codec *codec, char *pin) 1612int snd_soc_dapm_nc_pin(struct snd_soc_codec *codec, const char *pin)
1588{ 1613{
1589 return snd_soc_dapm_set_pin(codec, pin, 0); 1614 return snd_soc_dapm_set_pin(codec, pin, 0);
1590} 1615}
@@ -1599,7 +1624,7 @@ EXPORT_SYMBOL_GPL(snd_soc_dapm_nc_pin);
1599 * 1624 *
1600 * Returns 1 for connected otherwise 0. 1625 * Returns 1 for connected otherwise 0.
1601 */ 1626 */
1602int snd_soc_dapm_get_pin_status(struct snd_soc_codec *codec, char *pin) 1627int snd_soc_dapm_get_pin_status(struct snd_soc_codec *codec, const char *pin)
1603{ 1628{
1604 struct snd_soc_dapm_widget *w; 1629 struct snd_soc_dapm_widget *w;
1605 1630