Commit graph

365 commits

Author SHA1 Message Date
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 6517accf7e backend-drm: cosmetic changes to dmabuf_feedback_maybe_update()
Cosmetic changes that makes dmabuf_feedback_maybe_update() easier to
read.

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2023-03-28 16:23:44 -03:00
Leandro Ribeiro c9b7c7085a backend-drm: add scanout tranche even for views eligible for direct scanout
We log the reasons why the fb of a certain view was not placed in an
overlay plane and use that for debug purposes. With these reasons we
also decide if the scanout tranche should be included on the dma-buf
feedback or not. For instance:

  1. If the reason is the incompatibility between the format/modifier
     pair of the fb and those supported by the KMS device, the scanout
     tranche is added and feedback is re-sent (so that the client can
     re-allocate with parameters that makes it eligible for direct
     scanout).

  2. If the reason is because we have no overlay planes available, the
     scanout tranche is useless. So the scanout tranche is removed and
     the feedback re-sent (so that clients can re-allocate with
     parameters optimal for the render device).

Also, when we detect that a view is eligible for direct scanout, we
don't even consider sending new feedback, as our interpretation of the
dma-buf feedback spec was that we should avoid bothering clients with
new feedback when they are already hitting direct scanout.

After some discussions and clarifications regarding the spec, we've
realized that Weston should start to also include the scanout tranche
even when the compositor is able to place client's content on overlay
planes. Basically, because this gives a chance for clients to
re-allocate with the proper parameters (not only format/modifier pair,
but also the target_device and the flags) from the scanout tranche. In
this patch we start doing this.

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2023-03-28 16:23:44 -03:00
Leandro Ribeiro 0251c05212 backend-drm: remove scanout tranche when there are no planes available
It makes no sense to keep the scanout tranche on the dma-buf feedback if
there are no overlay planes available. So start to remove it.

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2023-03-28 16:23:44 -03:00
Leandro Ribeiro 8fc9d68ffa backend-drm: change dmabuf_feedback_maybe_update() return type to void
As we are not using the returned value, so let's change to void.

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2023-03-28 16:23:44 -03:00
Leandro Ribeiro 025ed4573c drm-backend: move aux function up to remove unnecessary declaration
Simple cosmetic change.

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2023-03-22 09:37:37 -03: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 2d70bdfdcd drm-backend: add support to output capture writeback source
With this change, we expose the DRM-backend writeback source through the
output capture interface, making it available to clients.

For now we'll always fail writeback screenshots requests, because we
still don't have the writeback screenshooter implementation on the
DRM-backend. We add that in the following commits.

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 Olbrich d5e5428478 backend-drm: don't copy the fence fd when duplicating the plane state
The state does not own the fd. This is usually not a problem, because the
in_fence_fd of the state is assigned during drm_assign_planes() and then
immediately used in drm_repaint_flush(). It cannot be closed in-between.

However, in the fallback path in drm_output_start_repaint_loop(), the state is
duplicated. At this point in time, the in_fence_fd may be invalid because it was
replaced in a new commit of the corresponding surface.

The plane state was already committed to the kernel when it is copied, so the
fence is no longer needed. So just clear it.

Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
2023-03-22 11:41:56 +00:00
Michael Olbrich 0edcc9e5ba backend-drm: don't try to commit an empty state
With multiple DRM devices, the state for one device may be empty during
repaint_flush(). This can happen for example if an output of one device triggers
the repaint and there are no screens attached to the other device and therefore
no active outputs.

The atomic commit will actually fail because the commit contains the
DRM_MODE_PAGE_FLIP_EVENT flag but no CRTCs.

Avoid this by skipping the commit entirly. There is nothing to to anyways.

Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
2023-03-22 11:38:17 +00: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 3f9f4277c3 backend-drm: import cursors on non gbm outputs
Additional devices don't have a gbm device. Therefore, we cannot create gbm bos
for the cursor.

If the output device differs from the gbm device, fall back to the allocation of
a dumb buffer for the cursor on the output device. Update the cursor sprite with
a memcpy to the already mapped dumb buffer that belongs to the current cursor.

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 575804c7e1 backend-drm: use linear buffers if gbm and kms device differ
If we are using multiple GPUs and are not able to use modifiers to ensure that
the formats are compatible, we have to use linear buffers for the transfer.

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
Michael Tretter a8fb329335 backend-drm: create faked zpos for device instead of backend
The faked z position must be created for each device. Therefore, the device
itself must be passed to the function. If only the backend is passed, the faked
z position would be only created for the primary device.

Signed-off-by: Michael Tretter <m.tretter@pengutronix.de>
2023-03-03 08:08:46 +00:00
Marius Vlad d90533b8ad backend-drm/drm-virtual: Hang off the drm_backend
This is needed by drm_output_fini_egl() to be able to retrieve the
backend out of the drm_output on the shutdown path of the compositor.

Both the remoting plug-in and the pipewire plug-in are users of the
drm-virtual API and as such they would trigger a crash when shutting
down the compositor, as we're not setting up any backend whatsoever.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2023-02-20 12:41:03 +02:00
Derek Foreman 583fbcda3b libweston: Use weston_coord in struct weston_pointer
Convert the bare x,y coordinates into struct weston_coord and update all
users.

We keep the surface position in wl_fixed_t for now so it still exactly
matches the position most recently sent to clients.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2023-02-17 13:51:23 +00:00
Derek Foreman 84a2a84045 input: Use weston_coord for pointer clamping
Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2023-02-17 13:51:23 +00:00
Marius Vlad 27ce9dadd8 backend-drm: Do not overwrite plane's index when creating virtual plane
Starting with commit 4cde507be6 "backend-drm: fix plane sorting" the
plane list will have a descending order of the planes rather than ascending.

This reversed order had the side-effect of exposing the fact that we
don't set-up a plane index when creating the drm_plane using the DRM
virtual API. Without settting a plane index for that drm_plane we
effectively overwrite the plane index which has the 0 (zero) entry.

This wasn't an issue before commit 4cde507be6 "backend-drm: fix
plane sorting" as it seems we never picked up that plane index as
being a suitable one due to the fact that those were assigned to primary
planes, but after that commit, the cursor plane will be one getting
the 0 (zero) plane index.

Finally, this would trip over because we attempt to place a (cursor)
view on a primary plane (where it would've normally be a cursor
plane) and we end up with no framebuffer ref.

This is fixed trivially by assigning a plane index, different than the
ones already created by create_spirtes().

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2023-02-07 16:24:07 +02: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 397ed8cec5 kms: Support bitmasks
From our perspective, a bitmask is pretty much the same as an enum, so
allow it to use the same path.

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
Derek Foreman 58dde0e0c0 drm-backend: Remember to set the zpos for the scanout plane
We can clear this via drm_plane_state_put_back() at the end of
drm_output_propose_state(). We need to set it back to the minimum zpos
when rendering.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2023-02-01 15:56:24 +00:00
Derek Foreman 64d9270804 libweston: Use weston_coord space conversion functions
Update users of the old coordinate space conversion functions that take
x, y pairs to the new weston_coord versions.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2023-02-01 07:27:05 -06:00
Philipp Zabel 397e66a4dd backend-drm: allow more formats with pixman-renderer
Clean up the code a little by dropping the now unnecessary switch case
in drm_output_init_pixman(). As a side effect, this enables all formats
that have a pixman_format entry in the pixel format table:

  - rgb565
  - xrgb8888
  - argb8888
  - xbgr8888
  - abgr8888
  - rgbx8888
  - rgba8888
  - bgrx8888
  - bgra8888
  - xrgb2101010
  - argb2101010
  - xbgr2101010
  - abgr2101010

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
2023-01-31 15:32:24 +00: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 ad38c41a50 gl-renderer: use pixel_format_info instead of drm fourccs
Use struct pixel_format_info pointers instead of uint32_t drm fourcc
values at the API surface for output and image creation.

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
2023-01-29 14:47:03 +01:00
Philipp Zabel c67773bc5c pixman-renderer: use pixel_format_info instead of pixman_format_code_t
Use struct pixel_format_info pointers instead of pixman_format_code_t
values at the API surface for output and image creation.

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
2023-01-28 12:59:16 +00:00
Philipp Zabel 14533cdd25 libweston: make weston_renderbuffer refcounted
Add weston_renderbuffer_ref/unref() functions and use them to
eventually destroy the weston_renderbuffer. Drop the explicit
renderbuffer_destroy vfunc from the pixman renderer interface.

Signed-off-by: Philipp Zabel <philipp.zabel@gmail.com>
2023-01-27 16:52:14 +01:00
Philipp Zabel eb9a740c20 libweston: move pixman_renderer_init() into weston_compositor_init_renderer()
Stop calling pixman_renderer_init() from backends directly.
Call it via weston_compositor_init_renderer() instead.

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
2023-01-23 20:05:21 +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 6757bae0f3 pixman-renderer: set renderbuffer via new repaint_output parameter
Add a struct weston_renderbuffer parameter to repaint_output and make
backends set the pixman image renderbuffer through this parameter
instead of using pixman_renderer_output_set_buffer()

Turn pixman_renderer_output_set_buffer() static.

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 32c7629516 pixman-renderer: add pixman_renderer_interface
Add a struct pixman_renderer_interface with output_create and
output_destroy vfuncs and store a pointer to it in struct
weston_renderer.

Make all backends access the pixman_renderer_output_create/destroy
functions through this interface and turn them static.

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
Derek Foreman f31c81dce7 backend-drm: Use output to buffer matrix for plane setup
We can save a bit of work by using the output_to_buffer_matrix we've
already calculated for the paint node to transform the destination
rectangle, instead of starting over from global regions and doing
individual steps.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2023-01-16 17:56:36 +00:00
Derek Foreman 56cf553a63 drm: Don't try to correct flipped buffer coordinates
We should never hit this because drm_view_transform_supported() filters
out any transforms where it would occur.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2023-01-16 17:56:36 +00: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
Pekka Paalanen dbce396c7c backend-drm: move *_add_prop() debug earlier
Move the debug printing before the bail-out if the property does not
exist. This means that trying to set a missing property will be logged,
and it can be identified by the property id being 0.

We are starting to program more KMS properties, and if KMS state
building fails, this gives better chances to figure out what happened.
For example, if we accidentally assume that some property always exists
when it doesn't.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2023-01-10 11:28:27 +00:00
Daniel Stone c683ebdea3 backend-drm: Use renderer enum type for config selection
When we're selecting our renderer, use the enum rather than a boolean to
force Pixman on.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2023-01-10 10:59:04 +02: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 a65ba82232 drm: Pass paint node to drm_output_try_view_on_plane
Rename the function as it no longer tests views, but paint nodes.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2023-01-09 21:58:19 +00:00
Derek Foreman 263e78d0fc drm: Pass paint node to cursor view prep function
Rename this as well, since 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
Pekka Paalanen 915d8e8cdf build: simplify dep_egl a bit
Make sure dep_egl is always a valid dependency object, even if not
found. Ensure it is not found when not wanted, to avoid linking when
found but not wanted.

Using a not-found dependency in Meson is defined to be a safe no-op, so
use that to simplify the backend dependencies.

libweston/meson.build already errors out if renderer-gl is enabled and
EGL is not found, so the same checks can be removed from the backends.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2022-12-14 11:57:24 +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
Pekka Paalanen 3700c78131 libweston: implement new screenshooting protocol base
This implements the basics of the new screenshooting protocol. The
actual pixel operations will be implemented separately in the renderers
and DRM-backend.

See the previous commit "protocol: new screenshooter protocol" for why.

If DRM-backend needs more from weston_capture_task when it implements
writeback screenshooting, it will be easy to add user_data or expose
weston_capture_task::link for the backend to use. Those were not added
yet because it is uncertain what is actually needed.

The DRM-backend no-damage optimization requires special handling here as
well. See also 7f1a113c89 .

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2022-11-29 11:00:52 +02: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
Pekka Paalanen f3bed68100 backend-drm: do not print head info twice
Before this patch, when a new head is found its information is printed
first as "updated" and then as "found" in the log.

The reason is that drm_head_create() calls drm_head_update_info() which
printed the head as "changed". Then drm_head_create() itself prints it
as "found".

This fixes it to print only once as "found".

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2022-11-08 16:57:51 +02: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
Derek Foreman 5079f0b2f9 helpers: Add a u64 from 2 u32 helper
We do this enough that having a single implementation for it is probably
a win.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2022-10-27 08:13:30 +00:00
Pekka Paalanen 7886cbe4b9 gl-renderer: pass initial output area explicitly
This changes the GL-renderer interface to pass the initial framebuffer
size and compositing area explicitly. All backends are changed to
provide the correct parameters.

GL-renderer mostly does not yet use these values, but later patches
will. The pbuffer path uses it already, because they replaced the
existing fields.

All this is to make GL-renderer aware of the different sizes, so it can
implement the future revision of the screenshooting API.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2022-09-23 12:42:05 +00:00
Pekka Paalanen f4559b0760 pixman-renderer: pass initial size explicitly
In a journey to decouple renderer from weston_output, pass the initial
framebuffer size to Pixman-renderer explicitly.

Now Pixman-renderer will never look into weston_output::current_mode.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2022-09-23 12:42:05 +00:00
Derek Foreman 64c618e47e libweston: Remove x,y from weston_plane_init
This is always passed as 0 right now.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2022-09-23 11:53:16 +00:00
Marius Vlad eaf2de3441 compositor: Use weston_load_module
Except the module dir path, they're one and the same. This change
warrants a libweston version bump, if it hasn't been done already.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2022-09-23 11:47:40 +00:00
Derek Foreman 21deaee6a9 libweston: use weston_region_global_to_output more often
Use this anywhere we used weston_matrix_transform_region with an output
matrix.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2022-09-23 11:41:59 +00:00
Derek Foreman c12ec7a2e5 compositor: Remove weston_transformed_region
Replace all uses of weston_transform_region with
weston_matrix_transform_region, then remove the function completely.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2022-09-23 11:41:59 +00:00
Derek Foreman df96fd435c backend-drm: Use weston_matrix_transform_region for plane setup
Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2022-09-23 11:41:59 +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 4cde507be6 backend-drm: fix plane sorting
The planes in the plane_list must be sorted from largest zpos_max to smallest.

Currently the plane order is only correct when the planes are already ordered
and added starting with the smallest zpos_max. This works accidentally in most
cases because the primary plane is usually first and there is often only one
overlay plane or the zpos is sufficiantly configurable.

To fix this, insert a new plane before the first plane with a smaller zpos_max.
And if none is found, insert it at the end of the list.

Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
2022-08-31 08:28:55 +02: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
Michael Olbrich 3b3fdc52c3 backend-drm: improve atomic commit failure handling
When an atomic commit fails then the output will be stuck in
REPAINT_AWAITING_COMPLETION state. It is waiting for a vblank event that was
never scheduled.
If the error is EBUSY then it can be expected to be a transient error. So
propagate the error and schedule a new repaint in the core compositor.

This is necessary because there are some circumstances when the commit can fail
unexpectedly:
- With 'state_invalid == true' one commit will disable all planes. If another
  commit for a different output is triggered immediately afterwards, then this
  commit can temporarily fail with EBUSY because it tries to use the same
  planes.
- At least with i915, if one commit enables an output then a second commit for a
  different output immediately afterwards can temporarily fail with EBUSY. This
  is probably caused by some hardware interdependency.

Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
2022-08-03 17:35:26 +02: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
Marius Vlad 50f98b1006 backend-drm/state-propose: Amend an older comment
Since b38b735e20, 'backend-drm: Remove Pixman conditional
for keep_buffer' the Pixman renderer keeps its own reference to buffers
when attached to surfaces, rather than flipping keep_buffer variable for
the surface. Problem is that when switching from the Pixman render to
the GL would not work and could result in a crash upon first repaint.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2022-07-15 12:54:05 +03:00
Michael Olbrich f5a4fb5abc backend-drm: make sure all buffers are released when an output is removed
When an output is destroyed then the output state is freed immediately. In this
case, the plane state is only partially destroyed because it is the currently
active state. This includes the buffer reference.

Without the output, the plane will not be updated any more until it is used by a
different output (if possible) or the output returns and the plane is used
again.
As a result, the buffer reference is kept for a long time. This will cause some
applications to stall because weston now keeps two buffers (the one here and
another one for a different output where the application is now displayed).

To avoid this, do a synchronous commit that disables the output. The output
needs to be disabled anyways and this way the current state contains no
buffers that would remain.

`device->state_invalid = true` in drm_output_detach_crtc() is no longer
needed, because drm_output_detach_crtc() is called only when initialization
failed and the crtc was not yet used or in drm_output_deinit() when the
crtc was already disabled with the new synchronous commit.

Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
2022-07-04 18:42:48 +00:00
Daniel Stone 01c57eca43 backend-drm: Don't leak drm_device on shutdown
This was introduced in a partial MR, where the later commits in the new
multi-GPU MR fully fix it, but the initially cherry-picked ones don't.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-06-29 14:33:21 +01:00
Michael Olbrich 2929b6c483 backend-drm: check that outputs are in fact ours
This is another followup to ffc011d6a3
("backend-drm: check that outputs and heads are in fact ours") which missed
some places.

Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
2022-06-23 14:00:04 +00:00
Ivan Nikolaenko 0d3e438d08 build: fix possible race/error for some backends
There is missing dependency on linux-dmabuf-unstable-v1-server-protocol.h
header file in backend-headless, backend-drm and backend-x11. That files
do not depend on that header, in fact. But by this moment they've had
that implicit dependency due to linux-dmabuf.h header.

With specific set of meson configure options the protocol header is not
generated at the right time, what causes build error in 100% cases using
small amount of building threads (from -j1 to -j8).

Signed-off-by: Ivan Nikolaenko <ivan.nikolaenko@unikie.com>
2022-06-20 16:14:01 +03:00
Michael Olbrich 78933093a1 backend-drm: check that outputs are in fact ours
This is a followup to ffc011d6a3
("backend-drm: check that outputs and heads are in fact ours") which missed
some places.

Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
2022-06-16 09:53:01 +00:00
Michael Olbrich 3e44a6eb3d backend-drm: don't try to disable planes on session deactivation
This uses the legacy DRM API it incomplete and no longer works anyways.
At this point, weston is no longer DRM master, so these calls fail with
"Permission denied".

So just remove the corresponding code.

Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
2022-06-16 09:53:01 +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
Luigi Santivetti 8b654c47eb Revert "backend-drm: add HDR_OUTPUT_METADATA definitions"
This reverts commit 6914064066.

This is a follow-up change of b623fd2a ("drm-backend: stop parsing IN_FORMATS
blobs, use libdrm instead"). Weston now has a hard-requirement on libdrm
2.4.108, clean up remaining and unnecessary conditional code. Change 69140640
("backend-drm: add HDR_OUTPUT_METADATA definitions") is no longer needed
and stop including libdrm-updates.h from kms-color.c.

Signed-off-by: Luigi Santivetti <luigi.santivetti@imgtec.com>
2022-06-07 09:35:14 +01:00
Luigi Santivetti a62bf5ff48 drm-backend: stop parsing IN_FORMATS blobs, use libdrm instead
Before this change the drm-backend in Weston did the work of parsing DRM
blobs in order to query IN_FORMATS data, if available. This is also the
case for other DRM/KMS clients that use IN_FORMATS (i.e. X).

libdrm 2.4.108 with e641e2a6 ("xf86drm: add iterator API for DRM/KMS
IN_FORMATS blobs") introduced a dedicated API for querying IN_FORMATS data.

Bump the minimum required version to 2.4.108, stop parsing IN_FORMATS in
Weston and start using DRM iterators. In addition, remove fallback code for
libdrm <2.4.107.

Signed-off-by: Luigi Santivetti <luigi.santivetti@imgtec.com>
2022-06-07 09:35:14 +01:00
Michael Tretter dfceb60274 backend-drm: explicitly pass device to initialization
The drm_device is initialized as a side effect of the (badly named)
drm_device_is_kms function. Explicitly pass the drm_device to be able to
initialize kms devices that are not the main drm device of the drm backend.

Signed-off-by: Michael Tretter <m.tretter@pengutronix.de>
2022-06-03 09:18:12 +02:00
Michael Tretter deebfd99e3 backend-drm: get the drm device from the output
If we have multiple drm devices, we cannot use the drm device from the backend,
because we would only get the primary device and not the device of the output.

Signed-off-by: Michael Tretter <m.tretter@pengutronix.de>
2022-06-03 09:17:49 +02:00
Michael Tretter 6e36787dfd backend-drm: handle hotplug events per drm device
If Weston receives a hotplug event, it has to check if the hotplug device
actually belongs to the drm device before updating the heads of the device. The
hotplug event should only remove heads that belong to the device and must not
change heads of other devices.

Signed-off-by: Michael Tretter <m.tretter@pengutronix.de>
2022-06-03 09:17:32 +02:00
Michael Tretter d990c6a939 backend-drm: ignore heads from other devices
The compositor lists the heads from all devices, but we must only disable the
connectors that belong to the current device. Therefore, other heads must be
ignored.

Signed-off-by: Michael Tretter <m.tretter@pengutronix.de>
2022-06-03 09:17:16 +02: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
Michael Tretter 615a37dc88 backend-drm: make dma-buf feedback device specific
The scanout format for the dma-buf feedback are specific to the kms device that
is used for scanout. Therefore, we have to pass the device of the output when
retrieving the scanout formats.

Signed-off-by: Michael Tretter <m.tretter@pengutronix.de>
2022-06-03 09:13:55 +02:00
Michael Tretter 101c0f6b8b backend-drm: get the fb using the device instead of the backend
The fbs are specific to the device on which they will be displayed. Therefore,
we have to tell which device shall be used when we are creating the fb.

Signed-off-by: Michael Tretter <m.tretter@pengutronix.de>
2022-06-03 09:13:40 +02:00
Michael Tretter d89fcf10cb backend-drm: pass device through atomic commit handler
The atomic commit is device specific. If we have multiple kms devices, we need
to know which device was used for the atomic commit.

Pass the device instead of the backend through the atomic commit.

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