aboutsummaryrefslogtreecommitdiffstats
path: root/sound/usb/caiaq
diff options
context:
space:
mode:
Diffstat (limited to 'sound/usb/caiaq')
-rw-r--r--sound/usb/caiaq/Makefile3
-rw-r--r--sound/usb/caiaq/caiaq-audio.c7
-rw-r--r--sound/usb/caiaq/caiaq-control.c315
-rw-r--r--sound/usb/caiaq/caiaq-control.h6
-rw-r--r--sound/usb/caiaq/caiaq-device.c92
-rw-r--r--sound/usb/caiaq/caiaq-device.h20
-rw-r--r--sound/usb/caiaq/caiaq-input.c238
-rw-r--r--sound/usb/caiaq/caiaq-midi.c3
8 files changed, 578 insertions, 106 deletions
diff --git a/sound/usb/caiaq/Makefile b/sound/usb/caiaq/Makefile
index 455c8c58a1bd..23dadd5a11cd 100644
--- a/sound/usb/caiaq/Makefile
+++ b/sound/usb/caiaq/Makefile
@@ -1,3 +1,4 @@
1snd-usb-caiaq-objs := caiaq-device.o caiaq-audio.o caiaq-midi.o caiaq-input.o 1snd-usb-caiaq-y := caiaq-device.o caiaq-audio.o caiaq-midi.o caiaq-control.o
2snd-usb-caiaq-$(CONFIG_SND_USB_CAIAQ_INPUT) += caiaq-input.o
2 3
3obj-$(CONFIG_SND_USB_CAIAQ) += snd-usb-caiaq.o 4obj-$(CONFIG_SND_USB_CAIAQ) += snd-usb-caiaq.o
diff --git a/sound/usb/caiaq/caiaq-audio.c b/sound/usb/caiaq/caiaq-audio.c
index 0666908a2361..9cc4cd8283f9 100644
--- a/sound/usb/caiaq/caiaq-audio.c
+++ b/sound/usb/caiaq/caiaq-audio.c
@@ -16,7 +16,6 @@
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17*/ 17*/
18 18
19#include <sound/driver.h>
20#include <linux/init.h> 19#include <linux/init.h>
21#include <linux/module.h> 20#include <linux/module.h>
22#include <linux/moduleparam.h> 21#include <linux/moduleparam.h>
@@ -27,9 +26,7 @@
27#include <sound/initval.h> 26#include <sound/initval.h>
28#include <sound/pcm.h> 27#include <sound/pcm.h>
29#include <sound/rawmidi.h> 28#include <sound/rawmidi.h>
30#ifdef CONFIG_SND_USB_CAIAQ_INPUT
31#include <linux/input.h> 29#include <linux/input.h>
32#endif
33 30
34#include "caiaq-device.h" 31#include "caiaq-device.h"
35#include "caiaq-audio.h" 32#include "caiaq-audio.h"
@@ -60,7 +57,7 @@ static struct snd_pcm_hardware snd_usb_caiaq_pcm_hardware = {
60 .channels_min = CHANNELS_PER_STREAM, 57 .channels_min = CHANNELS_PER_STREAM,
61 .channels_max = CHANNELS_PER_STREAM, 58 .channels_max = CHANNELS_PER_STREAM,
62 .buffer_bytes_max = MAX_BUFFER_SIZE, 59 .buffer_bytes_max = MAX_BUFFER_SIZE,
63 .period_bytes_min = 4096, 60 .period_bytes_min = 128,
64 .period_bytes_max = MAX_BUFFER_SIZE, 61 .period_bytes_max = MAX_BUFFER_SIZE,
65 .periods_min = 1, 62 .periods_min = 1,
66 .periods_max = 1024, 63 .periods_max = 1024,
@@ -606,7 +603,7 @@ static void free_urbs(struct urb **urbs)
606 kfree(urbs); 603 kfree(urbs);
607} 604}
608 605
609int __devinit snd_usb_caiaq_audio_init(struct snd_usb_caiaqdev *dev) 606int snd_usb_caiaq_audio_init(struct snd_usb_caiaqdev *dev)
610{ 607{
611 int i, ret; 608 int i, ret;
612 609
diff --git a/sound/usb/caiaq/caiaq-control.c b/sound/usb/caiaq/caiaq-control.c
new file mode 100644
index 000000000000..798ca124da58
--- /dev/null
+++ b/sound/usb/caiaq/caiaq-control.c
@@ -0,0 +1,315 @@
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
20#include <linux/init.h>
21#include <linux/interrupt.h>
22#include <linux/usb.h>
23#include <sound/core.h>
24#include <sound/initval.h>
25#include <sound/pcm.h>
26#include <sound/rawmidi.h>
27#include <sound/control.h>
28#include <linux/input.h>
29
30#include "caiaq-device.h"
31#include "caiaq-control.h"
32
33#define CNT_INTVAL 0x10000
34
35static int control_info(struct snd_kcontrol *kcontrol,
36 struct snd_ctl_elem_info *uinfo)
37{
38 struct snd_usb_audio *chip = snd_kcontrol_chip(kcontrol);
39 struct snd_usb_caiaqdev *dev = caiaqdev(chip->card);
40 int pos = kcontrol->private_value;
41 int is_intval = pos & CNT_INTVAL;
42
43 uinfo->count = 1;
44 pos &= ~CNT_INTVAL;
45
46 if (dev->chip.usb_id ==
47 USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_AUDIO8DJ)
48 && (pos == 0)) {
49 /* current input mode of A8DJ */
50 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
51 uinfo->value.integer.min = 0;
52 uinfo->value.integer.max = 2;
53 return 0;
54 }
55
56 if (is_intval) {
57 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
58 uinfo->value.integer.min = 0;
59 uinfo->value.integer.max = 64;
60 } else {
61 uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
62 uinfo->value.integer.min = 0;
63 uinfo->value.integer.max = 1;
64 }
65
66 return 0;
67}
68
69static int control_get(struct snd_kcontrol *kcontrol,
70 struct snd_ctl_elem_value *ucontrol)
71{
72 struct snd_usb_audio *chip = snd_kcontrol_chip(kcontrol);
73 struct snd_usb_caiaqdev *dev = caiaqdev(chip->card);
74 int pos = kcontrol->private_value;
75
76 if (pos & CNT_INTVAL)
77 ucontrol->value.integer.value[0]
78 = dev->control_state[pos & ~CNT_INTVAL];
79 else
80 ucontrol->value.integer.value[0]
81 = !!(dev->control_state[pos / 8] & (1 << pos % 8));
82
83 return 0;
84}
85
86static int control_put(struct snd_kcontrol *kcontrol,
87 struct snd_ctl_elem_value *ucontrol)
88{
89 struct snd_usb_audio *chip = snd_kcontrol_chip(kcontrol);
90 struct snd_usb_caiaqdev *dev = caiaqdev(chip->card);
91 int pos = kcontrol->private_value;
92
93 if (pos & CNT_INTVAL) {
94 dev->control_state[pos & ~CNT_INTVAL]
95 = ucontrol->value.integer.value[0];
96 snd_usb_caiaq_send_command(dev, EP1_CMD_DIMM_LEDS,
97 dev->control_state, sizeof(dev->control_state));
98 } else {
99 if (ucontrol->value.integer.value[0])
100 dev->control_state[pos / 8] |= 1 << (pos % 8);
101 else
102 dev->control_state[pos / 8] &= ~(1 << (pos % 8));
103
104 snd_usb_caiaq_send_command(dev, EP1_CMD_WRITE_IO,
105 dev->control_state, sizeof(dev->control_state));
106 }
107
108 return 1;
109}
110
111static struct snd_kcontrol_new kcontrol_template __devinitdata = {
112 .iface = SNDRV_CTL_ELEM_IFACE_HWDEP,
113 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE,
114 .index = 0,
115 .info = control_info,
116 .get = control_get,
117 .put = control_put,
118 /* name and private_value filled later */
119};
120
121struct caiaq_controller {
122 char *name;
123 int index;
124};
125
126static struct caiaq_controller ak1_controller[] = {
127 { "LED left", 2 },
128 { "LED middle", 1 },
129 { "LED right", 0 },
130 { "LED ring", 3 }
131};
132
133static struct caiaq_controller rk2_controller[] = {
134 { "LED 1", 5 },
135 { "LED 2", 4 },
136 { "LED 3", 3 },
137 { "LED 4", 2 },
138 { "LED 5", 1 },
139 { "LED 6", 0 },
140 { "LED pedal", 6 },
141 { "LED 7seg_1b", 8 },
142 { "LED 7seg_1c", 9 },
143 { "LED 7seg_2a", 10 },
144 { "LED 7seg_2b", 11 },
145 { "LED 7seg_2c", 12 },
146 { "LED 7seg_2d", 13 },
147 { "LED 7seg_2e", 14 },
148 { "LED 7seg_2f", 15 },
149 { "LED 7seg_2g", 16 },
150 { "LED 7seg_3a", 17 },
151 { "LED 7seg_3b", 18 },
152 { "LED 7seg_3c", 19 },
153 { "LED 7seg_3d", 20 },
154 { "LED 7seg_3e", 21 },
155 { "LED 7seg_3f", 22 },
156 { "LED 7seg_3g", 23 }
157};
158
159static struct caiaq_controller rk3_controller[] = {
160 { "LED 7seg_1a", 0 + 0 },
161 { "LED 7seg_1b", 0 + 1 },
162 { "LED 7seg_1c", 0 + 2 },
163 { "LED 7seg_1d", 0 + 3 },
164 { "LED 7seg_1e", 0 + 4 },
165 { "LED 7seg_1f", 0 + 5 },
166 { "LED 7seg_1g", 0 + 6 },
167 { "LED 7seg_1p", 0 + 7 },
168
169 { "LED 7seg_2a", 8 + 0 },
170 { "LED 7seg_2b", 8 + 1 },
171 { "LED 7seg_2c", 8 + 2 },
172 { "LED 7seg_2d", 8 + 3 },
173 { "LED 7seg_2e", 8 + 4 },
174 { "LED 7seg_2f", 8 + 5 },
175 { "LED 7seg_2g", 8 + 6 },
176 { "LED 7seg_2p", 8 + 7 },
177
178 { "LED 7seg_3a", 16 + 0 },
179 { "LED 7seg_3b", 16 + 1 },
180 { "LED 7seg_3c", 16 + 2 },
181 { "LED 7seg_3d", 16 + 3 },
182 { "LED 7seg_3e", 16 + 4 },
183 { "LED 7seg_3f", 16 + 5 },
184 { "LED 7seg_3g", 16 + 6 },
185 { "LED 7seg_3p", 16 + 7 },
186
187 { "LED 7seg_4a", 24 + 0 },
188 { "LED 7seg_4b", 24 + 1 },
189 { "LED 7seg_4c", 24 + 2 },
190 { "LED 7seg_4d", 24 + 3 },
191 { "LED 7seg_4e", 24 + 4 },
192 { "LED 7seg_4f", 24 + 5 },
193 { "LED 7seg_4g", 24 + 6 },
194 { "LED 7seg_4p", 24 + 7 },
195
196 { "LED 1", 32 + 0 },
197 { "LED 2", 32 + 1 },
198 { "LED 3", 32 + 2 },
199 { "LED 4", 32 + 3 },
200 { "LED 5", 32 + 4 },
201 { "LED 6", 32 + 5 },
202 { "LED 7", 32 + 6 },
203 { "LED 8", 32 + 7 },
204 { "LED pedal", 32 + 8 }
205};
206
207static struct caiaq_controller kore_controller[] = {
208 { "LED F1", 8 | CNT_INTVAL },
209 { "LED F2", 12 | CNT_INTVAL },
210 { "LED F3", 0 | CNT_INTVAL },
211 { "LED F4", 4 | CNT_INTVAL },
212 { "LED F5", 11 | CNT_INTVAL },
213 { "LED F6", 15 | CNT_INTVAL },
214 { "LED F7", 3 | CNT_INTVAL },
215 { "LED F8", 7 | CNT_INTVAL },
216 { "LED touch1", 10 | CNT_INTVAL },
217 { "LED touch2", 14 | CNT_INTVAL },
218 { "LED touch3", 2 | CNT_INTVAL },
219 { "LED touch4", 6 | CNT_INTVAL },
220 { "LED touch5", 9 | CNT_INTVAL },
221 { "LED touch6", 13 | CNT_INTVAL },
222 { "LED touch7", 1 | CNT_INTVAL },
223 { "LED touch8", 5 | CNT_INTVAL },
224 { "LED left", 18 | CNT_INTVAL },
225 { "LED right", 22 | CNT_INTVAL },
226 { "LED up", 16 | CNT_INTVAL },
227 { "LED down", 20 | CNT_INTVAL },
228 { "LED stop", 23 | CNT_INTVAL },
229 { "LED play", 21 | CNT_INTVAL },
230 { "LED record", 19 | CNT_INTVAL },
231 { "LED listen", 17 | CNT_INTVAL },
232 { "LED lcd", 30 | CNT_INTVAL },
233 { "LED menu", 28 | CNT_INTVAL },
234 { "LED sound", 31 | CNT_INTVAL },
235 { "LED esc", 29 | CNT_INTVAL },
236 { "LED view", 27 | CNT_INTVAL },
237 { "LED enter", 24 | CNT_INTVAL },
238 { "LED control", 26 | CNT_INTVAL }
239};
240
241static struct caiaq_controller a8dj_controller[] = {
242 { "Current input mode", 0 | CNT_INTVAL },
243 { "GND lift for TC Vinyl mode", 24 + 0 },
244 { "GND lift for TC CD/Line mode", 24 + 1 },
245 { "GND lift for phono mode", 24 + 2 },
246 { "GND lift for TC Vinyl mode", 24 + 3 },
247 { "Software lock", 40 }
248};
249
250int __devinit snd_usb_caiaq_control_init(struct snd_usb_caiaqdev *dev)
251{
252 int i;
253 struct snd_kcontrol *kc;
254
255 switch (dev->chip.usb_id) {
256 case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_AK1):
257 for (i = 0; i < ARRAY_SIZE(ak1_controller); i++) {
258 struct caiaq_controller *c = ak1_controller + i;
259 kcontrol_template.name = c->name;
260 kcontrol_template.private_value = c->index;
261 kc = snd_ctl_new1(&kcontrol_template, dev);
262 snd_ctl_add(dev->chip.card, kc);
263 }
264
265 break;
266
267 case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_RIGKONTROL2):
268 for (i = 0; i < ARRAY_SIZE(rk2_controller); i++) {
269 struct caiaq_controller *c = rk2_controller + i;
270 kcontrol_template.name = c->name;
271 kcontrol_template.private_value = c->index;
272 kc = snd_ctl_new1(&kcontrol_template, dev);
273 snd_ctl_add(dev->chip.card, kc);
274 }
275
276 break;
277
278 case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_RIGKONTROL3):
279 for (i = 0; i < ARRAY_SIZE(rk3_controller); i++) {
280 struct caiaq_controller *c = rk3_controller + i;
281 kcontrol_template.name = c->name;
282 kcontrol_template.private_value = c->index;
283 kc = snd_ctl_new1(&kcontrol_template, dev);
284 snd_ctl_add(dev->chip.card, kc);
285 }
286
287 break;
288
289 case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_KORECONTROLLER):
290 case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_KORECONTROLLER2):
291 for (i = 0; i < ARRAY_SIZE(kore_controller); i++) {
292 struct caiaq_controller *c = kore_controller + i;
293 kcontrol_template.name = c->name;
294 kcontrol_template.private_value = c->index;
295 kc = snd_ctl_new1(&kcontrol_template, dev);
296 snd_ctl_add(dev->chip.card, kc);
297 }
298
299 break;
300
301 case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_AUDIO8DJ):
302 for (i = 0; i < ARRAY_SIZE(a8dj_controller); i++) {
303 struct caiaq_controller *c = a8dj_controller + i;
304 kcontrol_template.name = c->name;
305 kcontrol_template.private_value = c->index;
306 kc = snd_ctl_new1(&kcontrol_template, dev);
307 snd_ctl_add(dev->chip.card, kc);
308 }
309
310 break;
311 }
312
313 return 0;
314}
315
diff --git a/sound/usb/caiaq/caiaq-control.h b/sound/usb/caiaq/caiaq-control.h
new file mode 100644
index 000000000000..2e7ab1aa4fb3
--- /dev/null
+++ b/sound/usb/caiaq/caiaq-control.h
@@ -0,0 +1,6 @@
1#ifndef CAIAQ_CONTROL_H
2#define CAIAQ_CONTROL_H
3
4int snd_usb_caiaq_control_init(struct snd_usb_caiaqdev *dev);
5
6#endif /* CAIAQ_CONTROL_H */
diff --git a/sound/usb/caiaq/caiaq-device.c b/sound/usb/caiaq/caiaq-device.c
index 58af8142c571..58d25e4e7d6c 100644
--- a/sound/usb/caiaq/caiaq-device.c
+++ b/sound/usb/caiaq/caiaq-device.c
@@ -26,26 +26,28 @@
26#include <linux/usb.h> 26#include <linux/usb.h>
27#include <linux/input.h> 27#include <linux/input.h>
28#include <linux/spinlock.h> 28#include <linux/spinlock.h>
29#include <sound/driver.h>
30#include <sound/core.h> 29#include <sound/core.h>
31#include <sound/initval.h> 30#include <sound/initval.h>
32#include <sound/pcm.h> 31#include <sound/pcm.h>
33#include <sound/rawmidi.h> 32#include <sound/rawmidi.h>
33#include <sound/control.h>
34 34
35#include "caiaq-device.h" 35#include "caiaq-device.h"
36#include "caiaq-audio.h" 36#include "caiaq-audio.h"
37#include "caiaq-midi.h" 37#include "caiaq-midi.h"
38#include "caiaq-control.h"
38 39
39#ifdef CONFIG_SND_USB_CAIAQ_INPUT 40#ifdef CONFIG_SND_USB_CAIAQ_INPUT
40#include "caiaq-input.h" 41#include "caiaq-input.h"
41#endif 42#endif
42 43
43MODULE_AUTHOR("Daniel Mack <daniel@caiaq.de>"); 44MODULE_AUTHOR("Daniel Mack <daniel@caiaq.de>");
44MODULE_DESCRIPTION("caiaq USB audio, version 1.2.0"); 45MODULE_DESCRIPTION("caiaq USB audio, version 1.3.2");
45MODULE_LICENSE("GPL"); 46MODULE_LICENSE("GPL");
46MODULE_SUPPORTED_DEVICE("{{Native Instruments, RigKontrol2}," 47MODULE_SUPPORTED_DEVICE("{{Native Instruments, RigKontrol2},"
47 "{Native Instruments, RigKontrol3}," 48 "{Native Instruments, RigKontrol3},"
48 "{Native Instruments, Kore Controller}," 49 "{Native Instruments, Kore Controller},"
50 "{Native Instruments, Kore Controller 2},"
49 "{Native Instruments, Audio Kontrol 1}" 51 "{Native Instruments, Audio Kontrol 1}"
50 "{Native Instruments, Audio 8 DJ}}"); 52 "{Native Instruments, Audio 8 DJ}}");
51 53
@@ -94,6 +96,11 @@ static struct usb_device_id snd_usb_id_table[] = {
94 .idProduct = USB_PID_KORECONTROLLER 96 .idProduct = USB_PID_KORECONTROLLER
95 }, 97 },
96 { 98 {
99 .match_flags = USB_DEVICE_ID_MATCH_DEVICE,
100 .idVendor = USB_VID_NATIVEINSTRUMENTS,
101 .idProduct = USB_PID_KORECONTROLLER2
102 },
103 {
97 .match_flags = USB_DEVICE_ID_MATCH_DEVICE, 104 .match_flags = USB_DEVICE_ID_MATCH_DEVICE,
98 .idVendor = USB_VID_NATIVEINSTRUMENTS, 105 .idVendor = USB_VID_NATIVEINSTRUMENTS,
99 .idProduct = USB_PID_AK1 106 .idProduct = USB_PID_AK1
@@ -140,14 +147,21 @@ static void usb_ep1_command_reply_dispatch (struct urb* urb)
140 case EP1_CMD_MIDI_READ: 147 case EP1_CMD_MIDI_READ:
141 snd_usb_caiaq_midi_handle_input(dev, buf[1], buf + 3, buf[2]); 148 snd_usb_caiaq_midi_handle_input(dev, buf[1], buf + 3, buf[2]);
142 break; 149 break;
143 150 case EP1_CMD_READ_IO:
151 if (dev->chip.usb_id ==
152 USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_AUDIO8DJ)) {
153 if (urb->actual_length > sizeof(dev->control_state))
154 urb->actual_length = sizeof(dev->control_state);
155 memcpy(dev->control_state, buf + 1, urb->actual_length);
156 wake_up(&dev->ep1_wait_queue);
157 break;
158 }
144#ifdef CONFIG_SND_USB_CAIAQ_INPUT 159#ifdef CONFIG_SND_USB_CAIAQ_INPUT
145 case EP1_CMD_READ_ERP: 160 case EP1_CMD_READ_ERP:
146 case EP1_CMD_READ_ANALOG: 161 case EP1_CMD_READ_ANALOG:
147 case EP1_CMD_READ_IO:
148 snd_usb_caiaq_input_dispatch(dev, buf, urb->actual_length); 162 snd_usb_caiaq_input_dispatch(dev, buf, urb->actual_length);
149 break;
150#endif 163#endif
164 break;
151 } 165 }
152 166
153 dev->ep1_in_urb.actual_length = 0; 167 dev->ep1_in_urb.actual_length = 0;
@@ -156,10 +170,10 @@ static void usb_ep1_command_reply_dispatch (struct urb* urb)
156 log("unable to submit urb. OOM!?\n"); 170 log("unable to submit urb. OOM!?\n");
157} 171}
158 172
159static int send_command (struct snd_usb_caiaqdev *dev, 173int snd_usb_caiaq_send_command(struct snd_usb_caiaqdev *dev,
160 unsigned char command, 174 unsigned char command,
161 const unsigned char *buffer, 175 const unsigned char *buffer,
162 int len) 176 int len)
163{ 177{
164 int actual_len; 178 int actual_len;
165 struct usb_device *usb_dev = dev->chip.dev; 179 struct usb_device *usb_dev = dev->chip.dev;
@@ -207,7 +221,8 @@ int snd_usb_caiaq_set_audio_params (struct snd_usb_caiaqdev *dev,
207 rate, depth, bpp); 221 rate, depth, bpp);
208 222
209 dev->audio_parm_answer = -1; 223 dev->audio_parm_answer = -1;
210 ret = send_command(dev, EP1_CMD_AUDIO_PARAMS, tmp, sizeof(tmp)); 224 ret = snd_usb_caiaq_send_command(dev, EP1_CMD_AUDIO_PARAMS,
225 tmp, sizeof(tmp));
211 226
212 if (ret) 227 if (ret)
213 return ret; 228 return ret;
@@ -226,7 +241,8 @@ int snd_usb_caiaq_set_auto_msg (struct snd_usb_caiaqdev *dev,
226 int digital, int analog, int erp) 241 int digital, int analog, int erp)
227{ 242{
228 char tmp[3] = { digital, analog, erp }; 243 char tmp[3] = { digital, analog, erp };
229 return send_command(dev, EP1_CMD_AUTO_MSG, tmp, sizeof(tmp)); 244 return snd_usb_caiaq_send_command(dev, EP1_CMD_AUTO_MSG,
245 tmp, sizeof(tmp));
230} 246}
231 247
232static void setup_card(struct snd_usb_caiaqdev *dev) 248static void setup_card(struct snd_usb_caiaqdev *dev)
@@ -241,7 +257,7 @@ static void setup_card(struct snd_usb_caiaqdev *dev)
241 val[0] = 0x00; 257 val[0] = 0x00;
242 val[1] = 0x00; 258 val[1] = 0x00;
243 val[2] = 0x01; 259 val[2] = 0x01;
244 send_command(dev, EP1_CMD_WRITE_IO, val, 3); 260 snd_usb_caiaq_send_command(dev, EP1_CMD_WRITE_IO, val, 3);
245 break; 261 break;
246 case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_RIGKONTROL3): 262 case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_RIGKONTROL3):
247 /* RigKontrol2 - display two centered dashes ('--') */ 263 /* RigKontrol2 - display two centered dashes ('--') */
@@ -249,22 +265,52 @@ static void setup_card(struct snd_usb_caiaqdev *dev)
249 val[1] = 0x40; 265 val[1] = 0x40;
250 val[2] = 0x40; 266 val[2] = 0x40;
251 val[3] = 0x00; 267 val[3] = 0x00;
252 send_command(dev, EP1_CMD_WRITE_IO, val, 4); 268 snd_usb_caiaq_send_command(dev, EP1_CMD_WRITE_IO, val, 4);
253 break; 269 break;
254 case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_AK1): 270 case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_AK1):
255 /* Audio Kontrol 1 - make USB-LED stop blinking */ 271 /* Audio Kontrol 1 - make USB-LED stop blinking */
256 val[0] = 0x00; 272 val[0] = 0x00;
257 send_command(dev, EP1_CMD_WRITE_IO, val, 1); 273 snd_usb_caiaq_send_command(dev, EP1_CMD_WRITE_IO, val, 1);
274 break;
275 case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_AUDIO8DJ):
276 /* Audio 8 DJ - trigger read of current settings */
277 dev->control_state[0] = 0xff;
278 snd_usb_caiaq_set_auto_msg(dev, 1, 0, 0);
279 snd_usb_caiaq_send_command(dev, EP1_CMD_READ_IO, NULL, 0);
280
281 if (!wait_event_timeout(dev->ep1_wait_queue,
282 dev->control_state[0] != 0xff, HZ))
283 return;
284
285 /* fix up some defaults */
286 if ((dev->control_state[1] != 2) ||
287 (dev->control_state[2] != 3) ||
288 (dev->control_state[4] != 2)) {
289 dev->control_state[1] = 2;
290 dev->control_state[2] = 3;
291 dev->control_state[4] = 2;
292 snd_usb_caiaq_send_command(dev,
293 EP1_CMD_WRITE_IO, dev->control_state, 6);
294 }
295
258 break; 296 break;
259 } 297 }
260 298
261 ret = snd_usb_caiaq_audio_init(dev); 299 if (dev->spec.num_analog_audio_out +
262 if (ret < 0) 300 dev->spec.num_analog_audio_in +
263 log("Unable to set up audio system (ret=%d)\n", ret); 301 dev->spec.num_digital_audio_out +
302 dev->spec.num_digital_audio_in > 0) {
303 ret = snd_usb_caiaq_audio_init(dev);
304 if (ret < 0)
305 log("Unable to set up audio system (ret=%d)\n", ret);
306 }
264 307
265 ret = snd_usb_caiaq_midi_init(dev); 308 if (dev->spec.num_midi_in +
266 if (ret < 0) 309 dev->spec.num_midi_out > 0) {
267 log("Unable to set up MIDI system (ret=%d)\n", ret); 310 ret = snd_usb_caiaq_midi_init(dev);
311 if (ret < 0)
312 log("Unable to set up MIDI system (ret=%d)\n", ret);
313 }
268 314
269#ifdef CONFIG_SND_USB_CAIAQ_INPUT 315#ifdef CONFIG_SND_USB_CAIAQ_INPUT
270 ret = snd_usb_caiaq_input_init(dev); 316 ret = snd_usb_caiaq_input_init(dev);
@@ -278,6 +324,10 @@ static void setup_card(struct snd_usb_caiaqdev *dev)
278 log("snd_card_register() returned %d\n", ret); 324 log("snd_card_register() returned %d\n", ret);
279 snd_card_free(dev->chip.card); 325 snd_card_free(dev->chip.card);
280 } 326 }
327
328 ret = snd_usb_caiaq_control_init(dev);
329 if (ret < 0)
330 log("Unable to set up control system (ret=%d)\n", ret);
281} 331}
282 332
283static struct snd_card* create_card(struct usb_device* usb_dev) 333static struct snd_card* create_card(struct usb_device* usb_dev)
@@ -340,7 +390,7 @@ static int init_card(struct snd_usb_caiaqdev *dev)
340 if (usb_submit_urb(&dev->ep1_in_urb, GFP_KERNEL) != 0) 390 if (usb_submit_urb(&dev->ep1_in_urb, GFP_KERNEL) != 0)
341 return -EIO; 391 return -EIO;
342 392
343 err = send_command(dev, EP1_CMD_GET_DEVICE_INFO, NULL, 0); 393 err = snd_usb_caiaq_send_command(dev, EP1_CMD_GET_DEVICE_INFO, NULL, 0);
344 if (err) 394 if (err)
345 return err; 395 return err;
346 396
diff --git a/sound/usb/caiaq/caiaq-device.h b/sound/usb/caiaq/caiaq-device.h
index 79bc5be2df7a..96a491379c60 100644
--- a/sound/usb/caiaq/caiaq-device.h
+++ b/sound/usb/caiaq/caiaq-device.h
@@ -7,7 +7,8 @@
7 7
8#define USB_PID_RIGKONTROL2 0x1969 8#define USB_PID_RIGKONTROL2 0x1969
9#define USB_PID_RIGKONTROL3 0x1940 9#define USB_PID_RIGKONTROL3 0x1940
10#define USB_PID_KORECONTROLLER 0x4711 10#define USB_PID_KORECONTROLLER 0x4711
11#define USB_PID_KORECONTROLLER2 0x4712
11#define USB_PID_AK1 0x0815 12#define USB_PID_AK1 0x0815
12#define USB_PID_AUDIO8DJ 0x1978 13#define USB_PID_AUDIO8DJ 0x1978
13 14
@@ -35,6 +36,7 @@
35#define EP1_CMD_MIDI_WRITE 0x7 36#define EP1_CMD_MIDI_WRITE 0x7
36#define EP1_CMD_AUDIO_PARAMS 0x9 37#define EP1_CMD_AUDIO_PARAMS 0x9
37#define EP1_CMD_AUTO_MSG 0xb 38#define EP1_CMD_AUTO_MSG 0xb
39#define EP1_CMD_DIMM_LEDS 0xc
38 40
39struct caiaq_device_spec { 41struct caiaq_device_spec {
40 unsigned short fw_version; 42 unsigned short fw_version;
@@ -62,7 +64,7 @@ struct snd_usb_caiaqdev {
62 struct urb **data_urbs_in; 64 struct urb **data_urbs_in;
63 struct urb **data_urbs_out; 65 struct urb **data_urbs_out;
64 struct snd_usb_caiaq_cb_info *data_cb_info; 66 struct snd_usb_caiaq_cb_info *data_cb_info;
65 67
66 unsigned char ep1_in_buf[EP1_BUFSIZE]; 68 unsigned char ep1_in_buf[EP1_BUFSIZE];
67 unsigned char ep1_out_buf[EP1_BUFSIZE]; 69 unsigned char ep1_out_buf[EP1_BUFSIZE];
68 unsigned char midi_out_buf[EP1_BUFSIZE]; 70 unsigned char midi_out_buf[EP1_BUFSIZE];
@@ -72,7 +74,7 @@ struct snd_usb_caiaqdev {
72 wait_queue_head_t ep1_wait_queue; 74 wait_queue_head_t ep1_wait_queue;
73 wait_queue_head_t prepare_wait_queue; 75 wait_queue_head_t prepare_wait_queue;
74 int spec_received, audio_parm_answer; 76 int spec_received, audio_parm_answer;
75 77
76 char vendor_name[CAIAQ_USB_STR_LEN]; 78 char vendor_name[CAIAQ_USB_STR_LEN];
77 char product_name[CAIAQ_USB_STR_LEN]; 79 char product_name[CAIAQ_USB_STR_LEN];
78 char serial[CAIAQ_USB_STR_LEN]; 80 char serial[CAIAQ_USB_STR_LEN];
@@ -90,11 +92,16 @@ struct snd_usb_caiaqdev {
90 struct snd_pcm_substream *sub_playback[MAX_STREAMS]; 92 struct snd_pcm_substream *sub_playback[MAX_STREAMS];
91 struct snd_pcm_substream *sub_capture[MAX_STREAMS]; 93 struct snd_pcm_substream *sub_capture[MAX_STREAMS];
92 94
95 /* Controls */
96 unsigned char control_state[64];
97
93 /* Linux input */ 98 /* Linux input */
94#ifdef CONFIG_SND_USB_CAIAQ_INPUT 99#ifdef CONFIG_SND_USB_CAIAQ_INPUT
95 struct input_dev *input_dev; 100 struct input_dev *input_dev;
101 char phys[64]; /* physical device path */
102 unsigned short keycode[64];
96#endif 103#endif
97 104
98 /* ALSA */ 105 /* ALSA */
99 struct snd_pcm *pcm; 106 struct snd_pcm *pcm;
100 struct snd_pcm_hardware pcm_info; 107 struct snd_pcm_hardware pcm_info;
@@ -112,6 +119,9 @@ struct snd_usb_caiaq_cb_info {
112 119
113int snd_usb_caiaq_set_audio_params (struct snd_usb_caiaqdev *dev, int rate, int depth, int bbp); 120int snd_usb_caiaq_set_audio_params (struct snd_usb_caiaqdev *dev, int rate, int depth, int bbp);
114int snd_usb_caiaq_set_auto_msg (struct snd_usb_caiaqdev *dev, int digital, int analog, int erp); 121int snd_usb_caiaq_set_auto_msg (struct snd_usb_caiaqdev *dev, int digital, int analog, int erp);
115 122int snd_usb_caiaq_send_command(struct snd_usb_caiaqdev *dev,
123 unsigned char command,
124 const unsigned char *buffer,
125 int len);
116 126
117#endif /* CAIAQ_DEVICE_H */ 127#endif /* CAIAQ_DEVICE_H */
diff --git a/sound/usb/caiaq/caiaq-input.c b/sound/usb/caiaq/caiaq-input.c
index cd536ca20e56..f743847a5e5a 100644
--- a/sound/usb/caiaq/caiaq-input.c
+++ b/sound/usb/caiaq/caiaq-input.c
@@ -21,28 +21,61 @@
21#include <linux/moduleparam.h> 21#include <linux/moduleparam.h>
22#include <linux/input.h> 22#include <linux/input.h>
23#include <linux/usb.h> 23#include <linux/usb.h>
24#include <linux/usb/input.h>
24#include <linux/spinlock.h> 25#include <linux/spinlock.h>
25#include <sound/driver.h>
26#include <sound/core.h> 26#include <sound/core.h>
27#include <sound/rawmidi.h> 27#include <sound/rawmidi.h>
28#include <sound/pcm.h> 28#include <sound/pcm.h>
29#include "caiaq-device.h" 29#include "caiaq-device.h"
30#include "caiaq-input.h" 30#include "caiaq-input.h"
31 31
32#ifdef CONFIG_SND_USB_CAIAQ_INPUT 32static unsigned short keycode_ak1[] = { KEY_C, KEY_B, KEY_A };
33 33static unsigned short keycode_rk2[] = { KEY_1, KEY_2, KEY_3, KEY_4,
34static unsigned char keycode_ak1[] = { KEY_C, KEY_B, KEY_A }; 34 KEY_5, KEY_6, KEY_7 };
35static unsigned char keycode_rk2[] = { KEY_1, KEY_2, KEY_3, KEY_4, 35static unsigned short keycode_rk3[] = { KEY_1, KEY_2, KEY_3, KEY_4,
36 KEY_5, KEY_6, KEY_7 }; 36 KEY_5, KEY_6, KEY_7, KEY_5, KEY_6 };
37static unsigned char keycode_rk3[] = { KEY_1, KEY_2, KEY_3, KEY_4, 37
38 KEY_5, KEY_6, KEY_7, KEY_5, KEY_6 }; 38static unsigned short keycode_kore[] = {
39 39 KEY_FN_F1, /* "menu" */
40#define DEG90 (range/2) 40 KEY_FN_F7, /* "lcd backlight */
41#define DEG180 (range) 41 KEY_FN_F2, /* "control" */
42#define DEG270 (DEG90 + DEG180) 42 KEY_FN_F3, /* "enter" */
43#define DEG360 (DEG180 * 2) 43 KEY_FN_F4, /* "view" */
44#define HIGH_PEAK (268) 44 KEY_FN_F5, /* "esc" */
45#define LOW_PEAK (-7) 45 KEY_FN_F6, /* "sound" */
46 KEY_FN_F8, /* array spacer, never triggered. */
47 KEY_RIGHT,
48 KEY_DOWN,
49 KEY_UP,
50 KEY_LEFT,
51 KEY_SOUND, /* "listen" */
52 KEY_RECORD,
53 KEY_PLAYPAUSE,
54 KEY_STOP,
55 BTN_4, /* 8 softkeys */
56 BTN_3,
57 BTN_2,
58 BTN_1,
59 BTN_8,
60 BTN_7,
61 BTN_6,
62 BTN_5,
63 KEY_BRL_DOT4, /* touch sensitive knobs */
64 KEY_BRL_DOT3,
65 KEY_BRL_DOT2,
66 KEY_BRL_DOT1,
67 KEY_BRL_DOT8,
68 KEY_BRL_DOT7,
69 KEY_BRL_DOT6,
70 KEY_BRL_DOT5
71};
72
73#define DEG90 (range / 2)
74#define DEG180 (range)
75#define DEG270 (DEG90 + DEG180)
76#define DEG360 (DEG180 * 2)
77#define HIGH_PEAK (268)
78#define LOW_PEAK (-7)
46 79
47/* some of these devices have endless rotation potentiometers 80/* some of these devices have endless rotation potentiometers
48 * built in which use two tapers, 90 degrees phase shifted. 81 * built in which use two tapers, 90 degrees phase shifted.
@@ -56,8 +89,8 @@ static unsigned int decode_erp(unsigned char a, unsigned char b)
56 int range = HIGH_PEAK - LOW_PEAK; 89 int range = HIGH_PEAK - LOW_PEAK;
57 int mid_value = (HIGH_PEAK + LOW_PEAK) / 2; 90 int mid_value = (HIGH_PEAK + LOW_PEAK) / 2;
58 91
59 weight_b = abs(mid_value-a) - (range/2 - 100)/2; 92 weight_b = abs(mid_value - a) - (range / 2 - 100) / 2;
60 93
61 if (weight_b < 0) 94 if (weight_b < 0)
62 weight_b = 0; 95 weight_b = 0;
63 96
@@ -93,7 +126,7 @@ static unsigned int decode_erp(unsigned char a, unsigned char b)
93 126
94 if (ret < 0) 127 if (ret < 0)
95 ret += 1000; 128 ret += 1000;
96 129
97 if (ret >= 1000) 130 if (ret >= 1000)
98 ret -= 1000; 131 ret -= 1000;
99 132
@@ -108,76 +141,113 @@ static unsigned int decode_erp(unsigned char a, unsigned char b)
108#undef LOW_PEAK 141#undef LOW_PEAK
109 142
110 143
111static void snd_caiaq_input_read_analog(struct snd_usb_caiaqdev *dev, 144static void snd_caiaq_input_read_analog(struct snd_usb_caiaqdev *dev,
112 const unsigned char *buf, 145 const unsigned char *buf,
113 unsigned int len) 146 unsigned int len)
114{ 147{
115 switch(dev->input_dev->id.product) { 148 struct input_dev *input_dev = dev->input_dev;
116 case USB_PID_RIGKONTROL2: 149
117 input_report_abs(dev->input_dev, ABS_X, (buf[4] << 8) |buf[5]); 150 switch (dev->chip.usb_id) {
118 input_report_abs(dev->input_dev, ABS_Y, (buf[0] << 8) |buf[1]); 151 case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_RIGKONTROL2):
119 input_report_abs(dev->input_dev, ABS_Z, (buf[2] << 8) |buf[3]); 152 input_report_abs(input_dev, ABS_X, (buf[4] << 8) | buf[5]);
120 input_sync(dev->input_dev); 153 input_report_abs(input_dev, ABS_Y, (buf[0] << 8) | buf[1]);
154 input_report_abs(input_dev, ABS_Z, (buf[2] << 8) | buf[3]);
155 input_sync(input_dev);
121 break; 156 break;
122 case USB_PID_RIGKONTROL3: 157 case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_RIGKONTROL3):
123 input_report_abs(dev->input_dev, ABS_X, (buf[0] << 8) |buf[1]); 158 input_report_abs(input_dev, ABS_X, (buf[0] << 8) | buf[1]);
124 input_report_abs(dev->input_dev, ABS_Y, (buf[2] << 8) |buf[3]); 159 input_report_abs(input_dev, ABS_Y, (buf[2] << 8) | buf[3]);
125 input_report_abs(dev->input_dev, ABS_Z, (buf[4] << 8) |buf[5]); 160 input_report_abs(input_dev, ABS_Z, (buf[4] << 8) | buf[5]);
126 input_sync(dev->input_dev); 161 input_sync(input_dev);
162 break;
163 case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_KORECONTROLLER):
164 case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_KORECONTROLLER2):
165 input_report_abs(input_dev, ABS_X, (buf[0] << 8) | buf[1]);
166 input_report_abs(input_dev, ABS_Y, (buf[2] << 8) | buf[3]);
167 input_report_abs(input_dev, ABS_Z, (buf[4] << 8) | buf[5]);
168 input_sync(input_dev);
127 break; 169 break;
128 } 170 }
129} 171}
130 172
131static void snd_caiaq_input_read_erp(struct snd_usb_caiaqdev *dev, 173static void snd_caiaq_input_read_erp(struct snd_usb_caiaqdev *dev,
132 const char *buf, unsigned int len) 174 const char *buf, unsigned int len)
133{ 175{
176 struct input_dev *input_dev = dev->input_dev;
134 int i; 177 int i;
135 178
136 switch(dev->input_dev->id.product) { 179 switch (dev->chip.usb_id) {
137 case USB_PID_AK1: 180 case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_AK1):
138 i = decode_erp(buf[0], buf[1]); 181 i = decode_erp(buf[0], buf[1]);
139 input_report_abs(dev->input_dev, ABS_X, i); 182 input_report_abs(input_dev, ABS_X, i);
140 input_sync(dev->input_dev); 183 input_sync(input_dev);
184 break;
185 case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_KORECONTROLLER):
186 case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_KORECONTROLLER2):
187 i = decode_erp(buf[7], buf[5]);
188 input_report_abs(input_dev, ABS_HAT0X, i);
189 i = decode_erp(buf[12], buf[14]);
190 input_report_abs(input_dev, ABS_HAT0Y, i);
191 i = decode_erp(buf[15], buf[13]);
192 input_report_abs(input_dev, ABS_HAT1X, i);
193 i = decode_erp(buf[0], buf[2]);
194 input_report_abs(input_dev, ABS_HAT1Y, i);
195 i = decode_erp(buf[3], buf[1]);
196 input_report_abs(input_dev, ABS_HAT2X, i);
197 i = decode_erp(buf[8], buf[10]);
198 input_report_abs(input_dev, ABS_HAT2Y, i);
199 i = decode_erp(buf[11], buf[9]);
200 input_report_abs(input_dev, ABS_HAT3X, i);
201 i = decode_erp(buf[4], buf[6]);
202 input_report_abs(input_dev, ABS_HAT3Y, i);
203 input_sync(input_dev);
141 break; 204 break;
142 } 205 }
143} 206}
144 207
145static void snd_caiaq_input_read_io(struct snd_usb_caiaqdev *dev, 208static void snd_caiaq_input_read_io(struct snd_usb_caiaqdev *dev,
146 char *buf, unsigned int len) 209 char *buf, unsigned int len)
147{ 210{
211 struct input_dev *input_dev = dev->input_dev;
212 unsigned short *keycode = input_dev->keycode;
148 int i; 213 int i;
149 unsigned char *keycode = dev->input_dev->keycode;
150 214
151 if (!keycode) 215 if (!keycode)
152 return; 216 return;
153 217
154 if (dev->input_dev->id.product == USB_PID_RIGKONTROL2) 218 if (input_dev->id.product == USB_PID_RIGKONTROL2)
155 for (i=0; i<len; i++) 219 for (i = 0; i < len; i++)
156 buf[i] = ~buf[i]; 220 buf[i] = ~buf[i];
157 221
158 for (i=0; (i<dev->input_dev->keycodemax) && (i < len); i++) 222 for (i = 0; i < input_dev->keycodemax && i < len * 8; i++)
159 input_report_key(dev->input_dev, keycode[i], 223 input_report_key(input_dev, keycode[i],
160 buf[i/8] & (1 << (i%8))); 224 buf[i / 8] & (1 << (i % 8)));
161 225
162 input_sync(dev->input_dev); 226 if (dev->chip.usb_id ==
227 USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_KORECONTROLLER) ||
228 dev->chip.usb_id ==
229 USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_KORECONTROLLER2))
230 input_report_abs(dev->input_dev, ABS_MISC, 255 - buf[4]);
231
232 input_sync(input_dev);
163} 233}
164 234
165void snd_usb_caiaq_input_dispatch(struct snd_usb_caiaqdev *dev, 235void snd_usb_caiaq_input_dispatch(struct snd_usb_caiaqdev *dev,
166 char *buf, 236 char *buf,
167 unsigned int len) 237 unsigned int len)
168{ 238{
169 if (!dev->input_dev || (len < 1)) 239 if (!dev->input_dev || len < 1)
170 return; 240 return;
171 241
172 switch (buf[0]) { 242 switch (buf[0]) {
173 case EP1_CMD_READ_ANALOG: 243 case EP1_CMD_READ_ANALOG:
174 snd_caiaq_input_read_analog(dev, buf+1, len-1); 244 snd_caiaq_input_read_analog(dev, buf + 1, len - 1);
175 break; 245 break;
176 case EP1_CMD_READ_ERP: 246 case EP1_CMD_READ_ERP:
177 snd_caiaq_input_read_erp(dev, buf+1, len-1); 247 snd_caiaq_input_read_erp(dev, buf + 1, len - 1);
178 break; 248 break;
179 case EP1_CMD_READ_IO: 249 case EP1_CMD_READ_IO:
180 snd_caiaq_input_read_io(dev, buf+1, len-1); 250 snd_caiaq_input_read_io(dev, buf + 1, len - 1);
181 break; 251 break;
182 } 252 }
183} 253}
@@ -192,37 +262,34 @@ int snd_usb_caiaq_input_init(struct snd_usb_caiaqdev *dev)
192 if (!input) 262 if (!input)
193 return -ENOMEM; 263 return -ENOMEM;
194 264
265 usb_make_path(usb_dev, dev->phys, sizeof(dev->phys));
266 strlcat(dev->phys, "/input0", sizeof(dev->phys));
267
195 input->name = dev->product_name; 268 input->name = dev->product_name;
196 input->id.bustype = BUS_USB; 269 input->phys = dev->phys;
197 input->id.vendor = usb_dev->descriptor.idVendor; 270 usb_to_input_id(usb_dev, &input->id);
198 input->id.product = usb_dev->descriptor.idProduct; 271 input->dev.parent = &usb_dev->dev;
199 input->id.version = usb_dev->descriptor.bcdDevice;
200 272
201 switch (dev->chip.usb_id) { 273 switch (dev->chip.usb_id) {
202 case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_RIGKONTROL2): 274 case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_RIGKONTROL2):
203 input->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS); 275 input->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS);
204 input->absbit[0] = BIT_MASK(ABS_X) | BIT_MASK(ABS_Y) | 276 input->absbit[0] = BIT_MASK(ABS_X) | BIT_MASK(ABS_Y) |
205 BIT_MASK(ABS_Z); 277 BIT_MASK(ABS_Z);
206 input->keycode = keycode_rk2; 278 BUILD_BUG_ON(sizeof(dev->keycode) < sizeof(keycode_rk2));
207 input->keycodesize = sizeof(char); 279 memcpy(dev->keycode, keycode_rk2, sizeof(keycode_rk2));
208 input->keycodemax = ARRAY_SIZE(keycode_rk2); 280 input->keycodemax = ARRAY_SIZE(keycode_rk2);
209 for (i=0; i<ARRAY_SIZE(keycode_rk2); i++)
210 set_bit(keycode_rk2[i], input->keybit);
211
212 input_set_abs_params(input, ABS_X, 0, 4096, 0, 10); 281 input_set_abs_params(input, ABS_X, 0, 4096, 0, 10);
213 input_set_abs_params(input, ABS_Y, 0, 4096, 0, 10); 282 input_set_abs_params(input, ABS_Y, 0, 4096, 0, 10);
214 input_set_abs_params(input, ABS_Z, 0, 4096, 0, 10); 283 input_set_abs_params(input, ABS_Z, 0, 4096, 0, 10);
215 snd_usb_caiaq_set_auto_msg(dev, 1, 10, 0); 284 snd_usb_caiaq_set_auto_msg(dev, 1, 10, 0);
216 break; 285 break;
217 case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_RIGKONTROL3): 286 case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_RIGKONTROL3):
218 input->evbit[0] = BIT(EV_KEY) | BIT(EV_ABS); 287 input->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS);
219 input->absbit[0] = BIT(ABS_X) | BIT(ABS_Y) | BIT(ABS_Z); 288 input->absbit[0] = BIT_MASK(ABS_X) | BIT_MASK(ABS_Y) |
220 input->keycode = keycode_rk3; 289 BIT_MASK(ABS_Z);
221 input->keycodesize = sizeof(char); 290 BUILD_BUG_ON(sizeof(dev->keycode) < sizeof(keycode_rk3));
291 memcpy(dev->keycode, keycode_rk3, sizeof(keycode_rk3));
222 input->keycodemax = ARRAY_SIZE(keycode_rk3); 292 input->keycodemax = ARRAY_SIZE(keycode_rk3);
223 for (i=0; i<ARRAY_SIZE(keycode_rk3); i++)
224 set_bit(keycode_rk3[i], input->keybit);
225
226 input_set_abs_params(input, ABS_X, 0, 1024, 0, 10); 293 input_set_abs_params(input, ABS_X, 0, 1024, 0, 10);
227 input_set_abs_params(input, ABS_Y, 0, 1024, 0, 10); 294 input_set_abs_params(input, ABS_Y, 0, 1024, 0, 10);
228 input_set_abs_params(input, ABS_Z, 0, 1024, 0, 10); 295 input_set_abs_params(input, ABS_Z, 0, 1024, 0, 10);
@@ -231,21 +298,50 @@ int snd_usb_caiaq_input_init(struct snd_usb_caiaqdev *dev)
231 case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_AK1): 298 case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_AK1):
232 input->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS); 299 input->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS);
233 input->absbit[0] = BIT_MASK(ABS_X); 300 input->absbit[0] = BIT_MASK(ABS_X);
234 input->keycode = keycode_ak1; 301 BUILD_BUG_ON(sizeof(dev->keycode) < sizeof(keycode_ak1));
235 input->keycodesize = sizeof(char); 302 memcpy(dev->keycode, keycode_ak1, sizeof(keycode_ak1));
236 input->keycodemax = ARRAY_SIZE(keycode_ak1); 303 input->keycodemax = ARRAY_SIZE(keycode_ak1);
237 for (i=0; i<ARRAY_SIZE(keycode_ak1); i++)
238 set_bit(keycode_ak1[i], input->keybit);
239
240 input_set_abs_params(input, ABS_X, 0, 999, 0, 10); 304 input_set_abs_params(input, ABS_X, 0, 999, 0, 10);
241 snd_usb_caiaq_set_auto_msg(dev, 1, 0, 5); 305 snd_usb_caiaq_set_auto_msg(dev, 1, 0, 5);
242 break; 306 break;
307 case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_KORECONTROLLER):
308 case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_KORECONTROLLER2):
309 input->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS);
310 input->absbit[0] = BIT_MASK(ABS_HAT0X) | BIT_MASK(ABS_HAT0Y) |
311 BIT_MASK(ABS_HAT1X) | BIT_MASK(ABS_HAT1Y) |
312 BIT_MASK(ABS_HAT2X) | BIT_MASK(ABS_HAT2Y) |
313 BIT_MASK(ABS_HAT3X) | BIT_MASK(ABS_HAT3Y) |
314 BIT_MASK(ABS_X) | BIT_MASK(ABS_Y) |
315 BIT_MASK(ABS_Z);
316 input->absbit[BIT_WORD(ABS_MISC)] |= BIT_MASK(ABS_MISC);
317 BUILD_BUG_ON(sizeof(dev->keycode) < sizeof(keycode_kore));
318 memcpy(dev->keycode, keycode_kore, sizeof(keycode_kore));
319 input->keycodemax = ARRAY_SIZE(keycode_kore);
320 input_set_abs_params(input, ABS_HAT0X, 0, 999, 0, 10);
321 input_set_abs_params(input, ABS_HAT0Y, 0, 999, 0, 10);
322 input_set_abs_params(input, ABS_HAT1X, 0, 999, 0, 10);
323 input_set_abs_params(input, ABS_HAT1Y, 0, 999, 0, 10);
324 input_set_abs_params(input, ABS_HAT2X, 0, 999, 0, 10);
325 input_set_abs_params(input, ABS_HAT2Y, 0, 999, 0, 10);
326 input_set_abs_params(input, ABS_HAT3X, 0, 999, 0, 10);
327 input_set_abs_params(input, ABS_HAT3Y, 0, 999, 0, 10);
328 input_set_abs_params(input, ABS_X, 0, 4096, 0, 10);
329 input_set_abs_params(input, ABS_Y, 0, 4096, 0, 10);
330 input_set_abs_params(input, ABS_Z, 0, 4096, 0, 10);
331 input_set_abs_params(input, ABS_MISC, 0, 255, 0, 1);
332 snd_usb_caiaq_set_auto_msg(dev, 1, 10, 5);
333 break;
243 default: 334 default:
244 /* no input methods supported on this device */ 335 /* no input methods supported on this device */
245 input_free_device(input); 336 input_free_device(input);
246 return 0; 337 return 0;
247 } 338 }
248 339
340 input->keycode = dev->keycode;
341 input->keycodesize = sizeof(unsigned short);
342 for (i = 0; i < input->keycodemax; i++)
343 __set_bit(dev->keycode[i], input->keybit);
344
249 ret = input_register_device(input); 345 ret = input_register_device(input);
250 if (ret < 0) { 346 if (ret < 0) {
251 input_free_device(input); 347 input_free_device(input);
@@ -265,5 +361,3 @@ void snd_usb_caiaq_input_free(struct snd_usb_caiaqdev *dev)
265 dev->input_dev = NULL; 361 dev->input_dev = NULL;
266} 362}
267 363
268#endif /* CONFIG_SND_USB_CAIAQ_INPUT */
269
diff --git a/sound/usb/caiaq/caiaq-midi.c b/sound/usb/caiaq/caiaq-midi.c
index 793ca20ce349..30b57f97c6e4 100644
--- a/sound/usb/caiaq/caiaq-midi.c
+++ b/sound/usb/caiaq/caiaq-midi.c
@@ -23,7 +23,6 @@
23#include <linux/usb.h> 23#include <linux/usb.h>
24#include <linux/input.h> 24#include <linux/input.h>
25#include <linux/spinlock.h> 25#include <linux/spinlock.h>
26#include <sound/driver.h>
27#include <sound/core.h> 26#include <sound/core.h>
28#include <sound/rawmidi.h> 27#include <sound/rawmidi.h>
29#include <sound/pcm.h> 28#include <sound/pcm.h>
@@ -124,7 +123,7 @@ void snd_usb_caiaq_midi_handle_input(struct snd_usb_caiaqdev *dev,
124 snd_rawmidi_receive(dev->midi_receive_substream, buf, len); 123 snd_rawmidi_receive(dev->midi_receive_substream, buf, len);
125} 124}
126 125
127int __devinit snd_usb_caiaq_midi_init(struct snd_usb_caiaqdev *device) 126int snd_usb_caiaq_midi_init(struct snd_usb_caiaqdev *device)
128{ 127{
129 int ret; 128 int ret;
130 struct snd_rawmidi *rmidi; 129 struct snd_rawmidi *rmidi;