aboutsummaryrefslogtreecommitdiffstats
path: root/sound
diff options
context:
space:
mode:
Diffstat (limited to 'sound')
-rw-r--r--sound/atmel/ac97c.c2
-rw-r--r--sound/pci/asihpi/hpi6205.c22
-rw-r--r--sound/soc/davinci/davinci-mcasp.c2
-rw-r--r--sound/soc/fsl/mpc5200_dma.h2
-rw-r--r--sound/soc/pxa/spitz.c36
-rw-r--r--sound/spi/at73c213.c1
-rw-r--r--sound/usb/clock.c12
-rw-r--r--sound/usb/endpoint.c1
-rw-r--r--sound/usb/format.c104
-rw-r--r--sound/usb/helper.h4
-rw-r--r--sound/usb/mixer.c32
11 files changed, 137 insertions, 81 deletions
diff --git a/sound/atmel/ac97c.c b/sound/atmel/ac97c.c
index 428121a7e705..10c3a871a12d 100644
--- a/sound/atmel/ac97c.c
+++ b/sound/atmel/ac97c.c
@@ -657,7 +657,7 @@ static irqreturn_t atmel_ac97c_interrupt(int irq, void *dev)
657 if (sr & AC97C_SR_CAEVT) { 657 if (sr & AC97C_SR_CAEVT) {
658 struct snd_pcm_runtime *runtime; 658 struct snd_pcm_runtime *runtime;
659 int offset, next_period, block_size; 659 int offset, next_period, block_size;
660 dev_info(&chip->pdev->dev, "channel A event%s%s%s%s%s%s\n", 660 dev_dbg(&chip->pdev->dev, "channel A event%s%s%s%s%s%s\n",
661 casr & AC97C_CSR_OVRUN ? " OVRUN" : "", 661 casr & AC97C_CSR_OVRUN ? " OVRUN" : "",
662 casr & AC97C_CSR_RXRDY ? " RXRDY" : "", 662 casr & AC97C_CSR_RXRDY ? " RXRDY" : "",
663 casr & AC97C_CSR_UNRUN ? " UNRUN" : "", 663 casr & AC97C_CSR_UNRUN ? " UNRUN" : "",
diff --git a/sound/pci/asihpi/hpi6205.c b/sound/pci/asihpi/hpi6205.c
index e89991ea3543..3b4413448226 100644
--- a/sound/pci/asihpi/hpi6205.c
+++ b/sound/pci/asihpi/hpi6205.c
@@ -941,11 +941,11 @@ static void outstream_host_buffer_free(struct hpi_adapter_obj *pao,
941 941
942} 942}
943 943
944static long outstream_get_space_available(struct hpi_hostbuffer_status 944static u32 outstream_get_space_available(struct hpi_hostbuffer_status
945 *status) 945 *status)
946{ 946{
947 return status->size_in_bytes - ((long)(status->host_index) - 947 return status->size_in_bytes - (status->host_index -
948 (long)(status->dSP_index)); 948 status->dSP_index);
949} 949}
950 950
951static void outstream_write(struct hpi_adapter_obj *pao, 951static void outstream_write(struct hpi_adapter_obj *pao,
@@ -954,7 +954,7 @@ static void outstream_write(struct hpi_adapter_obj *pao,
954 struct hpi_hw_obj *phw = pao->priv; 954 struct hpi_hw_obj *phw = pao->priv;
955 struct bus_master_interface *interface = phw->p_interface_buffer; 955 struct bus_master_interface *interface = phw->p_interface_buffer;
956 struct hpi_hostbuffer_status *status; 956 struct hpi_hostbuffer_status *status;
957 long space_available; 957 u32 space_available;
958 958
959 if (!phw->outstream_host_buffer_size[phm->obj_index]) { 959 if (!phw->outstream_host_buffer_size[phm->obj_index]) {
960 /* there is no BBM buffer, write via message */ 960 /* there is no BBM buffer, write via message */
@@ -1007,7 +1007,7 @@ static void outstream_write(struct hpi_adapter_obj *pao,
1007 } 1007 }
1008 1008
1009 space_available = outstream_get_space_available(status); 1009 space_available = outstream_get_space_available(status);
1010 if (space_available < (long)phm->u.d.u.data.data_size) { 1010 if (space_available < phm->u.d.u.data.data_size) {
1011 phr->error = HPI_ERROR_INVALID_DATASIZE; 1011 phr->error = HPI_ERROR_INVALID_DATASIZE;
1012 return; 1012 return;
1013 } 1013 }
@@ -1018,7 +1018,7 @@ static void outstream_write(struct hpi_adapter_obj *pao,
1018 && hpios_locked_mem_valid(&phw->outstream_host_buffers[phm-> 1018 && hpios_locked_mem_valid(&phw->outstream_host_buffers[phm->
1019 obj_index])) { 1019 obj_index])) {
1020 u8 *p_bbm_data; 1020 u8 *p_bbm_data;
1021 long l_first_write; 1021 u32 l_first_write;
1022 u8 *p_app_data = (u8 *)phm->u.d.u.data.pb_data; 1022 u8 *p_app_data = (u8 *)phm->u.d.u.data.pb_data;
1023 1023
1024 if (hpios_locked_mem_get_virt_addr(&phw-> 1024 if (hpios_locked_mem_get_virt_addr(&phw->
@@ -1248,9 +1248,9 @@ static void instream_start(struct hpi_adapter_obj *pao,
1248 hw_message(pao, phm, phr); 1248 hw_message(pao, phm, phr);
1249} 1249}
1250 1250
1251static long instream_get_bytes_available(struct hpi_hostbuffer_status *status) 1251static u32 instream_get_bytes_available(struct hpi_hostbuffer_status *status)
1252{ 1252{
1253 return (long)(status->dSP_index) - (long)(status->host_index); 1253 return status->dSP_index - status->host_index;
1254} 1254}
1255 1255
1256static void instream_read(struct hpi_adapter_obj *pao, 1256static void instream_read(struct hpi_adapter_obj *pao,
@@ -1259,9 +1259,9 @@ static void instream_read(struct hpi_adapter_obj *pao,
1259 struct hpi_hw_obj *phw = pao->priv; 1259 struct hpi_hw_obj *phw = pao->priv;
1260 struct bus_master_interface *interface = phw->p_interface_buffer; 1260 struct bus_master_interface *interface = phw->p_interface_buffer;
1261 struct hpi_hostbuffer_status *status; 1261 struct hpi_hostbuffer_status *status;
1262 long data_available; 1262 u32 data_available;
1263 u8 *p_bbm_data; 1263 u8 *p_bbm_data;
1264 long l_first_read; 1264 u32 l_first_read;
1265 u8 *p_app_data = (u8 *)phm->u.d.u.data.pb_data; 1265 u8 *p_app_data = (u8 *)phm->u.d.u.data.pb_data;
1266 1266
1267 if (!phw->instream_host_buffer_size[phm->obj_index]) { 1267 if (!phw->instream_host_buffer_size[phm->obj_index]) {
@@ -1272,7 +1272,7 @@ static void instream_read(struct hpi_adapter_obj *pao,
1272 1272
1273 status = &interface->instream_host_buffer_status[phm->obj_index]; 1273 status = &interface->instream_host_buffer_status[phm->obj_index];
1274 data_available = instream_get_bytes_available(status); 1274 data_available = instream_get_bytes_available(status);
1275 if (data_available < (long)phm->u.d.u.data.data_size) { 1275 if (data_available < phm->u.d.u.data.data_size) {
1276 phr->error = HPI_ERROR_INVALID_DATASIZE; 1276 phr->error = HPI_ERROR_INVALID_DATASIZE;
1277 return; 1277 return;
1278 } 1278 }
diff --git a/sound/soc/davinci/davinci-mcasp.c b/sound/soc/davinci/davinci-mcasp.c
index 79f0f4ad242c..d3955096d872 100644
--- a/sound/soc/davinci/davinci-mcasp.c
+++ b/sound/soc/davinci/davinci-mcasp.c
@@ -612,7 +612,6 @@ static void davinci_hw_common_param(struct davinci_audio_dev *dev, int stream)
612 NUMDMA_MASK); 612 NUMDMA_MASK);
613 mcasp_mod_bits(dev->base + DAVINCI_MCASP_WFIFOCTL, 613 mcasp_mod_bits(dev->base + DAVINCI_MCASP_WFIFOCTL,
614 ((dev->txnumevt * tx_ser) << 8), NUMEVT_MASK); 614 ((dev->txnumevt * tx_ser) << 8), NUMEVT_MASK);
615 mcasp_set_bits(dev->base + DAVINCI_MCASP_WFIFOCTL, FIFO_ENABLE);
616 } 615 }
617 616
618 if (dev->rxnumevt && stream == SNDRV_PCM_STREAM_CAPTURE) { 617 if (dev->rxnumevt && stream == SNDRV_PCM_STREAM_CAPTURE) {
@@ -623,7 +622,6 @@ static void davinci_hw_common_param(struct davinci_audio_dev *dev, int stream)
623 NUMDMA_MASK); 622 NUMDMA_MASK);
624 mcasp_mod_bits(dev->base + DAVINCI_MCASP_RFIFOCTL, 623 mcasp_mod_bits(dev->base + DAVINCI_MCASP_RFIFOCTL,
625 ((dev->rxnumevt * rx_ser) << 8), NUMEVT_MASK); 624 ((dev->rxnumevt * rx_ser) << 8), NUMEVT_MASK);
626 mcasp_set_bits(dev->base + DAVINCI_MCASP_RFIFOCTL, FIFO_ENABLE);
627 } 625 }
628} 626}
629 627
diff --git a/sound/soc/fsl/mpc5200_dma.h b/sound/soc/fsl/mpc5200_dma.h
index 22208b373fb9..e1ec6d91ea38 100644
--- a/sound/soc/fsl/mpc5200_dma.h
+++ b/sound/soc/fsl/mpc5200_dma.h
@@ -73,7 +73,7 @@ struct psc_dma {
73}; 73};
74 74
75/* Utility for retrieving psc_dma_stream structure from a substream */ 75/* Utility for retrieving psc_dma_stream structure from a substream */
76inline struct psc_dma_stream * 76static inline struct psc_dma_stream *
77to_psc_dma_stream(struct snd_pcm_substream *substream, struct psc_dma *psc_dma) 77to_psc_dma_stream(struct snd_pcm_substream *substream, struct psc_dma *psc_dma)
78{ 78{
79 if (substream->pstr->stream == SNDRV_PCM_STREAM_CAPTURE) 79 if (substream->pstr->stream == SNDRV_PCM_STREAM_CAPTURE)
diff --git a/sound/soc/pxa/spitz.c b/sound/soc/pxa/spitz.c
index 1941a357e8c4..d256f5f313b5 100644
--- a/sound/soc/pxa/spitz.c
+++ b/sound/soc/pxa/spitz.c
@@ -328,38 +328,6 @@ static struct snd_soc_device spitz_snd_devdata = {
328 .codec_dev = &soc_codec_dev_wm8750, 328 .codec_dev = &soc_codec_dev_wm8750,
329}; 329};
330 330
331/*
332 * FIXME: This is a temporary bodge to avoid cross-tree merge issues.
333 * New drivers should register the wm8750 I2C device in the machine
334 * setup code (under arch/arm for ARM systems).
335 */
336static int wm8750_i2c_register(void)
337{
338 struct i2c_board_info info;
339 struct i2c_adapter *adapter;
340 struct i2c_client *client;
341
342 memset(&info, 0, sizeof(struct i2c_board_info));
343 info.addr = 0x1b;
344 strlcpy(info.type, "wm8750", I2C_NAME_SIZE);
345
346 adapter = i2c_get_adapter(0);
347 if (!adapter) {
348 printk(KERN_ERR "can't get i2c adapter 0\n");
349 return -ENODEV;
350 }
351
352 client = i2c_new_device(adapter, &info);
353 i2c_put_adapter(adapter);
354 if (!client) {
355 printk(KERN_ERR "can't add i2c device at 0x%x\n",
356 (unsigned int)info.addr);
357 return -ENODEV;
358 }
359
360 return 0;
361}
362
363static struct platform_device *spitz_snd_device; 331static struct platform_device *spitz_snd_device;
364 332
365static int __init spitz_init(void) 333static int __init spitz_init(void)
@@ -369,10 +337,6 @@ static int __init spitz_init(void)
369 if (!(machine_is_spitz() || machine_is_borzoi() || machine_is_akita())) 337 if (!(machine_is_spitz() || machine_is_borzoi() || machine_is_akita()))
370 return -ENODEV; 338 return -ENODEV;
371 339
372 ret = wm8750_i2c_setup();
373 if (ret != 0)
374 return ret;
375
376 spitz_snd_device = platform_device_alloc("soc-audio", -1); 340 spitz_snd_device = platform_device_alloc("soc-audio", -1);
377 if (!spitz_snd_device) 341 if (!spitz_snd_device)
378 return -ENOMEM; 342 return -ENOMEM;
diff --git a/sound/spi/at73c213.c b/sound/spi/at73c213.c
index 4c7b051f9d17..1bc56b2b94e2 100644
--- a/sound/spi/at73c213.c
+++ b/sound/spi/at73c213.c
@@ -69,7 +69,6 @@ struct snd_at73c213 {
69 int irq; 69 int irq;
70 int period; 70 int period;
71 unsigned long bitrate; 71 unsigned long bitrate;
72 struct clk *bitclk;
73 struct ssc_device *ssc; 72 struct ssc_device *ssc;
74 struct spi_device *spi; 73 struct spi_device *spi;
75 u8 spi_wbuffer[2]; 74 u8 spi_wbuffer[2];
diff --git a/sound/usb/clock.c b/sound/usb/clock.c
index b7aadd614c70..b5855114667e 100644
--- a/sound/usb/clock.c
+++ b/sound/usb/clock.c
@@ -103,7 +103,8 @@ static int uac_clock_selector_get_val(struct snd_usb_audio *chip, int selector_i
103 ret = snd_usb_ctl_msg(chip->dev, usb_rcvctrlpipe(chip->dev, 0), 103 ret = snd_usb_ctl_msg(chip->dev, usb_rcvctrlpipe(chip->dev, 0),
104 UAC2_CS_CUR, 104 UAC2_CS_CUR,
105 USB_RECIP_INTERFACE | USB_TYPE_CLASS | USB_DIR_IN, 105 USB_RECIP_INTERFACE | USB_TYPE_CLASS | USB_DIR_IN,
106 UAC2_CX_CLOCK_SELECTOR << 8, selector_id << 8, 106 UAC2_CX_CLOCK_SELECTOR << 8,
107 snd_usb_ctrl_intf(chip) | (selector_id << 8),
107 &buf, sizeof(buf), 1000); 108 &buf, sizeof(buf), 1000);
108 109
109 if (ret < 0) 110 if (ret < 0)
@@ -120,7 +121,8 @@ static bool uac_clock_source_is_valid(struct snd_usb_audio *chip, int source_id)
120 121
121 err = snd_usb_ctl_msg(dev, usb_rcvctrlpipe(dev, 0), UAC2_CS_CUR, 122 err = snd_usb_ctl_msg(dev, usb_rcvctrlpipe(dev, 0), UAC2_CS_CUR,
122 USB_TYPE_CLASS | USB_RECIP_INTERFACE | USB_DIR_IN, 123 USB_TYPE_CLASS | USB_RECIP_INTERFACE | USB_DIR_IN,
123 UAC2_CS_CONTROL_CLOCK_VALID << 8, source_id << 8, 124 UAC2_CS_CONTROL_CLOCK_VALID << 8,
125 snd_usb_ctrl_intf(chip) | (source_id << 8),
124 &data, sizeof(data), 1000); 126 &data, sizeof(data), 1000);
125 127
126 if (err < 0) { 128 if (err < 0) {
@@ -269,7 +271,8 @@ static int set_sample_rate_v2(struct snd_usb_audio *chip, int iface,
269 data[3] = rate >> 24; 271 data[3] = rate >> 24;
270 if ((err = snd_usb_ctl_msg(dev, usb_sndctrlpipe(dev, 0), UAC2_CS_CUR, 272 if ((err = snd_usb_ctl_msg(dev, usb_sndctrlpipe(dev, 0), UAC2_CS_CUR,
271 USB_TYPE_CLASS | USB_RECIP_INTERFACE | USB_DIR_OUT, 273 USB_TYPE_CLASS | USB_RECIP_INTERFACE | USB_DIR_OUT,
272 UAC2_CS_CONTROL_SAM_FREQ << 8, clock << 8, 274 UAC2_CS_CONTROL_SAM_FREQ << 8,
275 snd_usb_ctrl_intf(chip) | (clock << 8),
273 data, sizeof(data), 1000)) < 0) { 276 data, sizeof(data), 1000)) < 0) {
274 snd_printk(KERN_ERR "%d:%d:%d: cannot set freq %d (v2)\n", 277 snd_printk(KERN_ERR "%d:%d:%d: cannot set freq %d (v2)\n",
275 dev->devnum, iface, fmt->altsetting, rate); 278 dev->devnum, iface, fmt->altsetting, rate);
@@ -278,7 +281,8 @@ static int set_sample_rate_v2(struct snd_usb_audio *chip, int iface,
278 281
279 if ((err = snd_usb_ctl_msg(dev, usb_rcvctrlpipe(dev, 0), UAC2_CS_CUR, 282 if ((err = snd_usb_ctl_msg(dev, usb_rcvctrlpipe(dev, 0), UAC2_CS_CUR,
280 USB_TYPE_CLASS | USB_RECIP_INTERFACE | USB_DIR_IN, 283 USB_TYPE_CLASS | USB_RECIP_INTERFACE | USB_DIR_IN,
281 UAC2_CS_CONTROL_SAM_FREQ << 8, clock << 8, 284 UAC2_CS_CONTROL_SAM_FREQ << 8,
285 snd_usb_ctrl_intf(chip) | (clock << 8),
282 data, sizeof(data), 1000)) < 0) { 286 data, sizeof(data), 1000)) < 0) {
283 snd_printk(KERN_WARNING "%d:%d:%d: cannot get freq (v2)\n", 287 snd_printk(KERN_WARNING "%d:%d:%d: cannot get freq (v2)\n",
284 dev->devnum, iface, fmt->altsetting); 288 dev->devnum, iface, fmt->altsetting);
diff --git a/sound/usb/endpoint.c b/sound/usb/endpoint.c
index 9593b91452b9..6f6596cf2b19 100644
--- a/sound/usb/endpoint.c
+++ b/sound/usb/endpoint.c
@@ -427,6 +427,7 @@ int snd_usb_parse_audio_endpoints(struct snd_usb_audio *chip, int iface_no)
427 if (snd_usb_parse_audio_format(chip, fp, format, fmt, stream, alts) < 0) { 427 if (snd_usb_parse_audio_format(chip, fp, format, fmt, stream, alts) < 0) {
428 kfree(fp->rate_table); 428 kfree(fp->rate_table);
429 kfree(fp); 429 kfree(fp);
430 fp = NULL;
430 continue; 431 continue;
431 } 432 }
432 433
diff --git a/sound/usb/format.c b/sound/usb/format.c
index 5367cd1e52d9..30364aba79cc 100644
--- a/sound/usb/format.c
+++ b/sound/usb/format.c
@@ -206,6 +206,60 @@ static int parse_audio_format_rates_v1(struct snd_usb_audio *chip, struct audiof
206} 206}
207 207
208/* 208/*
209 * Helper function to walk the array of sample rate triplets reported by
210 * the device. The problem is that we need to parse whole array first to
211 * get to know how many sample rates we have to expect.
212 * Then fp->rate_table can be allocated and filled.
213 */
214static int parse_uac2_sample_rate_range(struct audioformat *fp, int nr_triplets,
215 const unsigned char *data)
216{
217 int i, nr_rates = 0;
218
219 fp->rates = fp->rate_min = fp->rate_max = 0;
220
221 for (i = 0; i < nr_triplets; i++) {
222 int min = combine_quad(&data[2 + 12 * i]);
223 int max = combine_quad(&data[6 + 12 * i]);
224 int res = combine_quad(&data[10 + 12 * i]);
225 int rate;
226
227 if ((max < 0) || (min < 0) || (res < 0) || (max < min))
228 continue;
229
230 /*
231 * for ranges with res == 1, we announce a continuous sample
232 * rate range, and this function should return 0 for no further
233 * parsing.
234 */
235 if (res == 1) {
236 fp->rate_min = min;
237 fp->rate_max = max;
238 fp->rates = SNDRV_PCM_RATE_CONTINUOUS;
239 return 0;
240 }
241
242 for (rate = min; rate <= max; rate += res) {
243 if (fp->rate_table)
244 fp->rate_table[nr_rates] = rate;
245 if (!fp->rate_min || rate < fp->rate_min)
246 fp->rate_min = rate;
247 if (!fp->rate_max || rate > fp->rate_max)
248 fp->rate_max = rate;
249 fp->rates |= snd_pcm_rate_to_rate_bit(rate);
250
251 nr_rates++;
252
253 /* avoid endless loop */
254 if (res == 0)
255 break;
256 }
257 }
258
259 return nr_rates;
260}
261
262/*
209 * parse the format descriptor and stores the possible sample rates 263 * parse the format descriptor and stores the possible sample rates
210 * on the audioformat table (audio class v2). 264 * on the audioformat table (audio class v2).
211 */ 265 */
@@ -215,13 +269,20 @@ static int parse_audio_format_rates_v2(struct snd_usb_audio *chip,
215{ 269{
216 struct usb_device *dev = chip->dev; 270 struct usb_device *dev = chip->dev;
217 unsigned char tmp[2], *data; 271 unsigned char tmp[2], *data;
218 int i, nr_rates, data_size, ret = 0; 272 int nr_triplets, data_size, ret = 0;
219 int clock = snd_usb_clock_find_source(chip, chip->ctrl_intf, fp->clock); 273 int clock = snd_usb_clock_find_source(chip, chip->ctrl_intf, fp->clock);
220 274
275 if (clock < 0) {
276 snd_printk(KERN_ERR "%s(): unable to find clock source (clock %d)\n",
277 __func__, clock);
278 goto err;
279 }
280
221 /* get the number of sample rates first by only fetching 2 bytes */ 281 /* get the number of sample rates first by only fetching 2 bytes */
222 ret = snd_usb_ctl_msg(dev, usb_rcvctrlpipe(dev, 0), UAC2_CS_RANGE, 282 ret = snd_usb_ctl_msg(dev, usb_rcvctrlpipe(dev, 0), UAC2_CS_RANGE,
223 USB_TYPE_CLASS | USB_RECIP_INTERFACE | USB_DIR_IN, 283 USB_TYPE_CLASS | USB_RECIP_INTERFACE | USB_DIR_IN,
224 UAC2_CS_CONTROL_SAM_FREQ << 8, clock << 8, 284 UAC2_CS_CONTROL_SAM_FREQ << 8,
285 snd_usb_ctrl_intf(chip) | (clock << 8),
225 tmp, sizeof(tmp), 1000); 286 tmp, sizeof(tmp), 1000);
226 287
227 if (ret < 0) { 288 if (ret < 0) {
@@ -230,8 +291,8 @@ static int parse_audio_format_rates_v2(struct snd_usb_audio *chip,
230 goto err; 291 goto err;
231 } 292 }
232 293
233 nr_rates = (tmp[1] << 8) | tmp[0]; 294 nr_triplets = (tmp[1] << 8) | tmp[0];
234 data_size = 2 + 12 * nr_rates; 295 data_size = 2 + 12 * nr_triplets;
235 data = kzalloc(data_size, GFP_KERNEL); 296 data = kzalloc(data_size, GFP_KERNEL);
236 if (!data) { 297 if (!data) {
237 ret = -ENOMEM; 298 ret = -ENOMEM;
@@ -241,7 +302,8 @@ static int parse_audio_format_rates_v2(struct snd_usb_audio *chip,
241 /* now get the full information */ 302 /* now get the full information */
242 ret = snd_usb_ctl_msg(dev, usb_rcvctrlpipe(dev, 0), UAC2_CS_RANGE, 303 ret = snd_usb_ctl_msg(dev, usb_rcvctrlpipe(dev, 0), UAC2_CS_RANGE,
243 USB_TYPE_CLASS | USB_RECIP_INTERFACE | USB_DIR_IN, 304 USB_TYPE_CLASS | USB_RECIP_INTERFACE | USB_DIR_IN,
244 UAC2_CS_CONTROL_SAM_FREQ << 8, clock << 8, 305 UAC2_CS_CONTROL_SAM_FREQ << 8,
306 snd_usb_ctrl_intf(chip) | (clock << 8),
245 data, data_size, 1000); 307 data, data_size, 1000);
246 308
247 if (ret < 0) { 309 if (ret < 0) {
@@ -251,26 +313,28 @@ static int parse_audio_format_rates_v2(struct snd_usb_audio *chip,
251 goto err_free; 313 goto err_free;
252 } 314 }
253 315
254 fp->rate_table = kmalloc(sizeof(int) * nr_rates, GFP_KERNEL); 316 /* Call the triplet parser, and make sure fp->rate_table is NULL.
317 * We just use the return value to know how many sample rates we
318 * will have to deal with. */
319 kfree(fp->rate_table);
320 fp->rate_table = NULL;
321 fp->nr_rates = parse_uac2_sample_rate_range(fp, nr_triplets, data);
322
323 if (fp->nr_rates == 0) {
324 /* SNDRV_PCM_RATE_CONTINUOUS */
325 ret = 0;
326 goto err_free;
327 }
328
329 fp->rate_table = kmalloc(sizeof(int) * fp->nr_rates, GFP_KERNEL);
255 if (!fp->rate_table) { 330 if (!fp->rate_table) {
256 ret = -ENOMEM; 331 ret = -ENOMEM;
257 goto err_free; 332 goto err_free;
258 } 333 }
259 334
260 fp->nr_rates = 0; 335 /* Call the triplet parser again, but this time, fp->rate_table is
261 fp->rate_min = fp->rate_max = 0; 336 * allocated, so the rates will be stored */
262 337 parse_uac2_sample_rate_range(fp, nr_triplets, data);
263 for (i = 0; i < nr_rates; i++) {
264 int rate = combine_quad(&data[2 + 12 * i]);
265
266 fp->rate_table[fp->nr_rates] = rate;
267 if (!fp->rate_min || rate < fp->rate_min)
268 fp->rate_min = rate;
269 if (!fp->rate_max || rate > fp->rate_max)
270 fp->rate_max = rate;
271 fp->rates |= snd_pcm_rate_to_rate_bit(rate);
272 fp->nr_rates++;
273 }
274 338
275err_free: 339err_free:
276 kfree(data); 340 kfree(data);
diff --git a/sound/usb/helper.h b/sound/usb/helper.h
index a6b0e51b3a9a..09bd943c43bf 100644
--- a/sound/usb/helper.h
+++ b/sound/usb/helper.h
@@ -28,5 +28,9 @@ unsigned char snd_usb_parse_datainterval(struct snd_usb_audio *chip,
28#define snd_usb_get_speed(dev) ((dev)->speed) 28#define snd_usb_get_speed(dev) ((dev)->speed)
29#endif 29#endif
30 30
31static inline int snd_usb_ctrl_intf(struct snd_usb_audio *chip)
32{
33 return get_iface_desc(chip->ctrl_intf)->bInterfaceNumber;
34}
31 35
32#endif /* __USBAUDIO_HELPER_H */ 36#endif /* __USBAUDIO_HELPER_H */
diff --git a/sound/usb/mixer.c b/sound/usb/mixer.c
index a060d005e209..736d134cc03c 100644
--- a/sound/usb/mixer.c
+++ b/sound/usb/mixer.c
@@ -297,20 +297,27 @@ static int get_ctl_value_v1(struct usb_mixer_elem_info *cval, int request, int v
297 297
298static int get_ctl_value_v2(struct usb_mixer_elem_info *cval, int request, int validx, int *value_ret) 298static int get_ctl_value_v2(struct usb_mixer_elem_info *cval, int request, int validx, int *value_ret)
299{ 299{
300 unsigned char buf[14]; /* enough space for one range of 4 bytes */ 300 unsigned char buf[2 + 3*sizeof(__u16)]; /* enough space for one range */
301 unsigned char *val; 301 unsigned char *val;
302 int ret; 302 int ret, size;
303 __u8 bRequest; 303 __u8 bRequest;
304 304
305 bRequest = (request == UAC_GET_CUR) ? 305 if (request == UAC_GET_CUR) {
306 UAC2_CS_CUR : UAC2_CS_RANGE; 306 bRequest = UAC2_CS_CUR;
307 size = sizeof(__u16);
308 } else {
309 bRequest = UAC2_CS_RANGE;
310 size = sizeof(buf);
311 }
312
313 memset(buf, 0, sizeof(buf));
307 314
308 ret = snd_usb_ctl_msg(cval->mixer->chip->dev, 315 ret = snd_usb_ctl_msg(cval->mixer->chip->dev,
309 usb_rcvctrlpipe(cval->mixer->chip->dev, 0), 316 usb_rcvctrlpipe(cval->mixer->chip->dev, 0),
310 bRequest, 317 bRequest,
311 USB_RECIP_INTERFACE | USB_TYPE_CLASS | USB_DIR_IN, 318 USB_RECIP_INTERFACE | USB_TYPE_CLASS | USB_DIR_IN,
312 validx, cval->mixer->ctrlif | (cval->id << 8), 319 validx, cval->mixer->ctrlif | (cval->id << 8),
313 buf, sizeof(buf), 1000); 320 buf, size, 1000);
314 321
315 if (ret < 0) { 322 if (ret < 0) {
316 snd_printk(KERN_ERR "cannot get ctl value: req = %#x, wValue = %#x, wIndex = %#x, type = %d\n", 323 snd_printk(KERN_ERR "cannot get ctl value: req = %#x, wValue = %#x, wIndex = %#x, type = %d\n",
@@ -318,6 +325,8 @@ static int get_ctl_value_v2(struct usb_mixer_elem_info *cval, int request, int v
318 return ret; 325 return ret;
319 } 326 }
320 327
328 /* FIXME: how should we handle multiple triplets here? */
329
321 switch (request) { 330 switch (request) {
322 case UAC_GET_CUR: 331 case UAC_GET_CUR:
323 val = buf; 332 val = buf;
@@ -1098,6 +1107,19 @@ static void build_feature_ctl(struct mixer_build *state, void *raw_desc,
1098 } 1107 }
1099 break; 1108 break;
1100 1109
1110 case USB_ID(0x046d, 0x0809):
1111 case USB_ID(0x046d, 0x0991):
1112 /* Most audio usb devices lie about volume resolution.
1113 * Most Logitech webcams have res = 384.
1114 * Proboly there is some logitech magic behind this number --fishor
1115 */
1116 if (!strcmp(kctl->id.name, "Mic Capture Volume")) {
1117 snd_printk(KERN_INFO
1118 "set resolution quirk: cval->res = 384\n");
1119 cval->res = 384;
1120 }
1121 break;
1122
1101 } 1123 }
1102 1124
1103 snd_printdd(KERN_INFO "[%d] FU [%s] ch = %d, val = %d/%d/%d\n", 1125 snd_printdd(KERN_INFO "[%d] FU [%s] ch = %d, val = %d/%d/%d\n",