codeworkx | 62f02ba | 2012-05-20 12:00:36 +0200 | [diff] [blame] | 1 | /* |
| 2 | ** |
| 3 | ** Copyright 2008, The Android Open Source Project |
| 4 | ** Copyright 2010, Samsung Electronics Co. LTD |
| 5 | ** |
| 6 | ** Licensed under the Apache License, Version 2.0 (the "License"); |
| 7 | ** you may not use this file except in compliance with the License. |
| 8 | ** You may obtain a copy of the License at |
| 9 | ** |
| 10 | ** http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | ** |
| 12 | ** Unless required by applicable law or agreed to in writing, software |
| 13 | ** distributed under the License is distributed on an "AS IS" BASIS, |
| 14 | ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 15 | ** See the License for the specific language governing permissions and |
| 16 | ** limitations under the License. |
| 17 | */ |
| 18 | |
| 19 | #ifndef ANDROID_HARDWARE_CAMERA_SEC_H |
| 20 | #define ANDROID_HARDWARE_CAMERA_SEC_H |
| 21 | |
| 22 | #include <stdio.h> |
| 23 | #include <string.h> |
| 24 | #include <stdlib.h> |
| 25 | |
| 26 | #include <fcntl.h> |
| 27 | #include <unistd.h> |
| 28 | #include <errno.h> |
| 29 | #include <signal.h> |
| 30 | #include <sys/mman.h> |
| 31 | #include <sys/time.h> |
| 32 | #include <sys/ioctl.h> |
| 33 | #include <sys/poll.h> |
| 34 | #include <sys/stat.h> |
| 35 | #include <sys/types.h> |
| 36 | |
| 37 | #include <utils/RefBase.h> |
| 38 | #include <videodev2.h> |
| 39 | #include <videodev2_samsung.h> |
| 40 | #include <linux/vt.h> |
| 41 | |
| 42 | #include <media.h> |
| 43 | #include <v4l2-mediabus.h> |
| 44 | #include <v4l2-subdev.h> |
| 45 | |
| 46 | #include <sec_utils_v4l2.h> |
| 47 | |
| 48 | #include "SecBuffer.h" |
| 49 | |
| 50 | #include <mediactl.h> |
| 51 | #include <v4l2subdev.h> |
| 52 | |
| 53 | #include <utils/String8.h> |
| 54 | |
| 55 | #include "SecJpegEncoder.h" |
| 56 | |
| 57 | #include "Exif.h" |
| 58 | namespace android { |
| 59 | |
| 60 | //#define ENABLE_ESD_PREVIEW_CHECK |
| 61 | |
Daniel Hillenbrand | 0fdadca | 2012-07-22 15:45:33 +0200 | [diff] [blame^] | 62 | #if defined(ALOG_NDEBUG) && (ALOG_NDEBUG == 0) |
| 63 | #define LOG_CAMERA ALOGD |
| 64 | #define LOG_CAMERA_PREVIEW ALOGD |
codeworkx | 62f02ba | 2012-05-20 12:00:36 +0200 | [diff] [blame] | 65 | |
| 66 | #define LOG_TIME_DEFINE(n) \ |
| 67 | struct timeval time_start_##n, time_stop_##n; unsigned long log_time_##n = 0; |
| 68 | |
| 69 | #define LOG_TIME_START(n) \ |
| 70 | gettimeofday(&time_start_##n, NULL); |
| 71 | |
| 72 | #define LOG_TIME_END(n) \ |
| 73 | gettimeofday(&time_stop_##n, NULL); log_time_##n = measure_time_camera(&time_start_##n, &time_stop_##n); |
| 74 | |
| 75 | #define LOG_TIME(n) \ |
| 76 | log_time_##n |
| 77 | |
| 78 | #else |
| 79 | #define LOG_CAMERA(...) |
| 80 | #define LOG_CAMERA_PREVIEW(...) |
| 81 | #define LOG_TIME_DEFINE(n) |
| 82 | #define LOG_TIME_START(n) |
| 83 | #define LOG_TIME_END(n) |
| 84 | #define LOG_TIME(n) |
| 85 | #endif |
| 86 | |
| 87 | #define JOIN(x, y) JOIN_AGAIN(x, y) |
| 88 | #define JOIN_AGAIN(x, y) x ## y |
| 89 | |
| 90 | #define FRONT_CAM M5MO |
| 91 | #define BACK_CAM S5K4E5 |
| 92 | |
| 93 | #if !defined (FRONT_CAM) || !defined(BACK_CAM) |
| 94 | #error "Please define the Camera module" |
| 95 | #endif |
| 96 | |
| 97 | #define M5MO_PREVIEW_WIDTH 1920 |
| 98 | #define M5MO_PREVIEW_HEIGHT 1080 |
| 99 | #define M5MO_SNAPSHOT_WIDTH 3264 |
| 100 | #define M5MO_SNAPSHOT_HEIGHT 2448 |
| 101 | |
| 102 | #define M5MO_THUMBNAIL_WIDTH 320 |
| 103 | #define M5MO_THUMBNAIL_HEIGHT 240 |
| 104 | #define M5MO_THUMBNAIL_BPP 16 |
| 105 | |
| 106 | #define M5MO_FPS 30 |
| 107 | |
| 108 | /* focal length of 3.43mm */ |
| 109 | #define M5MO_FOCAL_LENGTH 343 |
| 110 | |
| 111 | #define S5K4E5_PREVIEW_WIDTH 1920 |
| 112 | #define S5K4E5_PREVIEW_HEIGHT 1080 |
| 113 | #define S5K4E5_SNAPSHOT_WIDTH 1920 |
| 114 | #define S5K4E5_SNAPSHOT_HEIGHT 1080 |
| 115 | |
| 116 | #define S5K4E5_THUMBNAIL_WIDTH 320 |
| 117 | #define S5K4E5_THUMBNAIL_HEIGHT 240 |
| 118 | #define S5K4E5_THUMBNAIL_BPP 16 |
| 119 | |
| 120 | #define S5K4E5_FPS 30 |
| 121 | |
| 122 | /* focal length of 0.9mm */ |
| 123 | #define S5K4E5_FOCAL_LENGTH 90 |
| 124 | |
| 125 | #define MAX_BACK_CAMERA_PREVIEW_WIDTH JOIN(BACK_CAM,_PREVIEW_WIDTH) |
| 126 | #define MAX_BACK_CAMERA_PREVIEW_HEIGHT JOIN(BACK_CAM,_PREVIEW_HEIGHT) |
| 127 | #define MAX_BACK_CAMERA_SNAPSHOT_WIDTH JOIN(BACK_CAM,_SNAPSHOT_WIDTH) |
| 128 | #define MAX_BACK_CAMERA_SNAPSHOT_HEIGHT JOIN(BACK_CAM,_SNAPSHOT_HEIGHT) |
| 129 | |
| 130 | #define BACK_CAMERA_THUMBNAIL_WIDTH JOIN(BACK_CAM,_THUMBNAIL_WIDTH) |
| 131 | #define BACK_CAMERA_THUMBNAIL_HEIGHT JOIN(BACK_CAM,_THUMBNAIL_HEIGHT) |
| 132 | #define BACK_CAMERA_THUMBNAIL_BPP JOIN(BACK_CAM,_THUMBNAIL_BPP) |
| 133 | |
| 134 | #define BACK_CAMERA_FPS JOIN(BACK_CAM,_FPS) |
| 135 | |
| 136 | #define BACK_CAMERA_FOCAL_LENGTH JOIN(BACK_CAM,_FOCAL_LENGTH) |
| 137 | |
| 138 | #define MAX_FRONT_CAMERA_PREVIEW_WIDTH JOIN(FRONT_CAM,_PREVIEW_WIDTH) |
| 139 | #define MAX_FRONT_CAMERA_PREVIEW_HEIGHT JOIN(FRONT_CAM,_PREVIEW_HEIGHT) |
| 140 | #define MAX_FRONT_CAMERA_SNAPSHOT_WIDTH JOIN(FRONT_CAM,_SNAPSHOT_WIDTH) |
| 141 | #define MAX_FRONT_CAMERA_SNAPSHOT_HEIGHT JOIN(FRONT_CAM,_SNAPSHOT_HEIGHT) |
| 142 | |
| 143 | #define FRONT_CAMERA_THUMBNAIL_WIDTH JOIN(FRONT_CAM,_THUMBNAIL_WIDTH) |
| 144 | #define FRONT_CAMERA_THUMBNAIL_HEIGHT JOIN(FRONT_CAM,_THUMBNAIL_HEIGHT) |
| 145 | #define FRONT_CAMERA_THUMBNAIL_BPP JOIN(FRONT_CAM,_THUMBNAIL_BPP) |
| 146 | |
| 147 | #define FRONT_CAMERA_FPS JOIN(FRONT_CAM,_FPS) |
| 148 | |
| 149 | #define FRONT_CAMERA_FOCAL_LENGTH JOIN(FRONT_CAM,_FOCAL_LENGTH) |
| 150 | |
| 151 | #define DEFAULT_JPEG_THUMBNAIL_WIDTH 256 |
| 152 | #define DEFAULT_JPEG_THUMBNAIL_HEIGHT 192 |
| 153 | |
| 154 | #define PFX_NODE_GSC "/dev/video" |
| 155 | |
| 156 | #define M5MOLS_ENTITY_NAME "M5MOLS 5-001f" |
| 157 | #define PFX_SUBDEV_ENTITY_MIPI_CSIS "s5p-mipi-csis" |
| 158 | #define PFX_SUBDEV_ENTITY_FLITE "exynos-fimc-lite" |
| 159 | #define PFX_SUBDEV_ENTITY_GSC_CAP "gsc-cap-subdev" |
| 160 | #define PFX_VIDEODEV_ENTITY_GSC_CAP "exynos-gsc" |
| 161 | #define FIMD1_ENTITY_NAME "s5p-fimd1" |
| 162 | |
| 163 | #define GAIA_FW_BETA 1 |
| 164 | |
| 165 | #ifndef GAIA_FW_BETA |
| 166 | #define GSC_VD_NODE_OFFSET 25 //GSCALER 0 (0:25, 1:28, 2:31, 3:34) |
| 167 | #else |
| 168 | #define GSC_VD_NODE_OFFSET 41 //INTERNAL_ISP 4E5 |
| 169 | |
| 170 | #define ISP_SENSOR_MAX_ENTITIES 1 |
| 171 | #define ISP_SENSOR_PAD_SOURCE_FRONT 0 |
| 172 | #define ISP_SENSOR_PADS_NUM 1 |
| 173 | |
| 174 | #define ISP_FRONT_MAX_ENTITIES 1 |
| 175 | #define ISP_FRONT_PAD_SINK 0 |
| 176 | #define ISP_FRONT_PAD_SOURCE_BACK 1 |
| 177 | #define ISP_FRONT_PAD_SOURCE_BAYER 2 |
| 178 | #define ISP_FRONT_PAD_SOURCE_SCALERC 3 |
| 179 | #define ISP_FRONT_PADS_NUM 4 |
| 180 | |
| 181 | #define ISP_BACK_MAX_ENTITIES 1 |
| 182 | #define ISP_BACK_PAD_SINK 0 |
| 183 | #define ISP_BACK_PAD_SOURCE_3DNR 1 |
| 184 | #define ISP_BACK_PAD_SOURCE_SCALERP 2 |
| 185 | #define ISP_BACK_PADS_NUM 3 |
| 186 | |
| 187 | #define ISP_MODULE_NAME "exynos5-fimc-is" |
| 188 | #define ISP_SENSOR_ENTITY_NAME "exynos5-fimc-is-sensor" |
| 189 | #define ISP_FRONT_ENTITY_NAME "exynos5-fimc-is-front" |
| 190 | #define ISP_BACK_ENTITY_NAME "exynos5-fimc-is-back" |
| 191 | #define ISP_VIDEO_BAYER_NAME "exynos5-fimc-is-bayer" |
| 192 | #define ISP_VIDEO_SCALERC_NAME "exynos5-fimc-is-scalerc" |
| 193 | #define ISP_VIDEO_3DNR_NAME "exynos5-fimc-is-3dnr" |
| 194 | #define ISP_VIDEO_SCALERP_NAME "exynos5-fimc-is-scalerp" |
| 195 | |
| 196 | #endif |
| 197 | #define MIPI_NUM 1 |
| 198 | #define FLITE_NUM 1 |
| 199 | #define GSC_NUM 0 |
| 200 | |
| 201 | #define PFX_SUBDEV_NODE "/dev/v4l-subdev" |
| 202 | |
| 203 | #define BPP 2 |
| 204 | #define MIN(x, y) (((x) < (y)) ? (x) : (y)) |
| 205 | #ifndef GAIA_FW_BETA |
| 206 | #define MAX_BUFFERS 8 |
| 207 | #else |
| 208 | #define MAX_BUFFERS 4 //external : 8, internal : 4 |
| 209 | #endif |
| 210 | |
| 211 | #define MAX_PLANES (3) |
| 212 | #define V4L2_BUF_TYPE V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE |
| 213 | |
| 214 | #define V4L2_MEMORY_TYPE V4L2_MEMORY_USERPTR |
| 215 | #define RECORD_PIX_FMT V4L2_PIX_FMT_NV12M |
| 216 | #define PREVIEW_NUM_PLANE (3) |
| 217 | #define RECORD_NUM_PLANE (2) |
| 218 | |
| 219 | /* |
| 220 | * V 4 L 2 F I M C E X T E N S I O N S |
| 221 | * |
| 222 | */ |
| 223 | #define V4L2_CID_ROTATION (V4L2_CID_PRIVATE_BASE + 0) |
| 224 | #define V4L2_CID_PADDR_Y (V4L2_CID_PRIVATE_BASE + 1) |
| 225 | #define V4L2_CID_PADDR_CB (V4L2_CID_PRIVATE_BASE + 2) |
| 226 | #define V4L2_CID_PADDR_CR (V4L2_CID_PRIVATE_BASE + 3) |
| 227 | #define V4L2_CID_PADDR_CBCR (V4L2_CID_PRIVATE_BASE + 4) |
| 228 | #define V4L2_CID_STREAM_PAUSE (V4L2_CID_PRIVATE_BASE + 53) |
| 229 | |
| 230 | #define V4L2_CID_CAM_JPEG_MAIN_SIZE (V4L2_CID_PRIVATE_BASE + 32) |
| 231 | #define V4L2_CID_CAM_JPEG_MAIN_OFFSET (V4L2_CID_PRIVATE_BASE + 33) |
| 232 | #define V4L2_CID_CAM_JPEG_THUMB_SIZE (V4L2_CID_PRIVATE_BASE + 34) |
| 233 | #define V4L2_CID_CAM_JPEG_THUMB_OFFSET (V4L2_CID_PRIVATE_BASE + 35) |
| 234 | #define V4L2_CID_CAM_JPEG_POSTVIEW_OFFSET (V4L2_CID_PRIVATE_BASE + 36) |
| 235 | #define V4L2_CID_CAM_JPEG_QUALITY (V4L2_CID_PRIVATE_BASE + 37) |
| 236 | |
| 237 | #define TPATTERN_COLORBAR 1 |
| 238 | #define TPATTERN_HORIZONTAL 2 |
| 239 | #define TPATTERN_VERTICAL 3 |
| 240 | |
| 241 | #define V4L2_PIX_FMT_YVYU v4l2_fourcc('Y', 'V', 'Y', 'U') |
| 242 | |
| 243 | /* FOURCC for FIMC specific */ |
| 244 | #define V4L2_PIX_FMT_VYUY v4l2_fourcc('V', 'Y', 'U', 'Y') |
| 245 | #define V4L2_PIX_FMT_NV16 v4l2_fourcc('N', 'V', '1', '6') |
| 246 | #define V4L2_PIX_FMT_NV61 v4l2_fourcc('N', 'V', '6', '1') |
| 247 | #define V4L2_PIX_FMT_NV12T v4l2_fourcc('T', 'V', '1', '2') |
| 248 | /* |
| 249 | * U S E R D E F I N E D T Y P E S |
| 250 | * |
| 251 | */ |
| 252 | #define PREVIEW_MODE 1 |
| 253 | #define RECORD_MODE 2 |
| 254 | |
| 255 | /* We use this struct as the v4l2_streamparm raw_data for |
| 256 | * VIDIOC_G_PARM and VIDIOC_S_PARM |
| 257 | */ |
| 258 | struct sec_cam_parm { |
| 259 | struct v4l2_captureparm capture; |
| 260 | int contrast; |
| 261 | int effects; |
| 262 | int brightness; |
| 263 | int exposure; |
| 264 | int flash_mode; |
| 265 | int focus_mode; |
| 266 | int iso; |
| 267 | int metering; |
| 268 | int saturation; |
| 269 | int scene_mode; |
| 270 | int sharpness; |
| 271 | int hue; |
| 272 | int white_balance; |
| 273 | }; |
| 274 | |
| 275 | struct yuv_fmt_list { |
| 276 | const char *name; |
| 277 | const char *desc; |
| 278 | unsigned int fmt; |
| 279 | int depth; |
| 280 | int planes; |
| 281 | }; |
| 282 | |
| 283 | struct camsensor_date_info { |
| 284 | unsigned int year; |
| 285 | unsigned int month; |
| 286 | unsigned int date; |
| 287 | }; |
| 288 | |
| 289 | class SecCamera : public virtual RefBase { |
| 290 | public: |
| 291 | |
| 292 | enum CAMERA_ID { |
| 293 | CAMERA_ID_BACK = 0, |
| 294 | CAMERA_ID_FRONT = 1, |
| 295 | }; |
| 296 | |
| 297 | enum JPEG_QUALITY { |
| 298 | JPEG_QUALITY_ECONOMY = 0, |
| 299 | JPEG_QUALITY_NORMAL = 50, |
| 300 | JPEG_QUALITY_SUPERFINE = 100, |
| 301 | JPEG_QUALITY_MAX, |
| 302 | }; |
| 303 | |
| 304 | enum OBJECT_TRACKING { |
| 305 | OBJECT_TRACKING_OFF, |
| 306 | OBJECT_TRACKING_ON, |
| 307 | OBJECT_TRACKING_MAX, |
| 308 | }; |
| 309 | |
| 310 | /*VT call*/ |
| 311 | enum VT_MODE { |
| 312 | VT_MODE_OFF, |
| 313 | VT_MODE_ON, |
| 314 | VT_MODE_MAX, |
| 315 | }; |
| 316 | |
| 317 | /*Camera sensor mode - Camcorder fix fps*/ |
| 318 | enum SENSOR_MODE { |
| 319 | SENSOR_MODE_CAMERA, |
| 320 | SENSOR_MODE_MOVIE, |
| 321 | }; |
| 322 | |
| 323 | /*Camera Shot mode*/ |
| 324 | enum SHOT_MODE { |
| 325 | SHOT_MODE_SINGLE = 0, |
| 326 | SHOT_MODE_CONTINUOUS = 1, |
| 327 | SHOT_MODE_PANORAMA = 2, |
| 328 | SHOT_MODE_SMILE = 3, |
| 329 | SHOT_MODE_SELF = 6, |
| 330 | }; |
| 331 | |
| 332 | enum CHK_DATALINE { |
| 333 | CHK_DATALINE_OFF, |
| 334 | CHK_DATALINE_ON, |
| 335 | CHK_DATALINE_MAX, |
| 336 | }; |
| 337 | |
| 338 | int m_touch_af_start_stop; |
| 339 | |
| 340 | SecCamera(); |
| 341 | virtual ~SecCamera(); |
| 342 | |
| 343 | static SecCamera* createInstance(void) |
| 344 | { |
| 345 | static SecCamera singleton; |
| 346 | return &singleton; |
| 347 | } |
| 348 | status_t dump(int fd); |
| 349 | |
| 350 | bool CreateCamera(int index); |
| 351 | bool DestroyCamera(void); |
| 352 | int getCameraId(void); |
| 353 | |
| 354 | int startPreview(void); |
| 355 | int stopPreview(void); |
| 356 | int getPreviewState(void) |
| 357 | { |
| 358 | return m_preview_state; |
| 359 | } |
| 360 | void clearPreviewState(void) |
| 361 | { |
| 362 | m_preview_state = 0; |
| 363 | } |
| 364 | |
| 365 | int startRecord(void); |
| 366 | int stopRecord(void); |
| 367 | int setPreviewFrame(int index); |
| 368 | int getRecordFrame(void); |
| 369 | int releaseRecordFrame(int index); |
| 370 | int getRecordAddr(int index, SecBuffer *buffer); |
| 371 | |
| 372 | int getPreview(void); |
| 373 | int setPreviewSize(int width, int height, int pixel_format); |
| 374 | int getPreviewSize(int *width, int *height, int *frame_size); |
| 375 | int getPreviewMaxSize(int *width, int *height); |
| 376 | int getPreviewPixelFormat(void); |
| 377 | int setPreviewImage(int index, unsigned char *buffer, int size); |
| 378 | |
| 379 | int setSnapshotSize(int width, int height); |
| 380 | int getSnapshotSize(int *width, int *height, int *frame_size); |
| 381 | int getSnapshotMaxSize(int *width, int *height); |
| 382 | int setSnapshotPixelFormat(int pixel_format); |
| 383 | int getSnapshotPixelFormat(void); |
| 384 | |
| 385 | unsigned char* getJpeg(unsigned char *snapshot_data, int snapshot_size, int *size); |
| 386 | unsigned char* yuv2Jpeg(unsigned char *raw_data, int raw_size, |
| 387 | int *jpeg_size, |
| 388 | int width, int height, int pixel_format); |
| 389 | |
| 390 | int setJpegThumbnailSize(int width, int height); |
| 391 | int getJpegThumbnailSize(int *width, int *height); |
| 392 | |
| 393 | int setJpegThumbnailQuality(int jpeg_thumbnail_quality); |
| 394 | int getJpegThumbnailQuality(void); |
| 395 | |
| 396 | int setAutofocus(void); |
| 397 | |
| 398 | int SetRotate(int angle); |
| 399 | int getRotate(void); |
| 400 | |
| 401 | int setVerticalMirror(void); |
| 402 | int setHorizontalMirror(void); |
| 403 | |
| 404 | int setWhiteBalance(int white_balance); |
| 405 | int getWhiteBalance(void); |
| 406 | |
| 407 | int setBrightness(int brightness); |
| 408 | int getBrightness(void); |
| 409 | |
| 410 | int setExposure(int exposure); |
| 411 | int getExposure(void); |
| 412 | |
| 413 | int setImageEffect(int image_effect); |
| 414 | int getImageEffect(void); |
| 415 | |
| 416 | int setSceneMode(int scene_mode); |
| 417 | int getSceneMode(void); |
| 418 | |
| 419 | int setFlashMode(int flash_mode); |
| 420 | int getFlashMode(void); |
| 421 | |
| 422 | int setMetering(int metering_value); |
| 423 | int getMetering(void); |
| 424 | |
| 425 | int setISO(int iso_value); |
| 426 | int getISO(void); |
| 427 | |
| 428 | int setContrast(int contrast_value); |
| 429 | int getContrast(void); |
| 430 | |
| 431 | int setSaturation(int saturation_value); |
| 432 | int getSaturation(void); |
| 433 | |
| 434 | int setSharpness(int sharpness_value); |
| 435 | int getSharpness(void); |
| 436 | |
| 437 | int setHue(int hue_value); |
| 438 | int getHue(void); |
| 439 | |
| 440 | int setWDR(int wdr_value); |
| 441 | int getWDR(void); |
| 442 | |
| 443 | int setAntiShake(int anti_shake); |
| 444 | int getAntiShake(void); |
| 445 | |
| 446 | int setJpegQuality(int jpeg_qality); |
| 447 | int getJpegQuality(void); |
| 448 | |
| 449 | int setZoom(int zoom_level); |
| 450 | int getZoom(void); |
| 451 | |
| 452 | int setObjectTracking(int object_tracking); |
| 453 | int getObjectTracking(void); |
| 454 | int getObjectTrackingStatus(void); |
| 455 | |
| 456 | int setSmartAuto(int smart_auto); |
| 457 | int getSmartAuto(void); |
| 458 | int getAutosceneStatus(void); |
| 459 | |
| 460 | int setBeautyShot(int beauty_shot); |
| 461 | int getBeautyShot(void); |
| 462 | |
| 463 | int setVintageMode(int vintage_mode); |
| 464 | int getVintageMode(void); |
| 465 | |
| 466 | int setFocusMode(int focus_mode); |
| 467 | int getFocusMode(void); |
| 468 | |
| 469 | int setFaceDetect(int face_detect); |
| 470 | int getFaceDetect(void); |
| 471 | |
| 472 | int setGPSLatitude(const char *gps_latitude); |
| 473 | int setGPSLongitude(const char *gps_longitude); |
| 474 | int setGPSAltitude(const char *gps_altitude); |
| 475 | int setGPSTimeStamp(const char *gps_timestamp); |
| 476 | int setGPSProcessingMethod(const char *gps_timestamp); |
| 477 | int cancelAutofocus(void); |
| 478 | int setFaceDetectLockUnlock(int facedetect_lockunlock); |
| 479 | int setObjectPosition(int x, int y); |
| 480 | int setObjectTrackingStartStop(int start_stop); |
| 481 | int setTouchAFStartStop(int start_stop); |
| 482 | int setCAFStatus(int on_off); |
| 483 | int getAutoFocusResult(void); |
| 484 | int setAntiBanding(int anti_banding); |
| 485 | int getPostview(void); |
| 486 | int setRecording(int recording_en); |
| 487 | int setRecordingSize(int width, int height); |
| 488 | int getRecordingSize(int *width, int *height); |
| 489 | int setGamma(int gamma); |
| 490 | int setSlowAE(int slow_ae); |
| 491 | int setExifOrientationInfo(int orientationInfo); |
| 492 | int setBatchReflection(void); |
| 493 | int setSnapshotCmd(void); |
| 494 | int endSnapshot(void); |
| 495 | int setCameraSensorReset(void); |
| 496 | int setSensorMode(int sensor_mode); /* Camcorder fix fps */ |
| 497 | int setShotMode(int shot_mode); /* Shot mode */ |
| 498 | int setDataLineCheck(int chk_dataline); |
| 499 | int getDataLineCheck(void); |
| 500 | int setDataLineCheckStop(void); |
| 501 | int setDefultIMEI(int imei); |
| 502 | int getDefultIMEI(void); |
| 503 | const __u8* getCameraSensorName(void); |
| 504 | #ifdef ENABLE_ESD_PREVIEW_CHECK |
| 505 | int getCameraSensorESDStatus(void); |
| 506 | #endif // ENABLE_ESD_PREVIEW_CHECK |
| 507 | |
| 508 | int setFrameRate(int frame_rate); |
| 509 | unsigned char* getJpeg(int*, unsigned int*); |
| 510 | int getSnapshotAndJpeg(unsigned char *yuv_buf, unsigned char *jpeg_buf, |
| 511 | unsigned int *output_size); |
| 512 | int getExif(unsigned char *pExifDst, unsigned char *pThumbSrc); |
| 513 | |
| 514 | void getPostViewConfig(int*, int*, int*); |
| 515 | void getThumbnailConfig(int *width, int *height, int *size); |
| 516 | |
| 517 | int getPostViewOffset(void); |
| 518 | int getCameraFd(void); |
| 519 | unsigned char* getPictureVaddr(void); |
| 520 | int getJpegFd(void); |
| 521 | void SetJpgAddr(unsigned char *addr); |
| 522 | int getPreviewAddr(int index, SecBuffer *buffer); |
| 523 | void setUserBufferAddr(void *ptr, int index, int mode); |
| 524 | static void setJpegRatio(double ratio) |
| 525 | { |
| 526 | if((ratio < 0) || (ratio > 1)) |
| 527 | return; |
| 528 | |
| 529 | jpeg_ratio = ratio; |
| 530 | } |
| 531 | |
| 532 | static double getJpegRatio() |
| 533 | { |
| 534 | return jpeg_ratio; |
| 535 | } |
| 536 | |
| 537 | static void setInterleaveDataSize(int x) |
| 538 | { |
| 539 | interleaveDataSize = x; |
| 540 | } |
| 541 | |
| 542 | static int getInterleaveDataSize() |
| 543 | { |
| 544 | return interleaveDataSize; |
| 545 | } |
| 546 | |
| 547 | static void setJpegLineLength(int x) |
| 548 | { |
| 549 | jpegLineLength = x; |
| 550 | } |
| 551 | |
| 552 | static int getJpegLineLength() |
| 553 | { |
| 554 | return jpegLineLength; |
| 555 | } |
| 556 | |
| 557 | private: |
| 558 | v4l2_streamparm m_streamparm; |
| 559 | struct sec_cam_parm *m_params; |
| 560 | int m_flagCreate; |
| 561 | int m_preview_state; |
| 562 | int m_camera_id; |
| 563 | |
| 564 | /* v4l2 sub-dev file description */ |
| 565 | int m_cam_sd_fd; |
| 566 | int m_mipi_sd_fd; |
| 567 | int m_flite_sd_fd; |
| 568 | int m_gsc_sd_fd; |
| 569 | int m_gsc_vd_fd; |
| 570 | |
| 571 | /* media controller variable */ |
| 572 | struct media_device *media; |
| 573 | struct media_link *links; |
| 574 | struct media_pad *pads; |
| 575 | |
| 576 | struct media_entity *camera_sd_entity; |
| 577 | struct media_entity *mipi_sd_entity; |
| 578 | struct media_entity *flite_sd_entity; |
| 579 | struct media_entity *gsc_cap_sd_entity; |
| 580 | struct media_entity *gsc_cap_vd_entity; |
| 581 | struct media_entity *isp_sensor_entity; |
| 582 | struct media_entity *isp_front_entity; |
| 583 | struct media_entity *isp_back_entity; |
| 584 | struct media_entity *isp_scalerc_entity; |
| 585 | struct media_entity *isp_scalerp_entity; |
| 586 | struct media_entity *isp_3dnr_entity; |
| 587 | |
| 588 | int m_cam_fd; |
| 589 | |
| 590 | int m_cam_fd2; |
| 591 | struct pollfd m_events_c2; |
| 592 | int m_flag_record_start; |
| 593 | |
| 594 | int m_preview_v4lformat; |
| 595 | int m_preview_width; |
| 596 | int m_preview_height; |
| 597 | int m_preview_max_width; |
| 598 | int m_preview_max_height; |
| 599 | |
| 600 | int m_snapshot_v4lformat; |
| 601 | int m_snapshot_width; |
| 602 | int m_snapshot_height; |
| 603 | int m_snapshot_max_width; |
| 604 | int m_snapshot_max_height; |
| 605 | unsigned char* m_picture_vaddr; |
| 606 | |
| 607 | int m_angle; |
| 608 | int m_anti_banding; |
| 609 | int m_wdr; |
| 610 | int m_anti_shake; |
| 611 | int m_zoom_level; |
| 612 | int m_object_tracking; |
| 613 | int m_smart_auto; |
| 614 | int m_beauty_shot; |
| 615 | int m_vintage_mode; |
| 616 | int m_face_detect; |
| 617 | int m_object_tracking_start_stop; |
| 618 | int m_recording_en; |
| 619 | int m_recording_width; |
| 620 | int m_recording_height; |
| 621 | long m_gps_latitude; |
| 622 | long m_gps_longitude; |
| 623 | long m_gps_altitude; |
| 624 | long m_gps_timestamp; |
| 625 | int m_sensor_mode; /*Camcorder fix fps */ |
| 626 | int m_shot_mode; /* Shot mode */ |
| 627 | int m_exif_orientation; |
| 628 | int m_chk_dataline; |
| 629 | int m_video_gamma; |
| 630 | int m_slow_ae; |
| 631 | int m_camera_af_flag; |
| 632 | |
| 633 | int m_flag_camera_start; |
| 634 | |
| 635 | int m_jpeg_fd; |
| 636 | int m_jpeg_thumbnail_width; |
| 637 | int m_jpeg_thumbnail_height; |
| 638 | int m_jpeg_thumbnail_quality; |
| 639 | int m_jpeg_quality; |
| 640 | |
| 641 | int m_postview_offset; |
| 642 | |
| 643 | #ifdef ENABLE_ESD_PREVIEW_CHECK |
| 644 | int m_esd_check_count; |
| 645 | #endif // ENABLE_ESD_PREVIEW_CHECK |
| 646 | |
| 647 | exif_attribute_t mExifInfo; |
| 648 | |
| 649 | struct SecBuffer m_capture_buf; |
| 650 | struct SecBuffer m_buffers_preview[MAX_BUFFERS]; |
| 651 | struct SecBuffer m_buffers_record[MAX_BUFFERS]; |
| 652 | struct pollfd m_events_c; |
| 653 | |
| 654 | inline void writeExifIfd(unsigned char **pCur, |
| 655 | unsigned short tag, |
| 656 | unsigned short type, |
| 657 | unsigned int count, |
| 658 | uint32_t value); |
| 659 | inline void writeExifIfd(unsigned char **pCur, |
| 660 | unsigned short tag, |
| 661 | unsigned short type, |
| 662 | unsigned int count, |
| 663 | unsigned char *pValue); |
| 664 | inline void writeExifIfd(unsigned char **pCur, |
| 665 | unsigned short tag, |
| 666 | unsigned short type, |
| 667 | unsigned int count, |
| 668 | rational_t *pValue, |
| 669 | unsigned int *offset, |
| 670 | unsigned char *start); |
| 671 | inline void writeExifIfd(unsigned char **pCur, |
| 672 | unsigned short tag, |
| 673 | unsigned short type, |
| 674 | unsigned int count, |
| 675 | unsigned char *pValue, |
| 676 | unsigned int *offset, |
| 677 | unsigned char *start); |
| 678 | |
| 679 | void setExifChangedAttribute(); |
| 680 | void setExifFixedAttribute(); |
| 681 | int makeExif (unsigned char *exifOut, |
| 682 | unsigned char *thumb_buf, |
| 683 | unsigned int thumb_size, |
| 684 | exif_attribute_t *exifInfo, |
| 685 | unsigned int *size, |
| 686 | bool useMainbufForThumb); |
| 687 | void resetCamera(); |
| 688 | |
| 689 | static double jpeg_ratio; |
| 690 | static int interleaveDataSize; |
| 691 | static int jpegLineLength; |
| 692 | }; |
| 693 | |
| 694 | extern unsigned long measure_time_camera(struct timeval *start, struct timeval *stop); |
| 695 | |
| 696 | }; // namespace android |
| 697 | |
| 698 | #endif // ANDROID_HARDWARE_CAMERA_SEC_H |