mixer_quirks.c 47 KB

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