blob: 7da643e79e3b50426c3cbaf4d46184d7283f3848 [file] [log] [blame]
Markus Grabner705ecec2009-02-27 19:43:04 -08001/*
Chris Rorvickc078a4a2015-01-20 02:20:50 -06002 * Line 6 Linux USB driver
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
Takashi Iwai129b3be2015-01-28 14:50:08 +010021#define USB_INTERVALS_PER_SECOND 1000
22
23/* Fallback USB interval and max packet size values */
24#define LINE6_FALLBACK_INTERVAL 10
25#define LINE6_FALLBACK_MAXPACKETSIZE 16
26
Markus Grabner705ecec2009-02-27 19:43:04 -080027#define LINE6_TIMEOUT 1
Markus Grabner705ecec2009-02-27 19:43:04 -080028#define LINE6_BUFSIZE_LISTEN 32
29#define LINE6_MESSAGE_MAXLEN 256
30
Markus Grabner705ecec2009-02-27 19:43:04 -080031/*
Chris Rorvickc6fffce2015-01-20 02:20:49 -060032 Line 6 MIDI control commands
Markus Grabner705ecec2009-02-27 19:43:04 -080033*/
34#define LINE6_PARAM_CHANGE 0xb0
35#define LINE6_PROGRAM_CHANGE 0xc0
36#define LINE6_SYSEX_BEGIN 0xf0
37#define LINE6_SYSEX_END 0xf7
38#define LINE6_RESET 0xff
39
40/*
41 MIDI channel for messages initiated by the host
42 (and eventually echoed back by the device)
43*/
44#define LINE6_CHANNEL_HOST 0x00
45
46/*
47 MIDI channel for messages initiated by the device
48*/
49#define LINE6_CHANNEL_DEVICE 0x02
50
Markus Grabnere1a164d2010-08-23 01:08:25 +020051#define LINE6_CHANNEL_UNKNOWN 5 /* don't know yet what this is good for */
Markus Grabner705ecec2009-02-27 19:43:04 -080052
53#define LINE6_CHANNEL_MASK 0x0f
54
Greg Kroah-Hartman027360c2010-09-21 16:58:00 -070055#define CHECK_STARTUP_PROGRESS(x, n) \
56do { \
57 if ((x) >= (n)) \
58 return; \
59 x = (n); \
60} while (0)
Markus Grabner1027f4762010-08-12 01:35:30 +020061
Markus Grabner705ecec2009-02-27 19:43:04 -080062extern const unsigned char line6_midi_id[3];
Markus Grabner705ecec2009-02-27 19:43:04 -080063
64static const int SYSEX_DATA_OFS = sizeof(line6_midi_id) + 3;
65static const int SYSEX_EXTRA_SIZE = sizeof(line6_midi_id) + 4;
66
Takashi Iwaicddbd4f2015-01-28 14:43:11 +010067/*
Chris Rorvickc6fffce2015-01-20 02:20:49 -060068 Common properties of Line 6 devices.
Markus Grabner705ecec2009-02-27 19:43:04 -080069*/
70struct line6_properties {
Takashi Iwaicddbd4f2015-01-28 14:43:11 +010071 /* Card id string (maximum 16 characters).
72 * This can be used to address the device in ALSA programs as
73 * "default:CARD=<id>"
74 */
Markus Grabner1027f4762010-08-12 01:35:30 +020075 const char *id;
76
Takashi Iwaicddbd4f2015-01-28 14:43:11 +010077 /* Card short name (maximum 32 characters) */
Markus Grabner705ecec2009-02-27 19:43:04 -080078 const char *name;
Markus Grabner1027f4762010-08-12 01:35:30 +020079
Takashi Iwaicddbd4f2015-01-28 14:43:11 +010080 /* Bit vector defining this device's capabilities in line6usb driver */
Markus Grabner705ecec2009-02-27 19:43:04 -080081 int capabilities;
Chris Rorvick7b9584f2015-01-12 12:42:52 -080082
83 int altsetting;
Chris Rorvick9e165be2015-01-12 12:42:53 -080084
85 unsigned ep_ctrl_r;
86 unsigned ep_ctrl_w;
Chris Rorvick16d603d2015-01-12 12:42:55 -080087 unsigned ep_audio_r;
88 unsigned ep_audio_w;
Markus Grabner705ecec2009-02-27 19:43:04 -080089};
90
Takashi Iwai129b3be2015-01-28 14:50:08 +010091/* Capability bits */
92enum {
93 /* device supports settings parameter via USB */
94 LINE6_CAP_CONTROL = 1 << 0,
95 /* device supports PCM input/output via USB */
96 LINE6_CAP_PCM = 1 << 1,
97 /* device support hardware monitoring */
98 LINE6_CAP_HWMON = 1 << 2,
99};
100
Takashi Iwaicddbd4f2015-01-28 14:43:11 +0100101/*
Chris Rorvickc6fffce2015-01-20 02:20:49 -0600102 Common data shared by all Line 6 devices.
Markus Grabner705ecec2009-02-27 19:43:04 -0800103 Corresponds to a pair of USB endpoints.
104*/
105struct usb_line6 {
Takashi Iwaicddbd4f2015-01-28 14:43:11 +0100106 /* USB device */
Markus Grabner705ecec2009-02-27 19:43:04 -0800107 struct usb_device *usbdev;
108
Takashi Iwaicddbd4f2015-01-28 14:43:11 +0100109 /* Properties */
Markus Grabner705ecec2009-02-27 19:43:04 -0800110 const struct line6_properties *properties;
111
Takashi Iwaicddbd4f2015-01-28 14:43:11 +0100112 /* Interval (ms) */
Markus Grabner705ecec2009-02-27 19:43:04 -0800113 int interval;
114
Takashi Iwaicddbd4f2015-01-28 14:43:11 +0100115 /* Maximum size of USB packet */
Markus Grabner705ecec2009-02-27 19:43:04 -0800116 int max_packet_size;
117
Takashi Iwaicddbd4f2015-01-28 14:43:11 +0100118 /* Device representing the USB interface */
Markus Grabner705ecec2009-02-27 19:43:04 -0800119 struct device *ifcdev;
120
Takashi Iwaicddbd4f2015-01-28 14:43:11 +0100121 /* Line 6 sound card data structure.
122 * Each device has at least MIDI or PCM.
123 */
Markus Grabner705ecec2009-02-27 19:43:04 -0800124 struct snd_card *card;
125
Takashi Iwaicddbd4f2015-01-28 14:43:11 +0100126 /* Line 6 PCM device data structure */
Markus Grabner705ecec2009-02-27 19:43:04 -0800127 struct snd_line6_pcm *line6pcm;
128
Takashi Iwaicddbd4f2015-01-28 14:43:11 +0100129 /* Line 6 MIDI device data structure */
Markus Grabner705ecec2009-02-27 19:43:04 -0800130 struct snd_line6_midi *line6midi;
131
Takashi Iwaicddbd4f2015-01-28 14:43:11 +0100132 /* URB for listening to PODxt Pro control endpoint */
Markus Grabner705ecec2009-02-27 19:43:04 -0800133 struct urb *urb_listen;
134
Takashi Iwaicddbd4f2015-01-28 14:43:11 +0100135 /* Buffer for listening to PODxt Pro control endpoint */
Markus Grabner705ecec2009-02-27 19:43:04 -0800136 unsigned char *buffer_listen;
137
Takashi Iwaicddbd4f2015-01-28 14:43:11 +0100138 /* Buffer for message to be processed */
Markus Grabner705ecec2009-02-27 19:43:04 -0800139 unsigned char *buffer_message;
140
Takashi Iwaicddbd4f2015-01-28 14:43:11 +0100141 /* Length of message to be processed */
Markus Grabner705ecec2009-02-27 19:43:04 -0800142 int message_length;
Chris Rorvick01f6b2b2015-01-12 12:42:58 -0800143
144 void (*process_message)(struct usb_line6 *);
Takashi Iwaif66fd992015-01-25 18:22:58 +0100145 void (*disconnect)(struct usb_line6 *line6);
Markus Grabner705ecec2009-02-27 19:43:04 -0800146};
147
Greg Kroah-Hartmana49e4832009-02-27 21:09:55 -0800148extern char *line6_alloc_sysex_buffer(struct usb_line6 *line6, int code1,
149 int code2, int size);
Chris Rorvick25a07072015-02-11 06:03:31 -0600150extern int line6_read_data(struct usb_line6 *line6, unsigned address,
151 void *data, unsigned datalen);
Greg Kroah-Hartmana49e4832009-02-27 21:09:55 -0800152extern int line6_read_serial_number(struct usb_line6 *line6,
Chris Rorvick12b00152015-02-10 23:03:16 -0600153 u32 *serial_number);
Greg Kroah-Hartmana49e4832009-02-27 21:09:55 -0800154extern int line6_send_raw_message_async(struct usb_line6 *line6,
155 const char *buffer, int size);
156extern int line6_send_sysex_message(struct usb_line6 *line6,
157 const char *buffer, int size);
158extern ssize_t line6_set_raw(struct device *dev, struct device_attribute *attr,
159 const char *buf, size_t count);
Nicholas Mc Guire6ccd93b2015-02-03 02:38:56 -0500160extern void line6_start_timer(struct timer_list *timer, unsigned long msecs,
Monam Agarwal56733e92014-02-27 21:06:58 +0530161 void (*function)(unsigned long),
Markus Grabnere1a164d2010-08-23 01:08:25 +0200162 unsigned long data);
Markus Grabner1027f4762010-08-12 01:35:30 +0200163extern int line6_version_request_async(struct usb_line6 *line6);
Chris Rorvick25a07072015-02-11 06:03:31 -0600164extern int line6_write_data(struct usb_line6 *line6, unsigned address,
165 void *data, unsigned datalen);
Markus Grabner1027f4762010-08-12 01:35:30 +0200166
Takashi Iwaiccddbe42015-01-15 08:22:31 +0100167int line6_probe(struct usb_interface *interface,
Takashi Iwaif66fd992015-01-25 18:22:58 +0100168 const struct usb_device_id *id,
Chris Rorvick12865ca2015-02-07 10:43:19 -0600169 const char *driver_name,
Takashi Iwaiccddbe42015-01-15 08:22:31 +0100170 const struct line6_properties *properties,
Takashi Iwaiaca514b2015-01-25 18:36:29 +0100171 int (*private_init)(struct usb_line6 *, const struct usb_device_id *id),
172 size_t data_size);
Takashi Iwaif66fd992015-01-25 18:22:58 +0100173
Takashi Iwaiccddbe42015-01-15 08:22:31 +0100174void line6_disconnect(struct usb_interface *interface);
175
176#ifdef CONFIG_PM
177int line6_suspend(struct usb_interface *interface, pm_message_t message);
178int line6_resume(struct usb_interface *interface);
179#endif
180
Markus Grabner705ecec2009-02-27 19:43:04 -0800181#endif