35246cfcd91f6217c837cb778ff06a2f8317b0a1
[deliverable/linux.git] / drivers / staging / line6 / driver.h
1 /*
2 * Line6 Linux USB driver - 0.9.1beta
3 *
4 * Copyright (C) 2004-2010 Markus Grabner (grabner@icg.tugraz.at)
5 *
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.
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 #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
25 #endif
26
27 #define LINE6_TIMEOUT 1
28 #define LINE6_BUFSIZE_LISTEN 32
29 #define LINE6_MESSAGE_MAXLEN 256
30
31 /*
32 Line6 MIDI control commands
33 */
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
39
40 /*
41 MIDI channel for messages initiated by the host
42 (and eventually echoed back by the device)
43 */
44 #define LINE6_CHANNEL_HOST 0x00
45
46 /*
47 MIDI channel for messages initiated by the device
48 */
49 #define LINE6_CHANNEL_DEVICE 0x02
50
51 #define LINE6_CHANNEL_UNKNOWN 5 /* don't know yet what this is good for */
52
53 #define LINE6_CHANNEL_MASK 0x0f
54
55 #ifdef CONFIG_LINE6_USB_DEBUG
56 #define DEBUG_MESSAGES(x) (x)
57 #else
58 #define DEBUG_MESSAGES(x)
59 #endif
60
61 #define MISSING_CASE \
62 printk(KERN_ERR "line6usb driver bug: missing case in %s:%d\n", \
63 __FILE__, __LINE__)
64
65 #define CHECK_RETURN(x) \
66 do { \
67 err = x; \
68 if (err < 0) \
69 return err; \
70 } while (0)
71
72 #define CHECK_STARTUP_PROGRESS(x, n) \
73 do { \
74 if ((x) >= (n)) \
75 return; \
76 x = (n); \
77 } while (0)
78
79 extern const unsigned char line6_midi_id[3];
80
81 static const int SYSEX_DATA_OFS = sizeof(line6_midi_id) + 3;
82 static const int SYSEX_EXTRA_SIZE = sizeof(line6_midi_id) + 4;
83
84 /**
85 Common properties of Line6 devices.
86 */
87 struct line6_properties {
88 /**
89 Bit identifying this device in the line6usb driver.
90 */
91 int device_bit;
92
93 /**
94 Card id string (maximum 16 characters).
95 This can be used to address the device in ALSA programs as
96 "default:CARD=<id>"
97 */
98 const char *id;
99
100 /**
101 Card short name (maximum 32 characters).
102 */
103 const char *name;
104
105 /**
106 Bit vector defining this device's capabilities in the
107 line6usb driver.
108 */
109 int capabilities;
110 };
111
112 /**
113 Common data shared by all Line6 devices.
114 Corresponds to a pair of USB endpoints.
115 */
116 struct usb_line6 {
117 /**
118 USB device.
119 */
120 struct usb_device *usbdev;
121
122 /**
123 Product id.
124 */
125 int product;
126
127 /**
128 Properties.
129 */
130 const struct line6_properties *properties;
131
132 /**
133 Interface number.
134 */
135 int interface_number;
136
137 /**
138 Interval (ms).
139 */
140 int interval;
141
142 /**
143 Maximum size of USB packet.
144 */
145 int max_packet_size;
146
147 /**
148 Device representing the USB interface.
149 */
150 struct device *ifcdev;
151
152 /**
153 Line6 sound card data structure.
154 Each device has at least MIDI or PCM.
155 */
156 struct snd_card *card;
157
158 /**
159 Line6 PCM device data structure.
160 */
161 struct snd_line6_pcm *line6pcm;
162
163 /**
164 Line6 MIDI device data structure.
165 */
166 struct snd_line6_midi *line6midi;
167
168 /**
169 USB endpoint for listening to control commands.
170 */
171 int ep_control_read;
172
173 /**
174 USB endpoint for writing control commands.
175 */
176 int ep_control_write;
177
178 /**
179 URB for listening to PODxt Pro control endpoint.
180 */
181 struct urb *urb_listen;
182
183 /**
184 Buffer for listening to PODxt Pro control endpoint.
185 */
186 unsigned char *buffer_listen;
187
188 /**
189 Buffer for message to be processed.
190 */
191 unsigned char *buffer_message;
192
193 /**
194 Length of message to be processed.
195 */
196 int message_length;
197 };
198
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,
207 size_t datalen);
208 extern int line6_read_serial_number(struct usb_line6 *line6,
209 int *serial_number);
210 extern int line6_send_program(struct usb_line6 *line6, u8 value);
211 extern int line6_send_raw_message(struct usb_line6 *line6, const char *buffer,
212 int size);
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),
223 unsigned long data);
224 extern int line6_transmit_parameter(struct usb_line6 *line6, int param,
225 u8 value);
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,
228 size_t datalen);
229
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);
233 #endif
234
235 #endif
This page took 0.035645 seconds and 4 git commands to generate.