Loading...
Note: File does not exist in v6.9.4.
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#define LINE6_TIMEOUT 1
24#define LINE6_BUFSIZE_LISTEN 32
25#define LINE6_MESSAGE_MAXLEN 256
26
27/*
28 Line6 MIDI control commands
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 MIDI channel for messages initiated by the host
38 (and eventually echoed back by the device)
39*/
40#define LINE6_CHANNEL_HOST 0x00
41
42/*
43 MIDI channel for messages initiated by the device
44*/
45#define LINE6_CHANNEL_DEVICE 0x02
46
47#define LINE6_CHANNEL_UNKNOWN 5 /* don't know yet what this is good for */
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 Common properties of Line6 devices.
76*/
77struct line6_properties {
78 /**
79 Bit identifying this device in the line6usb driver.
80 */
81 int device_bit;
82
83 /**
84 Card id string (maximum 16 characters).
85 This can be used to address the device in ALSA programs as
86 "default:CARD=<id>"
87 */
88 const char *id;
89
90 /**
91 Card short name (maximum 32 characters).
92 */
93 const char *name;
94
95 /**
96 Bit vector defining this device's capabilities in the
97 line6usb driver.
98 */
99 int capabilities;
100};
101
102/**
103 Common data shared by all Line6 devices.
104 Corresponds to a pair of USB endpoints.
105*/
106struct usb_line6 {
107 /**
108 USB device.
109 */
110 struct usb_device *usbdev;
111
112 /**
113 Product id.
114 */
115 int product;
116
117 /**
118 Properties.
119 */
120 const struct line6_properties *properties;
121
122 /**
123 Interface number.
124 */
125 int interface_number;
126
127 /**
128 Interval (ms).
129 */
130 int interval;
131
132 /**
133 Maximum size of USB packet.
134 */
135 int max_packet_size;
136
137 /**
138 Device representing the USB interface.
139 */
140 struct device *ifcdev;
141
142 /**
143 Line6 sound card data structure.
144 Each device has at least MIDI or PCM.
145 */
146 struct snd_card *card;
147
148 /**
149 Line6 PCM device data structure.
150 */
151 struct snd_line6_pcm *line6pcm;
152
153 /**
154 Line6 MIDI device data structure.
155 */
156 struct snd_line6_midi *line6midi;
157
158 /**
159 USB endpoint for listening to control commands.
160 */
161 int ep_control_read;
162
163 /**
164 USB endpoint for writing control commands.
165 */
166 int ep_control_write;
167
168 /**
169 URB for listening to PODxt Pro control endpoint.
170 */
171 struct urb *urb_listen;
172
173 /**
174 Buffer for listening to PODxt Pro control endpoint.
175 */
176 unsigned char *buffer_listen;
177
178 /**
179 Buffer for message to be processed.
180 */
181 unsigned char *buffer_message;
182
183 /**
184 Length of message to be processed.
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 int line6_read_data(struct usb_line6 *line6, int address, void *data,
194 size_t datalen);
195extern int line6_read_serial_number(struct usb_line6 *line6,
196 int *serial_number);
197extern int line6_send_program(struct usb_line6 *line6, u8 value);
198extern int line6_send_raw_message(struct usb_line6 *line6, const char *buffer,
199 int size);
200extern int line6_send_raw_message_async(struct usb_line6 *line6,
201 const char *buffer, int size);
202extern int line6_send_sysex_message(struct usb_line6 *line6,
203 const char *buffer, int size);
204extern ssize_t line6_set_raw(struct device *dev, struct device_attribute *attr,
205 const char *buf, size_t count);
206extern void line6_start_timer(struct timer_list *timer, unsigned int msecs,
207 void (*function)(unsigned long),
208 unsigned long data);
209extern int line6_transmit_parameter(struct usb_line6 *line6, int param,
210 u8 value);
211extern int line6_version_request_async(struct usb_line6 *line6);
212extern int line6_write_data(struct usb_line6 *line6, int address, void *data,
213 size_t datalen);
214
215#endif