diff mbox series

[1/6] drm/i915: Generalize planes_{enabling, disabling}()

Message ID 20230320203352.19515-2-ville.syrjala@linux.intel.com (mailing list archive)
State New, archived
Headers show
Series drm/i915/vrr: Allow fastset to enable/disable VRR | expand

Commit Message

Ville Syrjälä March 20, 2023, 8:33 p.m. UTC
From: Ville Syrjälä <ville.syrjala@linux.intel.com>

I want to use the same logic that planes_{enabling,disabling}()
are using for other features as well. Generlize the thing
into a pair of macros.

Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
---
 drivers/gpu/drm/i915/display/intel_display.c | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)

Comments

Mitul Golani April 5, 2023, 7:31 a.m. UTC | #1
> -----Original Message-----
> From: Intel-gfx <intel-gfx-bounces@lists.freedesktop.org> On Behalf Of Ville
> Syrjala
> Sent: 21 March 2023 02:04
> To: intel-gfx@lists.freedesktop.org
> Subject: [Intel-gfx] [PATCH 1/6] drm/i915: Generalize planes_{enabling,
> disabling}()
> 
> From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> 
> I want to use the same logic that planes_{enabling,disabling}() are using for
> other features as well. Generlize the thing into a pair of macros.
> 
> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
> ---
>  drivers/gpu/drm/i915/display/intel_display.c | 16 ++++++++++++----
>  1 file changed, 12 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/display/intel_display.c
> b/drivers/gpu/drm/i915/display/intel_display.c
> index 121990ba2a28..3356b0724e1e 100644
> --- a/drivers/gpu/drm/i915/display/intel_display.c
> +++ b/drivers/gpu/drm/i915/display/intel_display.c
> @@ -1069,20 +1069,28 @@ static bool needs_async_flip_vtd_wa(const
> struct intel_crtc_state *crtc_state)
>  		(DISPLAY_VER(i915) == 9 || IS_BROADWELL(i915) ||
> IS_HASWELL(i915));  }
> 
> +#define is_enabling(feature, old_crtc_state, new_crtc_state) \
> +	((!(old_crtc_state)->feature ||
> intel_crtc_needs_modeset(new_crtc_state)) && \
> +	 (new_crtc_state)->feature)
> +#define is_disabling(feature, old_crtc_state, new_crtc_state) \
> +	((old_crtc_state)->feature && \
> +	 (!(new_crtc_state)->feature ||
> +intel_crtc_needs_modeset(new_crtc_state)))
> +
>  static bool planes_enabling(const struct intel_crtc_state *old_crtc_state,
>  			    const struct intel_crtc_state *new_crtc_state)  {
> -	return (!old_crtc_state->active_planes ||
> intel_crtc_needs_modeset(new_crtc_state)) &&
> -		new_crtc_state->active_planes;
> +	return is_enabling(active_planes, old_crtc_state, new_crtc_state);
>  }
> 
>  static bool planes_disabling(const struct intel_crtc_state *old_crtc_state,
>  			     const struct intel_crtc_state *new_crtc_state)  {
> -	return old_crtc_state->active_planes &&
> -		(!new_crtc_state->active_planes ||
> intel_crtc_needs_modeset(new_crtc_state));
> +	return is_disabling(active_planes, old_crtc_state, new_crtc_state);
>  }
> 
> +#undef is_disabling
> +#undef is_enabling
> +
>  static void intel_post_plane_update(struct intel_atomic_state *state,
>  				    struct intel_crtc *crtc)
>  {
> --
> 2.39.2

changes LGTM. 
Thanks
 
Reviewed-by: Mitul Golani <mitulkumar.ajitkumar.golani@intel.com>
diff mbox series

Patch

diff --git a/drivers/gpu/drm/i915/display/intel_display.c b/drivers/gpu/drm/i915/display/intel_display.c
index 121990ba2a28..3356b0724e1e 100644
--- a/drivers/gpu/drm/i915/display/intel_display.c
+++ b/drivers/gpu/drm/i915/display/intel_display.c
@@ -1069,20 +1069,28 @@  static bool needs_async_flip_vtd_wa(const struct intel_crtc_state *crtc_state)
 		(DISPLAY_VER(i915) == 9 || IS_BROADWELL(i915) || IS_HASWELL(i915));
 }
 
+#define is_enabling(feature, old_crtc_state, new_crtc_state) \
+	((!(old_crtc_state)->feature || intel_crtc_needs_modeset(new_crtc_state)) && \
+	 (new_crtc_state)->feature)
+#define is_disabling(feature, old_crtc_state, new_crtc_state) \
+	((old_crtc_state)->feature && \
+	 (!(new_crtc_state)->feature || intel_crtc_needs_modeset(new_crtc_state)))
+
 static bool planes_enabling(const struct intel_crtc_state *old_crtc_state,
 			    const struct intel_crtc_state *new_crtc_state)
 {
-	return (!old_crtc_state->active_planes || intel_crtc_needs_modeset(new_crtc_state)) &&
-		new_crtc_state->active_planes;
+	return is_enabling(active_planes, old_crtc_state, new_crtc_state);
 }
 
 static bool planes_disabling(const struct intel_crtc_state *old_crtc_state,
 			     const struct intel_crtc_state *new_crtc_state)
 {
-	return old_crtc_state->active_planes &&
-		(!new_crtc_state->active_planes || intel_crtc_needs_modeset(new_crtc_state));
+	return is_disabling(active_planes, old_crtc_state, new_crtc_state);
 }
 
+#undef is_disabling
+#undef is_enabling
+
 static void intel_post_plane_update(struct intel_atomic_state *state,
 				    struct intel_crtc *crtc)
 {