mixer_quirks.c 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655
  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. /*
  41. * Sound Blaster remote control configuration
  42. *
  43. * format of remote control data:
  44. * Extigy: xx 00
  45. * Audigy 2 NX: 06 80 xx 00 00 00
  46. * Live! 24-bit: 06 80 xx yy 22 83
  47. */
  48. static const struct rc_config {
  49. u32 usb_id;
  50. u8 offset;
  51. u8 length;
  52. u8 packet_length;
  53. u8 min_packet_length; /* minimum accepted length of the URB result */
  54. u8 mute_mixer_id;
  55. u32 mute_code;
  56. } rc_configs[] = {
  57. { USB_ID(0x041e, 0x3000), 0, 1, 2, 1, 18, 0x0013 }, /* Extigy */
  58. { USB_ID(0x041e, 0x3020), 2, 1, 6, 6, 18, 0x0013 }, /* Audigy 2 NX */
  59. { USB_ID(0x041e, 0x3040), 2, 2, 6, 6, 2, 0x6e91 }, /* Live! 24-bit */
  60. { USB_ID(0x041e, 0x3042), 0, 1, 1, 1, 1, 0x000d }, /* Usb X-Fi S51 */
  61. { USB_ID(0x041e, 0x30df), 0, 1, 1, 1, 1, 0x000d }, /* Usb X-Fi S51 Pro */
  62. { USB_ID(0x041e, 0x3048), 2, 2, 6, 6, 2, 0x6e91 }, /* Toshiba SB0500 */
  63. };
  64. static void snd_usb_soundblaster_remote_complete(struct urb *urb)
  65. {
  66. struct usb_mixer_interface *mixer = urb->context;
  67. const struct rc_config *rc = mixer->rc_cfg;
  68. u32 code;
  69. if (urb->status < 0 || urb->actual_length < rc->min_packet_length)
  70. return;
  71. code = mixer->rc_buffer[rc->offset];
  72. if (rc->length == 2)
  73. code |= mixer->rc_buffer[rc->offset + 1] << 8;
  74. /* the Mute button actually changes the mixer control */
  75. if (code == rc->mute_code)
  76. snd_usb_mixer_notify_id(mixer, rc->mute_mixer_id);
  77. mixer->rc_code = code;
  78. wmb();
  79. wake_up(&mixer->rc_waitq);
  80. }
  81. static long snd_usb_sbrc_hwdep_read(struct snd_hwdep *hw, char __user *buf,
  82. long count, loff_t *offset)
  83. {
  84. struct usb_mixer_interface *mixer = hw->private_data;
  85. int err;
  86. u32 rc_code;
  87. if (count != 1 && count != 4)
  88. return -EINVAL;
  89. err = wait_event_interruptible(mixer->rc_waitq,
  90. (rc_code = xchg(&mixer->rc_code, 0)) != 0);
  91. if (err == 0) {
  92. if (count == 1)
  93. err = put_user(rc_code, buf);
  94. else
  95. err = put_user(rc_code, (u32 __user *)buf);
  96. }
  97. return err < 0 ? err : count;
  98. }
  99. static unsigned int snd_usb_sbrc_hwdep_poll(struct snd_hwdep *hw, struct file *file,
  100. poll_table *wait)
  101. {
  102. struct usb_mixer_interface *mixer = hw->private_data;
  103. poll_wait(file, &mixer->rc_waitq, wait);
  104. return mixer->rc_code ? POLLIN | POLLRDNORM : 0;
  105. }
  106. static int snd_usb_soundblaster_remote_init(struct usb_mixer_interface *mixer)
  107. {
  108. struct snd_hwdep *hwdep;
  109. int err, len, i;
  110. for (i = 0; i < ARRAY_SIZE(rc_configs); ++i)
  111. if (rc_configs[i].usb_id == mixer->chip->usb_id)
  112. break;
  113. if (i >= ARRAY_SIZE(rc_configs))
  114. return 0;
  115. mixer->rc_cfg = &rc_configs[i];
  116. len = mixer->rc_cfg->packet_length;
  117. init_waitqueue_head(&mixer->rc_waitq);
  118. err = snd_hwdep_new(mixer->chip->card, "SB remote control", 0, &hwdep);
  119. if (err < 0)
  120. return err;
  121. snprintf(hwdep->name, sizeof(hwdep->name),
  122. "%s remote control", mixer->chip->card->shortname);
  123. hwdep->iface = SNDRV_HWDEP_IFACE_SB_RC;
  124. hwdep->private_data = mixer;
  125. hwdep->ops.read = snd_usb_sbrc_hwdep_read;
  126. hwdep->ops.poll = snd_usb_sbrc_hwdep_poll;
  127. hwdep->exclusive = 1;
  128. mixer->rc_urb = usb_alloc_urb(0, GFP_KERNEL);
  129. if (!mixer->rc_urb)
  130. return -ENOMEM;
  131. mixer->rc_setup_packet = kmalloc(sizeof(*mixer->rc_setup_packet), GFP_KERNEL);
  132. if (!mixer->rc_setup_packet) {
  133. usb_free_urb(mixer->rc_urb);
  134. mixer->rc_urb = NULL;
  135. return -ENOMEM;
  136. }
  137. mixer->rc_setup_packet->bRequestType =
  138. USB_DIR_IN | USB_TYPE_CLASS | USB_RECIP_INTERFACE;
  139. mixer->rc_setup_packet->bRequest = UAC_GET_MEM;
  140. mixer->rc_setup_packet->wValue = cpu_to_le16(0);
  141. mixer->rc_setup_packet->wIndex = cpu_to_le16(0);
  142. mixer->rc_setup_packet->wLength = cpu_to_le16(len);
  143. usb_fill_control_urb(mixer->rc_urb, mixer->chip->dev,
  144. usb_rcvctrlpipe(mixer->chip->dev, 0),
  145. (u8*)mixer->rc_setup_packet, mixer->rc_buffer, len,
  146. snd_usb_soundblaster_remote_complete, mixer);
  147. return 0;
  148. }
  149. #define snd_audigy2nx_led_info snd_ctl_boolean_mono_info
  150. static int snd_audigy2nx_led_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
  151. {
  152. struct usb_mixer_interface *mixer = snd_kcontrol_chip(kcontrol);
  153. int index = kcontrol->private_value;
  154. ucontrol->value.integer.value[0] = mixer->audigy2nx_leds[index];
  155. return 0;
  156. }
  157. static int snd_audigy2nx_led_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
  158. {
  159. struct usb_mixer_interface *mixer = snd_kcontrol_chip(kcontrol);
  160. int index = kcontrol->private_value;
  161. int value = ucontrol->value.integer.value[0];
  162. int err, changed;
  163. if (value > 1)
  164. return -EINVAL;
  165. changed = value != mixer->audigy2nx_leds[index];
  166. if (mixer->chip->usb_id == USB_ID(0x041e, 0x3042))
  167. err = snd_usb_ctl_msg(mixer->chip->dev,
  168. usb_sndctrlpipe(mixer->chip->dev, 0), 0x24,
  169. USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_OTHER,
  170. !value, 0, NULL, 0, 100);
  171. /* USB X-Fi S51 Pro */
  172. if (mixer->chip->usb_id == USB_ID(0x041e, 0x30df))
  173. err = snd_usb_ctl_msg(mixer->chip->dev,
  174. usb_sndctrlpipe(mixer->chip->dev, 0), 0x24,
  175. USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_OTHER,
  176. !value, 0, NULL, 0, 100);
  177. else
  178. err = snd_usb_ctl_msg(mixer->chip->dev,
  179. usb_sndctrlpipe(mixer->chip->dev, 0), 0x24,
  180. USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_OTHER,
  181. value, index + 2, NULL, 0, 100);
  182. if (err < 0)
  183. return err;
  184. mixer->audigy2nx_leds[index] = value;
  185. return changed;
  186. }
  187. static struct snd_kcontrol_new snd_audigy2nx_controls[] = {
  188. {
  189. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  190. .name = "CMSS LED Switch",
  191. .info = snd_audigy2nx_led_info,
  192. .get = snd_audigy2nx_led_get,
  193. .put = snd_audigy2nx_led_put,
  194. .private_value = 0,
  195. },
  196. {
  197. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  198. .name = "Power LED Switch",
  199. .info = snd_audigy2nx_led_info,
  200. .get = snd_audigy2nx_led_get,
  201. .put = snd_audigy2nx_led_put,
  202. .private_value = 1,
  203. },
  204. {
  205. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  206. .name = "Dolby Digital LED Switch",
  207. .info = snd_audigy2nx_led_info,
  208. .get = snd_audigy2nx_led_get,
  209. .put = snd_audigy2nx_led_put,
  210. .private_value = 2,
  211. },
  212. };
  213. static int snd_audigy2nx_controls_create(struct usb_mixer_interface *mixer)
  214. {
  215. int i, err;
  216. for (i = 0; i < ARRAY_SIZE(snd_audigy2nx_controls); ++i) {
  217. /* USB X-Fi S51 doesn't have a CMSS LED */
  218. if ((mixer->chip->usb_id == USB_ID(0x041e, 0x3042)) && i == 0)
  219. continue;
  220. /* USB X-Fi S51 Pro doesn't have one either */
  221. if ((mixer->chip->usb_id == USB_ID(0x041e, 0x30df)) && i == 0)
  222. continue;
  223. if (i > 1 && /* Live24ext has 2 LEDs only */
  224. (mixer->chip->usb_id == USB_ID(0x041e, 0x3040) ||
  225. mixer->chip->usb_id == USB_ID(0x041e, 0x3042) ||
  226. mixer->chip->usb_id == USB_ID(0x041e, 0x30df) ||
  227. mixer->chip->usb_id == USB_ID(0x041e, 0x3048)))
  228. break;
  229. err = snd_ctl_add(mixer->chip->card,
  230. snd_ctl_new1(&snd_audigy2nx_controls[i], mixer));
  231. if (err < 0)
  232. return err;
  233. }
  234. mixer->audigy2nx_leds[1] = 1; /* Power LED is on by default */
  235. return 0;
  236. }
  237. static void snd_audigy2nx_proc_read(struct snd_info_entry *entry,
  238. struct snd_info_buffer *buffer)
  239. {
  240. static const struct sb_jack {
  241. int unitid;
  242. const char *name;
  243. } jacks_audigy2nx[] = {
  244. {4, "dig in "},
  245. {7, "line in"},
  246. {19, "spk out"},
  247. {20, "hph out"},
  248. {-1, NULL}
  249. }, jacks_live24ext[] = {
  250. {4, "line in"}, /* &1=Line, &2=Mic*/
  251. {3, "hph out"}, /* headphones */
  252. {0, "RC "}, /* last command, 6 bytes see rc_config above */
  253. {-1, NULL}
  254. };
  255. const struct sb_jack *jacks;
  256. struct usb_mixer_interface *mixer = entry->private_data;
  257. int i, err;
  258. u8 buf[3];
  259. snd_iprintf(buffer, "%s jacks\n\n", mixer->chip->card->shortname);
  260. if (mixer->chip->usb_id == USB_ID(0x041e, 0x3020))
  261. jacks = jacks_audigy2nx;
  262. else if (mixer->chip->usb_id == USB_ID(0x041e, 0x3040) ||
  263. mixer->chip->usb_id == USB_ID(0x041e, 0x3048))
  264. jacks = jacks_live24ext;
  265. else
  266. return;
  267. for (i = 0; jacks[i].name; ++i) {
  268. snd_iprintf(buffer, "%s: ", jacks[i].name);
  269. err = snd_usb_ctl_msg(mixer->chip->dev,
  270. usb_rcvctrlpipe(mixer->chip->dev, 0),
  271. UAC_GET_MEM, USB_DIR_IN | USB_TYPE_CLASS |
  272. USB_RECIP_INTERFACE, 0,
  273. jacks[i].unitid << 8, buf, 3, 100);
  274. if (err == 3 && (buf[0] == 3 || buf[0] == 6))
  275. snd_iprintf(buffer, "%02x %02x\n", buf[1], buf[2]);
  276. else
  277. snd_iprintf(buffer, "?\n");
  278. }
  279. }
  280. static int snd_xonar_u1_switch_get(struct snd_kcontrol *kcontrol,
  281. struct snd_ctl_elem_value *ucontrol)
  282. {
  283. struct usb_mixer_interface *mixer = snd_kcontrol_chip(kcontrol);
  284. ucontrol->value.integer.value[0] = !!(mixer->xonar_u1_status & 0x02);
  285. return 0;
  286. }
  287. static int snd_xonar_u1_switch_put(struct snd_kcontrol *kcontrol,
  288. struct snd_ctl_elem_value *ucontrol)
  289. {
  290. struct usb_mixer_interface *mixer = snd_kcontrol_chip(kcontrol);
  291. u8 old_status, new_status;
  292. int err, changed;
  293. old_status = mixer->xonar_u1_status;
  294. if (ucontrol->value.integer.value[0])
  295. new_status = old_status | 0x02;
  296. else
  297. new_status = old_status & ~0x02;
  298. changed = new_status != old_status;
  299. err = snd_usb_ctl_msg(mixer->chip->dev,
  300. usb_sndctrlpipe(mixer->chip->dev, 0), 0x08,
  301. USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_OTHER,
  302. 50, 0, &new_status, 1, 100);
  303. if (err < 0)
  304. return err;
  305. mixer->xonar_u1_status = new_status;
  306. return changed;
  307. }
  308. static struct snd_kcontrol_new snd_xonar_u1_output_switch = {
  309. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  310. .name = "Digital Playback Switch",
  311. .info = snd_ctl_boolean_mono_info,
  312. .get = snd_xonar_u1_switch_get,
  313. .put = snd_xonar_u1_switch_put,
  314. };
  315. static int snd_xonar_u1_controls_create(struct usb_mixer_interface *mixer)
  316. {
  317. int err;
  318. err = snd_ctl_add(mixer->chip->card,
  319. snd_ctl_new1(&snd_xonar_u1_output_switch, mixer));
  320. if (err < 0)
  321. return err;
  322. mixer->xonar_u1_status = 0x05;
  323. return 0;
  324. }
  325. /* Native Instruments device quirks */
  326. #define _MAKE_NI_CONTROL(bRequest,wIndex) ((bRequest) << 16 | (wIndex))
  327. static int snd_nativeinstruments_control_get(struct snd_kcontrol *kcontrol,
  328. struct snd_ctl_elem_value *ucontrol)
  329. {
  330. struct usb_mixer_interface *mixer = snd_kcontrol_chip(kcontrol);
  331. struct usb_device *dev = mixer->chip->dev;
  332. u8 bRequest = (kcontrol->private_value >> 16) & 0xff;
  333. u16 wIndex = kcontrol->private_value & 0xffff;
  334. u8 tmp;
  335. int ret = usb_control_msg(dev, usb_rcvctrlpipe(dev, 0), bRequest,
  336. USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_IN,
  337. 0, cpu_to_le16(wIndex),
  338. &tmp, sizeof(tmp), 1000);
  339. if (ret < 0) {
  340. snd_printk(KERN_ERR
  341. "unable to issue vendor read request (ret = %d)", ret);
  342. return ret;
  343. }
  344. ucontrol->value.integer.value[0] = tmp;
  345. return 0;
  346. }
  347. static int snd_nativeinstruments_control_put(struct snd_kcontrol *kcontrol,
  348. struct snd_ctl_elem_value *ucontrol)
  349. {
  350. struct usb_mixer_interface *mixer = snd_kcontrol_chip(kcontrol);
  351. struct usb_device *dev = mixer->chip->dev;
  352. u8 bRequest = (kcontrol->private_value >> 16) & 0xff;
  353. u16 wIndex = kcontrol->private_value & 0xffff;
  354. u16 wValue = ucontrol->value.integer.value[0];
  355. int ret = usb_control_msg(dev, usb_sndctrlpipe(dev, 0), bRequest,
  356. USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_OUT,
  357. cpu_to_le16(wValue), cpu_to_le16(wIndex),
  358. NULL, 0, 1000);
  359. if (ret < 0) {
  360. snd_printk(KERN_ERR
  361. "unable to issue vendor write request (ret = %d)", ret);
  362. return ret;
  363. }
  364. return 0;
  365. }
  366. static struct snd_kcontrol_new snd_nativeinstruments_ta6_mixers[] = {
  367. {
  368. .name = "Direct Thru Channel A",
  369. .private_value = _MAKE_NI_CONTROL(0x01, 0x03),
  370. },
  371. {
  372. .name = "Direct Thru Channel B",
  373. .private_value = _MAKE_NI_CONTROL(0x01, 0x05),
  374. },
  375. {
  376. .name = "Phono Input Channel A",
  377. .private_value = _MAKE_NI_CONTROL(0x02, 0x03),
  378. },
  379. {
  380. .name = "Phono Input Channel B",
  381. .private_value = _MAKE_NI_CONTROL(0x02, 0x05),
  382. },
  383. };
  384. static struct snd_kcontrol_new snd_nativeinstruments_ta10_mixers[] = {
  385. {
  386. .name = "Direct Thru Channel A",
  387. .private_value = _MAKE_NI_CONTROL(0x01, 0x03),
  388. },
  389. {
  390. .name = "Direct Thru Channel B",
  391. .private_value = _MAKE_NI_CONTROL(0x01, 0x05),
  392. },
  393. {
  394. .name = "Direct Thru Channel C",
  395. .private_value = _MAKE_NI_CONTROL(0x01, 0x07),
  396. },
  397. {
  398. .name = "Direct Thru Channel D",
  399. .private_value = _MAKE_NI_CONTROL(0x01, 0x09),
  400. },
  401. {
  402. .name = "Phono Input Channel A",
  403. .private_value = _MAKE_NI_CONTROL(0x02, 0x03),
  404. },
  405. {
  406. .name = "Phono Input Channel B",
  407. .private_value = _MAKE_NI_CONTROL(0x02, 0x05),
  408. },
  409. {
  410. .name = "Phono Input Channel C",
  411. .private_value = _MAKE_NI_CONTROL(0x02, 0x07),
  412. },
  413. {
  414. .name = "Phono Input Channel D",
  415. .private_value = _MAKE_NI_CONTROL(0x02, 0x09),
  416. },
  417. };
  418. static int snd_nativeinstruments_create_mixer(struct usb_mixer_interface *mixer,
  419. const struct snd_kcontrol_new *kc,
  420. unsigned int count)
  421. {
  422. int i, err = 0;
  423. struct snd_kcontrol_new template = {
  424. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  425. .access = SNDRV_CTL_ELEM_ACCESS_READWRITE,
  426. .get = snd_nativeinstruments_control_get,
  427. .put = snd_nativeinstruments_control_put,
  428. .info = snd_ctl_boolean_mono_info,
  429. };
  430. for (i = 0; i < count; i++) {
  431. struct snd_kcontrol *c;
  432. template.name = kc[i].name;
  433. template.private_value = kc[i].private_value;
  434. c = snd_ctl_new1(&template, mixer);
  435. err = snd_ctl_add(mixer->chip->card, c);
  436. if (err < 0)
  437. break;
  438. }
  439. return err;
  440. }
  441. /* M-Audio FastTrack Ultra quirks */
  442. /* private_free callback */
  443. static void usb_mixer_elem_free(struct snd_kcontrol *kctl)
  444. {
  445. kfree(kctl->private_data);
  446. kctl->private_data = NULL;
  447. }
  448. static int snd_maudio_ftu_create_ctl(struct usb_mixer_interface *mixer,
  449. int in, int out, const char *name)
  450. {
  451. struct usb_mixer_elem_info *cval;
  452. struct snd_kcontrol *kctl;
  453. cval = kzalloc(sizeof(*cval), GFP_KERNEL);
  454. if (!cval)
  455. return -ENOMEM;
  456. cval->id = 5;
  457. cval->mixer = mixer;
  458. cval->val_type = USB_MIXER_S16;
  459. cval->channels = 1;
  460. cval->control = out + 1;
  461. cval->cmask = 1 << in;
  462. kctl = snd_ctl_new1(snd_usb_feature_unit_ctl, cval);
  463. if (!kctl) {
  464. kfree(cval);
  465. return -ENOMEM;
  466. }
  467. snprintf(kctl->id.name, sizeof(kctl->id.name), name);
  468. kctl->private_free = usb_mixer_elem_free;
  469. return snd_usb_mixer_add_control(mixer, kctl);
  470. }
  471. static int snd_maudio_ftu_create_mixer(struct usb_mixer_interface *mixer)
  472. {
  473. char name[64];
  474. int in, out, err;
  475. for (out = 0; out < 8; out++) {
  476. for (in = 0; in < 8; in++) {
  477. snprintf(name, sizeof(name),
  478. "AIn%d - Out%d Capture Volume", in + 1, out + 1);
  479. err = snd_maudio_ftu_create_ctl(mixer, in, out, name);
  480. if (err < 0)
  481. return err;
  482. }
  483. for (in = 8; in < 16; in++) {
  484. snprintf(name, sizeof(name),
  485. "DIn%d - Out%d Playback Volume", in - 7, out + 1);
  486. err = snd_maudio_ftu_create_ctl(mixer, in, out, name);
  487. if (err < 0)
  488. return err;
  489. }
  490. }
  491. return 0;
  492. }
  493. void snd_emuusb_set_samplerate(struct snd_usb_audio *chip,
  494. unsigned char samplerate_id)
  495. {
  496. struct usb_mixer_interface *mixer;
  497. struct usb_mixer_elem_info *cval;
  498. int unitid = 12; /* SamleRate ExtensionUnit ID */
  499. list_for_each_entry(mixer, &chip->mixer_list, list) {
  500. cval = mixer->id_elems[unitid];
  501. if (cval) {
  502. snd_usb_mixer_set_ctl_value(cval, UAC_SET_CUR,
  503. cval->control << 8,
  504. samplerate_id);
  505. snd_usb_mixer_notify_id(mixer, unitid);
  506. }
  507. break;
  508. }
  509. }
  510. int snd_usb_mixer_apply_create_quirk(struct usb_mixer_interface *mixer)
  511. {
  512. int err = 0;
  513. struct snd_info_entry *entry;
  514. if ((err = snd_usb_soundblaster_remote_init(mixer)) < 0)
  515. return err;
  516. switch (mixer->chip->usb_id) {
  517. case USB_ID(0x041e, 0x3020):
  518. case USB_ID(0x041e, 0x3040):
  519. case USB_ID(0x041e, 0x3042):
  520. case USB_ID(0x041e, 0x30df):
  521. case USB_ID(0x041e, 0x3048):
  522. err = snd_audigy2nx_controls_create(mixer);
  523. if (err < 0)
  524. break;
  525. if (!snd_card_proc_new(mixer->chip->card, "audigy2nx", &entry))
  526. snd_info_set_text_ops(entry, mixer,
  527. snd_audigy2nx_proc_read);
  528. break;
  529. case USB_ID(0x0763, 0x2080): /* M-Audio Fast Track Ultra */
  530. case USB_ID(0x0763, 0x2081): /* M-Audio Fast Track Ultra 8R */
  531. err = snd_maudio_ftu_create_mixer(mixer);
  532. break;
  533. case USB_ID(0x0b05, 0x1739):
  534. case USB_ID(0x0b05, 0x1743):
  535. err = snd_xonar_u1_controls_create(mixer);
  536. break;
  537. case USB_ID(0x17cc, 0x1011): /* Traktor Audio 6 */
  538. err = snd_nativeinstruments_create_mixer(mixer,
  539. snd_nativeinstruments_ta6_mixers,
  540. ARRAY_SIZE(snd_nativeinstruments_ta6_mixers));
  541. break;
  542. case USB_ID(0x17cc, 0x1021): /* Traktor Audio 10 */
  543. err = snd_nativeinstruments_create_mixer(mixer,
  544. snd_nativeinstruments_ta10_mixers,
  545. ARRAY_SIZE(snd_nativeinstruments_ta10_mixers));
  546. break;
  547. }
  548. return err;
  549. }
  550. void snd_usb_mixer_rc_memory_change(struct usb_mixer_interface *mixer,
  551. int unitid)
  552. {
  553. if (!mixer->rc_cfg)
  554. return;
  555. /* unit ids specific to Extigy/Audigy 2 NX: */
  556. switch (unitid) {
  557. case 0: /* remote control */
  558. mixer->rc_urb->dev = mixer->chip->dev;
  559. usb_submit_urb(mixer->rc_urb, GFP_ATOMIC);
  560. break;
  561. case 4: /* digital in jack */
  562. case 7: /* line in jacks */
  563. case 19: /* speaker out jacks */
  564. case 20: /* headphones out jack */
  565. break;
  566. /* live24ext: 4 = line-in jack */
  567. case 3: /* hp-out jack (may actuate Mute) */
  568. if (mixer->chip->usb_id == USB_ID(0x041e, 0x3040) ||
  569. mixer->chip->usb_id == USB_ID(0x041e, 0x3048))
  570. snd_usb_mixer_notify_id(mixer, mixer->rc_cfg->mute_mixer_id);
  571. break;
  572. default:
  573. snd_printd(KERN_DEBUG "memory change in unknown unit %d\n", unitid);
  574. break;
  575. }
  576. }