mixer_quirks.c 34 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361
  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. *
  13. * This program is free software; you can redistribute it and/or modify
  14. * it under the terms of the GNU General Public License as published by
  15. * the Free Software Foundation; either version 2 of the License, or
  16. * (at your option) any later version.
  17. *
  18. * This program is distributed in the hope that it will be useful,
  19. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  20. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  21. * GNU General Public License for more details.
  22. *
  23. * You should have received a copy of the GNU General Public License
  24. * along with this program; if not, write to the Free Software
  25. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  26. */
  27. #include <linux/init.h>
  28. #include <linux/slab.h>
  29. #include <linux/usb.h>
  30. #include <linux/usb/audio.h>
  31. #include <sound/core.h>
  32. #include <sound/control.h>
  33. #include <sound/hwdep.h>
  34. #include <sound/info.h>
  35. #include "usbaudio.h"
  36. #include "mixer.h"
  37. #include "mixer_quirks.h"
  38. #include "helper.h"
  39. extern struct snd_kcontrol_new *snd_usb_feature_unit_ctl;
  40. struct std_mono_table {
  41. unsigned int unitid, control, cmask;
  42. int val_type;
  43. const char *name;
  44. snd_kcontrol_tlv_rw_t *tlv_callback;
  45. };
  46. /* private_free callback */
  47. static void usb_mixer_elem_free(struct snd_kcontrol *kctl)
  48. {
  49. kfree(kctl->private_data);
  50. kctl->private_data = NULL;
  51. }
  52. /* This function allows for the creation of standard UAC controls.
  53. * See the quirks for M-Audio FTUs or Ebox-44.
  54. * If you don't want to set a TLV callback pass NULL.
  55. *
  56. * Since there doesn't seem to be a devices that needs a multichannel
  57. * version, we keep it mono for simplicity.
  58. */
  59. static int snd_create_std_mono_ctl_offset(struct usb_mixer_interface *mixer,
  60. unsigned int unitid,
  61. unsigned int control,
  62. unsigned int cmask,
  63. int val_type,
  64. unsigned int idx_off,
  65. const char *name,
  66. snd_kcontrol_tlv_rw_t *tlv_callback)
  67. {
  68. int err;
  69. struct usb_mixer_elem_info *cval;
  70. struct snd_kcontrol *kctl;
  71. cval = kzalloc(sizeof(*cval), GFP_KERNEL);
  72. if (!cval)
  73. return -ENOMEM;
  74. cval->id = unitid;
  75. cval->mixer = mixer;
  76. cval->val_type = val_type;
  77. cval->channels = 1;
  78. cval->control = control;
  79. cval->cmask = cmask;
  80. cval->idx_off = idx_off;
  81. /* get_min_max() is called only for integer volumes later,
  82. * so provide a short-cut for booleans */
  83. cval->min = 0;
  84. cval->max = 1;
  85. cval->res = 0;
  86. cval->dBmin = 0;
  87. cval->dBmax = 0;
  88. /* Create control */
  89. kctl = snd_ctl_new1(snd_usb_feature_unit_ctl, cval);
  90. if (!kctl) {
  91. kfree(cval);
  92. return -ENOMEM;
  93. }
  94. /* Set name */
  95. snprintf(kctl->id.name, sizeof(kctl->id.name), name);
  96. kctl->private_free = usb_mixer_elem_free;
  97. /* set TLV */
  98. if (tlv_callback) {
  99. kctl->tlv.c = tlv_callback;
  100. kctl->vd[0].access |=
  101. SNDRV_CTL_ELEM_ACCESS_TLV_READ |
  102. SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK;
  103. }
  104. /* Add control to mixer */
  105. err = snd_usb_mixer_add_control(mixer, kctl);
  106. if (err < 0)
  107. return err;
  108. return 0;
  109. }
  110. static int snd_create_std_mono_ctl(struct usb_mixer_interface *mixer,
  111. unsigned int unitid,
  112. unsigned int control,
  113. unsigned int cmask,
  114. int val_type,
  115. const char *name,
  116. snd_kcontrol_tlv_rw_t *tlv_callback)
  117. {
  118. return snd_create_std_mono_ctl_offset(mixer, unitid, control, cmask,
  119. val_type, 0 /* Offset */, name, tlv_callback);
  120. }
  121. /*
  122. * Create a set of standard UAC controls from a table
  123. */
  124. static int snd_create_std_mono_table(struct usb_mixer_interface *mixer,
  125. struct std_mono_table *t)
  126. {
  127. int err;
  128. while (t->name != NULL) {
  129. err = snd_create_std_mono_ctl(mixer, t->unitid, t->control,
  130. t->cmask, t->val_type, t->name, t->tlv_callback);
  131. if (err < 0)
  132. return err;
  133. t++;
  134. }
  135. return 0;
  136. }
  137. /*
  138. * Sound Blaster remote control configuration
  139. *
  140. * format of remote control data:
  141. * Extigy: xx 00
  142. * Audigy 2 NX: 06 80 xx 00 00 00
  143. * Live! 24-bit: 06 80 xx yy 22 83
  144. */
  145. static const struct rc_config {
  146. u32 usb_id;
  147. u8 offset;
  148. u8 length;
  149. u8 packet_length;
  150. u8 min_packet_length; /* minimum accepted length of the URB result */
  151. u8 mute_mixer_id;
  152. u32 mute_code;
  153. } rc_configs[] = {
  154. { USB_ID(0x041e, 0x3000), 0, 1, 2, 1, 18, 0x0013 }, /* Extigy */
  155. { USB_ID(0x041e, 0x3020), 2, 1, 6, 6, 18, 0x0013 }, /* Audigy 2 NX */
  156. { USB_ID(0x041e, 0x3040), 2, 2, 6, 6, 2, 0x6e91 }, /* Live! 24-bit */
  157. { USB_ID(0x041e, 0x3042), 0, 1, 1, 1, 1, 0x000d }, /* Usb X-Fi S51 */
  158. { USB_ID(0x041e, 0x30df), 0, 1, 1, 1, 1, 0x000d }, /* Usb X-Fi S51 Pro */
  159. { USB_ID(0x041e, 0x3048), 2, 2, 6, 6, 2, 0x6e91 }, /* Toshiba SB0500 */
  160. };
  161. static void snd_usb_soundblaster_remote_complete(struct urb *urb)
  162. {
  163. struct usb_mixer_interface *mixer = urb->context;
  164. const struct rc_config *rc = mixer->rc_cfg;
  165. u32 code;
  166. if (urb->status < 0 || urb->actual_length < rc->min_packet_length)
  167. return;
  168. code = mixer->rc_buffer[rc->offset];
  169. if (rc->length == 2)
  170. code |= mixer->rc_buffer[rc->offset + 1] << 8;
  171. /* the Mute button actually changes the mixer control */
  172. if (code == rc->mute_code)
  173. snd_usb_mixer_notify_id(mixer, rc->mute_mixer_id);
  174. mixer->rc_code = code;
  175. wmb();
  176. wake_up(&mixer->rc_waitq);
  177. }
  178. static long snd_usb_sbrc_hwdep_read(struct snd_hwdep *hw, char __user *buf,
  179. long count, loff_t *offset)
  180. {
  181. struct usb_mixer_interface *mixer = hw->private_data;
  182. int err;
  183. u32 rc_code;
  184. if (count != 1 && count != 4)
  185. return -EINVAL;
  186. err = wait_event_interruptible(mixer->rc_waitq,
  187. (rc_code = xchg(&mixer->rc_code, 0)) != 0);
  188. if (err == 0) {
  189. if (count == 1)
  190. err = put_user(rc_code, buf);
  191. else
  192. err = put_user(rc_code, (u32 __user *)buf);
  193. }
  194. return err < 0 ? err : count;
  195. }
  196. static unsigned int snd_usb_sbrc_hwdep_poll(struct snd_hwdep *hw, struct file *file,
  197. poll_table *wait)
  198. {
  199. struct usb_mixer_interface *mixer = hw->private_data;
  200. poll_wait(file, &mixer->rc_waitq, wait);
  201. return mixer->rc_code ? POLLIN | POLLRDNORM : 0;
  202. }
  203. static int snd_usb_soundblaster_remote_init(struct usb_mixer_interface *mixer)
  204. {
  205. struct snd_hwdep *hwdep;
  206. int err, len, i;
  207. for (i = 0; i < ARRAY_SIZE(rc_configs); ++i)
  208. if (rc_configs[i].usb_id == mixer->chip->usb_id)
  209. break;
  210. if (i >= ARRAY_SIZE(rc_configs))
  211. return 0;
  212. mixer->rc_cfg = &rc_configs[i];
  213. len = mixer->rc_cfg->packet_length;
  214. init_waitqueue_head(&mixer->rc_waitq);
  215. err = snd_hwdep_new(mixer->chip->card, "SB remote control", 0, &hwdep);
  216. if (err < 0)
  217. return err;
  218. snprintf(hwdep->name, sizeof(hwdep->name),
  219. "%s remote control", mixer->chip->card->shortname);
  220. hwdep->iface = SNDRV_HWDEP_IFACE_SB_RC;
  221. hwdep->private_data = mixer;
  222. hwdep->ops.read = snd_usb_sbrc_hwdep_read;
  223. hwdep->ops.poll = snd_usb_sbrc_hwdep_poll;
  224. hwdep->exclusive = 1;
  225. mixer->rc_urb = usb_alloc_urb(0, GFP_KERNEL);
  226. if (!mixer->rc_urb)
  227. return -ENOMEM;
  228. mixer->rc_setup_packet = kmalloc(sizeof(*mixer->rc_setup_packet), GFP_KERNEL);
  229. if (!mixer->rc_setup_packet) {
  230. usb_free_urb(mixer->rc_urb);
  231. mixer->rc_urb = NULL;
  232. return -ENOMEM;
  233. }
  234. mixer->rc_setup_packet->bRequestType =
  235. USB_DIR_IN | USB_TYPE_CLASS | USB_RECIP_INTERFACE;
  236. mixer->rc_setup_packet->bRequest = UAC_GET_MEM;
  237. mixer->rc_setup_packet->wValue = cpu_to_le16(0);
  238. mixer->rc_setup_packet->wIndex = cpu_to_le16(0);
  239. mixer->rc_setup_packet->wLength = cpu_to_le16(len);
  240. usb_fill_control_urb(mixer->rc_urb, mixer->chip->dev,
  241. usb_rcvctrlpipe(mixer->chip->dev, 0),
  242. (u8*)mixer->rc_setup_packet, mixer->rc_buffer, len,
  243. snd_usb_soundblaster_remote_complete, mixer);
  244. return 0;
  245. }
  246. #define snd_audigy2nx_led_info snd_ctl_boolean_mono_info
  247. static int snd_audigy2nx_led_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
  248. {
  249. struct usb_mixer_interface *mixer = snd_kcontrol_chip(kcontrol);
  250. int index = kcontrol->private_value;
  251. ucontrol->value.integer.value[0] = mixer->audigy2nx_leds[index];
  252. return 0;
  253. }
  254. static int snd_audigy2nx_led_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
  255. {
  256. struct usb_mixer_interface *mixer = snd_kcontrol_chip(kcontrol);
  257. int index = kcontrol->private_value;
  258. int value = ucontrol->value.integer.value[0];
  259. int err, changed;
  260. if (value > 1)
  261. return -EINVAL;
  262. changed = value != mixer->audigy2nx_leds[index];
  263. down_read(&mixer->chip->shutdown_rwsem);
  264. if (mixer->chip->shutdown) {
  265. err = -ENODEV;
  266. goto out;
  267. }
  268. if (mixer->chip->usb_id == USB_ID(0x041e, 0x3042))
  269. err = snd_usb_ctl_msg(mixer->chip->dev,
  270. usb_sndctrlpipe(mixer->chip->dev, 0), 0x24,
  271. USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_OTHER,
  272. !value, 0, NULL, 0);
  273. /* USB X-Fi S51 Pro */
  274. if (mixer->chip->usb_id == USB_ID(0x041e, 0x30df))
  275. err = snd_usb_ctl_msg(mixer->chip->dev,
  276. usb_sndctrlpipe(mixer->chip->dev, 0), 0x24,
  277. USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_OTHER,
  278. !value, 0, NULL, 0);
  279. else
  280. err = snd_usb_ctl_msg(mixer->chip->dev,
  281. usb_sndctrlpipe(mixer->chip->dev, 0), 0x24,
  282. USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_OTHER,
  283. value, index + 2, NULL, 0);
  284. out:
  285. up_read(&mixer->chip->shutdown_rwsem);
  286. if (err < 0)
  287. return err;
  288. mixer->audigy2nx_leds[index] = value;
  289. return changed;
  290. }
  291. static struct snd_kcontrol_new snd_audigy2nx_controls[] = {
  292. {
  293. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  294. .name = "CMSS LED Switch",
  295. .info = snd_audigy2nx_led_info,
  296. .get = snd_audigy2nx_led_get,
  297. .put = snd_audigy2nx_led_put,
  298. .private_value = 0,
  299. },
  300. {
  301. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  302. .name = "Power LED Switch",
  303. .info = snd_audigy2nx_led_info,
  304. .get = snd_audigy2nx_led_get,
  305. .put = snd_audigy2nx_led_put,
  306. .private_value = 1,
  307. },
  308. {
  309. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  310. .name = "Dolby Digital LED Switch",
  311. .info = snd_audigy2nx_led_info,
  312. .get = snd_audigy2nx_led_get,
  313. .put = snd_audigy2nx_led_put,
  314. .private_value = 2,
  315. },
  316. };
  317. static int snd_audigy2nx_controls_create(struct usb_mixer_interface *mixer)
  318. {
  319. int i, err;
  320. for (i = 0; i < ARRAY_SIZE(snd_audigy2nx_controls); ++i) {
  321. /* USB X-Fi S51 doesn't have a CMSS LED */
  322. if ((mixer->chip->usb_id == USB_ID(0x041e, 0x3042)) && i == 0)
  323. continue;
  324. /* USB X-Fi S51 Pro doesn't have one either */
  325. if ((mixer->chip->usb_id == USB_ID(0x041e, 0x30df)) && i == 0)
  326. continue;
  327. if (i > 1 && /* Live24ext has 2 LEDs only */
  328. (mixer->chip->usb_id == USB_ID(0x041e, 0x3040) ||
  329. mixer->chip->usb_id == USB_ID(0x041e, 0x3042) ||
  330. mixer->chip->usb_id == USB_ID(0x041e, 0x30df) ||
  331. mixer->chip->usb_id == USB_ID(0x041e, 0x3048)))
  332. break;
  333. err = snd_ctl_add(mixer->chip->card,
  334. snd_ctl_new1(&snd_audigy2nx_controls[i], mixer));
  335. if (err < 0)
  336. return err;
  337. }
  338. mixer->audigy2nx_leds[1] = 1; /* Power LED is on by default */
  339. return 0;
  340. }
  341. static void snd_audigy2nx_proc_read(struct snd_info_entry *entry,
  342. struct snd_info_buffer *buffer)
  343. {
  344. static const struct sb_jack {
  345. int unitid;
  346. const char *name;
  347. } jacks_audigy2nx[] = {
  348. {4, "dig in "},
  349. {7, "line in"},
  350. {19, "spk out"},
  351. {20, "hph out"},
  352. {-1, NULL}
  353. }, jacks_live24ext[] = {
  354. {4, "line in"}, /* &1=Line, &2=Mic*/
  355. {3, "hph out"}, /* headphones */
  356. {0, "RC "}, /* last command, 6 bytes see rc_config above */
  357. {-1, NULL}
  358. };
  359. const struct sb_jack *jacks;
  360. struct usb_mixer_interface *mixer = entry->private_data;
  361. int i, err;
  362. u8 buf[3];
  363. snd_iprintf(buffer, "%s jacks\n\n", mixer->chip->card->shortname);
  364. if (mixer->chip->usb_id == USB_ID(0x041e, 0x3020))
  365. jacks = jacks_audigy2nx;
  366. else if (mixer->chip->usb_id == USB_ID(0x041e, 0x3040) ||
  367. mixer->chip->usb_id == USB_ID(0x041e, 0x3048))
  368. jacks = jacks_live24ext;
  369. else
  370. return;
  371. for (i = 0; jacks[i].name; ++i) {
  372. snd_iprintf(buffer, "%s: ", jacks[i].name);
  373. down_read(&mixer->chip->shutdown_rwsem);
  374. if (mixer->chip->shutdown)
  375. err = 0;
  376. else
  377. err = snd_usb_ctl_msg(mixer->chip->dev,
  378. usb_rcvctrlpipe(mixer->chip->dev, 0),
  379. UAC_GET_MEM, USB_DIR_IN | USB_TYPE_CLASS |
  380. USB_RECIP_INTERFACE, 0,
  381. jacks[i].unitid << 8, buf, 3);
  382. up_read(&mixer->chip->shutdown_rwsem);
  383. if (err == 3 && (buf[0] == 3 || buf[0] == 6))
  384. snd_iprintf(buffer, "%02x %02x\n", buf[1], buf[2]);
  385. else
  386. snd_iprintf(buffer, "?\n");
  387. }
  388. }
  389. static int snd_xonar_u1_switch_get(struct snd_kcontrol *kcontrol,
  390. struct snd_ctl_elem_value *ucontrol)
  391. {
  392. struct usb_mixer_interface *mixer = snd_kcontrol_chip(kcontrol);
  393. ucontrol->value.integer.value[0] = !!(mixer->xonar_u1_status & 0x02);
  394. return 0;
  395. }
  396. static int snd_xonar_u1_switch_put(struct snd_kcontrol *kcontrol,
  397. struct snd_ctl_elem_value *ucontrol)
  398. {
  399. struct usb_mixer_interface *mixer = snd_kcontrol_chip(kcontrol);
  400. u8 old_status, new_status;
  401. int err, changed;
  402. old_status = mixer->xonar_u1_status;
  403. if (ucontrol->value.integer.value[0])
  404. new_status = old_status | 0x02;
  405. else
  406. new_status = old_status & ~0x02;
  407. changed = new_status != old_status;
  408. down_read(&mixer->chip->shutdown_rwsem);
  409. if (mixer->chip->shutdown)
  410. err = -ENODEV;
  411. else
  412. err = snd_usb_ctl_msg(mixer->chip->dev,
  413. usb_sndctrlpipe(mixer->chip->dev, 0), 0x08,
  414. USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_OTHER,
  415. 50, 0, &new_status, 1);
  416. up_read(&mixer->chip->shutdown_rwsem);
  417. if (err < 0)
  418. return err;
  419. mixer->xonar_u1_status = new_status;
  420. return changed;
  421. }
  422. static struct snd_kcontrol_new snd_xonar_u1_output_switch = {
  423. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  424. .name = "Digital Playback Switch",
  425. .info = snd_ctl_boolean_mono_info,
  426. .get = snd_xonar_u1_switch_get,
  427. .put = snd_xonar_u1_switch_put,
  428. };
  429. static int snd_xonar_u1_controls_create(struct usb_mixer_interface *mixer)
  430. {
  431. int err;
  432. err = snd_ctl_add(mixer->chip->card,
  433. snd_ctl_new1(&snd_xonar_u1_output_switch, mixer));
  434. if (err < 0)
  435. return err;
  436. mixer->xonar_u1_status = 0x05;
  437. return 0;
  438. }
  439. /* Native Instruments device quirks */
  440. #define _MAKE_NI_CONTROL(bRequest,wIndex) ((bRequest) << 16 | (wIndex))
  441. static int snd_nativeinstruments_control_get(struct snd_kcontrol *kcontrol,
  442. struct snd_ctl_elem_value *ucontrol)
  443. {
  444. struct usb_mixer_interface *mixer = snd_kcontrol_chip(kcontrol);
  445. struct usb_device *dev = mixer->chip->dev;
  446. u8 bRequest = (kcontrol->private_value >> 16) & 0xff;
  447. u16 wIndex = kcontrol->private_value & 0xffff;
  448. u8 tmp;
  449. int ret;
  450. down_read(&mixer->chip->shutdown_rwsem);
  451. if (mixer->chip->shutdown)
  452. ret = -ENODEV;
  453. else
  454. ret = usb_control_msg(dev, usb_rcvctrlpipe(dev, 0), bRequest,
  455. USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_IN,
  456. 0, cpu_to_le16(wIndex),
  457. &tmp, sizeof(tmp), 1000);
  458. up_read(&mixer->chip->shutdown_rwsem);
  459. if (ret < 0) {
  460. snd_printk(KERN_ERR
  461. "unable to issue vendor read request (ret = %d)", ret);
  462. return ret;
  463. }
  464. ucontrol->value.integer.value[0] = tmp;
  465. return 0;
  466. }
  467. static int snd_nativeinstruments_control_put(struct snd_kcontrol *kcontrol,
  468. struct snd_ctl_elem_value *ucontrol)
  469. {
  470. struct usb_mixer_interface *mixer = snd_kcontrol_chip(kcontrol);
  471. struct usb_device *dev = mixer->chip->dev;
  472. u8 bRequest = (kcontrol->private_value >> 16) & 0xff;
  473. u16 wIndex = kcontrol->private_value & 0xffff;
  474. u16 wValue = ucontrol->value.integer.value[0];
  475. int ret;
  476. down_read(&mixer->chip->shutdown_rwsem);
  477. if (mixer->chip->shutdown)
  478. ret = -ENODEV;
  479. else
  480. ret = usb_control_msg(dev, usb_sndctrlpipe(dev, 0), bRequest,
  481. USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_OUT,
  482. cpu_to_le16(wValue), cpu_to_le16(wIndex),
  483. NULL, 0, 1000);
  484. up_read(&mixer->chip->shutdown_rwsem);
  485. if (ret < 0) {
  486. snd_printk(KERN_ERR
  487. "unable to issue vendor write request (ret = %d)", ret);
  488. return ret;
  489. }
  490. return 0;
  491. }
  492. static struct snd_kcontrol_new snd_nativeinstruments_ta6_mixers[] = {
  493. {
  494. .name = "Direct Thru Channel A",
  495. .private_value = _MAKE_NI_CONTROL(0x01, 0x03),
  496. },
  497. {
  498. .name = "Direct Thru Channel B",
  499. .private_value = _MAKE_NI_CONTROL(0x01, 0x05),
  500. },
  501. {
  502. .name = "Phono Input Channel A",
  503. .private_value = _MAKE_NI_CONTROL(0x02, 0x03),
  504. },
  505. {
  506. .name = "Phono Input Channel B",
  507. .private_value = _MAKE_NI_CONTROL(0x02, 0x05),
  508. },
  509. };
  510. static struct snd_kcontrol_new snd_nativeinstruments_ta10_mixers[] = {
  511. {
  512. .name = "Direct Thru Channel A",
  513. .private_value = _MAKE_NI_CONTROL(0x01, 0x03),
  514. },
  515. {
  516. .name = "Direct Thru Channel B",
  517. .private_value = _MAKE_NI_CONTROL(0x01, 0x05),
  518. },
  519. {
  520. .name = "Direct Thru Channel C",
  521. .private_value = _MAKE_NI_CONTROL(0x01, 0x07),
  522. },
  523. {
  524. .name = "Direct Thru Channel D",
  525. .private_value = _MAKE_NI_CONTROL(0x01, 0x09),
  526. },
  527. {
  528. .name = "Phono Input Channel A",
  529. .private_value = _MAKE_NI_CONTROL(0x02, 0x03),
  530. },
  531. {
  532. .name = "Phono Input Channel B",
  533. .private_value = _MAKE_NI_CONTROL(0x02, 0x05),
  534. },
  535. {
  536. .name = "Phono Input Channel C",
  537. .private_value = _MAKE_NI_CONTROL(0x02, 0x07),
  538. },
  539. {
  540. .name = "Phono Input Channel D",
  541. .private_value = _MAKE_NI_CONTROL(0x02, 0x09),
  542. },
  543. };
  544. static int snd_nativeinstruments_create_mixer(struct usb_mixer_interface *mixer,
  545. const struct snd_kcontrol_new *kc,
  546. unsigned int count)
  547. {
  548. int i, err = 0;
  549. struct snd_kcontrol_new template = {
  550. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  551. .access = SNDRV_CTL_ELEM_ACCESS_READWRITE,
  552. .get = snd_nativeinstruments_control_get,
  553. .put = snd_nativeinstruments_control_put,
  554. .info = snd_ctl_boolean_mono_info,
  555. };
  556. for (i = 0; i < count; i++) {
  557. struct snd_kcontrol *c;
  558. template.name = kc[i].name;
  559. template.private_value = kc[i].private_value;
  560. c = snd_ctl_new1(&template, mixer);
  561. err = snd_ctl_add(mixer->chip->card, c);
  562. if (err < 0)
  563. break;
  564. }
  565. return err;
  566. }
  567. /* M-Audio FastTrack Ultra quirks */
  568. /* FTU Effect switch (also used by C400) */
  569. struct snd_ftu_eff_switch_priv_val {
  570. struct usb_mixer_interface *mixer;
  571. int cached_value;
  572. int is_cached;
  573. int bUnitID;
  574. int validx;
  575. };
  576. static int snd_ftu_eff_switch_info(struct snd_kcontrol *kcontrol,
  577. struct snd_ctl_elem_info *uinfo)
  578. {
  579. static const char *texts[8] = {"Room 1",
  580. "Room 2",
  581. "Room 3",
  582. "Hall 1",
  583. "Hall 2",
  584. "Plate",
  585. "Delay",
  586. "Echo"
  587. };
  588. uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
  589. uinfo->count = 1;
  590. uinfo->value.enumerated.items = 8;
  591. if (uinfo->value.enumerated.item > 7)
  592. uinfo->value.enumerated.item = 7;
  593. strcpy(uinfo->value.enumerated.name,
  594. texts[uinfo->value.enumerated.item]);
  595. return 0;
  596. }
  597. static int snd_ftu_eff_switch_get(struct snd_kcontrol *kctl,
  598. struct snd_ctl_elem_value *ucontrol)
  599. {
  600. struct snd_usb_audio *chip;
  601. struct usb_mixer_interface *mixer;
  602. struct snd_ftu_eff_switch_priv_val *pval;
  603. int err;
  604. unsigned char value[2];
  605. int id, validx;
  606. const int val_len = 2;
  607. value[0] = 0x00;
  608. value[1] = 0x00;
  609. pval = (struct snd_ftu_eff_switch_priv_val *)
  610. kctl->private_value;
  611. if (pval->is_cached) {
  612. ucontrol->value.enumerated.item[0] = pval->cached_value;
  613. return 0;
  614. }
  615. mixer = (struct usb_mixer_interface *) pval->mixer;
  616. if (snd_BUG_ON(!mixer))
  617. return -EINVAL;
  618. chip = (struct snd_usb_audio *) mixer->chip;
  619. if (snd_BUG_ON(!chip))
  620. return -EINVAL;
  621. id = pval->bUnitID;
  622. validx = pval->validx;
  623. down_read(&mixer->chip->shutdown_rwsem);
  624. if (mixer->chip->shutdown)
  625. err = -ENODEV;
  626. else
  627. err = snd_usb_ctl_msg(chip->dev,
  628. usb_rcvctrlpipe(chip->dev, 0), UAC_GET_CUR,
  629. USB_RECIP_INTERFACE | USB_TYPE_CLASS | USB_DIR_IN,
  630. validx << 8, snd_usb_ctrl_intf(chip) | (id << 8),
  631. value, val_len);
  632. up_read(&mixer->chip->shutdown_rwsem);
  633. if (err < 0)
  634. return err;
  635. ucontrol->value.enumerated.item[0] = value[0];
  636. pval->cached_value = value[0];
  637. pval->is_cached = 1;
  638. return 0;
  639. }
  640. static int snd_ftu_eff_switch_put(struct snd_kcontrol *kctl,
  641. struct snd_ctl_elem_value *ucontrol)
  642. {
  643. struct snd_usb_audio *chip;
  644. struct snd_ftu_eff_switch_priv_val *pval;
  645. struct usb_mixer_interface *mixer;
  646. int changed, cur_val, err, new_val;
  647. unsigned char value[2];
  648. int id, validx;
  649. const int val_len = 2;
  650. changed = 0;
  651. pval = (struct snd_ftu_eff_switch_priv_val *)
  652. kctl->private_value;
  653. cur_val = pval->cached_value;
  654. new_val = ucontrol->value.enumerated.item[0];
  655. mixer = (struct usb_mixer_interface *) pval->mixer;
  656. if (snd_BUG_ON(!mixer))
  657. return -EINVAL;
  658. chip = (struct snd_usb_audio *) mixer->chip;
  659. if (snd_BUG_ON(!chip))
  660. return -EINVAL;
  661. id = pval->bUnitID;
  662. validx = pval->validx;
  663. if (!pval->is_cached) {
  664. /* Read current value */
  665. down_read(&mixer->chip->shutdown_rwsem);
  666. if (mixer->chip->shutdown)
  667. err = -ENODEV;
  668. else
  669. err = snd_usb_ctl_msg(chip->dev,
  670. usb_rcvctrlpipe(chip->dev, 0), UAC_GET_CUR,
  671. USB_RECIP_INTERFACE | USB_TYPE_CLASS | USB_DIR_IN,
  672. validx << 8, snd_usb_ctrl_intf(chip) | (id << 8),
  673. value, val_len);
  674. up_read(&mixer->chip->shutdown_rwsem);
  675. if (err < 0)
  676. return err;
  677. cur_val = value[0];
  678. pval->cached_value = cur_val;
  679. pval->is_cached = 1;
  680. }
  681. /* update value if needed */
  682. if (cur_val != new_val) {
  683. value[0] = new_val;
  684. value[1] = 0;
  685. down_read(&mixer->chip->shutdown_rwsem);
  686. if (mixer->chip->shutdown)
  687. err = -ENODEV;
  688. else
  689. err = snd_usb_ctl_msg(chip->dev,
  690. usb_sndctrlpipe(chip->dev, 0), UAC_SET_CUR,
  691. USB_RECIP_INTERFACE | USB_TYPE_CLASS | USB_DIR_OUT,
  692. validx << 8, snd_usb_ctrl_intf(chip) | (id << 8),
  693. value, val_len);
  694. up_read(&mixer->chip->shutdown_rwsem);
  695. if (err < 0)
  696. return err;
  697. pval->cached_value = new_val;
  698. pval->is_cached = 1;
  699. changed = 1;
  700. }
  701. return changed;
  702. }
  703. static int snd_ftu_create_effect_switch(struct usb_mixer_interface *mixer,
  704. int validx, int bUnitID)
  705. {
  706. static struct snd_kcontrol_new template = {
  707. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  708. .name = "Effect Program Switch",
  709. .index = 0,
  710. .access = SNDRV_CTL_ELEM_ACCESS_READWRITE,
  711. .info = snd_ftu_eff_switch_info,
  712. .get = snd_ftu_eff_switch_get,
  713. .put = snd_ftu_eff_switch_put
  714. };
  715. int err;
  716. struct snd_kcontrol *kctl;
  717. struct snd_ftu_eff_switch_priv_val *pval;
  718. pval = kzalloc(sizeof(*pval), GFP_KERNEL);
  719. if (!pval)
  720. return -ENOMEM;
  721. pval->cached_value = 0;
  722. pval->is_cached = 0;
  723. pval->mixer = mixer;
  724. pval->bUnitID = bUnitID;
  725. pval->validx = validx;
  726. template.private_value = (unsigned long) pval;
  727. kctl = snd_ctl_new1(&template, mixer->chip);
  728. if (!kctl) {
  729. kfree(pval);
  730. return -ENOMEM;
  731. }
  732. err = snd_ctl_add(mixer->chip->card, kctl);
  733. if (err < 0)
  734. return err;
  735. return 0;
  736. }
  737. /* Create volume controls for FTU devices*/
  738. static int snd_ftu_create_volume_ctls(struct usb_mixer_interface *mixer)
  739. {
  740. char name[64];
  741. unsigned int control, cmask;
  742. int in, out, err;
  743. const unsigned int id = 5;
  744. const int val_type = USB_MIXER_S16;
  745. for (out = 0; out < 8; out++) {
  746. control = out + 1;
  747. for (in = 0; in < 8; in++) {
  748. cmask = 1 << in;
  749. snprintf(name, sizeof(name),
  750. "AIn%d - Out%d Capture Volume",
  751. in + 1, out + 1);
  752. err = snd_create_std_mono_ctl(mixer, id, control,
  753. cmask, val_type, name,
  754. &snd_usb_mixer_vol_tlv);
  755. if (err < 0)
  756. return err;
  757. }
  758. for (in = 8; in < 16; in++) {
  759. cmask = 1 << in;
  760. snprintf(name, sizeof(name),
  761. "DIn%d - Out%d Playback Volume",
  762. in - 7, out + 1);
  763. err = snd_create_std_mono_ctl(mixer, id, control,
  764. cmask, val_type, name,
  765. &snd_usb_mixer_vol_tlv);
  766. if (err < 0)
  767. return err;
  768. }
  769. }
  770. return 0;
  771. }
  772. /* This control needs a volume quirk, see mixer.c */
  773. static int snd_ftu_create_effect_volume_ctl(struct usb_mixer_interface *mixer)
  774. {
  775. static const char name[] = "Effect Volume";
  776. const unsigned int id = 6;
  777. const int val_type = USB_MIXER_U8;
  778. const unsigned int control = 2;
  779. const unsigned int cmask = 0;
  780. return snd_create_std_mono_ctl(mixer, id, control, cmask, val_type,
  781. name, snd_usb_mixer_vol_tlv);
  782. }
  783. /* This control needs a volume quirk, see mixer.c */
  784. static int snd_ftu_create_effect_duration_ctl(struct usb_mixer_interface *mixer)
  785. {
  786. static const char name[] = "Effect Duration";
  787. const unsigned int id = 6;
  788. const int val_type = USB_MIXER_S16;
  789. const unsigned int control = 3;
  790. const unsigned int cmask = 0;
  791. return snd_create_std_mono_ctl(mixer, id, control, cmask, val_type,
  792. name, snd_usb_mixer_vol_tlv);
  793. }
  794. /* This control needs a volume quirk, see mixer.c */
  795. static int snd_ftu_create_effect_feedback_ctl(struct usb_mixer_interface *mixer)
  796. {
  797. static const char name[] = "Effect Feedback Volume";
  798. const unsigned int id = 6;
  799. const int val_type = USB_MIXER_U8;
  800. const unsigned int control = 4;
  801. const unsigned int cmask = 0;
  802. return snd_create_std_mono_ctl(mixer, id, control, cmask, val_type,
  803. name, NULL);
  804. }
  805. static int snd_ftu_create_effect_return_ctls(struct usb_mixer_interface *mixer)
  806. {
  807. unsigned int cmask;
  808. int err, ch;
  809. char name[48];
  810. const unsigned int id = 7;
  811. const int val_type = USB_MIXER_S16;
  812. const unsigned int control = 7;
  813. for (ch = 0; ch < 4; ++ch) {
  814. cmask = 1 << ch;
  815. snprintf(name, sizeof(name),
  816. "Effect Return %d Volume", ch + 1);
  817. err = snd_create_std_mono_ctl(mixer, id, control,
  818. cmask, val_type, name,
  819. snd_usb_mixer_vol_tlv);
  820. if (err < 0)
  821. return err;
  822. }
  823. return 0;
  824. }
  825. static int snd_ftu_create_effect_send_ctls(struct usb_mixer_interface *mixer)
  826. {
  827. unsigned int cmask;
  828. int err, ch;
  829. char name[48];
  830. const unsigned int id = 5;
  831. const int val_type = USB_MIXER_S16;
  832. const unsigned int control = 9;
  833. for (ch = 0; ch < 8; ++ch) {
  834. cmask = 1 << ch;
  835. snprintf(name, sizeof(name),
  836. "Effect Send AIn%d Volume", ch + 1);
  837. err = snd_create_std_mono_ctl(mixer, id, control, cmask,
  838. val_type, name,
  839. snd_usb_mixer_vol_tlv);
  840. if (err < 0)
  841. return err;
  842. }
  843. for (ch = 8; ch < 16; ++ch) {
  844. cmask = 1 << ch;
  845. snprintf(name, sizeof(name),
  846. "Effect Send DIn%d Volume", ch - 7);
  847. err = snd_create_std_mono_ctl(mixer, id, control, cmask,
  848. val_type, name,
  849. snd_usb_mixer_vol_tlv);
  850. if (err < 0)
  851. return err;
  852. }
  853. return 0;
  854. }
  855. static int snd_ftu_create_mixer(struct usb_mixer_interface *mixer)
  856. {
  857. int err;
  858. err = snd_ftu_create_volume_ctls(mixer);
  859. if (err < 0)
  860. return err;
  861. err = snd_ftu_create_effect_switch(mixer, 1, 6);
  862. if (err < 0)
  863. return err;
  864. err = snd_ftu_create_effect_volume_ctl(mixer);
  865. if (err < 0)
  866. return err;
  867. err = snd_ftu_create_effect_duration_ctl(mixer);
  868. if (err < 0)
  869. return err;
  870. err = snd_ftu_create_effect_feedback_ctl(mixer);
  871. if (err < 0)
  872. return err;
  873. err = snd_ftu_create_effect_return_ctls(mixer);
  874. if (err < 0)
  875. return err;
  876. err = snd_ftu_create_effect_send_ctls(mixer);
  877. if (err < 0)
  878. return err;
  879. return 0;
  880. }
  881. void snd_emuusb_set_samplerate(struct snd_usb_audio *chip,
  882. unsigned char samplerate_id)
  883. {
  884. struct usb_mixer_interface *mixer;
  885. struct usb_mixer_elem_info *cval;
  886. int unitid = 12; /* SamleRate ExtensionUnit ID */
  887. list_for_each_entry(mixer, &chip->mixer_list, list) {
  888. cval = mixer->id_elems[unitid];
  889. if (cval) {
  890. snd_usb_mixer_set_ctl_value(cval, UAC_SET_CUR,
  891. cval->control << 8,
  892. samplerate_id);
  893. snd_usb_mixer_notify_id(mixer, unitid);
  894. }
  895. break;
  896. }
  897. }
  898. /* M-Audio Fast Track C400 */
  899. /* C400 volume controls, this control needs a volume quirk, see mixer.c */
  900. static int snd_c400_create_vol_ctls(struct usb_mixer_interface *mixer)
  901. {
  902. char name[64];
  903. unsigned int cmask, offset;
  904. int out, chan, err;
  905. const unsigned int id = 0x40;
  906. const int val_type = USB_MIXER_S16;
  907. const int control = 1;
  908. for (chan = 0; chan < 10; chan++) {
  909. for (out = 0; out < 6; out++) {
  910. if (chan < 6) {
  911. snprintf(name, sizeof(name),
  912. "PCM%d-Out%d Playback Volume",
  913. chan + 1, out + 1);
  914. } else {
  915. snprintf(name, sizeof(name),
  916. "In%d-Out%d Playback Volume",
  917. chan - 5, out + 1);
  918. }
  919. cmask = (out == 0) ? 0 : 1 << (out - 1);
  920. offset = chan * 6;
  921. err = snd_create_std_mono_ctl_offset(mixer, id, control,
  922. cmask, val_type, offset, name,
  923. &snd_usb_mixer_vol_tlv);
  924. if (err < 0)
  925. return err;
  926. }
  927. }
  928. return 0;
  929. }
  930. /* This control needs a volume quirk, see mixer.c */
  931. static int snd_c400_create_effect_volume_ctl(struct usb_mixer_interface *mixer)
  932. {
  933. static const char name[] = "Effect Volume";
  934. const unsigned int id = 0x43;
  935. const int val_type = USB_MIXER_U8;
  936. const unsigned int control = 3;
  937. const unsigned int cmask = 0;
  938. return snd_create_std_mono_ctl(mixer, id, control, cmask, val_type,
  939. name, snd_usb_mixer_vol_tlv);
  940. }
  941. /* This control needs a volume quirk, see mixer.c */
  942. static int snd_c400_create_effect_duration_ctl(struct usb_mixer_interface *mixer)
  943. {
  944. static const char name[] = "Effect Duration";
  945. const unsigned int id = 0x43;
  946. const int val_type = USB_MIXER_S16;
  947. const unsigned int control = 4;
  948. const unsigned int cmask = 0;
  949. return snd_create_std_mono_ctl(mixer, id, control, cmask, val_type,
  950. name, snd_usb_mixer_vol_tlv);
  951. }
  952. /* This control needs a volume quirk, see mixer.c */
  953. static int snd_c400_create_effect_feedback_ctl(struct usb_mixer_interface *mixer)
  954. {
  955. static const char name[] = "Effect Feedback Volume";
  956. const unsigned int id = 0x43;
  957. const int val_type = USB_MIXER_U8;
  958. const unsigned int control = 5;
  959. const unsigned int cmask = 0;
  960. return snd_create_std_mono_ctl(mixer, id, control, cmask, val_type,
  961. name, NULL);
  962. }
  963. static int snd_c400_create_effect_vol_ctls(struct usb_mixer_interface *mixer)
  964. {
  965. char name[64];
  966. unsigned int cmask;
  967. int chan, err;
  968. const unsigned int id = 0x42;
  969. const int val_type = USB_MIXER_S16;
  970. const int control = 1;
  971. for (chan = 0; chan < 10; chan++) {
  972. if (chan < 6) {
  973. snprintf(name, sizeof(name),
  974. "Effect Send DOut%d",
  975. chan + 1);
  976. } else {
  977. snprintf(name, sizeof(name),
  978. "Effect Send AIn%d",
  979. chan - 5);
  980. }
  981. cmask = (chan == 0) ? 0 : 1 << (chan - 1);
  982. err = snd_create_std_mono_ctl(mixer, id, control,
  983. cmask, val_type, name,
  984. &snd_usb_mixer_vol_tlv);
  985. if (err < 0)
  986. return err;
  987. }
  988. return 0;
  989. }
  990. static int snd_c400_create_effect_ret_vol_ctls(struct usb_mixer_interface *mixer)
  991. {
  992. char name[64];
  993. unsigned int cmask;
  994. int chan, err;
  995. const unsigned int id = 0x40;
  996. const int val_type = USB_MIXER_S16;
  997. const int control = 1;
  998. const int chan_id[6] = { 0, 7, 2, 9, 4, 0xb };
  999. const unsigned int offset = 0x3c;
  1000. /* { 0x3c, 0x43, 0x3e, 0x45, 0x40, 0x47 } */
  1001. for (chan = 0; chan < 6; chan++) {
  1002. snprintf(name, sizeof(name),
  1003. "Effect Return %d",
  1004. chan + 1);
  1005. cmask = (chan_id[chan] == 0) ? 0 : 1 << (chan_id[chan] - 1);
  1006. err = snd_create_std_mono_ctl_offset(mixer, id, control,
  1007. cmask, val_type, offset, name,
  1008. &snd_usb_mixer_vol_tlv);
  1009. if (err < 0)
  1010. return err;
  1011. }
  1012. return 0;
  1013. }
  1014. static int snd_c400_create_mixer(struct usb_mixer_interface *mixer)
  1015. {
  1016. int err;
  1017. err = snd_c400_create_vol_ctls(mixer);
  1018. if (err < 0)
  1019. return err;
  1020. err = snd_c400_create_effect_vol_ctls(mixer);
  1021. if (err < 0)
  1022. return err;
  1023. err = snd_c400_create_effect_ret_vol_ctls(mixer);
  1024. if (err < 0)
  1025. return err;
  1026. err = snd_ftu_create_effect_switch(mixer, 2, 0x43);
  1027. if (err < 0)
  1028. return err;
  1029. err = snd_c400_create_effect_volume_ctl(mixer);
  1030. if (err < 0)
  1031. return err;
  1032. err = snd_c400_create_effect_duration_ctl(mixer);
  1033. if (err < 0)
  1034. return err;
  1035. err = snd_c400_create_effect_feedback_ctl(mixer);
  1036. if (err < 0)
  1037. return err;
  1038. return 0;
  1039. }
  1040. /*
  1041. * The mixer units for Ebox-44 are corrupt, and even where they
  1042. * are valid they presents mono controls as L and R channels of
  1043. * stereo. So we provide a good mixer here.
  1044. */
  1045. struct std_mono_table ebox44_table[] = {
  1046. {
  1047. .unitid = 4,
  1048. .control = 1,
  1049. .cmask = 0x0,
  1050. .val_type = USB_MIXER_INV_BOOLEAN,
  1051. .name = "Headphone Playback Switch"
  1052. },
  1053. {
  1054. .unitid = 4,
  1055. .control = 2,
  1056. .cmask = 0x1,
  1057. .val_type = USB_MIXER_S16,
  1058. .name = "Headphone A Mix Playback Volume"
  1059. },
  1060. {
  1061. .unitid = 4,
  1062. .control = 2,
  1063. .cmask = 0x2,
  1064. .val_type = USB_MIXER_S16,
  1065. .name = "Headphone B Mix Playback Volume"
  1066. },
  1067. {
  1068. .unitid = 7,
  1069. .control = 1,
  1070. .cmask = 0x0,
  1071. .val_type = USB_MIXER_INV_BOOLEAN,
  1072. .name = "Output Playback Switch"
  1073. },
  1074. {
  1075. .unitid = 7,
  1076. .control = 2,
  1077. .cmask = 0x1,
  1078. .val_type = USB_MIXER_S16,
  1079. .name = "Output A Playback Volume"
  1080. },
  1081. {
  1082. .unitid = 7,
  1083. .control = 2,
  1084. .cmask = 0x2,
  1085. .val_type = USB_MIXER_S16,
  1086. .name = "Output B Playback Volume"
  1087. },
  1088. {
  1089. .unitid = 10,
  1090. .control = 1,
  1091. .cmask = 0x0,
  1092. .val_type = USB_MIXER_INV_BOOLEAN,
  1093. .name = "Input Capture Switch"
  1094. },
  1095. {
  1096. .unitid = 10,
  1097. .control = 2,
  1098. .cmask = 0x1,
  1099. .val_type = USB_MIXER_S16,
  1100. .name = "Input A Capture Volume"
  1101. },
  1102. {
  1103. .unitid = 10,
  1104. .control = 2,
  1105. .cmask = 0x2,
  1106. .val_type = USB_MIXER_S16,
  1107. .name = "Input B Capture Volume"
  1108. },
  1109. {}
  1110. };
  1111. int snd_usb_mixer_apply_create_quirk(struct usb_mixer_interface *mixer)
  1112. {
  1113. int err = 0;
  1114. struct snd_info_entry *entry;
  1115. if ((err = snd_usb_soundblaster_remote_init(mixer)) < 0)
  1116. return err;
  1117. switch (mixer->chip->usb_id) {
  1118. case USB_ID(0x041e, 0x3020):
  1119. case USB_ID(0x041e, 0x3040):
  1120. case USB_ID(0x041e, 0x3042):
  1121. case USB_ID(0x041e, 0x30df):
  1122. case USB_ID(0x041e, 0x3048):
  1123. err = snd_audigy2nx_controls_create(mixer);
  1124. if (err < 0)
  1125. break;
  1126. if (!snd_card_proc_new(mixer->chip->card, "audigy2nx", &entry))
  1127. snd_info_set_text_ops(entry, mixer,
  1128. snd_audigy2nx_proc_read);
  1129. break;
  1130. case USB_ID(0x0763, 0x2030): /* M-Audio Fast Track C400 */
  1131. err = snd_c400_create_mixer(mixer);
  1132. break;
  1133. case USB_ID(0x0763, 0x2080): /* M-Audio Fast Track Ultra */
  1134. case USB_ID(0x0763, 0x2081): /* M-Audio Fast Track Ultra 8R */
  1135. err = snd_ftu_create_mixer(mixer);
  1136. break;
  1137. case USB_ID(0x0b05, 0x1739):
  1138. case USB_ID(0x0b05, 0x1743):
  1139. err = snd_xonar_u1_controls_create(mixer);
  1140. break;
  1141. case USB_ID(0x17cc, 0x1011): /* Traktor Audio 6 */
  1142. err = snd_nativeinstruments_create_mixer(mixer,
  1143. snd_nativeinstruments_ta6_mixers,
  1144. ARRAY_SIZE(snd_nativeinstruments_ta6_mixers));
  1145. break;
  1146. case USB_ID(0x17cc, 0x1021): /* Traktor Audio 10 */
  1147. err = snd_nativeinstruments_create_mixer(mixer,
  1148. snd_nativeinstruments_ta10_mixers,
  1149. ARRAY_SIZE(snd_nativeinstruments_ta10_mixers));
  1150. break;
  1151. case USB_ID(0x200c, 0x1018): /* Electrix Ebox-44 */
  1152. /* detection is disabled in mixer_maps.c */
  1153. err = snd_create_std_mono_table(mixer, ebox44_table);
  1154. break;
  1155. }
  1156. return err;
  1157. }
  1158. void snd_usb_mixer_rc_memory_change(struct usb_mixer_interface *mixer,
  1159. int unitid)
  1160. {
  1161. if (!mixer->rc_cfg)
  1162. return;
  1163. /* unit ids specific to Extigy/Audigy 2 NX: */
  1164. switch (unitid) {
  1165. case 0: /* remote control */
  1166. mixer->rc_urb->dev = mixer->chip->dev;
  1167. usb_submit_urb(mixer->rc_urb, GFP_ATOMIC);
  1168. break;
  1169. case 4: /* digital in jack */
  1170. case 7: /* line in jacks */
  1171. case 19: /* speaker out jacks */
  1172. case 20: /* headphones out jack */
  1173. break;
  1174. /* live24ext: 4 = line-in jack */
  1175. case 3: /* hp-out jack (may actuate Mute) */
  1176. if (mixer->chip->usb_id == USB_ID(0x041e, 0x3040) ||
  1177. mixer->chip->usb_id == USB_ID(0x041e, 0x3048))
  1178. snd_usb_mixer_notify_id(mixer, mixer->rc_cfg->mute_mixer_id);
  1179. break;
  1180. default:
  1181. snd_printd(KERN_DEBUG "memory change in unknown unit %d\n", unitid);
  1182. break;
  1183. }
  1184. }