]> err.no Git - linux-2.6/commitdiff
[ALSA] usb-audio - add selector unit names override for Audigy 2 NX
authorClemens Ladisch <clemens@ladisch.de>
Fri, 22 Apr 2005 13:49:52 +0000 (15:49 +0200)
committerJaroslav Kysela <perex@suse.cz>
Sun, 29 May 2005 08:05:11 +0000 (10:05 +0200)
USB generic driver
Add a mechanism to specify source names of selector units,
and add such names for the SB Audigy 2 NX.

Signed-off-by: Clemens Ladisch <clemens@ladisch.de>
sound/usb/usbmixer.c
sound/usb/usbmixer_maps.c

index 5f1906915aa626f66cd6e527e2484d92772c6530..6ad154aaba1bd5a84a1185d1123b70e14f76b6b3 100644 (file)
@@ -70,6 +70,7 @@ struct usb_mixer_build {
        DECLARE_BITMAP(unitbitmap, 32*32);
        usb_audio_term_t oterm;
        const struct usbmix_name_map *map;
+       const struct usbmix_selector_map *selector_map;
 };
 
 struct usb_mixer_elem_info {
@@ -187,6 +188,21 @@ static int check_ignored_ctl(mixer_build_t *state, int unitid, int control)
        return 0;
 }
 
+/* get the mapped selector source name */
+static int check_mapped_selector_name(mixer_build_t *state, int unitid,
+                                     int index, char *buf, int buflen)
+{
+       const struct usbmix_selector_map *p;
+
+       if (! state->selector_map)
+               return 0;
+       for (p = state->selector_map; p->id; p++) {
+               if (p->id == unitid && index < p->count)
+                       return strlcpy(buf, p->names[index], buflen);
+       }
+       return 0;
+}
+
 /*
  * find an audio control unit with the given unit id
  */
@@ -1415,7 +1431,9 @@ static int parse_audio_selector_unit(mixer_build_t *state, int unitid, unsigned
                        kfree(cval);
                        return -ENOMEM;
                }
-               if (check_input_term(state, desc[5 + i], &iterm) >= 0)
+               len = check_mapped_selector_name(state, unitid, i, namelist[i],
+                                                MAX_ITEM_NAME_LEN);
+               if (! len && check_input_term(state, desc[5 + i], &iterm) >= 0)
                        len = get_term_name(state, &iterm, namelist[i], MAX_ITEM_NAME_LEN, 0);
                if (! len)
                        sprintf(namelist[i], "Input %d", i);
@@ -1521,6 +1539,7 @@ int snd_usb_create_mixer(snd_usb_audio_t *chip, int ctrlif)
        for (map = usbmix_ctl_maps; map->vendor; map++) {
                if (map->vendor == state.vendor && map->product == state.product) {
                        state.map = map->map;
+                       state.selector_map = map->selector_map;
                        chip->ignore_ctl_error = map->ignore_ctl_error;
                        break;
                }
index 4918a18542232b5b19092f3647d97d8596b99411..adb0abb3ee85f9633b5b31cab1812052758a99ea 100644 (file)
@@ -26,10 +26,17 @@ struct usbmix_name_map {
        int control;
 };
 
+struct usbmix_selector_map {
+       int id;
+       int count;
+       const char **names;
+};
+
 struct usbmix_ctl_map {
        int vendor;
        int product;
        const struct usbmix_name_map *map;
+       const struct usbmix_selector_map *selector_map;
        int ignore_ctl_error;
 };
 
@@ -162,6 +169,25 @@ static struct usbmix_name_map audigy2nx_map[] = {
        { 0 } /* terminator */
 };
 
+static struct usbmix_selector_map audigy2nx_selectors[] = {
+       {
+               .id = 14, /* Capture Source */
+               .count = 3,
+               .names = (const char*[]) {"Line", "Digital In", "What-U-Hear"}
+       },
+       {
+               .id = 29, /* Digital Out Source */
+               .count = 3,
+               .names = (const char*[]) {"Front", "PCM", "Digital In"}
+       },
+       {
+               .id = 31, /* Headphone Source */
+               .count = 2,
+               .names = (const char*[]) {"Front", "Side"}
+       },
+       { 0 } /* terminator */
+};
+
 /* LineX FM Transmitter entry - needed to bypass controls bug */
 static struct usbmix_name_map linex_map[] = {
        /* 1: IT pcm */
@@ -198,11 +224,29 @@ static struct usbmix_name_map justlink_map[] = {
  */
 
 static struct usbmix_ctl_map usbmix_ctl_maps[] = {
-       { 0x41e, 0x3000, extigy_map, 1 },
-       { 0x41e, 0x3010, mp3plus_map, 0 },
-       { 0x41e, 0x3020, audigy2nx_map, 0 },
-       { 0x8bb, 0x2702, linex_map, 1 },
-       { 0xc45, 0x1158, justlink_map, 0 },
+       {
+               .vendor = 0x41e, .product = 0x3000,
+               .map = extigy_map,
+               .ignore_ctl_error = 1,
+       },
+       {
+               .vendor = 0x41e, .product = 0x3010,
+               .map = mp3plus_map,
+       },
+       {
+               .vendor = 0x41e, .product = 0x3020,
+               .map = audigy2nx_map,
+               .selector_map = audigy2nx_selectors,
+       },
+       {
+               .vendor = 0x8bb, .product = 0x2702,
+               .map = linex_map,
+               .ignore_ctl_error = 1,
+       },
+       {
+               .vendor = 0xc45, .product = 0x1158,
+               .map = justlink_map,
+       },
        { 0 } /* terminator */
 };