blob: 44e3edf88befab4ce60071a3d9b9da72bd9a727e [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
8#define USB_PID_RIGKONTROL2 0x1969
Daniel Mackad1e34b2007-09-17 14:45:14 +02009#define USB_PID_RIGKONTROL3 0x1940
Dmitry Torokhovb18b4932007-11-21 16:45:23 +010010#define USB_PID_KORECONTROLLER 0x4711
Daniel Mack7829d0e2007-11-26 09:00:56 +010011#define USB_PID_KORECONTROLLER2 0x4712
Daniel Mack523f1dc2007-03-26 19:11:24 +020012#define USB_PID_AK1 0x0815
Daniel Mackb30c4942009-07-22 14:13:35 +020013#define USB_PID_AUDIO2DJ 0x041c
Daniel Mack21655922009-01-16 11:03:19 +010014#define USB_PID_AUDIO4DJ 0x0839
Daniel Mack523f1dc2007-03-26 19:11:24 +020015#define USB_PID_AUDIO8DJ 0x1978
Daniel Mackf3e9d5d2008-05-08 15:42:15 +020016#define USB_PID_SESSIONIO 0x1915
Daniel Mack21655922009-01-16 11:03:19 +010017#define USB_PID_GUITARRIGMOBILE 0x0d8d
Daniel Mack523f1dc2007-03-26 19:11:24 +020018
19#define EP1_BUFSIZE 64
20#define CAIAQ_USB_STR_LEN 0xff
21#define MAX_STREAMS 32
22
23//#define SND_USB_CAIAQ_DEBUG
24
25#define MODNAME "snd-usb-caiaq"
26#define log(x...) snd_printk(KERN_WARNING MODNAME" log: " x)
27
28#ifdef SND_USB_CAIAQ_DEBUG
29#define debug(x...) snd_printk(KERN_WARNING MODNAME " debug: " x)
30#else
31#define debug(x...) do { } while(0)
32#endif
33
34#define EP1_CMD_GET_DEVICE_INFO 0x1
35#define EP1_CMD_READ_ERP 0x2
36#define EP1_CMD_READ_ANALOG 0x3
37#define EP1_CMD_READ_IO 0x4
38#define EP1_CMD_WRITE_IO 0x5
39#define EP1_CMD_MIDI_READ 0x6
40#define EP1_CMD_MIDI_WRITE 0x7
41#define EP1_CMD_AUDIO_PARAMS 0x9
42#define EP1_CMD_AUTO_MSG 0xb
Daniel Mack8e3cd082007-11-22 11:40:04 +010043#define EP1_CMD_DIMM_LEDS 0xc
Daniel Mack523f1dc2007-03-26 19:11:24 +020044
45struct caiaq_device_spec {
46 unsigned short fw_version;
47 unsigned char hw_subtype;
48 unsigned char num_erp;
49 unsigned char num_analog_in;
50 unsigned char num_digital_in;
51 unsigned char num_digital_out;
52 unsigned char num_analog_audio_out;
53 unsigned char num_analog_audio_in;
54 unsigned char num_digital_audio_out;
55 unsigned char num_digital_audio_in;
56 unsigned char num_midi_out;
57 unsigned char num_midi_in;
58 unsigned char data_alignment;
59} __attribute__ ((packed));
60
61struct snd_usb_caiaq_cb_info;
62
63struct snd_usb_caiaqdev {
64 struct snd_usb_audio chip;
65
66 struct urb ep1_in_urb;
67 struct urb midi_out_urb;
68 struct urb **data_urbs_in;
69 struct urb **data_urbs_out;
70 struct snd_usb_caiaq_cb_info *data_cb_info;
Dmitry Torokhovb18b4932007-11-21 16:45:23 +010071
Daniel Mack523f1dc2007-03-26 19:11:24 +020072 unsigned char ep1_in_buf[EP1_BUFSIZE];
73 unsigned char ep1_out_buf[EP1_BUFSIZE];
74 unsigned char midi_out_buf[EP1_BUFSIZE];
75
76 struct caiaq_device_spec spec;
77 spinlock_t spinlock;
78 wait_queue_head_t ep1_wait_queue;
79 wait_queue_head_t prepare_wait_queue;
80 int spec_received, audio_parm_answer;
Takashi Iwaif3f80a92009-01-08 15:32:56 +010081 int midi_out_active;
Dmitry Torokhovb18b4932007-11-21 16:45:23 +010082
Daniel Mack523f1dc2007-03-26 19:11:24 +020083 char vendor_name[CAIAQ_USB_STR_LEN];
84 char product_name[CAIAQ_USB_STR_LEN];
Daniel Mack523f1dc2007-03-26 19:11:24 +020085
86 int n_streams, n_audio_in, n_audio_out;
87 int streaming, first_packet, output_running;
88 int audio_in_buf_pos[MAX_STREAMS];
89 int audio_out_buf_pos[MAX_STREAMS];
90 int period_in_count[MAX_STREAMS];
91 int period_out_count[MAX_STREAMS];
Daniel Mack1313e702009-03-18 11:03:53 +010092 int input_panic, output_panic, warned;
Daniel Mack523f1dc2007-03-26 19:11:24 +020093 char *audio_in_buf, *audio_out_buf;
Daniel Mack9311c9b2009-03-18 11:03:54 +010094 unsigned int samplerates, bpp;
Daniel Mack523f1dc2007-03-26 19:11:24 +020095
96 struct snd_pcm_substream *sub_playback[MAX_STREAMS];
97 struct snd_pcm_substream *sub_capture[MAX_STREAMS];
98
Daniel Mack8e3cd082007-11-22 11:40:04 +010099 /* Controls */
100 unsigned char control_state[64];
101
Daniel Mack523f1dc2007-03-26 19:11:24 +0200102 /* Linux input */
103#ifdef CONFIG_SND_USB_CAIAQ_INPUT
104 struct input_dev *input_dev;
Dmitry Torokhovb18b4932007-11-21 16:45:23 +0100105 char phys[64]; /* physical device path */
Daniel Mack8e3cd082007-11-22 11:40:04 +0100106 unsigned short keycode[64];
Daniel Mack523f1dc2007-03-26 19:11:24 +0200107#endif
Dmitry Torokhovb18b4932007-11-21 16:45:23 +0100108
Daniel Mack523f1dc2007-03-26 19:11:24 +0200109 /* 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
117struct snd_usb_caiaq_cb_info {
118 struct snd_usb_caiaqdev *dev;
119 int index;
120};
121
122#define caiaqdev(c) ((struct snd_usb_caiaqdev*)(c)->private_data)
123
124int snd_usb_caiaq_set_audio_params (struct snd_usb_caiaqdev *dev, int rate, int depth, int bbp);
125int snd_usb_caiaq_set_auto_msg (struct snd_usb_caiaqdev *dev, int digital, int analog, int erp);
Daniel Mack8e3cd082007-11-22 11:40:04 +0100126int snd_usb_caiaq_send_command(struct snd_usb_caiaqdev *dev,
127 unsigned char command,
128 const unsigned char *buffer,
129 int len);
Daniel Mack523f1dc2007-03-26 19:11:24 +0200130
131#endif /* CAIAQ_DEVICE_H */