1 /*****************************************************************************
2 * v4l2.h : Video4Linux2 input module for vlc
3 *****************************************************************************
4 * Copyright (C) 2002-2011 the VideoLAN team
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU Lesser General Public License as published by
8 * the Free Software Foundation; either version 2.1 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public License
17 * along with this program; if not, write to the Free Software Foundation,
18 * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
19 *****************************************************************************/
21 #if defined(HAVE_LINUX_VIDEODEV2_H)
22 # include <linux/videodev2.h>
23 #elif defined(HAVE_SYS_VIDEOIO_H)
24 # include <sys/videoio.h>
26 # error "No Video4Linux2 headers found."
29 /* Hacks to compile with old headers */
30 #ifndef V4L2_CTRL_FLAG_VOLATILE /* 3.2 */
31 # warning Please update Video4Linux2 headers!
32 # define V4L2_CTRL_FLAG_VOLATILE 0x0080
33 # define V4L2_CID_POWER_LINE_FREQUENCY_AUTO 3
34 # define V4L2_STD_G (V4L2_STD_PAL_G|V4L2_STD_SECAM_G)
35 # define V4L2_STD_H (V4L2_STD_PAL_H|V4L2_STD_SECAM_H)
36 # define V4L2_STD_L (V4L2_STD_SECAM_L|V4L2_STD_SECAM_LC)
37 # define V4L2_STD_BG (V4L2_STD_B|V4L2_STD_G)
38 # define V4L2_STD_MTS (V4L2_STD_NTSC_M|V4L2_STD_PAL_M|V4L2_STD_PAL_N|\
42 # include <linux/version.h>
43 # if LINUX_VERSION_CODE < KERNEL_VERSION(3,1,0)
44 # define V4L2_CTRL_TYPE_BITMASK 8
47 #ifndef V4L2_CID_ILLUMINATORS_1 /* 2.6.37 */
48 # define V4L2_CID_ILLUMINATORS_1 (V4L2_CID_BASE+38)
49 # define V4L2_CID_ILLUMINATORS_2 (V4L2_CID_BASE+37)
51 #ifndef V4L2_CID_CHROMA_GAIN /* 2.6.35 */
52 # define V4L2_CID_CHROMA_GAIN (V4L2_CID_BASE+36)
53 # define V4L2_COLORFX_VIVID 9
54 # define V4L2_COLORFX_SKIN_WHITEN 8
55 # define V4L2_COLORFX_GRASS_GREEN 7
56 # define V4L2_COLORFX_SKY_BLUE 6
57 # define V4L2_COLORFX_SKETCH 5
58 # define V4L2_COLORFX_EMBOSS 4
59 # define V4L2_COLORFX_NEGATIVE 3
61 #ifndef V4L2_CID_ROTATE /* 2.6.33 */
62 # define V4L2_CID_BG_COLOR (V4L2_CID_BASE+35)
63 # define V4L2_CID_ROTATE (V4L2_CID_BASE+34)
66 /* libv4l2 functions */
67 extern int v4l2_fd_open (int, int);
68 extern int (*v4l2_close) (int);
69 extern int (*v4l2_ioctl) (int, unsigned long int, ...);
70 extern ssize_t (*v4l2_read) (int, void *, size_t);
71 extern void * (*v4l2_mmap) (void *, size_t, int, int, int, int64_t);
72 extern int (*v4l2_munmap) (void *, size_t);
74 #define CFG_PREFIX "v4l2-"
76 /* TODO: remove this, use callbacks */
83 typedef struct vlc_v4l2_ctrl vlc_v4l2_ctrl_t;
85 /* TODO: move this to access.c and demux.c (separately) */
93 struct buffer_t *p_buffers;
94 unsigned int i_nbuffers;
95 #define blocksize i_nbuffers /* HACK HACK */
98 uint32_t i_block_flags;
102 vlc_v4l2_ctrl_t *controls;
112 void ParseMRL(vlc_object_t *, const char *);
113 block_t* GrabVideo(vlc_object_t *, demux_sys_t *);
114 int InitVideo(vlc_object_t *, int fd, demux_sys_t *, bool demux);
117 int DemuxOpen(vlc_object_t *);
118 void DemuxClose(vlc_object_t *);
119 float GetAbsoluteMaxFrameRate(vlc_object_t *, int fd, uint32_t fmt);
120 void GetMaxDimensions(vlc_object_t *, int fd, uint32_t fmt, float fps_min,
121 uint32_t *pwidth, uint32_t *pheight);
124 int AccessOpen(vlc_object_t *);
125 void AccessClose(vlc_object_t *);
128 vlc_v4l2_ctrl_t *ControlsInit(vlc_object_t *, int fd);
129 void ControlsDeinit(vlc_object_t *, vlc_v4l2_ctrl_t *);