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
);
61 static struct line6_properties line6_properties_table
[] = {
62 { LINE6_BIT_BASSPODXT
, "BassPODxt", "BassPODxt", LINE6_BIT_CONTROL_PCM_HWMON
},
63 { LINE6_BIT_BASSPODXTLIVE
, "BassPODxtLive", "BassPODxt Live", LINE6_BIT_CONTROL_PCM_HWMON
},
64 { LINE6_BIT_BASSPODXTPRO
, "BassPODxtPro", "BassPODxt Pro", LINE6_BIT_CONTROL_PCM_HWMON
},
65 { LINE6_BIT_GUITARPORT
, "GuitarPort", "GuitarPort", LINE6_BIT_PCM
},
66 { LINE6_BIT_POCKETPOD
, "PocketPOD", "Pocket POD", LINE6_BIT_CONTROL
},
67 { LINE6_BIT_PODHD300
, "PODHD300", "POD HD300", LINE6_BIT_CONTROL_PCM_HWMON
},
68 { LINE6_BIT_PODHD400
, "PODHD400", "POD HD400", LINE6_BIT_CONTROL_PCM_HWMON
},
69 { LINE6_BIT_PODHD500
, "PODHD500", "POD HD500", LINE6_BIT_CONTROL_PCM_HWMON
},
70 { LINE6_BIT_PODSTUDIO_GX
, "PODStudioGX", "POD Studio GX", LINE6_BIT_PCM
},
71 { LINE6_BIT_PODSTUDIO_UX1
, "PODStudioUX1", "POD Studio UX1", LINE6_BIT_PCM
},
72 { LINE6_BIT_PODSTUDIO_UX2
, "PODStudioUX2", "POD Studio UX2", LINE6_BIT_PCM
},
73 { LINE6_BIT_PODX3
, "PODX3", "POD X3", LINE6_BIT_PCM
},
74 { LINE6_BIT_PODX3LIVE
, "PODX3Live", "POD X3 Live", LINE6_BIT_PCM
},
75 { LINE6_BIT_PODXT
, "PODxt", "PODxt", LINE6_BIT_CONTROL_PCM_HWMON
},
76 { LINE6_BIT_PODXTLIVE
, "PODxtLive", "PODxt Live", LINE6_BIT_CONTROL_PCM_HWMON
},
77 { LINE6_BIT_PODXTPRO
, "PODxtPro", "PODxt Pro", LINE6_BIT_CONTROL_PCM_HWMON
},
78 { LINE6_BIT_TONEPORT_GX
, "TonePortGX", "TonePort GX", LINE6_BIT_PCM
},
79 { LINE6_BIT_TONEPORT_UX1
, "TonePortUX1", "TonePort UX1", LINE6_BIT_PCM
},
80 { LINE6_BIT_TONEPORT_UX2
, "TonePortUX2", "TonePort UX2", LINE6_BIT_PCM
},
81 { LINE6_BIT_VARIAX
, "Variax", "Variax Workbench", LINE6_BIT_CONTROL
},
86 This is Line6's MIDI manufacturer ID.
88 const unsigned char line6_midi_id
[] = {
93 Code to request version of POD, Variax interface
94 (and maybe other devices).
96 static const char line6_request_version
[] = {
97 0xf0, 0x7e, 0x7f, 0x06, 0x01, 0xf7
101 Class for asynchronous messages.
104 struct usb_line6
*line6
;
111 Forward declarations.
113 static void line6_data_received(struct urb
*urb
);
114 static int line6_send_raw_message_async_part(struct message
*msg
,
118 Start to listen on endpoint.
120 static int line6_start_listen(struct usb_line6
*line6
)
123 usb_fill_int_urb(line6
->urb_listen
, line6
->usbdev
,
124 usb_rcvintpipe(line6
->usbdev
, line6
->ep_control_read
),
125 line6
->buffer_listen
, LINE6_BUFSIZE_LISTEN
,
126 line6_data_received
, line6
, line6
->interval
);
127 line6
->urb_listen
->actual_length
= 0;
128 err
= usb_submit_urb(line6
->urb_listen
, GFP_ATOMIC
);
133 Stop listening on endpoint.
135 static void line6_stop_listen(struct usb_line6
*line6
)
137 usb_kill_urb(line6
->urb_listen
);
141 Send raw message in pieces of wMaxPacketSize bytes.
143 int line6_send_raw_message(struct usb_line6
*line6
, const char *buffer
,
148 for (i
= 0; i
< size
; i
+= line6
->max_packet_size
) {
150 const char *frag_buf
= buffer
+ i
;
151 int frag_size
= min(line6
->max_packet_size
, size
- i
);
154 retval
= usb_interrupt_msg(line6
->usbdev
,
155 usb_sndintpipe(line6
->usbdev
,
156 line6
->ep_control_write
),
157 (char *)frag_buf
, frag_size
,
158 &partial
, LINE6_TIMEOUT
* HZ
);
161 dev_err(line6
->ifcdev
,
162 "usb_interrupt_msg failed (%d)\n", retval
);
173 Notification of completion of asynchronous request transmission.
175 static void line6_async_request_sent(struct urb
*urb
)
177 struct message
*msg
= (struct message
*)urb
->context
;
179 if (msg
->done
>= msg
->size
) {
183 line6_send_raw_message_async_part(msg
, urb
);
187 Asynchronously send part of a raw message.
189 static int line6_send_raw_message_async_part(struct message
*msg
,
193 struct usb_line6
*line6
= msg
->line6
;
194 int done
= msg
->done
;
195 int bytes
= min(msg
->size
- done
, line6
->max_packet_size
);
197 usb_fill_int_urb(urb
, line6
->usbdev
,
198 usb_sndintpipe(line6
->usbdev
, line6
->ep_control_write
),
199 (char *)msg
->buffer
+ done
, bytes
,
200 line6_async_request_sent
, msg
, line6
->interval
);
203 retval
= usb_submit_urb(urb
, GFP_ATOMIC
);
206 dev_err(line6
->ifcdev
, "%s: usb_submit_urb failed (%d)\n",
217 Setup and start timer.
219 void line6_start_timer(struct timer_list
*timer
, unsigned int msecs
,
220 void (*function
) (unsigned long), unsigned long data
)
222 setup_timer(timer
, function
, data
);
223 timer
->expires
= jiffies
+ msecs
* HZ
/ 1000;
228 Asynchronously send raw message.
230 int line6_send_raw_message_async(struct usb_line6
*line6
, const char *buffer
,
236 /* create message: */
237 msg
= kmalloc(sizeof(struct message
), GFP_ATOMIC
);
242 urb
= usb_alloc_urb(0, GFP_ATOMIC
);
246 dev_err(line6
->ifcdev
, "Out of memory\n");
250 /* set message data: */
252 msg
->buffer
= buffer
;
257 return line6_send_raw_message_async_part(msg
, urb
);
261 Send asynchronous device version request.
263 int line6_version_request_async(struct usb_line6
*line6
)
268 buffer
= kmemdup(line6_request_version
,
269 sizeof(line6_request_version
), GFP_ATOMIC
);
270 if (buffer
== NULL
) {
271 dev_err(line6
->ifcdev
, "Out of memory");
275 retval
= line6_send_raw_message_async(line6
, buffer
,
276 sizeof(line6_request_version
));
282 Send sysex message in pieces of wMaxPacketSize bytes.
284 int line6_send_sysex_message(struct usb_line6
*line6
, const char *buffer
,
287 return line6_send_raw_message(line6
, buffer
,
288 size
+ SYSEX_EXTRA_SIZE
) -
293 Allocate buffer for sysex message and prepare header.
294 @param code sysex message code
295 @param size number of bytes between code and sysex end
297 char *line6_alloc_sysex_buffer(struct usb_line6
*line6
, int code1
, int code2
,
300 char *buffer
= kmalloc(size
+ SYSEX_EXTRA_SIZE
, GFP_ATOMIC
);
305 buffer
[0] = LINE6_SYSEX_BEGIN
;
306 memcpy(buffer
+ 1, line6_midi_id
, sizeof(line6_midi_id
));
307 buffer
[sizeof(line6_midi_id
) + 1] = code1
;
308 buffer
[sizeof(line6_midi_id
) + 2] = code2
;
309 buffer
[sizeof(line6_midi_id
) + 3 + size
] = LINE6_SYSEX_END
;
314 Notification of data received from the Line6 device.
316 static void line6_data_received(struct urb
*urb
)
318 struct usb_line6
*line6
= (struct usb_line6
*)urb
->context
;
319 struct midi_buffer
*mb
= &line6
->line6midi
->midibuf_in
;
322 if (urb
->status
== -ESHUTDOWN
)
326 line6_midibuf_write(mb
, urb
->transfer_buffer
, urb
->actual_length
);
328 if (done
< urb
->actual_length
) {
329 line6_midibuf_ignore(mb
, done
);
330 dev_dbg(line6
->ifcdev
, "%d %d buffer overflow - message skipped\n",
331 done
, urb
->actual_length
);
336 line6_midibuf_read(mb
, line6
->buffer_message
,
337 LINE6_MESSAGE_MAXLEN
);
342 line6
->message_length
= done
;
343 line6_midi_receive(line6
, line6
->buffer_message
, done
);
345 switch (le16_to_cpu(line6
->usbdev
->descriptor
.idProduct
)) {
346 case LINE6_DEVID_BASSPODXT
:
347 case LINE6_DEVID_BASSPODXTLIVE
:
348 case LINE6_DEVID_BASSPODXTPRO
:
349 case LINE6_DEVID_PODXT
:
350 case LINE6_DEVID_PODXTPRO
:
351 case LINE6_DEVID_POCKETPOD
:
352 line6_pod_process_message((struct usb_line6_pod
*)
356 case LINE6_DEVID_PODHD300
:
357 case LINE6_DEVID_PODHD400
:
358 case LINE6_DEVID_PODHD500
:
359 break; /* let userspace handle MIDI */
361 case LINE6_DEVID_PODXTLIVE
:
362 switch (line6
->interface_number
) {
363 case PODXTLIVE_INTERFACE_POD
:
364 line6_pod_process_message((struct usb_line6_pod
368 case PODXTLIVE_INTERFACE_VARIAX
:
369 line6_variax_process_message((struct
375 dev_err(line6
->ifcdev
,
376 "PODxt Live interface %d not supported\n",
377 line6
->interface_number
);
381 case LINE6_DEVID_VARIAX
:
382 line6_variax_process_message((struct usb_line6_variax
*)
391 line6_start_listen(line6
);
395 Send channel number (i.e., switch to a different sound).
397 int line6_send_program(struct usb_line6
*line6
, u8 value
)
400 unsigned char *buffer
;
403 buffer
= kmalloc(2, GFP_KERNEL
);
407 buffer
[0] = LINE6_PROGRAM_CHANGE
| LINE6_CHANNEL_HOST
;
410 retval
= usb_interrupt_msg(line6
->usbdev
,
411 usb_sndintpipe(line6
->usbdev
,
412 line6
->ep_control_write
),
413 buffer
, 2, &partial
, LINE6_TIMEOUT
* HZ
);
416 dev_err(line6
->ifcdev
, "usb_interrupt_msg failed (%d)\n",
424 Transmit Line6 control parameter.
426 int line6_transmit_parameter(struct usb_line6
*line6
, int param
, u8 value
)
429 unsigned char *buffer
;
432 buffer
= kmalloc(3, GFP_KERNEL
);
436 buffer
[0] = LINE6_PARAM_CHANGE
| LINE6_CHANNEL_HOST
;
440 retval
= usb_interrupt_msg(line6
->usbdev
,
441 usb_sndintpipe(line6
->usbdev
,
442 line6
->ep_control_write
),
443 buffer
, 3, &partial
, LINE6_TIMEOUT
* HZ
);
446 dev_err(line6
->ifcdev
, "usb_interrupt_msg failed (%d)\n",
454 Read data from device.
456 int line6_read_data(struct usb_line6
*line6
, int address
, void *data
,
459 struct usb_device
*usbdev
= line6
->usbdev
;
463 /* query the serial number: */
464 ret
= usb_control_msg(usbdev
, usb_sndctrlpipe(usbdev
, 0), 0x67,
465 USB_TYPE_VENDOR
| USB_RECIP_DEVICE
| USB_DIR_OUT
,
466 (datalen
<< 8) | 0x21, address
,
467 NULL
, 0, LINE6_TIMEOUT
* HZ
);
470 dev_err(line6
->ifcdev
, "read request failed (error %d)\n", ret
);
474 /* Wait for data length. We'll get 0xff until length arrives. */
476 ret
= usb_control_msg(usbdev
, usb_rcvctrlpipe(usbdev
, 0), 0x67,
477 USB_TYPE_VENDOR
| USB_RECIP_DEVICE
|
479 0x0012, 0x0000, &len
, 1,
482 dev_err(line6
->ifcdev
,
483 "receive length failed (error %d)\n", ret
);
486 } while (len
== 0xff);
488 if (len
!= datalen
) {
489 /* should be equal or something went wrong */
490 dev_err(line6
->ifcdev
,
491 "length mismatch (expected %d, got %d)\n",
492 (int)datalen
, (int)len
);
496 /* receive the result: */
497 ret
= usb_control_msg(usbdev
, usb_rcvctrlpipe(usbdev
, 0), 0x67,
498 USB_TYPE_VENDOR
| USB_RECIP_DEVICE
| USB_DIR_IN
,
499 0x0013, 0x0000, data
, datalen
,
503 dev_err(line6
->ifcdev
, "read failed (error %d)\n", ret
);
511 Write data to device.
513 int line6_write_data(struct usb_line6
*line6
, int address
, void *data
,
516 struct usb_device
*usbdev
= line6
->usbdev
;
518 unsigned char status
;
520 ret
= usb_control_msg(usbdev
, usb_sndctrlpipe(usbdev
, 0), 0x67,
521 USB_TYPE_VENDOR
| USB_RECIP_DEVICE
| USB_DIR_OUT
,
522 0x0022, address
, data
, datalen
,
526 dev_err(line6
->ifcdev
,
527 "write request failed (error %d)\n", ret
);
532 ret
= usb_control_msg(usbdev
, usb_rcvctrlpipe(usbdev
, 0),
534 USB_TYPE_VENDOR
| USB_RECIP_DEVICE
|
537 &status
, 1, LINE6_TIMEOUT
* HZ
);
540 dev_err(line6
->ifcdev
,
541 "receiving status failed (error %d)\n", ret
);
544 } while (status
== 0xff);
547 dev_err(line6
->ifcdev
, "write failed (error %d)\n", ret
);
555 Read Line6 device serial number.
556 (POD, TonePort, GuitarPort)
558 int line6_read_serial_number(struct usb_line6
*line6
, int *serial_number
)
560 return line6_read_data(line6
, 0x80d0, serial_number
,
561 sizeof(*serial_number
));
565 No operation (i.e., unsupported).
567 ssize_t
line6_nop_read(struct device
*dev
, struct device_attribute
*attr
,
576 static void line6_destruct(struct usb_interface
*interface
)
578 struct usb_line6
*line6
;
580 if (interface
== NULL
)
582 line6
= usb_get_intfdata(interface
);
586 /* free buffer memory first: */
587 kfree(line6
->buffer_message
);
588 kfree(line6
->buffer_listen
);
590 /* then free URBs: */
591 usb_free_urb(line6
->urb_listen
);
593 /* make sure the device isn't destructed twice: */
594 usb_set_intfdata(interface
, NULL
);
596 /* free interface data: */
603 static int line6_probe(struct usb_interface
*interface
,
604 const struct usb_device_id
*id
)
607 struct usb_device
*usbdev
;
608 struct usb_line6
*line6
;
609 const struct line6_properties
*properties
;
610 int interface_number
, alternate
= 0;
613 int ep_read
= 0, ep_write
= 0;
616 if (interface
== NULL
)
618 usbdev
= interface_to_usbdev(interface
);
622 /* we don't handle multiple configurations */
623 if (usbdev
->descriptor
.bNumConfigurations
!= 1) {
628 /* check vendor and product id */
629 for (devtype
= ARRAY_SIZE(line6_id_table
) - 1; devtype
--;) {
630 u16 idVendor
= le16_to_cpu(usbdev
->descriptor
.idVendor
);
631 u16 idProduct
= le16_to_cpu(usbdev
->descriptor
.idProduct
);
633 if (idVendor
== line6_id_table
[devtype
].idVendor
&&
634 idProduct
== line6_id_table
[devtype
].idProduct
)
643 /* initialize device info: */
644 properties
= &line6_properties_table
[devtype
];
645 dev_info(&interface
->dev
, "Line6 %s found\n", properties
->name
);
646 product
= le16_to_cpu(usbdev
->descriptor
.idProduct
);
648 /* query interface number */
649 interface_number
= interface
->cur_altsetting
->desc
.bInterfaceNumber
;
652 case LINE6_DEVID_BASSPODXTLIVE
:
653 case LINE6_DEVID_PODXTLIVE
:
654 case LINE6_DEVID_VARIAX
:
658 case LINE6_DEVID_POCKETPOD
:
659 switch (interface_number
) {
661 return 0; /* this interface has no endpoints */
670 case LINE6_DEVID_PODHD500
:
671 case LINE6_DEVID_PODX3
:
672 case LINE6_DEVID_PODX3LIVE
:
673 switch (interface_number
) {
685 case LINE6_DEVID_BASSPODXT
:
686 case LINE6_DEVID_BASSPODXTPRO
:
687 case LINE6_DEVID_PODXT
:
688 case LINE6_DEVID_PODXTPRO
:
689 case LINE6_DEVID_PODHD300
:
690 case LINE6_DEVID_PODHD400
:
694 case LINE6_DEVID_GUITARPORT
:
695 case LINE6_DEVID_PODSTUDIO_GX
:
696 case LINE6_DEVID_PODSTUDIO_UX1
:
697 case LINE6_DEVID_TONEPORT_GX
:
698 case LINE6_DEVID_TONEPORT_UX1
:
699 alternate
= 2; /* 1..4 seem to be ok */
702 case LINE6_DEVID_TONEPORT_UX2
:
703 case LINE6_DEVID_PODSTUDIO_UX2
:
704 switch (interface_number
) {
706 /* defaults to 44.1kHz, 16-bit */
710 /* don't know yet what this is ...
726 ret
= usb_set_interface(usbdev
, interface_number
, alternate
);
728 dev_err(&interface
->dev
, "set_interface failed\n");
732 /* initialize device data based on product id: */
734 case LINE6_DEVID_BASSPODXT
:
735 case LINE6_DEVID_BASSPODXTLIVE
:
736 case LINE6_DEVID_BASSPODXTPRO
:
737 case LINE6_DEVID_PODXT
:
738 case LINE6_DEVID_PODXTPRO
:
739 size
= sizeof(struct usb_line6_pod
);
744 case LINE6_DEVID_PODHD300
:
745 case LINE6_DEVID_PODHD400
:
746 size
= sizeof(struct usb_line6_podhd
);
751 case LINE6_DEVID_PODHD500
:
752 size
= sizeof(struct usb_line6_podhd
);
757 case LINE6_DEVID_POCKETPOD
:
758 size
= sizeof(struct usb_line6_pod
);
763 case LINE6_DEVID_PODX3
:
764 case LINE6_DEVID_PODX3LIVE
:
765 /* currently unused! */
766 size
= sizeof(struct usb_line6_pod
);
771 case LINE6_DEVID_PODSTUDIO_GX
:
772 case LINE6_DEVID_PODSTUDIO_UX1
:
773 case LINE6_DEVID_PODSTUDIO_UX2
:
774 case LINE6_DEVID_TONEPORT_GX
:
775 case LINE6_DEVID_TONEPORT_UX1
:
776 case LINE6_DEVID_TONEPORT_UX2
:
777 case LINE6_DEVID_GUITARPORT
:
778 size
= sizeof(struct usb_line6_toneport
);
779 /* these don't have a control channel */
782 case LINE6_DEVID_PODXTLIVE
:
783 switch (interface_number
) {
784 case PODXTLIVE_INTERFACE_POD
:
785 size
= sizeof(struct usb_line6_pod
);
790 case PODXTLIVE_INTERFACE_VARIAX
:
791 size
= sizeof(struct usb_line6_variax
);
802 case LINE6_DEVID_VARIAX
:
803 size
= sizeof(struct usb_line6_variax
);
815 dev_err(&interface
->dev
,
816 "driver bug: interface data size not set\n");
821 line6
= kzalloc(size
, GFP_KERNEL
);
827 /* store basic data: */
828 line6
->interface_number
= interface_number
;
829 line6
->properties
= properties
;
830 line6
->usbdev
= usbdev
;
831 line6
->ifcdev
= &interface
->dev
;
832 line6
->ep_control_read
= ep_read
;
833 line6
->ep_control_write
= ep_write
;
834 line6
->product
= product
;
836 /* get data from endpoint descriptor (see usb_maxpacket): */
838 struct usb_host_endpoint
*ep
;
840 usb_pipeendpoint(usb_rcvintpipe(usbdev
, ep_read
));
841 ep
= usbdev
->ep_in
[epnum
];
844 line6
->interval
= ep
->desc
.bInterval
;
845 line6
->max_packet_size
=
846 le16_to_cpu(ep
->desc
.wMaxPacketSize
);
848 line6
->interval
= LINE6_FALLBACK_INTERVAL
;
849 line6
->max_packet_size
= LINE6_FALLBACK_MAXPACKETSIZE
;
850 dev_err(line6
->ifcdev
,
851 "endpoint not available, using fallback values");
855 usb_set_intfdata(interface
, line6
);
857 if (properties
->capabilities
& LINE6_BIT_CONTROL
) {
858 /* initialize USB buffers: */
859 line6
->buffer_listen
=
860 kmalloc(LINE6_BUFSIZE_LISTEN
, GFP_KERNEL
);
861 if (line6
->buffer_listen
== NULL
) {
866 line6
->buffer_message
=
867 kmalloc(LINE6_MESSAGE_MAXLEN
, GFP_KERNEL
);
868 if (line6
->buffer_message
== NULL
) {
873 line6
->urb_listen
= usb_alloc_urb(0, GFP_KERNEL
);
875 if (line6
->urb_listen
== NULL
) {
876 dev_err(&interface
->dev
, "Out of memory\n");
877 line6_destruct(interface
);
882 ret
= line6_start_listen(line6
);
884 dev_err(&interface
->dev
, "%s: usb_submit_urb failed\n",
890 /* initialize device data based on product id: */
892 case LINE6_DEVID_BASSPODXT
:
893 case LINE6_DEVID_BASSPODXTLIVE
:
894 case LINE6_DEVID_BASSPODXTPRO
:
895 case LINE6_DEVID_POCKETPOD
:
896 case LINE6_DEVID_PODX3
:
897 case LINE6_DEVID_PODX3LIVE
:
898 case LINE6_DEVID_PODXT
:
899 case LINE6_DEVID_PODXTPRO
:
900 ret
= line6_pod_init(interface
, (struct usb_line6_pod
*)line6
);
903 case LINE6_DEVID_PODHD300
:
904 case LINE6_DEVID_PODHD400
:
905 case LINE6_DEVID_PODHD500
:
906 ret
= line6_podhd_init(interface
,
907 (struct usb_line6_podhd
*)line6
);
910 case LINE6_DEVID_PODXTLIVE
:
911 switch (interface_number
) {
912 case PODXTLIVE_INTERFACE_POD
:
914 line6_pod_init(interface
,
915 (struct usb_line6_pod
*)line6
);
918 case PODXTLIVE_INTERFACE_VARIAX
:
920 line6_variax_init(interface
,
921 (struct usb_line6_variax
*)line6
);
925 dev_err(&interface
->dev
,
926 "PODxt Live interface %d not supported\n",
933 case LINE6_DEVID_VARIAX
:
935 line6_variax_init(interface
,
936 (struct usb_line6_variax
*)line6
);
939 case LINE6_DEVID_PODSTUDIO_GX
:
940 case LINE6_DEVID_PODSTUDIO_UX1
:
941 case LINE6_DEVID_PODSTUDIO_UX2
:
942 case LINE6_DEVID_TONEPORT_GX
:
943 case LINE6_DEVID_TONEPORT_UX1
:
944 case LINE6_DEVID_TONEPORT_UX2
:
945 case LINE6_DEVID_GUITARPORT
:
947 line6_toneport_init(interface
,
948 (struct usb_line6_toneport
*)line6
);
959 ret
= sysfs_create_link(&interface
->dev
.kobj
, &usbdev
->dev
.kobj
,
964 /* creation of additional special files should go here */
966 dev_info(&interface
->dev
, "Line6 %s now attached\n",
967 line6
->properties
->name
);
970 case LINE6_DEVID_PODX3
:
971 case LINE6_DEVID_PODX3LIVE
:
972 dev_info(&interface
->dev
,
973 "NOTE: the Line6 %s is detected, but not yet supported\n",
974 line6
->properties
->name
);
977 /* increment reference counters: */
978 usb_get_intf(interface
);
984 line6_destruct(interface
);
990 Line6 device disconnected.
992 static void line6_disconnect(struct usb_interface
*interface
)
994 struct usb_line6
*line6
;
995 struct usb_device
*usbdev
;
996 int interface_number
;
998 if (interface
== NULL
)
1000 usbdev
= interface_to_usbdev(interface
);
1004 /* removal of additional special files should go here */
1006 sysfs_remove_link(&interface
->dev
.kobj
, "usb_device");
1008 interface_number
= interface
->cur_altsetting
->desc
.bInterfaceNumber
;
1009 line6
= usb_get_intfdata(interface
);
1011 if (line6
!= NULL
) {
1012 if (line6
->urb_listen
!= NULL
)
1013 line6_stop_listen(line6
);
1015 if (usbdev
!= line6
->usbdev
)
1016 dev_err(line6
->ifcdev
,
1017 "driver bug: inconsistent usb device\n");
1019 switch (le16_to_cpu(line6
->usbdev
->descriptor
.idProduct
)) {
1020 case LINE6_DEVID_BASSPODXT
:
1021 case LINE6_DEVID_BASSPODXTLIVE
:
1022 case LINE6_DEVID_BASSPODXTPRO
:
1023 case LINE6_DEVID_POCKETPOD
:
1024 case LINE6_DEVID_PODX3
:
1025 case LINE6_DEVID_PODX3LIVE
:
1026 case LINE6_DEVID_PODXT
:
1027 case LINE6_DEVID_PODXTPRO
:
1028 line6_pod_disconnect(interface
);
1031 case LINE6_DEVID_PODHD300
:
1032 case LINE6_DEVID_PODHD400
:
1033 case LINE6_DEVID_PODHD500
:
1034 line6_podhd_disconnect(interface
);
1037 case LINE6_DEVID_PODXTLIVE
:
1038 switch (interface_number
) {
1039 case PODXTLIVE_INTERFACE_POD
:
1040 line6_pod_disconnect(interface
);
1043 case PODXTLIVE_INTERFACE_VARIAX
:
1044 line6_variax_disconnect(interface
);
1050 case LINE6_DEVID_VARIAX
:
1051 line6_variax_disconnect(interface
);
1054 case LINE6_DEVID_PODSTUDIO_GX
:
1055 case LINE6_DEVID_PODSTUDIO_UX1
:
1056 case LINE6_DEVID_PODSTUDIO_UX2
:
1057 case LINE6_DEVID_TONEPORT_GX
:
1058 case LINE6_DEVID_TONEPORT_UX1
:
1059 case LINE6_DEVID_TONEPORT_UX2
:
1060 case LINE6_DEVID_GUITARPORT
:
1061 line6_toneport_disconnect(interface
);
1068 dev_info(&interface
->dev
, "Line6 %s now disconnected\n",
1069 line6
->properties
->name
);
1072 line6_destruct(interface
);
1074 /* decrement reference counters: */
1075 usb_put_intf(interface
);
1076 usb_put_dev(usbdev
);
1082 Suspend Line6 device.
1084 static int line6_suspend(struct usb_interface
*interface
, pm_message_t message
)
1086 struct usb_line6
*line6
= usb_get_intfdata(interface
);
1087 struct snd_line6_pcm
*line6pcm
= line6
->line6pcm
;
1089 snd_power_change_state(line6
->card
, SNDRV_CTL_POWER_D3hot
);
1091 if (line6
->properties
->capabilities
& LINE6_BIT_CONTROL
)
1092 line6_stop_listen(line6
);
1094 if (line6pcm
!= NULL
) {
1095 snd_pcm_suspend_all(line6pcm
->pcm
);
1096 line6_pcm_disconnect(line6pcm
);
1097 line6pcm
->flags
= 0;
1104 Resume Line6 device.
1106 static int line6_resume(struct usb_interface
*interface
)
1108 struct usb_line6
*line6
= usb_get_intfdata(interface
);
1110 if (line6
->properties
->capabilities
& LINE6_BIT_CONTROL
)
1111 line6_start_listen(line6
);
1113 snd_power_change_state(line6
->card
, SNDRV_CTL_POWER_D0
);
1118 Resume Line6 device after reset.
1120 static int line6_reset_resume(struct usb_interface
*interface
)
1122 struct usb_line6
*line6
= usb_get_intfdata(interface
);
1124 switch (le16_to_cpu(line6
->usbdev
->descriptor
.idProduct
)) {
1125 case LINE6_DEVID_PODSTUDIO_GX
:
1126 case LINE6_DEVID_PODSTUDIO_UX1
:
1127 case LINE6_DEVID_PODSTUDIO_UX2
:
1128 case LINE6_DEVID_TONEPORT_GX
:
1129 case LINE6_DEVID_TONEPORT_UX1
:
1130 case LINE6_DEVID_TONEPORT_UX2
:
1131 case LINE6_DEVID_GUITARPORT
:
1132 line6_toneport_reset_resume((struct usb_line6_toneport
*)line6
);
1135 return line6_resume(interface
);
1138 #endif /* CONFIG_PM */
1140 static struct usb_driver line6_driver
= {
1141 .name
= DRIVER_NAME
,
1142 .probe
= line6_probe
,
1143 .disconnect
= line6_disconnect
,
1145 .suspend
= line6_suspend
,
1146 .resume
= line6_resume
,
1147 .reset_resume
= line6_reset_resume
,
1149 .id_table
= line6_id_table
,
1152 module_usb_driver(line6_driver
);
1154 MODULE_AUTHOR(DRIVER_AUTHOR
);
1155 MODULE_DESCRIPTION(DRIVER_DESC
);
1156 MODULE_LICENSE("GPL");
1157 MODULE_VERSION(DRIVER_VERSION
);