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

Commit a77166b9 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Camera: Add support for stream combination query"

parents 2b45d00c 40a8c6ed
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -452,6 +452,16 @@ int CameraModule::setTorchMode(const char* camera_id, bool enable) {
    return res;
}

int CameraModule::isStreamCombinationSupported(int cameraId, camera_stream_combination_t *streams) {
    int res = INVALID_OPERATION;
    if (mModule->is_stream_combination_supported != NULL) {
        ATRACE_BEGIN("camera_module->is_stream_combination_supported");
        res = mModule->is_stream_combination_supported(cameraId, streams);
        ATRACE_END();
    }
    return res;
}

status_t CameraModule::filterOpenErrorCode(status_t err) {
    switch(err) {
        case NO_ERROR:
+1 −0
Original line number Diff line number Diff line
@@ -66,6 +66,7 @@ public:
    // Only used by CameraProvider
    void removeCamera(int cameraId);
    int getPhysicalCameraInfo(int physicalCameraId, camera_metadata_t **physicalInfo);
    int isStreamCombinationSupported(int cameraId, camera_stream_combination_t *streams);

private:
    // Derive camera characteristics keys defined after HAL device version
+21 −8
Original line number Diff line number Diff line
@@ -2163,7 +2163,8 @@ void ExternalCameraDeviceSession::updateBufferCaches(const hidl_vec<BufferCache>
    }
}

bool ExternalCameraDeviceSession::isSupported(const Stream& stream) {
bool ExternalCameraDeviceSession::isSupported(const Stream& stream,
        const std::vector<SupportedV4L2Format>& supportedFormats) {
    int32_t ds = static_cast<int32_t>(stream.dataSpace);
    PixelFormat fmt = stream.format;
    uint32_t width = stream.width;
@@ -2206,7 +2207,7 @@ bool ExternalCameraDeviceSession::isSupported(const Stream& stream) {
    // Assume we can convert any V4L2 format to any of supported output format for now, i.e,
    // ignoring v4l2Fmt.fourcc for now. Might need more subtle check if we support more v4l format
    // in the futrue.
    for (const auto& v4l2Fmt : mSupportedFormats) {
    for (const auto& v4l2Fmt : supportedFormats) {
        if (width == v4l2Fmt.width && height == v4l2Fmt.height) {
            return true;
        }
@@ -2541,11 +2542,9 @@ void ExternalCameraDeviceSession::enqueueV4l2Frame(const sp<V4L2Frame>& frame) {
    mV4L2BufferReturned.notify_one();
}

Status ExternalCameraDeviceSession::configureStreams(
Status ExternalCameraDeviceSession::isStreamCombinationSupported(
        const V3_2::StreamConfiguration& config,
        V3_3::HalStreamConfiguration* out,
        uint32_t blobBufferSize) {
    ATRACE_CALL();
        const std::vector<SupportedV4L2Format>& supportedFormats) {
    if (config.operationMode != StreamConfigurationMode::NORMAL_MODE) {
        ALOGE("%s: unsupported operation mode: %d", __FUNCTION__, config.operationMode);
        return Status::ILLEGAL_ARGUMENT;
@@ -2560,7 +2559,7 @@ Status ExternalCameraDeviceSession::configureStreams(
    int numStallStream = 0;
    for (const auto& stream : config.streams) {
        // Check if the format/width/height combo is supported
        if (!isSupported(stream)) {
        if (!isSupported(stream, supportedFormats)) {
            return Status::ILLEGAL_ARGUMENT;
        }
        if (stream.format == PixelFormat::BLOB) {
@@ -2582,7 +2581,21 @@ Status ExternalCameraDeviceSession::configureStreams(
        return Status::ILLEGAL_ARGUMENT;
    }

    Status status = initStatus();
    return Status::OK;
}

Status ExternalCameraDeviceSession::configureStreams(
        const V3_2::StreamConfiguration& config,
        V3_3::HalStreamConfiguration* out,
        uint32_t blobBufferSize) {
    ATRACE_CALL();

    Status status = isStreamCombinationSupported(config, mSupportedFormats);
    if (status != Status::OK) {
        return status;
    }

    status = initStatus();
    if (status != Status::OK) {
        return status;
    }
+4 −1
Original line number Diff line number Diff line
@@ -193,13 +193,16 @@ protected:
    int configureV4l2StreamLocked(const SupportedV4L2Format& fmt, double fps = 0.0);
    int v4l2StreamOffLocked();
    int setV4l2FpsLocked(double fps);
    static Status isStreamCombinationSupported(const V3_2::StreamConfiguration& config,
            const std::vector<SupportedV4L2Format>& supportedFormats);

    // TODO: change to unique_ptr for better tracking
    sp<V4L2Frame> dequeueV4l2FrameLocked(/*out*/nsecs_t* shutterTs); // Called with mLock hold
    void enqueueV4l2Frame(const sp<V4L2Frame>&);

    // Check if input Stream is one of supported stream setting on this device
    bool isSupported(const Stream&);
    static bool isSupported(const Stream& stream,
            const std::vector<SupportedV4L2Format>& supportedFormats);

    // Validate and import request's output buffers and acquire fence
    virtual Status importRequestLocked(
+38 −0
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@ package android.hardware.camera.device@3.5;
import android.hardware.camera.common@1.0::Status;
import @3.2::CameraMetadata;
import @3.2::ICameraDevice;
import @3.4::StreamConfiguration;

/**
 * Camera device interface
@@ -75,4 +76,41 @@ interface ICameraDevice extends @3.2::ICameraDevice {
    getPhysicalCameraCharacteristics(string physicalCameraId)
            generates (Status status, CameraMetadata cameraCharacteristics);


    /**
     * isStreamCombinationSupported:
     *
     * Check for device support of specific camera stream combination.
     *
     * The streamList must contain at least one output-capable stream, and may
     * not contain more than one input-capable stream.
     *
     * ------------------------------------------------------------------------
     *
     * Preconditions:
     *
     * The framework can call this method at any time before, during and
     * after active session configuration. This means that calls must not
     * impact 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:
     * This call is expected to be significantly faster than stream
     * configuration. In general HW and SW camera settings must not be
     * changed and there must not be a user-visible impact on camera performance.
     *
     * @return Status Status code for the operation, one of:
     *     OK:
     *          On successful stream combination query.
     *     METHOD_NOT_SUPPORTED:
     *          The camera device does not support stream combination query.
     *     INTERNAL_ERROR:
     *          The stream combination query cannot complete due to internal
     *          error.
     * @return true in case the stream combination is supported, false otherwise.
     *
     */
    isStreamCombinationSupported(@3.4::StreamConfiguration streams)
            generates (Status status, bool queryStatus);
};
Loading