blob: 16e3fc2f1f1597e324cc8dd4c48d106b7338dc50 [file] [log] [blame]
Markus Grabner705ecec2009-02-27 19:43:04 -08001/*
Markus Grabnere1a164d2010-08-23 01:08:25 +02002 * Line6 Linux USB driver - 0.9.1beta
Markus Grabner705ecec2009-02-27 19:43:04 -08003 *
Markus Grabner1027f4762010-08-12 01:35:30 +02004 * Copyright (C) 2004-2010 Markus Grabner (grabner@icg.tugraz.at)
Markus Grabner705ecec2009-02-27 19:43:04 -08005 *
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
Markus Grabner705ecec2009-02-27 19:43:04 -080015#include <linux/spinlock.h>
16#include <linux/usb.h>
Markus Grabner705ecec2009-02-27 19:43:04 -080017#include <sound/core.h>
18
19#include "midi.h"
20
Markus Grabner705ecec2009-02-27 19:43:04 -080021#define DRIVER_NAME "line6usb"
22
23#define LINE6_TIMEOUT 1
Markus Grabner705ecec2009-02-27 19:43:04 -080024#define LINE6_BUFSIZE_LISTEN 32
25#define LINE6_MESSAGE_MAXLEN 256
26
Markus Grabner705ecec2009-02-27 19:43:04 -080027/*
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
Markus Grabnere1a164d2010-08-23 01:08:25 +020047#define LINE6_CHANNEL_UNKNOWN 5 /* don't know yet what this is good for */
Markus Grabner705ecec2009-02-27 19:43:04 -080048
49#define LINE6_CHANNEL_MASK 0x0f
50
Greg Kroah-Hartmana49e4832009-02-27 21:09:55 -080051#define MISSING_CASE \
Stefan Hajnoczi4d3f50e2013-01-11 23:08:11 +010052 pr_err("line6usb driver bug: missing case in %s:%d\n", \
Greg Kroah-Hartmana49e4832009-02-27 21:09:55 -080053 __FILE__, __LINE__)
Markus Grabner705ecec2009-02-27 19:43:04 -080054
Greg Kroah-Hartmana49e4832009-02-27 21:09:55 -080055#define CHECK_RETURN(x) \
56do { \
57 err = x; \
58 if (err < 0) \
59 return err; \
60} while (0)
Markus Grabner705ecec2009-02-27 19:43:04 -080061
Greg Kroah-Hartman027360c2010-09-21 16:58:00 -070062#define CHECK_STARTUP_PROGRESS(x, n) \
63do { \
64 if ((x) >= (n)) \
65 return; \
66 x = (n); \
67} while (0)
Markus Grabner1027f4762010-08-12 01:35:30 +020068
Markus Grabner705ecec2009-02-27 19:43:04 -080069extern const unsigned char line6_midi_id[3];
Markus Grabner705ecec2009-02-27 19:43:04 -080070
71static const int SYSEX_DATA_OFS = sizeof(line6_midi_id) + 3;
72static const int SYSEX_EXTRA_SIZE = sizeof(line6_midi_id) + 4;
73
Markus Grabner705ecec2009-02-27 19:43:04 -080074/**
75 Common properties of Line6 devices.
76*/
77struct line6_properties {
Markus Grabner1027f4762010-08-12 01:35:30 +020078 /**
Markus Grabner4c6fb5f2011-12-05 23:51:53 +010079 Bit identifying this device in the line6usb driver.
80 */
81 int device_bit;
82
83 /**
Markus Grabner1027f4762010-08-12 01:35:30 +020084 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 */
Markus Grabner705ecec2009-02-27 19:43:04 -080093 const char *name;
Markus Grabner1027f4762010-08-12 01:35:30 +020094
95 /**
Markus Grabner1027f4762010-08-12 01:35:30 +020096 Bit vector defining this device's capabilities in the
97 line6usb driver.
98 */
Markus Grabner705ecec2009-02-27 19:43:04 -080099 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
Greg Kroah-Hartmana49e4832009-02-27 21:09:55 -0800189extern 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);
Greg Kroah-Hartmana49e4832009-02-27 21:09:55 -0800193extern 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);
Johannes Thumshirn317e1882012-06-27 21:25:58 +0200197extern int line6_send_program(struct usb_line6 *line6, u8 value);
Greg Kroah-Hartmana49e4832009-02-27 21:09:55 -0800198extern 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);
Markus Grabner1027f4762010-08-12 01:35:30 +0200206extern void line6_start_timer(struct timer_list *timer, unsigned int msecs,
Monam Agarwal56733e92014-02-27 21:06:58 +0530207 void (*function)(unsigned long),
Markus Grabnere1a164d2010-08-23 01:08:25 +0200208 unsigned long data);
Greg Kroah-Hartmana49e4832009-02-27 21:09:55 -0800209extern int line6_transmit_parameter(struct usb_line6 *line6, int param,
Johannes Thumshirn2471c092012-06-27 21:25:55 +0200210 u8 value);
Markus Grabner1027f4762010-08-12 01:35:30 +0200211extern int line6_version_request_async(struct usb_line6 *line6);
Greg Kroah-Hartmana49e4832009-02-27 21:09:55 -0800212extern int line6_write_data(struct usb_line6 *line6, int address, void *data,
213 size_t datalen);
Markus Grabner1027f4762010-08-12 01:35:30 +0200214
Markus Grabner705ecec2009-02-27 19:43:04 -0800215#endif