Add tools

This commit is contained in:
Billy Laws 2022-02-10 21:43:45 +00:00
parent 4820e60412
commit 9032460f55
12 changed files with 4937 additions and 0 deletions

6
tools/README.md Normal file
View file

@ -0,0 +1,6 @@
## Tools for working with the Adreno Vulkan blob
blob-patcher.py is a script for generating adrenotools loadable drivers from an extracted ROM zip
qtimapper-shim allows newer drivers to work on devices that lack support for the new mapper HAL

64
tools/blob-patcher.py Executable file
View file

@ -0,0 +1,64 @@
#!/usr/bin/python3
import sys, os
def patch_lib_base(in_dir, out_dir, libs, in_name, out_name):
with open(in_dir + in_name, "rb") as inf:
with open(out_dir + out_name, "wb") as outf:
content = inf.read()
for lib in libs:
print(out_name + ": repl:", lib[0], "->", lib[1])
content = content.replace(lib[0].encode(), lib[1].encode())
content = content.replace(in_name.encode(), out_name.encode())
outf.write(content);
def patch_lib(in_dir, out_dir, libs, name):
patch_lib_base(in_dir, out_dir, libs, "lib" + name + ".so", "not" + name + ".so")
def patch_references(lib_dir, out_dir, vulkan_libname, vulkan_newname, stub_mapper):
try:
os.mkdir(out_dir)
except:
pass
replacement_list = [("libgsl.so", "notgsl.so"), ("libllvm-glnext.so", "notllvm-glnext.so"), ("libdmabufheap.so", "notdmabufheap.so"), ("libadreno_utils.so", "notadreno_utils.so"), ("libllvm-qgl.so", "notllvm-qgl.so")]
if (stub_mapper == 2):
replacement_list += [("vendor.qti.hardware.display.mapper@2.0.so", "vendor.qti.hardware.display.mapperstub.so"),
("android.hardware.graphics.mapper@2.0.so", "android.hardware.graphics.mapperstub.so"),
("vendor.qti.hardware.display.mapperextensions@1.0.so", "vendor.qti.hardware.display.mapperextensionsstub.so"),
("vendor.qti.hardware.display.mapperextensions@1.1.so", "vendor.qti.hardware.display.mapperextensionsstub.so")]
if (stub_mapper <= 3):
replacement_list += [("vendor.qti.hardware.display.mapper@3.0.so", "vendor.qti.hardware.display.mapperstub.so"),
("android.hardware.graphics.mapper@3.0.so", "android.hardware.graphics.mapperstub.so")]
if (stub_mapper <= 4):
replacement_list += [("vendor.qti.hardware.display.mapper@4.0.so", "vendor.qti.hardware.display.mapperstub.so"),
("android.hardware.graphics.mapper@4.0.so", "android.hardware.graphics.mapperstub.so")]
for lib in ["gsl", "llvm-glnext", "dmabufheap", "adreno_utils", "llvm-qgl"]:
try:
patch_lib(lib_dir, out_dir, replacement_list, lib)
except:
pass
patch_lib_base(lib_dir + "/hw/", out_dir, replacement_list, vulkan_libname, vulkan_newname)
if (len(sys.argv)!= 6):
print("<extracted rom in> <pkg out> <vk soname> <vk soname new> <mapper ver to patch up to>")
sys.exit()
root_path = sys.argv[1]
out_path = sys.argv[2]
vulkan_libname = sys.argv[3]
vulkan_newname = sys.argv[4]
stub_mapper = int(sys.argv[5])
vendor_path = root_path + "/vendor/"
if (len(vulkan_newname) != len(vulkan_libname)):
print("New vk soname must be equal to old one")
sys.exit()
for libdir in ["/lib64/", "/lib/"]:
patch_references(vendor_path + libdir, out_path + libdir, vulkan_libname, vulkan_newname, stub_mapper)
print("done!")

View file

@ -0,0 +1,34 @@
cc_defaults {
name: "shim_defaults",
srcs: [
"shim.cpp",
],
shared_libs: [
"liblog",
"libcutils",
"libhidlbase",
"libhardware",
"libutils",
],
cflags: [
"-Wno-error",
"-Wno-unused-parameter",
],
}
cc_library_shared {
name: "vendor.qti.hardware.display.mapperstub",
defaults: ["shim_defaults"],
}
cc_library_shared {
name: "vendor.qti.hardware.display.mapperextensionsstub",
defaults: ["shim_defaults"],
}
cc_library_shared {
name: "android.hardware.graphics.mapperstub",
defaults: ["shim_defaults"],
}

View file

@ -0,0 +1,19 @@
## QtiMapper-shim
A shim that translates between the IQtiMapper(2,3,4) API used by newer Adreno graphics drivers and gralloc1, which is the only available gralloc API on sdm845.
### Method
Exposes the same ABI as the newer mapper blobs and stubs enough functions to force the HAL to fallback to the 2.0 mapper/mapperextension API which is then shimmed with a passthrough to gralloc1. The blobs can then be patched to load the stub libs instead, see the blob-patcher script.
The code is fairly ugly but functional enough for the purpose, some functions are missing and will need to be implemented in the case that the driver starts using them.
### Building
Chuck into a lineage tree, then:
```
make vendor.qti.hardware.display.mapperstub
make vendor.qti.hardware.display.mapperextensionsstub
make android.hardware.graphics.mapperstub
```
and grab SOs out of outputs dir

View file

@ -0,0 +1,85 @@
/*
* Copyright 2022 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 <hidl/HidlSupport.h>
#include <hidl/MQDescriptor.h>
#include <hidl/Status.h>
#include <utils/NativeHandle.h>
#include "types/common.h"
using namespace android::hardware;
using namespace android;
/* Simplified version of hidl::base::V1_0::IBase */
struct IBase : virtual public RefBase {
virtual bool isRemote() const;
using interfaceChain_cb = std::function<void(const hidl_vec<hidl_string> &descriptors)>;
virtual Return<void> interfaceChain(interfaceChain_cb _hidl_cb) {
ALOGE("%s", __func__);
std::terminate();
}
virtual Return<void> debug(const hidl_handle &fd, const hidl_vec<hidl_string> &options) {
ALOGE("%s", __func__);
std::terminate();
}
using interfaceDescriptor_cb = std::function<void(const hidl_string &descriptor)>;
virtual Return<void> interfaceDescriptor(interfaceDescriptor_cb _hidl_cb) {
ALOGE("%s", __func__);
std::terminate();
}
using getHashChain_cb = std::function<void(const hidl_vec<hidl_array<uint8_t, 32>> &hashchain)>;
virtual Return<void> getHashChain(getHashChain_cb _hidl_cb) {
ALOGE("%s", __func__);
std::terminate();
}
virtual Return<void> setHALInstrumentation() {
ALOGE("%s", __func__);
std::terminate();
}
virtual Return<bool> linkToDeath(const sp<hidl_death_recipient> &recipient, uint64_t cookie) {
ALOGE("%s", __func__);
std::terminate();
}
virtual Return<void> ping() {
ALOGE("%s", __func__);
std::terminate();
}
using getDebugInfo_cb = std::function<void(const hidl::base::V1_0::DebugInfo &info)>;
virtual Return<void> getDebugInfo(getDebugInfo_cb _hidl_cb) {
ALOGE("%s", __func__);
std::terminate();
}
virtual Return<void> notifySyspropsChanged() {
ALOGE("%s", __func__);
std::terminate();
}
virtual Return<bool> unlinkToDeath(const sp<hidl_death_recipient> &recipient) {
ALOGE("%s", __func__);
std::terminate();
}
};

View file

@ -0,0 +1,198 @@
/*
* Copyright (c) 2011-2018, The Linux Foundation. All rights reserved.
* Not a Contribution
*
* Copyright (C) 2008 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.
*/
#ifndef __GR_PRIV_HANDLE_H__
#define __GR_PRIV_HANDLE_H__
#include <errno.h>
#include <log/log.h>
#include <hardware/gralloc.h>
#include <hardware/gralloc1.h>
#include <cinttypes>
#define GRALLOC_MODULE_PERFORM_CREATE_HANDLE_FROM_BUFFER 1
#define GRALLOC_MODULE_PERFORM_GET_STRIDE 2
#define GRALLOC_MODULE_PERFORM_GET_CUSTOM_STRIDE_FROM_HANDLE 3
#define GRALLOC_MODULE_PERFORM_GET_CUSTOM_STRIDE_AND_HEIGHT_FROM_HANDLE 4
#define GRALLOC_MODULE_PERFORM_GET_ATTRIBUTES 5
#define GRALLOC_MODULE_PERFORM_GET_COLOR_SPACE_FROM_HANDLE 6
#define GRALLOC_MODULE_PERFORM_GET_YUV_PLANE_INFO 7
#define GRALLOC_MODULE_PERFORM_GET_MAP_SECURE_BUFFER_INFO 8
#define GRALLOC_MODULE_PERFORM_GET_UBWC_FLAG 9
#define GRALLOC_MODULE_PERFORM_GET_RGB_DATA_ADDRESS 10
#define GRALLOC_MODULE_PERFORM_GET_IGC 11
#define GRALLOC_MODULE_PERFORM_SET_IGC 12
#define GRALLOC_MODULE_PERFORM_SET_SINGLE_BUFFER_MODE 13
#define GRALLOC1_MODULE_PERFORM_GET_BUFFER_SIZE_AND_DIMENSIONS 14
#define GRALLOC1_MODULE_PERFORM_GET_INTERLACE_FLAG 15
#define GRALLOC_MODULE_PERFORM_GET_GRAPHICS_METADATA 16
#define GRALLOC1_FUNCTION_PERFORM 0x00001000
#define DBG_HANDLE false
typedef gralloc1_error_t (*GRALLOC1_PFN_PERFORM)(gralloc1_device_t *device, int operation, ...);
#define PRIV_HANDLE_CONST(exp) static_cast<const private_handle_t *>(exp)
#pragma pack(push, 4)
struct private_handle_t : public native_handle_t {
enum {
PRIV_FLAGS_FRAMEBUFFER = 0x00000001,
PRIV_FLAGS_USES_ION = 0x00000008,
PRIV_FLAGS_NEEDS_FLUSH = 0x00000020,
PRIV_FLAGS_INTERNAL_ONLY = 0x00000040,
PRIV_FLAGS_NON_CPU_WRITER = 0x00000080,
PRIV_FLAGS_CACHED = 0x00000200,
PRIV_FLAGS_SECURE_BUFFER = 0x00000400,
PRIV_FLAGS_EXTERNAL_ONLY = 0x00002000,
PRIV_FLAGS_PROTECTED_BUFFER = 0x00004000,
PRIV_FLAGS_VIDEO_ENCODER = 0x00010000,
PRIV_FLAGS_CAMERA_WRITE = 0x00020000,
PRIV_FLAGS_CAMERA_READ = 0x00040000,
PRIV_FLAGS_HW_COMPOSER = 0x00080000,
PRIV_FLAGS_HW_TEXTURE = 0x00100000,
PRIV_FLAGS_ITU_R_601 = 0x00200000, // Unused from display
PRIV_FLAGS_ITU_R_601_FR = 0x00400000, // Unused from display
PRIV_FLAGS_ITU_R_709 = 0x00800000, // Unused from display
PRIV_FLAGS_SECURE_DISPLAY = 0x01000000,
PRIV_FLAGS_TILE_RENDERED = 0x02000000,
PRIV_FLAGS_CPU_RENDERED = 0x04000000,
PRIV_FLAGS_UBWC_ALIGNED = 0x08000000,
PRIV_FLAGS_DISP_CONSUMER = 0x10000000,
PRIV_FLAGS_CLIENT_ALLOCATED = 0x20000000, // Ion buffer allocated outside of gralloc
};
// file-descriptors dup'd over IPC
int fd;
int fd_metadata;
// values sent over IPC
int magic;
int flags;
int width; // holds width of the actual buffer allocated
int height; // holds height of the actual buffer allocated
int unaligned_width; // holds width client asked to allocate
int unaligned_height; // holds height client asked to allocate
int format;
int buffer_type;
unsigned int layer_count;
uint64_t id;
uint64_t usage;
unsigned int size;
unsigned int offset;
unsigned int offset_metadata;
uint64_t base;
uint64_t base_metadata;
uint64_t gpuaddr;
static const int kNumFds = 2;
static const int kMagic = 'gmsm';
static inline int NumInts() {
return ((sizeof(private_handle_t) - sizeof(native_handle_t)) / sizeof(int)) - kNumFds;
}
private_handle_t(int fd, int meta_fd, int flags, int width, int height, int uw, int uh,
int format, int buf_type, unsigned int size, uint64_t usage = 0)
: fd(fd),
fd_metadata(meta_fd),
magic(kMagic),
flags(flags),
width(width),
height(height),
unaligned_width(uw),
unaligned_height(uh),
format(format),
buffer_type(buf_type),
layer_count(1),
id(0),
usage(usage),
size(size),
offset(0),
offset_metadata(0),
base(0),
base_metadata(0),
gpuaddr(0) {
version = static_cast<int>(sizeof(native_handle));
numInts = NumInts();
numFds = kNumFds;
}
// Legacy constructor used by some clients
private_handle_t(int fd, unsigned int size, int usage, int buf_type, int format, int w, int h)
: private_handle_t(fd, -1, PRIV_FLAGS_CLIENT_ALLOCATED, w, h, 0, 0, format, buf_type, size,
static_cast<uint64_t>(usage)) {}
~private_handle_t() {
magic = 0;
ALOGE_IF(DBG_HANDLE, "Deleting buffer handle %p", this);
}
static int validate(const native_handle *h) {
auto *hnd = static_cast<const private_handle_t *>(h);
if (!h || h->version != sizeof(native_handle) || h->numInts != NumInts() ||
h->numFds != kNumFds) {
ALOGE("Invalid gralloc handle (at %p): ver(%d/%zu) ints(%d/%d) fds(%d/%d) ",
h, h ? h->version : -1, sizeof(native_handle), h ? h->numInts : -1, NumInts(),
h ? h->numFds : -1, kNumFds);
return -EINVAL;
}
if (hnd->magic != kMagic) {
ALOGE("magic(%c%c%c%c/%c%c%c%c)",
hnd ? (((hnd->magic >> 24) & 0xFF) ? ((hnd->magic >> 24) & 0xFF) : '-') : '?',
hnd ? (((hnd->magic >> 16) & 0xFF) ? ((hnd->magic >> 16) & 0xFF) : '-') : '?',
hnd ? (((hnd->magic >> 8) & 0xFF) ? ((hnd->magic >> 8) & 0xFF) : '-') : '?',
hnd ? (((hnd->magic >> 0) & 0xFF) ? ((hnd->magic >> 0) & 0xFF) : '-') : '?',
(kMagic >> 24) & 0xFF, (kMagic >> 16) & 0xFF, (kMagic >> 8) & 0xFF, (kMagic >> 0) & 0xFF);
return -EINVAL;
}
return 0;
}
static void Dump(const private_handle_t *hnd) {
ALOGD("handle id:%" PRIu64
" wxh:%dx%d uwxuh:%dx%d size: %d fd:%d fd_meta:%d flags:0x%x "
"usage:0x%" PRIx64 " format:0x%x layer_count: %d",
hnd->id, hnd->width, hnd->height, hnd->unaligned_width, hnd->unaligned_height, hnd->size,
hnd->fd, hnd->fd_metadata, hnd->flags, hnd->usage, hnd->format, hnd->layer_count);
}
int GetUnalignedWidth() const { return unaligned_width; }
int GetUnalignedHeight() const { return unaligned_height; }
int GetColorFormat() const { return format; }
unsigned int GetLayerCount() const { return layer_count; }
int GetStride() const {
// In handle we currently store aligned width after allocation.
return width;
}
uint64_t GetUsage() const { return usage; }
uint64_t GetBackingstore() const { return id; }
};
#pragma pack(pop)
#endif // __GR_PRIV_HANDLE_H__

View file

@ -0,0 +1,160 @@
/*
* Copyright (c) 2016-2022, The Linux Foundation. All rights reserved.
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of The Linux Foundation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#pragma once
#include <hidl/HidlSupport.h>
#include <hidl/MQDescriptor.h>
#include <hidl/Status.h>
#include <utils/NativeHandle.h>
#include <utils/misc.h>
#include "types/mapper.h"
namespace vendor::qti::hardware::display::mapperextensions::V1_0 {
struct IQtiMapperExtensions;
}
namespace android::hardware::graphics::mapper {
namespace V2_0 {
struct IMapper : public IBase {
struct BufferDescriptorInfo final {
uint32_t width __attribute__ ((aligned(4)));
uint32_t height __attribute__ ((aligned(4)));
uint32_t layerCount __attribute__ ((aligned(4)));
graphics::common::V1_0::PixelFormat format __attribute__ ((aligned(4)));
hidl_bitfield<graphics::common::V1_0::BufferUsage> usage __attribute__ ((aligned(8)));
};
struct Rect final {
int32_t left __attribute__ ((aligned(4)));
int32_t top __attribute__ ((aligned(4)));
int32_t width __attribute__ ((aligned(4)));
int32_t height __attribute__ ((aligned(4)));
};
static sp<IMapper> getService(const std::string &/* serviceName */, const bool /* getStub */);
};
}
namespace V3_0 {
struct IMapper : public IBase {
static sp<IMapper> getService(const std::string &/* serviceName */, const bool /* getStub */);
};
}
namespace V4_0 {
struct IMapper : public IBase {
static sp<IMapper> getService(const std::string &/* serviceName */, const bool /* getStub */);
};
}
}
namespace vendor::qti::hardware::display::mapper {
namespace V4_0 {
struct IQtiMapper : public IBase {
static Return<sp<IQtiMapper>> castFrom(const sp<graphics::mapper::V4_0::IMapper> &/* parent */, bool /* emitError */);
};
}
namespace V3_0 {
struct IQtiMapper : public IBase {
static Return<sp<IQtiMapper>> castFrom(const sp<graphics::mapper::V3_0::IMapper> &/* parent */, bool /* emitError */);
};
}
namespace V2_0 {
struct IQtiMapper : public IBase {
using createDescriptor_cb = std::function<void(graphics::mapper::V2_0::Error error, const hidl_vec<uint32_t> &descriptor)>;
virtual Return<void> createDescriptor(const graphics::mapper::V2_0::IMapper::BufferDescriptorInfo &descriptorInfo, createDescriptor_cb _hidl_cb) {
ALOGE("%s", __func__);
std::terminate();
}
using importBuffer_cb = std::function<void(graphics::mapper::V2_0::Error error, void *buffer)>;
virtual Return<void> importBuffer(const hidl_handle &rawHandle, importBuffer_cb _hidl_cb) {
ALOGE("%s", __func__);
std::terminate();
}
virtual Return<graphics::mapper::V2_0::Error> freeBuffer(void *buffer) {
ALOGE("%s", __func__);
std::terminate();
}
using lock_cb = std::function<void(graphics::mapper::V2_0::Error error, void *data)>;
virtual Return<void> lock(void *buffer, hidl_bitfield<graphics::common::V1_0::BufferUsage> cpuUsage, const graphics::mapper::V2_0::IMapper::Rect &accessRegion, const hidl_handle &acquireFence, lock_cb _hidl_cb) {
ALOGE("%s", __func__);
std::terminate();
}
using lockYCbCr_cb = std::function<void(graphics::mapper::V2_0::Error error, const graphics::mapper::V2_0::YCbCrLayout &layout)>;
virtual Return<void> lockYCbCr(void *buffer, hidl_bitfield<graphics::common::V1_0::BufferUsage> cpuUsage, const graphics::mapper::V2_0::IMapper::Rect &accessRegion, const hidl_handle &acquireFence, lockYCbCr_cb _hidl_cb) {
ALOGE("%s", __func__);
std::terminate();
}
using unlock_cb = std::function<void(graphics::mapper::V2_0::Error error, const hidl_handle &releaseFence)>;
virtual Return<void> unlock(void *buffer, unlock_cb _hidl_cb) {
ALOGE("%s", __func__);
std::terminate();
}
virtual Return<graphics::mapper::V2_0::Error> validateBufferSize(void *buffer, const graphics::mapper::V2_0::IMapper::BufferDescriptorInfo &descriptorInfo, uint32_t stride) {
ALOGE("%s", __func__);
std::terminate();
}
using getTransportSize_cb = std::function<void(graphics::mapper::V2_0::Error error, uint32_t numFds, uint32_t numInts)>;
virtual Return<void> getTransportSize(void *buffer, getTransportSize_cb _hidl_cb) {
ALOGE("%s", __func__);
std::terminate();
}
using createDescriptor_2_1_cb = std::function<void(graphics::mapper::V2_0::Error error, const hidl_vec<uint32_t> &descriptor)>;
virtual Return<void> createDescriptor_2_1(const graphics::mapper::V2_0::IMapper::BufferDescriptorInfo &descriptorInfo, createDescriptor_2_1_cb _hidl_cb) {
ALOGE("%s", __func__);
std::terminate();
}
using getMapperExtensions_cb = std::function<void(graphics::mapper::V2_0::Error error, const ::android::sp<::vendor::qti::hardware::display::mapperextensions::V1_0::IQtiMapperExtensions> &extensions)>;
virtual Return<void> getMapperExtensions(getMapperExtensions_cb _hidl_cb);
static Return<sp<IQtiMapper>> castFrom(const sp<graphics::mapper::V2_0::IMapper> &/* parent */, bool /* emitError */);
};
}
}

View file

@ -0,0 +1,173 @@
/*
* Copyright (c) 2016-2022, The Linux Foundation. All rights reserved.
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of The Linux Foundation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#pragma once
#include <hidl/HidlSupport.h>
#include <hidl/MQDescriptor.h>
#include <hidl/Status.h>
#include <utils/NativeHandle.h>
#include <utils/misc.h>
#include "types/mapperextensions.h"
#include "gr_priv_handle.h"
namespace vendor::qti::hardware::display::mapperextensions {
namespace V1_0 {
struct IQtiMapperExtensions : public IBase {
IQtiMapperExtensions() {};
};
}
namespace V1_1 {
struct IQtiMapperExtensions : public IBase {
IQtiMapperExtensions();
gralloc1_device_t *gralloc;
GRALLOC1_PFN_PERFORM perform;
using getMapSecureBufferFlag_cb = std::function<void(::vendor::qti::hardware::display::mapperextensions::V1_0::Error error, bool mapSecureBuffer)>;
virtual ::android::hardware::Return<void> getMapSecureBufferFlag(void *buffer, getMapSecureBufferFlag_cb _hidl_cb) {
ALOGE("%s", __func__);
std::terminate();
}
// Used, passthrough
using getInterlacedFlag_cb = std::function<void(::vendor::qti::hardware::display::mapperextensions::V1_0::Error error, bool interlaced)>;
virtual ::android::hardware::Return<void> getInterlacedFlag(void *buffer, getInterlacedFlag_cb _hidl_cb);
using getCustomDimensions_cb = std::function<void(::vendor::qti::hardware::display::mapperextensions::V1_0::Error error, int32_t stride, int32_t height)>;
virtual ::android::hardware::Return<void> getCustomDimensions(void *buffer, getCustomDimensions_cb _hidl_cb) {
ALOGE("%s", __func__);
std::terminate();
}
// Used, passthrough
using getRgbDataAddress_cb = std::function<void(::vendor::qti::hardware::display::mapperextensions::V1_0::Error error, void *rgb_data)>;
virtual ::android::hardware::Return<void> getRgbDataAddress(void *buffer, getRgbDataAddress_cb _hidl_cb);
using calculateBufferAttributes_cb = std::function<void(::vendor::qti::hardware::display::mapperextensions::V1_0::Error error, int32_t aligned_width, int32_t aligned_height, bool ubwc_enabled)>;
virtual ::android::hardware::Return<void> calculateBufferAttributes(int32_t width, int32_t height, int32_t format, uint64_t usage, calculateBufferAttributes_cb _hidl_cb) {
ALOGE("%s", __func__);
std::terminate();
}
// Used, passhthrough
using getColorSpace_cb = std::function<void(::vendor::qti::hardware::display::mapperextensions::V1_0::Error error, int32_t color_space)>;
virtual ::android::hardware::Return<void> getColorSpace(void *buffer, getColorSpace_cb _hidl_cb) {
ALOGE("%s", __func__);
std::terminate();
}
// Used, passthrough with hidl fixups
using getYuvPlaneInfo_cb = std::function<void(::vendor::qti::hardware::display::mapperextensions::V1_0::Error error, const ::android::hardware::hidl_vec<::vendor::qti::hardware::display::mapperextensions::V1_0::YCbCrLayout> &layout)>;
virtual ::android::hardware::Return<void> getYuvPlaneInfo(void *buffer, getYuvPlaneInfo_cb _hidl_cb) {
ALOGE("%s", __func__);
std::terminate();
}
virtual ::android::hardware::Return<::vendor::qti::hardware::display::mapperextensions::V1_0::Error> setSingleBufferMode(void *buffer, bool enable) {
ALOGE("%s", __func__);
std::terminate();
}
using getCustomFormatFlags_cb = std::function<void(::vendor::qti::hardware::display::mapperextensions::V1_0::Error error, int32_t format, uint64_t priv_flags)>;
virtual ::android::hardware::Return<void> getCustomFormatFlags(int32_t format, uint64_t usage, getCustomFormatFlags_cb _hidl_cb) {
ALOGE("%s", __func__);
std::terminate();
}
// Used, cast private data with no passthrough
using getFd_cb = std::function<void(::vendor::qti::hardware::display::mapperextensions::V1_0::Error error, int32_t fd)>;
virtual ::android::hardware::Return<void> getFd(void *buffer, getFd_cb _hidl_cb);
// Used, cast private data with no passthrough
using getWidth_cb = std::function<void(::vendor::qti::hardware::display::mapperextensions::V1_0::Error error, int32_t width)>;
virtual ::android::hardware::Return<void> getWidth(void *buffer, getWidth_cb _hidl_cb);
// Used, cast private data with no passthrough
using getHeight_cb = std::function<void(::vendor::qti::hardware::display::mapperextensions::V1_0::Error error, int32_t height)>;
virtual ::android::hardware::Return<void> getHeight(void *buffer, getHeight_cb _hidl_cb);
// Used, cast private data with no passthrough
using getOffset_cb = std::function<void(::vendor::qti::hardware::display::mapperextensions::V1_0::Error error, uint64_t offset)>;
virtual ::android::hardware::Return<void> getOffset(void *buffer, getOffset_cb _hidl_cb);
// Used, cast private data with no passthrough
using getSize_cb = std::function<void(::vendor::qti::hardware::display::mapperextensions::V1_0::Error error, uint64_t size)>;
virtual ::android::hardware::Return<void> getSize(void *buffer, getSize_cb _hidl_cb);
using getUnalignedWidth_cb = std::function<void(::vendor::qti::hardware::display::mapperextensions::V1_0::Error error, int32_t unaligned_width)>;
virtual ::android::hardware::Return<void> getUnalignedWidth(void *buffer, getUnalignedWidth_cb _hidl_cb);
using getUnalignedHeight_cb = std::function<void(::vendor::qti::hardware::display::mapperextensions::V1_0::Error error, int32_t unaligned_height)>;
virtual ::android::hardware::Return<void> getUnalignedHeight(void *buffer, getUnalignedHeight_cb _hidl_cb);
using getLayerCount_cb = std::function<void(::vendor::qti::hardware::display::mapperextensions::V1_0::Error error, uint64_t layer_count)>;
virtual ::android::hardware::Return<void> getLayerCount(void *buffer, getLayerCount_cb _hidl_cb);
using getId_cb = std::function<void(::vendor::qti::hardware::display::mapperextensions::V1_0::Error error, uint64_t id)>;
virtual ::android::hardware::Return<void> getId(void *buffer, getId_cb _hidl_cb);
using getUsageFlags_cb = std::function<void(::vendor::qti::hardware::display::mapperextensions::V1_0::Error error, uint64_t usage)>;
virtual ::android::hardware::Return<void> getUsageFlags(void *buffer, getUsageFlags_cb _hidl_cb);
// Used, cast private data with no passthrough
using getFormat_cb = std::function<void(::vendor::qti::hardware::display::mapperextensions::V1_0::Error error, int32_t format)>;
virtual ::android::hardware::Return<void> getFormat(void *buffer, getFormat_cb _hidl_cb);
// Used, cast private data with no passthrough
using getPrivateFlags_cb = std::function<void(::vendor::qti::hardware::display::mapperextensions::V1_0::Error error, int32_t flags)>;
virtual ::android::hardware::Return<void> getPrivateFlags(void *buffer, getPrivateFlags_cb _hidl_cb);
using getSurfaceMetadata_cb = std::function<void(::vendor::qti::hardware::display::mapperextensions::V1_0::Error error, void *metadata)>;
virtual ::android::hardware::Return<void> getSurfaceMetadata(void *buffer, getSurfaceMetadata_cb _hidl_cb) {
ALOGE("%s", __func__);
std::terminate();
}
// Used, PAIN
using getFormatLayout_cb = std::function<void(::vendor::qti::hardware::display::mapperextensions::V1_0::Error error, uint64_t size, const ::android::hardware::hidl_vec<::vendor::qti::hardware::display::mapperextensions::V1_0::PlaneLayout> &plane_info)>;
virtual ::android::hardware::Return<void> getFormatLayout(int32_t format, uint64_t usage, int32_t flags, int32_t width, int32_t height, getFormatLayout_cb _hidl_cb) {
ALOGE("%s fail", __func__);
return Void();
}
// V1.1, Used, passthrough
virtual ::android::hardware::Return<::vendor::qti::hardware::display::mapperextensions::V1_0::Error> getSurfaceMetadata_V1(void *buffer, void *metadata) {
ALOGE("%s", __func__);
std::terminate();
}
static Return<sp<IQtiMapperExtensions>> castFrom(android::sp<V1_0::IQtiMapperExtensions> const &/* parent */, bool /* emitError */);
};
}
}

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,231 @@
#ifndef HIDL_GENERATED_ANDROID_HARDWARE_GRAPHICS_MAPPER_V2_0_TYPES_H
#define HIDL_GENERATED_ANDROID_HARDWARE_GRAPHICS_MAPPER_V2_0_TYPES_H
#include <hidl/HidlSupport.h>
#include <hidl/MQDescriptor.h>
#include <utils/NativeHandle.h>
#include <utils/misc.h>
namespace android {
namespace hardware {
namespace graphics {
namespace mapper {
namespace V2_0 {
// Forward declaration for forward reference support:
enum class Error : int32_t;
struct YCbCrLayout;
enum class Error : int32_t {
NONE = 0,
BAD_DESCRIPTOR = 1,
BAD_BUFFER = 2,
BAD_VALUE = 3,
NO_RESOURCES = 5,
UNSUPPORTED = 7,
};
/**
* A buffer descriptor is an implementation-defined opaque data returned by
* createDescriptor. It describes the properties of a buffer and is consumed
* by the allocator.
*/
typedef ::android::hardware::hidl_vec<uint32_t> BufferDescriptor;
/**
* Structure for describing YCbCr formats for consumption by applications.
* This is used with PixelFormat::YCBCR_*_888.
*
* Buffer chroma subsampling is defined in the format.
* e.g. PixelFormat::YCBCR_420_888 has subsampling 4:2:0.
*
* Buffers must have a 8 bit depth.
*
* y, cb, and cr point to the first byte of their respective planes.
*
* Stride describes the distance in bytes from the first value of one row of
* the image to the first value of the next row. It includes the width of the
* image plus padding.
* yStride is the stride of the luma plane.
* cStride is the stride of the chroma planes.
*
* chromaStep is the distance in bytes from one chroma pixel value to the
* next. This is 2 bytes for semiplanar (because chroma values are interleaved
* and each chroma value is one byte) and 1 for planar.
*/
struct YCbCrLayout final {
void* y;
void* cb;
void* cr;
uint32_t yStride;
uint32_t cStride;
uint32_t chromaStep;
};
//
// type declarations for package
//
template<typename>
static inline std::string toString(int32_t o);
static inline std::string toString(::android::hardware::graphics::mapper::V2_0::Error o);
constexpr int32_t operator|(const ::android::hardware::graphics::mapper::V2_0::Error lhs, const ::android::hardware::graphics::mapper::V2_0::Error rhs) {
return static_cast<int32_t>(static_cast<int32_t>(lhs) | static_cast<int32_t>(rhs));
}
constexpr int32_t operator|(const int32_t lhs, const ::android::hardware::graphics::mapper::V2_0::Error rhs) {
return static_cast<int32_t>(lhs | static_cast<int32_t>(rhs));
}
constexpr int32_t operator|(const ::android::hardware::graphics::mapper::V2_0::Error lhs, const int32_t rhs) {
return static_cast<int32_t>(static_cast<int32_t>(lhs) | rhs);
}
constexpr int32_t operator&(const ::android::hardware::graphics::mapper::V2_0::Error lhs, const ::android::hardware::graphics::mapper::V2_0::Error rhs) {
return static_cast<int32_t>(static_cast<int32_t>(lhs) & static_cast<int32_t>(rhs));
}
constexpr int32_t operator&(const int32_t lhs, const ::android::hardware::graphics::mapper::V2_0::Error rhs) {
return static_cast<int32_t>(lhs & static_cast<int32_t>(rhs));
}
constexpr int32_t operator&(const ::android::hardware::graphics::mapper::V2_0::Error lhs, const int32_t rhs) {
return static_cast<int32_t>(static_cast<int32_t>(lhs) & rhs);
}
constexpr int32_t &operator|=(int32_t& v, const ::android::hardware::graphics::mapper::V2_0::Error e) {
v |= static_cast<int32_t>(e);
return v;
}
constexpr int32_t &operator&=(int32_t& v, const ::android::hardware::graphics::mapper::V2_0::Error e) {
v &= static_cast<int32_t>(e);
return v;
}
static inline std::string toString(const ::android::hardware::graphics::mapper::V2_0::YCbCrLayout& o);
// operator== and operator!= are not generated for YCbCrLayout
//
// type header definitions for package
//
template<>
inline std::string toString<::android::hardware::graphics::mapper::V2_0::Error>(int32_t o) {
using ::android::hardware::details::toHexString;
std::string os;
::android::hardware::hidl_bitfield<::android::hardware::graphics::mapper::V2_0::Error> flipped = 0;
bool first = true;
if ((o & ::android::hardware::graphics::mapper::V2_0::Error::NONE) == static_cast<int32_t>(::android::hardware::graphics::mapper::V2_0::Error::NONE)) {
os += (first ? "" : " | ");
os += "NONE";
first = false;
flipped |= ::android::hardware::graphics::mapper::V2_0::Error::NONE;
}
if ((o & ::android::hardware::graphics::mapper::V2_0::Error::BAD_DESCRIPTOR) == static_cast<int32_t>(::android::hardware::graphics::mapper::V2_0::Error::BAD_DESCRIPTOR)) {
os += (first ? "" : " | ");
os += "BAD_DESCRIPTOR";
first = false;
flipped |= ::android::hardware::graphics::mapper::V2_0::Error::BAD_DESCRIPTOR;
}
if ((o & ::android::hardware::graphics::mapper::V2_0::Error::BAD_BUFFER) == static_cast<int32_t>(::android::hardware::graphics::mapper::V2_0::Error::BAD_BUFFER)) {
os += (first ? "" : " | ");
os += "BAD_BUFFER";
first = false;
flipped |= ::android::hardware::graphics::mapper::V2_0::Error::BAD_BUFFER;
}
if ((o & ::android::hardware::graphics::mapper::V2_0::Error::BAD_VALUE) == static_cast<int32_t>(::android::hardware::graphics::mapper::V2_0::Error::BAD_VALUE)) {
os += (first ? "" : " | ");
os += "BAD_VALUE";
first = false;
flipped |= ::android::hardware::graphics::mapper::V2_0::Error::BAD_VALUE;
}
if ((o & ::android::hardware::graphics::mapper::V2_0::Error::NO_RESOURCES) == static_cast<int32_t>(::android::hardware::graphics::mapper::V2_0::Error::NO_RESOURCES)) {
os += (first ? "" : " | ");
os += "NO_RESOURCES";
first = false;
flipped |= ::android::hardware::graphics::mapper::V2_0::Error::NO_RESOURCES;
}
if ((o & ::android::hardware::graphics::mapper::V2_0::Error::UNSUPPORTED) == static_cast<int32_t>(::android::hardware::graphics::mapper::V2_0::Error::UNSUPPORTED)) {
os += (first ? "" : " | ");
os += "UNSUPPORTED";
first = false;
flipped |= ::android::hardware::graphics::mapper::V2_0::Error::UNSUPPORTED;
}
if (o != flipped) {
os += (first ? "" : " | ");
os += toHexString(o & (~flipped));
}os += " (";
os += toHexString(o);
os += ")";
return os;
}
static inline std::string toString(::android::hardware::graphics::mapper::V2_0::Error o) {
using ::android::hardware::details::toHexString;
if (o == ::android::hardware::graphics::mapper::V2_0::Error::NONE) {
return "NONE";
}
if (o == ::android::hardware::graphics::mapper::V2_0::Error::BAD_DESCRIPTOR) {
return "BAD_DESCRIPTOR";
}
if (o == ::android::hardware::graphics::mapper::V2_0::Error::BAD_BUFFER) {
return "BAD_BUFFER";
}
if (o == ::android::hardware::graphics::mapper::V2_0::Error::BAD_VALUE) {
return "BAD_VALUE";
}
if (o == ::android::hardware::graphics::mapper::V2_0::Error::NO_RESOURCES) {
return "NO_RESOURCES";
}
if (o == ::android::hardware::graphics::mapper::V2_0::Error::UNSUPPORTED) {
return "UNSUPPORTED";
}
std::string os;
os += toHexString(static_cast<int32_t>(o));
return os;
}
static inline std::string toString(const ::android::hardware::graphics::mapper::V2_0::YCbCrLayout& o) {
using ::android::hardware::toString;
std::string os;
os += "{";
os += ".y = ";
os += ::android::hardware::toString(o.y);
os += ", .cb = ";
os += ::android::hardware::toString(o.cb);
os += ", .cr = ";
os += ::android::hardware::toString(o.cr);
os += ", .yStride = ";
os += ::android::hardware::toString(o.yStride);
os += ", .cStride = ";
os += ::android::hardware::toString(o.cStride);
os += ", .chromaStep = ";
os += ::android::hardware::toString(o.chromaStep);
os += "}"; return os;
}
// operator== and operator!= are not generated for YCbCrLayout
} // namespace V2_0
} // namespace mapper
} // namespace graphics
} // namespace hardware
} // namespace android
//
// global type declarations for package
//
namespace android {
namespace hardware {
namespace details {
template<> constexpr std::array<::android::hardware::graphics::mapper::V2_0::Error, 6> hidl_enum_values<::android::hardware::graphics::mapper::V2_0::Error> = {
::android::hardware::graphics::mapper::V2_0::Error::NONE,
::android::hardware::graphics::mapper::V2_0::Error::BAD_DESCRIPTOR,
::android::hardware::graphics::mapper::V2_0::Error::BAD_BUFFER,
::android::hardware::graphics::mapper::V2_0::Error::BAD_VALUE,
::android::hardware::graphics::mapper::V2_0::Error::NO_RESOURCES,
::android::hardware::graphics::mapper::V2_0::Error::UNSUPPORTED,
};
} // namespace details
} // namespace hardware
} // namespace android
#endif // HIDL_GENERATED_ANDROID_HARDWARE_GRAPHICS_MAPPER_V2_0_TYPES_H

View file

@ -0,0 +1,553 @@
#ifndef HIDL_GENERATED_VENDOR_QTI_HARDWARE_DISPLAY_MAPPEREXTENSIONS_V1_0_TYPES_H
#define HIDL_GENERATED_VENDOR_QTI_HARDWARE_DISPLAY_MAPPEREXTENSIONS_V1_0_TYPES_H
#include <hidl/HidlSupport.h>
#include <hidl/MQDescriptor.h>
#include <utils/NativeHandle.h>
#include <utils/misc.h>
namespace vendor {
namespace qti {
namespace hardware {
namespace display {
namespace mapperextensions {
namespace V1_0 {
// Forward declaration for forward reference support:
enum class Error : int32_t;
struct YCbCrLayout;
enum class PlaneComponent : uint32_t;
enum class Flags : int32_t;
struct PlaneLayout;
enum class Error : int32_t {
NONE = 0,
BAD_BUFFER = 2,
NO_RESOURCES = 5,
UNSUPPORTED = 7,
};
struct YCbCrLayout final {
void* y;
void* cb;
void* cr;
uint32_t yStride;
uint32_t cStride;
uint32_t chromaStep;
};
/**
* Plane Component type definitions.
*/
enum class PlaneComponent : uint32_t {
PLANE_COMPONENT_Y = 1u /* (1 << 0) */,
PLANE_COMPONENT_Cb = 2u /* (1 << 1) */,
PLANE_COMPONENT_Cr = 4u /* (1 << 2) */,
PLANE_COMPONENT_R = 1024u /* (1 << 10) */,
PLANE_COMPONENT_G = 2048u /* (1 << 11) */,
PLANE_COMPONENT_B = 4096u /* (1 << 12) */,
PLANE_COMPONENT_A = 1048576u /* (1 << 20) */,
PLANE_COMPONENT_RAW = 1073741824u /* (1 << 30) */,
PLANE_COMPONENT_META = 2147483648u /* (1 << 31) */,
};
/**
* Flags to send with getFormatLayout for extra information for e.g. interlaced,
* otherwise send 0.
*/
enum class Flags : int32_t {
LAYOUT_INTERLACED_FLAG = 1 /* (1 << 0) */,
};
/**
* Structure for describing plane layout information for YUVA/RGBA/RAW formats
* YUV formats can be planar or semi-planar.
*
* This layout structure is used with any pixel format that can be
* represented by it, such as:
* - HAL_PIXEL_FORMAT_YCbCr_*
* - HAL_PIXEL_FORMAT_RGB*_*
* - even implementation defined formats that can be represented by
* the structures
*
* Each plane can be made up of one or more PlaneComponents depending on
* the format.
*
* Each plane can be subsampled either vertically or horizontally by
* a power-of-two factor.
*
* Pixel increment describes the distance in bytes from one pixel to the
* next pixel (to the right) on the same row for the component plane.
* This can be negative.
*
* Stride is provided in both pixels and bytes.
* Stride_bytes describes the distance in bytes from the first pixel of
* one row to the first pixel of the next row (below) for the component plane.
* This can be negative.
*
* Scanlines describes the height of the plane in terms of number of rows.
*
* Size of plane is stride_bytes * scanlines + any padding required for
* alignment as per format specification.
*
*/
struct PlaneLayout final {
::android::hardware::hidl_bitfield<::vendor::qti::hardware::display::mapperextensions::V1_0::PlaneComponent> component __attribute__ ((aligned(4)));
uint32_t h_subsampling __attribute__ ((aligned(4)));
uint32_t v_subsampling __attribute__ ((aligned(4)));
uint32_t offset __attribute__ ((aligned(4)));
int32_t pixel_increment __attribute__ ((aligned(4)));
int32_t stride __attribute__ ((aligned(4)));
int32_t stride_bytes __attribute__ ((aligned(4)));
int32_t scanlines __attribute__ ((aligned(4)));
uint32_t size __attribute__ ((aligned(4)));
};
static_assert(offsetof(::vendor::qti::hardware::display::mapperextensions::V1_0::PlaneLayout, component) == 0, "wrong offset");
static_assert(offsetof(::vendor::qti::hardware::display::mapperextensions::V1_0::PlaneLayout, h_subsampling) == 4, "wrong offset");
static_assert(offsetof(::vendor::qti::hardware::display::mapperextensions::V1_0::PlaneLayout, v_subsampling) == 8, "wrong offset");
static_assert(offsetof(::vendor::qti::hardware::display::mapperextensions::V1_0::PlaneLayout, offset) == 12, "wrong offset");
static_assert(offsetof(::vendor::qti::hardware::display::mapperextensions::V1_0::PlaneLayout, pixel_increment) == 16, "wrong offset");
static_assert(offsetof(::vendor::qti::hardware::display::mapperextensions::V1_0::PlaneLayout, stride) == 20, "wrong offset");
static_assert(offsetof(::vendor::qti::hardware::display::mapperextensions::V1_0::PlaneLayout, stride_bytes) == 24, "wrong offset");
static_assert(offsetof(::vendor::qti::hardware::display::mapperextensions::V1_0::PlaneLayout, scanlines) == 28, "wrong offset");
static_assert(offsetof(::vendor::qti::hardware::display::mapperextensions::V1_0::PlaneLayout, size) == 32, "wrong offset");
static_assert(sizeof(::vendor::qti::hardware::display::mapperextensions::V1_0::PlaneLayout) == 36, "wrong size");
static_assert(__alignof(::vendor::qti::hardware::display::mapperextensions::V1_0::PlaneLayout) == 4, "wrong alignment");
//
// type declarations for package
//
template<typename>
static inline std::string toString(int32_t o);
static inline std::string toString(::vendor::qti::hardware::display::mapperextensions::V1_0::Error o);
constexpr int32_t operator|(const ::vendor::qti::hardware::display::mapperextensions::V1_0::Error lhs, const ::vendor::qti::hardware::display::mapperextensions::V1_0::Error rhs) {
return static_cast<int32_t>(static_cast<int32_t>(lhs) | static_cast<int32_t>(rhs));
}
constexpr int32_t operator|(const int32_t lhs, const ::vendor::qti::hardware::display::mapperextensions::V1_0::Error rhs) {
return static_cast<int32_t>(lhs | static_cast<int32_t>(rhs));
}
constexpr int32_t operator|(const ::vendor::qti::hardware::display::mapperextensions::V1_0::Error lhs, const int32_t rhs) {
return static_cast<int32_t>(static_cast<int32_t>(lhs) | rhs);
}
constexpr int32_t operator&(const ::vendor::qti::hardware::display::mapperextensions::V1_0::Error lhs, const ::vendor::qti::hardware::display::mapperextensions::V1_0::Error rhs) {
return static_cast<int32_t>(static_cast<int32_t>(lhs) & static_cast<int32_t>(rhs));
}
constexpr int32_t operator&(const int32_t lhs, const ::vendor::qti::hardware::display::mapperextensions::V1_0::Error rhs) {
return static_cast<int32_t>(lhs & static_cast<int32_t>(rhs));
}
constexpr int32_t operator&(const ::vendor::qti::hardware::display::mapperextensions::V1_0::Error lhs, const int32_t rhs) {
return static_cast<int32_t>(static_cast<int32_t>(lhs) & rhs);
}
constexpr int32_t &operator|=(int32_t& v, const ::vendor::qti::hardware::display::mapperextensions::V1_0::Error e) {
v |= static_cast<int32_t>(e);
return v;
}
constexpr int32_t &operator&=(int32_t& v, const ::vendor::qti::hardware::display::mapperextensions::V1_0::Error e) {
v &= static_cast<int32_t>(e);
return v;
}
static inline std::string toString(const ::vendor::qti::hardware::display::mapperextensions::V1_0::YCbCrLayout& o);
// operator== and operator!= are not generated for YCbCrLayout
template<typename>
static inline std::string toString(uint32_t o);
static inline std::string toString(::vendor::qti::hardware::display::mapperextensions::V1_0::PlaneComponent o);
constexpr uint32_t operator|(const ::vendor::qti::hardware::display::mapperextensions::V1_0::PlaneComponent lhs, const ::vendor::qti::hardware::display::mapperextensions::V1_0::PlaneComponent rhs) {
return static_cast<uint32_t>(static_cast<uint32_t>(lhs) | static_cast<uint32_t>(rhs));
}
constexpr uint32_t operator|(const uint32_t lhs, const ::vendor::qti::hardware::display::mapperextensions::V1_0::PlaneComponent rhs) {
return static_cast<uint32_t>(lhs | static_cast<uint32_t>(rhs));
}
constexpr uint32_t operator|(const ::vendor::qti::hardware::display::mapperextensions::V1_0::PlaneComponent lhs, const uint32_t rhs) {
return static_cast<uint32_t>(static_cast<uint32_t>(lhs) | rhs);
}
constexpr uint32_t operator&(const ::vendor::qti::hardware::display::mapperextensions::V1_0::PlaneComponent lhs, const ::vendor::qti::hardware::display::mapperextensions::V1_0::PlaneComponent rhs) {
return static_cast<uint32_t>(static_cast<uint32_t>(lhs) & static_cast<uint32_t>(rhs));
}
constexpr uint32_t operator&(const uint32_t lhs, const ::vendor::qti::hardware::display::mapperextensions::V1_0::PlaneComponent rhs) {
return static_cast<uint32_t>(lhs & static_cast<uint32_t>(rhs));
}
constexpr uint32_t operator&(const ::vendor::qti::hardware::display::mapperextensions::V1_0::PlaneComponent lhs, const uint32_t rhs) {
return static_cast<uint32_t>(static_cast<uint32_t>(lhs) & rhs);
}
constexpr uint32_t &operator|=(uint32_t& v, const ::vendor::qti::hardware::display::mapperextensions::V1_0::PlaneComponent e) {
v |= static_cast<uint32_t>(e);
return v;
}
constexpr uint32_t &operator&=(uint32_t& v, const ::vendor::qti::hardware::display::mapperextensions::V1_0::PlaneComponent e) {
v &= static_cast<uint32_t>(e);
return v;
}
template<typename>
static inline std::string toString(int32_t o);
static inline std::string toString(::vendor::qti::hardware::display::mapperextensions::V1_0::Flags o);
constexpr int32_t operator|(const ::vendor::qti::hardware::display::mapperextensions::V1_0::Flags lhs, const ::vendor::qti::hardware::display::mapperextensions::V1_0::Flags rhs) {
return static_cast<int32_t>(static_cast<int32_t>(lhs) | static_cast<int32_t>(rhs));
}
constexpr int32_t operator|(const int32_t lhs, const ::vendor::qti::hardware::display::mapperextensions::V1_0::Flags rhs) {
return static_cast<int32_t>(lhs | static_cast<int32_t>(rhs));
}
constexpr int32_t operator|(const ::vendor::qti::hardware::display::mapperextensions::V1_0::Flags lhs, const int32_t rhs) {
return static_cast<int32_t>(static_cast<int32_t>(lhs) | rhs);
}
constexpr int32_t operator&(const ::vendor::qti::hardware::display::mapperextensions::V1_0::Flags lhs, const ::vendor::qti::hardware::display::mapperextensions::V1_0::Flags rhs) {
return static_cast<int32_t>(static_cast<int32_t>(lhs) & static_cast<int32_t>(rhs));
}
constexpr int32_t operator&(const int32_t lhs, const ::vendor::qti::hardware::display::mapperextensions::V1_0::Flags rhs) {
return static_cast<int32_t>(lhs & static_cast<int32_t>(rhs));
}
constexpr int32_t operator&(const ::vendor::qti::hardware::display::mapperextensions::V1_0::Flags lhs, const int32_t rhs) {
return static_cast<int32_t>(static_cast<int32_t>(lhs) & rhs);
}
constexpr int32_t &operator|=(int32_t& v, const ::vendor::qti::hardware::display::mapperextensions::V1_0::Flags e) {
v |= static_cast<int32_t>(e);
return v;
}
constexpr int32_t &operator&=(int32_t& v, const ::vendor::qti::hardware::display::mapperextensions::V1_0::Flags e) {
v &= static_cast<int32_t>(e);
return v;
}
static inline std::string toString(const ::vendor::qti::hardware::display::mapperextensions::V1_0::PlaneLayout& o);
static inline bool operator==(const ::vendor::qti::hardware::display::mapperextensions::V1_0::PlaneLayout& lhs, const ::vendor::qti::hardware::display::mapperextensions::V1_0::PlaneLayout& rhs);
static inline bool operator!=(const ::vendor::qti::hardware::display::mapperextensions::V1_0::PlaneLayout& lhs, const ::vendor::qti::hardware::display::mapperextensions::V1_0::PlaneLayout& rhs);
//
// type header definitions for package
//
template<>
inline std::string toString<::vendor::qti::hardware::display::mapperextensions::V1_0::Error>(int32_t o) {
using ::android::hardware::details::toHexString;
std::string os;
::android::hardware::hidl_bitfield<::vendor::qti::hardware::display::mapperextensions::V1_0::Error> flipped = 0;
bool first = true;
if ((o & ::vendor::qti::hardware::display::mapperextensions::V1_0::Error::NONE) == static_cast<int32_t>(::vendor::qti::hardware::display::mapperextensions::V1_0::Error::NONE)) {
os += (first ? "" : " | ");
os += "NONE";
first = false;
flipped |= ::vendor::qti::hardware::display::mapperextensions::V1_0::Error::NONE;
}
if ((o & ::vendor::qti::hardware::display::mapperextensions::V1_0::Error::BAD_BUFFER) == static_cast<int32_t>(::vendor::qti::hardware::display::mapperextensions::V1_0::Error::BAD_BUFFER)) {
os += (first ? "" : " | ");
os += "BAD_BUFFER";
first = false;
flipped |= ::vendor::qti::hardware::display::mapperextensions::V1_0::Error::BAD_BUFFER;
}
if ((o & ::vendor::qti::hardware::display::mapperextensions::V1_0::Error::NO_RESOURCES) == static_cast<int32_t>(::vendor::qti::hardware::display::mapperextensions::V1_0::Error::NO_RESOURCES)) {
os += (first ? "" : " | ");
os += "NO_RESOURCES";
first = false;
flipped |= ::vendor::qti::hardware::display::mapperextensions::V1_0::Error::NO_RESOURCES;
}
if ((o & ::vendor::qti::hardware::display::mapperextensions::V1_0::Error::UNSUPPORTED) == static_cast<int32_t>(::vendor::qti::hardware::display::mapperextensions::V1_0::Error::UNSUPPORTED)) {
os += (first ? "" : " | ");
os += "UNSUPPORTED";
first = false;
flipped |= ::vendor::qti::hardware::display::mapperextensions::V1_0::Error::UNSUPPORTED;
}
if (o != flipped) {
os += (first ? "" : " | ");
os += toHexString(o & (~flipped));
}os += " (";
os += toHexString(o);
os += ")";
return os;
}
static inline std::string toString(::vendor::qti::hardware::display::mapperextensions::V1_0::Error o) {
using ::android::hardware::details::toHexString;
if (o == ::vendor::qti::hardware::display::mapperextensions::V1_0::Error::NONE) {
return "NONE";
}
if (o == ::vendor::qti::hardware::display::mapperextensions::V1_0::Error::BAD_BUFFER) {
return "BAD_BUFFER";
}
if (o == ::vendor::qti::hardware::display::mapperextensions::V1_0::Error::NO_RESOURCES) {
return "NO_RESOURCES";
}
if (o == ::vendor::qti::hardware::display::mapperextensions::V1_0::Error::UNSUPPORTED) {
return "UNSUPPORTED";
}
std::string os;
os += toHexString(static_cast<int32_t>(o));
return os;
}
static inline std::string toString(const ::vendor::qti::hardware::display::mapperextensions::V1_0::YCbCrLayout& o) {
using ::android::hardware::toString;
std::string os;
os += "{";
os += ".y = ";
os += ::android::hardware::toString(o.y);
os += ", .cb = ";
os += ::android::hardware::toString(o.cb);
os += ", .cr = ";
os += ::android::hardware::toString(o.cr);
os += ", .yStride = ";
os += ::android::hardware::toString(o.yStride);
os += ", .cStride = ";
os += ::android::hardware::toString(o.cStride);
os += ", .chromaStep = ";
os += ::android::hardware::toString(o.chromaStep);
os += "}"; return os;
}
// operator== and operator!= are not generated for YCbCrLayout
template<>
inline std::string toString<::vendor::qti::hardware::display::mapperextensions::V1_0::PlaneComponent>(uint32_t o) {
using ::android::hardware::details::toHexString;
std::string os;
::android::hardware::hidl_bitfield<::vendor::qti::hardware::display::mapperextensions::V1_0::PlaneComponent> flipped = 0;
bool first = true;
if ((o & ::vendor::qti::hardware::display::mapperextensions::V1_0::PlaneComponent::PLANE_COMPONENT_Y) == static_cast<uint32_t>(::vendor::qti::hardware::display::mapperextensions::V1_0::PlaneComponent::PLANE_COMPONENT_Y)) {
os += (first ? "" : " | ");
os += "PLANE_COMPONENT_Y";
first = false;
flipped |= ::vendor::qti::hardware::display::mapperextensions::V1_0::PlaneComponent::PLANE_COMPONENT_Y;
}
if ((o & ::vendor::qti::hardware::display::mapperextensions::V1_0::PlaneComponent::PLANE_COMPONENT_Cb) == static_cast<uint32_t>(::vendor::qti::hardware::display::mapperextensions::V1_0::PlaneComponent::PLANE_COMPONENT_Cb)) {
os += (first ? "" : " | ");
os += "PLANE_COMPONENT_Cb";
first = false;
flipped |= ::vendor::qti::hardware::display::mapperextensions::V1_0::PlaneComponent::PLANE_COMPONENT_Cb;
}
if ((o & ::vendor::qti::hardware::display::mapperextensions::V1_0::PlaneComponent::PLANE_COMPONENT_Cr) == static_cast<uint32_t>(::vendor::qti::hardware::display::mapperextensions::V1_0::PlaneComponent::PLANE_COMPONENT_Cr)) {
os += (first ? "" : " | ");
os += "PLANE_COMPONENT_Cr";
first = false;
flipped |= ::vendor::qti::hardware::display::mapperextensions::V1_0::PlaneComponent::PLANE_COMPONENT_Cr;
}
if ((o & ::vendor::qti::hardware::display::mapperextensions::V1_0::PlaneComponent::PLANE_COMPONENT_R) == static_cast<uint32_t>(::vendor::qti::hardware::display::mapperextensions::V1_0::PlaneComponent::PLANE_COMPONENT_R)) {
os += (first ? "" : " | ");
os += "PLANE_COMPONENT_R";
first = false;
flipped |= ::vendor::qti::hardware::display::mapperextensions::V1_0::PlaneComponent::PLANE_COMPONENT_R;
}
if ((o & ::vendor::qti::hardware::display::mapperextensions::V1_0::PlaneComponent::PLANE_COMPONENT_G) == static_cast<uint32_t>(::vendor::qti::hardware::display::mapperextensions::V1_0::PlaneComponent::PLANE_COMPONENT_G)) {
os += (first ? "" : " | ");
os += "PLANE_COMPONENT_G";
first = false;
flipped |= ::vendor::qti::hardware::display::mapperextensions::V1_0::PlaneComponent::PLANE_COMPONENT_G;
}
if ((o & ::vendor::qti::hardware::display::mapperextensions::V1_0::PlaneComponent::PLANE_COMPONENT_B) == static_cast<uint32_t>(::vendor::qti::hardware::display::mapperextensions::V1_0::PlaneComponent::PLANE_COMPONENT_B)) {
os += (first ? "" : " | ");
os += "PLANE_COMPONENT_B";
first = false;
flipped |= ::vendor::qti::hardware::display::mapperextensions::V1_0::PlaneComponent::PLANE_COMPONENT_B;
}
if ((o & ::vendor::qti::hardware::display::mapperextensions::V1_0::PlaneComponent::PLANE_COMPONENT_A) == static_cast<uint32_t>(::vendor::qti::hardware::display::mapperextensions::V1_0::PlaneComponent::PLANE_COMPONENT_A)) {
os += (first ? "" : " | ");
os += "PLANE_COMPONENT_A";
first = false;
flipped |= ::vendor::qti::hardware::display::mapperextensions::V1_0::PlaneComponent::PLANE_COMPONENT_A;
}
if ((o & ::vendor::qti::hardware::display::mapperextensions::V1_0::PlaneComponent::PLANE_COMPONENT_RAW) == static_cast<uint32_t>(::vendor::qti::hardware::display::mapperextensions::V1_0::PlaneComponent::PLANE_COMPONENT_RAW)) {
os += (first ? "" : " | ");
os += "PLANE_COMPONENT_RAW";
first = false;
flipped |= ::vendor::qti::hardware::display::mapperextensions::V1_0::PlaneComponent::PLANE_COMPONENT_RAW;
}
if ((o & ::vendor::qti::hardware::display::mapperextensions::V1_0::PlaneComponent::PLANE_COMPONENT_META) == static_cast<uint32_t>(::vendor::qti::hardware::display::mapperextensions::V1_0::PlaneComponent::PLANE_COMPONENT_META)) {
os += (first ? "" : " | ");
os += "PLANE_COMPONENT_META";
first = false;
flipped |= ::vendor::qti::hardware::display::mapperextensions::V1_0::PlaneComponent::PLANE_COMPONENT_META;
}
if (o != flipped) {
os += (first ? "" : " | ");
os += toHexString(o & (~flipped));
}os += " (";
os += toHexString(o);
os += ")";
return os;
}
static inline std::string toString(::vendor::qti::hardware::display::mapperextensions::V1_0::PlaneComponent o) {
using ::android::hardware::details::toHexString;
if (o == ::vendor::qti::hardware::display::mapperextensions::V1_0::PlaneComponent::PLANE_COMPONENT_Y) {
return "PLANE_COMPONENT_Y";
}
if (o == ::vendor::qti::hardware::display::mapperextensions::V1_0::PlaneComponent::PLANE_COMPONENT_Cb) {
return "PLANE_COMPONENT_Cb";
}
if (o == ::vendor::qti::hardware::display::mapperextensions::V1_0::PlaneComponent::PLANE_COMPONENT_Cr) {
return "PLANE_COMPONENT_Cr";
}
if (o == ::vendor::qti::hardware::display::mapperextensions::V1_0::PlaneComponent::PLANE_COMPONENT_R) {
return "PLANE_COMPONENT_R";
}
if (o == ::vendor::qti::hardware::display::mapperextensions::V1_0::PlaneComponent::PLANE_COMPONENT_G) {
return "PLANE_COMPONENT_G";
}
if (o == ::vendor::qti::hardware::display::mapperextensions::V1_0::PlaneComponent::PLANE_COMPONENT_B) {
return "PLANE_COMPONENT_B";
}
if (o == ::vendor::qti::hardware::display::mapperextensions::V1_0::PlaneComponent::PLANE_COMPONENT_A) {
return "PLANE_COMPONENT_A";
}
if (o == ::vendor::qti::hardware::display::mapperextensions::V1_0::PlaneComponent::PLANE_COMPONENT_RAW) {
return "PLANE_COMPONENT_RAW";
}
if (o == ::vendor::qti::hardware::display::mapperextensions::V1_0::PlaneComponent::PLANE_COMPONENT_META) {
return "PLANE_COMPONENT_META";
}
std::string os;
os += toHexString(static_cast<uint32_t>(o));
return os;
}
template<>
inline std::string toString<::vendor::qti::hardware::display::mapperextensions::V1_0::Flags>(int32_t o) {
using ::android::hardware::details::toHexString;
std::string os;
::android::hardware::hidl_bitfield<::vendor::qti::hardware::display::mapperextensions::V1_0::Flags> flipped = 0;
bool first = true;
if ((o & ::vendor::qti::hardware::display::mapperextensions::V1_0::Flags::LAYOUT_INTERLACED_FLAG) == static_cast<int32_t>(::vendor::qti::hardware::display::mapperextensions::V1_0::Flags::LAYOUT_INTERLACED_FLAG)) {
os += (first ? "" : " | ");
os += "LAYOUT_INTERLACED_FLAG";
first = false;
flipped |= ::vendor::qti::hardware::display::mapperextensions::V1_0::Flags::LAYOUT_INTERLACED_FLAG;
}
if (o != flipped) {
os += (first ? "" : " | ");
os += toHexString(o & (~flipped));
}os += " (";
os += toHexString(o);
os += ")";
return os;
}
static inline std::string toString(::vendor::qti::hardware::display::mapperextensions::V1_0::Flags o) {
using ::android::hardware::details::toHexString;
if (o == ::vendor::qti::hardware::display::mapperextensions::V1_0::Flags::LAYOUT_INTERLACED_FLAG) {
return "LAYOUT_INTERLACED_FLAG";
}
std::string os;
os += toHexString(static_cast<int32_t>(o));
return os;
}
static inline std::string toString(const ::vendor::qti::hardware::display::mapperextensions::V1_0::PlaneLayout& o) {
using ::android::hardware::toString;
std::string os;
os += "{";
os += ".component = ";
os += ::vendor::qti::hardware::display::mapperextensions::V1_0::toString<::vendor::qti::hardware::display::mapperextensions::V1_0::PlaneComponent>(o.component);
os += ", .h_subsampling = ";
os += ::android::hardware::toString(o.h_subsampling);
os += ", .v_subsampling = ";
os += ::android::hardware::toString(o.v_subsampling);
os += ", .offset = ";
os += ::android::hardware::toString(o.offset);
os += ", .pixel_increment = ";
os += ::android::hardware::toString(o.pixel_increment);
os += ", .stride = ";
os += ::android::hardware::toString(o.stride);
os += ", .stride_bytes = ";
os += ::android::hardware::toString(o.stride_bytes);
os += ", .scanlines = ";
os += ::android::hardware::toString(o.scanlines);
os += ", .size = ";
os += ::android::hardware::toString(o.size);
os += "}"; return os;
}
static inline bool operator==(const ::vendor::qti::hardware::display::mapperextensions::V1_0::PlaneLayout& lhs, const ::vendor::qti::hardware::display::mapperextensions::V1_0::PlaneLayout& rhs) {
if (lhs.component != rhs.component) {
return false;
}
if (lhs.h_subsampling != rhs.h_subsampling) {
return false;
}
if (lhs.v_subsampling != rhs.v_subsampling) {
return false;
}
if (lhs.offset != rhs.offset) {
return false;
}
if (lhs.pixel_increment != rhs.pixel_increment) {
return false;
}
if (lhs.stride != rhs.stride) {
return false;
}
if (lhs.stride_bytes != rhs.stride_bytes) {
return false;
}
if (lhs.scanlines != rhs.scanlines) {
return false;
}
if (lhs.size != rhs.size) {
return false;
}
return true;
}
static inline bool operator!=(const ::vendor::qti::hardware::display::mapperextensions::V1_0::PlaneLayout& lhs, const ::vendor::qti::hardware::display::mapperextensions::V1_0::PlaneLayout& rhs){
return !(lhs == rhs);
}
} // namespace V1_0
} // namespace mapperextensions
} // namespace display
} // namespace hardware
} // namespace qti
} // namespace vendor
//
// global type declarations for package
//
namespace android {
namespace hardware {
namespace details {
template<> constexpr std::array<::vendor::qti::hardware::display::mapperextensions::V1_0::Error, 4> hidl_enum_values<::vendor::qti::hardware::display::mapperextensions::V1_0::Error> = {
::vendor::qti::hardware::display::mapperextensions::V1_0::Error::NONE,
::vendor::qti::hardware::display::mapperextensions::V1_0::Error::BAD_BUFFER,
::vendor::qti::hardware::display::mapperextensions::V1_0::Error::NO_RESOURCES,
::vendor::qti::hardware::display::mapperextensions::V1_0::Error::UNSUPPORTED,
};
} // namespace details
} // namespace hardware
} // namespace android
namespace android {
namespace hardware {
namespace details {
template<> constexpr std::array<::vendor::qti::hardware::display::mapperextensions::V1_0::PlaneComponent, 9> hidl_enum_values<::vendor::qti::hardware::display::mapperextensions::V1_0::PlaneComponent> = {
::vendor::qti::hardware::display::mapperextensions::V1_0::PlaneComponent::PLANE_COMPONENT_Y,
::vendor::qti::hardware::display::mapperextensions::V1_0::PlaneComponent::PLANE_COMPONENT_Cb,
::vendor::qti::hardware::display::mapperextensions::V1_0::PlaneComponent::PLANE_COMPONENT_Cr,
::vendor::qti::hardware::display::mapperextensions::V1_0::PlaneComponent::PLANE_COMPONENT_R,
::vendor::qti::hardware::display::mapperextensions::V1_0::PlaneComponent::PLANE_COMPONENT_G,
::vendor::qti::hardware::display::mapperextensions::V1_0::PlaneComponent::PLANE_COMPONENT_B,
::vendor::qti::hardware::display::mapperextensions::V1_0::PlaneComponent::PLANE_COMPONENT_A,
::vendor::qti::hardware::display::mapperextensions::V1_0::PlaneComponent::PLANE_COMPONENT_RAW,
::vendor::qti::hardware::display::mapperextensions::V1_0::PlaneComponent::PLANE_COMPONENT_META,
};
} // namespace details
} // namespace hardware
} // namespace android
namespace android {
namespace hardware {
namespace details {
template<> constexpr std::array<::vendor::qti::hardware::display::mapperextensions::V1_0::Flags, 1> hidl_enum_values<::vendor::qti::hardware::display::mapperextensions::V1_0::Flags> = {
::vendor::qti::hardware::display::mapperextensions::V1_0::Flags::LAYOUT_INTERLACED_FLAG,
};
} // namespace details
} // namespace hardware
} // namespace android
#endif // HIDL_GENERATED_VENDOR_QTI_HARDWARE_DISPLAY_MAPPEREXTENSIONS_V1_0_TYPES_H

View file

@ -0,0 +1,293 @@
/*
* Copyright (c) 2016-2022, The Linux Foundation. All rights reserved.
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of The Linux Foundation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#define LOG_TAG "qtimapper-shim"
#include <hidl/HidlSupport.h>
#include <hidl/MQDescriptor.h>
#include <hidl/Status.h>
#include <utils/NativeHandle.h>
#include <utils/misc.h>
#include <android/hidl/base/1.0/BpHwBase.h>
#include <log/log.h>
#include "ext_headers/common.h"
#include "ext_headers/mapper.h"
#include "ext_headers/mapperextensions.h"
using namespace android::hardware;
using namespace android;
bool IBase::isRemote() const {
return false;
}
namespace android::hardware::graphics::mapper {
namespace V2_0 {
sp<IMapper> IMapper::getService(const std::string &/* serviceName */, const bool /* getStub */) {
return nullptr;
}
}
namespace V3_0 {
sp<IMapper> IMapper::getService(const std::string &/* serviceName */, const bool /* getStub */) {
return nullptr;
}
}
namespace V4_0 {
sp<IMapper> IMapper::getService(const std::string &/* serviceName */, const bool /* getStub */) {
return nullptr;
}
}
}
namespace vendor::qti::hardware::display {
namespace mapper {
namespace V4_0 {
Return<sp<IQtiMapper>> IQtiMapper::castFrom(const sp<graphics::mapper::V4_0::IMapper> &/* parent */, bool /* emitV1_0::Error */) {
return nullptr;
}
}
namespace V3_0 {
Return<sp<IQtiMapper>> IQtiMapper::castFrom(const sp<graphics::mapper::V3_0::IMapper> &/* parent */, bool /* emitV1_0::Error */) {
return nullptr;
}
}
namespace V2_0 {
Return<sp<IQtiMapper>> IQtiMapper::castFrom(const sp<graphics::mapper::V2_0::IMapper> &/* parent */, bool /* emitV1_0::Error */) {
return new IQtiMapper();
}
Return<void> IQtiMapper::getMapperExtensions(getMapperExtensions_cb _hidl_cb) {
sp<mapperextensions::V1_0::IQtiMapperExtensions> ext{new mapperextensions::V1_0::IQtiMapperExtensions()};
_hidl_cb(graphics::mapper::V2_0::Error::NONE, ext);
ALOGD("IQtiMapperExtensions shim active");
return Void();
}
}
}
namespace mapperextensions {
namespace V1_1 {
IQtiMapperExtensions::IQtiMapperExtensions() {
hw_module_t const *module;
if (hw_get_module(GRALLOC_HARDWARE_MODULE_ID, &module)) {
ALOGE("Failed to open gralloc module!");
std::terminate();
}
if (gralloc1_open(module, &gralloc)) {
ALOGE("Failed to open gralloc HAL!");
std::terminate();
}
perform = reinterpret_cast<GRALLOC1_PFN_PERFORM>(gralloc->getFunction(gralloc, GRALLOC1_FUNCTION_PERFORM));
if (!perform) {
ALOGE("Failed to get gralloc perform helper!");
std::terminate();
}
ALOGD("Opened gralloc1 HAL");
}
Return<sp<IQtiMapperExtensions>> IQtiMapperExtensions::castFrom(android::sp<V1_0::IQtiMapperExtensions> const& /* parent */, bool /* emitV1_0::Error */) {
return new IQtiMapperExtensions();
}
Return<void> IQtiMapperExtensions::getRgbDataAddress(void *buffer, getRgbDataAddress_cb _hidl_cb) {
void *rgb_data = nullptr;
auto err = perform(gralloc, GRALLOC_MODULE_PERFORM_GET_RGB_DATA_ADDRESS, buffer, &rgb_data) ? V1_0::Error::NONE : V1_0::Error::BAD_BUFFER;
_hidl_cb(err, rgb_data);
return Void();
}
Return<void> IQtiMapperExtensions::getInterlacedFlag(void* buffer, getInterlacedFlag_cb _hidl_cb) {
int flag = 0;
auto perform = reinterpret_cast<GRALLOC1_PFN_PERFORM>(gralloc->getFunction(gralloc, GRALLOC1_FUNCTION_PERFORM));
auto err = perform(gralloc, GRALLOC1_MODULE_PERFORM_GET_INTERLACE_FLAG, buffer, &flag) ? V1_0::Error::NONE : V1_0::Error::BAD_BUFFER;
_hidl_cb(err, flag);
return Void();
}
Return<void> IQtiMapperExtensions::getFd(void *buffer, getFd_cb hidl_cb) {
auto err = V1_0::Error::BAD_BUFFER;
int fd = 0;
auto hnd = static_cast<private_handle_t *>(buffer);
if (buffer != nullptr && private_handle_t::validate(hnd) == 0) {
err = V1_0::Error::NONE;
fd = hnd->fd;
}
hidl_cb(err, fd);
return Void();
}
Return<void> IQtiMapperExtensions::getWidth(void *buffer, getWidth_cb hidl_cb) {
auto err = V1_0::Error::BAD_BUFFER;
int width = 0;
auto hnd = static_cast<private_handle_t *>(buffer);
if (buffer != nullptr && private_handle_t::validate(hnd) == 0) {
err = V1_0::Error::NONE;
width = hnd->width;
}
hidl_cb(err, width);
return Void();
}
Return<void> IQtiMapperExtensions::getHeight(void *buffer, getHeight_cb hidl_cb) {
auto err = V1_0::Error::BAD_BUFFER;
int height = 0;
auto hnd = static_cast<private_handle_t *>(buffer);
if (buffer != nullptr && private_handle_t::validate(hnd) == 0) {
err = V1_0::Error::NONE;
height = hnd->height;
}
hidl_cb(err, height);
return Void();
}
Return<void> IQtiMapperExtensions::getFormat(void *buffer, getFormat_cb hidl_cb) {
auto err = V1_0::Error::BAD_BUFFER;
int format = 0;
auto hnd = static_cast<private_handle_t *>(buffer);
if (buffer != nullptr && private_handle_t::validate(hnd) == 0) {
err = V1_0::Error::NONE;
format = hnd->format;
}
hidl_cb(err, format);
return Void();
}
Return<void> IQtiMapperExtensions::getPrivateFlags(void *buffer, getPrivateFlags_cb hidl_cb) {
auto err = V1_0::Error::BAD_BUFFER;
int flags = 0;
auto hnd = static_cast<private_handle_t *>(buffer);
if (buffer != nullptr && private_handle_t::validate(hnd) == 0) {
err = V1_0::Error::NONE;
flags = hnd->flags;
}
hidl_cb(err, flags);
return Void();
}
Return<void> IQtiMapperExtensions::getUnalignedWidth(void *buffer, getUnalignedWidth_cb hidl_cb) {
auto err = V1_0::Error::BAD_BUFFER;
int unaligned_width = 0;
auto hnd = static_cast<private_handle_t *>(buffer);
if (buffer != nullptr && private_handle_t::validate(hnd) == 0) {
err = V1_0::Error::NONE;
unaligned_width = hnd->unaligned_width;
}
hidl_cb(err, unaligned_width);
return Void();
}
Return<void> IQtiMapperExtensions::getUnalignedHeight(void *buffer, getUnalignedHeight_cb hidl_cb) {
auto err = V1_0::Error::BAD_BUFFER;
int unaligned_height = 0;
auto hnd = static_cast<private_handle_t *>(buffer);
if (buffer != nullptr && private_handle_t::validate(hnd) == 0) {
err = V1_0::Error::NONE;
unaligned_height = hnd->unaligned_height;
}
hidl_cb(err, unaligned_height);
return Void();
}
Return<void> IQtiMapperExtensions::getLayerCount(void *buffer, getLayerCount_cb hidl_cb) {
auto err = V1_0::Error::BAD_BUFFER;
unsigned int layer_count = 0;
auto hnd = static_cast<private_handle_t *>(buffer);
if (buffer != nullptr && private_handle_t::validate(hnd) == 0) {
err = V1_0::Error::NONE;
layer_count = hnd->layer_count;
}
hidl_cb(err, layer_count);
return Void();
}
Return<void> IQtiMapperExtensions::getId(void *buffer, getId_cb hidl_cb) {
auto err = V1_0::Error::BAD_BUFFER;
uint64_t id = 0;
auto hnd = static_cast<private_handle_t *>(buffer);
if (buffer != nullptr && private_handle_t::validate(hnd) == 0) {
err = V1_0::Error::NONE;
id = hnd->id;
}
hidl_cb(err, id);
return Void();
}
Return<void> IQtiMapperExtensions::getUsageFlags(void *buffer, getUsageFlags_cb hidl_cb) {
auto err = V1_0::Error::BAD_BUFFER;
uint64_t usage = 0;
auto hnd = static_cast<private_handle_t *>(buffer);
if (buffer != nullptr && private_handle_t::validate(hnd) == 0) {
err = V1_0::Error::NONE;
usage = hnd->usage;
}
hidl_cb(err, usage);
return Void();
}
Return<void> IQtiMapperExtensions::getSize(void *buffer, getSize_cb hidl_cb) {
auto err = V1_0::Error::BAD_BUFFER;
unsigned int size = 0;
auto hnd = static_cast<private_handle_t *>(buffer);
if (buffer != nullptr && private_handle_t::validate(hnd) == 0) {
err = V1_0::Error::NONE;
size = hnd->size;
}
hidl_cb(err, size);
return Void();
}
Return<void> IQtiMapperExtensions::getOffset(void *buffer, getOffset_cb hidl_cb) {
auto err = V1_0::Error::BAD_BUFFER;
unsigned int offset = 0;
auto hnd = static_cast<private_handle_t *>(buffer);
if (buffer != nullptr && private_handle_t::validate(hnd) == 0) {
err = V1_0::Error::NONE;
offset = hnd->offset;
}
hidl_cb(err, offset);
return Void();
}
}
}
}