From patchwork Fri Nov 16 16:39:08 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jagan Teki X-Patchwork-Id: 10687511 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E003D14E2 for ; Sat, 17 Nov 2018 14:57:05 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CFC6A2B902 for ; Sat, 17 Nov 2018 14:57:05 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C41A42B905; Sat, 17 Nov 2018 14:57:05 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 776B52B902 for ; Sat, 17 Nov 2018 14:57:05 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 3FC296E972; Sat, 17 Nov 2018 14:56:31 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-pf1-x441.google.com (mail-pf1-x441.google.com [IPv6:2607:f8b0:4864:20::441]) by gabe.freedesktop.org (Postfix) with ESMTPS id 2A31E6E7CC for ; Fri, 16 Nov 2018 16:40:08 +0000 (UTC) Received: by mail-pf1-x441.google.com with SMTP id v68-v6so11665893pfk.0 for ; Fri, 16 Nov 2018 08:40:08 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=YBsrf76ZM/i+rqqgf+m+LE5qjwwWDpXcodR4cqVxPuQ=; b=HRAuPa8wO5mkliXP0mwIdvdEH9xrexT1q5OFzGFbXypbC3vUpNoznscLxT643XmQnL XlTWFexQ4kmXjjlOMDG/zxFuUDFJxpxxKGZkA8J9Ddrbwdn63UWcAYGFFaQapJAh/OPl SHFep6YcL4EySmqcLZ+KQRanMUlk/FSKyYYir1hxDwWCEAywpADrQZWPDuU21FxLiTB/ 57tN2rzc2J5PEAqL9oRna65J3Bh71X3NdfmX9FmrljBaB8LNpvr/41nH0xKaD/aKxxq6 3dw1KbhRIF68Q6XSeO/qPw/0BSqdEIjjZpTLR6LbyhD6j8yHcd4xYUJJkzex9qFq/99T qRTQ== X-Gm-Message-State: AGRZ1gLZTwjnimdcYT5qbBK8k2W9FTqGUU3TxP5JHT13HEfqX//OhG8G Jf3AcLq+BEgYjz1y62Vvu1qkVQ== X-Google-Smtp-Source: AJdET5dLcC4ia6XQOMeChAGQ+PpLrfV212072zXMAz/H5w2/HqWBTXxsNpTbqcIes6VU8Qumxt9PsA== X-Received: by 2002:a63:8ac4:: with SMTP id y187mr10597592pgd.446.1542386407688; Fri, 16 Nov 2018 08:40:07 -0800 (PST) Received: from localhost.localdomain ([115.97.190.86]) by smtp.gmail.com with ESMTPSA id p5-v6sm34622213pfb.109.2018.11.16.08.40.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 16 Nov 2018 08:40:07 -0800 (PST) From: Jagan Teki To: Maarten Lankhorst , Maxime Ripard , Sean Paul , David Airlie , Rob Herring , Chen-Yu Tsai , Icenowy Zheng , Jernej Skrabec , Vasily Khoruzhick , Thierry Reding , Mark Rutland , dri-devel@lists.freedesktop.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Michael Trimarchi , TL Lim , linux-sunxi@googlegroups.com, linux-amarula@amarulasolutions.com Subject: [PATCH v2 04/12] drm/sun4i: sun6i_mipi_dsi: Simplify drq set to support all modes Date: Fri, 16 Nov 2018 22:09:08 +0530 Message-Id: <20181116163916.29621-5-jagan@amarulasolutions.com> X-Mailer: git-send-email 2.18.0.321.gffc6fa0e3 In-Reply-To: <20181116163916.29621-1-jagan@amarulasolutions.com> References: <20181116163916.29621-1-jagan@amarulasolutions.com> MIME-Version: 1.0 X-Mailman-Approved-At: Sat, 17 Nov 2018 14:56:24 +0000 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jagan Teki Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP 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; + + if (device->mode_flags & MIPI_DSI_MODE_VIDEO_BURST) + return drq; + + 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; + } + + return drq; +} + 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))); } static void sun6i_dsi_setup_inst_loop(struct sun6i_dsi *dsi,