[alsa-devel] ASoC: Defining "signed integer" mixer controls?

Stuart Longland redhatter at gentoo.org
Thu Jun 3 03:07:57 CEST 2010

Hi all...

I'm posting this via GMane since my server at home seems to be down, 
hopefully it gets through.  I hope to put a version of the TLV320AIC3204 
driver that I've been working on up there -- I did try posting it to the 
list, but I suspect it's either been left in the moderation queue or 
silently dropped.  In short, I got the sound working; just testing 
playback for now... Recording should work, once I get the mixer set up.

My query though; the mixer on this CODEC provides gain settings, 
helpfully scaled in dB, as signed integers.  For instance; the four line 
level output drivers: Headphone left/right,and Line Out left/right, can 
all be adjusted in gain from -6dB through to +29dB.

These are set in individual registers as the lower 6 bits; so:
	-6 dB is represented as 111010 (0x3a)
	29 dB is represented as 011101 (0x1d)

At the moment, things "half work" with the following code:
  * DAC digital volumes. From -63.5 to +24 dB in 0.5 dB steps
static DECLARE_TLV_DB_MINMAX(dac_tlv, -6350, 2400);
/* ADC PGA gain volumes. From 0 to 59.5 dB in 0.5 dB steps */
static DECLARE_TLV_DB_MINMAX(adc_tlv, 0, 0);
  * Output driver stage volumes; -6dB through to +29dB
static DECLARE_TLV_DB_MINMAX(output_stage_tlv, -600, 2900);

static const struct snd_kcontrol_new aic3204_snd_controls[] = {
	/* Output */
	SOC_DOUBLE_R_TLV("Headphone Output Volume",
			 0, 29, 0, output_stage_tlv),
	SOC_DOUBLE_R_TLV("Line Output Volume",
			 0, 29, 0, output_stage_tlv),
	SOC_DOUBLE_R_TLV("PCM Playback Volume",
			 0, 127, 0, dac_tlv),

However; it treats the bitfield as unsigned, which is wrong in this 
case.  The bitfield is a signed integer in two's complement format.  How 
do I convince ALSA that these integers have a sign bit?

Stuart Longland

More information about the Alsa-devel mailing list