mixer_quirks.c 34 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364
  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. /* ASUS Xonar U1 / U3 controls */
  390. static int snd_xonar_u1_switch_get(struct snd_kcontrol *kcontrol,
  391. struct snd_ctl_elem_value *ucontrol)
  392. {
  393. struct usb_mixer_interface *mixer = snd_kcontrol_chip(kcontrol);
  394. ucontrol->value.integer.value[0] = !!(mixer->xonar_u1_status & 0x02);
  395. return 0;
  396. }
  397. static int snd_xonar_u1_switch_put(struct snd_kcontrol *kcontrol,
  398. struct snd_ctl_elem_value *ucontrol)
  399. {
  400. struct usb_mixer_interface *mixer = snd_kcontrol_chip(kcontrol);
  401. u8 old_status, new_status;
  402. int err, changed;
  403. old_status = mixer->xonar_u1_status;
  404. if (ucontrol->value.integer.value[0])
  405. new_status = old_status | 0x02;
  406. else
  407. new_status = old_status & ~0x02;
  408. changed = new_status != old_status;
  409. down_read(&mixer->chip->shutdown_rwsem);
  410. if (mixer->chip->shutdown)
  411. err = -ENODEV;
  412. else
  413. err = snd_usb_ctl_msg(mixer->chip->dev,
  414. usb_sndctrlpipe(mixer->chip->dev, 0), 0x08,
  415. USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_OTHER,
  416. 50, 0, &new_status, 1);
  417. up_read(&mixer->chip->shutdown_rwsem);
  418. if (err < 0)
  419. return err;
  420. mixer->xonar_u1_status = new_status;
  421. return changed;
  422. }
  423. static struct snd_kcontrol_new snd_xonar_u1_output_switch = {
  424. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  425. .name = "Digital Playback Switch",
  426. .info = snd_ctl_boolean_mono_info,
  427. .get = snd_xonar_u1_switch_get,
  428. .put = snd_xonar_u1_switch_put,
  429. };
  430. static int snd_xonar_u1_controls_create(struct usb_mixer_interface *mixer)
  431. {
  432. int err;
  433. err = snd_ctl_add(mixer->chip->card,
  434. snd_ctl_new1(&snd_xonar_u1_output_switch, mixer));
  435. if (err < 0)
  436. return err;
  437. mixer->xonar_u1_status = 0x05;
  438. return 0;
  439. }
  440. /* Native Instruments device quirks */
  441. #define _MAKE_NI_CONTROL(bRequest,wIndex) ((bRequest) << 16 | (wIndex))
  442. static int snd_nativeinstruments_control_get(struct snd_kcontrol *kcontrol,
  443. struct snd_ctl_elem_value *ucontrol)
  444. {
  445. struct usb_mixer_interface *mixer = snd_kcontrol_chip(kcontrol);
  446. struct usb_device *dev = mixer->chip->dev;
  447. u8 bRequest = (kcontrol->private_value >> 16) & 0xff;
  448. u16 wIndex = kcontrol->private_value & 0xffff;
  449. u8 tmp;
  450. int ret;
  451. down_read(&mixer->chip->shutdown_rwsem);
  452. if (mixer->chip->shutdown)
  453. ret = -ENODEV;
  454. else
  455. ret = usb_control_msg(dev, usb_rcvctrlpipe(dev, 0), bRequest,
  456. USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_IN,
  457. 0, cpu_to_le16(wIndex),
  458. &tmp, sizeof(tmp), 1000);
  459. up_read(&mixer->chip->shutdown_rwsem);
  460. if (ret < 0) {
  461. snd_printk(KERN_ERR
  462. "unable to issue vendor read request (ret = %d)", ret);
  463. return ret;
  464. }
  465. ucontrol->value.integer.value[0] = tmp;
  466. return 0;
  467. }
  468. static int snd_nativeinstruments_control_put(struct snd_kcontrol *kcontrol,
  469. struct snd_ctl_elem_value *ucontrol)
  470. {
  471. struct usb_mixer_interface *mixer = snd_kcontrol_chip(kcontrol);
  472. struct usb_device *dev = mixer->chip->dev;
  473. u8 bRequest = (kcontrol->private_value >> 16) & 0xff;
  474. u16 wIndex = kcontrol->private_value & 0xffff;
  475. u16 wValue = ucontrol->value.integer.value[0];
  476. int ret;
  477. down_read(&mixer->chip->shutdown_rwsem);
  478. if (mixer->chip->shutdown)
  479. ret = -ENODEV;
  480. else
  481. ret = usb_control_msg(dev, usb_sndctrlpipe(dev, 0), bRequest,
  482. USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_OUT,
  483. cpu_to_le16(wValue), cpu_to_le16(wIndex),
  484. NULL, 0, 1000);
  485. up_read(&mixer->chip->shutdown_rwsem);
  486. if (ret < 0) {
  487. snd_printk(KERN_ERR
  488. "unable to issue vendor write request (ret = %d)", ret);
  489. return ret;
  490. }
  491. return 0;
  492. }
  493. static struct snd_kcontrol_new snd_nativeinstruments_ta6_mixers[] = {
  494. {
  495. .name = "Direct Thru Channel A",
  496. .private_value = _MAKE_NI_CONTROL(0x01, 0x03),
  497. },
  498. {
  499. .name = "Direct Thru Channel B",
  500. .private_value = _MAKE_NI_CONTROL(0x01, 0x05),
  501. },
  502. {
  503. .name = "Phono Input Channel A",
  504. .private_value = _MAKE_NI_CONTROL(0x02, 0x03),
  505. },
  506. {
  507. .name = "Phono Input Channel B",
  508. .private_value = _MAKE_NI_CONTROL(0x02, 0x05),
  509. },
  510. };
  511. static struct snd_kcontrol_new snd_nativeinstruments_ta10_mixers[] = {
  512. {
  513. .name = "Direct Thru Channel A",
  514. .private_value = _MAKE_NI_CONTROL(0x01, 0x03),
  515. },
  516. {
  517. .name = "Direct Thru Channel B",
  518. .private_value = _MAKE_NI_CONTROL(0x01, 0x05),
  519. },
  520. {
  521. .name = "Direct Thru Channel C",
  522. .private_value = _MAKE_NI_CONTROL(0x01, 0x07),
  523. },
  524. {
  525. .name = "Direct Thru Channel D",
  526. .private_value = _MAKE_NI_CONTROL(0x01, 0x09),
  527. },
  528. {
  529. .name = "Phono Input Channel A",
  530. .private_value = _MAKE_NI_CONTROL(0x02, 0x03),
  531. },
  532. {
  533. .name = "Phono Input Channel B",
  534. .private_value = _MAKE_NI_CONTROL(0x02, 0x05),
  535. },
  536. {
  537. .name = "Phono Input Channel C",
  538. .private_value = _MAKE_NI_CONTROL(0x02, 0x07),
  539. },
  540. {
  541. .name = "Phono Input Channel D",
  542. .private_value = _MAKE_NI_CONTROL(0x02, 0x09),
  543. },
  544. };
  545. static int snd_nativeinstruments_create_mixer(struct usb_mixer_interface *mixer,
  546. const struct snd_kcontrol_new *kc,
  547. unsigned int count)
  548. {
  549. int i, err = 0;
  550. struct snd_kcontrol_new template = {
  551. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  552. .access = SNDRV_CTL_ELEM_ACCESS_READWRITE,
  553. .get = snd_nativeinstruments_control_get,
  554. .put = snd_nativeinstruments_control_put,
  555. .info = snd_ctl_boolean_mono_info,
  556. };
  557. for (i = 0; i < count; i++) {
  558. struct snd_kcontrol *c;
  559. template.name = kc[i].name;
  560. template.private_value = kc[i].private_value;
  561. c = snd_ctl_new1(&template, mixer);
  562. err = snd_ctl_add(mixer->chip->card, c);
  563. if (err < 0)
  564. break;
  565. }
  566. return err;
  567. }
  568. /* M-Audio FastTrack Ultra quirks */
  569. /* FTU Effect switch (also used by C400) */
  570. struct snd_ftu_eff_switch_priv_val {
  571. struct usb_mixer_interface *mixer;
  572. int cached_value;
  573. int is_cached;
  574. int bUnitID;
  575. int validx;
  576. };
  577. static int snd_ftu_eff_switch_info(struct snd_kcontrol *kcontrol,
  578. struct snd_ctl_elem_info *uinfo)
  579. {
  580. static const char *texts[8] = {"Room 1",
  581. "Room 2",
  582. "Room 3",
  583. "Hall 1",
  584. "Hall 2",
  585. "Plate",
  586. "Delay",
  587. "Echo"
  588. };
  589. uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
  590. uinfo->count = 1;
  591. uinfo->value.enumerated.items = 8;
  592. if (uinfo->value.enumerated.item > 7)
  593. uinfo->value.enumerated.item = 7;
  594. strcpy(uinfo->value.enumerated.name,
  595. texts[uinfo->value.enumerated.item]);
  596. return 0;
  597. }
  598. static int snd_ftu_eff_switch_get(struct snd_kcontrol *kctl,
  599. struct snd_ctl_elem_value *ucontrol)
  600. {
  601. struct snd_usb_audio *chip;
  602. struct usb_mixer_interface *mixer;
  603. struct snd_ftu_eff_switch_priv_val *pval;
  604. int err;
  605. unsigned char value[2];
  606. int id, validx;
  607. const int val_len = 2;
  608. value[0] = 0x00;
  609. value[1] = 0x00;
  610. pval = (struct snd_ftu_eff_switch_priv_val *)
  611. kctl->private_value;
  612. if (pval->is_cached) {
  613. ucontrol->value.enumerated.item[0] = pval->cached_value;
  614. return 0;
  615. }
  616. mixer = (struct usb_mixer_interface *) pval->mixer;
  617. if (snd_BUG_ON(!mixer))
  618. return -EINVAL;
  619. chip = (struct snd_usb_audio *) mixer->chip;
  620. if (snd_BUG_ON(!chip))
  621. return -EINVAL;
  622. id = pval->bUnitID;
  623. validx = pval->validx;
  624. down_read(&mixer->chip->shutdown_rwsem);
  625. if (mixer->chip->shutdown)
  626. err = -ENODEV;
  627. else
  628. err = snd_usb_ctl_msg(chip->dev,
  629. usb_rcvctrlpipe(chip->dev, 0), UAC_GET_CUR,
  630. USB_RECIP_INTERFACE | USB_TYPE_CLASS | USB_DIR_IN,
  631. validx << 8, snd_usb_ctrl_intf(chip) | (id << 8),
  632. value, val_len);
  633. up_read(&mixer->chip->shutdown_rwsem);
  634. if (err < 0)
  635. return err;
  636. ucontrol->value.enumerated.item[0] = value[0];
  637. pval->cached_value = value[0];
  638. pval->is_cached = 1;
  639. return 0;
  640. }
  641. static int snd_ftu_eff_switch_put(struct snd_kcontrol *kctl,
  642. struct snd_ctl_elem_value *ucontrol)
  643. {
  644. struct snd_usb_audio *chip;
  645. struct snd_ftu_eff_switch_priv_val *pval;
  646. struct usb_mixer_interface *mixer;
  647. int changed, cur_val, err, new_val;
  648. unsigned char value[2];
  649. int id, validx;
  650. const int val_len = 2;
  651. changed = 0;
  652. pval = (struct snd_ftu_eff_switch_priv_val *)
  653. kctl->private_value;
  654. cur_val = pval->cached_value;
  655. new_val = ucontrol->value.enumerated.item[0];
  656. mixer = (struct usb_mixer_interface *) pval->mixer;
  657. if (snd_BUG_ON(!mixer))
  658. return -EINVAL;
  659. chip = (struct snd_usb_audio *) mixer->chip;
  660. if (snd_BUG_ON(!chip))
  661. return -EINVAL;
  662. id = pval->bUnitID;
  663. validx = pval->validx;
  664. if (!pval->is_cached) {
  665. /* Read current value */
  666. down_read(&mixer->chip->shutdown_rwsem);
  667. if (mixer->chip->shutdown)
  668. err = -ENODEV;
  669. else
  670. err = snd_usb_ctl_msg(chip->dev,
  671. usb_rcvctrlpipe(chip->dev, 0), UAC_GET_CUR,
  672. USB_RECIP_INTERFACE | USB_TYPE_CLASS | USB_DIR_IN,
  673. validx << 8, snd_usb_ctrl_intf(chip) | (id << 8),
  674. value, val_len);
  675. up_read(&mixer->chip->shutdown_rwsem);
  676. if (err < 0)
  677. return err;
  678. cur_val = value[0];
  679. pval->cached_value = cur_val;
  680. pval->is_cached = 1;
  681. }
  682. /* update value if needed */
  683. if (cur_val != new_val) {
  684. value[0] = new_val;
  685. value[1] = 0;
  686. down_read(&mixer->chip->shutdown_rwsem);
  687. if (mixer->chip->shutdown)
  688. err = -ENODEV;
  689. else
  690. err = snd_usb_ctl_msg(chip->dev,
  691. usb_sndctrlpipe(chip->dev, 0), UAC_SET_CUR,
  692. USB_RECIP_INTERFACE | USB_TYPE_CLASS | USB_DIR_OUT,
  693. validx << 8, snd_usb_ctrl_intf(chip) | (id << 8),
  694. value, val_len);
  695. up_read(&mixer->chip->shutdown_rwsem);
  696. if (err < 0)
  697. return err;
  698. pval->cached_value = new_val;
  699. pval->is_cached = 1;
  700. changed = 1;
  701. }
  702. return changed;
  703. }
  704. static int snd_ftu_create_effect_switch(struct usb_mixer_interface *mixer,
  705. int validx, int bUnitID)
  706. {
  707. static struct snd_kcontrol_new template = {
  708. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  709. .name = "Effect Program Switch",
  710. .index = 0,
  711. .access = SNDRV_CTL_ELEM_ACCESS_READWRITE,
  712. .info = snd_ftu_eff_switch_info,
  713. .get = snd_ftu_eff_switch_get,
  714. .put = snd_ftu_eff_switch_put
  715. };
  716. int err;
  717. struct snd_kcontrol *kctl;
  718. struct snd_ftu_eff_switch_priv_val *pval;
  719. pval = kzalloc(sizeof(*pval), GFP_KERNEL);
  720. if (!pval)
  721. return -ENOMEM;
  722. pval->cached_value = 0;
  723. pval->is_cached = 0;
  724. pval->mixer = mixer;
  725. pval->bUnitID = bUnitID;
  726. pval->validx = validx;
  727. template.private_value = (unsigned long) pval;
  728. kctl = snd_ctl_new1(&template, mixer->chip);
  729. if (!kctl) {
  730. kfree(pval);
  731. return -ENOMEM;
  732. }
  733. err = snd_ctl_add(mixer->chip->card, kctl);
  734. if (err < 0)
  735. return err;
  736. return 0;
  737. }
  738. /* Create volume controls for FTU devices*/
  739. static int snd_ftu_create_volume_ctls(struct usb_mixer_interface *mixer)
  740. {
  741. char name[64];
  742. unsigned int control, cmask;
  743. int in, out, err;
  744. const unsigned int id = 5;
  745. const int val_type = USB_MIXER_S16;
  746. for (out = 0; out < 8; out++) {
  747. control = out + 1;
  748. for (in = 0; in < 8; in++) {
  749. cmask = 1 << in;
  750. snprintf(name, sizeof(name),
  751. "AIn%d - Out%d Capture Volume",
  752. in + 1, out + 1);
  753. err = snd_create_std_mono_ctl(mixer, id, control,
  754. cmask, val_type, name,
  755. &snd_usb_mixer_vol_tlv);
  756. if (err < 0)
  757. return err;
  758. }
  759. for (in = 8; in < 16; in++) {
  760. cmask = 1 << in;
  761. snprintf(name, sizeof(name),
  762. "DIn%d - Out%d Playback Volume",
  763. in - 7, out + 1);
  764. err = snd_create_std_mono_ctl(mixer, id, control,
  765. cmask, val_type, name,
  766. &snd_usb_mixer_vol_tlv);
  767. if (err < 0)
  768. return err;
  769. }
  770. }
  771. return 0;
  772. }
  773. /* This control needs a volume quirk, see mixer.c */
  774. static int snd_ftu_create_effect_volume_ctl(struct usb_mixer_interface *mixer)
  775. {
  776. static const char name[] = "Effect Volume";
  777. const unsigned int id = 6;
  778. const int val_type = USB_MIXER_U8;
  779. const unsigned int control = 2;
  780. const unsigned int cmask = 0;
  781. return snd_create_std_mono_ctl(mixer, id, control, cmask, val_type,
  782. name, snd_usb_mixer_vol_tlv);
  783. }
  784. /* This control needs a volume quirk, see mixer.c */
  785. static int snd_ftu_create_effect_duration_ctl(struct usb_mixer_interface *mixer)
  786. {
  787. static const char name[] = "Effect Duration";
  788. const unsigned int id = 6;
  789. const int val_type = USB_MIXER_S16;
  790. const unsigned int control = 3;
  791. const unsigned int cmask = 0;
  792. return snd_create_std_mono_ctl(mixer, id, control, cmask, val_type,
  793. name, snd_usb_mixer_vol_tlv);
  794. }
  795. /* This control needs a volume quirk, see mixer.c */
  796. static int snd_ftu_create_effect_feedback_ctl(struct usb_mixer_interface *mixer)
  797. {
  798. static const char name[] = "Effect Feedback Volume";
  799. const unsigned int id = 6;
  800. const int val_type = USB_MIXER_U8;
  801. const unsigned int control = 4;
  802. const unsigned int cmask = 0;
  803. return snd_create_std_mono_ctl(mixer, id, control, cmask, val_type,
  804. name, NULL);
  805. }
  806. static int snd_ftu_create_effect_return_ctls(struct usb_mixer_interface *mixer)
  807. {
  808. unsigned int cmask;
  809. int err, ch;
  810. char name[48];
  811. const unsigned int id = 7;
  812. const int val_type = USB_MIXER_S16;
  813. const unsigned int control = 7;
  814. for (ch = 0; ch < 4; ++ch) {
  815. cmask = 1 << ch;
  816. snprintf(name, sizeof(name),
  817. "Effect Return %d Volume", ch + 1);
  818. err = snd_create_std_mono_ctl(mixer, id, control,
  819. cmask, val_type, name,
  820. snd_usb_mixer_vol_tlv);
  821. if (err < 0)
  822. return err;
  823. }
  824. return 0;
  825. }
  826. static int snd_ftu_create_effect_send_ctls(struct usb_mixer_interface *mixer)
  827. {
  828. unsigned int cmask;
  829. int err, ch;
  830. char name[48];
  831. const unsigned int id = 5;
  832. const int val_type = USB_MIXER_S16;
  833. const unsigned int control = 9;
  834. for (ch = 0; ch < 8; ++ch) {
  835. cmask = 1 << ch;
  836. snprintf(name, sizeof(name),
  837. "Effect Send AIn%d Volume", ch + 1);
  838. err = snd_create_std_mono_ctl(mixer, id, control, cmask,
  839. val_type, name,
  840. snd_usb_mixer_vol_tlv);
  841. if (err < 0)
  842. return err;
  843. }
  844. for (ch = 8; ch < 16; ++ch) {
  845. cmask = 1 << ch;
  846. snprintf(name, sizeof(name),
  847. "Effect Send DIn%d Volume", ch - 7);
  848. err = snd_create_std_mono_ctl(mixer, id, control, cmask,
  849. val_type, name,
  850. snd_usb_mixer_vol_tlv);
  851. if (err < 0)
  852. return err;
  853. }
  854. return 0;
  855. }
  856. static int snd_ftu_create_mixer(struct usb_mixer_interface *mixer)
  857. {
  858. int err;
  859. err = snd_ftu_create_volume_ctls(mixer);
  860. if (err < 0)
  861. return err;
  862. err = snd_ftu_create_effect_switch(mixer, 1, 6);
  863. if (err < 0)
  864. return err;
  865. err = snd_ftu_create_effect_volume_ctl(mixer);
  866. if (err < 0)
  867. return err;
  868. err = snd_ftu_create_effect_duration_ctl(mixer);
  869. if (err < 0)
  870. return err;
  871. err = snd_ftu_create_effect_feedback_ctl(mixer);
  872. if (err < 0)
  873. return err;
  874. err = snd_ftu_create_effect_return_ctls(mixer);
  875. if (err < 0)
  876. return err;
  877. err = snd_ftu_create_effect_send_ctls(mixer);
  878. if (err < 0)
  879. return err;
  880. return 0;
  881. }
  882. void snd_emuusb_set_samplerate(struct snd_usb_audio *chip,
  883. unsigned char samplerate_id)
  884. {
  885. struct usb_mixer_interface *mixer;
  886. struct usb_mixer_elem_info *cval;
  887. int unitid = 12; /* SamleRate ExtensionUnit ID */
  888. list_for_each_entry(mixer, &chip->mixer_list, list) {
  889. cval = mixer->id_elems[unitid];
  890. if (cval) {
  891. snd_usb_mixer_set_ctl_value(cval, UAC_SET_CUR,
  892. cval->control << 8,
  893. samplerate_id);
  894. snd_usb_mixer_notify_id(mixer, unitid);
  895. }
  896. break;
  897. }
  898. }
  899. /* M-Audio Fast Track C400 */
  900. /* C400 volume controls, this control needs a volume quirk, see mixer.c */
  901. static int snd_c400_create_vol_ctls(struct usb_mixer_interface *mixer)
  902. {
  903. char name[64];
  904. unsigned int cmask, offset;
  905. int out, chan, err;
  906. const unsigned int id = 0x40;
  907. const int val_type = USB_MIXER_S16;
  908. const int control = 1;
  909. for (chan = 0; chan < 10; chan++) {
  910. for (out = 0; out < 6; out++) {
  911. if (chan < 6) {
  912. snprintf(name, sizeof(name),
  913. "PCM%d-Out%d Playback Volume",
  914. chan + 1, out + 1);
  915. } else {
  916. snprintf(name, sizeof(name),
  917. "In%d-Out%d Playback Volume",
  918. chan - 5, out + 1);
  919. }
  920. cmask = (out == 0) ? 0 : 1 << (out - 1);
  921. offset = chan * 6;
  922. err = snd_create_std_mono_ctl_offset(mixer, id, control,
  923. cmask, val_type, offset, name,
  924. &snd_usb_mixer_vol_tlv);
  925. if (err < 0)
  926. return err;
  927. }
  928. }
  929. return 0;
  930. }
  931. /* This control needs a volume quirk, see mixer.c */
  932. static int snd_c400_create_effect_volume_ctl(struct usb_mixer_interface *mixer)
  933. {
  934. static const char name[] = "Effect Volume";
  935. const unsigned int id = 0x43;
  936. const int val_type = USB_MIXER_U8;
  937. const unsigned int control = 3;
  938. const unsigned int cmask = 0;
  939. return snd_create_std_mono_ctl(mixer, id, control, cmask, val_type,
  940. name, snd_usb_mixer_vol_tlv);
  941. }
  942. /* This control needs a volume quirk, see mixer.c */
  943. static int snd_c400_create_effect_duration_ctl(struct usb_mixer_interface *mixer)
  944. {
  945. static const char name[] = "Effect Duration";
  946. const unsigned int id = 0x43;
  947. const int val_type = USB_MIXER_S16;
  948. const unsigned int control = 4;
  949. const unsigned int cmask = 0;
  950. return snd_create_std_mono_ctl(mixer, id, control, cmask, val_type,
  951. name, snd_usb_mixer_vol_tlv);
  952. }
  953. /* This control needs a volume quirk, see mixer.c */
  954. static int snd_c400_create_effect_feedback_ctl(struct usb_mixer_interface *mixer)
  955. {
  956. static const char name[] = "Effect Feedback Volume";
  957. const unsigned int id = 0x43;
  958. const int val_type = USB_MIXER_U8;
  959. const unsigned int control = 5;
  960. const unsigned int cmask = 0;
  961. return snd_create_std_mono_ctl(mixer, id, control, cmask, val_type,
  962. name, NULL);
  963. }
  964. static int snd_c400_create_effect_vol_ctls(struct usb_mixer_interface *mixer)
  965. {
  966. char name[64];
  967. unsigned int cmask;
  968. int chan, err;
  969. const unsigned int id = 0x42;
  970. const int val_type = USB_MIXER_S16;
  971. const int control = 1;
  972. for (chan = 0; chan < 10; chan++) {
  973. if (chan < 6) {
  974. snprintf(name, sizeof(name),
  975. "Effect Send DOut%d",
  976. chan + 1);
  977. } else {
  978. snprintf(name, sizeof(name),
  979. "Effect Send AIn%d",
  980. chan - 5);
  981. }
  982. cmask = (chan == 0) ? 0 : 1 << (chan - 1);
  983. err = snd_create_std_mono_ctl(mixer, id, control,
  984. cmask, val_type, name,
  985. &snd_usb_mixer_vol_tlv);
  986. if (err < 0)
  987. return err;
  988. }
  989. return 0;
  990. }
  991. static int snd_c400_create_effect_ret_vol_ctls(struct usb_mixer_interface *mixer)
  992. {
  993. char name[64];
  994. unsigned int cmask;
  995. int chan, err;
  996. const unsigned int id = 0x40;
  997. const int val_type = USB_MIXER_S16;
  998. const int control = 1;
  999. const int chan_id[6] = { 0, 7, 2, 9, 4, 0xb };
  1000. const unsigned int offset = 0x3c;
  1001. /* { 0x3c, 0x43, 0x3e, 0x45, 0x40, 0x47 } */
  1002. for (chan = 0; chan < 6; chan++) {
  1003. snprintf(name, sizeof(name),
  1004. "Effect Return %d",
  1005. chan + 1);
  1006. cmask = (chan_id[chan] == 0) ? 0 : 1 << (chan_id[chan] - 1);
  1007. err = snd_create_std_mono_ctl_offset(mixer, id, control,
  1008. cmask, val_type, offset, name,
  1009. &snd_usb_mixer_vol_tlv);
  1010. if (err < 0)
  1011. return err;
  1012. }
  1013. return 0;
  1014. }
  1015. static int snd_c400_create_mixer(struct usb_mixer_interface *mixer)
  1016. {
  1017. int err;
  1018. err = snd_c400_create_vol_ctls(mixer);
  1019. if (err < 0)
  1020. return err;
  1021. err = snd_c400_create_effect_vol_ctls(mixer);
  1022. if (err < 0)
  1023. return err;
  1024. err = snd_c400_create_effect_ret_vol_ctls(mixer);
  1025. if (err < 0)
  1026. return err;
  1027. err = snd_ftu_create_effect_switch(mixer, 2, 0x43);
  1028. if (err < 0)
  1029. return err;
  1030. err = snd_c400_create_effect_volume_ctl(mixer);
  1031. if (err < 0)
  1032. return err;
  1033. err = snd_c400_create_effect_duration_ctl(mixer);
  1034. if (err < 0)
  1035. return err;
  1036. err = snd_c400_create_effect_feedback_ctl(mixer);
  1037. if (err < 0)
  1038. return err;
  1039. return 0;
  1040. }
  1041. /*
  1042. * The mixer units for Ebox-44 are corrupt, and even where they
  1043. * are valid they presents mono controls as L and R channels of
  1044. * stereo. So we provide a good mixer here.
  1045. */
  1046. struct std_mono_table ebox44_table[] = {
  1047. {
  1048. .unitid = 4,
  1049. .control = 1,
  1050. .cmask = 0x0,
  1051. .val_type = USB_MIXER_INV_BOOLEAN,
  1052. .name = "Headphone Playback Switch"
  1053. },
  1054. {
  1055. .unitid = 4,
  1056. .control = 2,
  1057. .cmask = 0x1,
  1058. .val_type = USB_MIXER_S16,
  1059. .name = "Headphone A Mix Playback Volume"
  1060. },
  1061. {
  1062. .unitid = 4,
  1063. .control = 2,
  1064. .cmask = 0x2,
  1065. .val_type = USB_MIXER_S16,
  1066. .name = "Headphone B Mix Playback Volume"
  1067. },
  1068. {
  1069. .unitid = 7,
  1070. .control = 1,
  1071. .cmask = 0x0,
  1072. .val_type = USB_MIXER_INV_BOOLEAN,
  1073. .name = "Output Playback Switch"
  1074. },
  1075. {
  1076. .unitid = 7,
  1077. .control = 2,
  1078. .cmask = 0x1,
  1079. .val_type = USB_MIXER_S16,
  1080. .name = "Output A Playback Volume"
  1081. },
  1082. {
  1083. .unitid = 7,
  1084. .control = 2,
  1085. .cmask = 0x2,
  1086. .val_type = USB_MIXER_S16,
  1087. .name = "Output B Playback Volume"
  1088. },
  1089. {
  1090. .unitid = 10,
  1091. .control = 1,
  1092. .cmask = 0x0,
  1093. .val_type = USB_MIXER_INV_BOOLEAN,
  1094. .name = "Input Capture Switch"
  1095. },
  1096. {
  1097. .unitid = 10,
  1098. .control = 2,
  1099. .cmask = 0x1,
  1100. .val_type = USB_MIXER_S16,
  1101. .name = "Input A Capture Volume"
  1102. },
  1103. {
  1104. .unitid = 10,
  1105. .control = 2,
  1106. .cmask = 0x2,
  1107. .val_type = USB_MIXER_S16,
  1108. .name = "Input B Capture Volume"
  1109. },
  1110. {}
  1111. };
  1112. int snd_usb_mixer_apply_create_quirk(struct usb_mixer_interface *mixer)
  1113. {
  1114. int err = 0;
  1115. struct snd_info_entry *entry;
  1116. if ((err = snd_usb_soundblaster_remote_init(mixer)) < 0)
  1117. return err;
  1118. switch (mixer->chip->usb_id) {
  1119. case USB_ID(0x041e, 0x3020):
  1120. case USB_ID(0x041e, 0x3040):
  1121. case USB_ID(0x041e, 0x3042):
  1122. case USB_ID(0x041e, 0x30df):
  1123. case USB_ID(0x041e, 0x3048):
  1124. err = snd_audigy2nx_controls_create(mixer);
  1125. if (err < 0)
  1126. break;
  1127. if (!snd_card_proc_new(mixer->chip->card, "audigy2nx", &entry))
  1128. snd_info_set_text_ops(entry, mixer,
  1129. snd_audigy2nx_proc_read);
  1130. break;
  1131. case USB_ID(0x0763, 0x2030): /* M-Audio Fast Track C400 */
  1132. err = snd_c400_create_mixer(mixer);
  1133. break;
  1134. case USB_ID(0x0763, 0x2080): /* M-Audio Fast Track Ultra */
  1135. case USB_ID(0x0763, 0x2081): /* M-Audio Fast Track Ultra 8R */
  1136. err = snd_ftu_create_mixer(mixer);
  1137. break;
  1138. case USB_ID(0x0b05, 0x1739): /* ASUS Xonar U1 */
  1139. case USB_ID(0x0b05, 0x1743): /* ASUS Xonar U1 (2) */
  1140. case USB_ID(0x0b05, 0x17a0): /* ASUS Xonar U3 */
  1141. err = snd_xonar_u1_controls_create(mixer);
  1142. break;
  1143. case USB_ID(0x17cc, 0x1011): /* Traktor Audio 6 */
  1144. err = snd_nativeinstruments_create_mixer(mixer,
  1145. snd_nativeinstruments_ta6_mixers,
  1146. ARRAY_SIZE(snd_nativeinstruments_ta6_mixers));
  1147. break;
  1148. case USB_ID(0x17cc, 0x1021): /* Traktor Audio 10 */
  1149. err = snd_nativeinstruments_create_mixer(mixer,
  1150. snd_nativeinstruments_ta10_mixers,
  1151. ARRAY_SIZE(snd_nativeinstruments_ta10_mixers));
  1152. break;
  1153. case USB_ID(0x200c, 0x1018): /* Electrix Ebox-44 */
  1154. /* detection is disabled in mixer_maps.c */
  1155. err = snd_create_std_mono_table(mixer, ebox44_table);
  1156. break;
  1157. }
  1158. return err;
  1159. }
  1160. void snd_usb_mixer_rc_memory_change(struct usb_mixer_interface *mixer,
  1161. int unitid)
  1162. {
  1163. if (!mixer->rc_cfg)
  1164. return;
  1165. /* unit ids specific to Extigy/Audigy 2 NX: */
  1166. switch (unitid) {
  1167. case 0: /* remote control */
  1168. mixer->rc_urb->dev = mixer->chip->dev;
  1169. usb_submit_urb(mixer->rc_urb, GFP_ATOMIC);
  1170. break;
  1171. case 4: /* digital in jack */
  1172. case 7: /* line in jacks */
  1173. case 19: /* speaker out jacks */
  1174. case 20: /* headphones out jack */
  1175. break;
  1176. /* live24ext: 4 = line-in jack */
  1177. case 3: /* hp-out jack (may actuate Mute) */
  1178. if (mixer->chip->usb_id == USB_ID(0x041e, 0x3040) ||
  1179. mixer->chip->usb_id == USB_ID(0x041e, 0x3048))
  1180. snd_usb_mixer_notify_id(mixer, mixer->rc_cfg->mute_mixer_id);
  1181. break;
  1182. default:
  1183. snd_printd(KERN_DEBUG "memory change in unknown unit %d\n", unitid);
  1184. break;
  1185. }
  1186. }