]> git.sesse.net Git - vlc/blob - modules/access/v4l2/v4l2.h
v4l2: factorize and simplify mmap() initialization
[vlc] / modules / access / v4l2 / v4l2.h
1 /*****************************************************************************
2  * v4l2.h : Video4Linux2 input module for vlc
3  *****************************************************************************
4  * Copyright (C) 2002-2011 the VideoLAN team
5  *
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.
10  *
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.
15  *
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  *****************************************************************************/
20
21 #if defined (HAVE_LINUX_VIDEODEV2_H)
22 # include <linux/videodev2.h>
23 #elif defined (HAVE_SYS_VIDEOIO_H)
24 # include <sys/videoio.h>
25 #else
26 # error "No Video4Linux2 headers found."
27 #endif
28 #ifndef V4L2_CAP_DEVICE_CAPS
29 # warning Please update Video4Linux2 headers!
30 #endif
31
32 /* Hacks to compile with old headers */
33 #ifndef V4L2_CTRL_FLAG_VOLATILE /* 3.2 */
34 # define V4L2_CTRL_FLAG_VOLATILE 0x0080
35 # define V4L2_CID_POWER_LINE_FREQUENCY_AUTO 3
36 # define V4L2_STD_G (V4L2_STD_PAL_G|V4L2_STD_SECAM_G)
37 # define V4L2_STD_H (V4L2_STD_PAL_H|V4L2_STD_SECAM_H)
38 # define V4L2_STD_L (V4L2_STD_SECAM_L|V4L2_STD_SECAM_LC)
39 # define V4L2_STD_BG (V4L2_STD_B|V4L2_STD_G)
40 # define V4L2_STD_MTS (V4L2_STD_NTSC_M|V4L2_STD_PAL_M|V4L2_STD_PAL_N|\
41                        V4L2_STD_PAL_Nc)
42 #endif
43 #ifndef V4L2_CID_ILLUMINATORS_1 /* 2.6.37 */
44 # define V4L2_CID_ILLUMINATORS_1 (V4L2_CID_BASE+38)
45 # define V4L2_CID_ILLUMINATORS_2 (V4L2_CID_BASE+37)
46 #endif
47 #ifndef V4L2_CID_CHROMA_GAIN /* 2.6.35 */
48 # define V4L2_CID_CHROMA_GAIN (V4L2_CID_BASE+36)
49 # define V4L2_COLORFX_VIVID 9
50 # define V4L2_COLORFX_SKIN_WHITEN 8
51 # define V4L2_COLORFX_GRASS_GREEN 7
52 # define V4L2_COLORFX_SKY_BLUE 6
53 # define V4L2_COLORFX_SKETCH 5
54 # define V4L2_COLORFX_EMBOSS 4
55 # define V4L2_COLORFX_NEGATIVE 3
56 #endif
57 #ifndef V4L2_CID_ROTATE /* 2.6.33 */
58 # define V4L2_CID_BG_COLOR (V4L2_CID_BASE+35)
59 # define V4L2_CID_ROTATE (V4L2_CID_BASE+34)
60 #endif
61
62 /* libv4l2 functions */
63 extern int v4l2_fd_open (int, int);
64 extern int (*v4l2_close) (int);
65 extern int (*v4l2_ioctl) (int, unsigned long int, ...);
66 extern ssize_t (*v4l2_read) (int, void *, size_t);
67 extern void * (*v4l2_mmap) (void *, size_t, int, int, int, int64_t);
68 extern int (*v4l2_munmap) (void *, size_t);
69
70 #define CFG_PREFIX "v4l2-"
71
72 typedef struct vlc_v4l2_ctrl vlc_v4l2_ctrl_t;
73
74 struct buffer_t
75 {
76     void *  start;
77     size_t  length;
78 };
79
80 /* v4l2.c */
81 void ParseMRL(vlc_object_t *, const char *);
82 v4l2_std_id var_InheritStandard (vlc_object_t *, const char *);
83
84 /* video.c */
85 int SetupInput (vlc_object_t *, int fd);
86 int SetupFormat (vlc_object_t *, int, uint32_t,
87                  struct v4l2_format *, struct v4l2_streamparm *);
88 #define SetupFormat(o,fd,fcc,fmt,p) \
89         SetupFormat(VLC_OBJECT(o),fd,fcc,fmt,p)
90
91 struct buffer_t *StartMmap (vlc_object_t *, int, uint32_t *);
92 void StopMmap (int, struct buffer_t *, uint32_t);
93
94 block_t* GrabVideo (vlc_object_t *, int, const struct buffer_t *);
95
96 /* demux.c */
97 int DemuxOpen(vlc_object_t *);
98 void DemuxClose(vlc_object_t *);
99 float GetAbsoluteMaxFrameRate(vlc_object_t *, int fd, uint32_t fmt);
100 void GetMaxDimensions(vlc_object_t *, int fd, uint32_t fmt, float fps_min,
101                       uint32_t *pwidth, uint32_t *pheight);
102
103 /* access.c */
104 int AccessOpen(vlc_object_t *);
105 void AccessClose(vlc_object_t *);
106
107 /* controls.c */
108 vlc_v4l2_ctrl_t *ControlsInit(vlc_object_t *, int fd);
109 void ControlsDeinit(vlc_object_t *, vlc_v4l2_ctrl_t *);