diff options
Diffstat (limited to 'sound/usb/caiaq/caiaq-device.c')
-rw-r--r-- | sound/usb/caiaq/caiaq-device.c | 65 |
1 files changed, 51 insertions, 14 deletions
diff --git a/sound/usb/caiaq/caiaq-device.c b/sound/usb/caiaq/caiaq-device.c index 58af8142c571..dc2e7f7fef0f 100644 --- a/sound/usb/caiaq/caiaq-device.c +++ b/sound/usb/caiaq/caiaq-device.c | |||
@@ -31,17 +31,19 @@ | |||
31 | #include <sound/initval.h> | 31 | #include <sound/initval.h> |
32 | #include <sound/pcm.h> | 32 | #include <sound/pcm.h> |
33 | #include <sound/rawmidi.h> | 33 | #include <sound/rawmidi.h> |
34 | #include <sound/control.h> | ||
34 | 35 | ||
35 | #include "caiaq-device.h" | 36 | #include "caiaq-device.h" |
36 | #include "caiaq-audio.h" | 37 | #include "caiaq-audio.h" |
37 | #include "caiaq-midi.h" | 38 | #include "caiaq-midi.h" |
39 | #include "caiaq-control.h" | ||
38 | 40 | ||
39 | #ifdef CONFIG_SND_USB_CAIAQ_INPUT | 41 | #ifdef CONFIG_SND_USB_CAIAQ_INPUT |
40 | #include "caiaq-input.h" | 42 | #include "caiaq-input.h" |
41 | #endif | 43 | #endif |
42 | 44 | ||
43 | MODULE_AUTHOR("Daniel Mack <daniel@caiaq.de>"); | 45 | MODULE_AUTHOR("Daniel Mack <daniel@caiaq.de>"); |
44 | MODULE_DESCRIPTION("caiaq USB audio, version 1.2.0"); | 46 | MODULE_DESCRIPTION("caiaq USB audio, version 1.3.0"); |
45 | MODULE_LICENSE("GPL"); | 47 | MODULE_LICENSE("GPL"); |
46 | MODULE_SUPPORTED_DEVICE("{{Native Instruments, RigKontrol2}," | 48 | MODULE_SUPPORTED_DEVICE("{{Native Instruments, RigKontrol2}," |
47 | "{Native Instruments, RigKontrol3}," | 49 | "{Native Instruments, RigKontrol3}," |
@@ -140,14 +142,21 @@ static void usb_ep1_command_reply_dispatch (struct urb* urb) | |||
140 | case EP1_CMD_MIDI_READ: | 142 | case EP1_CMD_MIDI_READ: |
141 | snd_usb_caiaq_midi_handle_input(dev, buf[1], buf + 3, buf[2]); | 143 | snd_usb_caiaq_midi_handle_input(dev, buf[1], buf + 3, buf[2]); |
142 | break; | 144 | break; |
143 | 145 | case EP1_CMD_READ_IO: | |
146 | if (dev->chip.usb_id == | ||
147 | USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_AUDIO8DJ)) { | ||
148 | if (urb->actual_length > sizeof(dev->control_state)) | ||
149 | urb->actual_length = sizeof(dev->control_state); | ||
150 | memcpy(dev->control_state, buf + 1, urb->actual_length); | ||
151 | wake_up(&dev->ep1_wait_queue); | ||
152 | break; | ||
153 | } | ||
144 | #ifdef CONFIG_SND_USB_CAIAQ_INPUT | 154 | #ifdef CONFIG_SND_USB_CAIAQ_INPUT |
145 | case EP1_CMD_READ_ERP: | 155 | case EP1_CMD_READ_ERP: |
146 | case EP1_CMD_READ_ANALOG: | 156 | case EP1_CMD_READ_ANALOG: |
147 | case EP1_CMD_READ_IO: | ||
148 | snd_usb_caiaq_input_dispatch(dev, buf, urb->actual_length); | 157 | snd_usb_caiaq_input_dispatch(dev, buf, urb->actual_length); |
149 | break; | ||
150 | #endif | 158 | #endif |
159 | break; | ||
151 | } | 160 | } |
152 | 161 | ||
153 | dev->ep1_in_urb.actual_length = 0; | 162 | dev->ep1_in_urb.actual_length = 0; |
@@ -156,10 +165,10 @@ static void usb_ep1_command_reply_dispatch (struct urb* urb) | |||
156 | log("unable to submit urb. OOM!?\n"); | 165 | log("unable to submit urb. OOM!?\n"); |
157 | } | 166 | } |
158 | 167 | ||
159 | static int send_command (struct snd_usb_caiaqdev *dev, | 168 | int snd_usb_caiaq_send_command(struct snd_usb_caiaqdev *dev, |
160 | unsigned char command, | 169 | unsigned char command, |
161 | const unsigned char *buffer, | 170 | const unsigned char *buffer, |
162 | int len) | 171 | int len) |
163 | { | 172 | { |
164 | int actual_len; | 173 | int actual_len; |
165 | struct usb_device *usb_dev = dev->chip.dev; | 174 | struct usb_device *usb_dev = dev->chip.dev; |
@@ -207,7 +216,8 @@ int snd_usb_caiaq_set_audio_params (struct snd_usb_caiaqdev *dev, | |||
207 | rate, depth, bpp); | 216 | rate, depth, bpp); |
208 | 217 | ||
209 | dev->audio_parm_answer = -1; | 218 | dev->audio_parm_answer = -1; |
210 | ret = send_command(dev, EP1_CMD_AUDIO_PARAMS, tmp, sizeof(tmp)); | 219 | ret = snd_usb_caiaq_send_command(dev, EP1_CMD_AUDIO_PARAMS, |
220 | tmp, sizeof(tmp)); | ||
211 | 221 | ||
212 | if (ret) | 222 | if (ret) |
213 | return ret; | 223 | return ret; |
@@ -226,7 +236,8 @@ int snd_usb_caiaq_set_auto_msg (struct snd_usb_caiaqdev *dev, | |||
226 | int digital, int analog, int erp) | 236 | int digital, int analog, int erp) |
227 | { | 237 | { |
228 | char tmp[3] = { digital, analog, erp }; | 238 | char tmp[3] = { digital, analog, erp }; |
229 | return send_command(dev, EP1_CMD_AUTO_MSG, tmp, sizeof(tmp)); | 239 | return snd_usb_caiaq_send_command(dev, EP1_CMD_AUTO_MSG, |
240 | tmp, sizeof(tmp)); | ||
230 | } | 241 | } |
231 | 242 | ||
232 | static void setup_card(struct snd_usb_caiaqdev *dev) | 243 | static void setup_card(struct snd_usb_caiaqdev *dev) |
@@ -241,7 +252,7 @@ static void setup_card(struct snd_usb_caiaqdev *dev) | |||
241 | val[0] = 0x00; | 252 | val[0] = 0x00; |
242 | val[1] = 0x00; | 253 | val[1] = 0x00; |
243 | val[2] = 0x01; | 254 | val[2] = 0x01; |
244 | send_command(dev, EP1_CMD_WRITE_IO, val, 3); | 255 | snd_usb_caiaq_send_command(dev, EP1_CMD_WRITE_IO, val, 3); |
245 | break; | 256 | break; |
246 | case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_RIGKONTROL3): | 257 | case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_RIGKONTROL3): |
247 | /* RigKontrol2 - display two centered dashes ('--') */ | 258 | /* RigKontrol2 - display two centered dashes ('--') */ |
@@ -249,12 +260,34 @@ static void setup_card(struct snd_usb_caiaqdev *dev) | |||
249 | val[1] = 0x40; | 260 | val[1] = 0x40; |
250 | val[2] = 0x40; | 261 | val[2] = 0x40; |
251 | val[3] = 0x00; | 262 | val[3] = 0x00; |
252 | send_command(dev, EP1_CMD_WRITE_IO, val, 4); | 263 | snd_usb_caiaq_send_command(dev, EP1_CMD_WRITE_IO, val, 4); |
253 | break; | 264 | break; |
254 | case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_AK1): | 265 | case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_AK1): |
255 | /* Audio Kontrol 1 - make USB-LED stop blinking */ | 266 | /* Audio Kontrol 1 - make USB-LED stop blinking */ |
256 | val[0] = 0x00; | 267 | val[0] = 0x00; |
257 | send_command(dev, EP1_CMD_WRITE_IO, val, 1); | 268 | snd_usb_caiaq_send_command(dev, EP1_CMD_WRITE_IO, val, 1); |
269 | break; | ||
270 | case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_AUDIO8DJ): | ||
271 | /* Audio 8 DJ - trigger read of current settings */ | ||
272 | dev->control_state[0] = 0xff; | ||
273 | snd_usb_caiaq_set_auto_msg(dev, 1, 0, 0); | ||
274 | snd_usb_caiaq_send_command(dev, EP1_CMD_READ_IO, NULL, 0); | ||
275 | |||
276 | if (!wait_event_timeout(dev->ep1_wait_queue, | ||
277 | dev->control_state[0] != 0xff, HZ)) | ||
278 | return; | ||
279 | |||
280 | /* fix up some defaults */ | ||
281 | if ((dev->control_state[1] != 2) || | ||
282 | (dev->control_state[2] != 3) || | ||
283 | (dev->control_state[4] != 2)) { | ||
284 | dev->control_state[1] = 2; | ||
285 | dev->control_state[2] = 3; | ||
286 | dev->control_state[4] = 2; | ||
287 | snd_usb_caiaq_send_command(dev, | ||
288 | EP1_CMD_WRITE_IO, dev->control_state, 6); | ||
289 | } | ||
290 | |||
258 | break; | 291 | break; |
259 | } | 292 | } |
260 | 293 | ||
@@ -278,6 +311,10 @@ static void setup_card(struct snd_usb_caiaqdev *dev) | |||
278 | log("snd_card_register() returned %d\n", ret); | 311 | log("snd_card_register() returned %d\n", ret); |
279 | snd_card_free(dev->chip.card); | 312 | snd_card_free(dev->chip.card); |
280 | } | 313 | } |
314 | |||
315 | ret = snd_usb_caiaq_control_init(dev); | ||
316 | if (ret < 0) | ||
317 | log("Unable to set up control system (ret=%d)\n", ret); | ||
281 | } | 318 | } |
282 | 319 | ||
283 | static struct snd_card* create_card(struct usb_device* usb_dev) | 320 | static struct snd_card* create_card(struct usb_device* usb_dev) |
@@ -340,7 +377,7 @@ static int init_card(struct snd_usb_caiaqdev *dev) | |||
340 | if (usb_submit_urb(&dev->ep1_in_urb, GFP_KERNEL) != 0) | 377 | if (usb_submit_urb(&dev->ep1_in_urb, GFP_KERNEL) != 0) |
341 | return -EIO; | 378 | return -EIO; |
342 | 379 | ||
343 | err = send_command(dev, EP1_CMD_GET_DEVICE_INFO, NULL, 0); | 380 | err = snd_usb_caiaq_send_command(dev, EP1_CMD_GET_DEVICE_INFO, NULL, 0); |
344 | if (err) | 381 | if (err) |
345 | return err; | 382 | return err; |
346 | 383 | ||