mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Ben Slusky <sluskyb@paranoiacs.org>
To: "linux-os (Dick Johnson)" <linux-os@analogic.com>
Cc: Carlos Munoz <carlos@kenati.com>,
	Denis Vlasenko <vda@ilport.com.ua>,
	Lee Revell <rlrevell@joe-job.com>,
	Valdis.Kletnieks@vt.edu,
	Linux kernel <linux-kernel@vger.kernel.org>,
	alsa-devel <alsa-devel@lists.sourceforge.net>
Subject: Re: How can I link the kernel with libgcc ?
Date: Fri, 10 Mar 2006 13:41:05 -0500	[thread overview]
Message-ID: <20060310184105.GA19846@paranoiacs.org> (raw)
In-Reply-To: <Pine.LNX.4.61.0603101320510.5057@chaos.analogic.com>

On Fri, 10 Mar 2006 13:33:02 -0500, linux-os (Dick Johnson) wrote:
> 
> On Fri, 10 Mar 2006, Carlos Munoz wrote:
> 
> > Denis Vlasenko wrote:
> >
> >> On Friday 10 March 2006 05:47, Carlos Munoz wrote:
> >>
> >>
> >>> Lee Revell wrote:
> >>>
> >>>
> >>>
> >>>> On Thu, 2006-03-09 at 19:25 -0800, Carlos Munoz wrote:
> >>>>
> >>>>
> >>>>
> >>>>
> >>>>> I figured out how to get the driver to use floating point operations.
> >>>>> I included source code (from an open source math library) for the
> >>>>> log10 function in the driver. Then I added the following lines to the
> >>>>> file arch/sh/kernel/sh_ksyms.c:
> >>>>>
> >>>>>
> >>>>>
> >>>>>
> >>>> Where is the source code to your driver?
> >>>>
> >>>> Lee
> >>>>
> >>>>
> >>>>
> >>>>
> >>>>
> >>> Hi Lee,
> >>>
> >>> Be warned. This driver is in the early stages of development. There is
> >>> still a lot of work that needs to be done (interrupt, dma, etc, etc).
> >>>
> >>>
> >>
> >> What? You are using log10 only twice!
> >>
> >>        if (!(siu_obj_status & ST_OPEN)) {
> >> 		...
> >>                /* = log2(over) */
> >>                ydef[22] = (u_int32_t)(log10((double)(over & 0x0000003f)) /
> >>                                       log10(2));
> >> 		...
> >>        }
> >>        else {
> >> 		...
> >>                if (coef) {
> >>                        ydef[16] = 0x03045000 | (over << 26) | (tap - 4);
> >>                        ydef[17] = (tap * 2 + 1);
> >>                        /* = log2(over) */
> >>                        ydef[22] = (u_int32_t)
> >>                                (log10((double)(over & 0x0000003f)) / log10(2));
> >>                }
> >>
> >> Don't you think that log10((double)(over & 0x0000003f)) / log10(2)
> >> can have only 64 different values depending on the result of (over & 0x3f)?
> >>
> >> Obtain them from precomputed uint32_t log10table[64].
> >> --
> >> vda
> >>
> >>
> > Hi Denis,
> >
> > Yes, the driver code so far only uses log10 twice, but there will be
> > more uses for it as I populate the rest of the tables. However, I think
> > its use will be some what limited. I wasn't aware that the floating
> > point registers are not saved. I'll investigate a way to create a table
> > with pre-calculated log10 values.
> >
> > Thanks,
> >
> >
> > Carlos
> 
> Since the log in base n is the log in any base times a constant,
> you can probably use log base 2 (binary bit position) and multiply
> the result by a constant, which may simply be shifts and adds.
> 
> I assume you are using 16-bit audio. If so, the dynamic range
> is only 20 * log10(2^16) = 96.3 dB. That means that attenuation
> from mininum to maximum, in 1 dB steps, requires only 94 values.
> 
> Your code shows something whacked off at 0x3f = 0->0x40 = 64
> 20 * log10(64) = 36 dB for only 36 values. Clearly, you don't
> need floating point, just some thought ahead of time.
> 
> Cheers,
> Dick Johnson

As Bart pointed out earlier, what this code is really trying to do is not
log10(foo) but int(log2(foo)) for some positive integer foo. This can be
simply expressed as fls(foo)-1 for all foo < 0. No floating point
necessary.

-- 
Ben Slusky                      | Trust is your enemy.
sluskyb@paranoiacs.org          |       -Dan Farmer and
sluskyb@stwing.org              |        Wietse Venema
PGP keyID ADA44B3B      

  reply	other threads:[~2006-03-10 18:41 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-03-10  1:44 Carlos Munoz
2006-03-10  1:45 ` Valdis.Kletnieks
2006-03-10  2:06   ` Lee Revell
2006-03-10  3:01     ` Carlos Munoz
2006-03-10  3:22       ` Lee Revell
2006-03-10  3:25       ` Carlos Munoz
2006-03-10  3:25         ` Lee Revell
2006-03-10  3:47           ` Carlos Munoz
2006-03-10 10:37             ` Denis Vlasenko
2006-03-10 11:05               ` Bart Hartgers
2006-03-10 18:03               ` Carlos Munoz
2006-03-10 18:33                 ` linux-os (Dick Johnson)
2006-03-10 18:41                   ` Ben Slusky [this message]
2006-03-10 19:18                 ` Al Viro
2006-03-10 20:04                   ` Carlos Munoz
2006-03-10 10:18         ` Jes Sorensen
2006-03-10 18:07           ` Carlos Munoz
2006-03-10  8:01       ` Arjan van de Ven
2006-03-10  2:02 ` Lee Revell
     [not found] <5OEVB-3GX-15@gated-at.bofh.it>
2006-03-10  2:32 ` Robert Hancock

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=20060310184105.GA19846@paranoiacs.org \
    --to=sluskyb@paranoiacs.org \
    --cc=Valdis.Kletnieks@vt.edu \
    --cc=alsa-devel@lists.sourceforge.net \
    --cc=carlos@kenati.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-os@analogic.com \
    --cc=rlrevell@joe-job.com \
    --cc=vda@ilport.com.ua \
    /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

all inboxes | Powered by JetHome®