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

Jani Nikula jani.nikula at linux.intel.com
Wed May 8 09:12:32 UTC 2024


On Mon, 08 Apr 2024, Ville Syrjala <ville.syrjala at linux.intel.com> wrote:
> From: Ville Syrjälä <ville.syrjala at linux.intel.com>
>
> Replace the open coded drm_crtc_vblank_crtc() with the real
> thing.
>
> Cc: intel-gfx at lists.freedesktop.org
> Signed-off-by: Ville Syrjälä <ville.syrjala at linux.intel.com>

Reviewed-by: Jani Nikula <jani.nikula at 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;

-- 
Jani Nikula, Intel


More information about the dri-devel mailing list