drm/i915: Add crtc state duplication/destruction functions
authorMatt Roper <matthew.d.roper@intel.com>
Thu, 22 Jan 2015 00:35:47 +0000 (16:35 -0800)
committerDaniel Vetter <daniel.vetter@ffwll.ch>
Tue, 27 Jan 2015 08:57:18 +0000 (09:57 +0100)
The atomic helpers need these to prepare a new state object when
starting a new atomic operation.

Signed-off-by: Matt Roper <matthew.d.roper@intel.com>
Reviewed-by: Ander Conselvan de Oliveira <conselvan2@gmail.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
drivers/gpu/drm/i915/intel_atomic.c
drivers/gpu/drm/i915/intel_display.c
drivers/gpu/drm/i915/intel_drv.h

index 52ef6f4abe457cebbb2c3ecf5a7a94ac20d3ac79..19a9dd5408f35ee14998c6aeef9a9bf2af50aa51 100644 (file)
@@ -200,3 +200,38 @@ intel_connector_atomic_get_property(struct drm_connector *connector,
 
        return -EINVAL;
 }
+
+/*
+ * intel_crtc_duplicate_state - duplicate crtc state
+ * @crtc: drm crtc
+ *
+ * Allocates and returns a copy of the crtc state (both common and
+ * Intel-specific) for the specified crtc.
+ *
+ * Returns: The newly allocated crtc state, or NULL on failure.
+ */
+struct drm_crtc_state *
+intel_crtc_duplicate_state(struct drm_crtc *crtc)
+{
+       struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
+
+       if (WARN_ON(!intel_crtc->config))
+               return kzalloc(sizeof(*intel_crtc->config), GFP_KERNEL);
+
+       return kmemdup(intel_crtc->config, sizeof(*intel_crtc->config),
+                      GFP_KERNEL);
+}
+
+/**
+ * intel_crtc_destroy_state - destroy crtc state
+ * @crtc: drm crtc
+ *
+ * Destroys the crtc state (both common and Intel-specific) for the
+ * specified crtc.
+ */
+void
+intel_crtc_destroy_state(struct drm_crtc *crtc,
+                         struct drm_crtc_state *state)
+{
+       drm_atomic_helper_crtc_destroy_state(crtc, state);
+}
index b461f90698e36a6d36ad8499a8908ae3599b4d43..2dc6d64d9234d6b7841832eb62162a919aaa5322 100644 (file)
@@ -11652,6 +11652,8 @@ static const struct drm_crtc_funcs intel_crtc_funcs = {
        .set_config = intel_crtc_set_config,
        .destroy = intel_crtc_destroy,
        .page_flip = intel_crtc_page_flip,
+       .atomic_duplicate_state = intel_crtc_duplicate_state,
+       .atomic_destroy_state = intel_crtc_destroy_state,
 };
 
 static bool ibx_pch_dpll_get_hw_state(struct drm_i915_private *dev_priv,
index 28b846e2e15a325dbb776bfe32bd441bfc7a5563..eef79ccd0b7ca9c20329021175543720e2756a9b 100644 (file)
@@ -1258,6 +1258,9 @@ int intel_connector_atomic_get_property(struct drm_connector *connector,
                                        const struct drm_connector_state *state,
                                        struct drm_property *property,
                                        uint64_t *val);
+struct drm_crtc_state *intel_crtc_duplicate_state(struct drm_crtc *crtc);
+void intel_crtc_destroy_state(struct drm_crtc *crtc,
+                              struct drm_crtc_state *state);
 
 /* intel_atomic_plane.c */
 struct intel_plane_state *intel_create_plane_state(struct drm_plane *plane);