drm: Introduce drm_plane_reset_state() helper function
authorAlexandros Frantzis <alexandros.frantzis@collabora.com>
Mon, 18 May 2020 12:22:49 +0000 (15:22 +0300)
committerDaniel Stone <daniels@collabora.com>
Mon, 17 Aug 2020 09:44:45 +0000 (09:44 +0000)
Introduce a helper function to reset the current state of a drm_plane.

Signed-off-by: Alexandros Frantzis <alexandros.frantzis@collabora.com>
libweston/backend-drm/drm-gbm.c
libweston/backend-drm/drm-internal.h
libweston/backend-drm/drm.c
libweston/backend-drm/state-helpers.c

index 4b83e99499642671b507822953804048264ff18f..30609e3ea60316f219953c4196240dd475c81005 100644 (file)
@@ -260,10 +260,7 @@ drm_output_fini_egl(struct drm_output *output)
        if (!b->shutting_down &&
            output->scanout_plane->state_cur->fb &&
            output->scanout_plane->state_cur->fb->type == BUFFER_GBM_SURFACE) {
-               drm_plane_state_free(output->scanout_plane->state_cur, true);
-               output->scanout_plane->state_cur =
-                       drm_plane_state_alloc(NULL, output->scanout_plane);
-               output->scanout_plane->state_cur->complete = true;
+               drm_plane_reset_state(output->scanout_plane);
        }
 
        gl_renderer->output_destroy(&output->base);
index 03c6f40b746c8ec814a3ed0aedf5d537482da2a0..7ece756dcb703d282fa05ae10874a3fbdacc7950 100644 (file)
@@ -748,6 +748,8 @@ drm_plane_state_put_back(struct drm_plane_state *state);
 bool
 drm_plane_state_coords_for_view(struct drm_plane_state *state,
                                struct weston_view *ev, uint64_t zpos);
+void
+drm_plane_reset_state(struct drm_plane *plane);
 
 void
 drm_assign_planes(struct weston_output *output_base, void *repaint_data);
index 4e5f39cf6c392514f482dda92953d7ef0b684268..7c1c0b4024137a251a0d05207f0a79ebf0097559 100644 (file)
@@ -1272,10 +1272,7 @@ drm_output_fini_pixman(struct drm_output *output)
        if (!b->shutting_down &&
            output->scanout_plane->state_cur->fb &&
            output->scanout_plane->state_cur->fb->type == BUFFER_PIXMAN_DUMB) {
-               drm_plane_state_free(output->scanout_plane->state_cur, true);
-               output->scanout_plane->state_cur =
-                       drm_plane_state_alloc(NULL, output->scanout_plane);
-               output->scanout_plane->state_cur->complete = true;
+               drm_plane_reset_state(output->scanout_plane);
        }
 
        pixman_renderer_output_destroy(&output->base);
index d105499338499c64430f2c0dc79ec6d2c4d00915..0ee663cb6f5cd05f0be3cc991866cbe439d5a503 100644 (file)
@@ -261,6 +261,21 @@ drm_plane_state_coords_for_view(struct drm_plane_state *state,
        return true;
 }
 
+/**
+ * Reset the current state of a DRM plane
+ *
+ * The current state will be freed and replaced by a pristine state.
+ *
+ * @param plane The plane to reset the current state of
+ */
+void
+drm_plane_reset_state(struct drm_plane *plane)
+{
+       drm_plane_state_free(plane->state_cur, true);
+       plane->state_cur = drm_plane_state_alloc(NULL, plane);
+       plane->state_cur->complete = true;
+}
+
 /**
  * Return a plane state from a drm_output_state.
  */