blob: 819e06b3f3dba31f8fbd835244515a121cc8f2ee [file] [log] [blame]
Markus Grabner705ecec2009-02-27 19:43:04 -08001/*
Chris Rorvickc078a4a2015-01-20 02:20:50 -06002 * Line 6 Linux USB driver
Markus Grabner705ecec2009-02-27 19:43:04 -08003 *
Markus Grabner1027f4762010-08-12 01:35:30 +02004 * Copyright (C) 2004-2010 Markus Grabner (grabner@icg.tugraz.at)
Markus Grabner705ecec2009-02-27 19:43:04 -08005 * Emil Myhrman (emil.myhrman@gmail.com)
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License as
9 * published by the Free Software Foundation, version 2.
10 *
11 */
12
Markus Grabner1027f4762010-08-12 01:35:30 +020013#include <linux/wait.h>
Takashi Iwaiccddbe42015-01-15 08:22:31 +010014#include <linux/usb.h>
15#include <linux/slab.h>
16#include <linux/module.h>
Takashi Iwaif44edd72015-01-20 09:36:31 +010017#include <linux/leds.h>
Takashi Iwaiccddbe42015-01-15 08:22:31 +010018#include <sound/core.h>
Markus Grabner1027f4762010-08-12 01:35:30 +020019#include <sound/control.h>
Markus Grabner705ecec2009-02-27 19:43:04 -080020
Markus Grabner705ecec2009-02-27 19:43:04 -080021#include "capture.h"
Markus Grabner1027f4762010-08-12 01:35:30 +020022#include "driver.h"
Markus Grabner705ecec2009-02-27 19:43:04 -080023#include "playback.h"
Takashi Iwaiccddbe42015-01-15 08:22:31 +010024#include "usbdefs.h"
25
26enum line6_device_type {
27 LINE6_GUITARPORT,
28 LINE6_PODSTUDIO_GX,
29 LINE6_PODSTUDIO_UX1,
30 LINE6_PODSTUDIO_UX2,
31 LINE6_TONEPORT_GX,
32 LINE6_TONEPORT_UX1,
33 LINE6_TONEPORT_UX2,
34};
35
Takashi Iwaif44edd72015-01-20 09:36:31 +010036struct usb_line6_toneport;
37
38struct toneport_led {
39 struct led_classdev dev;
40 char name[64];
41 struct usb_line6_toneport *toneport;
42 bool registered;
43};
44
Takashi Iwaiccddbe42015-01-15 08:22:31 +010045struct usb_line6_toneport {
46 /**
Chris Rorvickc6fffce2015-01-20 02:20:49 -060047 Generic Line 6 USB data.
Takashi Iwaiccddbe42015-01-15 08:22:31 +010048 */
49 struct usb_line6 line6;
50
51 /**
52 Source selector.
53 */
54 int source;
55
56 /**
57 Serial number of device.
58 */
59 int serial_number;
60
61 /**
62 Firmware version (x 100).
63 */
64 int firmware_version;
65
66 /**
67 Timer for delayed PCM startup.
68 */
69 struct timer_list timer;
70
71 /**
72 Device type.
73 */
74 enum line6_device_type type;
Takashi Iwaif44edd72015-01-20 09:36:31 +010075
76 /* LED instances */
77 struct toneport_led leds[2];
Takashi Iwaiccddbe42015-01-15 08:22:31 +010078};
Markus Grabner705ecec2009-02-27 19:43:04 -080079
Markus Grabner705ecec2009-02-27 19:43:04 -080080static int toneport_send_cmd(struct usb_device *usbdev, int cmd1, int cmd2);
81
Markus Grabner1027f4762010-08-12 01:35:30 +020082#define TONEPORT_PCM_DELAY 1
83
Markus Grabner705ecec2009-02-27 19:43:04 -080084static struct snd_ratden toneport_ratden = {
85 .num_min = 44100,
86 .num_max = 44100,
87 .num_step = 1,
88 .den = 1
89};
90
91static struct line6_pcm_properties toneport_pcm_properties = {
Shawn Bohrer63a4a8b2009-11-15 22:17:58 -060092 .snd_line6_playback_hw = {
Markus Grabnere1a164d2010-08-23 01:08:25 +020093 .info = (SNDRV_PCM_INFO_MMAP |
94 SNDRV_PCM_INFO_INTERLEAVED |
95 SNDRV_PCM_INFO_BLOCK_TRANSFER |
96 SNDRV_PCM_INFO_MMAP_VALID |
97 SNDRV_PCM_INFO_PAUSE |
Markus Grabnere1a164d2010-08-23 01:08:25 +020098 SNDRV_PCM_INFO_SYNC_START),
99 .formats = SNDRV_PCM_FMTBIT_S16_LE,
100 .rates = SNDRV_PCM_RATE_KNOT,
101 .rate_min = 44100,
102 .rate_max = 44100,
103 .channels_min = 2,
104 .channels_max = 2,
105 .buffer_bytes_max = 60000,
106 .period_bytes_min = 64,
107 .period_bytes_max = 8192,
108 .periods_min = 1,
109 .periods_max = 1024},
Shawn Bohrer63a4a8b2009-11-15 22:17:58 -0600110 .snd_line6_capture_hw = {
Markus Grabnere1a164d2010-08-23 01:08:25 +0200111 .info = (SNDRV_PCM_INFO_MMAP |
112 SNDRV_PCM_INFO_INTERLEAVED |
113 SNDRV_PCM_INFO_BLOCK_TRANSFER |
114 SNDRV_PCM_INFO_MMAP_VALID |
Markus Grabnere1a164d2010-08-23 01:08:25 +0200115 SNDRV_PCM_INFO_SYNC_START),
116 .formats = SNDRV_PCM_FMTBIT_S16_LE,
117 .rates = SNDRV_PCM_RATE_KNOT,
118 .rate_min = 44100,
119 .rate_max = 44100,
120 .channels_min = 2,
121 .channels_max = 2,
122 .buffer_bytes_max = 60000,
123 .period_bytes_min = 64,
124 .period_bytes_max = 8192,
125 .periods_min = 1,
126 .periods_max = 1024},
Markus Grabner705ecec2009-02-27 19:43:04 -0800127 .snd_line6_rates = {
Markus Grabnere1a164d2010-08-23 01:08:25 +0200128 .nrats = 1,
129 .rats = &toneport_ratden},
Markus Grabner705ecec2009-02-27 19:43:04 -0800130 .bytes_per_frame = 4
131};
132
Stefan Hajnoczi709b2fa2013-01-11 23:08:13 +0100133static const struct {
Markus Grabner1027f4762010-08-12 01:35:30 +0200134 const char *name;
135 int code;
Stefan Hajnoczi709b2fa2013-01-11 23:08:13 +0100136} toneport_source_info[] = {
Markus Grabnere1a164d2010-08-23 01:08:25 +0200137 {"Microphone", 0x0a01},
138 {"Line", 0x0801},
139 {"Instrument", 0x0b01},
140 {"Inst & Mic", 0x0901}
Markus Grabner1027f4762010-08-12 01:35:30 +0200141};
142
Markus Grabner705ecec2009-02-27 19:43:04 -0800143static int toneport_send_cmd(struct usb_device *usbdev, int cmd1, int cmd2)
144{
145 int ret;
Markus Grabner705ecec2009-02-27 19:43:04 -0800146
Greg Kroah-Hartman63537732009-02-27 22:43:45 -0800147 ret = usb_control_msg(usbdev, usb_sndctrlpipe(usbdev, 0), 0x67,
148 USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_OUT,
149 cmd1, cmd2, NULL, 0, LINE6_TIMEOUT * HZ);
150
151 if (ret < 0) {
Greg Kroah-Hartmand86938f2012-04-20 16:53:32 -0700152 dev_err(&usbdev->dev, "send failed (error %d)\n", ret);
Markus Grabner705ecec2009-02-27 19:43:04 -0800153 return ret;
154 }
155
156 return 0;
157}
158
Markus Grabner1027f4762010-08-12 01:35:30 +0200159/* monitor info callback */
160static int snd_toneport_monitor_info(struct snd_kcontrol *kcontrol,
161 struct snd_ctl_elem_info *uinfo)
162{
163 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
164 uinfo->count = 1;
165 uinfo->value.integer.min = 0;
166 uinfo->value.integer.max = 256;
167 return 0;
168}
169
170/* monitor get callback */
171static int snd_toneport_monitor_get(struct snd_kcontrol *kcontrol,
172 struct snd_ctl_elem_value *ucontrol)
173{
174 struct snd_line6_pcm *line6pcm = snd_kcontrol_chip(kcontrol);
Jerry Snitselaarf3c52612014-04-24 00:31:48 -0700175
Markus Grabner1027f4762010-08-12 01:35:30 +0200176 ucontrol->value.integer.value[0] = line6pcm->volume_monitor;
177 return 0;
178}
179
180/* monitor put callback */
181static int snd_toneport_monitor_put(struct snd_kcontrol *kcontrol,
182 struct snd_ctl_elem_value *ucontrol)
183{
184 struct snd_line6_pcm *line6pcm = snd_kcontrol_chip(kcontrol);
Takashi Iwai247d95e2015-01-27 16:42:14 +0100185 int err;
Markus Grabner1027f4762010-08-12 01:35:30 +0200186
Markus Grabnere1a164d2010-08-23 01:08:25 +0200187 if (ucontrol->value.integer.value[0] == line6pcm->volume_monitor)
Markus Grabner1027f4762010-08-12 01:35:30 +0200188 return 0;
189
190 line6pcm->volume_monitor = ucontrol->value.integer.value[0];
Markus Grabnere1a164d2010-08-23 01:08:25 +0200191
Takashi Iwai247d95e2015-01-27 16:42:14 +0100192 if (line6pcm->volume_monitor > 0) {
193 err = line6_pcm_acquire(line6pcm, LINE6_STREAM_MONITOR);
194 if (err < 0) {
195 line6pcm->volume_monitor = 0;
196 line6_pcm_release(line6pcm, LINE6_STREAM_MONITOR);
197 return err;
198 }
199 } else {
Takashi Iwai63e20df2015-01-27 15:24:09 +0100200 line6_pcm_release(line6pcm, LINE6_STREAM_MONITOR);
Takashi Iwai247d95e2015-01-27 16:42:14 +0100201 }
Markus Grabnere1a164d2010-08-23 01:08:25 +0200202
Markus Grabner1027f4762010-08-12 01:35:30 +0200203 return 1;
204}
205
206/* source info callback */
207static int snd_toneport_source_info(struct snd_kcontrol *kcontrol,
208 struct snd_ctl_elem_info *uinfo)
209{
210 const int size = ARRAY_SIZE(toneport_source_info);
Fabian Mewesa6b46992014-03-24 23:46:31 +0100211
Markus Grabner1027f4762010-08-12 01:35:30 +0200212 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
213 uinfo->count = 1;
214 uinfo->value.enumerated.items = size;
215
Markus Grabnere1a164d2010-08-23 01:08:25 +0200216 if (uinfo->value.enumerated.item >= size)
Markus Grabner1027f4762010-08-12 01:35:30 +0200217 uinfo->value.enumerated.item = size - 1;
218
219 strcpy(uinfo->value.enumerated.name,
220 toneport_source_info[uinfo->value.enumerated.item].name);
221
222 return 0;
223}
224
225/* source get callback */
226static int snd_toneport_source_get(struct snd_kcontrol *kcontrol,
227 struct snd_ctl_elem_value *ucontrol)
228{
229 struct snd_line6_pcm *line6pcm = snd_kcontrol_chip(kcontrol);
Markus Grabnere1a164d2010-08-23 01:08:25 +0200230 struct usb_line6_toneport *toneport =
231 (struct usb_line6_toneport *)line6pcm->line6;
Markus Grabner1027f4762010-08-12 01:35:30 +0200232 ucontrol->value.enumerated.item[0] = toneport->source;
233 return 0;
234}
235
236/* source put callback */
237static int snd_toneport_source_put(struct snd_kcontrol *kcontrol,
238 struct snd_ctl_elem_value *ucontrol)
239{
240 struct snd_line6_pcm *line6pcm = snd_kcontrol_chip(kcontrol);
Markus Grabnere1a164d2010-08-23 01:08:25 +0200241 struct usb_line6_toneport *toneport =
242 (struct usb_line6_toneport *)line6pcm->line6;
Dan Carpenterc3cb7182013-09-13 11:07:13 +0300243 unsigned int source;
Markus Grabner1027f4762010-08-12 01:35:30 +0200244
Dan Carpenterc3cb7182013-09-13 11:07:13 +0300245 source = ucontrol->value.enumerated.item[0];
246 if (source >= ARRAY_SIZE(toneport_source_info))
247 return -EINVAL;
248 if (source == toneport->source)
Markus Grabner1027f4762010-08-12 01:35:30 +0200249 return 0;
250
Dan Carpenterc3cb7182013-09-13 11:07:13 +0300251 toneport->source = source;
Markus Grabnere1a164d2010-08-23 01:08:25 +0200252 toneport_send_cmd(toneport->line6.usbdev,
Dan Carpenterc3cb7182013-09-13 11:07:13 +0300253 toneport_source_info[source].code, 0x0000);
Markus Grabner1027f4762010-08-12 01:35:30 +0200254 return 1;
255}
256
257static void toneport_start_pcm(unsigned long arg)
258{
259 struct usb_line6_toneport *toneport = (struct usb_line6_toneport *)arg;
260 struct usb_line6 *line6 = &toneport->line6;
Jerry Snitselaarf3c52612014-04-24 00:31:48 -0700261
Takashi Iwai63e20df2015-01-27 15:24:09 +0100262 line6_pcm_acquire(line6->line6pcm, LINE6_STREAM_MONITOR);
Markus Grabner1027f4762010-08-12 01:35:30 +0200263}
264
265/* control definition */
266static struct snd_kcontrol_new toneport_control_monitor = {
267 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
268 .name = "Monitor Playback Volume",
269 .index = 0,
270 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE,
271 .info = snd_toneport_monitor_info,
272 .get = snd_toneport_monitor_get,
273 .put = snd_toneport_monitor_put
274};
275
276/* source selector definition */
277static struct snd_kcontrol_new toneport_control_source = {
278 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
279 .name = "PCM Capture Source",
280 .index = 0,
281 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE,
282 .info = snd_toneport_source_info,
283 .get = snd_toneport_source_get,
284 .put = snd_toneport_source_put
285};
286
Markus Grabner705ecec2009-02-27 19:43:04 -0800287/*
Takashi Iwaif44edd72015-01-20 09:36:31 +0100288 For the led on Guitarport.
289 Brightness goes from 0x00 to 0x26. Set a value above this to have led
290 blink.
291 (void cmd_0x02(byte red, byte green)
292*/
293
294static bool toneport_has_led(enum line6_device_type type)
295{
296 return
297 (type == LINE6_GUITARPORT) ||
298 (type == LINE6_TONEPORT_GX);
299 /* add your device here if you are missing support for the LEDs */
300}
301
302static const char * const led_colors[2] = { "red", "green" };
303static const int led_init_vals[2] = { 0x00, 0x26 };
304
305static void toneport_update_led(struct usb_line6_toneport *toneport)
306{
307 toneport_send_cmd(toneport->line6.usbdev,
308 (toneport->leds[0].dev.brightness << 8) | 0x0002,
309 toneport->leds[1].dev.brightness);
310}
311
312static void toneport_led_brightness_set(struct led_classdev *led_cdev,
313 enum led_brightness brightness)
314{
315 struct toneport_led *leds =
316 container_of(led_cdev, struct toneport_led, dev);
317 toneport_update_led(leds->toneport);
318}
319
320static int toneport_init_leds(struct usb_line6_toneport *toneport)
321{
322 struct device *dev = &toneport->line6.usbdev->dev;
323 int i, err;
324
325 for (i = 0; i < 2; i++) {
326 struct toneport_led *led = &toneport->leds[i];
327 struct led_classdev *leddev = &led->dev;
328
329 led->toneport = toneport;
330 snprintf(led->name, sizeof(led->name), "%s::%s",
331 dev_name(dev), led_colors[i]);
332 leddev->name = led->name;
333 leddev->brightness = led_init_vals[i];
334 leddev->max_brightness = 0x26;
335 leddev->brightness_set = toneport_led_brightness_set;
336 err = led_classdev_register(dev, leddev);
337 if (err)
338 return err;
339 led->registered = true;
340 }
341
342 return 0;
343}
344
345static void toneport_remove_leds(struct usb_line6_toneport *toneport)
346{
347 struct toneport_led *led;
348 int i;
349
350 for (i = 0; i < 2; i++) {
351 led = &toneport->leds[i];
352 if (!led->registered)
353 break;
354 led_classdev_unregister(&led->dev);
355 led->registered = false;
356 }
357}
358
359/*
Markus Grabner1027f4762010-08-12 01:35:30 +0200360 Setup Toneport device.
Markus Grabner705ecec2009-02-27 19:43:04 -0800361*/
Markus Grabner1027f4762010-08-12 01:35:30 +0200362static void toneport_setup(struct usb_line6_toneport *toneport)
Markus Grabner705ecec2009-02-27 19:43:04 -0800363{
Markus Grabner1027f4762010-08-12 01:35:30 +0200364 int ticks;
Markus Grabner705ecec2009-02-27 19:43:04 -0800365 struct usb_line6 *line6 = &toneport->line6;
Markus Grabner1027f4762010-08-12 01:35:30 +0200366 struct usb_device *usbdev = line6->usbdev;
367
368 /* sync time on device with host: */
369 ticks = (int)get_seconds();
370 line6_write_data(line6, 0x80c6, &ticks, 4);
371
372 /* enable device: */
373 toneport_send_cmd(usbdev, 0x0301, 0x0000);
374
375 /* initialize source select: */
Takashi Iwaiccddbe42015-01-15 08:22:31 +0100376 switch (toneport->type) {
Chris Rorvicka23a8bf2015-01-12 12:42:42 -0800377 case LINE6_TONEPORT_UX1:
378 case LINE6_TONEPORT_UX2:
379 case LINE6_PODSTUDIO_UX1:
380 case LINE6_PODSTUDIO_UX2:
Markus Grabnere1a164d2010-08-23 01:08:25 +0200381 toneport_send_cmd(usbdev,
382 toneport_source_info[toneport->source].code,
383 0x0000);
Chris Rorvicka23a8bf2015-01-12 12:42:42 -0800384 default:
385 break;
Markus Grabner1027f4762010-08-12 01:35:30 +0200386 }
387
Takashi Iwaiccddbe42015-01-15 08:22:31 +0100388 if (toneport_has_led(toneport->type))
Takashi Iwaif44edd72015-01-20 09:36:31 +0100389 toneport_update_led(toneport);
Takashi Iwai6dd1c052015-01-20 09:40:20 +0100390
391 mod_timer(&toneport->timer, jiffies + TONEPORT_PCM_DELAY * HZ);
Markus Grabner1027f4762010-08-12 01:35:30 +0200392}
393
394/*
Chris Rorvickd29b8542015-01-12 12:43:00 -0800395 Toneport device disconnected.
396*/
Takashi Iwaif66fd992015-01-25 18:22:58 +0100397static void line6_toneport_disconnect(struct usb_line6 *line6)
Chris Rorvickd29b8542015-01-12 12:43:00 -0800398{
Takashi Iwaif66fd992015-01-25 18:22:58 +0100399 struct usb_line6_toneport *toneport =
400 (struct usb_line6_toneport *)line6;
Chris Rorvickd29b8542015-01-12 12:43:00 -0800401
Chris Rorvickd29b8542015-01-12 12:43:00 -0800402 del_timer_sync(&toneport->timer);
Chris Rorvickd29b8542015-01-12 12:43:00 -0800403
Takashi Iwaif44edd72015-01-20 09:36:31 +0100404 if (toneport_has_led(toneport->type))
405 toneport_remove_leds(toneport);
Chris Rorvickd29b8542015-01-12 12:43:00 -0800406}
407
408
409/*
Markus Grabner1027f4762010-08-12 01:35:30 +0200410 Try to init Toneport device.
411*/
Takashi Iwaif66fd992015-01-25 18:22:58 +0100412static int toneport_init(struct usb_line6 *line6,
413 const struct usb_device_id *id)
Markus Grabner1027f4762010-08-12 01:35:30 +0200414{
415 int err;
Chris Rorvicka221dd42015-01-12 12:42:56 -0800416 struct usb_line6_toneport *toneport = (struct usb_line6_toneport *) line6;
Markus Grabner705ecec2009-02-27 19:43:04 -0800417
Takashi Iwaif66fd992015-01-25 18:22:58 +0100418 toneport->type = id->driver_info;
Takashi Iwai6dd1c052015-01-20 09:40:20 +0100419 setup_timer(&toneport->timer, toneport_start_pcm,
420 (unsigned long)toneport);
421
Chris Rorvicka46c4672015-01-12 12:42:59 -0800422 line6->disconnect = line6_toneport_disconnect;
423
Markus Grabner705ecec2009-02-27 19:43:04 -0800424 /* initialize PCM subsystem: */
Greg Kroah-Hartman63537732009-02-27 22:43:45 -0800425 err = line6_init_pcm(line6, &toneport_pcm_properties);
Greg Kroah-Hartman027360c2010-09-21 16:58:00 -0700426 if (err < 0)
Markus Grabner705ecec2009-02-27 19:43:04 -0800427 return err;
Markus Grabner705ecec2009-02-27 19:43:04 -0800428
Markus Grabner1027f4762010-08-12 01:35:30 +0200429 /* register monitor control: */
Greg Kroah-Hartman027360c2010-09-21 16:58:00 -0700430 err = snd_ctl_add(line6->card,
431 snd_ctl_new1(&toneport_control_monitor,
432 line6->line6pcm));
433 if (err < 0)
Markus Grabner1027f4762010-08-12 01:35:30 +0200434 return err;
Markus Grabner1027f4762010-08-12 01:35:30 +0200435
436 /* register source select control: */
Takashi Iwaiccddbe42015-01-15 08:22:31 +0100437 switch (toneport->type) {
Chris Rorvicka23a8bf2015-01-12 12:42:42 -0800438 case LINE6_TONEPORT_UX1:
439 case LINE6_TONEPORT_UX2:
440 case LINE6_PODSTUDIO_UX1:
441 case LINE6_PODSTUDIO_UX2:
Markus Grabnere1a164d2010-08-23 01:08:25 +0200442 err =
443 snd_ctl_add(line6->card,
444 snd_ctl_new1(&toneport_control_source,
445 line6->line6pcm));
Greg Kroah-Hartman027360c2010-09-21 16:58:00 -0700446 if (err < 0)
Markus Grabner1027f4762010-08-12 01:35:30 +0200447 return err;
Chris Rorvicka23a8bf2015-01-12 12:42:42 -0800448
449 default:
450 break;
Markus Grabner1027f4762010-08-12 01:35:30 +0200451 }
452
Markus Grabner705ecec2009-02-27 19:43:04 -0800453 line6_read_serial_number(line6, &toneport->serial_number);
454 line6_read_data(line6, 0x80c2, &toneport->firmware_version, 1);
455
Takashi Iwaiccddbe42015-01-15 08:22:31 +0100456 if (toneport_has_led(toneport->type)) {
Takashi Iwaif44edd72015-01-20 09:36:31 +0100457 err = toneport_init_leds(toneport);
Takashi Iwaib2a3b022015-01-19 16:08:02 +0100458 if (err < 0)
459 return err;
Markus Grabner705ecec2009-02-27 19:43:04 -0800460 }
461
Markus Grabner1027f4762010-08-12 01:35:30 +0200462 toneport_setup(toneport);
463
Takashi Iwai85a93392015-01-19 15:54:00 +0100464 /* register audio system: */
465 return snd_card_register(line6->card);
Markus Grabner1027f4762010-08-12 01:35:30 +0200466}
467
Takashi Iwaiccddbe42015-01-15 08:22:31 +0100468#ifdef CONFIG_PM
Markus Grabner1027f4762010-08-12 01:35:30 +0200469/*
470 Resume Toneport device after reset.
471*/
Takashi Iwaiccddbe42015-01-15 08:22:31 +0100472static int toneport_reset_resume(struct usb_interface *interface)
Markus Grabner1027f4762010-08-12 01:35:30 +0200473{
Takashi Iwaiccddbe42015-01-15 08:22:31 +0100474 toneport_setup(usb_get_intfdata(interface));
475 return line6_resume(interface);
Markus Grabner1027f4762010-08-12 01:35:30 +0200476}
Takashi Iwaiccddbe42015-01-15 08:22:31 +0100477#endif
478
479#define LINE6_DEVICE(prod) USB_DEVICE(0x0e41, prod)
480#define LINE6_IF_NUM(prod, n) USB_DEVICE_INTERFACE_NUMBER(0x0e41, prod, n)
481
482/* table of devices that work with this driver */
483static const struct usb_device_id toneport_id_table[] = {
484 { LINE6_DEVICE(0x4750), .driver_info = LINE6_GUITARPORT },
485 { LINE6_DEVICE(0x4153), .driver_info = LINE6_PODSTUDIO_GX },
486 { LINE6_DEVICE(0x4150), .driver_info = LINE6_PODSTUDIO_UX1 },
487 { LINE6_IF_NUM(0x4151, 0), .driver_info = LINE6_PODSTUDIO_UX2 },
488 { LINE6_DEVICE(0x4147), .driver_info = LINE6_TONEPORT_GX },
489 { LINE6_DEVICE(0x4141), .driver_info = LINE6_TONEPORT_UX1 },
490 { LINE6_IF_NUM(0x4142, 0), .driver_info = LINE6_TONEPORT_UX2 },
491 {}
492};
493
494MODULE_DEVICE_TABLE(usb, toneport_id_table);
495
496static const struct line6_properties toneport_properties_table[] = {
497 [LINE6_GUITARPORT] = {
498 .id = "GuitarPort",
499 .name = "GuitarPort",
500 .capabilities = LINE6_CAP_PCM,
501 .altsetting = 2, /* 1..4 seem to be ok */
502 /* no control channel */
503 .ep_audio_r = 0x82,
504 .ep_audio_w = 0x01,
505 },
506 [LINE6_PODSTUDIO_GX] = {
507 .id = "PODStudioGX",
508 .name = "POD Studio GX",
509 .capabilities = LINE6_CAP_PCM,
510 .altsetting = 2, /* 1..4 seem to be ok */
511 /* no control channel */
512 .ep_audio_r = 0x82,
513 .ep_audio_w = 0x01,
514 },
515 [LINE6_PODSTUDIO_UX1] = {
516 .id = "PODStudioUX1",
517 .name = "POD Studio UX1",
518 .capabilities = LINE6_CAP_PCM,
519 .altsetting = 2, /* 1..4 seem to be ok */
520 /* no control channel */
521 .ep_audio_r = 0x82,
522 .ep_audio_w = 0x01,
523 },
524 [LINE6_PODSTUDIO_UX2] = {
525 .id = "PODStudioUX2",
526 .name = "POD Studio UX2",
527 .capabilities = LINE6_CAP_PCM,
528 .altsetting = 2, /* defaults to 44.1kHz, 16-bit */
529 /* no control channel */
530 .ep_audio_r = 0x82,
531 .ep_audio_w = 0x01,
532 },
533 [LINE6_TONEPORT_GX] = {
534 .id = "TonePortGX",
535 .name = "TonePort GX",
536 .capabilities = LINE6_CAP_PCM,
537 .altsetting = 2, /* 1..4 seem to be ok */
538 /* no control channel */
539 .ep_audio_r = 0x82,
540 .ep_audio_w = 0x01,
541 },
542 [LINE6_TONEPORT_UX1] = {
543 .id = "TonePortUX1",
544 .name = "TonePort UX1",
545 .capabilities = LINE6_CAP_PCM,
546 .altsetting = 2, /* 1..4 seem to be ok */
547 /* no control channel */
548 .ep_audio_r = 0x82,
549 .ep_audio_w = 0x01,
550 },
551 [LINE6_TONEPORT_UX2] = {
552 .id = "TonePortUX2",
553 .name = "TonePort UX2",
554 .capabilities = LINE6_CAP_PCM,
555 .altsetting = 2, /* defaults to 44.1kHz, 16-bit */
556 /* no control channel */
557 .ep_audio_r = 0x82,
558 .ep_audio_w = 0x01,
559 },
560};
561
562/*
563 Probe USB device.
564*/
565static int toneport_probe(struct usb_interface *interface,
566 const struct usb_device_id *id)
567{
Takashi Iwaiaca514b2015-01-25 18:36:29 +0100568 return line6_probe(interface, id,
Takashi Iwai85a93392015-01-19 15:54:00 +0100569 &toneport_properties_table[id->driver_info],
Takashi Iwaiaca514b2015-01-25 18:36:29 +0100570 toneport_init, sizeof(struct usb_line6_toneport));
Takashi Iwaiccddbe42015-01-15 08:22:31 +0100571}
572
573static struct usb_driver toneport_driver = {
574 .name = KBUILD_MODNAME,
575 .probe = toneport_probe,
576 .disconnect = line6_disconnect,
577#ifdef CONFIG_PM
578 .suspend = line6_suspend,
579 .resume = line6_resume,
580 .reset_resume = toneport_reset_resume,
581#endif
582 .id_table = toneport_id_table,
583};
584
585module_usb_driver(toneport_driver);
586
587MODULE_DESCRIPTION("TonePort USB driver");
588MODULE_LICENSE("GPL");