[PATCH RFC 1/3] media: v4l2-ctrls: Expose v4l2_ctrl_fill_event()

From: Yunke Cao
Date: Wed Jan 11 2023 - 03:53:13 EST


Rename fill_event() to v4l2_ctrl_fill_event() and expose it to drivers.

Signed-off-by: Yunke Cao <yunkec@xxxxxxxxxxxx>
---
drivers/media/v4l2-core/v4l2-ctrls-core.c | 9 +++++----
include/media/v4l2-ctrls.h | 12 ++++++++++++
2 files changed, 17 insertions(+), 4 deletions(-)

diff --git a/drivers/media/v4l2-core/v4l2-ctrls-core.c b/drivers/media/v4l2-core/v4l2-ctrls-core.c
index 29169170880a..184e03d032d9 100644
--- a/drivers/media/v4l2-core/v4l2-ctrls-core.c
+++ b/drivers/media/v4l2-core/v4l2-ctrls-core.c
@@ -16,8 +16,8 @@

static const union v4l2_ctrl_ptr ptr_null;

-static void fill_event(struct v4l2_event *ev, struct v4l2_ctrl *ctrl,
- u32 changes)
+void v4l2_ctrl_fill_event(struct v4l2_event *ev, struct v4l2_ctrl *ctrl,
+ u32 changes)
{
memset(ev, 0, sizeof(*ev));
ev->type = V4L2_EVENT_CTRL;
@@ -38,6 +38,7 @@ static void fill_event(struct v4l2_event *ev, struct v4l2_ctrl *ctrl,
ev->u.ctrl.step = ctrl->step;
ev->u.ctrl.default_value = ctrl->default_value;
}
+EXPORT_SYMBOL(v4l2_ctrl_fill_event);

void send_initial_event(struct v4l2_fh *fh, struct v4l2_ctrl *ctrl)
{
@@ -46,7 +47,7 @@ void send_initial_event(struct v4l2_fh *fh, struct v4l2_ctrl *ctrl)

if (!(ctrl->flags & V4L2_CTRL_FLAG_WRITE_ONLY))
changes |= V4L2_EVENT_CTRL_CH_VALUE;
- fill_event(&ev, ctrl, changes);
+ v4l2_ctrl_fill_event(&ev, ctrl, changes);
v4l2_event_queue_fh(fh, &ev);
}

@@ -57,7 +58,7 @@ void send_event(struct v4l2_fh *fh, struct v4l2_ctrl *ctrl, u32 changes)

if (list_empty(&ctrl->ev_subs))
return;
- fill_event(&ev, ctrl, changes);
+ v4l2_ctrl_fill_event(&ev, ctrl, changes);

list_for_each_entry(sev, &ctrl->ev_subs, node)
if (sev->fh != fh ||
diff --git a/include/media/v4l2-ctrls.h b/include/media/v4l2-ctrls.h
index e59d9a234631..52b2f366cdb6 100644
--- a/include/media/v4l2-ctrls.h
+++ b/include/media/v4l2-ctrls.h
@@ -847,6 +847,18 @@ void v4l2_ctrl_auto_cluster(unsigned int ncontrols,
*/
struct v4l2_ctrl *v4l2_ctrl_find(struct v4l2_ctrl_handler *hdl, u32 id);

+/**
+ * v4l2_ctrl_fill_event() - Fill the v4l2 event for a control.
+ *
+ * @ev: The event to fill.
+ * @ctrl: The struct v4l2_ctrl for the control event.
+ * @changes: A bitmask that tells what has changed.
+ *
+ * This function assumes that the control handler is locked.
+ */
+void v4l2_ctrl_fill_event(struct v4l2_event *ev, struct v4l2_ctrl *ctrl,
+ u32 changes);
+
/**
* v4l2_ctrl_activate() - Make the control active or inactive.
* @ctrl: The control to (de)activate.

--
b4 0.11.0-dev-4d321