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

Commit 050f5dcf authored by Emilian Peev's avatar Emilian Peev
Browse files

Camera: Switch usage flags to 64-bit unsigned

Usage flags should use 64-bit unsigned values.

Bug: 35215313
Test: Camera CTS
Change-Id: Ib8d8ec07e16698e34183c3e54498ad7491348087
parent 31abd0ae
Loading
Loading
Loading
Loading
+7 −8
Original line number Diff line number Diff line
@@ -570,7 +570,7 @@ binder::Status CameraDeviceClient::createDeferredSurfaceStreamLocked(
        /*out*/
        int* newStreamId) {
    int width, height, format, surfaceType;
    int32_t consumerUsage;
    uint64_t consumerUsage;
    android_dataspace dataSpace;
    status_t err;
    binder::Status res;
@@ -766,24 +766,23 @@ binder::Status CameraDeviceClient::createSurfaceFromGbp(
    // Query consumer usage bits to set async operation mode for
    // GLConsumer using controlledByApp parameter.
    bool useAsync = false;
    int32_t consumerUsage;
    uint64_t consumerUsage = 0;
    status_t err;
    if ((err = gbp->query(NATIVE_WINDOW_CONSUMER_USAGE_BITS,
            &consumerUsage)) != OK) {
    if ((err = gbp->getConsumerUsage(&consumerUsage)) != OK) {
        String8 msg = String8::format("Camera %s: Failed to query Surface consumer usage: %s (%d)",
                mCameraIdStr.string(), strerror(-err), err);
        ALOGE("%s: %s", __FUNCTION__, msg.string());
        return STATUS_ERROR(CameraService::ERROR_INVALID_OPERATION, msg.string());
    }
    if (consumerUsage & GraphicBuffer::USAGE_HW_TEXTURE) {
        ALOGW("%s: Camera %s with consumer usage flag: 0x%x: Forcing asynchronous mode for stream",
        ALOGW("%s: Camera %s with consumer usage flag: %" PRIu64 ": Forcing asynchronous mode for stream",
                __FUNCTION__, mCameraIdStr.string(), consumerUsage);
        useAsync = true;
    }

    int32_t disallowedFlags = GraphicBuffer::USAGE_HW_VIDEO_ENCODER |
    uint64_t disallowedFlags = GraphicBuffer::USAGE_HW_VIDEO_ENCODER |
                              GRALLOC_USAGE_RENDERSCRIPT;
    int32_t allowedFlags = GraphicBuffer::USAGE_SW_READ_MASK |
    uint64_t allowedFlags = GraphicBuffer::USAGE_SW_READ_MASK |
                           GraphicBuffer::USAGE_HW_TEXTURE |
                           GraphicBuffer::USAGE_HW_COMPOSER;
    bool flexibleConsumer = (consumerUsage & disallowedFlags) == 0 &&
@@ -876,7 +875,7 @@ binder::Status CameraDeviceClient::createSurfaceFromGbp(
        //surface class type. Use usage flag to approximate the comparison.
        if (consumerUsage != streamInfo.consumerUsage) {
            String8 msg = String8::format(
                    "Camera %s:Surface usage flag doesn't match 0x%x vs 0x%x",
                    "Camera %s:Surface usage flag doesn't match %" PRIu64 " vs %" PRIu64 "",
                    mCameraIdStr.string(), consumerUsage, streamInfo.consumerUsage);
            ALOGE("%s: %s", __FUNCTION__, msg.string());
            return STATUS_ERROR(CameraService::ERROR_ILLEGAL_ARGUMENT, msg.string());
+2 −2
Original line number Diff line number Diff line
@@ -213,13 +213,13 @@ private:
        int height;
        int format;
        android_dataspace dataSpace;
        int32_t consumerUsage;
        uint64_t consumerUsage;
        bool finalized = false;
        OutputStreamInfo() :
                width(-1), height(-1), format(-1), dataSpace(HAL_DATASPACE_UNKNOWN),
                consumerUsage(0) {}
        OutputStreamInfo(int _width, int _height, int _format, android_dataspace _dataSpace,
                int32_t _consumerUsage) :
                uint64_t _consumerUsage) :
                    width(_width), height(_height), format(_format),
                    dataSpace(_dataSpace), consumerUsage(_consumerUsage) {}
    };
+2 −2
Original line number Diff line number Diff line
@@ -119,7 +119,7 @@ class CameraDeviceBase : public virtual RefBase {
            uint32_t width, uint32_t height, int format,
            android_dataspace dataSpace, camera3_stream_rotation_t rotation, int *id,
            int streamSetId = camera3::CAMERA3_STREAM_SET_ID_INVALID,
            bool isShared = false, uint32_t consumerUsage = 0) = 0;
            bool isShared = false, uint64_t consumerUsage = 0) = 0;

    /**
     * Create an output stream of the requested size, format, rotation and
@@ -132,7 +132,7 @@ class CameraDeviceBase : public virtual RefBase {
            bool hasDeferredConsumer, uint32_t width, uint32_t height, int format,
            android_dataspace dataSpace, camera3_stream_rotation_t rotation, int *id,
            int streamSetId = camera3::CAMERA3_STREAM_SET_ID_INVALID,
            bool isShared = false, uint32_t consumerUsage = 0) = 0;
            bool isShared = false, uint64_t consumerUsage = 0) = 0;

    /**
     * Create an input stream of width, height, and format.
+1 −1
Original line number Diff line number Diff line
@@ -361,7 +361,7 @@ CameraHardwareInterface::setUsage(hardware::graphics::common::V1_0::BufferUsage
        ALOGE("%s: preview window is null", __FUNCTION__);
        return s;
    }
    mPreviewUsage = (int) usage;
    mPreviewUsage = static_cast<uint64_t> (usage);
    int rc = native_window_set_usage(a, mPreviewUsage);
    if (rc == OK) {
        cleanupCirculatingBuffers();
+1 −1
Original line number Diff line number Diff line
@@ -435,7 +435,7 @@ private:
    int mPreviewWidth;
    int mPreviewHeight;
    int mPreviewFormat;
    int mPreviewUsage;
    uint64_t mPreviewUsage;
    int mPreviewSwapInterval;
    android_native_rect_t mPreviewCrop;

Loading