summaryrefslogtreecommitdiffstats
path: root/libcamera
diff options
context:
space:
mode:
authorJeong-Seok Yang <jseok.yang@samsung.com>2010-09-19 21:17:26 -0700
committerSimon Wilson <simonwilson@google.com>2010-09-21 16:11:49 -0700
commit26932dec9142f3e1ac3a3648f68aee34c492756f (patch)
tree2c9624be27932d9d234a23d2022d2622664736df /libcamera
parent16c0970274f534702931eadb0e5de9768b19482a (diff)
downloaddevice_samsung_crespo-26932dec9142f3e1ac3a3648f68aee34c492756f.zip
device_samsung_crespo-26932dec9142f3e1ac3a3648f68aee34c492756f.tar.gz
device_samsung_crespo-26932dec9142f3e1ac3a3648f68aee34c492756f.tar.bz2
libcamera: Clean up code
Removed inconsistent coding style. Aligned better. Change-Id: Ib6fa351cc39ede6881ed4937594689246b87bca8 Signed-off-by: Jeong-Seok Yang <jseok.yang@samsung.com>
Diffstat (limited to 'libcamera')
-rw-r--r--[-rwxr-xr-x]libcamera/SecCamera.cpp5060
-rw-r--r--[-rwxr-xr-x]libcamera/SecCamera.h1378
-rw-r--r--libcamera/SecCameraHWInterface.cpp3936
-rw-r--r--libcamera/SecCameraHWInterface.h251
4 files changed, 5109 insertions, 5516 deletions
diff --git a/libcamera/SecCamera.cpp b/libcamera/SecCamera.cpp
index 27f7aee..ad9c1c2 100755..100644
--- a/libcamera/SecCamera.cpp
+++ b/libcamera/SecCamera.cpp
@@ -16,12 +16,12 @@
/*
************************************
-* Filename: SecCamera.cpp
+* Filename: SecCamera.cpp
* Author: Sachin P. Kamat
* Purpose: This file interacts with the Camera and JPEG drivers.
*************************************
*/
-
+
//#define LOG_NDEBUG 0
#define LOG_TAG "SecCamera"
#define ADD_THUMB_IMG 1
@@ -43,27 +43,25 @@ using namespace android;
#ifdef BOARD_USES_SDTV
#include "utils/Timers.h"
//#define MEASURE_DURATION_TVOUT
-sp<TvOut> mtvoutcamera;
-static bool suspendTvInit = false ;
+sp<TvOut> mtvoutcamera;
+static bool suspendTvInit = false;
#define TVOUT_RESUME_TIME 4
#endif
//#define PERFORMANCE //Uncomment to measure performance
//#define DUMP_YUV //Uncomment to take a dump of YUV frame during capture
-#define CHECK(return_value) \
- if(return_value < 0) \
- { \
- LOGE("%s::%d fail. errno: %s\n", __func__,__LINE__, strerror(errno)); \
- return -1; \
- } \
+#define CHECK(return_value) \
+ if (return_value < 0) { \
+ LOGE("%s::%d fail. errno: %s\n", __func__,__LINE__, strerror(errno)); \
+ return -1; \
+ }
-#define CHECK_PTR(return_value) \
- if(return_value < 0) \
- { \
- LOGE("%s::%d fail\n", __func__,__LINE__); \
- return NULL; \
- } \
+#define CHECK_PTR(return_value) \
+ if (return_value < 0) { \
+ LOGE("%s::%d fail\n", __func__,__LINE__); \
+ return NULL; \
+ }
#define ALIGN_TO_32B(x) ((((x) + (1 << 5) - 1) >> 5) << 5)
#define ALIGN_TO_128B(x) ((((x) + (1 << 7) - 1) >> 7) << 7)
@@ -79,590 +77,573 @@ static struct timeval time_stop;
unsigned long measure_time(struct timeval *start, struct timeval *stop)
{
+ unsigned long sec, usec, time;
- unsigned long sec, usec, time;
-
- sec = stop->tv_sec - start->tv_sec;
+ sec = stop->tv_sec - start->tv_sec;
- if (stop->tv_usec >= start->tv_usec) {
- usec = stop->tv_usec - start->tv_usec;
- } else {
- usec = stop->tv_usec + 1000000 - start->tv_usec;
- sec--;
- }
+ if (stop->tv_usec >= start->tv_usec) {
+ usec = stop->tv_usec - start->tv_usec;
+ } else {
+ usec = stop->tv_usec + 1000000 - start->tv_usec;
+ sec--;
+ }
- time = (sec * 1000000) + usec;
+ time = (sec * 1000000) + usec;
- return time;
+ return time;
}
static inline unsigned long check_performance()
{
- unsigned long time = 0;
- static unsigned long max=0, min=0xffffffff;
+ unsigned long time = 0;
+ static unsigned long max = 0;
+ static unsigned long min = 0xffffffff;
- if(time_start.tv_sec == 0 && time_start.tv_usec == 0) {
- gettimeofday(&time_start, NULL);
- } else {
- gettimeofday(&time_stop, NULL);
- time = measure_time(&time_start, &time_stop);
- if(max < time) max = time;
- if(min > time) min = time;
- LOGV("Interval: %lu us (%2.2lf fps), min:%2.2lf fps, max:%2.2lf fps\n", time, 1000000.0/time, 1000000.0/max, 1000000.0/min);
- gettimeofday(&time_start, NULL);
- }
+ if (time_start.tv_sec == 0 && time_start.tv_usec == 0) {
+ gettimeofday(&time_start, NULL);
+ } else {
+ gettimeofday(&time_stop, NULL);
+ time = measure_time(&time_start, &time_stop);
+ if (max < time) max = time;
+ if (min > time) min = time;
+ LOGV("Interval: %lu us (%2.2lf fps), min:%2.2lf fps, max:%2.2lf fps\n",
+ time, 1000000.0 / time, 1000000.0 / max, 1000000.0 / min);
+ gettimeofday(&time_start, NULL);
+ }
- return time;
+ return time;
}
static int close_buffers(struct fimc_buffer *buffers)
{
- int i;
+ int i;
- for (i = 0; i < MAX_BUFFERS; i++) {
- if (buffers[i].start)
- {
- munmap(buffers[i].start, buffers[i].length);
- //LOGV("munmap():virt. addr[%d]: 0x%x size = %d\n", i, (unsigned int) buffers[i].start, buffers[i].length);
- buffers[i].start = NULL;
- }
- }
+ for (i = 0; i < MAX_BUFFERS; i++) {
+ if (buffers[i].start) {
+ munmap(buffers[i].start, buffers[i].length);
+ //LOGV("munmap():virt. addr[%d]: 0x%x size = %d\n", i, (unsigned int) buffers[i].start, buffers[i].length);
+ buffers[i].start = NULL;
+ }
+ }
- return 0;
+ return 0;
}
static int get_pixel_depth(unsigned int fmt)
{
- int depth = 0;
-
- switch (fmt) {
- case V4L2_PIX_FMT_NV12:
- depth = 12;
- break;
- case V4L2_PIX_FMT_NV12T:
- depth = 12;
- break;
- case V4L2_PIX_FMT_NV21:
- depth = 12;
- break;
- case V4L2_PIX_FMT_YUV420:
- depth = 12;
- break;
-
- case V4L2_PIX_FMT_RGB565:
- case V4L2_PIX_FMT_YUYV:
- case V4L2_PIX_FMT_YVYU:
- case V4L2_PIX_FMT_UYVY:
- case V4L2_PIX_FMT_VYUY:
- case V4L2_PIX_FMT_NV16:
- case V4L2_PIX_FMT_NV61:
- case V4L2_PIX_FMT_YUV422P:
- depth = 16;
- break;
-
- case V4L2_PIX_FMT_RGB32:
- depth = 32;
- break;
- }
-
- return depth;
-}
-
-#define ALIGN_W(x) ((x+0x7F)&(~0x7F)) // Set as multiple of 128
-#define ALIGN_H(x) ((x+0x1F)&(~0x1F)) // Set as multiple of 32
-#define ALIGN_BUF(x) ((x+0x1FFF)&(~0x1FFF)) // Set as multiple of 8K
+ int depth = 0;
+
+ switch (fmt) {
+ case V4L2_PIX_FMT_NV12:
+ depth = 12;
+ break;
+ case V4L2_PIX_FMT_NV12T:
+ depth = 12;
+ break;
+ case V4L2_PIX_FMT_NV21:
+ depth = 12;
+ break;
+ case V4L2_PIX_FMT_YUV420:
+ depth = 12;
+ break;
+
+ case V4L2_PIX_FMT_RGB565:
+ case V4L2_PIX_FMT_YUYV:
+ case V4L2_PIX_FMT_YVYU:
+ case V4L2_PIX_FMT_UYVY:
+ case V4L2_PIX_FMT_VYUY:
+ case V4L2_PIX_FMT_NV16:
+ case V4L2_PIX_FMT_NV61:
+ case V4L2_PIX_FMT_YUV422P:
+ depth = 16;
+ break;
+
+ case V4L2_PIX_FMT_RGB32:
+ depth = 32;
+ break;
+ }
+
+ return depth;
+}
+
+#define ALIGN_W(x) (((x) + 0x7F) & (~0x7F)) // Set as multiple of 128
+#define ALIGN_H(x) (((x) + 0x1F) & (~0x1F)) // Set as multiple of 32
+#define ALIGN_BUF(x) (((x) + 0x1FFF)& (~0x1FFF)) // Set as multiple of 8K
static int init_yuv_buffers(struct fimc_buffer *buffers, int width, int height, unsigned int fmt)
{
- int i, len;
-
- len = (width * height * get_pixel_depth(fmt)) / 8;
-
-
- for (i = 0; i < MAX_BUFFERS; i++)
- {
- if(fmt==V4L2_PIX_FMT_NV12T)
- {
- buffers[i].start = NULL;
- buffers[i].length = ALIGN_BUF(ALIGN_W(width) * ALIGN_H(height))+ ALIGN_BUF(ALIGN_W(width) * ALIGN_H(height/2));
- }
- else
- {
- buffers[i].start = NULL;
- buffers[i].length = len;
- }
- }
+ int i, len;
+
+ len = (width * height * get_pixel_depth(fmt)) / 8;
+
+ for (i = 0; i < MAX_BUFFERS; i++) {
+ if (fmt==V4L2_PIX_FMT_NV12T) {
+ buffers[i].start = NULL;
+ buffers[i].length = ALIGN_BUF(ALIGN_W(width) * ALIGN_H(height)) +
+ ALIGN_BUF(ALIGN_W(width) * ALIGN_H(height / 2));
+ } else {
+ buffers[i].start = NULL;
+ buffers[i].length = len;
+ }
+ }
- return 0;
+ return 0;
}
static int fimc_poll(struct pollfd *events)
{
- int ret;
+ int ret;
- ret = poll(events, 1, 5000);
- if (ret < 0) {
- LOGE("ERR(%s):poll error\n", __FUNCTION__);
- return ret;
- }
+ ret = poll(events, 1, 5000);
+ if (ret < 0) {
+ LOGE("ERR(%s):poll error\n", __func__);
+ return ret;
+ }
- if (ret == 0) {
- LOGE("ERR(%s):No data in 5 secs..\n", __FUNCTION__);
- return ret;
- }
+ if (ret == 0) {
+ LOGE("ERR(%s):No data in 5 secs..\n", __func__);
+ return ret;
+ }
- return ret;
+ return ret;
}
#ifdef SWP1_CAMERA_ADD_ADVANCED_FUNCTION
static int fimc_esd_poll(struct pollfd *events)
{
- int ret;
+ int ret;
- ret = poll(events, 1, 1000);
+ ret = poll(events, 1, 1000);
- if (ret < 0) {
- LOGE("ERR(%s):poll error\n", __FUNCTION__);
- return ret;
- }
+ if (ret < 0) {
+ LOGE("ERR(%s):poll error\n", __func__);
+ return ret;
+ }
- if (ret == 0) {
- LOGE("ERR(%s):No data in 1 secs.. Camera Device Reset \n", __FUNCTION__);
- return ret;
- }
+ if (ret == 0) {
+ LOGE("ERR(%s):No data in 1 secs.. Camera Device Reset \n", __func__);
+ return ret;
+ }
- return ret;
+ return ret;
}
-#endif /* SWP1_CAMERA_ADD_ADVANCED_FUNCTION */
+#endif /* SWP1_CAMERA_ADD_ADVANCED_FUNCTION */
#ifdef DUMP_YUV
static int save_yuv(struct fimc_buffer *m_buffers_c, int width, int height, int depth, int index, int frame_count)
{
- FILE *yuv_fp = NULL;
- char filename[100], *buffer = NULL;
+ FILE *yuv_fp = NULL;
+ char filename[100], *buffer = NULL;
- /* file create/open, note to "wb" */
- yuv_fp = fopen("/data/main.yuv", "wb");
- if (yuv_fp==NULL)
- {
- LOGE("Save YUV] file open error");
- return -1;
- }
+ /* file create/open, note to "wb" */
+ yuv_fp = fopen("/data/main.yuv", "wb");
+ if (yuv_fp == NULL) {
+ LOGE("Save YUV] file open error");
+ return -1;
+ }
- buffer = (char *) malloc(m_buffers_c[index].length);
- if(buffer == NULL)
- {
- LOGE("Save YUV] buffer alloc failed");
- if(yuv_fp) fclose(yuv_fp);
- return -1;
- }
+ buffer = (char *) malloc(m_buffers_c[index].length);
+ if (buffer == NULL) {
+ LOGE("Save YUV] buffer alloc failed");
+ if (yuv_fp) fclose(yuv_fp);
+ return -1;
+ }
- memcpy(buffer, m_buffers_c[index].start, m_buffers_c[index].length);
+ memcpy(buffer, m_buffers_c[index].start, m_buffers_c[index].length);
- fflush(stdout);
+ fflush(stdout);
- fwrite(buffer, 1, m_buffers_c[index].length, yuv_fp);
+ fwrite(buffer, 1, m_buffers_c[index].length, yuv_fp);
- fflush(yuv_fp);
+ fflush(yuv_fp);
- if(yuv_fp)
- fclose(yuv_fp);
- if(buffer)
- free(buffer);
+ if (yuv_fp)
+ fclose(yuv_fp);
+ if (buffer)
+ free(buffer);
- return 0;
+ return 0;
}
#endif //DUMP_YUV
static int fimc_v4l2_querycap(int fp)
{
- struct v4l2_capability cap;
- int ret = 0;
+ struct v4l2_capability cap;
+ int ret = 0;
- ret = ioctl(fp, VIDIOC_QUERYCAP, &cap);
+ ret = ioctl(fp, VIDIOC_QUERYCAP, &cap);
- if (ret < 0) {
- LOGE("ERR(%s):VIDIOC_QUERYCAP failed\n", __FUNCTION__);
- return -1;
- }
+ if (ret < 0) {
+ LOGE("ERR(%s):VIDIOC_QUERYCAP failed\n", __func__);
+ return -1;
+ }
- if (!(cap.capabilities & V4L2_CAP_VIDEO_CAPTURE)) {
- LOGE("ERR(%s):no capture devices\n", __FUNCTION__);
- return -1;
- }
+ if (!(cap.capabilities & V4L2_CAP_VIDEO_CAPTURE)) {
+ LOGE("ERR(%s):no capture devices\n", __func__);
+ return -1;
+ }
- return ret;
+ return ret;
}
static int fimc_v4l2_enuminput(int fp, int index)
{
- struct v4l2_input input;
+ struct v4l2_input input;
- input.index = index;
- if(ioctl(fp, VIDIOC_ENUMINPUT, &input) != 0)
- {
- LOGE("ERR(%s):No matching index found\n", __FUNCTION__);
- return -1;
- }
- LOGI("Name of input channel[%d] is %s\n", input.index, input.name);
+ input.index = index;
+ if (ioctl(fp, VIDIOC_ENUMINPUT, &input) != 0) {
+ LOGE("ERR(%s):No matching index found\n", __func__);
+ return -1;
+ }
+ LOGI("Name of input channel[%d] is %s\n", input.index, input.name);
- return 0;
+ return 0;
}
static int fimc_v4l2_s_input(int fp, int index)
{
- struct v4l2_input input;
- int ret;
+ struct v4l2_input input;
+ int ret;
- input.index = index;
+ input.index = index;
- ret = ioctl(fp, VIDIOC_S_INPUT, &input);
- if (ret < 0) {
- LOGE("ERR(%s):VIDIOC_S_INPUT failed\n", __FUNCTION__);
- return ret;
- }
+ ret = ioctl(fp, VIDIOC_S_INPUT, &input);
+ if (ret < 0) {
+ LOGE("ERR(%s):VIDIOC_S_INPUT failed\n", __func__);
+ return ret;
+ }
- return ret;
+ return ret;
}
static int fimc_v4l2_s_fmt(int fp, int width, int height, unsigned int fmt, int flag_capture)
{
- struct v4l2_format v4l2_fmt;
- struct v4l2_pix_format pixfmt;
- int ret;
+ struct v4l2_format v4l2_fmt;
+ struct v4l2_pix_format pixfmt;
+ int ret;
- v4l2_fmt.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
+ v4l2_fmt.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
- memset(&pixfmt, 0, sizeof(pixfmt));
+ memset(&pixfmt, 0, sizeof(pixfmt));
- pixfmt.width = width;
- pixfmt.height = height;
- pixfmt.pixelformat = fmt;
-
- pixfmt.sizeimage = (width * height * get_pixel_depth(fmt)) / 8;
+ pixfmt.width = width;
+ pixfmt.height = height;
+ pixfmt.pixelformat = fmt;
- pixfmt.field = V4L2_FIELD_NONE;
+ pixfmt.sizeimage = (width * height * get_pixel_depth(fmt)) / 8;
- v4l2_fmt.fmt.pix = pixfmt;
+ pixfmt.field = V4L2_FIELD_NONE;
- /* Set up for capture */
- ret = ioctl(fp, VIDIOC_S_FMT, &v4l2_fmt);
- if (ret < 0) {
- LOGE("ERR(%s):VIDIOC_S_FMT failed\n", __FUNCTION__);
- return -1;
- }
+ v4l2_fmt.fmt.pix = pixfmt;
- return 0;
+ /* Set up for capture */
+ ret = ioctl(fp, VIDIOC_S_FMT, &v4l2_fmt);
+ if (ret < 0) {
+ LOGE("ERR(%s):VIDIOC_S_FMT failed\n", __func__);
+ return -1;
+ }
+
+ return 0;
}
static int fimc_v4l2_s_fmt_cap(int fp, int width, int height, unsigned int fmt)
{
- struct v4l2_format v4l2_fmt;
- struct v4l2_pix_format pixfmt;
- int ret;
-
- memset(&pixfmt, 0, sizeof(pixfmt));
+ struct v4l2_format v4l2_fmt;
+ struct v4l2_pix_format pixfmt;
+ int ret;
- v4l2_fmt.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
+ memset(&pixfmt, 0, sizeof(pixfmt));
- pixfmt.width = width;
- pixfmt.height = height;
- pixfmt.pixelformat = fmt;
- if (fmt == V4L2_PIX_FMT_JPEG){
- pixfmt.colorspace = V4L2_COLORSPACE_JPEG;
- }
+ v4l2_fmt.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
- pixfmt.sizeimage = (width * height * get_pixel_depth(fmt)) / 8;
+ pixfmt.width = width;
+ pixfmt.height = height;
+ pixfmt.pixelformat = fmt;
+ if (fmt == V4L2_PIX_FMT_JPEG) {
+ pixfmt.colorspace = V4L2_COLORSPACE_JPEG;
+ }
- v4l2_fmt.fmt.pix = pixfmt;
+ pixfmt.sizeimage = (width * height * get_pixel_depth(fmt)) / 8;
- //LOGE("ori_w %d, ori_h %d, w %d, h %d\n", width, height, v4l2_fmt.fmt.pix.width, v4l2_fmt.fmt.pix.height);
+ v4l2_fmt.fmt.pix = pixfmt;
- /* Set up for capture */
- ret = ioctl(fp, VIDIOC_S_FMT, &v4l2_fmt);
- if (ret < 0) {
- LOGE("ERR(%s):VIDIOC_S_FMT failed\n", __FUNCTION__);
- return ret;
- }
+ //LOGE("ori_w %d, ori_h %d, w %d, h %d\n", width, height, v4l2_fmt.fmt.pix.width, v4l2_fmt.fmt.pix.height);
+ /* Set up for capture */
+ ret = ioctl(fp, VIDIOC_S_FMT, &v4l2_fmt);
+ if (ret < 0) {
+ LOGE("ERR(%s):VIDIOC_S_FMT failed\n", __func__);
return ret;
+ }
+
+ return ret;
}
static int fimc_v4l2_enum_fmt(int fp, unsigned int fmt)
{
- struct v4l2_fmtdesc fmtdesc;
- int found = 0;
+ struct v4l2_fmtdesc fmtdesc;
+ int found = 0;
- fmtdesc.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
- fmtdesc.index = 0;
+ fmtdesc.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
+ fmtdesc.index = 0;
- while (ioctl(fp, VIDIOC_ENUM_FMT, &fmtdesc) == 0) {
- if (fmtdesc.pixelformat == fmt) {
- LOGD("passed fmt = %d found pixel format[%d]: %s\n", fmt, fmtdesc.index, fmtdesc.description);
- found = 1;
- break;
- }
-
- fmtdesc.index++;
+ while (ioctl(fp, VIDIOC_ENUM_FMT, &fmtdesc) == 0) {
+ if (fmtdesc.pixelformat == fmt) {
+ LOGD("passed fmt = %d found pixel format[%d]: %s\n", fmt, fmtdesc.index, fmtdesc.description);
+ found = 1;
+ break;
}
- if (!found) {
- LOGE("unsupported pixel format\n");
- return -1;
- }
+ fmtdesc.index++;
+ }
- return 0;
+ if (!found) {
+ LOGE("unsupported pixel format\n");
+ return -1;
+ }
+
+ return 0;
}
static int fimc_v4l2_reqbufs(int fp, enum v4l2_buf_type type, int nr_bufs)
{
- struct v4l2_requestbuffers req;
- int ret;
+ struct v4l2_requestbuffers req;
+ int ret;
- req.count = nr_bufs;
- req.type = type;
- req.memory = V4L2_MEMORY_MMAP;
+ req.count = nr_bufs;
+ req.type = type;
+ req.memory = V4L2_MEMORY_MMAP;
- ret = ioctl(fp, VIDIOC_REQBUFS, &req);
- if(ret < 0) {
- LOGE("ERR(%s):VIDIOC_REQBUFS failed\n", __FUNCTION__);
- return -1;
- }
+ ret = ioctl(fp, VIDIOC_REQBUFS, &req);
+ if (ret < 0) {
+ LOGE("ERR(%s):VIDIOC_REQBUFS failed\n", __func__);
+ return -1;
+ }
- return req.count;
+ return req.count;
}
static int fimc_v4l2_querybuf(int fp, struct fimc_buffer *buffers, enum v4l2_buf_type type, int nr_frames)
{
- struct v4l2_buffer v4l2_buf;
- int i, ret;
-
- for(i = 0; i < nr_frames; i++)
- {
- v4l2_buf.type = type;
- v4l2_buf.memory = V4L2_MEMORY_MMAP;
- v4l2_buf.index = i;
-
- ret = ioctl(fp , VIDIOC_QUERYBUF, &v4l2_buf);
- if(ret < 0)
- {
- LOGE("ERR(%s):VIDIOC_QUERYBUF failed\n", __FUNCTION__);
- return -1;
- }
-
- if(nr_frames == 1)
- {
- buffers[i].length = v4l2_buf.length;
- if ((buffers[i].start = (char *) mmap(0, v4l2_buf.length, \
- PROT_READ | PROT_WRITE, MAP_SHARED, \
- fp, v4l2_buf.m.offset)) < 0)
- {
- LOGE("%s %d] mmap() failed\n",__FUNCTION__, __LINE__);
- return -1;
- }
-
- //LOGV("buffers[%d].start = %p v4l2_buf.length = %d", i, buffers[i].start, v4l2_buf.length);
- }
- else
- {
-
-#if defined DUMP_YUV || defined (SEND_YUV_RECORD_DATA)
- buffers[i].length = v4l2_buf.length;
- if ((buffers[i].start = (char *) mmap(0, v4l2_buf.length, \
- PROT_READ | PROT_WRITE, MAP_SHARED, \
- fp, v4l2_buf.m.offset)) < 0)
- {
- LOGE("%s %d] mmap() failed\n",__FUNCTION__, __LINE__);
- return -1;
- }
-
- //LOGV("buffers[%d].start = %p v4l2_buf.length = %d", i, buffers[i].start, v4l2_buf.length);
-#endif
- }
+ struct v4l2_buffer v4l2_buf;
+ int i, ret;
+
+ for (i = 0; i < nr_frames; i++) {
+ v4l2_buf.type = type;
+ v4l2_buf.memory = V4L2_MEMORY_MMAP;
+ v4l2_buf.index = i;
+
+ ret = ioctl(fp , VIDIOC_QUERYBUF, &v4l2_buf);
+ if (ret < 0) {
+ LOGE("ERR(%s):VIDIOC_QUERYBUF failed\n", __func__);
+ return -1;
+ }
+
+ if (nr_frames == 1) {
+ buffers[i].length = v4l2_buf.length;
+ if ((buffers[i].start = (char *)mmap(0, v4l2_buf.length, PROT_READ | PROT_WRITE, MAP_SHARED,
+ fp, v4l2_buf.m.offset)) < 0) {
+ LOGE("%s %d] mmap() failed\n",__func__, __LINE__);
+ return -1;
+ }
- }
+ //LOGV("buffers[%d].start = %p v4l2_buf.length = %d", i, buffers[i].start, v4l2_buf.length);
+ } else {
- return 0;
+#if defined DUMP_YUV || defined (SEND_YUV_RECORD_DATA)
+ buffers[i].length = v4l2_buf.length;
+ if ((buffers[i].start = (char *)mmap(0, v4l2_buf.length, PROT_READ | PROT_WRITE, MAP_SHARED,
+ fp, v4l2_buf.m.offset)) < 0) {
+ LOGE("%s %d] mmap() failed\n",__func__, __LINE__);
+ return -1;
+ }
+
+ //LOGV("buffers[%d].start = %p v4l2_buf.length = %d", i, buffers[i].start, v4l2_buf.length);
+#endif
+ }
+ }
+
+ return 0;
}
static int fimc_v4l2_streamon(int fp)
{
- enum v4l2_buf_type type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
- int ret;
+ enum v4l2_buf_type type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
+ int ret;
- ret = ioctl(fp, VIDIOC_STREAMON, &type);
- if (ret < 0) {
- LOGE("ERR(%s):VIDIOC_STREAMON failed\n", __FUNCTION__);
- return ret;
- }
+ ret = ioctl(fp, VIDIOC_STREAMON, &type);
+ if (ret < 0) {
+ LOGE("ERR(%s):VIDIOC_STREAMON failed\n", __func__);
+ return ret;
+ }
- return ret;
+ return ret;
}
static int fimc_v4l2_streamoff(int fp)
{
- enum v4l2_buf_type type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
- int ret;
+ enum v4l2_buf_type type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
+ int ret;
#ifdef SWP1_CAMERA_ADD_ADVANCED_FUNCTION
- LOGE("%s()", __FUNCTION__);
+ LOGE("%s()", __func__);
#endif
- ret = ioctl(fp, VIDIOC_STREAMOFF, &type);
- if (ret < 0) {
- LOGE("ERR(%s):VIDIOC_STREAMOFF failed\n", __FUNCTION__);
- return ret;
- }
+ ret = ioctl(fp, VIDIOC_STREAMOFF, &type);
+ if (ret < 0) {
+ LOGE("ERR(%s):VIDIOC_STREAMOFF failed\n", __func__);
+ return ret;
+ }
- return ret;
+ return ret;
}
static int fimc_v4l2_qbuf(int fp, int index)
{
- struct v4l2_buffer v4l2_buf;
- int ret;
+ struct v4l2_buffer v4l2_buf;
+ int ret;
- v4l2_buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
- v4l2_buf.memory = V4L2_MEMORY_MMAP;
- v4l2_buf.index = index;
+ v4l2_buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
+ v4l2_buf.memory = V4L2_MEMORY_MMAP;
+ v4l2_buf.index = index;
- ret = ioctl(fp, VIDIOC_QBUF, &v4l2_buf);
- if (ret < 0) {
- LOGE("ERR(%s):VIDIOC_QBUF failed\n", __FUNCTION__);
- return ret;
- }
+ ret = ioctl(fp, VIDIOC_QBUF, &v4l2_buf);
+ if (ret < 0) {
+ LOGE("ERR(%s):VIDIOC_QBUF failed\n", __func__);
+ return ret;
+ }
- return 0;
+ return 0;
}
static int fimc_v4l2_dqbuf(int fp)
{
- struct v4l2_buffer v4l2_buf;
- int ret;
+ struct v4l2_buffer v4l2_buf;
+ int ret;
- v4l2_buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
- v4l2_buf.memory = V4L2_MEMORY_MMAP;
+ v4l2_buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
+ v4l2_buf.memory = V4L2_MEMORY_MMAP;
- ret = ioctl(fp, VIDIOC_DQBUF, &v4l2_buf);
- if (ret < 0) {
- LOGE("ERR(%s):VIDIOC_DQBUF failed\n", __FUNCTION__);
- return ret;
- }
+ ret = ioctl(fp, VIDIOC_DQBUF, &v4l2_buf);
+ if (ret < 0) {
+ LOGE("ERR(%s):VIDIOC_DQBUF failed\n", __func__);
+ return ret;
+ }
- return v4l2_buf.index;
+ return v4l2_buf.index;
}
static int fimc_v4l2_g_ctrl(int fp, unsigned int id)
{
- struct v4l2_control ctrl;
- int ret;
+ struct v4l2_control ctrl;
+ int ret;
- ctrl.id = id;
+ ctrl.id = id;
- ret = ioctl(fp, VIDIOC_G_CTRL, &ctrl);
- if (ret < 0) {
- LOGE("ERR(%s):VIDIOC_G_CTRL failed\n", __FUNCTION__);
- return ret;
- }
+ ret = ioctl(fp, VIDIOC_G_CTRL, &ctrl);
+ if (ret < 0) {
+ LOGE("ERR(%s):VIDIOC_G_CTRL failed\n", __func__);
+ return ret;
+ }
- return ctrl.value;
+ return ctrl.value;
}
static int fimc_v4l2_s_ctrl(int fp, unsigned int id, unsigned int value)
{
- struct v4l2_control ctrl;
- int ret;
+ struct v4l2_control ctrl;
+ int ret;
- ctrl.id = id;
- ctrl.value = value;
+ ctrl.id = id;
+ ctrl.value = value;
- ret = ioctl(fp, VIDIOC_S_CTRL, &ctrl);
- if (ret < 0) {
- LOGE("ERR(%s):VIDIOC_S_CTRL failed, ret: %d\n", __FUNCTION__, ret);
- return ret;
- }
+ ret = ioctl(fp, VIDIOC_S_CTRL, &ctrl);
+ if (ret < 0) {
+ LOGE("ERR(%s):VIDIOC_S_CTRL failed, ret: %d\n", __func__, ret);
+ return ret;
+ }
- return ctrl.value;
+ return ctrl.value;
}
#ifdef SWP1_CAMERA_ADD_ADVANCED_FUNCTION
-static int fimc_v4l2_s_ext_ctrl(int fp, unsigned int id, void * value)
+static int fimc_v4l2_s_ext_ctrl(int fp, unsigned int id, void *value)
{
- struct v4l2_ext_controls ctrls;
- struct v4l2_ext_control ctrl;
- int ret;
+ struct v4l2_ext_controls ctrls;
+ struct v4l2_ext_control ctrl;
+ int ret;
- ctrl.id = id;
- ctrl.reserved = value;
+ ctrl.id = id;
+ ctrl.reserved = value;
- ctrls.ctrl_class = V4L2_CTRL_CLASS_CAMERA;
- ctrls.count = 1;
- ctrls.controls = &ctrl;
+ ctrls.ctrl_class = V4L2_CTRL_CLASS_CAMERA;
+ ctrls.count = 1;
+ ctrls.controls = &ctrl;
- ret = ioctl(fp, VIDIOC_S_EXT_CTRLS, &ctrls);
- if (ret < 0)
- LOGE("ERR(%s):VIDIOC_S_EXT_CTRLS failed\n", __FUNCTION__);
-
- return ret;
+ ret = ioctl(fp, VIDIOC_S_EXT_CTRLS, &ctrls);
+ if (ret < 0)
+ LOGE("ERR(%s):VIDIOC_S_EXT_CTRLS failed\n", __func__);
+
+ return ret;
}
#endif
static int fimc_v4l2_g_parm(int fp)
{
- struct v4l2_streamparm stream;
- int ret;
-
- stream.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
+ struct v4l2_streamparm stream;
+ int ret;
- ret = ioctl(fp, VIDIOC_G_PARM, &stream);
- if (ret < 0) {
- LOGE("ERR(%s):VIDIOC_G_PARM failed\n", __FUNCTION__);
- return -1;
- }
+ stream.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
-// LOGV("timeperframe: numerator %d, denominator %d\n", \
- stream.parm.capture.timeperframe.numerator, \
- stream.parm.capture.timeperframe.denominator);
-
- return 0;
+ ret = ioctl(fp, VIDIOC_G_PARM, &stream);
+ if (ret < 0) {
+ LOGE("ERR(%s):VIDIOC_G_PARM failed\n", __func__);
+ return -1;
+ }
+/*
+ LOGV("timeperframe: numerator %d, denominator %d\n",
+ stream.parm.capture.timeperframe.numerator,
+ stream.parm.capture.timeperframe.denominator);
+*/
+ return 0;
}
static int fimc_v4l2_s_parm(int fp, int fps_numerator, int fps_denominator)
{
- struct v4l2_streamparm stream;
- int ret;
+ struct v4l2_streamparm stream;
+ int ret;
- stream.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
- stream.parm.capture.capturemode = 0;
- stream.parm.capture.timeperframe.numerator = fps_numerator;
- stream.parm.capture.timeperframe.denominator = fps_denominator;
+ stream.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
+ stream.parm.capture.capturemode = 0;
+ stream.parm.capture.timeperframe.numerator = fps_numerator;
+ stream.parm.capture.timeperframe.denominator = fps_denominator;
- ret = ioctl(fp, VIDIOC_S_PARM, &stream);
- if (ret < 0) {
- LOGE("ERR(%s):VIDIOC_S_PARM failed\n", __FUNCTION__);
- return ret;
- }
+ ret = ioctl(fp, VIDIOC_S_PARM, &stream);
+ if (ret < 0) {
+ LOGE("ERR(%s):VIDIOC_S_PARM failed\n", __func__);
+ return ret;
+ }
- return 0;
+ return 0;
}
#if 0
static int fimc_v4l2_s_parm_ex(int fp, int mode, int no_dma_op) //Kamat: not present in new code
{
- struct v4l2_streamparm stream;
- int ret;
+ struct v4l2_streamparm stream;
+ int ret;
- stream.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
- stream.parm.capture.capturemode = mode;
- if(no_dma_op)
- stream.parm.capture.reserved[0] = 100;
-
- ret = ioctl(fp, VIDIOC_S_PARM, &stream);
- if (ret < 0) {
- LOGE("ERR(%s):VIDIOC_S_PARM_EX failed\n", __FUNCTION__);
- return ret;
- }
+ stream.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
+ stream.parm.capture.capturemode = mode;
+ if (no_dma_op)
+ stream.parm.capture.reserved[0] = 100;
- return 0;
+ ret = ioctl(fp, VIDIOC_S_PARM, &stream);
+ if (ret < 0) {
+ LOGE("ERR(%s):VIDIOC_S_PARM_EX failed\n", __func__);
+ return ret;
+ }
+
+ return 0;
}
#endif
@@ -670,411 +651,389 @@ static int fimc_v4l2_s_parm_ex(int fp, int mode, int no_dma_op) //Kamat: not pre
// Constructor & Destructor
SecCamera::SecCamera() :
- m_focus_mode(1),
- m_iso(0),
- m_camera_id(CAMERA_ID_BACK),
- m_preview_v4lformat(-1),
- m_preview_width (0),
- m_preview_height (0),
- m_preview_max_width (MAX_BACK_CAMERA_PREVIEW_WIDTH),
- m_preview_max_height (MAX_BACK_CAMERA_PREVIEW_HEIGHT),
- m_snapshot_v4lformat(-1),
- m_snapshot_width (0),
- m_snapshot_height (0),
- m_snapshot_max_width (MAX_BACK_CAMERA_SNAPSHOT_WIDTH),
- m_snapshot_max_height (MAX_BACK_CAMERA_SNAPSHOT_HEIGHT),
- m_angle(0),
- m_fps(30),
- m_autofocus(AUTO_FOCUS_ON),
- m_white_balance(WHITE_BALANCE_AUTO),
- m_brightness(BRIGHTNESS_NORMAL),
- m_image_effect(IMAGE_EFFECT_NONE),
- #ifdef SWP1_CAMERA_ADD_ADVANCED_FUNCTION
- m_anti_banding(0),
- m_flash_mode(1),
- m_metering(2),
- m_contrast(2),
- m_saturation(2),
- m_sharpness(2),
- m_wdr(0),
- m_anti_shake(0),
- m_zoom_level(0),
- m_object_tracking(0),
- m_smart_auto(0),
- m_beauty_shot(0),
- m_vintage_mode(1),
- m_face_detect(0),
- m_gps_latitude(0),
- m_gps_longitude(0),
- m_gps_altitude(0),
- m_gps_timestamp(0),
- m_vtmode(0),
- m_sensor_mode(0),
- m_exif_orientation(1),
- m_blur_level(0),
- m_chk_dataline(0),
- m_video_gamma(0),
- m_slow_ae(0),
- #else
- m_image_effect(IMAGE_EFFECT_ORIGINAL),
- #endif
- m_flag_camera_start(0),
- m_jpeg_thumbnail_width (0),
- m_jpeg_thumbnail_height(0),
- m_jpeg_quality(100),
- m_camera_af_flag(-1),
- m_shot_mode(0),
- m_flag_init(0)
-{
- LOGV("%s()", __FUNCTION__);
+ m_focus_mode(1),
+ m_iso(0),
+ m_camera_id(CAMERA_ID_BACK),
+ m_preview_v4lformat(-1),
+ m_preview_width (0),
+ m_preview_height (0),
+ m_preview_max_width (MAX_BACK_CAMERA_PREVIEW_WIDTH),
+ m_preview_max_height (MAX_BACK_CAMERA_PREVIEW_HEIGHT),
+ m_snapshot_v4lformat(-1),
+ m_snapshot_width (0),
+ m_snapshot_height (0),
+ m_snapshot_max_width (MAX_BACK_CAMERA_SNAPSHOT_WIDTH),
+ m_snapshot_max_height (MAX_BACK_CAMERA_SNAPSHOT_HEIGHT),
+ m_angle(0),
+ m_fps(30),
+ m_autofocus(AUTO_FOCUS_ON),
+ m_white_balance(WHITE_BALANCE_AUTO),
+ m_brightness(BRIGHTNESS_NORMAL),
+ m_image_effect(IMAGE_EFFECT_NONE),
+ #ifdef SWP1_CAMERA_ADD_ADVANCED_FUNCTION
+ m_anti_banding(0),
+ m_flash_mode(1),
+ m_metering(2),
+ m_contrast(2),
+ m_saturation(2),
+ m_sharpness(2),
+ m_wdr(0),
+ m_anti_shake(0),
+ m_zoom_level(0),
+ m_object_tracking(0),
+ m_smart_auto(0),
+ m_beauty_shot(0),
+ m_vintage_mode(1),
+ m_face_detect(0),
+ m_gps_latitude(0),
+ m_gps_longitude(0),
+ m_gps_altitude(0),
+ m_gps_timestamp(0),
+ m_vtmode(0),
+ m_sensor_mode(0),
+ m_exif_orientation(1),
+ m_blur_level(0),
+ m_chk_dataline(0),
+ m_video_gamma(0),
+ m_slow_ae(0),
+ #else
+ m_image_effect(IMAGE_EFFECT_ORIGINAL),
+ #endif
+ m_flag_camera_start(0),
+ m_jpeg_thumbnail_width (0),
+ m_jpeg_thumbnail_height(0),
+ m_jpeg_quality(100),
+ m_camera_af_flag(-1),
+ m_shot_mode(0),
+ m_flag_init(0)
+{
+ LOGV("%s()", __func__);
#ifdef BOARD_USES_SDTV
- nsecs_t before1, after1;
+ nsecs_t before1, after1;
-#ifdef MEASURE_DURATION_TVOUT
- before1 = systemTime(SYSTEM_TIME_MONOTONIC);
+#ifdef MEASURE_DURATION_TVOUT
+ before1 = systemTime(SYSTEM_TIME_MONOTONIC);
#endif
- //suspend
- if(mtvoutcamera == 0) {
- mtvoutcamera = TvOut::connect();
- }
- if(mtvoutcamera != 0 )
- {
- if (mtvoutcamera->isEnabled() )
- {
- mtvoutcamera->DisableTvOut() ; // //TvOutSuspend("Tvout is not available! so what can i do, close camera or any other app which uses fimc");
- suspendTvInit = true;
- }
- }
-
-#ifdef MEASURE_DURATION_TVOUT
- after1 = systemTime(SYSTEM_TIME_MONOTONIC);
- LOGD("%s: MEASURE_DURATION_TVOUT duration=%lld", __func__, ns2us(after1-before1));
+ //suspend
+ if (mtvoutcamera == 0) {
+ mtvoutcamera = TvOut::connect();
+ }
+
+ if (mtvoutcamera != 0) {
+ if (mtvoutcamera->isEnabled()) {
+ mtvoutcamera->DisableTvOut();
+ //TvOutSuspend("Tvout is not available! so what can i do, close camera or any other app which uses fimc");
+ suspendTvInit = true;
+ }
+ }
+
+#ifdef MEASURE_DURATION_TVOUT
+ after1 = systemTime(SYSTEM_TIME_MONOTONIC);
+ LOGD("%s: MEASURE_DURATION_TVOUT duration=%lld", __func__, ns2us(after1-before1));
#endif
-#endif
+#endif
}
int SecCamera::flagCreate(void) const
{
- LOGV("%s() : %d", __FUNCTION__, m_flag_init);
- return m_flag_init;
+ LOGV("%s() : %d", __func__, m_flag_init);
+ return m_flag_init;
}
SecCamera::~SecCamera()
{
- LOGV("%s()", __FUNCTION__);
+ LOGV("%s()", __func__);
#ifdef BOARD_USES_SDTV
- nsecs_t before1, after1;
+ nsecs_t before1, after1;
-#ifdef MEASURE_DURATION_TVOUT
- before1 = systemTime(SYSTEM_TIME_MONOTONIC);
+#ifdef MEASURE_DURATION_TVOUT
+ before1 = systemTime(SYSTEM_TIME_MONOTONIC);
#endif
- //resume
- if(mtvoutcamera != 0 )
- {
- if (!mtvoutcamera->isEnabled() && (mtvoutcamera->isSuspended() ))
- {
- mtvoutcamera->TvOutResume(TVOUT_RESUME_TIME);
- }
- }
- suspendTvInit = false;
-#ifdef MEASURE_DURATION_TVOUT
- after1 = systemTime(SYSTEM_TIME_MONOTONIC);
- LOGD("%s: MEASURE_DURATION_TVOUT duration=%lld", __func__, ns2us(after1-before1));
+ //resume
+ if (mtvoutcamera != 0) {
+ if (!mtvoutcamera->isEnabled() && mtvoutcamera->isSuspended()) {
+ mtvoutcamera->TvOutResume(TVOUT_RESUME_TIME);
+ }
+ }
+ suspendTvInit = false;
+#ifdef MEASURE_DURATION_TVOUT
+ after1 = systemTime(SYSTEM_TIME_MONOTONIC);
+ LOGD("%s: MEASURE_DURATION_TVOUT duration=%lld", __func__, ns2us(after1-before1));
+#endif
#endif
-#endif
}
int SecCamera::initCamera(int index)
{
- LOGV("%s()", __FUNCTION__);
- int ret = 0;
+ LOGV("%s()", __func__);
+ int ret = 0;
- if(!m_flag_init)
- {
- /* Arun C
- * Reset the lense position only during camera starts; don't do
- * reset between shot to shot
- */
- m_camera_af_flag = -1;
+ if (!m_flag_init) {
+ /* Arun C
+ * Reset the lense position only during camera starts; don't do
+ * reset between shot to shot
+ */
+ m_camera_af_flag = -1;
#ifdef BOARD_USES_SDTV
- nsecs_t before1, after1;
+ nsecs_t before1, after1;
-#ifdef MEASURE_DURATION_TVOUT
- before1 = systemTime(SYSTEM_TIME_MONOTONIC);
+#ifdef MEASURE_DURATION_TVOUT
+ before1 = systemTime(SYSTEM_TIME_MONOTONIC);
#endif
-
- //suspend
- if(mtvoutcamera == 0) {
- mtvoutcamera = TvOut::connect();
- }
-
-
-
- if(mtvoutcamera != 0 )
- {
-
- if ( mtvoutcamera->isEnabled() )
- {
-
- mtvoutcamera->DisableTvOut() ;
- suspendTvInit = true;
- }
- }
-
-#ifdef MEASURE_DURATION_TVOUT
- after1 = systemTime(SYSTEM_TIME_MONOTONIC);
- LOGD("%s: MEASURE_DURATION_TVOUT duration=%lld", __func__, ns2us(after1-before1));
+
+ //suspend
+ if (mtvoutcamera == 0) {
+ mtvoutcamera = TvOut::connect();
+ }
+
+ if (mtvoutcamera != 0) {
+ if (mtvoutcamera->isEnabled()) {
+
+ mtvoutcamera->DisableTvOut();
+ suspendTvInit = true;
+ }
+ }
+
+#ifdef MEASURE_DURATION_TVOUT
+ after1 = systemTime(SYSTEM_TIME_MONOTONIC);
+ LOGD("%s: MEASURE_DURATION_TVOUT duration=%lld", __func__, ns2us(after1-before1));
#endif
#endif
#ifndef JPEG_FROM_SENSOR
- m_jpeg_fd = SsbSipJPEGEncodeInit();
- LOGD("(%s):JPEG device open ID = %d\n", __FUNCTION__,m_jpeg_fd);
- if(m_jpeg_fd < 0)
- {
- m_jpeg_fd = 0;
- LOGE("ERR(%s):Cannot open a jpeg device file\n", __FUNCTION__);
- return -1;
- }
+ m_jpeg_fd = SsbSipJPEGEncodeInit();
+ LOGD("(%s):JPEG device open ID = %d\n", __func__, m_jpeg_fd);
+ if (m_jpeg_fd < 0) {
+ m_jpeg_fd = 0;
+ LOGE("ERR(%s):Cannot open a jpeg device file\n", __func__);
+ return -1;
+ }
#endif
- m_cam_fd_temp = -1;
- m_cam_fd2_temp = -1;
+ m_cam_fd_temp = -1;
+ m_cam_fd2_temp = -1;
- m_cam_fd = open(CAMERA_DEV_NAME, O_RDWR);
- if (m_cam_fd < 0)
- {
- LOGE("ERR(%s):Cannot open %s (error : %s)\n", __FUNCTION__, CAMERA_DEV_NAME, strerror(errno));
+ m_cam_fd = open(CAMERA_DEV_NAME, O_RDWR);
+ if (m_cam_fd < 0) {
+ LOGE("ERR(%s):Cannot open %s (error : %s)\n", __func__, CAMERA_DEV_NAME, strerror(errno));
#ifndef JPEG_FROM_SENSOR
- SsbSipJPEGEncodeDeInit(m_jpeg_fd);
+ SsbSipJPEGEncodeDeInit(m_jpeg_fd);
#endif
- return -1;
- }
-
- if(m_cam_fd < 3) { // for 0, 1, 2
- LOGE("ERR(%s):m_cam_fd is %d\n", __FUNCTION__, m_cam_fd);
-
- close(m_cam_fd);
-
- m_cam_fd_temp = open(CAMERA_DEV_NAME_TEMP, O_CREAT);
-
- LOGE("ERR(%s):m_cam_fd_temp is %d\n", __FUNCTION__, m_cam_fd_temp);
-
- m_cam_fd = open(CAMERA_DEV_NAME, O_RDWR);
-
- if(m_cam_fd < 3) { // for 0, 1, 2
- LOGE("ERR(%s):retring to open %s is failed, %d\n", __FUNCTION__, CAMERA_DEV_NAME, m_cam_fd);
-
- if (m_cam_fd < 0){
- return -1;
- }
- else{
- close(m_cam_fd);
- m_cam_fd = -1;
- }
-
- if(m_cam_fd_temp != -1){
- close(m_cam_fd_temp);
- m_cam_fd_temp = -1;
- }
- return -1;
- }
- }
-
- LOGE("initCamera: m_cam_fd(%d), m_jpeg_fd(%d)", m_cam_fd, m_jpeg_fd);
-
- ret = fimc_v4l2_querycap(m_cam_fd);
- CHECK(ret);
- ret = fimc_v4l2_enuminput(m_cam_fd, index);
- CHECK(ret);
- ret = fimc_v4l2_s_input(m_cam_fd, index);
- CHECK(ret);
+ return -1;
+ }
+
+ if (m_cam_fd < 3) { // for 0, 1, 2
+ LOGE("ERR(%s):m_cam_fd is %d\n", __func__, m_cam_fd);
+
+ close(m_cam_fd);
+
+ m_cam_fd_temp = open(CAMERA_DEV_NAME_TEMP, O_CREAT);
+
+ LOGE("ERR(%s):m_cam_fd_temp is %d\n", __func__, m_cam_fd_temp);
+
+ m_cam_fd = open(CAMERA_DEV_NAME, O_RDWR);
+
+ if (m_cam_fd < 3) { // for 0, 1, 2
+ LOGE("ERR(%s):retring to open %s is failed, %d\n", __func__, CAMERA_DEV_NAME, m_cam_fd);
+
+ if (m_cam_fd < 0) {
+ return -1;
+ } else {
+ close(m_cam_fd);
+ m_cam_fd = -1;
+ }
+
+ if (m_cam_fd_temp != -1){
+ close(m_cam_fd_temp);
+ m_cam_fd_temp = -1;
+ }
+ return -1;
+ }
+ }
+
+ LOGE("initCamera: m_cam_fd(%d), m_jpeg_fd(%d)", m_cam_fd, m_jpeg_fd);
+
+ ret = fimc_v4l2_querycap(m_cam_fd);
+ CHECK(ret);
+ ret = fimc_v4l2_enuminput(m_cam_fd, index);
+ CHECK(ret);
+ ret = fimc_v4l2_s_input(m_cam_fd, index);
+ CHECK(ret);
#ifdef DUAL_PORT_RECORDING
- m_cam_fd2 = open(CAMERA_DEV_NAME2, O_RDWR);
- if (m_cam_fd2 < 0)
- {
- LOGE("ERR(%s):Cannot open %s (error : %s)\n", __FUNCTION__, CAMERA_DEV_NAME2, strerror(errno));
- return -1;
- }
- if(m_cam_fd2 < 3) { // for 0, 1, 2
- LOGE("ERR(%s):m_cam_fd2 is %d\n", __FUNCTION__, m_cam_fd2);
-
- close(m_cam_fd2);
-
- m_cam_fd2_temp = open(CAMERA_DEV_NAME2_TEMP, O_CREAT);
-
- LOGE("ERR(%s):m_cam_fd2_temp is %d\n", __FUNCTION__, m_cam_fd2_temp);
-
- m_cam_fd2 = open(CAMERA_DEV_NAME2, O_RDWR);
-
- if(m_cam_fd2 < 3) { // for 0, 1, 2
- LOGE("ERR(%s):retring to open %s is failed, %d\n", __FUNCTION__, CAMERA_DEV_NAME2, m_cam_fd2);
-
- if (m_cam_fd2 < 0){
- return -1;
- }
- else{
- close(m_cam_fd2);
- m_cam_fd2 = -1;
- }
-
- if(m_cam_fd2_temp != -1){
- close(m_cam_fd2_temp);
- m_cam_fd2_temp = -1;
- }
-
- return -1;
- }
- }
-
- if(m_cam_fd_temp != -1){
- close(m_cam_fd_temp);
- m_cam_fd_temp = -1;
- }
-
- if(m_cam_fd2_temp != -1){
- close(m_cam_fd2_temp);
- m_cam_fd2_temp = -1;
- }
-
- LOGE("initCamera: m_cam_fd2(%d)", m_cam_fd2);
-
- ret = fimc_v4l2_querycap(m_cam_fd2);
- CHECK(ret);
- ret = fimc_v4l2_enuminput(m_cam_fd2, index);
- CHECK(ret);
- ret = fimc_v4l2_s_input(m_cam_fd2, index);
- CHECK(ret);
+ m_cam_fd2 = open(CAMERA_DEV_NAME2, O_RDWR);
+ if (m_cam_fd2 < 0) {
+ LOGE("ERR(%s):Cannot open %s (error : %s)\n", __func__, CAMERA_DEV_NAME2, strerror(errno));
+ return -1;
+ }
+ if (m_cam_fd2 < 3) { // for 0, 1, 2
+ LOGE("ERR(%s):m_cam_fd2 is %d\n", __func__, m_cam_fd2);
+
+ close(m_cam_fd2);
+
+ m_cam_fd2_temp = open(CAMERA_DEV_NAME2_TEMP, O_CREAT);
+
+ LOGE("ERR(%s):m_cam_fd2_temp is %d\n", __func__, m_cam_fd2_temp);
+
+ m_cam_fd2 = open(CAMERA_DEV_NAME2, O_RDWR);
+
+ if (m_cam_fd2 < 3) { // for 0, 1, 2
+ LOGE("ERR(%s):retring to open %s is failed, %d\n", __func__, CAMERA_DEV_NAME2, m_cam_fd2);
+
+ if (m_cam_fd2 < 0) {
+ return -1;
+ }
+ else{
+ close(m_cam_fd2);
+ m_cam_fd2 = -1;
+ }
+
+ if (m_cam_fd2_temp != -1) {
+ close(m_cam_fd2_temp);
+ m_cam_fd2_temp = -1;
+ }
+
+ return -1;
+ }
+ }
+
+ if (m_cam_fd_temp != -1) {
+ close(m_cam_fd_temp);
+ m_cam_fd_temp = -1;
+ }
+
+ if (m_cam_fd2_temp != -1) {
+ close(m_cam_fd2_temp);
+ m_cam_fd2_temp = -1;
+ }
+
+ LOGE("initCamera: m_cam_fd2(%d)", m_cam_fd2);
+
+ ret = fimc_v4l2_querycap(m_cam_fd2);
+ CHECK(ret);
+ ret = fimc_v4l2_enuminput(m_cam_fd2, index);
+ CHECK(ret);
+ ret = fimc_v4l2_s_input(m_cam_fd2, index);
+ CHECK(ret);
#endif
setExifFixedAttribute();
- m_camera_id = index;
- m_flag_init = 1;
- }
- return 0;
+ m_camera_id = index;
+ m_flag_init = 1;
+ }
+ return 0;
}
void SecCamera::resetCamera()
{
- LOGV("%s()", __FUNCTION__);
- DeinitCamera();
- initCamera(m_camera_id);
+ LOGV("%s()", __func__);
+ DeinitCamera();
+ initCamera(m_camera_id);
}
void SecCamera::DeinitCamera()
{
- LOGV("%s()", __FUNCTION__);
+ LOGV("%s()", __func__);
- if(m_flag_init)
- {
+ if (m_flag_init) {
#ifndef JPEG_FROM_SENSOR
- if(m_jpeg_fd > 0)
- {
- if(SsbSipJPEGEncodeDeInit(m_jpeg_fd) != JPEG_OK)
- {
- LOGE("ERR(%s):Fail on SsbSipJPEGEncodeDeInit\n", __FUNCTION__);
- }
- m_jpeg_fd = 0;
- }
+ if (m_jpeg_fd > 0) {
+ if (SsbSipJPEGEncodeDeInit(m_jpeg_fd) != JPEG_OK) {
+ LOGE("ERR(%s):Fail on SsbSipJPEGEncodeDeInit\n", __func__);
+ }
+ m_jpeg_fd = 0;
+ }
#endif
- LOGE("DeinitCamera: m_cam_fd(%d)", m_cam_fd);
- if(m_cam_fd > -1)
- {
- close(m_cam_fd);
- m_cam_fd = -1;
- }
+ LOGE("DeinitCamera: m_cam_fd(%d)", m_cam_fd);
+ if (m_cam_fd > -1) {
+ close(m_cam_fd);
+ m_cam_fd = -1;
+ }
#ifdef DUAL_PORT_RECORDING
- LOGE("DeinitCamera: m_cam_fd2(%d)", m_cam_fd2);
- if(m_cam_fd2 > -1)
- {
- close(m_cam_fd2);
- m_cam_fd2 = -1;
- }
+ LOGE("DeinitCamera: m_cam_fd2(%d)", m_cam_fd2);
+ if (m_cam_fd2 > -1) {
+ close(m_cam_fd2);
+ m_cam_fd2 = -1;
+ }
#endif
- if(m_cam_fd_temp != -1){
- close(m_cam_fd_temp);
- m_cam_fd_temp = -1;
- }
+ if (m_cam_fd_temp != -1) {
+ close(m_cam_fd_temp);
+ m_cam_fd_temp = -1;
+ }
- if(m_cam_fd2_temp != -1){
- close(m_cam_fd2_temp);
- m_cam_fd2_temp = -1;
- }
+ if (m_cam_fd2_temp != -1) {
+ close(m_cam_fd2_temp);
+ m_cam_fd2_temp = -1;
+ }
#ifdef BOARD_USES_SDTV
- nsecs_t before1, after1;
+ nsecs_t before1, after1;
-#ifdef MEASURE_DURATION_TVOUT
- before1 = systemTime(SYSTEM_TIME_MONOTONIC);
+#ifdef MEASURE_DURATION_TVOUT
+ before1 = systemTime(SYSTEM_TIME_MONOTONIC);
#endif
- if(mtvoutcamera == 0) {
- mtvoutcamera = TvOut::connect();
-
- }
-
- //resume
- if(mtvoutcamera != 0 )
- {
-
- if(mtvoutcamera->isSuspended())
- {
- mtvoutcamera->TvOutResume(TVOUT_RESUME_TIME);
- }
- }
-#ifdef MEASURE_DURATION_TVOUT
- after1 = systemTime(SYSTEM_TIME_MONOTONIC);
- LOGD("%s: MEASURE_DURATION_TVOUT duration=%lld", __func__, ns2us(after1-before1));
+ if (mtvoutcamera == 0) {
+ mtvoutcamera = TvOut::connect();
+ }
+
+ //resume
+ if (mtvoutcamera != 0 ) {
+ if (mtvoutcamera->isSuspended()) {
+ mtvoutcamera->TvOutResume(TVOUT_RESUME_TIME);
+ }
+ }
+#ifdef MEASURE_DURATION_TVOUT
+ after1 = systemTime(SYSTEM_TIME_MONOTONIC);
+ LOGD("%s: MEASURE_DURATION_TVOUT duration=%lld", __func__, ns2us(after1-before1));
#endif
#endif
- m_flag_init = 0;
- usleep(100000); //100 ms delay to allow proper closure of fimc device.
- }
+ m_flag_init = 0;
+ usleep(100000); //100 ms delay to allow proper closure of fimc device.
+ }
}
int SecCamera::getCameraFd(void)
{
- return m_cam_fd;
+ return m_cam_fd;
}
#ifdef SWP1_CAMERA_ADD_ADVANCED_FUNCTION
int SecCamera::setCameraSensorReset(void)
{
- int ret = 0;
-
- LOGV("%s", __FUNCTION__);
+ int ret = 0;
- ret = fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_CAMERA_RESET, 0);
- CHECK(ret);
-
- return ret;
+ LOGV("%s", __func__);
+
+ ret = fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_CAMERA_RESET, 0);
+ CHECK(ret);
+
+ return ret;
}
-int SecCamera::setDefultIMEI(int imei)
+int SecCamera::setDefultIMEI(int imei)
{
- LOGV("%s(m_default_imei (%d))", __FUNCTION__, imei);
-
- if(m_default_imei != imei)
- {
- m_default_imei = imei;
- }
- return 0;
+ LOGV("%s(m_default_imei (%d))", __func__, imei);
+
+ if (m_default_imei != imei) {
+ m_default_imei = imei;
+ }
+ return 0;
}
-int SecCamera::getDefultIMEI(void)
+int SecCamera::getDefultIMEI(void)
{
- return m_default_imei;
+ return m_default_imei;
}
-#endif /* SWP1_CAMERA_ADD_ADVANCED_FUNCTION */
+#endif /* SWP1_CAMERA_ADD_ADVANCED_FUNCTION */
// ======================================================================
@@ -1082,544 +1041,531 @@ int SecCamera::getDefultIMEI(void)
int SecCamera::flagPreviewStart(void)
{
- LOGV("%s:started(%d)", __func__, m_flag_camera_start);
-
- return m_flag_camera_start > 0;
+ LOGV("%s:started(%d)", __func__, m_flag_camera_start);
+
+ return m_flag_camera_start > 0;
}
int SecCamera::startPreview(void)
{
#ifdef SWP1_CAMERA_ADD_ADVANCED_FUNCTION
- LOGV("%s()", __FUNCTION__);
-#else /* SWP1_CAMERA_ADD_ADVANCED_FUNCTION */
- LOGE("%s()", __FUNCTION__);
-#endif /* SWP1_CAMERA_ADD_ADVANCED_FUNCTION */
-
- // aleady started
- if(m_flag_camera_start > 0)
- {
- LOGE("ERR(%s):Preview was already started\n", __FUNCTION__);
- return 0;
- }
-
- if(m_cam_fd <= 0)
- {
- LOGE("ERR(%s):Camera was closed\n", __FUNCTION__);
- return -1;
- }
-
- memset(&m_events_c, 0, sizeof(m_events_c));
- m_events_c.fd = m_cam_fd;
- m_events_c.events = POLLIN | POLLERR;
-
- /* enum_fmt, s_fmt sample */
- int ret = fimc_v4l2_enum_fmt(m_cam_fd,m_preview_v4lformat);
- CHECK(ret);
- ret = fimc_v4l2_s_fmt(m_cam_fd, m_preview_width,m_preview_height,m_preview_v4lformat, 0);
- CHECK(ret);
-
- init_yuv_buffers(m_buffers_c, m_preview_width, m_preview_height, m_preview_v4lformat);
- ret = fimc_v4l2_reqbufs(m_cam_fd, V4L2_BUF_TYPE_VIDEO_CAPTURE, MAX_BUFFERS);
- CHECK(ret);
- ret = fimc_v4l2_querybuf(m_cam_fd, m_buffers_c, V4L2_BUF_TYPE_VIDEO_CAPTURE, MAX_BUFFERS);
- CHECK(ret);
-
- /* g_parm, s_parm sample */
- ret = fimc_v4l2_g_parm(m_cam_fd);
- CHECK(ret);
- ret = fimc_v4l2_s_parm(m_cam_fd, 1, m_fps);
- CHECK(ret);
-
-#ifdef SWP1_CAMERA_ADD_ADVANCED_FUNCTION
- LOGE("%s()m_preview_width: %d m_preview_height: %d m_angle: %d\n", __FUNCTION__, m_preview_width,m_preview_height,m_angle);
- ret = fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_ROTATION, m_angle);
- CHECK(ret);
-
- ret = fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_CAMERA_CHECK_DATALINE, m_chk_dataline);
- CHECK(ret);
-
- if(m_camera_id == CAMERA_ID_BACK)
- {
- /*Should be set before starting preview*/
- ret = fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_CAMERA_ANTI_BANDING, m_anti_banding);
- CHECK(ret);
- ret = fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_CAMERA_ISO, m_iso);
- CHECK(ret);
- ret = fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_CAMERA_BRIGHTNESS, m_brightness + BRIGHTNESS_NORMAL);
- CHECK(ret);
- ret = fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_CAMERA_FRAME_RATE, m_fps);
- CHECK(ret);
- ret = fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_CAMERA_METERING, m_metering);
- CHECK(ret);
- ret = fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_CAMERA_SET_GAMMA, m_video_gamma);
- CHECK(ret);
- ret = fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_CAMERA_SET_SLOW_AE, m_slow_ae);
- CHECK(ret);
- ret = fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_CAMERA_EFFECT, m_image_effect);
- CHECK(ret);
- ret = fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_CAMERA_WHITE_BALANCE, m_white_balance);
- CHECK(ret);
- }
- else
- {
- /* VT mode setting */
- ret = fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_CAMERA_VT_MODE, m_vtmode);
- CHECK(ret);
- }
+ LOGV("%s()", __func__);
+#else /* SWP1_CAMERA_ADD_ADVANCED_FUNCTION */
+ LOGE("%s()", __func__);
+#endif /* SWP1_CAMERA_ADD_ADVANCED_FUNCTION */
+
+ // aleady started
+ if (m_flag_camera_start > 0) {
+ LOGE("ERR(%s):Preview was already started\n", __func__);
+ return 0;
+ }
+
+ if (m_cam_fd <= 0) {
+ LOGE("ERR(%s):Camera was closed\n", __func__);
+ return -1;
+ }
+
+ memset(&m_events_c, 0, sizeof(m_events_c));
+ m_events_c.fd = m_cam_fd;
+ m_events_c.events = POLLIN | POLLERR;
+
+ /* enum_fmt, s_fmt sample */
+ int ret = fimc_v4l2_enum_fmt(m_cam_fd,m_preview_v4lformat);
+ CHECK(ret);
+ ret = fimc_v4l2_s_fmt(m_cam_fd, m_preview_width,m_preview_height,m_preview_v4lformat, 0);
+ CHECK(ret);
+
+ init_yuv_buffers(m_buffers_c, m_preview_width, m_preview_height, m_preview_v4lformat);
+ ret = fimc_v4l2_reqbufs(m_cam_fd, V4L2_BUF_TYPE_VIDEO_CAPTURE, MAX_BUFFERS);
+ CHECK(ret);
+ ret = fimc_v4l2_querybuf(m_cam_fd, m_buffers_c, V4L2_BUF_TYPE_VIDEO_CAPTURE, MAX_BUFFERS);
+ CHECK(ret);
+
+ /* g_parm, s_parm sample */
+ ret = fimc_v4l2_g_parm(m_cam_fd);
+ CHECK(ret);
+ ret = fimc_v4l2_s_parm(m_cam_fd, 1, m_fps);
+ CHECK(ret);
+
+#ifdef SWP1_CAMERA_ADD_ADVANCED_FUNCTION
+ LOGE("%s()m_preview_width: %d m_preview_height: %d m_angle: %d\n",
+ __func__, m_preview_width, m_preview_height, m_angle);
+ ret = fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_ROTATION, m_angle);
+ CHECK(ret);
+
+ ret = fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_CAMERA_CHECK_DATALINE, m_chk_dataline);
+ CHECK(ret);
+
+ if (m_camera_id == CAMERA_ID_BACK) {
+ /*Should be set before starting preview*/
+ ret = fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_CAMERA_ANTI_BANDING, m_anti_banding);
+ CHECK(ret);
+ ret = fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_CAMERA_ISO, m_iso);
+ CHECK(ret);
+ ret = fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_CAMERA_BRIGHTNESS, m_brightness + BRIGHTNESS_NORMAL);
+ CHECK(ret);
+ ret = fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_CAMERA_FRAME_RATE, m_fps);
+ CHECK(ret);
+ ret = fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_CAMERA_METERING, m_metering);
+ CHECK(ret);
+ ret = fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_CAMERA_SET_GAMMA, m_video_gamma);
+ CHECK(ret);
+ ret = fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_CAMERA_SET_SLOW_AE, m_slow_ae);
+ CHECK(ret);
+ ret = fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_CAMERA_EFFECT, m_image_effect);
+ CHECK(ret);
+ ret = fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_CAMERA_WHITE_BALANCE, m_white_balance);
+ CHECK(ret);
+ } else {
+ /* VT mode setting */
+ ret = fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_CAMERA_VT_MODE, m_vtmode);
+ CHECK(ret);
+ }
#endif
- /* start with all buffers in queue */
- for (int i = 0; i < MAX_BUFFERS; i++)
- {
- ret = fimc_v4l2_qbuf(m_cam_fd, i);
- CHECK(ret);
- }
-
- ret = fimc_v4l2_streamon(m_cam_fd);
- CHECK(ret);
-
+ /* start with all buffers in queue */
+ for (int i = 0; i < MAX_BUFFERS; i++) {
+ ret = fimc_v4l2_qbuf(m_cam_fd, i);
+ CHECK(ret);
+ }
+
+ ret = fimc_v4l2_streamon(m_cam_fd);
+ CHECK(ret);
+
#ifdef SWP1_CAMERA_ADD_ADVANCED_FUNCTION
- m_flag_camera_start = 1; //Kamat check
-
- if(m_camera_id == CAMERA_ID_BACK) {
- ret = fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_CAMERA_EFFECT, m_image_effect);
- CHECK(ret);
- ret = fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_CAMERA_WHITE_BALANCE, m_white_balance);
- CHECK(ret);
- ret = fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_CAMERA_ISO, m_iso);
- CHECK(ret);
- if(m_focus_mode ==FOCUS_MODE_FACEDETECT)
- ret = fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_CAMERA_FOCUS_MODE, FOCUS_MODE_AUTO);
- else{
- if(m_shot_mode == 2){ //Panorama shot
- ret = fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_CAMERA_FOCUS_MODE, m_focus_mode);
- CHECK(ret);
- m_camera_af_flag = -1;
- }
- else if(m_shot_mode == 3){ //Smile shot
- ret = fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_CAMERA_FOCUS_MODE, m_focus_mode);
- CHECK(ret);
- m_camera_af_flag = -1;
- }
- else if (m_camera_af_flag < 0) { //After captur, Focus is fixed.
- ret = fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_CAMERA_FOCUS_MODE, m_focus_mode);
- CHECK(ret);
- m_camera_af_flag = 0;
- }
- }
- ret = fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_CAMERA_FRAME_RATE, m_fps);
- CHECK(ret);
- ret = fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_CAMERA_METERING, m_metering);
- CHECK(ret);
- ret = fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_CAMERA_SATURATION, m_saturation);
- CHECK(ret);
- ret = fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_CAMERA_CONTRAST, m_contrast);
- CHECK(ret);
- ret = fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_CAMERA_ZOOM, m_zoom_level);
- CHECK(ret);
- ret = fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_CAMERA_SENSOR_MODE, m_sensor_mode);
- CHECK(ret);
- // Apply the scene mode only in camera not in camcorder
- if (!m_sensor_mode)
- {
- ret = fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_CAMERA_SCENE_MODE, m_scene_mode);
- CHECK(ret);
- }
- ret = fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_CAMERA_BRIGHTNESS, m_brightness + BRIGHTNESS_NORMAL);
- CHECK(ret);
- ret = fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_CAMERA_SHARPNESS, m_sharpness);
- CHECK(ret);
- }
- else // In case VGA camera
- {
- /* Brightness setting */
- ret = fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_CAMERA_BRIGHTNESS, m_brightness + BRIGHTNESS_NORMAL);
- CHECK(ret);
- }
+ m_flag_camera_start = 1; //Kamat check
+
+ if (m_camera_id == CAMERA_ID_BACK) {
+ ret = fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_CAMERA_EFFECT, m_image_effect);
+ CHECK(ret);
+ ret = fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_CAMERA_WHITE_BALANCE, m_white_balance);
+ CHECK(ret);
+ ret = fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_CAMERA_ISO, m_iso);
+ CHECK(ret);
+ if (m_focus_mode ==FOCUS_MODE_FACEDETECT)
+ ret = fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_CAMERA_FOCUS_MODE, FOCUS_MODE_AUTO);
+ else {
+ if (m_shot_mode == 2) { //Panorama shot
+ ret = fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_CAMERA_FOCUS_MODE, m_focus_mode);
+ CHECK(ret);
+ m_camera_af_flag = -1;
+ } else if (m_shot_mode == 3) { //Smile shot
+ ret = fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_CAMERA_FOCUS_MODE, m_focus_mode);
+ CHECK(ret);
+ m_camera_af_flag = -1;
+ } else if (m_camera_af_flag < 0) { //After captur, Focus is fixed.
+ ret = fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_CAMERA_FOCUS_MODE, m_focus_mode);
+ CHECK(ret);
+ m_camera_af_flag = 0;
+ }
+ }
+ ret = fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_CAMERA_FRAME_RATE, m_fps);
+ CHECK(ret);
+ ret = fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_CAMERA_METERING, m_metering);
+ CHECK(ret);
+ ret = fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_CAMERA_SATURATION, m_saturation);
+ CHECK(ret);
+ ret = fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_CAMERA_CONTRAST, m_contrast);
+ CHECK(ret);
+ ret = fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_CAMERA_ZOOM, m_zoom_level);
+ CHECK(ret);
+ ret = fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_CAMERA_SENSOR_MODE, m_sensor_mode);
+ CHECK(ret);
+ // Apply the scene mode only in camera not in camcorder
+ if (!m_sensor_mode) {
+ ret = fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_CAMERA_SCENE_MODE, m_scene_mode);
+ CHECK(ret);
+ }
+ ret = fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_CAMERA_BRIGHTNESS, m_brightness + BRIGHTNESS_NORMAL);
+ CHECK(ret);
+ ret = fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_CAMERA_SHARPNESS, m_sharpness);
+ CHECK(ret);
+ } else { // In case VGA camera
+ /* Brightness setting */
+ ret = fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_CAMERA_BRIGHTNESS, m_brightness + BRIGHTNESS_NORMAL);
+ CHECK(ret);
+ }
#endif
- // It is a delay for a new frame, not to show the previous bigger ugly picture frame.
- ret = fimc_poll(&m_events_c);
- CHECK(ret);
+ // It is a delay for a new frame, not to show the previous bigger ugly picture frame.
+ ret = fimc_poll(&m_events_c);
+ CHECK(ret);
#ifdef SWP1_CAMERA_ADD_ADVANCED_FUNCTION
- LOGE("%s: get the first frame of the preview\n", __FUNCTION__);
-#endif /* SWP1_CAMERA_ADD_ADVANCED_FUNCTION */
+ LOGE("%s: get the first frame of the preview\n", __func__);
+#endif /* SWP1_CAMERA_ADD_ADVANCED_FUNCTION */
#ifndef SWP1_CAMERA_ADD_ADVANCED_FUNCTION
- m_flag_camera_start = 1; //Kamat check
-#endif /* SWP1_CAMERA_ADD_ADVANCED_FUNCTION */
+ m_flag_camera_start = 1; //Kamat check
+#endif /* SWP1_CAMERA_ADD_ADVANCED_FUNCTION */
#ifdef ENABLE_HDMI_DISPLAY
- hdmi_initialize(m_preview_width,m_preview_height);
- hdmi_gl_initialize(0);
- hdmi_gl_streamoff(0);
-#endif
+ hdmi_initialize(m_preview_width,m_preview_height);
+ hdmi_gl_initialize(0);
+ hdmi_gl_streamoff(0);
+#endif
#ifdef BOARD_USES_SDTV
- if(suspendTvInit ==true )
- {
- if(!mtvoutcamera->isSuspended())
- {
- mtvoutcamera->TvOutSuspend("") ;
- }
- }
-
-#endif
+ if (suspendTvInit == true) {
+ if (!mtvoutcamera->isSuspended()) {
+ mtvoutcamera->TvOutSuspend("");
+ }
+ }
- return 0;
+#endif
+ return 0;
}
int SecCamera::stopPreview(void)
{
#ifdef SWP1_CAMERA_ADD_ADVANCED_FUNCTION
- LOGE("%s()\n", __FUNCTION__);
-
- close_buffers(m_buffers_c);
-
- if(m_flag_camera_start == 0) {
- LOGE("%s: m_flag_camera_start is zero", __FUNCTION__);
- return 0;
- }
-#else /* SWP1_CAMERA_ADD_ADVANCED_FUNCTION */
- LOGV("%s()", __FUNCTION__);
-
- close_buffers(m_buffers_c);
-
- if(m_flag_camera_start == 0)
- return 0;
-#endif /* SWP1_CAMERA_ADD_ADVANCED_FUNCTION */
+ LOGE("%s()\n", __func__);
+
+ close_buffers(m_buffers_c);
+
+ if (m_flag_camera_start == 0) {
+ LOGE("%s: m_flag_camera_start is zero", __func__);
+ return 0;
+ }
+#else /* SWP1_CAMERA_ADD_ADVANCED_FUNCTION */
+ LOGV("%s()", __func__);
+
+ close_buffers(m_buffers_c);
+
+ if (m_flag_camera_start == 0)
+ return 0;
+#endif /* SWP1_CAMERA_ADD_ADVANCED_FUNCTION */
#ifdef ENABLE_HDMI_DISPLAY
- hdmi_deinitialize();
- hdmi_gl_streamon(0);
+ hdmi_deinitialize();
+ hdmi_gl_streamon(0);
#endif
- if(m_cam_fd <= 0)
- {
- LOGE("ERR(%s):Camera was closed\n", __FUNCTION__);
- return -1;
- }
+ if (m_cam_fd <= 0) {
+ LOGE("ERR(%s):Camera was closed\n", __func__);
+ return -1;
+ }
- int ret = fimc_v4l2_streamoff(m_cam_fd);
+ int ret = fimc_v4l2_streamoff(m_cam_fd);
- m_flag_camera_start = 0; //Kamat check
- CHECK(ret);
+ m_flag_camera_start = 0; //Kamat check
+ CHECK(ret);
- return ret;
+ return ret;
}
//Recording
#ifdef DUAL_PORT_RECORDING
int SecCamera::startRecord(void)
{
- LOGV("%s()", __FUNCTION__);
-
- // aleady started
- if(m_flag_record_start > 0)
- {
- LOGE("ERR(%s):Preview was already started\n", __FUNCTION__);
- return 0;
- }
-
- if(m_cam_fd2 <= 0)
- {
- LOGE("ERR(%s):Camera was closed\n", __FUNCTION__);
- return -1;
- }
-
- memset(&m_events_c2, 0, sizeof(m_events_c2));
- m_events_c2.fd = m_cam_fd2;
- m_events_c2.events = POLLIN | POLLERR;
-
- int m_record_v4lformat = V4L2_PIX_FMT_NV12T; //Kamat: set suitably
- /* enum_fmt, s_fmt sample */
- int ret = fimc_v4l2_enum_fmt(m_cam_fd2,m_record_v4lformat);
- CHECK(ret);
+ LOGV("%s()", __func__);
+
+ // aleady started
+ if (m_flag_record_start > 0) {
+ LOGE("ERR(%s):Preview was already started\n", __func__);
+ return 0;
+ }
+
+ if (m_cam_fd2 <= 0) {
+ LOGE("ERR(%s):Camera was closed\n", __func__);
+ return -1;
+ }
+
+ memset(&m_events_c2, 0, sizeof(m_events_c2));
+ m_events_c2.fd = m_cam_fd2;
+ m_events_c2.events = POLLIN | POLLERR;
+
+ int m_record_v4lformat = V4L2_PIX_FMT_NV12T; //Kamat: set suitably
+ /* enum_fmt, s_fmt sample */
+ int ret = fimc_v4l2_enum_fmt(m_cam_fd2,m_record_v4lformat);
+ CHECK(ret);
#ifdef SWP1_CAMERA_ADD_ADVANCED_FUNCTION
- LOGE("%s: m_recording_width = %d, m_recording_height = %d\n", __FUNCTION__, m_recording_width, m_recording_height);
+ LOGE("%s: m_recording_width = %d, m_recording_height = %d\n", __func__, m_recording_width, m_recording_height);
- ret = fimc_v4l2_s_fmt(m_cam_fd2, m_recording_width, m_recording_height,m_record_v4lformat, 0);
+ ret = fimc_v4l2_s_fmt(m_cam_fd2, m_recording_width, m_recording_height, m_record_v4lformat, 0);
- CHECK(ret);
+ CHECK(ret);
- init_yuv_buffers(m_buffers_c2, m_recording_width, m_recording_height, m_record_v4lformat);
-#else /* SWP1_CAMERA_ADD_ADVANCED_FUNCTION */
- ret = fimc_v4l2_s_fmt(m_cam_fd2, m_preview_width,m_preview_height,m_record_v4lformat, 0);
- CHECK(ret);
+ init_yuv_buffers(m_buffers_c2, m_recording_width, m_recording_height, m_record_v4lformat);
+#else /* SWP1_CAMERA_ADD_ADVANCED_FUNCTION */
+ ret = fimc_v4l2_s_fmt(m_cam_fd2, m_preview_width, m_preview_height, m_record_v4lformat, 0);
+ CHECK(ret);
- init_yuv_buffers(m_buffers_c2, m_preview_width, m_preview_height, m_record_v4lformat);
-#endif /* SWP1_CAMERA_ADD_ADVANCED_FUNCTION */
+ init_yuv_buffers(m_buffers_c2, m_preview_width, m_preview_height, m_record_v4lformat);
+#endif /* SWP1_CAMERA_ADD_ADVANCED_FUNCTION */
- ret = fimc_v4l2_reqbufs(m_cam_fd2, V4L2_BUF_TYPE_VIDEO_CAPTURE, MAX_BUFFERS);
- CHECK(ret);
- ret = fimc_v4l2_querybuf(m_cam_fd2, m_buffers_c2, V4L2_BUF_TYPE_VIDEO_CAPTURE, MAX_BUFFERS);
- CHECK(ret);
+ ret = fimc_v4l2_reqbufs(m_cam_fd2, V4L2_BUF_TYPE_VIDEO_CAPTURE, MAX_BUFFERS);
+ CHECK(ret);
+ ret = fimc_v4l2_querybuf(m_cam_fd2, m_buffers_c2, V4L2_BUF_TYPE_VIDEO_CAPTURE, MAX_BUFFERS);
+ CHECK(ret);
- /* g_parm, s_parm sample */
- ret = fimc_v4l2_g_parm(m_cam_fd2);
- CHECK(ret);
- ret = fimc_v4l2_s_parm(m_cam_fd2, 1, m_fps);
- CHECK(ret);
+ /* g_parm, s_parm sample */
+ ret = fimc_v4l2_g_parm(m_cam_fd2);
+ CHECK(ret);
+ ret = fimc_v4l2_s_parm(m_cam_fd2, 1, m_fps);
+ CHECK(ret);
- /* start with all buffers in queue */
- for (int i = 0; i < MAX_BUFFERS; i++)
- {
- ret = fimc_v4l2_qbuf(m_cam_fd2, i);
- CHECK(ret);
- }
+ /* start with all buffers in queue */
+ for (int i = 0; i < MAX_BUFFERS; i++) {
+ ret = fimc_v4l2_qbuf(m_cam_fd2, i);
+ CHECK(ret);
+ }
- ret = fimc_v4l2_streamon(m_cam_fd2);
- CHECK(ret);
+ ret = fimc_v4l2_streamon(m_cam_fd2);
+ CHECK(ret);
- // It is a delay for a new frame, not to show the previous bigger ugly picture frame.
- ret = fimc_poll(&m_events_c2);
- CHECK(ret);
+ // It is a delay for a new frame, not to show the previous bigger ugly picture frame.
+ ret = fimc_poll(&m_events_c2);
+ CHECK(ret);
- m_flag_record_start = 1; //Kamat check
+ m_flag_record_start = 1; //Kamat check
- return 0;
+ return 0;
}
int SecCamera::stopRecord(void)
{
- if(m_flag_record_start == 0)
- return 0;
-
- LOGV("%s()", __FUNCTION__);
-
- close_buffers(m_buffers_c2);
-
- if(m_cam_fd2 <= 0)
- {
- LOGE("ERR(%s):Camera was closed\n", __FUNCTION__);
- return -1;
- }
+ if (m_flag_record_start == 0)
+ return 0;
+
+ LOGV("%s()", __func__);
+
+ close_buffers(m_buffers_c2);
- int ret = fimc_v4l2_streamoff(m_cam_fd2);
+ if (m_cam_fd2 <= 0) {
+ LOGE("ERR(%s):Camera was closed\n", __func__);
+ return -1;
+ }
- m_flag_record_start = 0; //Kamat check
- CHECK(ret);
+ int ret = fimc_v4l2_streamoff(m_cam_fd2);
- return 0;
+ m_flag_record_start = 0; //Kamat check
+ CHECK(ret);
+
+ return 0;
}
unsigned int SecCamera::getRecPhyAddrY(int index)
{
- unsigned int addr_y;
+ unsigned int addr_y;
- addr_y = fimc_v4l2_s_ctrl(m_cam_fd2, V4L2_CID_PADDR_Y, index);
- CHECK((int)addr_y);
- return addr_y;
+ addr_y = fimc_v4l2_s_ctrl(m_cam_fd2, V4L2_CID_PADDR_Y, index);
+ CHECK((int)addr_y);
+ return addr_y;
}
unsigned int SecCamera::getRecPhyAddrC(int index)
{
- unsigned int addr_c;
+ unsigned int addr_c;
- addr_c = fimc_v4l2_s_ctrl(m_cam_fd2, V4L2_CID_PADDR_CBCR, index);
- CHECK((int)addr_c);
- return addr_c;
+ addr_c = fimc_v4l2_s_ctrl(m_cam_fd2, V4L2_CID_PADDR_CBCR, index);
+ CHECK((int)addr_c);
+ return addr_c;
}
#endif //DUAL_PORT_RECORDING
unsigned int SecCamera::getPhyAddrY(int index)
{
- unsigned int addr_y;
+ unsigned int addr_y;
- addr_y = fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_PADDR_Y, index);
- CHECK((int)addr_y);
- return addr_y;
+ addr_y = fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_PADDR_Y, index);
+ CHECK((int)addr_y);
+ return addr_y;
}
unsigned int SecCamera::getPhyAddrC(int index)
{
- unsigned int addr_c;
+ unsigned int addr_c;
- addr_c = fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_PADDR_CBCR, index);
- CHECK((int)addr_c);
- return addr_c;
+ addr_c = fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_PADDR_CBCR, index);
+ CHECK((int)addr_c);
+ return addr_c;
}
-#ifdef SEND_YUV_RECORD_DATA
-#define PAGE_ALIGN(x) ((x+0xFFF)&(~0xFFF)) // Set as multiple of 4K
-void SecCamera::getYUVBuffers(unsigned char** virYAddr, unsigned char** virCAddr, int index)
+#ifdef SEND_YUV_RECORD_DATA
+#define PAGE_ALIGN(x) (((x) + 0xFFF) & (~0xFFF)) // Set as multiple of 4K
+void SecCamera::getYUVBuffers(unsigned char **virYAddr, unsigned char **virCAddr, int index)
{
- *virYAddr = (unsigned char*)m_buffers_c[index].start;
- //*virCAddr = (unsigned char*)m_buffers_c[index].start + PAGE_ALIGN(m_preview_width * m_preview_height);
- *virCAddr = (unsigned char*)m_buffers_c[index].start + ALIGN_TO_8KB(ALIGN_TO_128B(m_preview_width) * ALIGN_TO_32B(m_preview_height));
+ *virYAddr = (unsigned char*)m_buffers_c[index].start;
+ //*virCAddr = (unsigned char*)m_buffers_c[index].start + PAGE_ALIGN(m_preview_width * m_preview_height);
+ *virCAddr = (unsigned char*)m_buffers_c[index].start +
+ ALIGN_TO_8KB(ALIGN_TO_128B(m_preview_width) * ALIGN_TO_32B(m_preview_height));
}
#endif
void SecCamera::pausePreview()
{
- fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_STREAM_PAUSE, 0);
+ fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_STREAM_PAUSE, 0);
}
int SecCamera::getPreview()
{
- int index;
+ int index;
#ifdef SWP1_CAMERA_ADD_ADVANCED_FUNCTION
- int ret;
+ int ret;
#endif
#ifdef PERFORMANCE
- LOG_TIME_DEFINE(0)
- LOG_TIME_DEFINE(1)
+ LOG_TIME_DEFINE(0)
+ LOG_TIME_DEFINE(1)
- LOG_TIME_START(0)
- fimc_poll(&m_events_c);
- LOG_TIME_END(0)
- LOG_CAMERA("fimc_poll interval: %lu us", LOG_TIME(0));
+ LOG_TIME_START(0)
+ fimc_poll(&m_events_c);
+ LOG_TIME_END(0)
+ LOG_CAMERA("fimc_poll interval: %lu us", LOG_TIME(0));
- LOG_TIME_START(1)
- index = fimc_v4l2_dqbuf(m_cam_fd);
- LOG_TIME_END(1)
- LOG_CAMERA("fimc_dqbuf interval: %lu us", LOG_TIME(1));
+ LOG_TIME_START(1)
+ index = fimc_v4l2_dqbuf(m_cam_fd);
+ LOG_TIME_END(1)
+ LOG_CAMERA("fimc_dqbuf interval: %lu us", LOG_TIME(1));
#else
#ifdef SWP1_CAMERA_ADD_ADVANCED_FUNCTION
- if(m_flag_camera_start == 0 || fimc_esd_poll(&m_events_c) == 0)
- {
- LOGE("ERR(%s):Start Camera Device Reset \n", __FUNCTION__);
- /* GAUDI Project([arun.c@samsung.com]) 2010.05.20. [Implemented ESD code] */
- /*
- * When there is no data for more than 1 second from the camera we inform
- * the FIMC driver by calling fimc_v4l2_s_input() with a special value = 1000
- * FIMC driver identify that there is something wrong with the camera
- * and it restarts the sensor.
- */
- stopPreview();
- /* Reset Only Camera Device */
- ret = fimc_v4l2_querycap(m_cam_fd);
- CHECK(ret);
- ret = fimc_v4l2_enuminput(m_cam_fd, m_camera_id);
- CHECK(ret);
- ret = fimc_v4l2_s_input(m_cam_fd, 1000);
- CHECK(ret);
- //setCameraSensorReset();
- ret = startPreview();
-
- if(ret < 0) {
- LOGE("ERR(%s): startPreview() return %d\n", __FUNCTION__, ret);
-
- return 0;
- }
- }
-#else /* SWP1_CAMERA_ADD_ADVANCED_FUNCTION */
- fimc_poll(&m_events_c);
-#endif /* SWP1_CAMERA_ADD_ADVANCED_FUNCTION */
- index = fimc_v4l2_dqbuf(m_cam_fd);
+ if (m_flag_camera_start == 0 || fimc_esd_poll(&m_events_c) == 0) {
+ LOGE("ERR(%s):Start Camera Device Reset \n", __func__);
+ /* GAUDI Project([arun.c@samsung.com]) 2010.05.20. [Implemented ESD code] */
+ /*
+ * When there is no data for more than 1 second from the camera we inform
+ * the FIMC driver by calling fimc_v4l2_s_input() with a special value = 1000
+ * FIMC driver identify that there is something wrong with the camera
+ * and it restarts the sensor.
+ */
+ stopPreview();
+ /* Reset Only Camera Device */
+ ret = fimc_v4l2_querycap(m_cam_fd);
+ CHECK(ret);
+ ret = fimc_v4l2_enuminput(m_cam_fd, m_camera_id);
+ CHECK(ret);
+ ret = fimc_v4l2_s_input(m_cam_fd, 1000);
+ CHECK(ret);
+ //setCameraSensorReset();
+ ret = startPreview();
+
+ if (ret < 0) {
+ LOGE("ERR(%s): startPreview() return %d\n", __func__, ret);
+ return 0;
+ }
+ }
+#else /* SWP1_CAMERA_ADD_ADVANCED_FUNCTION */
+ fimc_poll(&m_events_c);
+#endif /* SWP1_CAMERA_ADD_ADVANCED_FUNCTION */
+ index = fimc_v4l2_dqbuf(m_cam_fd);
#endif
- if(!(0 <= index && index < MAX_BUFFERS))
- {
- LOGE("ERR(%s):wrong index = %d\n", __FUNCTION__, index);
- return -1;
- }
+ if (!(0 <= index && index < MAX_BUFFERS)) {
+ LOGE("ERR(%s):wrong index = %d\n", __func__, index);
+ return -1;
+ }
#ifdef SWP1_CAMERA_ADD_ADVANCED_FUNCTION
- ret = fimc_v4l2_qbuf(m_cam_fd, index); //Kamat: is it overhead?
-#else /* SWP1_CAMERA_ADD_ADVANCED_FUNCTION */
- int ret = fimc_v4l2_qbuf(m_cam_fd, index); //Kamat: is it overhead?
-#endif /* SWP1_CAMERA_ADD_ADVANCED_FUNCTION */
+ ret = fimc_v4l2_qbuf(m_cam_fd, index); //Kamat: is it overhead?
+#else /* SWP1_CAMERA_ADD_ADVANCED_FUNCTION */
+ int ret = fimc_v4l2_qbuf(m_cam_fd, index); //Kamat: is it overhead?
+#endif /* SWP1_CAMERA_ADD_ADVANCED_FUNCTION */
- CHECK(ret);
+ CHECK(ret);
-#ifdef ENABLE_HDMI_DISPLAY
- hdmi_set_v_param(getPhyAddrY(index), getPhyAddrC (index),m_preview_width,m_preview_height);
+#ifdef ENABLE_HDMI_DISPLAY
+ hdmi_set_v_param(getPhyAddrY(index), getPhyAddrC (index), m_preview_width, m_preview_height);
#endif
- return index;
+ return index;
}
#ifdef DUAL_PORT_RECORDING
int SecCamera::getRecord()
{
- int index;
+ int index;
#ifdef SWP1_CAMERA_ADD_ADVANCED_FUNCTION
- if(m_flag_record_start == 0) {
- LOGE("%s: m_flag_record_start is 0", __FUNCTION__);
- startRecord();
- }
+ if (m_flag_record_start == 0) {
+ LOGE("%s: m_flag_record_start is 0", __func__);
+ startRecord();
+ }
#endif
#ifdef PERFORMANCE
- LOG_TIME_DEFINE(0)
- LOG_TIME_DEFINE(1)
+ LOG_TIME_DEFINE(0)
+ LOG_TIME_DEFINE(1)
- LOG_TIME_START(0)
- fimc_poll(&m_events_c2);
- LOG_TIME_END(0)
- LOG_CAMERA("fimc_poll interval: %lu us", LOG_TIME(0));
+ LOG_TIME_START(0)
+ fimc_poll(&m_events_c2);
+ LOG_TIME_END(0)
+ LOG_CAMERA("fimc_poll interval: %lu us", LOG_TIME(0));
- LOG_TIME_START(1)
- index = fimc_v4l2_dqbuf(m_cam_fd2);
- LOG_TIME_END(1)
- LOG_CAMERA("fimc_dqbuf interval: %lu us", LOG_TIME(1));
+ LOG_TIME_START(1)
+ index = fimc_v4l2_dqbuf(m_cam_fd2);
+ LOG_TIME_END(1)
+ LOG_CAMERA("fimc_dqbuf interval: %lu us", LOG_TIME(1));
#else
- fimc_poll(&m_events_c2);
- index = fimc_v4l2_dqbuf(m_cam_fd2);
+ fimc_poll(&m_events_c2);
+ index = fimc_v4l2_dqbuf(m_cam_fd2);
#endif
- if(!(0 <= index && index < MAX_BUFFERS))
- {
- LOGE("ERR(%s):wrong index = %d\n", __FUNCTION__, index);
- return -1;
- }
+ if (!(0 <= index && index < MAX_BUFFERS)) {
+ LOGE("ERR(%s):wrong index = %d\n", __func__, index);
+ return -1;
+ }
- int ret = fimc_v4l2_qbuf(m_cam_fd2, index); //Kamat: is it overhead?
- CHECK(ret);
+ int ret = fimc_v4l2_qbuf(m_cam_fd2, index); //Kamat: is it overhead?
+ CHECK(ret);
- return index;
+ return index;
}
#endif //DUAL_PORT_RECORDING
int SecCamera::setPreviewSize(int width, int height, int pixel_format)
{
- LOGV("%s(width(%d), height(%d), format(%d))", __FUNCTION__, width, height, pixel_format);
+ LOGV("%s(width(%d), height(%d), format(%d))", __func__, width, height, pixel_format);
- int v4lpixelformat = pixel_format;
+ int v4lpixelformat = pixel_format;
#if defined(LOG_NDEBUG) && LOG_NDEBUG == 0
- if(v4lpixelformat == V4L2_PIX_FMT_YUV420) { LOGV("PreviewFormat:V4L2_PIX_FMT_YUV420"); }
- else if(v4lpixelformat == V4L2_PIX_FMT_NV12) { LOGV("PreviewFormat:V4L2_PIX_FMT_NV12"); }
- else if(v4lpixelformat == V4L2_PIX_FMT_NV12T) { LOGV("PreviewFormat:V4L2_PIX_FMT_NV12T"); }
- else if(v4lpixelformat == V4L2_PIX_FMT_NV21) { LOGV("PreviewFormat:V4L2_PIX_FMT_NV21"); }
- else if(v4lpixelformat == V4L2_PIX_FMT_YUV422P) { LOGV("PreviewFormat:V4L2_PIX_FMT_YUV422P"); }
- else if(v4lpixelformat == V4L2_PIX_FMT_YUYV) { LOGV("PreviewFormat:V4L2_PIX_FMT_YUYV"); }
- else if(v4lpixelformat == V4L2_PIX_FMT_RGB565) { LOGV("PreviewFormat:V4L2_PIX_FMT_RGB565"); }
- else { LOGV("PreviewFormat:UnknownFormat"); }
+ if (v4lpixelformat == V4L2_PIX_FMT_YUV420)
+ LOGV("PreviewFormat:V4L2_PIX_FMT_YUV420");
+ else if (v4lpixelformat == V4L2_PIX_FMT_NV12)
+ LOGV("PreviewFormat:V4L2_PIX_FMT_NV12");
+ else if (v4lpixelformat == V4L2_PIX_FMT_NV12T)
+ LOGV("PreviewFormat:V4L2_PIX_FMT_NV12T");
+ else if (v4lpixelformat == V4L2_PIX_FMT_NV21)
+ LOGV("PreviewFormat:V4L2_PIX_FMT_NV21");
+ else if (v4lpixelformat == V4L2_PIX_FMT_YUV422P)
+ LOGV("PreviewFormat:V4L2_PIX_FMT_YUV422P");
+ else if (v4lpixelformat == V4L2_PIX_FMT_YUYV)
+ LOGV("PreviewFormat:V4L2_PIX_FMT_YUYV");
+ else if (v4lpixelformat == V4L2_PIX_FMT_RGB565)
+ LOGV("PreviewFormat:V4L2_PIX_FMT_RGB565");
+ else
+ LOGV("PreviewFormat:UnknownFormat");
#endif
- m_preview_width = width;
- m_preview_height = height;
- m_preview_v4lformat = v4lpixelformat;
+ m_preview_width = width;
+ m_preview_height = height;
+ m_preview_v4lformat = v4lpixelformat;
- return 0;
+ return 0;
}
-int SecCamera::getPreviewSize(int * width, int * height, int * frame_size)
+int SecCamera::getPreviewSize(int *width, int *height, int *frame_size)
{
- *width = m_preview_width;
- *height = m_preview_height;
- *frame_size = m_frameSize(m_preview_v4lformat, m_preview_width, m_preview_height);
+ *width = m_preview_width;
+ *height = m_preview_height;
+ *frame_size = m_frameSize(m_preview_v4lformat, m_preview_width, m_preview_height);
- return 0;
+ return 0;
}
-int SecCamera::getPreviewMaxSize(int * width, int * height)
+int SecCamera::getPreviewMaxSize(int *width, int *height)
{
- *width = m_preview_max_width;
- *height = m_preview_max_height;
+ *width = m_preview_max_width;
+ *height = m_preview_max_height;
- return 0;
+ return 0;
}
int SecCamera::getPreviewPixelFormat(void)
{
- return m_preview_v4lformat;
+ return m_preview_v4lformat;
}
@@ -1632,373 +1578,384 @@ int SecCamera::getPreviewPixelFormat(void)
*/
int SecCamera::setSnapshotCmd(void)
{
- LOGV("%s()", __FUNCTION__);
-
- int ret = 0;
+ LOGV("%s()", __func__);
+
+ int ret = 0;
- LOG_TIME_DEFINE(0)
- LOG_TIME_DEFINE(1)
+ LOG_TIME_DEFINE(0)
+ LOG_TIME_DEFINE(1)
- if(m_cam_fd <= 0)
- {
- LOGE("ERR(%s):Camera was closed\n", __FUNCTION__);
- return 0;
- }
+ if (m_cam_fd <= 0) {
+ LOGE("ERR(%s):Camera was closed\n", __func__);
+ return 0;
+ }
- if(m_flag_camera_start > 0)
- {
- LOG_TIME_START(0)
- stopPreview();
- LOG_TIME_END(0)
- }
+ if (m_flag_camera_start > 0) {
+ LOG_TIME_START(0)
+ stopPreview();
+ LOG_TIME_END(0)
+ }
- memset(&m_events_c, 0, sizeof(m_events_c));
- m_events_c.fd = m_cam_fd;
- m_events_c.events = POLLIN | POLLERR;
+ memset(&m_events_c, 0, sizeof(m_events_c));
+ m_events_c.fd = m_cam_fd;
+ m_events_c.events = POLLIN | POLLERR;
- LOG_TIME_START(1) // prepare
- int nframe = 1;
+ LOG_TIME_START(1) // prepare
+ int nframe = 1;
- ret = fimc_v4l2_enum_fmt(m_cam_fd,m_snapshot_v4lformat);
- CHECK_PTR(ret);
- ret = fimc_v4l2_s_fmt_cap(m_cam_fd, m_snapshot_width, m_snapshot_height, V4L2_PIX_FMT_JPEG);
- CHECK_PTR(ret);
- init_yuv_buffers(m_buffers_c, m_snapshot_width, m_snapshot_height, m_snapshot_v4lformat);
+ ret = fimc_v4l2_enum_fmt(m_cam_fd,m_snapshot_v4lformat);
+ CHECK_PTR(ret);
+ ret = fimc_v4l2_s_fmt_cap(m_cam_fd, m_snapshot_width, m_snapshot_height, V4L2_PIX_FMT_JPEG);
+ CHECK_PTR(ret);
+ init_yuv_buffers(m_buffers_c, m_snapshot_width, m_snapshot_height, m_snapshot_v4lformat);
- ret = fimc_v4l2_reqbufs(m_cam_fd, V4L2_BUF_TYPE_VIDEO_CAPTURE, nframe);
- CHECK_PTR(ret);
- ret = fimc_v4l2_querybuf(m_cam_fd, m_buffers_c, V4L2_BUF_TYPE_VIDEO_CAPTURE, nframe);
- CHECK_PTR(ret);
+ ret = fimc_v4l2_reqbufs(m_cam_fd, V4L2_BUF_TYPE_VIDEO_CAPTURE, nframe);
+ CHECK_PTR(ret);
+ ret = fimc_v4l2_querybuf(m_cam_fd, m_buffers_c, V4L2_BUF_TYPE_VIDEO_CAPTURE, nframe);
+ CHECK_PTR(ret);
- ret = fimc_v4l2_g_parm(m_cam_fd);
- CHECK_PTR(ret);
- ret = fimc_v4l2_s_parm(m_cam_fd, 1, m_fps);
- CHECK_PTR(ret);
+ ret = fimc_v4l2_g_parm(m_cam_fd);
+ CHECK_PTR(ret);
+ ret = fimc_v4l2_s_parm(m_cam_fd, 1, m_fps);
+ CHECK_PTR(ret);
- ret = fimc_v4l2_qbuf(m_cam_fd, 0);
- CHECK_PTR(ret);
+ ret = fimc_v4l2_qbuf(m_cam_fd, 0);
+ CHECK_PTR(ret);
- ret = fimc_v4l2_streamon(m_cam_fd);
- CHECK_PTR(ret);
- LOG_TIME_END(1)
+ ret = fimc_v4l2_streamon(m_cam_fd);
+ CHECK_PTR(ret);
+ LOG_TIME_END(1)
- return 0;
+ return 0;
}
/*
* Set Jpeg quality & exif info and get JPEG data from camera ISP
*/
-unsigned char* SecCamera::getJpeg(int* jpeg_size, unsigned int* phyaddr)
+unsigned char* SecCamera::getJpeg(int *jpeg_size, unsigned int *phyaddr)
{
- LOGV("%s()", __FUNCTION__);
-
- int index, ret = 0;
- unsigned char* addr;
+ LOGV("%s()", __func__);
- LOG_TIME_DEFINE(2)
-/* kidggang (10.7.5) - Problem - After jpegquality is capture, operation setting is normal.
+ int index, ret = 0;
+ unsigned char *addr;
- ret = fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_CAM_JPEG_QUALITY, m_jpeg_quality);
- CHECK_PTR(ret);
-*/
+ LOG_TIME_DEFINE(2)
+ /* kidggang (10.7.5) - Problem - After jpegquality is capture, operation setting is normal.
+
+ ret = fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_CAM_JPEG_QUALITY, m_jpeg_quality);
+ CHECK_PTR(ret);
+ */
#ifdef SWP1_CAMERA_ADD_ADVANCED_FUNCTION
- //exif orient info
-// ret = fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_CAMERA_EXIF_ORIENTATION, m_exif_orientation); //kidggang
-// CHECK_PTR(ret);
+ //exif orient info
+// ret = fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_CAMERA_EXIF_ORIENTATION, m_exif_orientation); //kidggang
+// CHECK_PTR(ret);
#if 0//def SWP1_CAMERA_ADD_ADVANCED_FUNCTION
- //set gps information
- ret = fimc_v4l2_s_ext_ctrl(m_cam_fd, V4L2_CID_CAMERA_GPS_LATITUDE, &m_gps_latitude);
- CHECK_PTR(ret);
- ret = fimc_v4l2_s_ext_ctrl(m_cam_fd, V4L2_CID_CAMERA_GPS_LONGITUDE, &m_gps_longitude);
- CHECK_PTR(ret);
- ret = fimc_v4l2_s_ext_ctrl(m_cam_fd, V4L2_CID_CAMERA_GPS_ALTITUDE, &m_gps_altitude);
- CHECK_PTR(ret);
- ret = fimc_v4l2_s_ext_ctrl(m_cam_fd, V4L2_CID_CAMERA_GPS_TIMESTAMP, &m_gps_timestamp);
- CHECK_PTR(ret);
+ //set gps information
+ ret = fimc_v4l2_s_ext_ctrl(m_cam_fd, V4L2_CID_CAMERA_GPS_LATITUDE, &m_gps_latitude);
+ CHECK_PTR(ret);
+ ret = fimc_v4l2_s_ext_ctrl(m_cam_fd, V4L2_CID_CAMERA_GPS_LONGITUDE, &m_gps_longitude);
+ CHECK_PTR(ret);
+ ret = fimc_v4l2_s_ext_ctrl(m_cam_fd, V4L2_CID_CAMERA_GPS_ALTITUDE, &m_gps_altitude);
+ CHECK_PTR(ret);
+ ret = fimc_v4l2_s_ext_ctrl(m_cam_fd, V4L2_CID_CAMERA_GPS_TIMESTAMP, &m_gps_timestamp);
+ CHECK_PTR(ret);
#endif
/* kidggang
- ret = fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_CAMERA_CAPTURE, 0);
- CHECK_PTR(ret);*/
-
- // capture
- ret = fimc_poll(&m_events_c);
- CHECK_PTR(ret);
- index = fimc_v4l2_dqbuf(m_cam_fd);
- if(!(0 <= index && index < MAX_BUFFERS))
- {
- LOGE("ERR(%s):wrong index = %d\n", __FUNCTION__, index);
- return NULL;
- }
-#endif
-
- *jpeg_size = fimc_v4l2_g_ctrl(m_cam_fd, V4L2_CID_CAM_JPEG_MAIN_SIZE);
- CHECK_PTR(*jpeg_size);
- int main_offset = fimc_v4l2_g_ctrl(m_cam_fd, V4L2_CID_CAM_JPEG_MAIN_OFFSET);
- CHECK_PTR(main_offset);
- m_postview_offset = fimc_v4l2_g_ctrl(m_cam_fd, V4L2_CID_CAM_JPEG_POSTVIEW_OFFSET);
- CHECK_PTR(m_postview_offset);
-
- ret = fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_STREAM_PAUSE, 0);
- CHECK_PTR(ret);
- LOGV("\nsnapshot dqueued buffer = %d snapshot_width = %d snapshot_height = %d\n\n",index, m_snapshot_width, m_snapshot_height);
-
- addr = (unsigned char*)(m_buffers_c[index].start) + main_offset;
- *phyaddr = getPhyAddrY(index) + m_postview_offset;
-
- LOG_TIME_START(2) // post
- ret = fimc_v4l2_streamoff(m_cam_fd);
- CHECK_PTR(ret);
- LOG_TIME_END(2)
-
+ ret = fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_CAMERA_CAPTURE, 0);
+ CHECK_PTR(ret);*/
+
+ // capture
+ ret = fimc_poll(&m_events_c);
+ CHECK_PTR(ret);
+ index = fimc_v4l2_dqbuf(m_cam_fd);
+ if (!(0 <= index && index < MAX_BUFFERS)) {
+ LOGE("ERR(%s):wrong index = %d\n", __func__, index);
+ return NULL;
+ }
+#endif
+
+ *jpeg_size = fimc_v4l2_g_ctrl(m_cam_fd, V4L2_CID_CAM_JPEG_MAIN_SIZE);
+ CHECK_PTR(*jpeg_size);
+
+ int main_offset = fimc_v4l2_g_ctrl(m_cam_fd, V4L2_CID_CAM_JPEG_MAIN_OFFSET);
+ CHECK_PTR(main_offset);
+ m_postview_offset = fimc_v4l2_g_ctrl(m_cam_fd, V4L2_CID_CAM_JPEG_POSTVIEW_OFFSET);
+ CHECK_PTR(m_postview_offset);
+
+ ret = fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_STREAM_PAUSE, 0);
+ CHECK_PTR(ret);
+ LOGV("\nsnapshot dqueued buffer = %d snapshot_width = %d snapshot_height = %d\n\n",
+ index, m_snapshot_width, m_snapshot_height);
+
+ addr = (unsigned char*)(m_buffers_c[index].start) + main_offset;
+ *phyaddr = getPhyAddrY(index) + m_postview_offset;
+
+ LOG_TIME_START(2) // post
+ ret = fimc_v4l2_streamoff(m_cam_fd);
+ CHECK_PTR(ret);
+ LOG_TIME_END(2)
+
#if 0 //temporary blocked for build
- LOG_CAMERA("getSnapshotAndJpeg intervals : stopPreview(%lu), prepare(%lu), capture(%lu), memcpy(%lu), yuv2Jpeg(%lu), post(%lu) us"
- , LOG_TIME(0), LOG_TIME(1), LOG_TIME(2), LOG_TIME(3), LOG_TIME(4), LOG_TIME(5));
+ LOG_CAMERA("getSnapshotAndJpeg intervals : stopPreview(%lu), prepare(%lu), "
+ "capture(%lu), memcpy(%lu), yuv2Jpeg(%lu), post(%lu) us",
+ LOG_TIME(0), LOG_TIME(1), LOG_TIME(2), LOG_TIME(3), LOG_TIME(4), LOG_TIME(5));
#endif
- return addr;
+ return addr;
}
-int SecCamera::getExif(unsigned char *pExifDst, unsigned char *pThumbSrc)
+int SecCamera::getExif (unsigned char *pExifDst, unsigned char *pThumbSrc)
{
return 0;
}
-void SecCamera::getPostViewConfig(int* width, int* height, int* size)
+void SecCamera::getPostViewConfig(int *width, int *height, int *size)
{
- if(m_preview_width == 1024)
- {
- *width = BACK_CAMERA_POSTVIEW_WIDE_WIDTH;
- *height = BACK_CAMERA_POSTVIEW_HEIGHT;
- *size = BACK_CAMERA_POSTVIEW_WIDE_WIDTH * BACK_CAMERA_POSTVIEW_HEIGHT * BACK_CAMERA_POSTVIEW_BPP/8;
-
- }
- else
- {
- *width = BACK_CAMERA_POSTVIEW_WIDTH;
- *height = BACK_CAMERA_POSTVIEW_HEIGHT;
- *size = BACK_CAMERA_POSTVIEW_WIDTH * BACK_CAMERA_POSTVIEW_HEIGHT * BACK_CAMERA_POSTVIEW_BPP/8;
- }
- LOGV("[5B] m_preview_width : %d, mPostViewWidth = %d mPostViewHeight = %d mPostViewSize = %d", m_preview_width, *width, *height, *size);
+ if (m_preview_width == 1024) {
+ *width = BACK_CAMERA_POSTVIEW_WIDE_WIDTH;
+ *height = BACK_CAMERA_POSTVIEW_HEIGHT;
+ *size = BACK_CAMERA_POSTVIEW_WIDE_WIDTH * BACK_CAMERA_POSTVIEW_HEIGHT * BACK_CAMERA_POSTVIEW_BPP / 8;
+ } else {
+ *width = BACK_CAMERA_POSTVIEW_WIDTH;
+ *height = BACK_CAMERA_POSTVIEW_HEIGHT;
+ *size = BACK_CAMERA_POSTVIEW_WIDTH * BACK_CAMERA_POSTVIEW_HEIGHT * BACK_CAMERA_POSTVIEW_BPP / 8;
+ }
+ LOGV("[5B] m_preview_width : %d, mPostViewWidth = %d mPostViewHeight = %d mPostViewSize = %d",
+ m_preview_width, *width, *height, *size);
}
#ifdef DIRECT_DELIVERY_OF_POSTVIEW_DATA
int SecCamera::getPostViewOffset(void)
{
- return m_postview_offset;
+ return m_postview_offset;
}
#endif
#else //#ifdef JPEG_FROM_SENSOR
int SecCamera::getJpegFd(void)
{
- return m_jpeg_fd;
+ return m_jpeg_fd;
}
void SecCamera::SetJpgAddr(unsigned char *addr)
{
- SetMapAddr(addr);
+ SetMapAddr(addr);
}
#if 0
-int SecCamera::getSnapshot(unsigned char * buffer, unsigned int buffer_size)
+int SecCamera::getSnapshot(unsigned char *buffer, unsigned int buffer_size)
{
- LOGV("%s(buffer(%p), size(%d))", __FUNCTION__, buffer, buffer_size);
-
- if(getSnapshotAndJpeg(buffer, buffer_size, NULL, NULL) == 0)
- return -1;
-
- return 0;
+ LOGV("%s(buffer(%p), size(%d))", __func__, buffer, buffer_size);
+
+ if (getSnapshotAndJpeg(buffer, buffer_size, NULL, NULL) == 0)
+ return -1;
+
+ return 0;
}
#endif
#endif
-unsigned char* SecCamera::getSnapshotAndJpeg(unsigned int* output_size)
-{
- LOGV("%s()", __FUNCTION__);
-
- int index;
- //unsigned int addr;
- unsigned char* addr;
- int ret = 0;
-
- LOG_TIME_DEFINE(0)
- LOG_TIME_DEFINE(1)
- LOG_TIME_DEFINE(2)
- LOG_TIME_DEFINE(3)
- LOG_TIME_DEFINE(4)
- LOG_TIME_DEFINE(5)
-
- //fimc_v4l2_streamoff(m_cam_fd); [zzangdol] remove - it is separate in HWInterface with camera_id
-
- if(m_cam_fd <= 0)
- {
- LOGE("ERR(%s):Camera was closed\n", __FUNCTION__);
- return 0;
- }
-
- if(m_flag_camera_start > 0)
- {
- LOG_TIME_START(0)
- stopPreview();
- LOG_TIME_END(0)
- }
-
- memset(&m_events_c, 0, sizeof(m_events_c));
- m_events_c.fd = m_cam_fd;
- m_events_c.events = POLLIN | POLLERR;
+unsigned char* SecCamera::getSnapshotAndJpeg(unsigned int* output_size)
+{
+ LOGV("%s()", __func__);
+
+ int index;
+ //unsigned int addr;
+ unsigned char* addr;
+ int ret = 0;
+
+ LOG_TIME_DEFINE(0)
+ LOG_TIME_DEFINE(1)
+ LOG_TIME_DEFINE(2)
+ LOG_TIME_DEFINE(3)
+ LOG_TIME_DEFINE(4)
+ LOG_TIME_DEFINE(5)
+
+ //fimc_v4l2_streamoff(m_cam_fd); [zzangdol] remove - it is separate in HWInterface with camera_id
+
+ if (m_cam_fd <= 0) {
+ LOGE("ERR(%s):Camera was closed\n", __func__);
+ return 0;
+ }
+
+ if (m_flag_camera_start > 0) {
+ LOG_TIME_START(0)
+ stopPreview();
+ LOG_TIME_END(0)
+ }
+
+ memset(&m_events_c, 0, sizeof(m_events_c));
+ m_events_c.fd = m_cam_fd;
+ m_events_c.events = POLLIN | POLLERR;
#if defined(LOG_NDEBUG) && LOG_NDEBUG == 0
- if(m_snapshot_v4lformat == V4L2_PIX_FMT_YUV420) { LOGV("SnapshotFormat:V4L2_PIX_FMT_YUV420"); }
- else if(m_snapshot_v4lformat == V4L2_PIX_FMT_NV12) { LOGV("SnapshotFormat:V4L2_PIX_FMT_NV12"); }
- else if(m_snapshot_v4lformat == V4L2_PIX_FMT_NV12T) { LOGV("SnapshotFormat:V4L2_PIX_FMT_NV12T"); }
- else if(m_snapshot_v4lformat == V4L2_PIX_FMT_NV21) { LOGV("SnapshotFormat:V4L2_PIX_FMT_NV21"); }
- else if(m_snapshot_v4lformat == V4L2_PIX_FMT_YUV422P) { LOGV("SnapshotFormat:V4L2_PIX_FMT_YUV422P"); }
- else if(m_snapshot_v4lformat == V4L2_PIX_FMT_YUYV) { LOGV("SnapshotFormat:V4L2_PIX_FMT_YUYV"); }
- else if(m_snapshot_v4lformat == V4L2_PIX_FMT_UYVY) { LOGV("SnapshotFormat:V4L2_PIX_FMT_UYVY"); }
- else if(m_snapshot_v4lformat == V4L2_PIX_FMT_RGB565) { LOGV("SnapshotFormat:V4L2_PIX_FMT_RGB565"); }
- else { LOGV("SnapshotFormat:UnknownFormat"); }
+ if (m_snapshot_v4lformat == V4L2_PIX_FMT_YUV420)
+ LOGV("SnapshotFormat:V4L2_PIX_FMT_YUV420");
+ else if (m_snapshot_v4lformat == V4L2_PIX_FMT_NV12)
+ LOGV("SnapshotFormat:V4L2_PIX_FMT_NV12");
+ else if (m_snapshot_v4lformat == V4L2_PIX_FMT_NV12T)
+ LOGV("SnapshotFormat:V4L2_PIX_FMT_NV12T");
+ else if (m_snapshot_v4lformat == V4L2_PIX_FMT_NV21)
+ LOGV("SnapshotFormat:V4L2_PIX_FMT_NV21");
+ else if (m_snapshot_v4lformat == V4L2_PIX_FMT_YUV422P)
+ LOGV("SnapshotFormat:V4L2_PIX_FMT_YUV422P");
+ else if (m_snapshot_v4lformat == V4L2_PIX_FMT_YUYV)
+ LOGV("SnapshotFormat:V4L2_PIX_FMT_YUYV");
+ else if (m_snapshot_v4lformat == V4L2_PIX_FMT_UYVY)
+ LOGV("SnapshotFormat:V4L2_PIX_FMT_UYVY");
+ else if (m_snapshot_v4lformat == V4L2_PIX_FMT_RGB565)
+ LOGV("SnapshotFormat:V4L2_PIX_FMT_RGB565");
+ else
+ LOGV("SnapshotFormat:UnknownFormat");
#endif
- LOG_TIME_START(1) // prepare
- int nframe = 1;
+ LOG_TIME_START(1) // prepare
+ int nframe = 1;
- LOGE("[zzangdol] w %d, h %d\n", m_snapshot_width, m_snapshot_height);
+ LOGE("[zzangdol] w %d, h %d\n", m_snapshot_width, m_snapshot_height);
- ret = fimc_v4l2_enum_fmt(m_cam_fd,m_snapshot_v4lformat);
- CHECK_PTR(ret);
- ret = fimc_v4l2_s_fmt_cap(m_cam_fd, m_snapshot_width, m_snapshot_height, m_snapshot_v4lformat);
- CHECK_PTR(ret);
- init_yuv_buffers(m_buffers_c, m_snapshot_width, m_snapshot_height, m_snapshot_v4lformat);
+ ret = fimc_v4l2_enum_fmt(m_cam_fd,m_snapshot_v4lformat);
+ CHECK_PTR(ret);
+ ret = fimc_v4l2_s_fmt_cap(m_cam_fd, m_snapshot_width, m_snapshot_height, m_snapshot_v4lformat);
+ CHECK_PTR(ret);
+ init_yuv_buffers(m_buffers_c, m_snapshot_width, m_snapshot_height, m_snapshot_v4lformat);
- ret = fimc_v4l2_reqbufs(m_cam_fd, V4L2_BUF_TYPE_VIDEO_CAPTURE, nframe);
- CHECK_PTR(ret);
- ret = fimc_v4l2_querybuf(m_cam_fd, m_buffers_c, V4L2_BUF_TYPE_VIDEO_CAPTURE, nframe);
- CHECK_PTR(ret);
+ ret = fimc_v4l2_reqbufs(m_cam_fd, V4L2_BUF_TYPE_VIDEO_CAPTURE, nframe);
+ CHECK_PTR(ret);
+ ret = fimc_v4l2_querybuf(m_cam_fd, m_buffers_c, V4L2_BUF_TYPE_VIDEO_CAPTURE, nframe);
+ CHECK_PTR(ret);
- /* g_parm, s_parm sample */
- ret = fimc_v4l2_g_parm(m_cam_fd);
- CHECK_PTR(ret);
- ret = fimc_v4l2_s_parm(m_cam_fd, 1, m_fps);
- CHECK_PTR(ret);
+ /* g_parm, s_parm sample */
+ ret = fimc_v4l2_g_parm(m_cam_fd);
+ CHECK_PTR(ret);
+ ret = fimc_v4l2_s_parm(m_cam_fd, 1, m_fps);
+ CHECK_PTR(ret);
- ret = fimc_v4l2_qbuf(m_cam_fd, 0);
- CHECK_PTR(ret);
+ ret = fimc_v4l2_qbuf(m_cam_fd, 0);
+ CHECK_PTR(ret);
- ret = fimc_v4l2_streamon(m_cam_fd);//zzangdolp
- CHECK_PTR(ret);
- LOG_TIME_END(1)
+ ret = fimc_v4l2_streamon(m_cam_fd);
+ CHECK_PTR(ret);
+ LOG_TIME_END(1)
- LOG_TIME_START(2) // capture
- fimc_poll(&m_events_c);
- index = fimc_v4l2_dqbuf(m_cam_fd);
- fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_STREAM_PAUSE, 0);
- LOGV("\nsnapshot dqueued buffer = %d snapshot_width = %d snapshot_height = %d\n\n",index, m_snapshot_width, m_snapshot_height);
+ LOG_TIME_START(2) // capture
+ fimc_poll(&m_events_c);
+ index = fimc_v4l2_dqbuf(m_cam_fd);
+ fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_STREAM_PAUSE, 0);
+ LOGV("\nsnapshot dqueued buffer = %d snapshot_width = %d snapshot_height = %d\n\n",
+ index, m_snapshot_width, m_snapshot_height);
#ifdef DUMP_YUV
- save_yuv(m_buffers_c, m_snapshot_width, m_snapshot_height, 16, index, 0);
+ save_yuv(m_buffers_c, m_snapshot_width, m_snapshot_height, 16, index, 0);
#endif
- LOG_TIME_END(2)
-
- //addr = getPhyAddrY(index);
- addr = (unsigned char*)m_buffers_c[index].start;
- if(addr == 0)
- {
- LOGE("%s] Physical address 0");
- }
- LOG_TIME_START(5) // post
- fimc_v4l2_streamoff(m_cam_fd);
+ LOG_TIME_END(2)
+
+ //addr = getPhyAddrY(index);
+ addr = (unsigned char*)m_buffers_c[index].start;
+ if (addr == 0) {
+ LOGE("%s] Physical address 0");
+ }
+ LOG_TIME_START(5) // post
+ fimc_v4l2_streamoff(m_cam_fd);
#ifdef DUMP_YUV
- close_buffers(m_buffers_c);
+ close_buffers(m_buffers_c);
#endif
- LOG_TIME_END(5)
+ LOG_TIME_END(5)
- LOG_CAMERA("getSnapshotAndJpeg intervals : stopPreview(%lu), prepare(%lu), capture(%lu), memcpy(%lu), yuv2Jpeg(%lu), post(%lu) us"
- , LOG_TIME(0), LOG_TIME(1), LOG_TIME(2), LOG_TIME(3), LOG_TIME(4), LOG_TIME(5));
+ LOG_CAMERA("getSnapshotAndJpeg intervals : stopPreview(%lu), prepare(%lu),
+ " capture(%lu), memcpy(%lu), yuv2Jpeg(%lu), post(%lu) us",
+ LOG_TIME(0), LOG_TIME(1), LOG_TIME(2), LOG_TIME(3), LOG_TIME(4), LOG_TIME(5));
- return addr;
+ return addr;
}
int SecCamera::setSnapshotSize(int width, int height)
{
- LOGV("%s(width(%d), height(%d))", __FUNCTION__, width, height);
-
- m_snapshot_width = width;
- m_snapshot_height = height;
+ LOGV("%s(width(%d), height(%d))", __func__, width, height);
+
+ m_snapshot_width = width;
+ m_snapshot_height = height;
- return 0;
+ return 0;
}
-int SecCamera::getSnapshotSize(int * width, int * height, int * frame_size)
+int SecCamera::getSnapshotSize(int *width, int *height, int *frame_size)
{
- *width = m_snapshot_width;
- *height = m_snapshot_height;
+ *width = m_snapshot_width;
+ *height = m_snapshot_height;
+
+ int frame = 0;
- int frame = 0;
+ frame = m_frameSize(m_snapshot_v4lformat, m_snapshot_width, m_snapshot_height);
- frame = m_frameSize(m_snapshot_v4lformat, m_snapshot_width, m_snapshot_height);
-
- // set it big.
- if(frame == 0)
- frame = m_snapshot_width * m_snapshot_height * BPP;
-
- *frame_size = frame;
+ // set it big.
+ if (frame == 0)
+ frame = m_snapshot_width * m_snapshot_height * BPP;
- return 0;
+ *frame_size = frame;
+
+ return 0;
}
-int SecCamera::getSnapshotMaxSize(int * width, int * height)
+int SecCamera::getSnapshotMaxSize(int *width, int *height)
{
- switch(m_camera_id)
- {
- case CAMERA_ID_FRONT:
- m_snapshot_max_width = MAX_FRONT_CAMERA_SNAPSHOT_WIDTH;
- m_snapshot_max_height = MAX_FRONT_CAMERA_SNAPSHOT_HEIGHT;
- break;
+ switch (m_camera_id) {
+ case CAMERA_ID_FRONT:
+ m_snapshot_max_width = MAX_FRONT_CAMERA_SNAPSHOT_WIDTH;
+ m_snapshot_max_height = MAX_FRONT_CAMERA_SNAPSHOT_HEIGHT;
+ break;
- default:
- case CAMERA_ID_BACK:
- m_snapshot_max_width = MAX_BACK_CAMERA_SNAPSHOT_WIDTH;
- m_snapshot_max_height = MAX_BACK_CAMERA_SNAPSHOT_HEIGHT;
- break;
- }
+ default:
+ case CAMERA_ID_BACK:
+ m_snapshot_max_width = MAX_BACK_CAMERA_SNAPSHOT_WIDTH;
+ m_snapshot_max_height = MAX_BACK_CAMERA_SNAPSHOT_HEIGHT;
+ break;
+ }
- *width = m_snapshot_max_width;
- *height = m_snapshot_max_height;
+ *width = m_snapshot_max_width;
+ *height = m_snapshot_max_height;
- return 0;
+ return 0;
}
int SecCamera::setSnapshotPixelFormat(int pixel_format)
{
- int v4lpixelformat= pixel_format;
+ int v4lpixelformat= pixel_format;
+
+ if (m_snapshot_v4lformat != v4lpixelformat) {
+ m_snapshot_v4lformat = v4lpixelformat;
+ }
+
- if(m_snapshot_v4lformat != v4lpixelformat)
- {
- m_snapshot_v4lformat = v4lpixelformat;
- }
-
-
#if defined(LOG_NDEBUG) && LOG_NDEBUG == 0
- if(m_snapshot_v4lformat == V4L2_PIX_FMT_YUV420) { LOGE("%s():SnapshotFormat:V4L2_PIX_FMT_YUV420", __FUNCTION__); }
- else if(m_snapshot_v4lformat == V4L2_PIX_FMT_NV12) { LOGE("%s():SnapshotFormat:V4L2_PIX_FMT_NV12", __FUNCTION__); }
- else if(m_snapshot_v4lformat == V4L2_PIX_FMT_NV12T) { LOGE("%s():SnapshotFormat:V4L2_PIX_FMT_NV12T", __FUNCTION__); }
- else if(m_snapshot_v4lformat == V4L2_PIX_FMT_NV21) { LOGE("%s():SnapshotFormat:V4L2_PIX_FMT_NV21", __FUNCTION__); }
- else if(m_snapshot_v4lformat == V4L2_PIX_FMT_YUV422P) { LOGE("%s():SnapshotFormat:V4L2_PIX_FMT_YUV422P", __FUNCTION__); }
- else if(m_snapshot_v4lformat == V4L2_PIX_FMT_YUYV) { LOGE("%s():SnapshotFormat:V4L2_PIX_FMT_YUYV", __FUNCTION__); }
- else if(m_snapshot_v4lformat == V4L2_PIX_FMT_UYVY) { LOGE("%s():SnapshotFormat:V4L2_PIX_FMT_UYVY", __FUNCTION__); }
- else if(m_snapshot_v4lformat == V4L2_PIX_FMT_RGB565) { LOGE("%s():SnapshotFormat:V4L2_PIX_FMT_RGB565", __FUNCTION__); }
- else { LOGE("SnapshotFormat:UnknownFormat"); }
+ if (m_snapshot_v4lformat == V4L2_PIX_FMT_YUV420)
+ LOGE("%s():SnapshotFormat:V4L2_PIX_FMT_YUV420", __func__);
+ else if (m_snapshot_v4lformat == V4L2_PIX_FMT_NV12)
+ LOGE("%s():SnapshotFormat:V4L2_PIX_FMT_NV12", __func__);
+ else if (m_snapshot_v4lformat == V4L2_PIX_FMT_NV12T)
+ LOGE("%s():SnapshotFormat:V4L2_PIX_FMT_NV12T", __func__);
+ else if (m_snapshot_v4lformat == V4L2_PIX_FMT_NV21)
+ LOGE("%s():SnapshotFormat:V4L2_PIX_FMT_NV21", __func__);
+ else if (m_snapshot_v4lformat == V4L2_PIX_FMT_YUV422P)
+ LOGE("%s():SnapshotFormat:V4L2_PIX_FMT_YUV422P", __func__);
+ else if (m_snapshot_v4lformat == V4L2_PIX_FMT_YUYV)
+ LOGE("%s():SnapshotFormat:V4L2_PIX_FMT_YUYV", __func__);
+ else if (m_snapshot_v4lformat == V4L2_PIX_FMT_UYVY)
+ LOGE("%s():SnapshotFormat:V4L2_PIX_FMT_UYVY", __func__);
+ else if (m_snapshot_v4lformat == V4L2_PIX_FMT_RGB565)
+ LOGE("%s():SnapshotFormat:V4L2_PIX_FMT_RGB565", __func__);
+ else
+ LOGE("SnapshotFormat:UnknownFormat");
#endif
-
- return 0;
+ return 0;
}
int SecCamera::getSnapshotPixelFormat(void)
{
- return m_snapshot_v4lformat;
+ return m_snapshot_v4lformat;
}
@@ -2007,652 +1964,585 @@ int SecCamera::getSnapshotPixelFormat(void)
int SecCamera::setCameraId(int camera_id)
{
- if( camera_id != CAMERA_ID_FRONT
- && camera_id != CAMERA_ID_BACK)
- {
- LOGE("ERR(%s)::Invalid camera id(%d)\n", __func__, camera_id);
- return -1;
- }
- if(m_camera_id == camera_id)
- return 0;
+ if ((camera_id != CAMERA_ID_FRONT) && (camera_id != CAMERA_ID_BACK)) {
+ LOGE("ERR(%s)::Invalid camera id(%d)\n", __func__, camera_id);
+ return -1;
+ }
+ if (m_camera_id == camera_id)
+ return 0;
- LOGV("%s(camera_id(%d))", __FUNCTION__, camera_id);
-
- switch(camera_id)
- {
- case CAMERA_ID_FRONT:
+ LOGV("%s(camera_id(%d))", __func__, camera_id);
- m_preview_max_width = MAX_FRONT_CAMERA_PREVIEW_WIDTH;
- m_preview_max_height = MAX_FRONT_CAMERA_PREVIEW_HEIGHT;
- m_snapshot_max_width = MAX_FRONT_CAMERA_SNAPSHOT_WIDTH;
- m_snapshot_max_height = MAX_FRONT_CAMERA_SNAPSHOT_HEIGHT;
- break;
+ switch (camera_id) {
+ case CAMERA_ID_FRONT:
+ m_preview_max_width = MAX_FRONT_CAMERA_PREVIEW_WIDTH;
+ m_preview_max_height = MAX_FRONT_CAMERA_PREVIEW_HEIGHT;
+ m_snapshot_max_width = MAX_FRONT_CAMERA_SNAPSHOT_WIDTH;
+ m_snapshot_max_height = MAX_FRONT_CAMERA_SNAPSHOT_HEIGHT;
+ break;
- case CAMERA_ID_BACK:
- m_preview_max_width = MAX_BACK_CAMERA_PREVIEW_WIDTH;
- m_preview_max_height = MAX_BACK_CAMERA_PREVIEW_HEIGHT;
- m_snapshot_max_width = MAX_BACK_CAMERA_SNAPSHOT_WIDTH;
- m_snapshot_max_height = MAX_BACK_CAMERA_SNAPSHOT_HEIGHT;
- break;
- }
+ case CAMERA_ID_BACK:
+ m_preview_max_width = MAX_BACK_CAMERA_PREVIEW_WIDTH;
+ m_preview_max_height = MAX_BACK_CAMERA_PREVIEW_HEIGHT;
+ m_snapshot_max_width = MAX_BACK_CAMERA_SNAPSHOT_WIDTH;
+ m_snapshot_max_height = MAX_BACK_CAMERA_SNAPSHOT_HEIGHT;
+ break;
+ }
- m_camera_id = camera_id;
-
- resetCamera();
+ m_camera_id = camera_id;
- return 0;
+ resetCamera();
+
+ return 0;
}
int SecCamera::getCameraId(void)
{
- return m_camera_id;
+ return m_camera_id;
}
// -----------------------------------
int SecCamera::setAutofocus(void)
{
- LOGV("%s()", __FUNCTION__);
+ LOGV("%s()", __func__);
#ifdef SWP1_CAMERA_ADD_ADVANCED_FUNCTION
- if(m_cam_fd <= 0)
- {
- LOGE("ERR(%s):Camera was closed\n", __FUNCTION__);
- return -1;
- }
-
- if (fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_CAMERA_SET_AUTO_FOCUS, AUTO_FOCUS_ON) < 0)
- {
- LOGE("ERR(%s):Fail on V4L2_CID_CAMERA_SET_AUTO_FOCUS", __FUNCTION__);
- return -1;
- }
+ if (m_cam_fd <= 0) {
+ LOGE("ERR(%s):Camera was closed\n", __func__);
+ return -1;
+ }
+
+ if (fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_CAMERA_SET_AUTO_FOCUS, AUTO_FOCUS_ON) < 0) {
+ LOGE("ERR(%s):Fail on V4L2_CID_CAMERA_SET_AUTO_FOCUS", __func__);
+ return -1;
+ }
#else
- // kcoolsw : turn on setAutofocus initially..
- if(m_autofocus != AUTO_FOCUS_ON)
- {
- m_autofocus = AUTO_FOCUS_ON;
- }
+ // kcoolsw : turn on setAutofocus initially..
+ if (m_autofocus != AUTO_FOCUS_ON) {
+ m_autofocus = AUTO_FOCUS_ON;
+ }
#endif
- return 0;
-}
+ return 0;
+}
#ifdef SWP1_CAMERA_ADD_ADVANCED_FUNCTION
int SecCamera::getAutoFocusResult(void)
{
- int af_result = 0;
- af_result = fimc_v4l2_g_ctrl(m_cam_fd, V4L2_CID_CAMERA_AUTO_FOCUS_RESULT);
- return af_result;
+ int af_result = 0;
+
+ af_result = fimc_v4l2_g_ctrl(m_cam_fd, V4L2_CID_CAMERA_AUTO_FOCUS_RESULT);
+ return af_result;
}
int SecCamera::cancelAutofocus(void)
{
- LOGV("%s()", __FUNCTION__);
-
- if(m_cam_fd <= 0)
- {
- LOGE("ERR(%s):Camera was closed\n", __FUNCTION__);
- return -1;
- }
-
- if (fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_CAMERA_SET_AUTO_FOCUS, AUTO_FOCUS_OFF) < 0)
- {
- LOGE("ERR(%s):Fail on V4L2_CID_CAMERA_SET_AUTO_FOCUS", __FUNCTION__);
- return -1;
- }
-
- usleep(1000);
-
- if (fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_CAMERA_SET_AUTO_FOCUS, AUTO_FOCUS_STATUS) < 0)
- {
- LOGE("ERR(%s):Fail on V4L2_CID_CAMERA_SET_AUTO_FOCUS", __FUNCTION__);
- return -1;
- }
- return 0;
-}
+ LOGV("%s()", __func__);
+
+ if (m_cam_fd <= 0) {
+ LOGE("ERR(%s):Camera was closed\n", __func__);
+ return -1;
+ }
+
+ if (fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_CAMERA_SET_AUTO_FOCUS, AUTO_FOCUS_OFF) < 0) {
+ LOGE("ERR(%s):Fail on V4L2_CID_CAMERA_SET_AUTO_FOCUS", __func__);
+ return -1;
+ }
+
+ usleep(1000);
+
+ if (fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_CAMERA_SET_AUTO_FOCUS, AUTO_FOCUS_STATUS) < 0) {
+ LOGE("ERR(%s):Fail on V4L2_CID_CAMERA_SET_AUTO_FOCUS", __func__);
+ return -1;
+ }
+ return 0;
+}
#endif
// -----------------------------------
int SecCamera::zoomIn(void)
{
- LOGV("%s()", __FUNCTION__);
- return 0;
+ LOGV("%s()", __func__);
+ return 0;
}
int SecCamera::zoomOut(void)
{
- LOGV("%s()", __FUNCTION__);
- return 0;
+ LOGV("%s()", __func__);
+ return 0;
}
// -----------------------------------
int SecCamera::SetRotate(int angle)
{
- LOGE("%s(angle(%d))", __FUNCTION__, angle);
+ LOGE("%s(angle(%d))", __func__, angle);
#ifdef SWP1_CAMERA_ADD_ADVANCED_FUNCTION
- if(m_angle != angle)
- {
- switch(angle)
- {
- case -360 :
- case 0 :
- case 360 :
- m_angle = 0;
- break;
-
- case -270 :
- case 90 :
- m_angle = 90;
- break;
-
- case -180 :
- case 180 :
- m_angle = 180;
- break;
-
- case -90 :
- case 270 :
- m_angle = 270;
- break;
-
- default :
- LOGE("ERR(%s):Invalid angle(%d)", __FUNCTION__, angle);
- return -1;
- }
-
-
- if(m_flag_camera_start)
- {
- if (fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_ROTATION, angle) < 0)
- {
- LOGE("ERR(%s):Fail on V4L2_CID_ROTATION", __FUNCTION__);
- return -1;
- }
- }
- }
-#endif
- return 0;
+ if (m_angle != angle) {
+ switch (angle) {
+ case -360:
+ case 0:
+ case 360:
+ m_angle = 0;
+ break;
+
+ case -270:
+ case 90:
+ m_angle = 90;
+ break;
+
+ case -180:
+ case 180:
+ m_angle = 180;
+ break;
+
+ case -90:
+ case 270:
+ m_angle = 270;
+ break;
+
+ default:
+ LOGE("ERR(%s):Invalid angle(%d)", __func__, angle);
+ return -1;
+ }
+
+ if (m_flag_camera_start) {
+ if (fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_ROTATION, angle) < 0) {
+ LOGE("ERR(%s):Fail on V4L2_CID_ROTATION", __func__);
+ return -1;
+ }
+ }
+ }
+#endif
+ return 0;
}
int SecCamera::getRotate(void)
{
- LOGV("%s():angle(%d)", __FUNCTION__, m_angle);
- return m_angle;
+ LOGV("%s():angle(%d)", __func__, m_angle);
+ return m_angle;
}
void SecCamera::setFrameRate(int frame_rate)
{
#ifdef SWP1_CAMERA_ADD_ADVANCED_FUNCTION
- LOGV("%s(FrameRate(%d))", __FUNCTION__, frame_rate);
-
- if(frame_rate < FRAME_RATE_AUTO || FRAME_RATE_MAX < frame_rate )
- LOGE("ERR(%s):Invalid frame_rate(%d)", __FUNCTION__, frame_rate);
-
- if(m_fps != frame_rate)
- {
- m_fps = frame_rate;
- if(m_flag_camera_start)
- {
- if (fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_CAMERA_FRAME_RATE, frame_rate) < 0)
- LOGE("ERR(%s):Fail on V4L2_CID_CAMERA_FRAME_RATE", __FUNCTION__);
- }
- }
+ LOGV("%s(FrameRate(%d))", __func__, frame_rate);
+
+ if (frame_rate < FRAME_RATE_AUTO || FRAME_RATE_MAX < frame_rate )
+ LOGE("ERR(%s):Invalid frame_rate(%d)", __func__, frame_rate);
+
+ if (m_fps != frame_rate) {
+ m_fps = frame_rate;
+ if (m_flag_camera_start) {
+ if (fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_CAMERA_FRAME_RATE, frame_rate) < 0)
+ LOGE("ERR(%s):Fail on V4L2_CID_CAMERA_FRAME_RATE", __func__);
+ }
+ }
#else
- m_fps = frame_rate;
+ m_fps = frame_rate;
#endif
-
+
}
/* kidggang (10.7.5) - Problem - After jpegquality is capture, operation setting is normal.
void SecCamera::setJpegQuality(int quality)
{
- m_jpeg_quality = quality;
+ m_jpeg_quality = quality;
}
*/
// -----------------------------------
int SecCamera::setVerticalMirror(void)
{
- LOGV("%s()", __FUNCTION__);
-
- if(m_cam_fd <= 0)
- {
- LOGE("ERR(%s):Camera was closed\n", __FUNCTION__);
- return -1;
- }
+ LOGV("%s()", __func__);
+
+ if (m_cam_fd <= 0) {
+ LOGE("ERR(%s):Camera was closed\n", __func__);
+ return -1;
+ }
- if (fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_VFLIP, 0) < 0)
- {
- LOGE("ERR(%s):Fail on V4L2_CID_VFLIP", __FUNCTION__);
- return -1;
- }
+ if (fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_VFLIP, 0) < 0) {
+ LOGE("ERR(%s):Fail on V4L2_CID_VFLIP", __func__);
+ return -1;
+ }
- return 0;
+ return 0;
}
int SecCamera::setHorizontalMirror(void)
{
- LOGV("%s()", __FUNCTION__);
-
- if(m_cam_fd <= 0)
- {
- LOGE("ERR(%s):Camera was closed\n", __FUNCTION__);
- return -1;
- }
+ LOGV("%s()", __func__);
+
+ if (m_cam_fd <= 0) {
+ LOGE("ERR(%s):Camera was closed\n", __func__);
+ return -1;
+ }
- if (fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_HFLIP, 0) < 0)
- {
- LOGE("ERR(%s):Fail on V4L2_CID_HFLIP", __FUNCTION__);
- return -1;
- }
+ if (fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_HFLIP, 0) < 0) {
+ LOGE("ERR(%s):Fail on V4L2_CID_HFLIP", __func__);
+ return -1;
+ }
- return 0;
+ return 0;
}
// -----------------------------------
int SecCamera::setWhiteBalance(int white_balance)
{
- LOGV("%s(white_balance(%d))", __FUNCTION__, white_balance);
+ LOGV("%s(white_balance(%d))", __func__, white_balance);
-#ifdef SWP1_CAMERA_ADD_ADVANCED_FUNCTION
- if(white_balance <= WHITE_BALANCE_BASE || WHITE_BALANCE_MAX <= white_balance)
+#ifdef SWP1_CAMERA_ADD_ADVANCED_FUNCTION
+ if (white_balance <= WHITE_BALANCE_BASE || WHITE_BALANCE_MAX <= white_balance) {
#else
- if(white_balance < WHITE_BALANCE_AUTO || WHITE_BALANCE_SUNNY < white_balance)
+ if (white_balance < WHITE_BALANCE_AUTO || WHITE_BALANCE_SUNNY < white_balance) {
#endif
- {
- LOGE("ERR(%s):Invalid white_balance(%d)", __FUNCTION__, white_balance);
- return -1;
- }
-
- if(m_white_balance != white_balance)
- {
- m_white_balance = white_balance;
+ LOGE("ERR(%s):Invalid white_balance(%d)", __func__, white_balance);
+ return -1;
+ }
+
+ if (m_white_balance != white_balance) {
+ m_white_balance = white_balance;
#ifdef SWP1_CAMERA_ADD_ADVANCED_FUNCTION
- if(m_flag_camera_start)
- {
- if (fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_CAMERA_WHITE_BALANCE, white_balance) < 0)
- {
- LOGE("ERR(%s):Fail on V4L2_CID_CAMERA_WHITE_BALANCE", __FUNCTION__);
- return -1;
- }
- }
+ if (m_flag_camera_start) {
+ if (fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_CAMERA_WHITE_BALANCE, white_balance) < 0) {
+ LOGE("ERR(%s):Fail on V4L2_CID_CAMERA_WHITE_BALANCE", __func__);
+ return -1;
+ }
+ }
#endif
- }
+ }
- return 0;
+ return 0;
}
int SecCamera::getWhiteBalance(void)
{
- LOGV("%s():white_balance(%d)", __FUNCTION__, m_white_balance);
- return m_white_balance;
+ LOGV("%s():white_balance(%d)", __func__, m_white_balance);
+ return m_white_balance;
}
// -----------------------------------
int SecCamera::setBrightness(int brightness)
-{
- LOGV("%s(brightness(%d))", __FUNCTION__, brightness);
-
- if(brightness < BRIGHTNESS_MINUS_4|| BRIGHTNESS_PLUS_4< brightness )
- {
- LOGE("ERR(%s):Invalid brightness(%d)", __FUNCTION__, brightness);
- return -1;
- }
-
- if(m_brightness != brightness)
- {
- m_brightness = brightness;
+{
+ LOGV("%s(brightness(%d))", __func__, brightness);
+
+ if (brightness < BRIGHTNESS_MINUS_4 || BRIGHTNESS_PLUS_4 < brightness) {
+ LOGE("ERR(%s):Invalid brightness(%d)", __func__, brightness);
+ return -1;
+ }
+
+ if (m_brightness != brightness) {
+ m_brightness = brightness;
#ifdef SWP1_CAMERA_ADD_ADVANCED_FUNCTION
- if(m_flag_camera_start)
- {
- if (fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_CAMERA_BRIGHTNESS, brightness + BRIGHTNESS_NORMAL) < 0)
- {
- LOGE("ERR(%s):Fail on V4L2_CID_CAMERA_BRIGHTNESS", __FUNCTION__);
- return -1;
- }
- }
+ if (m_flag_camera_start) {
+ if (fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_CAMERA_BRIGHTNESS, brightness + BRIGHTNESS_NORMAL) < 0) {
+ LOGE("ERR(%s):Fail on V4L2_CID_CAMERA_BRIGHTNESS", __func__);
+ return -1;
+ }
+ }
#endif
- }
+ }
- return 0;
+ return 0;
}
int SecCamera::getBrightness(void)
{
- LOGV("%s():brightness(%d)", __FUNCTION__, m_brightness);
- return m_brightness;
+ LOGV("%s():brightness(%d)", __func__, m_brightness);
+ return m_brightness;
}
// -----------------------------------
int SecCamera::setImageEffect(int image_effect)
{
- LOGV("%s(image_effect(%d))", __FUNCTION__, image_effect);
-
+ LOGV("%s(image_effect(%d))", __func__, image_effect);
+
#ifdef SWP1_CAMERA_ADD_ADVANCED_FUNCTION
- if(image_effect <= IMAGE_EFFECT_BASE || IMAGE_EFFECT_MAX <= image_effect)
+ if (image_effect <= IMAGE_EFFECT_BASE || IMAGE_EFFECT_MAX <= image_effect) {
#else
- if(image_effect < IMAGE_EFFECT_ORIGINAL || IMAGE_EFFECT_SILHOUETTE < image_effect)
+ if (image_effect < IMAGE_EFFECT_ORIGINAL || IMAGE_EFFECT_SILHOUETTE < image_effect) {
#endif
- {
- LOGE("ERR(%s):Invalid image_effect(%d)", __FUNCTION__, image_effect);
- return -1;
- }
-
- if(m_image_effect != image_effect)
- {
- m_image_effect = image_effect;
+ LOGE("ERR(%s):Invalid image_effect(%d)", __func__, image_effect);
+ return -1;
+ }
+
+ if (m_image_effect != image_effect) {
+ m_image_effect = image_effect;
#ifdef SWP1_CAMERA_ADD_ADVANCED_FUNCTION
- if(m_flag_camera_start)
- {
- if (fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_CAMERA_EFFECT, image_effect) < 0)
- {
- LOGE("ERR(%s):Fail on V4L2_CID_CAMERA_EFFECT", __FUNCTION__);
- return -1;
- }
- }
+ if (m_flag_camera_start) {
+ if (fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_CAMERA_EFFECT, image_effect) < 0) {
+ LOGE("ERR(%s):Fail on V4L2_CID_CAMERA_EFFECT", __func__);
+ return -1;
+ }
+ }
#endif
- }
+ }
- return 0;
+ return 0;
}
int SecCamera::getImageEffect(void)
{
- LOGV("%s():image_effect(%d)", __FUNCTION__, m_image_effect);
- return m_image_effect;
+ LOGV("%s():image_effect(%d)", __func__, m_image_effect);
+ return m_image_effect;
}
// ======================================================================
#ifdef SWP1_CAMERA_ADD_ADVANCED_FUNCTION
int SecCamera::setAntiBanding(int anti_banding)
{
- LOGV("%s(anti_banding(%d))", __FUNCTION__, anti_banding);
-
- if(anti_banding < ANTI_BANDING_AUTO|| ANTI_BANDING_OFF < anti_banding)
- {
- LOGE("ERR(%s):Invalid anti_banding (%d)", __FUNCTION__, anti_banding);
- return -1;
- }
-
- if(m_anti_banding != anti_banding)
- {
- m_anti_banding = anti_banding;
- if(m_flag_camera_start)
- {
- if (fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_CAMERA_ANTI_BANDING, anti_banding) < 0)
- {
- LOGE("ERR(%s):Fail on V4L2_CID_CAMERA_ANTI_BANDING", __FUNCTION__);
- return -1;
- }
- }
- }
-
- return 0;
+ LOGV("%s(anti_banding(%d))", __func__, anti_banding);
+
+ if (anti_banding < ANTI_BANDING_AUTO || ANTI_BANDING_OFF < anti_banding) {
+ LOGE("ERR(%s):Invalid anti_banding (%d)", __func__, anti_banding);
+ return -1;
+ }
+
+ if (m_anti_banding != anti_banding) {
+ m_anti_banding = anti_banding;
+ if (m_flag_camera_start) {
+ if (fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_CAMERA_ANTI_BANDING, anti_banding) < 0) {
+ LOGE("ERR(%s):Fail on V4L2_CID_CAMERA_ANTI_BANDING", __func__);
+ return -1;
+ }
+ }
+ }
+
+ return 0;
}
//======================================================================
int SecCamera::setSceneMode(int scene_mode)
{
- LOGV("%s(scene_mode(%d))", __FUNCTION__, scene_mode);
-
- if(scene_mode <= SCENE_MODE_BASE || SCENE_MODE_MAX <= scene_mode)
- {
- LOGE("ERR(%s):Invalid scene_mode (%d)", __FUNCTION__, scene_mode);
- return -1;
- }
-
- if(m_scene_mode != scene_mode)
- {
- m_scene_mode = scene_mode;
- if(m_flag_camera_start)
- {
- if (fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_CAMERA_SCENE_MODE, m_scene_mode) < 0)
- {
- LOGE("ERR(%s):Fail on V4L2_CID_CAMERA_SCENE_MODE", __FUNCTION__);
- return -1;
- }
- }
- }
+ LOGV("%s(scene_mode(%d))", __func__, scene_mode);
+
+ if (scene_mode <= SCENE_MODE_BASE || SCENE_MODE_MAX <= scene_mode) {
+ LOGE("ERR(%s):Invalid scene_mode (%d)", __func__, scene_mode);
+ return -1;
+ }
+
+ if (m_scene_mode != scene_mode) {
+ m_scene_mode = scene_mode;
+ if (m_flag_camera_start) {
+ if (fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_CAMERA_SCENE_MODE, m_scene_mode) < 0) {
+ LOGE("ERR(%s):Fail on V4L2_CID_CAMERA_SCENE_MODE", __func__);
+ return -1;
+ }
+ }
+ }
- return 0;
+ return 0;
}
-int SecCamera::getSceneMode(void)
+int SecCamera::getSceneMode(void)
{
- return m_scene_mode;
+ return m_scene_mode;
}
//======================================================================
int SecCamera::setFlashMode(int flash_mode)
{
- LOGV("%s(flash_mode(%d))", __FUNCTION__, flash_mode);
-
- if(flash_mode <= FLASH_MODE_BASE || FLASH_MODE_MAX <= flash_mode)
- {
- LOGE("ERR(%s):Invalid flash_mode (%d)", __FUNCTION__, flash_mode);
- return -1;
- }
-
- if(m_flash_mode != flash_mode)
- {
- m_flash_mode = flash_mode;
- if(m_flag_camera_start)
- {
- if (fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_CAMERA_FLASH_MODE, flash_mode) < 0)
- {
- LOGE("ERR(%s):Fail on V4L2_CID_CAMERA_FLASH_MODE", __FUNCTION__);
- return -1;
- }
- }
- }
+ LOGV("%s(flash_mode(%d))", __func__, flash_mode);
+
+ if (flash_mode <= FLASH_MODE_BASE || FLASH_MODE_MAX <= flash_mode) {
+ LOGE("ERR(%s):Invalid flash_mode (%d)", __func__, flash_mode);
+ return -1;
+ }
- return 0;
+ if (m_flash_mode != flash_mode) {
+ m_flash_mode = flash_mode;
+ if (m_flag_camera_start) {
+ if (fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_CAMERA_FLASH_MODE, flash_mode) < 0) {
+ LOGE("ERR(%s):Fail on V4L2_CID_CAMERA_FLASH_MODE", __func__);
+ return -1;
+ }
+ }
+ }
+
+ return 0;
}
-int SecCamera::getFlashMode(void)
+int SecCamera::getFlashMode(void)
{
- return m_flash_mode;
+ return m_flash_mode;
}
//======================================================================
int SecCamera::setISO(int iso_value)
{
- LOGV("%s(iso_value(%d))", __FUNCTION__, iso_value);
- if(iso_value <ISO_AUTO || ISO_MAX <= iso_value)
- {
- LOGE("ERR(%s):Invalid iso_value (%d)", __FUNCTION__, iso_value);
- return -1;
- }
-
- if(m_iso != iso_value)
- {
- m_iso = iso_value;
- if(m_flag_camera_start)
- {
- if (fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_CAMERA_ISO, iso_value) < 0)
- {
- LOGE("ERR(%s):Fail on V4L2_CID_CAMERA_ISO", __FUNCTION__);
- return -1;
- }
- }
- }
+ LOGV("%s(iso_value(%d))", __func__, iso_value);
+ if (iso_value < ISO_AUTO || ISO_MAX <= iso_value) {
+ LOGE("ERR(%s):Invalid iso_value (%d)", __func__, iso_value);
+ return -1;
+ }
+
+ if (m_iso != iso_value)
+ {
+ m_iso = iso_value;
+ if (m_flag_camera_start) {
+ if (fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_CAMERA_ISO, iso_value) < 0) {
+ LOGE("ERR(%s):Fail on V4L2_CID_CAMERA_ISO", __func__);
+ return -1;
+ }
+ }
+ }
- return 0;
+ return 0;
}
-int SecCamera::getISO(void)
+int SecCamera::getISO(void)
{
- return m_iso;
+ return m_iso;
}
//======================================================================
int SecCamera::setContrast(int contrast_value)
{
- LOGV("%s(contrast_value(%d))", __FUNCTION__, contrast_value);
-
- if(contrast_value <CONTRAST_MINUS_2|| CONTRAST_MAX<= contrast_value)
- {
- LOGE("ERR(%s):Invalid contrast_value (%d)", __FUNCTION__, contrast_value);
- return -1;
- }
-
- if(m_contrast != contrast_value)
- {
- m_contrast = contrast_value;
- if(m_flag_camera_start)
- {
- if (fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_CAMERA_CONTRAST, contrast_value) < 0)
- {
- LOGE("ERR(%s):Fail on V4L2_CID_CAMERA_CONTRAST", __FUNCTION__);
- return -1;
- }
- }
- }
+ LOGV("%s(contrast_value(%d))", __func__, contrast_value);
+
+ if (contrast_value < CONTRAST_MINUS_2 || CONTRAST_MAX <= contrast_value) {
+ LOGE("ERR(%s):Invalid contrast_value (%d)", __func__, contrast_value);
+ return -1;
+ }
- return 0;
+ if (m_contrast != contrast_value) {
+ m_contrast = contrast_value;
+ if (m_flag_camera_start) {
+ if (fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_CAMERA_CONTRAST, contrast_value) < 0) {
+ LOGE("ERR(%s):Fail on V4L2_CID_CAMERA_CONTRAST", __func__);
+ return -1;
+ }
+ }
+ }
+
+ return 0;
}
-int SecCamera::getContrast(void)
+int SecCamera::getContrast(void)
{
- return m_contrast;
+ return m_contrast;
}
//======================================================================
int SecCamera::setSaturation(int saturation_value)
{
- LOGV("%s(saturation_value(%d))", __FUNCTION__, saturation_value);
-
- if(saturation_value <SATURATION_MINUS_2|| SATURATION_MAX<= saturation_value)
- {
- LOGE("ERR(%s):Invalid saturation_value (%d)", __FUNCTION__, saturation_value);
- return -1;
- }
-
- if(m_saturation!= saturation_value)
- {
- m_saturation = saturation_value;
- if(m_flag_camera_start)
- {
- if (fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_CAMERA_SATURATION, saturation_value) < 0)
- {
- LOGE("ERR(%s):Fail on V4L2_CID_CAMERA_SATURATION", __FUNCTION__);
- return -1;
- }
- }
- }
+ LOGV("%s(saturation_value(%d))", __func__, saturation_value);
- return 0;
+ if (saturation_value <SATURATION_MINUS_2 || SATURATION_MAX<= saturation_value) {
+ LOGE("ERR(%s):Invalid saturation_value (%d)", __func__, saturation_value);
+ return -1;
+ }
+
+ if (m_saturation != saturation_value) {
+ m_saturation = saturation_value;
+ if (m_flag_camera_start) {
+ if (fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_CAMERA_SATURATION, saturation_value) < 0) {
+ LOGE("ERR(%s):Fail on V4L2_CID_CAMERA_SATURATION", __func__);
+ return -1;
+ }
+ }
+ }
+
+ return 0;
}
-int SecCamera::getSaturation(void)
+int SecCamera::getSaturation(void)
{
- return m_saturation;
+ return m_saturation;
}
//======================================================================
int SecCamera::setSharpness(int sharpness_value)
{
- LOGV("%s(sharpness_value(%d))", __FUNCTION__, sharpness_value);
-
- if(sharpness_value <SHARPNESS_MINUS_2|| SHARPNESS_MAX<= sharpness_value)
- {
- LOGE("ERR(%s):Invalid sharpness_value (%d)", __FUNCTION__, sharpness_value);
- return -1;
- }
-
- if(m_sharpness!= sharpness_value)
- {
- m_sharpness = sharpness_value;
- if(m_flag_camera_start)
- {
- if (fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_CAMERA_SHARPNESS, sharpness_value) < 0)
- {
- LOGE("ERR(%s):Fail on V4L2_CID_CAMERA_SHARPNESS", __FUNCTION__);
- return -1;
- }
- }
- }
+ LOGV("%s(sharpness_value(%d))", __func__, sharpness_value);
+
+ if (sharpness_value < SHARPNESS_MINUS_2 || SHARPNESS_MAX <= sharpness_value) {
+ LOGE("ERR(%s):Invalid sharpness_value (%d)", __func__, sharpness_value);
+ return -1;
+ }
- return 0;
+ if (m_sharpness != sharpness_value) {
+ m_sharpness = sharpness_value;
+ if (m_flag_camera_start) {
+ if (fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_CAMERA_SHARPNESS, sharpness_value) < 0) {
+ LOGE("ERR(%s):Fail on V4L2_CID_CAMERA_SHARPNESS", __func__);
+ return -1;
+ }
+ }
+ }
+
+ return 0;
}
-int SecCamera::getSharpness(void)
+int SecCamera::getSharpness(void)
{
- return m_sharpness;
+ return m_sharpness;
}
//======================================================================
int SecCamera::setWDR(int wdr_value)
{
- LOGV("%s(wdr_value(%d))", __FUNCTION__, wdr_value);
-
- if(wdr_value<WDR_OFF || WDR_MAX<= wdr_value)
- {
- LOGE("ERR(%s):Invalid wdr_value (%d)", __FUNCTION__, wdr_value);
- return -1;
- }
-
- if(m_wdr!= wdr_value)
- {
- m_wdr = wdr_value;
- if(m_flag_camera_start)
- {
- if (fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_CAMERA_WDR, wdr_value) < 0)
- {
- LOGE("ERR(%s):Fail on V4L2_CID_CAMERA_WDR", __FUNCTION__);
- return -1;
- }
- }
- }
+ LOGV("%s(wdr_value(%d))", __func__, wdr_value);
+
+ if (wdr_value < WDR_OFF || WDR_MAX <= wdr_value) {
+ LOGE("ERR(%s):Invalid wdr_value (%d)", __func__, wdr_value);
+ return -1;
+ }
+
+ if (m_wdr != wdr_value) {
+ m_wdr = wdr_value;
+ if (m_flag_camera_start) {
+ if (fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_CAMERA_WDR, wdr_value) < 0) {
+ LOGE("ERR(%s):Fail on V4L2_CID_CAMERA_WDR", __func__);
+ return -1;
+ }
+ }
+ }
- return 0;
+ return 0;
}
-int SecCamera::getWDR(void)
+int SecCamera::getWDR(void)
{
- return m_wdr;
+ return m_wdr;
}
//======================================================================
int SecCamera::setAntiShake(int anti_shake)
{
- LOGV("%s(anti_shake(%d))", __FUNCTION__, anti_shake);
-
- if(anti_shake<ANTI_SHAKE_OFF || ANTI_SHAKE_MAX<= anti_shake)
- {
- LOGE("ERR(%s):Invalid anti_shake (%d)", __FUNCTION__, anti_shake);
- return -1;
- }
-
- if(m_anti_shake!= anti_shake)
- {
- m_anti_shake = anti_shake;
- if(m_flag_camera_start)
- {
- if (fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_CAMERA_ANTI_SHAKE, anti_shake) < 0)
- {
- LOGE("ERR(%s):Fail on V4L2_CID_CAMERA_ANTI_SHAKE", __FUNCTION__);
- return -1;
- }
- }
- }
+ LOGV("%s(anti_shake(%d))", __func__, anti_shake);
+
+ if (anti_shake < ANTI_SHAKE_OFF || ANTI_SHAKE_MAX <= anti_shake) {
+ LOGE("ERR(%s):Invalid anti_shake (%d)", __func__, anti_shake);
+ return -1;
+ }
- return 0;
+ if (m_anti_shake != anti_shake) {
+ m_anti_shake = anti_shake;
+ if (m_flag_camera_start) {
+ if (fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_CAMERA_ANTI_SHAKE, anti_shake) < 0) {
+ LOGE("ERR(%s):Fail on V4L2_CID_CAMERA_ANTI_SHAKE", __func__);
+ return -1;
+ }
+ }
+ }
+
+ return 0;
}
-int SecCamera::getAntiShake(void)
+int SecCamera::getAntiShake(void)
{
- return m_anti_shake;
+ return m_anti_shake;
}
//======================================================================
@@ -2660,720 +2550,645 @@ int SecCamera::getAntiShake(void)
int SecCamera::setMetering(int metering_value)
{
- LOGV("%s(metering (%d))", __FUNCTION__, metering_value);
-
- if(metering_value <= METERING_BASE || METERING_MAX <= metering_value)
- {
- LOGE("ERR(%s):Invalid metering_value (%d)", __FUNCTION__, metering_value);
- return -1;
- }
-
- if(m_metering != metering_value)
- {
- m_metering = metering_value;
- if(m_flag_camera_start)
- {
- if (fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_CAMERA_METERING, metering_value) < 0)
- {
- LOGE("ERR(%s):Fail on V4L2_CID_CAMERA_METERING", __FUNCTION__);
- return -1;
- }
- }
- }
+ LOGV("%s(metering (%d))", __func__, metering_value);
+
+ if (metering_value <= METERING_BASE || METERING_MAX <= metering_value) {
+ LOGE("ERR(%s):Invalid metering_value (%d)", __func__, metering_value);
+ return -1;
+ }
+
+ if (m_metering != metering_value) {
+ m_metering = metering_value;
+ if (m_flag_camera_start) {
+ if (fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_CAMERA_METERING, metering_value) < 0) {
+ LOGE("ERR(%s):Fail on V4L2_CID_CAMERA_METERING", __func__);
+ return -1;
+ }
+ }
+ }
- return 0;
+ return 0;
}
-int SecCamera::getMetering(void)
+int SecCamera::getMetering(void)
{
- return m_metering;
+ return m_metering;
}
//======================================================================
int SecCamera::setJpegQuality(int jpeg_quality)
{
- LOGV("%s(jpeg_quality (%d))", __FUNCTION__, jpeg_quality);
-
- if(jpeg_quality < JPEG_QUALITY_ECONOMY|| JPEG_QUALITY_MAX<= jpeg_quality)
- {
- LOGE("ERR(%s):Invalid jpeg_quality (%d)", __FUNCTION__, jpeg_quality);
- return -1;
- }
-
- if(m_jpeg_quality != jpeg_quality)
- {
- m_jpeg_quality = jpeg_quality;
- if (fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_CAM_JPEG_QUALITY, jpeg_quality) < 0)
- {
- LOGE("ERR(%s):Fail on V4L2_CID_CAM_JPEG_QUALITY", __FUNCTION__);
- return -1;
- }
- }
+ LOGV("%s(jpeg_quality (%d))", __func__, jpeg_quality);
+
+ if (jpeg_quality < JPEG_QUALITY_ECONOMY || JPEG_QUALITY_MAX <= jpeg_quality) {
+ LOGE("ERR(%s):Invalid jpeg_quality (%d)", __func__, jpeg_quality);
+ return -1;
+ }
+
+ if (m_jpeg_quality != jpeg_quality) {
+ m_jpeg_quality = jpeg_quality;
+ if (fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_CAM_JPEG_QUALITY, jpeg_quality) < 0) {
+ LOGE("ERR(%s):Fail on V4L2_CID_CAM_JPEG_QUALITY", __func__);
+ return -1;
+ }
+ }
- return 0;
+ return 0;
}
-int SecCamera::getJpegQuality(void)
+int SecCamera::getJpegQuality(void)
{
- return m_jpeg_quality;
+ return m_jpeg_quality;
}
//======================================================================
int SecCamera::setZoom(int zoom_level)
{
- LOGV("%s(zoom_level (%d))", __FUNCTION__, zoom_level);
-
- if(zoom_level < ZOOM_LEVEL_0|| ZOOM_LEVEL_MAX<= zoom_level)
- {
- LOGE("ERR(%s):Invalid zoom_level (%d)", __FUNCTION__, zoom_level);
- return -1;
- }
-
- if(m_zoom_level != zoom_level)
- {
- m_zoom_level = zoom_level;
+ LOGV("%s(zoom_level (%d))", __func__, zoom_level);
+
+ if (zoom_level < ZOOM_LEVEL_0 || ZOOM_LEVEL_MAX <= zoom_level) {
+ LOGE("ERR(%s):Invalid zoom_level (%d)", __func__, zoom_level);
+ return -1;
+ }
+
+ if (m_zoom_level != zoom_level) {
+ m_zoom_level = zoom_level;
- if(m_flag_camera_start)
- {
- if (fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_CAMERA_ZOOM, zoom_level) < 0)
- {
- LOGE("ERR(%s):Fail on V4L2_CID_CAMERA_ZOOM", __FUNCTION__);
- return -1;
- }
- }
- }
+ if (m_flag_camera_start) {
+ if (fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_CAMERA_ZOOM, zoom_level) < 0) {
+ LOGE("ERR(%s):Fail on V4L2_CID_CAMERA_ZOOM", __func__);
+ return -1;
+ }
+ }
+ }
- return 0;
+ return 0;
}
-int SecCamera::getZoom(void)
+int SecCamera::getZoom(void)
{
- return m_zoom_level;
+ return m_zoom_level;
}
//======================================================================
int SecCamera::setObjectTracking(int object_tracking)
{
- LOGV("%s(object_tracking (%d))", __FUNCTION__, object_tracking);
-
- if(object_tracking < OBJECT_TRACKING_OFF|| OBJECT_TRACKING_MAX<= object_tracking)
- {
- LOGE("ERR(%s):Invalid object_tracking (%d)", __FUNCTION__, object_tracking);
- return -1;
- }
-
- if(m_object_tracking != object_tracking)
- {
- m_object_tracking = object_tracking;
- }
+ LOGV("%s(object_tracking (%d))", __func__, object_tracking);
+
+ if (object_tracking < OBJECT_TRACKING_OFF || OBJECT_TRACKING_MAX <= object_tracking) {
+ LOGE("ERR(%s):Invalid object_tracking (%d)", __func__, object_tracking);
+ return -1;
+ }
- return 0;
+ if (m_object_tracking != object_tracking) {
+ m_object_tracking = object_tracking;
+ }
+
+ return 0;
}
-int SecCamera::getObjectTracking(void)
+int SecCamera::getObjectTracking(void)
{
- return m_object_tracking;
+ return m_object_tracking;
}
int SecCamera::getObjectTrackingStatus(void)
{
- int obj_status = 0;
- obj_status = fimc_v4l2_g_ctrl(m_cam_fd, V4L2_CID_CAMERA_OBJ_TRACKING_STATUS);
- return obj_status;
+ int obj_status = 0;
+ obj_status = fimc_v4l2_g_ctrl(m_cam_fd, V4L2_CID_CAMERA_OBJ_TRACKING_STATUS);
+ return obj_status;
}
int SecCamera::setObjectTrackingStartStop(int start_stop)
{
- LOGV("%s(object_tracking_start_stop (%d))", __FUNCTION__, start_stop);
-
- if(m_object_tracking_start_stop != start_stop)
- {
- m_object_tracking_start_stop = start_stop;
- if (fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_CAMERA_OBJ_TRACKING_START_STOP, start_stop) < 0)
- {
- LOGE("ERR(%s):Fail on V4L2_CID_CAMERA_OBJ_TRACKING_START_STOP", __FUNCTION__);
- return -1;
- }
- }
+ LOGV("%s(object_tracking_start_stop (%d))", __func__, start_stop);
+
+ if (m_object_tracking_start_stop != start_stop) {
+ m_object_tracking_start_stop = start_stop;
+ if (fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_CAMERA_OBJ_TRACKING_START_STOP, start_stop) < 0) {
+ LOGE("ERR(%s):Fail on V4L2_CID_CAMERA_OBJ_TRACKING_START_STOP", __func__);
+ return -1;
+ }
+ }
- return 0;
+ return 0;
}
int SecCamera::setTouchAFStartStop(int start_stop)
{
- LOGV("%s(touch_af_start_stop (%d))", __FUNCTION__, start_stop);
-
- if(m_touch_af_start_stop != start_stop)
- {
- m_touch_af_start_stop = start_stop;
- if (fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_CAMERA_TOUCH_AF_START_STOP, start_stop) < 0)
-{
- LOGE("ERR(%s):Fail on V4L2_CID_CAMERA_TOUCH_AF_START_STOP", __FUNCTION__);
- return -1;
- }
- }
+ LOGV("%s(touch_af_start_stop (%d))", __func__, start_stop);
+
+ if (m_touch_af_start_stop != start_stop) {
+ m_touch_af_start_stop = start_stop;
+ if (fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_CAMERA_TOUCH_AF_START_STOP, start_stop) < 0) {
+ LOGE("ERR(%s):Fail on V4L2_CID_CAMERA_TOUCH_AF_START_STOP", __func__);
+ return -1;
+ }
+ }
- return 0;
+ return 0;
}
//======================================================================
int SecCamera::setSmartAuto(int smart_auto)
{
- LOGV("%s(smart_auto (%d))", __FUNCTION__, smart_auto);
-
- if(smart_auto < SMART_AUTO_OFF|| SMART_AUTO_MAX <= smart_auto)
- {
- LOGE("ERR(%s):Invalid smart_auto (%d)", __FUNCTION__, smart_auto);
- return -1;
- }
-
- if(m_smart_auto != smart_auto)
- {
- m_smart_auto = smart_auto;
- if(m_flag_camera_start)
- {
- if (fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_CAMERA_SMART_AUTO, smart_auto) < 0)
- {
- LOGE("ERR(%s):Fail on V4L2_CID_CAMERA_SMART_AUTO", __FUNCTION__);
- return -1;
- }
- }
- }
-
- return 0;
-}
-
-int SecCamera::getSmartAuto(void)
-{
- return m_smart_auto;
-}
-
-int SecCamera::getAutosceneStatus(void)
-{
- int autoscene_status = -1;
-
- if(getSmartAuto() == SMART_AUTO_ON)
- {
- autoscene_status = fimc_v4l2_g_ctrl(m_cam_fd, V4L2_CID_CAMERA_SMART_AUTO_STATUS);
-
- if((autoscene_status < SMART_AUTO_STATUS_AUTO) || (autoscene_status > SMART_AUTO_STATUS_MAX))
- {
- LOGE("ERR(%s):Invalid getAutosceneStatus (%d)", __FUNCTION__, autoscene_status);
- return -1;
- }
- }
- //LOGV("%s() autoscene_status (%d)", __FUNCTION__, autoscene_status);
- return autoscene_status;
+ LOGV("%s(smart_auto (%d))", __func__, smart_auto);
+
+ if (smart_auto < SMART_AUTO_OFF || SMART_AUTO_MAX <= smart_auto) {
+ LOGE("ERR(%s):Invalid smart_auto (%d)", __func__, smart_auto);
+ return -1;
+ }
+
+ if (m_smart_auto != smart_auto) {
+ m_smart_auto = smart_auto;
+ if (m_flag_camera_start) {
+ if (fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_CAMERA_SMART_AUTO, smart_auto) < 0) {
+ LOGE("ERR(%s):Fail on V4L2_CID_CAMERA_SMART_AUTO", __func__);
+ return -1;
+ }
+ }
+ }
+
+ return 0;
+}
+
+int SecCamera::getSmartAuto(void)
+{
+ return m_smart_auto;
+}
+
+int SecCamera::getAutosceneStatus(void)
+{
+ int autoscene_status = -1;
+
+ if (getSmartAuto() == SMART_AUTO_ON) {
+ autoscene_status = fimc_v4l2_g_ctrl(m_cam_fd, V4L2_CID_CAMERA_SMART_AUTO_STATUS);
+
+ if ((autoscene_status < SMART_AUTO_STATUS_AUTO) || (autoscene_status > SMART_AUTO_STATUS_MAX)) {
+ LOGE("ERR(%s):Invalid getAutosceneStatus (%d)", __func__, autoscene_status);
+ return -1;
+ }
+ }
+ //LOGV("%s() autoscene_status (%d)", __func__, autoscene_status);
+ return autoscene_status;
}
//======================================================================
int SecCamera::setBeautyShot(int beauty_shot)
{
- LOGV("%s(beauty_shot (%d))", __FUNCTION__, beauty_shot);
-
- if(beauty_shot < BEAUTY_SHOT_OFF|| BEAUTY_SHOT_MAX <= beauty_shot)
- {
- LOGE("ERR(%s):Invalid beauty_shot (%d)", __FUNCTION__, beauty_shot);
- return -1;
- }
-
- if(m_beauty_shot != beauty_shot)
- {
- m_beauty_shot = beauty_shot;
- if(m_flag_camera_start)
- {
- if (fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_CAMERA_BEAUTY_SHOT, beauty_shot) < 0)
- {
- LOGE("ERR(%s):Fail on V4L2_CID_CAMERA_BEAUTY_SHOT", __FUNCTION__);
- return -1;
- }
-
- setFaceDetect(FACE_DETECT_BEAUTY_ON);
- }
- }
-
- return 0;
-}
-
-int SecCamera::getBeautyShot(void)
-{
- return m_beauty_shot;
+ LOGV("%s(beauty_shot (%d))", __func__, beauty_shot);
+
+ if (beauty_shot < BEAUTY_SHOT_OFF || BEAUTY_SHOT_MAX <= beauty_shot) {
+ LOGE("ERR(%s):Invalid beauty_shot (%d)", __func__, beauty_shot);
+ return -1;
+ }
+
+ if (m_beauty_shot != beauty_shot) {
+ m_beauty_shot = beauty_shot;
+ if (m_flag_camera_start) {
+ if (fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_CAMERA_BEAUTY_SHOT, beauty_shot) < 0) {
+ LOGE("ERR(%s):Fail on V4L2_CID_CAMERA_BEAUTY_SHOT", __func__);
+ return -1;
+ }
+
+ setFaceDetect(FACE_DETECT_BEAUTY_ON);
+ }
+ }
+
+ return 0;
+}
+
+int SecCamera::getBeautyShot(void)
+{
+ return m_beauty_shot;
}
//======================================================================
int SecCamera::setVintageMode(int vintage_mode)
{
- LOGV("%s(vintage_mode(%d))", __FUNCTION__, vintage_mode);
-
- if(vintage_mode <= VINTAGE_MODE_BASE || VINTAGE_MODE_MAX <= vintage_mode)
- {
- LOGE("ERR(%s):Invalid vintage_mode (%d)", __FUNCTION__, vintage_mode);
- return -1;
- }
-
- if(m_vintage_mode != vintage_mode)
- {
- m_vintage_mode = vintage_mode;
- if(m_flag_camera_start)
- {
- if (fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_CAMERA_VINTAGE_MODE, vintage_mode) < 0)
- {
- LOGE("ERR(%s):Fail on V4L2_CID_CAMERA_VINTAGE_MODE", __FUNCTION__);
- return -1;
- }
- }
- }
+ LOGV("%s(vintage_mode(%d))", __func__, vintage_mode);
- return 0;
+ if (vintage_mode <= VINTAGE_MODE_BASE || VINTAGE_MODE_MAX <= vintage_mode) {
+ LOGE("ERR(%s):Invalid vintage_mode (%d)", __func__, vintage_mode);
+ return -1;
+ }
+
+ if (m_vintage_mode != vintage_mode) {
+ m_vintage_mode = vintage_mode;
+ if (m_flag_camera_start) {
+ if (fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_CAMERA_VINTAGE_MODE, vintage_mode) < 0) {
+ LOGE("ERR(%s):Fail on V4L2_CID_CAMERA_VINTAGE_MODE", __func__);
+ return -1;
+ }
+ }
+ }
+
+ return 0;
}
-int SecCamera::getVintageMode(void)
+int SecCamera::getVintageMode(void)
{
- return m_vintage_mode;
+ return m_vintage_mode;
}
//======================================================================
int SecCamera::setFocusMode(int focus_mode)
{
- LOGV("%s(focus_mode(%d))", __FUNCTION__, focus_mode);
-
- if(FOCUS_MODE_MAX <= focus_mode)
- {
- LOGE("ERR(%s):Invalid focus_mode (%d)", __FUNCTION__, focus_mode);
- return -1;
- }
-
- if(m_focus_mode != focus_mode)
- {
- m_focus_mode = focus_mode;
-
- if (m_focus_mode != FOCUS_MODE_FACEDETECT)
- {
- m_face_detect = FACE_DETECT_OFF;
- if(m_flag_camera_start)
- {
-// setFaceDetect(m_face_detect);
-
- if (fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_CAMERA_FOCUS_MODE, focus_mode) < 0)
- {
- LOGE("ERR(%s):Fail on V4L2_CID_CAMERA_FOCUS_MODE", __FUNCTION__);
- return -1;
- }
- }
- }
- else
- {
- m_face_detect = FACE_DETECT_NORMAL_ON;
- if(m_flag_camera_start)
- {
- if (fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_CAMERA_FOCUS_MODE, FOCUS_MODE_AUTO) < 0)
- {
- LOGE("ERR(%s):Fail on V4L2_CID_CAMERA_FOCUS_MODE", __FUNCTION__);
- return -1;
- }
-
-// setFaceDetect(m_face_detect);
- }
- }
- }
-
- return 0;
-}
-
-int SecCamera::getFocusMode(void)
-{
- return m_focus_mode;
+ LOGV("%s(focus_mode(%d))", __func__, focus_mode);
+
+ if (FOCUS_MODE_MAX <= focus_mode) {
+ LOGE("ERR(%s):Invalid focus_mode (%d)", __func__, focus_mode);
+ return -1;
+ }
+
+ if (m_focus_mode != focus_mode) {
+ m_focus_mode = focus_mode;
+
+ if (m_focus_mode != FOCUS_MODE_FACEDETECT) {
+ m_face_detect = FACE_DETECT_OFF;
+ if (m_flag_camera_start) {
+// setFaceDetect(m_face_detect);
+
+ if (fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_CAMERA_FOCUS_MODE, focus_mode) < 0) {
+ LOGE("ERR(%s):Fail on V4L2_CID_CAMERA_FOCUS_MODE", __func__);
+ return -1;
+ }
+ }
+ } else {
+ m_face_detect = FACE_DETECT_NORMAL_ON;
+ if (m_flag_camera_start) {
+ if (fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_CAMERA_FOCUS_MODE, FOCUS_MODE_AUTO) < 0) {
+ LOGE("ERR(%s):Fail on V4L2_CID_CAMERA_FOCUS_MODE", __func__);
+ return -1;
+ }
+
+// setFaceDetect(m_face_detect);
+ }
+ }
+ }
+
+ return 0;
+}
+
+int SecCamera::getFocusMode(void)
+{
+ return m_focus_mode;
}
//======================================================================
- int SecCamera::setFaceDetect(int face_detect)
- {
- LOGV("%s(face_detect(%d))", __FUNCTION__, face_detect);
-
-// if(m_face_detect != face_detect)
- {
- m_face_detect = face_detect;
- if(m_flag_camera_start)
- {
- if(m_face_detect != FACE_DETECT_OFF)
- {
- if (fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_CAMERA_FOCUS_MODE, FOCUS_MODE_AUTO) < 0)
- {
- LOGE("ERR(%s):Fail on V4L2_CID_CAMERA_FOCUS_MODin face detecion", __FUNCTION__);
- return -1;
- }
- }
- if (fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_CAMERA_FACE_DETECTION, face_detect) < 0)
- {
- LOGE("ERR(%s):Fail on V4L2_CID_CAMERA_FACE_DETECTION", __FUNCTION__);
- return -1;
- }
- }
- }
-
- return 0;
-}
-
- int SecCamera::getFaceDetect(void)
- {
- return m_face_detect;
- }
+int SecCamera::setFaceDetect(int face_detect)
+{
+ LOGV("%s(face_detect(%d))", __func__, face_detect);
- //======================================================================
-
- int SecCamera::setGPSLatitude(const char * gps_latitude)
- {
- double conveted_latitude = 0;
- LOGV("%s(gps_latitude(%s))", __FUNCTION__, gps_latitude);
- if(gps_latitude == NULL)
- m_gps_latitude = 0;
- else
- {
- conveted_latitude = atof(gps_latitude);
- m_gps_latitude = (long)(conveted_latitude *10000 /1);
- }
-
- LOGV("%s(m_gps_latitude(%ld))", __FUNCTION__, m_gps_latitude);
- return 0;
- }
- int SecCamera::setGPSLongitude(const char * gps_longitude)
- {
- double conveted_longitude = 0;
- LOGV("%s(gps_longitude(%s))", __FUNCTION__, gps_longitude);
- if(gps_longitude == NULL)
- m_gps_longitude = 0;
- else
- {
- conveted_longitude = atof(gps_longitude);
- m_gps_longitude = (long)(conveted_longitude *10000 /1);
- }
-
- LOGV("%s(m_gps_longitude(%ld))", __FUNCTION__, m_gps_longitude);
- return 0;
- }
- int SecCamera::setGPSAltitude(const char * gps_altitude)
- {
- double conveted_altitude = 0;
- LOGV("%s(gps_altitude(%s))", __FUNCTION__, gps_altitude);
- if(gps_altitude == NULL)
- m_gps_altitude = 0;
- else
- {
- conveted_altitude = atof(gps_altitude);
- m_gps_altitude = (long)(conveted_altitude *100 /1);
- }
-
- LOGV("%s(m_gps_altitude(%ld))", __FUNCTION__, m_gps_altitude);
- return 0;
- }
- int SecCamera::setGPSTimeStamp(const char * gps_timestamp)
- {
- LOGV("%s(gps_timestamp(%s))", __FUNCTION__, gps_timestamp);
- if(gps_timestamp == NULL)
- m_gps_timestamp = 0;
- else
- m_gps_timestamp = atol(gps_timestamp);
-
- LOGV("%s(m_gps_timestamp(%ld))", __FUNCTION__, m_gps_timestamp);
- return 0;
+// if (m_face_detect != face_detect) {
+ m_face_detect = face_detect;
+ if (m_flag_camera_start) {
+ if (m_face_detect != FACE_DETECT_OFF) {
+ if (fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_CAMERA_FOCUS_MODE, FOCUS_MODE_AUTO) < 0) {
+ LOGE("ERR(%s):Fail on V4L2_CID_CAMERA_FOCUS_MODin face detecion", __func__);
+ return -1;
+ }
+ }
+ if (fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_CAMERA_FACE_DETECTION, face_detect) < 0) {
+ LOGE("ERR(%s):Fail on V4L2_CID_CAMERA_FACE_DETECTION", __func__);
+ return -1;
+ }
+ }
+// }
+
+ return 0;
+}
+
+int SecCamera::getFaceDetect(void)
+{
+ return m_face_detect;
+}
+
+//======================================================================
+
+int SecCamera::setGPSLatitude(const char *gps_latitude)
+{
+ double conveted_latitude = 0;
+ LOGV("%s(gps_latitude(%s))", __func__, gps_latitude);
+ if (gps_latitude == NULL)
+ m_gps_latitude = 0;
+ else {
+ conveted_latitude = atof(gps_latitude);
+ m_gps_latitude = (long)(conveted_latitude * 10000 / 1);
+ }
+
+ LOGV("%s(m_gps_latitude(%ld))", __func__, m_gps_latitude);
+ return 0;
+}
+
+int SecCamera::setGPSLongitude(const char *gps_longitude)
+{
+ double conveted_longitude = 0;
+ LOGV("%s(gps_longitude(%s))", __func__, gps_longitude);
+ if (gps_longitude == NULL)
+ m_gps_longitude = 0;
+ else {
+ conveted_longitude = atof(gps_longitude);
+ m_gps_longitude = (long)(conveted_longitude * 10000 / 1);
+ }
+
+ LOGV("%s(m_gps_longitude(%ld))", __func__, m_gps_longitude);
+ return 0;
+}
+
+int SecCamera::setGPSAltitude(const char *gps_altitude)
+{
+ double conveted_altitude = 0;
+ LOGV("%s(gps_altitude(%s))", __func__, gps_altitude);
+ if (gps_altitude == NULL)
+ m_gps_altitude = 0;
+ else {
+ conveted_altitude = atof(gps_altitude);
+ m_gps_altitude = (long)(conveted_altitude * 100 / 1);
+ }
+
+ LOGV("%s(m_gps_altitude(%ld))", __func__, m_gps_altitude);
+ return 0;
+}
+
+int SecCamera::setGPSTimeStamp(const char *gps_timestamp)
+{
+ LOGV("%s(gps_timestamp(%s))", __func__, gps_timestamp);
+ if (gps_timestamp == NULL)
+ m_gps_timestamp = 0;
+ else
+ m_gps_timestamp = atol(gps_timestamp);
+
+ LOGV("%s(m_gps_timestamp(%ld))", __func__, m_gps_timestamp);
+ return 0;
}
- //======================================================================
- int SecCamera::setAEAWBLockUnlock(int ae_lockunlock, int awb_lockunlock)
- {
- LOGV("%s(ae_lockunlock(%d) , (awb_lockunlock(%d))", __FUNCTION__, ae_lockunlock, awb_lockunlock);
- int ae_awb_status = 1;
+//======================================================================
+int SecCamera::setAEAWBLockUnlock(int ae_lockunlock, int awb_lockunlock)
+{
+ LOGV("%s(ae_lockunlock(%d) , (awb_lockunlock(%d))", __func__, ae_lockunlock, awb_lockunlock);
+ int ae_awb_status = 1;
#if 0
- if(ae_lockunlock == 0 && awb_lockunlock ==0)
- ae_awb_status = AE_UNLOCK_AWB_UNLOCK;
- else if (ae_lockunlock == 1 && awb_lockunlock ==0)
- ae_awb_status = AE_LOCK_AWB_UNLOCK;
- else if (ae_lockunlock == 1 && awb_lockunlock ==0)
- ae_awb_status = AE_UNLOCK_AWB_LOCK;
- else
- ae_awb_status = AE_LOCK_AWB_LOCK;
-#endif
- if (fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_CAMERA_AEAWB_LOCK_UNLOCK, ae_awb_status) < 0)
- {
- LOGE("ERR(%s):Fail on V4L2_CID_CAMERA_AE_AWB_LOCKUNLOCK", __FUNCTION__);
- return -1;
- }
-
- return 0;
- }
+ if (ae_lockunlock == 0 && awb_lockunlock == 0)
+ ae_awb_status = AE_UNLOCK_AWB_UNLOCK;
+ else if (ae_lockunlock == 1 && awb_lockunlock == 0)
+ ae_awb_status = AE_LOCK_AWB_UNLOCK;
+ else if (ae_lockunlock == 1 && awb_lockunlock == 0)
+ ae_awb_status = AE_UNLOCK_AWB_LOCK;
+ else
+ ae_awb_status = AE_LOCK_AWB_LOCK;
+#endif
+ if (fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_CAMERA_AEAWB_LOCK_UNLOCK, ae_awb_status) < 0) {
+ LOGE("ERR(%s):Fail on V4L2_CID_CAMERA_AE_AWB_LOCKUNLOCK", __func__);
+ return -1;
+ }
- int SecCamera::setFaceDetectLockUnlock(int facedetect_lockunlock)
- {
- LOGV("%s(facedetect_lockunlock(%d))", __FUNCTION__, facedetect_lockunlock);
-
- if (fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_CAMERA_FACEDETECT_LOCKUNLOCK, facedetect_lockunlock) < 0)
- {
- LOGE("ERR(%s):Fail on V4L2_CID_CAMERA_FACEDETECT_LOCKUNLOCK", __FUNCTION__);
- return -1;
- }
-
- return 0;
- }
+ return 0;
+}
- int SecCamera::setObjectPosition(int x, int y)
- {
- LOGV("%s(setObjectPosition(x=%d, y=%d))", __FUNCTION__, x, y);
-
- if(m_preview_width ==640)
- x = x - 80;
-
- if (fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_CAMERA_OBJECT_POSITION_X, x) < 0)
- {
- LOGE("ERR(%s):Fail on V4L2_CID_CAMERA_OBJECT_POSITION_X", __FUNCTION__);
- return -1;
- }
-
- if (fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_CAMERA_OBJECT_POSITION_Y, y) < 0)
- {
- LOGE("ERR(%s):Fail on V4L2_CID_CAMERA_OBJECT_POSITION_Y", __FUNCTION__);
- return -1;
- }
-
- return 0;
- }
-
- //======================================================================
-
- int SecCamera::setGamma(int gamma)
- {
- LOGV("%s(gamma(%d))", __FUNCTION__, gamma);
-
- if(gamma<GAMMA_OFF|| GAMMA_MAX<= gamma)
- {
- LOGE("ERR(%s):Invalid gamma (%d)", __FUNCTION__, gamma);
- return -1;
- }
-
- if(m_video_gamma!= gamma)
- {
- m_video_gamma = gamma;
- if(m_flag_camera_start)
- {
- if (fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_CAMERA_SET_GAMMA, gamma) < 0)
- {
- LOGE("ERR(%s):Fail on V4L2_CID_CAMERA_SET_GAMMA", __FUNCTION__);
- return -1;
- }
- }
- }
-
- return 0;
- }
-
- //======================================================================
-
- int SecCamera::setSlowAE(int slow_ae)
- {
- LOGV("%s(slow_ae(%d))", __FUNCTION__, slow_ae);
-
- if(slow_ae<GAMMA_OFF|| GAMMA_MAX<= slow_ae)
- {
- LOGE("ERR(%s):Invalid slow_ae (%d)", __FUNCTION__, slow_ae);
- return -1;
- }
-
- if(m_slow_ae!= slow_ae)
- {
- m_slow_ae = slow_ae;
- if(m_flag_camera_start)
- {
- if (fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_CAMERA_SET_SLOW_AE, slow_ae) < 0)
- {
- LOGE("ERR(%s):Fail on V4L2_CID_CAMERA_SET_SLOW_AE", __FUNCTION__);
- return -1;
- }
- }
- }
-
- return 0;
- }
-
- //======================================================================
-
- int SecCamera::setRecordingSize(int width, int height)
- {
- LOGE("%s(width(%d), height(%d))", __FUNCTION__, width, height);
-
- m_recording_width = width;
- m_recording_height = height;
-
- return 0;
- }
+int SecCamera::setFaceDetectLockUnlock(int facedetect_lockunlock)
+{
+ LOGV("%s(facedetect_lockunlock(%d))", __func__, facedetect_lockunlock);
+
+ if (fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_CAMERA_FACEDETECT_LOCKUNLOCK, facedetect_lockunlock) < 0) {
+ LOGE("ERR(%s):Fail on V4L2_CID_CAMERA_FACEDETECT_LOCKUNLOCK", __func__);
+ return -1;
+ }
+
+ return 0;
+}
+
+int SecCamera::setObjectPosition(int x, int y)
+{
+ LOGV("%s(setObjectPosition(x=%d, y=%d))", __func__, x, y);
+
+ if (m_preview_width ==640)
+ x = x - 80;
+
+ if (fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_CAMERA_OBJECT_POSITION_X, x) < 0) {
+ LOGE("ERR(%s):Fail on V4L2_CID_CAMERA_OBJECT_POSITION_X", __func__);
+ return -1;
+ }
+
+ if (fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_CAMERA_OBJECT_POSITION_Y, y) < 0) {
+ LOGE("ERR(%s):Fail on V4L2_CID_CAMERA_OBJECT_POSITION_Y", __func__);
+ return -1;
+ }
+
+ return 0;
+}
+
+//======================================================================
+
+int SecCamera::setGamma(int gamma)
+{
+ LOGV("%s(gamma(%d))", __func__, gamma);
+
+ if (gamma < GAMMA_OFF || GAMMA_MAX <= gamma) {
+ LOGE("ERR(%s):Invalid gamma (%d)", __func__, gamma);
+ return -1;
+ }
+
+ if (m_video_gamma != gamma) {
+ m_video_gamma = gamma;
+ if (m_flag_camera_start) {
+ if (fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_CAMERA_SET_GAMMA, gamma) < 0) {
+ LOGE("ERR(%s):Fail on V4L2_CID_CAMERA_SET_GAMMA", __func__);
+ return -1;
+ }
+ }
+ }
+
+ return 0;
+}
+
+//======================================================================
+
+int SecCamera::setSlowAE(int slow_ae)
+{
+ LOGV("%s(slow_ae(%d))", __func__, slow_ae);
+
+ if (slow_ae < GAMMA_OFF || GAMMA_MAX <= slow_ae) {
+ LOGE("ERR(%s):Invalid slow_ae (%d)", __func__, slow_ae);
+ return -1;
+ }
+
+ if (m_slow_ae!= slow_ae) {
+ m_slow_ae = slow_ae;
+ if (m_flag_camera_start) {
+ if (fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_CAMERA_SET_SLOW_AE, slow_ae) < 0) {
+ LOGE("ERR(%s):Fail on V4L2_CID_CAMERA_SET_SLOW_AE", __func__);
+ return -1;
+ }
+ }
+ }
+
+ return 0;
+}
+
+//======================================================================
+int SecCamera::setRecordingSize(int width, int height)
+{
+ LOGE("%s(width(%d), height(%d))", __func__, width, height);
- //======================================================================
+ m_recording_width = width;
+ m_recording_height = height;
+
+ return 0;
+}
+
+//======================================================================
int SecCamera::setExifOrientationInfo(int orientationInfo)
{
- LOGV("%s(orientationInfo(%d))", __FUNCTION__, orientationInfo);
-
- if(orientationInfo < 0)
- {
- LOGE("ERR(%s):Invalid orientationInfo (%d)", __FUNCTION__, orientationInfo);
- return -1;
- }
- m_exif_orientation = orientationInfo;
+ LOGV("%s(orientationInfo(%d))", __func__, orientationInfo);
- return 0;
+ if (orientationInfo < 0) {
+ LOGE("ERR(%s):Invalid orientationInfo (%d)", __func__, orientationInfo);
+ return -1;
+ }
+ m_exif_orientation = orientationInfo;
+
+ return 0;
}
- //======================================================================
+//======================================================================
int SecCamera::setBatchReflection()
{
- if(m_flag_camera_start)
- {
- if (fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_CAMERA_BATCH_REFLECTION, 1) < 0)
- {
- LOGE("ERR(%s):Fail on V4L2_CID_CAMERA_BATCH_REFLECTION", __FUNCTION__);
- return -1;
- }
- }
-
- return 0;
+ if (m_flag_camera_start) {
+ if (fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_CAMERA_BATCH_REFLECTION, 1) < 0) {
+ LOGE("ERR(%s):Fail on V4L2_CID_CAMERA_BATCH_REFLECTION", __func__);
+ return -1;
+ }
+ }
+
+ return 0;
}
/*Video call*/
int SecCamera::setVTmode(int vtmode)
{
- LOGV("%s(vtmode (%d))", __FUNCTION__, vtmode);
-
- if(vtmode < VT_MODE_OFF || VT_MODE_MAX <= vtmode)
- {
- LOGE("ERR(%s):Invalid vtmode (%d)", __FUNCTION__, vtmode);
- return -1;
- }
-
- if(m_vtmode != vtmode)
- {
- m_vtmode = vtmode;
- }
+ LOGV("%s(vtmode (%d))", __func__, vtmode);
+
+ if (vtmode < VT_MODE_OFF || VT_MODE_MAX <= vtmode) {
+ LOGE("ERR(%s):Invalid vtmode (%d)", __func__, vtmode);
+ return -1;
+ }
- return 0;
+ if (m_vtmode != vtmode) {
+ m_vtmode = vtmode;
+ }
+
+ return 0;
}
/* Camcorder fix fps */
int SecCamera::setSensorMode(int sensor_mode)
{
- LOGV("%s(sensor_mode (%d))", __FUNCTION__, sensor_mode);
-
- if(sensor_mode < SENSOR_MODE_CAMERA || SENSOR_MODE_MOVIE < sensor_mode)
- {
- LOGE("ERR(%s):Invalid sensor mode (%d)", __FUNCTION__, sensor_mode);
- return -1;
- }
-
- if(m_sensor_mode != sensor_mode)
- {
- m_sensor_mode = sensor_mode;
- }
-
- return 0;
-}
-
-/* Shot mode */
-/* SINGLE = 0
-* CONTINUOUS = 1
-* PANORAMA = 2
-* SMILE = 3
-* SELF = 6
+ LOGV("%s(sensor_mode (%d))", __func__, sensor_mode);
+
+ if (sensor_mode < SENSOR_MODE_CAMERA || SENSOR_MODE_MOVIE < sensor_mode) {
+ LOGE("ERR(%s):Invalid sensor mode (%d)", __func__, sensor_mode);
+ return -1;
+ }
+
+ if (m_sensor_mode != sensor_mode) {
+ m_sensor_mode = sensor_mode;
+ }
+
+ return 0;
+}
+
+/* Shot mode */
+/* SINGLE = 0
+* CONTINUOUS = 1
+* PANORAMA = 2
+* SMILE = 3
+* SELF = 6
*/
int SecCamera::setShotMode(int shot_mode)
{
- LOGV("%s(shot_mode (%d))", __FUNCTION__, shot_mode);
- if(shot_mode < SHOT_MODE_SINGLE || SHOT_MODE_SELF < shot_mode)
- {
- LOGE("ERR(%s):Invalid shot_mode (%d)", __FUNCTION__, shot_mode);
- return -1;
- }
- m_shot_mode = shot_mode;
+ LOGV("%s(shot_mode (%d))", __func__, shot_mode);
+ if (shot_mode < SHOT_MODE_SINGLE || SHOT_MODE_SELF < shot_mode) {
+ LOGE("ERR(%s):Invalid shot_mode (%d)", __func__, shot_mode);
+ return -1;
+ }
+ m_shot_mode = shot_mode;
- return 0;
+ return 0;
}
-int SecCamera::getVTmode(void)
+int SecCamera::getVTmode(void)
{
- return m_vtmode;
+ return m_vtmode;
}
int SecCamera::setBlur(int blur_level)
{
- LOGV("%s(level (%d))", __FUNCTION__, blur_level);
-
- if(blur_level < BLUR_LEVEL_0|| BLUR_LEVEL_MAX <= blur_level)
- {
- LOGE("ERR(%s):Invalid level (%d)", __FUNCTION__, blur_level);
- return -1;
- }
+ LOGV("%s(level (%d))", __func__, blur_level);
+
+ if (blur_level < BLUR_LEVEL_0 || BLUR_LEVEL_MAX <= blur_level) {
+ LOGE("ERR(%s):Invalid level (%d)", __func__, blur_level);
+ return -1;
+ }
- if(m_blur_level != blur_level)
- {
- m_blur_level = blur_level;
-
- if(m_flag_camera_start)
- {
- if (fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_CAMERA_VGA_BLUR, blur_level) < 0)
- {
- LOGE("ERR(%s):Fail on V4L2_CID_CAMERA_VGA_BLUR", __FUNCTION__);
- return -1;
- }
- }
- }
- return 0;
+ if (m_blur_level != blur_level) {
+ m_blur_level = blur_level;
+
+ if (m_flag_camera_start) {
+ if (fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_CAMERA_VGA_BLUR, blur_level) < 0) {
+ LOGE("ERR(%s):Fail on V4L2_CID_CAMERA_VGA_BLUR", __func__);
+ return -1;
+ }
+ }
+ }
+ return 0;
}
-int SecCamera::getBlur(void)
+int SecCamera::getBlur(void)
{
- return m_blur_level;
+ return m_blur_level;
}
-
int SecCamera::setDataLineCheck(int chk_dataline)
{
- LOGV("%s(chk_dataline (%d))", __FUNCTION__, chk_dataline);
-
- if(chk_dataline < CHK_DATALINE_OFF || CHK_DATALINE_MAX<= chk_dataline)
- {
- LOGE("ERR(%s):Invalid chk_dataline (%d)", __FUNCTION__, chk_dataline);
- return -1;
- }
-
- if(m_chk_dataline != chk_dataline)
- {
- m_chk_dataline = chk_dataline;
- }
+ LOGV("%s(chk_dataline (%d))", __func__, chk_dataline);
- return 0;
+ if (chk_dataline < CHK_DATALINE_OFF || CHK_DATALINE_MAX <= chk_dataline) {
+ LOGE("ERR(%s):Invalid chk_dataline (%d)", __func__, chk_dataline);
+ return -1;
+ }
+
+ if (m_chk_dataline != chk_dataline) {
+ m_chk_dataline = chk_dataline;
+ }
+
+ return 0;
}
-int SecCamera::getDataLineCheck(void)
+int SecCamera::getDataLineCheck(void)
{
- return m_chk_dataline;
+ return m_chk_dataline;
}
-int SecCamera::setDataLineCheckStop(void)
+int SecCamera::setDataLineCheckStop(void)
{
- LOGV("%s", __FUNCTION__);
-
- if(m_flag_camera_start)
- {
- if (fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_CAMERA_CHECK_DATALINE_STOP, 1) < 0)
- {
- LOGE("ERR(%s):Fail on V4L2_CID_CAMERA_CHECK_DATALINE_STOP", __FUNCTION__);
- return -1;
- }
- }
- return 0;
+ LOGV("%s", __func__);
+
+ if (m_flag_camera_start) {
+ if (fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_CAMERA_CHECK_DATALINE_STOP, 1) < 0) {
+ LOGE("ERR(%s):Fail on V4L2_CID_CAMERA_CHECK_DATALINE_STOP", __func__);
+ return -1;
+ }
+ }
+ return 0;
}
#endif
@@ -3382,215 +3197,204 @@ int SecCamera::setDataLineCheckStop(void)
// Jpeg
#ifndef JPEG_FROM_SENSOR
-unsigned char * SecCamera::getJpeg(unsigned char *snapshot_data, int snapshot_size, int * size)
+unsigned char* SecCamera::getJpeg(unsigned char *snapshot_data, int snapshot_size, int *size)
{
- LOGV("%s()", __FUNCTION__);
-
- if(m_cam_fd <= 0)
- {
- LOGE("ERR(%s):Camera was closed\n", __FUNCTION__);
- return NULL;
- }
+ LOGV("%s()", __func__);
+
+ if (m_cam_fd <= 0) {
+ LOGE("ERR(%s):Camera was closed\n", __func__);
+ return NULL;
+ }
+
+ unsigned char *jpeg_data = NULL;
+ int jpeg_size = 0;
- unsigned char * jpeg_data = NULL;
- int jpeg_size = 0;
+ jpeg_data = yuv2Jpeg(snapshot_data, snapshot_size, &jpeg_size,
+ m_snapshot_width, m_snapshot_height, m_snapshot_v4lformat);
- jpeg_data = yuv2Jpeg(snapshot_data, snapshot_size, &jpeg_size, m_snapshot_width, m_snapshot_height, m_snapshot_v4lformat);
-
- *size = jpeg_size;
- return jpeg_data;
+ *size = jpeg_size;
+ return jpeg_data;
}
#endif
#ifndef JPEG_FROM_SENSOR
-unsigned char * SecCamera::yuv2Jpeg(unsigned char * raw_data, int raw_size,int * jpeg_size,int width, int height, int pixel_format)
-{
- LOGV("%s:raw_data(%p), raw_size(%d), jpeg_size(%d), width(%d), height(%d), format(%d)",
- __FUNCTION__, raw_data, raw_size, *jpeg_size, width, height, pixel_format);
-
- if(m_jpeg_fd <= 0)
- {
- LOGE("ERR(%s):JPEG device was closed\n", __FUNCTION__);
- return NULL;
- }
- if(pixel_format == V4L2_PIX_FMT_RGB565)
- {
- LOGE("ERR(%s):It doesn't support V4L2_PIX_FMT_RGB565\n", __FUNCTION__);
- return NULL;
- }
-
- unsigned char * InBuf = NULL;
- unsigned char * OutBuf = NULL;
- unsigned char * jpeg_data = NULL;
- long frameSize;
- exif_file_info_t ExifInfo;
-
- int input_file_format = JPG_MODESEL_YCBCR;
-
- int out_file_format = JPG_422;
- switch(pixel_format)
- {
- case V4L2_PIX_FMT_NV12:
- case V4L2_PIX_FMT_NV21:
- case V4L2_PIX_FMT_NV12T:
- case V4L2_PIX_FMT_YUV420:
- out_file_format = JPG_420;
- break;
- case V4L2_PIX_FMT_YUYV:
- case V4L2_PIX_FMT_UYVY:
- case V4L2_PIX_FMT_YUV422P:
- out_file_format = JPG_422;
- break;
- }
-
- //////////////////////////////////////////////////////////////
- // 2. set encode config. //
- //////////////////////////////////////////////////////////////
- LOGV("Step 1 : JPEG_SET_ENCODE_IN_FORMAT(JPG_MODESEL_YCBCR)");
- if (SsbSipJPEGSetEncConfig(JPEG_SET_ENCODE_IN_FORMAT, input_file_format) != JPEG_OK) {
- LOGE("ERR(%s):Fail on JPEG_SET_ENCODE_IN_FORMAT\n", __FUNCTION__);
- goto YUV2JPEG_END;
- }
-
- LOGV("Step 2 : JPEG_SET_SAMPING_MODE(JPG_422)");
- if (SsbSipJPEGSetEncConfig(JPEG_SET_SAMPING_MODE, out_file_format) != JPEG_OK) {
- LOGE("ERR(%s):Fail on JPEG_SET_SAMPING_MODE\n", __FUNCTION__);
- goto YUV2JPEG_END;
- }
-
- LOGV("Step 3 : JPEG_SET_ENCODE_WIDTH(%d)", width);
- if (SsbSipJPEGSetEncConfig(JPEG_SET_ENCODE_WIDTH, width) != JPEG_OK) {
- LOGE("ERR(%s):Fail on JPEG_SET_ENCODE_WIDTH \n", __FUNCTION__);
- goto YUV2JPEG_END;
- }
-
- LOGV("Step 4 : JPEG_SET_ENCODE_HEIGHT(%d)", height);
- if (SsbSipJPEGSetEncConfig(JPEG_SET_ENCODE_HEIGHT, height) != JPEG_OK) {
- LOGE("ERR(%s):Fail on JPEG_SET_ENCODE_HEIGHT \n", __FUNCTION__);
- goto YUV2JPEG_END;
- }
-
- LOGV("Step 5 : JPEG_SET_ENCODE_QUALITY(JPG_QUALITY_LEVEL_2)");
- if (SsbSipJPEGSetEncConfig(JPEG_SET_ENCODE_QUALITY, JPG_QUALITY_LEVEL_2) != JPEG_OK) {
- LOGE("ERR(%s):Fail on JPEG_SET_ENCODE_QUALITY \n", __FUNCTION__);
- goto YUV2JPEG_END;
- }
+unsigned char* SecCamera::yuv2Jpeg(unsigned char *raw_data, int raw_size, int *jpeg_size,
+ int width, int height, int pixel_format)
+{
+ LOGV("%s:raw_data(%p), raw_size(%d), jpeg_size(%d), width(%d), height(%d), format(%d)",
+ __func__, raw_data, raw_size, *jpeg_size, width, height, pixel_format);
+
+ if (m_jpeg_fd <= 0) {
+ LOGE("ERR(%s):JPEG device was closed\n", __func__);
+ return NULL;
+ }
+ if (pixel_format == V4L2_PIX_FMT_RGB565) {
+ LOGE("ERR(%s):It doesn't support V4L2_PIX_FMT_RGB565\n", __func__);
+ return NULL;
+ }
+
+ unsigned char *InBuf = NULL;
+ unsigned char *OutBuf = NULL;
+ unsigned char *jpeg_data = NULL;
+ long frameSize;
+ exif_file_info_t ExifInfo;
+
+ int input_file_format = JPG_MODESEL_YCBCR;
+
+ int out_file_format = JPG_422;
+
+ switch (pixel_format) {
+ case V4L2_PIX_FMT_NV12:
+ case V4L2_PIX_FMT_NV21:
+ case V4L2_PIX_FMT_NV12T:
+ case V4L2_PIX_FMT_YUV420:
+ out_file_format = JPG_420;
+ break;
+ case V4L2_PIX_FMT_YUYV:
+ case V4L2_PIX_FMT_UYVY:
+ case V4L2_PIX_FMT_YUV422P:
+ out_file_format = JPG_422;
+ break;
+ }
+
+ //////////////////////////////////////////////////////////////
+ // 2. set encode config. //
+ //////////////////////////////////////////////////////////////
+ LOGV("Step 1 : JPEG_SET_ENCODE_IN_FORMAT(JPG_MODESEL_YCBCR)");
+ if (SsbSipJPEGSetEncConfig(JPEG_SET_ENCODE_IN_FORMAT, input_file_format) != JPEG_OK) {
+ LOGE("ERR(%s):Fail on JPEG_SET_ENCODE_IN_FORMAT\n", __func__);
+ goto YUV2JPEG_END;
+ }
+
+ LOGV("Step 2 : JPEG_SET_SAMPING_MODE(JPG_422)");
+ if (SsbSipJPEGSetEncConfig(JPEG_SET_SAMPING_MODE, out_file_format) != JPEG_OK) {
+ LOGE("ERR(%s):Fail on JPEG_SET_SAMPING_MODE\n", __func__);
+ goto YUV2JPEG_END;
+ }
+
+ LOGV("Step 3 : JPEG_SET_ENCODE_WIDTH(%d)", width);
+ if (SsbSipJPEGSetEncConfig(JPEG_SET_ENCODE_WIDTH, width) != JPEG_OK) {
+ LOGE("ERR(%s):Fail on JPEG_SET_ENCODE_WIDTH \n", __func__);
+ goto YUV2JPEG_END;
+ }
+
+ LOGV("Step 4 : JPEG_SET_ENCODE_HEIGHT(%d)", height);
+ if (SsbSipJPEGSetEncConfig(JPEG_SET_ENCODE_HEIGHT, height) != JPEG_OK) {
+ LOGE("ERR(%s):Fail on JPEG_SET_ENCODE_HEIGHT \n", __func__);
+ goto YUV2JPEG_END;
+ }
+
+ LOGV("Step 5 : JPEG_SET_ENCODE_QUALITY(JPG_QUALITY_LEVEL_2)");
+ if (SsbSipJPEGSetEncConfig(JPEG_SET_ENCODE_QUALITY, JPG_QUALITY_LEVEL_2) != JPEG_OK) {
+ LOGE("ERR(%s):Fail on JPEG_SET_ENCODE_QUALITY \n", __func__);
+ goto YUV2JPEG_END;
+ }
#if (INCLUDE_JPEG_THUMBNAIL == 1)
- LOGV("Step 6a : JPEG_SET_ENCODE_THUMBNAIL(TRUE)");
- if (SsbSipJPEGSetEncConfig(JPEG_SET_ENCODE_THUMBNAIL, TRUE) != JPEG_OK) {
- LOGE("ERR(%s):Fail on JPEG_SET_ENCODE_THUMBNAIL \n", __FUNCTION__);
- goto YUV2JPEG_END;
- }
+ LOGV("Step 6a : JPEG_SET_ENCODE_THUMBNAIL(TRUE)");
+ if (SsbSipJPEGSetEncConfig(JPEG_SET_ENCODE_THUMBNAIL, TRUE) != JPEG_OK) {
+ LOGE("ERR(%s):Fail on JPEG_SET_ENCODE_THUMBNAIL \n", __func__);
+ goto YUV2JPEG_END;
+ }
- LOGV("Step 6b : JPEG_SET_THUMBNAIL_WIDTH(%d)", m_jpeg_thumbnail_width);
- if (SsbSipJPEGSetEncConfig(JPEG_SET_THUMBNAIL_WIDTH, m_jpeg_thumbnail_width) != JPEG_OK) {
- LOGE("ERR(%s):Fail on JPEG_SET_THUMBNAIL_WIDTH(%d) \n", __FUNCTION__, m_jpeg_thumbnail_height);
- goto YUV2JPEG_END;
- }
+ LOGV("Step 6b : JPEG_SET_THUMBNAIL_WIDTH(%d)", m_jpeg_thumbnail_width);
+ if (SsbSipJPEGSetEncConfig(JPEG_SET_THUMBNAIL_WIDTH, m_jpeg_thumbnail_width) != JPEG_OK) {
+ LOGE("ERR(%s):Fail on JPEG_SET_THUMBNAIL_WIDTH(%d) \n", __func__, m_jpeg_thumbnail_height);
+ goto YUV2JPEG_END;
+ }
- LOGV("Step 6c : JPEG_SET_THUMBNAIL_HEIGHT(%d)", m_jpeg_thumbnail_height);
- if (SsbSipJPEGSetEncConfig(JPEG_SET_THUMBNAIL_HEIGHT, m_jpeg_thumbnail_height) != JPEG_OK) {
- LOGE("ERR(%s):Fail on JPEG_SET_THUMBNAIL_HEIGHT(%d) \n", __FUNCTION__, m_jpeg_thumbnail_height);
- goto YUV2JPEG_END;
- }
+ LOGV("Step 6c : JPEG_SET_THUMBNAIL_HEIGHT(%d)", m_jpeg_thumbnail_height);
+ if (SsbSipJPEGSetEncConfig(JPEG_SET_THUMBNAIL_HEIGHT, m_jpeg_thumbnail_height) != JPEG_OK) {
+ LOGE("ERR(%s):Fail on JPEG_SET_THUMBNAIL_HEIGHT(%d) \n", __func__, m_jpeg_thumbnail_height);
+ goto YUV2JPEG_END;
+ }
#endif
- if(raw_size == 0) //Kamat: This is our code path
- {
- unsigned int addr_y;
- int width, height,frame_size;
- getSnapshotSize(&width, &height, &frame_size);
- if(raw_data == NULL)
- {
- LOGE("%s %d] Raw data is NULL \n",__func__,__LINE__);
- goto YUV2JPEG_END;
- }
- else //Kamat: our path
- {
- addr_y = (unsigned int)raw_data;
- }
-
- SsbSipJPEGSetEncodeInBuf(m_jpeg_fd, addr_y, frame_size);
- }
- else
- {
- //////////////////////////////////////////////////////////////
- // 4. get Input buffer address //
- //////////////////////////////////////////////////////////////
- LOGV("Step 7 : Input buffer size(0x%X", raw_size);
- InBuf = (unsigned char *)SsbSipJPEGGetEncodeInBuf(m_jpeg_fd, raw_size);
- if(InBuf == NULL)
- {
- LOGE("ERR(%s):Fail on SsbSipJPEGGetEncodeInBuf \n", __FUNCTION__);
- goto YUV2JPEG_END;
- }
- //////////////////////////////////////////////////////////////
- // 5. put YUV stream to Input buffer
- //////////////////////////////////////////////////////////////
- LOGV("Step 8: memcpy(InBuf(%p), raw_data(%p), raw_size(%d)", InBuf, raw_data, raw_size);
- memcpy(InBuf, raw_data, raw_size);
- }
-
- //////////////////////////////////////////////////////////////
- // 6. Make Exif info parameters
- //////////////////////////////////////////////////////////////
- LOGV("Step 9: m_makeExifParam()");
- memset(&ExifInfo, 0x00, sizeof(exif_file_info_t));
- m_makeExifParam(&ExifInfo);
-
- //////////////////////////////////////////////////////////////
- // 7. Encode YUV stream
- //////////////////////////////////////////////////////////////
- LOGV("Step a: SsbSipJPEGEncodeExe()");
- if(SsbSipJPEGEncodeExe(m_jpeg_fd, &ExifInfo, JPEG_USE_SW_SCALER) != JPEG_OK) //with Exif
- {
- LOGE("ERR(%s):Fail on SsbSipJPEGEncodeExe \n", __FUNCTION__);
- goto YUV2JPEG_END;
- }
- //////////////////////////////////////////////////////////////
- // 8. get output buffer address
- //////////////////////////////////////////////////////////////
- LOGV("Step b: SsbSipJPEGGetEncodeOutBuf()");
- OutBuf = (unsigned char *)SsbSipJPEGGetEncodeOutBuf(m_jpeg_fd, &frameSize);
- if(OutBuf == NULL)
- {
- LOGE("ERR(%s):Fail on SsbSipJPEGGetEncodeOutBuf \n", __FUNCTION__);
- goto YUV2JPEG_END;
- }
- //////////////////////////////////////////////////////////////
- // 9. write JPEG result file
- //////////////////////////////////////////////////////////////
- LOGV("Done");
- jpeg_data = OutBuf;
- *jpeg_size = (int)frameSize;
-
-YUV2JPEG_END :
-
- return jpeg_data;
+ if (raw_size == 0) { //Kamat: This is our code path
+ unsigned int addr_y;
+ int width, height,frame_size;
+ getSnapshotSize(&width, &height, &frame_size);
+ if (raw_data == NULL) {
+ LOGE("%s %d] Raw data is NULL \n", __func__, __LINE__);
+ goto YUV2JPEG_END;
+ } else { //Kamat: our path
+ addr_y = (unsigned int)raw_data;
+ }
+
+ SsbSipJPEGSetEncodeInBuf(m_jpeg_fd, addr_y, frame_size);
+ } else {
+ //////////////////////////////////////////////////////////////
+ // 4. get Input buffer address //
+ //////////////////////////////////////////////////////////////
+ LOGV("Step 7 : Input buffer size(0x%X", raw_size);
+ InBuf = (unsigned char *)SsbSipJPEGGetEncodeInBuf(m_jpeg_fd, raw_size);
+ if (InBuf == NULL) {
+ LOGE("ERR(%s):Fail on SsbSipJPEGGetEncodeInBuf \n", __func__);
+ goto YUV2JPEG_END;
+ }
+ //////////////////////////////////////////////////////////////
+ // 5. put YUV stream to Input buffer
+ //////////////////////////////////////////////////////////////
+ LOGV("Step 8: memcpy(InBuf(%p), raw_data(%p), raw_size(%d)", InBuf, raw_data, raw_size);
+ memcpy(InBuf, raw_data, raw_size);
+ }
+
+ //////////////////////////////////////////////////////////////
+ // 6. Make Exif info parameters
+ //////////////////////////////////////////////////////////////
+ LOGV("Step 9: m_makeExifParam()");
+ memset(&ExifInfo, 0x00, sizeof(exif_file_info_t));
+ m_makeExifParam(&ExifInfo);
+
+ //////////////////////////////////////////////////////////////
+ // 7. Encode YUV stream
+ //////////////////////////////////////////////////////////////
+ LOGV("Step a: SsbSipJPEGEncodeExe()");
+ if (SsbSipJPEGEncodeExe(m_jpeg_fd, &ExifInfo, JPEG_USE_SW_SCALER) != JPEG_OK) { //with Exif
+ LOGE("ERR(%s):Fail on SsbSipJPEGEncodeExe \n", __func__);
+ goto YUV2JPEG_END;
+ }
+ //////////////////////////////////////////////////////////////
+ // 8. get output buffer address
+ //////////////////////////////////////////////////////////////
+ LOGV("Step b: SsbSipJPEGGetEncodeOutBuf()");
+ OutBuf = (unsigned char *)SsbSipJPEGGetEncodeOutBuf(m_jpeg_fd, &frameSize);
+ if (OutBuf == NULL) {
+ LOGE("ERR(%s):Fail on SsbSipJPEGGetEncodeOutBuf \n", __func__);
+ goto YUV2JPEG_END;
+ }
+ //////////////////////////////////////////////////////////////
+ // 9. write JPEG result file
+ //////////////////////////////////////////////////////////////
+ LOGV("Done");
+ jpeg_data = OutBuf;
+ *jpeg_size = (int)frameSize;
+
+YUV2JPEG_END:
+ return jpeg_data;
}
#endif
int SecCamera::setJpegThumbnailSize(int width, int height)
{
- LOGV("%s(width(%d), height(%d))", __FUNCTION__, width, height);
-
- m_jpeg_thumbnail_width = width;
- m_jpeg_thumbnail_height = height;
+ LOGV("%s(width(%d), height(%d))", __func__, width, height);
+
+ m_jpeg_thumbnail_width = width;
+ m_jpeg_thumbnail_height = height;
- return 0;
+ return 0;
}
-int SecCamera::getJpegThumbnailSize(int * width, int * height)
+int SecCamera::getJpegThumbnailSize(int *width, int *height)
{
- if(width)
- *width = m_jpeg_thumbnail_width;
- if(height)
- *height = m_jpeg_thumbnail_height;
-
- return 0;
+ if (width)
+ *width = m_jpeg_thumbnail_width;
+ if (height)
+ *height = m_jpeg_thumbnail_height;
+
+ return 0;
}
void SecCamera::setExifFixedAttribute()
@@ -3599,7 +3403,7 @@ void SecCamera::setExifFixedAttribute()
}
void SecCamera::setExifChangedAttribute()
-{
+{
}
@@ -3608,37 +3412,37 @@ void SecCamera::setExifChangedAttribute()
inline int SecCamera::m_frameSize(int format, int width, int height)
{
- int size = 0;
-
- switch(format)
- {
- case V4L2_PIX_FMT_YUV420 :
- case V4L2_PIX_FMT_NV12 :
- case V4L2_PIX_FMT_NV21 :
- size = (width * height * 3 / 2);
- break;
-
- case V4L2_PIX_FMT_NV12T:
- size = ALIGN_TO_8KB(ALIGN_TO_128B(width) * ALIGN_TO_32B(height)) + ALIGN_TO_8KB(ALIGN_TO_128B(width) * ALIGN_TO_32B(height/2));
- break;
-
- case V4L2_PIX_FMT_YUV422P :
- case V4L2_PIX_FMT_YUYV :
- case V4L2_PIX_FMT_UYVY :
- size = (width * height * 2);
- break;
-
- default :
- LOGE("ERR(%s):Invalid V4L2 pixel format(%d)\n", __FUNCTION__, format);
- case V4L2_PIX_FMT_RGB565 :
- size = (width * height * BPP);
- break;
- }
-
- return size;
-}
-
-status_t SecCamera::dump(int fd, const Vector<String16>& args)
+ int size = 0;
+
+ switch (format) {
+ case V4L2_PIX_FMT_YUV420:
+ case V4L2_PIX_FMT_NV12:
+ case V4L2_PIX_FMT_NV21:
+ size = (width * height * 3 / 2);
+ break;
+
+ case V4L2_PIX_FMT_NV12T:
+ size = ALIGN_TO_8KB(ALIGN_TO_128B(width) * ALIGN_TO_32B(height)) +
+ ALIGN_TO_8KB(ALIGN_TO_128B(width) * ALIGN_TO_32B(height / 2));
+ break;
+
+ case V4L2_PIX_FMT_YUV422P:
+ case V4L2_PIX_FMT_YUYV:
+ case V4L2_PIX_FMT_UYVY:
+ size = (width * height * 2);
+ break;
+
+ default :
+ LOGE("ERR(%s):Invalid V4L2 pixel format(%d)\n", __func__, format);
+ case V4L2_PIX_FMT_RGB565:
+ size = (width * height * BPP);
+ break;
+ }
+
+ return size;
+}
+
+status_t SecCamera::dump(int fd, const Vector<String16> &args)
{
const size_t SIZE = 256;
char buffer[SIZE];
diff --git a/libcamera/SecCamera.h b/libcamera/SecCamera.h
index c176092..a4950ae 100755..100644
--- a/libcamera/SecCamera.h
+++ b/libcamera/SecCamera.h
@@ -2,16 +2,16 @@
**
** Copyright 2008, The Android Open Source Project
**
-** Licensed under the Apache License, Version 2.0 (the "License");
-** you may not use this file except in compliance with the License.
-** You may obtain a copy of the License at
+** Licensed under the Apache License, Version 2.0 (the "License");
+** you may not use this file except in compliance with the License.
+** You may obtain a copy of the License at
**
-** http://www.apache.org/licenses/LICENSE-2.0
+** http://www.apache.org/licenses/LICENSE-2.0
**
-** Unless required by applicable law or agreed to in writing, software
-** distributed under the License is distributed on an "AS IS" BASIS,
-** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-** See the License for the specific language governing permissions and
+** Unless required by applicable law or agreed to in writing, software
+** distributed under the License is distributed on an "AS IS" BASIS,
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+** See the License for the specific language governing permissions and
** limitations under the License.
*/
@@ -44,10 +44,10 @@
#include <camera/CameraHardwareInterface.h>
namespace android {
-
-#define PREVIEW_USING_MMAP //Define this if the preview data is to be shared using memory mapped technique instead of passing physical address.
-
-#define JPEG_FROM_SENSOR //Define this if the JPEG images are obtained directly from camera sensor. Else on chip JPEG encoder will be used.
+//Define this if the preview data is to be shared using memory mapped technique instead of passing physical address.
+#define PREVIEW_USING_MMAP
+//Define this if the JPEG images are obtained directly from camera sensor. Else on chip JPEG encoder will be used.
+#define JPEG_FROM_SENSOR
//#define DUAL_PORT_RECORDING //Define this if 2 fimc ports are needed for recording.
@@ -68,16 +68,16 @@ namespace android {
#define LOG_CAMERA_PREVIEW LOGD
#define LOG_TIME_DEFINE(n) \
- struct timeval time_start_##n, time_stop_##n; unsigned long log_time_##n = 0;
+ struct timeval time_start_##n, time_stop_##n; unsigned long log_time_##n = 0;
#define LOG_TIME_START(n) \
- gettimeofday(&time_start_##n, NULL);
+ gettimeofday(&time_start_##n, NULL);
#define LOG_TIME_END(n) \
- gettimeofday(&time_stop_##n, NULL); log_time_##n = measure_time(&time_start_##n, &time_stop_##n);
+ gettimeofday(&time_stop_##n, NULL); log_time_##n = measure_time(&time_start_##n, &time_stop_##n);
#define LOG_TIME(n) \
- log_time_##n
+ log_time_##n
#else
#define LOG_CAMERA(...)
@@ -88,8 +88,8 @@ namespace android {
#define LOG_TIME(n)
#endif
-#define LCD_WIDTH 480
-#define LCD_HEIGHT 800
+#define LCD_WIDTH 480
+#define LCD_HEIGHT 800
#define JOIN(x, y) JOIN_AGAIN(x, y)
#define JOIN_AGAIN(x, y) x ## y
@@ -101,39 +101,39 @@ namespace android {
#error "Please define the Camera module"
#endif
-#define ISX006_PREVIEW_WIDTH 640
-#define ISX006_PREVIEW_HEIGHT 480
-#define ISX006_SNAPSHOT_WIDTH 2560
-#define ISX006_SNAPSHOT_HEIGHT 1920
+#define ISX006_PREVIEW_WIDTH 640
+#define ISX006_PREVIEW_HEIGHT 480
+#define ISX006_SNAPSHOT_WIDTH 2560
+#define ISX006_SNAPSHOT_HEIGHT 1920
-#define ISX006_POSTVIEW_WIDTH 640
-#define ISX006_POSTVIEW_WIDE_WIDTH 800
-#define ISX006_POSTVIEW_HEIGHT 480
-#define ISX006_POSTVIEW_BPP 16
+#define ISX006_POSTVIEW_WIDTH 640
+#define ISX006_POSTVIEW_WIDE_WIDTH 800
+#define ISX006_POSTVIEW_HEIGHT 480
+#define ISX006_POSTVIEW_BPP 16
-#define VGA_PREVIEW_WIDTH 640
-#define VGA_PREVIEW_HEIGHT 480
-#define VGA_SNAPSHOT_WIDTH 640
-#define VGA_SNAPSHOT_HEIGHT 480
+#define VGA_PREVIEW_WIDTH 640
+#define VGA_PREVIEW_HEIGHT 480
+#define VGA_SNAPSHOT_WIDTH 640
+#define VGA_SNAPSHOT_HEIGHT 480
-#define MAX_BACK_CAMERA_PREVIEW_WIDTH JOIN(BACK_CAM,_PREVIEW_WIDTH)
-#define MAX_BACK_CAMERA_PREVIEW_HEIGHT JOIN(BACK_CAM,_PREVIEW_HEIGHT)
-#define MAX_BACK_CAMERA_SNAPSHOT_WIDTH JOIN(BACK_CAM,_SNAPSHOT_WIDTH)
-#define MAX_BACK_CAMERA_SNAPSHOT_HEIGHT JOIN(BACK_CAM,_SNAPSHOT_HEIGHT)
-#define BACK_CAMERA_POSTVIEW_WIDTH JOIN(BACK_CAM,_POSTVIEW_WIDTH)
-#define BACK_CAMERA_POSTVIEW_WIDE_WIDTH JOIN(BACK_CAM,_POSTVIEW_WIDE_WIDTH)
-#define BACK_CAMERA_POSTVIEW_HEIGHT JOIN(BACK_CAM,_POSTVIEW_HEIGHT)
-#define BACK_CAMERA_POSTVIEW_BPP JOIN(BACK_CAM,_POSTVIEW_BPP)
+#define MAX_BACK_CAMERA_PREVIEW_WIDTH JOIN(BACK_CAM,_PREVIEW_WIDTH)
+#define MAX_BACK_CAMERA_PREVIEW_HEIGHT JOIN(BACK_CAM,_PREVIEW_HEIGHT)
+#define MAX_BACK_CAMERA_SNAPSHOT_WIDTH JOIN(BACK_CAM,_SNAPSHOT_WIDTH)
+#define MAX_BACK_CAMERA_SNAPSHOT_HEIGHT JOIN(BACK_CAM,_SNAPSHOT_HEIGHT)
+#define BACK_CAMERA_POSTVIEW_WIDTH JOIN(BACK_CAM,_POSTVIEW_WIDTH)
+#define BACK_CAMERA_POSTVIEW_WIDE_WIDTH JOIN(BACK_CAM,_POSTVIEW_WIDE_WIDTH)
+#define BACK_CAMERA_POSTVIEW_HEIGHT JOIN(BACK_CAM,_POSTVIEW_HEIGHT)
+#define BACK_CAMERA_POSTVIEW_BPP JOIN(BACK_CAM,_POSTVIEW_BPP)
-#define MAX_FRONT_CAMERA_PREVIEW_WIDTH JOIN(FRONT_CAM,_PREVIEW_WIDTH)
-#define MAX_FRONT_CAMERA_PREVIEW_HEIGHT JOIN(FRONT_CAM,_PREVIEW_HEIGHT)
-#define MAX_FRONT_CAMERA_SNAPSHOT_WIDTH JOIN(FRONT_CAM,_SNAPSHOT_WIDTH)
-#define MAX_FRONT_CAMERA_SNAPSHOT_HEIGHT JOIN(FRONT_CAM,_SNAPSHOT_HEIGHT)
+#define MAX_FRONT_CAMERA_PREVIEW_WIDTH JOIN(FRONT_CAM,_PREVIEW_WIDTH)
+#define MAX_FRONT_CAMERA_PREVIEW_HEIGHT JOIN(FRONT_CAM,_PREVIEW_HEIGHT)
+#define MAX_FRONT_CAMERA_SNAPSHOT_WIDTH JOIN(FRONT_CAM,_SNAPSHOT_WIDTH)
+#define MAX_FRONT_CAMERA_SNAPSHOT_HEIGHT JOIN(FRONT_CAM,_SNAPSHOT_HEIGHT)
-#define DEFAULT_JPEG_THUMBNAIL_WIDTH 256
-#define DEFAULT_JPEG_THUMBNAIL_HEIGHT 192
+#define DEFAULT_JPEG_THUMBNAIL_WIDTH 256
+#define DEFAULT_JPEG_THUMBNAIL_HEIGHT 192
-#define CAMERA_DEV_NAME "/dev/video0"
+#define CAMERA_DEV_NAME "/dev/video0"
#ifdef DUAL_PORT_RECORDING
#define CAMERA_DEV_NAME2 "/dev/video2"
@@ -142,451 +142,416 @@ namespace android {
#define CAMERA_DEV_NAME2_TEMP "/data/videotemp_002"
-#define BPP 2
-#define MIN(x, y) ((x < y) ? x : y)
-#define MAX_BUFFERS 8
+#define BPP 2
+#define MIN(x, y) (((x) < (y)) ? (x) : (y))
+#define MAX_BUFFERS 8
/*
* V 4 L 2 F I M C E X T E N S I O N S
*
-*/
-#define V4L2_CID_ROTATION (V4L2_CID_PRIVATE_BASE + 0)
-#define V4L2_CID_PADDR_Y (V4L2_CID_PRIVATE_BASE + 1)
-#define V4L2_CID_PADDR_CB (V4L2_CID_PRIVATE_BASE + 2)
-#define V4L2_CID_PADDR_CR (V4L2_CID_PRIVATE_BASE + 3)
-#define V4L2_CID_PADDR_CBCR (V4L2_CID_PRIVATE_BASE + 4)
-#define V4L2_CID_STREAM_PAUSE (V4L2_CID_PRIVATE_BASE + 53)
-
-#define V4L2_CID_CAM_JPEG_MAIN_SIZE (V4L2_CID_PRIVATE_BASE + 32)
-#define V4L2_CID_CAM_JPEG_MAIN_OFFSET (V4L2_CID_PRIVATE_BASE + 33)
-#define V4L2_CID_CAM_JPEG_THUMB_SIZE (V4L2_CID_PRIVATE_BASE + 34)
-#define V4L2_CID_CAM_JPEG_THUMB_OFFSET (V4L2_CID_PRIVATE_BASE + 35)
-#define V4L2_CID_CAM_JPEG_POSTVIEW_OFFSET (V4L2_CID_PRIVATE_BASE + 36)
-#define V4L2_CID_CAM_JPEG_QUALITY (V4L2_CID_PRIVATE_BASE + 37)
-
-#define TPATTERN_COLORBAR 1
-#define TPATTERN_HORIZONTAL 2
-#define TPATTERN_VERTICAL 3
-
-#define V4L2_PIX_FMT_YVYU v4l2_fourcc('Y', 'V', 'Y', 'U')
+ */
+#define V4L2_CID_ROTATION (V4L2_CID_PRIVATE_BASE + 0)
+#define V4L2_CID_PADDR_Y (V4L2_CID_PRIVATE_BASE + 1)
+#define V4L2_CID_PADDR_CB (V4L2_CID_PRIVATE_BASE + 2)
+#define V4L2_CID_PADDR_CR (V4L2_CID_PRIVATE_BASE + 3)
+#define V4L2_CID_PADDR_CBCR (V4L2_CID_PRIVATE_BASE + 4)
+#define V4L2_CID_STREAM_PAUSE (V4L2_CID_PRIVATE_BASE + 53)
+
+#define V4L2_CID_CAM_JPEG_MAIN_SIZE (V4L2_CID_PRIVATE_BASE + 32)
+#define V4L2_CID_CAM_JPEG_MAIN_OFFSET (V4L2_CID_PRIVATE_BASE + 33)
+#define V4L2_CID_CAM_JPEG_THUMB_SIZE (V4L2_CID_PRIVATE_BASE + 34)
+#define V4L2_CID_CAM_JPEG_THUMB_OFFSET (V4L2_CID_PRIVATE_BASE + 35)
+#define V4L2_CID_CAM_JPEG_POSTVIEW_OFFSET (V4L2_CID_PRIVATE_BASE + 36)
+#define V4L2_CID_CAM_JPEG_QUALITY (V4L2_CID_PRIVATE_BASE + 37)
+
+#define TPATTERN_COLORBAR 1
+#define TPATTERN_HORIZONTAL 2
+#define TPATTERN_VERTICAL 3
+
+#define V4L2_PIX_FMT_YVYU v4l2_fourcc('Y', 'V', 'Y', 'U')
/* FOURCC for FIMC specific */
-#define V4L2_PIX_FMT_VYUY v4l2_fourcc('V', 'Y', 'U', 'Y')
-#define V4L2_PIX_FMT_NV16 v4l2_fourcc('N', 'V', '1', '6')
-#define V4L2_PIX_FMT_NV61 v4l2_fourcc('N', 'V', '6', '1')
-#define V4L2_PIX_FMT_NV12T v4l2_fourcc('T', 'V', '1', '2')
+#define V4L2_PIX_FMT_VYUY v4l2_fourcc('V', 'Y', 'U', 'Y')
+#define V4L2_PIX_FMT_NV16 v4l2_fourcc('N', 'V', '1', '6')
+#define V4L2_PIX_FMT_NV61 v4l2_fourcc('N', 'V', '6', '1')
+#define V4L2_PIX_FMT_NV12T v4l2_fourcc('T', 'V', '1', '2')
/*
- * U S E R D E F I N E D T Y P E S
+ * U S E R D E F I N E D T Y P E S
*
-*/
+ */
struct fimc_buffer {
- void *start;
- size_t length;
+ void *start;
+ size_t length;
};
struct yuv_fmt_list {
- const char *name;
- const char *desc;
- unsigned int fmt;
- int depth;
- int planes;
+ const char *name;
+ const char *desc;
+ unsigned int fmt;
+ int depth;
+ int planes;
};
//s1 [Apply factory standard]
struct camsensor_date_info {
- unsigned int year;
- unsigned int month;
- unsigned int date;
+ unsigned int year;
+ unsigned int month;
+ unsigned int date;
};
class SecCamera {
public:
- enum CAMERA_ID
- {
- CAMERA_ID_BACK = 0,
- CAMERA_ID_FRONT = 1,
- };
-
- enum AUTO_FOCUS
- {
- AUTO_FOCUS_OFF,
- AUTO_FOCUS_ON,
- AUTO_FOCUS_STATUS,
- };
-
- enum WHILTE_BALANCE
- {
+ enum CAMERA_ID {
+ CAMERA_ID_BACK = 0,
+ CAMERA_ID_FRONT = 1,
+ };
+
+ enum AUTO_FOCUS {
+ AUTO_FOCUS_OFF,
+ AUTO_FOCUS_ON,
+ AUTO_FOCUS_STATUS,
+ };
+
+ enum WHILTE_BALANCE {
#ifdef SWP1_CAMERA_ADD_ADVANCED_FUNCTION
- WHITE_BALANCE_BASE,
- WHITE_BALANCE_AUTO,
- WHITE_BALANCE_DAYLIGHT,
- WHITE_BALANCE_CLOUDY,
- WHITE_BALANCE_INCANDESCENT,
- WHITE_BALANCE_FLUORESCENT,
- WHITE_BALANCE_MAX,
+ WHITE_BALANCE_BASE,
+ WHITE_BALANCE_AUTO,
+ WHITE_BALANCE_DAYLIGHT,
+ WHITE_BALANCE_CLOUDY,
+ WHITE_BALANCE_INCANDESCENT,
+ WHITE_BALANCE_FLUORESCENT,
+ WHITE_BALANCE_MAX,
#else
- WHITE_BALANCE_AUTO,
- WHITE_BALANCE_INDOOR3100,
- WHITE_BALANCE_OUTDOOR5100,
- WHITE_BALANCE_INDOOR2000,
- WHITE_BALANCE_HALT,
- WHITE_BALANCE_CLOUDY,
- WHITE_BALANCE_SUNNY,
+ WHITE_BALANCE_AUTO,
+ WHITE_BALANCE_INDOOR3100,
+ WHITE_BALANCE_OUTDOOR5100,
+ WHITE_BALANCE_INDOOR2000,
+ WHITE_BALANCE_HALT,
+ WHITE_BALANCE_CLOUDY,
+ WHITE_BALANCE_SUNNY,
#endif
- };
-
- enum BRIGHTNESS
- {
- BRIGHTNESS_MINUS_4= 0,
- BRIGHTNESS_MINUS_3,
- BRIGHTNESS_MINUS_2,
- BRIGHTNESS_MINUS_1,
- BRIGHTNESS_NORMAL,
- BRIGHTNESS_PLUS_1,
- BRIGHTNESS_PLUS_2,
- BRIGHTNESS_PLUS_3,
- BRIGHTNESS_PLUS_4,
- };
-
- enum IMAGE_EFFECT
- {
+ };
+
+ enum BRIGHTNESS {
+ BRIGHTNESS_MINUS_4= 0,
+ BRIGHTNESS_MINUS_3,
+ BRIGHTNESS_MINUS_2,
+ BRIGHTNESS_MINUS_1,
+ BRIGHTNESS_NORMAL,
+ BRIGHTNESS_PLUS_1,
+ BRIGHTNESS_PLUS_2,
+ BRIGHTNESS_PLUS_3,
+ BRIGHTNESS_PLUS_4,
+ };
+
+ enum IMAGE_EFFECT {
#ifdef SWP1_CAMERA_ADD_ADVANCED_FUNCTION
- IMAGE_EFFECT_BASE,
- IMAGE_EFFECT_NONE,
- IMAGE_EFFECT_BNW,
- IMAGE_EFFECT_SEPIA,
- IMAGE_EFFECT_AQUA,
- IMAGE_EFFECT_ANTIQUE,
- IMAGE_EFFECT_NEGATIVE,
- IMAGE_EFFECT_SHARPEN,
- IMAGE_EFFECT_MAX,
+ IMAGE_EFFECT_BASE,
+ IMAGE_EFFECT_NONE,
+ IMAGE_EFFECT_BNW,
+ IMAGE_EFFECT_SEPIA,
+ IMAGE_EFFECT_AQUA,
+ IMAGE_EFFECT_ANTIQUE,
+ IMAGE_EFFECT_NEGATIVE,
+ IMAGE_EFFECT_SHARPEN,
+ IMAGE_EFFECT_MAX,
#else
- IMAGE_EFFECT_ORIGINAL,
- IMAGE_EFFECT_ARBITRARY,
- IMAGE_EFFECT_NEGATIVE,
- IMAGE_EFFECT_FREEZE,
- IMAGE_EFFECT_EMBOSSING,
- IMAGE_EFFECT_SILHOUETTE,
+ IMAGE_EFFECT_ORIGINAL,
+ IMAGE_EFFECT_ARBITRARY,
+ IMAGE_EFFECT_NEGATIVE,
+ IMAGE_EFFECT_FREEZE,
+ IMAGE_EFFECT_EMBOSSING,
+ IMAGE_EFFECT_SILHOUETTE,
#endif
- };
+ };
#ifdef SWP1_CAMERA_ADD_ADVANCED_FUNCTION
- enum SCENE_MODE
- {
- SCENE_MODE_BASE,
- SCENE_MODE_NONE,
- SCENE_MODE_PORTRAIT,
- SCENE_MODE_NIGHTSHOT,
- SCENE_MODE_BACK_LIGHT,
- SCENE_MODE_LANDSCAPE,
- SCENE_MODE_SPORTS,
- SCENE_MODE_PARTY_INDOOR,
- SCENE_MODE_BEACH_SNOW,
- SCENE_MODE_SUNSET,
- SCENE_MODE_DUSK_DAWN,
- SCENE_MODE_FALL_COLOR,
- SCENE_MODE_FIREWORKS,
- SCENE_MODE_TEXT,
- SCENE_MODE_CANDLE_LIGHT,
- SCENE_MODE_MAX,
- };
-
- enum FLASH_MODE
- {
- FLASH_MODE_BASE,
- FLASH_MODE_OFF,
- FLASH_MODE_AUTO,
- FLASH_MODE_ON,
- FLASH_MODE_TORCH,
- FLASH_MODE_MAX,
- };
-
- enum ISO
- {
- ISO_AUTO,
- ISO_50,
- ISO_100,
- ISO_200,
- ISO_400,
- ISO_800,
- ISO_1600,
- ISO_SPORTS,
- ISO_NIGHT,
- ISO_MOVIE,
- ISO_MAX,
- };
-
- enum METERING
- {
- METERING_BASE = 0,
- METERING_MATRIX,
- METERING_CENTER,
- METERING_SPOT,
- METERING_MAX,
- };
-
- enum CONTRAST
- {
- CONTRAST_MINUS_2 = 0,
- CONTRAST_MINUS_1,
- CONTRAST_NORMAL,
- CONTRAST_PLUS_1,
- CONTRAST_PLUS_2,
- CONTRAST_MAX,
- };
-
- enum SATURATION
- {
- SATURATION_MINUS_2= 0,
- SATURATION_MINUS_1,
- SATURATION_NORMAL,
- SATURATION_PLUS_1,
- SATURATION_PLUS_2,
- SATURATION_MAX,
- };
-
- enum SHARPNESS
- {
- SHARPNESS_MINUS_2 = 0,
- SHARPNESS_MINUS_1,
- SHARPNESS_NORMAL,
- SHARPNESS_PLUS_1,
- SHARPNESS_PLUS_2,
- SHARPNESS_MAX,
- };
-
- enum WDR
- {
- WDR_OFF,
- WDR_ON,
- WDR_MAX,
- };
-
- enum ANTI_SHAKE
- {
- ANTI_SHAKE_OFF,
- ANTI_SHAKE_ON,
- ANTI_SHAKE_MAX,
- };
-
- enum JPEG_QUALITY
- {
- JPEG_QUALITY_ECONOMY = 0,
- JPEG_QUALITY_NORMAL = 50,
- JPEG_QUALITY_SUPERFINE = 100,
- JPEG_QUALITY_MAX,
- };
-
- enum ZOOM_LEVEL
- {
- ZOOM_LEVEL_0 = 0,
- ZOOM_LEVEL_1,
- ZOOM_LEVEL_2,
- ZOOM_LEVEL_3,
- ZOOM_LEVEL_4,
- ZOOM_LEVEL_5,
- ZOOM_LEVEL_6,
- ZOOM_LEVEL_7,
- ZOOM_LEVEL_8,
- ZOOM_LEVEL_9,
- ZOOM_LEVEL_10,
- ZOOM_LEVEL_11,
- ZOOM_LEVEL_12,
- ZOOM_LEVEL_MAX,
- };
-
- enum OBJECT_TRACKING
- {
- OBJECT_TRACKING_OFF,
- OBJECT_TRACKING_ON,
- OBJECT_TRACKING_MAX,
- };
-
- enum OBJECT_TRACKING_STAUS
- {
- OBJECT_TRACKING_STATUS_BASE,
- OBJECT_TRACKING_STATUS_PROGRESSING,
- OBJECT_TRACKING_STATUS_SUCCESS,
- OBJECT_TRACKING_STATUS_FAIL,
- OBJECT_TRACKING_STATUS_MISSING,
- OBJECT_TRACKING_STATUS_MAX,
- };
-
- enum SMART_AUTO
- {
- SMART_AUTO_OFF,
- SMART_AUTO_ON,
- SMART_AUTO_MAX,
- };
-
- enum BEAUTY_SHOT
- {
- BEAUTY_SHOT_OFF,
- BEAUTY_SHOT_ON,
- BEAUTY_SHOT_MAX,
- };
-
- enum VINTAGE_MODE
- {
- VINTAGE_MODE_BASE,
- VINTAGE_MODE_OFF,
- VINTAGE_MODE_NORMAL,
- VINTAGE_MODE_WARM,
- VINTAGE_MODE_COOL,
- VINTAGE_MODE_BNW,
- VINTAGE_MODE_MAX,
- };
-
- enum FOCUS_MODE
- {
- FOCUS_MODE_AUTO,
- FOCUS_MODE_MACRO,
- FOCUS_MODE_FACEDETECT,
- FOCUS_MODE_AUTO_DEFAULT,
- FOCUS_MODE_MACRO_DEFAULT,
- FOCUS_MODE_FACEDETECT_DEFAULT,
- FOCUS_MODE_MAX,
- };
-
- enum FACE_DETECT
- {
- FACE_DETECT_OFF,
- FACE_DETECT_NORMAL_ON,
- FACE_DETECT_BEAUTY_ON,
- FACE_DETECT_NO_LINE,
- FACE_DETECT_MAX,
- };
-
- enum AE_AWB_LOCK_UNLOCK
- {
- AE_UNLOCK_AWB_UNLOCK = 0,
- AE_LOCK_AWB_UNLOCK,
- AE_UNLOCK_AWB_LOCK,
- AE_LOCK_AWB_LOCK,
- AE_AWB_MAX
- };
-
- enum FRAME_RATE
- {
- FRAME_RATE_AUTO = 0,
- FRAME_RATE_15 = 15,
- FRAME_RATE_30 = 30,
- FRAME_RATE_60 = 60,
- FRAME_RATE_120 = 120,
- FRAME_RATE_MAX
- };
- enum ANTI_BANDING
- {
- ANTI_BANDING_AUTO = 0,
- ANTI_BANDING_50HZ = 1,
- ANTI_BANDING_60HZ = 2,
- ANTI_BANDING_OFF = 3,
- };
-
- enum SMART_AUTO_SCENE
- {
- SMART_AUTO_STATUS_AUTO = 0,
- SMART_AUTO_STATUS_LANDSCAPE,
- SMART_AUTO_STATUS_PORTRAIT,
- SMART_AUTO_STATUS_MACRO,
- SMART_AUTO_STATUS_NIGHT,
- SMART_AUTO_STATUS_PORTRAIT_NIGHT,
- SMART_AUTO_STATUS_BACKLIT,
- SMART_AUTO_STATUS_PORTRAIT_BACKLIT,
- SMART_AUTO_STATUS_ANTISHAKE,
- SMART_AUTO_STATUS_PORTRAIT_ANTISHAKE,
- SMART_AUTO_STATUS_MAX,
- };
-
- enum GAMMA
- {
- GAMMA_OFF,
- GAMMA_ON,
- GAMMA_MAX,
- };
-
- enum SLOW_AE
- {
- SLOW_AE_OFF,
- SLOW_AE_ON,
- SLOW_AE_MAX,
- };
-
- /*VT call*/
- enum VT_MODE
- {
- VT_MODE_OFF,
- VT_MODE_ON,
- VT_MODE_MAX,
- };
-
- /*Camera sensor mode - Camcorder fix fps*/
- enum SENSOR_MODE
- {
- SENSOR_MODE_CAMERA,
- SENSOR_MODE_MOVIE,
- };
-
- /*Camera Shot mode*/
- enum SHOT_MODE
- {
- SHOT_MODE_SINGLE = 0,
- SHOT_MODE_CONTINUOUS = 1,
- SHOT_MODE_PANORAMA = 2,
- SHOT_MODE_SMILE = 3,
- SHOT_MODE_SELF = 6,
- };
-
- enum BLUR_LEVEL
- {
- BLUR_LEVEL_0 = 0,
- BLUR_LEVEL_1,
- BLUR_LEVEL_2,
- BLUR_LEVEL_3,
- BLUR_LEVEL_MAX,
- };
-
- enum CHK_DATALINE
- {
- CHK_DATALINE_OFF,
- CHK_DATALINE_ON,
- CHK_DATALINE_MAX,
- };
-
- enum FACE_LOCK
- {
- FACE_LOCK_OFF,
- FACE_LOCK_ON,
- FIRST_FACE_TRACKING,
- FACE_LOCK_MAX
- };
-
- int m_touch_af_start_stop;
- int m_focus_mode;
- int m_iso;
+ enum SCENE_MODE {
+ SCENE_MODE_BASE,
+ SCENE_MODE_NONE,
+ SCENE_MODE_PORTRAIT,
+ SCENE_MODE_NIGHTSHOT,
+ SCENE_MODE_BACK_LIGHT,
+ SCENE_MODE_LANDSCAPE,
+ SCENE_MODE_SPORTS,
+ SCENE_MODE_PARTY_INDOOR,
+ SCENE_MODE_BEACH_SNOW,
+ SCENE_MODE_SUNSET,
+ SCENE_MODE_DUSK_DAWN,
+ SCENE_MODE_FALL_COLOR,
+ SCENE_MODE_FIREWORKS,
+ SCENE_MODE_TEXT,
+ SCENE_MODE_CANDLE_LIGHT,
+ SCENE_MODE_MAX,
+ };
+
+ enum FLASH_MODE {
+ FLASH_MODE_BASE,
+ FLASH_MODE_OFF,
+ FLASH_MODE_AUTO,
+ FLASH_MODE_ON,
+ FLASH_MODE_TORCH,
+ FLASH_MODE_MAX,
+ };
+
+ enum ISO {
+ ISO_AUTO,
+ ISO_50,
+ ISO_100,
+ ISO_200,
+ ISO_400,
+ ISO_800,
+ ISO_1600,
+ ISO_SPORTS,
+ ISO_NIGHT,
+ ISO_MOVIE,
+ ISO_MAX,
+ };
+
+ enum METERING {
+ METERING_BASE = 0,
+ METERING_MATRIX,
+ METERING_CENTER,
+ METERING_SPOT,
+ METERING_MAX,
+ };
+
+ enum CONTRAST {
+ CONTRAST_MINUS_2 = 0,
+ CONTRAST_MINUS_1,
+ CONTRAST_NORMAL,
+ CONTRAST_PLUS_1,
+ CONTRAST_PLUS_2,
+ CONTRAST_MAX,
+ };
+
+ enum SATURATION {
+ SATURATION_MINUS_2= 0,
+ SATURATION_MINUS_1,
+ SATURATION_NORMAL,
+ SATURATION_PLUS_1,
+ SATURATION_PLUS_2,
+ SATURATION_MAX,
+ };
+
+ enum SHARPNESS {
+ SHARPNESS_MINUS_2 = 0,
+ SHARPNESS_MINUS_1,
+ SHARPNESS_NORMAL,
+ SHARPNESS_PLUS_1,
+ SHARPNESS_PLUS_2,
+ SHARPNESS_MAX,
+ };
+
+ enum WDR {
+ WDR_OFF,
+ WDR_ON,
+ WDR_MAX,
+ };
+
+ enum ANTI_SHAKE {
+ ANTI_SHAKE_OFF,
+ ANTI_SHAKE_ON,
+ ANTI_SHAKE_MAX,
+ };
+
+ enum JPEG_QUALITY {
+ JPEG_QUALITY_ECONOMY = 0,
+ JPEG_QUALITY_NORMAL = 50,
+ JPEG_QUALITY_SUPERFINE = 100,
+ JPEG_QUALITY_MAX,
+ };
+
+ enum ZOOM_LEVEL {
+ ZOOM_LEVEL_0 = 0,
+ ZOOM_LEVEL_1,
+ ZOOM_LEVEL_2,
+ ZOOM_LEVEL_3,
+ ZOOM_LEVEL_4,
+ ZOOM_LEVEL_5,
+ ZOOM_LEVEL_6,
+ ZOOM_LEVEL_7,
+ ZOOM_LEVEL_8,
+ ZOOM_LEVEL_9,
+ ZOOM_LEVEL_10,
+ ZOOM_LEVEL_11,
+ ZOOM_LEVEL_12,
+ ZOOM_LEVEL_MAX,
+ };
+
+ enum OBJECT_TRACKING {
+ OBJECT_TRACKING_OFF,
+ OBJECT_TRACKING_ON,
+ OBJECT_TRACKING_MAX,
+ };
+
+ enum OBJECT_TRACKING_STAUS {
+ OBJECT_TRACKING_STATUS_BASE,
+ OBJECT_TRACKING_STATUS_PROGRESSING,
+ OBJECT_TRACKING_STATUS_SUCCESS,
+ OBJECT_TRACKING_STATUS_FAIL,
+ OBJECT_TRACKING_STATUS_MISSING,
+ OBJECT_TRACKING_STATUS_MAX,
+ };
+
+ enum SMART_AUTO {
+ SMART_AUTO_OFF,
+ SMART_AUTO_ON,
+ SMART_AUTO_MAX,
+ };
+
+ enum BEAUTY_SHOT {
+ BEAUTY_SHOT_OFF,
+ BEAUTY_SHOT_ON,
+ BEAUTY_SHOT_MAX,
+ };
+
+ enum VINTAGE_MODE {
+ VINTAGE_MODE_BASE,
+ VINTAGE_MODE_OFF,
+ VINTAGE_MODE_NORMAL,
+ VINTAGE_MODE_WARM,
+ VINTAGE_MODE_COOL,
+ VINTAGE_MODE_BNW,
+ VINTAGE_MODE_MAX,
+ };
+
+ enum FOCUS_MODE {
+ FOCUS_MODE_AUTO,
+ FOCUS_MODE_MACRO,
+ FOCUS_MODE_FACEDETECT,
+ FOCUS_MODE_AUTO_DEFAULT,
+ FOCUS_MODE_MACRO_DEFAULT,
+ FOCUS_MODE_FACEDETECT_DEFAULT,
+ FOCUS_MODE_MAX,
+ };
+
+ enum FACE_DETECT {
+ FACE_DETECT_OFF,
+ FACE_DETECT_NORMAL_ON,
+ FACE_DETECT_BEAUTY_ON,
+ FACE_DETECT_NO_LINE,
+ FACE_DETECT_MAX,
+ };
+
+ enum AE_AWB_LOCK_UNLOCK {
+ AE_UNLOCK_AWB_UNLOCK = 0,
+ AE_LOCK_AWB_UNLOCK,
+ AE_UNLOCK_AWB_LOCK,
+ AE_LOCK_AWB_LOCK,
+ AE_AWB_MAX
+ };
+
+ enum FRAME_RATE {
+ FRAME_RATE_AUTO = 0,
+ FRAME_RATE_15 = 15,
+ FRAME_RATE_30 = 30,
+ FRAME_RATE_60 = 60,
+ FRAME_RATE_120 = 120,
+ FRAME_RATE_MAX
+ };
+ enum ANTI_BANDING {
+ ANTI_BANDING_AUTO = 0,
+ ANTI_BANDING_50HZ = 1,
+ ANTI_BANDING_60HZ = 2,
+ ANTI_BANDING_OFF = 3,
+ };
+
+ enum SMART_AUTO_SCENE {
+ SMART_AUTO_STATUS_AUTO = 0,
+ SMART_AUTO_STATUS_LANDSCAPE,
+ SMART_AUTO_STATUS_PORTRAIT,
+ SMART_AUTO_STATUS_MACRO,
+ SMART_AUTO_STATUS_NIGHT,
+ SMART_AUTO_STATUS_PORTRAIT_NIGHT,
+ SMART_AUTO_STATUS_BACKLIT,
+ SMART_AUTO_STATUS_PORTRAIT_BACKLIT,
+ SMART_AUTO_STATUS_ANTISHAKE,
+ SMART_AUTO_STATUS_PORTRAIT_ANTISHAKE,
+ SMART_AUTO_STATUS_MAX,
+ };
+
+ enum GAMMA {
+ GAMMA_OFF,
+ GAMMA_ON,
+ GAMMA_MAX,
+ };
+
+ enum SLOW_AE {
+ SLOW_AE_OFF,
+ SLOW_AE_ON,
+ SLOW_AE_MAX,
+ };
+
+ /*VT call*/
+ enum VT_MODE {
+ VT_MODE_OFF,
+ VT_MODE_ON,
+ VT_MODE_MAX,
+ };
+
+ /*Camera sensor mode - Camcorder fix fps*/
+ enum SENSOR_MODE {
+ SENSOR_MODE_CAMERA,
+ SENSOR_MODE_MOVIE,
+ };
+
+ /*Camera Shot mode*/
+ enum SHOT_MODE {
+ SHOT_MODE_SINGLE = 0,
+ SHOT_MODE_CONTINUOUS = 1,
+ SHOT_MODE_PANORAMA = 2,
+ SHOT_MODE_SMILE = 3,
+ SHOT_MODE_SELF = 6,
+ };
+
+ enum BLUR_LEVEL {
+ BLUR_LEVEL_0 = 0,
+ BLUR_LEVEL_1,
+ BLUR_LEVEL_2,
+ BLUR_LEVEL_3,
+ BLUR_LEVEL_MAX,
+ };
+
+ enum CHK_DATALINE {
+ CHK_DATALINE_OFF,
+ CHK_DATALINE_ON,
+ CHK_DATALINE_MAX,
+ };
+
+ enum FACE_LOCK {
+ FACE_LOCK_OFF,
+ FACE_LOCK_ON,
+ FIRST_FACE_TRACKING,
+ FACE_LOCK_MAX
+ };
+
+ int m_touch_af_start_stop;
+ int m_focus_mode;
+ int m_iso;
#ifdef SWP1_CAMERA_ADD_ADVANCED_FUNCTION
- struct gps_info_latiude {
- unsigned int north_south;
- unsigned int dgree;
- unsigned int minute;
- unsigned int second;
- }gpsInfoLatitude;
- struct gps_info_longitude {
- unsigned int east_west;
- unsigned int dgree;
- unsigned int minute;
- unsigned int second;
- }gpsInfoLongitude;
- struct gps_info_altitude {
- unsigned int plus_minus;
- unsigned int dgree;
- unsigned int minute;
- unsigned int second;
- }gpsInfoAltitude;
+ struct gps_info_latiude {
+ unsigned int north_south;
+ unsigned int dgree;
+ unsigned int minute;
+ unsigned int second;
+ } gpsInfoLatitude;
+ struct gps_info_longitude {
+ unsigned int east_west;
+ unsigned int dgree;
+ unsigned int minute;
+ unsigned int second;
+ } gpsInfoLongitude;
+ struct gps_info_altitude {
+ unsigned int plus_minus;
+ unsigned int dgree;
+ unsigned int minute;
+ unsigned int second;
+ } gpsInfoAltitude;
#endif
@@ -595,277 +560,276 @@ public:
SecCamera();
~SecCamera();
- static SecCamera * createInstance(void)
- {
- static SecCamera singleton;
- return &singleton;
- }
- status_t dump(int fd, const Vector<String16>& args);
-
- int flagCreate(void) const;
-
-
- int setCameraId(int camera_id);
- int getCameraId(void);
-
- int startPreview(void);
- int stopPreview (void);
+ static SecCamera* createInstance(void)
+ {
+ static SecCamera singleton;
+ return &singleton;
+ }
+ status_t dump(int fd, const Vector<String16>& args);
+
+ int flagCreate(void) const;
+
+
+ int setCameraId(int camera_id);
+ int getCameraId(void);
+
+ int startPreview(void);
+ int stopPreview(void);
#ifdef DUAL_PORT_RECORDING
- int startRecord(void);
- int stopRecord (void);
- int getRecord(void);
- unsigned int getRecPhyAddrY(int);
- unsigned int getRecPhyAddrC(int);
+ int startRecord(void);
+ int stopRecord(void);
+ int getRecord(void);
+ unsigned int getRecPhyAddrY(int);
+ unsigned int getRecPhyAddrC(int);
#endif
- int flagPreviewStart(void);
- // int getPreview (unsigned char * buffer, unsigned int buffer_size);
- int getPreview(void);
- //int getPreview(int *offset, int *size, unsigned char * buffer, unsigned int buffer_size);
- int setPreviewSize(int width, int height, int pixel_format);
- int getPreviewSize(int * width, int * height, int * frame_size);
- int getPreviewMaxSize(int * width, int * height);
- int getPreviewPixelFormat(void);
- int setPreviewImage(int index, unsigned char * buffer, int size);
-
-
- int getSnapshot(unsigned char * buffer, unsigned int buffer_size);
- int setSnapshotSize(int width, int height);
- int getSnapshotSize(int * width, int * height, int * frame_size);
- int getSnapshotMaxSize(int * width, int * height);
- int setSnapshotPixelFormat(int pixel_format);
- int getSnapshotPixelFormat(void);
-
- unsigned char * getJpeg (unsigned char *snapshot_data, int snapshot_size, int * size);
- unsigned char * yuv2Jpeg (unsigned char * raw_data, int raw_size,
- int * jpeg_size,
- int width, int height, int pixel_format);
-
- int setJpegThumbnailSize(int width, int height);
- int getJpegThumbnailSize(int * width, int * height);
-
- int setAutofocus(void);
- int zoomIn(void);
- int zoomOut(void);
-
- int SetRotate(int angle);
- int getRotate(void);
-
- int setVerticalMirror(void);
- int setHorizontalMirror(void);
-
- int setWhiteBalance(int white_balance);
- int getWhiteBalance(void);
-
- int setBrightness(int brightness);
- int getBrightness(void);
-
- int setImageEffect(int image_effect);
- int getImageEffect(void);
+ int flagPreviewStart(void);
+ //int getPreview (unsigned char *buffer, unsigned int buffer_size);
+ int getPreview(void);
+ //int getPreview(int *offset, int *size, unsigned char *buffer, unsigned int buffer_size);
+ int setPreviewSize(int width, int height, int pixel_format);
+ int getPreviewSize(int *width, int *height, int *frame_size);
+ int getPreviewMaxSize(int *width, int *height);
+ int getPreviewPixelFormat(void);
+ int setPreviewImage(int index, unsigned char *buffer, int size);
+
+
+ int getSnapshot(unsigned char *buffer, unsigned int buffer_size);
+ int setSnapshotSize(int width, int height);
+ int getSnapshotSize(int *width, int *height, int *frame_size);
+ int getSnapshotMaxSize(int *width, int *height);
+ int setSnapshotPixelFormat(int pixel_format);
+ int getSnapshotPixelFormat(void);
+
+ unsigned char* getJpeg(unsigned char *snapshot_data, int snapshot_size, int *size);
+ unsigned char* yuv2Jpeg(unsigned char *raw_data, int raw_size,
+ int *jpeg_size,
+ int width, int height, int pixel_format);
+
+ int setJpegThumbnailSize(int width, int height);
+ int getJpegThumbnailSize(int *width, int *height);
+
+ int setAutofocus(void);
+ int zoomIn(void);
+ int zoomOut(void);
+
+ int SetRotate(int angle);
+ int getRotate(void);
+
+ int setVerticalMirror(void);
+ int setHorizontalMirror(void);
+
+ int setWhiteBalance(int white_balance);
+ int getWhiteBalance(void);
+
+ int setBrightness(int brightness);
+ int getBrightness(void);
+
+ int setImageEffect(int image_effect);
+ int getImageEffect(void);
#ifdef SWP1_CAMERA_ADD_ADVANCED_FUNCTION
- int setSceneMode(int scene_mode);
- int getSceneMode(void);
-
- int setFlashMode(int flash_mode);
- int getFlashMode(void);
-
- int setMetering(int metering_value);
- int getMetering(void);
-
- int setISO(int iso_value);
- int getISO(void);
-
- int setContrast(int contrast_value);
- int getContrast(void);
-
- int setSaturation(int saturation_value);
- int getSaturation(void);
-
- int setSharpness(int sharpness_value);
- int getSharpness(void);
-
- int setWDR(int wdr_value);
- int getWDR(void);
-
- int setAntiShake(int anti_shake);
- int getAntiShake(void);
-
- int setJpegQuality(int jpeg_qality);
- int getJpegQuality(void);
-
- int setZoom(int zoom_level);
- int getZoom(void);
-
- int setObjectTracking(int object_tracking);
- int getObjectTracking(void);
- int getObjectTrackingStatus(void);
-
- int setSmartAuto(int smart_auto);
- int getSmartAuto(void);
- int getAutosceneStatus(void);
-
- int setBeautyShot(int beauty_shot);
- int getBeautyShot(void);
-
- int setVintageMode(int vintage_mode);
- int getVintageMode(void);
-
- int setFocusMode(int focus_mode);
- int getFocusMode(void);
-
- int setFaceDetect(int face_detect);
- int getFaceDetect(void);
-
- int setGPSLatitude(const char * gps_latitude);
- int setGPSLongitude(const char * gps_longitude);
- int setGPSAltitude(const char * gps_altitude);
- int setGPSTimeStamp(const char * gps_timestamp);
- int cancelAutofocus(void);
- int setAEAWBLockUnlock(int ae_lockunlock, int awb_lockunlock);
- int setFaceDetectLockUnlock(int facedetect_lockunlock);
- int setObjectPosition(int x, int y);
- int setObjectTrackingStartStop(int start_stop);
- int setTouchAFStartStop(int start_stop);
- int setCAFStatus(int on_off);
- int getAutoFocusResult(void);
- int setAntiBanding(int anti_banding);
- int getPostview(void);
- int setRecordingSize(int width, int height);
- int setGamma(int gamma);
- int setSlowAE(int slow_ae);
- int setExifOrientationInfo(int orientationInfo);
- int setBatchReflection(void);
- int setSnapshotCmd(void);
- int setCameraSensorReset(void); //s1_camera [ Defense process by ESD input ]
- int setSensorMode(int sensor_mode); /* Camcorder fix fps */
- int setShotMode(int shot_mode); /* Shot mode */
- /*VT call*/
- int setVTmode(int vtmode);
- int getVTmode(void);
- int setBlur(int blur_level);
- int getBlur(void);
- int setDataLineCheck(int chk_dataline);
- int getDataLineCheck(void);
- int setDataLineCheckStop(void);
- int setDefultIMEI(int imei);
- int getDefultIMEI(void);
+ int setSceneMode(int scene_mode);
+ int getSceneMode(void);
+
+ int setFlashMode(int flash_mode);
+ int getFlashMode(void);
+
+ int setMetering(int metering_value);
+ int getMetering(void);
+
+ int setISO(int iso_value);
+ int getISO(void);
+
+ int setContrast(int contrast_value);
+ int getContrast(void);
+
+ int setSaturation(int saturation_value);
+ int getSaturation(void);
+
+ int setSharpness(int sharpness_value);
+ int getSharpness(void);
+
+ int setWDR(int wdr_value);
+ int getWDR(void);
+
+ int setAntiShake(int anti_shake);
+ int getAntiShake(void);
+
+ int setJpegQuality(int jpeg_qality);
+ int getJpegQuality(void);
+
+ int setZoom(int zoom_level);
+ int getZoom(void);
+
+ int setObjectTracking(int object_tracking);
+ int getObjectTracking(void);
+ int getObjectTrackingStatus(void);
+
+ int setSmartAuto(int smart_auto);
+ int getSmartAuto(void);
+ int getAutosceneStatus(void);
+
+ int setBeautyShot(int beauty_shot);
+ int getBeautyShot(void);
+
+ int setVintageMode(int vintage_mode);
+ int getVintageMode(void);
+
+ int setFocusMode(int focus_mode);
+ int getFocusMode(void);
+
+ int setFaceDetect(int face_detect);
+ int getFaceDetect(void);
+
+ int setGPSLatitude(const char *gps_latitude);
+ int setGPSLongitude(const char *gps_longitude);
+ int setGPSAltitude(const char *gps_altitude);
+ int setGPSTimeStamp(const char *gps_timestamp);
+ int cancelAutofocus(void);
+ int setAEAWBLockUnlock(int ae_lockunlock, int awb_lockunlock);
+ int setFaceDetectLockUnlock(int facedetect_lockunlock);
+ int setObjectPosition(int x, int y);
+ int setObjectTrackingStartStop(int start_stop);
+ int setTouchAFStartStop(int start_stop);
+ int setCAFStatus(int on_off);
+ int getAutoFocusResult(void);
+ int setAntiBanding(int anti_banding);
+ int getPostview(void);
+ int setRecordingSize(int width, int height);
+ int setGamma(int gamma);
+ int setSlowAE(int slow_ae);
+ int setExifOrientationInfo(int orientationInfo);
+ int setBatchReflection(void);
+ int setSnapshotCmd(void);
+ int setCameraSensorReset(void);
+ int setSensorMode(int sensor_mode); /* Camcorder fix fps */
+ int setShotMode(int shot_mode); /* Shot mode */
+ /*VT call*/
+ int setVTmode(int vtmode);
+ int getVTmode(void);
+ int setBlur(int blur_level);
+ int getBlur(void);
+ int setDataLineCheck(int chk_dataline);
+ int getDataLineCheck(void);
+ int setDataLineCheckStop(void);
+ int setDefultIMEI(int imei);
+ int getDefultIMEI(void);
#endif
- void setFrameRate(int frame_rate);
-// void setJpegQuality(int quality);
- unsigned char* getJpeg(int*, unsigned int*);
- unsigned char* getSnapshotAndJpeg(unsigned int* output_size);
- //[zzangdol] add function
- int getExif(unsigned char *pExifDst, unsigned char *pThumbSrc);
+ void setFrameRate(int frame_rate);
+// void setJpegQuality(int quality);
+ unsigned char* getJpeg(int*, unsigned int*);
+ unsigned char* getSnapshotAndJpeg(unsigned int *output_size);
+ int getExif(unsigned char *pExifDst, unsigned char *pThumbSrc);
#ifdef JPEG_FROM_SENSOR
- void getPostViewConfig(int*, int*, int*);
+ void getPostViewConfig(int*, int*, int*);
#endif
#ifdef DIRECT_DELIVERY_OF_POSTVIEW_DATA
- int getPostViewOffset(void);
-#endif
- int getCameraFd(void);
- int getJpegFd(void);
- void SetJpgAddr(unsigned char *addr);
- unsigned int getPhyAddrY(int);
- unsigned int getPhyAddrC(int);
+ int getPostViewOffset(void);
+#endif
+ int getCameraFd(void);
+ int getJpegFd(void);
+ void SetJpgAddr(unsigned char *addr);
+ unsigned int getPhyAddrY(int);
+ unsigned int getPhyAddrC(int);
#ifdef SEND_YUV_RECORD_DATA
- void getYUVBuffers(unsigned char** virYAddr, unsigned char** virCaddr, int index);
+ void getYUVBuffers(unsigned char **virYAddr, unsigned char **virCaddr, int index);
#endif
- void pausePreview();
- int initCamera(int index);
- void DeinitCamera();
+ void pausePreview();
+ int initCamera(int index);
+ void DeinitCamera();
private:
- int m_flag_init;
+ int m_flag_init;
- int m_camera_id;
+ int m_camera_id;
- int m_cam_fd;
+ int m_cam_fd;
- int m_cam_fd_temp;
- int m_cam_fd2_temp;
+ int m_cam_fd_temp;
+ int m_cam_fd2_temp;
#ifdef DUAL_PORT_RECORDING
- int m_cam_fd2;
- struct pollfd m_events_c2;
- int m_flag_record_start;
- struct fimc_buffer m_buffers_c2[MAX_BUFFERS];
+ int m_cam_fd2;
+ struct pollfd m_events_c2;
+ int m_flag_record_start;
+ struct fimc_buffer m_buffers_c2[MAX_BUFFERS];
#endif
-
- int m_preview_v4lformat;
- int m_preview_width;
- int m_preview_height;
- int m_preview_max_width;
- int m_preview_max_height;
-
- int m_snapshot_v4lformat;
- int m_snapshot_width;
- int m_snapshot_height;
- int m_snapshot_max_width;
- int m_snapshot_max_height;
-
- int m_angle;
- int m_fps;
- int m_autofocus;
- int m_white_balance;
- int m_brightness;
- int m_image_effect;
+
+ int m_preview_v4lformat;
+ int m_preview_width;
+ int m_preview_height;
+ int m_preview_max_width;
+ int m_preview_max_height;
+
+ int m_snapshot_v4lformat;
+ int m_snapshot_width;
+ int m_snapshot_height;
+ int m_snapshot_max_width;
+ int m_snapshot_max_height;
+
+ int m_angle;
+ int m_fps;
+ int m_autofocus;
+ int m_white_balance;
+ int m_brightness;
+ int m_image_effect;
#ifdef SWP1_CAMERA_ADD_ADVANCED_FUNCTION
- int m_anti_banding;
- int m_scene_mode;
- int m_flash_mode;
-// int m_iso;
- int m_metering;
- int m_contrast;
- int m_saturation;
- int m_sharpness;
- int m_wdr;
- int m_anti_shake;
-// int m_jpeg_quality;
- int m_zoom_level;
- int m_object_tracking;
- int m_smart_auto;
- int m_beauty_shot;
- int m_vintage_mode;
-// int m_focus_mode;
- int m_face_detect;
- int m_object_tracking_start_stop;
- int m_recording_width;
- int m_recording_height;
- long m_gps_latitude;
- long m_gps_longitude;
- long m_gps_altitude;
- long m_gps_timestamp;
- int m_vtmode;
- int m_sensor_mode; /*Camcorder fix fps */
- int m_shot_mode; /* Shot mode */
- int m_exif_orientation;
- int m_blur_level;
- int m_chk_dataline;
- int m_video_gamma;
- int m_slow_ae;
- int m_caf_on_off;
- int m_default_imei;
- int m_camera_af_flag;
+ int m_anti_banding;
+ int m_scene_mode;
+ int m_flash_mode;
+// int m_iso;
+ int m_metering;
+ int m_contrast;
+ int m_saturation;
+ int m_sharpness;
+ int m_wdr;
+ int m_anti_shake;
+// int m_jpeg_quality;
+ int m_zoom_level;
+ int m_object_tracking;
+ int m_smart_auto;
+ int m_beauty_shot;
+ int m_vintage_mode;
+// int m_focus_mode;
+ int m_face_detect;
+ int m_object_tracking_start_stop;
+ int m_recording_width;
+ int m_recording_height;
+ long m_gps_latitude;
+ long m_gps_longitude;
+ long m_gps_altitude;
+ long m_gps_timestamp;
+ int m_vtmode;
+ int m_sensor_mode; /*Camcorder fix fps */
+ int m_shot_mode; /* Shot mode */
+ int m_exif_orientation;
+ int m_blur_level;
+ int m_chk_dataline;
+ int m_video_gamma;
+ int m_slow_ae;
+ int m_caf_on_off;
+ int m_default_imei;
+ int m_camera_af_flag;
#endif
-
- int m_flag_camera_start;
-
- int m_jpeg_fd;
- int m_jpeg_thumbnail_width;
- int m_jpeg_thumbnail_height;
- int m_jpeg_quality;
-
- int m_postview_offset;
-
- struct fimc_buffer m_buffers_c[MAX_BUFFERS];
- struct pollfd m_events_c;
-
- inline int m_frameSize(int format, int width, int height);
-
- void setExifChangedAttribute();
- void setExifFixedAttribute();
- void resetCamera();
+
+ int m_flag_camera_start;
+
+ int m_jpeg_fd;
+ int m_jpeg_thumbnail_width;
+ int m_jpeg_thumbnail_height;
+ int m_jpeg_quality;
+
+ int m_postview_offset;
+
+ struct fimc_buffer m_buffers_c[MAX_BUFFERS];
+ struct pollfd m_events_c;
+
+ inline int m_frameSize(int format, int width, int height);
+
+ void setExifChangedAttribute();
+ void setExifFixedAttribute();
+ void resetCamera();
};
extern unsigned long measure_time(struct timeval *start, struct timeval *stop);
diff --git a/libcamera/SecCameraHWInterface.cpp b/libcamera/SecCameraHWInterface.cpp
index 6ebc0b3..aa8f308 100644
--- a/libcamera/SecCameraHWInterface.cpp
+++ b/libcamera/SecCameraHWInterface.cpp
@@ -1,4 +1,4 @@
-/*
+/*
**
** Copyright 2008, The Android Open Source Project
** Copyright@ Samsung Electronics Co. LTD
@@ -28,8 +28,8 @@
#if defined(BOARD_USES_OVERLAY)
#include <hardware/overlay.h>
#include <ui/Overlay.h>
-#define CACHEABLE_BUFFERS 0x1
-#define ALL_BUFFERS_FLUSHED -66
+#define CACHEABLE_BUFFERS 0x1
+#define ALL_BUFFERS_FLUSHED -66
int buf_idx = 0;
#endif
@@ -37,366 +37,358 @@ int buf_idx = 0;
#define ALIGN_TO_32B(x) ((((x) + (1 << 5) - 1) >> 5) << 5)
#define ALIGN_TO_128B(x) ((((x) + (1 << 7) - 1) >> 7) << 7)
#define ALIGN_TO_8KB(x) ((((x) + (1 << 13) - 1) >> 13) << 13)
-#define RECORD_HEAP_SIZE (ALIGN_TO_8KB(ALIGN_TO_128B(1280) * ALIGN_TO_32B(720)) + ALIGN_TO_8KB(ALIGN_TO_128B(1280) * ALIGN_TO_32B(720/2)))
+#define RECORD_HEAP_SIZE (ALIGN_TO_8KB(ALIGN_TO_128B(1280) * \
+ ALIGN_TO_32B(720)) + ALIGN_TO_8KB(ALIGN_TO_128B(1280) * \
+ ALIGN_TO_32B(720 / 2)))
#endif
namespace android {
-struct ADDRS
-{
- unsigned int addr_y;
- unsigned int addr_cbcr;
- unsigned int buf_index;
- unsigned int reserved;
+struct addrs {
+ unsigned int addr_y;
+ unsigned int addr_cbcr;
+ unsigned int buf_index;
+ unsigned int reserved;
};
-struct ADDRS_CAP
-{
- unsigned int addr_y;
- unsigned int width;
- unsigned int height;
+struct addrs_cap {
+ unsigned int addr_y;
+ unsigned int width;
+ unsigned int height;
};
CameraHardwareSec::CameraHardwareSec(int cameraId)
- : mParameters(),
- mPreviewHeap(0),
- mRawHeap(0),
- mRecordHeap(0),
- mJpegHeap(0),
- mSecCamera(NULL),
- mPreviewRunning(false),
- mPreviewFrameSize(0),
- mRawFrameSize(0),
- mPreviewFrameRateMicrosec(33000),
- mNotifyCb(0),
- mDataCb(0),
- mDataCbTimestamp(0),
- mCallbackCookie(0),
- mMsgEnabled(0),
- mCurrentPreviewFrame(0),
+ : mParameters(),
+ mPreviewHeap(0),
+ mRawHeap(0),
+ mRecordHeap(0),
+ mJpegHeap(0),
+ mSecCamera(NULL),
+ mPreviewRunning(false),
+ mPreviewFrameSize(0),
+ mRawFrameSize(0),
+ mPreviewFrameRateMicrosec(33000),
+ mNotifyCb(0),
+ mDataCb(0),
+ mDataCbTimestamp(0),
+ mCallbackCookie(0),
+ mMsgEnabled(0),
+ mCurrentPreviewFrame(0),
#if defined(BOARD_USES_OVERLAY)
- mUseOverlay(false),
+ mUseOverlay(false),
#endif
- mRecordRunning(false)
+ mRecordRunning(false)
#ifdef JPEG_FROM_SENSOR
- ,
- mPostViewWidth(0),
- mPostViewHeight(0),
- mPostViewSize(0)
-#endif
+ ,
+ mPostViewWidth(0),
+ mPostViewHeight(0),
+ mPostViewSize(0)
+#endif
#ifdef SWP1_CAMERA_ADD_ADVANCED_FUNCTION
- ,
- mObjectTrackingStatus(0),
- mSmartautosceneRunning(false),
- mSmartautoscene_current_status(0),
- mSmartautoscene_previous_status(0)
+ ,
+ mObjectTrackingStatus(0),
+ mSmartautosceneRunning(false),
+ mSmartautoscene_current_status(0),
+ mSmartautoscene_previous_status(0)
#endif
{
- LOGV("%s()", __func__);
- int ret = 0;
- mNoHwHandle = 0;
-
- mSecCamera = SecCamera::createInstance();
- if(mSecCamera == NULL)
- {
- LOGE("ERR(%s):Fail on mSecCamera object creation", __func__);
- }
-
- ret = mSecCamera->initCamera(cameraId);
- if(ret < 0)
- {
- LOGE("ERR(%s):Fail on mSecCamera init", __func__);
- }
-
- if(mSecCamera->flagCreate() == 0)
- {
- LOGE("ERR(%s):Fail on mSecCamera->flagCreate()", __func__);
- }
+ LOGV("%s()", __func__);
+ int ret = 0;
+ mNoHwHandle = 0;
+
+ mSecCamera = SecCamera::createInstance();
+
+ if (mSecCamera == NULL) {
+ LOGE("ERR(%s):Fail on mSecCamera object creation", __func__);
+ }
+
+ ret = mSecCamera->initCamera(cameraId);
+ if (ret < 0) {
+ LOGE("ERR(%s):Fail on mSecCamera init", __func__);
+ }
+
+ if (mSecCamera->flagCreate() == 0) {
+ LOGE("ERR(%s):Fail on mSecCamera->flagCreate()", __func__);
+ }
#ifndef PREVIEW_USING_MMAP
- int previewHeapSize = sizeof(struct ADDRS) * kBufferCount;
- LOGV("mPreviewHeap : MemoryHeapBase(previewHeapSize(%d))", previewHeapSize);
- mPreviewHeap = new MemoryHeapBase(previewHeapSize);
- if (mPreviewHeap->getHeapID() < 0)
- {
- LOGE("ERR(%s): Preview heap creation fail", __func__);
+ int previewHeapSize = sizeof(struct addrs) * kBufferCount;
+
+ LOGV("mPreviewHeap : MemoryHeapBase(previewHeapSize(%d))", previewHeapSize);
+ mPreviewHeap = new MemoryHeapBase(previewHeapSize);
+ if (mPreviewHeap->getHeapID() < 0) {
+ LOGE("ERR(%s): Preview heap creation fail", __func__);
mPreviewHeap.clear();
- }
+ }
#endif
#ifdef SEND_YUV_RECORD_DATA
- int recordHeapSize = RECORD_HEAP_SIZE;
+ int recordHeapSize = RECORD_HEAP_SIZE;
#else
- int recordHeapSize = sizeof(struct ADDRS) * kBufferCount;
+ int recordHeapSize = sizeof(struct addrs) * kBufferCount;
#endif
- LOGV("mRecordHeap : MemoryHeapBase(recordHeapSize(%d))", recordHeapSize);
- mRecordHeap = new MemoryHeapBase(recordHeapSize);
- if (mRecordHeap->getHeapID() < 0)
- {
- LOGE("ERR(%s): Record heap creation fail", __func__);
+ LOGV("mRecordHeap : MemoryHeapBase(recordHeapSize(%d))", recordHeapSize);
+ mRecordHeap = new MemoryHeapBase(recordHeapSize);
+ if (mRecordHeap->getHeapID() < 0) {
+ LOGE("ERR(%s): Record heap creation fail", __func__);
mRecordHeap.clear();
- }
+ }
-#ifdef JPEG_FROM_SENSOR
- mSecCamera->getPostViewConfig(&mPostViewWidth, &mPostViewHeight, &mPostViewSize);
- LOGV("mPostViewWidth = %d mPostViewHeight = %d mPostViewSize = %d",mPostViewWidth,mPostViewHeight,mPostViewSize);
+#ifdef JPEG_FROM_SENSOR
+ mSecCamera->getPostViewConfig(&mPostViewWidth, &mPostViewHeight, &mPostViewSize);
+ LOGV("mPostViewWidth = %d mPostViewHeight = %d mPostViewSize = %d",
+ mPostViewWidth,mPostViewHeight,mPostViewSize);
#endif
-
+
#ifdef DIRECT_DELIVERY_OF_POSTVIEW_DATA
- int rawHeapSize = mPostViewSize;
+ int rawHeapSize = mPostViewSize;
#else
- int rawHeapSize = sizeof(struct ADDRS_CAP);
+ int rawHeapSize = sizeof(struct addrs_cap);
#endif
- LOGV("mRawHeap : MemoryHeapBase(previewHeapSize(%d))", rawHeapSize);
- mRawHeap = new MemoryHeapBase(rawHeapSize);
- if (mRawHeap->getHeapID() < 0)
- {
- LOGE("ERR(%s): Raw heap creation fail", __func__);
+ LOGV("mRawHeap : MemoryHeapBase(previewHeapSize(%d))", rawHeapSize);
+ mRawHeap = new MemoryHeapBase(rawHeapSize);
+ if (mRawHeap->getHeapID() < 0) {
+ LOGE("ERR(%s): Raw heap creation fail", __func__);
mRawHeap.clear();
- }
+ }
- initDefaultParameters(cameraId);
+ initDefaultParameters(cameraId);
}
void CameraHardwareSec::initDefaultParameters(int cameraId)
{
- if(mSecCamera == NULL)
- {
- LOGE("ERR(%s):mSecCamera object is NULL", __func__);
- return;
- }
-
- CameraParameters p;
-
- int preview_max_width = 0;
- int preview_max_height = 0;
- int snapshot_max_width = 0;
- int snapshot_max_height = 0;
-
- p.set("camera-id", cameraId);
- /* set camera ID & reset camera */
- if(cameraId == 0)
- mSecCamera->setCameraId(SecCamera::CAMERA_ID_BACK);
- else
- mSecCamera->setCameraId(SecCamera::CAMERA_ID_FRONT);
-
- if(mSecCamera->getPreviewMaxSize(&preview_max_width, &preview_max_height) < 0)
- {
- LOGE("getPreviewMaxSize fail (%d / %d) \n", preview_max_width, preview_max_height);
- preview_max_width = LCD_WIDTH;
- preview_max_height = LCD_HEIGHT;
- }
- if(mSecCamera->getSnapshotMaxSize(&snapshot_max_width, &snapshot_max_height) < 0)
- {
- LOGE("getSnapshotMaxSize fail (%d / %d) \n", snapshot_max_width, snapshot_max_height);
- snapshot_max_width = LCD_WIDTH;
- snapshot_max_height = LCD_HEIGHT;
- }
+ if (mSecCamera == NULL) {
+ LOGE("ERR(%s):mSecCamera object is NULL", __func__);
+ return;
+ }
+
+ CameraParameters p;
+
+ int preview_max_width = 0;
+ int preview_max_height = 0;
+ int snapshot_max_width = 0;
+ int snapshot_max_height = 0;
+
+ p.set("camera-id", cameraId);
+ /* set camera ID & reset camera */
+ if (cameraId == 0)
+ mSecCamera->setCameraId(SecCamera::CAMERA_ID_BACK);
+ else
+ mSecCamera->setCameraId(SecCamera::CAMERA_ID_FRONT);
+
+ if (mSecCamera->getPreviewMaxSize(&preview_max_width, &preview_max_height) < 0) {
+ LOGE("getPreviewMaxSize fail (%d / %d) \n", preview_max_width, preview_max_height);
+ preview_max_width = LCD_WIDTH;
+ preview_max_height = LCD_HEIGHT;
+ }
+ if (mSecCamera->getSnapshotMaxSize(&snapshot_max_width, &snapshot_max_height) < 0) {
+ LOGE("getSnapshotMaxSize fail (%d / %d) \n", snapshot_max_width, snapshot_max_height);
+ snapshot_max_width = LCD_WIDTH;
+ snapshot_max_height = LCD_HEIGHT;
+ }
#ifdef PREVIEW_USING_MMAP
- p.setPreviewFormat(CameraParameters::PIXEL_FORMAT_YUV420SP);
+ p.setPreviewFormat(CameraParameters::PIXEL_FORMAT_YUV420SP);
#else
- p.setPreviewFormat("yuv420sp_custom");
+ p.setPreviewFormat("yuv420sp_custom");
#endif
- p.setPreviewSize(preview_max_width, preview_max_height);
- p.setPreviewFrameRate(30);
-
- p.setPictureFormat(CameraParameters::PIXEL_FORMAT_JPEG);
- p.setPictureSize(snapshot_max_width, snapshot_max_height);
- p.set(CameraParameters::KEY_JPEG_QUALITY, "100"); // maximum quality
+ p.setPreviewSize(preview_max_width, preview_max_height);
+ p.setPreviewFrameRate(30);
+
+ p.setPictureFormat(CameraParameters::PIXEL_FORMAT_JPEG);
+ p.setPictureSize(snapshot_max_width, snapshot_max_height);
+ p.set(CameraParameters::KEY_JPEG_QUALITY, "100"); // maximum quality
#ifdef SWP1_CAMERA_ADD_ADVANCED_FUNCTION
- p.set(CameraParameters::KEY_SUPPORTED_PREVIEW_SIZES,
- "640x480,800x480");
- p.set(CameraParameters::KEY_SUPPORTED_PICTURE_SIZES,
- "2560x1920,2048x1536,1600x1200,640x480");
- p.set(CameraParameters::KEY_SUPPORTED_PREVIEW_FORMATS,
- CameraParameters::PIXEL_FORMAT_YUV420SP);
- p.set(CameraParameters::KEY_SUPPORTED_PREVIEW_FRAME_RATES, "15,30");
- p.set(CameraParameters::KEY_SUPPORTED_PICTURE_FORMATS,
- CameraParameters::PIXEL_FORMAT_JPEG);
- p.set(CameraParameters::KEY_SUPPORTED_JPEG_THUMBNAIL_SIZES,
- "160x120,0x0");
- p.set(CameraParameters::KEY_VIDEO_FRAME_FORMAT,
- CameraParameters::PIXEL_FORMAT_YUV420SP);
-
- String8 parameterString;
-
- parameterString = CameraParameters::FOCUS_MODE_AUTO;
- parameterString.append(",");
- parameterString.append(CameraParameters::FOCUS_MODE_MACRO);
- p.set(CameraParameters::KEY_SUPPORTED_FOCUS_MODES, parameterString.string());
-
- parameterString = CameraParameters::ANTIBANDING_AUTO;
- parameterString.append(",");
- parameterString.append(CameraParameters::ANTIBANDING_50HZ);
- parameterString.append(",");
- parameterString.append(CameraParameters::ANTIBANDING_60HZ);
- parameterString.append(",");
- parameterString.append(CameraParameters::ANTIBANDING_OFF);
- p.set(CameraParameters::KEY_SUPPORTED_ANTIBANDING, parameterString.string());
-
- parameterString = CameraParameters::EFFECT_NONE;
- parameterString.append(",");
- parameterString.append(CameraParameters::EFFECT_MONO);
- parameterString.append(",");
- parameterString.append(CameraParameters::EFFECT_NEGATIVE);
- parameterString.append(",");
- parameterString.append(CameraParameters::EFFECT_SEPIA);
- p.set(CameraParameters::KEY_SUPPORTED_EFFECTS, parameterString.string());
-
- p.set(CameraParameters::KEY_SUPPORTED_FLASH_MODES,
- CameraParameters::FLASH_MODE_OFF);
-// p.set("focus-mode-values", "auto,infinity,macro");
-
- parameterString = CameraParameters::SCENE_MODE_AUTO;
- parameterString.append(",");
- parameterString.append(CameraParameters::SCENE_MODE_PORTRAIT);
- parameterString.append(",");
- parameterString.append(CameraParameters::SCENE_MODE_LANDSCAPE);
- parameterString.append(",");
- parameterString.append(CameraParameters::SCENE_MODE_NIGHT);
- parameterString.append(",");
- parameterString.append(CameraParameters::SCENE_MODE_BEACH);
- parameterString.append(",");
- parameterString.append(CameraParameters::SCENE_MODE_SNOW);
- parameterString.append(",");
- parameterString.append(CameraParameters::SCENE_MODE_SUNSET);
- parameterString.append(",");
- parameterString.append(CameraParameters::SCENE_MODE_FIREWORKS);
- parameterString.append(",");
- parameterString.append(CameraParameters::SCENE_MODE_SPORTS);
- parameterString.append(",");
- parameterString.append(CameraParameters::SCENE_MODE_PARTY);
- parameterString.append(",");
- parameterString.append(CameraParameters::SCENE_MODE_CANDLELIGHT);
- p.set(CameraParameters::KEY_SUPPORTED_SCENE_MODES, parameterString.string());
-
- parameterString = CameraParameters::WHITE_BALANCE_AUTO;
- parameterString.append(",");
- parameterString.append(CameraParameters::WHITE_BALANCE_INCANDESCENT);
- parameterString.append(",");
- parameterString.append(CameraParameters::WHITE_BALANCE_FLUORESCENT);
- parameterString.append(",");
- parameterString.append(CameraParameters::WHITE_BALANCE_DAYLIGHT);
- parameterString.append(",");
- parameterString.append(CameraParameters::WHITE_BALANCE_CLOUDY_DAYLIGHT);
- p.set(CameraParameters::KEY_GPS_PROCESSING_METHOD, parameterString.string());
+ p.set(CameraParameters::KEY_SUPPORTED_PREVIEW_SIZES,
+ "640x480,800x480");
+ p.set(CameraParameters::KEY_SUPPORTED_PICTURE_SIZES,
+ "2560x1920,2048x1536,1600x1200,640x480");
+ p.set(CameraParameters::KEY_SUPPORTED_PREVIEW_FORMATS,
+ CameraParameters::PIXEL_FORMAT_YUV420SP);
+ p.set(CameraParameters::KEY_SUPPORTED_PREVIEW_FRAME_RATES, "15,30");
+ p.set(CameraParameters::KEY_SUPPORTED_PICTURE_FORMATS,
+ CameraParameters::PIXEL_FORMAT_JPEG);
+ p.set(CameraParameters::KEY_SUPPORTED_JPEG_THUMBNAIL_SIZES,
+ "160x120,0x0");
+ p.set(CameraParameters::KEY_VIDEO_FRAME_FORMAT,
+ CameraParameters::PIXEL_FORMAT_YUV420SP);
+
+ String8 parameterString;
+
+ parameterString = CameraParameters::FOCUS_MODE_AUTO;
+ parameterString.append(",");
+ parameterString.append(CameraParameters::FOCUS_MODE_MACRO);
+ p.set(CameraParameters::KEY_SUPPORTED_FOCUS_MODES, parameterString.string());
+
+ parameterString = CameraParameters::ANTIBANDING_AUTO;
+ parameterString.append(",");
+ parameterString.append(CameraParameters::ANTIBANDING_50HZ);
+ parameterString.append(",");
+ parameterString.append(CameraParameters::ANTIBANDING_60HZ);
+ parameterString.append(",");
+ parameterString.append(CameraParameters::ANTIBANDING_OFF);
+ p.set(CameraParameters::KEY_SUPPORTED_ANTIBANDING, parameterString.string());
+
+ parameterString = CameraParameters::EFFECT_NONE;
+ parameterString.append(",");
+ parameterString.append(CameraParameters::EFFECT_MONO);
+ parameterString.append(",");
+ parameterString.append(CameraParameters::EFFECT_NEGATIVE);
+ parameterString.append(",");
+ parameterString.append(CameraParameters::EFFECT_SEPIA);
+ p.set(CameraParameters::KEY_SUPPORTED_EFFECTS, parameterString.string());
+
+ p.set(CameraParameters::KEY_SUPPORTED_FLASH_MODES,
+ CameraParameters::FLASH_MODE_OFF);
+
+ parameterString = CameraParameters::SCENE_MODE_AUTO;
+ parameterString.append(",");
+ parameterString.append(CameraParameters::SCENE_MODE_PORTRAIT);
+ parameterString.append(",");
+ parameterString.append(CameraParameters::SCENE_MODE_LANDSCAPE);
+ parameterString.append(",");
+ parameterString.append(CameraParameters::SCENE_MODE_NIGHT);
+ parameterString.append(",");
+ parameterString.append(CameraParameters::SCENE_MODE_BEACH);
+ parameterString.append(",");
+ parameterString.append(CameraParameters::SCENE_MODE_SNOW);
+ parameterString.append(",");
+ parameterString.append(CameraParameters::SCENE_MODE_SUNSET);
+ parameterString.append(",");
+ parameterString.append(CameraParameters::SCENE_MODE_FIREWORKS);
+ parameterString.append(",");
+ parameterString.append(CameraParameters::SCENE_MODE_SPORTS);
+ parameterString.append(",");
+ parameterString.append(CameraParameters::SCENE_MODE_PARTY);
+ parameterString.append(",");
+ parameterString.append(CameraParameters::SCENE_MODE_CANDLELIGHT);
+ p.set(CameraParameters::KEY_SUPPORTED_SCENE_MODES, parameterString.string());
+
+ parameterString = CameraParameters::WHITE_BALANCE_AUTO;
+ parameterString.append(",");
+ parameterString.append(CameraParameters::WHITE_BALANCE_INCANDESCENT);
+ parameterString.append(",");
+ parameterString.append(CameraParameters::WHITE_BALANCE_FLUORESCENT);
+ parameterString.append(",");
+ parameterString.append(CameraParameters::WHITE_BALANCE_DAYLIGHT);
+ parameterString.append(",");
+ parameterString.append(CameraParameters::WHITE_BALANCE_CLOUDY_DAYLIGHT);
+ p.set(CameraParameters::KEY_GPS_PROCESSING_METHOD, parameterString.string());
//add the max and min for adjust value[20100728 giung.jung]
- p.set("sharpness-min", 0);
- p.set("sharpness-max", 4);
- p.set("saturation-min", 0);
- p.set("saturation-max", 4);
- p.set("contrast-min", 0);
- p.set("contrast-max", 4);
-
+ p.set("sharpness-min", 0);
+ p.set("sharpness-max", 4);
+ p.set("saturation-min", 0);
+ p.set("saturation-max", 4);
+ p.set("contrast-min", 0);
+ p.set("contrast-max", 4);
+
#else
- // List supported picture size values //Kamat
- p.set(CameraParameters::KEY_SUPPORTED_PICTURE_SIZES,
- "2560x1920,2048x1536,1600x1200,1280x960");
+ // List supported picture size values //Kamat
+ p.set(CameraParameters::KEY_SUPPORTED_PICTURE_SIZES,
+ "2560x1920,2048x1536,1600x1200,1280x960");
#endif
- // These values must be multiples of 16, so we can't do 427x320, which is the exact size on
- // screen we want to display at. 480x360 doesn't work either since it's a multiple of 8.
- p.set(CameraParameters::KEY_JPEG_THUMBNAIL_WIDTH, "160");
- p.set(CameraParameters::KEY_JPEG_THUMBNAIL_HEIGHT, "120");
- p.set(CameraParameters::KEY_JPEG_THUMBNAIL_QUALITY, "100");
-
- p.set(CameraParameters::KEY_ROTATION, 0);
- p.set(CameraParameters::KEY_WHITE_BALANCE, CameraParameters::WHITE_BALANCE_AUTO);
+ // These values must be multiples of 16, so we can't do 427x320, which is the exact size on
+ // screen we want to display at. 480x360 doesn't work either since it's a multiple of 8.
+ p.set(CameraParameters::KEY_JPEG_THUMBNAIL_WIDTH, "160");
+ p.set(CameraParameters::KEY_JPEG_THUMBNAIL_HEIGHT, "120");
+ p.set(CameraParameters::KEY_JPEG_THUMBNAIL_QUALITY, "100");
+
+ p.set(CameraParameters::KEY_ROTATION, 0);
+ p.set(CameraParameters::KEY_WHITE_BALANCE, CameraParameters::WHITE_BALANCE_AUTO);
#ifdef SWP1_CAMERA_ADD_ADVANCED_FUNCTION
- p.set(CameraParameters::KEY_EFFECT, CameraParameters::EFFECT_NONE);
- p.set(CameraParameters::KEY_SCENE_MODE, CameraParameters::SCENE_MODE_AUTO);
- p.set("vintagemode", "off");
- p.set("sharpness", 2);
- p.set("contrast", 2);
- p.set("saturation", 2);
- p.set("iso", "auto");
- p.set("metering", "center");
- //p.set("facedetect", 0);
- p.set(CameraParameters::KEY_FLASH_MODE, CameraParameters::FLASH_MODE_OFF);
- p.set(CameraParameters::KEY_FOCUS_MODE, CameraParameters::FOCUS_MODE_AUTO);
- p.set("anti-shake", 0);
- p.set("wdr", 0);
- p.set("smart-auto",0);
- p.set("beauty-shot", 0);
- p.set(CameraParameters::KEY_ANTIBANDING, CameraParameters::ANTIBANDING_AUTO);
- p.set("video_recording_gamma", "off");
- p.set("slow_ae", "off");
- p.set("vtmode", 0);
- p.set("chk_dataline", 0);
- p.set("blur", 0);
+ p.set(CameraParameters::KEY_EFFECT, CameraParameters::EFFECT_NONE);
+ p.set(CameraParameters::KEY_SCENE_MODE, CameraParameters::SCENE_MODE_AUTO);
+ p.set("vintagemode", "off");
+ p.set("sharpness", 2);
+ p.set("contrast", 2);
+ p.set("saturation", 2);
+ p.set("iso", "auto");
+ p.set("metering", "center");
+ p.set(CameraParameters::KEY_FLASH_MODE, CameraParameters::FLASH_MODE_OFF);
+ p.set(CameraParameters::KEY_FOCUS_MODE, CameraParameters::FOCUS_MODE_AUTO);
+ p.set("anti-shake", 0);
+ p.set("wdr", 0);
+ p.set("smart-auto",0);
+ p.set("beauty-shot", 0);
+ p.set(CameraParameters::KEY_ANTIBANDING, CameraParameters::ANTIBANDING_AUTO);
+ p.set("video_recording_gamma", "off");
+ p.set("slow_ae", "off");
+ p.set("vtmode", 0);
+ p.set("chk_dataline", 0);
+ p.set("blur", 0);
#else
- p.set("image-effects", "original");
+ p.set("image-effects", "original");
#endif
- p.set(CameraParameters::KEY_ZOOM, "0");
- p.set(CameraParameters::KEY_ZOOM_SUPPORTED, CameraParameters::TRUE);
- p.set(CameraParameters::KEY_MAX_ZOOM, "12");
- p.set(CameraParameters::KEY_ZOOM_RATIOS,
- "100,125,150,175,200,225,250,275,300,324,350,375,400");
+ p.set(CameraParameters::KEY_ZOOM, "0");
+ p.set(CameraParameters::KEY_ZOOM_SUPPORTED, CameraParameters::TRUE);
+ p.set(CameraParameters::KEY_MAX_ZOOM, "12");
+ p.set(CameraParameters::KEY_ZOOM_RATIOS,
+ "100,125,150,175,200,225,250,275,300,324,350,375,400");
+
+ p.set(CameraParameters::KEY_FOCAL_LENGTH, "3.79");
- p.set(CameraParameters::KEY_FOCAL_LENGTH, "3.79");
+ p.set(CameraParameters::KEY_HORIZONTAL_VIEW_ANGLE, "51.2");
+ p.set(CameraParameters::KEY_VERTICAL_VIEW_ANGLE, "39.4");
- p.set(CameraParameters::KEY_HORIZONTAL_VIEW_ANGLE, "51.2");
- p.set(CameraParameters::KEY_VERTICAL_VIEW_ANGLE, "39.4");
+ p.set(CameraParameters::KEY_EXPOSURE_COMPENSATION, "0");
+ p.set(CameraParameters::KEY_MAX_EXPOSURE_COMPENSATION, "4");
+ p.set(CameraParameters::KEY_MIN_EXPOSURE_COMPENSATION, "-4");
+ p.set(CameraParameters::KEY_EXPOSURE_COMPENSATION_STEP, "0.5");
- p.set(CameraParameters::KEY_EXPOSURE_COMPENSATION, "0");
- p.set(CameraParameters::KEY_MAX_EXPOSURE_COMPENSATION, "4");
- p.set(CameraParameters::KEY_MIN_EXPOSURE_COMPENSATION, "-4");
- p.set(CameraParameters::KEY_EXPOSURE_COMPENSATION_STEP, "0.5");
+ p.set("AppShutterSound", 0);
- p.set("AppShutterSound", 0);
- if (setParameters(p) != NO_ERROR)
- {
- LOGE("ERR(%s):Fail on setParameters(p)", __func__);
- }
+ if (setParameters(p) != NO_ERROR) {
+ LOGE("ERR(%s):Fail on setParameters(p)", __func__);
+ }
}
CameraHardwareSec::~CameraHardwareSec()
{
- LOGV("%s()", __func__);
+ LOGV("%s()", __func__);
- mSecCamera->DeinitCamera();
+ mSecCamera->DeinitCamera();
- if(mRawHeap != NULL)
- mRawHeap.clear();
+ if (mRawHeap != NULL)
+ mRawHeap.clear();
- if(mJpegHeap != NULL)
- mJpegHeap.clear();
+ if (mJpegHeap != NULL)
+ mJpegHeap.clear();
- if(mPreviewHeap != NULL)
- mPreviewHeap.clear();
+ if (mPreviewHeap != NULL)
+ mPreviewHeap.clear();
- if(mRecordHeap != NULL)
- mRecordHeap.clear();
+ if (mRecordHeap != NULL)
+ mRecordHeap.clear();
#if defined(BOARD_USES_OVERLAY)
- if(mUseOverlay) {
- mOverlay->destroy();
- mUseOverlay = false;
- mOverlay = NULL;
- }
+ if(mUseOverlay) {
+ mOverlay->destroy();
+ mUseOverlay = false;
+ mOverlay = NULL;
+ }
#endif
- mSecCamera = NULL;
+ mSecCamera = NULL;
- singleton.clear();
+ singleton.clear();
}
sp<IMemoryHeap> CameraHardwareSec::getPreviewHeap() const
{
- return mPreviewHeap;
+ return mPreviewHeap;
}
sp<IMemoryHeap> CameraHardwareSec::getRawHeap() const
{
- return mRawHeap;
+ return mRawHeap;
}
//Kamat added: New code as per eclair framework
void CameraHardwareSec::setCallbacks(notify_callback notify_cb,
data_callback data_cb,
data_callback_timestamp data_cb_timestamp,
- void* user)
+ void *user)
{
Mutex::Autolock lock(mLock);
mNotifyCb = notify_cb;
@@ -427,373 +419,347 @@ bool CameraHardwareSec::msgTypeEnabled(int32_t msgType)
int CameraHardwareSec::previewThread()
{
- int index;
-
- index = mSecCamera->getPreview();
- if(index < 0)
- {
- LOGE("ERR(%s):Fail on SecCamera->getPreview()", __func__);
- return UNKNOWN_ERROR;
- }
-
- nsecs_t timestamp = systemTime(SYSTEM_TIME_MONOTONIC);
-
+ int index;
+
+ index = mSecCamera->getPreview();
+ if (index < 0) {
+ LOGE("ERR(%s):Fail on SecCamera->getPreview()", __func__);
+ return UNKNOWN_ERROR;
+ }
+
+ nsecs_t timestamp = systemTime(SYSTEM_TIME_MONOTONIC);
+
#ifdef PREVIEW_USING_MMAP
- int width, height, frame_size, offset;
- mSecCamera->getPreviewSize(&width, &height, &frame_size);
-
- offset = (frame_size+16)*index;
+ int width, height, frame_size, offset;
+
+ mSecCamera->getPreviewSize(&width, &height, &frame_size);
+
+ offset = (frame_size + 16) * index;
sp<MemoryBase> buffer = new MemoryBase(mPreviewHeap, offset, frame_size);
- unsigned int phyYAddr = mSecCamera->getPhyAddrY(index);
- unsigned int phyCAddr = mSecCamera->getPhyAddrC(index);
- if(phyYAddr == 0xffffffff || phyCAddr == 0xffffffff)
- {
- LOGE("ERR(%s):Fail on SecCamera. Invalid PhyAddr, Y addr = %0x C addr = %0x", __func__, phyYAddr, phyCAddr);
- return UNKNOWN_ERROR;
- }
- memcpy(static_cast<unsigned char *>(mPreviewHeap->base()) + (offset+frame_size ), &phyYAddr, 4);
- memcpy(static_cast<unsigned char *>(mPreviewHeap->base()) + (offset+frame_size+4), &phyCAddr, 4);
+ unsigned int phyYAddr = mSecCamera->getPhyAddrY(index);
+ unsigned int phyCAddr = mSecCamera->getPhyAddrC(index);
-#if defined(BOARD_USES_OVERLAY)
- if(mUseOverlay) {
- int ret;
+ if (phyYAddr == 0xffffffff || phyCAddr == 0xffffffff) {
+ LOGE("ERR(%s):Fail on SecCamera. Invalid PhyAddr, Y addr = %0x C addr = %0x",
+ __func__, phyYAddr, phyCAddr);
+ return UNKNOWN_ERROR;
+ }
+ memcpy(static_cast<unsigned char *>(mPreviewHeap->base()) + (offset + frame_size ), &phyYAddr, 4);
+ memcpy(static_cast<unsigned char *>(mPreviewHeap->base()) + (offset + frame_size + 4), &phyCAddr, 4);
- if ( buf_idx == 0 )
- buf_idx = 1;
- else
- buf_idx = 0;
+#if defined(BOARD_USES_OVERLAY)
+ if (mUseOverlay) {
+ int ret;
- memcpy(static_cast<unsigned char*>(mPreviewHeap->base()) + (offset+frame_size) + sizeof(phyYAddr) + sizeof(phyCAddr), &buf_idx, sizeof(buf_idx));
+ if (buf_idx == 0)
+ buf_idx = 1;
+ else
+ buf_idx = 0;
- ret = mOverlay->queueBuffer((void*)(static_cast<unsigned char *>(mPreviewHeap->base()) + (offset+frame_size)));
+ memcpy(static_cast<unsigned char*>(mPreviewHeap->base()) + offset + frame_size + sizeof(phyYAddr) + sizeof(phyCAddr),
+ &buf_idx, sizeof(buf_idx));
- if (ret == ALL_BUFFERS_FLUSHED) {
- goto OverlayEnd;
- } else if (ret == -1) {
- LOGE("ERR(%s):overlay queueBuffer fail", __func__);
- goto OverlayEnd;
- }
+ ret = mOverlay->queueBuffer((void*)(static_cast<unsigned char *>(mPreviewHeap->base()) + (offset + frame_size)));
- overlay_buffer_t overlay_buffer;
- ret = mOverlay->dequeueBuffer(&overlay_buffer);
+ if (ret == ALL_BUFFERS_FLUSHED) {
+ goto OverlayEnd;
+ } else if (ret == -1) {
+ LOGE("ERR(%s):overlay queueBuffer fail", __func__);
+ goto OverlayEnd;
+ }
- if (ret == ALL_BUFFERS_FLUSHED) {
- goto OverlayEnd;
- } else if (ret == -1) {
- LOGE("ERR(%s):overlay dequeueBuffer fail", __func__);
- goto OverlayEnd;
- }
+ overlay_buffer_t overlay_buffer;
+ ret = mOverlay->dequeueBuffer(&overlay_buffer);
- }
+ if (ret == ALL_BUFFERS_FLUSHED) {
+ goto OverlayEnd;
+ } else if (ret == -1) {
+ LOGE("ERR(%s):overlay dequeueBuffer fail", __func__);
+ goto OverlayEnd;
+ }
+ }
OverlayEnd:
#endif
#else
- unsigned int phyYAddr = mSecCamera->getPhyAddrY(index);
- unsigned int phyCAddr = mSecCamera->getPhyAddrC(index);
- if(phyYAddr == 0xffffffff || phyCAddr == 0xffffffff)
- {
- LOGE("ERR(%s):Fail on SecCamera getPhyAddr Y addr = %0x C addr = %0x", __func__, phyYAddr, phyCAddr);
- return UNKNOWN_ERROR;
- }
- struct ADDRS *addrs = (struct ADDRS *)mPreviewHeap->base();
-
- sp<MemoryBase> buffer = new MemoryBase(mPreviewHeap, index * sizeof(struct ADDRS), sizeof(struct ADDRS));
- addrs[index].addr_y = phyYAddr;
- addrs[index].addr_cbcr = phyCAddr;
+ unsigned int phyYAddr = mSecCamera->getPhyAddrY(index);
+ unsigned int phyCAddr = mSecCamera->getPhyAddrC(index);
+
+ if (phyYAddr == 0xffffffff || phyCAddr == 0xffffffff) {
+ LOGE("ERR(%s):Fail on SecCamera getPhyAddr Y addr = %0x C addr = %0x", __func__, phyYAddr, phyCAddr);
+ return UNKNOWN_ERROR;
+ }
+ struct addrs *addrs = (struct addrs *)mPreviewHeap->base();
+
+ sp<MemoryBase> buffer = new MemoryBase(mPreviewHeap, index * sizeof(struct addrs), sizeof(struct addrs));
+ addrs[index].addr_y = phyYAddr;
+ addrs[index].addr_cbcr = phyCAddr;
#endif //PREVIEW_USING_MMAP
- // Notify the client of a new frame. //Kamat --eclair
- if (mMsgEnabled & CAMERA_MSG_PREVIEW_FRAME)
- {
- mDataCb(CAMERA_MSG_PREVIEW_FRAME, buffer, mCallbackCookie);
- }
-// LOG_CAMERA_PREVIEW("previewThread: addr_y(0x%08X) addr_cbcr(0x%08X)", addrs[index].addr_y, addrs[index].addr_cbcr);
-
- if(mRecordRunning == true)
- {
+ // Notify the client of a new frame. //Kamat --eclair
+ if (mMsgEnabled & CAMERA_MSG_PREVIEW_FRAME) {
+ mDataCb(CAMERA_MSG_PREVIEW_FRAME, buffer, mCallbackCookie);
+ }
+
+ if (mRecordRunning == true) {
#ifdef SEND_YUV_RECORD_DATA
- int width, height, frame_size;
- unsigned char* virYAddr;
- unsigned char* virCAddr;
- mSecCamera->getPreviewSize(&width, &height, &frame_size);
- mSecCamera->getYUVBuffers(&virYAddr, &virCAddr, index);
- sp<MemoryBase> buffer = new MemoryBase(mRecordHeap, 0, frame_size);
- //memcpy(mRecordHeap->base(), (void*)virYAddr, width*height);
- //memcpy(mRecordHeap->base()+(width*height),(void*)virCAddr, width*height*0.5);
- memcpy(mRecordHeap->base(), (void*)virYAddr, ALIGN_TO_8KB(ALIGN_TO_128B(width) * ALIGN_TO_32B(height)));
- memcpy(mRecordHeap->base() + ALIGN_TO_8KB(ALIGN_TO_128B(width) * ALIGN_TO_32B(height)),(void*)virCAddr, ALIGN_TO_8KB(ALIGN_TO_128B(width) * ALIGN_TO_32B(height/2)));
+ int width, height, frame_size;
+ unsigned char *virYAddr;
+ unsigned char *virCAddr;
+
+ mSecCamera->getPreviewSize(&width, &height, &frame_size);
+ mSecCamera->getYUVBuffers(&virYAddr, &virCAddr, index);
+ sp<MemoryBase> buffer = new MemoryBase(mRecordHeap, 0, frame_size);
+ //memcpy(mRecordHeap->base(), (void*)virYAddr, width * height);
+ //memcpy(mRecordHeap->base() + (width*height),(void*)virCAddr, width * height * 0.5);
+ memcpy(mRecordHeap->base(), (void*)virYAddr, ALIGN_TO_8KB(ALIGN_TO_128B(width) * ALIGN_TO_32B(height)));
+ memcpy(mRecordHeap->base() + ALIGN_TO_8KB(ALIGN_TO_128B(width) * ALIGN_TO_32B(height)),
+ (void*)virCAddr, ALIGN_TO_8KB(ALIGN_TO_128B(width) * ALIGN_TO_32B(height / 2)));
#else
#ifdef DUAL_PORT_RECORDING
- int index = mSecCamera->getRecord();
- if(index < 0)
- {
- LOGE("ERR(%s):Fail on SecCamera->getRecord()", __func__);
- return UNKNOWN_ERROR;
- }
- unsigned int phyYAddr = mSecCamera->getRecPhyAddrY(index);
- unsigned int phyCAddr = mSecCamera->getRecPhyAddrC(index);
- if(phyYAddr == 0xffffffff || phyCAddr == 0xffffffff)
- {
- LOGE("ERR(%s):Fail on SecCamera getRectPhyAddr Y addr = %0x C addr = %0x", __func__, phyYAddr, phyCAddr);
- return UNKNOWN_ERROR;
- }
+ int index = mSecCamera->getRecord();
+
+ if (index < 0) {
+ LOGE("ERR(%s):Fail on SecCamera->getRecord()", __func__);
+ return UNKNOWN_ERROR;
+ }
+
+ unsigned int phyYAddr = mSecCamera->getRecPhyAddrY(index);
+ unsigned int phyCAddr = mSecCamera->getRecPhyAddrC(index);
+
+ if (phyYAddr == 0xffffffff || phyCAddr == 0xffffffff) {
+ LOGE("ERR(%s):Fail on SecCamera getRectPhyAddr Y addr = %0x C addr = %0x", __func__, phyYAddr, phyCAddr);
+ return UNKNOWN_ERROR;
+ }
#endif//DUAL_PORT_RECORDING
- struct ADDRS *addrs = (struct ADDRS *)mRecordHeap->base();
+ struct addrs *addrs = (struct addrs *)mRecordHeap->base();
- sp<MemoryBase> buffer = new MemoryBase(mRecordHeap, index * sizeof(struct ADDRS), sizeof(struct ADDRS));
- addrs[index].addr_y = phyYAddr;
- addrs[index].addr_cbcr = phyCAddr;
+ sp<MemoryBase> buffer = new MemoryBase(mRecordHeap, index * sizeof(struct addrs), sizeof(struct addrs));
+ addrs[index].addr_y = phyYAddr;
+ addrs[index].addr_cbcr = phyCAddr;
#endif
- // Notify the client of a new frame. //Kamat --eclair
- if (mMsgEnabled & CAMERA_MSG_VIDEO_FRAME)
- {
- //nsecs_t timestamp = systemTime(SYSTEM_TIME_MONOTONIC);
- mDataCbTimestamp(timestamp, CAMERA_MSG_VIDEO_FRAME, buffer, mCallbackCookie);
- }
- }
+ // Notify the client of a new frame. //Kamat --eclair
+ if (mMsgEnabled & CAMERA_MSG_VIDEO_FRAME) {
+ //nsecs_t timestamp = systemTime(SYSTEM_TIME_MONOTONIC);
+ mDataCbTimestamp(timestamp, CAMERA_MSG_VIDEO_FRAME, buffer, mCallbackCookie);
+ }
#ifdef DUAL_PORT_RECORDING
- else if(mRecordRunning == false)
- {
- if(mSecCamera->stopRecord() < 0)
- {
- LOGE("ERR(%s):Fail on mSecCamera->stopRecord()", __func__);
- return UNKNOWN_ERROR;
- }
- }
+ } else if (mRecordRunning == false) {
+ if (mSecCamera->stopRecord() < 0) {
+ LOGE("ERR(%s):Fail on mSecCamera->stopRecord()", __func__);
+ return UNKNOWN_ERROR;
+ }
#endif
+ }
-// buffer.clear();
-
- // Wait for it...
- if(mTimeStart.tv_sec == 0 && mTimeStart.tv_usec == 0)
- {
- gettimeofday(&mTimeStart, NULL);
- } else
- {
- gettimeofday(&mTimeStop, NULL);
- long time = measure_time(&mTimeStart, &mTimeStop);
+ // Wait for it...
+ if (mTimeStart.tv_sec == 0 && mTimeStart.tv_usec == 0) {
+ gettimeofday(&mTimeStart, NULL);
+ } else {
+ gettimeofday(&mTimeStop, NULL);
+ long time = measure_time(&mTimeStart, &mTimeStop);
+ int delay = (mPreviewFrameRateMicrosec > time) ? mPreviewFrameRateMicrosec - time : 0;
- int delay = (mPreviewFrameRateMicrosec > time) ? mPreviewFrameRateMicrosec - time : 0;
- usleep(delay);
- //LOG_CAMERA_PREVIEW("delay = %d time = %ld us\n ", delay, time);
- gettimeofday(&mTimeStart, NULL);
- }
+ usleep(delay);
+ //LOG_CAMERA_PREVIEW("delay = %d time = %ld us\n ", delay, time);
+ gettimeofday(&mTimeStart, NULL);
+ }
- return NO_ERROR;
+ return NO_ERROR;
}
status_t CameraHardwareSec::startPreview()
{
- int ret = 0; //s1 [Apply factory standard]
-
- LOGE("%s()", __func__);
-
- Mutex::Autolock lock(mLock);
- if (mPreviewThread != 0) {
- // already running
- return INVALID_OPERATION;
- }
-
- memset(&mTimeStart, 0, sizeof(mTimeStart));
- memset(&mTimeStop, 0, sizeof(mTimeStop));
-
- mSecCamera->stopPreview();
-
-#if 1 //s1 [Apply factory standard]
- ret = mSecCamera->startPreview();
- LOGE("%s : return startPreview %d", __func__, ret);
-
- if(ret < 0)
-#else
- if(mSecCamera->startPreview() < 0)
-#endif
- {
- LOGE("ERR(%s):Fail on mSecCamera->startPreview()", __func__);
- if (mMsgEnabled & CAMERA_MSG_ERROR)
- {
- mNotifyCb(CAMERA_MSG_ERROR, -2, 0, mCallbackCookie);
- }
- return -1; //UNKNOWN_ERROR;
- }
+ int ret = 0; //s1 [Apply factory standard]
+
+ LOGE("%s()", __func__);
+
+ Mutex::Autolock lock(mLock);
+ if (mPreviewThread != 0) {
+ // already running
+ return INVALID_OPERATION;
+ }
+
+ memset(&mTimeStart, 0, sizeof(mTimeStart));
+ memset(&mTimeStop, 0, sizeof(mTimeStop));
+
+ mSecCamera->stopPreview();
+
+ ret = mSecCamera->startPreview();
+ LOGE("%s : return startPreview %d", __func__, ret);
+
+ if (ret < 0) {
+ LOGE("ERR(%s):Fail on mSecCamera->startPreview()", __func__);
+ if (mMsgEnabled & CAMERA_MSG_ERROR) {
+ mNotifyCb(CAMERA_MSG_ERROR, -2, 0, mCallbackCookie);
+ }
+ return -1; //UNKNOWN_ERROR;
+ }
#ifdef PREVIEW_USING_MMAP
- if(mPreviewHeap != NULL)
- mPreviewHeap.clear();
- int width, height, frame_size;
- mSecCamera->getPreviewSize(&width, &height, &frame_size);
- int previewHeapSize = (frame_size+16) * kBufferCount;
- LOGD("MemoryHeapBase(fd(%d), size(%d), width(%d), height(%d))", (int)mSecCamera->getCameraFd(), (size_t)(previewHeapSize), width, height);
- mPreviewHeap = new MemoryHeapBase((int)mSecCamera->getCameraFd(), (size_t)(previewHeapSize), (uint32_t)0);
+ if (mPreviewHeap != NULL)
+ mPreviewHeap.clear();
+
+ int width, height, frame_size;
+
+ mSecCamera->getPreviewSize(&width, &height, &frame_size);
+
+ int previewHeapSize = (frame_size + 16) * kBufferCount;
+
+ LOGD("MemoryHeapBase(fd(%d), size(%d), width(%d), height(%d))", (int)mSecCamera->getCameraFd(), (size_t)(previewHeapSize), width, height);
+ mPreviewHeap = new MemoryHeapBase((int)mSecCamera->getCameraFd(), (size_t)(previewHeapSize), (uint32_t)0);
#endif
-#ifdef JPEG_FROM_SENSOR
- mSecCamera->getPostViewConfig(&mPostViewWidth, &mPostViewHeight, &mPostViewSize);
- LOGE("CameraHardwareSec: mPostViewWidth = %d mPostViewHeight = %d mPostViewSize = %d",mPostViewWidth,mPostViewHeight,mPostViewSize);
+#ifdef JPEG_FROM_SENSOR
+ mSecCamera->getPostViewConfig(&mPostViewWidth, &mPostViewHeight, &mPostViewSize);
+ LOGE("CameraHardwareSec: mPostViewWidth = %d mPostViewHeight = %d mPostViewSize = %d",mPostViewWidth,mPostViewHeight,mPostViewSize);
#endif
-
+
#ifdef DIRECT_DELIVERY_OF_POSTVIEW_DATA
- int rawHeapSize = mPostViewSize;
+ int rawHeapSize = mPostViewSize;
#else
- int rawHeapSize = sizeof(struct ADDRS_CAP);
+ int rawHeapSize = sizeof(struct addrs_cap);
#endif
- LOGE("CameraHardwareSec: mRawHeap : MemoryHeapBase(previewHeapSize(%d))", rawHeapSize);
- mRawHeap = new MemoryHeapBase(rawHeapSize);
- if (mRawHeap->getHeapID() < 0)
- {
- LOGE("ERR(%s): Raw heap creation fail", __func__);
- mRawHeap.clear();
- }
-
-#if 0
- mSecCamera->getPostViewConfig(&mPostViewWidth, &mPostViewHeight, &mPostViewSize);
- struct ADDRS_CAP *addrs = (struct ADDRS_CAP *)mRawHeap->base();
-
- LOGE("[5B 1] mPostViewWidth = %d mPostViewHeight = %d mPostViewSize = %d",mPostViewWidth,mPostViewHeight);
+ LOGE("CameraHardwareSec: mRawHeap : MemoryHeapBase(previewHeapSize(%d))", rawHeapSize);
+ mRawHeap = new MemoryHeapBase(rawHeapSize);
+ if (mRawHeap->getHeapID() < 0) {
+ LOGE("ERR(%s): Raw heap creation fail", __func__);
+ mRawHeap.clear();
+ }
- addrs[0].width = mPostViewWidth;
- addrs[0].height = mPostViewHeight;
-
-#endif
+ mPreviewRunning = true;
+ mPreviewThread = new PreviewThread(this);
- mPreviewRunning = true;
- mPreviewThread = new PreviewThread(this);
- return NO_ERROR;
+ return NO_ERROR;
}
#if defined(BOARD_USES_OVERLAY)
bool CameraHardwareSec::useOverlay()
{
- return true;
+ return true;
}
status_t CameraHardwareSec::setOverlay(const sp<Overlay> &overlay)
{
- LOGV("%s() : ", __func__);
+ LOGV("%s() : ", __func__);
- int overlayWidth = 0;
- int overlayHeight = 0;
- int overlayFrameSize = 0;
+ int overlayWidth = 0;
+ int overlayHeight = 0;
+ int overlayFrameSize = 0;
- if(overlay == NULL) {
- goto setOverlayFail;
- }
-
- if(overlay->getHandleRef()== NULL && mUseOverlay == true) {
- if(mOverlay != 0)
- mOverlay->destroy();
- mOverlay = NULL;
- mUseOverlay = false;
+ if (overlay == NULL) {
+ goto setOverlayFail;
+ }
- return NO_ERROR;
- }
+ if (overlay->getHandleRef()== NULL && mUseOverlay == true) {
+ if (mOverlay != 0)
+ mOverlay->destroy();
- if(overlay->getStatus() != NO_ERROR)
- {
- LOGE("ERR(%s):overlay->getStatus() fail", __func__);
- goto setOverlayFail;
- }
+ mOverlay = NULL;
+ mUseOverlay = false;
- mSecCamera->getPreviewSize(&overlayWidth, &overlayHeight, &overlayFrameSize);
+ return NO_ERROR;
+ }
- if(overlay->setCrop(0, 0, overlayWidth, overlayHeight) != NO_ERROR)
- {
- LOGE("ERR(%s)::(mOverlay->setCrop(0, 0, %d, %d) fail", __func__, overlayWidth, overlayHeight);
- goto setOverlayFail;
- }
+ if (overlay->getStatus() != NO_ERROR) {
+ LOGE("ERR(%s):overlay->getStatus() fail", __func__);
+ goto setOverlayFail;
+ }
- mOverlay = overlay;
- mUseOverlay = true;
+ mSecCamera->getPreviewSize(&overlayWidth, &overlayHeight, &overlayFrameSize);
- return NO_ERROR;
+ if (overlay->setCrop(0, 0, overlayWidth, overlayHeight) != NO_ERROR) {
+ LOGE("ERR(%s)::(mOverlay->setCrop(0, 0, %d, %d) fail", __func__, overlayWidth, overlayHeight);
+ goto setOverlayFail;
+ }
-setOverlayFail :
+ mOverlay = overlay;
+ mUseOverlay = true;
- if(mOverlay != 0)
- mOverlay->destroy();
- mOverlay = 0;
+ return NO_ERROR;
- mUseOverlay = false;
+setOverlayFail :
+ if (mOverlay != 0)
+ mOverlay->destroy();
+ mOverlay = 0;
- return UNKNOWN_ERROR;
+ mUseOverlay = false;
+ return UNKNOWN_ERROR;
}
#endif
void CameraHardwareSec::stopPreview()
{
- LOGV("%s()", __func__);
-
- sp<PreviewThread> previewThread;
+ LOGV("%s()", __func__);
- { // scope for the lock
- Mutex::Autolock lock(mLock);
- previewThread = mPreviewThread;
- }
+ sp<PreviewThread> previewThread;
- // don't hold the lock while waiting for the thread to quit
- if (previewThread != 0) {
- previewThread->requestExitAndWait();
- }
+ { // scope for the lock
+ Mutex::Autolock lock(mLock);
+ previewThread = mPreviewThread;
+ }
- Mutex::Autolock lock(mLock);
- mPreviewThread.clear();
+ // don't hold the lock while waiting for the thread to quit
+ if (previewThread != 0) {
+ previewThread->requestExitAndWait();
+ }
- if(!mNoHwHandle)
- if(mSecCamera->stopPreview() < 0)
- {
- LOGE("ERR(%s):Fail on mSecCamera->stopPreview()", __func__);
- }
+ Mutex::Autolock lock(mLock);
+ mPreviewThread.clear();
- mPreviewRunning = false;
+ if (!mNoHwHandle)
+ if (mSecCamera->stopPreview() < 0)
+ LOGE("ERR(%s):Fail on mSecCamera->stopPreview()", __func__);
+ mPreviewRunning = false;
}
-bool CameraHardwareSec::previewEnabled() {
- LOGV("%s() : %d", __func__, mPreviewThread != 0);
- return mPreviewThread != 0;
+bool CameraHardwareSec::previewEnabled()
+{
+ LOGV("%s() : %d", __func__, mPreviewThread != 0);
+ return mPreviewThread != 0;
}
// ---------------------------------------------------------------------------
status_t CameraHardwareSec::startRecording()
{
- LOGV("%s()", __func__);
+ LOGV("%s()", __func__);
#ifdef DUAL_PORT_RECORDING
- if(mSecCamera->startRecord() < 0)
- {
- LOGE("ERR(%s):Fail on mSecCamera->startRecord()", __func__);
- return UNKNOWN_ERROR;
+ if (mSecCamera->startRecord() < 0) {
+ LOGE("ERR(%s):Fail on mSecCamera->startRecord()", __func__);
+ return UNKNOWN_ERROR;
}
#endif
- mRecordRunning = true;
- return NO_ERROR;
+ mRecordRunning = true;
+ return NO_ERROR;
}
void CameraHardwareSec::stopRecording()
{
- LOGV("%s()", __func__);
+ LOGV("%s()", __func__);
- mRecordRunning = false;
+ mRecordRunning = false;
}
bool CameraHardwareSec::recordingEnabled()
{
- LOGV("%s()", __func__);
+ LOGV("%s()", __func__);
- return mRecordRunning;
+ return mRecordRunning;
}
void CameraHardwareSec::releaseRecordingFrame(const sp<IMemory>& mem)
{
- LOG_CAMERA_PREVIEW("%s()", __func__);
+ LOG_CAMERA_PREVIEW("%s()", __func__);
// ssize_t offset; size_t size;
-// sp<MemoryBase> mem1 = mem;
+// sp<MemoryBase> mem1 = mem;
// sp<MemoryHeapBase> heap = mem->getMemory(&offset, &size);
// sp<IMemoryHeap> heap = mem->getMemory(&offset, &size);
@@ -806,72 +772,70 @@ void CameraHardwareSec::releaseRecordingFrame(const sp<IMemory>& mem)
#ifdef SWP1_CAMERA_ADD_ADVANCED_FUNCTION
int CameraHardwareSec::smartautosceneThread()
{
+ mSmartautoscene_current_status = mSecCamera->getAutosceneStatus();
+
+ if (mSmartautoscene_current_status < 0) {
+ LOGE("ERR(%s):Fail on mSecCamera->getAutosceneStatus()", __func__);
+ return UNKNOWN_ERROR;
+ }
- mSmartautoscene_current_status = mSecCamera->getAutosceneStatus();
-
- if(mSmartautoscene_current_status < 0)
- {
- LOGE("ERR(%s):Fail on mSecCamera->getAutosceneStatus()", __func__);
- return UNKNOWN_ERROR;
- }
-
- if(mSmartautoscene_current_status != mSmartautoscene_previous_status)
- {
- //if (mMsgEnabled & CAMERA_MSG_SMARTAUTO_SCENE_STATUS)
- //mNotifyCb(CAMERA_MSG_SMARTAUTO_SCENE_STATUS, mSmartautoscene_current_status, 0, mCallbackCookie);
- LOGE("%s CAMERA_MSG_SMARTAUTO_SCENE_STATUS(%d) Callback!!!!!!!! ", __func__,mSmartautoscene_current_status);
- mSmartautoscene_previous_status = mSmartautoscene_current_status;
- }
- else
- {
- LOGE("%s current_status(%d) is same with previous_status(%d)", __func__,mSmartautoscene_current_status,mSmartautoscene_previous_status);
- }
- usleep(2000*1000); //2000ms delay
- LOGE("DELAY(2000ms)!!!!!!!");
- return NO_ERROR;
+ if (mSmartautoscene_current_status != mSmartautoscene_previous_status) {
+ //if (mMsgEnabled & CAMERA_MSG_SMARTAUTO_SCENE_STATUS)
+ //mNotifyCb(CAMERA_MSG_SMARTAUTO_SCENE_STATUS, mSmartautoscene_current_status, 0, mCallbackCookie);
+ LOGE("%s CAMERA_MSG_SMARTAUTO_SCENE_STATUS(%d) Callback!!!!!!!! ",
+ __func__,mSmartautoscene_current_status);
+ mSmartautoscene_previous_status = mSmartautoscene_current_status;
+ } else {
+ LOGE("%s current_status(%d) is same with previous_status(%d)",
+ __func__,mSmartautoscene_current_status,mSmartautoscene_previous_status);
+ }
+ usleep(2000 * 1000); //2000ms delay
+ LOGE("DELAY(2000ms)!!!!!!!");
+ return NO_ERROR;
}
status_t CameraHardwareSec::startSmartautoscene()
{
- LOGV("%s()", __func__);
-
-// Mutex::Autolock lock(mLock);
-
- if (mSmartautosceneThread != 0) {
- // already running
- return INVALID_OPERATION;
- }
-
- mSmartautosceneRunning = true;
- mSmartautosceneThread = new SmartautosceneThread(this);
- return NO_ERROR;
+ LOGV("%s()", __func__);
+
+// Mutex::Autolock lock(mLock);
+
+ if (mSmartautosceneThread != 0) {
+ // already running
+ return INVALID_OPERATION;
+ }
+
+ mSmartautosceneRunning = true;
+ mSmartautosceneThread = new SmartautosceneThread(this);
+ return NO_ERROR;
}
void CameraHardwareSec::stopSmartautoscene()
{
- LOGV("%s()", __func__);
-
- sp<SmartautosceneThread> smartautosceneThread;
+ LOGV("%s()", __func__);
- { // scope for the lock
-// Mutex::Autolock lock(mLock);
- smartautosceneThread = mSmartautosceneThread;
- }
+ sp<SmartautosceneThread> smartautosceneThread;
- // don't hold the lock while waiting for the thread to quit
- if (smartautosceneThread != 0) {
- smartautosceneThread->requestExitAndWait();
- }
+ { // scope for the lock
+// Mutex::Autolock lock(mLock);
+ smartautosceneThread = mSmartautosceneThread;
+ }
+
+ // don't hold the lock while waiting for the thread to quit
+ if (smartautosceneThread != 0) {
+ smartautosceneThread->requestExitAndWait();
+ }
-// Mutex::Autolock lock(mLock);
- mSmartautosceneThread.clear();
+// Mutex::Autolock lock(mLock);
+ mSmartautosceneThread.clear();
- mSmartautosceneRunning = false;
+ mSmartautosceneRunning = false;
}
-bool CameraHardwareSec::smartautosceneEnabled() {
- LOGV("%s() : %d", __func__, mSmartautosceneThread != 0);
- return mSmartautosceneThread != 0;
+bool CameraHardwareSec::smartautosceneEnabled()
+{
+ LOGV("%s() : %d", __func__, mSmartautosceneThread != 0);
+ return mSmartautosceneThread != 0;
}
#endif
@@ -879,75 +843,68 @@ bool CameraHardwareSec::smartautosceneEnabled() {
int CameraHardwareSec::beginAutoFocusThread(void *cookie)
{
- LOGV("%s()", __func__);
- CameraHardwareSec *c = (CameraHardwareSec *)cookie;
- return c->autoFocusThread();
+ LOGV("%s()", __func__);
+ CameraHardwareSec *c = (CameraHardwareSec *)cookie;
+ return c->autoFocusThread();
}
int CameraHardwareSec::autoFocusThread()
{
#ifdef SWP1_CAMERA_ADD_ADVANCED_FUNCTION
- int count =0;
- int af_status =0 ;
-#endif
-
- LOGV("%s()", __func__);
-// usleep(50000); // 1frame delay 50ms
- if(mSecCamera->setAutofocus() < 0)
- {
- LOGE("ERR(%s):Fail on mSecCamera->setAutofocus()", __func__);
- return UNKNOWN_ERROR;
- }
-
+ int count =0;
+ int af_status =0 ;
+#endif
+
+ LOGV("%s()", __func__);
+// usleep(50000); // 1frame delay 50ms
+ if (mSecCamera->setAutofocus() < 0) {
+ LOGE("ERR(%s):Fail on mSecCamera->setAutofocus()", __func__);
+ return UNKNOWN_ERROR;
+ }
+
#ifdef SWP1_CAMERA_ADD_ADVANCED_FUNCTION
-// usleep(10000);
- af_status = mSecCamera->getAutoFocusResult();
-
- if (af_status == 0x01)
- {
- LOGV("%s() AF Success!!", __func__);
- if (mMsgEnabled & CAMERA_MSG_FOCUS)
- mNotifyCb(CAMERA_MSG_FOCUS, true, 0, mCallbackCookie);
- }
- else if (af_status == 0x02)
- {
- LOGV("%s() AF Cancelled !!", __func__);
- if (mMsgEnabled & CAMERA_MSG_FOCUS)
- mNotifyCb(CAMERA_MSG_FOCUS, 0x02, 0, mCallbackCookie);
- }
- else
- {
- LOGV("%s() AF Fail !!", __func__);
- if (mMsgEnabled & CAMERA_MSG_FOCUS)
- mNotifyCb(CAMERA_MSG_FOCUS, false, 0, mCallbackCookie);
- }
+// usleep(10000);
+ af_status = mSecCamera->getAutoFocusResult();
+
+ if (af_status == 0x01) {
+ LOGV("%s() AF Success!!", __func__);
+ if (mMsgEnabled & CAMERA_MSG_FOCUS)
+ mNotifyCb(CAMERA_MSG_FOCUS, true, 0, mCallbackCookie);
+ } else if (af_status == 0x02) {
+ LOGV("%s() AF Cancelled !!", __func__);
+ if (mMsgEnabled & CAMERA_MSG_FOCUS)
+ mNotifyCb(CAMERA_MSG_FOCUS, 0x02, 0, mCallbackCookie);
+ } else {
+ LOGV("%s() AF Fail !!", __func__);
+ if (mMsgEnabled & CAMERA_MSG_FOCUS)
+ mNotifyCb(CAMERA_MSG_FOCUS, false, 0, mCallbackCookie);
+ }
#else
- if (mMsgEnabled & CAMERA_MSG_FOCUS)
- mNotifyCb(CAMERA_MSG_FOCUS, true, 0, mCallbackCookie);
-#endif
- return NO_ERROR;
+ if (mMsgEnabled & CAMERA_MSG_FOCUS)
+ mNotifyCb(CAMERA_MSG_FOCUS, true, 0, mCallbackCookie);
+#endif
+ return NO_ERROR;
}
status_t CameraHardwareSec::autoFocus()
{
- LOGV("%s()", __func__);
- Mutex::Autolock lock(mLock);
- if (createThread(beginAutoFocusThread, this) == false)
- return UNKNOWN_ERROR;
- return NO_ERROR;
+ LOGV("%s()", __func__);
+ Mutex::Autolock lock(mLock);
+ if (createThread(beginAutoFocusThread, this) == false)
+ return UNKNOWN_ERROR;
+ return NO_ERROR;
}
/* 2009.10.14 by icarus for added interface */
status_t CameraHardwareSec::cancelAutoFocus()
{
#ifdef SWP1_CAMERA_ADD_ADVANCED_FUNCTION
- LOGV("%s()", __func__);
-
- if(mSecCamera->cancelAutofocus() < 0)
- {
- LOGE("ERR(%s):Fail on mSecCamera->cancelAutofocus()", __func__);
- return UNKNOWN_ERROR;
- }
+ LOGV("%s()", __func__);
+
+ if (mSecCamera->cancelAutofocus() < 0) {
+ LOGE("ERR(%s):Fail on mSecCamera->cancelAutofocus()", __func__);
+ return UNKNOWN_ERROR;
+ }
#endif
return NO_ERROR;
}
@@ -955,256 +912,247 @@ status_t CameraHardwareSec::cancelAutoFocus()
#ifdef SWP1_CAMERA_ADD_ADVANCED_FUNCTION
status_t CameraHardwareSec::objectTracking(int onoff)
{
- LOGV("%s() onoff = %d", __func__, onoff);
-
- Mutex::Autolock lock(mLock);
- if(onoff)
- {
- if (mObjectTrackingThread == 0) {
- mObjectTrackingThread = new ObjectTrackingThread(this);
- }
- mObjectTrackingRunning=true;
- }
- else
- {
- if (mObjectTrackingThread != 0) {
- mObjectTrackingThread->requestExitAndWait();
- }
- mObjectTrackingThread.clear();
- mObjectTrackingRunning=false;
- }
- return 0;
+ LOGV("%s() onoff = %d", __func__, onoff);
+
+ Mutex::Autolock lock(mLock);
+ if (onoff) {
+ if (mObjectTrackingThread == 0) {
+ mObjectTrackingThread = new ObjectTrackingThread(this);
+ }
+ mObjectTrackingRunning=true;
+ } else {
+ if (mObjectTrackingThread != 0) {
+ mObjectTrackingThread->requestExitAndWait();
+ }
+ mObjectTrackingThread.clear();
+ mObjectTrackingRunning=false;
+ }
+ return 0;
}
-int CameraHardwareSec::save_jpeg( unsigned char * real_jpeg, int jpeg_size)
+int CameraHardwareSec::save_jpeg( unsigned char *real_jpeg, int jpeg_size)
{
- FILE *yuv_fp = NULL;
- char filename[100], *buffer = NULL;
+ FILE *yuv_fp = NULL;
+ char filename[100], *buffer = NULL;
+
+ /* file create/open, note to "wb" */
+ yuv_fp = fopen("/data/camera_dump.jpeg", "wb");
+ if (yuv_fp == NULL) {
+ LOGE("Save jpeg file open error");
+ return -1;
+ }
- /* file create/open, note to "wb" */
- yuv_fp = fopen("/data/camera_dump.jpeg", "wb");
- if (yuv_fp==NULL)
- {
- LOGE("Save jpeg file open error");
- return -1;
- }
+ LOGE("[BestIQ] real_jpeg size ========> %d\n", jpeg_size);
+ buffer = (char *) malloc(jpeg_size);
+ if (buffer == NULL) {
+ LOGE("Save YUV] buffer alloc failed");
+ if (yuv_fp)
+ fclose(yuv_fp);
- LOGE("[BestIQ] real_jpeg size ========> %d\n", jpeg_size);
- buffer = (char *) malloc(jpeg_size);
- if(buffer == NULL)
- {
- LOGE("Save YUV] buffer alloc failed");
- if(yuv_fp) fclose(yuv_fp);
- return -1;
- }
+ return -1;
+ }
- memcpy(buffer, real_jpeg, jpeg_size);
+ memcpy(buffer, real_jpeg, jpeg_size);
- fflush(stdout);
+ fflush(stdout);
- fwrite(buffer, 1, jpeg_size, yuv_fp);
+ fwrite(buffer, 1, jpeg_size, yuv_fp);
- fflush(yuv_fp);
+ fflush(yuv_fp);
- if(yuv_fp)
- fclose(yuv_fp);
- if(buffer)
- free(buffer);
+ if (yuv_fp)
+ fclose(yuv_fp);
+ if (buffer)
+ free(buffer);
- return 0;
+ return 0;
}
int CameraHardwareSec::objectTrackingThread()
{
- int new_obj_status;
- new_obj_status = mSecCamera->getObjectTrackingStatus();
+ int new_obj_status;
+
+ new_obj_status = mSecCamera->getObjectTrackingStatus();
#if 0 //temp till define callback msg
- if (mObjectTrackingStatus != new_obj_status)
- {
- mObjectTrackingStatus = new_obj_status;
- if (mMsgEnabled & CAMERA_MSG_OBJ_TRACKING)
- mNotifyCb(CAMERA_MSG_OBJ_TRACKING, new_obj_status, 0, mCallbackCookie);
- }
+ if (mObjectTrackingStatus != new_obj_status) {
+ mObjectTrackingStatus = new_obj_status;
+ if (mMsgEnabled & CAMERA_MSG_OBJ_TRACKING)
+ mNotifyCb(CAMERA_MSG_OBJ_TRACKING, new_obj_status, 0, mCallbackCookie);
+ }
#endif
- usleep(100000); //100ms
- return NO_ERROR;
+ usleep(100000); //100ms
+ return NO_ERROR;
}
#endif
/*static*/ int CameraHardwareSec::beginPictureThread(void *cookie)
{
- LOGV("%s()", __func__);
- CameraHardwareSec *c = (CameraHardwareSec *)cookie;
- return c->pictureThread();
+ LOGV("%s()", __func__);
+ CameraHardwareSec *c = (CameraHardwareSec *)cookie;
+ return c->pictureThread();
}
void CameraHardwareSec::save_postview(const char *fname, uint8_t *buf, uint32_t size)
{
- int nw, cnt = 0;
- uint32_t written = 0;
-
- LOGD("opening file [%s]\n", fname);
- int fd = open(fname, O_RDWR | O_CREAT);
- if (fd < 0) {
- LOGE("failed to create file [%s]: %s", fname, strerror(errno));
- return;
- }
-
- LOGD("writing %d bytes to file [%s]\n", size, fname);
- while (written < size) {
- nw = ::write(fd,
- buf + written,
- size - written);
- if (nw < 0) {
- LOGE("failed to write to file %d [%s]: %s",written,fname, strerror(errno));
- break;
- }
- written += nw;
- cnt++;
- }
- LOGD("done writing %d bytes to file [%s] in %d passes\n",size, fname, cnt);
- ::close(fd);
+ int nw;
+ int cnt = 0;
+ uint32_t written = 0;
+
+ LOGD("opening file [%s]\n", fname);
+ int fd = open(fname, O_RDWR | O_CREAT);
+ if (fd < 0) {
+ LOGE("failed to create file [%s]: %s", fname, strerror(errno));
+ return;
+ }
+
+ LOGD("writing %d bytes to file [%s]\n", size, fname);
+ while (written < size) {
+ nw = ::write(fd, buf + written, size - written);
+ if (nw < 0) {
+ LOGE("failed to write to file %d [%s]: %s",written,fname, strerror(errno));
+ break;
+ }
+ written += nw;
+ cnt++;
+ }
+ LOGD("done writing %d bytes to file [%s] in %d passes\n",size, fname, cnt);
+ ::close(fd);
}
int CameraHardwareSec::pictureThread()
{
- LOGV("%s()", __func__);
-
- int jpeg_size = 0;
- int ret = NO_ERROR;
- unsigned char * jpeg_data = NULL;
- int postview_offset = 0;
- unsigned char * postview_data = NULL;
-
- //unsigned int addr;
- unsigned char * addr = NULL;
- int mPostViewWidth, mPostViewHeight, mPostViewSize;
- int cap_width, cap_height, cap_frame_size;
-
- unsigned int output_size = 0;
-
- mSecCamera->getPostViewConfig(&mPostViewWidth, &mPostViewHeight, &mPostViewSize);
- int postviewHeapSize = mPostViewWidth*mPostViewHeight*2; //*size = (BACK_CAMERA_POSTVIEW_WIDTH * BACK_CAMERA_POSTVIEW_HEIGHT * BACK_CAMERA_POSTVIEW_BPP)/8;
- mSecCamera->getSnapshotSize(&cap_width, &cap_height, &cap_frame_size);
- LOGE("[kidggang]:func(%s):line(%d)&cap_width(%d), &cap_height(%d), &cap_frame_size(%d)\n",__func__,__LINE__,cap_width, cap_height, cap_frame_size);
-
-// sp<MemoryBase> buffer = new MemoryBase(mRawHeap, 0, postviewHeapSize);
-
- LOG_TIME_DEFINE(0)
- LOG_TIME_START(0)
+ LOGV("%s()", __func__);
+
+ int jpeg_size = 0;
+ int ret = NO_ERROR;
+ unsigned char *jpeg_data = NULL;
+ int postview_offset = 0;
+ unsigned char *postview_data = NULL;
+
+ //unsigned int addr;
+ unsigned char *addr = NULL;
+ int mPostViewWidth, mPostViewHeight, mPostViewSize;
+ int cap_width, cap_height, cap_frame_size;
+
+ unsigned int output_size = 0;
+
+ mSecCamera->getPostViewConfig(&mPostViewWidth, &mPostViewHeight, &mPostViewSize);
+ //*size = (BACK_CAMERA_POSTVIEW_WIDTH * BACK_CAMERA_POSTVIEW_HEIGHT * BACK_CAMERA_POSTVIEW_BPP) / 8;
+ int postviewHeapSize = mPostViewWidth * mPostViewHeight * 2;
+ mSecCamera->getSnapshotSize(&cap_width, &cap_height, &cap_frame_size);
+ LOGE("[kidggang]:func(%s):line(%d)&cap_width(%d), &cap_height(%d), &cap_frame_size(%d)\n",
+ __func__,__LINE__,cap_width, cap_height, cap_frame_size);
+
+// sp<MemoryBase> buffer = new MemoryBase(mRawHeap, 0, postviewHeapSize);
+
+ LOG_TIME_DEFINE(0)
+ LOG_TIME_START(0)
#ifdef DIRECT_DELIVERY_OF_POSTVIEW_DATA
- sp<MemoryBase> buffer = new MemoryBase(mRawHeap, 0, mPostViewSize+8);
+ sp<MemoryBase> buffer = new MemoryBase(mRawHeap, 0, mPostViewSize + 8);
#else
- sp<MemoryBase> buffer = new MemoryBase(mRawHeap, 0, sizeof(struct ADDRS_CAP));
+ sp<MemoryBase> buffer = new MemoryBase(mRawHeap, 0, sizeof(struct addrs_cap));
#endif
- struct ADDRS_CAP *addrs = (struct ADDRS_CAP *)mRawHeap->base();
+ struct addrs_cap *addrs = (struct addrs_cap *)mRawHeap->base();
#ifdef JPEG_FROM_SENSOR
- addrs[0].width = mPostViewWidth;
- addrs[0].height = mPostViewHeight;
- LOGV("[5B] mPostViewWidth = %d mPostViewHeight = %d\n",mPostViewWidth,mPostViewHeight);
+ addrs[0].width = mPostViewWidth;
+ addrs[0].height = mPostViewHeight;
+ LOGV("[5B] mPostViewWidth = %d mPostViewHeight = %d\n",mPostViewWidth,mPostViewHeight);
#else
- mParameters.getPictureSize((int*)&addrs[0].width, (int*)&addrs[0].height);
+ mParameters.getPictureSize((int*)&addrs[0].width, (int*)&addrs[0].height);
#endif
- if (mSecCamera->getCameraId() == SecCamera::CAMERA_ID_BACK) { //[zzangdol] CAMERA_ID_BACK
+ if (mSecCamera->getCameraId() == SecCamera::CAMERA_ID_BACK) { //[zzangdol] CAMERA_ID_BACK
#ifndef SWP1_CAMERA_ADD_ADVANCED_FUNCTION
- if (mMsgEnabled & CAMERA_MSG_SHUTTER)
- {
- mNotifyCb(CAMERA_MSG_SHUTTER, 0, 0, mCallbackCookie);
- }
+ if (mMsgEnabled & CAMERA_MSG_SHUTTER) {
+ mNotifyCb(CAMERA_MSG_SHUTTER, 0, 0, mCallbackCookie);
+ }
#endif
- }//[zzangdol]CAMERA_ID_BACK
+ }//[zzangdol]CAMERA_ID_BACK
- if (mMsgEnabled & CAMERA_MSG_RAW_IMAGE)
- {
- LOG_TIME_DEFINE(1)
- LOG_TIME_START(1)
+ if (mMsgEnabled & CAMERA_MSG_RAW_IMAGE) {
+ LOG_TIME_DEFINE(1)
+ LOG_TIME_START(1)
- int picture_size, picture_width, picture_height;
- mSecCamera->getSnapshotSize(&picture_width, &picture_height, &picture_size);
- int picture_format = mSecCamera->getSnapshotPixelFormat();
+ int picture_size, picture_width, picture_height;
+ mSecCamera->getSnapshotSize(&picture_width, &picture_height, &picture_size);
+ int picture_format = mSecCamera->getSnapshotPixelFormat();
- unsigned int phyAddr;
+ unsigned int phyAddr;
#ifdef JPEG_FROM_SENSOR
- // Modified the shutter sound timing for Jpeg capture
- if (mSecCamera->getCameraId() == SecCamera::CAMERA_ID_BACK)
- mSecCamera->setSnapshotCmd();
+ // Modified the shutter sound timing for Jpeg capture
+ if (mSecCamera->getCameraId() == SecCamera::CAMERA_ID_BACK)
+ mSecCamera->setSnapshotCmd();
#ifdef SWP1_CAMERA_ADD_ADVANCED_FUNCTION
- if (mMsgEnabled & CAMERA_MSG_SHUTTER)
- {
- mNotifyCb(CAMERA_MSG_SHUTTER, 0, 0, mCallbackCookie);
- }
+ if (mMsgEnabled & CAMERA_MSG_SHUTTER) {
+ mNotifyCb(CAMERA_MSG_SHUTTER, 0, 0, mCallbackCookie);
+ }
#endif
- if (mSecCamera->getCameraId() == SecCamera::CAMERA_ID_BACK){ //[zzangdol] CAMERA_ID_BACK
- jpeg_data = mSecCamera->getJpeg(&jpeg_size, &phyAddr);
- if(jpeg_data == NULL)
- {
- LOGE("ERR(%s):Fail on SecCamera->getSnapshot()", __func__);
- ret = UNKNOWN_ERROR;
- }
- }//[zzangdol] CAMERA_ID_BACK
- else
- {
- addr = mSecCamera->getSnapshotAndJpeg(&output_size);
- //LOGV("[zzangdol] getSnapshotAndJpeg\n");
- }
+ if (mSecCamera->getCameraId() == SecCamera::CAMERA_ID_BACK){ //[zzangdol] CAMERA_ID_BACK
+ jpeg_data = mSecCamera->getJpeg(&jpeg_size, &phyAddr);
+ if (jpeg_data == NULL) {
+ LOGE("ERR(%s):Fail on SecCamera->getSnapshot()", __func__);
+ ret = UNKNOWN_ERROR;
+ }
+ } else {
+ addr = mSecCamera->getSnapshotAndJpeg(&output_size);
+ //LOGV("[zzangdol] getSnapshotAndJpeg\n");
+ }
#else
- phyAddr = mSecCamera->getSnapshotAndJpeg();
- jpeg_data = mSecCamera->yuv2Jpeg((unsigned char*)phyAddr, 0, &jpeg_size, picture_width, picture_height, picture_format);
+ phyAddr = mSecCamera->getSnapshotAndJpeg();
+ jpeg_data = mSecCamera->yuv2Jpeg((unsigned char*)phyAddr, 0, &jpeg_size,
+ picture_width, picture_height, picture_format);
#endif
-
-#ifdef DIRECT_DELIVERY_OF_POSTVIEW_DATA
- postview_offset = mSecCamera->getPostViewOffset();
- if(jpeg_data != NULL)
- memcpy(mRawHeap->base(), jpeg_data+postview_offset, mPostViewSize);
+
+#ifdef DIRECT_DELIVERY_OF_POSTVIEW_DATA
+ postview_offset = mSecCamera->getPostViewOffset();
+ if (jpeg_data != NULL)
+ memcpy(mRawHeap->base(), jpeg_data + postview_offset, mPostViewSize);
#else
- addrs[0].addr_y = phyAddr;
+ addrs[0].addr_y = phyAddr;
#endif
-
- LOG_TIME_END(1)
- LOG_CAMERA("getSnapshotAndJpeg interval: %lu us", LOG_TIME(1));
- }
+
+ LOG_TIME_END(1)
+ LOG_CAMERA("getSnapshotAndJpeg interval: %lu us", LOG_TIME(1));
+ }
int JpegImageSize, JpegExifSize;
+
sp<MemoryHeapBase> PostviewHeap = new MemoryHeapBase(mPostViewSize);
sp<MemoryHeapBase> JpegHeap = new MemoryHeapBase(4300000);
- decodeInterleaveData(jpeg_data, 4261248, mPostViewWidth, mPostViewHeight,
+ decodeInterleaveData(jpeg_data, 4261248, mPostViewWidth, mPostViewHeight,
&JpegImageSize, JpegHeap->base(), PostviewHeap->base());
- sp<MemoryBase> postview = new MemoryBase(PostviewHeap, 0, postviewHeapSize);
- memcpy(mRawHeap->base(),PostviewHeap->base(), postviewHeapSize);
- if (mMsgEnabled & CAMERA_MSG_RAW_IMAGE)
- {
- mDataCb(CAMERA_MSG_RAW_IMAGE, buffer, mCallbackCookie);
- }
+ sp<MemoryBase> postview = new MemoryBase(PostviewHeap, 0, postviewHeapSize);
+ memcpy(mRawHeap->base(),PostviewHeap->base(), postviewHeapSize);
+ if (mMsgEnabled & CAMERA_MSG_RAW_IMAGE) {
+ mDataCb(CAMERA_MSG_RAW_IMAGE, buffer, mCallbackCookie);
+ }
#if 0//def SWP1_CAMERA_ADD_ADVANCED_FUNCTION
- if (mMsgEnabled & CAMERA_MSG_POSTVIEW_FRAME)
- {
- int postviewHeapSize = mPostViewSize;
- sp<MemoryHeapBase> mPostviewHeap = new MemoryHeapBase(postviewHeapSize);
+ if (mMsgEnabled & CAMERA_MSG_POSTVIEW_FRAME) {
+ int postviewHeapSize = mPostViewSize;
+ sp<MemoryHeapBase> mPostviewHeap = new MemoryHeapBase(postviewHeapSize);
- postview_data = jpeg_data + postview_offset;
- sp<MemoryBase> postview = new MemoryBase(mPostviewHeap, 0, postviewHeapSize);
+ postview_data = jpeg_data + postview_offset;
+ sp<MemoryBase> postview = new MemoryBase(mPostviewHeap, 0, postviewHeapSize);
- if(postview_data != NULL)
- memcpy(mPostviewHeap->base(), postview_data, postviewHeapSize);
+ if (postview_data != NULL)
+ memcpy(mPostviewHeap->base(), postview_data, postviewHeapSize);
- mDataCb(CAMERA_MSG_POSTVIEW_FRAME, postview, mCallbackCookie);
- }
+ mDataCb(CAMERA_MSG_POSTVIEW_FRAME, postview, mCallbackCookie);
+ }
#endif //#ifdef SWP1_CAMERA_ADD_ADVANCED_FUNCTION
- if (mMsgEnabled & CAMERA_MSG_COMPRESSED_IMAGE)
- {
- if (mSecCamera->getCameraId() == SecCamera::CAMERA_ID_BACK){
- const int EXIF_FILE_SIZE = 28800;
- const int JPG_STREAM_BUF_SIZE = 3145728;
+ if (mMsgEnabled & CAMERA_MSG_COMPRESSED_IMAGE) {
+ if (mSecCamera->getCameraId() == SecCamera::CAMERA_ID_BACK) {
+ const int EXIF_FILE_SIZE = 28800;
+ const int JPG_STREAM_BUF_SIZE = 3145728;
sp<MemoryHeapBase> ExifHeap = new MemoryHeapBase(EXIF_FILE_SIZE + JPG_STREAM_BUF_SIZE);
- JpegExifSize = mSecCamera->getExif((unsigned char *)ExifHeap->base(),
+ JpegExifSize = mSecCamera->getExif ((unsigned char *)ExifHeap->base(),
(unsigned char *)PostviewHeap->base());
LOGE("JpegExifSize=%d", JpegExifSize);
@@ -1216,37 +1164,35 @@ int CameraHardwareSec::pictureThread()
sp<MemoryBase> mem = new MemoryBase(JpegHeap, 0, JpegImageSize + JpegExifSize);
mDataCb(CAMERA_MSG_COMPRESSED_IMAGE, mem, mCallbackCookie);
- }//[zzangdol] CAMERA_ID_BACK
- else
- {
- LOGV("[zzangdol] COMPRESSED_IMAGE\n");
- //mSecCamera->getSnapshotSize(&cap_width, &cap_height, &cap_frame_size);
- //sp<MemoryHeapBase> mHeap = new MemoryHeapBase((int)mSecCamera->getCameraFd(), (size_t)(cap_frame_size * kBufferCount), (uint32_t)0);
- sp<MemoryHeapBase> mHeap = new MemoryHeapBase(2000000);
- memcpy(mHeap->base(), addr, cap_frame_size);
- sp<MemoryBase> mem = new MemoryBase(mHeap , 0, cap_frame_size);
- //save_postview("/data/front.yuv", (uint8_t *)mHeap->base(), yuv_frame_size2);
- mDataCb(CAMERA_MSG_COMPRESSED_IMAGE, mem, mCallbackCookie);//[zzangdol]
- }
- }
-
- LOG_TIME_END(0)
- LOG_CAMERA("pictureThread interval: %lu us", LOG_TIME(0));
-
- return ret;
+ } else {
+ LOGV("[zzangdol] COMPRESSED_IMAGE\n");
+ //mSecCamera->getSnapshotSize(&cap_width, &cap_height, &cap_frame_size);
+ //sp<MemoryHeapBase> mHeap = new MemoryHeapBase((int)mSecCamera->getCameraFd(), (size_t)(cap_frame_size * kBufferCount), (uint32_t)0);
+ sp<MemoryHeapBase> mHeap = new MemoryHeapBase(2000000);
+ memcpy(mHeap->base(), addr, cap_frame_size);
+ sp<MemoryBase> mem = new MemoryBase(mHeap , 0, cap_frame_size);
+ //save_postview("/data/front.yuv", (uint8_t *)mHeap->base(), yuv_frame_size2);
+ mDataCb(CAMERA_MSG_COMPRESSED_IMAGE, mem, mCallbackCookie);//[zzangdol]
+ }
+ }
+
+ LOG_TIME_END(0)
+ LOG_CAMERA("pictureThread interval: %lu us", LOG_TIME(0));
+
+ return ret;
}
status_t CameraHardwareSec::takePicture()
{
- LOGV("%s()", __func__);
+ LOGV("%s()", __func__);
- stopPreview();
- mNoHwHandle = 0;
+ stopPreview();
+ mNoHwHandle = 0;
- if (createThread(beginPictureThread, this) == false)
- return -1;
+ if (createThread(beginPictureThread, this) == false)
+ return -1;
- return NO_ERROR;
+ return NO_ERROR;
}
status_t CameraHardwareSec::cancelPicture()
@@ -1255,15 +1201,15 @@ status_t CameraHardwareSec::cancelPicture()
}
int CameraHardwareSec::decodeInterleaveData(unsigned char *pInterleaveData,
- int interleaveDataSize,
- int yuvWidth,
- int yuvHeight,
- int *pJpegSize,
- void *pJpegData,
- void *pYuvData)
+ int interleaveDataSize,
+ int yuvWidth,
+ int yuvHeight,
+ int *pJpegSize,
+ void *pJpegData,
+ void *pYuvData)
{
- if (pInterleaveData == NULL)
- return false;
+ if (pInterleaveData == NULL)
+ return false;
bool ret = true;
unsigned int *interleave_ptr = (unsigned int *)pInterleaveData;
@@ -1273,78 +1219,75 @@ int CameraHardwareSec::decodeInterleaveData(unsigned char *pInterleaveData,
int jpeg_size = 0;
int yuv_size = 0;
- int i = 0;
+ int i = 0;
- LOGE("decodeInterleaveData Start~~~");
- while(i < interleaveDataSize) {
- if ((*interleave_ptr == 0xFFFFFFFF) ||
- (*interleave_ptr == 0x02FFFFFF) ||
- (*interleave_ptr == 0xFF02FFFF)) {
- // Padding Data
+ LOGE("decodeInterleaveData Start~~~");
+ while (i < interleaveDataSize) {
+ if ((*interleave_ptr == 0xFFFFFFFF) || (*interleave_ptr == 0x02FFFFFF) ||
+ (*interleave_ptr == 0xFF02FFFF)) {
+ // Padding Data
// LOGE("%d(%x) padding data\n", i, *interleave_ptr);
- interleave_ptr++;
- i += 4;
- }
+ interleave_ptr++;
+ i += 4;
+ }
else if ((*interleave_ptr & 0xFFFF) == 0x05FF) {
- // Start-code of YUV Data
+ // Start-code of YUV Data
// LOGE("%d(%x) yuv data\n", i, *interleave_ptr);
- p = (unsigned char *)interleave_ptr;
- p += 2;
- i += 2;
-
- // Extract YUV Data
- if (pYuvData != NULL) {
- memcpy(yuv_ptr, p, yuvWidth * 2);
- yuv_ptr += yuvWidth * 2;
- yuv_size += yuvWidth * 2;
- }
- p += yuvWidth * 2;
- i += yuvWidth * 2;
-
- // Check End-code of YUV Data
- if ((*p == 0xFF) && (*(p + 1) == 0x06)) {
- interleave_ptr = (unsigned int *)(p + 2);
- i += 2;
- } else {
- ret = false;
- break;
- }
-
- }
- else {
- // Extract JPEG Data
+ p = (unsigned char *)interleave_ptr;
+ p += 2;
+ i += 2;
+
+ // Extract YUV Data
+ if (pYuvData != NULL) {
+ memcpy(yuv_ptr, p, yuvWidth * 2);
+ yuv_ptr += yuvWidth * 2;
+ yuv_size += yuvWidth * 2;
+ }
+ p += yuvWidth * 2;
+ i += yuvWidth * 2;
+
+ // Check End-code of YUV Data
+ if ((*p == 0xFF) && (*(p + 1) == 0x06)) {
+ interleave_ptr = (unsigned int *)(p + 2);
+ i += 2;
+ } else {
+ ret = false;
+ break;
+ }
+ } else {
+ // Extract JPEG Data
// LOGE("%d(%x) jpg data, jpeg_size = %d bytes\n", i, *interleave_ptr, jpeg_size);
- if (pJpegData != NULL) {
- memcpy(jpeg_ptr, interleave_ptr, 4);
- jpeg_ptr += 4;
- jpeg_size += 4;
- }
- interleave_ptr++;
- i += 4;
- }
- }
- if (ret) {
- if (pJpegData != NULL) {
- // Remove Padding after EOI
- for (i=0; i<3; i++) {
- if (*(--jpeg_ptr) != 0xFF) {
- break;
- }
- jpeg_size--;
- }
- *pJpegSize = jpeg_size;
-
- }
- // Check YUV Data Size
- if (pYuvData != NULL) {
- if (yuv_size != (yuvWidth * yuvHeight * 2)) {
- ret = false;
- }
- }
- }
- LOGE("decodeInterleaveData End~~~");
- return ret;
-}
+ if (pJpegData != NULL) {
+ memcpy(jpeg_ptr, interleave_ptr, 4);
+ jpeg_ptr += 4;
+ jpeg_size += 4;
+ }
+ interleave_ptr++;
+ i += 4;
+ }
+ }
+ if (ret) {
+ if (pJpegData != NULL) {
+ // Remove Padding after EOI
+ for (i = 0; i < 3; i++) {
+ if (*(--jpeg_ptr) != 0xFF) {
+ break;
+ }
+ jpeg_size--;
+ }
+ *pJpegSize = jpeg_size;
+
+ }
+ // Check YUV Data Size
+ if (pYuvData != NULL) {
+ if (yuv_size != (yuvWidth * yuvHeight * 2)) {
+ ret = false;
+ }
+ }
+ }
+ LOGE("decodeInterleaveData End~~~");
+ return ret;
+}
status_t CameraHardwareSec::dump(int fd, const Vector<String16>& args) const
{
@@ -1352,6 +1295,7 @@ status_t CameraHardwareSec::dump(int fd, const Vector<String16>& args) const
char buffer[SIZE];
String8 result;
AutoMutex lock(&mLock);
+
if (mSecCamera != 0) {
mSecCamera->dump(fd, args);
mParameters.dump(fd, args);
@@ -1366,1145 +1310,1026 @@ status_t CameraHardwareSec::dump(int fd, const Vector<String16>& args) const
status_t CameraHardwareSec::setParameters(const CameraParameters& params)
{
- LOGV("%s()", __func__);
-
- Mutex::Autolock lock(mLock);
-
- status_t ret = NO_ERROR;
-
- mParameters = params;
-
- // set camera id
- int new_camera_id = params.getInt("camera-id");
- if(0 <= new_camera_id)
- {
- if(mSecCamera->setCameraId(new_camera_id) < 0)
- {
- LOGE("ERR(%s):Fail on mSecCamera->setCameraId(camera_id(%d))", __func__, new_camera_id);
- ret = UNKNOWN_ERROR;
- }
- }
-
- // preview size
- int new_preview_width = 0;
- int new_preview_height = 0;
- params.getPreviewSize(&new_preview_width, &new_preview_height);
- const char * new_str_preview_format = params.getPreviewFormat();
- if(0 < new_preview_width && 0 < new_preview_height && new_str_preview_format != NULL)
- {
- int new_preview_format = 0;
-
- if (strcmp(new_str_preview_format, CameraParameters::PIXEL_FORMAT_RGB565) == 0)
- new_preview_format = V4L2_PIX_FMT_RGB565;
- else if (strcmp(new_str_preview_format, CameraParameters::PIXEL_FORMAT_YUV420SP) == 0)
- new_preview_format = V4L2_PIX_FMT_NV21; //Kamat
- else if (strcmp(new_str_preview_format, "yuv420sp_custom") == 0)
- new_preview_format = V4L2_PIX_FMT_NV12T; //Kamat
- else if (strcmp(new_str_preview_format, "yuv420p") == 0)
- new_preview_format = V4L2_PIX_FMT_YUV420;
- else if (strcmp(new_str_preview_format, "yuv422i") == 0)
- new_preview_format = V4L2_PIX_FMT_YUYV;
- else if (strcmp(new_str_preview_format, "yuv422p") == 0)
- new_preview_format = V4L2_PIX_FMT_YUV422P;
- else
- new_preview_format = V4L2_PIX_FMT_NV21; //for 3rd party
-
- if(mSecCamera->setPreviewSize(new_preview_width, new_preview_height, new_preview_format) < 0)
- {
- LOGE("ERR(%s):Fail on mSecCamera->setPreviewSize(width(%d), height(%d), format(%d))", __func__, new_preview_width, new_preview_height, new_preview_format);
- ret = UNKNOWN_ERROR;
- }
+ LOGV("%s()", __func__);
+
+ Mutex::Autolock lock(mLock);
+
+ status_t ret = NO_ERROR;
+
+ mParameters = params;
+
+ // set camera id
+ int new_camera_id = params.getInt("camera-id");
+ if (0 <= new_camera_id) {
+ if (mSecCamera->setCameraId(new_camera_id) < 0) {
+ LOGE("ERR(%s):Fail on mSecCamera->setCameraId(camera_id(%d))", __func__, new_camera_id);
+ ret = UNKNOWN_ERROR;
+ }
+ }
+
+ // preview size
+ int new_preview_width = 0;
+ int new_preview_height = 0;
+ params.getPreviewSize(&new_preview_width, &new_preview_height);
+ const char *new_str_preview_format = params.getPreviewFormat();
+
+ if (0 < new_preview_width && 0 < new_preview_height && new_str_preview_format != NULL) {
+ int new_preview_format = 0;
+
+ if (strcmp(new_str_preview_format, CameraParameters::PIXEL_FORMAT_RGB565) == 0)
+ new_preview_format = V4L2_PIX_FMT_RGB565;
+ else if (strcmp(new_str_preview_format, CameraParameters::PIXEL_FORMAT_YUV420SP) == 0)
+ new_preview_format = V4L2_PIX_FMT_NV21; //Kamat
+ else if (strcmp(new_str_preview_format, "yuv420sp_custom") == 0)
+ new_preview_format = V4L2_PIX_FMT_NV12T; //Kamat
+ else if (strcmp(new_str_preview_format, "yuv420p") == 0)
+ new_preview_format = V4L2_PIX_FMT_YUV420;
+ else if (strcmp(new_str_preview_format, "yuv422i") == 0)
+ new_preview_format = V4L2_PIX_FMT_YUYV;
+ else if (strcmp(new_str_preview_format, "yuv422p") == 0)
+ new_preview_format = V4L2_PIX_FMT_YUV422P;
+ else
+ new_preview_format = V4L2_PIX_FMT_NV21; //for 3rd party
+
+ if (mSecCamera->setPreviewSize(new_preview_width, new_preview_height, new_preview_format) < 0) {
+ LOGE("ERR(%s):Fail on mSecCamera->setPreviewSize(width(%d), height(%d), format(%d))",
+ __func__, new_preview_width, new_preview_height, new_preview_format);
+ ret = UNKNOWN_ERROR;
+ }
#if defined(BOARD_USES_OVERLAY)
- if(mUseOverlay == true && mOverlay != 0)
- {
- if(mOverlay->setCrop(0, 0, new_preview_width, new_preview_height) != NO_ERROR) {
- LOGE("ERR(%s)::(mOverlay->setCrop(0, 0, %d, %d) fail", __func__, new_preview_width, new_preview_height);
- }
- }
+ if (mUseOverlay == true && mOverlay != 0) {
+ if (mOverlay->setCrop(0, 0, new_preview_width, new_preview_height) != NO_ERROR) {
+ LOGE("ERR(%s)::(mOverlay->setCrop(0, 0, %d, %d) fail",
+ __func__, new_preview_width, new_preview_height);
+ }
+ }
#endif
- }
-
- int new_picture_width = 0;
- int new_picture_height = 0;
- params.getPictureSize(&new_picture_width, &new_picture_height);
- if(0 < new_picture_width && 0 < new_picture_height)
- {
- if(mSecCamera->setSnapshotSize(new_picture_width, new_picture_height) < 0)
- {
- LOGE("ERR(%s):Fail on mSecCamera->setSnapshotSize(width(%d), height(%d))", __func__, new_picture_width, new_picture_height);
- ret = UNKNOWN_ERROR;
- }
- }
-
- // picture format
- const char * new_str_picture_format = params.getPictureFormat();
- if(new_str_picture_format != NULL)
- {
- int new_picture_format = 0;
-
- if (strcmp(new_str_picture_format, CameraParameters::PIXEL_FORMAT_RGB565) == 0)
- new_picture_format = V4L2_PIX_FMT_RGB565;
- else if (strcmp(new_str_picture_format, CameraParameters::PIXEL_FORMAT_YUV420SP) == 0)
- new_picture_format = V4L2_PIX_FMT_NV21; //Kamat: Default format
- else if (strcmp(new_str_picture_format, "yuv420sp_custom") == 0)
- new_picture_format = V4L2_PIX_FMT_NV12T;
- else if (strcmp(new_str_picture_format, "yuv420p") == 0)
- new_picture_format = V4L2_PIX_FMT_YUV420;
- else if (strcmp(new_str_picture_format, "yuv422i") == 0)
- new_picture_format = V4L2_PIX_FMT_YUYV;
- else if (strcmp(new_str_picture_format, "uyv422i_custom") == 0) //Zero copy UYVY format
- new_picture_format = V4L2_PIX_FMT_UYVY;
- else if (strcmp(new_str_picture_format, "uyv422i") == 0) //Non-zero copy UYVY format
- new_picture_format = V4L2_PIX_FMT_UYVY;
- else if (strcmp(new_str_picture_format, CameraParameters::PIXEL_FORMAT_JPEG) == 0)
+ }
+
+ int new_picture_width = 0;
+ int new_picture_height = 0;
+
+ params.getPictureSize(&new_picture_width, &new_picture_height);
+ if (0 < new_picture_width && 0 < new_picture_height) {
+ if (mSecCamera->setSnapshotSize(new_picture_width, new_picture_height) < 0) {
+ LOGE("ERR(%s):Fail on mSecCamera->setSnapshotSize(width(%d), height(%d))",
+ __func__, new_picture_width, new_picture_height);
+ ret = UNKNOWN_ERROR;
+ }
+ }
+
+ // picture format
+ const char *new_str_picture_format = params.getPictureFormat();
+
+ if (new_str_picture_format != NULL) {
+ int new_picture_format = 0;
+
+ if (strcmp(new_str_picture_format, CameraParameters::PIXEL_FORMAT_RGB565) == 0)
+ new_picture_format = V4L2_PIX_FMT_RGB565;
+ else if (strcmp(new_str_picture_format, CameraParameters::PIXEL_FORMAT_YUV420SP) == 0)
+ new_picture_format = V4L2_PIX_FMT_NV21; //Kamat: Default format
+ else if (strcmp(new_str_picture_format, "yuv420sp_custom") == 0)
+ new_picture_format = V4L2_PIX_FMT_NV12T;
+ else if (strcmp(new_str_picture_format, "yuv420p") == 0)
+ new_picture_format = V4L2_PIX_FMT_YUV420;
+ else if (strcmp(new_str_picture_format, "yuv422i") == 0)
+ new_picture_format = V4L2_PIX_FMT_YUYV;
+ else if (strcmp(new_str_picture_format, "uyv422i_custom") == 0) //Zero copy UYVY format
+ new_picture_format = V4L2_PIX_FMT_UYVY;
+ else if (strcmp(new_str_picture_format, "uyv422i") == 0) //Non-zero copy UYVY format
+ new_picture_format = V4L2_PIX_FMT_UYVY;
+ else if (strcmp(new_str_picture_format, CameraParameters::PIXEL_FORMAT_JPEG) == 0)
#ifdef JPEG_FROM_SENSOR
- new_picture_format = V4L2_PIX_FMT_UYVY;
+ new_picture_format = V4L2_PIX_FMT_UYVY;
#else
- new_picture_format = V4L2_PIX_FMT_YUYV;
+ new_picture_format = V4L2_PIX_FMT_YUYV;
#endif
- else if (strcmp(new_str_picture_format, "yuv422p") == 0)
- new_picture_format = V4L2_PIX_FMT_YUV422P;
- else
- new_picture_format = V4L2_PIX_FMT_NV21; //for 3rd party
-
- if(mSecCamera->setSnapshotPixelFormat(new_picture_format) < 0)
- {
- LOGE("ERR(%s):Fail on mSecCamera->setSnapshotPixelFormat(format(%d))", __func__, new_picture_format);
- ret = UNKNOWN_ERROR;
- }
- }
+ else if (strcmp(new_str_picture_format, "yuv422p") == 0)
+ new_picture_format = V4L2_PIX_FMT_YUV422P;
+ else
+ new_picture_format = V4L2_PIX_FMT_NV21; //for 3rd party
+
+ if (mSecCamera->setSnapshotPixelFormat(new_picture_format) < 0) {
+ LOGE("ERR(%s):Fail on mSecCamera->setSnapshotPixelFormat(format(%d))", __func__, new_picture_format);
+ ret = UNKNOWN_ERROR;
+ }
+ }
#ifdef SWP1_CAMERA_ADD_ADVANCED_FUNCTION
- //JPEG image quality
- int new_jpeg_quality = params.getInt(CameraParameters::KEY_JPEG_QUALITY);
+ //JPEG image quality
+ int new_jpeg_quality = params.getInt(CameraParameters::KEY_JPEG_QUALITY);
- if (new_jpeg_quality < 1 || new_jpeg_quality > 100) {
- LOGE("ERR(%s): Invalid quality(%d))", __func__, new_jpeg_quality);
+ if (new_jpeg_quality < 1 || new_jpeg_quality > 100) {
+ LOGE("ERR(%s): Invalid quality(%d))", __func__, new_jpeg_quality);
- new_jpeg_quality = 100;
+ new_jpeg_quality = 100;
- mParameters.set(CameraParameters::KEY_JPEG_QUALITY, "100");
- }
+ mParameters.set(CameraParameters::KEY_JPEG_QUALITY, "100");
+ }
- mSecCamera->setJpegQuality(new_jpeg_quality);
+ mSecCamera->setJpegQuality(new_jpeg_quality);
#else
- //JPEG image quality
- int new_jpeg_quality = params.getInt(CameraParameters::KEY_JPEG_QUALITY);
- if (new_jpeg_quality < 0)
- {
- LOGW("JPEG-image quality is not specified or is negative, defaulting to 100");
- new_jpeg_quality = 100;
- mParameters.set(CameraParameters::KEY_JPEG_QUALITY, "100");
- }
- mSecCamera->setJpegQuality(new_jpeg_quality);
+ //JPEG image quality
+ int new_jpeg_quality = params.getInt(CameraParameters::KEY_JPEG_QUALITY);
+
+ if (new_jpeg_quality < 0) {
+ LOGW("JPEG-image quality is not specified or is negative, defaulting to 100");
+ new_jpeg_quality = 100;
+ mParameters.set(CameraParameters::KEY_JPEG_QUALITY, "100");
+ }
+ mSecCamera->setJpegQuality(new_jpeg_quality);
#endif
- // JPEG thumbnail size
- int new_jpeg_thumbnail_width = params.getInt(CameraParameters::KEY_JPEG_THUMBNAIL_WIDTH);
- int new_jpeg_thumbnail_height= params.getInt(CameraParameters::KEY_JPEG_THUMBNAIL_HEIGHT);
-
- if(0 < new_jpeg_thumbnail_width && 0 < new_jpeg_thumbnail_height)
- {
- if(mSecCamera->setJpegThumbnailSize(new_jpeg_thumbnail_width, new_jpeg_thumbnail_height) < 0)
- {
- LOGE("ERR(%s):Fail on mSecCamera->setJpegThumbnailSize(width(%d), height(%d))", __func__, new_jpeg_thumbnail_width, new_jpeg_thumbnail_height);
- ret = UNKNOWN_ERROR;
- }
- }
-
- // frame rate
- int new_frame_rate = params.getPreviewFrameRate();
- if(new_frame_rate < 5 || new_frame_rate > 30)
- {
- new_frame_rate = 30;
- }
-
- mParameters.setPreviewFrameRate(new_frame_rate);
- // Calculate how long to wait between frames.
- mPreviewFrameRateMicrosec = (int)(1000000.0f / float(new_frame_rate));
-
- LOGD("frame rate:%d, mPreviewFrameRateMicrosec:%d", new_frame_rate, mPreviewFrameRateMicrosec);
-
- mSecCamera->setFrameRate(new_frame_rate);
-
- //vt mode
- int new_vtmode = params.getInt("vtmode");
- if(0 <= new_vtmode)
- {
- if(mSecCamera->setVTmode(new_vtmode) < 0)
- {
- LOGE("ERR(%s):Fail on mSecCamera->setVTMode(%d)", __func__, new_vtmode);
- ret = UNKNOWN_ERROR;
- }
- }
-
- // rotation
- int new_rotation = params.getInt(CameraParameters::KEY_ROTATION);
- int new_exif_rotation = 1;
- if(new_rotation != -1)
- {
- if(new_vtmode == SecCamera::VT_MODE_ON ) // vt preview rotation
- {
- LOGE("ERR(%s):VT mode is on. Rotate(%d))", __func__, new_rotation);
-
- if(mSecCamera->SetRotate(new_rotation) < 0)
- {
- LOGE("ERR(%s):Fail on mSecCamera->SetRotate(rotation(%d))", __func__, new_rotation);
- ret = UNKNOWN_ERROR;
- }
- }
- else //exif orientation information
- {
- if(mSecCamera->SetRotate(0) < 0)
- {
- LOGE("ERR(%s):Fail on mSecCamera->SetRotate(rotation(%d))", __func__, new_rotation);
- ret = UNKNOWN_ERROR;
- }
-
- if(new_rotation == 0)
- new_exif_rotation = 1;
- else if (new_rotation == 90)
- new_exif_rotation = 6;
- else if (new_rotation == 180)
- new_exif_rotation = 3;
- else if (new_rotation == 270)
- new_exif_rotation = 8;
- else
- new_exif_rotation = 1;
- }
- }
-
+ // JPEG thumbnail size
+ int new_jpeg_thumbnail_width = params.getInt(CameraParameters::KEY_JPEG_THUMBNAIL_WIDTH);
+ int new_jpeg_thumbnail_height= params.getInt(CameraParameters::KEY_JPEG_THUMBNAIL_HEIGHT);
+
+ if (0 < new_jpeg_thumbnail_width && 0 < new_jpeg_thumbnail_height) {
+ if (mSecCamera->setJpegThumbnailSize(new_jpeg_thumbnail_width, new_jpeg_thumbnail_height) < 0) {
+ LOGE("ERR(%s):Fail on mSecCamera->setJpegThumbnailSize(width(%d), height(%d))", __func__, new_jpeg_thumbnail_width, new_jpeg_thumbnail_height);
+ ret = UNKNOWN_ERROR;
+ }
+ }
+
+ // frame rate
+ int new_frame_rate = params.getPreviewFrameRate();
+
+ if (new_frame_rate < 5 || new_frame_rate > 30) {
+ new_frame_rate = 30;
+ }
+
+ mParameters.setPreviewFrameRate(new_frame_rate);
+ // Calculate how long to wait between frames.
+ mPreviewFrameRateMicrosec = (int)(1000000.0f / float(new_frame_rate));
+
+ LOGD("frame rate:%d, mPreviewFrameRateMicrosec:%d", new_frame_rate, mPreviewFrameRateMicrosec);
+
+ mSecCamera->setFrameRate(new_frame_rate);
+
+ //vt mode
+ int new_vtmode = params.getInt("vtmode");
+
+ if (0 <= new_vtmode) {
+ if (mSecCamera->setVTmode(new_vtmode) < 0) {
+ LOGE("ERR(%s):Fail on mSecCamera->setVTMode(%d)", __func__, new_vtmode);
+ ret = UNKNOWN_ERROR;
+ }
+ }
+
+ // rotation
+ int new_rotation = params.getInt(CameraParameters::KEY_ROTATION);
+ int new_exif_rotation = 1;
+
+ if (new_rotation != -1) {
+ if (new_vtmode == SecCamera::VT_MODE_ON ) {
+ LOGE("ERR(%s):VT mode is on. Rotate(%d))", __func__, new_rotation);
+
+ if (mSecCamera->SetRotate(new_rotation) < 0) {
+ LOGE("ERR(%s):Fail on mSecCamera->SetRotate(rotation(%d))", __func__, new_rotation);
+ ret = UNKNOWN_ERROR;
+ }
+ } else {
+ if (mSecCamera->SetRotate(0) < 0) {
+ LOGE("ERR(%s):Fail on mSecCamera->SetRotate(rotation(%d))", __func__, new_rotation);
+ ret = UNKNOWN_ERROR;
+ }
+
+ if (new_rotation == 0)
+ new_exif_rotation = 1;
+ else if (new_rotation == 90)
+ new_exif_rotation = 6;
+ else if (new_rotation == 180)
+ new_exif_rotation = 3;
+ else if (new_rotation == 270)
+ new_exif_rotation = 8;
+ else
+ new_exif_rotation = 1;
+ }
+ }
+
#ifndef SWP1_CAMERA_ADD_ADVANCED_FUNCTION
- // brightness
- int new_exposure_compensation = params.getInt(CameraParameters::KEY_EXPOSURE_COMPENSATION);
- int max_exposure_compensation = params.getInt(CameraParameters::KEY_MAX_EXPOSURE_COMPENSATION);
- int min_exposure_compensation = params.getInt(CameraParameters::KEY_MIN_EXPOSURE_COMPENSATION);
-
- if( (min_exposure_compensation <= new_exposure_compensation) &&
- (max_exposure_compensation >= new_exposure_compensation) )
- {
- if(mSecCamera->setBrightness(new_exposure_compensation) < 0)
- {
- LOGE("ERR(%s):Fail on mSecCamera->setBrightness(brightness(%d))", __func__, new_exposure_compensation);
- ret = UNKNOWN_ERROR;
- }
-
- }
-
- // whitebalance
- const char * new_white_str = params.get(CameraParameters::KEY_WHITE_BALANCE);
- if(new_white_str != NULL)
- {
- int new_white = -1;
-
- if(strcmp(new_white_str, CameraParameters::WHITE_BALANCE_AUTO) == 0)
- new_white = SecCamera::WHITE_BALANCE_AUTO;
- else if(strcmp(new_white_str, "indoor3100") == 0)
- new_white = SecCamera::WHITE_BALANCE_INDOOR3100;
- else if(strcmp(new_white_str, "outdoor5100") == 0)
- new_white = SecCamera::WHITE_BALANCE_OUTDOOR5100;
- else if(strcmp(new_white_str, "indoor2000") == 0)
- new_white = SecCamera::WHITE_BALANCE_INDOOR2000;
- else if(strcmp(new_white_str, "halt") == 0)
- new_white = SecCamera::WHITE_BALANCE_HALT;
- else if(strcmp(new_white_str, "cloudy") == 0)
- new_white = SecCamera::WHITE_BALANCE_CLOUDY;
- else if(strcmp(new_white_str, "sunny") == 0)
- new_white = SecCamera::WHITE_BALANCE_SUNNY;
- else
- {
- LOGE("ERR(%s):Invalid white balance(%s)", __func__, new_white_str);
- ret = UNKNOWN_ERROR;
- }
-
- if(0 <= new_white)
- {
- // white_balance
- if(mSecCamera->setWhiteBalance(new_white) < 0)
- {
- LOGE("ERR(%s):Fail on mSecCamera->setWhiteBalance(white(%d))", __func__, new_white);
- ret = UNKNOWN_ERROR;
- }
- }
- }
-
- // image effect
- const char * new_image_effect_str = params.get("image-effects");
- if(new_image_effect_str != NULL)
- {
- int new_image_effect = -1;
-
- if(strcmp(new_image_effect_str, "original") == 0)
- new_image_effect = SecCamera::IMAGE_EFFECT_ORIGINAL;
- else if(strcmp(new_image_effect_str, "arbitrary") == 0)
- new_image_effect = SecCamera::IMAGE_EFFECT_ARBITRARY;
- else if(strcmp(new_image_effect_str, "negative") == 0)
- new_image_effect = SecCamera::IMAGE_EFFECT_NEGATIVE;
- else if(strcmp(new_image_effect_str, "freeze") == 0)
- new_image_effect = SecCamera::IMAGE_EFFECT_FREEZE;
- else if(strcmp(new_image_effect_str, "embossing") == 0)
- new_image_effect = SecCamera::IMAGE_EFFECT_EMBOSSING;
- else if(strcmp(new_image_effect_str, "silhouette") == 0)
- new_image_effect = SecCamera::IMAGE_EFFECT_SILHOUETTE;
- else
- {
- LOGE("ERR(%s):Invalid effect(%s)", __func__, new_image_effect_str);
- ret = UNKNOWN_ERROR;
- }
-
- if(new_image_effect >= 0)
- {
- // white_balance
- if(mSecCamera->setImageEffect(new_image_effect) < 0)
- {
- LOGE("ERR(%s):Fail on mSecCamera->setImageEffect(effect(%d))", __func__, new_image_effect);
- ret = UNKNOWN_ERROR;
- }
- }
- }
+ // brightness
+ int new_exposure_compensation = params.getInt(CameraParameters::KEY_EXPOSURE_COMPENSATION);
+ int max_exposure_compensation = params.getInt(CameraParameters::KEY_MAX_EXPOSURE_COMPENSATION);
+ int min_exposure_compensation = params.getInt(CameraParameters::KEY_MIN_EXPOSURE_COMPENSATION);
+
+ if ((min_exposure_compensation <= new_exposure_compensation) &&
+ (max_exposure_compensation >= new_exposure_compensation)) {
+ if (mSecCamera->setBrightness(new_exposure_compensation) < 0) {
+ LOGE("ERR(%s):Fail on mSecCamera->setBrightness(brightness(%d))", __func__, new_exposure_compensation);
+ ret = UNKNOWN_ERROR;
+ }
+ }
+
+ // whitebalance
+ const char *new_white_str = params.get(CameraParameters::KEY_WHITE_BALANCE);
+
+ if (new_white_str != NULL) {
+ int new_white = -1;
+
+ if (strcmp(new_white_str, CameraParameters::WHITE_BALANCE_AUTO) == 0)
+ new_white = SecCamera::WHITE_BALANCE_AUTO;
+ else if (strcmp(new_white_str, "indoor3100") == 0)
+ new_white = SecCamera::WHITE_BALANCE_INDOOR3100;
+ else if (strcmp(new_white_str, "outdoor5100") == 0)
+ new_white = SecCamera::WHITE_BALANCE_OUTDOOR5100;
+ else if (strcmp(new_white_str, "indoor2000") == 0)
+ new_white = SecCamera::WHITE_BALANCE_INDOOR2000;
+ else if (strcmp(new_white_str, "halt") == 0)
+ new_white = SecCamera::WHITE_BALANCE_HALT;
+ else if (strcmp(new_white_str, "cloudy") == 0)
+ new_white = SecCamera::WHITE_BALANCE_CLOUDY;
+ else if (strcmp(new_white_str, "sunny") == 0)
+ new_white = SecCamera::WHITE_BALANCE_SUNNY;
+ else {
+ LOGE("ERR(%s):Invalid white balance(%s)", __func__, new_white_str);
+ ret = UNKNOWN_ERROR;
+ }
+
+ if (0 <= new_white) {
+ // white_balance
+ if (mSecCamera->setWhiteBalance(new_white) < 0) {
+ LOGE("ERR(%s):Fail on mSecCamera->setWhiteBalance(white(%d))", __func__, new_white);
+ ret = UNKNOWN_ERROR;
+ }
+ }
+ }
+
+ // image effect
+ const char *new_image_effect_str = params.get("image-effects");
+
+ if (new_image_effect_str != NULL) {
+ int new_image_effect = -1;
+
+ if (strcmp(new_image_effect_str, "original") == 0)
+ new_image_effect = SecCamera::IMAGE_EFFECT_ORIGINAL;
+ else if (strcmp(new_image_effect_str, "arbitrary") == 0)
+ new_image_effect = SecCamera::IMAGE_EFFECT_ARBITRARY;
+ else if (strcmp(new_image_effect_str, "negative") == 0)
+ new_image_effect = SecCamera::IMAGE_EFFECT_NEGATIVE;
+ else if (strcmp(new_image_effect_str, "freeze") == 0)
+ new_image_effect = SecCamera::IMAGE_EFFECT_FREEZE;
+ else if (strcmp(new_image_effect_str, "embossing") == 0)
+ new_image_effect = SecCamera::IMAGE_EFFECT_EMBOSSING;
+ else if (strcmp(new_image_effect_str, "silhouette") == 0)
+ new_image_effect = SecCamera::IMAGE_EFFECT_SILHOUETTE;
+ else {
+ LOGE("ERR(%s):Invalid effect(%s)", __func__, new_image_effect_str);
+ ret = UNKNOWN_ERROR;
+ }
+
+ if (new_image_effect >= 0) {
+ // white_balance
+ if (mSecCamera->setImageEffect(new_image_effect) < 0) {
+ LOGE("ERR(%s):Fail on mSecCamera->setImageEffect(effect(%d))", __func__, new_image_effect);
+ ret = UNKNOWN_ERROR;
+ }
+ }
+ }
#else
- // scene mode
- const char * new_scene_mode_str = params.get(CameraParameters::KEY_SCENE_MODE);
-
- LOGV("%s() new_scene_mode_str %s", __func__,new_scene_mode_str);
-
- if(new_scene_mode_str != NULL)
- {
- int new_scene_mode = -1;
-
- const char * new_iso_str = NULL;
- const char * new_metering_str = NULL;
- int new_exposure_compensation = 0;
- const char * new_white_str = NULL;
- int new_sharpness = 0;
- int new_saturation = 0;
- const char * new_focus_mode_str = NULL;
- const char * new_flash_mode_str = NULL;
-
- if(strcmp(new_scene_mode_str, CameraParameters::SCENE_MODE_AUTO) == 0)
- {
- new_scene_mode = SecCamera::SCENE_MODE_NONE;
-
- new_iso_str = params.get("iso");
- new_metering_str = params.get("metering");
- new_exposure_compensation = params.getInt(CameraParameters::KEY_EXPOSURE_COMPENSATION);
- new_white_str = params.get(CameraParameters::KEY_WHITE_BALANCE);
- new_sharpness = params.getInt("sharpness");
- new_saturation = params.getInt("saturation");
- new_focus_mode_str = params.get(CameraParameters::KEY_FOCUS_MODE);
- new_flash_mode_str = params.get(CameraParameters::KEY_FLASH_MODE);
- }
- else
- {
- if(strcmp(new_scene_mode_str, CameraParameters::SCENE_MODE_PORTRAIT) == 0)
- {
- new_scene_mode = SecCamera::SCENE_MODE_PORTRAIT;
-
- mParameters.set("iso", "auto");
- mParameters.set("metering", "center");
- mParameters.set(CameraParameters::KEY_EXPOSURE_COMPENSATION, SecCamera::BRIGHTNESS_NORMAL);
- mParameters.set(CameraParameters::KEY_WHITE_BALANCE, CameraParameters::WHITE_BALANCE_AUTO);
- mParameters.set("sharpness", SecCamera::SHARPNESS_MINUS_1);
- mParameters.set("saturation", SecCamera::SATURATION_NORMAL);
- mParameters.set(CameraParameters::KEY_FOCUS_MODE, "facedetect");
- }
- else if(strcmp(new_scene_mode_str, CameraParameters::SCENE_MODE_LANDSCAPE) == 0)
- {
- new_scene_mode = SecCamera::SCENE_MODE_LANDSCAPE;
-
- mParameters.set("iso", "auto");
- mParameters.set("metering", "matrix");
- mParameters.set(CameraParameters::KEY_EXPOSURE_COMPENSATION, SecCamera::BRIGHTNESS_NORMAL);
- mParameters.set(CameraParameters::KEY_WHITE_BALANCE, CameraParameters::WHITE_BALANCE_AUTO);
- mParameters.set("sharpness", SecCamera::SHARPNESS_PLUS_1);
- mParameters.set("saturation", SecCamera::SATURATION_PLUS_1);
- mParameters.set(CameraParameters::KEY_FOCUS_MODE, CameraParameters::FOCUS_MODE_AUTO);
- mParameters.set(CameraParameters::KEY_FLASH_MODE, "off");
- }
- else if(strcmp(new_scene_mode_str, CameraParameters::SCENE_MODE_SPORTS) == 0)
- {
- new_scene_mode = SecCamera::SCENE_MODE_SPORTS;
-
- mParameters.set("iso", "sports");
- mParameters.set("metering", "center");
- mParameters.set(CameraParameters::KEY_EXPOSURE_COMPENSATION, SecCamera::BRIGHTNESS_NORMAL);
- mParameters.set(CameraParameters::KEY_WHITE_BALANCE, CameraParameters::WHITE_BALANCE_AUTO);
- mParameters.set("sharpness", SecCamera::SHARPNESS_NORMAL);
- mParameters.set("saturation", SecCamera::SATURATION_NORMAL);
- mParameters.set(CameraParameters::KEY_FOCUS_MODE, CameraParameters::FOCUS_MODE_AUTO);
- mParameters.set(CameraParameters::KEY_FLASH_MODE, "off");
- }
- else if(strcmp(new_scene_mode_str, CameraParameters::SCENE_MODE_PARTY) == 0)
- {
- new_scene_mode = SecCamera::SCENE_MODE_PARTY_INDOOR;
-
- mParameters.set("iso", "200");
- mParameters.set("metering", "center");
- mParameters.set(CameraParameters::KEY_EXPOSURE_COMPENSATION, SecCamera::BRIGHTNESS_NORMAL);
- mParameters.set(CameraParameters::KEY_WHITE_BALANCE, CameraParameters::WHITE_BALANCE_AUTO);
- mParameters.set("sharpness", SecCamera::SHARPNESS_NORMAL);
- mParameters.set("saturation", SecCamera::SATURATION_PLUS_1);
- mParameters.set(CameraParameters::KEY_FOCUS_MODE, CameraParameters::FOCUS_MODE_AUTO);
- }
- else if((strcmp(new_scene_mode_str, CameraParameters::SCENE_MODE_BEACH) == 0) || (strcmp(new_scene_mode_str, CameraParameters::SCENE_MODE_SNOW) == 0))
- {
- new_scene_mode = SecCamera::SCENE_MODE_BEACH_SNOW;
-
- mParameters.set("iso", "50");
- mParameters.set("metering", "center");
- mParameters.set(CameraParameters::KEY_EXPOSURE_COMPENSATION, SecCamera::BRIGHTNESS_PLUS_2);
- mParameters.set(CameraParameters::KEY_WHITE_BALANCE, CameraParameters::WHITE_BALANCE_AUTO);
- mParameters.set("sharpness", SecCamera::SHARPNESS_NORMAL);
- mParameters.set("saturation", SecCamera::SATURATION_PLUS_1);
- mParameters.set(CameraParameters::KEY_FOCUS_MODE, CameraParameters::FOCUS_MODE_AUTO);
- mParameters.set(CameraParameters::KEY_FLASH_MODE, "off");
- }
- else if(strcmp(new_scene_mode_str, CameraParameters::SCENE_MODE_SUNSET) == 0)
- {
- new_scene_mode = SecCamera::SCENE_MODE_SUNSET;
-
- mParameters.set("iso", "auto");
- mParameters.set("metering", "center");
- mParameters.set(CameraParameters::KEY_EXPOSURE_COMPENSATION, SecCamera::BRIGHTNESS_NORMAL);
- mParameters.set(CameraParameters::KEY_WHITE_BALANCE, CameraParameters::WHITE_BALANCE_DAYLIGHT);
- mParameters.set("sharpness", SecCamera::SHARPNESS_NORMAL);
- mParameters.set("saturation", SecCamera::SATURATION_NORMAL);
- mParameters.set(CameraParameters::KEY_FOCUS_MODE, CameraParameters::FOCUS_MODE_AUTO);
- mParameters.set(CameraParameters::KEY_FLASH_MODE, "off");
- }
- else if(strcmp(new_scene_mode_str, "dusk-dawn") == 0) //added
- {
- new_scene_mode = SecCamera::SCENE_MODE_DUSK_DAWN;
-
- mParameters.set("iso", "auto");
- mParameters.set("metering", "center");
- mParameters.set(CameraParameters::KEY_EXPOSURE_COMPENSATION, SecCamera::BRIGHTNESS_NORMAL);
- mParameters.set(CameraParameters::KEY_WHITE_BALANCE, CameraParameters::WHITE_BALANCE_FLUORESCENT);
- mParameters.set("sharpness", SecCamera::SHARPNESS_NORMAL);
- mParameters.set("saturation", SecCamera::SATURATION_NORMAL);
- mParameters.set(CameraParameters::KEY_FOCUS_MODE, CameraParameters::FOCUS_MODE_AUTO);
- mParameters.set(CameraParameters::KEY_FLASH_MODE, "off");
- }
- else if(strcmp(new_scene_mode_str, "fall-color") == 0) //added
- {
- new_scene_mode = SecCamera::SCENE_MODE_FALL_COLOR;
-
- mParameters.set("iso", "auto");
- mParameters.set("metering", "center");
- mParameters.set(CameraParameters::KEY_EXPOSURE_COMPENSATION, SecCamera::BRIGHTNESS_NORMAL);
- mParameters.set(CameraParameters::KEY_WHITE_BALANCE, CameraParameters::WHITE_BALANCE_AUTO);
- mParameters.set("sharpness", SecCamera::SHARPNESS_NORMAL);
- mParameters.set("saturation", SecCamera::SATURATION_PLUS_2);
- mParameters.set(CameraParameters::KEY_FOCUS_MODE, CameraParameters::FOCUS_MODE_AUTO);
- mParameters.set(CameraParameters::KEY_FLASH_MODE, "off");
- }
- else if(strcmp(new_scene_mode_str, CameraParameters::SCENE_MODE_NIGHT) == 0)
- {
- new_scene_mode = SecCamera::SCENE_MODE_NIGHTSHOT;
-
- mParameters.set("iso", "night");
- mParameters.set("metering", "center");
- mParameters.set(CameraParameters::KEY_EXPOSURE_COMPENSATION, SecCamera::BRIGHTNESS_NORMAL);
- mParameters.set(CameraParameters::KEY_WHITE_BALANCE, CameraParameters::WHITE_BALANCE_AUTO);
- mParameters.set("sharpness", SecCamera::SHARPNESS_NORMAL);
- mParameters.set("saturation", SecCamera::SATURATION_NORMAL);
- mParameters.set(CameraParameters::KEY_FOCUS_MODE, CameraParameters::FOCUS_MODE_AUTO);
- mParameters.set(CameraParameters::KEY_FLASH_MODE, "off");
- }
- else if(strcmp(new_scene_mode_str, "back-light") == 0) //added
- {
- const char * flash_mode_str = params.get(CameraParameters::KEY_FLASH_MODE);
-
- new_scene_mode = SecCamera::SCENE_MODE_BACK_LIGHT;
-
- mParameters.set("iso", "auto");
- if(strcmp(flash_mode_str, "off") == 0)
- mParameters.set("metering", "spot");
- else
- mParameters.set("metering", "center");
- mParameters.set(CameraParameters::KEY_EXPOSURE_COMPENSATION, SecCamera::BRIGHTNESS_NORMAL);
- mParameters.set(CameraParameters::KEY_WHITE_BALANCE, CameraParameters::WHITE_BALANCE_AUTO);
- mParameters.set("sharpness", SecCamera::SHARPNESS_NORMAL);
- mParameters.set("saturation", SecCamera::SATURATION_NORMAL);
- mParameters.set(CameraParameters::KEY_FOCUS_MODE, CameraParameters::FOCUS_MODE_AUTO);
- }
- else if(strcmp(new_scene_mode_str, CameraParameters::SCENE_MODE_FIREWORKS) == 0)
- {
- new_scene_mode = SecCamera::SCENE_MODE_FIREWORKS;
-
- mParameters.set("iso", "50");
- mParameters.set("metering", "center");
- mParameters.set(CameraParameters::KEY_EXPOSURE_COMPENSATION, SecCamera::BRIGHTNESS_NORMAL);
- mParameters.set(CameraParameters::KEY_WHITE_BALANCE, CameraParameters::WHITE_BALANCE_AUTO);
- mParameters.set("sharpness", SecCamera::SHARPNESS_NORMAL);
- mParameters.set("saturation", SecCamera::SATURATION_NORMAL);
- mParameters.set(CameraParameters::KEY_FOCUS_MODE, CameraParameters::FOCUS_MODE_AUTO);
- mParameters.set(CameraParameters::KEY_FLASH_MODE, "off");
- }
- else if(strcmp(new_scene_mode_str, "text") == 0) //added
- {
- new_scene_mode = SecCamera::SCENE_MODE_TEXT;
-
- mParameters.set("iso", "auto");
- mParameters.set("metering", "center");
- mParameters.set(CameraParameters::KEY_EXPOSURE_COMPENSATION, SecCamera::BRIGHTNESS_NORMAL);
- mParameters.set(CameraParameters::KEY_WHITE_BALANCE, CameraParameters::WHITE_BALANCE_AUTO);
- mParameters.set("sharpness", SecCamera::SHARPNESS_PLUS_2);
- mParameters.set("saturation", SecCamera::SATURATION_NORMAL);
- mParameters.set(CameraParameters::KEY_FOCUS_MODE, CameraParameters::FOCUS_MODE_MACRO);
- }
- else if(strcmp(new_scene_mode_str, CameraParameters::SCENE_MODE_CANDLELIGHT) == 0)
- {
- new_scene_mode = SecCamera::SCENE_MODE_CANDLE_LIGHT;
-
- mParameters.set("iso", "auto");
- mParameters.set("metering", "center");
- mParameters.set(CameraParameters::KEY_EXPOSURE_COMPENSATION, SecCamera::BRIGHTNESS_NORMAL);
- mParameters.set(CameraParameters::KEY_WHITE_BALANCE, CameraParameters::WHITE_BALANCE_DAYLIGHT);
- mParameters.set("sharpness", SecCamera::SHARPNESS_NORMAL);
- mParameters.set("saturation", SecCamera::SATURATION_NORMAL);
- mParameters.set(CameraParameters::KEY_FOCUS_MODE, CameraParameters::FOCUS_MODE_AUTO);
- mParameters.set(CameraParameters::KEY_FLASH_MODE, "off");
- }
- else
- {
- LOGE("%s::unmatched scene_mode(%s)", __func__, new_scene_mode_str); //action, night-portrait, theatre, steadyphoto
- ret = UNKNOWN_ERROR;
- }
-
- new_iso_str = mParameters.get("iso");
- new_metering_str = mParameters.get("metering");
- new_exposure_compensation = mParameters.getInt(CameraParameters::KEY_EXPOSURE_COMPENSATION);
- new_white_str = mParameters.get(CameraParameters::KEY_WHITE_BALANCE);
- new_sharpness = mParameters.getInt("sharpness");
- new_saturation = mParameters.getInt("saturation");
- new_focus_mode_str = mParameters.get(CameraParameters::KEY_FOCUS_MODE);
- new_flash_mode_str = mParameters.get(CameraParameters::KEY_FLASH_MODE);
- }
-
- // 1. ISO
- if(new_iso_str != NULL )
- {
- int new_iso = -1;
- if(strcmp(new_iso_str, "auto") == 0)
- new_iso = SecCamera::ISO_AUTO;
- else if(strcmp(new_iso_str, "50") == 0)
- new_iso = SecCamera::ISO_50;
- else if(strcmp(new_iso_str, "100") == 0)
- new_iso = SecCamera::ISO_100;
- else if(strcmp(new_iso_str, "200") == 0)
- new_iso = SecCamera::ISO_200;
- else if(strcmp(new_iso_str, "400") == 0)
- new_iso = SecCamera::ISO_400;
- else if(strcmp(new_iso_str, "800") == 0)
- new_iso = SecCamera::ISO_800;
- else if(strcmp(new_iso_str, "1600") == 0)
- new_iso = SecCamera::ISO_1600;
- else if(strcmp(new_iso_str, "sports") == 0)
- new_iso = SecCamera::ISO_SPORTS;
- else if(strcmp(new_iso_str, "night") == 0)
- new_iso = SecCamera::ISO_NIGHT;
- else if(strcmp(new_iso_str, "movie") == 0)
- new_iso = SecCamera::ISO_MOVIE;
- else
- {
- LOGE("%s::unmatched iso(%d)", __func__, new_iso);
- ret = UNKNOWN_ERROR;
- }
- if(0 <= new_iso)
- {
- if(mSecCamera->setISO(new_iso) < 0)
- {
- LOGE("%s::mSecCamera->setISO(%d) fail", __func__, new_iso);
- ret = UNKNOWN_ERROR;
- }
- }
- }
-
- // 2. metering
- if(new_metering_str != NULL )
- {
- int new_metering = -1;
- if(strcmp(new_metering_str, "matrix") == 0)
- new_metering = SecCamera::METERING_MATRIX;
- else if(strcmp(new_metering_str, "center") == 0)
- new_metering = SecCamera::METERING_CENTER;
- else if(strcmp(new_metering_str, "spot") == 0)
- new_metering = SecCamera::METERING_SPOT;
- else
- {
- LOGE("%s::unmatched metering(%s)", __func__, new_metering_str);
- ret = UNKNOWN_ERROR;
- }
- if(0 <= new_metering)
- {
- if(mSecCamera->setMetering(new_metering) < 0)
- {
- LOGE("%s::mSecCamera->setMetering(%d) fail", __func__, new_metering);
- ret = UNKNOWN_ERROR;
- }
- }
- }
-
- // 3. brightness
- int max_exposure_compensation = params.getInt(CameraParameters::KEY_MAX_EXPOSURE_COMPENSATION);
- int min_exposure_compensation = params.getInt(CameraParameters::KEY_MIN_EXPOSURE_COMPENSATION);
-
- if( (min_exposure_compensation <= new_exposure_compensation) &&
- (max_exposure_compensation >= new_exposure_compensation) )
- {
- if(mSecCamera->setBrightness(new_exposure_compensation) < 0)
- {
- LOGE("ERR(%s):Fail on mSecCamera->setBrightness(brightness(%d))", __func__, new_exposure_compensation);
- ret = UNKNOWN_ERROR;
- }
-
- }
-
- // 4. whitebalance
- if(new_white_str != NULL)
- {
- int new_white = -1;
-
- if(strcmp(new_white_str, CameraParameters::WHITE_BALANCE_AUTO) == 0)
- new_white = SecCamera::WHITE_BALANCE_AUTO;
- else if(strcmp(new_white_str, CameraParameters::WHITE_BALANCE_DAYLIGHT) == 0)
- new_white = SecCamera::WHITE_BALANCE_DAYLIGHT;
- else if((strcmp(new_white_str, "cloudy") == 0) || (strcmp(new_white_str, "cloudy-daylight") == 0))
- new_white = SecCamera::WHITE_BALANCE_CLOUDY;
- else if(strcmp(new_white_str, CameraParameters::WHITE_BALANCE_FLUORESCENT) == 0)
- new_white = SecCamera::WHITE_BALANCE_FLUORESCENT;
- else if(strcmp(new_white_str, CameraParameters::WHITE_BALANCE_INCANDESCENT) == 0)
- new_white = SecCamera::WHITE_BALANCE_INCANDESCENT;
- else
- {
- LOGE("ERR(%s):Invalid white balance(%s)", __func__, new_white_str); //twilight, shade, warm_flourescent
- ret = UNKNOWN_ERROR;
- }
-
- if(0 <= new_white)
- {
- // white_balance
- if(mSecCamera->setWhiteBalance(new_white) < 0)
- {
- LOGE("ERR(%s):Fail on mSecCamera->setWhiteBalance(white(%d))", __func__, new_white);
- ret = UNKNOWN_ERROR;
- }
- }
- }
-
- //5. sharpness
- if(0 <= new_sharpness)
- {
- if(mSecCamera->setSharpness(new_sharpness) < 0)
- {
- LOGE("ERR(%s):Fail on mSecCamera->setSharpness(%d)", __func__,new_sharpness);
- ret = UNKNOWN_ERROR;
- }
- }
-
- //6. saturation
- if(0 <= new_saturation)
- {
- if(mSecCamera->setSaturation(new_saturation) < 0)
- {
- LOGE("ERR(%s):Fail on mSecCamera->setSaturation(%d)", __func__, new_saturation);
- ret = UNKNOWN_ERROR;
- }
- }
-
- // 7. focus mode
- if(new_focus_mode_str != NULL)
- {
- int new_focus_mode = -1;
-
- if((strcmp(new_focus_mode_str, CameraParameters::FOCUS_MODE_AUTO) == 0) || (strcmp(new_focus_mode_str, CameraParameters::FOCUS_MODE_FIXED) == 0) ||(strcmp(new_focus_mode_str, CameraParameters::FOCUS_MODE_INFINITY) == 0))
- new_focus_mode = SecCamera::FOCUS_MODE_AUTO;
- else if(strcmp(new_focus_mode_str, CameraParameters::FOCUS_MODE_MACRO) == 0)
- new_focus_mode = SecCamera::FOCUS_MODE_MACRO;
- else if(strcmp(new_focus_mode_str, "facedetect") == 0)
- new_focus_mode = SecCamera::FOCUS_MODE_FACEDETECT;
- else
- {
- LOGE("%s::unmatched focus_mode(%s)", __func__, new_focus_mode_str); //infinity
- ret = UNKNOWN_ERROR;
- }
-
- if(0 <= new_focus_mode)
- {
- if(mSecCamera->setFocusMode(new_focus_mode) < 0)
- {
- LOGE("%s::mSecCamera->setFocusMode(%d) fail", __func__, new_focus_mode);
- ret = UNKNOWN_ERROR;
- }
- }
- }
-
- // 8. flash..
- if(new_flash_mode_str != NULL )
- {
- int new_flash_mode = -1;
- if(strcmp(new_flash_mode_str, CameraParameters::FLASH_MODE_OFF) == 0)
- new_flash_mode = SecCamera::FLASH_MODE_OFF;
- else if(strcmp(new_flash_mode_str, CameraParameters::FLASH_MODE_AUTO) == 0)
- new_flash_mode = SecCamera::FLASH_MODE_AUTO;
- else if(strcmp(new_flash_mode_str, CameraParameters::FLASH_MODE_ON) == 0)
- new_flash_mode = SecCamera::FLASH_MODE_ON;
- else if(strcmp(new_flash_mode_str, CameraParameters::FLASH_MODE_TORCH) == 0)
- new_flash_mode = SecCamera::FLASH_MODE_TORCH;
- else
- {
- LOGE("%s::unmatched flash_mode(%s)", __func__, new_flash_mode_str); //red-eye
- ret = UNKNOWN_ERROR;
- }
- if(0 <= new_flash_mode)
- {
- if(mSecCamera->setFlashMode(new_flash_mode) < 0)
- {
- LOGE("%s::mSecCamera->setFlashMode(%d) fail", __func__, new_flash_mode);
- ret = UNKNOWN_ERROR;
- }
- }
- }
-
- // 9. scene..
- if(0 <= new_scene_mode)
- {
- if(mSecCamera->setSceneMode(new_scene_mode) < 0)
- {
- LOGE("%s::mSecCamera->setSceneMode(%d) fail", __func__, new_scene_mode);
- ret = UNKNOWN_ERROR;
- }
- }
- }
-
-// ---------------------------------------------------------------------------
-
- // image effect
- const char * new_image_effect_str = params.get(CameraParameters::KEY_EFFECT);
- if(new_image_effect_str != NULL)
- {
- int new_image_effect = -1;
-
- if((strcmp(new_image_effect_str, "auto") == 0) || (strcmp(new_image_effect_str, CameraParameters::EFFECT_NONE) == 0))
- new_image_effect = SecCamera::IMAGE_EFFECT_NONE;
- else if((strcmp(new_image_effect_str, "bnw") == 0) || (strcmp(new_image_effect_str, CameraParameters::EFFECT_MONO) == 0))
- new_image_effect = SecCamera::IMAGE_EFFECT_BNW;
- else if(strcmp(new_image_effect_str, CameraParameters::EFFECT_SEPIA) == 0)
- new_image_effect = SecCamera::IMAGE_EFFECT_SEPIA;
- else if(strcmp(new_image_effect_str, CameraParameters::EFFECT_AQUA) == 0)
- new_image_effect = SecCamera::IMAGE_EFFECT_AQUA;
- else if(strcmp(new_image_effect_str, "antique") == 0) //added at samsung
- new_image_effect = SecCamera::IMAGE_EFFECT_ANTIQUE;
- else if(strcmp(new_image_effect_str, CameraParameters::EFFECT_NEGATIVE) == 0)
- new_image_effect = SecCamera::IMAGE_EFFECT_NEGATIVE;
- else if(strcmp(new_image_effect_str, "sharpen") == 0) //added at samsung
- new_image_effect = SecCamera::IMAGE_EFFECT_SHARPEN;
- else
- {
- LOGE("ERR(%s):Invalid effect(%s)", __func__, new_image_effect_str); //posterize, whiteboard, blackboard, solarize
- ret = UNKNOWN_ERROR;
- }
-
- if(new_image_effect >= 0)
- {
- if(mSecCamera->setImageEffect(new_image_effect) < 0)
- {
- LOGE("ERR(%s):Fail on mSecCamera->setImageEffect(effect(%d))", __func__, new_image_effect);
- ret = UNKNOWN_ERROR;
- }
- }
- }
-
- //antiBanding
- const char * new_antibanding_str = params.get(CameraParameters::KEY_ANTIBANDING);
- if(new_antibanding_str != NULL)
- {
- int new_antibanding = -1;
-
- if(strcmp(new_antibanding_str, CameraParameters::ANTIBANDING_AUTO) == 0)
- new_antibanding = SecCamera::ANTI_BANDING_AUTO;
- else if(strcmp(new_antibanding_str, CameraParameters::ANTIBANDING_50HZ) == 0)
- new_antibanding = SecCamera::ANTI_BANDING_50HZ;
- else if(strcmp(new_antibanding_str, CameraParameters::ANTIBANDING_60HZ) == 0)
- new_antibanding = SecCamera::ANTI_BANDING_60HZ;
- else if(strcmp(new_antibanding_str, CameraParameters::ANTIBANDING_OFF) == 0)
- new_antibanding = SecCamera::ANTI_BANDING_OFF;
- else
- {
- LOGE("%s::unmatched antibanding(%s)", __func__, new_antibanding_str);
- ret = UNKNOWN_ERROR;
- }
-
- if(0 <= new_antibanding)
- {
- if(mSecCamera->setAntiBanding(new_antibanding) < 0)
- {
- LOGE("%s::mSecCamera->setAntiBanding(%d) fail", __func__, new_antibanding);
- ret = UNKNOWN_ERROR;
- }
- }
-
- }
-
- //contrast
- int new_contrast = params.getInt("contrast");
- if(0 <= new_contrast)
- {
- if(mSecCamera->setContrast(new_contrast) < 0)
- {
- LOGE("ERR(%s):Fail on mSecCamera->setContrast(%d)", __func__, new_contrast);
- ret = UNKNOWN_ERROR;
- }
- }
-
- //WDR
- int new_wdr = params.getInt("wdr");
- if(0 <= new_wdr)
- {
- if(mSecCamera->setWDR(new_wdr) < 0)
- {
- LOGE("ERR(%s):Fail on mSecCamera->setWDR(%d)", __func__, new_wdr);
- ret = UNKNOWN_ERROR;
- }
- }
-
- //anti shake
- int new_anti_shake = params.getInt("anti-shake");
- if(0 <= new_anti_shake)
- {
- if(mSecCamera->setAntiShake(new_anti_shake) < 0)
- {
- LOGE("ERR(%s):Fail on mSecCamera->setWDR(%d)", __func__, new_anti_shake);
- ret = UNKNOWN_ERROR;
- }
- }
-
- //zoom
- int new_zoom_level = params.getInt(CameraParameters::KEY_ZOOM);
- if(0 <= new_zoom_level)
- {
- if(mSecCamera->setZoom(new_zoom_level) < 0)
- {
- LOGE("ERR(%s):Fail on mSecCamera->setZoom(%d)", __func__, new_zoom_level);
- ret = UNKNOWN_ERROR;
- }
- }
-
- //object tracking
- int new_obj_tracking = params.getInt("obj-tracking");
- if(0 <= new_obj_tracking)
- {
- if(mSecCamera->setObjectTracking(new_obj_tracking) < 0)
- {
- LOGE("ERR(%s):Fail on mSecCamera->setObjectTracking(%d)", __func__, new_obj_tracking);
- ret = UNKNOWN_ERROR;
- }
- }
-
- // smart auto
- int new_smart_auto = params.getInt("smart-auto");
- if(0 <= new_smart_auto)
- {
- if(mSecCamera->setSmartAuto(new_smart_auto) < 0)
- {
- LOGE("ERR(%s):Fail on mSecCamera->setSmartAuto(%d)", __func__, new_smart_auto);
- ret = UNKNOWN_ERROR;
- }
-
- //smart auto on => start Smartautoscene Thread
- if(mSecCamera->getSmartAuto() == 1)
- {
- if(startSmartautoscene() == INVALID_OPERATION)
- {
- LOGE("Smartautoscene thread is already running");
- }
- else
- LOGE("Smartautoscene thread start");
- }
- //smart auto off => stop Smartautoscene Thread
- else
- {
- if(mSmartautosceneRunning == true)
- {
- stopSmartautoscene();
- LOGV("Smartautoscene thread stop");
- }
- else
- LOGV("Smartautoscene thread was already stop");
- }
- }
-
- // beauty_shot
- int new_beauty_shot = params.getInt("face_beauty");
- if(0 <= new_beauty_shot)
- {
- if(mSecCamera->setBeautyShot(new_beauty_shot) < 0)
- {
- LOGE("ERR(%s):Fail on mSecCamera->setBeautyShot(%d)", __func__, new_beauty_shot);
- ret = UNKNOWN_ERROR;
- }
- }
-
- // vintage mode
- const char * new_vintage_mode_str = params.get("vintagemode");
- if(new_vintage_mode_str != NULL)
- {
- int new_vintage_mode = -1;
-
- if(strcmp(new_vintage_mode_str, "off") == 0)
- new_vintage_mode = SecCamera::VINTAGE_MODE_OFF;
- else if(strcmp(new_vintage_mode_str, "normal") == 0)
- new_vintage_mode = SecCamera::VINTAGE_MODE_NORMAL;
- else if(strcmp(new_vintage_mode_str, "warm") == 0)
- new_vintage_mode = SecCamera::VINTAGE_MODE_WARM;
- else if(strcmp(new_vintage_mode_str, "cool") == 0)
- new_vintage_mode = SecCamera::VINTAGE_MODE_COOL;
- else if(strcmp(new_vintage_mode_str, "bnw") == 0)
- new_vintage_mode = SecCamera::VINTAGE_MODE_BNW;
- else
- {
- LOGE("%s::unmatched vintage_mode(%d)", __func__, new_vintage_mode);
- ret = UNKNOWN_ERROR;
- }
-
- if(0 <= new_vintage_mode)
- {
- if(mSecCamera->setVintageMode(new_vintage_mode) < 0)
- {
- LOGE("%s::mSecCamera->setVintageMode(%d) fail", __func__, new_vintage_mode);
- ret = UNKNOWN_ERROR;
- }
- }
- }
-
- // gps latitude
- const char * new_gps_latitude_str = params.get("gps-latitude");
- if(mSecCamera->setGPSLatitude(new_gps_latitude_str) < 0)
- {
- LOGE("%s::mSecCamera->setGPSLatitude(%s) fail", __func__, new_gps_latitude_str);
- ret = UNKNOWN_ERROR;
- }
-
- // gps longitude
- const char * new_gps_longitute_str = params.get("gps-longitude");
- if(mSecCamera->setGPSLongitude(new_gps_longitute_str) < 0)
- {
- LOGE("%s::mSecCamera->setGPSLongitude(%s) fail", __func__, new_gps_longitute_str);
- ret = UNKNOWN_ERROR;
- }
-
- // gps altitude
- const char * new_gps_altitude_str = params.get("gps-altitude");
- if(mSecCamera->setGPSAltitude(new_gps_altitude_str) < 0)
- {
- LOGE("%s::mSecCamera->setGPSAltitude(%s) fail", __func__, new_gps_altitude_str);
- ret = UNKNOWN_ERROR;
- }
-
- // gps timestamp
- const char * new_gps_timestamp_str = params.get("gps-timestamp");
- if(mSecCamera->setGPSTimeStamp(new_gps_timestamp_str) < 0)
- {
- LOGE("%s::mSecCamera->setGPSTimeStamp(%s) fail", __func__, new_gps_timestamp_str);
- ret = UNKNOWN_ERROR;
- }
-
- // Recording size
- int new_recording_width = params.getInt("recording-size-width");
- int new_recording_height= params.getInt("recording-size-height");
-
- if(0 < new_recording_width && 0 < new_recording_height) {
- if(mSecCamera->setRecordingSize(new_recording_width, new_recording_height) < 0) {
- LOGE("ERR(%s):Fail on mSecCamera->setRecordingSize(width(%d), height(%d))", __func__, new_recording_width, new_recording_height);
- ret = UNKNOWN_ERROR;
- }
- }
-
- else {
- if(mSecCamera->setRecordingSize(new_preview_width, new_preview_height) < 0) {
- LOGE("ERR(%s):Fail on mSecCamera->setRecordingSize(width(%d), height(%d))", __func__, new_preview_width, new_preview_height);
- ret = UNKNOWN_ERROR;
- }
- }
-
- //gamma
- const char * new_gamma_str = params.get("video_recording_gamma");
- if(new_gamma_str != NULL)
- {
- int new_gamma = -1;
-
- if(strcmp(new_gamma_str, "off") == 0)
- new_gamma = SecCamera::GAMMA_OFF;
- else if(strcmp(new_gamma_str, "on") == 0)
- new_gamma = SecCamera::GAMMA_ON;
- else
- {
- LOGE("%s::unmatched gamma(%s)", __func__, new_gamma_str);
- ret = UNKNOWN_ERROR;
- }
-
- if(0 <= new_gamma)
- {
- if(mSecCamera->setGamma(new_gamma) < 0)
- {
- LOGE("%s::mSecCamera->setGamma(%d) fail", __func__, new_gamma);
- ret = UNKNOWN_ERROR;
- }
- }
- }
-
- //slow ae
- const char * new_slow_ae_str = params.get("slow_ae");
- if(new_slow_ae_str != NULL)
- {
- int new_slow_ae = -1;
-
- if(strcmp(new_slow_ae_str, "off") == 0)
- new_slow_ae = SecCamera::SLOW_AE_OFF;
- else if(strcmp(new_slow_ae_str, "on") == 0)
- new_slow_ae = SecCamera::SLOW_AE_ON;
- else
- {
- LOGE("%s::unmatched slow_ae(%s)", __func__, new_slow_ae_str);
- ret = UNKNOWN_ERROR;
- }
-
- if(0 <= new_slow_ae)
- {
- if(mSecCamera->setSlowAE(new_slow_ae) < 0)
- {
- LOGE("%s::mSecCamera->setSlowAE(%d) fail", __func__, new_slow_ae);
- ret = UNKNOWN_ERROR;
- }
- }
- }
-
- //exif orientation info
- int new_exif_orientation = params.getInt("exifOrientation"); //kidggang
- if(0 <= new_exif_orientation)
- {
- if(mSecCamera->setExifOrientationInfo(new_exif_orientation) < 0)
- {
- LOGE("ERR(%s):Fail on mSecCamera->setExifOrientationInfo(%d)", __func__, new_exif_orientation);
- ret = UNKNOWN_ERROR;
- }
- }
-
- /*Camcorder fix fps*/
- int new_sensor_mode = params.getInt("cam_mode");
- if(0 <= new_sensor_mode)
- {
- if(mSecCamera->setSensorMode(new_sensor_mode) < 0)
- {
- LOGE("ERR(%s):Fail on mSecCamera->setSensorMode(%d)", __func__, new_sensor_mode);
- ret = UNKNOWN_ERROR;
- }
- }
- else
- {
- new_sensor_mode=0;
- }
-
- /*Shot mode*/
- int new_shot_mode = params.getInt("shot_mode");
- if(0 <= new_shot_mode)
- {
- if(mSecCamera->setShotMode(new_shot_mode) < 0)
- {
- LOGE("ERR(%s):Fail on mSecCamera->setShotMode(%d)", __func__, new_shot_mode);
- ret = UNKNOWN_ERROR;
- }
- }
- else
- {
- new_shot_mode=0;
- }
-
- //blur for Video call
- int new_blur_level = params.getInt("blur");
- if(0 <= new_blur_level)
- {
- if(mSecCamera->setBlur(new_blur_level) < 0)
- {
- LOGE("ERR(%s):Fail on mSecCamera->setBlur(%d)", __func__, new_blur_level);
- ret = UNKNOWN_ERROR;
- }
- }
+ // scene mode
+ const char *new_scene_mode_str = params.get(CameraParameters::KEY_SCENE_MODE);
+
+ LOGV("%s() new_scene_mode_str %s", __func__,new_scene_mode_str);
+
+ if (new_scene_mode_str != NULL) {
+ int new_scene_mode = -1;
+
+ const char *new_iso_str = NULL;
+ const char *new_metering_str = NULL;
+ int new_exposure_compensation = 0;
+ const char *new_white_str = NULL;
+ int new_sharpness = 0;
+ int new_saturation = 0;
+ const char *new_focus_mode_str = NULL;
+ const char *new_flash_mode_str = NULL;
+
+ if (strcmp(new_scene_mode_str, CameraParameters::SCENE_MODE_AUTO) == 0) {
+ new_scene_mode = SecCamera::SCENE_MODE_NONE;
+
+ new_iso_str = params.get("iso");
+ new_metering_str = params.get("metering");
+ new_exposure_compensation = params.getInt(CameraParameters::KEY_EXPOSURE_COMPENSATION);
+ new_white_str = params.get(CameraParameters::KEY_WHITE_BALANCE);
+ new_sharpness = params.getInt("sharpness");
+ new_saturation = params.getInt("saturation");
+ new_focus_mode_str = params.get(CameraParameters::KEY_FOCUS_MODE);
+ new_flash_mode_str = params.get(CameraParameters::KEY_FLASH_MODE);
+ } else {
+ if (strcmp(new_scene_mode_str, CameraParameters::SCENE_MODE_PORTRAIT) == 0) {
+ new_scene_mode = SecCamera::SCENE_MODE_PORTRAIT;
+
+ mParameters.set("iso", "auto");
+ mParameters.set("metering", "center");
+ mParameters.set(CameraParameters::KEY_EXPOSURE_COMPENSATION, SecCamera::BRIGHTNESS_NORMAL);
+ mParameters.set(CameraParameters::KEY_WHITE_BALANCE, CameraParameters::WHITE_BALANCE_AUTO);
+ mParameters.set("sharpness", SecCamera::SHARPNESS_MINUS_1);
+ mParameters.set("saturation", SecCamera::SATURATION_NORMAL);
+ mParameters.set(CameraParameters::KEY_FOCUS_MODE, "facedetect");
+ } else if (strcmp(new_scene_mode_str, CameraParameters::SCENE_MODE_LANDSCAPE) == 0) {
+ new_scene_mode = SecCamera::SCENE_MODE_LANDSCAPE;
+
+ mParameters.set("iso", "auto");
+ mParameters.set("metering", "matrix");
+ mParameters.set(CameraParameters::KEY_EXPOSURE_COMPENSATION, SecCamera::BRIGHTNESS_NORMAL);
+ mParameters.set(CameraParameters::KEY_WHITE_BALANCE, CameraParameters::WHITE_BALANCE_AUTO);
+ mParameters.set("sharpness", SecCamera::SHARPNESS_PLUS_1);
+ mParameters.set("saturation", SecCamera::SATURATION_PLUS_1);
+ mParameters.set(CameraParameters::KEY_FOCUS_MODE, CameraParameters::FOCUS_MODE_AUTO);
+ mParameters.set(CameraParameters::KEY_FLASH_MODE, "off");
+ } else if (strcmp(new_scene_mode_str, CameraParameters::SCENE_MODE_SPORTS) == 0) {
+ new_scene_mode = SecCamera::SCENE_MODE_SPORTS;
+
+ mParameters.set("iso", "sports");
+ mParameters.set("metering", "center");
+ mParameters.set(CameraParameters::KEY_EXPOSURE_COMPENSATION, SecCamera::BRIGHTNESS_NORMAL);
+ mParameters.set(CameraParameters::KEY_WHITE_BALANCE, CameraParameters::WHITE_BALANCE_AUTO);
+ mParameters.set("sharpness", SecCamera::SHARPNESS_NORMAL);
+ mParameters.set("saturation", SecCamera::SATURATION_NORMAL);
+ mParameters.set(CameraParameters::KEY_FOCUS_MODE, CameraParameters::FOCUS_MODE_AUTO);
+ mParameters.set(CameraParameters::KEY_FLASH_MODE, "off");
+ } else if (strcmp(new_scene_mode_str, CameraParameters::SCENE_MODE_PARTY) == 0) {
+ new_scene_mode = SecCamera::SCENE_MODE_PARTY_INDOOR;
+
+ mParameters.set("iso", "200");
+ mParameters.set("metering", "center");
+ mParameters.set(CameraParameters::KEY_EXPOSURE_COMPENSATION, SecCamera::BRIGHTNESS_NORMAL);
+ mParameters.set(CameraParameters::KEY_WHITE_BALANCE, CameraParameters::WHITE_BALANCE_AUTO);
+ mParameters.set("sharpness", SecCamera::SHARPNESS_NORMAL);
+ mParameters.set("saturation", SecCamera::SATURATION_PLUS_1);
+ mParameters.set(CameraParameters::KEY_FOCUS_MODE, CameraParameters::FOCUS_MODE_AUTO);
+ } else if ((strcmp(new_scene_mode_str, CameraParameters::SCENE_MODE_BEACH) == 0) ||
+ (strcmp(new_scene_mode_str, CameraParameters::SCENE_MODE_SNOW) == 0)) {
+ new_scene_mode = SecCamera::SCENE_MODE_BEACH_SNOW;
+
+ mParameters.set("iso", "50");
+ mParameters.set("metering", "center");
+ mParameters.set(CameraParameters::KEY_EXPOSURE_COMPENSATION, SecCamera::BRIGHTNESS_PLUS_2);
+ mParameters.set(CameraParameters::KEY_WHITE_BALANCE, CameraParameters::WHITE_BALANCE_AUTO);
+ mParameters.set("sharpness", SecCamera::SHARPNESS_NORMAL);
+ mParameters.set("saturation", SecCamera::SATURATION_PLUS_1);
+ mParameters.set(CameraParameters::KEY_FOCUS_MODE, CameraParameters::FOCUS_MODE_AUTO);
+ mParameters.set(CameraParameters::KEY_FLASH_MODE, "off");
+ } else if (strcmp(new_scene_mode_str, CameraParameters::SCENE_MODE_SUNSET) == 0) {
+ new_scene_mode = SecCamera::SCENE_MODE_SUNSET;
+
+ mParameters.set("iso", "auto");
+ mParameters.set("metering", "center");
+ mParameters.set(CameraParameters::KEY_EXPOSURE_COMPENSATION, SecCamera::BRIGHTNESS_NORMAL);
+ mParameters.set(CameraParameters::KEY_WHITE_BALANCE, CameraParameters::WHITE_BALANCE_DAYLIGHT);
+ mParameters.set("sharpness", SecCamera::SHARPNESS_NORMAL);
+ mParameters.set("saturation", SecCamera::SATURATION_NORMAL);
+ mParameters.set(CameraParameters::KEY_FOCUS_MODE, CameraParameters::FOCUS_MODE_AUTO);
+ mParameters.set(CameraParameters::KEY_FLASH_MODE, "off");
+ } else if (strcmp(new_scene_mode_str, "dusk-dawn") == 0) {
+ new_scene_mode = SecCamera::SCENE_MODE_DUSK_DAWN;
+
+ mParameters.set("iso", "auto");
+ mParameters.set("metering", "center");
+ mParameters.set(CameraParameters::KEY_EXPOSURE_COMPENSATION, SecCamera::BRIGHTNESS_NORMAL);
+ mParameters.set(CameraParameters::KEY_WHITE_BALANCE, CameraParameters::WHITE_BALANCE_FLUORESCENT);
+ mParameters.set("sharpness", SecCamera::SHARPNESS_NORMAL);
+ mParameters.set("saturation", SecCamera::SATURATION_NORMAL);
+ mParameters.set(CameraParameters::KEY_FOCUS_MODE, CameraParameters::FOCUS_MODE_AUTO);
+ mParameters.set(CameraParameters::KEY_FLASH_MODE, "off");
+ } else if (strcmp(new_scene_mode_str, "fall-color") == 0) {
+ new_scene_mode = SecCamera::SCENE_MODE_FALL_COLOR;
+
+ mParameters.set("iso", "auto");
+ mParameters.set("metering", "center");
+ mParameters.set(CameraParameters::KEY_EXPOSURE_COMPENSATION, SecCamera::BRIGHTNESS_NORMAL);
+ mParameters.set(CameraParameters::KEY_WHITE_BALANCE, CameraParameters::WHITE_BALANCE_AUTO);
+ mParameters.set("sharpness", SecCamera::SHARPNESS_NORMAL);
+ mParameters.set("saturation", SecCamera::SATURATION_PLUS_2);
+ mParameters.set(CameraParameters::KEY_FOCUS_MODE, CameraParameters::FOCUS_MODE_AUTO);
+ mParameters.set(CameraParameters::KEY_FLASH_MODE, "off");
+ } else if (strcmp(new_scene_mode_str, CameraParameters::SCENE_MODE_NIGHT) == 0) {
+ new_scene_mode = SecCamera::SCENE_MODE_NIGHTSHOT;
+
+ mParameters.set("iso", "night");
+ mParameters.set("metering", "center");
+ mParameters.set(CameraParameters::KEY_EXPOSURE_COMPENSATION, SecCamera::BRIGHTNESS_NORMAL);
+ mParameters.set(CameraParameters::KEY_WHITE_BALANCE, CameraParameters::WHITE_BALANCE_AUTO);
+ mParameters.set("sharpness", SecCamera::SHARPNESS_NORMAL);
+ mParameters.set("saturation", SecCamera::SATURATION_NORMAL);
+ mParameters.set(CameraParameters::KEY_FOCUS_MODE, CameraParameters::FOCUS_MODE_AUTO);
+ mParameters.set(CameraParameters::KEY_FLASH_MODE, "off");
+ } else if (strcmp(new_scene_mode_str, "back-light") == 0) {
+ const char *flash_mode_str = params.get(CameraParameters::KEY_FLASH_MODE);
+
+ new_scene_mode = SecCamera::SCENE_MODE_BACK_LIGHT;
+
+ mParameters.set("iso", "auto");
+ if (strcmp(flash_mode_str, "off") == 0)
+ mParameters.set("metering", "spot");
+ else
+ mParameters.set("metering", "center");
+ mParameters.set(CameraParameters::KEY_EXPOSURE_COMPENSATION, SecCamera::BRIGHTNESS_NORMAL);
+ mParameters.set(CameraParameters::KEY_WHITE_BALANCE, CameraParameters::WHITE_BALANCE_AUTO);
+ mParameters.set("sharpness", SecCamera::SHARPNESS_NORMAL);
+ mParameters.set("saturation", SecCamera::SATURATION_NORMAL);
+ mParameters.set(CameraParameters::KEY_FOCUS_MODE, CameraParameters::FOCUS_MODE_AUTO);
+ } else if (strcmp(new_scene_mode_str, CameraParameters::SCENE_MODE_FIREWORKS) == 0) {
+ new_scene_mode = SecCamera::SCENE_MODE_FIREWORKS;
+
+ mParameters.set("iso", "50");
+ mParameters.set("metering", "center");
+ mParameters.set(CameraParameters::KEY_EXPOSURE_COMPENSATION, SecCamera::BRIGHTNESS_NORMAL);
+ mParameters.set(CameraParameters::KEY_WHITE_BALANCE, CameraParameters::WHITE_BALANCE_AUTO);
+ mParameters.set("sharpness", SecCamera::SHARPNESS_NORMAL);
+ mParameters.set("saturation", SecCamera::SATURATION_NORMAL);
+ mParameters.set(CameraParameters::KEY_FOCUS_MODE, CameraParameters::FOCUS_MODE_AUTO);
+ mParameters.set(CameraParameters::KEY_FLASH_MODE, "off");
+ } else if (strcmp(new_scene_mode_str, "text") == 0) {
+ new_scene_mode = SecCamera::SCENE_MODE_TEXT;
+
+ mParameters.set("iso", "auto");
+ mParameters.set("metering", "center");
+ mParameters.set(CameraParameters::KEY_EXPOSURE_COMPENSATION, SecCamera::BRIGHTNESS_NORMAL);
+ mParameters.set(CameraParameters::KEY_WHITE_BALANCE, CameraParameters::WHITE_BALANCE_AUTO);
+ mParameters.set("sharpness", SecCamera::SHARPNESS_PLUS_2);
+ mParameters.set("saturation", SecCamera::SATURATION_NORMAL);
+ mParameters.set(CameraParameters::KEY_FOCUS_MODE, CameraParameters::FOCUS_MODE_MACRO);
+ } else if (strcmp(new_scene_mode_str, CameraParameters::SCENE_MODE_CANDLELIGHT) == 0) {
+ new_scene_mode = SecCamera::SCENE_MODE_CANDLE_LIGHT;
+
+ mParameters.set("iso", "auto");
+ mParameters.set("metering", "center");
+ mParameters.set(CameraParameters::KEY_EXPOSURE_COMPENSATION, SecCamera::BRIGHTNESS_NORMAL);
+ mParameters.set(CameraParameters::KEY_WHITE_BALANCE, CameraParameters::WHITE_BALANCE_DAYLIGHT);
+ mParameters.set("sharpness", SecCamera::SHARPNESS_NORMAL);
+ mParameters.set("saturation", SecCamera::SATURATION_NORMAL);
+ mParameters.set(CameraParameters::KEY_FOCUS_MODE, CameraParameters::FOCUS_MODE_AUTO);
+ mParameters.set(CameraParameters::KEY_FLASH_MODE, "off");
+ } else {
+ LOGE("%s::unmatched scene_mode(%s)", __func__, new_scene_mode_str); //action, night-portrait, theatre, steadyphoto
+ ret = UNKNOWN_ERROR;
+ }
+
+ new_iso_str = mParameters.get("iso");
+ new_metering_str = mParameters.get("metering");
+ new_exposure_compensation = mParameters.getInt(CameraParameters::KEY_EXPOSURE_COMPENSATION);
+ new_white_str = mParameters.get(CameraParameters::KEY_WHITE_BALANCE);
+ new_sharpness = mParameters.getInt("sharpness");
+ new_saturation = mParameters.getInt("saturation");
+ new_focus_mode_str = mParameters.get(CameraParameters::KEY_FOCUS_MODE);
+ new_flash_mode_str = mParameters.get(CameraParameters::KEY_FLASH_MODE);
+ }
+
+ // 1. ISO
+ if (new_iso_str != NULL) {
+ int new_iso = -1;
+ if (strcmp(new_iso_str, "auto") == 0)
+ new_iso = SecCamera::ISO_AUTO;
+ else if (strcmp(new_iso_str, "50") == 0)
+ new_iso = SecCamera::ISO_50;
+ else if (strcmp(new_iso_str, "100") == 0)
+ new_iso = SecCamera::ISO_100;
+ else if (strcmp(new_iso_str, "200") == 0)
+ new_iso = SecCamera::ISO_200;
+ else if (strcmp(new_iso_str, "400") == 0)
+ new_iso = SecCamera::ISO_400;
+ else if (strcmp(new_iso_str, "800") == 0)
+ new_iso = SecCamera::ISO_800;
+ else if (strcmp(new_iso_str, "1600") == 0)
+ new_iso = SecCamera::ISO_1600;
+ else if (strcmp(new_iso_str, "sports") == 0)
+ new_iso = SecCamera::ISO_SPORTS;
+ else if (strcmp(new_iso_str, "night") == 0)
+ new_iso = SecCamera::ISO_NIGHT;
+ else if (strcmp(new_iso_str, "movie") == 0)
+ new_iso = SecCamera::ISO_MOVIE;
+ else {
+ LOGE("%s::unmatched iso(%d)", __func__, new_iso);
+ ret = UNKNOWN_ERROR;
+ }
+
+ if (0 <= new_iso) {
+ if (mSecCamera->setISO(new_iso) < 0) {
+ LOGE("%s::mSecCamera->setISO(%d) fail", __func__, new_iso);
+ ret = UNKNOWN_ERROR;
+ }
+ }
+ }
+
+ // 2. metering
+ if (new_metering_str != NULL) {
+ int new_metering = -1;
+ if (strcmp(new_metering_str, "matrix") == 0)
+ new_metering = SecCamera::METERING_MATRIX;
+ else if (strcmp(new_metering_str, "center") == 0)
+ new_metering = SecCamera::METERING_CENTER;
+ else if (strcmp(new_metering_str, "spot") == 0)
+ new_metering = SecCamera::METERING_SPOT;
+ else {
+ LOGE("%s::unmatched metering(%s)", __func__, new_metering_str);
+ ret = UNKNOWN_ERROR;
+ }
+ if (0 <= new_metering) {
+ if (mSecCamera->setMetering(new_metering) < 0) {
+ LOGE("%s::mSecCamera->setMetering(%d) fail", __func__, new_metering);
+ ret = UNKNOWN_ERROR;
+ }
+ }
+ }
+
+ // 3. brightness
+ int max_exposure_compensation = params.getInt(CameraParameters::KEY_MAX_EXPOSURE_COMPENSATION);
+ int min_exposure_compensation = params.getInt(CameraParameters::KEY_MIN_EXPOSURE_COMPENSATION);
+
+ if ((min_exposure_compensation <= new_exposure_compensation) &&
+ (max_exposure_compensation >= new_exposure_compensation)) {
+ if (mSecCamera->setBrightness(new_exposure_compensation) < 0) {
+ LOGE("ERR(%s):Fail on mSecCamera->setBrightness(brightness(%d))", __func__, new_exposure_compensation);
+ ret = UNKNOWN_ERROR;
+ }
+ }
+
+ // 4. whitebalance
+ if (new_white_str != NULL) {
+ int new_white = -1;
+
+ if (strcmp(new_white_str, CameraParameters::WHITE_BALANCE_AUTO) == 0)
+ new_white = SecCamera::WHITE_BALANCE_AUTO;
+ else if (strcmp(new_white_str, CameraParameters::WHITE_BALANCE_DAYLIGHT) == 0)
+ new_white = SecCamera::WHITE_BALANCE_DAYLIGHT;
+ else if ((strcmp(new_white_str, "cloudy") == 0) || (strcmp(new_white_str, "cloudy-daylight") == 0))
+ new_white = SecCamera::WHITE_BALANCE_CLOUDY;
+ else if (strcmp(new_white_str, CameraParameters::WHITE_BALANCE_FLUORESCENT) == 0)
+ new_white = SecCamera::WHITE_BALANCE_FLUORESCENT;
+ else if (strcmp(new_white_str, CameraParameters::WHITE_BALANCE_INCANDESCENT) == 0)
+ new_white = SecCamera::WHITE_BALANCE_INCANDESCENT;
+ else {
+ LOGE("ERR(%s):Invalid white balance(%s)", __func__, new_white_str); //twilight, shade, warm_flourescent
+ ret = UNKNOWN_ERROR;
+ }
+
+ if (0 <= new_white) {
+ // white_balance
+ if (mSecCamera->setWhiteBalance(new_white) < 0) {
+ LOGE("ERR(%s):Fail on mSecCamera->setWhiteBalance(white(%d))", __func__, new_white);
+ ret = UNKNOWN_ERROR;
+ }
+ }
+ }
+
+ //5. sharpness
+ if (0 <= new_sharpness) {
+ if (mSecCamera->setSharpness(new_sharpness) < 0) {
+ LOGE("ERR(%s):Fail on mSecCamera->setSharpness(%d)", __func__,new_sharpness);
+ ret = UNKNOWN_ERROR;
+ }
+ }
+
+ //6. saturation
+ if (0 <= new_saturation) {
+ if (mSecCamera->setSaturation(new_saturation) < 0) {
+ LOGE("ERR(%s):Fail on mSecCamera->setSaturation(%d)", __func__, new_saturation);
+ ret = UNKNOWN_ERROR;
+ }
+ }
+
+ // 7. focus mode
+ if (new_focus_mode_str != NULL) {
+ int new_focus_mode = -1;
+
+ if ((strcmp(new_focus_mode_str, CameraParameters::FOCUS_MODE_AUTO) == 0) || (strcmp(new_focus_mode_str, CameraParameters::FOCUS_MODE_FIXED) == 0) ||(strcmp(new_focus_mode_str, CameraParameters::FOCUS_MODE_INFINITY) == 0))
+ new_focus_mode = SecCamera::FOCUS_MODE_AUTO;
+ else if (strcmp(new_focus_mode_str, CameraParameters::FOCUS_MODE_MACRO) == 0)
+ new_focus_mode = SecCamera::FOCUS_MODE_MACRO;
+ else if (strcmp(new_focus_mode_str, "facedetect") == 0)
+ new_focus_mode = SecCamera::FOCUS_MODE_FACEDETECT;
+ else {
+ LOGE("%s::unmatched focus_mode(%s)", __func__, new_focus_mode_str); //infinity
+ ret = UNKNOWN_ERROR;
+ }
+
+ if (0 <= new_focus_mode) {
+ if (mSecCamera->setFocusMode(new_focus_mode) < 0) {
+ LOGE("%s::mSecCamera->setFocusMode(%d) fail", __func__, new_focus_mode);
+ ret = UNKNOWN_ERROR;
+ }
+ }
+ }
+
+ // 8. flash..
+ if (new_flash_mode_str != NULL) {
+ int new_flash_mode = -1;
+
+ if (strcmp(new_flash_mode_str, CameraParameters::FLASH_MODE_OFF) == 0)
+ new_flash_mode = SecCamera::FLASH_MODE_OFF;
+ else if (strcmp(new_flash_mode_str, CameraParameters::FLASH_MODE_AUTO) == 0)
+ new_flash_mode = SecCamera::FLASH_MODE_AUTO;
+ else if (strcmp(new_flash_mode_str, CameraParameters::FLASH_MODE_ON) == 0)
+ new_flash_mode = SecCamera::FLASH_MODE_ON;
+ else if (strcmp(new_flash_mode_str, CameraParameters::FLASH_MODE_TORCH) == 0)
+ new_flash_mode = SecCamera::FLASH_MODE_TORCH;
+ else {
+ LOGE("%s::unmatched flash_mode(%s)", __func__, new_flash_mode_str); //red-eye
+ ret = UNKNOWN_ERROR;
+ }
+ if (0 <= new_flash_mode) {
+ if (mSecCamera->setFlashMode(new_flash_mode) < 0) {
+ LOGE("%s::mSecCamera->setFlashMode(%d) fail", __func__, new_flash_mode);
+ ret = UNKNOWN_ERROR;
+ }
+ }
+ }
+
+ // 9. scene..
+ if (0 <= new_scene_mode) {
+ if (mSecCamera->setSceneMode(new_scene_mode) < 0) {
+ LOGE("%s::mSecCamera->setSceneMode(%d) fail", __func__, new_scene_mode);
+ ret = UNKNOWN_ERROR;
+ }
+ }
+ }
+
+ // ---------------------------------------------------------------------------
+
+ // image effect
+ const char *new_image_effect_str = params.get(CameraParameters::KEY_EFFECT);
+ if (new_image_effect_str != NULL) {
+
+ int new_image_effect = -1;
+
+ if ((strcmp(new_image_effect_str, "auto") == 0) ||
+ (strcmp(new_image_effect_str, CameraParameters::EFFECT_NONE) == 0))
+ new_image_effect = SecCamera::IMAGE_EFFECT_NONE;
+ else if ((strcmp(new_image_effect_str, "bnw") == 0) ||
+ (strcmp(new_image_effect_str, CameraParameters::EFFECT_MONO) == 0))
+ new_image_effect = SecCamera::IMAGE_EFFECT_BNW;
+ else if (strcmp(new_image_effect_str, CameraParameters::EFFECT_SEPIA) == 0)
+ new_image_effect = SecCamera::IMAGE_EFFECT_SEPIA;
+ else if (strcmp(new_image_effect_str, CameraParameters::EFFECT_AQUA) == 0)
+ new_image_effect = SecCamera::IMAGE_EFFECT_AQUA;
+ else if (strcmp(new_image_effect_str, "antique") == 0) //added at samsung
+ new_image_effect = SecCamera::IMAGE_EFFECT_ANTIQUE;
+ else if (strcmp(new_image_effect_str, CameraParameters::EFFECT_NEGATIVE) == 0)
+ new_image_effect = SecCamera::IMAGE_EFFECT_NEGATIVE;
+ else if (strcmp(new_image_effect_str, "sharpen") == 0) //added at samsung
+ new_image_effect = SecCamera::IMAGE_EFFECT_SHARPEN;
+ else {
+ //posterize, whiteboard, blackboard, solarize
+ LOGE("ERR(%s):Invalid effect(%s)", __func__, new_image_effect_str);
+ ret = UNKNOWN_ERROR;
+ }
+
+ if (new_image_effect >= 0) {
+ if (mSecCamera->setImageEffect(new_image_effect) < 0) {
+ LOGE("ERR(%s):Fail on mSecCamera->setImageEffect(effect(%d))", __func__, new_image_effect);
+ ret = UNKNOWN_ERROR;
+ }
+ }
+ }
+
+ //antiBanding
+ const char *new_antibanding_str = params.get(CameraParameters::KEY_ANTIBANDING);
+
+ if (new_antibanding_str != NULL) {
+ int new_antibanding = -1;
+
+ if (strcmp(new_antibanding_str, CameraParameters::ANTIBANDING_AUTO) == 0)
+ new_antibanding = SecCamera::ANTI_BANDING_AUTO;
+ else if (strcmp(new_antibanding_str, CameraParameters::ANTIBANDING_50HZ) == 0)
+ new_antibanding = SecCamera::ANTI_BANDING_50HZ;
+ else if (strcmp(new_antibanding_str, CameraParameters::ANTIBANDING_60HZ) == 0)
+ new_antibanding = SecCamera::ANTI_BANDING_60HZ;
+ else if (strcmp(new_antibanding_str, CameraParameters::ANTIBANDING_OFF) == 0)
+ new_antibanding = SecCamera::ANTI_BANDING_OFF;
+ else {
+ LOGE("%s::unmatched antibanding(%s)", __func__, new_antibanding_str);
+ ret = UNKNOWN_ERROR;
+ }
+
+ if (0 <= new_antibanding) {
+ if (mSecCamera->setAntiBanding(new_antibanding) < 0) {
+ LOGE("%s::mSecCamera->setAntiBanding(%d) fail", __func__, new_antibanding);
+ ret = UNKNOWN_ERROR;
+ }
+ }
+ }
+
+ //contrast
+ int new_contrast = params.getInt("contrast");
+
+ if (0 <= new_contrast) {
+ if (mSecCamera->setContrast(new_contrast) < 0) {
+ LOGE("ERR(%s):Fail on mSecCamera->setContrast(%d)", __func__, new_contrast);
+ ret = UNKNOWN_ERROR;
+ }
+ }
+
+ //WDR
+ int new_wdr = params.getInt("wdr");
+
+ if (0 <= new_wdr) {
+ if (mSecCamera->setWDR(new_wdr) < 0) {
+ LOGE("ERR(%s):Fail on mSecCamera->setWDR(%d)", __func__, new_wdr);
+ ret = UNKNOWN_ERROR;
+ }
+ }
+
+ //anti shake
+ int new_anti_shake = params.getInt("anti-shake");
+
+ if (0 <= new_anti_shake) {
+ if (mSecCamera->setAntiShake(new_anti_shake) < 0) {
+ LOGE("ERR(%s):Fail on mSecCamera->setWDR(%d)", __func__, new_anti_shake);
+ ret = UNKNOWN_ERROR;
+ }
+ }
+
+ //zoom
+ int new_zoom_level = params.getInt(CameraParameters::KEY_ZOOM);
+
+ if (0 <= new_zoom_level) {
+ if (mSecCamera->setZoom(new_zoom_level) < 0) {
+ LOGE("ERR(%s):Fail on mSecCamera->setZoom(%d)", __func__, new_zoom_level);
+ ret = UNKNOWN_ERROR;
+ }
+ }
+
+ //object tracking
+ int new_obj_tracking = params.getInt("obj-tracking");
+
+ if (0 <= new_obj_tracking) {
+ if (mSecCamera->setObjectTracking(new_obj_tracking) < 0) {
+ LOGE("ERR(%s):Fail on mSecCamera->setObjectTracking(%d)", __func__, new_obj_tracking);
+ ret = UNKNOWN_ERROR;
+ }
+ }
+
+ // smart auto
+ int new_smart_auto = params.getInt("smart-auto");
+
+ if (0 <= new_smart_auto) {
+ if (mSecCamera->setSmartAuto(new_smart_auto) < 0) {
+ LOGE("ERR(%s):Fail on mSecCamera->setSmartAuto(%d)", __func__, new_smart_auto);
+ ret = UNKNOWN_ERROR;
+ }
+
+ //smart auto on => start Smartautoscene Thread
+ if (mSecCamera->getSmartAuto() == 1) {
+ if (startSmartautoscene() == INVALID_OPERATION) {
+ LOGE("Smartautoscene thread is already running");
+ } else
+ LOGE("Smartautoscene thread start");
+ } else { //smart auto off => stop Smartautoscene Thread
+ if (mSmartautosceneRunning == true) {
+ stopSmartautoscene();
+ LOGV("Smartautoscene thread stop");
+ } else
+ LOGV("Smartautoscene thread was already stop");
+ }
+ }
+
+ // beauty_shot
+ int new_beauty_shot = params.getInt("face_beauty");
+
+ if (0 <= new_beauty_shot) {
+ if (mSecCamera->setBeautyShot(new_beauty_shot) < 0) {
+ LOGE("ERR(%s):Fail on mSecCamera->setBeautyShot(%d)", __func__, new_beauty_shot);
+ ret = UNKNOWN_ERROR;
+ }
+ }
+
+ // vintage mode
+ const char *new_vintage_mode_str = params.get("vintagemode");
+
+ if (new_vintage_mode_str != NULL) {
+ int new_vintage_mode = -1;
+
+ if (strcmp(new_vintage_mode_str, "off") == 0)
+ new_vintage_mode = SecCamera::VINTAGE_MODE_OFF;
+ else if (strcmp(new_vintage_mode_str, "normal") == 0)
+ new_vintage_mode = SecCamera::VINTAGE_MODE_NORMAL;
+ else if (strcmp(new_vintage_mode_str, "warm") == 0)
+ new_vintage_mode = SecCamera::VINTAGE_MODE_WARM;
+ else if (strcmp(new_vintage_mode_str, "cool") == 0)
+ new_vintage_mode = SecCamera::VINTAGE_MODE_COOL;
+ else if (strcmp(new_vintage_mode_str, "bnw") == 0)
+ new_vintage_mode = SecCamera::VINTAGE_MODE_BNW;
+ else {
+ LOGE("%s::unmatched vintage_mode(%d)", __func__, new_vintage_mode);
+ ret = UNKNOWN_ERROR;
+ }
+
+ if (0 <= new_vintage_mode) {
+ if (mSecCamera->setVintageMode(new_vintage_mode) < 0) {
+ LOGE("%s::mSecCamera->setVintageMode(%d) fail", __func__, new_vintage_mode);
+ ret = UNKNOWN_ERROR;
+ }
+ }
+ }
+
+ // gps latitude
+ const char *new_gps_latitude_str = params.get("gps-latitude");
+
+ if (mSecCamera->setGPSLatitude(new_gps_latitude_str) < 0) {
+ LOGE("%s::mSecCamera->setGPSLatitude(%s) fail", __func__, new_gps_latitude_str);
+ ret = UNKNOWN_ERROR;
+ }
+
+ // gps longitude
+ const char *new_gps_longitute_str = params.get("gps-longitude");
+
+ if (mSecCamera->setGPSLongitude(new_gps_longitute_str) < 0) {
+ LOGE("%s::mSecCamera->setGPSLongitude(%s) fail", __func__, new_gps_longitute_str);
+ ret = UNKNOWN_ERROR;
+ }
+
+ // gps altitude
+ const char *new_gps_altitude_str = params.get("gps-altitude");
+
+ if (mSecCamera->setGPSAltitude(new_gps_altitude_str) < 0) {
+ LOGE("%s::mSecCamera->setGPSAltitude(%s) fail", __func__, new_gps_altitude_str);
+ ret = UNKNOWN_ERROR;
+ }
+
+ // gps timestamp
+ const char *new_gps_timestamp_str = params.get("gps-timestamp");
+
+ if (mSecCamera->setGPSTimeStamp(new_gps_timestamp_str) < 0) {
+ LOGE("%s::mSecCamera->setGPSTimeStamp(%s) fail", __func__, new_gps_timestamp_str);
+ ret = UNKNOWN_ERROR;
+ }
+
+ // Recording size
+ int new_recording_width = params.getInt("recording-size-width");
+ int new_recording_height= params.getInt("recording-size-height");
+
+ if (0 < new_recording_width && 0 < new_recording_height) {
+ if (mSecCamera->setRecordingSize(new_recording_width, new_recording_height) < 0) {
+ LOGE("ERR(%s):Fail on mSecCamera->setRecordingSize(width(%d), height(%d))", __func__, new_recording_width, new_recording_height);
+ ret = UNKNOWN_ERROR;
+ }
+ } else {
+ if (mSecCamera->setRecordingSize(new_preview_width, new_preview_height) < 0) {
+ LOGE("ERR(%s):Fail on mSecCamera->setRecordingSize(width(%d), height(%d))", __func__, new_preview_width, new_preview_height);
+ ret = UNKNOWN_ERROR;
+ }
+ }
+
+ //gamma
+ const char *new_gamma_str = params.get("video_recording_gamma");
+
+ if (new_gamma_str != NULL) {
+ int new_gamma = -1;
+
+ if (strcmp(new_gamma_str, "off") == 0)
+ new_gamma = SecCamera::GAMMA_OFF;
+ else if (strcmp(new_gamma_str, "on") == 0)
+ new_gamma = SecCamera::GAMMA_ON;
+ else {
+ LOGE("%s::unmatched gamma(%s)", __func__, new_gamma_str);
+ ret = UNKNOWN_ERROR;
+ }
+
+ if (0 <= new_gamma) {
+ if (mSecCamera->setGamma(new_gamma) < 0) {
+ LOGE("%s::mSecCamera->setGamma(%d) fail", __func__, new_gamma);
+ ret = UNKNOWN_ERROR;
+ }
+ }
+ }
+
+ //slow ae
+ const char *new_slow_ae_str = params.get("slow_ae");
+
+ if (new_slow_ae_str != NULL) {
+ int new_slow_ae = -1;
+
+ if (strcmp(new_slow_ae_str, "off") == 0)
+ new_slow_ae = SecCamera::SLOW_AE_OFF;
+ else if (strcmp(new_slow_ae_str, "on") == 0)
+ new_slow_ae = SecCamera::SLOW_AE_ON;
+ else {
+ LOGE("%s::unmatched slow_ae(%s)", __func__, new_slow_ae_str);
+ ret = UNKNOWN_ERROR;
+ }
+
+ if (0 <= new_slow_ae) {
+ if (mSecCamera->setSlowAE(new_slow_ae) < 0) {
+ LOGE("%s::mSecCamera->setSlowAE(%d) fail", __func__, new_slow_ae);
+ ret = UNKNOWN_ERROR;
+ }
+ }
+ }
+
+ //exif orientation info
+ int new_exif_orientation = params.getInt("exifOrientation");
+
+ if (0 <= new_exif_orientation) {
+ if (mSecCamera->setExifOrientationInfo(new_exif_orientation) < 0) {
+ LOGE("ERR(%s):Fail on mSecCamera->setExifOrientationInfo(%d)", __func__, new_exif_orientation);
+ ret = UNKNOWN_ERROR;
+ }
+ }
+
+ /*Camcorder fix fps*/
+ int new_sensor_mode = params.getInt("cam_mode");
+
+ if (0 <= new_sensor_mode) {
+ if (mSecCamera->setSensorMode(new_sensor_mode) < 0) {
+ LOGE("ERR(%s):Fail on mSecCamera->setSensorMode(%d)", __func__, new_sensor_mode);
+ ret = UNKNOWN_ERROR;
+ }
+ } else {
+ new_sensor_mode=0;
+ }
+
+ /*Shot mode*/
+ int new_shot_mode = params.getInt("shot_mode");
+
+ if (0 <= new_shot_mode) {
+ if (mSecCamera->setShotMode(new_shot_mode) < 0) {
+ LOGE("ERR(%s):Fail on mSecCamera->setShotMode(%d)", __func__, new_shot_mode);
+ ret = UNKNOWN_ERROR;
+ }
+ } else {
+ new_shot_mode=0;
+ }
+
+ //blur for Video call
+ int new_blur_level = params.getInt("blur");
+
+ if (0 <= new_blur_level) {
+ if (mSecCamera->setBlur(new_blur_level) < 0) {
+ LOGE("ERR(%s):Fail on mSecCamera->setBlur(%d)", __func__, new_blur_level);
+ ret = UNKNOWN_ERROR;
+ }
+ }
// chk_dataline
- int new_dataline = params.getInt("chk_dataline");
- if(0 <= new_dataline)
- {
- if(mSecCamera->setDataLineCheck(new_dataline) < 0)
- {
- LOGE("ERR(%s):Fail on mSecCamera->setDataLineCheck(%d)", __func__, new_dataline);
- ret = UNKNOWN_ERROR;
- }
- }
-
- //Batch Command
- if(new_camera_id == SecCamera::CAMERA_ID_BACK)
- {
- if(mSecCamera->setBatchReflection() < 0)
- {
- LOGE("ERR(%s):Fail on mSecCamera->setBatchCmd", __func__);
- ret = UNKNOWN_ERROR;
- }
- }
+ int new_dataline = params.getInt("chk_dataline");
+
+ if (0 <= new_dataline) {
+ if (mSecCamera->setDataLineCheck(new_dataline) < 0) {
+ LOGE("ERR(%s):Fail on mSecCamera->setDataLineCheck(%d)", __func__, new_dataline);
+ ret = UNKNOWN_ERROR;
+ }
+ }
+
+ //Batch Command
+ if (new_camera_id == SecCamera::CAMERA_ID_BACK) {
+ if (mSecCamera->setBatchReflection() < 0) {
+ LOGE("ERR(%s):Fail on mSecCamera->setBatchCmd", __func__);
+ ret = UNKNOWN_ERROR;
+ }
+ }
#endif
- return ret;
+ return ret;
}
CameraParameters CameraHardwareSec::getParameters() const
{
- LOGV("%s()", __func__);
- Mutex::Autolock lock(mLock);
- return mParameters;
+ LOGV("%s()", __func__);
+ Mutex::Autolock lock(mLock);
+ return mParameters;
}
status_t CameraHardwareSec::sendCommand(int32_t command, int32_t arg1, int32_t arg2)
{
#ifdef SWP1_CAMERA_ADD_ADVANCED_FUNCTION
- LOGV("%s() : command = %d, arg1 =%d, arg2= %d", __func__,command, arg1, arg2);
- switch(command)
- {
- case COMMAND_AE_AWB_LOCK_UNLOCK:
- mSecCamera->setAEAWBLockUnlock(arg1, arg2);
- break;
- case COMMAND_FACE_DETECT_LOCK_UNLOCK:
- mSecCamera->setFaceDetectLockUnlock(arg1);
- break;
- case COMMAND_OBJECT_POSITION:
- mSecCamera->setObjectPosition(arg1, arg2);
- break;
- case COMMAND_OBJECT_TRACKING_STARTSTOP:
- mSecCamera->setObjectTrackingStartStop(arg1);
- objectTracking(arg1);
- break;
- case CONTINUOUS_SHOT_START_CAPTURE:
- break;
- case CONTINUOUS_SHOT_STOP_AND_ENCODING:
- mSecCamera->setAEAWBLockUnlock(arg1, arg2);
- LOGV("Continuous shot command received");
- break;
- case COMMAND_TOUCH_AF_STARTSTOP:
- mSecCamera->setTouchAFStartStop(arg1);
- break;
- case COMMAND_CHECK_DATALINE:
- mSecCamera->setDataLineCheckStop();
- break;
- case COMMAND_DEFAULT_IMEI:
- mSecCamera->setDefultIMEI(arg1);
- break;
- defualt:
- LOGV("%s()", __func__);
- break;
- }
-
- return NO_ERROR;
+ LOGV("%s() : command = %d, arg1 =%d, arg2= %d", __func__,command, arg1, arg2);
+ switch (command) {
+ case COMMAND_AE_AWB_LOCK_UNLOCK:
+ mSecCamera->setAEAWBLockUnlock(arg1, arg2);
+ break;
+ case COMMAND_FACE_DETECT_LOCK_UNLOCK:
+ mSecCamera->setFaceDetectLockUnlock(arg1);
+ break;
+ case COMMAND_OBJECT_POSITION:
+ mSecCamera->setObjectPosition(arg1, arg2);
+ break;
+ case COMMAND_OBJECT_TRACKING_STARTSTOP:
+ mSecCamera->setObjectTrackingStartStop(arg1);
+ objectTracking(arg1);
+ break;
+ case CONTINUOUS_SHOT_START_CAPTURE:
+ break;
+ case CONTINUOUS_SHOT_STOP_AND_ENCODING:
+ mSecCamera->setAEAWBLockUnlock(arg1, arg2);
+ LOGV("Continuous shot command received");
+ break;
+ case COMMAND_TOUCH_AF_STARTSTOP:
+ mSecCamera->setTouchAFStartStop(arg1);
+ break;
+ case COMMAND_CHECK_DATALINE:
+ mSecCamera->setDataLineCheckStop();
+ break;
+ case COMMAND_DEFAULT_IMEI:
+ mSecCamera->setDefultIMEI(arg1);
+ break;
+ defualt:
+ LOGV("%s()", __func__);
+ break;
+ }
+
+ return NO_ERROR;
#else
return BAD_VALUE;
#endif
@@ -2512,29 +2337,29 @@ status_t CameraHardwareSec::sendCommand(int32_t command, int32_t arg1, int32_t a
void CameraHardwareSec::release()
{
- LOGV("%s()", __func__);
+ LOGV("%s()", __func__);
}
wp<CameraHardwareInterface> CameraHardwareSec::singleton;
sp<CameraHardwareInterface> CameraHardwareSec::createInstance(int cameraId)
{
- LOGV("%s()", __func__);
- if (singleton != 0) {
- sp<CameraHardwareInterface> hardware = singleton.promote();
- if (hardware != 0) {
- return hardware;
- }
- }
- sp<CameraHardwareInterface> hardware(new CameraHardwareSec(cameraId));
- singleton = hardware;
- return hardware;
+ LOGV("%s()", __func__);
+ if (singleton != 0) {
+ sp<CameraHardwareInterface> hardware = singleton.promote();
+ if (hardware != 0) {
+ return hardware;
+ }
+ }
+ sp<CameraHardwareInterface> hardware(new CameraHardwareSec(cameraId));
+ singleton = hardware;
+ return hardware;
}
#if 0
extern "C" sp<CameraHardwareInterface> openCameraHardware()
{
- LOGV("%s()", __func__);
- return CameraHardwareSec::createInstance();
+ LOGV("%s()", __func__);
+ return CameraHardwareSec::createInstance();
}
#endif
@@ -2543,8 +2368,7 @@ static CameraInfo sCameraInfo[] = {
CAMERA_FACING_BACK,
90, /* orientation */
},
-
- {
+ {
CAMERA_FACING_FRONT,
0, /* orientation */
}
@@ -2555,7 +2379,7 @@ extern "C" int HAL_getNumberOfCameras()
return sizeof(sCameraInfo) / sizeof(sCameraInfo[0]);
}
-extern "C" void HAL_getCameraInfo(int cameraId, struct CameraInfo* cameraInfo)
+extern "C" void HAL_getCameraInfo(int cameraId, struct CameraInfo *cameraInfo)
{
memcpy(cameraInfo, &sCameraInfo[cameraId], sizeof(CameraInfo));
}
diff --git a/libcamera/SecCameraHWInterface.h b/libcamera/SecCameraHWInterface.h
index 1adb023..3a4c509 100644
--- a/libcamera/SecCameraHWInterface.h
+++ b/libcamera/SecCameraHWInterface.h
@@ -12,7 +12,7 @@
** distributed under the License is distributed on an "AS IS" BASIS,
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
** See the License for the specific language governing permissions and
-** limitations under the License.
+** limitations under the License.
*/
#ifndef ANDROID_HARDWARE_CAMERA_HARDWARE_SEC_H
@@ -35,7 +35,7 @@ public:
virtual void setCallbacks(notify_callback notify_cb,
data_callback data_cb,
data_callback_timestamp data_cb_timestamp,
- void* user);
+ void *user);
virtual void enableMsgType(int32_t msgType);
virtual void disableMsgType(int32_t msgType);
@@ -50,28 +50,28 @@ public:
virtual bool previewEnabled();
#ifdef SWP1_CAMERA_ADD_ADVANCED_FUNCTION
- virtual status_t startSmartautoscene();
- virtual void stopSmartautoscene();
- virtual bool smartautosceneEnabled();
+ virtual status_t startSmartautoscene();
+ virtual void stopSmartautoscene();
+ virtual bool smartautosceneEnabled();
#endif
virtual status_t startRecording();
virtual void stopRecording();
virtual bool recordingEnabled();
- virtual void releaseRecordingFrame(const sp<IMemory>& mem);
+ virtual void releaseRecordingFrame(const sp<IMemory> &mem);
virtual status_t autoFocus();
virtual status_t cancelAutoFocus();
virtual status_t takePicture();
virtual status_t cancelPicture();
- virtual status_t dump(int fd, const Vector<String16>& args) const;
+ virtual status_t dump(int fd, const Vector<String16> &args) const;
virtual status_t setParameters(const CameraParameters& params);
virtual CameraParameters getParameters() const;
virtual status_t sendCommand(int32_t command, int32_t arg1,
int32_t arg2);
- virtual void release();
+ virtual void release();
- static sp<CameraHardwareInterface> createInstance(int cameraId);
+ static sp<CameraHardwareInterface> createInstance(int cameraId);
private:
CameraHardwareSec(int cameraId);
@@ -79,21 +79,21 @@ private:
static wp<CameraHardwareInterface> singleton;
- static const int kBufferCount = MAX_BUFFERS;
- static const int kBufferCountForRecord = MAX_BUFFERS;
+ static const int kBufferCount = MAX_BUFFERS;
+ static const int kBufferCountForRecord = MAX_BUFFERS;
class PreviewThread : public Thread {
- CameraHardwareSec* mHardware;
+ CameraHardwareSec *mHardware;
public:
- PreviewThread(CameraHardwareSec* hw):
+ PreviewThread(CameraHardwareSec *hw):
#ifdef SINGLE_PROCESS
- // In single process mode this thread needs to be a java thread,
- // since we won't be calling through the binder.
- Thread(true),
+ // In single process mode this thread needs to be a java thread,
+ // since we won't be calling through the binder.
+ Thread(true),
#else
- Thread(false),
+ Thread(false),
#endif
- mHardware(hw) { }
+ mHardware(hw) { }
virtual void onFirstRef() {
run("CameraPreviewThread", PRIORITY_URGENT_DISPLAY);
}
@@ -101,65 +101,66 @@ private:
int ret = mHardware->previewThread();
// loop until we need to quit
if(ret == NO_ERROR)
- return true;
- else
- return false;
+ return true;
+ else
+ return false;
}
};
-#ifdef SWP1_CAMERA_ADD_ADVANCED_FUNCTION
- class SmartautosceneThread : public Thread {
- CameraHardwareSec* mHardware;
- public:
- SmartautosceneThread(CameraHardwareSec* hw):
+#ifdef SWP1_CAMERA_ADD_ADVANCED_FUNCTION
+ class SmartautosceneThread : public Thread {
+ CameraHardwareSec *mHardware;
+ public:
+ SmartautosceneThread(CameraHardwareSec *hw):
#ifdef SINGLE_PROCESS
- // In single process mode this thread needs to be a java thread,
- // since we won't be calling through the binder.
- Thread(true),
+ // In single process mode this thread needs to be a java thread,
+ // since we won't be calling through the binder.
+ Thread(true),
#else
- Thread(false),
+ Thread(false),
#endif
- mHardware(hw) { }
- virtual void onFirstRef() {
- run("CameraSmartautosceneThread", PRIORITY_URGENT_DISPLAY);
- }
- virtual bool threadLoop() {
- int ret = mHardware->smartautosceneThread();
- // loop until we need to quit
- if(ret == NO_ERROR)
- return true;
- else
- return false;
- }
- };
+ mHardware(hw) { }
+ virtual void onFirstRef() {
+ run("CameraSmartautosceneThread", PRIORITY_URGENT_DISPLAY);
+ }
+ virtual bool threadLoop() {
+ int ret = mHardware->smartautosceneThread();
+ // loop until we need to quit
+ if(ret == NO_ERROR)
+ return true;
+ else
+ return false;
+ }
+ };
#endif
- void initDefaultParameters(int cameraId);
- void initHeapLocked();
+ void initDefaultParameters(int cameraId);
+ void initHeapLocked();
- int previewThread();
-#ifdef SWP1_CAMERA_ADD_ADVANCED_FUNCTION
- int smartautosceneThread();
+ int previewThread();
+#ifdef SWP1_CAMERA_ADD_ADVANCED_FUNCTION
+ int smartautosceneThread();
#endif
- static int beginAutoFocusThread(void *cookie);
- int autoFocusThread();
-
- static int beginPictureThread(void *cookie);
- int pictureThread();
- int save_jpeg( unsigned char * real_jpeg, int jpeg_size);
- void save_postview(const char *fname, uint8_t *buf, uint32_t size);
- int decodeInterleaveData(unsigned char *pInterleaveData,
- int interleaveDataSize,
- int yuvWidth,
- int yuvHeight,
- int *pJpegSize,
- void *pJpegData,
- void *pYuvData);
+ static int beginAutoFocusThread(void *cookie);
+ int autoFocusThread();
+
+ static int beginPictureThread(void *cookie);
+ int pictureThread();
+ int save_jpeg(unsigned char *real_jpeg, int jpeg_size);
+ void save_postview(const char *fname, uint8_t *buf,
+ uint32_t size);
+ int decodeInterleaveData(unsigned char *pInterleaveData,
+ int interleaveDataSize,
+ int yuvWidth,
+ int yuvHeight,
+ int *pJpegSize,
+ void *pJpegData,
+ void *pYuvData);
#ifdef SWP1_CAMERA_ADD_ADVANCED_FUNCTION
- static int beginObjectTrackingThread(void *cookie);
- int objectTrackingThread();
- status_t objectTracking(int onoff);
+ static int beginObjectTrackingThread(void *cookie);
+ int objectTrackingThread();
+ status_t objectTracking(int onoff);
#endif
mutable Mutex mLock;
@@ -173,70 +174,69 @@ private:
sp<MemoryBase> mBuffers[kBufferCount];
sp<MemoryBase> mRecordBuffers[kBufferCountForRecord];
- SecCamera *mSecCamera;
- bool mPreviewRunning;
- int mPreviewFrameSize;
- int mRawFrameSize;
- int mPreviewFrameRateMicrosec;
+ SecCamera *mSecCamera;
+ bool mPreviewRunning;
+ int mPreviewFrameSize;
+ int mRawFrameSize;
+ int mPreviewFrameRateMicrosec;
#if defined(BOARD_USES_OVERLAY)
- sp<Overlay> mOverlay;
- bool mUseOverlay;
+ sp<Overlay> mOverlay;
+ bool mUseOverlay;
#endif
// protected by mLock
sp<PreviewThread> mPreviewThread;
-#ifdef SWP1_CAMERA_ADD_ADVANCED_FUNCTION
- sp<SmartautosceneThread> mSmartautosceneThread;
+#ifdef SWP1_CAMERA_ADD_ADVANCED_FUNCTION
+ sp<SmartautosceneThread> mSmartautosceneThread;
#endif
- notify_callback mNotifyCb;
- data_callback mDataCb;
+ notify_callback mNotifyCb;
+ data_callback mDataCb;
data_callback_timestamp mDataCbTimestamp;
- void *mCallbackCookie;
+ void *mCallbackCookie;
- int32_t mMsgEnabled;
+ int32_t mMsgEnabled;
- // only used from PreviewThread
- int mCurrentPreviewFrame;
- int mCurrentRecordFrame;
+ // only used from PreviewThread
+ int mCurrentPreviewFrame;
+ int mCurrentRecordFrame;
- bool mRecordRunning;
-#ifdef JPEG_FROM_SENSOR
- int mPostViewWidth;
- int mPostViewHeight;
- int mPostViewSize;
-#endif
+ bool mRecordRunning;
+#ifdef JPEG_FROM_SENSOR
+ int mPostViewWidth;
+ int mPostViewHeight;
+ int mPostViewSize;
+#endif
- int mNoHwHandle;
- struct timeval mTimeStart;
- struct timeval mTimeStop;
+ int mNoHwHandle;
+ struct timeval mTimeStart;
+ struct timeval mTimeStop;
#ifdef SWP1_CAMERA_ADD_ADVANCED_FUNCTION
- enum COMMAND_DEFINE
- {
- COMMAND_AE_AWB_LOCK_UNLOCK = 1101,
- COMMAND_FACE_DETECT_LOCK_UNLOCK = 1102,
- COMMAND_OBJECT_POSITION = 1103,
- COMMAND_OBJECT_TRACKING_STARTSTOP = 1104,
- COMMAND_TOUCH_AF_STARTSTOP = 1105,
- COMMAND_CHECK_DATALINE = 1106,
- CONTINUOUS_SHOT_START_CAPTURE = 1023,
- CONTINUOUS_SHOT_STOP_AND_ENCODING = 1024,
- COMMAND_DEFAULT_IMEI = 1107,
- };
-
-class ObjectTrackingThread : public Thread {
- CameraHardwareSec* mHardware;
+ enum COMMAND_DEFINE {
+ COMMAND_AE_AWB_LOCK_UNLOCK = 1101,
+ COMMAND_FACE_DETECT_LOCK_UNLOCK = 1102,
+ COMMAND_OBJECT_POSITION = 1103,
+ COMMAND_OBJECT_TRACKING_STARTSTOP = 1104,
+ COMMAND_TOUCH_AF_STARTSTOP = 1105,
+ COMMAND_CHECK_DATALINE = 1106,
+ CONTINUOUS_SHOT_START_CAPTURE = 1023,
+ CONTINUOUS_SHOT_STOP_AND_ENCODING = 1024,
+ COMMAND_DEFAULT_IMEI = 1107,
+ };
+
+ class ObjectTrackingThread : public Thread {
+ CameraHardwareSec *mHardware;
public:
- ObjectTrackingThread(CameraHardwareSec* hw):
-#ifdef SINGLE_PROCESS
- // In single process mode this thread needs to be a java thread,
- // since we won't be calling through the binder.
- Thread(true),
-#else
- Thread(false),
-#endif
- mHardware(hw) { }
+ ObjectTrackingThread(CameraHardwareSec *hw):
+ #ifdef SINGLE_PROCESS
+ // In single process mode this thread needs to be a java thread,
+ // since we won't be calling through the binder.
+ Thread(true),
+ #else
+ Thread(false),
+ #endif
+ mHardware(hw) { }
virtual void onFirstRef() {
run("CameraObjectTrackingThread", PRIORITY_URGENT_DISPLAY);
}
@@ -244,19 +244,20 @@ class ObjectTrackingThread : public Thread {
int ret = mHardware->objectTrackingThread();
// loop until we need to quit
if(ret == NO_ERROR)
- return true;
- else
- return false;
+ return true;
+ else
+ return false;
}
};
- bool mObjectTrackingRunning;
- sp<ObjectTrackingThread> mObjectTrackingThread;
- int mObjectTrackingStatus;
-
- bool mSmartautosceneRunning;
- int mSmartautoscene_current_status;
- int mSmartautoscene_previous_status;
- int af_thread_status;
+
+ bool mObjectTrackingRunning;
+ sp<ObjectTrackingThread> mObjectTrackingThread;
+ int mObjectTrackingStatus;
+
+ bool mSmartautosceneRunning;
+ int mSmartautoscene_current_status;
+ int mSmartautoscene_previous_status;
+ int af_thread_status;
#endif
};