summaryrefslogtreecommitdiff
path: root/camerasrc/src/include/camerasrc-internal.h
blob: 6b97589f7d43910f202975bf908d659438806c56 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
/*
 * camerasrc
 *
 * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
 *
 * Contact: Jeongmo Yang <jm80.yang@samsung.com>
 *
 * This library is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Lesser General Public License as published by the
 * Free Software Foundation; either version 2.1 of the License, or (at your option)
 * any later version.
 *
 * This library is distributed in the hope that it will be useful, but WITHOUT ANY
 * WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
 * License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this library; if not, write to the Free Software Foundation, Inc., 51
 * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 *
 */

#ifndef __CAMERASRC_INTERNAL_H__
#define __CAMERASRC_INTERNAL_H__

#include "camerasrc-common.h"

#ifdef __cplusplus
extern "C" {
#endif

/**
 * Video 4 linux control ID definitions (Extended by kernel team)
 * extended pixel format for V4l2
 */


/**
 * Miscellaneous camera-dependent definitions
 */
#define CAMERASRC_DEV_INDEX_MAX                 2
#define CAMERASRC_AF_TOTALTIME                  5000000
#define CAMERASRC_AF_INTERVAL                   20000
#define CAMERASRC_AF_STOP_INTERVAL              10000
#define CAMERASRC_MEGA_DEV_NAME                 "/dev/video0"
#define CAMERASRC_VGA_DEV_NAME                  "/dev/video0"
#define CAMERASRC_JPG_STILL_H_SYNC              2048
#define CAMERASRC_JPG_STILL_V_SYNC              2048
#define CAMERASRC_JPG_STILL_SKIP_FRAME          0
#define CAMERASRC_RAW_STILL_THUMBNAIL_OFFSET    1689600
#define CAMERASRC_JPG_STILL_THUMBNAIL_OFFSET    0x1bd000
#define CAMERASRC_MAX_MAIN_JPEG_SIZE            CAMERASRC_JPG_STILL_H_SYNC * CAMERASRC_JPG_STILL_V_SYNC /* 0x1bd000 */
#define CAMERASRC_MAX_THM_JPEG_SIZE             0
#define CAMERASRC_PREVIEW_BUFFER_NUM            6
#define CAMERASRC_VIDEO_BUFFER_NUM              7
#define CAMERASRC_STILL_BUFFER_NUM              1
#define CAMERASRC_YUV_THMBNL_SIZE               320 * 240 * 2
#define CAMERASRC_TIMEOUT_CRITICAL_VALUE        5000
#define CAMERASRC_PRE_AF_INTERVAL               0
#define CAMERASRC_REGISTER_SET_RETRY_NO         200
#define CAMERASRC_V4L2_PREVIEW_PIX_FMT_DEFAULT          V4L2_PIX_FMT_YUYV
#define CAMERASRC_V4L2_JPEG_CAPTURE_PIX_FMT_DEFAULT     V4L2_PIX_FMT_JPEG
#define CAMERASRC_V4L2_JPG_YUV_CAPTURE_PIX_FMT_DEFAULT  V4L2_PIX_FMT_MJPEG
#define CAMERASRC_V4L2_RGB_CAPTURE_PIX_FMT_DEFAULT      V4L2_PIX_FMT_RGB565

#define CAMERASRC_SYNC_KEY_PATH                 "FUJITSU_M5MOLS"
#define CAMERASRC_SYNC_KEY_PREFIX               0x55

#define CAMERASRC_AF_DELAY_AFTER_SET_AF_AREA    350 /* msec */

#define _CAMERASRC_EXIF_COMP_CONF               (0x00000000) | (0x00000001) | (0x00000002 << 8) | (0x00000003 << 16)    /* Y Cb Cr - */
#define _CAMERASRC_EXIF_COLORSPACE              0x00000001
#define _CAMERASRC_EXIF_FOCAL_LEN_NUM           454
#define _CAMERASRC_EXIF_FOCAL_LEN_DEN           100
#define _CAMERASRC_EXIF_F_NUM_NUM               28
#define _CAMERASRC_EXIF_F_NUM_DEN               10
#define _CAMERASRC_EXIF_MAX_F_NUM_NUM_IN_APEX   3

#define _CAMERASRC_CMD_SUPPORT_EMBED_EXIF_DEF   0

/*
 * |------------------------------------------------------------|
 * |             | Primary   | Secondary | Extension| Unknown   |
 * |------------------------------------------------------------|
 * |   Index     |    2      |     1     |    0     |    -1     |
 * |------------------------------------------------------------|
 *
 * |------------------------------------------------------------|
 * |             |    0      |     1     |    2     |     3     |
 * |------------------------------------------------------------|
 * |   ID        | Unknown   | Secondary | Primary  | Extension |
 * |------------------------------------------------------------|
 */

static int _camerasrc_dev_index[CAMERASRC_DEV_ID_NUM][CAMERASRC_DEV_RECOG_NUM] =
{
    {CAMERASRC_DEV_ID_SECONDARY, 0},
    {CAMERASRC_DEV_ID_PRIMARY, 1},
    {CAMERASRC_DEV_ID_EXTENSION, 2},
    {CAMERASRC_DEV_ID_UNKNOWN, -1},
};


/**
 * preset size index
 * |-------------------------------------------------------------------------|
 * |             |             |  YUV422P  |  YUV420P |  SRGGB8   | SRGGB10  |
 * |-------------------------------------------------------------------------|
 * |             | Highquality |     O     |    X     |     X     |     X    |
 * |    RAW      |-----------------------------------------------------------|
 * |             | Normal      |     O     |    X     |     X     |     X    |
 * |-------------------------------------------------------------------------|
 * |             | Highquality |     X     |    X     |     O     |     X    |
 * |    JPEG     |-----------------------------------------------------------|
 * |             | Normal      |     X     |    X     |     X     |     X    |
 * |-------------------------------------------------------------------------|
 */
static char _camerasrc_match_col_to_pix[CAMERASRC_DEV_ID_EXTENSION][CAMERASRC_COL_NUM][CAMERASRC_PIX_NUM][CAMERASRC_QUALITY_NUM] =
{
    {/*SECONDARY*/
        /*422P,     420P,      SRGGB8,    SRGGB10*/
        {{0x1,0x0}, {0x0,0x0}, {0x0,0x0}, {0x0,0x0}},   /**< RAW */
        {{0x0,0x0}, {0x0,0x0}, {0x0,0x0}, {0x0,0x0}},   /**< JPG */
    },
    {/*PRIMARY*/
        /*422P,     420P,      SRGGB8,    SRGGB10 */
        {{0x1,0x0}, {0x0,0x0}, {0x0,0x0}, {0x0,0x0}},   /**< RAW */
        {{0x0,0x0}, {0x0,0x0}, {0x0,0x1}, {0x0,0x1}},   /**< JPG */
    },
}; /* {Normal quality, High quality} */

/*
 * |--------------------------------------------------------------------------------|
 * |               | Support   | MAX value | MIN value |   CID                      |
 * |--------------------------------------------------------------------------------|
 * | Brightness    |    1      |     8     |    0      | V4L2_CID_BRIGHTNESS        |
 * |--------------------------------------------------------------------------------|
 * | Contrast      |    1      |     9     |    0      |    -1                      |
 * |--------------------------------------------------------------------------------|
 * | Digital zoom  |    1      |    100    |    0      |  V4L2_CID_BASE+29          |
 * |--------------------------------------------------------------------------------|
 * | Optical zoom  |    0      |    -1     |   -1      |    -1                      |
 * |--------------------------------------------------------------------------------|
 * | White balance |    1      |     9     |    0      |  V4L2_CID_DO_WHITE_BALANCE |
 * |--------------------------------------------------------------------------------|
 * | Color tone    |    1      |    14     |    0      |  V4L2_CID_BASE+28          |
 * |--------------------------------------------------------------------------------|
 * | Program mode  |    0      |    -1     |   -1      |    -1                      |
 * |--------------------------------------------------------------------------------|
 * | Flip          |    1      |     1     |    0      |  V4L2_CID_FLIP             |
 * |--------------------------------------------------------------------------------|
 * | Flash         |    1      |     2     |    0      |  V4L2_CID_BASE+32          |
 * |--------------------------------------------------------------------------------|
 */

/* CUSTOM V4L2 CONTROL ID DEFINITIONS */

#define CAM_AF_STATUS_ONGOING  0
#define CAM_AF_STATUS_FOCUSED  1
#define CAM_AF_STATUS_FAILED   2

enum {
    CAMERASRC_SENSOR_AF_STATUS_ONGOING  = CAM_AF_STATUS_ONGOING,
    CAMERASRC_SENSOR_AF_STATUS_FOCUSED  = CAM_AF_STATUS_FOCUSED,
    CAMERASRC_SENSOR_AF_STATUS_FAILED   = CAM_AF_STATUS_FAILED
};

/* FACE_DETECTION CMD & STATUS */
#define V4L2_CID_FACE_DETECTION        (V4L2_CID_PRIVATE_BASE + 38)

#define CAM_FACE_DETECTION_OFF     0
#define CAM_FACE_DETECTION_ON      1

/* ESD INTERRUPT CHECK */
/*To read interrupt status of "Data output stop from sensor"*/
#define V4L2_CID_ESD_INT               (V4L2_CID_PRIVATE_BASE + 40)

#define CAM_ESD_INT_NORMAL         0
#define CAM_ESD_INT_TROUBLE        1


/* CUSTOM V4L2 CONTROL ID DEFINITIONS (END) */
static int _camerasrc_ctrl_list[CAMERASRC_DEV_ID_EXTENSION][CAMERASRC_CTRL_NUM][CAMERASRC_CTRL_PROPERTY_NUM] =
{       /* { SUPPORT, MAX_VALUE, MIN_VALUE, CID, CURRENT_VALUE } */
    {   /* Primary camera */
        {-1, 4, -4, V4L2_CID_EXPOSURE, 0},              /* Brightness */
        {-1, 3, -3, V4L2_CID_CONTRAST, 0},              /* Contrast */
        {-1, 30, 0, V4L2_CID_CAMERA_ZOOM, 0},           /* Digital zoom */
        {0,  -1, -1, -1, -1},                           /* Optical zoom */
        {-1, CAMERASRC_WHITEBALANCE_HORIZON, CAMERASRC_WHITEBALANCE_AUTO, V4L2_CID_WHITE_BALANCE_PRESET, CAMERASRC_WHITEBALANCE_AUTO},          /* White balance */
        {-1, CAMERASRC_COLORTONE_ANTIQUE, CAMERASRC_COLORTONE_NONE, V4L2_CID_COLORFX, CAMERASRC_COLORTONE_NONE},                                /* Colortone */
        {-1, CAMERASRC_PROGRAM_MODE_BACK_LIGHT, CAMERASRC_PROGRAM_MODE_NORMAL, V4L2_CID_CAMERA_SCENE_MODE, CAMERASRC_PROGRAM_MODE_NORMAL},      /* program mode */
        {0,  -1, -1, -1, -1},                           /* Flip. V4L2_CID_VFLIP/HFLIP */
        {0,  -1, -1, -1, -1},                           /* PARTCOLOR_SRC */
        {0,  -1, -1, -1, -1},                           /* PARTCOLOR_DST */
        {0,  -1, -1, -1, -1},                           /* PARTCOLOR_MODE */
        {-1, 3, 0, V4L2_CID_CAM_STABILIZE, 0},          /* ANTI_HANDSHAKE */
        {-1, 2, 0, V4L2_CID_CAM_DR, 0},                 /* WIDE_DYNAMIC_RANGE */
        {-1, 3, -3, V4L2_CID_SATURATION, 0},            /* SATURATION */
        {-1, 3, -3, V4L2_CID_SHARPNESS, 0},             /* SHARPNESS */
        {-1,  -1, -1, V4L2_CID_CAMERA_ISO, -1},         /* ISO */
        {-1,  -1, -1, V4L2_CID_CAMERA_METERING, -1},    /* PHOTOMETRY */
    },
    {   /* Secondary camera */
        {0,  -1, -1, V4L2_CID_CAMERA_BRIGHTNESS, -1},   /* Brightness */
        {0,  -1, -1, V4L2_CID_CONTRAST, -1},            /* Contrast */
        {0,  -1, -1, V4L2_CID_ZOOM_ABSOLUTE, -1},       /* Digital zoom */
        {0,  -1, -1, -1, -1},                           /* Optical zoom */
        {0,  -1, -1, V4L2_CID_WHITE_BALANCE_PRESET, -1},/* White balance */
        {0,  -1, -1, V4L2_CID_COLORFX, -1},             /* Colortone */
        {0,  -1, -1, V4L2_CID_CAMERA_SCENE_MODE, -1},   /* program mode */
        {0,  -1, -1, -1, -1},                           /* Flip */
        {0,  -1, -1, -1, -1},                           /* PARTCOLOR_SRC */
        {0,  -1, -1, -1, -1},                           /* PARTCOLOR_DST */
        {0,  -1, -1, -1, -1},                           /* PARTCOLOR_MODE */
        {0,  -1, -1, V4L2_CID_CAM_STABILIZE, -1},       /* ANTI_HANDSHAKE */
        {0,  -1, -1, V4L2_CID_CAM_DR, -1},              /* WIDE_DYNAMIC_RANGE */
        {0,  -1, -1, V4L2_CID_SATURATION, -1},          /* SATURATION */
        {0,  -1, -1, V4L2_CID_SHARPNESS, -1},           /* SHARPNESS */
        {0,  -1, -1, V4L2_CID_CAMERA_ISO, -1},          /* ISO */
        {0,  -1, -1, V4L2_CID_CAMERA_METERING, -1},     /* PHOTOMETRY */
    },
};

static char _camerasrc_misc_func_list[CAMERASRC_DEV_ID_EXTENSION][CAMERASRC_OP_REGISTER_VALUE][CAMERASRC_COL_NUM][CAMERASRC_MISC_FUNC_NUM] =
{
    {/*Primary*/
        /*Raw,       JPG*/
        {{0x0,0x1}, {0x0,0x0}}, /*Preview*/
        {{0x0,0x1}, {0x0,0x0}}, /*Capture*/
        {{0x0,0x1}, {0x0,0x0}}, /*Video*/
    },
    {/*Secondary*/
        {{0x0,0x0}, {0x0,0x0}}, /*Preview*/
        {{0x0,0x0}, {0x0,0x0}}, /*Capture*/
        {{0x0,0x0}, {0x0,0x0}}, /*Video*/
    }/*{{Signal,Skip}, {Signal,Skip}}*/
};

static int _camerasrc_af_support[CAMERASRC_DEV_ID_NUM] = {1, 0, 0, 0};

#ifdef __cplusplus
}
#endif

#endif /*__CAMERASRC_INTERNAL_H__*/