summaryrefslogtreecommitdiff
authorbrian.zhu <brian.zhu@amlogic.com>2012-01-31 07:01:51 (GMT)
committer brian.zhu <brian.zhu@amlogic.com>2012-01-31 07:01:51 (GMT)
commitd4240baedd5179688c1dbe36e3bf941e54f47222 (patch)
treecc8e3c699d17aad29369336997b1237d46cb60f3
parentbaf6bb806d873aeb2451042e013a1a936620df90 (diff)
downloadcamera-d4240baedd5179688c1dbe36e3bf941e54f47222.zip
camera-d4240baedd5179688c1dbe36e3bf941e54f47222.tar.gz
camera-d4240baedd5179688c1dbe36e3bf941e54f47222.tar.bz2
enable digital zoom function
Diffstat
-rwxr-xr-xCameraHal.cpp47
-rwxr-xr-xV4LCameraAdapter/V4LCameraAdapter.cpp41
-rwxr-xr-xinc/V4LCameraAdapter/V4LCameraAdapter.h2
3 files changed, 41 insertions, 49 deletions
diff --git a/CameraHal.cpp b/CameraHal.cpp
index 8f87f65..7318ce3 100755
--- a/CameraHal.cpp
+++ b/CameraHal.cpp
@@ -35,7 +35,7 @@
namespace android {
-#if 1//def AMLOGIC_CAMERA_OVERLAY_SUPPORT
+
#ifndef FBIOPUT_OSD_SRCCOLORKEY
#define FBIOPUT_OSD_SRCCOLORKEY 0x46fb
#endif
@@ -102,6 +102,7 @@ static void write_sys_string(const char *path, const char *s)
#define ENABLE_BLACKOUT "/sys/class/video/blackout_policy"
#define TSYNC_EVENT "/sys/class/tsync/event"
#define VIDEO_ZOOM "/sys/class/video/zoom"
+#define SCREEN_MODE "/sys/class/video/screen_mode"
static int SYS_enable_nextvideo()
{
@@ -133,54 +134,20 @@ static int SYS_disable_video_pause()
return 0;
}
-static int SYS_set_zoom(int zoom)
+extern "C" int SYS_set_zoom(int zoom)
{
+ if(zoom!=100)
+ write_sys_int(SCREEN_MODE, 1); // full stretch
write_sys_int(VIDEO_ZOOM, zoom);
return 0;
}
-static int SYS_reset_zoom(void)
+extern "C" int SYS_reset_zoom(void)
{
+ write_sys_int(SCREEN_MODE, 0);
write_sys_int(VIDEO_ZOOM, 100);
return 0;
}
-#else
-static int SYS_enable_nextvideo()
-{
- return 0;
-}
-
-static int SYS_close_video()
-{
- return 0;
-}
-
-static int SYS_open_video()
-{
- return 0;
-}
-
-static int SYS_disable_avsync()
-{
- return 0;
-}
-
-static int SYS_disable_video_pause()
-{
- return 0;
-}
-
-static int SYS_set_zoom(int zoom)
-{
- return 0;
-}
-
-static int SYS_reset_zoom(void)
-{
- return 0;
-}
-
-#endif
extern "C" CameraAdapter* CameraAdapter_Factory(size_t);
diff --git a/V4LCameraAdapter/V4LCameraAdapter.cpp b/V4LCameraAdapter/V4LCameraAdapter.cpp
index 235ec26..b4126f3 100755
--- a/V4LCameraAdapter/V4LCameraAdapter.cpp
+++ b/V4LCameraAdapter/V4LCameraAdapter.cpp
@@ -82,7 +82,7 @@ extern "C" int set_night_mode(int camera_fd,const char *snm);
extern "C" int set_effect(int camera_fd,const char *sef);
extern "C" int SetExposure(int camera_fd,const char *sbn);
extern "C" int set_white_balance(int camera_fd,const char *swb);
-
+extern "C" int SYS_set_zoom(int zoom);
/*--------------------junk STARTS here-----------------------------*/
@@ -163,6 +163,7 @@ status_t V4LCameraAdapter::initialize(CameraProperties::Properties* caps)
mPreviewing = false;
mVideoInfo->isStreaming = false;
mRecording = false;
+ mZoomlevel = -1;
#ifndef AMLOGIC_USB_CAMERA_SUPPORT
// ---------
@@ -231,12 +232,34 @@ status_t V4LCameraAdapter::setParameters(const CameraParameters &params)
//check zoom value
int zoom = mParams.getInt(CameraParameters::KEY_ZOOM);
int maxzoom = mParams.getInt(CameraParameters::KEY_MAX_ZOOM);
- if((zoom > maxzoom) || (zoom < 0))
- {
+ char *p = (char *)mParams.get(CameraParameters::KEY_ZOOM_RATIOS);
+
+ if(zoom > maxzoom){
rtn = INVALID_OPERATION;
+ CAMHAL_LOGEB("Zoom Parameter Out of range1------zoom level:%d,max level:%d",zoom,maxzoom);
+ zoom = maxzoom;
mParams.set((const char*)CameraParameters::KEY_ZOOM, maxzoom);
+ }else if(zoom <0) {
+ rtn = INVALID_OPERATION;
+ zoom = 0;
+ CAMHAL_LOGEB("Zoom Parameter Out of range2------zoom level:%d,max level:%d",zoom,maxzoom);
+ mParams.set((const char*)CameraParameters::KEY_ZOOM, zoom);
}
+ if ((p) && (zoom >= 0)&&(zoom!=mZoomlevel)) {
+ int z = (int)strtol(p, &p, 10);
+ int i = 0;
+ while (i < zoom) {
+ if (*p != ',') break;
+ z = (int)strtol(p+1, &p, 10);
+ i++;
+ }
+ notifyZoomSubscribers(mZoomlevel,zoom);
+ CAMHAL_LOGDB("Change the zoom level---old:%d,new:%d",mZoomlevel,zoom);
+ mZoomlevel = zoom;
+ SYS_set_zoom(z);
+ }
+
int min_fps,max_fps;
const char *white_balance=NULL;
const char *exposure=NULL;
@@ -1493,16 +1516,16 @@ extern "C" void loadCaps(int camera_id, CameraProperties::Properties* params) {
params->set(CameraProperties::SUPPORTED_EV_STEP, 1);
//don't support digital zoom now
-#if 0
+#ifdef AML_CAMERA_BY_VM_INTERFACE
params->set(CameraProperties::ZOOM_SUPPORTED,"true");
- params->set(CameraProperties::SMOOTH_ZOOM_SUPPORTED,1);
- params->set(CameraProperties::SUPPORTED_ZOOM_RATIOS,"1,2,3,4,5,6,7,8");
- params->set(CameraProperties::SUPPORTED_ZOOM_STAGES,7); //think the zoom ratios as a array, the max zoom is the max index
+ params->set(CameraProperties::SMOOTH_ZOOM_SUPPORTED,"false");
+ params->set(CameraProperties::SUPPORTED_ZOOM_RATIOS,"100,120,140,160,180,200,220,280,300");
+ params->set(CameraProperties::SUPPORTED_ZOOM_STAGES,8); //think the zoom ratios as a array, the max zoom is the max index
params->set(CameraProperties::ZOOM, 0);//default should be 0
#else
params->set(CameraProperties::ZOOM_SUPPORTED,"false");
- params->set(CameraProperties::SMOOTH_ZOOM_SUPPORTED,0);
- params->set(CameraProperties::SUPPORTED_ZOOM_RATIOS,"1");
+ params->set(CameraProperties::SMOOTH_ZOOM_SUPPORTED,"false");
+ params->set(CameraProperties::SUPPORTED_ZOOM_RATIOS,"100");
params->set(CameraProperties::SUPPORTED_ZOOM_STAGES,0); //think the zoom ratios as a array, the max zoom is the max index
params->set(CameraProperties::ZOOM, 0);//default should be 0
#endif
diff --git a/inc/V4LCameraAdapter/V4LCameraAdapter.h b/inc/V4LCameraAdapter/V4LCameraAdapter.h
index 04ffd22..b4e4c64 100755
--- a/inc/V4LCameraAdapter/V4LCameraAdapter.h
+++ b/inc/V4LCameraAdapter/V4LCameraAdapter.h
@@ -299,6 +299,8 @@ private:
int nQueued;
int nDequeued;
+
+ int mZoomlevel;
//int maxQueueable;//the max queued buffers in v4l