Commit 31508f83 authored by James Courtier-Dutton's avatar James Courtier-Dutton Committed by Jaroslav Kysela

[ALSA] snd-emu10k1: Implement dB gain infomation.

Signed-off-by: default avatarJames Courtier-Dutton <James@superbug.co.uk>
Signed-off-by: default avatarJaroslav Kysela <perex@suse.cz>
parent fff36e47
...@@ -1524,6 +1524,10 @@ struct snd_emu10k1_fx8010_control_gpr { ...@@ -1524,6 +1524,10 @@ struct snd_emu10k1_fx8010_control_gpr {
unsigned int value[32]; /* initial values */ unsigned int value[32]; /* initial values */
unsigned int min; /* minimum range */ unsigned int min; /* minimum range */
unsigned int max; /* maximum range */ unsigned int max; /* maximum range */
union {
snd_kcontrol_tlv_rw_t *c;
unsigned int *p;
} tlv;
unsigned int translation; /* translation type (EMU10K1_GPR_TRANSLATION*) */ unsigned int translation; /* translation type (EMU10K1_GPR_TRANSLATION*) */
}; };
......
...@@ -35,6 +35,7 @@ ...@@ -35,6 +35,7 @@
#include <linux/mutex.h> #include <linux/mutex.h>
#include <sound/core.h> #include <sound/core.h>
#include <sound/tlv.h>
#include <sound/emu10k1.h> #include <sound/emu10k1.h>
#if 0 /* for testing purposes - digital out -> capture */ #if 0 /* for testing purposes - digital out -> capture */
...@@ -290,6 +291,9 @@ static const u32 db_table[101] = { ...@@ -290,6 +291,9 @@ static const u32 db_table[101] = {
0x7fffffff, 0x7fffffff,
}; };
/* EMU10k1/EMU10k2 DSP control db gain */
static DECLARE_TLV_DB_SCALE(snd_emu10k1_db_scale1, -4000, 40, 1);
static const u32 onoff_table[2] = { static const u32 onoff_table[2] = {
0x00000000, 0x00000001 0x00000000, 0x00000001
}; };
...@@ -755,6 +759,11 @@ static int snd_emu10k1_add_controls(struct snd_emu10k1 *emu, ...@@ -755,6 +759,11 @@ static int snd_emu10k1_add_controls(struct snd_emu10k1 *emu,
knew.device = gctl->id.device; knew.device = gctl->id.device;
knew.subdevice = gctl->id.subdevice; knew.subdevice = gctl->id.subdevice;
knew.info = snd_emu10k1_gpr_ctl_info; knew.info = snd_emu10k1_gpr_ctl_info;
if (gctl->tlv.p) {
knew.tlv.p = gctl->tlv.p;
knew.access = SNDRV_CTL_ELEM_ACCESS_READWRITE |
SNDRV_CTL_ELEM_ACCESS_TLV_READ;
}
knew.get = snd_emu10k1_gpr_ctl_get; knew.get = snd_emu10k1_gpr_ctl_get;
knew.put = snd_emu10k1_gpr_ctl_put; knew.put = snd_emu10k1_gpr_ctl_put;
memset(nctl, 0, sizeof(*nctl)); memset(nctl, 0, sizeof(*nctl));
...@@ -1013,6 +1022,7 @@ snd_emu10k1_init_mono_control(struct snd_emu10k1_fx8010_control_gpr *ctl, ...@@ -1013,6 +1022,7 @@ snd_emu10k1_init_mono_control(struct snd_emu10k1_fx8010_control_gpr *ctl,
ctl->gpr[0] = gpr + 0; ctl->value[0] = defval; ctl->gpr[0] = gpr + 0; ctl->value[0] = defval;
ctl->min = 0; ctl->min = 0;
ctl->max = 100; ctl->max = 100;
ctl->tlv.p = snd_emu10k1_db_scale1;
ctl->translation = EMU10K1_GPR_TRANSLATION_TABLE100; ctl->translation = EMU10K1_GPR_TRANSLATION_TABLE100;
} }
...@@ -1027,6 +1037,7 @@ snd_emu10k1_init_stereo_control(struct snd_emu10k1_fx8010_control_gpr *ctl, ...@@ -1027,6 +1037,7 @@ snd_emu10k1_init_stereo_control(struct snd_emu10k1_fx8010_control_gpr *ctl,
ctl->gpr[1] = gpr + 1; ctl->value[1] = defval; ctl->gpr[1] = gpr + 1; ctl->value[1] = defval;
ctl->min = 0; ctl->min = 0;
ctl->max = 100; ctl->max = 100;
ctl->tlv.p = snd_emu10k1_db_scale1;
ctl->translation = EMU10K1_GPR_TRANSLATION_TABLE100; ctl->translation = EMU10K1_GPR_TRANSLATION_TABLE100;
} }
......
...@@ -100,6 +100,7 @@ ...@@ -100,6 +100,7 @@
#include <sound/pcm.h> #include <sound/pcm.h>
#include <sound/ac97_codec.h> #include <sound/ac97_codec.h>
#include <sound/info.h> #include <sound/info.h>
#include <sound/tlv.h>
#include <sound/emu10k1.h> #include <sound/emu10k1.h>
#include "p16v.h" #include "p16v.h"
...@@ -784,12 +785,16 @@ static int snd_p16v_capture_channel_put(struct snd_kcontrol *kcontrol, ...@@ -784,12 +785,16 @@ static int snd_p16v_capture_channel_put(struct snd_kcontrol *kcontrol,
} }
return change; return change;
} }
static DECLARE_TLV_DB_SCALE(snd_p16v_db_scale1, -5175, 25, 1);
#define P16V_VOL(xname,xreg,xhl) { \ #define P16V_VOL(xname,xreg,xhl) { \
.iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
.access = SNDRV_CTL_ELEM_ACCESS_READWRITE | \
SNDRV_CTL_ELEM_ACCESS_TLV_READ, \
.info = snd_p16v_volume_info, \ .info = snd_p16v_volume_info, \
.get = snd_p16v_volume_get, \ .get = snd_p16v_volume_get, \
.put = snd_p16v_volume_put, \ .put = snd_p16v_volume_put, \
.tlv.p = snd_p16v_db_scale1, \
.private_value = ((xreg) | ((xhl) << 8)) \ .private_value = ((xreg) | ((xhl) << 8)) \
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment