All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Daniel Glöckner" <dg@emlix.com>
To: Eliot Blennerhassett <linux@audioscience.com>
Cc: alsa-devel@alsa-project.org
Subject: Re: Support for floating point controls?
Date: Tue, 02 Feb 2010 11:08:10 +0100	[thread overview]
Message-ID: <4B67F98A.1000208@emlix.com> (raw)
In-Reply-To: <4B60C841.9010306@audioscience.com>

On 01/28/2010 12:12 AM, Eliot Blennerhassett wrote:
> I wonder if a patch implementing float ctl elements would be accepted?
> Note that the floats are not manipulated in the kernel at all, the
> values are just passed through from the hardware to userspace (?)
> 
> Adding something like:
> 
> #define	SNDRV_CTL_ELEM_TYPE_FLOAT	((__force snd_ctl_elem_type_t) 7)
> 
> struct snd_ctl_elem_info {
> ...
>   union {
> 	struct {
> 		float min;		/* R: minimum value */
> 		float max;		/* R: maximum value */
> 		float step;		/* R: step (0 variable) */
> 	} float;
> ...
> }
> 
> struct snd_ctl_elem_value {
>   union {
> 	union {
> 		float value[128];
> 	} float;

I see several issues here.
There might be some day an architecture where float is not the
IEEE 754 single precision type. Or there might be a compiler that
insists on using floating point instructions to read those values
from memory. Therefore I prefer __s32 here instead of float.

Drivers would have to check if a passed control value is in the
range [min, max] and filter out INFs and NANs. So one needs to
implement an in-kernel version of C99's fpclassify and isgreater
working on floating point values kept in integer variables for
all drivers to use.

Alsa-lib may need to convert the IEEE floats to the native floats
if they are not the same. Just look at the issues with double on
ARM. There the order of the two 32 bit halves in memory depends on
the ABI IIRC.

Just my 2 cents

  Daniel


-- 
Dipl.-Math. Daniel Glöckner, emlix GmbH, http://www.emlix.com
Fon +49 551 30664-0, Fax -11, Bahnhofsallee 1b, 37081 Göttingen, Germany
Sitz der Gesellschaft: Göttingen, Amtsgericht Göttingen HR B 3160
Geschäftsführer: Dr. Uwe Kracke, Ust-IdNr.: DE 205 198 055

emlix - your embedded linux partner

  parent reply	other threads:[~2010-02-02 10:08 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-01-27 23:12 Support for floating point controls? Eliot Blennerhassett
2010-02-01 16:43 ` Jaroslav Kysela
2010-02-01 16:57   ` Takashi Iwai
2010-02-01 18:13 ` James Courtier-Dutton
2010-02-01 19:42   ` Eliot Blennerhassett
2010-02-02 10:08 ` Daniel Glöckner [this message]
2010-02-02 10:44   ` Takashi Iwai
  -- strict thread matches above, loose matches on Subject: below --
2010-02-01 16:13 Tobias Schneider

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=4B67F98A.1000208@emlix.com \
    --to=dg@emlix.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=linux@audioscience.com \
    /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.