diff mbox series

[PATCH/RFC,v1,3/9] media: i2c: ar0144: Add support for the parallel interface

Message ID 20240630141802.15830-4-laurent.pinchart@ideasonboard.com
State New
Headers show
Series media: i2c: AR0144 camera sensor driver with companding support | expand

Commit Message

Laurent Pinchart June 30, 2024, 2:17 p.m. UTC
Add basic support for the parallel interface. This hasn't been tested
due to the lack of a test platform, and will thus likely not work out of
the box.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
 drivers/media/i2c/ar0144.c | 31 +++++++++++++++++++++++++++++--
 1 file changed, 29 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/drivers/media/i2c/ar0144.c b/drivers/media/i2c/ar0144.c
index b0e738a28de6..d231459d7218 100644
--- a/drivers/media/i2c/ar0144.c
+++ b/drivers/media/i2c/ar0144.c
@@ -10,7 +10,8 @@ 
  * - Use grouped parameter hold to update controls atomically
  * - Expose debug information through debugfs (FRAME_COUNT, FRAME_STATUS, ...)
  * - Make MIPI D-PHY timings configurable
- * - Support the parallel interface
+ * - Program additional parallel interface parameters (slew rates, polarities,
+ *   ...)
  * - Expose additional controls (in particular the temperature sensor and the
  *   on-chip black level correction)
  */
@@ -298,6 +299,8 @@ 
 #define AR0144_MIN_CSI2_LINK_FREQ		150000000U
 #define AR0144_MAX_CSI2_LINK_FREQ		384000000U
 
+#define AR0144_MAX_PARALLEL_LINK_FREQ		74250000U
+
 /*
  * The pixel array contains 1300x820 optically transparent pixels, with 6 dummy
  * pixels on each side that can't be read out. The active size is 1288x808.
@@ -464,6 +467,12 @@  static int ar0144_configure_pll(struct ar0144 *sensor)
 	return ret;
 }
 
+static int ar0144_configure_parallel(struct ar0144 *sensor,
+				     const struct ar0144_format_info *info)
+{
+	return cci_write(sensor->regmap, AR0144_SERIAL_FORMAT, 0x0200, NULL);
+}
+
 static int ar0144_configure_mipi(struct ar0144 *sensor,
 				 const struct ar0144_format_info *info)
 {
@@ -550,13 +559,19 @@  static int ar0144_start_streaming(struct ar0144 *sensor,
 	if (ret)
 		return ret;
 
-	ret = ar0144_configure_mipi(sensor, info);
+	if (sensor->bus_cfg.bus_type == V4L2_MBUS_PARALLEL)
+		ret = ar0144_configure_parallel(sensor, info);
+	else
+		ret = ar0144_configure_mipi(sensor, info);
 
 	/*
 	 * We're all set, start streaming. Mask bad frames and keep read-only
 	 * registers locked.
 	 */
 	val = AR0144_MASK_BAD | AR0144_LOCK_REG | AR0144_STREAM | 0x2010;
+	if (sensor->bus_cfg.bus_type == V4L2_MBUS_PARALLEL)
+		val |= AR0144_SMIA_SERIALIZER_DIS | AR0144_PARALLEL_EN
+		    |  AR0144_DRIVE_PINS;
 	cci_write(sensor->regmap, AR0144_RESET_REGISTER, val, &ret);
 
 	return ret;
@@ -581,6 +596,10 @@  static int ar0144_stop_streaming(struct ar0144 *sensor)
 	 * Initiate the transition to standby by clearing the STREAM bit. Don't
 	 * clear the bits that affect the output interface yet.
 	 */
+	if (sensor->bus_cfg.bus_type == V4L2_MBUS_PARALLEL)
+		val |= AR0144_SMIA_SERIALIZER_DIS | AR0144_PARALLEL_EN
+		    |  AR0144_DRIVE_PINS;
+
 	ret = cci_write(sensor->regmap, AR0144_RESET_REGISTER, reset_bits, NULL);
 	if (ret)
 		return ret;
@@ -1268,6 +1287,10 @@  static int ar0144_get_mbus_config(struct v4l2_subdev *sd, unsigned int pad,
 	default:
 		cfg->bus.mipi_csi2 = sensor->bus_cfg.bus.mipi_csi2;
 		break;
+
+	case V4L2_MBUS_PARALLEL:
+		cfg->bus.parallel = sensor->bus_cfg.bus.parallel;
+		break;
 	}
 
 	return 0;
@@ -1607,6 +1630,10 @@  static int ar0144_parse_dt(struct ar0144 *sensor)
 		}
 		break;
 
+	case V4L2_MBUS_PARALLEL:
+		nlanes = ep->bus.parallel.bus_width ? : 12;
+		break;
+
 	default:
 		dev_err(sensor->dev, "Unsupported bus type %u\n", ep->bus_type);
 		goto error;