summaryrefslogtreecommitdiff
authorYuxi Sun <yuxi.sun@amlogic.com>2014-12-30 06:49:52 (GMT)
committer Yuxi Sun <yuxi.sun@amlogic.com>2015-01-04 06:43:08 (GMT)
commit0efc0db663ea63f39e19d1ed37bc11921f3d0de2 (patch)
tree2ce6ee0782c885329ee9c15e83649ab772ee5a9b
parent90539dead910d09157ea4601789de0de16ef7cb0 (diff)
downloadcamera-0efc0db663ea63f39e19d1ed37bc11921f3d0de2.zip
camera-0efc0db663ea63f39e19d1ed37bc11921f3d0de2.tar.gz
camera-0efc0db663ea63f39e19d1ed37bc11921f3d0de2.tar.bz2
New facing rule for usb and on board camera.
When there is ro.camera.usb.faceback property in system, usb facing back or front is decided by this property, if there is't, by default is front. On board camera facing is decided by DTD cfg first, if DTD facing cfg does not exist, id 0 will be back, all others will be front. Change-Id: I843d6e604fd58effce007f888c2d784806914b63 Signed-off-by: yuxi.sun <yuxi.sun@amlogic.com>
Diffstat
-rwxr-xr-xv3/EmulatedCameraFactory.cpp11
-rwxr-xr-xv3/EmulatedFakeCamera3.cpp75
-rwxr-xr-xv3/EmulatedFakeCamera3.h3
-rwxr-xr-xv3/fake-pipeline2/Sensor.cpp11
-rwxr-xr-xv3/fake-pipeline2/Sensor.h29
5 files changed, 95 insertions, 34 deletions
diff --git a/v3/EmulatedCameraFactory.cpp b/v3/EmulatedCameraFactory.cpp
index 01629f4..eea5127 100755
--- a/v3/EmulatedCameraFactory.cpp
+++ b/v3/EmulatedCameraFactory.cpp
@@ -74,7 +74,6 @@ EmulatedCameraFactory::EmulatedCameraFactory()
{
status_t res;
/* Connect to the factory service in the emulator, and create Qemu cameras. */
- bool facingback = true;
int cameraId = 0;
memset(mEmulatedCameras, 0,(MAX_CAMERA_NUM) * sizeof(EmulatedBaseCamera*));
@@ -83,14 +82,13 @@ EmulatedCameraFactory::EmulatedCameraFactory()
for( int i = 0; i < mEmulatedCameraNum; i++ ) {
cameraId = i;
- facingback = isFakeCameraFacingBack(cameraId);
- mEmulatedCameras[i] = new EmulatedFakeCamera3(cameraId, facingback,&HAL_MODULE_INFO_SYM.common);
+ mEmulatedCameras[i] = new EmulatedFakeCamera3(cameraId, &HAL_MODULE_INFO_SYM.common);
if (mEmulatedCameras[i] != NULL) {
ALOGV("%s: camera device version is %d", __FUNCTION__,
getFakeCameraHalVersion(cameraId));
res = mEmulatedCameras[i]->Initialize();
if (res != NO_ERROR) {
- ALOGE("%s: Unable to intialize back camera %d: %s (%d)",
+ ALOGE("%s: Unable to intialize camera %d: %s (%d)",
__FUNCTION__, i, strerror(-res), res);
delete mEmulatedCameras[i];
}
@@ -424,8 +422,7 @@ void EmulatedCameraFactory::onStatusChanged(int cameraId, int newStatus)
if (!cam) {
/*suppose only usb camera produce uevent, and it is facing back*/
- cam = new EmulatedFakeCamera3(cameraId,
- /*facingback*/true,&HAL_MODULE_INFO_SYM.common);
+ cam = new EmulatedFakeCamera3(cameraId, &HAL_MODULE_INFO_SYM.common);
if (cam != NULL) {
CAMHAL_LOGDB("%s: new camera device version is %d", __FUNCTION__,
getFakeCameraHalVersion(cameraId));
@@ -433,7 +430,7 @@ void EmulatedCameraFactory::onStatusChanged(int cameraId, int newStatus)
usleep(10000);
res = cam->Initialize();
if (res != NO_ERROR) {
- ALOGE("%s: Unable to intialize back camera %d: %s (%d)",
+ ALOGE("%s: Unable to intialize camera %d: %s (%d)",
__FUNCTION__, cameraId, strerror(-res), res);
delete cam;
}
diff --git a/v3/EmulatedFakeCamera3.cpp b/v3/EmulatedFakeCamera3.cpp
index 482a760..564e1e3 100755
--- a/v3/EmulatedFakeCamera3.cpp
+++ b/v3/EmulatedFakeCamera3.cpp
@@ -160,12 +160,9 @@ ssize_t EmulatedFakeCamera3::getJpegBufferSize(int width, int height) {
return jpegBufferSize;
}
-EmulatedFakeCamera3::EmulatedFakeCamera3(int cameraId, bool facingBack,
- struct hw_module_t* module) :
- EmulatedCamera3(cameraId, module),
- mFacingBack(facingBack) {
- ALOGI("Constructing emulated fake camera 3 facing %s, cameraID:%d",
- facingBack ? "back" : "front", mCameraID);
+EmulatedFakeCamera3::EmulatedFakeCamera3(int cameraId, struct hw_module_t* module) :
+ EmulatedCamera3(cameraId, module) {
+ ALOGI("Constructing emulated fake camera 3 cameraID:%d", mCameraID);
for (size_t i = 0; i < CAMERA3_TEMPLATE_COUNT; i++) {
mDefaultTemplates[i] = NULL;
@@ -359,13 +356,22 @@ status_t EmulatedFakeCamera3::getCameraInfo(struct camera_info *info) {
info->facing = mFacingBack ? CAMERA_FACING_BACK : CAMERA_FACING_FRONT;
if (mSupportCap & IOCTL_MASK_ROTATE) {
if (mFacingBack) {
- property_get("ro.camera.orientation.back", property, "270");
+ property_get("rw.camera.orientation.back", property, "270");
} else {
- property_get("ro.camera.orientation.front", property, "90");
+ property_get("rw.camera.orientation.front", property, "90");
}
info->orientation = atoi(property);
} else {
- info->orientation = 0;
+ if (mFacingBack) {
+ property_get("rw.camera.orientation.back", property, "270");
+ } else {
+ property_get("rw.camera.orientation.front", property, "90");
+ }
+ int32_t orientation = atoi(property);
+ property_get("rw.camera.usb.orientation_offset", property, "0");
+ orientation += atoi(property);
+ orientation %= 360;
+ info->orientation = orientation ;
}
return EmulatedCamera3::getCameraInfo(info);
}
@@ -1567,6 +1573,34 @@ status_t EmulatedFakeCamera3::constructStaticInfo() {
sp<Sensor> s = new Sensor();
s->startUp(mCameraID);
+ if (s->getSensorType() == SENSOR_USB) {
+ char property[PROPERTY_VALUE_MAX];
+ property_get("rw.camera.usb.faceback", property, "false");
+ if (strstr(property, "true"))
+ mFacingBack = 1;
+ else
+ mFacingBack = 0;
+ ALOGI("Setting usb camera cameraID:%d to back camera:%s\n",
+ mCameraID, property);
+ } else {
+ if (s->mSensorFace == SENSOR_FACE_FRONT) {
+ mFacingBack = 0;
+ } else if (s->mSensorFace == SENSOR_FACE_BACK) {
+ mFacingBack = 1;
+ } else if (s->mSensorFace == SENSOR_FACE_NONE) {
+ if (gEmulatedCameraFactory.getEmulatedCameraNum() == 1) {
+ mFacingBack = 1;
+ } else if ( mCameraID == 0) {
+ mFacingBack = 1;
+ } else {
+ mFacingBack = 0;
+ }
+ }
+
+ ALOGI("Setting on board camera cameraID:%d to back camera:%d[0 false, 1 true]\n",
+ mCameraID, mFacingBack);
+ }
+
mSupportCap = s->IoctlStateProbe();
if (mSupportCap & IOCTL_MASK_ROTATE) {
supportrotate = true;
@@ -1669,14 +1703,25 @@ status_t EmulatedFakeCamera3::constructStaticInfo() {
info.update(ANDROID_SENSOR_INFO_TIMESTAMP_SOURCE, &timestampSource, 1);
if (supportrotate) {
if (mFacingBack) {
- property_get("ro.camera.orientation.back", property, "0");
+ property_get("rw.camera.orientation.back", property, "0");
+ const int32_t orientation = atoi(property);
+ info.update(ANDROID_SENSOR_ORIENTATION, &orientation, 1);
} else {
- property_get("ro.camera.orientation.front", property, "90");
+ property_get("rw.camera.orientation.front", property, "90");
+ const int32_t orientation = atoi(property);
+ info.update(ANDROID_SENSOR_ORIENTATION, &orientation, 1);
}
- const int32_t orientation = atoi(property);
- info.update(ANDROID_SENSOR_ORIENTATION, &orientation, 1);
- } else {
- static const int32_t orientation = 0;
+
+ } else if (s->getSensorType() == SENSOR_USB) {
+ if (mFacingBack) {
+ property_get("rw.camera.orientation.back", property, "0");
+ } else {
+ property_get("rw.camera.orientation.front", property, "90");
+ }
+ int32_t orientation = atoi(property);
+ property_get("rw.camera.usb.orientation_offset", property, "0");
+ orientation += atoi(property);
+ orientation %= 360;
info.update(ANDROID_SENSOR_ORIENTATION, &orientation, 1);
}
diff --git a/v3/EmulatedFakeCamera3.h b/v3/EmulatedFakeCamera3.h
index 7de6a4e..a78d53c 100755
--- a/v3/EmulatedFakeCamera3.h
+++ b/v3/EmulatedFakeCamera3.h
@@ -50,8 +50,7 @@ class EmulatedFakeCamera3 : public EmulatedCamera3,
private Sensor::SensorListener {
public:
- EmulatedFakeCamera3(int cameraId, bool facingBack,
- struct hw_module_t* module);
+ EmulatedFakeCamera3(int cameraId, struct hw_module_t* module);
virtual ~EmulatedFakeCamera3();
diff --git a/v3/fake-pipeline2/Sensor.cpp b/v3/fake-pipeline2/Sensor.cpp
index bfd2027..98866bd 100755
--- a/v3/fake-pipeline2/Sensor.cpp
+++ b/v3/fake-pipeline2/Sensor.cpp
@@ -176,9 +176,20 @@ status_t Sensor::startUp(int idx) {
mSensorType = SENSOR_SHARE_FD;
}
+ if (strstr((const char *)vinfo->cap.card, "front"))
+ mSensorFace = SENSOR_FACE_FRONT;
+ else if (strstr((const char *)vinfo->cap.card, "back"))
+ mSensorFace = SENSOR_FACE_BACK;
+ else
+ mSensorFace = SENSOR_FACE_NONE;
+
return res;
}
+sensor_type_e Sensor::getSensorType(void)
+{
+ return mSensorType;
+}
status_t Sensor::IoctlStateProbe(void) {
struct v4l2_queryctrl qc;
int ret = 0;
diff --git a/v3/fake-pipeline2/Sensor.h b/v3/fake-pipeline2/Sensor.h
index 8de02be..1116dc9 100755
--- a/v3/fake-pipeline2/Sensor.h
+++ b/v3/fake-pipeline2/Sensor.h
@@ -149,6 +149,21 @@ typedef enum camera_focus_mode_e {
CAM_FOCUS_MODE_CONTI_PIC,
}camera_focus_mode_t;
+typedef enum sensor_type_e{
+ SENSOR_MMAP = 0,
+ SENSOR_ION,
+ SENSOR_ION_MPLANE,
+ SENSOR_DMA,
+ SENSOR_CANVAS_MODE,
+ SENSOR_USB,
+ SENSOR_SHARE_FD,
+}sensor_type_t;
+
+typedef enum sensor_face_type_e{
+ SENSOR_FACE_NONE= 0,
+ SENSOR_FACE_FRONT,
+ SENSOR_FACE_BACK,
+}sensor_face_type_t;
#define IOCTL_MASK_ROTATE (1<<0)
class Sensor: private Thread, public virtual RefBase {
@@ -285,6 +300,10 @@ class Sensor: private Thread, public virtual RefBase {
static const int32_t kSensitivityRange[2];
static const uint32_t kDefaultSensitivity;
+ sensor_type_e getSensorType(void);
+
+ sensor_face_type_e mSensorFace;
+
private:
Mutex mControlMutex; // Lock before accessing control parameters
// Start of control parameters
@@ -322,16 +341,6 @@ class Sensor: private Thread, public virtual RefBase {
unsigned int framecount;
unsigned int fps;
- typedef enum sensor_type_e{
- SENSOR_MMAP = 0,
- SENSOR_ION,
- SENSOR_ION_MPLANE,
- SENSOR_DMA,
- SENSOR_CANVAS_MODE,
- SENSOR_USB,
- SENSOR_SHARE_FD,
- }sensor_type_t;
-
enum sensor_type_e mSensorType;
unsigned int mIoctlSupport;
unsigned int msupportrotate;