Skip to contentSkip to conversation

gpu: ipu-v3: csi: add RGB565 support

PATCH In review Jan Luebbe 2 participants 4 messages May 3, 2018 – May 18, 2018

Subsystems (2)
lore
Share & tools
lore

Jan Luebbe

author
#0 lore raw

cover gpu: ipu-v3: csi: add RGB565 support

This series adds support to capture in RGB565 format on the parallel bus by using the bayer (generic) mode instead.

It also contains a small cleanup patch to pass on error codes from mbus_code_to_bus_cfg in fill_csi_bus_cfg and ipu_csi_init_interface by Enrico Scholz.

Enrico Scholz (1):
gpu: ipu-v3: csi: pass back mbus_code_to_bus_cfg error codes

Jan Luebbe (1):
gpu: ipu-v3: csi: support RGB565 on parallel bus

 drivers/gpu/ipu-v3/ipu-csi.c | 28 ++++++++++++++++++++++------
 1 file changed, 22 insertions(+), 6 deletions(-)
Signature · 6 lines
2.17.0

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
author
#1 lore raw

PATCH 1/2 gpu: ipu-v3: csi: pass back mbus_code_to_bus_cfg error codes

From: Enrico Scholz <[email protected]>

mbus_code_to_bus_cfg() can fail on unknown mbus codes; pass back the error to the caller.

---
 drivers/gpu/ipu-v3/ipu-csi.c | 20 ++++++++++++++++----
 1 file changed, 16 insertions(+), 4 deletions(-)
drivers/gpu/ipu-v3/ipu-csi.c +16 -4
index caa05b0702e1..39c3aabb6d17 100644
@@ -318,13 +318,17 @@ static int mbus_code_to_bus_cfg(struct ipu_csi_bus_config *cfg, u32 mbus_code)
 /*
  * Fill a CSI bus config struct from mbus_config and mbus_framefmt.
  */
-static void fill_csi_bus_cfg(struct ipu_csi_bus_config *csicfg,
+static int fill_csi_bus_cfg(struct ipu_csi_bus_config *csicfg,
 				 struct v4l2_mbus_config *mbus_cfg,
 				 struct v4l2_mbus_framefmt *mbus_fmt)
 {
+	int rc;
+
 	memset(csicfg, 0, sizeof(*csicfg));
 
-	mbus_code_to_bus_cfg(csicfg, mbus_fmt->code);
+	rc = mbus_code_to_bus_cfg(csicfg, mbus_fmt->code);
+	if (rc < 0)
+		return rc;
 
 	switch (mbus_cfg->type) {
 	case V4L2_MBUS_PARALLEL:
@@ -355,6 +359,8 @@ static void fill_csi_bus_cfg(struct ipu_csi_bus_config *csicfg,
 		/* will never get here, keep compiler quiet */
 		break;
 	}
+
+	return 0;
 }
 
 int ipu_csi_init_interface(struct ipu_csi *csi,
@@ -364,8 +370,11 @@ int ipu_csi_init_interface(struct ipu_csi *csi,
 	struct ipu_csi_bus_config cfg;
 	unsigned long flags;
 	u32 width, height, data = 0;
+	int rc;
 
-	fill_csi_bus_cfg(&cfg, mbus_cfg, mbus_fmt);
+	rc = fill_csi_bus_cfg(&cfg, mbus_cfg, mbus_fmt);
+	if (rc < 0)
+		return rc;
 
 	/* set default sensor frame width and height */
 	width = mbus_fmt->width;
@@ -586,11 +595,14 @@ int ipu_csi_set_mipi_datatype(struct ipu_csi *csi, u32 vc,
 	struct ipu_csi_bus_config cfg;
 	unsigned long flags;
 	u32 temp;
+	int rc;
 
 	if (vc > 3)
 		return -EINVAL;
 
-	mbus_code_to_bus_cfg(&cfg, mbus_fmt->code);
+	rc = mbus_code_to_bus_cfg(&cfg, mbus_fmt->code);
+	if (rc < 0)
+		return rc;
 
 	spin_lock_irqsave(&csi->lock, flags);
 
Signature · 6 lines
2.17.0

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
author
#2 lore raw

PATCH 2/2 gpu: ipu-v3: csi: support RGB565 on parallel bus

In reply to Jan Luebbe

The CSI_SENS_CONF_DATA_FMT_RGB565 configuration only works for MIPI CSI-2 sources. On the parallel bus, we need to use bayer (generic) mode instead. To handle this difference, we pass the mbus_type to mbus_code_to_bus_cfg().

---
 drivers/gpu/ipu-v3/ipu-csi.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)
drivers/gpu/ipu-v3/ipu-csi.c +8 -4
index 39c3aabb6d17..28a6b6243baa 100644
@@ -224,14 +224,18 @@ static int ipu_csi_set_testgen_mclk(struct ipu_csi *csi, u32 pixel_clk,
  * Find the CSI data format and data width for the given V4L2 media
  * bus pixel format code.
  */
-static int mbus_code_to_bus_cfg(struct ipu_csi_bus_config *cfg, u32 mbus_code)
+static int mbus_code_to_bus_cfg(struct ipu_csi_bus_config *cfg, u32 mbus_code,
+				enum v4l2_mbus_type mbus_type)
 {
 	switch (mbus_code) {
 	case MEDIA_BUS_FMT_BGR565_2X8_BE:
 	case MEDIA_BUS_FMT_BGR565_2X8_LE:
 	case MEDIA_BUS_FMT_RGB565_2X8_BE:
 	case MEDIA_BUS_FMT_RGB565_2X8_LE:
-		cfg->data_fmt = CSI_SENS_CONF_DATA_FMT_RGB565;
+		if (mbus_type == V4L2_MBUS_CSI2)
+			cfg->data_fmt = CSI_SENS_CONF_DATA_FMT_RGB565;
+		else
+			cfg->data_fmt = CSI_SENS_CONF_DATA_FMT_BAYER;
 		cfg->mipi_dt = MIPI_DT_RGB565;
 		cfg->data_width = IPU_CSI_DATA_WIDTH_8;
 		break;
@@ -326,7 +330,7 @@ static int fill_csi_bus_cfg(struct ipu_csi_bus_config *csicfg,
 
 	memset(csicfg, 0, sizeof(*csicfg));
 
-	rc = mbus_code_to_bus_cfg(csicfg, mbus_fmt->code);
+	rc = mbus_code_to_bus_cfg(csicfg, mbus_fmt->code, mbus_cfg->type);
 	if (rc < 0)
 		return rc;
 
@@ -600,7 +604,7 @@ int ipu_csi_set_mipi_datatype(struct ipu_csi *csi, u32 vc,
 	if (vc > 3)
 		return -EINVAL;
 
-	rc = mbus_code_to_bus_cfg(&cfg, mbus_fmt->code);
+	rc = mbus_code_to_bus_cfg(&cfg, mbus_fmt->code, V4L2_MBUS_CSI2);
 	if (rc < 0)
 		return rc;
 
Signature · 6 lines
2.17.0

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
maintainer
#3 lore raw
In reply to Jan Luebbe
Quoted 7 lines · Jan Luebbe

This series adds support to capture in RGB565 format on the parallel bus by using the bayer (generic) mode instead.

It also contains a small cleanup patch to pass on error codes from mbus_code_to_bus_cfg in fill_csi_bus_cfg and ipu_csi_init_interface by Enrico Scholz.

Quoted 8 lines

Enrico Scholz (1):
gpu: ipu-v3: csi: pass back mbus_code_to_bus_cfg error codes

Jan Luebbe (1):
gpu: ipu-v3: csi: support RGB565 on parallel bus

 drivers/gpu/ipu-v3/ipu-csi.c | 28 ++++++++++++++++++++++------
 1 file changed, 22 insertions(+), 6 deletions(-)

I have applied both patches to imx-drm/next after renaming the "rc" local variables to "ret" for consistency with the other ipu-v3 code.

regards
Philipp
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel