]> git.sesse.net Git - vlc/blob - modules/access/v4l2/v4l2.h
v4l2: fix warning on old systems
[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
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|\
39                        V4L2_STD_PAL_Nc)
40 #endif
41 #ifndef V4L2_CID_ILLUMINATORS_1 /* 2.6.37 */
42 # define V4L2_CID_ILLUMINATORS_1 (V4L2_CID_BASE+38)
43 # define V4L2_CID_ILLUMINATORS_2 (V4L2_CID_BASE+37)
44 #endif
45 #ifndef V4L2_CID_CHROMA_GAIN /* 2.6.35 */
46 # define V4L2_CID_CHROMA_GAIN (V4L2_CID_BASE+36)
47 # define V4L2_COLORFX_VIVID 9
48 # define V4L2_COLORFX_SKIN_WHITEN 8
49 # define V4L2_COLORFX_GRASS_GREEN 7
50 # define V4L2_COLORFX_SKY_BLUE 6
51 # define V4L2_COLORFX_SKETCH 5
52 # define V4L2_COLORFX_EMBOSS 4
53 # define V4L2_COLORFX_NEGATIVE 3
54 #endif
55 #ifndef V4L2_CID_ROTATE /* 2.6.33 */
56 # define V4L2_CID_BG_COLOR (V4L2_CID_BASE+35)
57 # define V4L2_CID_ROTATE (V4L2_CID_BASE+34)
58 #endif
59
60 /* libv4l2 functions */
61 extern int v4l2_fd_open (int, int);
62 extern int (*v4l2_close) (int);
63 extern int (*v4l2_ioctl) (int, unsigned long int, ...);
64 extern ssize_t (*v4l2_read) (int, void *, size_t);
65 extern void * (*v4l2_mmap) (void *, size_t, int, int, int, int64_t);
66 extern int (*v4l2_munmap) (void *, size_t);
67
68 #define CFG_PREFIX "v4l2-"
69
70 /* TODO: remove this, use callbacks */
71 typedef enum {
72     IO_METHOD_READ=1,
73     IO_METHOD_MMAP,
74 } io_method;
75
76 typedef struct vlc_v4l2_ctrl vlc_v4l2_ctrl_t;
77
78 /* TODO: move this to access.c and demux.c (separately) */
79 struct demux_sys_t
80 {
81     int  i_fd;
82
83     /* Video */
84     io_method io;
85
86     struct buffer_t *p_buffers;
87     unsigned int i_nbuffers;
88 #define blocksize i_nbuffers /* HACK HACK */
89
90     uint32_t i_block_flags;
91
92     es_out_id_t *p_es;
93
94     vlc_v4l2_ctrl_t *controls;
95 };
96
97 struct buffer_t
98 {
99     void *  start;
100     size_t  length;
101 };
102
103 /* video.c */
104 void ParseMRL(vlc_object_t *, const char *);
105 int SetupInput (vlc_object_t *, int fd);
106 int SetupFormat (vlc_object_t *, int, uint32_t,
107                  struct v4l2_format *, struct v4l2_streamparm *);
108 #define SetupFormat(o,fd,fcc,fmt,p) \
109         SetupFormat(VLC_OBJECT(o),fd,fcc,fmt,p)
110
111 int InitMmap (vlc_object_t *, demux_sys_t *, int);
112 block_t* GrabVideo(vlc_object_t *, demux_sys_t *);
113
114 /* demux.c */
115 int DemuxOpen(vlc_object_t *);
116 void DemuxClose(vlc_object_t *);
117 float GetAbsoluteMaxFrameRate(vlc_object_t *, int fd, uint32_t fmt);
118 void GetMaxDimensions(vlc_object_t *, int fd, uint32_t fmt, float fps_min,
119                       uint32_t *pwidth, uint32_t *pheight);
120
121 /* access.c */
122 int AccessOpen(vlc_object_t *);
123 void AccessClose(vlc_object_t *);
124
125 /* controls.c */
126 vlc_v4l2_ctrl_t *ControlsInit(vlc_object_t *, int fd);
127 void ControlsDeinit(vlc_object_t *, vlc_v4l2_ctrl_t *);