aboutsummaryrefslogtreecommitdiffstats
path: root/sound/usb/caiaq
diff options
context:
space:
mode:
authorHannes Gräuler <hgraeule@uos.de>2013-09-28 15:51:08 -0400
committerTakashi Iwai <tiwai@suse.de>2013-09-30 05:19:16 -0400
commitd2724de1874917be2a12939657820616742bd8ec (patch)
treec21a2e0857e4dca3a1148ea2d6bbe4d4deae642f /sound/usb/caiaq
parente84841f9ba134d3aa4cad5c16d05712672583c76 (diff)
ALSA: snd-usb-caiaq: LED support for Maschine Controller
This patch adds LED support for the Native Instruments Maschine Controller. It adds ALSA controls for dimming the LEDs of all buttons and the backlight of the two displays. Signed-off-by: Hannes Gräuler <hgraeule@uos.de> Acked-by: Daniel Mack <zonque@gmail.com> Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/usb/caiaq')
-rw-r--r--sound/usb/caiaq/control.c92
-rw-r--r--sound/usb/caiaq/device.c25
-rw-r--r--sound/usb/caiaq/device.h5
3 files changed, 122 insertions, 0 deletions
diff --git a/sound/usb/caiaq/control.c b/sound/usb/caiaq/control.c
index ae6b50f9ed56..f65fc0987cfb 100644
--- a/sound/usb/caiaq/control.c
+++ b/sound/usb/caiaq/control.c
@@ -28,6 +28,7 @@
28#include "control.h" 28#include "control.h"
29 29
30#define CNT_INTVAL 0x10000 30#define CNT_INTVAL 0x10000
31#define MASCHINE_BANK_SIZE 32
31 32
32static int control_info(struct snd_kcontrol *kcontrol, 33static int control_info(struct snd_kcontrol *kcontrol,
33 struct snd_ctl_elem_info *uinfo) 34 struct snd_ctl_elem_info *uinfo)
@@ -105,6 +106,10 @@ static int control_put(struct snd_kcontrol *kcontrol,
105 USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_TRAKTORKONTROLX1)) 106 USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_TRAKTORKONTROLX1))
106 cmd = EP1_CMD_DIMM_LEDS; 107 cmd = EP1_CMD_DIMM_LEDS;
107 108
109 if (cdev->chip.usb_id ==
110 USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_MASCHINECONTROLLER))
111 cmd = EP1_CMD_DIMM_LEDS;
112
108 if (pos & CNT_INTVAL) { 113 if (pos & CNT_INTVAL) {
109 int i = pos & ~CNT_INTVAL; 114 int i = pos & ~CNT_INTVAL;
110 115
@@ -121,6 +126,20 @@ static int control_put(struct snd_kcontrol *kcontrol,
121 usb_sndbulkpipe(cdev->chip.dev, 8), 126 usb_sndbulkpipe(cdev->chip.dev, 8),
122 cdev->ep8_out_buf, sizeof(cdev->ep8_out_buf), 127 cdev->ep8_out_buf, sizeof(cdev->ep8_out_buf),
123 &actual_len, 200); 128 &actual_len, 200);
129 } else if (cdev->chip.usb_id ==
130 USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_MASCHINECONTROLLER)) {
131
132 int bank = 0;
133 int offset = 0;
134
135 if (i >= MASCHINE_BANK_SIZE) {
136 bank = 0x1e;
137 offset = MASCHINE_BANK_SIZE;
138 }
139
140 snd_usb_caiaq_send_command_bank(cdev, cmd, bank,
141 cdev->control_state + offset,
142 MASCHINE_BANK_SIZE);
124 } else { 143 } else {
125 snd_usb_caiaq_send_command(cdev, cmd, 144 snd_usb_caiaq_send_command(cdev, cmd,
126 cdev->control_state, sizeof(cdev->control_state)); 145 cdev->control_state, sizeof(cdev->control_state));
@@ -490,6 +509,74 @@ static struct caiaq_controller kontrols4_controller[] = {
490 { "LED: FX2: Mode", 133 | CNT_INTVAL }, 509 { "LED: FX2: Mode", 133 | CNT_INTVAL },
491}; 510};
492 511
512static struct caiaq_controller maschine_controller[] = {
513 { "LED: Pad 1", 3 | CNT_INTVAL },
514 { "LED: Pad 2", 2 | CNT_INTVAL },
515 { "LED: Pad 3", 1 | CNT_INTVAL },
516 { "LED: Pad 4", 0 | CNT_INTVAL },
517 { "LED: Pad 5", 7 | CNT_INTVAL },
518 { "LED: Pad 6", 6 | CNT_INTVAL },
519 { "LED: Pad 7", 5 | CNT_INTVAL },
520 { "LED: Pad 8", 4 | CNT_INTVAL },
521 { "LED: Pad 9", 11 | CNT_INTVAL },
522 { "LED: Pad 10", 10 | CNT_INTVAL },
523 { "LED: Pad 11", 9 | CNT_INTVAL },
524 { "LED: Pad 12", 8 | CNT_INTVAL },
525 { "LED: Pad 13", 15 | CNT_INTVAL },
526 { "LED: Pad 14", 14 | CNT_INTVAL },
527 { "LED: Pad 15", 13 | CNT_INTVAL },
528 { "LED: Pad 16", 12 | CNT_INTVAL },
529
530 { "LED: Mute", 16 | CNT_INTVAL },
531 { "LED: Solo", 17 | CNT_INTVAL },
532 { "LED: Select", 18 | CNT_INTVAL },
533 { "LED: Duplicate", 19 | CNT_INTVAL },
534 { "LED: Navigate", 20 | CNT_INTVAL },
535 { "LED: Pad Mode", 21 | CNT_INTVAL },
536 { "LED: Pattern", 22 | CNT_INTVAL },
537 { "LED: Scene", 23 | CNT_INTVAL },
538
539 { "LED: Shift", 24 | CNT_INTVAL },
540 { "LED: Erase", 25 | CNT_INTVAL },
541 { "LED: Grid", 26 | CNT_INTVAL },
542 { "LED: Right Bottom", 27 | CNT_INTVAL },
543 { "LED: Rec", 28 | CNT_INTVAL },
544 { "LED: Play", 29 | CNT_INTVAL },
545 { "LED: Left Bottom", 32 | CNT_INTVAL },
546 { "LED: Restart", 33 | CNT_INTVAL },
547
548 { "LED: Group A", 41 | CNT_INTVAL },
549 { "LED: Group B", 40 | CNT_INTVAL },
550 { "LED: Group C", 37 | CNT_INTVAL },
551 { "LED: Group D", 36 | CNT_INTVAL },
552 { "LED: Group E", 39 | CNT_INTVAL },
553 { "LED: Group F", 38 | CNT_INTVAL },
554 { "LED: Group G", 35 | CNT_INTVAL },
555 { "LED: Group H", 34 | CNT_INTVAL },
556
557 { "LED: Auto Write", 42 | CNT_INTVAL },
558 { "LED: Snap", 43 | CNT_INTVAL },
559 { "LED: Right Top", 44 | CNT_INTVAL },
560 { "LED: Left Top", 45 | CNT_INTVAL },
561 { "LED: Sampling", 46 | CNT_INTVAL },
562 { "LED: Browse", 47 | CNT_INTVAL },
563 { "LED: Step", 48 | CNT_INTVAL },
564 { "LED: Control", 49 | CNT_INTVAL },
565
566 { "LED: Top Button 1", 57 | CNT_INTVAL },
567 { "LED: Top Button 2", 56 | CNT_INTVAL },
568 { "LED: Top Button 3", 55 | CNT_INTVAL },
569 { "LED: Top Button 4", 54 | CNT_INTVAL },
570 { "LED: Top Button 5", 53 | CNT_INTVAL },
571 { "LED: Top Button 6", 52 | CNT_INTVAL },
572 { "LED: Top Button 7", 51 | CNT_INTVAL },
573 { "LED: Top Button 8", 50 | CNT_INTVAL },
574
575 { "LED: Note Repeat", 58 | CNT_INTVAL },
576
577 { "Backlight Display", 59 | CNT_INTVAL }
578};
579
493static int add_controls(struct caiaq_controller *c, int num, 580static int add_controls(struct caiaq_controller *c, int num,
494 struct snd_usb_caiaqdev *cdev) 581 struct snd_usb_caiaqdev *cdev)
495{ 582{
@@ -553,6 +640,11 @@ int snd_usb_caiaq_control_init(struct snd_usb_caiaqdev *cdev)
553 ret = add_controls(kontrols4_controller, 640 ret = add_controls(kontrols4_controller,
554 ARRAY_SIZE(kontrols4_controller), cdev); 641 ARRAY_SIZE(kontrols4_controller), cdev);
555 break; 642 break;
643
644 case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_MASCHINECONTROLLER):
645 ret = add_controls(maschine_controller,
646 ARRAY_SIZE(maschine_controller), cdev);
647 break;
556 } 648 }
557 649
558 return ret; 650 return ret;
diff --git a/sound/usb/caiaq/device.c b/sound/usb/caiaq/device.c
index 1a61dd12fe38..bc55f708a696 100644
--- a/sound/usb/caiaq/device.c
+++ b/sound/usb/caiaq/device.c
@@ -235,6 +235,31 @@ int snd_usb_caiaq_send_command(struct snd_usb_caiaqdev *cdev,
235 cdev->ep1_out_buf, len+1, &actual_len, 200); 235 cdev->ep1_out_buf, len+1, &actual_len, 200);
236} 236}
237 237
238int snd_usb_caiaq_send_command_bank(struct snd_usb_caiaqdev *cdev,
239 unsigned char command,
240 unsigned char bank,
241 const unsigned char *buffer,
242 int len)
243{
244 int actual_len;
245 struct usb_device *usb_dev = cdev->chip.dev;
246
247 if (!usb_dev)
248 return -EIO;
249
250 if (len > EP1_BUFSIZE - 2)
251 len = EP1_BUFSIZE - 2;
252
253 if (buffer && len > 0)
254 memcpy(cdev->ep1_out_buf+2, buffer, len);
255
256 cdev->ep1_out_buf[0] = command;
257 cdev->ep1_out_buf[1] = bank;
258
259 return usb_bulk_msg(usb_dev, usb_sndbulkpipe(usb_dev, 1),
260 cdev->ep1_out_buf, len+2, &actual_len, 200);
261}
262
238int snd_usb_caiaq_set_audio_params (struct snd_usb_caiaqdev *cdev, 263int snd_usb_caiaq_set_audio_params (struct snd_usb_caiaqdev *cdev,
239 int rate, int depth, int bpp) 264 int rate, int depth, int bpp)
240{ 265{
diff --git a/sound/usb/caiaq/device.h b/sound/usb/caiaq/device.h
index ad102fac6942..ab0f7520a99b 100644
--- a/sound/usb/caiaq/device.h
+++ b/sound/usb/caiaq/device.h
@@ -128,5 +128,10 @@ int snd_usb_caiaq_send_command(struct snd_usb_caiaqdev *cdev,
128 unsigned char command, 128 unsigned char command,
129 const unsigned char *buffer, 129 const unsigned char *buffer,
130 int len); 130 int len);
131int snd_usb_caiaq_send_command_bank(struct snd_usb_caiaqdev *cdev,
132 unsigned char command,
133 unsigned char bank,
134 const unsigned char *buffer,
135 int len);
131 136
132#endif /* CAIAQ_DEVICE_H */ 137#endif /* CAIAQ_DEVICE_H */