diff options
-rw-r--r-- | include/sound/soc-dapm.h | 12 | ||||
-rw-r--r-- | sound/soc/soc-dapm.c | 70 |
2 files changed, 82 insertions, 0 deletions
diff --git a/include/sound/soc-dapm.h b/include/sound/soc-dapm.h index bb3a863ad14e..a7def6a9a030 100644 --- a/include/sound/soc-dapm.h +++ b/include/sound/soc-dapm.h | |||
@@ -192,6 +192,12 @@ | |||
192 | .get = snd_soc_dapm_get_value_enum_double, \ | 192 | .get = snd_soc_dapm_get_value_enum_double, \ |
193 | .put = snd_soc_dapm_put_value_enum_double, \ | 193 | .put = snd_soc_dapm_put_value_enum_double, \ |
194 | .private_value = (unsigned long)&xenum } | 194 | .private_value = (unsigned long)&xenum } |
195 | #define SOC_DAPM_PIN_SWITCH(xname) \ | ||
196 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname " Switch", \ | ||
197 | .info = snd_soc_dapm_info_pin_switch, \ | ||
198 | .get = snd_soc_dapm_get_pin_switch, \ | ||
199 | .put = snd_soc_dapm_put_pin_switch, \ | ||
200 | .private_value = (unsigned long)xname } | ||
195 | 201 | ||
196 | /* dapm stream operations */ | 202 | /* dapm stream operations */ |
197 | #define SND_SOC_DAPM_STREAM_NOP 0x0 | 203 | #define SND_SOC_DAPM_STREAM_NOP 0x0 |
@@ -238,6 +244,12 @@ int snd_soc_dapm_get_value_enum_double(struct snd_kcontrol *kcontrol, | |||
238 | struct snd_ctl_elem_value *ucontrol); | 244 | struct snd_ctl_elem_value *ucontrol); |
239 | int snd_soc_dapm_put_value_enum_double(struct snd_kcontrol *kcontrol, | 245 | int snd_soc_dapm_put_value_enum_double(struct snd_kcontrol *kcontrol, |
240 | struct snd_ctl_elem_value *ucontrol); | 246 | struct snd_ctl_elem_value *ucontrol); |
247 | int snd_soc_dapm_info_pin_switch(struct snd_kcontrol *kcontrol, | ||
248 | struct snd_ctl_elem_info *uinfo); | ||
249 | int snd_soc_dapm_get_pin_switch(struct snd_kcontrol *kcontrol, | ||
250 | struct snd_ctl_elem_value *uncontrol); | ||
251 | int snd_soc_dapm_put_pin_switch(struct snd_kcontrol *kcontrol, | ||
252 | struct snd_ctl_elem_value *uncontrol); | ||
241 | int snd_soc_dapm_new_control(struct snd_soc_codec *codec, | 253 | int snd_soc_dapm_new_control(struct snd_soc_codec *codec, |
242 | const struct snd_soc_dapm_widget *widget); | 254 | const struct snd_soc_dapm_widget *widget); |
243 | int snd_soc_dapm_new_controls(struct snd_soc_codec *codec, | 255 | int snd_soc_dapm_new_controls(struct snd_soc_codec *codec, |
diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c index f4a8753c84c0..4b8dbbfe2efb 100644 --- a/sound/soc/soc-dapm.c +++ b/sound/soc/soc-dapm.c | |||
@@ -1421,6 +1421,76 @@ out: | |||
1421 | EXPORT_SYMBOL_GPL(snd_soc_dapm_put_value_enum_double); | 1421 | EXPORT_SYMBOL_GPL(snd_soc_dapm_put_value_enum_double); |
1422 | 1422 | ||
1423 | /** | 1423 | /** |
1424 | * snd_soc_dapm_info_pin_switch - Info for a pin switch | ||
1425 | * | ||
1426 | * @kcontrol: mixer control | ||
1427 | * @uinfo: control element information | ||
1428 | * | ||
1429 | * Callback to provide information about a pin switch control. | ||
1430 | */ | ||
1431 | int snd_soc_dapm_info_pin_switch(struct snd_kcontrol *kcontrol, | ||
1432 | struct snd_ctl_elem_info *uinfo) | ||
1433 | { | ||
1434 | uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN; | ||
1435 | uinfo->count = 1; | ||
1436 | uinfo->value.integer.min = 0; | ||
1437 | uinfo->value.integer.max = 1; | ||
1438 | |||
1439 | return 0; | ||
1440 | } | ||
1441 | EXPORT_SYMBOL_GPL(snd_soc_dapm_info_pin_switch); | ||
1442 | |||
1443 | /** | ||
1444 | * snd_soc_dapm_get_pin_switch - Get information for a pin switch | ||
1445 | * | ||
1446 | * @kcontrol: mixer control | ||
1447 | * @ucontrol: Value | ||
1448 | */ | ||
1449 | int snd_soc_dapm_get_pin_switch(struct snd_kcontrol *kcontrol, | ||
1450 | struct snd_ctl_elem_value *ucontrol) | ||
1451 | { | ||
1452 | struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); | ||
1453 | const char *pin = (const char *)kcontrol->private_value; | ||
1454 | |||
1455 | mutex_lock(&codec->mutex); | ||
1456 | |||
1457 | ucontrol->value.integer.value[0] = | ||
1458 | snd_soc_dapm_get_pin_status(codec, pin); | ||
1459 | |||
1460 | mutex_unlock(&codec->mutex); | ||
1461 | |||
1462 | return 0; | ||
1463 | } | ||
1464 | EXPORT_SYMBOL_GPL(snd_soc_dapm_get_pin_switch); | ||
1465 | |||
1466 | /** | ||
1467 | * snd_soc_dapm_put_pin_switch - Set information for a pin switch | ||
1468 | * | ||
1469 | * @kcontrol: mixer control | ||
1470 | * @ucontrol: Value | ||
1471 | */ | ||
1472 | int snd_soc_dapm_put_pin_switch(struct snd_kcontrol *kcontrol, | ||
1473 | struct snd_ctl_elem_value *ucontrol) | ||
1474 | { | ||
1475 | struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); | ||
1476 | const char *pin = (const char *)kcontrol->private_value; | ||
1477 | |||
1478 | mutex_lock(&codec->mutex); | ||
1479 | |||
1480 | if (ucontrol->value.integer.value[0]) | ||
1481 | snd_soc_dapm_enable_pin(codec, pin); | ||
1482 | else | ||
1483 | snd_soc_dapm_disable_pin(codec, pin); | ||
1484 | |||
1485 | snd_soc_dapm_sync(codec); | ||
1486 | |||
1487 | mutex_unlock(&codec->mutex); | ||
1488 | |||
1489 | return 0; | ||
1490 | } | ||
1491 | EXPORT_SYMBOL_GPL(snd_soc_dapm_put_pin_switch); | ||
1492 | |||
1493 | /** | ||
1424 | * snd_soc_dapm_new_control - create new dapm control | 1494 | * snd_soc_dapm_new_control - create new dapm control |
1425 | * @codec: audio codec | 1495 | * @codec: audio codec |
1426 | * @widget: widget template | 1496 | * @widget: widget template |