Received: by 2002:a05:6a10:6d10:0:0:0:0 with SMTP id gq16csp1521978pxb; Thu, 14 Apr 2022 07:58:58 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw0JpyV54OUmsLV+mAzw9jy1qUm3SFYXYwX6eQD1mgXD5tO0l5rNh2iHFLfrjpZ9HSA1pK3 X-Received: by 2002:a17:907:da6:b0:6ec:f599:b053 with SMTP id go38-20020a1709070da600b006ecf599b053mr590552ejc.503.1649948338485; Thu, 14 Apr 2022 07:58:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649948338; cv=none; d=google.com; s=arc-20160816; b=ytjmHqTPkR16OG6KqFNO4lRaudl8ZDhpcEg3WPAFTBnGAGi0T7MFjogRq2Pg38wnS1 45PvNm6o+OKPXnk2ouHJgx77PAfQ/dZx/tV5VjH7TlygCJtTaREvmggmaDiW08OEhGlf ph1Moe9VShWeHcq41mEvUWcqSuARP/il+QK4Ts78/rup4j19qI6eRAzH7PgrqFTC2Yv1 CVUnrmB8+Mpfv1NJAFvYF24CCdwMXg5Brn/e/zcEi7r0lztXtYH3GaQPQmUAxA6wGek8 wkHW8p0OYXJo3Ros4DSCY1lFY23fzVAwOcGvGMCRtWb+G4p/4vyKbXvKDl8l5P1SjXK4 FN6g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:dkim-signature; bh=fMitBsbOl69eJtZqeNqN7y5Gep0bncSngDUeMZp8zB4=; b=gD6dqKxeK7MB5LDTrwl0l56UFSUl8fuv2mTGzYBNAO+rIjzTrmxbBw4m+Ji0pVZop2 tti1UU6LDK1t/FY9OvcZnHCwaUrleOykhVrmuO4VTHI9zFJmM7vm98W6XXm5E/ikjYmI AXIpdWZImPtToaRI60gPV5MlywyEMhbVWtzLWPC6MOuJnDRYJ8ZC0oxgR5+6e7F0ZhUm QEJswBQTkW3mq8qXf1xKiSBs5LC7akNkaeQIVOqZCOYyF8v8+moc2pqlX8ICPwNreUNs cQSM4uv4wrCyZTC5ycS2r8wX5Z9nBJNiwxa0JPjIKO8kIOQwh4SPiwO3+F+Gkbh3bYk6 rOfQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sholland.org header.s=fm2 header.b=qJkffVFY; dkim=pass header.i=@messagingengine.com header.s=fm1 header.b=iFab+bH6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e23-20020a17090681d700b006df76385c21si1920737ejx.193.2022.04.14.07.58.32; Thu, 14 Apr 2022 07:58:58 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@sholland.org header.s=fm2 header.b=qJkffVFY; dkim=pass header.i=@messagingengine.com header.s=fm1 header.b=iFab+bH6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237504AbiDMWWt (ORCPT + 99 others); Wed, 13 Apr 2022 18:22:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40042 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238074AbiDMWW3 (ORCPT ); Wed, 13 Apr 2022 18:22:29 -0400 Received: from out5-smtp.messagingengine.com (out5-smtp.messagingengine.com [66.111.4.29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7119D24BE9; Wed, 13 Apr 2022 15:19:48 -0700 (PDT) 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=20St=C3=BCbner?= , Sandy Huang , dri-devel@lists.freedesktop.org Cc: linux-rockchip@lists.infradead.org, Alistair Francis , =?UTF-8?q?Ond=C5=99ej=20Jirman?= , 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 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW,SPF_HELO_PASS, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.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. */ -- 2.35.1