aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/staging/line6/toneport.c
diff options
context:
space:
mode:
authorMarkus Grabner <grabner@icg.tugraz.at>2010-08-22 19:08:25 -0400
committerGreg Kroah-Hartman <gregkh@suse.de>2010-08-31 18:28:16 -0400
commite1a164d7a3e05aae15eb603ee8f1b77446480a3b (patch)
tree829d6ed586e9fe3680be24faab8c61d5c596443e /drivers/staging/line6/toneport.c
parent1027f476f507ef7ed9919cd3e3d32310f3985da1 (diff)
Staging: line6: another upstream sync
Everything should be in sync now. Signed-off-by: Markus Grabner <grabner@icg.tugraz.at> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/staging/line6/toneport.c')
-rw-r--r--drivers/staging/line6/toneport.c143
1 files changed, 77 insertions, 66 deletions
diff --git a/drivers/staging/line6/toneport.c b/drivers/staging/line6/toneport.c
index 0e7e871507c..d4ac734d744 100644
--- a/drivers/staging/line6/toneport.c
+++ b/drivers/staging/line6/toneport.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * Line6 Linux USB driver - 0.9.0 2 * Line6 Linux USB driver - 0.9.1beta
3 * 3 *
4 * Copyright (C) 2004-2010 Markus Grabner (grabner@icg.tugraz.at) 4 * Copyright (C) 2004-2010 Markus Grabner (grabner@icg.tugraz.at)
5 * Emil Myhrman (emil.myhrman@gmail.com) 5 * Emil Myhrman (emil.myhrman@gmail.com)
@@ -19,13 +19,10 @@
19#include "playback.h" 19#include "playback.h"
20#include "toneport.h" 20#include "toneport.h"
21 21
22
23static int toneport_send_cmd(struct usb_device *usbdev, int cmd1, int cmd2); 22static int toneport_send_cmd(struct usb_device *usbdev, int cmd1, int cmd2);
24 23
25
26#define TONEPORT_PCM_DELAY 1 24#define TONEPORT_PCM_DELAY 1
27 25
28
29static struct snd_ratden toneport_ratden = { 26static struct snd_ratden toneport_ratden = {
30 .num_min = 44100, 27 .num_min = 44100,
31 .num_max = 44100, 28 .num_max = 44100,
@@ -35,52 +32,49 @@ static struct snd_ratden toneport_ratden = {
35 32
36static struct line6_pcm_properties toneport_pcm_properties = { 33static struct line6_pcm_properties toneport_pcm_properties = {
37 .snd_line6_playback_hw = { 34 .snd_line6_playback_hw = {
38 .info = (SNDRV_PCM_INFO_MMAP | 35 .info = (SNDRV_PCM_INFO_MMAP |
39 SNDRV_PCM_INFO_INTERLEAVED | 36 SNDRV_PCM_INFO_INTERLEAVED |
40 SNDRV_PCM_INFO_BLOCK_TRANSFER | 37 SNDRV_PCM_INFO_BLOCK_TRANSFER |
41 SNDRV_PCM_INFO_MMAP_VALID | 38 SNDRV_PCM_INFO_MMAP_VALID |
42 SNDRV_PCM_INFO_PAUSE | 39 SNDRV_PCM_INFO_PAUSE |
43#ifdef CONFIG_PM 40#ifdef CONFIG_PM
44 SNDRV_PCM_INFO_RESUME | 41 SNDRV_PCM_INFO_RESUME |
45#endif 42#endif
46 SNDRV_PCM_INFO_SYNC_START), 43 SNDRV_PCM_INFO_SYNC_START),
47 .formats = SNDRV_PCM_FMTBIT_S16_LE, 44 .formats = SNDRV_PCM_FMTBIT_S16_LE,
48 .rates = SNDRV_PCM_RATE_KNOT, 45 .rates = SNDRV_PCM_RATE_KNOT,
49 .rate_min = 44100, 46 .rate_min = 44100,
50 .rate_max = 44100, 47 .rate_max = 44100,
51 .channels_min = 2, 48 .channels_min = 2,
52 .channels_max = 2, 49 .channels_max = 2,
53 .buffer_bytes_max = 60000, 50 .buffer_bytes_max = 60000,
54 .period_bytes_min = 64, 51 .period_bytes_min = 64,
55 .period_bytes_max = 8192, 52 .period_bytes_max = 8192,
56 .periods_min = 1, 53 .periods_min = 1,
57 .periods_max = 1024 54 .periods_max = 1024},
58 },
59 .snd_line6_capture_hw = { 55 .snd_line6_capture_hw = {
60 .info = (SNDRV_PCM_INFO_MMAP | 56 .info = (SNDRV_PCM_INFO_MMAP |
61 SNDRV_PCM_INFO_INTERLEAVED | 57 SNDRV_PCM_INFO_INTERLEAVED |
62 SNDRV_PCM_INFO_BLOCK_TRANSFER | 58 SNDRV_PCM_INFO_BLOCK_TRANSFER |
63 SNDRV_PCM_INFO_MMAP_VALID | 59 SNDRV_PCM_INFO_MMAP_VALID |
64#ifdef CONFIG_PM 60#ifdef CONFIG_PM
65 SNDRV_PCM_INFO_RESUME | 61 SNDRV_PCM_INFO_RESUME |
66#endif 62#endif
67 SNDRV_PCM_INFO_SYNC_START), 63 SNDRV_PCM_INFO_SYNC_START),
68 .formats = SNDRV_PCM_FMTBIT_S16_LE, 64 .formats = SNDRV_PCM_FMTBIT_S16_LE,
69 .rates = SNDRV_PCM_RATE_KNOT, 65 .rates = SNDRV_PCM_RATE_KNOT,
70 .rate_min = 44100, 66 .rate_min = 44100,
71 .rate_max = 44100, 67 .rate_max = 44100,
72 .channels_min = 2, 68 .channels_min = 2,
73 .channels_max = 2, 69 .channels_max = 2,
74 .buffer_bytes_max = 60000, 70 .buffer_bytes_max = 60000,
75 .period_bytes_min = 64, 71 .period_bytes_min = 64,
76 .period_bytes_max = 8192, 72 .period_bytes_max = 8192,
77 .periods_min = 1, 73 .periods_min = 1,
78 .periods_max = 1024 74 .periods_max = 1024},
79 },
80 .snd_line6_rates = { 75 .snd_line6_rates = {
81 .nrats = 1, 76 .nrats = 1,
82 .rats = &toneport_ratden 77 .rats = &toneport_ratden},
83 },
84 .bytes_per_frame = 4 78 .bytes_per_frame = 4
85}; 79};
86 80
@@ -93,24 +87,23 @@ static struct line6_pcm_properties toneport_pcm_properties = {
93static int led_red = 0x00; 87static int led_red = 0x00;
94static int led_green = 0x26; 88static int led_green = 0x26;
95 89
96struct ToneportSourceInfo 90struct ToneportSourceInfo {
97{
98 const char *name; 91 const char *name;
99 int code; 92 int code;
100}; 93};
101 94
102static const struct ToneportSourceInfo toneport_source_info[] = { 95static const struct ToneportSourceInfo toneport_source_info[] = {
103 { "Microphone", 0x0a01 }, 96 {"Microphone", 0x0a01},
104 { "Line" , 0x0801 }, 97 {"Line", 0x0801},
105 { "Instrument", 0x0b01 }, 98 {"Instrument", 0x0b01},
106 { "Inst & Mic", 0x0901 } 99 {"Inst & Mic", 0x0901}
107}; 100};
108 101
109static bool toneport_has_led(short product) 102static bool toneport_has_led(short product)
110{ 103{
111 return 104 return
112 (product == LINE6_DEVID_GUITARPORT) || 105 (product == LINE6_DEVID_GUITARPORT) ||
113 (product == LINE6_DEVID_TONEPORT_GX); 106 (product == LINE6_DEVID_TONEPORT_GX);
114 /* add your device here if you are missing support for the LEDs */ 107 /* add your device here if you are missing support for the LEDs */
115} 108}
116 109
@@ -166,7 +159,6 @@ static DEVICE_ATTR(led_red, S_IWUGO | S_IRUGO, line6_nop_read,
166static DEVICE_ATTR(led_green, S_IWUGO | S_IRUGO, line6_nop_read, 159static DEVICE_ATTR(led_green, S_IWUGO | S_IRUGO, line6_nop_read,
167 toneport_set_led_green); 160 toneport_set_led_green);
168 161
169
170static int toneport_send_cmd(struct usb_device *usbdev, int cmd1, int cmd2) 162static int toneport_send_cmd(struct usb_device *usbdev, int cmd1, int cmd2)
171{ 163{
172 int ret; 164 int ret;
@@ -209,10 +201,16 @@ static int snd_toneport_monitor_put(struct snd_kcontrol *kcontrol,
209{ 201{
210 struct snd_line6_pcm *line6pcm = snd_kcontrol_chip(kcontrol); 202 struct snd_line6_pcm *line6pcm = snd_kcontrol_chip(kcontrol);
211 203
212 if(ucontrol->value.integer.value[0] == line6pcm->volume_monitor) 204 if (ucontrol->value.integer.value[0] == line6pcm->volume_monitor)
213 return 0; 205 return 0;
214 206
215 line6pcm->volume_monitor = ucontrol->value.integer.value[0]; 207 line6pcm->volume_monitor = ucontrol->value.integer.value[0];
208
209 if (line6pcm->volume_monitor > 0)
210 line6_pcm_start(line6pcm, MASK_PCM_MONITOR);
211 else
212 line6_pcm_stop(line6pcm, MASK_PCM_MONITOR);
213
216 return 1; 214 return 1;
217} 215}
218 216
@@ -225,7 +223,7 @@ static int snd_toneport_source_info(struct snd_kcontrol *kcontrol,
225 uinfo->count = 1; 223 uinfo->count = 1;
226 uinfo->value.enumerated.items = size; 224 uinfo->value.enumerated.items = size;
227 225
228 if(uinfo->value.enumerated.item >= size) 226 if (uinfo->value.enumerated.item >= size)
229 uinfo->value.enumerated.item = size - 1; 227 uinfo->value.enumerated.item = size - 1;
230 228
231 strcpy(uinfo->value.enumerated.name, 229 strcpy(uinfo->value.enumerated.name,
@@ -239,7 +237,8 @@ static int snd_toneport_source_get(struct snd_kcontrol *kcontrol,
239 struct snd_ctl_elem_value *ucontrol) 237 struct snd_ctl_elem_value *ucontrol)
240{ 238{
241 struct snd_line6_pcm *line6pcm = snd_kcontrol_chip(kcontrol); 239 struct snd_line6_pcm *line6pcm = snd_kcontrol_chip(kcontrol);
242 struct usb_line6_toneport *toneport = (struct usb_line6_toneport *)line6pcm->line6; 240 struct usb_line6_toneport *toneport =
241 (struct usb_line6_toneport *)line6pcm->line6;
243 ucontrol->value.enumerated.item[0] = toneport->source; 242 ucontrol->value.enumerated.item[0] = toneport->source;
244 return 0; 243 return 0;
245} 244}
@@ -249,13 +248,15 @@ static int snd_toneport_source_put(struct snd_kcontrol *kcontrol,
249 struct snd_ctl_elem_value *ucontrol) 248 struct snd_ctl_elem_value *ucontrol)
250{ 249{
251 struct snd_line6_pcm *line6pcm = snd_kcontrol_chip(kcontrol); 250 struct snd_line6_pcm *line6pcm = snd_kcontrol_chip(kcontrol);
252 struct usb_line6_toneport *toneport = (struct usb_line6_toneport *)line6pcm->line6; 251 struct usb_line6_toneport *toneport =
252 (struct usb_line6_toneport *)line6pcm->line6;
253 253
254 if(ucontrol->value.enumerated.item[0] == toneport->source) 254 if (ucontrol->value.enumerated.item[0] == toneport->source)
255 return 0; 255 return 0;
256 256
257 toneport->source = ucontrol->value.enumerated.item[0]; 257 toneport->source = ucontrol->value.enumerated.item[0];
258 toneport_send_cmd(toneport->line6.usbdev, toneport_source_info[toneport->source].code, 0x0000); 258 toneport_send_cmd(toneport->line6.usbdev,
259 toneport_source_info[toneport->source].code, 0x0000);
259 return 1; 260 return 1;
260} 261}
261 262
@@ -321,10 +322,12 @@ static void toneport_setup(struct usb_line6_toneport *toneport)
321 toneport_send_cmd(usbdev, 0x0301, 0x0000); 322 toneport_send_cmd(usbdev, 0x0301, 0x0000);
322 323
323 /* initialize source select: */ 324 /* initialize source select: */
324 switch(usbdev->descriptor.idProduct) { 325 switch (usbdev->descriptor.idProduct) {
325 case LINE6_DEVID_TONEPORT_UX1: 326 case LINE6_DEVID_TONEPORT_UX1:
326 case LINE6_DEVID_PODSTUDIO_UX1: 327 case LINE6_DEVID_PODSTUDIO_UX1:
327 toneport_send_cmd(usbdev, toneport_source_info[toneport->source].code, 0x0000); 328 toneport_send_cmd(usbdev,
329 toneport_source_info[toneport->source].code,
330 0x0000);
328 } 331 }
329 332
330 if (toneport_has_led(usbdev->descriptor.idProduct)) 333 if (toneport_has_led(usbdev->descriptor.idProduct))
@@ -357,16 +360,22 @@ static int toneport_try_init(struct usb_interface *interface,
357 } 360 }
358 361
359 /* register monitor control: */ 362 /* register monitor control: */
360 err = snd_ctl_add(line6->card, snd_ctl_new1(&toneport_control_monitor, line6->line6pcm)); 363 err =
364 snd_ctl_add(line6->card,
365 snd_ctl_new1(&toneport_control_monitor,
366 line6->line6pcm));
361 if (err < 0) { 367 if (err < 0) {
362 return err; 368 return err;
363 } 369 }
364 370
365 /* register source select control: */ 371 /* register source select control: */
366 switch(usbdev->descriptor.idProduct) { 372 switch (usbdev->descriptor.idProduct) {
367 case LINE6_DEVID_TONEPORT_UX1: 373 case LINE6_DEVID_TONEPORT_UX1:
368 case LINE6_DEVID_PODSTUDIO_UX1: 374 case LINE6_DEVID_PODSTUDIO_UX1:
369 err = snd_ctl_add(line6->card, snd_ctl_new1(&toneport_control_source, line6->line6pcm)); 375 err =
376 snd_ctl_add(line6->card,
377 snd_ctl_new1(&toneport_control_source,
378 line6->line6pcm));
370 if (err < 0) { 379 if (err < 0) {
371 return err; 380 return err;
372 } 381 }
@@ -382,8 +391,10 @@ static int toneport_try_init(struct usb_interface *interface,
382 line6_read_data(line6, 0x80c2, &toneport->firmware_version, 1); 391 line6_read_data(line6, 0x80c2, &toneport->firmware_version, 1);
383 392
384 if (toneport_has_led(usbdev->descriptor.idProduct)) { 393 if (toneport_has_led(usbdev->descriptor.idProduct)) {
385 CHECK_RETURN(device_create_file(&interface->dev, &dev_attr_led_red)); 394 CHECK_RETURN(device_create_file
386 CHECK_RETURN(device_create_file(&interface->dev, &dev_attr_led_green)); 395 (&interface->dev, &dev_attr_led_red));
396 CHECK_RETURN(device_create_file
397 (&interface->dev, &dev_attr_led_green));
387 } 398 }
388 399
389 toneport_setup(toneport); 400 toneport_setup(toneport);