1 /* SPDX-License-Identifier: GPL-2.0-or-later */
3 * V4L2 controls framework private header.
5 * Copyright (C) 2010-2021 Hans Verkuil <hverkuil-cisco@xs4all.nl>
8 #ifndef _V4L2_CTRLS_PRIV_H_
9 #define _V4L2_CTRLS_PRIV_H_
11 #define dprintk(vdev, fmt, arg...) do { \
12 if (!WARN_ON(!(vdev)) && ((vdev)->dev_debug & V4L2_DEV_DEBUG_CTRL)) \
13 printk(KERN_DEBUG pr_fmt("%s: %s: " fmt), \
14 __func__, video_device_node_name(vdev), ##arg); \
17 #define has_op(master, op) \
18 ((master)->ops && (master)->ops->op)
19 #define call_op(master, op) \
20 (has_op(master, op) ? (master)->ops->op(master) : 0)
22 static inline u32
node2id(struct list_head
*node
)
24 return list_entry(node
, struct v4l2_ctrl_ref
, node
)->ctrl
->id
;
28 * Small helper function to determine if the autocluster is set to manual
31 static inline bool is_cur_manual(const struct v4l2_ctrl
*master
)
33 return master
->is_auto
&& master
->cur
.val
== master
->manual_mode_value
;
37 * Small helper function to determine if the autocluster will be set to manual
40 static inline bool is_new_manual(const struct v4l2_ctrl
*master
)
42 return master
->is_auto
&& master
->val
== master
->manual_mode_value
;
45 static inline u32
user_flags(const struct v4l2_ctrl
*ctrl
)
47 u32 flags
= ctrl
->flags
;
50 flags
|= V4L2_CTRL_FLAG_HAS_PAYLOAD
;
55 /* v4l2-ctrls-core.c */
56 void cur_to_new(struct v4l2_ctrl
*ctrl
);
57 void cur_to_req(struct v4l2_ctrl_ref
*ref
);
58 void new_to_cur(struct v4l2_fh
*fh
, struct v4l2_ctrl
*ctrl
, u32 ch_flags
);
59 void new_to_req(struct v4l2_ctrl_ref
*ref
);
60 int req_to_new(struct v4l2_ctrl_ref
*ref
);
61 void send_initial_event(struct v4l2_fh
*fh
, struct v4l2_ctrl
*ctrl
);
62 void send_event(struct v4l2_fh
*fh
, struct v4l2_ctrl
*ctrl
, u32 changes
);
63 int handler_new_ref(struct v4l2_ctrl_handler
*hdl
,
64 struct v4l2_ctrl
*ctrl
,
65 struct v4l2_ctrl_ref
**ctrl_ref
,
66 bool from_other_dev
, bool allocate_req
);
67 struct v4l2_ctrl_ref
*find_ref(struct v4l2_ctrl_handler
*hdl
, u32 id
);
68 struct v4l2_ctrl_ref
*find_ref_lock(struct v4l2_ctrl_handler
*hdl
, u32 id
);
69 int check_range(enum v4l2_ctrl_type type
,
70 s64 min
, s64 max
, u64 step
, s64 def
);
71 void update_from_auto_cluster(struct v4l2_ctrl
*master
);
72 int try_or_set_cluster(struct v4l2_fh
*fh
, struct v4l2_ctrl
*master
,
73 bool set
, u32 ch_flags
);
75 /* v4l2-ctrls-api.c */
76 int v4l2_g_ext_ctrls_common(struct v4l2_ctrl_handler
*hdl
,
77 struct v4l2_ext_controls
*cs
,
78 struct video_device
*vdev
);
79 int try_set_ext_ctrls_common(struct v4l2_fh
*fh
,
80 struct v4l2_ctrl_handler
*hdl
,
81 struct v4l2_ext_controls
*cs
,
82 struct video_device
*vdev
, bool set
);
84 /* v4l2-ctrls-request.c */
85 void v4l2_ctrl_handler_init_request(struct v4l2_ctrl_handler
*hdl
);
86 void v4l2_ctrl_handler_free_request(struct v4l2_ctrl_handler
*hdl
);
87 int v4l2_g_ext_ctrls_request(struct v4l2_ctrl_handler
*hdl
, struct video_device
*vdev
,
88 struct media_device
*mdev
, struct v4l2_ext_controls
*cs
);
89 int try_set_ext_ctrls_request(struct v4l2_fh
*fh
,
90 struct v4l2_ctrl_handler
*hdl
,
91 struct video_device
*vdev
,
92 struct media_device
*mdev
,
93 struct v4l2_ext_controls
*cs
, bool set
);