Skip to contentSkip to conversation

media: ov2740: Add event support for controls

PATCH In review Sakari Ailus 2 participants 2 messages May 2, 2024 – May 6, 2024

Subsystems (3)
lore
Share & tools
lore

Sakari Ailus

author maintainer
#0 lore raw

PATCH 1/1 media: ov2740: Add event support for controls

The driver supports controls. Therefore, add support for control events. This makes the driver pass v4l2-compliance, too.

---
 drivers/media/i2c/ov2740.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)
drivers/media/i2c/ov2740.c +9 -1
index 57906df7be4e..3e3f958db256 100644
@@ -13,6 +13,7 @@
 #include <linux/regmap.h>
 #include <media/v4l2-ctrls.h>
 #include <media/v4l2-device.h>
+#include <media/v4l2-event.h>
 #include <media/v4l2-fwnode.h>
 
 #define OV2740_LINK_FREQ_360MHZ		360000000ULL
@@ -1100,7 +1101,13 @@ static const struct v4l2_subdev_pad_ops ov2740_pad_ops = {
 	.enum_frame_size = ov2740_enum_frame_size,
 };
 
+static const struct v4l2_subdev_core_ops ov2740_core_ops = {
+	.subscribe_event = v4l2_ctrl_subdev_subscribe_event,
+	.unsubscribe_event = v4l2_event_subdev_unsubscribe,
+};
+
 static const struct v4l2_subdev_ops ov2740_subdev_ops = {
+	.core = &ov2740_core_ops,
 	.video = &ov2740_video_ops,
 	.pad = &ov2740_pad_ops,
 };
@@ -1364,7 +1371,8 @@ static int ov2740_probe(struct i2c_client *client)
 	}
 
 	ov2740->sd.state_lock = ov2740->ctrl_handler.lock;
-	ov2740->sd.flags |= V4L2_SUBDEV_FL_HAS_DEVNODE;
+	ov2740->sd.flags |= V4L2_SUBDEV_FL_HAS_DEVNODE |
+		V4L2_SUBDEV_FL_HAS_EVENTS;
 	ov2740->sd.entity.ops = &ov2740_subdev_entity_ops;
 	ov2740->sd.entity.function = MEDIA_ENT_F_CAM_SENSOR;
 	ov2740->pad.flags = MEDIA_PAD_FL_SOURCE;
Signature · 1 line
2.39.2
Reviewed-by on v1 1/1
#1 lore raw

Sakari,

Thanks for the patch.

Quoted 36 lines · Sakari Ailus

The driver supports controls. Therefore, add support for control events. This makes the driver pass v4l2-compliance, too.

---
 drivers/media/i2c/ov2740.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)
drivers/media/i2c/ov2740.c +7 -0
index 57906df7be4e..3e3f958db256 100644
@@ -13,6 +13,7 @@
 #include <linux/regmap.h>
 #include <media/v4l2-ctrls.h>
 #include <media/v4l2-device.h>
+#include <media/v4l2-event.h>
 #include <media/v4l2-fwnode.h>
 
 #define OV2740_LINK_FREQ_360MHZ		360000000ULL
@@ -1100,7 +1101,13 @@ static const struct v4l2_subdev_pad_ops ov2740_pad_ops = {
 	.enum_frame_size = ov2740_enum_frame_size,
 };
 
+static const struct v4l2_subdev_core_ops ov2740_core_ops = {
+	.subscribe_event = v4l2_ctrl_subdev_subscribe_event,
+	.unsubscribe_event = v4l2_event_subdev_unsubscribe,
+};
+
 static const struct v4l2_subdev_ops ov2740_subdev_ops = {
+	.core = &ov2740_core_ops,
 	.video = &ov2740_video_ops,
 	.pad = &ov2740_pad_ops,
 };

drivers/media/i2c/ov2740.c static int ov2740_probe(struct i2c_client *client) · line 1378

Quoted 9 lines
drivers/media/i2c/ov2740.c +2 -1
@@ -1364,7 +1371,8 @@ static int ov2740_probe(struct i2c_client *client)
 	}
 
 	ov2740->sd.state_lock = ov2740->ctrl_handler.lock;
-	ov2740->sd.flags |= V4L2_SUBDEV_FL_HAS_DEVNODE;
+	ov2740->sd.flags |= V4L2_SUBDEV_FL_HAS_DEVNODE |
+		V4L2_SUBDEV_FL_HAS_EVENTS;
 	ov2740->sd.entity.ops = &ov2740_subdev_entity_ops;
 	ov2740->sd.entity.function = MEDIA_ENT_F_CAM_SENSOR;
 	ov2740->pad.flags = MEDIA_PAD_FL_SOURCE;
Signature · 2 lines
Best regards,
Bingbu Cao