summaryrefslogtreecommitdiff
authorshuze.ma <shuze.ma@amlogic.com>2017-11-15 08:26:25 (GMT)
committer shuze.ma <shuze.ma@amlogic.com>2017-11-24 06:32:24 (GMT)
commit3ce5e3e7d492b032c268f6e3fea16c236839c852 (patch)
tree566bfb21bfb8bd29db7dd8f48c9c6a20162de2e7
parentd5258260762009e1e8e6de8a1f184b1ba7b6b32b (diff)
downloadhwcomposer-3ce5e3e7d492b032c268f6e3fea16c236839c852.zip
hwcomposer-3ce5e3e7d492b032c268f6e3fea16c236839c852.tar.gz
hwcomposer-3ce5e3e7d492b032c268f6e3fea16c236839c852.tar.bz2
hwc2: add osd1 mouse op [2/3]
PD# 153294 1.add function setOsdMouse 2.add listener modeChangeEventListener setOsdMouse when the following happens: 1)first launch platform 2)change display mode 3)hot plug Change-Id: Ie60ea90d695f01d2b4fd414f1f00ffde7a3eaf47
Diffstat
-rw-r--r--hwc2/common/devices/PhysicalDevice.cpp85
-rw-r--r--hwc2/common/devices/PrimaryDevice.cpp36
-rw-r--r--hwc2/common/utils/Utils.cpp16
-rw-r--r--hwc2/common/utils/Utils.h4
-rw-r--r--hwc2/include/PhysicalDevice.h20
-rw-r--r--hwc2/include/PrimaryDevice.h7
6 files changed, 163 insertions, 5 deletions
diff --git a/hwc2/common/devices/PhysicalDevice.cpp b/hwc2/common/devices/PhysicalDevice.cpp
index 69264f8..85490e8 100644
--- a/hwc2/common/devices/PhysicalDevice.cpp
+++ b/hwc2/common/devices/PhysicalDevice.cpp
@@ -134,6 +134,27 @@ bool PhysicalDevice::initialize() {
return true;
}
+auto PhysicalDevice::getSystemControlService() {
+ static bool bGot = false;
+ static auto systemControl = ISystemControl::getService();
+ if (bGot) {
+ ETRACE("systemControl is already exist");
+ return systemControl;
+ }
+ mDeathRecipient = new SystemControlDeathRecipient();
+ Return<bool> linked = systemControl->linkToDeath(mDeathRecipient, /*cookie*/ 0);
+ if (!linked.isOk()) {
+ ETRACE("Transaction error in linking to system service death: %s",
+ linked.description().c_str());
+ } else if (!linked) {
+ ETRACE("Unable to link to system service death notifications");
+ } else {
+ DTRACE("Link to system service death notification successful");
+ }
+ bGot = true;
+ return systemControl;
+}
+
void PhysicalDevice::updateDisplayInfo(char defaultMode[64]) {
if (!strncmp(defaultMode, "720", 3)) {
mDisplayWidth= FULL_WIDTH_720;
@@ -705,6 +726,7 @@ int32_t PhysicalDevice::postFramebuffer(int32_t* outRetireFence, bool hasVideoOv
Utils::setSysfsStr(DISPLAY_LOGO_INDEX, "-1");
Utils::setSysfsStr(DISPLAY_FB0_FREESCALE_SWTICH, "0x10001");
+ setOsdMouse();
}
// real post framebuffer here.
@@ -794,6 +816,69 @@ bool PhysicalDevice::updateCursorBuffer() {
return false;
}
+void PhysicalDevice::setOsdMouse()
+{
+ bool ret = true;
+ char cur_mode[MODE_LEN] = {0};
+ Utils::getSysfsStr(SYSFS_DISPLAY_MODE, cur_mode);
+ DTRACE("set osd mouse mode: %s", cur_mode);
+ int position[4] = { 0, 0, 0, 0 };//x,y,w,h
+ getOsdPosition(cur_mode, position);
+ setOsdMouse(position[0], position[1], position[2], position[3], cur_mode);
+}
+
+void PhysicalDevice::setOsdMouse(int x, int y, int w, int h, const char* cur_mode)
+{
+ DTRACE("set osd mouse x:%d y:%d w:%d h:%d", x, y, w, h);
+ const char* displaySize = "1920 1080";
+ int display_w, display_h;
+ if (!strncmp(mDefaultMode, "720", 3)) {
+ displaySize = "1280 720";
+ } else if (!strncmp(mDefaultMode, "1080", 4)) {
+ displaySize = "1920 1080";
+ } else if (!strncmp(mDefaultMode, "4k2k", 4)) {
+ displaySize = "3840 2160";
+ }
+
+ if (!strcmp(cur_mode, MODE_480I) || !strcmp(cur_mode, MODE_576I) ||
+ !strcmp(cur_mode, MODE_480CVBS) || !strcmp(cur_mode, MODE_576CVBS) ||
+ !strcmp(cur_mode, MODE_1080I50HZ) || !strcmp(cur_mode, MODE_1080I)) {
+ y /= 2;
+ h /= 2;
+ }
+
+ char axis[512] = {0};
+ sprintf(axis, "%d %d %s %d %d 18 18", x, y, displaySize, x, y);
+ Utils::setSysfsStr(SYSFS_DISPLAY_AXIS, axis);
+
+ sprintf(axis, "%s %d %d", displaySize, w, h);
+ sscanf(displaySize,"%d %d",&display_w,&display_h);
+ Utils::setSysfsStr(DISPLAY_FB1_SCALE_AXIS, axis);
+ if ((display_w != w) || (display_h != h)) {
+ Utils::setSysfsStr(DISPLAY_FB1_SCALE, "0x10001");
+ } else {
+ Utils::setSysfsStr(DISPLAY_FB1_SCALE, "0");
+ }
+}
+
+int PhysicalDevice::getOsdPosition(const char* curMode, int *position) {
+ auto scs = getSystemControlService();
+ if (scs == NULL) {
+ ETRACE("syscontrol::getOsdPosition FAIL.");
+ return FAILED_TRANSACTION;
+ }
+ scs->getPosition(curMode, [&position](const Result &ret,
+ int left, int top, int width, int height) {
+ if (ret == Result::OK) {
+ position[0] = left;
+ position[1] = top;
+ position[2] = width;
+ position[3] = height;
+ }
+ });
+ return NO_ERROR;
+}
+
int32_t PhysicalDevice::setOSD1Blank(bool cursorShow) {
framebuffer_info_t* cbInfo = mCursorContext->getInfo();
diff --git a/hwc2/common/devices/PrimaryDevice.cpp b/hwc2/common/devices/PrimaryDevice.cpp
index da28b8e..377db74 100644
--- a/hwc2/common/devices/PrimaryDevice.cpp
+++ b/hwc2/common/devices/PrimaryDevice.cpp
@@ -22,7 +22,6 @@
#include <Utils.h>
#include <SysTokenizer.h>
-
namespace android {
namespace amlogic {
@@ -56,6 +55,10 @@ bool PrimaryDevice::initialize()
Utils::getHotplugUeventEnvelope(),
hotplugEventListener,
this);
+ observer->registerListener(
+ Utils::getModeChangeUeventEnvelope(),
+ modeChangeEventListener,
+ this);
} else {
ETRACE("Uevent observer is NULL");
}
@@ -76,6 +79,15 @@ void PrimaryDevice::hotplugEventListener(void *data, bool status)
}
}
+void PrimaryDevice::modeChangeEventListener(void *data, bool status)
+{
+ PrimaryDevice *pThis = (PrimaryDevice*)data;
+ DTRACE("mode change event: %d", status);
+ if (status && pThis) {
+ pThis->changeModeDetectThread();
+ }
+}
+
void PrimaryDevice::hotplugListener(bool connected)
{
CTRACE();
@@ -124,5 +136,27 @@ int PrimaryDevice::parseConfigFile()
return status;
}
+void PrimaryDevice::changeModeDetectThread()
+{
+ pthread_t id;
+ int ret = pthread_create(&id, NULL, changeModeDetect, this);
+ if (ret != 0)
+ ETRACE("Create changeModeDetect error!\n");
+}
+
+void* PrimaryDevice::changeModeDetect(void* data)
+{
+ PrimaryDevice *pThis = (PrimaryDevice*)data;
+ bool modeChanged = false;
+ char lastMode[32];
+ Utils::getSysfsStr(SYSFS_DISPLAY_MODE, lastMode);
+ do {
+ modeChanged = Utils::checkSysfsStatus(SYSFS_DISPLAY_MODE, lastMode, 32);
+ usleep(1000 * 1000);
+ } while (!modeChanged);
+ pThis->setOsdMouse();
+ return NULL;
+}
+
} // namespace amlogic
} // namespace android
diff --git a/hwc2/common/utils/Utils.cpp b/hwc2/common/utils/Utils.cpp
index 52b6309..deae89c 100644
--- a/hwc2/common/utils/Utils.cpp
+++ b/hwc2/common/utils/Utils.cpp
@@ -76,6 +76,13 @@ int Utils::getSysfsInt(const char* syspath, int def) {
return val;
}
+int Utils::getSysfsStr(const char *syspath, char *valstr){
+ char buf[MAX_STR_LEN+1] = {0};
+ getSysfsStr(syspath, (char*)buf, MAX_STR_LEN, false);
+ strcpy(valstr, buf);
+ return 0;
+}
+
int Utils::getSysfsStr(const char* syspath, char *valstr, int size,
bool needOriginalData) {
@@ -204,14 +211,19 @@ const char* Utils::getHdcpUeventEnvelope()
return "change@/devices/virtual/switch/hdcp";
}
+const char* Utils::getModeChangeUeventEnvelope()
+{
+ return "change@/devices/virtual/amhdmitx/amhdmitx0/setmode";
+}
+
const char* Utils::getSwitchState0()
{
- return "SWITCH_STATE=0";
+ return "STATE=HDMI=0";
}
const char* Utils::getSwitchState1()
{
- return "SWITCH_STATE=1";
+ return "STATE=HDMI=1";
}
diff --git a/hwc2/common/utils/Utils.h b/hwc2/common/utils/Utils.h
index 8e55e63..f9c782f 100644
--- a/hwc2/common/utils/Utils.h
+++ b/hwc2/common/utils/Utils.h
@@ -33,6 +33,8 @@
#define SYSFS_VIDEOBUFUSED "/sys/class/amstream/videobufused"
#define SYSFS_WINDOW_AXIS "/sys/class/graphics/fb0/window_axis"
+#define MAX_STR_LEN 4096
+
namespace android {
namespace amlogic {
@@ -46,6 +48,7 @@ public:
static bool get_str_prop(const char *key, char *value, const char *def);
static int getSysfsInt(const char* syspath, int def);
+ static int getSysfsStr(const char *syspath, char *valstr);
static int getSysfsStr(const char* syspath, char *valstr, int size,
bool needOriginalData = false);
static int setSysfsStr(const char *path, const char *val);
@@ -60,6 +63,7 @@ public:
static const char* getHotplugUeventEnvelope();
static const char* getHdcpUeventEnvelope();
+ static const char* getModeChangeUeventEnvelope();
static const char* getSwitchState0();
static const char* getSwitchState1();
diff --git a/hwc2/include/PhysicalDevice.h b/hwc2/include/PhysicalDevice.h
index aaa0292..e47982f 100644
--- a/hwc2/include/PhysicalDevice.h
+++ b/hwc2/include/PhysicalDevice.h
@@ -34,6 +34,9 @@
#define DISPLAY_LOGO_INDEX "/sys/module/fb/parameters/osd_logo_index"
#define DISPLAY_FB0_FREESCALE_SWTICH "/sys/class/graphics/fb0/free_scale_switch"
+#define SYSFS_DISPLAY_AXIS "/sys/class/display/axis"
+#define DISPLAY_FB1_SCALE_AXIS "/sys/class/graphics/fb1/scale_axis"
+#define DISPLAY_FB1_SCALE "/sys/class/graphics/fb1/scale"
namespace android {
namespace amlogic {
@@ -144,11 +147,28 @@ public:
virtual void dump(Dump& d);
DisplayHdmi* getDisplayHdmi() const { return mDisplayHdmi; };
+protected:
+ auto getSystemControlService();
+ void setOsdMouse();
+ char mDefaultMode[64];//this used for mbox
+
private:
+
+#if PLATFORM_SDK_VERSION >= 26
+ struct SystemControlDeathRecipient : public android::hardware::hidl_death_recipient {
+ // hidl_death_recipient interface
+ virtual void serviceDied(uint64_t cookie,
+ const ::android::wp<::android::hidl::base::V1_0::IBase>& who) override{};
+ };
+ sp<SystemControlDeathRecipient> mDeathRecipient = nullptr;
+#endif
+
// For use by Device
int32_t initDisplay();
int32_t postFramebuffer(int32_t* outRetireFence, bool hasVideoOverlay);
bool updateCursorBuffer();
+ void setOsdMouse(int x, int y, int w, int h, const char* cur_mode);
+ int getOsdPosition(const char* curMode, int *position);
int32_t getLineValue(const char *lineStr, const char *magicStr);
int32_t clearLayersStats();
diff --git a/hwc2/include/PrimaryDevice.h b/hwc2/include/PrimaryDevice.h
index d003133..7cb8fef 100644
--- a/hwc2/include/PrimaryDevice.h
+++ b/hwc2/include/PrimaryDevice.h
@@ -24,7 +24,7 @@
#include <IComposeDeviceFactory.h>
#define DEVICE_STR_MBOX "MBOX"
-#define DEVICE_STR_TV "TV"
+#define DEVICE_STR_TV "TV"
#if PLATFORM_SDK_VERSION >= 26 //8.0
#define DISPLAY_CFG_FILE "/vendor/etc/mesondisplay.cfg"
@@ -48,13 +48,16 @@ public:
virtual int32_t setOutputBuffer(buffer_handle_t buffer, int32_t releaseFence) { return HWC2_ERROR_NONE; }
private:
+
static void hotplugEventListener(void *data, bool status);
+ static void modeChangeEventListener(void *data, bool status);
void hotplugListener(bool connected);
int parseConfigFile();
+ void changeModeDetectThread();
+ static void* changeModeDetect(void * data);
const char* pConfigPath;
int mDisplayType;
- char mDefaultMode[64];//this used for mbox
};
}