0001
0002 #ifndef CAIAQ_DEVICE_H
0003 #define CAIAQ_DEVICE_H
0004
0005 #include "../usbaudio.h"
0006
0007 #define USB_VID_NATIVEINSTRUMENTS 0x17cc
0008
0009 #define USB_PID_RIGKONTROL2 0x1969
0010 #define USB_PID_RIGKONTROL3 0x1940
0011 #define USB_PID_KORECONTROLLER 0x4711
0012 #define USB_PID_KORECONTROLLER2 0x4712
0013 #define USB_PID_AK1 0x0815
0014 #define USB_PID_AUDIO2DJ 0x041c
0015 #define USB_PID_AUDIO4DJ 0x0839
0016 #define USB_PID_AUDIO8DJ 0x1978
0017 #define USB_PID_SESSIONIO 0x1915
0018 #define USB_PID_GUITARRIGMOBILE 0x0d8d
0019 #define USB_PID_TRAKTORKONTROLX1 0x2305
0020 #define USB_PID_TRAKTORKONTROLS4 0xbaff
0021 #define USB_PID_TRAKTORAUDIO2 0x041d
0022 #define USB_PID_MASCHINECONTROLLER 0x0808
0023
0024 #define EP1_BUFSIZE 64
0025 #define EP4_BUFSIZE 512
0026 #define CAIAQ_USB_STR_LEN 0xff
0027 #define MAX_STREAMS 32
0028
0029 #define MODNAME "snd-usb-caiaq"
0030
0031 #define EP1_CMD_GET_DEVICE_INFO 0x1
0032 #define EP1_CMD_READ_ERP 0x2
0033 #define EP1_CMD_READ_ANALOG 0x3
0034 #define EP1_CMD_READ_IO 0x4
0035 #define EP1_CMD_WRITE_IO 0x5
0036 #define EP1_CMD_MIDI_READ 0x6
0037 #define EP1_CMD_MIDI_WRITE 0x7
0038 #define EP1_CMD_AUDIO_PARAMS 0x9
0039 #define EP1_CMD_AUTO_MSG 0xb
0040 #define EP1_CMD_DIMM_LEDS 0xc
0041
0042 struct caiaq_device_spec {
0043 unsigned short fw_version;
0044 unsigned char hw_subtype;
0045 unsigned char num_erp;
0046 unsigned char num_analog_in;
0047 unsigned char num_digital_in;
0048 unsigned char num_digital_out;
0049 unsigned char num_analog_audio_out;
0050 unsigned char num_analog_audio_in;
0051 unsigned char num_digital_audio_out;
0052 unsigned char num_digital_audio_in;
0053 unsigned char num_midi_out;
0054 unsigned char num_midi_in;
0055 unsigned char data_alignment;
0056 } __attribute__ ((packed));
0057
0058 struct snd_usb_caiaq_cb_info;
0059
0060 struct snd_usb_caiaqdev {
0061 struct snd_usb_audio chip;
0062
0063 struct urb ep1_in_urb;
0064 struct urb midi_out_urb;
0065 struct urb **data_urbs_in;
0066 struct urb **data_urbs_out;
0067 struct snd_usb_caiaq_cb_info *data_cb_info;
0068
0069 unsigned char ep1_in_buf[EP1_BUFSIZE];
0070 unsigned char ep1_out_buf[EP1_BUFSIZE];
0071 unsigned char midi_out_buf[EP1_BUFSIZE];
0072
0073 struct caiaq_device_spec spec;
0074 spinlock_t spinlock;
0075 wait_queue_head_t ep1_wait_queue;
0076 wait_queue_head_t prepare_wait_queue;
0077 int spec_received, audio_parm_answer;
0078 int midi_out_active;
0079
0080 char vendor_name[CAIAQ_USB_STR_LEN];
0081 char product_name[CAIAQ_USB_STR_LEN];
0082
0083 int n_streams, n_audio_in, n_audio_out;
0084 int streaming, first_packet, output_running;
0085 int audio_in_buf_pos[MAX_STREAMS];
0086 int audio_out_buf_pos[MAX_STREAMS];
0087 int period_in_count[MAX_STREAMS];
0088 int period_out_count[MAX_STREAMS];
0089 int input_panic, output_panic, warned;
0090 char *audio_in_buf, *audio_out_buf;
0091 unsigned int samplerates, bpp;
0092 unsigned long outurb_active_mask;
0093
0094 struct snd_pcm_substream *sub_playback[MAX_STREAMS];
0095 struct snd_pcm_substream *sub_capture[MAX_STREAMS];
0096
0097
0098 unsigned char control_state[256];
0099 unsigned char ep8_out_buf[2];
0100
0101
0102 #ifdef CONFIG_SND_USB_CAIAQ_INPUT
0103 struct input_dev *input_dev;
0104 char phys[64];
0105 unsigned short keycode[128];
0106 struct urb *ep4_in_urb;
0107 unsigned char ep4_in_buf[EP4_BUFSIZE];
0108 #endif
0109
0110
0111 struct snd_pcm *pcm;
0112 struct snd_pcm_hardware pcm_info;
0113 struct snd_rawmidi *rmidi;
0114 struct snd_rawmidi_substream *midi_receive_substream;
0115 struct snd_rawmidi_substream *midi_out_substream;
0116 };
0117
0118 struct snd_usb_caiaq_cb_info {
0119 struct snd_usb_caiaqdev *cdev;
0120 int index;
0121 };
0122
0123 #define caiaqdev(c) ((struct snd_usb_caiaqdev*)(c)->private_data)
0124 #define caiaqdev_to_dev(d) (d->chip.card->dev)
0125
0126 int snd_usb_caiaq_set_audio_params (struct snd_usb_caiaqdev *cdev, int rate, int depth, int bbp);
0127 int snd_usb_caiaq_set_auto_msg (struct snd_usb_caiaqdev *cdev, int digital, int analog, int erp);
0128 int snd_usb_caiaq_send_command(struct snd_usb_caiaqdev *cdev,
0129 unsigned char command,
0130 const unsigned char *buffer,
0131 int len);
0132 int snd_usb_caiaq_send_command_bank(struct snd_usb_caiaqdev *cdev,
0133 unsigned char command,
0134 unsigned char bank,
0135 const unsigned char *buffer,
0136 int len);
0137
0138 #endif