From owner-freebsd-arm@freebsd.org Tue Jun 30 15:46:57 2015 Return-Path: Delivered-To: freebsd-arm@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 8FA3098D40A for ; Tue, 30 Jun 2015 15:46:57 +0000 (UTC) (envelope-from leonardofogel@yahoo.com.br) Received: from nm17-vm2.bullet.mail.ne1.yahoo.com (nm17-vm2.bullet.mail.ne1.yahoo.com [98.138.91.93]) (using TLSv1 with cipher ECDHE-RSA-RC4-SHA (128/128 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 545DD16E7 for ; Tue, 30 Jun 2015 15:46:56 +0000 (UTC) (envelope-from leonardofogel@yahoo.com.br) Received: from [98.138.226.178] by nm17.bullet.mail.ne1.yahoo.com with NNFMP; 30 Jun 2015 15:44:29 -0000 Received: from [98.138.87.1] by tm13.bullet.mail.ne1.yahoo.com with NNFMP; 30 Jun 2015 15:44:29 -0000 Received: from [127.0.0.1] by omp1001.mail.ne1.yahoo.com with NNFMP; 30 Jun 2015 15:44:29 -0000 X-Yahoo-Newman-Property: ymail-3 X-Yahoo-Newman-Id: 364858.77468.bm@omp1001.mail.ne1.yahoo.com Received: (qmail 29036 invoked by uid 60001); 30 Jun 2015 15:44:29 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com.br; s=s1024; t=1435679069; bh=CdyHsl3ES15sunNTd/SuujAhKcUjDNyHudo6XNPiWJ8=; h=Message-ID:Date:From:Subject:To:MIME-Version:Content-Type:Content-Transfer-Encoding; b=qgOOJbp99oLEFs3v39RswvmKZp5S39D9aLBluomqDwxGExMOapu0g7DZZ+y5IK+ET06wxhdjr/izMzKmv/54ohYfaEEVil5JPMpzfsyZdZg8b38hsxxSx25+ucK96USioRb71WGuKocO8JrC+MdOrflggktOswDrfivb23ll0FA= X-YMail-OSG: OHxS8_oVM1na4lG_9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X-Mailer: YahooMailBasic/545 YahooMailWebService/0.8.203.802 Message-ID: <1435679069.12329.YahooMailBasic@web120802.mail.ne1.yahoo.com> Date: Tue, 30 Jun 2015 08:44:29 -0700 From: Leonardo Fogel Subject: Improvement to am335x_lcd_calc_divisor() To: freebsd-arm@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-BeenThere: freebsd-arm@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: "Porting FreeBSD to ARM processors." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 30 Jun 2015 15:46:57 -0000 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