control.c 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657
  1. /*
  2. * Copyright (c) 2007 Daniel Mack
  3. * friendly supported by NI.
  4. *
  5. * This program is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation; either version 2 of the License, or
  8. * (at your option) any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this program; if not, write to the Free Software
  17. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  18. */
  19. #include <linux/device.h>
  20. #include <linux/init.h>
  21. #include <linux/usb.h>
  22. #include <sound/control.h>
  23. #include <sound/core.h>
  24. #include <sound/pcm.h>
  25. #include "device.h"
  26. #include "control.h"
  27. #define CNT_INTVAL 0x10000
  28. #define MASCHINE_BANK_SIZE 32
  29. static int control_info(struct snd_kcontrol *kcontrol,
  30. struct snd_ctl_elem_info *uinfo)
  31. {
  32. struct snd_usb_audio *chip = snd_kcontrol_chip(kcontrol);
  33. struct snd_usb_caiaqdev *cdev = caiaqdev(chip->card);
  34. int pos = kcontrol->private_value;
  35. int is_intval = pos & CNT_INTVAL;
  36. int maxval = 63;
  37. uinfo->count = 1;
  38. pos &= ~CNT_INTVAL;
  39. switch (cdev->chip.usb_id) {
  40. case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_AUDIO8DJ):
  41. case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_AUDIO4DJ):
  42. if (pos == 0) {
  43. /* current input mode of A8DJ and A4DJ */
  44. uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
  45. uinfo->value.integer.min = 0;
  46. uinfo->value.integer.max = 2;
  47. return 0;
  48. }
  49. break;
  50. case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_TRAKTORKONTROLX1):
  51. maxval = 127;
  52. break;
  53. case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_TRAKTORKONTROLS4):
  54. maxval = 31;
  55. break;
  56. }
  57. if (is_intval) {
  58. uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
  59. uinfo->value.integer.min = 0;
  60. uinfo->value.integer.max = maxval;
  61. } else {
  62. uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
  63. uinfo->value.integer.min = 0;
  64. uinfo->value.integer.max = 1;
  65. }
  66. return 0;
  67. }
  68. static int control_get(struct snd_kcontrol *kcontrol,
  69. struct snd_ctl_elem_value *ucontrol)
  70. {
  71. struct snd_usb_audio *chip = snd_kcontrol_chip(kcontrol);
  72. struct snd_usb_caiaqdev *cdev = caiaqdev(chip->card);
  73. int pos = kcontrol->private_value;
  74. if (pos & CNT_INTVAL)
  75. ucontrol->value.integer.value[0]
  76. = cdev->control_state[pos & ~CNT_INTVAL];
  77. else
  78. ucontrol->value.integer.value[0]
  79. = !!(cdev->control_state[pos / 8] & (1 << pos % 8));
  80. return 0;
  81. }
  82. static int control_put(struct snd_kcontrol *kcontrol,
  83. struct snd_ctl_elem_value *ucontrol)
  84. {
  85. struct snd_usb_audio *chip = snd_kcontrol_chip(kcontrol);
  86. struct snd_usb_caiaqdev *cdev = caiaqdev(chip->card);
  87. int pos = kcontrol->private_value;
  88. int v = ucontrol->value.integer.value[0];
  89. unsigned char cmd;
  90. switch (cdev->chip.usb_id) {
  91. case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_MASCHINECONTROLLER):
  92. case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_TRAKTORKONTROLX1):
  93. case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_KORECONTROLLER2):
  94. case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_KORECONTROLLER):
  95. cmd = EP1_CMD_DIMM_LEDS;
  96. break;
  97. default:
  98. cmd = EP1_CMD_WRITE_IO;
  99. break;
  100. }
  101. if (pos & CNT_INTVAL) {
  102. int i = pos & ~CNT_INTVAL;
  103. cdev->control_state[i] = v;
  104. if (cdev->chip.usb_id ==
  105. USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_TRAKTORKONTROLS4)) {
  106. int actual_len;
  107. cdev->ep8_out_buf[0] = i;
  108. cdev->ep8_out_buf[1] = v;
  109. usb_bulk_msg(cdev->chip.dev,
  110. usb_sndbulkpipe(cdev->chip.dev, 8),
  111. cdev->ep8_out_buf, sizeof(cdev->ep8_out_buf),
  112. &actual_len, 200);
  113. } else if (cdev->chip.usb_id ==
  114. USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_MASCHINECONTROLLER)) {
  115. int bank = 0;
  116. int offset = 0;
  117. if (i >= MASCHINE_BANK_SIZE) {
  118. bank = 0x1e;
  119. offset = MASCHINE_BANK_SIZE;
  120. }
  121. snd_usb_caiaq_send_command_bank(cdev, cmd, bank,
  122. cdev->control_state + offset,
  123. MASCHINE_BANK_SIZE);
  124. } else {
  125. snd_usb_caiaq_send_command(cdev, cmd,
  126. cdev->control_state, sizeof(cdev->control_state));
  127. }
  128. } else {
  129. if (v)
  130. cdev->control_state[pos / 8] |= 1 << (pos % 8);
  131. else
  132. cdev->control_state[pos / 8] &= ~(1 << (pos % 8));
  133. snd_usb_caiaq_send_command(cdev, cmd,
  134. cdev->control_state, sizeof(cdev->control_state));
  135. }
  136. return 1;
  137. }
  138. static struct snd_kcontrol_new kcontrol_template = {
  139. .iface = SNDRV_CTL_ELEM_IFACE_HWDEP,
  140. .access = SNDRV_CTL_ELEM_ACCESS_READWRITE,
  141. .index = 0,
  142. .info = control_info,
  143. .get = control_get,
  144. .put = control_put,
  145. /* name and private_value filled later */
  146. };
  147. struct caiaq_controller {
  148. char *name;
  149. int index;
  150. };
  151. static struct caiaq_controller ak1_controller[] = {
  152. { "LED left", 2 },
  153. { "LED middle", 1 },
  154. { "LED right", 0 },
  155. { "LED ring", 3 }
  156. };
  157. static struct caiaq_controller rk2_controller[] = {
  158. { "LED 1", 5 },
  159. { "LED 2", 4 },
  160. { "LED 3", 3 },
  161. { "LED 4", 2 },
  162. { "LED 5", 1 },
  163. { "LED 6", 0 },
  164. { "LED pedal", 6 },
  165. { "LED 7seg_1b", 8 },
  166. { "LED 7seg_1c", 9 },
  167. { "LED 7seg_2a", 10 },
  168. { "LED 7seg_2b", 11 },
  169. { "LED 7seg_2c", 12 },
  170. { "LED 7seg_2d", 13 },
  171. { "LED 7seg_2e", 14 },
  172. { "LED 7seg_2f", 15 },
  173. { "LED 7seg_2g", 16 },
  174. { "LED 7seg_3a", 17 },
  175. { "LED 7seg_3b", 18 },
  176. { "LED 7seg_3c", 19 },
  177. { "LED 7seg_3d", 20 },
  178. { "LED 7seg_3e", 21 },
  179. { "LED 7seg_3f", 22 },
  180. { "LED 7seg_3g", 23 }
  181. };
  182. static struct caiaq_controller rk3_controller[] = {
  183. { "LED 7seg_1a", 0 + 0 },
  184. { "LED 7seg_1b", 0 + 1 },
  185. { "LED 7seg_1c", 0 + 2 },
  186. { "LED 7seg_1d", 0 + 3 },
  187. { "LED 7seg_1e", 0 + 4 },
  188. { "LED 7seg_1f", 0 + 5 },
  189. { "LED 7seg_1g", 0 + 6 },
  190. { "LED 7seg_1p", 0 + 7 },
  191. { "LED 7seg_2a", 8 + 0 },
  192. { "LED 7seg_2b", 8 + 1 },
  193. { "LED 7seg_2c", 8 + 2 },
  194. { "LED 7seg_2d", 8 + 3 },
  195. { "LED 7seg_2e", 8 + 4 },
  196. { "LED 7seg_2f", 8 + 5 },
  197. { "LED 7seg_2g", 8 + 6 },
  198. { "LED 7seg_2p", 8 + 7 },
  199. { "LED 7seg_3a", 16 + 0 },
  200. { "LED 7seg_3b", 16 + 1 },
  201. { "LED 7seg_3c", 16 + 2 },
  202. { "LED 7seg_3d", 16 + 3 },
  203. { "LED 7seg_3e", 16 + 4 },
  204. { "LED 7seg_3f", 16 + 5 },
  205. { "LED 7seg_3g", 16 + 6 },
  206. { "LED 7seg_3p", 16 + 7 },
  207. { "LED 7seg_4a", 24 + 0 },
  208. { "LED 7seg_4b", 24 + 1 },
  209. { "LED 7seg_4c", 24 + 2 },
  210. { "LED 7seg_4d", 24 + 3 },
  211. { "LED 7seg_4e", 24 + 4 },
  212. { "LED 7seg_4f", 24 + 5 },
  213. { "LED 7seg_4g", 24 + 6 },
  214. { "LED 7seg_4p", 24 + 7 },
  215. { "LED 1", 32 + 0 },
  216. { "LED 2", 32 + 1 },
  217. { "LED 3", 32 + 2 },
  218. { "LED 4", 32 + 3 },
  219. { "LED 5", 32 + 4 },
  220. { "LED 6", 32 + 5 },
  221. { "LED 7", 32 + 6 },
  222. { "LED 8", 32 + 7 },
  223. { "LED pedal", 32 + 8 }
  224. };
  225. static struct caiaq_controller kore_controller[] = {
  226. { "LED F1", 8 | CNT_INTVAL },
  227. { "LED F2", 12 | CNT_INTVAL },
  228. { "LED F3", 0 | CNT_INTVAL },
  229. { "LED F4", 4 | CNT_INTVAL },
  230. { "LED F5", 11 | CNT_INTVAL },
  231. { "LED F6", 15 | CNT_INTVAL },
  232. { "LED F7", 3 | CNT_INTVAL },
  233. { "LED F8", 7 | CNT_INTVAL },
  234. { "LED touch1", 10 | CNT_INTVAL },
  235. { "LED touch2", 14 | CNT_INTVAL },
  236. { "LED touch3", 2 | CNT_INTVAL },
  237. { "LED touch4", 6 | CNT_INTVAL },
  238. { "LED touch5", 9 | CNT_INTVAL },
  239. { "LED touch6", 13 | CNT_INTVAL },
  240. { "LED touch7", 1 | CNT_INTVAL },
  241. { "LED touch8", 5 | CNT_INTVAL },
  242. { "LED left", 18 | CNT_INTVAL },
  243. { "LED right", 22 | CNT_INTVAL },
  244. { "LED up", 16 | CNT_INTVAL },
  245. { "LED down", 20 | CNT_INTVAL },
  246. { "LED stop", 23 | CNT_INTVAL },
  247. { "LED play", 21 | CNT_INTVAL },
  248. { "LED record", 19 | CNT_INTVAL },
  249. { "LED listen", 17 | CNT_INTVAL },
  250. { "LED lcd", 30 | CNT_INTVAL },
  251. { "LED menu", 28 | CNT_INTVAL },
  252. { "LED sound", 31 | CNT_INTVAL },
  253. { "LED esc", 29 | CNT_INTVAL },
  254. { "LED view", 27 | CNT_INTVAL },
  255. { "LED enter", 24 | CNT_INTVAL },
  256. { "LED control", 26 | CNT_INTVAL }
  257. };
  258. static struct caiaq_controller a8dj_controller[] = {
  259. { "Current input mode", 0 | CNT_INTVAL },
  260. { "GND lift for TC Vinyl mode", 24 + 0 },
  261. { "GND lift for TC CD/Line mode", 24 + 1 },
  262. { "GND lift for phono mode", 24 + 2 },
  263. { "Software lock", 40 }
  264. };
  265. static struct caiaq_controller a4dj_controller[] = {
  266. { "Current input mode", 0 | CNT_INTVAL }
  267. };
  268. static struct caiaq_controller kontrolx1_controller[] = {
  269. { "LED FX A: ON", 7 | CNT_INTVAL },
  270. { "LED FX A: 1", 6 | CNT_INTVAL },
  271. { "LED FX A: 2", 5 | CNT_INTVAL },
  272. { "LED FX A: 3", 4 | CNT_INTVAL },
  273. { "LED FX B: ON", 3 | CNT_INTVAL },
  274. { "LED FX B: 1", 2 | CNT_INTVAL },
  275. { "LED FX B: 2", 1 | CNT_INTVAL },
  276. { "LED FX B: 3", 0 | CNT_INTVAL },
  277. { "LED Hotcue", 28 | CNT_INTVAL },
  278. { "LED Shift (white)", 29 | CNT_INTVAL },
  279. { "LED Shift (green)", 30 | CNT_INTVAL },
  280. { "LED Deck A: FX1", 24 | CNT_INTVAL },
  281. { "LED Deck A: FX2", 25 | CNT_INTVAL },
  282. { "LED Deck A: IN", 17 | CNT_INTVAL },
  283. { "LED Deck A: OUT", 16 | CNT_INTVAL },
  284. { "LED Deck A: < BEAT", 19 | CNT_INTVAL },
  285. { "LED Deck A: BEAT >", 18 | CNT_INTVAL },
  286. { "LED Deck A: CUE/ABS", 21 | CNT_INTVAL },
  287. { "LED Deck A: CUP/REL", 20 | CNT_INTVAL },
  288. { "LED Deck A: PLAY", 23 | CNT_INTVAL },
  289. { "LED Deck A: SYNC", 22 | CNT_INTVAL },
  290. { "LED Deck B: FX1", 26 | CNT_INTVAL },
  291. { "LED Deck B: FX2", 27 | CNT_INTVAL },
  292. { "LED Deck B: IN", 15 | CNT_INTVAL },
  293. { "LED Deck B: OUT", 14 | CNT_INTVAL },
  294. { "LED Deck B: < BEAT", 13 | CNT_INTVAL },
  295. { "LED Deck B: BEAT >", 12 | CNT_INTVAL },
  296. { "LED Deck B: CUE/ABS", 11 | CNT_INTVAL },
  297. { "LED Deck B: CUP/REL", 10 | CNT_INTVAL },
  298. { "LED Deck B: PLAY", 9 | CNT_INTVAL },
  299. { "LED Deck B: SYNC", 8 | CNT_INTVAL },
  300. };
  301. static struct caiaq_controller kontrols4_controller[] = {
  302. { "LED: Master: Quant", 10 | CNT_INTVAL },
  303. { "LED: Master: Headphone", 11 | CNT_INTVAL },
  304. { "LED: Master: Master", 12 | CNT_INTVAL },
  305. { "LED: Master: Snap", 14 | CNT_INTVAL },
  306. { "LED: Master: Warning", 15 | CNT_INTVAL },
  307. { "LED: Master: Master button", 112 | CNT_INTVAL },
  308. { "LED: Master: Snap button", 113 | CNT_INTVAL },
  309. { "LED: Master: Rec", 118 | CNT_INTVAL },
  310. { "LED: Master: Size", 119 | CNT_INTVAL },
  311. { "LED: Master: Quant button", 120 | CNT_INTVAL },
  312. { "LED: Master: Browser button", 121 | CNT_INTVAL },
  313. { "LED: Master: Play button", 126 | CNT_INTVAL },
  314. { "LED: Master: Undo button", 127 | CNT_INTVAL },
  315. { "LED: Channel A: >", 4 | CNT_INTVAL },
  316. { "LED: Channel A: <", 5 | CNT_INTVAL },
  317. { "LED: Channel A: Meter 1", 97 | CNT_INTVAL },
  318. { "LED: Channel A: Meter 2", 98 | CNT_INTVAL },
  319. { "LED: Channel A: Meter 3", 99 | CNT_INTVAL },
  320. { "LED: Channel A: Meter 4", 100 | CNT_INTVAL },
  321. { "LED: Channel A: Meter 5", 101 | CNT_INTVAL },
  322. { "LED: Channel A: Meter 6", 102 | CNT_INTVAL },
  323. { "LED: Channel A: Meter clip", 103 | CNT_INTVAL },
  324. { "LED: Channel A: Active", 114 | CNT_INTVAL },
  325. { "LED: Channel A: Cue", 116 | CNT_INTVAL },
  326. { "LED: Channel A: FX1", 149 | CNT_INTVAL },
  327. { "LED: Channel A: FX2", 148 | CNT_INTVAL },
  328. { "LED: Channel B: >", 2 | CNT_INTVAL },
  329. { "LED: Channel B: <", 3 | CNT_INTVAL },
  330. { "LED: Channel B: Meter 1", 89 | CNT_INTVAL },
  331. { "LED: Channel B: Meter 2", 90 | CNT_INTVAL },
  332. { "LED: Channel B: Meter 3", 91 | CNT_INTVAL },
  333. { "LED: Channel B: Meter 4", 92 | CNT_INTVAL },
  334. { "LED: Channel B: Meter 5", 93 | CNT_INTVAL },
  335. { "LED: Channel B: Meter 6", 94 | CNT_INTVAL },
  336. { "LED: Channel B: Meter clip", 95 | CNT_INTVAL },
  337. { "LED: Channel B: Active", 122 | CNT_INTVAL },
  338. { "LED: Channel B: Cue", 125 | CNT_INTVAL },
  339. { "LED: Channel B: FX1", 147 | CNT_INTVAL },
  340. { "LED: Channel B: FX2", 146 | CNT_INTVAL },
  341. { "LED: Channel C: >", 6 | CNT_INTVAL },
  342. { "LED: Channel C: <", 7 | CNT_INTVAL },
  343. { "LED: Channel C: Meter 1", 105 | CNT_INTVAL },
  344. { "LED: Channel C: Meter 2", 106 | CNT_INTVAL },
  345. { "LED: Channel C: Meter 3", 107 | CNT_INTVAL },
  346. { "LED: Channel C: Meter 4", 108 | CNT_INTVAL },
  347. { "LED: Channel C: Meter 5", 109 | CNT_INTVAL },
  348. { "LED: Channel C: Meter 6", 110 | CNT_INTVAL },
  349. { "LED: Channel C: Meter clip", 111 | CNT_INTVAL },
  350. { "LED: Channel C: Active", 115 | CNT_INTVAL },
  351. { "LED: Channel C: Cue", 117 | CNT_INTVAL },
  352. { "LED: Channel C: FX1", 151 | CNT_INTVAL },
  353. { "LED: Channel C: FX2", 150 | CNT_INTVAL },
  354. { "LED: Channel D: >", 0 | CNT_INTVAL },
  355. { "LED: Channel D: <", 1 | CNT_INTVAL },
  356. { "LED: Channel D: Meter 1", 81 | CNT_INTVAL },
  357. { "LED: Channel D: Meter 2", 82 | CNT_INTVAL },
  358. { "LED: Channel D: Meter 3", 83 | CNT_INTVAL },
  359. { "LED: Channel D: Meter 4", 84 | CNT_INTVAL },
  360. { "LED: Channel D: Meter 5", 85 | CNT_INTVAL },
  361. { "LED: Channel D: Meter 6", 86 | CNT_INTVAL },
  362. { "LED: Channel D: Meter clip", 87 | CNT_INTVAL },
  363. { "LED: Channel D: Active", 123 | CNT_INTVAL },
  364. { "LED: Channel D: Cue", 124 | CNT_INTVAL },
  365. { "LED: Channel D: FX1", 145 | CNT_INTVAL },
  366. { "LED: Channel D: FX2", 144 | CNT_INTVAL },
  367. { "LED: Deck A: 1 (blue)", 22 | CNT_INTVAL },
  368. { "LED: Deck A: 1 (green)", 23 | CNT_INTVAL },
  369. { "LED: Deck A: 2 (blue)", 20 | CNT_INTVAL },
  370. { "LED: Deck A: 2 (green)", 21 | CNT_INTVAL },
  371. { "LED: Deck A: 3 (blue)", 18 | CNT_INTVAL },
  372. { "LED: Deck A: 3 (green)", 19 | CNT_INTVAL },
  373. { "LED: Deck A: 4 (blue)", 16 | CNT_INTVAL },
  374. { "LED: Deck A: 4 (green)", 17 | CNT_INTVAL },
  375. { "LED: Deck A: Load", 44 | CNT_INTVAL },
  376. { "LED: Deck A: Deck C button", 45 | CNT_INTVAL },
  377. { "LED: Deck A: In", 47 | CNT_INTVAL },
  378. { "LED: Deck A: Out", 46 | CNT_INTVAL },
  379. { "LED: Deck A: Shift", 24 | CNT_INTVAL },
  380. { "LED: Deck A: Sync", 27 | CNT_INTVAL },
  381. { "LED: Deck A: Cue", 26 | CNT_INTVAL },
  382. { "LED: Deck A: Play", 25 | CNT_INTVAL },
  383. { "LED: Deck A: Tempo up", 33 | CNT_INTVAL },
  384. { "LED: Deck A: Tempo down", 32 | CNT_INTVAL },
  385. { "LED: Deck A: Master", 34 | CNT_INTVAL },
  386. { "LED: Deck A: Keylock", 35 | CNT_INTVAL },
  387. { "LED: Deck A: Deck A", 37 | CNT_INTVAL },
  388. { "LED: Deck A: Deck C", 36 | CNT_INTVAL },
  389. { "LED: Deck A: Samples", 38 | CNT_INTVAL },
  390. { "LED: Deck A: On Air", 39 | CNT_INTVAL },
  391. { "LED: Deck A: Sample 1", 31 | CNT_INTVAL },
  392. { "LED: Deck A: Sample 2", 30 | CNT_INTVAL },
  393. { "LED: Deck A: Sample 3", 29 | CNT_INTVAL },
  394. { "LED: Deck A: Sample 4", 28 | CNT_INTVAL },
  395. { "LED: Deck A: Digit 1 - A", 55 | CNT_INTVAL },
  396. { "LED: Deck A: Digit 1 - B", 54 | CNT_INTVAL },
  397. { "LED: Deck A: Digit 1 - C", 53 | CNT_INTVAL },
  398. { "LED: Deck A: Digit 1 - D", 52 | CNT_INTVAL },
  399. { "LED: Deck A: Digit 1 - E", 51 | CNT_INTVAL },
  400. { "LED: Deck A: Digit 1 - F", 50 | CNT_INTVAL },
  401. { "LED: Deck A: Digit 1 - G", 49 | CNT_INTVAL },
  402. { "LED: Deck A: Digit 1 - dot", 48 | CNT_INTVAL },
  403. { "LED: Deck A: Digit 2 - A", 63 | CNT_INTVAL },
  404. { "LED: Deck A: Digit 2 - B", 62 | CNT_INTVAL },
  405. { "LED: Deck A: Digit 2 - C", 61 | CNT_INTVAL },
  406. { "LED: Deck A: Digit 2 - D", 60 | CNT_INTVAL },
  407. { "LED: Deck A: Digit 2 - E", 59 | CNT_INTVAL },
  408. { "LED: Deck A: Digit 2 - F", 58 | CNT_INTVAL },
  409. { "LED: Deck A: Digit 2 - G", 57 | CNT_INTVAL },
  410. { "LED: Deck A: Digit 2 - dot", 56 | CNT_INTVAL },
  411. { "LED: Deck B: 1 (blue)", 78 | CNT_INTVAL },
  412. { "LED: Deck B: 1 (green)", 79 | CNT_INTVAL },
  413. { "LED: Deck B: 2 (blue)", 76 | CNT_INTVAL },
  414. { "LED: Deck B: 2 (green)", 77 | CNT_INTVAL },
  415. { "LED: Deck B: 3 (blue)", 74 | CNT_INTVAL },
  416. { "LED: Deck B: 3 (green)", 75 | CNT_INTVAL },
  417. { "LED: Deck B: 4 (blue)", 72 | CNT_INTVAL },
  418. { "LED: Deck B: 4 (green)", 73 | CNT_INTVAL },
  419. { "LED: Deck B: Load", 180 | CNT_INTVAL },
  420. { "LED: Deck B: Deck D button", 181 | CNT_INTVAL },
  421. { "LED: Deck B: In", 183 | CNT_INTVAL },
  422. { "LED: Deck B: Out", 182 | CNT_INTVAL },
  423. { "LED: Deck B: Shift", 64 | CNT_INTVAL },
  424. { "LED: Deck B: Sync", 67 | CNT_INTVAL },
  425. { "LED: Deck B: Cue", 66 | CNT_INTVAL },
  426. { "LED: Deck B: Play", 65 | CNT_INTVAL },
  427. { "LED: Deck B: Tempo up", 185 | CNT_INTVAL },
  428. { "LED: Deck B: Tempo down", 184 | CNT_INTVAL },
  429. { "LED: Deck B: Master", 186 | CNT_INTVAL },
  430. { "LED: Deck B: Keylock", 187 | CNT_INTVAL },
  431. { "LED: Deck B: Deck B", 189 | CNT_INTVAL },
  432. { "LED: Deck B: Deck D", 188 | CNT_INTVAL },
  433. { "LED: Deck B: Samples", 190 | CNT_INTVAL },
  434. { "LED: Deck B: On Air", 191 | CNT_INTVAL },
  435. { "LED: Deck B: Sample 1", 71 | CNT_INTVAL },
  436. { "LED: Deck B: Sample 2", 70 | CNT_INTVAL },
  437. { "LED: Deck B: Sample 3", 69 | CNT_INTVAL },
  438. { "LED: Deck B: Sample 4", 68 | CNT_INTVAL },
  439. { "LED: Deck B: Digit 1 - A", 175 | CNT_INTVAL },
  440. { "LED: Deck B: Digit 1 - B", 174 | CNT_INTVAL },
  441. { "LED: Deck B: Digit 1 - C", 173 | CNT_INTVAL },
  442. { "LED: Deck B: Digit 1 - D", 172 | CNT_INTVAL },
  443. { "LED: Deck B: Digit 1 - E", 171 | CNT_INTVAL },
  444. { "LED: Deck B: Digit 1 - F", 170 | CNT_INTVAL },
  445. { "LED: Deck B: Digit 1 - G", 169 | CNT_INTVAL },
  446. { "LED: Deck B: Digit 1 - dot", 168 | CNT_INTVAL },
  447. { "LED: Deck B: Digit 2 - A", 167 | CNT_INTVAL },
  448. { "LED: Deck B: Digit 2 - B", 166 | CNT_INTVAL },
  449. { "LED: Deck B: Digit 2 - C", 165 | CNT_INTVAL },
  450. { "LED: Deck B: Digit 2 - D", 164 | CNT_INTVAL },
  451. { "LED: Deck B: Digit 2 - E", 163 | CNT_INTVAL },
  452. { "LED: Deck B: Digit 2 - F", 162 | CNT_INTVAL },
  453. { "LED: Deck B: Digit 2 - G", 161 | CNT_INTVAL },
  454. { "LED: Deck B: Digit 2 - dot", 160 | CNT_INTVAL },
  455. { "LED: FX1: dry/wet", 153 | CNT_INTVAL },
  456. { "LED: FX1: 1", 154 | CNT_INTVAL },
  457. { "LED: FX1: 2", 155 | CNT_INTVAL },
  458. { "LED: FX1: 3", 156 | CNT_INTVAL },
  459. { "LED: FX1: Mode", 157 | CNT_INTVAL },
  460. { "LED: FX2: dry/wet", 129 | CNT_INTVAL },
  461. { "LED: FX2: 1", 130 | CNT_INTVAL },
  462. { "LED: FX2: 2", 131 | CNT_INTVAL },
  463. { "LED: FX2: 3", 132 | CNT_INTVAL },
  464. { "LED: FX2: Mode", 133 | CNT_INTVAL },
  465. };
  466. static struct caiaq_controller maschine_controller[] = {
  467. { "LED: Pad 1", 3 | CNT_INTVAL },
  468. { "LED: Pad 2", 2 | CNT_INTVAL },
  469. { "LED: Pad 3", 1 | CNT_INTVAL },
  470. { "LED: Pad 4", 0 | CNT_INTVAL },
  471. { "LED: Pad 5", 7 | CNT_INTVAL },
  472. { "LED: Pad 6", 6 | CNT_INTVAL },
  473. { "LED: Pad 7", 5 | CNT_INTVAL },
  474. { "LED: Pad 8", 4 | CNT_INTVAL },
  475. { "LED: Pad 9", 11 | CNT_INTVAL },
  476. { "LED: Pad 10", 10 | CNT_INTVAL },
  477. { "LED: Pad 11", 9 | CNT_INTVAL },
  478. { "LED: Pad 12", 8 | CNT_INTVAL },
  479. { "LED: Pad 13", 15 | CNT_INTVAL },
  480. { "LED: Pad 14", 14 | CNT_INTVAL },
  481. { "LED: Pad 15", 13 | CNT_INTVAL },
  482. { "LED: Pad 16", 12 | CNT_INTVAL },
  483. { "LED: Mute", 16 | CNT_INTVAL },
  484. { "LED: Solo", 17 | CNT_INTVAL },
  485. { "LED: Select", 18 | CNT_INTVAL },
  486. { "LED: Duplicate", 19 | CNT_INTVAL },
  487. { "LED: Navigate", 20 | CNT_INTVAL },
  488. { "LED: Pad Mode", 21 | CNT_INTVAL },
  489. { "LED: Pattern", 22 | CNT_INTVAL },
  490. { "LED: Scene", 23 | CNT_INTVAL },
  491. { "LED: Shift", 24 | CNT_INTVAL },
  492. { "LED: Erase", 25 | CNT_INTVAL },
  493. { "LED: Grid", 26 | CNT_INTVAL },
  494. { "LED: Right Bottom", 27 | CNT_INTVAL },
  495. { "LED: Rec", 28 | CNT_INTVAL },
  496. { "LED: Play", 29 | CNT_INTVAL },
  497. { "LED: Left Bottom", 32 | CNT_INTVAL },
  498. { "LED: Restart", 33 | CNT_INTVAL },
  499. { "LED: Group A", 41 | CNT_INTVAL },
  500. { "LED: Group B", 40 | CNT_INTVAL },
  501. { "LED: Group C", 37 | CNT_INTVAL },
  502. { "LED: Group D", 36 | CNT_INTVAL },
  503. { "LED: Group E", 39 | CNT_INTVAL },
  504. { "LED: Group F", 38 | CNT_INTVAL },
  505. { "LED: Group G", 35 | CNT_INTVAL },
  506. { "LED: Group H", 34 | CNT_INTVAL },
  507. { "LED: Auto Write", 42 | CNT_INTVAL },
  508. { "LED: Snap", 43 | CNT_INTVAL },
  509. { "LED: Right Top", 44 | CNT_INTVAL },
  510. { "LED: Left Top", 45 | CNT_INTVAL },
  511. { "LED: Sampling", 46 | CNT_INTVAL },
  512. { "LED: Browse", 47 | CNT_INTVAL },
  513. { "LED: Step", 48 | CNT_INTVAL },
  514. { "LED: Control", 49 | CNT_INTVAL },
  515. { "LED: Top Button 1", 57 | CNT_INTVAL },
  516. { "LED: Top Button 2", 56 | CNT_INTVAL },
  517. { "LED: Top Button 3", 55 | CNT_INTVAL },
  518. { "LED: Top Button 4", 54 | CNT_INTVAL },
  519. { "LED: Top Button 5", 53 | CNT_INTVAL },
  520. { "LED: Top Button 6", 52 | CNT_INTVAL },
  521. { "LED: Top Button 7", 51 | CNT_INTVAL },
  522. { "LED: Top Button 8", 50 | CNT_INTVAL },
  523. { "LED: Note Repeat", 58 | CNT_INTVAL },
  524. { "Backlight Display", 59 | CNT_INTVAL }
  525. };
  526. static int add_controls(struct caiaq_controller *c, int num,
  527. struct snd_usb_caiaqdev *cdev)
  528. {
  529. int i, ret;
  530. struct snd_kcontrol *kc;
  531. for (i = 0; i < num; i++, c++) {
  532. kcontrol_template.name = c->name;
  533. kcontrol_template.private_value = c->index;
  534. kc = snd_ctl_new1(&kcontrol_template, cdev);
  535. ret = snd_ctl_add(cdev->chip.card, kc);
  536. if (ret < 0)
  537. return ret;
  538. }
  539. return 0;
  540. }
  541. int snd_usb_caiaq_control_init(struct snd_usb_caiaqdev *cdev)
  542. {
  543. int ret = 0;
  544. switch (cdev->chip.usb_id) {
  545. case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_AK1):
  546. ret = add_controls(ak1_controller,
  547. ARRAY_SIZE(ak1_controller), cdev);
  548. break;
  549. case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_RIGKONTROL2):
  550. ret = add_controls(rk2_controller,
  551. ARRAY_SIZE(rk2_controller), cdev);
  552. break;
  553. case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_RIGKONTROL3):
  554. ret = add_controls(rk3_controller,
  555. ARRAY_SIZE(rk3_controller), cdev);
  556. break;
  557. case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_KORECONTROLLER):
  558. case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_KORECONTROLLER2):
  559. ret = add_controls(kore_controller,
  560. ARRAY_SIZE(kore_controller), cdev);
  561. break;
  562. case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_AUDIO8DJ):
  563. ret = add_controls(a8dj_controller,
  564. ARRAY_SIZE(a8dj_controller), cdev);
  565. break;
  566. case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_AUDIO4DJ):
  567. ret = add_controls(a4dj_controller,
  568. ARRAY_SIZE(a4dj_controller), cdev);
  569. break;
  570. case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_TRAKTORKONTROLX1):
  571. ret = add_controls(kontrolx1_controller,
  572. ARRAY_SIZE(kontrolx1_controller), cdev);
  573. break;
  574. case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_TRAKTORKONTROLS4):
  575. ret = add_controls(kontrols4_controller,
  576. ARRAY_SIZE(kontrols4_controller), cdev);
  577. break;
  578. case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_MASCHINECONTROLLER):
  579. ret = add_controls(maschine_controller,
  580. ARRAY_SIZE(maschine_controller), cdev);
  581. break;
  582. }
  583. return ret;
  584. }