13 #include <linux/wait.h>
22 static int toneport_send_cmd(
struct usb_device *
usbdev,
int cmd1,
int cmd2);
24 #define TONEPORT_PCM_DELAY 1
34 .snd_line6_playback_hw = {
50 .buffer_bytes_max = 60000,
51 .period_bytes_min = 64,
52 .period_bytes_max = 8192,
70 .buffer_bytes_max = 60000,
71 .period_bytes_min = 64,
72 .period_bytes_max = 8192,
77 .rats = &toneport_ratden},
87 static int led_red = 0x00;
88 static int led_green = 0x26;
96 {
"Microphone", 0x0a01},
98 {
"Instrument", 0x0b01},
99 {
"Inst & Mic", 0x0901}
102 static bool toneport_has_led(
short product)
110 static void toneport_update_led(
struct device *
dev)
121 toneport_send_cmd(line6->usbdev, (led_red << 8) | 0x0002,
137 toneport_update_led(dev);
143 const char *buf,
size_t count)
153 toneport_update_led(dev);
158 toneport_set_led_red);
160 toneport_set_led_green);
162 static int toneport_send_cmd(
struct usb_device *
usbdev,
int cmd1,
int cmd2)
171 dev_err(&usbdev->dev,
"send failed (error %d)\n", ret);
179 static int snd_toneport_monitor_info(
struct snd_kcontrol *kcontrol,
190 static int snd_toneport_monitor_get(
struct snd_kcontrol *kcontrol,
199 static int snd_toneport_monitor_put(
struct snd_kcontrol *kcontrol,
218 static int snd_toneport_source_info(
struct snd_kcontrol *kcontrol,
236 static int snd_toneport_source_get(
struct snd_kcontrol *kcontrol,
242 ucontrol->
value.enumerated.item[0] = toneport->
source;
247 static int snd_toneport_source_put(
struct snd_kcontrol *kcontrol,
257 toneport->
source = ucontrol->
value.enumerated.item[0];
258 toneport_send_cmd(toneport->
line6.usbdev,
259 toneport_source_info[toneport->
source].
code, 0x0000);
263 static void toneport_start_pcm(
unsigned long arg)
273 .name =
"Monitor Playback Volume",
276 .info = snd_toneport_monitor_info,
277 .get = snd_toneport_monitor_get,
278 .put = snd_toneport_monitor_put
284 .name =
"PCM Capture Source",
287 .info = snd_toneport_source_info,
288 .get = snd_toneport_source_get,
289 .put = snd_toneport_source_put
299 if (toneport ==
NULL)
311 struct usb_device *usbdev = line6->
usbdev;
318 toneport_send_cmd(usbdev, 0x0301, 0x0000);
321 switch (usbdev->descriptor.idProduct) {
326 toneport_send_cmd(usbdev,
331 if (toneport_has_led(usbdev->descriptor.idProduct))
332 toneport_update_led(&usbdev->dev);
338 static int toneport_try_init(
struct usb_interface *interface,
343 struct usb_device *usbdev = line6->
usbdev;
345 if ((interface ==
NULL) || (toneport ==
NULL))
366 switch (usbdev->descriptor.idProduct) {
387 if (toneport_has_led(usbdev->descriptor.idProduct)) {
389 (&interface->dev, &dev_attr_led_red));
391 (&interface->dev, &dev_attr_led_green));
394 toneport_setup(toneport);
398 toneport->
timer.function = toneport_start_pcm;
399 toneport->
timer.data = (
unsigned long)toneport;
411 int err = toneport_try_init(interface, toneport);
414 toneport_destruct(interface);
424 toneport_setup(toneport);
434 if (interface ==
NULL)
437 toneport = usb_get_intfdata(interface);
440 if (toneport_has_led(toneport->
line6.usbdev->descriptor.idProduct)) {
445 if (toneport !=
NULL) {
448 if (line6pcm !=
NULL) {
454 toneport_destruct(interface);