2020-08-02 22:22:19 +00:00
|
|
|
/*
|
|
|
|
KWin - the KDE window manager
|
|
|
|
This file is part of the KDE project.
|
2015-05-06 15:47:07 +00:00
|
|
|
|
2020-08-02 22:22:19 +00:00
|
|
|
SPDX-FileCopyrightText: 2015 Martin Gräßlin <mgraesslin@kde.org>
|
2015-05-06 15:47:07 +00:00
|
|
|
|
2020-08-02 22:22:19 +00:00
|
|
|
SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
*/
|
2015-05-06 15:47:07 +00:00
|
|
|
#ifndef KWIN_HWCOMPOSER_BACKEND_H
|
|
|
|
#define KWIN_HWCOMPOSER_BACKEND_H
|
2016-04-07 07:24:17 +00:00
|
|
|
#include "platform.h"
|
2019-06-13 09:36:07 +00:00
|
|
|
#include "abstract_wayland_output.h"
|
2016-02-16 09:40:20 +00:00
|
|
|
#include "input.h"
|
2015-05-06 15:47:07 +00:00
|
|
|
|
2016-02-16 09:40:20 +00:00
|
|
|
#include <QElapsedTimer>
|
2015-10-20 11:16:05 +00:00
|
|
|
#include <QMutex>
|
|
|
|
#include <QWaitCondition>
|
|
|
|
|
2017-09-07 06:07:18 +00:00
|
|
|
#include <android-config.h>
|
2015-05-06 15:47:07 +00:00
|
|
|
// libhybris
|
2017-10-23 08:11:32 +00:00
|
|
|
#include <hardware/hwcomposer.h>
|
2015-05-06 15:47:07 +00:00
|
|
|
#include <hwcomposer_window.h>
|
|
|
|
// needed as hwcomposer_window.h includes EGL which on non-arm includes Xlib
|
|
|
|
#include <fixx11h.h>
|
|
|
|
|
|
|
|
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;
|
2015-11-16 08:01:48 +00:00
|
|
|
struct light_device_t;
|
2015-05-06 15:47:07 +00:00
|
|
|
|
2015-10-09 11:12:40 +00:00
|
|
|
class HWComposerNativeWindowBuffer;
|
|
|
|
|
2015-05-06 15:47:07 +00:00
|
|
|
namespace KWin
|
|
|
|
{
|
|
|
|
|
|
|
|
class HwcomposerWindow;
|
2016-02-16 09:40:20 +00:00
|
|
|
class BacklightInputEventFilter;
|
2015-05-06 15:47:07 +00:00
|
|
|
|
2019-06-13 09:36:07 +00:00
|
|
|
class HwcomposerOutput : public AbstractWaylandOutput
|
2019-02-20 13:19:51 +00:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
|
|
|
HwcomposerOutput(hwc_composer_device_1_t *device);
|
|
|
|
~HwcomposerOutput() override;
|
|
|
|
bool isValid() const;
|
|
|
|
|
2020-04-29 15:18:41 +00:00
|
|
|
void updateDpms(KWaylandServer::OutputInterface::DpmsMode mode) override;
|
2019-02-20 13:19:51 +00:00
|
|
|
Q_SIGNALS:
|
2020-04-29 15:18:41 +00:00
|
|
|
void dpmsModeRequested(KWaylandServer::OutputInterface::DpmsMode mode);
|
2019-02-20 13:19:51 +00:00
|
|
|
private:
|
|
|
|
QSize m_pixelSize;
|
|
|
|
hwc_composer_device_1_t *m_device;
|
|
|
|
};
|
|
|
|
|
2016-04-07 07:18:10 +00:00
|
|
|
class HwcomposerBackend : public Platform
|
2015-05-06 15:47:07 +00:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
2016-04-07 07:18:10 +00:00
|
|
|
Q_INTERFACES(KWin::Platform)
|
|
|
|
Q_PLUGIN_METADATA(IID "org.kde.kwin.Platform" FILE "hwcomposer.json")
|
2015-05-06 15:47:07 +00:00
|
|
|
public:
|
|
|
|
explicit HwcomposerBackend(QObject *parent = nullptr);
|
|
|
|
virtual ~HwcomposerBackend();
|
|
|
|
|
|
|
|
void init() override;
|
|
|
|
OpenGLBackend *createOpenGLBackend() override;
|
|
|
|
|
2019-02-20 13:19:51 +00:00
|
|
|
Outputs outputs() const override;
|
|
|
|
Outputs enabledOutputs() const override;
|
2015-05-06 15:47:07 +00:00
|
|
|
|
[platforms/hwcomposer] Add scaling support
Summary:
Despite plasma frameworks doing it's own scaling with fonts, it's been
requested to use kwin/wayland scaling.
Like DRM, when kscreen is not used, scale value is loaded from a config
file.
Config format is
[HWComposerOutputs][0]
Scale=N
The 0 is to map similarly to DRM and support multi-screen, but with a
screen index
rather than a UUID based on EDID.
Because we don't support multi screen this is always 0 for now.
Test Plan: Ran with the config value unset and with the config value at
Scale=3.
Reviewers: #kwin, romangg
Reviewed By: #kwin, romangg
Subscribers: bshah, romangg, nicolasfella, zzag, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D18810
2019-02-22 00:44:12 +00:00
|
|
|
QSize size() const;
|
2019-02-20 13:19:51 +00:00
|
|
|
QSize screenSize() const override;
|
|
|
|
|
[platforms/hwcomposer] Add scaling support
Summary:
Despite plasma frameworks doing it's own scaling with fonts, it's been
requested to use kwin/wayland scaling.
Like DRM, when kscreen is not used, scale value is loaded from a config
file.
Config format is
[HWComposerOutputs][0]
Scale=N
The 0 is to map similarly to DRM and support multi-screen, but with a
screen index
rather than a UUID based on EDID.
Because we don't support multi screen this is always 0 for now.
Test Plan: Ran with the config value unset and with the config value at
Scale=3.
Reviewers: #kwin, romangg
Reviewed By: #kwin, romangg
Subscribers: bshah, romangg, nicolasfella, zzag, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D18810
2019-02-22 00:44:12 +00:00
|
|
|
int scale() const;
|
|
|
|
|
2019-02-20 13:19:51 +00:00
|
|
|
HwcomposerWindow *createSurface();
|
2015-05-06 15:47:07 +00:00
|
|
|
|
|
|
|
hwc_composer_device_1_t *device() const {
|
|
|
|
return m_device;
|
|
|
|
}
|
2015-10-19 08:13:04 +00:00
|
|
|
void enableVSync(bool enable);
|
2015-10-20 11:16:05 +00:00
|
|
|
void waitVSync();
|
|
|
|
void wakeVSync();
|
2015-06-26 08:09:16 +00:00
|
|
|
|
2016-02-16 09:40:20 +00:00
|
|
|
bool isBacklightOff() const {
|
|
|
|
return m_outputBlank;
|
|
|
|
}
|
|
|
|
|
2017-10-15 20:24:49 +00:00
|
|
|
QVector<CompositingType> supportedCompositors() const override {
|
|
|
|
return QVector<CompositingType>{OpenGLCompositing};
|
|
|
|
}
|
|
|
|
|
2015-11-17 13:46:54 +00:00
|
|
|
Q_SIGNALS:
|
|
|
|
void outputBlankChanged();
|
|
|
|
|
2015-05-11 12:43:51 +00:00
|
|
|
private Q_SLOTS:
|
|
|
|
void toggleBlankOutput();
|
[platforms/hwcomposer] Reset old brightness when turning screen back on
Summary:
Now powerdevil can adjust brightness using leds subsystem, however, kwin
as well sets brightness to 0 for turning off screen and 0xff when
turning screen back on. This resets the brightness set by the powerdevil
to 100%.
As a solution now kwin listens to brightnessChanged dbus signal of
brightnesscontrol and book-keeps the changed brightness, if screen is
turned off it sets brightness to 0 and when turning screen on, it resets
to old brightness.
If powermanagement service doesn't appear on dbus by default it restores
100% brightness.
Test Plan:
Appearantly this still doesn't work as-it-is on phone, because powerdevil
doesn't emit brightnessChanged dbus signal because of bug in the driver of
backlight control, driver doesn't seem to trigger uevents for changes in
backlight. But with hack in powerdevil to emit brightnessChanged when setting
brightness, this works
Reviewers: broulik, #plasma_on_wayland, graesslin
Reviewed By: #plasma_on_wayland, graesslin
Subscribers: plasma-devel, kwin
Tags: #plasma_on_wayland, #kwin
Differential Revision: https://phabricator.kde.org/D2468
2016-08-17 09:09:58 +00:00
|
|
|
void screenBrightnessChanged(int brightness) {
|
|
|
|
m_oldScreenBrightness = brightness;
|
|
|
|
}
|
2015-05-11 12:43:51 +00:00
|
|
|
|
2015-05-06 15:47:07 +00:00
|
|
|
private:
|
2015-11-16 08:01:48 +00:00
|
|
|
void initLights();
|
|
|
|
void toggleScreenBrightness();
|
2015-05-06 15:47:07 +00:00
|
|
|
hwc_composer_device_1_t *m_device = nullptr;
|
2015-11-16 08:01:48 +00:00
|
|
|
light_device_t *m_lights = nullptr;
|
2015-05-11 12:43:51 +00:00
|
|
|
bool m_outputBlank = true;
|
2015-10-20 11:16:05 +00:00
|
|
|
int m_vsyncInterval = 16;
|
2016-12-15 14:02:49 +00:00
|
|
|
uint32_t m_hwcVersion;
|
2016-08-18 12:26:24 +00:00
|
|
|
int m_oldScreenBrightness = 0x7f;
|
2015-10-19 08:13:04 +00:00
|
|
|
bool m_hasVsync = false;
|
2015-10-20 11:16:05 +00:00
|
|
|
QMutex m_vsyncMutex;
|
|
|
|
QWaitCondition m_vsyncWaitCondition;
|
2016-02-16 09:40:20 +00:00
|
|
|
QScopedPointer<BacklightInputEventFilter> m_filter;
|
2019-02-20 13:19:51 +00:00
|
|
|
QScopedPointer<HwcomposerOutput> m_output;
|
2015-05-06 15:47:07 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class HwcomposerWindow : public HWComposerNativeWindow
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
virtual ~HwcomposerWindow();
|
|
|
|
|
2015-10-09 11:12:40 +00:00
|
|
|
void present(HWComposerNativeWindowBuffer *buffer);
|
2015-05-06 15:47:07 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
friend HwcomposerBackend;
|
|
|
|
HwcomposerWindow(HwcomposerBackend *backend);
|
|
|
|
HwcomposerBackend *m_backend;
|
|
|
|
hwc_display_contents_1_t **m_list;
|
|
|
|
};
|
|
|
|
|
2016-02-16 09:40:20 +00:00
|
|
|
class BacklightInputEventFilter : public InputEventFilter
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
BacklightInputEventFilter(HwcomposerBackend *backend);
|
|
|
|
virtual ~BacklightInputEventFilter();
|
|
|
|
|
|
|
|
bool pointerEvent(QMouseEvent *event, quint32 nativeButton) override;
|
|
|
|
bool wheelEvent(QWheelEvent *event) override;
|
|
|
|
bool keyEvent(QKeyEvent *event) override;
|
2019-08-17 10:54:09 +00:00
|
|
|
bool touchDown(qint32 id, const QPointF &pos, quint32 time) override;
|
|
|
|
bool touchMotion(qint32 id, const QPointF &pos, quint32 time) override;
|
|
|
|
bool touchUp(qint32 id, quint32 time) override;
|
2016-02-16 09:40:20 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
void toggleBacklight();
|
|
|
|
HwcomposerBackend *m_backend;
|
|
|
|
QElapsedTimer m_doubleTapTimer;
|
|
|
|
QVector<qint32> m_touchPoints;
|
|
|
|
bool m_secondTap = false;
|
|
|
|
};
|
|
|
|
|
2015-05-06 15:47:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|