Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp2021538imm; Thu, 27 Sep 2018 06:18:20 -0700 (PDT) X-Google-Smtp-Source: ACcGV61BIVyyHoF0C6+jZa5y/S5BCq1cGonGNm0olBN1QBsKVbeKkvfX06a/YqQci5E9k1wjkFK9 X-Received: by 2002:a62:6781:: with SMTP id t1-v6mr11469114pfj.200.1538054300199; Thu, 27 Sep 2018 06:18:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538054300; cv=none; d=google.com; s=arc-20160816; b=wbkoYik30PyQ5eg+DNJ6Lh7st63+TVu4QlqRtpv7Wbq72O5LQIIzgA29k+gcv5kMk+ 1f7BivdK7kcAcoFawn0X/yxJaZgnfXiMwzmFYrdxYgzQSRAhf+m5lJTm/E7FJPrrWI17 pdtnKjjTQx5XcO/yJaYcRyl+PiLsKkW8QOw30lKN57/wvRf+7lTcwSj46E4QRdx/oiSR f8PWrQFijVci3yHs4qKRCEoJVAZLWsdDZZ3LR7d+XQ+D7EY99sjjBVvfb4M2vEJqmMza VK7FOzsngwneCzRYtWNjcfleBwJxoKWit6XYCFZL8g4y6YP55yePFyMQtXE7WRXMQfKU yj9Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=xLa/QeQNShWFOzFP7uriCsF9h6Vx3/9DwBaMCGFvdSY=; b=i30K8439ikFI9v50erBJREiR3iUD5bveYewszoNMyUYGHg69/Kmui5+cOD8CD0ABLx UF4r75KFSFdpNplEJeRlvkrUY4048Fd9ae0JDWwAT4wnWeyWuoGNV5bQMqTHk7VYFj5T a11x0kh4cuYc3FRZ5siI9CEtY9Avrsk8bSJ8h2tFyPxP4mr+82J1h5xxGZFCkX8tGNoX ZK+wui2/dE/uQmf7MRi5orDcdXWrk9JjQ+DX8V39YYHGlkeCB6ZOe6v1sGHSlum2S5Cb xnOwQ7u50wpt+6kQTEtLsa3rUjQruvT94gIz8V99YYU7NlKMX7Tpt0V76vYF+q8ozK+t 6yqg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=HPYVs4AP; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f62-v6si2023257pfb.218.2018.09.27.06.18.02; Thu, 27 Sep 2018 06:18:20 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=HPYVs4AP; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727745AbeI0Tf1 (ORCPT + 99 others); Thu, 27 Sep 2018 15:35:27 -0400 Received: from mail-oi1-f194.google.com ([209.85.167.194]:46402 "EHLO mail-oi1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727199AbeI0Tf1 (ORCPT ); Thu, 27 Sep 2018 15:35:27 -0400 Received: by mail-oi1-f194.google.com with SMTP id k64-v6so2054617oia.13 for ; Thu, 27 Sep 2018 06:17:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=xLa/QeQNShWFOzFP7uriCsF9h6Vx3/9DwBaMCGFvdSY=; b=HPYVs4APb+PNX1CW2IWkNDGP/gvlfNdQ2Zr8cRSCUcO6/pWxiyWyNqlVLo4R9BmnxD 4a1GUBEO9k0F41uEsQCHCYcXKFHXd4bba84h0Vfwa3nKXLY+imVDE7ZwiaTdX6k2+h/q awoxI/l0PpEvSpLXmAZyyIoqcClO5316eOFNs= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=xLa/QeQNShWFOzFP7uriCsF9h6Vx3/9DwBaMCGFvdSY=; b=qQGR4p01B0QkReZbg8bz/lZ0keBEM7+00LpsivfXYMVtl1YgZx7w7bKd0UBG8nAguv N9kp/NJrhXcgsngBn1OUpJxeNDthTMwZRHjVYzFR4S7/LTiM+QJqE7kSZfyWbKexGCTo nmMderWFx4Hf+HxosTXRMkeI8KtKaJi8h19UkgDNbFwNHdSL73dvFcybOqErLEKkPz6N GuKHU90SGvc0U6bnuRzDmKdKz0F+LYvh3CztKI9beJSc9P900+I6GL1HEQXnUKFm1LeR XVwx+u1cWc7j6772W12a9HQuPPxqr4/aRtoqjuLlaLlFr6KoTVa3hjyBbkPQ1AksjvAi DEPA== X-Gm-Message-State: ABuFfoi0Gd5qJRb2fwuSb6hNRg6eiFeqXkYbZc+7OjOM0fjEQGnH2Bb7 kuADnJE2hArv5/GsZrnM4hKlZys4AF7WeNUG1KgWUQ== X-Received: by 2002:aca:601:: with SMTP id 1-v6mr3326464oig.358.1538054232742; Thu, 27 Sep 2018 06:17:12 -0700 (PDT) MIME-Version: 1.0 References: <7441c31c-7427-da4e-c877-6d58b5bd869f@st.com> In-Reply-To: From: Benjamin Gaignard Date: Thu, 27 Sep 2018 15:17:01 +0200 Message-ID: Subject: Re: [PATCH] drm: stm: implement get_scanout_position function To: Yannick Fertre Cc: Philippe Cornu , Benjamin GAIGNARD , David Airlie , Linux Kernel Mailing List , ML dri-devel Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Le jeu. 27 sept. 2018 =C3=A0 13:32, Yannick FERTRE = a =C3=A9crit : > > Reviewed-by: Yannick Fertr=C3=A9 > Tested-by: Yannick Fertr=C3=A9 Applied on drm-misc-next, Thanks, Benjamin > > On 09/27/2018 10:15 AM, Yannick FERTRE wrote: > > Reviewed-by/tested-by: yannick.fertre@st.com > > > > -------- Forwarded Message -------- > > Subject: [PATCH] drm: stm: implement get_scanout_position function > > Date: Fri, 29 Jun 2018 15:01:40 +0200 > > From: Benjamin Gaignard > > To: yannick.fertre@st.com, philippe.cornu@st.com, airlied@linux.ie > > CC: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, > > Benjamin Gaignard , Benjamin Gaignard > > > > > > Hardware allow to read the position in scanout buffer so > > we can use this information to make wait of vblank more accurate. > > > > Active area bounds (start, end, total height) have already been > > computed and written in ltdc registers, read them and get the > > current line position to compute vpos value. > > > > Signed-off-by: Benjamin Gaignard > > --- > > drivers/gpu/drm/stm/drv.c | 2 ++ > > drivers/gpu/drm/stm/ltdc.c | 45 > > +++++++++++++++++++++++++++++++++++++++++++++ > > drivers/gpu/drm/stm/ltdc.h | 5 +++++ > > 3 files changed, 52 insertions(+) > > > > diff --git a/drivers/gpu/drm/stm/drv.c b/drivers/gpu/drm/stm/drv.c > > index 8698e08313e1..ac53383350e3 100644 > > --- a/drivers/gpu/drm/stm/drv.c > > +++ b/drivers/gpu/drm/stm/drv.c > > @@ -72,6 +72,8 @@ static struct drm_driver drv_driver =3D { > > .gem_prime_vmap =3D drm_gem_cma_prime_vmap, > > .gem_prime_vunmap =3D drm_gem_cma_prime_vunmap, > > .gem_prime_mmap =3D drm_gem_cma_prime_mmap, > > + .get_scanout_position =3D ltdc_crtc_scanoutpos, > > + .get_vblank_timestamp =3D drm_calc_vbltimestamp_from_scanoutpos, > > }; > > static int drv_load(struct drm_device *ddev) > > diff --git a/drivers/gpu/drm/stm/ltdc.c b/drivers/gpu/drm/stm/ltdc.c > > index d997a6014d6c..05b714673042 100644 > > --- a/drivers/gpu/drm/stm/ltdc.c > > +++ b/drivers/gpu/drm/stm/ltdc.c > > @@ -148,6 +148,8 @@ > > #define IER_TERRIE BIT(2) /* Transfer ERRor Interrupt > > Enable */ > > #define IER_RRIE BIT(3) /* Register Reload Interrupt > > enable */ > > +#define CPSR_CYPOS GENMASK(15, 0) /* Current Y position */ > > + > > #define ISR_LIF BIT(0) /* Line Interrupt Flag */ > > #define ISR_FUIF BIT(1) /* Fifo Underrun Interrupt Flag */ > > #define ISR_TERRIF BIT(2) /* Transfer ERRor Interrupt Flag = */ > > @@ -622,6 +624,49 @@ static void ltdc_crtc_disable_vblank(struct > > drm_crtc *crtc) > > reg_clear(ldev->regs, LTDC_IER, IER_LIE); > > } > > +bool ltdc_crtc_scanoutpos(struct drm_device *ddev, unsigned int pipe= , > > + bool in_vblank_irq, int *vpos, int *hpos, > > + ktime_t *stime, ktime_t *etime, > > + const struct drm_display_mode *mode) > > +{ > > + struct ltdc_device *ldev =3D ddev->dev_private; > > + int line, vactive_start, vactive_end, vtotal; > > + > > + if (stime) > > + *stime =3D ktime_get(); > > + > > + /* The active area starts after vsync + front porch and ends > > + * at vsync + front porc + display size. > > + * The total height also include back porch. > > + * We have 3 possible cases to handle: > > + * - line < vactive_start: vpos =3D line - vactive_start and will = be > > + * negative > > + * - vactive_start < line < vactive_end: vpos =3D line - vactive_s= tart > > + * and will be positive > > + * - line > vactive_end: vpos =3D line - vtotal - vactive_start > > + * and will negative > > + * > > + * Computation for the two first cases are identical so we can > > + * simplify the code and only test if line > vactive_end > > + */ > > + line =3D reg_read(ldev->regs, LTDC_CPSR) & CPSR_CYPOS; > > + vactive_start =3D reg_read(ldev->regs, LTDC_BPCR) & BPCR_AVBP; > > + vactive_end =3D reg_read(ldev->regs, LTDC_AWCR) & AWCR_AAH; > > + vtotal =3D reg_read(ldev->regs, LTDC_TWCR) & TWCR_TOTALH; > > + > > + if (line > vactive_end) > > + *vpos =3D line - vtotal - vactive_start; > > + else > > + *vpos =3D line - vactive_start; > > + > > + *hpos =3D 0; > > + > > + if (etime) > > + *etime =3D ktime_get(); > > + > > + return true; > > +} > > + > > static const struct drm_crtc_funcs ltdc_crtc_funcs =3D { > > .destroy =3D drm_crtc_cleanup, > > .set_config =3D drm_atomic_helper_set_config, > > diff --git a/drivers/gpu/drm/stm/ltdc.h b/drivers/gpu/drm/stm/ltdc.h > > index 1e16d6afb0d2..b8c5cc41e17a 100644 > > --- a/drivers/gpu/drm/stm/ltdc.h > > +++ b/drivers/gpu/drm/stm/ltdc.h > > @@ -37,6 +37,11 @@ struct ltdc_device { > > struct fps_info plane_fpsi[LTDC_MAX_LAYER]; > > }; > > +bool ltdc_crtc_scanoutpos(struct drm_device *dev, unsigned int pipe, > > + bool in_vblank_irq, int *vpos, int *hpos, > > + ktime_t *stime, ktime_t *etime, > > + const struct drm_display_mode *mode); > > + > > int ltdc_load(struct drm_device *ddev); > > void ltdc_unload(struct drm_device *ddev); > > -- 2.15.0 > > > > -- > Yannick Fertr=C3=A9 | TINA: 166 7152 | Tel: +33 244027152 | Mobile: +33 6= 20600270 > Microcontrollers and Digital ICs Group | Microcontrolleurs Division > _______________________________________________ > dri-devel mailing list > dri-devel@lists.freedesktop.org > https://lists.freedesktop.org/mailman/listinfo/dri-devel