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

Commit 15d22137 authored by Chia-I Wu's avatar Chia-I Wu
Browse files

graphics: add a default impl for IMapper 2.1

This is for reference only.  It almost only has stub implementations
for the new 2.1 methods.

Test: boots and VTS
Change-Id: I60499f3094df1975ccbbcda7b5c03d4a0dc57c39
parent 3ceef47c
Loading
Loading
Loading
Loading
+37 −0
Original line number Diff line number Diff line
//
// Copyright (C) 2016 The Android Open Source Project
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//      http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

cc_library_shared {
    name: "android.hardware.graphics.mapper@2.0-impl-2.1",
    defaults: ["hidl_defaults"],
    vendor: true,
    relative_install_path: "hw",
    srcs: ["passthrough.cpp"],
    header_libs: [
        "android.hardware.graphics.mapper@2.1-passthrough",
    ],
    shared_libs: [
        "android.hardware.graphics.mapper@2.0",
        "android.hardware.graphics.mapper@2.1",
        "libbase",
        "libcutils",
        "libhardware",
        "libhidlbase",
        "libhidltransport",
        "liblog",
        "libsync",
        "libutils",
    ],
}
+4 −0
Original line number Diff line number Diff line
# Graphics team
jessehall@google.com
olv@google.com
stoza@google.com
+24 −0
Original line number Diff line number Diff line
/*
 * Copyright 2016 The Android Open Source Project
 * * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#include <android/hardware/graphics/mapper/2.1/IMapper.h>
#include <mapper-passthrough/2.1/GrallocLoader.h>

using android::hardware::graphics::mapper::V2_1::IMapper;
using android::hardware::graphics::mapper::V2_1::passthrough::GrallocLoader;

extern "C" IMapper* HIDL_FETCH_IMapper(const char* /*name*/) {
    return GrallocLoader::load();
}
+37 −0
Original line number Diff line number Diff line
//
// Copyright (C) 2016 The Android Open Source Project
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//      http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

cc_library_headers {
    name: "android.hardware.graphics.mapper@2.1-passthrough",
    defaults: ["hidl_defaults"],
    vendor: true,
    shared_libs: [
        "android.hardware.graphics.mapper@2.1",
        "libhardware",
    ],
    export_shared_lib_headers: [
        "android.hardware.graphics.mapper@2.1",
        "libhardware",
    ],
    header_libs: [
        "android.hardware.graphics.mapper@2.0-passthrough",
        "android.hardware.graphics.mapper@2.1-hal",
    ],
    export_header_lib_headers: [
        "android.hardware.graphics.mapper@2.0-passthrough",
        "android.hardware.graphics.mapper@2.1-hal",
    ],
    export_include_dirs: ["include"],
}
+76 −0
Original line number Diff line number Diff line
/*
 * Copyright 2016 The Android Open Source Project
 * * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#pragma once

#include <mapper-hal/2.1/MapperHal.h>
#include <mapper-passthrough/2.0/Gralloc0Hal.h>

namespace android {
namespace hardware {
namespace graphics {
namespace mapper {
namespace V2_1 {
namespace passthrough {

namespace detail {

using V2_0::BufferDescriptor;
using V2_0::Error;

// Gralloc0HalImpl implements V2_*::hal::MapperHal on top of gralloc0
template <typename Hal>
class Gralloc0HalImpl : public V2_0::passthrough::detail::Gralloc0HalImpl<Hal> {
   public:
    Error validateBufferSize(const native_handle_t* /*bufferHandle*/,
                             const IMapper::BufferDescriptorInfo& /*descriptorInfo*/,
                             uint32_t /*stride*/) override {
        // need a gralloc0 extension to really validate
        return Error::NONE;
    }

    Error getTransportSize(const native_handle_t* bufferHandle, uint32_t* outNumFds,
                           uint32_t* outNumInts) override {
        // need a gralloc0 extension to get the transport size
        *outNumFds = bufferHandle->numFds;
        *outNumInts = bufferHandle->numInts;
        return Error::NONE;
    }

    Error createDescriptor_2_1(const IMapper::BufferDescriptorInfo& descriptorInfo,
                               BufferDescriptor* outDescriptor) override {
        return createDescriptor(
            V2_0::IMapper::BufferDescriptorInfo{
                descriptorInfo.width, descriptorInfo.height, descriptorInfo.layerCount,
                static_cast<common::V1_0::PixelFormat>(descriptorInfo.format), descriptorInfo.usage,
            },
            outDescriptor);
    }

   private:
    using BaseType2_0 = V2_0::passthrough::detail::Gralloc0HalImpl<Hal>;
    using BaseType2_0::createDescriptor;
};

}  // namespace detail

using Gralloc0Hal = detail::Gralloc0HalImpl<hal::MapperHal>;

}  // namespace passthrough
}  // namespace V2_1
}  // namespace mapper
}  // namespace graphics
}  // namespace hardware
}  // namespace android
Loading