From patchwork Wed Oct 12 22:11:59 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Marek Vasut X-Patchwork-Id: 13005492 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 D3BC9C4332F for ; Wed, 12 Oct 2022 22:12:15 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 63EA010E062; Wed, 12 Oct 2022 22:12:13 +0000 (UTC) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) by gabe.freedesktop.org (Postfix) with ESMTPS id 68BF510E062 for ; Wed, 12 Oct 2022 22:12:09 +0000 (UTC) Received: from tr.lan (ip-86-49-12-201.bb.vodafone.cz [86.49.12.201]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: marex@denx.de) by phobos.denx.de (Postfix) with ESMTPSA id 65EDE84E44; Thu, 13 Oct 2022 00:12:06 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=denx.de; s=phobos-20191101; t=1665612727; bh=vVJsVm9BWLe/Eis+SEZxIdVnhP7Eq0P+dM/IljrN09c=; h=From:To:Cc:Subject:Date:From; b=b/p6I2tdEFgpI1H0Dj4QEE/A2H7H2H7BPhvKH9soxZWOiAbug1U8MvaQjxpEFPZZf fWgSoNkfyXqKn0WmCrr90gCamzsJ1W3ZotOGr8zBa1A8bvvHXiQCXaNQpYA9sY5bCh BD0X1/AZxF8St2I4gBwQLl2rPvvebRFJLlZdCQW8AG8tr2DbmPorYZbrquHYperMwt jr2nQE8Dk4kzGrh+KhQz/Eg3kJ3zYxlvwAkguuRjyZCJ4Ha5AyrI1LXap/am1Fonkb n8Q6qmgyFgqRzGwlXax4Jd2I8AwZXx/jRivS2VyRWXf99WXsmcBW4+23VgJIjR9TUc s4FJ4NRQucUiw== From: Marek Vasut To: dri-devel@lists.freedesktop.org Subject: [PATCH v2] drm/panel/panel-sitronix-st7701: Fix RTNI calculation Date: Thu, 13 Oct 2022 00:11:59 +0200 Message-Id: <20221012221159.88397-1-marex@denx.de> X-Mailer: git-send-email 2.35.1 MIME-Version: 1.0 X-Virus-Scanned: clamav-milter 0.103.6 at phobos.denx.de X-Virus-Status: Clean 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 , =?utf-8?q?Guido_G=C3=BCnther?= , Thierry Reding , Jagan Teki , Sam Ravnborg , Laurent Pinchart Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" The RTNI field is multiplied by 16 and incremented by 512 before being used as the minimum number of pixel clock per horizontal line, hence it is necessary to subtract those 512 bytes from htotal and then divide the result by 16 before writing the value into the RTNI field. Fix the calculation. Fixes: de2b4917843c ("drm/panel/panel-sitronix-st7701: Infer horizontal pixel count from TFT mode") Signed-off-by: Marek Vasut Reviewed-by: Linus Walleij --- Cc: Guido Günther Cc: Jagan Teki Cc: Laurent Pinchart Cc: Linus Walleij Cc: Sam Ravnborg Cc: Thierry Reding --- V2: Clamp the htotal to range 512...1008, so RTNI always fits the bitfield --- drivers/gpu/drm/panel/panel-sitronix-st7701.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpu/drm/panel/panel-sitronix-st7701.c b/drivers/gpu/drm/panel/panel-sitronix-st7701.c index c481daa4bbceb..9578f461f5e48 100644 --- a/drivers/gpu/drm/panel/panel-sitronix-st7701.c +++ b/drivers/gpu/drm/panel/panel-sitronix-st7701.c @@ -244,7 +244,7 @@ static void st7701_init_sequence(struct st7701 *st7701) DSI_CMD2_BK0_INVSEL_ONES_MASK | FIELD_PREP(DSI_CMD2_BK0_INVSEL_NLINV_MASK, desc->nlinv), FIELD_PREP(DSI_CMD2_BK0_INVSEL_RTNI_MASK, - DIV_ROUND_UP(mode->htotal, 16))); + (clamp((u32)mode->htotal, 512U, 1008U) - 512) / 16)); /* Command2, BK1 */ ST7701_DSI(st7701, DSI_CMD2BKX_SEL,