Bug 447792 - Support "reflect-x" output transform
Summary: Support "reflect-x" output transform
Status: RESOLVED FIXED
Alias: None
Product: KScreen
Classification: Plasma
Component: common (show other bugs)
Version: 5.23.4
Platform: Other Linux
: NOR wishlist
Target Milestone: ---
Assignee: kscreen-bugs-null@kde.org
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-01-01 20:24 UTC by Jakob Hauser
Modified: 2023-10-15 13:57 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In: 6.0


Attachments
Screenshot showing the issue (414.15 KB, image/png)
2022-01-01 20:24 UTC, Jakob Hauser
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Jakob Hauser 2022-01-01 20:24:08 UTC
Created attachment 145025 [details]
Screenshot showing the issue

SUMMARY
On device samsung-serranove, the screen natively shows a mirrored image. Flipping the screen in the kernel is not implemented yet. In distribution postmarketOS we compensate this by adding "video=540x960,reflect_x" to the boot cmdline [1].

On Plasma Mobile with KWin version 5.22.4, the screen is ok after boot. When rotating the device, auto-rotate rotates the screen. This results in a mirrored image.

With KWin version 5.23.4, the screen shows a mirrored image right after boot. It remains mirrored after auto-rotation.

Between those versions, at 5.22.90, there was a commit "drm: Use KScreen's json files to set up the initial output composition" [2]. So I guess in KWin 5.22.4 the configuration was first read from ~/.config/kwinrc and upon auto-rotation it was read from ~/.local/share/kscreen/. In KWin 5.23.4 it's read from ~/.local/share/kscreen/. right away.

Using the package "drm_info" to have a better insight, I can see that on KWin 5.22.4 after boot the "rotation" property of the drm plane 0 is at "(rotate-0 | reflect-x)". After auto-rotation it's changed to "(rotate-0)" only. On KWin 5.23.4 it's on "(rotate-0)" only from the beginning.

As far as I can see, KScreen doesn't support screen flipping/reflecting [3] [4]. Presumably because of this, the reflect-x of the drm plane get's lost as soon as KScreen comes in.

Well, I guess this comes down to KScreen missing this feature.

[1] https://www.kernel.org/doc/html/v5.15/fb/modedb.html
[2] https://invent.kde.org/plasma/kwin/-/merge_requests/944
[3] https://invent.kde.org/plasma/libkscreen/-/blob/v5.23.4/backends/kwayland/waylandoutputdevice.cpp#L101
[4] https://invent.kde.org/plasma/kwin/-/blob/v5.23.4/src/plugins/platforms/drm/drm_backend.cpp#L445-467


STEPS TO REPRODUCE
Unfortunately, this cannot be reproduced on many desktops or laptops. Many cards don't support refect-x. Whether it's supported can be checked by installing package drm-info, type "drm_info | less", checking if "rotation" property is listed for plane 0 and if it's capable to do "reflect-x". On Debian or Ubuntu, the package is available on bullseye and hirsute or higher.

If the card is able to do reflect-x, the issue can be reproduced artificiallly. I could not test this because my desktop/laptop cards don't support "reflect-x".
1. Make sure in Plasma Settings -> Display -> the rotation is set to "No Roation".
2. Get the screen resolution, e.g. by something like cat /sys/class/graphics/fb0/modes.
3. Add something like "video=1280x1024,reflect_x" to the boot cmdline.
4a. On KWin 5.22.4, after reboot, the screen should be flipped/reflected/mirrored. When now going to Plasma Settings -> Display -> change the rotation to something, the "reflect-x" will get lost and the screen isn't mirrored anymore.
4b. On KWin 5.23.4, when reaching Plasma after reboot, "reflect-x" will get lost directly.


OBSERVED RESULT
On KWin 5.23.4, boot cmdline video parameter "reflect_x" gets lost. Also there seems no other possibility to flip the screen.

On KWin 5.22.4, this happens after rotating the screen (KScreen).


EXPECTED RESULT
Ability to reflect/flip the screeen if needed, e.g. by cmdline video parameter "reflect_x".


SOFTWARE/OS VERSIONS
Operating System: postmarketOS v21.12 / Plasma Mobile
KDE Plasma Version: 5.23.4
KDE Frameworks Version: 5.89.0
Qt Version: 5.15.3
Kernel Version: 5.15.0-msm8916 (armv7)
OS Type: 32-bit
Graphics Platform: Wayland
Processors: 4 × 1.2 GHz Quad-core Cortex-A53
Memory: 1.4 GiB of RAM
Graphics Processor: Adreno 305


ADDITIONAL INFORMATION
none
Comment 1 Vlad Zahorodnii 2022-01-11 10:27:48 UTC
That's correct. KWin internally supports reflect transforms, but kscreen does not.
Comment 2 Bug Janitor Service 2023-10-10 12:39:26 UTC
A possibly relevant merge request was started @ https://invent.kde.org/plasma/kwin/-/merge_requests/4487
Comment 3 Bug Janitor Service 2023-10-10 13:53:38 UTC
A possibly relevant merge request was started @ https://invent.kde.org/plasma/libkscreen/-/merge_requests/160
Comment 4 Zamundaaa 2023-10-11 12:39:01 UTC
Git commit 339da7ed857c00ffd9048b86fa520389863293d3 by Xaver Hugl.
Committed on 11/10/2023 at 14:38.
Pushed by zamundaaa into branch 'master'.

support flipped transformations

M  +12   -8    backends/kwayland/waylandoutputdevice.cpp
M  +2    -1    backends/xrandr/xrandroutput.cpp
M  +5    -1    src/doctor/doctor.cpp
M  +1    -1    src/doctor/kscreen-doctor.zsh
M  +9    -5    src/output.h

https://invent.kde.org/plasma/libkscreen/-/commit/339da7ed857c00ffd9048b86fa520389863293d3
Comment 5 Zamundaaa 2023-10-11 12:45:43 UTC
Git commit 1f82d81558f49e29a8a3b8137a9fc3adda4d26a2 by Xaver Hugl.
Committed on 11/10/2023 at 14:37.
Pushed by zamundaaa into branch 'master'.

improve support for mirroring output transforms

M  +5    -4    src/backends/drm/drm_egl_cursor_layer.cpp
M  +5    -4    src/backends/drm/drm_egl_layer.cpp
M  +3    -0    src/backends/drm/drm_egl_layer_surface.cpp
M  +8    -6    src/backends/drm/drm_output.cpp
M  +16   -0    src/outputconfigurationstore.cpp
M  +1    -1    src/plugins/screentransform/screentransform.cpp

https://invent.kde.org/plasma/kwin/-/commit/1f82d81558f49e29a8a3b8137a9fc3adda4d26a2
Comment 6 Jakob Hauser 2023-10-15 13:57:06 UTC
@Zamundaaa: Many thanks for implementing screen flip to libkscreen and thus KWin!!