diff options
author | Daniel Mack <daniel@caiaq.de> | 2007-11-22 05:40:04 -0500 |
---|---|---|
committer | Jaroslav Kysela <perex@perex.cz> | 2008-01-31 11:29:28 -0500 |
commit | 8e3cd08ed8e590952aa9a656758cb24d4ba898f8 (patch) | |
tree | 162fa11dcaff39a1f5e2fff6f7f03670321a558d /sound/usb/caiaq/caiaq-input.c | |
parent | e5f73e2ae813aa216b480728548e5ffbebcc170a (diff) |
[ALSA] caiaq - add control API and more input features
- added support for all input controllers on Native Instrument's 'Kore
controller'.
- added ALSA controls to switch LEDs on 'RigKontrol 2', 'RigKontrol3',
'Audio Kontrol 1' and 'Kore controller'.
- added ALSA controls to switch input mode, software lock and ground
lift features on 'Audio 8 DJ'.
Signed-off-by: Daniel Mack <daniel@caiaq.de>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
Diffstat (limited to 'sound/usb/caiaq/caiaq-input.c')
-rw-r--r-- | sound/usb/caiaq/caiaq-input.c | 108 |
1 files changed, 99 insertions, 9 deletions
diff --git a/sound/usb/caiaq/caiaq-input.c b/sound/usb/caiaq/caiaq-input.c index 03bf4c63b5ef..00846b1f92b2 100644 --- a/sound/usb/caiaq/caiaq-input.c +++ b/sound/usb/caiaq/caiaq-input.c | |||
@@ -38,6 +38,41 @@ static unsigned short keycode_rk2[] = { KEY_1, KEY_2, KEY_3, KEY_4, | |||
38 | static unsigned short keycode_rk3[] = { KEY_1, KEY_2, KEY_3, KEY_4, | 38 | static unsigned short keycode_rk3[] = { KEY_1, KEY_2, KEY_3, KEY_4, |
39 | KEY_5, KEY_6, KEY_7, KEY_5, KEY_6 }; | 39 | KEY_5, KEY_6, KEY_7, KEY_5, KEY_6 }; |
40 | 40 | ||
41 | static unsigned short keycode_kore[] = { | ||
42 | KEY_FN_F1, /* "menu" */ | ||
43 | KEY_FN_F7, /* "lcd backlight */ | ||
44 | KEY_FN_F2, /* "control" */ | ||
45 | KEY_FN_F3, /* "enter" */ | ||
46 | KEY_FN_F4, /* "view" */ | ||
47 | KEY_FN_F5, /* "esc" */ | ||
48 | KEY_FN_F6, /* "sound" */ | ||
49 | KEY_FN_F8, /* array spacer, never triggered. */ | ||
50 | KEY_RIGHT, | ||
51 | KEY_DOWN, | ||
52 | KEY_UP, | ||
53 | KEY_LEFT, | ||
54 | KEY_SOUND, /* "listen" */ | ||
55 | KEY_RECORD, | ||
56 | KEY_PLAYPAUSE, | ||
57 | KEY_STOP, | ||
58 | BTN_4, /* 8 softkeys */ | ||
59 | BTN_3, | ||
60 | BTN_2, | ||
61 | BTN_1, | ||
62 | BTN_8, | ||
63 | BTN_7, | ||
64 | BTN_6, | ||
65 | BTN_5, | ||
66 | KEY_BRL_DOT4, /* touch sensitive knobs */ | ||
67 | KEY_BRL_DOT3, | ||
68 | KEY_BRL_DOT2, | ||
69 | KEY_BRL_DOT1, | ||
70 | KEY_BRL_DOT8, | ||
71 | KEY_BRL_DOT7, | ||
72 | KEY_BRL_DOT6, | ||
73 | KEY_BRL_DOT5 | ||
74 | }; | ||
75 | |||
41 | #define DEG90 (range / 2) | 76 | #define DEG90 (range / 2) |
42 | #define DEG180 (range) | 77 | #define DEG180 (range) |
43 | #define DEG270 (DEG90 + DEG180) | 78 | #define DEG270 (DEG90 + DEG180) |
@@ -115,14 +150,20 @@ static void snd_caiaq_input_read_analog(struct snd_usb_caiaqdev *dev, | |||
115 | { | 150 | { |
116 | struct input_dev *input_dev = dev->input_dev; | 151 | struct input_dev *input_dev = dev->input_dev; |
117 | 152 | ||
118 | switch (input_dev->id.product) { | 153 | switch (dev->chip.usb_id) { |
119 | case USB_PID_RIGKONTROL2: | 154 | case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_RIGKONTROL2): |
120 | input_report_abs(input_dev, ABS_X, (buf[4] << 8) | buf[5]); | 155 | input_report_abs(input_dev, ABS_X, (buf[4] << 8) | buf[5]); |
121 | input_report_abs(input_dev, ABS_Y, (buf[0] << 8) | buf[1]); | 156 | input_report_abs(input_dev, ABS_Y, (buf[0] << 8) | buf[1]); |
122 | input_report_abs(input_dev, ABS_Z, (buf[2] << 8) | buf[3]); | 157 | input_report_abs(input_dev, ABS_Z, (buf[2] << 8) | buf[3]); |
123 | input_sync(input_dev); | 158 | input_sync(input_dev); |
124 | break; | 159 | break; |
125 | case USB_PID_RIGKONTROL3: | 160 | case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_RIGKONTROL3): |
161 | input_report_abs(input_dev, ABS_X, (buf[0] << 8) | buf[1]); | ||
162 | input_report_abs(input_dev, ABS_Y, (buf[2] << 8) | buf[3]); | ||
163 | input_report_abs(input_dev, ABS_Z, (buf[4] << 8) | buf[5]); | ||
164 | input_sync(input_dev); | ||
165 | break; | ||
166 | case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_KORECONTROLLER): | ||
126 | input_report_abs(input_dev, ABS_X, (buf[0] << 8) | buf[1]); | 167 | input_report_abs(input_dev, ABS_X, (buf[0] << 8) | buf[1]); |
127 | input_report_abs(input_dev, ABS_Y, (buf[2] << 8) | buf[3]); | 168 | input_report_abs(input_dev, ABS_Y, (buf[2] << 8) | buf[3]); |
128 | input_report_abs(input_dev, ABS_Z, (buf[4] << 8) | buf[5]); | 169 | input_report_abs(input_dev, ABS_Z, (buf[4] << 8) | buf[5]); |
@@ -137,12 +178,31 @@ static void snd_caiaq_input_read_erp(struct snd_usb_caiaqdev *dev, | |||
137 | struct input_dev *input_dev = dev->input_dev; | 178 | struct input_dev *input_dev = dev->input_dev; |
138 | int i; | 179 | int i; |
139 | 180 | ||
140 | switch (input_dev->id.product) { | 181 | switch (dev->chip.usb_id) { |
141 | case USB_PID_AK1: | 182 | case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_AK1): |
142 | i = decode_erp(buf[0], buf[1]); | 183 | i = decode_erp(buf[0], buf[1]); |
143 | input_report_abs(input_dev, ABS_X, i); | 184 | input_report_abs(input_dev, ABS_X, i); |
144 | input_sync(input_dev); | 185 | input_sync(input_dev); |
145 | break; | 186 | break; |
187 | case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_KORECONTROLLER): | ||
188 | i = decode_erp(buf[7], buf[5]); | ||
189 | input_report_abs(input_dev, ABS_HAT0X, i); | ||
190 | i = decode_erp(buf[12], buf[14]); | ||
191 | input_report_abs(input_dev, ABS_HAT0Y, i); | ||
192 | i = decode_erp(buf[15], buf[13]); | ||
193 | input_report_abs(input_dev, ABS_HAT1X, i); | ||
194 | i = decode_erp(buf[0], buf[2]); | ||
195 | input_report_abs(input_dev, ABS_HAT1Y, i); | ||
196 | i = decode_erp(buf[3], buf[1]); | ||
197 | input_report_abs(input_dev, ABS_HAT2X, i); | ||
198 | i = decode_erp(buf[8], buf[10]); | ||
199 | input_report_abs(input_dev, ABS_HAT2Y, i); | ||
200 | i = decode_erp(buf[11], buf[9]); | ||
201 | input_report_abs(input_dev, ABS_HAT3X, i); | ||
202 | i = decode_erp(buf[4], buf[6]); | ||
203 | input_report_abs(input_dev, ABS_HAT3Y, i); | ||
204 | input_sync(input_dev); | ||
205 | break; | ||
146 | } | 206 | } |
147 | } | 207 | } |
148 | 208 | ||
@@ -160,10 +220,14 @@ static void snd_caiaq_input_read_io(struct snd_usb_caiaqdev *dev, | |||
160 | for (i = 0; i < len; i++) | 220 | for (i = 0; i < len; i++) |
161 | buf[i] = ~buf[i]; | 221 | buf[i] = ~buf[i]; |
162 | 222 | ||
163 | for (i = 0; i < input_dev->keycodemax && i < len; i++) | 223 | for (i = 0; i < input_dev->keycodemax && i < len * 8; i++) |
164 | input_report_key(input_dev, keycode[i], | 224 | input_report_key(input_dev, keycode[i], |
165 | buf[i / 8] & (1 << (i % 8))); | 225 | buf[i / 8] & (1 << (i % 8))); |
166 | 226 | ||
227 | if (dev->chip.usb_id == | ||
228 | USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_KORECONTROLLER)) | ||
229 | input_report_abs(dev->input_dev, ABS_MISC, 255 - buf[4]); | ||
230 | |||
167 | input_sync(input_dev); | 231 | input_sync(input_dev); |
168 | } | 232 | } |
169 | 233 | ||
@@ -218,10 +282,10 @@ int snd_usb_caiaq_input_init(struct snd_usb_caiaqdev *dev) | |||
218 | input_set_abs_params(input, ABS_Z, 0, 4096, 0, 10); | 282 | input_set_abs_params(input, ABS_Z, 0, 4096, 0, 10); |
219 | snd_usb_caiaq_set_auto_msg(dev, 1, 10, 0); | 283 | snd_usb_caiaq_set_auto_msg(dev, 1, 10, 0); |
220 | break; | 284 | break; |
221 | |||
222 | case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_RIGKONTROL3): | 285 | case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_RIGKONTROL3): |
223 | input->evbit[0] = BIT(EV_KEY) | BIT(EV_ABS); | 286 | input->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS); |
224 | input->absbit[0] = BIT(ABS_X) | BIT(ABS_Y) | BIT(ABS_Z); | 287 | input->absbit[0] = BIT_MASK(ABS_X) | BIT_MASK(ABS_Y) | |
288 | BIT_MASK(ABS_Z); | ||
225 | BUILD_BUG_ON(sizeof(dev->keycode) < sizeof(keycode_rk3)); | 289 | BUILD_BUG_ON(sizeof(dev->keycode) < sizeof(keycode_rk3)); |
226 | memcpy(dev->keycode, keycode_rk3, sizeof(keycode_rk3)); | 290 | memcpy(dev->keycode, keycode_rk3, sizeof(keycode_rk3)); |
227 | input->keycodemax = ARRAY_SIZE(keycode_rk3); | 291 | input->keycodemax = ARRAY_SIZE(keycode_rk3); |
@@ -239,6 +303,32 @@ int snd_usb_caiaq_input_init(struct snd_usb_caiaqdev *dev) | |||
239 | input_set_abs_params(input, ABS_X, 0, 999, 0, 10); | 303 | input_set_abs_params(input, ABS_X, 0, 999, 0, 10); |
240 | snd_usb_caiaq_set_auto_msg(dev, 1, 0, 5); | 304 | snd_usb_caiaq_set_auto_msg(dev, 1, 0, 5); |
241 | break; | 305 | break; |
306 | case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_KORECONTROLLER): | ||
307 | input->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS); | ||
308 | input->absbit[0] = BIT_MASK(ABS_HAT0X) | BIT_MASK(ABS_HAT0Y) | | ||
309 | BIT_MASK(ABS_HAT1X) | BIT_MASK(ABS_HAT1Y) | | ||
310 | BIT_MASK(ABS_HAT2X) | BIT_MASK(ABS_HAT2Y) | | ||
311 | BIT_MASK(ABS_HAT3X) | BIT_MASK(ABS_HAT3Y) | | ||
312 | BIT_MASK(ABS_X) | BIT_MASK(ABS_Y) | | ||
313 | BIT_MASK(ABS_Z); | ||
314 | input->absbit[BIT_WORD(ABS_MISC)] |= BIT_MASK(ABS_MISC); | ||
315 | BUILD_BUG_ON(sizeof(dev->keycode) < sizeof(keycode_kore)); | ||
316 | memcpy(dev->keycode, keycode_kore, sizeof(keycode_kore)); | ||
317 | input->keycodemax = ARRAY_SIZE(keycode_kore); | ||
318 | input_set_abs_params(input, ABS_HAT0X, 0, 999, 0, 10); | ||
319 | input_set_abs_params(input, ABS_HAT0Y, 0, 999, 0, 10); | ||
320 | input_set_abs_params(input, ABS_HAT1X, 0, 999, 0, 10); | ||
321 | input_set_abs_params(input, ABS_HAT1Y, 0, 999, 0, 10); | ||
322 | input_set_abs_params(input, ABS_HAT2X, 0, 999, 0, 10); | ||
323 | input_set_abs_params(input, ABS_HAT2Y, 0, 999, 0, 10); | ||
324 | input_set_abs_params(input, ABS_HAT3X, 0, 999, 0, 10); | ||
325 | input_set_abs_params(input, ABS_HAT3Y, 0, 999, 0, 10); | ||
326 | input_set_abs_params(input, ABS_X, 0, 4096, 0, 10); | ||
327 | input_set_abs_params(input, ABS_Y, 0, 4096, 0, 10); | ||
328 | input_set_abs_params(input, ABS_Z, 0, 4096, 0, 10); | ||
329 | input_set_abs_params(input, ABS_MISC, 0, 255, 0, 1); | ||
330 | snd_usb_caiaq_set_auto_msg(dev, 1, 10, 5); | ||
331 | break; | ||
242 | default: | 332 | default: |
243 | /* no input methods supported on this device */ | 333 | /* no input methods supported on this device */ |
244 | input_free_device(input); | 334 | input_free_device(input); |