diff mbox series

[3/5] drm/i915: Use drm_crtc_vblank_crtc()

Message ID 20240408190611.24914-3-ville.syrjala@linux.intel.com (mailing list archive)
State New, archived
Headers show
Series [1/5] drm/vblank: Introduce drm_crtc_vblank_crtc() | expand

Commit Message

Ville Syrjälä April 8, 2024, 7:06 p.m. UTC
From: Ville Syrjälä <ville.syrjala@linux.intel.com>

Replace the open coded drm_crtc_vblank_crtc() with the real
thing.

Cc: intel-gfx@lists.freedesktop.org
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
---
 drivers/gpu/drm/i915/display/intel_crtc.c   |  3 +--
 drivers/gpu/drm/i915/display/intel_vblank.c | 16 +++++-----------
 2 files changed, 6 insertions(+), 13 deletions(-)

Comments

Jani Nikula May 8, 2024, 9:12 a.m. UTC | #1
On Mon, 08 Apr 2024, Ville Syrjala <ville.syrjala@linux.intel.com> wrote:
> From: Ville Syrjälä <ville.syrjala@linux.intel.com>
>
> Replace the open coded drm_crtc_vblank_crtc() with the real
> thing.
>
> Cc: intel-gfx@lists.freedesktop.org
> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>

Reviewed-by: Jani Nikula <jani.nikula@intel.com>

> ---
>  drivers/gpu/drm/i915/display/intel_crtc.c   |  3 +--
>  drivers/gpu/drm/i915/display/intel_vblank.c | 16 +++++-----------
>  2 files changed, 6 insertions(+), 13 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/display/intel_crtc.c b/drivers/gpu/drm/i915/display/intel_crtc.c
> index 25593f6aae7d..339010384b86 100644
> --- a/drivers/gpu/drm/i915/display/intel_crtc.c
> +++ b/drivers/gpu/drm/i915/display/intel_crtc.c
> @@ -78,8 +78,7 @@ void intel_wait_for_vblank_if_active(struct drm_i915_private *i915,
>  
>  u32 intel_crtc_get_vblank_counter(struct intel_crtc *crtc)
>  {
> -	struct drm_device *dev = crtc->base.dev;
> -	struct drm_vblank_crtc *vblank = &dev->vblank[drm_crtc_index(&crtc->base)];
> +	struct drm_vblank_crtc *vblank = drm_crtc_vblank_crtc(&crtc->base);
>  
>  	if (!crtc->active)
>  		return 0;
> diff --git a/drivers/gpu/drm/i915/display/intel_vblank.c b/drivers/gpu/drm/i915/display/intel_vblank.c
> index baf7354cb6e2..951190bcbc50 100644
> --- a/drivers/gpu/drm/i915/display/intel_vblank.c
> +++ b/drivers/gpu/drm/i915/display/intel_vblank.c
> @@ -132,8 +132,7 @@ u32 g4x_get_vblank_counter(struct drm_crtc *crtc)
>  static u32 intel_crtc_scanlines_since_frame_timestamp(struct intel_crtc *crtc)
>  {
>  	struct drm_i915_private *dev_priv = to_i915(crtc->base.dev);
> -	struct drm_vblank_crtc *vblank =
> -		&crtc->base.dev->vblank[drm_crtc_index(&crtc->base)];
> +	struct drm_vblank_crtc *vblank = drm_crtc_vblank_crtc(&crtc->base);
>  	const struct drm_display_mode *mode = &vblank->hwmode;
>  	u32 htotal = mode->crtc_htotal;
>  	u32 clock = mode->crtc_clock;
> @@ -178,8 +177,7 @@ static u32 intel_crtc_scanlines_since_frame_timestamp(struct intel_crtc *crtc)
>   */
>  static u32 __intel_get_crtc_scanline_from_timestamp(struct intel_crtc *crtc)
>  {
> -	struct drm_vblank_crtc *vblank =
> -		&crtc->base.dev->vblank[drm_crtc_index(&crtc->base)];
> +	struct drm_vblank_crtc *vblank = drm_crtc_vblank_crtc(&crtc->base);
>  	const struct drm_display_mode *mode = &vblank->hwmode;
>  	u32 vblank_start = mode->crtc_vblank_start;
>  	u32 vtotal = mode->crtc_vtotal;
> @@ -200,17 +198,14 @@ static int __intel_get_crtc_scanline(struct intel_crtc *crtc)
>  {
>  	struct drm_device *dev = crtc->base.dev;
>  	struct drm_i915_private *dev_priv = to_i915(dev);
> -	const struct drm_display_mode *mode;
> -	struct drm_vblank_crtc *vblank;
> +	struct drm_vblank_crtc *vblank = drm_crtc_vblank_crtc(&crtc->base);
> +	const struct drm_display_mode *mode = &vblank->hwmode;
>  	enum pipe pipe = crtc->pipe;
>  	int position, vtotal;
>  
>  	if (!crtc->active)
>  		return 0;
>  
> -	vblank = &crtc->base.dev->vblank[drm_crtc_index(&crtc->base)];
> -	mode = &vblank->hwmode;
> -
>  	if (crtc->mode_flags & I915_MODE_FLAG_GET_SCANLINE_FROM_TIMESTAMP)
>  		return __intel_get_crtc_scanline_from_timestamp(crtc);
>  
> @@ -254,8 +249,7 @@ static int __intel_get_crtc_scanline(struct intel_crtc *crtc)
>  
>  int intel_crtc_scanline_to_hw(struct intel_crtc *crtc, int scanline)
>  {
> -	const struct drm_vblank_crtc *vblank =
> -		&crtc->base.dev->vblank[drm_crtc_index(&crtc->base)];
> +	const struct drm_vblank_crtc *vblank = drm_crtc_vblank_crtc(&crtc->base);
>  	const struct drm_display_mode *mode = &vblank->hwmode;
>  	int vtotal;
Ville Syrjälä May 8, 2024, 7:01 p.m. UTC | #2
On Wed, May 08, 2024 at 12:12:32PM +0300, Jani Nikula wrote:
> On Mon, 08 Apr 2024, Ville Syrjala <ville.syrjala@linux.intel.com> wrote:
> > From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> >
> > Replace the open coded drm_crtc_vblank_crtc() with the real
> > thing.
> >
> > Cc: intel-gfx@lists.freedesktop.org
> > Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
> 
> Reviewed-by: Jani Nikula <jani.nikula@intel.com>

Ta. Pushed this one to to drm-intel-next since
drm_crtc_vblank_crtc() made it there in the meantime.
diff mbox series

Patch

diff --git a/drivers/gpu/drm/i915/display/intel_crtc.c b/drivers/gpu/drm/i915/display/intel_crtc.c
index 25593f6aae7d..339010384b86 100644
--- a/drivers/gpu/drm/i915/display/intel_crtc.c
+++ b/drivers/gpu/drm/i915/display/intel_crtc.c
@@ -78,8 +78,7 @@  void intel_wait_for_vblank_if_active(struct drm_i915_private *i915,
 
 u32 intel_crtc_get_vblank_counter(struct intel_crtc *crtc)
 {
-	struct drm_device *dev = crtc->base.dev;
-	struct drm_vblank_crtc *vblank = &dev->vblank[drm_crtc_index(&crtc->base)];
+	struct drm_vblank_crtc *vblank = drm_crtc_vblank_crtc(&crtc->base);
 
 	if (!crtc->active)
 		return 0;
diff --git a/drivers/gpu/drm/i915/display/intel_vblank.c b/drivers/gpu/drm/i915/display/intel_vblank.c
index baf7354cb6e2..951190bcbc50 100644
--- a/drivers/gpu/drm/i915/display/intel_vblank.c
+++ b/drivers/gpu/drm/i915/display/intel_vblank.c
@@ -132,8 +132,7 @@  u32 g4x_get_vblank_counter(struct drm_crtc *crtc)
 static u32 intel_crtc_scanlines_since_frame_timestamp(struct intel_crtc *crtc)
 {
 	struct drm_i915_private *dev_priv = to_i915(crtc->base.dev);
-	struct drm_vblank_crtc *vblank =
-		&crtc->base.dev->vblank[drm_crtc_index(&crtc->base)];
+	struct drm_vblank_crtc *vblank = drm_crtc_vblank_crtc(&crtc->base);
 	const struct drm_display_mode *mode = &vblank->hwmode;
 	u32 htotal = mode->crtc_htotal;
 	u32 clock = mode->crtc_clock;
@@ -178,8 +177,7 @@  static u32 intel_crtc_scanlines_since_frame_timestamp(struct intel_crtc *crtc)
  */
 static u32 __intel_get_crtc_scanline_from_timestamp(struct intel_crtc *crtc)
 {
-	struct drm_vblank_crtc *vblank =
-		&crtc->base.dev->vblank[drm_crtc_index(&crtc->base)];
+	struct drm_vblank_crtc *vblank = drm_crtc_vblank_crtc(&crtc->base);
 	const struct drm_display_mode *mode = &vblank->hwmode;
 	u32 vblank_start = mode->crtc_vblank_start;
 	u32 vtotal = mode->crtc_vtotal;
@@ -200,17 +198,14 @@  static int __intel_get_crtc_scanline(struct intel_crtc *crtc)
 {
 	struct drm_device *dev = crtc->base.dev;
 	struct drm_i915_private *dev_priv = to_i915(dev);
-	const struct drm_display_mode *mode;
-	struct drm_vblank_crtc *vblank;
+	struct drm_vblank_crtc *vblank = drm_crtc_vblank_crtc(&crtc->base);
+	const struct drm_display_mode *mode = &vblank->hwmode;
 	enum pipe pipe = crtc->pipe;
 	int position, vtotal;
 
 	if (!crtc->active)
 		return 0;
 
-	vblank = &crtc->base.dev->vblank[drm_crtc_index(&crtc->base)];
-	mode = &vblank->hwmode;
-
 	if (crtc->mode_flags & I915_MODE_FLAG_GET_SCANLINE_FROM_TIMESTAMP)
 		return __intel_get_crtc_scanline_from_timestamp(crtc);
 
@@ -254,8 +249,7 @@  static int __intel_get_crtc_scanline(struct intel_crtc *crtc)
 
 int intel_crtc_scanline_to_hw(struct intel_crtc *crtc, int scanline)
 {
-	const struct drm_vblank_crtc *vblank =
-		&crtc->base.dev->vblank[drm_crtc_index(&crtc->base)];
+	const struct drm_vblank_crtc *vblank = drm_crtc_vblank_crtc(&crtc->base);
 	const struct drm_display_mode *mode = &vblank->hwmode;
 	int vtotal;