Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 30 Jun 2015 08:44:29 -0700
From:      Leonardo Fogel <leonardofogel@yahoo.com.br>
To:        freebsd-arm@freebsd.org
Subject:   Improvement to am335x_lcd_calc_divisor()
Message-ID:  <1435679069.12329.YahooMailBasic@web120802.mail.ne1.yahoo.com>

next in thread | raw e-mail | index | archive | help
I just realized the last proposal would depend on 64-bit multiplication, wh=
ich may not be available. Here is another approach:

Let f be the fractional part of r, the real number (R%F)/F. If f >=3D 0.5, =
then lround(r) rounds up. We can test the multiplicative inverse of f, 1/f,=
 F/(R%F). If 1/f <=3D 2, then lround(r) rounds up.

=09if (freq =3D=3D 0) /* there is a bug somewhere. */
=09=09return (255);

=09if ((reference%freq > 0) && (freq/(reference%freq) <=3D 2))
=09=09div =3D reference/freq + 1; /* rounds up   */
=09else
=09=09div =3D reference/freq;     /* rounds down */

=09/* Raster mode case: divisors are in range from 2 to 255 */
=09if (div < 2)
=09=09div =3D 2;
=09else if (div > 255)
=09=09dir =3D 255;

=09return (div);

Thank you.
Leonardo




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?1435679069.12329.YahooMailBasic>