From df21d4b011c19e84fb1aa9d0c5a70c5db5eae489 Mon Sep 17 00:00:00 2001 From: Tellen Yu Date: Tue, 23 May 2017 06:29:51 +0000 Subject: enable mouse display for kernel 4.9 from kernel 4.9, cursor ioctl switch from FBIO_CURSOR to FBIOPUT_OSD_CURSOR Change-Id: Ibd66ca394c7c34fb0000432b481b6b88fc9a25d4 --- diff --git a/hwc2/common/devices/PhysicalDevice.cpp b/hwc2/common/devices/PhysicalDevice.cpp index 0afbb54..7311796 100644 --- a/hwc2/common/devices/PhysicalDevice.cpp +++ b/hwc2/common/devices/PhysicalDevice.cpp @@ -27,6 +27,8 @@ #include #include #include +#include +#define FBIOPUT_OSD_CURSOR 0x451a static int Amvideo_Handle = 0; @@ -94,6 +96,14 @@ PhysicalDevice::PhysicalDevice(hwc2_display_t id, Hwcomposer& hwc, DeviceControl mGE2DRenderSortedLayerIds.clear(); mHwcCurReleaseFences = mHwcPriorReleaseFences = NULL; + + int major = 0, minor = 0; + struct utsname info; + if (uname(&info) || sscanf(info.release, "%d.%d", &major, &minor) <= 0) { + ETRACE("Could not get linux version: %s", strerror(errno)); + } + // from kernel 4.9 use FBIOPUT_OSD_CURSOR instead of FBIO_CURSOR + mUsingPutCurosr = major > 4 || (major == 4 && minor >= 9); } PhysicalDevice::~PhysicalDevice() @@ -1258,7 +1268,12 @@ int32_t PhysicalDevice::setCursorPosition(hwc2_layer_t layerId, int32_t x, int32 cinfo.hot.x = x; cinfo.hot.y = y; DTRACE("setCursorPosition x_pos=%d, y_pos=%d", cinfo.hot.x, cinfo.hot.y); - ioctl(cbInfo->fd, FBIO_CURSOR, &cinfo); + + // from kernel 4.9 use FBIOPUT_OSD_CURSOR instead of FBIO_CURSOR + if (mUsingPutCurosr) + ioctl(cbInfo->fd, FBIOPUT_OSD_CURSOR, &cinfo); + else + ioctl(cbInfo->fd, FBIO_CURSOR, &cinfo); } } else { ETRACE("setCursorPosition bad layer."); diff --git a/hwc2/include/PhysicalDevice.h b/hwc2/include/PhysicalDevice.h index 57e181f..07767a1 100644 --- a/hwc2/include/PhysicalDevice.h +++ b/hwc2/include/PhysicalDevice.h @@ -252,6 +252,7 @@ private: // lock Mutex mLock; bool mInitialized; + bool mUsingPutCurosr; }; -- cgit