[Intel-gfx] [PATCH 2/4] drm/atomic/helper: Allow duplication of in-flight states

Matt Roper matthew.d.roper at intel.com
Wed Sep 9 18:57:53 PDT 2015


Drivers may wish to duplicate in-flight states internally, but the
__drm_atomic_helper_{crtc,plane}_duplicate_state helper functions can
only be used to make a copy of state that has already been committed to
obj->state.  Let's update the helpers to take any existing state object
as their first parameter rather than the DRM object pointer.  We can
update handful of existing callsites to just pass obj->state for it.

Cc: dri-devel at lists.freedesktop.org
Signed-off-by: Matt Roper <matthew.d.roper at intel.com>
---
 drivers/gpu/drm/drm_atomic_helper.c       | 12 ++++++------
 drivers/gpu/drm/i915/intel_atomic.c       |  2 +-
 drivers/gpu/drm/i915/intel_atomic_plane.c |  2 +-
 drivers/gpu/drm/omapdrm/omap_plane.c      |  2 +-
 drivers/gpu/drm/rcar-du/rcar_du_plane.c   |  2 +-
 drivers/gpu/drm/tegra/dc.c                |  4 ++--
 include/drm/drm_atomic_helper.h           |  4 ++--
 7 files changed, 14 insertions(+), 14 deletions(-)

diff --git a/drivers/gpu/drm/drm_atomic_helper.c b/drivers/gpu/drm/drm_atomic_helper.c
index 9941167..915b462 100644
--- a/drivers/gpu/drm/drm_atomic_helper.c
+++ b/drivers/gpu/drm/drm_atomic_helper.c
@@ -2149,10 +2149,10 @@ EXPORT_SYMBOL(drm_atomic_helper_crtc_reset);
  * Copies atomic state from a CRTC's current state and resets inferred values.
  * This is useful for drivers that subclass the CRTC state.
  */
-void __drm_atomic_helper_crtc_duplicate_state(struct drm_crtc *crtc,
+void __drm_atomic_helper_crtc_duplicate_state(struct drm_crtc_state *from,
 					      struct drm_crtc_state *state)
 {
-	memcpy(state, crtc->state, sizeof(*state));
+	memcpy(state, from, sizeof(*state));
 
 	if (state->mode_blob)
 		drm_property_reference_blob(state->mode_blob);
@@ -2181,7 +2181,7 @@ drm_atomic_helper_crtc_duplicate_state(struct drm_crtc *crtc)
 
 	state = kmalloc(sizeof(*state), GFP_KERNEL);
 	if (state)
-		__drm_atomic_helper_crtc_duplicate_state(crtc, state);
+		__drm_atomic_helper_crtc_duplicate_state(crtc->state, state);
 
 	return state;
 }
@@ -2248,10 +2248,10 @@ EXPORT_SYMBOL(drm_atomic_helper_plane_reset);
  * Copies atomic state from a plane's current state. This is useful for
  * drivers that subclass the plane state.
  */
-void __drm_atomic_helper_plane_duplicate_state(struct drm_plane *plane,
+void __drm_atomic_helper_plane_duplicate_state(struct drm_plane_state *from,
 					       struct drm_plane_state *state)
 {
-	memcpy(state, plane->state, sizeof(*state));
+	memcpy(state, from, sizeof(*state));
 
 	if (state->fb)
 		drm_framebuffer_reference(state->fb);
@@ -2275,7 +2275,7 @@ drm_atomic_helper_plane_duplicate_state(struct drm_plane *plane)
 
 	state = kmalloc(sizeof(*state), GFP_KERNEL);
 	if (state)
-		__drm_atomic_helper_plane_duplicate_state(plane, state);
+		__drm_atomic_helper_plane_duplicate_state(plane->state, state);
 
 	return state;
 }
diff --git a/drivers/gpu/drm/i915/intel_atomic.c b/drivers/gpu/drm/i915/intel_atomic.c
index 3ffc385..45b21ac 100644
--- a/drivers/gpu/drm/i915/intel_atomic.c
+++ b/drivers/gpu/drm/i915/intel_atomic.c
@@ -97,7 +97,7 @@ intel_crtc_duplicate_state(struct drm_crtc *crtc)
 	if (!crtc_state)
 		return NULL;
 
-	__drm_atomic_helper_crtc_duplicate_state(crtc, &crtc_state->base);
+	__drm_atomic_helper_crtc_duplicate_state(crtc->state, &crtc_state->base);
 
 	crtc_state->base.crtc = crtc;
 
diff --git a/drivers/gpu/drm/i915/intel_atomic_plane.c b/drivers/gpu/drm/i915/intel_atomic_plane.c
index f1ab8e4..afbbfe0 100644
--- a/drivers/gpu/drm/i915/intel_atomic_plane.c
+++ b/drivers/gpu/drm/i915/intel_atomic_plane.c
@@ -87,7 +87,7 @@ intel_plane_duplicate_state(struct drm_plane *plane)
 
 	state = &intel_state->base;
 
-	__drm_atomic_helper_plane_duplicate_state(plane, state);
+	__drm_atomic_helper_plane_duplicate_state(plane->state, state);
 
 	return state;
 }
diff --git a/drivers/gpu/drm/omapdrm/omap_plane.c b/drivers/gpu/drm/omapdrm/omap_plane.c
index 09e363b..8962e6b 100644
--- a/drivers/gpu/drm/omapdrm/omap_plane.c
+++ b/drivers/gpu/drm/omapdrm/omap_plane.c
@@ -258,7 +258,7 @@ omap_plane_atomic_duplicate_state(struct drm_plane *plane)
 	if (copy == NULL)
 		return NULL;
 
-	__drm_atomic_helper_plane_duplicate_state(plane, &copy->base);
+	__drm_atomic_helper_plane_duplicate_state(plane->state, &copy->base);
 
 	return &copy->base;
 }
diff --git a/drivers/gpu/drm/rcar-du/rcar_du_plane.c b/drivers/gpu/drm/rcar-du/rcar_du_plane.c
index c669864..e050f54 100644
--- a/drivers/gpu/drm/rcar-du/rcar_du_plane.c
+++ b/drivers/gpu/drm/rcar-du/rcar_du_plane.c
@@ -310,7 +310,7 @@ rcar_du_plane_atomic_duplicate_state(struct drm_plane *plane)
 	if (copy == NULL)
 		return NULL;
 
-	__drm_atomic_helper_plane_duplicate_state(plane, &copy->state);
+	__drm_atomic_helper_plane_duplicate_state(plane->state, &copy->state);
 
 	return &copy->state;
 }
diff --git a/drivers/gpu/drm/tegra/dc.c b/drivers/gpu/drm/tegra/dc.c
index b4af4ab..efd1fc1 100644
--- a/drivers/gpu/drm/tegra/dc.c
+++ b/drivers/gpu/drm/tegra/dc.c
@@ -455,7 +455,7 @@ static struct drm_plane_state *tegra_plane_atomic_duplicate_state(struct drm_pla
 	if (!copy)
 		return NULL;
 
-	__drm_atomic_helper_plane_duplicate_state(plane, &copy->base);
+	__drm_atomic_helper_plane_duplicate_state(plane->state, &copy->base);
 	copy->tiling = state->tiling;
 	copy->format = state->format;
 	copy->swap = state->swap;
@@ -1036,7 +1036,7 @@ tegra_crtc_atomic_duplicate_state(struct drm_crtc *crtc)
 	if (!copy)
 		return NULL;
 
-	__drm_atomic_helper_crtc_duplicate_state(crtc, &copy->base);
+	__drm_atomic_helper_crtc_duplicate_state(crtc->state, &copy->base);
 	copy->clk = state->clk;
 	copy->pclk = state->pclk;
 	copy->div = state->div;
diff --git a/include/drm/drm_atomic_helper.h b/include/drm/drm_atomic_helper.h
index 1547eb4..570ebff 100644
--- a/include/drm/drm_atomic_helper.h
+++ b/include/drm/drm_atomic_helper.h
@@ -93,7 +93,7 @@ int drm_atomic_helper_connector_dpms(struct drm_connector *connector,
 
 /* default implementations for state handling */
 void drm_atomic_helper_crtc_reset(struct drm_crtc *crtc);
-void __drm_atomic_helper_crtc_duplicate_state(struct drm_crtc *crtc,
+void __drm_atomic_helper_crtc_duplicate_state(struct drm_crtc_state *from,
 					      struct drm_crtc_state *state);
 struct drm_crtc_state *
 drm_atomic_helper_crtc_duplicate_state(struct drm_crtc *crtc);
@@ -103,7 +103,7 @@ void drm_atomic_helper_crtc_destroy_state(struct drm_crtc *crtc,
 					  struct drm_crtc_state *state);
 
 void drm_atomic_helper_plane_reset(struct drm_plane *plane);
-void __drm_atomic_helper_plane_duplicate_state(struct drm_plane *plane,
+void __drm_atomic_helper_plane_duplicate_state(struct drm_plane_state *from,
 					       struct drm_plane_state *state);
 struct drm_plane_state *
 drm_atomic_helper_plane_duplicate_state(struct drm_plane *plane);
-- 
2.1.4



More information about the Intel-gfx mailing list