aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMisael Lopez Cruz2013-05-02 18:11:17 -0500
committerVishal Mahaveer2014-11-12 17:51:42 -0600
commit78a059042cc488d9d52072695f6453f37e4534e1 (patch)
tree8a76f442f4d6314ff830a8c68ff426d2d389af0a
parent8863816dc5659a1e4678d17906c90844264d1588 (diff)
downloadplatform-external-tinyalsa-master.tar.gz
platform-external-tinyalsa-master.tar.xz
platform-external-tinyalsa-master.zip
mixer: Add get_card_name() APIHEADmasterd-lollipop-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.h6
-rw-r--r--mixer.c32
2 files changed, 38 insertions, 0 deletions
diff --git a/include/tinyalsa/asoundlib.h b/include/tinyalsa/asoundlib.h
index 75e5cda..4b6e4ec 100644
--- a/include/tinyalsa/asoundlib.h
+++ b/include/tinyalsa/asoundlib.h
@@ -147,6 +147,12 @@ enum mixer_ctl_type {
147 MIXER_CTL_TYPE_MAX, 147 MIXER_CTL_TYPE_MAX,
148}; 148};
149 149
150#ifdef OMAP_ENHANCEMENT
151#define MAX_CARD_COUNT 32
152
153int mixer_get_card_name(int card, char *str, size_t strlen);
154#endif
155
150/* Open and close a stream */ 156/* Open and close a stream */
151struct pcm *pcm_open(unsigned int card, unsigned int device, 157struct pcm *pcm_open(unsigned int card, unsigned int device,
152 unsigned int flags, struct pcm_config *config); 158 unsigned int flags, struct pcm_config *config);
diff --git a/mixer.c b/mixer.c
index 4568cca..8a0add0 100644
--- a/mixer.c
+++ b/mixer.c
@@ -495,3 +495,35 @@ int mixer_ctl_set_enum_by_string(struct mixer_ctl *ctl, const char *string)
495 return -EINVAL; 495 return -EINVAL;
496} 496}
497 497
498#ifdef OMAP_ENHANCEMENT
499int mixer_get_card_name(int card, char *str, size_t strlen)
500{
501 struct snd_ctl_card_info info;
502 char fn[256];
503 int fd;
504 int ret;
505
506 if (card > MAX_CARD_COUNT)
507 return -EINVAL;
508
509 if (!str)
510 return -EINVAL;
511
512 snprintf(fn, sizeof(fn), "/dev/snd/controlC%u", card);
513 fd = open(fn, O_RDWR);
514 if (fd < 0)
515 return -ENODEV;
516
517 ret = ioctl(fd, SNDRV_CTL_IOCTL_CARD_INFO, &info);
518 if (ret < 0) {
519 close(fd);
520 return ret;
521 }
522
523 strncpy(str, (char *)info.id, strlen);
524
525 close(fd);
526
527 return 0;
528}
529#endif