staging: line6: sync with upstream
[deliverable/linux.git] / drivers / staging / line6 / driver.h
CommitLineData
705ececd 1/*
1027f476 2 * Line6 Linux USB driver - 0.9.0
705ececd 3 *
1027f476 4 * Copyright (C) 2004-2010 Markus Grabner (grabner@icg.tugraz.at)
705ececd
MG
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
705ececd
MG
16#include <linux/spinlock.h>
17#include <linux/usb.h>
705ececd
MG
18#include <sound/core.h>
19
20#include "midi.h"
21
1027f476 22
705ececd
MG
23#define DRIVER_NAME "line6usb"
24
1027f476
MG
25#if defined(CONFIG_LINE6_USB_DUMP_CTRL) || defined(CONFIG_LINE6_USB_DUMP_MIDI) || defined(CONFIG_LINE6_USB_DUMP_PCM)
26#define CONFIG_LINE6_USB_DUMP_ANY
27#endif
28
705ececd
MG
29#define LINE6_TIMEOUT 1
30#define LINE6_MAX_DEVICES 8
31#define LINE6_BUFSIZE_LISTEN 32
32#define LINE6_MESSAGE_MAXLEN 256
33
705ececd
MG
34/*
35 Line6 MIDI control commands
36*/
37#define LINE6_PARAM_CHANGE 0xb0
38#define LINE6_PROGRAM_CHANGE 0xc0
39#define LINE6_SYSEX_BEGIN 0xf0
40#define LINE6_SYSEX_END 0xf7
41#define LINE6_RESET 0xff
42
43/*
44 MIDI channel for messages initiated by the host
45 (and eventually echoed back by the device)
46*/
47#define LINE6_CHANNEL_HOST 0x00
48
49/*
50 MIDI channel for messages initiated by the device
51*/
52#define LINE6_CHANNEL_DEVICE 0x02
53
54#define LINE6_CHANNEL_UNKNOWN 5 /* don't know yet what this is good for */
55
56#define LINE6_CHANNEL_MASK 0x0f
57
1027f476
MG
58#ifdef CONFIG_LINE6_USB_DEBUG
59#define DEBUG_MESSAGES(x) (x)
60#else
61#define DEBUG_MESSAGES(x)
62#endif
63
705ececd 64
a49e4838
GKH
65#define MISSING_CASE \
66 printk(KERN_ERR "line6usb driver bug: missing case in %s:%d\n", \
67 __FILE__, __LINE__)
705ececd
MG
68
69
a49e4838
GKH
70#define CHECK_RETURN(x) \
71do { \
72 err = x; \
73 if (err < 0) \
74 return err; \
75} while (0)
705ececd 76
1027f476
MG
77#define CHECK_STARTUP_PROGRESS(x, n) \
78 if((x) >= (n)) \
79 return; \
80 x = (n);
81
705ececd
MG
82
83extern const unsigned char line6_midi_id[3];
84extern struct usb_line6 *line6_devices[LINE6_MAX_DEVICES];
705ececd
MG
85
86static const int SYSEX_DATA_OFS = sizeof(line6_midi_id) + 3;
87static const int SYSEX_EXTRA_SIZE = sizeof(line6_midi_id) + 4;
88
89
90/**
91 Common properties of Line6 devices.
92*/
93struct line6_properties {
1027f476
MG
94 /**
95 Card id string (maximum 16 characters).
96 This can be used to address the device in ALSA programs as
97 "default:CARD=<id>"
98 */
99 const char *id;
100
101 /**
102 Card short name (maximum 32 characters).
103 */
705ececd 104 const char *name;
1027f476
MG
105
106 /**
107 Bit identifying this device in the line6usb driver.
108 */
705ececd 109 int device_bit;
1027f476
MG
110
111 /**
112 Bit vector defining this device's capabilities in the
113 line6usb driver.
114 */
705ececd
MG
115 int capabilities;
116};
117
118/**
119 Common data shared by all Line6 devices.
120 Corresponds to a pair of USB endpoints.
121*/
122struct usb_line6 {
123 /**
124 USB device.
125 */
126 struct usb_device *usbdev;
127
128 /**
129 Product id.
130 */
131 int product;
132
133 /**
134 Properties.
135 */
136 const struct line6_properties *properties;
137
138 /**
139 Interface number.
140 */
141 int interface_number;
142
143 /**
144 Interval (ms).
145 */
146 int interval;
147
148 /**
149 Maximum size of USB packet.
150 */
151 int max_packet_size;
152
153 /**
154 Device representing the USB interface.
155 */
156 struct device *ifcdev;
157
158 /**
159 Line6 sound card data structure.
160 Each device has at least MIDI or PCM.
161 */
162 struct snd_card *card;
163
164 /**
165 Line6 PCM device data structure.
166 */
167 struct snd_line6_pcm *line6pcm;
168
169 /**
170 Line6 MIDI device data structure.
171 */
172 struct snd_line6_midi *line6midi;
173
174 /**
175 USB endpoint for listening to control commands.
176 */
177 int ep_control_read;
178
179 /**
180 USB endpoint for writing control commands.
181 */
182 int ep_control_write;
183
184 /**
185 URB for listening to PODxt Pro control endpoint.
186 */
187 struct urb *urb_listen;
188
189 /**
190 Buffer for listening to PODxt Pro control endpoint.
191 */
192 unsigned char *buffer_listen;
193
194 /**
195 Buffer for message to be processed.
196 */
197 unsigned char *buffer_message;
198
199 /**
200 Length of message to be processed.
201 */
202 int message_length;
203};
204
205
a49e4838
GKH
206extern char *line6_alloc_sysex_buffer(struct usb_line6 *line6, int code1,
207 int code2, int size);
208extern ssize_t line6_nop_read(struct device *dev,
209 struct device_attribute *attr, char *buf);
210extern ssize_t line6_nop_write(struct device *dev,
211 struct device_attribute *attr,
212 const char *buf, size_t count);
213extern int line6_read_data(struct usb_line6 *line6, int address, void *data,
214 size_t datalen);
215extern int line6_read_serial_number(struct usb_line6 *line6,
216 int *serial_number);
705ececd 217extern int line6_send_program(struct usb_line6 *line6, int value);
a49e4838
GKH
218extern int line6_send_raw_message(struct usb_line6 *line6, const char *buffer,
219 int size);
220extern int line6_send_raw_message_async(struct usb_line6 *line6,
221 const char *buffer, int size);
222extern int line6_send_sysex_message(struct usb_line6 *line6,
223 const char *buffer, int size);
1027f476
MG
224extern int line6_send_sysex_message_async(struct usb_line6 *line6,
225 const char *buffer, int size);
a49e4838
GKH
226extern ssize_t line6_set_raw(struct device *dev, struct device_attribute *attr,
227 const char *buf, size_t count);
1027f476
MG
228extern void line6_start_timer(struct timer_list *timer, unsigned int msecs,
229 void (*function)(unsigned long), unsigned long data);
a49e4838
GKH
230extern int line6_transmit_parameter(struct usb_line6 *line6, int param,
231 int value);
1027f476 232extern int line6_version_request_async(struct usb_line6 *line6);
a49e4838
GKH
233extern int line6_write_data(struct usb_line6 *line6, int address, void *data,
234 size_t datalen);
1027f476
MG
235
236#ifdef CONFIG_LINE6_USB_DUMP_ANY
a49e4838
GKH
237extern void line6_write_hexdump(struct usb_line6 *line6, char dir,
238 const unsigned char *buffer, int size);
1027f476 239#endif
705ececd
MG
240
241
242#endif
This page took 0.203178 seconds and 5 git commands to generate.