driver.h 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  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 DRIVER_NAME "line6usb"
  18. #define LINE6_TIMEOUT 1
  19. #define LINE6_BUFSIZE_LISTEN 32
  20. #define LINE6_MESSAGE_MAXLEN 256
  21. /*
  22. Line 6 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 CHECK_STARTUP_PROGRESS(x, n) \
  41. do { \
  42. if ((x) >= (n)) \
  43. return; \
  44. x = (n); \
  45. } while (0)
  46. extern const unsigned char line6_midi_id[3];
  47. static const int SYSEX_DATA_OFS = sizeof(line6_midi_id) + 3;
  48. static const int SYSEX_EXTRA_SIZE = sizeof(line6_midi_id) + 4;
  49. /*
  50. Common properties of Line 6 devices.
  51. */
  52. struct line6_properties {
  53. /* Card id string (maximum 16 characters).
  54. * This can be used to address the device in ALSA programs as
  55. * "default:CARD=<id>"
  56. */
  57. const char *id;
  58. /* Card short name (maximum 32 characters) */
  59. const char *name;
  60. /* Bit vector defining this device's capabilities in line6usb driver */
  61. int capabilities;
  62. int altsetting;
  63. unsigned ep_ctrl_r;
  64. unsigned ep_ctrl_w;
  65. unsigned ep_audio_r;
  66. unsigned ep_audio_w;
  67. };
  68. /*
  69. Common data shared by all Line 6 devices.
  70. Corresponds to a pair of USB endpoints.
  71. */
  72. struct usb_line6 {
  73. /* USB device */
  74. struct usb_device *usbdev;
  75. /* Properties */
  76. const struct line6_properties *properties;
  77. /* Interval (ms) */
  78. int interval;
  79. /* Maximum size of USB packet */
  80. int max_packet_size;
  81. /* Device representing the USB interface */
  82. struct device *ifcdev;
  83. /* Line 6 sound card data structure.
  84. * Each device has at least MIDI or PCM.
  85. */
  86. struct snd_card *card;
  87. /* Line 6 PCM device data structure */
  88. struct snd_line6_pcm *line6pcm;
  89. /* Line 6 MIDI device data structure */
  90. struct snd_line6_midi *line6midi;
  91. /* URB for listening to PODxt Pro control endpoint */
  92. struct urb *urb_listen;
  93. /* Buffer for listening to PODxt Pro control endpoint */
  94. unsigned char *buffer_listen;
  95. /* Buffer for message to be processed */
  96. unsigned char *buffer_message;
  97. /* Length of message to be processed */
  98. int message_length;
  99. void (*process_message)(struct usb_line6 *);
  100. void (*disconnect)(struct usb_line6 *line6);
  101. };
  102. extern char *line6_alloc_sysex_buffer(struct usb_line6 *line6, int code1,
  103. int code2, int size);
  104. extern int line6_read_data(struct usb_line6 *line6, int address, void *data,
  105. size_t datalen);
  106. extern int line6_read_serial_number(struct usb_line6 *line6,
  107. int *serial_number);
  108. extern int line6_send_raw_message_async(struct usb_line6 *line6,
  109. const char *buffer, int size);
  110. extern int line6_send_sysex_message(struct usb_line6 *line6,
  111. const char *buffer, int size);
  112. extern ssize_t line6_set_raw(struct device *dev, struct device_attribute *attr,
  113. const char *buf, size_t count);
  114. extern void line6_start_timer(struct timer_list *timer, unsigned int msecs,
  115. void (*function)(unsigned long),
  116. unsigned long data);
  117. extern int line6_version_request_async(struct usb_line6 *line6);
  118. extern int line6_write_data(struct usb_line6 *line6, int address, void *data,
  119. size_t datalen);
  120. int line6_probe(struct usb_interface *interface,
  121. const struct usb_device_id *id,
  122. const struct line6_properties *properties,
  123. int (*private_init)(struct usb_line6 *, const struct usb_device_id *id),
  124. size_t data_size);
  125. void line6_disconnect(struct usb_interface *interface);
  126. #ifdef CONFIG_PM
  127. int line6_suspend(struct usb_interface *interface, pm_message_t message);
  128. int line6_resume(struct usb_interface *interface);
  129. #endif
  130. #endif