1
2
3
4
5
6
7
8
9
10
11
12#ifndef DRIVER_H
13#define DRIVER_H
14
15#include <linux/spinlock.h>
16#include <linux/usb.h>
17#include <sound/core.h>
18
19#include "midi.h"
20
21#define DRIVER_NAME "line6usb"
22
23#define LINE6_TIMEOUT 1
24#define LINE6_BUFSIZE_LISTEN 32
25#define LINE6_MESSAGE_MAXLEN 256
26
27
28
29
30#define LINE6_PARAM_CHANGE 0xb0
31#define LINE6_PROGRAM_CHANGE 0xc0
32#define LINE6_SYSEX_BEGIN 0xf0
33#define LINE6_SYSEX_END 0xf7
34#define LINE6_RESET 0xff
35
36
37
38
39
40#define LINE6_CHANNEL_HOST 0x00
41
42
43
44
45#define LINE6_CHANNEL_DEVICE 0x02
46
47#define LINE6_CHANNEL_UNKNOWN 5
48
49#define LINE6_CHANNEL_MASK 0x0f
50
51#define MISSING_CASE \
52 pr_err("line6usb driver bug: missing case in %s:%d\n", \
53 __FILE__, __LINE__)
54
55#define CHECK_RETURN(x) \
56do { \
57 err = x; \
58 if (err < 0) \
59 return err; \
60} while (0)
61
62#define CHECK_STARTUP_PROGRESS(x, n) \
63do { \
64 if ((x) >= (n)) \
65 return; \
66 x = (n); \
67} while (0)
68
69extern const unsigned char line6_midi_id[3];
70
71static const int SYSEX_DATA_OFS = sizeof(line6_midi_id) + 3;
72static const int SYSEX_EXTRA_SIZE = sizeof(line6_midi_id) + 4;
73
74
75
76
77struct line6_properties {
78
79
80
81 int device_bit;
82
83
84
85
86
87
88 const char *id;
89
90
91
92
93 const char *name;
94
95
96
97
98
99 int capabilities;
100};
101
102
103
104
105
106struct usb_line6 {
107
108
109
110 struct usb_device *usbdev;
111
112
113
114
115 int product;
116
117
118
119
120 const struct line6_properties *properties;
121
122
123
124
125 int interface_number;
126
127
128
129
130 int interval;
131
132
133
134
135 int max_packet_size;
136
137
138
139
140 struct device *ifcdev;
141
142
143
144
145
146 struct snd_card *card;
147
148
149
150
151 struct snd_line6_pcm *line6pcm;
152
153
154
155
156 struct snd_line6_midi *line6midi;
157
158
159
160
161 int ep_control_read;
162
163
164
165
166 int ep_control_write;
167
168
169
170
171 struct urb *urb_listen;
172
173
174
175
176 unsigned char *buffer_listen;
177
178
179
180
181 unsigned char *buffer_message;
182
183
184
185
186 int message_length;
187};
188
189extern char *line6_alloc_sysex_buffer(struct usb_line6 *line6, int code1,
190 int code2, int size);
191extern ssize_t line6_nop_read(struct device *dev,
192 struct device_attribute *attr, char *buf);
193extern ssize_t line6_nop_write(struct device *dev,
194 struct device_attribute *attr,
195 const char *buf, size_t count);
196extern int line6_read_data(struct usb_line6 *line6, int address, void *data,
197 size_t datalen);
198extern int line6_read_serial_number(struct usb_line6 *line6,
199 int *serial_number);
200extern int line6_send_program(struct usb_line6 *line6, u8 value);
201extern int line6_send_raw_message(struct usb_line6 *line6, const char *buffer,
202 int size);
203extern int line6_send_raw_message_async(struct usb_line6 *line6,
204 const char *buffer, int size);
205extern int line6_send_sysex_message(struct usb_line6 *line6,
206 const char *buffer, int size);
207extern ssize_t line6_set_raw(struct device *dev, struct device_attribute *attr,
208 const char *buf, size_t count);
209extern void line6_start_timer(struct timer_list *timer, unsigned int msecs,
210 void (*function) (unsigned long),
211 unsigned long data);
212extern int line6_transmit_parameter(struct usb_line6 *line6, int param,
213 u8 value);
214extern int line6_version_request_async(struct usb_line6 *line6);
215extern int line6_write_data(struct usb_line6 *line6, int address, void *data,
216 size_t datalen);
217
218#endif
219