2019-05-31 16:09:32 +08:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-only
|
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
|
|
|
* Emil Myhrman (emil.myhrman@gmail.com)
|
|
|
|
*/
|
|
|
|
|
2010-08-12 07:35:30 +08:00
|
|
|
#include <linux/wait.h>
|
2015-01-15 15:22:31 +08:00
|
|
|
#include <linux/usb.h>
|
|
|
|
#include <linux/slab.h>
|
|
|
|
#include <linux/module.h>
|
2015-01-20 16:36:31 +08:00
|
|
|
#include <linux/leds.h>
|
2015-01-15 15:22:31 +08:00
|
|
|
#include <sound/core.h>
|
2010-08-12 07:35:30 +08:00
|
|
|
#include <sound/control.h>
|
2009-02-28 11:43:04 +08:00
|
|
|
|
|
|
|
#include "capture.h"
|
2010-08-12 07:35:30 +08:00
|
|
|
#include "driver.h"
|
2009-02-28 11:43:04 +08:00
|
|
|
#include "playback.h"
|
2015-01-15 15:22:31 +08:00
|
|
|
|
|
|
|
enum line6_device_type {
|
|
|
|
LINE6_GUITARPORT,
|
|
|
|
LINE6_PODSTUDIO_GX,
|
|
|
|
LINE6_PODSTUDIO_UX1,
|
|
|
|
LINE6_PODSTUDIO_UX2,
|
|
|
|
LINE6_TONEPORT_GX,
|
|
|
|
LINE6_TONEPORT_UX1,
|
|
|
|
LINE6_TONEPORT_UX2,
|
|
|
|
};
|
|
|
|
|
2015-01-20 16:36:31 +08:00
|
|
|
struct usb_line6_toneport;
|
|
|
|
|
|
|
|
struct toneport_led {
|
|
|
|
struct led_classdev dev;
|
|
|
|
char name[64];
|
|
|
|
struct usb_line6_toneport *toneport;
|
|
|
|
bool registered;
|
|
|
|
};
|
|
|
|
|
2015-01-15 15:22:31 +08:00
|
|
|
struct usb_line6_toneport {
|
2015-01-28 21:43:11 +08:00
|
|
|
/* Generic Line 6 USB data */
|
2015-01-15 15:22:31 +08:00
|
|
|
struct usb_line6 line6;
|
|
|
|
|
2015-01-28 21:43:11 +08:00
|
|
|
/* Source selector */
|
2015-01-15 15:22:31 +08:00
|
|
|
int source;
|
|
|
|
|
2015-01-28 21:43:11 +08:00
|
|
|
/* Serial number of device */
|
2015-02-11 13:03:16 +08:00
|
|
|
u32 serial_number;
|
2015-01-15 15:22:31 +08:00
|
|
|
|
2015-01-28 21:43:11 +08:00
|
|
|
/* Firmware version (x 100) */
|
2015-02-11 13:03:17 +08:00
|
|
|
u8 firmware_version;
|
2015-01-15 15:22:31 +08:00
|
|
|
|
2015-01-28 21:43:11 +08:00
|
|
|
/* Device type */
|
2015-01-15 15:22:31 +08:00
|
|
|
enum line6_device_type type;
|
2015-01-20 16:36:31 +08:00
|
|
|
|
|
|
|
/* LED instances */
|
|
|
|
struct toneport_led leds[2];
|
2015-01-15 15:22:31 +08:00
|
|
|
};
|
2009-02-28 11:43:04 +08:00
|
|
|
|
2019-05-28 15:05:31 +08:00
|
|
|
#define line6_to_toneport(x) container_of(x, struct usb_line6_toneport, line6)
|
|
|
|
|
2009-02-28 11:43:04 +08:00
|
|
|
static int toneport_send_cmd(struct usb_device *usbdev, int cmd1, int cmd2);
|
|
|
|
|
2010-08-12 07:35:30 +08:00
|
|
|
#define TONEPORT_PCM_DELAY 1
|
|
|
|
|
2009-02-28 11:43:04 +08:00
|
|
|
static struct snd_ratden toneport_ratden = {
|
|
|
|
.num_min = 44100,
|
|
|
|
.num_max = 44100,
|
|
|
|
.num_step = 1,
|
|
|
|
.den = 1
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct line6_pcm_properties toneport_pcm_properties = {
|
2015-01-28 22:08:59 +08:00
|
|
|
.playback_hw = {
|
2010-08-23 07:08:25 +08:00
|
|
|
.info = (SNDRV_PCM_INFO_MMAP |
|
|
|
|
SNDRV_PCM_INFO_INTERLEAVED |
|
|
|
|
SNDRV_PCM_INFO_BLOCK_TRANSFER |
|
|
|
|
SNDRV_PCM_INFO_MMAP_VALID |
|
|
|
|
SNDRV_PCM_INFO_PAUSE |
|
|
|
|
SNDRV_PCM_INFO_SYNC_START),
|
|
|
|
.formats = SNDRV_PCM_FMTBIT_S16_LE,
|
|
|
|
.rates = SNDRV_PCM_RATE_KNOT,
|
|
|
|
.rate_min = 44100,
|
|
|
|
.rate_max = 44100,
|
|
|
|
.channels_min = 2,
|
|
|
|
.channels_max = 2,
|
|
|
|
.buffer_bytes_max = 60000,
|
|
|
|
.period_bytes_min = 64,
|
|
|
|
.period_bytes_max = 8192,
|
|
|
|
.periods_min = 1,
|
|
|
|
.periods_max = 1024},
|
2015-01-28 22:08:59 +08:00
|
|
|
.capture_hw = {
|
2010-08-23 07:08:25 +08:00
|
|
|
.info = (SNDRV_PCM_INFO_MMAP |
|
|
|
|
SNDRV_PCM_INFO_INTERLEAVED |
|
|
|
|
SNDRV_PCM_INFO_BLOCK_TRANSFER |
|
|
|
|
SNDRV_PCM_INFO_MMAP_VALID |
|
|
|
|
SNDRV_PCM_INFO_SYNC_START),
|
|
|
|
.formats = SNDRV_PCM_FMTBIT_S16_LE,
|
|
|
|
.rates = SNDRV_PCM_RATE_KNOT,
|
|
|
|
.rate_min = 44100,
|
|
|
|
.rate_max = 44100,
|
|
|
|
.channels_min = 2,
|
|
|
|
.channels_max = 2,
|
|
|
|
.buffer_bytes_max = 60000,
|
|
|
|
.period_bytes_min = 64,
|
|
|
|
.period_bytes_max = 8192,
|
|
|
|
.periods_min = 1,
|
|
|
|
.periods_max = 1024},
|
2015-01-28 22:08:59 +08:00
|
|
|
.rates = {
|
2010-08-23 07:08:25 +08:00
|
|
|
.nrats = 1,
|
|
|
|
.rats = &toneport_ratden},
|
2016-09-19 02:59:24 +08:00
|
|
|
.bytes_per_channel = 2
|
2009-02-28 11:43:04 +08:00
|
|
|
};
|
|
|
|
|
2013-01-12 06:08:13 +08:00
|
|
|
static const struct {
|
2010-08-12 07:35:30 +08:00
|
|
|
const char *name;
|
|
|
|
int code;
|
2013-01-12 06:08:13 +08:00
|
|
|
} toneport_source_info[] = {
|
2010-08-23 07:08:25 +08:00
|
|
|
{"Microphone", 0x0a01},
|
|
|
|
{"Line", 0x0801},
|
|
|
|
{"Instrument", 0x0b01},
|
|
|
|
{"Inst & Mic", 0x0901}
|
2010-08-12 07:35:30 +08:00
|
|
|
};
|
|
|
|
|
2009-02-28 11:43:04 +08:00
|
|
|
static int toneport_send_cmd(struct usb_device *usbdev, int cmd1, int cmd2)
|
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
|
2009-02-28 14:43:45 +08:00
|
|
|
ret = usb_control_msg(usbdev, usb_sndctrlpipe(usbdev, 0), 0x67,
|
|
|
|
USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_OUT,
|
|
|
|
cmd1, cmd2, NULL, 0, LINE6_TIMEOUT * HZ);
|
|
|
|
|
|
|
|
if (ret < 0) {
|
2012-04-21 07:53:32 +08:00
|
|
|
dev_err(&usbdev->dev, "send failed (error %d)\n", ret);
|
2009-02-28 11:43:04 +08:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2010-08-12 07:35:30 +08:00
|
|
|
/* monitor info callback */
|
|
|
|
static int snd_toneport_monitor_info(struct snd_kcontrol *kcontrol,
|
|
|
|
struct snd_ctl_elem_info *uinfo)
|
|
|
|
{
|
|
|
|
uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
|
|
|
|
uinfo->count = 1;
|
|
|
|
uinfo->value.integer.min = 0;
|
|
|
|
uinfo->value.integer.max = 256;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* monitor get callback */
|
|
|
|
static int snd_toneport_monitor_get(struct snd_kcontrol *kcontrol,
|
|
|
|
struct snd_ctl_elem_value *ucontrol)
|
|
|
|
{
|
|
|
|
struct snd_line6_pcm *line6pcm = snd_kcontrol_chip(kcontrol);
|
2014-04-24 15:31:48 +08:00
|
|
|
|
2010-08-12 07:35:30 +08:00
|
|
|
ucontrol->value.integer.value[0] = line6pcm->volume_monitor;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* monitor put callback */
|
|
|
|
static int snd_toneport_monitor_put(struct snd_kcontrol *kcontrol,
|
|
|
|
struct snd_ctl_elem_value *ucontrol)
|
|
|
|
{
|
|
|
|
struct snd_line6_pcm *line6pcm = snd_kcontrol_chip(kcontrol);
|
2015-01-27 23:42:14 +08:00
|
|
|
int err;
|
2010-08-12 07:35:30 +08:00
|
|
|
|
2010-08-23 07:08:25 +08:00
|
|
|
if (ucontrol->value.integer.value[0] == line6pcm->volume_monitor)
|
2010-08-12 07:35:30 +08:00
|
|
|
return 0;
|
|
|
|
|
|
|
|
line6pcm->volume_monitor = ucontrol->value.integer.value[0];
|
2010-08-23 07:08:25 +08:00
|
|
|
|
2015-01-27 23:42:14 +08:00
|
|
|
if (line6pcm->volume_monitor > 0) {
|
2016-09-19 02:59:25 +08:00
|
|
|
err = line6_pcm_acquire(line6pcm, LINE6_STREAM_MONITOR, true);
|
2015-01-27 23:42:14 +08:00
|
|
|
if (err < 0) {
|
|
|
|
line6pcm->volume_monitor = 0;
|
|
|
|
line6_pcm_release(line6pcm, LINE6_STREAM_MONITOR);
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
} else {
|
2015-01-27 22:24:09 +08:00
|
|
|
line6_pcm_release(line6pcm, LINE6_STREAM_MONITOR);
|
2015-01-27 23:42:14 +08:00
|
|
|
}
|
2010-08-23 07:08:25 +08:00
|
|
|
|
2010-08-12 07:35:30 +08:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* source info callback */
|
|
|
|
static int snd_toneport_source_info(struct snd_kcontrol *kcontrol,
|
|
|
|
struct snd_ctl_elem_info *uinfo)
|
|
|
|
{
|
|
|
|
const int size = ARRAY_SIZE(toneport_source_info);
|
2014-03-25 06:46:31 +08:00
|
|
|
|
2010-08-12 07:35:30 +08:00
|
|
|
uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
|
|
|
|
uinfo->count = 1;
|
|
|
|
uinfo->value.enumerated.items = size;
|
|
|
|
|
2010-08-23 07:08:25 +08:00
|
|
|
if (uinfo->value.enumerated.item >= size)
|
2010-08-12 07:35:30 +08:00
|
|
|
uinfo->value.enumerated.item = size - 1;
|
|
|
|
|
|
|
|
strcpy(uinfo->value.enumerated.name,
|
|
|
|
toneport_source_info[uinfo->value.enumerated.item].name);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* source get callback */
|
|
|
|
static int snd_toneport_source_get(struct snd_kcontrol *kcontrol,
|
|
|
|
struct snd_ctl_elem_value *ucontrol)
|
|
|
|
{
|
|
|
|
struct snd_line6_pcm *line6pcm = snd_kcontrol_chip(kcontrol);
|
2019-05-28 15:05:31 +08:00
|
|
|
struct usb_line6_toneport *toneport = line6_to_toneport(line6pcm->line6);
|
|
|
|
|
2010-08-12 07:35:30 +08:00
|
|
|
ucontrol->value.enumerated.item[0] = toneport->source;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* source put callback */
|
|
|
|
static int snd_toneport_source_put(struct snd_kcontrol *kcontrol,
|
|
|
|
struct snd_ctl_elem_value *ucontrol)
|
|
|
|
{
|
|
|
|
struct snd_line6_pcm *line6pcm = snd_kcontrol_chip(kcontrol);
|
2019-05-28 15:05:31 +08:00
|
|
|
struct usb_line6_toneport *toneport = line6_to_toneport(line6pcm->line6);
|
2013-09-13 16:07:13 +08:00
|
|
|
unsigned int source;
|
2010-08-12 07:35:30 +08:00
|
|
|
|
2013-09-13 16:07:13 +08:00
|
|
|
source = ucontrol->value.enumerated.item[0];
|
|
|
|
if (source >= ARRAY_SIZE(toneport_source_info))
|
|
|
|
return -EINVAL;
|
|
|
|
if (source == toneport->source)
|
2010-08-12 07:35:30 +08:00
|
|
|
return 0;
|
|
|
|
|
2013-09-13 16:07:13 +08:00
|
|
|
toneport->source = source;
|
2010-08-23 07:08:25 +08:00
|
|
|
toneport_send_cmd(toneport->line6.usbdev,
|
2013-09-13 16:07:13 +08:00
|
|
|
toneport_source_info[source].code, 0x0000);
|
2010-08-12 07:35:30 +08:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2019-05-28 14:39:44 +08:00
|
|
|
static void toneport_startup(struct usb_line6 *line6)
|
2010-08-12 07:35:30 +08:00
|
|
|
{
|
2016-09-19 02:59:25 +08:00
|
|
|
line6_pcm_acquire(line6->line6pcm, LINE6_STREAM_MONITOR, true);
|
2010-08-12 07:35:30 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* control definition */
|
2017-04-12 21:10:47 +08:00
|
|
|
static const struct snd_kcontrol_new toneport_control_monitor = {
|
2010-08-12 07:35:30 +08:00
|
|
|
.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
|
|
|
|
.name = "Monitor Playback Volume",
|
|
|
|
.index = 0,
|
|
|
|
.access = SNDRV_CTL_ELEM_ACCESS_READWRITE,
|
|
|
|
.info = snd_toneport_monitor_info,
|
|
|
|
.get = snd_toneport_monitor_get,
|
|
|
|
.put = snd_toneport_monitor_put
|
|
|
|
};
|
|
|
|
|
|
|
|
/* source selector definition */
|
2017-04-12 21:10:47 +08:00
|
|
|
static const struct snd_kcontrol_new toneport_control_source = {
|
2010-08-12 07:35:30 +08:00
|
|
|
.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
|
|
|
|
.name = "PCM Capture Source",
|
|
|
|
.index = 0,
|
|
|
|
.access = SNDRV_CTL_ELEM_ACCESS_READWRITE,
|
|
|
|
.info = snd_toneport_source_info,
|
|
|
|
.get = snd_toneport_source_get,
|
|
|
|
.put = snd_toneport_source_put
|
|
|
|
};
|
|
|
|
|
2015-01-20 16:36:31 +08:00
|
|
|
/*
|
|
|
|
For the led on Guitarport.
|
|
|
|
Brightness goes from 0x00 to 0x26. Set a value above this to have led
|
|
|
|
blink.
|
|
|
|
(void cmd_0x02(byte red, byte green)
|
|
|
|
*/
|
|
|
|
|
2015-02-08 00:43:18 +08:00
|
|
|
static bool toneport_has_led(struct usb_line6_toneport *toneport)
|
2015-01-20 16:36:31 +08:00
|
|
|
{
|
2015-02-08 00:43:18 +08:00
|
|
|
switch (toneport->type) {
|
|
|
|
case LINE6_GUITARPORT:
|
|
|
|
case LINE6_TONEPORT_GX:
|
2015-01-20 16:36:31 +08:00
|
|
|
/* add your device here if you are missing support for the LEDs */
|
2015-02-08 00:43:18 +08:00
|
|
|
return true;
|
|
|
|
|
|
|
|
default:
|
|
|
|
return false;
|
|
|
|
}
|
2015-01-20 16:36:31 +08:00
|
|
|
}
|
|
|
|
|
2019-04-07 01:04:44 +08:00
|
|
|
static const char * const toneport_led_colors[2] = { "red", "green" };
|
|
|
|
static const int toneport_led_init_vals[2] = { 0x00, 0x26 };
|
2015-01-20 16:36:31 +08:00
|
|
|
|
|
|
|
static void toneport_update_led(struct usb_line6_toneport *toneport)
|
|
|
|
{
|
|
|
|
toneport_send_cmd(toneport->line6.usbdev,
|
|
|
|
(toneport->leds[0].dev.brightness << 8) | 0x0002,
|
|
|
|
toneport->leds[1].dev.brightness);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void toneport_led_brightness_set(struct led_classdev *led_cdev,
|
|
|
|
enum led_brightness brightness)
|
|
|
|
{
|
|
|
|
struct toneport_led *leds =
|
|
|
|
container_of(led_cdev, struct toneport_led, dev);
|
|
|
|
toneport_update_led(leds->toneport);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int toneport_init_leds(struct usb_line6_toneport *toneport)
|
|
|
|
{
|
|
|
|
struct device *dev = &toneport->line6.usbdev->dev;
|
|
|
|
int i, err;
|
|
|
|
|
|
|
|
for (i = 0; i < 2; i++) {
|
|
|
|
struct toneport_led *led = &toneport->leds[i];
|
|
|
|
struct led_classdev *leddev = &led->dev;
|
|
|
|
|
|
|
|
led->toneport = toneport;
|
|
|
|
snprintf(led->name, sizeof(led->name), "%s::%s",
|
2019-04-07 01:04:44 +08:00
|
|
|
dev_name(dev), toneport_led_colors[i]);
|
2015-01-20 16:36:31 +08:00
|
|
|
leddev->name = led->name;
|
2019-04-07 01:04:44 +08:00
|
|
|
leddev->brightness = toneport_led_init_vals[i];
|
2015-01-20 16:36:31 +08:00
|
|
|
leddev->max_brightness = 0x26;
|
|
|
|
leddev->brightness_set = toneport_led_brightness_set;
|
|
|
|
err = led_classdev_register(dev, leddev);
|
|
|
|
if (err)
|
|
|
|
return err;
|
|
|
|
led->registered = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void toneport_remove_leds(struct usb_line6_toneport *toneport)
|
|
|
|
{
|
|
|
|
struct toneport_led *led;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < 2; i++) {
|
|
|
|
led = &toneport->leds[i];
|
|
|
|
if (!led->registered)
|
|
|
|
break;
|
|
|
|
led_classdev_unregister(&led->dev);
|
|
|
|
led->registered = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-02-08 00:43:17 +08:00
|
|
|
static bool toneport_has_source_select(struct usb_line6_toneport *toneport)
|
|
|
|
{
|
|
|
|
switch (toneport->type) {
|
|
|
|
case LINE6_TONEPORT_UX1:
|
|
|
|
case LINE6_TONEPORT_UX2:
|
|
|
|
case LINE6_PODSTUDIO_UX1:
|
|
|
|
case LINE6_PODSTUDIO_UX2:
|
|
|
|
return true;
|
|
|
|
|
|
|
|
default:
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-02-28 11:43:04 +08:00
|
|
|
/*
|
2010-08-12 07:35:30 +08:00
|
|
|
Setup Toneport device.
|
2009-02-28 11:43:04 +08:00
|
|
|
*/
|
2019-04-29 00:04:11 +08:00
|
|
|
static int toneport_setup(struct usb_line6_toneport *toneport)
|
2009-02-28 11:43:04 +08:00
|
|
|
{
|
2019-04-29 00:04:11 +08:00
|
|
|
u32 *ticks;
|
2009-02-28 11:43:04 +08:00
|
|
|
struct usb_line6 *line6 = &toneport->line6;
|
2010-08-12 07:35:30 +08:00
|
|
|
struct usb_device *usbdev = line6->usbdev;
|
|
|
|
|
2019-04-29 00:04:11 +08:00
|
|
|
ticks = kmalloc(sizeof(*ticks), GFP_KERNEL);
|
|
|
|
if (!ticks)
|
|
|
|
return -ENOMEM;
|
|
|
|
|
2010-08-12 07:35:30 +08:00
|
|
|
/* sync time on device with host: */
|
2018-06-18 23:41:01 +08:00
|
|
|
/* note: 32-bit timestamps overflow in year 2106 */
|
2019-04-29 00:04:11 +08:00
|
|
|
*ticks = (u32)ktime_get_real_seconds();
|
|
|
|
line6_write_data(line6, 0x80c6, ticks, 4);
|
|
|
|
kfree(ticks);
|
2010-08-12 07:35:30 +08:00
|
|
|
|
|
|
|
/* enable device: */
|
|
|
|
toneport_send_cmd(usbdev, 0x0301, 0x0000);
|
|
|
|
|
|
|
|
/* initialize source select: */
|
2015-02-08 00:43:17 +08:00
|
|
|
if (toneport_has_source_select(toneport))
|
2010-08-23 07:08:25 +08:00
|
|
|
toneport_send_cmd(usbdev,
|
|
|
|
toneport_source_info[toneport->source].code,
|
|
|
|
0x0000);
|
2010-08-12 07:35:30 +08:00
|
|
|
|
2015-02-08 00:43:18 +08:00
|
|
|
if (toneport_has_led(toneport))
|
2015-01-20 16:36:31 +08:00
|
|
|
toneport_update_led(toneport);
|
2015-01-20 16:40:20 +08:00
|
|
|
|
2019-05-28 14:39:44 +08:00
|
|
|
schedule_delayed_work(&toneport->line6.startup_work,
|
2019-05-08 21:01:24 +08:00
|
|
|
msecs_to_jiffies(TONEPORT_PCM_DELAY * 1000));
|
2019-04-29 00:04:11 +08:00
|
|
|
return 0;
|
2010-08-12 07:35:30 +08:00
|
|
|
}
|
|
|
|
|
2015-01-13 04:43:00 +08:00
|
|
|
/*
|
|
|
|
Toneport device disconnected.
|
|
|
|
*/
|
2015-01-26 01:22:58 +08:00
|
|
|
static void line6_toneport_disconnect(struct usb_line6 *line6)
|
2015-01-13 04:43:00 +08:00
|
|
|
{
|
2019-05-28 15:05:31 +08:00
|
|
|
struct usb_line6_toneport *toneport = line6_to_toneport(line6);
|
2015-01-13 04:43:00 +08:00
|
|
|
|
2015-02-08 00:43:18 +08:00
|
|
|
if (toneport_has_led(toneport))
|
2015-01-20 16:36:31 +08:00
|
|
|
toneport_remove_leds(toneport);
|
2015-01-13 04:43:00 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-08-12 07:35:30 +08:00
|
|
|
/*
|
|
|
|
Try to init Toneport device.
|
|
|
|
*/
|
2015-01-26 01:22:58 +08:00
|
|
|
static int toneport_init(struct usb_line6 *line6,
|
|
|
|
const struct usb_device_id *id)
|
2010-08-12 07:35:30 +08:00
|
|
|
{
|
|
|
|
int err;
|
2019-05-28 15:05:31 +08:00
|
|
|
struct usb_line6_toneport *toneport = line6_to_toneport(line6);
|
2009-02-28 11:43:04 +08:00
|
|
|
|
2015-01-26 01:22:58 +08:00
|
|
|
toneport->type = id->driver_info;
|
2015-01-20 16:40:20 +08:00
|
|
|
|
2015-01-13 04:42:59 +08:00
|
|
|
line6->disconnect = line6_toneport_disconnect;
|
2019-05-28 14:39:44 +08:00
|
|
|
line6->startup = toneport_startup;
|
2015-01-13 04:42:59 +08:00
|
|
|
|
2009-02-28 11:43:04 +08:00
|
|
|
/* initialize PCM subsystem: */
|
2009-02-28 14:43:45 +08:00
|
|
|
err = line6_init_pcm(line6, &toneport_pcm_properties);
|
2010-09-22 07:58:00 +08:00
|
|
|
if (err < 0)
|
2009-02-28 11:43:04 +08:00
|
|
|
return err;
|
|
|
|
|
2010-08-12 07:35:30 +08:00
|
|
|
/* register monitor control: */
|
2010-09-22 07:58:00 +08:00
|
|
|
err = snd_ctl_add(line6->card,
|
|
|
|
snd_ctl_new1(&toneport_control_monitor,
|
|
|
|
line6->line6pcm));
|
|
|
|
if (err < 0)
|
2010-08-12 07:35:30 +08:00
|
|
|
return err;
|
|
|
|
|
|
|
|
/* register source select control: */
|
2015-02-08 00:43:17 +08:00
|
|
|
if (toneport_has_source_select(toneport)) {
|
2010-08-23 07:08:25 +08:00
|
|
|
err =
|
|
|
|
snd_ctl_add(line6->card,
|
|
|
|
snd_ctl_new1(&toneport_control_source,
|
|
|
|
line6->line6pcm));
|
2010-09-22 07:58:00 +08:00
|
|
|
if (err < 0)
|
2010-08-12 07:35:30 +08:00
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
2009-02-28 11:43:04 +08:00
|
|
|
line6_read_serial_number(line6, &toneport->serial_number);
|
|
|
|
line6_read_data(line6, 0x80c2, &toneport->firmware_version, 1);
|
|
|
|
|
2015-02-08 00:43:18 +08:00
|
|
|
if (toneport_has_led(toneport)) {
|
2015-01-20 16:36:31 +08:00
|
|
|
err = toneport_init_leds(toneport);
|
2015-01-19 23:08:02 +08:00
|
|
|
if (err < 0)
|
|
|
|
return err;
|
2010-08-12 07:35:30 +08:00
|
|
|
}
|
2009-02-28 11:43:04 +08:00
|
|
|
|
2019-04-29 00:04:11 +08:00
|
|
|
err = toneport_setup(toneport);
|
|
|
|
if (err)
|
|
|
|
return err;
|
2009-02-28 11:43:04 +08:00
|
|
|
|
2015-01-19 22:54:00 +08:00
|
|
|
/* register audio system: */
|
|
|
|
return snd_card_register(line6->card);
|
2010-08-12 07:35:30 +08:00
|
|
|
}
|
|
|
|
|
2015-01-15 15:22:31 +08:00
|
|
|
#ifdef CONFIG_PM
|
2010-08-12 07:35:30 +08:00
|
|
|
/*
|
|
|
|
Resume Toneport device after reset.
|
|
|
|
*/
|
2015-01-15 15:22:31 +08:00
|
|
|
static int toneport_reset_resume(struct usb_interface *interface)
|
2010-08-12 07:35:30 +08:00
|
|
|
{
|
2019-04-29 00:04:11 +08:00
|
|
|
int err;
|
|
|
|
|
|
|
|
err = toneport_setup(usb_get_intfdata(interface));
|
|
|
|
if (err)
|
|
|
|
return err;
|
2015-01-15 15:22:31 +08:00
|
|
|
return line6_resume(interface);
|
2010-08-12 07:35:30 +08:00
|
|
|
}
|
2015-01-15 15:22:31 +08:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#define LINE6_DEVICE(prod) USB_DEVICE(0x0e41, prod)
|
|
|
|
#define LINE6_IF_NUM(prod, n) USB_DEVICE_INTERFACE_NUMBER(0x0e41, prod, n)
|
|
|
|
|
|
|
|
/* table of devices that work with this driver */
|
|
|
|
static const struct usb_device_id toneport_id_table[] = {
|
|
|
|
{ LINE6_DEVICE(0x4750), .driver_info = LINE6_GUITARPORT },
|
|
|
|
{ LINE6_DEVICE(0x4153), .driver_info = LINE6_PODSTUDIO_GX },
|
|
|
|
{ LINE6_DEVICE(0x4150), .driver_info = LINE6_PODSTUDIO_UX1 },
|
|
|
|
{ LINE6_IF_NUM(0x4151, 0), .driver_info = LINE6_PODSTUDIO_UX2 },
|
|
|
|
{ LINE6_DEVICE(0x4147), .driver_info = LINE6_TONEPORT_GX },
|
|
|
|
{ LINE6_DEVICE(0x4141), .driver_info = LINE6_TONEPORT_UX1 },
|
|
|
|
{ LINE6_IF_NUM(0x4142, 0), .driver_info = LINE6_TONEPORT_UX2 },
|
|
|
|
{}
|
|
|
|
};
|
|
|
|
|
|
|
|
MODULE_DEVICE_TABLE(usb, toneport_id_table);
|
|
|
|
|
|
|
|
static const struct line6_properties toneport_properties_table[] = {
|
|
|
|
[LINE6_GUITARPORT] = {
|
|
|
|
.id = "GuitarPort",
|
|
|
|
.name = "GuitarPort",
|
|
|
|
.capabilities = LINE6_CAP_PCM,
|
|
|
|
.altsetting = 2, /* 1..4 seem to be ok */
|
|
|
|
/* no control channel */
|
|
|
|
.ep_audio_r = 0x82,
|
|
|
|
.ep_audio_w = 0x01,
|
|
|
|
},
|
|
|
|
[LINE6_PODSTUDIO_GX] = {
|
|
|
|
.id = "PODStudioGX",
|
|
|
|
.name = "POD Studio GX",
|
|
|
|
.capabilities = LINE6_CAP_PCM,
|
|
|
|
.altsetting = 2, /* 1..4 seem to be ok */
|
|
|
|
/* no control channel */
|
|
|
|
.ep_audio_r = 0x82,
|
|
|
|
.ep_audio_w = 0x01,
|
|
|
|
},
|
|
|
|
[LINE6_PODSTUDIO_UX1] = {
|
|
|
|
.id = "PODStudioUX1",
|
|
|
|
.name = "POD Studio UX1",
|
|
|
|
.capabilities = LINE6_CAP_PCM,
|
|
|
|
.altsetting = 2, /* 1..4 seem to be ok */
|
|
|
|
/* no control channel */
|
|
|
|
.ep_audio_r = 0x82,
|
|
|
|
.ep_audio_w = 0x01,
|
|
|
|
},
|
|
|
|
[LINE6_PODSTUDIO_UX2] = {
|
|
|
|
.id = "PODStudioUX2",
|
|
|
|
.name = "POD Studio UX2",
|
|
|
|
.capabilities = LINE6_CAP_PCM,
|
|
|
|
.altsetting = 2, /* defaults to 44.1kHz, 16-bit */
|
|
|
|
/* no control channel */
|
|
|
|
.ep_audio_r = 0x82,
|
|
|
|
.ep_audio_w = 0x01,
|
|
|
|
},
|
|
|
|
[LINE6_TONEPORT_GX] = {
|
|
|
|
.id = "TonePortGX",
|
|
|
|
.name = "TonePort GX",
|
|
|
|
.capabilities = LINE6_CAP_PCM,
|
|
|
|
.altsetting = 2, /* 1..4 seem to be ok */
|
|
|
|
/* no control channel */
|
|
|
|
.ep_audio_r = 0x82,
|
|
|
|
.ep_audio_w = 0x01,
|
|
|
|
},
|
|
|
|
[LINE6_TONEPORT_UX1] = {
|
|
|
|
.id = "TonePortUX1",
|
|
|
|
.name = "TonePort UX1",
|
|
|
|
.capabilities = LINE6_CAP_PCM,
|
|
|
|
.altsetting = 2, /* 1..4 seem to be ok */
|
|
|
|
/* no control channel */
|
|
|
|
.ep_audio_r = 0x82,
|
|
|
|
.ep_audio_w = 0x01,
|
|
|
|
},
|
|
|
|
[LINE6_TONEPORT_UX2] = {
|
|
|
|
.id = "TonePortUX2",
|
|
|
|
.name = "TonePort UX2",
|
|
|
|
.capabilities = LINE6_CAP_PCM,
|
|
|
|
.altsetting = 2, /* defaults to 44.1kHz, 16-bit */
|
|
|
|
/* no control channel */
|
|
|
|
.ep_audio_r = 0x82,
|
|
|
|
.ep_audio_w = 0x01,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
Probe USB device.
|
|
|
|
*/
|
|
|
|
static int toneport_probe(struct usb_interface *interface,
|
|
|
|
const struct usb_device_id *id)
|
|
|
|
{
|
2015-02-08 00:43:19 +08:00
|
|
|
return line6_probe(interface, id, "Line6-TonePort",
|
2015-01-19 22:54:00 +08:00
|
|
|
&toneport_properties_table[id->driver_info],
|
2015-01-26 01:36:29 +08:00
|
|
|
toneport_init, sizeof(struct usb_line6_toneport));
|
2015-01-15 15:22:31 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static struct usb_driver toneport_driver = {
|
|
|
|
.name = KBUILD_MODNAME,
|
|
|
|
.probe = toneport_probe,
|
|
|
|
.disconnect = line6_disconnect,
|
|
|
|
#ifdef CONFIG_PM
|
|
|
|
.suspend = line6_suspend,
|
|
|
|
.resume = line6_resume,
|
|
|
|
.reset_resume = toneport_reset_resume,
|
|
|
|
#endif
|
|
|
|
.id_table = toneport_id_table,
|
|
|
|
};
|
|
|
|
|
|
|
|
module_usb_driver(toneport_driver);
|
|
|
|
|
|
|
|
MODULE_DESCRIPTION("TonePort USB driver");
|
|
|
|
MODULE_LICENSE("GPL");
|