]>
Commit | Line | Data |
---|---|---|
705ececd MG |
1 | /* |
2 | * Line6 Linux USB driver - 0.8.0 | |
3 | * | |
4 | * Copyright (C) 2004-2009 Markus Grabner (grabner@icg.tugraz.at) | |
5 | * | |
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. | |
9 | * | |
10 | */ | |
11 | ||
12 | #include "driver.h" | |
13 | ||
5a0e3ad6 TH |
14 | #include <linux/slab.h> |
15 | ||
705ececd MG |
16 | #include "audio.h" |
17 | #include "control.h" | |
18 | #include "variax.h" | |
19 | ||
20 | ||
21 | #define VARIAX_SYSEX_CODE 7 | |
22 | #define VARIAX_SYSEX_PARAM 0x3b | |
23 | #define VARIAX_SYSEX_ACTIVATE 0x2a | |
24 | #define VARIAX_MODEL_HEADER_LENGTH 7 | |
25 | #define VARIAX_MODEL_MESSAGE_LENGTH 199 | |
26 | #define VARIAX_OFFSET_ACTIVATE 7 | |
27 | ||
28 | ||
29 | static const char variax_activate[] = { | |
30 | 0xf0, 0x00, 0x01, 0x0c, 0x07, 0x00, 0x2a, 0x01, | |
31 | 0xf7 | |
32 | }; | |
33 | static const char variax_request_bank[] = { | |
34 | 0xf0, 0x00, 0x01, 0x0c, 0x07, 0x00, 0x6d, 0xf7 | |
35 | }; | |
36 | static const char variax_request_model1[] = { | |
37 | 0xf0, 0x00, 0x01, 0x0c, 0x07, 0x00, 0x3c, 0x00, | |
38 | 0x02, 0x00, 0x00, 0x00, 0x00, 0x03, 0x05, 0x03, | |
39 | 0x00, 0x00, 0x00, 0xf7 | |
40 | }; | |
41 | static const char variax_request_model2[] = { | |
42 | 0xf0, 0x00, 0x01, 0x0c, 0x07, 0x00, 0x3c, 0x00, | |
43 | 0x02, 0x00, 0x00, 0x00, 0x00, 0x03, 0x07, 0x03, | |
44 | 0x00, 0x00, 0x00, 0xf7 | |
45 | }; | |
46 | ||
47 | ||
48 | /* | |
49 | Decode data transmitted by workbench. | |
50 | */ | |
9cd57f77 GKH |
51 | static void variax_decode(const unsigned char *raw_data, unsigned char *data, |
52 | int raw_size) | |
705ececd | 53 | { |
9cd57f77 | 54 | for (; raw_size > 0; raw_size -= 6) { |
705ececd MG |
55 | data[2] = raw_data[0] | (raw_data[1] << 4); |
56 | data[1] = raw_data[2] | (raw_data[3] << 4); | |
57 | data[0] = raw_data[4] | (raw_data[5] << 4); | |
58 | raw_data += 6; | |
59 | data += 3; | |
60 | } | |
61 | } | |
62 | ||
63 | static void variax_activate_timeout(unsigned long arg) | |
64 | { | |
65 | struct usb_line6_variax *variax = (struct usb_line6_variax *)arg; | |
66 | variax->buffer_activate[VARIAX_OFFSET_ACTIVATE] = 1; | |
9cd57f77 GKH |
67 | line6_send_raw_message_async(&variax->line6, variax->buffer_activate, |
68 | sizeof(variax_activate)); | |
705ececd MG |
69 | } |
70 | ||
71 | /* | |
72 | Send an asynchronous activation request after a given interval. | |
73 | */ | |
9cd57f77 GKH |
74 | static void variax_activate_delayed(struct usb_line6_variax *variax, |
75 | int seconds) | |
705ececd MG |
76 | { |
77 | variax->activate_timer.expires = jiffies + seconds * HZ; | |
78 | variax->activate_timer.function = variax_activate_timeout; | |
79 | variax->activate_timer.data = (unsigned long)variax; | |
80 | add_timer(&variax->activate_timer); | |
81 | } | |
82 | ||
83 | static void variax_startup_timeout(unsigned long arg) | |
84 | { | |
85 | struct usb_line6_variax *variax = (struct usb_line6_variax *)arg; | |
86 | ||
9cd57f77 | 87 | if (variax->dumpreq.ok) |
705ececd MG |
88 | return; |
89 | ||
90 | line6_dump_request_async(&variax->dumpreq, &variax->line6, 0); | |
9cd57f77 GKH |
91 | line6_startup_delayed(&variax->dumpreq, 1, variax_startup_timeout, |
92 | variax); | |
705ececd MG |
93 | } |
94 | ||
95 | /* | |
96 | Process a completely received message. | |
97 | */ | |
98 | void variax_process_message(struct usb_line6_variax *variax) | |
99 | { | |
100 | const unsigned char *buf = variax->line6.buffer_message; | |
101 | ||
9cd57f77 | 102 | switch (buf[0]) { |
705ececd | 103 | case LINE6_PARAM_CHANGE | LINE6_CHANNEL_HOST: |
9cd57f77 | 104 | switch (buf[1]) { |
705ececd MG |
105 | case VARIAXMIDI_volume: |
106 | variax->volume = buf[2]; | |
107 | break; | |
108 | ||
109 | case VARIAXMIDI_tone: | |
110 | variax->tone = buf[2]; | |
111 | } | |
112 | ||
113 | break; | |
114 | ||
115 | case LINE6_PROGRAM_CHANGE | LINE6_CHANNEL_DEVICE: | |
116 | case LINE6_PROGRAM_CHANGE | LINE6_CHANNEL_HOST: | |
117 | variax->model = buf[1]; | |
118 | line6_dump_request_async(&variax->dumpreq, &variax->line6, 0); | |
119 | break; | |
120 | ||
121 | case LINE6_RESET: | |
122 | dev_info(variax->line6.ifcdev, "VARIAX reset\n"); | |
123 | variax_activate_delayed(variax, VARIAX_ACTIVATE_DELAY); | |
124 | break; | |
125 | ||
126 | case LINE6_SYSEX_BEGIN: | |
9cd57f77 GKH |
127 | if (memcmp(buf + 1, variax_request_model1 + 1, |
128 | VARIAX_MODEL_HEADER_LENGTH - 1) == 0) { | |
129 | if (variax->line6.message_length == | |
130 | VARIAX_MODEL_MESSAGE_LENGTH) { | |
131 | switch (variax->dumpreq.in_progress) { | |
705ececd MG |
132 | case VARIAX_DUMP_PASS1: |
133 | variax_decode(buf + VARIAX_MODEL_HEADER_LENGTH, (unsigned char *)&variax->model_data, | |
134 | (sizeof(variax->model_data.name) + sizeof(variax->model_data.control) / 2) * 2); | |
135 | line6_dump_request_async(&variax->dumpreq, &variax->line6, 1); | |
136 | line6_dump_started(&variax->dumpreq, VARIAX_DUMP_PASS2); | |
137 | break; | |
138 | ||
139 | case VARIAX_DUMP_PASS2: | |
140 | /* model name is transmitted twice, so skip it here: */ | |
141 | variax_decode(buf + VARIAX_MODEL_HEADER_LENGTH, | |
9cd57f77 GKH |
142 | (unsigned char *)&variax->model_data.control + sizeof(variax->model_data.control) / 2, |
143 | sizeof(variax->model_data.control) / 2 * 2); | |
705ececd MG |
144 | variax->dumpreq.ok = 1; |
145 | line6_dump_request_async(&variax->dumpreq, &variax->line6, 2); | |
146 | line6_dump_started(&variax->dumpreq, VARIAX_DUMP_PASS3); | |
147 | } | |
9cd57f77 | 148 | } else { |
705ececd MG |
149 | DEBUG_MESSAGES(dev_err(variax->line6.ifcdev, "illegal length %d of model data\n", variax->line6.message_length)); |
150 | line6_dump_finished(&variax->dumpreq); | |
151 | } | |
9cd57f77 GKH |
152 | } else if (memcmp(buf + 1, variax_request_bank + 1, |
153 | sizeof(variax_request_bank) - 2) == 0) { | |
154 | memcpy(variax->bank, | |
155 | buf + sizeof(variax_request_bank) - 1, | |
156 | sizeof(variax->bank)); | |
705ececd MG |
157 | variax->dumpreq.ok = 1; |
158 | line6_dump_finished(&variax->dumpreq); | |
159 | } | |
160 | ||
161 | break; | |
162 | ||
163 | case LINE6_SYSEX_END: | |
164 | break; | |
165 | ||
166 | default: | |
167 | DEBUG_MESSAGES(dev_err(variax->line6.ifcdev, "Variax: unknown message %02X\n", buf[0])); | |
168 | } | |
169 | } | |
170 | ||
171 | /* | |
172 | "read" request on "volume" special file. | |
173 | */ | |
77491e52 GKH |
174 | static ssize_t variax_get_volume(struct device *dev, |
175 | struct device_attribute *attr, char *buf) | |
705ececd MG |
176 | { |
177 | struct usb_line6_variax *variax = usb_get_intfdata(to_usb_interface(dev)); | |
178 | return sprintf(buf, "%d\n", variax->volume); | |
179 | } | |
180 | ||
181 | /* | |
182 | "write" request on "volume" special file. | |
183 | */ | |
77491e52 GKH |
184 | static ssize_t variax_set_volume(struct device *dev, |
185 | struct device_attribute *attr, | |
186 | const char *buf, size_t count) | |
705ececd MG |
187 | { |
188 | struct usb_line6_variax *variax = usb_get_intfdata(to_usb_interface(dev)); | |
c0e6e7c1 SB |
189 | unsigned long value; |
190 | int ret; | |
191 | ||
192 | ret = strict_strtoul(buf, 10, &value); | |
193 | if (ret) | |
194 | return ret; | |
705ececd | 195 | |
9cd57f77 GKH |
196 | if (line6_transmit_parameter(&variax->line6, VARIAXMIDI_volume, |
197 | value) == 0) | |
705ececd MG |
198 | variax->volume = value; |
199 | ||
200 | return count; | |
201 | } | |
202 | ||
203 | /* | |
204 | "read" request on "model" special file. | |
205 | */ | |
77491e52 GKH |
206 | static ssize_t variax_get_model(struct device *dev, |
207 | struct device_attribute *attr, char *buf) | |
705ececd MG |
208 | { |
209 | struct usb_line6_variax *variax = usb_get_intfdata(to_usb_interface(dev)); | |
210 | return sprintf(buf, "%d\n", variax->model); | |
211 | } | |
212 | ||
213 | /* | |
214 | "write" request on "model" special file. | |
215 | */ | |
77491e52 GKH |
216 | static ssize_t variax_set_model(struct device *dev, |
217 | struct device_attribute *attr, | |
218 | const char *buf, size_t count) | |
705ececd | 219 | { |
9cd57f77 | 220 | struct usb_line6_variax *variax = usb_get_intfdata(to_usb_interface(dev)); |
c0e6e7c1 SB |
221 | unsigned long value; |
222 | int ret; | |
223 | ||
224 | ret = strict_strtoul(buf, 10, &value); | |
225 | if (ret) | |
226 | return ret; | |
705ececd | 227 | |
9cd57f77 | 228 | if (line6_send_program(&variax->line6, value) == 0) |
705ececd MG |
229 | variax->model = value; |
230 | ||
231 | return count; | |
232 | } | |
233 | ||
234 | /* | |
235 | "read" request on "active" special file. | |
236 | */ | |
77491e52 GKH |
237 | static ssize_t variax_get_active(struct device *dev, |
238 | struct device_attribute *attr, char *buf) | |
705ececd MG |
239 | { |
240 | struct usb_line6_variax *variax = usb_get_intfdata(to_usb_interface(dev)); | |
241 | return sprintf(buf, "%d\n", variax->buffer_activate[VARIAX_OFFSET_ACTIVATE]); | |
242 | } | |
243 | ||
244 | /* | |
245 | "write" request on "active" special file. | |
246 | */ | |
77491e52 GKH |
247 | static ssize_t variax_set_active(struct device *dev, |
248 | struct device_attribute *attr, | |
249 | const char *buf, size_t count) | |
705ececd MG |
250 | { |
251 | struct usb_line6_variax *variax = usb_get_intfdata(to_usb_interface(dev)); | |
c0e6e7c1 SB |
252 | unsigned long value; |
253 | int ret; | |
254 | ||
255 | ret = strict_strtoul(buf, 10, &value); | |
256 | if (ret) | |
257 | return ret; | |
258 | ||
0f7cf003 | 259 | variax->buffer_activate[VARIAX_OFFSET_ACTIVATE] = value ? 1 : 0; |
9cd57f77 GKH |
260 | line6_send_raw_message_async(&variax->line6, variax->buffer_activate, |
261 | sizeof(variax_activate)); | |
705ececd MG |
262 | return count; |
263 | } | |
264 | ||
265 | /* | |
266 | "read" request on "tone" special file. | |
267 | */ | |
77491e52 GKH |
268 | static ssize_t variax_get_tone(struct device *dev, |
269 | struct device_attribute *attr, char *buf) | |
705ececd MG |
270 | { |
271 | struct usb_line6_variax *variax = usb_get_intfdata(to_usb_interface(dev)); | |
272 | return sprintf(buf, "%d\n", variax->tone); | |
273 | } | |
274 | ||
275 | /* | |
276 | "write" request on "tone" special file. | |
277 | */ | |
77491e52 GKH |
278 | static ssize_t variax_set_tone(struct device *dev, |
279 | struct device_attribute *attr, | |
280 | const char *buf, size_t count) | |
705ececd MG |
281 | { |
282 | struct usb_line6_variax *variax = usb_get_intfdata(to_usb_interface(dev)); | |
c0e6e7c1 SB |
283 | unsigned long value; |
284 | int ret; | |
285 | ||
286 | ret = strict_strtoul(buf, 10, &value); | |
287 | if (ret) | |
288 | return ret; | |
705ececd | 289 | |
9cd57f77 GKH |
290 | if (line6_transmit_parameter(&variax->line6, VARIAXMIDI_tone, |
291 | value) == 0) | |
705ececd MG |
292 | variax->tone = value; |
293 | ||
294 | return count; | |
295 | } | |
296 | ||
297 | static ssize_t get_string(char *buf, const char *data, int length) | |
298 | { | |
299 | int i; | |
300 | memcpy(buf, data, length); | |
301 | ||
9cd57f77 | 302 | for (i = length; i--;) { |
705ececd MG |
303 | char c = buf[i]; |
304 | ||
9cd57f77 | 305 | if ((c != 0) && (c != ' ')) |
705ececd MG |
306 | break; |
307 | } | |
308 | ||
309 | buf[i + 1] = '\n'; | |
310 | return i + 2; | |
311 | } | |
312 | ||
313 | /* | |
314 | "read" request on "name" special file. | |
315 | */ | |
77491e52 GKH |
316 | static ssize_t variax_get_name(struct device *dev, |
317 | struct device_attribute *attr, char *buf) | |
705ececd MG |
318 | { |
319 | struct usb_line6_variax *variax = usb_get_intfdata(to_usb_interface(dev)); | |
320 | line6_wait_dump(&variax->dumpreq, 0); | |
9cd57f77 GKH |
321 | return get_string(buf, variax->model_data.name, |
322 | sizeof(variax->model_data.name)); | |
705ececd MG |
323 | } |
324 | ||
325 | /* | |
326 | "read" request on "bank" special file. | |
327 | */ | |
77491e52 GKH |
328 | static ssize_t variax_get_bank(struct device *dev, |
329 | struct device_attribute *attr, char *buf) | |
705ececd MG |
330 | { |
331 | struct usb_line6_variax *variax = usb_get_intfdata(to_usb_interface(dev)); | |
332 | line6_wait_dump(&variax->dumpreq, 0); | |
333 | return get_string(buf, variax->bank, sizeof(variax->bank)); | |
334 | } | |
335 | ||
336 | /* | |
337 | "read" request on "dump" special file. | |
338 | */ | |
77491e52 GKH |
339 | static ssize_t variax_get_dump(struct device *dev, |
340 | struct device_attribute *attr, char *buf) | |
705ececd MG |
341 | { |
342 | struct usb_line6_variax *variax = usb_get_intfdata(to_usb_interface(dev)); | |
343 | int retval; | |
344 | retval = line6_wait_dump(&variax->dumpreq, 0); | |
9cd57f77 GKH |
345 | if (retval < 0) |
346 | return retval; | |
347 | memcpy(buf, &variax->model_data.control, | |
348 | sizeof(variax->model_data.control)); | |
705ececd MG |
349 | return sizeof(variax->model_data.control); |
350 | } | |
351 | ||
352 | #if CREATE_RAW_FILE | |
353 | ||
354 | /* | |
355 | "write" request on "raw" special file. | |
356 | */ | |
77491e52 GKH |
357 | static ssize_t variax_set_raw2(struct device *dev, |
358 | struct device_attribute *attr, | |
359 | const char *buf, size_t count) | |
705ececd MG |
360 | { |
361 | struct usb_line6_variax *variax = usb_get_intfdata(to_usb_interface(dev)); | |
362 | int size; | |
363 | int i; | |
364 | char *sysex; | |
365 | ||
366 | count -= count % 3; | |
367 | size = count * 2; | |
368 | sysex = variax_alloc_sysex_buffer(variax, VARIAX_SYSEX_PARAM, size); | |
369 | ||
9cd57f77 | 370 | if (!sysex) |
705ececd MG |
371 | return 0; |
372 | ||
9cd57f77 | 373 | for (i = 0; i < count; i += 3) { |
705ececd MG |
374 | const unsigned char *p1 = buf + i; |
375 | char *p2 = sysex + SYSEX_DATA_OFS + i * 2; | |
376 | p2[0] = p1[2] & 0x0f; | |
377 | p2[1] = p1[2] >> 4; | |
378 | p2[2] = p1[1] & 0x0f; | |
379 | p2[3] = p1[1] >> 4; | |
380 | p2[4] = p1[0] & 0x0f; | |
381 | p2[5] = p1[0] >> 4; | |
382 | } | |
383 | ||
384 | line6_send_sysex_message(&variax->line6, sysex, size); | |
385 | kfree(sysex); | |
386 | return count; | |
387 | } | |
388 | ||
389 | #endif | |
390 | ||
391 | /* Variax workbench special files: */ | |
392 | static DEVICE_ATTR(model, S_IWUGO | S_IRUGO, variax_get_model, variax_set_model); | |
393 | static DEVICE_ATTR(volume, S_IWUGO | S_IRUGO, variax_get_volume, variax_set_volume); | |
394 | static DEVICE_ATTR(tone, S_IWUGO | S_IRUGO, variax_get_tone, variax_set_tone); | |
395 | static DEVICE_ATTR(name, S_IRUGO, variax_get_name, line6_nop_write); | |
396 | static DEVICE_ATTR(bank, S_IRUGO, variax_get_bank, line6_nop_write); | |
397 | static DEVICE_ATTR(dump, S_IRUGO, variax_get_dump, line6_nop_write); | |
398 | static DEVICE_ATTR(active, S_IWUGO | S_IRUGO, variax_get_active, variax_set_active); | |
399 | ||
400 | #if CREATE_RAW_FILE | |
401 | static DEVICE_ATTR(raw, S_IWUGO, line6_nop_read, line6_set_raw); | |
402 | static DEVICE_ATTR(raw2, S_IWUGO, line6_nop_read, variax_set_raw2); | |
403 | #endif | |
404 | ||
405 | ||
406 | /* | |
407 | Variax destructor. | |
408 | */ | |
409 | static void variax_destruct(struct usb_interface *interface) | |
410 | { | |
411 | struct usb_line6_variax *variax = usb_get_intfdata(interface); | |
412 | struct usb_line6 *line6; | |
413 | ||
9cd57f77 GKH |
414 | if (variax == NULL) |
415 | return; | |
705ececd | 416 | line6 = &variax->line6; |
9cd57f77 GKH |
417 | if (line6 == NULL) |
418 | return; | |
705ececd MG |
419 | line6_cleanup_audio(line6); |
420 | ||
421 | /* free dump request data: */ | |
422 | line6_dumpreq_destructbuf(&variax->dumpreq, 2); | |
423 | line6_dumpreq_destructbuf(&variax->dumpreq, 1); | |
424 | line6_dumpreq_destruct(&variax->dumpreq); | |
425 | ||
9cd57f77 | 426 | kfree(variax->buffer_activate); |
705ececd MG |
427 | del_timer_sync(&variax->activate_timer); |
428 | } | |
429 | ||
430 | /* | |
431 | Create sysfs entries. | |
432 | */ | |
b702ed25 | 433 | static int variax_create_files2(struct device *dev) |
705ececd MG |
434 | { |
435 | int err; | |
436 | CHECK_RETURN(device_create_file(dev, &dev_attr_model)); | |
437 | CHECK_RETURN(device_create_file(dev, &dev_attr_volume)); | |
438 | CHECK_RETURN(device_create_file(dev, &dev_attr_tone)); | |
439 | CHECK_RETURN(device_create_file(dev, &dev_attr_name)); | |
440 | CHECK_RETURN(device_create_file(dev, &dev_attr_bank)); | |
441 | CHECK_RETURN(device_create_file(dev, &dev_attr_dump)); | |
442 | CHECK_RETURN(device_create_file(dev, &dev_attr_active)); | |
443 | #if CREATE_RAW_FILE | |
444 | CHECK_RETURN(device_create_file(dev, &dev_attr_raw)); | |
445 | CHECK_RETURN(device_create_file(dev, &dev_attr_raw2)); | |
446 | #endif | |
447 | return 0; | |
448 | } | |
449 | ||
450 | /* | |
451 | Init workbench device. | |
452 | */ | |
9cd57f77 GKH |
453 | int variax_init(struct usb_interface *interface, |
454 | struct usb_line6_variax *variax) | |
705ececd MG |
455 | { |
456 | int err; | |
457 | ||
9cd57f77 GKH |
458 | if ((interface == NULL) || (variax == NULL)) |
459 | return -ENODEV; | |
705ececd MG |
460 | |
461 | /* initialize USB buffers: */ | |
9cd57f77 GKH |
462 | err = line6_dumpreq_init(&variax->dumpreq, variax_request_model1, |
463 | sizeof(variax_request_model1)); | |
705ececd | 464 | |
9cd57f77 | 465 | if (err < 0) { |
705ececd MG |
466 | dev_err(&interface->dev, "Out of memory\n"); |
467 | variax_destruct(interface); | |
468 | return err; | |
469 | } | |
470 | ||
9cd57f77 GKH |
471 | err = line6_dumpreq_initbuf(&variax->dumpreq, variax_request_model2, |
472 | sizeof(variax_request_model2), 1); | |
705ececd | 473 | |
9cd57f77 | 474 | if (err < 0) { |
705ececd MG |
475 | dev_err(&interface->dev, "Out of memory\n"); |
476 | variax_destruct(interface); | |
477 | return err; | |
478 | } | |
479 | ||
9cd57f77 GKH |
480 | err = line6_dumpreq_initbuf(&variax->dumpreq, variax_request_bank, |
481 | sizeof(variax_request_bank), 2); | |
705ececd | 482 | |
9cd57f77 | 483 | if (err < 0) { |
705ececd MG |
484 | dev_err(&interface->dev, "Out of memory\n"); |
485 | variax_destruct(interface); | |
486 | return err; | |
487 | } | |
488 | ||
489 | variax->buffer_activate = kmalloc(sizeof(variax_activate), GFP_KERNEL); | |
490 | ||
9cd57f77 | 491 | if (variax->buffer_activate == NULL) { |
705ececd MG |
492 | dev_err(&interface->dev, "Out of memory\n"); |
493 | variax_destruct(interface); | |
494 | return -ENOMEM; | |
495 | } | |
496 | ||
9cd57f77 GKH |
497 | memcpy(variax->buffer_activate, variax_activate, |
498 | sizeof(variax_activate)); | |
705ececd MG |
499 | init_timer(&variax->activate_timer); |
500 | ||
501 | /* create sysfs entries: */ | |
9cd57f77 GKH |
502 | err = variax_create_files(0, 0, &interface->dev); |
503 | if (err < 0) { | |
705ececd MG |
504 | variax_destruct(interface); |
505 | return err; | |
506 | } | |
507 | ||
9cd57f77 GKH |
508 | err = variax_create_files2(&interface->dev); |
509 | if (err < 0) { | |
705ececd MG |
510 | variax_destruct(interface); |
511 | return err; | |
512 | } | |
513 | ||
514 | /* initialize audio system: */ | |
9cd57f77 GKH |
515 | err = line6_init_audio(&variax->line6); |
516 | if (err < 0) { | |
705ececd MG |
517 | variax_destruct(interface); |
518 | return err; | |
519 | } | |
520 | ||
521 | /* initialize MIDI subsystem: */ | |
9cd57f77 GKH |
522 | err = line6_init_midi(&variax->line6); |
523 | if (err < 0) { | |
705ececd MG |
524 | variax_destruct(interface); |
525 | return err; | |
526 | } | |
527 | ||
528 | /* register audio system: */ | |
9cd57f77 GKH |
529 | err = line6_register_audio(&variax->line6); |
530 | if (err < 0) { | |
705ececd MG |
531 | variax_destruct(interface); |
532 | return err; | |
533 | } | |
534 | ||
535 | variax_activate_delayed(variax, VARIAX_ACTIVATE_DELAY); | |
9cd57f77 GKH |
536 | line6_startup_delayed(&variax->dumpreq, VARIAX_STARTUP_DELAY, |
537 | variax_startup_timeout, variax); | |
705ececd MG |
538 | return 0; |
539 | } | |
540 | ||
541 | /* | |
542 | Workbench device disconnected. | |
543 | */ | |
544 | void variax_disconnect(struct usb_interface *interface) | |
545 | { | |
546 | struct device *dev; | |
547 | ||
9cd57f77 GKH |
548 | if (interface == NULL) |
549 | return; | |
705ececd MG |
550 | dev = &interface->dev; |
551 | ||
9cd57f77 | 552 | if (dev != NULL) { |
705ececd MG |
553 | /* remove sysfs entries: */ |
554 | variax_remove_files(0, 0, dev); | |
555 | device_remove_file(dev, &dev_attr_model); | |
556 | device_remove_file(dev, &dev_attr_volume); | |
557 | device_remove_file(dev, &dev_attr_tone); | |
558 | device_remove_file(dev, &dev_attr_name); | |
559 | device_remove_file(dev, &dev_attr_bank); | |
560 | device_remove_file(dev, &dev_attr_dump); | |
561 | device_remove_file(dev, &dev_attr_active); | |
562 | #if CREATE_RAW_FILE | |
563 | device_remove_file(dev, &dev_attr_raw); | |
564 | device_remove_file(dev, &dev_attr_raw2); | |
565 | #endif | |
566 | } | |
567 | ||
568 | variax_destruct(interface); | |
569 | } |