diff options
Diffstat (limited to 'drivers/staging/line6/pod.c')
| -rw-r--r-- | drivers/staging/line6/pod.c | 130 |
1 files changed, 38 insertions, 92 deletions
diff --git a/drivers/staging/line6/pod.c b/drivers/staging/line6/pod.c index e542540d0db..44f4b2f9857 100644 --- a/drivers/staging/line6/pod.c +++ b/drivers/staging/line6/pod.c @@ -34,12 +34,14 @@ enum { POD_SYSEX_DUMPMEM = 0x73, POD_SYSEX_DUMP = 0x74, POD_SYSEX_DUMPREQ = 0x75 - /* POD_SYSEX_DUMPMEM2 = 0x76 */ /* dumps entire internal memory of PODxt Pro */ + + /* dumps entire internal memory of PODxt Pro */ + /* POD_SYSEX_DUMPMEM2 = 0x76 */ }; enum { - POD_monitor_level = 0x04, - POD_system_invalid = 0x10000 + POD_MONITOR_LEVEL = 0x04, + POD_SYSTEM_INVALID = 0x10000 }; /* *INDENT-ON* */ @@ -133,84 +135,26 @@ void line6_pod_process_message(struct usb_line6_pod *pod) { const unsigned char *buf = pod->line6.buffer_message; - /* filter messages by type */ - switch (buf[0] & 0xf0) { - case LINE6_PARAM_CHANGE: - case LINE6_PROGRAM_CHANGE: - case LINE6_SYSEX_BEGIN: - break; /* handle these further down */ + if (memcmp(buf, pod_version_header, sizeof(pod_version_header)) == 0) { + pod->firmware_version = buf[13] * 100 + buf[14] * 10 + buf[15]; + pod->device_id = ((int)buf[8] << 16) | ((int)buf[9] << 8) | + (int) buf[10]; + pod_startup3(pod); + return; + } - default: - return; /* ignore all others */ + /* Only look for sysex messages from this device */ + if (buf[0] != (LINE6_SYSEX_BEGIN | LINE6_CHANNEL_DEVICE) && + buf[0] != (LINE6_SYSEX_BEGIN | LINE6_CHANNEL_UNKNOWN)) { + return; } + if (memcmp(buf + 1, line6_midi_id, sizeof(line6_midi_id)) != 0) + return; - /* process all remaining messages */ - switch (buf[0]) { - case LINE6_PARAM_CHANGE | LINE6_CHANNEL_DEVICE: - case LINE6_PARAM_CHANGE | LINE6_CHANNEL_HOST: - break; - - case LINE6_PROGRAM_CHANGE | LINE6_CHANNEL_DEVICE: - case LINE6_PROGRAM_CHANGE | LINE6_CHANNEL_HOST: - break; - - case LINE6_SYSEX_BEGIN | LINE6_CHANNEL_DEVICE: - case LINE6_SYSEX_BEGIN | LINE6_CHANNEL_UNKNOWN: - if (memcmp(buf + 1, line6_midi_id, sizeof(line6_midi_id)) == 0) { - switch (buf[5]) { - case POD_SYSEX_DUMP: - break; - - case POD_SYSEX_SYSTEM:{ - short value = - ((int)buf[7] << 12) | ((int)buf[8] - << 8) | - ((int)buf[9] << 4) | (int)buf[10]; - - if (buf[6] == POD_monitor_level) - pod->monitor_level = value; - break; - } - - case POD_SYSEX_FINISH: - /* do we need to respond to this? */ - break; - - case POD_SYSEX_SAVE: - break; - - case POD_SYSEX_STORE: - dev_dbg(pod->line6.ifcdev, - "message %02X not yet implemented\n", - buf[5]); - break; - - default: - dev_dbg(pod->line6.ifcdev, - "unknown sysex message %02X\n", - buf[5]); - } - } else - if (memcmp - (buf, pod_version_header, - sizeof(pod_version_header)) == 0) { - pod->firmware_version = - buf[13] * 100 + buf[14] * 10 + buf[15]; - pod->device_id = - ((int)buf[8] << 16) | ((int)buf[9] << 8) | (int) - buf[10]; - pod_startup3(pod); - } else - dev_dbg(pod->line6.ifcdev, "unknown sysex header\n"); - - break; - - case LINE6_SYSEX_END: - break; - - default: - dev_dbg(pod->line6.ifcdev, "POD: unknown message %02X\n", - buf[0]); + if (buf[5] == POD_SYSEX_SYSTEM && buf[6] == POD_MONITOR_LEVEL) { + short value = ((int)buf[7] << 12) | ((int)buf[8] << 8) | + ((int)buf[9] << 4) | (int)buf[10]; + pod->monitor_level = value; } } @@ -248,23 +192,24 @@ static int pod_set_system_param_int(struct usb_line6_pod *pod, int value, /* "read" request on "serial_number" special file. */ -static ssize_t pod_get_serial_number(struct device *dev, - struct device_attribute *attr, char *buf) +static ssize_t serial_number_show(struct device *dev, + struct device_attribute *attr, char *buf) { struct usb_interface *interface = to_usb_interface(dev); struct usb_line6_pod *pod = usb_get_intfdata(interface); + return sprintf(buf, "%d\n", pod->serial_number); } /* "read" request on "firmware_version" special file. */ -static ssize_t pod_get_firmware_version(struct device *dev, - struct device_attribute *attr, - char *buf) +static ssize_t firmware_version_show(struct device *dev, + struct device_attribute *attr, char *buf) { struct usb_interface *interface = to_usb_interface(dev); struct usb_line6_pod *pod = usb_get_intfdata(interface); + return sprintf(buf, "%d.%02d\n", pod->firmware_version / 100, pod->firmware_version % 100); } @@ -272,11 +217,12 @@ static ssize_t pod_get_firmware_version(struct device *dev, /* "read" request on "device_id" special file. */ -static ssize_t pod_get_device_id(struct device *dev, - struct device_attribute *attr, char *buf) +static ssize_t device_id_show(struct device *dev, + struct device_attribute *attr, char *buf) { struct usb_interface *interface = to_usb_interface(dev); struct usb_line6_pod *pod = usb_get_intfdata(interface); + return sprintf(buf, "%d\n", pod->device_id); } @@ -300,6 +246,7 @@ static void pod_startup2(unsigned long data) { struct usb_line6_pod *pod = (struct usb_line6_pod *)data; struct usb_line6 *line6 = &pod->line6; + CHECK_STARTUP_PROGRESS(pod->startup_progress, POD_STARTUP_VERSIONREQ); /* request firmware version: */ @@ -330,11 +277,9 @@ static void pod_startup4(struct work_struct *work) } /* POD special files: */ -static DEVICE_ATTR(device_id, S_IRUGO, pod_get_device_id, line6_nop_write); -static DEVICE_ATTR(firmware_version, S_IRUGO, pod_get_firmware_version, - line6_nop_write); -static DEVICE_ATTR(serial_number, S_IRUGO, pod_get_serial_number, - line6_nop_write); +static DEVICE_ATTR_RO(device_id); +static DEVICE_ATTR_RO(firmware_version); +static DEVICE_ATTR_RO(serial_number); /* control info callback */ static int snd_pod_control_monitor_info(struct snd_kcontrol *kcontrol, @@ -353,6 +298,7 @@ static int snd_pod_control_monitor_get(struct snd_kcontrol *kcontrol, { struct snd_line6_pcm *line6pcm = snd_kcontrol_chip(kcontrol); struct usb_line6_pod *pod = (struct usb_line6_pod *)line6pcm->line6; + ucontrol->value.integer.value[0] = pod->monitor_level; return 0; } @@ -369,7 +315,7 @@ static int snd_pod_control_monitor_put(struct snd_kcontrol *kcontrol, pod->monitor_level = ucontrol->value.integer.value[0]; pod_set_system_param_int(pod, ucontrol->value.integer.value[0], - POD_monitor_level); + POD_MONITOR_LEVEL); return 1; } @@ -460,7 +406,7 @@ static int pod_try_init(struct usb_interface *interface, */ if (pod->line6.properties->capabilities & LINE6_BIT_CONTROL) { - pod->monitor_level = POD_system_invalid; + pod->monitor_level = POD_SYSTEM_INVALID; /* initiate startup procedure: */ pod_startup1(pod); |
