diff options
author | Long Ling <longling@google.com> | 2020-07-23 13:50:25 -0700 |
---|---|---|
committer | Long Ling <longling@google.com> | 2020-07-31 11:27:31 -0700 |
commit | 20db70be212cfadb60a0193db63e2e292a7658fb (patch) | |
tree | 165dc76d30f37f77902cc15e5b3b36014363ff6c /libhwc2.1/libmaindisplay | |
parent | 5a03eebf3a6ef4e6102827b293879f3b4c9dd375 (diff) | |
download | gs101-20db70be212cfadb60a0193db63e2e292a7658fb.tar.gz |
libhwc2.1: load displaycolor library at runtime
To remove HWC compile dependency on vendor.
Bug: 158048652
Change-Id: Ifae4b4fa2bb7079e6fbbfb2910b8b722a787c530
Signed-off-by: Long Ling <longling@google.com>
Diffstat (limited to 'libhwc2.1/libmaindisplay')
-rw-r--r-- | libhwc2.1/libmaindisplay/DisplayColorLoader.h | 62 | ||||
-rw-r--r-- | libhwc2.1/libmaindisplay/ExynosPrimaryDisplayModule.cpp | 4 | ||||
-rw-r--r-- | libhwc2.1/libmaindisplay/ExynosPrimaryDisplayModule.h | 8 |
3 files changed, 69 insertions, 5 deletions
diff --git a/libhwc2.1/libmaindisplay/DisplayColorLoader.h b/libhwc2.1/libmaindisplay/DisplayColorLoader.h new file mode 100644 index 0000000..c4d7bcd --- /dev/null +++ b/libhwc2.1/libmaindisplay/DisplayColorLoader.h @@ -0,0 +1,62 @@ +/* + * Copyright (C) 2020 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef DISPLAY_COLOR_LOADER_H +#define DISPLAY_COLOR_LOADER_H + +#include <dlfcn.h> +#include <gs101/displaycolor/displaycolor_gs101.h> +#include <log/log.h> +#include <string> + +class DisplayColorLoader { + public: + DisplayColorLoader(const char *lib_name) { + lib_handle = dlopen(lib_name, RTLD_LAZY); + + if (lib_handle != nullptr) { + get_display_color_gs101 = (decltype(get_display_color_gs101)) + dlsym(lib_handle, "GetDisplayColorGS101"); + + if (get_display_color_gs101 == nullptr) { + ALOGE("%s: failed to get GetDisplayColorGS101\n", __func__); + } + } else { + ALOGE("%s: failed to load library %s\n", __func__, lib_name); + get_display_color_gs101 = nullptr; + } + } + + displaycolor::IDisplayColorGS101* GetDisplayColorGS101() { + if (get_display_color_gs101 != nullptr) { + return get_display_color_gs101(); + } + + return nullptr; + } + + ~DisplayColorLoader() { + if (lib_handle != nullptr) { + dlclose(lib_handle); + } + } + + private: + void *lib_handle; + displaycolor::IDisplayColorGS101* (*get_display_color_gs101)(); +}; + +#endif //DISPLAY_COLOR_LOADER_H diff --git a/libhwc2.1/libmaindisplay/ExynosPrimaryDisplayModule.cpp b/libhwc2.1/libmaindisplay/ExynosPrimaryDisplayModule.cpp index 82b8694..4423870 100644 --- a/libhwc2.1/libmaindisplay/ExynosPrimaryDisplayModule.cpp +++ b/libhwc2.1/libmaindisplay/ExynosPrimaryDisplayModule.cpp @@ -33,13 +33,13 @@ mpp_phycal_type_t getMPPTypeFromDPPChannel(uint32_t channel) { } ExynosPrimaryDisplayModule::ExynosPrimaryDisplayModule(uint32_t __unused type, ExynosDevice *device) - : ExynosPrimaryDisplay(HWC_DISPLAY_PRIMARY, device) + : ExynosPrimaryDisplay(HWC_DISPLAY_PRIMARY, device), mDisplayColorLoader(DISPLAY_COLOR_LIB) { #ifdef FORCE_GPU_COMPOSITION exynosHWCControl.forceGpu = true; #endif - mDisplayColorInterface = IDisplayColorGS101::Create(); + mDisplayColorInterface = mDisplayColorLoader.GetDisplayColorGS101(); } ExynosPrimaryDisplayModule::~ExynosPrimaryDisplayModule () { diff --git a/libhwc2.1/libmaindisplay/ExynosPrimaryDisplayModule.h b/libhwc2.1/libmaindisplay/ExynosPrimaryDisplayModule.h index 3feaea7..fe7ccdd 100644 --- a/libhwc2.1/libmaindisplay/ExynosPrimaryDisplayModule.h +++ b/libhwc2.1/libmaindisplay/ExynosPrimaryDisplayModule.h @@ -16,10 +16,12 @@ #ifndef EXYNOS_DISPLAY_MODULE_H #define EXYNOS_DISPLAY_MODULE_H +#include <gs101/displaycolor/displaycolor_gs101.h> + +#include "DisplayColorLoader.h" #include "ExynosDisplay.h" #include "ExynosPrimaryDisplay.h" #include "ExynosLayer.h" -#include <displaycolor/displaycolor_gs101.h> using namespace displaycolor; @@ -129,8 +131,8 @@ class ExynosPrimaryDisplayModule : public ExynosPrimaryDisplay { private: int32_t setLayersColorData(); - std::unique_ptr<IDisplayColorGS101> mDisplayColorInterface; + IDisplayColorGS101 *mDisplayColorInterface; DisplaySceneInfo mDisplaySceneInfo; - + DisplayColorLoader mDisplayColorLoader; }; #endif |