^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) /* SPDX-License-Identifier: GPL-2.0-or-later */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) * V4L2 controls support header.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) * Copyright (C) 2010 Hans Verkuil <hverkuil@xs4all.nl>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) #ifndef _V4L2_CTRLS_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) #define _V4L2_CTRLS_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) #include <linux/list.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) #include <linux/mutex.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) #include <linux/videodev2.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) #include <linux/android_kabi.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) #include <media/media-request.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) * Include the stateless codec compound control definitions.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) * This will move to the public headers once this API is fully stable.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) #include <media/mpeg2-ctrls.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) #include <media/fwht-ctrls.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) #include <media/h264-ctrls.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) #include <media/vp8-ctrls.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) #include <media/hevc-ctrls.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) /* forward references */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) struct file;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) struct poll_table_struct;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) struct v4l2_ctrl;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) struct v4l2_ctrl_handler;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) struct v4l2_ctrl_helper;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) struct v4l2_fh;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) struct v4l2_fwnode_device_properties;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) struct v4l2_subdev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) struct v4l2_subscribed_event;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) struct video_device;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) * union v4l2_ctrl_ptr - A pointer to a control value.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) * @p_s32: Pointer to a 32-bit signed value.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) * @p_s64: Pointer to a 64-bit signed value.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) * @p_u8: Pointer to a 8-bit unsigned value.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) * @p_u16: Pointer to a 16-bit unsigned value.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) * @p_u32: Pointer to a 32-bit unsigned value.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) * @p_char: Pointer to a string.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) * @p_mpeg2_slice_params: Pointer to a MPEG2 slice parameters structure.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) * @p_mpeg2_quantization: Pointer to a MPEG2 quantization data structure.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) * @p_fwht_params: Pointer to a FWHT stateless parameters structure.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) * @p_h264_sps: Pointer to a struct v4l2_ctrl_h264_sps.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) * @p_h264_pps: Pointer to a struct v4l2_ctrl_h264_pps.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) * @p_h264_scaling_matrix: Pointer to a struct v4l2_ctrl_h264_scaling_matrix.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) * @p_h264_slice_params: Pointer to a struct v4l2_ctrl_h264_slice_params.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) * @p_h264_decode_params: Pointer to a struct v4l2_ctrl_h264_decode_params.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) * @p_h264_pred_weights: Pointer to a struct v4l2_ctrl_h264_pred_weights.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) * @p_vp8_frame_header: Pointer to a VP8 frame header structure.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) * @p_hevc_sps: Pointer to an HEVC sequence parameter set structure.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) * @p_hevc_pps: Pointer to an HEVC picture parameter set structure.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) * @p_hevc_slice_params: Pointer to an HEVC slice parameters structure.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) * @p_hdr10_cll: Pointer to an HDR10 Content Light Level structure.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) * @p_hdr10_mastering: Pointer to an HDR10 Mastering Display structure.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) * @p_area: Pointer to an area.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) * @p: Pointer to a compound value.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) * @p_const: Pointer to a constant compound value.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) union v4l2_ctrl_ptr {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) s32 *p_s32;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) s64 *p_s64;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) u8 *p_u8;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) u16 *p_u16;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) u32 *p_u32;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) char *p_char;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) struct v4l2_ctrl_mpeg2_slice_params *p_mpeg2_slice_params;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) struct v4l2_ctrl_mpeg2_quantization *p_mpeg2_quantization;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) struct v4l2_ctrl_fwht_params *p_fwht_params;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) struct v4l2_ctrl_h264_sps *p_h264_sps;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) struct v4l2_ctrl_h264_pps *p_h264_pps;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) struct v4l2_ctrl_h264_scaling_matrix *p_h264_scaling_matrix;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) struct v4l2_ctrl_h264_slice_params *p_h264_slice_params;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) struct v4l2_ctrl_h264_decode_params *p_h264_decode_params;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) struct v4l2_ctrl_h264_pred_weights *p_h264_pred_weights;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) struct v4l2_ctrl_vp8_frame_header *p_vp8_frame_header;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) struct v4l2_ctrl_hevc_sps *p_hevc_sps;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) struct v4l2_ctrl_hevc_pps *p_hevc_pps;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) struct v4l2_ctrl_hevc_slice_params *p_hevc_slice_params;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) struct v4l2_ctrl_hdr10_cll_info *p_hdr10_cll;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) struct v4l2_ctrl_hdr10_mastering_display *p_hdr10_mastering;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) struct v4l2_area *p_area;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) void *p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) const void *p_const;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) ANDROID_KABI_RESERVE(1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) ANDROID_KABI_RESERVE(2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) * v4l2_ctrl_ptr_create() - Helper function to return a v4l2_ctrl_ptr from a
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) * void pointer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) * @ptr: The void pointer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) static inline union v4l2_ctrl_ptr v4l2_ctrl_ptr_create(void *ptr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) union v4l2_ctrl_ptr p = { .p = ptr };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) return p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) * struct v4l2_ctrl_ops - The control operations that the driver has to provide.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) * @g_volatile_ctrl: Get a new value for this control. Generally only relevant
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) * for volatile (and usually read-only) controls such as a control
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) * that returns the current signal strength which changes
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) * continuously.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) * If not set, then the currently cached value will be returned.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) * @try_ctrl: Test whether the control's value is valid. Only relevant when
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) * the usual min/max/step checks are not sufficient.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) * @s_ctrl: Actually set the new control value. s_ctrl is compulsory. The
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) * ctrl->handler->lock is held when these ops are called, so no
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) * one else can access controls owned by that handler.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) struct v4l2_ctrl_ops {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) int (*g_volatile_ctrl)(struct v4l2_ctrl *ctrl);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) int (*try_ctrl)(struct v4l2_ctrl *ctrl);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) int (*s_ctrl)(struct v4l2_ctrl *ctrl);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) ANDROID_KABI_RESERVE(1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) * struct v4l2_ctrl_type_ops - The control type operations that the driver
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) * has to provide.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) * @equal: return true if both values are equal.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) * @init: initialize the value.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) * @log: log the value.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) * @validate: validate the value. Return 0 on success and a negative value
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) * otherwise.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) struct v4l2_ctrl_type_ops {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) bool (*equal)(const struct v4l2_ctrl *ctrl, u32 idx,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) union v4l2_ctrl_ptr ptr1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) union v4l2_ctrl_ptr ptr2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) void (*init)(const struct v4l2_ctrl *ctrl, u32 idx,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) union v4l2_ctrl_ptr ptr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) void (*log)(const struct v4l2_ctrl *ctrl);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) int (*validate)(const struct v4l2_ctrl *ctrl, u32 idx,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) union v4l2_ctrl_ptr ptr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) ANDROID_KABI_RESERVE(1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) * typedef v4l2_ctrl_notify_fnc - typedef for a notify argument with a function
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) * that should be called when a control value has changed.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) * @ctrl: pointer to struct &v4l2_ctrl
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) * @priv: control private data
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) * This typedef definition is used as an argument to v4l2_ctrl_notify()
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) * and as an argument at struct &v4l2_ctrl_handler.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) typedef void (*v4l2_ctrl_notify_fnc)(struct v4l2_ctrl *ctrl, void *priv);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) * struct v4l2_ctrl - The control structure.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) * @node: The list node.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) * @ev_subs: The list of control event subscriptions.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) * @handler: The handler that owns the control.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) * @cluster: Point to start of cluster array.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) * @ncontrols: Number of controls in cluster array.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) * @done: Internal flag: set for each processed control.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) * @is_new: Set when the user specified a new value for this control. It
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) * is also set when called from v4l2_ctrl_handler_setup(). Drivers
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) * should never set this flag.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) * @has_changed: Set when the current value differs from the new value. Drivers
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) * should never use this flag.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) * @is_private: If set, then this control is private to its handler and it
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) * will not be added to any other handlers. Drivers can set
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) * this flag.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) * @is_auto: If set, then this control selects whether the other cluster
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) * members are in 'automatic' mode or 'manual' mode. This is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) * used for autogain/gain type clusters. Drivers should never
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) * set this flag directly.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) * @is_int: If set, then this control has a simple integer value (i.e. it
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) * uses ctrl->val).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) * @is_string: If set, then this control has type %V4L2_CTRL_TYPE_STRING.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) * @is_ptr: If set, then this control is an array and/or has type >=
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) * %V4L2_CTRL_COMPOUND_TYPES
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) * and/or has type %V4L2_CTRL_TYPE_STRING. In other words, &struct
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) * v4l2_ext_control uses field p to point to the data.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) * @is_array: If set, then this control contains an N-dimensional array.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) * @has_volatiles: If set, then one or more members of the cluster are volatile.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) * Drivers should never touch this flag.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) * @call_notify: If set, then call the handler's notify function whenever the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) * control's value changes.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) * @manual_mode_value: If the is_auto flag is set, then this is the value
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) * of the auto control that determines if that control is in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) * manual mode. So if the value of the auto control equals this
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) * value, then the whole cluster is in manual mode. Drivers should
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) * never set this flag directly.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) * @ops: The control ops.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) * @type_ops: The control type ops.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) * @id: The control ID.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) * @name: The control name.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) * @type: The control type.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) * @minimum: The control's minimum value.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) * @maximum: The control's maximum value.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) * @default_value: The control's default value.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) * @step: The control's step value for non-menu controls.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) * @elems: The number of elements in the N-dimensional array.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) * @elem_size: The size in bytes of the control.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) * @dims: The size of each dimension.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) * @nr_of_dims:The number of dimensions in @dims.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) * @menu_skip_mask: The control's skip mask for menu controls. This makes it
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) * easy to skip menu items that are not valid. If bit X is set,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) * then menu item X is skipped. Of course, this only works for
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) * menus with <= 32 menu items. There are no menus that come
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) * close to that number, so this is OK. Should we ever need more,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) * then this will have to be extended to a u64 or a bit array.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) * @qmenu: A const char * array for all menu items. Array entries that are
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) * empty strings ("") correspond to non-existing menu items (this
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) * is in addition to the menu_skip_mask above). The last entry
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) * must be NULL.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) * Used only if the @type is %V4L2_CTRL_TYPE_MENU.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) * @qmenu_int: A 64-bit integer array for with integer menu items.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) * The size of array must be equal to the menu size, e. g.:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) * :math:`ceil(\frac{maximum - minimum}{step}) + 1`.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) * Used only if the @type is %V4L2_CTRL_TYPE_INTEGER_MENU.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) * @flags: The control's flags.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) * @cur: Structure to store the current value.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) * @cur.val: The control's current value, if the @type is represented via
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) * a u32 integer (see &enum v4l2_ctrl_type).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) * @val: The control's new s32 value.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) * @priv: The control's private pointer. For use by the driver. It is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) * untouched by the control framework. Note that this pointer is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) * not freed when the control is deleted. Should this be needed
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) * then a new internal bitfield can be added to tell the framework
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) * to free this pointer.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) * @p_def: The control's default value represented via a union which
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) * provides a standard way of accessing control types
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) * through a pointer (for compound controls only).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) * @p_cur: The control's current value represented via a union which
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) * provides a standard way of accessing control types
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) * through a pointer.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) * @p_new: The control's new value represented via a union which provides
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) * a standard way of accessing control types
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) * through a pointer.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) struct v4l2_ctrl {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) /* Administrative fields */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) struct list_head node;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) struct list_head ev_subs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) struct v4l2_ctrl_handler *handler;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) struct v4l2_ctrl **cluster;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) unsigned int ncontrols;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) unsigned int done:1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) unsigned int is_new:1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) unsigned int has_changed:1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) unsigned int is_private:1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) unsigned int is_auto:1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) unsigned int is_int:1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) unsigned int is_string:1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) unsigned int is_ptr:1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) unsigned int is_array:1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) unsigned int has_volatiles:1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) unsigned int call_notify:1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) unsigned int manual_mode_value:8;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) const struct v4l2_ctrl_ops *ops;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) const struct v4l2_ctrl_type_ops *type_ops;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) u32 id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) const char *name;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) enum v4l2_ctrl_type type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) s64 minimum, maximum, default_value;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) u32 elems;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) u32 elem_size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) u32 dims[V4L2_CTRL_MAX_DIMS];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) u32 nr_of_dims;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) union {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) u64 step;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) u64 menu_skip_mask;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) union {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) const char * const *qmenu;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) const s64 *qmenu_int;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) unsigned long flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) void *priv;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) s32 val;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) s32 val;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) } cur;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298) union v4l2_ctrl_ptr p_def;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) union v4l2_ctrl_ptr p_new;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) union v4l2_ctrl_ptr p_cur;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302) ANDROID_KABI_RESERVE(1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306) * struct v4l2_ctrl_ref - The control reference.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308) * @node: List node for the sorted list.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309) * @next: Single-link list node for the hash.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310) * @ctrl: The actual control information.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311) * @helper: Pointer to helper struct. Used internally in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312) * ``prepare_ext_ctrls`` function at ``v4l2-ctrl.c``.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313) * @from_other_dev: If true, then @ctrl was defined in another
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314) * device than the &struct v4l2_ctrl_handler.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315) * @req_done: Internal flag: if the control handler containing this control
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316) * reference is bound to a media request, then this is set when
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317) * the control has been applied. This prevents applying controls
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318) * from a cluster with multiple controls twice (when the first
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319) * control of a cluster is applied, they all are).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320) * @valid_p_req: If set, then p_req contains the control value for the request.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321) * @p_req: If the control handler containing this control reference
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322) * is bound to a media request, then this points to the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323) * value of the control that must be applied when the request
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324) * is executed, or to the value of the control at the time
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325) * that the request was completed. If @valid_p_req is false,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326) * then this control was never set for this request and the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327) * control will not be updated when this request is applied.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 328) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 329) * Each control handler has a list of these refs. The list_head is used to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 330) * keep a sorted-by-control-ID list of all controls, while the next pointer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 331) * is used to link the control in the hash's bucket.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 332) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 333) struct v4l2_ctrl_ref {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 334) struct list_head node;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 335) struct v4l2_ctrl_ref *next;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 336) struct v4l2_ctrl *ctrl;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 337) struct v4l2_ctrl_helper *helper;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 338) bool from_other_dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 339) bool req_done;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 340) bool valid_p_req;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 341) union v4l2_ctrl_ptr p_req;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 342)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 343) ANDROID_KABI_RESERVE(1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 344) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 345)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 346) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 347) * struct v4l2_ctrl_handler - The control handler keeps track of all the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 348) * controls: both the controls owned by the handler and those inherited
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 349) * from other handlers.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 350) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 351) * @_lock: Default for "lock".
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 352) * @lock: Lock to control access to this handler and its controls.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 353) * May be replaced by the user right after init.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 354) * @ctrls: The list of controls owned by this handler.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 355) * @ctrl_refs: The list of control references.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 356) * @cached: The last found control reference. It is common that the same
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 357) * control is needed multiple times, so this is a simple
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 358) * optimization.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 359) * @buckets: Buckets for the hashing. Allows for quick control lookup.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 360) * @notify: A notify callback that is called whenever the control changes
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 361) * value.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 362) * Note that the handler's lock is held when the notify function
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 363) * is called!
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 364) * @notify_priv: Passed as argument to the v4l2_ctrl notify callback.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 365) * @nr_of_buckets: Total number of buckets in the array.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 366) * @error: The error code of the first failed control addition.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 367) * @request_is_queued: True if the request was queued.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 368) * @requests: List to keep track of open control handler request objects.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 369) * For the parent control handler (@req_obj.ops == NULL) this
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 370) * is the list header. When the parent control handler is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 371) * removed, it has to unbind and put all these requests since
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 372) * they refer to the parent.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 373) * @requests_queued: List of the queued requests. This determines the order
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 374) * in which these controls are applied. Once the request is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 375) * completed it is removed from this list.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 376) * @req_obj: The &struct media_request_object, used to link into a
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 377) * &struct media_request. This request object has a refcount.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 378) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 379) struct v4l2_ctrl_handler {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 380) struct mutex _lock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 381) struct mutex *lock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 382) struct list_head ctrls;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 383) struct list_head ctrl_refs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 384) struct v4l2_ctrl_ref *cached;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 385) struct v4l2_ctrl_ref **buckets;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 386) v4l2_ctrl_notify_fnc notify;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 387) void *notify_priv;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 388) u16 nr_of_buckets;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 389) int error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 390) bool request_is_queued;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 391) struct list_head requests;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 392) struct list_head requests_queued;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 393) struct media_request_object req_obj;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 394)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 395) ANDROID_KABI_RESERVE(1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 396) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 397)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 398) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 399) * struct v4l2_ctrl_config - Control configuration structure.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 400) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 401) * @ops: The control ops.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 402) * @type_ops: The control type ops. Only needed for compound controls.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 403) * @id: The control ID.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 404) * @name: The control name.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 405) * @type: The control type.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 406) * @min: The control's minimum value.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 407) * @max: The control's maximum value.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 408) * @step: The control's step value for non-menu controls.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 409) * @def: The control's default value.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 410) * @p_def: The control's default value for compound controls.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 411) * @dims: The size of each dimension.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 412) * @elem_size: The size in bytes of the control.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 413) * @flags: The control's flags.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 414) * @menu_skip_mask: The control's skip mask for menu controls. This makes it
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 415) * easy to skip menu items that are not valid. If bit X is set,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 416) * then menu item X is skipped. Of course, this only works for
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 417) * menus with <= 64 menu items. There are no menus that come
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 418) * close to that number, so this is OK. Should we ever need more,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 419) * then this will have to be extended to a bit array.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 420) * @qmenu: A const char * array for all menu items. Array entries that are
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 421) * empty strings ("") correspond to non-existing menu items (this
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 422) * is in addition to the menu_skip_mask above). The last entry
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 423) * must be NULL.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 424) * @qmenu_int: A const s64 integer array for all menu items of the type
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 425) * V4L2_CTRL_TYPE_INTEGER_MENU.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 426) * @is_private: If set, then this control is private to its handler and it
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 427) * will not be added to any other handlers.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 428) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 429) struct v4l2_ctrl_config {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 430) const struct v4l2_ctrl_ops *ops;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 431) const struct v4l2_ctrl_type_ops *type_ops;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 432) u32 id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 433) const char *name;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 434) enum v4l2_ctrl_type type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 435) s64 min;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 436) s64 max;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 437) u64 step;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 438) s64 def;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 439) union v4l2_ctrl_ptr p_def;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 440) u32 dims[V4L2_CTRL_MAX_DIMS];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 441) u32 elem_size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 442) u32 flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 443) u64 menu_skip_mask;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 444) const char * const *qmenu;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 445) const s64 *qmenu_int;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 446) unsigned int is_private:1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 447)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 448) ANDROID_KABI_RESERVE(1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 449) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 450)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 451) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 452) * v4l2_ctrl_fill - Fill in the control fields based on the control ID.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 453) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 454) * @id: ID of the control
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 455) * @name: pointer to be filled with a string with the name of the control
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 456) * @type: pointer for storing the type of the control
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 457) * @min: pointer for storing the minimum value for the control
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 458) * @max: pointer for storing the maximum value for the control
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 459) * @step: pointer for storing the control step
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 460) * @def: pointer for storing the default value for the control
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 461) * @flags: pointer for storing the flags to be used on the control
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 462) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 463) * This works for all standard V4L2 controls.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 464) * For non-standard controls it will only fill in the given arguments
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 465) * and @name content will be set to %NULL.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 466) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 467) * This function will overwrite the contents of @name, @type and @flags.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 468) * The contents of @min, @max, @step and @def may be modified depending on
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 469) * the type.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 470) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 471) * .. note::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 472) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 473) * Do not use in drivers! It is used internally for backwards compatibility
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 474) * control handling only. Once all drivers are converted to use the new
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 475) * control framework this function will no longer be exported.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 476) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 477) void v4l2_ctrl_fill(u32 id, const char **name, enum v4l2_ctrl_type *type,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 478) s64 *min, s64 *max, u64 *step, s64 *def, u32 *flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 479)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 480)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 481) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 482) * v4l2_ctrl_handler_init_class() - Initialize the control handler.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 483) * @hdl: The control handler.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 484) * @nr_of_controls_hint: A hint of how many controls this handler is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 485) * expected to refer to. This is the total number, so including
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 486) * any inherited controls. It doesn't have to be precise, but if
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 487) * it is way off, then you either waste memory (too many buckets
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 488) * are allocated) or the control lookup becomes slower (not enough
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 489) * buckets are allocated, so there are more slow list lookups).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 490) * It will always work, though.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 491) * @key: Used by the lock validator if CONFIG_LOCKDEP is set.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 492) * @name: Used by the lock validator if CONFIG_LOCKDEP is set.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 493) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 494) * .. attention::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 495) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 496) * Never use this call directly, always use the v4l2_ctrl_handler_init()
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 497) * macro that hides the @key and @name arguments.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 498) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 499) * Return: returns an error if the buckets could not be allocated. This
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 500) * error will also be stored in @hdl->error.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 501) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 502) int v4l2_ctrl_handler_init_class(struct v4l2_ctrl_handler *hdl,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 503) unsigned int nr_of_controls_hint,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 504) struct lock_class_key *key, const char *name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 505)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 506) #ifdef CONFIG_LOCKDEP
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 507)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 508) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 509) * v4l2_ctrl_handler_init - helper function to create a static struct
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 510) * &lock_class_key and calls v4l2_ctrl_handler_init_class()
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 511) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 512) * @hdl: The control handler.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 513) * @nr_of_controls_hint: A hint of how many controls this handler is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 514) * expected to refer to. This is the total number, so including
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 515) * any inherited controls. It doesn't have to be precise, but if
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 516) * it is way off, then you either waste memory (too many buckets
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 517) * are allocated) or the control lookup becomes slower (not enough
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 518) * buckets are allocated, so there are more slow list lookups).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 519) * It will always work, though.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 520) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 521) * This helper function creates a static struct &lock_class_key and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 522) * calls v4l2_ctrl_handler_init_class(), providing a proper name for the lock
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 523) * validador.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 524) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 525) * Use this helper function to initialize a control handler.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 526) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 527) #define v4l2_ctrl_handler_init(hdl, nr_of_controls_hint) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 528) ( \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 529) ({ \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 530) static struct lock_class_key _key; \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 531) v4l2_ctrl_handler_init_class(hdl, nr_of_controls_hint, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 532) &_key, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 533) KBUILD_BASENAME ":" \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 534) __stringify(__LINE__) ":" \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 535) "(" #hdl ")->_lock"); \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 536) }) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 537) )
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 538) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 539) #define v4l2_ctrl_handler_init(hdl, nr_of_controls_hint) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 540) v4l2_ctrl_handler_init_class(hdl, nr_of_controls_hint, NULL, NULL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 541) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 542)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 543) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 544) * v4l2_ctrl_handler_free() - Free all controls owned by the handler and free
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 545) * the control list.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 546) * @hdl: The control handler.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 547) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 548) * Does nothing if @hdl == NULL.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 549) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 550) void v4l2_ctrl_handler_free(struct v4l2_ctrl_handler *hdl);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 551)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 552) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 553) * v4l2_ctrl_lock() - Helper function to lock the handler
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 554) * associated with the control.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 555) * @ctrl: The control to lock.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 556) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 557) static inline void v4l2_ctrl_lock(struct v4l2_ctrl *ctrl)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 558) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 559) mutex_lock(ctrl->handler->lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 560) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 561)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 562) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 563) * v4l2_ctrl_unlock() - Helper function to unlock the handler
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 564) * associated with the control.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 565) * @ctrl: The control to unlock.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 566) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 567) static inline void v4l2_ctrl_unlock(struct v4l2_ctrl *ctrl)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 568) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 569) mutex_unlock(ctrl->handler->lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 570) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 571)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 572) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 573) * __v4l2_ctrl_handler_setup() - Call the s_ctrl op for all controls belonging
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 574) * to the handler to initialize the hardware to the current control values. The
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 575) * caller is responsible for acquiring the control handler mutex on behalf of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 576) * __v4l2_ctrl_handler_setup().
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 577) * @hdl: The control handler.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 578) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 579) * Button controls will be skipped, as are read-only controls.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 580) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 581) * If @hdl == NULL, then this just returns 0.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 582) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 583) int __v4l2_ctrl_handler_setup(struct v4l2_ctrl_handler *hdl);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 584)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 585) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 586) * v4l2_ctrl_handler_setup() - Call the s_ctrl op for all controls belonging
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 587) * to the handler to initialize the hardware to the current control values.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 588) * @hdl: The control handler.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 589) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 590) * Button controls will be skipped, as are read-only controls.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 591) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 592) * If @hdl == NULL, then this just returns 0.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 593) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 594) int v4l2_ctrl_handler_setup(struct v4l2_ctrl_handler *hdl);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 595)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 596) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 597) * v4l2_ctrl_handler_log_status() - Log all controls owned by the handler.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 598) * @hdl: The control handler.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 599) * @prefix: The prefix to use when logging the control values. If the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 600) * prefix does not end with a space, then ": " will be added
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 601) * after the prefix. If @prefix == NULL, then no prefix will be
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 602) * used.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 603) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 604) * For use with VIDIOC_LOG_STATUS.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 605) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 606) * Does nothing if @hdl == NULL.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 607) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 608) void v4l2_ctrl_handler_log_status(struct v4l2_ctrl_handler *hdl,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 609) const char *prefix);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 610)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 611) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 612) * v4l2_ctrl_new_custom() - Allocate and initialize a new custom V4L2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 613) * control.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 614) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 615) * @hdl: The control handler.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 616) * @cfg: The control's configuration data.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 617) * @priv: The control's driver-specific private data.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 618) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 619) * If the &v4l2_ctrl struct could not be allocated then NULL is returned
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 620) * and @hdl->error is set to the error code (if it wasn't set already).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 621) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 622) struct v4l2_ctrl *v4l2_ctrl_new_custom(struct v4l2_ctrl_handler *hdl,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 623) const struct v4l2_ctrl_config *cfg,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 624) void *priv);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 625)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 626) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 627) * v4l2_ctrl_new_std() - Allocate and initialize a new standard V4L2 non-menu
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 628) * control.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 629) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 630) * @hdl: The control handler.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 631) * @ops: The control ops.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 632) * @id: The control ID.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 633) * @min: The control's minimum value.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 634) * @max: The control's maximum value.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 635) * @step: The control's step value
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 636) * @def: The control's default value.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 637) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 638) * If the &v4l2_ctrl struct could not be allocated, or the control
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 639) * ID is not known, then NULL is returned and @hdl->error is set to the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 640) * appropriate error code (if it wasn't set already).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 641) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 642) * If @id refers to a menu control, then this function will return NULL.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 643) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 644) * Use v4l2_ctrl_new_std_menu() when adding menu controls.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 645) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 646) struct v4l2_ctrl *v4l2_ctrl_new_std(struct v4l2_ctrl_handler *hdl,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 647) const struct v4l2_ctrl_ops *ops,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 648) u32 id, s64 min, s64 max, u64 step,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 649) s64 def);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 650)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 651) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 652) * v4l2_ctrl_new_std_menu() - Allocate and initialize a new standard V4L2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 653) * menu control.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 654) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 655) * @hdl: The control handler.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 656) * @ops: The control ops.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 657) * @id: The control ID.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 658) * @max: The control's maximum value.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 659) * @mask: The control's skip mask for menu controls. This makes it
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 660) * easy to skip menu items that are not valid. If bit X is set,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 661) * then menu item X is skipped. Of course, this only works for
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 662) * menus with <= 64 menu items. There are no menus that come
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 663) * close to that number, so this is OK. Should we ever need more,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 664) * then this will have to be extended to a bit array.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 665) * @def: The control's default value.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 666) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 667) * Same as v4l2_ctrl_new_std(), but @min is set to 0 and the @mask value
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 668) * determines which menu items are to be skipped.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 669) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 670) * If @id refers to a non-menu control, then this function will return NULL.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 671) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 672) struct v4l2_ctrl *v4l2_ctrl_new_std_menu(struct v4l2_ctrl_handler *hdl,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 673) const struct v4l2_ctrl_ops *ops,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 674) u32 id, u8 max, u64 mask, u8 def);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 675)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 676) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 677) * v4l2_ctrl_new_std_menu_items() - Create a new standard V4L2 menu control
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 678) * with driver specific menu.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 679) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 680) * @hdl: The control handler.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 681) * @ops: The control ops.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 682) * @id: The control ID.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 683) * @max: The control's maximum value.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 684) * @mask: The control's skip mask for menu controls. This makes it
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 685) * easy to skip menu items that are not valid. If bit X is set,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 686) * then menu item X is skipped. Of course, this only works for
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 687) * menus with <= 64 menu items. There are no menus that come
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 688) * close to that number, so this is OK. Should we ever need more,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 689) * then this will have to be extended to a bit array.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 690) * @def: The control's default value.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 691) * @qmenu: The new menu.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 692) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 693) * Same as v4l2_ctrl_new_std_menu(), but @qmenu will be the driver specific
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 694) * menu of this control.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 695) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 696) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 697) struct v4l2_ctrl *v4l2_ctrl_new_std_menu_items(struct v4l2_ctrl_handler *hdl,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 698) const struct v4l2_ctrl_ops *ops,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 699) u32 id, u8 max,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 700) u64 mask, u8 def,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 701) const char * const *qmenu);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 702)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 703) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 704) * v4l2_ctrl_new_std_compound() - Allocate and initialize a new standard V4L2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 705) * compound control.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 706) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 707) * @hdl: The control handler.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 708) * @ops: The control ops.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 709) * @id: The control ID.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 710) * @p_def: The control's default value.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 711) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 712) * Sames as v4l2_ctrl_new_std(), but with support to compound controls, thanks
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 713) * to the @p_def field. Use v4l2_ctrl_ptr_create() to create @p_def from a
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 714) * pointer. Use v4l2_ctrl_ptr_create(NULL) if the default value of the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 715) * compound control should be all zeroes.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 716) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 717) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 718) struct v4l2_ctrl *v4l2_ctrl_new_std_compound(struct v4l2_ctrl_handler *hdl,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 719) const struct v4l2_ctrl_ops *ops,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 720) u32 id,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 721) const union v4l2_ctrl_ptr p_def);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 722)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 723) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 724) * v4l2_ctrl_new_int_menu() - Create a new standard V4L2 integer menu control.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 725) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 726) * @hdl: The control handler.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 727) * @ops: The control ops.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 728) * @id: The control ID.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 729) * @max: The control's maximum value.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 730) * @def: The control's default value.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 731) * @qmenu_int: The control's menu entries.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 732) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 733) * Same as v4l2_ctrl_new_std_menu(), but @mask is set to 0 and it additionally
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 734) * takes as an argument an array of integers determining the menu items.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 735) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 736) * If @id refers to a non-integer-menu control, then this function will
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 737) * return %NULL.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 738) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 739) struct v4l2_ctrl *v4l2_ctrl_new_int_menu(struct v4l2_ctrl_handler *hdl,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 740) const struct v4l2_ctrl_ops *ops,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 741) u32 id, u8 max, u8 def,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 742) const s64 *qmenu_int);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 743)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 744) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 745) * typedef v4l2_ctrl_filter - Typedef to define the filter function to be
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 746) * used when adding a control handler.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 747) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 748) * @ctrl: pointer to struct &v4l2_ctrl.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 749) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 750)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 751) typedef bool (*v4l2_ctrl_filter)(const struct v4l2_ctrl *ctrl);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 752)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 753) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 754) * v4l2_ctrl_add_handler() - Add all controls from handler @add to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 755) * handler @hdl.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 756) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 757) * @hdl: The control handler.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 758) * @add: The control handler whose controls you want to add to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 759) * the @hdl control handler.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 760) * @filter: This function will filter which controls should be added.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 761) * @from_other_dev: If true, then the controls in @add were defined in another
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 762) * device than @hdl.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 763) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 764) * Does nothing if either of the two handlers is a NULL pointer.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 765) * If @filter is NULL, then all controls are added. Otherwise only those
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 766) * controls for which @filter returns true will be added.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 767) * In case of an error @hdl->error will be set to the error code (if it
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 768) * wasn't set already).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 769) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 770) int v4l2_ctrl_add_handler(struct v4l2_ctrl_handler *hdl,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 771) struct v4l2_ctrl_handler *add,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 772) v4l2_ctrl_filter filter,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 773) bool from_other_dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 774)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 775) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 776) * v4l2_ctrl_radio_filter() - Standard filter for radio controls.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 777) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 778) * @ctrl: The control that is filtered.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 779) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 780) * This will return true for any controls that are valid for radio device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 781) * nodes. Those are all of the V4L2_CID_AUDIO_* user controls and all FM
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 782) * transmitter class controls.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 783) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 784) * This function is to be used with v4l2_ctrl_add_handler().
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 785) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 786) bool v4l2_ctrl_radio_filter(const struct v4l2_ctrl *ctrl);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 787)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 788) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 789) * v4l2_ctrl_cluster() - Mark all controls in the cluster as belonging
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 790) * to that cluster.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 791) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 792) * @ncontrols: The number of controls in this cluster.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 793) * @controls: The cluster control array of size @ncontrols.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 794) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 795) void v4l2_ctrl_cluster(unsigned int ncontrols, struct v4l2_ctrl **controls);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 796)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 797)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 798) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 799) * v4l2_ctrl_auto_cluster() - Mark all controls in the cluster as belonging
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 800) * to that cluster and set it up for autofoo/foo-type handling.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 801) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 802) * @ncontrols: The number of controls in this cluster.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 803) * @controls: The cluster control array of size @ncontrols. The first control
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 804) * must be the 'auto' control (e.g. autogain, autoexposure, etc.)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 805) * @manual_val: The value for the first control in the cluster that equals the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 806) * manual setting.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 807) * @set_volatile: If true, then all controls except the first auto control will
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 808) * be volatile.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 809) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 810) * Use for control groups where one control selects some automatic feature and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 811) * the other controls are only active whenever the automatic feature is turned
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 812) * off (manual mode). Typical examples: autogain vs gain, auto-whitebalance vs
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 813) * red and blue balance, etc.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 814) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 815) * The behavior of such controls is as follows:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 816) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 817) * When the autofoo control is set to automatic, then any manual controls
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 818) * are set to inactive and any reads will call g_volatile_ctrl (if the control
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 819) * was marked volatile).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 820) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 821) * When the autofoo control is set to manual, then any manual controls will
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 822) * be marked active, and any reads will just return the current value without
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 823) * going through g_volatile_ctrl.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 824) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 825) * In addition, this function will set the %V4L2_CTRL_FLAG_UPDATE flag
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 826) * on the autofoo control and %V4L2_CTRL_FLAG_INACTIVE on the foo control(s)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 827) * if autofoo is in auto mode.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 828) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 829) void v4l2_ctrl_auto_cluster(unsigned int ncontrols,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 830) struct v4l2_ctrl **controls,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 831) u8 manual_val, bool set_volatile);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 832)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 833)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 834) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 835) * v4l2_ctrl_find() - Find a control with the given ID.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 836) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 837) * @hdl: The control handler.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 838) * @id: The control ID to find.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 839) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 840) * If @hdl == NULL this will return NULL as well. Will lock the handler so
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 841) * do not use from inside &v4l2_ctrl_ops.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 842) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 843) struct v4l2_ctrl *v4l2_ctrl_find(struct v4l2_ctrl_handler *hdl, u32 id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 844)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 845) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 846) * v4l2_ctrl_activate() - Make the control active or inactive.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 847) * @ctrl: The control to (de)activate.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 848) * @active: True if the control should become active.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 849) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 850) * This sets or clears the V4L2_CTRL_FLAG_INACTIVE flag atomically.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 851) * Does nothing if @ctrl == NULL.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 852) * This will usually be called from within the s_ctrl op.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 853) * The V4L2_EVENT_CTRL event will be generated afterwards.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 854) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 855) * This function assumes that the control handler is locked.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 856) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 857) void v4l2_ctrl_activate(struct v4l2_ctrl *ctrl, bool active);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 858)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 859) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 860) * __v4l2_ctrl_grab() - Unlocked variant of v4l2_ctrl_grab.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 861) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 862) * @ctrl: The control to (de)activate.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 863) * @grabbed: True if the control should become grabbed.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 864) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 865) * This sets or clears the V4L2_CTRL_FLAG_GRABBED flag atomically.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 866) * Does nothing if @ctrl == NULL.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 867) * The V4L2_EVENT_CTRL event will be generated afterwards.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 868) * This will usually be called when starting or stopping streaming in the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 869) * driver.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 870) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 871) * This function assumes that the control handler is locked by the caller.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 872) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 873) void __v4l2_ctrl_grab(struct v4l2_ctrl *ctrl, bool grabbed);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 874)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 875) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 876) * v4l2_ctrl_grab() - Mark the control as grabbed or not grabbed.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 877) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 878) * @ctrl: The control to (de)activate.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 879) * @grabbed: True if the control should become grabbed.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 880) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 881) * This sets or clears the V4L2_CTRL_FLAG_GRABBED flag atomically.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 882) * Does nothing if @ctrl == NULL.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 883) * The V4L2_EVENT_CTRL event will be generated afterwards.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 884) * This will usually be called when starting or stopping streaming in the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 885) * driver.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 886) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 887) * This function assumes that the control handler is not locked and will
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 888) * take the lock itself.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 889) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 890) static inline void v4l2_ctrl_grab(struct v4l2_ctrl *ctrl, bool grabbed)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 891) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 892) if (!ctrl)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 893) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 894)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 895) v4l2_ctrl_lock(ctrl);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 896) __v4l2_ctrl_grab(ctrl, grabbed);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 897) v4l2_ctrl_unlock(ctrl);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 898) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 899)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 900) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 901) *__v4l2_ctrl_modify_range() - Unlocked variant of v4l2_ctrl_modify_range()
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 902) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 903) * @ctrl: The control to update.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 904) * @min: The control's minimum value.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 905) * @max: The control's maximum value.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 906) * @step: The control's step value
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 907) * @def: The control's default value.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 908) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 909) * Update the range of a control on the fly. This works for control types
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 910) * INTEGER, BOOLEAN, MENU, INTEGER MENU and BITMASK. For menu controls the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 911) * @step value is interpreted as a menu_skip_mask.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 912) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 913) * An error is returned if one of the range arguments is invalid for this
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 914) * control type.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 915) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 916) * The caller is responsible for acquiring the control handler mutex on behalf
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 917) * of __v4l2_ctrl_modify_range().
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 918) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 919) int __v4l2_ctrl_modify_range(struct v4l2_ctrl *ctrl,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 920) s64 min, s64 max, u64 step, s64 def);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 921)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 922) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 923) * v4l2_ctrl_modify_range() - Update the range of a control.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 924) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 925) * @ctrl: The control to update.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 926) * @min: The control's minimum value.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 927) * @max: The control's maximum value.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 928) * @step: The control's step value
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 929) * @def: The control's default value.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 930) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 931) * Update the range of a control on the fly. This works for control types
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 932) * INTEGER, BOOLEAN, MENU, INTEGER MENU and BITMASK. For menu controls the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 933) * @step value is interpreted as a menu_skip_mask.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 934) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 935) * An error is returned if one of the range arguments is invalid for this
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 936) * control type.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 937) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 938) * This function assumes that the control handler is not locked and will
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 939) * take the lock itself.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 940) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 941) static inline int v4l2_ctrl_modify_range(struct v4l2_ctrl *ctrl,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 942) s64 min, s64 max, u64 step, s64 def)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 943) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 944) int rval;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 945)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 946) v4l2_ctrl_lock(ctrl);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 947) rval = __v4l2_ctrl_modify_range(ctrl, min, max, step, def);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 948) v4l2_ctrl_unlock(ctrl);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 949)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 950) return rval;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 951) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 952)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 953) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 954) * v4l2_ctrl_notify() - Function to set a notify callback for a control.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 955) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 956) * @ctrl: The control.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 957) * @notify: The callback function.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 958) * @priv: The callback private handle, passed as argument to the callback.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 959) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 960) * This function sets a callback function for the control. If @ctrl is NULL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 961) * then it will do nothing. If @notify is NULL, then the notify callback will
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 962) * be removed.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 963) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 964) * There can be only one notify. If another already exists, then a WARN_ON
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 965) * will be issued and the function will do nothing.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 966) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 967) void v4l2_ctrl_notify(struct v4l2_ctrl *ctrl, v4l2_ctrl_notify_fnc notify,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 968) void *priv);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 969)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 970) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 971) * v4l2_ctrl_get_name() - Get the name of the control
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 972) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 973) * @id: The control ID.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 974) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 975) * This function returns the name of the given control ID or NULL if it isn't
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 976) * a known control.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 977) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 978) const char *v4l2_ctrl_get_name(u32 id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 979)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 980) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 981) * v4l2_ctrl_get_menu() - Get the menu string array of the control
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 982) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 983) * @id: The control ID.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 984) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 985) * This function returns the NULL-terminated menu string array name of the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 986) * given control ID or NULL if it isn't a known menu control.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 987) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 988) const char * const *v4l2_ctrl_get_menu(u32 id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 989)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 990) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 991) * v4l2_ctrl_get_int_menu() - Get the integer menu array of the control
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 992) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 993) * @id: The control ID.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 994) * @len: The size of the integer array.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 995) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 996) * This function returns the integer array of the given control ID or NULL if it
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 997) * if it isn't a known integer menu control.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 998) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 999) const s64 *v4l2_ctrl_get_int_menu(u32 id, u32 *len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1000)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1001) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1002) * v4l2_ctrl_g_ctrl() - Helper function to get the control's value from
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1003) * within a driver.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1004) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1005) * @ctrl: The control.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1006) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1007) * This returns the control's value safely by going through the control
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1008) * framework. This function will lock the control's handler, so it cannot be
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1009) * used from within the &v4l2_ctrl_ops functions.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1010) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1011) * This function is for integer type controls only.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1012) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1013) s32 v4l2_ctrl_g_ctrl(struct v4l2_ctrl *ctrl);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1014)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1015) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1016) * __v4l2_ctrl_s_ctrl() - Unlocked variant of v4l2_ctrl_s_ctrl().
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1017) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1018) * @ctrl: The control.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1019) * @val: The new value.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1020) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1021) * This sets the control's new value safely by going through the control
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1022) * framework. This function assumes the control's handler is already locked,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1023) * allowing it to be used from within the &v4l2_ctrl_ops functions.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1024) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1025) * This function is for integer type controls only.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1026) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1027) int __v4l2_ctrl_s_ctrl(struct v4l2_ctrl *ctrl, s32 val);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1028)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1029) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1030) * v4l2_ctrl_s_ctrl() - Helper function to set the control's value from
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1031) * within a driver.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1032) * @ctrl: The control.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1033) * @val: The new value.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1034) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1035) * This sets the control's new value safely by going through the control
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1036) * framework. This function will lock the control's handler, so it cannot be
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1037) * used from within the &v4l2_ctrl_ops functions.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1038) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1039) * This function is for integer type controls only.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1040) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1041) static inline int v4l2_ctrl_s_ctrl(struct v4l2_ctrl *ctrl, s32 val)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1042) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1043) int rval;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1044)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1045) v4l2_ctrl_lock(ctrl);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1046) rval = __v4l2_ctrl_s_ctrl(ctrl, val);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1047) v4l2_ctrl_unlock(ctrl);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1048)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1049) return rval;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1050) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1051)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1052) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1053) * v4l2_ctrl_g_ctrl_int64() - Helper function to get a 64-bit control's value
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1054) * from within a driver.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1055) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1056) * @ctrl: The control.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1057) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1058) * This returns the control's value safely by going through the control
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1059) * framework. This function will lock the control's handler, so it cannot be
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1060) * used from within the &v4l2_ctrl_ops functions.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1061) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1062) * This function is for 64-bit integer type controls only.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1063) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1064) s64 v4l2_ctrl_g_ctrl_int64(struct v4l2_ctrl *ctrl);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1065)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1066) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1067) * __v4l2_ctrl_s_ctrl_int64() - Unlocked variant of v4l2_ctrl_s_ctrl_int64().
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1068) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1069) * @ctrl: The control.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1070) * @val: The new value.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1071) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1072) * This sets the control's new value safely by going through the control
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1073) * framework. This function assumes the control's handler is already locked,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1074) * allowing it to be used from within the &v4l2_ctrl_ops functions.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1075) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1076) * This function is for 64-bit integer type controls only.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1077) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1078) int __v4l2_ctrl_s_ctrl_int64(struct v4l2_ctrl *ctrl, s64 val);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1079)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1080) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1081) * v4l2_ctrl_s_ctrl_int64() - Helper function to set a 64-bit control's value
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1082) * from within a driver.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1083) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1084) * @ctrl: The control.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1085) * @val: The new value.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1086) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1087) * This sets the control's new value safely by going through the control
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1088) * framework. This function will lock the control's handler, so it cannot be
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1089) * used from within the &v4l2_ctrl_ops functions.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1090) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1091) * This function is for 64-bit integer type controls only.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1092) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1093) static inline int v4l2_ctrl_s_ctrl_int64(struct v4l2_ctrl *ctrl, s64 val)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1094) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1095) int rval;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1096)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1097) v4l2_ctrl_lock(ctrl);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1098) rval = __v4l2_ctrl_s_ctrl_int64(ctrl, val);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1099) v4l2_ctrl_unlock(ctrl);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1100)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1101) return rval;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1102) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1103)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1104) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1105) * __v4l2_ctrl_s_ctrl_string() - Unlocked variant of v4l2_ctrl_s_ctrl_string().
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1106) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1107) * @ctrl: The control.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1108) * @s: The new string.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1109) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1110) * This sets the control's new string safely by going through the control
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1111) * framework. This function assumes the control's handler is already locked,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1112) * allowing it to be used from within the &v4l2_ctrl_ops functions.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1113) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1114) * This function is for string type controls only.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1115) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1116) int __v4l2_ctrl_s_ctrl_string(struct v4l2_ctrl *ctrl, const char *s);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1117)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1118) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1119) * v4l2_ctrl_s_ctrl_string() - Helper function to set a control's string value
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1120) * from within a driver.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1121) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1122) * @ctrl: The control.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1123) * @s: The new string.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1124) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1125) * This sets the control's new string safely by going through the control
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1126) * framework. This function will lock the control's handler, so it cannot be
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1127) * used from within the &v4l2_ctrl_ops functions.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1128) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1129) * This function is for string type controls only.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1130) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1131) static inline int v4l2_ctrl_s_ctrl_string(struct v4l2_ctrl *ctrl, const char *s)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1132) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1133) int rval;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1134)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1135) v4l2_ctrl_lock(ctrl);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1136) rval = __v4l2_ctrl_s_ctrl_string(ctrl, s);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1137) v4l2_ctrl_unlock(ctrl);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1138)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1139) return rval;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1140) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1141)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1142) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1143) * __v4l2_ctrl_s_ctrl_compound() - Unlocked variant to set a compound control
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1144) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1145) * @ctrl: The control.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1146) * @type: The type of the data.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1147) * @p: The new compound payload.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1148) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1149) * This sets the control's new compound payload safely by going through the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1150) * control framework. This function assumes the control's handler is already
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1151) * locked, allowing it to be used from within the &v4l2_ctrl_ops functions.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1152) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1153) * This function is for compound type controls only.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1154) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1155) int __v4l2_ctrl_s_ctrl_compound(struct v4l2_ctrl *ctrl,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1156) enum v4l2_ctrl_type type, const void *p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1157)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1158) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1159) * v4l2_ctrl_s_ctrl_compound() - Helper function to set a compound control
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1160) * from within a driver.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1161) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1162) * @ctrl: The control.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1163) * @type: The type of the data.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1164) * @p: The new compound payload.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1165) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1166) * This sets the control's new compound payload safely by going through the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1167) * control framework. This function will lock the control's handler, so it
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1168) * cannot be used from within the &v4l2_ctrl_ops functions.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1169) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1170) * This function is for compound type controls only.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1171) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1172) static inline int v4l2_ctrl_s_ctrl_compound(struct v4l2_ctrl *ctrl,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1173) enum v4l2_ctrl_type type,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1174) const void *p)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1175) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1176) int rval;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1177)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1178) v4l2_ctrl_lock(ctrl);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1179) rval = __v4l2_ctrl_s_ctrl_compound(ctrl, type, p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1180) v4l2_ctrl_unlock(ctrl);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1181)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1182) return rval;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1183) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1184)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1185) /* Helper defines for area type controls */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1186) #define __v4l2_ctrl_s_ctrl_area(ctrl, area) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1187) __v4l2_ctrl_s_ctrl_compound((ctrl), V4L2_CTRL_TYPE_AREA, (area))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1188) #define v4l2_ctrl_s_ctrl_area(ctrl, area) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1189) v4l2_ctrl_s_ctrl_compound((ctrl), V4L2_CTRL_TYPE_AREA, (area))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1190)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1191) /* Internal helper functions that deal with control events. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1192) extern const struct v4l2_subscribed_event_ops v4l2_ctrl_sub_ev_ops;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1193)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1194) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1195) * v4l2_ctrl_replace - Function to be used as a callback to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1196) * &struct v4l2_subscribed_event_ops replace\(\)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1197) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1198) * @old: pointer to struct &v4l2_event with the reported
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1199) * event;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1200) * @new: pointer to struct &v4l2_event with the modified
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1201) * event;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1202) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1203) void v4l2_ctrl_replace(struct v4l2_event *old, const struct v4l2_event *new);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1204)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1205) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1206) * v4l2_ctrl_merge - Function to be used as a callback to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1207) * &struct v4l2_subscribed_event_ops merge(\)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1208) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1209) * @old: pointer to struct &v4l2_event with the reported
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1210) * event;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1211) * @new: pointer to struct &v4l2_event with the merged
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1212) * event;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1213) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1214) void v4l2_ctrl_merge(const struct v4l2_event *old, struct v4l2_event *new);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1215)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1216) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1217) * v4l2_ctrl_log_status - helper function to implement %VIDIOC_LOG_STATUS ioctl
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1218) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1219) * @file: pointer to struct file
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1220) * @fh: unused. Kept just to be compatible to the arguments expected by
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1221) * &struct v4l2_ioctl_ops.vidioc_log_status.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1222) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1223) * Can be used as a vidioc_log_status function that just dumps all controls
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1224) * associated with the filehandle.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1225) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1226) int v4l2_ctrl_log_status(struct file *file, void *fh);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1227)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1228) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1229) * v4l2_ctrl_subscribe_event - Subscribes to an event
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1230) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1231) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1232) * @fh: pointer to struct v4l2_fh
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1233) * @sub: pointer to &struct v4l2_event_subscription
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1234) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1235) * Can be used as a vidioc_subscribe_event function that just subscribes
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1236) * control events.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1237) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1238) int v4l2_ctrl_subscribe_event(struct v4l2_fh *fh,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1239) const struct v4l2_event_subscription *sub);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1240)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1241) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1242) * v4l2_ctrl_poll - function to be used as a callback to the poll()
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1243) * That just polls for control events.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1244) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1245) * @file: pointer to struct file
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1246) * @wait: pointer to struct poll_table_struct
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1247) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1248) __poll_t v4l2_ctrl_poll(struct file *file, struct poll_table_struct *wait);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1249)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1250) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1251) * v4l2_ctrl_request_setup - helper function to apply control values in a request
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1252) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1253) * @req: The request
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1254) * @parent: The parent control handler ('priv' in media_request_object_find())
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1255) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1256) * This is a helper function to call the control handler's s_ctrl callback with
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1257) * the control values contained in the request. Do note that this approach of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1258) * applying control values in a request is only applicable to memory-to-memory
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1259) * devices.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1260) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1261) int v4l2_ctrl_request_setup(struct media_request *req,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1262) struct v4l2_ctrl_handler *parent);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1263)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1264) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1265) * v4l2_ctrl_request_complete - Complete a control handler request object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1266) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1267) * @req: The request
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1268) * @parent: The parent control handler ('priv' in media_request_object_find())
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1269) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1270) * This function is to be called on each control handler that may have had a
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1271) * request object associated with it, i.e. control handlers of a driver that
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1272) * supports requests.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1273) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1274) * The function first obtains the values of any volatile controls in the control
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1275) * handler and attach them to the request. Then, the function completes the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1276) * request object.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1277) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1278) void v4l2_ctrl_request_complete(struct media_request *req,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1279) struct v4l2_ctrl_handler *parent);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1280)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1281) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1282) * v4l2_ctrl_request_hdl_find - Find the control handler in the request
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1283) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1284) * @req: The request
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1285) * @parent: The parent control handler ('priv' in media_request_object_find())
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1286) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1287) * This function finds the control handler in the request. It may return
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1288) * NULL if not found. When done, you must call v4l2_ctrl_request_put_hdl()
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1289) * with the returned handler pointer.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1290) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1291) * If the request is not in state VALIDATING or QUEUED, then this function
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1292) * will always return NULL.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1293) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1294) * Note that in state VALIDATING the req_queue_mutex is held, so
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1295) * no objects can be added or deleted from the request.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1296) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1297) * In state QUEUED it is the driver that will have to ensure this.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1298) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1299) struct v4l2_ctrl_handler *v4l2_ctrl_request_hdl_find(struct media_request *req,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1300) struct v4l2_ctrl_handler *parent);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1301)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1302) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1303) * v4l2_ctrl_request_hdl_put - Put the control handler
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1304) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1305) * @hdl: Put this control handler
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1306) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1307) * This function released the control handler previously obtained from'
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1308) * v4l2_ctrl_request_hdl_find().
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1309) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1310) static inline void v4l2_ctrl_request_hdl_put(struct v4l2_ctrl_handler *hdl)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1311) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1312) if (hdl)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1313) media_request_object_put(&hdl->req_obj);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1314) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1315)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1316) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1317) * v4l2_ctrl_request_ctrl_find() - Find a control with the given ID.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1318) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1319) * @hdl: The control handler from the request.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1320) * @id: The ID of the control to find.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1321) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1322) * This function returns a pointer to the control if this control is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1323) * part of the request or NULL otherwise.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1324) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1325) struct v4l2_ctrl *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1326) v4l2_ctrl_request_hdl_ctrl_find(struct v4l2_ctrl_handler *hdl, u32 id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1327)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1328) /* Helpers for ioctl_ops */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1329)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1330) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1331) * v4l2_queryctrl - Helper function to implement
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1332) * :ref:`VIDIOC_QUERYCTRL <vidioc_queryctrl>` ioctl
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1333) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1334) * @hdl: pointer to &struct v4l2_ctrl_handler
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1335) * @qc: pointer to &struct v4l2_queryctrl
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1336) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1337) * If hdl == NULL then they will all return -EINVAL.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1338) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1339) int v4l2_queryctrl(struct v4l2_ctrl_handler *hdl, struct v4l2_queryctrl *qc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1340)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1341) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1342) * v4l2_query_ext_ctrl - Helper function to implement
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1343) * :ref:`VIDIOC_QUERY_EXT_CTRL <vidioc_queryctrl>` ioctl
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1344) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1345) * @hdl: pointer to &struct v4l2_ctrl_handler
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1346) * @qc: pointer to &struct v4l2_query_ext_ctrl
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1347) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1348) * If hdl == NULL then they will all return -EINVAL.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1349) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1350) int v4l2_query_ext_ctrl(struct v4l2_ctrl_handler *hdl,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1351) struct v4l2_query_ext_ctrl *qc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1352)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1353) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1354) * v4l2_querymenu - Helper function to implement
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1355) * :ref:`VIDIOC_QUERYMENU <vidioc_queryctrl>` ioctl
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1356) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1357) * @hdl: pointer to &struct v4l2_ctrl_handler
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1358) * @qm: pointer to &struct v4l2_querymenu
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1359) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1360) * If hdl == NULL then they will all return -EINVAL.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1361) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1362) int v4l2_querymenu(struct v4l2_ctrl_handler *hdl, struct v4l2_querymenu *qm);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1363)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1364) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1365) * v4l2_g_ctrl - Helper function to implement
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1366) * :ref:`VIDIOC_G_CTRL <vidioc_g_ctrl>` ioctl
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1367) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1368) * @hdl: pointer to &struct v4l2_ctrl_handler
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1369) * @ctrl: pointer to &struct v4l2_control
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1370) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1371) * If hdl == NULL then they will all return -EINVAL.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1372) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1373) int v4l2_g_ctrl(struct v4l2_ctrl_handler *hdl, struct v4l2_control *ctrl);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1374)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1375) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1376) * v4l2_s_ctrl - Helper function to implement
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1377) * :ref:`VIDIOC_S_CTRL <vidioc_g_ctrl>` ioctl
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1378) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1379) * @fh: pointer to &struct v4l2_fh
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1380) * @hdl: pointer to &struct v4l2_ctrl_handler
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1381) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1382) * @ctrl: pointer to &struct v4l2_control
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1383) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1384) * If hdl == NULL then they will all return -EINVAL.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1385) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1386) int v4l2_s_ctrl(struct v4l2_fh *fh, struct v4l2_ctrl_handler *hdl,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1387) struct v4l2_control *ctrl);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1388)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1389) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1390) * v4l2_g_ext_ctrls - Helper function to implement
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1391) * :ref:`VIDIOC_G_EXT_CTRLS <vidioc_g_ext_ctrls>` ioctl
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1392) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1393) * @hdl: pointer to &struct v4l2_ctrl_handler
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1394) * @vdev: pointer to &struct video_device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1395) * @mdev: pointer to &struct media_device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1396) * @c: pointer to &struct v4l2_ext_controls
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1397) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1398) * If hdl == NULL then they will all return -EINVAL.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1399) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1400) int v4l2_g_ext_ctrls(struct v4l2_ctrl_handler *hdl, struct video_device *vdev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1401) struct media_device *mdev, struct v4l2_ext_controls *c);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1402)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1403) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1404) * v4l2_try_ext_ctrls - Helper function to implement
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1405) * :ref:`VIDIOC_TRY_EXT_CTRLS <vidioc_g_ext_ctrls>` ioctl
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1406) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1407) * @hdl: pointer to &struct v4l2_ctrl_handler
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1408) * @vdev: pointer to &struct video_device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1409) * @mdev: pointer to &struct media_device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1410) * @c: pointer to &struct v4l2_ext_controls
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1411) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1412) * If hdl == NULL then they will all return -EINVAL.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1413) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1414) int v4l2_try_ext_ctrls(struct v4l2_ctrl_handler *hdl,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1415) struct video_device *vdev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1416) struct media_device *mdev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1417) struct v4l2_ext_controls *c);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1418)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1419) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1420) * v4l2_s_ext_ctrls - Helper function to implement
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1421) * :ref:`VIDIOC_S_EXT_CTRLS <vidioc_g_ext_ctrls>` ioctl
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1422) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1423) * @fh: pointer to &struct v4l2_fh
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1424) * @hdl: pointer to &struct v4l2_ctrl_handler
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1425) * @vdev: pointer to &struct video_device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1426) * @mdev: pointer to &struct media_device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1427) * @c: pointer to &struct v4l2_ext_controls
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1428) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1429) * If hdl == NULL then they will all return -EINVAL.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1430) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1431) int v4l2_s_ext_ctrls(struct v4l2_fh *fh, struct v4l2_ctrl_handler *hdl,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1432) struct video_device *vdev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1433) struct media_device *mdev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1434) struct v4l2_ext_controls *c);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1435)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1436) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1437) * v4l2_ctrl_subdev_subscribe_event - Helper function to implement
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1438) * as a &struct v4l2_subdev_core_ops subscribe_event function
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1439) * that just subscribes control events.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1440) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1441) * @sd: pointer to &struct v4l2_subdev
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1442) * @fh: pointer to &struct v4l2_fh
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1443) * @sub: pointer to &struct v4l2_event_subscription
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1444) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1445) int v4l2_ctrl_subdev_subscribe_event(struct v4l2_subdev *sd, struct v4l2_fh *fh,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1446) struct v4l2_event_subscription *sub);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1447)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1448) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1449) * v4l2_ctrl_subdev_log_status - Log all controls owned by subdev's control
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1450) * handler.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1451) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1452) * @sd: pointer to &struct v4l2_subdev
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1453) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1454) int v4l2_ctrl_subdev_log_status(struct v4l2_subdev *sd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1455)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1456) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1457) * v4l2_ctrl_new_fwnode_properties() - Register controls for the device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1458) * properties
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1459) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1460) * @hdl: pointer to &struct v4l2_ctrl_handler to register controls on
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1461) * @ctrl_ops: pointer to &struct v4l2_ctrl_ops to register controls with
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1462) * @p: pointer to &struct v4l2_fwnode_device_properties
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1463) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1464) * This function registers controls associated to device properties, using the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1465) * property values contained in @p parameter, if the property has been set to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1466) * a value.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1467) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1468) * Currently the following v4l2 controls are parsed and registered:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1469) * - V4L2_CID_CAMERA_ORIENTATION
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1470) * - V4L2_CID_CAMERA_SENSOR_ROTATION;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1471) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1472) * Controls already registered by the caller with the @hdl control handler are
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1473) * not overwritten. Callers should register the controls they want to handle
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1474) * themselves before calling this function.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1475) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1476) * Return: 0 on success, a negative error code on failure.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1477) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1478) int v4l2_ctrl_new_fwnode_properties(struct v4l2_ctrl_handler *hdl,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1479) const struct v4l2_ctrl_ops *ctrl_ops,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1480) const struct v4l2_fwnode_device_properties *p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1481) #endif