2010-08-02 01:32:42 +08:00
|
|
|
/*
|
2016-07-23 00:57:29 +08:00
|
|
|
* V4L2 controls support header.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2010 Hans Verkuil <hverkuil@xs4all.nl>
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
2010-08-02 01:32:42 +08:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _V4L2_CTRLS_H
|
|
|
|
#define _V4L2_CTRLS_H
|
|
|
|
|
|
|
|
#include <linux/list.h>
|
2013-06-28 16:44:22 +08:00
|
|
|
#include <linux/mutex.h>
|
2010-11-19 22:20:06 +08:00
|
|
|
#include <linux/videodev2.h>
|
2018-05-21 16:54:37 +08:00
|
|
|
#include <media/media-request.h>
|
2010-08-02 01:32:42 +08:00
|
|
|
|
2018-12-05 19:28:20 +08:00
|
|
|
/*
|
2019-03-07 05:13:40 +08:00
|
|
|
* Include the mpeg2 and fwht stateless codec compound control definitions.
|
2018-12-05 19:28:20 +08:00
|
|
|
* This will move to the public headers once this API is fully stable.
|
|
|
|
*/
|
|
|
|
#include <media/mpeg2-ctrls.h>
|
2019-03-07 05:13:40 +08:00
|
|
|
#include <media/fwht-ctrls.h>
|
2018-12-05 19:28:20 +08:00
|
|
|
|
2010-08-02 01:32:42 +08:00
|
|
|
/* forward references */
|
2012-04-23 19:20:35 +08:00
|
|
|
struct file;
|
2010-08-02 01:32:42 +08:00
|
|
|
struct v4l2_ctrl_handler;
|
2011-06-14 21:04:06 +08:00
|
|
|
struct v4l2_ctrl_helper;
|
2010-08-02 01:32:42 +08:00
|
|
|
struct v4l2_ctrl;
|
|
|
|
struct video_device;
|
|
|
|
struct v4l2_subdev;
|
2011-06-14 05:55:58 +08:00
|
|
|
struct v4l2_subscribed_event;
|
2011-06-07 22:13:44 +08:00
|
|
|
struct v4l2_fh;
|
2012-01-28 03:18:42 +08:00
|
|
|
struct poll_table_struct;
|
2010-08-02 01:32:42 +08:00
|
|
|
|
2015-08-22 19:03:49 +08:00
|
|
|
/**
|
|
|
|
* union v4l2_ctrl_ptr - A pointer to a control value.
|
2018-09-13 22:51:52 +08:00
|
|
|
* @p_s32: Pointer to a 32-bit signed value.
|
|
|
|
* @p_s64: Pointer to a 64-bit signed value.
|
|
|
|
* @p_u8: Pointer to a 8-bit unsigned value.
|
|
|
|
* @p_u16: Pointer to a 16-bit unsigned value.
|
|
|
|
* @p_u32: Pointer to a 32-bit unsigned value.
|
|
|
|
* @p_char: Pointer to a string.
|
|
|
|
* @p_mpeg2_slice_params: Pointer to a MPEG2 slice parameters structure.
|
|
|
|
* @p_mpeg2_quantization: Pointer to a MPEG2 quantization data structure.
|
2019-03-07 05:13:40 +08:00
|
|
|
* @p_fwht_params: Pointer to a FWHT stateless parameters structure.
|
2018-09-13 22:51:52 +08:00
|
|
|
* @p: Pointer to a compound value.
|
2014-04-27 14:22:17 +08:00
|
|
|
*/
|
|
|
|
union v4l2_ctrl_ptr {
|
|
|
|
s32 *p_s32;
|
|
|
|
s64 *p_s64;
|
2014-06-10 18:30:04 +08:00
|
|
|
u8 *p_u8;
|
|
|
|
u16 *p_u16;
|
2014-07-21 21:45:37 +08:00
|
|
|
u32 *p_u32;
|
2014-04-27 14:22:17 +08:00
|
|
|
char *p_char;
|
2018-09-13 22:51:52 +08:00
|
|
|
struct v4l2_ctrl_mpeg2_slice_params *p_mpeg2_slice_params;
|
|
|
|
struct v4l2_ctrl_mpeg2_quantization *p_mpeg2_quantization;
|
2019-03-07 05:13:40 +08:00
|
|
|
struct v4l2_ctrl_fwht_params *p_fwht_params;
|
2014-04-27 14:22:17 +08:00
|
|
|
void *p;
|
|
|
|
};
|
|
|
|
|
2015-08-22 19:03:49 +08:00
|
|
|
/**
|
|
|
|
* struct v4l2_ctrl_ops - The control operations that the driver has to provide.
|
2016-07-23 00:57:29 +08:00
|
|
|
*
|
2015-08-22 19:03:49 +08:00
|
|
|
* @g_volatile_ctrl: Get a new value for this control. Generally only relevant
|
|
|
|
* for volatile (and usually read-only) controls such as a control
|
|
|
|
* that returns the current signal strength which changes
|
|
|
|
* continuously.
|
|
|
|
* If not set, then the currently cached value will be returned.
|
|
|
|
* @try_ctrl: Test whether the control's value is valid. Only relevant when
|
|
|
|
* the usual min/max/step checks are not sufficient.
|
|
|
|
* @s_ctrl: Actually set the new control value. s_ctrl is compulsory. The
|
|
|
|
* ctrl->handler->lock is held when these ops are called, so no
|
|
|
|
* one else can access controls owned by that handler.
|
|
|
|
*/
|
2010-08-02 01:32:42 +08:00
|
|
|
struct v4l2_ctrl_ops {
|
|
|
|
int (*g_volatile_ctrl)(struct v4l2_ctrl *ctrl);
|
|
|
|
int (*try_ctrl)(struct v4l2_ctrl *ctrl);
|
|
|
|
int (*s_ctrl)(struct v4l2_ctrl *ctrl);
|
|
|
|
};
|
|
|
|
|
2015-08-22 19:03:49 +08:00
|
|
|
/**
|
|
|
|
* struct v4l2_ctrl_type_ops - The control type operations that the driver
|
2016-07-23 00:57:29 +08:00
|
|
|
* has to provide.
|
2015-08-22 19:03:49 +08:00
|
|
|
*
|
|
|
|
* @equal: return true if both values are equal.
|
|
|
|
* @init: initialize the value.
|
|
|
|
* @log: log the value.
|
2016-07-23 00:57:29 +08:00
|
|
|
* @validate: validate the value. Return 0 on success and a negative value
|
|
|
|
* otherwise.
|
2015-08-22 19:03:49 +08:00
|
|
|
*/
|
2014-04-27 14:22:17 +08:00
|
|
|
struct v4l2_ctrl_type_ops {
|
2014-06-10 18:55:00 +08:00
|
|
|
bool (*equal)(const struct v4l2_ctrl *ctrl, u32 idx,
|
2014-04-27 14:22:17 +08:00
|
|
|
union v4l2_ctrl_ptr ptr1,
|
|
|
|
union v4l2_ctrl_ptr ptr2);
|
2014-06-10 18:55:00 +08:00
|
|
|
void (*init)(const struct v4l2_ctrl *ctrl, u32 idx,
|
2014-04-27 14:22:17 +08:00
|
|
|
union v4l2_ctrl_ptr ptr);
|
|
|
|
void (*log)(const struct v4l2_ctrl *ctrl);
|
2014-06-10 18:55:00 +08:00
|
|
|
int (*validate)(const struct v4l2_ctrl *ctrl, u32 idx,
|
2014-04-27 14:22:17 +08:00
|
|
|
union v4l2_ctrl_ptr ptr);
|
|
|
|
};
|
|
|
|
|
2016-08-30 04:26:15 +08:00
|
|
|
/**
|
|
|
|
* typedef v4l2_ctrl_notify_fnc - typedef for a notify argument with a function
|
|
|
|
* that should be called when a control value has changed.
|
|
|
|
*
|
|
|
|
* @ctrl: pointer to struct &v4l2_ctrl
|
|
|
|
* @priv: control private data
|
|
|
|
*
|
|
|
|
* This typedef definition is used as an argument to v4l2_ctrl_notify()
|
|
|
|
* and as an argument at struct &v4l2_ctrl_handler.
|
|
|
|
*/
|
2012-09-07 15:46:39 +08:00
|
|
|
typedef void (*v4l2_ctrl_notify_fnc)(struct v4l2_ctrl *ctrl, void *priv);
|
|
|
|
|
2015-08-22 19:03:49 +08:00
|
|
|
/**
|
|
|
|
* struct v4l2_ctrl - The control structure.
|
2016-07-23 00:57:29 +08:00
|
|
|
*
|
2015-08-22 19:03:49 +08:00
|
|
|
* @node: The list node.
|
|
|
|
* @ev_subs: The list of control event subscriptions.
|
|
|
|
* @handler: The handler that owns the control.
|
|
|
|
* @cluster: Point to start of cluster array.
|
|
|
|
* @ncontrols: Number of controls in cluster array.
|
|
|
|
* @done: Internal flag: set for each processed control.
|
|
|
|
* @is_new: Set when the user specified a new value for this control. It
|
2016-07-23 00:57:29 +08:00
|
|
|
* is also set when called from v4l2_ctrl_handler_setup(). Drivers
|
2015-08-22 19:03:49 +08:00
|
|
|
* should never set this flag.
|
|
|
|
* @has_changed: Set when the current value differs from the new value. Drivers
|
|
|
|
* should never use this flag.
|
|
|
|
* @is_private: If set, then this control is private to its handler and it
|
|
|
|
* will not be added to any other handlers. Drivers can set
|
|
|
|
* this flag.
|
|
|
|
* @is_auto: If set, then this control selects whether the other cluster
|
|
|
|
* members are in 'automatic' mode or 'manual' mode. This is
|
|
|
|
* used for autogain/gain type clusters. Drivers should never
|
|
|
|
* set this flag directly.
|
|
|
|
* @is_int: If set, then this control has a simple integer value (i.e. it
|
|
|
|
* uses ctrl->val).
|
2016-07-23 00:57:29 +08:00
|
|
|
* @is_string: If set, then this control has type %V4L2_CTRL_TYPE_STRING.
|
|
|
|
* @is_ptr: If set, then this control is an array and/or has type >=
|
|
|
|
* %V4L2_CTRL_COMPOUND_TYPES
|
|
|
|
* and/or has type %V4L2_CTRL_TYPE_STRING. In other words, &struct
|
2015-08-22 19:03:49 +08:00
|
|
|
* v4l2_ext_control uses field p to point to the data.
|
|
|
|
* @is_array: If set, then this control contains an N-dimensional array.
|
|
|
|
* @has_volatiles: If set, then one or more members of the cluster are volatile.
|
|
|
|
* Drivers should never touch this flag.
|
|
|
|
* @call_notify: If set, then call the handler's notify function whenever the
|
|
|
|
* control's value changes.
|
|
|
|
* @manual_mode_value: If the is_auto flag is set, then this is the value
|
|
|
|
* of the auto control that determines if that control is in
|
|
|
|
* manual mode. So if the value of the auto control equals this
|
|
|
|
* value, then the whole cluster is in manual mode. Drivers should
|
|
|
|
* never set this flag directly.
|
|
|
|
* @ops: The control ops.
|
|
|
|
* @type_ops: The control type ops.
|
|
|
|
* @id: The control ID.
|
|
|
|
* @name: The control name.
|
|
|
|
* @type: The control type.
|
|
|
|
* @minimum: The control's minimum value.
|
|
|
|
* @maximum: The control's maximum value.
|
|
|
|
* @default_value: The control's default value.
|
|
|
|
* @step: The control's step value for non-menu controls.
|
|
|
|
* @elems: The number of elements in the N-dimensional array.
|
|
|
|
* @elem_size: The size in bytes of the control.
|
|
|
|
* @dims: The size of each dimension.
|
|
|
|
* @nr_of_dims:The number of dimensions in @dims.
|
|
|
|
* @menu_skip_mask: The control's skip mask for menu controls. This makes it
|
|
|
|
* easy to skip menu items that are not valid. If bit X is set,
|
|
|
|
* then menu item X is skipped. Of course, this only works for
|
|
|
|
* menus with <= 32 menu items. There are no menus that come
|
|
|
|
* close to that number, so this is OK. Should we ever need more,
|
|
|
|
* then this will have to be extended to a u64 or a bit array.
|
|
|
|
* @qmenu: A const char * array for all menu items. Array entries that are
|
|
|
|
* empty strings ("") correspond to non-existing menu items (this
|
|
|
|
* is in addition to the menu_skip_mask above). The last entry
|
|
|
|
* must be NULL.
|
2017-09-28 00:25:21 +08:00
|
|
|
* Used only if the @type is %V4L2_CTRL_TYPE_MENU.
|
|
|
|
* @qmenu_int: A 64-bit integer array for with integer menu items.
|
|
|
|
* The size of array must be equal to the menu size, e. g.:
|
|
|
|
* :math:`ceil(\frac{maximum - minimum}{step}) + 1`.
|
|
|
|
* Used only if the @type is %V4L2_CTRL_TYPE_INTEGER_MENU.
|
2015-08-22 19:03:49 +08:00
|
|
|
* @flags: The control's flags.
|
2017-09-28 00:25:21 +08:00
|
|
|
* @cur: Structure to store the current value.
|
|
|
|
* @cur.val: The control's current value, if the @type is represented via
|
|
|
|
* a u32 integer (see &enum v4l2_ctrl_type).
|
2015-08-22 19:03:49 +08:00
|
|
|
* @val: The control's new s32 value.
|
|
|
|
* @priv: The control's private pointer. For use by the driver. It is
|
|
|
|
* untouched by the control framework. Note that this pointer is
|
|
|
|
* not freed when the control is deleted. Should this be needed
|
|
|
|
* then a new internal bitfield can be added to tell the framework
|
|
|
|
* to free this pointer.
|
2018-07-05 17:38:00 +08:00
|
|
|
* @p_cur: The control's current value represented via a union which
|
2015-08-22 19:22:03 +08:00
|
|
|
* provides a standard way of accessing control types
|
|
|
|
* through a pointer.
|
2018-07-05 17:38:00 +08:00
|
|
|
* @p_new: The control's new value represented via a union which provides
|
2015-08-22 19:22:03 +08:00
|
|
|
* a standard way of accessing control types
|
|
|
|
* through a pointer.
|
2015-08-22 19:03:49 +08:00
|
|
|
*/
|
2010-08-02 01:32:42 +08:00
|
|
|
struct v4l2_ctrl {
|
|
|
|
/* Administrative fields */
|
|
|
|
struct list_head node;
|
2011-06-14 05:55:58 +08:00
|
|
|
struct list_head ev_subs;
|
2010-08-02 01:32:42 +08:00
|
|
|
struct v4l2_ctrl_handler *handler;
|
|
|
|
struct v4l2_ctrl **cluster;
|
2016-07-23 00:57:29 +08:00
|
|
|
unsigned int ncontrols;
|
|
|
|
|
2010-08-02 01:32:42 +08:00
|
|
|
unsigned int done:1;
|
|
|
|
|
2011-01-12 01:45:03 +08:00
|
|
|
unsigned int is_new:1;
|
2014-01-17 19:25:26 +08:00
|
|
|
unsigned int has_changed:1;
|
2010-08-02 01:32:42 +08:00
|
|
|
unsigned int is_private:1;
|
2011-06-10 16:44:36 +08:00
|
|
|
unsigned int is_auto:1;
|
2014-06-12 18:54:16 +08:00
|
|
|
unsigned int is_int:1;
|
|
|
|
unsigned int is_string:1;
|
|
|
|
unsigned int is_ptr:1;
|
2014-06-10 18:55:00 +08:00
|
|
|
unsigned int is_array:1;
|
[media] v4l2-ctrls: implement new volatile autocluster scheme
The problem tackled in this patch is how to handle volatile autoclusters
correctly. A volatile autocluster is a cluster of related controls where one
control is the control that toggles between manual and auto mode and the other
controls are the values for the manual mode. For example autogain and gain,
autoexposure and exposure, etc.
If the hardware lets you read out the automatically calculated manual values
while in automode, then those manual controls should be marked volatile.
gain value as calculated by the autogain circuitry, then you would mark the
gain control as volatile (i.e. continuously changing).
The question in such use cases is what to do when switching from the auto
mode to the manual mode. Should we switch to the last set manual values or
should the volatile values be copied and used as the initial manual values.
For example: suppose the mode is manual gain and gain is set to 5. Then
autogain is turned on and the gain is set by the hardware to 2. Finally
the user switches back to manual gain. What should the gain be? 2 or 5?
After a long discussion the decisions was made to keep the last value as
calculated by the auto mode (so 2 in the example above).
The reason is that webcams that do such things will adapt themselves to
the current light conditions and when you switch back to manual mode you
expect that you keep the same picture. If you would switch back to old
manual values, then that would give you a suddenly different picture,
which is jarring for the user.
Additionally, this would be difficult to implement in applications that
store and restore the control values at application exit and start.
If you want to keep the old manual values when you switch from auto to
manual, then there would have to be a way for applications to get hold
of those old values while in auto mode, but there isn't.
So this patch will do all the heavy lifting in v4l2-ctrls.c: if you go
from auto mode to manual mode and the manual controls are volatile, then
g_volatile_ctrl will be called to get the current values for the manual
controls before switching to manual mode.
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Acked-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
2011-08-26 18:53:53 +08:00
|
|
|
unsigned int has_volatiles:1;
|
2012-09-07 15:46:39 +08:00
|
|
|
unsigned int call_notify:1;
|
2011-06-28 21:43:13 +08:00
|
|
|
unsigned int manual_mode_value:8;
|
2010-08-02 01:32:42 +08:00
|
|
|
|
|
|
|
const struct v4l2_ctrl_ops *ops;
|
2014-04-27 14:22:17 +08:00
|
|
|
const struct v4l2_ctrl_type_ops *type_ops;
|
2010-08-02 01:32:42 +08:00
|
|
|
u32 id;
|
|
|
|
const char *name;
|
|
|
|
enum v4l2_ctrl_type type;
|
2014-04-16 20:41:25 +08:00
|
|
|
s64 minimum, maximum, default_value;
|
2014-06-12 18:55:21 +08:00
|
|
|
u32 elems;
|
2014-06-12 18:54:16 +08:00
|
|
|
u32 elem_size;
|
2014-06-12 18:55:21 +08:00
|
|
|
u32 dims[V4L2_CTRL_MAX_DIMS];
|
|
|
|
u32 nr_of_dims;
|
2010-08-02 01:32:42 +08:00
|
|
|
union {
|
2014-04-16 20:41:25 +08:00
|
|
|
u64 step;
|
|
|
|
u64 menu_skip_mask;
|
2010-08-02 01:32:42 +08:00
|
|
|
};
|
2011-08-05 00:51:11 +08:00
|
|
|
union {
|
|
|
|
const char * const *qmenu;
|
|
|
|
const s64 *qmenu_int;
|
|
|
|
};
|
2010-08-02 01:32:42 +08:00
|
|
|
unsigned long flags;
|
2014-06-12 18:54:16 +08:00
|
|
|
void *priv;
|
2014-04-27 14:38:13 +08:00
|
|
|
s32 val;
|
|
|
|
struct {
|
2010-08-02 01:32:42 +08:00
|
|
|
s32 val;
|
2014-06-12 18:54:16 +08:00
|
|
|
} cur;
|
2014-04-27 14:22:17 +08:00
|
|
|
|
|
|
|
union v4l2_ctrl_ptr p_new;
|
|
|
|
union v4l2_ctrl_ptr p_cur;
|
2010-08-02 01:32:42 +08:00
|
|
|
};
|
|
|
|
|
2015-08-22 19:03:49 +08:00
|
|
|
/**
|
|
|
|
* struct v4l2_ctrl_ref - The control reference.
|
2016-07-23 00:57:29 +08:00
|
|
|
*
|
2015-08-22 19:03:49 +08:00
|
|
|
* @node: List node for the sorted list.
|
|
|
|
* @next: Single-link list node for the hash.
|
|
|
|
* @ctrl: The actual control information.
|
2016-07-23 00:57:29 +08:00
|
|
|
* @helper: Pointer to helper struct. Used internally in
|
2016-08-30 05:43:02 +08:00
|
|
|
* ``prepare_ext_ctrls`` function at ``v4l2-ctrl.c``.
|
2018-05-21 16:54:36 +08:00
|
|
|
* @from_other_dev: If true, then @ctrl was defined in another
|
|
|
|
* device than the &struct v4l2_ctrl_handler.
|
2018-05-21 16:54:40 +08:00
|
|
|
* @req_done: Internal flag: if the control handler containing this control
|
|
|
|
* reference is bound to a media request, then this is set when
|
|
|
|
* the control has been applied. This prevents applying controls
|
|
|
|
* from a cluster with multiple controls twice (when the first
|
|
|
|
* control of a cluster is applied, they all are).
|
|
|
|
* @req: If set, this refers to another request that sets this control.
|
2018-05-21 16:54:37 +08:00
|
|
|
* @p_req: If the control handler containing this control reference
|
|
|
|
* is bound to a media request, then this points to the
|
|
|
|
* value of the control that should be applied when the request
|
|
|
|
* is executed, or to the value of the control at the time
|
|
|
|
* that the request was completed.
|
2015-08-22 19:03:49 +08:00
|
|
|
*
|
|
|
|
* Each control handler has a list of these refs. The list_head is used to
|
|
|
|
* keep a sorted-by-control-ID list of all controls, while the next pointer
|
|
|
|
* is used to link the control in the hash's bucket.
|
|
|
|
*/
|
2010-08-02 01:32:42 +08:00
|
|
|
struct v4l2_ctrl_ref {
|
|
|
|
struct list_head node;
|
|
|
|
struct v4l2_ctrl_ref *next;
|
|
|
|
struct v4l2_ctrl *ctrl;
|
2011-06-14 21:04:06 +08:00
|
|
|
struct v4l2_ctrl_helper *helper;
|
2018-05-21 16:54:36 +08:00
|
|
|
bool from_other_dev;
|
2018-05-21 16:54:40 +08:00
|
|
|
bool req_done;
|
|
|
|
struct v4l2_ctrl_ref *req;
|
2018-05-21 16:54:37 +08:00
|
|
|
union v4l2_ctrl_ptr p_req;
|
2010-08-02 01:32:42 +08:00
|
|
|
};
|
|
|
|
|
2015-08-22 19:03:49 +08:00
|
|
|
/**
|
|
|
|
* struct v4l2_ctrl_handler - The control handler keeps track of all the
|
2016-07-23 00:57:29 +08:00
|
|
|
* controls: both the controls owned by the handler and those inherited
|
|
|
|
* from other handlers.
|
|
|
|
*
|
2015-08-22 19:03:49 +08:00
|
|
|
* @_lock: Default for "lock".
|
|
|
|
* @lock: Lock to control access to this handler and its controls.
|
|
|
|
* May be replaced by the user right after init.
|
|
|
|
* @ctrls: The list of controls owned by this handler.
|
|
|
|
* @ctrl_refs: The list of control references.
|
|
|
|
* @cached: The last found control reference. It is common that the same
|
|
|
|
* control is needed multiple times, so this is a simple
|
|
|
|
* optimization.
|
|
|
|
* @buckets: Buckets for the hashing. Allows for quick control lookup.
|
2016-07-23 00:57:29 +08:00
|
|
|
* @notify: A notify callback that is called whenever the control changes
|
|
|
|
* value.
|
2015-08-22 19:03:49 +08:00
|
|
|
* Note that the handler's lock is held when the notify function
|
|
|
|
* is called!
|
|
|
|
* @notify_priv: Passed as argument to the v4l2_ctrl notify callback.
|
|
|
|
* @nr_of_buckets: Total number of buckets in the array.
|
|
|
|
* @error: The error code of the first failed control addition.
|
2018-05-21 16:54:40 +08:00
|
|
|
* @request_is_queued: True if the request was queued.
|
|
|
|
* @requests: List to keep track of open control handler request objects.
|
|
|
|
* For the parent control handler (@req_obj.req == NULL) this
|
|
|
|
* is the list header. When the parent control handler is
|
|
|
|
* removed, it has to unbind and put all these requests since
|
|
|
|
* they refer to the parent.
|
|
|
|
* @requests_queued: List of the queued requests. This determines the order
|
|
|
|
* in which these controls are applied. Once the request is
|
|
|
|
* completed it is removed from this list.
|
2018-05-21 16:54:37 +08:00
|
|
|
* @req_obj: The &struct media_request_object, used to link into a
|
|
|
|
* &struct media_request. This request object has a refcount.
|
2015-08-22 19:03:49 +08:00
|
|
|
*/
|
2010-08-02 01:32:42 +08:00
|
|
|
struct v4l2_ctrl_handler {
|
2012-01-25 08:05:34 +08:00
|
|
|
struct mutex _lock;
|
|
|
|
struct mutex *lock;
|
2010-08-02 01:32:42 +08:00
|
|
|
struct list_head ctrls;
|
|
|
|
struct list_head ctrl_refs;
|
|
|
|
struct v4l2_ctrl_ref *cached;
|
|
|
|
struct v4l2_ctrl_ref **buckets;
|
2012-09-07 15:46:39 +08:00
|
|
|
v4l2_ctrl_notify_fnc notify;
|
|
|
|
void *notify_priv;
|
2010-08-02 01:32:42 +08:00
|
|
|
u16 nr_of_buckets;
|
|
|
|
int error;
|
2018-05-21 16:54:40 +08:00
|
|
|
bool request_is_queued;
|
|
|
|
struct list_head requests;
|
|
|
|
struct list_head requests_queued;
|
2018-05-21 16:54:37 +08:00
|
|
|
struct media_request_object req_obj;
|
2010-08-02 01:32:42 +08:00
|
|
|
};
|
|
|
|
|
2015-08-22 19:03:49 +08:00
|
|
|
/**
|
|
|
|
* struct v4l2_ctrl_config - Control configuration structure.
|
2016-07-23 00:57:29 +08:00
|
|
|
*
|
2015-08-22 19:03:49 +08:00
|
|
|
* @ops: The control ops.
|
|
|
|
* @type_ops: The control type ops. Only needed for compound controls.
|
|
|
|
* @id: The control ID.
|
|
|
|
* @name: The control name.
|
|
|
|
* @type: The control type.
|
|
|
|
* @min: The control's minimum value.
|
|
|
|
* @max: The control's maximum value.
|
|
|
|
* @step: The control's step value for non-menu controls.
|
2016-07-23 00:57:29 +08:00
|
|
|
* @def: The control's default value.
|
2015-08-22 19:03:49 +08:00
|
|
|
* @dims: The size of each dimension.
|
|
|
|
* @elem_size: The size in bytes of the control.
|
|
|
|
* @flags: The control's flags.
|
|
|
|
* @menu_skip_mask: The control's skip mask for menu controls. This makes it
|
|
|
|
* easy to skip menu items that are not valid. If bit X is set,
|
|
|
|
* then menu item X is skipped. Of course, this only works for
|
|
|
|
* menus with <= 64 menu items. There are no menus that come
|
|
|
|
* close to that number, so this is OK. Should we ever need more,
|
|
|
|
* then this will have to be extended to a bit array.
|
|
|
|
* @qmenu: A const char * array for all menu items. Array entries that are
|
|
|
|
* empty strings ("") correspond to non-existing menu items (this
|
|
|
|
* is in addition to the menu_skip_mask above). The last entry
|
|
|
|
* must be NULL.
|
2015-08-22 19:22:03 +08:00
|
|
|
* @qmenu_int: A const s64 integer array for all menu items of the type
|
2016-07-23 00:57:29 +08:00
|
|
|
* V4L2_CTRL_TYPE_INTEGER_MENU.
|
2015-08-22 19:03:49 +08:00
|
|
|
* @is_private: If set, then this control is private to its handler and it
|
|
|
|
* will not be added to any other handlers.
|
|
|
|
*/
|
2010-08-02 01:32:42 +08:00
|
|
|
struct v4l2_ctrl_config {
|
|
|
|
const struct v4l2_ctrl_ops *ops;
|
2014-04-27 14:22:17 +08:00
|
|
|
const struct v4l2_ctrl_type_ops *type_ops;
|
2010-08-02 01:32:42 +08:00
|
|
|
u32 id;
|
|
|
|
const char *name;
|
|
|
|
enum v4l2_ctrl_type type;
|
2014-04-16 20:41:25 +08:00
|
|
|
s64 min;
|
|
|
|
s64 max;
|
|
|
|
u64 step;
|
|
|
|
s64 def;
|
2014-06-12 18:55:21 +08:00
|
|
|
u32 dims[V4L2_CTRL_MAX_DIMS];
|
2014-06-12 18:54:16 +08:00
|
|
|
u32 elem_size;
|
2010-08-02 01:32:42 +08:00
|
|
|
u32 flags;
|
2014-04-16 20:41:25 +08:00
|
|
|
u64 menu_skip_mask;
|
2010-12-30 01:25:52 +08:00
|
|
|
const char * const *qmenu;
|
2011-08-05 00:51:11 +08:00
|
|
|
const s64 *qmenu_int;
|
2010-08-02 01:32:42 +08:00
|
|
|
unsigned int is_private:1;
|
|
|
|
};
|
|
|
|
|
2016-07-23 00:57:29 +08:00
|
|
|
/**
|
|
|
|
* v4l2_ctrl_fill - Fill in the control fields based on the control ID.
|
|
|
|
*
|
|
|
|
* @id: ID of the control
|
2017-08-12 17:57:05 +08:00
|
|
|
* @name: pointer to be filled with a string with the name of the control
|
|
|
|
* @type: pointer for storing the type of the control
|
|
|
|
* @min: pointer for storing the minimum value for the control
|
|
|
|
* @max: pointer for storing the maximum value for the control
|
|
|
|
* @step: pointer for storing the control step
|
|
|
|
* @def: pointer for storing the default value for the control
|
|
|
|
* @flags: pointer for storing the flags to be used on the control
|
2015-08-22 19:03:49 +08:00
|
|
|
*
|
|
|
|
* This works for all standard V4L2 controls.
|
|
|
|
* For non-standard controls it will only fill in the given arguments
|
2017-08-12 17:57:05 +08:00
|
|
|
* and @name content will be set to %NULL.
|
2015-08-22 19:03:49 +08:00
|
|
|
*
|
|
|
|
* This function will overwrite the contents of @name, @type and @flags.
|
|
|
|
* The contents of @min, @max, @step and @def may be modified depending on
|
|
|
|
* the type.
|
|
|
|
*
|
2016-07-23 00:57:29 +08:00
|
|
|
* .. note::
|
|
|
|
*
|
|
|
|
* Do not use in drivers! It is used internally for backwards compatibility
|
|
|
|
* control handling only. Once all drivers are converted to use the new
|
|
|
|
* control framework this function will no longer be exported.
|
2015-08-22 19:03:49 +08:00
|
|
|
*/
|
2010-08-02 01:32:42 +08:00
|
|
|
void v4l2_ctrl_fill(u32 id, const char **name, enum v4l2_ctrl_type *type,
|
2014-04-16 20:41:25 +08:00
|
|
|
s64 *min, s64 *max, u64 *step, s64 *def, u32 *flags);
|
2010-08-02 01:32:42 +08:00
|
|
|
|
|
|
|
|
2015-08-22 19:03:49 +08:00
|
|
|
/**
|
|
|
|
* v4l2_ctrl_handler_init_class() - Initialize the control handler.
|
|
|
|
* @hdl: The control handler.
|
|
|
|
* @nr_of_controls_hint: A hint of how many controls this handler is
|
|
|
|
* expected to refer to. This is the total number, so including
|
|
|
|
* any inherited controls. It doesn't have to be precise, but if
|
|
|
|
* it is way off, then you either waste memory (too many buckets
|
|
|
|
* are allocated) or the control lookup becomes slower (not enough
|
|
|
|
* buckets are allocated, so there are more slow list lookups).
|
|
|
|
* It will always work, though.
|
|
|
|
* @key: Used by the lock validator if CONFIG_LOCKDEP is set.
|
|
|
|
* @name: Used by the lock validator if CONFIG_LOCKDEP is set.
|
|
|
|
*
|
2016-08-30 04:26:15 +08:00
|
|
|
* .. attention::
|
|
|
|
*
|
|
|
|
* Never use this call directly, always use the v4l2_ctrl_handler_init()
|
|
|
|
* macro that hides the @key and @name arguments.
|
2015-08-22 19:03:49 +08:00
|
|
|
*
|
2016-08-30 04:26:15 +08:00
|
|
|
* Return: returns an error if the buckets could not be allocated. This
|
|
|
|
* error will also be stored in @hdl->error.
|
2015-08-22 19:03:49 +08:00
|
|
|
*/
|
2013-03-09 16:55:11 +08:00
|
|
|
int v4l2_ctrl_handler_init_class(struct v4l2_ctrl_handler *hdl,
|
2016-07-23 00:57:29 +08:00
|
|
|
unsigned int nr_of_controls_hint,
|
2013-03-09 16:55:11 +08:00
|
|
|
struct lock_class_key *key, const char *name);
|
|
|
|
|
|
|
|
#ifdef CONFIG_LOCKDEP
|
2016-08-30 04:26:15 +08:00
|
|
|
|
|
|
|
/**
|
2016-09-22 18:59:03 +08:00
|
|
|
* v4l2_ctrl_handler_init - helper function to create a static struct
|
|
|
|
* &lock_class_key and calls v4l2_ctrl_handler_init_class()
|
2016-08-30 04:26:15 +08:00
|
|
|
*
|
|
|
|
* @hdl: The control handler.
|
|
|
|
* @nr_of_controls_hint: A hint of how many controls this handler is
|
|
|
|
* expected to refer to. This is the total number, so including
|
|
|
|
* any inherited controls. It doesn't have to be precise, but if
|
|
|
|
* it is way off, then you either waste memory (too many buckets
|
|
|
|
* are allocated) or the control lookup becomes slower (not enough
|
|
|
|
* buckets are allocated, so there are more slow list lookups).
|
|
|
|
* It will always work, though.
|
|
|
|
*
|
|
|
|
* This helper function creates a static struct &lock_class_key and
|
|
|
|
* calls v4l2_ctrl_handler_init_class(), providing a proper name for the lock
|
|
|
|
* validador.
|
|
|
|
*
|
|
|
|
* Use this helper function to initialize a control handler.
|
|
|
|
*/
|
2013-03-09 16:55:11 +08:00
|
|
|
#define v4l2_ctrl_handler_init(hdl, nr_of_controls_hint) \
|
|
|
|
( \
|
|
|
|
({ \
|
|
|
|
static struct lock_class_key _key; \
|
|
|
|
v4l2_ctrl_handler_init_class(hdl, nr_of_controls_hint, \
|
|
|
|
&_key, \
|
|
|
|
KBUILD_BASENAME ":" \
|
|
|
|
__stringify(__LINE__) ":" \
|
|
|
|
"(" #hdl ")->_lock"); \
|
|
|
|
}) \
|
|
|
|
)
|
|
|
|
#else
|
|
|
|
#define v4l2_ctrl_handler_init(hdl, nr_of_controls_hint) \
|
|
|
|
v4l2_ctrl_handler_init_class(hdl, nr_of_controls_hint, NULL, NULL)
|
|
|
|
#endif
|
2010-08-02 01:32:42 +08:00
|
|
|
|
2015-08-22 19:03:49 +08:00
|
|
|
/**
|
|
|
|
* v4l2_ctrl_handler_free() - Free all controls owned by the handler and free
|
|
|
|
* the control list.
|
|
|
|
* @hdl: The control handler.
|
|
|
|
*
|
|
|
|
* Does nothing if @hdl == NULL.
|
|
|
|
*/
|
2010-08-02 01:32:42 +08:00
|
|
|
void v4l2_ctrl_handler_free(struct v4l2_ctrl_handler *hdl);
|
|
|
|
|
2015-08-22 19:03:49 +08:00
|
|
|
/**
|
|
|
|
* v4l2_ctrl_lock() - Helper function to lock the handler
|
|
|
|
* associated with the control.
|
|
|
|
* @ctrl: The control to lock.
|
|
|
|
*/
|
2014-06-13 00:09:39 +08:00
|
|
|
static inline void v4l2_ctrl_lock(struct v4l2_ctrl *ctrl)
|
|
|
|
{
|
|
|
|
mutex_lock(ctrl->handler->lock);
|
|
|
|
}
|
|
|
|
|
2015-08-22 19:03:49 +08:00
|
|
|
/**
|
|
|
|
* v4l2_ctrl_unlock() - Helper function to unlock the handler
|
|
|
|
* associated with the control.
|
|
|
|
* @ctrl: The control to unlock.
|
|
|
|
*/
|
2014-06-13 00:09:39 +08:00
|
|
|
static inline void v4l2_ctrl_unlock(struct v4l2_ctrl *ctrl)
|
|
|
|
{
|
|
|
|
mutex_unlock(ctrl->handler->lock);
|
|
|
|
}
|
|
|
|
|
2017-05-26 16:21:37 +08:00
|
|
|
/**
|
|
|
|
* __v4l2_ctrl_handler_setup() - Call the s_ctrl op for all controls belonging
|
|
|
|
* to the handler to initialize the hardware to the current control values. The
|
|
|
|
* caller is responsible for acquiring the control handler mutex on behalf of
|
|
|
|
* __v4l2_ctrl_handler_setup().
|
|
|
|
* @hdl: The control handler.
|
|
|
|
*
|
|
|
|
* Button controls will be skipped, as are read-only controls.
|
|
|
|
*
|
|
|
|
* If @hdl == NULL, then this just returns 0.
|
|
|
|
*/
|
|
|
|
int __v4l2_ctrl_handler_setup(struct v4l2_ctrl_handler *hdl);
|
|
|
|
|
2015-08-22 19:03:49 +08:00
|
|
|
/**
|
|
|
|
* v4l2_ctrl_handler_setup() - Call the s_ctrl op for all controls belonging
|
|
|
|
* to the handler to initialize the hardware to the current control values.
|
|
|
|
* @hdl: The control handler.
|
|
|
|
*
|
|
|
|
* Button controls will be skipped, as are read-only controls.
|
|
|
|
*
|
|
|
|
* If @hdl == NULL, then this just returns 0.
|
|
|
|
*/
|
2010-08-02 01:32:42 +08:00
|
|
|
int v4l2_ctrl_handler_setup(struct v4l2_ctrl_handler *hdl);
|
|
|
|
|
2015-08-22 19:03:49 +08:00
|
|
|
/**
|
|
|
|
* v4l2_ctrl_handler_log_status() - Log all controls owned by the handler.
|
|
|
|
* @hdl: The control handler.
|
|
|
|
* @prefix: The prefix to use when logging the control values. If the
|
|
|
|
* prefix does not end with a space, then ": " will be added
|
|
|
|
* after the prefix. If @prefix == NULL, then no prefix will be
|
|
|
|
* used.
|
|
|
|
*
|
|
|
|
* For use with VIDIOC_LOG_STATUS.
|
|
|
|
*
|
|
|
|
* Does nothing if @hdl == NULL.
|
|
|
|
*/
|
2010-08-02 01:32:42 +08:00
|
|
|
void v4l2_ctrl_handler_log_status(struct v4l2_ctrl_handler *hdl,
|
|
|
|
const char *prefix);
|
|
|
|
|
2015-08-22 19:03:49 +08:00
|
|
|
/**
|
|
|
|
* v4l2_ctrl_new_custom() - Allocate and initialize a new custom V4L2
|
2016-07-23 00:57:29 +08:00
|
|
|
* control.
|
|
|
|
*
|
2015-08-22 19:03:49 +08:00
|
|
|
* @hdl: The control handler.
|
|
|
|
* @cfg: The control's configuration data.
|
|
|
|
* @priv: The control's driver-specific private data.
|
|
|
|
*
|
|
|
|
* If the &v4l2_ctrl struct could not be allocated then NULL is returned
|
|
|
|
* and @hdl->error is set to the error code (if it wasn't set already).
|
|
|
|
*/
|
2010-08-02 01:32:42 +08:00
|
|
|
struct v4l2_ctrl *v4l2_ctrl_new_custom(struct v4l2_ctrl_handler *hdl,
|
2016-07-23 00:57:29 +08:00
|
|
|
const struct v4l2_ctrl_config *cfg,
|
|
|
|
void *priv);
|
2010-08-02 01:32:42 +08:00
|
|
|
|
2015-08-22 19:03:49 +08:00
|
|
|
/**
|
2016-07-23 00:57:29 +08:00
|
|
|
* v4l2_ctrl_new_std() - Allocate and initialize a new standard V4L2 non-menu
|
|
|
|
* control.
|
|
|
|
*
|
2015-08-22 19:03:49 +08:00
|
|
|
* @hdl: The control handler.
|
|
|
|
* @ops: The control ops.
|
2016-07-23 00:57:29 +08:00
|
|
|
* @id: The control ID.
|
2015-08-22 19:03:49 +08:00
|
|
|
* @min: The control's minimum value.
|
|
|
|
* @max: The control's maximum value.
|
|
|
|
* @step: The control's step value
|
2016-07-23 00:57:29 +08:00
|
|
|
* @def: The control's default value.
|
2015-08-22 19:03:49 +08:00
|
|
|
*
|
|
|
|
* If the &v4l2_ctrl struct could not be allocated, or the control
|
|
|
|
* ID is not known, then NULL is returned and @hdl->error is set to the
|
|
|
|
* appropriate error code (if it wasn't set already).
|
|
|
|
*
|
|
|
|
* If @id refers to a menu control, then this function will return NULL.
|
|
|
|
*
|
|
|
|
* Use v4l2_ctrl_new_std_menu() when adding menu controls.
|
|
|
|
*/
|
2010-08-02 01:32:42 +08:00
|
|
|
struct v4l2_ctrl *v4l2_ctrl_new_std(struct v4l2_ctrl_handler *hdl,
|
2016-07-23 00:57:29 +08:00
|
|
|
const struct v4l2_ctrl_ops *ops,
|
|
|
|
u32 id, s64 min, s64 max, u64 step,
|
|
|
|
s64 def);
|
2010-08-02 01:32:42 +08:00
|
|
|
|
2015-08-22 19:03:49 +08:00
|
|
|
/**
|
2016-07-23 00:57:29 +08:00
|
|
|
* v4l2_ctrl_new_std_menu() - Allocate and initialize a new standard V4L2
|
|
|
|
* menu control.
|
|
|
|
*
|
2015-08-22 19:03:49 +08:00
|
|
|
* @hdl: The control handler.
|
|
|
|
* @ops: The control ops.
|
2016-07-23 00:57:29 +08:00
|
|
|
* @id: The control ID.
|
2015-08-22 19:03:49 +08:00
|
|
|
* @max: The control's maximum value.
|
2016-07-23 00:57:29 +08:00
|
|
|
* @mask: The control's skip mask for menu controls. This makes it
|
2015-08-22 19:03:49 +08:00
|
|
|
* easy to skip menu items that are not valid. If bit X is set,
|
|
|
|
* then menu item X is skipped. Of course, this only works for
|
|
|
|
* menus with <= 64 menu items. There are no menus that come
|
|
|
|
* close to that number, so this is OK. Should we ever need more,
|
|
|
|
* then this will have to be extended to a bit array.
|
2016-07-23 00:57:29 +08:00
|
|
|
* @def: The control's default value.
|
2015-08-22 19:03:49 +08:00
|
|
|
*
|
|
|
|
* Same as v4l2_ctrl_new_std(), but @min is set to 0 and the @mask value
|
|
|
|
* determines which menu items are to be skipped.
|
|
|
|
*
|
|
|
|
* If @id refers to a non-menu control, then this function will return NULL.
|
|
|
|
*/
|
2010-08-02 01:32:42 +08:00
|
|
|
struct v4l2_ctrl *v4l2_ctrl_new_std_menu(struct v4l2_ctrl_handler *hdl,
|
2016-07-23 00:57:29 +08:00
|
|
|
const struct v4l2_ctrl_ops *ops,
|
|
|
|
u32 id, u8 max, u64 mask, u8 def);
|
2010-08-02 01:32:42 +08:00
|
|
|
|
2015-08-22 19:03:49 +08:00
|
|
|
/**
|
|
|
|
* v4l2_ctrl_new_std_menu_items() - Create a new standard V4L2 menu control
|
2016-07-23 00:57:29 +08:00
|
|
|
* with driver specific menu.
|
|
|
|
*
|
2015-08-22 19:03:49 +08:00
|
|
|
* @hdl: The control handler.
|
|
|
|
* @ops: The control ops.
|
|
|
|
* @id: The control ID.
|
|
|
|
* @max: The control's maximum value.
|
|
|
|
* @mask: The control's skip mask for menu controls. This makes it
|
|
|
|
* easy to skip menu items that are not valid. If bit X is set,
|
|
|
|
* then menu item X is skipped. Of course, this only works for
|
|
|
|
* menus with <= 64 menu items. There are no menus that come
|
|
|
|
* close to that number, so this is OK. Should we ever need more,
|
|
|
|
* then this will have to be extended to a bit array.
|
|
|
|
* @def: The control's default value.
|
|
|
|
* @qmenu: The new menu.
|
|
|
|
*
|
|
|
|
* Same as v4l2_ctrl_new_std_menu(), but @qmenu will be the driver specific
|
|
|
|
* menu of this control.
|
|
|
|
*
|
|
|
|
*/
|
2012-09-19 02:54:38 +08:00
|
|
|
struct v4l2_ctrl *v4l2_ctrl_new_std_menu_items(struct v4l2_ctrl_handler *hdl,
|
2016-07-23 00:57:29 +08:00
|
|
|
const struct v4l2_ctrl_ops *ops,
|
|
|
|
u32 id, u8 max,
|
|
|
|
u64 mask, u8 def,
|
|
|
|
const char * const *qmenu);
|
2012-09-19 02:54:38 +08:00
|
|
|
|
2015-08-22 19:03:49 +08:00
|
|
|
/**
|
|
|
|
* v4l2_ctrl_new_int_menu() - Create a new standard V4L2 integer menu control.
|
2016-07-23 00:57:29 +08:00
|
|
|
*
|
2015-08-22 19:03:49 +08:00
|
|
|
* @hdl: The control handler.
|
|
|
|
* @ops: The control ops.
|
|
|
|
* @id: The control ID.
|
|
|
|
* @max: The control's maximum value.
|
|
|
|
* @def: The control's default value.
|
|
|
|
* @qmenu_int: The control's menu entries.
|
|
|
|
*
|
2019-02-19 03:29:06 +08:00
|
|
|
* Same as v4l2_ctrl_new_std_menu(), but @mask is set to 0 and it additionally
|
2015-08-22 19:03:49 +08:00
|
|
|
* takes as an argument an array of integers determining the menu items.
|
|
|
|
*
|
2016-07-23 00:57:29 +08:00
|
|
|
* If @id refers to a non-integer-menu control, then this function will
|
|
|
|
* return %NULL.
|
2015-08-22 19:03:49 +08:00
|
|
|
*/
|
2012-05-07 02:30:44 +08:00
|
|
|
struct v4l2_ctrl *v4l2_ctrl_new_int_menu(struct v4l2_ctrl_handler *hdl,
|
2016-07-23 00:57:29 +08:00
|
|
|
const struct v4l2_ctrl_ops *ops,
|
|
|
|
u32 id, u8 max, u8 def,
|
|
|
|
const s64 *qmenu_int);
|
2012-05-07 02:30:44 +08:00
|
|
|
|
2016-08-30 04:26:15 +08:00
|
|
|
/**
|
|
|
|
* typedef v4l2_ctrl_filter - Typedef to define the filter function to be
|
|
|
|
* used when adding a control handler.
|
|
|
|
*
|
|
|
|
* @ctrl: pointer to struct &v4l2_ctrl.
|
|
|
|
*/
|
|
|
|
|
2016-07-22 21:58:03 +08:00
|
|
|
typedef bool (*v4l2_ctrl_filter)(const struct v4l2_ctrl *ctrl);
|
|
|
|
|
2015-08-22 19:03:49 +08:00
|
|
|
/**
|
|
|
|
* v4l2_ctrl_add_handler() - Add all controls from handler @add to
|
2016-07-23 00:57:29 +08:00
|
|
|
* handler @hdl.
|
|
|
|
*
|
2015-08-22 19:03:49 +08:00
|
|
|
* @hdl: The control handler.
|
|
|
|
* @add: The control handler whose controls you want to add to
|
|
|
|
* the @hdl control handler.
|
|
|
|
* @filter: This function will filter which controls should be added.
|
2018-05-21 16:54:36 +08:00
|
|
|
* @from_other_dev: If true, then the controls in @add were defined in another
|
|
|
|
* device than @hdl.
|
2015-08-22 19:03:49 +08:00
|
|
|
*
|
|
|
|
* Does nothing if either of the two handlers is a NULL pointer.
|
|
|
|
* If @filter is NULL, then all controls are added. Otherwise only those
|
|
|
|
* controls for which @filter returns true will be added.
|
|
|
|
* In case of an error @hdl->error will be set to the error code (if it
|
|
|
|
* wasn't set already).
|
|
|
|
*/
|
2010-08-02 01:32:42 +08:00
|
|
|
int v4l2_ctrl_add_handler(struct v4l2_ctrl_handler *hdl,
|
2012-09-14 18:15:03 +08:00
|
|
|
struct v4l2_ctrl_handler *add,
|
2018-05-21 16:54:36 +08:00
|
|
|
v4l2_ctrl_filter filter,
|
|
|
|
bool from_other_dev);
|
2010-08-02 01:32:42 +08:00
|
|
|
|
2015-08-22 19:03:49 +08:00
|
|
|
/**
|
|
|
|
* v4l2_ctrl_radio_filter() - Standard filter for radio controls.
|
2016-07-23 00:57:29 +08:00
|
|
|
*
|
2015-08-22 19:03:49 +08:00
|
|
|
* @ctrl: The control that is filtered.
|
|
|
|
*
|
|
|
|
* This will return true for any controls that are valid for radio device
|
|
|
|
* nodes. Those are all of the V4L2_CID_AUDIO_* user controls and all FM
|
|
|
|
* transmitter class controls.
|
|
|
|
*
|
|
|
|
* This function is to be used with v4l2_ctrl_add_handler().
|
|
|
|
*/
|
2012-09-14 18:15:03 +08:00
|
|
|
bool v4l2_ctrl_radio_filter(const struct v4l2_ctrl *ctrl);
|
2010-08-02 01:32:42 +08:00
|
|
|
|
2015-08-22 19:03:49 +08:00
|
|
|
/**
|
2016-07-23 00:57:29 +08:00
|
|
|
* v4l2_ctrl_cluster() - Mark all controls in the cluster as belonging
|
|
|
|
* to that cluster.
|
|
|
|
*
|
2015-08-22 19:03:49 +08:00
|
|
|
* @ncontrols: The number of controls in this cluster.
|
2016-07-23 00:57:29 +08:00
|
|
|
* @controls: The cluster control array of size @ncontrols.
|
2015-08-22 19:03:49 +08:00
|
|
|
*/
|
2016-07-23 00:57:29 +08:00
|
|
|
void v4l2_ctrl_cluster(unsigned int ncontrols, struct v4l2_ctrl **controls);
|
2010-08-02 01:32:42 +08:00
|
|
|
|
|
|
|
|
2015-08-22 19:03:49 +08:00
|
|
|
/**
|
2016-07-23 00:57:29 +08:00
|
|
|
* v4l2_ctrl_auto_cluster() - Mark all controls in the cluster as belonging
|
|
|
|
* to that cluster and set it up for autofoo/foo-type handling.
|
|
|
|
*
|
2015-08-22 19:03:49 +08:00
|
|
|
* @ncontrols: The number of controls in this cluster.
|
|
|
|
* @controls: The cluster control array of size @ncontrols. The first control
|
|
|
|
* must be the 'auto' control (e.g. autogain, autoexposure, etc.)
|
|
|
|
* @manual_val: The value for the first control in the cluster that equals the
|
|
|
|
* manual setting.
|
|
|
|
* @set_volatile: If true, then all controls except the first auto control will
|
|
|
|
* be volatile.
|
|
|
|
*
|
|
|
|
* Use for control groups where one control selects some automatic feature and
|
|
|
|
* the other controls are only active whenever the automatic feature is turned
|
|
|
|
* off (manual mode). Typical examples: autogain vs gain, auto-whitebalance vs
|
|
|
|
* red and blue balance, etc.
|
|
|
|
*
|
|
|
|
* The behavior of such controls is as follows:
|
|
|
|
*
|
|
|
|
* When the autofoo control is set to automatic, then any manual controls
|
|
|
|
* are set to inactive and any reads will call g_volatile_ctrl (if the control
|
|
|
|
* was marked volatile).
|
|
|
|
*
|
|
|
|
* When the autofoo control is set to manual, then any manual controls will
|
|
|
|
* be marked active, and any reads will just return the current value without
|
|
|
|
* going through g_volatile_ctrl.
|
|
|
|
*
|
2016-08-30 04:26:15 +08:00
|
|
|
* In addition, this function will set the %V4L2_CTRL_FLAG_UPDATE flag
|
|
|
|
* on the autofoo control and %V4L2_CTRL_FLAG_INACTIVE on the foo control(s)
|
2015-08-22 19:03:49 +08:00
|
|
|
* if autofoo is in auto mode.
|
|
|
|
*/
|
2016-07-23 00:57:29 +08:00
|
|
|
void v4l2_ctrl_auto_cluster(unsigned int ncontrols,
|
|
|
|
struct v4l2_ctrl **controls,
|
|
|
|
u8 manual_val, bool set_volatile);
|
2011-06-10 16:44:36 +08:00
|
|
|
|
|
|
|
|
2015-08-22 19:03:49 +08:00
|
|
|
/**
|
|
|
|
* v4l2_ctrl_find() - Find a control with the given ID.
|
2016-07-23 00:57:29 +08:00
|
|
|
*
|
2015-08-22 19:03:49 +08:00
|
|
|
* @hdl: The control handler.
|
|
|
|
* @id: The control ID to find.
|
|
|
|
*
|
|
|
|
* If @hdl == NULL this will return NULL as well. Will lock the handler so
|
|
|
|
* do not use from inside &v4l2_ctrl_ops.
|
|
|
|
*/
|
2010-08-02 01:32:42 +08:00
|
|
|
struct v4l2_ctrl *v4l2_ctrl_find(struct v4l2_ctrl_handler *hdl, u32 id);
|
|
|
|
|
2015-08-22 19:03:49 +08:00
|
|
|
/**
|
|
|
|
* v4l2_ctrl_activate() - Make the control active or inactive.
|
|
|
|
* @ctrl: The control to (de)activate.
|
|
|
|
* @active: True if the control should become active.
|
|
|
|
*
|
|
|
|
* This sets or clears the V4L2_CTRL_FLAG_INACTIVE flag atomically.
|
|
|
|
* Does nothing if @ctrl == NULL.
|
|
|
|
* This will usually be called from within the s_ctrl op.
|
|
|
|
* The V4L2_EVENT_CTRL event will be generated afterwards.
|
|
|
|
*
|
|
|
|
* This function assumes that the control handler is locked.
|
|
|
|
*/
|
2010-08-02 01:32:42 +08:00
|
|
|
void v4l2_ctrl_activate(struct v4l2_ctrl *ctrl, bool active);
|
|
|
|
|
2018-07-19 19:11:40 +08:00
|
|
|
/**
|
|
|
|
* __v4l2_ctrl_grab() - Unlocked variant of v4l2_ctrl_grab.
|
|
|
|
*
|
|
|
|
* @ctrl: The control to (de)activate.
|
|
|
|
* @grabbed: True if the control should become grabbed.
|
|
|
|
*
|
|
|
|
* This sets or clears the V4L2_CTRL_FLAG_GRABBED flag atomically.
|
|
|
|
* Does nothing if @ctrl == NULL.
|
|
|
|
* The V4L2_EVENT_CTRL event will be generated afterwards.
|
|
|
|
* This will usually be called when starting or stopping streaming in the
|
|
|
|
* driver.
|
|
|
|
*
|
|
|
|
* This function assumes that the control handler is locked by the caller.
|
|
|
|
*/
|
|
|
|
void __v4l2_ctrl_grab(struct v4l2_ctrl *ctrl, bool grabbed);
|
|
|
|
|
2015-08-22 19:03:49 +08:00
|
|
|
/**
|
|
|
|
* v4l2_ctrl_grab() - Mark the control as grabbed or not grabbed.
|
2016-07-23 00:57:29 +08:00
|
|
|
*
|
2015-08-22 19:03:49 +08:00
|
|
|
* @ctrl: The control to (de)activate.
|
|
|
|
* @grabbed: True if the control should become grabbed.
|
|
|
|
*
|
|
|
|
* This sets or clears the V4L2_CTRL_FLAG_GRABBED flag atomically.
|
|
|
|
* Does nothing if @ctrl == NULL.
|
|
|
|
* The V4L2_EVENT_CTRL event will be generated afterwards.
|
|
|
|
* This will usually be called when starting or stopping streaming in the
|
|
|
|
* driver.
|
|
|
|
*
|
|
|
|
* This function assumes that the control handler is not locked and will
|
|
|
|
* take the lock itself.
|
|
|
|
*/
|
2018-07-19 19:11:40 +08:00
|
|
|
static inline void v4l2_ctrl_grab(struct v4l2_ctrl *ctrl, bool grabbed)
|
|
|
|
{
|
|
|
|
if (!ctrl)
|
|
|
|
return;
|
|
|
|
|
|
|
|
v4l2_ctrl_lock(ctrl);
|
|
|
|
__v4l2_ctrl_grab(ctrl, grabbed);
|
|
|
|
v4l2_ctrl_unlock(ctrl);
|
|
|
|
}
|
2010-08-02 01:32:42 +08:00
|
|
|
|
2015-08-22 19:03:49 +08:00
|
|
|
/**
|
|
|
|
*__v4l2_ctrl_modify_range() - Unlocked variant of v4l2_ctrl_modify_range()
|
|
|
|
*
|
|
|
|
* @ctrl: The control to update.
|
|
|
|
* @min: The control's minimum value.
|
|
|
|
* @max: The control's maximum value.
|
|
|
|
* @step: The control's step value
|
|
|
|
* @def: The control's default value.
|
|
|
|
*
|
|
|
|
* Update the range of a control on the fly. This works for control types
|
|
|
|
* INTEGER, BOOLEAN, MENU, INTEGER MENU and BITMASK. For menu controls the
|
|
|
|
* @step value is interpreted as a menu_skip_mask.
|
|
|
|
*
|
|
|
|
* An error is returned if one of the range arguments is invalid for this
|
|
|
|
* control type.
|
|
|
|
*
|
2018-02-03 21:18:14 +08:00
|
|
|
* The caller is responsible for acquiring the control handler mutex on behalf
|
|
|
|
* of __v4l2_ctrl_modify_range().
|
2015-08-22 19:03:49 +08:00
|
|
|
*/
|
2014-06-13 00:09:40 +08:00
|
|
|
int __v4l2_ctrl_modify_range(struct v4l2_ctrl *ctrl,
|
|
|
|
s64 min, s64 max, u64 step, s64 def);
|
|
|
|
|
2015-08-22 19:03:49 +08:00
|
|
|
/**
|
|
|
|
* v4l2_ctrl_modify_range() - Update the range of a control.
|
2016-07-23 00:57:29 +08:00
|
|
|
*
|
2015-08-22 19:03:49 +08:00
|
|
|
* @ctrl: The control to update.
|
|
|
|
* @min: The control's minimum value.
|
|
|
|
* @max: The control's maximum value.
|
|
|
|
* @step: The control's step value
|
|
|
|
* @def: The control's default value.
|
|
|
|
*
|
|
|
|
* Update the range of a control on the fly. This works for control types
|
|
|
|
* INTEGER, BOOLEAN, MENU, INTEGER MENU and BITMASK. For menu controls the
|
|
|
|
* @step value is interpreted as a menu_skip_mask.
|
|
|
|
*
|
|
|
|
* An error is returned if one of the range arguments is invalid for this
|
|
|
|
* control type.
|
|
|
|
*
|
|
|
|
* This function assumes that the control handler is not locked and will
|
|
|
|
* take the lock itself.
|
|
|
|
*/
|
2014-06-13 00:09:40 +08:00
|
|
|
static inline int v4l2_ctrl_modify_range(struct v4l2_ctrl *ctrl,
|
|
|
|
s64 min, s64 max, u64 step, s64 def)
|
|
|
|
{
|
|
|
|
int rval;
|
|
|
|
|
|
|
|
v4l2_ctrl_lock(ctrl);
|
|
|
|
rval = __v4l2_ctrl_modify_range(ctrl, min, max, step, def);
|
|
|
|
v4l2_ctrl_unlock(ctrl);
|
|
|
|
|
|
|
|
return rval;
|
|
|
|
}
|
2013-01-20 02:51:55 +08:00
|
|
|
|
2015-08-22 19:03:49 +08:00
|
|
|
/**
|
|
|
|
* v4l2_ctrl_notify() - Function to set a notify callback for a control.
|
2016-07-23 00:57:29 +08:00
|
|
|
*
|
2015-08-22 19:03:49 +08:00
|
|
|
* @ctrl: The control.
|
|
|
|
* @notify: The callback function.
|
|
|
|
* @priv: The callback private handle, passed as argument to the callback.
|
|
|
|
*
|
|
|
|
* This function sets a callback function for the control. If @ctrl is NULL,
|
|
|
|
* then it will do nothing. If @notify is NULL, then the notify callback will
|
|
|
|
* be removed.
|
|
|
|
*
|
|
|
|
* There can be only one notify. If another already exists, then a WARN_ON
|
|
|
|
* will be issued and the function will do nothing.
|
|
|
|
*/
|
2016-07-23 00:57:29 +08:00
|
|
|
void v4l2_ctrl_notify(struct v4l2_ctrl *ctrl, v4l2_ctrl_notify_fnc notify,
|
|
|
|
void *priv);
|
2012-09-07 15:46:39 +08:00
|
|
|
|
2015-08-22 19:03:49 +08:00
|
|
|
/**
|
|
|
|
* v4l2_ctrl_get_name() - Get the name of the control
|
2016-07-23 00:57:29 +08:00
|
|
|
*
|
2014-11-23 20:39:54 +08:00
|
|
|
* @id: The control ID.
|
|
|
|
*
|
|
|
|
* This function returns the name of the given control ID or NULL if it isn't
|
|
|
|
* a known control.
|
|
|
|
*/
|
|
|
|
const char *v4l2_ctrl_get_name(u32 id);
|
|
|
|
|
2015-08-22 19:03:49 +08:00
|
|
|
/**
|
|
|
|
* v4l2_ctrl_get_menu() - Get the menu string array of the control
|
2016-07-23 00:57:29 +08:00
|
|
|
*
|
2014-11-23 20:39:54 +08:00
|
|
|
* @id: The control ID.
|
|
|
|
*
|
|
|
|
* This function returns the NULL-terminated menu string array name of the
|
|
|
|
* given control ID or NULL if it isn't a known menu control.
|
|
|
|
*/
|
|
|
|
const char * const *v4l2_ctrl_get_menu(u32 id);
|
|
|
|
|
2015-08-22 19:03:49 +08:00
|
|
|
/**
|
|
|
|
* v4l2_ctrl_get_int_menu() - Get the integer menu array of the control
|
2016-07-23 00:57:29 +08:00
|
|
|
*
|
2014-11-23 20:39:54 +08:00
|
|
|
* @id: The control ID.
|
|
|
|
* @len: The size of the integer array.
|
|
|
|
*
|
|
|
|
* This function returns the integer array of the given control ID or NULL if it
|
|
|
|
* if it isn't a known integer menu control.
|
|
|
|
*/
|
|
|
|
const s64 *v4l2_ctrl_get_int_menu(u32 id, u32 *len);
|
|
|
|
|
2015-08-22 19:03:49 +08:00
|
|
|
/**
|
2016-07-23 00:57:29 +08:00
|
|
|
* v4l2_ctrl_g_ctrl() - Helper function to get the control's value from
|
|
|
|
* within a driver.
|
|
|
|
*
|
2015-08-22 19:03:49 +08:00
|
|
|
* @ctrl: The control.
|
|
|
|
*
|
|
|
|
* This returns the control's value safely by going through the control
|
|
|
|
* framework. This function will lock the control's handler, so it cannot be
|
|
|
|
* used from within the &v4l2_ctrl_ops functions.
|
|
|
|
*
|
|
|
|
* This function is for integer type controls only.
|
|
|
|
*/
|
2010-08-02 01:32:42 +08:00
|
|
|
s32 v4l2_ctrl_g_ctrl(struct v4l2_ctrl *ctrl);
|
|
|
|
|
2015-08-22 19:03:49 +08:00
|
|
|
/**
|
|
|
|
* __v4l2_ctrl_s_ctrl() - Unlocked variant of v4l2_ctrl_s_ctrl().
|
2016-07-23 00:57:29 +08:00
|
|
|
*
|
2015-08-22 19:03:49 +08:00
|
|
|
* @ctrl: The control.
|
2016-07-23 00:57:29 +08:00
|
|
|
* @val: TheControls name new value.
|
2015-08-22 19:03:49 +08:00
|
|
|
*
|
2016-06-15 20:57:48 +08:00
|
|
|
* This sets the control's new value safely by going through the control
|
|
|
|
* framework. This function assumes the control's handler is already locked,
|
|
|
|
* allowing it to be used from within the &v4l2_ctrl_ops functions.
|
2015-08-22 19:03:49 +08:00
|
|
|
*
|
|
|
|
* This function is for integer type controls only.
|
|
|
|
*/
|
2014-06-13 00:09:42 +08:00
|
|
|
int __v4l2_ctrl_s_ctrl(struct v4l2_ctrl *ctrl, s32 val);
|
2015-08-22 19:03:49 +08:00
|
|
|
|
2016-07-23 00:57:29 +08:00
|
|
|
/**
|
|
|
|
* v4l2_ctrl_s_ctrl() - Helper function to set the control's value from
|
|
|
|
* within a driver.
|
2015-08-22 19:03:49 +08:00
|
|
|
* @ctrl: The control.
|
|
|
|
* @val: The new value.
|
|
|
|
*
|
2016-06-15 20:57:48 +08:00
|
|
|
* This sets the control's new value safely by going through the control
|
2015-08-22 19:03:49 +08:00
|
|
|
* framework. This function will lock the control's handler, so it cannot be
|
|
|
|
* used from within the &v4l2_ctrl_ops functions.
|
|
|
|
*
|
|
|
|
* This function is for integer type controls only.
|
|
|
|
*/
|
2014-06-13 00:09:42 +08:00
|
|
|
static inline int v4l2_ctrl_s_ctrl(struct v4l2_ctrl *ctrl, s32 val)
|
|
|
|
{
|
|
|
|
int rval;
|
|
|
|
|
|
|
|
v4l2_ctrl_lock(ctrl);
|
|
|
|
rval = __v4l2_ctrl_s_ctrl(ctrl, val);
|
|
|
|
v4l2_ctrl_unlock(ctrl);
|
|
|
|
|
|
|
|
return rval;
|
|
|
|
}
|
2010-08-02 01:32:42 +08:00
|
|
|
|
2015-08-22 19:03:49 +08:00
|
|
|
/**
|
|
|
|
* v4l2_ctrl_g_ctrl_int64() - Helper function to get a 64-bit control's value
|
|
|
|
* from within a driver.
|
2016-07-23 00:57:29 +08:00
|
|
|
*
|
2015-08-22 19:03:49 +08:00
|
|
|
* @ctrl: The control.
|
|
|
|
*
|
|
|
|
* This returns the control's value safely by going through the control
|
|
|
|
* framework. This function will lock the control's handler, so it cannot be
|
|
|
|
* used from within the &v4l2_ctrl_ops functions.
|
|
|
|
*
|
|
|
|
* This function is for 64-bit integer type controls only.
|
|
|
|
*/
|
2012-07-23 20:15:21 +08:00
|
|
|
s64 v4l2_ctrl_g_ctrl_int64(struct v4l2_ctrl *ctrl);
|
|
|
|
|
2015-08-22 19:03:49 +08:00
|
|
|
/**
|
|
|
|
* __v4l2_ctrl_s_ctrl_int64() - Unlocked variant of v4l2_ctrl_s_ctrl_int64().
|
|
|
|
*
|
|
|
|
* @ctrl: The control.
|
|
|
|
* @val: The new value.
|
|
|
|
*
|
2016-06-15 20:57:48 +08:00
|
|
|
* This sets the control's new value safely by going through the control
|
|
|
|
* framework. This function assumes the control's handler is already locked,
|
|
|
|
* allowing it to be used from within the &v4l2_ctrl_ops functions.
|
2015-08-22 19:03:49 +08:00
|
|
|
*
|
|
|
|
* This function is for 64-bit integer type controls only.
|
|
|
|
*/
|
2014-06-13 00:09:42 +08:00
|
|
|
int __v4l2_ctrl_s_ctrl_int64(struct v4l2_ctrl *ctrl, s64 val);
|
|
|
|
|
2016-07-23 00:57:29 +08:00
|
|
|
/**
|
|
|
|
* v4l2_ctrl_s_ctrl_int64() - Helper function to set a 64-bit control's value
|
2015-08-22 19:03:49 +08:00
|
|
|
* from within a driver.
|
|
|
|
*
|
|
|
|
* @ctrl: The control.
|
|
|
|
* @val: The new value.
|
|
|
|
*
|
2016-06-15 20:57:48 +08:00
|
|
|
* This sets the control's new value safely by going through the control
|
2015-08-22 19:03:49 +08:00
|
|
|
* framework. This function will lock the control's handler, so it cannot be
|
|
|
|
* used from within the &v4l2_ctrl_ops functions.
|
|
|
|
*
|
|
|
|
* This function is for 64-bit integer type controls only.
|
|
|
|
*/
|
2014-06-13 00:09:42 +08:00
|
|
|
static inline int v4l2_ctrl_s_ctrl_int64(struct v4l2_ctrl *ctrl, s64 val)
|
|
|
|
{
|
|
|
|
int rval;
|
|
|
|
|
|
|
|
v4l2_ctrl_lock(ctrl);
|
|
|
|
rval = __v4l2_ctrl_s_ctrl_int64(ctrl, val);
|
|
|
|
v4l2_ctrl_unlock(ctrl);
|
|
|
|
|
|
|
|
return rval;
|
|
|
|
}
|
2012-07-23 20:15:21 +08:00
|
|
|
|
2016-07-23 00:57:29 +08:00
|
|
|
/**
|
|
|
|
* __v4l2_ctrl_s_ctrl_string() - Unlocked variant of v4l2_ctrl_s_ctrl_string().
|
2015-08-22 19:03:49 +08:00
|
|
|
*
|
|
|
|
* @ctrl: The control.
|
|
|
|
* @s: The new string.
|
|
|
|
*
|
2016-06-15 20:57:48 +08:00
|
|
|
* This sets the control's new string safely by going through the control
|
|
|
|
* framework. This function assumes the control's handler is already locked,
|
|
|
|
* allowing it to be used from within the &v4l2_ctrl_ops functions.
|
2015-08-22 19:03:49 +08:00
|
|
|
*
|
|
|
|
* This function is for string type controls only.
|
|
|
|
*/
|
2014-07-21 21:45:42 +08:00
|
|
|
int __v4l2_ctrl_s_ctrl_string(struct v4l2_ctrl *ctrl, const char *s);
|
|
|
|
|
2016-07-23 00:57:29 +08:00
|
|
|
/**
|
|
|
|
* v4l2_ctrl_s_ctrl_string() - Helper function to set a control's string value
|
2015-08-22 19:03:49 +08:00
|
|
|
* from within a driver.
|
|
|
|
*
|
|
|
|
* @ctrl: The control.
|
|
|
|
* @s: The new string.
|
2016-07-23 00:57:29 +08:00
|
|
|
*Controls name
|
2016-06-15 20:57:48 +08:00
|
|
|
* This sets the control's new string safely by going through the control
|
2015-08-22 19:03:49 +08:00
|
|
|
* framework. This function will lock the control's handler, so it cannot be
|
|
|
|
* used from within the &v4l2_ctrl_ops functions.
|
|
|
|
*
|
|
|
|
* This function is for string type controls only.
|
|
|
|
*/
|
2014-07-21 21:45:42 +08:00
|
|
|
static inline int v4l2_ctrl_s_ctrl_string(struct v4l2_ctrl *ctrl, const char *s)
|
|
|
|
{
|
|
|
|
int rval;
|
|
|
|
|
|
|
|
v4l2_ctrl_lock(ctrl);
|
|
|
|
rval = __v4l2_ctrl_s_ctrl_string(ctrl, s);
|
|
|
|
v4l2_ctrl_unlock(ctrl);
|
|
|
|
|
|
|
|
return rval;
|
|
|
|
}
|
|
|
|
|
2011-06-10 16:56:39 +08:00
|
|
|
/* Internal helper functions that deal with control events. */
|
2012-04-08 23:59:47 +08:00
|
|
|
extern const struct v4l2_subscribed_event_ops v4l2_ctrl_sub_ev_ops;
|
2016-07-23 00:57:29 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* v4l2_ctrl_replace - Function to be used as a callback to
|
|
|
|
* &struct v4l2_subscribed_event_ops replace\(\)
|
|
|
|
*
|
2016-08-30 06:29:58 +08:00
|
|
|
* @old: pointer to struct &v4l2_event with the reported
|
2016-07-23 00:57:29 +08:00
|
|
|
* event;
|
2016-08-30 06:29:58 +08:00
|
|
|
* @new: pointer to struct &v4l2_event with the modified
|
2016-07-23 00:57:29 +08:00
|
|
|
* event;
|
|
|
|
*/
|
2012-04-08 23:59:47 +08:00
|
|
|
void v4l2_ctrl_replace(struct v4l2_event *old, const struct v4l2_event *new);
|
2016-07-23 00:57:29 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* v4l2_ctrl_merge - Function to be used as a callback to
|
|
|
|
* &struct v4l2_subscribed_event_ops merge(\)
|
|
|
|
*
|
2016-08-30 06:29:58 +08:00
|
|
|
* @old: pointer to struct &v4l2_event with the reported
|
2016-07-23 00:57:29 +08:00
|
|
|
* event;
|
2016-08-30 06:29:58 +08:00
|
|
|
* @new: pointer to struct &v4l2_event with the merged
|
2016-07-23 00:57:29 +08:00
|
|
|
* event;
|
|
|
|
*/
|
2012-04-08 23:59:47 +08:00
|
|
|
void v4l2_ctrl_merge(const struct v4l2_event *old, struct v4l2_event *new);
|
2011-06-07 22:13:44 +08:00
|
|
|
|
2016-07-23 00:57:29 +08:00
|
|
|
/**
|
|
|
|
* v4l2_ctrl_log_status - helper function to implement %VIDIOC_LOG_STATUS ioctl
|
|
|
|
*
|
|
|
|
* @file: pointer to struct file
|
|
|
|
* @fh: unused. Kept just to be compatible to the arguments expected by
|
|
|
|
* &struct v4l2_ioctl_ops.vidioc_log_status.
|
|
|
|
*
|
|
|
|
* Can be used as a vidioc_log_status function that just dumps all controls
|
|
|
|
* associated with the filehandle.
|
|
|
|
*/
|
2012-02-02 19:20:53 +08:00
|
|
|
int v4l2_ctrl_log_status(struct file *file, void *fh);
|
|
|
|
|
2016-07-23 00:57:29 +08:00
|
|
|
/**
|
|
|
|
* v4l2_ctrl_subscribe_event - Subscribes to an event
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* @fh: pointer to struct v4l2_fh
|
|
|
|
* @sub: pointer to &struct v4l2_event_subscription
|
|
|
|
*
|
|
|
|
* Can be used as a vidioc_subscribe_event function that just subscribes
|
|
|
|
* control events.
|
|
|
|
*/
|
2012-01-28 03:18:42 +08:00
|
|
|
int v4l2_ctrl_subscribe_event(struct v4l2_fh *fh,
|
2012-09-04 22:46:09 +08:00
|
|
|
const struct v4l2_event_subscription *sub);
|
2012-01-28 03:18:42 +08:00
|
|
|
|
2016-07-23 00:57:29 +08:00
|
|
|
/**
|
|
|
|
* v4l2_ctrl_poll - function to be used as a callback to the poll()
|
|
|
|
* That just polls for control events.
|
|
|
|
*
|
|
|
|
* @file: pointer to struct file
|
|
|
|
* @wait: pointer to struct poll_table_struct
|
|
|
|
*/
|
2017-07-03 15:02:56 +08:00
|
|
|
__poll_t v4l2_ctrl_poll(struct file *file, struct poll_table_struct *wait);
|
2012-01-28 03:18:42 +08:00
|
|
|
|
2018-05-21 16:54:40 +08:00
|
|
|
/**
|
|
|
|
* v4l2_ctrl_request_setup - helper function to apply control values in a request
|
|
|
|
*
|
|
|
|
* @req: The request
|
|
|
|
* @parent: The parent control handler ('priv' in media_request_object_find())
|
|
|
|
*
|
|
|
|
* This is a helper function to call the control handler's s_ctrl callback with
|
|
|
|
* the control values contained in the request. Do note that this approach of
|
|
|
|
* applying control values in a request is only applicable to memory-to-memory
|
|
|
|
* devices.
|
|
|
|
*/
|
2019-03-07 05:13:26 +08:00
|
|
|
int v4l2_ctrl_request_setup(struct media_request *req,
|
2018-05-21 16:54:40 +08:00
|
|
|
struct v4l2_ctrl_handler *parent);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* v4l2_ctrl_request_complete - Complete a control handler request object
|
|
|
|
*
|
|
|
|
* @req: The request
|
|
|
|
* @parent: The parent control handler ('priv' in media_request_object_find())
|
|
|
|
*
|
|
|
|
* This function is to be called on each control handler that may have had a
|
|
|
|
* request object associated with it, i.e. control handlers of a driver that
|
|
|
|
* supports requests.
|
|
|
|
*
|
|
|
|
* The function first obtains the values of any volatile controls in the control
|
|
|
|
* handler and attach them to the request. Then, the function completes the
|
|
|
|
* request object.
|
|
|
|
*/
|
|
|
|
void v4l2_ctrl_request_complete(struct media_request *req,
|
2018-07-10 16:00:53 +08:00
|
|
|
struct v4l2_ctrl_handler *parent);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* v4l2_ctrl_request_hdl_find - Find the control handler in the request
|
|
|
|
*
|
|
|
|
* @req: The request
|
|
|
|
* @parent: The parent control handler ('priv' in media_request_object_find())
|
|
|
|
*
|
|
|
|
* This function finds the control handler in the request. It may return
|
|
|
|
* NULL if not found. When done, you must call v4l2_ctrl_request_put_hdl()
|
|
|
|
* with the returned handler pointer.
|
|
|
|
*
|
|
|
|
* If the request is not in state VALIDATING or QUEUED, then this function
|
|
|
|
* will always return NULL.
|
|
|
|
*
|
|
|
|
* Note that in state VALIDATING the req_queue_mutex is held, so
|
|
|
|
* no objects can be added or deleted from the request.
|
|
|
|
*
|
|
|
|
* In state QUEUED it is the driver that will have to ensure this.
|
|
|
|
*/
|
|
|
|
struct v4l2_ctrl_handler *v4l2_ctrl_request_hdl_find(struct media_request *req,
|
|
|
|
struct v4l2_ctrl_handler *parent);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* v4l2_ctrl_request_hdl_put - Put the control handler
|
|
|
|
*
|
|
|
|
* @hdl: Put this control handler
|
|
|
|
*
|
|
|
|
* This function released the control handler previously obtained from'
|
|
|
|
* v4l2_ctrl_request_hdl_find().
|
|
|
|
*/
|
|
|
|
static inline void v4l2_ctrl_request_hdl_put(struct v4l2_ctrl_handler *hdl)
|
|
|
|
{
|
|
|
|
if (hdl)
|
|
|
|
media_request_object_put(&hdl->req_obj);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* v4l2_ctrl_request_ctrl_find() - Find a control with the given ID.
|
|
|
|
*
|
|
|
|
* @hdl: The control handler from the request.
|
|
|
|
* @id: The ID of the control to find.
|
|
|
|
*
|
|
|
|
* This function returns a pointer to the control if this control is
|
|
|
|
* part of the request or NULL otherwise.
|
|
|
|
*/
|
|
|
|
struct v4l2_ctrl *
|
|
|
|
v4l2_ctrl_request_hdl_ctrl_find(struct v4l2_ctrl_handler *hdl, u32 id);
|
2018-05-21 16:54:40 +08:00
|
|
|
|
2016-07-23 00:57:29 +08:00
|
|
|
/* Helpers for ioctl_ops */
|
|
|
|
|
|
|
|
/**
|
|
|
|
* v4l2_queryctrl - Helper function to implement
|
|
|
|
* :ref:`VIDIOC_QUERYCTRL <vidioc_queryctrl>` ioctl
|
|
|
|
*
|
|
|
|
* @hdl: pointer to &struct v4l2_ctrl_handler
|
|
|
|
* @qc: pointer to &struct v4l2_queryctrl
|
|
|
|
*
|
|
|
|
* If hdl == NULL then they will all return -EINVAL.
|
|
|
|
*/
|
2010-08-02 01:32:42 +08:00
|
|
|
int v4l2_queryctrl(struct v4l2_ctrl_handler *hdl, struct v4l2_queryctrl *qc);
|
2016-07-23 00:57:29 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* v4l2_query_ext_ctrl - Helper function to implement
|
|
|
|
* :ref:`VIDIOC_QUERY_EXT_CTRL <vidioc_queryctrl>` ioctl
|
|
|
|
*
|
|
|
|
* @hdl: pointer to &struct v4l2_ctrl_handler
|
|
|
|
* @qc: pointer to &struct v4l2_query_ext_ctrl
|
|
|
|
*
|
|
|
|
* If hdl == NULL then they will all return -EINVAL.
|
|
|
|
*/
|
|
|
|
int v4l2_query_ext_ctrl(struct v4l2_ctrl_handler *hdl,
|
|
|
|
struct v4l2_query_ext_ctrl *qc);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* v4l2_querymenu - Helper function to implement
|
|
|
|
* :ref:`VIDIOC_QUERYMENU <vidioc_queryctrl>` ioctl
|
|
|
|
*
|
|
|
|
* @hdl: pointer to &struct v4l2_ctrl_handler
|
|
|
|
* @qm: pointer to &struct v4l2_querymenu
|
|
|
|
*
|
|
|
|
* If hdl == NULL then they will all return -EINVAL.
|
|
|
|
*/
|
2010-08-02 01:32:42 +08:00
|
|
|
int v4l2_querymenu(struct v4l2_ctrl_handler *hdl, struct v4l2_querymenu *qm);
|
2016-07-23 00:57:29 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* v4l2_g_ctrl - Helper function to implement
|
|
|
|
* :ref:`VIDIOC_G_CTRL <vidioc_g_ctrl>` ioctl
|
|
|
|
*
|
|
|
|
* @hdl: pointer to &struct v4l2_ctrl_handler
|
|
|
|
* @ctrl: pointer to &struct v4l2_control
|
|
|
|
*
|
|
|
|
* If hdl == NULL then they will all return -EINVAL.
|
|
|
|
*/
|
2010-08-02 01:32:42 +08:00
|
|
|
int v4l2_g_ctrl(struct v4l2_ctrl_handler *hdl, struct v4l2_control *ctrl);
|
2016-07-23 00:57:29 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* v4l2_s_ctrl - Helper function to implement
|
|
|
|
* :ref:`VIDIOC_S_CTRL <vidioc_g_ctrl>` ioctl
|
|
|
|
*
|
|
|
|
* @fh: pointer to &struct v4l2_fh
|
|
|
|
* @hdl: pointer to &struct v4l2_ctrl_handler
|
|
|
|
*
|
|
|
|
* @ctrl: pointer to &struct v4l2_control
|
|
|
|
*
|
|
|
|
* If hdl == NULL then they will all return -EINVAL.
|
|
|
|
*/
|
2011-06-07 17:47:18 +08:00
|
|
|
int v4l2_s_ctrl(struct v4l2_fh *fh, struct v4l2_ctrl_handler *hdl,
|
2016-07-23 00:57:29 +08:00
|
|
|
struct v4l2_control *ctrl);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* v4l2_g_ext_ctrls - Helper function to implement
|
|
|
|
* :ref:`VIDIOC_G_EXT_CTRLS <vidioc_g_ext_ctrls>` ioctl
|
|
|
|
*
|
|
|
|
* @hdl: pointer to &struct v4l2_ctrl_handler
|
2018-05-21 16:54:42 +08:00
|
|
|
* @mdev: pointer to &struct media_device
|
2016-07-23 00:57:29 +08:00
|
|
|
* @c: pointer to &struct v4l2_ext_controls
|
|
|
|
*
|
|
|
|
* If hdl == NULL then they will all return -EINVAL.
|
|
|
|
*/
|
2018-05-21 16:54:42 +08:00
|
|
|
int v4l2_g_ext_ctrls(struct v4l2_ctrl_handler *hdl, struct media_device *mdev,
|
2016-07-23 00:57:29 +08:00
|
|
|
struct v4l2_ext_controls *c);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* v4l2_try_ext_ctrls - Helper function to implement
|
|
|
|
* :ref:`VIDIOC_TRY_EXT_CTRLS <vidioc_g_ext_ctrls>` ioctl
|
|
|
|
*
|
|
|
|
* @hdl: pointer to &struct v4l2_ctrl_handler
|
2018-05-21 16:54:42 +08:00
|
|
|
* @mdev: pointer to &struct media_device
|
2016-07-23 00:57:29 +08:00
|
|
|
* @c: pointer to &struct v4l2_ext_controls
|
|
|
|
*
|
|
|
|
* If hdl == NULL then they will all return -EINVAL.
|
|
|
|
*/
|
|
|
|
int v4l2_try_ext_ctrls(struct v4l2_ctrl_handler *hdl,
|
2018-05-21 16:54:42 +08:00
|
|
|
struct media_device *mdev,
|
2016-07-23 00:57:29 +08:00
|
|
|
struct v4l2_ext_controls *c);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* v4l2_s_ext_ctrls - Helper function to implement
|
|
|
|
* :ref:`VIDIOC_S_EXT_CTRLS <vidioc_g_ext_ctrls>` ioctl
|
|
|
|
*
|
|
|
|
* @fh: pointer to &struct v4l2_fh
|
|
|
|
* @hdl: pointer to &struct v4l2_ctrl_handler
|
2018-05-21 16:54:42 +08:00
|
|
|
* @mdev: pointer to &struct media_device
|
2016-07-23 00:57:29 +08:00
|
|
|
* @c: pointer to &struct v4l2_ext_controls
|
|
|
|
*
|
|
|
|
* If hdl == NULL then they will all return -EINVAL.
|
|
|
|
*/
|
2011-06-07 17:47:18 +08:00
|
|
|
int v4l2_s_ext_ctrls(struct v4l2_fh *fh, struct v4l2_ctrl_handler *hdl,
|
2018-05-21 16:54:42 +08:00
|
|
|
struct media_device *mdev,
|
2016-07-23 00:57:29 +08:00
|
|
|
struct v4l2_ext_controls *c);
|
2010-08-02 01:32:42 +08:00
|
|
|
|
2016-07-23 00:57:29 +08:00
|
|
|
/**
|
|
|
|
* v4l2_ctrl_subdev_subscribe_event - Helper function to implement
|
2018-01-04 19:47:28 +08:00
|
|
|
* as a &struct v4l2_subdev_core_ops subscribe_event function
|
2016-07-23 00:57:29 +08:00
|
|
|
* that just subscribes control events.
|
|
|
|
*
|
|
|
|
* @sd: pointer to &struct v4l2_subdev
|
|
|
|
* @fh: pointer to &struct v4l2_fh
|
|
|
|
* @sub: pointer to &struct v4l2_event_subscription
|
|
|
|
*/
|
2013-01-23 06:00:23 +08:00
|
|
|
int v4l2_ctrl_subdev_subscribe_event(struct v4l2_subdev *sd, struct v4l2_fh *fh,
|
|
|
|
struct v4l2_event_subscription *sub);
|
|
|
|
|
2016-07-23 00:57:29 +08:00
|
|
|
/**
|
|
|
|
* v4l2_ctrl_subdev_log_status - Log all controls owned by subdev's control
|
|
|
|
* handler.
|
|
|
|
*
|
|
|
|
* @sd: pointer to &struct v4l2_subdev
|
|
|
|
*/
|
2013-01-23 06:01:02 +08:00
|
|
|
int v4l2_ctrl_subdev_log_status(struct v4l2_subdev *sd);
|
|
|
|
|
2010-08-02 01:32:42 +08:00
|
|
|
#endif
|