From patchwork Sat May 6 19:24:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adam Ford X-Patchwork-Id: 13233600 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 22B1CC77B75 for ; Sat, 6 May 2023 19:25:29 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id C5C6B10E0D0; Sat, 6 May 2023 19:25:22 +0000 (UTC) Received: from mail-io1-xd2d.google.com (mail-io1-xd2d.google.com [IPv6:2607:f8b0:4864:20::d2d]) by gabe.freedesktop.org (Postfix) with ESMTPS id 902B510E0BE for ; Sat, 6 May 2023 19:25:20 +0000 (UTC) Received: by mail-io1-xd2d.google.com with SMTP id ca18e2360f4ac-763c3429a8cso82632839f.2 for ; Sat, 06 May 2023 12:25:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1683401120; x=1685993120; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=dygmSIeKyL1Qr6osm0gPJv6LRBfSTNTnVZ/IpsRKoBs=; b=H5PigfyG9oRnNxodKmNzLaAP9VtSQhKlEdYbUUlyN9weXF0pSZ793X45J21cstr8B0 YKN/Zllv5ezdTRJPThz+qtDuskoHPSKqh5f9XJTtTcQlSr1LXbt82uznqghmgsZKxR3g J8/1frtv3TzM2KcQrAV5VTmr016lw2xhVMxMZfjuvMpgi1/ybeRLjo3l6pzEcHj+f6OY 2Zaac2GmUjrJZ2JMiMyj64SdJKaOkxFb2fUis0BE9yMsCuI0RrV8P0WXfEs7jQkWnU/1 cyaJNRtakpOs76DiS+Bnp292VXuc1s/DIEeHfnmhBfUJ/nDm2bbUK1+ENyKM17j1nVGM 2nSQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683401120; x=1685993120; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=dygmSIeKyL1Qr6osm0gPJv6LRBfSTNTnVZ/IpsRKoBs=; b=MYotDmsSMdRLiV7PrnTLsqYhXu/8xSBQx78i00xv88pTZsCTcPuJdkThhLZrEB3zFb Ijmqp4+ABafVuptcHeGrvWpwZxw9aB0jD8pMRW9JOosr3DpVgepcD8ES1Jrp4M/kTLK1 qTNrmbbtJfunC0bkw4Omjq3H5HPNHNLt+dUqRdvd4bWAbEgHyQgvszIZEjJI2oo3O48m yaabXSF5lzdPpm2dUHlZYMVemsvNZr/0Qn4NToKrlDKiSQf5rGL+WXxJ5ItupavfOWPj IClT5KDrhyKQjgrLirrwt0RwdCnZWJVFEvWuQbf0OA3cPkasAV1z95915kz5zEtL24Z1 4PXg== X-Gm-Message-State: AC+VfDzZNe9QVlMA1I9ykuRZfDbblHPNOmeGOc4sv/pTEpJMP8M7nC9T Rp1ZyIGkDdCI7ipu/gmBZIt//4CrGs3Cfg== X-Google-Smtp-Source: ACHHUZ5zY7Nps8qwvUG1/YIRkiugFxI0kuxCKAG8Urz0yubjmQw99S7re/+45O6b4dZajVTK7isG5Q== X-Received: by 2002:a05:6e02:4cd:b0:331:8f55:15b8 with SMTP id f13-20020a056e0204cd00b003318f5515b8mr3135194ils.3.1683401119844; Sat, 06 May 2023 12:25:19 -0700 (PDT) Received: from aford-B741.lan ([2601:447:d001:897f:5e49:1bed:79d0:5c25]) by smtp.gmail.com with ESMTPSA id z18-20020a05663822b200b0041631393ac9sm847824jas.18.2023.05.06.12.25.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 06 May 2023 12:25:19 -0700 (PDT) From: Adam Ford To: dri-devel@lists.freedesktop.org Subject: [PATCH V5 1/6] drm: bridge: samsung-dsim: fix blanking packet size calculation Date: Sat, 6 May 2023 14:24:48 -0500 Message-Id: <20230506192453.725621-2-aford173@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230506192453.725621-1-aford173@gmail.com> References: <20230506192453.725621-1-aford173@gmail.com> MIME-Version: 1.0 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: Marek Vasut , Neil Armstrong , Jernej Skrabec , Robert Foss , Jonas Karlman , aford@beaconembedded.com, Frieder Schrempf , linux-kernel@vger.kernel.org, Jagan Teki , Laurent Pinchart , Andrzej Hajda , Chen-Yu Tsai , Marek Szyprowski , Adam Ford Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Lucas Stach Scale the blanking packet sizes to match the ratio between HS clock and DPI interface clock. The controller seems to do internal scaling to the number of active lanes, so we don't take those into account. Signed-off-by: Lucas Stach Signed-off-by: Adam Ford Tested-by: Chen-Yu Tsai Tested-by: Frieder Schrempf --- drivers/gpu/drm/bridge/samsung-dsim.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/bridge/samsung-dsim.c b/drivers/gpu/drm/bridge/samsung-dsim.c index e0a402a85787..2be3b58624c3 100644 --- a/drivers/gpu/drm/bridge/samsung-dsim.c +++ b/drivers/gpu/drm/bridge/samsung-dsim.c @@ -874,17 +874,29 @@ static void samsung_dsim_set_display_mode(struct samsung_dsim *dsi) u32 reg; if (dsi->mode_flags & MIPI_DSI_MODE_VIDEO) { + int byte_clk_khz = dsi->burst_clk_rate / 1000 / 8; + int hfp = (m->hsync_start - m->hdisplay) * byte_clk_khz / m->clock; + int hbp = (m->htotal - m->hsync_end) * byte_clk_khz / m->clock; + int hsa = (m->hsync_end - m->hsync_start) * byte_clk_khz / m->clock; + + /* remove packet overhead when possible */ + hfp = max(hfp - 6, 0); + hbp = max(hbp - 6, 0); + hsa = max(hsa - 6, 0); + + dev_dbg(dsi->dev, "calculated hfp: %u, hbp: %u, hsa: %u", + hfp, hbp, hsa); + reg = DSIM_CMD_ALLOW(0xf) | DSIM_STABLE_VFP(m->vsync_start - m->vdisplay) | DSIM_MAIN_VBP(m->vtotal - m->vsync_end); samsung_dsim_write(dsi, DSIM_MVPORCH_REG, reg); - reg = DSIM_MAIN_HFP(m->hsync_start - m->hdisplay) - | DSIM_MAIN_HBP(m->htotal - m->hsync_end); + reg = DSIM_MAIN_HFP(hfp) | DSIM_MAIN_HBP(hbp); samsung_dsim_write(dsi, DSIM_MHPORCH_REG, reg); reg = DSIM_MAIN_VSA(m->vsync_end - m->vsync_start) - | DSIM_MAIN_HSA(m->hsync_end - m->hsync_start); + | DSIM_MAIN_HSA(hsa); samsung_dsim_write(dsi, DSIM_MSYNC_REG, reg); } reg = DSIM_MAIN_HRESOL(m->hdisplay, num_bits_resol) |