1
2
3
4
5
6
7
8 #ifndef DRIVER_H
9 #define DRIVER_H
10
11 #include <linux/usb.h>
12 #include <linux/mutex.h>
13 #include <linux/kfifo.h>
14 #include <sound/core.h>
15
16 #include "midi.h"
17
18
19 #define USB_LOW_INTERVALS_PER_SECOND 1000
20 #define USB_LOW_ISO_BUFFERS 2
21
22
23 #define USB_HIGH_INTERVALS_PER_SECOND 8000
24 #define USB_HIGH_ISO_BUFFERS 16
25
26
27 #define LINE6_FALLBACK_INTERVAL 10
28 #define LINE6_FALLBACK_MAXPACKETSIZE 16
29
30 #define LINE6_TIMEOUT 1
31 #define LINE6_BUFSIZE_LISTEN 64
32 #define LINE6_MIDI_MESSAGE_MAXLEN 256
33
34 #define LINE6_RAW_MESSAGES_MAXCOUNT_ORDER 7
35
36 #define LINE6_RAW_MESSAGES_MAXCOUNT (1 << LINE6_RAW_MESSAGES_MAXCOUNT_ORDER)
37
38
39 #if LINE6_BUFSIZE_LISTEN > 65535
40 #error "Use dynamic fifo instead"
41 #endif
42
43
44
45
46 #define LINE6_PARAM_CHANGE 0xb0
47 #define LINE6_PROGRAM_CHANGE 0xc0
48 #define LINE6_SYSEX_BEGIN 0xf0
49 #define LINE6_SYSEX_END 0xf7
50 #define LINE6_RESET 0xff
51
52
53
54
55
56 #define LINE6_CHANNEL_HOST 0x00
57
58
59
60
61 #define LINE6_CHANNEL_DEVICE 0x02
62
63 #define LINE6_CHANNEL_UNKNOWN 5
64
65 #define LINE6_CHANNEL_MASK 0x0f
66
67 extern const unsigned char line6_midi_id[3];
68
69 static const int SYSEX_DATA_OFS = sizeof(line6_midi_id) + 3;
70 static const int SYSEX_EXTRA_SIZE = sizeof(line6_midi_id) + 4;
71
72
73
74
75 struct line6_properties {
76
77
78
79
80 const char *id;
81
82
83 const char *name;
84
85
86 int capabilities;
87
88 int altsetting;
89
90 unsigned int ctrl_if;
91 unsigned int ep_ctrl_r;
92 unsigned int ep_ctrl_w;
93 unsigned int ep_audio_r;
94 unsigned int ep_audio_w;
95 };
96
97
98 enum {
99
100 LINE6_CAP_CONTROL = 1 << 0,
101
102 LINE6_CAP_PCM = 1 << 1,
103
104 LINE6_CAP_HWMON = 1 << 2,
105
106 LINE6_CAP_IN_NEEDS_OUT = 1 << 3,
107
108 LINE6_CAP_CONTROL_MIDI = 1 << 4,
109
110 LINE6_CAP_CONTROL_INFO = 1 << 5,
111 };
112
113
114
115
116
117 struct usb_line6 {
118
119 struct usb_device *usbdev;
120
121
122 const struct line6_properties *properties;
123
124
125 int interval;
126
127 int intervals_per_second;
128
129
130 int iso_buffers;
131
132
133 int max_packet_size;
134
135
136 struct device *ifcdev;
137
138
139
140
141 struct snd_card *card;
142
143
144 struct snd_line6_pcm *line6pcm;
145
146
147 struct snd_line6_midi *line6midi;
148
149
150 struct urb *urb_listen;
151
152
153 unsigned char *buffer_listen;
154
155
156 unsigned char *buffer_message;
157
158
159 int message_length;
160
161
162 struct {
163 struct mutex read_lock;
164 wait_queue_head_t wait_queue;
165 unsigned int active:1;
166 STRUCT_KFIFO_REC_2(LINE6_BUFSIZE_LISTEN * LINE6_RAW_MESSAGES_MAXCOUNT)
167 fifo;
168 } messages;
169
170
171 struct delayed_work startup_work;
172
173
174
175
176 void (*process_message)(struct usb_line6 *);
177 void (*disconnect)(struct usb_line6 *line6);
178 void (*startup)(struct usb_line6 *line6);
179 };
180
181 extern char *line6_alloc_sysex_buffer(struct usb_line6 *line6, int code1,
182 int code2, int size);
183 extern int line6_read_data(struct usb_line6 *line6, unsigned address,
184 void *data, unsigned datalen);
185 extern int line6_read_serial_number(struct usb_line6 *line6,
186 u32 *serial_number);
187 extern int line6_send_raw_message_async(struct usb_line6 *line6,
188 const char *buffer, int size);
189 extern int line6_send_sysex_message(struct usb_line6 *line6,
190 const char *buffer, int size);
191 extern ssize_t line6_set_raw(struct device *dev, struct device_attribute *attr,
192 const char *buf, size_t count);
193 extern int line6_version_request_async(struct usb_line6 *line6);
194 extern int line6_write_data(struct usb_line6 *line6, unsigned address,
195 void *data, unsigned datalen);
196
197 int line6_probe(struct usb_interface *interface,
198 const struct usb_device_id *id,
199 const char *driver_name,
200 const struct line6_properties *properties,
201 int (*private_init)(struct usb_line6 *, const struct usb_device_id *id),
202 size_t data_size);
203
204 void line6_disconnect(struct usb_interface *interface);
205
206 #ifdef CONFIG_PM
207 int line6_suspend(struct usb_interface *interface, pm_message_t message);
208 int line6_resume(struct usb_interface *interface);
209 #endif
210
211 #endif