CameraService: Remove device HALv2 support, other cleanup
HALv2 only ever shipped with Nexus 10, and has been fully superceded by
HALv3. Remove it to allow for various code simplifications and cleanup.
- Remove Camera2Device
- Remove various special-case codepaths for supporting Camera2Device
- Remove CameraDeviceFactory, since it only creates Camera3Devices now
- Remove BurstCapture and associated CaptureSequence/Parameters code
- Remove old ZslProcessor and simplify ZslProcessor hierarchy to be
just ZslProcessor3, which is renamed to just ZslProcessor
- Add service-init-time check for unsupported device versions
- Fix assorted compiler warnings, some old, some new
- Remove references to HALv2 when possible
Bug: 25866588
Change-Id: Ia1063264d315f9b742ec5cdd0483539310894f5e
diff --git a/services/camera/libcameraservice/api1/Camera2Client.cpp b/services/camera/libcameraservice/api1/Camera2Client.cpp
index 4338d64..175920f 100644
--- a/services/camera/libcameraservice/api1/Camera2Client.cpp
+++ b/services/camera/libcameraservice/api1/Camera2Client.cpp
@@ -32,7 +32,6 @@
#include "api1/client2/CaptureSequencer.h"
#include "api1/client2/CallbackProcessor.h"
#include "api1/client2/ZslProcessor.h"
-#include "api1/client2/ZslProcessor3.h"
#define ALOG1(...) ALOGD_IF(gLogLevel >= 1, __VA_ARGS__);
#define ALOG2(...) ALOGD_IF(gLogLevel >= 2, __VA_ARGS__);
@@ -111,30 +110,11 @@
mCameraId);
mJpegProcessor->run(threadName.string());
- switch (mDeviceVersion) {
- case CAMERA_DEVICE_API_VERSION_2_0: {
- sp<ZslProcessor> zslProc =
- new ZslProcessor(this, mCaptureSequencer);
- mZslProcessor = zslProc;
- mZslProcessorThread = zslProc;
- break;
- }
- case CAMERA_DEVICE_API_VERSION_3_0:
- case CAMERA_DEVICE_API_VERSION_3_1:
- case CAMERA_DEVICE_API_VERSION_3_2:
- case CAMERA_DEVICE_API_VERSION_3_3: {
- sp<ZslProcessor3> zslProc =
- new ZslProcessor3(this, mCaptureSequencer);
- mZslProcessor = zslProc;
- mZslProcessorThread = zslProc;
- break;
- }
- default:
- break;
- }
+ mZslProcessor = new ZslProcessor(this, mCaptureSequencer);
+
threadName = String8::format("C2-%d-ZslProc",
mCameraId);
- mZslProcessorThread->run(threadName.string());
+ mZslProcessor->run(threadName.string());
mCallbackProcessor = new CallbackProcessor(this);
threadName = String8::format("C2-%d-CallbkProc",
@@ -414,7 +394,7 @@
mFrameProcessor->requestExit();
mCaptureSequencer->requestExit();
mJpegProcessor->requestExit();
- mZslProcessorThread->requestExit();
+ mZslProcessor->requestExit();
mCallbackProcessor->requestExit();
ALOGV("Camera %d: Waiting for threads", mCameraId);
@@ -428,7 +408,7 @@
mFrameProcessor->join();
mCaptureSequencer->join();
mJpegProcessor->join();
- mZslProcessorThread->join();
+ mZslProcessor->join();
mCallbackProcessor->join();
mBinderSerializationLock.lock();
@@ -442,9 +422,6 @@
mCallbackProcessor->deleteStream();
mZslProcessor->deleteStream();
- // Remove all ZSL stream state before disconnect; needed to work around b/15408128.
- mZslProcessor->disconnect();
-
ALOGV("Camera %d: Disconnecting device", mCameraId);
mDevice->disconnect();
@@ -761,8 +738,8 @@
// We could wait to create the JPEG output stream until first actual use
// (first takePicture call). However, this would substantially increase the
- // first capture latency on HAL3 devices, and potentially on some HAL2
- // devices. So create it unconditionally at preview start. As a drawback,
+ // first capture latency on HAL3 devices.
+ // So create it unconditionally at preview start. As a drawback,
// this increases gralloc memory consumption for applications that don't
// ever take a picture. Do not enter this mode when jpeg stream will slow
// down preview.
@@ -1069,35 +1046,33 @@
}
}
- // On current HALs, clean up ZSL before transitioning into recording
- if (mDeviceVersion != CAMERA_DEVICE_API_VERSION_2_0) {
- if (mZslProcessor->getStreamId() != NO_STREAM) {
- ALOGV("%s: Camera %d: Clearing out zsl stream before "
- "creating recording stream", __FUNCTION__, mCameraId);
- res = mStreamingProcessor->stopStream();
- if (res != OK) {
- ALOGE("%s: Camera %d: Can't stop streaming to delete callback stream",
- __FUNCTION__, mCameraId);
- return res;
- }
- res = mDevice->waitUntilDrained();
- if (res != OK) {
- ALOGE("%s: Camera %d: Waiting to stop streaming failed: %s (%d)",
- __FUNCTION__, mCameraId, strerror(-res), res);
- }
- res = mZslProcessor->clearZslQueue();
- if (res != OK) {
- ALOGE("%s: Camera %d: Can't clear zsl queue",
- __FUNCTION__, mCameraId);
- return res;
- }
- res = mZslProcessor->deleteStream();
- if (res != OK) {
- ALOGE("%s: Camera %d: Unable to delete zsl stream before "
- "record: %s (%d)", __FUNCTION__, mCameraId,
- strerror(-res), res);
- return res;
- }
+ // Clean up ZSL before transitioning into recording
+ if (mZslProcessor->getStreamId() != NO_STREAM) {
+ ALOGV("%s: Camera %d: Clearing out zsl stream before "
+ "creating recording stream", __FUNCTION__, mCameraId);
+ res = mStreamingProcessor->stopStream();
+ if (res != OK) {
+ ALOGE("%s: Camera %d: Can't stop streaming to delete callback stream",
+ __FUNCTION__, mCameraId);
+ return res;
+ }
+ res = mDevice->waitUntilDrained();
+ if (res != OK) {
+ ALOGE("%s: Camera %d: Waiting to stop streaming failed: %s (%d)",
+ __FUNCTION__, mCameraId, strerror(-res), res);
+ }
+ res = mZslProcessor->clearZslQueue();
+ if (res != OK) {
+ ALOGE("%s: Camera %d: Can't clear zsl queue",
+ __FUNCTION__, mCameraId);
+ return res;
+ }
+ res = mZslProcessor->deleteStream();
+ if (res != OK) {
+ ALOGE("%s: Camera %d: Unable to delete zsl stream before "
+ "record: %s (%d)", __FUNCTION__, mCameraId,
+ strerror(-res), res);
+ return res;
}
}
@@ -1105,56 +1080,43 @@
// and we can't fail record start without stagefright asserting.
params.previewCallbackFlags = 0;
- if (mDeviceVersion != CAMERA_DEVICE_API_VERSION_2_0) {
- // For newer devices, may need to reconfigure video snapshot JPEG sizes
- // during recording startup, so need a more complex sequence here to
- // ensure an early stream reconfiguration doesn't happen
- bool recordingStreamNeedsUpdate;
- res = mStreamingProcessor->recordingStreamNeedsUpdate(params, &recordingStreamNeedsUpdate);
+ // May need to reconfigure video snapshot JPEG sizes
+ // during recording startup, so need a more complex sequence here to
+ // ensure an early stream reconfiguration doesn't happen
+ bool recordingStreamNeedsUpdate;
+ res = mStreamingProcessor->recordingStreamNeedsUpdate(params, &recordingStreamNeedsUpdate);
+ if (res != OK) {
+ ALOGE("%s: Camera %d: Can't query recording stream",
+ __FUNCTION__, mCameraId);
+ return res;
+ }
+
+ if (recordingStreamNeedsUpdate) {
+ // Need to stop stream here so updateProcessorStream won't trigger configureStream
+ // Right now camera device cannot handle configureStream failure gracefully
+ // when device is streaming
+ res = mStreamingProcessor->stopStream();
if (res != OK) {
- ALOGE("%s: Camera %d: Can't query recording stream",
- __FUNCTION__, mCameraId);
+ ALOGE("%s: Camera %d: Can't stop streaming to update record "
+ "stream", __FUNCTION__, mCameraId);
return res;
}
-
- if (recordingStreamNeedsUpdate) {
- // Need to stop stream here so updateProcessorStream won't trigger configureStream
- // Right now camera device cannot handle configureStream failure gracefully
- // when device is streaming
- res = mStreamingProcessor->stopStream();
- if (res != OK) {
- ALOGE("%s: Camera %d: Can't stop streaming to update record "
- "stream", __FUNCTION__, mCameraId);
- return res;
- }
- res = mDevice->waitUntilDrained();
- if (res != OK) {
- ALOGE("%s: Camera %d: Waiting to stop streaming failed: "
- "%s (%d)", __FUNCTION__, mCameraId,
- strerror(-res), res);
- }
-
- res = updateProcessorStream<
- StreamingProcessor,
- &StreamingProcessor::updateRecordingStream>(
- mStreamingProcessor,
- params);
- if (res != OK) {
- ALOGE("%s: Camera %d: Unable to update recording stream: "
- "%s (%d)", __FUNCTION__, mCameraId,
- strerror(-res), res);
- return res;
- }
- }
- } else {
- // Maintain call sequencing for HALv2 devices.
- res = updateProcessorStream<
- StreamingProcessor,
- &StreamingProcessor::updateRecordingStream>(mStreamingProcessor,
- params);
+ res = mDevice->waitUntilDrained();
if (res != OK) {
- ALOGE("%s: Camera %d: Unable to update recording stream: %s (%d)",
- __FUNCTION__, mCameraId, strerror(-res), res);
+ ALOGE("%s: Camera %d: Waiting to stop streaming failed: "
+ "%s (%d)", __FUNCTION__, mCameraId,
+ strerror(-res), res);
+ }
+
+ res = updateProcessorStream<
+ StreamingProcessor,
+ &StreamingProcessor::updateRecordingStream>(
+ mStreamingProcessor,
+ params);
+ if (res != OK) {
+ ALOGE("%s: Camera %d: Unable to update recording stream: "
+ "%s (%d)", __FUNCTION__, mCameraId,
+ strerror(-res), res);
return res;
}
}
diff --git a/services/camera/libcameraservice/api1/Camera2Client.h b/services/camera/libcameraservice/api1/Camera2Client.h
index d50bf63..e1e18c9 100644
--- a/services/camera/libcameraservice/api1/Camera2Client.h
+++ b/services/camera/libcameraservice/api1/Camera2Client.h
@@ -24,7 +24,7 @@
#include "api1/client2/FrameProcessor.h"
//#include "api1/client2/StreamingProcessor.h"
//#include "api1/client2/JpegProcessor.h"
-//#include "api1/client2/ZslProcessorInterface.h"
+//#include "api1/client2/ZslProcessor.h"
//#include "api1/client2/CaptureSequencer.h"
//#include "api1/client2/CallbackProcessor.h"
@@ -34,7 +34,7 @@
class StreamingProcessor;
class JpegProcessor;
-class ZslProcessorInterface;
+class ZslProcessor;
class CaptureSequencer;
class CallbackProcessor;
@@ -43,7 +43,7 @@
class IMemory;
/**
* Interface between android.hardware.Camera API and Camera HAL device for versions
- * CAMERA_DEVICE_API_VERSION_2_0 and 3_0.
+ * CAMERA_DEVICE_API_VERSION_3_0 and above.
*/
class Camera2Client :
public Camera2ClientBase<CameraService::Client>
@@ -204,12 +204,7 @@
sp<camera2::CaptureSequencer> mCaptureSequencer;
sp<camera2::JpegProcessor> mJpegProcessor;
- sp<camera2::ZslProcessorInterface> mZslProcessor;
- sp<Thread> mZslProcessorThread;
-
- /** Notification-related members */
-
- bool mAfInMotion;
+ sp<camera2::ZslProcessor> mZslProcessor;
/** Utility members */
bool mLegacyMode;
diff --git a/services/camera/libcameraservice/api1/client2/BurstCapture.cpp b/services/camera/libcameraservice/api1/client2/BurstCapture.cpp
deleted file mode 100644
index 5502dcb..0000000
--- a/services/camera/libcameraservice/api1/client2/BurstCapture.cpp
+++ /dev/null
@@ -1,113 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-//#define LOG_NDEBUG 0
-#define LOG_TAG "Camera2-BurstCapture"
-
-#include <utils/Log.h>
-#include <utils/Trace.h>
-
-#include "BurstCapture.h"
-
-#include "api1/Camera2Client.h"
-#include "api1/client2/JpegCompressor.h"
-
-namespace android {
-namespace camera2 {
-
-BurstCapture::BurstCapture(wp<Camera2Client> client, wp<CaptureSequencer> sequencer):
- mCaptureStreamId(NO_STREAM),
- mClient(client),
- mSequencer(sequencer)
-{
-}
-
-BurstCapture::~BurstCapture() {
-}
-
-status_t BurstCapture::start(Vector<CameraMetadata> &/*metadatas*/,
- int32_t /*firstCaptureId*/) {
- ALOGE("Not completely implemented");
- return INVALID_OPERATION;
-}
-
-void BurstCapture::onFrameAvailable(const BufferItem &/*item*/) {
- ALOGV("%s", __FUNCTION__);
- Mutex::Autolock l(mInputMutex);
- if(!mInputChanged) {
- mInputChanged = true;
- mInputSignal.signal();
- }
-}
-
-bool BurstCapture::threadLoop() {
- status_t res;
- {
- Mutex::Autolock l(mInputMutex);
- while(!mInputChanged) {
- res = mInputSignal.waitRelative(mInputMutex, kWaitDuration);
- if(res == TIMED_OUT) return true;
- }
- mInputChanged = false;
- }
-
- do {
- sp<Camera2Client> client = mClient.promote();
- if(client == 0) return false;
- ALOGV("%s: Calling processFrameAvailable()", __FUNCTION__);
- res = processFrameAvailable(client);
- } while(res == OK);
-
- return true;
-}
-
-CpuConsumer::LockedBuffer* BurstCapture::jpegEncode(
- CpuConsumer::LockedBuffer *imgBuffer,
- int /*quality*/)
-{
- ALOGV("%s", __FUNCTION__);
-
- CpuConsumer::LockedBuffer *imgEncoded = new CpuConsumer::LockedBuffer;
- uint8_t *data = new uint8_t[ANDROID_JPEG_MAX_SIZE];
- imgEncoded->data = data;
- imgEncoded->width = imgBuffer->width;
- imgEncoded->height = imgBuffer->height;
- imgEncoded->stride = imgBuffer->stride;
-
- Vector<CpuConsumer::LockedBuffer*> buffers;
- buffers.push_back(imgBuffer);
- buffers.push_back(imgEncoded);
-
- sp<JpegCompressor> jpeg = new JpegCompressor();
- jpeg->start(buffers, 1);
-
- bool success = jpeg->waitForDone(10 * 1e9);
- if(success) {
- return buffers[1];
- }
- else {
- ALOGE("%s: JPEG encode timed out", __FUNCTION__);
- return NULL; // TODO: maybe change function return value to status_t
- }
-}
-
-status_t BurstCapture::processFrameAvailable(sp<Camera2Client> &/*client*/) {
- ALOGE("Not implemented");
- return INVALID_OPERATION;
-}
-
-} // namespace camera2
-} // namespace android
diff --git a/services/camera/libcameraservice/api1/client2/BurstCapture.h b/services/camera/libcameraservice/api1/client2/BurstCapture.h
deleted file mode 100644
index c3b7722..0000000
--- a/services/camera/libcameraservice/api1/client2/BurstCapture.h
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef ANDROID_SERVERS_CAMERA_BURST_CAPTURE_H
-#define ANDROID_SERVERS_CAMERA_BURST_CAPTURE_H
-
-#include <camera/CameraMetadata.h>
-#include <binder/MemoryBase.h>
-#include <binder/MemoryHeapBase.h>
-#include <gui/CpuConsumer.h>
-
-#include "device2/Camera2Device.h"
-
-namespace android {
-
-class Camera2Client;
-
-namespace camera2 {
-
-class CaptureSequencer;
-
-class BurstCapture : public virtual Thread,
- public virtual CpuConsumer::FrameAvailableListener
-{
-public:
- BurstCapture(wp<Camera2Client> client, wp<CaptureSequencer> sequencer);
- virtual ~BurstCapture();
-
- virtual void onFrameAvailable(const BufferItem& item);
- virtual status_t start(Vector<CameraMetadata> &metadatas, int32_t firstCaptureId);
-
-protected:
- Mutex mInputMutex;
- bool mInputChanged;
- Condition mInputSignal;
- int mCaptureStreamId;
- wp<Camera2Client> mClient;
- wp<CaptureSequencer> mSequencer;
-
- // Should only be accessed by processing thread
- enum {
- NO_STREAM = -1
- };
-
- CpuConsumer::LockedBuffer* jpegEncode(
- CpuConsumer::LockedBuffer *imgBuffer,
- int quality);
-
- virtual status_t processFrameAvailable(sp<Camera2Client> &client);
-
-private:
- virtual bool threadLoop();
- static const nsecs_t kWaitDuration = 10000000; // 10 ms
-};
-
-} // namespace camera2
-} // namespace android
-
-#endif
diff --git a/services/camera/libcameraservice/api1/client2/CallbackProcessor.h b/services/camera/libcameraservice/api1/client2/CallbackProcessor.h
index a290536..a22442f 100644
--- a/services/camera/libcameraservice/api1/client2/CallbackProcessor.h
+++ b/services/camera/libcameraservice/api1/client2/CallbackProcessor.h
@@ -33,7 +33,7 @@
namespace camera2 {
-class Parameters;
+struct Parameters;
/***
* Still image capture output image processing
@@ -75,7 +75,6 @@
sp<CpuConsumer> mCallbackConsumer;
sp<Surface> mCallbackWindow;
sp<Camera2Heap> mCallbackHeap;
- int mCallbackHeapId;
size_t mCallbackHeapHead, mCallbackHeapFree;
virtual bool threadLoop();
diff --git a/services/camera/libcameraservice/api1/client2/CaptureSequencer.cpp b/services/camera/libcameraservice/api1/client2/CaptureSequencer.cpp
index 5f7fd74..61e1442 100644
--- a/services/camera/libcameraservice/api1/client2/CaptureSequencer.cpp
+++ b/services/camera/libcameraservice/api1/client2/CaptureSequencer.cpp
@@ -26,9 +26,8 @@
#include "api1/Camera2Client.h"
#include "api1/client2/CaptureSequencer.h"
-#include "api1/client2/BurstCapture.h"
#include "api1/client2/Parameters.h"
-#include "api1/client2/ZslProcessorInterface.h"
+#include "api1/client2/ZslProcessor.h"
namespace android {
namespace camera2 {
@@ -59,7 +58,7 @@
ALOGV("%s: Exit", __FUNCTION__);
}
-void CaptureSequencer::setZslProcessor(wp<ZslProcessorInterface> processor) {
+void CaptureSequencer::setZslProcessor(wp<ZslProcessor> processor) {
Mutex::Autolock l(mInputMutex);
mZslProcessor = processor;
}
@@ -111,6 +110,7 @@
void CaptureSequencer::notifyShutter(const CaptureResultExtras& resultExtras,
nsecs_t timestamp) {
ATRACE_CALL();
+ (void) timestamp;
Mutex::Autolock l(mInputMutex);
if (!mHalNotifiedShutter && resultExtras.requestId == mShutterCaptureId) {
mHalNotifiedShutter = true;
@@ -174,8 +174,6 @@
"STANDARD_PRECAPTURE_WAIT",
"STANDARD_CAPTURE",
"STANDARD_CAPTURE_WAIT",
- "BURST_CAPTURE_START",
- "BURST_CAPTURE_WAIT",
"DONE",
"ERROR",
"UNKNOWN"
@@ -192,8 +190,6 @@
&CaptureSequencer::manageStandardPrecaptureWait,
&CaptureSequencer::manageStandardCapture,
&CaptureSequencer::manageStandardCaptureWait,
- &CaptureSequencer::manageBurstCaptureStart,
- &CaptureSequencer::manageBurstCaptureWait,
&CaptureSequencer::manageDone,
};
@@ -293,7 +289,7 @@
}
takePictureCounter = l.mParameters.takePictureCounter;
}
- sp<ZslProcessorInterface> processor = mZslProcessor.promote();
+ sp<ZslProcessor> processor = mZslProcessor.promote();
if (processor != 0) {
ALOGV("%s: Memory optimization, clearing ZSL queue",
__FUNCTION__);
@@ -336,10 +332,6 @@
return DONE;
}
- if(l.mParameters.lightFx != Parameters::LIGHTFX_NONE &&
- l.mParameters.state == Parameters::STILL_CAPTURE) {
- nextState = BURST_CAPTURE_START;
- }
else if (l.mParameters.zslMode &&
l.mParameters.state == Parameters::STILL_CAPTURE &&
l.mParameters.flashMode != Parameters::FLASH_MODE_ON) {
@@ -361,7 +353,7 @@
sp<Camera2Client> &client) {
ALOGV("%s", __FUNCTION__);
status_t res;
- sp<ZslProcessorInterface> processor = mZslProcessor.promote();
+ sp<ZslProcessor> processor = mZslProcessor.promote();
if (processor == 0) {
ALOGE("%s: No ZSL queue to use!", __FUNCTION__);
return DONE;
@@ -664,76 +656,6 @@
return STANDARD_CAPTURE_WAIT;
}
-CaptureSequencer::CaptureState CaptureSequencer::manageBurstCaptureStart(
- sp<Camera2Client> &client) {
- ALOGV("%s", __FUNCTION__);
- status_t res;
- ATRACE_CALL();
-
- // check which burst mode is set, create respective burst object
- {
- SharedParameters::Lock l(client->getParameters());
-
- res = updateCaptureRequest(l.mParameters, client);
- if(res != OK) {
- return DONE;
- }
-
- //
- // check for burst mode type in mParameters here
- //
- mBurstCapture = new BurstCapture(client, this);
- }
-
- res = mCaptureRequest.update(ANDROID_REQUEST_ID, &mCaptureId, 1);
- if (res == OK) {
- res = mCaptureRequest.sort();
- }
- if (res != OK) {
- ALOGE("%s: Camera %d: Unable to set up still capture request: %s (%d)",
- __FUNCTION__, client->getCameraId(), strerror(-res), res);
- return DONE;
- }
-
- CameraMetadata captureCopy = mCaptureRequest;
- if (captureCopy.entryCount() == 0) {
- ALOGE("%s: Camera %d: Unable to copy capture request for HAL device",
- __FUNCTION__, client->getCameraId());
- return DONE;
- }
-
- Vector<CameraMetadata> requests;
- requests.push(mCaptureRequest);
- res = mBurstCapture->start(requests, mCaptureId);
- mTimeoutCount = kMaxTimeoutsForCaptureEnd * 10;
- return BURST_CAPTURE_WAIT;
-}
-
-CaptureSequencer::CaptureState CaptureSequencer::manageBurstCaptureWait(
- sp<Camera2Client> &/*client*/) {
- status_t res;
- ATRACE_CALL();
- while (!mNewCaptureReceived) {
- res = mNewCaptureSignal.waitRelative(mInputMutex, kWaitDuration);
- if (res == TIMED_OUT) {
- mTimeoutCount--;
- break;
- }
- }
-
- if (mTimeoutCount <= 0) {
- ALOGW("Timed out waiting for burst capture to complete");
- return DONE;
- }
- if (mNewCaptureReceived) {
- mNewCaptureReceived = false;
- // TODO: update mCaptureId to last burst's capture ID + 1?
- return DONE;
- }
-
- return BURST_CAPTURE_WAIT;
-}
-
status_t CaptureSequencer::updateCaptureRequest(const Parameters ¶ms,
sp<Camera2Client> &client) {
ATRACE_CALL();
diff --git a/services/camera/libcameraservice/api1/client2/CaptureSequencer.h b/services/camera/libcameraservice/api1/client2/CaptureSequencer.h
index 10252fb..b05207e 100644
--- a/services/camera/libcameraservice/api1/client2/CaptureSequencer.h
+++ b/services/camera/libcameraservice/api1/client2/CaptureSequencer.h
@@ -34,8 +34,7 @@
namespace camera2 {
-class ZslProcessorInterface;
-class BurstCapture;
+class ZslProcessor;
/**
* Manages the still image capture process for
@@ -49,7 +48,7 @@
~CaptureSequencer();
// Get reference to the ZslProcessor, which holds the ZSL buffers and frames
- void setZslProcessor(wp<ZslProcessorInterface> processor);
+ void setZslProcessor(wp<ZslProcessor> processor);
// Begin still image capture
status_t startCapture(int msgType);
@@ -113,8 +112,7 @@
static const int kMaxTimeoutsForCaptureEnd = 40; // 4 sec
wp<Camera2Client> mClient;
- wp<ZslProcessorInterface> mZslProcessor;
- sp<BurstCapture> mBurstCapture;
+ wp<ZslProcessor> mZslProcessor;
enum CaptureState {
IDLE,
@@ -126,8 +124,6 @@
STANDARD_PRECAPTURE_WAIT,
STANDARD_CAPTURE,
STANDARD_CAPTURE_WAIT,
- BURST_CAPTURE_START,
- BURST_CAPTURE_WAIT,
DONE,
ERROR,
NUM_CAPTURE_STATES
@@ -165,9 +161,6 @@
CaptureState manageStandardCapture(sp<Camera2Client> &client);
CaptureState manageStandardCaptureWait(sp<Camera2Client> &client);
- CaptureState manageBurstCaptureStart(sp<Camera2Client> &client);
- CaptureState manageBurstCaptureWait(sp<Camera2Client> &client);
-
CaptureState manageDone(sp<Camera2Client> &client);
// Utility methods
diff --git a/services/camera/libcameraservice/api1/client2/FrameProcessor.cpp b/services/camera/libcameraservice/api1/client2/FrameProcessor.cpp
index 40d53b3..6490682 100644
--- a/services/camera/libcameraservice/api1/client2/FrameProcessor.cpp
+++ b/services/camera/libcameraservice/api1/client2/FrameProcessor.cpp
@@ -170,7 +170,7 @@
entry = frame.find(ANDROID_SCALER_CROP_REGION);
if (entry.count < 4) {
- ALOGE("%s: Camera %d: Unable to read crop region (count = %d)",
+ ALOGE("%s: Camera %d: Unable to read crop region (count = %zu)",
__FUNCTION__, client->getCameraId(), entry.count);
return res;
}
diff --git a/services/camera/libcameraservice/api1/client2/JpegProcessor.cpp b/services/camera/libcameraservice/api1/client2/JpegProcessor.cpp
index bd9786f..3923853 100644
--- a/services/camera/libcameraservice/api1/client2/JpegProcessor.cpp
+++ b/services/camera/libcameraservice/api1/client2/JpegProcessor.cpp
@@ -108,7 +108,7 @@
return NO_MEMORY;
}
}
- ALOGV("%s: Camera %d: JPEG capture heap now %d bytes; requested %d bytes",
+ ALOGV("%s: Camera %d: JPEG capture heap now %zu bytes; requested %zd bytes",
__FUNCTION__, mId, mCaptureHeap->getSize(), maxJpegSize);
if (mCaptureStreamId != NO_STREAM) {
diff --git a/services/camera/libcameraservice/api1/client2/JpegProcessor.h b/services/camera/libcameraservice/api1/client2/JpegProcessor.h
index fbdae11..ac6f5c7 100644
--- a/services/camera/libcameraservice/api1/client2/JpegProcessor.h
+++ b/services/camera/libcameraservice/api1/client2/JpegProcessor.h
@@ -35,7 +35,7 @@
namespace camera2 {
class CaptureSequencer;
-class Parameters;
+struct Parameters;
/***
* Still image capture output image processing
diff --git a/services/camera/libcameraservice/api1/client2/Parameters.cpp b/services/camera/libcameraservice/api1/client2/Parameters.cpp
index fc5ebac..f901dda 100644
--- a/services/camera/libcameraservice/api1/client2/Parameters.cpp
+++ b/services/camera/libcameraservice/api1/client2/Parameters.cpp
@@ -913,8 +913,6 @@
ALOGI("%s: zslMode: %d slowJpegMode %d", __FUNCTION__, zslMode, slowJpegMode);
- lightFx = LIGHTFX_NONE;
-
state = STOPPED;
paramsFlattened = params.flatten();
@@ -1864,10 +1862,6 @@
ALOGE("%s: Video stabilization not supported", __FUNCTION__);
}
- // LIGHTFX
- validatedParams.lightFx = lightFxStringToEnum(
- newParams.get(CameraParameters::KEY_LIGHTFX));
-
/** Update internal parameters */
*this = validatedParams;
@@ -1959,7 +1953,7 @@
if (res != OK) return res;
// android.hardware.Camera requires that when face detect is enabled, the
- // camera is in a face-priority mode. HAL2 splits this into separate parts
+ // camera is in a face-priority mode. HAL3.x splits this into separate parts
// (face detection statistics and face priority scene mode). Map from other
// to the other.
bool sceneModeActive =
@@ -2501,18 +2495,6 @@
}
}
-Parameters::Parameters::lightFxMode_t Parameters::lightFxStringToEnum(
- const char *lightFxMode) {
- return
- !lightFxMode ?
- Parameters::LIGHTFX_NONE :
- !strcmp(lightFxMode, CameraParameters::LIGHTFX_LOWLIGHT) ?
- Parameters::LIGHTFX_LOWLIGHT :
- !strcmp(lightFxMode, CameraParameters::LIGHTFX_HDR) ?
- Parameters::LIGHTFX_HDR :
- Parameters::LIGHTFX_NONE;
-}
-
status_t Parameters::parseAreas(const char *areasCStr,
Vector<Parameters::Area> *areas) {
static const size_t NUM_FIELDS = 5;
diff --git a/services/camera/libcameraservice/api1/client2/Parameters.h b/services/camera/libcameraservice/api1/client2/Parameters.h
index 972d007..c5bbf63 100644
--- a/services/camera/libcameraservice/api1/client2/Parameters.h
+++ b/services/camera/libcameraservice/api1/client2/Parameters.h
@@ -136,12 +136,6 @@
bool recordingHint;
bool videoStabilization;
- enum lightFxMode_t {
- LIGHTFX_NONE = 0,
- LIGHTFX_LOWLIGHT,
- LIGHTFX_HDR
- } lightFx;
-
CameraParameters2 params;
String8 paramsFlattened;
@@ -307,7 +301,6 @@
static const char* flashModeEnumToString(flashMode_t flashMode);
static focusMode_t focusModeStringToEnum(const char *focusMode);
static const char* focusModeEnumToString(focusMode_t focusMode);
- static lightFxMode_t lightFxStringToEnum(const char *lightFxMode);
static status_t parseAreas(const char *areasCStr,
Vector<Area> *areas);
@@ -330,7 +323,7 @@
static const int kFpsToApiScale = 1000;
// Transform from (-1000,-1000)-(1000,1000) normalized coords from camera
- // API to HAL2 (0,0)-(activePixelArray.width/height) coordinates
+ // API to HAL3 (0,0)-(activePixelArray.width/height) coordinates
int normalizedXToArray(int x) const;
int normalizedYToArray(int y) const;
@@ -350,7 +343,7 @@
private:
// Convert from viewfinder crop-region relative array coordinates
- // to HAL2 sensor array coordinates
+ // to HAL3 sensor array coordinates
int cropXToArray(int x) const;
int cropYToArray(int y) const;
diff --git a/services/camera/libcameraservice/api1/client2/StreamingProcessor.h b/services/camera/libcameraservice/api1/client2/StreamingProcessor.h
index e0cad3a..0b17eae 100644
--- a/services/camera/libcameraservice/api1/client2/StreamingProcessor.h
+++ b/services/camera/libcameraservice/api1/client2/StreamingProcessor.h
@@ -31,7 +31,7 @@
namespace camera2 {
-class Parameters;
+struct Parameters;
class Camera2Heap;
/**
diff --git a/services/camera/libcameraservice/api1/client2/ZslProcessor.cpp b/services/camera/libcameraservice/api1/client2/ZslProcessor.cpp
index 0b79b31..b127472 100644
--- a/services/camera/libcameraservice/api1/client2/ZslProcessor.cpp
+++ b/services/camera/libcameraservice/api1/client2/ZslProcessor.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2012 The Android Open Source Project
+ * Copyright (C) 2013 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -22,7 +22,7 @@
#ifdef LOG_NNDEBUG
#define ALOGVV(...) ALOGV(__VA_ARGS__)
#else
-#define ALOGVV(...) ((void)0)
+#define ALOGVV(...) if (0) ALOGV(__VA_ARGS__)
#endif
#include <inttypes.h>
@@ -35,6 +35,7 @@
#include "api1/Camera2Client.h"
#include "api1/client2/CaptureSequencer.h"
#include "api1/client2/ZslProcessor.h"
+#include "device3/Camera3Device.h"
namespace android {
namespace camera2 {
@@ -43,35 +44,55 @@
sp<Camera2Client> client,
wp<CaptureSequencer> sequencer):
Thread(false),
+ mLatestClearedBufferTimestamp(0),
mState(RUNNING),
mClient(client),
- mDevice(client->getCameraDevice()),
mSequencer(sequencer),
mId(client->getCameraId()),
- mDeleted(false),
- mZslBufferAvailable(false),
mZslStreamId(NO_STREAM),
- mZslReprocessStreamId(NO_STREAM),
mFrameListHead(0),
- mZslQueueHead(0),
- mZslQueueTail(0) {
- mZslQueue.insertAt(0, kZslBufferDepth);
- mFrameList.insertAt(0, kFrameListDepth);
+ mHasFocuser(false) {
+ // Initialize buffer queue and frame list based on pipeline max depth.
+ size_t pipelineMaxDepth = kDefaultMaxPipelineDepth;
+ if (client != 0) {
+ sp<Camera3Device> device =
+ static_cast<Camera3Device*>(client->getCameraDevice().get());
+ if (device != 0) {
+ camera_metadata_ro_entry_t entry =
+ device->info().find(ANDROID_REQUEST_PIPELINE_MAX_DEPTH);
+ if (entry.count == 1) {
+ pipelineMaxDepth = entry.data.u8[0];
+ } else {
+ ALOGW("%s: Unable to find the android.request.pipelineMaxDepth,"
+ " use default pipeline max depth %d", __FUNCTION__,
+ kDefaultMaxPipelineDepth);
+ }
+
+ entry = device->info().find(ANDROID_LENS_INFO_MINIMUM_FOCUS_DISTANCE);
+ if (entry.count > 0 && entry.data.f[0] != 0.) {
+ mHasFocuser = true;
+ }
+ }
+ }
+
+ ALOGV("%s: Initialize buffer queue and frame list depth based on max pipeline depth (%zu)",
+ __FUNCTION__, pipelineMaxDepth);
+ // Need to keep buffer queue longer than metadata queue because sometimes buffer arrives
+ // earlier than metadata which causes the buffer corresponding to oldest metadata being
+ // removed.
+ mFrameListDepth = pipelineMaxDepth;
+ mBufferQueueDepth = mFrameListDepth + 1;
+
+
+ mZslQueue.insertAt(0, mBufferQueueDepth);
+ mFrameList.insertAt(0, mFrameListDepth);
sp<CaptureSequencer> captureSequencer = mSequencer.promote();
if (captureSequencer != 0) captureSequencer->setZslProcessor(this);
}
ZslProcessor::~ZslProcessor() {
ALOGV("%s: Exit", __FUNCTION__);
- disconnect();
-}
-
-void ZslProcessor::onFrameAvailable(const BufferItem& /*item*/) {
- Mutex::Autolock l(mInputMutex);
- if (!mZslBufferAvailable) {
- mZslBufferAvailable = true;
- mZslBufferAvailableSignal.signal();
- }
+ deleteStream();
}
void ZslProcessor::onResultAvailable(const CaptureResult &result) {
@@ -81,35 +102,27 @@
camera_metadata_ro_entry_t entry;
entry = result.mMetadata.find(ANDROID_SENSOR_TIMESTAMP);
nsecs_t timestamp = entry.data.i64[0];
- (void)timestamp;
- ALOGVV("Got preview frame for timestamp %" PRId64, timestamp);
+ if (entry.count == 0) {
+ ALOGE("%s: metadata doesn't have timestamp, skip this result", __FUNCTION__);
+ return;
+ }
+
+ entry = result.mMetadata.find(ANDROID_REQUEST_FRAME_COUNT);
+ if (entry.count == 0) {
+ ALOGE("%s: metadata doesn't have frame number, skip this result", __FUNCTION__);
+ return;
+ }
+ int32_t frameNumber = entry.data.i32[0];
+
+ ALOGVV("Got preview metadata for frame %d with timestamp %" PRId64, frameNumber, timestamp);
if (mState != RUNNING) return;
+ // Corresponding buffer has been cleared. No need to push into mFrameList
+ if (timestamp <= mLatestClearedBufferTimestamp) return;
+
mFrameList.editItemAt(mFrameListHead) = result.mMetadata;
- mFrameListHead = (mFrameListHead + 1) % kFrameListDepth;
-
- findMatchesLocked();
-}
-
-void ZslProcessor::onBufferReleased(buffer_handle_t *handle) {
- Mutex::Autolock l(mInputMutex);
-
- // Verify that the buffer is in our queue
- size_t i = 0;
- for (; i < mZslQueue.size(); i++) {
- if (&(mZslQueue[i].buffer.mGraphicBuffer->handle) == handle) break;
- }
- if (i == mZslQueue.size()) {
- ALOGW("%s: Released buffer %p not found in queue",
- __FUNCTION__, handle);
- }
-
- // Erase entire ZSL queue since we've now completed the capture and preview
- // is stopped.
- clearZslQueueLocked();
-
- mState = RUNNING;
+ mFrameListHead = (mFrameListHead + 1) % mFrameListDepth;
}
status_t ZslProcessor::updateStream(const Parameters ¶ms) {
@@ -124,25 +137,13 @@
ALOGE("%s: Camera %d: Client does not exist", __FUNCTION__, mId);
return INVALID_OPERATION;
}
- sp<CameraDeviceBase> device = mDevice.promote();
+ sp<Camera3Device> device =
+ static_cast<Camera3Device*>(client->getCameraDevice().get());
if (device == 0) {
ALOGE("%s: Camera %d: Device does not exist", __FUNCTION__, mId);
return INVALID_OPERATION;
}
- if (mZslConsumer == 0) {
- // Create CPU buffer queue endpoint
- sp<IGraphicBufferProducer> producer;
- sp<IGraphicBufferConsumer> consumer;
- BufferQueue::createBufferQueue(&producer, &consumer);
- mZslConsumer = new BufferItemConsumer(consumer,
- GRALLOC_USAGE_HW_CAMERA_ZSL,
- kZslBufferDepth);
- mZslConsumer->setFrameAvailableListener(this);
- mZslConsumer->setName(String8("Camera2-ZslConsumer"));
- mZslWindow = new Surface(producer);
- }
-
if (mZslStreamId != NO_STREAM) {
// Check if stream parameters have to change
uint32_t currentWidth, currentHeight;
@@ -151,57 +152,50 @@
if (res != OK) {
ALOGE("%s: Camera %d: Error querying capture output stream info: "
"%s (%d)", __FUNCTION__,
- mId, strerror(-res), res);
+ client->getCameraId(), strerror(-res), res);
return res;
}
if (currentWidth != (uint32_t)params.fastInfo.arrayWidth ||
currentHeight != (uint32_t)params.fastInfo.arrayHeight) {
- res = device->deleteReprocessStream(mZslReprocessStreamId);
- if (res != OK) {
- ALOGE("%s: Camera %d: Unable to delete old reprocess stream "
- "for ZSL: %s (%d)", __FUNCTION__,
- mId, strerror(-res), res);
- return res;
- }
- ALOGV("%s: Camera %d: Deleting stream %d since the buffer dimensions changed",
- __FUNCTION__, mId, mZslStreamId);
+ ALOGV("%s: Camera %d: Deleting stream %d since the buffer "
+ "dimensions changed",
+ __FUNCTION__, client->getCameraId(), mZslStreamId);
res = device->deleteStream(mZslStreamId);
- if (res != OK) {
+ if (res == -EBUSY) {
+ ALOGV("%s: Camera %d: Device is busy, call updateStream again "
+ " after it becomes idle", __FUNCTION__, mId);
+ return res;
+ } else if(res != OK) {
ALOGE("%s: Camera %d: Unable to delete old output stream "
"for ZSL: %s (%d)", __FUNCTION__,
- mId, strerror(-res), res);
+ client->getCameraId(), strerror(-res), res);
return res;
}
mZslStreamId = NO_STREAM;
}
}
- mDeleted = false;
-
if (mZslStreamId == NO_STREAM) {
// Create stream for HAL production
// TODO: Sort out better way to select resolution for ZSL
- int streamType = params.quirks.useZslFormat ?
- (int)CAMERA2_HAL_PIXEL_FORMAT_ZSL :
- (int)HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED;
- res = device->createStream(mZslWindow,
- params.fastInfo.arrayWidth, params.fastInfo.arrayHeight, streamType,
- HAL_DATASPACE_UNKNOWN, CAMERA3_STREAM_ROTATION_0, &mZslStreamId);
+
+ // Note that format specified internally in Camera3ZslStream
+ res = device->createZslStream(
+ params.fastInfo.arrayWidth, params.fastInfo.arrayHeight,
+ mBufferQueueDepth,
+ &mZslStreamId,
+ &mZslStream);
if (res != OK) {
- ALOGE("%s: Camera %d: Can't create output stream for ZSL: "
- "%s (%d)", __FUNCTION__, mId,
+ ALOGE("%s: Camera %d: Can't create ZSL stream: "
+ "%s (%d)", __FUNCTION__, client->getCameraId(),
strerror(-res), res);
return res;
}
- res = device->createReprocessStreamFromStream(mZslStreamId,
- &mZslReprocessStreamId);
- if (res != OK) {
- ALOGE("%s: Camera %d: Can't create reprocess stream for ZSL: "
- "%s (%d)", __FUNCTION__, mId,
- strerror(-res), res);
- return res;
- }
+
+ // Only add the camera3 buffer listener when the stream is created.
+ mZslStream->addBufferListener(this);
}
+
client->registerFrameListener(Camera2Client::kPreviewRequestIdStart,
Camera2Client::kPreviewRequestIdEnd,
this,
@@ -212,47 +206,32 @@
status_t ZslProcessor::deleteStream() {
ATRACE_CALL();
- Mutex::Autolock l(mInputMutex);
- // WAR(b/15408128): do not delete stream unless client is being disconnected.
- mDeleted = true;
- return OK;
-}
-
-status_t ZslProcessor::disconnect() {
- ATRACE_CALL();
status_t res;
Mutex::Autolock l(mInputMutex);
if (mZslStreamId != NO_STREAM) {
- sp<CameraDeviceBase> device = mDevice.promote();
+ sp<Camera2Client> client = mClient.promote();
+ if (client == 0) {
+ ALOGE("%s: Camera %d: Client does not exist", __FUNCTION__, mId);
+ return INVALID_OPERATION;
+ }
+
+ sp<Camera3Device> device =
+ reinterpret_cast<Camera3Device*>(client->getCameraDevice().get());
if (device == 0) {
ALOGE("%s: Camera %d: Device does not exist", __FUNCTION__, mId);
return INVALID_OPERATION;
}
- clearZslQueueLocked();
-
- res = device->deleteReprocessStream(mZslReprocessStreamId);
- if (res != OK) {
- ALOGE("%s: Camera %d: Cannot delete ZSL reprocessing stream %d: "
- "%s (%d)", __FUNCTION__, mId,
- mZslReprocessStreamId, strerror(-res), res);
- return res;
- }
-
- mZslReprocessStreamId = NO_STREAM;
res = device->deleteStream(mZslStreamId);
if (res != OK) {
ALOGE("%s: Camera %d: Cannot delete ZSL output stream %d: "
- "%s (%d)", __FUNCTION__, mId,
+ "%s (%d)", __FUNCTION__, client->getCameraId(),
mZslStreamId, strerror(-res), res);
return res;
}
- mZslWindow.clear();
- mZslConsumer.clear();
-
mZslStreamId = NO_STREAM;
}
return OK;
@@ -263,6 +242,46 @@
return mZslStreamId;
}
+status_t ZslProcessor::updateRequestWithDefaultStillRequest(CameraMetadata &request) const {
+ sp<Camera2Client> client = mClient.promote();
+ if (client == 0) {
+ ALOGE("%s: Camera %d: Client does not exist", __FUNCTION__, mId);
+ return INVALID_OPERATION;
+ }
+ sp<Camera3Device> device =
+ static_cast<Camera3Device*>(client->getCameraDevice().get());
+ if (device == 0) {
+ ALOGE("%s: Camera %d: Device does not exist", __FUNCTION__, mId);
+ return INVALID_OPERATION;
+ }
+
+ CameraMetadata stillTemplate;
+ device->createDefaultRequest(CAMERA3_TEMPLATE_STILL_CAPTURE, &stillTemplate);
+
+ // Find some of the post-processing tags, and assign the value from template to the request.
+ // Only check the aberration mode and noise reduction mode for now, as they are very important
+ // for image quality.
+ uint32_t postProcessingTags[] = {
+ ANDROID_NOISE_REDUCTION_MODE,
+ ANDROID_COLOR_CORRECTION_ABERRATION_MODE,
+ ANDROID_COLOR_CORRECTION_MODE,
+ ANDROID_TONEMAP_MODE,
+ ANDROID_SHADING_MODE,
+ ANDROID_HOT_PIXEL_MODE,
+ ANDROID_EDGE_MODE
+ };
+
+ camera_metadata_entry_t entry;
+ for (size_t i = 0; i < sizeof(postProcessingTags) / sizeof(uint32_t); i++) {
+ entry = stillTemplate.find(postProcessingTags[i]);
+ if (entry.count > 0) {
+ request.update(postProcessingTags[i], entry.data.u8, 1);
+ }
+ }
+
+ return OK;
+}
+
status_t ZslProcessor::pushToReprocess(int32_t requestId) {
ALOGV("%s: Send in reprocess request with id %d",
__FUNCTION__, requestId);
@@ -279,21 +298,30 @@
dumpZslQueue(-1);
}
- if (mZslQueueTail != mZslQueueHead) {
- CameraMetadata request;
- size_t index = mZslQueueTail;
- while (index != mZslQueueHead) {
- if (!mZslQueue[index].frame.isEmpty()) {
- request = mZslQueue[index].frame;
- break;
- }
- index = (index + 1) % kZslBufferDepth;
- }
- if (index == mZslQueueHead) {
- ALOGV("%s: ZSL queue has no valid frames to send yet.",
- __FUNCTION__);
- return NOT_ENOUGH_DATA;
- }
+ size_t metadataIdx;
+ nsecs_t candidateTimestamp = getCandidateTimestampLocked(&metadataIdx);
+
+ if (candidateTimestamp == -1) {
+ ALOGE("%s: Could not find good candidate for ZSL reprocessing",
+ __FUNCTION__);
+ return NOT_ENOUGH_DATA;
+ }
+
+ res = mZslStream->enqueueInputBufferByTimestamp(candidateTimestamp,
+ /*actualTimestamp*/NULL);
+
+ if (res == mZslStream->NO_BUFFER_AVAILABLE) {
+ ALOGV("%s: No ZSL buffers yet", __FUNCTION__);
+ return NOT_ENOUGH_DATA;
+ } else if (res != OK) {
+ ALOGE("%s: Unable to push buffer for reprocessing: %s (%d)",
+ __FUNCTION__, strerror(-res), res);
+ return res;
+ }
+
+ {
+ CameraMetadata request = mFrameList[metadataIdx];
+
// Verify that the frame is reasonable for reprocessing
camera_metadata_entry_t entry;
@@ -310,25 +338,51 @@
return NOT_ENOUGH_DATA;
}
- buffer_handle_t *handle =
- &(mZslQueue[index].buffer.mGraphicBuffer->handle);
-
uint8_t requestType = ANDROID_REQUEST_TYPE_REPROCESS;
res = request.update(ANDROID_REQUEST_TYPE,
&requestType, 1);
+ if (res != OK) {
+ ALOGE("%s: Unable to update request type",
+ __FUNCTION__);
+ return INVALID_OPERATION;
+ }
+
int32_t inputStreams[1] =
- { mZslReprocessStreamId };
- if (res == OK) request.update(ANDROID_REQUEST_INPUT_STREAMS,
+ { mZslStreamId };
+ res = request.update(ANDROID_REQUEST_INPUT_STREAMS,
inputStreams, 1);
+ if (res != OK) {
+ ALOGE("%s: Unable to update request input streams",
+ __FUNCTION__);
+ return INVALID_OPERATION;
+ }
+
+ uint8_t captureIntent =
+ static_cast<uint8_t>(ANDROID_CONTROL_CAPTURE_INTENT_STILL_CAPTURE);
+ res = request.update(ANDROID_CONTROL_CAPTURE_INTENT,
+ &captureIntent, 1);
+ if (res != OK ) {
+ ALOGE("%s: Unable to update request capture intent",
+ __FUNCTION__);
+ return INVALID_OPERATION;
+ }
+
+ // TODO: Shouldn't we also update the latest preview frame?
int32_t outputStreams[1] =
{ client->getCaptureStreamId() };
- if (res == OK) request.update(ANDROID_REQUEST_OUTPUT_STREAMS,
+ res = request.update(ANDROID_REQUEST_OUTPUT_STREAMS,
outputStreams, 1);
+ if (res != OK) {
+ ALOGE("%s: Unable to update request output streams",
+ __FUNCTION__);
+ return INVALID_OPERATION;
+ }
+
res = request.update(ANDROID_REQUEST_ID,
&requestId, 1);
-
if (res != OK ) {
- ALOGE("%s: Unable to update frame to a reprocess request", __FUNCTION__);
+ ALOGE("%s: Unable to update frame to a reprocess request",
+ __FUNCTION__);
return INVALID_OPERATION;
}
@@ -336,17 +390,9 @@
if (res != OK) {
ALOGE("%s: Camera %d: Unable to stop preview for ZSL capture: "
"%s (%d)",
- __FUNCTION__, mId, strerror(-res), res);
+ __FUNCTION__, client->getCameraId(), strerror(-res), res);
return INVALID_OPERATION;
}
- // TODO: have push-and-clear be atomic
- res = client->getCameraDevice()->pushReprocessBuffer(mZslReprocessStreamId,
- handle, this);
- if (res != OK) {
- ALOGE("%s: Unable to push buffer for reprocessing: %s (%d)",
- __FUNCTION__, strerror(-res), res);
- return res;
- }
// Update JPEG settings
{
@@ -355,25 +401,30 @@
if (res != OK) {
ALOGE("%s: Camera %d: Unable to update JPEG entries of ZSL "
"capture request: %s (%d)", __FUNCTION__,
- mId,
+ client->getCameraId(),
strerror(-res), res);
return res;
}
}
+ // Update post-processing settings
+ res = updateRequestWithDefaultStillRequest(request);
+ if (res != OK) {
+ ALOGW("%s: Unable to update post-processing tags, the reprocessed image quality "
+ "may be compromised", __FUNCTION__);
+ }
+
mLatestCapturedRequest = request;
res = client->getCameraDevice()->capture(request);
if (res != OK ) {
- ALOGE("%s: Unable to send ZSL reprocess request to capture: %s (%d)",
- __FUNCTION__, strerror(-res), res);
+ ALOGE("%s: Unable to send ZSL reprocess request to capture: %s"
+ " (%d)", __FUNCTION__, strerror(-res), res);
return res;
}
mState = LOCKED;
- } else {
- ALOGV("%s: No ZSL buffers yet", __FUNCTION__);
- return NOT_ENOUGH_DATA;
}
+
return OK;
}
@@ -386,17 +437,20 @@
}
status_t ZslProcessor::clearZslQueueLocked() {
- for (size_t i = 0; i < mZslQueue.size(); i++) {
- if (mZslQueue[i].buffer.mTimestamp != 0) {
- mZslConsumer->releaseBuffer(mZslQueue[i].buffer);
- }
- mZslQueue.replaceAt(i);
+ if (mZslStream != 0) {
+ // clear result metadata list first.
+ clearZslResultQueueLocked();
+ return mZslStream->clearInputRingBuffer(&mLatestClearedBufferTimestamp);
}
- mZslQueueHead = 0;
- mZslQueueTail = 0;
return OK;
}
+void ZslProcessor::clearZslResultQueueLocked() {
+ mFrameList.clear();
+ mFrameListHead = 0;
+ mFrameList.insertAt(0, mFrameListDepth);
+}
+
void ZslProcessor::dump(int fd, const Vector<String16>& /*args*/) const {
Mutex::Autolock l(mInputMutex);
if (!mLatestCapturedRequest.isEmpty()) {
@@ -411,128 +465,9 @@
}
bool ZslProcessor::threadLoop() {
- status_t res;
-
- {
- Mutex::Autolock l(mInputMutex);
- while (!mZslBufferAvailable) {
- res = mZslBufferAvailableSignal.waitRelative(mInputMutex,
- kWaitDuration);
- if (res == TIMED_OUT) return true;
- }
- mZslBufferAvailable = false;
- }
-
- do {
- res = processNewZslBuffer();
- } while (res == OK);
-
- return true;
-}
-
-status_t ZslProcessor::processNewZslBuffer() {
- ATRACE_CALL();
- status_t res;
- sp<BufferItemConsumer> zslConsumer;
- {
- Mutex::Autolock l(mInputMutex);
- if (mZslConsumer == 0) return OK;
- zslConsumer = mZslConsumer;
- }
- ALOGVV("Trying to get next buffer");
- BufferItem item;
- res = zslConsumer->acquireBuffer(&item, 0);
- if (res != OK) {
- if (res != BufferItemConsumer::NO_BUFFER_AVAILABLE) {
- ALOGE("%s: Camera %d: Error receiving ZSL image buffer: "
- "%s (%d)", __FUNCTION__,
- mId, strerror(-res), res);
- } else {
- ALOGVV(" No buffer");
- }
- return res;
- }
-
- Mutex::Autolock l(mInputMutex);
-
- if (mState == LOCKED) {
- ALOGVV("In capture, discarding new ZSL buffers");
- zslConsumer->releaseBuffer(item);
- return OK;
- }
-
- ALOGVV("Got ZSL buffer: head: %d, tail: %d", mZslQueueHead, mZslQueueTail);
-
- if ( (mZslQueueHead + 1) % kZslBufferDepth == mZslQueueTail) {
- ALOGVV("Releasing oldest buffer");
- zslConsumer->releaseBuffer(mZslQueue[mZslQueueTail].buffer);
- mZslQueue.replaceAt(mZslQueueTail);
- mZslQueueTail = (mZslQueueTail + 1) % kZslBufferDepth;
- }
-
- ZslPair &queueHead = mZslQueue.editItemAt(mZslQueueHead);
-
- queueHead.buffer = item;
- queueHead.frame.release();
-
- mZslQueueHead = (mZslQueueHead + 1) % kZslBufferDepth;
-
- ALOGVV(" Acquired buffer, timestamp %" PRId64, queueHead.buffer.mTimestamp);
-
- findMatchesLocked();
-
- return OK;
-}
-
-void ZslProcessor::findMatchesLocked() {
- ALOGVV("Scanning");
- for (size_t i = 0; i < mZslQueue.size(); i++) {
- ZslPair &queueEntry = mZslQueue.editItemAt(i);
- nsecs_t bufferTimestamp = queueEntry.buffer.mTimestamp;
- IF_ALOGV() {
- camera_metadata_entry_t entry;
- nsecs_t frameTimestamp = 0;
- if (!queueEntry.frame.isEmpty()) {
- entry = queueEntry.frame.find(ANDROID_SENSOR_TIMESTAMP);
- frameTimestamp = entry.data.i64[0];
- }
- ALOGVV(" %d: b: %" PRId64 "\tf: %" PRId64, i,
- bufferTimestamp, frameTimestamp );
- }
- if (queueEntry.frame.isEmpty() && bufferTimestamp != 0) {
- // Have buffer, no matching frame. Look for one
- for (size_t j = 0; j < mFrameList.size(); j++) {
- bool match = false;
- CameraMetadata &frame = mFrameList.editItemAt(j);
- if (!frame.isEmpty()) {
- camera_metadata_entry_t entry;
- entry = frame.find(ANDROID_SENSOR_TIMESTAMP);
- if (entry.count == 0) {
- ALOGE("%s: Can't find timestamp in frame!",
- __FUNCTION__);
- continue;
- }
- nsecs_t frameTimestamp = entry.data.i64[0];
- if (bufferTimestamp == frameTimestamp) {
- ALOGVV("%s: Found match %" PRId64, __FUNCTION__,
- frameTimestamp);
- match = true;
- } else {
- int64_t delta = abs(bufferTimestamp - frameTimestamp);
- if ( delta < 1000000) {
- ALOGVV("%s: Found close match %" PRId64 " (delta %" PRId64 ")",
- __FUNCTION__, bufferTimestamp, delta);
- match = true;
- }
- }
- }
- if (match) {
- queueEntry.frame.acquire(frame);
- break;
- }
- }
- }
- }
+ // TODO: remove dependency on thread. For now, shut thread down right
+ // away.
+ return false;
}
void ZslProcessor::dumpZslQueue(int fd) const {
@@ -567,5 +502,174 @@
}
}
+bool ZslProcessor::isFixedFocusMode(uint8_t afMode) const {
+ switch (afMode) {
+ case ANDROID_CONTROL_AF_MODE_AUTO:
+ case ANDROID_CONTROL_AF_MODE_CONTINUOUS_VIDEO:
+ case ANDROID_CONTROL_AF_MODE_CONTINUOUS_PICTURE:
+ case ANDROID_CONTROL_AF_MODE_MACRO:
+ return false;
+ break;
+ case ANDROID_CONTROL_AF_MODE_OFF:
+ case ANDROID_CONTROL_AF_MODE_EDOF:
+ return true;
+ default:
+ ALOGE("%s: unknown focus mode %d", __FUNCTION__, afMode);
+ return false;
+ }
+}
+
+nsecs_t ZslProcessor::getCandidateTimestampLocked(size_t* metadataIdx) const {
+ /**
+ * Find the smallest timestamp we know about so far
+ * - ensure that aeState is either converged or locked
+ */
+
+ size_t idx = 0;
+ nsecs_t minTimestamp = -1;
+
+ size_t emptyCount = mFrameList.size();
+
+ for (size_t j = 0; j < mFrameList.size(); j++) {
+ const CameraMetadata &frame = mFrameList[j];
+ if (!frame.isEmpty()) {
+
+ emptyCount--;
+
+ camera_metadata_ro_entry_t entry;
+ entry = frame.find(ANDROID_SENSOR_TIMESTAMP);
+ if (entry.count == 0) {
+ ALOGE("%s: Can't find timestamp in frame!",
+ __FUNCTION__);
+ continue;
+ }
+ nsecs_t frameTimestamp = entry.data.i64[0];
+ if (minTimestamp > frameTimestamp || minTimestamp == -1) {
+
+ entry = frame.find(ANDROID_CONTROL_AE_STATE);
+
+ if (entry.count == 0) {
+ /**
+ * This is most likely a HAL bug. The aeState field is
+ * mandatory, so it should always be in a metadata packet.
+ */
+ ALOGW("%s: ZSL queue frame has no AE state field!",
+ __FUNCTION__);
+ continue;
+ }
+ if (entry.data.u8[0] != ANDROID_CONTROL_AE_STATE_CONVERGED &&
+ entry.data.u8[0] != ANDROID_CONTROL_AE_STATE_LOCKED) {
+ ALOGVV("%s: ZSL queue frame AE state is %d, need "
+ "full capture", __FUNCTION__, entry.data.u8[0]);
+ continue;
+ }
+
+ entry = frame.find(ANDROID_CONTROL_AF_MODE);
+ if (entry.count == 0) {
+ ALOGW("%s: ZSL queue frame has no AF mode field!",
+ __FUNCTION__);
+ continue;
+ }
+ uint8_t afMode = entry.data.u8[0];
+ if (afMode == ANDROID_CONTROL_AF_MODE_OFF) {
+ // Skip all the ZSL buffer for manual AF mode, as we don't really
+ // know the af state.
+ continue;
+ }
+
+ // Check AF state if device has focuser and focus mode isn't fixed
+ if (mHasFocuser && !isFixedFocusMode(afMode)) {
+ // Make sure the candidate frame has good focus.
+ entry = frame.find(ANDROID_CONTROL_AF_STATE);
+ if (entry.count == 0) {
+ ALOGW("%s: ZSL queue frame has no AF state field!",
+ __FUNCTION__);
+ continue;
+ }
+ uint8_t afState = entry.data.u8[0];
+ if (afState != ANDROID_CONTROL_AF_STATE_PASSIVE_FOCUSED &&
+ afState != ANDROID_CONTROL_AF_STATE_FOCUSED_LOCKED &&
+ afState != ANDROID_CONTROL_AF_STATE_NOT_FOCUSED_LOCKED) {
+ ALOGVV("%s: ZSL queue frame AF state is %d is not good for capture, skip it",
+ __FUNCTION__, afState);
+ continue;
+ }
+ }
+
+ minTimestamp = frameTimestamp;
+ idx = j;
+ }
+
+ ALOGVV("%s: Saw timestamp %" PRId64, __FUNCTION__, frameTimestamp);
+ }
+ }
+
+ if (emptyCount == mFrameList.size()) {
+ /**
+ * This could be mildly bad and means our ZSL was triggered before
+ * there were any frames yet received by the camera framework.
+ *
+ * This is a fairly corner case which can happen under:
+ * + a user presses the shutter button real fast when the camera starts
+ * (startPreview followed immediately by takePicture).
+ * + burst capture case (hitting shutter button as fast possible)
+ *
+ * If this happens in steady case (preview running for a while, call
+ * a single takePicture) then this might be a fwk bug.
+ */
+ ALOGW("%s: ZSL queue has no metadata frames", __FUNCTION__);
+ }
+
+ ALOGV("%s: Candidate timestamp %" PRId64 " (idx %zu), empty frames: %zu",
+ __FUNCTION__, minTimestamp, idx, emptyCount);
+
+ if (metadataIdx) {
+ *metadataIdx = idx;
+ }
+
+ return minTimestamp;
+}
+
+void ZslProcessor::onBufferAcquired(const BufferInfo& /*bufferInfo*/) {
+ // Intentionally left empty
+ // Although theoretically we could use this to get better dump info
+}
+
+void ZslProcessor::onBufferReleased(const BufferInfo& bufferInfo) {
+
+ // ignore output buffers
+ if (bufferInfo.mOutput) {
+ return;
+ }
+
+ // Lock mutex only once we know this is an input buffer returned to avoid
+ // potential deadlock
+ Mutex::Autolock l(mInputMutex);
+ // TODO: Verify that the buffer is in our queue by looking at timestamp
+ // theoretically unnecessary unless we change the following assumptions:
+ // -- only 1 buffer reprocessed at a time (which is the case now)
+
+ // Erase entire ZSL queue since we've now completed the capture and preview
+ // is stopped.
+ //
+ // We need to guarantee that if we do two back-to-back captures,
+ // the second won't use a buffer that's older/the same as the first, which
+ // is theoretically possible if we don't clear out the queue and the
+ // selection criteria is something like 'newest'. Clearing out the result
+ // metadata queue on a completed capture ensures we'll only use new timestamp.
+ // Calling clearZslQueueLocked is a guaranteed deadlock because this callback
+ // holds the Camera3Stream internal lock (mLock), and clearZslQueueLocked requires
+ // to hold the same lock.
+ // TODO: need figure out a way to clear the Zsl buffer queue properly. Right now
+ // it is safe not to do so, as back to back ZSL capture requires stop and start
+ // preview, which will flush ZSL queue automatically.
+ ALOGV("%s: Memory optimization, clearing ZSL queue",
+ __FUNCTION__);
+ clearZslResultQueueLocked();
+
+ // Required so we accept more ZSL requests
+ mState = RUNNING;
+}
+
}; // namespace camera2
}; // namespace android
diff --git a/services/camera/libcameraservice/api1/client2/ZslProcessor.h b/services/camera/libcameraservice/api1/client2/ZslProcessor.h
index 5870bd3..86c06c6 100644
--- a/services/camera/libcameraservice/api1/client2/ZslProcessor.h
+++ b/services/camera/libcameraservice/api1/client2/ZslProcessor.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2012 The Android Open Source Project
+ * Copyright (C) 2013 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -25,11 +25,9 @@
#include <gui/BufferItem.h>
#include <gui/BufferItemConsumer.h>
#include <camera/CameraMetadata.h>
-#include <camera/CaptureResult.h>
-#include "common/CameraDeviceBase.h"
-#include "api1/client2/ZslProcessorInterface.h"
#include "api1/client2/FrameProcessor.h"
+#include "device3/Camera3ZslStream.h"
namespace android {
@@ -38,45 +36,66 @@
namespace camera2 {
class CaptureSequencer;
-class Parameters;
+struct Parameters;
/***
- * ZSL queue processing
+ * ZSL queue processing for HALv3.0 or newer
*/
-class ZslProcessor:
+class ZslProcessor :
+ public camera3::Camera3StreamBufferListener,
virtual public Thread,
- virtual public BufferItemConsumer::FrameAvailableListener,
- virtual public FrameProcessor::FilteredListener,
- virtual public CameraDeviceBase::BufferReleasedListener,
- public ZslProcessorInterface {
+ virtual public FrameProcessor::FilteredListener {
public:
ZslProcessor(sp<Camera2Client> client, wp<CaptureSequencer> sequencer);
~ZslProcessor();
- // From mZslConsumer
- virtual void onFrameAvailable(const BufferItem& item);
- // From FrameProcessor
+ // From FrameProcessor::FilteredListener
virtual void onResultAvailable(const CaptureResult &result);
- virtual void onBufferReleased(buffer_handle_t *handle);
-
/**
****************************************
* ZslProcessorInterface implementation *
****************************************
*/
+ // Update the streams by recreating them if the size/format has changed
status_t updateStream(const Parameters ¶ms);
+
+ // Delete the underlying CameraDevice streams
status_t deleteStream();
- status_t disconnect();
+
+ // Get ID for use with android.request.outputStreams / inputStreams
int getStreamId() const;
+ /**
+ * Submits a ZSL capture request (id = requestId)
+ *
+ * An appropriate ZSL buffer is selected by the closest timestamp,
+ * then we push that buffer to be reprocessed by the HAL.
+ * A capture request is created and submitted on behalf of the client.
+ */
status_t pushToReprocess(int32_t requestId);
+
+ // Flush the ZSL buffer queue, freeing up all the buffers
status_t clearZslQueue();
void dump(int fd, const Vector<String16>& args) const;
+
+ protected:
+ /**
+ **********************************************
+ * Camera3StreamBufferListener implementation *
+ **********************************************
+ */
+ typedef camera3::Camera3StreamBufferListener::BufferInfo BufferInfo;
+ // Buffer was acquired by the HAL
+ virtual void onBufferAcquired(const BufferInfo& bufferInfo);
+ // Buffer was released by the HAL
+ virtual void onBufferReleased(const BufferInfo& bufferInfo);
+
private:
static const nsecs_t kWaitDuration = 10000000; // 10 ms
+ nsecs_t mLatestClearedBufferTimestamp;
enum {
RUNNING,
@@ -84,53 +103,52 @@
} mState;
wp<Camera2Client> mClient;
- wp<CameraDeviceBase> mDevice;
wp<CaptureSequencer> mSequencer;
- int mId;
- bool mDeleted;
+ const int mId;
mutable Mutex mInputMutex;
- bool mZslBufferAvailable;
- Condition mZslBufferAvailableSignal;
enum {
NO_STREAM = -1
};
int mZslStreamId;
- int mZslReprocessStreamId;
- sp<BufferItemConsumer> mZslConsumer;
- sp<Surface> mZslWindow;
+ sp<camera3::Camera3ZslStream> mZslStream;
struct ZslPair {
BufferItem buffer;
CameraMetadata frame;
};
- static const size_t kZslBufferDepth = 4;
- static const size_t kFrameListDepth = kZslBufferDepth * 2;
+ static const int32_t kDefaultMaxPipelineDepth = 4;
+ size_t mBufferQueueDepth;
+ size_t mFrameListDepth;
Vector<CameraMetadata> mFrameList;
size_t mFrameListHead;
ZslPair mNextPair;
Vector<ZslPair> mZslQueue;
- size_t mZslQueueHead;
- size_t mZslQueueTail;
CameraMetadata mLatestCapturedRequest;
+ bool mHasFocuser;
+
virtual bool threadLoop();
- status_t processNewZslBuffer();
-
- // Match up entries from frame list to buffers in ZSL queue
- void findMatchesLocked();
-
status_t clearZslQueueLocked();
+ void clearZslResultQueueLocked();
+
void dumpZslQueue(int id) const;
+
+ nsecs_t getCandidateTimestampLocked(size_t* metadataIdx) const;
+
+ bool isFixedFocusMode(uint8_t afMode) const;
+
+ // Update the post-processing metadata with the default still capture request template
+ status_t updateRequestWithDefaultStillRequest(CameraMetadata &request) const;
};
diff --git a/services/camera/libcameraservice/api1/client2/ZslProcessor3.cpp b/services/camera/libcameraservice/api1/client2/ZslProcessor3.cpp
deleted file mode 100644
index 69620ac..0000000
--- a/services/camera/libcameraservice/api1/client2/ZslProcessor3.cpp
+++ /dev/null
@@ -1,677 +0,0 @@
-/*
- * Copyright (C) 2013 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#define LOG_TAG "Camera2-ZslProcessor3"
-#define ATRACE_TAG ATRACE_TAG_CAMERA
-//#define LOG_NDEBUG 0
-//#define LOG_NNDEBUG 0
-
-#ifdef LOG_NNDEBUG
-#define ALOGVV(...) ALOGV(__VA_ARGS__)
-#else
-#define ALOGVV(...) ((void)0)
-#endif
-
-#include <inttypes.h>
-
-#include <utils/Log.h>
-#include <utils/Trace.h>
-#include <gui/Surface.h>
-
-#include "common/CameraDeviceBase.h"
-#include "api1/Camera2Client.h"
-#include "api1/client2/CaptureSequencer.h"
-#include "api1/client2/ZslProcessor3.h"
-#include "device3/Camera3Device.h"
-
-namespace android {
-namespace camera2 {
-
-ZslProcessor3::ZslProcessor3(
- sp<Camera2Client> client,
- wp<CaptureSequencer> sequencer):
- Thread(false),
- mLatestClearedBufferTimestamp(0),
- mState(RUNNING),
- mClient(client),
- mSequencer(sequencer),
- mId(client->getCameraId()),
- mZslStreamId(NO_STREAM),
- mFrameListHead(0),
- mZslQueueHead(0),
- mZslQueueTail(0),
- mHasFocuser(false) {
- // Initialize buffer queue and frame list based on pipeline max depth.
- size_t pipelineMaxDepth = kDefaultMaxPipelineDepth;
- if (client != 0) {
- sp<Camera3Device> device =
- static_cast<Camera3Device*>(client->getCameraDevice().get());
- if (device != 0) {
- camera_metadata_ro_entry_t entry =
- device->info().find(ANDROID_REQUEST_PIPELINE_MAX_DEPTH);
- if (entry.count == 1) {
- pipelineMaxDepth = entry.data.u8[0];
- } else {
- ALOGW("%s: Unable to find the android.request.pipelineMaxDepth,"
- " use default pipeline max depth %zu", __FUNCTION__,
- kDefaultMaxPipelineDepth);
- }
-
- entry = device->info().find(ANDROID_LENS_INFO_MINIMUM_FOCUS_DISTANCE);
- if (entry.count > 0 && entry.data.f[0] != 0.) {
- mHasFocuser = true;
- }
- }
- }
-
- ALOGV("%s: Initialize buffer queue and frame list depth based on max pipeline depth (%d)",
- __FUNCTION__, pipelineMaxDepth);
- // Need to keep buffer queue longer than metadata queue because sometimes buffer arrives
- // earlier than metadata which causes the buffer corresponding to oldest metadata being
- // removed.
- mFrameListDepth = pipelineMaxDepth;
- mBufferQueueDepth = mFrameListDepth + 1;
-
-
- mZslQueue.insertAt(0, mBufferQueueDepth);
- mFrameList.insertAt(0, mFrameListDepth);
- sp<CaptureSequencer> captureSequencer = mSequencer.promote();
- if (captureSequencer != 0) captureSequencer->setZslProcessor(this);
-}
-
-ZslProcessor3::~ZslProcessor3() {
- ALOGV("%s: Exit", __FUNCTION__);
- deleteStream();
-}
-
-void ZslProcessor3::onResultAvailable(const CaptureResult &result) {
- ATRACE_CALL();
- ALOGV("%s:", __FUNCTION__);
- Mutex::Autolock l(mInputMutex);
- camera_metadata_ro_entry_t entry;
- entry = result.mMetadata.find(ANDROID_SENSOR_TIMESTAMP);
- nsecs_t timestamp = entry.data.i64[0];
- if (entry.count == 0) {
- ALOGE("%s: metadata doesn't have timestamp, skip this result", __FUNCTION__);
- return;
- }
-
- entry = result.mMetadata.find(ANDROID_REQUEST_FRAME_COUNT);
- if (entry.count == 0) {
- ALOGE("%s: metadata doesn't have frame number, skip this result", __FUNCTION__);
- return;
- }
- int32_t frameNumber = entry.data.i32[0];
-
- ALOGVV("Got preview metadata for frame %d with timestamp %" PRId64, frameNumber, timestamp);
-
- if (mState != RUNNING) return;
-
- // Corresponding buffer has been cleared. No need to push into mFrameList
- if (timestamp <= mLatestClearedBufferTimestamp) return;
-
- mFrameList.editItemAt(mFrameListHead) = result.mMetadata;
- mFrameListHead = (mFrameListHead + 1) % mFrameListDepth;
-}
-
-status_t ZslProcessor3::updateStream(const Parameters ¶ms) {
- ATRACE_CALL();
- ALOGV("%s: Configuring ZSL streams", __FUNCTION__);
- status_t res;
-
- Mutex::Autolock l(mInputMutex);
-
- sp<Camera2Client> client = mClient.promote();
- if (client == 0) {
- ALOGE("%s: Camera %d: Client does not exist", __FUNCTION__, mId);
- return INVALID_OPERATION;
- }
- sp<Camera3Device> device =
- static_cast<Camera3Device*>(client->getCameraDevice().get());
- if (device == 0) {
- ALOGE("%s: Camera %d: Device does not exist", __FUNCTION__, mId);
- return INVALID_OPERATION;
- }
-
- if (mZslStreamId != NO_STREAM) {
- // Check if stream parameters have to change
- uint32_t currentWidth, currentHeight;
- res = device->getStreamInfo(mZslStreamId,
- ¤tWidth, ¤tHeight, 0, 0);
- if (res != OK) {
- ALOGE("%s: Camera %d: Error querying capture output stream info: "
- "%s (%d)", __FUNCTION__,
- client->getCameraId(), strerror(-res), res);
- return res;
- }
- if (currentWidth != (uint32_t)params.fastInfo.arrayWidth ||
- currentHeight != (uint32_t)params.fastInfo.arrayHeight) {
- ALOGV("%s: Camera %d: Deleting stream %d since the buffer "
- "dimensions changed",
- __FUNCTION__, client->getCameraId(), mZslStreamId);
- res = device->deleteStream(mZslStreamId);
- if (res == -EBUSY) {
- ALOGV("%s: Camera %d: Device is busy, call updateStream again "
- " after it becomes idle", __FUNCTION__, mId);
- return res;
- } else if(res != OK) {
- ALOGE("%s: Camera %d: Unable to delete old output stream "
- "for ZSL: %s (%d)", __FUNCTION__,
- client->getCameraId(), strerror(-res), res);
- return res;
- }
- mZslStreamId = NO_STREAM;
- }
- }
-
- if (mZslStreamId == NO_STREAM) {
- // Create stream for HAL production
- // TODO: Sort out better way to select resolution for ZSL
-
- // Note that format specified internally in Camera3ZslStream
- res = device->createZslStream(
- params.fastInfo.arrayWidth, params.fastInfo.arrayHeight,
- mBufferQueueDepth,
- &mZslStreamId,
- &mZslStream);
- if (res != OK) {
- ALOGE("%s: Camera %d: Can't create ZSL stream: "
- "%s (%d)", __FUNCTION__, client->getCameraId(),
- strerror(-res), res);
- return res;
- }
-
- // Only add the camera3 buffer listener when the stream is created.
- mZslStream->addBufferListener(this);
- }
-
- client->registerFrameListener(Camera2Client::kPreviewRequestIdStart,
- Camera2Client::kPreviewRequestIdEnd,
- this,
- /*sendPartials*/false);
-
- return OK;
-}
-
-status_t ZslProcessor3::deleteStream() {
- ATRACE_CALL();
- status_t res;
-
- Mutex::Autolock l(mInputMutex);
-
- if (mZslStreamId != NO_STREAM) {
- sp<Camera2Client> client = mClient.promote();
- if (client == 0) {
- ALOGE("%s: Camera %d: Client does not exist", __FUNCTION__, mId);
- return INVALID_OPERATION;
- }
-
- sp<Camera3Device> device =
- reinterpret_cast<Camera3Device*>(client->getCameraDevice().get());
- if (device == 0) {
- ALOGE("%s: Camera %d: Device does not exist", __FUNCTION__, mId);
- return INVALID_OPERATION;
- }
-
- res = device->deleteStream(mZslStreamId);
- if (res != OK) {
- ALOGE("%s: Camera %d: Cannot delete ZSL output stream %d: "
- "%s (%d)", __FUNCTION__, client->getCameraId(),
- mZslStreamId, strerror(-res), res);
- return res;
- }
-
- mZslStreamId = NO_STREAM;
- }
- return OK;
-}
-
-int ZslProcessor3::getStreamId() const {
- Mutex::Autolock l(mInputMutex);
- return mZslStreamId;
-}
-
-status_t ZslProcessor3::updateRequestWithDefaultStillRequest(CameraMetadata &request) const {
- sp<Camera2Client> client = mClient.promote();
- if (client == 0) {
- ALOGE("%s: Camera %d: Client does not exist", __FUNCTION__, mId);
- return INVALID_OPERATION;
- }
- sp<Camera3Device> device =
- static_cast<Camera3Device*>(client->getCameraDevice().get());
- if (device == 0) {
- ALOGE("%s: Camera %d: Device does not exist", __FUNCTION__, mId);
- return INVALID_OPERATION;
- }
-
- CameraMetadata stillTemplate;
- device->createDefaultRequest(CAMERA3_TEMPLATE_STILL_CAPTURE, &stillTemplate);
-
- // Find some of the post-processing tags, and assign the value from template to the request.
- // Only check the aberration mode and noise reduction mode for now, as they are very important
- // for image quality.
- uint32_t postProcessingTags[] = {
- ANDROID_NOISE_REDUCTION_MODE,
- ANDROID_COLOR_CORRECTION_ABERRATION_MODE,
- ANDROID_COLOR_CORRECTION_MODE,
- ANDROID_TONEMAP_MODE,
- ANDROID_SHADING_MODE,
- ANDROID_HOT_PIXEL_MODE,
- ANDROID_EDGE_MODE
- };
-
- camera_metadata_entry_t entry;
- for (size_t i = 0; i < sizeof(postProcessingTags) / sizeof(uint32_t); i++) {
- entry = stillTemplate.find(postProcessingTags[i]);
- if (entry.count > 0) {
- request.update(postProcessingTags[i], entry.data.u8, 1);
- }
- }
-
- return OK;
-}
-
-status_t ZslProcessor3::pushToReprocess(int32_t requestId) {
- ALOGV("%s: Send in reprocess request with id %d",
- __FUNCTION__, requestId);
- Mutex::Autolock l(mInputMutex);
- status_t res;
- sp<Camera2Client> client = mClient.promote();
-
- if (client == 0) {
- ALOGE("%s: Camera %d: Client does not exist", __FUNCTION__, mId);
- return INVALID_OPERATION;
- }
-
- IF_ALOGV() {
- dumpZslQueue(-1);
- }
-
- size_t metadataIdx;
- nsecs_t candidateTimestamp = getCandidateTimestampLocked(&metadataIdx);
-
- if (candidateTimestamp == -1) {
- ALOGE("%s: Could not find good candidate for ZSL reprocessing",
- __FUNCTION__);
- return NOT_ENOUGH_DATA;
- }
-
- res = mZslStream->enqueueInputBufferByTimestamp(candidateTimestamp,
- /*actualTimestamp*/NULL);
-
- if (res == mZslStream->NO_BUFFER_AVAILABLE) {
- ALOGV("%s: No ZSL buffers yet", __FUNCTION__);
- return NOT_ENOUGH_DATA;
- } else if (res != OK) {
- ALOGE("%s: Unable to push buffer for reprocessing: %s (%d)",
- __FUNCTION__, strerror(-res), res);
- return res;
- }
-
- {
- CameraMetadata request = mFrameList[metadataIdx];
-
- // Verify that the frame is reasonable for reprocessing
-
- camera_metadata_entry_t entry;
- entry = request.find(ANDROID_CONTROL_AE_STATE);
- if (entry.count == 0) {
- ALOGE("%s: ZSL queue frame has no AE state field!",
- __FUNCTION__);
- return BAD_VALUE;
- }
- if (entry.data.u8[0] != ANDROID_CONTROL_AE_STATE_CONVERGED &&
- entry.data.u8[0] != ANDROID_CONTROL_AE_STATE_LOCKED) {
- ALOGV("%s: ZSL queue frame AE state is %d, need full capture",
- __FUNCTION__, entry.data.u8[0]);
- return NOT_ENOUGH_DATA;
- }
-
- uint8_t requestType = ANDROID_REQUEST_TYPE_REPROCESS;
- res = request.update(ANDROID_REQUEST_TYPE,
- &requestType, 1);
- if (res != OK) {
- ALOGE("%s: Unable to update request type",
- __FUNCTION__);
- return INVALID_OPERATION;
- }
-
- int32_t inputStreams[1] =
- { mZslStreamId };
- res = request.update(ANDROID_REQUEST_INPUT_STREAMS,
- inputStreams, 1);
- if (res != OK) {
- ALOGE("%s: Unable to update request input streams",
- __FUNCTION__);
- return INVALID_OPERATION;
- }
-
- uint8_t captureIntent =
- static_cast<uint8_t>(ANDROID_CONTROL_CAPTURE_INTENT_STILL_CAPTURE);
- res = request.update(ANDROID_CONTROL_CAPTURE_INTENT,
- &captureIntent, 1);
- if (res != OK ) {
- ALOGE("%s: Unable to update request capture intent",
- __FUNCTION__);
- return INVALID_OPERATION;
- }
-
- // TODO: Shouldn't we also update the latest preview frame?
- int32_t outputStreams[1] =
- { client->getCaptureStreamId() };
- res = request.update(ANDROID_REQUEST_OUTPUT_STREAMS,
- outputStreams, 1);
- if (res != OK) {
- ALOGE("%s: Unable to update request output streams",
- __FUNCTION__);
- return INVALID_OPERATION;
- }
-
- res = request.update(ANDROID_REQUEST_ID,
- &requestId, 1);
- if (res != OK ) {
- ALOGE("%s: Unable to update frame to a reprocess request",
- __FUNCTION__);
- return INVALID_OPERATION;
- }
-
- res = client->stopStream();
- if (res != OK) {
- ALOGE("%s: Camera %d: Unable to stop preview for ZSL capture: "
- "%s (%d)",
- __FUNCTION__, client->getCameraId(), strerror(-res), res);
- return INVALID_OPERATION;
- }
-
- // Update JPEG settings
- {
- SharedParameters::Lock l(client->getParameters());
- res = l.mParameters.updateRequestJpeg(&request);
- if (res != OK) {
- ALOGE("%s: Camera %d: Unable to update JPEG entries of ZSL "
- "capture request: %s (%d)", __FUNCTION__,
- client->getCameraId(),
- strerror(-res), res);
- return res;
- }
- }
-
- // Update post-processing settings
- res = updateRequestWithDefaultStillRequest(request);
- if (res != OK) {
- ALOGW("%s: Unable to update post-processing tags, the reprocessed image quality "
- "may be compromised", __FUNCTION__);
- }
-
- mLatestCapturedRequest = request;
- res = client->getCameraDevice()->capture(request);
- if (res != OK ) {
- ALOGE("%s: Unable to send ZSL reprocess request to capture: %s"
- " (%d)", __FUNCTION__, strerror(-res), res);
- return res;
- }
-
- mState = LOCKED;
- }
-
- return OK;
-}
-
-status_t ZslProcessor3::clearZslQueue() {
- Mutex::Autolock l(mInputMutex);
- // If in middle of capture, can't clear out queue
- if (mState == LOCKED) return OK;
-
- return clearZslQueueLocked();
-}
-
-status_t ZslProcessor3::clearZslQueueLocked() {
- if (mZslStream != 0) {
- // clear result metadata list first.
- clearZslResultQueueLocked();
- return mZslStream->clearInputRingBuffer(&mLatestClearedBufferTimestamp);
- }
- return OK;
-}
-
-void ZslProcessor3::clearZslResultQueueLocked() {
- mFrameList.clear();
- mFrameListHead = 0;
- mFrameList.insertAt(0, mFrameListDepth);
-}
-
-void ZslProcessor3::dump(int fd, const Vector<String16>& /*args*/) const {
- Mutex::Autolock l(mInputMutex);
- if (!mLatestCapturedRequest.isEmpty()) {
- String8 result(" Latest ZSL capture request:\n");
- write(fd, result.string(), result.size());
- mLatestCapturedRequest.dump(fd, 2, 6);
- } else {
- String8 result(" Latest ZSL capture request: none yet\n");
- write(fd, result.string(), result.size());
- }
- dumpZslQueue(fd);
-}
-
-bool ZslProcessor3::threadLoop() {
- // TODO: remove dependency on thread. For now, shut thread down right
- // away.
- return false;
-}
-
-void ZslProcessor3::dumpZslQueue(int fd) const {
- String8 header("ZSL queue contents:");
- String8 indent(" ");
- ALOGV("%s", header.string());
- if (fd != -1) {
- header = indent + header + "\n";
- write(fd, header.string(), header.size());
- }
- for (size_t i = 0; i < mZslQueue.size(); i++) {
- const ZslPair &queueEntry = mZslQueue[i];
- nsecs_t bufferTimestamp = queueEntry.buffer.mTimestamp;
- camera_metadata_ro_entry_t entry;
- nsecs_t frameTimestamp = 0;
- int frameAeState = -1;
- if (!queueEntry.frame.isEmpty()) {
- entry = queueEntry.frame.find(ANDROID_SENSOR_TIMESTAMP);
- if (entry.count > 0) frameTimestamp = entry.data.i64[0];
- entry = queueEntry.frame.find(ANDROID_CONTROL_AE_STATE);
- if (entry.count > 0) frameAeState = entry.data.u8[0];
- }
- String8 result =
- String8::format(" %zu: b: %" PRId64 "\tf: %" PRId64 ", AE state: %d", i,
- bufferTimestamp, frameTimestamp, frameAeState);
- ALOGV("%s", result.string());
- if (fd != -1) {
- result = indent + result + "\n";
- write(fd, result.string(), result.size());
- }
-
- }
-}
-
-bool ZslProcessor3::isFixedFocusMode(uint8_t afMode) const {
- switch (afMode) {
- case ANDROID_CONTROL_AF_MODE_AUTO:
- case ANDROID_CONTROL_AF_MODE_CONTINUOUS_VIDEO:
- case ANDROID_CONTROL_AF_MODE_CONTINUOUS_PICTURE:
- case ANDROID_CONTROL_AF_MODE_MACRO:
- return false;
- break;
- case ANDROID_CONTROL_AF_MODE_OFF:
- case ANDROID_CONTROL_AF_MODE_EDOF:
- return true;
- default:
- ALOGE("%s: unknown focus mode %d", __FUNCTION__, afMode);
- return false;
- }
-}
-
-nsecs_t ZslProcessor3::getCandidateTimestampLocked(size_t* metadataIdx) const {
- /**
- * Find the smallest timestamp we know about so far
- * - ensure that aeState is either converged or locked
- */
-
- size_t idx = 0;
- nsecs_t minTimestamp = -1;
-
- size_t emptyCount = mFrameList.size();
-
- for (size_t j = 0; j < mFrameList.size(); j++) {
- const CameraMetadata &frame = mFrameList[j];
- if (!frame.isEmpty()) {
-
- emptyCount--;
-
- camera_metadata_ro_entry_t entry;
- entry = frame.find(ANDROID_SENSOR_TIMESTAMP);
- if (entry.count == 0) {
- ALOGE("%s: Can't find timestamp in frame!",
- __FUNCTION__);
- continue;
- }
- nsecs_t frameTimestamp = entry.data.i64[0];
- if (minTimestamp > frameTimestamp || minTimestamp == -1) {
-
- entry = frame.find(ANDROID_CONTROL_AE_STATE);
-
- if (entry.count == 0) {
- /**
- * This is most likely a HAL bug. The aeState field is
- * mandatory, so it should always be in a metadata packet.
- */
- ALOGW("%s: ZSL queue frame has no AE state field!",
- __FUNCTION__);
- continue;
- }
- if (entry.data.u8[0] != ANDROID_CONTROL_AE_STATE_CONVERGED &&
- entry.data.u8[0] != ANDROID_CONTROL_AE_STATE_LOCKED) {
- ALOGVV("%s: ZSL queue frame AE state is %d, need "
- "full capture", __FUNCTION__, entry.data.u8[0]);
- continue;
- }
-
- entry = frame.find(ANDROID_CONTROL_AF_MODE);
- if (entry.count == 0) {
- ALOGW("%s: ZSL queue frame has no AF mode field!",
- __FUNCTION__);
- continue;
- }
- uint8_t afMode = entry.data.u8[0];
- if (afMode == ANDROID_CONTROL_AF_MODE_OFF) {
- // Skip all the ZSL buffer for manual AF mode, as we don't really
- // know the af state.
- continue;
- }
-
- // Check AF state if device has focuser and focus mode isn't fixed
- if (mHasFocuser && !isFixedFocusMode(afMode)) {
- // Make sure the candidate frame has good focus.
- entry = frame.find(ANDROID_CONTROL_AF_STATE);
- if (entry.count == 0) {
- ALOGW("%s: ZSL queue frame has no AF state field!",
- __FUNCTION__);
- continue;
- }
- uint8_t afState = entry.data.u8[0];
- if (afState != ANDROID_CONTROL_AF_STATE_PASSIVE_FOCUSED &&
- afState != ANDROID_CONTROL_AF_STATE_FOCUSED_LOCKED &&
- afState != ANDROID_CONTROL_AF_STATE_NOT_FOCUSED_LOCKED) {
- ALOGVV("%s: ZSL queue frame AF state is %d is not good for capture, skip it",
- __FUNCTION__, afState);
- continue;
- }
- }
-
- minTimestamp = frameTimestamp;
- idx = j;
- }
-
- ALOGVV("%s: Saw timestamp %" PRId64, __FUNCTION__, frameTimestamp);
- }
- }
-
- if (emptyCount == mFrameList.size()) {
- /**
- * This could be mildly bad and means our ZSL was triggered before
- * there were any frames yet received by the camera framework.
- *
- * This is a fairly corner case which can happen under:
- * + a user presses the shutter button real fast when the camera starts
- * (startPreview followed immediately by takePicture).
- * + burst capture case (hitting shutter button as fast possible)
- *
- * If this happens in steady case (preview running for a while, call
- * a single takePicture) then this might be a fwk bug.
- */
- ALOGW("%s: ZSL queue has no metadata frames", __FUNCTION__);
- }
-
- ALOGV("%s: Candidate timestamp %" PRId64 " (idx %zu), empty frames: %zu",
- __FUNCTION__, minTimestamp, idx, emptyCount);
-
- if (metadataIdx) {
- *metadataIdx = idx;
- }
-
- return minTimestamp;
-}
-
-void ZslProcessor3::onBufferAcquired(const BufferInfo& /*bufferInfo*/) {
- // Intentionally left empty
- // Although theoretically we could use this to get better dump info
-}
-
-void ZslProcessor3::onBufferReleased(const BufferInfo& bufferInfo) {
-
- // ignore output buffers
- if (bufferInfo.mOutput) {
- return;
- }
-
- // Lock mutex only once we know this is an input buffer returned to avoid
- // potential deadlock
- Mutex::Autolock l(mInputMutex);
- // TODO: Verify that the buffer is in our queue by looking at timestamp
- // theoretically unnecessary unless we change the following assumptions:
- // -- only 1 buffer reprocessed at a time (which is the case now)
-
- // Erase entire ZSL queue since we've now completed the capture and preview
- // is stopped.
- //
- // We need to guarantee that if we do two back-to-back captures,
- // the second won't use a buffer that's older/the same as the first, which
- // is theoretically possible if we don't clear out the queue and the
- // selection criteria is something like 'newest'. Clearing out the result
- // metadata queue on a completed capture ensures we'll only use new timestamp.
- // Calling clearZslQueueLocked is a guaranteed deadlock because this callback
- // holds the Camera3Stream internal lock (mLock), and clearZslQueueLocked requires
- // to hold the same lock.
- // TODO: need figure out a way to clear the Zsl buffer queue properly. Right now
- // it is safe not to do so, as back to back ZSL capture requires stop and start
- // preview, which will flush ZSL queue automatically.
- ALOGV("%s: Memory optimization, clearing ZSL queue",
- __FUNCTION__);
- clearZslResultQueueLocked();
-
- // Required so we accept more ZSL requests
- mState = RUNNING;
-}
-
-}; // namespace camera2
-}; // namespace android
diff --git a/services/camera/libcameraservice/api1/client2/ZslProcessor3.h b/services/camera/libcameraservice/api1/client2/ZslProcessor3.h
deleted file mode 100644
index 2960478..0000000
--- a/services/camera/libcameraservice/api1/client2/ZslProcessor3.h
+++ /dev/null
@@ -1,148 +0,0 @@
-/*
- * Copyright (C) 2013 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef ANDROID_SERVERS_CAMERA_CAMERA2_ZSLPROCESSOR3_H
-#define ANDROID_SERVERS_CAMERA_CAMERA2_ZSLPROCESSOR3_H
-
-#include <utils/Thread.h>
-#include <utils/String16.h>
-#include <utils/Vector.h>
-#include <utils/Mutex.h>
-#include <utils/Condition.h>
-#include <gui/BufferItem.h>
-#include <gui/BufferItemConsumer.h>
-#include <camera/CameraMetadata.h>
-
-#include "api1/client2/FrameProcessor.h"
-#include "api1/client2/ZslProcessorInterface.h"
-#include "device3/Camera3ZslStream.h"
-
-namespace android {
-
-class Camera2Client;
-
-namespace camera2 {
-
-class CaptureSequencer;
-class Parameters;
-
-/***
- * ZSL queue processing
- */
-class ZslProcessor3 :
- public ZslProcessorInterface,
- public camera3::Camera3StreamBufferListener,
- virtual public Thread,
- virtual public FrameProcessor::FilteredListener {
- public:
- ZslProcessor3(sp<Camera2Client> client, wp<CaptureSequencer> sequencer);
- ~ZslProcessor3();
-
- // From FrameProcessor::FilteredListener
- virtual void onResultAvailable(const CaptureResult &result);
-
- /**
- ****************************************
- * ZslProcessorInterface implementation *
- ****************************************
- */
-
- virtual status_t updateStream(const Parameters ¶ms);
- virtual status_t deleteStream();
- virtual int getStreamId() const;
-
- virtual status_t pushToReprocess(int32_t requestId);
- virtual status_t clearZslQueue();
-
- void dump(int fd, const Vector<String16>& args) const;
-
- protected:
- /**
- **********************************************
- * Camera3StreamBufferListener implementation *
- **********************************************
- */
- typedef camera3::Camera3StreamBufferListener::BufferInfo BufferInfo;
- // Buffer was acquired by the HAL
- virtual void onBufferAcquired(const BufferInfo& bufferInfo);
- // Buffer was released by the HAL
- virtual void onBufferReleased(const BufferInfo& bufferInfo);
-
- private:
- static const nsecs_t kWaitDuration = 10000000; // 10 ms
- nsecs_t mLatestClearedBufferTimestamp;
-
- enum {
- RUNNING,
- LOCKED
- } mState;
-
- wp<Camera2Client> mClient;
- wp<CaptureSequencer> mSequencer;
-
- const int mId;
-
- mutable Mutex mInputMutex;
-
- enum {
- NO_STREAM = -1
- };
-
- int mZslStreamId;
- sp<camera3::Camera3ZslStream> mZslStream;
-
- struct ZslPair {
- BufferItem buffer;
- CameraMetadata frame;
- };
-
- static const int32_t kDefaultMaxPipelineDepth = 4;
- size_t mBufferQueueDepth;
- size_t mFrameListDepth;
- Vector<CameraMetadata> mFrameList;
- size_t mFrameListHead;
-
- ZslPair mNextPair;
-
- Vector<ZslPair> mZslQueue;
- size_t mZslQueueHead;
- size_t mZslQueueTail;
-
- CameraMetadata mLatestCapturedRequest;
-
- bool mHasFocuser;
-
- virtual bool threadLoop();
-
- status_t clearZslQueueLocked();
-
- void clearZslResultQueueLocked();
-
- void dumpZslQueue(int id) const;
-
- nsecs_t getCandidateTimestampLocked(size_t* metadataIdx) const;
-
- bool isFixedFocusMode(uint8_t afMode) const;
-
- // Update the post-processing metadata with the default still capture request template
- status_t updateRequestWithDefaultStillRequest(CameraMetadata &request) const;
-};
-
-
-}; //namespace camera2
-}; //namespace android
-
-#endif
diff --git a/services/camera/libcameraservice/api1/client2/ZslProcessorInterface.cpp b/services/camera/libcameraservice/api1/client2/ZslProcessorInterface.cpp
deleted file mode 100644
index 9efeaba..0000000
--- a/services/camera/libcameraservice/api1/client2/ZslProcessorInterface.cpp
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * Copyright (C) 2014 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "ZslProcessorInterface.h"
-
-namespace android {
-namespace camera2 {
-
-status_t ZslProcessorInterface::disconnect() {
- return OK;
-}
-
-}; //namespace camera2
-}; //namespace android
-
diff --git a/services/camera/libcameraservice/api1/client2/ZslProcessorInterface.h b/services/camera/libcameraservice/api1/client2/ZslProcessorInterface.h
deleted file mode 100644
index 9e266e7..0000000
--- a/services/camera/libcameraservice/api1/client2/ZslProcessorInterface.h
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * Copyright (C) 2013 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef ANDROID_SERVERS_CAMERA_CAMERA2_ZSLPROCESSORINTERFACE_H
-#define ANDROID_SERVERS_CAMERA_CAMERA2_ZSLPROCESSORINTERFACE_H
-
-#include <utils/Errors.h>
-#include <utils/RefBase.h>
-#include <utils/String16.h>
-#include <utils/Vector.h>
-
-namespace android {
-namespace camera2 {
-
-class Parameters;
-
-class ZslProcessorInterface : virtual public RefBase {
-public:
-
- // Get ID for use with android.request.outputStreams / inputStreams
- virtual int getStreamId() const = 0;
-
- // Update the streams by recreating them if the size/format has changed
- virtual status_t updateStream(const Parameters& params) = 0;
-
- // Delete the underlying CameraDevice streams
- virtual status_t deleteStream() = 0;
-
- // Clear any additional state necessary before the CameraDevice is disconnected
- virtual status_t disconnect();
-
- /**
- * Submits a ZSL capture request (id = requestId)
- *
- * An appropriate ZSL buffer is selected by the closest timestamp,
- * then we push that buffer to be reprocessed by the HAL.
- * A capture request is created and submitted on behalf of the client.
- */
- virtual status_t pushToReprocess(int32_t requestId) = 0;
-
- // Flush the ZSL buffer queue, freeing up all the buffers
- virtual status_t clearZslQueue() = 0;
-
- // (Debugging only) Dump the current state to the specified file descriptor
- virtual void dump(int fd, const Vector<String16>& args) const = 0;
-};
-
-}; //namespace camera2
-}; //namespace android
-
-#endif