From: Takashi Iwai <tiwai@suse.de>
To: Mark Brown <broonie@sirena.org.uk>
Cc: alsa-devel@alsa-project.org, Troy Kisky <troy.kisky@boundarydevices.com>
Subject: Re: [PATCH 1/4] ASoC: TLV320AIC23B Support more sample rates
Date: Thu, 06 Nov 2008 12:23:56 +0100 [thread overview]
Message-ID: <s5hy6zxt7w3.wl%tiwai@suse.de> (raw)
In-Reply-To: <20081106104905.GA26469@sirena.org.uk> <1225911211-22474-1-git-send-email-broonie@opensource.wolfsonmicro.com>
At Thu, 6 Nov 2008 10:49:06 +0000,
Mark Brown wrote:
>
> On Wed, Nov 05, 2008 at 09:35:01PM +0100, Takashi Iwai wrote:
> > Mark Brown wrote:
>
> > > + return score;
>
> > > + return 0xffffffff;
>
> > -1 would be simpler and safer (for possible missing f's).
>
> I'm not sure that'd add to the clarity - the goal isn't to have all bits
> set, the goal is to have a much larger score than could ever otherwise
> be achieved so putting in a very large constant expresses that much more
> directly.
Also, regarding unsigned integer:
> +unsigned get_score(int adc, int adc_l, int adc_h, int need_adc,
> + int dac, int dac_l, int dac_h, int need_dac)
> +{
> + if ((adc >= adc_l) && (adc <= adc_h) &&
> + (dac >= dac_l) && (dac <= dac_h)) {
> + unsigned diff_adc = need_adc - adc;
> + unsigned diff_dac = need_dac - dac;
> + unsigned score;
> + if (((int)diff_adc) < 0)
> + diff_adc = -diff_adc;
> + if (((int)diff_dac) < 0)
> + diff_dac = -diff_dac;
> + score = diff_adc + diff_dac;
> + return score;
It's more readable when diff_adc, diff_dac are int so that you have no
ugly cast:
int diff_adc = need_adc - adc;
int diff_dac = need_dac - dac;
unsigned score;
if (diff_adc < 0)
diff_adc = -diff_adc;
if (diff_dac < 0)
diff_dac = -diff_dac;
score = diff_adc + diff_dac;
return score;
And, even more readable with abs() (not surprisingly defined in
linux/kernel.h):
int diff_adc = need_adc - adc;
int diff_dac = need_dac - dac;
return abs(diff_adc) + abs(diff_dac);
Takashi
next prev parent reply other threads:[~2008-11-06 11:23 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-11-05 18:52 [PATCH 0/4] ASoC updates Mark Brown
2008-11-05 18:53 ` [PATCH 1/4] ASoC: TLV320AIC23B Support more sample rates Mark Brown
2008-11-05 18:53 ` [PATCH 2/4] ASoC: Add Palm/PXA27x unified ASoC audio driver Mark Brown
2008-11-05 18:53 ` [PATCH 3/4] ASoC: Remove core version number Mark Brown
2008-11-05 18:53 ` [PATCH 4/4] ASoC: Add new parameter to s3c24xx_pcm_enqueue Mark Brown
2008-11-05 19:35 ` [PATCH 2/4] ASoC: Add Palm/PXA27x unified ASoC audio driver Marek Vasut
2008-11-05 20:35 ` Takashi Iwai
2008-11-05 21:54 ` Mark Brown
2008-11-05 20:35 ` [PATCH 1/4] ASoC: TLV320AIC23B Support more sample rates Takashi Iwai
2008-11-05 22:05 ` Mark Brown
2008-11-06 23:11 ` [PATCH 1/1] [ALSA] " Troy Kisky
2008-11-07 14:10 ` Mark Brown
2008-11-06 10:49 ` [PATCH 1/4] " Mark Brown
2008-11-06 11:03 ` Takashi Iwai
2008-11-06 11:23 ` Takashi Iwai [this message]
-- strict thread matches above, loose matches on Subject: below --
2008-11-12 11:55 [PATCH 0/4] ASoC updates Mark Brown
2008-11-12 11:55 ` [PATCH 1/4] ASoC: TLV320AIC23B Support more sample rates 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=s5hy6zxt7w3.wl%tiwai@suse.de \
--to=tiwai@suse.de \
--cc=alsa-devel@alsa-project.org \
--cc=broonie@sirena.org.uk \
--cc=troy.kisky@boundarydevices.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox