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. /* Priority handling */
  22. int (*vidioc_g_priority) (struct file *file, void *fh,
  23. enum v4l2_priority *p);
  24. int (*vidioc_s_priority) (struct file *file, void *fh,
  25. enum v4l2_priority p);
  26. /* VIDIOC_ENUM_FMT handlers */
  27. int (*vidioc_enum_fmt_vid_cap) (struct file *file, void *fh,
  28. struct v4l2_fmtdesc *f);
  29. int (*vidioc_enum_fmt_vid_overlay) (struct file *file, void *fh,
  30. struct v4l2_fmtdesc *f);
  31. int (*vidioc_enum_fmt_vid_out) (struct file *file, void *fh,
  32. struct v4l2_fmtdesc *f);
  33. int (*vidioc_enum_fmt_vid_cap_mplane)(struct file *file, void *fh,
  34. struct v4l2_fmtdesc *f);
  35. int (*vidioc_enum_fmt_vid_out_mplane)(struct file *file, void *fh,
  36. struct v4l2_fmtdesc *f);
  37. int (*vidioc_enum_fmt_type_private)(struct file *file, void *fh,
  38. struct v4l2_fmtdesc *f);
  39. /* VIDIOC_G_FMT handlers */
  40. int (*vidioc_g_fmt_vid_cap) (struct file *file, void *fh,
  41. struct v4l2_format *f);
  42. int (*vidioc_g_fmt_vid_overlay)(struct file *file, void *fh,
  43. struct v4l2_format *f);
  44. int (*vidioc_g_fmt_vid_out) (struct file *file, void *fh,
  45. struct v4l2_format *f);
  46. int (*vidioc_g_fmt_vid_out_overlay)(struct file *file, void *fh,
  47. struct v4l2_format *f);
  48. int (*vidioc_g_fmt_vbi_cap) (struct file *file, void *fh,
  49. struct v4l2_format *f);
  50. int (*vidioc_g_fmt_vbi_out) (struct file *file, void *fh,
  51. struct v4l2_format *f);
  52. int (*vidioc_g_fmt_sliced_vbi_cap)(struct file *file, void *fh,
  53. struct v4l2_format *f);
  54. int (*vidioc_g_fmt_sliced_vbi_out)(struct file *file, void *fh,
  55. struct v4l2_format *f);
  56. int (*vidioc_g_fmt_vid_cap_mplane)(struct file *file, void *fh,
  57. struct v4l2_format *f);
  58. int (*vidioc_g_fmt_vid_out_mplane)(struct file *file, void *fh,
  59. struct v4l2_format *f);
  60. int (*vidioc_g_fmt_type_private)(struct file *file, void *fh,
  61. struct v4l2_format *f);
  62. /* VIDIOC_S_FMT handlers */
  63. int (*vidioc_s_fmt_vid_cap) (struct file *file, void *fh,
  64. struct v4l2_format *f);
  65. int (*vidioc_s_fmt_vid_overlay)(struct file *file, void *fh,
  66. struct v4l2_format *f);
  67. int (*vidioc_s_fmt_vid_out) (struct file *file, void *fh,
  68. struct v4l2_format *f);
  69. int (*vidioc_s_fmt_vid_out_overlay)(struct file *file, void *fh,
  70. struct v4l2_format *f);
  71. int (*vidioc_s_fmt_vbi_cap) (struct file *file, void *fh,
  72. struct v4l2_format *f);
  73. int (*vidioc_s_fmt_vbi_out) (struct file *file, void *fh,
  74. struct v4l2_format *f);
  75. int (*vidioc_s_fmt_sliced_vbi_cap)(struct file *file, void *fh,
  76. struct v4l2_format *f);
  77. int (*vidioc_s_fmt_sliced_vbi_out)(struct file *file, void *fh,
  78. struct v4l2_format *f);
  79. int (*vidioc_s_fmt_vid_cap_mplane)(struct file *file, void *fh,
  80. struct v4l2_format *f);
  81. int (*vidioc_s_fmt_vid_out_mplane)(struct file *file, void *fh,
  82. struct v4l2_format *f);
  83. int (*vidioc_s_fmt_type_private)(struct file *file, void *fh,
  84. struct v4l2_format *f);
  85. /* VIDIOC_TRY_FMT handlers */
  86. int (*vidioc_try_fmt_vid_cap) (struct file *file, void *fh,
  87. struct v4l2_format *f);
  88. int (*vidioc_try_fmt_vid_overlay)(struct file *file, void *fh,
  89. struct v4l2_format *f);
  90. int (*vidioc_try_fmt_vid_out) (struct file *file, void *fh,
  91. struct v4l2_format *f);
  92. int (*vidioc_try_fmt_vid_out_overlay)(struct file *file, void *fh,
  93. struct v4l2_format *f);
  94. int (*vidioc_try_fmt_vbi_cap) (struct file *file, void *fh,
  95. struct v4l2_format *f);
  96. int (*vidioc_try_fmt_vbi_out) (struct file *file, void *fh,
  97. struct v4l2_format *f);
  98. int (*vidioc_try_fmt_sliced_vbi_cap)(struct file *file, void *fh,
  99. struct v4l2_format *f);
  100. int (*vidioc_try_fmt_sliced_vbi_out)(struct file *file, void *fh,
  101. struct v4l2_format *f);
  102. int (*vidioc_try_fmt_vid_cap_mplane)(struct file *file, void *fh,
  103. struct v4l2_format *f);
  104. int (*vidioc_try_fmt_vid_out_mplane)(struct file *file, void *fh,
  105. struct v4l2_format *f);
  106. int (*vidioc_try_fmt_type_private)(struct file *file, void *fh,
  107. struct v4l2_format *f);
  108. /* Buffer handlers */
  109. int (*vidioc_reqbufs) (struct file *file, void *fh, struct v4l2_requestbuffers *b);
  110. int (*vidioc_querybuf)(struct file *file, void *fh, struct v4l2_buffer *b);
  111. int (*vidioc_qbuf) (struct file *file, void *fh, struct v4l2_buffer *b);
  112. int (*vidioc_dqbuf) (struct file *file, void *fh, struct v4l2_buffer *b);
  113. int (*vidioc_create_bufs)(struct file *file, void *fh, struct v4l2_create_buffers *b);
  114. int (*vidioc_prepare_buf)(struct file *file, void *fh, struct v4l2_buffer *b);
  115. int (*vidioc_overlay) (struct file *file, void *fh, unsigned int i);
  116. int (*vidioc_g_fbuf) (struct file *file, void *fh,
  117. struct v4l2_framebuffer *a);
  118. int (*vidioc_s_fbuf) (struct file *file, void *fh,
  119. struct v4l2_framebuffer *a);
  120. /* Stream on/off */
  121. int (*vidioc_streamon) (struct file *file, void *fh, enum v4l2_buf_type i);
  122. int (*vidioc_streamoff)(struct file *file, void *fh, enum v4l2_buf_type i);
  123. /* Standard handling
  124. ENUMSTD is handled by videodev.c
  125. */
  126. int (*vidioc_g_std) (struct file *file, void *fh, v4l2_std_id *norm);
  127. int (*vidioc_s_std) (struct file *file, void *fh, v4l2_std_id *norm);
  128. int (*vidioc_querystd) (struct file *file, void *fh, v4l2_std_id *a);
  129. /* Input handling */
  130. int (*vidioc_enum_input)(struct file *file, void *fh,
  131. struct v4l2_input *inp);
  132. int (*vidioc_g_input) (struct file *file, void *fh, unsigned int *i);
  133. int (*vidioc_s_input) (struct file *file, void *fh, unsigned int i);
  134. /* Output handling */
  135. int (*vidioc_enum_output) (struct file *file, void *fh,
  136. struct v4l2_output *a);
  137. int (*vidioc_g_output) (struct file *file, void *fh, unsigned int *i);
  138. int (*vidioc_s_output) (struct file *file, void *fh, unsigned int i);
  139. /* Control handling */
  140. int (*vidioc_queryctrl) (struct file *file, void *fh,
  141. struct v4l2_queryctrl *a);
  142. int (*vidioc_g_ctrl) (struct file *file, void *fh,
  143. struct v4l2_control *a);
  144. int (*vidioc_s_ctrl) (struct file *file, void *fh,
  145. struct v4l2_control *a);
  146. int (*vidioc_g_ext_ctrls) (struct file *file, void *fh,
  147. struct v4l2_ext_controls *a);
  148. int (*vidioc_s_ext_ctrls) (struct file *file, void *fh,
  149. struct v4l2_ext_controls *a);
  150. int (*vidioc_try_ext_ctrls) (struct file *file, void *fh,
  151. struct v4l2_ext_controls *a);
  152. int (*vidioc_querymenu) (struct file *file, void *fh,
  153. struct v4l2_querymenu *a);
  154. /* Audio ioctls */
  155. int (*vidioc_enumaudio) (struct file *file, void *fh,
  156. struct v4l2_audio *a);
  157. int (*vidioc_g_audio) (struct file *file, void *fh,
  158. struct v4l2_audio *a);
  159. int (*vidioc_s_audio) (struct file *file, void *fh,
  160. struct v4l2_audio *a);
  161. /* Audio out ioctls */
  162. int (*vidioc_enumaudout) (struct file *file, void *fh,
  163. struct v4l2_audioout *a);
  164. int (*vidioc_g_audout) (struct file *file, void *fh,
  165. struct v4l2_audioout *a);
  166. int (*vidioc_s_audout) (struct file *file, void *fh,
  167. struct v4l2_audioout *a);
  168. int (*vidioc_g_modulator) (struct file *file, void *fh,
  169. struct v4l2_modulator *a);
  170. int (*vidioc_s_modulator) (struct file *file, void *fh,
  171. struct v4l2_modulator *a);
  172. /* Crop ioctls */
  173. int (*vidioc_cropcap) (struct file *file, void *fh,
  174. struct v4l2_cropcap *a);
  175. int (*vidioc_g_crop) (struct file *file, void *fh,
  176. struct v4l2_crop *a);
  177. int (*vidioc_s_crop) (struct file *file, void *fh,
  178. struct v4l2_crop *a);
  179. int (*vidioc_g_selection) (struct file *file, void *fh,
  180. struct v4l2_selection *s);
  181. int (*vidioc_s_selection) (struct file *file, void *fh,
  182. struct v4l2_selection *s);
  183. /* Compression ioctls */
  184. int (*vidioc_g_jpegcomp) (struct file *file, void *fh,
  185. struct v4l2_jpegcompression *a);
  186. int (*vidioc_s_jpegcomp) (struct file *file, void *fh,
  187. struct v4l2_jpegcompression *a);
  188. int (*vidioc_g_enc_index) (struct file *file, void *fh,
  189. struct v4l2_enc_idx *a);
  190. int (*vidioc_encoder_cmd) (struct file *file, void *fh,
  191. struct v4l2_encoder_cmd *a);
  192. int (*vidioc_try_encoder_cmd) (struct file *file, void *fh,
  193. struct v4l2_encoder_cmd *a);
  194. int (*vidioc_decoder_cmd) (struct file *file, void *fh,
  195. struct v4l2_decoder_cmd *a);
  196. int (*vidioc_try_decoder_cmd) (struct file *file, void *fh,
  197. struct v4l2_decoder_cmd *a);
  198. /* Stream type-dependent parameter ioctls */
  199. int (*vidioc_g_parm) (struct file *file, void *fh,
  200. struct v4l2_streamparm *a);
  201. int (*vidioc_s_parm) (struct file *file, void *fh,
  202. struct v4l2_streamparm *a);
  203. /* Tuner ioctls */
  204. int (*vidioc_g_tuner) (struct file *file, void *fh,
  205. struct v4l2_tuner *a);
  206. int (*vidioc_s_tuner) (struct file *file, void *fh,
  207. struct v4l2_tuner *a);
  208. int (*vidioc_g_frequency) (struct file *file, void *fh,
  209. struct v4l2_frequency *a);
  210. int (*vidioc_s_frequency) (struct file *file, void *fh,
  211. struct v4l2_frequency *a);
  212. /* Sliced VBI cap */
  213. int (*vidioc_g_sliced_vbi_cap) (struct file *file, void *fh,
  214. struct v4l2_sliced_vbi_cap *a);
  215. /* Log status ioctl */
  216. int (*vidioc_log_status) (struct file *file, void *fh);
  217. int (*vidioc_s_hw_freq_seek) (struct file *file, void *fh,
  218. struct v4l2_hw_freq_seek *a);
  219. /* Debugging ioctls */
  220. #ifdef CONFIG_VIDEO_ADV_DEBUG
  221. int (*vidioc_g_register) (struct file *file, void *fh,
  222. struct v4l2_dbg_register *reg);
  223. int (*vidioc_s_register) (struct file *file, void *fh,
  224. struct v4l2_dbg_register *reg);
  225. #endif
  226. int (*vidioc_g_chip_ident) (struct file *file, void *fh,
  227. struct v4l2_dbg_chip_ident *chip);
  228. int (*vidioc_enum_framesizes) (struct file *file, void *fh,
  229. struct v4l2_frmsizeenum *fsize);
  230. int (*vidioc_enum_frameintervals) (struct file *file, void *fh,
  231. struct v4l2_frmivalenum *fival);
  232. /* DV Timings IOCTLs */
  233. int (*vidioc_enum_dv_presets) (struct file *file, void *fh,
  234. struct v4l2_dv_enum_preset *preset);
  235. int (*vidioc_s_dv_preset) (struct file *file, void *fh,
  236. struct v4l2_dv_preset *preset);
  237. int (*vidioc_g_dv_preset) (struct file *file, void *fh,
  238. struct v4l2_dv_preset *preset);
  239. int (*vidioc_query_dv_preset) (struct file *file, void *fh,
  240. struct v4l2_dv_preset *qpreset);
  241. int (*vidioc_s_dv_timings) (struct file *file, void *fh,
  242. struct v4l2_dv_timings *timings);
  243. int (*vidioc_g_dv_timings) (struct file *file, void *fh,
  244. struct v4l2_dv_timings *timings);
  245. int (*vidioc_subscribe_event) (struct v4l2_fh *fh,
  246. struct v4l2_event_subscription *sub);
  247. int (*vidioc_unsubscribe_event)(struct v4l2_fh *fh,
  248. struct v4l2_event_subscription *sub);
  249. /* For other private ioctls */
  250. long (*vidioc_default) (struct file *file, void *fh,
  251. bool valid_prio, int cmd, void *arg);
  252. };
  253. /* v4l debugging and diagnostics */
  254. /* Debug bitmask flags to be used on V4L2 */
  255. #define V4L2_DEBUG_IOCTL 0x01
  256. #define V4L2_DEBUG_IOCTL_ARG 0x02
  257. /* Use this macro for non-I2C drivers. Pass the driver name as the first arg. */
  258. #define v4l_print_ioctl(name, cmd) \
  259. do { \
  260. printk(KERN_DEBUG "%s: ", name); \
  261. v4l_printk_ioctl(cmd); \
  262. } while (0)
  263. /* Use this macro in I2C drivers where 'client' is the struct i2c_client
  264. pointer */
  265. #define v4l_i2c_print_ioctl(client, cmd) \
  266. do { \
  267. v4l_client_printk(KERN_DEBUG, client, ""); \
  268. v4l_printk_ioctl(cmd); \
  269. } while (0)
  270. /* Video standard functions */
  271. extern const char *v4l2_norm_to_name(v4l2_std_id id);
  272. extern void v4l2_video_std_frame_period(int id, struct v4l2_fract *frameperiod);
  273. extern int v4l2_video_std_construct(struct v4l2_standard *vs,
  274. int id, const char *name);
  275. /* Prints the ioctl in a human-readable format */
  276. extern void v4l_printk_ioctl(unsigned int cmd);
  277. /* names for fancy debug output */
  278. extern const char *v4l2_field_names[];
  279. extern const char *v4l2_type_names[];
  280. #ifdef CONFIG_COMPAT
  281. /* 32 Bits compatibility layer for 64 bits processors */
  282. extern long v4l2_compat_ioctl32(struct file *file, unsigned int cmd,
  283. unsigned long arg);
  284. #endif
  285. typedef long (*v4l2_kioctl)(struct file *file,
  286. unsigned int cmd, void *arg);
  287. /* Include support for obsoleted stuff */
  288. extern long video_usercopy(struct file *file, unsigned int cmd,
  289. unsigned long arg, v4l2_kioctl func);
  290. /* Standard handlers for V4L ioctl's */
  291. extern long video_ioctl2(struct file *file,
  292. unsigned int cmd, unsigned long arg);
  293. #endif /* _V4L2_IOCTL_H */