@@ -4255,6 +4255,21 @@ int __v4l2_ctrl_s_ctrl_area(struct v4l2_ctrl *ctrl,
}
EXPORT_SYMBOL(__v4l2_ctrl_s_ctrl_area);
+int __v4l2_ctrl_s_ctrl_compound(struct v4l2_ctrl *ctrl, const void *data,
+ size_t len)
+{
+ lockdep_assert_held(ctrl->handler->lock);
+
+ /* It's a driver bug if this happens. */
+ WARN_ON(!ctrl->is_ptr || ctrl->type < V4L2_CTRL_COMPOUND_TYPES);
+ if (WARN_ON(len != (ctrl->elem_size * ctrl->elems)))
+ return -EINVAL;
+
+ memcpy(ctrl->p_new.p, data, len);
+ return set_ctrl(NULL, ctrl, 0);
+}
+EXPORT_SYMBOL(__v4l2_ctrl_s_ctrl_compound);
+
void v4l2_ctrl_request_complete(struct media_request *req,
struct v4l2_ctrl_handler *main_hdl)
{
@@ -1152,6 +1152,49 @@ static inline int v4l2_ctrl_s_ctrl_area(struct v4l2_ctrl *ctrl,
return rval;
}
+/**
+ * __v4l2_ctrl_s_ctrl_compound() - Unlocked variant of
+ * v4l2_ctrl_s_ctrl_compound().
+ *
+ * @ctrl: The control.
+ * @data: The object pointer.
+ * @len: The object length.
+ *
+ * This sets the control's new compound safely by going through the control
+ * framework. This function assumes the control's handler is already locked,
+ * allowing it to be used from within the &v4l2_ctrl_ops functions.
+ *
+ * This function is for compound type controls only.
+ */
+int __v4l2_ctrl_s_ctrl_compound(struct v4l2_ctrl *ctrl, const void *data,
+ size_t len);
+
+/**
+ * v4l2_ctrl_s_ctrl_compound() - Helper function to set a control's compound
+ * value from within a driver.
+ *
+ * @ctrl: The control.
+ * @data: The object pointer.
+ * @len: The object length.
+ *
+ * This sets the control's new compound safely by going through the control
+ * framework. This function will lock the control's handler, so it cannot be
+ * used from within the &v4l2_ctrl_ops functions.
+ *
+ * This function is for compound type controls only.
+ */
+static inline int v4l2_ctrl_s_ctrl_compound(struct v4l2_ctrl *ctrl,
+ const void *data, size_t len)
+{
+ int rval;
+
+ v4l2_ctrl_lock(ctrl);
+ rval = __v4l2_ctrl_s_ctrl_compound(ctrl, data, len);
+ v4l2_ctrl_unlock(ctrl);
+
+ return rval;
+}
+
/* Internal helper functions that deal with control events. */
extern const struct v4l2_subscribed_event_ops v4l2_ctrl_sub_ev_ops;
VP9 codec drivers will need to set some of their frame context compound controls. Let's provide the [__]v4l2_ctrl_s_ctrl_compound() helpers to allow that. Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com> --- drivers/media/v4l2-core/v4l2-ctrls.c | 15 ++++++++++ include/media/v4l2-ctrls.h | 43 ++++++++++++++++++++++++++++ 2 files changed, 58 insertions(+)