From patchwork Mon Oct 23 21:11:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonas Karlman X-Patchwork-Id: 13433575 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 C71C0C25B45 for ; Mon, 23 Oct 2023 21:12:48 +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: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:In-Reply-To:References: List-Owner; bh=4Sa1G2hDeunXZGdmHyLqPQbpLF2ZDizWPCTMElwnd7k=; b=lBNwZjQro4/Ygc 8InLadnASa96dibD2gr4SOe+ua4ETS9BDyopMas/5TnbnS8hqqXSxkxxq3Cjq/QZegnDJKZW0VPBJ wpAEZfQo8M1XukLkhw35ohvH6L06Q+1UQY9wTGhElaJwo+FSHmKJVZEx+037nafDUrKnxOxNy+gut J3mfOB1zQmNZjLONRiIzvtqbeuPnarAHAD1vAWyN1GknWKDJTazBAbZD8GgVabvxTolpm7xEWrZmz nGjfMxNFayMO1PgXiAffVEApUnNOsu+lZcfG5DoBX3tsMTXyMcGPcdVbeL+CA+HFTkgthtYI4t4Ak TJ+lwDb3gGE6QnEY3rGg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qv2Dl-008IQu-2y; Mon, 23 Oct 2023 21:12:21 +0000 Received: from smtp.forwardemail.net ([149.28.215.223]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qv2Di-008IPf-3D; Mon, 23 Oct 2023 21:12:20 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kwiboo.se; h=Content-Transfer-Encoding: MIME-Version: Message-ID: Date: Subject: Cc: To: From; q=dns/txt; s=fe-e1b5cab7be; t=1698095525; bh=EPCnxjTdpRw5P9F35T3qjQzzJlRqsS8bWZ4roLB5nXo=; b=gcNihjn2SE/Kg7pcvFvXdA5rphQHLWmJseBfsBDen6uO1LZNX9As3uLIo0NGIeX7FWOveDGzd 8AIwr2HbiQ7yo5pMNC++MjF5rF5XwVvW9jYd2+FWB4jvvoZjtxi5aS50GM9S+C1kprBR0VrF7WC HSrG1GKcFM4qPOOXlivj3DAClfqplBnlG1k6uUK+Spz0g3SeK6BnuLoT/THn+8EbUVG/ioFtm3j Bc/G9KDZrlAy6xcU8SG3ROR/BkTzpKQeYnuCT1kounkx5T64lxFVMgHz34pe2O+XMEblFf3yNiU 0HhtAKwsgC2iPChC7PKS8JGP6DJbp7qq/6wpF57upODA== From: Jonas Karlman To: Heiko Stuebner , Sandy Huang , David Airlie , Daniel Vetter Cc: Christopher Obbard , Jonas Karlman , dri-devel@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org, linux-rockchip@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH] drm/rockchip: vop: Fix color for RGB888/BGR888 format on VOP full Date: Mon, 23 Oct 2023 21:11:57 +0000 Message-ID: <20231023211158.424489-1-jonas@kwiboo.se> X-Mailer: git-send-email 2.42.0 MIME-Version: 1.0 X-Report-Abuse-To: abuse@forwardemail.net X-Report-Abuse: abuse@forwardemail.net X-Complaints-To: abuse@forwardemail.net X-ForwardEmail-Version: 0.4.40 X-ForwardEmail-Sender: rfc822; jonas@kwiboo.se, smtp.forwardemail.net, 149.28.215.223 X-ForwardEmail-ID: 6536e1a4b7c1916c16a25195 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231023_141219_072987_2047038B X-CRM114-Status: UNSURE ( 8.49 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Use of DRM_FORMAT_RGB888 and DRM_FORMAT_BGR888 on e.g. RK3288, RK3328 and RK3399 result in wrong colors being displayed. The issue can be observed using modetest: modetest -s @:1920x1080-60@RG24 modetest -s @:1920x1080-60@BG24 Vendor 4.4 kernel apply an inverted rb swap for these formats on VOP full (major = 3). Fix colors by applying rb swap similar to vendor 4.4 kernel. Signed-off-by: Jonas Karlman --- drivers/gpu/drm/rockchip/rockchip_drm_vop.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_vop.c b/drivers/gpu/drm/rockchip/rockchip_drm_vop.c index b3d0b6ae9294..a1ce09a22f83 100644 --- a/drivers/gpu/drm/rockchip/rockchip_drm_vop.c +++ b/drivers/gpu/drm/rockchip/rockchip_drm_vop.c @@ -247,14 +247,17 @@ static inline void vop_cfg_done(struct vop *vop) VOP_REG_SET(vop, common, cfg_done, 1); } -static bool has_rb_swapped(uint32_t format) +static bool has_rb_swapped(uint32_t version, uint32_t format) { switch (format) { case DRM_FORMAT_XBGR8888: case DRM_FORMAT_ABGR8888: - case DRM_FORMAT_BGR888: case DRM_FORMAT_BGR565: return true; + case DRM_FORMAT_RGB888: + return VOP_MAJOR(version) == 3; + case DRM_FORMAT_BGR888: + return VOP_MAJOR(version) != 3; default: return false; } @@ -1035,7 +1038,7 @@ static void vop_plane_atomic_update(struct drm_plane *plane, VOP_WIN_SET(vop, win, dsp_info, dsp_info); VOP_WIN_SET(vop, win, dsp_st, dsp_st); - rb_swap = has_rb_swapped(fb->format->format); + rb_swap = has_rb_swapped(vop->data->version, fb->format->format); VOP_WIN_SET(vop, win, rb_swap, rb_swap); /*