diff options
author | Mingyu Kim <mingyu0.kim@samsung.com> | 2010-09-16 23:14:48 -0700 |
---|---|---|
committer | Simon Wilson <simonwilson@google.com> | 2010-09-20 12:10:04 -0700 |
commit | 41b855f0cea2e4e7d7afd16aa69fdcb6983a950c (patch) | |
tree | a26b1c0ddd47c13f07fef3174cb8ab8daab57cba /libcamera | |
parent | ec04e3567b8e7439c9a7d2005d1ad21204b5f6c2 (diff) | |
download | device_samsung_crespo-41b855f0cea2e4e7d7afd16aa69fdcb6983a950c.zip device_samsung_crespo-41b855f0cea2e4e7d7afd16aa69fdcb6983a950c.tar.gz device_samsung_crespo-41b855f0cea2e4e7d7afd16aa69fdcb6983a950c.tar.bz2 |
libcamera: supporting for front-facing camera
Signed-off-by: Mingyu Kim <mingyu0.kim@samsung.com>
Change-Id: I5b55678032bb633103ee596288cd7b7770596b87
Diffstat (limited to 'libcamera')
-rwxr-xr-x[-rw-r--r--] | libcamera/SecCamera.cpp | 39 | ||||
-rwxr-xr-x[-rw-r--r--] | libcamera/SecCamera.h | 33 | ||||
-rwxr-xr-x[-rw-r--r--] | libcamera/SecCameraHWInterface.cpp | 48 | ||||
-rw-r--r-- | libcamera/SecCameraHWInterface.h | 6 |
4 files changed, 61 insertions, 65 deletions
diff --git a/libcamera/SecCamera.cpp b/libcamera/SecCamera.cpp index 19b2821..27f7aee 100644..100755 --- a/libcamera/SecCamera.cpp +++ b/libcamera/SecCamera.cpp @@ -76,7 +76,6 @@ namespace android { static struct timeval time_start; static struct timeval time_stop; -static int cam_id = 0; unsigned long measure_time(struct timeval *start, struct timeval *stop) { @@ -243,7 +242,7 @@ static int save_yuv(struct fimc_buffer *m_buffers_c, int width, int height, int char filename[100], *buffer = NULL; /* file create/open, note to "wb" */ - yuv_fp = fopen("/sdcard/camera_dump.yuv", "wb"); + yuv_fp = fopen("/data/main.yuv", "wb"); if (yuv_fp==NULL) { LOGE("Save YUV] file open error"); @@ -295,11 +294,11 @@ static int fimc_v4l2_querycap(int fp) return ret; } -static int fimc_v4l2_enuminput(int fp) +static int fimc_v4l2_enuminput(int fp, int index) { struct v4l2_input input; - input.index = cam_id; + input.index = index; if(ioctl(fp, VIDIOC_ENUMINPUT, &input) != 0) { LOGE("ERR(%s):No matching index found\n", __FUNCTION__); @@ -307,7 +306,7 @@ static int fimc_v4l2_enuminput(int fp) } LOGI("Name of input channel[%d] is %s\n", input.index, input.name); - return input.index; + return 0; } @@ -724,7 +723,8 @@ SecCamera::SecCamera() : m_jpeg_thumbnail_height(0), m_jpeg_quality(100), m_camera_af_flag(-1), - m_shot_mode(0) + m_shot_mode(0), + m_flag_init(0) { LOGV("%s()", __FUNCTION__); #ifdef BOARD_USES_SDTV @@ -752,7 +752,6 @@ SecCamera::SecCamera() : #endif #endif - initCamera(); } int SecCamera::flagCreate(void) const @@ -765,7 +764,6 @@ SecCamera::~SecCamera() { LOGV("%s()", __FUNCTION__); - DeinitCamera(); #ifdef BOARD_USES_SDTV nsecs_t before1, after1; @@ -789,10 +787,10 @@ SecCamera::~SecCamera() #endif } -int SecCamera::initCamera() +int SecCamera::initCamera(int index) { LOGV("%s()", __FUNCTION__); - int ret = 0, index = 0; + int ret = 0; if(!m_flag_init) { @@ -892,8 +890,8 @@ int SecCamera::initCamera() ret = fimc_v4l2_querycap(m_cam_fd); CHECK(ret); - index = fimc_v4l2_enuminput(m_cam_fd); - CHECK(index); + ret = fimc_v4l2_enuminput(m_cam_fd, index); + CHECK(ret); ret = fimc_v4l2_s_input(m_cam_fd, index); CHECK(ret); @@ -949,13 +947,14 @@ int SecCamera::initCamera() ret = fimc_v4l2_querycap(m_cam_fd2); CHECK(ret); - index = fimc_v4l2_enuminput(m_cam_fd2); - CHECK(index); + 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; @@ -965,7 +964,7 @@ void SecCamera::resetCamera() { LOGV("%s()", __FUNCTION__); DeinitCamera(); - initCamera(); + initCamera(m_camera_id); } void SecCamera::DeinitCamera() @@ -1274,7 +1273,7 @@ int SecCamera::startPreview(void) int SecCamera::stopPreview(void) { #ifdef SWP1_CAMERA_ADD_ADVANCED_FUNCTION - LOGE("%s()", __FUNCTION__); + LOGE("%s()\n", __FUNCTION__); close_buffers(m_buffers_c); @@ -1495,8 +1494,8 @@ int SecCamera::getPreview() /* Reset Only Camera Device */ ret = fimc_v4l2_querycap(m_cam_fd); CHECK(ret); - index = fimc_v4l2_enuminput(m_cam_fd); - CHECK(index); + ret = fimc_v4l2_enuminput(m_cam_fd, m_camera_id); + CHECK(ret); ret = fimc_v4l2_s_input(m_cam_fd, 1000); CHECK(ret); //setCameraSensorReset(); @@ -1815,7 +1814,7 @@ int SecCamera::getSnapshot(unsigned char * buffer, unsigned int buffer_size) #endif -unsigned char* SecCamera::getSnapshotAndJpeg() +unsigned char* SecCamera::getSnapshotAndJpeg(unsigned int* output_size) { LOGV("%s()", __FUNCTION__); @@ -2027,7 +2026,6 @@ int SecCamera::setCameraId(int camera_id) 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; - cam_id = 1; break; case CAMERA_ID_BACK: @@ -2035,7 +2033,6 @@ int SecCamera::setCameraId(int camera_id) 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; - cam_id = 0; break; } diff --git a/libcamera/SecCamera.h b/libcamera/SecCamera.h index f77aeb8..c176092 100644..100755 --- a/libcamera/SecCamera.h +++ b/libcamera/SecCamera.h @@ -95,28 +95,21 @@ namespace android { #define JOIN_AGAIN(x, y) x ## y #define FRONT_CAM VGA -#define BACK_CAM CE147 +#define BACK_CAM ISX006 #if !defined (FRONT_CAM) || !defined(BACK_CAM) #error "Please define the Camera module" #endif -#ifdef SWP1_CAMERA_ADD_ADVANCED_FUNCTION -#define CE147_PREVIEW_WIDTH 640 -#define CE147_PREVIEW_HEIGHT 480 -#define CE147_SNAPSHOT_WIDTH 2560 -#define CE147_SNAPSHOT_HEIGHT 1920 -#else -#define CE147_PREVIEW_WIDTH 1280 -#define CE147_PREVIEW_HEIGHT 720 -#define CE147_SNAPSHOT_WIDTH 2592 -#define CE147_SNAPSHOT_HEIGHT 1936 -#endif +#define ISX006_PREVIEW_WIDTH 640 +#define ISX006_PREVIEW_HEIGHT 480 +#define ISX006_SNAPSHOT_WIDTH 2560 +#define ISX006_SNAPSHOT_HEIGHT 1920 -#define CE147_POSTVIEW_WIDTH 640 -#define CE147_POSTVIEW_WIDE_WIDTH 800 -#define CE147_POSTVIEW_HEIGHT 480 -#define CE147_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 @@ -213,8 +206,8 @@ public: enum CAMERA_ID { - CAMERA_ID_BACK = 1, - CAMERA_ID_FRONT = 2, + CAMERA_ID_BACK = 0, + CAMERA_ID_FRONT = 1, }; enum AUTO_FOCUS @@ -760,7 +753,7 @@ public: void setFrameRate(int frame_rate); // void setJpegQuality(int quality); unsigned char* getJpeg(int*, unsigned int*); - unsigned char* getSnapshotAndJpeg(void); + unsigned char* getSnapshotAndJpeg(unsigned int* output_size); //[zzangdol] add function int getExif(unsigned char *pExifDst, unsigned char *pThumbSrc); @@ -780,7 +773,7 @@ public: void getYUVBuffers(unsigned char** virYAddr, unsigned char** virCaddr, int index); #endif void pausePreview(); - int initCamera(); + int initCamera(int index); void DeinitCamera(); private: diff --git a/libcamera/SecCameraHWInterface.cpp b/libcamera/SecCameraHWInterface.cpp index 7663f53..e37a247 100644..100755 --- a/libcamera/SecCameraHWInterface.cpp +++ b/libcamera/SecCameraHWInterface.cpp @@ -57,7 +57,7 @@ struct ADDRS_CAP unsigned int height; }; -CameraHardwareSec::CameraHardwareSec() +CameraHardwareSec::CameraHardwareSec(int cameraId) : mParameters(), mPreviewHeap(0), mRawHeap(0), @@ -102,7 +102,7 @@ CameraHardwareSec::CameraHardwareSec() LOGE("ERR(%s):Fail on mSecCamera object creation", __func__); } - ret = mSecCamera->initCamera(); + ret = mSecCamera->initCamera(cameraId); if(ret < 0) { LOGE("ERR(%s):Fail on mSecCamera init", __func__); @@ -155,10 +155,10 @@ CameraHardwareSec::CameraHardwareSec() mRawHeap.clear(); } - initDefaultParameters(); + initDefaultParameters(cameraId); } -void CameraHardwareSec::initDefaultParameters() +void CameraHardwareSec::initDefaultParameters(int cameraId) { if(mSecCamera == NULL) { @@ -173,11 +173,9 @@ void CameraHardwareSec::initDefaultParameters() int snapshot_max_width = 0; int snapshot_max_height = 0; - int camera_id = 1; - - p.set("camera-id", camera_id); - - if(camera_id == 1) + 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); @@ -208,7 +206,7 @@ void CameraHardwareSec::initDefaultParameters() p.set("jpeg-quality", "100"); // maximum quality #ifdef SWP1_CAMERA_ADD_ADVANCED_FUNCTION p.set("preview-size-values","640x480,800x480"); //s1_camera [ 3-party application ¿¡¼ get supported preview size ¾ÈµÇ´Â Çö»ó ¼öÁ¤ ] - p.set("picture-size-values","2560x1920,2048x1536,1600x1200,640x480,2560x1536,2048x1232,1600x960,800x480"); + p.set("picture-size-values","2560x1920,2048x1536,1600x1200,640x480"); p.set("preview-format-values", "yuv420sp"); p.set("preview-frame-rate-values", "15,30"); p.set("picture-format-values", "jpeg"); @@ -217,7 +215,7 @@ void CameraHardwareSec::initDefaultParameters() p.set("focus-mode-values", "auto,macro"); p.set("antibanding-values", "auto,50hz,60hz,off"); p.set("effect-values", "none,mono,negative,sepia"); - p.set("flash-mode-values", "off"); + p.set("flash-mode-values", "on,off,auto"); // p.set("focus-mode-values", "auto,infinity,macro"); p.set("scene-mode-values", "auto,portrait,landscape,night,beach,snow,sunset,fireworks,sports,party,candlelight"); p.set("whitebalance-values", "auto,incandescent,fluorescent,daylight,cloudy-daylight"); @@ -661,9 +659,9 @@ void CameraHardwareSec::stopPreview() } // don't hold the lock while waiting for the thread to quit -// if (previewThread != 0) { -// previewThread->requestExitAndWait(); -// } + if (previewThread != 0) { + previewThread->requestExitAndWait(); + } Mutex::Autolock lock(mLock); mPreviewThread.clear(); @@ -1015,6 +1013,8 @@ int CameraHardwareSec::pictureThread() 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; @@ -1082,7 +1082,7 @@ int CameraHardwareSec::pictureThread() }//[zzangdol] CAMERA_ID_BACK else { - addr = mSecCamera->getSnapshotAndJpeg(); + addr = mSecCamera->getSnapshotAndJpeg(&output_size); //LOGV("[zzangdol] getSnapshotAndJpeg\n"); } #else @@ -1110,6 +1110,10 @@ int CameraHardwareSec::pictureThread() 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) { @@ -1145,8 +1149,6 @@ int CameraHardwareSec::pictureThread() sp<MemoryBase> mem = new MemoryBase(JpegHeap, 0, JpegImageSize + JpegExifSize); mDataCb(CAMERA_MSG_COMPRESSED_IMAGE, mem, mCallbackCookie); - - mDataCb(CAMERA_MSG_RAW_IMAGE, buffer, mCallbackCookie); }//[zzangdol] CAMERA_ID_BACK else { @@ -2386,7 +2388,6 @@ status_t CameraHardwareSec::setParameters(const CameraParameters& params) } } #endif - return ret; } @@ -2449,7 +2450,7 @@ void CameraHardwareSec::release() wp<CameraHardwareInterface> CameraHardwareSec::singleton; -sp<CameraHardwareInterface> CameraHardwareSec::createInstance() +sp<CameraHardwareInterface> CameraHardwareSec::createInstance(int cameraId) { LOGV("%s()", __func__); if (singleton != 0) { @@ -2458,7 +2459,7 @@ sp<CameraHardwareInterface> CameraHardwareSec::createInstance() return hardware; } } - sp<CameraHardwareInterface> hardware(new CameraHardwareSec()); + sp<CameraHardwareInterface> hardware(new CameraHardwareSec(cameraId)); singleton = hardware; return hardware; } @@ -2474,6 +2475,11 @@ static CameraInfo sCameraInfo[] = { { CAMERA_FACING_BACK, 90, /* orientation */ + }, + + { + CAMERA_FACING_FRONT, + 0, /* orientation */ } }; @@ -2489,7 +2495,7 @@ extern "C" void HAL_getCameraInfo(int cameraId, struct CameraInfo* cameraInfo) extern "C" sp<CameraHardwareInterface> HAL_openCameraHardware(int cameraId) { - return CameraHardwareSec::createInstance(); + return CameraHardwareSec::createInstance(cameraId); } }; // namespace android diff --git a/libcamera/SecCameraHWInterface.h b/libcamera/SecCameraHWInterface.h index 4cf446c..1adb023 100644 --- a/libcamera/SecCameraHWInterface.h +++ b/libcamera/SecCameraHWInterface.h @@ -71,10 +71,10 @@ public: int32_t arg2); virtual void release(); - static sp<CameraHardwareInterface> createInstance(); + static sp<CameraHardwareInterface> createInstance(int cameraId); private: - CameraHardwareSec(); + CameraHardwareSec(int cameraId); virtual ~CameraHardwareSec(); static wp<CameraHardwareInterface> singleton; @@ -133,7 +133,7 @@ private: } }; #endif - void initDefaultParameters(); + void initDefaultParameters(int cameraId); void initHeapLocked(); int previewThread(); |