ALSA: line6: Enable different number of URBs for frame transfers
[linux-2.6-block.git] / sound / usb / line6 / driver.h
CommitLineData
705ececd 1/*
c078a4aa 2 * Line 6 Linux USB driver
705ececd 3 *
1027f476 4 * Copyright (C) 2004-2010 Markus Grabner (grabner@icg.tugraz.at)
705ececd
MG
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
705ececd
MG
15#include <linux/spinlock.h>
16#include <linux/usb.h>
705ececd
MG
17#include <sound/core.h>
18
19#include "midi.h"
20
129b3be6
TI
21#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
705ececd 27#define LINE6_TIMEOUT 1
705ececd
MG
28#define LINE6_BUFSIZE_LISTEN 32
29#define LINE6_MESSAGE_MAXLEN 256
30
705ececd 31/*
c6fffce9 32 Line 6 MIDI control commands
705ececd
MG
33*/
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
e1a164d7 51#define LINE6_CHANNEL_UNKNOWN 5 /* don't know yet what this is good for */
705ececd
MG
52
53#define LINE6_CHANNEL_MASK 0x0f
54
027360c5
GKH
55#define CHECK_STARTUP_PROGRESS(x, n) \
56do { \
57 if ((x) >= (n)) \
58 return; \
59 x = (n); \
60} while (0)
1027f476 61
705ececd 62extern const unsigned char line6_midi_id[3];
705ececd
MG
63
64static const int SYSEX_DATA_OFS = sizeof(line6_midi_id) + 3;
65static const int SYSEX_EXTRA_SIZE = sizeof(line6_midi_id) + 4;
66
cddbd4f1 67/*
c6fffce9 68 Common properties of Line 6 devices.
705ececd
MG
69*/
70struct line6_properties {
cddbd4f1
TI
71 /* Card id string (maximum 16 characters).
72 * This can be used to address the device in ALSA programs as
73 * "default:CARD=<id>"
74 */
1027f476
MG
75 const char *id;
76
cddbd4f1 77 /* Card short name (maximum 32 characters) */
705ececd 78 const char *name;
1027f476 79
cddbd4f1 80 /* Bit vector defining this device's capabilities in line6usb driver */
705ececd 81 int capabilities;
7b9584fa
CR
82
83 int altsetting;
9e165be7
CR
84
85 unsigned ep_ctrl_r;
86 unsigned ep_ctrl_w;
16d603d3
CR
87 unsigned ep_audio_r;
88 unsigned ep_audio_w;
705ececd
MG
89};
90
129b3be6
TI
91/* 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
cddbd4f1 101/*
c6fffce9 102 Common data shared by all Line 6 devices.
705ececd
MG
103 Corresponds to a pair of USB endpoints.
104*/
105struct usb_line6 {
cddbd4f1 106 /* USB device */
705ececd
MG
107 struct usb_device *usbdev;
108
cddbd4f1 109 /* Properties */
705ececd
MG
110 const struct line6_properties *properties;
111
cddbd4f1 112 /* Interval (ms) */
705ececd 113 int interval;
b2233d97
AK
114 /* Number of isochronous URBs used for frame transfers */
115 int iso_buffers;
705ececd 116
cddbd4f1 117 /* Maximum size of USB packet */
705ececd
MG
118 int max_packet_size;
119
cddbd4f1 120 /* Device representing the USB interface */
705ececd
MG
121 struct device *ifcdev;
122
cddbd4f1
TI
123 /* Line 6 sound card data structure.
124 * Each device has at least MIDI or PCM.
125 */
705ececd
MG
126 struct snd_card *card;
127
cddbd4f1 128 /* Line 6 PCM device data structure */
705ececd
MG
129 struct snd_line6_pcm *line6pcm;
130
cddbd4f1 131 /* Line 6 MIDI device data structure */
705ececd
MG
132 struct snd_line6_midi *line6midi;
133
cddbd4f1 134 /* URB for listening to PODxt Pro control endpoint */
705ececd
MG
135 struct urb *urb_listen;
136
cddbd4f1 137 /* Buffer for listening to PODxt Pro control endpoint */
705ececd
MG
138 unsigned char *buffer_listen;
139
cddbd4f1 140 /* Buffer for message to be processed */
705ececd
MG
141 unsigned char *buffer_message;
142
cddbd4f1 143 /* Length of message to be processed */
705ececd 144 int message_length;
01f6b2bc
CR
145
146 void (*process_message)(struct usb_line6 *);
f66fd990 147 void (*disconnect)(struct usb_line6 *line6);
705ececd
MG
148};
149
a49e4838
GKH
150extern char *line6_alloc_sysex_buffer(struct usb_line6 *line6, int code1,
151 int code2, int size);
25a0707c
CR
152extern int line6_read_data(struct usb_line6 *line6, unsigned address,
153 void *data, unsigned datalen);
a49e4838 154extern int line6_read_serial_number(struct usb_line6 *line6,
12b00157 155 u32 *serial_number);
a49e4838
GKH
156extern int line6_send_raw_message_async(struct usb_line6 *line6,
157 const char *buffer, int size);
158extern int line6_send_sysex_message(struct usb_line6 *line6,
159 const char *buffer, int size);
160extern ssize_t line6_set_raw(struct device *dev, struct device_attribute *attr,
161 const char *buf, size_t count);
6ccd93bd 162extern void line6_start_timer(struct timer_list *timer, unsigned long msecs,
56733e97 163 void (*function)(unsigned long),
e1a164d7 164 unsigned long data);
1027f476 165extern int line6_version_request_async(struct usb_line6 *line6);
25a0707c
CR
166extern int line6_write_data(struct usb_line6 *line6, unsigned address,
167 void *data, unsigned datalen);
1027f476 168
ccddbe4a 169int line6_probe(struct usb_interface *interface,
f66fd990 170 const struct usb_device_id *id,
12865cac 171 const char *driver_name,
ccddbe4a 172 const struct line6_properties *properties,
aca514b8
TI
173 int (*private_init)(struct usb_line6 *, const struct usb_device_id *id),
174 size_t data_size);
f66fd990 175
ccddbe4a
TI
176void line6_disconnect(struct usb_interface *interface);
177
178#ifdef CONFIG_PM
179int line6_suspend(struct usb_interface *interface, pm_message_t message);
180int line6_resume(struct usb_interface *interface);
181#endif
182
705ececd 183#endif