2 * Line6 Linux USB driver - 0.8.0
4 * Copyright (C) 2004-2009 Markus Grabner (grabner@icg.tugraz.at)
5 * Emil Myhrman (emil.myhrman@gmail.com)
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License as
9 * published by the Free Software Foundation, version 2.
20 static int toneport_send_cmd(struct usb_device
*usbdev
, int cmd1
, int cmd2
);
22 static struct snd_ratden toneport_ratden
= {
29 static struct line6_pcm_properties toneport_pcm_properties
= {
30 .snd_line6_playback_hw
= {
31 .info
= (SNDRV_PCM_INFO_MMAP
|
32 SNDRV_PCM_INFO_INTERLEAVED
|
33 SNDRV_PCM_INFO_BLOCK_TRANSFER
|
34 SNDRV_PCM_INFO_MMAP_VALID
|
35 SNDRV_PCM_INFO_PAUSE
|
36 SNDRV_PCM_INFO_SYNC_START
),
37 .formats
= SNDRV_PCM_FMTBIT_S16_LE
,
38 .rates
= SNDRV_PCM_RATE_KNOT
,
43 .buffer_bytes_max
= 60000,
44 .period_bytes_min
= 180 * 4,
45 .period_bytes_max
= 8192,
48 .snd_line6_capture_hw
= {
49 .info
= (SNDRV_PCM_INFO_MMAP
|
50 SNDRV_PCM_INFO_INTERLEAVED
|
51 SNDRV_PCM_INFO_BLOCK_TRANSFER
|
52 SNDRV_PCM_INFO_MMAP_VALID
|
53 SNDRV_PCM_INFO_SYNC_START
),
54 .formats
= SNDRV_PCM_FMTBIT_S16_LE
,
55 .rates
= SNDRV_PCM_RATE_KNOT
,
60 .buffer_bytes_max
= 60000,
61 .period_bytes_min
= 188 * 4,
62 .period_bytes_max
= 8192,
67 .rats
= &toneport_ratden
},
72 For the led on Guitarport.
73 Brightness goes from 0x00 to 0x26. Set a value above this to have led
75 (void cmd_0x02(byte red, byte green)
77 static int led_red
= 0x00;
78 static int led_green
= 0x26;
80 static void toneport_update_led(struct device
*dev
)
82 struct usb_interface
*interface
= to_usb_interface(dev
);
83 struct usb_line6_toneport
*tp
= usb_get_intfdata(interface
);
84 struct usb_line6
*line6
;
91 toneport_send_cmd(line6
->usbdev
, (led_red
<< 8) | 0x0002,
95 static ssize_t
toneport_set_led_red(struct device
*dev
,
96 struct device_attribute
*attr
,
97 const char *buf
, size_t count
)
102 retval
= strict_strtol(buf
, 10, &value
);
107 toneport_update_led(dev
);
111 static ssize_t
toneport_set_led_green(struct device
*dev
,
112 struct device_attribute
*attr
,
113 const char *buf
, size_t count
)
118 retval
= strict_strtol(buf
, 10, &value
);
123 toneport_update_led(dev
);
127 static DEVICE_ATTR(led_red
, S_IWUGO
| S_IRUGO
, line6_nop_read
,
128 toneport_set_led_red
);
129 static DEVICE_ATTR(led_green
, S_IWUGO
| S_IRUGO
, line6_nop_read
,
130 toneport_set_led_green
);
132 static int toneport_send_cmd(struct usb_device
*usbdev
, int cmd1
, int cmd2
)
136 ret
= usb_control_msg(usbdev
, usb_sndctrlpipe(usbdev
, 0), 0x67,
137 USB_TYPE_VENDOR
| USB_RECIP_DEVICE
| USB_DIR_OUT
,
138 cmd1
, cmd2
, NULL
, 0, LINE6_TIMEOUT
* HZ
);
141 err("send failed (error %d)\n", ret
);
151 static void toneport_destruct(struct usb_interface
*interface
)
153 struct usb_line6_toneport
*toneport
= usb_get_intfdata(interface
);
154 struct usb_line6
*line6
;
156 if (toneport
== NULL
)
158 line6
= &toneport
->line6
;
161 line6_cleanup_audio(line6
);
165 Init Toneport device.
167 int toneport_init(struct usb_interface
*interface
,
168 struct usb_line6_toneport
*toneport
)
171 struct usb_line6
*line6
= &toneport
->line6
;
172 struct usb_device
*usbdev
;
174 if ((interface
== NULL
) || (toneport
== NULL
))
177 /* initialize audio system: */
178 err
= line6_init_audio(line6
);
180 toneport_destruct(interface
);
184 /* initialize PCM subsystem: */
185 err
= line6_init_pcm(line6
, &toneport_pcm_properties
);
187 toneport_destruct(interface
);
191 /* register audio system: */
192 err
= line6_register_audio(line6
);
194 toneport_destruct(interface
);
198 usbdev
= line6
->usbdev
;
199 line6_read_serial_number(line6
, &toneport
->serial_number
);
200 line6_read_data(line6
, 0x80c2, &toneport
->firmware_version
, 1);
202 /* sync time on device with host: */
203 ticks
= (int)get_seconds();
204 line6_write_data(line6
, 0x80c6, &ticks
, 4);
207 seems to work without the first two...
209 /* toneport_send_cmd(usbdev, 0x0201, 0x0002); */
210 /* toneport_send_cmd(usbdev, 0x0801, 0x0000); */
211 /* only one that works for me; on GP, TP might be different? */
212 toneport_send_cmd(usbdev
, 0x0301, 0x0000);
214 if (usbdev
->descriptor
.idProduct
!= LINE6_DEVID_GUITARPORT
) {
215 CHECK_RETURN(device_create_file
216 (&interface
->dev
, &dev_attr_led_red
));
217 CHECK_RETURN(device_create_file
218 (&interface
->dev
, &dev_attr_led_green
));
219 toneport_update_led(&usbdev
->dev
);
226 Toneport device disconnected.
228 void toneport_disconnect(struct usb_interface
*interface
)
230 struct usb_line6_toneport
*toneport
;
232 if (interface
== NULL
)
234 toneport
= usb_get_intfdata(interface
);
236 if (toneport
->line6
.usbdev
->descriptor
.idProduct
!=
237 LINE6_DEVID_GUITARPORT
) {
238 device_remove_file(&interface
->dev
, &dev_attr_led_red
);
239 device_remove_file(&interface
->dev
, &dev_attr_led_green
);
242 if (toneport
!= NULL
) {
243 struct snd_line6_pcm
*line6pcm
= toneport
->line6
.line6pcm
;
245 if (line6pcm
!= NULL
) {
246 unlink_wait_clear_audio_out_urbs(line6pcm
);
247 unlink_wait_clear_audio_in_urbs(line6pcm
);
251 toneport_destruct(interface
);