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 <mripard@kernel.org>
---
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..12ce1c7aa0a9e028bd7d4c84356e0e166294a1f6 100644
--- a/drivers/media/i2c/gc2145.c
+++ b/drivers/media/i2c/gc2145.c
@@ -579,11 +579,11 @@ static const struct gc2145_format supported_formats[] = {
.colorspace = V4L2_COLORSPACE_SRGB,
.datatype = MIPI_CSI2_DT_YUV422_8B,
.output_fmt = 0x03,
},
{
- .code = MEDIA_BUS_FMT_RGB565_1X16,
+ .code = MEDIA_BUS_FMT_BGR565_1X16,
.colorspace = V4L2_COLORSPACE_SRGB,
.datatype = MIPI_CSI2_DT_RGB565,
.output_fmt = 0x06,
.switch_bit = true,
},
@@ -696,11 +696,11 @@ static int gc2145_init_state(struct v4l2_subdev *sd,
struct v4l2_rect *crop;
/* Initialize pad format */
format = 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);
/* Initialize crop rectangle. */
crop = v4l2_subdev_state_get_crop(state, 0);
*crop = supported_modes[0].crop;
--
2.49.0
On 12/06/2025 14:53, Maxime Ripard wrote: > The GalaxyCore GC2145 is an MIPI-CSI2 sensor. is an HDMI to MIPI-CSI2 Is it a sensor or an HDMI-to-CSI bridge? This looks like a copy-and-paste mistake. Regards, Hans > 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 <mripard@kernel.org> > --- > 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..12ce1c7aa0a9e028bd7d4c84356e0e166294a1f6 100644 > --- a/drivers/media/i2c/gc2145.c > +++ b/drivers/media/i2c/gc2145.c > @@ -579,11 +579,11 @@ static const struct gc2145_format supported_formats[] = { > .colorspace = V4L2_COLORSPACE_SRGB, > .datatype = MIPI_CSI2_DT_YUV422_8B, > .output_fmt = 0x03, > }, > { > - .code = MEDIA_BUS_FMT_RGB565_1X16, > + .code = MEDIA_BUS_FMT_BGR565_1X16, > .colorspace = V4L2_COLORSPACE_SRGB, > .datatype = MIPI_CSI2_DT_RGB565, > .output_fmt = 0x06, > .switch_bit = true, > }, > @@ -696,11 +696,11 @@ static int gc2145_init_state(struct v4l2_subdev *sd, > struct v4l2_rect *crop; > > /* Initialize pad format */ > format = 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); > > /* Initialize crop rectangle. */ > crop = v4l2_subdev_state_get_crop(state, 0); > *crop = supported_modes[0].crop; >
© 2016 - 2025 Red Hat, Inc.