2 * Line6 Linux USB driver - 0.9.1beta
4 * Copyright (C) 2004-2010 Markus Grabner (grabner@icg.tugraz.at)
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.
12 #include <linux/slab.h>
13 #include <linux/wait.h>
14 #include <sound/control.h>
23 #define POD_SYSEX_CODE 3
24 #define POD_BYTES_PER_FRAME 6 /* 24bit audio (stereo) */
29 POD_SYSEX_SAVE = 0x24,
30 POD_SYSEX_SYSTEM = 0x56,
31 POD_SYSEX_SYSTEMREQ = 0x57,
32 /* POD_SYSEX_UPDATE = 0x6c, */ /* software update! */
33 POD_SYSEX_STORE = 0x71,
34 POD_SYSEX_FINISH = 0x72,
35 POD_SYSEX_DUMPMEM = 0x73,
36 POD_SYSEX_DUMP = 0x74,
37 POD_SYSEX_DUMPREQ = 0x75
38 /* POD_SYSEX_DUMPMEM2 = 0x76 */ /* dumps entire internal memory of PODxt Pro */
42 POD_monitor_level = 0x04,
44 POD_tuner_mute = 0x13,
45 POD_tuner_freq = 0x15,
46 POD_tuner_note = 0x16,
47 POD_tuner_pitch = 0x17,
48 POD_system_invalid = 0x10000
65 static struct snd_ratden pod_ratden = {
72 static struct line6_pcm_properties pod_pcm_properties = {
73 .snd_line6_playback_hw = {
74 .info = (SNDRV_PCM_INFO_MMAP |
75 SNDRV_PCM_INFO_INTERLEAVED |
76 SNDRV_PCM_INFO_BLOCK_TRANSFER |
77 SNDRV_PCM_INFO_MMAP_VALID |
78 SNDRV_PCM_INFO_PAUSE |
80 SNDRV_PCM_INFO_RESUME |
82 SNDRV_PCM_INFO_SYNC_START),
83 .formats = SNDRV_PCM_FMTBIT_S24_3LE,
84 .rates = SNDRV_PCM_RATE_KNOT,
89 .buffer_bytes_max = 60000,
90 .period_bytes_min = 64,
91 .period_bytes_max = 8192,
94 .snd_line6_capture_hw = {
95 .info = (SNDRV_PCM_INFO_MMAP |
96 SNDRV_PCM_INFO_INTERLEAVED |
97 SNDRV_PCM_INFO_BLOCK_TRANSFER |
98 SNDRV_PCM_INFO_MMAP_VALID |
100 SNDRV_PCM_INFO_RESUME |
102 SNDRV_PCM_INFO_SYNC_START),
103 .formats = SNDRV_PCM_FMTBIT_S24_3LE,
104 .rates = SNDRV_PCM_RATE_KNOT,
109 .buffer_bytes_max = 60000,
110 .period_bytes_min = 64,
111 .period_bytes_max = 8192,
113 .periods_max = 1024},
116 .rats = &pod_ratden},
117 .bytes_per_frame = POD_BYTES_PER_FRAME
120 static const char pod_request_channel[] = {
121 0xf0, 0x00, 0x01, 0x0c, 0x03, 0x75, 0xf7
124 static const char pod_version_header[] = {
125 0xf2, 0x7e, 0x7f, 0x06, 0x02
128 /* forward declarations: */
129 static void pod_startup2(unsigned long data);
130 static void pod_startup3(struct usb_line6_pod *pod);
131 static void pod_startup4(struct usb_line6_pod *pod);
133 static char *pod_alloc_sysex_buffer(struct usb_line6_pod *pod, int code,
136 return line6_alloc_sysex_buffer(&pod->line6, POD_SYSEX_CODE, code,
141 Store parameter value in driver memory.
143 static void pod_store_parameter(struct usb_line6_pod *pod, int param, int value)
145 pod->prog_data.control[param] = value;
151 static void pod_save_button_pressed(struct usb_line6_pod *pod, int type,
154 set_bit(POD_SAVE_PRESSED, &pod->atomic_flags);
158 Process a completely received message.
160 void line6_pod_process_message(struct usb_line6_pod *pod)
162 const unsigned char *buf = pod->line6.buffer_message;
164 /* filter messages by type */
165 switch (buf[0] & 0xf0) {
166 case LINE6_PARAM_CHANGE:
167 case LINE6_PROGRAM_CHANGE:
168 case LINE6_SYSEX_BEGIN:
169 break; /* handle these further down */
172 return; /* ignore all others */
175 /* process all remaining messages */
177 case LINE6_PARAM_CHANGE | LINE6_CHANNEL_DEVICE:
178 pod_store_parameter(pod, buf[1], buf[2]);
179 /* intentionally no break here! */
181 case LINE6_PARAM_CHANGE | LINE6_CHANNEL_HOST:
182 if ((buf[1] == POD_amp_model_setup) ||
183 (buf[1] == POD_effect_setup))
184 /* these also affect other settings */
185 line6_dump_request_async(&pod->dumpreq, &pod->line6, 0,
190 case LINE6_PROGRAM_CHANGE | LINE6_CHANNEL_DEVICE:
191 case LINE6_PROGRAM_CHANGE | LINE6_CHANNEL_HOST:
192 set_bit(POD_CHANNEL_DIRTY, &pod->atomic_flags);
193 line6_dump_request_async(&pod->dumpreq, &pod->line6, 0,
197 case LINE6_SYSEX_BEGIN | LINE6_CHANNEL_DEVICE:
198 case LINE6_SYSEX_BEGIN | LINE6_CHANNEL_UNKNOWN:
199 if (memcmp(buf + 1, line6_midi_id, sizeof(line6_midi_id)) == 0) {
202 if (pod->line6.message_length ==
203 sizeof(pod->prog_data) + 7) {
204 switch (pod->dumpreq.in_progress) {
205 case LINE6_DUMP_CURRENT:
206 memcpy(&pod->prog_data, buf + 7,
207 sizeof(pod->prog_data));
210 case POD_DUMP_MEMORY:
211 memcpy(&pod->prog_data_buf,
214 (pod->prog_data_buf));
218 dev_dbg(pod->line6.ifcdev,
219 "unknown dump code %02X\n",
220 pod->dumpreq.in_progress);
223 line6_dump_finished(&pod->dumpreq);
226 dev_dbg(pod->line6.ifcdev,
227 "wrong size of channel dump message (%d instead of %d)\n",
228 pod->line6.message_length,
229 (int)sizeof(pod->prog_data) +
234 case POD_SYSEX_SYSTEM:{
236 ((int)buf[7] << 12) | ((int)buf[8]
238 ((int)buf[9] << 4) | (int)buf[10];
240 #define PROCESS_SYSTEM_PARAM(x) \
242 pod->x.value = value; \
243 wake_up(&pod->x.wait); \
247 case POD_monitor_level:
248 pod->monitor_level = value;
251 PROCESS_SYSTEM_PARAM(routing);
261 #undef PROCESS_SYSTEM_PARAM
264 dev_dbg(pod->line6.ifcdev,
265 "unknown tuner/system response %02X\n",
272 case POD_SYSEX_FINISH:
273 /* do we need to respond to this? */
277 pod_save_button_pressed(pod, buf[6], buf[7]);
280 case POD_SYSEX_STORE:
281 dev_dbg(pod->line6.ifcdev,
282 "message %02X not yet implemented\n",
287 dev_dbg(pod->line6.ifcdev,
288 "unknown sysex message %02X\n",
293 (buf, pod_version_header,
294 sizeof(pod_version_header)) == 0) {
295 pod->firmware_version =
296 buf[13] * 100 + buf[14] * 10 + buf[15];
298 ((int)buf[8] << 16) | ((int)buf[9] << 8) | (int)
302 dev_dbg(pod->line6.ifcdev, "unknown sysex header\n");
306 case LINE6_SYSEX_END:
310 dev_dbg(pod->line6.ifcdev, "POD: unknown message %02X\n",
316 Detect some cases that require a channel dump after sending a command to the
317 device. Important notes:
318 *) The actual dump request can not be sent here since we are not allowed to
319 wait for the completion of the first message in this context, and sending
320 the dump request before completion of the previous message leaves the POD
321 in an undefined state. The dump request will be sent when the echoed
322 commands are received.
323 *) This method fails if a param change message is "chopped" after the first
326 void line6_pod_midi_postprocess(struct usb_line6_pod *pod, unsigned char *data,
331 if (!pod->midi_postprocess)
334 for (i = 0; i < length; ++i) {
335 if (data[i] == (LINE6_PROGRAM_CHANGE | LINE6_CHANNEL_HOST)) {
336 line6_invalidate_current(&pod->dumpreq);
339 if ((data[i] == (LINE6_PARAM_CHANGE | LINE6_CHANNEL_HOST))
341 if ((data[i + 1] == POD_amp_model_setup)
342 || (data[i + 1] == POD_effect_setup)) {
343 line6_invalidate_current(&pod->dumpreq);
350 Transmit PODxt Pro control parameter.
352 void line6_pod_transmit_parameter(struct usb_line6_pod *pod, int param,
355 if (line6_transmit_parameter(&pod->line6, param, value) == 0)
356 pod_store_parameter(pod, param, value);
358 if ((param == POD_amp_model_setup) || (param == POD_effect_setup)) /* these also affect other settings */
359 line6_invalidate_current(&pod->dumpreq);
363 Resolve value to memory location.
365 static int pod_resolve(const char *buf, short block0, short block1,
366 unsigned char *location)
372 ret = kstrtou8(buf, 10, &value);
376 block = (value < 0x40) ? block0 : block1;
378 location[0] = block >> 7;
379 location[1] = value | (block & 0x7f);
384 Send command to store channel/effects setup/amp setup to PODxt Pro.
386 static ssize_t pod_send_store_command(struct device *dev, const char *buf,
387 size_t count, short block0, short block1)
389 struct usb_interface *interface = to_usb_interface(dev);
390 struct usb_line6_pod *pod = usb_get_intfdata(interface);
392 int size = 3 + sizeof(pod->prog_data_buf);
393 char *sysex = pod_alloc_sysex_buffer(pod, POD_SYSEX_STORE, size);
398 /* Don't know what this is good for, but PODxt Pro transmits it, so we
400 sysex[SYSEX_DATA_OFS] = 5;
401 ret = pod_resolve(buf, block0, block1, sysex + SYSEX_DATA_OFS + 1);
407 memcpy(sysex + SYSEX_DATA_OFS + 3, &pod->prog_data_buf,
408 sizeof(pod->prog_data_buf));
410 line6_send_sysex_message(&pod->line6, sysex, size);
412 /* needs some delay here on AMD64 platform */
417 Send command to retrieve channel/effects setup/amp setup to PODxt Pro.
419 static ssize_t pod_send_retrieve_command(struct device *dev, const char *buf,
420 size_t count, short block0,
423 struct usb_interface *interface = to_usb_interface(dev);
424 struct usb_line6_pod *pod = usb_get_intfdata(interface);
427 char *sysex = pod_alloc_sysex_buffer(pod, POD_SYSEX_DUMPMEM, size);
432 ret = pod_resolve(buf, block0, block1, sysex + SYSEX_DATA_OFS);
437 sysex[SYSEX_DATA_OFS + 2] = 0;
438 sysex[SYSEX_DATA_OFS + 3] = 0;
439 line6_dump_started(&pod->dumpreq, POD_DUMP_MEMORY);
441 if (line6_send_sysex_message(&pod->line6, sysex, size) < size)
442 line6_dump_finished(&pod->dumpreq);
445 /* needs some delay here on AMD64 platform */
450 Identify system parameters related to the tuner.
452 static bool pod_is_tuner(int code)
455 (code == POD_tuner_mute) ||
456 (code == POD_tuner_freq) ||
457 (code == POD_tuner_note) || (code == POD_tuner_pitch);
461 Get system parameter (as integer).
462 @param tuner non-zero, if code refers to a tuner parameter
464 static int pod_get_system_param_int(struct usb_line6_pod *pod, int *value,
465 int code, struct ValueWait *param, int sign)
468 static const int size = 1;
471 if (((pod->prog_data.control[POD_tuner] & 0x40) == 0)
472 && pod_is_tuner(code))
475 /* send value request to device: */
476 param->value = POD_system_invalid;
477 sysex = pod_alloc_sysex_buffer(pod, POD_SYSEX_SYSTEMREQ, size);
482 sysex[SYSEX_DATA_OFS] = code;
483 line6_send_sysex_message(&pod->line6, sysex, size);
486 /* wait for device to respond: */
488 wait_event_interruptible(param->wait,
489 param->value != POD_system_invalid);
494 *value = sign ? (int)(signed short)param->value : (int)(unsigned short)
497 if (*value == POD_system_invalid)
498 *value = 0; /* don't report uninitialized values */
504 Get system parameter (as string).
505 @param tuner non-zero, if code refers to a tuner parameter
507 static ssize_t pod_get_system_param_string(struct usb_line6_pod *pod, char *buf,
508 int code, struct ValueWait *param,
511 int retval, value = 0;
512 retval = pod_get_system_param_int(pod, &value, code, param, sign);
517 return sprintf(buf, "%d\n", value);
521 Send system parameter (from integer).
522 @param tuner non-zero, if code refers to a tuner parameter
524 static int pod_set_system_param_int(struct usb_line6_pod *pod, int value,
528 static const int size = 5;
530 if (((pod->prog_data.control[POD_tuner] & 0x40) == 0)
531 && pod_is_tuner(code))
534 /* send value to tuner: */
535 sysex = pod_alloc_sysex_buffer(pod, POD_SYSEX_SYSTEM, size);
538 sysex[SYSEX_DATA_OFS] = code;
539 sysex[SYSEX_DATA_OFS + 1] = (value >> 12) & 0x0f;
540 sysex[SYSEX_DATA_OFS + 2] = (value >> 8) & 0x0f;
541 sysex[SYSEX_DATA_OFS + 3] = (value >> 4) & 0x0f;
542 sysex[SYSEX_DATA_OFS + 4] = (value) & 0x0f;
543 line6_send_sysex_message(&pod->line6, sysex, size);
549 Send system parameter (from string).
550 @param tuner non-zero, if code refers to a tuner parameter
552 static ssize_t pod_set_system_param_string(struct usb_line6_pod *pod,
553 const char *buf, int count, int code,
557 unsigned short value = simple_strtoul(buf, NULL, 10) & mask;
558 retval = pod_set_system_param_int(pod, value, code);
559 return (retval < 0) ? retval : count;
563 "write" request on "finish" special file.
565 static ssize_t pod_set_finish(struct device *dev,
566 struct device_attribute *attr,
567 const char *buf, size_t count)
569 struct usb_interface *interface = to_usb_interface(dev);
570 struct usb_line6_pod *pod = usb_get_intfdata(interface);
572 char *sysex = pod_alloc_sysex_buffer(pod, POD_SYSEX_FINISH, size);
575 line6_send_sysex_message(&pod->line6, sysex, size);
581 "write" request on "store_channel" special file.
583 static ssize_t pod_set_store_channel(struct device *dev,
584 struct device_attribute *attr,
585 const char *buf, size_t count)
587 return pod_send_store_command(dev, buf, count, 0x0000, 0x00c0);
591 "write" request on "store_effects_setup" special file.
593 static ssize_t pod_set_store_effects_setup(struct device *dev,
594 struct device_attribute *attr,
595 const char *buf, size_t count)
597 return pod_send_store_command(dev, buf, count, 0x0080, 0x0080);
601 "write" request on "store_amp_setup" special file.
603 static ssize_t pod_set_store_amp_setup(struct device *dev,
604 struct device_attribute *attr,
605 const char *buf, size_t count)
607 return pod_send_store_command(dev, buf, count, 0x0040, 0x0100);
611 "write" request on "retrieve_effects_setup" special file.
613 static ssize_t pod_set_retrieve_effects_setup(struct device *dev,
614 struct device_attribute *attr,
615 const char *buf, size_t count)
617 return pod_send_retrieve_command(dev, buf, count, 0x0080, 0x0080);
621 "read" request on "midi_postprocess" special file.
623 static ssize_t pod_get_midi_postprocess(struct device *dev,
624 struct device_attribute *attr,
627 struct usb_interface *interface = to_usb_interface(dev);
628 struct usb_line6_pod *pod = usb_get_intfdata(interface);
629 return sprintf(buf, "%d\n", pod->midi_postprocess);
633 "write" request on "midi_postprocess" special file.
635 static ssize_t pod_set_midi_postprocess(struct device *dev,
636 struct device_attribute *attr,
637 const char *buf, size_t count)
639 struct usb_interface *interface = to_usb_interface(dev);
640 struct usb_line6_pod *pod = usb_get_intfdata(interface);
644 ret = kstrtou8(buf, 10, &value);
648 pod->midi_postprocess = value ? 1 : 0;
653 "read" request on "serial_number" special file.
655 static ssize_t pod_get_serial_number(struct device *dev,
656 struct device_attribute *attr, char *buf)
658 struct usb_interface *interface = to_usb_interface(dev);
659 struct usb_line6_pod *pod = usb_get_intfdata(interface);
660 return sprintf(buf, "%d\n", pod->serial_number);
664 "read" request on "firmware_version" special file.
666 static ssize_t pod_get_firmware_version(struct device *dev,
667 struct device_attribute *attr,
670 struct usb_interface *interface = to_usb_interface(dev);
671 struct usb_line6_pod *pod = usb_get_intfdata(interface);
672 return sprintf(buf, "%d.%02d\n", pod->firmware_version / 100,
673 pod->firmware_version % 100);
677 "read" request on "device_id" special file.
679 static ssize_t pod_get_device_id(struct device *dev,
680 struct device_attribute *attr, char *buf)
682 struct usb_interface *interface = to_usb_interface(dev);
683 struct usb_line6_pod *pod = usb_get_intfdata(interface);
684 return sprintf(buf, "%d\n", pod->device_id);
688 POD startup procedure.
689 This is a sequence of functions with special requirements (e.g., must
690 not run immediately after initialization, must not run in interrupt
691 context). After the last one has finished, the device is ready to use.
694 static void pod_startup1(struct usb_line6_pod *pod)
696 CHECK_STARTUP_PROGRESS(pod->startup_progress, POD_STARTUP_INIT);
698 /* delay startup procedure: */
699 line6_start_timer(&pod->startup_timer, POD_STARTUP_DELAY, pod_startup2,
703 static void pod_startup2(unsigned long data)
705 struct usb_line6_pod *pod = (struct usb_line6_pod *)data;
707 /* schedule another startup procedure until startup is complete: */
708 if (pod->startup_progress >= POD_STARTUP_LAST)
711 pod->startup_progress = POD_STARTUP_DUMPREQ;
712 line6_start_timer(&pod->startup_timer, POD_STARTUP_DELAY, pod_startup2,
715 /* current channel dump: */
716 line6_dump_request_async(&pod->dumpreq, &pod->line6, 0,
720 static void pod_startup3(struct usb_line6_pod *pod)
722 struct usb_line6 *line6 = &pod->line6;
723 CHECK_STARTUP_PROGRESS(pod->startup_progress, POD_STARTUP_VERSIONREQ);
725 /* request firmware version: */
726 line6_version_request_async(line6);
729 static void pod_startup4(struct usb_line6_pod *pod)
731 CHECK_STARTUP_PROGRESS(pod->startup_progress, POD_STARTUP_WORKQUEUE);
733 /* schedule work for global work queue: */
734 schedule_work(&pod->startup_work);
737 static void pod_startup5(struct work_struct *work)
739 struct usb_line6_pod *pod =
740 container_of(work, struct usb_line6_pod, startup_work);
741 struct usb_line6 *line6 = &pod->line6;
743 CHECK_STARTUP_PROGRESS(pod->startup_progress, POD_STARTUP_SETUP);
746 line6_read_serial_number(&pod->line6, &pod->serial_number);
748 /* ALSA audio interface: */
749 line6_register_audio(line6);
752 line6_pod_create_files(pod->firmware_version,
753 line6->properties->device_bit, line6->ifcdev);
756 #define POD_GET_SYSTEM_PARAM(code, sign) \
757 static ssize_t pod_get_ ## code(struct device *dev, \
758 struct device_attribute *attr, char *buf) \
760 struct usb_interface *interface = to_usb_interface(dev); \
761 struct usb_line6_pod *pod = usb_get_intfdata(interface); \
762 return pod_get_system_param_string(pod, buf, POD_ ## code, \
766 #define POD_GET_SET_SYSTEM_PARAM(code, mask, sign) \
767 POD_GET_SYSTEM_PARAM(code, sign) \
768 static ssize_t pod_set_ ## code(struct device *dev, \
769 struct device_attribute *attr, \
770 const char *buf, size_t count) \
772 struct usb_interface *interface = to_usb_interface(dev); \
773 struct usb_line6_pod *pod = usb_get_intfdata(interface); \
774 return pod_set_system_param_string(pod, buf, count, POD_ ## code, mask); \
777 POD_GET_SET_SYSTEM_PARAM(routing, 0x0003, 0);
778 POD_GET_SET_SYSTEM_PARAM(tuner_mute, 0x0001, 0);
779 POD_GET_SET_SYSTEM_PARAM(tuner_freq, 0xffff, 0);
780 POD_GET_SYSTEM_PARAM(tuner_note, 1);
781 POD_GET_SYSTEM_PARAM(tuner_pitch, 1);
783 #undef GET_SET_SYSTEM_PARAM
784 #undef GET_SYSTEM_PARAM
786 /* POD special files: */
787 static DEVICE_ATTR(device_id, S_IRUGO, pod_get_device_id, line6_nop_write);
788 static DEVICE_ATTR(finish, S_IWUSR, line6_nop_read, pod_set_finish);
789 static DEVICE_ATTR(firmware_version, S_IRUGO, pod_get_firmware_version,
791 static DEVICE_ATTR(midi_postprocess, S_IWUSR | S_IRUGO,
792 pod_get_midi_postprocess, pod_set_midi_postprocess);
793 static DEVICE_ATTR(retrieve_effects_setup, S_IWUSR, line6_nop_read,
794 pod_set_retrieve_effects_setup);
795 static DEVICE_ATTR(routing, S_IWUSR | S_IRUGO, pod_get_routing,
797 static DEVICE_ATTR(serial_number, S_IRUGO, pod_get_serial_number,
799 static DEVICE_ATTR(store_amp_setup, S_IWUSR, line6_nop_read,
800 pod_set_store_amp_setup);
801 static DEVICE_ATTR(store_channel, S_IWUSR, line6_nop_read,
802 pod_set_store_channel);
803 static DEVICE_ATTR(store_effects_setup, S_IWUSR, line6_nop_read,
804 pod_set_store_effects_setup);
805 static DEVICE_ATTR(tuner_freq, S_IWUSR | S_IRUGO, pod_get_tuner_freq,
807 static DEVICE_ATTR(tuner_mute, S_IWUSR | S_IRUGO, pod_get_tuner_mute,
809 static DEVICE_ATTR(tuner_note, S_IRUGO, pod_get_tuner_note, line6_nop_write);
810 static DEVICE_ATTR(tuner_pitch, S_IRUGO, pod_get_tuner_pitch, line6_nop_write);
812 #ifdef CONFIG_LINE6_USB_RAW
813 static DEVICE_ATTR(raw, S_IWUSR, line6_nop_read, line6_set_raw);
816 /* control info callback */
817 static int snd_pod_control_monitor_info(struct snd_kcontrol *kcontrol,
818 struct snd_ctl_elem_info *uinfo)
820 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
822 uinfo->value.integer.min = 0;
823 uinfo->value.integer.max = 65535;
827 /* control get callback */
828 static int snd_pod_control_monitor_get(struct snd_kcontrol *kcontrol,
829 struct snd_ctl_elem_value *ucontrol)
831 struct snd_line6_pcm *line6pcm = snd_kcontrol_chip(kcontrol);
832 struct usb_line6_pod *pod = (struct usb_line6_pod *)line6pcm->line6;
833 ucontrol->value.integer.value[0] = pod->monitor_level;
837 /* control put callback */
838 static int snd_pod_control_monitor_put(struct snd_kcontrol *kcontrol,
839 struct snd_ctl_elem_value *ucontrol)
841 struct snd_line6_pcm *line6pcm = snd_kcontrol_chip(kcontrol);
842 struct usb_line6_pod *pod = (struct usb_line6_pod *)line6pcm->line6;
844 if (ucontrol->value.integer.value[0] == pod->monitor_level)
847 pod->monitor_level = ucontrol->value.integer.value[0];
848 pod_set_system_param_int(pod, ucontrol->value.integer.value[0],
853 /* control definition */
854 static struct snd_kcontrol_new pod_control_monitor = {
855 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
856 .name = "Monitor Playback Volume",
858 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE,
859 .info = snd_pod_control_monitor_info,
860 .get = snd_pod_control_monitor_get,
861 .put = snd_pod_control_monitor_put
867 static void pod_destruct(struct usb_interface *interface)
869 struct usb_line6_pod *pod = usb_get_intfdata(interface);
873 line6_cleanup_audio(&pod->line6);
875 del_timer(&pod->startup_timer);
876 cancel_work_sync(&pod->startup_work);
878 /* free dump request data: */
879 line6_dumpreq_destruct(&pod->dumpreq);
883 Create sysfs entries.
885 static int pod_create_files2(struct device *dev)
889 CHECK_RETURN(device_create_file(dev, &dev_attr_device_id));
890 CHECK_RETURN(device_create_file(dev, &dev_attr_finish));
891 CHECK_RETURN(device_create_file(dev, &dev_attr_firmware_version));
892 CHECK_RETURN(device_create_file(dev, &dev_attr_midi_postprocess));
893 CHECK_RETURN(device_create_file(dev, &dev_attr_retrieve_effects_setup));
894 CHECK_RETURN(device_create_file(dev, &dev_attr_routing));
895 CHECK_RETURN(device_create_file(dev, &dev_attr_serial_number));
896 CHECK_RETURN(device_create_file(dev, &dev_attr_store_amp_setup));
897 CHECK_RETURN(device_create_file(dev, &dev_attr_store_channel));
898 CHECK_RETURN(device_create_file(dev, &dev_attr_store_effects_setup));
899 CHECK_RETURN(device_create_file(dev, &dev_attr_tuner_freq));
900 CHECK_RETURN(device_create_file(dev, &dev_attr_tuner_mute));
901 CHECK_RETURN(device_create_file(dev, &dev_attr_tuner_note));
902 CHECK_RETURN(device_create_file(dev, &dev_attr_tuner_pitch));
904 #ifdef CONFIG_LINE6_USB_RAW
905 CHECK_RETURN(device_create_file(dev, &dev_attr_raw));
912 Try to init POD device.
914 static int pod_try_init(struct usb_interface *interface,
915 struct usb_line6_pod *pod)
918 struct usb_line6 *line6 = &pod->line6;
920 init_timer(&pod->startup_timer);
921 INIT_WORK(&pod->startup_work, pod_startup5);
923 if ((interface == NULL) || (pod == NULL))
926 /* initialize wait queues: */
927 init_waitqueue_head(&pod->routing.wait);
928 init_waitqueue_head(&pod->tuner_mute.wait);
929 init_waitqueue_head(&pod->tuner_freq.wait);
930 init_waitqueue_head(&pod->tuner_note.wait);
931 init_waitqueue_head(&pod->tuner_pitch.wait);
933 /* initialize USB buffers: */
934 err = line6_dumpreq_init(&pod->dumpreq, pod_request_channel,
935 sizeof(pod_request_channel));
937 dev_err(&interface->dev, "Out of memory\n");
941 /* create sysfs entries: */
942 err = pod_create_files2(&interface->dev);
946 /* initialize audio system: */
947 err = line6_init_audio(line6);
951 /* initialize MIDI subsystem: */
952 err = line6_init_midi(line6);
956 /* initialize PCM subsystem: */
957 err = line6_init_pcm(line6, &pod_pcm_properties);
961 /* register monitor control: */
962 err = snd_ctl_add(line6->card,
963 snd_ctl_new1(&pod_control_monitor, line6->line6pcm));
968 When the sound card is registered at this point, the PODxt Live
969 displays "Invalid Code Error 07", so we do it later in the event
973 if (pod->line6.properties->capabilities & LINE6_BIT_CONTROL) {
974 pod->monitor_level = POD_system_invalid;
976 /* initiate startup procedure: */
984 Init POD device (and clean up in case of failure).
986 int line6_pod_init(struct usb_interface *interface, struct usb_line6_pod *pod)
988 int err = pod_try_init(interface, pod);
991 pod_destruct(interface);
997 POD device disconnected.
999 void line6_pod_disconnect(struct usb_interface *interface)
1001 struct usb_line6_pod *pod;
1003 if (interface == NULL)
1005 pod = usb_get_intfdata(interface);
1008 struct snd_line6_pcm *line6pcm = pod->line6.line6pcm;
1009 struct device *dev = &interface->dev;
1011 if (line6pcm != NULL)
1012 line6_pcm_disconnect(line6pcm);
1015 /* remove sysfs entries: */
1016 line6_pod_remove_files(pod->firmware_version,
1018 properties->device_bit, dev);
1020 device_remove_file(dev, &dev_attr_device_id);
1021 device_remove_file(dev, &dev_attr_finish);
1022 device_remove_file(dev, &dev_attr_firmware_version);
1023 device_remove_file(dev, &dev_attr_midi_postprocess);
1024 device_remove_file(dev,
1025 &dev_attr_retrieve_effects_setup);
1026 device_remove_file(dev, &dev_attr_routing);
1027 device_remove_file(dev, &dev_attr_serial_number);
1028 device_remove_file(dev, &dev_attr_store_amp_setup);
1029 device_remove_file(dev, &dev_attr_store_channel);
1030 device_remove_file(dev, &dev_attr_store_effects_setup);
1031 device_remove_file(dev, &dev_attr_tuner_freq);
1032 device_remove_file(dev, &dev_attr_tuner_mute);
1033 device_remove_file(dev, &dev_attr_tuner_note);
1034 device_remove_file(dev, &dev_attr_tuner_pitch);
1036 #ifdef CONFIG_LINE6_USB_RAW
1037 device_remove_file(dev, &dev_attr_raw);
1042 pod_destruct(interface);