From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.0 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_SANE_2 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1E2D1C433DB for ; Sat, 30 Jan 2021 11:29:15 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id CE41E64E0B for ; Sat, 30 Jan 2021 11:29:14 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org CE41E64E0B Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 2BEC26ECA8; Sat, 30 Jan 2021 11:29:10 +0000 (UTC) Received: from mail-pl1-x62c.google.com (mail-pl1-x62c.google.com [IPv6:2607:f8b0:4864:20::62c]) by gabe.freedesktop.org (Postfix) with ESMTPS id C56326EC87 for ; Sat, 30 Jan 2021 06:39:31 +0000 (UTC) Received: by mail-pl1-x62c.google.com with SMTP id u11so6648602plg.13 for ; Fri, 29 Jan 2021 22:39:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:in-reply-to:references :organization:mime-version:content-transfer-encoding; bh=TANixHB1VghGJvUItmZRy+uLix9/H4aSqcnAzrKjFBE=; b=T4CRyO1szRQ0/ybotrnrWq6fV5wBmc5Oa0bouNJ6DA8t+KkTh452zOK4hqN+tAKE+g SgECaofNxz3i//yrAFtiQo7qdPEPHRSRJsK0fwSSiGscDYxZ/sDIISz3mHuSjpf0eDdY mjay+t0F2sxzBCOwXFC1bg+vTJ90c/TOL/j/ZSPYpv5fZtKz0Np3FfgdjXVFQS4QAJmb RlBvbTOjNm3jd8pYvJYdACiSRg0BRtQ9muhClDFdcfKmfT78vxyY/rRVd+OjCctD9dTP AT9J9LC6AOr7OSFl0jPhhLHXOhS5kvAV7mahZfnCcKZbV/u8d+XIe99uvtSIx4mazpO/ Ydug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:in-reply-to :references:organization:mime-version:content-transfer-encoding; bh=TANixHB1VghGJvUItmZRy+uLix9/H4aSqcnAzrKjFBE=; b=nMTLICHF1zMoPZetK5Fyz+bVuRWzoPuNxerMB9hHOSqMiUHWaE9rz7Vf1jIiCuA9oE xv+HAqDXjfI+dikd7GuKTel66Pgp9QrrvunwrbkdYmiqD+2j3UYpjDdR5Vjegg02Lmmt 2x/PmWebLwFhbqYYK5wMiQ16Y4tYrGDPDPRGmv+llYrbtJSU2aE2Lon3OdWotxw0YxzM P/2Qq6uo1/r/UaaMWjLqWJfLd7I+dIbWmBxcRCW+j8vZkl0pyga2n+h4WkdDTedV5eZs gHPDqhiHTgQOpMRUi+jICn9bbrJTjvKV7hBgEBtywrNfYHH8sqtRC/Rxi2ok7qpYmngv RoJQ== X-Gm-Message-State: AOAM530E3A2/LyxZvttJylcGBMLTi5XhOMUs8jvFbAXhchOcW26i3vW0 zDsDq/pbLWnb+ZEDg9mG3I0= X-Google-Smtp-Source: ABdhPJznlhJCt2LNVfTUGyGHmkAifzTWGztAOXlfqCmGbmi3wonXDaAJr5lCg8Q1B9X5uB6Z8XvqGQ== X-Received: by 2002:a17:903:2306:b029:de:18e9:f439 with SMTP id d6-20020a1709032306b02900de18e9f439mr8089143plh.38.1611988771137; Fri, 29 Jan 2021 22:39:31 -0800 (PST) Received: from localhost ([103.220.76.197]) by smtp.gmail.com with ESMTPSA id j14sm9083885pjl.35.2021.01.29.22.39.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Jan 2021 22:39:30 -0800 (PST) Date: Sat, 30 Jan 2021 14:39:24 +0800 From: carlis To: Andy Shevchenko Subject: Re: [PATCH v12] staging: fbtft: add tearing signal detect Message-ID: <20210130143924.00005432@gmail.com> In-Reply-To: References: <1611838435-151774-1-git-send-email-zhangxuezhi3@gmail.com> <20210129130110.00003bb1@gmail.com> <20210129215638.000047b0@gmail.com> Organization: Tyzmig-ryrjum-8kedto X-Mailer: Claws Mail 3.17.4 (GTK+ 2.24.32; i686-w64-mingw32) MIME-Version: 1.0 X-Mailman-Approved-At: Sat, 30 Jan 2021 11:28:30 +0000 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "open list:STAGING SUBSYSTEM" , "open list:FRAMEBUFFER LAYER" , Deepak R Varma , Greg Kroah-Hartman , oliver.graute@kococonnector.com, Linux Kernel Mailing List , dri-devel , Stefano Brivio , Colin King , zhangxuezhi1@yulong.com Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" On Fri, 29 Jan 2021 16:26:12 +0200 Andy Shevchenko wrote: > On Fri, Jan 29, 2021 at 3:56 PM carlis wrote: > > On Fri, 29 Jan 2021 12:23:08 +0200 > > Andy Shevchenko wrote: > > We are almost there, I have no idea what Noralf or others are going to > say though. > > ... > > > Hi, I apologize for what I said in the previous two emails. I missed > > one email you sent before, and now I probably understand what you > > meant. Here is a version I modified according to your suggestion: > > > > From 399e7fb91d1dcba4924cd38cc8283393c80b97e4 Mon Sep 17 00:00:00 > > 2001 From: Carlis > > Date: Sun, 24 Jan 2021 22:43:21 +0800 > > Subject: [PATCH v13] staging: fbtft: add tearing signal detect > > > > For st7789v IC,when we need continuous full screen refresh, it is > > best > > Missed space after comma. > > > to wait for the tearing effect line signal arrive to avoid screen > > to arrive > > > tearing. > > ... > > > +#define PANEL_TE_TIMEOUT_MS 34 /* 60Hz for 16.6ms, configured as > > 2*16.6ms */ + > > Move comment before the definition > /* comment */ > #define DEFINITION > > Also consider to use 33 ms as closest to what you mentioned in the > comment. Or leave it with mention that you are using ceil() value. > > ... > > > +/** > > + * init_tearing_effect_line() - init tearing effect line > > > + * > > As per a few previous reviews. > Okay, I have noticed that the existing kernel-doc is written like > this, but it doesn't prevent you from avoiding this little mistake. > > > + * @par: FBTFT parameter object > > + * > > + * Return: 0 on success, or a negative error code otherwise. > > + */ > > +static int init_tearing_effect_line(struct fbtft_par *par) > > +{ > > + struct device *dev = par->info->device; > > + struct gpio_desc *te; > > + int rc; > > + > > + te = gpiod_get_optional(dev, "te", GPIOD_IN); > > + if (IS_ERR(te)) > > + return dev_err_probe(dev, PTR_ERR(te), "Failed to > > request te GPIO\n"); + > > Below is okay, but needs a comment explaining why we return a success. > > > + if (!te) > > + return 0; > > + > > + par->irq_te = gpiod_to_irq(te); > > + > > + /* GPIO is locked as an IRQ, we may drop the reference */ > > + gpiod_put(te); > > + > > + if (par->irq_te < 0) > > + return par->irq_te; > > I recommend using a temporary variable. In such a case you won't need > to specifically check for negative error code. So, something like > > int irq; > > irq = ... > > if (irq < 0) > return irq; > > ->irq_te = irq; > > > + init_completion(&par->panel_te); > > + rc = devm_request_irq(dev, par->irq_te, panel_te_handler, > > + IRQF_TRIGGER_RISING, "TE_GPIO", par); > > > > Right. Now it needs a comment explaining the choice of rising edge > type of IRQ. > > > + if (rc) > > + return dev_err_probe(dev, rc, "TE IRQ request > > failed.\n"); + > > + disable_irq_nosync(par->irq_te); > > + > > + return 0; > > +} > > ... > > > + rc = init_tearing_effect_line(par); > > > + if (rc < 0) > > Here is no need to specifically check against less than 0, > if (ret) > will work nicely. > > > + return rc; > > ... > > > + if (par->irq_te) > > + write_reg(par, MIPI_DCS_SET_TEAR_ON, 0x00); > > Do you need to call MIPI_DCS_SET_TEAR_SCANLINE in this case? > Hi, TE line output is off by default when powering on, and I use Qualcomm SDX55 chip, SPI top speed is only 50MHz, its data transmission speed( It takes about 24ms to transmit a frame) is slower than 60Hz refresh(a frame only need 16.6ms), so i think there is no need to call MIPI_DCS_SET_TEAR_SCANLINE > Alos, when there is no IRQ, shouldn't we explicitly call > write_reg(par, MIPI_DCS_SET_TEAR_OFF); > ? > > ... > > > /** > > + * st7789v_write_vmem16_bus8() - write data to display > > > + * > > Redundant. > > > + * @par: FBTFT parameter object > > + * @offset: offset from screen_buffer > > + * @len: the length of data to be written > > + * > > > + * 16 bit pixel over 8-bit databus > > Write 16-bit pixels over 8-bit data bus. > > > + * Return: 0 on success, or a negative error code otherwise. > > + */ > > ... > > > + if (par->irq_te) { > > + enable_irq(par->irq_te); > > + reinit_completion(&par->panel_te); > > + ret = wait_for_completion_timeout(&par->panel_te, > > + > > msecs_to_jiffies(PANEL_TE_TIMEOUT_MS)); > > + if (ret == 0) > > + dev_err(dev, "wait panel TE time out\n"); > > timeout > > > + > > + disable_irq(par->irq_te); > > + } > > ... > > > + * @panel_te: completion for panel te line > > TE line > > > + * @irq_te: LCD Chip tearing effect line > > "Linux IRQ for LCD..." > hi, i modify new below: >From b65fc2bfbe123defc8ec838601a9c12707f70c53 Mon Sep 17 00:00:00 2001 From: Carlis Date: Sun, 24 Jan 2021 22:43:21 +0800 Subject: [PATCH v13] staging: fbtft: add tearing signal detect For st7789v IC, when we need continuous full screen refresh, it is best to wait for the tearing effect line signal to arrive to avoid screen tearing. Signed-off-by: Carlis --- v13: change TE completion to par data struct member and add a new function to deal te gpio request, move wait logic to fbtft_write_vmem16_bus8. v12: change dev_err to dev_err_probe and add space in comments start, and delete te_mutex, change te wait logic. v11: remove devm_gpio_put and change a dev_err to dev_info. v10: additional notes. v9: change pr_* to dev_*. v8: delete a log line. v7: return error value when request fail. v6: add te gpio request fail deal logic. v5: fix log print. v4: modify some code style and change te irq set function name. v3: modify author and signed-off-by name. v2: add release te gpio after irq request fail. --- drivers/staging/fbtft/fb_st7789v.c | 64 ++++++++++++++++++++++++++++++++++++++ drivers/staging/fbtft/fbtft-bus.c | 20 ++++++++++-- drivers/staging/fbtft/fbtft.h | 5 +++ 3 files changed, 87 insertions(+), 2 deletions(-) diff --git a/drivers/staging/fbtft/fb_st7789v.c b/drivers/staging/fbtft/fb_st7789v.c index 3a280cc..695dcac 100644 --- a/drivers/staging/fbtft/fb_st7789v.c +++ b/drivers/staging/fbtft/fb_st7789v.c @@ -7,9 +7,13 @@ #include #include +#include #include #include +#include +#include #include + #include