summaryrefslogtreecommitdiffstats
path: root/modules/gralloc
diff options
context:
space:
mode:
authorDavid 'Digit' Turner <digit@google.com>2011-01-15 21:06:12 +0100
committerDavid 'Digit' Turner <digit@google.com>2011-01-15 21:06:12 +0100
commit80d3699c9e8e18d57684f3b20d58fd259379a9d2 (patch)
tree957d926b3683f7e218b3be399a7e4b6778b6de81 /modules/gralloc
parent3cceaceecac1e76244153940b8855ad1bbdd1037 (diff)
downloadhardware_libhardware-80d3699c9e8e18d57684f3b20d58fd259379a9d2.zip
hardware_libhardware-80d3699c9e8e18d57684f3b20d58fd259379a9d2.tar.gz
hardware_libhardware-80d3699c9e8e18d57684f3b20d58fd259379a9d2.tar.bz2
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: Idb6bcdd58999ea9231f2411481c25929d5d02f1d
Diffstat (limited to 'modules/gralloc')
-rw-r--r--modules/gralloc/framebuffer.cpp6
1 files changed, 5 insertions, 1 deletions
diff --git a/modules/gralloc/framebuffer.cpp b/modules/gralloc/framebuffer.cpp
index a487b5d..59c5001 100644
--- a/modules/gralloc/framebuffer.cpp
+++ b/modules/gralloc/framebuffer.cpp
@@ -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