From patchwork Thu Oct 26 19:14:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonas Karlman X-Patchwork-Id: 13437830 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 8CD65C25B48 for ; Thu, 26 Oct 2023 19:15:58 +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=m3T9sRKpNSiqqdqBx3pMkBqLf2yS7aIg9B39o3csHLs=; b=qh6xn9N8pDZta/ jgRszh9fC4ai2SsyoDinlewgEYj9kE4fKfJgAUaEiIlwa/sSQGT1U60dj3NUaTsIgXXP5tLnFk+9Y ODplyZwioKBpoja6HlA2C2C/mkaYiZEkANzd9T8c9mf7P8jt7stEN8dUreF8xU3hrNc6ySbv5u6uj DVVjzvXdlloXWGkLRrHfh5nf5pCA/B4mY5uoaqMd/DtpWAQyWFF/cPpjFfkyru03Q3yRg/HPD6fA2 ZXrjPrERkKiW73Yxs9tYbnKE3gOlFCkJfAWeWhxAMKf9OlMiX50tDWPccB34hR8Jn4qrWFWuZq255 H5xSr4zbch3yY3VlkYTA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qw5pQ-00F2mU-1L; Thu, 26 Oct 2023 19:15:36 +0000 Received: from smtp.forwardemail.net ([167.172.40.54]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qw5pN-00F2kE-05; Thu, 26 Oct 2023 19:15:35 +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=1698347709; bh=H5xROb9Mq7jaJ0zsDNHjRXkPAmzwRa/v5qsxfjL/qww=; b=JugZH+SXup/DsE/dVZgeHKhyg4eX7mPMlLki3IZih3gTapClZ4jt77etp4Si5UEH/A3BqpENj OidNxRWO5888fxv9dQVt3lHoMoHkicjnP3+WarXPkrvMGqPDbfijDNjjCuwUG+jH3Gtp5LzsdiB HtAi807oEu4GkGZLVanKWqmQW3XJdGhpy2Fsz7xLJxyt1ZyHGZttesqIk3zr8EzJtICJZdMXiH0 LMtg5CtpYFhhnEdSwe9pesBSvcnNpY5UHbbJcw4H+dyrdKjLyTH6ys5t/QkRa8k8hyUtkfA5O9J 8jZKfwKBY+4y+/n7DHEA2wfVrWFd//nQEX5X0AvJC3Rg== From: Jonas Karlman To: Heiko Stuebner , Sandy Huang , David Airlie , Daniel Vetter , Tomasz Figa Cc: Christopher Obbard , Andy Yan , 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 v2] drm/rockchip: vop: Fix color for RGB888/BGR888 format on VOP full Date: Thu, 26 Oct 2023 19:14:58 +0000 Message-ID: <20231026191500.2994225-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, 167.172.40.54 X-ForwardEmail-ID: 653ababbbb49096ed18860ca X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231026_121533_996779_D2FBF66A X-CRM114-Status: GOOD ( 10.34 ) 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 framework (IP version 3.x) compared to VOP little framework (2.x). Fix colors by applying different rb swap for VOP full framework (3.x) and VOP little framework (2.x) similar to vendor 4.4 kernel. Fixes: 85a359f25388 ("drm/rockchip: Add BGR formats to VOP") Signed-off-by: Jonas Karlman Reviewed-by: Christopher Obbard Tested-by: Christopher Obbard Tested-by: Diederik de Haas --- Changes in v2: - Add comment about different rb swap for IP version 3.x and 2.x - Add fixes tag drivers/gpu/drm/rockchip/rockchip_drm_vop.c | 14 +++++++++++--- 1 file changed, 11 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..ed2ed25959a2 100644 --- a/drivers/gpu/drm/rockchip/rockchip_drm_vop.c +++ b/drivers/gpu/drm/rockchip/rockchip_drm_vop.c @@ -247,14 +247,22 @@ 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; + /* + * full framework (IP version 3.x) only need rb swapped for RGB888 and + * little framework (IP version 2.x) only need rb swapped for BGR888, + * check for 3.x to also only rb swap BGR888 for unknown vop version + */ + case DRM_FORMAT_RGB888: + return VOP_MAJOR(version) == 3; + case DRM_FORMAT_BGR888: + return VOP_MAJOR(version) != 3; default: return false; } @@ -1035,7 +1043,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); /*