device.h 3.9 KB

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