12 #include <linux/slab.h>
13 #include <linux/wait.h>
23 #define POD_SYSEX_CODE 3
24 #define POD_BYTES_PER_FRAME 6
74 .snd_line6_playback_hw = {
90 .buffer_bytes_max = 60000,
91 .period_bytes_min = 64,
92 .period_bytes_max = 8192,
110 .buffer_bytes_max = 60000,
111 .period_bytes_min = 64,
112 .period_bytes_max = 8192,
114 .periods_max = 1024},
117 .rats = &pod_ratden},
121 static const char pod_request_channel[] = {
122 0xf0, 0x00, 0x01, 0x0c, 0x03, 0x75, 0xf7
125 static const char pod_version_header[] = {
126 0xf2, 0x7e, 0x7f, 0x06, 0x02
130 static void pod_startup2(
unsigned long data);
137 static void pod_mark_batch_all_dirty(
struct usb_line6_pod *pod)
163 sysex[SYSEX_DATA_OFS] = 5;
167 pod_mark_batch_all_dirty(pod);
196 const unsigned char *
buf = pod->
line6.buffer_message;
199 switch (buf[0] & 0xf0) {
212 pod_store_parameter(pod, buf[1], buf[2]);
238 if (pod->
line6.message_length ==
240 switch (pod->
dumpreq.in_progress) {
244 pod_mark_batch_all_dirty(pod);
258 "unknown dump code %02X\n",
260 dumpreq.in_progress));
268 "wrong size of channel dump message (%d instead of %d)\n",
270 line6.message_length,
279 ((
int)buf[7] << 12) | ((
int)buf[8]
281 ((
int)buf[9] << 4) | (
int)buf[10];
283 #define PROCESS_SYSTEM_PARAM(x) \
285 pod->x.value = value; \
286 wake_up(&pod->x.wait); \
302 #undef PROCESS_SYSTEM_PARAM
308 "unknown tuner/system response %02X\n",
320 pod_save_button_pressed(pod, buf[6], buf[7]);
334 "message %02X not yet implemented\n",
341 "unknown sysex message %02X\n",
346 (buf, pod_version_header,
347 sizeof(pod_version_header)) == 0) {
349 buf[13] * 100 + buf[14] * 10 + buf[15];
351 ((
int)buf[8] << 16) | ((
int)buf[9] << 8) | (
int)
357 "unknown sysex header\n"));
367 "POD: unknown message %02X\n", buf[0]));
425 pod_store_parameter(pod, param, value);
434 static int pod_resolve(
const char *
buf,
short block0,
short block1,
445 block = (value < 0x40) ? block0 : block1;
447 location[0] = block >> 7;
448 location[1] = value | (block & 0x7f);
456 size_t count,
short block0,
short block1)
467 sysex[SYSEX_DATA_OFS] = 5;
468 ret = pod_resolve(buf, block0, block1, sysex + SYSEX_DATA_OFS + 1);
486 static ssize_t pod_send_retrieve_command(
struct device *dev,
const char *buf,
487 size_t count,
short block0,
499 ret = pod_resolve(buf, block0, block1, sysex + SYSEX_DATA_OFS);
504 sysex[SYSEX_DATA_OFS + 2] = 0;
505 sysex[SYSEX_DATA_OFS + 3] = 0;
525 char *last_non_space =
buf;
531 for (p1 = str, p2 = buf; *
p1; ++
p1, ++p2) {
539 *(last_non_space + 1) =
'\n';
540 return last_non_space - buf + 2;
559 const char *buf,
size_t count)
570 pod_send_channel(pod, value);
594 return get_name_generic(pod,
618 const char *buf,
size_t count)
625 "data block must be exactly %d bytes\n",
637 static bool pod_is_tuner(
int code)
649 static int pod_get_system_param_int(
struct usb_line6_pod *pod,
int *value,
653 static const int size = 1;
657 && pod_is_tuner(code))
667 sysex[SYSEX_DATA_OFS] =
code;
679 *value = sign ? (
int)(
signed short)param->
value : (
int)(
unsigned short)
697 retval = pod_get_system_param_int(pod, &value, code, param, sign);
702 return sprintf(buf,
"%d\n", value);
709 static int pod_set_system_param_int(
struct usb_line6_pod *pod,
int value,
713 static const int size = 5;
716 && pod_is_tuner(code))
723 sysex[SYSEX_DATA_OFS] =
code;
724 sysex[SYSEX_DATA_OFS + 1] = (value >> 12) & 0x0f;
725 sysex[SYSEX_DATA_OFS + 2] = (value >> 8) & 0x0f;
726 sysex[SYSEX_DATA_OFS + 3] = (value >> 4) & 0x0f;
727 sysex[SYSEX_DATA_OFS + 4] = (
value) & 0x0f;
738 const char *buf,
int count,
int code,
743 retval = pod_set_system_param_int(pod, value, code);
744 return (retval < 0) ? retval :
count;
767 const char *buf,
size_t count)
774 "data block must be exactly %d bytes\n",
788 const char *buf,
size_t count)
806 const char *buf,
size_t count)
808 return pod_send_store_command(dev, buf, count, 0x0000, 0x00c0);
814 static ssize_t pod_set_store_effects_setup(
struct device *dev,
816 const char *buf,
size_t count)
818 return pod_send_store_command(dev, buf, count, 0x0080, 0x0080);
826 const char *buf,
size_t count)
828 return pod_send_store_command(dev, buf, count, 0x0040, 0x0100);
836 const char *buf,
size_t count)
838 return pod_send_retrieve_command(dev, buf, count, 0x0000, 0x00c0);
844 static ssize_t pod_set_retrieve_effects_setup(
struct device *dev,
846 const char *buf,
size_t count)
848 return pod_send_retrieve_command(dev, buf, count, 0x0080, 0x0080);
854 static ssize_t pod_set_retrieve_amp_setup(
struct device *dev,
856 const char *buf,
size_t count)
858 return pod_send_retrieve_command(dev, buf, count, 0x0040, 0x0100);
869 buf[0] = pod->
dirty ?
'1' :
'0';
891 const char *buf,
size_t count)
969 static void pod_startup2(
unsigned long data)
1022 #define POD_GET_SYSTEM_PARAM(code, sign) \
1023 static ssize_t pod_get_ ## code(struct device *dev, \
1024 struct device_attribute *attr, char *buf) \
1026 struct usb_interface *interface = to_usb_interface(dev); \
1027 struct usb_line6_pod *pod = usb_get_intfdata(interface); \
1028 return pod_get_system_param_string(pod, buf, POD_ ## code, \
1029 &pod->code, sign); \
1032 #define POD_GET_SET_SYSTEM_PARAM(code, mask, sign) \
1033 POD_GET_SYSTEM_PARAM(code, sign) \
1034 static ssize_t pod_set_ ## code(struct device *dev, \
1035 struct device_attribute *attr, \
1036 const char *buf, size_t count) \
1038 struct usb_interface *interface = to_usb_interface(dev); \
1039 struct usb_line6_pod *pod = usb_get_intfdata(interface); \
1040 return pod_set_system_param_string(pod, buf, count, POD_ ## code, mask); \
1050 #undef GET_SET_SYSTEM_PARAM
1051 #undef GET_SYSTEM_PARAM
1066 pod_get_midi_postprocess, pod_set_midi_postprocess);
1068 pod_set_monitor_level);
1072 pod_set_retrieve_amp_setup);
1074 pod_set_retrieve_channel);
1076 pod_set_retrieve_effects_setup);
1082 pod_set_store_amp_setup);
1084 pod_set_store_channel);
1086 pod_set_store_effects_setup);
1088 pod_set_tuner_freq);
1090 pod_set_tuner_mute);
1094 #ifdef CONFIG_LINE6_USB_RAW
1099 static int snd_pod_control_monitor_info(
struct snd_kcontrol *kcontrol,
1110 static int snd_pod_control_monitor_get(
struct snd_kcontrol *kcontrol,
1120 static int snd_pod_control_monitor_put(
struct snd_kcontrol *kcontrol,
1130 pod_set_system_param_int(pod, ucontrol->
value.integer.value[0],
1138 .name =
"Monitor Playback Volume",
1141 .info = snd_pod_control_monitor_info,
1142 .get = snd_pod_control_monitor_get,
1143 .put = snd_pod_control_monitor_put
1167 static int pod_create_files2(
struct device *dev)
1196 #ifdef CONFIG_LINE6_USB_RAW
1215 if ((interface ==
NULL) || (pod ==
NULL))
1233 sizeof(pod_request_channel));
1235 dev_err(&interface->dev,
"Out of memory\n");
1240 err = pod_create_files2(&interface->dev);
1286 int err = pod_try_init(interface, pod);
1289 pod_destruct(interface);
1301 if (interface ==
NULL)
1303 pod = usb_get_intfdata(interface);
1307 struct device *dev = &interface->dev;
1309 if (line6pcm !=
NULL)
1316 properties->device_bit, dev);
1333 &dev_attr_retrieve_effects_setup);
1344 #ifdef CONFIG_LINE6_USB_RAW
1350 pod_destruct(interface);