From patchwork Sun Mar 3 17:35:23 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jagan Teki X-Patchwork-Id: 10837165 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 91A231575 for ; Sun, 3 Mar 2019 17:36:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7B4B429B73 for ; Sun, 3 Mar 2019 17:36:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6FA1729CBF; Sun, 3 Mar 2019 17:36:19 +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 150EF29B73 for ; Sun, 3 Mar 2019 17:36:19 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id EA65489A1E; Sun, 3 Mar 2019 17:36:17 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-pl1-x643.google.com (mail-pl1-x643.google.com [IPv6:2607:f8b0:4864:20::643]) by gabe.freedesktop.org (Postfix) with ESMTPS id ED4D289A1E for ; Sun, 3 Mar 2019 17:36:15 +0000 (UTC) Received: by mail-pl1-x643.google.com with SMTP id y5so1360854plk.8 for ; Sun, 03 Mar 2019 09:36:15 -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=YvQ56Xx1Bmp0kWQNDK2nAiI9K4YgbqYzq9u72/Tb/Wo=; b=krIlmhkG/3rEf0dt1Yai8rQmGHS2ELIhye8SFZCY7VRMPGR62JG8KKbo89MEa9O2bN +WBkwUD2WscYlg7fR2jFzAld0yGVVYaS9MobFYT6qcxQypFyvgYubLtIKNCoqC2z0EO8 XrQnMbbB04jPccbMuGb+d5bOHqQIZDZ4BH/WQuLWtIrc5C7rMGsFrdZQHCAifJjmr+DV FvhnJoKMAeuE1rxPvbaYMJFI2wM+FBoY+m4CHDPT9Kw52jxJlWKgY08uLVowCm3aOy3A IbDx4BwBsRCgKBtefIdmgq2gfFJS/q8mTaqPUVUglaO2lKFqr3/HMxyqMIh0kxLkvW1d 4pGQ== X-Gm-Message-State: APjAAAVQAKFCFN7X1Ck1QBYJekYGmkTVq9t+7crQ9IApObo/2i5Yl6jF ksC/FrddZmSZNRxADX5J/Iw33g== X-Google-Smtp-Source: APXvYqwMfcEqRj8CRJW1LCxN3K8d+OryA2fDRcxHfLMc10INVG90SRQRlL8++UlhSKwM0Kz41FXC0Q== X-Received: by 2002:a17:902:52c:: with SMTP id 41mr16382818plf.331.1551634575454; Sun, 03 Mar 2019 09:36:15 -0800 (PST) Received: from localhost.localdomain ([115.97.184.151]) by smtp.gmail.com with ESMTPSA id d129sm5614737pgc.59.2019.03.03.09.36.11 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 03 Mar 2019 09:36:14 -0800 (PST) From: Jagan Teki To: Maxime Ripard , David Airlie , Daniel Vetter , Chen-Yu Tsai Subject: [PATCH v9 1/5] drm/sun4i: sun6i_mipi_dsi: Fix hsync_porch overflow Date: Sun, 3 Mar 2019 23:05:23 +0530 Message-Id: <20190303173527.31055-2-jagan@amarulasolutions.com> X-Mailer: git-send-email 2.18.0.321.gffc6fa0e3 In-Reply-To: <20190303173527.31055-1-jagan@amarulasolutions.com> References: <20190303173527.31055-1-jagan@amarulasolutions.com> MIME-Version: 1.0 X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amarulasolutions.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=YvQ56Xx1Bmp0kWQNDK2nAiI9K4YgbqYzq9u72/Tb/Wo=; b=LflUIddUoNDPr+yhSqv8YqZrx+sPJX8q6IeVAKXozXBQmd+7QqdF5FC/Nnfuh4HgEb P0P7322O1SSJswkLmEli+W4c4fUmqaQsvLpS23zbRTSmaNeBpt5i1mKVUS9aYaD6d08r 50szGzTOFiwKeoS4HmqpCI/fn6Ka88k8gLleo= 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: linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-sunxi@googlegroups.com, Jagan Teki , Michael Trimarchi , linux-amarula@amarulasolutions.com, linux-arm-kernel@lists.infradead.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP Loop N1 instruction delay for burst mode devices are computed based on horizontal sync and porch timing values. The current driver is using u16 type for computing this hsync_porch value, which would failed to fit within the u16 type for large sync and porch timings devices. This would result in hsync_porch overflow and eventually computed wrong instruction delay value. Example, timings, where it produces the overflow { .hdisplay = 1080, .hsync_start = 1080 + 408, .hsync_end = 1080 + 408 + 4, .htotal = 1080 + 408 + 4 + 38, } It reproduces the desired delay value 65487 but the correct working value should be 7. So, Fix it by computing hsync_porch value separately with u32 type. Fixes: 1c1a7aa3663c ("drm/sun4i: dsi: Add burst support") Signed-off-by: Jagan Teki Tested-by: Merlijn Wajer --- drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c b/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c index 6ff585055a07..465e7fc57899 100644 --- a/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c +++ b/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c @@ -457,8 +457,9 @@ static void sun6i_dsi_setup_inst_loop(struct sun6i_dsi *dsi, u16 delay = 50 - 1; if (device->mode_flags & MIPI_DSI_MODE_VIDEO_BURST) { - delay = (mode->htotal - mode->hdisplay) * 150; - delay /= (mode->clock / 1000) * 8; + u32 hsync_porch = (mode->htotal - mode->hdisplay); + + delay = ((hsync_porch * 150) / ((mode->clock / 1000) * 8)); delay -= 50; } From patchwork Sun Mar 3 17:35:24 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jagan Teki X-Patchwork-Id: 10837167 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 6ED581399 for ; Sun, 3 Mar 2019 17:36:22 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 58C7D29B73 for ; Sun, 3 Mar 2019 17:36:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4D28829CBF; Sun, 3 Mar 2019 17:36:22 +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 07BB429B73 for ; Sun, 3 Mar 2019 17:36:22 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 0E90E89A34; Sun, 3 Mar 2019 17:36:21 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-pg1-x543.google.com (mail-pg1-x543.google.com [IPv6:2607:f8b0:4864:20::543]) by gabe.freedesktop.org (Postfix) with ESMTPS id 474CF89A34 for ; Sun, 3 Mar 2019 17:36:20 +0000 (UTC) Received: by mail-pg1-x543.google.com with SMTP id m2so1361159pgl.5 for ; Sun, 03 Mar 2019 09:36:20 -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=D+mNFlao6tHpPYybFt0Tr/cBREXotgdAIz+jZKUMM8c=; b=HeRWvjEs2f5ImmnwDb8YMo2mCdCVwVyW9ufp2JLfUzDDy1th2TrD15RiUYjeLewSy/ +JOxD3R77dxdfCdMeOr6gBQGnypq432zzDuPjZpLB3vloXhUTC7lDOgSnW9d2DEr+rf5 LynEvW9bSXsgmcsi68azPats+zkb0Dmq19he9YgD+DwB2VkfzDydJaYo2ojnNoQK1KeZ sbsmNNUHRr6DdyNSbLO7ea0t+soZJSi2q463E64BsfzQNkxmoqiX9DX31rPHnWzWjuNL rJefqGTcIQ7JyFwh+QR4fFo6edNhxxvsXxk74rQKC8RKzJSgABlsanhp/a7PvCRgPtHo Gt5w== X-Gm-Message-State: APjAAAUWmRzud/PwN52idlYGHlymNyp46Hgqmt3paIGTVc1/0ImAqz61 Jwg32Qa9gr3A29IwRUsK37FIWQ== X-Google-Smtp-Source: APXvYqw/rVw52JfOtprvCQ9ajiMytcLnTP3ioHWwc0DoRpGUzVox9uFCiT03q1KAGX5Vu5OA3vgNcw== X-Received: by 2002:a63:eb56:: with SMTP id b22mr14828169pgk.287.1551634579844; Sun, 03 Mar 2019 09:36:19 -0800 (PST) Received: from localhost.localdomain ([115.97.184.151]) by smtp.gmail.com with ESMTPSA id d129sm5614737pgc.59.2019.03.03.09.36.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 03 Mar 2019 09:36:19 -0800 (PST) From: Jagan Teki To: Maxime Ripard , David Airlie , Daniel Vetter , Chen-Yu Tsai Subject: [PATCH v9 2/5] drm/sun4i: sun6i_mipi_dsi: Fix TCON DRQ set bits Date: Sun, 3 Mar 2019 23:05:24 +0530 Message-Id: <20190303173527.31055-3-jagan@amarulasolutions.com> X-Mailer: git-send-email 2.18.0.321.gffc6fa0e3 In-Reply-To: <20190303173527.31055-1-jagan@amarulasolutions.com> References: <20190303173527.31055-1-jagan@amarulasolutions.com> MIME-Version: 1.0 X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amarulasolutions.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=D+mNFlao6tHpPYybFt0Tr/cBREXotgdAIz+jZKUMM8c=; b=Q8DwfqBNMv5PqaAtlE0XmZxgdpp/cRJy5iNPf8b3ivLstJdfrhcCcaWdYGko5ulXzr 9WHzPMpHLrbhfgp71WTn91Nqke6SKxrsrSoI4IQa/wOST9+8m3ry4ld60oJV3luDkTW4 0bCHt/xqh/DhxGPwSZr6BZKnmuPhL7+pGT6aA= 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: linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-sunxi@googlegroups.com, Jagan Teki , Michael Trimarchi , linux-amarula@amarulasolutions.com, linux-arm-kernel@lists.infradead.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP TCON DRQ for non-burst DSI mode can computed based on horizontal front porch value, but the current driver trying to include sync timings along with front porch resulting wrong drq. This patch is trying to update the drq by subtracting hsync_start with hdisplay, which is horizontal front porch. Current code: ------------ mode->hsync_end - mode->hdisplay => horizontal front porch + sync With this patch: ---------------- mode->hsync_start - mode->hdisplay => horizontal front porch BSP code form BPI-M64-bsp is computing TCON DRQ set bits for non-burts as (from linux-sunxi/ drivers/video/sunxi/disp2/disp/de/lowlevel_sun50iw1/de_dsi.c) => panel->lcd_ht - panel->lcd_x - panel->lcd_hbp => (timmings->hor_front_porch + panel->lcd_hbp + panel->lcd_x) - panel->lcd_x - panel->hbp => timmings->hor_front_porch => mode->hsync_start - mode->hdisplay So, update the DRQ set bits accordingly. Signed-off-by: Jagan Teki Tested-by: Merlijn Wajer --- drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c b/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c index 465e7fc57899..140e55f5ed2e 100644 --- a/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c +++ b/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c @@ -436,9 +436,9 @@ static void sun6i_dsi_setup_burst(struct sun6i_dsi *dsi, SUN6I_DSI_BURST_LINE_SYNC_POINT(SUN6I_DSI_SYNC_POINT)); val = SUN6I_DSI_TCON_DRQ_ENABLE_MODE; - } else if ((mode->hsync_end - mode->hdisplay) > 20) { + } else if ((mode->hsync_start - mode->hdisplay) > 20) { /* Maaaaaagic */ - u16 drq = (mode->hsync_end - mode->hdisplay) - 20; + u16 drq = (mode->hsync_start - mode->hdisplay) - 20; drq *= mipi_dsi_pixel_format_to_bpp(device->format); drq /= 32; From patchwork Sun Mar 3 17:35:25 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jagan Teki X-Patchwork-Id: 10837169 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 BF5B71399 for ; Sun, 3 Mar 2019 17:36:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AA6D329B73 for ; Sun, 3 Mar 2019 17:36:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9E9C329CBF; Sun, 3 Mar 2019 17:36:27 +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 4788129B73 for ; Sun, 3 Mar 2019 17:36:27 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 627C188FE5; Sun, 3 Mar 2019 17:36:26 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-pf1-x442.google.com (mail-pf1-x442.google.com [IPv6:2607:f8b0:4864:20::442]) by gabe.freedesktop.org (Postfix) with ESMTPS id DA50688FE5 for ; Sun, 3 Mar 2019 17:36:24 +0000 (UTC) Received: by mail-pf1-x442.google.com with SMTP id h1so1295533pfo.7 for ; Sun, 03 Mar 2019 09:36:24 -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=SeROb0sI2fop2jpbyKF+OkejpdGcXO+z0TOiWQ+8P+Y=; b=OP0fho9OH+S4izdCFuF0S3lib+rDQQV23rb/rHxUhF5j1J43L8h1qmanW6qyKYx8Br uWRW1fiuhjl9UwOCCqFrDo+cpwHw9I4G3O4AsswdbZc4i8sa97d69T5RVAw1QAu+A8NY RTMWMU9GRVlcszJ3UXb5kpmkkaHp4UP7Pq5m6+V6wCAtJI0EEDXxVBhyrVf0jBMrntly gUOmOc1ucVTCqj+yiVu3axcGo02uGYQWHBhGqAybt/9YfTp3a6Z7nzakc03wnuwgPcZr NiSdjkeERf7kGIiICLe0qrwXnxGEx7UoP+lHigq5l6bZ4QAFNT6is45iKD0Eqd2I+gEY 7jWw== X-Gm-Message-State: AHQUAuZ3/OdhsryV5TcPVdaQEvJdU+tur1OGlQTHPxzuW+8I+QfL2dYq F4x2WkmJ4rLPQv58ZRwTU2kDPg== X-Google-Smtp-Source: AHgI3IaHgCR/5gcoWfZyzZcvwfxV9xnkUCOWuDAbEsxR5J/AtP0GFGZ49JcE+EKJuorIFBEXwivTPw== X-Received: by 2002:a62:4188:: with SMTP id g8mr16390415pfd.205.1551634584392; Sun, 03 Mar 2019 09:36:24 -0800 (PST) Received: from localhost.localdomain ([115.97.184.151]) by smtp.gmail.com with ESMTPSA id d129sm5614737pgc.59.2019.03.03.09.36.20 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 03 Mar 2019 09:36:23 -0800 (PST) From: Jagan Teki To: Maxime Ripard , David Airlie , Daniel Vetter , Chen-Yu Tsai Subject: [PATCH v9 3/5] drm/sun4i: sun6i_mipi_dsi: Support vblk timing for 4-lane devices Date: Sun, 3 Mar 2019 23:05:25 +0530 Message-Id: <20190303173527.31055-4-jagan@amarulasolutions.com> X-Mailer: git-send-email 2.18.0.321.gffc6fa0e3 In-Reply-To: <20190303173527.31055-1-jagan@amarulasolutions.com> References: <20190303173527.31055-1-jagan@amarulasolutions.com> MIME-Version: 1.0 X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amarulasolutions.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=SeROb0sI2fop2jpbyKF+OkejpdGcXO+z0TOiWQ+8P+Y=; b=azB7/TKSI1sGpYuQu5cYJgGyV1BbHN2qWtz/jzBQNGABtiKATw+o4e8327tYUG+def 0/CYRxPtK/mNCC4Y3vmoousXQ81+e2hr1WXOJCzBZjcPpwY7YBwuGo84AlhQThEotbVK Ge1jSGgvaB99KQhqtEhUh0JBFIu9lnvGB1WHg= 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: linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-sunxi@googlegroups.com, Jagan Teki , Michael Trimarchi , linux-amarula@amarulasolutions.com, linux-arm-kernel@lists.infradead.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP Like other dsi setup timings, or hblk for that matter vblk would also require compute the timings based payload equation along with packet overhead. But, on the other hand vblk computation is also depends on device lane number. - for 4 lane devices, it is computed based on vtotal, packet overhead along with hblk value. - for others devices, it is simply 0 BSP code from BPI-M64-bsp is computing vblk as for 4-lane devices (from linux-sunxi drivers/video/sunxi/disp2/disp/de/lowlevel_sun50iw1/de_dsi.c) tmp = (ht*dsi_pixel_bits[format]/8)*vt-(4+dsi_hblk+2); dsi_vblk = (lane-tmp%lane); So, update the vblk timing calculation to support all type of devices. Tested on 2-lane, 4-lane MIPI-DSI LCD panels. Signed-off-by: Jagan Teki Tested-by: Merlijn Wajer --- drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c | 27 +++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c b/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c index 140e55f5ed2e..b38358465d87 100644 --- a/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c +++ b/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c @@ -527,6 +527,24 @@ static void sun6i_dsi_setup_format(struct sun6i_dsi *dsi, SUN6I_DSI_PIXEL_CTL0_FORMAT(fmt)); } +static u16 sun6i_dsi_get_timings_vblk(struct sun6i_dsi *dsi, + struct drm_display_mode *mode, u16 hblk) +{ + struct mipi_dsi_device *device = dsi->device; + unsigned int Bpp = mipi_dsi_pixel_format_to_bpp(device->format) / 8; + int tmp; + + /* + * The vertical blank is set using a blanking packet (4 bytes + + * payload + 2 bytes). Its minimal size is therefore 6 bytes + */ +#define VBLK_PACKET_OVERHEAD 6 + tmp = (mode->htotal * Bpp) * mode->vtotal - + (hblk + VBLK_PACKET_OVERHEAD); + + return (device->lanes - tmp % device->lanes); +} + static void sun6i_dsi_setup_timings(struct sun6i_dsi *dsi, struct drm_display_mode *mode) { @@ -586,13 +604,8 @@ static void sun6i_dsi_setup_timings(struct sun6i_dsi *dsi, (mode->htotal - (mode->hsync_end - mode->hsync_start)) * Bpp - HBLK_PACKET_OVERHEAD); - /* - * And I'm not entirely sure what vblk is about. The driver in - * Allwinner BSP is using a rather convoluted calculation - * there only for 4 lanes. However, using 0 (the !4 lanes - * case) even with a 4 lanes screen seems to work... - */ - vblk = 0; + if (device->lanes == 4) + vblk = sun6i_dsi_get_timings_vblk(dsi, mode, hblk); } /* How many bytes do we need to send all payloads? */ From patchwork Sun Mar 3 17:35:26 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jagan Teki X-Patchwork-Id: 10837173 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 7540A1575 for ; Sun, 3 Mar 2019 17:36:32 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5C64429B73 for ; Sun, 3 Mar 2019 17:36:32 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5060A29CBF; Sun, 3 Mar 2019 17:36:32 +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 0EDED29B73 for ; Sun, 3 Mar 2019 17:36:32 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 2667689A44; Sun, 3 Mar 2019 17:36:31 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-pg1-x541.google.com (mail-pg1-x541.google.com [IPv6:2607:f8b0:4864:20::541]) by gabe.freedesktop.org (Postfix) with ESMTPS id 10E7989A44 for ; Sun, 3 Mar 2019 17:36:29 +0000 (UTC) Received: by mail-pg1-x541.google.com with SMTP id h11so1371975pgl.0 for ; Sun, 03 Mar 2019 09:36:29 -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=vJPTx000oHxbopR6zSva+6PYTZChrEwYDWEdYvNHNSw=; b=ExhpnWrfrPDy9XOOaJAZFi6lEODNsXxw7UJpqxjW4L1HQb0kIPyFWfTwqIrrp2kprY eZvNAgDUyRwbY836x9zONQ70fwmAgTKiVoItGdx49gGF/WCaYzKCsfrid9HAlSDf3AEd 5+ErBNcjBsls++GtBdCfPAOh5edqMDG3uopwutOEAFSfpZsQwe9/56D7aW0sK2H+jc7I QQ4Nbu4njGA/9STSJRpG65AFFTRZly0uOzmnCYbAdqC1Hw75l3wCj2MNmBTg90wCEQee +PSjA3q4CHsI0NI68K1QIMkhi/Plkfo1+77P91jaQG0Iqb3FPmLI3epn9vv85GzR4ptf 4G9A== X-Gm-Message-State: APjAAAXI8P9M9NEngVl3e0qMI/chgT2idzp2ZNDCdFwkSYE/Hn2Cx+Z6 MTmhToF3inWdxu+Y2ydjhTKimEwE8cg= X-Google-Smtp-Source: APXvYqxPgxhRSykWz7+/csq2o3JggZowiY4OEPnJlGnRLSmE+fk/rSEqeuGKOjGVBBzGgGe2M3gKNQ== X-Received: by 2002:a63:e752:: with SMTP id j18mr14560664pgk.313.1551634588608; Sun, 03 Mar 2019 09:36:28 -0800 (PST) Received: from localhost.localdomain ([115.97.184.151]) by smtp.gmail.com with ESMTPSA id d129sm5614737pgc.59.2019.03.03.09.36.24 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 03 Mar 2019 09:36:28 -0800 (PST) From: Jagan Teki To: Maxime Ripard , David Airlie , Daniel Vetter , Chen-Yu Tsai Subject: [PATCH v9 4/5] drm/sun4i: sun6i_mipi_dsi: Support DSI GENERIC_SHORT_WRITE_2 transfer Date: Sun, 3 Mar 2019 23:05:26 +0530 Message-Id: <20190303173527.31055-5-jagan@amarulasolutions.com> X-Mailer: git-send-email 2.18.0.321.gffc6fa0e3 In-Reply-To: <20190303173527.31055-1-jagan@amarulasolutions.com> References: <20190303173527.31055-1-jagan@amarulasolutions.com> MIME-Version: 1.0 X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amarulasolutions.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=vJPTx000oHxbopR6zSva+6PYTZChrEwYDWEdYvNHNSw=; b=SZZFDZzAKGseSn3ySk56BE72SkGB/cctCQLD2HMzWaXLItoLAUHTNv8+AKaQJtOZr6 7G94/LEMpIGOB8LeSXhKRk5v48oPEh4Bli2Q7rCzhfC1KM8eGI5kOzW/1qmb6wBJJpn9 l/7EOWAHDhpr+aUn+8i1DfnYGkCnNE/2zGKFg= 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: linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-sunxi@googlegroups.com, Jagan Teki , Michael Trimarchi , linux-amarula@amarulasolutions.com, linux-arm-kernel@lists.infradead.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP Some DSI panels do use GENERIC_SHORT_WRITE_2 transfer protocol to host DSI driver and which is similar to GENERIC_SHORT_WRITE. Add support for the same transfer, so-that so-that the panels which are requesting similar transfer type will process properly. Signed-off-by: Jagan Teki Tested-by: Merlijn Wajer --- drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c b/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c index b38358465d87..31ec4048804d 100644 --- a/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c +++ b/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c @@ -993,6 +993,7 @@ static ssize_t sun6i_dsi_transfer(struct mipi_dsi_host *host, switch (msg->type) { case MIPI_DSI_DCS_SHORT_WRITE: case MIPI_DSI_DCS_SHORT_WRITE_PARAM: + case MIPI_DSI_GENERIC_SHORT_WRITE_2_PARAM: ret = sun6i_dsi_dcs_write_short(dsi, msg); break; From patchwork Sun Mar 3 17:35:27 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jagan Teki X-Patchwork-Id: 10837175 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 172261399 for ; Sun, 3 Mar 2019 17:36:37 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0276829B73 for ; Sun, 3 Mar 2019 17:36:37 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E9B8D29CBF; Sun, 3 Mar 2019 17:36:36 +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 80CC229B73 for ; Sun, 3 Mar 2019 17:36:36 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id A0EE089A4B; Sun, 3 Mar 2019 17:36:35 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-pf1-x444.google.com (mail-pf1-x444.google.com [IPv6:2607:f8b0:4864:20::444]) by gabe.freedesktop.org (Postfix) with ESMTPS id D7DF689A4B for ; Sun, 3 Mar 2019 17:36:33 +0000 (UTC) Received: by mail-pf1-x444.google.com with SMTP id h1so1295600pfo.7 for ; Sun, 03 Mar 2019 09:36:33 -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=nH8G1W2EgQa6aDAZzLfPouCwgu4asZ6FIPx9/UPBlXw=; b=CyCf9F6J6TnSpJu7i+f/MVoFKR3PwPGak+Ag/pBao9+4+gGo3l0Ix57OAN5KG7VYxY U0pH3D68eRODEseDTTEDNZn/gR66WXZBYSEDcbo99/Ly2lRPRrlx4OHlczmL6GfQw9Va iC5bJ3AbhCJCNsxeSyG6p5kbdpOXJvnTLIxQ5beSkBrA25HYE88bbNpBmoxERZHcS9dE fEqscKAQPn6QwGFfDkG7G17KhszXlsHLYu0VH+tdbUpTG597M8rKrHvQed55qnQZQcCF xmc9zwx5B/hEkZ0dbbGA7I69SLAms8x0g+nSV6mZ7r5ZoZcoHWFxmqJrYCySq1DaRFRF 8qtg== X-Gm-Message-State: AHQUAubLiXaFNY9CrIIYhyBS6HXBewESc4v5RIjW9Ya50fkS5DIkZlFP Yf3qYxqDRXHAU9Eph0TYjEld8g== X-Google-Smtp-Source: AHgI3IagjBeD7CYWDO3mg/s0XAZehQj9szKzEtW7vEEHLwfsdUn/ST4V3eOL+zwMZQHQsdIkEImAjw== X-Received: by 2002:a62:76c9:: with SMTP id r192mr16283667pfc.251.1551634593359; Sun, 03 Mar 2019 09:36:33 -0800 (PST) Received: from localhost.localdomain ([115.97.184.151]) by smtp.gmail.com with ESMTPSA id d129sm5614737pgc.59.2019.03.03.09.36.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 03 Mar 2019 09:36:32 -0800 (PST) From: Jagan Teki To: Maxime Ripard , David Airlie , Daniel Vetter , Chen-Yu Tsai Subject: [PATCH v9 5/5] drm/sun4i: sun6i_mipi_dsi: Simplify dsi setup timings code Date: Sun, 3 Mar 2019 23:05:27 +0530 Message-Id: <20190303173527.31055-6-jagan@amarulasolutions.com> X-Mailer: git-send-email 2.18.0.321.gffc6fa0e3 In-Reply-To: <20190303173527.31055-1-jagan@amarulasolutions.com> References: <20190303173527.31055-1-jagan@amarulasolutions.com> MIME-Version: 1.0 X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amarulasolutions.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=nH8G1W2EgQa6aDAZzLfPouCwgu4asZ6FIPx9/UPBlXw=; b=m1FrEllfMfg/suYjQdH2Ti+ra+O0Y+MXCh1/x2MHp8Aczb3+Wpnapl0qsZLfY5SXmp c1Yn6AP9Fxv4Gt3zu3vta8gvNg54IrM2HCRcdP3i+bUyCBTeDbdvdQshM5IrbMZ0hEFZ Z6SNyVr4VObWmVbRbKbQWVY8aI73f5YfjHlgI= 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: linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-sunxi@googlegroups.com, Jagan Teki , Michael Trimarchi , linux-amarula@amarulasolutions.com, linux-arm-kernel@lists.infradead.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP DSI timings are varies between burst/non-burst devices and current driver is handling this support via if, else statements which would difficult to read. Simplify it by using goto to make code more readable. Signed-off-by: Jagan Teki Tested-by: Merlijn Wajer --- Note: This change is created based on previous version burst changes [1] by addressing comment from [2] by Maxime to make code readable. [1] https://patchwork.kernel.org/cover/10813623/ [2] https://patchwork.kernel.org/patch/10666607/ drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c | 79 ++++++++++++++------------ 1 file changed, 42 insertions(+), 37 deletions(-) diff --git a/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c b/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c index 31ec4048804d..898f32319c2d 100644 --- a/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c +++ b/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c @@ -550,7 +550,8 @@ static void sun6i_dsi_setup_timings(struct sun6i_dsi *dsi, { struct mipi_dsi_device *device = dsi->device; unsigned int Bpp = mipi_dsi_pixel_format_to_bpp(device->format) / 8; - u16 hbp = 0, hfp = 0, hsa = 0, hblk = 0, vblk = 0; + u16 hbp, hfp, hsa, hblk; + u16 vblk = 0; u32 basic_ctl = 0; size_t bytes; u8 *buffer; @@ -558,6 +559,7 @@ static void sun6i_dsi_setup_timings(struct sun6i_dsi *dsi, /* Do all timing calculations up front to allocate buffer space */ if (device->mode_flags & MIPI_DSI_MODE_VIDEO_BURST) { + hbp = hfp = hsa = 0; hblk = mode->hdisplay * Bpp; basic_ctl = SUN6I_DSI_BASIC_CTL_VIDEO_BURST | SUN6I_DSI_BASIC_CTL_HSA_HSE_DIS | @@ -566,48 +568,51 @@ static void sun6i_dsi_setup_timings(struct sun6i_dsi *dsi, if (device->lanes == 4) basic_ctl |= SUN6I_DSI_BASIC_CTL_TRAIL_FILL | SUN6I_DSI_BASIC_CTL_TRAIL_INV(0xc); - } else { - /* - * A sync period is composed of a blanking packet (4 - * bytes + payload + 2 bytes) and a sync event packet - * (4 bytes). Its minimal size is therefore 10 bytes - */ + + goto alloc_buf; + } + + /* + * A sync period is composed of a blanking packet (4 + * bytes + payload + 2 bytes) and a sync event packet + * (4 bytes). Its minimal size is therefore 10 bytes + */ #define HSA_PACKET_OVERHEAD 10 - hsa = max((unsigned int)HSA_PACKET_OVERHEAD, - (mode->hsync_end - mode->hsync_start) * Bpp - HSA_PACKET_OVERHEAD); - - /* - * The backporch is set using a blanking packet (4 - * bytes + payload + 2 bytes). Its minimal size is - * therefore 6 bytes - */ + hsa = max((unsigned int)HSA_PACKET_OVERHEAD, + (mode->hsync_end - mode->hsync_start) * Bpp - HSA_PACKET_OVERHEAD); + + /* + * The backporch is set using a blanking packet (4 + * bytes + payload + 2 bytes). Its minimal size is + * therefore 6 bytes + */ #define HBP_PACKET_OVERHEAD 6 - hbp = max((unsigned int)HBP_PACKET_OVERHEAD, - (mode->htotal - mode->hsync_end) * Bpp - HBP_PACKET_OVERHEAD); - - /* - * The frontporch is set using a blanking packet (4 - * bytes + payload + 2 bytes). Its minimal size is - * therefore 6 bytes - */ + hbp = max((unsigned int)HBP_PACKET_OVERHEAD, + (mode->htotal - mode->hsync_end) * Bpp - HBP_PACKET_OVERHEAD); + + /* + * The frontporch is set using a blanking packet (4 + * bytes + payload + 2 bytes). Its minimal size is + * therefore 6 bytes + */ #define HFP_PACKET_OVERHEAD 6 - hfp = max((unsigned int)HFP_PACKET_OVERHEAD, - (mode->hsync_start - mode->hdisplay) * Bpp - HFP_PACKET_OVERHEAD); - - /* - * The blanking is set using a sync event (4 bytes) - * and a blanking packet (4 bytes + payload + 2 - * bytes). Its minimal size is therefore 10 bytes. - */ + hfp = max((unsigned int)HFP_PACKET_OVERHEAD, + (mode->hsync_start - mode->hdisplay) * Bpp - HFP_PACKET_OVERHEAD); + + /* + * The blanking is set using a sync event (4 bytes) + * and a blanking packet (4 bytes + payload + 2 + * bytes). Its minimal size is therefore 10 bytes. + */ #define HBLK_PACKET_OVERHEAD 10 - hblk = max((unsigned int)HBLK_PACKET_OVERHEAD, - (mode->htotal - (mode->hsync_end - mode->hsync_start)) * Bpp - - HBLK_PACKET_OVERHEAD); + hblk = max((unsigned int)HBLK_PACKET_OVERHEAD, + (mode->htotal - (mode->hsync_end - mode->hsync_start)) * Bpp - + HBLK_PACKET_OVERHEAD); - if (device->lanes == 4) - vblk = sun6i_dsi_get_timings_vblk(dsi, mode, hblk); - } + if (device->lanes == 4) + vblk = sun6i_dsi_get_timings_vblk(dsi, mode, hblk); +alloc_buf: /* How many bytes do we need to send all payloads? */ bytes = max_t(size_t, max(max(hfp, hblk), max(hsa, hbp)), vblk); buffer = kmalloc(bytes, GFP_KERNEL);