Received: by 2002:a05:7412:a9a2:b0:e2:908c:2ebd with SMTP id o34csp682181rdh; Thu, 26 Oct 2023 12:37:23 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFl7uCFnvm4BnABCL/uOzQaLfHcAjR62LgEl0sCo7wTrle4cfg1qX5QV1ZyaUTh4FJHUJZ/ X-Received: by 2002:a81:7641:0:b0:59b:bd55:8452 with SMTP id j1-20020a817641000000b0059bbd558452mr429019ywk.36.1698349043002; Thu, 26 Oct 2023 12:37:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698349042; cv=none; d=google.com; s=arc-20160816; b=N5omL5e51avXabDuK99cSSdTh0Ck+ySNelrjbCkurXSLbF3DJSEtFDwAa1wLyoTt/R XDTihNLSJGeVY5NCQ5x+yrs6i+WRUVCCPwFmyTeWUrUWaP1EJ8LIj7EYqu/HtEaWfCYQ y6nwWL7pm7LKqtWI1fPymdX71UaJhHEbj7n3O7C/fFTm6kIRQaxZtYkFFcNFO9PvTQpS 7uEESykzNN/QOvfihjcQUAenNzZsvhLPlEea9UAC5Zyf3ao56la0CtKHuWx/aTEaMErk yhaeIdzQonGrcK7K9X625zk/IP7ZUq5zBd0JUv5lD+VfLMYev8NMa5Q7jrrdEyp3ZWgH kz1A== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=H5xROb9Mq7jaJ0zsDNHjRXkPAmzwRa/v5qsxfjL/qww=; fh=T1aRxEdO+pLInG8G6g+Z2aWEdLWBuwhNexbBKYdniGI=; b=i4vJNQltNiG1sQ23akyiMF9+9fMw9gr8htRPVMXLbE7UyPE9EB3ZZqSEbyuYvCZgpn 8qk0+HvxDc8DoiBq6WB5xsjlTh7OvaG6Q3nKWHl3QrrqxNEsALPmI0/UCQYdlPRlY2pM FMzHotQeHy7QkzJlOT38FAh9v6oCT894oyoQMlZWrqOYdeTNjqt6/arQIQpsw8x1WNGS El/DvFqoAMGHW29hEYrdYURuxBC0cWY0c5eBI9PqMO0E5H3n/9XuoRUvjb8UilBjbnwC +Q6RYPqikLYD4LIwzjAIylro4FfQC1dK/KtHcGVKRpzRq57xu9+PCk70oVY6atPMcMT9 njIA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kwiboo.se header.s=fe-e1b5cab7be header.b=POM6mqM7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kwiboo.se Return-Path: Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id v66-20020a818545000000b0054fdf854b93si14817669ywf.576.2023.10.26.12.37.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Oct 2023 12:37:22 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@kwiboo.se header.s=fe-e1b5cab7be header.b=POM6mqM7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kwiboo.se Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 4F95D80417CA; Thu, 26 Oct 2023 12:36:44 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231890AbjJZTgl (ORCPT + 99 others); Thu, 26 Oct 2023 15:36:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41426 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231841AbjJZTgk (ORCPT ); Thu, 26 Oct 2023 15:36:40 -0400 X-Greylist: delayed 652 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Thu, 26 Oct 2023 12:36:37 PDT Received: from smtp.forwardemail.net (smtp.forwardemail.net [149.28.215.223]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5B3A8121 for ; Thu, 26 Oct 2023 12:36:37 -0700 (PDT) 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=1698348995; bh=H5xROb9Mq7jaJ0zsDNHjRXkPAmzwRa/v5qsxfjL/qww=; b=POM6mqM7qlNC3MLnjaGw7voec3OKp5nDEb3R/KN1i+PwynTHF0dyWPlF1p/C04FESVi462gUr Uggf/CrGpOKpfDqvyQbKqW0hsHqO/fIVFVGhe7qE3/GcOvX9xQpiJ9IbPK/comawHDvXSdZH2uQ yL8lMxixjEmPwfyMRzrpJ5+M/Jo647WDueY4lJ6zzgZGROCtGE2pPTPJCqIPgjoN4ZopgArrpqC 6QFvG3K5C42pH8QdLu/VZwUN/YLYGdxLuMDMH+9VOiHtCFHPrvrkHz4V5drDwGIGpvjA4USoPFn LBpDdwEEWZ2gH/BobIAz/r1nyByMrr3zOC4RE40Qu3dw== 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 Content-Transfer-Encoding: 8bit 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: 653ababbbb49096ed18860ca X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED 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 X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Thu, 26 Oct 2023 12:36:44 -0700 (PDT) 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 --- 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); /* -- 2.42.0