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.c81
1 files changed, 51 insertions, 30 deletions
diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c
index 91cbbefefb0a..94296b5dc58f 100644
--- a/sound/soc/soc-dapm.c
+++ b/sound/soc/soc-dapm.c
@@ -880,8 +880,25 @@ static void dapm_free_widgets(struct snd_soc_codec *codec)
880 } 880 }
881} 881}
882 882
883static int snd_soc_dapm_set_pin(struct snd_soc_codec *codec,
884 char *pin, int status)
885{
886 struct snd_soc_dapm_widget *w;
887
888 list_for_each_entry(w, &codec->dapm_widgets, list) {
889 if (!strcmp(w->name, pin)) {
890 dbg("dapm: %s: pin %s\n", codec->name, pin);
891 w->connected = status;
892 return 0;
893 }
894 }
895
896 dbg("dapm: %s: configuring unknown pin %s\n", codec->name, pin);
897 return -EINVAL;
898}
899
883/** 900/**
884 * snd_soc_dapm_sync_endpoints - scan and power dapm paths 901 * snd_soc_dapm_sync - scan and power dapm paths
885 * @codec: audio codec 902 * @codec: audio codec
886 * 903 *
887 * Walks all dapm audio paths and powers widgets according to their 904 * Walks all dapm audio paths and powers widgets according to their
@@ -889,11 +906,11 @@ static void dapm_free_widgets(struct snd_soc_codec *codec)
889 * 906 *
890 * Returns 0 for success. 907 * Returns 0 for success.
891 */ 908 */
892int snd_soc_dapm_sync_endpoints(struct snd_soc_codec *codec) 909int snd_soc_dapm_sync(struct snd_soc_codec *codec)
893{ 910{
894 return dapm_power_widgets(codec, SND_SOC_DAPM_STREAM_NOP); 911 return dapm_power_widgets(codec, SND_SOC_DAPM_STREAM_NOP);
895} 912}
896EXPORT_SYMBOL_GPL(snd_soc_dapm_sync_endpoints); 913EXPORT_SYMBOL_GPL(snd_soc_dapm_sync);
897 914
898static int snd_soc_dapm_add_route(struct snd_soc_codec *codec, 915static int snd_soc_dapm_add_route(struct snd_soc_codec *codec,
899 const char *sink, const char *control, const char *source) 916 const char *sink, const char *control, const char *source)
@@ -1441,53 +1458,57 @@ int snd_soc_dapm_set_bias_level(struct snd_soc_device *socdev,
1441} 1458}
1442 1459
1443/** 1460/**
1444 * snd_soc_dapm_set_endpoint - set audio endpoint status 1461 * snd_soc_dapm_enable_pin - enable pin.
1445 * @codec: audio codec 1462 * @snd_soc_codec: SoC codec
1446 * @endpoint: audio signal endpoint (or start point) 1463 * @pin: pin name
1447 * @status: point status
1448 *
1449 * Set audio endpoint status - connected or disconnected.
1450 * 1464 *
1451 * Returns 0 for success else error. 1465 * Enables input/output pin and it's parents or children widgets iff there is
1466 * a valid audio route and active audio stream.
1467 * NOTE: snd_soc_dapm_sync() needs to be called after this for DAPM to
1468 * do any widget power switching.
1452 */ 1469 */
1453int snd_soc_dapm_set_endpoint(struct snd_soc_codec *codec, 1470int snd_soc_dapm_enable_pin(struct snd_soc_codec *codec, char *pin)
1454 char *endpoint, int status)
1455{ 1471{
1456 struct snd_soc_dapm_widget *w; 1472 return snd_soc_dapm_set_pin(codec, pin, 1);
1457 1473}
1458 list_for_each_entry(w, &codec->dapm_widgets, list) { 1474EXPORT_SYMBOL_GPL(snd_soc_dapm_enable_pin);
1459 if (!strcmp(w->name, endpoint)) {
1460 w->connected = status;
1461 return 0;
1462 }
1463 }
1464 1475
1465 return -ENODEV; 1476/**
1477 * snd_soc_dapm_disable_pin - disable pin.
1478 * @codec: SoC codec
1479 * @pin: pin name
1480 *
1481 * Disables input/output pin and it's parents or children widgets.
1482 * NOTE: snd_soc_dapm_sync() needs to be called after this for DAPM to
1483 * do any widget power switching.
1484 */
1485int snd_soc_dapm_disable_pin(struct snd_soc_codec *codec, char *pin)
1486{
1487 return snd_soc_dapm_set_pin(codec, pin, 0);
1466} 1488}
1467EXPORT_SYMBOL_GPL(snd_soc_dapm_set_endpoint); 1489EXPORT_SYMBOL_GPL(snd_soc_dapm_disable_pin);
1468 1490
1469/** 1491/**
1470 * snd_soc_dapm_get_endpoint_status - get audio endpoint status 1492 * snd_soc_dapm_get_pin_status - get audio pin status
1471 * @codec: audio codec 1493 * @codec: audio codec
1472 * @endpoint: audio signal endpoint (or start point) 1494 * @pin: audio signal pin endpoint (or start point)
1473 * 1495 *
1474 * Get audio endpoint status - connected or disconnected. 1496 * Get audio pin status - connected or disconnected.
1475 * 1497 *
1476 * Returns status 1498 * Returns 1 for connected otherwise 0.
1477 */ 1499 */
1478int snd_soc_dapm_get_endpoint_status(struct snd_soc_codec *codec, 1500int snd_soc_dapm_get_pin_status(struct snd_soc_codec *codec, char *pin)
1479 char *endpoint)
1480{ 1501{
1481 struct snd_soc_dapm_widget *w; 1502 struct snd_soc_dapm_widget *w;
1482 1503
1483 list_for_each_entry(w, &codec->dapm_widgets, list) { 1504 list_for_each_entry(w, &codec->dapm_widgets, list) {
1484 if (!strcmp(w->name, endpoint)) 1505 if (!strcmp(w->name, pin))
1485 return w->connected; 1506 return w->connected;
1486 } 1507 }
1487 1508
1488 return 0; 1509 return 0;
1489} 1510}
1490EXPORT_SYMBOL_GPL(snd_soc_dapm_get_endpoint_status); 1511EXPORT_SYMBOL_GPL(snd_soc_dapm_get_pin_status);
1491 1512
1492/** 1513/**
1493 * snd_soc_dapm_free - free dapm resources 1514 * snd_soc_dapm_free - free dapm resources