v4l2-ioctl.h 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337
  1. /*
  2. *
  3. * V 4 L 2 D R I V E R H E L P E R A P I
  4. *
  5. * Moved from videodev2.h
  6. *
  7. * Some commonly needed functions for drivers (v4l2-common.o module)
  8. */
  9. #ifndef _V4L2_IOCTL_H
  10. #define _V4L2_IOCTL_H
  11. #include <linux/poll.h>
  12. #include <linux/fs.h>
  13. #include <linux/mutex.h>
  14. #include <linux/compiler.h> /* need __user */
  15. #include <linux/videodev2.h>
  16. struct v4l2_fh;
  17. struct v4l2_ioctl_ops {
  18. /* ioctl callbacks */
  19. /* VIDIOC_QUERYCAP handler */
  20. int (*vidioc_querycap)(struct file *file, void *fh, struct v4l2_capability *cap);
  21. /* VIDIOC_ENUM_FMT handlers */
  22. int (*vidioc_enum_fmt_vid_cap) (struct file *file, void *fh,
  23. struct v4l2_fmtdesc *f);
  24. int (*vidioc_enum_fmt_vid_overlay) (struct file *file, void *fh,
  25. struct v4l2_fmtdesc *f);
  26. int (*vidioc_enum_fmt_vid_out) (struct file *file, void *fh,
  27. struct v4l2_fmtdesc *f);
  28. int (*vidioc_enum_fmt_vid_cap_mplane)(struct file *file, void *fh,
  29. struct v4l2_fmtdesc *f);
  30. int (*vidioc_enum_fmt_vid_out_mplane)(struct file *file, void *fh,
  31. struct v4l2_fmtdesc *f);
  32. int (*vidioc_enum_fmt_sdr_cap) (struct file *file, void *fh,
  33. struct v4l2_fmtdesc *f);
  34. /* VIDIOC_G_FMT handlers */
  35. int (*vidioc_g_fmt_vid_cap) (struct file *file, void *fh,
  36. struct v4l2_format *f);
  37. int (*vidioc_g_fmt_vid_overlay)(struct file *file, void *fh,
  38. struct v4l2_format *f);
  39. int (*vidioc_g_fmt_vid_out) (struct file *file, void *fh,
  40. struct v4l2_format *f);
  41. int (*vidioc_g_fmt_vid_out_overlay)(struct file *file, void *fh,
  42. struct v4l2_format *f);
  43. int (*vidioc_g_fmt_vbi_cap) (struct file *file, void *fh,
  44. struct v4l2_format *f);
  45. int (*vidioc_g_fmt_vbi_out) (struct file *file, void *fh,
  46. struct v4l2_format *f);
  47. int (*vidioc_g_fmt_sliced_vbi_cap)(struct file *file, void *fh,
  48. struct v4l2_format *f);
  49. int (*vidioc_g_fmt_sliced_vbi_out)(struct file *file, void *fh,
  50. struct v4l2_format *f);
  51. int (*vidioc_g_fmt_vid_cap_mplane)(struct file *file, void *fh,
  52. struct v4l2_format *f);
  53. int (*vidioc_g_fmt_vid_out_mplane)(struct file *file, void *fh,
  54. struct v4l2_format *f);
  55. int (*vidioc_g_fmt_sdr_cap) (struct file *file, void *fh,
  56. struct v4l2_format *f);
  57. /* VIDIOC_S_FMT handlers */
  58. int (*vidioc_s_fmt_vid_cap) (struct file *file, void *fh,
  59. struct v4l2_format *f);
  60. int (*vidioc_s_fmt_vid_overlay)(struct file *file, void *fh,
  61. struct v4l2_format *f);
  62. int (*vidioc_s_fmt_vid_out) (struct file *file, void *fh,
  63. struct v4l2_format *f);
  64. int (*vidioc_s_fmt_vid_out_overlay)(struct file *file, void *fh,
  65. struct v4l2_format *f);
  66. int (*vidioc_s_fmt_vbi_cap) (struct file *file, void *fh,
  67. struct v4l2_format *f);
  68. int (*vidioc_s_fmt_vbi_out) (struct file *file, void *fh,
  69. struct v4l2_format *f);
  70. int (*vidioc_s_fmt_sliced_vbi_cap)(struct file *file, void *fh,
  71. struct v4l2_format *f);
  72. int (*vidioc_s_fmt_sliced_vbi_out)(struct file *file, void *fh,
  73. struct v4l2_format *f);
  74. int (*vidioc_s_fmt_vid_cap_mplane)(struct file *file, void *fh,
  75. struct v4l2_format *f);
  76. int (*vidioc_s_fmt_vid_out_mplane)(struct file *file, void *fh,
  77. struct v4l2_format *f);
  78. int (*vidioc_s_fmt_sdr_cap) (struct file *file, void *fh,
  79. struct v4l2_format *f);
  80. /* VIDIOC_TRY_FMT handlers */
  81. int (*vidioc_try_fmt_vid_cap) (struct file *file, void *fh,
  82. struct v4l2_format *f);
  83. int (*vidioc_try_fmt_vid_overlay)(struct file *file, void *fh,
  84. struct v4l2_format *f);
  85. int (*vidioc_try_fmt_vid_out) (struct file *file, void *fh,
  86. struct v4l2_format *f);
  87. int (*vidioc_try_fmt_vid_out_overlay)(struct file *file, void *fh,
  88. struct v4l2_format *f);
  89. int (*vidioc_try_fmt_vbi_cap) (struct file *file, void *fh,
  90. struct v4l2_format *f);
  91. int (*vidioc_try_fmt_vbi_out) (struct file *file, void *fh,
  92. struct v4l2_format *f);
  93. int (*vidioc_try_fmt_sliced_vbi_cap)(struct file *file, void *fh,
  94. struct v4l2_format *f);
  95. int (*vidioc_try_fmt_sliced_vbi_out)(struct file *file, void *fh,
  96. struct v4l2_format *f);
  97. int (*vidioc_try_fmt_vid_cap_mplane)(struct file *file, void *fh,
  98. struct v4l2_format *f);
  99. int (*vidioc_try_fmt_vid_out_mplane)(struct file *file, void *fh,
  100. struct v4l2_format *f);
  101. int (*vidioc_try_fmt_sdr_cap) (struct file *file, void *fh,
  102. struct v4l2_format *f);
  103. /* Buffer handlers */
  104. int (*vidioc_reqbufs) (struct file *file, void *fh, struct v4l2_requestbuffers *b);
  105. int (*vidioc_querybuf)(struct file *file, void *fh, struct v4l2_buffer *b);
  106. int (*vidioc_qbuf) (struct file *file, void *fh, struct v4l2_buffer *b);
  107. int (*vidioc_expbuf) (struct file *file, void *fh,
  108. struct v4l2_exportbuffer *e);
  109. int (*vidioc_dqbuf) (struct file *file, void *fh, struct v4l2_buffer *b);
  110. int (*vidioc_create_bufs)(struct file *file, void *fh, struct v4l2_create_buffers *b);
  111. int (*vidioc_prepare_buf)(struct file *file, void *fh, struct v4l2_buffer *b);
  112. int (*vidioc_overlay) (struct file *file, void *fh, unsigned int i);
  113. int (*vidioc_g_fbuf) (struct file *file, void *fh,
  114. struct v4l2_framebuffer *a);
  115. int (*vidioc_s_fbuf) (struct file *file, void *fh,
  116. const struct v4l2_framebuffer *a);
  117. /* Stream on/off */
  118. int (*vidioc_streamon) (struct file *file, void *fh, enum v4l2_buf_type i);
  119. int (*vidioc_streamoff)(struct file *file, void *fh, enum v4l2_buf_type i);
  120. /* Standard handling
  121. ENUMSTD is handled by videodev.c
  122. */
  123. int (*vidioc_g_std) (struct file *file, void *fh, v4l2_std_id *norm);
  124. int (*vidioc_s_std) (struct file *file, void *fh, v4l2_std_id norm);
  125. int (*vidioc_querystd) (struct file *file, void *fh, v4l2_std_id *a);
  126. /* Input handling */
  127. int (*vidioc_enum_input)(struct file *file, void *fh,
  128. struct v4l2_input *inp);
  129. int (*vidioc_g_input) (struct file *file, void *fh, unsigned int *i);
  130. int (*vidioc_s_input) (struct file *file, void *fh, unsigned int i);
  131. /* Output handling */
  132. int (*vidioc_enum_output) (struct file *file, void *fh,
  133. struct v4l2_output *a);
  134. int (*vidioc_g_output) (struct file *file, void *fh, unsigned int *i);
  135. int (*vidioc_s_output) (struct file *file, void *fh, unsigned int i);
  136. /* Control handling */
  137. int (*vidioc_queryctrl) (struct file *file, void *fh,
  138. struct v4l2_queryctrl *a);
  139. int (*vidioc_query_ext_ctrl) (struct file *file, void *fh,
  140. struct v4l2_query_ext_ctrl *a);
  141. int (*vidioc_g_ctrl) (struct file *file, void *fh,
  142. struct v4l2_control *a);
  143. int (*vidioc_s_ctrl) (struct file *file, void *fh,
  144. struct v4l2_control *a);
  145. int (*vidioc_g_ext_ctrls) (struct file *file, void *fh,
  146. struct v4l2_ext_controls *a);
  147. int (*vidioc_s_ext_ctrls) (struct file *file, void *fh,
  148. struct v4l2_ext_controls *a);
  149. int (*vidioc_try_ext_ctrls) (struct file *file, void *fh,
  150. struct v4l2_ext_controls *a);
  151. int (*vidioc_querymenu) (struct file *file, void *fh,
  152. struct v4l2_querymenu *a);
  153. /* Audio ioctls */
  154. int (*vidioc_enumaudio) (struct file *file, void *fh,
  155. struct v4l2_audio *a);
  156. int (*vidioc_g_audio) (struct file *file, void *fh,
  157. struct v4l2_audio *a);
  158. int (*vidioc_s_audio) (struct file *file, void *fh,
  159. const struct v4l2_audio *a);
  160. /* Audio out ioctls */
  161. int (*vidioc_enumaudout) (struct file *file, void *fh,
  162. struct v4l2_audioout *a);
  163. int (*vidioc_g_audout) (struct file *file, void *fh,
  164. struct v4l2_audioout *a);
  165. int (*vidioc_s_audout) (struct file *file, void *fh,
  166. const struct v4l2_audioout *a);
  167. int (*vidioc_g_modulator) (struct file *file, void *fh,
  168. struct v4l2_modulator *a);
  169. int (*vidioc_s_modulator) (struct file *file, void *fh,
  170. const struct v4l2_modulator *a);
  171. /* Crop ioctls */
  172. int (*vidioc_cropcap) (struct file *file, void *fh,
  173. struct v4l2_cropcap *a);
  174. int (*vidioc_g_crop) (struct file *file, void *fh,
  175. struct v4l2_crop *a);
  176. int (*vidioc_s_crop) (struct file *file, void *fh,
  177. const struct v4l2_crop *a);
  178. int (*vidioc_g_selection) (struct file *file, void *fh,
  179. struct v4l2_selection *s);
  180. int (*vidioc_s_selection) (struct file *file, void *fh,
  181. struct v4l2_selection *s);
  182. /* Compression ioctls */
  183. int (*vidioc_g_jpegcomp) (struct file *file, void *fh,
  184. struct v4l2_jpegcompression *a);
  185. int (*vidioc_s_jpegcomp) (struct file *file, void *fh,
  186. const struct v4l2_jpegcompression *a);
  187. int (*vidioc_g_enc_index) (struct file *file, void *fh,
  188. struct v4l2_enc_idx *a);
  189. int (*vidioc_encoder_cmd) (struct file *file, void *fh,
  190. struct v4l2_encoder_cmd *a);
  191. int (*vidioc_try_encoder_cmd) (struct file *file, void *fh,
  192. struct v4l2_encoder_cmd *a);
  193. int (*vidioc_decoder_cmd) (struct file *file, void *fh,
  194. struct v4l2_decoder_cmd *a);
  195. int (*vidioc_try_decoder_cmd) (struct file *file, void *fh,
  196. struct v4l2_decoder_cmd *a);
  197. /* Stream type-dependent parameter ioctls */
  198. int (*vidioc_g_parm) (struct file *file, void *fh,
  199. struct v4l2_streamparm *a);
  200. int (*vidioc_s_parm) (struct file *file, void *fh,
  201. struct v4l2_streamparm *a);
  202. /* Tuner ioctls */
  203. int (*vidioc_g_tuner) (struct file *file, void *fh,
  204. struct v4l2_tuner *a);
  205. int (*vidioc_s_tuner) (struct file *file, void *fh,
  206. const struct v4l2_tuner *a);
  207. int (*vidioc_g_frequency) (struct file *file, void *fh,
  208. struct v4l2_frequency *a);
  209. int (*vidioc_s_frequency) (struct file *file, void *fh,
  210. const struct v4l2_frequency *a);
  211. int (*vidioc_enum_freq_bands) (struct file *file, void *fh,
  212. struct v4l2_frequency_band *band);
  213. /* Sliced VBI cap */
  214. int (*vidioc_g_sliced_vbi_cap) (struct file *file, void *fh,
  215. struct v4l2_sliced_vbi_cap *a);
  216. /* Log status ioctl */
  217. int (*vidioc_log_status) (struct file *file, void *fh);
  218. int (*vidioc_s_hw_freq_seek) (struct file *file, void *fh,
  219. const struct v4l2_hw_freq_seek *a);
  220. /* Debugging ioctls */
  221. #ifdef CONFIG_VIDEO_ADV_DEBUG
  222. int (*vidioc_g_register) (struct file *file, void *fh,
  223. struct v4l2_dbg_register *reg);
  224. int (*vidioc_s_register) (struct file *file, void *fh,
  225. const struct v4l2_dbg_register *reg);
  226. int (*vidioc_g_chip_info) (struct file *file, void *fh,
  227. struct v4l2_dbg_chip_info *chip);
  228. #endif
  229. int (*vidioc_enum_framesizes) (struct file *file, void *fh,
  230. struct v4l2_frmsizeenum *fsize);
  231. int (*vidioc_enum_frameintervals) (struct file *file, void *fh,
  232. struct v4l2_frmivalenum *fival);
  233. /* DV Timings IOCTLs */
  234. int (*vidioc_s_dv_timings) (struct file *file, void *fh,
  235. struct v4l2_dv_timings *timings);
  236. int (*vidioc_g_dv_timings) (struct file *file, void *fh,
  237. struct v4l2_dv_timings *timings);
  238. int (*vidioc_query_dv_timings) (struct file *file, void *fh,
  239. struct v4l2_dv_timings *timings);
  240. int (*vidioc_enum_dv_timings) (struct file *file, void *fh,
  241. struct v4l2_enum_dv_timings *timings);
  242. int (*vidioc_dv_timings_cap) (struct file *file, void *fh,
  243. struct v4l2_dv_timings_cap *cap);
  244. int (*vidioc_g_edid) (struct file *file, void *fh, struct v4l2_edid *edid);
  245. int (*vidioc_s_edid) (struct file *file, void *fh, struct v4l2_edid *edid);
  246. int (*vidioc_subscribe_event) (struct v4l2_fh *fh,
  247. const struct v4l2_event_subscription *sub);
  248. int (*vidioc_unsubscribe_event)(struct v4l2_fh *fh,
  249. const struct v4l2_event_subscription *sub);
  250. /* For other private ioctls */
  251. long (*vidioc_default) (struct file *file, void *fh,
  252. bool valid_prio, unsigned int cmd, void *arg);
  253. };
  254. /* v4l debugging and diagnostics */
  255. /* Device debug flags to be used with the video device debug attribute */
  256. /* Just log the ioctl name + error code */
  257. #define V4L2_DEV_DEBUG_IOCTL 0x01
  258. /* Log the ioctl name arguments + error code */
  259. #define V4L2_DEV_DEBUG_IOCTL_ARG 0x02
  260. /* Log the file operations open, release, mmap and get_unmapped_area */
  261. #define V4L2_DEV_DEBUG_FOP 0x04
  262. /* Log the read and write file operations and the VIDIOC_(D)QBUF ioctls */
  263. #define V4L2_DEV_DEBUG_STREAMING 0x08
  264. /* Log poll() */
  265. #define V4L2_DEV_DEBUG_POLL 0x10
  266. /* Video standard functions */
  267. extern const char *v4l2_norm_to_name(v4l2_std_id id);
  268. extern void v4l2_video_std_frame_period(int id, struct v4l2_fract *frameperiod);
  269. extern int v4l2_video_std_construct(struct v4l2_standard *vs,
  270. int id, const char *name);
  271. /* Prints the ioctl in a human-readable format. If prefix != NULL,
  272. then do printk(KERN_DEBUG "%s: ", prefix) first. */
  273. extern void v4l_printk_ioctl(const char *prefix, unsigned int cmd);
  274. /* Internal use only: get the mutex (if any) that we need to lock for the
  275. given command. */
  276. struct video_device;
  277. extern struct mutex *v4l2_ioctl_get_lock(struct video_device *vdev, unsigned cmd);
  278. /* names for fancy debug output */
  279. extern const char *v4l2_field_names[];
  280. extern const char *v4l2_type_names[];
  281. #ifdef CONFIG_COMPAT
  282. /* 32 Bits compatibility layer for 64 bits processors */
  283. extern long v4l2_compat_ioctl32(struct file *file, unsigned int cmd,
  284. unsigned long arg);
  285. #endif
  286. typedef long (*v4l2_kioctl)(struct file *file,
  287. unsigned int cmd, void *arg);
  288. /* Include support for obsoleted stuff */
  289. extern long video_usercopy(struct file *file, unsigned int cmd,
  290. unsigned long arg, v4l2_kioctl func);
  291. /* Standard handlers for V4L ioctl's */
  292. extern long video_ioctl2(struct file *file,
  293. unsigned int cmd, unsigned long arg);
  294. #endif /* _V4L2_IOCTL_H */