All of lore.kernel.org
 help / color / mirror / Atom feed
From: Inki Dae <inki.dae@samsung.com>
To: Andrzej Hajda <a.hajda@samsung.com>,
	dri-devel@lists.freedesktop.org,
	linux-samsung-soc@vger.kernel.org
Cc: Marek Szyprowski <m.szyprowski@samsung.com>,
	Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
Subject: Re: [PATCH] drm/exynos/decon5433: implement frame counter
Date: Tue, 07 Mar 2017 18:22:18 +0900	[thread overview]
Message-ID: <58BE7BCA.3080203@samsung.com> (raw)
In-Reply-To: <1488443736-5287-1-git-send-email-a.hajda@samsung.com>



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@samsung.com>
> ---
> 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@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

      reply	other threads:[~2017-03-07  9:22 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CGME20170302083541eucas1p13c1c1f247f06714e6cf4b5732b22dc49@eucas1p1.samsung.com>
2017-03-02  8:35 ` [PATCH] drm/exynos/decon5433: implement frame counter Andrzej Hajda
2017-03-07  9:22   ` Inki Dae [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=58BE7BCA.3080203@samsung.com \
    --to=inki.dae@samsung.com \
    --cc=a.hajda@samsung.com \
    --cc=b.zolnierkie@samsung.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=linux-samsung-soc@vger.kernel.org \
    --cc=m.szyprowski@samsung.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.