Initial release
[adaptation/ap_samsung/gst-plugins-s5pc2xx.git] / camerasrc / src / include / camerasrc-internal.h
1 /*
2  * camerasrc
3  *
4  * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
5  *
6  * Contact: Jeongmo Yang <jm80.yang@samsung.com>
7  *
8  * This library is free software; you can redistribute it and/or modify it under
9  * the terms of the GNU Lesser General Public License as published by the
10  * Free Software Foundation; either version 2.1 of the License, or (at your option)
11  * any later version.
12  *
13  * This library is distributed in the hope that it will be useful, but WITHOUT ANY
14  * WARRANTY; without even the implied warranty of MERCHANTABILITY or
15  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
16  * License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public License
19  * along with this library; if not, write to the Free Software Foundation, Inc., 51
20  * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21  *
22  */
23
24 #ifndef __CAMERASRC_INTERNAL_H__
25 #define __CAMERASRC_INTERNAL_H__
26
27 #include "camerasrc-common.h"
28
29 #ifdef __cplusplus
30 extern "C" {
31 #endif
32
33 /**
34  * Video 4 linux control ID definitions (Extended by kernel team)
35  * extended pixel format for V4l2
36  */
37
38
39 /**
40  * Miscellaneous camera-dependent definitions
41  */
42 #define CAMERASRC_DEV_INDEX_MAX                 2
43 #define CAMERASRC_AF_TOTALTIME                  5000000
44 #define CAMERASRC_AF_INTERVAL                   20000
45 #define CAMERASRC_AF_STOP_INTERVAL              10000
46 #define CAMERASRC_MEGA_DEV_NAME                 "/dev/video0"
47 #define CAMERASRC_VGA_DEV_NAME                  "/dev/video0"
48 #define CAMERASRC_JPG_STILL_H_SYNC              2048
49 #define CAMERASRC_JPG_STILL_V_SYNC              2048
50 #define CAMERASRC_JPG_STILL_SKIP_FRAME          0
51 #define CAMERASRC_RAW_STILL_THUMBNAIL_OFFSET    1689600
52 #define CAMERASRC_JPG_STILL_THUMBNAIL_OFFSET    0x1bd000
53 #define CAMERASRC_MAX_MAIN_JPEG_SIZE            CAMERASRC_JPG_STILL_H_SYNC * CAMERASRC_JPG_STILL_V_SYNC /* 0x1bd000 */
54 #define CAMERASRC_MAX_THM_JPEG_SIZE             0
55 #define CAMERASRC_PREVIEW_BUFFER_NUM            6
56 #define CAMERASRC_VIDEO_BUFFER_NUM              7
57 #define CAMERASRC_STILL_BUFFER_NUM              1
58 #define CAMERASRC_YUV_THMBNL_SIZE               320 * 240 * 2
59 #define CAMERASRC_TIMEOUT_CRITICAL_VALUE        5000
60 #define CAMERASRC_PRE_AF_INTERVAL               0
61 #define CAMERASRC_REGISTER_SET_RETRY_NO         200
62 #define CAMERASRC_V4L2_PREVIEW_PIX_FMT_DEFAULT          V4L2_PIX_FMT_YUYV
63 #define CAMERASRC_V4L2_JPEG_CAPTURE_PIX_FMT_DEFAULT     V4L2_PIX_FMT_JPEG
64 #define CAMERASRC_V4L2_JPG_YUV_CAPTURE_PIX_FMT_DEFAULT  V4L2_PIX_FMT_MJPEG
65 #define CAMERASRC_V4L2_RGB_CAPTURE_PIX_FMT_DEFAULT      V4L2_PIX_FMT_RGB565
66
67 #define CAMERASRC_SYNC_KEY_PATH                 "FUJITSU_M5MOLS"
68 #define CAMERASRC_SYNC_KEY_PREFIX               0x55
69
70 #define CAMERASRC_AF_DELAY_AFTER_SET_AF_AREA    350 /* msec */
71
72 #define _CAMERASRC_EXIF_COMP_CONF               (0x00000000) | (0x00000001) | (0x00000002 << 8) | (0x00000003 << 16)    /* Y Cb Cr - */
73 #define _CAMERASRC_EXIF_COLORSPACE              0x00000001
74 #define _CAMERASRC_EXIF_FOCAL_LEN_NUM           454
75 #define _CAMERASRC_EXIF_FOCAL_LEN_DEN           100
76 #define _CAMERASRC_EXIF_F_NUM_NUM               28
77 #define _CAMERASRC_EXIF_F_NUM_DEN               10
78 #define _CAMERASRC_EXIF_MAX_F_NUM_NUM_IN_APEX   3
79
80 #define _CAMERASRC_CMD_SUPPORT_EMBED_EXIF_DEF   0
81
82 /*
83  * |------------------------------------------------------------|
84  * |             | Primary   | Secondary | Extension| Unknown   |
85  * |------------------------------------------------------------|
86  * |   Index     |    2      |     1     |    0     |    -1     |
87  * |------------------------------------------------------------|
88  *
89  * |------------------------------------------------------------|
90  * |             |    0      |     1     |    2     |     3     |
91  * |------------------------------------------------------------|
92  * |   ID        | Unknown   | Secondary | Primary  | Extension |
93  * |------------------------------------------------------------|
94  */
95
96 static int _camerasrc_dev_index[CAMERASRC_DEV_ID_NUM][CAMERASRC_DEV_RECOG_NUM] =
97 {
98     {CAMERASRC_DEV_ID_SECONDARY, 0},
99     {CAMERASRC_DEV_ID_PRIMARY, 1},
100     {CAMERASRC_DEV_ID_EXTENSION, 2},
101     {CAMERASRC_DEV_ID_UNKNOWN, -1},
102 };
103
104
105 /**
106  * preset size index
107  * |-------------------------------------------------------------------------|
108  * |             |             |  YUV422P  |  YUV420P |  SRGGB8   | SRGGB10  |
109  * |-------------------------------------------------------------------------|
110  * |             | Highquality |     O     |    X     |     X     |     X    |
111  * |    RAW      |-----------------------------------------------------------|
112  * |             | Normal      |     O     |    X     |     X     |     X    |
113  * |-------------------------------------------------------------------------|
114  * |             | Highquality |     X     |    X     |     O     |     X    |
115  * |    JPEG     |-----------------------------------------------------------|
116  * |             | Normal      |     X     |    X     |     X     |     X    |
117  * |-------------------------------------------------------------------------|
118  */
119 static char _camerasrc_match_col_to_pix[CAMERASRC_DEV_ID_EXTENSION][CAMERASRC_COL_NUM][CAMERASRC_PIX_NUM][CAMERASRC_QUALITY_NUM] =
120 {
121     {/*SECONDARY*/
122         /*422P,     420P,      SRGGB8,    SRGGB10*/
123         {{0x1,0x0}, {0x0,0x0}, {0x0,0x0}, {0x0,0x0}},   /**< RAW */
124         {{0x0,0x0}, {0x0,0x0}, {0x0,0x0}, {0x0,0x0}},   /**< JPG */
125     },
126     {/*PRIMARY*/
127         /*422P,     420P,      SRGGB8,    SRGGB10 */
128         {{0x1,0x0}, {0x0,0x0}, {0x0,0x0}, {0x0,0x0}},   /**< RAW */
129         {{0x0,0x0}, {0x0,0x0}, {0x0,0x1}, {0x0,0x1}},   /**< JPG */
130     },
131 }; /* {Normal quality, High quality} */
132
133 /*
134  * |--------------------------------------------------------------------------------|
135  * |               | Support   | MAX value | MIN value |   CID                      |
136  * |--------------------------------------------------------------------------------|
137  * | Brightness    |    1      |     8     |    0      | V4L2_CID_BRIGHTNESS        |
138  * |--------------------------------------------------------------------------------|
139  * | Contrast      |    1      |     9     |    0      |    -1                      |
140  * |--------------------------------------------------------------------------------|
141  * | Digital zoom  |    1      |    100    |    0      |  V4L2_CID_BASE+29          |
142  * |--------------------------------------------------------------------------------|
143  * | Optical zoom  |    0      |    -1     |   -1      |    -1                      |
144  * |--------------------------------------------------------------------------------|
145  * | White balance |    1      |     9     |    0      |  V4L2_CID_DO_WHITE_BALANCE |
146  * |--------------------------------------------------------------------------------|
147  * | Color tone    |    1      |    14     |    0      |  V4L2_CID_BASE+28          |
148  * |--------------------------------------------------------------------------------|
149  * | Program mode  |    0      |    -1     |   -1      |    -1                      |
150  * |--------------------------------------------------------------------------------|
151  * | Flip          |    1      |     1     |    0      |  V4L2_CID_FLIP             |
152  * |--------------------------------------------------------------------------------|
153  * | Flash         |    1      |     2     |    0      |  V4L2_CID_BASE+32          |
154  * |--------------------------------------------------------------------------------|
155  */
156
157 /* CUSTOM V4L2 CONTROL ID DEFINITIONS */
158
159 #define CAM_AF_STATUS_ONGOING  0
160 #define CAM_AF_STATUS_FOCUSED  1
161 #define CAM_AF_STATUS_FAILED   2
162
163 enum {
164     CAMERASRC_SENSOR_AF_STATUS_ONGOING  = CAM_AF_STATUS_ONGOING,
165     CAMERASRC_SENSOR_AF_STATUS_FOCUSED  = CAM_AF_STATUS_FOCUSED,
166     CAMERASRC_SENSOR_AF_STATUS_FAILED   = CAM_AF_STATUS_FAILED
167 };
168
169 /* FACE_DETECTION CMD & STATUS */
170 #define V4L2_CID_FACE_DETECTION        (V4L2_CID_PRIVATE_BASE + 38)
171
172 #define CAM_FACE_DETECTION_OFF     0
173 #define CAM_FACE_DETECTION_ON      1
174
175 /* ESD INTERRUPT CHECK */
176 /*To read interrupt status of "Data output stop from sensor"*/
177 #define V4L2_CID_ESD_INT               (V4L2_CID_PRIVATE_BASE + 40)
178
179 #define CAM_ESD_INT_NORMAL         0
180 #define CAM_ESD_INT_TROUBLE        1
181
182
183 /* CUSTOM V4L2 CONTROL ID DEFINITIONS (END) */
184 static int _camerasrc_ctrl_list[CAMERASRC_DEV_ID_EXTENSION][CAMERASRC_CTRL_NUM][CAMERASRC_CTRL_PROPERTY_NUM] =
185 {       /* { SUPPORT, MAX_VALUE, MIN_VALUE, CID, CURRENT_VALUE } */
186     {   /* Primary camera */
187         {-1, 4, -4, V4L2_CID_EXPOSURE, 0},              /* Brightness */
188         {-1, 3, -3, V4L2_CID_CONTRAST, 0},              /* Contrast */
189         {-1, 30, 0, V4L2_CID_CAMERA_ZOOM, 0},           /* Digital zoom */
190         {0,  -1, -1, -1, -1},                           /* Optical zoom */
191         {-1, CAMERASRC_WHITEBALANCE_HORIZON, CAMERASRC_WHITEBALANCE_AUTO, V4L2_CID_WHITE_BALANCE_PRESET, CAMERASRC_WHITEBALANCE_AUTO},          /* White balance */
192         {-1, CAMERASRC_COLORTONE_ANTIQUE, CAMERASRC_COLORTONE_NONE, V4L2_CID_COLORFX, CAMERASRC_COLORTONE_NONE},                                /* Colortone */
193         {-1, CAMERASRC_PROGRAM_MODE_BACK_LIGHT, CAMERASRC_PROGRAM_MODE_NORMAL, V4L2_CID_CAMERA_SCENE_MODE, CAMERASRC_PROGRAM_MODE_NORMAL},      /* program mode */
194         {0,  -1, -1, -1, -1},                           /* Flip. V4L2_CID_VFLIP/HFLIP */
195         {0,  -1, -1, -1, -1},                           /* PARTCOLOR_SRC */
196         {0,  -1, -1, -1, -1},                           /* PARTCOLOR_DST */
197         {0,  -1, -1, -1, -1},                           /* PARTCOLOR_MODE */
198         {-1, 3, 0, V4L2_CID_CAM_STABILIZE, 0},          /* ANTI_HANDSHAKE */
199         {-1, 2, 0, V4L2_CID_CAM_DR, 0},                 /* WIDE_DYNAMIC_RANGE */
200         {-1, 3, -3, V4L2_CID_SATURATION, 0},            /* SATURATION */
201         {-1, 3, -3, V4L2_CID_SHARPNESS, 0},             /* SHARPNESS */
202         {-1,  -1, -1, V4L2_CID_CAMERA_ISO, -1},         /* ISO */
203         {-1,  -1, -1, V4L2_CID_CAMERA_METERING, -1},    /* PHOTOMETRY */
204     },
205     {   /* Secondary camera */
206         {0,  -1, -1, V4L2_CID_CAMERA_BRIGHTNESS, -1},   /* Brightness */
207         {0,  -1, -1, V4L2_CID_CONTRAST, -1},            /* Contrast */
208         {0,  -1, -1, V4L2_CID_ZOOM_ABSOLUTE, -1},       /* Digital zoom */
209         {0,  -1, -1, -1, -1},                           /* Optical zoom */
210         {0,  -1, -1, V4L2_CID_WHITE_BALANCE_PRESET, -1},/* White balance */
211         {0,  -1, -1, V4L2_CID_COLORFX, -1},             /* Colortone */
212         {0,  -1, -1, V4L2_CID_CAMERA_SCENE_MODE, -1},   /* program mode */
213         {0,  -1, -1, -1, -1},                           /* Flip */
214         {0,  -1, -1, -1, -1},                           /* PARTCOLOR_SRC */
215         {0,  -1, -1, -1, -1},                           /* PARTCOLOR_DST */
216         {0,  -1, -1, -1, -1},                           /* PARTCOLOR_MODE */
217         {0,  -1, -1, V4L2_CID_CAM_STABILIZE, -1},       /* ANTI_HANDSHAKE */
218         {0,  -1, -1, V4L2_CID_CAM_DR, -1},              /* WIDE_DYNAMIC_RANGE */
219         {0,  -1, -1, V4L2_CID_SATURATION, -1},          /* SATURATION */
220         {0,  -1, -1, V4L2_CID_SHARPNESS, -1},           /* SHARPNESS */
221         {0,  -1, -1, V4L2_CID_CAMERA_ISO, -1},          /* ISO */
222         {0,  -1, -1, V4L2_CID_CAMERA_METERING, -1},     /* PHOTOMETRY */
223     },
224 };
225
226 static char _camerasrc_misc_func_list[CAMERASRC_DEV_ID_EXTENSION][CAMERASRC_OP_REGISTER_VALUE][CAMERASRC_COL_NUM][CAMERASRC_MISC_FUNC_NUM] =
227 {
228     {/*Primary*/
229         /*Raw,       JPG*/
230         {{0x0,0x1}, {0x0,0x0}}, /*Preview*/
231         {{0x0,0x1}, {0x0,0x0}}, /*Capture*/
232         {{0x0,0x1}, {0x0,0x0}}, /*Video*/
233     },
234     {/*Secondary*/
235         {{0x0,0x0}, {0x0,0x0}}, /*Preview*/
236         {{0x0,0x0}, {0x0,0x0}}, /*Capture*/
237         {{0x0,0x0}, {0x0,0x0}}, /*Video*/
238     }/*{{Signal,Skip}, {Signal,Skip}}*/
239 };
240
241 static int _camerasrc_af_support[CAMERASRC_DEV_ID_NUM] = {1, 0, 0, 0};
242
243 #ifdef __cplusplus
244 }
245 #endif
246
247 #endif /*__CAMERASRC_INTERNAL_H__*/