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