diff mbox series

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

Message ID 20240630141802.15830-10-laurent.pinchart@ideasonboard.com
State Superseded
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 the V4L2_CID_COMPANDING control to enable control of companding. The
sensor supports A-law only, enable the linear (no companding) and A-law
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 782a09a66ba6..021e19861f8f 100644
--- a/drivers/media/i2c/ar0144.c
+++ b/drivers/media/i2c/ar0144.c
@@ -996,6 +996,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_ALAW ?
+			  AR0144_COMPAND_EN : 0, &ret);
+		break;
+
 	case V4L2_CID_LINK_FREQ:
 		break;
 
@@ -1030,7 +1036,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);
@@ -1094,6 +1100,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_ALAW, 0,
+			       V4L2_COMPANDING_LINEAR);
+
 	if (sensor->ctrls.error) {
 		ret = sensor->ctrls.error;
 		v4l2_ctrl_handler_free(&sensor->ctrls);