.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
---|
1 | 2 | /* |
---|
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 |
---|
9 | | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
10 | | - * GNU General Public License for more details. |
---|
11 | | - * |
---|
12 | | - * You should have received a copy of the GNU General Public License |
---|
13 | | - * along with this program; if not, write to the Free Software |
---|
14 | | - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
---|
15 | 3 | */ |
---|
16 | 4 | |
---|
17 | 5 | #include <linux/init.h> |
---|
.. | .. |
---|
19 | 7 | #include <linux/usb.h> |
---|
20 | 8 | #include <linux/usb/audio.h> |
---|
21 | 9 | #include <linux/usb/midi.h> |
---|
| 10 | +#include <linux/bits.h> |
---|
22 | 11 | |
---|
23 | 12 | #include <sound/control.h> |
---|
24 | 13 | #include <sound/core.h> |
---|
.. | .. |
---|
537 | 526 | return 1; /* Continue with creating streams and mixer */ |
---|
538 | 527 | } |
---|
539 | 528 | |
---|
| 529 | +static int setup_disable_autosuspend(struct snd_usb_audio *chip, |
---|
| 530 | + struct usb_interface *iface, |
---|
| 531 | + struct usb_driver *driver, |
---|
| 532 | + const struct snd_usb_audio_quirk *quirk) |
---|
| 533 | +{ |
---|
| 534 | + usb_disable_autosuspend(interface_to_usbdev(iface)); |
---|
| 535 | + return 1; /* Continue with creating streams and mixer */ |
---|
| 536 | +} |
---|
| 537 | + |
---|
540 | 538 | /* |
---|
541 | 539 | * audio-interface quirks |
---|
542 | 540 | * |
---|
.. | .. |
---|
576 | 574 | [QUIRK_AUDIO_ALIGN_TRANSFER] = create_align_transfer_quirk, |
---|
577 | 575 | [QUIRK_AUDIO_STANDARD_MIXER] = create_standard_mixer_quirk, |
---|
578 | 576 | [QUIRK_SETUP_FMT_AFTER_RESUME] = setup_fmt_after_resume_quirk, |
---|
| 577 | + [QUIRK_SETUP_DISABLE_AUTOSUSPEND] = setup_disable_autosuspend, |
---|
579 | 578 | }; |
---|
580 | 579 | |
---|
581 | 580 | if (quirk->type < QUIRK_TYPE_COUNT) { |
---|
.. | .. |
---|
690 | 689 | } |
---|
691 | 690 | |
---|
692 | 691 | /* |
---|
693 | | - * C-Media CM6206 is based on CM106 with two additional |
---|
694 | | - * registers that are not documented in the data sheet. |
---|
695 | | - * Values here are chosen based on sniffing USB traffic |
---|
696 | | - * under Windows. |
---|
| 692 | + * CM6206 registers from the CM6206 datasheet rev 2.1 |
---|
697 | 693 | */ |
---|
| 694 | +#define CM6206_REG0_DMA_MASTER BIT(15) |
---|
| 695 | +#define CM6206_REG0_SPDIFO_RATE_48K (2 << 12) |
---|
| 696 | +#define CM6206_REG0_SPDIFO_RATE_96K (7 << 12) |
---|
| 697 | +/* Bit 4 thru 11 is the S/PDIF category code */ |
---|
| 698 | +#define CM6206_REG0_SPDIFO_CAT_CODE_GENERAL (0 << 4) |
---|
| 699 | +#define CM6206_REG0_SPDIFO_EMPHASIS_CD BIT(3) |
---|
| 700 | +#define CM6206_REG0_SPDIFO_COPYRIGHT_NA BIT(2) |
---|
| 701 | +#define CM6206_REG0_SPDIFO_NON_AUDIO BIT(1) |
---|
| 702 | +#define CM6206_REG0_SPDIFO_PRO_FORMAT BIT(0) |
---|
| 703 | + |
---|
| 704 | +#define CM6206_REG1_TEST_SEL_CLK BIT(14) |
---|
| 705 | +#define CM6206_REG1_PLLBIN_EN BIT(13) |
---|
| 706 | +#define CM6206_REG1_SOFT_MUTE_EN BIT(12) |
---|
| 707 | +#define CM6206_REG1_GPIO4_OUT BIT(11) |
---|
| 708 | +#define CM6206_REG1_GPIO4_OE BIT(10) |
---|
| 709 | +#define CM6206_REG1_GPIO3_OUT BIT(9) |
---|
| 710 | +#define CM6206_REG1_GPIO3_OE BIT(8) |
---|
| 711 | +#define CM6206_REG1_GPIO2_OUT BIT(7) |
---|
| 712 | +#define CM6206_REG1_GPIO2_OE BIT(6) |
---|
| 713 | +#define CM6206_REG1_GPIO1_OUT BIT(5) |
---|
| 714 | +#define CM6206_REG1_GPIO1_OE BIT(4) |
---|
| 715 | +#define CM6206_REG1_SPDIFO_INVALID BIT(3) |
---|
| 716 | +#define CM6206_REG1_SPDIF_LOOP_EN BIT(2) |
---|
| 717 | +#define CM6206_REG1_SPDIFO_DIS BIT(1) |
---|
| 718 | +#define CM6206_REG1_SPDIFI_MIX BIT(0) |
---|
| 719 | + |
---|
| 720 | +#define CM6206_REG2_DRIVER_ON BIT(15) |
---|
| 721 | +#define CM6206_REG2_HEADP_SEL_SIDE_CHANNELS (0 << 13) |
---|
| 722 | +#define CM6206_REG2_HEADP_SEL_SURROUND_CHANNELS (1 << 13) |
---|
| 723 | +#define CM6206_REG2_HEADP_SEL_CENTER_SUBW (2 << 13) |
---|
| 724 | +#define CM6206_REG2_HEADP_SEL_FRONT_CHANNELS (3 << 13) |
---|
| 725 | +#define CM6206_REG2_MUTE_HEADPHONE_RIGHT BIT(12) |
---|
| 726 | +#define CM6206_REG2_MUTE_HEADPHONE_LEFT BIT(11) |
---|
| 727 | +#define CM6206_REG2_MUTE_REAR_SURROUND_RIGHT BIT(10) |
---|
| 728 | +#define CM6206_REG2_MUTE_REAR_SURROUND_LEFT BIT(9) |
---|
| 729 | +#define CM6206_REG2_MUTE_SIDE_SURROUND_RIGHT BIT(8) |
---|
| 730 | +#define CM6206_REG2_MUTE_SIDE_SURROUND_LEFT BIT(7) |
---|
| 731 | +#define CM6206_REG2_MUTE_SUBWOOFER BIT(6) |
---|
| 732 | +#define CM6206_REG2_MUTE_CENTER BIT(5) |
---|
| 733 | +#define CM6206_REG2_MUTE_RIGHT_FRONT BIT(3) |
---|
| 734 | +#define CM6206_REG2_MUTE_LEFT_FRONT BIT(3) |
---|
| 735 | +#define CM6206_REG2_EN_BTL BIT(2) |
---|
| 736 | +#define CM6206_REG2_MCUCLKSEL_1_5_MHZ (0) |
---|
| 737 | +#define CM6206_REG2_MCUCLKSEL_3_MHZ (1) |
---|
| 738 | +#define CM6206_REG2_MCUCLKSEL_6_MHZ (2) |
---|
| 739 | +#define CM6206_REG2_MCUCLKSEL_12_MHZ (3) |
---|
| 740 | + |
---|
| 741 | +/* Bit 11..13 sets the sensitivity to FLY tuner volume control VP/VD signal */ |
---|
| 742 | +#define CM6206_REG3_FLYSPEED_DEFAULT (2 << 11) |
---|
| 743 | +#define CM6206_REG3_VRAP25EN BIT(10) |
---|
| 744 | +#define CM6206_REG3_MSEL1 BIT(9) |
---|
| 745 | +#define CM6206_REG3_SPDIFI_RATE_44_1K BIT(0 << 7) |
---|
| 746 | +#define CM6206_REG3_SPDIFI_RATE_48K BIT(2 << 7) |
---|
| 747 | +#define CM6206_REG3_SPDIFI_RATE_32K BIT(3 << 7) |
---|
| 748 | +#define CM6206_REG3_PINSEL BIT(6) |
---|
| 749 | +#define CM6206_REG3_FOE BIT(5) |
---|
| 750 | +#define CM6206_REG3_ROE BIT(4) |
---|
| 751 | +#define CM6206_REG3_CBOE BIT(3) |
---|
| 752 | +#define CM6206_REG3_LOSE BIT(2) |
---|
| 753 | +#define CM6206_REG3_HPOE BIT(1) |
---|
| 754 | +#define CM6206_REG3_SPDIFI_CANREC BIT(0) |
---|
| 755 | + |
---|
| 756 | +#define CM6206_REG5_DA_RSTN BIT(13) |
---|
| 757 | +#define CM6206_REG5_AD_RSTN BIT(12) |
---|
| 758 | +#define CM6206_REG5_SPDIFO_AD2SPDO BIT(12) |
---|
| 759 | +#define CM6206_REG5_SPDIFO_SEL_FRONT (0 << 9) |
---|
| 760 | +#define CM6206_REG5_SPDIFO_SEL_SIDE_SUR (1 << 9) |
---|
| 761 | +#define CM6206_REG5_SPDIFO_SEL_CEN_LFE (2 << 9) |
---|
| 762 | +#define CM6206_REG5_SPDIFO_SEL_REAR_SUR (3 << 9) |
---|
| 763 | +#define CM6206_REG5_CODECM BIT(8) |
---|
| 764 | +#define CM6206_REG5_EN_HPF BIT(7) |
---|
| 765 | +#define CM6206_REG5_T_SEL_DSDA4 BIT(6) |
---|
| 766 | +#define CM6206_REG5_T_SEL_DSDA3 BIT(5) |
---|
| 767 | +#define CM6206_REG5_T_SEL_DSDA2 BIT(4) |
---|
| 768 | +#define CM6206_REG5_T_SEL_DSDA1 BIT(3) |
---|
| 769 | +#define CM6206_REG5_T_SEL_DSDAD_NORMAL 0 |
---|
| 770 | +#define CM6206_REG5_T_SEL_DSDAD_FRONT 4 |
---|
| 771 | +#define CM6206_REG5_T_SEL_DSDAD_S_SURROUND 5 |
---|
| 772 | +#define CM6206_REG5_T_SEL_DSDAD_CEN_LFE 6 |
---|
| 773 | +#define CM6206_REG5_T_SEL_DSDAD_R_SURROUND 7 |
---|
| 774 | + |
---|
698 | 775 | static int snd_usb_cm6206_boot_quirk(struct usb_device *dev) |
---|
699 | 776 | { |
---|
700 | 777 | int err = 0, reg; |
---|
701 | | - int val[] = {0x2004, 0x3000, 0xf800, 0x143f, 0x0000, 0x3000}; |
---|
| 778 | + int val[] = { |
---|
| 779 | + /* |
---|
| 780 | + * Values here are chosen based on sniffing USB traffic |
---|
| 781 | + * under Windows. |
---|
| 782 | + * |
---|
| 783 | + * REG0: DAC is master, sample rate 48kHz, no copyright |
---|
| 784 | + */ |
---|
| 785 | + CM6206_REG0_SPDIFO_RATE_48K | |
---|
| 786 | + CM6206_REG0_SPDIFO_COPYRIGHT_NA, |
---|
| 787 | + /* |
---|
| 788 | + * REG1: PLL binary search enable, soft mute enable. |
---|
| 789 | + */ |
---|
| 790 | + CM6206_REG1_PLLBIN_EN | |
---|
| 791 | + CM6206_REG1_SOFT_MUTE_EN, |
---|
| 792 | + /* |
---|
| 793 | + * REG2: enable output drivers, |
---|
| 794 | + * select front channels to the headphone output, |
---|
| 795 | + * then mute the headphone channels, run the MCU |
---|
| 796 | + * at 1.5 MHz. |
---|
| 797 | + */ |
---|
| 798 | + CM6206_REG2_DRIVER_ON | |
---|
| 799 | + CM6206_REG2_HEADP_SEL_FRONT_CHANNELS | |
---|
| 800 | + CM6206_REG2_MUTE_HEADPHONE_RIGHT | |
---|
| 801 | + CM6206_REG2_MUTE_HEADPHONE_LEFT, |
---|
| 802 | + /* |
---|
| 803 | + * REG3: default flyspeed, set 2.5V mic bias |
---|
| 804 | + * enable all line out ports and enable SPDIF |
---|
| 805 | + */ |
---|
| 806 | + CM6206_REG3_FLYSPEED_DEFAULT | |
---|
| 807 | + CM6206_REG3_VRAP25EN | |
---|
| 808 | + CM6206_REG3_FOE | |
---|
| 809 | + CM6206_REG3_ROE | |
---|
| 810 | + CM6206_REG3_CBOE | |
---|
| 811 | + CM6206_REG3_LOSE | |
---|
| 812 | + CM6206_REG3_HPOE | |
---|
| 813 | + CM6206_REG3_SPDIFI_CANREC, |
---|
| 814 | + /* REG4 is just a bunch of GPIO lines */ |
---|
| 815 | + 0x0000, |
---|
| 816 | + /* REG5: de-assert AD/DA reset signals */ |
---|
| 817 | + CM6206_REG5_DA_RSTN | |
---|
| 818 | + CM6206_REG5_AD_RSTN }; |
---|
702 | 819 | |
---|
703 | 820 | for (reg = 0; reg < ARRAY_SIZE(val); reg++) { |
---|
704 | 821 | err = snd_usb_cm106_write_int_reg(dev, reg, val[reg]); |
---|
.. | .. |
---|
743 | 860 | static int snd_usb_accessmusic_boot_quirk(struct usb_device *dev) |
---|
744 | 861 | { |
---|
745 | 862 | int err, actual_length; |
---|
746 | | - |
---|
747 | 863 | /* "midi send" enable */ |
---|
748 | 864 | static const u8 seq[] = { 0x4e, 0x73, 0x52, 0x01 }; |
---|
| 865 | + void *buf; |
---|
749 | 866 | |
---|
750 | | - void *buf = kmemdup(seq, ARRAY_SIZE(seq), GFP_KERNEL); |
---|
| 867 | + if (usb_pipe_type_check(dev, usb_sndintpipe(dev, 0x05))) |
---|
| 868 | + return -EINVAL; |
---|
| 869 | + buf = kmemdup(seq, ARRAY_SIZE(seq), GFP_KERNEL); |
---|
751 | 870 | if (!buf) |
---|
752 | 871 | return -ENOMEM; |
---|
753 | 872 | err = usb_interrupt_msg(dev, usb_sndintpipe(dev, 0x05), buf, |
---|
.. | .. |
---|
772 | 891 | |
---|
773 | 892 | static int snd_usb_nativeinstruments_boot_quirk(struct usb_device *dev) |
---|
774 | 893 | { |
---|
775 | | - int ret = usb_control_msg(dev, usb_sndctrlpipe(dev, 0), |
---|
| 894 | + int ret; |
---|
| 895 | + |
---|
| 896 | + ret = usb_control_msg(dev, usb_sndctrlpipe(dev, 0), |
---|
776 | 897 | 0xaf, USB_TYPE_VENDOR | USB_RECIP_DEVICE, |
---|
777 | 898 | 1, 0, NULL, 0, 1000); |
---|
778 | 899 | |
---|
.. | .. |
---|
903 | 1024 | return 0; |
---|
904 | 1025 | } |
---|
905 | 1026 | |
---|
| 1027 | + |
---|
| 1028 | +#define MICROBOOK_BUF_SIZE 128 |
---|
| 1029 | + |
---|
| 1030 | +static int snd_usb_motu_microbookii_communicate(struct usb_device *dev, u8 *buf, |
---|
| 1031 | + int buf_size, int *length) |
---|
| 1032 | +{ |
---|
| 1033 | + int err, actual_length; |
---|
| 1034 | + |
---|
| 1035 | + if (usb_pipe_type_check(dev, usb_sndintpipe(dev, 0x01))) |
---|
| 1036 | + return -EINVAL; |
---|
| 1037 | + err = usb_interrupt_msg(dev, usb_sndintpipe(dev, 0x01), buf, *length, |
---|
| 1038 | + &actual_length, 1000); |
---|
| 1039 | + if (err < 0) |
---|
| 1040 | + return err; |
---|
| 1041 | + |
---|
| 1042 | + print_hex_dump(KERN_DEBUG, "MicroBookII snd: ", DUMP_PREFIX_NONE, 16, 1, |
---|
| 1043 | + buf, actual_length, false); |
---|
| 1044 | + |
---|
| 1045 | + memset(buf, 0, buf_size); |
---|
| 1046 | + |
---|
| 1047 | + if (usb_pipe_type_check(dev, usb_rcvintpipe(dev, 0x82))) |
---|
| 1048 | + return -EINVAL; |
---|
| 1049 | + err = usb_interrupt_msg(dev, usb_rcvintpipe(dev, 0x82), buf, buf_size, |
---|
| 1050 | + &actual_length, 1000); |
---|
| 1051 | + if (err < 0) |
---|
| 1052 | + return err; |
---|
| 1053 | + |
---|
| 1054 | + print_hex_dump(KERN_DEBUG, "MicroBookII rcv: ", DUMP_PREFIX_NONE, 16, 1, |
---|
| 1055 | + buf, actual_length, false); |
---|
| 1056 | + |
---|
| 1057 | + *length = actual_length; |
---|
| 1058 | + return 0; |
---|
| 1059 | +} |
---|
| 1060 | + |
---|
| 1061 | +static int snd_usb_motu_microbookii_boot_quirk(struct usb_device *dev) |
---|
| 1062 | +{ |
---|
| 1063 | + int err, actual_length, poll_attempts = 0; |
---|
| 1064 | + static const u8 set_samplerate_seq[] = { 0x00, 0x00, 0x00, 0x00, |
---|
| 1065 | + 0x00, 0x00, 0x0b, 0x14, |
---|
| 1066 | + 0x00, 0x00, 0x00, 0x01 }; |
---|
| 1067 | + static const u8 poll_ready_seq[] = { 0x00, 0x04, 0x00, 0x00, |
---|
| 1068 | + 0x00, 0x00, 0x0b, 0x18 }; |
---|
| 1069 | + u8 *buf = kzalloc(MICROBOOK_BUF_SIZE, GFP_KERNEL); |
---|
| 1070 | + |
---|
| 1071 | + if (!buf) |
---|
| 1072 | + return -ENOMEM; |
---|
| 1073 | + |
---|
| 1074 | + dev_info(&dev->dev, "Waiting for MOTU Microbook II to boot up...\n"); |
---|
| 1075 | + |
---|
| 1076 | + /* First we tell the device which sample rate to use. */ |
---|
| 1077 | + memcpy(buf, set_samplerate_seq, sizeof(set_samplerate_seq)); |
---|
| 1078 | + actual_length = sizeof(set_samplerate_seq); |
---|
| 1079 | + err = snd_usb_motu_microbookii_communicate(dev, buf, MICROBOOK_BUF_SIZE, |
---|
| 1080 | + &actual_length); |
---|
| 1081 | + |
---|
| 1082 | + if (err < 0) { |
---|
| 1083 | + dev_err(&dev->dev, |
---|
| 1084 | + "failed setting the sample rate for Motu MicroBook II: %d\n", |
---|
| 1085 | + err); |
---|
| 1086 | + goto free_buf; |
---|
| 1087 | + } |
---|
| 1088 | + |
---|
| 1089 | + /* Then we poll every 100 ms until the device informs of its readiness. */ |
---|
| 1090 | + while (true) { |
---|
| 1091 | + if (++poll_attempts > 100) { |
---|
| 1092 | + dev_err(&dev->dev, |
---|
| 1093 | + "failed booting Motu MicroBook II: timeout\n"); |
---|
| 1094 | + err = -ENODEV; |
---|
| 1095 | + goto free_buf; |
---|
| 1096 | + } |
---|
| 1097 | + |
---|
| 1098 | + memset(buf, 0, MICROBOOK_BUF_SIZE); |
---|
| 1099 | + memcpy(buf, poll_ready_seq, sizeof(poll_ready_seq)); |
---|
| 1100 | + |
---|
| 1101 | + actual_length = sizeof(poll_ready_seq); |
---|
| 1102 | + err = snd_usb_motu_microbookii_communicate( |
---|
| 1103 | + dev, buf, MICROBOOK_BUF_SIZE, &actual_length); |
---|
| 1104 | + if (err < 0) { |
---|
| 1105 | + dev_err(&dev->dev, |
---|
| 1106 | + "failed booting Motu MicroBook II: communication error %d\n", |
---|
| 1107 | + err); |
---|
| 1108 | + goto free_buf; |
---|
| 1109 | + } |
---|
| 1110 | + |
---|
| 1111 | + /* the device signals its readiness through a message of the |
---|
| 1112 | + * form |
---|
| 1113 | + * XX 06 00 00 00 00 0b 18 00 00 00 01 |
---|
| 1114 | + * If the device is not yet ready to accept audio data, the |
---|
| 1115 | + * last byte of that sequence is 00. |
---|
| 1116 | + */ |
---|
| 1117 | + if (actual_length == 12 && buf[actual_length - 1] == 1) |
---|
| 1118 | + break; |
---|
| 1119 | + |
---|
| 1120 | + msleep(100); |
---|
| 1121 | + } |
---|
| 1122 | + |
---|
| 1123 | + dev_info(&dev->dev, "MOTU MicroBook II ready\n"); |
---|
| 1124 | + |
---|
| 1125 | +free_buf: |
---|
| 1126 | + kfree(buf); |
---|
| 1127 | + return err; |
---|
| 1128 | +} |
---|
| 1129 | + |
---|
| 1130 | +static int snd_usb_motu_m_series_boot_quirk(struct usb_device *dev) |
---|
| 1131 | +{ |
---|
| 1132 | + int ret; |
---|
| 1133 | + |
---|
| 1134 | + ret = usb_control_msg(dev, usb_sndctrlpipe(dev, 0), |
---|
| 1135 | + 1, USB_TYPE_VENDOR | USB_RECIP_DEVICE, |
---|
| 1136 | + 0x0, 0, NULL, 0, 1000); |
---|
| 1137 | + |
---|
| 1138 | + if (ret < 0) |
---|
| 1139 | + return ret; |
---|
| 1140 | + |
---|
| 1141 | + msleep(2000); |
---|
| 1142 | + |
---|
| 1143 | + ret = usb_control_msg(dev, usb_sndctrlpipe(dev, 0), |
---|
| 1144 | + 1, USB_TYPE_VENDOR | USB_RECIP_DEVICE, |
---|
| 1145 | + 0x20, 0, NULL, 0, 1000); |
---|
| 1146 | + |
---|
| 1147 | + if (ret < 0) |
---|
| 1148 | + return ret; |
---|
| 1149 | + |
---|
| 1150 | + return 0; |
---|
| 1151 | +} |
---|
| 1152 | + |
---|
906 | 1153 | /* |
---|
907 | 1154 | * Setup quirks |
---|
908 | 1155 | */ |
---|
909 | 1156 | #define MAUDIO_SET 0x01 /* parse device_setup */ |
---|
910 | 1157 | #define MAUDIO_SET_COMPATIBLE 0x80 /* use only "win-compatible" interfaces */ |
---|
911 | 1158 | #define MAUDIO_SET_DTS 0x02 /* enable DTS Digital Output */ |
---|
912 | | -#define MAUDIO_SET_96K 0x04 /* 48-96KHz rate if set, 8-48KHz otherwise */ |
---|
| 1159 | +#define MAUDIO_SET_96K 0x04 /* 48-96kHz rate if set, 8-48kHz otherwise */ |
---|
913 | 1160 | #define MAUDIO_SET_24B 0x08 /* 24bits sample if set, 16bits otherwise */ |
---|
914 | 1161 | #define MAUDIO_SET_DI 0x10 /* enable Digital Input */ |
---|
915 | 1162 | #define MAUDIO_SET_MASK 0x1f /* bit mask for setup value */ |
---|
916 | | -#define MAUDIO_SET_24B_48K_DI 0x19 /* 24bits+48KHz+Digital Input */ |
---|
917 | | -#define MAUDIO_SET_24B_48K_NOTDI 0x09 /* 24bits+48KHz+No Digital Input */ |
---|
918 | | -#define MAUDIO_SET_16B_48K_DI 0x11 /* 16bits+48KHz+Digital Input */ |
---|
919 | | -#define MAUDIO_SET_16B_48K_NOTDI 0x01 /* 16bits+48KHz+No Digital Input */ |
---|
| 1163 | +#define MAUDIO_SET_24B_48K_DI 0x19 /* 24bits+48kHz+Digital Input */ |
---|
| 1164 | +#define MAUDIO_SET_24B_48K_NOTDI 0x09 /* 24bits+48kHz+No Digital Input */ |
---|
| 1165 | +#define MAUDIO_SET_16B_48K_DI 0x11 /* 16bits+48kHz+Digital Input */ |
---|
| 1166 | +#define MAUDIO_SET_16B_48K_NOTDI 0x01 /* 16bits+48kHz+No Digital Input */ |
---|
920 | 1167 | |
---|
921 | 1168 | static int quattro_skip_setting_quirk(struct snd_usb_audio *chip, |
---|
922 | 1169 | int iface, int altno) |
---|
.. | .. |
---|
1017 | 1264 | return 0; /* keep this altsetting */ |
---|
1018 | 1265 | } |
---|
1019 | 1266 | |
---|
| 1267 | +static int s1810c_skip_setting_quirk(struct snd_usb_audio *chip, |
---|
| 1268 | + int iface, int altno) |
---|
| 1269 | +{ |
---|
| 1270 | + /* |
---|
| 1271 | + * Altno settings: |
---|
| 1272 | + * |
---|
| 1273 | + * Playback (Interface 1): |
---|
| 1274 | + * 1: 6 Analog + 2 S/PDIF |
---|
| 1275 | + * 2: 6 Analog + 2 S/PDIF |
---|
| 1276 | + * 3: 6 Analog |
---|
| 1277 | + * |
---|
| 1278 | + * Capture (Interface 2): |
---|
| 1279 | + * 1: 8 Analog + 2 S/PDIF + 8 ADAT |
---|
| 1280 | + * 2: 8 Analog + 2 S/PDIF + 4 ADAT |
---|
| 1281 | + * 3: 8 Analog |
---|
| 1282 | + */ |
---|
| 1283 | + |
---|
| 1284 | + /* |
---|
| 1285 | + * I'll leave 2 as the default one and |
---|
| 1286 | + * use device_setup to switch to the |
---|
| 1287 | + * other two. |
---|
| 1288 | + */ |
---|
| 1289 | + if ((chip->setup == 0 || chip->setup > 2) && altno != 2) |
---|
| 1290 | + return 1; |
---|
| 1291 | + else if (chip->setup == 1 && altno != 1) |
---|
| 1292 | + return 1; |
---|
| 1293 | + else if (chip->setup == 2 && altno != 3) |
---|
| 1294 | + return 1; |
---|
| 1295 | + |
---|
| 1296 | + return 0; |
---|
| 1297 | +} |
---|
| 1298 | + |
---|
1020 | 1299 | int snd_usb_apply_interface_quirk(struct snd_usb_audio *chip, |
---|
1021 | 1300 | int iface, |
---|
1022 | 1301 | int altno) |
---|
.. | .. |
---|
1030 | 1309 | /* fasttrackpro usb: skip altsets incompatible with device_setup */ |
---|
1031 | 1310 | if (chip->usb_id == USB_ID(0x0763, 0x2012)) |
---|
1032 | 1311 | return fasttrackpro_skip_setting_quirk(chip, iface, altno); |
---|
| 1312 | + /* presonus studio 1810c: skip altsets incompatible with device_setup */ |
---|
| 1313 | + if (chip->usb_id == USB_ID(0x194f, 0x010c)) |
---|
| 1314 | + return s1810c_skip_setting_quirk(chip, iface, altno); |
---|
| 1315 | + |
---|
1033 | 1316 | |
---|
1034 | 1317 | return 0; |
---|
1035 | 1318 | } |
---|
.. | .. |
---|
1080 | 1363 | return snd_usb_gamecon780_boot_quirk(dev); |
---|
1081 | 1364 | case USB_ID(0x2466, 0x8010): /* Fractal Audio Axe-Fx 3 */ |
---|
1082 | 1365 | return snd_usb_axefx3_boot_quirk(dev); |
---|
| 1366 | + case USB_ID(0x07fd, 0x0004): /* MOTU MicroBook II */ |
---|
| 1367 | + /* |
---|
| 1368 | + * For some reason interface 3 with vendor-spec class is |
---|
| 1369 | + * detected on MicroBook IIc. |
---|
| 1370 | + */ |
---|
| 1371 | + if (get_iface_desc(intf->altsetting)->bInterfaceClass == |
---|
| 1372 | + USB_CLASS_VENDOR_SPEC && |
---|
| 1373 | + get_iface_desc(intf->altsetting)->bInterfaceNumber < 3) |
---|
| 1374 | + return snd_usb_motu_microbookii_boot_quirk(dev); |
---|
| 1375 | + break; |
---|
| 1376 | + } |
---|
| 1377 | + |
---|
| 1378 | + return 0; |
---|
| 1379 | +} |
---|
| 1380 | + |
---|
| 1381 | +int snd_usb_apply_boot_quirk_once(struct usb_device *dev, |
---|
| 1382 | + struct usb_interface *intf, |
---|
| 1383 | + const struct snd_usb_audio_quirk *quirk, |
---|
| 1384 | + unsigned int id) |
---|
| 1385 | +{ |
---|
| 1386 | + switch (id) { |
---|
| 1387 | + case USB_ID(0x07fd, 0x0008): /* MOTU M Series */ |
---|
| 1388 | + return snd_usb_motu_m_series_boot_quirk(dev); |
---|
1083 | 1389 | } |
---|
1084 | 1390 | |
---|
1085 | 1391 | return 0; |
---|
.. | .. |
---|
1164 | 1470 | subs->pkt_offset_adj = (emu_samplerate_id >= EMU_QUIRK_SR_176400HZ) ? 4 : 0; |
---|
1165 | 1471 | } |
---|
1166 | 1472 | |
---|
| 1473 | + |
---|
| 1474 | +/* |
---|
| 1475 | + * Pioneer DJ DJM-900NXS2 |
---|
| 1476 | + * Device needs to know the sample rate each time substream is started |
---|
| 1477 | + */ |
---|
| 1478 | +static int pioneer_djm_set_format_quirk(struct snd_usb_substream *subs) |
---|
| 1479 | +{ |
---|
| 1480 | + |
---|
| 1481 | + /* Convert sample rate value to little endian */ |
---|
| 1482 | + u8 sr[3]; |
---|
| 1483 | + |
---|
| 1484 | + sr[0] = subs->cur_rate & 0xff; |
---|
| 1485 | + sr[1] = (subs->cur_rate >> 8) & 0xff; |
---|
| 1486 | + sr[2] = (subs->cur_rate >> 16) & 0xff; |
---|
| 1487 | + |
---|
| 1488 | + /* Configure device */ |
---|
| 1489 | + usb_set_interface(subs->dev, 0, 1); |
---|
| 1490 | + snd_usb_ctl_msg(subs->stream->chip->dev, |
---|
| 1491 | + usb_rcvctrlpipe(subs->stream->chip->dev, 0), |
---|
| 1492 | + 0x01, 0x22, 0x0100, 0x0082, &sr, 0x0003); |
---|
| 1493 | + |
---|
| 1494 | + return 0; |
---|
| 1495 | +} |
---|
| 1496 | + |
---|
1167 | 1497 | void snd_usb_set_format_quirk(struct snd_usb_substream *subs, |
---|
1168 | 1498 | struct audioformat *fmt) |
---|
1169 | 1499 | { |
---|
.. | .. |
---|
1174 | 1504 | case USB_ID(0x041e, 0x3f19): /* E-Mu 0204 USB */ |
---|
1175 | 1505 | set_format_emu_quirk(subs, fmt); |
---|
1176 | 1506 | break; |
---|
| 1507 | + case USB_ID(0x2b73, 0x000a): /* Pioneer DJ DJM-900NXS2 */ |
---|
| 1508 | + case USB_ID(0x2b73, 0x0017): /* Pioneer DJ DJM-250MK2 */ |
---|
| 1509 | + pioneer_djm_set_format_quirk(subs); |
---|
| 1510 | + break; |
---|
| 1511 | + case USB_ID(0x534d, 0x0021): /* MacroSilicon MS2100/MS2106 */ |
---|
| 1512 | + case USB_ID(0x534d, 0x2109): /* MacroSilicon MS2109 */ |
---|
| 1513 | + subs->stream_offset_adj = 2; |
---|
| 1514 | + break; |
---|
1177 | 1515 | } |
---|
1178 | 1516 | } |
---|
1179 | 1517 | |
---|
.. | .. |
---|
1181 | 1519 | { |
---|
1182 | 1520 | /* devices which do not support reading the sample rate. */ |
---|
1183 | 1521 | switch (chip->usb_id) { |
---|
1184 | | - case USB_ID(0x041E, 0x4080): /* Creative Live Cam VF0610 */ |
---|
1185 | | - case USB_ID(0x04D8, 0xFEEA): /* Benchmark DAC1 Pre */ |
---|
| 1522 | + case USB_ID(0x041e, 0x4080): /* Creative Live Cam VF0610 */ |
---|
| 1523 | + case USB_ID(0x04d8, 0xfeea): /* Benchmark DAC1 Pre */ |
---|
1186 | 1524 | case USB_ID(0x0556, 0x0014): /* Phoenix Audio TMX320VC */ |
---|
1187 | | - case USB_ID(0x05A3, 0x9420): /* ELP HD USB Camera */ |
---|
| 1525 | + case USB_ID(0x05a3, 0x9420): /* ELP HD USB Camera */ |
---|
1188 | 1526 | case USB_ID(0x05a7, 0x1020): /* Bose Companion 5 */ |
---|
1189 | | -#ifdef CONFIG_HID_RKVR |
---|
1190 | | - case USB_ID(0x071B, 0x3205): /* RockChip NanoC VR */ |
---|
1191 | | -#endif |
---|
1192 | | - case USB_ID(0x074D, 0x3553): /* Outlaw RR2150 (Micronas UAC3553B) */ |
---|
| 1527 | + case USB_ID(0x074d, 0x3553): /* Outlaw RR2150 (Micronas UAC3553B) */ |
---|
1193 | 1528 | case USB_ID(0x1395, 0x740a): /* Sennheiser DECT */ |
---|
1194 | 1529 | case USB_ID(0x1901, 0x0191): /* GE B850V3 CP2114 audio interface */ |
---|
1195 | | - case USB_ID(0x21B4, 0x0081): /* AudioQuest DragonFly */ |
---|
| 1530 | + case USB_ID(0x21b4, 0x0081): /* AudioQuest DragonFly */ |
---|
1196 | 1531 | case USB_ID(0x2912, 0x30c8): /* Audioengine D1 */ |
---|
1197 | 1532 | case USB_ID(0x413c, 0xa506): /* Dell AE515 sound bar */ |
---|
1198 | 1533 | case USB_ID(0x046d, 0x084c): /* Logitech ConferenceCam Connect */ |
---|
.. | .. |
---|
1201 | 1536 | |
---|
1202 | 1537 | /* devices of these vendors don't support reading rate, either */ |
---|
1203 | 1538 | switch (USB_ID_VENDOR(chip->usb_id)) { |
---|
1204 | | - case 0x045E: /* MS Lifecam */ |
---|
1205 | | - case 0x047F: /* Plantronics */ |
---|
| 1539 | + case 0x045e: /* MS Lifecam */ |
---|
| 1540 | + case 0x047f: /* Plantronics */ |
---|
1206 | 1541 | case 0x1de7: /* Phoenix Audio */ |
---|
1207 | 1542 | return true; |
---|
1208 | 1543 | } |
---|
.. | .. |
---|
1281 | 1616 | |
---|
1282 | 1617 | /* |
---|
1283 | 1618 | * M-Audio Fast Track C400/C600 - when packets are not skipped, real |
---|
1284 | | - * world latency varies by approx. +/- 50 frames (at 96KHz) each time |
---|
| 1619 | + * world latency varies by approx. +/- 50 frames (at 96kHz) each time |
---|
1285 | 1620 | * the stream is (re)started. When skipping packets 16 at endpoint |
---|
1286 | 1621 | * start up, the real world latency is stable within +/- 1 frame (also |
---|
1287 | 1622 | * across power cycles). |
---|
.. | .. |
---|
1409 | 1744 | /* XMOS based USB DACs */ |
---|
1410 | 1745 | switch (chip->usb_id) { |
---|
1411 | 1746 | case USB_ID(0x1511, 0x0037): /* AURALiC VEGA */ |
---|
| 1747 | + case USB_ID(0x21ed, 0xd75a): /* Accuphase DAC-60 option card */ |
---|
1412 | 1748 | case USB_ID(0x2522, 0x0012): /* LH Labs VI DAC Infinity */ |
---|
1413 | 1749 | case USB_ID(0x2772, 0x0230): /* Pro-Ject Pre Box S2 Digital */ |
---|
1414 | 1750 | if (fp->altsetting == 2) |
---|
.. | .. |
---|
1504 | 1840 | int stream) |
---|
1505 | 1841 | { |
---|
1506 | 1842 | switch (chip->usb_id) { |
---|
1507 | | -#ifdef CONFIG_HID_RKVR |
---|
1508 | | - case USB_ID(0x071B, 0x3205): /* RockChip NanoC VR */ |
---|
1509 | | -#endif |
---|
1510 | 1843 | case USB_ID(0x0a92, 0x0053): /* AudioTrak Optoplay */ |
---|
1511 | 1844 | /* Optoplay sets the sample rate attribute although |
---|
1512 | 1845 | * it seems not supporting it in fact. |
---|
.. | .. |
---|
1532 | 1865 | fp->ep_attr |= USB_ENDPOINT_SYNC_ADAPTIVE; |
---|
1533 | 1866 | else |
---|
1534 | 1867 | fp->ep_attr |= USB_ENDPOINT_SYNC_SYNC; |
---|
| 1868 | + break; |
---|
| 1869 | + case USB_ID(0x07fd, 0x0004): /* MOTU MicroBook IIc */ |
---|
| 1870 | + /* |
---|
| 1871 | + * MaxPacketsOnly attribute is erroneously set in endpoint |
---|
| 1872 | + * descriptors. As a result this card produces noise with |
---|
| 1873 | + * all sample rates other than 96 kHz. |
---|
| 1874 | + */ |
---|
| 1875 | + fp->attributes &= ~UAC_EP_CS_ATTR_FILL_MAX; |
---|
1535 | 1876 | break; |
---|
1536 | 1877 | } |
---|
1537 | 1878 | } |
---|
.. | .. |
---|
1572 | 1913 | |
---|
1573 | 1914 | for (q = registration_quirks; q->usb_id; q++) |
---|
1574 | 1915 | if (chip->usb_id == q->usb_id) |
---|
1575 | | - return iface != q->interface; |
---|
| 1916 | + return iface < q->interface; |
---|
1576 | 1917 | |
---|
1577 | 1918 | /* Register as normal */ |
---|
1578 | 1919 | return false; |
---|