drm/i915: Fix plane allocation/free functions
authorMaarten Lankhorst <maarten.lankhorst@linux.intel.com>
Tue, 13 Nov 2018 09:28:04 +0000 (10:28 +0100)
committerMaarten Lankhorst <maarten.lankhorst@linux.intel.com>
Thu, 15 Nov 2018 11:16:33 +0000 (12:16 +0100)
Use intel_plane_destroy_state in intel_plane_free to free the state.
Also fix intel_plane_alloc() to use __drm_atomic_helper_plane_reset(),
to get sane defaults from the atomic core.

This is needed to get the correct alpha value and blend mode from the
core, and any new default values added from new properties.

Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Reported-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
Fixes: b20815255693 ("drm/i915: Add plane alpha blending support, v2.")
[mlankhorst: Update commit description to mention alpha blend support]
Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20181113092804.13304-1-maarten.lankhorst@linux.intel.com
drivers/gpu/drm/i915/intel_atomic_plane.c
drivers/gpu/drm/i915/intel_drv.h
drivers/gpu/drm/i915/intel_sprite.c

index 7d3685075201f05e21e002815e57da4c9b6bca47..905f8ef3ba4fce9fb7a34e757e168c4440c63774 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 *intel_plane_alloc(void)
 {
-       struct intel_plane_state *state;
+       struct intel_plane_state *plane_state;
+       struct intel_plane *plane;
 
-       state = kzalloc(sizeof(*state), GFP_KERNEL);
-       if (!state)
-               return NULL;
+       plane = kzalloc(sizeof(*plane), GFP_KERNEL);
+       if (!plane)
+               return ERR_PTR(-ENOMEM);
 
-       state->base.plane = plane;
-       state->base.rotation = DRM_MODE_ROTATE_0;
-       state->scaler_id = -1;
+       plane_state = kzalloc(sizeof(*plane_state), GFP_KERNEL);
+       if (!plane_state) {
+               kfree(plane);
+               return ERR_PTR(-ENOMEM);
+       }
 
-       return state;
+       __drm_atomic_helper_plane_reset(&plane->base, &plane_state->base);
+       plane_state->scaler_id = -1;
+
+       return plane;
+}
+
+void intel_plane_free(struct intel_plane *plane)
+{
+       intel_plane_destroy_state(&plane->base, plane->base.state);
+       kfree(plane);
 }
 
 /**
index 18b419f7f7fe85b2d87446b64ff526cfa63dedad..f575ba2a59da221adb198c08c13ba822030b0eda 100644 (file)
@@ -2219,8 +2219,6 @@ void intel_pipe_update_end(struct intel_crtc_state *new_crtc_state);
 int intel_plane_check_stride(const struct intel_plane_state *plane_state);
 int intel_plane_check_src_coordinates(struct intel_plane_state *plane_state);
 int chv_plane_check_rotation(const struct intel_plane_state *plane_state);
-struct intel_plane *intel_plane_alloc(void);
-void intel_plane_free(struct intel_plane *plane);
 struct intel_plane *
 skl_universal_plane_create(struct drm_i915_private *dev_priv,
                           enum pipe pipe, enum plane_id plane_id);
@@ -2282,7 +2280,8 @@ int intel_atomic_setup_scalers(struct drm_i915_private *dev_priv,
                               struct intel_crtc_state *crtc_state);
 
 /* intel_atomic_plane.c */
-struct intel_plane_state *intel_create_plane_state(struct drm_plane *plane);
+struct intel_plane *intel_plane_alloc(void);
+void intel_plane_free(struct intel_plane *plane);
 struct drm_plane_state *intel_plane_duplicate_state(struct drm_plane *plane);
 void intel_plane_destroy_state(struct drm_plane *plane,
                               struct drm_plane_state *state);
index 5e0f7b575a50e8f5109700532124b6fff923d7f2..abe193815cccfde71d19d7d71e7ba1dd94fbd6c2 100644 (file)
@@ -1983,35 +1983,6 @@ static bool skl_plane_has_ccs(struct drm_i915_private *dev_priv,
                 plane_id == PLANE_SPRITE0);
 }
 
-struct intel_plane *intel_plane_alloc(void)
-{
-       struct intel_plane_state *plane_state;
-       struct intel_plane *plane;
-
-       plane = kzalloc(sizeof(*plane), GFP_KERNEL);
-       if (!plane)
-               return ERR_PTR(-ENOMEM);
-
-       plane_state = intel_create_plane_state(&plane->base);
-       if (!plane_state) {
-               kfree(plane);
-               return ERR_PTR(-ENOMEM);
-       }
-
-       plane->base.state = &plane_state->base;
-
-       return plane;
-}
-
-void intel_plane_free(struct intel_plane *plane)
-{
-       struct intel_plane_state *plane_state =
-               to_intel_plane_state(plane->base.state);
-
-       kfree(plane_state);
-       kfree(plane);
-}
-
 struct intel_plane *
 skl_universal_plane_create(struct drm_i915_private *dev_priv,
                           enum pipe pipe, enum plane_id plane_id)