blob: ad203f197e80569ae434307b2a4a1cbbcaf9ec70 [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
Chris Rorvick410dca82015-01-12 12:42:40 -080023enum line6_device_type {
24 LINE6_BASSPODXT,
25 LINE6_BASSPODXTLIVE,
26 LINE6_BASSPODXTPRO,
27 LINE6_GUITARPORT,
28 LINE6_POCKETPOD,
29 LINE6_PODHD300,
30 LINE6_PODHD400,
Chris Rorvick951dd312015-01-12 12:42:49 -080031 LINE6_PODHD500_0,
32 LINE6_PODHD500_1,
Chris Rorvick410dca82015-01-12 12:42:40 -080033 LINE6_PODSTUDIO_GX,
34 LINE6_PODSTUDIO_UX1,
35 LINE6_PODSTUDIO_UX2,
36 LINE6_PODXT,
Chris Rorvick7ad07312015-01-12 12:42:48 -080037 LINE6_PODXTLIVE_POD,
38 LINE6_PODXTLIVE_VARIAX,
Chris Rorvick410dca82015-01-12 12:42:40 -080039 LINE6_PODXTPRO,
40 LINE6_TONEPORT_GX,
41 LINE6_TONEPORT_UX1,
42 LINE6_TONEPORT_UX2,
43 LINE6_VARIAX
44};
45
Markus Grabner705ecec2009-02-27 19:43:04 -080046#define LINE6_TIMEOUT 1
Markus Grabner705ecec2009-02-27 19:43:04 -080047#define LINE6_BUFSIZE_LISTEN 32
48#define LINE6_MESSAGE_MAXLEN 256
49
Markus Grabner705ecec2009-02-27 19:43:04 -080050/*
51 Line6 MIDI control commands
52*/
53#define LINE6_PARAM_CHANGE 0xb0
54#define LINE6_PROGRAM_CHANGE 0xc0
55#define LINE6_SYSEX_BEGIN 0xf0
56#define LINE6_SYSEX_END 0xf7
57#define LINE6_RESET 0xff
58
59/*
60 MIDI channel for messages initiated by the host
61 (and eventually echoed back by the device)
62*/
63#define LINE6_CHANNEL_HOST 0x00
64
65/*
66 MIDI channel for messages initiated by the device
67*/
68#define LINE6_CHANNEL_DEVICE 0x02
69
Markus Grabnere1a164d2010-08-23 01:08:25 +020070#define LINE6_CHANNEL_UNKNOWN 5 /* don't know yet what this is good for */
Markus Grabner705ecec2009-02-27 19:43:04 -080071
72#define LINE6_CHANNEL_MASK 0x0f
73
Greg Kroah-Hartmana49e4832009-02-27 21:09:55 -080074#define MISSING_CASE \
Stefan Hajnoczi4d3f50e2013-01-11 23:08:11 +010075 pr_err("line6usb driver bug: missing case in %s:%d\n", \
Greg Kroah-Hartmana49e4832009-02-27 21:09:55 -080076 __FILE__, __LINE__)
Markus Grabner705ecec2009-02-27 19:43:04 -080077
Greg Kroah-Hartmana49e4832009-02-27 21:09:55 -080078#define CHECK_RETURN(x) \
79do { \
80 err = x; \
81 if (err < 0) \
82 return err; \
83} while (0)
Markus Grabner705ecec2009-02-27 19:43:04 -080084
Greg Kroah-Hartman027360c2010-09-21 16:58:00 -070085#define CHECK_STARTUP_PROGRESS(x, n) \
86do { \
87 if ((x) >= (n)) \
88 return; \
89 x = (n); \
90} while (0)
Markus Grabner1027f4762010-08-12 01:35:30 +020091
Markus Grabner705ecec2009-02-27 19:43:04 -080092extern const unsigned char line6_midi_id[3];
Markus Grabner705ecec2009-02-27 19:43:04 -080093
94static const int SYSEX_DATA_OFS = sizeof(line6_midi_id) + 3;
95static const int SYSEX_EXTRA_SIZE = sizeof(line6_midi_id) + 4;
96
Markus Grabner705ecec2009-02-27 19:43:04 -080097/**
98 Common properties of Line6 devices.
99*/
100struct line6_properties {
Markus Grabner1027f4762010-08-12 01:35:30 +0200101 /**
102 Card id string (maximum 16 characters).
103 This can be used to address the device in ALSA programs as
104 "default:CARD=<id>"
105 */
106 const char *id;
107
108 /**
109 Card short name (maximum 32 characters).
110 */
Markus Grabner705ecec2009-02-27 19:43:04 -0800111 const char *name;
Markus Grabner1027f4762010-08-12 01:35:30 +0200112
113 /**
Markus Grabner1027f4762010-08-12 01:35:30 +0200114 Bit vector defining this device's capabilities in the
115 line6usb driver.
116 */
Markus Grabner705ecec2009-02-27 19:43:04 -0800117 int capabilities;
Chris Rorvick7b9584f2015-01-12 12:42:52 -0800118
119 int altsetting;
Chris Rorvick9e165be2015-01-12 12:42:53 -0800120
121 unsigned ep_ctrl_r;
122 unsigned ep_ctrl_w;
Chris Rorvick16d603d2015-01-12 12:42:55 -0800123 unsigned ep_audio_r;
124 unsigned ep_audio_w;
Markus Grabner705ecec2009-02-27 19:43:04 -0800125};
126
127/**
128 Common data shared by all Line6 devices.
129 Corresponds to a pair of USB endpoints.
130*/
131struct usb_line6 {
132 /**
133 USB device.
134 */
135 struct usb_device *usbdev;
136
137 /**
Chris Rorvicka23a8bf2015-01-12 12:42:42 -0800138 Device type.
Markus Grabner705ecec2009-02-27 19:43:04 -0800139 */
Chris Rorvicka23a8bf2015-01-12 12:42:42 -0800140 enum line6_device_type type;
Markus Grabner705ecec2009-02-27 19:43:04 -0800141
142 /**
143 Properties.
144 */
145 const struct line6_properties *properties;
146
147 /**
Markus Grabner705ecec2009-02-27 19:43:04 -0800148 Interval (ms).
149 */
150 int interval;
151
152 /**
153 Maximum size of USB packet.
154 */
155 int max_packet_size;
156
157 /**
158 Device representing the USB interface.
159 */
160 struct device *ifcdev;
161
162 /**
163 Line6 sound card data structure.
164 Each device has at least MIDI or PCM.
165 */
166 struct snd_card *card;
167
168 /**
169 Line6 PCM device data structure.
170 */
171 struct snd_line6_pcm *line6pcm;
172
173 /**
174 Line6 MIDI device data structure.
175 */
176 struct snd_line6_midi *line6midi;
177
178 /**
Markus Grabner705ecec2009-02-27 19:43:04 -0800179 URB for listening to PODxt Pro control endpoint.
180 */
181 struct urb *urb_listen;
182
183 /**
184 Buffer for listening to PODxt Pro control endpoint.
185 */
186 unsigned char *buffer_listen;
187
188 /**
189 Buffer for message to be processed.
190 */
191 unsigned char *buffer_message;
192
193 /**
194 Length of message to be processed.
195 */
196 int message_length;
Chris Rorvick01f6b2b2015-01-12 12:42:58 -0800197
198 void (*process_message)(struct usb_line6 *);
Chris Rorvicka46c4672015-01-12 12:42:59 -0800199 void (*disconnect)(struct usb_interface *);
Markus Grabner705ecec2009-02-27 19:43:04 -0800200};
201
Greg Kroah-Hartmana49e4832009-02-27 21:09:55 -0800202extern char *line6_alloc_sysex_buffer(struct usb_line6 *line6, int code1,
203 int code2, int size);
204extern ssize_t line6_nop_read(struct device *dev,
205 struct device_attribute *attr, char *buf);
Greg Kroah-Hartmana49e4832009-02-27 21:09:55 -0800206extern int line6_read_data(struct usb_line6 *line6, int address, void *data,
207 size_t datalen);
208extern int line6_read_serial_number(struct usb_line6 *line6,
209 int *serial_number);
Johannes Thumshirn317e1882012-06-27 21:25:58 +0200210extern int line6_send_program(struct usb_line6 *line6, u8 value);
Greg Kroah-Hartmana49e4832009-02-27 21:09:55 -0800211extern int line6_send_raw_message(struct usb_line6 *line6, const char *buffer,
212 int size);
213extern int line6_send_raw_message_async(struct usb_line6 *line6,
214 const char *buffer, int size);
215extern int line6_send_sysex_message(struct usb_line6 *line6,
216 const char *buffer, int size);
217extern ssize_t line6_set_raw(struct device *dev, struct device_attribute *attr,
218 const char *buf, size_t count);
Markus Grabner1027f4762010-08-12 01:35:30 +0200219extern void line6_start_timer(struct timer_list *timer, unsigned int msecs,
Monam Agarwal56733e92014-02-27 21:06:58 +0530220 void (*function)(unsigned long),
Markus Grabnere1a164d2010-08-23 01:08:25 +0200221 unsigned long data);
Greg Kroah-Hartmana49e4832009-02-27 21:09:55 -0800222extern int line6_transmit_parameter(struct usb_line6 *line6, int param,
Johannes Thumshirn2471c092012-06-27 21:25:55 +0200223 u8 value);
Markus Grabner1027f4762010-08-12 01:35:30 +0200224extern int line6_version_request_async(struct usb_line6 *line6);
Greg Kroah-Hartmana49e4832009-02-27 21:09:55 -0800225extern int line6_write_data(struct usb_line6 *line6, int address, void *data,
226 size_t datalen);
Markus Grabner1027f4762010-08-12 01:35:30 +0200227
Markus Grabner705ecec2009-02-27 19:43:04 -0800228#endif