From nobody Fri Oct 10 20:50:12 2025 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 979DD23C50F; Thu, 12 Jun 2025 12:53:54 +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=1749732834; cv=none; b=dHdkSrt5gD/DqTY9IkVhHZVLzqMWl9oHiDLKsqpRZ+JdEPCKvQL+08IU4rhH1688y3ASmLYxhSsdHNOKUAkPyhQ4/I1zSmcxG2nA30DO0epBavzrU+RL/CKkXoV0X05FaFsbu3p8+icXJyigwI9rg+Gd/lsIsOvNEwjnnNBShSs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749732834; c=relaxed/simple; bh=7G0cws/Pe3XBneIH9rCyYiUV0a/VekpAv58Mjc90PL4=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=BDBaBmEYNnI3DDOb0k1iy8Z+HD0aDkZ3YiBRjMs54GU6yDdVauw256MqsunrxHRgKvwnMxqRBF9sDRoao/Y+D3wGQtahSeAef5sdMde/0I/InMbQuWz7HVMZarSEFnYy3hfzwJbIRyvu3zTLsOb83Rg5M9TDhprY3cwhFAkykec= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=mrlBzqse; 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="mrlBzqse" Received: by smtp.kernel.org (Postfix) with ESMTPSA id AACF9C4CEEA; Thu, 12 Jun 2025 12:53:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1749732834; bh=7G0cws/Pe3XBneIH9rCyYiUV0a/VekpAv58Mjc90PL4=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=mrlBzqsepPzF+PUq2GYU6LkukotyTI9pvbrzSEyORk0GhF1O6IRtG5L6eIE4y34WV H10P24rpp62YDB5pogFudZUX26qKBXIc1DHjJ+ltBFcSoVo0xSNEHwWJv6wLi/vz6u GSFofoG0AO672D9MKDT3z9TZbzyo27zU1gmhXNN7MzhSc1VlwJXRWXI0ueetPUeF9C qTA2ds2MAMvOZ1RdmIbwATwyK7oSZzZzRXrwesV3TOmioaRGSQGY9jRkDLB4Jm3ZA8 YOusdhpApujsWiORti/tAqHbWRiky/JlSpCha9XgDrALGuVQdIgDHMBwZe0JNHj0Ap EOockdCOGsFRQ== From: Maxime Ripard Date: Thu, 12 Jun 2025 14:53:39 +0200 Subject: [PATCH 1/4] media: uapi: Clarify MBUS color component order for serial buses Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250612-csi-bgr-rgb-v1-1-dc8a309118f8@kernel.org> References: <20250612-csi-bgr-rgb-v1-0-dc8a309118f8@kernel.org> In-Reply-To: <20250612-csi-bgr-rgb-v1-0-dc8a309118f8@kernel.org> To: Mauro Carvalho Chehab , Hans Verkuil , Mats Randgaard , Alain Volmat , Sakari Ailus Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, Hans Verkuil , Dave Stevenson , Maxime Ripard X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=2324; i=mripard@kernel.org; h=from:subject:message-id; bh=7G0cws/Pe3XBneIH9rCyYiUV0a/VekpAv58Mjc90PL4=; b=owGbwMvMwCmsHn9OcpHtvjLG02pJDBleZ2+VbD3x6+z+//mCC3k8Px+p3r5LcIP908Oca6PuL jFy3+7t1DGVhUGYk0FWTJHliUzY6eXti6sc7Ff+gJnDygQyhIGLUwAmMoefsT69t7dDWXBVYPiF RRxzs2dYz+jdkHTOMXvR7mvqHbY6PLtfNR+x7HLZPCP+SF76z7vWoowNt7t6XjXV7HroHP286Mu HVTw3CoSMnu9I0g+QvlawU8pA8WLWvW1vNNnC1FXvvNiwKnYTAA== X-Developer-Key: i=mripard@kernel.org; a=openpgp; fpr=BE5675C37E818C8B5764241C254BCFC56BF6CE8D The subdev format documentation has a subsection describing how to use the media bus pixel codes for serial buses. While it describes the sampling part well, it doesn't really describe the current convention used for the components order. Let's improve that. Signed-off-by: Maxime Ripard --- Documentation/userspace-api/media/v4l/subdev-formats.rst | 14 ++++++++----= -- 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/Documentation/userspace-api/media/v4l/subdev-formats.rst b/Doc= umentation/userspace-api/media/v4l/subdev-formats.rst index 2a94371448dc07e5c7097421bd82f42dcd7e21aa..8e92f784abd8123f9ea950f954a= 60af56ee76dbe 100644 --- a/Documentation/userspace-api/media/v4l/subdev-formats.rst +++ b/Documentation/userspace-api/media/v4l/subdev-formats.rst @@ -158,16 +158,18 @@ formats in memory (a raw Bayer image won't be magical= ly converted to JPEG just by storing it to memory), there is no one-to-one correspondence between them. =20 The media bus pixel codes document parallel formats. Should the pixel data= be transported over a serial bus, the media bus pixel code that describes a -parallel format that transfers a sample on a single clock cycle is used. F= or -instance, both MEDIA_BUS_FMT_BGR888_1X24 and MEDIA_BUS_FMT_BGR888_3X8 are = used -on parallel busses for transferring an 8 bits per sample BGR data, whereas= on -serial busses the data in this format is only referred to using -MEDIA_BUS_FMT_BGR888_1X24. This is because there is effectively only a sin= gle -way to transport that format on the serial busses. +parallel format that transfers a sample on a single clock cycle is used. T= he +color component order used is the same used on the serial bus. For instanc= e, +both MEDIA_BUS_FMT_BGR888_1X24 and MEDIA_BUS_FMT_BGR888_3X8 are used on pa= rallel +busses for transferring an 8 bits per sample BGR data, whereas on serial b= usses +the data in this format is only referred to using MEDIA_BUS_FMT_BGR888_1X2= 4, +with BGR meaning that the blue component is transmitted first, then green,= then +red. This is because there is effectively only a single way to transport t= hat +format on the serial busses. =20 Packed RGB Formats ^^^^^^^^^^^^^^^^^^ =20 Those formats transfer pixel data as red, green and blue components. The --=20 2.49.0 From nobody Fri Oct 10 20:50:12 2025 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 88D0323D2AE; Thu, 12 Jun 2025 12:53:57 +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=1749732837; cv=none; b=E+dDDLMVePhg+POjRAQx0r3MCb1dJeYVxQegXaKVREXOAom0hTIOhKe2m9KXr7pB3QlKO/BiyaW6ivh3twvnK1B07/R+JDQl0Wm1mfxxnh8XhtnIX2AYs4ic6Hv9iGfQy8d70PCeMgcFPTChJCZIorhMX6vb/bV6lZTNjnCZlgI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749732837; c=relaxed/simple; bh=VrIIKM49InaDKrW7YQ8qvCLpsKEgvUI8aQjOX9xkdWE=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=AdCk66t+fbcApRFHy8ZvxyCERXDVxq3K3a53EREJ4GlhEFJsPWwP3HYg3sHbP+C8BJEvLMUhsL1DTy2NRNcX1s0WL7HkogbYfJI6KHvm8pcmdmte8dHm/PUtg7BvW0zHi3iEsPUi1NveU+LNnEkhRBLtkkF7C5hrR+2qew6l36I= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Rm721y7a; 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="Rm721y7a" Received: by smtp.kernel.org (Postfix) with ESMTPSA id B9A12C4CEEA; Thu, 12 Jun 2025 12:53:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1749732837; bh=VrIIKM49InaDKrW7YQ8qvCLpsKEgvUI8aQjOX9xkdWE=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=Rm721y7a04n7T3K4l7/E2hUB5SzKBg3Qw1L2tLURmBfoSBoxbpLUCHGGYfe6+BYtP 8jiY8rfo5e9TETtZJOCMfq4FM5e0O8GmkcG0f7HGBq7V0YHIkvkKGrzWsan6UrRn0o ZSrdel68J+aBNUkD4uTH8XS2DEtlnSpMHC5Dain2DhQ40+77IFbRCTatw0CcFMxA3r sYi4SbyhRRI6pNuS1kANYLYfiRshAUI5jCP3hI1mYZDMPRuS2QhatYmeSv+yWXjl3n 25KbKaEu5oDUze+T/wbmPDpHl7LaZXWvy7rXRElUmRZIK8+v/qMj0l9NlThA9FFvAZ 3VXMCeY6LpchA== From: Maxime Ripard Date: Thu, 12 Jun 2025 14:53:40 +0200 Subject: [PATCH 2/4] media: uapi: Introduce MEDIA_BUS_FMT_BGR565_1X16 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250612-csi-bgr-rgb-v1-2-dc8a309118f8@kernel.org> References: <20250612-csi-bgr-rgb-v1-0-dc8a309118f8@kernel.org> In-Reply-To: <20250612-csi-bgr-rgb-v1-0-dc8a309118f8@kernel.org> To: Mauro Carvalho Chehab , Hans Verkuil , Mats Randgaard , Alain Volmat , Sakari Ailus Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, Hans Verkuil , Dave Stevenson , Maxime Ripard X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=3098; i=mripard@kernel.org; h=from:subject:message-id; bh=VrIIKM49InaDKrW7YQ8qvCLpsKEgvUI8aQjOX9xkdWE=; b=owGbwMvMwCmsHn9OcpHtvjLG02pJDBleZ2+fPLrjWOht7qkfFPZEzS0Uu/n789tZs76YMnU+f bFkz9tVnR1TWRiEORlkxRRZnsiEnV7evrjKwX7lD5g5rEwgQxi4OAVgIhF+jA3LKl9Ff/esVxXO 7Xv5a0rNmYCTPz+YzdjAvrXGTOykCvNG0Zb19UJLeKLy8/y8+ts7TRnr034cF5LZcSngeejsh1d k5m7/O23Guzee3H2OF5XTjxi4Bd93OhjE8Y7/69zfnwvbvigoAAA= X-Developer-Key: i=mripard@kernel.org; a=openpgp; fpr=BE5675C37E818C8B5764241C254BCFC56BF6CE8D MIPI-CSI2 sends its RGB format on the wire with the blue component first, then green, then red. MIPI calls that format "RGB", but by v4l2 conventions it would be BGR. MIPI-CSI2 supports three RGB variants: 444, 555, 565, 666 and 888. We already have BGR666 and BGR888 media bus formats, we don't have any CSI transceivers using the 444 and 555 variants, but some transceivers use the CSI RGB565 format, while using the RGB656 media bus code. That's a mistake, but since we don't have a BGR656 media bus code we need to introduce one before fixing it. Signed-off-by: Maxime Ripard --- .../userspace-api/media/v4l/subdev-formats.rst | 37 ++++++++++++++++++= ++++ include/uapi/linux/media-bus-format.h | 3 +- 2 files changed, 39 insertions(+), 1 deletion(-) diff --git a/Documentation/userspace-api/media/v4l/subdev-formats.rst b/Doc= umentation/userspace-api/media/v4l/subdev-formats.rst index 8e92f784abd8123f9ea950f954a60af56ee76dbe..def0d24ef6cdb1a2ec9395af146= 8f56adf31a8de 100644 --- a/Documentation/userspace-api/media/v4l/subdev-formats.rst +++ b/Documentation/userspace-api/media/v4l/subdev-formats.rst @@ -625,10 +625,47 @@ The following tables list existing packed RGB formats. - b\ :sub:`4` - b\ :sub:`3` - b\ :sub:`2` - b\ :sub:`1` - b\ :sub:`0` + * .. _MEDIA-BUS-FMT-BGR565-1X16: + + - MEDIA_BUS_FMT_BGR565_1X16 + - 0x1028 + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - b\ :sub:`4` + - b\ :sub:`3` + - b\ :sub:`2` + - b\ :sub:`1` + - b\ :sub:`0` + - g\ :sub:`5` + - g\ :sub:`4` + - g\ :sub:`3` + - g\ :sub:`2` + - g\ :sub:`1` + - g\ :sub:`0` + - r\ :sub:`4` + - r\ :sub:`3` + - r\ :sub:`2` + - r\ :sub:`1` + - r\ :sub:`0` * .. _MEDIA-BUS-FMT-BGR565-2X8-BE: =20 - MEDIA_BUS_FMT_BGR565_2X8_BE - 0x1005 - diff --git a/include/uapi/linux/media-bus-format.h b/include/uapi/linux/med= ia-bus-format.h index ff62056feed5b6588bfcfdff178f5b68eecd3a26..a73d91876d31844bf8c2da91dde= a541181840bd2 100644 --- a/include/uapi/linux/media-bus-format.h +++ b/include/uapi/linux/media-bus-format.h @@ -32,17 +32,18 @@ * new pixel codes. */ =20 #define MEDIA_BUS_FMT_FIXED 0x0001 =20 -/* RGB - next is 0x1028 */ +/* RGB - next is 0x1029 */ #define MEDIA_BUS_FMT_RGB444_1X12 0x1016 #define MEDIA_BUS_FMT_RGB444_2X8_PADHI_BE 0x1001 #define MEDIA_BUS_FMT_RGB444_2X8_PADHI_LE 0x1002 #define MEDIA_BUS_FMT_RGB555_2X8_PADHI_BE 0x1003 #define MEDIA_BUS_FMT_RGB555_2X8_PADHI_LE 0x1004 #define MEDIA_BUS_FMT_RGB565_1X16 0x1017 +#define MEDIA_BUS_FMT_BGR565_1X16 0x1028 #define MEDIA_BUS_FMT_BGR565_2X8_BE 0x1005 #define MEDIA_BUS_FMT_BGR565_2X8_LE 0x1006 #define MEDIA_BUS_FMT_RGB565_2X8_BE 0x1007 #define MEDIA_BUS_FMT_RGB565_2X8_LE 0x1008 #define MEDIA_BUS_FMT_RGB666_1X18 0x1009 --=20 2.49.0 From nobody Fri Oct 10 20:50:12 2025 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 64A5C242D74; Thu, 12 Jun 2025 12:54:00 +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=1749732840; cv=none; b=u8nzp6EtiVs6ymJ19EUH8gsFKGUnHtp2+2tz/em5vEWMLLHk5PpmgB1a7NU4pMNANcFSoc8rVKsQOAw3j/LMXK+DZfgZPDaGK5bs6RHRWEqPKSAHUax0BCVNeqzZ6vXChciLmBPKokaJzgKi5fcIBb1RnSlPBJhOkIzEGY/yqq0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749732840; c=relaxed/simple; bh=ZBCgrd9sHXn1llOMmgl1QZ1JUWMTyWciOFWEbRfQRz8=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=F4CIaHoSlhpSJCSHz+UTte+ZBB9KzcoEUnsYC4UrGaUHTTmXiFPiXUMK2g5z2rRkNttafpeNdQoSZYaK8UoI81xLlGSEafkqAzp5UqtxIX6F2IQ0mt9+LR2GzpOBHEJHSYvBZge58hclpX9YbR1r84HAfcGbR0O1C+nhRuY/cZ0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=a9KSBiqt; 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="a9KSBiqt" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8CEA5C4CEED; Thu, 12 Jun 2025 12:53:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1749732839; bh=ZBCgrd9sHXn1llOMmgl1QZ1JUWMTyWciOFWEbRfQRz8=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=a9KSBiqtIb3cobtv+erAVdJxYqcwDZ8j1i9Mce7vV7rjD6PkvBu+9Mx6yRj99Cr6V 965tCb/soPJDXAS/G4eNGjX/bL475/Q4ltePVtrZut6KwRIvIuEkouPHaxYIqWgn64 sO718mm9R64V/Tw0mVjS+v7fELkWdFCyo52MwZoar4/NDWg2LIu789z4SgBR4lO354 2QDDr1ABbOV7JS2lY3G8YPlgiG9WTE1QNKbWK46epluiLELY28wP1s2Whs7Ii2V3Lv QzzQU3nK5r3L9mULdnw2vXMhGffINKAB+5y+R/clxzcbdeRqhEZEDzGAb/RccUjFNB 9yEXN6fGSpG7w== From: Maxime Ripard Date: Thu, 12 Jun 2025 14:53:41 +0200 Subject: [PATCH 3/4] media: tc358743: Fix the RGB MBUS format Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250612-csi-bgr-rgb-v1-3-dc8a309118f8@kernel.org> References: <20250612-csi-bgr-rgb-v1-0-dc8a309118f8@kernel.org> In-Reply-To: <20250612-csi-bgr-rgb-v1-0-dc8a309118f8@kernel.org> To: Mauro Carvalho Chehab , Hans Verkuil , Mats Randgaard , Alain Volmat , Sakari Ailus Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, Hans Verkuil , Dave Stevenson , Maxime Ripard X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=3407; i=mripard@kernel.org; h=from:subject:message-id; bh=ZBCgrd9sHXn1llOMmgl1QZ1JUWMTyWciOFWEbRfQRz8=; b=kA0DAAkTJ1/OGaI9vnYByyZiAGhKzduh3pZnJKDgORyDuF5Soo86AukCh2BiJ0G4eYd43L1iz oiVBAATCQAdFiEE5BxWy6eHo3pAP6n4J1/OGaI9vnYFAmhKzdsACgkQJ1/OGaI9vnZZawGAk/09 eRSuD0w7WvMj1ZufjA1Tpr1hHnhInO2HCaLPHKfhb+4Zw4UX3ovko0JhMXMpAYCMBCAZfl2sWpd Myc9L64zukiNoTQoFV0QmQXu+rzUhW6PwI6hIk4U+fu9xmzg1EUI= X-Developer-Key: i=mripard@kernel.org; a=openpgp; fpr=BE5675C37E818C8B5764241C254BCFC56BF6CE8D The tc358743 is an HDMI to MIPI-CSI2 bridge. It supports two of the three HDMI 1.4 video formats: RGB 4:4:4 and YCbCr 422. RGB 4:4:4 is converted to the MIPI-CSI2 RGB888 video format, and listed in the driver as MEDIA_BUS_FMT_RGB888_1X24. Most CSI2 receiver drivers then map MEDIA_BUS_FMT_RGB888_1X24 to V4L2_PIX_FMT_RGB24. However, V4L2_PIX_FMT_RGB24 is defined as having its color components in the R, G and B order, from left to right. MIPI-CSI2 however defines the RGB888 format with blue first. This essentially means that the R and B will be swapped compared to what V4L2_PIX_FMT_RGB24 defines. The proper MBUS format would be BGR888, so let's use that. Fixes: d32d98642de6 ("[media] Driver for Toshiba TC358743 HDMI to CSI-2 bri= dge") Signed-off-by: Maxime Ripard --- drivers/media/i2c/tc358743.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/media/i2c/tc358743.c b/drivers/media/i2c/tc358743.c index ca0b0b9bda1755313f066ba36ab218873b9ae438..a1c164a7716a10b0cb9ff38f88c= 0513b45f24771 100644 --- a/drivers/media/i2c/tc358743.c +++ b/drivers/media/i2c/tc358743.c @@ -688,11 +688,11 @@ static void tc358743_set_csi_color_space(struct v4l2_= subdev *sd) mutex_lock(&state->confctl_mutex); i2c_wr16_and_or(sd, CONFCTL, ~MASK_YCBCRFMT, MASK_YCBCRFMT_422_8_BIT); mutex_unlock(&state->confctl_mutex); break; - case MEDIA_BUS_FMT_RGB888_1X24: + case MEDIA_BUS_FMT_BGR888_1X24: v4l2_dbg(2, debug, sd, "%s: RGB 888 24-bit\n", __func__); i2c_wr8_and_or(sd, VOUT_SET2, ~(MASK_SEL422 | MASK_VOUT_422FIL_100) & 0xff, 0x00); i2c_wr8_and_or(sd, VI_REP, ~MASK_VOUT_COLOR_SEL & 0xff, @@ -1353,11 +1353,11 @@ static int tc358743_log_status(struct v4l2_subdev *= sd) (i2c_rd16(sd, CSI_STATUS) & MASK_S_HLT) ? "yes" : "no"); v4l2_info(sd, "Color space: %s\n", state->mbus_fmt_code =3D=3D MEDIA_BUS_FMT_UYVY8_1X16 ? "YCbCr 422 16-bit" : - state->mbus_fmt_code =3D=3D MEDIA_BUS_FMT_RGB888_1X24 ? + state->mbus_fmt_code =3D=3D MEDIA_BUS_FMT_BGR888_1X24 ? "RGB 888 24-bit" : "Unsupported"); =20 v4l2_info(sd, "-----%s status-----\n", is_hdmi(sd) ? "HDMI" : "DVI-D"); v4l2_info(sd, "HDCP encrypted content: %s\n", hdmi_sys_status & MASK_S_HDCP ? "yes" : "no"); @@ -1691,11 +1691,11 @@ static int tc358743_enum_mbus_code(struct v4l2_subd= ev *sd, struct v4l2_subdev_state *sd_state, struct v4l2_subdev_mbus_code_enum *code) { switch (code->index) { case 0: - code->code =3D MEDIA_BUS_FMT_RGB888_1X24; + code->code =3D MEDIA_BUS_FMT_BGR888_1X24; break; case 1: code->code =3D MEDIA_BUS_FMT_UYVY8_1X16; break; default: @@ -1753,11 +1753,11 @@ static int tc358743_set_fmt(struct v4l2_subdev *sd, =20 if (ret) return ret; =20 switch (code) { - case MEDIA_BUS_FMT_RGB888_1X24: + case MEDIA_BUS_FMT_BGR888_1X24: case MEDIA_BUS_FMT_UYVY8_1X16: break; default: return -EINVAL; } @@ -2172,11 +2172,11 @@ static int tc358743_probe(struct i2c_client *client) sd->entity.function =3D MEDIA_ENT_F_VID_IF_BRIDGE; err =3D media_entity_pads_init(&sd->entity, 1, &state->pad); if (err < 0) goto err_hdl; =20 - state->mbus_fmt_code =3D MEDIA_BUS_FMT_RGB888_1X24; + state->mbus_fmt_code =3D MEDIA_BUS_FMT_BGR888_1X24; =20 sd->dev =3D &client->dev; =20 mutex_init(&state->confctl_mutex); =20 --=20 2.49.0 From nobody Fri Oct 10 20:50:12 2025 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 4DF692459D4; Thu, 12 Jun 2025 12:54:02 +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=1749732843; cv=none; b=GP5vV82+I9etL4Tsn2oZh3TTSqCR76y6GjjEm0VEeSIxM+YKX1VzfWslf68eoN1aYVRD2NDNMD9O2Y7TycgfSdJPO75Y5JYeas2CWptTS+hsVSUHCe3Q/Oe6luB0f0f+y4wocb1Y/uTFOBO8190/CPl410FGbZSg9OLjpPLDthc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749732843; c=relaxed/simple; bh=qi5lfHwQHhJGRjqK2zsDjKYabHNZy+zeTYkiDzXpm7c=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=c989LvKcb4LkLSjLhLiYQXUxjCg4bOMQwGhfXFGZVMoPLLdQqekY4um7KN6mQIgkxAcUem+2HHaZc6oruVgQHSxIz12Glv2Zcj9m4s2WR9S4j8UKKH3RQv+bXx1YjqYTB0GdLCfy+q5cbPP91grKKQiIYBBWEOpMKrXnXD751eU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=tsBSimhI; 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="tsBSimhI" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 809E9C4CEEA; Thu, 12 Jun 2025 12:54:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1749732842; bh=qi5lfHwQHhJGRjqK2zsDjKYabHNZy+zeTYkiDzXpm7c=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=tsBSimhIJ5dk+rnIBtVQDgOX4s1Wj9N3wHF/QVwIpSiNUULxoXVT0X9gn1uImpTwc tgl0MD2h2KAS3x1asGEcvyL/bhZDGa/+fP689ptZHREqBqpUd1DgXeiG52Y7l1Jkz0 hyMHoG2fZ2Hyysr/ws1jHRITl8q9vreegHVUopnZh3wVEzsHGVgZOQCf0DGVIlibIT udNZnxvQm8REoGpDJx7KMBneJ3z9kCGWZN8SQ5JD9Hh606eLnTVYe5ry3V1X29OycM 56m+8m2r9J4ixucy+Hb92A87D5rW6AuQTsbkkb5HK6sRV9cOsd82nUhhsj6XzvjqX6 XDZ2S9U3CexMA== From: Maxime Ripard Date: Thu, 12 Jun 2025 14:53:42 +0200 Subject: [PATCH 4/4] media: gc2145: Fix the RGB MBUS format Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250612-csi-bgr-rgb-v1-4-dc8a309118f8@kernel.org> References: <20250612-csi-bgr-rgb-v1-0-dc8a309118f8@kernel.org> In-Reply-To: <20250612-csi-bgr-rgb-v1-0-dc8a309118f8@kernel.org> To: Mauro Carvalho Chehab , Hans Verkuil , Mats Randgaard , Alain Volmat , Sakari Ailus Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, Hans Verkuil , Dave Stevenson , Maxime Ripard X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=1985; i=mripard@kernel.org; h=from:subject:message-id; bh=qi5lfHwQHhJGRjqK2zsDjKYabHNZy+zeTYkiDzXpm7c=; b=owGbwMvMwCmsHn9OcpHtvjLG02pJDBleZ28fCT6UcMWzJvJvYWC1wMXrQq8fBVb5vDv67bnXI 8ucS0ElHVNZGIQ5GWTFFFmeyISdXt6+uMrBfuUPmDmsTCBDGLg4BWAimZcYGy5X5ysGPHad4WCy NyHb+jezoqb5fK9ZkUEXtG3eL3l7MqGoJen1iqaVte8tb9q76bhaMzbsNWrdMvnm3fXvD9ks31Z 367B9zxpVK9klenp20vd3q/G0/byiV/4m8kfBjBnPROeczWEHAA== X-Developer-Key: i=mripard@kernel.org; a=openpgp; fpr=BE5675C37E818C8B5764241C254BCFC56BF6CE8D The GalaxyCore GC2145 is an MIPI-CSI2 sensor. is an HDMI to MIPI-CSI2 bridge. Among others, it support the MIPI-CSI2 RGB565 format, listed in the driver as MEDIA_BUS_FMT_RGB565_1X16. Most CSI2 receiver drivers then map MEDIA_BUS_FMT_RGB565_1X16 to V4L2_PIX_FMT_RGB565. However, V4L2_PIX_FMT_RGB565 is defined as having its color components in the R, G and B order, from left to right. MIPI-CSI2 however defines the RGB565 format with blue first. This essentially means that the R and B will be swapped compared to what V4L2_PIX_FMT_RGB565 defines. The proper MBUS format would be BGR565, so let's use that. Fixes: 03cc7fefbb09 ("media: i2c: gc2145: Galaxy Core GC2145 sensor support= ") Signed-off-by: Maxime Ripard --- drivers/media/i2c/gc2145.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/media/i2c/gc2145.c b/drivers/media/i2c/gc2145.c index ba02161d46e723d14e8670ef89ba10b270d7d178..12ce1c7aa0a9e028bd7d4c84356= e0e166294a1f6 100644 --- a/drivers/media/i2c/gc2145.c +++ b/drivers/media/i2c/gc2145.c @@ -579,11 +579,11 @@ static const struct gc2145_format supported_formats[]= =3D { .colorspace =3D V4L2_COLORSPACE_SRGB, .datatype =3D MIPI_CSI2_DT_YUV422_8B, .output_fmt =3D 0x03, }, { - .code =3D MEDIA_BUS_FMT_RGB565_1X16, + .code =3D MEDIA_BUS_FMT_BGR565_1X16, .colorspace =3D V4L2_COLORSPACE_SRGB, .datatype =3D MIPI_CSI2_DT_RGB565, .output_fmt =3D 0x06, .switch_bit =3D true, }, @@ -696,11 +696,11 @@ static int gc2145_init_state(struct v4l2_subdev *sd, struct v4l2_rect *crop; =20 /* Initialize pad format */ format =3D v4l2_subdev_state_get_format(state, 0); gc2145_update_pad_format(gc2145, &supported_modes[0], format, - MEDIA_BUS_FMT_RGB565_1X16, + MEDIA_BUS_FMT_BGR565_1X16, V4L2_COLORSPACE_SRGB); =20 /* Initialize crop rectangle. */ crop =3D v4l2_subdev_state_get_crop(state, 0); *crop =3D supported_modes[0].crop; --=20 2.49.0