driver.h 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  1. /*
  2. * Line 6 Linux USB driver
  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 USB_INTERVALS_PER_SECOND 1000
  18. /* Fallback USB interval and max packet size values */
  19. #define LINE6_FALLBACK_INTERVAL 10
  20. #define LINE6_FALLBACK_MAXPACKETSIZE 16
  21. #define LINE6_TIMEOUT 1
  22. #define LINE6_BUFSIZE_LISTEN 32
  23. #define LINE6_MESSAGE_MAXLEN 256
  24. /*
  25. Line 6 MIDI control commands
  26. */
  27. #define LINE6_PARAM_CHANGE 0xb0
  28. #define LINE6_PROGRAM_CHANGE 0xc0
  29. #define LINE6_SYSEX_BEGIN 0xf0
  30. #define LINE6_SYSEX_END 0xf7
  31. #define LINE6_RESET 0xff
  32. /*
  33. MIDI channel for messages initiated by the host
  34. (and eventually echoed back by the device)
  35. */
  36. #define LINE6_CHANNEL_HOST 0x00
  37. /*
  38. MIDI channel for messages initiated by the device
  39. */
  40. #define LINE6_CHANNEL_DEVICE 0x02
  41. #define LINE6_CHANNEL_UNKNOWN 5 /* don't know yet what this is good for */
  42. #define LINE6_CHANNEL_MASK 0x0f
  43. #define CHECK_STARTUP_PROGRESS(x, n) \
  44. do { \
  45. if ((x) >= (n)) \
  46. return; \
  47. x = (n); \
  48. } while (0)
  49. extern const unsigned char line6_midi_id[3];
  50. static const int SYSEX_DATA_OFS = sizeof(line6_midi_id) + 3;
  51. static const int SYSEX_EXTRA_SIZE = sizeof(line6_midi_id) + 4;
  52. /*
  53. Common properties of Line 6 devices.
  54. */
  55. struct line6_properties {
  56. /* Card id string (maximum 16 characters).
  57. * This can be used to address the device in ALSA programs as
  58. * "default:CARD=<id>"
  59. */
  60. const char *id;
  61. /* Card short name (maximum 32 characters) */
  62. const char *name;
  63. /* Bit vector defining this device's capabilities in line6usb driver */
  64. int capabilities;
  65. int altsetting;
  66. unsigned ep_ctrl_r;
  67. unsigned ep_ctrl_w;
  68. unsigned ep_audio_r;
  69. unsigned ep_audio_w;
  70. };
  71. /* Capability bits */
  72. enum {
  73. /* device supports settings parameter via USB */
  74. LINE6_CAP_CONTROL = 1 << 0,
  75. /* device supports PCM input/output via USB */
  76. LINE6_CAP_PCM = 1 << 1,
  77. /* device support hardware monitoring */
  78. LINE6_CAP_HWMON = 1 << 2,
  79. };
  80. /*
  81. Common data shared by all Line 6 devices.
  82. Corresponds to a pair of USB endpoints.
  83. */
  84. struct usb_line6 {
  85. /* USB device */
  86. struct usb_device *usbdev;
  87. /* Properties */
  88. const struct line6_properties *properties;
  89. /* Interval (ms) */
  90. int interval;
  91. /* Maximum size of USB packet */
  92. int max_packet_size;
  93. /* Device representing the USB interface */
  94. struct device *ifcdev;
  95. /* Line 6 sound card data structure.
  96. * Each device has at least MIDI or PCM.
  97. */
  98. struct snd_card *card;
  99. /* Line 6 PCM device data structure */
  100. struct snd_line6_pcm *line6pcm;
  101. /* Line 6 MIDI device data structure */
  102. struct snd_line6_midi *line6midi;
  103. /* URB for listening to PODxt Pro control endpoint */
  104. struct urb *urb_listen;
  105. /* Buffer for listening to PODxt Pro control endpoint */
  106. unsigned char *buffer_listen;
  107. /* Buffer for message to be processed */
  108. unsigned char *buffer_message;
  109. /* Length of message to be processed */
  110. int message_length;
  111. void (*process_message)(struct usb_line6 *);
  112. void (*disconnect)(struct usb_line6 *line6);
  113. };
  114. extern char *line6_alloc_sysex_buffer(struct usb_line6 *line6, int code1,
  115. int code2, int size);
  116. extern int line6_read_data(struct usb_line6 *line6, unsigned address,
  117. void *data, unsigned datalen);
  118. extern int line6_read_serial_number(struct usb_line6 *line6,
  119. u32 *serial_number);
  120. extern int line6_send_raw_message_async(struct usb_line6 *line6,
  121. const char *buffer, int size);
  122. extern int line6_send_sysex_message(struct usb_line6 *line6,
  123. const char *buffer, int size);
  124. extern ssize_t line6_set_raw(struct device *dev, struct device_attribute *attr,
  125. const char *buf, size_t count);
  126. extern void line6_start_timer(struct timer_list *timer, unsigned long msecs,
  127. void (*function)(unsigned long),
  128. unsigned long data);
  129. extern int line6_version_request_async(struct usb_line6 *line6);
  130. extern int line6_write_data(struct usb_line6 *line6, unsigned address,
  131. void *data, unsigned datalen);
  132. int line6_probe(struct usb_interface *interface,
  133. const struct usb_device_id *id,
  134. const char *driver_name,
  135. const struct line6_properties *properties,
  136. int (*private_init)(struct usb_line6 *, const struct usb_device_id *id),
  137. size_t data_size);
  138. void line6_disconnect(struct usb_interface *interface);
  139. #ifdef CONFIG_PM
  140. int line6_suspend(struct usb_interface *interface, pm_message_t message);
  141. int line6_resume(struct usb_interface *interface);
  142. #endif
  143. #endif