aboutsummaryrefslogtreecommitdiffstats
path: root/sound/usb
diff options
context:
space:
mode:
authorTorsten Schenk <torsten.schenk@zoho.com>2012-02-22 09:20:54 -0500
committerTakashi Iwai <tiwai@suse.de>2012-02-22 09:50:56 -0500
commit8e247a9c90e65b25b5b064e2159d9c4c2c173a5e (patch)
treea8f58503dc3a5a02e385e27ab99062ff60e310f2 /sound/usb
parentc596758f57aa33e5e89c006867ae66fa2f9c357c (diff)
ALSA: snd-usb-6fire: add tlv to controls
Remove the soft log-conversion and add a dB scale according to the DAC documentation instead. Signed-off-by: Torsten Schenk <torsten.schenk@zoho.com> Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/usb')
-rw-r--r--sound/usb/6fire/control.c34
1 files changed, 9 insertions, 25 deletions
diff --git a/sound/usb/6fire/control.c b/sound/usb/6fire/control.c
index 8111844c4b1..b00b8bb88c6 100644
--- a/sound/usb/6fire/control.c
+++ b/sound/usb/6fire/control.c
@@ -15,6 +15,7 @@
15 15
16#include <linux/interrupt.h> 16#include <linux/interrupt.h>
17#include <sound/control.h> 17#include <sound/control.h>
18#include <sound/tlv.h>
18 19
19#include "control.h" 20#include "control.h"
20#include "comm.h" 21#include "comm.h"
@@ -24,26 +25,6 @@ static char *opt_coax_texts[2] = { "Optical", "Coax" };
24static char *line_phono_texts[2] = { "Line", "Phono" }; 25static char *line_phono_texts[2] = { "Line", "Phono" };
25 26
26/* 27/*
27 * calculated with $value\[i\] = 128 \cdot sqrt[3]{\frac{i}{128}}$
28 * this is done because the linear values cause rapid degredation
29 * of volume in the uppermost region.
30 */
31static const u8 log_volume_table[128] = {
32 0x00, 0x19, 0x20, 0x24, 0x28, 0x2b, 0x2e, 0x30, 0x32, 0x34,
33 0x36, 0x38, 0x3a, 0x3b, 0x3d, 0x3e, 0x40, 0x41, 0x42, 0x43,
34 0x44, 0x46, 0x47, 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e,
35 0x4e, 0x4f, 0x50, 0x51, 0x52, 0x53, 0x53, 0x54, 0x55, 0x56,
36 0x56, 0x57, 0x58, 0x58, 0x59, 0x5a, 0x5b, 0x5b, 0x5c, 0x5c,
37 0x5d, 0x5e, 0x5e, 0x5f, 0x60, 0x60, 0x61, 0x61, 0x62, 0x62,
38 0x63, 0x63, 0x64, 0x65, 0x65, 0x66, 0x66, 0x67, 0x67, 0x68,
39 0x68, 0x69, 0x69, 0x6a, 0x6a, 0x6b, 0x6b, 0x6c, 0x6c, 0x6c,
40 0x6d, 0x6d, 0x6e, 0x6e, 0x6f, 0x6f, 0x70, 0x70, 0x70, 0x71,
41 0x71, 0x72, 0x72, 0x73, 0x73, 0x73, 0x74, 0x74, 0x75, 0x75,
42 0x75, 0x76, 0x76, 0x77, 0x77, 0x77, 0x78, 0x78, 0x78, 0x79,
43 0x79, 0x7a, 0x7a, 0x7a, 0x7b, 0x7b, 0x7b, 0x7c, 0x7c, 0x7c,
44 0x7d, 0x7d, 0x7d, 0x7e, 0x7e, 0x7e, 0x7f, 0x7f };
45
46/*
47 * data that needs to be sent to device. sets up card internal stuff. 28 * data that needs to be sent to device. sets up card internal stuff.
48 * values dumped from windows driver and filtered by trial'n'error. 29 * values dumped from windows driver and filtered by trial'n'error.
49 */ 30 */
@@ -69,6 +50,8 @@ static const int rates_altsetting[] = { 1, 1, 2, 2, 3, 3 };
69static const u16 rates_6fire_vl[] = {0x00, 0x01, 0x00, 0x01, 0x00, 0x01}; 50static const u16 rates_6fire_vl[] = {0x00, 0x01, 0x00, 0x01, 0x00, 0x01};
70static const u16 rates_6fire_vh[] = {0x11, 0x11, 0x10, 0x10, 0x00, 0x00}; 51static const u16 rates_6fire_vh[] = {0x11, 0x11, 0x10, 0x10, 0x00, 0x00};
71 52
53static DECLARE_TLV_DB_MINMAX(tlv_output, -9000, 0);
54
72enum { 55enum {
73 DIGITAL_THRU_ONLY_SAMPLERATE = 3 56 DIGITAL_THRU_ONLY_SAMPLERATE = 3
74}; 57};
@@ -78,8 +61,7 @@ static void usb6fire_control_master_vol_update(struct control_runtime *rt)
78 struct comm_runtime *comm_rt = rt->chip->comm; 61 struct comm_runtime *comm_rt = rt->chip->comm;
79 if (comm_rt) { 62 if (comm_rt) {
80 /* set volume */ 63 /* set volume */
81 comm_rt->write8(comm_rt, 0x12, 0x0f, 0x7f - 64 comm_rt->write8(comm_rt, 0x12, 0x0f, 180 - rt->master_vol);
82 log_volume_table[rt->master_vol]);
83 /* unmute */ 65 /* unmute */
84 comm_rt->write8(comm_rt, 0x12, 0x0e, 0x00); 66 comm_rt->write8(comm_rt, 0x12, 0x0e, 0x00);
85 } 67 }
@@ -170,7 +152,7 @@ static int usb6fire_control_master_vol_info(struct snd_kcontrol *kcontrol,
170 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; 152 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
171 uinfo->count = 1; 153 uinfo->count = 1;
172 uinfo->value.integer.min = 0; 154 uinfo->value.integer.min = 0;
173 uinfo->value.integer.max = 127; 155 uinfo->value.integer.max = 180;
174 return 0; 156 return 0;
175} 157}
176 158
@@ -291,10 +273,12 @@ static struct __devinitdata snd_kcontrol_new elements[] = {
291 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 273 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
292 .name = "Master Playback Volume", 274 .name = "Master Playback Volume",
293 .index = 0, 275 .index = 0,
294 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE, 276 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE |
277 SNDRV_CTL_ELEM_ACCESS_TLV_READ,
295 .info = usb6fire_control_master_vol_info, 278 .info = usb6fire_control_master_vol_info,
296 .get = usb6fire_control_master_vol_get, 279 .get = usb6fire_control_master_vol_get,
297 .put = usb6fire_control_master_vol_put 280 .put = usb6fire_control_master_vol_put,
281 .tlv = { .p = tlv_output }
298 }, 282 },
299 { 283 {
300 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 284 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,