^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) // SPDX-License-Identifier: GPL-2.0-only
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) * Line 6 Linux USB driver
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) * Copyright (C) 2004-2010 Markus Grabner (grabner@icg.tugraz.at)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) * Emil Myhrman (emil.myhrman@gmail.com)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) #include <linux/wait.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) #include <linux/usb.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) #include <linux/slab.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) #include <linux/module.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) #include <linux/leds.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) #include <sound/core.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) #include <sound/control.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) #include "capture.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) #include "driver.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) #include "playback.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) enum line6_device_type {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) LINE6_GUITARPORT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) LINE6_PODSTUDIO_GX,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) LINE6_PODSTUDIO_UX1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) LINE6_PODSTUDIO_UX2,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) LINE6_TONEPORT_GX,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) LINE6_TONEPORT_UX1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) LINE6_TONEPORT_UX2,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) struct usb_line6_toneport;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) struct toneport_led {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) struct led_classdev dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) char name[64];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) struct usb_line6_toneport *toneport;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) bool registered;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) struct usb_line6_toneport {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) /* Generic Line 6 USB data */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) struct usb_line6 line6;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) /* Source selector */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) int source;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) /* Serial number of device */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) u32 serial_number;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) /* Firmware version (x 100) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) u8 firmware_version;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) /* Device type */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) enum line6_device_type type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) /* LED instances */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) struct toneport_led leds[2];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) #define line6_to_toneport(x) container_of(x, struct usb_line6_toneport, line6)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) static int toneport_send_cmd(struct usb_device *usbdev, int cmd1, int cmd2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) #define TONEPORT_PCM_DELAY 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) static const struct snd_ratden toneport_ratden = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) .num_min = 44100,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) .num_max = 44100,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) .num_step = 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) .den = 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) static struct line6_pcm_properties toneport_pcm_properties = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) .playback_hw = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) .info = (SNDRV_PCM_INFO_MMAP |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) SNDRV_PCM_INFO_INTERLEAVED |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) SNDRV_PCM_INFO_BLOCK_TRANSFER |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) SNDRV_PCM_INFO_MMAP_VALID |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) SNDRV_PCM_INFO_PAUSE |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) SNDRV_PCM_INFO_SYNC_START),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) .formats = SNDRV_PCM_FMTBIT_S16_LE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) .rates = SNDRV_PCM_RATE_KNOT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) .rate_min = 44100,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) .rate_max = 44100,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) .channels_min = 2,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) .channels_max = 2,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) .buffer_bytes_max = 60000,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) .period_bytes_min = 64,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) .period_bytes_max = 8192,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) .periods_min = 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) .periods_max = 1024},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) .capture_hw = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) .info = (SNDRV_PCM_INFO_MMAP |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) SNDRV_PCM_INFO_INTERLEAVED |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) SNDRV_PCM_INFO_BLOCK_TRANSFER |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) SNDRV_PCM_INFO_MMAP_VALID |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) SNDRV_PCM_INFO_SYNC_START),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) .formats = SNDRV_PCM_FMTBIT_S16_LE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) .rates = SNDRV_PCM_RATE_KNOT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) .rate_min = 44100,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) .rate_max = 44100,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) .channels_min = 2,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) .channels_max = 2,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) .buffer_bytes_max = 60000,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) .period_bytes_min = 64,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) .period_bytes_max = 8192,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) .periods_min = 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) .periods_max = 1024},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) .rates = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) .nrats = 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) .rats = &toneport_ratden},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) .bytes_per_channel = 2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) static const struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) const char *name;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) int code;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) } toneport_source_info[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) {"Microphone", 0x0a01},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) {"Line", 0x0801},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) {"Instrument", 0x0b01},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) {"Inst & Mic", 0x0901}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) static int toneport_send_cmd(struct usb_device *usbdev, int cmd1, int cmd2)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) ret = usb_control_msg_send(usbdev, 0, 0x67,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_OUT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) cmd1, cmd2, NULL, 0, LINE6_TIMEOUT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) if (ret) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) dev_err(&usbdev->dev, "send failed (error %d)\n", ret);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) /* monitor info callback */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) static int snd_toneport_monitor_info(struct snd_kcontrol *kcontrol,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) struct snd_ctl_elem_info *uinfo)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) uinfo->count = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) uinfo->value.integer.min = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) uinfo->value.integer.max = 256;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) /* monitor get callback */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) static int snd_toneport_monitor_get(struct snd_kcontrol *kcontrol,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) struct snd_ctl_elem_value *ucontrol)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) struct snd_line6_pcm *line6pcm = snd_kcontrol_chip(kcontrol);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) ucontrol->value.integer.value[0] = line6pcm->volume_monitor;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) /* monitor put callback */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) static int snd_toneport_monitor_put(struct snd_kcontrol *kcontrol,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) struct snd_ctl_elem_value *ucontrol)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) struct snd_line6_pcm *line6pcm = snd_kcontrol_chip(kcontrol);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) int err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) if (ucontrol->value.integer.value[0] == line6pcm->volume_monitor)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) line6pcm->volume_monitor = ucontrol->value.integer.value[0];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) if (line6pcm->volume_monitor > 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) err = line6_pcm_acquire(line6pcm, LINE6_STREAM_MONITOR, true);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) if (err < 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) line6pcm->volume_monitor = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) line6_pcm_release(line6pcm, LINE6_STREAM_MONITOR);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) line6_pcm_release(line6pcm, LINE6_STREAM_MONITOR);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) return 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) /* source info callback */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) static int snd_toneport_source_info(struct snd_kcontrol *kcontrol,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) struct snd_ctl_elem_info *uinfo)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) const int size = ARRAY_SIZE(toneport_source_info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) uinfo->count = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) uinfo->value.enumerated.items = size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) if (uinfo->value.enumerated.item >= size)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) uinfo->value.enumerated.item = size - 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) strcpy(uinfo->value.enumerated.name,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) toneport_source_info[uinfo->value.enumerated.item].name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) /* source get callback */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) static int snd_toneport_source_get(struct snd_kcontrol *kcontrol,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) struct snd_ctl_elem_value *ucontrol)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) struct snd_line6_pcm *line6pcm = snd_kcontrol_chip(kcontrol);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) struct usb_line6_toneport *toneport = line6_to_toneport(line6pcm->line6);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) ucontrol->value.enumerated.item[0] = toneport->source;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) /* source put callback */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) static int snd_toneport_source_put(struct snd_kcontrol *kcontrol,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) struct snd_ctl_elem_value *ucontrol)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) struct snd_line6_pcm *line6pcm = snd_kcontrol_chip(kcontrol);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) struct usb_line6_toneport *toneport = line6_to_toneport(line6pcm->line6);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) unsigned int source;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) source = ucontrol->value.enumerated.item[0];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) if (source >= ARRAY_SIZE(toneport_source_info))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) if (source == toneport->source)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) toneport->source = source;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) toneport_send_cmd(toneport->line6.usbdev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) toneport_source_info[source].code, 0x0000);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) return 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) static void toneport_startup(struct usb_line6 *line6)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) line6_pcm_acquire(line6->line6pcm, LINE6_STREAM_MONITOR, true);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) /* control definition */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) static const struct snd_kcontrol_new toneport_control_monitor = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) .name = "Monitor Playback Volume",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) .index = 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) .access = SNDRV_CTL_ELEM_ACCESS_READWRITE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) .info = snd_toneport_monitor_info,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) .get = snd_toneport_monitor_get,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) .put = snd_toneport_monitor_put
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) /* source selector definition */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) static const struct snd_kcontrol_new toneport_control_source = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) .name = "PCM Capture Source",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) .index = 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) .access = SNDRV_CTL_ELEM_ACCESS_READWRITE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) .info = snd_toneport_source_info,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) .get = snd_toneport_source_get,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) .put = snd_toneport_source_put
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) For the led on Guitarport.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) Brightness goes from 0x00 to 0x26. Set a value above this to have led
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) blink.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) (void cmd_0x02(byte red, byte green)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) static bool toneport_has_led(struct usb_line6_toneport *toneport)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) switch (toneport->type) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) case LINE6_GUITARPORT:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) case LINE6_TONEPORT_GX:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) /* add your device here if you are missing support for the LEDs */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) return true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) return false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) static const char * const toneport_led_colors[2] = { "red", "green" };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) static const int toneport_led_init_vals[2] = { 0x00, 0x26 };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) static void toneport_update_led(struct usb_line6_toneport *toneport)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) toneport_send_cmd(toneport->line6.usbdev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) (toneport->leds[0].dev.brightness << 8) | 0x0002,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) toneport->leds[1].dev.brightness);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) static void toneport_led_brightness_set(struct led_classdev *led_cdev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) enum led_brightness brightness)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) struct toneport_led *leds =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) container_of(led_cdev, struct toneport_led, dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301) toneport_update_led(leds->toneport);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304) static int toneport_init_leds(struct usb_line6_toneport *toneport)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306) struct device *dev = &toneport->line6.usbdev->dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307) int i, err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309) for (i = 0; i < 2; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310) struct toneport_led *led = &toneport->leds[i];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311) struct led_classdev *leddev = &led->dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313) led->toneport = toneport;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314) snprintf(led->name, sizeof(led->name), "%s::%s",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315) dev_name(dev), toneport_led_colors[i]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316) leddev->name = led->name;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317) leddev->brightness = toneport_led_init_vals[i];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318) leddev->max_brightness = 0x26;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319) leddev->brightness_set = toneport_led_brightness_set;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320) err = led_classdev_register(dev, leddev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321) if (err)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322) return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323) led->registered = true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 328)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 329) static void toneport_remove_leds(struct usb_line6_toneport *toneport)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 330) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 331) struct toneport_led *led;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 332) int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 333)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 334) for (i = 0; i < 2; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 335) led = &toneport->leds[i];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 336) if (!led->registered)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 337) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 338) led_classdev_unregister(&led->dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 339) led->registered = false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 340) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 341) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 342)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 343) static bool toneport_has_source_select(struct usb_line6_toneport *toneport)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 344) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 345) switch (toneport->type) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 346) case LINE6_TONEPORT_UX1:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 347) case LINE6_TONEPORT_UX2:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 348) case LINE6_PODSTUDIO_UX1:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 349) case LINE6_PODSTUDIO_UX2:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 350) return true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 351)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 352) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 353) return false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 354) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 355) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 356)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 357) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 358) Setup Toneport device.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 359) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 360) static int toneport_setup(struct usb_line6_toneport *toneport)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 361) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 362) u32 *ticks;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 363) struct usb_line6 *line6 = &toneport->line6;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 364) struct usb_device *usbdev = line6->usbdev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 365)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 366) ticks = kmalloc(sizeof(*ticks), GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 367) if (!ticks)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 368) return -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 369)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 370) /* sync time on device with host: */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 371) /* note: 32-bit timestamps overflow in year 2106 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 372) *ticks = (u32)ktime_get_real_seconds();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 373) line6_write_data(line6, 0x80c6, ticks, 4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 374) kfree(ticks);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 375)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 376) /* enable device: */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 377) toneport_send_cmd(usbdev, 0x0301, 0x0000);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 378)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 379) /* initialize source select: */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 380) if (toneport_has_source_select(toneport))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 381) toneport_send_cmd(usbdev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 382) toneport_source_info[toneport->source].code,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 383) 0x0000);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 384)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 385) if (toneport_has_led(toneport))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 386) toneport_update_led(toneport);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 387)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 388) schedule_delayed_work(&toneport->line6.startup_work,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 389) msecs_to_jiffies(TONEPORT_PCM_DELAY * 1000));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 390) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 391) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 392)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 393) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 394) Toneport device disconnected.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 395) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 396) static void line6_toneport_disconnect(struct usb_line6 *line6)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 397) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 398) struct usb_line6_toneport *toneport = line6_to_toneport(line6);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 399)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 400) if (toneport_has_led(toneport))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 401) toneport_remove_leds(toneport);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 402) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 403)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 404)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 405) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 406) Try to init Toneport device.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 407) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 408) static int toneport_init(struct usb_line6 *line6,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 409) const struct usb_device_id *id)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 410) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 411) int err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 412) struct usb_line6_toneport *toneport = line6_to_toneport(line6);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 413)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 414) toneport->type = id->driver_info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 415)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 416) line6->disconnect = line6_toneport_disconnect;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 417) line6->startup = toneport_startup;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 418)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 419) /* initialize PCM subsystem: */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 420) err = line6_init_pcm(line6, &toneport_pcm_properties);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 421) if (err < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 422) return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 423)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 424) /* register monitor control: */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 425) err = snd_ctl_add(line6->card,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 426) snd_ctl_new1(&toneport_control_monitor,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 427) line6->line6pcm));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 428) if (err < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 429) return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 430)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 431) /* register source select control: */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 432) if (toneport_has_source_select(toneport)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 433) err =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 434) snd_ctl_add(line6->card,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 435) snd_ctl_new1(&toneport_control_source,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 436) line6->line6pcm));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 437) if (err < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 438) return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 439) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 440)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 441) line6_read_serial_number(line6, &toneport->serial_number);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 442) line6_read_data(line6, 0x80c2, &toneport->firmware_version, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 443)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 444) if (toneport_has_led(toneport)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 445) err = toneport_init_leds(toneport);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 446) if (err < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 447) return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 448) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 449)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 450) err = toneport_setup(toneport);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 451) if (err)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 452) return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 453)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 454) /* register audio system: */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 455) return snd_card_register(line6->card);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 456) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 457)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 458) #ifdef CONFIG_PM
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 459) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 460) Resume Toneport device after reset.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 461) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 462) static int toneport_reset_resume(struct usb_interface *interface)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 463) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 464) int err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 465)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 466) err = toneport_setup(usb_get_intfdata(interface));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 467) if (err)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 468) return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 469) return line6_resume(interface);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 470) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 471) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 472)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 473) #define LINE6_DEVICE(prod) USB_DEVICE(0x0e41, prod)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 474) #define LINE6_IF_NUM(prod, n) USB_DEVICE_INTERFACE_NUMBER(0x0e41, prod, n)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 475)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 476) /* table of devices that work with this driver */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 477) static const struct usb_device_id toneport_id_table[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 478) { LINE6_DEVICE(0x4750), .driver_info = LINE6_GUITARPORT },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 479) { LINE6_DEVICE(0x4153), .driver_info = LINE6_PODSTUDIO_GX },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 480) { LINE6_DEVICE(0x4150), .driver_info = LINE6_PODSTUDIO_UX1 },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 481) { LINE6_IF_NUM(0x4151, 0), .driver_info = LINE6_PODSTUDIO_UX2 },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 482) { LINE6_DEVICE(0x4147), .driver_info = LINE6_TONEPORT_GX },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 483) { LINE6_DEVICE(0x4141), .driver_info = LINE6_TONEPORT_UX1 },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 484) { LINE6_IF_NUM(0x4142, 0), .driver_info = LINE6_TONEPORT_UX2 },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 485) {}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 486) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 487)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 488) MODULE_DEVICE_TABLE(usb, toneport_id_table);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 489)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 490) static const struct line6_properties toneport_properties_table[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 491) [LINE6_GUITARPORT] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 492) .id = "GuitarPort",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 493) .name = "GuitarPort",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 494) .capabilities = LINE6_CAP_PCM,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 495) .altsetting = 2, /* 1..4 seem to be ok */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 496) /* no control channel */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 497) .ep_audio_r = 0x82,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 498) .ep_audio_w = 0x01,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 499) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 500) [LINE6_PODSTUDIO_GX] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 501) .id = "PODStudioGX",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 502) .name = "POD Studio GX",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 503) .capabilities = LINE6_CAP_PCM,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 504) .altsetting = 2, /* 1..4 seem to be ok */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 505) /* no control channel */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 506) .ep_audio_r = 0x82,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 507) .ep_audio_w = 0x01,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 508) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 509) [LINE6_PODSTUDIO_UX1] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 510) .id = "PODStudioUX1",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 511) .name = "POD Studio UX1",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 512) .capabilities = LINE6_CAP_PCM,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 513) .altsetting = 2, /* 1..4 seem to be ok */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 514) /* no control channel */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 515) .ep_audio_r = 0x82,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 516) .ep_audio_w = 0x01,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 517) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 518) [LINE6_PODSTUDIO_UX2] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 519) .id = "PODStudioUX2",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 520) .name = "POD Studio UX2",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 521) .capabilities = LINE6_CAP_PCM,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 522) .altsetting = 2, /* defaults to 44.1kHz, 16-bit */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 523) /* no control channel */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 524) .ep_audio_r = 0x82,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 525) .ep_audio_w = 0x01,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 526) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 527) [LINE6_TONEPORT_GX] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 528) .id = "TonePortGX",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 529) .name = "TonePort GX",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 530) .capabilities = LINE6_CAP_PCM,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 531) .altsetting = 2, /* 1..4 seem to be ok */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 532) /* no control channel */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 533) .ep_audio_r = 0x82,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 534) .ep_audio_w = 0x01,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 535) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 536) [LINE6_TONEPORT_UX1] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 537) .id = "TonePortUX1",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 538) .name = "TonePort UX1",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 539) .capabilities = LINE6_CAP_PCM,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 540) .altsetting = 2, /* 1..4 seem to be ok */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 541) /* no control channel */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 542) .ep_audio_r = 0x82,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 543) .ep_audio_w = 0x01,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 544) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 545) [LINE6_TONEPORT_UX2] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 546) .id = "TonePortUX2",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 547) .name = "TonePort UX2",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 548) .capabilities = LINE6_CAP_PCM,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 549) .altsetting = 2, /* defaults to 44.1kHz, 16-bit */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 550) /* no control channel */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 551) .ep_audio_r = 0x82,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 552) .ep_audio_w = 0x01,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 553) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 554) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 555)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 556) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 557) Probe USB device.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 558) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 559) static int toneport_probe(struct usb_interface *interface,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 560) const struct usb_device_id *id)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 561) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 562) return line6_probe(interface, id, "Line6-TonePort",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 563) &toneport_properties_table[id->driver_info],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 564) toneport_init, sizeof(struct usb_line6_toneport));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 565) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 566)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 567) static struct usb_driver toneport_driver = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 568) .name = KBUILD_MODNAME,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 569) .probe = toneport_probe,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 570) .disconnect = line6_disconnect,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 571) #ifdef CONFIG_PM
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 572) .suspend = line6_suspend,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 573) .resume = line6_resume,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 574) .reset_resume = toneport_reset_resume,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 575) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 576) .id_table = toneport_id_table,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 577) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 578)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 579) module_usb_driver(toneport_driver);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 580)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 581) MODULE_DESCRIPTION("TonePort USB driver");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 582) MODULE_LICENSE("GPL");