summaryrefslogtreecommitdiff
authorsky.zhou <sky.zhou@amlogic.com>2012-10-15 06:49:23 (GMT)
committer sky.zhou <sky.zhou@amlogic.com>2012-10-15 06:49:23 (GMT)
commitcbb930eeb951d6c7cdec339ff1476592ec82cc77 (patch)
tree65e8708da2e96f408f9a81267f909e60368e8a30
parentfc07c4ecb18947732add7c583b18a4644b938243 (diff)
downloadcamera-cbb930eeb951d6c7cdec339ff1476592ec82cc77.zip
camera-cbb930eeb951d6c7cdec339ff1476592ec82cc77.tar.gz
camera-cbb930eeb951d6c7cdec339ff1476592ec82cc77.tar.bz2
add a special command CAMERA_DISABLE_MIRROR for some camera application display error
Diffstat
-rwxr-xr-xBaseCameraAdapter.cpp13
-rwxr-xr-xCameraHal.cpp24
-rwxr-xr-xV4LCameraAdapter/V4LCameraAdapter.cpp37
-rwxr-xr-xinc/BaseCameraAdapter.h2
-rwxr-xr-xinc/CameraHal.h2
-rwxr-xr-xinc/V4LCameraAdapter/V4LCameraAdapter.h3
6 files changed, 63 insertions, 18 deletions
diff --git a/BaseCameraAdapter.cpp b/BaseCameraAdapter.cpp
index a048e7f..64ef828 100755
--- a/BaseCameraAdapter.cpp
+++ b/BaseCameraAdapter.cpp
@@ -974,6 +974,10 @@ status_t BaseCameraAdapter::sendCommand(CameraCommands operation, int value1, in
ret = switchToExecuting();
break;
+ case CameraAdapter::CAMERA_DISABLE_MIRROR:
+ ret = disableMirror(value1);
+ break;
+
default:
CAMHAL_LOGEB("Command 0x%x unsupported!", operation);
break;
@@ -1733,6 +1737,15 @@ status_t BaseCameraAdapter::switchToExecuting()
return ret;
}
+status_t BaseCameraAdapter::disableMirror(bool bDisable)
+{
+ status_t ret = NO_ERROR;
+ LOG_FUNCTION_NAME;
+ LOG_FUNCTION_NAME_EXIT;
+ return ret;
+}
+
+
status_t BaseCameraAdapter::setState(CameraCommands operation)
{
status_t ret = NO_ERROR;
diff --git a/CameraHal.cpp b/CameraHal.cpp
index f114544..f15a420 100755
--- a/CameraHal.cpp
+++ b/CameraHal.cpp
@@ -2799,21 +2799,33 @@ status_t CameraHal::sendCommand(int32_t cmd, int32_t arg1, int32_t arg2)
if ( ( NO_ERROR == ret ) && ( NULL == mCameraAdapter ) )
- {
+ {
CAMHAL_LOGEA("No CameraAdapter instance");
ret = -EINVAL;
- }
+ }
if ( ( NO_ERROR == ret ) && ( !previewEnabled() ))
- {
+ {
+ if( cmd == CAMERA_CMD_SET_DISPLAY_ORIENTATION) {
+ if(arg2 == 1) {//disable mirror
+ ret = mCameraAdapter->sendCommand(CameraAdapter::CAMERA_DISABLE_MIRROR, 1);
+ }
+ }
CAMHAL_LOGEA("Preview is not running");
ret = -EINVAL;
- }
+ }
if ( NO_ERROR == ret )
- {
+ {
switch(cmd)
- {
+ {
+ case CAMERA_CMD_SET_DISPLAY_ORIENTATION:
+
+ if(arg2 == 1) {//disable mirror
+ ret = mCameraAdapter->sendCommand(CameraAdapter::CAMERA_DISABLE_MIRROR, 1);
+ }
+
+ break;
case CAMERA_CMD_START_SMOOTH_ZOOM:
ret = mCameraAdapter->sendCommand(CameraAdapter::CAMERA_START_SMOOTH_ZOOM, arg1);
diff --git a/V4LCameraAdapter/V4LCameraAdapter.cpp b/V4LCameraAdapter/V4LCameraAdapter.cpp
index dbd05f4..efc79c1 100755
--- a/V4LCameraAdapter/V4LCameraAdapter.cpp
+++ b/V4LCameraAdapter/V4LCameraAdapter.cpp
@@ -1066,12 +1066,7 @@ status_t V4LCameraAdapter::startPreview()
#ifndef AMLOGIC_USB_CAMERA_SUPPORT
- if(mIoctlSupport & IOCTL_MASK_HFLIP){
- if(set_hflip_mode(mCameraHandle,mbFrontCamera?true:false))
- writefile((char *)SYSFILE_CAMERA_SET_MIRROR,(char*)(mbFrontCamera?"1":"0"));
- }else{
- writefile((char *)SYSFILE_CAMERA_SET_MIRROR,(char*)(mbFrontCamera?"1":"0"));
- }
+ setMirrorEffect();
if(mIoctlSupport & IOCTL_MASK_ROTATE){
set_rotate_value(mCameraHandle,0);
@@ -1354,6 +1349,7 @@ V4LCameraAdapter::V4LCameraAdapter(size_t sensor_index)
{
LOG_FUNCTION_NAME;
+ mbDisableMirror = false;
mSensorIndex = sensor_index;
LOG_FUNCTION_NAME_EXIT;
@@ -1677,12 +1673,7 @@ int V4LCameraAdapter::pictureThread()
CameraFrame frame;
#ifndef AMLOGIC_USB_CAMERA_SUPPORT
- if(mIoctlSupport & IOCTL_MASK_HFLIP){
- if(set_hflip_mode(mCameraHandle,mbFrontCamera?true:false))
- writefile((char *)SYSFILE_CAMERA_SET_MIRROR,(char*)(mbFrontCamera?"1":"0"));
- }else{
- writefile((char *)SYSFILE_CAMERA_SET_MIRROR,(char*)(mbFrontCamera?"1":"0"));
- }
+ setMirrorEffect();
#endif
if( (mIoctlSupport & IOCTL_MASK_FLASH)
@@ -1874,6 +1865,28 @@ int V4LCameraAdapter::pictureThread()
}
+status_t V4LCameraAdapter::disableMirror(bool bDisable) {
+ LOGD("disableMirror %d",bDisable);
+ mbDisableMirror = bDisable;
+ setMirrorEffect();
+ return NO_ERROR;
+}
+
+status_t V4LCameraAdapter::setMirrorEffect() {
+ bool bEnable = mbFrontCamera&&(!mbDisableMirror);
+ LOGD("setmirror effect %d",bEnable);
+
+ if(mIoctlSupport & IOCTL_MASK_HFLIP){
+ if(set_hflip_mode(mCameraHandle,bEnable))
+ writefile((char *)SYSFILE_CAMERA_SET_MIRROR,(char*)(bEnable?"1":"0"));
+ }else{
+ writefile((char *)SYSFILE_CAMERA_SET_MIRROR,(char*)(bEnable?"1":"0"));
+ }
+ return NO_ERROR;
+}
+
+
+
// ---------------------------------------------------------------------------
extern "C" CameraAdapter* CameraAdapter_Factory(size_t sensor_index)
{
diff --git a/inc/BaseCameraAdapter.h b/inc/BaseCameraAdapter.h
index c0e2767..3df57f0 100755
--- a/inc/BaseCameraAdapter.h
+++ b/inc/BaseCameraAdapter.h
@@ -162,6 +162,8 @@ protected:
int getFrameRefCount(void* frameBuf, CameraFrame::FrameType frameType);
int setInitFrameRefCount(void* buf, unsigned int mask);
+ virtual status_t disableMirror(bool bDisable);
+
// private member functions
private:
status_t __sendFrameToSubscribers(CameraFrame* frame,
diff --git a/inc/CameraHal.h b/inc/CameraHal.h
index 3ce77d7..effe37b 100755
--- a/inc/CameraHal.h
+++ b/inc/CameraHal.h
@@ -781,6 +781,8 @@ public:
CAMERA_START_FD = 22,
CAMERA_STOP_FD = 23,
CAMERA_SWITCH_TO_EXECUTING = 24,
+ CAMERA_DISABLE_MIRROR = 25,
+
};
enum CameraMode
diff --git a/inc/V4LCameraAdapter/V4LCameraAdapter.h b/inc/V4LCameraAdapter/V4LCameraAdapter.h
index 2acf346..22713ae 100755
--- a/inc/V4LCameraAdapter/V4LCameraAdapter.h
+++ b/inc/V4LCameraAdapter/V4LCameraAdapter.h
@@ -272,6 +272,8 @@ protected:
virtual status_t getFrameDataSize(size_t &dataFrameSize, size_t bufferCount);
virtual void onOrientationEvent(uint32_t orientation, uint32_t tilt);
//-----------------------------------------------------------------------------
+ status_t disableMirror(bool bDisable);
+ status_t setMirrorEffect();
private:
@@ -337,6 +339,7 @@ private:
int mSensorIndex;
bool mbFrontCamera;
+ bool mbDisableMirror;
// protected by mLock
sp<PreviewThread> mPreviewThread;