diff options
author | Jeong-Seok Yang <jseok.yang@samsung.com> | 2010-10-06 03:21:16 +0900 |
---|---|---|
committer | Simon Wilson <simonwilson@google.com> | 2010-10-08 14:17:04 -0700 |
commit | cc8274b15fe9e35d6ea693c80c92482cbf0fb405 (patch) | |
tree | 7c093b3ae060374b87a66195d51225d99df13222 /libcamera | |
parent | f13282cadba4e5b953ecb396e6a2dea367bed9d3 (diff) | |
download | device_samsung_crespo-cc8274b15fe9e35d6ea693c80c92482cbf0fb405.zip device_samsung_crespo-cc8274b15fe9e35d6ea693c80c92482cbf0fb405.tar.gz device_samsung_crespo-cc8274b15fe9e35d6ea693c80c92482cbf0fb405.tar.bz2 |
S5PC11X: CAMERA: Add support for 5MP SLSI camera
Cleaned up parameters so that we advertise the
right features for the front and back cameras.
Also remove a lot of unsupported features.
Change-Id: I3b2fd77153c7855cccf27733ee87c1379d357be8
Signed-off-by: Jeong-Seok Yang <jseok.yang@samsung.com>
Signed-off-by: Mike J. Chen <mjchen@sta.samsung.com>
Diffstat (limited to 'libcamera')
-rw-r--r-- | libcamera/SecCamera.cpp | 398 | ||||
-rw-r--r-- | libcamera/SecCamera.h | 23 | ||||
-rw-r--r-- | libcamera/SecCameraHWInterface.cpp | 741 | ||||
-rw-r--r-- | libcamera/SecCameraHWInterface.h | 107 |
4 files changed, 461 insertions, 808 deletions
diff --git a/libcamera/SecCamera.cpp b/libcamera/SecCamera.cpp index 59d9d27..91117bc 100644 --- a/libcamera/SecCamera.cpp +++ b/libcamera/SecCamera.cpp @@ -34,20 +34,8 @@ #include "SecCamera.h" #include "cutils/properties.h" -#ifdef BOARD_USES_SDTV -#include "TvOut.h" -#endif - using namespace android; -#ifdef BOARD_USES_SDTV -#include "utils/Timers.h" -//#define MEASURE_DURATION_TVOUT -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 @@ -286,18 +274,18 @@ static int fimc_v4l2_querycap(int fp) return ret; } -static int fimc_v4l2_enuminput(int fp, int index) +static const __u8* fimc_v4l2_enuminput(int fp, int index) { - struct v4l2_input input; + static struct v4l2_input input; input.index = index; if (ioctl(fp, VIDIOC_ENUMINPUT, &input) != 0) { LOGE("ERR(%s):No matching index found\n", __func__); - return -1; + return NULL; } LOGI("Name of input channel[%d] is %s\n", input.index, input.name); - return 0; + return input.name; } @@ -559,7 +547,8 @@ static int fimc_v4l2_s_ctrl(int fp, unsigned int id, unsigned int value) ret = ioctl(fp, VIDIOC_S_CTRL, &ctrl); if (ret < 0) { - LOGE("ERR(%s):VIDIOC_S_CTRL failed, ret: %d\n", __func__, ret); + LOGE("ERR(%s):VIDIOC_S_CTRL failed, ret: %d, value = %d, id = %#x\n", + __func__, ret, value, id); return ret; } @@ -626,35 +615,15 @@ static int fimc_v4l2_s_parm(int fp, int fps_numerator, int fps_denominator) 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; - - 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", __func__); - return ret; - } - - return 0; -} -#endif - // ====================================================================== // Constructor & Destructor SecCamera::SecCamera() : m_focus_mode(1), - m_iso(0), + m_iso(-1), + m_flag_init(0), m_camera_id(CAMERA_ID_BACK), - m_preview_v4lformat(-1), + m_preview_v4lformat(V4L2_PIX_FMT_NV21), m_preview_width (0), m_preview_height (0), m_preview_max_width (MAX_BACK_CAMERA_PREVIEW_WIDTH), @@ -664,79 +633,53 @@ SecCamera::SecCamera() : 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), + m_angle(-1), + m_fps(-1), + m_autofocus(-1), + m_white_balance(-1), + m_brightness(-1), + m_image_effect(-1), #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_anti_banding(-1), + m_flash_mode(-1), + m_metering(-1), + m_contrast(-1), + m_saturation(-1), + m_sharpness(-1), + m_wdr(-1), + m_anti_shake(-1), + m_zoom_level(-1), + m_object_tracking(-1), + m_smart_auto(-1), + m_beauty_shot(-1), + m_vintage_mode(-1), + m_face_detect(-1), + m_gps_latitude(-1), + m_gps_longitude(-1), + m_gps_altitude(-1), + m_gps_timestamp(-1), 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), + m_sensor_mode(-1), + m_shot_mode(-1), + m_exif_orientation(-1), + m_blur_level(-1), + m_chk_dataline(-1), + m_video_gamma(-1), + m_slow_ae(-1), + m_camera_af_flag(-1), #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) + m_jpeg_quality(100) #ifdef ENABLE_ESD_PREVIEW_CHECK , m_esd_check_count(0) #endif // ENABLE_ESD_PREVIEW_CHECK { LOGV("%s()", __func__); -#ifdef BOARD_USES_SDTV - nsecs_t before1, after1; - -#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)); -#endif - -#endif } int SecCamera::flagCreate(void) const @@ -748,26 +691,6 @@ int SecCamera::flagCreate(void) const SecCamera::~SecCamera() { LOGV("%s()", __func__); - -#ifdef BOARD_USES_SDTV - nsecs_t before1, after1; - -#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)); -#endif -#endif } int SecCamera::initCamera(int index) @@ -782,33 +705,6 @@ int SecCamera::initCamera(int index) */ m_camera_af_flag = -1; -#ifdef BOARD_USES_SDTV - nsecs_t before1, after1; - -#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)); -#endif - - -#endif #ifndef JPEG_FROM_SENSOR m_jpeg_fd = SsbSipJPEGEncodeInit(); LOGD("(%s):JPEG device open ID = %d\n", __func__, m_jpeg_fd); @@ -864,8 +760,8 @@ int SecCamera::initCamera(int index) ret = fimc_v4l2_querycap(m_cam_fd); CHECK(ret); - ret = fimc_v4l2_enuminput(m_cam_fd, index); - CHECK(ret); + if (!fimc_v4l2_enuminput(m_cam_fd, index)) + return -1; ret = fimc_v4l2_s_input(m_cam_fd, index); CHECK(ret); @@ -920,8 +816,8 @@ int SecCamera::initCamera(int index) ret = fimc_v4l2_querycap(m_cam_fd2); CHECK(ret); - ret = fimc_v4l2_enuminput(m_cam_fd2, index); - CHECK(ret); + if (!fimc_v4l2_enuminput(m_cam_fd2, index)) + return -1; ret = fimc_v4l2_s_input(m_cam_fd2, index); CHECK(ret); #endif @@ -975,28 +871,6 @@ void SecCamera::DeinitCamera() m_cam_fd2_temp = -1; } -#ifdef BOARD_USES_SDTV - nsecs_t before1, after1; - -#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)); -#endif -#endif m_flag_init = 0; usleep(100000); //100 ms delay to allow proper closure of fimc device. } @@ -1008,38 +882,6 @@ int SecCamera::getCameraFd(void) return m_cam_fd; } -#ifdef SWP1_CAMERA_ADD_ADVANCED_FUNCTION -int SecCamera::setCameraSensorReset(void) -{ - int ret = 0; - - 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) -{ - LOGV("%s(m_default_imei (%d))", __func__, imei); - - if (m_default_imei != imei) { - m_default_imei = imei; - } - return 0; -} - -int SecCamera::getDefultIMEI(void) -{ - return m_default_imei; -} - - -#endif /* SWP1_CAMERA_ADD_ADVANCED_FUNCTION */ - - // ====================================================================== // Preview @@ -1094,33 +936,12 @@ int SecCamera::startPreview(void) #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); + 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 = setBrightness(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 { + if (m_camera_id == CAMERA_ID_FRONT) { /* VT mode setting */ ret = fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_CAMERA_VT_MODE, m_vtmode); CHECK(ret); @@ -1146,6 +967,9 @@ int SecCamera::startPreview(void) 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_FLASH_MODE, + m_flash_mode); + 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 { @@ -1171,22 +995,22 @@ int SecCamera::startPreview(void) 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 = setBrightness(m_brightness - BRIGHTNESS_NORMAL); + ret = fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_CAMERA_BRIGHTNESS, m_brightness); 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 = setBrightness(m_brightness - BRIGHTNESS_NORMAL); + ret = fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_CAMERA_BRIGHTNESS, m_brightness); + CHECK(ret); + /* Blur setting */ + ret = fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_CAMERA_VGA_BLUR, m_blur_level); CHECK(ret); } #endif @@ -1208,22 +1032,12 @@ int SecCamera::startPreview(void) hdmi_gl_initialize(0); hdmi_gl_streamoff(0); #endif -#ifdef BOARD_USES_SDTV - - if (suspendTvInit == true) { - if (!mtvoutcamera->isSuspended()) { - mtvoutcamera->TvOutSuspend(""); - } - } - -#endif return 0; } int SecCamera::stopPreview(void) { -#ifdef SWP1_CAMERA_ADD_ADVANCED_FUNCTION - LOGE("%s()\n", __func__); + LOGV("%s()", __func__); close_buffers(m_buffers_c); @@ -1231,14 +1045,7 @@ int SecCamera::stopPreview(void) 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); @@ -1453,8 +1260,8 @@ int SecCamera::getPreview() /* 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); + if (fimc_v4l2_enuminput(m_cam_fd, m_camera_id)) + return -1; ret = fimc_v4l2_s_input(m_cam_fd, 1000); CHECK(ret); //setCameraSensorReset(); @@ -1719,11 +1526,6 @@ unsigned char* SecCamera::getJpeg(int *jpeg_size, unsigned int *phyaddr) 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)); -#endif return addr; } @@ -1826,18 +1628,6 @@ void SecCamera::SetJpgAddr(unsigned char *addr) SetMapAddr(addr); } -#if 0 -int SecCamera::getSnapshot(unsigned char *buffer, unsigned int buffer_size) -{ - LOGV("%s(buffer(%p), size(%d))", __func__, buffer, buffer_size); - - if (getSnapshotAndJpeg(buffer, buffer_size, NULL, NULL) == 0) - return -1; - - return 0; -} -#endif - #endif int SecCamera::getSnapshotAndJpeg(unsigned char *yuv_buf, unsigned char *jpeg_buf, @@ -1942,7 +1732,7 @@ int SecCamera::getSnapshotAndJpeg(unsigned char *yuv_buf, unsigned char *jpeg_bu #endif LOG_TIME_END(5) - LOG_CAMERA("getSnapshotAndJpeg intervals : stopPreview(%lu), prepare(%lu), + 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)); /* JPEG encoding */ @@ -2183,10 +1973,6 @@ int SecCamera::cancelAutofocus(void) 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 @@ -2210,6 +1996,7 @@ int SecCamera::SetRotate(int angle) { LOGE("%s(angle(%d))", __func__, angle); #ifdef SWP1_CAMERA_ADD_ADVANCED_FUNCTION + if (m_angle != angle) { switch (angle) { case -360: @@ -2439,8 +2226,8 @@ int SecCamera::setAntiBanding(int 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; + LOGE("ERR(%s):Fail on V4L2_CID_CAMERA_ANTI_BANDING", __func__); + return -1; } } } @@ -2515,8 +2302,7 @@ int SecCamera::setISO(int iso_value) return -1; } - if (m_iso != iso_value) - { + 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) { @@ -2722,9 +2508,11 @@ int SecCamera::setJpegQuality(int jpeg_quality) 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; + if (m_flag_camera_start) { + 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; + } } } @@ -2749,7 +2537,6 @@ int SecCamera::setZoom(int zoom_level) 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", __func__); @@ -2888,9 +2675,9 @@ int SecCamera::setBeautyShot(int beauty_shot) LOGE("ERR(%s):Fail on V4L2_CID_CAMERA_BEAUTY_SHOT", __func__); return -1; } - - setFaceDetect(FACE_DETECT_BEAUTY_ON); } + + setFaceDetect(FACE_DETECT_BEAUTY_ON); } return 0; @@ -2960,9 +2747,8 @@ int SecCamera::setFocusMode(int focus_mode) 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); + } } } } @@ -2981,7 +2767,7 @@ int SecCamera::setFaceDetect(int face_detect) { LOGV("%s(face_detect(%d))", __func__, face_detect); -// if (m_face_detect != 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) { @@ -2995,7 +2781,7 @@ int SecCamera::setFaceDetect(int face_detect) return -1; } } -// } + } return 0; } @@ -3062,29 +2848,6 @@ int SecCamera::setGPSTimeStamp(const char *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))", __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", __func__); - return -1; - } - - return 0; } int SecCamera::setFaceDetectLockUnlock(int facedetect_lockunlock) @@ -3275,7 +3038,6 @@ int SecCamera::setBlur(int blur_level) 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__); @@ -3327,6 +3089,13 @@ int SecCamera::setDataLineCheckStop(void) #endif +const __u8* SecCamera::getCameraSensorName(void) +{ + LOGV("%s", __func__); + + return fimc_v4l2_enuminput(m_cam_fd, getCameraId()); +} + #ifdef ENABLE_ESD_PREVIEW_CHECK int SecCamera::getCameraSensorESDStatus(void) { @@ -3824,5 +3593,6 @@ status_t SecCamera::dump(int fd, const Vector<String16> &args) double SecCamera::jpeg_ratio = 0.7; int SecCamera::interleaveDataSize = 4261248; +int SecCamera::jpegLineLength = 636; }; // namespace android diff --git a/libcamera/SecCamera.h b/libcamera/SecCamera.h index 38f706e..a26e29e 100644 --- a/libcamera/SecCamera.h +++ b/libcamera/SecCamera.h @@ -216,9 +216,9 @@ public: }; enum AUTO_FOCUS { - AUTO_FOCUS_OFF, + AUTO_FOCUS_OFF = 0, AUTO_FOCUS_ON, - AUTO_FOCUS_STATUS, + AUTO_FOCUS_MAX, }; enum WHILTE_BALANCE { @@ -598,8 +598,6 @@ public: 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); @@ -691,7 +689,6 @@ public: 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); @@ -719,6 +716,7 @@ public: int setDataLineCheckStop(void); int setDefultIMEI(int imei); int getDefultIMEI(void); + const __u8* getCameraSensorName(void); #ifdef ENABLE_ESD_PREVIEW_CHECK int getCameraSensorESDStatus(void); #endif // ENABLE_ESD_PREVIEW_CHECK @@ -773,6 +771,17 @@ public: return interleaveDataSize; } + static void setJpegLineLength(int x) + { + jpegLineLength = x; + } + + static int getJpegLineLength() + { + return jpegLineLength; + } + + private: int m_flag_init; @@ -811,20 +820,17 @@ private: 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; @@ -872,6 +878,7 @@ private: static double jpeg_ratio; static int interleaveDataSize; + static int jpegLineLength; }; extern unsigned long measure_time(struct timeval *start, struct timeval *stop); diff --git a/libcamera/SecCameraHWInterface.cpp b/libcamera/SecCameraHWInterface.cpp index 0cd0544..0c0d60d 100644 --- a/libcamera/SecCameraHWInterface.cpp +++ b/libcamera/SecCameraHWInterface.cpp @@ -41,6 +41,13 @@ ALIGN_TO_32B(720 / 2))) #endif +#define VIDEO_COMMENT_MARKER_H 0xFFBE +#define VIDEO_COMMENT_MARKER_L 0xFFBF +#define VIDEO_COMMENT_MARKER_LENGTH 4 +#define JPEG_EOI_MARKER 0xFFD9 +#define HIBYTE(x) (((x) >> 8) & 0xFF) +#define LOBYTE(x) ((x) & 0xFF) + namespace android { struct addrs { @@ -67,16 +74,17 @@ CameraHardwareSec::CameraHardwareSec(int cameraId) mPreviewFrameSize(0), mRawFrameSize(0), mPreviewFrameRateMicrosec(33000), + mCameraSensorName(NULL), +#if defined(BOARD_USES_OVERLAY) + mUseOverlay(false), + mOverlayBufferIdx(0), +#endif mNotifyCb(0), mDataCb(0), mDataCbTimestamp(0), mCallbackCookie(0), mMsgEnabled(0), mCurrentPreviewFrame(0), -#if defined(BOARD_USES_OVERLAY) - mUseOverlay(false), - mOverlayBufferIdx(0), -#endif mRecordRunning(false) #ifdef JPEG_FROM_SENSOR , @@ -84,13 +92,6 @@ CameraHardwareSec::CameraHardwareSec(int cameraId) mPostViewHeight(0), mPostViewSize(0) #endif -#ifdef SWP1_CAMERA_ADD_ADVANCED_FUNCTION - , - mObjectTrackingStatus(0), - mSmartautosceneRunning(false), - mSmartautoscene_current_status(0), - mSmartautoscene_previous_status(0) -#endif { LOGV("%s()", __func__); int ret = 0; @@ -164,6 +165,9 @@ void CameraHardwareSec::initDefaultParameters(int cameraId) CameraParameters p; + mCameraSensorName = mSecCamera->getCameraSensorName(); + LOGV("CameraSensorName: %s", mCameraSensorName); + int preview_max_width = 0; int preview_max_height = 0; int snapshot_max_width = 0; @@ -174,23 +178,26 @@ void CameraHardwareSec::initDefaultParameters(int cameraId) mSecCamera->setCameraId(cameraId); if (cameraId == SecCamera::CAMERA_ID_BACK) { p.set(CameraParameters::KEY_SUPPORTED_PREVIEW_SIZES, - "800x480,640x480"); + "640x480,720x480,352x288,176x144"); p.set(CameraParameters::KEY_SUPPORTED_PICTURE_SIZES, - "2560x1920,2048x1536,1600x1200,1280x960,640x480"); - } - else { + "2560x1920,2048x1536,1600x1200,1024x768,640x480"); + } else { p.set(CameraParameters::KEY_SUPPORTED_PREVIEW_SIZES, - "640x480,320x240,160x120"); + "640x480"); p.set(CameraParameters::KEY_SUPPORTED_PICTURE_SIZES, - "640x480"); + "640x480"); } // If these fail, then we are using an invalid cameraId and we'll leave the // sizes at zero to catch the error. - if (mSecCamera->getPreviewMaxSize(&preview_max_width, &preview_max_height) < 0) - LOGE("getPreviewMaxSize fail (%d / %d) \n", preview_max_width, preview_max_height); - if (mSecCamera->getSnapshotMaxSize(&snapshot_max_width, &snapshot_max_height) < 0) - LOGE("getSnapshotMaxSize fail (%d / %d) \n", snapshot_max_width, snapshot_max_height); + if (mSecCamera->getPreviewMaxSize(&preview_max_width, + &preview_max_height) < 0) + LOGE("getPreviewMaxSize fail (%d / %d) \n", + preview_max_width, preview_max_height); + if (mSecCamera->getSnapshotMaxSize(&snapshot_max_width, + &snapshot_max_height) < 0) + LOGE("getSnapshotMaxSize fail (%d / %d) \n", + snapshot_max_width, snapshot_max_height); #ifdef PREVIEW_USING_MMAP p.setPreviewFormat(CameraParameters::PIXEL_FORMAT_YUV420SP); @@ -205,30 +212,24 @@ void CameraHardwareSec::initDefaultParameters(int cameraId) p.set(CameraParameters::KEY_JPEG_QUALITY, "100"); // maximum quality #ifdef SWP1_CAMERA_ADD_ADVANCED_FUNCTION p.set(CameraParameters::KEY_SUPPORTED_PREVIEW_FORMATS, - CameraParameters::PIXEL_FORMAT_YUV420SP); + CameraParameters::PIXEL_FORMAT_YUV420SP); p.set(CameraParameters::KEY_SUPPORTED_PREVIEW_FRAME_RATES, "30,15"); p.set(CameraParameters::KEY_SUPPORTED_PICTURE_FORMATS, - CameraParameters::PIXEL_FORMAT_JPEG); + CameraParameters::PIXEL_FORMAT_JPEG); p.set(CameraParameters::KEY_SUPPORTED_JPEG_THUMBNAIL_SIZES, - "160x120,0x0"); + "160x120,0x0"); p.set(CameraParameters::KEY_VIDEO_FRAME_FORMAT, - CameraParameters::PIXEL_FORMAT_YUV420SP); + 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()); + if (cameraId == SecCamera::CAMERA_ID_BACK) { + parameterString = CameraParameters::FOCUS_MODE_AUTO; + parameterString.append(","); + parameterString.append(CameraParameters::FOCUS_MODE_MACRO); + p.set(CameraParameters::KEY_SUPPORTED_FOCUS_MODES, + parameterString.string()); + } parameterString = CameraParameters::EFFECT_NONE; parameterString.append(","); @@ -239,35 +240,39 @@ void CameraHardwareSec::initDefaultParameters(int cameraId) parameterString.append(CameraParameters::EFFECT_SEPIA); p.set(CameraParameters::KEY_SUPPORTED_EFFECTS, parameterString.string()); - parameterString = CameraParameters::FLASH_MODE_ON; - parameterString.append(","); - parameterString.append(CameraParameters::FLASH_MODE_OFF); - parameterString.append(","); - parameterString.append(CameraParameters::FLASH_MODE_AUTO); - p.set(CameraParameters::KEY_SUPPORTED_FLASH_MODES, parameterString.string()); - - 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()); + if (cameraId == SecCamera::CAMERA_ID_BACK) { + parameterString = CameraParameters::FLASH_MODE_ON; + parameterString.append(","); + parameterString.append(CameraParameters::FLASH_MODE_OFF); + parameterString.append(","); + parameterString.append(CameraParameters::FLASH_MODE_AUTO); + p.set(CameraParameters::KEY_SUPPORTED_FLASH_MODES, + parameterString.string()); + + 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(","); @@ -278,7 +283,8 @@ void CameraHardwareSec::initDefaultParameters(int cameraId) 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_WHITE_BALANCE, + parameterString.string()); //add the max and min for adjust value[20100728 giung.jung] p.set("sharpness-min", 0); p.set("sharpness-max", 4); @@ -299,34 +305,27 @@ void CameraHardwareSec::initDefaultParameters(int cameraId) #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(CameraParameters::KEY_FLASH_MODE, CameraParameters::FLASH_MODE_OFF); + + if (cameraId == SecCamera::CAMERA_ID_BACK) { + p.set(CameraParameters::KEY_FLASH_MODE, + CameraParameters::FLASH_MODE_AUTO); + } 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); + if (cameraId == SecCamera::CAMERA_ID_FRONT) { + p.set("vtmode", 0); + p.set("blur", 0); + } #else 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_FOCAL_LENGTH, "3.79"); p.set(CameraParameters::KEY_HORIZONTAL_VIEW_ANGLE, "51.2"); @@ -335,13 +334,11 @@ void CameraHardwareSec::initDefaultParameters(int cameraId) 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_STEP, "1.0"); p.set("AppShutterSound", 0); - if (setParameters(p) != NO_ERROR) { - LOGE("ERR(%s):Fail on setParameters(p)", __func__); - } + mParameters = p; } CameraHardwareSec::~CameraHardwareSec() @@ -765,78 +762,6 @@ 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; - } - - 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; -} - -void CameraHardwareSec::stopSmartautoscene() -{ - LOGV("%s()", __func__); - - sp<SmartautosceneThread> smartautosceneThread; - - { // 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(); - - mSmartautosceneRunning = false; -} - -bool CameraHardwareSec::smartautosceneEnabled() -{ - LOGV("%s() : %d", __func__, mSmartautosceneThread != 0); - return mSmartautosceneThread != 0; -} - -#endif - - int CameraHardwareSec::beginAutoFocusThread(void *cookie) { LOGV("%s()", __func__); @@ -905,27 +830,6 @@ status_t CameraHardwareSec::cancelAutoFocus() return NO_ERROR; } -#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; -} - int CameraHardwareSec::save_jpeg( unsigned char *real_jpeg, int jpeg_size) { FILE *yuv_fp = NULL; @@ -964,23 +868,6 @@ int CameraHardwareSec::save_jpeg( unsigned char *real_jpeg, int jpeg_size) return 0; } - -int CameraHardwareSec::objectTrackingThread() -{ - 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); - } -#endif - usleep(100000); //100ms - return NO_ERROR; -} -#endif /*static*/ int CameraHardwareSec::beginPictureThread(void *cookie) { LOGV("%s()", __func__); @@ -1049,7 +936,7 @@ bool CameraHardwareSec::scaleDownYuv422(char *srcBuf, uint32_t srcWidth, uint32_ bool CameraHardwareSec::YUY2toNV21(void *srcBuf, void *dstBuf, uint32_t srcWidth, uint32_t srcHeight) { - int32_t x, y, src_y_start_pos, dst_cbcr_pos, dst_pos, src_pos; + int32_t x, y, src_y_start_pos, dst_cbcr_pos, dst_pos, src_pos; unsigned char *srcBufPointer = (unsigned char *)srcBuf; unsigned char *dstBufPointer = (unsigned char *)dstBuf; @@ -1103,7 +990,7 @@ int CameraHardwareSec::pictureThread() mSecCamera->getSnapshotSize(&cap_width, &cap_height, &cap_frame_size); int mJpegHeapSize; if (mSecCamera->getCameraId() == SecCamera::CAMERA_ID_BACK) - mJpegHeapSize = cap_frame_size * mSecCamera->getJpegRatio(); + mJpegHeapSize = cap_frame_size * SecCamera::getJpegRatio(); else mJpegHeapSize = cap_frame_size; LOGE("[kidggang]:func(%s):line(%d)&cap_width(%d), &cap_height(%d), &cap_frame_size(%d), mJpegHeapSize(%d)\n", @@ -1192,11 +1079,27 @@ int CameraHardwareSec::pictureThread() } int JpegImageSize, JpegExifSize; + bool isLSISensor = false; + + isLSISensor = !strncmp((const char*)mCameraSensorName, "S5K4ECGX", 8); + if (isLSISensor) + LOGE("== Camera Sensor Detect LSI SOC 5M ==\n"); + else + LOGE("== Camera Sensor Detect Sony SOC 5M ==\n"); if (mSecCamera->getCameraId() == SecCamera::CAMERA_ID_BACK) { - decodeInterleaveData(jpeg_data, SecCamera::getInterleaveDataSize(), mPostViewWidth, mPostViewHeight, - &JpegImageSize, JpegHeap->base(), PostviewHeap->base()); + if(isLSISensor) { + // LSI 5M SOC + SplitFrame(jpeg_data, SecCamera::getInterleaveDataSize(), + SecCamera::getJpegLineLength(), + mPostViewWidth * 2, mPostViewWidth, + JpegHeap->base(), &JpegImageSize, + PostviewHeap->base(), &mPostViewSize); + } else { + decodeInterleaveData(jpeg_data, SecCamera::getInterleaveDataSize(), mPostViewWidth, mPostViewHeight, + &JpegImageSize, JpegHeap->base(), PostviewHeap->base()); + } scaleDownYuv422((char *)PostviewHeap->base(), mPostViewWidth, mPostViewHeight, (char *)ThumbnailHeap->base(), mThumbWidth, mThumbHeight); } @@ -1312,6 +1215,140 @@ status_t CameraHardwareSec::cancelPicture() return NO_ERROR; } +bool CameraHardwareSec::CheckVideoStartMarker(unsigned char *pBuf) +{ + if (!pBuf) { + LOGE("CheckVideoStartMarker() => pBuf is NULL\n"); + return false; + } + + if (HIBYTE(VIDEO_COMMENT_MARKER_H) == * pBuf && LOBYTE(VIDEO_COMMENT_MARKER_H) == *(pBuf + 1) && + HIBYTE(VIDEO_COMMENT_MARKER_L) == *(pBuf + 2) && LOBYTE(VIDEO_COMMENT_MARKER_L) == *(pBuf + 3)) + return true; + + return false; +} + +bool CameraHardwareSec::CheckEOIMarker(unsigned char *pBuf) +{ + if (!pBuf) { + LOGE("CheckEOIMarker() => pBuf is NULL\n"); + return false; + } + + // EOI marker [FF D9] + if (HIBYTE(JPEG_EOI_MARKER) == *pBuf && LOBYTE(JPEG_EOI_MARKER) == *(pBuf + 1)) + return true; + + return false; +} + +bool CameraHardwareSec::FindEOIMarkerInJPEG(unsigned char *pBuf, int dwBufSize, int *pnJPEGsize) +{ + if (NULL == pBuf || 0 >= dwBufSize) { + LOGE("FindEOIMarkerInJPEG() => There is no contents."); + return false; + } + + unsigned char *pBufEnd = pBuf + dwBufSize; + + while (pBuf < pBufEnd) { + if (CheckEOIMarker(pBuf++)) + return true; + + (*pnJPEGsize)++; + } + + return false; +} + +bool CameraHardwareSec::SplitFrame(unsigned char *pFrame, int dwSize, + int dwJPEGLineLength, int dwVideoLineLength, int dwVideoHeight, + void *pJPEG, int *pdwJPEGSize, + void *pVideo, int *pdwVideoSize) +{ + LOGV("===========SplitFrame Start=============="); + + if (NULL == pFrame || 0 >= dwSize) { + LOGE("There is no contents.\r\n"); + return false; + } + + if (0 == dwJPEGLineLength || 0 == dwVideoLineLength) { + LOGE("There in no input information for decoding interleaved jpeg"); + return false; + } + + unsigned char *pSrc = pFrame; + unsigned char *pSrcEnd = pFrame + dwSize; + + unsigned char *pJ = (unsigned char *)pJPEG; + int dwJSize = 0; + unsigned char *pV = (unsigned char *)pVideo; + int dwVSize = 0; + + bool bRet = false; + bool isFinishJpeg = false; + + while (pSrc < pSrcEnd) { + // Check video start marker + if (CheckVideoStartMarker(pSrc)) { + // Copy video data + if (pV) { + memcpy(pV, pSrc + VIDEO_COMMENT_MARKER_LENGTH, dwVideoLineLength); + pV += dwVideoLineLength; + dwVSize += dwVideoLineLength; + } + pSrc += dwVideoLineLength + VIDEO_COMMENT_MARKER_LENGTH; + } else { + // Copy pure JPEG data + int size = 0; + int dwCopyBufLen = dwJPEGLineLength <= pSrcEnd-pSrc ? dwJPEGLineLength : pSrcEnd - pSrc; + + if (FindEOIMarkerInJPEG((unsigned char *)pSrc, dwCopyBufLen, &size)) { + isFinishJpeg = true; + size += 2; // to count EOF marker size + } else { + if ((dwCopyBufLen == 1) && (pJPEG < pJ)) { + unsigned char checkBuf[2] = { *(pJ - 1), *pSrc }; + + if (CheckEOIMarker(checkBuf)) + isFinishJpeg = true; + } + size = dwCopyBufLen; + } + + memcpy(pJ, pSrc, size); + + dwJSize += size; + + pJ += dwCopyBufLen; + pSrc += dwCopyBufLen; + } + + if (isFinishJpeg) + break; + } + + if (isFinishJpeg) { + bRet = true; + if(pdwJPEGSize) + *pdwJPEGSize = dwJSize; + if(pdwVideoSize) + *pdwVideoSize = dwVSize; + } else { + LOGE("DecodeInterleaveJPEG_WithOutDT() => Can not find EOI"); + bRet = false; + if(pdwJPEGSize) + *pdwJPEGSize = 0; + if(pdwVideoSize) + *pdwVideoSize = 0; + } + LOGV("===========SplitFrame end=============="); + + return bRet; +} + int CameraHardwareSec::decodeInterleaveData(unsigned char *pInterleaveData, int interleaveDataSize, int yuvWidth, @@ -1448,9 +1485,11 @@ status_t CameraHardwareSec::setParameters(const CameraParameters& params) 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) + 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) + 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 @@ -1708,7 +1747,8 @@ status_t CameraHardwareSec::setParameters(const CameraParameters& params) 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) { + if (strcmp(new_scene_mode_str, + CameraParameters::SCENE_MODE_PORTRAIT) == 0) { new_scene_mode = SecCamera::SCENE_MODE_PORTRAIT; mParameters.set("iso", "auto"); @@ -1718,97 +1758,128 @@ status_t CameraHardwareSec::setParameters(const CameraParameters& params) 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) { + } 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(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_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) { + } 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(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_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) { + } 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(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)) { + 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(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_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) { + } 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(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_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(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_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(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_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) { + } 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(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_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); - + const char *flash_mode_str; + flash_mode_str = params.get(CameraParameters::KEY_FLASH_MODE); new_scene_mode = SecCamera::SCENE_MODE_BACK_LIGHT; mParameters.set("iso", "auto"); @@ -1816,45 +1887,60 @@ status_t CameraHardwareSec::setParameters(const CameraParameters& params) 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(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) { + 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(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_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(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) { + 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(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_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 + LOGE("%s::unmatched scene_mode(%s)", + __func__, new_scene_mode_str); //action, night-portrait, theatre, steadyphoto ret = UNKNOWN_ERROR; } @@ -1896,7 +1982,7 @@ status_t CameraHardwareSec::setParameters(const CameraParameters& params) ret = UNKNOWN_ERROR; } - if (0 <= new_iso) { + if (0 <= new_iso) { if (mSecCamera->setISO(new_iso) < 0) { LOGE("%s::mSecCamera->setISO(%d) fail", __func__, new_iso); ret = UNKNOWN_ERROR; @@ -1985,9 +2071,15 @@ status_t CameraHardwareSec::setParameters(const CameraParameters& params) 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)) + 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) + 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; @@ -2132,89 +2224,6 @@ status_t CameraHardwareSec::setParameters(const CameraParameters& params) } } - //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"); @@ -2268,7 +2277,6 @@ status_t CameraHardwareSec::setParameters(const CameraParameters& params) 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) @@ -2354,13 +2362,6 @@ status_t CameraHardwareSec::setParameters(const CameraParameters& params) } } - //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; } @@ -2374,46 +2375,7 @@ CameraParameters CameraHardwareSec::getParameters() const 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; -#else return BAD_VALUE; -#endif } void CameraHardwareSec::release() @@ -2436,13 +2398,6 @@ sp<CameraHardwareInterface> CameraHardwareSec::createInstance(int cameraId) singleton = hardware; return hardware; } -#if 0 -extern "C" sp<CameraHardwareInterface> openCameraHardware() -{ - LOGV("%s()", __func__); - return CameraHardwareSec::createInstance(); -} -#endif static CameraInfo sCameraInfo[] = { { diff --git a/libcamera/SecCameraHWInterface.h b/libcamera/SecCameraHWInterface.h index fde5486..184acf3 100644 --- a/libcamera/SecCameraHWInterface.h +++ b/libcamera/SecCameraHWInterface.h @@ -49,12 +49,6 @@ public: virtual void stopPreview(); virtual bool previewEnabled(); -#ifdef SWP1_CAMERA_ADD_ADVANCED_FUNCTION - virtual status_t startSmartautoscene(); - virtual void stopSmartautoscene(); - virtual bool smartautosceneEnabled(); -#endif - virtual status_t startRecording(); virtual void stopRecording(); virtual bool recordingEnabled(); @@ -107,39 +101,10 @@ private: } }; -#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), -#else - 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; - } - }; -#endif void initDefaultParameters(int cameraId); void initHeapLocked(); int previewThread(); -#ifdef SWP1_CAMERA_ADD_ADVANCED_FUNCTION - int smartautosceneThread(); -#endif static int beginAutoFocusThread(void *cookie); int autoFocusThread(); @@ -157,14 +122,19 @@ private: void *pJpegData, void *pYuvData); bool YUY2toNV21(void *srcBuf, void *dstBuf, uint32_t srcWidth, uint32_t srcHeight); - bool scaleDownYuv422(char *srcBuf, uint32_t srcWidth, uint32_t srcHight, - char *dstBuf, uint32_t dstWidth, uint32_t dstHight); - -#ifdef SWP1_CAMERA_ADD_ADVANCED_FUNCTION - static int beginObjectTrackingThread(void *cookie); - int objectTrackingThread(); - status_t objectTracking(int onoff); -#endif + bool scaleDownYuv422(char *srcBuf, uint32_t srcWidth, + uint32_t srcHight, char *dstBuf, + uint32_t dstWidth, uint32_t dstHight); + + bool CheckVideoStartMarker(unsigned char *pBuf); + bool CheckEOIMarker(unsigned char *pBuf); + bool FindEOIMarkerInJPEG(unsigned char *pBuf, + int dwBufSize, int *pnJPEGsize); + bool SplitFrame(unsigned char *pFrame, int dwSize, + int dwJPEGLineLength, int dwVideoLineLength, + int dwVideoHeight, void *pJPEG, + int *pdwJPEGSize, void *pVideo, + int *pdwVideoSize); mutable Mutex mLock; @@ -182,6 +152,7 @@ private: int mPreviewFrameSize; int mRawFrameSize; int mPreviewFrameRateMicrosec; + const __u8 *mCameraSensorName; #if defined(BOARD_USES_OVERLAY) sp<Overlay> mOverlay; @@ -191,9 +162,6 @@ private: // protected by mLock sp<PreviewThread> mPreviewThread; -#ifdef SWP1_CAMERA_ADD_ADVANCED_FUNCTION - sp<SmartautosceneThread> mSmartautosceneThread; -#endif notify_callback mNotifyCb; data_callback mDataCb; data_callback_timestamp mDataCbTimestamp; @@ -216,53 +184,6 @@ private: 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; - 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) { } - virtual void onFirstRef() { - run("CameraObjectTrackingThread", PRIORITY_URGENT_DISPLAY); - } - virtual bool threadLoop() { - int ret = mHardware->objectTrackingThread(); - // loop until we need to quit - if(ret == NO_ERROR) - 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; -#endif }; }; // namespace android |