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_PODHD400
)},
42 {USB_DEVICE(LINE6_VENDOR_ID
, LINE6_DEVID_PODHD500
)},
43 {USB_DEVICE(LINE6_VENDOR_ID
, LINE6_DEVID_PODSTUDIO_GX
)},
44 {USB_DEVICE(LINE6_VENDOR_ID
, LINE6_DEVID_PODSTUDIO_UX1
)},
45 {USB_DEVICE(LINE6_VENDOR_ID
, LINE6_DEVID_PODSTUDIO_UX2
)},
46 {USB_DEVICE(LINE6_VENDOR_ID
, LINE6_DEVID_PODX3
)},
47 {USB_DEVICE(LINE6_VENDOR_ID
, LINE6_DEVID_PODX3LIVE
)},
48 {USB_DEVICE(LINE6_VENDOR_ID
, LINE6_DEVID_PODXT
)},
49 {USB_DEVICE(LINE6_VENDOR_ID
, LINE6_DEVID_PODXTLIVE
)},
50 {USB_DEVICE(LINE6_VENDOR_ID
, LINE6_DEVID_PODXTPRO
)},
51 {USB_DEVICE(LINE6_VENDOR_ID
, LINE6_DEVID_TONEPORT_GX
)},
52 {USB_DEVICE(LINE6_VENDOR_ID
, LINE6_DEVID_TONEPORT_UX1
)},
53 {USB_DEVICE(LINE6_VENDOR_ID
, LINE6_DEVID_TONEPORT_UX2
)},
54 {USB_DEVICE(LINE6_VENDOR_ID
, LINE6_DEVID_VARIAX
)},
58 MODULE_DEVICE_TABLE(usb
, line6_id_table
);
60 #define L6PROP(dev_bit, dev_id, dev_name, dev_cap)\
61 {.device_bit = LINE6_BIT_##dev_bit, .id = dev_id,\
62 .name = dev_name, .capabilities = LINE6_BIT_##dev_cap}
65 static const struct line6_properties line6_properties_table
[] = {
66 L6PROP(BASSPODXT
, "BassPODxt", "BassPODxt", CTRL_PCM_HW
),
67 L6PROP(BASSPODXTLIVE
, "BassPODxtLive", "BassPODxt Live", CTRL_PCM_HW
),
68 L6PROP(BASSPODXTPRO
, "BassPODxtPro", "BassPODxt Pro", CTRL_PCM_HW
),
69 L6PROP(GUITARPORT
, "GuitarPort", "GuitarPort", PCM
),
70 L6PROP(POCKETPOD
, "PocketPOD", "Pocket POD", CONTROL
),
71 L6PROP(PODHD300
, "PODHD300", "POD HD300", CTRL_PCM_HW
),
72 L6PROP(PODHD400
, "PODHD400", "POD HD400", CTRL_PCM_HW
),
73 L6PROP(PODHD500
, "PODHD500", "POD HD500", CTRL_PCM_HW
),
74 L6PROP(PODSTUDIO_GX
, "PODStudioGX", "POD Studio GX", PCM
),
75 L6PROP(PODSTUDIO_UX1
, "PODStudioUX1", "POD Studio UX1", PCM
),
76 L6PROP(PODSTUDIO_UX2
, "PODStudioUX2", "POD Studio UX2", PCM
),
77 L6PROP(PODX3
, "PODX3", "POD X3", PCM
),
78 L6PROP(PODX3LIVE
, "PODX3Live", "POD X3 Live", PCM
),
79 L6PROP(PODXT
, "PODxt", "PODxt", CTRL_PCM_HW
),
80 L6PROP(PODXTLIVE
, "PODxtLive", "PODxt Live", CTRL_PCM_HW
),
81 L6PROP(PODXTPRO
, "PODxtPro", "PODxt Pro", CTRL_PCM_HW
),
82 L6PROP(TONEPORT_GX
, "TonePortGX", "TonePort GX", PCM
),
83 L6PROP(TONEPORT_UX1
, "TonePortUX1", "TonePort UX1", PCM
),
84 L6PROP(TONEPORT_UX2
, "TonePortUX2", "TonePort UX2", PCM
),
85 L6PROP(VARIAX
, "Variax", "Variax Workbench", CONTROL
),
90 This is Line6's MIDI manufacturer ID.
92 const unsigned char line6_midi_id
[] = {
97 Code to request version of POD, Variax interface
98 (and maybe other devices).
100 static const char line6_request_version
[] = {
101 0xf0, 0x7e, 0x7f, 0x06, 0x01, 0xf7
105 Class for asynchronous messages.
108 struct usb_line6
*line6
;
115 Forward declarations.
117 static void line6_data_received(struct urb
*urb
);
118 static int line6_send_raw_message_async_part(struct message
*msg
,
122 Start to listen on endpoint.
124 static int line6_start_listen(struct usb_line6
*line6
)
127 usb_fill_int_urb(line6
->urb_listen
, line6
->usbdev
,
128 usb_rcvintpipe(line6
->usbdev
, line6
->ep_control_read
),
129 line6
->buffer_listen
, LINE6_BUFSIZE_LISTEN
,
130 line6_data_received
, line6
, line6
->interval
);
131 line6
->urb_listen
->actual_length
= 0;
132 err
= usb_submit_urb(line6
->urb_listen
, GFP_ATOMIC
);
137 Stop listening on endpoint.
139 static void line6_stop_listen(struct usb_line6
*line6
)
141 usb_kill_urb(line6
->urb_listen
);
145 Send raw message in pieces of wMaxPacketSize bytes.
147 int line6_send_raw_message(struct usb_line6
*line6
, const char *buffer
,
152 for (i
= 0; i
< size
; i
+= line6
->max_packet_size
) {
154 const char *frag_buf
= buffer
+ i
;
155 int frag_size
= min(line6
->max_packet_size
, size
- i
);
158 retval
= usb_interrupt_msg(line6
->usbdev
,
159 usb_sndintpipe(line6
->usbdev
,
160 line6
->ep_control_write
),
161 (char *)frag_buf
, frag_size
,
162 &partial
, LINE6_TIMEOUT
* HZ
);
165 dev_err(line6
->ifcdev
,
166 "usb_interrupt_msg failed (%d)\n", retval
);
177 Notification of completion of asynchronous request transmission.
179 static void line6_async_request_sent(struct urb
*urb
)
181 struct message
*msg
= (struct message
*)urb
->context
;
183 if (msg
->done
>= msg
->size
) {
187 line6_send_raw_message_async_part(msg
, urb
);
191 Asynchronously send part of a raw message.
193 static int line6_send_raw_message_async_part(struct message
*msg
,
197 struct usb_line6
*line6
= msg
->line6
;
198 int done
= msg
->done
;
199 int bytes
= min(msg
->size
- done
, line6
->max_packet_size
);
201 usb_fill_int_urb(urb
, line6
->usbdev
,
202 usb_sndintpipe(line6
->usbdev
, line6
->ep_control_write
),
203 (char *)msg
->buffer
+ done
, bytes
,
204 line6_async_request_sent
, msg
, line6
->interval
);
207 retval
= usb_submit_urb(urb
, GFP_ATOMIC
);
210 dev_err(line6
->ifcdev
, "%s: usb_submit_urb failed (%d)\n",
221 Setup and start timer.
223 void line6_start_timer(struct timer_list
*timer
, unsigned int msecs
,
224 void (*function
)(unsigned long), unsigned long data
)
226 setup_timer(timer
, function
, data
);
227 timer
->expires
= jiffies
+ msecs
* HZ
/ 1000;
232 Asynchronously send raw message.
234 int line6_send_raw_message_async(struct usb_line6
*line6
, const char *buffer
,
240 /* create message: */
241 msg
= kmalloc(sizeof(struct message
), GFP_ATOMIC
);
246 urb
= usb_alloc_urb(0, GFP_ATOMIC
);
250 dev_err(line6
->ifcdev
, "Out of memory\n");
254 /* set message data: */
256 msg
->buffer
= buffer
;
261 return line6_send_raw_message_async_part(msg
, urb
);
265 Send asynchronous device version request.
267 int line6_version_request_async(struct usb_line6
*line6
)
272 buffer
= kmemdup(line6_request_version
,
273 sizeof(line6_request_version
), GFP_ATOMIC
);
274 if (buffer
== NULL
) {
275 dev_err(line6
->ifcdev
, "Out of memory");
279 retval
= line6_send_raw_message_async(line6
, buffer
,
280 sizeof(line6_request_version
));
286 Send sysex message in pieces of wMaxPacketSize bytes.
288 int line6_send_sysex_message(struct usb_line6
*line6
, const char *buffer
,
291 return line6_send_raw_message(line6
, buffer
,
292 size
+ SYSEX_EXTRA_SIZE
) -
297 Allocate buffer for sysex message and prepare header.
298 @param code sysex message code
299 @param size number of bytes between code and sysex end
301 char *line6_alloc_sysex_buffer(struct usb_line6
*line6
, int code1
, int code2
,
304 char *buffer
= kmalloc(size
+ SYSEX_EXTRA_SIZE
, GFP_ATOMIC
);
309 buffer
[0] = LINE6_SYSEX_BEGIN
;
310 memcpy(buffer
+ 1, line6_midi_id
, sizeof(line6_midi_id
));
311 buffer
[sizeof(line6_midi_id
) + 1] = code1
;
312 buffer
[sizeof(line6_midi_id
) + 2] = code2
;
313 buffer
[sizeof(line6_midi_id
) + 3 + size
] = LINE6_SYSEX_END
;
318 Notification of data received from the Line6 device.
320 static void line6_data_received(struct urb
*urb
)
322 struct usb_line6
*line6
= (struct usb_line6
*)urb
->context
;
323 struct midi_buffer
*mb
= &line6
->line6midi
->midibuf_in
;
326 if (urb
->status
== -ESHUTDOWN
)
330 line6_midibuf_write(mb
, urb
->transfer_buffer
, urb
->actual_length
);
332 if (done
< urb
->actual_length
) {
333 line6_midibuf_ignore(mb
, done
);
334 dev_dbg(line6
->ifcdev
, "%d %d buffer overflow - message skipped\n",
335 done
, urb
->actual_length
);
340 line6_midibuf_read(mb
, line6
->buffer_message
,
341 LINE6_MESSAGE_MAXLEN
);
346 line6
->message_length
= done
;
347 line6_midi_receive(line6
, line6
->buffer_message
, done
);
349 switch (le16_to_cpu(line6
->usbdev
->descriptor
.idProduct
)) {
350 case LINE6_DEVID_BASSPODXT
:
351 case LINE6_DEVID_BASSPODXTLIVE
:
352 case LINE6_DEVID_BASSPODXTPRO
:
353 case LINE6_DEVID_PODXT
:
354 case LINE6_DEVID_PODXTPRO
:
355 case LINE6_DEVID_POCKETPOD
:
356 line6_pod_process_message((struct usb_line6_pod
*)
360 case LINE6_DEVID_PODHD300
:
361 case LINE6_DEVID_PODHD400
:
362 case LINE6_DEVID_PODHD500
:
363 break; /* let userspace handle MIDI */
365 case LINE6_DEVID_PODXTLIVE
:
366 switch (line6
->interface_number
) {
367 case PODXTLIVE_INTERFACE_POD
:
368 line6_pod_process_message((struct usb_line6_pod
372 case PODXTLIVE_INTERFACE_VARIAX
:
373 line6_variax_process_message((struct
379 dev_err(line6
->ifcdev
,
380 "PODxt Live interface %d not supported\n",
381 line6
->interface_number
);
385 case LINE6_DEVID_VARIAX
:
386 line6_variax_process_message((struct usb_line6_variax
*)
395 line6_start_listen(line6
);
399 Send channel number (i.e., switch to a different sound).
401 int line6_send_program(struct usb_line6
*line6
, u8 value
)
404 unsigned char *buffer
;
407 buffer
= kmalloc(2, GFP_KERNEL
);
411 buffer
[0] = LINE6_PROGRAM_CHANGE
| LINE6_CHANNEL_HOST
;
414 retval
= usb_interrupt_msg(line6
->usbdev
,
415 usb_sndintpipe(line6
->usbdev
,
416 line6
->ep_control_write
),
417 buffer
, 2, &partial
, LINE6_TIMEOUT
* HZ
);
420 dev_err(line6
->ifcdev
, "usb_interrupt_msg failed (%d)\n",
428 Transmit Line6 control parameter.
430 int line6_transmit_parameter(struct usb_line6
*line6
, int param
, u8 value
)
433 unsigned char *buffer
;
436 buffer
= kmalloc(3, GFP_KERNEL
);
440 buffer
[0] = LINE6_PARAM_CHANGE
| LINE6_CHANNEL_HOST
;
444 retval
= usb_interrupt_msg(line6
->usbdev
,
445 usb_sndintpipe(line6
->usbdev
,
446 line6
->ep_control_write
),
447 buffer
, 3, &partial
, LINE6_TIMEOUT
* HZ
);
450 dev_err(line6
->ifcdev
, "usb_interrupt_msg failed (%d)\n",
458 Read data from device.
460 int line6_read_data(struct usb_line6
*line6
, int address
, void *data
,
463 struct usb_device
*usbdev
= line6
->usbdev
;
467 /* query the serial number: */
468 ret
= usb_control_msg(usbdev
, usb_sndctrlpipe(usbdev
, 0), 0x67,
469 USB_TYPE_VENDOR
| USB_RECIP_DEVICE
| USB_DIR_OUT
,
470 (datalen
<< 8) | 0x21, address
,
471 NULL
, 0, LINE6_TIMEOUT
* HZ
);
474 dev_err(line6
->ifcdev
, "read request failed (error %d)\n", ret
);
478 /* Wait for data length. We'll get 0xff until length arrives. */
480 ret
= usb_control_msg(usbdev
, usb_rcvctrlpipe(usbdev
, 0), 0x67,
481 USB_TYPE_VENDOR
| USB_RECIP_DEVICE
|
483 0x0012, 0x0000, &len
, 1,
486 dev_err(line6
->ifcdev
,
487 "receive length failed (error %d)\n", ret
);
490 } while (len
== 0xff);
492 if (len
!= datalen
) {
493 /* should be equal or something went wrong */
494 dev_err(line6
->ifcdev
,
495 "length mismatch (expected %d, got %d)\n",
496 (int)datalen
, (int)len
);
500 /* receive the result: */
501 ret
= usb_control_msg(usbdev
, usb_rcvctrlpipe(usbdev
, 0), 0x67,
502 USB_TYPE_VENDOR
| USB_RECIP_DEVICE
| USB_DIR_IN
,
503 0x0013, 0x0000, data
, datalen
,
507 dev_err(line6
->ifcdev
, "read failed (error %d)\n", ret
);
515 Write data to device.
517 int line6_write_data(struct usb_line6
*line6
, int address
, void *data
,
520 struct usb_device
*usbdev
= line6
->usbdev
;
522 unsigned char status
;
524 ret
= usb_control_msg(usbdev
, usb_sndctrlpipe(usbdev
, 0), 0x67,
525 USB_TYPE_VENDOR
| USB_RECIP_DEVICE
| USB_DIR_OUT
,
526 0x0022, address
, data
, datalen
,
530 dev_err(line6
->ifcdev
,
531 "write request failed (error %d)\n", ret
);
536 ret
= usb_control_msg(usbdev
, usb_rcvctrlpipe(usbdev
, 0),
538 USB_TYPE_VENDOR
| USB_RECIP_DEVICE
|
541 &status
, 1, LINE6_TIMEOUT
* HZ
);
544 dev_err(line6
->ifcdev
,
545 "receiving status failed (error %d)\n", ret
);
548 } while (status
== 0xff);
551 dev_err(line6
->ifcdev
, "write failed (error %d)\n", ret
);
559 Read Line6 device serial number.
560 (POD, TonePort, GuitarPort)
562 int line6_read_serial_number(struct usb_line6
*line6
, int *serial_number
)
564 return line6_read_data(line6
, 0x80d0, serial_number
,
565 sizeof(*serial_number
));
569 No operation (i.e., unsupported).
571 ssize_t
line6_nop_read(struct device
*dev
, struct device_attribute
*attr
,
580 static void line6_destruct(struct usb_interface
*interface
)
582 struct usb_line6
*line6
;
584 if (interface
== NULL
)
586 line6
= usb_get_intfdata(interface
);
590 /* free buffer memory first: */
591 kfree(line6
->buffer_message
);
592 kfree(line6
->buffer_listen
);
594 /* then free URBs: */
595 usb_free_urb(line6
->urb_listen
);
597 /* make sure the device isn't destructed twice: */
598 usb_set_intfdata(interface
, NULL
);
600 /* free interface data: */
607 static int line6_probe(struct usb_interface
*interface
,
608 const struct usb_device_id
*id
)
611 struct usb_device
*usbdev
;
612 struct usb_line6
*line6
;
613 const struct line6_properties
*properties
;
614 int interface_number
, alternate
= 0;
617 int ep_read
= 0, ep_write
= 0;
620 if (interface
== NULL
)
622 usbdev
= interface_to_usbdev(interface
);
626 /* we don't handle multiple configurations */
627 if (usbdev
->descriptor
.bNumConfigurations
!= 1) {
632 /* check vendor and product id */
633 for (devtype
= ARRAY_SIZE(line6_id_table
) - 1; devtype
--;) {
634 u16 idVendor
= le16_to_cpu(usbdev
->descriptor
.idVendor
);
635 u16 idProduct
= le16_to_cpu(usbdev
->descriptor
.idProduct
);
637 if (idVendor
== line6_id_table
[devtype
].idVendor
&&
638 idProduct
== line6_id_table
[devtype
].idProduct
)
647 /* initialize device info: */
648 properties
= &line6_properties_table
[devtype
];
649 dev_info(&interface
->dev
, "Line6 %s found\n", properties
->name
);
650 product
= le16_to_cpu(usbdev
->descriptor
.idProduct
);
652 /* query interface number */
653 interface_number
= interface
->cur_altsetting
->desc
.bInterfaceNumber
;
656 case LINE6_DEVID_BASSPODXTLIVE
:
657 case LINE6_DEVID_PODXTLIVE
:
658 case LINE6_DEVID_VARIAX
:
662 case LINE6_DEVID_POCKETPOD
:
663 switch (interface_number
) {
665 return 0; /* this interface has no endpoints */
674 case LINE6_DEVID_PODHD500
:
675 case LINE6_DEVID_PODX3
:
676 case LINE6_DEVID_PODX3LIVE
:
677 switch (interface_number
) {
689 case LINE6_DEVID_BASSPODXT
:
690 case LINE6_DEVID_BASSPODXTPRO
:
691 case LINE6_DEVID_PODXT
:
692 case LINE6_DEVID_PODXTPRO
:
693 case LINE6_DEVID_PODHD300
:
694 case LINE6_DEVID_PODHD400
:
698 case LINE6_DEVID_GUITARPORT
:
699 case LINE6_DEVID_PODSTUDIO_GX
:
700 case LINE6_DEVID_PODSTUDIO_UX1
:
701 case LINE6_DEVID_TONEPORT_GX
:
702 case LINE6_DEVID_TONEPORT_UX1
:
703 alternate
= 2; /* 1..4 seem to be ok */
706 case LINE6_DEVID_TONEPORT_UX2
:
707 case LINE6_DEVID_PODSTUDIO_UX2
:
708 switch (interface_number
) {
710 /* defaults to 44.1kHz, 16-bit */
714 /* don't know yet what this is ...
730 ret
= usb_set_interface(usbdev
, interface_number
, alternate
);
732 dev_err(&interface
->dev
, "set_interface failed\n");
736 /* initialize device data based on product id: */
738 case LINE6_DEVID_BASSPODXT
:
739 case LINE6_DEVID_BASSPODXTLIVE
:
740 case LINE6_DEVID_BASSPODXTPRO
:
741 case LINE6_DEVID_PODXT
:
742 case LINE6_DEVID_PODXTPRO
:
743 size
= sizeof(struct usb_line6_pod
);
748 case LINE6_DEVID_PODHD300
:
749 case LINE6_DEVID_PODHD400
:
750 size
= sizeof(struct usb_line6_podhd
);
755 case LINE6_DEVID_PODHD500
:
756 size
= sizeof(struct usb_line6_podhd
);
761 case LINE6_DEVID_POCKETPOD
:
762 size
= sizeof(struct usb_line6_pod
);
767 case LINE6_DEVID_PODX3
:
768 case LINE6_DEVID_PODX3LIVE
:
769 /* currently unused! */
770 size
= sizeof(struct usb_line6_pod
);
775 case LINE6_DEVID_PODSTUDIO_GX
:
776 case LINE6_DEVID_PODSTUDIO_UX1
:
777 case LINE6_DEVID_PODSTUDIO_UX2
:
778 case LINE6_DEVID_TONEPORT_GX
:
779 case LINE6_DEVID_TONEPORT_UX1
:
780 case LINE6_DEVID_TONEPORT_UX2
:
781 case LINE6_DEVID_GUITARPORT
:
782 size
= sizeof(struct usb_line6_toneport
);
783 /* these don't have a control channel */
786 case LINE6_DEVID_PODXTLIVE
:
787 switch (interface_number
) {
788 case PODXTLIVE_INTERFACE_POD
:
789 size
= sizeof(struct usb_line6_pod
);
794 case PODXTLIVE_INTERFACE_VARIAX
:
795 size
= sizeof(struct usb_line6_variax
);
806 case LINE6_DEVID_VARIAX
:
807 size
= sizeof(struct usb_line6_variax
);
819 dev_err(&interface
->dev
,
820 "driver bug: interface data size not set\n");
825 line6
= kzalloc(size
, GFP_KERNEL
);
831 /* store basic data: */
832 line6
->interface_number
= interface_number
;
833 line6
->properties
= properties
;
834 line6
->usbdev
= usbdev
;
835 line6
->ifcdev
= &interface
->dev
;
836 line6
->ep_control_read
= ep_read
;
837 line6
->ep_control_write
= ep_write
;
838 line6
->product
= product
;
840 /* get data from endpoint descriptor (see usb_maxpacket): */
842 struct usb_host_endpoint
*ep
;
844 usb_pipeendpoint(usb_rcvintpipe(usbdev
, ep_read
));
845 ep
= usbdev
->ep_in
[epnum
];
848 line6
->interval
= ep
->desc
.bInterval
;
849 line6
->max_packet_size
=
850 le16_to_cpu(ep
->desc
.wMaxPacketSize
);
852 line6
->interval
= LINE6_FALLBACK_INTERVAL
;
853 line6
->max_packet_size
= LINE6_FALLBACK_MAXPACKETSIZE
;
854 dev_err(line6
->ifcdev
,
855 "endpoint not available, using fallback values");
859 usb_set_intfdata(interface
, line6
);
861 if (properties
->capabilities
& LINE6_BIT_CONTROL
) {
862 /* initialize USB buffers: */
863 line6
->buffer_listen
=
864 kmalloc(LINE6_BUFSIZE_LISTEN
, GFP_KERNEL
);
865 if (line6
->buffer_listen
== NULL
) {
870 line6
->buffer_message
=
871 kmalloc(LINE6_MESSAGE_MAXLEN
, GFP_KERNEL
);
872 if (line6
->buffer_message
== NULL
) {
877 line6
->urb_listen
= usb_alloc_urb(0, GFP_KERNEL
);
879 if (line6
->urb_listen
== NULL
) {
880 dev_err(&interface
->dev
, "Out of memory\n");
881 line6_destruct(interface
);
886 ret
= line6_start_listen(line6
);
888 dev_err(&interface
->dev
, "%s: usb_submit_urb failed\n",
894 /* initialize device data based on product id: */
896 case LINE6_DEVID_BASSPODXT
:
897 case LINE6_DEVID_BASSPODXTLIVE
:
898 case LINE6_DEVID_BASSPODXTPRO
:
899 case LINE6_DEVID_POCKETPOD
:
900 case LINE6_DEVID_PODX3
:
901 case LINE6_DEVID_PODX3LIVE
:
902 case LINE6_DEVID_PODXT
:
903 case LINE6_DEVID_PODXTPRO
:
904 ret
= line6_pod_init(interface
, (struct usb_line6_pod
*)line6
);
907 case LINE6_DEVID_PODHD300
:
908 case LINE6_DEVID_PODHD400
:
909 case LINE6_DEVID_PODHD500
:
910 ret
= line6_podhd_init(interface
,
911 (struct usb_line6_podhd
*)line6
);
914 case LINE6_DEVID_PODXTLIVE
:
915 switch (interface_number
) {
916 case PODXTLIVE_INTERFACE_POD
:
918 line6_pod_init(interface
,
919 (struct usb_line6_pod
*)line6
);
922 case PODXTLIVE_INTERFACE_VARIAX
:
924 line6_variax_init(interface
,
925 (struct usb_line6_variax
*)line6
);
929 dev_err(&interface
->dev
,
930 "PODxt Live interface %d not supported\n",
937 case LINE6_DEVID_VARIAX
:
939 line6_variax_init(interface
,
940 (struct usb_line6_variax
*)line6
);
943 case LINE6_DEVID_PODSTUDIO_GX
:
944 case LINE6_DEVID_PODSTUDIO_UX1
:
945 case LINE6_DEVID_PODSTUDIO_UX2
:
946 case LINE6_DEVID_TONEPORT_GX
:
947 case LINE6_DEVID_TONEPORT_UX1
:
948 case LINE6_DEVID_TONEPORT_UX2
:
949 case LINE6_DEVID_GUITARPORT
:
951 line6_toneport_init(interface
,
952 (struct usb_line6_toneport
*)line6
);
963 ret
= sysfs_create_link(&interface
->dev
.kobj
, &usbdev
->dev
.kobj
,
968 /* creation of additional special files should go here */
970 dev_info(&interface
->dev
, "Line6 %s now attached\n",
971 line6
->properties
->name
);
974 case LINE6_DEVID_PODX3
:
975 case LINE6_DEVID_PODX3LIVE
:
976 dev_info(&interface
->dev
,
977 "NOTE: the Line6 %s is detected, but not yet supported\n",
978 line6
->properties
->name
);
981 /* increment reference counters: */
982 usb_get_intf(interface
);
988 line6_destruct(interface
);
994 Line6 device disconnected.
996 static void line6_disconnect(struct usb_interface
*interface
)
998 struct usb_line6
*line6
;
999 struct usb_device
*usbdev
;
1000 int interface_number
;
1002 if (interface
== NULL
)
1004 usbdev
= interface_to_usbdev(interface
);
1008 /* removal of additional special files should go here */
1010 sysfs_remove_link(&interface
->dev
.kobj
, "usb_device");
1012 interface_number
= interface
->cur_altsetting
->desc
.bInterfaceNumber
;
1013 line6
= usb_get_intfdata(interface
);
1015 if (line6
!= NULL
) {
1016 if (line6
->urb_listen
!= NULL
)
1017 line6_stop_listen(line6
);
1019 if (usbdev
!= line6
->usbdev
)
1020 dev_err(line6
->ifcdev
,
1021 "driver bug: inconsistent usb device\n");
1023 switch (le16_to_cpu(line6
->usbdev
->descriptor
.idProduct
)) {
1024 case LINE6_DEVID_BASSPODXT
:
1025 case LINE6_DEVID_BASSPODXTLIVE
:
1026 case LINE6_DEVID_BASSPODXTPRO
:
1027 case LINE6_DEVID_POCKETPOD
:
1028 case LINE6_DEVID_PODX3
:
1029 case LINE6_DEVID_PODX3LIVE
:
1030 case LINE6_DEVID_PODXT
:
1031 case LINE6_DEVID_PODXTPRO
:
1032 line6_pod_disconnect(interface
);
1035 case LINE6_DEVID_PODHD300
:
1036 case LINE6_DEVID_PODHD400
:
1037 case LINE6_DEVID_PODHD500
:
1038 line6_podhd_disconnect(interface
);
1041 case LINE6_DEVID_PODXTLIVE
:
1042 switch (interface_number
) {
1043 case PODXTLIVE_INTERFACE_POD
:
1044 line6_pod_disconnect(interface
);
1047 case PODXTLIVE_INTERFACE_VARIAX
:
1048 line6_variax_disconnect(interface
);
1054 case LINE6_DEVID_VARIAX
:
1055 line6_variax_disconnect(interface
);
1058 case LINE6_DEVID_PODSTUDIO_GX
:
1059 case LINE6_DEVID_PODSTUDIO_UX1
:
1060 case LINE6_DEVID_PODSTUDIO_UX2
:
1061 case LINE6_DEVID_TONEPORT_GX
:
1062 case LINE6_DEVID_TONEPORT_UX1
:
1063 case LINE6_DEVID_TONEPORT_UX2
:
1064 case LINE6_DEVID_GUITARPORT
:
1065 line6_toneport_disconnect(interface
);
1072 dev_info(&interface
->dev
, "Line6 %s now disconnected\n",
1073 line6
->properties
->name
);
1076 line6_destruct(interface
);
1078 /* decrement reference counters: */
1079 usb_put_intf(interface
);
1080 usb_put_dev(usbdev
);
1086 Suspend Line6 device.
1088 static int line6_suspend(struct usb_interface
*interface
, pm_message_t message
)
1090 struct usb_line6
*line6
= usb_get_intfdata(interface
);
1091 struct snd_line6_pcm
*line6pcm
= line6
->line6pcm
;
1093 snd_power_change_state(line6
->card
, SNDRV_CTL_POWER_D3hot
);
1095 if (line6
->properties
->capabilities
& LINE6_BIT_CONTROL
)
1096 line6_stop_listen(line6
);
1098 if (line6pcm
!= NULL
) {
1099 snd_pcm_suspend_all(line6pcm
->pcm
);
1100 line6_pcm_disconnect(line6pcm
);
1101 line6pcm
->flags
= 0;
1108 Resume Line6 device.
1110 static int line6_resume(struct usb_interface
*interface
)
1112 struct usb_line6
*line6
= usb_get_intfdata(interface
);
1114 if (line6
->properties
->capabilities
& LINE6_BIT_CONTROL
)
1115 line6_start_listen(line6
);
1117 snd_power_change_state(line6
->card
, SNDRV_CTL_POWER_D0
);
1122 Resume Line6 device after reset.
1124 static int line6_reset_resume(struct usb_interface
*interface
)
1126 struct usb_line6
*line6
= usb_get_intfdata(interface
);
1128 switch (le16_to_cpu(line6
->usbdev
->descriptor
.idProduct
)) {
1129 case LINE6_DEVID_PODSTUDIO_GX
:
1130 case LINE6_DEVID_PODSTUDIO_UX1
:
1131 case LINE6_DEVID_PODSTUDIO_UX2
:
1132 case LINE6_DEVID_TONEPORT_GX
:
1133 case LINE6_DEVID_TONEPORT_UX1
:
1134 case LINE6_DEVID_TONEPORT_UX2
:
1135 case LINE6_DEVID_GUITARPORT
:
1136 line6_toneport_reset_resume((struct usb_line6_toneport
*)line6
);
1139 return line6_resume(interface
);
1142 #endif /* CONFIG_PM */
1144 static struct usb_driver line6_driver
= {
1145 .name
= DRIVER_NAME
,
1146 .probe
= line6_probe
,
1147 .disconnect
= line6_disconnect
,
1149 .suspend
= line6_suspend
,
1150 .resume
= line6_resume
,
1151 .reset_resume
= line6_reset_resume
,
1153 .id_table
= line6_id_table
,
1156 module_usb_driver(line6_driver
);
1158 MODULE_AUTHOR(DRIVER_AUTHOR
);
1159 MODULE_DESCRIPTION(DRIVER_DESC
);
1160 MODULE_LICENSE("GPL");
1161 MODULE_VERSION(DRIVER_VERSION
);