]> git.sesse.net Git - vlc/blob - modules/access/v4l2/v4l2.h
v4l2: eliminate dead user pointer code
[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 #ifdef __linux__
42 # include <linux/version.h>
43 # if LINUX_VERSION_CODE < KERNEL_VERSION(3,1,0)
44 #  define V4L2_CTRL_TYPE_BITMASK 8
45 # endif
46 #endif
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)
50 #endif
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
60 #endif
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)
64 #endif
65
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);
73
74 #define CFG_PREFIX "v4l2-"
75
76 /* TODO: remove this, use callbacks */
77 typedef enum {
78     IO_METHOD_READ=1,
79     IO_METHOD_MMAP,
80     IO_METHOD_USERPTR,
81 } io_method;
82
83 typedef struct vlc_v4l2_ctrl vlc_v4l2_ctrl_t;
84
85 /* TODO: move this to access.c and demux.c (separately) */
86 struct demux_sys_t
87 {
88     int  i_fd;
89
90     /* Video */
91     io_method io;
92
93     struct buffer_t *p_buffers;
94     unsigned int i_nbuffers;
95 #define blocksize i_nbuffers /* HACK HACK */
96
97     int i_fourcc;
98     uint32_t i_block_flags;
99
100     es_out_id_t *p_es;
101
102     vlc_v4l2_ctrl_t *controls;
103 };
104
105 struct buffer_t
106 {
107     void *  start;
108     size_t  length;
109 };
110
111 /* video.c */
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);
115
116 /* demux.c */
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);
122
123 /* access.c */
124 int AccessOpen(vlc_object_t *);
125 void AccessClose(vlc_object_t *);
126
127 /* controls.c */
128 vlc_v4l2_ctrl_t *ControlsInit(vlc_object_t *, int fd);
129 void ControlsDeinit(vlc_object_t *, vlc_v4l2_ctrl_t *);