v4l2: Remove last include to linux/videodev2.h
[platform/upstream/gst-plugins-good.git] / sys / v4l2 / v4l2_calls.h
1 /* GStreamer
2  *
3  * Copyright (C) 2002 Ronald Bultje <rbultje@ronald.bitfreak.net>
4  *               2006 Edgard Lima <edgard.lima@indt.org.br>
5  *
6  * v4l2_calls.h - generic V4L2 calls handling
7  *
8  * This library is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Library General Public
10  * License as published by the Free Software Foundation; either
11  * version 2 of the License, or (at your option) any later version.
12  *
13  * This library is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16  * Library General Public License for more details.
17  *
18  * You should have received a copy of the GNU Library General Public
19  * License along with this library; if not, write to the
20  * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
21  * Boston, MA 02110-1301, USA.
22  */
23
24 #ifndef __V4L2_CALLS_H__
25 #define __V4L2_CALLS_H__
26
27 #include "gstv4l2object.h"
28
29 #ifdef HAVE_LIBV4L2
30 #  include <libv4l2.h>
31 #else
32 #  include "ext/videodev2.h"
33 #  include <sys/ioctl.h>
34 #  include <sys/mman.h>
35 #  include <unistd.h>
36 #  define v4l2_fd_open(fd, flags) (fd)
37 #  define v4l2_close    close
38 #  define v4l2_dup      dup
39 #  define v4l2_ioctl    ioctl
40 #  define v4l2_read     read
41 #  define v4l2_mmap     mmap
42 #  define v4l2_munmap   munmap
43 #endif
44
45 #define GST_V4L2_IS_OVERLAY(v4l2object) \
46   (v4l2object->vcap.capabilities & V4L2_CAP_VIDEO_OVERLAY)
47
48 /* checks whether the current v4lv4l2object has already been open()'ed or not */
49 #define GST_V4L2_CHECK_OPEN(v4l2object)                         \
50   if (!GST_V4L2_IS_OPEN(v4l2object))                            \
51   {                                                             \
52     GST_ELEMENT_ERROR (v4l2object->element, RESOURCE, SETTINGS, \
53       (_("Device is not open.")), (NULL));                      \
54     return FALSE;                                               \
55   }
56
57 /* checks whether the current v4lv4l2object is close()'ed or whether it is still open */
58 #define GST_V4L2_CHECK_NOT_OPEN(v4l2object)                     \
59   if (GST_V4L2_IS_OPEN(v4l2object))                             \
60   {                                                             \
61     GST_ELEMENT_ERROR (v4l2object->element, RESOURCE, SETTINGS, \
62       (_("Device is open.")), (NULL));                          \
63     return FALSE;                                               \
64   }
65
66 /* checks whether the current v4lv4l2object does video overlay */
67 #define GST_V4L2_CHECK_OVERLAY(v4l2object)                      \
68   if (!GST_V4L2_IS_OVERLAY(v4l2object))                         \
69   {                                                             \
70     GST_ELEMENT_ERROR (v4l2object->element, RESOURCE, SETTINGS, \
71       (NULL), ("Device cannot handle overlay"));                \
72     return FALSE;                                               \
73   }
74
75 /* checks whether we're in capture mode or not */
76 #define GST_V4L2_CHECK_ACTIVE(v4l2object)                       \
77   if (!GST_V4L2_IS_ACTIVE(v4l2object))                          \
78   {                                                             \
79     GST_ELEMENT_ERROR (v4l2object->element, RESOURCE, SETTINGS, \
80       (NULL), ("Device is not in streaming mode"));             \
81     return FALSE;                                               \
82   }
83
84 /* checks whether we're out of capture mode or not */
85 #define GST_V4L2_CHECK_NOT_ACTIVE(v4l2object)                   \
86   if (GST_V4L2_IS_ACTIVE(v4l2object))                           \
87   {                                                             \
88     GST_ELEMENT_ERROR (v4l2object->element, RESOURCE, SETTINGS, \
89       (NULL), ("Device is in streaming mode"));                 \
90     return FALSE;                                               \
91   }
92
93
94 /* open/close the device */
95 gboolean        gst_v4l2_open                   (GstV4l2Object *v4l2object);
96 gboolean        gst_v4l2_dup                    (GstV4l2Object *v4l2object, GstV4l2Object *other);
97 gboolean        gst_v4l2_close                  (GstV4l2Object *v4l2object);
98
99 /* norm/input/output */
100 gboolean        gst_v4l2_get_norm               (GstV4l2Object *v4l2object,
101                                                  v4l2_std_id    *norm);
102 gboolean        gst_v4l2_set_norm               (GstV4l2Object *v4l2object,
103                                                  v4l2_std_id     norm);
104 gboolean        gst_v4l2_get_input              (GstV4l2Object * v4l2object,
105                                                  gint * input);
106 gboolean        gst_v4l2_set_input              (GstV4l2Object * v4l2object,
107                                                  gint input);
108 gboolean        gst_v4l2_get_output             (GstV4l2Object *v4l2object,
109                                                  gint           *output);
110 gboolean        gst_v4l2_set_output             (GstV4l2Object *v4l2object,
111                                                  gint            output);
112
113 /* frequency control */
114 gboolean        gst_v4l2_get_frequency          (GstV4l2Object *v4l2object,
115                                                  gint            tunernum,
116                                                  gulong         *frequency);
117 gboolean        gst_v4l2_set_frequency          (GstV4l2Object *v4l2object,
118                                                  gint            tunernum,
119                                                  gulong          frequency);
120 gboolean        gst_v4l2_signal_strength        (GstV4l2Object *v4l2object,
121                                                  gint            tunernum,
122                                                  gulong         *signal);
123
124 /* attribute control */
125 gboolean        gst_v4l2_get_attribute          (GstV4l2Object *v4l2object,
126                                                  int             attribute,
127                                                  int            *value);
128 gboolean        gst_v4l2_set_attribute          (GstV4l2Object *v4l2object,
129                                                  int             attribute,
130                                                  const int       value);
131
132 gboolean        gst_v4l2_set_controls           (GstV4l2Object * v4l2object,
133                                                  GstStructure * controls);
134
135 gboolean        gst_v4l2_get_capabilities       (GstV4l2Object * v4l2object);
136
137
138 #define LOG_CAPS(obj, caps) GST_DEBUG_OBJECT (obj, "%s: %" GST_PTR_FORMAT, #caps, caps)
139
140 #endif /* __V4L2_CALLS_H__ */