All of lore.kernel.org
 help / color / mirror / Atom feed
From: Stuart Longland <redhatter@gentoo.org>
To: alsa-devel@alsa-project.org
Subject: ASoC: Defining "signed integer" mixer controls?
Date: Thu, 03 Jun 2010 11:07:57 +1000	[thread overview]
Message-ID: <hu6v9i$v43$1@dough.gmane.org> (raw)

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",
			 AIC3204_HPLGAIN, AIC3204_HPRGAIN,
			 0, 29, 0, output_stage_tlv),
	SOC_DOUBLE_R_TLV("Line Output Volume",
			 AIC3204_LOLGAIN, AIC3204_LORGAIN,
			 0, 29, 0, output_stage_tlv),
	SOC_DOUBLE_R_TLV("PCM Playback Volume",
			 AIC3204_LDACVOL, AIC3204_RDACVOL,
			 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?

Regards,
Stuart Longland

             reply	other threads:[~2010-06-03  1:40 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-06-03  1:07 Stuart Longland [this message]
2010-06-03  7:09 ` ASoC: Defining "signed integer" mixer controls? James Courtier-Dutton
2010-06-03 11:21   ` Mark Brown
2010-06-03 12:09     ` James Courtier-Dutton
2010-06-03  8:25 ` Clemens Ladisch
2010-06-03 10:33   ` Stuart Longland
2010-06-03 15:52     ` James Courtier-Dutton
2010-06-03 11:20 ` Mark Brown
2010-06-04  9:27   ` Stuart Longland
2010-06-04 11:28     ` Mark Brown

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='hu6v9i$v43$1@dough.gmane.org' \
    --to=redhatter@gentoo.org \
    --cc=alsa-devel@alsa-project.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.