^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) /* SPDX-License-Identifier: GPL-2.0 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) #ifndef CAIAQ_DEVICE_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) #define CAIAQ_DEVICE_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) #include "../usbaudio.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) #define USB_VID_NATIVEINSTRUMENTS 0x17cc
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) #define USB_PID_RIGKONTROL2 0x1969
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) #define USB_PID_RIGKONTROL3 0x1940
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) #define USB_PID_KORECONTROLLER 0x4711
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) #define USB_PID_KORECONTROLLER2 0x4712
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) #define USB_PID_AK1 0x0815
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) #define USB_PID_AUDIO2DJ 0x041c
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) #define USB_PID_AUDIO4DJ 0x0839
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) #define USB_PID_AUDIO8DJ 0x1978
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) #define USB_PID_SESSIONIO 0x1915
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) #define USB_PID_GUITARRIGMOBILE 0x0d8d
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) #define USB_PID_TRAKTORKONTROLX1 0x2305
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) #define USB_PID_TRAKTORKONTROLS4 0xbaff
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) #define USB_PID_TRAKTORAUDIO2 0x041d
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) #define USB_PID_MASCHINECONTROLLER 0x0808
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) #define EP1_BUFSIZE 64
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) #define EP4_BUFSIZE 512
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) #define CAIAQ_USB_STR_LEN 0xff
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) #define MAX_STREAMS 32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) #define MODNAME "snd-usb-caiaq"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) #define EP1_CMD_GET_DEVICE_INFO 0x1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) #define EP1_CMD_READ_ERP 0x2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) #define EP1_CMD_READ_ANALOG 0x3
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) #define EP1_CMD_READ_IO 0x4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) #define EP1_CMD_WRITE_IO 0x5
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) #define EP1_CMD_MIDI_READ 0x6
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) #define EP1_CMD_MIDI_WRITE 0x7
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) #define EP1_CMD_AUDIO_PARAMS 0x9
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) #define EP1_CMD_AUTO_MSG 0xb
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) #define EP1_CMD_DIMM_LEDS 0xc
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) struct caiaq_device_spec {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) unsigned short fw_version;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) unsigned char hw_subtype;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) unsigned char num_erp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) unsigned char num_analog_in;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) unsigned char num_digital_in;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) unsigned char num_digital_out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) unsigned char num_analog_audio_out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) unsigned char num_analog_audio_in;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) unsigned char num_digital_audio_out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) unsigned char num_digital_audio_in;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) unsigned char num_midi_out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) unsigned char num_midi_in;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) unsigned char data_alignment;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) } __attribute__ ((packed));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) struct snd_usb_caiaq_cb_info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) struct snd_usb_caiaqdev {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) struct snd_usb_audio chip;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) struct urb ep1_in_urb;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) struct urb midi_out_urb;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) struct urb **data_urbs_in;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) struct urb **data_urbs_out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) struct snd_usb_caiaq_cb_info *data_cb_info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) unsigned char ep1_in_buf[EP1_BUFSIZE];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) unsigned char ep1_out_buf[EP1_BUFSIZE];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) unsigned char midi_out_buf[EP1_BUFSIZE];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) struct caiaq_device_spec spec;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) spinlock_t spinlock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) wait_queue_head_t ep1_wait_queue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) wait_queue_head_t prepare_wait_queue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) int spec_received, audio_parm_answer;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) int midi_out_active;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) char vendor_name[CAIAQ_USB_STR_LEN];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) char product_name[CAIAQ_USB_STR_LEN];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) int n_streams, n_audio_in, n_audio_out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) int streaming, first_packet, output_running;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) int audio_in_buf_pos[MAX_STREAMS];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) int audio_out_buf_pos[MAX_STREAMS];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) int period_in_count[MAX_STREAMS];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) int period_out_count[MAX_STREAMS];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) int input_panic, output_panic, warned;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) char *audio_in_buf, *audio_out_buf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) unsigned int samplerates, bpp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) unsigned long outurb_active_mask;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) struct snd_pcm_substream *sub_playback[MAX_STREAMS];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) struct snd_pcm_substream *sub_capture[MAX_STREAMS];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) /* Controls */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) unsigned char control_state[256];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) unsigned char ep8_out_buf[2];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) /* Linux input */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) #ifdef CONFIG_SND_USB_CAIAQ_INPUT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) struct input_dev *input_dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) char phys[64]; /* physical device path */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) unsigned short keycode[128];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) struct urb *ep4_in_urb;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) unsigned char ep4_in_buf[EP4_BUFSIZE];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) /* ALSA */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) struct snd_pcm *pcm;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) struct snd_pcm_hardware pcm_info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) struct snd_rawmidi *rmidi;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) struct snd_rawmidi_substream *midi_receive_substream;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) struct snd_rawmidi_substream *midi_out_substream;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) struct snd_usb_caiaq_cb_info {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) struct snd_usb_caiaqdev *cdev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) int index;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) #define caiaqdev(c) ((struct snd_usb_caiaqdev*)(c)->private_data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) #define caiaqdev_to_dev(d) (d->chip.card->dev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) int snd_usb_caiaq_set_audio_params (struct snd_usb_caiaqdev *cdev, int rate, int depth, int bbp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) int snd_usb_caiaq_set_auto_msg (struct snd_usb_caiaqdev *cdev, int digital, int analog, int erp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) int snd_usb_caiaq_send_command(struct snd_usb_caiaqdev *cdev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) unsigned char command,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) const unsigned char *buffer,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) int len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) int snd_usb_caiaq_send_command_bank(struct snd_usb_caiaqdev *cdev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) unsigned char command,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) unsigned char bank,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) const unsigned char *buffer,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) int len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) #endif /* CAIAQ_DEVICE_H */