Re: [PATCH] drm/exynos/decon5433: implement frame counter

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

 




2017년 03월 02일 17:35에 Andrzej Hajda 이(가) 쓴 글:
> Decon in Exynos5433 has frame counter, it can be used to implement
> get_vblank_counter callback.
> 
> Signed-off-by: Andrzej Hajda <a.hajda@xxxxxxxxxxx>
> ---
> Hi Inki,
> 
> The patch is based on my last patches, maybe to make it clear I will resend all
> these patches in one patchset, what do you think?

One patch set it better. :)

Thanks.

> 
> Regards
> Andrzej
> 
>  drivers/gpu/drm/exynos/exynos5433_drm_decon.c | 76 ++++++++++++++++++---------
>  drivers/gpu/drm/exynos/exynos_drm_crtc.c      | 11 ++++
>  drivers/gpu/drm/exynos/exynos_drm_drv.h       |  1 +
>  3 files changed, 63 insertions(+), 25 deletions(-)
> 
> diff --git a/drivers/gpu/drm/exynos/exynos5433_drm_decon.c b/drivers/gpu/drm/exynos/exynos5433_drm_decon.c
> index 4b596dc..4b5af67 100644
> --- a/drivers/gpu/drm/exynos/exynos5433_drm_decon.c
> +++ b/drivers/gpu/drm/exynos/exynos5433_drm_decon.c
> @@ -123,6 +123,53 @@ static void decon_disable_vblank(struct exynos_drm_crtc *crtc)
>  		writel(0, ctx->addr + DECON_VIDINTCON0);
>  }
>  
> +/* return number of starts/ends of frame transmissions since reset */
> +static u32 decon_get_frame_count(struct decon_context *ctx, bool end)
> +{
> +	u32 frm, pfrm, status, cnt;
> +
> +	/* To get consistent result repeat read until frame id is stable. */
> +	frm = readl(ctx->addr + DECON_CRFMID);
> +	cnt = 3;
> +	do {
> +		status = readl(ctx->addr + DECON_VIDCON1);
> +		pfrm = frm;
> +		frm = readl(ctx->addr + DECON_CRFMID);
> +	} while (frm != pfrm && --cnt);
> +
> +	/* CRFMID is incremented on BPORCH in case of I80 and on VSYNC in case
> +	 * of RGB, it should be taken into account.
> +	 */
> +	if (!frm)
> +		return 0;
> +
> +	switch (status & (VIDCON1_VSTATUS_MASK | VIDCON1_I80_ACTIVE)) {
> +	case VIDCON1_VSTATUS_VS:
> +		if (!(ctx->out_type & IFTYPE_I80))
> +			--frm;
> +		break;
> +	case VIDCON1_VSTATUS_BP:
> +		--frm;
> +		break;
> +	case VIDCON1_I80_ACTIVE:
> +	case VIDCON1_VSTATUS_AC:
> +		if (end)
> +			--frm;
> +	}
> +
> +	return frm;
> +}
> +
> +static u32 decon_get_vblank_counter(struct exynos_drm_crtc *crtc)
> +{
> +	struct decon_context *ctx = crtc->ctx;
> +
> +	if (test_bit(BIT_SUSPENDED, &ctx->flags))
> +		return 0;
> +
> +	return decon_get_frame_count(ctx, false);
> +}
> +
>  static void decon_setup_trigger(struct decon_context *ctx)
>  {
>  	if (!(ctx->out_type & (IFTYPE_I80 | I80_HW_TRG)))
> @@ -518,6 +565,7 @@ static const struct exynos_drm_crtc_ops decon_crtc_ops = {
>  	.enable			= decon_enable,
>  	.disable		= decon_disable,
>  	.enable_vblank		= decon_enable_vblank,
> +	.get_vblank_counter	= decon_get_vblank_counter,
>  	.disable_vblank		= decon_disable_vblank,
>  	.atomic_begin		= decon_atomic_begin,
>  	.update_plane		= decon_update_plane,
> @@ -536,6 +584,7 @@ static int decon_bind(struct device *dev, struct device *master, void *data)
>  	int ret;
>  
>  	ctx->drm_dev = drm_dev;
> +	drm_dev->max_vblank_count = 0xffffffff;
>  
>  	for (win = ctx->first_win; win < WINDOWS_NR; win++) {
>  		int tmp = (win == ctx->first_win) ? 0 : win;
> @@ -581,34 +630,11 @@ static const struct component_ops decon_component_ops = {
>  
>  static void decon_handle_vblank(struct decon_context *ctx)
>  {
> -	u32 frm, pfrm, status, cnt;
> +	u32 frm;
>  
>  	spin_lock(&ctx->vblank_lock);
>  
> -	/* To get consistent result repeat read until frame id is stable. */
> -	frm = readl(ctx->addr + DECON_CRFMID);
> -	cnt = 3;
> -	do {
> -		status = readl(ctx->addr + DECON_VIDCON1);
> -		pfrm = frm;
> -		frm = readl(ctx->addr + DECON_CRFMID);
> -	} while (frm != pfrm && --cnt);
> -
> -	status &= VIDCON1_VSTATUS_MASK | VIDCON1_I80_ACTIVE;
> -
> -	/* In case of delayed vblank CRFMID could be already incremented,
> -	 * it should be taken into account.
> -	 */
> -	if (frm > 0)
> -		switch (status) {
> -		case VIDCON1_VSTATUS_VS:
> -			if (ctx->out_type & IFTYPE_I80)
> -				break;
> -		case VIDCON1_I80_ACTIVE:
> -		case VIDCON1_VSTATUS_BP:
> -		case VIDCON1_VSTATUS_AC:
> -			--frm;
> -		}
> +	frm = decon_get_frame_count(ctx, true);
>  
>  	if (frm != ctx->frame_id) {
>  		if (frm > ctx->frame_id)
> diff --git a/drivers/gpu/drm/exynos/exynos_drm_crtc.c b/drivers/gpu/drm/exynos/exynos_drm_crtc.c
> index 0c9a775..d72777f 100644
> --- a/drivers/gpu/drm/exynos/exynos_drm_crtc.c
> +++ b/drivers/gpu/drm/exynos/exynos_drm_crtc.c
> @@ -132,6 +132,16 @@ static void exynos_drm_crtc_disable_vblank(struct drm_crtc *crtc)
>  		exynos_crtc->ops->disable_vblank(exynos_crtc);
>  }
>  
> +static u32 exynos_drm_crtc_get_vblank_counter(struct drm_crtc *crtc)
> +{
> +	struct exynos_drm_crtc *exynos_crtc = to_exynos_crtc(crtc);
> +
> +	if (exynos_crtc->ops->get_vblank_counter)
> +		return exynos_crtc->ops->get_vblank_counter(exynos_crtc);
> +
> +	return 0;
> +}
> +
>  static const struct drm_crtc_funcs exynos_crtc_funcs = {
>  	.set_config	= drm_atomic_helper_set_config,
>  	.page_flip	= drm_atomic_helper_page_flip,
> @@ -141,6 +151,7 @@ static const struct drm_crtc_funcs exynos_crtc_funcs = {
>  	.atomic_destroy_state = drm_atomic_helper_crtc_destroy_state,
>  	.enable_vblank = exynos_drm_crtc_enable_vblank,
>  	.disable_vblank = exynos_drm_crtc_disable_vblank,
> +	.get_vblank_counter = exynos_drm_crtc_get_vblank_counter,
>  };
>  
>  struct exynos_drm_crtc *exynos_drm_crtc_create(struct drm_device *drm_dev,
> diff --git a/drivers/gpu/drm/exynos/exynos_drm_drv.h b/drivers/gpu/drm/exynos/exynos_drm_drv.h
> index e52f70a..527bf1d 100644
> --- a/drivers/gpu/drm/exynos/exynos_drm_drv.h
> +++ b/drivers/gpu/drm/exynos/exynos_drm_drv.h
> @@ -131,6 +131,7 @@ struct exynos_drm_crtc_ops {
>  	void (*disable)(struct exynos_drm_crtc *crtc);
>  	int (*enable_vblank)(struct exynos_drm_crtc *crtc);
>  	void (*disable_vblank)(struct exynos_drm_crtc *crtc);
> +	u32 (*get_vblank_counter)(struct exynos_drm_crtc *crtc);
>  	int (*atomic_check)(struct exynos_drm_crtc *crtc,
>  			    struct drm_crtc_state *state);
>  	void (*atomic_begin)(struct exynos_drm_crtc *crtc);
> 
_______________________________________________
dri-devel mailing list
dri-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/dri-devel




[Index of Archives]     [Linux DRI Users]     [Linux Intel Graphics]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux