Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp1905785imm; Thu, 27 Sep 2018 04:32:41 -0700 (PDT) X-Google-Smtp-Source: ACcGV6010n5x4t3447Jc6T2+xeOntrnk77OzXfFgeKe4fzrRZq90poN5NTM7YO0d5T8MtHFuWSTQ X-Received: by 2002:a65:4849:: with SMTP id i9-v6mr9651371pgs.350.1538047961102; Thu, 27 Sep 2018 04:32:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538047961; cv=none; d=google.com; s=arc-20160816; b=HpY/runmw4L+rPeaU5CFuLOnSRfmaiEThPx5ZU2UQbVBFEbmcqy04ipuZFs0SzihDH yabo2XdEQASpgPf+yWl5iFukHPpS+O7ewxcxSnI6T6PA6CYVvEYzFcGjHqvjg9sf9WK9 5vHDmJWlQX208S/gle6mKHq13w4IOKooiROzSRKMU6V20N/2FPMsdUjdFKPWqOYMixCd eo1DGH32cujWoZ75rk+L2m0zcTqjmZ7oCpIzCo0atlWlUrb5jGae79fDe41YBEC9P1t2 m8N/aHMExte/LT/QzVYEM7E9YPWjySZjbN0d0tVSGjmaMOOXfqRHuPJ/p0Cgw/2rtBrM vPug== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :content-id:user-agent:content-language:accept-language:in-reply-to :references:message-id:date:thread-index:thread-topic:subject:cc:to :from; bh=HG11c7nhUNT9z5w0M/Gx62RjJuBDK44456MSLuCTSlU=; b=rko84CkbAwYWRztcDnJ+IagLsHWR6PWmlMGO7B2ISpmtNIRaUr9pyWGW4iyql1lP6Z LJejCTynMWdcF8NhwW5dMAvhqv4JfLpm5h8FB1q3E2hSjD5xst03zl4I5u0mjPAd0eUN AWvWlBMP7GqK1o8jx8PrAPdFfdvB636DO6zI4TARlbvi8Pd4DY3OQIysfPHH07jV6mqi 9J+DVnF/t8sc0e7329fs0DgmVRTfcDqIx1h2UUvQKTAPvO1k7aJ7Q68MJ9Kc82D1Nze4 O++T/prIcneqdp1557KorChireI5wriVVMPJM1QGpx07knohp+MYgulbNc4/rLB+ygnU PAtQ== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t21-v6si1717169ply.478.2018.09.27.04.32.25; Thu, 27 Sep 2018 04:32:41 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727295AbeI0Rt4 convert rfc822-to-8bit (ORCPT + 99 others); Thu, 27 Sep 2018 13:49:56 -0400 Received: from mx08-00178001.pphosted.com ([91.207.212.93]:58415 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727171AbeI0Rt4 (ORCPT ); Thu, 27 Sep 2018 13:49:56 -0400 Received: from pps.filterd (m0046661.ppops.net [127.0.0.1]) by mx08-.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id w8RBO9D2025250; Thu, 27 Sep 2018 13:32:01 +0200 Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx08-00178001.pphosted.com with ESMTP id 2mncmep1jb-1 (version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NOT); Thu, 27 Sep 2018 13:32:01 +0200 Received: from zeta.dmz-eu.st.com (zeta.dmz-eu.st.com [164.129.230.9]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id DB81831; Thu, 27 Sep 2018 11:32:00 +0000 (GMT) Received: from Webmail-eu.st.com (sfhdag6node3.st.com [10.75.127.18]) by zeta.dmz-eu.st.com (STMicroelectronics) with ESMTP id B456C294E; Thu, 27 Sep 2018 11:32:00 +0000 (GMT) Received: from SFHDAG6NODE1.st.com (10.75.127.16) by SFHDAG6NODE3.st.com (10.75.127.18) with Microsoft SMTP Server (TLS) id 15.0.1347.2; Thu, 27 Sep 2018 13:32:00 +0200 Received: from SFHDAG6NODE1.st.com ([fe80::8d96:4406:44e3:eb27]) by SFHDAG6NODE1.st.com ([fe80::8d96:4406:44e3:eb27%20]) with mapi id 15.00.1347.000; Thu, 27 Sep 2018 13:32:00 +0200 From: Yannick FERTRE To: Philippe CORNU , Benjamin GAIGNARD , "airlied@linux.ie" CC: "dri-devel@lists.freedesktop.org" , "linux-kernel@vger.kernel.org" Subject: Re: [PATCH] drm: stm: implement get_scanout_position function Thread-Topic: [PATCH] drm: stm: implement get_scanout_position function Thread-Index: AQHUD6lh/FtQB5XoQ0G3N1zp/AXzb6R9OioAgIb5igCAADbZgA== Date: Thu, 27 Sep 2018 11:32:00 +0000 Message-ID: References: <7441c31c-7427-da4e-c877-6d58b5bd869f@st.com> In-Reply-To: Accept-Language: fr-FR, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: user-agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 x-ms-exchange-messagesentrepresentingtype: 1 x-ms-exchange-transport-fromentityheader: Hosted x-originating-ip: [10.75.127.48] Content-Type: text/plain; charset="Windows-1252" Content-ID: <8DDFC31A9EA01D4492CE076675B2CD8D@st.com> Content-Transfer-Encoding: 8BIT MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2018-09-27_06:,, signatures=0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Reviewed-by: Yannick Fertr? Tested-by: Yannick Fertr? 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 = { > ????? .gem_prime_vmap = drm_gem_cma_prime_vmap, > ????? .gem_prime_vunmap = drm_gem_cma_prime_vunmap, > ????? .gem_prime_mmap = drm_gem_cma_prime_mmap, > +??? .get_scanout_position = ltdc_crtc_scanoutpos, > +??? .get_vblank_timestamp = 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 = ddev->dev_private; > +??? int line, vactive_start, vactive_end, vtotal; > + > +??? if (stime) > +??????? *stime = 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 = line - vactive_start and will be > +???? * negative > +???? * - vactive_start < line < vactive_end: vpos = line - vactive_start > +???? * and will be positive > +???? * - line > vactive_end: vpos = 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 = reg_read(ldev->regs, LTDC_CPSR) & CPSR_CYPOS; > +??? vactive_start = reg_read(ldev->regs, LTDC_BPCR) & BPCR_AVBP; > +??? vactive_end = reg_read(ldev->regs, LTDC_AWCR) & AWCR_AAH; > +??? vtotal = reg_read(ldev->regs, LTDC_TWCR) & TWCR_TOTALH; > + > +??? if (line > vactive_end) > +??????? *vpos = line - vtotal - vactive_start; > +??? else > +??????? *vpos = line - vactive_start; > + > +??? *hpos = 0; > + > +??? if (etime) > +??????? *etime = ktime_get(); > + > +??? return true; > +} > + > ? static const struct drm_crtc_funcs ltdc_crtc_funcs = { > ????? .destroy = drm_crtc_cleanup, > ????? .set_config = 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? | TINA: 166 7152 | Tel: +33 244027152 | Mobile: +33 620600270 Microcontrollers and Digital ICs Group | Microcontrolleurs Division