format.c (50d1e9302bab7d35dae7146f8c468e0943015616) | format.c (74754f974b36c5a1156be46d0da05ab2c0a0960b) |
---|---|
1/* 2 * This program is free software; you can redistribute it and/or modify 3 * it under the terms of the GNU General Public License as published by 4 * the Free Software Foundation; either version 2 of the License, or 5 * (at your option) any later version. 6 * 7 * This program is distributed in the hope that it will be useful, 8 * but WITHOUT ANY WARRANTY; without even the implied warranty of --- 264 unchanged lines hidden (view full) --- 273err: 274 return ret; 275} 276 277/* 278 * parse the format type I and III descriptors 279 */ 280static int parse_audio_format_i(struct snd_usb_audio *chip, | 1/* 2 * This program is free software; you can redistribute it and/or modify 3 * it under the terms of the GNU General Public License as published by 4 * the Free Software Foundation; either version 2 of the License, or 5 * (at your option) any later version. 6 * 7 * This program is distributed in the hope that it will be useful, 8 * but WITHOUT ANY WARRANTY; without even the implied warranty of --- 264 unchanged lines hidden (view full) --- 273err: 274 return ret; 275} 276 277/* 278 * parse the format type I and III descriptors 279 */ 280static int parse_audio_format_i(struct snd_usb_audio *chip, |
281 struct audioformat *fp, 282 int format, void *_fmt, | 281 struct audioformat *fp, int format, 282 struct uac_format_type_i_continuous_descriptor *fmt, |
283 struct usb_host_interface *iface) 284{ 285 struct usb_interface_descriptor *altsd = get_iface_desc(iface); | 283 struct usb_host_interface *iface) 284{ 285 struct usb_interface_descriptor *altsd = get_iface_desc(iface); |
286 struct uac_format_type_i_discrete_descriptor *fmt = _fmt; | |
287 int protocol = altsd->bInterfaceProtocol; 288 int pcm_format, ret; 289 290 if (fmt->bFormatType == UAC_FORMAT_TYPE_III) { 291 /* FIXME: the format type is really IECxxx 292 * but we give normal PCM format to get the existing 293 * apps working... 294 */ --- 20 unchanged lines hidden (view full) --- 315 /* gather possible sample rates */ 316 /* audio class v1 reports possible sample rates as part of the 317 * proprietary class specific descriptor. 318 * audio class v2 uses class specific EP0 range requests for that. 319 */ 320 switch (protocol) { 321 case UAC_VERSION_1: 322 fp->channels = fmt->bNrChannels; | 286 int protocol = altsd->bInterfaceProtocol; 287 int pcm_format, ret; 288 289 if (fmt->bFormatType == UAC_FORMAT_TYPE_III) { 290 /* FIXME: the format type is really IECxxx 291 * but we give normal PCM format to get the existing 292 * apps working... 293 */ --- 20 unchanged lines hidden (view full) --- 314 /* gather possible sample rates */ 315 /* audio class v1 reports possible sample rates as part of the 316 * proprietary class specific descriptor. 317 * audio class v2 uses class specific EP0 range requests for that. 318 */ 319 switch (protocol) { 320 case UAC_VERSION_1: 321 fp->channels = fmt->bNrChannels; |
323 ret = parse_audio_format_rates_v1(chip, fp, _fmt, 7); | 322 ret = parse_audio_format_rates_v1(chip, fp, (unsigned char *) fmt, 7); |
324 break; 325 case UAC_VERSION_2: 326 /* fp->channels is already set in this case */ 327 ret = parse_audio_format_rates_v2(chip, fp, iface); 328 break; 329 } 330 331 if (fp->channels < 1) { --- 55 unchanged lines hidden (view full) --- 387 break; 388 } 389 } 390 391 return ret; 392} 393 394int snd_usb_parse_audio_format(struct snd_usb_audio *chip, struct audioformat *fp, | 323 break; 324 case UAC_VERSION_2: 325 /* fp->channels is already set in this case */ 326 ret = parse_audio_format_rates_v2(chip, fp, iface); 327 break; 328 } 329 330 if (fp->channels < 1) { --- 55 unchanged lines hidden (view full) --- 386 break; 387 } 388 } 389 390 return ret; 391} 392 393int snd_usb_parse_audio_format(struct snd_usb_audio *chip, struct audioformat *fp, |
395 int format, unsigned char *fmt, int stream, 396 struct usb_host_interface *iface) | 394 int format, struct uac_format_type_i_continuous_descriptor *fmt, 395 int stream, struct usb_host_interface *iface) |
397{ 398 int err; 399 | 396{ 397 int err; 398 |
400 switch (fmt[3]) { | 399 switch (fmt->bFormatType) { |
401 case UAC_FORMAT_TYPE_I: 402 case UAC_FORMAT_TYPE_III: 403 err = parse_audio_format_i(chip, fp, format, fmt, iface); 404 break; 405 case UAC_FORMAT_TYPE_II: 406 err = parse_audio_format_ii(chip, fp, format, fmt, iface); 407 break; 408 default: 409 snd_printd(KERN_INFO "%d:%u:%d : format type %d is not supported yet\n", | 400 case UAC_FORMAT_TYPE_I: 401 case UAC_FORMAT_TYPE_III: 402 err = parse_audio_format_i(chip, fp, format, fmt, iface); 403 break; 404 case UAC_FORMAT_TYPE_II: 405 err = parse_audio_format_ii(chip, fp, format, fmt, iface); 406 break; 407 default: 408 snd_printd(KERN_INFO "%d:%u:%d : format type %d is not supported yet\n", |
410 chip->dev->devnum, fp->iface, fp->altsetting, fmt[3]); | 409 chip->dev->devnum, fp->iface, fp->altsetting, 410 fmt->bFormatType); |
411 return -1; 412 } | 411 return -1; 412 } |
413 fp->fmt_type = fmt[3]; | 413 fp->fmt_type = fmt->bFormatType; |
414 if (err < 0) 415 return err; 416#if 1 417 /* FIXME: temporary hack for extigy/audigy 2 nx/zs */ 418 /* extigy apparently supports sample rates other than 48k 419 * but not in ordinary way. so we enable only 48k atm. 420 */ 421 if (chip->usb_id == USB_ID(0x041e, 0x3000) || 422 chip->usb_id == USB_ID(0x041e, 0x3020) || 423 chip->usb_id == USB_ID(0x041e, 0x3061)) { | 414 if (err < 0) 415 return err; 416#if 1 417 /* FIXME: temporary hack for extigy/audigy 2 nx/zs */ 418 /* extigy apparently supports sample rates other than 48k 419 * but not in ordinary way. so we enable only 48k atm. 420 */ 421 if (chip->usb_id == USB_ID(0x041e, 0x3000) || 422 chip->usb_id == USB_ID(0x041e, 0x3020) || 423 chip->usb_id == USB_ID(0x041e, 0x3061)) { |
424 if (fmt[3] == UAC_FORMAT_TYPE_I && | 424 if (fmt->bFormatType == UAC_FORMAT_TYPE_I && |
425 fp->rates != SNDRV_PCM_RATE_48000 && 426 fp->rates != SNDRV_PCM_RATE_96000) 427 return -1; 428 } 429#endif 430 return 0; 431} 432 | 425 fp->rates != SNDRV_PCM_RATE_48000 && 426 fp->rates != SNDRV_PCM_RATE_96000) 427 return -1; 428 } 429#endif 430 return 0; 431} 432 |