quirks.c (b3fdfc1b4b641d372e35ced98814289bc60bc5d1) | quirks.c (0ba41d917eeb87f608cf147f870ff2f4c1056bab) |
---|---|
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 --- 96 unchanged lines hidden (view full) --- 105 struct usb_host_interface *alts; 106 struct usb_interface_descriptor *altsd; 107 int err; 108 109 alts = &iface->altsetting[0]; 110 altsd = get_iface_desc(alts); 111 err = snd_usb_parse_audio_interface(chip, altsd->bInterfaceNumber); 112 if (err < 0) { | 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 --- 96 unchanged lines hidden (view full) --- 105 struct usb_host_interface *alts; 106 struct usb_interface_descriptor *altsd; 107 int err; 108 109 alts = &iface->altsetting[0]; 110 altsd = get_iface_desc(alts); 111 err = snd_usb_parse_audio_interface(chip, altsd->bInterfaceNumber); 112 if (err < 0) { |
113 snd_printk(KERN_ERR "cannot setup if %d: error %d\n", | 113 usb_audio_err(chip, "cannot setup if %d: error %d\n", |
114 altsd->bInterfaceNumber, err); 115 return err; 116 } 117 /* reset the current interface */ 118 usb_set_interface(chip->dev, altsd->bInterfaceNumber, 0); 119 return 0; 120} 121 --- 8 unchanged lines hidden (view full) --- 130 struct audioformat *fp; 131 struct usb_host_interface *alts; 132 struct usb_interface_descriptor *altsd; 133 int stream, err; 134 unsigned *rate_table = NULL; 135 136 fp = kmemdup(quirk->data, sizeof(*fp), GFP_KERNEL); 137 if (!fp) { | 114 altsd->bInterfaceNumber, err); 115 return err; 116 } 117 /* reset the current interface */ 118 usb_set_interface(chip->dev, altsd->bInterfaceNumber, 0); 119 return 0; 120} 121 --- 8 unchanged lines hidden (view full) --- 130 struct audioformat *fp; 131 struct usb_host_interface *alts; 132 struct usb_interface_descriptor *altsd; 133 int stream, err; 134 unsigned *rate_table = NULL; 135 136 fp = kmemdup(quirk->data, sizeof(*fp), GFP_KERNEL); 137 if (!fp) { |
138 snd_printk(KERN_ERR "cannot memdup\n"); | 138 usb_audio_err(chip, "cannot memdup\n"); |
139 return -ENOMEM; 140 } 141 if (fp->nr_rates > MAX_NR_RATES) { 142 kfree(fp); 143 return -EINVAL; 144 } 145 if (fp->nr_rates > 0) { 146 rate_table = kmemdup(fp->rate_table, --- 312 unchanged lines hidden (view full) --- 459 case 0x140: 460 fp->rate_max = fp->rate_min = 48000; 461 break; 462 case 0x258: 463 case 0x260: 464 fp->rate_max = fp->rate_min = 96000; 465 break; 466 default: | 139 return -ENOMEM; 140 } 141 if (fp->nr_rates > MAX_NR_RATES) { 142 kfree(fp); 143 return -EINVAL; 144 } 145 if (fp->nr_rates > 0) { 146 rate_table = kmemdup(fp->rate_table, --- 312 unchanged lines hidden (view full) --- 459 case 0x140: 460 fp->rate_max = fp->rate_min = 48000; 461 break; 462 case 0x258: 463 case 0x260: 464 fp->rate_max = fp->rate_min = 96000; 465 break; 466 default: |
467 snd_printk(KERN_ERR "unknown sample rate\n"); | 467 usb_audio_err(chip, "unknown sample rate\n"); |
468 kfree(fp); 469 return -ENXIO; 470 } 471 472 stream = (fp->endpoint & USB_DIR_IN) 473 ? SNDRV_PCM_STREAM_CAPTURE : SNDRV_PCM_STREAM_PLAYBACK; 474 err = snd_usb_add_audio_stream(chip, stream, fp); 475 if (err < 0) { --- 55 unchanged lines hidden (view full) --- 531 [QUIRK_AUDIO_EDIROL_UAXX] = create_uaxx_quirk, 532 [QUIRK_AUDIO_ALIGN_TRANSFER] = create_align_transfer_quirk, 533 [QUIRK_AUDIO_STANDARD_MIXER] = create_standard_mixer_quirk, 534 }; 535 536 if (quirk->type < QUIRK_TYPE_COUNT) { 537 return quirk_funcs[quirk->type](chip, iface, driver, quirk); 538 } else { | 468 kfree(fp); 469 return -ENXIO; 470 } 471 472 stream = (fp->endpoint & USB_DIR_IN) 473 ? SNDRV_PCM_STREAM_CAPTURE : SNDRV_PCM_STREAM_PLAYBACK; 474 err = snd_usb_add_audio_stream(chip, stream, fp); 475 if (err < 0) { --- 55 unchanged lines hidden (view full) --- 531 [QUIRK_AUDIO_EDIROL_UAXX] = create_uaxx_quirk, 532 [QUIRK_AUDIO_ALIGN_TRANSFER] = create_align_transfer_quirk, 533 [QUIRK_AUDIO_STANDARD_MIXER] = create_standard_mixer_quirk, 534 }; 535 536 if (quirk->type < QUIRK_TYPE_COUNT) { 537 return quirk_funcs[quirk->type](chip, iface, driver, quirk); 538 } else { |
539 snd_printd(KERN_ERR "invalid quirk type %d\n", quirk->type); | 539 usb_audio_err(chip, "invalid quirk type %d\n", quirk->type); |
540 return -ENXIO; 541 } 542} 543 544/* 545 * boot quirks 546 */ 547 548#define EXTIGY_FIRMWARE_SIZE_OLD 794 549#define EXTIGY_FIRMWARE_SIZE_NEW 483 550 551static int snd_usb_extigy_boot_quirk(struct usb_device *dev, struct usb_interface *intf) 552{ 553 struct usb_host_config *config = dev->actconfig; 554 int err; 555 556 if (le16_to_cpu(get_cfg_desc(config)->wTotalLength) == EXTIGY_FIRMWARE_SIZE_OLD || 557 le16_to_cpu(get_cfg_desc(config)->wTotalLength) == EXTIGY_FIRMWARE_SIZE_NEW) { | 540 return -ENXIO; 541 } 542} 543 544/* 545 * boot quirks 546 */ 547 548#define EXTIGY_FIRMWARE_SIZE_OLD 794 549#define EXTIGY_FIRMWARE_SIZE_NEW 483 550 551static int snd_usb_extigy_boot_quirk(struct usb_device *dev, struct usb_interface *intf) 552{ 553 struct usb_host_config *config = dev->actconfig; 554 int err; 555 556 if (le16_to_cpu(get_cfg_desc(config)->wTotalLength) == EXTIGY_FIRMWARE_SIZE_OLD || 557 le16_to_cpu(get_cfg_desc(config)->wTotalLength) == EXTIGY_FIRMWARE_SIZE_NEW) { |
558 snd_printdd("sending Extigy boot sequence...\n"); | 558 dev_dbg(&dev->dev, "sending Extigy boot sequence...\n"); |
559 /* Send message to force it to reconnect with full interface. */ 560 err = snd_usb_ctl_msg(dev, usb_sndctrlpipe(dev,0), 561 0x10, 0x43, 0x0001, 0x000a, NULL, 0); | 559 /* Send message to force it to reconnect with full interface. */ 560 err = snd_usb_ctl_msg(dev, usb_sndctrlpipe(dev,0), 561 0x10, 0x43, 0x0001, 0x000a, NULL, 0); |
562 if (err < 0) snd_printdd("error sending boot message: %d\n", err); | 562 if (err < 0) 563 dev_dbg(&dev->dev, "error sending boot message: %d\n", err); |
563 err = usb_get_descriptor(dev, USB_DT_DEVICE, 0, 564 &dev->descriptor, sizeof(dev->descriptor)); 565 config = dev->actconfig; | 564 err = usb_get_descriptor(dev, USB_DT_DEVICE, 0, 565 &dev->descriptor, sizeof(dev->descriptor)); 566 config = dev->actconfig; |
566 if (err < 0) snd_printdd("error usb_get_descriptor: %d\n", err); | 567 if (err < 0) 568 dev_dbg(&dev->dev, "error usb_get_descriptor: %d\n", err); |
567 err = usb_reset_configuration(dev); | 569 err = usb_reset_configuration(dev); |
568 if (err < 0) snd_printdd("error usb_reset_configuration: %d\n", err); 569 snd_printdd("extigy_boot: new boot length = %d\n", | 570 if (err < 0) 571 dev_dbg(&dev->dev, "error usb_reset_configuration: %d\n", err); 572 dev_dbg(&dev->dev, "extigy_boot: new boot length = %d\n", |
570 le16_to_cpu(get_cfg_desc(config)->wTotalLength)); 571 return -ENODEV; /* quit this anyway */ 572 } 573 return 0; 574} 575 576static int snd_usb_audigy2nx_boot_quirk(struct usb_device *dev) 577{ --- 11 unchanged lines hidden (view full) --- 589 return 0; 590} 591 592static int snd_usb_fasttrackpro_boot_quirk(struct usb_device *dev) 593{ 594 int err; 595 596 if (dev->actconfig->desc.bConfigurationValue == 1) { | 573 le16_to_cpu(get_cfg_desc(config)->wTotalLength)); 574 return -ENODEV; /* quit this anyway */ 575 } 576 return 0; 577} 578 579static int snd_usb_audigy2nx_boot_quirk(struct usb_device *dev) 580{ --- 11 unchanged lines hidden (view full) --- 592 return 0; 593} 594 595static int snd_usb_fasttrackpro_boot_quirk(struct usb_device *dev) 596{ 597 int err; 598 599 if (dev->actconfig->desc.bConfigurationValue == 1) { |
597 snd_printk(KERN_INFO "usb-audio: " | 600 dev_info(&dev->dev, |
598 "Fast Track Pro switching to config #2\n"); 599 /* This function has to be available by the usb core module. 600 * if it is not avialable the boot quirk has to be left out 601 * and the configuration has to be set by udev or hotplug 602 * rules 603 */ 604 err = usb_driver_set_configuration(dev, 2); 605 if (err < 0) | 601 "Fast Track Pro switching to config #2\n"); 602 /* This function has to be available by the usb core module. 603 * if it is not avialable the boot quirk has to be left out 604 * and the configuration has to be set by udev or hotplug 605 * rules 606 */ 607 err = usb_driver_set_configuration(dev, 2); 608 if (err < 0) |
606 snd_printdd("error usb_driver_set_configuration: %d\n", 607 err); | 609 dev_dbg(&dev->dev, 610 "error usb_driver_set_configuration: %d\n", 611 err); |
608 /* Always return an error, so that we stop creating a device 609 that will just be destroyed and recreated with a new 610 configuration */ 611 return -ENODEV; 612 } else | 612 /* Always return an error, so that we stop creating a device 613 that will just be destroyed and recreated with a new 614 configuration */ 615 return -ENODEV; 616 } else |
613 snd_printk(KERN_INFO "usb-audio: Fast Track Pro config OK\n"); | 617 dev_info(&dev->dev, "Fast Track Pro config OK\n"); |
614 615 return 0; 616} 617 618/* 619 * C-Media CM106/CM106+ have four 16-bit internal registers that are nicely 620 * documented in the device's data sheet. 621 */ --- 152 unchanged lines hidden (view full) --- 774 int err; 775 u8 bootresponse[0x12]; 776 int fwsize; 777 int count; 778 779 fwsize = le16_to_cpu(get_cfg_desc(config)->wTotalLength); 780 781 if (fwsize != MBOX2_FIRMWARE_SIZE) { | 618 619 return 0; 620} 621 622/* 623 * C-Media CM106/CM106+ have four 16-bit internal registers that are nicely 624 * documented in the device's data sheet. 625 */ --- 152 unchanged lines hidden (view full) --- 778 int err; 779 u8 bootresponse[0x12]; 780 int fwsize; 781 int count; 782 783 fwsize = le16_to_cpu(get_cfg_desc(config)->wTotalLength); 784 785 if (fwsize != MBOX2_FIRMWARE_SIZE) { |
782 snd_printk(KERN_ERR "usb-audio: Invalid firmware size=%d.\n", fwsize); | 786 dev_err(&dev->dev, "Invalid firmware size=%d.\n", fwsize); |
783 return -ENODEV; 784 } 785 | 787 return -ENODEV; 788 } 789 |
786 snd_printd("usb-audio: Sending Digidesign Mbox 2 boot sequence...\n"); | 790 dev_dbg(&dev->dev, "Sending Digidesign Mbox 2 boot sequence...\n"); |
787 788 count = 0; 789 bootresponse[0] = MBOX2_BOOT_LOADING; 790 while ((bootresponse[0] == MBOX2_BOOT_LOADING) && (count < 10)) { 791 msleep(500); /* 0.5 second delay */ 792 snd_usb_ctl_msg(dev, usb_rcvctrlpipe(dev, 0), 793 /* Control magic - load onboard firmware */ 794 0x85, 0xc0, 0x0001, 0x0000, &bootresponse, 0x0012); 795 if (bootresponse[0] == MBOX2_BOOT_READY) 796 break; | 791 792 count = 0; 793 bootresponse[0] = MBOX2_BOOT_LOADING; 794 while ((bootresponse[0] == MBOX2_BOOT_LOADING) && (count < 10)) { 795 msleep(500); /* 0.5 second delay */ 796 snd_usb_ctl_msg(dev, usb_rcvctrlpipe(dev, 0), 797 /* Control magic - load onboard firmware */ 798 0x85, 0xc0, 0x0001, 0x0000, &bootresponse, 0x0012); 799 if (bootresponse[0] == MBOX2_BOOT_READY) 800 break; |
797 snd_printd("usb-audio: device not ready, resending boot sequence...\n"); | 801 dev_dbg(&dev->dev, "device not ready, resending boot sequence...\n"); |
798 count++; 799 } 800 801 if (bootresponse[0] != MBOX2_BOOT_READY) { | 802 count++; 803 } 804 805 if (bootresponse[0] != MBOX2_BOOT_READY) { |
802 snd_printk(KERN_ERR "usb-audio: Unknown bootresponse=%d, or timed out, ignoring device.\n", bootresponse[0]); | 806 dev_err(&dev->dev, "Unknown bootresponse=%d, or timed out, ignoring device.\n", bootresponse[0]); |
803 return -ENODEV; 804 } 805 | 807 return -ENODEV; 808 } 809 |
806 snd_printdd("usb-audio: device initialised!\n"); | 810 dev_dbg(&dev->dev, "device initialised!\n"); |
807 808 err = usb_get_descriptor(dev, USB_DT_DEVICE, 0, 809 &dev->descriptor, sizeof(dev->descriptor)); 810 config = dev->actconfig; 811 if (err < 0) | 811 812 err = usb_get_descriptor(dev, USB_DT_DEVICE, 0, 813 &dev->descriptor, sizeof(dev->descriptor)); 814 config = dev->actconfig; 815 if (err < 0) |
812 snd_printd("error usb_get_descriptor: %d\n", err); | 816 dev_dbg(&dev->dev, "error usb_get_descriptor: %d\n", err); |
813 814 err = usb_reset_configuration(dev); 815 if (err < 0) | 817 818 err = usb_reset_configuration(dev); 819 if (err < 0) |
816 snd_printd("error usb_reset_configuration: %d\n", err); 817 snd_printdd("mbox2_boot: new boot length = %d\n", | 820 dev_dbg(&dev->dev, "error usb_reset_configuration: %d\n", err); 821 dev_dbg(&dev->dev, "mbox2_boot: new boot length = %d\n", |
818 le16_to_cpu(get_cfg_desc(config)->wTotalLength)); 819 820 mbox2_setup_48_24_magic(dev); 821 | 822 le16_to_cpu(get_cfg_desc(config)->wTotalLength)); 823 824 mbox2_setup_48_24_magic(dev); 825 |
822 snd_printk(KERN_INFO "usb-audio: Digidesign Mbox 2: 24bit 48kHz"); | 826 dev_info(&dev->dev, "Digidesign Mbox 2: 24bit 48kHz"); |
823 824 return 0; /* Successful boot */ 825} 826 827/* 828 * Setup quirks 829 */ 830#define MAUDIO_SET 0x01 /* parse device_setup */ --- 29 unchanged lines hidden (view full) --- 860 if (mask == MAUDIO_SET_24B_48K_DI && altno != 2) 861 return 1; /* skip this altsetting */ 862 if (mask == MAUDIO_SET_24B_48K_NOTDI && altno != 3) 863 return 1; /* skip this altsetting */ 864 if (mask == MAUDIO_SET_16B_48K_NOTDI && altno != 4) 865 return 1; /* skip this altsetting */ 866 } 867 } | 827 828 return 0; /* Successful boot */ 829} 830 831/* 832 * Setup quirks 833 */ 834#define MAUDIO_SET 0x01 /* parse device_setup */ --- 29 unchanged lines hidden (view full) --- 864 if (mask == MAUDIO_SET_24B_48K_DI && altno != 2) 865 return 1; /* skip this altsetting */ 866 if (mask == MAUDIO_SET_24B_48K_NOTDI && altno != 3) 867 return 1; /* skip this altsetting */ 868 if (mask == MAUDIO_SET_16B_48K_NOTDI && altno != 4) 869 return 1; /* skip this altsetting */ 870 } 871 } |
868 snd_printdd(KERN_INFO | 872 usb_audio_dbg(chip, |
869 "using altsetting %d for interface %d config %d\n", 870 altno, iface, chip->setup); 871 return 0; /* keep this altsetting */ 872} 873 874static int audiophile_skip_setting_quirk(struct snd_usb_audio *chip, 875 int iface, 876 int altno) --- 50 unchanged lines hidden (view full) --- 927 return 1; /* enalbe only altsets 2 and 5 */ 928 } 929 } else { 930 /* keep only 16-Bit mode */ 931 if (altno != 1) 932 return 1; 933 } 934 | 873 "using altsetting %d for interface %d config %d\n", 874 altno, iface, chip->setup); 875 return 0; /* keep this altsetting */ 876} 877 878static int audiophile_skip_setting_quirk(struct snd_usb_audio *chip, 879 int iface, 880 int altno) --- 50 unchanged lines hidden (view full) --- 931 return 1; /* enalbe only altsets 2 and 5 */ 932 } 933 } else { 934 /* keep only 16-Bit mode */ 935 if (altno != 1) 936 return 1; 937 } 938 |
935 snd_printdd(KERN_INFO | 939 usb_audio_dbg(chip, |
936 "using altsetting %d for interface %d config %d\n", 937 altno, iface, chip->setup); 938 return 0; /* keep this altsetting */ 939} 940 941int snd_usb_apply_interface_quirk(struct snd_usb_audio *chip, 942 int iface, 943 int altno) --- 231 unchanged lines hidden --- | 940 "using altsetting %d for interface %d config %d\n", 941 altno, iface, chip->setup); 942 return 0; /* keep this altsetting */ 943} 944 945int snd_usb_apply_interface_quirk(struct snd_usb_audio *chip, 946 int iface, 947 int altno) --- 231 unchanged lines hidden --- |