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

Commit 565fe886 authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge "DO NOT MERGE - Merge pie-platform-release (PPRL.181205.001) into master"

parents 0f2911a5 5c60a308
Loading
Loading
Loading
Loading
+49 −1
Original line number Original line Diff line number Diff line
@@ -53,6 +53,7 @@ CameraDeviceSession::CameraDeviceSession(
        camera3_callback_ops({&sProcessCaptureResult, &sNotify}),
        camera3_callback_ops({&sProcessCaptureResult, &sNotify}),
        mDevice(device),
        mDevice(device),
        mDeviceVersion(device->common.version),
        mDeviceVersion(device->common.version),
        mFreeBufEarly(shouldFreeBufEarly()),
        mIsAELockAvailable(false),
        mIsAELockAvailable(false),
        mDerivePostRawSensKey(false),
        mDerivePostRawSensKey(false),
        mNumPartialResults(1),
        mNumPartialResults(1),
@@ -129,6 +130,10 @@ bool CameraDeviceSession::initialize() {
    return false;
    return false;
}
}


bool CameraDeviceSession::shouldFreeBufEarly() {
    return property_get_bool("ro.vendor.camera.free_buf_early", 0) == 1;
}

CameraDeviceSession::~CameraDeviceSession() {
CameraDeviceSession::~CameraDeviceSession() {
    if (!isClosed()) {
    if (!isClosed()) {
        ALOGE("CameraDeviceSession deleted before close!");
        ALOGE("CameraDeviceSession deleted before close!");
@@ -887,6 +892,24 @@ bool CameraDeviceSession::preProcessConfigurationLocked(
        (*streams)[i] = &mStreamMap[id];
        (*streams)[i] = &mStreamMap[id];
    }
    }


    if (mFreeBufEarly) {
        // Remove buffers of deleted streams
        for(auto it = mStreamMap.begin(); it != mStreamMap.end(); it++) {
            int id = it->first;
            bool found = false;
            for (const auto& stream : requestedConfiguration.streams) {
                if (id == stream.id) {
                    found = true;
                    break;
                }
            }
            if (!found) {
                // Unmap all buffers of deleted stream
                cleanupBuffersLocked(id);
            }
        }
    }

    return true;
    return true;
}
}


@@ -908,7 +931,9 @@ void CameraDeviceSession::postProcessConfigurationLocked(
            // Unmap all buffers of deleted stream
            // Unmap all buffers of deleted stream
            // in case the configuration call succeeds and HAL
            // in case the configuration call succeeds and HAL
            // is able to release the corresponding resources too.
            // is able to release the corresponding resources too.
            if (!mFreeBufEarly) {
                cleanupBuffersLocked(id);
                cleanupBuffersLocked(id);
            }
            it = mStreamMap.erase(it);
            it = mStreamMap.erase(it);
        } else {
        } else {
            ++it;
            ++it;
@@ -927,6 +952,27 @@ void CameraDeviceSession::postProcessConfigurationLocked(
    mResultBatcher.setBatchedStreams(mVideoStreamIds);
    mResultBatcher.setBatchedStreams(mVideoStreamIds);
}
}



void CameraDeviceSession::postProcessConfigurationFailureLocked(
        const StreamConfiguration& requestedConfiguration) {
    if (mFreeBufEarly) {
        // Re-build the buf cache entry for deleted streams
        for(auto it = mStreamMap.begin(); it != mStreamMap.end(); it++) {
            int id = it->first;
            bool found = false;
            for (const auto& stream : requestedConfiguration.streams) {
                if (id == stream.id) {
                    found = true;
                    break;
                }
            }
            if (!found) {
                mCirculatingBuffers.emplace(id, CirculatingBuffers{});
            }
        }
    }
}

Return<void> CameraDeviceSession::configureStreams(
Return<void> CameraDeviceSession::configureStreams(
        const StreamConfiguration& requestedConfiguration,
        const StreamConfiguration& requestedConfiguration,
        ICameraDeviceSession::configureStreams_cb _hidl_cb)  {
        ICameraDeviceSession::configureStreams_cb _hidl_cb)  {
@@ -979,6 +1025,8 @@ Return<void> CameraDeviceSession::configureStreams(
    // the corresponding resources of the deleted streams.
    // the corresponding resources of the deleted streams.
    if (ret == OK) {
    if (ret == OK) {
        postProcessConfigurationLocked(requestedConfiguration);
        postProcessConfigurationLocked(requestedConfiguration);
    } else {
        postProcessConfigurationFailureLocked(requestedConfiguration);
    }
    }


    if (ret == -EINVAL) {
    if (ret == -EINVAL) {
+5 −0
Original line number Original line Diff line number Diff line
@@ -120,6 +120,8 @@ protected:
            hidl_vec<camera3_stream_t*> *streams /*out*/);
            hidl_vec<camera3_stream_t*> *streams /*out*/);
    void postProcessConfigurationLocked(const StreamConfiguration& requestedConfiguration);
    void postProcessConfigurationLocked(const StreamConfiguration& requestedConfiguration);


    void postProcessConfigurationFailureLocked(const StreamConfiguration& requestedConfiguration);

protected:
protected:


    // protecting mClosed/mDisconnected/mInitFail
    // protecting mClosed/mDisconnected/mInitFail
@@ -142,6 +144,7 @@ protected:


    camera3_device_t* mDevice;
    camera3_device_t* mDevice;
    const uint32_t mDeviceVersion;
    const uint32_t mDeviceVersion;
    const bool mFreeBufEarly;
    bool mIsAELockAvailable;
    bool mIsAELockAvailable;
    bool mDerivePostRawSensKey;
    bool mDerivePostRawSensKey;
    uint32_t mNumPartialResults;
    uint32_t mNumPartialResults;
@@ -293,6 +296,8 @@ protected:


    bool initialize();
    bool initialize();


    static bool shouldFreeBufEarly();

    Status initStatus() const;
    Status initStatus() const;


    // Validate and import request's input buffer and acquire fence
    // Validate and import request's input buffer and acquire fence
+2 −0
Original line number Original line Diff line number Diff line
@@ -92,6 +92,8 @@ Return<void> CameraDeviceSession::configureStreams_3_3(
    // the corresponding resources of the deleted streams.
    // the corresponding resources of the deleted streams.
    if (ret == OK) {
    if (ret == OK) {
        postProcessConfigurationLocked(requestedConfiguration);
        postProcessConfigurationLocked(requestedConfiguration);
    } else {
        postProcessConfigurationFailureLocked(requestedConfiguration);
    }
    }


    if (ret == -EINVAL) {
    if (ret == -EINVAL) {
+42 −1
Original line number Original line Diff line number Diff line
@@ -154,6 +154,8 @@ Return<void> CameraDeviceSession::configureStreams_3_4(
    // the corresponding resources of the deleted streams.
    // the corresponding resources of the deleted streams.
    if (ret == OK) {
    if (ret == OK) {
        postProcessConfigurationLocked_3_4(requestedConfiguration);
        postProcessConfigurationLocked_3_4(requestedConfiguration);
    } else {
        postProcessConfigurationFailureLocked_3_4(requestedConfiguration);
    }
    }


    if (ret == -EINVAL) {
    if (ret == -EINVAL) {
@@ -215,6 +217,23 @@ bool CameraDeviceSession::preProcessConfigurationLocked_3_4(
        (*streams)[i] = &mStreamMap[id];
        (*streams)[i] = &mStreamMap[id];
    }
    }


    if (mFreeBufEarly) {
        // Remove buffers of deleted streams
        for(auto it = mStreamMap.begin(); it != mStreamMap.end(); it++) {
            int id = it->first;
            bool found = false;
            for (const auto& stream : requestedConfiguration.streams) {
                if (id == stream.v3_2.id) {
                    found = true;
                    break;
                }
            }
            if (!found) {
                // Unmap all buffers of deleted stream
                cleanupBuffersLocked(id);
            }
        }
    }
    return true;
    return true;
}
}


@@ -236,7 +255,9 @@ void CameraDeviceSession::postProcessConfigurationLocked_3_4(
            // Unmap all buffers of deleted stream
            // Unmap all buffers of deleted stream
            // in case the configuration call succeeds and HAL
            // in case the configuration call succeeds and HAL
            // is able to release the corresponding resources too.
            // is able to release the corresponding resources too.
            if (!mFreeBufEarly) {
                cleanupBuffersLocked(id);
                cleanupBuffersLocked(id);
            }
            it = mStreamMap.erase(it);
            it = mStreamMap.erase(it);
        } else {
        } else {
            ++it;
            ++it;
@@ -255,6 +276,26 @@ void CameraDeviceSession::postProcessConfigurationLocked_3_4(
    mResultBatcher_3_4.setBatchedStreams(mVideoStreamIds);
    mResultBatcher_3_4.setBatchedStreams(mVideoStreamIds);
}
}


void CameraDeviceSession::postProcessConfigurationFailureLocked_3_4(
        const StreamConfiguration& requestedConfiguration) {
    if (mFreeBufEarly) {
        // Re-build the buf cache entry for deleted streams
        for(auto it = mStreamMap.begin(); it != mStreamMap.end(); it++) {
            int id = it->first;
            bool found = false;
            for (const auto& stream : requestedConfiguration.streams) {
                if (id == stream.v3_2.id) {
                    found = true;
                    break;
                }
            }
            if (!found) {
                mCirculatingBuffers.emplace(id, CirculatingBuffers{});
            }
        }
    }
}

Return<void> CameraDeviceSession::processCaptureRequest_3_4(
Return<void> CameraDeviceSession::processCaptureRequest_3_4(
        const hidl_vec<V3_4::CaptureRequest>& requests,
        const hidl_vec<V3_4::CaptureRequest>& requests,
        const hidl_vec<V3_2::BufferCache>& cachesToRemove,
        const hidl_vec<V3_2::BufferCache>& cachesToRemove,
+2 −0
Original line number Original line Diff line number Diff line
@@ -84,6 +84,8 @@ protected:
            camera3_stream_configuration_t *stream_list /*out*/,
            camera3_stream_configuration_t *stream_list /*out*/,
            hidl_vec<camera3_stream_t*> *streams /*out*/);
            hidl_vec<camera3_stream_t*> *streams /*out*/);
    void postProcessConfigurationLocked_3_4(const StreamConfiguration& requestedConfiguration);
    void postProcessConfigurationLocked_3_4(const StreamConfiguration& requestedConfiguration);
    void postProcessConfigurationFailureLocked_3_4(
            const StreamConfiguration& requestedConfiguration);


    Return<void> processCaptureRequest_3_4(
    Return<void> processCaptureRequest_3_4(
            const hidl_vec<V3_4::CaptureRequest>& requests,
            const hidl_vec<V3_4::CaptureRequest>& requests,