summaryrefslogtreecommitdiff
path: root/sound/usb/usbmixer.c
diff options
context:
space:
mode:
authorClemens Ladisch <clemens@ladisch.de>2005-05-02 10:51:26 +0400
committerJaroslav Kysela <perex@suse.cz>2005-05-29 12:05:47 +0400
commit27d10f5664c7650af3b2ffadfefaf19b36dc7bd8 (patch)
treeb89c8d639041f460557bf6e9078c7cee7426cd2b /sound/usb/usbmixer.c
parentb259b10c420a59a2fdbcf5a3498253ebcbdffa1e (diff)
downloadlinux-27d10f5664c7650af3b2ffadfefaf19b36dc7bd8.tar.xz
[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.c38
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 {
struct usb_mixer_interface *mixer;
unsigned char *buffer;
unsigned int buflen;
- unsigned short vendor;
- unsigned short product;
DECLARE_BITMAP(unitbitmap, 256);
usb_audio_term_t oterm;
const struct usbmix_name_map *map;
@@ -906,11 +904,16 @@ static void build_feature_ctl(mixer_build_t *state, unsigned char *desc,
/* note that detection between firmware 2.1.1.7 (N101) and later 2.1.1.21 */
/* is not very clear from datasheets */
/* I hope that the min value is -15360 for newer firmware --jk */
- if (((state->vendor == 0x471 && (state->product == 0x104 || state->product == 0x105 || state->product == 0x101)) ||
- (state->vendor == 0x672 && state->product == 0x1041)) && !strcmp(kctl->id.name, "PCM Playback Volume") &&
- cval->min == -15616) {
- snd_printk("USB Audio: using volume control quirk for the UDA1321/N101 chip\n");
- cval->max = -256;
+ switch (state->chip->usb_id) {
+ case USB_ID(0x0471, 0x0101):
+ case USB_ID(0x0471, 0x0104):
+ case USB_ID(0x0471, 0x0105):
+ case USB_ID(0x0672, 0x1041):
+ if (!strcmp(kctl->id.name, "PCM Playback Volume") &&
+ cval->min == -15616) {
+ snd_printk("using volume control quirk for the UDA1321/N101 chip\n");
+ cval->max = -256;
+ }
}
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)
mixer_build_t state;
int err;
const struct usbmix_ctl_map *map;
- struct usb_device_descriptor *dev = &mixer->chip->dev->descriptor;
struct usb_host_interface *hostif;
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)
state.mixer = mixer;
state.buffer = hostif->extra;
state.buflen = hostif->extralen;
- state.vendor = le16_to_cpu(dev->idVendor);
- state.product = le16_to_cpu(dev->idProduct);
/* check the mapping table */
- for (map = usbmix_ctl_maps; map->vendor; map++) {
- if (map->vendor == state.vendor && map->product == state.product) {
+ for (map = usbmix_ctl_maps; map->id; map++) {
+ if (map->id == state.chip->usb_id) {
state.map = map->map;
state.selector_map = map->selector_map;
mixer->ignore_ctl_error = map->ignore_ctl_error;
@@ -1766,12 +1766,12 @@ static int snd_usb_soundblaster_remote_init(struct usb_mixer_interface *mixer)
snd_hwdep_t *hwdep;
int err, len;
- switch (le16_to_cpu(mixer->chip->dev->descriptor.idProduct)) {
- case 0x3000:
+ switch (mixer->chip->usb_id) {
+ case USB_ID(0x041e, 0x3000):
mixer->rc_type = RC_EXTIGY;
len = 2;
break;
- case 0x3020:
+ case USB_ID(0x041e, 0x3020):
mixer->rc_type = RC_AUDIGY2NX;
len = 6;
break;
@@ -1844,11 +1844,9 @@ int snd_usb_create_mixer(snd_usb_audio_t *chip, int ctrlif)
return err;
}
- if (le16_to_cpu(chip->dev->descriptor.idVendor) == 0x041e) {
- if ((err = snd_usb_soundblaster_remote_init(mixer)) < 0) {
- snd_usb_mixer_free(mixer);
- return err;
- }
+ if ((err = snd_usb_soundblaster_remote_init(mixer)) < 0) {
+ snd_usb_mixer_free(mixer);
+ return err;
}
err = snd_device_new(chip->card, SNDRV_DEV_LOWLEVEL, mixer, &dev_ops);