~ubuntu-branches/debian/wheezy/linux-2.6/wheezy

« back to all changes in this revision

Viewing changes to sound/usb/mixer.c

  • Committer: Bazaar Package Importer
  • Author(s): Ben Hutchings, Ben Hutchings, Aurelien Jarno
  • Date: 2011-06-07 12:14:05 UTC
  • mfrom: (43.1.9 sid)
  • Revision ID: james.westby@ubuntu.com-20110607121405-i3h1rd7nrnd2b73h
Tags: 2.6.39-2
[ Ben Hutchings ]
* [x86] Enable BACKLIGHT_APPLE, replacing BACKLIGHT_MBP_NVIDIA
  (Closes: #627492)
* cgroups: Disable memory resource controller by default. Allow it
  to be enabled using kernel parameter 'cgroup_enable=memory'.
* rt2800usb: Enable support for more USB devices including
  Linksys WUSB600N (Closes: #596626) (this change was accidentally
  omitted from 2.6.39-1)
* [x86] Remove Celeron from list of processors supporting PAE. Most
  'Celeron M' models do not.
* Update debconf template translations:
  - Swedish (Martin Bagge) (Closes: #628932)
  - French (David Prévot) (Closes: #628191)
* aufs: Update for 2.6.39 (Closes: #627837)
* Add stable 2.6.39.1, including:
  - ext4: dont set PageUptodate in ext4_end_bio()
  - pata_cmd64x: fix boot crash on parisc (Closes: #622997, #622745)
  - ext3: Fix fs corruption when make_indexed_dir() fails
  - netfilter: nf_ct_sip: validate Content-Length in TCP SIP messages
  - sctp: fix race between sctp_bind_addr_free() and
    sctp_bind_addr_conflict()
  - sctp: fix memory leak of the ASCONF queue when free asoc
  - md/bitmap: fix saving of events_cleared and other state
  - cdc_acm: Fix oops when Droids MuIn LCD is connected
  - cx88: Fix conversion from BKL to fine-grained locks (Closes: #619827)
  - keys: Set cred->user_ns in key_replace_session_keyring (CVE-2011-2184)
  - tmpfs: fix race between truncate and writepage
  - nfs41: Correct offset for LAYOUTCOMMIT
  - xen/mmu: fix a race window causing leave_mm BUG()
  - ext4: fix possible use-after-free in ext4_remove_li_request()
  For the complete list of changes, see:
   http://www.kernel.org/pub/linux/kernel/v2.6/ChangeLog-2.6.39.1
* Bump ABI to 2
* netfilter: Enable IP_SET, IP_SET_BITMAP_IP, IP_SET_BITMAP_IPMAC,
  IP_SET_BITMAP_PORT, IP_SET_HASH_IP, IP_SET_HASH_IPPORT,
  IP_SET_HASH_IPPORTIP, IP_SET_HASH_IPPORTNET, IP_SET_HASH_NET,
  IP_SET_HASH_NETPORT, IP_SET_LIST_SET, NETFILTER_XT_SET as modules
  (Closes: #629401)

[ Aurelien Jarno ]
* [mipsel/loongson-2f] Disable_SCSI_LPFC to workaround GCC ICE.

Show diffs side-by-side

added added

removed removed

Lines of Context:
61
61
#include "mixer.h"
62
62
#include "helper.h"
63
63
#include "mixer_quirks.h"
 
64
#include "power.h"
64
65
 
65
66
#define MAX_ID_ELEMS    256
66
67
 
295
296
        unsigned char buf[2];
296
297
        int val_len = cval->val_type >= USB_MIXER_S16 ? 2 : 1;
297
298
        int timeout = 10;
 
299
        int err;
298
300
 
 
301
        err = snd_usb_autoresume(cval->mixer->chip);
 
302
        if (err < 0)
 
303
                return -EIO;
299
304
        while (timeout-- > 0) {
300
305
                if (snd_usb_ctl_msg(chip->dev, usb_rcvctrlpipe(chip->dev, 0), request,
301
306
                                    USB_RECIP_INTERFACE | USB_TYPE_CLASS | USB_DIR_IN,
302
307
                                    validx, snd_usb_ctrl_intf(chip) | (cval->id << 8),
303
308
                                    buf, val_len, 100) >= val_len) {
304
309
                        *value_ret = convert_signed_value(cval, snd_usb_combine_bytes(buf, val_len));
 
310
                        snd_usb_autosuspend(cval->mixer->chip);
305
311
                        return 0;
306
312
                }
307
313
        }
 
314
        snd_usb_autosuspend(cval->mixer->chip);
308
315
        snd_printdd(KERN_ERR "cannot get ctl value: req = %#x, wValue = %#x, wIndex = %#x, type = %d\n",
309
316
                    request, validx, snd_usb_ctrl_intf(chip) | (cval->id << 8), cval->val_type);
310
317
        return -EINVAL;
328
335
 
329
336
        memset(buf, 0, sizeof(buf));
330
337
 
 
338
        ret = snd_usb_autoresume(chip) ? -EIO : 0;
 
339
        if (ret)
 
340
                goto error;
 
341
 
331
342
        ret = snd_usb_ctl_msg(chip->dev, usb_rcvctrlpipe(chip->dev, 0), bRequest,
332
343
                              USB_RECIP_INTERFACE | USB_TYPE_CLASS | USB_DIR_IN,
333
344
                              validx, snd_usb_ctrl_intf(chip) | (cval->id << 8),
334
345
                              buf, size, 1000);
 
346
        snd_usb_autosuspend(chip);
335
347
 
336
348
        if (ret < 0) {
 
349
error:
337
350
                snd_printk(KERN_ERR "cannot get ctl value: req = %#x, wValue = %#x, wIndex = %#x, type = %d\n",
338
351
                           request, validx, snd_usb_ctrl_intf(chip) | (cval->id << 8), cval->val_type);
339
352
                return ret;
413
426
{
414
427
        struct snd_usb_audio *chip = cval->mixer->chip;
415
428
        unsigned char buf[2];
416
 
        int val_len, timeout = 10;
 
429
        int val_len, err, timeout = 10;
417
430
 
418
431
        if (cval->mixer->protocol == UAC_VERSION_1) {
419
432
                val_len = cval->val_type >= USB_MIXER_S16 ? 2 : 1;
433
446
        value_set = convert_bytes_value(cval, value_set);
434
447
        buf[0] = value_set & 0xff;
435
448
        buf[1] = (value_set >> 8) & 0xff;
 
449
        err = snd_usb_autoresume(chip);
 
450
        if (err < 0)
 
451
                return -EIO;
436
452
        while (timeout-- > 0)
437
453
                if (snd_usb_ctl_msg(chip->dev,
438
454
                                    usb_sndctrlpipe(chip->dev, 0), request,
439
455
                                    USB_RECIP_INTERFACE | USB_TYPE_CLASS | USB_DIR_OUT,
440
456
                                    validx, snd_usb_ctrl_intf(chip) | (cval->id << 8),
441
 
                                    buf, val_len, 100) >= 0)
 
457
                                    buf, val_len, 100) >= 0) {
 
458
                        snd_usb_autosuspend(chip);
442
459
                        return 0;
 
460
                }
 
461
        snd_usb_autosuspend(chip);
443
462
        snd_printdd(KERN_ERR "cannot set ctl value: req = %#x, wValue = %#x, wIndex = %#x, type = %d, data = %#x/%#x\n",
444
463
                    request, validx, snd_usb_ctrl_intf(chip) | (cval->id << 8), cval->val_type, buf[0], buf[1]);
445
464
        return -EINVAL;
987
1006
        struct snd_kcontrol *kctl;
988
1007
        struct usb_mixer_elem_info *cval;
989
1008
        const struct usbmix_name_map *map;
 
1009
        unsigned int range;
990
1010
 
991
1011
        control++; /* change from zero-based to 1-based value */
992
1012
 
1121
1141
                }
1122
1142
                break;
1123
1143
 
 
1144
        case USB_ID(0x046d, 0x0808):
1124
1145
        case USB_ID(0x046d, 0x0809):
1125
1146
        case USB_ID(0x046d, 0x0991):
1126
1147
        /* Most audio usb devices lie about volume resolution.
1136
1157
 
1137
1158
        }
1138
1159
 
 
1160
        range = (cval->max - cval->min) / cval->res;
 
1161
        /* Are there devices with volume range more than 255? I use a bit more
 
1162
         * to be sure. 384 is a resolution magic number found on Logitech
 
1163
         * devices. It will definitively catch all buggy Logitech devices.
 
1164
         */
 
1165
        if (range > 384) {
 
1166
                snd_printk(KERN_WARNING "usb_audio: Warning! Unlikely big "
 
1167
                           "volume range (=%u), cval->res is probably wrong.",
 
1168
                           range);
 
1169
                snd_printk(KERN_WARNING "usb_audio: [%d] FU [%s] ch = %d, "
 
1170
                           "val = %d/%d/%d", cval->id,
 
1171
                           kctl->id.name, cval->channels,
 
1172
                           cval->min, cval->max, cval->res);
 
1173
        }
 
1174
 
1139
1175
        snd_printdd(KERN_INFO "[%d] FU [%s] ch = %d, val = %d/%d/%d\n",
1140
1176
                    cval->id, kctl->id.name, cval->channels, cval->min, cval->max, cval->res);
1141
1177
        add_control_to_empty(state, kctl);
1146
1182
/*
1147
1183
 * parse a feature unit
1148
1184
 *
1149
 
 * most of controlls are defined here.
 
1185
 * most of controls are defined here.
1150
1186
 */
1151
1187
static int parse_audio_feature_unit(struct mixer_build *state, int unitid, void *_ftr)
1152
1188
{
2058
2094
{
2059
2095
        struct usb_mixer_interface *mixer = urb->context;
2060
2096
        int len = urb->actual_length;
 
2097
        int ustatus = urb->status;
2061
2098
 
2062
 
        if (urb->status != 0)
 
2099
        if (ustatus != 0)
2063
2100
                goto requeue;
2064
2101
 
2065
2102
        if (mixer->protocol == UAC_VERSION_1) {
2100
2137
        }
2101
2138
 
2102
2139
requeue:
2103
 
        if (urb->status != -ENOENT && urb->status != -ECONNRESET) {
 
2140
        if (ustatus != -ENOENT && ustatus != -ECONNRESET && ustatus != -ESHUTDOWN) {
2104
2141
                urb->dev = mixer->chip->dev;
2105
2142
                usb_submit_urb(urb, GFP_ATOMIC);
2106
2143
        }
2107
2144
}
2108
2145
 
 
2146
/* stop any bus activity of a mixer */
 
2147
void snd_usb_mixer_inactivate(struct usb_mixer_interface *mixer)
 
2148
{
 
2149
        usb_kill_urb(mixer->urb);
 
2150
        usb_kill_urb(mixer->rc_urb);
 
2151
}
 
2152
 
 
2153
int snd_usb_mixer_activate(struct usb_mixer_interface *mixer)
 
2154
{
 
2155
        int err;
 
2156
 
 
2157
        if (mixer->urb) {
 
2158
                err = usb_submit_urb(mixer->urb, GFP_NOIO);
 
2159
                if (err < 0)
 
2160
                        return err;
 
2161
        }
 
2162
 
 
2163
        return 0;
 
2164
}
 
2165
 
2109
2166
/* create the handler for the optional status interrupt endpoint */
2110
2167
static int snd_usb_mixer_status_create(struct usb_mixer_interface *mixer)
2111
2168
{