Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp2610313imu; Mon, 19 Nov 2018 03:23:47 -0800 (PST) X-Google-Smtp-Source: AJdET5c/urw/QyZvMfRM5KhUyi/WHySFFuOHPxK9I82Q8UP9nHRYsQhObiq/oTJFCFWjitNnOyzO X-Received: by 2002:a17:902:8214:: with SMTP id x20-v6mr21149541pln.224.1542626627781; Mon, 19 Nov 2018 03:23:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542626627; cv=none; d=google.com; s=arc-20160816; b=xVCwMQvTFsWvtVwSeC5eyp17DwDzxjHov05+n/QYNPssT3RatgLbBlHDHs7TDzLOKC FppecnFJrbBontKaokk8yVlEjIiqM42r1GJgP7nV62fAGTbQgVjOzhR0cc0oFrM9psxU z+0+X/qcq5rV5TTW+gBskNQ14ThmKLlal1xNHaIHRMn/MA4Kqj7AKPWERvl8Qx6lAcGO X6pr1gidL4G4oR2JQhsgr5UxZqJcGnw9O/7J4nmJyBEIzHIH5uHnORu0B/9yicR+Y4u4 yNnHl78hO4Kb9l39WKIeD9/AHETCb7II0UoOKsYWr+GutTXW4HhDWiMU6GJb75KU9dW+ w7VQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=3TA0tjnvEntm7WKuCiOxyeEgF0BAR0FEyPhya5grE5w=; b=QU3fSkOXLFbPP8Efy9Q3tEJhU1Cto0NpWzyOAwD64FrggETAca8+rqmRqDspJCTPWg GG/EVeZq7W+9BfH4PmS07J44+p5uor2ce+aJL5dZaeQ+poWxUx4Aa9UqYLSMS9M/k59u AK+Y63QHaiiX+NdrtJ+9Geq6g0hj7ljlp20n26BaBH0iGThtaaGs1ex2faIX9lApjzhB ph/H/+6gp6Km3y1v1fzhuMhRumdH51Uq2Z8npTYZAWZF3TLkvHjtBX3Na1m402FcwDzR WZF9xMgZbGQBbgc9sDMJD3DuSlBcXF8WZqfjMcuGF3IC1hvb+mg233E4YOyr5gHIEl2O 2Qdw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=fGVj0V8u; 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 b6si6266884pgd.292.2018.11.19.03.23.33; Mon, 19 Nov 2018 03:23:47 -0800 (PST) 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=@amarulasolutions.com header.s=google header.b=fGVj0V8u; 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 S1728696AbeKSVpt (ORCPT + 99 others); Mon, 19 Nov 2018 16:45:49 -0500 Received: from mail-it1-f194.google.com ([209.85.166.194]:38240 "EHLO mail-it1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727857AbeKSVpt (ORCPT ); Mon, 19 Nov 2018 16:45:49 -0500 Received: by mail-it1-f194.google.com with SMTP id h65so3602206ith.3 for ; Mon, 19 Nov 2018 03:22:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amarulasolutions.com; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=3TA0tjnvEntm7WKuCiOxyeEgF0BAR0FEyPhya5grE5w=; b=fGVj0V8ulBIbtr8rVm8gCTyB62WBAwEqDm90S1LZzZ/l0LeLmakRwQtfq4Iph4wecR O2Mgc4rSkCyoNvgt0nKcPbGZsu49vmrylyt6Ky4JeomKD4Bq8Nr+OcKNIYI4zMvExQNy RTRU2YziouEHsUHTZpqJkRy/UVXNZb6q71uAA= 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; bh=3TA0tjnvEntm7WKuCiOxyeEgF0BAR0FEyPhya5grE5w=; b=I28f0RvF6H7vDFfPLgAEU2TmpGJVMypy2iDULHyftkgoRJHxp5b3ewGwR8Zm6zhEZW OHVpFmR+lI6K+QvmVNtLP3NDZ+0hRUMmBS+Z80LFFI8YbW0FSdfUDaFUYerxd18npjyG 8ZvNFMP3kCfVepQRUdaIlyKw2KnMmof5Bk0baU3TUVNn8ZGvyNiQ4DICZaqaLY8G2IAr Xt4kMFeF6rdaNixVx/8dok7wNOYmjOhbwUvreQlmjZpLk+gN2kOll5zFcaQnEdw9NaHR JUXTzFke1c7VYkPpVdOPFI/ZWA25MtKM3n70kK3cQdjhm81DFC1vjV+p08BMaycXAwle PKjg== X-Gm-Message-State: AA+aEWaQK2wf+pjNEYKePkq3JJdfqwkcENPzNXC0SybWq1ZO/I69v4Rd 9wi9fKOPrXliWY8wP0HBQETwMFiQYfGEpd1UDnfcIw== X-Received: by 2002:a24:2710:: with SMTP id g16-v6mr510905ita.107.1542626549241; Mon, 19 Nov 2018 03:22:29 -0800 (PST) MIME-Version: 1.0 References: <20181116163916.29621-1-jagan@amarulasolutions.com> <20181116163916.29621-5-jagan@amarulasolutions.com> <20181119083243.4njj2p2sy2xf2zyf@flea> In-Reply-To: <20181119083243.4njj2p2sy2xf2zyf@flea> From: Jagan Teki Date: Mon, 19 Nov 2018 16:52:17 +0530 Message-ID: Subject: Re: [PATCH v2 04/12] drm/sun4i: sun6i_mipi_dsi: Simplify drq set to support all modes To: Maxime Ripard Cc: Maarten Lankhorst , Sean Paul , David Airlie , Rob Herring , Chen-Yu Tsai , Icenowy Zheng , Jernej Skrabec , Vasily Khoruzhick , Thierry Reding , Mark Rutland , dri-devel , devicetree , linux-kernel , linux-arm-kernel , Michael Trimarchi , TL Lim , linux-sunxi@googlegroups.com, linux-amarula@amarulasolutions.com Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Nov 19, 2018 at 2:02 PM Maxime Ripard wrote: > > On Fri, Nov 16, 2018 at 10:09:08PM +0530, Jagan Teki wrote: > > Allwinner MIPI DSI DRQ set value can be varied with respective > > video modes. > > - burst mode the set value is always 0 > > - video modes whose front porch greater than 20, the set value > > can be computed based front porch and bpp. > > - video modes whose front porch is not greater than 20, the set value > > is simply 0 > > > > This patch simplifies existing drq set value code by grouping > > into sun6i_dsi_get_drq and support all video modes. > > > > Signed-off-by: Jagan Teki > > --- > > drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c | 38 ++++++++++++++++---------- > > 1 file changed, 23 insertions(+), 15 deletions(-) > > > > diff --git a/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c b/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c > > index efd08bfd0cb8..d60955880c43 100644 > > --- a/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c > > +++ b/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c > > @@ -363,6 +363,26 @@ static void sun6i_dsi_inst_init(struct sun6i_dsi *dsi, > > SUN6I_DSI_INST_JUMP_CFG_NUM(1)); > > }; > > > > +static int sun6i_dsi_get_drq(struct sun6i_dsi *dsi, > > + struct drm_display_mode *mode) > > +{ > > + struct mipi_dsi_device *device = dsi->device; > > + int drq = 0; > > So, here, you declaring a variable called drq, set to 0. > > > + if (device->mode_flags & MIPI_DSI_MODE_VIDEO_BURST) > > + return drq; > > That you return here. You could just return 0, to be clearer. > > > + if ((mode->hsync_start - mode->hdisplay) > 20) { > > + /* Maaaaaagic */ > > + u16 drq = (mode->hsync_start - mode->hdisplay) - 20; > > You re-declare a variable with the same name here, but a different > type.... > > > + drq *= mipi_dsi_pixel_format_to_bpp(device->format); > > + drq /= 32; > > + } > > + > > + return drq; > > And then return the first one? How is that even working? Will fix this. > > > + > > static u16 sun6i_dsi_get_timings_vblk(struct sun6i_dsi *dsi, > > struct drm_display_mode *mode, u16 hblk) > > { > > @@ -478,21 +498,9 @@ static u16 sun6i_dsi_get_video_start_delay(struct sun6i_dsi *dsi, > > static void sun6i_dsi_setup_burst(struct sun6i_dsi *dsi, > > struct drm_display_mode *mode) > > { > > - struct mipi_dsi_device *device = dsi->device; > > - u32 val = 0; > > - > > - if ((mode->hsync_start - mode->hdisplay) > 20) { > > - /* Maaaaaagic */ > > - u16 drq = (mode->hsync_start - mode->hdisplay) - 20; > > - > > - drq *= mipi_dsi_pixel_format_to_bpp(device->format); > > - drq /= 32; > > - > > - val = (SUN6I_DSI_TCON_DRQ_ENABLE_MODE | > > - SUN6I_DSI_TCON_DRQ_SET(drq)); > > - } > > - > > - regmap_write(dsi->regs, SUN6I_DSI_TCON_DRQ_REG, val); > > + regmap_write(dsi->regs, SUN6I_DSI_TCON_DRQ_REG, > > + SUN6I_DSI_TCON_DRQ_ENABLE_MODE | > > + SUN6I_DSI_TCON_DRQ_SET(sun6i_dsi_get_drq(dsi, mode))); > > On top of that, you now enable the DRQ stuff all the time, while it Earlier the val value is ENABLE_MODE ORed with drq value. for the condition drq is computed in if block otherwise the val is 0. So as I explained in commit message the drq value is 0 - for video modes whose front porch is not greater than 20 and - for burst mode the val ie reason I mode it common.