2 * Line6 Linux USB driver - 0.9.1beta
4 * Copyright (C) 2004-2010 Markus Grabner (grabner@icg.tugraz.at)
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License as
8 * published by the Free Software Foundation, version 2.
12 #include <linux/kernel.h>
13 #include <linux/module.h>
14 #include <linux/slab.h>
15 #include <linux/usb.h>
29 #define DRIVER_AUTHOR "Markus Grabner <grabner@icg.tugraz.at>"
30 #define DRIVER_DESC "Line6 USB Driver"
31 #define DRIVER_VERSION "0.9.1beta" DRIVER_REVISION
33 /* table of devices that work with this driver */
34 static const struct usb_device_id line6_id_table
[] = {
35 {USB_DEVICE(LINE6_VENDOR_ID
, LINE6_DEVID_BASSPODXT
)},
36 {USB_DEVICE(LINE6_VENDOR_ID
, LINE6_DEVID_BASSPODXTLIVE
)},
37 {USB_DEVICE(LINE6_VENDOR_ID
, LINE6_DEVID_BASSPODXTPRO
)},
38 {USB_DEVICE(LINE6_VENDOR_ID
, LINE6_DEVID_GUITARPORT
)},
39 {USB_DEVICE(LINE6_VENDOR_ID
, LINE6_DEVID_POCKETPOD
)},
40 {USB_DEVICE(LINE6_VENDOR_ID
, LINE6_DEVID_PODHD300
)},
41 {USB_DEVICE(LINE6_VENDOR_ID
, LINE6_DEVID_PODHD500
)},
42 {USB_DEVICE(LINE6_VENDOR_ID
, LINE6_DEVID_PODSTUDIO_GX
)},
43 {USB_DEVICE(LINE6_VENDOR_ID
, LINE6_DEVID_PODSTUDIO_UX1
)},
44 {USB_DEVICE(LINE6_VENDOR_ID
, LINE6_DEVID_PODSTUDIO_UX2
)},
45 {USB_DEVICE(LINE6_VENDOR_ID
, LINE6_DEVID_PODX3
)},
46 {USB_DEVICE(LINE6_VENDOR_ID
, LINE6_DEVID_PODX3LIVE
)},
47 {USB_DEVICE(LINE6_VENDOR_ID
, LINE6_DEVID_PODXT
)},
48 {USB_DEVICE(LINE6_VENDOR_ID
, LINE6_DEVID_PODXTLIVE
)},
49 {USB_DEVICE(LINE6_VENDOR_ID
, LINE6_DEVID_PODXTPRO
)},
50 {USB_DEVICE(LINE6_VENDOR_ID
, LINE6_DEVID_TONEPORT_GX
)},
51 {USB_DEVICE(LINE6_VENDOR_ID
, LINE6_DEVID_TONEPORT_UX1
)},
52 {USB_DEVICE(LINE6_VENDOR_ID
, LINE6_DEVID_TONEPORT_UX2
)},
53 {USB_DEVICE(LINE6_VENDOR_ID
, LINE6_DEVID_VARIAX
)},
57 MODULE_DEVICE_TABLE(usb
, line6_id_table
);
60 static struct line6_properties line6_properties_table
[] = {
61 { LINE6_BIT_BASSPODXT
, "BassPODxt", "BassPODxt", LINE6_BIT_CONTROL_PCM_HWMON
},
62 { LINE6_BIT_BASSPODXTLIVE
, "BassPODxtLive", "BassPODxt Live", LINE6_BIT_CONTROL_PCM_HWMON
},
63 { LINE6_BIT_BASSPODXTPRO
, "BassPODxtPro", "BassPODxt Pro", LINE6_BIT_CONTROL_PCM_HWMON
},
64 { LINE6_BIT_GUITARPORT
, "GuitarPort", "GuitarPort", LINE6_BIT_PCM
},
65 { LINE6_BIT_POCKETPOD
, "PocketPOD", "Pocket POD", LINE6_BIT_CONTROL
},
66 { LINE6_BIT_PODHD300
, "PODHD300", "POD HD300", LINE6_BIT_CONTROL_PCM_HWMON
},
67 { LINE6_BIT_PODHD500
, "PODHD500", "POD HD500", LINE6_BIT_CONTROL_PCM_HWMON
},
68 { LINE6_BIT_PODSTUDIO_GX
, "PODStudioGX", "POD Studio GX", LINE6_BIT_PCM
},
69 { LINE6_BIT_PODSTUDIO_UX1
, "PODStudioUX1", "POD Studio UX1", LINE6_BIT_PCM
},
70 { LINE6_BIT_PODSTUDIO_UX2
, "PODStudioUX2", "POD Studio UX2", LINE6_BIT_PCM
},
71 { LINE6_BIT_PODX3
, "PODX3", "POD X3", LINE6_BIT_PCM
},
72 { LINE6_BIT_PODX3LIVE
, "PODX3Live", "POD X3 Live", LINE6_BIT_PCM
},
73 { LINE6_BIT_PODXT
, "PODxt", "PODxt", LINE6_BIT_CONTROL_PCM_HWMON
},
74 { LINE6_BIT_PODXTLIVE
, "PODxtLive", "PODxt Live", LINE6_BIT_CONTROL_PCM_HWMON
},
75 { LINE6_BIT_PODXTPRO
, "PODxtPro", "PODxt Pro", LINE6_BIT_CONTROL_PCM_HWMON
},
76 { LINE6_BIT_TONEPORT_GX
, "TonePortGX", "TonePort GX", LINE6_BIT_PCM
},
77 { LINE6_BIT_TONEPORT_UX1
, "TonePortUX1", "TonePort UX1", LINE6_BIT_PCM
},
78 { LINE6_BIT_TONEPORT_UX2
, "TonePortUX2", "TonePort UX2", LINE6_BIT_PCM
},
79 { LINE6_BIT_VARIAX
, "Variax", "Variax Workbench", LINE6_BIT_CONTROL
},
84 This is Line6's MIDI manufacturer ID.
86 const unsigned char line6_midi_id
[] = {
91 Code to request version of POD, Variax interface
92 (and maybe other devices).
94 static const char line6_request_version
[] = {
95 0xf0, 0x7e, 0x7f, 0x06, 0x01, 0xf7
99 Class for asynchronous messages.
102 struct usb_line6
*line6
;
109 Forward declarations.
111 static void line6_data_received(struct urb
*urb
);
112 static int line6_send_raw_message_async_part(struct message
*msg
,
116 Start to listen on endpoint.
118 static int line6_start_listen(struct usb_line6
*line6
)
121 usb_fill_int_urb(line6
->urb_listen
, line6
->usbdev
,
122 usb_rcvintpipe(line6
->usbdev
, line6
->ep_control_read
),
123 line6
->buffer_listen
, LINE6_BUFSIZE_LISTEN
,
124 line6_data_received
, line6
, line6
->interval
);
125 line6
->urb_listen
->actual_length
= 0;
126 err
= usb_submit_urb(line6
->urb_listen
, GFP_ATOMIC
);
131 Stop listening on endpoint.
133 static void line6_stop_listen(struct usb_line6
*line6
)
135 usb_kill_urb(line6
->urb_listen
);
139 Send raw message in pieces of wMaxPacketSize bytes.
141 int line6_send_raw_message(struct usb_line6
*line6
, const char *buffer
,
146 for (i
= 0; i
< size
; i
+= line6
->max_packet_size
) {
148 const char *frag_buf
= buffer
+ i
;
149 int frag_size
= min(line6
->max_packet_size
, size
- i
);
152 retval
= usb_interrupt_msg(line6
->usbdev
,
153 usb_sndintpipe(line6
->usbdev
,
154 line6
->ep_control_write
),
155 (char *)frag_buf
, frag_size
,
156 &partial
, LINE6_TIMEOUT
* HZ
);
159 dev_err(line6
->ifcdev
,
160 "usb_interrupt_msg failed (%d)\n", retval
);
171 Notification of completion of asynchronous request transmission.
173 static void line6_async_request_sent(struct urb
*urb
)
175 struct message
*msg
= (struct message
*)urb
->context
;
177 if (msg
->done
>= msg
->size
) {
181 line6_send_raw_message_async_part(msg
, urb
);
185 Asynchronously send part of a raw message.
187 static int line6_send_raw_message_async_part(struct message
*msg
,
191 struct usb_line6
*line6
= msg
->line6
;
192 int done
= msg
->done
;
193 int bytes
= min(msg
->size
- done
, line6
->max_packet_size
);
195 usb_fill_int_urb(urb
, line6
->usbdev
,
196 usb_sndintpipe(line6
->usbdev
, line6
->ep_control_write
),
197 (char *)msg
->buffer
+ done
, bytes
,
198 line6_async_request_sent
, msg
, line6
->interval
);
201 retval
= usb_submit_urb(urb
, GFP_ATOMIC
);
204 dev_err(line6
->ifcdev
, "%s: usb_submit_urb failed (%d)\n",
215 Setup and start timer.
217 void line6_start_timer(struct timer_list
*timer
, unsigned int msecs
,
218 void (*function
) (unsigned long), unsigned long data
)
220 setup_timer(timer
, function
, data
);
221 timer
->expires
= jiffies
+ msecs
* HZ
/ 1000;
226 Asynchronously send raw message.
228 int line6_send_raw_message_async(struct usb_line6
*line6
, const char *buffer
,
234 /* create message: */
235 msg
= kmalloc(sizeof(struct message
), GFP_ATOMIC
);
240 urb
= usb_alloc_urb(0, GFP_ATOMIC
);
244 dev_err(line6
->ifcdev
, "Out of memory\n");
248 /* set message data: */
250 msg
->buffer
= buffer
;
255 return line6_send_raw_message_async_part(msg
, urb
);
259 Send asynchronous device version request.
261 int line6_version_request_async(struct usb_line6
*line6
)
266 buffer
= kmemdup(line6_request_version
,
267 sizeof(line6_request_version
), GFP_ATOMIC
);
268 if (buffer
== NULL
) {
269 dev_err(line6
->ifcdev
, "Out of memory");
273 retval
= line6_send_raw_message_async(line6
, buffer
,
274 sizeof(line6_request_version
));
280 Send sysex message in pieces of wMaxPacketSize bytes.
282 int line6_send_sysex_message(struct usb_line6
*line6
, const char *buffer
,
285 return line6_send_raw_message(line6
, buffer
,
286 size
+ SYSEX_EXTRA_SIZE
) -
291 Allocate buffer for sysex message and prepare header.
292 @param code sysex message code
293 @param size number of bytes between code and sysex end
295 char *line6_alloc_sysex_buffer(struct usb_line6
*line6
, int code1
, int code2
,
298 char *buffer
= kmalloc(size
+ SYSEX_EXTRA_SIZE
, GFP_ATOMIC
);
303 buffer
[0] = LINE6_SYSEX_BEGIN
;
304 memcpy(buffer
+ 1, line6_midi_id
, sizeof(line6_midi_id
));
305 buffer
[sizeof(line6_midi_id
) + 1] = code1
;
306 buffer
[sizeof(line6_midi_id
) + 2] = code2
;
307 buffer
[sizeof(line6_midi_id
) + 3 + size
] = LINE6_SYSEX_END
;
312 Notification of data received from the Line6 device.
314 static void line6_data_received(struct urb
*urb
)
316 struct usb_line6
*line6
= (struct usb_line6
*)urb
->context
;
317 struct midi_buffer
*mb
= &line6
->line6midi
->midibuf_in
;
320 if (urb
->status
== -ESHUTDOWN
)
324 line6_midibuf_write(mb
, urb
->transfer_buffer
, urb
->actual_length
);
326 if (done
< urb
->actual_length
) {
327 line6_midibuf_ignore(mb
, done
);
328 dev_dbg(line6
->ifcdev
, "%d %d buffer overflow - message skipped\n",
329 done
, urb
->actual_length
);
334 line6_midibuf_read(mb
, line6
->buffer_message
,
335 LINE6_MESSAGE_MAXLEN
);
340 line6
->message_length
= done
;
341 line6_midi_receive(line6
, line6
->buffer_message
, done
);
343 switch (line6
->usbdev
->descriptor
.idProduct
) {
344 case LINE6_DEVID_BASSPODXT
:
345 case LINE6_DEVID_BASSPODXTLIVE
:
346 case LINE6_DEVID_BASSPODXTPRO
:
347 case LINE6_DEVID_PODXT
:
348 case LINE6_DEVID_PODXTPRO
:
349 case LINE6_DEVID_POCKETPOD
:
350 line6_pod_process_message((struct usb_line6_pod
*)
354 case LINE6_DEVID_PODHD300
:
355 case LINE6_DEVID_PODHD500
:
356 break; /* let userspace handle MIDI */
358 case LINE6_DEVID_PODXTLIVE
:
359 switch (line6
->interface_number
) {
360 case PODXTLIVE_INTERFACE_POD
:
361 line6_pod_process_message((struct usb_line6_pod
365 case PODXTLIVE_INTERFACE_VARIAX
:
366 line6_variax_process_message((struct
372 dev_err(line6
->ifcdev
,
373 "PODxt Live interface %d not supported\n",
374 line6
->interface_number
);
378 case LINE6_DEVID_VARIAX
:
379 line6_variax_process_message((struct usb_line6_variax
*)
388 line6_start_listen(line6
);
392 Send channel number (i.e., switch to a different sound).
394 int line6_send_program(struct usb_line6
*line6
, u8 value
)
397 unsigned char *buffer
;
400 buffer
= kmalloc(2, GFP_KERNEL
);
404 buffer
[0] = LINE6_PROGRAM_CHANGE
| LINE6_CHANNEL_HOST
;
407 retval
= usb_interrupt_msg(line6
->usbdev
,
408 usb_sndintpipe(line6
->usbdev
,
409 line6
->ep_control_write
),
410 buffer
, 2, &partial
, LINE6_TIMEOUT
* HZ
);
413 dev_err(line6
->ifcdev
, "usb_interrupt_msg failed (%d)\n",
421 Transmit Line6 control parameter.
423 int line6_transmit_parameter(struct usb_line6
*line6
, int param
, u8 value
)
426 unsigned char *buffer
;
429 buffer
= kmalloc(3, GFP_KERNEL
);
433 buffer
[0] = LINE6_PARAM_CHANGE
| LINE6_CHANNEL_HOST
;
437 retval
= usb_interrupt_msg(line6
->usbdev
,
438 usb_sndintpipe(line6
->usbdev
,
439 line6
->ep_control_write
),
440 buffer
, 3, &partial
, LINE6_TIMEOUT
* HZ
);
443 dev_err(line6
->ifcdev
, "usb_interrupt_msg failed (%d)\n",
451 Read data from device.
453 int line6_read_data(struct usb_line6
*line6
, int address
, void *data
,
456 struct usb_device
*usbdev
= line6
->usbdev
;
460 /* query the serial number: */
461 ret
= usb_control_msg(usbdev
, usb_sndctrlpipe(usbdev
, 0), 0x67,
462 USB_TYPE_VENDOR
| USB_RECIP_DEVICE
| USB_DIR_OUT
,
463 (datalen
<< 8) | 0x21, address
,
464 NULL
, 0, LINE6_TIMEOUT
* HZ
);
467 dev_err(line6
->ifcdev
, "read request failed (error %d)\n", ret
);
471 /* Wait for data length. We'll get 0xff until length arrives. */
473 ret
= usb_control_msg(usbdev
, usb_rcvctrlpipe(usbdev
, 0), 0x67,
474 USB_TYPE_VENDOR
| USB_RECIP_DEVICE
|
476 0x0012, 0x0000, &len
, 1,
479 dev_err(line6
->ifcdev
,
480 "receive length failed (error %d)\n", ret
);
483 } while (len
== 0xff);
485 if (len
!= datalen
) {
486 /* should be equal or something went wrong */
487 dev_err(line6
->ifcdev
,
488 "length mismatch (expected %d, got %d)\n",
489 (int)datalen
, (int)len
);
493 /* receive the result: */
494 ret
= usb_control_msg(usbdev
, usb_rcvctrlpipe(usbdev
, 0), 0x67,
495 USB_TYPE_VENDOR
| USB_RECIP_DEVICE
| USB_DIR_IN
,
496 0x0013, 0x0000, data
, datalen
,
500 dev_err(line6
->ifcdev
, "read failed (error %d)\n", ret
);
508 Write data to device.
510 int line6_write_data(struct usb_line6
*line6
, int address
, void *data
,
513 struct usb_device
*usbdev
= line6
->usbdev
;
515 unsigned char status
;
517 ret
= usb_control_msg(usbdev
, usb_sndctrlpipe(usbdev
, 0), 0x67,
518 USB_TYPE_VENDOR
| USB_RECIP_DEVICE
| USB_DIR_OUT
,
519 0x0022, address
, data
, datalen
,
523 dev_err(line6
->ifcdev
,
524 "write request failed (error %d)\n", ret
);
529 ret
= usb_control_msg(usbdev
, usb_rcvctrlpipe(usbdev
, 0),
531 USB_TYPE_VENDOR
| USB_RECIP_DEVICE
|
534 &status
, 1, LINE6_TIMEOUT
* HZ
);
537 dev_err(line6
->ifcdev
,
538 "receiving status failed (error %d)\n", ret
);
541 } while (status
== 0xff);
544 dev_err(line6
->ifcdev
, "write failed (error %d)\n", ret
);
552 Read Line6 device serial number.
553 (POD, TonePort, GuitarPort)
555 int line6_read_serial_number(struct usb_line6
*line6
, int *serial_number
)
557 return line6_read_data(line6
, 0x80d0, serial_number
,
558 sizeof(*serial_number
));
562 No operation (i.e., unsupported).
564 ssize_t
line6_nop_read(struct device
*dev
, struct device_attribute
*attr
,
573 static void line6_destruct(struct usb_interface
*interface
)
575 struct usb_line6
*line6
;
577 if (interface
== NULL
)
579 line6
= usb_get_intfdata(interface
);
583 /* free buffer memory first: */
584 kfree(line6
->buffer_message
);
585 kfree(line6
->buffer_listen
);
587 /* then free URBs: */
588 usb_free_urb(line6
->urb_listen
);
590 /* make sure the device isn't destructed twice: */
591 usb_set_intfdata(interface
, NULL
);
593 /* free interface data: */
600 static int line6_probe(struct usb_interface
*interface
,
601 const struct usb_device_id
*id
)
604 struct usb_device
*usbdev
;
605 struct usb_line6
*line6
;
606 const struct line6_properties
*properties
;
607 int interface_number
, alternate
= 0;
610 int ep_read
= 0, ep_write
= 0;
613 if (interface
== NULL
)
615 usbdev
= interface_to_usbdev(interface
);
619 /* we don't handle multiple configurations */
620 if (usbdev
->descriptor
.bNumConfigurations
!= 1) {
625 /* check vendor and product id */
626 for (devtype
= ARRAY_SIZE(line6_id_table
) - 1; devtype
--;) {
627 u16 idVendor
= le16_to_cpu(usbdev
->descriptor
.idVendor
);
628 u16 idProduct
= le16_to_cpu(usbdev
->descriptor
.idProduct
);
630 if (idVendor
== line6_id_table
[devtype
].idVendor
&&
631 idProduct
== line6_id_table
[devtype
].idProduct
)
640 /* initialize device info: */
641 properties
= &line6_properties_table
[devtype
];
642 dev_info(&interface
->dev
, "Line6 %s found\n", properties
->name
);
643 product
= le16_to_cpu(usbdev
->descriptor
.idProduct
);
645 /* query interface number */
646 interface_number
= interface
->cur_altsetting
->desc
.bInterfaceNumber
;
649 case LINE6_DEVID_BASSPODXTLIVE
:
650 case LINE6_DEVID_PODXTLIVE
:
651 case LINE6_DEVID_VARIAX
:
655 case LINE6_DEVID_POCKETPOD
:
656 switch (interface_number
) {
658 return 0; /* this interface has no endpoints */
667 case LINE6_DEVID_PODHD500
:
668 case LINE6_DEVID_PODX3
:
669 case LINE6_DEVID_PODX3LIVE
:
670 switch (interface_number
) {
682 case LINE6_DEVID_BASSPODXT
:
683 case LINE6_DEVID_BASSPODXTPRO
:
684 case LINE6_DEVID_PODXT
:
685 case LINE6_DEVID_PODXTPRO
:
686 case LINE6_DEVID_PODHD300
:
690 case LINE6_DEVID_GUITARPORT
:
691 case LINE6_DEVID_PODSTUDIO_GX
:
692 case LINE6_DEVID_PODSTUDIO_UX1
:
693 case LINE6_DEVID_TONEPORT_GX
:
694 case LINE6_DEVID_TONEPORT_UX1
:
695 alternate
= 2; /* 1..4 seem to be ok */
698 case LINE6_DEVID_TONEPORT_UX2
:
699 case LINE6_DEVID_PODSTUDIO_UX2
:
700 switch (interface_number
) {
702 /* defaults to 44.1kHz, 16-bit */
706 /* don't know yet what this is ...
722 ret
= usb_set_interface(usbdev
, interface_number
, alternate
);
724 dev_err(&interface
->dev
, "set_interface failed\n");
728 /* initialize device data based on product id: */
730 case LINE6_DEVID_BASSPODXT
:
731 case LINE6_DEVID_BASSPODXTLIVE
:
732 case LINE6_DEVID_BASSPODXTPRO
:
733 case LINE6_DEVID_PODXT
:
734 case LINE6_DEVID_PODXTPRO
:
735 size
= sizeof(struct usb_line6_pod
);
740 case LINE6_DEVID_PODHD300
:
741 size
= sizeof(struct usb_line6_podhd
);
746 case LINE6_DEVID_PODHD500
:
747 size
= sizeof(struct usb_line6_podhd
);
752 case LINE6_DEVID_POCKETPOD
:
753 size
= sizeof(struct usb_line6_pod
);
758 case LINE6_DEVID_PODX3
:
759 case LINE6_DEVID_PODX3LIVE
:
760 /* currently unused! */
761 size
= sizeof(struct usb_line6_pod
);
766 case LINE6_DEVID_PODSTUDIO_GX
:
767 case LINE6_DEVID_PODSTUDIO_UX1
:
768 case LINE6_DEVID_PODSTUDIO_UX2
:
769 case LINE6_DEVID_TONEPORT_GX
:
770 case LINE6_DEVID_TONEPORT_UX1
:
771 case LINE6_DEVID_TONEPORT_UX2
:
772 case LINE6_DEVID_GUITARPORT
:
773 size
= sizeof(struct usb_line6_toneport
);
774 /* these don't have a control channel */
777 case LINE6_DEVID_PODXTLIVE
:
778 switch (interface_number
) {
779 case PODXTLIVE_INTERFACE_POD
:
780 size
= sizeof(struct usb_line6_pod
);
785 case PODXTLIVE_INTERFACE_VARIAX
:
786 size
= sizeof(struct usb_line6_variax
);
797 case LINE6_DEVID_VARIAX
:
798 size
= sizeof(struct usb_line6_variax
);
810 dev_err(&interface
->dev
,
811 "driver bug: interface data size not set\n");
816 line6
= kzalloc(size
, GFP_KERNEL
);
822 /* store basic data: */
823 line6
->interface_number
= interface_number
;
824 line6
->properties
= properties
;
825 line6
->usbdev
= usbdev
;
826 line6
->ifcdev
= &interface
->dev
;
827 line6
->ep_control_read
= ep_read
;
828 line6
->ep_control_write
= ep_write
;
829 line6
->product
= product
;
831 /* get data from endpoint descriptor (see usb_maxpacket): */
833 struct usb_host_endpoint
*ep
;
835 usb_pipeendpoint(usb_rcvintpipe(usbdev
, ep_read
));
836 ep
= usbdev
->ep_in
[epnum
];
839 line6
->interval
= ep
->desc
.bInterval
;
840 line6
->max_packet_size
=
841 le16_to_cpu(ep
->desc
.wMaxPacketSize
);
843 line6
->interval
= LINE6_FALLBACK_INTERVAL
;
844 line6
->max_packet_size
= LINE6_FALLBACK_MAXPACKETSIZE
;
845 dev_err(line6
->ifcdev
,
846 "endpoint not available, using fallback values");
850 usb_set_intfdata(interface
, line6
);
852 if (properties
->capabilities
& LINE6_BIT_CONTROL
) {
853 /* initialize USB buffers: */
854 line6
->buffer_listen
=
855 kmalloc(LINE6_BUFSIZE_LISTEN
, GFP_KERNEL
);
856 if (line6
->buffer_listen
== NULL
) {
861 line6
->buffer_message
=
862 kmalloc(LINE6_MESSAGE_MAXLEN
, GFP_KERNEL
);
863 if (line6
->buffer_message
== NULL
) {
868 line6
->urb_listen
= usb_alloc_urb(0, GFP_KERNEL
);
870 if (line6
->urb_listen
== NULL
) {
871 dev_err(&interface
->dev
, "Out of memory\n");
872 line6_destruct(interface
);
877 ret
= line6_start_listen(line6
);
879 dev_err(&interface
->dev
, "%s: usb_submit_urb failed\n",
885 /* initialize device data based on product id: */
887 case LINE6_DEVID_BASSPODXT
:
888 case LINE6_DEVID_BASSPODXTLIVE
:
889 case LINE6_DEVID_BASSPODXTPRO
:
890 case LINE6_DEVID_POCKETPOD
:
891 case LINE6_DEVID_PODX3
:
892 case LINE6_DEVID_PODX3LIVE
:
893 case LINE6_DEVID_PODXT
:
894 case LINE6_DEVID_PODXTPRO
:
895 ret
= line6_pod_init(interface
, (struct usb_line6_pod
*)line6
);
898 case LINE6_DEVID_PODHD300
:
899 case LINE6_DEVID_PODHD500
:
900 ret
= line6_podhd_init(interface
,
901 (struct usb_line6_podhd
*)line6
);
904 case LINE6_DEVID_PODXTLIVE
:
905 switch (interface_number
) {
906 case PODXTLIVE_INTERFACE_POD
:
908 line6_pod_init(interface
,
909 (struct usb_line6_pod
*)line6
);
912 case PODXTLIVE_INTERFACE_VARIAX
:
914 line6_variax_init(interface
,
915 (struct usb_line6_variax
*)line6
);
919 dev_err(&interface
->dev
,
920 "PODxt Live interface %d not supported\n",
927 case LINE6_DEVID_VARIAX
:
929 line6_variax_init(interface
,
930 (struct usb_line6_variax
*)line6
);
933 case LINE6_DEVID_PODSTUDIO_GX
:
934 case LINE6_DEVID_PODSTUDIO_UX1
:
935 case LINE6_DEVID_PODSTUDIO_UX2
:
936 case LINE6_DEVID_TONEPORT_GX
:
937 case LINE6_DEVID_TONEPORT_UX1
:
938 case LINE6_DEVID_TONEPORT_UX2
:
939 case LINE6_DEVID_GUITARPORT
:
941 line6_toneport_init(interface
,
942 (struct usb_line6_toneport
*)line6
);
953 ret
= sysfs_create_link(&interface
->dev
.kobj
, &usbdev
->dev
.kobj
,
958 /* creation of additional special files should go here */
960 dev_info(&interface
->dev
, "Line6 %s now attached\n",
961 line6
->properties
->name
);
964 case LINE6_DEVID_PODX3
:
965 case LINE6_DEVID_PODX3LIVE
:
966 dev_info(&interface
->dev
,
967 "NOTE: the Line6 %s is detected, but not yet supported\n",
968 line6
->properties
->name
);
971 /* increment reference counters: */
972 usb_get_intf(interface
);
978 line6_destruct(interface
);
984 Line6 device disconnected.
986 static void line6_disconnect(struct usb_interface
*interface
)
988 struct usb_line6
*line6
;
989 struct usb_device
*usbdev
;
990 int interface_number
;
992 if (interface
== NULL
)
994 usbdev
= interface_to_usbdev(interface
);
998 /* removal of additional special files should go here */
1000 sysfs_remove_link(&interface
->dev
.kobj
, "usb_device");
1002 interface_number
= interface
->cur_altsetting
->desc
.bInterfaceNumber
;
1003 line6
= usb_get_intfdata(interface
);
1005 if (line6
!= NULL
) {
1006 if (line6
->urb_listen
!= NULL
)
1007 line6_stop_listen(line6
);
1009 if (usbdev
!= line6
->usbdev
)
1010 dev_err(line6
->ifcdev
,
1011 "driver bug: inconsistent usb device\n");
1013 switch (line6
->usbdev
->descriptor
.idProduct
) {
1014 case LINE6_DEVID_BASSPODXT
:
1015 case LINE6_DEVID_BASSPODXTLIVE
:
1016 case LINE6_DEVID_BASSPODXTPRO
:
1017 case LINE6_DEVID_POCKETPOD
:
1018 case LINE6_DEVID_PODX3
:
1019 case LINE6_DEVID_PODX3LIVE
:
1020 case LINE6_DEVID_PODXT
:
1021 case LINE6_DEVID_PODXTPRO
:
1022 line6_pod_disconnect(interface
);
1025 case LINE6_DEVID_PODHD300
:
1026 case LINE6_DEVID_PODHD500
:
1027 line6_podhd_disconnect(interface
);
1030 case LINE6_DEVID_PODXTLIVE
:
1031 switch (interface_number
) {
1032 case PODXTLIVE_INTERFACE_POD
:
1033 line6_pod_disconnect(interface
);
1036 case PODXTLIVE_INTERFACE_VARIAX
:
1037 line6_variax_disconnect(interface
);
1043 case LINE6_DEVID_VARIAX
:
1044 line6_variax_disconnect(interface
);
1047 case LINE6_DEVID_PODSTUDIO_GX
:
1048 case LINE6_DEVID_PODSTUDIO_UX1
:
1049 case LINE6_DEVID_PODSTUDIO_UX2
:
1050 case LINE6_DEVID_TONEPORT_GX
:
1051 case LINE6_DEVID_TONEPORT_UX1
:
1052 case LINE6_DEVID_TONEPORT_UX2
:
1053 case LINE6_DEVID_GUITARPORT
:
1054 line6_toneport_disconnect(interface
);
1061 dev_info(&interface
->dev
, "Line6 %s now disconnected\n",
1062 line6
->properties
->name
);
1065 line6_destruct(interface
);
1067 /* decrement reference counters: */
1068 usb_put_intf(interface
);
1069 usb_put_dev(usbdev
);
1075 Suspend Line6 device.
1077 static int line6_suspend(struct usb_interface
*interface
, pm_message_t message
)
1079 struct usb_line6
*line6
= usb_get_intfdata(interface
);
1080 struct snd_line6_pcm
*line6pcm
= line6
->line6pcm
;
1082 snd_power_change_state(line6
->card
, SNDRV_CTL_POWER_D3hot
);
1084 if (line6
->properties
->capabilities
& LINE6_BIT_CONTROL
)
1085 line6_stop_listen(line6
);
1087 if (line6pcm
!= NULL
) {
1088 snd_pcm_suspend_all(line6pcm
->pcm
);
1089 line6_pcm_disconnect(line6pcm
);
1090 line6pcm
->flags
= 0;
1097 Resume Line6 device.
1099 static int line6_resume(struct usb_interface
*interface
)
1101 struct usb_line6
*line6
= usb_get_intfdata(interface
);
1103 if (line6
->properties
->capabilities
& LINE6_BIT_CONTROL
)
1104 line6_start_listen(line6
);
1106 snd_power_change_state(line6
->card
, SNDRV_CTL_POWER_D0
);
1111 Resume Line6 device after reset.
1113 static int line6_reset_resume(struct usb_interface
*interface
)
1115 struct usb_line6
*line6
= usb_get_intfdata(interface
);
1117 switch (line6
->usbdev
->descriptor
.idProduct
) {
1118 case LINE6_DEVID_PODSTUDIO_GX
:
1119 case LINE6_DEVID_PODSTUDIO_UX1
:
1120 case LINE6_DEVID_PODSTUDIO_UX2
:
1121 case LINE6_DEVID_TONEPORT_GX
:
1122 case LINE6_DEVID_TONEPORT_UX1
:
1123 case LINE6_DEVID_TONEPORT_UX2
:
1124 case LINE6_DEVID_GUITARPORT
:
1125 line6_toneport_reset_resume((struct usb_line6_toneport
*)line6
);
1128 return line6_resume(interface
);
1131 #endif /* CONFIG_PM */
1133 static struct usb_driver line6_driver
= {
1134 .name
= DRIVER_NAME
,
1135 .probe
= line6_probe
,
1136 .disconnect
= line6_disconnect
,
1138 .suspend
= line6_suspend
,
1139 .resume
= line6_resume
,
1140 .reset_resume
= line6_reset_resume
,
1142 .id_table
= line6_id_table
,
1145 module_usb_driver(line6_driver
);
1147 MODULE_AUTHOR(DRIVER_AUTHOR
);
1148 MODULE_DESCRIPTION(DRIVER_DESC
);
1149 MODULE_LICENSE("GPL");
1150 MODULE_VERSION(DRIVER_VERSION
);