aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sound/usb/usbaudio.c79
-rw-r--r--sound/usb/usbmixer.c142
-rw-r--r--sound/usb/usbmixer_maps.c26
-rw-r--r--sound/usb/usbquirks.h10
-rw-r--r--sound/usb/usx2y/usb_stream.c2
5 files changed, 154 insertions, 105 deletions
diff --git a/sound/usb/usbaudio.c b/sound/usb/usbaudio.c
index 8f3cdb37a0ec..c2db0f959681 100644
--- a/sound/usb/usbaudio.c
+++ b/sound/usb/usbaudio.c
@@ -107,7 +107,7 @@ MODULE_PARM_DESC(ignore_ctl_error,
107#define MAX_PACKS_HS (MAX_PACKS * 8) /* in high speed mode */ 107#define MAX_PACKS_HS (MAX_PACKS * 8) /* in high speed mode */
108#define MAX_URBS 8 108#define MAX_URBS 8
109#define SYNC_URBS 4 /* always four urbs for sync */ 109#define SYNC_URBS 4 /* always four urbs for sync */
110#define MIN_PACKS_URB 1 /* minimum 1 packet per urb */ 110#define MAX_QUEUE 24 /* try not to exceed this queue length, in ms */
111 111
112struct audioformat { 112struct audioformat {
113 struct list_head list; 113 struct list_head list;
@@ -525,7 +525,7 @@ static int snd_usb_audio_next_packet_size(struct snd_usb_substream *subs)
525/* 525/*
526 * Prepare urb for streaming before playback starts or when paused. 526 * Prepare urb for streaming before playback starts or when paused.
527 * 527 *
528 * We don't have any data, so we send a frame of silence. 528 * We don't have any data, so we send silence.
529 */ 529 */
530static int prepare_nodata_playback_urb(struct snd_usb_substream *subs, 530static int prepare_nodata_playback_urb(struct snd_usb_substream *subs,
531 struct snd_pcm_runtime *runtime, 531 struct snd_pcm_runtime *runtime,
@@ -537,13 +537,13 @@ static int prepare_nodata_playback_urb(struct snd_usb_substream *subs,
537 537
538 offs = 0; 538 offs = 0;
539 urb->dev = ctx->subs->dev; 539 urb->dev = ctx->subs->dev;
540 urb->number_of_packets = subs->packs_per_ms; 540 for (i = 0; i < ctx->packets; ++i) {
541 for (i = 0; i < subs->packs_per_ms; ++i) {
542 counts = snd_usb_audio_next_packet_size(subs); 541 counts = snd_usb_audio_next_packet_size(subs);
543 urb->iso_frame_desc[i].offset = offs * stride; 542 urb->iso_frame_desc[i].offset = offs * stride;
544 urb->iso_frame_desc[i].length = counts * stride; 543 urb->iso_frame_desc[i].length = counts * stride;
545 offs += counts; 544 offs += counts;
546 } 545 }
546 urb->number_of_packets = ctx->packets;
547 urb->transfer_buffer_length = offs * stride; 547 urb->transfer_buffer_length = offs * stride;
548 memset(urb->transfer_buffer, 548 memset(urb->transfer_buffer,
549 subs->cur_audiofmt->format == SNDRV_PCM_FORMAT_U8 ? 0x80 : 0, 549 subs->cur_audiofmt->format == SNDRV_PCM_FORMAT_U8 ? 0x80 : 0,
@@ -1034,9 +1034,9 @@ static void release_substream_urbs(struct snd_usb_substream *subs, int force)
1034static int init_substream_urbs(struct snd_usb_substream *subs, unsigned int period_bytes, 1034static int init_substream_urbs(struct snd_usb_substream *subs, unsigned int period_bytes,
1035 unsigned int rate, unsigned int frame_bits) 1035 unsigned int rate, unsigned int frame_bits)
1036{ 1036{
1037 unsigned int maxsize, n, i; 1037 unsigned int maxsize, i;
1038 int is_playback = subs->direction == SNDRV_PCM_STREAM_PLAYBACK; 1038 int is_playback = subs->direction == SNDRV_PCM_STREAM_PLAYBACK;
1039 unsigned int npacks[MAX_URBS], urb_packs, total_packs, packs_per_ms; 1039 unsigned int urb_packs, total_packs, packs_per_ms;
1040 1040
1041 /* calculate the frequency in 16.16 format */ 1041 /* calculate the frequency in 16.16 format */
1042 if (snd_usb_get_speed(subs->dev) == USB_SPEED_FULL) 1042 if (snd_usb_get_speed(subs->dev) == USB_SPEED_FULL)
@@ -1070,8 +1070,7 @@ static int init_substream_urbs(struct snd_usb_substream *subs, unsigned int peri
1070 subs->packs_per_ms = packs_per_ms; 1070 subs->packs_per_ms = packs_per_ms;
1071 1071
1072 if (is_playback) { 1072 if (is_playback) {
1073 urb_packs = nrpacks; 1073 urb_packs = max(nrpacks, 1);
1074 urb_packs = max(urb_packs, (unsigned int)MIN_PACKS_URB);
1075 urb_packs = min(urb_packs, (unsigned int)MAX_PACKS); 1074 urb_packs = min(urb_packs, (unsigned int)MAX_PACKS);
1076 } else 1075 } else
1077 urb_packs = 1; 1076 urb_packs = 1;
@@ -1079,7 +1078,7 @@ static int init_substream_urbs(struct snd_usb_substream *subs, unsigned int peri
1079 1078
1080 /* decide how many packets to be used */ 1079 /* decide how many packets to be used */
1081 if (is_playback) { 1080 if (is_playback) {
1082 unsigned int minsize; 1081 unsigned int minsize, maxpacks;
1083 /* determine how small a packet can be */ 1082 /* determine how small a packet can be */
1084 minsize = (subs->freqn >> (16 - subs->datainterval)) 1083 minsize = (subs->freqn >> (16 - subs->datainterval))
1085 * (frame_bits >> 3); 1084 * (frame_bits >> 3);
@@ -1092,8 +1091,13 @@ static int init_substream_urbs(struct snd_usb_substream *subs, unsigned int peri
1092 total_packs = (total_packs + packs_per_ms - 1) 1091 total_packs = (total_packs + packs_per_ms - 1)
1093 & ~(packs_per_ms - 1); 1092 & ~(packs_per_ms - 1);
1094 /* we need at least two URBs for queueing */ 1093 /* we need at least two URBs for queueing */
1095 if (total_packs < 2 * MIN_PACKS_URB * packs_per_ms) 1094 if (total_packs < 2 * packs_per_ms) {
1096 total_packs = 2 * MIN_PACKS_URB * packs_per_ms; 1095 total_packs = 2 * packs_per_ms;
1096 } else {
1097 /* and we don't want too long a queue either */
1098 maxpacks = max(MAX_QUEUE * packs_per_ms, urb_packs * 2);
1099 total_packs = min(total_packs, maxpacks);
1100 }
1097 } else { 1101 } else {
1098 total_packs = MAX_URBS * urb_packs; 1102 total_packs = MAX_URBS * urb_packs;
1099 } 1103 }
@@ -1102,31 +1106,11 @@ static int init_substream_urbs(struct snd_usb_substream *subs, unsigned int peri
1102 /* too much... */ 1106 /* too much... */
1103 subs->nurbs = MAX_URBS; 1107 subs->nurbs = MAX_URBS;
1104 total_packs = MAX_URBS * urb_packs; 1108 total_packs = MAX_URBS * urb_packs;
1105 } 1109 } else if (subs->nurbs < 2) {
1106 n = total_packs;
1107 for (i = 0; i < subs->nurbs; i++) {
1108 npacks[i] = n > urb_packs ? urb_packs : n;
1109 n -= urb_packs;
1110 }
1111 if (subs->nurbs <= 1) {
1112 /* too little - we need at least two packets 1110 /* too little - we need at least two packets
1113 * to ensure contiguous playback/capture 1111 * to ensure contiguous playback/capture
1114 */ 1112 */
1115 subs->nurbs = 2; 1113 subs->nurbs = 2;
1116 npacks[0] = (total_packs + 1) / 2;
1117 npacks[1] = total_packs - npacks[0];
1118 } else if (npacks[subs->nurbs-1] < MIN_PACKS_URB * packs_per_ms) {
1119 /* the last packet is too small.. */
1120 if (subs->nurbs > 2) {
1121 /* merge to the first one */
1122 npacks[0] += npacks[subs->nurbs - 1];
1123 subs->nurbs--;
1124 } else {
1125 /* divide to two */
1126 subs->nurbs = 2;
1127 npacks[0] = (total_packs + 1) / 2;
1128 npacks[1] = total_packs - npacks[0];
1129 }
1130 } 1114 }
1131 1115
1132 /* allocate and initialize data urbs */ 1116 /* allocate and initialize data urbs */
@@ -1134,7 +1118,8 @@ static int init_substream_urbs(struct snd_usb_substream *subs, unsigned int peri
1134 struct snd_urb_ctx *u = &subs->dataurb[i]; 1118 struct snd_urb_ctx *u = &subs->dataurb[i];
1135 u->index = i; 1119 u->index = i;
1136 u->subs = subs; 1120 u->subs = subs;
1137 u->packets = npacks[i]; 1121 u->packets = (i + 1) * total_packs / subs->nurbs
1122 - i * total_packs / subs->nurbs;
1138 u->buffer_size = maxsize * u->packets; 1123 u->buffer_size = maxsize * u->packets;
1139 if (subs->fmt_type == USB_FORMAT_TYPE_II) 1124 if (subs->fmt_type == USB_FORMAT_TYPE_II)
1140 u->packets++; /* for transfer delimiter */ 1125 u->packets++; /* for transfer delimiter */
@@ -1292,14 +1277,14 @@ static int init_usb_sample_rate(struct usb_device *dev, int iface,
1292 if ((err = snd_usb_ctl_msg(dev, usb_sndctrlpipe(dev, 0), SET_CUR, 1277 if ((err = snd_usb_ctl_msg(dev, usb_sndctrlpipe(dev, 0), SET_CUR,
1293 USB_TYPE_CLASS|USB_RECIP_ENDPOINT|USB_DIR_OUT, 1278 USB_TYPE_CLASS|USB_RECIP_ENDPOINT|USB_DIR_OUT,
1294 SAMPLING_FREQ_CONTROL << 8, ep, data, 3, 1000)) < 0) { 1279 SAMPLING_FREQ_CONTROL << 8, ep, data, 3, 1000)) < 0) {
1295 snd_printk(KERN_ERR "%d:%d:%d: cannot set freq %d to ep 0x%x\n", 1280 snd_printk(KERN_ERR "%d:%d:%d: cannot set freq %d to ep %#x\n",
1296 dev->devnum, iface, fmt->altsetting, rate, ep); 1281 dev->devnum, iface, fmt->altsetting, rate, ep);
1297 return err; 1282 return err;
1298 } 1283 }
1299 if ((err = snd_usb_ctl_msg(dev, usb_rcvctrlpipe(dev, 0), GET_CUR, 1284 if ((err = snd_usb_ctl_msg(dev, usb_rcvctrlpipe(dev, 0), GET_CUR,
1300 USB_TYPE_CLASS|USB_RECIP_ENDPOINT|USB_DIR_IN, 1285 USB_TYPE_CLASS|USB_RECIP_ENDPOINT|USB_DIR_IN,
1301 SAMPLING_FREQ_CONTROL << 8, ep, data, 3, 1000)) < 0) { 1286 SAMPLING_FREQ_CONTROL << 8, ep, data, 3, 1000)) < 0) {
1302 snd_printk(KERN_WARNING "%d:%d:%d: cannot get freq at ep 0x%x\n", 1287 snd_printk(KERN_WARNING "%d:%d:%d: cannot get freq at ep %#x\n",
1303 dev->devnum, iface, fmt->altsetting, ep); 1288 dev->devnum, iface, fmt->altsetting, ep);
1304 return 0; /* some devices don't support reading */ 1289 return 0; /* some devices don't support reading */
1305 } 1290 }
@@ -1431,9 +1416,11 @@ static int set_format(struct snd_usb_substream *subs, struct audioformat *fmt)
1431 subs->cur_audiofmt = fmt; 1416 subs->cur_audiofmt = fmt;
1432 1417
1433#if 0 1418#if 0
1434 printk("setting done: format = %d, rate = %d..%d, channels = %d\n", 1419 printk(KERN_DEBUG
1420 "setting done: format = %d, rate = %d..%d, channels = %d\n",
1435 fmt->format, fmt->rate_min, fmt->rate_max, fmt->channels); 1421 fmt->format, fmt->rate_min, fmt->rate_max, fmt->channels);
1436 printk(" datapipe = 0x%0x, syncpipe = 0x%0x\n", 1422 printk(KERN_DEBUG
1423 " datapipe = 0x%0x, syncpipe = 0x%0x\n",
1437 subs->datapipe, subs->syncpipe); 1424 subs->datapipe, subs->syncpipe);
1438#endif 1425#endif
1439 1426
@@ -1468,7 +1455,7 @@ static int snd_usb_hw_params(struct snd_pcm_substream *substream,
1468 channels = params_channels(hw_params); 1455 channels = params_channels(hw_params);
1469 fmt = find_format(subs, format, rate, channels); 1456 fmt = find_format(subs, format, rate, channels);
1470 if (!fmt) { 1457 if (!fmt) {
1471 snd_printd(KERN_DEBUG "cannot set format: format = 0x%x, rate = %d, channels = %d\n", 1458 snd_printd(KERN_DEBUG "cannot set format: format = %#x, rate = %d, channels = %d\n",
1472 format, rate, channels); 1459 format, rate, channels);
1473 return -EINVAL; 1460 return -EINVAL;
1474 } 1461 }
@@ -1795,7 +1782,7 @@ static int check_hw_params_convention(struct snd_usb_substream *subs)
1795 if (rates[f->format] && rates[f->format] != f->rates) 1782 if (rates[f->format] && rates[f->format] != f->rates)
1796 goto __out; 1783 goto __out;
1797 } 1784 }
1798 channels[f->format] |= (1 << f->channels); 1785 channels[f->format] |= 1 << (f->channels - 1);
1799 rates[f->format] |= f->rates; 1786 rates[f->format] |= f->rates;
1800 /* needs knot? */ 1787 /* needs knot? */
1801 if (f->rates & SNDRV_PCM_RATE_KNOT) 1788 if (f->rates & SNDRV_PCM_RATE_KNOT)
@@ -1822,7 +1809,7 @@ static int check_hw_params_convention(struct snd_usb_substream *subs)
1822 continue; 1809 continue;
1823 for (i = 0; i < 32; i++) { 1810 for (i = 0; i < 32; i++) {
1824 if (f->rates & (1 << i)) 1811 if (f->rates & (1 << i))
1825 channels[i] |= (1 << f->channels); 1812 channels[i] |= 1 << (f->channels - 1);
1826 } 1813 }
1827 } 1814 }
1828 cmaster = 0; 1815 cmaster = 0;
@@ -1919,7 +1906,7 @@ static int setup_hw_info(struct snd_pcm_runtime *runtime, struct snd_usb_substre
1919 * in the current code assume the 1ms period. 1906 * in the current code assume the 1ms period.
1920 */ 1907 */
1921 snd_pcm_hw_constraint_minmax(runtime, SNDRV_PCM_HW_PARAM_PERIOD_TIME, 1908 snd_pcm_hw_constraint_minmax(runtime, SNDRV_PCM_HW_PARAM_PERIOD_TIME,
1922 1000 * MIN_PACKS_URB, 1909 1000,
1923 /*(nrpacks * MAX_URBS) * 1000*/ UINT_MAX); 1910 /*(nrpacks * MAX_URBS) * 1000*/ UINT_MAX);
1924 1911
1925 err = check_hw_params_convention(subs); 1912 err = check_hw_params_convention(subs);
@@ -2160,7 +2147,7 @@ static void proc_dump_substream_formats(struct snd_usb_substream *subs, struct s
2160 fp = list_entry(p, struct audioformat, list); 2147 fp = list_entry(p, struct audioformat, list);
2161 snd_iprintf(buffer, " Interface %d\n", fp->iface); 2148 snd_iprintf(buffer, " Interface %d\n", fp->iface);
2162 snd_iprintf(buffer, " Altset %d\n", fp->altsetting); 2149 snd_iprintf(buffer, " Altset %d\n", fp->altsetting);
2163 snd_iprintf(buffer, " Format: 0x%x\n", fp->format); 2150 snd_iprintf(buffer, " Format: %#x\n", fp->format);
2164 snd_iprintf(buffer, " Channels: %d\n", fp->channels); 2151 snd_iprintf(buffer, " Channels: %d\n", fp->channels);
2165 snd_iprintf(buffer, " Endpoint: %d %s (%s)\n", 2152 snd_iprintf(buffer, " Endpoint: %d %s (%s)\n",
2166 fp->endpoint & USB_ENDPOINT_NUMBER_MASK, 2153 fp->endpoint & USB_ENDPOINT_NUMBER_MASK,
@@ -2180,7 +2167,7 @@ static void proc_dump_substream_formats(struct snd_usb_substream *subs, struct s
2180 snd_iprintf(buffer, "\n"); 2167 snd_iprintf(buffer, "\n");
2181 } 2168 }
2182 // snd_iprintf(buffer, " Max Packet Size = %d\n", fp->maxpacksize); 2169 // snd_iprintf(buffer, " Max Packet Size = %d\n", fp->maxpacksize);
2183 // snd_iprintf(buffer, " EP Attribute = 0x%x\n", fp->attributes); 2170 // snd_iprintf(buffer, " EP Attribute = %#x\n", fp->attributes);
2184 } 2171 }
2185} 2172}
2186 2173
@@ -2621,7 +2608,7 @@ static int parse_audio_format_ii(struct snd_usb_audio *chip, struct audioformat
2621 fp->format = SNDRV_PCM_FORMAT_MPEG; 2608 fp->format = SNDRV_PCM_FORMAT_MPEG;
2622 break; 2609 break;
2623 default: 2610 default:
2624 snd_printd(KERN_INFO "%d:%u:%d : unknown format tag 0x%x is detected. processed as MPEG.\n", 2611 snd_printd(KERN_INFO "%d:%u:%d : unknown format tag %#x is detected. processed as MPEG.\n",
2625 chip->dev->devnum, fp->iface, fp->altsetting, format); 2612 chip->dev->devnum, fp->iface, fp->altsetting, format);
2626 fp->format = SNDRV_PCM_FORMAT_MPEG; 2613 fp->format = SNDRV_PCM_FORMAT_MPEG;
2627 break; 2614 break;
@@ -2819,7 +2806,7 @@ static int parse_audio_endpoints(struct snd_usb_audio *chip, int iface_no)
2819 continue; 2806 continue;
2820 } 2807 }
2821 2808
2822 snd_printdd(KERN_INFO "%d:%u:%d: add audio endpoint 0x%x\n", dev->devnum, iface_no, altno, fp->endpoint); 2809 snd_printdd(KERN_INFO "%d:%u:%d: add audio endpoint %#x\n", dev->devnum, iface_no, altno, fp->endpoint);
2823 err = add_audio_endpoint(chip, stream, fp); 2810 err = add_audio_endpoint(chip, stream, fp);
2824 if (err < 0) { 2811 if (err < 0) {
2825 kfree(fp->rate_table); 2812 kfree(fp->rate_table);
@@ -3766,7 +3753,7 @@ static int usb_audio_resume(struct usb_interface *intf)
3766 3753
3767static int __init snd_usb_audio_init(void) 3754static int __init snd_usb_audio_init(void)
3768{ 3755{
3769 if (nrpacks < MIN_PACKS_URB || nrpacks > MAX_PACKS) { 3756 if (nrpacks < 1 || nrpacks > MAX_PACKS) {
3770 printk(KERN_WARNING "invalid nrpacks value.\n"); 3757 printk(KERN_WARNING "invalid nrpacks value.\n");
3771 return -EINVAL; 3758 return -EINVAL;
3772 } 3759 }
diff --git a/sound/usb/usbmixer.c b/sound/usb/usbmixer.c
index 2bde79216fa5..ecb58e7a6245 100644
--- a/sound/usb/usbmixer.c
+++ b/sound/usb/usbmixer.c
@@ -66,6 +66,7 @@ static const struct rc_config {
66 { USB_ID(0x041e, 0x3000), 0, 1, 2, 1, 18, 0x0013 }, /* Extigy */ 66 { USB_ID(0x041e, 0x3000), 0, 1, 2, 1, 18, 0x0013 }, /* Extigy */
67 { USB_ID(0x041e, 0x3020), 2, 1, 6, 6, 18, 0x0013 }, /* Audigy 2 NX */ 67 { USB_ID(0x041e, 0x3020), 2, 1, 6, 6, 18, 0x0013 }, /* Audigy 2 NX */
68 { USB_ID(0x041e, 0x3040), 2, 2, 6, 6, 2, 0x6e91 }, /* Live! 24-bit */ 68 { USB_ID(0x041e, 0x3040), 2, 2, 6, 6, 2, 0x6e91 }, /* Live! 24-bit */
69 { USB_ID(0x041e, 0x3048), 2, 2, 6, 6, 2, 0x6e91 }, /* Toshiba SB0500 */
69}; 70};
70 71
71struct usb_mixer_interface { 72struct usb_mixer_interface {
@@ -109,6 +110,8 @@ struct mixer_build {
109 const struct usbmix_selector_map *selector_map; 110 const struct usbmix_selector_map *selector_map;
110}; 111};
111 112
113#define MAX_CHANNELS 10 /* max logical channels */
114
112struct usb_mixer_elem_info { 115struct usb_mixer_elem_info {
113 struct usb_mixer_interface *mixer; 116 struct usb_mixer_interface *mixer;
114 struct usb_mixer_elem_info *next_id_elem; /* list of controls with same id */ 117 struct usb_mixer_elem_info *next_id_elem; /* list of controls with same id */
@@ -119,6 +122,8 @@ struct usb_mixer_elem_info {
119 int channels; 122 int channels;
120 int val_type; 123 int val_type;
121 int min, max, res; 124 int min, max, res;
125 int cached;
126 int cache_val[MAX_CHANNELS];
122 u8 initialized; 127 u8 initialized;
123}; 128};
124 129
@@ -180,8 +185,6 @@ enum {
180 USB_PROC_DCR_RELEASE = 6, 185 USB_PROC_DCR_RELEASE = 6,
181}; 186};
182 187
183#define MAX_CHANNELS 10 /* max logical channels */
184
185 188
186/* 189/*
187 * manual mapping of mixer names 190 * manual mapping of mixer names
@@ -218,7 +221,10 @@ static int check_ignored_ctl(struct mixer_build *state, int unitid, int control)
218 for (p = state->map; p->id; p++) { 221 for (p = state->map; p->id; p++) {
219 if (p->id == unitid && ! p->name && 222 if (p->id == unitid && ! p->name &&
220 (! control || ! p->control || control == p->control)) { 223 (! control || ! p->control || control == p->control)) {
221 // printk("ignored control %d:%d\n", unitid, control); 224 /*
225 printk(KERN_DEBUG "ignored control %d:%d\n",
226 unitid, control);
227 */
222 return 1; 228 return 1;
223 } 229 }
224 } 230 }
@@ -375,11 +381,35 @@ static int get_cur_ctl_value(struct usb_mixer_elem_info *cval, int validx, int *
375} 381}
376 382
377/* channel = 0: master, 1 = first channel */ 383/* channel = 0: master, 1 = first channel */
378static inline int get_cur_mix_value(struct usb_mixer_elem_info *cval, int channel, int *value) 384static inline int get_cur_mix_raw(struct usb_mixer_elem_info *cval,
385 int channel, int *value)
379{ 386{
380 return get_ctl_value(cval, GET_CUR, (cval->control << 8) | channel, value); 387 return get_ctl_value(cval, GET_CUR, (cval->control << 8) | channel, value);
381} 388}
382 389
390static int get_cur_mix_value(struct usb_mixer_elem_info *cval,
391 int channel, int index, int *value)
392{
393 int err;
394
395 if (cval->cached & (1 << channel)) {
396 *value = cval->cache_val[index];
397 return 0;
398 }
399 err = get_cur_mix_raw(cval, channel, value);
400 if (err < 0) {
401 if (!cval->mixer->ignore_ctl_error)
402 snd_printd(KERN_ERR "cannot get current value for "
403 "control %d ch %d: err = %d\n",
404 cval->control, channel, err);
405 return err;
406 }
407 cval->cached |= 1 << channel;
408 cval->cache_val[index] = *value;
409 return 0;
410}
411
412
383/* 413/*
384 * set a mixer value 414 * set a mixer value
385 */ 415 */
@@ -411,9 +441,17 @@ static int set_cur_ctl_value(struct usb_mixer_elem_info *cval, int validx, int v
411 return set_ctl_value(cval, SET_CUR, validx, value); 441 return set_ctl_value(cval, SET_CUR, validx, value);
412} 442}
413 443
414static inline int set_cur_mix_value(struct usb_mixer_elem_info *cval, int channel, int value) 444static int set_cur_mix_value(struct usb_mixer_elem_info *cval, int channel,
445 int index, int value)
415{ 446{
416 return set_ctl_value(cval, SET_CUR, (cval->control << 8) | channel, value); 447 int err;
448 err = set_ctl_value(cval, SET_CUR, (cval->control << 8) | channel,
449 value);
450 if (err < 0)
451 return err;
452 cval->cached |= 1 << channel;
453 cval->cache_val[index] = value;
454 return 0;
417} 455}
418 456
419/* 457/*
@@ -717,7 +755,7 @@ static int get_min_max(struct usb_mixer_elem_info *cval, int default_min)
717 if (cval->min + cval->res < cval->max) { 755 if (cval->min + cval->res < cval->max) {
718 int last_valid_res = cval->res; 756 int last_valid_res = cval->res;
719 int saved, test, check; 757 int saved, test, check;
720 get_cur_mix_value(cval, minchn, &saved); 758 get_cur_mix_raw(cval, minchn, &saved);
721 for (;;) { 759 for (;;) {
722 test = saved; 760 test = saved;
723 if (test < cval->max) 761 if (test < cval->max)
@@ -725,8 +763,8 @@ static int get_min_max(struct usb_mixer_elem_info *cval, int default_min)
725 else 763 else
726 test -= cval->res; 764 test -= cval->res;
727 if (test < cval->min || test > cval->max || 765 if (test < cval->min || test > cval->max ||
728 set_cur_mix_value(cval, minchn, test) || 766 set_cur_mix_value(cval, minchn, 0, test) ||
729 get_cur_mix_value(cval, minchn, &check)) { 767 get_cur_mix_raw(cval, minchn, &check)) {
730 cval->res = last_valid_res; 768 cval->res = last_valid_res;
731 break; 769 break;
732 } 770 }
@@ -734,7 +772,7 @@ static int get_min_max(struct usb_mixer_elem_info *cval, int default_min)
734 break; 772 break;
735 cval->res *= 2; 773 cval->res *= 2;
736 } 774 }
737 set_cur_mix_value(cval, minchn, saved); 775 set_cur_mix_value(cval, minchn, 0, saved);
738 } 776 }
739 777
740 cval->initialized = 1; 778 cval->initialized = 1;
@@ -774,35 +812,25 @@ static int mixer_ctl_feature_get(struct snd_kcontrol *kcontrol, struct snd_ctl_e
774 struct usb_mixer_elem_info *cval = kcontrol->private_data; 812 struct usb_mixer_elem_info *cval = kcontrol->private_data;
775 int c, cnt, val, err; 813 int c, cnt, val, err;
776 814
815 ucontrol->value.integer.value[0] = cval->min;
777 if (cval->cmask) { 816 if (cval->cmask) {
778 cnt = 0; 817 cnt = 0;
779 for (c = 0; c < MAX_CHANNELS; c++) { 818 for (c = 0; c < MAX_CHANNELS; c++) {
780 if (cval->cmask & (1 << c)) { 819 if (!(cval->cmask & (1 << c)))
781 err = get_cur_mix_value(cval, c + 1, &val); 820 continue;
782 if (err < 0) { 821 err = get_cur_mix_value(cval, c + 1, cnt, &val);
783 if (cval->mixer->ignore_ctl_error) { 822 if (err < 0)
784 ucontrol->value.integer.value[0] = cval->min; 823 return cval->mixer->ignore_ctl_error ? 0 : err;
785 return 0; 824 val = get_relative_value(cval, val);
786 } 825 ucontrol->value.integer.value[cnt] = val;
787 snd_printd(KERN_ERR "cannot get current value for control %d ch %d: err = %d\n", cval->control, c + 1, err); 826 cnt++;
788 return err;
789 }
790 val = get_relative_value(cval, val);
791 ucontrol->value.integer.value[cnt] = val;
792 cnt++;
793 }
794 } 827 }
828 return 0;
795 } else { 829 } else {
796 /* master channel */ 830 /* master channel */
797 err = get_cur_mix_value(cval, 0, &val); 831 err = get_cur_mix_value(cval, 0, 0, &val);
798 if (err < 0) { 832 if (err < 0)
799 if (cval->mixer->ignore_ctl_error) { 833 return cval->mixer->ignore_ctl_error ? 0 : err;
800 ucontrol->value.integer.value[0] = cval->min;
801 return 0;
802 }
803 snd_printd(KERN_ERR "cannot get current value for control %d master ch: err = %d\n", cval->control, err);
804 return err;
805 }
806 val = get_relative_value(cval, val); 834 val = get_relative_value(cval, val);
807 ucontrol->value.integer.value[0] = val; 835 ucontrol->value.integer.value[0] = val;
808 } 836 }
@@ -819,34 +847,28 @@ static int mixer_ctl_feature_put(struct snd_kcontrol *kcontrol, struct snd_ctl_e
819 if (cval->cmask) { 847 if (cval->cmask) {
820 cnt = 0; 848 cnt = 0;
821 for (c = 0; c < MAX_CHANNELS; c++) { 849 for (c = 0; c < MAX_CHANNELS; c++) {
822 if (cval->cmask & (1 << c)) { 850 if (!(cval->cmask & (1 << c)))
823 err = get_cur_mix_value(cval, c + 1, &oval); 851 continue;
824 if (err < 0) { 852 err = get_cur_mix_value(cval, c + 1, cnt, &oval);
825 if (cval->mixer->ignore_ctl_error) 853 if (err < 0)
826 return 0; 854 return cval->mixer->ignore_ctl_error ? 0 : err;
827 return err; 855 val = ucontrol->value.integer.value[cnt];
828 } 856 val = get_abs_value(cval, val);
829 val = ucontrol->value.integer.value[cnt]; 857 if (oval != val) {
830 val = get_abs_value(cval, val); 858 set_cur_mix_value(cval, c + 1, cnt, val);
831 if (oval != val) { 859 changed = 1;
832 set_cur_mix_value(cval, c + 1, val);
833 changed = 1;
834 }
835 get_cur_mix_value(cval, c + 1, &val);
836 cnt++;
837 } 860 }
861 cnt++;
838 } 862 }
839 } else { 863 } else {
840 /* master channel */ 864 /* master channel */
841 err = get_cur_mix_value(cval, 0, &oval); 865 err = get_cur_mix_value(cval, 0, 0, &oval);
842 if (err < 0 && cval->mixer->ignore_ctl_error)
843 return 0;
844 if (err < 0) 866 if (err < 0)
845 return err; 867 return cval->mixer->ignore_ctl_error ? 0 : err;
846 val = ucontrol->value.integer.value[0]; 868 val = ucontrol->value.integer.value[0];
847 val = get_abs_value(cval, val); 869 val = get_abs_value(cval, val);
848 if (val != oval) { 870 if (val != oval) {
849 set_cur_mix_value(cval, 0, val); 871 set_cur_mix_value(cval, 0, 0, val);
850 changed = 1; 872 changed = 1;
851 } 873 }
852 } 874 }
@@ -1705,7 +1727,8 @@ static void snd_usb_mixer_memory_change(struct usb_mixer_interface *mixer,
1705 break; 1727 break;
1706 /* live24ext: 4 = line-in jack */ 1728 /* live24ext: 4 = line-in jack */
1707 case 3: /* hp-out jack (may actuate Mute) */ 1729 case 3: /* hp-out jack (may actuate Mute) */
1708 if (mixer->chip->usb_id == USB_ID(0x041e, 0x3040)) 1730 if (mixer->chip->usb_id == USB_ID(0x041e, 0x3040) ||
1731 mixer->chip->usb_id == USB_ID(0x041e, 0x3048))
1709 snd_usb_mixer_notify_id(mixer, mixer->rc_cfg->mute_mixer_id); 1732 snd_usb_mixer_notify_id(mixer, mixer->rc_cfg->mute_mixer_id);
1710 break; 1733 break;
1711 default: 1734 default:
@@ -1936,8 +1959,9 @@ static int snd_audigy2nx_controls_create(struct usb_mixer_interface *mixer)
1936 int i, err; 1959 int i, err;
1937 1960
1938 for (i = 0; i < ARRAY_SIZE(snd_audigy2nx_controls); ++i) { 1961 for (i = 0; i < ARRAY_SIZE(snd_audigy2nx_controls); ++i) {
1939 if (i > 1 && /* Live24ext has 2 LEDs only */ 1962 if (i > 1 && /* Live24ext has 2 LEDs only */
1940 mixer->chip->usb_id == USB_ID(0x041e, 0x3040)) 1963 (mixer->chip->usb_id == USB_ID(0x041e, 0x3040) ||
1964 mixer->chip->usb_id == USB_ID(0x041e, 0x3048)))
1941 break; 1965 break;
1942 err = snd_ctl_add(mixer->chip->card, 1966 err = snd_ctl_add(mixer->chip->card,
1943 snd_ctl_new1(&snd_audigy2nx_controls[i], mixer)); 1967 snd_ctl_new1(&snd_audigy2nx_controls[i], mixer));
@@ -1974,7 +1998,8 @@ static void snd_audigy2nx_proc_read(struct snd_info_entry *entry,
1974 snd_iprintf(buffer, "%s jacks\n\n", mixer->chip->card->shortname); 1998 snd_iprintf(buffer, "%s jacks\n\n", mixer->chip->card->shortname);
1975 if (mixer->chip->usb_id == USB_ID(0x041e, 0x3020)) 1999 if (mixer->chip->usb_id == USB_ID(0x041e, 0x3020))
1976 jacks = jacks_audigy2nx; 2000 jacks = jacks_audigy2nx;
1977 else if (mixer->chip->usb_id == USB_ID(0x041e, 0x3040)) 2001 else if (mixer->chip->usb_id == USB_ID(0x041e, 0x3040) ||
2002 mixer->chip->usb_id == USB_ID(0x041e, 0x3048))
1978 jacks = jacks_live24ext; 2003 jacks = jacks_live24ext;
1979 else 2004 else
1980 return; 2005 return;
@@ -2024,7 +2049,8 @@ int snd_usb_create_mixer(struct snd_usb_audio *chip, int ctrlif,
2024 goto _error; 2049 goto _error;
2025 2050
2026 if (mixer->chip->usb_id == USB_ID(0x041e, 0x3020) || 2051 if (mixer->chip->usb_id == USB_ID(0x041e, 0x3020) ||
2027 mixer->chip->usb_id == USB_ID(0x041e, 0x3040)) { 2052 mixer->chip->usb_id == USB_ID(0x041e, 0x3040) ||
2053 mixer->chip->usb_id == USB_ID(0x041e, 0x3048)) {
2028 struct snd_info_entry *entry; 2054 struct snd_info_entry *entry;
2029 2055
2030 if ((err = snd_audigy2nx_controls_create(mixer)) < 0) 2056 if ((err = snd_audigy2nx_controls_create(mixer)) < 0)
diff --git a/sound/usb/usbmixer_maps.c b/sound/usb/usbmixer_maps.c
index d755be0ad811..3e5d66cf1f5a 100644
--- a/sound/usb/usbmixer_maps.c
+++ b/sound/usb/usbmixer_maps.c
@@ -261,6 +261,22 @@ static struct usbmix_name_map aureon_51_2_map[] = {
261 {} /* terminator */ 261 {} /* terminator */
262}; 262};
263 263
264static struct usbmix_name_map scratch_live_map[] = {
265 /* 1: IT Line 1 (USB streaming) */
266 /* 2: OT Line 1 (Speaker) */
267 /* 3: IT Line 1 (Line connector) */
268 { 4, "Line 1 In" }, /* FU */
269 /* 5: OT Line 1 (USB streaming) */
270 /* 6: IT Line 2 (USB streaming) */
271 /* 7: OT Line 2 (Speaker) */
272 /* 8: IT Line 2 (Line connector) */
273 { 9, "Line 2 In" }, /* FU */
274 /* 10: OT Line 2 (USB streaming) */
275 /* 11: IT Mic (Line connector) */
276 /* 12: OT Mic (USB streaming) */
277 { 0 } /* terminator */
278};
279
264/* 280/*
265 * Control map entries 281 * Control map entries
266 */ 282 */
@@ -285,6 +301,11 @@ static struct usbmix_ctl_map usbmix_ctl_maps[] = {
285 .map = live24ext_map, 301 .map = live24ext_map,
286 }, 302 },
287 { 303 {
304 .id = USB_ID(0x041e, 0x3048),
305 .map = audigy2nx_map,
306 .selector_map = audigy2nx_selectors,
307 },
308 {
288 /* Hercules DJ Console (Windows Edition) */ 309 /* Hercules DJ Console (Windows Edition) */
289 .id = USB_ID(0x06f8, 0xb000), 310 .id = USB_ID(0x06f8, 0xb000),
290 .ignore_ctl_error = 1, 311 .ignore_ctl_error = 1,
@@ -311,6 +332,11 @@ static struct usbmix_ctl_map usbmix_ctl_maps[] = {
311 .id = USB_ID(0x0ccd, 0x0028), 332 .id = USB_ID(0x0ccd, 0x0028),
312 .map = aureon_51_2_map, 333 .map = aureon_51_2_map,
313 }, 334 },
335 {
336 .id = USB_ID(0x13e5, 0x0001),
337 .map = scratch_live_map,
338 .ignore_ctl_error = 1,
339 },
314 { 0 } /* terminator */ 340 { 0 } /* terminator */
315}; 341};
316 342
diff --git a/sound/usb/usbquirks.h b/sound/usb/usbquirks.h
index 5d8ef09b9dcc..647ef5029651 100644
--- a/sound/usb/usbquirks.h
+++ b/sound/usb/usbquirks.h
@@ -39,6 +39,16 @@
39 .idProduct = prod, \ 39 .idProduct = prod, \
40 .bInterfaceClass = USB_CLASS_VENDOR_SPEC 40 .bInterfaceClass = USB_CLASS_VENDOR_SPEC
41 41
42/* Creative/Toshiba Multimedia Center SB-0500 */
43{
44 USB_DEVICE(0x041e, 0x3048),
45 .driver_info = (unsigned long) & (const struct snd_usb_audio_quirk) {
46 .vendor_name = "Toshiba",
47 .product_name = "SB-0500",
48 .ifnum = QUIRK_NO_INTERFACE
49 }
50},
51
42/* Creative/E-Mu devices */ 52/* Creative/E-Mu devices */
43{ 53{
44 USB_DEVICE(0x041e, 0x3010), 54 USB_DEVICE(0x041e, 0x3010),
diff --git a/sound/usb/usx2y/usb_stream.c b/sound/usb/usx2y/usb_stream.c
index 70b96355ca4c..24393dafcb6e 100644
--- a/sound/usb/usx2y/usb_stream.c
+++ b/sound/usb/usx2y/usb_stream.c
@@ -557,7 +557,7 @@ static void stream_start(struct usb_stream_kernel *sk,
557 s->idle_insize -= max_diff - max_diff_0; 557 s->idle_insize -= max_diff - max_diff_0;
558 s->idle_insize += urb_size - s->period_size; 558 s->idle_insize += urb_size - s->period_size;
559 if (s->idle_insize < 0) { 559 if (s->idle_insize < 0) {
560 snd_printk("%i %i %i\n", 560 snd_printk(KERN_WARNING "%i %i %i\n",
561 s->idle_insize, urb_size, s->period_size); 561 s->idle_insize, urb_size, s->period_size);
562 return; 562 return;
563 } else if (s->idle_insize == 0) { 563 } else if (s->idle_insize == 0) {