Bug 949930 - CameraControl.sensorAngle doesn't return consistent angle among different devices. r=mikeh, a=1.3+
authorBen Tian <btian@mozilla.com>
Mon, 13 Jan 2014 10:12:40 +0800
changeset 175694 2d68aecfdef5de9cb349b5dbc05613b6b18a96d5
parent 175693 f2fa642b5be5c93f405fea2ac8eb8ec0cf7f5cf3
child 175695 2f64f1f2c4c497bee46cee4e44345b54a853de2d
push id445
push userffxbld
push dateMon, 10 Mar 2014 22:05:19 +0000
treeherdermozilla-release@dc38b741b04e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmikeh, 1
bugs949930
milestone28.0a2
Bug 949930 - CameraControl.sensorAngle doesn't return consistent angle among different devices. r=mikeh, a=1.3+
dom/camera/GonkCameraControl.cpp
dom/camera/GonkCameraHwMgr.cpp
dom/camera/GonkCameraHwMgr.h
--- a/dom/camera/GonkCameraControl.cpp
+++ b/dom/camera/GonkCameraControl.cpp
@@ -986,17 +986,17 @@ nsGonkCameraControl::TakePictureImpl(Tak
   SetPictureSize(aTakePicture->mSize.width, aTakePicture->mSize.height);
 
   // Picture format -- need to keep it for the callback.
   mFileFormat = aTakePicture->mFileFormat;
   SetParameter(CameraParameters::KEY_PICTURE_FORMAT, NS_ConvertUTF16toUTF8(mFileFormat).get());
 
   // Convert 'rotation' to a positive value from 0..270 degrees, in steps of 90.
   uint32_t r = static_cast<uint32_t>(aTakePicture->mRotation);
-  r += mCameraHw->GetSensorOrientation();
+  r += mCameraHw->GetSensorOrientation(GonkCameraHardware::OFFSET_SENSOR_ORIENTATION);
   r %= 360;
   r += 45;
   r /= 90;
   r *= 90;
   DOM_CAMERA_LOGI("setting picture rotation to %d degrees (mapped from %d)\n", r, aTakePicture->mRotation);
   SetParameter(CameraParameters::KEY_ROTATION, nsPrintfCString("%u", r).get());
 
   // Add any specified positional information -- don't care if these fail.
@@ -1527,17 +1527,17 @@ nsGonkCameraControl::SetupRecording(int 
   if (aMaxFileSizeBytes == 0) {
     aMaxFileSizeBytes = -1;
   }
   snprintf(buffer, SIZE, "max-filesize=%lld", aMaxFileSizeBytes);
   CHECK_SETARG(mRecorder->setParameters(String8(buffer)));
 
   // adjust rotation by camera sensor offset
   int r = aRotation;
-  r += mCameraHw->GetSensorOrientation(GonkCameraHardware::RAW_SENSOR_ORIENTATION);
+  r += mCameraHw->GetSensorOrientation();
   r %= 360;
   r += 45;
   r /= 90;
   r *= 90;
   if (r < 0) {
     // the video recorder only supports positive rotations
     r += 360;
   }
--- a/dom/camera/GonkCameraHwMgr.cpp
+++ b/dom/camera/GonkCameraHwMgr.cpp
@@ -163,18 +163,20 @@ GonkCameraHardware::Init()
   if (rv != 0) {
     DOM_CAMERA_LOGE("%s: failed to get CameraInfo mCameraId %d\n", __func__, mCameraId);
     return;
    }
 
   mRawSensorOrientation = info.orientation;
   mSensorOrientation = mRawSensorOrientation;
 
-  // Some kernels report the wrong sensor orientation through
-  // get_camera_info()...
+  /**
+   * Non-V4L2-based camera driver adds extra offset onto picture orientation
+   * set by gecko, so we have to adjust it back.
+   */
   char propname[PROP_NAME_MAX];
   char prop[PROP_VALUE_MAX];
   int offset = 0;
   snprintf(propname, sizeof(propname), "ro.moz.cam.%d.sensor_offset", mCameraId);
   if (__system_property_get(propname, prop) > 0) {
     offset = clamped(atoi(prop), 0, 270);
     mSensorOrientation += offset;
     mSensorOrientation %= 360;
--- a/dom/camera/GonkCameraHwMgr.h
+++ b/dom/camera/GonkCameraHwMgr.h
@@ -73,17 +73,17 @@ public:
    * RAW_SENSOR_ORIENTATION is the uncorrected orientation returned directly
    * by get_camera_info(); OFFSET_SENSOR_ORIENTATION is the offset adjusted
    * orientation.
    */
   enum {
     RAW_SENSOR_ORIENTATION,
     OFFSET_SENSOR_ORIENTATION
   };
-  int      GetSensorOrientation(uint32_t aType = OFFSET_SENSOR_ORIENTATION);
+  int      GetSensorOrientation(uint32_t aType = RAW_SENSOR_ORIENTATION);
 
   int      AutoFocus();
   void     CancelAutoFocus();
   int      TakePicture();
   void     CancelTakePicture();
   int      StartPreview();
   void     StopPreview();
   int      PushParameters(const CameraParameters& aParams);