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

Commit f2a74aad authored by Yin-Chia Yeh's avatar Yin-Chia Yeh Committed by Android (Google) Code Review
Browse files

Merge "Camera2: improve ZSL candidate selection logic" into lmp-dev

parents 095da43d dec84fb1
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -1291,6 +1291,9 @@ status_t Camera2Client::cancelAutoFocus() {

            return OK;
        }
        if (l.mParameters.zslMode) {
            mZslProcessor->clearZslQueue();
        }
    }
    syncWithDevice();

@@ -1379,8 +1382,14 @@ status_t Camera2Client::setParameters(const String8& params) {

    SharedParameters::Lock l(mParameters);

    Parameters::focusMode_t focusModeBefore = l.mParameters.focusMode;
    res = l.mParameters.set(params);
    if (res != OK) return res;
    Parameters::focusMode_t focusModeAfter = l.mParameters.focusMode;

    if (l.mParameters.zslMode && focusModeAfter != focusModeBefore) {
        mZslProcessor->clearZslQueue();
    }

    res = updateRequests(l.mParameters);

+27 −2
Original line number Diff line number Diff line
@@ -457,6 +457,23 @@ void ZslProcessor3::dumpZslQueue(int fd) const {
    }
}

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
@@ -502,8 +519,16 @@ nsecs_t ZslProcessor3::getCandidateTimestampLocked(size_t* metadataIdx) const {
                    continue;
                }

                // Check AF state if device has focuser
                if (mHasFocuser) {
                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];

                // 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) {
+2 −0
Original line number Diff line number Diff line
@@ -133,6 +133,8 @@ class ZslProcessor3 :
    void dumpZslQueue(int id) const;

    nsecs_t getCandidateTimestampLocked(size_t* metadataIdx) const;

    bool isFixedFocusMode(uint8_t afMode) const;
};