Loading graphics/composer/2.1/default/Android.bp +2 −1 Original line number Diff line number Diff line Loading @@ -38,7 +38,8 @@ cc_library_shared { "liblog", "libsync", "libutils", "libhwc2on1adapter" "libhwc2on1adapter", "libhwc2onfbadapter", ], } Loading graphics/composer/2.1/default/Hwc.cpp +43 −10 Original line number Diff line number Diff line Loading @@ -23,8 +23,10 @@ #include <log/log.h> #include "ComposerClient.h" #include "hardware/fb.h" #include "hardware/hwcomposer.h" #include "hwc2on1adapter/HWC2On1Adapter.h" #include "hwc2onfbadapter/HWC2OnFbAdapter.h" using namespace std::chrono_literals; Loading @@ -37,6 +39,30 @@ namespace implementation { HwcHal::HwcHal(const hw_module_t* module) : mDevice(nullptr), mDispatch(), mMustValidateDisplay(true), mAdapter() { uint32_t majorVersion; if (module->id && strcmp(module->id, GRALLOC_HARDWARE_MODULE_ID) == 0) { majorVersion = initWithFb(module); } else { majorVersion = initWithHwc(module); } initCapabilities(); if (majorVersion >= 2 && hasCapability(Capability::PRESENT_FENCE_IS_NOT_RELIABLE)) { ALOGE("Present fence must be reliable from HWC2 on."); abort(); } initDispatch(); } HwcHal::~HwcHal() { hwc2_close(mDevice); } uint32_t HwcHal::initWithHwc(const hw_module_t* module) { // Determine what kind of module is available (HWC2 vs HWC1.X). hw_device_t* device = nullptr; int error = module->methods->open(module, HWC_HARDWARE_COMPOSER, &device); Loading Loading @@ -65,19 +91,22 @@ HwcHal::HwcHal(const hw_module_t* module) mDevice = reinterpret_cast<hwc2_device_t*>(device); } initCapabilities(); if (majorVersion >= 2 && hasCapability(Capability::PRESENT_FENCE_IS_NOT_RELIABLE)) { ALOGE("Present fence must be reliable from HWC2 on."); abort(); return majorVersion; } initDispatch(); uint32_t HwcHal::initWithFb(const hw_module_t* module) { framebuffer_device_t* fb_device; int error = framebuffer_open(module, &fb_device); if (error != 0) { ALOGE("Failed to open FB device (%s), aborting", strerror(-error)); abort(); } HwcHal::~HwcHal() { hwc2_close(mDevice); mFbAdapter = std::make_unique<HWC2OnFbAdapter>(fb_device); mDevice = mFbAdapter.get(); return 0; } void HwcHal::initCapabilities() Loading Loading @@ -757,7 +786,11 @@ IComposer* HIDL_FETCH_IComposer(const char*) const hw_module_t* module = nullptr; int err = hw_get_module(HWC_HARDWARE_MODULE_ID, &module); if (err) { ALOGE("failed to get hwcomposer module"); ALOGI("falling back to FB HAL"); err = hw_get_module(GRALLOC_HARDWARE_MODULE_ID, &module); } if (err) { ALOGE("failed to get hwcomposer or fb module"); return nullptr; } Loading graphics/composer/2.1/default/Hwc.h +8 −0 Original line number Diff line number Diff line Loading @@ -34,6 +34,7 @@ namespace android { class HWC2On1Adapter; class HWC2OnFbAdapter; } namespace android { Loading Loading @@ -147,6 +148,9 @@ public: Error setLayerZOrder(Display display, Layer layer, uint32_t z) override; private: uint32_t initWithHwc(const hw_module_t* module); uint32_t initWithFb(const hw_module_t* module); void initCapabilities(); template<typename T> Loading Loading @@ -221,6 +225,10 @@ private: // If the HWC implementation version is < 2.0, use an adapter to interface // between HWC 2.0 <-> HWC 1.X. std::unique_ptr<HWC2On1Adapter> mAdapter; // If there is no HWC implementation, use an adapter to interface between // HWC 2.0 <-> FB HAL. std::unique_ptr<HWC2OnFbAdapter> mFbAdapter; }; extern "C" IComposer* HIDL_FETCH_IComposer(const char* name); Loading Loading
graphics/composer/2.1/default/Android.bp +2 −1 Original line number Diff line number Diff line Loading @@ -38,7 +38,8 @@ cc_library_shared { "liblog", "libsync", "libutils", "libhwc2on1adapter" "libhwc2on1adapter", "libhwc2onfbadapter", ], } Loading
graphics/composer/2.1/default/Hwc.cpp +43 −10 Original line number Diff line number Diff line Loading @@ -23,8 +23,10 @@ #include <log/log.h> #include "ComposerClient.h" #include "hardware/fb.h" #include "hardware/hwcomposer.h" #include "hwc2on1adapter/HWC2On1Adapter.h" #include "hwc2onfbadapter/HWC2OnFbAdapter.h" using namespace std::chrono_literals; Loading @@ -37,6 +39,30 @@ namespace implementation { HwcHal::HwcHal(const hw_module_t* module) : mDevice(nullptr), mDispatch(), mMustValidateDisplay(true), mAdapter() { uint32_t majorVersion; if (module->id && strcmp(module->id, GRALLOC_HARDWARE_MODULE_ID) == 0) { majorVersion = initWithFb(module); } else { majorVersion = initWithHwc(module); } initCapabilities(); if (majorVersion >= 2 && hasCapability(Capability::PRESENT_FENCE_IS_NOT_RELIABLE)) { ALOGE("Present fence must be reliable from HWC2 on."); abort(); } initDispatch(); } HwcHal::~HwcHal() { hwc2_close(mDevice); } uint32_t HwcHal::initWithHwc(const hw_module_t* module) { // Determine what kind of module is available (HWC2 vs HWC1.X). hw_device_t* device = nullptr; int error = module->methods->open(module, HWC_HARDWARE_COMPOSER, &device); Loading Loading @@ -65,19 +91,22 @@ HwcHal::HwcHal(const hw_module_t* module) mDevice = reinterpret_cast<hwc2_device_t*>(device); } initCapabilities(); if (majorVersion >= 2 && hasCapability(Capability::PRESENT_FENCE_IS_NOT_RELIABLE)) { ALOGE("Present fence must be reliable from HWC2 on."); abort(); return majorVersion; } initDispatch(); uint32_t HwcHal::initWithFb(const hw_module_t* module) { framebuffer_device_t* fb_device; int error = framebuffer_open(module, &fb_device); if (error != 0) { ALOGE("Failed to open FB device (%s), aborting", strerror(-error)); abort(); } HwcHal::~HwcHal() { hwc2_close(mDevice); mFbAdapter = std::make_unique<HWC2OnFbAdapter>(fb_device); mDevice = mFbAdapter.get(); return 0; } void HwcHal::initCapabilities() Loading Loading @@ -757,7 +786,11 @@ IComposer* HIDL_FETCH_IComposer(const char*) const hw_module_t* module = nullptr; int err = hw_get_module(HWC_HARDWARE_MODULE_ID, &module); if (err) { ALOGE("failed to get hwcomposer module"); ALOGI("falling back to FB HAL"); err = hw_get_module(GRALLOC_HARDWARE_MODULE_ID, &module); } if (err) { ALOGE("failed to get hwcomposer or fb module"); return nullptr; } Loading
graphics/composer/2.1/default/Hwc.h +8 −0 Original line number Diff line number Diff line Loading @@ -34,6 +34,7 @@ namespace android { class HWC2On1Adapter; class HWC2OnFbAdapter; } namespace android { Loading Loading @@ -147,6 +148,9 @@ public: Error setLayerZOrder(Display display, Layer layer, uint32_t z) override; private: uint32_t initWithHwc(const hw_module_t* module); uint32_t initWithFb(const hw_module_t* module); void initCapabilities(); template<typename T> Loading Loading @@ -221,6 +225,10 @@ private: // If the HWC implementation version is < 2.0, use an adapter to interface // between HWC 2.0 <-> HWC 1.X. std::unique_ptr<HWC2On1Adapter> mAdapter; // If there is no HWC implementation, use an adapter to interface between // HWC 2.0 <-> FB HAL. std::unique_ptr<HWC2OnFbAdapter> mFbAdapter; }; extern "C" IComposer* HIDL_FETCH_IComposer(const char* name); Loading