Re: [PATCH 3/7] drm/i915: Add i915_get_crtc_scanline()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, 17 Oct 2013 22:53:15 +0300
ville.syrjala@xxxxxxxxxxxxxxx wrote:

> From: Ville Syrjälä <ville.syrjala@xxxxxxxxxxxxxxx>
> 
> Refactor the i915_get_crtc_scanoutpos() code a bit to make the
> "negative values during vblank" adjustment optional. For most uses
> the raw scanline number without such adjustments is easier to use.
> 
> Signed-off-by: Ville Syrjälä <ville.syrjala@xxxxxxxxxxxxxxx>
> ---
>  drivers/gpu/drm/i915/i915_irq.c  | 46 ++++++++++++++++++++++++++++------------
>  drivers/gpu/drm/i915/intel_drv.h |  1 +
>  2 files changed, 33 insertions(+), 14 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/i915_irq.c b/drivers/gpu/drm/i915/i915_irq.c
> index 6b379de..49bcf4e 100644
> --- a/drivers/gpu/drm/i915/i915_irq.c
> +++ b/drivers/gpu/drm/i915/i915_irq.c
> @@ -646,8 +646,8 @@ static bool intel_pipe_in_vblank(struct drm_device *dev, enum pipe pipe)
>  	}
>  }
>  
> -static int i915_get_crtc_scanoutpos(struct drm_device *dev, int pipe,
> -			     int *vpos, int *hpos)
> +int i915_get_crtc_scanoutpos(struct drm_device *dev, int pipe,
> +			     int *vpos, int *hpos, bool adjust)
>  {
>  	struct drm_i915_private *dev_priv = dev->dev_private;
>  	struct drm_crtc *crtc = dev_priv->pipe_to_crtc_mapping[pipe];
> @@ -704,18 +704,20 @@ static int i915_get_crtc_scanoutpos(struct drm_device *dev, int pipe,
>  		vtotal *= htotal;
>  	}
>  
> -	in_vbl = position >= vbl_start && position < vbl_end;
> +	if (adjust) {
> +		in_vbl = position >= vbl_start && position < vbl_end;
>  
> -	/*
> -	 * While in vblank, position will be negative
> -	 * counting up towards 0 at vbl_end. And outside
> -	 * vblank, position will be positive counting
> -	 * up since vbl_end.
> -	 */
> -	if (position >= vbl_start)
> -		position -= vbl_end;
> -	else
> -		position += vtotal - vbl_end;
> +		/*
> +		 * While in vblank, position will be negative
> +		 * counting up towards 0 at vbl_end. And outside
> +		 * vblank, position will be positive counting
> +		 * up since vbl_end.
> +		 */
> +		if (position >= vbl_start)
> +			position -= vbl_end;
> +		else
> +			position += vtotal - vbl_end;
> +	}
>  
>  	if (IS_GEN2(dev) || IS_G4X(dev) || INTEL_INFO(dev)->gen >= 5) {
>  		*vpos = position;
> @@ -732,6 +734,22 @@ static int i915_get_crtc_scanoutpos(struct drm_device *dev, int pipe,
>  	return ret;
>  }
>  
> +static int i915_get_scanout_position(struct drm_device *dev, int pipe,
> +				     int *vpos, int *hpos)
> +{
> +	return i915_get_crtc_scanoutpos(dev, pipe, vpos, hpos, true);
> +}
> +
> +int i915_get_crtc_scanline(struct drm_crtc *crtc)
> +{
> +	int vpos = 0, hpos = 0;
> +
> +	i915_get_crtc_scanoutpos(crtc->dev, to_intel_crtc(crtc)->pipe,
> +				 &vpos, &hpos, false);
> +
> +	return vpos;
> +}
> +
>  static int i915_get_vblank_timestamp(struct drm_device *dev, int pipe,
>  			      int *max_error,
>  			      struct timeval *vblank_time,
> @@ -3313,7 +3331,7 @@ void intel_irq_init(struct drm_device *dev)
>  
>  	if (drm_core_check_feature(dev, DRIVER_MODESET)) {
>  		dev->driver->get_vblank_timestamp = i915_get_vblank_timestamp;
> -		dev->driver->get_scanout_position = i915_get_crtc_scanoutpos;
> +		dev->driver->get_scanout_position = i915_get_scanout_position;
>  	}
>  
>  	if (IS_VALLEYVIEW(dev)) {
> diff --git a/drivers/gpu/drm/i915/intel_drv.h b/drivers/gpu/drm/i915/intel_drv.h
> index e33f387..7f5f74d 100644
> --- a/drivers/gpu/drm/i915/intel_drv.h
> +++ b/drivers/gpu/drm/i915/intel_drv.h
> @@ -580,6 +580,7 @@ void snb_enable_pm_irq(struct drm_i915_private *dev_priv, uint32_t mask);
>  void snb_disable_pm_irq(struct drm_i915_private *dev_priv, uint32_t mask);
>  void hsw_pc8_disable_interrupts(struct drm_device *dev);
>  void hsw_pc8_restore_interrupts(struct drm_device *dev);
> +int i915_get_crtc_scanline(struct drm_crtc *crtc);
>  
>  
>  /* intel_crt.c */

Reviewed-by: Jesse Barnes <jbarnes@xxxxxxxxxxxxxxxx>

-- 
Jesse Barnes, Intel Open Source Technology Center
_______________________________________________
Intel-gfx mailing list
Intel-gfx@xxxxxxxxxxxxxxxxxxxxx
http://lists.freedesktop.org/mailman/listinfo/intel-gfx





[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]
  Powered by Linux