/drivers/staging/line6/driver.h

https://bitbucket.org/slukk/jb-tsm-kernel-4.2 · C Header · 237 lines · 106 code · 40 blank · 91 comment · 6 complexity · 239bb52ab5b430d7b2498b72c20a2d29 MD5 · raw file

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