diff mbox series

[PATCH/RFC,v2,9/9] media: i2c: ar0144: Add support for companding

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

Commit Message

Laurent Pinchart Sept. 5, 2024, 10:53 p.m. UTC
Add the V4L2_CID_COMPANDING control to enable control of companding. The
sensor supports compression only, enable the linear (no companding) and
compression menu entries.

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

Patch

diff --git a/drivers/media/i2c/ar0144.c b/drivers/media/i2c/ar0144.c
index c2ef8b26a2bc..8789ba0d2ea8 100644
--- a/drivers/media/i2c/ar0144.c
+++ b/drivers/media/i2c/ar0144.c
@@ -1010,6 +1010,12 @@  static int ar0144_s_ctrl(struct v4l2_ctrl *ctrl)
 			  AR0144_AUTO_AG_EN | AR0144_AE_ENABLE : 0, &ret);
 		break;
 
+	case V4L2_CID_COMPANDING:
+		cci_write(sensor->regmap, AR0144_COMPANDING,
+			  ctrl->val == V4L2_COMPANDING_COMPRESS ?
+			  AR0144_COMPAND_EN : 0, &ret);
+		break;
+
 	case V4L2_CID_LINK_FREQ:
 		break;
 
@@ -1044,7 +1050,7 @@  static int ar0144_init_ctrls(struct ar0144 *sensor)
 	if (ret < 0)
 		return ret;
 
-	v4l2_ctrl_handler_init(&sensor->ctrls, 17);
+	v4l2_ctrl_handler_init(&sensor->ctrls, 18);
 
 	v4l2_ctrl_new_fwnode_properties(&sensor->ctrls, &ar0144_ctrl_ops,
 					&props);
@@ -1108,6 +1114,10 @@  static int ar0144_init_ctrls(struct ar0144 *sensor)
 	sensor->vflip = v4l2_ctrl_new_std(&sensor->ctrls, &ar0144_ctrl_ops,
 					  V4L2_CID_VFLIP, 0, 1, 1, 0);
 
+	v4l2_ctrl_new_std_menu(&sensor->ctrls, &ar0144_ctrl_ops,
+			       V4L2_CID_COMPANDING, V4L2_COMPANDING_COMPRESS, 0,
+			       V4L2_COMPANDING_LINEAR);
+
 	if (sensor->ctrls.error) {
 		ret = sensor->ctrls.error;
 		v4l2_ctrl_handler_free(&sensor->ctrls);