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

Commit 332467b8 authored by Emilian Peev's avatar Emilian Peev Committed by Android (Google) Code Review
Browse files

Merge "Camera: Enable session parameter reconfiguration queries"

parents d4ef9218 22eac5f6
Loading
Loading
Loading
Loading
+46 −0
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
package android.hardware.camera.device@3.5;

import android.hardware.camera.common@1.0::Status;
import @3.2::CameraMetadata;
import @3.4::ICameraDeviceSession;
import @3.4::HalStreamConfiguration;

@@ -99,4 +100,49 @@ interface ICameraDeviceSession extends @3.4::ICameraDeviceSession {
        vec<int32_t> streamIds,
        uint32_t streamConfigCounter
    );

    /**
     * isReconfigurationRequired:
     *
     * Check whether complete stream reconfiguration is required for possible new session
     * parameter values.
     *
     * This method must be called by the camera framework in case the client changes
     * the value of any advertised session parameters. Depending on the specific values
     * the HAL can decide whether a complete stream reconfiguration is required. In case
     * the HAL returns false, the camera framework must skip the internal reconfiguration.
     * In case Hal returns true, the framework must reconfigure the streams and pass the
     * new session parameter values accordingly.
     * This call may be done by the framework some time before the request with new parameters
     * is submitted to the HAL, and the request may be cancelled before it ever gets submitted.
     * Therefore, the HAL must not use this query as an indication to change its behavior in any
     * way.
     * ------------------------------------------------------------------------
     *
     * Preconditions:
     *
     * The framework can call this method at any time after active
     * session configuration. There must be no impact on the performance of
     * pending camera requests in any way. In particular there must not be
     * any glitches or delays during normal camera streaming.
     *
     * Performance requirements:
     * HW and SW camera settings must not be changed and there must not be
     * a user-visible impact on camera performance.
     *
     * @param oldSessionParams Before session parameters, usually the current session parameters.
     * @param newSessionParams The new session parameters which may be set by client.
     *
     * @return Status Status code for the operation, one of:
     *     OK:
     *          On successful reconfiguration required query.
     *     METHOD_NOT_SUPPORTED:
     *          The camera device does not support the reconfiguration query.
     *     INTERNAL_ERROR:
     *          The reconfiguration query cannot complete due to internal
     *          error.
     * @return true in case the stream reconfiguration is required, false otherwise.
     */
    isReconfigurationRequired(CameraMetadata oldSessionParams, CameraMetadata newSessionParams)
            generates(Status status, bool reconfigurationNeeded);
};
+29 −0
Original line number Diff line number Diff line
@@ -356,6 +356,35 @@ void CameraDeviceSession::sReturnStreamBuffers(
    d->returnStreamBuffers(num_buffers, buffers);
}

Return<void> CameraDeviceSession::isReconfigurationRequired(
        const V3_2::CameraMetadata& oldSessionParams, const V3_2::CameraMetadata& newSessionParams,
        ICameraDeviceSession::isReconfigurationRequired_cb _hidl_cb) {
    if (mDevice->ops->is_reconfiguration_required != nullptr) {
        const camera_metadata_t *oldParams, *newParams;
        V3_2::implementation::convertFromHidl(oldSessionParams, &oldParams);
        V3_2::implementation::convertFromHidl(newSessionParams, &newParams);
        auto ret = mDevice->ops->is_reconfiguration_required(mDevice, oldParams, newParams);
        switch (ret) {
            case 0:
                _hidl_cb(Status::OK, true);
                break;
            case -EINVAL:
                _hidl_cb(Status::OK, false);
                break;
            case -ENOSYS:
                _hidl_cb(Status::METHOD_NOT_SUPPORTED, true);
                break;
            default:
                _hidl_cb(Status::INTERNAL_ERROR, true);
                break;
        };
    } else {
        _hidl_cb(Status::METHOD_NOT_SUPPORTED, true);
    }

    return Void();
}

} // namespace implementation
}  // namespace V3_5
}  // namespace device
+9 −0
Original line number Diff line number Diff line
@@ -295,6 +295,15 @@ int ExternalCameraDeviceSession::OutputThread::waitForBufferRequestDone(
    return 0;
}

Return<void> ExternalCameraDeviceSession::isReconfigurationRequired(
        const V3_2::CameraMetadata& /*oldSessionParams*/,
        const V3_2::CameraMetadata& /*newSessionParams*/,
        ICameraDeviceSession::isReconfigurationRequired_cb _hidl_cb) {
    //Stub implementation
    _hidl_cb(Status::OK, true);
    return Void();
}

} // namespace implementation
}  // namespace V3_5
}  // namespace device
+8 −0
Original line number Diff line number Diff line
@@ -93,6 +93,9 @@ protected:
            hidl_vec<buffer_handle_t*>& allBufPtrs,
            hidl_vec<int>& allFences) override;

    Return<void> isReconfigurationRequired(const V3_2::CameraMetadata& oldSessionParams,
            const V3_2::CameraMetadata& newSessionParams,
            ICameraDeviceSession::isReconfigurationRequired_cb _hidl_cb);
    /**
     * Static callback forwarding methods from HAL to instance
     */
@@ -238,6 +241,11 @@ private:
            return mParent->signalStreamFlush(requests, streamConfigCounter);
        }

        virtual Return<void> isReconfigurationRequired(const V3_2::CameraMetadata& oldSessionParams,
                const V3_2::CameraMetadata& newSessionParams,
                ICameraDeviceSession::isReconfigurationRequired_cb _hidl_cb) override {
            return mParent->isReconfigurationRequired(oldSessionParams, newSessionParams, _hidl_cb);
        }
    private:
        sp<CameraDeviceSession> mParent;
    };
+10 −0
Original line number Diff line number Diff line
@@ -106,6 +106,10 @@ protected:
            const hidl_vec<int32_t>& requests,
            uint32_t streamConfigCounter);

    Return<void> isReconfigurationRequired(const V3_2::CameraMetadata& oldSessionParams,
            const V3_2::CameraMetadata& newSessionParams,
            ICameraDeviceSession::isReconfigurationRequired_cb _hidl_cb);

    virtual void initOutputThread() override;
    virtual void closeOutputThread() override;
    void closeOutputThreadImpl();
@@ -247,6 +251,12 @@ private:
            return mParent->signalStreamFlush(requests, streamConfigCounter);
        }

        virtual Return<void> isReconfigurationRequired(const V3_2::CameraMetadata& oldSessionParams,
                const V3_2::CameraMetadata& newSessionParams,
                ICameraDeviceSession::isReconfigurationRequired_cb _hidl_cb) override {
            return mParent->isReconfigurationRequired(oldSessionParams, newSessionParams, _hidl_cb);
        }

    private:
        sp<ExternalCameraDeviceSession> mParent;
    };
Loading