peripherals  1.4.2
RoadNarrows Robotics Hardware Peripherals Package
econ50.h
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////////////
2 //
3 // Package: Wound Measurement
4 //
5 // Program: WMTake
6 //
7 // File: econ.h
8 //
9 /*! \file
10  *
11  * $LastChangedDate: 2013-02-20 10:20:40 -0700 (Wed, 20 Feb 2013) $
12  * $Rev: 2697 $
13  *
14  * \brief e-Con systems ecam50 header file
15  *
16  * \author Robin Knight (robin.knight@roadnarrows.com)
17  * \author Daniel Packard (daniel@roadnarrows.com)
18  *
19  * \par Copyright:
20  * (C) 2011. CoMedTec
21  * (http://www.comedtec.com)
22  * \n All Rights Reserved
23  */
24 // Unless otherwise noted, all materials contained are copyrighted and may not
25 // be used except as provided in these terms and conditions or in the copyright
26 // notice (documents and software ) or other proprietary notice provided with
27 // the relevant materials.
28 //
29 //
30 // IN NO EVENT SHALL THE AUTHOR, COMEDTEC, OR ANY MEMBERS/EMPLOYEES/CONTRACTORS
31 // OF COMEDTEC OR DISTRIBUTORS OF THIS SOFTWARE BE LIABLE TO ANY
32 // PARTY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL
33 // DAMAGES ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION,
34 // EVEN IF THE AUTHORS OR ANY OF THE ABOVE PARTIES HAVE BEEN ADVISED OF
35 // THE POSSIBILITY OF SUCH DAMAGE.
36 //
37 // THE AUTHORS AND COMEDTEC SPECIFICALLY DISCLAIM ANY WARRANTIES,
38 // INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
39 // FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS ON AN
40 // "AS IS" BASIS, AND THE AUTHORS AND DISTRIBUTORS HAVE NO OBLIGATION TO
41 // PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
42 //:w
43 //
44 ////////////////////////////////////////////////////////////////////////////////
45 
46 #ifndef _ECON_H
47 #define _ECON_H
48 
49 #include <linux/videodev.h>
50 #include <linux/fb.h>
51 #include <sys/ioctl.h>
52 #include <malloc.h>
53 #include <pthread.h>
54 
55 /*
56  * Standard ECON Header file
57  */
58 
59  #ifdef HAVE_CONFIG_H
60  #include <config.h>
61  #endif
62 
63  #include <stdio.h>
64  #include <stdlib.h>
65  #include <string.h>
66  #include <fcntl.h>
67  #include <termios.h>
68  #include <unistd.h>
69 
70  #include <sys/types.h>
71  #include <sys/stat.h>
72  #include <sys/time.h>
73  #include <sys/ioctl.h>
74  #include <sys/mman.h>
75 
76 /*
77  * include custom header file
78  */
79  #ifdef HAVE_IOCTL_DEF
80  #include "ioctls_def.h"
81  #endif
82 
83 #include "econ_typedef.h"
84 #include "econ_error.h"
85 #include "econ_fn_res_prototype.h"
86 
87 #define ECAM50_MAX_IMAGE_WIDTH 2592
88 #define ECAM50_MAX_IMAGE_HEIGHT 1944
89 #define ECAM50_MAX_PATH_NAME 500
90 
91 #define ECAM50_READ 0
92 #define ECAM50_WRITE 1
93 #define ECAM50_QUERY 2
94 
95 #define ENABLE 0x01
96 #define DISABLE 0x00
97 
98 #define ECAM50_TEST_BUFFER_NUM 2
99 
100 /*!
101  * \brief v4l2 sensor interface
102  */
103 #define V4L2_SENS_TRIG_FOCUS (V4L2_CID_PRIVATE_BASE + 1)
104 #define V4L2_SENS_FCS_OLAY (V4L2_CID_PRIVATE_BASE + 2)
105 
106 #define V4L2_SENS_FLASH (V4L2_CID_PRIVATE_BASE + 3)
107 #define V4L2_SENS_FLASH_LUM (V4L2_CID_PRIVATE_BASE + 4)
108 #define V4L2_SENS_FLASH_TORCH (V4L2_CID_PRIVATE_BASE + 5)
109 #define V4L2_SENS_FLASH_FLASH (V4L2_CID_PRIVATE_BASE + 6)
110 #define V4L2_SENS_FLASH_STROBE (V4L2_CID_PRIVATE_BASE + 7)
111 #define V4L2_SENS_FLASH_FLASH_LUM (V4L2_CID_PRIVATE_BASE + 10)
112 #define V4L2_SENS_FLASH_TORCH_LUM (V4L2_CID_PRIVATE_BASE + 11)
113 
114 #define V4L2_SENS_EFFECTS (V4L2_CID_PRIVATE_BASE + 8)
115 #define V4L2_SENS_FOCUS_DISABLE (V4L2_CID_PRIVATE_BASE + 9)
116 
117 #define V4L2_SENS_ANTISHAKE (V4L2_CID_PRIVATE_BASE + 12)
118 #define V4L2_SENS_ANTISHAKE_STATUS (V4L2_CID_PRIVATE_BASE + 13)
119 
120 /*!
121  * \brief ecam50 camera control structure
122  */
123 typedef struct _ecam50_camera_data
124 {
125  INT32 fd_v4l2;
126 
127  struct v4l2_format fmt;
128 
129  struct v4l2_control ctrl_whitebalance,ctrl_brightness, \
130  ctrl_contrast,ctrl_saturation,ctrl_exposure, \
131  ctrl_focus,ctrl_sharpness,ctrl_hue,ctrl_effects, \
132  ctrl_h_mirror,ctrl_flash,ctrl_anti_shake,ctrl_v_flip;
133 
134  struct v4l2_queryctrl qctrl_whitebalance,qctrl_brightness,qctrl_contrast, \
135  qctrl_saturation,qctrl_exposure,qctrl_focus, \
136  qctrl_sharpness,qctrl_effects,qctrl_v_flip, \
137  qctrl_h_mirror,qctrl_flash,qctrl_anti_shake,qctrl_hue;
138 
139  struct v4l2_streamparm fps;
140  struct v4l2_requestbuffers req;
141  enum v4l2_buf_type type;
142  struct v4l2_buffer buf;
143 
144 
145  PINT8 rgb_888_buffer;
146  PINT8 raw_read_buffer;
147  UINT8 save_raw_file_needed;
148 
149  union
150  {
151  UINT32 Maintain_threads;
152  struct
153  {
154  UINT32 stream_thread_kill :1;
155  }thread;
156  }kill;
157 
158  union
159  {
160  UINT32 G_FLAG;
161  struct
162  {
163  UINT32 comm_ctrl :2; // 0 - read, 1 - write, 2 - query
164  UINT32 anti_shake :1;
165  }bit;
166  }flag;
167 
168  struct __attribute__ ((__packed__))
169  {
170  UINT16 type;
171  UINT32 size;
172  UINT16 reserved1;
173  UINT16 reserved2;
174  UINT32 offbits;
175  UINT32 size_header;
176  INT32 width;
177  INT32 height;
178  UINT16 planes;
179  UINT16 bitcount;
180  UINT32 compression;
181  UINT32 size_image;
182  INT32 x_permeter;
183  INT32 y_permeter;
184  UINT32 clr_used;
185  UINT32 clr_important;
186  }bmp_header;
187 
188  FILE *save_file_ptr;
189  INT8 save_path[ECAM50_MAX_PATH_NAME];
190 
191  struct fb_var_screeninfo gvinfo;
192  struct fb_var_screeninfo vinfo;
193  INT32 fb_fd;
194  PINT8 fb_ptr;
195 
196  INT32 stream_width;
197  INT32 stream_height;
198 
199  pthread_t stream_tid;
200  struct testbuffer
201  {
202  UPINT8 start;
203  size_t offset;
204  UINT32 length;
205  }buffers[ECAM50_TEST_BUFFER_NUM];
206 
207  union
208  {
209  UINT32 G_FLAG;
210  struct
211  {
212  UINT32 record_mode :1;
213  UINT32 stream_lcd :1;
214  }bit;
215  }stream;
216 
217  FILE *fp_file_record;
218 
219 } ecam50;
220 
221 /*!
222  * \brief ecam50 interface
223  */
224 extern FNRESLT register_camera_data(ecam50 **cam, UINT8 configure_status_flag);
225 extern FNRESLT save_snap(ecam50 *cam, const char *sFileName);
226 extern FNRESLT feature_test_api_init(ecam50 **cam, int nVidIndex);
227 extern FNRESLT feature_test_api_exit(ecam50 *cam);
228 extern FNRESLT close_camera(ecam50 *cam);
229 extern FNRESLT stream_on(ecam50 *cam);
230 extern FNRESLT stream_off(ecam50 *cam);
231 extern FNRESLT snap_apply_ctrl(ecam50 *cam);
232 extern FNRESLT take_snap(ecam50 *cam);
233 extern FNRESLT read_snap(ecam50 *cam);
234 extern FNRESLT convert_bmp_565_bmp_888(ecam50 *cam);
235 extern FNRESLT form_bmp_header_info(ecam50 *cam);
236 extern FNRESLT anti_shake(ecam50 *cam);
237 extern FNRESLT v_flip(ecam50 *cam);
238 
239 FNRESLT gettime(OUT PINT64 millisec,UINT8 flag);
240 
241 #endif // _ECON_H
ecam50 camera control structure
Definition: econ50.h:123
struct _ecam50_camera_data ecam50
ecam50 camera control structure
FNRESLT register_camera_data(ecam50 **cam, UINT8 configure_status_flag)
ecam50 interface