Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 204e3295 authored by Zhijun He's avatar Zhijun He
Browse files

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
parent 671160ff
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -37,6 +37,7 @@ status_t CaptureResultExtras::readFromParcel(Parcel *parcel) {
    parcel->readInt32(&afTriggerId);
    parcel->readInt32(&precaptureTriggerId);
    parcel->readInt64(&frameNumber);
    parcel->readInt32(&partialResultCount);

    return OK;
}
@@ -52,6 +53,7 @@ status_t CaptureResultExtras::writeToParcel(Parcel *parcel) const {
    parcel->writeInt32(afTriggerId);
    parcel->writeInt32(precaptureTriggerId);
    parcel->writeInt64(frameNumber);
    parcel->writeInt32(partialResultCount);

    return OK;
}
+7 −1
Original line number Diff line number Diff line
@@ -52,6 +52,11 @@ struct CaptureResultExtras {
     */
    int64_t frameNumber;

    /**
     * The partial result count (index) for this capture result.
     */
    int32_t partialResultCount;

    /**
     * Constructor initializes object as invalid by setting requestId to be -1.
     */
@@ -60,7 +65,8 @@ struct CaptureResultExtras {
          burstId(0),
          afTriggerId(0),
          precaptureTriggerId(0),
          frameNumber(0) {
          frameNumber(0),
          partialResultCount(0) {
    }

    /**
+18 −9
Original line number Diff line number Diff line
@@ -40,7 +40,12 @@ FrameProcessor::FrameProcessor(wp<CameraDeviceBase> device,

    {
        SharedParameters::Lock l(client->getParameters());
        mUsePartialQuirk = l.mParameters.quirks.partialResults;

        if (client->getCameraDeviceVersion() >= CAMERA_DEVICE_API_VERSION_3_2) {
            mUsePartialResult = (mNumPartialResults > 1);
        } else {
            mUsePartialResult = l.mParameters.quirks.partialResults;
        }

        // Initialize starting 3A state
        m3aState.afTriggerId = l.mParameters.afTriggerCounter;
@@ -63,17 +68,21 @@ bool FrameProcessor::processSingleFrame(CaptureResult &frame,
        return false;
    }

    bool partialResult = false;
    if (mUsePartialQuirk) {
    bool isPartialResult = false;
    if (mUsePartialResult) {
        if (client->getCameraDeviceVersion() >= CAMERA_DEVICE_API_VERSION_3_2) {
            isPartialResult = frame.mResultExtras.partialResultCount < mNumPartialResults;
        } else {
            camera_metadata_entry_t entry;
            entry = frame.mMetadata.find(ANDROID_QUIRKS_PARTIAL_RESULT);
            if (entry.count > 0 &&
                    entry.data.u8[0] == ANDROID_QUIRKS_PARTIAL_RESULT_PARTIAL) {
            partialResult = true;
                isPartialResult = true;
            }
        }
    }

    if (!partialResult && processFaceDetect(frame.mMetadata, client) != OK) {
    if (!isPartialResult && processFaceDetect(frame.mMetadata, client) != OK) {
        return false;
    }

+2 −2
Original line number Diff line number Diff line
@@ -91,8 +91,8 @@ class FrameProcessor : public FrameProcessorBase {
        }
    } m3aState;

    // Whether the partial result quirk is enabled for this device
    bool mUsePartialQuirk;
    // Whether the partial result is enabled for this device
    bool mUsePartialResult;

    // Track most recent frame number for which 3A notifications were sent for.
    // Used to filter against sending 3A notifications for the same frame
+2 −2
Original line number Diff line number Diff line
@@ -94,14 +94,14 @@ void ZslProcessor3::onResultAvailable(const CaptureResult &result) {
    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");
        ALOGE("%s: metadata doesn't have timestamp, skip this result", __FUNCTION__);
        return;
    }
    (void)timestamp;

    entry = result.mMetadata.find(ANDROID_REQUEST_FRAME_COUNT);
    if (entry.count == 0) {
        ALOGE("%s: metadata doesn't have frame number, skip this result");
        ALOGE("%s: metadata doesn't have frame number, skip this result", __FUNCTION__);
        return;
    }
    int32_t frameNumber = entry.data.i32[0];
Loading