aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Wilson2013-06-28 18:47:16 -0500
committerSimon Wilson2013-06-28 18:47:19 -0500
commit7e8a656722b3b19d499ad89c9c1e46b8be3da896 (patch)
treebfe28387934c5cbfa3f636f8115a6561878334bc
parent8813fe8c9c7bfe5722932166d379bc79e9dedf1d (diff)
downloadplatform-external-tinyalsa-7e8a656722b3b19d499ad89c9c1e46b8be3da896.tar.gz
platform-external-tinyalsa-7e8a656722b3b19d499ad89c9c1e46b8be3da896.tar.xz
platform-external-tinyalsa-7e8a656722b3b19d499ad89c9c1e46b8be3da896.zip
Update to latest tinyalsa
ec28139 mixer: add mixer_get_name() API 710df88 mixer: add mixer_ctl_update() API Change-Id: I0cabe7e673a53f4358b5dbae4a17112eff5a2848
-rw-r--r--include/tinyalsa/asoundlib.h9
-rw-r--r--mixer.c28
-rw-r--r--tinymix.c2
3 files changed, 32 insertions, 7 deletions
diff --git a/include/tinyalsa/asoundlib.h b/include/tinyalsa/asoundlib.h
index 2e16392..4dfffd9 100644
--- a/include/tinyalsa/asoundlib.h
+++ b/include/tinyalsa/asoundlib.h
@@ -211,6 +211,9 @@ struct mixer_ctl;
211struct mixer *mixer_open(unsigned int card); 211struct mixer *mixer_open(unsigned int card);
212void mixer_close(struct mixer *mixer); 212void mixer_close(struct mixer *mixer);
213 213
214/* Get info about a mixer */
215const char *mixer_get_name(struct mixer *mixer);
216
214/* Obtain mixer controls */ 217/* Obtain mixer controls */
215unsigned int mixer_get_num_ctls(struct mixer *mixer); 218unsigned int mixer_get_num_ctls(struct mixer *mixer);
216struct mixer_ctl *mixer_get_ctl(struct mixer *mixer, unsigned int id); 219struct mixer_ctl *mixer_get_ctl(struct mixer *mixer, unsigned int id);
@@ -225,6 +228,12 @@ unsigned int mixer_ctl_get_num_enums(struct mixer_ctl *ctl);
225const char *mixer_ctl_get_enum_string(struct mixer_ctl *ctl, 228const char *mixer_ctl_get_enum_string(struct mixer_ctl *ctl,
226 unsigned int enum_id); 229 unsigned int enum_id);
227 230
231/* Some sound cards update their controls due to external events,
232 * such as HDMI EDID byte data changing when an HDMI cable is
233 * connected. This API allows the count of elements to be updated.
234 */
235void mixer_ctl_update(struct mixer_ctl *ctl);
236
228/* Set and get mixer controls */ 237/* Set and get mixer controls */
229int mixer_ctl_get_percent(struct mixer_ctl *ctl, unsigned int id); 238int mixer_ctl_get_percent(struct mixer_ctl *ctl, unsigned int id);
230int mixer_ctl_set_percent(struct mixer_ctl *ctl, unsigned int id, int percent); 239int mixer_ctl_set_percent(struct mixer_ctl *ctl, unsigned int id, int percent);
diff --git a/mixer.c b/mixer.c
index 7419d3f..4568cca 100644
--- a/mixer.c
+++ b/mixer.c
@@ -52,7 +52,8 @@ struct mixer_ctl {
52 52
53struct mixer { 53struct mixer {
54 int fd; 54 int fd;
55 struct snd_ctl_elem_info *info; 55 struct snd_ctl_card_info card_info;
56 struct snd_ctl_elem_info *elem_info;
56 struct mixer_ctl *ctl; 57 struct mixer_ctl *ctl;
57 unsigned int count; 58 unsigned int count;
58}; 59};
@@ -79,8 +80,8 @@ void mixer_close(struct mixer *mixer)
79 free(mixer->ctl); 80 free(mixer->ctl);
80 } 81 }
81 82
82 if (mixer->info) 83 if (mixer->elem_info)
83 free(mixer->info); 84 free(mixer->elem_info);
84 85
85 free(mixer); 86 free(mixer);
86 87
@@ -111,8 +112,11 @@ struct mixer *mixer_open(unsigned int card)
111 goto fail; 112 goto fail;
112 113
113 mixer->ctl = calloc(elist.count, sizeof(struct mixer_ctl)); 114 mixer->ctl = calloc(elist.count, sizeof(struct mixer_ctl));
114 mixer->info = calloc(elist.count, sizeof(struct snd_ctl_elem_info)); 115 mixer->elem_info = calloc(elist.count, sizeof(struct snd_ctl_elem_info));
115 if (!mixer->ctl || !mixer->info) 116 if (!mixer->ctl || !mixer->elem_info)
117 goto fail;
118
119 if (ioctl(fd, SNDRV_CTL_IOCTL_CARD_INFO, &mixer->card_info) < 0)
116 goto fail; 120 goto fail;
117 121
118 eid = calloc(elist.count, sizeof(struct snd_ctl_elem_id)); 122 eid = calloc(elist.count, sizeof(struct snd_ctl_elem_id));
@@ -127,7 +131,7 @@ struct mixer *mixer_open(unsigned int card)
127 goto fail; 131 goto fail;
128 132
129 for (n = 0; n < mixer->count; n++) { 133 for (n = 0; n < mixer->count; n++) {
130 struct snd_ctl_elem_info *ei = mixer->info + n; 134 struct snd_ctl_elem_info *ei = mixer->elem_info + n;
131 ei->id.numid = eid[n].numid; 135 ei->id.numid = eid[n].numid;
132 if (ioctl(fd, SNDRV_CTL_IOCTL_ELEM_INFO, ei) < 0) 136 if (ioctl(fd, SNDRV_CTL_IOCTL_ELEM_INFO, ei) < 0)
133 goto fail; 137 goto fail;
@@ -165,6 +169,11 @@ fail:
165 return 0; 169 return 0;
166} 170}
167 171
172const char *mixer_get_name(struct mixer *mixer)
173{
174 return (const char *)mixer->card_info.name;
175}
176
168unsigned int mixer_get_num_ctls(struct mixer *mixer) 177unsigned int mixer_get_num_ctls(struct mixer *mixer)
169{ 178{
170 if (!mixer) 179 if (!mixer)
@@ -189,12 +198,17 @@ struct mixer_ctl *mixer_get_ctl_by_name(struct mixer *mixer, const char *name)
189 return NULL; 198 return NULL;
190 199
191 for (n = 0; n < mixer->count; n++) 200 for (n = 0; n < mixer->count; n++)
192 if (!strcmp(name, (char*) mixer->info[n].id.name)) 201 if (!strcmp(name, (char*) mixer->elem_info[n].id.name))
193 return mixer->ctl + n; 202 return mixer->ctl + n;
194 203
195 return NULL; 204 return NULL;
196} 205}
197 206
207void mixer_ctl_update(struct mixer_ctl *ctl)
208{
209 ioctl(ctl->mixer->fd, SNDRV_CTL_IOCTL_ELEM_INFO, ctl->info);
210}
211
198const char *mixer_ctl_get_name(struct mixer_ctl *ctl) 212const char *mixer_ctl_get_name(struct mixer_ctl *ctl)
199{ 213{
200 if (!ctl) 214 if (!ctl)
diff --git a/tinymix.c b/tinymix.c
index 962450e..da0c463 100644
--- a/tinymix.c
+++ b/tinymix.c
@@ -61,6 +61,8 @@ int main(int argc, char **argv)
61 return EXIT_FAILURE; 61 return EXIT_FAILURE;
62 } 62 }
63 63
64 printf("Mixer name: '%s'\n", mixer_get_name(mixer));
65
64 if (argc == 1) 66 if (argc == 1)
65 tinymix_list_controls(mixer); 67 tinymix_list_controls(mixer);
66 else if (argc == 2) 68 else if (argc == 2)