driver.h 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215
  1. /*
  2. * Line6 Linux USB driver - 0.9.1beta
  3. *
  4. * Copyright (C) 2004-2010 Markus Grabner (grabner@icg.tugraz.at)
  5. *
  6. * This program is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU General Public License as
  8. * published by the Free Software Foundation, version 2.
  9. *
  10. */
  11. #ifndef DRIVER_H
  12. #define DRIVER_H
  13. #include <linux/spinlock.h>
  14. #include <linux/usb.h>
  15. #include <sound/core.h>
  16. #include "midi.h"
  17. #define DRIVER_NAME "line6usb"
  18. #define LINE6_TIMEOUT 1
  19. #define LINE6_BUFSIZE_LISTEN 32
  20. #define LINE6_MESSAGE_MAXLEN 256
  21. /*
  22. Line6 MIDI control commands
  23. */
  24. #define LINE6_PARAM_CHANGE 0xb0
  25. #define LINE6_PROGRAM_CHANGE 0xc0
  26. #define LINE6_SYSEX_BEGIN 0xf0
  27. #define LINE6_SYSEX_END 0xf7
  28. #define LINE6_RESET 0xff
  29. /*
  30. MIDI channel for messages initiated by the host
  31. (and eventually echoed back by the device)
  32. */
  33. #define LINE6_CHANNEL_HOST 0x00
  34. /*
  35. MIDI channel for messages initiated by the device
  36. */
  37. #define LINE6_CHANNEL_DEVICE 0x02
  38. #define LINE6_CHANNEL_UNKNOWN 5 /* don't know yet what this is good for */
  39. #define LINE6_CHANNEL_MASK 0x0f
  40. #define MISSING_CASE \
  41. pr_err("line6usb driver bug: missing case in %s:%d\n", \
  42. __FILE__, __LINE__)
  43. #define CHECK_RETURN(x) \
  44. do { \
  45. err = x; \
  46. if (err < 0) \
  47. return err; \
  48. } while (0)
  49. #define CHECK_STARTUP_PROGRESS(x, n) \
  50. do { \
  51. if ((x) >= (n)) \
  52. return; \
  53. x = (n); \
  54. } while (0)
  55. extern const unsigned char line6_midi_id[3];
  56. static const int SYSEX_DATA_OFS = sizeof(line6_midi_id) + 3;
  57. static const int SYSEX_EXTRA_SIZE = sizeof(line6_midi_id) + 4;
  58. /**
  59. Common properties of Line6 devices.
  60. */
  61. struct line6_properties {
  62. /**
  63. Bit identifying this device in the line6usb driver.
  64. */
  65. int device_bit;
  66. /**
  67. Card id string (maximum 16 characters).
  68. This can be used to address the device in ALSA programs as
  69. "default:CARD=<id>"
  70. */
  71. const char *id;
  72. /**
  73. Card short name (maximum 32 characters).
  74. */
  75. const char *name;
  76. /**
  77. Bit vector defining this device's capabilities in the
  78. line6usb driver.
  79. */
  80. int capabilities;
  81. };
  82. /**
  83. Common data shared by all Line6 devices.
  84. Corresponds to a pair of USB endpoints.
  85. */
  86. struct usb_line6 {
  87. /**
  88. USB device.
  89. */
  90. struct usb_device *usbdev;
  91. /**
  92. Product id.
  93. */
  94. int product;
  95. /**
  96. Properties.
  97. */
  98. const struct line6_properties *properties;
  99. /**
  100. Interface number.
  101. */
  102. int interface_number;
  103. /**
  104. Interval (ms).
  105. */
  106. int interval;
  107. /**
  108. Maximum size of USB packet.
  109. */
  110. int max_packet_size;
  111. /**
  112. Device representing the USB interface.
  113. */
  114. struct device *ifcdev;
  115. /**
  116. Line6 sound card data structure.
  117. Each device has at least MIDI or PCM.
  118. */
  119. struct snd_card *card;
  120. /**
  121. Line6 PCM device data structure.
  122. */
  123. struct snd_line6_pcm *line6pcm;
  124. /**
  125. Line6 MIDI device data structure.
  126. */
  127. struct snd_line6_midi *line6midi;
  128. /**
  129. USB endpoint for listening to control commands.
  130. */
  131. int ep_control_read;
  132. /**
  133. USB endpoint for writing control commands.
  134. */
  135. int ep_control_write;
  136. /**
  137. URB for listening to PODxt Pro control endpoint.
  138. */
  139. struct urb *urb_listen;
  140. /**
  141. Buffer for listening to PODxt Pro control endpoint.
  142. */
  143. unsigned char *buffer_listen;
  144. /**
  145. Buffer for message to be processed.
  146. */
  147. unsigned char *buffer_message;
  148. /**
  149. Length of message to be processed.
  150. */
  151. int message_length;
  152. };
  153. extern char *line6_alloc_sysex_buffer(struct usb_line6 *line6, int code1,
  154. int code2, int size);
  155. extern ssize_t line6_nop_read(struct device *dev,
  156. struct device_attribute *attr, char *buf);
  157. extern int line6_read_data(struct usb_line6 *line6, int address, void *data,
  158. size_t datalen);
  159. extern int line6_read_serial_number(struct usb_line6 *line6,
  160. int *serial_number);
  161. extern int line6_send_program(struct usb_line6 *line6, u8 value);
  162. extern int line6_send_raw_message(struct usb_line6 *line6, const char *buffer,
  163. int size);
  164. extern int line6_send_raw_message_async(struct usb_line6 *line6,
  165. const char *buffer, int size);
  166. extern int line6_send_sysex_message(struct usb_line6 *line6,
  167. const char *buffer, int size);
  168. extern ssize_t line6_set_raw(struct device *dev, struct device_attribute *attr,
  169. const char *buf, size_t count);
  170. extern void line6_start_timer(struct timer_list *timer, unsigned int msecs,
  171. void (*function)(unsigned long),
  172. unsigned long data);
  173. extern int line6_transmit_parameter(struct usb_line6 *line6, int param,
  174. u8 value);
  175. extern int line6_version_request_async(struct usb_line6 *line6);
  176. extern int line6_write_data(struct usb_line6 *line6, int address, void *data,
  177. size_t datalen);
  178. #endif