19 #include <linux/slab.h>
21 #include <linux/usb/audio.h>
49 int sample_width, sample_bytes;
81 sample_width == 24 && sample_bytes == 2)
83 else if (sample_width > sample_bytes * 8) {
86 sample_width, sample_bytes);
89 switch (sample_bytes) {
111 sample_width, sample_bytes);
132 if (format & ~0x3f) {
153 int nr_rates = fmt[
offset];
155 if (fmt[0] < offset + 1 + 3 * (nr_rates ? nr_rates : 2)) {
175 for (r = 0, idx = offset + 1; r < nr_rates; r++, idx += 3) {
181 if (rate == 48000 && nr_rates == 1 &&
188 if (rate == 16000 && chip->
usb_id ==
USB_ID(0x041e, 0x4068))
192 if (!fp->
rate_min || rate < fp->rate_min)
200 hwc_debug(
"All rates were zero. Skipping format!\n");
218 static int parse_uac2_sample_rate_range(
struct audioformat *fp,
int nr_triplets,
219 const unsigned char *
data)
225 for (i = 0; i < nr_triplets; i++) {
231 if ((max < 0) || (min < 0) || (res < 0) || (max < min))
246 for (rate = min; rate <=
max; rate +=
res) {
249 if (!fp->
rate_min || rate < fp->rate_min)
274 static int parse_audio_format_rates_v2(
struct snd_usb_audio *chip,
277 struct usb_device *
dev = chip->
dev;
292 snd_usb_ctrl_intf(chip) | (clock << 8),
301 nr_triplets = (tmp[1] << 8) | tmp[0];
302 data_size = 2 + 12 * nr_triplets;
313 snd_usb_ctrl_intf(chip) | (clock << 8),
328 fp->
nr_rates = parse_uac2_sample_rate_range(fp, nr_triplets, data);
344 parse_uac2_sample_rate_range(fp, nr_triplets, data);
358 struct usb_host_interface *iface)
371 case USB_ID(0x0763, 0x2003):
381 fp->
formats = 1uLL << pcm_format;
383 fp->
formats = parse_audio_format_i_type(chip, fp, format,
401 ret = parse_audio_format_rates_v1(chip, fp, (
unsigned char *) fmt, 7);
405 ret = parse_audio_format_rates_v2(chip, fp);
423 int format,
void *_fmt,
424 struct usb_host_interface *iface)
426 int brate, framesize,
ret;
440 snd_printd(
KERN_INFO "%d:%u:%d : unknown format tag %#x is detected. processed as MPEG.\n",
457 snd_printd(
KERN_INFO "found format II with max.bitrate = %d, frame size=%d\n", brate, framesize);
459 ret = parse_audio_format_rates_v1(chip, fp, _fmt, 8);
466 snd_printd(
KERN_INFO "found format II with max.bitrate = %d, frame size=%d\n", brate, framesize);
468 ret = parse_audio_format_rates_v2(chip, fp);
478 int stream,
struct usb_host_interface *iface)
485 err = parse_audio_format_i(chip, fp, format, fmt, iface);
488 err = parse_audio_format_ii(chip, fp, format, fmt, iface);