Commit graph

27 commits

Author SHA1 Message Date
Martin Gräßlin
2bff90976e Move backends/ to plugins/platforms/
Summary:
Source code reorganization:
The base class AbstractBackend got renamed to Platform, thus the
"backends" are "platforms" now. As they are plugins they should go
together with other KWin plugins which are nowadays in the folder
plugins.

So new location is plugins/platforms/

Reviewers: #plasma, sebas

Subscribers: plasma-devel

Projects: #plasma

Differential Revision: https://phabricator.kde.org/D1353
2016-04-12 08:01:27 +02:00
Martin Gräßlin
10632f09ca Rename AbstractBackend to Platform 2016-04-07 16:18:12 +02:00
Martin Gräßlin
146af48f22 waylandServer()->backend() replaced by kwinApp()->platform() 2016-04-07 15:00:11 +02:00
Martin Gräßlin
1c4c5caf65 [backends/hwcomposer] Use input event filter for turning screen on/off
Like in the drm backend we use an InputEventFilter to turn the backlight
on and off. In this case the filter needs to be always installed as key
event should also turn the screen off. We cannot use a global shortcut
as it would not trigger while the screen is locked.

Unlike the filter in DRM backend only the power key can toggle the
backlight, other key events are ignored. For pointer we are optimistic
and already support enabling the backlight. Double tap to wake is also
implemented, but at least on reference hardware (Nexus 5) doesn't work
as disabling the backlight also disables touch input.

Reviewed-By: Bhushan Shah
2016-02-16 10:49:04 +01:00
Martin Gräßlin
3361373445 [backends/hwcomposer] Announce support for DPMS
Hooked up to toggle blank output dependent on state.

REVIEW: 126095
2015-11-23 11:48:39 +01:00
Martin Gräßlin
e71a230213 [hwcomposer] Add support for backlight through light_device_t
We use the hw module's backlight and set the color to either 0
or FF depending on whetehr we want to have the screen on or off.
This turns the backlight off properly. It is bound to the toggleBlank
functionality so that we always turn on/off the backlight depending
on whether our compositor is on or off.

In addition we listen to key release events on the power button to
toggle the state.

REVIEW: 126083
2015-11-17 14:45:34 +01:00
Martin Gräßlin
8d00355448 [hwcomposer] Don't waitVsync if we haven't activated vsync yet
Would just hit the timeout, no need to wait 16 msec for nothing.
2015-11-17 14:45:34 +01:00
Martin Gräßlin
eb5ff917f6 [backends/hwcomposer] Blank output on tear down
This gives a better tear down experience as it goes to black instead
of showing outdated screen and also it disables vsync which fixes a
crash on teardown.
2015-11-13 17:39:16 +01:00
Martin Gräßlin
93b5e13308 [hwcomposer] Rework the vsync code
This changes how we synchronize through vsync. We use a mutex and a
wait condition to synchronize the threads. When presenting the frame
our main gui thread blocks and will be woken up by the vsync event
(or a timeout of max 1 frame time slot). In order to minimize the
blocked time we use the blocksForRetrace functionality from the GLX
compositor.

Given this change we no longer need to tell the compositor that we
are swapping the frame, it's blocked anyway. Also we don't need the
failsafe QTimer anymore.

With this change applied on a Nexus 5 it's succeeding the "Martin
tortures phone test". It doesn't tear anymore and has a smooth
experience.

I'm rather disappointed by the fact that we need to block in order
to get vsync. This means Android/hwcomposer is as bad as GLX. So
much for the "Android stack is so awesome", in fact it's not. Anybody
thinking it's awesome should compare to DRM/KMS and especially atomic
modesetting. Yes it's possible to present frames without tearing and
without having to block the rendering thread.

Reviewed-By: Marco Martin and Bhushan Shah
2015-10-20 13:16:05 +02:00
Martin Gräßlin
b38999e0a9 [hwcomposer] Use three rendering buffers
Seems to improve the tearing problem.
2015-10-20 11:39:42 +02:00
Martin Gräßlin
98a669d70f [hwcomposer] Use newer setOutputsEnabled API instead of blocking buffer swap
The newer API is designed for the case that outputs are disabled and
makes sure that we don't have to abuse the aboutToSwapBuffers. This
also prevents possible conflicts between blocking during rendering and
screens being off.

Reviewed-By: Bhushan Shah
2015-10-20 09:39:03 +02:00
Martin Graesslin
d2cb445f4c Delay enabling vsync till first frame is rendered
According to the hwcomposer documentation:
"It is a (silent) error to have HWC_EVENT_VSYNC enabled when calling
hwc_composer_device.set(..., 0, 0, 0) (screen off)".

Because of that we may not enable vsync directly after toggling the
output, but need to wait till after calling the set call.

Reviewed-by: Bhushan Shah
2015-10-19 10:18:48 +02:00
Martin Gräßlin
70e744fe26 [backends/hwcomposer] Add a failsafe timer for vsync events
Apparently we don't get a vsync event for the first frame during startup
which blocks the compositor till the end of days. Thus a timer is added
which calls vsync after 1 sec if we didn't get an event.
2015-10-16 18:19:10 +02:00
Martin Gräßlin
f36af69a0e [hwcomposer] Add support for vsync
Note: qt5-qpa-hwcomposer-plugin does the vsync in a different way:
it uses a wait condition to truly block in present till the vsync.
Maybe we need to do that as well.
2015-10-15 09:17:57 +02:00
Martin Graesslin
28fe78a94f Adjust to newer upstream libhybris version
Based on a previous patch done by David Edmundson and heavily
inspired by qt5-qpa-hwcomposer-plugin [1].

The change requires a newer libhybris than the one used by Ubuntu. In
fact it allows to build against current master (at the day of writing [2]).

REVIEW: 125606

[1] https://github.com/mer-hybris/qt5-qpa-hwcomposer-plugin
[2] bd6df6a306
2015-10-14 08:14:24 +02:00
Martin Graesslin
425e703dff Drop Android input handling
Libinput does work on libhybris enabled devices. There is no need to
use Android's input stack. This simplifies our code a lot and increases
sharing with normal Linux systems.

What's tricky is to convince the system to use libinput through with our
logind helper. Logind fails to open the files for us if we start KWin
over either ssh or adb shell. We need to get it into a proper session, so
only a kwin started through a helper like simplelogin will be able to use
libinput.

REVIEW: 125608
2015-10-14 08:13:37 +02:00
Martin Gräßlin
67734050e6 [hwcomposer] Get refresh rate 2015-06-25 18:04:06 +02:00
Martin Gräßlin
53dcd98b8b [hwcomposer] Switch to format HAL_PIXEL_FORMAT_RGB_888
We clearly do not need an alpha channel for our scene.
2015-06-25 15:49:52 +02:00
Martin Gräßlin
b8ae823b50 [hwcomposer] Announce support for pointer
Without announcing pointer support the touch-to-pointer translation
in KWayland::Server might not work.
2015-06-24 08:41:10 +02:00
David Edmundson
268eb70016 [hwcomposer] Only update the attached screen 2015-06-17 15:08:49 -07:00
David Edmundson
5115d54926 Multitouch on hwcomposer
REVIEW: 123796
2015-05-15 13:28:29 +01:00
Martin Gräßlin
d6700ff9f9 [backends/hwcomposer] Forward input events to main thread
Libhybris input events are generated in a different thread, but we want
them in the main thread (InputRedirection and KWayland are not (yet)
thread safe). Thus all events need to be send to the main thread using
QMetaObject::invokeMethod.
2015-05-11 15:43:30 +02:00
Martin Gräßlin
d5d304c2f6 [backends/hwcompser] Toggle blank screen on power button press
Also blocks compositor while screen is turned off.
2015-05-11 15:24:23 +02:00
Martin Gräßlin
533a39bc3e [backends/hwcomposer] Perform mapping of key codes
Not all key codes are mapped yet. Those not mapped have KEY_RESERVED
as mapping value and those are not forwarded to InputRedirection.
2015-05-11 14:28:32 +02:00
Martin Graesslin
6a66d84f5c [backends/hwcomper] Initial support for input handling
Unfortunately on libhybris enabled systems libinput doesn't work, thus
the backend needs to handle input events which can be read from hybris.
So far the backend only handles touch events properly, though some
aspects look wrong. E.g. motion gives only for one touch contact point.
Unfortunately the documentation is quite weak, so there might be
something important missing.
2015-05-09 16:22:27 +02:00
Martin Gräßlin
1f62c0acb0 [backends/hwcomposer] Handle OutputInterfaces in Backend
Allows to read the DPI information and export the physical display
size from it. DPI is scaled by 1000 in hwcomposer, split by X and Y,
which allows to calculate size in mm from pixel size.
2015-05-08 21:41:38 +02:00
Martin Graesslin
e12400a675 Add a hwcomposer backend based on libhybris
This backend interacts with libhybris to create a hwcomposer which is
used for creating the egl context and surface. The initial version of
this backend is based on test_hwcomposer.cpp provided by libhybris.

Please note that using the hwcomposer backend requires a newer libepoxy,
the latest stable release is not able to bring up OpenGLES, so one needs
a master build of libepoxy.

Notes on licensing:
libhybris is Apache 2.0 licensed, which is not compatile with GPLv2.
But it is compatible with GPLv3. Thus the source files in the hwcomposer
backend are licensed GPLv3+ and not GPLv2+ as the rest of KWin. If one
uses KWin without the hwcomposer backend (which is obviously the default)
the licence doesn't change. But if the hwcomposer backend is used the
overall license of KWin changes to GPLv3+.
2015-05-08 10:28:52 +02:00