Commit 16dc10401133d16d13a5eea7da2a71d2080e32a1

Authored by Stefan Hajnoczi
Committed by Greg Kroah-Hartman
1 parent 982d6ab501

staging: line6: add Pod HD300 support

The Pod HD device family uses new MIDI SysEx messages and therefore
cannot reuse the existing Pod code.  Instead of hardcoding Pod HD MIDI
messages into the driver, leave MIDI up to userspace.  This driver
simply presents MIDI and pcm ALSA devices.

This device is similar to the Pod except that it has 48 kHz audio and
does not respond to Pod SysEx messages.

Signed-off-by: Stefan Hajnoczi <stefanha@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>

Showing 6 changed files with 216 additions and 2 deletions Side-by-side Diff

drivers/staging/line6/Makefile
... ... @@ -12,5 +12,6 @@
12 12 playback.o \
13 13 pod.o \
14 14 toneport.o \
15   - variax.o
  15 + variax.o \
  16 + podhd.o
drivers/staging/line6/driver.c
... ... @@ -21,6 +21,7 @@
21 21 #include "midi.h"
22 22 #include "playback.h"
23 23 #include "pod.h"
  24 +#include "podhd.h"
24 25 #include "revision.h"
25 26 #include "toneport.h"
26 27 #include "usbdefs.h"
... ... @@ -49,6 +50,7 @@
49 50 {USB_DEVICE(LINE6_VENDOR_ID, LINE6_DEVID_TONEPORT_UX1)},
50 51 {USB_DEVICE(LINE6_VENDOR_ID, LINE6_DEVID_TONEPORT_UX2)},
51 52 {USB_DEVICE(LINE6_VENDOR_ID, LINE6_DEVID_VARIAX)},
  53 + {USB_DEVICE(LINE6_VENDOR_ID, LINE6_DEVID_PODHD300)},
52 54 {},
53 55 };
54 56  
... ... @@ -72,7 +74,8 @@
72 74 { "TonePortGX", "TonePort GX", LINE6_BIT_TONEPORT_GX, LINE6_BIT_PCM },
73 75 { "TonePortUX1", "TonePort UX1", LINE6_BIT_TONEPORT_UX1, LINE6_BIT_PCM },
74 76 { "TonePortUX2", "TonePort UX2", LINE6_BIT_TONEPORT_UX2, LINE6_BIT_PCM },
75   - { "Variax", "Variax Workbench", LINE6_BIT_VARIAX, LINE6_BIT_CONTROL }
  77 + { "Variax", "Variax Workbench", LINE6_BIT_VARIAX, LINE6_BIT_CONTROL },
  78 + { "PODHD300", "POD HD300", LINE6_BIT_PODHD300, LINE6_BIT_CONTROL_PCM_HWMON },
76 79 };
77 80 /* *INDENT-ON* */
78 81  
... ... @@ -437,6 +440,9 @@
437 440 line6);
438 441 break;
439 442  
  443 + case LINE6_DEVID_PODHD300:
  444 + break; /* let userspace handle MIDI */
  445 +
440 446 case LINE6_DEVID_PODXTLIVE:
441 447 switch (line6->interface_number) {
442 448 case PODXTLIVE_INTERFACE_POD:
... ... @@ -812,6 +818,7 @@
812 818 case LINE6_DEVID_BASSPODXTPRO:
813 819 case LINE6_DEVID_PODXT:
814 820 case LINE6_DEVID_PODXTPRO:
  821 + case LINE6_DEVID_PODHD300:
815 822 alternate = 5;
816 823 break;
817 824  
... ... @@ -865,6 +872,12 @@
865 872 ep_write = 0x03;
866 873 break;
867 874  
  875 + case LINE6_DEVID_PODHD300:
  876 + size = sizeof(struct usb_line6_podhd);
  877 + ep_read = 0x84;
  878 + ep_write = 0x03;
  879 + break;
  880 +
868 881 case LINE6_DEVID_POCKETPOD:
869 882 size = sizeof(struct usb_line6_pod);
870 883 ep_read = 0x82;
... ... @@ -1017,6 +1030,11 @@
1017 1030 ret = line6_pod_init(interface, (struct usb_line6_pod *)line6);
1018 1031 break;
1019 1032  
  1033 + case LINE6_DEVID_PODHD300:
  1034 + ret = line6_podhd_init(interface,
  1035 + (struct usb_line6_podhd *)line6);
  1036 + break;
  1037 +
1020 1038 case LINE6_DEVID_PODXTLIVE:
1021 1039 switch (interface_number) {
1022 1040 case PODXTLIVE_INTERFACE_POD:
... ... @@ -1137,6 +1155,10 @@
1137 1155 case LINE6_DEVID_PODXT:
1138 1156 case LINE6_DEVID_PODXTPRO:
1139 1157 line6_pod_disconnect(interface);
  1158 + break;
  1159 +
  1160 + case LINE6_DEVID_PODHD300:
  1161 + line6_podhd_disconnect(interface);
1140 1162 break;
1141 1163  
1142 1164 case LINE6_DEVID_PODXTLIVE:
drivers/staging/line6/pcm.c
... ... @@ -403,6 +403,7 @@
403 403 case LINE6_DEVID_PODXT:
404 404 case LINE6_DEVID_PODXTLIVE:
405 405 case LINE6_DEVID_PODXTPRO:
  406 + case LINE6_DEVID_PODHD300:
406 407 ep_read = 0x82;
407 408 ep_write = 0x01;
408 409 break;
drivers/staging/line6/podhd.c
  1 +/*
  2 + * Line6 Pod HD
  3 + *
  4 + * Copyright (C) 2011 Stefan Hajnoczi <stefanha@gmail.com>
  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 <sound/core.h>
  13 +#include <sound/pcm.h>
  14 +
  15 +#include "audio.h"
  16 +#include "driver.h"
  17 +#include "pcm.h"
  18 +#include "podhd.h"
  19 +
  20 +#define PODHD_BYTES_PER_FRAME 6 /* 24bit audio (stereo) */
  21 +
  22 +static struct snd_ratden podhd_ratden = {
  23 + .num_min = 48000,
  24 + .num_max = 48000,
  25 + .num_step = 1,
  26 + .den = 1,
  27 +};
  28 +
  29 +static struct line6_pcm_properties podhd_pcm_properties = {
  30 + .snd_line6_playback_hw = {
  31 + .info = (SNDRV_PCM_INFO_MMAP |
  32 + SNDRV_PCM_INFO_INTERLEAVED |
  33 + SNDRV_PCM_INFO_BLOCK_TRANSFER |
  34 + SNDRV_PCM_INFO_MMAP_VALID |
  35 + SNDRV_PCM_INFO_PAUSE |
  36 +#ifdef CONFIG_PM
  37 + SNDRV_PCM_INFO_RESUME |
  38 +#endif
  39 + SNDRV_PCM_INFO_SYNC_START),
  40 + .formats = SNDRV_PCM_FMTBIT_S24_3LE,
  41 + .rates = SNDRV_PCM_RATE_48000,
  42 + .rate_min = 48000,
  43 + .rate_max = 48000,
  44 + .channels_min = 2,
  45 + .channels_max = 2,
  46 + .buffer_bytes_max = 60000,
  47 + .period_bytes_min = 64,
  48 + .period_bytes_max = 8192,
  49 + .periods_min = 1,
  50 + .periods_max = 1024},
  51 + .snd_line6_capture_hw = {
  52 + .info = (SNDRV_PCM_INFO_MMAP |
  53 + SNDRV_PCM_INFO_INTERLEAVED |
  54 + SNDRV_PCM_INFO_BLOCK_TRANSFER |
  55 + SNDRV_PCM_INFO_MMAP_VALID |
  56 +#ifdef CONFIG_PM
  57 + SNDRV_PCM_INFO_RESUME |
  58 +#endif
  59 + SNDRV_PCM_INFO_SYNC_START),
  60 + .formats = SNDRV_PCM_FMTBIT_S24_3LE,
  61 + .rates = SNDRV_PCM_RATE_48000,
  62 + .rate_min = 48000,
  63 + .rate_max = 48000,
  64 + .channels_min = 2,
  65 + .channels_max = 2,
  66 + .buffer_bytes_max = 60000,
  67 + .period_bytes_min = 64,
  68 + .period_bytes_max = 8192,
  69 + .periods_min = 1,
  70 + .periods_max = 1024},
  71 + .snd_line6_rates = {
  72 + .nrats = 1,
  73 + .rats = &podhd_ratden},
  74 + .bytes_per_frame = PODHD_BYTES_PER_FRAME
  75 +};
  76 +
  77 +/*
  78 + POD HD destructor.
  79 +*/
  80 +static void podhd_destruct(struct usb_interface *interface)
  81 +{
  82 + struct usb_line6_podhd *podhd = usb_get_intfdata(interface);
  83 + struct usb_line6 *line6;
  84 +
  85 + if (podhd == NULL)
  86 + return;
  87 + line6 = &podhd->line6;
  88 + if (line6 == NULL)
  89 + return;
  90 + line6_cleanup_audio(line6);
  91 +}
  92 +
  93 +/*
  94 + Try to init POD HD device.
  95 +*/
  96 +static int podhd_try_init(struct usb_interface *interface,
  97 + struct usb_line6_podhd *podhd)
  98 +{
  99 + int err;
  100 + struct usb_line6 *line6 = &podhd->line6;
  101 +
  102 + if ((interface == NULL) || (podhd == NULL))
  103 + return -ENODEV;
  104 +
  105 + /* initialize audio system: */
  106 + err = line6_init_audio(line6);
  107 + if (err < 0)
  108 + return err;
  109 +
  110 + /* initialize MIDI subsystem: */
  111 + err = line6_init_midi(line6);
  112 + if (err < 0)
  113 + return err;
  114 +
  115 + /* initialize PCM subsystem: */
  116 + err = line6_init_pcm(line6, &podhd_pcm_properties);
  117 + if (err < 0)
  118 + return err;
  119 +
  120 + /* register USB audio system: */
  121 + err = line6_register_audio(line6);
  122 + return err;
  123 +}
  124 +
  125 +/*
  126 + Init POD HD device (and clean up in case of failure).
  127 +*/
  128 +int line6_podhd_init(struct usb_interface *interface,
  129 + struct usb_line6_podhd *podhd)
  130 +{
  131 + int err = podhd_try_init(interface, podhd);
  132 +
  133 + if (err < 0)
  134 + podhd_destruct(interface);
  135 +
  136 + return err;
  137 +}
  138 +
  139 +/*
  140 + POD HD device disconnected.
  141 +*/
  142 +void line6_podhd_disconnect(struct usb_interface *interface)
  143 +{
  144 + struct usb_line6_podhd *podhd;
  145 +
  146 + if (interface == NULL)
  147 + return;
  148 + podhd = usb_get_intfdata(interface);
  149 +
  150 + if (podhd != NULL) {
  151 + struct snd_line6_pcm *line6pcm = podhd->line6.line6pcm;
  152 +
  153 + if (line6pcm != NULL)
  154 + line6_pcm_disconnect(line6pcm);
  155 + }
  156 +
  157 + podhd_destruct(interface);
  158 +}
drivers/staging/line6/podhd.h
  1 +/*
  2 + * Line6 Pod HD
  3 + *
  4 + * Copyright (C) 2011 Stefan Hajnoczi <stefanha@gmail.com>
  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 +#ifndef PODHD_H
  13 +#define PODHD_H
  14 +
  15 +#include <linux/usb.h>
  16 +
  17 +#include "driver.h"
  18 +
  19 +struct usb_line6_podhd {
  20 + /**
  21 + Generic Line6 USB data.
  22 + */
  23 + struct usb_line6 line6;
  24 +};
  25 +
  26 +extern void line6_podhd_disconnect(struct usb_interface *interface);
  27 +extern int line6_podhd_init(struct usb_interface *interface,
  28 + struct usb_line6_podhd *podhd);
  29 +
  30 +#endif /* PODHD_H */
drivers/staging/line6/usbdefs.h
... ... @@ -36,6 +36,7 @@
36 36 #define LINE6_DEVID_TONEPORT_UX1 0x4141
37 37 #define LINE6_DEVID_TONEPORT_UX2 0x4142
38 38 #define LINE6_DEVID_VARIAX 0x534d
  39 +#define LINE6_DEVID_PODHD300 0x5057
39 40  
40 41 #define LINE6_BIT_BASSPODXT (1 << 0)
41 42 #define LINE6_BIT_BASSPODXTLIVE (1 << 1)
... ... @@ -54,6 +55,7 @@
54 55 #define LINE6_BIT_TONEPORT_UX1 (1 << 14)
55 56 #define LINE6_BIT_TONEPORT_UX2 (1 << 15)
56 57 #define LINE6_BIT_VARIAX (1 << 16)
  58 +#define LINE6_BIT_PODHD300 (1 << 17)
57 59  
58 60 #define LINE6_BITS_PRO (LINE6_BIT_BASSPODXTPRO | \
59 61 LINE6_BIT_PODXTPRO)