am 80d3699c: gralloc: Fix division-by-0 during system emulation.
* commit '80d3699c9e8e18d57684f3b20d58fd259379a9d2':
gralloc: Fix division-by-0 during system emulation.
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 @@
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