diff options
author | Byunghun Jeon <bjeon@codeaurora.org> | 2016-02-23 17:16:48 -0800 |
---|---|---|
committer | Steve Kondik <steve@cyngn.com> | 2016-08-25 21:55:20 -0700 |
commit | 4d2d8724a686e893f330e1d28d3bcf4dbfd26b58 (patch) | |
tree | ab51c6cc3f2417d7c246fe9191ed14f133bc1706 | |
parent | 59906a8b182d0f30309f476a96c8c510cb59d1c5 (diff) | |
download | android_packages_apps_Snap-4d2d8724a686e893f330e1d28d3bcf4dbfd26b58.tar.gz android_packages_apps_Snap-4d2d8724a686e893f330e1d28d3bcf4dbfd26b58.tar.bz2 android_packages_apps_Snap-4d2d8724a686e893f330e1d28d3bcf4dbfd26b58.zip |
SnapdragonCamera: Camera2 link bayer mono
Link bayer and mono in Camera2 dual mode
CRs-Fixed: 989750
Change-Id: I16684f31d75296d4e4daa5b892e9bca06c03b5be
-rw-r--r-- | src/com/android/camera/CaptureModule.java | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/src/com/android/camera/CaptureModule.java b/src/com/android/camera/CaptureModule.java index 41a26c59d..52f9327e6 100644 --- a/src/com/android/camera/CaptureModule.java +++ b/src/com/android/camera/CaptureModule.java @@ -121,6 +121,15 @@ public class CaptureModule implements CameraModule, PhotoController, } MeteringRectangle[][] mAFRegions = new MeteringRectangle[MAX_NUM_CAM][]; + CaptureRequest.Key<Byte> BayerMonoLinkEnableKey = + new CaptureRequest.Key<>("org.codeaurora.qcamera3.dualcam_link_meta_data.enable", + Byte.class); + CaptureRequest.Key<Byte> BayerMonoLinkMainKey = + new CaptureRequest.Key<>("org.codeaurora.qcamera3.dualcam_link_meta_data.is_main", + Byte.class); + CaptureRequest.Key<Integer> BayerMonoLinkSessionIdKey = + new CaptureRequest.Key<>("org.codeaurora.qcamera3.dualcam_link_meta_data" + + ".related_camera_id", Integer.class); private int mLastResultAFState = -1; private Rect[] mCropRegion = new Rect[MAX_NUM_CAM]; private boolean mAutoFocusSupported; @@ -130,6 +139,7 @@ public class CaptureModule implements CameraModule, PhotoController, private Map<String, String> mSettings = new HashMap<String, String>(); private boolean mFirstTimeInitialized; private boolean mInitialized = false; + private boolean mIsLinked = false; private long mCaptureStartTime; private boolean mPaused = true; private boolean mSurfaceReady = false; @@ -524,6 +534,10 @@ public class CaptureModule implements CameraModule, PhotoController, mCaptureSession[id] = cameraCaptureSession; initializePreviewConfiguration(id); try { + if (MODE == DUAL_MODE) { + linkBayerMono(id); + mIsLinked = true; + } // Finally, we start displaying the camera preview. mCaptureSession[id].setRepeatingRequest(mPreviewRequestBuilder[id] .build(), mCaptureCallback, mCameraHandler); @@ -640,6 +654,29 @@ public class CaptureModule implements CameraModule, PhotoController, } } + public void linkBayerMono(int id) { + Log.d(TAG, "linkBayerMono " + id); + if (id == BAYER_ID) { + mPreviewRequestBuilder[id].set(BayerMonoLinkEnableKey, (byte) 1); + mPreviewRequestBuilder[id].set(BayerMonoLinkMainKey, (byte) 1); + mPreviewRequestBuilder[id].set(BayerMonoLinkSessionIdKey, MONO_ID); + } else if (id == MONO_ID) { + mPreviewRequestBuilder[id].set(BayerMonoLinkEnableKey, (byte) 1); + mPreviewRequestBuilder[id].set(BayerMonoLinkMainKey, (byte) 0); + mPreviewRequestBuilder[id].set(BayerMonoLinkSessionIdKey, BAYER_ID); + } + } + + public void unLinkBayerMono(int id) { + Log.d(TAG, "unlinkBayerMono " + id); + if (id == BAYER_ID) { + mPreviewRequestBuilder[id].set(BayerMonoLinkEnableKey, (byte) 0); + } else if (id == MONO_ID) { + mPreviewRequestBuilder[id].set(BayerMonoLinkEnableKey, (byte) 0); + } + } + + /** * Capture a still picture. This method should be called when we get a response in * {@link #mCaptureCallback} from both {@link #lockFocus()}. @@ -797,6 +834,16 @@ public class CaptureModule implements CameraModule, PhotoController, mCameraOpenCloseLock.acquire(); for (int i = 0; i < MAX_NUM_CAM; i++) { if (null != mCaptureSession[i]) { + if (mIsLinked) { + unLinkBayerMono(i); + try { + mCaptureSession[i].capture(mPreviewRequestBuilder[i].build(), null, + mCameraHandler); + } catch (CameraAccessException e) { + e.printStackTrace(); + } + } + mCaptureSession[i].close(); mCaptureSession[i] = null; } @@ -812,6 +859,12 @@ public class CaptureModule implements CameraModule, PhotoController, mCameraOpened[i] = false; } } + /* no need to set this in the callback and handle asynchronously. This is the same + reason as why we release the semaphore here, not in camera close callback function + as we don't have to protect the case where camera open() gets called during camera + close(). The low level framework/HAL handles the synchronization for open() + happens after close() */ + mIsLinked = false; } catch (InterruptedException e) { mCameraOpenCloseLock.release(); throw new RuntimeException("Interrupted while trying to lock camera closing.", e); |