From: Johannes Berg <johannes@sipsolutions.net>
To: ALSA development <alsa-devel@alsa-project.org>
Cc: linuxppc-dev list <linuxppc-dev@ozlabs.org>
Subject: [RFC] alsa integer control ranges
Date: Tue, 16 May 2006 14:02:20 +0200 [thread overview]
Message-ID: <1147780945.29795.110.camel@johannes> (raw)
Apparently all alsa userspace programs including alsamixer suck. Hence,
this patch is required to make them work properly. Why is it so hard to
do these additions/subtractions in the program or maybe even in the alsa
library? The alsa libraries already think they know better and mess up
all kinds of things.
What are your opinions on this? Should this be required? And if so, why
do we even have the value.integer.min when we can't use it anyway?
The code this patch applies against is in
http://johannes.sipsolutions.net/snd-aoa.git/ but that isn't all too
relevant, the patch serves just as an illustration of what is wrong
here.
Thanks,
johannes
--- snd-aoa.orig/aoa/codecs/onyx/snd-aoa-codec-onyx.c 2006-05-16 12:13:39.663950213 +0200
+++ snd-aoa/aoa/codecs/onyx/snd-aoa-codec-onyx.c 2006-05-16 12:14:13.698643898 +0200
@@ -102,8 +102,8 @@ static int onyx_snd_vol_info(struct snd_
{
uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
uinfo->count = 2;
- uinfo->value.integer.min = -128;
- uinfo->value.integer.max = -1;
+ uinfo->value.integer.min = -128+128;
+ uinfo->value.integer.max = -1+128;
return 0;
}
@@ -115,8 +115,8 @@ static int onyx_snd_vol_get(struct snd_k
onyx_read_register(onyx, ONYX_REG_DAC_ATTEN_LEFT, &l);
onyx_read_register(onyx, ONYX_REG_DAC_ATTEN_RIGHT, &r);
- ucontrol->value.integer.value[0] = l;
- ucontrol->value.integer.value[1] = r;
+ ucontrol->value.integer.value[0] = l+128;
+ ucontrol->value.integer.value[1] = r+128;
return 0;
}
@@ -125,8 +125,8 @@ static int onyx_snd_vol_put(struct snd_k
{
struct onyx *onyx = snd_kcontrol_chip(kcontrol);
- onyx_write_register(onyx, ONYX_REG_DAC_ATTEN_LEFT, ucontrol->value.integer.value[0]);
- onyx_write_register(onyx, ONYX_REG_DAC_ATTEN_RIGHT, ucontrol->value.integer.value[1]);
+ onyx_write_register(onyx, ONYX_REG_DAC_ATTEN_LEFT, ucontrol->value.integer.value[0]-128);
+ onyx_write_register(onyx, ONYX_REG_DAC_ATTEN_RIGHT, ucontrol->value.integer.value[1]-128);
/* FIXME: we could be checking if anything changed */
return 1;
}
@@ -145,8 +145,8 @@ static int onyx_snd_inputgain_info(struc
{
uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
uinfo->count = 1;
- uinfo->value.integer.min = 3;
- uinfo->value.integer.max = 28;
+ uinfo->value.integer.min = 3-3;
+ uinfo->value.integer.max = 28-3;
return 0;
}
@@ -157,7 +157,7 @@ static int onyx_snd_inputgain_get(struct
u8 ig;
onyx_read_register(onyx, ONYX_REG_ADC_CONTROL, &ig);
- ucontrol->value.integer.value[0] = ig & ONYX_ADC_PGA_GAIN_MASK;
+ ucontrol->value.integer.value[0] = (ig & ONYX_ADC_PGA_GAIN_MASK)-3;
return 0;
}
@@ -169,7 +169,7 @@ static int onyx_snd_inputgain_put(struct
onyx_read_register(onyx, ONYX_REG_ADC_CONTROL, &val);
val &= ~ONYX_ADC_PGA_GAIN_MASK;
- val |= ucontrol->value.integer.value[0] & ONYX_ADC_PGA_GAIN_MASK;
+ val |= (ucontrol->value.integer.value[0]+3) & ONYX_ADC_PGA_GAIN_MASK;
onyx_write_register(onyx, ONYX_REG_ADC_CONTROL, val);
return 1;
}
next reply other threads:[~2006-05-16 12:03 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-05-16 12:02 Johannes Berg [this message]
2006-05-16 12:27 ` [Alsa-devel] [RFC] alsa integer control ranges Takashi Iwai
2006-05-16 22:03 ` Benjamin Herrenschmidt
2006-05-17 9:59 ` Takashi Iwai
2006-05-17 12:16 ` Johannes Berg
2006-05-17 12:35 ` Takashi Iwai
2006-05-17 12:39 ` Johannes Berg
2006-05-17 21:41 ` Benjamin Herrenschmidt
2006-05-17 12:17 ` Johannes Berg
2006-05-17 12:37 ` Takashi Iwai
2006-05-16 12:31 ` Jaroslav Kysela
2006-05-16 22:04 ` Benjamin Herrenschmidt
2006-05-17 6:41 ` Jaroslav Kysela
2006-05-17 12:21 ` Johannes Berg
2006-05-17 9:47 ` Takashi Iwai
2006-05-17 12:24 ` Johannes Berg
2006-05-16 14:53 ` Lee Revell
2006-05-16 14:55 ` Johannes Berg
2006-05-17 15:38 ` Wolfgang Pfeiffer
2006-05-16 22:00 ` Benjamin Herrenschmidt
2006-05-16 22:04 ` [Alsa-devel] " Lee Revell
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=1147780945.29795.110.camel@johannes \
--to=johannes@sipsolutions.net \
--cc=alsa-devel@alsa-project.org \
--cc=linuxppc-dev@ozlabs.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).