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,
571 No operation (i.e., unsupported).
573 ssize_t line6_nop_write(struct device *dev, struct device_attribute *attr,
574 const char *buf, size_t count)
582 static void line6_destruct(struct usb_interface *interface)
584 struct usb_line6 *line6;
586 if (interface == NULL)
588 line6 = usb_get_intfdata(interface);
592 /* free buffer memory first: */
593 kfree(line6->buffer_message);
594 kfree(line6->buffer_listen);
596 /* then free URBs: */
597 usb_free_urb(line6->urb_listen);
599 /* make sure the device isn't destructed twice: */
600 usb_set_intfdata(interface, NULL);
602 /* free interface data: */
609 static int line6_probe(struct usb_interface *interface,
610 const struct usb_device_id *id)
613 struct usb_device *usbdev;
614 struct usb_line6 *line6;
615 const struct line6_properties *properties;
616 int interface_number, alternate = 0;
619 int ep_read = 0, ep_write = 0;
622 if (interface == NULL)
624 usbdev = interface_to_usbdev(interface);
628 /* we don't handle multiple configurations */
629 if (usbdev->descriptor.bNumConfigurations != 1) {
634 /* check vendor and product id */
635 for (devtype = ARRAY_SIZE(line6_id_table) - 1; devtype--;) {
636 u16 idVendor = le16_to_cpu(usbdev->descriptor.idVendor);
637 u16 idProduct = le16_to_cpu(usbdev->descriptor.idProduct);
639 if (idVendor == line6_id_table[devtype].idVendor &&
640 idProduct == line6_id_table[devtype].idProduct)
649 /* initialize device info: */
650 properties = &line6_properties_table[devtype];
651 dev_info(&interface->dev, "Line6 %s found\n", properties->name);
652 product = le16_to_cpu(usbdev->descriptor.idProduct);
654 /* query interface number */
655 interface_number = interface->cur_altsetting->desc.bInterfaceNumber;
658 case LINE6_DEVID_BASSPODXTLIVE:
659 case LINE6_DEVID_PODXTLIVE:
660 case LINE6_DEVID_VARIAX:
664 case LINE6_DEVID_POCKETPOD:
665 switch (interface_number) {
667 return 0; /* this interface has no endpoints */
676 case LINE6_DEVID_PODHD500:
677 case LINE6_DEVID_PODX3:
678 case LINE6_DEVID_PODX3LIVE:
679 switch (interface_number) {
691 case LINE6_DEVID_BASSPODXT:
692 case LINE6_DEVID_BASSPODXTPRO:
693 case LINE6_DEVID_PODXT:
694 case LINE6_DEVID_PODXTPRO:
695 case LINE6_DEVID_PODHD300:
699 case LINE6_DEVID_GUITARPORT:
700 case LINE6_DEVID_PODSTUDIO_GX:
701 case LINE6_DEVID_PODSTUDIO_UX1:
702 case LINE6_DEVID_TONEPORT_GX:
703 case LINE6_DEVID_TONEPORT_UX1:
704 alternate = 2; /* 1..4 seem to be ok */
707 case LINE6_DEVID_TONEPORT_UX2:
708 case LINE6_DEVID_PODSTUDIO_UX2:
709 switch (interface_number) {
711 /* defaults to 44.1kHz, 16-bit */
715 /* don't know yet what this is ...
731 ret = usb_set_interface(usbdev, interface_number, alternate);
733 dev_err(&interface->dev, "set_interface failed\n");
737 /* initialize device data based on product id: */
739 case LINE6_DEVID_BASSPODXT:
740 case LINE6_DEVID_BASSPODXTLIVE:
741 case LINE6_DEVID_BASSPODXTPRO:
742 case LINE6_DEVID_PODXT:
743 case LINE6_DEVID_PODXTPRO:
744 size = sizeof(struct usb_line6_pod);
749 case LINE6_DEVID_PODHD300:
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_PODHD500:
909 ret = line6_podhd_init(interface,
910 (struct usb_line6_podhd *)line6);
913 case LINE6_DEVID_PODXTLIVE:
914 switch (interface_number) {
915 case PODXTLIVE_INTERFACE_POD:
917 line6_pod_init(interface,
918 (struct usb_line6_pod *)line6);
921 case PODXTLIVE_INTERFACE_VARIAX:
923 line6_variax_init(interface,
924 (struct usb_line6_variax *)line6);
928 dev_err(&interface->dev,
929 "PODxt Live interface %d not supported\n",
936 case LINE6_DEVID_VARIAX:
938 line6_variax_init(interface,
939 (struct usb_line6_variax *)line6);
942 case LINE6_DEVID_PODSTUDIO_GX:
943 case LINE6_DEVID_PODSTUDIO_UX1:
944 case LINE6_DEVID_PODSTUDIO_UX2:
945 case LINE6_DEVID_TONEPORT_GX:
946 case LINE6_DEVID_TONEPORT_UX1:
947 case LINE6_DEVID_TONEPORT_UX2:
948 case LINE6_DEVID_GUITARPORT:
950 line6_toneport_init(interface,
951 (struct usb_line6_toneport *)line6);
962 ret = sysfs_create_link(&interface->dev.kobj, &usbdev->dev.kobj,
967 /* creation of additional special files should go here */
969 dev_info(&interface->dev, "Line6 %s now attached\n",
970 line6->properties->name);
973 case LINE6_DEVID_PODX3:
974 case LINE6_DEVID_PODX3LIVE:
975 dev_info(&interface->dev,
976 "NOTE: the Line6 %s is detected, but not yet supported\n",
977 line6->properties->name);
980 /* increment reference counters: */
981 usb_get_intf(interface);
987 line6_destruct(interface);
993 Line6 device disconnected.
995 static void line6_disconnect(struct usb_interface *interface)
997 struct usb_line6 *line6;
998 struct usb_device *usbdev;
999 int interface_number;
1001 if (interface == NULL)
1003 usbdev = interface_to_usbdev(interface);
1007 /* removal of additional special files should go here */
1009 sysfs_remove_link(&interface->dev.kobj, "usb_device");
1011 interface_number = interface->cur_altsetting->desc.bInterfaceNumber;
1012 line6 = usb_get_intfdata(interface);
1014 if (line6 != NULL) {
1015 if (line6->urb_listen != NULL)
1016 line6_stop_listen(line6);
1018 if (usbdev != line6->usbdev)
1019 dev_err(line6->ifcdev,
1020 "driver bug: inconsistent usb device\n");
1022 switch (line6->usbdev->descriptor.idProduct) {
1023 case LINE6_DEVID_BASSPODXT:
1024 case LINE6_DEVID_BASSPODXTLIVE:
1025 case LINE6_DEVID_BASSPODXTPRO:
1026 case LINE6_DEVID_POCKETPOD:
1027 case LINE6_DEVID_PODX3:
1028 case LINE6_DEVID_PODX3LIVE:
1029 case LINE6_DEVID_PODXT:
1030 case LINE6_DEVID_PODXTPRO:
1031 line6_pod_disconnect(interface);
1034 case LINE6_DEVID_PODHD300:
1035 case LINE6_DEVID_PODHD500:
1036 line6_podhd_disconnect(interface);
1039 case LINE6_DEVID_PODXTLIVE:
1040 switch (interface_number) {
1041 case PODXTLIVE_INTERFACE_POD:
1042 line6_pod_disconnect(interface);
1045 case PODXTLIVE_INTERFACE_VARIAX:
1046 line6_variax_disconnect(interface);
1052 case LINE6_DEVID_VARIAX:
1053 line6_variax_disconnect(interface);
1056 case LINE6_DEVID_PODSTUDIO_GX:
1057 case LINE6_DEVID_PODSTUDIO_UX1:
1058 case LINE6_DEVID_PODSTUDIO_UX2:
1059 case LINE6_DEVID_TONEPORT_GX:
1060 case LINE6_DEVID_TONEPORT_UX1:
1061 case LINE6_DEVID_TONEPORT_UX2:
1062 case LINE6_DEVID_GUITARPORT:
1063 line6_toneport_disconnect(interface);
1070 dev_info(&interface->dev, "Line6 %s now disconnected\n",
1071 line6->properties->name);
1074 line6_destruct(interface);
1076 /* decrement reference counters: */
1077 usb_put_intf(interface);
1078 usb_put_dev(usbdev);
1084 Suspend Line6 device.
1086 static int line6_suspend(struct usb_interface *interface, pm_message_t message)
1088 struct usb_line6 *line6 = usb_get_intfdata(interface);
1089 struct snd_line6_pcm *line6pcm = line6->line6pcm;
1091 snd_power_change_state(line6->card, SNDRV_CTL_POWER_D3hot);
1093 if (line6->properties->capabilities & LINE6_BIT_CONTROL)
1094 line6_stop_listen(line6);
1096 if (line6pcm != NULL) {
1097 snd_pcm_suspend_all(line6pcm->pcm);
1098 line6_pcm_disconnect(line6pcm);
1099 line6pcm->flags = 0;
1106 Resume Line6 device.
1108 static int line6_resume(struct usb_interface *interface)
1110 struct usb_line6 *line6 = usb_get_intfdata(interface);
1112 if (line6->properties->capabilities & LINE6_BIT_CONTROL)
1113 line6_start_listen(line6);
1115 snd_power_change_state(line6->card, SNDRV_CTL_POWER_D0);
1120 Resume Line6 device after reset.
1122 static int line6_reset_resume(struct usb_interface *interface)
1124 struct usb_line6 *line6 = usb_get_intfdata(interface);
1126 switch (line6->usbdev->descriptor.idProduct) {
1127 case LINE6_DEVID_PODSTUDIO_GX:
1128 case LINE6_DEVID_PODSTUDIO_UX1:
1129 case LINE6_DEVID_PODSTUDIO_UX2:
1130 case LINE6_DEVID_TONEPORT_GX:
1131 case LINE6_DEVID_TONEPORT_UX1:
1132 case LINE6_DEVID_TONEPORT_UX2:
1133 case LINE6_DEVID_GUITARPORT:
1134 line6_toneport_reset_resume((struct usb_line6_toneport *)line6);
1137 return line6_resume(interface);
1140 #endif /* CONFIG_PM */
1142 static struct usb_driver line6_driver = {
1143 .name = DRIVER_NAME,
1144 .probe = line6_probe,
1145 .disconnect = line6_disconnect,
1147 .suspend = line6_suspend,
1148 .resume = line6_resume,
1149 .reset_resume = line6_reset_resume,
1151 .id_table = line6_id_table,
1154 module_usb_driver(line6_driver);
1156 MODULE_AUTHOR(DRIVER_AUTHOR);
1157 MODULE_DESCRIPTION(DRIVER_DESC);
1158 MODULE_LICENSE("GPL");
1159 MODULE_VERSION(DRIVER_VERSION);