device.h 3.8 KB

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