mixer_quirks.c 47 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827
  1. /*
  2. * USB Audio Driver for ALSA
  3. *
  4. * Quirks and vendor-specific extensions for mixer interfaces
  5. *
  6. * Copyright (c) 2002 by Takashi Iwai <tiwai@suse.de>
  7. *
  8. * Many codes borrowed from audio.c by
  9. * Alan Cox (alan@lxorguk.ukuu.org.uk)
  10. * Thomas Sailer (sailer@ife.ee.ethz.ch)
  11. *
  12. * Audio Advantage Micro II support added by:
  13. * Przemek Rudy (prudy1@o2.pl)
  14. *
  15. * This program is free software; you can redistribute it and/or modify
  16. * it under the terms of the GNU General Public License as published by
  17. * the Free Software Foundation; either version 2 of the License, or
  18. * (at your option) any later version.
  19. *
  20. * This program is distributed in the hope that it will be useful,
  21. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  22. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  23. * GNU General Public License for more details.
  24. *
  25. * You should have received a copy of the GNU General Public License
  26. * along with this program; if not, write to the Free Software
  27. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  28. */
  29. #include <linux/init.h>
  30. #include <linux/slab.h>
  31. #include <linux/usb.h>
  32. #include <linux/usb/audio.h>
  33. #include <sound/asoundef.h>
  34. #include <sound/core.h>
  35. #include <sound/control.h>
  36. #include <sound/hwdep.h>
  37. #include <sound/info.h>
  38. #include "usbaudio.h"
  39. #include "mixer.h"
  40. #include "mixer_quirks.h"
  41. #include "mixer_scarlett.h"
  42. #include "helper.h"
  43. extern struct snd_kcontrol_new *snd_usb_feature_unit_ctl;
  44. struct std_mono_table {
  45. unsigned int unitid, control, cmask;
  46. int val_type;
  47. const char *name;
  48. snd_kcontrol_tlv_rw_t *tlv_callback;
  49. };
  50. /* This function allows for the creation of standard UAC controls.
  51. * See the quirks for M-Audio FTUs or Ebox-44.
  52. * If you don't want to set a TLV callback pass NULL.
  53. *
  54. * Since there doesn't seem to be a devices that needs a multichannel
  55. * version, we keep it mono for simplicity.
  56. */
  57. static int snd_create_std_mono_ctl_offset(struct usb_mixer_interface *mixer,
  58. unsigned int unitid,
  59. unsigned int control,
  60. unsigned int cmask,
  61. int val_type,
  62. unsigned int idx_off,
  63. const char *name,
  64. snd_kcontrol_tlv_rw_t *tlv_callback)
  65. {
  66. struct usb_mixer_elem_info *cval;
  67. struct snd_kcontrol *kctl;
  68. cval = kzalloc(sizeof(*cval), GFP_KERNEL);
  69. if (!cval)
  70. return -ENOMEM;
  71. snd_usb_mixer_elem_init_std(&cval->head, mixer, unitid);
  72. cval->val_type = val_type;
  73. cval->channels = 1;
  74. cval->control = control;
  75. cval->cmask = cmask;
  76. cval->idx_off = idx_off;
  77. /* get_min_max() is called only for integer volumes later,
  78. * so provide a short-cut for booleans */
  79. cval->min = 0;
  80. cval->max = 1;
  81. cval->res = 0;
  82. cval->dBmin = 0;
  83. cval->dBmax = 0;
  84. /* Create control */
  85. kctl = snd_ctl_new1(snd_usb_feature_unit_ctl, cval);
  86. if (!kctl) {
  87. kfree(cval);
  88. return -ENOMEM;
  89. }
  90. /* Set name */
  91. snprintf(kctl->id.name, sizeof(kctl->id.name), name);
  92. kctl->private_free = snd_usb_mixer_elem_free;
  93. /* set TLV */
  94. if (tlv_callback) {
  95. kctl->tlv.c = tlv_callback;
  96. kctl->vd[0].access |=
  97. SNDRV_CTL_ELEM_ACCESS_TLV_READ |
  98. SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK;
  99. }
  100. /* Add control to mixer */
  101. return snd_usb_mixer_add_control(&cval->head, kctl);
  102. }
  103. static int snd_create_std_mono_ctl(struct usb_mixer_interface *mixer,
  104. unsigned int unitid,
  105. unsigned int control,
  106. unsigned int cmask,
  107. int val_type,
  108. const char *name,
  109. snd_kcontrol_tlv_rw_t *tlv_callback)
  110. {
  111. return snd_create_std_mono_ctl_offset(mixer, unitid, control, cmask,
  112. val_type, 0 /* Offset */, name, tlv_callback);
  113. }
  114. /*
  115. * Create a set of standard UAC controls from a table
  116. */
  117. static int snd_create_std_mono_table(struct usb_mixer_interface *mixer,
  118. struct std_mono_table *t)
  119. {
  120. int err;
  121. while (t->name != NULL) {
  122. err = snd_create_std_mono_ctl(mixer, t->unitid, t->control,
  123. t->cmask, t->val_type, t->name, t->tlv_callback);
  124. if (err < 0)
  125. return err;
  126. t++;
  127. }
  128. return 0;
  129. }
  130. static int add_single_ctl_with_resume(struct usb_mixer_interface *mixer,
  131. int id,
  132. usb_mixer_elem_resume_func_t resume,
  133. const struct snd_kcontrol_new *knew,
  134. struct usb_mixer_elem_list **listp)
  135. {
  136. struct usb_mixer_elem_list *list;
  137. struct snd_kcontrol *kctl;
  138. list = kzalloc(sizeof(*list), GFP_KERNEL);
  139. if (!list)
  140. return -ENOMEM;
  141. if (listp)
  142. *listp = list;
  143. list->mixer = mixer;
  144. list->id = id;
  145. list->resume = resume;
  146. kctl = snd_ctl_new1(knew, list);
  147. if (!kctl) {
  148. kfree(list);
  149. return -ENOMEM;
  150. }
  151. kctl->private_free = snd_usb_mixer_elem_free;
  152. return snd_usb_mixer_add_control(list, kctl);
  153. }
  154. /*
  155. * Sound Blaster remote control configuration
  156. *
  157. * format of remote control data:
  158. * Extigy: xx 00
  159. * Audigy 2 NX: 06 80 xx 00 00 00
  160. * Live! 24-bit: 06 80 xx yy 22 83
  161. */
  162. static const struct rc_config {
  163. u32 usb_id;
  164. u8 offset;
  165. u8 length;
  166. u8 packet_length;
  167. u8 min_packet_length; /* minimum accepted length of the URB result */
  168. u8 mute_mixer_id;
  169. u32 mute_code;
  170. } rc_configs[] = {
  171. { USB_ID(0x041e, 0x3000), 0, 1, 2, 1, 18, 0x0013 }, /* Extigy */
  172. { USB_ID(0x041e, 0x3020), 2, 1, 6, 6, 18, 0x0013 }, /* Audigy 2 NX */
  173. { USB_ID(0x041e, 0x3040), 2, 2, 6, 6, 2, 0x6e91 }, /* Live! 24-bit */
  174. { USB_ID(0x041e, 0x3042), 0, 1, 1, 1, 1, 0x000d }, /* Usb X-Fi S51 */
  175. { USB_ID(0x041e, 0x30df), 0, 1, 1, 1, 1, 0x000d }, /* Usb X-Fi S51 Pro */
  176. { USB_ID(0x041e, 0x3237), 0, 1, 1, 1, 1, 0x000d }, /* Usb X-Fi S51 Pro */
  177. { USB_ID(0x041e, 0x3048), 2, 2, 6, 6, 2, 0x6e91 }, /* Toshiba SB0500 */
  178. };
  179. static void snd_usb_soundblaster_remote_complete(struct urb *urb)
  180. {
  181. struct usb_mixer_interface *mixer = urb->context;
  182. const struct rc_config *rc = mixer->rc_cfg;
  183. u32 code;
  184. if (urb->status < 0 || urb->actual_length < rc->min_packet_length)
  185. return;
  186. code = mixer->rc_buffer[rc->offset];
  187. if (rc->length == 2)
  188. code |= mixer->rc_buffer[rc->offset + 1] << 8;
  189. /* the Mute button actually changes the mixer control */
  190. if (code == rc->mute_code)
  191. snd_usb_mixer_notify_id(mixer, rc->mute_mixer_id);
  192. mixer->rc_code = code;
  193. wmb();
  194. wake_up(&mixer->rc_waitq);
  195. }
  196. static long snd_usb_sbrc_hwdep_read(struct snd_hwdep *hw, char __user *buf,
  197. long count, loff_t *offset)
  198. {
  199. struct usb_mixer_interface *mixer = hw->private_data;
  200. int err;
  201. u32 rc_code;
  202. if (count != 1 && count != 4)
  203. return -EINVAL;
  204. err = wait_event_interruptible(mixer->rc_waitq,
  205. (rc_code = xchg(&mixer->rc_code, 0)) != 0);
  206. if (err == 0) {
  207. if (count == 1)
  208. err = put_user(rc_code, buf);
  209. else
  210. err = put_user(rc_code, (u32 __user *)buf);
  211. }
  212. return err < 0 ? err : count;
  213. }
  214. static unsigned int snd_usb_sbrc_hwdep_poll(struct snd_hwdep *hw, struct file *file,
  215. poll_table *wait)
  216. {
  217. struct usb_mixer_interface *mixer = hw->private_data;
  218. poll_wait(file, &mixer->rc_waitq, wait);
  219. return mixer->rc_code ? POLLIN | POLLRDNORM : 0;
  220. }
  221. static int snd_usb_soundblaster_remote_init(struct usb_mixer_interface *mixer)
  222. {
  223. struct snd_hwdep *hwdep;
  224. int err, len, i;
  225. for (i = 0; i < ARRAY_SIZE(rc_configs); ++i)
  226. if (rc_configs[i].usb_id == mixer->chip->usb_id)
  227. break;
  228. if (i >= ARRAY_SIZE(rc_configs))
  229. return 0;
  230. mixer->rc_cfg = &rc_configs[i];
  231. len = mixer->rc_cfg->packet_length;
  232. init_waitqueue_head(&mixer->rc_waitq);
  233. err = snd_hwdep_new(mixer->chip->card, "SB remote control", 0, &hwdep);
  234. if (err < 0)
  235. return err;
  236. snprintf(hwdep->name, sizeof(hwdep->name),
  237. "%s remote control", mixer->chip->card->shortname);
  238. hwdep->iface = SNDRV_HWDEP_IFACE_SB_RC;
  239. hwdep->private_data = mixer;
  240. hwdep->ops.read = snd_usb_sbrc_hwdep_read;
  241. hwdep->ops.poll = snd_usb_sbrc_hwdep_poll;
  242. hwdep->exclusive = 1;
  243. mixer->rc_urb = usb_alloc_urb(0, GFP_KERNEL);
  244. if (!mixer->rc_urb)
  245. return -ENOMEM;
  246. mixer->rc_setup_packet = kmalloc(sizeof(*mixer->rc_setup_packet), GFP_KERNEL);
  247. if (!mixer->rc_setup_packet) {
  248. usb_free_urb(mixer->rc_urb);
  249. mixer->rc_urb = NULL;
  250. return -ENOMEM;
  251. }
  252. mixer->rc_setup_packet->bRequestType =
  253. USB_DIR_IN | USB_TYPE_CLASS | USB_RECIP_INTERFACE;
  254. mixer->rc_setup_packet->bRequest = UAC_GET_MEM;
  255. mixer->rc_setup_packet->wValue = cpu_to_le16(0);
  256. mixer->rc_setup_packet->wIndex = cpu_to_le16(0);
  257. mixer->rc_setup_packet->wLength = cpu_to_le16(len);
  258. usb_fill_control_urb(mixer->rc_urb, mixer->chip->dev,
  259. usb_rcvctrlpipe(mixer->chip->dev, 0),
  260. (u8*)mixer->rc_setup_packet, mixer->rc_buffer, len,
  261. snd_usb_soundblaster_remote_complete, mixer);
  262. return 0;
  263. }
  264. #define snd_audigy2nx_led_info snd_ctl_boolean_mono_info
  265. static int snd_audigy2nx_led_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
  266. {
  267. ucontrol->value.integer.value[0] = kcontrol->private_value >> 8;
  268. return 0;
  269. }
  270. static int snd_audigy2nx_led_update(struct usb_mixer_interface *mixer,
  271. int value, int index)
  272. {
  273. struct snd_usb_audio *chip = mixer->chip;
  274. int err;
  275. err = snd_usb_lock_shutdown(chip);
  276. if (err < 0)
  277. return err;
  278. if (chip->usb_id == USB_ID(0x041e, 0x3042))
  279. err = snd_usb_ctl_msg(chip->dev,
  280. usb_sndctrlpipe(chip->dev, 0), 0x24,
  281. USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_OTHER,
  282. !value, 0, NULL, 0);
  283. /* USB X-Fi S51 Pro */
  284. if (chip->usb_id == USB_ID(0x041e, 0x30df))
  285. err = snd_usb_ctl_msg(chip->dev,
  286. usb_sndctrlpipe(chip->dev, 0), 0x24,
  287. USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_OTHER,
  288. !value, 0, NULL, 0);
  289. else
  290. err = snd_usb_ctl_msg(chip->dev,
  291. usb_sndctrlpipe(chip->dev, 0), 0x24,
  292. USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_OTHER,
  293. value, index + 2, NULL, 0);
  294. snd_usb_unlock_shutdown(chip);
  295. return err;
  296. }
  297. static int snd_audigy2nx_led_put(struct snd_kcontrol *kcontrol,
  298. struct snd_ctl_elem_value *ucontrol)
  299. {
  300. struct usb_mixer_elem_list *list = snd_kcontrol_chip(kcontrol);
  301. struct usb_mixer_interface *mixer = list->mixer;
  302. int index = kcontrol->private_value & 0xff;
  303. int value = ucontrol->value.integer.value[0];
  304. int old_value = kcontrol->private_value >> 8;
  305. int err;
  306. if (value > 1)
  307. return -EINVAL;
  308. if (value == old_value)
  309. return 0;
  310. kcontrol->private_value = (value << 8) | index;
  311. err = snd_audigy2nx_led_update(mixer, value, index);
  312. return err < 0 ? err : 1;
  313. }
  314. static int snd_audigy2nx_led_resume(struct usb_mixer_elem_list *list)
  315. {
  316. int priv_value = list->kctl->private_value;
  317. return snd_audigy2nx_led_update(list->mixer, priv_value >> 8,
  318. priv_value & 0xff);
  319. }
  320. /* name and private_value are set dynamically */
  321. static struct snd_kcontrol_new snd_audigy2nx_control = {
  322. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  323. .info = snd_audigy2nx_led_info,
  324. .get = snd_audigy2nx_led_get,
  325. .put = snd_audigy2nx_led_put,
  326. };
  327. static const char * const snd_audigy2nx_led_names[] = {
  328. "CMSS LED Switch",
  329. "Power LED Switch",
  330. "Dolby Digital LED Switch",
  331. };
  332. static int snd_audigy2nx_controls_create(struct usb_mixer_interface *mixer)
  333. {
  334. int i, err;
  335. for (i = 0; i < ARRAY_SIZE(snd_audigy2nx_led_names); ++i) {
  336. struct snd_kcontrol_new knew;
  337. /* USB X-Fi S51 doesn't have a CMSS LED */
  338. if ((mixer->chip->usb_id == USB_ID(0x041e, 0x3042)) && i == 0)
  339. continue;
  340. /* USB X-Fi S51 Pro doesn't have one either */
  341. if ((mixer->chip->usb_id == USB_ID(0x041e, 0x30df)) && i == 0)
  342. continue;
  343. if (i > 1 && /* Live24ext has 2 LEDs only */
  344. (mixer->chip->usb_id == USB_ID(0x041e, 0x3040) ||
  345. mixer->chip->usb_id == USB_ID(0x041e, 0x3042) ||
  346. mixer->chip->usb_id == USB_ID(0x041e, 0x30df) ||
  347. mixer->chip->usb_id == USB_ID(0x041e, 0x3048)))
  348. break;
  349. knew = snd_audigy2nx_control;
  350. knew.name = snd_audigy2nx_led_names[i];
  351. knew.private_value = (1 << 8) | i; /* LED on as default */
  352. err = add_single_ctl_with_resume(mixer, 0,
  353. snd_audigy2nx_led_resume,
  354. &knew, NULL);
  355. if (err < 0)
  356. return err;
  357. }
  358. return 0;
  359. }
  360. static void snd_audigy2nx_proc_read(struct snd_info_entry *entry,
  361. struct snd_info_buffer *buffer)
  362. {
  363. static const struct sb_jack {
  364. int unitid;
  365. const char *name;
  366. } jacks_audigy2nx[] = {
  367. {4, "dig in "},
  368. {7, "line in"},
  369. {19, "spk out"},
  370. {20, "hph out"},
  371. {-1, NULL}
  372. }, jacks_live24ext[] = {
  373. {4, "line in"}, /* &1=Line, &2=Mic*/
  374. {3, "hph out"}, /* headphones */
  375. {0, "RC "}, /* last command, 6 bytes see rc_config above */
  376. {-1, NULL}
  377. };
  378. const struct sb_jack *jacks;
  379. struct usb_mixer_interface *mixer = entry->private_data;
  380. int i, err;
  381. u8 buf[3];
  382. snd_iprintf(buffer, "%s jacks\n\n", mixer->chip->card->shortname);
  383. if (mixer->chip->usb_id == USB_ID(0x041e, 0x3020))
  384. jacks = jacks_audigy2nx;
  385. else if (mixer->chip->usb_id == USB_ID(0x041e, 0x3040) ||
  386. mixer->chip->usb_id == USB_ID(0x041e, 0x3048))
  387. jacks = jacks_live24ext;
  388. else
  389. return;
  390. for (i = 0; jacks[i].name; ++i) {
  391. snd_iprintf(buffer, "%s: ", jacks[i].name);
  392. err = snd_usb_lock_shutdown(mixer->chip);
  393. if (err < 0)
  394. return;
  395. err = snd_usb_ctl_msg(mixer->chip->dev,
  396. usb_rcvctrlpipe(mixer->chip->dev, 0),
  397. UAC_GET_MEM, USB_DIR_IN | USB_TYPE_CLASS |
  398. USB_RECIP_INTERFACE, 0,
  399. jacks[i].unitid << 8, buf, 3);
  400. snd_usb_unlock_shutdown(mixer->chip);
  401. if (err == 3 && (buf[0] == 3 || buf[0] == 6))
  402. snd_iprintf(buffer, "%02x %02x\n", buf[1], buf[2]);
  403. else
  404. snd_iprintf(buffer, "?\n");
  405. }
  406. }
  407. /* EMU0204 */
  408. static int snd_emu0204_ch_switch_info(struct snd_kcontrol *kcontrol,
  409. struct snd_ctl_elem_info *uinfo)
  410. {
  411. static const char * const texts[2] = {"1/2", "3/4"};
  412. return snd_ctl_enum_info(uinfo, 1, ARRAY_SIZE(texts), texts);
  413. }
  414. static int snd_emu0204_ch_switch_get(struct snd_kcontrol *kcontrol,
  415. struct snd_ctl_elem_value *ucontrol)
  416. {
  417. ucontrol->value.enumerated.item[0] = kcontrol->private_value;
  418. return 0;
  419. }
  420. static int snd_emu0204_ch_switch_update(struct usb_mixer_interface *mixer,
  421. int value)
  422. {
  423. struct snd_usb_audio *chip = mixer->chip;
  424. int err;
  425. unsigned char buf[2];
  426. err = snd_usb_lock_shutdown(chip);
  427. if (err < 0)
  428. return err;
  429. buf[0] = 0x01;
  430. buf[1] = value ? 0x02 : 0x01;
  431. err = snd_usb_ctl_msg(chip->dev,
  432. usb_sndctrlpipe(chip->dev, 0), UAC_SET_CUR,
  433. USB_RECIP_INTERFACE | USB_TYPE_CLASS | USB_DIR_OUT,
  434. 0x0400, 0x0e00, buf, 2);
  435. snd_usb_unlock_shutdown(chip);
  436. return err;
  437. }
  438. static int snd_emu0204_ch_switch_put(struct snd_kcontrol *kcontrol,
  439. struct snd_ctl_elem_value *ucontrol)
  440. {
  441. struct usb_mixer_elem_list *list = snd_kcontrol_chip(kcontrol);
  442. struct usb_mixer_interface *mixer = list->mixer;
  443. unsigned int value = ucontrol->value.enumerated.item[0];
  444. int err;
  445. if (value > 1)
  446. return -EINVAL;
  447. if (value == kcontrol->private_value)
  448. return 0;
  449. kcontrol->private_value = value;
  450. err = snd_emu0204_ch_switch_update(mixer, value);
  451. return err < 0 ? err : 1;
  452. }
  453. static int snd_emu0204_ch_switch_resume(struct usb_mixer_elem_list *list)
  454. {
  455. return snd_emu0204_ch_switch_update(list->mixer,
  456. list->kctl->private_value);
  457. }
  458. static struct snd_kcontrol_new snd_emu0204_control = {
  459. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  460. .name = "Front Jack Channels",
  461. .info = snd_emu0204_ch_switch_info,
  462. .get = snd_emu0204_ch_switch_get,
  463. .put = snd_emu0204_ch_switch_put,
  464. .private_value = 0,
  465. };
  466. static int snd_emu0204_controls_create(struct usb_mixer_interface *mixer)
  467. {
  468. return add_single_ctl_with_resume(mixer, 0,
  469. snd_emu0204_ch_switch_resume,
  470. &snd_emu0204_control, NULL);
  471. }
  472. /* ASUS Xonar U1 / U3 controls */
  473. static int snd_xonar_u1_switch_get(struct snd_kcontrol *kcontrol,
  474. struct snd_ctl_elem_value *ucontrol)
  475. {
  476. ucontrol->value.integer.value[0] = !!(kcontrol->private_value & 0x02);
  477. return 0;
  478. }
  479. static int snd_xonar_u1_switch_update(struct usb_mixer_interface *mixer,
  480. unsigned char status)
  481. {
  482. struct snd_usb_audio *chip = mixer->chip;
  483. int err;
  484. err = snd_usb_lock_shutdown(chip);
  485. if (err < 0)
  486. return err;
  487. err = snd_usb_ctl_msg(chip->dev,
  488. usb_sndctrlpipe(chip->dev, 0), 0x08,
  489. USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_OTHER,
  490. 50, 0, &status, 1);
  491. snd_usb_unlock_shutdown(chip);
  492. return err;
  493. }
  494. static int snd_xonar_u1_switch_put(struct snd_kcontrol *kcontrol,
  495. struct snd_ctl_elem_value *ucontrol)
  496. {
  497. struct usb_mixer_elem_list *list = snd_kcontrol_chip(kcontrol);
  498. u8 old_status, new_status;
  499. int err;
  500. old_status = kcontrol->private_value;
  501. if (ucontrol->value.integer.value[0])
  502. new_status = old_status | 0x02;
  503. else
  504. new_status = old_status & ~0x02;
  505. if (new_status == old_status)
  506. return 0;
  507. kcontrol->private_value = new_status;
  508. err = snd_xonar_u1_switch_update(list->mixer, new_status);
  509. return err < 0 ? err : 1;
  510. }
  511. static int snd_xonar_u1_switch_resume(struct usb_mixer_elem_list *list)
  512. {
  513. return snd_xonar_u1_switch_update(list->mixer,
  514. list->kctl->private_value);
  515. }
  516. static struct snd_kcontrol_new snd_xonar_u1_output_switch = {
  517. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  518. .name = "Digital Playback Switch",
  519. .info = snd_ctl_boolean_mono_info,
  520. .get = snd_xonar_u1_switch_get,
  521. .put = snd_xonar_u1_switch_put,
  522. .private_value = 0x05,
  523. };
  524. static int snd_xonar_u1_controls_create(struct usb_mixer_interface *mixer)
  525. {
  526. return add_single_ctl_with_resume(mixer, 0,
  527. snd_xonar_u1_switch_resume,
  528. &snd_xonar_u1_output_switch, NULL);
  529. }
  530. /* Digidesign Mbox 1 clock source switch (internal/spdif) */
  531. static int snd_mbox1_switch_get(struct snd_kcontrol *kctl,
  532. struct snd_ctl_elem_value *ucontrol)
  533. {
  534. ucontrol->value.enumerated.item[0] = kctl->private_value;
  535. return 0;
  536. }
  537. static int snd_mbox1_switch_update(struct usb_mixer_interface *mixer, int val)
  538. {
  539. struct snd_usb_audio *chip = mixer->chip;
  540. int err;
  541. unsigned char buff[3];
  542. err = snd_usb_lock_shutdown(chip);
  543. if (err < 0)
  544. return err;
  545. /* Prepare for magic command to toggle clock source */
  546. err = snd_usb_ctl_msg(chip->dev,
  547. usb_rcvctrlpipe(chip->dev, 0), 0x81,
  548. USB_DIR_IN |
  549. USB_TYPE_CLASS |
  550. USB_RECIP_INTERFACE, 0x00, 0x500, buff, 1);
  551. if (err < 0)
  552. goto err;
  553. err = snd_usb_ctl_msg(chip->dev,
  554. usb_rcvctrlpipe(chip->dev, 0), 0x81,
  555. USB_DIR_IN |
  556. USB_TYPE_CLASS |
  557. USB_RECIP_ENDPOINT, 0x100, 0x81, buff, 3);
  558. if (err < 0)
  559. goto err;
  560. /* 2 possibilities: Internal -> send sample rate
  561. * S/PDIF sync -> send zeroes
  562. * NB: Sample rate locked to 48kHz on purpose to
  563. * prevent user from resetting the sample rate
  564. * while S/PDIF sync is enabled and confusing
  565. * this configuration.
  566. */
  567. if (val == 0) {
  568. buff[0] = 0x80;
  569. buff[1] = 0xbb;
  570. buff[2] = 0x00;
  571. } else {
  572. buff[0] = buff[1] = buff[2] = 0x00;
  573. }
  574. /* Send the magic command to toggle the clock source */
  575. err = snd_usb_ctl_msg(chip->dev,
  576. usb_sndctrlpipe(chip->dev, 0), 0x1,
  577. USB_TYPE_CLASS |
  578. USB_RECIP_ENDPOINT, 0x100, 0x81, buff, 3);
  579. if (err < 0)
  580. goto err;
  581. err = snd_usb_ctl_msg(chip->dev,
  582. usb_rcvctrlpipe(chip->dev, 0), 0x81,
  583. USB_DIR_IN |
  584. USB_TYPE_CLASS |
  585. USB_RECIP_ENDPOINT, 0x100, 0x81, buff, 3);
  586. if (err < 0)
  587. goto err;
  588. err = snd_usb_ctl_msg(chip->dev,
  589. usb_rcvctrlpipe(chip->dev, 0), 0x81,
  590. USB_DIR_IN |
  591. USB_TYPE_CLASS |
  592. USB_RECIP_ENDPOINT, 0x100, 0x2, buff, 3);
  593. if (err < 0)
  594. goto err;
  595. err:
  596. snd_usb_unlock_shutdown(chip);
  597. return err;
  598. }
  599. static int snd_mbox1_switch_put(struct snd_kcontrol *kctl,
  600. struct snd_ctl_elem_value *ucontrol)
  601. {
  602. struct usb_mixer_elem_list *list = snd_kcontrol_chip(kctl);
  603. struct usb_mixer_interface *mixer = list->mixer;
  604. int err;
  605. bool cur_val, new_val;
  606. cur_val = kctl->private_value;
  607. new_val = ucontrol->value.enumerated.item[0];
  608. if (cur_val == new_val)
  609. return 0;
  610. kctl->private_value = new_val;
  611. err = snd_mbox1_switch_update(mixer, new_val);
  612. return err < 0 ? err : 1;
  613. }
  614. static int snd_mbox1_switch_info(struct snd_kcontrol *kcontrol,
  615. struct snd_ctl_elem_info *uinfo)
  616. {
  617. static const char *const texts[2] = {
  618. "Internal",
  619. "S/PDIF"
  620. };
  621. return snd_ctl_enum_info(uinfo, 1, ARRAY_SIZE(texts), texts);
  622. }
  623. static int snd_mbox1_switch_resume(struct usb_mixer_elem_list *list)
  624. {
  625. return snd_mbox1_switch_update(list->mixer, list->kctl->private_value);
  626. }
  627. static struct snd_kcontrol_new snd_mbox1_switch = {
  628. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  629. .name = "Clock Source",
  630. .index = 0,
  631. .access = SNDRV_CTL_ELEM_ACCESS_READWRITE,
  632. .info = snd_mbox1_switch_info,
  633. .get = snd_mbox1_switch_get,
  634. .put = snd_mbox1_switch_put,
  635. .private_value = 0
  636. };
  637. static int snd_mbox1_create_sync_switch(struct usb_mixer_interface *mixer)
  638. {
  639. return add_single_ctl_with_resume(mixer, 0,
  640. snd_mbox1_switch_resume,
  641. &snd_mbox1_switch, NULL);
  642. }
  643. /* Native Instruments device quirks */
  644. #define _MAKE_NI_CONTROL(bRequest,wIndex) ((bRequest) << 16 | (wIndex))
  645. static int snd_ni_control_init_val(struct usb_mixer_interface *mixer,
  646. struct snd_kcontrol *kctl)
  647. {
  648. struct usb_device *dev = mixer->chip->dev;
  649. unsigned int pval = kctl->private_value;
  650. u8 value;
  651. int err;
  652. err = snd_usb_ctl_msg(dev, usb_rcvctrlpipe(dev, 0),
  653. (pval >> 16) & 0xff,
  654. USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_IN,
  655. 0, pval & 0xffff, &value, 1);
  656. if (err < 0) {
  657. dev_err(&dev->dev,
  658. "unable to issue vendor read request (ret = %d)", err);
  659. return err;
  660. }
  661. kctl->private_value |= (value << 24);
  662. return 0;
  663. }
  664. static int snd_nativeinstruments_control_get(struct snd_kcontrol *kcontrol,
  665. struct snd_ctl_elem_value *ucontrol)
  666. {
  667. ucontrol->value.integer.value[0] = kcontrol->private_value >> 24;
  668. return 0;
  669. }
  670. static int snd_ni_update_cur_val(struct usb_mixer_elem_list *list)
  671. {
  672. struct snd_usb_audio *chip = list->mixer->chip;
  673. unsigned int pval = list->kctl->private_value;
  674. int err;
  675. err = snd_usb_lock_shutdown(chip);
  676. if (err < 0)
  677. return err;
  678. err = usb_control_msg(chip->dev, usb_sndctrlpipe(chip->dev, 0),
  679. (pval >> 16) & 0xff,
  680. USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_OUT,
  681. pval >> 24, pval & 0xffff, NULL, 0, 1000);
  682. snd_usb_unlock_shutdown(chip);
  683. return err;
  684. }
  685. static int snd_nativeinstruments_control_put(struct snd_kcontrol *kcontrol,
  686. struct snd_ctl_elem_value *ucontrol)
  687. {
  688. struct usb_mixer_elem_list *list = snd_kcontrol_chip(kcontrol);
  689. u8 oldval = (kcontrol->private_value >> 24) & 0xff;
  690. u8 newval = ucontrol->value.integer.value[0];
  691. int err;
  692. if (oldval == newval)
  693. return 0;
  694. kcontrol->private_value &= ~(0xff << 24);
  695. kcontrol->private_value |= newval;
  696. err = snd_ni_update_cur_val(list);
  697. return err < 0 ? err : 1;
  698. }
  699. static struct snd_kcontrol_new snd_nativeinstruments_ta6_mixers[] = {
  700. {
  701. .name = "Direct Thru Channel A",
  702. .private_value = _MAKE_NI_CONTROL(0x01, 0x03),
  703. },
  704. {
  705. .name = "Direct Thru Channel B",
  706. .private_value = _MAKE_NI_CONTROL(0x01, 0x05),
  707. },
  708. {
  709. .name = "Phono Input Channel A",
  710. .private_value = _MAKE_NI_CONTROL(0x02, 0x03),
  711. },
  712. {
  713. .name = "Phono Input Channel B",
  714. .private_value = _MAKE_NI_CONTROL(0x02, 0x05),
  715. },
  716. };
  717. static struct snd_kcontrol_new snd_nativeinstruments_ta10_mixers[] = {
  718. {
  719. .name = "Direct Thru Channel A",
  720. .private_value = _MAKE_NI_CONTROL(0x01, 0x03),
  721. },
  722. {
  723. .name = "Direct Thru Channel B",
  724. .private_value = _MAKE_NI_CONTROL(0x01, 0x05),
  725. },
  726. {
  727. .name = "Direct Thru Channel C",
  728. .private_value = _MAKE_NI_CONTROL(0x01, 0x07),
  729. },
  730. {
  731. .name = "Direct Thru Channel D",
  732. .private_value = _MAKE_NI_CONTROL(0x01, 0x09),
  733. },
  734. {
  735. .name = "Phono Input Channel A",
  736. .private_value = _MAKE_NI_CONTROL(0x02, 0x03),
  737. },
  738. {
  739. .name = "Phono Input Channel B",
  740. .private_value = _MAKE_NI_CONTROL(0x02, 0x05),
  741. },
  742. {
  743. .name = "Phono Input Channel C",
  744. .private_value = _MAKE_NI_CONTROL(0x02, 0x07),
  745. },
  746. {
  747. .name = "Phono Input Channel D",
  748. .private_value = _MAKE_NI_CONTROL(0x02, 0x09),
  749. },
  750. };
  751. static int snd_nativeinstruments_create_mixer(struct usb_mixer_interface *mixer,
  752. const struct snd_kcontrol_new *kc,
  753. unsigned int count)
  754. {
  755. int i, err = 0;
  756. struct snd_kcontrol_new template = {
  757. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  758. .access = SNDRV_CTL_ELEM_ACCESS_READWRITE,
  759. .get = snd_nativeinstruments_control_get,
  760. .put = snd_nativeinstruments_control_put,
  761. .info = snd_ctl_boolean_mono_info,
  762. };
  763. for (i = 0; i < count; i++) {
  764. struct usb_mixer_elem_list *list;
  765. template.name = kc[i].name;
  766. template.private_value = kc[i].private_value;
  767. err = add_single_ctl_with_resume(mixer, 0,
  768. snd_ni_update_cur_val,
  769. &template, &list);
  770. if (err < 0)
  771. break;
  772. snd_ni_control_init_val(mixer, list->kctl);
  773. }
  774. return err;
  775. }
  776. /* M-Audio FastTrack Ultra quirks */
  777. /* FTU Effect switch (also used by C400/C600) */
  778. static int snd_ftu_eff_switch_info(struct snd_kcontrol *kcontrol,
  779. struct snd_ctl_elem_info *uinfo)
  780. {
  781. static const char *const texts[8] = {
  782. "Room 1", "Room 2", "Room 3", "Hall 1",
  783. "Hall 2", "Plate", "Delay", "Echo"
  784. };
  785. return snd_ctl_enum_info(uinfo, 1, ARRAY_SIZE(texts), texts);
  786. }
  787. static int snd_ftu_eff_switch_init(struct usb_mixer_interface *mixer,
  788. struct snd_kcontrol *kctl)
  789. {
  790. struct usb_device *dev = mixer->chip->dev;
  791. unsigned int pval = kctl->private_value;
  792. int err;
  793. unsigned char value[2];
  794. value[0] = 0x00;
  795. value[1] = 0x00;
  796. err = snd_usb_ctl_msg(dev, usb_rcvctrlpipe(dev, 0), UAC_GET_CUR,
  797. USB_RECIP_INTERFACE | USB_TYPE_CLASS | USB_DIR_IN,
  798. pval & 0xff00,
  799. snd_usb_ctrl_intf(mixer->chip) | ((pval & 0xff) << 8),
  800. value, 2);
  801. if (err < 0)
  802. return err;
  803. kctl->private_value |= value[0] << 24;
  804. return 0;
  805. }
  806. static int snd_ftu_eff_switch_get(struct snd_kcontrol *kctl,
  807. struct snd_ctl_elem_value *ucontrol)
  808. {
  809. ucontrol->value.enumerated.item[0] = kctl->private_value >> 24;
  810. return 0;
  811. }
  812. static int snd_ftu_eff_switch_update(struct usb_mixer_elem_list *list)
  813. {
  814. struct snd_usb_audio *chip = list->mixer->chip;
  815. unsigned int pval = list->kctl->private_value;
  816. unsigned char value[2];
  817. int err;
  818. value[0] = pval >> 24;
  819. value[1] = 0;
  820. err = snd_usb_lock_shutdown(chip);
  821. if (err < 0)
  822. return err;
  823. err = snd_usb_ctl_msg(chip->dev,
  824. usb_sndctrlpipe(chip->dev, 0),
  825. UAC_SET_CUR,
  826. USB_RECIP_INTERFACE | USB_TYPE_CLASS | USB_DIR_OUT,
  827. pval & 0xff00,
  828. snd_usb_ctrl_intf(chip) | ((pval & 0xff) << 8),
  829. value, 2);
  830. snd_usb_unlock_shutdown(chip);
  831. return err;
  832. }
  833. static int snd_ftu_eff_switch_put(struct snd_kcontrol *kctl,
  834. struct snd_ctl_elem_value *ucontrol)
  835. {
  836. struct usb_mixer_elem_list *list = snd_kcontrol_chip(kctl);
  837. unsigned int pval = list->kctl->private_value;
  838. int cur_val, err, new_val;
  839. cur_val = pval >> 24;
  840. new_val = ucontrol->value.enumerated.item[0];
  841. if (cur_val == new_val)
  842. return 0;
  843. kctl->private_value &= ~(0xff << 24);
  844. kctl->private_value |= new_val << 24;
  845. err = snd_ftu_eff_switch_update(list);
  846. return err < 0 ? err : 1;
  847. }
  848. static int snd_ftu_create_effect_switch(struct usb_mixer_interface *mixer,
  849. int validx, int bUnitID)
  850. {
  851. static struct snd_kcontrol_new template = {
  852. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  853. .name = "Effect Program Switch",
  854. .index = 0,
  855. .access = SNDRV_CTL_ELEM_ACCESS_READWRITE,
  856. .info = snd_ftu_eff_switch_info,
  857. .get = snd_ftu_eff_switch_get,
  858. .put = snd_ftu_eff_switch_put
  859. };
  860. struct usb_mixer_elem_list *list;
  861. int err;
  862. err = add_single_ctl_with_resume(mixer, bUnitID,
  863. snd_ftu_eff_switch_update,
  864. &template, &list);
  865. if (err < 0)
  866. return err;
  867. list->kctl->private_value = (validx << 8) | bUnitID;
  868. snd_ftu_eff_switch_init(mixer, list->kctl);
  869. return 0;
  870. }
  871. /* Create volume controls for FTU devices*/
  872. static int snd_ftu_create_volume_ctls(struct usb_mixer_interface *mixer)
  873. {
  874. char name[64];
  875. unsigned int control, cmask;
  876. int in, out, err;
  877. const unsigned int id = 5;
  878. const int val_type = USB_MIXER_S16;
  879. for (out = 0; out < 8; out++) {
  880. control = out + 1;
  881. for (in = 0; in < 8; in++) {
  882. cmask = 1 << in;
  883. snprintf(name, sizeof(name),
  884. "AIn%d - Out%d Capture Volume",
  885. in + 1, out + 1);
  886. err = snd_create_std_mono_ctl(mixer, id, control,
  887. cmask, val_type, name,
  888. &snd_usb_mixer_vol_tlv);
  889. if (err < 0)
  890. return err;
  891. }
  892. for (in = 8; in < 16; in++) {
  893. cmask = 1 << in;
  894. snprintf(name, sizeof(name),
  895. "DIn%d - Out%d Playback Volume",
  896. in - 7, out + 1);
  897. err = snd_create_std_mono_ctl(mixer, id, control,
  898. cmask, val_type, name,
  899. &snd_usb_mixer_vol_tlv);
  900. if (err < 0)
  901. return err;
  902. }
  903. }
  904. return 0;
  905. }
  906. /* This control needs a volume quirk, see mixer.c */
  907. static int snd_ftu_create_effect_volume_ctl(struct usb_mixer_interface *mixer)
  908. {
  909. static const char name[] = "Effect Volume";
  910. const unsigned int id = 6;
  911. const int val_type = USB_MIXER_U8;
  912. const unsigned int control = 2;
  913. const unsigned int cmask = 0;
  914. return snd_create_std_mono_ctl(mixer, id, control, cmask, val_type,
  915. name, snd_usb_mixer_vol_tlv);
  916. }
  917. /* This control needs a volume quirk, see mixer.c */
  918. static int snd_ftu_create_effect_duration_ctl(struct usb_mixer_interface *mixer)
  919. {
  920. static const char name[] = "Effect Duration";
  921. const unsigned int id = 6;
  922. const int val_type = USB_MIXER_S16;
  923. const unsigned int control = 3;
  924. const unsigned int cmask = 0;
  925. return snd_create_std_mono_ctl(mixer, id, control, cmask, val_type,
  926. name, snd_usb_mixer_vol_tlv);
  927. }
  928. /* This control needs a volume quirk, see mixer.c */
  929. static int snd_ftu_create_effect_feedback_ctl(struct usb_mixer_interface *mixer)
  930. {
  931. static const char name[] = "Effect Feedback Volume";
  932. const unsigned int id = 6;
  933. const int val_type = USB_MIXER_U8;
  934. const unsigned int control = 4;
  935. const unsigned int cmask = 0;
  936. return snd_create_std_mono_ctl(mixer, id, control, cmask, val_type,
  937. name, NULL);
  938. }
  939. static int snd_ftu_create_effect_return_ctls(struct usb_mixer_interface *mixer)
  940. {
  941. unsigned int cmask;
  942. int err, ch;
  943. char name[48];
  944. const unsigned int id = 7;
  945. const int val_type = USB_MIXER_S16;
  946. const unsigned int control = 7;
  947. for (ch = 0; ch < 4; ++ch) {
  948. cmask = 1 << ch;
  949. snprintf(name, sizeof(name),
  950. "Effect Return %d Volume", ch + 1);
  951. err = snd_create_std_mono_ctl(mixer, id, control,
  952. cmask, val_type, name,
  953. snd_usb_mixer_vol_tlv);
  954. if (err < 0)
  955. return err;
  956. }
  957. return 0;
  958. }
  959. static int snd_ftu_create_effect_send_ctls(struct usb_mixer_interface *mixer)
  960. {
  961. unsigned int cmask;
  962. int err, ch;
  963. char name[48];
  964. const unsigned int id = 5;
  965. const int val_type = USB_MIXER_S16;
  966. const unsigned int control = 9;
  967. for (ch = 0; ch < 8; ++ch) {
  968. cmask = 1 << ch;
  969. snprintf(name, sizeof(name),
  970. "Effect Send AIn%d Volume", ch + 1);
  971. err = snd_create_std_mono_ctl(mixer, id, control, cmask,
  972. val_type, name,
  973. snd_usb_mixer_vol_tlv);
  974. if (err < 0)
  975. return err;
  976. }
  977. for (ch = 8; ch < 16; ++ch) {
  978. cmask = 1 << ch;
  979. snprintf(name, sizeof(name),
  980. "Effect Send DIn%d Volume", ch - 7);
  981. err = snd_create_std_mono_ctl(mixer, id, control, cmask,
  982. val_type, name,
  983. snd_usb_mixer_vol_tlv);
  984. if (err < 0)
  985. return err;
  986. }
  987. return 0;
  988. }
  989. static int snd_ftu_create_mixer(struct usb_mixer_interface *mixer)
  990. {
  991. int err;
  992. err = snd_ftu_create_volume_ctls(mixer);
  993. if (err < 0)
  994. return err;
  995. err = snd_ftu_create_effect_switch(mixer, 1, 6);
  996. if (err < 0)
  997. return err;
  998. err = snd_ftu_create_effect_volume_ctl(mixer);
  999. if (err < 0)
  1000. return err;
  1001. err = snd_ftu_create_effect_duration_ctl(mixer);
  1002. if (err < 0)
  1003. return err;
  1004. err = snd_ftu_create_effect_feedback_ctl(mixer);
  1005. if (err < 0)
  1006. return err;
  1007. err = snd_ftu_create_effect_return_ctls(mixer);
  1008. if (err < 0)
  1009. return err;
  1010. err = snd_ftu_create_effect_send_ctls(mixer);
  1011. if (err < 0)
  1012. return err;
  1013. return 0;
  1014. }
  1015. void snd_emuusb_set_samplerate(struct snd_usb_audio *chip,
  1016. unsigned char samplerate_id)
  1017. {
  1018. struct usb_mixer_interface *mixer;
  1019. struct usb_mixer_elem_info *cval;
  1020. int unitid = 12; /* SamleRate ExtensionUnit ID */
  1021. list_for_each_entry(mixer, &chip->mixer_list, list) {
  1022. cval = (struct usb_mixer_elem_info *)mixer->id_elems[unitid];
  1023. if (cval) {
  1024. snd_usb_mixer_set_ctl_value(cval, UAC_SET_CUR,
  1025. cval->control << 8,
  1026. samplerate_id);
  1027. snd_usb_mixer_notify_id(mixer, unitid);
  1028. }
  1029. break;
  1030. }
  1031. }
  1032. /* M-Audio Fast Track C400/C600 */
  1033. /* C400/C600 volume controls, this control needs a volume quirk, see mixer.c */
  1034. static int snd_c400_create_vol_ctls(struct usb_mixer_interface *mixer)
  1035. {
  1036. char name[64];
  1037. unsigned int cmask, offset;
  1038. int out, chan, err;
  1039. int num_outs = 0;
  1040. int num_ins = 0;
  1041. const unsigned int id = 0x40;
  1042. const int val_type = USB_MIXER_S16;
  1043. const int control = 1;
  1044. switch (mixer->chip->usb_id) {
  1045. case USB_ID(0x0763, 0x2030):
  1046. num_outs = 6;
  1047. num_ins = 4;
  1048. break;
  1049. case USB_ID(0x0763, 0x2031):
  1050. num_outs = 8;
  1051. num_ins = 6;
  1052. break;
  1053. }
  1054. for (chan = 0; chan < num_outs + num_ins; chan++) {
  1055. for (out = 0; out < num_outs; out++) {
  1056. if (chan < num_outs) {
  1057. snprintf(name, sizeof(name),
  1058. "PCM%d-Out%d Playback Volume",
  1059. chan + 1, out + 1);
  1060. } else {
  1061. snprintf(name, sizeof(name),
  1062. "In%d-Out%d Playback Volume",
  1063. chan - num_outs + 1, out + 1);
  1064. }
  1065. cmask = (out == 0) ? 0 : 1 << (out - 1);
  1066. offset = chan * num_outs;
  1067. err = snd_create_std_mono_ctl_offset(mixer, id, control,
  1068. cmask, val_type, offset, name,
  1069. &snd_usb_mixer_vol_tlv);
  1070. if (err < 0)
  1071. return err;
  1072. }
  1073. }
  1074. return 0;
  1075. }
  1076. /* This control needs a volume quirk, see mixer.c */
  1077. static int snd_c400_create_effect_volume_ctl(struct usb_mixer_interface *mixer)
  1078. {
  1079. static const char name[] = "Effect Volume";
  1080. const unsigned int id = 0x43;
  1081. const int val_type = USB_MIXER_U8;
  1082. const unsigned int control = 3;
  1083. const unsigned int cmask = 0;
  1084. return snd_create_std_mono_ctl(mixer, id, control, cmask, val_type,
  1085. name, snd_usb_mixer_vol_tlv);
  1086. }
  1087. /* This control needs a volume quirk, see mixer.c */
  1088. static int snd_c400_create_effect_duration_ctl(struct usb_mixer_interface *mixer)
  1089. {
  1090. static const char name[] = "Effect Duration";
  1091. const unsigned int id = 0x43;
  1092. const int val_type = USB_MIXER_S16;
  1093. const unsigned int control = 4;
  1094. const unsigned int cmask = 0;
  1095. return snd_create_std_mono_ctl(mixer, id, control, cmask, val_type,
  1096. name, snd_usb_mixer_vol_tlv);
  1097. }
  1098. /* This control needs a volume quirk, see mixer.c */
  1099. static int snd_c400_create_effect_feedback_ctl(struct usb_mixer_interface *mixer)
  1100. {
  1101. static const char name[] = "Effect Feedback Volume";
  1102. const unsigned int id = 0x43;
  1103. const int val_type = USB_MIXER_U8;
  1104. const unsigned int control = 5;
  1105. const unsigned int cmask = 0;
  1106. return snd_create_std_mono_ctl(mixer, id, control, cmask, val_type,
  1107. name, NULL);
  1108. }
  1109. static int snd_c400_create_effect_vol_ctls(struct usb_mixer_interface *mixer)
  1110. {
  1111. char name[64];
  1112. unsigned int cmask;
  1113. int chan, err;
  1114. int num_outs = 0;
  1115. int num_ins = 0;
  1116. const unsigned int id = 0x42;
  1117. const int val_type = USB_MIXER_S16;
  1118. const int control = 1;
  1119. switch (mixer->chip->usb_id) {
  1120. case USB_ID(0x0763, 0x2030):
  1121. num_outs = 6;
  1122. num_ins = 4;
  1123. break;
  1124. case USB_ID(0x0763, 0x2031):
  1125. num_outs = 8;
  1126. num_ins = 6;
  1127. break;
  1128. }
  1129. for (chan = 0; chan < num_outs + num_ins; chan++) {
  1130. if (chan < num_outs) {
  1131. snprintf(name, sizeof(name),
  1132. "Effect Send DOut%d",
  1133. chan + 1);
  1134. } else {
  1135. snprintf(name, sizeof(name),
  1136. "Effect Send AIn%d",
  1137. chan - num_outs + 1);
  1138. }
  1139. cmask = (chan == 0) ? 0 : 1 << (chan - 1);
  1140. err = snd_create_std_mono_ctl(mixer, id, control,
  1141. cmask, val_type, name,
  1142. &snd_usb_mixer_vol_tlv);
  1143. if (err < 0)
  1144. return err;
  1145. }
  1146. return 0;
  1147. }
  1148. static int snd_c400_create_effect_ret_vol_ctls(struct usb_mixer_interface *mixer)
  1149. {
  1150. char name[64];
  1151. unsigned int cmask;
  1152. int chan, err;
  1153. int num_outs = 0;
  1154. int offset = 0;
  1155. const unsigned int id = 0x40;
  1156. const int val_type = USB_MIXER_S16;
  1157. const int control = 1;
  1158. switch (mixer->chip->usb_id) {
  1159. case USB_ID(0x0763, 0x2030):
  1160. num_outs = 6;
  1161. offset = 0x3c;
  1162. /* { 0x3c, 0x43, 0x3e, 0x45, 0x40, 0x47 } */
  1163. break;
  1164. case USB_ID(0x0763, 0x2031):
  1165. num_outs = 8;
  1166. offset = 0x70;
  1167. /* { 0x70, 0x79, 0x72, 0x7b, 0x74, 0x7d, 0x76, 0x7f } */
  1168. break;
  1169. }
  1170. for (chan = 0; chan < num_outs; chan++) {
  1171. snprintf(name, sizeof(name),
  1172. "Effect Return %d",
  1173. chan + 1);
  1174. cmask = (chan == 0) ? 0 :
  1175. 1 << (chan + (chan % 2) * num_outs - 1);
  1176. err = snd_create_std_mono_ctl_offset(mixer, id, control,
  1177. cmask, val_type, offset, name,
  1178. &snd_usb_mixer_vol_tlv);
  1179. if (err < 0)
  1180. return err;
  1181. }
  1182. return 0;
  1183. }
  1184. static int snd_c400_create_mixer(struct usb_mixer_interface *mixer)
  1185. {
  1186. int err;
  1187. err = snd_c400_create_vol_ctls(mixer);
  1188. if (err < 0)
  1189. return err;
  1190. err = snd_c400_create_effect_vol_ctls(mixer);
  1191. if (err < 0)
  1192. return err;
  1193. err = snd_c400_create_effect_ret_vol_ctls(mixer);
  1194. if (err < 0)
  1195. return err;
  1196. err = snd_ftu_create_effect_switch(mixer, 2, 0x43);
  1197. if (err < 0)
  1198. return err;
  1199. err = snd_c400_create_effect_volume_ctl(mixer);
  1200. if (err < 0)
  1201. return err;
  1202. err = snd_c400_create_effect_duration_ctl(mixer);
  1203. if (err < 0)
  1204. return err;
  1205. err = snd_c400_create_effect_feedback_ctl(mixer);
  1206. if (err < 0)
  1207. return err;
  1208. return 0;
  1209. }
  1210. /*
  1211. * The mixer units for Ebox-44 are corrupt, and even where they
  1212. * are valid they presents mono controls as L and R channels of
  1213. * stereo. So we provide a good mixer here.
  1214. */
  1215. static struct std_mono_table ebox44_table[] = {
  1216. {
  1217. .unitid = 4,
  1218. .control = 1,
  1219. .cmask = 0x0,
  1220. .val_type = USB_MIXER_INV_BOOLEAN,
  1221. .name = "Headphone Playback Switch"
  1222. },
  1223. {
  1224. .unitid = 4,
  1225. .control = 2,
  1226. .cmask = 0x1,
  1227. .val_type = USB_MIXER_S16,
  1228. .name = "Headphone A Mix Playback Volume"
  1229. },
  1230. {
  1231. .unitid = 4,
  1232. .control = 2,
  1233. .cmask = 0x2,
  1234. .val_type = USB_MIXER_S16,
  1235. .name = "Headphone B Mix Playback Volume"
  1236. },
  1237. {
  1238. .unitid = 7,
  1239. .control = 1,
  1240. .cmask = 0x0,
  1241. .val_type = USB_MIXER_INV_BOOLEAN,
  1242. .name = "Output Playback Switch"
  1243. },
  1244. {
  1245. .unitid = 7,
  1246. .control = 2,
  1247. .cmask = 0x1,
  1248. .val_type = USB_MIXER_S16,
  1249. .name = "Output A Playback Volume"
  1250. },
  1251. {
  1252. .unitid = 7,
  1253. .control = 2,
  1254. .cmask = 0x2,
  1255. .val_type = USB_MIXER_S16,
  1256. .name = "Output B Playback Volume"
  1257. },
  1258. {
  1259. .unitid = 10,
  1260. .control = 1,
  1261. .cmask = 0x0,
  1262. .val_type = USB_MIXER_INV_BOOLEAN,
  1263. .name = "Input Capture Switch"
  1264. },
  1265. {
  1266. .unitid = 10,
  1267. .control = 2,
  1268. .cmask = 0x1,
  1269. .val_type = USB_MIXER_S16,
  1270. .name = "Input A Capture Volume"
  1271. },
  1272. {
  1273. .unitid = 10,
  1274. .control = 2,
  1275. .cmask = 0x2,
  1276. .val_type = USB_MIXER_S16,
  1277. .name = "Input B Capture Volume"
  1278. },
  1279. {}
  1280. };
  1281. /* Audio Advantage Micro II findings:
  1282. *
  1283. * Mapping spdif AES bits to vendor register.bit:
  1284. * AES0: [0 0 0 0 2.3 2.2 2.1 2.0] - default 0x00
  1285. * AES1: [3.3 3.2.3.1.3.0 2.7 2.6 2.5 2.4] - default: 0x01
  1286. * AES2: [0 0 0 0 0 0 0 0]
  1287. * AES3: [0 0 0 0 0 0 x 0] - 'x' bit is set basing on standard usb request
  1288. * (UAC_EP_CS_ATTR_SAMPLE_RATE) for Audio Devices
  1289. *
  1290. * power on values:
  1291. * r2: 0x10
  1292. * r3: 0x20 (b7 is zeroed just before playback (except IEC61937) and set
  1293. * just after it to 0xa0, presumably it disables/mutes some analog
  1294. * parts when there is no audio.)
  1295. * r9: 0x28
  1296. *
  1297. * Optical transmitter on/off:
  1298. * vendor register.bit: 9.1
  1299. * 0 - on (0x28 register value)
  1300. * 1 - off (0x2a register value)
  1301. *
  1302. */
  1303. static int snd_microii_spdif_info(struct snd_kcontrol *kcontrol,
  1304. struct snd_ctl_elem_info *uinfo)
  1305. {
  1306. uinfo->type = SNDRV_CTL_ELEM_TYPE_IEC958;
  1307. uinfo->count = 1;
  1308. return 0;
  1309. }
  1310. static int snd_microii_spdif_default_get(struct snd_kcontrol *kcontrol,
  1311. struct snd_ctl_elem_value *ucontrol)
  1312. {
  1313. struct usb_mixer_elem_list *list = snd_kcontrol_chip(kcontrol);
  1314. struct snd_usb_audio *chip = list->mixer->chip;
  1315. int err;
  1316. struct usb_interface *iface;
  1317. struct usb_host_interface *alts;
  1318. unsigned int ep;
  1319. unsigned char data[3];
  1320. int rate;
  1321. err = snd_usb_lock_shutdown(chip);
  1322. if (err < 0)
  1323. return err;
  1324. ucontrol->value.iec958.status[0] = kcontrol->private_value & 0xff;
  1325. ucontrol->value.iec958.status[1] = (kcontrol->private_value >> 8) & 0xff;
  1326. ucontrol->value.iec958.status[2] = 0x00;
  1327. /* use known values for that card: interface#1 altsetting#1 */
  1328. iface = usb_ifnum_to_if(chip->dev, 1);
  1329. alts = &iface->altsetting[1];
  1330. ep = get_endpoint(alts, 0)->bEndpointAddress;
  1331. err = snd_usb_ctl_msg(chip->dev,
  1332. usb_rcvctrlpipe(chip->dev, 0),
  1333. UAC_GET_CUR,
  1334. USB_TYPE_CLASS | USB_RECIP_ENDPOINT | USB_DIR_IN,
  1335. UAC_EP_CS_ATTR_SAMPLE_RATE << 8,
  1336. ep,
  1337. data,
  1338. sizeof(data));
  1339. if (err < 0)
  1340. goto end;
  1341. rate = data[0] | (data[1] << 8) | (data[2] << 16);
  1342. ucontrol->value.iec958.status[3] = (rate == 48000) ?
  1343. IEC958_AES3_CON_FS_48000 : IEC958_AES3_CON_FS_44100;
  1344. err = 0;
  1345. end:
  1346. snd_usb_unlock_shutdown(chip);
  1347. return err;
  1348. }
  1349. static int snd_microii_spdif_default_update(struct usb_mixer_elem_list *list)
  1350. {
  1351. struct snd_usb_audio *chip = list->mixer->chip;
  1352. unsigned int pval = list->kctl->private_value;
  1353. u8 reg;
  1354. int err;
  1355. err = snd_usb_lock_shutdown(chip);
  1356. if (err < 0)
  1357. return err;
  1358. reg = ((pval >> 4) & 0xf0) | (pval & 0x0f);
  1359. err = snd_usb_ctl_msg(chip->dev,
  1360. usb_sndctrlpipe(chip->dev, 0),
  1361. UAC_SET_CUR,
  1362. USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_OTHER,
  1363. reg,
  1364. 2,
  1365. NULL,
  1366. 0);
  1367. if (err < 0)
  1368. goto end;
  1369. reg = (pval & IEC958_AES0_NONAUDIO) ? 0xa0 : 0x20;
  1370. reg |= (pval >> 12) & 0x0f;
  1371. err = snd_usb_ctl_msg(chip->dev,
  1372. usb_sndctrlpipe(chip->dev, 0),
  1373. UAC_SET_CUR,
  1374. USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_OTHER,
  1375. reg,
  1376. 3,
  1377. NULL,
  1378. 0);
  1379. if (err < 0)
  1380. goto end;
  1381. end:
  1382. snd_usb_unlock_shutdown(chip);
  1383. return err;
  1384. }
  1385. static int snd_microii_spdif_default_put(struct snd_kcontrol *kcontrol,
  1386. struct snd_ctl_elem_value *ucontrol)
  1387. {
  1388. struct usb_mixer_elem_list *list = snd_kcontrol_chip(kcontrol);
  1389. unsigned int pval, pval_old;
  1390. int err;
  1391. pval = pval_old = kcontrol->private_value;
  1392. pval &= 0xfffff0f0;
  1393. pval |= (ucontrol->value.iec958.status[1] & 0x0f) << 8;
  1394. pval |= (ucontrol->value.iec958.status[0] & 0x0f);
  1395. pval &= 0xffff0fff;
  1396. pval |= (ucontrol->value.iec958.status[1] & 0xf0) << 8;
  1397. /* The frequency bits in AES3 cannot be set via register access. */
  1398. /* Silently ignore any bits from the request that cannot be set. */
  1399. if (pval == pval_old)
  1400. return 0;
  1401. kcontrol->private_value = pval;
  1402. err = snd_microii_spdif_default_update(list);
  1403. return err < 0 ? err : 1;
  1404. }
  1405. static int snd_microii_spdif_mask_get(struct snd_kcontrol *kcontrol,
  1406. struct snd_ctl_elem_value *ucontrol)
  1407. {
  1408. ucontrol->value.iec958.status[0] = 0x0f;
  1409. ucontrol->value.iec958.status[1] = 0xff;
  1410. ucontrol->value.iec958.status[2] = 0x00;
  1411. ucontrol->value.iec958.status[3] = 0x00;
  1412. return 0;
  1413. }
  1414. static int snd_microii_spdif_switch_get(struct snd_kcontrol *kcontrol,
  1415. struct snd_ctl_elem_value *ucontrol)
  1416. {
  1417. ucontrol->value.integer.value[0] = !(kcontrol->private_value & 0x02);
  1418. return 0;
  1419. }
  1420. static int snd_microii_spdif_switch_update(struct usb_mixer_elem_list *list)
  1421. {
  1422. struct snd_usb_audio *chip = list->mixer->chip;
  1423. u8 reg = list->kctl->private_value;
  1424. int err;
  1425. err = snd_usb_lock_shutdown(chip);
  1426. if (err < 0)
  1427. return err;
  1428. err = snd_usb_ctl_msg(chip->dev,
  1429. usb_sndctrlpipe(chip->dev, 0),
  1430. UAC_SET_CUR,
  1431. USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_OTHER,
  1432. reg,
  1433. 9,
  1434. NULL,
  1435. 0);
  1436. snd_usb_unlock_shutdown(chip);
  1437. return err;
  1438. }
  1439. static int snd_microii_spdif_switch_put(struct snd_kcontrol *kcontrol,
  1440. struct snd_ctl_elem_value *ucontrol)
  1441. {
  1442. struct usb_mixer_elem_list *list = snd_kcontrol_chip(kcontrol);
  1443. u8 reg;
  1444. int err;
  1445. reg = ucontrol->value.integer.value[0] ? 0x28 : 0x2a;
  1446. if (reg != list->kctl->private_value)
  1447. return 0;
  1448. kcontrol->private_value = reg;
  1449. err = snd_microii_spdif_switch_update(list);
  1450. return err < 0 ? err : 1;
  1451. }
  1452. static struct snd_kcontrol_new snd_microii_mixer_spdif[] = {
  1453. {
  1454. .iface = SNDRV_CTL_ELEM_IFACE_PCM,
  1455. .name = SNDRV_CTL_NAME_IEC958("", PLAYBACK, DEFAULT),
  1456. .info = snd_microii_spdif_info,
  1457. .get = snd_microii_spdif_default_get,
  1458. .put = snd_microii_spdif_default_put,
  1459. .private_value = 0x00000100UL,/* reset value */
  1460. },
  1461. {
  1462. .access = SNDRV_CTL_ELEM_ACCESS_READ,
  1463. .iface = SNDRV_CTL_ELEM_IFACE_PCM,
  1464. .name = SNDRV_CTL_NAME_IEC958("", PLAYBACK, MASK),
  1465. .info = snd_microii_spdif_info,
  1466. .get = snd_microii_spdif_mask_get,
  1467. },
  1468. {
  1469. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  1470. .name = SNDRV_CTL_NAME_IEC958("", PLAYBACK, SWITCH),
  1471. .info = snd_ctl_boolean_mono_info,
  1472. .get = snd_microii_spdif_switch_get,
  1473. .put = snd_microii_spdif_switch_put,
  1474. .private_value = 0x00000028UL,/* reset value */
  1475. }
  1476. };
  1477. static int snd_microii_controls_create(struct usb_mixer_interface *mixer)
  1478. {
  1479. int err, i;
  1480. static usb_mixer_elem_resume_func_t resume_funcs[] = {
  1481. snd_microii_spdif_default_update,
  1482. NULL,
  1483. snd_microii_spdif_switch_update
  1484. };
  1485. for (i = 0; i < ARRAY_SIZE(snd_microii_mixer_spdif); ++i) {
  1486. err = add_single_ctl_with_resume(mixer, 0,
  1487. resume_funcs[i],
  1488. &snd_microii_mixer_spdif[i],
  1489. NULL);
  1490. if (err < 0)
  1491. return err;
  1492. }
  1493. return 0;
  1494. }
  1495. int snd_usb_mixer_apply_create_quirk(struct usb_mixer_interface *mixer)
  1496. {
  1497. int err = 0;
  1498. struct snd_info_entry *entry;
  1499. if ((err = snd_usb_soundblaster_remote_init(mixer)) < 0)
  1500. return err;
  1501. switch (mixer->chip->usb_id) {
  1502. case USB_ID(0x041e, 0x3020):
  1503. case USB_ID(0x041e, 0x3040):
  1504. case USB_ID(0x041e, 0x3042):
  1505. case USB_ID(0x041e, 0x30df):
  1506. case USB_ID(0x041e, 0x3048):
  1507. err = snd_audigy2nx_controls_create(mixer);
  1508. if (err < 0)
  1509. break;
  1510. if (!snd_card_proc_new(mixer->chip->card, "audigy2nx", &entry))
  1511. snd_info_set_text_ops(entry, mixer,
  1512. snd_audigy2nx_proc_read);
  1513. break;
  1514. /* EMU0204 */
  1515. case USB_ID(0x041e, 0x3f19):
  1516. err = snd_emu0204_controls_create(mixer);
  1517. if (err < 0)
  1518. break;
  1519. break;
  1520. case USB_ID(0x0763, 0x2030): /* M-Audio Fast Track C400 */
  1521. case USB_ID(0x0763, 0x2031): /* M-Audio Fast Track C400 */
  1522. err = snd_c400_create_mixer(mixer);
  1523. break;
  1524. case USB_ID(0x0763, 0x2080): /* M-Audio Fast Track Ultra */
  1525. case USB_ID(0x0763, 0x2081): /* M-Audio Fast Track Ultra 8R */
  1526. err = snd_ftu_create_mixer(mixer);
  1527. break;
  1528. case USB_ID(0x0b05, 0x1739): /* ASUS Xonar U1 */
  1529. case USB_ID(0x0b05, 0x1743): /* ASUS Xonar U1 (2) */
  1530. case USB_ID(0x0b05, 0x17a0): /* ASUS Xonar U3 */
  1531. err = snd_xonar_u1_controls_create(mixer);
  1532. break;
  1533. case USB_ID(0x0d8c, 0x0103): /* Audio Advantage Micro II */
  1534. err = snd_microii_controls_create(mixer);
  1535. break;
  1536. case USB_ID(0x0dba, 0x1000): /* Digidesign Mbox 1 */
  1537. err = snd_mbox1_create_sync_switch(mixer);
  1538. break;
  1539. case USB_ID(0x17cc, 0x1011): /* Traktor Audio 6 */
  1540. err = snd_nativeinstruments_create_mixer(mixer,
  1541. snd_nativeinstruments_ta6_mixers,
  1542. ARRAY_SIZE(snd_nativeinstruments_ta6_mixers));
  1543. break;
  1544. case USB_ID(0x17cc, 0x1021): /* Traktor Audio 10 */
  1545. err = snd_nativeinstruments_create_mixer(mixer,
  1546. snd_nativeinstruments_ta10_mixers,
  1547. ARRAY_SIZE(snd_nativeinstruments_ta10_mixers));
  1548. break;
  1549. case USB_ID(0x200c, 0x1018): /* Electrix Ebox-44 */
  1550. /* detection is disabled in mixer_maps.c */
  1551. err = snd_create_std_mono_table(mixer, ebox44_table);
  1552. break;
  1553. case USB_ID(0x1235, 0x8012): /* Focusrite Scarlett 6i6 */
  1554. case USB_ID(0x1235, 0x8002): /* Focusrite Scarlett 8i6 */
  1555. case USB_ID(0x1235, 0x8004): /* Focusrite Scarlett 18i6 */
  1556. case USB_ID(0x1235, 0x8014): /* Focusrite Scarlett 18i8 */
  1557. case USB_ID(0x1235, 0x800c): /* Focusrite Scarlett 18i20 */
  1558. err = snd_scarlett_controls_create(mixer);
  1559. break;
  1560. }
  1561. return err;
  1562. }
  1563. void snd_usb_mixer_rc_memory_change(struct usb_mixer_interface *mixer,
  1564. int unitid)
  1565. {
  1566. if (!mixer->rc_cfg)
  1567. return;
  1568. /* unit ids specific to Extigy/Audigy 2 NX: */
  1569. switch (unitid) {
  1570. case 0: /* remote control */
  1571. mixer->rc_urb->dev = mixer->chip->dev;
  1572. usb_submit_urb(mixer->rc_urb, GFP_ATOMIC);
  1573. break;
  1574. case 4: /* digital in jack */
  1575. case 7: /* line in jacks */
  1576. case 19: /* speaker out jacks */
  1577. case 20: /* headphones out jack */
  1578. break;
  1579. /* live24ext: 4 = line-in jack */
  1580. case 3: /* hp-out jack (may actuate Mute) */
  1581. if (mixer->chip->usb_id == USB_ID(0x041e, 0x3040) ||
  1582. mixer->chip->usb_id == USB_ID(0x041e, 0x3048))
  1583. snd_usb_mixer_notify_id(mixer, mixer->rc_cfg->mute_mixer_id);
  1584. break;
  1585. default:
  1586. usb_audio_dbg(mixer->chip, "memory change in unknown unit %d\n", unitid);
  1587. break;
  1588. }
  1589. }