ALSA: line6: fixup of line6_start_timer argument type
[firefly-linux-kernel-4.4.55.git] / sound / usb / line6 / driver.h
1 /*
2  * Line 6 Linux USB driver
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 USB_INTERVALS_PER_SECOND 1000
24
25 /* Fallback USB interval and max packet size values */
26 #define LINE6_FALLBACK_INTERVAL 10
27 #define LINE6_FALLBACK_MAXPACKETSIZE 16
28
29 #define LINE6_TIMEOUT 1
30 #define LINE6_BUFSIZE_LISTEN 32
31 #define LINE6_MESSAGE_MAXLEN 256
32
33 /*
34         Line 6 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 #define CHECK_STARTUP_PROGRESS(x, n)    \
58 do {                                    \
59         if ((x) >= (n))                 \
60                 return;                 \
61         x = (n);                        \
62 } while (0)
63
64 extern const unsigned char line6_midi_id[3];
65
66 static const int SYSEX_DATA_OFS = sizeof(line6_midi_id) + 3;
67 static const int SYSEX_EXTRA_SIZE = sizeof(line6_midi_id) + 4;
68
69 /*
70          Common properties of Line 6 devices.
71 */
72 struct line6_properties {
73         /* Card id string (maximum 16 characters).
74          * This can be used to address the device in ALSA programs as
75          * "default:CARD=<id>"
76          */
77         const char *id;
78
79         /* Card short name (maximum 32 characters) */
80         const char *name;
81
82         /* Bit vector defining this device's capabilities in line6usb driver */
83         int capabilities;
84
85         int altsetting;
86
87         unsigned ep_ctrl_r;
88         unsigned ep_ctrl_w;
89         unsigned ep_audio_r;
90         unsigned ep_audio_w;
91 };
92
93 /* Capability bits */
94 enum {
95         /* device supports settings parameter via USB */
96         LINE6_CAP_CONTROL =     1 << 0,
97         /* device supports PCM input/output via USB */
98         LINE6_CAP_PCM =         1 << 1,
99         /* device support hardware monitoring */
100         LINE6_CAP_HWMON =       1 << 2,
101 };
102
103 /*
104          Common data shared by all Line 6 devices.
105          Corresponds to a pair of USB endpoints.
106 */
107 struct usb_line6 {
108         /* USB device */
109         struct usb_device *usbdev;
110
111         /* Properties */
112         const struct line6_properties *properties;
113
114         /* Interval (ms) */
115         int interval;
116
117         /* Maximum size of USB packet */
118         int max_packet_size;
119
120         /* Device representing the USB interface */
121         struct device *ifcdev;
122
123         /* Line 6 sound card data structure.
124          * Each device has at least MIDI or PCM.
125          */
126         struct snd_card *card;
127
128         /* Line 6 PCM device data structure */
129         struct snd_line6_pcm *line6pcm;
130
131         /* Line 6 MIDI device data structure */
132         struct snd_line6_midi *line6midi;
133
134         /* URB for listening to PODxt Pro control endpoint */
135         struct urb *urb_listen;
136
137         /* Buffer for listening to PODxt Pro control endpoint */
138         unsigned char *buffer_listen;
139
140         /* Buffer for message to be processed */
141         unsigned char *buffer_message;
142
143         /* Length of message to be processed */
144         int message_length;
145
146         void (*process_message)(struct usb_line6 *);
147         void (*disconnect)(struct usb_line6 *line6);
148 };
149
150 extern char *line6_alloc_sysex_buffer(struct usb_line6 *line6, int code1,
151                                       int code2, int size);
152 extern int line6_read_data(struct usb_line6 *line6, int address, void *data,
153                            size_t datalen);
154 extern int line6_read_serial_number(struct usb_line6 *line6,
155                                     int *serial_number);
156 extern int line6_send_raw_message_async(struct usb_line6 *line6,
157                                         const char *buffer, int size);
158 extern int line6_send_sysex_message(struct usb_line6 *line6,
159                                     const char *buffer, int size);
160 extern ssize_t line6_set_raw(struct device *dev, struct device_attribute *attr,
161                              const char *buf, size_t count);
162 extern void line6_start_timer(struct timer_list *timer, unsigned long msecs,
163                               void (*function)(unsigned long),
164                               unsigned long data);
165 extern int line6_version_request_async(struct usb_line6 *line6);
166 extern int line6_write_data(struct usb_line6 *line6, int address, void *data,
167                             size_t datalen);
168
169 int line6_probe(struct usb_interface *interface,
170                 const struct usb_device_id *id,
171                 const struct line6_properties *properties,
172                 int (*private_init)(struct usb_line6 *, const struct usb_device_id *id),
173                 size_t data_size);
174
175 void line6_disconnect(struct usb_interface *interface);
176
177 #ifdef CONFIG_PM
178 int line6_suspend(struct usb_interface *interface, pm_message_t message);
179 int line6_resume(struct usb_interface *interface);
180 #endif
181
182 #endif