output-capture: Add output_get_writeback_formats helper

And implement it in the DRM backend. This will be used by the next
commit.

Signed-off-by: Robert Mader <robert.mader@collabora.com>
This commit is contained in:
Robert Mader 2025-09-03 17:57:19 +02:00
parent 00902a5921
commit 07a5ec8157
3 changed files with 32 additions and 0 deletions

View file

@ -491,6 +491,11 @@ struct weston_output {
void (*detach_head)(struct weston_output *output,
struct weston_head *head);
/**
* Get the DRM formats supported by a compatible writeback connector.
*/
const struct weston_drm_format_array *(*get_writeback_formats)(struct weston_output *output);
/**
* When set, this output is a mirror-of another output. See
* mirror-of key in [output] section.
@ -2653,6 +2658,9 @@ weston_output_set_vrr_mode(struct weston_output *output,
uint32_t
weston_output_get_supported_vrr_modes(struct weston_output *output);
const struct weston_drm_format_array *
weston_output_get_writeback_formats(struct weston_output *output);
void
weston_compositor_arm_surface_counter_fps(struct weston_compositor *ec);

View file

@ -1940,6 +1940,19 @@ drm_output_detach_head(struct weston_output *output_base,
wl_list_insert(&output->disable_head, &head->disable_head_link);
}
static const struct weston_drm_format_array *
drm_output_get_writeback_formats(struct weston_output *output_base)
{
struct drm_output *output = to_drm_output(output_base);
struct drm_writeback *writeback;
writeback = drm_output_find_compatible_writeback(output);
if (!writeback)
return NULL;
return &writeback->formats;
}
int
parse_gbm_format(const char *s, const struct pixel_format_info *default_format,
const struct pixel_format_info **format)
@ -3247,6 +3260,8 @@ drm_output_create(struct weston_backend *backend, const char *name)
output->base.attach_head = drm_output_attach_head;
output->base.detach_head = drm_output_detach_head;
output->base.get_writeback_formats = drm_output_get_writeback_formats;
output->backend = b;
output->destroy_pending = false;

View file

@ -292,6 +292,15 @@ weston_output_update_capture_info(struct weston_output *output,
}
}
WL_EXPORT const struct weston_drm_format_array *
weston_output_get_writeback_formats(struct weston_output *output)
{
if (output->get_writeback_formats)
return output->get_writeback_formats(output);
return NULL;
}
static bool
buffer_is_compatible(struct weston_buffer *buffer,
struct weston_output_capture_source_info *csi)