drm: Add drm_plane_mask()
authorVille Syrjälä <ville.syrjala@linux.intel.com>
Tue, 26 Jun 2018 19:47:07 +0000 (22:47 +0300)
committerVille Syrjälä <ville.syrjala@linux.intel.com>
Mon, 2 Jul 2018 15:45:55 +0000 (18:45 +0300)
Add drm_plane_mask() which returns the 1<<index for the plane.
We already have an identical drm_crtc_mask() for crtcs.

Mostly performed with coccinelle:
@@
@@
- (1<<drm_plane_index(
+ drm_plane_mask(
  ...)
-  )

@@
@@
- 1<<drm_plane_index(
+ drm_plane_mask(
  ...)

@@
@@
- BIT(drm_plane_index(
+ drm_plane_mask(
  ...)
- )

Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20180626194716.12522-1-ville.syrjala@linux.intel.com
Reviewed-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
drivers/gpu/drm/drm_atomic.c
drivers/gpu/drm/drm_framebuffer.c
drivers/gpu/drm/drm_simple_kms_helper.c
include/drm/drm_plane.h

index 178842380f75847ae3666c4bec261ed5d57299d1..684c9d3a1d6cb1abcb705f01b24a26579a7c5afb 100644 (file)
@@ -1581,7 +1581,7 @@ drm_atomic_set_crtc_for_plane(struct drm_plane_state *plane_state,
                if (WARN_ON(IS_ERR(crtc_state)))
                        return PTR_ERR(crtc_state);
 
-               crtc_state->plane_mask &= ~(1 << drm_plane_index(plane));
+               crtc_state->plane_mask &= ~drm_plane_mask(plane);
        }
 
        plane_state->crtc = crtc;
@@ -1591,7 +1591,7 @@ drm_atomic_set_crtc_for_plane(struct drm_plane_state *plane_state,
                                                       crtc);
                if (IS_ERR(crtc_state))
                        return PTR_ERR(crtc_state);
-               crtc_state->plane_mask |= (1 << drm_plane_index(plane));
+               crtc_state->plane_mask |= drm_plane_mask(plane);
        }
 
        if (crtc)
index ed90974a452a17b6fc51ffff469e492a33b6794a..781af1d42d766bf63db12801ace4703132db84fa 100644 (file)
@@ -847,7 +847,7 @@ retry:
                if (ret)
                        goto unlock;
 
-               plane_mask |= BIT(drm_plane_index(plane));
+               plane_mask |= drm_plane_mask(plane);
        }
 
        /* This list is only filled when disable_crtcs is set. */
index 7a00455ca568b0e82f35f6a6a5d972f26d41b204..9d87961da1dbccf759facd7926d453dac21d1ddf 100644 (file)
@@ -52,7 +52,7 @@ static int drm_simple_kms_crtc_check(struct drm_crtc *crtc,
                                     struct drm_crtc_state *state)
 {
        bool has_primary = state->plane_mask &
-                          BIT(drm_plane_index(crtc->primary));
+                          drm_plane_mask(crtc->primary);
 
        /* We always want to have an active plane with an active CRTC */
        if (has_primary != state->enable)
index 7d4d6c7f0afdb0f3764c9fa6f7644398a3e1bb40..cee9dfaaa740e4ce83de8f680d88442255ce969f 100644 (file)
@@ -639,10 +639,20 @@ void drm_plane_cleanup(struct drm_plane *plane);
  * Given a registered plane, return the index of that plane within a DRM
  * device's list of planes.
  */
-static inline unsigned int drm_plane_index(struct drm_plane *plane)
+static inline unsigned int drm_plane_index(const struct drm_plane *plane)
 {
        return plane->index;
 }
+
+/**
+ * drm_plane_mask - find the mask of a registered plane
+ * @plane: plane to find mask for
+ */
+static inline u32 drm_plane_mask(const struct drm_plane *plane)
+{
+       return 1 << drm_plane_index(plane);
+}
+
 struct drm_plane * drm_plane_from_index(struct drm_device *dev, int idx);
 void drm_plane_force_disable(struct drm_plane *plane);
 
@@ -678,7 +688,7 @@ static inline struct drm_plane *drm_plane_find(struct drm_device *dev,
  */
 #define drm_for_each_plane_mask(plane, dev, plane_mask) \
        list_for_each_entry((plane), &(dev)->mode_config.plane_list, head) \
-               for_each_if ((plane_mask) & (1 << drm_plane_index(plane)))
+               for_each_if ((plane_mask) & drm_plane_mask(plane))
 
 /**
  * drm_for_each_legacy_plane - iterate over all planes for legacy userspace