From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4D9CE1487CA; Mon, 22 Jan 2024 15:17:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705936645; cv=none; b=blbNV7h7LemAte6eobhkydc2qaOEr4WcUeAQk8Wei3C/8dhrSlOiLMoxXqpd6XbxBVyQ1X7l7kISr+F7WImPPer0ZxaK7fHl2H4iLa3LJe6iSIsbNLBqLJAFjAOEyBo3TqwhlBrGn/YFyQhBcJUXKfbYnW0xukuJXg98SZ2jW5g= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705936645; c=relaxed/simple; bh=RHgkWSYJcXcEx2L/5M8uPuxxgZbjcV9nKsnWU2sX2aY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=dbEea91fVOSumoOS8/DkypO1oAA5EsDhqy3fG+rUXxbLQH2v/udffa0dvbKkZmKKPLbQqSeXlCGfUE1qsnnX3SQOJRNuGVTVjVPOnBpKj7eKddgMlZF1JgfoDv4d0lbC8Cv31160mdwD2dkLmRIbhROXdS5WRxUHLiEZuV7RGdE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=NjIe4248; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="NjIe4248" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5D9F0C43399; Mon, 22 Jan 2024 15:17:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1705936644; bh=RHgkWSYJcXcEx2L/5M8uPuxxgZbjcV9nKsnWU2sX2aY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NjIe42482DgZ3flZb3z7yHa7Nsmap7ipJx7PcrhTlOy5Zpx9j+0ye0QF4eUNQNhS6 Sv4Bn889j6tpYGT0xFI/B0SbZOJ1wB8bnu8ZCIyTn2PcqF4h7bsvXORkYkrt1/Ydxt HBNh4F8esShRa14SxmIoJ04tSL9EfGR7M/uMBArcNDbeY0QkJBsOETo6ANHFP0RNPZ KMV5CRXGEVEeMgggwoXS4zsuS0NQE50kUusq1ioP79VD6pjzq7jHlzKLlI6rvTMees Irs4RmRTwtenN92Gins2A8pewMQXuRgiZC6+07udDqiCUFSB/Awu7i+dXxUCHJlx3U Z12dF7OHzW8jg== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Michael Tretter , Hans Verkuil , Sasha Levin , jacob-chen@iotwrt.com, ezequiel@vanguardiasur.com.ar, mchehab@kernel.org, heiko@sntech.de, linux-media@vger.kernel.org, linux-rockchip@lists.infradead.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH AUTOSEL 5.4 11/24] media: rockchip: rga: fix swizzling for RGB formats Date: Mon, 22 Jan 2024 10:16:25 -0500 Message-ID: <20240122151659.997085-11-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240122151659.997085-1-sashal@kernel.org> References: <20240122151659.997085-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore X-stable-base: Linux 5.4.267 Content-Transfer-Encoding: 8bit From: Michael Tretter [ Upstream commit 9e7dc39260edac180c206bb6149595a40eabae3e ] When using 32 bit RGB formats, the RGA on the rk3568 produces wrong colors as the wrong color channels are read or written. The reason is that the format description for the channel swizzeling is wrong and the wrong bits are configured. For example, when converting ARGB32 to NV12, the alpha channel is used as blue channel.. This doesn't happen if the color format is the same on both sides. Fix the color_swap settings of the formats to correctly handle 32 bit RGB formats. For RGA_COLOR_FMT_XBGR8888, the RGA_COLOR_ALPHA_SWAP bit doesn't have an effect. Thus, it isn't possible to handle the V4L2_PIX_FMT_XRGB32. Thus, it is removed from the list of supported formats. Signed-off-by: Michael Tretter Signed-off-by: Hans Verkuil Signed-off-by: Sasha Levin --- drivers/media/platform/rockchip/rga/rga.c | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/drivers/media/platform/rockchip/rga/rga.c b/drivers/media/platform/rockchip/rga/rga.c index e9ff12b6b5bb..302da68075b2 100644 --- a/drivers/media/platform/rockchip/rga/rga.c +++ b/drivers/media/platform/rockchip/rga/rga.c @@ -187,25 +187,16 @@ static int rga_setup_ctrls(struct rga_ctx *ctx) static struct rga_fmt formats[] = { { .fourcc = V4L2_PIX_FMT_ARGB32, - .color_swap = RGA_COLOR_RB_SWAP, + .color_swap = RGA_COLOR_ALPHA_SWAP, .hw_format = RGA_COLOR_FMT_ABGR8888, .depth = 32, .uv_factor = 1, .y_div = 1, .x_div = 1, }, - { - .fourcc = V4L2_PIX_FMT_XRGB32, - .color_swap = RGA_COLOR_RB_SWAP, - .hw_format = RGA_COLOR_FMT_XBGR8888, - .depth = 32, - .uv_factor = 1, - .y_div = 1, - .x_div = 1, - }, { .fourcc = V4L2_PIX_FMT_ABGR32, - .color_swap = RGA_COLOR_ALPHA_SWAP, + .color_swap = RGA_COLOR_RB_SWAP, .hw_format = RGA_COLOR_FMT_ABGR8888, .depth = 32, .uv_factor = 1, @@ -214,7 +205,7 @@ static struct rga_fmt formats[] = { }, { .fourcc = V4L2_PIX_FMT_XBGR32, - .color_swap = RGA_COLOR_ALPHA_SWAP, + .color_swap = RGA_COLOR_RB_SWAP, .hw_format = RGA_COLOR_FMT_XBGR8888, .depth = 32, .uv_factor = 1, -- 2.43.0