xref: /openbmc/linux/include/media/v4l2-ioctl.h (revision 82e6fdd6)
1 /* SPDX-License-Identifier: GPL-2.0 */
2 /*
3  *
4  *	V 4 L 2   D R I V E R   H E L P E R   A P I
5  *
6  * Moved from videodev2.h
7  *
8  *	Some commonly needed functions for drivers (v4l2-common.o module)
9  */
10 #ifndef _V4L2_IOCTL_H
11 #define _V4L2_IOCTL_H
12 
13 #include <linux/poll.h>
14 #include <linux/fs.h>
15 #include <linux/mutex.h>
16 #include <linux/sched/signal.h>
17 #include <linux/compiler.h> /* need __user */
18 #include <linux/videodev2.h>
19 
20 struct v4l2_fh;
21 
22 /**
23  * struct v4l2_ioctl_ops - describe operations for each V4L2 ioctl
24  *
25  * @vidioc_querycap: pointer to the function that implements
26  *	:ref:`VIDIOC_QUERYCAP <vidioc_querycap>` ioctl
27  * @vidioc_enum_fmt_vid_cap: pointer to the function that implements
28  *	:ref:`VIDIOC_ENUM_FMT <vidioc_enum_fmt>` ioctl logic
29  *	for video capture in single plane mode
30  * @vidioc_enum_fmt_vid_overlay: pointer to the function that implements
31  *	:ref:`VIDIOC_ENUM_FMT <vidioc_enum_fmt>` ioctl logic
32  *	for video overlay
33  * @vidioc_enum_fmt_vid_out: pointer to the function that implements
34  *	:ref:`VIDIOC_ENUM_FMT <vidioc_enum_fmt>` ioctl logic
35  *	for video output in single plane mode
36  * @vidioc_enum_fmt_vid_cap_mplane: pointer to the function that implements
37  *	:ref:`VIDIOC_ENUM_FMT <vidioc_enum_fmt>` ioctl logic
38  *	for video capture in multiplane mode
39  * @vidioc_enum_fmt_vid_out_mplane: pointer to the function that implements
40  *	:ref:`VIDIOC_ENUM_FMT <vidioc_enum_fmt>` ioctl logic
41  *	for video output in multiplane mode
42  * @vidioc_enum_fmt_sdr_cap: pointer to the function that implements
43  *	:ref:`VIDIOC_ENUM_FMT <vidioc_enum_fmt>` ioctl logic
44  *	for Software Defined Radio capture
45  * @vidioc_enum_fmt_sdr_out: pointer to the function that implements
46  *	:ref:`VIDIOC_ENUM_FMT <vidioc_enum_fmt>` ioctl logic
47  *	for Software Defined Radio output
48  * @vidioc_enum_fmt_meta_cap: pointer to the function that implements
49  *	:ref:`VIDIOC_ENUM_FMT <vidioc_enum_fmt>` ioctl logic
50  *	for metadata capture
51  * @vidioc_g_fmt_vid_cap: pointer to the function that implements
52  *	:ref:`VIDIOC_G_FMT <vidioc_g_fmt>` ioctl logic for video capture
53  *	in single plane mode
54  * @vidioc_g_fmt_vid_overlay: pointer to the function that implements
55  *	:ref:`VIDIOC_G_FMT <vidioc_g_fmt>` ioctl logic for video overlay
56  * @vidioc_g_fmt_vid_out: pointer to the function that implements
57  *	:ref:`VIDIOC_G_FMT <vidioc_g_fmt>` ioctl logic for video out
58  *	in single plane mode
59  * @vidioc_g_fmt_vid_out_overlay: pointer to the function that implements
60  *	:ref:`VIDIOC_G_FMT <vidioc_g_fmt>` ioctl logic for video overlay output
61  * @vidioc_g_fmt_vbi_cap: pointer to the function that implements
62  *	:ref:`VIDIOC_G_FMT <vidioc_g_fmt>` ioctl logic for raw VBI capture
63  * @vidioc_g_fmt_vbi_out: pointer to the function that implements
64  *	:ref:`VIDIOC_G_FMT <vidioc_g_fmt>` ioctl logic for raw VBI output
65  * @vidioc_g_fmt_sliced_vbi_cap: pointer to the function that implements
66  *	:ref:`VIDIOC_G_FMT <vidioc_g_fmt>` ioctl logic for sliced VBI capture
67  * @vidioc_g_fmt_sliced_vbi_out: pointer to the function that implements
68  *	:ref:`VIDIOC_G_FMT <vidioc_g_fmt>` ioctl logic for sliced VBI output
69  * @vidioc_g_fmt_vid_cap_mplane: pointer to the function that implements
70  *	:ref:`VIDIOC_G_FMT <vidioc_g_fmt>` ioctl logic for video capture
71  *	in multiple plane mode
72  * @vidioc_g_fmt_vid_out_mplane: pointer to the function that implements
73  *	:ref:`VIDIOC_G_FMT <vidioc_g_fmt>` ioctl logic for video out
74  *	in multiplane plane mode
75  * @vidioc_g_fmt_sdr_cap: pointer to the function that implements
76  *	:ref:`VIDIOC_G_FMT <vidioc_g_fmt>` ioctl logic for Software Defined
77  *	Radio capture
78  * @vidioc_g_fmt_sdr_out: pointer to the function that implements
79  *	:ref:`VIDIOC_G_FMT <vidioc_g_fmt>` ioctl logic for Software Defined
80  *	Radio output
81  * @vidioc_g_fmt_meta_cap: pointer to the function that implements
82  *	:ref:`VIDIOC_G_FMT <vidioc_g_fmt>` ioctl logic for metadata capture
83  * @vidioc_s_fmt_vid_cap: pointer to the function that implements
84  *	:ref:`VIDIOC_S_FMT <vidioc_g_fmt>` ioctl logic for video capture
85  *	in single plane mode
86  * @vidioc_s_fmt_vid_overlay: pointer to the function that implements
87  *	:ref:`VIDIOC_S_FMT <vidioc_g_fmt>` ioctl logic for video overlay
88  * @vidioc_s_fmt_vid_out: pointer to the function that implements
89  *	:ref:`VIDIOC_S_FMT <vidioc_g_fmt>` ioctl logic for video out
90  *	in single plane mode
91  * @vidioc_s_fmt_vid_out_overlay: pointer to the function that implements
92  *	:ref:`VIDIOC_S_FMT <vidioc_g_fmt>` ioctl logic for video overlay output
93  * @vidioc_s_fmt_vbi_cap: pointer to the function that implements
94  *	:ref:`VIDIOC_S_FMT <vidioc_g_fmt>` ioctl logic for raw VBI capture
95  * @vidioc_s_fmt_vbi_out: pointer to the function that implements
96  *	:ref:`VIDIOC_S_FMT <vidioc_g_fmt>` ioctl logic for raw VBI output
97  * @vidioc_s_fmt_sliced_vbi_cap: pointer to the function that implements
98  *	:ref:`VIDIOC_S_FMT <vidioc_g_fmt>` ioctl logic for sliced VBI capture
99  * @vidioc_s_fmt_sliced_vbi_out: pointer to the function that implements
100  *	:ref:`VIDIOC_S_FMT <vidioc_g_fmt>` ioctl logic for sliced VBI output
101  * @vidioc_s_fmt_vid_cap_mplane: pointer to the function that implements
102  *	:ref:`VIDIOC_S_FMT <vidioc_g_fmt>` ioctl logic for video capture
103  *	in multiple plane mode
104  * @vidioc_s_fmt_vid_out_mplane: pointer to the function that implements
105  *	:ref:`VIDIOC_S_FMT <vidioc_g_fmt>` ioctl logic for video out
106  *	in multiplane plane mode
107  * @vidioc_s_fmt_sdr_cap: pointer to the function that implements
108  *	:ref:`VIDIOC_S_FMT <vidioc_g_fmt>` ioctl logic for Software Defined
109  *	Radio capture
110  * @vidioc_s_fmt_sdr_out: pointer to the function that implements
111  *	:ref:`VIDIOC_S_FMT <vidioc_g_fmt>` ioctl logic for Software Defined
112  *	Radio output
113  * @vidioc_s_fmt_meta_cap: pointer to the function that implements
114  *	:ref:`VIDIOC_S_FMT <vidioc_g_fmt>` ioctl logic for metadata capture
115  * @vidioc_try_fmt_vid_cap: pointer to the function that implements
116  *	:ref:`VIDIOC_TRY_FMT <vidioc_g_fmt>` ioctl logic for video capture
117  *	in single plane mode
118  * @vidioc_try_fmt_vid_overlay: pointer to the function that implements
119  *	:ref:`VIDIOC_TRY_FMT <vidioc_g_fmt>` ioctl logic for video overlay
120  * @vidioc_try_fmt_vid_out: pointer to the function that implements
121  *	:ref:`VIDIOC_TRY_FMT <vidioc_g_fmt>` ioctl logic for video out
122  *	in single plane mode
123  * @vidioc_try_fmt_vid_out_overlay: pointer to the function that implements
124  *	:ref:`VIDIOC_TRY_FMT <vidioc_g_fmt>` ioctl logic for video overlay
125  *	output
126  * @vidioc_try_fmt_vbi_cap: pointer to the function that implements
127  *	:ref:`VIDIOC_TRY_FMT <vidioc_g_fmt>` ioctl logic for raw VBI capture
128  * @vidioc_try_fmt_vbi_out: pointer to the function that implements
129  *	:ref:`VIDIOC_TRY_FMT <vidioc_g_fmt>` ioctl logic for raw VBI output
130  * @vidioc_try_fmt_sliced_vbi_cap: pointer to the function that implements
131  *	:ref:`VIDIOC_TRY_FMT <vidioc_g_fmt>` ioctl logic for sliced VBI
132  *	capture
133  * @vidioc_try_fmt_sliced_vbi_out: pointer to the function that implements
134  *	:ref:`VIDIOC_TRY_FMT <vidioc_g_fmt>` ioctl logic for sliced VBI output
135  * @vidioc_try_fmt_vid_cap_mplane: pointer to the function that implements
136  *	:ref:`VIDIOC_TRY_FMT <vidioc_g_fmt>` ioctl logic for video capture
137  *	in multiple plane mode
138  * @vidioc_try_fmt_vid_out_mplane: pointer to the function that implements
139  *	:ref:`VIDIOC_TRY_FMT <vidioc_g_fmt>` ioctl logic for video out
140  *	in multiplane plane mode
141  * @vidioc_try_fmt_sdr_cap: pointer to the function that implements
142  *	:ref:`VIDIOC_TRY_FMT <vidioc_g_fmt>` ioctl logic for Software Defined
143  *	Radio capture
144  * @vidioc_try_fmt_sdr_out: pointer to the function that implements
145  *	:ref:`VIDIOC_TRY_FMT <vidioc_g_fmt>` ioctl logic for Software Defined
146  *	Radio output
147  * @vidioc_try_fmt_meta_cap: pointer to the function that implements
148  *	:ref:`VIDIOC_TRY_FMT <vidioc_g_fmt>` ioctl logic for metadata capture
149  * @vidioc_reqbufs: pointer to the function that implements
150  *	:ref:`VIDIOC_REQBUFS <vidioc_reqbufs>` ioctl
151  * @vidioc_querybuf: pointer to the function that implements
152  *	:ref:`VIDIOC_QUERYBUF <vidioc_querybuf>` ioctl
153  * @vidioc_qbuf: pointer to the function that implements
154  *	:ref:`VIDIOC_QBUF <vidioc_qbuf>` ioctl
155  * @vidioc_expbuf: pointer to the function that implements
156  *	:ref:`VIDIOC_EXPBUF <vidioc_expbuf>` ioctl
157  * @vidioc_dqbuf: pointer to the function that implements
158  *	:ref:`VIDIOC_DQBUF <vidioc_qbuf>` ioctl
159  * @vidioc_create_bufs: pointer to the function that implements
160  *	:ref:`VIDIOC_CREATE_BUFS <vidioc_create_bufs>` ioctl
161  * @vidioc_prepare_buf: pointer to the function that implements
162  *	:ref:`VIDIOC_PREPARE_BUF <vidioc_prepare_buf>` ioctl
163  * @vidioc_overlay: pointer to the function that implements
164  *	:ref:`VIDIOC_OVERLAY <vidioc_overlay>` ioctl
165  * @vidioc_g_fbuf: pointer to the function that implements
166  *	:ref:`VIDIOC_G_FBUF <vidioc_g_fbuf>` ioctl
167  * @vidioc_s_fbuf: pointer to the function that implements
168  *	:ref:`VIDIOC_S_FBUF <vidioc_g_fbuf>` ioctl
169  * @vidioc_streamon: pointer to the function that implements
170  *	:ref:`VIDIOC_STREAMON <vidioc_streamon>` ioctl
171  * @vidioc_streamoff: pointer to the function that implements
172  *	:ref:`VIDIOC_STREAMOFF <vidioc_streamon>` ioctl
173  * @vidioc_g_std: pointer to the function that implements
174  *	:ref:`VIDIOC_G_STD <vidioc_g_std>` ioctl
175  * @vidioc_s_std: pointer to the function that implements
176  *	:ref:`VIDIOC_S_STD <vidioc_g_std>` ioctl
177  * @vidioc_querystd: pointer to the function that implements
178  *	:ref:`VIDIOC_QUERYSTD <vidioc_querystd>` ioctl
179  * @vidioc_enum_input: pointer to the function that implements
180  *	:ref:`VIDIOC_ENUM_INPUT <vidioc_g_input>` ioctl
181  * @vidioc_g_input: pointer to the function that implements
182  *	:ref:`VIDIOC_G_INPUT <vidioc_g_input>` ioctl
183  * @vidioc_s_input: pointer to the function that implements
184  *	:ref:`VIDIOC_S_INPUT <vidioc_g_input>` ioctl
185  * @vidioc_enum_output: pointer to the function that implements
186  *	:ref:`VIDIOC_ENUM_OUTPUT <vidioc_g_output>` ioctl
187  * @vidioc_g_output: pointer to the function that implements
188  *	:ref:`VIDIOC_G_OUTPUT <vidioc_g_output>` ioctl
189  * @vidioc_s_output: pointer to the function that implements
190  *	:ref:`VIDIOC_S_OUTPUT <vidioc_g_output>` ioctl
191  * @vidioc_queryctrl: pointer to the function that implements
192  *	:ref:`VIDIOC_QUERYCTRL <vidioc_queryctrl>` ioctl
193  * @vidioc_query_ext_ctrl: pointer to the function that implements
194  *	:ref:`VIDIOC_QUERY_EXT_CTRL <vidioc_queryctrl>` ioctl
195  * @vidioc_g_ctrl: pointer to the function that implements
196  *	:ref:`VIDIOC_G_CTRL <vidioc_g_ctrl>` ioctl
197  * @vidioc_s_ctrl: pointer to the function that implements
198  *	:ref:`VIDIOC_S_CTRL <vidioc_g_ctrl>` ioctl
199  * @vidioc_g_ext_ctrls: pointer to the function that implements
200  *	:ref:`VIDIOC_G_EXT_CTRLS <vidioc_g_ext_ctrls>` ioctl
201  * @vidioc_s_ext_ctrls: pointer to the function that implements
202  *	:ref:`VIDIOC_S_EXT_CTRLS <vidioc_g_ext_ctrls>` ioctl
203  * @vidioc_try_ext_ctrls: pointer to the function that implements
204  *	:ref:`VIDIOC_TRY_EXT_CTRLS <vidioc_g_ext_ctrls>` ioctl
205  * @vidioc_querymenu: pointer to the function that implements
206  *	:ref:`VIDIOC_QUERYMENU <vidioc_queryctrl>` ioctl
207  * @vidioc_enumaudio: pointer to the function that implements
208  *	:ref:`VIDIOC_ENUMAUDIO <vidioc_enumaudio>` ioctl
209  * @vidioc_g_audio: pointer to the function that implements
210  *	:ref:`VIDIOC_G_AUDIO <vidioc_g_audio>` ioctl
211  * @vidioc_s_audio: pointer to the function that implements
212  *	:ref:`VIDIOC_S_AUDIO <vidioc_g_audio>` ioctl
213  * @vidioc_enumaudout: pointer to the function that implements
214  *	:ref:`VIDIOC_ENUMAUDOUT <vidioc_enumaudout>` ioctl
215  * @vidioc_g_audout: pointer to the function that implements
216  *	:ref:`VIDIOC_G_AUDOUT <vidioc_g_audout>` ioctl
217  * @vidioc_s_audout: pointer to the function that implements
218  *	:ref:`VIDIOC_S_AUDOUT <vidioc_g_audout>` ioctl
219  * @vidioc_g_modulator: pointer to the function that implements
220  *	:ref:`VIDIOC_G_MODULATOR <vidioc_g_modulator>` ioctl
221  * @vidioc_s_modulator: pointer to the function that implements
222  *	:ref:`VIDIOC_S_MODULATOR <vidioc_g_modulator>` ioctl
223  * @vidioc_cropcap: pointer to the function that implements
224  *	:ref:`VIDIOC_CROPCAP <vidioc_cropcap>` ioctl
225  * @vidioc_g_crop: pointer to the function that implements
226  *	:ref:`VIDIOC_G_CROP <vidioc_g_crop>` ioctl
227  * @vidioc_s_crop: pointer to the function that implements
228  *	:ref:`VIDIOC_S_CROP <vidioc_g_crop>` ioctl
229  * @vidioc_g_selection: pointer to the function that implements
230  *	:ref:`VIDIOC_G_SELECTION <vidioc_g_selection>` ioctl
231  * @vidioc_s_selection: pointer to the function that implements
232  *	:ref:`VIDIOC_S_SELECTION <vidioc_g_selection>` ioctl
233  * @vidioc_g_jpegcomp: pointer to the function that implements
234  *	:ref:`VIDIOC_G_JPEGCOMP <vidioc_g_jpegcomp>` ioctl
235  * @vidioc_s_jpegcomp: pointer to the function that implements
236  *	:ref:`VIDIOC_S_JPEGCOMP <vidioc_g_jpegcomp>` ioctl
237  * @vidioc_g_enc_index: pointer to the function that implements
238  *	:ref:`VIDIOC_G_ENC_INDEX <vidioc_g_enc_index>` ioctl
239  * @vidioc_encoder_cmd: pointer to the function that implements
240  *	:ref:`VIDIOC_ENCODER_CMD <vidioc_encoder_cmd>` ioctl
241  * @vidioc_try_encoder_cmd: pointer to the function that implements
242  *	:ref:`VIDIOC_TRY_ENCODER_CMD <vidioc_encoder_cmd>` ioctl
243  * @vidioc_decoder_cmd: pointer to the function that implements
244  *	:ref:`VIDIOC_DECODER_CMD <vidioc_decoder_cmd>` ioctl
245  * @vidioc_try_decoder_cmd: pointer to the function that implements
246  *	:ref:`VIDIOC_TRY_DECODER_CMD <vidioc_decoder_cmd>` ioctl
247  * @vidioc_g_parm: pointer to the function that implements
248  *	:ref:`VIDIOC_G_PARM <vidioc_g_parm>` ioctl
249  * @vidioc_s_parm: pointer to the function that implements
250  *	:ref:`VIDIOC_S_PARM <vidioc_g_parm>` ioctl
251  * @vidioc_g_tuner: pointer to the function that implements
252  *	:ref:`VIDIOC_G_TUNER <vidioc_g_tuner>` ioctl
253  * @vidioc_s_tuner: pointer to the function that implements
254  *	:ref:`VIDIOC_S_TUNER <vidioc_g_tuner>` ioctl
255  * @vidioc_g_frequency: pointer to the function that implements
256  *	:ref:`VIDIOC_G_FREQUENCY <vidioc_g_frequency>` ioctl
257  * @vidioc_s_frequency: pointer to the function that implements
258  *	:ref:`VIDIOC_S_FREQUENCY <vidioc_g_frequency>` ioctl
259  * @vidioc_enum_freq_bands: pointer to the function that implements
260  *	:ref:`VIDIOC_ENUM_FREQ_BANDS <vidioc_enum_freq_bands>` ioctl
261  * @vidioc_g_sliced_vbi_cap: pointer to the function that implements
262  *	:ref:`VIDIOC_G_SLICED_VBI_CAP <vidioc_g_sliced_vbi_cap>` ioctl
263  * @vidioc_log_status: pointer to the function that implements
264  *	:ref:`VIDIOC_LOG_STATUS <vidioc_log_status>` ioctl
265  * @vidioc_s_hw_freq_seek: pointer to the function that implements
266  *	:ref:`VIDIOC_S_HW_FREQ_SEEK <vidioc_s_hw_freq_seek>` ioctl
267  * @vidioc_g_register: pointer to the function that implements
268  *	:ref:`VIDIOC_DBG_G_REGISTER <vidioc_dbg_g_register>` ioctl
269  * @vidioc_s_register: pointer to the function that implements
270  *	:ref:`VIDIOC_DBG_S_REGISTER <vidioc_dbg_g_register>` ioctl
271  * @vidioc_g_chip_info: pointer to the function that implements
272  *	:ref:`VIDIOC_DBG_G_CHIP_INFO <vidioc_dbg_g_chip_info>` ioctl
273  * @vidioc_enum_framesizes: pointer to the function that implements
274  *	:ref:`VIDIOC_ENUM_FRAMESIZES <vidioc_enum_framesizes>` ioctl
275  * @vidioc_enum_frameintervals: pointer to the function that implements
276  *	:ref:`VIDIOC_ENUM_FRAMEINTERVALS <vidioc_enum_frameintervals>` ioctl
277  * @vidioc_s_dv_timings: pointer to the function that implements
278  *	:ref:`VIDIOC_S_DV_TIMINGS <vidioc_g_dv_timings>` ioctl
279  * @vidioc_g_dv_timings: pointer to the function that implements
280  *	:ref:`VIDIOC_G_DV_TIMINGS <vidioc_g_dv_timings>` ioctl
281  * @vidioc_query_dv_timings: pointer to the function that implements
282  *	:ref:`VIDIOC_QUERY_DV_TIMINGS <vidioc_query_dv_timings>` ioctl
283  * @vidioc_enum_dv_timings: pointer to the function that implements
284  *	:ref:`VIDIOC_ENUM_DV_TIMINGS <vidioc_enum_dv_timings>` ioctl
285  * @vidioc_dv_timings_cap: pointer to the function that implements
286  *	:ref:`VIDIOC_DV_TIMINGS_CAP <vidioc_dv_timings_cap>` ioctl
287  * @vidioc_g_edid: pointer to the function that implements
288  *	:ref:`VIDIOC_G_EDID <vidioc_g_edid>` ioctl
289  * @vidioc_s_edid: pointer to the function that implements
290  *	:ref:`VIDIOC_S_EDID <vidioc_g_edid>` ioctl
291  * @vidioc_subscribe_event: pointer to the function that implements
292  *	:ref:`VIDIOC_SUBSCRIBE_EVENT <vidioc_subscribe_event>` ioctl
293  * @vidioc_unsubscribe_event: pointer to the function that implements
294  *	:ref:`VIDIOC_UNSUBSCRIBE_EVENT <vidioc_unsubscribe_event>` ioctl
295  * @vidioc_default: pointed used to allow other ioctls
296  */
297 struct v4l2_ioctl_ops {
298 	/* ioctl callbacks */
299 
300 	/* VIDIOC_QUERYCAP handler */
301 	int (*vidioc_querycap)(struct file *file, void *fh,
302 			       struct v4l2_capability *cap);
303 
304 	/* VIDIOC_ENUM_FMT handlers */
305 	int (*vidioc_enum_fmt_vid_cap)(struct file *file, void *fh,
306 				       struct v4l2_fmtdesc *f);
307 	int (*vidioc_enum_fmt_vid_overlay)(struct file *file, void *fh,
308 					   struct v4l2_fmtdesc *f);
309 	int (*vidioc_enum_fmt_vid_out)(struct file *file, void *fh,
310 				       struct v4l2_fmtdesc *f);
311 	int (*vidioc_enum_fmt_vid_cap_mplane)(struct file *file, void *fh,
312 					      struct v4l2_fmtdesc *f);
313 	int (*vidioc_enum_fmt_vid_out_mplane)(struct file *file, void *fh,
314 					      struct v4l2_fmtdesc *f);
315 	int (*vidioc_enum_fmt_sdr_cap)(struct file *file, void *fh,
316 				       struct v4l2_fmtdesc *f);
317 	int (*vidioc_enum_fmt_sdr_out)(struct file *file, void *fh,
318 				       struct v4l2_fmtdesc *f);
319 	int (*vidioc_enum_fmt_meta_cap)(struct file *file, void *fh,
320 					struct v4l2_fmtdesc *f);
321 
322 	/* VIDIOC_G_FMT handlers */
323 	int (*vidioc_g_fmt_vid_cap)(struct file *file, void *fh,
324 				    struct v4l2_format *f);
325 	int (*vidioc_g_fmt_vid_overlay)(struct file *file, void *fh,
326 					struct v4l2_format *f);
327 	int (*vidioc_g_fmt_vid_out)(struct file *file, void *fh,
328 				    struct v4l2_format *f);
329 	int (*vidioc_g_fmt_vid_out_overlay)(struct file *file, void *fh,
330 					    struct v4l2_format *f);
331 	int (*vidioc_g_fmt_vbi_cap)(struct file *file, void *fh,
332 				    struct v4l2_format *f);
333 	int (*vidioc_g_fmt_vbi_out)(struct file *file, void *fh,
334 				    struct v4l2_format *f);
335 	int (*vidioc_g_fmt_sliced_vbi_cap)(struct file *file, void *fh,
336 					   struct v4l2_format *f);
337 	int (*vidioc_g_fmt_sliced_vbi_out)(struct file *file, void *fh,
338 					   struct v4l2_format *f);
339 	int (*vidioc_g_fmt_vid_cap_mplane)(struct file *file, void *fh,
340 					   struct v4l2_format *f);
341 	int (*vidioc_g_fmt_vid_out_mplane)(struct file *file, void *fh,
342 					   struct v4l2_format *f);
343 	int (*vidioc_g_fmt_sdr_cap)(struct file *file, void *fh,
344 				    struct v4l2_format *f);
345 	int (*vidioc_g_fmt_sdr_out)(struct file *file, void *fh,
346 				    struct v4l2_format *f);
347 	int (*vidioc_g_fmt_meta_cap)(struct file *file, void *fh,
348 				     struct v4l2_format *f);
349 
350 	/* VIDIOC_S_FMT handlers */
351 	int (*vidioc_s_fmt_vid_cap)(struct file *file, void *fh,
352 				    struct v4l2_format *f);
353 	int (*vidioc_s_fmt_vid_overlay)(struct file *file, void *fh,
354 					struct v4l2_format *f);
355 	int (*vidioc_s_fmt_vid_out)(struct file *file, void *fh,
356 				    struct v4l2_format *f);
357 	int (*vidioc_s_fmt_vid_out_overlay)(struct file *file, void *fh,
358 					    struct v4l2_format *f);
359 	int (*vidioc_s_fmt_vbi_cap)(struct file *file, void *fh,
360 				    struct v4l2_format *f);
361 	int (*vidioc_s_fmt_vbi_out)(struct file *file, void *fh,
362 				    struct v4l2_format *f);
363 	int (*vidioc_s_fmt_sliced_vbi_cap)(struct file *file, void *fh,
364 					   struct v4l2_format *f);
365 	int (*vidioc_s_fmt_sliced_vbi_out)(struct file *file, void *fh,
366 					   struct v4l2_format *f);
367 	int (*vidioc_s_fmt_vid_cap_mplane)(struct file *file, void *fh,
368 					   struct v4l2_format *f);
369 	int (*vidioc_s_fmt_vid_out_mplane)(struct file *file, void *fh,
370 					   struct v4l2_format *f);
371 	int (*vidioc_s_fmt_sdr_cap)(struct file *file, void *fh,
372 				    struct v4l2_format *f);
373 	int (*vidioc_s_fmt_sdr_out)(struct file *file, void *fh,
374 				    struct v4l2_format *f);
375 	int (*vidioc_s_fmt_meta_cap)(struct file *file, void *fh,
376 				     struct v4l2_format *f);
377 
378 	/* VIDIOC_TRY_FMT handlers */
379 	int (*vidioc_try_fmt_vid_cap)(struct file *file, void *fh,
380 				      struct v4l2_format *f);
381 	int (*vidioc_try_fmt_vid_overlay)(struct file *file, void *fh,
382 					  struct v4l2_format *f);
383 	int (*vidioc_try_fmt_vid_out)(struct file *file, void *fh,
384 				      struct v4l2_format *f);
385 	int (*vidioc_try_fmt_vid_out_overlay)(struct file *file, void *fh,
386 					     struct v4l2_format *f);
387 	int (*vidioc_try_fmt_vbi_cap)(struct file *file, void *fh,
388 				      struct v4l2_format *f);
389 	int (*vidioc_try_fmt_vbi_out)(struct file *file, void *fh,
390 				      struct v4l2_format *f);
391 	int (*vidioc_try_fmt_sliced_vbi_cap)(struct file *file, void *fh,
392 					     struct v4l2_format *f);
393 	int (*vidioc_try_fmt_sliced_vbi_out)(struct file *file, void *fh,
394 					     struct v4l2_format *f);
395 	int (*vidioc_try_fmt_vid_cap_mplane)(struct file *file, void *fh,
396 					     struct v4l2_format *f);
397 	int (*vidioc_try_fmt_vid_out_mplane)(struct file *file, void *fh,
398 					     struct v4l2_format *f);
399 	int (*vidioc_try_fmt_sdr_cap)(struct file *file, void *fh,
400 				      struct v4l2_format *f);
401 	int (*vidioc_try_fmt_sdr_out)(struct file *file, void *fh,
402 				      struct v4l2_format *f);
403 	int (*vidioc_try_fmt_meta_cap)(struct file *file, void *fh,
404 				       struct v4l2_format *f);
405 
406 	/* Buffer handlers */
407 	int (*vidioc_reqbufs)(struct file *file, void *fh,
408 			      struct v4l2_requestbuffers *b);
409 	int (*vidioc_querybuf)(struct file *file, void *fh,
410 			       struct v4l2_buffer *b);
411 	int (*vidioc_qbuf)(struct file *file, void *fh,
412 			   struct v4l2_buffer *b);
413 	int (*vidioc_expbuf)(struct file *file, void *fh,
414 			     struct v4l2_exportbuffer *e);
415 	int (*vidioc_dqbuf)(struct file *file, void *fh,
416 			    struct v4l2_buffer *b);
417 
418 	int (*vidioc_create_bufs)(struct file *file, void *fh,
419 				  struct v4l2_create_buffers *b);
420 	int (*vidioc_prepare_buf)(struct file *file, void *fh,
421 				  struct v4l2_buffer *b);
422 
423 	int (*vidioc_overlay)(struct file *file, void *fh, unsigned int i);
424 	int (*vidioc_g_fbuf)(struct file *file, void *fh,
425 			     struct v4l2_framebuffer *a);
426 	int (*vidioc_s_fbuf)(struct file *file, void *fh,
427 			     const struct v4l2_framebuffer *a);
428 
429 		/* Stream on/off */
430 	int (*vidioc_streamon)(struct file *file, void *fh,
431 			       enum v4l2_buf_type i);
432 	int (*vidioc_streamoff)(struct file *file, void *fh,
433 				enum v4l2_buf_type i);
434 
435 		/*
436 		 * Standard handling
437 		 *
438 		 * Note: ENUMSTD is handled by videodev.c
439 		 */
440 	int (*vidioc_g_std)(struct file *file, void *fh, v4l2_std_id *norm);
441 	int (*vidioc_s_std)(struct file *file, void *fh, v4l2_std_id norm);
442 	int (*vidioc_querystd)(struct file *file, void *fh, v4l2_std_id *a);
443 
444 		/* Input handling */
445 	int (*vidioc_enum_input)(struct file *file, void *fh,
446 				 struct v4l2_input *inp);
447 	int (*vidioc_g_input)(struct file *file, void *fh, unsigned int *i);
448 	int (*vidioc_s_input)(struct file *file, void *fh, unsigned int i);
449 
450 		/* Output handling */
451 	int (*vidioc_enum_output)(struct file *file, void *fh,
452 				  struct v4l2_output *a);
453 	int (*vidioc_g_output)(struct file *file, void *fh, unsigned int *i);
454 	int (*vidioc_s_output)(struct file *file, void *fh, unsigned int i);
455 
456 		/* Control handling */
457 	int (*vidioc_queryctrl)(struct file *file, void *fh,
458 				struct v4l2_queryctrl *a);
459 	int (*vidioc_query_ext_ctrl)(struct file *file, void *fh,
460 				     struct v4l2_query_ext_ctrl *a);
461 	int (*vidioc_g_ctrl)(struct file *file, void *fh,
462 			     struct v4l2_control *a);
463 	int (*vidioc_s_ctrl)(struct file *file, void *fh,
464 			     struct v4l2_control *a);
465 	int (*vidioc_g_ext_ctrls)(struct file *file, void *fh,
466 				  struct v4l2_ext_controls *a);
467 	int (*vidioc_s_ext_ctrls)(struct file *file, void *fh,
468 				  struct v4l2_ext_controls *a);
469 	int (*vidioc_try_ext_ctrls)(struct file *file, void *fh,
470 				    struct v4l2_ext_controls *a);
471 	int (*vidioc_querymenu)(struct file *file, void *fh,
472 				struct v4l2_querymenu *a);
473 
474 	/* Audio ioctls */
475 	int (*vidioc_enumaudio)(struct file *file, void *fh,
476 				struct v4l2_audio *a);
477 	int (*vidioc_g_audio)(struct file *file, void *fh,
478 			      struct v4l2_audio *a);
479 	int (*vidioc_s_audio)(struct file *file, void *fh,
480 			      const struct v4l2_audio *a);
481 
482 	/* Audio out ioctls */
483 	int (*vidioc_enumaudout)(struct file *file, void *fh,
484 				 struct v4l2_audioout *a);
485 	int (*vidioc_g_audout)(struct file *file, void *fh,
486 			       struct v4l2_audioout *a);
487 	int (*vidioc_s_audout)(struct file *file, void *fh,
488 			       const struct v4l2_audioout *a);
489 	int (*vidioc_g_modulator)(struct file *file, void *fh,
490 				  struct v4l2_modulator *a);
491 	int (*vidioc_s_modulator)(struct file *file, void *fh,
492 				  const struct v4l2_modulator *a);
493 	/* Crop ioctls */
494 	int (*vidioc_cropcap)(struct file *file, void *fh,
495 			      struct v4l2_cropcap *a);
496 	int (*vidioc_g_crop)(struct file *file, void *fh,
497 			     struct v4l2_crop *a);
498 	int (*vidioc_s_crop)(struct file *file, void *fh,
499 			     const struct v4l2_crop *a);
500 	int (*vidioc_g_selection)(struct file *file, void *fh,
501 				  struct v4l2_selection *s);
502 	int (*vidioc_s_selection)(struct file *file, void *fh,
503 				  struct v4l2_selection *s);
504 	/* Compression ioctls */
505 	int (*vidioc_g_jpegcomp)(struct file *file, void *fh,
506 				 struct v4l2_jpegcompression *a);
507 	int (*vidioc_s_jpegcomp)(struct file *file, void *fh,
508 				 const struct v4l2_jpegcompression *a);
509 	int (*vidioc_g_enc_index)(struct file *file, void *fh,
510 				  struct v4l2_enc_idx *a);
511 	int (*vidioc_encoder_cmd)(struct file *file, void *fh,
512 				  struct v4l2_encoder_cmd *a);
513 	int (*vidioc_try_encoder_cmd)(struct file *file, void *fh,
514 				      struct v4l2_encoder_cmd *a);
515 	int (*vidioc_decoder_cmd)(struct file *file, void *fh,
516 				  struct v4l2_decoder_cmd *a);
517 	int (*vidioc_try_decoder_cmd)(struct file *file, void *fh,
518 				      struct v4l2_decoder_cmd *a);
519 
520 	/* Stream type-dependent parameter ioctls */
521 	int (*vidioc_g_parm)(struct file *file, void *fh,
522 			     struct v4l2_streamparm *a);
523 	int (*vidioc_s_parm)(struct file *file, void *fh,
524 			     struct v4l2_streamparm *a);
525 
526 	/* Tuner ioctls */
527 	int (*vidioc_g_tuner)(struct file *file, void *fh,
528 			      struct v4l2_tuner *a);
529 	int (*vidioc_s_tuner)(struct file *file, void *fh,
530 			      const struct v4l2_tuner *a);
531 	int (*vidioc_g_frequency)(struct file *file, void *fh,
532 				  struct v4l2_frequency *a);
533 	int (*vidioc_s_frequency)(struct file *file, void *fh,
534 				  const struct v4l2_frequency *a);
535 	int (*vidioc_enum_freq_bands)(struct file *file, void *fh,
536 				      struct v4l2_frequency_band *band);
537 
538 	/* Sliced VBI cap */
539 	int (*vidioc_g_sliced_vbi_cap)(struct file *file, void *fh,
540 				       struct v4l2_sliced_vbi_cap *a);
541 
542 	/* Log status ioctl */
543 	int (*vidioc_log_status)(struct file *file, void *fh);
544 
545 	int (*vidioc_s_hw_freq_seek)(struct file *file, void *fh,
546 				     const struct v4l2_hw_freq_seek *a);
547 
548 	/* Debugging ioctls */
549 #ifdef CONFIG_VIDEO_ADV_DEBUG
550 	int (*vidioc_g_register)(struct file *file, void *fh,
551 				 struct v4l2_dbg_register *reg);
552 	int (*vidioc_s_register)(struct file *file, void *fh,
553 				 const struct v4l2_dbg_register *reg);
554 
555 	int (*vidioc_g_chip_info)(struct file *file, void *fh,
556 				  struct v4l2_dbg_chip_info *chip);
557 #endif
558 
559 	int (*vidioc_enum_framesizes)(struct file *file, void *fh,
560 				      struct v4l2_frmsizeenum *fsize);
561 
562 	int (*vidioc_enum_frameintervals)(struct file *file, void *fh,
563 					  struct v4l2_frmivalenum *fival);
564 
565 	/* DV Timings IOCTLs */
566 	int (*vidioc_s_dv_timings)(struct file *file, void *fh,
567 				   struct v4l2_dv_timings *timings);
568 	int (*vidioc_g_dv_timings)(struct file *file, void *fh,
569 				   struct v4l2_dv_timings *timings);
570 	int (*vidioc_query_dv_timings)(struct file *file, void *fh,
571 				       struct v4l2_dv_timings *timings);
572 	int (*vidioc_enum_dv_timings)(struct file *file, void *fh,
573 				      struct v4l2_enum_dv_timings *timings);
574 	int (*vidioc_dv_timings_cap)(struct file *file, void *fh,
575 				     struct v4l2_dv_timings_cap *cap);
576 	int (*vidioc_g_edid)(struct file *file, void *fh,
577 			     struct v4l2_edid *edid);
578 	int (*vidioc_s_edid)(struct file *file, void *fh,
579 			     struct v4l2_edid *edid);
580 
581 	int (*vidioc_subscribe_event)(struct v4l2_fh *fh,
582 				      const struct v4l2_event_subscription *sub);
583 	int (*vidioc_unsubscribe_event)(struct v4l2_fh *fh,
584 					const struct v4l2_event_subscription *sub);
585 
586 	/* For other private ioctls */
587 	long (*vidioc_default)(struct file *file, void *fh,
588 			       bool valid_prio, unsigned int cmd, void *arg);
589 };
590 
591 
592 /* v4l debugging and diagnostics */
593 
594 /* Device debug flags to be used with the video device debug attribute */
595 
596 /* Just log the ioctl name + error code */
597 #define V4L2_DEV_DEBUG_IOCTL		0x01
598 /* Log the ioctl name arguments + error code */
599 #define V4L2_DEV_DEBUG_IOCTL_ARG	0x02
600 /* Log the file operations open, release, mmap and get_unmapped_area */
601 #define V4L2_DEV_DEBUG_FOP		0x04
602 /* Log the read and write file operations and the VIDIOC_(D)QBUF ioctls */
603 #define V4L2_DEV_DEBUG_STREAMING	0x08
604 /* Log poll() */
605 #define V4L2_DEV_DEBUG_POLL		0x10
606 
607 /*  Video standard functions  */
608 
609 /**
610  * v4l2_norm_to_name - Ancillary routine to analog TV standard name from its ID.
611  *
612  * @id:	analog TV standard ID.
613  *
614  * Return: returns a string with the name of the analog TV standard.
615  * If the standard is not found or if @id points to multiple standard,
616  * it returns "Unknown".
617  */
618 const char *v4l2_norm_to_name(v4l2_std_id id);
619 
620 /**
621  * v4l2_video_std_frame_period - Ancillary routine that fills a
622  *	struct &v4l2_fract pointer with the default framerate fraction.
623  *
624  * @id: analog TV sdandard ID.
625  * @frameperiod: struct &v4l2_fract pointer to be filled
626  *
627  */
628 void v4l2_video_std_frame_period(int id, struct v4l2_fract *frameperiod);
629 
630 /**
631  * v4l2_video_std_construct - Ancillary routine that fills in the fields of
632  *	a &v4l2_standard structure according to the @id parameter.
633  *
634  * @vs: struct &v4l2_standard pointer to be filled
635  * @id: analog TV sdandard ID.
636  * @name: name of the standard to be used
637  *
638  * .. note::
639  *
640  *    This ancillary routine is obsolete. Shouldn't be used on newer drivers.
641  */
642 int v4l2_video_std_construct(struct v4l2_standard *vs,
643 				    int id, const char *name);
644 
645 /**
646  * v4l_printk_ioctl - Ancillary routine that prints the ioctl in a
647  *	human-readable format.
648  *
649  * @prefix: prefix to be added at the ioctl prints.
650  * @cmd: ioctl name
651  *
652  * .. note::
653  *
654  *    If prefix != %NULL, then it will issue a
655  *    ``printk(KERN_DEBUG "%s: ", prefix)`` first.
656  */
657 void v4l_printk_ioctl(const char *prefix, unsigned int cmd);
658 
659 struct video_device;
660 
661 
662 /**
663  * v4l2_ioctl_get_lock - get the mutex (if any) that it is need to lock for
664  *	a given command.
665  *
666  * @vdev: Pointer to struct &video_device.
667  * @cmd: Ioctl name.
668  *
669  * .. note:: Internal use only. Should not be used outside V4L2 core.
670  */
671 struct mutex *v4l2_ioctl_get_lock(struct video_device *vdev, unsigned int cmd);
672 
673 /* names for fancy debug output */
674 extern const char *v4l2_field_names[];
675 extern const char *v4l2_type_names[];
676 
677 #ifdef CONFIG_COMPAT
678 /**
679  * v4l2_compat_ioctl32 -32 Bits compatibility layer for 64 bits processors
680  *
681  * @file: Pointer to struct &file.
682  * @cmd: Ioctl name.
683  * @arg: Ioctl argument.
684  */
685 long int v4l2_compat_ioctl32(struct file *file, unsigned int cmd,
686 			     unsigned long arg);
687 #endif
688 
689 /**
690  * typedef v4l2_kioctl - Typedef used to pass an ioctl handler.
691  *
692  * @file: Pointer to struct &file.
693  * @cmd: Ioctl name.
694  * @arg: Ioctl argument.
695  */
696 typedef long (*v4l2_kioctl)(struct file *file, unsigned int cmd, void *arg);
697 
698 /**
699  * video_usercopy - copies data from/to userspace memory when an ioctl is
700  *	issued.
701  *
702  * @file: Pointer to struct &file.
703  * @cmd: Ioctl name.
704  * @arg: Ioctl argument.
705  * @func: function that will handle the ioctl
706  *
707  * .. note::
708  *
709  *    This routine should be used only inside the V4L2 core.
710  */
711 long int video_usercopy(struct file *file, unsigned int cmd,
712 			unsigned long int arg, v4l2_kioctl func);
713 
714 /**
715  * video_ioctl2 - Handles a V4L2 ioctl.
716  *
717  * @file: Pointer to struct &file.
718  * @cmd: Ioctl name.
719  * @arg: Ioctl argument.
720  *
721  * Method used to hancle an ioctl. Should be used to fill the
722  * &v4l2_ioctl_ops.unlocked_ioctl on all V4L2 drivers.
723  */
724 long int video_ioctl2(struct file *file,
725 		      unsigned int cmd, unsigned long int arg);
726 
727 #endif /* _V4L2_IOCTL_H */
728