diff options
author | Misael Lopez Cruz | 2013-05-02 18:11:17 -0500 |
---|---|---|
committer | Vishal Mahaveer | 2015-10-08 06:15:41 -0500 |
commit | 3ab125a06d9e9b7db759370baf13572d4149f703 (patch) | |
tree | 031c445c5050992c1c847cfe5014b18ca9251157 | |
parent | 49a61374fc18a0f39da0d9c11cc9ccc3e9c1ec3f (diff) | |
download | platform-external-tinyalsa-d-marshmallow-release.tar.gz platform-external-tinyalsa-d-marshmallow-release.tar.xz platform-external-tinyalsa-d-marshmallow-release.zip |
mixer: Add get_card_name() APId-marshmallow-release
Add mixer_get_card_name() so that clients can retrieve card's
name based on its id.
Change-Id: Ic29e5e8c8098c578aadb8e104c4cd48e0871afeb
Signed-off-by: Misael Lopez Cruz <misael.lopez@ti.com>
-rw-r--r-- | include/tinyalsa/asoundlib.h | 6 | ||||
-rw-r--r-- | mixer.c | 32 |
2 files changed, 38 insertions, 0 deletions
diff --git a/include/tinyalsa/asoundlib.h b/include/tinyalsa/asoundlib.h index 1554b52..af8d826 100644 --- a/include/tinyalsa/asoundlib.h +++ b/include/tinyalsa/asoundlib.h | |||
@@ -150,6 +150,12 @@ enum mixer_ctl_type { | |||
150 | MIXER_CTL_TYPE_MAX, | 150 | MIXER_CTL_TYPE_MAX, |
151 | }; | 151 | }; |
152 | 152 | ||
153 | #ifdef OMAP_ENHANCEMENT | ||
154 | #define MAX_CARD_COUNT 32 | ||
155 | |||
156 | int mixer_get_card_name(int card, char *str, size_t strlen); | ||
157 | #endif | ||
158 | |||
153 | /* Open and close a stream */ | 159 | /* Open and close a stream */ |
154 | struct pcm *pcm_open(unsigned int card, unsigned int device, | 160 | struct pcm *pcm_open(unsigned int card, unsigned int device, |
155 | unsigned int flags, struct pcm_config *config); | 161 | unsigned int flags, struct pcm_config *config); |
@@ -505,3 +505,35 @@ int mixer_ctl_set_enum_by_string(struct mixer_ctl *ctl, const char *string) | |||
505 | return -EINVAL; | 505 | return -EINVAL; |
506 | } | 506 | } |
507 | 507 | ||
508 | #ifdef OMAP_ENHANCEMENT | ||
509 | int mixer_get_card_name(int card, char *str, size_t strlen) | ||
510 | { | ||
511 | struct snd_ctl_card_info info; | ||
512 | char fn[256]; | ||
513 | int fd; | ||
514 | int ret; | ||
515 | |||
516 | if (card > MAX_CARD_COUNT) | ||
517 | return -EINVAL; | ||
518 | |||
519 | if (!str) | ||
520 | return -EINVAL; | ||
521 | |||
522 | snprintf(fn, sizeof(fn), "/dev/snd/controlC%u", card); | ||
523 | fd = open(fn, O_RDWR); | ||
524 | if (fd < 0) | ||
525 | return -ENODEV; | ||
526 | |||
527 | ret = ioctl(fd, SNDRV_CTL_IOCTL_CARD_INFO, &info); | ||
528 | if (ret < 0) { | ||
529 | close(fd); | ||
530 | return ret; | ||
531 | } | ||
532 | |||
533 | strncpy(str, (char *)info.id, strlen); | ||
534 | |||
535 | close(fd); | ||
536 | |||
537 | return 0; | ||
538 | } | ||
539 | #endif | ||