From 01a627447b22cfdd29e9b792ea72e50975d4a74a Mon Sep 17 00:00:00 2001 From: Byunghun Jeon Date: Tue, 23 Feb 2016 17:16:48 -0800 Subject: SnapdragonCamera: Camera2 link bayer mono Link bayer and mono in Camera2 dual mode CRs-Fixed: 989750 Change-Id: I16684f31d75296d4e4daa5b892e9bca06c03b5be --- src/com/android/camera/CaptureModule.java | 53 +++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) 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 BayerMonoLinkEnableKey = + new CaptureRequest.Key<>("org.codeaurora.qcamera3.dualcam_link_meta_data.enable", + Byte.class); + CaptureRequest.Key BayerMonoLinkMainKey = + new CaptureRequest.Key<>("org.codeaurora.qcamera3.dualcam_link_meta_data.is_main", + Byte.class); + CaptureRequest.Key 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 mSettings = new HashMap(); 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); -- cgit v1.2.3