blob: f1117ecc84fdf9d7b6133ae3fd96ed395f073109 [file] [log] [blame]
Daniel Mack523f1dc2007-03-26 19:11:24 +02001#ifndef CAIAQ_DEVICE_H
2#define CAIAQ_DEVICE_H
3
4#include "../usbaudio.h"
5
6#define USB_VID_NATIVEINSTRUMENTS 0x17cc
7
Daniel Mack6da7a2a2010-03-22 13:13:37 +01008#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 Mack523f1dc2007-03-26 19:11:24 +020019
20#define EP1_BUFSIZE 64
Daniel Mack6da7a2a2010-03-22 13:13:37 +010021#define EP4_BUFSIZE 512
Daniel Mack523f1dc2007-03-26 19:11:24 +020022#define CAIAQ_USB_STR_LEN 0xff
23#define MAX_STREAMS 32
24
25//#define SND_USB_CAIAQ_DEBUG
26
27#define MODNAME "snd-usb-caiaq"
28#define log(x...) snd_printk(KERN_WARNING MODNAME" log: " x)
29
30#ifdef SND_USB_CAIAQ_DEBUG
31#define debug(x...) snd_printk(KERN_WARNING MODNAME " debug: " x)
32#else
33#define debug(x...) do { } while(0)
34#endif
35
36#define EP1_CMD_GET_DEVICE_INFO 0x1
37#define EP1_CMD_READ_ERP 0x2
38#define EP1_CMD_READ_ANALOG 0x3
39#define EP1_CMD_READ_IO 0x4
40#define EP1_CMD_WRITE_IO 0x5
41#define EP1_CMD_MIDI_READ 0x6
42#define EP1_CMD_MIDI_WRITE 0x7
43#define EP1_CMD_AUDIO_PARAMS 0x9
44#define EP1_CMD_AUTO_MSG 0xb
Daniel Mack8e3cd082007-11-22 11:40:04 +010045#define EP1_CMD_DIMM_LEDS 0xc
Daniel Mack523f1dc2007-03-26 19:11:24 +020046
47struct caiaq_device_spec {
48 unsigned short fw_version;
49 unsigned char hw_subtype;
50 unsigned char num_erp;
51 unsigned char num_analog_in;
52 unsigned char num_digital_in;
53 unsigned char num_digital_out;
54 unsigned char num_analog_audio_out;
55 unsigned char num_analog_audio_in;
56 unsigned char num_digital_audio_out;
57 unsigned char num_digital_audio_in;
58 unsigned char num_midi_out;
59 unsigned char num_midi_in;
60 unsigned char data_alignment;
61} __attribute__ ((packed));
62
63struct snd_usb_caiaq_cb_info;
64
65struct snd_usb_caiaqdev {
66 struct snd_usb_audio chip;
67
68 struct urb ep1_in_urb;
69 struct urb midi_out_urb;
70 struct urb **data_urbs_in;
71 struct urb **data_urbs_out;
72 struct snd_usb_caiaq_cb_info *data_cb_info;
Dmitry Torokhovb18b4932007-11-21 16:45:23 +010073
Daniel Mack523f1dc2007-03-26 19:11:24 +020074 unsigned char ep1_in_buf[EP1_BUFSIZE];
75 unsigned char ep1_out_buf[EP1_BUFSIZE];
76 unsigned char midi_out_buf[EP1_BUFSIZE];
77
78 struct caiaq_device_spec spec;
79 spinlock_t spinlock;
80 wait_queue_head_t ep1_wait_queue;
81 wait_queue_head_t prepare_wait_queue;
82 int spec_received, audio_parm_answer;
Takashi Iwaif3f80a92009-01-08 15:32:56 +010083 int midi_out_active;
Dmitry Torokhovb18b4932007-11-21 16:45:23 +010084
Daniel Mack523f1dc2007-03-26 19:11:24 +020085 char vendor_name[CAIAQ_USB_STR_LEN];
86 char product_name[CAIAQ_USB_STR_LEN];
Daniel Mack523f1dc2007-03-26 19:11:24 +020087
88 int n_streams, n_audio_in, n_audio_out;
89 int streaming, first_packet, output_running;
90 int audio_in_buf_pos[MAX_STREAMS];
91 int audio_out_buf_pos[MAX_STREAMS];
92 int period_in_count[MAX_STREAMS];
93 int period_out_count[MAX_STREAMS];
Daniel Mack1313e702009-03-18 11:03:53 +010094 int input_panic, output_panic, warned;
Daniel Mack523f1dc2007-03-26 19:11:24 +020095 char *audio_in_buf, *audio_out_buf;
Daniel Mack9311c9b2009-03-18 11:03:54 +010096 unsigned int samplerates, bpp;
Daniel Mack523f1dc2007-03-26 19:11:24 +020097
98 struct snd_pcm_substream *sub_playback[MAX_STREAMS];
99 struct snd_pcm_substream *sub_capture[MAX_STREAMS];
100
Daniel Mack8e3cd082007-11-22 11:40:04 +0100101 /* Controls */
102 unsigned char control_state[64];
103
Daniel Mack523f1dc2007-03-26 19:11:24 +0200104 /* Linux input */
105#ifdef CONFIG_SND_USB_CAIAQ_INPUT
106 struct input_dev *input_dev;
Dmitry Torokhovb18b4932007-11-21 16:45:23 +0100107 char phys[64]; /* physical device path */
Daniel Mack8e3cd082007-11-22 11:40:04 +0100108 unsigned short keycode[64];
Daniel Mack6da7a2a2010-03-22 13:13:37 +0100109 struct urb *ep4_in_urb;
110 unsigned char ep4_in_buf[EP4_BUFSIZE];
Daniel Mack523f1dc2007-03-26 19:11:24 +0200111#endif
Dmitry Torokhovb18b4932007-11-21 16:45:23 +0100112
Daniel Mack523f1dc2007-03-26 19:11:24 +0200113 /* ALSA */
114 struct snd_pcm *pcm;
115 struct snd_pcm_hardware pcm_info;
116 struct snd_rawmidi *rmidi;
117 struct snd_rawmidi_substream *midi_receive_substream;
118 struct snd_rawmidi_substream *midi_out_substream;
119};
120
121struct snd_usb_caiaq_cb_info {
122 struct snd_usb_caiaqdev *dev;
123 int index;
124};
125
126#define caiaqdev(c) ((struct snd_usb_caiaqdev*)(c)->private_data)
127
128int snd_usb_caiaq_set_audio_params (struct snd_usb_caiaqdev *dev, int rate, int depth, int bbp);
129int snd_usb_caiaq_set_auto_msg (struct snd_usb_caiaqdev *dev, int digital, int analog, int erp);
Daniel Mack8e3cd082007-11-22 11:40:04 +0100130int snd_usb_caiaq_send_command(struct snd_usb_caiaqdev *dev,
131 unsigned char command,
132 const unsigned char *buffer,
133 int len);
Daniel Mack523f1dc2007-03-26 19:11:24 +0200134
135#endif /* CAIAQ_DEVICE_H */