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

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

Merge "Camera: Add external camera provider"

parents 6d2d1307 19030595
Loading
Loading
Loading
Loading
+59 −0
Original line number Diff line number Diff line
@@ -134,6 +134,65 @@ void HandleImporter::closeFence(int fd) const {
    }
}

YCbCrLayout HandleImporter::lockYCbCr(
        buffer_handle_t& buf, uint64_t cpuUsage,
        const IMapper::Rect& accessRegion) {
    Mutex::Autolock lock(mLock);
    YCbCrLayout layout = {};

    if (!mInitialized) {
        initializeLocked();
    }

    if (mMapper == nullptr) {
        ALOGE("%s: mMapper is null!", __FUNCTION__);
        return layout;
    }

    hidl_handle acquireFenceHandle;
    auto buffer = const_cast<native_handle_t*>(buf);
    mMapper->lockYCbCr(buffer, cpuUsage, accessRegion, acquireFenceHandle,
            [&](const auto& tmpError, const auto& tmpLayout) {
                if (tmpError == MapperError::NONE) {
                    layout = tmpLayout;
                } else {
                    ALOGE("%s: failed to lockYCbCr error %d!", __FUNCTION__, tmpError);
                }
           });

    ALOGV("%s: layout y %p cb %p cr %p y_str %d c_str %d c_step %d",
            __FUNCTION__, layout.y, layout.cb, layout.cr,
            layout.yStride, layout.cStride, layout.chromaStep);
    return layout;
}

int HandleImporter::unlock(buffer_handle_t& buf) {
    int releaseFence = -1;
    auto buffer = const_cast<native_handle_t*>(buf);
    mMapper->unlock(
        buffer, [&](const auto& tmpError, const auto& tmpReleaseFence) {
            if (tmpError == MapperError::NONE) {
                auto fenceHandle = tmpReleaseFence.getNativeHandle();
                if (fenceHandle) {
                    if (fenceHandle->numInts != 0 || fenceHandle->numFds != 1) {
                        ALOGE("%s: bad release fence numInts %d numFds %d",
                                __FUNCTION__, fenceHandle->numInts, fenceHandle->numFds);
                        return;
                    }
                    releaseFence = dup(fenceHandle->data[0]);
                    if (releaseFence <= 0) {
                        ALOGE("%s: bad release fence FD %d",
                                __FUNCTION__, releaseFence);
                    }
                }
            } else {
                ALOGE("%s: failed to unlock error %d!", __FUNCTION__, tmpError);
            }
        });

    return releaseFence;
}

} // namespace helper
} // namespace V1_0
} // namespace common
+8 −1
Original line number Diff line number Diff line
@@ -22,6 +22,7 @@
#include <cutils/native_handle.h>

using android::hardware::graphics::mapper::V2_0::IMapper;
using android::hardware::graphics::mapper::V2_0::YCbCrLayout;

namespace android {
namespace hardware {
@@ -43,6 +44,12 @@ public:
    bool importFence(const native_handle_t* handle, int& fd) const;
    void closeFence(int fd) const;

    // Assume caller has done waiting for acquire fences
    YCbCrLayout lockYCbCr(buffer_handle_t& buf, uint64_t cpuUsage,
                          const IMapper::Rect& accessRegion);

    int unlock(buffer_handle_t& buf); // returns release fence

private:
    void initializeLocked();
    void cleanup();
+44 −1
Original line number Diff line number Diff line
@@ -17,7 +17,13 @@
cc_library_headers {
    name: "camera.device@3.4-impl_headers",
    vendor: true,
    export_include_dirs: ["include/device_v3_4_impl"],
    export_include_dirs: ["include/device_v3_4_impl"]
}

cc_library_headers {
    name: "camera.device@3.4-external-impl_headers",
    vendor: true,
    export_include_dirs: ["include/ext_device_v3_4_impl"]
}

cc_library_shared {
@@ -55,3 +61,40 @@ cc_library_shared {
        "libfmq",
    ],
}

cc_library_shared {
    name: "camera.device@3.4-external-impl",
    defaults: ["hidl_defaults"],
    proprietary: true,
    vendor: true,
    srcs: [
        "ExternalCameraDevice.cpp",
        "ExternalCameraDeviceSession.cpp"
    ],
    shared_libs: [
        "libhidlbase",
        "libhidltransport",
        "libutils",
        "libcutils",
        "camera.device@3.2-impl",
        "camera.device@3.3-impl",
        "android.hardware.camera.device@3.2",
        "android.hardware.camera.device@3.3",
        "android.hardware.camera.device@3.4",
        "android.hardware.camera.provider@2.4",
        "android.hardware.graphics.mapper@2.0",
        "liblog",
        "libhardware",
        "libcamera_metadata",
        "libfmq",
        "libsync",
        "libyuv",
    ],
    static_libs: [
        "android.hardware.camera.common@1.0-helper",
    ],
    local_include_dirs: ["include/ext_device_v3_4_impl"],
    export_shared_lib_headers: [
        "libfmq",
    ],
}
+793 −0

File added.

Preview size limit exceeded, changes collapsed.

+1990 −0

File added.

Preview size limit exceeded, changes collapsed.

Loading