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

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

Merge "Merge redfin/bramble support."

parents 1c3dcd32 625bfc25
Loading
Loading
Loading
Loading
+6 −3
Original line number Diff line number Diff line
@@ -4453,8 +4453,11 @@ void CameraHidlTest::processCaptureRequestInternal(uint64_t bufferUsage,
                            nullptr};
        } else {
            allocateGraphicBuffer(testStream.width, testStream.height,
                    android_convertGralloc1To0Usage(halStreamConfig.streams[0].producerUsage,
                        halStreamConfig.streams[0].consumerUsage),
                                  /* We don't look at halStreamConfig.streams[0].consumerUsage
                                   * since that is 0 for output streams
                                   */
                                  android_convertGralloc1To0Usage(
                                          halStreamConfig.streams[0].producerUsage, bufferUsage),
                                  halStreamConfig.streams[0].overrideFormat, &buffer_handle);
            outputBuffer = {halStreamConfig.streams[0].id,
                            bufferId,
+5 −3
Original line number Diff line number Diff line
@@ -256,8 +256,10 @@ TEST_P(GnssHalTest, TestGnssSvInfoFields) {
    ALOGD("Observed %d GnssSvStatus, while awaiting one location (%d received)",
          sv_info_list_cbq_size, location_called_count);

    hidl_vec<IGnssCallback_2_1::GnssSvInfo> last_sv_info_list;
    ASSERT_TRUE(gnss_cb_->sv_info_list_cbq_.retrieve(last_sv_info_list, 1));
    // Get the last sv_info_list
    std::list<hidl_vec<IGnssCallback_2_1::GnssSvInfo>> sv_info_vec_list;
    gnss_cb_->sv_info_list_cbq_.retrieve(sv_info_vec_list, sv_info_list_cbq_size, 1);
    hidl_vec<IGnssCallback_2_1::GnssSvInfo> last_sv_info_list = sv_info_vec_list.back();

    bool nonZeroCn0Found = false;
    for (auto sv_info : last_sv_info_list) {
+5 −13
Original line number Diff line number Diff line
@@ -22,28 +22,24 @@ cc_library_static {
    export_header_lib_headers: ["media_plugin_headers"],
    export_include_dirs: ["."],

    shared_libs: [
        "libui",
    ],

    static_libs: [
        "libgtest",
        "libhidlmemory",
        "android.hidl.allocator@1.0",
        "android.hidl.memory@1.0",
        "android.hardware.media.omx@1.0",
        "android.hardware.graphics.allocator@2.0",
        "android.hardware.graphics.allocator@3.0",
        "android.hardware.graphics.common@1.0",
        "android.hardware.graphics.common@1.1",
        "android.hardware.graphics.common@1.2",
        "android.hardware.graphics.mapper@2.0",
        "android.hardware.graphics.mapper@3.0",
    ],
    export_static_lib_headers: [
        "android.hardware.graphics.allocator@2.0",
        "android.hardware.graphics.allocator@3.0",
        "android.hardware.graphics.common@1.0",
        "android.hardware.graphics.common@1.1",
        "android.hardware.graphics.common@1.2",
        "android.hardware.graphics.mapper@2.0",
        "android.hardware.graphics.mapper@3.0",
    ],
}

@@ -54,15 +50,10 @@ cc_defaults {
    // Link to these statically as they are not guaranteed to be on the device.
    static_libs: [
        "VtsHalMediaOmxV1_0CommonUtil",
        "android.hardware.graphics.allocator@2.0",
        "android.hardware.graphics.allocator@3.0",
        "android.hardware.graphics.common@1.0",
        "android.hardware.graphics.common@1.1",
        "android.hardware.graphics.common@1.2",
        "android.hardware.graphics.mapper@2.0",
        "android.hardware.graphics.mapper@3.0",
        "android.hardware.graphics.bufferqueue@1.0",
        "android.hardware.graphics.common@1.0",
        "android.hardware.media.omx@1.0",
        "android.hardware.media@1.0",
        "android.hidl.allocator@1.0",
@@ -73,6 +64,7 @@ cc_defaults {
    // TODO(b/64437680): Assume these libs are always available on the device.
    shared_libs: [
        "libnativehelper",
        "libui",
        "libstagefright_foundation",
        "libstagefright_omx_utils",
    ],
+20 −92
Original line number Diff line number Diff line
@@ -21,12 +21,6 @@

#include <android-base/logging.h>

#include <android/hardware/graphics/allocator/2.0/IAllocator.h>
#include <android/hardware/graphics/allocator/3.0/IAllocator.h>
#include <android/hardware/graphics/mapper/2.0/IMapper.h>
#include <android/hardware/graphics/mapper/2.0/types.h>
#include <android/hardware/graphics/mapper/3.0/IMapper.h>
#include <android/hardware/graphics/mapper/3.0/types.h>
#include <android/hardware/media/omx/1.0/IOmx.h>
#include <android/hardware/media/omx/1.0/IOmxNode.h>
#include <android/hardware/media/omx/1.0/IOmxObserver.h>
@@ -199,42 +193,6 @@ void allocateGraphicBuffers(sp<IOmxNode> omxNode, OMX_U32 portIndex,
                            BufferInfo* buffer, uint32_t nFrameWidth,
                            uint32_t nFrameHeight, int32_t* nStride,
                            int format) {
    struct AllocatorV2 : public GrallocV2 {
        sp<IAllocator> mAllocator;
        sp<IMapper> mMapper;
        AllocatorV2(sp<IAllocator>&& allocator, sp<IMapper>&& mapper)
              : mAllocator{std::move(allocator)}, mMapper{std::move(mapper)} {}
        AllocatorV2() = default;
    };
    struct AllocatorV3 : public GrallocV3 {
        sp<IAllocator> mAllocator;
        sp<IMapper> mMapper;
        AllocatorV3(sp<IAllocator>&& allocator, sp<IMapper>&& mapper)
              : mAllocator{std::move(allocator)}, mMapper{std::move(mapper)} {}
        AllocatorV3() = default;
    };
    std::variant<AllocatorV2, AllocatorV3> grallocVar;

    sp<android::hardware::graphics::mapper::V2_0::IMapper> mapper2{};
    sp<android::hardware::graphics::mapper::V3_0::IMapper> mapper3{};
    sp<android::hardware::graphics::allocator::V2_0::IAllocator> allocator2{};
    sp<android::hardware::graphics::allocator::V3_0::IAllocator> allocator3 =
        android::hardware::graphics::allocator::V3_0::IAllocator::getService();
    if (allocator3) {
        mapper3 =
            android::hardware::graphics::mapper::V3_0::IMapper::getService();
        ASSERT_NE(nullptr, mapper3.get());
        grallocVar.emplace<AllocatorV3>(std::move(allocator3), std::move(mapper3));
    } else {
        allocator2 =
            android::hardware::graphics::allocator::V2_0::IAllocator::getService();
        ASSERT_NE(nullptr, allocator2.get());
        mapper2 =
            android::hardware::graphics::mapper::V2_0::IMapper::getService();
        ASSERT_NE(nullptr, allocator2.get());
        grallocVar.emplace<AllocatorV2>(std::move(allocator2), std::move(mapper2));
    }

    android::hardware::media::omx::V1_0::Status status{};
    uint64_t usage{};
    ASSERT_TRUE(omxNode->getGraphicBufferUsage(
@@ -246,57 +204,27 @@ void allocateGraphicBuffers(sp<IOmxNode> omxNode, OMX_U32 portIndex,
        }).isOk());
    ASSERT_EQ(status, android::hardware::media::omx::V1_0::Status::OK);

    static std::atomic_int32_t bufferIdCounter{0};
    uint32_t stride;
    buffer_handle_t handle = nullptr;
    android::GraphicBufferAllocator& allocator = android::GraphicBufferAllocator::get();
    android::status_t error = allocator.allocate(
            nFrameWidth, nFrameHeight, static_cast<android::PixelFormat>(format), 1,
            usage | BufferUsage::CPU_READ_OFTEN, &handle, &stride, "omx_vts_common");

    std::visit([buffer, nFrameWidth, nFrameHeight, format, usage, nStride](auto&& gralloc) {
            using Gralloc = std::remove_reference_t<decltype(gralloc)>;
            using Descriptor = typename Gralloc::Descriptor;
            using DescriptorInfo = typename Gralloc::DescriptorInfo;
            using Error = typename Gralloc::Error;
            using Format = typename Gralloc::Format;
            using Usage = typename Gralloc::Usage;

            Error error{};
            Descriptor descriptor{};

            DescriptorInfo descriptorInfo{};
            descriptorInfo.width = nFrameWidth;
            descriptorInfo.height = nFrameHeight;
            descriptorInfo.layerCount = 1;
            descriptorInfo.format = static_cast<Format>(format);
            descriptorInfo.usage = usage | Usage(BufferUsage::CPU_READ_OFTEN);

            gralloc.mMapper->createDescriptor(descriptorInfo,
                    [&error, &descriptor](
                        Error _s,
                        const Descriptor& _n1) {
                    error = _s;
                    descriptor = _n1;
                });
            ASSERT_EQ(error, Error::NONE);

            gralloc.mAllocator->allocate(
                descriptor, 1,
                [&](Error _s, uint32_t _n1,
                    const ::android::hardware::hidl_vec<
                        ::android::hardware::hidl_handle>& _n2) {
                    ASSERT_EQ(Error::NONE, _s);
                    *nStride = _n1;
                    buffer->omxBuffer.nativeHandle = _n2[0];
    ASSERT_EQ(error, android::NO_ERROR);
    ASSERT_NE(handle, nullptr);

    *nStride = static_cast<int32_t>(stride);
    buffer->omxBuffer.nativeHandle = handle;
    buffer->omxBuffer.attr.anwBuffer.width = nFrameWidth;
    buffer->omxBuffer.attr.anwBuffer.height = nFrameHeight;
                    buffer->omxBuffer.attr.anwBuffer.stride = _n1;
                    buffer->omxBuffer.attr.anwBuffer.format =
                        static_cast<PixelFormat>(descriptorInfo.format);
                    buffer->omxBuffer.attr.anwBuffer.usage =
                        static_cast<uint32_t>(descriptorInfo.usage);
                    buffer->omxBuffer.attr.anwBuffer.layerCount =
                        descriptorInfo.layerCount;
                    buffer->omxBuffer.attr.anwBuffer.id =
                        (static_cast<uint64_t>(getpid()) << 32) |
    buffer->omxBuffer.attr.anwBuffer.stride = stride;
    buffer->omxBuffer.attr.anwBuffer.format = static_cast<PixelFormat>(format);
    buffer->omxBuffer.attr.anwBuffer.usage = usage | BufferUsage::CPU_READ_OFTEN;
    buffer->omxBuffer.attr.anwBuffer.layerCount = 1;
    static std::atomic_int32_t bufferIdCounter{0};
    buffer->omxBuffer.attr.anwBuffer.id = (static_cast<uint64_t>(getpid()) << 32) |
                                          bufferIdCounter.fetch_add(1, std::memory_order_relaxed);
                });
        }, grallocVar);
}

// allocate buffers needed on a component port
+3 −39
Original line number Diff line number Diff line
@@ -22,16 +22,6 @@
#endif

#include <getopt.h>

#include <android/hardware/graphics/allocator/2.0/IAllocator.h>
#include <android/hardware/graphics/allocator/3.0/IAllocator.h>
#include <android/hardware/graphics/common/1.0/types.h>
#include <android/hardware/graphics/common/1.1/types.h>
#include <android/hardware/graphics/common/1.2/types.h>
#include <android/hardware/graphics/mapper/2.0/IMapper.h>
#include <android/hardware/graphics/mapper/2.0/types.h>
#include <android/hardware/graphics/mapper/3.0/IMapper.h>
#include <android/hardware/graphics/mapper/3.0/types.h>
#include <gtest/gtest.h>
#include <hidl/ServiceManagement.h>
#include <media/stagefright/foundation/ALooper.h>
@@ -46,6 +36,9 @@
#include <media/openmax/OMX_AudioExt.h>
#include <media/openmax/OMX_VideoExt.h>

#include <ui/GraphicBufferAllocator.h>
#include <ui/GraphicBufferMapper.h>

/* TIME OUTS (Wait time in dequeueMessage()) */

/* As component is switching states (loaded<->idle<->execute), dequeueMessage()
@@ -312,35 +305,6 @@ Return<android::hardware::media::omx::V1_0::Status> setPortConfig(
/*
 * common functions declarations
 */
struct GrallocV2 {
    using Format = android::hardware::graphics::common::V1_0::PixelFormat;
    using Usage = android::hardware::hidl_bitfield<
            android::hardware::graphics::common::V1_0::BufferUsage>;

    using IAllocator = android::hardware::graphics::allocator::V2_0::IAllocator;

    using IMapper = android::hardware::graphics::mapper::V2_0::IMapper;
    using Error = android::hardware::graphics::mapper::V2_0::Error;
    using Descriptor = android::hardware::graphics::mapper::V2_0::BufferDescriptor;
    using YCbCrLayout = android::hardware::graphics::mapper::V2_0::YCbCrLayout;
    using DescriptorInfo = IMapper::BufferDescriptorInfo;
    using Rect = IMapper::Rect;
};

struct GrallocV3 {
    using Format = android::hardware::graphics::common::V1_2::PixelFormat;
    using Usage = android::hardware::hidl_bitfield<
            android::hardware::graphics::common::V1_2::BufferUsage>;

    using IAllocator = android::hardware::graphics::allocator::V3_0::IAllocator;

    using IMapper = android::hardware::graphics::mapper::V3_0::IMapper;
    using Error = android::hardware::graphics::mapper::V3_0::Error;
    using Descriptor = android::hardware::graphics::mapper::V3_0::BufferDescriptor;
    using YCbCrLayout = android::hardware::graphics::mapper::V3_0::YCbCrLayout;
    using DescriptorInfo = IMapper::BufferDescriptorInfo;
    using Rect = IMapper::Rect;
};

Return<android::hardware::media::omx::V1_0::Status> setRole(sp<IOmxNode> omxNode,
                                                            const std::string& role);
Loading