diff options
author | Daniel Mack <daniel@caiaq.de> | 2010-06-16 11:57:31 -0400 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2010-06-23 10:10:23 -0400 |
commit | 3d8d4dcfd423b01ef7ea7c3c97720764b7adb6df (patch) | |
tree | 4bb52394ecfe1f2bda274ab6af3dbe1be9d7bbf2 /sound/usb/mixer.c | |
parent | 157a57b6fae7d3c6d24b7623dcc6679c6d244621 (diff) |
ALSA: usb-audio: simplify control interface access
As the control interface is now carried in struct snd_usb_audio, we can
simplify the API a little and also drop the private ctrlif field from
struct usb_mixer_interface.
Also remove a left-over function prototype in pcm.h.
Signed-off-by: Daniel Mack <daniel@caiaq.de>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/usb/mixer.c')
-rw-r--r-- | sound/usb/mixer.c | 37 |
1 files changed, 18 insertions, 19 deletions
diff --git a/sound/usb/mixer.c b/sound/usb/mixer.c index 1163ec3ca8a0..035a77bd67a6 100644 --- a/sound/usb/mixer.c +++ b/sound/usb/mixer.c | |||
@@ -291,16 +291,15 @@ static int get_abs_value(struct usb_mixer_elem_info *cval, int val) | |||
291 | 291 | ||
292 | static int get_ctl_value_v1(struct usb_mixer_elem_info *cval, int request, int validx, int *value_ret) | 292 | static int get_ctl_value_v1(struct usb_mixer_elem_info *cval, int request, int validx, int *value_ret) |
293 | { | 293 | { |
294 | struct snd_usb_audio *chip = cval->mixer->chip; | ||
294 | unsigned char buf[2]; | 295 | unsigned char buf[2]; |
295 | int val_len = cval->val_type >= USB_MIXER_S16 ? 2 : 1; | 296 | int val_len = cval->val_type >= USB_MIXER_S16 ? 2 : 1; |
296 | int timeout = 10; | 297 | int timeout = 10; |
297 | 298 | ||
298 | while (timeout-- > 0) { | 299 | while (timeout-- > 0) { |
299 | if (snd_usb_ctl_msg(cval->mixer->chip->dev, | 300 | if (snd_usb_ctl_msg(chip->dev, usb_rcvctrlpipe(chip->dev, 0), request, |
300 | usb_rcvctrlpipe(cval->mixer->chip->dev, 0), | ||
301 | request, | ||
302 | USB_RECIP_INTERFACE | USB_TYPE_CLASS | USB_DIR_IN, | 301 | USB_RECIP_INTERFACE | USB_TYPE_CLASS | USB_DIR_IN, |
303 | validx, cval->mixer->ctrlif | (cval->id << 8), | 302 | validx, snd_usb_ctrl_intf(chip) | (cval->id << 8), |
304 | buf, val_len, 100) >= val_len) { | 303 | buf, val_len, 100) >= val_len) { |
305 | *value_ret = convert_signed_value(cval, snd_usb_combine_bytes(buf, val_len)); | 304 | *value_ret = convert_signed_value(cval, snd_usb_combine_bytes(buf, val_len)); |
306 | return 0; | 305 | return 0; |
@@ -313,6 +312,7 @@ static int get_ctl_value_v1(struct usb_mixer_elem_info *cval, int request, int v | |||
313 | 312 | ||
314 | static int get_ctl_value_v2(struct usb_mixer_elem_info *cval, int request, int validx, int *value_ret) | 313 | static int get_ctl_value_v2(struct usb_mixer_elem_info *cval, int request, int validx, int *value_ret) |
315 | { | 314 | { |
315 | struct snd_usb_audio *chip = cval->mixer->chip; | ||
316 | unsigned char buf[2 + 3*sizeof(__u16)]; /* enough space for one range */ | 316 | unsigned char buf[2 + 3*sizeof(__u16)]; /* enough space for one range */ |
317 | unsigned char *val; | 317 | unsigned char *val; |
318 | int ret, size; | 318 | int ret, size; |
@@ -328,16 +328,14 @@ static int get_ctl_value_v2(struct usb_mixer_elem_info *cval, int request, int v | |||
328 | 328 | ||
329 | memset(buf, 0, sizeof(buf)); | 329 | memset(buf, 0, sizeof(buf)); |
330 | 330 | ||
331 | ret = snd_usb_ctl_msg(cval->mixer->chip->dev, | 331 | ret = snd_usb_ctl_msg(chip->dev, usb_rcvctrlpipe(chip->dev, 0), bRequest, |
332 | usb_rcvctrlpipe(cval->mixer->chip->dev, 0), | ||
333 | bRequest, | ||
334 | USB_RECIP_INTERFACE | USB_TYPE_CLASS | USB_DIR_IN, | 332 | USB_RECIP_INTERFACE | USB_TYPE_CLASS | USB_DIR_IN, |
335 | validx, cval->mixer->ctrlif | (cval->id << 8), | 333 | validx, snd_usb_ctrl_intf(chip) | (cval->id << 8), |
336 | buf, size, 1000); | 334 | buf, size, 1000); |
337 | 335 | ||
338 | if (ret < 0) { | 336 | if (ret < 0) { |
339 | snd_printk(KERN_ERR "cannot get ctl value: req = %#x, wValue = %#x, wIndex = %#x, type = %d\n", | 337 | snd_printk(KERN_ERR "cannot get ctl value: req = %#x, wValue = %#x, wIndex = %#x, type = %d\n", |
340 | request, validx, cval->mixer->ctrlif | (cval->id << 8), cval->val_type); | 338 | request, validx, snd_usb_ctrl_intf(chip) | (cval->id << 8), cval->val_type); |
341 | return ret; | 339 | return ret; |
342 | } | 340 | } |
343 | 341 | ||
@@ -413,6 +411,7 @@ static int get_cur_mix_value(struct usb_mixer_elem_info *cval, | |||
413 | int snd_usb_mixer_set_ctl_value(struct usb_mixer_elem_info *cval, | 411 | int snd_usb_mixer_set_ctl_value(struct usb_mixer_elem_info *cval, |
414 | int request, int validx, int value_set) | 412 | int request, int validx, int value_set) |
415 | { | 413 | { |
414 | struct snd_usb_audio *chip = cval->mixer->chip; | ||
416 | unsigned char buf[2]; | 415 | unsigned char buf[2]; |
417 | int val_len, timeout = 10; | 416 | int val_len, timeout = 10; |
418 | 417 | ||
@@ -435,15 +434,14 @@ int snd_usb_mixer_set_ctl_value(struct usb_mixer_elem_info *cval, | |||
435 | buf[0] = value_set & 0xff; | 434 | buf[0] = value_set & 0xff; |
436 | buf[1] = (value_set >> 8) & 0xff; | 435 | buf[1] = (value_set >> 8) & 0xff; |
437 | while (timeout-- > 0) | 436 | while (timeout-- > 0) |
438 | if (snd_usb_ctl_msg(cval->mixer->chip->dev, | 437 | if (snd_usb_ctl_msg(chip->dev, |
439 | usb_sndctrlpipe(cval->mixer->chip->dev, 0), | 438 | usb_sndctrlpipe(chip->dev, 0), request, |
440 | request, | ||
441 | USB_RECIP_INTERFACE | USB_TYPE_CLASS | USB_DIR_OUT, | 439 | USB_RECIP_INTERFACE | USB_TYPE_CLASS | USB_DIR_OUT, |
442 | validx, cval->mixer->ctrlif | (cval->id << 8), | 440 | validx, snd_usb_ctrl_intf(chip) | (cval->id << 8), |
443 | buf, val_len, 100) >= 0) | 441 | buf, val_len, 100) >= 0) |
444 | return 0; | 442 | return 0; |
445 | snd_printdd(KERN_ERR "cannot set ctl value: req = %#x, wValue = %#x, wIndex = %#x, type = %d, data = %#x/%#x\n", | 443 | snd_printdd(KERN_ERR "cannot set ctl value: req = %#x, wValue = %#x, wIndex = %#x, type = %d, data = %#x/%#x\n", |
446 | request, validx, cval->mixer->ctrlif | (cval->id << 8), cval->val_type, buf[0], buf[1]); | 444 | request, validx, snd_usb_ctrl_intf(chip) | (cval->id << 8), cval->val_type, buf[0], buf[1]); |
447 | return -EINVAL; | 445 | return -EINVAL; |
448 | } | 446 | } |
449 | 447 | ||
@@ -761,6 +759,8 @@ static void usb_mixer_elem_free(struct snd_kcontrol *kctl) | |||
761 | */ | 759 | */ |
762 | static int get_min_max(struct usb_mixer_elem_info *cval, int default_min) | 760 | static int get_min_max(struct usb_mixer_elem_info *cval, int default_min) |
763 | { | 761 | { |
762 | struct snd_usb_audio *chip = cval->mixer->chip; | ||
763 | |||
764 | /* for failsafe */ | 764 | /* for failsafe */ |
765 | cval->min = default_min; | 765 | cval->min = default_min; |
766 | cval->max = cval->min + 1; | 766 | cval->max = cval->min + 1; |
@@ -783,7 +783,7 @@ static int get_min_max(struct usb_mixer_elem_info *cval, int default_min) | |||
783 | if (get_ctl_value(cval, UAC_GET_MAX, (cval->control << 8) | minchn, &cval->max) < 0 || | 783 | if (get_ctl_value(cval, UAC_GET_MAX, (cval->control << 8) | minchn, &cval->max) < 0 || |
784 | get_ctl_value(cval, UAC_GET_MIN, (cval->control << 8) | minchn, &cval->min) < 0) { | 784 | get_ctl_value(cval, UAC_GET_MIN, (cval->control << 8) | minchn, &cval->min) < 0) { |
785 | snd_printd(KERN_ERR "%d:%d: cannot get min/max values for control %d (id %d)\n", | 785 | snd_printd(KERN_ERR "%d:%d: cannot get min/max values for control %d (id %d)\n", |
786 | cval->id, cval->mixer->ctrlif, cval->control, cval->id); | 786 | cval->id, snd_usb_ctrl_intf(chip), cval->control, cval->id); |
787 | return -EINVAL; | 787 | return -EINVAL; |
788 | } | 788 | } |
789 | if (get_ctl_value(cval, UAC_GET_RES, (cval->control << 8) | minchn, &cval->res) < 0) { | 789 | if (get_ctl_value(cval, UAC_GET_RES, (cval->control << 8) | minchn, &cval->res) < 0) { |
@@ -1913,7 +1913,7 @@ static int snd_usb_mixer_controls(struct usb_mixer_interface *mixer) | |||
1913 | struct usb_host_interface *hostif; | 1913 | struct usb_host_interface *hostif; |
1914 | void *p; | 1914 | void *p; |
1915 | 1915 | ||
1916 | hostif = &usb_ifnum_to_if(mixer->chip->dev, mixer->ctrlif)->altsetting[0]; | 1916 | hostif = mixer->chip->ctrl_intf; |
1917 | memset(&state, 0, sizeof(state)); | 1917 | memset(&state, 0, sizeof(state)); |
1918 | state.chip = mixer->chip; | 1918 | state.chip = mixer->chip; |
1919 | state.mixer = mixer; | 1919 | state.mixer = mixer; |
@@ -2005,7 +2005,7 @@ static void snd_usb_mixer_proc_read(struct snd_info_entry *entry, | |||
2005 | list_for_each_entry(mixer, &chip->mixer_list, list) { | 2005 | list_for_each_entry(mixer, &chip->mixer_list, list) { |
2006 | snd_iprintf(buffer, | 2006 | snd_iprintf(buffer, |
2007 | "USB Mixer: usb_id=0x%08x, ctrlif=%i, ctlerr=%i\n", | 2007 | "USB Mixer: usb_id=0x%08x, ctrlif=%i, ctlerr=%i\n", |
2008 | chip->usb_id, mixer->ctrlif, | 2008 | chip->usb_id, snd_usb_ctrl_intf(chip), |
2009 | mixer->ignore_ctl_error); | 2009 | mixer->ignore_ctl_error); |
2010 | snd_iprintf(buffer, "Card: %s\n", chip->card->longname); | 2010 | snd_iprintf(buffer, "Card: %s\n", chip->card->longname); |
2011 | for (unitid = 0; unitid < MAX_ID_ELEMS; unitid++) { | 2011 | for (unitid = 0; unitid < MAX_ID_ELEMS; unitid++) { |
@@ -2123,7 +2123,7 @@ static int snd_usb_mixer_status_create(struct usb_mixer_interface *mixer) | |||
2123 | int buffer_length; | 2123 | int buffer_length; |
2124 | unsigned int epnum; | 2124 | unsigned int epnum; |
2125 | 2125 | ||
2126 | hostif = &usb_ifnum_to_if(mixer->chip->dev, mixer->ctrlif)->altsetting[0]; | 2126 | hostif = mixer->chip->ctrl_intf; |
2127 | /* we need one interrupt input endpoint */ | 2127 | /* we need one interrupt input endpoint */ |
2128 | if (get_iface_desc(hostif)->bNumEndpoints < 1) | 2128 | if (get_iface_desc(hostif)->bNumEndpoints < 1) |
2129 | return 0; | 2129 | return 0; |
@@ -2166,7 +2166,6 @@ int snd_usb_create_mixer(struct snd_usb_audio *chip, int ctrlif, | |||
2166 | if (!mixer) | 2166 | if (!mixer) |
2167 | return -ENOMEM; | 2167 | return -ENOMEM; |
2168 | mixer->chip = chip; | 2168 | mixer->chip = chip; |
2169 | mixer->ctrlif = ctrlif; | ||
2170 | mixer->ignore_ctl_error = ignore_error; | 2169 | mixer->ignore_ctl_error = ignore_error; |
2171 | mixer->id_elems = kcalloc(MAX_ID_ELEMS, sizeof(*mixer->id_elems), | 2170 | mixer->id_elems = kcalloc(MAX_ID_ELEMS, sizeof(*mixer->id_elems), |
2172 | GFP_KERNEL); | 2171 | GFP_KERNEL); |