2009-02-28 11:43:04 +08:00
|
|
|
/*
|
2015-01-20 16:20:50 +08:00
|
|
|
* Line 6 Linux USB driver
|
2009-02-28 11:43:04 +08:00
|
|
|
*
|
2010-08-12 07:35:30 +08:00
|
|
|
* Copyright (C) 2004-2010 Markus Grabner (grabner@icg.tugraz.at)
|
2009-02-28 11:43:04 +08:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License as
|
|
|
|
* published by the Free Software Foundation, version 2.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef DRIVER_H
|
|
|
|
#define DRIVER_H
|
|
|
|
|
|
|
|
#include <linux/spinlock.h>
|
|
|
|
#include <linux/usb.h>
|
|
|
|
#include <sound/core.h>
|
|
|
|
|
|
|
|
#include "midi.h"
|
|
|
|
|
|
|
|
#define DRIVER_NAME "line6usb"
|
|
|
|
|
|
|
|
#define LINE6_TIMEOUT 1
|
|
|
|
#define LINE6_BUFSIZE_LISTEN 32
|
|
|
|
#define LINE6_MESSAGE_MAXLEN 256
|
|
|
|
|
|
|
|
/*
|
2015-01-20 16:20:49 +08:00
|
|
|
Line 6 MIDI control commands
|
2009-02-28 11:43:04 +08:00
|
|
|
*/
|
|
|
|
#define LINE6_PARAM_CHANGE 0xb0
|
|
|
|
#define LINE6_PROGRAM_CHANGE 0xc0
|
|
|
|
#define LINE6_SYSEX_BEGIN 0xf0
|
|
|
|
#define LINE6_SYSEX_END 0xf7
|
|
|
|
#define LINE6_RESET 0xff
|
|
|
|
|
|
|
|
/*
|
|
|
|
MIDI channel for messages initiated by the host
|
|
|
|
(and eventually echoed back by the device)
|
|
|
|
*/
|
|
|
|
#define LINE6_CHANNEL_HOST 0x00
|
|
|
|
|
|
|
|
/*
|
|
|
|
MIDI channel for messages initiated by the device
|
|
|
|
*/
|
|
|
|
#define LINE6_CHANNEL_DEVICE 0x02
|
|
|
|
|
2010-08-23 07:08:25 +08:00
|
|
|
#define LINE6_CHANNEL_UNKNOWN 5 /* don't know yet what this is good for */
|
2009-02-28 11:43:04 +08:00
|
|
|
|
|
|
|
#define LINE6_CHANNEL_MASK 0x0f
|
|
|
|
|
2010-09-22 07:58:00 +08:00
|
|
|
#define CHECK_STARTUP_PROGRESS(x, n) \
|
|
|
|
do { \
|
|
|
|
if ((x) >= (n)) \
|
|
|
|
return; \
|
|
|
|
x = (n); \
|
|
|
|
} while (0)
|
2010-08-12 07:35:30 +08:00
|
|
|
|
2009-02-28 11:43:04 +08:00
|
|
|
extern const unsigned char line6_midi_id[3];
|
|
|
|
|
|
|
|
static const int SYSEX_DATA_OFS = sizeof(line6_midi_id) + 3;
|
|
|
|
static const int SYSEX_EXTRA_SIZE = sizeof(line6_midi_id) + 4;
|
|
|
|
|
|
|
|
/**
|
2015-01-20 16:20:49 +08:00
|
|
|
Common properties of Line 6 devices.
|
2009-02-28 11:43:04 +08:00
|
|
|
*/
|
|
|
|
struct line6_properties {
|
2010-08-12 07:35:30 +08:00
|
|
|
/**
|
|
|
|
Card id string (maximum 16 characters).
|
|
|
|
This can be used to address the device in ALSA programs as
|
|
|
|
"default:CARD=<id>"
|
|
|
|
*/
|
|
|
|
const char *id;
|
|
|
|
|
|
|
|
/**
|
|
|
|
Card short name (maximum 32 characters).
|
|
|
|
*/
|
2009-02-28 11:43:04 +08:00
|
|
|
const char *name;
|
2010-08-12 07:35:30 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
Bit vector defining this device's capabilities in the
|
|
|
|
line6usb driver.
|
|
|
|
*/
|
2009-02-28 11:43:04 +08:00
|
|
|
int capabilities;
|
2015-01-13 04:42:52 +08:00
|
|
|
|
|
|
|
int altsetting;
|
2015-01-13 04:42:53 +08:00
|
|
|
|
|
|
|
unsigned ep_ctrl_r;
|
|
|
|
unsigned ep_ctrl_w;
|
2015-01-13 04:42:55 +08:00
|
|
|
unsigned ep_audio_r;
|
|
|
|
unsigned ep_audio_w;
|
2009-02-28 11:43:04 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
2015-01-20 16:20:49 +08:00
|
|
|
Common data shared by all Line 6 devices.
|
2009-02-28 11:43:04 +08:00
|
|
|
Corresponds to a pair of USB endpoints.
|
|
|
|
*/
|
|
|
|
struct usb_line6 {
|
|
|
|
/**
|
|
|
|
USB device.
|
|
|
|
*/
|
|
|
|
struct usb_device *usbdev;
|
|
|
|
|
|
|
|
/**
|
|
|
|
Properties.
|
|
|
|
*/
|
|
|
|
const struct line6_properties *properties;
|
|
|
|
|
|
|
|
/**
|
|
|
|
Interval (ms).
|
|
|
|
*/
|
|
|
|
int interval;
|
|
|
|
|
|
|
|
/**
|
|
|
|
Maximum size of USB packet.
|
|
|
|
*/
|
|
|
|
int max_packet_size;
|
|
|
|
|
|
|
|
/**
|
|
|
|
Device representing the USB interface.
|
|
|
|
*/
|
|
|
|
struct device *ifcdev;
|
|
|
|
|
|
|
|
/**
|
2015-01-20 16:20:49 +08:00
|
|
|
Line 6 sound card data structure.
|
2009-02-28 11:43:04 +08:00
|
|
|
Each device has at least MIDI or PCM.
|
|
|
|
*/
|
|
|
|
struct snd_card *card;
|
|
|
|
|
|
|
|
/**
|
2015-01-20 16:20:49 +08:00
|
|
|
Line 6 PCM device data structure.
|
2009-02-28 11:43:04 +08:00
|
|
|
*/
|
|
|
|
struct snd_line6_pcm *line6pcm;
|
|
|
|
|
|
|
|
/**
|
2015-01-20 16:20:49 +08:00
|
|
|
Line 6 MIDI device data structure.
|
2009-02-28 11:43:04 +08:00
|
|
|
*/
|
|
|
|
struct snd_line6_midi *line6midi;
|
|
|
|
|
|
|
|
/**
|
|
|
|
URB for listening to PODxt Pro control endpoint.
|
|
|
|
*/
|
|
|
|
struct urb *urb_listen;
|
|
|
|
|
|
|
|
/**
|
|
|
|
Buffer for listening to PODxt Pro control endpoint.
|
|
|
|
*/
|
|
|
|
unsigned char *buffer_listen;
|
|
|
|
|
|
|
|
/**
|
|
|
|
Buffer for message to be processed.
|
|
|
|
*/
|
|
|
|
unsigned char *buffer_message;
|
|
|
|
|
|
|
|
/**
|
|
|
|
Length of message to be processed.
|
|
|
|
*/
|
|
|
|
int message_length;
|
2015-01-13 04:42:58 +08:00
|
|
|
|
|
|
|
void (*process_message)(struct usb_line6 *);
|
2015-01-26 01:22:58 +08:00
|
|
|
void (*disconnect)(struct usb_line6 *line6);
|
2009-02-28 11:43:04 +08:00
|
|
|
};
|
|
|
|
|
2009-02-28 13:09:55 +08:00
|
|
|
extern char *line6_alloc_sysex_buffer(struct usb_line6 *line6, int code1,
|
|
|
|
int code2, int size);
|
|
|
|
extern int line6_read_data(struct usb_line6 *line6, int address, void *data,
|
|
|
|
size_t datalen);
|
|
|
|
extern int line6_read_serial_number(struct usb_line6 *line6,
|
|
|
|
int *serial_number);
|
|
|
|
extern int line6_send_raw_message_async(struct usb_line6 *line6,
|
|
|
|
const char *buffer, int size);
|
|
|
|
extern int line6_send_sysex_message(struct usb_line6 *line6,
|
|
|
|
const char *buffer, int size);
|
|
|
|
extern ssize_t line6_set_raw(struct device *dev, struct device_attribute *attr,
|
|
|
|
const char *buf, size_t count);
|
2010-08-12 07:35:30 +08:00
|
|
|
extern void line6_start_timer(struct timer_list *timer, unsigned int msecs,
|
2014-02-27 23:36:58 +08:00
|
|
|
void (*function)(unsigned long),
|
2010-08-23 07:08:25 +08:00
|
|
|
unsigned long data);
|
2010-08-12 07:35:30 +08:00
|
|
|
extern int line6_version_request_async(struct usb_line6 *line6);
|
2009-02-28 13:09:55 +08:00
|
|
|
extern int line6_write_data(struct usb_line6 *line6, int address, void *data,
|
|
|
|
size_t datalen);
|
2010-08-12 07:35:30 +08:00
|
|
|
|
2015-01-15 15:22:31 +08:00
|
|
|
int line6_probe(struct usb_interface *interface,
|
2015-01-26 01:22:58 +08:00
|
|
|
const struct usb_device_id *id,
|
2015-01-15 15:22:31 +08:00
|
|
|
const struct line6_properties *properties,
|
2015-01-26 01:36:29 +08:00
|
|
|
int (*private_init)(struct usb_line6 *, const struct usb_device_id *id),
|
|
|
|
size_t data_size);
|
2015-01-26 01:22:58 +08:00
|
|
|
|
2015-01-15 15:22:31 +08:00
|
|
|
void line6_disconnect(struct usb_interface *interface);
|
|
|
|
|
|
|
|
#ifdef CONFIG_PM
|
|
|
|
int line6_suspend(struct usb_interface *interface, pm_message_t message);
|
|
|
|
int line6_resume(struct usb_interface *interface);
|
|
|
|
#endif
|
|
|
|
|
2009-02-28 11:43:04 +08:00
|
|
|
#endif
|