From patchwork Fri Jun 19 08:53:02 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?6buE5a626ZKX?= X-Patchwork-Id: 11613521 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E3C5B14B7 for ; Fri, 19 Jun 2020 08:53:27 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id C230A21527 for ; Fri, 19 Jun 2020 08:53:27 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="tpxN+dDN" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C230A21527 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=rock-chips.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-rockchip-bounces+patchwork-linux-rockchip=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:Message-Id:Date: Subject: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=lqwLoKTjVNWh6JTtrJEqpM+YlsMf2nR4267TdWXY5yo=; b=tpx N+dDN4Cxybzk7MpR0FqwXdIfnlyWdQpU+JCKvNudtICxHRSZyw2750qJCojg0HAEmaLPlUypaPahv nIYnimiPdQ2Z9PxIw2rzXdP1s5PGHD4gsAdF5FWvYFLhDMJWL+EiDsNbV3Ygq4H+MtFe8S6SJ8ESF zasGOoWvv3HmPV0kQ5vl3+AfdIi2Ouq6ZhafScF8u1H/WhplUd4SwvkpkqiexPEoEfz6/MknA8xd6 3wOHHS0WfBmRBocss/oRuuz9PXNOMOaJviLE5n6xa3Oe2K4F0Ic4FbJvXA5Y5x4kF/TAglysvSWcl DjiJKkhs47dDd23qpEJDf8nROllFONQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jmCm2-0002jB-Vu; Fri, 19 Jun 2020 08:53:22 +0000 Received: from lucky1.263xmail.com ([211.157.147.134]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1jmClr-0002YD-A5; Fri, 19 Jun 2020 08:53:12 +0000 Received: from localhost (unknown [192.168.167.209]) by lucky1.263xmail.com (Postfix) with ESMTP id 6ADA7BFCA3; Fri, 19 Jun 2020 16:53:05 +0800 (CST) X-MAIL-GRAY: 0 X-MAIL-DELIVERY: 1 X-ADDR-CHECKED4: 1 X-ANTISPAM-LEVEL: 2 X-ABS-CHECKED: 0 Received: from localhost.localdomain (unknown [58.22.7.114]) by smtp.263.net (postfix) whith ESMTP id P10491T139788078274304S1592556784649283_; Fri, 19 Jun 2020 16:53:05 +0800 (CST) X-IP-DOMAINF: 1 X-UNIQUE-TAG: <01c70fabecef316f33fcc8cfd259d260> X-RL-SENDER: hjc@rock-chips.com X-SENDER: hjc@rock-chips.com X-LOGIN-NAME: hjc@rock-chips.com X-FST-TO: heiko@sntech.de X-SENDER-IP: 58.22.7.114 X-ATTACHMENT-NUM: 0 X-DNS-TYPE: 0 X-System-Flag: 0 From: Sandy Huang To: heiko@sntech.de, Sandy Huang , David Airlie , Daniel Vetter Subject: [PATCH v2] drm/rockchip: vop: fix vop full rgb24 r/b color error Date: Fri, 19 Jun 2020 16:53:02 +0800 Message-Id: <20200619085302.2263-1-hjc@rock-chips.com> X-Mailer: git-send-email 2.17.1 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200619_015311_538499_55039E9F X-CRM114-Status: GOOD ( 12.29 ) X-Spam-Score: 1.5 (+) X-Spam-Report: SpamAssassin version 3.4.4 on bombadil.infradead.org summary: Content analysis details: (1.5 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [211.157.147.134 listed in list.dnswl.org] 1.5 RCVD_IN_SORBS_WEB RBL: SORBS: sender is an abusable web server [58.22.7.114 listed in dnsbl.sorbs.net] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.0 T_SPF_PERMERROR SPF: test of record failed (permerror) -0.0 RCVD_IN_MSPIKE_H2 RBL: Average reputation (+2) [211.157.147.134 listed in wl.mailspike.net] X-BeenThere: linux-rockchip@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Upstream kernel work for Rockchip platforms List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: huangtao@rock-chips.com, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-rockchip@lists.infradead.org, andy.yan@rock-chips.com, linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "Linux-rockchip" Errors-To: linux-rockchip-bounces+patchwork-linux-rockchip=patchwork.kernel.org@lists.infradead.org RGB888 format msb is red component and the lsb is blue component, at vop full platform this is swapped, and this is different from vop lite and vop next, so add this patch to fix it. v2: move to has_rb_swapped() function. Signed-off-by: Sandy Huang --- drivers/gpu/drm/rockchip/rockchip_drm_vop.c | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_vop.c b/drivers/gpu/drm/rockchip/rockchip_drm_vop.c index c80f7d9fd13f..99bdb5a2a185 100644 --- a/drivers/gpu/drm/rockchip/rockchip_drm_vop.c +++ b/drivers/gpu/drm/rockchip/rockchip_drm_vop.c @@ -132,6 +132,7 @@ struct vop_win { struct rockchip_rgb; struct vop { + uint32_t version; struct drm_crtc crtc; struct device *dev; struct drm_device *drm_dev; @@ -248,17 +249,28 @@ 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(struct vop *vop, uint32_t format) { + bool rb_swapped; + switch (format) { case DRM_FORMAT_XBGR8888: case DRM_FORMAT_ABGR8888: case DRM_FORMAT_BGR888: case DRM_FORMAT_BGR565: - return true; + rb_swapped = true; default: - return false; + rb_swapped = false; } + + /* + * VOP full need to do rb swap to show rgb888/bgr888 format color correctly + */ + if ((format == DRM_FORMAT_RGB888 || format == DRM_FORMAT_BGR888) && + VOP_MAJOR(vop->version) == 3) + rb_swapped = !rb_swapped; + + return rb_swapped; } static enum vop_data_format vop_convert_format(uint32_t format) @@ -988,7 +1000,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, fb->format->format); VOP_WIN_SET(vop, win, rb_swap, rb_swap); /* @@ -2091,6 +2103,7 @@ static int vop_bind(struct device *dev, struct device *master, void *data) vop->dev = dev; vop->data = vop_data; vop->drm_dev = drm_dev; + vop->version = vop_data->version; dev_set_drvdata(dev, vop); vop_win_init(vop);