Daniel Mack | 523f1dc | 2007-03-26 19:11:24 +0200 | [diff] [blame] | 1 | #ifndef CAIAQ_DEVICE_H |
| 2 | #define CAIAQ_DEVICE_H |
| 3 | |
| 4 | #include "../usbaudio.h" |
| 5 | |
| 6 | #define USB_VID_NATIVEINSTRUMENTS 0x17cc |
| 7 | |
Daniel Mack | 6da7a2a | 2010-03-22 13:13:37 +0100 | [diff] [blame] | 8 | #define USB_PID_RIGKONTROL2 0x1969 |
| 9 | #define USB_PID_RIGKONTROL3 0x1940 |
| 10 | #define USB_PID_KORECONTROLLER 0x4711 |
| 11 | #define USB_PID_KORECONTROLLER2 0x4712 |
| 12 | #define USB_PID_AK1 0x0815 |
| 13 | #define USB_PID_AUDIO2DJ 0x041c |
| 14 | #define USB_PID_AUDIO4DJ 0x0839 |
| 15 | #define USB_PID_AUDIO8DJ 0x1978 |
| 16 | #define USB_PID_SESSIONIO 0x1915 |
| 17 | #define USB_PID_GUITARRIGMOBILE 0x0d8d |
| 18 | #define USB_PID_TRAKTORKONTROLX1 0x2305 |
Daniel Mack | 15c5ab6 | 2010-09-10 17:04:57 +0800 | [diff] [blame] | 19 | #define USB_PID_TRAKTORKONTROLS4 0xbaff |
Daniel Mack | df8d81a | 2010-09-01 16:23:46 +0800 | [diff] [blame] | 20 | #define USB_PID_TRAKTORAUDIO2 0x041d |
William Light | e653510 | 2011-10-10 15:54:23 +0000 | [diff] [blame] | 21 | #define USB_PID_MASCHINECONTROLLER 0x0808 |
Daniel Mack | 523f1dc | 2007-03-26 19:11:24 +0200 | [diff] [blame] | 22 | |
| 23 | #define EP1_BUFSIZE 64 |
Daniel Mack | 6da7a2a | 2010-03-22 13:13:37 +0100 | [diff] [blame] | 24 | #define EP4_BUFSIZE 512 |
Daniel Mack | 523f1dc | 2007-03-26 19:11:24 +0200 | [diff] [blame] | 25 | #define CAIAQ_USB_STR_LEN 0xff |
| 26 | #define MAX_STREAMS 32 |
| 27 | |
Daniel Mack | 523f1dc | 2007-03-26 19:11:24 +0200 | [diff] [blame] | 28 | #define MODNAME "snd-usb-caiaq" |
Daniel Mack | 523f1dc | 2007-03-26 19:11:24 +0200 | [diff] [blame] | 29 | |
| 30 | #define EP1_CMD_GET_DEVICE_INFO 0x1 |
| 31 | #define EP1_CMD_READ_ERP 0x2 |
| 32 | #define EP1_CMD_READ_ANALOG 0x3 |
| 33 | #define EP1_CMD_READ_IO 0x4 |
| 34 | #define EP1_CMD_WRITE_IO 0x5 |
| 35 | #define EP1_CMD_MIDI_READ 0x6 |
| 36 | #define EP1_CMD_MIDI_WRITE 0x7 |
| 37 | #define EP1_CMD_AUDIO_PARAMS 0x9 |
| 38 | #define EP1_CMD_AUTO_MSG 0xb |
Daniel Mack | 8e3cd08 | 2007-11-22 11:40:04 +0100 | [diff] [blame] | 39 | #define EP1_CMD_DIMM_LEDS 0xc |
Daniel Mack | 523f1dc | 2007-03-26 19:11:24 +0200 | [diff] [blame] | 40 | |
| 41 | struct caiaq_device_spec { |
| 42 | unsigned short fw_version; |
| 43 | unsigned char hw_subtype; |
| 44 | unsigned char num_erp; |
| 45 | unsigned char num_analog_in; |
| 46 | unsigned char num_digital_in; |
| 47 | unsigned char num_digital_out; |
| 48 | unsigned char num_analog_audio_out; |
| 49 | unsigned char num_analog_audio_in; |
| 50 | unsigned char num_digital_audio_out; |
| 51 | unsigned char num_digital_audio_in; |
| 52 | unsigned char num_midi_out; |
| 53 | unsigned char num_midi_in; |
| 54 | unsigned char data_alignment; |
| 55 | } __attribute__ ((packed)); |
| 56 | |
| 57 | struct snd_usb_caiaq_cb_info; |
| 58 | |
| 59 | struct snd_usb_caiaqdev { |
| 60 | struct snd_usb_audio chip; |
| 61 | |
| 62 | struct urb ep1_in_urb; |
| 63 | struct urb midi_out_urb; |
| 64 | struct urb **data_urbs_in; |
| 65 | struct urb **data_urbs_out; |
| 66 | struct snd_usb_caiaq_cb_info *data_cb_info; |
Dmitry Torokhov | b18b493 | 2007-11-21 16:45:23 +0100 | [diff] [blame] | 67 | |
Daniel Mack | 523f1dc | 2007-03-26 19:11:24 +0200 | [diff] [blame] | 68 | unsigned char ep1_in_buf[EP1_BUFSIZE]; |
| 69 | unsigned char ep1_out_buf[EP1_BUFSIZE]; |
| 70 | unsigned char midi_out_buf[EP1_BUFSIZE]; |
| 71 | |
| 72 | struct caiaq_device_spec spec; |
| 73 | spinlock_t spinlock; |
| 74 | wait_queue_head_t ep1_wait_queue; |
| 75 | wait_queue_head_t prepare_wait_queue; |
| 76 | int spec_received, audio_parm_answer; |
Takashi Iwai | f3f80a9 | 2009-01-08 15:32:56 +0100 | [diff] [blame] | 77 | int midi_out_active; |
Dmitry Torokhov | b18b493 | 2007-11-21 16:45:23 +0100 | [diff] [blame] | 78 | |
Daniel Mack | 523f1dc | 2007-03-26 19:11:24 +0200 | [diff] [blame] | 79 | char vendor_name[CAIAQ_USB_STR_LEN]; |
| 80 | char product_name[CAIAQ_USB_STR_LEN]; |
Daniel Mack | 523f1dc | 2007-03-26 19:11:24 +0200 | [diff] [blame] | 81 | |
| 82 | int n_streams, n_audio_in, n_audio_out; |
| 83 | int streaming, first_packet, output_running; |
| 84 | int audio_in_buf_pos[MAX_STREAMS]; |
| 85 | int audio_out_buf_pos[MAX_STREAMS]; |
| 86 | int period_in_count[MAX_STREAMS]; |
| 87 | int period_out_count[MAX_STREAMS]; |
Daniel Mack | 1313e70 | 2009-03-18 11:03:53 +0100 | [diff] [blame] | 88 | int input_panic, output_panic, warned; |
Daniel Mack | 523f1dc | 2007-03-26 19:11:24 +0200 | [diff] [blame] | 89 | char *audio_in_buf, *audio_out_buf; |
Daniel Mack | 9311c9b | 2009-03-18 11:03:54 +0100 | [diff] [blame] | 90 | unsigned int samplerates, bpp; |
Daniel Mack | da6094e | 2011-08-14 11:31:16 +0200 | [diff] [blame] | 91 | unsigned long outurb_active_mask; |
Daniel Mack | 523f1dc | 2007-03-26 19:11:24 +0200 | [diff] [blame] | 92 | |
| 93 | struct snd_pcm_substream *sub_playback[MAX_STREAMS]; |
| 94 | struct snd_pcm_substream *sub_capture[MAX_STREAMS]; |
| 95 | |
Daniel Mack | 8e3cd08 | 2007-11-22 11:40:04 +0100 | [diff] [blame] | 96 | /* Controls */ |
Daniel Mack | 15c5ab6 | 2010-09-10 17:04:57 +0800 | [diff] [blame] | 97 | unsigned char control_state[256]; |
| 98 | unsigned char ep8_out_buf[2]; |
Daniel Mack | 8e3cd08 | 2007-11-22 11:40:04 +0100 | [diff] [blame] | 99 | |
Daniel Mack | 523f1dc | 2007-03-26 19:11:24 +0200 | [diff] [blame] | 100 | /* Linux input */ |
| 101 | #ifdef CONFIG_SND_USB_CAIAQ_INPUT |
| 102 | struct input_dev *input_dev; |
Dmitry Torokhov | b18b493 | 2007-11-21 16:45:23 +0100 | [diff] [blame] | 103 | char phys[64]; /* physical device path */ |
Daniel Mack | 15c5ab6 | 2010-09-10 17:04:57 +0800 | [diff] [blame] | 104 | unsigned short keycode[128]; |
Daniel Mack | 6da7a2a | 2010-03-22 13:13:37 +0100 | [diff] [blame] | 105 | struct urb *ep4_in_urb; |
| 106 | unsigned char ep4_in_buf[EP4_BUFSIZE]; |
Daniel Mack | 523f1dc | 2007-03-26 19:11:24 +0200 | [diff] [blame] | 107 | #endif |
Dmitry Torokhov | b18b493 | 2007-11-21 16:45:23 +0100 | [diff] [blame] | 108 | |
Daniel Mack | 523f1dc | 2007-03-26 19:11:24 +0200 | [diff] [blame] | 109 | /* ALSA */ |
| 110 | struct snd_pcm *pcm; |
| 111 | struct snd_pcm_hardware pcm_info; |
| 112 | struct snd_rawmidi *rmidi; |
| 113 | struct snd_rawmidi_substream *midi_receive_substream; |
| 114 | struct snd_rawmidi_substream *midi_out_substream; |
| 115 | }; |
| 116 | |
| 117 | struct snd_usb_caiaq_cb_info { |
Daniel Mack | 1c8470c | 2013-03-03 20:46:21 +0100 | [diff] [blame] | 118 | struct snd_usb_caiaqdev *cdev; |
Daniel Mack | 523f1dc | 2007-03-26 19:11:24 +0200 | [diff] [blame] | 119 | int index; |
| 120 | }; |
| 121 | |
| 122 | #define caiaqdev(c) ((struct snd_usb_caiaqdev*)(c)->private_data) |
Daniel Mack | f1f6b8f | 2013-03-03 20:46:22 +0100 | [diff] [blame] | 123 | #define caiaqdev_to_dev(d) (d->chip.card->dev) |
Daniel Mack | 523f1dc | 2007-03-26 19:11:24 +0200 | [diff] [blame] | 124 | |
Daniel Mack | 1c8470c | 2013-03-03 20:46:21 +0100 | [diff] [blame] | 125 | int snd_usb_caiaq_set_audio_params (struct snd_usb_caiaqdev *cdev, int rate, int depth, int bbp); |
| 126 | int snd_usb_caiaq_set_auto_msg (struct snd_usb_caiaqdev *cdev, int digital, int analog, int erp); |
| 127 | int snd_usb_caiaq_send_command(struct snd_usb_caiaqdev *cdev, |
Daniel Mack | 8e3cd08 | 2007-11-22 11:40:04 +0100 | [diff] [blame] | 128 | unsigned char command, |
| 129 | const unsigned char *buffer, |
| 130 | int len); |
Daniel Mack | 523f1dc | 2007-03-26 19:11:24 +0200 | [diff] [blame] | 131 | |
| 132 | #endif /* CAIAQ_DEVICE_H */ |