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>
This commit is contained in:
Philipp Zabel 2023-01-13 23:07:01 +01:00 committed by Philipp Zabel
parent 6f977640e6
commit 97e9ee5b10
4 changed files with 14 additions and 9 deletions

View file

@ -278,7 +278,7 @@ drm_output_init_egl(struct drm_output *output, struct drm_backend *b)
void
drm_output_fini_egl(struct drm_output *output)
{
struct drm_backend *b = to_drm_backend(output->base.compositor);
struct drm_backend *b = output->backend;
/* Destroying the GBM surface will destroy all our GBM buffers,
* regardless of refcount. Ensure we destroy them here. */

View file

@ -553,6 +553,7 @@ struct drm_crtc {
struct drm_output {
struct weston_output base;
struct drm_backend *backend;
struct drm_device *device;
struct drm_crtc *crtc;

View file

@ -1244,7 +1244,7 @@ err:
static void
drm_output_fini_pixman(struct drm_output *output)
{
struct drm_backend *b = to_drm_backend(output->base.compositor);
struct drm_backend *b = output->backend;
unsigned int i;
/* Destroying the Pixman surface will destroy all our buffers,
@ -1293,7 +1293,8 @@ static int
drm_output_attach_head(struct weston_output *output_base,
struct weston_head *head_base)
{
struct drm_backend *b = to_drm_backend(output_base->compositor);
struct drm_output *output = to_drm_output(output_base);
struct drm_backend *b = output->backend;
struct drm_device *device = b->drm;
if (wl_list_length(&output_base->head_list) >= MAX_CLONED_CONNECTORS)
@ -1322,7 +1323,8 @@ static void
drm_output_detach_head(struct weston_output *output_base,
struct weston_head *head_base)
{
struct drm_backend *b = to_drm_backend(output_base->compositor);
struct drm_output *output = to_drm_output(output_base);
struct drm_backend *b = output->backend;
struct drm_device *device = b->drm;
if (!output_base->enabled)
@ -1409,7 +1411,7 @@ drm_output_set_seat(struct weston_output *base,
const char *seat)
{
struct drm_output *output = to_drm_output(base);
struct drm_backend *b = to_drm_backend(base->compositor);
struct drm_backend *b = output->backend;
setup_output_seat_constraint(b, &output->base,
seat ? seat : "");
@ -1704,7 +1706,7 @@ err:
static int
drm_output_init_planes(struct drm_output *output)
{
struct drm_backend *b = to_drm_backend(output->base.compositor);
struct drm_backend *b = output->backend;
struct drm_device *device = output->device;
output->scanout_plane =
@ -1742,7 +1744,7 @@ drm_output_init_planes(struct drm_output *output)
static void
drm_output_deinit_planes(struct drm_output *output)
{
struct drm_backend *b = to_drm_backend(output->base.compositor);
struct drm_backend *b = output->backend;
struct drm_device *device = output->device;
/* If the compositor is already shutting down, the planes have already
@ -1939,7 +1941,7 @@ static void
drm_output_deinit(struct weston_output *base)
{
struct drm_output *output = to_drm_output(base);
struct drm_backend *b = to_drm_backend(base->compositor);
struct drm_backend *b = output->backend;
struct drm_device *device = b->drm;
struct drm_pending_state *pending;
@ -2361,6 +2363,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->backend = b;
output->destroy_pending = false;
output->disable_pending = false;

View file

@ -531,7 +531,7 @@ drm_fb_get_from_paint_node(struct drm_output_state *state,
struct weston_paint_node *pnode)
{
struct drm_output *output = state->output;
struct drm_backend *b = to_drm_backend(output->base.compositor);
struct drm_backend *b = output->backend;
struct drm_device *device = output->device;
struct weston_view *ev = pnode->view;
struct weston_buffer *buffer = ev->surface->buffer_ref.buffer;