f9fbdbae269d21491d2dc84f726cfc12cdf51261
[linux-2.6.git] / sound / usb / caiaq / caiaq-device.h
1 #ifndef CAIAQ_DEVICE_H
2 #define CAIAQ_DEVICE_H
3
4 #include "../usbaudio.h"
5
6 #define USB_VID_NATIVEINSTRUMENTS 0x17cc
7
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_AUDIO8DJ        0x1978
14 #define USB_PID_SESSIONIO       0x1915
15
16 #define EP1_BUFSIZE 64
17 #define CAIAQ_USB_STR_LEN 0xff
18 #define MAX_STREAMS 32
19
20 //#define       SND_USB_CAIAQ_DEBUG
21
22 #define MODNAME "snd-usb-caiaq"
23 #define log(x...) snd_printk(KERN_WARNING MODNAME" log: " x)
24
25 #ifdef SND_USB_CAIAQ_DEBUG
26 #define debug(x...) snd_printk(KERN_WARNING MODNAME " debug: " x)
27 #else
28 #define debug(x...) do { } while(0)
29 #endif
30
31 #define EP1_CMD_GET_DEVICE_INFO 0x1
32 #define EP1_CMD_READ_ERP        0x2
33 #define EP1_CMD_READ_ANALOG     0x3
34 #define EP1_CMD_READ_IO         0x4
35 #define EP1_CMD_WRITE_IO        0x5
36 #define EP1_CMD_MIDI_READ       0x6
37 #define EP1_CMD_MIDI_WRITE      0x7
38 #define EP1_CMD_AUDIO_PARAMS    0x9
39 #define EP1_CMD_AUTO_MSG        0xb
40 #define EP1_CMD_DIMM_LEDS       0xc
41
42 struct caiaq_device_spec {
43         unsigned short fw_version;
44         unsigned char hw_subtype;
45         unsigned char num_erp;
46         unsigned char num_analog_in;
47         unsigned char num_digital_in;
48         unsigned char num_digital_out;
49         unsigned char num_analog_audio_out;
50         unsigned char num_analog_audio_in;
51         unsigned char num_digital_audio_out;
52         unsigned char num_digital_audio_in;
53         unsigned char num_midi_out;
54         unsigned char num_midi_in;
55         unsigned char data_alignment;
56 } __attribute__ ((packed));
57
58 struct snd_usb_caiaq_cb_info;
59
60 struct snd_usb_caiaqdev {
61         struct snd_usb_audio chip;
62
63         struct urb ep1_in_urb;
64         struct urb midi_out_urb;
65         struct urb **data_urbs_in;
66         struct urb **data_urbs_out;
67         struct snd_usb_caiaq_cb_info *data_cb_info;
68
69         unsigned char ep1_in_buf[EP1_BUFSIZE];
70         unsigned char ep1_out_buf[EP1_BUFSIZE];
71         unsigned char midi_out_buf[EP1_BUFSIZE];
72
73         struct caiaq_device_spec spec;
74         spinlock_t spinlock;
75         wait_queue_head_t ep1_wait_queue;
76         wait_queue_head_t prepare_wait_queue;
77         int spec_received, audio_parm_answer;
78
79         char vendor_name[CAIAQ_USB_STR_LEN];
80         char product_name[CAIAQ_USB_STR_LEN];
81         char serial[CAIAQ_USB_STR_LEN];
82
83         int n_streams, n_audio_in, n_audio_out;
84         int streaming, first_packet, output_running;
85         int audio_in_buf_pos[MAX_STREAMS];
86         int audio_out_buf_pos[MAX_STREAMS];
87         int period_in_count[MAX_STREAMS];
88         int period_out_count[MAX_STREAMS];
89         int input_panic, output_panic;
90         char *audio_in_buf, *audio_out_buf;
91         unsigned int samplerates;
92
93         struct snd_pcm_substream *sub_playback[MAX_STREAMS];
94         struct snd_pcm_substream *sub_capture[MAX_STREAMS];
95
96         /* Controls */
97         unsigned char control_state[64];
98
99         /* Linux input */
100 #ifdef CONFIG_SND_USB_CAIAQ_INPUT
101         struct input_dev *input_dev;
102         char phys[64];                  /* physical device path */
103         unsigned short keycode[64];
104 #endif
105
106         /* ALSA */
107         struct snd_pcm *pcm;
108         struct snd_pcm_hardware pcm_info;
109         struct snd_rawmidi *rmidi;
110         struct snd_rawmidi_substream *midi_receive_substream;
111         struct snd_rawmidi_substream *midi_out_substream;
112 };
113
114 struct snd_usb_caiaq_cb_info {
115         struct snd_usb_caiaqdev *dev;
116         int index;
117 };
118
119 #define caiaqdev(c) ((struct snd_usb_caiaqdev*)(c)->private_data)
120
121 int snd_usb_caiaq_set_audio_params (struct snd_usb_caiaqdev *dev, int rate, int depth, int bbp);
122 int snd_usb_caiaq_set_auto_msg (struct snd_usb_caiaqdev *dev, int digital, int analog, int erp);
123 int snd_usb_caiaq_send_command(struct snd_usb_caiaqdev *dev,
124                                unsigned char command,
125                                const unsigned char *buffer,
126                                int len);
127
128 #endif /* CAIAQ_DEVICE_H */