Staging: line6: remove KERNEL_VERSION checks
[firefly-linux-kernel-4.4.55.git] / drivers / staging / line6 / driver.h
1 /*
2  * Line6 Linux USB driver - 0.8.0
3  *
4  * Copyright (C) 2004-2009 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
16 #include "config.h"
17
18 #include <linux/spinlock.h>
19 #include <linux/usb.h>
20 #include <linux/wait.h>
21 #include <sound/core.h>
22
23 #include "midi.h"
24
25 #define DRIVER_NAME "line6usb"
26
27 #define LINE6_TIMEOUT 1
28 #define LINE6_MAX_DEVICES 8
29 #define LINE6_BUFSIZE_LISTEN 32
30 #define LINE6_MESSAGE_MAXLEN 256
31
32
33 /*
34         Line6 MIDI control commands
35 */
36 #define LINE6_PARAM_CHANGE   0xb0
37 #define LINE6_PROGRAM_CHANGE 0xc0
38 #define LINE6_SYSEX_BEGIN    0xf0
39 #define LINE6_SYSEX_END      0xf7
40 #define LINE6_RESET          0xff
41
42 /*
43         MIDI channel for messages initiated by the host
44         (and eventually echoed back by the device)
45 */
46 #define LINE6_CHANNEL_HOST   0x00
47
48 /*
49         MIDI channel for messages initiated by the device
50 */
51 #define LINE6_CHANNEL_DEVICE 0x02
52
53 #define LINE6_CHANNEL_UNKNOWN 5  /* don't know yet what this is good for */
54
55 #define LINE6_CHANNEL_MASK 0x0f
56
57
58 #define MISSING_CASE printk("line6usb driver bug: missing case in %s:%d\n", __FILE__, __LINE__)
59
60
61 #define CHECK_RETURN(x) if((err = x) < 0) return err
62
63
64 extern const unsigned char line6_midi_id[3];
65 extern struct usb_line6 *line6_devices[LINE6_MAX_DEVICES];
66 extern struct workqueue_struct *line6_workqueue;
67
68 static const int SYSEX_DATA_OFS = sizeof(line6_midi_id) + 3;
69 static const int SYSEX_EXTRA_SIZE = sizeof(line6_midi_id) + 4;
70
71
72 /**
73          Common properties of Line6 devices.
74 */
75 struct line6_properties {
76         const char *name;
77         int device_bit;
78         int capabilities;
79 };
80
81 /**
82          Common data shared by all Line6 devices.
83          Corresponds to a pair of USB endpoints.
84 */
85 struct usb_line6 {
86         /**
87                  USB device.
88         */
89         struct usb_device *usbdev;
90
91         /**
92                  Product id.
93         */
94         int product;
95
96         /**
97                  Properties.
98         */
99         const struct line6_properties *properties;
100
101         /**
102                  Interface number.
103         */
104         int interface_number;
105
106         /**
107                  Interval (ms).
108         */
109         int interval;
110
111         /**
112                  Maximum size of USB packet.
113         */
114         int max_packet_size;
115
116         /**
117                  Device representing the USB interface.
118         */
119         struct device *ifcdev;
120
121         /**
122                  Line6 sound card data structure.
123                  Each device has at least MIDI or PCM.
124         */
125         struct snd_card *card;
126
127         /**
128                  Line6 PCM device data structure.
129         */
130         struct snd_line6_pcm *line6pcm;
131
132         /**
133                  Line6 MIDI device data structure.
134         */
135         struct snd_line6_midi *line6midi;
136
137         /**
138                  USB endpoint for listening to control commands.
139         */
140         int ep_control_read;
141
142         /**
143                  USB endpoint for writing control commands.
144         */
145         int ep_control_write;
146
147         /**
148                  URB for listening to PODxt Pro control endpoint.
149         */
150         struct urb *urb_listen;
151
152         /**
153                  Buffer for listening to PODxt Pro control endpoint.
154         */
155         unsigned char *buffer_listen;
156
157         /**
158                  Buffer for message to be processed.
159         */
160         unsigned char *buffer_message;
161
162         /**
163                  Length of message to be processed.
164         */
165         int message_length;
166 };
167
168
169 extern char *line6_alloc_sysex_buffer(struct usb_line6 *line6, int code1, int code2, int size);
170 extern ssize_t line6_nop_read(struct device *dev, struct device_attribute *attr, char *buf);
171 extern ssize_t line6_nop_write(struct device *dev, struct device_attribute *attr, const char *buf, size_t count);
172 extern int line6_read_data(struct usb_line6 *line6, int address, void *data, size_t datalen);
173 extern int line6_read_serial_number(struct usb_line6 *line6, int *serial_number);
174 extern int line6_send_program(struct usb_line6 *line6, int value);
175 extern int line6_send_raw_message(struct usb_line6 *line6, const char *buffer, int size);
176 extern int line6_send_raw_message_async(struct usb_line6 *line6, const char *buffer, int size);
177 extern int line6_send_sysex_message(struct usb_line6 *line6, const char *buffer, int size);
178 extern ssize_t line6_set_raw(struct device *dev, struct device_attribute *attr, const char *buf, size_t count);
179 extern int line6_transmit_parameter(struct usb_line6 *line6, int param, int value);
180 extern int line6_write_data(struct usb_line6 *line6, int address, void *data, size_t datalen);
181 extern void line6_write_hexdump(struct usb_line6 *line6, char dir, const unsigned char *buffer, int size);
182
183
184 #endif