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>
dev
Michael Tretter 3 years ago committed by Daniel Stone
parent 615a37dc88
commit c4685d9463
  1. 4
      libweston/backend-drm/drm-internal.h
  2. 9
      libweston/backend-drm/drm.c
  3. 14
      libweston/backend-drm/kms.c
  4. 6
      libweston/backend-drm/state-helpers.c

@ -388,7 +388,7 @@ struct drm_edid {
* output state will complete and be retired separately. * output state will complete and be retired separately.
*/ */
struct drm_pending_state { struct drm_pending_state {
struct drm_backend *backend; struct drm_device *device;
struct wl_list output_list; struct wl_list output_list;
}; };
@ -760,7 +760,7 @@ drm_can_scanout_dmabuf(struct weston_compositor *ec,
#endif #endif
struct drm_pending_state * struct drm_pending_state *
drm_pending_state_alloc(struct drm_backend *backend); drm_pending_state_alloc(struct drm_device *device);
void void
drm_pending_state_free(struct drm_pending_state *pending_state); drm_pending_state_free(struct drm_pending_state *pending_state);
struct drm_output_state * struct drm_output_state *

@ -272,6 +272,7 @@ drm_output_update_complete(struct drm_output *output, uint32_t flags,
unsigned int sec, unsigned int usec) unsigned int sec, unsigned int usec)
{ {
struct drm_backend *b = to_drm_backend(output->base.compositor); struct drm_backend *b = to_drm_backend(output->base.compositor);
struct drm_device *device = b->drm;
struct drm_plane_state *ps; struct drm_plane_state *ps;
struct timespec ts; struct timespec ts;
@ -297,7 +298,7 @@ drm_output_update_complete(struct drm_output *output, uint32_t flags,
weston_output_disable(&output->base); weston_output_disable(&output->base);
return; return;
} else if (output->dpms_off_pending) { } else if (output->dpms_off_pending) {
struct drm_pending_state *pending = drm_pending_state_alloc(b); struct drm_pending_state *pending = drm_pending_state_alloc(device);
output->dpms_off_pending = false; output->dpms_off_pending = false;
drm_output_get_disable_state(pending, output); drm_output_get_disable_state(pending, output);
drm_pending_state_apply_sync(pending); drm_pending_state_apply_sync(pending);
@ -588,7 +589,7 @@ drm_output_start_repaint_loop(struct weston_output *output_base)
assert(!output->page_flip_pending); assert(!output->page_flip_pending);
assert(!output->state_last); assert(!output->state_last);
pending_state = drm_pending_state_alloc(backend); pending_state = drm_pending_state_alloc(device);
drm_output_state_duplicate(output->state_cur, pending_state, drm_output_state_duplicate(output->state_cur, pending_state,
DRM_OUTPUT_STATE_PRESERVE_PLANES); DRM_OUTPUT_STATE_PRESERVE_PLANES);
@ -624,7 +625,7 @@ drm_repaint_begin(struct weston_compositor *compositor)
struct drm_device *device = b->drm; struct drm_device *device = b->drm;
struct drm_pending_state *pending_state; struct drm_pending_state *pending_state;
pending_state = drm_pending_state_alloc(b); pending_state = drm_pending_state_alloc(device);
device->repaint_data = pending_state; device->repaint_data = pending_state;
if (weston_log_scope_is_enabled(b->debug)) { if (weston_log_scope_is_enabled(b->debug)) {
@ -1101,7 +1102,7 @@ drm_set_dpms(struct weston_output *output_base, enum dpms_enum level)
return; return;
} }
pending_state = drm_pending_state_alloc(b); pending_state = drm_pending_state_alloc(device);
drm_output_get_disable_state(pending_state, output); drm_output_get_disable_state(pending_state, output);
ret = drm_pending_state_apply_sync(pending_state); ret = drm_pending_state_apply_sync(pending_state);
if (ret != 0) if (ret != 0)

@ -1065,8 +1065,8 @@ static int
drm_pending_state_apply_atomic(struct drm_pending_state *pending_state, drm_pending_state_apply_atomic(struct drm_pending_state *pending_state,
enum drm_state_apply_mode mode) enum drm_state_apply_mode mode)
{ {
struct drm_backend *b = pending_state->backend; struct drm_device *device = pending_state->device;
struct drm_device *device = b->drm; struct drm_backend *b = device->backend;
struct drm_output_state *output_state, *tmp; struct drm_output_state *output_state, *tmp;
struct drm_plane *plane; struct drm_plane *plane;
drmModeAtomicReq *req = drmModeAtomicAlloc(); drmModeAtomicReq *req = drmModeAtomicAlloc();
@ -1235,8 +1235,7 @@ out:
int int
drm_pending_state_test(struct drm_pending_state *pending_state) drm_pending_state_test(struct drm_pending_state *pending_state)
{ {
struct drm_backend *b = pending_state->backend; struct drm_device *device = pending_state->device;
struct drm_device *device = b->drm;
if (device->atomic_modeset) if (device->atomic_modeset)
return drm_pending_state_apply_atomic(pending_state, return drm_pending_state_apply_atomic(pending_state,
@ -1257,8 +1256,8 @@ drm_pending_state_test(struct drm_pending_state *pending_state)
int int
drm_pending_state_apply(struct drm_pending_state *pending_state) drm_pending_state_apply(struct drm_pending_state *pending_state)
{ {
struct drm_backend *b = pending_state->backend; struct drm_device *device = pending_state->device;
struct drm_device *device = b->drm; struct drm_backend *b = device->backend;
struct drm_output_state *output_state, *tmp; struct drm_output_state *output_state, *tmp;
struct drm_crtc *crtc; struct drm_crtc *crtc;
@ -1325,8 +1324,7 @@ drm_pending_state_apply(struct drm_pending_state *pending_state)
int int
drm_pending_state_apply_sync(struct drm_pending_state *pending_state) drm_pending_state_apply_sync(struct drm_pending_state *pending_state)
{ {
struct drm_backend *backend = pending_state->backend; struct drm_device *device = pending_state->device;
struct drm_device *device = backend->drm;
struct drm_output_state *output_state, *tmp; struct drm_output_state *output_state, *tmp;
struct drm_crtc *crtc; struct drm_crtc *crtc;

@ -438,11 +438,11 @@ drm_output_state_free(struct drm_output_state *state)
* Allocate a new, empty, 'pending state' structure to be used across a * Allocate a new, empty, 'pending state' structure to be used across a
* repaint cycle or similar. * repaint cycle or similar.
* *
* @param backend DRM backend * @param device DRM device
* @returns Newly-allocated pending state structure * @returns Newly-allocated pending state structure
*/ */
struct drm_pending_state * struct drm_pending_state *
drm_pending_state_alloc(struct drm_backend *backend) drm_pending_state_alloc(struct drm_device *device)
{ {
struct drm_pending_state *ret; struct drm_pending_state *ret;
@ -450,7 +450,7 @@ drm_pending_state_alloc(struct drm_backend *backend)
if (!ret) if (!ret)
return NULL; return NULL;
ret->backend = backend; ret->device = device;
wl_list_init(&ret->output_list); wl_list_init(&ret->output_list);
return ret; return ret;

Loading…
Cancel
Save