diff options
author | Clemens Ladisch <clemens@ladisch.de> | 2005-05-02 02:51:26 -0400 |
---|---|---|
committer | Jaroslav Kysela <perex@suse.cz> | 2005-05-29 04:05:47 -0400 |
commit | 27d10f5664c7650af3b2ffadfefaf19b36dc7bd8 (patch) | |
tree | b89c8d639041f460557bf6e9078c7cee7426cd2b /sound/usb/usbmixer.c | |
parent | b259b10c420a59a2fdbcf5a3498253ebcbdffa1e (diff) |
[ALSA] usb-audio - cache vendor/product IDs
USB generic driver
Cache the decoded values of idVendor/idProduct to get rid of most of
those ugly le16_to_cpu() calls.
Signed-off-by: Clemens Ladisch <clemens@ladisch.de>
Diffstat (limited to 'sound/usb/usbmixer.c')
-rw-r--r-- | sound/usb/usbmixer.c | 38 |
1 files changed, 18 insertions, 20 deletions
diff --git a/sound/usb/usbmixer.c b/sound/usb/usbmixer.c index 7ea42d43d7ff..bfaec4fc1851 100644 --- a/sound/usb/usbmixer.c +++ b/sound/usb/usbmixer.c | |||
@@ -89,8 +89,6 @@ struct usb_mixer_build { | |||
89 | struct usb_mixer_interface *mixer; | 89 | struct usb_mixer_interface *mixer; |
90 | unsigned char *buffer; | 90 | unsigned char *buffer; |
91 | unsigned int buflen; | 91 | unsigned int buflen; |
92 | unsigned short vendor; | ||
93 | unsigned short product; | ||
94 | DECLARE_BITMAP(unitbitmap, 256); | 92 | DECLARE_BITMAP(unitbitmap, 256); |
95 | usb_audio_term_t oterm; | 93 | usb_audio_term_t oterm; |
96 | const struct usbmix_name_map *map; | 94 | const struct usbmix_name_map *map; |
@@ -906,11 +904,16 @@ static void build_feature_ctl(mixer_build_t *state, unsigned char *desc, | |||
906 | /* note that detection between firmware 2.1.1.7 (N101) and later 2.1.1.21 */ | 904 | /* note that detection between firmware 2.1.1.7 (N101) and later 2.1.1.21 */ |
907 | /* is not very clear from datasheets */ | 905 | /* is not very clear from datasheets */ |
908 | /* I hope that the min value is -15360 for newer firmware --jk */ | 906 | /* I hope that the min value is -15360 for newer firmware --jk */ |
909 | if (((state->vendor == 0x471 && (state->product == 0x104 || state->product == 0x105 || state->product == 0x101)) || | 907 | switch (state->chip->usb_id) { |
910 | (state->vendor == 0x672 && state->product == 0x1041)) && !strcmp(kctl->id.name, "PCM Playback Volume") && | 908 | case USB_ID(0x0471, 0x0101): |
911 | cval->min == -15616) { | 909 | case USB_ID(0x0471, 0x0104): |
912 | snd_printk("USB Audio: using volume control quirk for the UDA1321/N101 chip\n"); | 910 | case USB_ID(0x0471, 0x0105): |
913 | cval->max = -256; | 911 | case USB_ID(0x0672, 0x1041): |
912 | if (!strcmp(kctl->id.name, "PCM Playback Volume") && | ||
913 | cval->min == -15616) { | ||
914 | snd_printk("using volume control quirk for the UDA1321/N101 chip\n"); | ||
915 | cval->max = -256; | ||
916 | } | ||
914 | } | 917 | } |
915 | 918 | ||
916 | snd_printdd(KERN_INFO "[%d] FU [%s] ch = %d, val = %d/%d/%d\n", | 919 | snd_printdd(KERN_INFO "[%d] FU [%s] ch = %d, val = %d/%d/%d\n", |
@@ -1574,7 +1577,6 @@ static int snd_usb_mixer_controls(struct usb_mixer_interface *mixer) | |||
1574 | mixer_build_t state; | 1577 | mixer_build_t state; |
1575 | int err; | 1578 | int err; |
1576 | const struct usbmix_ctl_map *map; | 1579 | const struct usbmix_ctl_map *map; |
1577 | struct usb_device_descriptor *dev = &mixer->chip->dev->descriptor; | ||
1578 | struct usb_host_interface *hostif; | 1580 | struct usb_host_interface *hostif; |
1579 | 1581 | ||
1580 | hostif = &usb_ifnum_to_if(mixer->chip->dev, mixer->ctrlif)->altsetting[0]; | 1582 | hostif = &usb_ifnum_to_if(mixer->chip->dev, mixer->ctrlif)->altsetting[0]; |
@@ -1583,12 +1585,10 @@ static int snd_usb_mixer_controls(struct usb_mixer_interface *mixer) | |||
1583 | state.mixer = mixer; | 1585 | state.mixer = mixer; |
1584 | state.buffer = hostif->extra; | 1586 | state.buffer = hostif->extra; |
1585 | state.buflen = hostif->extralen; | 1587 | state.buflen = hostif->extralen; |
1586 | state.vendor = le16_to_cpu(dev->idVendor); | ||
1587 | state.product = le16_to_cpu(dev->idProduct); | ||
1588 | 1588 | ||
1589 | /* check the mapping table */ | 1589 | /* check the mapping table */ |
1590 | for (map = usbmix_ctl_maps; map->vendor; map++) { | 1590 | for (map = usbmix_ctl_maps; map->id; map++) { |
1591 | if (map->vendor == state.vendor && map->product == state.product) { | 1591 | if (map->id == state.chip->usb_id) { |
1592 | state.map = map->map; | 1592 | state.map = map->map; |
1593 | state.selector_map = map->selector_map; | 1593 | state.selector_map = map->selector_map; |
1594 | mixer->ignore_ctl_error = map->ignore_ctl_error; | 1594 | mixer->ignore_ctl_error = map->ignore_ctl_error; |
@@ -1766,12 +1766,12 @@ static int snd_usb_soundblaster_remote_init(struct usb_mixer_interface *mixer) | |||
1766 | snd_hwdep_t *hwdep; | 1766 | snd_hwdep_t *hwdep; |
1767 | int err, len; | 1767 | int err, len; |
1768 | 1768 | ||
1769 | switch (le16_to_cpu(mixer->chip->dev->descriptor.idProduct)) { | 1769 | switch (mixer->chip->usb_id) { |
1770 | case 0x3000: | 1770 | case USB_ID(0x041e, 0x3000): |
1771 | mixer->rc_type = RC_EXTIGY; | 1771 | mixer->rc_type = RC_EXTIGY; |
1772 | len = 2; | 1772 | len = 2; |
1773 | break; | 1773 | break; |
1774 | case 0x3020: | 1774 | case USB_ID(0x041e, 0x3020): |
1775 | mixer->rc_type = RC_AUDIGY2NX; | 1775 | mixer->rc_type = RC_AUDIGY2NX; |
1776 | len = 6; | 1776 | len = 6; |
1777 | break; | 1777 | break; |
@@ -1844,11 +1844,9 @@ int snd_usb_create_mixer(snd_usb_audio_t *chip, int ctrlif) | |||
1844 | return err; | 1844 | return err; |
1845 | } | 1845 | } |
1846 | 1846 | ||
1847 | if (le16_to_cpu(chip->dev->descriptor.idVendor) == 0x041e) { | 1847 | if ((err = snd_usb_soundblaster_remote_init(mixer)) < 0) { |
1848 | if ((err = snd_usb_soundblaster_remote_init(mixer)) < 0) { | 1848 | snd_usb_mixer_free(mixer); |
1849 | snd_usb_mixer_free(mixer); | 1849 | return err; |
1850 | return err; | ||
1851 | } | ||
1852 | } | 1850 | } |
1853 | 1851 | ||
1854 | err = snd_device_new(chip->card, SNDRV_DEV_LOWLEVEL, mixer, &dev_ops); | 1852 | err = snd_device_new(chip->card, SNDRV_DEV_LOWLEVEL, mixer, &dev_ops); |