Commit Graph

52 Commits (b50f7478769c1b50b48d5f0e9201a8e4b7e275ef)

Author SHA1 Message Date
Xaver Hugl b50f747876 Multi-GPU output support on Wayland
This commit sets up udev and the DrmBackend to list and use all GPUs.

BUG: 425586
BUG: 417323
2020-10-05 21:05:55 +00:00
Aleix Pol d5da366507 Add a generic Output::transformation method
Makes it possible to map any space into the output's coordinates system
2020-08-19 14:51:42 +00:00
Vlad Zahorodnii 4ce853e8e4 Prettify license headers 2020-08-07 19:57:56 +00:00
Vlad Zahorodnii 1fb9f6f13a Switch to SPDX license markers
The main advantage of SPDX license identifiers over the traditional
license headers is that it's more difficult to overlook inappropriate
licenses for kwin, for example GPL 3. We also don't have to copy a
lot of boilerplate text.

In order to create this change, I ran licensedigger -r -c from the
toplevel source directory.
2020-08-07 19:57:56 +00:00
Aleix Pol 4eda4d2b5d drm: prevent cursor buffer leakage
Use smart pointers to make sure we don't dereference valid pointers.
2020-07-27 09:29:11 +00:00
Aleix Pol 3a9d7a6e9d Port KWin to KWaylandServer
Summary: Away from KWayland::Server and KF5WaylandServer.

Test Plan: Builds, ran nested session

Reviewers: #kwin, #plasma, #frameworks, davidedmundson, zzag

Reviewed By: #kwin, #plasma, davidedmundson, zzag

Subscribers: zzag, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D29278
2020-04-30 12:56:08 +02:00
Aleix Pol fa654bda59 drm: Improve QDebug of DrmOutput
Instead of printing as QObject, provide actual information of the
instance.
2020-04-08 16:11:44 +02:00
Aleix Pol 6abd23ed02 Make it possible to have a separate cursor for the tablet
Summary:
As is KWin only had 1 Cursor which was a singleton. This made it impossible for
us to properly implement the tablet (as in drawing tablets) support and show where
we're drawing.
This patch makes it possible to have different Cursors in KWin, it makes all the
current code still follow the mouse but the tablet can still render a cursor.

Test Plan: Tests pass, been using it and works as well as before but with beautiful tablet cursors.

Reviewers: #kwin, cblack, davidedmundson

Reviewed By: #kwin, cblack, davidedmundson

Subscribers: davidedmundson, cblack, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D28155
2020-04-03 01:16:45 +02:00
Roman Gilg 2c66e1f690 Remove orientation sensor
Summary:
This functionality will instead be implemented in KScreen such that manual and
automatic output rotation can be used and configured through a single UI in
unison together.

Test Plan: Compiles.

Reviewers: #kwin, davidedmundson, zzag

Reviewed By: #kwin, zzag

Subscribers: kwin, bshah, davidedmundson, zzag

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D26036
2020-02-29 09:59:30 +05:30
Roman Gilg dfea5798f1 [platforms/drm] Add hardware transformation API
Summary:
Planes might be able to do transformations without compositing required.
When changing the current transform try this with the primary plane. If this
fails fall back to no transformation at all through hardware and communicate
the fact and other information through some getters.

Also adds an environment variable to never do hardware transformations.

Test Plan: Compiles.

Reviewers: #kwin

Subscribers: zzag, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D25906
2020-02-28 12:22:42 +00:00
Roman Gilg e827d0a8ee Use Transform enum internally
Summary:
Instead of using Qt::ScreenOrientation use an enum class that is directly
mapped to KWayland's transformation enums. This simplifies the code.

Test Plan: Compiles and transformations work as before.

Reviewers: #kwin, zzag

Reviewed By: #kwin, zzag

Subscribers: zzag, kwin

Tags: #kwin

Maniphest Tasks: T11670

Differential Revision: https://phabricator.kde.org/D25558
2019-11-27 21:08:20 +01:00
Roman Gilg 6bfa931f2b Associate output transforms and orientations
Summary:
We use internally Qt:ScreenOrientation for representing output transforms.

This is not ideal since the values do not map directly to Wayland transform
values, but we can make it work by using OR combinations of
Qt:ScreenOrientations.

Do this for now and see if we should not better introduce an internal enum
mapped directly.

Additionally the OR combinations need to be handled in the drm backend at
various places accordingly as well (see TODOs).

Test Plan: Compiles

Reviewers: #kwin

Subscribers: kwin

Tags: #kwin

Maniphest Tasks: T11670

Differential Revision: https://phabricator.kde.org/D25505
2019-11-26 22:29:40 +01:00
Roman Gilg df3c1de848 [platforms/drm] Rework enablement and dpms switching
Summary:
This patch further refines output management.

We go now through AbstractWaylandOutput virtual functions to enable and
disable outputs.

Dpms changes and enablement switches use separate code paths at start in the
Drm backend code since they are similar but not the directly same. Common code
is shared though, functions are renamed accordingly.

Asserts have been put in place to better understand and check the control
flow. A seemingly unnecessary call to DrmOutput::pageFlipped on reactivation
after Vt switch has been removed to allow for that.

In future patches we need to look additionally at the legacy mode switching
code path which was and is still not working and better handling of the
current monitor Dpms state. For example a monitor being switched off is not
properly acted on and the workspace still expanded.

Test Plan:
With one and two monitors:
* Dpms off/on
* Vt switches
* Screen disable/enable

Reviewers: #kwin

Subscribers: kwin

Tags: #kwin

Maniphest Tasks: T11459

Differential Revision: https://phabricator.kde.org/D23600
2019-09-05 17:36:21 +02:00
Roman Gilg f7ff62e2e2 Lift output enablement into Platform
Summary:
This lifts the enablement code for outputs from the DRM backend to Platform
allowing other Wayland backends in the future to use this interface as well.

To do that we also create some helper functions on Platform level and have to
spill some KWayland classes into AbstractOutput what motivates a further split
of Platform into a Wayland child class like for AbstractOutput.

Test Plan: Disabled and enabled an output in DRM session.

Reviewers: #kwin

Subscribers: zzag, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D23545
2019-09-05 17:22:44 +02:00
Roman Gilg dbb2cede08 Get output pixel size from output device
Summary:
Get the pixel size directly from the always available output device
interface instead of saving an additional copy in the backends.

Test Plan: Nested Wayland, Drm, virtual backends tested.

Reviewers: #kwin, davidedmundson

Reviewed By: #kwin, davidedmundson

Subscribers: kwin

Tags: #kwin

Maniphest Tasks: T11459

Differential Revision: https://phabricator.kde.org/D23495
2019-08-28 14:54:14 +02:00
Vlad Zagorodniy 1892bd33f2 [platforms/drm] Refactor out Edid class
Summary:
The new class is responsible for parsing EDID blobs. It has pretty
straightforward API: you hand blob data to the constructor and after
that you're ready to query parsed data, e.g. physical size, etc.

The main reason to extract EDID parsing code into a class is to clean up
drm_output.cpp a bit.

Test Plan: Compiles, the DRM platform still works.

Reviewers: #kwin, davidedmundson

Reviewed By: #kwin, davidedmundson

Subscribers: davidedmundson, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D22211
2019-07-02 20:45:55 +03:00
Vlad Zagorodniy 0d381846f1 Backport Night Color feature to X11
Summary:
The color correction manager doesn't make any specific assumptions about
underlying platform, e.g. whether it's x11, etc. The platform just
has to be capable of setting gamma ramps. Given that, there are no any
significant technical blockers for making this feature work on x.

Reviewers: #kwin, davidedmundson, romangg

Reviewed By: #kwin, davidedmundson, romangg

Subscribers: romangg, neobrain, GB_2, filipf, davidedmundson, ngraham, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D21345
2019-06-17 12:09:04 +03:00
Roman Gilg 1a11abc821 [platforms/x11/standalone] Port to AbstractOutput
Summary:
Represent outputs in the X11 session via AbstractOutput. For that we
move all Wayland specific parts of AbstractOutput into a new subclass
AbstractWaylandOutput and let the outputs of our Wayland backends inherit
from there.

This should allow us to get rid of the Screens class later on.

Test Plan: Manually in X session.

Reviewers: #kwin, zzag, davidedmundson

Reviewed By: #kwin, zzag, davidedmundson

Subscribers: ngraham, zzag, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D19208
2019-06-13 11:39:25 +02:00
Fabian Vogt 7804eb41d9 Fix crash due to dangling reference
Summary:
Returning a reference to a value on the stack is broken.
This caused kwin_wayland to crash in openQA with a nullptr deref.

BUG: 407199

Test Plan: Only build tested.

Reviewers: #kwin, zzag

Reviewed By: #kwin, zzag

Subscribers: kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D21085
2019-05-08 19:15:05 +02:00
Aleix Pol 559c2e68d3 Improve behavior of rotated displays
Reviewers: #kwin, davidedmundson

Reviewed By: #kwin, davidedmundson

Subscribers: zzag, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D20255
2019-04-26 13:10:41 +02:00
Vlad Zagorodniy af862a9caf Remove redundant AbstractOutput::internal() method
Summary: We already have AbstractOutput::isInternal() method.

Reviewers: #kwin, davidedmundson

Reviewed By: #kwin, davidedmundson

Subscribers: kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D20587
2019-04-16 10:13:38 +03:00
Erik Kurzinger c898f96df3 [platforms/drm] EGLStream DRM Backend Initial Implementation
Summary:
This is the initial implementation of a DRM backend based on the EGLDevice,
EGLOutput, and EGLStream extensions, supporting NVIDIA graphics hardware using
their proprietary driver. The new backend will be used if the environment
variable KWIN_DRM_USE_EGL_STREAMS is set. On initialization, it will attempt to
create an EGLDevice based on the DRM device currently in use and create
EGLOutputs and EGLStreams for any attached displays. These are used to control
presentation of the final composited frame. Additionally, it will register the
wl_eglstream_controller Wayland interface so that native EGL windows created by
clients can be attached to an EGLStream allowing buffer contents to be shared
with the compositor as a GL texture.

At this time there are two known bugs in the NVIDIA driver's EGL implementation
affecting desktop functionality. The first can result in tooltip windows drawn
by plasmashell to contain incorrect contents. The second prevents KWayland from
being able to query the format of EGLStream-backed buffers which interferes
with the blur effect. Fixes for both of these are currently in development and
should appear in an upcoming NVIDIA driver release.

Additionally, hardware cursors are currently not supported with this backend.
Enabling them causes the desktop to intermittently hang for several seconds.
This is also likely a bug in the NVIDIA DRM-KMS implementation but the root
cause is still under investigation.

Test Plan:
On a system with an NVIDIA graphics card running a recent release of their
proprietary driver

    * Ensure the nvidia_drm kernel module is loaded with the option "modeset=1"
      ("# cat /sys/module/nvidia_drm/parameters/modeset" should print "Y")
    * Ensure EGL external platform support is installed
      https://github.com/NVIDIA/eglexternalplatform
    * Ensure KWin was build with the CMake option
      KWIN_BUILD_EGL_STREAM_BACKEND=ON (this is the default)
    * Start a plasma wayland session with the environment variable
      KWIN_DRM_USE_EGL_STREAMS set
    * Ensure output from KWin OpenGL initialization indicates the NVIDIA EGL
      driver is in use (as opposed to Mesa / llvmpipe).
    * Desktop should be fully functional and perform smoothly.

Reviewers: #kwin, romangg, davidedmundson

Reviewed By: #kwin, romangg, davidedmundson

Subscribers: kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D18570
2019-04-15 07:26:22 -07:00
Vlad Zagorodniy 02a5a08a6c [platforms/drm] Rework ScopedDrmPointer
Summary:
Currently there is no any good reason for keeping ScopedDrmPointer;
providing our own deleter for QScopedPointer would make more sense.

Given that we already have type that acts as a scoped pointer for drm
objects we can improve it a bit and make simpler, e.g.

    DrmScopedPointer<drmModeConnector> connector;

is much simpler than

    ScopedDrmPointer<_drmModeConnector, &drmModeFreeConnector> connector;

Reviewers: #kwin, davidedmundson

Reviewed By: #kwin, davidedmundson

Subscribers: apol, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D19905
2019-04-09 14:09:19 +03:00
Roman Gilg 6295d1e6a2 Move output refresh rate getter into AbstractOutput
Summary:
The current refresh rate is stored in OutputInterface. Move the getter
therefore in the AbstractOutput class.

Reviewers: #kwin, davidedmundson

Reviewed By: #kwin, davidedmundson

Subscribers: kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D16793
2018-11-14 20:04:29 +01:00
Roman Gilg 93f78c2d23 Set outputs enabled in AbstractOutput
Summary:
Nothing hardware specific anymore in setEnabled method,
therefore put it in AbstractOutput.

Reviewers: #kwin, davidedmundson

Reviewed By: #kwin, davidedmundson

Subscribers: kwin

Tags: #kwin

Maniphest Tasks: T10016

Differential Revision: https://phabricator.kde.org/D16790
2018-11-14 20:00:28 +01:00
Roman Gilg 27946199b6 Abstract output dpms handling
Summary:
Move init and Wayland side changes of dpms modes into
AbstractOutput.

Reviewers: #kwin, davidedmundson

Reviewed By: #kwin, davidedmundson

Subscribers: davidedmundson, kwin

Tags: #kwin

Maniphest Tasks: T10016

Differential Revision: https://phabricator.kde.org/D16787
2018-11-14 19:57:25 +01:00
Roman Gilg e2b1bcea1b Set mode in AbstractOutput
Summary:
Set the mode in AbstractOutput and call into the plugin
for final change on hardware.

Reviewers: #kwin, davidedmundson

Reviewed By: #kwin, davidedmundson

Subscribers: davidedmundson, kwin

Tags: #kwin

Maniphest Tasks: T10016

Differential Revision: https://phabricator.kde.org/D16786
2018-11-14 19:56:07 +01:00
Roman Gilg 254a807374 Handle Wayland change sets in AbstractOutput
Summary:
Move Wayland change set handling to AbstractOutput and create
virtual functions to call into the hardware implementation

Reviewers: #kwin, davidedmundson

Reviewed By: #kwin, davidedmundson

Subscribers: kwin

Tags: #kwin

Maniphest Tasks: T10016

Differential Revision: https://phabricator.kde.org/D16785
2018-11-14 19:54:29 +01:00
Roman Gilg 21aee588af Initialize Wayland output in AbstractOutput
Summary:
Wayland output is on protocol level and not dependent on the hardware
platform. Next steps are to do the same for output device and then let
the virtual output call into these initializing functions as well.

Test Plan: Manually and auto test.

Reviewers: #kwin, davidedmundson

Reviewed By: #kwin, davidedmundson

Subscribers: davidedmundson, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D16783
2018-11-09 19:47:23 +01:00
Roman Gilg 9cf2730f8d [colorcorrection] Set gamma through Output class
Summary:
With the new Output class we can set the gamma directly here. This is also
a stepping stone to adjust individual output gamma adjustment later on.

This means any future backend, which aims to support the color correction
frontend needs to use the Output class.

Test Plan: Night Color test still passes.

Reviewers: #kwin

Subscribers: kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D11803
2018-08-31 11:58:21 +02:00
Roman Gilg fe63e21f80 Introduce generic Output class
Summary:
In order to separate high-level properties of individual outputs from
hardware-specific ones and access these, introduce a new generic class Output.

Also make the DrmOutput class directly a child class of this generic class.

The long-term goal is to get rid of the Screens global object on Wayland and
instead directly work with Output objects on compositing level.

This should enable us long-term to do direct scanout to hardware planes, what
I predict needs this generic output representation at one point.

Test Plan: Manually.

Reviewers: #kwin

Subscribers: kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D11781
2018-08-31 11:53:12 +02:00
David Edmundson 9f2f6d9657 Don't remove outputs during page flip
Summary:
To do so leaves a dangling pointer on our pageFlipHandler

BUG: 396272

Test Plan: Wobbled a window whilst plugging a monitor in and out

Reviewers: #kwin

Subscribers: kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D14210
2018-07-18 16:05:59 +01:00
David Edmundson 1403fcf316 Add XDG Output support
Test Plan:
Very minimal expansion of unit tests which uses WaylandScreens
Wrote mini app to debug actual output of xdg-output for testing the DRM code

Main relevant user of this is xwayland > 1.20 which I don't have, so that
part remains untested

Reviewers: #plasma, graesslin

Reviewed By: #plasma, graesslin

Subscribers: romangg, graesslin, bshah, kwin

Tags: #kwin

Maniphest Tasks: T8501

Differential Revision: https://phabricator.kde.org/D12243
2018-05-18 14:16:13 +01:00
Rohan Garg 757ed91a5d Handle errors with drmModeSetCursor instead of silently failing
Summary:
Make sure we switch to a software cursor when drmModeSetCursor
fails.

Reviewers: #kwin, graesslin

Subscribers: davidedmundson, bshah, graesslin, kwin, #kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D12447
2018-04-23 10:39:24 +02:00
Oleg Chernovskiy 4d46edd7ba
GBM remote access support for KWin
Summary:
Implements a KWayland protocol to pass GBM fd from KWin to KRfb and
addictions to relevant projects from both sides.

Note that this patch does not affect default behaviour of mentioned projects. It can be used
only with KWIN_REMOTE=1 in env from KWin side and with preferredFrameBufferPlugin=gbm in krfbrc from
KRfb side. In all other aspects app behaviour remains unchanged.

Test Plan: Launched KWin in Wayland mode, launched KRfb in it, launched KRDC on a laptop, connected in read-only mode, observed a correctly retrieved desktop with Krfb window

Reviewers: graesslin, davidedmundson, romangg, #kwin

Reviewed By: davidedmundson, romangg, #kwin

Subscribers: kossebau, jgrulich, romangg, ngraham, alexeymin, aacid, kwin, #kwin, davidedmundson, plasma-devel

Tags: #plasma_on_wayland, #kwin

Maniphest Tasks: T5653, T7785

Differential Revision: https://phabricator.kde.org/D1230
2018-03-25 20:18:47 +03:00
Martin Flöser 68698b4201 [libinput] Find screen for touch screen devices and calibrate accordingly
Summary:
This change finds the screen for a touch screen device based on:
 * number available screens
 * output name defined on the touch screen device
 * internal screen
 * and physical size

The id of the screen is stored in the Device allowing to adjust the
touch points accordingly. This means instead of transferring to the
combined display size the touch points are transferred into the output
space and the position of the output is added. Thus in a multi screen
system the touch points are properly mapped to the output.

Furthermore the screen orientation is passed to the Device and a
calibration matrix is set accordingly. Thus a transformed screen has the
touch screen transformed accordingly.

Please note that this only affects libinput on Wayland and not on X11!
The x11 standalone platform needs to gain similar code.

Reviewers: #kwin, #plasma

Subscribers: plasma-devel, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D8748
2017-12-23 10:18:55 +01:00
David Edmundson 01c1870e9d Support dynamic output enabling/disabling from KScreen
Summary:
We need to keep the DrmOutput object to still have the
WaylandOutputDevice.

Screens currently start off enabled as before.

In order to keep KWin to have a correct index based list of screens we
need to store a second vector of currently enabled outputs for the
screens interface.

Test Plan:
Had dual screens.
Disabled/Enabled each one through the kscreen KCM

Reviewers: #plasma, graesslin

Reviewed By: #plasma, graesslin

Subscribers: ngraham, luebking, broulik, graesslin, plasma-devel, kwin, #kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D8796
2017-11-21 12:04:30 +00:00
David Edmundson e96f2bff11 Split init'ing the wayland output from init
Summary:
This is a tiny refactor so that DrmOutput can have WaylandOutput
dynamically
deleted and recreated at runtime as we disable outptuts.

Reviewers: #plasma, graesslin

Reviewed By: #plasma, graesslin

Subscribers: plasma-devel, kwin, #kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D8794
2017-11-15 16:09:03 +00:00
Martin Flöser 9df1744830 Support automatic screen rotation based on orientation sensor
Summary:
This change introduces an OrientationSensor class which wraps a
QOrientationSensor. The OrientationSensor is hold by Screens and gets
enabled if Screens knows about an internal (e.g. LVDS) display which
supports rotation. In addition the OrientationSensor holds an KSni to
enable/disable the automatic rotation support.

The drm platform plugin is adjusted to make use of the OrientationSensor.
The API is defined in a way that this can also be implemented on other
platforms supporting rotation. Most important are hwcomposer and X11
standalone. The latter should be straight forward as rotation is provided
through XRandR. The former needs addition for rotation support first.

Test Plan: Rotated my Yoga 12

Reviewers: #kwin, #plasma, sebas

Subscribers: plasma-devel

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D8699
2017-11-08 17:44:38 +01:00
Martin Flöser c9c26019a1 [platforms/drm] Move cursor dumb buffers to Output
Summary:
So far all outputs shared the same dumb buffer for the cursor image.
This doesn't work any more when screen rotation is enabled. For rotated
screens the cursor image per output is different. On some it might be
rotated, on some not.

To solve this problem the dumb buffers are moved from the DrmBackend to
the DrmOutput. The DrmOutput now creates the cursor images itself and
can rotate them if needed. Thus we get nicely transformed cursors.

Test Plan: Rotated screens, moved cursor around, image properly rotated

Reviewers: #kwin, #plasma

Subscribers: plasma-devel, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D8664
2017-11-06 16:48:02 +01:00
Martin Flöser 26cdfd317f [platforms/drm] Restore previous mode if an atomic test fails
Summary:
When KWin successfully presents a new mode, it stores the current state
as the last working mode. If a new modeset is requested and the atomic
test fails, all is undone and reverted to this last knowing mode.

Currently included are:
 * the mode
 * global position
 * transformation

This is only done on a modeset not when going to DPMS.

Test Plan:
Selected the not working vertical rotation and nothing bad
happened.

Reviewers: #kwin, #plasma, subdiff

Subscribers: plasma-devel, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D8602
2017-11-05 09:21:24 +01:00
Martin Flöser b2d8bbec81 [platforms/drm] Rotate screen if requested from KScreen
Summary:
This change hooks up the drm plane rotate with the rotation requests
from KScreen. Our requests support more than what KScreen exposes in the
UI, that is all the flipped variants. I do not really understand what
the flip means, so this is not implemented yet.

Furthermore this only implements the visual rotation and not the input
rotation. This means mouse movement and touch input is currently broken
on a rotated screen.

Please note that the hardware I used seems to not support the vertical
rotation. I'm not sure whether my code works. On my system it just
results in atomic commit errors and we need to go back to a previous
working state. This is not yet implemented. I need to test the vertical
rotation on my notebook, which should (in theory) support it.

Reviewers: #kwin, #plasma, subdiff, sebas

Subscribers: plasma-devel, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D8594
2017-11-02 22:08:43 +01:00
Martin Flöser 33a4cf4050 [drm] Implement changing of modes
Summary:
This change hooks up the bits for changing the mode when a request to
change mode from kscreen is received. This includes:
 * setting new mode in DrmOutput
 * creating new buffers in SceneQPainter backend
 * creating new GbmSurface in SceneOpenGL backend

Room for improvement:
 * detect whether the new mode works and go back to old one if it fails

Test Plan:
Started both a QPainter/OpenGL session. Used kcmshell5 kscreen
to modify the resolution. Saw that it got applied, maximized a window to
verify it's correct. Changed back to original resolution. Verified it looked
good by maximizing a window.

Reviewers: #kwin, #plasma, subdiff, sebas

Subscribers: plasma-devel, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D8398
2017-10-31 12:45:38 +01:00
Martin Flöser 02d3daf28a Add physicalSize to the Screens API
Summary:
Allows to share the implementation in a better way and is a requirement
to get the Screen implementation in the QPA plugin to be based on
KWin::Screens instead of KWayland::Output.

Reviewers: #kwin, #plasma

Subscribers: plasma-devel, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D8344
2017-10-19 18:02:32 +02:00
Roman Gilg d15cb52682 [DRM plugin] Correct Atomic Mode Setting
This patch makes the AMS execution path work with the new DrmCrtc and
DrmBuffer structure and solves major issues about:
* VT switching
* DPMS
* Hot plugging
* Logout
* Memory leaks

Test Plan:
Tested with Gl and QPainter.

Reviewers: #kwin

Subscribers: kwin, #kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D5191
2017-05-09 21:29:10 +02:00
Roman Gilg efedddd905 [DRM plugin] Reorganize DrmBuffer
Split off GBM based buffers to a separate file, which gets only included,
when GBM is available.

Note, that this also removes the gbmCallback, since already before this
patch we did delete the buffers always without it.

The plan is to later use this file for via GBM directly imported Wayland
buffers as well.

Test Plan:
Tested with Gl and QPainter backends.

Reviewers: #kwin

Subscribers: kwin, #kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D5179
2017-05-09 21:00:33 +02:00
Roman Gilg a0571ccf84 [DRM plugin] Remember static kernel objects, amplify use of DrmCrtc
To get an image from KWin to the screen in the DRM pipeline we combine a CRTC,
an encoder and a connector. These objects are static in the sense, that they
represent real hardware on the graphics card, which doesn't change in a
session. See here for more details:
https://01.org/linuxgraphics/gfx-docs/drm/gpu/drm-kms.html

Until now we used DrmOutput as the main representation for such an active
rendering pipeline. I.e. it gets created and destroyed on hot plug events of
displays. On the other side we had no fixed representation of the static kernel
objects throughout the lifetime of KWin. This has several disadvantages:
* We always need to query all available static objects on an hot plug event.
* We can't manipulate the frame buffer of a CRTC after an output has been
  disconnected
* Adding functionality for driving multiple displays on a single CRTC (i.e.
  cloning) would be difficult
* We can't destroy the last frame buffer on display disconnect because the CRTC
  still accesses it and have therefore a memory leak on every display disconnect

This patch  solves these issues by storing representations of all available CRTC
and Connector objects in DrmBackend on init via DrmCrtc and DrmConnector
instances. On an hotplug event these vectors are looped for a fitting CRTC and
Connector combinations. Buffer handling is moved to the respective CRTC
instance. All changes in overview:
* Query all available CRTCs and Connectors and save for subsequent hotplug
  events
* Fix logic errors in `queryResources()`
* Move framebuffers, buffer flip and blank logic in DrmCrtc
* Remove `restoreSaved()`. It isn't necessary and is dangerous if the old
  framebuffer was deleted in the meantime. Also could reveal sensitive user
  info from old session.

Test Plan:
Login, logout, VT switching, connect and disconnect external monitor, energy
saving mode.

Reviewers: #kwin

Subscribers: kwin, #kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D5118
2017-05-09 20:23:43 +02:00
David Edmundson 0dac5d6bfe Add scaling to DRM backend
Test Plan:
For the first time, actually plugged in my high DPI laptop.
Tested both 1x and 2x windows on 2 real displays one high DPI, one normal

Reviewers: #plasma

Subscribers: plasma-devel, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D3498
2017-03-29 20:53:22 +01:00
Roman Gilg a347d009d1 [DrmBackend] Straighten out EGL surface buffer release logic on page flip
The logic on page flips was inconsistent in the sense, that it should never
release a GBM buffer before it's not used (i.e. viewable on the display)
anymore. This happened unintended until now (on page flip we never really
did something useful in the else statement, because if we're here it's not
a GBM buffer anyway).

With this patch we:
* delete on page flips always only the old buffer, which is not used anymore
* release the buffer earlier on interrupts like display disconnect in order
  to be able to destroy the EGL context

Test Plan:
Tested in non atomic mode (atomic mode is obsolete right now until my other
WIP patch D4539 is ready to be merged): Login, logout, suspend, normal use.

Reviewers: #kwin, graesslin

Reviewed By: #kwin, graesslin

Subscribers: plasma-devel, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D5060
2017-03-17 20:41:46 +01:00
Roman Gilg 997cf97c9f Atomic Mode Setting / Universal Plane preliminary support
This is Milestone 1 of full support of Atomic Mode Setting (AMS) and
Universal Planes in the KWin DRM backend.

With Milestone 1 we can use the primary plane of a DRM output and do an
AMS commit (this means mode setting aswell as page flipping), if the
driver supports it. Until now the functionality is only tested on Intel
graphics. You need the drm-next kernel for most recent DRM kernel
developments. As boot option set "i915.nuclear_pageflip". Additionally
at the moment AMS is still hidden behind the environment variable
KWIN_DRM_AMS. Set it, if you want to try out AMS.

What needs to be done next: Make it possible to transfer EGL buffers
directly to planes and implement logic for deciding about using a plane
or not for a specific buffer.

You can read more about it on LWN:
https://lwn.net/Articles/653071
And on Martin's blog:
https://blog.martin-graesslin.com/blog/2015/08/layered-compositing/
I used as model previous work by Daniel Stone for Weston:
https://git.collabora.com/cgit/user/daniels/weston.git

Reviewed-by: mgraesslin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D2370
2016-08-31 14:06:31 +02:00