diff options
author | Zhijun He <zhijunhe@google.com> | 2014-07-14 17:09:23 -0700 |
---|---|---|
committer | Zhijun He <zhijunhe@google.com> | 2014-07-16 15:27:17 -0700 |
commit | 204e3295e2814052aef7e45ee9edd60128efbbd0 (patch) | |
tree | 1110e6c06e489c9c2003398e1768b9194effee78 /services/camera/libcameraservice/common | |
parent | 671160ffe81592efa376dc1ff0fc3f4ddcdebc35 (diff) | |
download | frameworks_av-204e3295e2814052aef7e45ee9edd60128efbbd0.zip frameworks_av-204e3295e2814052aef7e45ee9edd60128efbbd0.tar.gz frameworks_av-204e3295e2814052aef7e45ee9edd60128efbbd0.tar.bz2 |
Camera HAL3: migrate from partial quirks to partial result
- Enable the normal partial result path for HAL3.2, the quirk is only used
for the HAL version lower than HAL3.2. The partial quirks is no longer supported
for HAL3.2 or higher versions.
- Add CameraDeviceBase getDeviceVersion API.
- Fix some build warnings
Change-Id: I7a1b03d4d5fd5258d2addfba4368bee2ba691337
Diffstat (limited to 'services/camera/libcameraservice/common')
3 files changed, 32 insertions, 10 deletions
diff --git a/services/camera/libcameraservice/common/CameraDeviceBase.h b/services/camera/libcameraservice/common/CameraDeviceBase.h index c7bd886..037695d 100644 --- a/services/camera/libcameraservice/common/CameraDeviceBase.h +++ b/services/camera/libcameraservice/common/CameraDeviceBase.h @@ -252,6 +252,10 @@ class CameraDeviceBase : public virtual RefBase { */ virtual status_t flush(int64_t *lastFrameNumber = NULL) = 0; + /** + * Get the HAL device version. + */ + virtual uint32_t getDeviceVersion() = 0; }; }; // namespace android diff --git a/services/camera/libcameraservice/common/FrameProcessorBase.cpp b/services/camera/libcameraservice/common/FrameProcessorBase.cpp index 482f687..29eb78f 100644 --- a/services/camera/libcameraservice/common/FrameProcessorBase.cpp +++ b/services/camera/libcameraservice/common/FrameProcessorBase.cpp @@ -29,7 +29,17 @@ namespace camera2 { FrameProcessorBase::FrameProcessorBase(wp<CameraDeviceBase> device) : Thread(/*canCallJava*/false), - mDevice(device) { + mDevice(device), + mNumPartialResults(1) { + sp<CameraDeviceBase> cameraDevice = device.promote(); + if (cameraDevice != 0 && + cameraDevice->getDeviceVersion() >= CAMERA_DEVICE_API_VERSION_3_2) { + CameraMetadata staticInfo = cameraDevice->info(); + camera_metadata_entry_t entry = staticInfo.find(ANDROID_REQUEST_PARTIAL_RESULT_COUNT); + if (entry.count > 0) { + mNumPartialResults = entry.data.i32[0]; + } + } } FrameProcessorBase::~FrameProcessorBase() { @@ -160,14 +170,18 @@ status_t FrameProcessorBase::processListeners(const CaptureResult &result, camera_metadata_ro_entry_t entry; - // Quirks: Don't deliver partial results to listeners that don't want them - bool quirkIsPartial = false; - entry = result.mMetadata.find(ANDROID_QUIRKS_PARTIAL_RESULT); - if (entry.count != 0 && - entry.data.u8[0] == ANDROID_QUIRKS_PARTIAL_RESULT_PARTIAL) { - ALOGV("%s: Camera %d: Not forwarding partial result to listeners", - __FUNCTION__, device->getId()); - quirkIsPartial = true; + // Check if this result is partial. + bool isPartialResult = false; + if (device->getDeviceVersion() >= CAMERA_DEVICE_API_VERSION_3_2) { + isPartialResult = result.mResultExtras.partialResultCount < mNumPartialResults; + } else { + entry = result.mMetadata.find(ANDROID_QUIRKS_PARTIAL_RESULT); + if (entry.count != 0 && + entry.data.u8[0] == ANDROID_QUIRKS_PARTIAL_RESULT_PARTIAL) { + ALOGV("%s: Camera %d: This is a partial result", + __FUNCTION__, device->getId()); + isPartialResult = true; + } } // TODO: instead of getting requestID from CameraMetadata, we should get it @@ -186,9 +200,10 @@ status_t FrameProcessorBase::processListeners(const CaptureResult &result, Mutex::Autolock l(mInputMutex); List<RangeListener>::iterator item = mRangeListeners.begin(); + // Don't deliver partial results to listeners that don't want them while (item != mRangeListeners.end()) { if (requestId >= item->minId && requestId < item->maxId && - (!quirkIsPartial || item->sendPartials)) { + (!isPartialResult || item->sendPartials)) { sp<FilteredListener> listener = item->listener.promote(); if (listener == 0) { item = mRangeListeners.erase(item); diff --git a/services/camera/libcameraservice/common/FrameProcessorBase.h b/services/camera/libcameraservice/common/FrameProcessorBase.h index 3649c45..a618d84 100644 --- a/services/camera/libcameraservice/common/FrameProcessorBase.h +++ b/services/camera/libcameraservice/common/FrameProcessorBase.h @@ -71,6 +71,9 @@ class FrameProcessorBase: public Thread { }; List<RangeListener> mRangeListeners; + // Number of partial result the HAL will potentially send. + int32_t mNumPartialResults; + void processNewFrames(const sp<CameraDeviceBase> &device); virtual bool processSingleFrame(CaptureResult &result, |