2 * Line 6 Linux USB driver
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 USB_INTERVALS_PER_SECOND 1000
23 /* Fallback USB interval and max packet size values */
24 #define LINE6_FALLBACK_INTERVAL 10
25 #define LINE6_FALLBACK_MAXPACKETSIZE 16
27 #define LINE6_TIMEOUT 1
28 #define LINE6_BUFSIZE_LISTEN 32
29 #define LINE6_MESSAGE_MAXLEN 256
32 Line 6 MIDI control commands
34 #define LINE6_PARAM_CHANGE 0xb0
35 #define LINE6_PROGRAM_CHANGE 0xc0
36 #define LINE6_SYSEX_BEGIN 0xf0
37 #define LINE6_SYSEX_END 0xf7
38 #define LINE6_RESET 0xff
41 MIDI channel for messages initiated by the host
42 (and eventually echoed back by the device)
44 #define LINE6_CHANNEL_HOST 0x00
47 MIDI channel for messages initiated by the device
49 #define LINE6_CHANNEL_DEVICE 0x02
51 #define LINE6_CHANNEL_UNKNOWN 5 /* don't know yet what this is good for */
53 #define LINE6_CHANNEL_MASK 0x0f
55 #define CHECK_STARTUP_PROGRESS(x, n) \
62 extern const unsigned char line6_midi_id
[3];
64 static const int SYSEX_DATA_OFS
= sizeof(line6_midi_id
) + 3;
65 static const int SYSEX_EXTRA_SIZE
= sizeof(line6_midi_id
) + 4;
68 Common properties of Line 6 devices.
70 struct line6_properties
{
71 /* Card id string (maximum 16 characters).
72 * This can be used to address the device in ALSA programs as
77 /* Card short name (maximum 32 characters) */
80 /* Bit vector defining this device's capabilities in line6usb driver */
93 /* device supports settings parameter via USB */
94 LINE6_CAP_CONTROL
= 1 << 0,
95 /* device supports PCM input/output via USB */
96 LINE6_CAP_PCM
= 1 << 1,
97 /* device support hardware monitoring */
98 LINE6_CAP_HWMON
= 1 << 2,
102 Common data shared by all Line 6 devices.
103 Corresponds to a pair of USB endpoints.
107 struct usb_device
*usbdev
;
110 const struct line6_properties
*properties
;
115 /* Maximum size of USB packet */
118 /* Device representing the USB interface */
119 struct device
*ifcdev
;
121 /* Line 6 sound card data structure.
122 * Each device has at least MIDI or PCM.
124 struct snd_card
*card
;
126 /* Line 6 PCM device data structure */
127 struct snd_line6_pcm
*line6pcm
;
129 /* Line 6 MIDI device data structure */
130 struct snd_line6_midi
*line6midi
;
132 /* URB for listening to PODxt Pro control endpoint */
133 struct urb
*urb_listen
;
135 /* Buffer for listening to PODxt Pro control endpoint */
136 unsigned char *buffer_listen
;
138 /* Buffer for message to be processed */
139 unsigned char *buffer_message
;
141 /* Length of message to be processed */
144 void (*process_message
)(struct usb_line6
*);
145 void (*disconnect
)(struct usb_line6
*line6
);
148 extern char *line6_alloc_sysex_buffer(struct usb_line6
*line6
, int code1
,
149 int code2
, int size
);
150 extern int line6_read_data(struct usb_line6
*line6
, unsigned address
,
151 void *data
, unsigned datalen
);
152 extern int line6_read_serial_number(struct usb_line6
*line6
,
154 extern int line6_send_raw_message_async(struct usb_line6
*line6
,
155 const char *buffer
, int size
);
156 extern int line6_send_sysex_message(struct usb_line6
*line6
,
157 const char *buffer
, int size
);
158 extern ssize_t
line6_set_raw(struct device
*dev
, struct device_attribute
*attr
,
159 const char *buf
, size_t count
);
160 extern void line6_start_timer(struct timer_list
*timer
, unsigned long msecs
,
161 void (*function
)(unsigned long),
163 extern int line6_version_request_async(struct usb_line6
*line6
);
164 extern int line6_write_data(struct usb_line6
*line6
, unsigned address
,
165 void *data
, unsigned datalen
);
167 int line6_probe(struct usb_interface
*interface
,
168 const struct usb_device_id
*id
,
169 const char *driver_name
,
170 const struct line6_properties
*properties
,
171 int (*private_init
)(struct usb_line6
*, const struct usb_device_id
*id
),
174 void line6_disconnect(struct usb_interface
*interface
);
177 int line6_suspend(struct usb_interface
*interface
, pm_message_t message
);
178 int line6_resume(struct usb_interface
*interface
);