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