Lines Matching +full:min +full:- +full:sample +full:- +full:time
1 // SPDX-License-Identifier: GPL-2.0-or-later
9 #include <linux/usb/audio-v2.h>
10 #include <linux/usb/audio-v3.h>
39 switch (fp->protocol) { in parse_audio_format_i_type()
43 sample_width = fmt->bBitResolution; in parse_audio_format_i_type()
44 sample_bytes = fmt->bSubframeSize; in parse_audio_format_i_type()
51 sample_width = fmt->bBitResolution; in parse_audio_format_i_type()
52 sample_bytes = fmt->bSubslotSize; in parse_audio_format_i_type()
57 fp->dsd_raw = true; in parse_audio_format_i_type()
66 sample_width = as->bBitResolution; in parse_audio_format_i_type()
67 sample_bytes = as->bSubslotSize; in parse_audio_format_i_type()
77 fp->fmt_bits = sample_width; in parse_audio_format_i_type()
83 fp->iface, fp->altsetting); in parse_audio_format_i_type()
87 if (((chip->usb_id == USB_ID(0x0582, 0x0016)) || in parse_audio_format_i_type()
88 /* Edirol SD-90 */ in parse_audio_format_i_type()
89 (chip->usb_id == USB_ID(0x0582, 0x000c))) && in parse_audio_format_i_type()
90 /* Roland SC-D70 */ in parse_audio_format_i_type()
94 usb_audio_info(chip, "%u:%d : sample bitwidth %d in over sample bytes %d\n", in parse_audio_format_i_type()
95 fp->iface, fp->altsetting, in parse_audio_format_i_type()
120 "%u:%d : unsupported sample bitwidth %d in %d bytes\n", in parse_audio_format_i_type()
121 fp->iface, fp->altsetting, in parse_audio_format_i_type()
129 if (chip->usb_id == USB_ID(0x04fa, 0x4201)) in parse_audio_format_i_type()
146 fp->iface, fp->altsetting, format); in parse_audio_format_i_type()
156 kfree(fp->rate_table); in set_fixed_rate()
157 fp->rate_table = kmalloc(sizeof(int), GFP_KERNEL); in set_fixed_rate()
158 if (!fp->rate_table) in set_fixed_rate()
159 return -ENOMEM; in set_fixed_rate()
160 fp->nr_rates = 1; in set_fixed_rate()
161 fp->rate_min = rate; in set_fixed_rate()
162 fp->rate_max = rate; in set_fixed_rate()
163 fp->rates = rate_bits; in set_fixed_rate()
164 fp->rate_table[0] = rate; in set_fixed_rate()
169 * parse the format descriptor and stores the possible sample rates
186 fp->iface, fp->altsetting); in parse_audio_format_rates_v1()
187 return -EINVAL; in parse_audio_format_rates_v1()
196 fp->rate_table = kmalloc_array(nr_rates, sizeof(int), in parse_audio_format_rates_v1()
198 if (fp->rate_table == NULL) in parse_audio_format_rates_v1()
199 return -ENOMEM; in parse_audio_format_rates_v1()
201 fp->nr_rates = 0; in parse_audio_format_rates_v1()
202 fp->rate_min = fp->rate_max = 0; in parse_audio_format_rates_v1()
207 /* C-Media CM6501 mislabels its 96 kHz altsetting */ in parse_audio_format_rates_v1()
208 /* Terratec Aureon 7.1 USB C-Media 6206, too */ in parse_audio_format_rates_v1()
210 (chip->usb_id == USB_ID(0x0d8c, 0x0201) || in parse_audio_format_rates_v1()
211 chip->usb_id == USB_ID(0x0d8c, 0x0102) || in parse_audio_format_rates_v1()
212 chip->usb_id == USB_ID(0x0ccd, 0x00b1)) && in parse_audio_format_rates_v1()
213 fp->altsetting == 5 && fp->maxpacksize == 392) in parse_audio_format_rates_v1()
217 (chip->usb_id == USB_ID(0x041e, 0x4064) || in parse_audio_format_rates_v1()
218 chip->usb_id == USB_ID(0x041e, 0x4068))) in parse_audio_format_rates_v1()
221 fp->rate_table[fp->nr_rates] = rate; in parse_audio_format_rates_v1()
222 if (!fp->rate_min || rate < fp->rate_min) in parse_audio_format_rates_v1()
223 fp->rate_min = rate; in parse_audio_format_rates_v1()
224 if (!fp->rate_max || rate > fp->rate_max) in parse_audio_format_rates_v1()
225 fp->rate_max = rate; in parse_audio_format_rates_v1()
226 fp->rates |= snd_pcm_rate_to_rate_bit(rate); in parse_audio_format_rates_v1()
227 fp->nr_rates++; in parse_audio_format_rates_v1()
229 if (!fp->nr_rates) { in parse_audio_format_rates_v1()
231 return -EINVAL; in parse_audio_format_rates_v1()
235 fp->rates = SNDRV_PCM_RATE_CONTINUOUS; in parse_audio_format_rates_v1()
236 fp->rate_min = combine_triple(&fmt[offset + 1]); in parse_audio_format_rates_v1()
237 fp->rate_max = combine_triple(&fmt[offset + 4]); in parse_audio_format_rates_v1()
241 if (chip->usb_id == USB_ID(0x0b0e, 0x030b)) { in parse_audio_format_rates_v1()
243 if (fp->nr_rates != 1) in parse_audio_format_rates_v1()
253 * rates per altsetting but reports the full set each time.
264 switch (fp->altsetting) { in s1810c_valid_sample_rate()
283 * descriptor which has a non-standard bLength = 10.
294 iface = usb_ifnum_to_if(chip->dev, fp->iface); in focusrite_valid_sample_rate()
298 alts = &iface->altsetting[fp->altset_idx]; in focusrite_valid_sample_rate()
299 fmt = snd_usb_find_csint_desc(alts->extra, alts->extralen, in focusrite_valid_sample_rate()
315 fp->iface, fp->altsetting, max_rate); in focusrite_valid_sample_rate()
327 * Helper function to walk the array of sample rate triplets reported by
329 * get to know how many sample rates we have to expect.
330 * Then fp->rate_table can be allocated and filled.
338 fp->rates = fp->rate_min = fp->rate_max = 0; in parse_uac2_sample_rate_range()
341 int min = combine_quad(&data[2 + 12 * i]); in parse_uac2_sample_rate_range() local
346 if ((max < 0) || (min < 0) || (res < 0) || (max < min)) in parse_uac2_sample_rate_range()
350 * for ranges with res == 1, we announce a continuous sample in parse_uac2_sample_rate_range()
355 fp->rate_min = min; in parse_uac2_sample_rate_range()
356 fp->rate_max = max; in parse_uac2_sample_rate_range()
357 fp->rates = SNDRV_PCM_RATE_CONTINUOUS; in parse_uac2_sample_rate_range()
361 for (rate = min; rate <= max; rate += res) { in parse_uac2_sample_rate_range()
364 if (chip->usb_id == USB_ID(0x0194f, 0x010c) && in parse_uac2_sample_rate_range()
369 if (USB_ID_VENDOR(chip->usb_id) == 0x1235 && in parse_uac2_sample_rate_range()
373 if (fp->rate_table) in parse_uac2_sample_rate_range()
374 fp->rate_table[nr_rates] = rate; in parse_uac2_sample_rate_range()
375 if (!fp->rate_min || rate < fp->rate_min) in parse_uac2_sample_rate_range()
376 fp->rate_min = rate; in parse_uac2_sample_rate_range()
377 if (!fp->rate_max || rate > fp->rate_max) in parse_uac2_sample_rate_range()
378 fp->rate_max = rate; in parse_uac2_sample_rate_range()
379 fp->rates |= snd_pcm_rate_to_rate_bit(rate); in parse_uac2_sample_rate_range()
404 switch (chip->usb_id) { in line6_parse_audio_format_rates_quirk()
408 case USB_ID(0x0e41, 0x4246): /* Line6 HX-Stomp */ in line6_parse_audio_format_rates_quirk()
417 return -ENODEV; in line6_parse_audio_format_rates_quirk()
421 * parse the format descriptor and stores the possible sample rates
427 struct usb_device *dev = chip->dev; in parse_audio_format_rates_v2v3()
433 dev_err(&dev->dev, in parse_audio_format_rates_v2v3()
439 /* get the number of sample rates first by only fetching 2 bytes */ in parse_audio_format_rates_v2v3()
449 if (ret_l6 == -ENODEV) { in parse_audio_format_rates_v2v3()
451 dev_err(&dev->dev, in parse_audio_format_rates_v2v3()
452 "%s(): unable to retrieve number of sample rates (clock %d)\n", in parse_audio_format_rates_v2v3()
457 dev_info(&dev->dev, in parse_audio_format_rates_v2v3()
458 "%s(): unable to retrieve number of sample rates: set it to a predefined value (clock %d).\n", in parse_audio_format_rates_v2v3()
470 ret = -ENOMEM; in parse_audio_format_rates_v2v3()
482 dev_err(&dev->dev, in parse_audio_format_rates_v2v3()
483 "%s(): unable to retrieve sample rate range (clock %d)\n", in parse_audio_format_rates_v2v3()
485 ret = -EINVAL; in parse_audio_format_rates_v2v3()
489 /* Call the triplet parser, and make sure fp->rate_table is NULL. in parse_audio_format_rates_v2v3()
490 * We just use the return value to know how many sample rates we in parse_audio_format_rates_v2v3()
492 kfree(fp->rate_table); in parse_audio_format_rates_v2v3()
493 fp->rate_table = NULL; in parse_audio_format_rates_v2v3()
494 fp->nr_rates = parse_uac2_sample_rate_range(chip, fp, nr_triplets, data); in parse_audio_format_rates_v2v3()
496 if (fp->nr_rates == 0) { in parse_audio_format_rates_v2v3()
502 fp->rate_table = kmalloc_array(fp->nr_rates, sizeof(int), GFP_KERNEL); in parse_audio_format_rates_v2v3()
503 if (!fp->rate_table) { in parse_audio_format_rates_v2v3()
504 ret = -ENOMEM; in parse_audio_format_rates_v2v3()
508 /* Call the triplet parser again, but this time, fp->rate_table is in parse_audio_format_rates_v2v3()
529 switch (fp->protocol) { in parse_audio_format_i()
535 fmt_type = fmt->bFormatType; in parse_audio_format_i()
539 /* fp->fmt_type is already set in this case */ in parse_audio_format_i()
540 fmt_type = fp->fmt_type; in parse_audio_format_i()
550 switch (chip->usb_id) { in parse_audio_format_i()
552 case USB_ID(0x0763, 0x2003): /* M-Audio Audiophile USB */ in parse_audio_format_i()
553 if (chip->setup == 0x00 && in parse_audio_format_i()
554 fp->altsetting == 6) in parse_audio_format_i()
562 fp->formats = pcm_format_to_bits(pcm_format); in parse_audio_format_i()
564 fp->formats = parse_audio_format_i_type(chip, fp, format, _fmt); in parse_audio_format_i()
565 if (!fp->formats) in parse_audio_format_i()
566 return -EINVAL; in parse_audio_format_i()
569 /* gather possible sample rates */ in parse_audio_format_i()
570 /* audio class v1 reports possible sample rates as part of the in parse_audio_format_i()
574 switch (fp->protocol) { in parse_audio_format_i()
579 fp->channels = fmt->bNrChannels; in parse_audio_format_i()
585 /* fp->channels is already set in this case */ in parse_audio_format_i()
591 if (fp->channels < 1) { in parse_audio_format_i()
594 fp->iface, fp->altsetting, fp->channels); in parse_audio_format_i()
595 return -EINVAL; in parse_audio_format_i()
613 // fp->formats = SNDRV_PCM_FMTBIT_AC3; in parse_audio_format_ii()
614 fp->formats = SNDRV_PCM_FMTBIT_U8; /* temporary hack to receive byte streams */ in parse_audio_format_ii()
617 fp->formats = SNDRV_PCM_FMTBIT_MPEG; in parse_audio_format_ii()
622 fp->iface, fp->altsetting, format); in parse_audio_format_ii()
623 fp->formats = SNDRV_PCM_FMTBIT_MPEG; in parse_audio_format_ii()
627 fp->channels = 1; in parse_audio_format_ii()
629 switch (fp->protocol) { in parse_audio_format_ii()
633 brate = le16_to_cpu(fmt->wMaxBitRate); in parse_audio_format_ii()
634 framesize = le16_to_cpu(fmt->wSamplesPerFrame); in parse_audio_format_ii()
636 fp->frame_size = framesize; in parse_audio_format_ii()
637 ret = parse_audio_format_rates_v1(chip, fp, _fmt, 8); /* fmt[8..] sample rates */ in parse_audio_format_ii()
642 brate = le16_to_cpu(fmt->wMaxBitRate); in parse_audio_format_ii()
643 framesize = le16_to_cpu(fmt->wSamplesPerFrame); in parse_audio_format_ii()
645 fp->frame_size = framesize; in parse_audio_format_ii()
661 switch (fmt->bFormatType) { in snd_usb_parse_audio_format()
672 fp->iface, fp->altsetting, in snd_usb_parse_audio_format()
673 fmt->bFormatType); in snd_usb_parse_audio_format()
674 return -ENOTSUPP; in snd_usb_parse_audio_format()
676 fp->fmt_type = fmt->bFormatType; in snd_usb_parse_audio_format()
681 /* extigy apparently supports sample rates other than 48k in snd_usb_parse_audio_format()
684 if (chip->usb_id == USB_ID(0x041e, 0x3000) || in snd_usb_parse_audio_format()
685 chip->usb_id == USB_ID(0x041e, 0x3020) || in snd_usb_parse_audio_format()
686 chip->usb_id == USB_ID(0x041e, 0x3061)) { in snd_usb_parse_audio_format()
687 if (fmt->bFormatType == UAC_FORMAT_TYPE_I && in snd_usb_parse_audio_format()
688 fp->rates != SNDRV_PCM_RATE_48000 && in snd_usb_parse_audio_format()
689 fp->rates != SNDRV_PCM_RATE_96000) in snd_usb_parse_audio_format()
690 return -ENOTSUPP; in snd_usb_parse_audio_format()
701 u64 format = le64_to_cpu(as->bmFormats); in snd_usb_parse_audio_format_v3()
709 fp->fmt_type = UAC_FORMAT_TYPE_I; in snd_usb_parse_audio_format_v3()
711 fp->fmt_type = UAC_FORMAT_TYPE_III; in snd_usb_parse_audio_format_v3()