Merge 80d3699c: gralloc: Fix division-by-0 during system emulation.

This patch avoids a division-by-0 when the system is running
under emulation (the kernel driver reports pixclock as 0, for
some reason). Which results in a SIGFPE during the boot sequence.

Change-Id: Ia9febdf143dcbce9837ca89c641e95dce3a888bb
This commit is contained in:
David 'Digit' Turner 2011-01-15 21:06:12 +01:00 committed by Xavier Ducrohet
parent 158549c894
commit 3d05f9cfbd

View file

@ -213,13 +213,17 @@ int mapFrameBufferLocked(struct private_module_t* module)
if (ioctl(fd, FBIOGET_VSCREENINFO, &info) == -1)
return -errno;
int refreshRate = 1000000000000000LLU /
uint64_t refreshQuotient =
(
uint64_t( info.upper_margin + info.lower_margin + info.yres )
* ( info.left_margin + info.right_margin + info.xres )
* info.pixclock
);
/* Beware, info.pixclock might be 0 under emulation, so avoid a
* division-by-0 here (SIGFPE on ARM) */
int refreshRate = refreshQuotient > 0 ? (int)(1000000000000000LLU / refreshQuotient) : 0;
if (refreshRate == 0) {
// bleagh, bad info from the driver
refreshRate = 60*1000; // 60 Hz