12 #include <linux/slab.h>
19 #define VARIAX_SYSEX_CODE 7
20 #define VARIAX_SYSEX_PARAM 0x3b
21 #define VARIAX_SYSEX_ACTIVATE 0x2a
22 #define VARIAX_MODEL_HEADER_LENGTH 7
23 #define VARIAX_MODEL_MESSAGE_LENGTH 199
24 #define VARIAX_OFFSET_ACTIVATE 7
30 static const char variax_init_model[] = {
31 0xf0, 0x00, 0x01, 0x0c, 0x07, 0x00, 0x69, 0x02,
39 static const char variax_init_version[] = {
40 0xf0, 0x7e, 0x7f, 0x06, 0x02, 0x00, 0x01, 0x0c,
41 0x07, 0x00, 0x00, 0x00
47 static const char variax_init_done[] = {
48 0xf0, 0x00, 0x01, 0x0c, 0x07, 0x00, 0x6b
51 static const char variax_activate[] = {
52 0xf0, 0x00, 0x01, 0x0c, 0x07, 0x00, 0x2a, 0x01,
56 static const char variax_request_bank[] = {
57 0xf0, 0x00, 0x01, 0x0c, 0x07, 0x00, 0x6d, 0xf7
60 static const char variax_request_model1[] = {
61 0xf0, 0x00, 0x01, 0x0c, 0x07, 0x00, 0x3c, 0x00,
62 0x02, 0x00, 0x00, 0x00, 0x00, 0x03, 0x05, 0x03,
63 0x00, 0x00, 0x00, 0xf7
66 static const char variax_request_model2[] = {
67 0xf0, 0x00, 0x01, 0x0c, 0x07, 0x00, 0x3c, 0x00,
68 0x02, 0x00, 0x00, 0x00, 0x00, 0x03, 0x07, 0x03,
69 0x00, 0x00, 0x00, 0xf7
73 static int variax_create_files2(
struct device *
dev);
74 static void variax_startup2(
unsigned long data);
75 static void variax_startup4(
unsigned long data);
76 static void variax_startup5(
unsigned long data);
81 static void variax_decode(
const unsigned char *raw_data,
unsigned char *
data,
84 for (; raw_size > 0; raw_size -= 6) {
85 data[2] = raw_data[0] | (raw_data[1] << 4);
86 data[1] = raw_data[2] | (raw_data[3] << 4);
87 data[0] = raw_data[4] | (raw_data[5] << 4);
97 sizeof(variax_activate));
113 variax_startup2, (
unsigned long)variax);
116 static void variax_startup2(
unsigned long data)
127 variax_startup2, (
unsigned long)variax);
139 variax_startup4, (
unsigned long)variax);
142 static void variax_startup4(
unsigned long data)
149 variax_activate_async(variax, 1);
151 variax_startup5, (
unsigned long)variax);
154 static void variax_startup5(
unsigned long data)
188 variax_create_files2(line6->
ifcdev);
196 const unsigned char *
buf = variax->
line6.buffer_message;
206 variax->
tone = buf[2];
213 variax->
model = buf[1];
223 if (
memcmp(buf + 1, variax_request_model1 + 1,
225 if (variax->
line6.message_length ==
227 switch (variax->
dumpreq.in_progress) {
264 (variax->
line6.ifcdev,
265 "illegal length %d of model data\n",
266 variax->
line6.message_length));
269 }
else if (
memcmp(buf + 1, variax_request_bank + 1,
270 sizeof(variax_request_bank) - 2) == 0) {
272 buf +
sizeof(variax_request_bank) - 1,
273 sizeof(variax->
bank));
275 variax_startup6(variax);
276 }
else if (
memcmp(buf + 1, variax_init_model + 1,
277 sizeof(variax_init_model) - 1) == 0) {
279 buf +
sizeof(variax_init_model),
281 }
else if (
memcmp(buf + 1, variax_init_version + 1,
282 sizeof(variax_init_version) - 1) == 0) {
283 variax_startup3(variax);
284 }
else if (
memcmp(buf + 1, variax_init_done + 1,
285 sizeof(variax_init_done) - 1) == 0) {
287 variax_startup4((
unsigned long)variax);
297 (variax->
line6.ifcdev,
298 "Variax: unknown message %02X\n", buf[0]));
309 usb_get_intfdata(to_usb_interface(dev));
318 const char *buf,
size_t count)
321 usb_get_intfdata(to_usb_interface(dev));
343 usb_get_intfdata(to_usb_interface(dev));
352 const char *buf,
size_t count)
355 usb_get_intfdata(to_usb_interface(dev));
376 usb_get_intfdata(to_usb_interface(dev));
386 const char *buf,
size_t count)
389 usb_get_intfdata(to_usb_interface(dev));
397 variax_activate_async(variax, value ? 1 : 0);
408 usb_get_intfdata(to_usb_interface(dev));
417 const char *buf,
size_t count)
420 usb_get_intfdata(to_usb_interface(dev));
435 static ssize_t get_string(
char *buf,
const char *data,
int length)
438 memcpy(buf, data, length);
440 for (i = length; i--;) {
443 if ((c != 0) && (c !=
' '))
458 usb_get_intfdata(to_usb_interface(dev));
460 return get_string(buf, variax->
model_data.name,
471 usb_get_intfdata(to_usb_interface(dev));
473 return get_string(buf, variax->
bank,
sizeof(variax->
bank));
483 usb_get_intfdata(to_usb_interface(dev));
500 usb_get_intfdata(to_usb_interface(dev));
504 #ifdef CONFIG_LINE6_USB_RAW
518 const char *buf,
size_t count)
521 usb_get_intfdata(to_usb_interface(dev));
533 for (i = 0; i <
count; i += 3) {
534 const unsigned char *
p1 = buf +
i;
535 char *p2 = sysex + SYSEX_DATA_OFS + i * 2;
536 p2[0] = p1[2] & 0x0f;
538 p2[2] = p1[1] & 0x0f;
540 p2[4] = p1[0] & 0x0f;
564 #ifdef CONFIG_LINE6_USB_RAW
595 static int variax_create_files2(
struct device *dev)
606 #ifdef CONFIG_LINE6_USB_RAW
625 if ((interface ==
NULL) || (variax ==
NULL))
630 sizeof(variax_request_model1));
633 dev_err(&interface->dev,
"Out of memory\n");
638 sizeof(variax_request_model2), 1);
641 dev_err(&interface->dev,
"Out of memory\n");
646 sizeof(variax_request_bank), 2);
649 dev_err(&interface->dev,
"Out of memory\n");
657 dev_err(&interface->dev,
"Out of memory\n");
672 variax_startup1(variax);
682 int err = variax_try_init(interface, variax);
685 variax_destruct(interface);
697 if (interface ==
NULL)
699 dev = &interface->dev;
712 #ifdef CONFIG_LINE6_USB_RAW
718 variax_destruct(interface);