From patchwork Wed Apr 13 22:19:13 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Samuel Holland X-Patchwork-Id: 12812757 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 A70D0C433EF for ; Wed, 13 Apr 2022 22:27:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=n/m2Tb0LpAip0cOgY0o4ddd2+IX+CdX13yBwZtEvPas=; b=P37uXQJVwr+HLw 35HFt5549FkDfSNoDisSbtOY7SEoaSxX1eF5xBrcBnOmY8gLGCGxLvnW0h2I1ux21GcUq5ibKFe6D 6vCo3fkLCXpWN1xDQJMopbuk1Enly1fL5JxMxkujGNC/RxgzqEixGMiP6jDv7Gqtlw9jayHITcvQC qsGLyyel6pcT2WkQwtjH/R7Pm0SP3GXv+ri/Bpzx1PWKKX6Na7FRsrA/y4q1AMf2DvP/qF0YdJP5w gbpBhO/D9djX283EsECJjzGVtjrFapU/ojAMQPreMoiR3D618Loqi/qU8gCASDMQaXU318OCwQ2H6 7Na8fvoC7pIdg0p+RSCQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nelRy-002tRb-Gx; Wed, 13 Apr 2022 22:26:58 +0000 Received: from out5-smtp.messagingengine.com ([66.111.4.29]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nelL2-002q4L-FA; Wed, 13 Apr 2022 22:19:53 +0000 Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.nyi.internal (Postfix) with ESMTP id CB4D95C02B7; Wed, 13 Apr 2022 18:19:47 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute5.internal (MEProxy); Wed, 13 Apr 2022 18:19:47 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sholland.org; h= cc:cc:content-transfer-encoding:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:sender :subject:subject:to:to; s=fm2; t=1649888387; x=1649974787; bh=fM itBsbOl69eJtZqeNqN7y5Gep0bncSngDUeMZp8zB4=; b=qJkffVFYB9u7OIdDzI T+1qUMCsmcnyDpSK9V3nkFZ5QOoQsHC/fGuXl63TdKyWdr72KmxelbV6YPH7WaQ7 Baf3DTKZeommUEDIxwu+J+/OwRmkTX+phQZWLXNE4EyZ/80yATPkevMKvx6PQQku DvbyMupWMAu9HlWSjjud30mpLgrW1oaWCLhiDEuirEqfEAgEbRvOd2i1IWyhqqmo flEf8CWNhsligN4vGyse639Z6hV+Avv09HlueYb/KVCsbk7jLUeIaQ/MRmy+AFqH Q2lNi5ZeQNi5RgdxbYaaq+YAowpHa5WnFT3Ek6/aP2swQ7dSpi0Myn0Ctc3uTi6i TQNw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding:date:date :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:sender:subject:subject:to:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t= 1649888387; x=1649974787; bh=fMitBsbOl69eJtZqeNqN7y5Gep0bncSngDU eMZp8zB4=; b=iFab+bH6MXUBpnDsciPRLYKcTitrp1MRRAMJsBccGx0Yj72+C54 qt0C6cHdYHQgI536AX+ZfWtAyYD1261wPAL10dugJO1L+R9kDXDwJVRzYgYhS3Wg igMT9SrlenjEXrpj5bTVasZpwFp+wTYHSKMLPgcjAoorkJILWjszYaFWU3DQZQ39 kzqHcMf2F16lcAa/dIedVMMsg16vJ4kPkYy96vHFp+Wl3hOZO5/cA1pXmsNA5mBv zsHy4zQi4qGoDlhvchcnQ36PgsEErts66IqUmxTVpmtRw77/GCSsf9TTdbO3aOhm zWRxjedZPyxwL68m8khLTjbcXEqqG0X0ezA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvvddrudelvddgtdelucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvufffkffojghfggfgsedtkeertdertddtnecuhfhrohhmpefurghmuhgv lhcujfholhhlrghnugcuoehsrghmuhgvlhesshhhohhllhgrnhgurdhorhhgqeenucggtf frrghtthgvrhhnpeduhfejfedvhffgfeehtefghfeiiefgfeehgfdvvdevfeegjeehjedv gfejheeuieenucevlhhushhtvghrufhiiigvpeejnecurfgrrhgrmhepmhgrihhlfhhroh hmpehsrghmuhgvlhesshhhohhllhgrnhgurdhorhhg X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 13 Apr 2022 18:19:46 -0400 (EDT) From: Samuel Holland To: =?utf-8?q?Heiko_St=C3=BCbner?= , Sandy Huang , dri-devel@lists.freedesktop.org Cc: linux-rockchip@lists.infradead.org, Alistair Francis , =?utf-8?q?Ond=C5=99ej_Jirman?= , Andreas Kemnade , Daniel Vetter , David Airlie , Geert Uytterhoeven , Samuel Holland , Krzysztof Kozlowski , Liang Chen , Maarten Lankhorst , Maxime Ripard , Michael Riesch , Nicolas Frattaroli , Peter Geis , Rob Herring , Sam Ravnborg , Thierry Reding , Thomas Zimmermann , devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [RFC PATCH 13/16] drm/rockchip: ebc: Add a panel reflection option Date: Wed, 13 Apr 2022 17:19:13 -0500 Message-Id: <20220413221916.50995-14-samuel@sholland.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220413221916.50995-1-samuel@sholland.org> References: <20220413221916.50995-1-samuel@sholland.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220413_151948_670721_7BF66038 X-CRM114-Status: GOOD ( 13.77 ) X-BeenThere: linux-rockchip@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Upstream kernel work for Rockchip platforms List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Linux-rockchip" Errors-To: linux-rockchip-bounces+linux-rockchip=archiver.kernel.org@lists.infradead.org Some panels, like the one in the PineNote, are reflected. Since the driver already has to copy pixels, the driver can handle this with little additional overhead. Currently, there is no devicetree binding for this situation, so control the behavior via a module parameter. Signed-off-by: Samuel Holland --- drivers/gpu/drm/rockchip/rockchip_ebc.c | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/rockchip/rockchip_ebc.c b/drivers/gpu/drm/rockchip/rockchip_ebc.c index 93d689ff0933..9d0b2cdc5fdc 100644 --- a/drivers/gpu/drm/rockchip/rockchip_ebc.c +++ b/drivers/gpu/drm/rockchip/rockchip_ebc.c @@ -166,6 +166,10 @@ static bool direct_mode = true; module_param(direct_mode, bool, 0444); MODULE_PARM_DESC(direct_mode, "compute waveforms in software (software LUT)"); +static bool panel_reflection = true; +module_param(panel_reflection, bool, 0644); +MODULE_PARM_DESC(panel_reflection, "reflect the image horizontally"); + static bool skip_reset; module_param(skip_reset, bool, 0444); MODULE_PARM_DESC(skip_reset, "skip the initial display reset"); @@ -1046,23 +1050,29 @@ static bool rockchip_ebc_blit_fb(const struct rockchip_ebc_ctx *ctx, { unsigned int dst_pitch = ctx->gray4_pitch; unsigned int src_pitch = fb->pitches[0]; - unsigned int x, y; + unsigned int start_x, x, y; const void *src; u8 changed = 0; + int delta_x; void *dst; + delta_x = panel_reflection ? -1 : 1; + start_x = panel_reflection ? src_clip->x2 - 1 : src_clip->x1; + dst = ctx->final + dst_clip->y1 * dst_pitch + dst_clip->x1 / 2; - src = vaddr + src_clip->y1 * src_pitch + src_clip->x1 * fb->format->cpp[0]; + src = vaddr + src_clip->y1 * src_pitch + start_x * fb->format->cpp[0]; for (y = src_clip->y1; y < src_clip->y2; y++) { const u32 *sbuf = src; u8 *dbuf = dst; for (x = src_clip->x1; x < src_clip->x2; x += 2) { - u32 rgb0 = *sbuf++; - u32 rgb1 = *sbuf++; + u32 rgb0, rgb1; u8 gray; + rgb0 = *sbuf; sbuf += delta_x; + rgb1 = *sbuf; sbuf += delta_x; + /* Truncate the RGB values to 5 bits each. */ rgb0 &= 0x00f8f8f8U; rgb1 &= 0x00f8f8f8U; /* Put the sum 2R+5G+B in bits 24-31. */ @@ -1136,6 +1146,13 @@ static void rockchip_ebc_plane_atomic_update(struct drm_plane *plane, dst_clip->x2 += adjust; src_clip.x2 += adjust; + if (panel_reflection) { + int x1 = dst_clip->x1, x2 = dst_clip->x2; + + dst_clip->x1 = plane_state->dst.x2 - x2; + dst_clip->x2 = plane_state->dst.x2 - x1; + } + if (!rockchip_ebc_blit_fb(ctx, dst_clip, vaddr, plane_state->fb, &src_clip)) { /* Drop the area if the FB didn't actually change. */