mixer_quirks.c 47 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846
  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. down_read(&chip->shutdown_rwsem);
  276. if (chip->shutdown) {
  277. err = -ENODEV;
  278. goto out;
  279. }
  280. if (chip->usb_id == USB_ID(0x041e, 0x3042))
  281. err = snd_usb_ctl_msg(chip->dev,
  282. usb_sndctrlpipe(chip->dev, 0), 0x24,
  283. USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_OTHER,
  284. !value, 0, NULL, 0);
  285. /* USB X-Fi S51 Pro */
  286. if (chip->usb_id == USB_ID(0x041e, 0x30df))
  287. err = snd_usb_ctl_msg(chip->dev,
  288. usb_sndctrlpipe(chip->dev, 0), 0x24,
  289. USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_OTHER,
  290. !value, 0, NULL, 0);
  291. else
  292. err = snd_usb_ctl_msg(chip->dev,
  293. usb_sndctrlpipe(chip->dev, 0), 0x24,
  294. USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_OTHER,
  295. value, index + 2, NULL, 0);
  296. out:
  297. up_read(&chip->shutdown_rwsem);
  298. return err;
  299. }
  300. static int snd_audigy2nx_led_put(struct snd_kcontrol *kcontrol,
  301. struct snd_ctl_elem_value *ucontrol)
  302. {
  303. struct usb_mixer_elem_list *list = snd_kcontrol_chip(kcontrol);
  304. struct usb_mixer_interface *mixer = list->mixer;
  305. int index = kcontrol->private_value & 0xff;
  306. int value = ucontrol->value.integer.value[0];
  307. int old_value = kcontrol->private_value >> 8;
  308. int err;
  309. if (value > 1)
  310. return -EINVAL;
  311. if (value == old_value)
  312. return 0;
  313. kcontrol->private_value = (value << 8) | index;
  314. err = snd_audigy2nx_led_update(mixer, value, index);
  315. return err < 0 ? err : 1;
  316. }
  317. static int snd_audigy2nx_led_resume(struct usb_mixer_elem_list *list)
  318. {
  319. int priv_value = list->kctl->private_value;
  320. return snd_audigy2nx_led_update(list->mixer, priv_value >> 8,
  321. priv_value & 0xff);
  322. }
  323. /* name and private_value are set dynamically */
  324. static struct snd_kcontrol_new snd_audigy2nx_control = {
  325. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  326. .info = snd_audigy2nx_led_info,
  327. .get = snd_audigy2nx_led_get,
  328. .put = snd_audigy2nx_led_put,
  329. };
  330. static const char * const snd_audigy2nx_led_names[] = {
  331. "CMSS LED Switch",
  332. "Power LED Switch",
  333. "Dolby Digital LED Switch",
  334. };
  335. static int snd_audigy2nx_controls_create(struct usb_mixer_interface *mixer)
  336. {
  337. int i, err;
  338. for (i = 0; i < ARRAY_SIZE(snd_audigy2nx_led_names); ++i) {
  339. struct snd_kcontrol_new knew;
  340. /* USB X-Fi S51 doesn't have a CMSS LED */
  341. if ((mixer->chip->usb_id == USB_ID(0x041e, 0x3042)) && i == 0)
  342. continue;
  343. /* USB X-Fi S51 Pro doesn't have one either */
  344. if ((mixer->chip->usb_id == USB_ID(0x041e, 0x30df)) && i == 0)
  345. continue;
  346. if (i > 1 && /* Live24ext has 2 LEDs only */
  347. (mixer->chip->usb_id == USB_ID(0x041e, 0x3040) ||
  348. mixer->chip->usb_id == USB_ID(0x041e, 0x3042) ||
  349. mixer->chip->usb_id == USB_ID(0x041e, 0x30df) ||
  350. mixer->chip->usb_id == USB_ID(0x041e, 0x3048)))
  351. break;
  352. knew = snd_audigy2nx_control;
  353. knew.name = snd_audigy2nx_led_names[i];
  354. knew.private_value = (1 << 8) | i; /* LED on as default */
  355. err = add_single_ctl_with_resume(mixer, 0,
  356. snd_audigy2nx_led_resume,
  357. &knew, NULL);
  358. if (err < 0)
  359. return err;
  360. }
  361. return 0;
  362. }
  363. static void snd_audigy2nx_proc_read(struct snd_info_entry *entry,
  364. struct snd_info_buffer *buffer)
  365. {
  366. static const struct sb_jack {
  367. int unitid;
  368. const char *name;
  369. } jacks_audigy2nx[] = {
  370. {4, "dig in "},
  371. {7, "line in"},
  372. {19, "spk out"},
  373. {20, "hph out"},
  374. {-1, NULL}
  375. }, jacks_live24ext[] = {
  376. {4, "line in"}, /* &1=Line, &2=Mic*/
  377. {3, "hph out"}, /* headphones */
  378. {0, "RC "}, /* last command, 6 bytes see rc_config above */
  379. {-1, NULL}
  380. };
  381. const struct sb_jack *jacks;
  382. struct usb_mixer_interface *mixer = entry->private_data;
  383. int i, err;
  384. u8 buf[3];
  385. snd_iprintf(buffer, "%s jacks\n\n", mixer->chip->card->shortname);
  386. if (mixer->chip->usb_id == USB_ID(0x041e, 0x3020))
  387. jacks = jacks_audigy2nx;
  388. else if (mixer->chip->usb_id == USB_ID(0x041e, 0x3040) ||
  389. mixer->chip->usb_id == USB_ID(0x041e, 0x3048))
  390. jacks = jacks_live24ext;
  391. else
  392. return;
  393. for (i = 0; jacks[i].name; ++i) {
  394. snd_iprintf(buffer, "%s: ", jacks[i].name);
  395. down_read(&mixer->chip->shutdown_rwsem);
  396. if (mixer->chip->shutdown)
  397. err = 0;
  398. else
  399. err = snd_usb_ctl_msg(mixer->chip->dev,
  400. usb_rcvctrlpipe(mixer->chip->dev, 0),
  401. UAC_GET_MEM, USB_DIR_IN | USB_TYPE_CLASS |
  402. USB_RECIP_INTERFACE, 0,
  403. jacks[i].unitid << 8, buf, 3);
  404. up_read(&mixer->chip->shutdown_rwsem);
  405. if (err == 3 && (buf[0] == 3 || buf[0] == 6))
  406. snd_iprintf(buffer, "%02x %02x\n", buf[1], buf[2]);
  407. else
  408. snd_iprintf(buffer, "?\n");
  409. }
  410. }
  411. /* EMU0204 */
  412. static int snd_emu0204_ch_switch_info(struct snd_kcontrol *kcontrol,
  413. struct snd_ctl_elem_info *uinfo)
  414. {
  415. static const char * const texts[2] = {"1/2", "3/4"};
  416. return snd_ctl_enum_info(uinfo, 1, ARRAY_SIZE(texts), texts);
  417. }
  418. static int snd_emu0204_ch_switch_get(struct snd_kcontrol *kcontrol,
  419. struct snd_ctl_elem_value *ucontrol)
  420. {
  421. ucontrol->value.enumerated.item[0] = kcontrol->private_value;
  422. return 0;
  423. }
  424. static int snd_emu0204_ch_switch_update(struct usb_mixer_interface *mixer,
  425. int value)
  426. {
  427. struct snd_usb_audio *chip = mixer->chip;
  428. int err;
  429. unsigned char buf[2];
  430. down_read(&chip->shutdown_rwsem);
  431. if (mixer->chip->shutdown) {
  432. err = -ENODEV;
  433. goto out;
  434. }
  435. buf[0] = 0x01;
  436. buf[1] = value ? 0x02 : 0x01;
  437. err = snd_usb_ctl_msg(chip->dev,
  438. usb_sndctrlpipe(chip->dev, 0), UAC_SET_CUR,
  439. USB_RECIP_INTERFACE | USB_TYPE_CLASS | USB_DIR_OUT,
  440. 0x0400, 0x0e00, buf, 2);
  441. out:
  442. up_read(&chip->shutdown_rwsem);
  443. return err;
  444. }
  445. static int snd_emu0204_ch_switch_put(struct snd_kcontrol *kcontrol,
  446. struct snd_ctl_elem_value *ucontrol)
  447. {
  448. struct usb_mixer_elem_list *list = snd_kcontrol_chip(kcontrol);
  449. struct usb_mixer_interface *mixer = list->mixer;
  450. unsigned int value = ucontrol->value.enumerated.item[0];
  451. int err;
  452. if (value > 1)
  453. return -EINVAL;
  454. if (value == kcontrol->private_value)
  455. return 0;
  456. kcontrol->private_value = value;
  457. err = snd_emu0204_ch_switch_update(mixer, value);
  458. return err < 0 ? err : 1;
  459. }
  460. static int snd_emu0204_ch_switch_resume(struct usb_mixer_elem_list *list)
  461. {
  462. return snd_emu0204_ch_switch_update(list->mixer,
  463. list->kctl->private_value);
  464. }
  465. static struct snd_kcontrol_new snd_emu0204_control = {
  466. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  467. .name = "Front Jack Channels",
  468. .info = snd_emu0204_ch_switch_info,
  469. .get = snd_emu0204_ch_switch_get,
  470. .put = snd_emu0204_ch_switch_put,
  471. .private_value = 0,
  472. };
  473. static int snd_emu0204_controls_create(struct usb_mixer_interface *mixer)
  474. {
  475. return add_single_ctl_with_resume(mixer, 0,
  476. snd_emu0204_ch_switch_resume,
  477. &snd_emu0204_control, NULL);
  478. }
  479. /* ASUS Xonar U1 / U3 controls */
  480. static int snd_xonar_u1_switch_get(struct snd_kcontrol *kcontrol,
  481. struct snd_ctl_elem_value *ucontrol)
  482. {
  483. ucontrol->value.integer.value[0] = !!(kcontrol->private_value & 0x02);
  484. return 0;
  485. }
  486. static int snd_xonar_u1_switch_update(struct usb_mixer_interface *mixer,
  487. unsigned char status)
  488. {
  489. struct snd_usb_audio *chip = mixer->chip;
  490. int err;
  491. down_read(&chip->shutdown_rwsem);
  492. if (chip->shutdown)
  493. err = -ENODEV;
  494. else
  495. err = snd_usb_ctl_msg(chip->dev,
  496. usb_sndctrlpipe(chip->dev, 0), 0x08,
  497. USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_OTHER,
  498. 50, 0, &status, 1);
  499. up_read(&chip->shutdown_rwsem);
  500. return err;
  501. }
  502. static int snd_xonar_u1_switch_put(struct snd_kcontrol *kcontrol,
  503. struct snd_ctl_elem_value *ucontrol)
  504. {
  505. struct usb_mixer_elem_list *list = snd_kcontrol_chip(kcontrol);
  506. u8 old_status, new_status;
  507. int err;
  508. old_status = kcontrol->private_value;
  509. if (ucontrol->value.integer.value[0])
  510. new_status = old_status | 0x02;
  511. else
  512. new_status = old_status & ~0x02;
  513. if (new_status == old_status)
  514. return 0;
  515. kcontrol->private_value = new_status;
  516. err = snd_xonar_u1_switch_update(list->mixer, new_status);
  517. return err < 0 ? err : 1;
  518. }
  519. static int snd_xonar_u1_switch_resume(struct usb_mixer_elem_list *list)
  520. {
  521. return snd_xonar_u1_switch_update(list->mixer,
  522. list->kctl->private_value);
  523. }
  524. static struct snd_kcontrol_new snd_xonar_u1_output_switch = {
  525. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  526. .name = "Digital Playback Switch",
  527. .info = snd_ctl_boolean_mono_info,
  528. .get = snd_xonar_u1_switch_get,
  529. .put = snd_xonar_u1_switch_put,
  530. .private_value = 0x05,
  531. };
  532. static int snd_xonar_u1_controls_create(struct usb_mixer_interface *mixer)
  533. {
  534. return add_single_ctl_with_resume(mixer, 0,
  535. snd_xonar_u1_switch_resume,
  536. &snd_xonar_u1_output_switch, NULL);
  537. }
  538. /* Digidesign Mbox 1 clock source switch (internal/spdif) */
  539. static int snd_mbox1_switch_get(struct snd_kcontrol *kctl,
  540. struct snd_ctl_elem_value *ucontrol)
  541. {
  542. ucontrol->value.enumerated.item[0] = kctl->private_value;
  543. return 0;
  544. }
  545. static int snd_mbox1_switch_update(struct usb_mixer_interface *mixer, int val)
  546. {
  547. struct snd_usb_audio *chip = mixer->chip;
  548. int err;
  549. unsigned char buff[3];
  550. down_read(&chip->shutdown_rwsem);
  551. if (chip->shutdown) {
  552. err = -ENODEV;
  553. goto err;
  554. }
  555. /* Prepare for magic command to toggle clock source */
  556. err = snd_usb_ctl_msg(chip->dev,
  557. usb_rcvctrlpipe(chip->dev, 0), 0x81,
  558. USB_DIR_IN |
  559. USB_TYPE_CLASS |
  560. USB_RECIP_INTERFACE, 0x00, 0x500, buff, 1);
  561. if (err < 0)
  562. goto err;
  563. err = snd_usb_ctl_msg(chip->dev,
  564. usb_rcvctrlpipe(chip->dev, 0), 0x81,
  565. USB_DIR_IN |
  566. USB_TYPE_CLASS |
  567. USB_RECIP_ENDPOINT, 0x100, 0x81, buff, 3);
  568. if (err < 0)
  569. goto err;
  570. /* 2 possibilities: Internal -> send sample rate
  571. * S/PDIF sync -> send zeroes
  572. * NB: Sample rate locked to 48kHz on purpose to
  573. * prevent user from resetting the sample rate
  574. * while S/PDIF sync is enabled and confusing
  575. * this configuration.
  576. */
  577. if (val == 0) {
  578. buff[0] = 0x80;
  579. buff[1] = 0xbb;
  580. buff[2] = 0x00;
  581. } else {
  582. buff[0] = buff[1] = buff[2] = 0x00;
  583. }
  584. /* Send the magic command to toggle the clock source */
  585. err = snd_usb_ctl_msg(chip->dev,
  586. usb_sndctrlpipe(chip->dev, 0), 0x1,
  587. USB_TYPE_CLASS |
  588. USB_RECIP_ENDPOINT, 0x100, 0x81, buff, 3);
  589. if (err < 0)
  590. goto err;
  591. err = snd_usb_ctl_msg(chip->dev,
  592. usb_rcvctrlpipe(chip->dev, 0), 0x81,
  593. USB_DIR_IN |
  594. USB_TYPE_CLASS |
  595. USB_RECIP_ENDPOINT, 0x100, 0x81, buff, 3);
  596. if (err < 0)
  597. goto err;
  598. err = snd_usb_ctl_msg(chip->dev,
  599. usb_rcvctrlpipe(chip->dev, 0), 0x81,
  600. USB_DIR_IN |
  601. USB_TYPE_CLASS |
  602. USB_RECIP_ENDPOINT, 0x100, 0x2, buff, 3);
  603. if (err < 0)
  604. goto err;
  605. err:
  606. up_read(&chip->shutdown_rwsem);
  607. return err;
  608. }
  609. static int snd_mbox1_switch_put(struct snd_kcontrol *kctl,
  610. struct snd_ctl_elem_value *ucontrol)
  611. {
  612. struct usb_mixer_elem_list *list = snd_kcontrol_chip(kctl);
  613. struct usb_mixer_interface *mixer = list->mixer;
  614. int err;
  615. bool cur_val, new_val;
  616. cur_val = kctl->private_value;
  617. new_val = ucontrol->value.enumerated.item[0];
  618. if (cur_val == new_val)
  619. return 0;
  620. kctl->private_value = new_val;
  621. err = snd_mbox1_switch_update(mixer, new_val);
  622. return err < 0 ? err : 1;
  623. }
  624. static int snd_mbox1_switch_info(struct snd_kcontrol *kcontrol,
  625. struct snd_ctl_elem_info *uinfo)
  626. {
  627. static const char *const texts[2] = {
  628. "Internal",
  629. "S/PDIF"
  630. };
  631. return snd_ctl_enum_info(uinfo, 1, ARRAY_SIZE(texts), texts);
  632. }
  633. static int snd_mbox1_switch_resume(struct usb_mixer_elem_list *list)
  634. {
  635. return snd_mbox1_switch_update(list->mixer, list->kctl->private_value);
  636. }
  637. static struct snd_kcontrol_new snd_mbox1_switch = {
  638. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  639. .name = "Clock Source",
  640. .index = 0,
  641. .access = SNDRV_CTL_ELEM_ACCESS_READWRITE,
  642. .info = snd_mbox1_switch_info,
  643. .get = snd_mbox1_switch_get,
  644. .put = snd_mbox1_switch_put,
  645. .private_value = 0
  646. };
  647. static int snd_mbox1_create_sync_switch(struct usb_mixer_interface *mixer)
  648. {
  649. return add_single_ctl_with_resume(mixer, 0,
  650. snd_mbox1_switch_resume,
  651. &snd_mbox1_switch, NULL);
  652. }
  653. /* Native Instruments device quirks */
  654. #define _MAKE_NI_CONTROL(bRequest,wIndex) ((bRequest) << 16 | (wIndex))
  655. static int snd_ni_control_init_val(struct usb_mixer_interface *mixer,
  656. struct snd_kcontrol *kctl)
  657. {
  658. struct usb_device *dev = mixer->chip->dev;
  659. unsigned int pval = kctl->private_value;
  660. u8 value;
  661. int err;
  662. err = snd_usb_ctl_msg(dev, usb_rcvctrlpipe(dev, 0),
  663. (pval >> 16) & 0xff,
  664. USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_IN,
  665. 0, pval & 0xffff, &value, 1);
  666. if (err < 0) {
  667. dev_err(&dev->dev,
  668. "unable to issue vendor read request (ret = %d)", err);
  669. return err;
  670. }
  671. kctl->private_value |= (value << 24);
  672. return 0;
  673. }
  674. static int snd_nativeinstruments_control_get(struct snd_kcontrol *kcontrol,
  675. struct snd_ctl_elem_value *ucontrol)
  676. {
  677. ucontrol->value.integer.value[0] = kcontrol->private_value >> 24;
  678. return 0;
  679. }
  680. static int snd_ni_update_cur_val(struct usb_mixer_elem_list *list)
  681. {
  682. struct snd_usb_audio *chip = list->mixer->chip;
  683. unsigned int pval = list->kctl->private_value;
  684. int err;
  685. down_read(&chip->shutdown_rwsem);
  686. if (chip->shutdown)
  687. err = -ENODEV;
  688. else
  689. err = usb_control_msg(chip->dev, usb_sndctrlpipe(chip->dev, 0),
  690. (pval >> 16) & 0xff,
  691. USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_OUT,
  692. pval >> 24, pval & 0xffff, NULL, 0, 1000);
  693. up_read(&chip->shutdown_rwsem);
  694. return err;
  695. }
  696. static int snd_nativeinstruments_control_put(struct snd_kcontrol *kcontrol,
  697. struct snd_ctl_elem_value *ucontrol)
  698. {
  699. struct usb_mixer_elem_list *list = snd_kcontrol_chip(kcontrol);
  700. u8 oldval = (kcontrol->private_value >> 24) & 0xff;
  701. u8 newval = ucontrol->value.integer.value[0];
  702. int err;
  703. if (oldval == newval)
  704. return 0;
  705. kcontrol->private_value &= ~(0xff << 24);
  706. kcontrol->private_value |= newval;
  707. err = snd_ni_update_cur_val(list);
  708. return err < 0 ? err : 1;
  709. }
  710. static struct snd_kcontrol_new snd_nativeinstruments_ta6_mixers[] = {
  711. {
  712. .name = "Direct Thru Channel A",
  713. .private_value = _MAKE_NI_CONTROL(0x01, 0x03),
  714. },
  715. {
  716. .name = "Direct Thru Channel B",
  717. .private_value = _MAKE_NI_CONTROL(0x01, 0x05),
  718. },
  719. {
  720. .name = "Phono Input Channel A",
  721. .private_value = _MAKE_NI_CONTROL(0x02, 0x03),
  722. },
  723. {
  724. .name = "Phono Input Channel B",
  725. .private_value = _MAKE_NI_CONTROL(0x02, 0x05),
  726. },
  727. };
  728. static struct snd_kcontrol_new snd_nativeinstruments_ta10_mixers[] = {
  729. {
  730. .name = "Direct Thru Channel A",
  731. .private_value = _MAKE_NI_CONTROL(0x01, 0x03),
  732. },
  733. {
  734. .name = "Direct Thru Channel B",
  735. .private_value = _MAKE_NI_CONTROL(0x01, 0x05),
  736. },
  737. {
  738. .name = "Direct Thru Channel C",
  739. .private_value = _MAKE_NI_CONTROL(0x01, 0x07),
  740. },
  741. {
  742. .name = "Direct Thru Channel D",
  743. .private_value = _MAKE_NI_CONTROL(0x01, 0x09),
  744. },
  745. {
  746. .name = "Phono Input Channel A",
  747. .private_value = _MAKE_NI_CONTROL(0x02, 0x03),
  748. },
  749. {
  750. .name = "Phono Input Channel B",
  751. .private_value = _MAKE_NI_CONTROL(0x02, 0x05),
  752. },
  753. {
  754. .name = "Phono Input Channel C",
  755. .private_value = _MAKE_NI_CONTROL(0x02, 0x07),
  756. },
  757. {
  758. .name = "Phono Input Channel D",
  759. .private_value = _MAKE_NI_CONTROL(0x02, 0x09),
  760. },
  761. };
  762. static int snd_nativeinstruments_create_mixer(struct usb_mixer_interface *mixer,
  763. const struct snd_kcontrol_new *kc,
  764. unsigned int count)
  765. {
  766. int i, err = 0;
  767. struct snd_kcontrol_new template = {
  768. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  769. .access = SNDRV_CTL_ELEM_ACCESS_READWRITE,
  770. .get = snd_nativeinstruments_control_get,
  771. .put = snd_nativeinstruments_control_put,
  772. .info = snd_ctl_boolean_mono_info,
  773. };
  774. for (i = 0; i < count; i++) {
  775. struct usb_mixer_elem_list *list;
  776. template.name = kc[i].name;
  777. template.private_value = kc[i].private_value;
  778. err = add_single_ctl_with_resume(mixer, 0,
  779. snd_ni_update_cur_val,
  780. &template, &list);
  781. if (err < 0)
  782. break;
  783. snd_ni_control_init_val(mixer, list->kctl);
  784. }
  785. return err;
  786. }
  787. /* M-Audio FastTrack Ultra quirks */
  788. /* FTU Effect switch (also used by C400/C600) */
  789. static int snd_ftu_eff_switch_info(struct snd_kcontrol *kcontrol,
  790. struct snd_ctl_elem_info *uinfo)
  791. {
  792. static const char *const texts[8] = {
  793. "Room 1", "Room 2", "Room 3", "Hall 1",
  794. "Hall 2", "Plate", "Delay", "Echo"
  795. };
  796. return snd_ctl_enum_info(uinfo, 1, ARRAY_SIZE(texts), texts);
  797. }
  798. static int snd_ftu_eff_switch_init(struct usb_mixer_interface *mixer,
  799. struct snd_kcontrol *kctl)
  800. {
  801. struct usb_device *dev = mixer->chip->dev;
  802. unsigned int pval = kctl->private_value;
  803. int err;
  804. unsigned char value[2];
  805. value[0] = 0x00;
  806. value[1] = 0x00;
  807. err = snd_usb_ctl_msg(dev, usb_rcvctrlpipe(dev, 0), UAC_GET_CUR,
  808. USB_RECIP_INTERFACE | USB_TYPE_CLASS | USB_DIR_IN,
  809. pval & 0xff00,
  810. snd_usb_ctrl_intf(mixer->chip) | ((pval & 0xff) << 8),
  811. value, 2);
  812. if (err < 0)
  813. return err;
  814. kctl->private_value |= value[0] << 24;
  815. return 0;
  816. }
  817. static int snd_ftu_eff_switch_get(struct snd_kcontrol *kctl,
  818. struct snd_ctl_elem_value *ucontrol)
  819. {
  820. ucontrol->value.enumerated.item[0] = kctl->private_value >> 24;
  821. return 0;
  822. }
  823. static int snd_ftu_eff_switch_update(struct usb_mixer_elem_list *list)
  824. {
  825. struct snd_usb_audio *chip = list->mixer->chip;
  826. unsigned int pval = list->kctl->private_value;
  827. unsigned char value[2];
  828. int err;
  829. value[0] = pval >> 24;
  830. value[1] = 0;
  831. down_read(&chip->shutdown_rwsem);
  832. if (chip->shutdown)
  833. err = -ENODEV;
  834. else
  835. err = snd_usb_ctl_msg(chip->dev,
  836. usb_sndctrlpipe(chip->dev, 0),
  837. UAC_SET_CUR,
  838. USB_RECIP_INTERFACE | USB_TYPE_CLASS | USB_DIR_OUT,
  839. pval & 0xff00,
  840. snd_usb_ctrl_intf(chip) | ((pval & 0xff) << 8),
  841. value, 2);
  842. up_read(&chip->shutdown_rwsem);
  843. return err;
  844. }
  845. static int snd_ftu_eff_switch_put(struct snd_kcontrol *kctl,
  846. struct snd_ctl_elem_value *ucontrol)
  847. {
  848. struct usb_mixer_elem_list *list = snd_kcontrol_chip(kctl);
  849. unsigned int pval = list->kctl->private_value;
  850. int cur_val, err, new_val;
  851. cur_val = pval >> 24;
  852. new_val = ucontrol->value.enumerated.item[0];
  853. if (cur_val == new_val)
  854. return 0;
  855. kctl->private_value &= ~(0xff << 24);
  856. kctl->private_value |= new_val << 24;
  857. err = snd_ftu_eff_switch_update(list);
  858. return err < 0 ? err : 1;
  859. }
  860. static int snd_ftu_create_effect_switch(struct usb_mixer_interface *mixer,
  861. int validx, int bUnitID)
  862. {
  863. static struct snd_kcontrol_new template = {
  864. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  865. .name = "Effect Program Switch",
  866. .index = 0,
  867. .access = SNDRV_CTL_ELEM_ACCESS_READWRITE,
  868. .info = snd_ftu_eff_switch_info,
  869. .get = snd_ftu_eff_switch_get,
  870. .put = snd_ftu_eff_switch_put
  871. };
  872. struct usb_mixer_elem_list *list;
  873. int err;
  874. err = add_single_ctl_with_resume(mixer, bUnitID,
  875. snd_ftu_eff_switch_update,
  876. &template, &list);
  877. if (err < 0)
  878. return err;
  879. list->kctl->private_value = (validx << 8) | bUnitID;
  880. snd_ftu_eff_switch_init(mixer, list->kctl);
  881. return 0;
  882. }
  883. /* Create volume controls for FTU devices*/
  884. static int snd_ftu_create_volume_ctls(struct usb_mixer_interface *mixer)
  885. {
  886. char name[64];
  887. unsigned int control, cmask;
  888. int in, out, err;
  889. const unsigned int id = 5;
  890. const int val_type = USB_MIXER_S16;
  891. for (out = 0; out < 8; out++) {
  892. control = out + 1;
  893. for (in = 0; in < 8; in++) {
  894. cmask = 1 << in;
  895. snprintf(name, sizeof(name),
  896. "AIn%d - Out%d Capture Volume",
  897. in + 1, out + 1);
  898. err = snd_create_std_mono_ctl(mixer, id, control,
  899. cmask, val_type, name,
  900. &snd_usb_mixer_vol_tlv);
  901. if (err < 0)
  902. return err;
  903. }
  904. for (in = 8; in < 16; in++) {
  905. cmask = 1 << in;
  906. snprintf(name, sizeof(name),
  907. "DIn%d - Out%d Playback Volume",
  908. in - 7, out + 1);
  909. err = snd_create_std_mono_ctl(mixer, id, control,
  910. cmask, val_type, name,
  911. &snd_usb_mixer_vol_tlv);
  912. if (err < 0)
  913. return err;
  914. }
  915. }
  916. return 0;
  917. }
  918. /* This control needs a volume quirk, see mixer.c */
  919. static int snd_ftu_create_effect_volume_ctl(struct usb_mixer_interface *mixer)
  920. {
  921. static const char name[] = "Effect Volume";
  922. const unsigned int id = 6;
  923. const int val_type = USB_MIXER_U8;
  924. const unsigned int control = 2;
  925. const unsigned int cmask = 0;
  926. return snd_create_std_mono_ctl(mixer, id, control, cmask, val_type,
  927. name, snd_usb_mixer_vol_tlv);
  928. }
  929. /* This control needs a volume quirk, see mixer.c */
  930. static int snd_ftu_create_effect_duration_ctl(struct usb_mixer_interface *mixer)
  931. {
  932. static const char name[] = "Effect Duration";
  933. const unsigned int id = 6;
  934. const int val_type = USB_MIXER_S16;
  935. const unsigned int control = 3;
  936. const unsigned int cmask = 0;
  937. return snd_create_std_mono_ctl(mixer, id, control, cmask, val_type,
  938. name, snd_usb_mixer_vol_tlv);
  939. }
  940. /* This control needs a volume quirk, see mixer.c */
  941. static int snd_ftu_create_effect_feedback_ctl(struct usb_mixer_interface *mixer)
  942. {
  943. static const char name[] = "Effect Feedback Volume";
  944. const unsigned int id = 6;
  945. const int val_type = USB_MIXER_U8;
  946. const unsigned int control = 4;
  947. const unsigned int cmask = 0;
  948. return snd_create_std_mono_ctl(mixer, id, control, cmask, val_type,
  949. name, NULL);
  950. }
  951. static int snd_ftu_create_effect_return_ctls(struct usb_mixer_interface *mixer)
  952. {
  953. unsigned int cmask;
  954. int err, ch;
  955. char name[48];
  956. const unsigned int id = 7;
  957. const int val_type = USB_MIXER_S16;
  958. const unsigned int control = 7;
  959. for (ch = 0; ch < 4; ++ch) {
  960. cmask = 1 << ch;
  961. snprintf(name, sizeof(name),
  962. "Effect Return %d Volume", ch + 1);
  963. err = snd_create_std_mono_ctl(mixer, id, control,
  964. cmask, val_type, name,
  965. snd_usb_mixer_vol_tlv);
  966. if (err < 0)
  967. return err;
  968. }
  969. return 0;
  970. }
  971. static int snd_ftu_create_effect_send_ctls(struct usb_mixer_interface *mixer)
  972. {
  973. unsigned int cmask;
  974. int err, ch;
  975. char name[48];
  976. const unsigned int id = 5;
  977. const int val_type = USB_MIXER_S16;
  978. const unsigned int control = 9;
  979. for (ch = 0; ch < 8; ++ch) {
  980. cmask = 1 << ch;
  981. snprintf(name, sizeof(name),
  982. "Effect Send AIn%d Volume", ch + 1);
  983. err = snd_create_std_mono_ctl(mixer, id, control, cmask,
  984. val_type, name,
  985. snd_usb_mixer_vol_tlv);
  986. if (err < 0)
  987. return err;
  988. }
  989. for (ch = 8; ch < 16; ++ch) {
  990. cmask = 1 << ch;
  991. snprintf(name, sizeof(name),
  992. "Effect Send DIn%d Volume", ch - 7);
  993. err = snd_create_std_mono_ctl(mixer, id, control, cmask,
  994. val_type, name,
  995. snd_usb_mixer_vol_tlv);
  996. if (err < 0)
  997. return err;
  998. }
  999. return 0;
  1000. }
  1001. static int snd_ftu_create_mixer(struct usb_mixer_interface *mixer)
  1002. {
  1003. int err;
  1004. err = snd_ftu_create_volume_ctls(mixer);
  1005. if (err < 0)
  1006. return err;
  1007. err = snd_ftu_create_effect_switch(mixer, 1, 6);
  1008. if (err < 0)
  1009. return err;
  1010. err = snd_ftu_create_effect_volume_ctl(mixer);
  1011. if (err < 0)
  1012. return err;
  1013. err = snd_ftu_create_effect_duration_ctl(mixer);
  1014. if (err < 0)
  1015. return err;
  1016. err = snd_ftu_create_effect_feedback_ctl(mixer);
  1017. if (err < 0)
  1018. return err;
  1019. err = snd_ftu_create_effect_return_ctls(mixer);
  1020. if (err < 0)
  1021. return err;
  1022. err = snd_ftu_create_effect_send_ctls(mixer);
  1023. if (err < 0)
  1024. return err;
  1025. return 0;
  1026. }
  1027. void snd_emuusb_set_samplerate(struct snd_usb_audio *chip,
  1028. unsigned char samplerate_id)
  1029. {
  1030. struct usb_mixer_interface *mixer;
  1031. struct usb_mixer_elem_info *cval;
  1032. int unitid = 12; /* SamleRate ExtensionUnit ID */
  1033. list_for_each_entry(mixer, &chip->mixer_list, list) {
  1034. cval = (struct usb_mixer_elem_info *)mixer->id_elems[unitid];
  1035. if (cval) {
  1036. snd_usb_mixer_set_ctl_value(cval, UAC_SET_CUR,
  1037. cval->control << 8,
  1038. samplerate_id);
  1039. snd_usb_mixer_notify_id(mixer, unitid);
  1040. }
  1041. break;
  1042. }
  1043. }
  1044. /* M-Audio Fast Track C400/C600 */
  1045. /* C400/C600 volume controls, this control needs a volume quirk, see mixer.c */
  1046. static int snd_c400_create_vol_ctls(struct usb_mixer_interface *mixer)
  1047. {
  1048. char name[64];
  1049. unsigned int cmask, offset;
  1050. int out, chan, err;
  1051. int num_outs = 0;
  1052. int num_ins = 0;
  1053. const unsigned int id = 0x40;
  1054. const int val_type = USB_MIXER_S16;
  1055. const int control = 1;
  1056. switch (mixer->chip->usb_id) {
  1057. case USB_ID(0x0763, 0x2030):
  1058. num_outs = 6;
  1059. num_ins = 4;
  1060. break;
  1061. case USB_ID(0x0763, 0x2031):
  1062. num_outs = 8;
  1063. num_ins = 6;
  1064. break;
  1065. }
  1066. for (chan = 0; chan < num_outs + num_ins; chan++) {
  1067. for (out = 0; out < num_outs; out++) {
  1068. if (chan < num_outs) {
  1069. snprintf(name, sizeof(name),
  1070. "PCM%d-Out%d Playback Volume",
  1071. chan + 1, out + 1);
  1072. } else {
  1073. snprintf(name, sizeof(name),
  1074. "In%d-Out%d Playback Volume",
  1075. chan - num_outs + 1, out + 1);
  1076. }
  1077. cmask = (out == 0) ? 0 : 1 << (out - 1);
  1078. offset = chan * num_outs;
  1079. err = snd_create_std_mono_ctl_offset(mixer, id, control,
  1080. cmask, val_type, offset, name,
  1081. &snd_usb_mixer_vol_tlv);
  1082. if (err < 0)
  1083. return err;
  1084. }
  1085. }
  1086. return 0;
  1087. }
  1088. /* This control needs a volume quirk, see mixer.c */
  1089. static int snd_c400_create_effect_volume_ctl(struct usb_mixer_interface *mixer)
  1090. {
  1091. static const char name[] = "Effect Volume";
  1092. const unsigned int id = 0x43;
  1093. const int val_type = USB_MIXER_U8;
  1094. const unsigned int control = 3;
  1095. const unsigned int cmask = 0;
  1096. return snd_create_std_mono_ctl(mixer, id, control, cmask, val_type,
  1097. name, snd_usb_mixer_vol_tlv);
  1098. }
  1099. /* This control needs a volume quirk, see mixer.c */
  1100. static int snd_c400_create_effect_duration_ctl(struct usb_mixer_interface *mixer)
  1101. {
  1102. static const char name[] = "Effect Duration";
  1103. const unsigned int id = 0x43;
  1104. const int val_type = USB_MIXER_S16;
  1105. const unsigned int control = 4;
  1106. const unsigned int cmask = 0;
  1107. return snd_create_std_mono_ctl(mixer, id, control, cmask, val_type,
  1108. name, snd_usb_mixer_vol_tlv);
  1109. }
  1110. /* This control needs a volume quirk, see mixer.c */
  1111. static int snd_c400_create_effect_feedback_ctl(struct usb_mixer_interface *mixer)
  1112. {
  1113. static const char name[] = "Effect Feedback Volume";
  1114. const unsigned int id = 0x43;
  1115. const int val_type = USB_MIXER_U8;
  1116. const unsigned int control = 5;
  1117. const unsigned int cmask = 0;
  1118. return snd_create_std_mono_ctl(mixer, id, control, cmask, val_type,
  1119. name, NULL);
  1120. }
  1121. static int snd_c400_create_effect_vol_ctls(struct usb_mixer_interface *mixer)
  1122. {
  1123. char name[64];
  1124. unsigned int cmask;
  1125. int chan, err;
  1126. int num_outs = 0;
  1127. int num_ins = 0;
  1128. const unsigned int id = 0x42;
  1129. const int val_type = USB_MIXER_S16;
  1130. const int control = 1;
  1131. switch (mixer->chip->usb_id) {
  1132. case USB_ID(0x0763, 0x2030):
  1133. num_outs = 6;
  1134. num_ins = 4;
  1135. break;
  1136. case USB_ID(0x0763, 0x2031):
  1137. num_outs = 8;
  1138. num_ins = 6;
  1139. break;
  1140. }
  1141. for (chan = 0; chan < num_outs + num_ins; chan++) {
  1142. if (chan < num_outs) {
  1143. snprintf(name, sizeof(name),
  1144. "Effect Send DOut%d",
  1145. chan + 1);
  1146. } else {
  1147. snprintf(name, sizeof(name),
  1148. "Effect Send AIn%d",
  1149. chan - num_outs + 1);
  1150. }
  1151. cmask = (chan == 0) ? 0 : 1 << (chan - 1);
  1152. err = snd_create_std_mono_ctl(mixer, id, control,
  1153. cmask, val_type, name,
  1154. &snd_usb_mixer_vol_tlv);
  1155. if (err < 0)
  1156. return err;
  1157. }
  1158. return 0;
  1159. }
  1160. static int snd_c400_create_effect_ret_vol_ctls(struct usb_mixer_interface *mixer)
  1161. {
  1162. char name[64];
  1163. unsigned int cmask;
  1164. int chan, err;
  1165. int num_outs = 0;
  1166. int offset = 0;
  1167. const unsigned int id = 0x40;
  1168. const int val_type = USB_MIXER_S16;
  1169. const int control = 1;
  1170. switch (mixer->chip->usb_id) {
  1171. case USB_ID(0x0763, 0x2030):
  1172. num_outs = 6;
  1173. offset = 0x3c;
  1174. /* { 0x3c, 0x43, 0x3e, 0x45, 0x40, 0x47 } */
  1175. break;
  1176. case USB_ID(0x0763, 0x2031):
  1177. num_outs = 8;
  1178. offset = 0x70;
  1179. /* { 0x70, 0x79, 0x72, 0x7b, 0x74, 0x7d, 0x76, 0x7f } */
  1180. break;
  1181. }
  1182. for (chan = 0; chan < num_outs; chan++) {
  1183. snprintf(name, sizeof(name),
  1184. "Effect Return %d",
  1185. chan + 1);
  1186. cmask = (chan == 0) ? 0 :
  1187. 1 << (chan + (chan % 2) * num_outs - 1);
  1188. err = snd_create_std_mono_ctl_offset(mixer, id, control,
  1189. cmask, val_type, offset, name,
  1190. &snd_usb_mixer_vol_tlv);
  1191. if (err < 0)
  1192. return err;
  1193. }
  1194. return 0;
  1195. }
  1196. static int snd_c400_create_mixer(struct usb_mixer_interface *mixer)
  1197. {
  1198. int err;
  1199. err = snd_c400_create_vol_ctls(mixer);
  1200. if (err < 0)
  1201. return err;
  1202. err = snd_c400_create_effect_vol_ctls(mixer);
  1203. if (err < 0)
  1204. return err;
  1205. err = snd_c400_create_effect_ret_vol_ctls(mixer);
  1206. if (err < 0)
  1207. return err;
  1208. err = snd_ftu_create_effect_switch(mixer, 2, 0x43);
  1209. if (err < 0)
  1210. return err;
  1211. err = snd_c400_create_effect_volume_ctl(mixer);
  1212. if (err < 0)
  1213. return err;
  1214. err = snd_c400_create_effect_duration_ctl(mixer);
  1215. if (err < 0)
  1216. return err;
  1217. err = snd_c400_create_effect_feedback_ctl(mixer);
  1218. if (err < 0)
  1219. return err;
  1220. return 0;
  1221. }
  1222. /*
  1223. * The mixer units for Ebox-44 are corrupt, and even where they
  1224. * are valid they presents mono controls as L and R channels of
  1225. * stereo. So we provide a good mixer here.
  1226. */
  1227. static struct std_mono_table ebox44_table[] = {
  1228. {
  1229. .unitid = 4,
  1230. .control = 1,
  1231. .cmask = 0x0,
  1232. .val_type = USB_MIXER_INV_BOOLEAN,
  1233. .name = "Headphone Playback Switch"
  1234. },
  1235. {
  1236. .unitid = 4,
  1237. .control = 2,
  1238. .cmask = 0x1,
  1239. .val_type = USB_MIXER_S16,
  1240. .name = "Headphone A Mix Playback Volume"
  1241. },
  1242. {
  1243. .unitid = 4,
  1244. .control = 2,
  1245. .cmask = 0x2,
  1246. .val_type = USB_MIXER_S16,
  1247. .name = "Headphone B Mix Playback Volume"
  1248. },
  1249. {
  1250. .unitid = 7,
  1251. .control = 1,
  1252. .cmask = 0x0,
  1253. .val_type = USB_MIXER_INV_BOOLEAN,
  1254. .name = "Output Playback Switch"
  1255. },
  1256. {
  1257. .unitid = 7,
  1258. .control = 2,
  1259. .cmask = 0x1,
  1260. .val_type = USB_MIXER_S16,
  1261. .name = "Output A Playback Volume"
  1262. },
  1263. {
  1264. .unitid = 7,
  1265. .control = 2,
  1266. .cmask = 0x2,
  1267. .val_type = USB_MIXER_S16,
  1268. .name = "Output B Playback Volume"
  1269. },
  1270. {
  1271. .unitid = 10,
  1272. .control = 1,
  1273. .cmask = 0x0,
  1274. .val_type = USB_MIXER_INV_BOOLEAN,
  1275. .name = "Input Capture Switch"
  1276. },
  1277. {
  1278. .unitid = 10,
  1279. .control = 2,
  1280. .cmask = 0x1,
  1281. .val_type = USB_MIXER_S16,
  1282. .name = "Input A Capture Volume"
  1283. },
  1284. {
  1285. .unitid = 10,
  1286. .control = 2,
  1287. .cmask = 0x2,
  1288. .val_type = USB_MIXER_S16,
  1289. .name = "Input B Capture Volume"
  1290. },
  1291. {}
  1292. };
  1293. /* Audio Advantage Micro II findings:
  1294. *
  1295. * Mapping spdif AES bits to vendor register.bit:
  1296. * AES0: [0 0 0 0 2.3 2.2 2.1 2.0] - default 0x00
  1297. * AES1: [3.3 3.2.3.1.3.0 2.7 2.6 2.5 2.4] - default: 0x01
  1298. * AES2: [0 0 0 0 0 0 0 0]
  1299. * AES3: [0 0 0 0 0 0 x 0] - 'x' bit is set basing on standard usb request
  1300. * (UAC_EP_CS_ATTR_SAMPLE_RATE) for Audio Devices
  1301. *
  1302. * power on values:
  1303. * r2: 0x10
  1304. * r3: 0x20 (b7 is zeroed just before playback (except IEC61937) and set
  1305. * just after it to 0xa0, presumably it disables/mutes some analog
  1306. * parts when there is no audio.)
  1307. * r9: 0x28
  1308. *
  1309. * Optical transmitter on/off:
  1310. * vendor register.bit: 9.1
  1311. * 0 - on (0x28 register value)
  1312. * 1 - off (0x2a register value)
  1313. *
  1314. */
  1315. static int snd_microii_spdif_info(struct snd_kcontrol *kcontrol,
  1316. struct snd_ctl_elem_info *uinfo)
  1317. {
  1318. uinfo->type = SNDRV_CTL_ELEM_TYPE_IEC958;
  1319. uinfo->count = 1;
  1320. return 0;
  1321. }
  1322. static int snd_microii_spdif_default_get(struct snd_kcontrol *kcontrol,
  1323. struct snd_ctl_elem_value *ucontrol)
  1324. {
  1325. struct usb_mixer_elem_list *list = snd_kcontrol_chip(kcontrol);
  1326. struct snd_usb_audio *chip = list->mixer->chip;
  1327. int err;
  1328. struct usb_interface *iface;
  1329. struct usb_host_interface *alts;
  1330. unsigned int ep;
  1331. unsigned char data[3];
  1332. int rate;
  1333. down_read(&chip->shutdown_rwsem);
  1334. if (chip->shutdown) {
  1335. err = -ENODEV;
  1336. goto end;
  1337. }
  1338. ucontrol->value.iec958.status[0] = kcontrol->private_value & 0xff;
  1339. ucontrol->value.iec958.status[1] = (kcontrol->private_value >> 8) & 0xff;
  1340. ucontrol->value.iec958.status[2] = 0x00;
  1341. /* use known values for that card: interface#1 altsetting#1 */
  1342. iface = usb_ifnum_to_if(chip->dev, 1);
  1343. alts = &iface->altsetting[1];
  1344. ep = get_endpoint(alts, 0)->bEndpointAddress;
  1345. err = snd_usb_ctl_msg(chip->dev,
  1346. usb_rcvctrlpipe(chip->dev, 0),
  1347. UAC_GET_CUR,
  1348. USB_TYPE_CLASS | USB_RECIP_ENDPOINT | USB_DIR_IN,
  1349. UAC_EP_CS_ATTR_SAMPLE_RATE << 8,
  1350. ep,
  1351. data,
  1352. sizeof(data));
  1353. if (err < 0)
  1354. goto end;
  1355. rate = data[0] | (data[1] << 8) | (data[2] << 16);
  1356. ucontrol->value.iec958.status[3] = (rate == 48000) ?
  1357. IEC958_AES3_CON_FS_48000 : IEC958_AES3_CON_FS_44100;
  1358. err = 0;
  1359. end:
  1360. up_read(&chip->shutdown_rwsem);
  1361. return err;
  1362. }
  1363. static int snd_microii_spdif_default_update(struct usb_mixer_elem_list *list)
  1364. {
  1365. struct snd_usb_audio *chip = list->mixer->chip;
  1366. unsigned int pval = list->kctl->private_value;
  1367. u8 reg;
  1368. int err;
  1369. down_read(&chip->shutdown_rwsem);
  1370. if (chip->shutdown) {
  1371. err = -ENODEV;
  1372. goto end;
  1373. }
  1374. reg = ((pval >> 4) & 0xf0) | (pval & 0x0f);
  1375. err = snd_usb_ctl_msg(chip->dev,
  1376. usb_sndctrlpipe(chip->dev, 0),
  1377. UAC_SET_CUR,
  1378. USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_OTHER,
  1379. reg,
  1380. 2,
  1381. NULL,
  1382. 0);
  1383. if (err < 0)
  1384. goto end;
  1385. reg = (pval & IEC958_AES0_NONAUDIO) ? 0xa0 : 0x20;
  1386. reg |= (pval >> 12) & 0x0f;
  1387. err = snd_usb_ctl_msg(chip->dev,
  1388. usb_sndctrlpipe(chip->dev, 0),
  1389. UAC_SET_CUR,
  1390. USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_OTHER,
  1391. reg,
  1392. 3,
  1393. NULL,
  1394. 0);
  1395. if (err < 0)
  1396. goto end;
  1397. end:
  1398. up_read(&chip->shutdown_rwsem);
  1399. return err;
  1400. }
  1401. static int snd_microii_spdif_default_put(struct snd_kcontrol *kcontrol,
  1402. struct snd_ctl_elem_value *ucontrol)
  1403. {
  1404. struct usb_mixer_elem_list *list = snd_kcontrol_chip(kcontrol);
  1405. unsigned int pval, pval_old;
  1406. int err;
  1407. pval = pval_old = kcontrol->private_value;
  1408. pval &= 0xfffff0f0;
  1409. pval |= (ucontrol->value.iec958.status[1] & 0x0f) << 8;
  1410. pval |= (ucontrol->value.iec958.status[0] & 0x0f);
  1411. pval &= 0xffff0fff;
  1412. pval |= (ucontrol->value.iec958.status[1] & 0xf0) << 8;
  1413. /* The frequency bits in AES3 cannot be set via register access. */
  1414. /* Silently ignore any bits from the request that cannot be set. */
  1415. if (pval == pval_old)
  1416. return 0;
  1417. kcontrol->private_value = pval;
  1418. err = snd_microii_spdif_default_update(list);
  1419. return err < 0 ? err : 1;
  1420. }
  1421. static int snd_microii_spdif_mask_get(struct snd_kcontrol *kcontrol,
  1422. struct snd_ctl_elem_value *ucontrol)
  1423. {
  1424. ucontrol->value.iec958.status[0] = 0x0f;
  1425. ucontrol->value.iec958.status[1] = 0xff;
  1426. ucontrol->value.iec958.status[2] = 0x00;
  1427. ucontrol->value.iec958.status[3] = 0x00;
  1428. return 0;
  1429. }
  1430. static int snd_microii_spdif_switch_get(struct snd_kcontrol *kcontrol,
  1431. struct snd_ctl_elem_value *ucontrol)
  1432. {
  1433. ucontrol->value.integer.value[0] = !(kcontrol->private_value & 0x02);
  1434. return 0;
  1435. }
  1436. static int snd_microii_spdif_switch_update(struct usb_mixer_elem_list *list)
  1437. {
  1438. struct snd_usb_audio *chip = list->mixer->chip;
  1439. u8 reg = list->kctl->private_value;
  1440. int err;
  1441. down_read(&chip->shutdown_rwsem);
  1442. if (chip->shutdown) {
  1443. err = -ENODEV;
  1444. goto end;
  1445. }
  1446. err = snd_usb_ctl_msg(chip->dev,
  1447. usb_sndctrlpipe(chip->dev, 0),
  1448. UAC_SET_CUR,
  1449. USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_OTHER,
  1450. reg,
  1451. 9,
  1452. NULL,
  1453. 0);
  1454. end:
  1455. up_read(&chip->shutdown_rwsem);
  1456. return err;
  1457. }
  1458. static int snd_microii_spdif_switch_put(struct snd_kcontrol *kcontrol,
  1459. struct snd_ctl_elem_value *ucontrol)
  1460. {
  1461. struct usb_mixer_elem_list *list = snd_kcontrol_chip(kcontrol);
  1462. u8 reg;
  1463. int err;
  1464. reg = ucontrol->value.integer.value[0] ? 0x28 : 0x2a;
  1465. if (reg != list->kctl->private_value)
  1466. return 0;
  1467. kcontrol->private_value = reg;
  1468. err = snd_microii_spdif_switch_update(list);
  1469. return err < 0 ? err : 1;
  1470. }
  1471. static struct snd_kcontrol_new snd_microii_mixer_spdif[] = {
  1472. {
  1473. .iface = SNDRV_CTL_ELEM_IFACE_PCM,
  1474. .name = SNDRV_CTL_NAME_IEC958("", PLAYBACK, DEFAULT),
  1475. .info = snd_microii_spdif_info,
  1476. .get = snd_microii_spdif_default_get,
  1477. .put = snd_microii_spdif_default_put,
  1478. .private_value = 0x00000100UL,/* reset value */
  1479. },
  1480. {
  1481. .access = SNDRV_CTL_ELEM_ACCESS_READ,
  1482. .iface = SNDRV_CTL_ELEM_IFACE_PCM,
  1483. .name = SNDRV_CTL_NAME_IEC958("", PLAYBACK, MASK),
  1484. .info = snd_microii_spdif_info,
  1485. .get = snd_microii_spdif_mask_get,
  1486. },
  1487. {
  1488. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  1489. .name = SNDRV_CTL_NAME_IEC958("", PLAYBACK, SWITCH),
  1490. .info = snd_ctl_boolean_mono_info,
  1491. .get = snd_microii_spdif_switch_get,
  1492. .put = snd_microii_spdif_switch_put,
  1493. .private_value = 0x00000028UL,/* reset value */
  1494. }
  1495. };
  1496. static int snd_microii_controls_create(struct usb_mixer_interface *mixer)
  1497. {
  1498. int err, i;
  1499. static usb_mixer_elem_resume_func_t resume_funcs[] = {
  1500. snd_microii_spdif_default_update,
  1501. NULL,
  1502. snd_microii_spdif_switch_update
  1503. };
  1504. for (i = 0; i < ARRAY_SIZE(snd_microii_mixer_spdif); ++i) {
  1505. err = add_single_ctl_with_resume(mixer, 0,
  1506. resume_funcs[i],
  1507. &snd_microii_mixer_spdif[i],
  1508. NULL);
  1509. if (err < 0)
  1510. return err;
  1511. }
  1512. return 0;
  1513. }
  1514. int snd_usb_mixer_apply_create_quirk(struct usb_mixer_interface *mixer)
  1515. {
  1516. int err = 0;
  1517. struct snd_info_entry *entry;
  1518. if ((err = snd_usb_soundblaster_remote_init(mixer)) < 0)
  1519. return err;
  1520. switch (mixer->chip->usb_id) {
  1521. case USB_ID(0x041e, 0x3020):
  1522. case USB_ID(0x041e, 0x3040):
  1523. case USB_ID(0x041e, 0x3042):
  1524. case USB_ID(0x041e, 0x30df):
  1525. case USB_ID(0x041e, 0x3048):
  1526. err = snd_audigy2nx_controls_create(mixer);
  1527. if (err < 0)
  1528. break;
  1529. if (!snd_card_proc_new(mixer->chip->card, "audigy2nx", &entry))
  1530. snd_info_set_text_ops(entry, mixer,
  1531. snd_audigy2nx_proc_read);
  1532. break;
  1533. /* EMU0204 */
  1534. case USB_ID(0x041e, 0x3f19):
  1535. err = snd_emu0204_controls_create(mixer);
  1536. if (err < 0)
  1537. break;
  1538. break;
  1539. case USB_ID(0x0763, 0x2030): /* M-Audio Fast Track C400 */
  1540. case USB_ID(0x0763, 0x2031): /* M-Audio Fast Track C400 */
  1541. err = snd_c400_create_mixer(mixer);
  1542. break;
  1543. case USB_ID(0x0763, 0x2080): /* M-Audio Fast Track Ultra */
  1544. case USB_ID(0x0763, 0x2081): /* M-Audio Fast Track Ultra 8R */
  1545. err = snd_ftu_create_mixer(mixer);
  1546. break;
  1547. case USB_ID(0x0b05, 0x1739): /* ASUS Xonar U1 */
  1548. case USB_ID(0x0b05, 0x1743): /* ASUS Xonar U1 (2) */
  1549. case USB_ID(0x0b05, 0x17a0): /* ASUS Xonar U3 */
  1550. err = snd_xonar_u1_controls_create(mixer);
  1551. break;
  1552. case USB_ID(0x0d8c, 0x0103): /* Audio Advantage Micro II */
  1553. err = snd_microii_controls_create(mixer);
  1554. break;
  1555. case USB_ID(0x0dba, 0x1000): /* Digidesign Mbox 1 */
  1556. err = snd_mbox1_create_sync_switch(mixer);
  1557. break;
  1558. case USB_ID(0x17cc, 0x1011): /* Traktor Audio 6 */
  1559. err = snd_nativeinstruments_create_mixer(mixer,
  1560. snd_nativeinstruments_ta6_mixers,
  1561. ARRAY_SIZE(snd_nativeinstruments_ta6_mixers));
  1562. break;
  1563. case USB_ID(0x17cc, 0x1021): /* Traktor Audio 10 */
  1564. err = snd_nativeinstruments_create_mixer(mixer,
  1565. snd_nativeinstruments_ta10_mixers,
  1566. ARRAY_SIZE(snd_nativeinstruments_ta10_mixers));
  1567. break;
  1568. case USB_ID(0x200c, 0x1018): /* Electrix Ebox-44 */
  1569. /* detection is disabled in mixer_maps.c */
  1570. err = snd_create_std_mono_table(mixer, ebox44_table);
  1571. break;
  1572. case USB_ID(0x1235, 0x8012): /* Focusrite Scarlett 6i6 */
  1573. case USB_ID(0x1235, 0x8002): /* Focusrite Scarlett 8i6 */
  1574. case USB_ID(0x1235, 0x8004): /* Focusrite Scarlett 18i6 */
  1575. case USB_ID(0x1235, 0x8014): /* Focusrite Scarlett 18i8 */
  1576. case USB_ID(0x1235, 0x800c): /* Focusrite Scarlett 18i20 */
  1577. err = snd_scarlett_controls_create(mixer);
  1578. break;
  1579. }
  1580. return err;
  1581. }
  1582. void snd_usb_mixer_rc_memory_change(struct usb_mixer_interface *mixer,
  1583. int unitid)
  1584. {
  1585. if (!mixer->rc_cfg)
  1586. return;
  1587. /* unit ids specific to Extigy/Audigy 2 NX: */
  1588. switch (unitid) {
  1589. case 0: /* remote control */
  1590. mixer->rc_urb->dev = mixer->chip->dev;
  1591. usb_submit_urb(mixer->rc_urb, GFP_ATOMIC);
  1592. break;
  1593. case 4: /* digital in jack */
  1594. case 7: /* line in jacks */
  1595. case 19: /* speaker out jacks */
  1596. case 20: /* headphones out jack */
  1597. break;
  1598. /* live24ext: 4 = line-in jack */
  1599. case 3: /* hp-out jack (may actuate Mute) */
  1600. if (mixer->chip->usb_id == USB_ID(0x041e, 0x3040) ||
  1601. mixer->chip->usb_id == USB_ID(0x041e, 0x3048))
  1602. snd_usb_mixer_notify_id(mixer, mixer->rc_cfg->mute_mixer_id);
  1603. break;
  1604. default:
  1605. usb_audio_dbg(mixer->chip, "memory change in unknown unit %d\n", unitid);
  1606. break;
  1607. }
  1608. }