]> Pileus Git - ~andy/linux/blob - drivers/staging/line6/pod.c
staging: line6: drop channel sysfs attr
[~andy/linux] / drivers / staging / line6 / pod.c
1 /*
2  * Line6 Linux USB driver - 0.9.1beta
3  *
4  * Copyright (C) 2004-2010 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 <linux/slab.h>
13 #include <linux/wait.h>
14 #include <sound/control.h>
15
16 #include "audio.h"
17 #include "capture.h"
18 #include "control.h"
19 #include "driver.h"
20 #include "playback.h"
21 #include "pod.h"
22
23 #define POD_SYSEX_CODE 3
24 #define POD_BYTES_PER_FRAME 6   /* 24bit audio (stereo) */
25
26 /* *INDENT-OFF* */
27
28 enum {
29         POD_SYSEX_CLIP      = 0x0f,
30         POD_SYSEX_SAVE      = 0x24,
31         POD_SYSEX_SYSTEM    = 0x56,
32         POD_SYSEX_SYSTEMREQ = 0x57,
33         /* POD_SYSEX_UPDATE    = 0x6c, */  /* software update! */
34         POD_SYSEX_STORE     = 0x71,
35         POD_SYSEX_FINISH    = 0x72,
36         POD_SYSEX_DUMPMEM   = 0x73,
37         POD_SYSEX_DUMP      = 0x74,
38         POD_SYSEX_DUMPREQ   = 0x75
39         /* POD_SYSEX_DUMPMEM2  = 0x76 */   /* dumps entire internal memory of PODxt Pro */
40 };
41
42 enum {
43         POD_monitor_level  = 0x04,
44         POD_routing        = 0x05,
45         POD_tuner_mute     = 0x13,
46         POD_tuner_freq     = 0x15,
47         POD_tuner_note     = 0x16,
48         POD_tuner_pitch    = 0x17,
49         POD_system_invalid = 0x10000
50 };
51
52 /* *INDENT-ON* */
53
54 enum {
55         POD_DUMP_MEMORY = 2
56 };
57
58 enum {
59         POD_BUSY_READ,
60         POD_BUSY_WRITE,
61         POD_CHANNEL_DIRTY,
62         POD_SAVE_PRESSED,
63         POD_BUSY_MIDISEND
64 };
65
66 static struct snd_ratden pod_ratden = {
67         .num_min = 78125,
68         .num_max = 78125,
69         .num_step = 1,
70         .den = 2
71 };
72
73 static struct line6_pcm_properties pod_pcm_properties = {
74         .snd_line6_playback_hw = {
75                                   .info = (SNDRV_PCM_INFO_MMAP |
76                                            SNDRV_PCM_INFO_INTERLEAVED |
77                                            SNDRV_PCM_INFO_BLOCK_TRANSFER |
78                                            SNDRV_PCM_INFO_MMAP_VALID |
79                                            SNDRV_PCM_INFO_PAUSE |
80 #ifdef CONFIG_PM
81                                            SNDRV_PCM_INFO_RESUME |
82 #endif
83                                            SNDRV_PCM_INFO_SYNC_START),
84                                   .formats = SNDRV_PCM_FMTBIT_S24_3LE,
85                                   .rates = SNDRV_PCM_RATE_KNOT,
86                                   .rate_min = 39062,
87                                   .rate_max = 39063,
88                                   .channels_min = 2,
89                                   .channels_max = 2,
90                                   .buffer_bytes_max = 60000,
91                                   .period_bytes_min = 64,
92                                   .period_bytes_max = 8192,
93                                   .periods_min = 1,
94                                   .periods_max = 1024},
95         .snd_line6_capture_hw = {
96                                  .info = (SNDRV_PCM_INFO_MMAP |
97                                           SNDRV_PCM_INFO_INTERLEAVED |
98                                           SNDRV_PCM_INFO_BLOCK_TRANSFER |
99                                           SNDRV_PCM_INFO_MMAP_VALID |
100 #ifdef CONFIG_PM
101                                           SNDRV_PCM_INFO_RESUME |
102 #endif
103                                           SNDRV_PCM_INFO_SYNC_START),
104                                  .formats = SNDRV_PCM_FMTBIT_S24_3LE,
105                                  .rates = SNDRV_PCM_RATE_KNOT,
106                                  .rate_min = 39062,
107                                  .rate_max = 39063,
108                                  .channels_min = 2,
109                                  .channels_max = 2,
110                                  .buffer_bytes_max = 60000,
111                                  .period_bytes_min = 64,
112                                  .period_bytes_max = 8192,
113                                  .periods_min = 1,
114                                  .periods_max = 1024},
115         .snd_line6_rates = {
116                             .nrats = 1,
117                             .rats = &pod_ratden},
118         .bytes_per_frame = POD_BYTES_PER_FRAME
119 };
120
121 static const char pod_request_channel[] = {
122         0xf0, 0x00, 0x01, 0x0c, 0x03, 0x75, 0xf7
123 };
124
125 static const char pod_version_header[] = {
126         0xf2, 0x7e, 0x7f, 0x06, 0x02
127 };
128
129 /* forward declarations: */
130 static void pod_startup2(unsigned long data);
131 static void pod_startup3(struct usb_line6_pod *pod);
132 static void pod_startup4(struct usb_line6_pod *pod);
133
134 /*
135         Mark all parameters as dirty and notify waiting processes.
136 */
137 static void pod_mark_batch_all_dirty(struct usb_line6_pod *pod)
138 {
139         int i;
140
141         for (i = 0; i < POD_CONTROL_SIZE; i++)
142                 set_bit(i, pod->param_dirty);
143 }
144
145 static char *pod_alloc_sysex_buffer(struct usb_line6_pod *pod, int code,
146                                     int size)
147 {
148         return line6_alloc_sysex_buffer(&pod->line6, POD_SYSEX_CODE, code,
149                                         size);
150 }
151
152 /*
153         Send channel dump data to the PODxt Pro.
154 */
155 static void pod_dump(struct usb_line6_pod *pod, const unsigned char *data)
156 {
157         int size = 1 + sizeof(pod->prog_data);
158         char *sysex = pod_alloc_sysex_buffer(pod, POD_SYSEX_DUMP, size);
159         if (!sysex)
160                 return;
161         /* Don't know what this is good for, but PODxt Pro transmits it, so we
162          * also do... */
163         sysex[SYSEX_DATA_OFS] = 5;
164         memcpy(sysex + SYSEX_DATA_OFS + 1, data, sizeof(pod->prog_data));
165         line6_send_sysex_message(&pod->line6, sysex, size);
166         memcpy(&pod->prog_data, data, sizeof(pod->prog_data));
167         pod_mark_batch_all_dirty(pod);
168         kfree(sysex);
169 }
170
171 /*
172         Store parameter value in driver memory and mark it as dirty.
173 */
174 static void pod_store_parameter(struct usb_line6_pod *pod, int param, int value)
175 {
176         pod->prog_data.control[param] = value;
177         set_bit(param, pod->param_dirty);
178         pod->dirty = 1;
179 }
180
181 /*
182         Handle SAVE button.
183 */
184 static void pod_save_button_pressed(struct usb_line6_pod *pod, int type,
185                                     int index)
186 {
187         pod->dirty = 0;
188         set_bit(POD_SAVE_PRESSED, &pod->atomic_flags);
189 }
190
191 /*
192         Process a completely received message.
193 */
194 void line6_pod_process_message(struct usb_line6_pod *pod)
195 {
196         const unsigned char *buf = pod->line6.buffer_message;
197
198         /* filter messages by type */
199         switch (buf[0] & 0xf0) {
200         case LINE6_PARAM_CHANGE:
201         case LINE6_PROGRAM_CHANGE:
202         case LINE6_SYSEX_BEGIN:
203                 break;          /* handle these further down */
204
205         default:
206                 return;         /* ignore all others */
207         }
208
209         /* process all remaining messages */
210         switch (buf[0]) {
211         case LINE6_PARAM_CHANGE | LINE6_CHANNEL_DEVICE:
212                 pod_store_parameter(pod, buf[1], buf[2]);
213                 /* intentionally no break here! */
214
215         case LINE6_PARAM_CHANGE | LINE6_CHANNEL_HOST:
216                 if ((buf[1] == POD_amp_model_setup) ||
217                     (buf[1] == POD_effect_setup))
218                         /* these also affect other settings */
219                         line6_dump_request_async(&pod->dumpreq, &pod->line6, 0,
220                                                  LINE6_DUMP_CURRENT);
221
222                 break;
223
224         case LINE6_PROGRAM_CHANGE | LINE6_CHANNEL_DEVICE:
225         case LINE6_PROGRAM_CHANGE | LINE6_CHANNEL_HOST:
226                 pod->dirty = 0;
227                 set_bit(POD_CHANNEL_DIRTY, &pod->atomic_flags);
228                 line6_dump_request_async(&pod->dumpreq, &pod->line6, 0,
229                                          LINE6_DUMP_CURRENT);
230                 break;
231
232         case LINE6_SYSEX_BEGIN | LINE6_CHANNEL_DEVICE:
233         case LINE6_SYSEX_BEGIN | LINE6_CHANNEL_UNKNOWN:
234                 if (memcmp(buf + 1, line6_midi_id, sizeof(line6_midi_id)) == 0) {
235                         switch (buf[5]) {
236                         case POD_SYSEX_DUMP:
237                                 if (pod->line6.message_length ==
238                                     sizeof(pod->prog_data) + 7) {
239                                         switch (pod->dumpreq.in_progress) {
240                                         case LINE6_DUMP_CURRENT:
241                                                 memcpy(&pod->prog_data, buf + 7,
242                                                        sizeof(pod->prog_data));
243                                                 pod_mark_batch_all_dirty(pod);
244                                                 break;
245
246                                         case POD_DUMP_MEMORY:
247                                                 memcpy(&pod->prog_data_buf,
248                                                        buf + 7,
249                                                        sizeof
250                                                        (pod->prog_data_buf));
251                                                 break;
252
253                                         default:
254                                                 dev_dbg(pod->line6.ifcdev,
255                                                         "unknown dump code %02X\n",
256                                                         pod->dumpreq.in_progress);
257                                         }
258
259                                         line6_dump_finished(&pod->dumpreq);
260                                         pod_startup3(pod);
261                                 } else
262                                         dev_dbg(pod->line6.ifcdev,
263                                                 "wrong size of channel dump message (%d instead of %d)\n",
264                                                 pod->line6.message_length,
265                                                 (int)sizeof(pod->prog_data) +
266                                                 7);
267
268                                 break;
269
270                         case POD_SYSEX_SYSTEM:{
271                                         short value =
272                                             ((int)buf[7] << 12) | ((int)buf[8]
273                                                                    << 8) |
274                                             ((int)buf[9] << 4) | (int)buf[10];
275
276 #define PROCESS_SYSTEM_PARAM(x) \
277                                         case POD_ ## x: \
278                                                 pod->x.value = value; \
279                                                 wake_up(&pod->x.wait); \
280                                                 break;
281
282                                         switch (buf[6]) {
283                                                 PROCESS_SYSTEM_PARAM
284                                                     (monitor_level);
285                                                 PROCESS_SYSTEM_PARAM(routing);
286                                                 PROCESS_SYSTEM_PARAM
287                                                     (tuner_mute);
288                                                 PROCESS_SYSTEM_PARAM
289                                                     (tuner_freq);
290                                                 PROCESS_SYSTEM_PARAM
291                                                     (tuner_note);
292                                                 PROCESS_SYSTEM_PARAM
293                                                     (tuner_pitch);
294
295 #undef PROCESS_SYSTEM_PARAM
296
297                                         default:
298                                                 dev_dbg(pod->line6.ifcdev,
299                                                         "unknown tuner/system response %02X\n",
300                                                         buf[6]);
301                                         }
302
303                                         break;
304                                 }
305
306                         case POD_SYSEX_FINISH:
307                                 /* do we need to respond to this? */
308                                 break;
309
310                         case POD_SYSEX_SAVE:
311                                 pod_save_button_pressed(pod, buf[6], buf[7]);
312                                 break;
313
314                         case POD_SYSEX_CLIP:
315                                 dev_dbg(pod->line6.ifcdev, "audio clipped\n");
316                                 pod->clipping.value = 1;
317                                 wake_up(&pod->clipping.wait);
318                                 break;
319
320                         case POD_SYSEX_STORE:
321                                 dev_dbg(pod->line6.ifcdev,
322                                         "message %02X not yet implemented\n",
323                                         buf[5]);
324                                 break;
325
326                         default:
327                                 dev_dbg(pod->line6.ifcdev,
328                                         "unknown sysex message %02X\n",
329                                         buf[5]);
330                         }
331                 } else
332                     if (memcmp
333                         (buf, pod_version_header,
334                          sizeof(pod_version_header)) == 0) {
335                         pod->firmware_version =
336                             buf[13] * 100 + buf[14] * 10 + buf[15];
337                         pod->device_id =
338                             ((int)buf[8] << 16) | ((int)buf[9] << 8) | (int)
339                             buf[10];
340                         pod_startup4(pod);
341                 } else
342                         dev_dbg(pod->line6.ifcdev, "unknown sysex header\n");
343
344                 break;
345
346         case LINE6_SYSEX_END:
347                 break;
348
349         default:
350                 dev_dbg(pod->line6.ifcdev, "POD: unknown message %02X\n",
351                         buf[0]);
352         }
353 }
354
355 /*
356         Detect some cases that require a channel dump after sending a command to the
357         device. Important notes:
358         *) The actual dump request can not be sent here since we are not allowed to
359         wait for the completion of the first message in this context, and sending
360         the dump request before completion of the previous message leaves the POD
361         in an undefined state. The dump request will be sent when the echoed
362         commands are received.
363         *) This method fails if a param change message is "chopped" after the first
364         byte.
365 */
366 void line6_pod_midi_postprocess(struct usb_line6_pod *pod, unsigned char *data,
367                                 int length)
368 {
369         int i;
370
371         if (!pod->midi_postprocess)
372                 return;
373
374         for (i = 0; i < length; ++i) {
375                 if (data[i] == (LINE6_PROGRAM_CHANGE | LINE6_CHANNEL_HOST)) {
376                         line6_invalidate_current(&pod->dumpreq);
377                         break;
378                 } else
379                     if ((data[i] == (LINE6_PARAM_CHANGE | LINE6_CHANNEL_HOST))
380                         && (i < length - 1))
381                         if ((data[i + 1] == POD_amp_model_setup)
382                             || (data[i + 1] == POD_effect_setup)) {
383                                 line6_invalidate_current(&pod->dumpreq);
384                                 break;
385                         }
386         }
387 }
388
389 /*
390         Transmit PODxt Pro control parameter.
391 */
392 void line6_pod_transmit_parameter(struct usb_line6_pod *pod, int param,
393                                   u8 value)
394 {
395         if (line6_transmit_parameter(&pod->line6, param, value) == 0)
396                 pod_store_parameter(pod, param, value);
397
398         if ((param == POD_amp_model_setup) || (param == POD_effect_setup))      /* these also affect other settings */
399                 line6_invalidate_current(&pod->dumpreq);
400 }
401
402 /*
403         Resolve value to memory location.
404 */
405 static int pod_resolve(const char *buf, short block0, short block1,
406                        unsigned char *location)
407 {
408         u8 value;
409         short block;
410         int ret;
411
412         ret = kstrtou8(buf, 10, &value);
413         if (ret)
414                 return ret;
415
416         block = (value < 0x40) ? block0 : block1;
417         value &= 0x3f;
418         location[0] = block >> 7;
419         location[1] = value | (block & 0x7f);
420         return 0;
421 }
422
423 /*
424         Send command to store channel/effects setup/amp setup to PODxt Pro.
425 */
426 static ssize_t pod_send_store_command(struct device *dev, const char *buf,
427                                       size_t count, short block0, short block1)
428 {
429         struct usb_interface *interface = to_usb_interface(dev);
430         struct usb_line6_pod *pod = usb_get_intfdata(interface);
431         int ret;
432         int size = 3 + sizeof(pod->prog_data_buf);
433         char *sysex = pod_alloc_sysex_buffer(pod, POD_SYSEX_STORE, size);
434
435         if (!sysex)
436                 return 0;
437
438         sysex[SYSEX_DATA_OFS] = 5;      /* see pod_dump() */
439         ret = pod_resolve(buf, block0, block1, sysex + SYSEX_DATA_OFS + 1);
440         if (ret) {
441                 kfree(sysex);
442                 return ret;
443         }
444
445         memcpy(sysex + SYSEX_DATA_OFS + 3, &pod->prog_data_buf,
446                sizeof(pod->prog_data_buf));
447
448         line6_send_sysex_message(&pod->line6, sysex, size);
449         kfree(sysex);
450         /* needs some delay here on AMD64 platform */
451         return count;
452 }
453
454 /*
455         Send command to retrieve channel/effects setup/amp setup to PODxt Pro.
456 */
457 static ssize_t pod_send_retrieve_command(struct device *dev, const char *buf,
458                                          size_t count, short block0,
459                                          short block1)
460 {
461         struct usb_interface *interface = to_usb_interface(dev);
462         struct usb_line6_pod *pod = usb_get_intfdata(interface);
463         int ret;
464         int size = 4;
465         char *sysex = pod_alloc_sysex_buffer(pod, POD_SYSEX_DUMPMEM, size);
466
467         if (!sysex)
468                 return 0;
469
470         ret = pod_resolve(buf, block0, block1, sysex + SYSEX_DATA_OFS);
471         if (ret) {
472                 kfree(sysex);
473                 return ret;
474         }
475         sysex[SYSEX_DATA_OFS + 2] = 0;
476         sysex[SYSEX_DATA_OFS + 3] = 0;
477         line6_dump_started(&pod->dumpreq, POD_DUMP_MEMORY);
478
479         if (line6_send_sysex_message(&pod->line6, sysex, size) < size)
480                 line6_dump_finished(&pod->dumpreq);
481
482         kfree(sysex);
483         /* needs some delay here on AMD64 platform */
484         return count;
485 }
486
487 /*
488         Generic get name function.
489 */
490 static ssize_t get_name_generic(struct usb_line6_pod *pod, const char *str,
491                                 char *buf)
492 {
493         int length = 0;
494         const char *p1;
495         char *p2;
496         char *last_non_space = buf;
497
498         int retval = line6_dump_wait_interruptible(&pod->dumpreq);
499         if (retval < 0)
500                 return retval;
501
502         for (p1 = str, p2 = buf; *p1; ++p1, ++p2) {
503                 *p2 = *p1;
504                 if (*p2 != ' ')
505                         last_non_space = p2;
506                 if (++length == POD_NAME_LENGTH)
507                         break;
508         }
509
510         *(last_non_space + 1) = '\n';
511         return last_non_space - buf + 2;
512 }
513
514 /*
515         "read" request on "name" special file.
516 */
517 static ssize_t pod_get_name(struct device *dev, struct device_attribute *attr,
518                             char *buf)
519 {
520         struct usb_interface *interface = to_usb_interface(dev);
521         struct usb_line6_pod *pod = usb_get_intfdata(interface);
522         return get_name_generic(pod, pod->prog_data.header + POD_NAME_OFFSET,
523                                 buf);
524 }
525
526 /*
527         "read" request on "name" special file.
528 */
529 static ssize_t pod_get_name_buf(struct device *dev,
530                                 struct device_attribute *attr, char *buf)
531 {
532         struct usb_interface *interface = to_usb_interface(dev);
533         struct usb_line6_pod *pod = usb_get_intfdata(interface);
534         return get_name_generic(pod,
535                                 pod->prog_data_buf.header + POD_NAME_OFFSET,
536                                 buf);
537 }
538
539 /*
540         "read" request on "dump" special file.
541 */
542 static ssize_t pod_get_dump(struct device *dev, struct device_attribute *attr,
543                             char *buf)
544 {
545         struct usb_interface *interface = to_usb_interface(dev);
546         struct usb_line6_pod *pod = usb_get_intfdata(interface);
547         int retval = line6_dump_wait_interruptible(&pod->dumpreq);
548         if (retval < 0)
549                 return retval;
550         memcpy(buf, &pod->prog_data, sizeof(pod->prog_data));
551         return sizeof(pod->prog_data);
552 }
553
554 /*
555         "write" request on "dump" special file.
556 */
557 static ssize_t pod_set_dump(struct device *dev, struct device_attribute *attr,
558                             const char *buf, size_t count)
559 {
560         struct usb_interface *interface = to_usb_interface(dev);
561         struct usb_line6_pod *pod = usb_get_intfdata(interface);
562
563         if (count != sizeof(pod->prog_data)) {
564                 dev_err(pod->line6.ifcdev,
565                         "data block must be exactly %d bytes\n",
566                         (int)sizeof(pod->prog_data));
567                 return -EINVAL;
568         }
569
570         pod_dump(pod, buf);
571         return sizeof(pod->prog_data);
572 }
573
574 /*
575         Identify system parameters related to the tuner.
576 */
577 static bool pod_is_tuner(int code)
578 {
579         return
580             (code == POD_tuner_mute) ||
581             (code == POD_tuner_freq) ||
582             (code == POD_tuner_note) || (code == POD_tuner_pitch);
583 }
584
585 /*
586         Get system parameter (as integer).
587         @param tuner non-zero, if code refers to a tuner parameter
588 */
589 static int pod_get_system_param_int(struct usb_line6_pod *pod, int *value,
590                                     int code, struct ValueWait *param, int sign)
591 {
592         char *sysex;
593         static const int size = 1;
594         int retval = 0;
595
596         if (((pod->prog_data.control[POD_tuner] & 0x40) == 0)
597             && pod_is_tuner(code))
598                 return -ENODEV;
599
600         /* send value request to device: */
601         param->value = POD_system_invalid;
602         sysex = pod_alloc_sysex_buffer(pod, POD_SYSEX_SYSTEMREQ, size);
603
604         if (!sysex)
605                 return -ENOMEM;
606
607         sysex[SYSEX_DATA_OFS] = code;
608         line6_send_sysex_message(&pod->line6, sysex, size);
609         kfree(sysex);
610
611         /* wait for device to respond: */
612         retval =
613             wait_event_interruptible(param->wait,
614                                      param->value != POD_system_invalid);
615
616         if (retval < 0)
617                 return retval;
618
619         *value = sign ? (int)(signed short)param->value : (int)(unsigned short)
620             param->value;
621
622         if (*value == POD_system_invalid)
623                 *value = 0;     /* don't report uninitialized values */
624
625         return 0;
626 }
627
628 /*
629         Get system parameter (as string).
630         @param tuner non-zero, if code refers to a tuner parameter
631 */
632 static ssize_t pod_get_system_param_string(struct usb_line6_pod *pod, char *buf,
633                                            int code, struct ValueWait *param,
634                                            int sign)
635 {
636         int retval, value = 0;
637         retval = pod_get_system_param_int(pod, &value, code, param, sign);
638
639         if (retval < 0)
640                 return retval;
641
642         return sprintf(buf, "%d\n", value);
643 }
644
645 /*
646         Send system parameter (from integer).
647         @param tuner non-zero, if code refers to a tuner parameter
648 */
649 static int pod_set_system_param_int(struct usb_line6_pod *pod, int value,
650                                     int code)
651 {
652         char *sysex;
653         static const int size = 5;
654
655         if (((pod->prog_data.control[POD_tuner] & 0x40) == 0)
656             && pod_is_tuner(code))
657                 return -EINVAL;
658
659         /* send value to tuner: */
660         sysex = pod_alloc_sysex_buffer(pod, POD_SYSEX_SYSTEM, size);
661         if (!sysex)
662                 return -ENOMEM;
663         sysex[SYSEX_DATA_OFS] = code;
664         sysex[SYSEX_DATA_OFS + 1] = (value >> 12) & 0x0f;
665         sysex[SYSEX_DATA_OFS + 2] = (value >> 8) & 0x0f;
666         sysex[SYSEX_DATA_OFS + 3] = (value >> 4) & 0x0f;
667         sysex[SYSEX_DATA_OFS + 4] = (value) & 0x0f;
668         line6_send_sysex_message(&pod->line6, sysex, size);
669         kfree(sysex);
670         return 0;
671 }
672
673 /*
674         Send system parameter (from string).
675         @param tuner non-zero, if code refers to a tuner parameter
676 */
677 static ssize_t pod_set_system_param_string(struct usb_line6_pod *pod,
678                                            const char *buf, int count, int code,
679                                            unsigned short mask)
680 {
681         int retval;
682         unsigned short value = simple_strtoul(buf, NULL, 10) & mask;
683         retval = pod_set_system_param_int(pod, value, code);
684         return (retval < 0) ? retval : count;
685 }
686
687 /*
688         "read" request on "dump_buf" special file.
689 */
690 static ssize_t pod_get_dump_buf(struct device *dev,
691                                 struct device_attribute *attr, char *buf)
692 {
693         struct usb_interface *interface = to_usb_interface(dev);
694         struct usb_line6_pod *pod = usb_get_intfdata(interface);
695         int retval = line6_dump_wait_interruptible(&pod->dumpreq);
696         if (retval < 0)
697                 return retval;
698         memcpy(buf, &pod->prog_data_buf, sizeof(pod->prog_data_buf));
699         return sizeof(pod->prog_data_buf);
700 }
701
702 /*
703         "write" request on "dump_buf" special file.
704 */
705 static ssize_t pod_set_dump_buf(struct device *dev,
706                                 struct device_attribute *attr,
707                                 const char *buf, size_t count)
708 {
709         struct usb_interface *interface = to_usb_interface(dev);
710         struct usb_line6_pod *pod = usb_get_intfdata(interface);
711
712         if (count != sizeof(pod->prog_data)) {
713                 dev_err(pod->line6.ifcdev,
714                         "data block must be exactly %d bytes\n",
715                         (int)sizeof(pod->prog_data));
716                 return -EINVAL;
717         }
718
719         memcpy(&pod->prog_data_buf, buf, sizeof(pod->prog_data));
720         return sizeof(pod->prog_data);
721 }
722
723 /*
724         "write" request on "finish" special file.
725 */
726 static ssize_t pod_set_finish(struct device *dev,
727                               struct device_attribute *attr,
728                               const char *buf, size_t count)
729 {
730         struct usb_interface *interface = to_usb_interface(dev);
731         struct usb_line6_pod *pod = usb_get_intfdata(interface);
732         int size = 0;
733         char *sysex = pod_alloc_sysex_buffer(pod, POD_SYSEX_FINISH, size);
734         if (!sysex)
735                 return 0;
736         line6_send_sysex_message(&pod->line6, sysex, size);
737         kfree(sysex);
738         return count;
739 }
740
741 /*
742         "write" request on "store_channel" special file.
743 */
744 static ssize_t pod_set_store_channel(struct device *dev,
745                                      struct device_attribute *attr,
746                                      const char *buf, size_t count)
747 {
748         return pod_send_store_command(dev, buf, count, 0x0000, 0x00c0);
749 }
750
751 /*
752         "write" request on "store_effects_setup" special file.
753 */
754 static ssize_t pod_set_store_effects_setup(struct device *dev,
755                                            struct device_attribute *attr,
756                                            const char *buf, size_t count)
757 {
758         return pod_send_store_command(dev, buf, count, 0x0080, 0x0080);
759 }
760
761 /*
762         "write" request on "store_amp_setup" special file.
763 */
764 static ssize_t pod_set_store_amp_setup(struct device *dev,
765                                        struct device_attribute *attr,
766                                        const char *buf, size_t count)
767 {
768         return pod_send_store_command(dev, buf, count, 0x0040, 0x0100);
769 }
770
771 /*
772         "write" request on "retrieve_channel" special file.
773 */
774 static ssize_t pod_set_retrieve_channel(struct device *dev,
775                                         struct device_attribute *attr,
776                                         const char *buf, size_t count)
777 {
778         return pod_send_retrieve_command(dev, buf, count, 0x0000, 0x00c0);
779 }
780
781 /*
782         "write" request on "retrieve_effects_setup" special file.
783 */
784 static ssize_t pod_set_retrieve_effects_setup(struct device *dev,
785                                               struct device_attribute *attr,
786                                               const char *buf, size_t count)
787 {
788         return pod_send_retrieve_command(dev, buf, count, 0x0080, 0x0080);
789 }
790
791 /*
792         "write" request on "retrieve_amp_setup" special file.
793 */
794 static ssize_t pod_set_retrieve_amp_setup(struct device *dev,
795                                           struct device_attribute *attr,
796                                           const char *buf, size_t count)
797 {
798         return pod_send_retrieve_command(dev, buf, count, 0x0040, 0x0100);
799 }
800
801 /*
802         "read" request on "dirty" special file.
803 */
804 static ssize_t pod_get_dirty(struct device *dev, struct device_attribute *attr,
805                              char *buf)
806 {
807         struct usb_interface *interface = to_usb_interface(dev);
808         struct usb_line6_pod *pod = usb_get_intfdata(interface);
809         buf[0] = pod->dirty ? '1' : '0';
810         buf[1] = '\n';
811         return 2;
812 }
813
814 /*
815         "read" request on "midi_postprocess" special file.
816 */
817 static ssize_t pod_get_midi_postprocess(struct device *dev,
818                                         struct device_attribute *attr,
819                                         char *buf)
820 {
821         struct usb_interface *interface = to_usb_interface(dev);
822         struct usb_line6_pod *pod = usb_get_intfdata(interface);
823         return sprintf(buf, "%d\n", pod->midi_postprocess);
824 }
825
826 /*
827         "write" request on "midi_postprocess" special file.
828 */
829 static ssize_t pod_set_midi_postprocess(struct device *dev,
830                                         struct device_attribute *attr,
831                                         const char *buf, size_t count)
832 {
833         struct usb_interface *interface = to_usb_interface(dev);
834         struct usb_line6_pod *pod = usb_get_intfdata(interface);
835         u8 value;
836         int ret;
837
838         ret = kstrtou8(buf, 10, &value);
839         if (ret)
840                 return ret;
841
842         pod->midi_postprocess = value ? 1 : 0;
843         return count;
844 }
845
846 /*
847         "read" request on "serial_number" special file.
848 */
849 static ssize_t pod_get_serial_number(struct device *dev,
850                                      struct device_attribute *attr, char *buf)
851 {
852         struct usb_interface *interface = to_usb_interface(dev);
853         struct usb_line6_pod *pod = usb_get_intfdata(interface);
854         return sprintf(buf, "%d\n", pod->serial_number);
855 }
856
857 /*
858         "read" request on "firmware_version" special file.
859 */
860 static ssize_t pod_get_firmware_version(struct device *dev,
861                                         struct device_attribute *attr,
862                                         char *buf)
863 {
864         struct usb_interface *interface = to_usb_interface(dev);
865         struct usb_line6_pod *pod = usb_get_intfdata(interface);
866         return sprintf(buf, "%d.%02d\n", pod->firmware_version / 100,
867                        pod->firmware_version % 100);
868 }
869
870 /*
871         "read" request on "device_id" special file.
872 */
873 static ssize_t pod_get_device_id(struct device *dev,
874                                  struct device_attribute *attr, char *buf)
875 {
876         struct usb_interface *interface = to_usb_interface(dev);
877         struct usb_line6_pod *pod = usb_get_intfdata(interface);
878         return sprintf(buf, "%d\n", pod->device_id);
879 }
880
881 /*
882         "read" request on "clip" special file.
883 */
884 static ssize_t pod_wait_for_clip(struct device *dev,
885                                  struct device_attribute *attr, char *buf)
886 {
887         struct usb_interface *interface = to_usb_interface(dev);
888         struct usb_line6_pod *pod = usb_get_intfdata(interface);
889         return wait_event_interruptible(pod->clipping.wait,
890                                         pod->clipping.value != 0);
891 }
892
893 /*
894         POD startup procedure.
895         This is a sequence of functions with special requirements (e.g., must
896         not run immediately after initialization, must not run in interrupt
897         context). After the last one has finished, the device is ready to use.
898 */
899
900 static void pod_startup1(struct usb_line6_pod *pod)
901 {
902         CHECK_STARTUP_PROGRESS(pod->startup_progress, POD_STARTUP_INIT);
903
904         /* delay startup procedure: */
905         line6_start_timer(&pod->startup_timer, POD_STARTUP_DELAY, pod_startup2,
906                           (unsigned long)pod);
907 }
908
909 static void pod_startup2(unsigned long data)
910 {
911         struct usb_line6_pod *pod = (struct usb_line6_pod *)data;
912
913         /* schedule another startup procedure until startup is complete: */
914         if (pod->startup_progress >= POD_STARTUP_LAST)
915                 return;
916
917         pod->startup_progress = POD_STARTUP_DUMPREQ;
918         line6_start_timer(&pod->startup_timer, POD_STARTUP_DELAY, pod_startup2,
919                           (unsigned long)pod);
920
921         /* current channel dump: */
922         line6_dump_request_async(&pod->dumpreq, &pod->line6, 0,
923                                  LINE6_DUMP_CURRENT);
924 }
925
926 static void pod_startup3(struct usb_line6_pod *pod)
927 {
928         struct usb_line6 *line6 = &pod->line6;
929         CHECK_STARTUP_PROGRESS(pod->startup_progress, POD_STARTUP_VERSIONREQ);
930
931         /* request firmware version: */
932         line6_version_request_async(line6);
933 }
934
935 static void pod_startup4(struct usb_line6_pod *pod)
936 {
937         CHECK_STARTUP_PROGRESS(pod->startup_progress, POD_STARTUP_WORKQUEUE);
938
939         /* schedule work for global work queue: */
940         schedule_work(&pod->startup_work);
941 }
942
943 static void pod_startup5(struct work_struct *work)
944 {
945         struct usb_line6_pod *pod =
946             container_of(work, struct usb_line6_pod, startup_work);
947         struct usb_line6 *line6 = &pod->line6;
948
949         CHECK_STARTUP_PROGRESS(pod->startup_progress, POD_STARTUP_SETUP);
950
951         /* serial number: */
952         line6_read_serial_number(&pod->line6, &pod->serial_number);
953
954         /* ALSA audio interface: */
955         line6_register_audio(line6);
956
957         /* device files: */
958         line6_pod_create_files(pod->firmware_version,
959                                line6->properties->device_bit, line6->ifcdev);
960 }
961
962 #define POD_GET_SYSTEM_PARAM(code, sign) \
963 static ssize_t pod_get_ ## code(struct device *dev, \
964                                 struct device_attribute *attr, char *buf) \
965 { \
966         struct usb_interface *interface = to_usb_interface(dev); \
967         struct usb_line6_pod *pod = usb_get_intfdata(interface); \
968         return pod_get_system_param_string(pod, buf, POD_ ## code,      \
969                                            &pod->code, sign);           \
970 }
971
972 #define POD_GET_SET_SYSTEM_PARAM(code, mask, sign) \
973 POD_GET_SYSTEM_PARAM(code, sign) \
974 static ssize_t pod_set_ ## code(struct device *dev, \
975                                 struct device_attribute *attr, \
976                                 const char *buf, size_t count) \
977 { \
978         struct usb_interface *interface = to_usb_interface(dev); \
979         struct usb_line6_pod *pod = usb_get_intfdata(interface); \
980         return pod_set_system_param_string(pod, buf, count, POD_ ## code, mask); \
981 }
982
983 POD_GET_SET_SYSTEM_PARAM(monitor_level, 0xffff, 0);
984 POD_GET_SET_SYSTEM_PARAM(routing, 0x0003, 0);
985 POD_GET_SET_SYSTEM_PARAM(tuner_mute, 0x0001, 0);
986 POD_GET_SET_SYSTEM_PARAM(tuner_freq, 0xffff, 0);
987 POD_GET_SYSTEM_PARAM(tuner_note, 1);
988 POD_GET_SYSTEM_PARAM(tuner_pitch, 1);
989
990 #undef GET_SET_SYSTEM_PARAM
991 #undef GET_SYSTEM_PARAM
992
993 /* POD special files: */
994 static DEVICE_ATTR(clip, S_IRUGO, pod_wait_for_clip, line6_nop_write);
995 static DEVICE_ATTR(device_id, S_IRUGO, pod_get_device_id, line6_nop_write);
996 static DEVICE_ATTR(dirty, S_IRUGO, pod_get_dirty, line6_nop_write);
997 static DEVICE_ATTR(dump, S_IWUSR | S_IRUGO, pod_get_dump, pod_set_dump);
998 static DEVICE_ATTR(dump_buf, S_IWUSR | S_IRUGO, pod_get_dump_buf,
999                    pod_set_dump_buf);
1000 static DEVICE_ATTR(finish, S_IWUSR, line6_nop_read, pod_set_finish);
1001 static DEVICE_ATTR(firmware_version, S_IRUGO, pod_get_firmware_version,
1002                    line6_nop_write);
1003 static DEVICE_ATTR(midi_postprocess, S_IWUSR | S_IRUGO,
1004                    pod_get_midi_postprocess, pod_set_midi_postprocess);
1005 static DEVICE_ATTR(monitor_level, S_IWUSR | S_IRUGO, pod_get_monitor_level,
1006                    pod_set_monitor_level);
1007 static DEVICE_ATTR(name, S_IRUGO, pod_get_name, line6_nop_write);
1008 static DEVICE_ATTR(name_buf, S_IRUGO, pod_get_name_buf, line6_nop_write);
1009 static DEVICE_ATTR(retrieve_amp_setup, S_IWUSR, line6_nop_read,
1010                    pod_set_retrieve_amp_setup);
1011 static DEVICE_ATTR(retrieve_channel, S_IWUSR, line6_nop_read,
1012                    pod_set_retrieve_channel);
1013 static DEVICE_ATTR(retrieve_effects_setup, S_IWUSR, line6_nop_read,
1014                    pod_set_retrieve_effects_setup);
1015 static DEVICE_ATTR(routing, S_IWUSR | S_IRUGO, pod_get_routing,
1016                    pod_set_routing);
1017 static DEVICE_ATTR(serial_number, S_IRUGO, pod_get_serial_number,
1018                    line6_nop_write);
1019 static DEVICE_ATTR(store_amp_setup, S_IWUSR, line6_nop_read,
1020                    pod_set_store_amp_setup);
1021 static DEVICE_ATTR(store_channel, S_IWUSR, line6_nop_read,
1022                    pod_set_store_channel);
1023 static DEVICE_ATTR(store_effects_setup, S_IWUSR, line6_nop_read,
1024                    pod_set_store_effects_setup);
1025 static DEVICE_ATTR(tuner_freq, S_IWUSR | S_IRUGO, pod_get_tuner_freq,
1026                    pod_set_tuner_freq);
1027 static DEVICE_ATTR(tuner_mute, S_IWUSR | S_IRUGO, pod_get_tuner_mute,
1028                    pod_set_tuner_mute);
1029 static DEVICE_ATTR(tuner_note, S_IRUGO, pod_get_tuner_note, line6_nop_write);
1030 static DEVICE_ATTR(tuner_pitch, S_IRUGO, pod_get_tuner_pitch, line6_nop_write);
1031
1032 #ifdef CONFIG_LINE6_USB_RAW
1033 static DEVICE_ATTR(raw, S_IWUSR, line6_nop_read, line6_set_raw);
1034 #endif
1035
1036 /* control info callback */
1037 static int snd_pod_control_monitor_info(struct snd_kcontrol *kcontrol,
1038                                         struct snd_ctl_elem_info *uinfo)
1039 {
1040         uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
1041         uinfo->count = 1;
1042         uinfo->value.integer.min = 0;
1043         uinfo->value.integer.max = 65535;
1044         return 0;
1045 }
1046
1047 /* control get callback */
1048 static int snd_pod_control_monitor_get(struct snd_kcontrol *kcontrol,
1049                                        struct snd_ctl_elem_value *ucontrol)
1050 {
1051         struct snd_line6_pcm *line6pcm = snd_kcontrol_chip(kcontrol);
1052         struct usb_line6_pod *pod = (struct usb_line6_pod *)line6pcm->line6;
1053         ucontrol->value.integer.value[0] = pod->monitor_level.value;
1054         return 0;
1055 }
1056
1057 /* control put callback */
1058 static int snd_pod_control_monitor_put(struct snd_kcontrol *kcontrol,
1059                                        struct snd_ctl_elem_value *ucontrol)
1060 {
1061         struct snd_line6_pcm *line6pcm = snd_kcontrol_chip(kcontrol);
1062         struct usb_line6_pod *pod = (struct usb_line6_pod *)line6pcm->line6;
1063
1064         if (ucontrol->value.integer.value[0] == pod->monitor_level.value)
1065                 return 0;
1066
1067         pod->monitor_level.value = ucontrol->value.integer.value[0];
1068         pod_set_system_param_int(pod, ucontrol->value.integer.value[0],
1069                                  POD_monitor_level);
1070         return 1;
1071 }
1072
1073 /* control definition */
1074 static struct snd_kcontrol_new pod_control_monitor = {
1075         .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1076         .name = "Monitor Playback Volume",
1077         .index = 0,
1078         .access = SNDRV_CTL_ELEM_ACCESS_READWRITE,
1079         .info = snd_pod_control_monitor_info,
1080         .get = snd_pod_control_monitor_get,
1081         .put = snd_pod_control_monitor_put
1082 };
1083
1084 /*
1085         POD destructor.
1086 */
1087 static void pod_destruct(struct usb_interface *interface)
1088 {
1089         struct usb_line6_pod *pod = usb_get_intfdata(interface);
1090
1091         if (pod == NULL)
1092                 return;
1093         line6_cleanup_audio(&pod->line6);
1094
1095         del_timer(&pod->startup_timer);
1096         cancel_work_sync(&pod->startup_work);
1097
1098         /* free dump request data: */
1099         line6_dumpreq_destruct(&pod->dumpreq);
1100 }
1101
1102 /*
1103         Create sysfs entries.
1104 */
1105 static int pod_create_files2(struct device *dev)
1106 {
1107         int err;
1108
1109         CHECK_RETURN(device_create_file(dev, &dev_attr_clip));
1110         CHECK_RETURN(device_create_file(dev, &dev_attr_device_id));
1111         CHECK_RETURN(device_create_file(dev, &dev_attr_dirty));
1112         CHECK_RETURN(device_create_file(dev, &dev_attr_dump));
1113         CHECK_RETURN(device_create_file(dev, &dev_attr_dump_buf));
1114         CHECK_RETURN(device_create_file(dev, &dev_attr_finish));
1115         CHECK_RETURN(device_create_file(dev, &dev_attr_firmware_version));
1116         CHECK_RETURN(device_create_file(dev, &dev_attr_midi_postprocess));
1117         CHECK_RETURN(device_create_file(dev, &dev_attr_monitor_level));
1118         CHECK_RETURN(device_create_file(dev, &dev_attr_name));
1119         CHECK_RETURN(device_create_file(dev, &dev_attr_name_buf));
1120         CHECK_RETURN(device_create_file(dev, &dev_attr_retrieve_amp_setup));
1121         CHECK_RETURN(device_create_file(dev, &dev_attr_retrieve_channel));
1122         CHECK_RETURN(device_create_file(dev, &dev_attr_retrieve_effects_setup));
1123         CHECK_RETURN(device_create_file(dev, &dev_attr_routing));
1124         CHECK_RETURN(device_create_file(dev, &dev_attr_serial_number));
1125         CHECK_RETURN(device_create_file(dev, &dev_attr_store_amp_setup));
1126         CHECK_RETURN(device_create_file(dev, &dev_attr_store_channel));
1127         CHECK_RETURN(device_create_file(dev, &dev_attr_store_effects_setup));
1128         CHECK_RETURN(device_create_file(dev, &dev_attr_tuner_freq));
1129         CHECK_RETURN(device_create_file(dev, &dev_attr_tuner_mute));
1130         CHECK_RETURN(device_create_file(dev, &dev_attr_tuner_note));
1131         CHECK_RETURN(device_create_file(dev, &dev_attr_tuner_pitch));
1132
1133 #ifdef CONFIG_LINE6_USB_RAW
1134         CHECK_RETURN(device_create_file(dev, &dev_attr_raw));
1135 #endif
1136
1137         return 0;
1138 }
1139
1140 /*
1141          Try to init POD device.
1142 */
1143 static int pod_try_init(struct usb_interface *interface,
1144                         struct usb_line6_pod *pod)
1145 {
1146         int err;
1147         struct usb_line6 *line6 = &pod->line6;
1148
1149         init_timer(&pod->startup_timer);
1150         INIT_WORK(&pod->startup_work, pod_startup5);
1151
1152         if ((interface == NULL) || (pod == NULL))
1153                 return -ENODEV;
1154
1155         /* initialize wait queues: */
1156         init_waitqueue_head(&pod->monitor_level.wait);
1157         init_waitqueue_head(&pod->routing.wait);
1158         init_waitqueue_head(&pod->tuner_mute.wait);
1159         init_waitqueue_head(&pod->tuner_freq.wait);
1160         init_waitqueue_head(&pod->tuner_note.wait);
1161         init_waitqueue_head(&pod->tuner_pitch.wait);
1162         init_waitqueue_head(&pod->clipping.wait);
1163
1164         memset(pod->param_dirty, 0xff, sizeof(pod->param_dirty));
1165
1166         /* initialize USB buffers: */
1167         err = line6_dumpreq_init(&pod->dumpreq, pod_request_channel,
1168                                  sizeof(pod_request_channel));
1169         if (err < 0) {
1170                 dev_err(&interface->dev, "Out of memory\n");
1171                 return -ENOMEM;
1172         }
1173
1174         /* create sysfs entries: */
1175         err = pod_create_files2(&interface->dev);
1176         if (err < 0)
1177                 return err;
1178
1179         /* initialize audio system: */
1180         err = line6_init_audio(line6);
1181         if (err < 0)
1182                 return err;
1183
1184         /* initialize MIDI subsystem: */
1185         err = line6_init_midi(line6);
1186         if (err < 0)
1187                 return err;
1188
1189         /* initialize PCM subsystem: */
1190         err = line6_init_pcm(line6, &pod_pcm_properties);
1191         if (err < 0)
1192                 return err;
1193
1194         /* register monitor control: */
1195         err = snd_ctl_add(line6->card,
1196                           snd_ctl_new1(&pod_control_monitor, line6->line6pcm));
1197         if (err < 0)
1198                 return err;
1199
1200         /*
1201            When the sound card is registered at this point, the PODxt Live
1202            displays "Invalid Code Error 07", so we do it later in the event
1203            handler.
1204          */
1205
1206         if (pod->line6.properties->capabilities & LINE6_BIT_CONTROL) {
1207                 pod->monitor_level.value = POD_system_invalid;
1208
1209                 /* initiate startup procedure: */
1210                 pod_startup1(pod);
1211         }
1212
1213         return 0;
1214 }
1215
1216 /*
1217          Init POD device (and clean up in case of failure).
1218 */
1219 int line6_pod_init(struct usb_interface *interface, struct usb_line6_pod *pod)
1220 {
1221         int err = pod_try_init(interface, pod);
1222
1223         if (err < 0)
1224                 pod_destruct(interface);
1225
1226         return err;
1227 }
1228
1229 /*
1230         POD device disconnected.
1231 */
1232 void line6_pod_disconnect(struct usb_interface *interface)
1233 {
1234         struct usb_line6_pod *pod;
1235
1236         if (interface == NULL)
1237                 return;
1238         pod = usb_get_intfdata(interface);
1239
1240         if (pod != NULL) {
1241                 struct snd_line6_pcm *line6pcm = pod->line6.line6pcm;
1242                 struct device *dev = &interface->dev;
1243
1244                 if (line6pcm != NULL)
1245                         line6_pcm_disconnect(line6pcm);
1246
1247                 if (dev != NULL) {
1248                         /* remove sysfs entries: */
1249                         line6_pod_remove_files(pod->firmware_version,
1250                                                pod->line6.
1251                                                properties->device_bit, dev);
1252
1253                         device_remove_file(dev, &dev_attr_clip);
1254                         device_remove_file(dev, &dev_attr_device_id);
1255                         device_remove_file(dev, &dev_attr_dirty);
1256                         device_remove_file(dev, &dev_attr_dump);
1257                         device_remove_file(dev, &dev_attr_dump_buf);
1258                         device_remove_file(dev, &dev_attr_finish);
1259                         device_remove_file(dev, &dev_attr_firmware_version);
1260                         device_remove_file(dev, &dev_attr_midi_postprocess);
1261                         device_remove_file(dev, &dev_attr_monitor_level);
1262                         device_remove_file(dev, &dev_attr_name);
1263                         device_remove_file(dev, &dev_attr_name_buf);
1264                         device_remove_file(dev, &dev_attr_retrieve_amp_setup);
1265                         device_remove_file(dev, &dev_attr_retrieve_channel);
1266                         device_remove_file(dev,
1267                                            &dev_attr_retrieve_effects_setup);
1268                         device_remove_file(dev, &dev_attr_routing);
1269                         device_remove_file(dev, &dev_attr_serial_number);
1270                         device_remove_file(dev, &dev_attr_store_amp_setup);
1271                         device_remove_file(dev, &dev_attr_store_channel);
1272                         device_remove_file(dev, &dev_attr_store_effects_setup);
1273                         device_remove_file(dev, &dev_attr_tuner_freq);
1274                         device_remove_file(dev, &dev_attr_tuner_mute);
1275                         device_remove_file(dev, &dev_attr_tuner_note);
1276                         device_remove_file(dev, &dev_attr_tuner_pitch);
1277
1278 #ifdef CONFIG_LINE6_USB_RAW
1279                         device_remove_file(dev, &dev_attr_raw);
1280 #endif
1281                 }
1282         }
1283
1284         pod_destruct(interface);
1285 }