Commit graph

109 commits

Author SHA1 Message Date
Pekka Paalanen 2c0a9c064a backend-drm: store EDID data
Store the EDID data as-is, so that we can tell when the EDID blob has
changed. This is not too useful yet, because all the weston_head_set_*()
API raises the device_changed flag only if the information actually
changes. However, I want to expose the libdisplay-info di_info structure
through weston_head, and those cannot be (as) easily compared.

We need to know when the EDID blob changes, so we can call
weston_head_set_device_changed() appropriately when updating di_info.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2024-01-29 15:20:04 +02:00
Zhou Liang 8b3becf524 backend-drm: fix drm find wrong connector
In a multi-GPU environment, different cards may contain connectors with the
same ID, and drm_head_find_by_connector just use the connector_id to find
the connector, it may find the wrong connector.
Fix this by find the connector based on the drm device and connector id.

Signed-off-by: Zhou Liang <174381115@qq.com>
2024-01-12 12:11:45 +00:00
Derek Foreman 2abe4efcf7 libweston/backends: Move damage flush into backends
Currently we flush damage for the "primary plane" every repaint, but this
is folly.

The drm backend may skip rendering entirely if using an all-planes
composition. This could leave the renderer plane in a messy state if a
surface on an overlay plane disappears.

Instead, let the backends flush the primary plane damage when they know
they need to render.

Fixes #864

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2024-01-10 14:13:09 -06:00
Philipp Zabel 281aa0a4d7 backend-drm: enable multi-backend support
Insert the backend into the weston_compositor::backend_list instead
of setting weston_compositor::backend. The compositor uses this to
determine that the backend is capable of being loaded simultaneously
with other backends.

The DRM backend can only be loaded as primary backend.

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
2023-09-28 14:02:04 +00:00
Leandro Ribeiro f9ef4e64ea backend-drm: fix possible leak of struct drm_output
Before this patch, we would leak the drm_output if there was a pending
flip during shutdown.

Now we destroy the drm_output even if there's a pending flip (only
during shutdown, as we don't want to wait until flip completion to
destroy the output).

Also, it fixes a problem where weston_output_enable() is called right
after weston_output_enable() or weston_output_disable() and it could
fail to find available DRM objects (as they are only released after
the flip completion).

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2023-06-27 10:57:12 +00:00
Daniel Stone 9aa68248a9 backend-drm: Use weston_compositor.shutting_down
We previously had our own local variable for this, but now we can just
use the one in weston_compositor.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2023-06-19 21:32:47 +01:00
Pekka Paalanen d48d571f0a backend-drm: move struct drm_edid definition
Now that this is used only internally in modes.c, move it there. It will
not be used with libdisplay-info.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2023-04-28 13:58:53 +03:00
Pekka Paalanen dfdb1a71f8 backend-drm: let EDID parser return malloc'd strings
This will make adding libdisplay-info as another EDID parser easier,
because libdisplay-info always returns malloc'd strings.

To make things easier to extend as well, I introduce struct
drm_head_info. The libdisplay-info case will likely return more
information than this in the future.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2023-04-28 13:58:53 +03:00
Michael Tretter bcacd9ec5a backend-drm: schedule connector disable for detached head
Currently, if a head is detached, the entire state of the device is invalidated
to make sure that the connector is disabled on the next atomic commit. Side
effect of the invalid state is that all planes are disabled on the next commit.
This includes planes that are used with a different head that is not part of the
next atomic commit. Disabling the planes of unrelated outputs causes a blanking
of these outputs until output is repainted and the plane is reenabled.

Store the detached heads in a list on the output and disable the connectors for
all heads in this list in the next atomic commit.

Signed-off-by: Michael Tretter <m.tretter@pengutronix.de>
2023-04-18 11:11:21 +02:00
Andrew F. Davis 94afcbcdc3 backend-drm: Select plane based on current attached CRTC
When doing plane selection for an output CRTC check if the plane
already has a CRTC attached and if so prefer that plane only for
the corresponding CRTC.

This prevents changing a CRTC's primary plane when it is active
which is not allowed by the DRM framework.

Based-on-patch-by: Eric Ruei <e-ruei1@ti.com>
Signed-off-by: Andrew F. Davis <afd@ti.com>
2023-03-30 17:51:33 +01:00
Veeresh Kadasani f35eccc6fa backend-drm: Add plane alpha DRM-property
This checks whether plane alpha is supported.
We get range of alpha value supported for plane
which is required for mapping view's alpha(0.0-1.0)
with drm plane alpha. No functional change.

Signed-off-by: Hsuan-Yu Lin <hlin@jp.adit-jv.com>
Signed-off-by: Veeresh Kadasani <external.vkadasani@jp.adit-jv.com>
Signed-off-by: Vinh Nguyen Trong <Vinh.NguyenTrong@vn.bosch.com>
2023-03-30 17:29:07 +01:00
Leandro Ribeiro dc27a52216 drm-backend: address case in which writeback takes longer than atomic commit
In commit "drm-backend: add writeback connector screenshooter to
DRM-backend" we were failing the writeback screenshot when the DRM/KMS
driver would take longer than the atomic commit to finish. In this patch
we address such case.

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2023-03-22 09:37:37 -03:00
Leandro Ribeiro 5b04895835 drm-backend: add writeback connector screenshooter to DRM-backend
In this patch, we add the writeback connector screenshooter to the
DRM-backend.

This will be useful to create plane composition tests that will run in
our CI, as VKMS already supports writeback connectors.

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2023-03-22 09:37:37 -03:00
Leandro Ribeiro 247d492d64 drm-backend: add supported formats for writeback connectors
In the following commits we add a writeback screenshooter. For that,
we'll need the formats supported by the writeback connectors. So include
the supported formats in struct drm_writeback.

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2023-03-22 09:37:37 -03:00
Michael Tretter 3c6cfe6bf4 backend-drm: add additional-devices to support multi GPU
Add the --additional-devices parameter to Weston to add secondary drm devices
that will only be used as outputs, but not for rendering.

We can only fail the repaint for the entire backend, but not for single
devices. Thus, if one of the devices fail, we have to fail the repaint for the
entire backend.

Signed-off-by: Michael Tretter <m.tretter@pengutronix.de>
2023-03-03 08:08:46 +00:00
Michael Tretter 7887d3fb48 backend-drm: import GBM bo to scanout device if necessary
If the GBM bo was allocated on a different device than the device that is used
for the fb, we have to import the fd first and update the handle.

Use drmPrimeFDToHandle directly instead of using a gbm device for the scanout
device, since a gbm device would require a gbm implementation, which is often
not available for devices that only support scanout.

Signed-off-by: Michael Tretter <m.tretter@pengutronix.de>
2023-03-03 08:08:46 +00:00
Michael Tretter f05029127c backend-drm: allow to create multiple drm_fb for a weston_view
Weston uses a cached drm_fb when a view is shown multiple times. If the view is
shown on multiple outputs backed by different DRM devices, Weston returns the
cached drm_fb for the first device that was used for the import. This causes a
failure when adding the fb to the other device.

Use a list of all drm_fbs to cache the buf_fb per device, and check for the
device before reusing a drm_fb.

Signed-off-by: Michael Tretter <m.tretter@pengutronix.de>
2023-03-03 08:08:46 +00:00
Derek Foreman e471edb33d drm-backend: Enable plane rotations
Search for planes that support the rotation required to properly display
a paint node, and properly set coordinates and rotation properties.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2023-02-02 12:25:56 -06:00
Derek Foreman b0f23dc09d backend-drm: Set rotation property on planes when possible
For now we just always set the plane up to have a "normal" rotation, so
no new features are added with this commit.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2023-02-02 12:25:56 -06:00
Derek Foreman f89f440735 kms: Add plane rotation property
Add plane rotations to our recognized properties.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2023-02-02 12:25:56 -06:00
Derek Foreman e3ec879d11 drm-backend: Cache paint node transform
Instead of calculating this multiple times, just store it in the paint
node.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2023-02-02 12:25:54 -06:00
Derek Foreman 8057f28b98 backend-drm: Support tearing
Allow tearing for clients that request it, provided we can put their
content on a plane.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2023-02-01 10:12:55 -06:00
Derek Foreman 9203d98f8b backend-drm: Check for the atomic tearing capability
Check if our drm device supports atomic async page flips.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2023-02-01 10:12:55 -06:00
Philipp Zabel 4c3febfb52 backend-drm: use pixel_format_info instead of gbm_format
Use const struct pixel_format_info *format instead of uint32_t
gbm_format for backend and output pixel format.

Since create_gbm_surface() is never called without output->format being
set, drop the unnecessary error message.

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
2023-01-31 15:32:24 +00:00
Philipp Zabel 4d96635a3f pixman-renderer: track damage in weston_renderbuffer
Add a damage region to struct weston_renderbuffer and use it to replace
the previous_damage tracking in the drm backend.

Keep renderbuffers on a list in struct pixman_output_state and use it
to accumulate damage on all renderbuffers during repaint_output.
Now renderbuffers have to be created when pixman output state already
exists.
Reorder renderer output state and renderbuffer creation accordingly.

With this, pixman_renderer_output_set_hw_extra_damage() can be removed.

This can not yet replace the external damage tracking in the VNC
backend, which needsto know the accumulated damage that is not returned
from repaint_output.

Signed-off-by: Philipp Zabel <philipp.zabel@gmail.com>
2023-01-23 20:05:21 +00:00
Philipp Zabel 89e1831cd7 pixman-renderer: add weston_renderbuffer and create/destroy interface
Add a create_image_from_ptr vfunc to struct pixman_renderer_interface,
which wraps weston_renderbuffer creation for the pixman renderer via
pixman_image_create_bits(), as well as a renderbuffer_destroy vfunc
to dispose of the pixman image renderbuffer.
Also add create_image_no_clear using pixman_image_create_bits_no_clear()
instead.

Make the backends create and destroy their pixman image renderbuffers
through this interface.

Signed-off-by: Philipp Zabel <philipp.zabel@gmail.com>
2023-01-23 20:05:21 +00:00
Philipp Zabel fc8d260ce3 libweston, backends: move GL renderer interface into weston_renderer
Move the struct gl_renderer_interface pointer from the backends into
the weston_renderer structure. The interface struct only contains
function pointers that never change, so make it const.

Load and initialize the GL renderer in libweston instead of in the
backends, using the new weston_compositor_init_renderer() function.

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
2023-01-16 20:40:34 +01:00
Philipp Zabel 97e9ee5b10 backend-drm: store backend on struct drm_output
To avoid retrieving the backend from the compositor all the time, store
a pointer to the drm backend on its drm_output structures.

This will be useful once the compositor contains more than one backend.

Signed-off-by: Philipp Zabel <philipp.zabel@gmail.com>
2023-01-16 11:51:48 +01:00
Philipp Zabel 6f977640e6 libweston, backends: pass backend parameter to weston_backend functions
Passing the backend as a parameter to the weston_backend function
pointers seems more natural and will be very useful once there can be
more than one backend.

Since all backends already store a pointer to the compositor instance,
replace the compositor parameter with the backend in all functions.

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
2023-01-13 18:55:59 +01:00
Pekka Paalanen 409993639e backend-drm: reset CRTC_VRR_ENABLED
Libweston has no support for VRR yet, so make sure it cannot be on by
accident.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2023-01-10 11:28:27 +00:00
Pekka Paalanen e0d267fb12 backend-drm: reset CRTC_CTM
We are assuming that CRTC_CTM is pass-through, so better ensure it
really is pass-through rather than whatever the previous KMS client left
there.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2023-01-10 11:28:27 +00:00
Pekka Paalanen d1ca5f71ee backend-drm: reset CRTC_DEGAMMA_LUT
We are assuming that CRTC_DEGAMMA_LUT is pass-through, so better ensure
it really is pass-through rather than whatever the previous KMS client
left there.

This too falls under deprecated_gamma_is_set check, because the legacy
gamma could use either GAMMA or DEGAMMA.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2023-01-10 11:28:27 +00:00
Pekka Paalanen 1acf69ac2f backend-drm: reset gamma on legacy KMS
We are assuming that gamma LUT is pass-through, so better ensure it
really is pass-through rather than whatever the previous KMS client left
there.

Unfortunately the legacy ioctl does not offer any way to reset the LUT
without actually crafting an identity LUT.

If the legacy gamma libdrm function indicates the feature is not
supported, do not try to use it again. This avoids hammering the legacy
gamma every frame when deprecated drm_output_set_gamma() is not used.

drm_output_set_gamma() is not updated to check/set this flag in order to
maintain its old behavior.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2023-01-10 11:28:27 +00:00
Pekka Paalanen debfeb3049 backend-drm: reset CRTC_GAMMA_LUT
We are assuming that CRTC_GAMMA_LUT is pass-through, so better ensure it
really is pass-through rather than whatever the previous KMS client left
there.

Unfortunately, we have old drm_output_set_gamma() API that cms-static
and cms-colord plugins are using. To avoid trampling over them, do not
touch gamma after they did. Those plugins are deprecated, so there is no
reason to make set_gamma work through atomic.

drm_output_set_gamma() is called from weston_compositor_add_output()
through the output_created_signal. This is after drm_output_enable() and
before any KMS modeset or atomic commit on the CRTC. Therefore it is not
possible that there would be any KMS action in flight when
drm_output_set_gamma() is called, and so setting deprecated_gamma_is_set
should be non-racy - like setting CRTC_GAMMA_LUT itself.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2023-01-10 11:28:27 +00:00
Derek Foreman 68cad4db42 drm: Use cached matrix in drm_paint_node_transform_supported
We've passed the paint node deeply enough that we can now use the cached
matrix in it to save some calculations.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2023-01-09 21:58:19 +00:00
Derek Foreman 05eee6eaef drm: Pass paint node to drm_view_transform_supported
Rename it as well.

By passing the paint node we'll have access to the cached buffer to output
matrix later.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2023-01-09 21:58:19 +00:00
Derek Foreman 7c7489fe79 drm: Pass paint node to drm_plane_state_coords_for_view
Rename the function as well, as it no longer takes a view.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2023-01-09 21:58:19 +00:00
Derek Foreman 567ed2706a drm: pass paint node to drm_fb_get_from_view
This is a preamble to saving a bit of matrix maths.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2023-01-09 21:58:19 +00:00
Philipp Zabel 746a03068e libweston, backends: store backend pointer in struct weston_head
Compositor code can use opaque pointer comparison to determine whether
a head belongs to a given backend. Store a backend pointer in struct
weston_head to enable the compositor to select the correct backend
specific output configuration code.

This also allows to use the backend pointer instead of the opaque
backend_id pointer to check whether a head belongs to a backend, so
replace the checks in all to_xyz_head() functions and drop backend_id.

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
2022-12-12 15:21:16 +01:00
Philipp Zabel a9c1b41f3f backend-drm: drop use_pixman from drm_backend
Now that the renderer type is stored in struct weston_renderer,
use that instead of use_pixman to determine the renderer type.

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
2022-12-08 09:44:20 +00:00
Derek Foreman 021fdf4244 backend-drm: Analyze transformation chain to check if it's supported
Instead of bailing based on our loosely tracked matrix "type" (that won't
recognize when an operation is reversed by its inverse) use the new
weston_matrix_to_transform to determine if the matrix reasonably matches.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2022-11-25 08:29:05 -06:00
Emmanuel Gil Peyrot 1c5ce4c2cc DRM: Add support for HDMI content type
Some monitors expose a selector for the kind of content that will get
displayed, allowing them to optimise their settings for this particular
content type.

I got access to such a monitor, sadly even setting it to game mode
didn’t lower its atrocious latency, but drm_info[1] reports it to be set
correctly so hopefully it’ll work better with other monitors.

[1] https://github.com/ascent12/drm_info

Signed-off-by: Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
2022-11-03 15:40:00 +00:00
vanfanel 3240ccc69d Don't change the max_bpc connector prop if mode=current.
As things are, even when mode=current is specified on the .ini file,
a full modeset is needed (and done), which causes a very noticeable
screen blinking. That is because setting the max_bpc on a connector
needs full modesetting.
The idea here is that if mode=current on the .ini, no modesetting
should be done, so the current max_bpc is programmed into the
connector.
But if a custom max-bpc=... is specified, that will be used instead,
even if mode=current on the .ini

Fixes: https://gitlab.freedesktop.org/wayland/weston/-/issues/660

Signed-off-by: vanfanel <redwindwanderer@gmail.com>
2022-09-23 11:05:34 +00:00
Michael Olbrich 6275a0fb32 backend-drm: delay mode switches until the last commit is completed
Changing the mode will destoy the GBM surface for the output. As a result all
corresponding BOs are deleted regardless of the drm_fb refcount.

While a commit is pending, the last_state may contain a reference to such a BO.
So delay the mode switch until the commit is finished and the reference is
release.

Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
2022-08-08 14:37:50 +00:00
Marius Vlad 78ccc99d0a libweston: Remove runtime render switching
It is only enabled by a debug key binding, currently not tested at all,
and is seems it doesn't really work, so let's remove it. This also
removes it from the man page.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2022-07-26 13:40:43 +00:00
Pekka Paalanen d24adbbe25 backend-drm: set connector max bpc
"max bpc" property is meant for working around faulty sink hardware.
Normally it should be set to the maximum possible value so that the
kernel driver has full freedom to choose the link bpc without being
artificially forced to lower color precision.

The default value is 16 because that is a nice round number and more
than any link technology I've heard is using today which would be 12.

Also offer an API set the value, so that weston.ini could be used in the
next patch for sink workaround purposes.

Closes: https://gitlab.freedesktop.org/wayland/weston/-/issues/612

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2022-06-15 12:58:38 +00:00
Philipp Zabel ffc011d6a3 backend-drm: check that outputs and heads are in fact ours
As a first step towards heterogeneous outputs, ignore other backends'
heads and outputs. This is done by checking the destroy callbacks for
heads and outputs.

See: https://gitlab.freedesktop.org/wayland/weston/-/issues/268

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
2022-06-10 09:27:43 +00:00
Philipp Zabel aab722bb17 backend-drm: prepare virtual output API for heterogeneous outputs
Stop plugins from overwriting the struct weston_output::destroy vfunc,
as that will be used by backends to recognize their outputs.
Instead, pass a plugin-specific destroy callback when creating the
virtual output.

See: https://gitlab.freedesktop.org/wayland/weston/-/issues/268

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
2022-06-10 09:27:43 +00:00
Michael Tretter 345e705e33 backend-drm: move drm objects from backend to drm device
The outputs, heads, crtcs, and connectors are specific to a drm device and not
the backend in general.

Link them to the device that they belong to to be able to retrieve the
respective device.

Signed-off-by: Michael Tretter <m.tretter@pengutronix.de>
2022-06-03 09:17:15 +02:00
Michael Tretter c4685d9463 backend-drm: attach device to pending state
The commits happen per device instead of per backend. The pending state is
therefore per device as well. Allow to retrieve the device from the pending
state.

Signed-off-by: Michael Tretter <m.tretter@pengutronix.de>
2022-06-03 09:14:11 +02:00