v4l2-ioctl.h 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308
  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/device.h>
  14. #include <linux/mutex.h>
  15. #include <linux/compiler.h> /* need __user */
  16. #ifdef CONFIG_VIDEO_V4L1_COMPAT
  17. #include <linux/videodev.h>
  18. #else
  19. #include <linux/videodev2.h>
  20. #endif
  21. struct v4l2_ioctl_ops {
  22. /* ioctl callbacks */
  23. /* VIDIOC_QUERYCAP handler */
  24. int (*vidioc_querycap)(struct file *file, void *fh, struct v4l2_capability *cap);
  25. /* Priority handling */
  26. int (*vidioc_g_priority) (struct file *file, void *fh,
  27. enum v4l2_priority *p);
  28. int (*vidioc_s_priority) (struct file *file, void *fh,
  29. enum v4l2_priority p);
  30. /* VIDIOC_ENUM_FMT handlers */
  31. int (*vidioc_enum_fmt_vid_cap) (struct file *file, void *fh,
  32. struct v4l2_fmtdesc *f);
  33. int (*vidioc_enum_fmt_vid_overlay) (struct file *file, void *fh,
  34. struct v4l2_fmtdesc *f);
  35. int (*vidioc_enum_fmt_vid_out) (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_type_private)(struct file *file, void *fh,
  57. struct v4l2_format *f);
  58. /* VIDIOC_S_FMT handlers */
  59. int (*vidioc_s_fmt_vid_cap) (struct file *file, void *fh,
  60. struct v4l2_format *f);
  61. int (*vidioc_s_fmt_vid_overlay)(struct file *file, void *fh,
  62. struct v4l2_format *f);
  63. int (*vidioc_s_fmt_vid_out) (struct file *file, void *fh,
  64. struct v4l2_format *f);
  65. int (*vidioc_s_fmt_vid_out_overlay)(struct file *file, void *fh,
  66. struct v4l2_format *f);
  67. int (*vidioc_s_fmt_vbi_cap) (struct file *file, void *fh,
  68. struct v4l2_format *f);
  69. int (*vidioc_s_fmt_vbi_out) (struct file *file, void *fh,
  70. struct v4l2_format *f);
  71. int (*vidioc_s_fmt_sliced_vbi_cap)(struct file *file, void *fh,
  72. struct v4l2_format *f);
  73. int (*vidioc_s_fmt_sliced_vbi_out)(struct file *file, void *fh,
  74. struct v4l2_format *f);
  75. int (*vidioc_s_fmt_type_private)(struct file *file, void *fh,
  76. struct v4l2_format *f);
  77. /* VIDIOC_TRY_FMT handlers */
  78. int (*vidioc_try_fmt_vid_cap) (struct file *file, void *fh,
  79. struct v4l2_format *f);
  80. int (*vidioc_try_fmt_vid_overlay)(struct file *file, void *fh,
  81. struct v4l2_format *f);
  82. int (*vidioc_try_fmt_vid_out) (struct file *file, void *fh,
  83. struct v4l2_format *f);
  84. int (*vidioc_try_fmt_vid_out_overlay)(struct file *file, void *fh,
  85. struct v4l2_format *f);
  86. int (*vidioc_try_fmt_vbi_cap) (struct file *file, void *fh,
  87. struct v4l2_format *f);
  88. int (*vidioc_try_fmt_vbi_out) (struct file *file, void *fh,
  89. struct v4l2_format *f);
  90. int (*vidioc_try_fmt_sliced_vbi_cap)(struct file *file, void *fh,
  91. struct v4l2_format *f);
  92. int (*vidioc_try_fmt_sliced_vbi_out)(struct file *file, void *fh,
  93. struct v4l2_format *f);
  94. int (*vidioc_try_fmt_type_private)(struct file *file, void *fh,
  95. struct v4l2_format *f);
  96. /* Buffer handlers */
  97. int (*vidioc_reqbufs) (struct file *file, void *fh, struct v4l2_requestbuffers *b);
  98. int (*vidioc_querybuf)(struct file *file, void *fh, struct v4l2_buffer *b);
  99. int (*vidioc_qbuf) (struct file *file, void *fh, struct v4l2_buffer *b);
  100. int (*vidioc_dqbuf) (struct file *file, void *fh, struct v4l2_buffer *b);
  101. int (*vidioc_overlay) (struct file *file, void *fh, unsigned int i);
  102. #ifdef CONFIG_VIDEO_V4L1_COMPAT
  103. /* buffer type is struct vidio_mbuf * */
  104. int (*vidiocgmbuf) (struct file *file, void *fh, struct video_mbuf *p);
  105. #endif
  106. int (*vidioc_g_fbuf) (struct file *file, void *fh,
  107. struct v4l2_framebuffer *a);
  108. int (*vidioc_s_fbuf) (struct file *file, void *fh,
  109. struct v4l2_framebuffer *a);
  110. /* Stream on/off */
  111. int (*vidioc_streamon) (struct file *file, void *fh, enum v4l2_buf_type i);
  112. int (*vidioc_streamoff)(struct file *file, void *fh, enum v4l2_buf_type i);
  113. /* Standard handling
  114. ENUMSTD is handled by videodev.c
  115. */
  116. int (*vidioc_g_std) (struct file *file, void *fh, v4l2_std_id *norm);
  117. int (*vidioc_s_std) (struct file *file, void *fh, v4l2_std_id *norm);
  118. int (*vidioc_querystd) (struct file *file, void *fh, v4l2_std_id *a);
  119. /* Input handling */
  120. int (*vidioc_enum_input)(struct file *file, void *fh,
  121. struct v4l2_input *inp);
  122. int (*vidioc_g_input) (struct file *file, void *fh, unsigned int *i);
  123. int (*vidioc_s_input) (struct file *file, void *fh, unsigned int i);
  124. /* Output handling */
  125. int (*vidioc_enum_output) (struct file *file, void *fh,
  126. struct v4l2_output *a);
  127. int (*vidioc_g_output) (struct file *file, void *fh, unsigned int *i);
  128. int (*vidioc_s_output) (struct file *file, void *fh, unsigned int i);
  129. /* Control handling */
  130. int (*vidioc_queryctrl) (struct file *file, void *fh,
  131. struct v4l2_queryctrl *a);
  132. int (*vidioc_g_ctrl) (struct file *file, void *fh,
  133. struct v4l2_control *a);
  134. int (*vidioc_s_ctrl) (struct file *file, void *fh,
  135. struct v4l2_control *a);
  136. int (*vidioc_g_ext_ctrls) (struct file *file, void *fh,
  137. struct v4l2_ext_controls *a);
  138. int (*vidioc_s_ext_ctrls) (struct file *file, void *fh,
  139. struct v4l2_ext_controls *a);
  140. int (*vidioc_try_ext_ctrls) (struct file *file, void *fh,
  141. struct v4l2_ext_controls *a);
  142. int (*vidioc_querymenu) (struct file *file, void *fh,
  143. struct v4l2_querymenu *a);
  144. /* Audio ioctls */
  145. int (*vidioc_enumaudio) (struct file *file, void *fh,
  146. struct v4l2_audio *a);
  147. int (*vidioc_g_audio) (struct file *file, void *fh,
  148. struct v4l2_audio *a);
  149. int (*vidioc_s_audio) (struct file *file, void *fh,
  150. struct v4l2_audio *a);
  151. /* Audio out ioctls */
  152. int (*vidioc_enumaudout) (struct file *file, void *fh,
  153. struct v4l2_audioout *a);
  154. int (*vidioc_g_audout) (struct file *file, void *fh,
  155. struct v4l2_audioout *a);
  156. int (*vidioc_s_audout) (struct file *file, void *fh,
  157. struct v4l2_audioout *a);
  158. int (*vidioc_g_modulator) (struct file *file, void *fh,
  159. struct v4l2_modulator *a);
  160. int (*vidioc_s_modulator) (struct file *file, void *fh,
  161. struct v4l2_modulator *a);
  162. /* Crop ioctls */
  163. int (*vidioc_cropcap) (struct file *file, void *fh,
  164. struct v4l2_cropcap *a);
  165. int (*vidioc_g_crop) (struct file *file, void *fh,
  166. struct v4l2_crop *a);
  167. int (*vidioc_s_crop) (struct file *file, void *fh,
  168. struct v4l2_crop *a);
  169. /* Compression ioctls */
  170. int (*vidioc_g_jpegcomp) (struct file *file, void *fh,
  171. struct v4l2_jpegcompression *a);
  172. int (*vidioc_s_jpegcomp) (struct file *file, void *fh,
  173. struct v4l2_jpegcompression *a);
  174. int (*vidioc_g_enc_index) (struct file *file, void *fh,
  175. struct v4l2_enc_idx *a);
  176. int (*vidioc_encoder_cmd) (struct file *file, void *fh,
  177. struct v4l2_encoder_cmd *a);
  178. int (*vidioc_try_encoder_cmd) (struct file *file, void *fh,
  179. struct v4l2_encoder_cmd *a);
  180. /* Stream type-dependent parameter ioctls */
  181. int (*vidioc_g_parm) (struct file *file, void *fh,
  182. struct v4l2_streamparm *a);
  183. int (*vidioc_s_parm) (struct file *file, void *fh,
  184. struct v4l2_streamparm *a);
  185. /* Tuner ioctls */
  186. int (*vidioc_g_tuner) (struct file *file, void *fh,
  187. struct v4l2_tuner *a);
  188. int (*vidioc_s_tuner) (struct file *file, void *fh,
  189. struct v4l2_tuner *a);
  190. int (*vidioc_g_frequency) (struct file *file, void *fh,
  191. struct v4l2_frequency *a);
  192. int (*vidioc_s_frequency) (struct file *file, void *fh,
  193. struct v4l2_frequency *a);
  194. /* Sliced VBI cap */
  195. int (*vidioc_g_sliced_vbi_cap) (struct file *file, void *fh,
  196. struct v4l2_sliced_vbi_cap *a);
  197. /* Log status ioctl */
  198. int (*vidioc_log_status) (struct file *file, void *fh);
  199. int (*vidioc_s_hw_freq_seek) (struct file *file, void *fh,
  200. struct v4l2_hw_freq_seek *a);
  201. /* Debugging ioctls */
  202. #ifdef CONFIG_VIDEO_ADV_DEBUG
  203. int (*vidioc_g_register) (struct file *file, void *fh,
  204. struct v4l2_register *reg);
  205. int (*vidioc_s_register) (struct file *file, void *fh,
  206. struct v4l2_register *reg);
  207. #endif
  208. int (*vidioc_g_chip_ident) (struct file *file, void *fh,
  209. struct v4l2_chip_ident *chip);
  210. /* For other private ioctls */
  211. int (*vidioc_default) (struct file *file, void *fh,
  212. int cmd, void *arg);
  213. };
  214. /* v4l debugging and diagnostics */
  215. /* Debug bitmask flags to be used on V4L2 */
  216. #define V4L2_DEBUG_IOCTL 0x01
  217. #define V4L2_DEBUG_IOCTL_ARG 0x02
  218. /* Use this macro for non-I2C drivers. Pass the driver name as the first arg. */
  219. #define v4l_print_ioctl(name, cmd) \
  220. do { \
  221. printk(KERN_DEBUG "%s: ", name); \
  222. v4l_printk_ioctl(cmd); \
  223. } while (0)
  224. /* Use this macro in I2C drivers where 'client' is the struct i2c_client
  225. pointer */
  226. #define v4l_i2c_print_ioctl(client, cmd) \
  227. do { \
  228. v4l_client_printk(KERN_DEBUG, client, ""); \
  229. v4l_printk_ioctl(cmd); \
  230. } while (0)
  231. /* Video standard functions */
  232. extern const char *v4l2_norm_to_name(v4l2_std_id id);
  233. extern int v4l2_video_std_construct(struct v4l2_standard *vs,
  234. int id, const char *name);
  235. /* Prints the ioctl in a human-readable format */
  236. extern void v4l_printk_ioctl(unsigned int cmd);
  237. /* names for fancy debug output */
  238. extern const char *v4l2_field_names[];
  239. extern const char *v4l2_type_names[];
  240. /* Compatibility layer interface -- v4l1-compat module */
  241. typedef int (*v4l2_kioctl)(struct file *file,
  242. unsigned int cmd, void *arg);
  243. #ifdef CONFIG_VIDEO_V4L1_COMPAT
  244. int v4l_compat_translate_ioctl(struct file *file,
  245. int cmd, void *arg, v4l2_kioctl driver_ioctl);
  246. #else
  247. #define v4l_compat_translate_ioctl(file, cmd, arg, ioctl) (-EINVAL)
  248. #endif
  249. /* 32 Bits compatibility layer for 64 bits processors */
  250. extern long v4l_compat_ioctl32(struct file *file, unsigned int cmd,
  251. unsigned long arg);
  252. /* Include support for obsoleted stuff */
  253. extern int video_usercopy(struct inode *inode, struct file *file,
  254. unsigned int cmd, unsigned long arg,
  255. int (*func)(struct inode *inode, struct file *file,
  256. unsigned int cmd, void *arg));
  257. /* Standard handlers for V4L ioctl's */
  258. /* This prototype is used on fops.unlocked_ioctl */
  259. extern int __video_ioctl2(struct file *file,
  260. unsigned int cmd, unsigned long arg);
  261. /* This prototype is used on fops.ioctl
  262. * Since fops.ioctl enables Kernel Big Lock, it is preferred
  263. * to use __video_ioctl2 instead.
  264. * It should be noticed that there's no lock code inside
  265. * video_ioctl2().
  266. */
  267. extern int video_ioctl2(struct inode *inode, struct file *file,
  268. unsigned int cmd, unsigned long arg);
  269. #endif /* _V4L2_IOCTL_H */