diff --git a/plugins/platforms/hwcomposer/hwcomposer_backend.h b/plugins/platforms/hwcomposer/hwcomposer_backend.h --- a/plugins/platforms/hwcomposer/hwcomposer_backend.h +++ b/plugins/platforms/hwcomposer/hwcomposer_backend.h @@ -34,7 +34,6 @@ typedef struct hwc_display_contents_1 hwc_display_contents_1_t; typedef struct hwc_layer_1 hwc_layer_1_t; typedef struct hwc_composer_device_1 hwc_composer_device_1_t; -struct light_device_t; class HWComposerNativeWindowBuffer; @@ -88,11 +87,8 @@ void toggleBlankOutput(); private: - void initLights(); - void toggleScreenBrightness(); QSize m_displaySize; hwc_composer_device_1_t *m_device = nullptr; - light_device_t *m_lights = nullptr; bool m_outputBlank = true; int m_refreshRate = 60000; int m_vsyncInterval = 16; diff --git a/plugins/platforms/hwcomposer/hwcomposer_backend.cpp b/plugins/platforms/hwcomposer/hwcomposer_backend.cpp --- a/plugins/platforms/hwcomposer/hwcomposer_backend.cpp +++ b/plugins/platforms/hwcomposer/hwcomposer_backend.cpp @@ -34,7 +34,6 @@ // hybris/android #include #include -#include // linux #include @@ -234,7 +233,6 @@ }; m_device->registerProcs(m_device, procs); - initLights(); toggleBlankOutput(); m_filter.reset(new BacklightInputEventFilter(this)); input()->prepandInputEventFilter(m_filter.data()); @@ -250,57 +248,40 @@ if (m_refreshRate != 0) { m_vsyncInterval = 1000000/m_refreshRate; } - if (m_lights) { - using namespace KWayland::Server; - output->setDpmsSupported(true); - auto updateDpms = [this, output] { - output->setDpmsMode(m_outputBlank ? OutputInterface::DpmsMode::Off : OutputInterface::DpmsMode::On); - }; - updateDpms(); - connect(this, &HwcomposerBackend::outputBlankChanged, this, updateDpms); - connect(output, &OutputInterface::dpmsModeRequested, this, - [this] (KWayland::Server::OutputInterface::DpmsMode mode) { - if (mode == OutputInterface::DpmsMode::On) { - if (m_outputBlank) { - toggleBlankOutput(); - } - } else { - if (!m_outputBlank) { - toggleBlankOutput(); - } + + using namespace KWayland::Server; + output->setDpmsSupported(true); + auto updateDpms = [this, output] { + output->setDpmsMode(m_outputBlank ? OutputInterface::DpmsMode::Off : OutputInterface::DpmsMode::On); + }; + updateDpms(); + connect(this, &HwcomposerBackend::outputBlankChanged, this, updateDpms); + connect(output, &OutputInterface::dpmsModeRequested, this, + [this] (KWayland::Server::OutputInterface::DpmsMode mode) { + if (mode == OutputInterface::DpmsMode::On) { + if (m_outputBlank) { + toggleBlankOutput(); + } + } else { + if (!m_outputBlank) { + toggleBlankOutput(); } } - ); - } + } + ); qCDebug(KWIN_HWCOMPOSER) << "Display size:" << m_displaySize; qCDebug(KWIN_HWCOMPOSER) << "Refresh rate:" << m_refreshRate; emit screensQueried(); setReady(true); } -void HwcomposerBackend::initLights() -{ - hw_module_t *lightsModule = nullptr; - if (hw_get_module(LIGHTS_HARDWARE_MODULE_ID, (const hw_module_t **)&lightsModule) != 0) { - qCWarning(KWIN_HWCOMPOSER) << "Failed to get lights module"; - return; - } - light_device_t *lightsDevice = nullptr; - if (lightsModule->methods->open(lightsModule, LIGHT_ID_BACKLIGHT, (hw_device_t **)&lightsDevice) != 0) { - qCWarning(KWIN_HWCOMPOSER) << "Failed to create lights device"; - return; - } - m_lights = lightsDevice; -} - void HwcomposerBackend::toggleBlankOutput() { if (!m_device) { return; } m_outputBlank = !m_outputBlank; - toggleScreenBrightness(); m_device->blank(m_device, 0, m_outputBlank ? 1 : 0); // only disable Vsycn, enable happens after next frame rendered if (m_outputBlank) { @@ -316,21 +297,6 @@ emit outputBlankChanged(); } -void HwcomposerBackend::toggleScreenBrightness() -{ - if (!m_lights) { - return; - } - const int brightness = m_outputBlank ? 0 : 0xFF; - struct light_state_t state; - state.flashMode = LIGHT_FLASH_NONE; - state.brightnessMode = BRIGHTNESS_MODE_USER; - - state.color = (int)((0xffU << 24) | (brightness << 16) | - (brightness << 8) | brightness); - m_lights->set_light(m_lights, &state); -} - void HwcomposerBackend::enableVSync(bool enable) { if (m_hasVsync == enable) {