0001
0002
0003
0004
0005
0006
0007
0008 #ifndef DRIVER_H
0009 #define DRIVER_H
0010
0011 #include <linux/usb.h>
0012 #include <linux/mutex.h>
0013 #include <linux/kfifo.h>
0014 #include <sound/core.h>
0015
0016 #include "midi.h"
0017
0018
0019 #define USB_LOW_INTERVALS_PER_SECOND 1000
0020 #define USB_LOW_ISO_BUFFERS 2
0021
0022
0023 #define USB_HIGH_INTERVALS_PER_SECOND 8000
0024 #define USB_HIGH_ISO_BUFFERS 16
0025
0026
0027 #define LINE6_FALLBACK_INTERVAL 10
0028 #define LINE6_FALLBACK_MAXPACKETSIZE 16
0029
0030 #define LINE6_TIMEOUT 1000
0031 #define LINE6_BUFSIZE_LISTEN 64
0032 #define LINE6_MIDI_MESSAGE_MAXLEN 256
0033
0034 #define LINE6_RAW_MESSAGES_MAXCOUNT_ORDER 7
0035
0036 #define LINE6_RAW_MESSAGES_MAXCOUNT (1 << LINE6_RAW_MESSAGES_MAXCOUNT_ORDER)
0037
0038
0039 #if LINE6_BUFSIZE_LISTEN > 65535
0040 #error "Use dynamic fifo instead"
0041 #endif
0042
0043
0044
0045
0046 #define LINE6_PARAM_CHANGE 0xb0
0047 #define LINE6_PROGRAM_CHANGE 0xc0
0048 #define LINE6_SYSEX_BEGIN 0xf0
0049 #define LINE6_SYSEX_END 0xf7
0050 #define LINE6_RESET 0xff
0051
0052
0053
0054
0055
0056 #define LINE6_CHANNEL_HOST 0x00
0057
0058
0059
0060
0061 #define LINE6_CHANNEL_DEVICE 0x02
0062
0063 #define LINE6_CHANNEL_UNKNOWN 5
0064
0065 #define LINE6_CHANNEL_MASK 0x0f
0066
0067 extern const unsigned char line6_midi_id[3];
0068
0069 #define SYSEX_DATA_OFS (sizeof(line6_midi_id) + 3)
0070 #define SYSEX_EXTRA_SIZE (sizeof(line6_midi_id) + 4)
0071
0072
0073
0074
0075 struct line6_properties {
0076
0077
0078
0079
0080 const char *id;
0081
0082
0083 const char *name;
0084
0085
0086 int capabilities;
0087
0088 int altsetting;
0089
0090 unsigned int ctrl_if;
0091 unsigned int ep_ctrl_r;
0092 unsigned int ep_ctrl_w;
0093 unsigned int ep_audio_r;
0094 unsigned int ep_audio_w;
0095 };
0096
0097
0098 enum {
0099
0100 LINE6_CAP_CONTROL = 1 << 0,
0101
0102 LINE6_CAP_PCM = 1 << 1,
0103
0104 LINE6_CAP_HWMON = 1 << 2,
0105
0106 LINE6_CAP_IN_NEEDS_OUT = 1 << 3,
0107
0108 LINE6_CAP_CONTROL_MIDI = 1 << 4,
0109
0110 LINE6_CAP_CONTROL_INFO = 1 << 5,
0111
0112 LINE6_CAP_HWMON_CTL = 1 << 6,
0113 };
0114
0115
0116
0117
0118
0119 struct usb_line6 {
0120
0121 struct usb_device *usbdev;
0122
0123
0124 const struct line6_properties *properties;
0125
0126
0127 int interval;
0128
0129 int intervals_per_second;
0130
0131
0132 int iso_buffers;
0133
0134
0135 int max_packet_size;
0136
0137
0138 struct device *ifcdev;
0139
0140
0141
0142
0143 struct snd_card *card;
0144
0145
0146 struct snd_line6_pcm *line6pcm;
0147
0148
0149 struct snd_line6_midi *line6midi;
0150
0151
0152 struct urb *urb_listen;
0153
0154
0155 unsigned char *buffer_listen;
0156
0157
0158 unsigned char *buffer_message;
0159
0160
0161 int message_length;
0162
0163
0164 struct {
0165 struct mutex read_lock;
0166 wait_queue_head_t wait_queue;
0167 unsigned int active:1;
0168 unsigned int nonblock:1;
0169 STRUCT_KFIFO_REC_2(LINE6_BUFSIZE_LISTEN * LINE6_RAW_MESSAGES_MAXCOUNT)
0170 fifo;
0171 } messages;
0172
0173
0174 struct delayed_work startup_work;
0175
0176
0177
0178
0179 void (*process_message)(struct usb_line6 *);
0180 void (*disconnect)(struct usb_line6 *line6);
0181 void (*startup)(struct usb_line6 *line6);
0182 };
0183
0184 extern char *line6_alloc_sysex_buffer(struct usb_line6 *line6, int code1,
0185 int code2, int size);
0186 extern int line6_read_data(struct usb_line6 *line6, unsigned address,
0187 void *data, unsigned datalen);
0188 extern int line6_read_serial_number(struct usb_line6 *line6,
0189 u32 *serial_number);
0190 extern int line6_send_raw_message(struct usb_line6 *line6,
0191 const char *buffer, int size);
0192 extern int line6_send_raw_message_async(struct usb_line6 *line6,
0193 const char *buffer, int size);
0194 extern int line6_send_sysex_message(struct usb_line6 *line6,
0195 const char *buffer, int size);
0196 extern ssize_t line6_set_raw(struct device *dev, struct device_attribute *attr,
0197 const char *buf, size_t count);
0198 extern int line6_version_request_async(struct usb_line6 *line6);
0199 extern int line6_write_data(struct usb_line6 *line6, unsigned address,
0200 void *data, unsigned datalen);
0201
0202 int line6_probe(struct usb_interface *interface,
0203 const struct usb_device_id *id,
0204 const char *driver_name,
0205 const struct line6_properties *properties,
0206 int (*private_init)(struct usb_line6 *, const struct usb_device_id *id),
0207 size_t data_size);
0208
0209 void line6_disconnect(struct usb_interface *interface);
0210
0211 #ifdef CONFIG_PM
0212 int line6_suspend(struct usb_interface *interface, pm_message_t message);
0213 int line6_resume(struct usb_interface *interface);
0214 #endif
0215
0216 #endif