drm/i915: Move rotation from intel_plane to drm_plane_state
[deliverable/linux.git] / drivers / gpu / drm / i915 / intel_atomic_plane.c
index 5488efef1837b5cef81b1e55f9959b0b1d060037..d9d430604c07f0890f632c9399e25829867708e0 100644 (file)
 #include <drm/drm_plane_helper.h>
 #include "intel_drv.h"
 
+/**
+ * intel_create_plane_state - create plane state object
+ * @plane: drm plane
+ *
+ * Allocates a fresh plane state for the given plane and sets some of
+ * the state values to sensible initial values.
+ *
+ * Returns: A newly allocated plane state, or NULL on failure
+ */
+struct intel_plane_state *
+intel_create_plane_state(struct drm_plane *plane)
+{
+       struct intel_plane_state *state;
+
+       state = kzalloc(sizeof(*state), GFP_KERNEL);
+       if (!state)
+               return NULL;
+
+       state->base.plane = plane;
+       state->base.rotation = BIT(DRM_ROTATE_0);
+
+       return state;
+}
+
 /**
  * intel_plane_duplicate_state - duplicate plane state
  * @plane: drm plane
  * Allocates and returns a copy of the plane state (both common and
  * Intel-specific) for the specified plane.
  *
- * Returns: The newly allocated plane state, or NULL or failure.
+ * Returns: The newly allocated plane state, or NULL on failure.
  */
 struct drm_plane_state *
 intel_plane_duplicate_state(struct drm_plane *plane)
 {
-       struct intel_plane_state *state;
+       struct drm_plane_state *state;
+       struct intel_plane_state *intel_state;
 
-       if (plane->state)
-               state = kmemdup(plane->state, sizeof(*state), GFP_KERNEL);
+       if (WARN_ON(!plane->state))
+               intel_state = intel_create_plane_state(plane);
        else
-               state = kzalloc(sizeof(*state), GFP_KERNEL);
+               intel_state = kmemdup(plane->state, sizeof(*intel_state),
+                                     GFP_KERNEL);
 
-       if (!state)
+       if (!intel_state)
                return NULL;
 
-       if (state->base.fb)
-               drm_framebuffer_reference(state->base.fb);
+       state = &intel_state->base;
+       if (state->fb)
+               drm_framebuffer_reference(state->fb);
 
-       return &state->base;
+       return state;
 }
 
 /**
@@ -108,9 +135,9 @@ static int intel_plane_atomic_check(struct drm_plane *plane,
        intel_state->clip.x1 = 0;
        intel_state->clip.y1 = 0;
        intel_state->clip.x2 =
-               intel_crtc->active ? intel_crtc->config.pipe_src_w : 0;
+               intel_crtc->active ? intel_crtc->config->pipe_src_w : 0;
        intel_state->clip.y2 =
-               intel_crtc->active ? intel_crtc->config.pipe_src_h : 0;
+               intel_crtc->active ? intel_crtc->config->pipe_src_h : 0;
 
        /*
         * Disabling a plane is always okay; we just need to update
This page took 0.027274 seconds and 5 git commands to generate.