author | Tellen Yu <tellen.yu@amlogic.com> | 2017-08-29 11:14:20 (GMT) |
---|---|---|
committer | Tellen Yu <tellen.yu@amlogic.com> | 2017-09-04 05:14:20 (GMT) |
commit | f1ac07f320abbb28366e070fd1829ecbe680bb70 (patch) | |
tree | b8c1c17f4ed5935dbe16f7b5ee0d3d3dbf6bc238 | |
parent | 9426f3d6aad3b9ce919a22aaa80f9d062cfcf2d1 (diff) | |
download | hwcomposer-f1ac07f320abbb28366e070fd1829ecbe680bb70.zip hwcomposer-f1ac07f320abbb28366e070fd1829ecbe680bb70.tar.gz hwcomposer-f1ac07f320abbb28366e070fd1829ecbe680bb70.tar.bz2 |
hidl: hwc communicate with systemcontrol by hwbinder [3/6]
PD# NONE
in binderied mode, hwc connect to systemcontrol by hwbinder
Change-Id: Icdebbfe054bd094c1f6963e40d6b8dcf42c0dbbc
-rw-r--r-- | hwc2/common/base/Hwcomposer.cpp | 7 | ||||
-rw-r--r-- | hwc2/common/devices/PhysicalDevice.cpp | 53 | ||||
-rw-r--r-- | hwc2/common/hdmi/DisplayHdmi.cpp | 121 | ||||
-rw-r--r-- | hwc2/common/hdmi/DisplayHdmi.h | 19 | ||||
-rw-r--r-- | hwc2/platforms/Android.mk | 13 |
5 files changed, 175 insertions, 38 deletions
diff --git a/hwc2/common/base/Hwcomposer.cpp b/hwc2/common/base/Hwcomposer.cpp index 0602f77..a271778 100644 --- a/hwc2/common/base/Hwcomposer.cpp +++ b/hwc2/common/base/Hwcomposer.cpp @@ -928,12 +928,17 @@ bool Hwcomposer::release() { bool Hwcomposer::initialize(private_module_t *grallocModule) { CTRACE(); - if (!mPlatFactory || !grallocModule) { + if (!mPlatFactory) { DEINIT_AND_RETURN_FALSE("failed to provide a PlatFactory"); } +#if PLATFORM_SDK_VERSION < 26 + if ( !grallocModule) { + DEINIT_AND_RETURN_FALSE("failed to provide a grallocModule"); + } // initial gralloc module. mGrallocModule = grallocModule; +#endif mUeventObserver = new UeventObserver(); if (!mUeventObserver || !mUeventObserver->initialize()) { diff --git a/hwc2/common/devices/PhysicalDevice.cpp b/hwc2/common/devices/PhysicalDevice.cpp index cf4babd..f2125ef 100644 --- a/hwc2/common/devices/PhysicalDevice.cpp +++ b/hwc2/common/devices/PhysicalDevice.cpp @@ -32,6 +32,11 @@ static int Amvideo_Handle = 0; +#include <vendor/amlogic/hardware/systemcontrol/1.0/ISystemControl.h> + +using ::vendor::amlogic::hardware::systemcontrol::V1_0::ISystemControl; +using ::vendor::amlogic::hardware::systemcontrol::V1_0::Result; + namespace android { namespace amlogic { @@ -1325,6 +1330,8 @@ int32_t PhysicalDevice::initDisplay() { fbInfo->fbIdx, fbInfo->info.xres, fbInfo->info.yres); int32_t usage = 0; + +#if PLATFORM_SDK_VERSION < 26 private_module_t *grallocModule = Hwcomposer::getInstance().getGrallocModule(); if (mId == HWC_DISPLAY_PRIMARY) { grallocModule->fb_primary.fb_info = *(fbInfo); @@ -1333,13 +1340,17 @@ int32_t PhysicalDevice::initDisplay() { usage |= GRALLOC_USAGE_EXTERNAL_DISP; } fbInfo->grallocModule = grallocModule; +#endif //Register the framebuffer to gralloc module mFramebufferHnd = new private_handle_t( private_handle_t::PRIV_FLAGS_FRAMEBUFFER, usage, fbInfo->fbSize, 0, 0, fbInfo->fd, bufferSize, 0); +#if PLATFORM_SDK_VERSION < 26 grallocModule->base.registerBuffer(&(grallocModule->base), mFramebufferHnd); +#endif + DTRACE("init_frame_buffer get frame size %d usage %d", bufferSize, usage); } @@ -1400,21 +1411,37 @@ bool PhysicalDevice::updateDisplayConfigs() { //ETRACE("updateDisplayConfigs rate:%d", mDisplayHdmi->getActiveRefreshRate()); // check hdcp authentication status when hotplug is happen. - if (mSystemControl == NULL) { - mSystemControl = getSystemControlService(); - } else { - DTRACE("already have system control instance."); - } - if (mSystemControl != NULL) { - // mSecure = Utils::checkHdcp(); - int status = 0; - mSystemControl->isHDCPTxAuthSuccess(status); - DTRACE("hdcp status: %d", status); - mSecure = (status == 1) ? true : false; - } else { - ETRACE("can't get system control."); + int status = 0; + bool trebleSystemControlEnable = property_get_bool("persist.system_control.treble", true); + sp<ISystemControl> trebleSystemControl; + if (trebleSystemControlEnable) { + ITRACE("ISystemControl::getService"); + trebleSystemControl = ISystemControl::getService(); + if (trebleSystemControl != NULL) { + ITRACE("Link to system service death notification successful"); + + Result ret = trebleSystemControl->isHDCPTxAuthSuccess(); + if (Result::OK == ret) { + status = 1; + } + } + else + ETRACE("ISystemControl::getService fail"); + } + else { + sp<IServiceManager> sm = defaultServiceManager(); + if (sm == NULL) { + ETRACE("Couldn't get default ServiceManager\n"); + return NULL; + } + sp<IBinder> binder = sm->getService(String16("system_control")); + sp<ISystemControlService> sc = interface_cast<ISystemControlService>(binder); + sc->isHDCPTxAuthSuccess(status); } + DTRACE("hdcp status: %d", status); + mSecure = (status == 1) ? true : false; + return true; } diff --git a/hwc2/common/hdmi/DisplayHdmi.cpp b/hwc2/common/hdmi/DisplayHdmi.cpp index f49b826..50cd93a 100644 --- a/hwc2/common/hdmi/DisplayHdmi.cpp +++ b/hwc2/common/hdmi/DisplayHdmi.cpp @@ -6,26 +6,20 @@ #include <gui/SurfaceComposerClient.h> #include <gui/ISurfaceComposer.h> #include "DisplayHdmi.h" +#include <cutils/properties.h> namespace android { namespace amlogic { +void DisplayHdmi::SystemControlDeathRecipient::serviceDied( + uint64_t, const wp<::android::hidl::base::V1_0::IBase>&) { + ETRACE("system_control died, need reconnect it\n"); +} + DisplayHdmi::DisplayHdmi(hwc2_display_t id) { mDisplayId = id; - sp<IServiceManager> sm = defaultServiceManager(); - if (sm == NULL) - { - ETRACE("Couldn't get default ServiceManager\n"); - return ; - } - - mSystemControlService = interface_cast<ISystemControlService>(sm->getService(String16("system_control"))); - if (mSystemControlService == NULL) - { - ETRACE("Couldn't get connection to SystemControlService\n"); - return ; - } + mTrebleSystemControlEnable = property_get_bool("persist.system_control.treble", true); initModes(); } @@ -34,6 +28,39 @@ DisplayHdmi::~DisplayHdmi() { mAllModes.clear(); } +void DisplayHdmi::initBinderService() { + mTrebleSystemControl = nullptr; + sp<ISystemControl> control = nullptr; + + if (mTrebleSystemControlEnable) { + control = ISystemControl::getService(); + mDeathRecipient = new SystemControlDeathRecipient(); + Return<bool> linked = control->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 { + ITRACE("Link to system service death notification successful"); + } + + mTrebleSystemControl = control; + } + else { + sp<IServiceManager> sm = defaultServiceManager(); + if (sm == NULL) { + ETRACE("Couldn't get default ServiceManager\n"); + return ; + } + + mSystemControlService = interface_cast<ISystemControlService>(sm->getService(String16("system_control"))); + if (mSystemControlService == NULL) { + ETRACE("Couldn't get connection to SystemControlService\n"); + return ; + } + } +} + void DisplayHdmi::initialize() { reset(); } @@ -61,6 +88,7 @@ bool DisplayHdmi::updateHotplug(bool connected, private_handle_t* framebufferHnd) { bool ret = true; int32_t rate; + initBinderService(); mConnected = connected; @@ -76,7 +104,17 @@ bool DisplayHdmi::updateHotplug(bool connected, //hdmi plug out when system is starting up std::string dispMode; int width, height; - mSystemControlService->getActiveDispMode(&dispMode); + if (mTrebleSystemControlEnable) { + mTrebleSystemControl->getActiveDispMode([&dispMode](const Result &ret, const hidl_string& mode) { + if (Result::OK == ret) { + dispMode = mode.c_str(); + } + }); + } + else { + mSystemControlService->getActiveDispMode(&dispMode); + } + ret = calcMode2Config(dispMode.c_str(), &rate, &width, &height); if (!ret) { dispMode = std::string("1080p60hz"); @@ -113,9 +151,16 @@ bool DisplayHdmi::updateHotplug(bool connected, updateDisplayConfigures(); updateActiveDisplayConfigure(); - ALOGD("updateHotplug setDisplayMode to %s", mActiveDisplaymode); std::string strmode(mActiveDisplaymode); - mSystemControlService->setActiveDispMode(strmode); + if (mTrebleSystemControlEnable) { + hidl_string mode(strmode); + Result ret = mTrebleSystemControl->setActiveDispMode(mode); + if (Result::OK == ret) { + } + } + else { + mSystemControlService->setActiveDispMode(strmode); + } } std::thread t1(&DisplayHdmi::setSurfaceFlingerActiveMode, this); @@ -129,7 +174,7 @@ int DisplayHdmi::updateDisplayModeList() { mSupportDispModes.clear(); bool fullActiveMode = Utils::get_bool_prop("ro.sf.full_activemode"); - bool isConfiged = readConfigFile("/system/etc/displayModeList.cfg", &mSupportDispModes); + bool isConfiged = readConfigFile("/vendor/etc/displayModeList.cfg", &mSupportDispModes); if (isConfiged) { return 0; } @@ -141,7 +186,20 @@ int DisplayHdmi::updateDisplayModeList() { std::vector<std::string> getSupportDispModes; std::string::size_type pos; - mSystemControlService->getSupportDispModeList(&getSupportDispModes); + if (mTrebleSystemControlEnable) { + mTrebleSystemControl->getSupportDispModeList( + [&getSupportDispModes](const Result &ret, const hidl_vec<hidl_string>& modeList) { + if (Result::OK == ret) { + for (size_t i = 0; i < modeList.size(); i++) { + getSupportDispModes.push_back(modeList[i]); + } + } + }); + } + else { + mSystemControlService->getSupportDispModeList(&getSupportDispModes); + } + if (getSupportDispModes.size() == 0) { ALOGD("SupportDispModeList null!!!"); return -1; @@ -177,7 +235,18 @@ int DisplayHdmi::updateDisplayModeList() { int DisplayHdmi::updateActiveDisplayMode() { std::string dispMode; - mSystemControlService->getActiveDispMode(&dispMode); + + if (mTrebleSystemControlEnable) { + mTrebleSystemControl->getActiveDispMode([&dispMode](const Result &ret, const hidl_string& mode) { + if (Result::OK == ret) { + dispMode = mode.c_str(); + } + }); + } + else { + mSystemControlService->getActiveDispMode(&dispMode); + } + strcpy(mActiveDisplaymode, dispMode.c_str()); int refreshRate = 60; @@ -206,7 +275,15 @@ int DisplayHdmi::setDisplayMode(const char* displaymode) { ALOGD("setDisplayMode to %s", displaymode); std::string strmode(displaymode); - mSystemControlService->setActiveDispMode(strmode); + if (mTrebleSystemControlEnable) { + hidl_string mode(strmode); + Result ret = mTrebleSystemControl->setActiveDispMode(mode); + if (Result::OK == ret) { + } + } + else { + mSystemControlService->setActiveDispMode(strmode); + } updateActiveDisplayMode(); @@ -446,12 +523,12 @@ bool DisplayHdmi::readConfigFile(const char* configPath, std::vector<std::string } void DisplayHdmi::setSurfaceFlingerActiveMode() { + /* sp<IBinder> dtoken(SurfaceComposerClient::getBuiltInDisplay( ISurfaceComposer::eDisplayIdMain)); SurfaceComposerClient::setActiveConfig(dtoken, mDisplayConfigs.size()-mActiveDisplayConfigItem-1); - - return; + */ } void DisplayHdmi::initModes() { diff --git a/hwc2/common/hdmi/DisplayHdmi.h b/hwc2/common/hdmi/DisplayHdmi.h index 2d27150..785b40b 100644 --- a/hwc2/common/hdmi/DisplayHdmi.h +++ b/hwc2/common/hdmi/DisplayHdmi.h @@ -20,8 +20,16 @@ #include <ISystemControlService.h> #include <gui/SurfaceComposerClient.h> +#include <vendor/amlogic/hardware/systemcontrol/1.0/ISystemControl.h> + #define HWC_DISPLAY_MODE_LENGTH 32 +using ::vendor::amlogic::hardware::systemcontrol::V1_0::ISystemControl; +using ::vendor::amlogic::hardware::systemcontrol::V1_0::Result; +using ::android::hardware::hidl_vec; +using ::android::hardware::hidl_string; +using ::android::hardware::Return; + namespace android { namespace amlogic { @@ -98,9 +106,20 @@ public: void dump(Dump& d); private: + void initBinderService(); + 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; + }; + hwc2_display_t mDisplayId; //0-primary 1-external bool mConnected; + bool mTrebleSystemControlEnable; sp<ISystemControlService> mSystemControlService; + sp<ISystemControl> mTrebleSystemControl; + sp<SystemControlDeathRecipient> mDeathRecipient = nullptr; sp<SurfaceComposerClient> mComposerClient; //display outputmode as 4k20hz, 1080p60hz, panel. etc. diff --git a/hwc2/platforms/Android.mk b/hwc2/platforms/Android.mk index 31b6698..76782d6 100644 --- a/hwc2/platforms/Android.mk +++ b/hwc2/platforms/Android.mk @@ -16,7 +16,7 @@ endif LOCAL_SRC_FILES := \ ../common/base/HwcLayer.cpp \ - ../common/base/HwcFenceControl.cpp \ + ../common/base/HwcFenceControl.cpp \ ../common/base/Hwcomposer.cpp \ ../common/base/HwcModule.cpp \ ../common/base/VsyncManager.cpp \ @@ -37,7 +37,7 @@ LOCAL_SRC_FILES += \ LOCAL_SHARED_LIBRARIES := \ libcutils \ liblog \ - libEGL \ + libEGL \ libdl \ libhardware \ libutils \ @@ -49,6 +49,13 @@ LOCAL_SHARED_LIBRARIES := \ libsystemcontrolservice \ libgui +# added for treble +LOCAL_SHARED_LIBRARIES += \ + vendor.amlogic.hardware.systemcontrol@1.0 \ + libbase \ + libhidlbase \ + libhidltransport + LOCAL_STATIC_LIBRARIES := \ libomxutil @@ -95,6 +102,8 @@ LOCAL_C_INCLUDES += $(MESON_GRALLOC_DIR) LOCAL_C_INCLUDES += system/core/libion/include/ \ system/core/libion/kernel-headers +LOCAL_CFLAGS += -DPLATFORM_SDK_VERSION=$(PLATFORM_SDK_VERSION) + ifeq ($(TARGET_APP_LAYER_USE_CONTINUOUS_BUFFER),true) LOCAL_CFLAGS += -DUSE_CONTINOUS_BUFFER_COMPOSER # LOCAL_CFLAGS += -DENABLE_AML_GE2D_COMPOSER |