Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 355f6046 authored by Dan Stoza's avatar Dan Stoza
Browse files

HWC2: Change version detection scheme

SurfaceFlinger now checks hardware composer module numbers by looking
at device.version, the high byte of which corresponds to the HWC
major version (0x01... for HWC 1.x and 0x02... for HWC 2.0).

Bug: 28161397
Change-Id: I4560bf60c35bdb97629fda1aa1256b03122688ad
parent 6979bb98
Loading
Loading
Loading
Loading
+13 −15
Original line number Diff line number Diff line
@@ -116,22 +116,20 @@ void HWComposer::loadHwcModule()
        abort();
    }

    if (module->module_api_version >= 0x0200) {
        hwc2_device_t* hwc2device = nullptr;
        int error = hwc2_open(module, &hwc2device);
    hw_device_t* device = nullptr;
    int error = module->methods->open(module, HWC_HARDWARE_COMPOSER, &device);
    if (error != 0) {
            ALOGE("Failed to open HWC2 device (%s), aborting", strerror(-error));
        ALOGE("Failed to open HWC device (%s), aborting", strerror(-error));
        abort();
    }
        mHwcDevice = std::make_unique<HWC2::Device>(hwc2device);

    uint32_t majorVersion = (device->version >> 24) & 0xF;
    if (majorVersion == 2) {
        mHwcDevice = std::make_unique<HWC2::Device>(
                reinterpret_cast<hwc2_device_t*>(device));
    } else {
        hwc_composer_device_1_t* hwc1device = nullptr;
        int error = hwc_open_1(module, &hwc1device);
        if (error) {
            ALOGE("Failed to open HWC1 device (%s), aborting", strerror(-error));
            abort();
        }
        mAdapter = std::make_unique<HWC2On1Adapter>(hwc1device);
        mAdapter = std::make_unique<HWC2On1Adapter>(
                reinterpret_cast<hwc_composer_device_1_t*>(device));
        uint8_t minorVersion = mAdapter->getHwc1MinorVersion();
        if (minorVersion < 1) {
            ALOGE("Cannot adapt to HWC version %d.%d",