summaryrefslogtreecommitdiff
authorjiyu.yang <jiyu.yang@amlogic.com>2013-01-15 02:51:15 (GMT)
committer jiyu.yang <jiyu.yang@amlogic.com>2013-01-15 02:55:35 (GMT)
commit762776f3ab12d13fe63db7341d43a581ba519b42 (patch)
tree50417b3e48e7efa0bbac111245ee26dda77c17f4
parentb34b3999d1ea623b2bc0de06e263ddf39dae1439 (diff)
downloadcamera-762776f3ab12d13fe63db7341d43a581ba519b42.zip
camera-762776f3ab12d13fe63db7341d43a581ba519b42.tar.gz
camera-762776f3ab12d13fe63db7341d43a581ba519b42.tar.bz2
add touch focus support and version info
Conflicts: V4LCameraAdapter/V4LCameraAdapter.cpp
Diffstat
-rwxr-xr-xAndroid.mk15
-rwxr-xr-xCameraHal_Module.cpp18
-rwxr-xr-xV4LCameraAdapter/V4LCameraAdapter.cpp102
-rwxr-xr-xinc/V4LCameraAdapter/V4LCameraAdapter.h1
4 files changed, 133 insertions, 3 deletions
diff --git a/Android.mk b/Android.mk
index 24d3cf4..d153d4d 100755
--- a/Android.mk
+++ b/Android.mk
@@ -60,6 +60,21 @@ LOCAL_SHARED_LIBRARIES:= \
LOCAL_CFLAGS := -fno-short-enums -DCOPY_IMAGE_BUFFER
+CAMHAL_GIT_VERSION="$(shell cd $(LOCAL_PATH);git log | grep commit -m 1 | cut -d' ' -f 2)"
+CAMHAL_GIT_UNCOMMIT_FILE_NUM=$(shell cd $(LOCAL_PATH);git diff | grep +++ -c)
+CAMHAL_LAST_CHANGED="$(shell cd $(LOCAL_PATH);git log | grep Date -m 1)"
+CAMHAL_BUILD_TIME=" $(shell date)"
+CAMHAL_BUILD_NAME=" $(shell echo ${LOGNAME})"
+CAMHAL_BRANCH_NAME="$(shell cd $(LOCAL_PATH);git branch -a | sed -n '/'*'/p')"
+
+LOCAL_CFLAGS+=-DHAVE_VERSION_INFO
+LOCAL_CFLAGS+=-DCAMHAL_GIT_VERSION=\"${CAMHAL_GIT_VERSION}${CAMHAL_GIT_DIRTY}\"
+LOCAL_CFLAGS+=-DCAMHAL_BRANCH_NAME=\"${CAMHAL_BRANCH_NAME}\"
+LOCAL_CFLAGS+=-DCAMHAL_LAST_CHANGED=\"${CAMHAL_LAST_CHANGED}\"
+LOCAL_CFLAGS+=-DCAMHAL_BUILD_TIME=\"${CAMHAL_BUILD_TIME}\"
+LOCAL_CFLAGS+=-DCAMHAL_BUILD_NAME=\"${CAMHAL_BUILD_NAME}\"
+LOCAL_CFLAGS+=-DCAMHAL_GIT_UNCOMMIT_FILE_NUM=${CAMHAL_GIT_UNCOMMIT_FILE_NUM}
+
ifeq ($(BOARD_HAVE_FRONT_CAM),true)
LOCAL_CFLAGS += -DAMLOGIC_FRONT_CAMERA_SUPPORT
endif
diff --git a/CameraHal_Module.cpp b/CameraHal_Module.cpp
index 92c4b49..ef1e623 100755
--- a/CameraHal_Module.cpp
+++ b/CameraHal_Module.cpp
@@ -617,6 +617,24 @@ extern "C" int CameraAdapter_CameraNum();
int camera_get_number_of_cameras(void)
{
int num_cameras = CameraAdapter_CameraNum();
+
+#ifdef HAVE_VERSION_INFO
+ CAMHAL_LOGDB("\n--------------------------------\n"
+ "author:aml.sh multi-media team\n"
+ "branch name: %s\n"
+ "git version: %s \n"
+ "last changed: %s\n"
+ "build-time: %s\n"
+ "build-name: %s\n"
+ "uncommitted-file-num:%d\n"
+ "--------------------------------\n",
+ CAMHAL_BRANCH_NAME,
+ CAMHAL_GIT_VERSION,
+ CAMHAL_LAST_CHANGED,
+ CAMHAL_BUILD_TIME,
+ CAMHAL_BUILD_NAME,
+ CAMHAL_GIT_UNCOMMIT_FILE_NUM );
+#endif
return num_cameras;
}
diff --git a/V4LCameraAdapter/V4LCameraAdapter.cpp b/V4LCameraAdapter/V4LCameraAdapter.cpp
index 1822ffe..b3e268f 100755
--- a/V4LCameraAdapter/V4LCameraAdapter.cpp
+++ b/V4LCameraAdapter/V4LCameraAdapter.cpp
@@ -282,13 +282,24 @@ status_t V4LCameraAdapter::initialize(CameraProperties::Properties* caps)
if((fpsrange != NULL)&&(NO_ERROR == ret) && ( 0 !=fps_num )){
mPreviewFrameRate = fps/fps_num;
sprintf(fpsrange,"%s%d","5,",fps/fps_num);
- CAMHAL_LOGDB("supported preview rates is %s\n", fpsrange);
+ CAMHAL_LOGDB("supported preview rates is %s\n", fpsrange);
mParams.set(CameraParameters::KEY_PREVIEW_FRAME_RATE,fps/fps_num);
mParams.set(CameraParameters::KEY_SUPPORTED_PREVIEW_FRAME_RATES,fpsrange);
mParams.set(CameraParameters::KEY_SUPPORTED_PREVIEW_FPS_RANGE,fpsrange);
mParams.set(CameraParameters::KEY_PREVIEW_FPS_RANGE,fpsrange);
+ }else{
+ mPreviewFrameRate = 15;
+
+ sprintf(fpsrange,"%s%d","10,", mPreviewFrameRate);
+ CAMHAL_LOGDB("default preview rates is %s\n", fpsrange);
+
+ mParams.set(CameraParameters::KEY_PREVIEW_FRAME_RATE, mPreviewFrameRate);
+ mParams.set(CameraParameters::KEY_SUPPORTED_PREVIEW_FRAME_RATES,fpsrange);
+
+ mParams.set(CameraParameters::KEY_SUPPORTED_PREVIEW_FPS_RANGE,fpsrange);
+ mParams.set(CameraParameters::KEY_PREVIEW_FPS_RANGE,fpsrange);
}
#endif
#ifndef AMLOGIC_USB_CAMERA_SUPPORT
@@ -538,6 +549,7 @@ status_t V4LCameraAdapter::setParameters(const CameraParameters &params)
const char *flashmode=NULL;
const char *focusmode=NULL;
const char *supportfocusmode=NULL;
+ const char *focusarea = NULL;
qulity=mParams.get(CameraParameters::KEY_JPEG_QUALITY);
@@ -640,6 +652,11 @@ status_t V4LCameraAdapter::setParameters(const CameraParameters &params)
CAMHAL_LOGDA("not support continuous mode!\n");
}
+ focusarea = mParams.get(CameraParameters::KEY_FOCUS_AREAS);
+ if(focusarea){
+ set_focus_area( mCameraHandle, focusarea);
+ }
+
mParams.getPreviewFpsRange(&min_fps, &max_fps);
if((min_fps<0)||(max_fps<0)||(max_fps<min_fps))
{
@@ -2500,6 +2517,46 @@ static bool getCameraAutoFocus(int camera_fd, char* focus_mode_str, char*def_foc
}
return auto_focus_enable;
}
+static bool getCameraFocusArea(int camera_fd, char* max_num_focus_area,
+ char*focus_area)
+{
+ struct v4l2_queryctrl qc;
+ int ret = 0;
+ int x0 = 0;
+ int y0 = 0;
+ int x1 = 0;
+ int y1 = 0;
+
+ if((!max_num_focus_area)||(!focus_area)){
+ CAMHAL_LOGEA("focus area str buf error");
+ return false;
+ }
+
+
+ if(camera_fd<0){
+ CAMHAL_LOGEA("camera handle is invaild");
+ return false;
+ }
+
+
+ memset(&qc, 0, sizeof(struct v4l2_queryctrl));
+ qc.id = V4L2_CID_FOCUS_ABSOLUTE;
+ ret = ioctl (camera_fd, VIDIOC_QUERYCTRL, &qc);
+ if((qc.flags == V4L2_CTRL_FLAG_DISABLED) ||( ret < 0)
+ || (qc.type != V4L2_CTRL_TYPE_INTEGER)){
+ CAMHAL_LOGDB("camera handle %d can't support auto focus",camera_fd);
+ return false;
+ }
+
+ x0 = qc.minimum & 0xFFFF;
+ y0 = (qc.minimum >> 16) & 0xFFFF;
+ x1 = qc.maximum & 0xFFFF;
+ y1 = (qc.maximum >> 16) & 0xFFFF;
+ strcpy(max_num_focus_area, "1");
+ sprintf(focus_area, "(%d,%d,%d,%d, 1)", x0, y0, x1, y1);
+
+ return true;
+}
//TODO move
extern "C" void loadCaps(int camera_id, CameraProperties::Properties* params) {
@@ -2804,6 +2861,13 @@ extern "C" void loadCaps(int camera_id, CameraProperties::Properties* params) {
if(getCameraAutoFocus(camera_fd, focus_mode,def_focus_mode)) {
params->set(CameraProperties::SUPPORTED_FOCUS_MODES, focus_mode);
params->set(CameraProperties::FOCUS_MODE, def_focus_mode);
+ memset(focus_mode,0,256);
+ memset(def_focus_mode,0,64);
+ if ( getCameraFocusArea( camera_fd, def_focus_mode, focus_mode)){
+ params->set(CameraProperties::MAX_FOCUS_AREAS, def_focus_mode);
+ CAMHAL_LOGDB("focus_area=%s, max_num_focus_area=%s\n",
+ focus_mode, def_focus_mode);
+ }
}else {
params->set(CameraProperties::SUPPORTED_FOCUS_MODES, "fixed");
params->set(CameraProperties::FOCUS_MODE, "fixed");
@@ -2814,11 +2878,11 @@ extern "C" void loadCaps(int camera_id, CameraProperties::Properties* params) {
}
if(focus_mode){
free(focus_mode);
- focus_mode = NULL;
+ focus_mode = NULL;
}
if(def_focus_mode){
free(def_focus_mode);
- def_focus_mode = NULL;
+ def_focus_mode = NULL;
}
char *banding_mode = (char *) calloc (1, 256);
@@ -3196,6 +3260,38 @@ status_t V4LCameraAdapter::getFocusMoveStatus()
return ctl.value;
}
+extern "C" int V4LCameraAdapter::set_focus_area( int camera_fd, const char *focusarea)
+{
+ struct v4l2_control ctl;
+ int ret;
+ int x0 = 0;
+ int y0 = 0;
+ int x1 = 0;
+ int y1 = 0;
+ int weight = 0;
+ int tempvalue = 0;
+
+ sscanf(focusarea,"(%d,%d,%d,%d,%d)",&x0,&y0,&x1,&y1,&weight);
+ if( (x0==x1)&&(y0==y1) ){
+ CAMHAL_LOGDA("Invalid position for tap focus!\n");
+ return 0;
+ }
+ memset( &ctl, 0, sizeof(ctl));
+ ctl.id = V4L2_CID_FOCUS_ABSOLUTE;
+
+ tempvalue = ((x0+x1)/2 + 1000);
+ tempvalue <<= 16;
+ ctl.value = tempvalue;
+ tempvalue = ((y0+y1)/2 + 1000) & 0xffff;
+ ctl.value |= tempvalue;
+ ret = ioctl(mCameraHandle, VIDIOC_S_CTRL, &ctl);
+ if ( 0 > ret ){
+ CAMHAL_LOGDA("focus tap failed\n");
+ return -EINVAL;
+ }
+
+ return 0;
+}
/*
* use id V4L2_CID_EXPOSURE_AUTO to set exposure mode
* 0: Auto Mode, commit failure @20120504
diff --git a/inc/V4LCameraAdapter/V4LCameraAdapter.h b/inc/V4LCameraAdapter/V4LCameraAdapter.h
index 759fef9..a9073ad 100755
--- a/inc/V4LCameraAdapter/V4LCameraAdapter.h
+++ b/inc/V4LCameraAdapter/V4LCameraAdapter.h
@@ -243,6 +243,7 @@ public:
int SetExposure(int camera_fd,const char *sbn);
int SetExposureMode(int camera_fd, unsigned int mode);
int set_white_balance(int camera_fd,const char *swb);
+ int set_focus_area(int camera_fd, const char *focusarea);
int set_banding(int camera_fd,const char *snm);
///Initialzes the camera adapter creates any resources required