summaryrefslogtreecommitdiff
authorbrian.zhu <brian.zhu@amlogic.com>2011-12-12 11:52:53 (GMT)
committer brian.zhu <brian.zhu@amlogic.com>2011-12-12 11:52:53 (GMT)
commitf47e3ff0d3842819d3c20b60115606f6ddf6b64a (patch)
tree7099a6a2ca3d57210a0f8477986ffc768a98b215
parent2e2e26ab3dee561da17c6e95b2a8d97dfe602858 (diff)
downloadcamera-f47e3ff0d3842819d3c20b60115606f6ddf6b64a.zip
camera-f47e3ff0d3842819d3c20b60115606f6ddf6b64a.tar.gz
camera-f47e3ff0d3842819d3c20b60115606f6ddf6b64a.tar.bz2
disable video layer when using suface to display
Diffstat
-rw-r--r--CameraHal.cpp171
1 files changed, 169 insertions, 2 deletions
diff --git a/CameraHal.cpp b/CameraHal.cpp
index daa2ad6..1f8e7d3 100644
--- a/CameraHal.cpp
+++ b/CameraHal.cpp
@@ -33,8 +33,157 @@
#include <poll.h>
#include <math.h>
+//#define AMLOGIC_CAMERA_OVERLAY_SUPPORT
+
namespace android {
+#if 1//def AMLOGIC_CAMERA_OVERLAY_SUPPORT
+#ifndef FBIOPUT_OSD_SRCCOLORKEY
+#define FBIOPUT_OSD_SRCCOLORKEY 0x46fb
+#endif
+#ifndef FBIOPUT_OSD_SRCKEY_ENABLE
+#define FBIOPUT_OSD_SRCKEY_ENABLE 0x46fa
+#endif
+#ifndef FBIOPUT_OSD_SET_GBL_ALPHA
+#define FBIOPUT_OSD_SET_GBL_ALPHA 0x4500
+#endif
+
+int SYS_enable_colorkey(short key_rgb565)
+{
+ int ret = -1;
+ int fd_fb0 = open("/dev/graphics/fb0", O_RDWR);
+ if (fd_fb0 >= 0)
+ {
+ uint32_t myKeyColor = key_rgb565;
+ uint32_t myKeyColor_en = 1;
+ printf("enablecolorkey color=%#x\n", myKeyColor);
+ ret = ioctl(fd_fb0, FBIOPUT_OSD_SRCCOLORKEY, &myKeyColor);
+ ret += ioctl(fd_fb0, FBIOPUT_OSD_SRCKEY_ENABLE, &myKeyColor_en);
+ close(fd_fb0);
+ }
+ return ret;
+}
+
+int SYS_disable_colorkey()
+{
+ int ret = -1;
+ int fd_fb0 = open("/dev/graphics/fb0", O_RDWR);
+ if (fd_fb0 >= 0)
+ {
+ uint32_t myKeyColor_en = 0;
+ ret = ioctl(fd_fb0, FBIOPUT_OSD_SRCKEY_ENABLE, &myKeyColor_en);
+ close(fd_fb0);
+ }
+ return ret;
+}
+
+static void write_sys_int(const char *path, int val)
+{
+ char cmd[16];
+ int fd = open(path, O_RDWR);
+
+ if(fd >= 0) {
+ sprintf(cmd, "%d", val);
+ write(fd, cmd, strlen(cmd));
+ close(fd);
+ }
+}
+
+static void write_sys_string(const char *path, const char *s)
+{
+ int fd = open(path, O_RDWR);
+
+ if(fd >= 0) {
+ write(fd, s, strlen(s));
+ close(fd);
+ }
+}
+
+#define DISABLE_VIDEO "/sys/class/video/disable_video"
+#define ENABLE_AVSYNC "/sys/class/tsync/enable"
+#define ENABLE_BLACKOUT "/sys/class/video/blackout_policy"
+#define TSYNC_EVENT "/sys/class/tsync/event"
+#define VIDEO_ZOOM "/sys/class/video/zoom"
+
+static int SYS_enable_nextvideo()
+{
+ write_sys_int(DISABLE_VIDEO, 2);
+ return 0;
+}
+
+static int SYS_close_video()
+{
+ write_sys_int(DISABLE_VIDEO, 1);
+ return 0;
+}
+
+static int SYS_open_video()
+{
+ write_sys_int(DISABLE_VIDEO, 0);
+ return 0;
+}
+
+static int SYS_disable_avsync()
+{
+ write_sys_int(ENABLE_AVSYNC, 0);
+ return 0;
+}
+
+static int SYS_disable_video_pause()
+{
+ write_sys_string(TSYNC_EVENT, "VIDEO_PAUSE:0x0");
+ return 0;
+}
+
+static int SYS_set_zoom(int zoom)
+{
+ write_sys_int(VIDEO_ZOOM, zoom);
+ return 0;
+}
+
+static int SYS_reset_zoom(void)
+{
+ 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);
/*****************************************************************************/
@@ -2754,6 +2903,11 @@ void CameraHal::release()
///@todo Investigate on how release is used by CameraService. Vaguely remember that this is called
///just before CameraHal object destruction
deinitialize();
+
+ SYS_enable_nextvideo();
+ SYS_reset_zoom();
+ SYS_disable_colorkey();
+
LOG_FUNCTION_NAME_EXIT;
}
@@ -2851,6 +3005,15 @@ CameraHal::CameraHal(int cameraId)
mCameraIndex = cameraId;
+
+ SYS_disable_avsync();
+ SYS_disable_video_pause();
+#ifdef AMLOGIC_CAMERA_OVERLAY_SUPPORT
+ SYS_enable_nextvideo();
+#else
+ SYS_close_video();
+#endif
+
LOG_FUNCTION_NAME_EXIT;
}
@@ -2868,11 +3031,11 @@ CameraHal::~CameraHal()
deinitialize();
if ( NULL != mEventProvider )
- {
+ {
mEventProvider->disableEventNotification(CameraHalEvent::ALL_EVENTS);
delete mEventProvider;
mEventProvider = NULL;
- }
+ }
/// Free the callback notifier
mAppCallbackNotifier.clear();
@@ -2893,6 +3056,10 @@ CameraHal::~CameraHal()
/// Free the memory manager
mMemoryManager.clear();
+ SYS_enable_nextvideo();
+ SYS_reset_zoom();
+ SYS_disable_colorkey();
+
LOG_FUNCTION_NAME_EXIT;
}