added config
[nao-ulib.git] / src / mmap_v4l.h
blob606ed6e08d5a56cda8b27d99c9a13a8bdbf4e972
1 /*
2 * nao-ulib
3 * Copyright 2011 Daniel Borkmann <dborkma@tik.ee.ethz.ch>
4 * Subject to the GPL.
5 * Nao-Team HTWK,
6 * Faculty of Computer Science, Mathematics and Natural Sciences,
7 * Leipzig University of Applied Sciences (HTWK Leipzig)
8 */
10 #ifndef NAONET_H
11 #define NAONET_H
13 #include <stdint.h>
14 #include <stdio.h>
15 #include <asm/types.h>
16 #include <linux/videodev2.h>
18 #ifndef V4L2_CID_AUTOEXPOSURE
19 # define V4L2_CID_AUTOEXPOSURE (V4L2_CID_BASE + 32)
20 #endif
21 #ifndef V4L2_CID_CAM_INIT
22 # define V4L2_CID_CAM_INIT (V4L2_CID_BASE + 33)
23 #endif
24 #ifndef V4L2_CID_AUDIO_MUTE
25 # define V4L2_CID_AUDIO_MUTE (V4L2_CID_BASE + 9)
26 #endif
27 #ifndef V4L2_CID_POWER_LINE_FREQUENCY
28 # define V4L2_CID_POWER_LINE_FREQUENCY (V4L2_CID_BASE + 24)
29 enum v4l2_power_line_frequency {
30 V4L2_CID_POWER_LINE_FREQUENCY_DISABLED = 0,
31 V4L2_CID_POWER_LINE_FREQUENCY_50HZ = 1,
32 V4L2_CID_POWER_LINE_FREQUENCY_60HZ = 2,
34 #endif
35 #ifndef V4L2_CID_HUE_AUTO
36 # define V4L2_CID_HUE_AUTO (V4L2_CID_BASE + 25)
37 #endif
38 #ifndef V4L2_CID_WHITE_BALANCE_TEMPERATURE
39 # define V4L2_CID_WHITE_BALANCE_TEMPERATURE (V4L2_CID_BASE + 26)
40 #endif
41 #ifndef V4L2_CID_SHARPNESS
42 # define V4L2_CID_SHARPNESS (V4L2_CID_BASE + 27)
43 #endif
44 #ifndef V4L2_CID_BACKLIGHT_COMPENSATION
45 # define V4L2_CID_BACKLIGHT_COMPENSATION (V4L2_CID_BASE + 28)
46 #endif
47 #ifndef V4L2_CID_CAMERA_CLASS_BASE
48 # define V4L2_CID_CAMERA_CLASS_BASE (V4L2_CTRL_CLASS_CAMERA | 0x900)
49 #endif
50 #ifndef V4L2_CID_CAMERA_CLASS
51 # define V4L2_CID_CAMERA_CLASS (V4L2_CTRL_CLASS_CAMERA | 1)
52 #endif
53 #ifndef V4L2_CID_EXPOSURE_AUTO
54 # define V4L2_CID_EXPOSURE_AUTO (V4L2_CID_CAMERA_CLASS_BASE + 1)
55 enum v4l2_exposure_auto_type {
56 V4L2_EXPOSURE_MANUAL = 0,
57 V4L2_EXPOSURE_AUTO = 1,
58 V4L2_EXPOSURE_SHUTTER_PRIORITY = 2,
59 V4L2_EXPOSURE_APERTURE_PRIORITY = 3
61 #endif
62 #ifndef V4L2_CID_EXPOSURE_ABSOLUTE
63 # define V4L2_CID_EXPOSURE_ABSOLUTE (V4L2_CID_CAMERA_CLASS_BASE + 2)
64 #endif
65 #ifndef V4L2_CID_EXPOSURE_AUTO_PRIORITY
66 # define V4L2_CID_EXPOSURE_AUTO_PRIORITY (V4L2_CID_CAMERA_CLASS_BASE + 3)
67 #endif
68 #ifndef V4L2_CID_PAN_RELATIVE
69 # define V4L2_CID_PAN_RELATIVE (V4L2_CID_CAMERA_CLASS_BASE + 4)
70 #endif
71 #ifndef V4L2_CID_TILT_RELATIVE
72 # define V4L2_CID_TILT_RELATIVE (V4L2_CID_CAMERA_CLASS_BASE + 5)
73 #endif
74 #ifndef V4L2_CID_PAN_RESET
75 # define V4L2_CID_PAN_RESET (V4L2_CID_CAMERA_CLASS_BASE + 6)
76 #endif
77 #ifndef V4L2_CID_TILT_RESET
78 # define V4L2_CID_TILT_RESET (V4L2_CID_CAMERA_CLASS_BASE + 7)
79 #endif
80 #ifndef V4L2_CID_PAN_ABSOLUTE
81 # define V4L2_CID_PAN_ABSOLUTE (V4L2_CID_CAMERA_CLASS_BASE + 8)
82 #endif
83 #ifndef V4L2_CID_TILT_ABSOLUTE
84 # define V4L2_CID_TILT_ABSOLUTE (V4L2_CID_CAMERA_CLASS_BASE + 9)
85 #endif
86 #ifndef V4L2_CID_FOCUS_ABSOLUTE
87 # define V4L2_CID_FOCUS_ABSOLUTE (V4L2_CID_CAMERA_CLASS_BASE + 10)
88 #endif
89 #ifndef V4L2_CID_FOCUS_RELATIVE
90 # define V4L2_CID_FOCUS_RELATIVE (V4L2_CID_CAMERA_CLASS_BASE + 11)
91 #endif
92 #ifndef V4L2_CID_FOCUS_AUTO
93 # define V4L2_CID_FOCUS_AUTO (V4L2_CID_CAMERA_CLASS_BASE + 12)
94 #endif
96 struct v4l_buff {
97 void *start;
98 size_t length;
102 * 0) select cam
103 * 1) open_v4l_device
104 * 2) init_v4l_device
105 * 3) init_mmap
106 * 4) start_v4l_capturing
107 * 5) while ... read_v4l_frame
108 * 6) stop_v4l_capturing
109 * 7) cleanup_v4l_device
110 * 8) close_vl4_device
113 extern void convert_v4l_yuyv_to_rgb24(const uint8_t *src,
114 uint8_t *dest, int width, int height);
115 extern int read_v4l_frame(int fd, unsigned int nbuffs,
116 struct v4l_buff *buffs,
117 int (*rx_v4l_cb)(uint8_t *frame, size_t len));
118 extern int open_v4l_device(char *dev);
119 extern void close_vl4_device(int fd);
120 extern int start_v4l_capturing(int fd, unsigned int nbuffs);
121 extern int stop_v4l_capturing(int fd);
122 extern int init_mmap(int fd, const char *dev, unsigned int *nbuffs,
123 struct v4l_buff **buffs, int frames);
124 extern int cleanup_v4l_device(int fd, unsigned int nbuffs,
125 struct v4l_buff *buffs);
126 extern void set_v4l_ctl_or_die(int fd, unsigned int id, int value);
127 extern int init_v4l_device(int fd, int width, int height);
128 extern void debug_v4l_struct_buffer(struct v4l2_buffer *img);
129 extern int i2c_select_lower_cam(void);
130 extern int i2c_select_upper_cam(void);
132 #endif /* NAONET_H */