summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 8863816)
raw | patch | inline | side by side (parent: 8863816)
author | Misael Lopez Cruz <misael.lopez@ti.com> | |
Thu, 2 May 2013 23:11:17 +0000 (18:11 -0500) | ||
committer | Vishal Mahaveer <vishalm@ti.com> | |
Wed, 12 Nov 2014 23:51:42 +0000 (17:51 -0600) |
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>
name based on its id.
Change-Id: Ic29e5e8c8098c578aadb8e104c4cd48e0871afeb
Signed-off-by: Misael Lopez Cruz <misael.lopez@ti.com>
include/tinyalsa/asoundlib.h | patch | blob | history | |
mixer.c | patch | blob | history |
index 75e5cda3e9a25e3ad9ab1baa4f45f3263060e42b..4b6e4ecaf8fbbf64273794fbac91fe0e407a7095 100644 (file)
MIXER_CTL_TYPE_MAX,
};
+#ifdef OMAP_ENHANCEMENT
+#define MAX_CARD_COUNT 32
+
+int mixer_get_card_name(int card, char *str, size_t strlen);
+#endif
+
/* Open and close a stream */
struct pcm *pcm_open(unsigned int card, unsigned int device,
unsigned int flags, struct pcm_config *config);
index 4568cca2bfed71746b551b397f2a12e09207b894..8a0add01c2823b856751c2f9c8016382f776eefa 100644 (file)
--- a/mixer.c
+++ b/mixer.c
return -EINVAL;
}
+#ifdef OMAP_ENHANCEMENT
+int mixer_get_card_name(int card, char *str, size_t strlen)
+{
+ struct snd_ctl_card_info info;
+ char fn[256];
+ int fd;
+ int ret;
+
+ if (card > MAX_CARD_COUNT)
+ return -EINVAL;
+
+ if (!str)
+ return -EINVAL;
+
+ snprintf(fn, sizeof(fn), "/dev/snd/controlC%u", card);
+ fd = open(fn, O_RDWR);
+ if (fd < 0)
+ return -ENODEV;
+
+ ret = ioctl(fd, SNDRV_CTL_IOCTL_CARD_INFO, &info);
+ if (ret < 0) {
+ close(fd);
+ return ret;
+ }
+
+ strncpy(str, (char *)info.id, strlen);
+
+ close(fd);
+
+ return 0;
+}
+#endif