2 * Line6 Linux USB driver - 0.8.0
4 * Copyright (C) 2004-2009 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.
14 #include <linux/kernel.h>
15 #include <linux/module.h>
16 #include <linux/usb.h>
30 #define DRIVER_AUTHOR "Markus Grabner <grabner@icg.tugraz.at>"
31 #define DRIVER_DESC "Line6 USB Driver"
32 #define DRIVER_VERSION "0.8.0"
35 /* table of devices that work with this driver */
36 static struct usb_device_id line6_id_table[] = {
37 { USB_DEVICE(LINE6_VENDOR_ID, LINE6_DEVID_BASSPODXT) },
38 { USB_DEVICE(LINE6_VENDOR_ID, LINE6_DEVID_BASSPODXTLIVE) },
39 { USB_DEVICE(LINE6_VENDOR_ID, LINE6_DEVID_BASSPODXTPRO) },
40 { USB_DEVICE(LINE6_VENDOR_ID, LINE6_DEVID_GUITARPORT) },
41 { USB_DEVICE(LINE6_VENDOR_ID, LINE6_DEVID_POCKETPOD) },
42 { USB_DEVICE(LINE6_VENDOR_ID, LINE6_DEVID_PODX3) },
43 { USB_DEVICE(LINE6_VENDOR_ID, LINE6_DEVID_PODX3LIVE) },
44 { USB_DEVICE(LINE6_VENDOR_ID, LINE6_DEVID_PODXT) },
45 { USB_DEVICE(LINE6_VENDOR_ID, LINE6_DEVID_PODXTLIVE) },
46 { USB_DEVICE(LINE6_VENDOR_ID, LINE6_DEVID_PODXTPRO) },
47 { USB_DEVICE(LINE6_VENDOR_ID, LINE6_DEVID_TONEPORT_GX) },
48 { USB_DEVICE(LINE6_VENDOR_ID, LINE6_DEVID_TONEPORT_UX1) },
49 { USB_DEVICE(LINE6_VENDOR_ID, LINE6_DEVID_TONEPORT_UX2) },
50 { USB_DEVICE(LINE6_VENDOR_ID, LINE6_DEVID_VARIAX) },
53 MODULE_DEVICE_TABLE(usb, line6_id_table);
55 static struct line6_properties line6_properties_table[] = {
56 { "BassPODxt", LINE6_BIT_BASSPODXT, LINE6_BIT_CONTROL_PCM },
57 { "BassPODxt Live", LINE6_BIT_BASSPODXTLIVE, LINE6_BIT_CONTROL_PCM },
58 { "BassPODxt Pro", LINE6_BIT_BASSPODXTPRO, LINE6_BIT_CONTROL_PCM },
59 { "GuitarPort", LINE6_BIT_GUITARPORT, LINE6_BIT_PCM },
60 { "Pocket POD", LINE6_BIT_POCKETPOD, LINE6_BIT_CONTROL_PCM },
61 { "POD X3", LINE6_BIT_PODX3, LINE6_BIT_PCM },
62 { "POD X3 Live", LINE6_BIT_PODX3LIVE, LINE6_BIT_PCM },
63 { "PODxt", LINE6_BIT_PODXT, LINE6_BIT_CONTROL_PCM },
64 { "PODxt Live", LINE6_BIT_PODXTLIVE, LINE6_BIT_CONTROL_PCM },
65 { "PODxt Pro", LINE6_BIT_PODXTPRO, LINE6_BIT_CONTROL_PCM },
66 { "TonePort GX", LINE6_BIT_TONEPORT_GX, LINE6_BIT_PCM },
67 { "TonePort UX1", LINE6_BIT_TONEPORT_UX1, LINE6_BIT_PCM },
68 { "TonePort UX2", LINE6_BIT_TONEPORT_UX2, LINE6_BIT_PCM },
69 { "Variax Workbench", LINE6_BIT_VARIAX, LINE6_BIT_CONTROL }
74 This is Line6's MIDI manufacturer ID.
76 const unsigned char line6_midi_id[] = { 0x00, 0x01, 0x0c };
78 struct usb_line6 *line6_devices[LINE6_MAX_DEVICES];
79 struct workqueue_struct *line6_workqueue;
83 Class for asynchronous messages.
86 struct usb_line6 *line6;
96 static void line6_data_received(struct urb *urb);
97 static int line6_send_raw_message_async_part(struct message *msg,
102 Start to listen on endpoint.
104 static int line6_start_listen(struct usb_line6 *line6)
106 usb_fill_int_urb(line6->urb_listen, line6->usbdev,
107 usb_rcvintpipe(line6->usbdev, line6->ep_control_read),
108 line6->buffer_listen, LINE6_BUFSIZE_LISTEN,
109 line6_data_received, line6, line6->interval);
110 line6->urb_listen->actual_length = 0;
111 return usb_submit_urb(line6->urb_listen, GFP_KERNEL);
116 Write hexdump to syslog.
118 void line6_write_hexdump(struct usb_line6 *line6, char dir,
119 const unsigned char *buffer, int size)
121 static const int BYTES_PER_LINE = 8;
123 char asc[BYTES_PER_LINE + 1];
126 for (i = 0; i < size; i += BYTES_PER_LINE) {
127 int hexdumpsize = sizeof(hexdump);
129 int n = min(size - i, BYTES_PER_LINE);
132 for (j = 0; j < BYTES_PER_LINE; ++j) {
136 unsigned char val = buffer[i + j];
137 bytes = snprintf(p, hexdumpsize, " %02X", val);
138 asc[j] = ((val >= 0x20) && (val < 0x7f)) ? val : '.';
140 bytes = snprintf(p, hexdumpsize, " ");
142 if (bytes > hexdumpsize)
143 break; /* buffer overflow */
146 hexdumpsize -= bytes;
149 dev_info(line6->ifcdev, "%c%04X:%s %s\n", dir, i, hexdump, asc);
154 #if DO_DUMP_URB_RECEIVE
156 Dump URB data to syslog.
158 static void line6_dump_urb(struct urb *urb)
160 struct usb_line6 *line6 = (struct usb_line6 *)urb->context;
165 line6_write_hexdump(line6, 'R', (unsigned char *)urb->transfer_buffer,
171 Send raw message in pieces of wMaxPacketSize bytes.
173 int line6_send_raw_message(struct usb_line6 *line6, const char *buffer,
179 line6_write_hexdump(line6, 'S', buffer, size);
182 for (i = 0; i < size; i += line6->max_packet_size) {
184 const char *frag_buf = buffer + i;
185 int frag_size = min(line6->max_packet_size, size - i);
188 retval = usb_interrupt_msg(line6->usbdev,
189 usb_sndintpipe(line6->usbdev,
190 line6->ep_control_write),
191 (char *)frag_buf, frag_size,
192 &partial, LINE6_TIMEOUT * HZ);
195 dev_err(line6->ifcdev,
196 "usb_interrupt_msg failed (%d)\n", retval);
207 Notification of completion of asynchronous request transmission.
209 static void line6_async_request_sent(struct urb *urb)
211 struct message *msg = (struct message *)urb->context;
213 if (msg->done >= msg->size) {
217 line6_send_raw_message_async_part(msg, urb);
221 Asynchronously send part of a raw message.
223 static int line6_send_raw_message_async_part(struct message *msg,
227 struct usb_line6 *line6 = msg->line6;
228 int done = msg->done;
229 int bytes = min(msg->size - done, line6->max_packet_size);
231 usb_fill_int_urb(urb, line6->usbdev,
232 usb_sndintpipe(line6->usbdev, line6->ep_control_write),
233 (char *)msg->buffer + done, bytes,
234 line6_async_request_sent, msg, line6->interval);
237 line6_write_hexdump(line6, 'S', (char *)msg->buffer + done, bytes);
241 retval = usb_submit_urb(urb, GFP_ATOMIC);
244 dev_err(line6->ifcdev, "%s: usb_submit_urb failed (%d)\n",
255 Asynchronously send raw message.
257 int line6_send_raw_message_async(struct usb_line6 *line6, const char *buffer,
263 /* create message: */
264 msg = kmalloc(sizeof(struct message), GFP_ATOMIC);
267 dev_err(line6->ifcdev, "Out of memory\n");
272 urb = usb_alloc_urb(0, GFP_ATOMIC);
276 dev_err(line6->ifcdev, "Out of memory\n");
280 /* set message data: */
282 msg->buffer = buffer;
287 return line6_send_raw_message_async_part(msg, urb);
291 Send sysex message in pieces of wMaxPacketSize bytes.
293 int line6_send_sysex_message(struct usb_line6 *line6, const char *buffer,
296 return line6_send_raw_message(line6, buffer, size + SYSEX_EXTRA_SIZE) - SYSEX_EXTRA_SIZE;
300 Allocate buffer for sysex message and prepare header.
301 @param code sysex message code
302 @param size number of bytes between code and sysex end
304 char *line6_alloc_sysex_buffer(struct usb_line6 *line6, int code1, int code2,
307 char *buffer = kmalloc(size + SYSEX_EXTRA_SIZE, GFP_KERNEL);
310 dev_err(line6->ifcdev, "out of memory\n");
314 buffer[0] = LINE6_SYSEX_BEGIN;
315 memcpy(buffer + 1, line6_midi_id, sizeof(line6_midi_id));
316 buffer[sizeof(line6_midi_id) + 1] = code1;
317 buffer[sizeof(line6_midi_id) + 2] = code2;
318 buffer[sizeof(line6_midi_id) + 3 + size] = LINE6_SYSEX_END;
323 Notification of data received from the Line6 device.
325 static void line6_data_received(struct urb *urb)
327 struct usb_line6 *line6 = (struct usb_line6 *)urb->context;
328 struct MidiBuffer *mb = &line6->line6midi->midibuf_in;
331 if (urb->status == -ESHUTDOWN)
334 #if DO_DUMP_URB_RECEIVE
338 done = midibuf_write(mb, urb->transfer_buffer, urb->actual_length);
340 if (done < urb->actual_length) {
341 midibuf_ignore(mb, done);
342 DEBUG_MESSAGES(dev_err(line6->ifcdev, "%d %d buffer overflow - message skipped\n", done, urb->actual_length));
346 done = midibuf_read(mb, line6->buffer_message, LINE6_MESSAGE_MAXLEN);
351 /* MIDI input filter */
352 if (midibuf_skip_message(mb, line6->line6midi->midi_mask_receive))
355 line6->message_length = done;
356 #if DO_DUMP_MIDI_RECEIVE
357 line6_write_hexdump(line6, 'r', line6->buffer_message, done);
359 line6_midi_receive(line6, line6->buffer_message, done);
361 switch (line6->usbdev->descriptor.idProduct) {
362 case LINE6_DEVID_BASSPODXT:
363 case LINE6_DEVID_BASSPODXTLIVE:
364 case LINE6_DEVID_BASSPODXTPRO:
365 case LINE6_DEVID_PODXT:
366 case LINE6_DEVID_PODXTPRO:
367 case LINE6_DEVID_POCKETPOD:
368 pod_process_message((struct usb_line6_pod *)line6);
371 case LINE6_DEVID_PODXTLIVE:
372 switch (line6->interface_number) {
373 case PODXTLIVE_INTERFACE_POD:
374 pod_process_message((struct usb_line6_pod *)line6);
377 case PODXTLIVE_INTERFACE_VARIAX:
378 variax_process_message((struct usb_line6_variax *)line6);
382 dev_err(line6->ifcdev, "PODxt Live interface %d not supported\n", line6->interface_number);
386 case LINE6_DEVID_VARIAX:
387 variax_process_message((struct usb_line6_variax *)line6);
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, int value)
404 unsigned char *buffer;
405 unsigned int partial;
407 buffer = kmalloc(2, GFP_KERNEL);
410 dev_err(line6->ifcdev, "out of memory\n");
414 buffer[0] = LINE6_PROGRAM_CHANGE | LINE6_CHANNEL_HOST;
418 line6_write_hexdump(line6, 'S', buffer, 2);
421 retval = usb_interrupt_msg(line6->usbdev,
422 usb_sndintpipe(line6->usbdev,
423 line6->ep_control_write),
424 buffer, 2, &partial, LINE6_TIMEOUT * HZ);
427 dev_err(line6->ifcdev, "usb_interrupt_msg failed (%d)\n", retval);
434 Transmit Line6 control parameter.
436 int line6_transmit_parameter(struct usb_line6 *line6, int param, int value)
439 unsigned char *buffer;
440 unsigned int partial;
442 buffer = kmalloc(3, GFP_KERNEL);
445 dev_err(line6->ifcdev, "out of memory\n");
449 buffer[0] = LINE6_PARAM_CHANGE | LINE6_CHANNEL_HOST;
454 line6_write_hexdump(line6, 'S', buffer, 3);
457 retval = usb_interrupt_msg(line6->usbdev,
458 usb_sndintpipe(line6->usbdev, line6->ep_control_write),
459 buffer, 3, &partial, LINE6_TIMEOUT * HZ);
462 dev_err(line6->ifcdev, "usb_interrupt_msg failed (%d)\n", retval);
469 Read data from device.
471 int line6_read_data(struct usb_line6 *line6, int address, void *data, size_t datalen)
473 struct usb_device *usbdev = line6->usbdev;
477 /* query the serial number: */
478 ret = usb_control_msg(usbdev, usb_sndctrlpipe(usbdev, 0), 0x67,
479 USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_OUT,
480 (datalen << 8) | 0x21, address, NULL, 0, LINE6_TIMEOUT * HZ);
483 dev_err(line6->ifcdev, "read request failed (error %d)\n", ret);
487 /* Wait for data length. We'll get a couple of 0xff until length arrives. */
489 ret = usb_control_msg(usbdev, usb_rcvctrlpipe(usbdev, 0), 0x67,
490 USB_TYPE_VENDOR | USB_RECIP_DEVICE |
492 0x0012, 0x0000, &len, 1,
495 dev_err(line6->ifcdev,
496 "receive length failed (error %d)\n", ret);
503 if (len != datalen) {
504 /* should be equal or something went wrong */
505 dev_err(line6->ifcdev,
506 "length mismatch (expected %d, got %d)\n",
507 (int)datalen, (int)len);
511 /* receive the result: */
512 ret = usb_control_msg(usbdev, usb_rcvctrlpipe(usbdev, 0), 0x67,
513 USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_IN,
514 0x0013, 0x0000, data, datalen,
518 dev_err(line6->ifcdev, "read failed (error %d)\n", ret);
526 Write data to device.
528 int line6_write_data(struct usb_line6 *line6, int address, void *data,
531 struct usb_device *usbdev = line6->usbdev;
533 unsigned char status;
535 ret = usb_control_msg(usbdev, usb_sndctrlpipe(usbdev, 0), 0x67,
536 USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_OUT,
537 0x0022, address, data, datalen,
541 dev_err(line6->ifcdev,
542 "write request failed (error %d)\n", ret);
547 ret = usb_control_msg(usbdev, usb_rcvctrlpipe(usbdev, 0),
549 USB_TYPE_VENDOR | USB_RECIP_DEVICE |
552 &status, 1, LINE6_TIMEOUT * HZ);
555 dev_err(line6->ifcdev,
556 "receiving status failed (error %d)\n", ret);
560 while (status == 0xff)
564 dev_err(line6->ifcdev, "write failed (error %d)\n", ret);
572 Read Line6 device serial number.
573 (POD, TonePort, GuitarPort)
575 int line6_read_serial_number(struct usb_line6 *line6, int *serial_number)
577 return line6_read_data(line6, 0x80d0, serial_number, sizeof(*serial_number));
581 No operation (i.e., unsupported).
583 ssize_t line6_nop_read(struct device *dev, struct device_attribute *attr,
590 No operation (i.e., unsupported).
592 ssize_t line6_nop_write(struct device *dev, struct device_attribute *attr,
593 const char *buf, size_t count)
599 "write" request on "raw" special file.
602 ssize_t line6_set_raw(struct device *dev, struct device_attribute *attr,
603 const char *buf, size_t count)
605 struct usb_interface *interface = to_usb_interface(dev);
606 struct usb_line6 *line6 = usb_get_intfdata(interface);
607 line6_send_raw_message(line6, buf, count);
615 static void line6_destruct(struct usb_interface *interface)
617 struct usb_line6 *line6;
619 if (interface == NULL)
621 line6 = usb_get_intfdata(interface);
625 /* free buffer memory first: */
626 kfree(line6->buffer_message);
627 kfree(line6->buffer_listen);
629 /* then free URBs: */
630 usb_free_urb(line6->urb_listen);
632 /* make sure the device isn't destructed twice: */
633 usb_set_intfdata(interface, NULL);
635 /* free interface data: */
639 static void line6_list_devices(void)
643 for (i = 0; i < LINE6_MAX_DEVICES; ++i) {
644 struct usb_line6 *dev = line6_devices[i];
645 printk(KERN_INFO "Line6 device %d: ", i);
648 printk("(not used)\n");
650 printk("%s:%d\n", dev->properties->name, dev->interface_number);
657 static int line6_probe(struct usb_interface *interface, const struct usb_device_id *id)
660 struct usb_device *usbdev = NULL;
661 struct usb_line6 *line6 = NULL;
662 const struct line6_properties *properties;
664 int interface_number, alternate = 0;
667 int ep_read = 0, ep_write = 0;
670 if (interface == NULL)
672 usbdev = interface_to_usbdev(interface);
676 /* increment reference counters: */
677 usb_get_intf(interface);
680 /* we don't handle multiple configurations */
681 if (usbdev->descriptor.bNumConfigurations != 1)
684 /* check vendor and product id */
685 for (devtype = ARRAY_SIZE(line6_id_table) - 1; devtype--;)
686 if ((le16_to_cpu(usbdev->descriptor.idVendor) == line6_id_table[devtype].idVendor) &&
687 (le16_to_cpu(usbdev->descriptor.idProduct) == line6_id_table[devtype].idProduct))
693 /* find free slot in device table: */
694 for (devnum = 0; devnum < LINE6_MAX_DEVICES; ++devnum)
695 if (line6_devices[devnum] == NULL)
698 if (devnum == LINE6_MAX_DEVICES)
701 /* initialize device info: */
702 properties = &line6_properties_table[devtype];
703 dev_info(&interface->dev, "Line6 %s found\n", properties->name);
704 product = le16_to_cpu(usbdev->descriptor.idProduct);
706 /* query interface number */
707 interface_number = interface->cur_altsetting->desc.bInterfaceNumber;
710 case LINE6_DEVID_BASSPODXTLIVE:
711 case LINE6_DEVID_POCKETPOD:
712 case LINE6_DEVID_PODXTLIVE:
713 case LINE6_DEVID_VARIAX:
717 case LINE6_DEVID_PODX3:
718 case LINE6_DEVID_PODX3LIVE:
719 switch (interface_number) {
731 case LINE6_DEVID_BASSPODXT:
732 case LINE6_DEVID_BASSPODXTPRO:
733 case LINE6_DEVID_PODXT:
734 case LINE6_DEVID_PODXTPRO:
738 case LINE6_DEVID_TONEPORT_GX:
739 case LINE6_DEVID_GUITARPORT:
740 alternate = 2; /* 1..4 seem to be ok */
743 case LINE6_DEVID_TONEPORT_UX1:
744 case LINE6_DEVID_TONEPORT_UX2:
745 switch (interface_number) {
747 /* defaults to 44.1kHz, 16-bit */
763 ret = usb_set_interface(usbdev, interface_number, alternate);
765 dev_err(&interface->dev, "set_interface failed\n");
769 /* initialize device data based on product id: */
771 case LINE6_DEVID_BASSPODXT:
772 case LINE6_DEVID_BASSPODXTLIVE:
773 case LINE6_DEVID_BASSPODXTPRO:
774 case LINE6_DEVID_POCKETPOD:
775 case LINE6_DEVID_PODXT:
776 case LINE6_DEVID_PODXTPRO:
777 size = sizeof(struct usb_line6_pod);
782 case LINE6_DEVID_PODX3:
783 case LINE6_DEVID_PODX3LIVE:
784 /* currently unused! */
785 size = sizeof(struct usb_line6_pod);
790 case LINE6_DEVID_TONEPORT_GX:
791 case LINE6_DEVID_TONEPORT_UX1:
792 case LINE6_DEVID_TONEPORT_UX2:
793 case LINE6_DEVID_GUITARPORT:
794 size = sizeof(struct usb_line6_toneport);
795 /* these don't have a control channel */
798 case LINE6_DEVID_PODXTLIVE:
799 switch (interface_number) {
800 case PODXTLIVE_INTERFACE_POD:
801 size = sizeof(struct usb_line6_pod);
806 case PODXTLIVE_INTERFACE_VARIAX:
807 size = sizeof(struct usb_line6_variax);
817 case LINE6_DEVID_VARIAX:
818 size = sizeof(struct usb_line6_variax);
829 dev_err(line6->ifcdev, "driver bug: interface data size not set\n");
833 line6 = kzalloc(size, GFP_KERNEL);
836 dev_err(&interface->dev, "Out of memory\n");
840 /* store basic data: */
841 line6->interface_number = interface_number;
842 line6->properties = properties;
843 line6->usbdev = usbdev;
844 line6->ifcdev = &interface->dev;
845 line6->ep_control_read = ep_read;
846 line6->ep_control_write = ep_write;
847 line6->product = product;
849 /* get data from endpoint descriptor (see usb_maxpacket): */
851 struct usb_host_endpoint *ep;
852 unsigned epnum = usb_pipeendpoint(usb_rcvintpipe(usbdev, ep_read));
853 ep = usbdev->ep_in[epnum];
856 line6->interval = ep->desc.bInterval;
857 line6->max_packet_size = le16_to_cpu(ep->desc.wMaxPacketSize);
859 line6->interval = LINE6_FALLBACK_INTERVAL;
860 line6->max_packet_size = LINE6_FALLBACK_MAXPACKETSIZE;
861 dev_err(line6->ifcdev, "endpoint not available, using fallback values");
865 usb_set_intfdata(interface, line6);
867 if (properties->capabilities & LINE6_BIT_CONTROL) {
868 /* initialize USB buffers: */
869 line6->buffer_listen = kmalloc(LINE6_BUFSIZE_LISTEN, GFP_KERNEL);
871 if (line6->buffer_listen == NULL) {
872 dev_err(&interface->dev, "Out of memory\n");
873 line6_destruct(interface);
877 line6->buffer_message = kmalloc(LINE6_MESSAGE_MAXLEN, GFP_KERNEL);
879 if (line6->buffer_message == NULL) {
880 dev_err(&interface->dev, "Out of memory\n");
881 line6_destruct(interface);
885 line6->urb_listen = usb_alloc_urb(0, GFP_KERNEL);
887 if (line6->urb_listen == NULL) {
888 dev_err(&interface->dev, "Out of memory\n");
889 line6_destruct(interface);
893 ret = line6_start_listen(line6);
895 dev_err(&interface->dev, "%s: usb_submit_urb failed\n",
897 line6_destruct(interface);
902 /* initialize device data based on product id: */
904 case LINE6_DEVID_BASSPODXT:
905 case LINE6_DEVID_BASSPODXTLIVE:
906 case LINE6_DEVID_BASSPODXTPRO:
907 case LINE6_DEVID_POCKETPOD:
908 case LINE6_DEVID_PODX3:
909 case LINE6_DEVID_PODX3LIVE:
910 case LINE6_DEVID_PODXT:
911 case LINE6_DEVID_PODXTPRO:
912 ret = pod_init(interface, (struct usb_line6_pod *)line6);
915 case LINE6_DEVID_PODXTLIVE:
916 switch (interface_number) {
917 case PODXTLIVE_INTERFACE_POD:
918 ret = pod_init(interface, (struct usb_line6_pod *)line6);
921 case PODXTLIVE_INTERFACE_VARIAX:
922 ret = variax_init(interface, (struct usb_line6_variax *)line6);
926 dev_err(&interface->dev,
927 "PODxt Live interface %d not supported\n",
934 case LINE6_DEVID_VARIAX:
935 ret = variax_init(interface, (struct usb_line6_variax *)line6);
938 case LINE6_DEVID_TONEPORT_GX:
939 case LINE6_DEVID_TONEPORT_UX1:
940 case LINE6_DEVID_TONEPORT_UX2:
941 case LINE6_DEVID_GUITARPORT:
942 ret = toneport_init(interface, (struct usb_line6_toneport *)line6);
951 line6_destruct(interface);
955 ret = sysfs_create_link(&interface->dev.kobj, &usbdev->dev.kobj,
958 line6_destruct(interface);
962 dev_info(&interface->dev, "Line6 %s now attached\n",
963 line6->properties->name);
964 line6_devices[devnum] = line6;
965 line6_list_devices();
970 Line6 device disconnected.
972 static void line6_disconnect(struct usb_interface *interface)
974 struct usb_line6 *line6;
975 struct usb_device *usbdev;
976 int interface_number, i;
978 if (interface == NULL)
980 usbdev = interface_to_usbdev(interface);
984 sysfs_remove_link(&interface->dev.kobj, "usb_device");
986 interface_number = interface->cur_altsetting->desc.bInterfaceNumber;
987 line6 = usb_get_intfdata(interface);
990 if (line6->urb_listen != NULL)
991 usb_kill_urb(line6->urb_listen);
993 if (usbdev != line6->usbdev)
994 dev_err(line6->ifcdev,
995 "driver bug: inconsistent usb device\n");
997 switch (line6->usbdev->descriptor.idProduct) {
998 case LINE6_DEVID_BASSPODXT:
999 case LINE6_DEVID_BASSPODXTLIVE:
1000 case LINE6_DEVID_BASSPODXTPRO:
1001 case LINE6_DEVID_POCKETPOD:
1002 case LINE6_DEVID_PODX3:
1003 case LINE6_DEVID_PODX3LIVE:
1004 case LINE6_DEVID_PODXT:
1005 case LINE6_DEVID_PODXTPRO:
1006 pod_disconnect(interface);
1009 case LINE6_DEVID_PODXTLIVE:
1010 switch (interface_number) {
1011 case PODXTLIVE_INTERFACE_POD:
1012 pod_disconnect(interface);
1015 case PODXTLIVE_INTERFACE_VARIAX:
1016 variax_disconnect(interface);
1022 case LINE6_DEVID_VARIAX:
1023 variax_disconnect(interface);
1026 case LINE6_DEVID_TONEPORT_GX:
1027 case LINE6_DEVID_TONEPORT_UX1:
1028 case LINE6_DEVID_TONEPORT_UX2:
1029 case LINE6_DEVID_GUITARPORT:
1030 toneport_disconnect(interface);
1037 dev_info(&interface->dev, "Line6 %s now disconnected\n", line6->properties->name);
1039 for (i = LINE6_MAX_DEVICES; i--;)
1040 if (line6_devices[i] == line6)
1041 line6_devices[i] = NULL;
1044 line6_destruct(interface);
1046 /* decrement reference counters: */
1047 usb_put_intf(interface);
1048 usb_put_dev(usbdev);
1050 line6_list_devices();
1053 static struct usb_driver line6_driver = {
1054 .name = DRIVER_NAME,
1055 .probe = line6_probe,
1056 .disconnect = line6_disconnect,
1057 .id_table = line6_id_table,
1061 Module initialization.
1063 static int __init line6_init(void)
1067 printk(KERN_INFO "%s driver version %s%s\n",
1068 DRIVER_NAME, DRIVER_VERSION, DRIVER_REVISION);
1069 line6_workqueue = create_workqueue(DRIVER_NAME);
1071 if (line6_workqueue == NULL) {
1072 err("couldn't create workqueue");
1076 for (i = LINE6_MAX_DEVICES; i--;)
1077 line6_devices[i] = NULL;
1079 retval = usb_register(&line6_driver);
1082 err("usb_register failed. Error number %d", retval);
1090 static void __exit line6_exit(void)
1092 destroy_workqueue(line6_workqueue);
1093 usb_deregister(&line6_driver);
1096 module_init(line6_init);
1097 module_exit(line6_exit);
1099 MODULE_AUTHOR(DRIVER_AUTHOR);
1100 MODULE_DESCRIPTION(DRIVER_DESC);
1101 MODULE_LICENSE("GPL");
1102 MODULE_VERSION(DRIVER_VERSION);