2 * Line6 Linux USB driver - 0.9.1beta
4 * Copyright (C) 2004-2010 Markus Grabner (grabner@icg.tugraz.at)
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.
15 #include <linux/spinlock.h>
16 #include <linux/usb.h>
17 #include <sound/core.h>
21 #define DRIVER_NAME "line6usb"
23 #if defined(CONFIG_LINE6_USB_DUMP_CTRL) || defined(CONFIG_LINE6_USB_DUMP_MIDI) || defined(CONFIG_LINE6_USB_DUMP_PCM)
24 #define CONFIG_LINE6_USB_DUMP_ANY
27 #define LINE6_TIMEOUT 1
28 #define LINE6_MAX_DEVICES 8
29 #define LINE6_BUFSIZE_LISTEN 32
30 #define LINE6_MESSAGE_MAXLEN 256
33 Line6 MIDI control commands
35 #define LINE6_PARAM_CHANGE 0xb0
36 #define LINE6_PROGRAM_CHANGE 0xc0
37 #define LINE6_SYSEX_BEGIN 0xf0
38 #define LINE6_SYSEX_END 0xf7
39 #define LINE6_RESET 0xff
42 MIDI channel for messages initiated by the host
43 (and eventually echoed back by the device)
45 #define LINE6_CHANNEL_HOST 0x00
48 MIDI channel for messages initiated by the device
50 #define LINE6_CHANNEL_DEVICE 0x02
52 #define LINE6_CHANNEL_UNKNOWN 5 /* don't know yet what this is good for */
54 #define LINE6_CHANNEL_MASK 0x0f
56 #ifdef CONFIG_LINE6_USB_DEBUG
57 #define DEBUG_MESSAGES(x) (x)
59 #define DEBUG_MESSAGES(x)
62 #define MISSING_CASE \
63 printk(KERN_ERR "line6usb driver bug: missing case in %s:%d\n", \
66 #define CHECK_RETURN(x) \
73 #define CHECK_STARTUP_PROGRESS(x, n) \
78 extern const unsigned char line6_midi_id[3];
79 extern struct usb_line6 *line6_devices[LINE6_MAX_DEVICES];
81 static const int SYSEX_DATA_OFS = sizeof(line6_midi_id) + 3;
82 static const int SYSEX_EXTRA_SIZE = sizeof(line6_midi_id) + 4;
85 Common properties of Line6 devices.
87 struct line6_properties {
89 Card id string (maximum 16 characters).
90 This can be used to address the device in ALSA programs as
96 Card short name (maximum 32 characters).
101 Bit identifying this device in the line6usb driver.
106 Bit vector defining this device's capabilities in the
113 Common data shared by all Line6 devices.
114 Corresponds to a pair of USB endpoints.
120 struct usb_device *usbdev;
130 const struct line6_properties *properties;
135 int interface_number;
143 Maximum size of USB packet.
148 Device representing the USB interface.
150 struct device *ifcdev;
153 Line6 sound card data structure.
154 Each device has at least MIDI or PCM.
156 struct snd_card *card;
159 Line6 PCM device data structure.
161 struct snd_line6_pcm *line6pcm;
164 Line6 MIDI device data structure.
166 struct snd_line6_midi *line6midi;
169 USB endpoint for listening to control commands.
174 USB endpoint for writing control commands.
176 int ep_control_write;
179 URB for listening to PODxt Pro control endpoint.
181 struct urb *urb_listen;
184 Buffer for listening to PODxt Pro control endpoint.
186 unsigned char *buffer_listen;
189 Buffer for message to be processed.
191 unsigned char *buffer_message;
194 Length of message to be processed.
199 extern char *line6_alloc_sysex_buffer(struct usb_line6 *line6, int code1,
200 int code2, int size);
201 extern ssize_t line6_nop_read(struct device *dev,
202 struct device_attribute *attr, char *buf);
203 extern ssize_t line6_nop_write(struct device *dev,
204 struct device_attribute *attr,
205 const char *buf, size_t count);
206 extern int line6_read_data(struct usb_line6 *line6, int address, void *data,
208 extern int line6_read_serial_number(struct usb_line6 *line6,
210 extern int line6_send_program(struct usb_line6 *line6, int value);
211 extern int line6_send_raw_message(struct usb_line6 *line6, const char *buffer,
213 extern int line6_send_raw_message_async(struct usb_line6 *line6,
214 const char *buffer, int size);
215 extern int line6_send_sysex_message(struct usb_line6 *line6,
216 const char *buffer, int size);
217 extern int line6_send_sysex_message_async(struct usb_line6 *line6,
218 const char *buffer, int size);
219 extern ssize_t line6_set_raw(struct device *dev, struct device_attribute *attr,
220 const char *buf, size_t count);
221 extern void line6_start_timer(struct timer_list *timer, unsigned int msecs,
222 void (*function) (unsigned long),
224 extern int line6_transmit_parameter(struct usb_line6 *line6, int param,
226 extern int line6_version_request_async(struct usb_line6 *line6);
227 extern int line6_write_data(struct usb_line6 *line6, int address, void *data,
230 #ifdef CONFIG_LINE6_USB_DUMP_ANY
231 extern void line6_write_hexdump(struct usb_line6 *line6, char dir,
232 const unsigned char *buffer, int size);