diff --git a/.gitmodules b/.gitmodules index 017fb5edfd..94ac4d33f3 100644 --- a/.gitmodules +++ b/.gitmodules @@ -4,6 +4,3 @@ [submodule "libusb"] path = externals/libusb/libusb url = https://github.com/libusb/libusb.git -[submodule "externals/boost-headers"] - path = externals/boost-headers - url = https://github.com/boostorg/headers.git diff --git a/.patch/discord-rpc/0001-cmake-version.patch b/.patch/discord-rpc/0001-cmake-version.patch new file mode 100644 index 0000000000..6a1609fadf --- /dev/null +++ b/.patch/discord-rpc/0001-cmake-version.patch @@ -0,0 +1,10 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 5dad9e9..760a1b2 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -1,4 +1,4 @@ +-cmake_minimum_required (VERSION 3.2.0) ++cmake_minimum_required (VERSION 3.10) + project (DiscordRPC) + + include(GNUInstallDirs) diff --git a/.patch/discord-rpc/0002-no-clang-format.patch b/.patch/discord-rpc/0002-no-clang-format.patch new file mode 100644 index 0000000000..4b1e37c29f --- /dev/null +++ b/.patch/discord-rpc/0002-no-clang-format.patch @@ -0,0 +1,40 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 760a1b2..540d643 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -12,20 +12,6 @@ file(GLOB_RECURSE ALL_SOURCE_FILES + src/*.cpp src/*.h src/*.c + ) + +-# Set CLANG_FORMAT_SUFFIX if you are using custom clang-format, e.g. clang-format-5.0 +-find_program(CLANG_FORMAT_CMD clang-format${CLANG_FORMAT_SUFFIX}) +- +-if (CLANG_FORMAT_CMD) +- add_custom_target( +- clangformat +- COMMAND ${CLANG_FORMAT_CMD} +- -i -style=file -fallback-style=none +- ${ALL_SOURCE_FILES} +- DEPENDS +- ${ALL_SOURCE_FILES} +- ) +-endif(CLANG_FORMAT_CMD) +- + # thirdparty stuff + execute_process( + COMMAND mkdir ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty +diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt +index 290d761..cd2cc92 100644 +--- a/src/CMakeLists.txt ++++ b/src/CMakeLists.txt +@@ -120,10 +120,6 @@ if (${BUILD_SHARED_LIBS}) + target_compile_definitions(discord-rpc PRIVATE -DDISCORD_BUILDING_SDK) + endif(${BUILD_SHARED_LIBS}) + +-if (CLANG_FORMAT_CMD) +- add_dependencies(discord-rpc clangformat) +-endif(CLANG_FORMAT_CMD) +- + # install + + install( diff --git a/.patch/libadrenotools/0001-linkerns-cpm.patch b/.patch/libadrenotools/0001-linkerns-cpm.patch new file mode 100644 index 0000000000..8c5abe28e5 --- /dev/null +++ b/.patch/libadrenotools/0001-linkerns-cpm.patch @@ -0,0 +1,20 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 16c6092..9e75548 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -8,7 +8,14 @@ project(adrenotools LANGUAGES CXX C) + + set(GEN_INSTALL_TARGET OFF CACHE BOOL "") + +-add_subdirectory(lib/linkernsbypass) ++include(CPM) ++set(CPM_USE_LOCAL_PACKAGES OFF) ++ ++CPMAddPackage( ++ NAME linkernsbypass ++ URL "https://github.com/bylaws/liblinkernsbypass/archive/aa3975893d.zip" ++ URL_HASH SHA512=43d3d146facb7ec99d066a9b8990369ab7b9eec0d5f9a67131b0a0744fde0af27d884ca1f2a272cd113718a23356530ed97703c8c0659c4c25948d50c106119e ++) + + set(LIB_SOURCES src/bcenabler.cpp + src/driver.cpp diff --git a/externals/CMakeLists.txt b/externals/CMakeLists.txt index bb18fb0247..bf9ca8da6f 100644 --- a/externals/CMakeLists.txt +++ b/externals/CMakeLists.txt @@ -315,7 +315,13 @@ if (YUZU_USE_EXTERNAL_VULKAN_SPIRV_TOOLS) endif() # Boost headers -add_subdirectory(boost-headers) +set(CPM_USE_LOCAL_PACKAGES OFF) + +CPMAddPackage( + NAME boost_headers + URL "https://github.com/boostorg/headers/archive/0456900fad.zip" + URL_HASH SHA512=50cd75dcdfc5f082225cdace058f47b4fb114a47585f7aee1d22236a910a80b667186254c214fa2fcebac67ae6d37ba4b6e695e1faea8affd6fd42a03cf996e3 +) # TZDB (Time Zone Database) add_subdirectory(nx_tzdb) @@ -362,9 +368,17 @@ if (NOT TARGET RenderDoc::API) endif() if (ANDROID) - if (ARCHITECTURE_arm64) - add_subdirectory(libadrenotools) - endif() + if (ARCHITECTURE_arm64) + set(CPM_USE_LOCAL_PACKAGES OFF) + + CPMAddPackage( + NAME libadrenotools + URL "https://github.com/bylaws/libadrenotools/archive/8fae8ce254.zip" + URL_HASH SHA512=c74fa855f0edebbf25c9bce40b00966daa2447bfc5e15f0cf1a95f86cbf70fc6b02590707edbde16328a0a2a4fb9a1fc419d2dfc22a4a4150971be91892d4edb + PATCHES + ${CMAKE_SOURCE_DIR}/.patch/libadrenotools/0001-linkerns-cpm.patch + ) + endif() endif() if ((CMAKE_SYSTEM_NAME STREQUAL "Linux" OR ANDROID) AND NOT TARGET gamemode::headers) diff --git a/externals/boost-headers b/externals/boost-headers deleted file mode 160000 index 0456900fad..0000000000 --- a/externals/boost-headers +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 0456900fadde4b07c84760eadea4ccc9f948fe28 diff --git a/externals/libadrenotools/.gitmodules b/externals/libadrenotools/.gitmodules deleted file mode 100644 index accd2b965f..0000000000 --- a/externals/libadrenotools/.gitmodules +++ /dev/null @@ -1,4 +0,0 @@ -[submodule "lib/linkernsbypass"] - path = lib/linkernsbypass - url = https://github.com/bylaws/liblinkernsbypass/ - branch = master diff --git a/externals/libadrenotools/CMakeLists.txt b/externals/libadrenotools/CMakeLists.txt deleted file mode 100644 index 16c6092302..0000000000 --- a/externals/libadrenotools/CMakeLists.txt +++ /dev/null @@ -1,37 +0,0 @@ -cmake_minimum_required(VERSION 3.14) - -if(NOT ${CMAKE_ANDROID_ARCH_ABI} STREQUAL arm64-v8a) - message(FATAL_ERROR "Unsupported target architecture: ${CMAKE_ANDROID_ARCH_ABI}. Please make an issue on the repo!") -endif() - -project(adrenotools LANGUAGES CXX C) - -set(GEN_INSTALL_TARGET OFF CACHE BOOL "") - -add_subdirectory(lib/linkernsbypass) - -set(LIB_SOURCES src/bcenabler.cpp - src/driver.cpp - include/adrenotools/bcenabler.h - include/adrenotools/driver.h - include/adrenotools/priv.h) - -add_library(adrenotools ${LIB_SOURCES}) - -target_include_directories(adrenotools PUBLIC include) -target_include_directories(adrenotools PRIVATE .) -target_compile_options(adrenotools PRIVATE -Wall -Wextra) -target_link_libraries(adrenotools android linkernsbypass) - -add_subdirectory(src/hook) -if (${BUILD_SHARED_LIBS}) - target_link_options(adrenotools PRIVATE "-Wl,-s,--exclude-libs,liblinkernsbypass.a") -endif() -if (${GEN_INSTALL_TARGET}) - configure_file(adrenotools.pc.in adrenotools.pc @ONLY) - install(FILES ${CMAKE_BINARY_DIR}/adrenotools.pc DESTINATION lib/pkgconfig) - install(TARGETS adrenotools main_hook file_redirect_hook gsl_alloc_hook hook_impl) - install(DIRECTORY include/ - DESTINATION include - FILES_MATCHING PATTERN "*.h*") -endif() diff --git a/externals/libadrenotools/LICENSE b/externals/libadrenotools/LICENSE deleted file mode 100644 index a8f664a745..0000000000 --- a/externals/libadrenotools/LICENSE +++ /dev/null @@ -1,24 +0,0 @@ -BSD 2-Clause License - -Copyright (c) 2021, Billy Laws - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - -1. Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. - -2. 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. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER 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. diff --git a/externals/libadrenotools/README.md b/externals/libadrenotools/README.md deleted file mode 100644 index b265f4c8b1..0000000000 --- a/externals/libadrenotools/README.md +++ /dev/null @@ -1,30 +0,0 @@ -### Adreno Tools -A library for applying rootless Adreno GPU driver modifications/replacements. Currently supports loading custom GPU drivers such as [turnip](https://docs.mesa3d.org/android.html#building-using-the-android-ndk), enabling BCn textures and redirecting file operations to allow accessing shader dumps and modification of the [driver config file](https://gist.github.com/bylaws/04130932e2634d1c6a2a9729e3940d60) without root. - -#### Documentation -API is documented in the `include/adrenotools` headers. - -#### Support -Android 9+ -Arm64 - -Please create an issue if support for anything else is desired. - -### FAQ - -#### Is there an example project? - -There is a simple bare-bones project [AdrenoToolsTest](https://github.com/darksylinc/AdrenoToolsTest) demonstrating how to get libadrenotools working. - -#### How do I use this to update the drivers on my phone? Where's the apk? - -You don't. This library is **not** for installing into Android and is **not** for end users. -This library is aimed at other developers. - -Each individual app must explicitly make use of libadrenotools in order to load custom drivers into an app / game. - -#### How do I use this library to make \ use newer drivers? - -See previous question. It's up to the game developer to add support & use this library. - -You could contact them to so they add support for it; but that's out of our power. \ No newline at end of file diff --git a/externals/libadrenotools/adrenotools.pc.in b/externals/libadrenotools/adrenotools.pc.in deleted file mode 100644 index 1102f434c8..0000000000 --- a/externals/libadrenotools/adrenotools.pc.in +++ /dev/null @@ -1,13 +0,0 @@ -prefix="@CMAKE_INSTALL_PREFIX@" -exec_prefix=${prefix} -libdir=${exec_prefix}/lib -includedir=${prefix}/include - -Name: adrenotools -Description: -URL: -Version: 1.0.0 -Libs: -L${libdir} -ladrenotools -Libs.private: -Requires.private: -Cflags: -I${includedir} diff --git a/externals/libadrenotools/build_asm.sh b/externals/libadrenotools/build_asm.sh deleted file mode 100755 index b53d25c1ba..0000000000 --- a/externals/libadrenotools/build_asm.sh +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/sh - -aarch64-linux-gnu-gcc -c src/bcenabler_patch.s -o /tmp/patch.o -aarch64-linux-gnu-objcopy -O binary -j .text /tmp/patch.o /tmp/patch.bin - -# Must be smaller than a single page -bin2c -o gen/bcenabler_patch.h -n PatchRawData /tmp/patch.bin - -rm /tmp/patch.o -rm /tmp/patch.bin diff --git a/externals/libadrenotools/gen/bcenabler_patch.h b/externals/libadrenotools/gen/bcenabler_patch.h deleted file mode 100644 index 3909a25ca1..0000000000 --- a/externals/libadrenotools/gen/bcenabler_patch.h +++ /dev/null @@ -1,23 +0,0 @@ -/* Generated by bin2c, do not edit manually */ - -/* Contents of file /tmp/patch.bin */ -const long int PatchRawData_size = 264; -const unsigned char PatchRawData[264] = { - 0x1F, 0x0C, 0x02, 0x71, 0x61, 0x00, 0x00, 0x54, 0xE0, 0x08, 0x80, 0x52, 0x3E, 0x00, 0x00, 0x14, - 0x1F, 0x14, 0x02, 0x71, 0x61, 0x00, 0x00, 0x54, 0xE0, 0x08, 0x80, 0x52, 0x3A, 0x00, 0x00, 0x14, - 0x1F, 0x10, 0x02, 0x71, 0x61, 0x00, 0x00, 0x54, 0x00, 0x09, 0x80, 0x52, 0x36, 0x00, 0x00, 0x14, - 0x1F, 0x18, 0x02, 0x71, 0x61, 0x00, 0x00, 0x54, 0x00, 0x09, 0x80, 0x52, 0x32, 0x00, 0x00, 0x14, - 0x1F, 0x1C, 0x02, 0x71, 0x61, 0x00, 0x00, 0x54, 0x40, 0x09, 0x80, 0x52, 0x2E, 0x00, 0x00, 0x14, - 0x1F, 0x20, 0x02, 0x71, 0x61, 0x00, 0x00, 0x54, 0x60, 0x09, 0x80, 0x52, 0x2A, 0x00, 0x00, 0x14, - 0x1F, 0x24, 0x02, 0x71, 0x61, 0x00, 0x00, 0x54, 0xA0, 0x09, 0x80, 0x52, 0x26, 0x00, 0x00, 0x14, - 0x1F, 0x28, 0x02, 0x71, 0x61, 0x00, 0x00, 0x54, 0xC0, 0x09, 0x80, 0x52, 0x22, 0x00, 0x00, 0x14, - 0x1F, 0x2C, 0x02, 0x71, 0x61, 0x00, 0x00, 0x54, 0x00, 0x0A, 0x80, 0x52, 0x1E, 0x00, 0x00, 0x14, - 0x1F, 0x30, 0x02, 0x71, 0x61, 0x00, 0x00, 0x54, 0x20, 0x0A, 0x80, 0x52, 0x1A, 0x00, 0x00, 0x14, - 0x1F, 0x34, 0x02, 0x71, 0x61, 0x00, 0x00, 0x54, 0x60, 0x0A, 0x80, 0x52, 0x16, 0x00, 0x00, 0x14, - 0x1F, 0x38, 0x02, 0x71, 0x61, 0x00, 0x00, 0x54, 0x80, 0x0A, 0x80, 0x52, 0x12, 0x00, 0x00, 0x14, - 0x1F, 0x3C, 0x02, 0x71, 0x61, 0x00, 0x00, 0x54, 0xE0, 0x0B, 0x80, 0x52, 0x0E, 0x00, 0x00, 0x14, - 0x1F, 0x40, 0x02, 0x71, 0x61, 0x00, 0x00, 0x54, 0x00, 0x0C, 0x80, 0x52, 0x0A, 0x00, 0x00, 0x14, - 0x1F, 0x44, 0x02, 0x71, 0x61, 0x00, 0x00, 0x54, 0x40, 0x0C, 0x80, 0x52, 0x06, 0x00, 0x00, 0x14, - 0x1F, 0x48, 0x02, 0x71, 0x61, 0x00, 0x00, 0x54, 0x60, 0x0C, 0x80, 0x52, 0x02, 0x00, 0x00, 0x14, - 0x00, 0x00, 0x80, 0x52, 0xFF, 0xFF, 0xFF, 0xFF -}; diff --git a/externals/libadrenotools/include/adrenotools/bcenabler.h b/externals/libadrenotools/include/adrenotools/bcenabler.h deleted file mode 100644 index 3d3a76e7d5..0000000000 --- a/externals/libadrenotools/include/adrenotools/bcenabler.h +++ /dev/null @@ -1,41 +0,0 @@ -// SPDX-License-Identifier: BSD-2-Clause -// Copyright © 2021 Billy Laws - -#pragma once - -#ifdef __cplusplus -extern "C" { -#else -#include -#endif - -#include - -/** - * @brief Describes the level of BCeNabler support for a driver - */ -enum adrenotools_bcn_type { - ADRENOTOOLS_BCN_INCOMPATIBLE, //!< Driver isn't supported by BCeNabler - ADRENOTOOLS_BCN_BLOB, //!< Driver already supports BCn textures so BCeNabler isn't necessary - ADRENOTOOLS_BCN_PATCH //!< Driver can be patched with BCeNabler to support BCn textures -}; - -/** - * @brief Checks the status of BCn support in the supplied driver - * @param major The major part of VkPhysicalDeviceProperties::driverVersion - * @param minor The minor part of VkPhysicalDeviceProperties::driverVersion - * @param vendorId VkPhysicalDeviceProperties::vendorId - */ -enum adrenotools_bcn_type adrenotools_get_bcn_type(uint32_t major, uint32_t minor, uint32_t vendorId); - -/** - * @brief Patches the Adreno graphics driver to enable support for BCn compressed formats - * @note adrenotools_get_bcn_type MUST be checked to equal ADRENOTOOLS_BCN_PATCH before calling this - * @param vkGetPhysicalDeviceFormatPropertiesFn A pointer to vkGetPhysicalDeviceFormatProperties obtained through vkGetInstanceProcAddr. This is used to find the correct function to patch - * @return If the patching succeeded, if false the driver will be in an undefined state - */ -bool adrenotools_patch_bcn(void *vkGetPhysicalDeviceFormatPropertiesFn); - -#ifdef __cplusplus -} -#endif diff --git a/externals/libadrenotools/include/adrenotools/driver.h b/externals/libadrenotools/include/adrenotools/driver.h deleted file mode 100644 index f81e8fe34d..0000000000 --- a/externals/libadrenotools/include/adrenotools/driver.h +++ /dev/null @@ -1,71 +0,0 @@ -// SPDX-License-Identifier: BSD-2-Clause -// Copyright © 2021 Billy Laws - -#pragma once - -#ifdef __cplusplus -extern "C" { -#endif - -#include -#include "priv.h" - -/** - * @brief Opens a new libvulkan.so instance according to `flags` - * @remark IMPORTANT: The app MUST be packaged w/ useLegacyPackaging = true. The reason for this is - * that we install the hook in hookLibDir; but this folder won't be set correctly when useLegacyPackaging == false - * because Android expects to read the *.so directly from the apk (instead of decompressing them into nativeLibraryDir). - * @param dlopenMode The dlopen mode to use when opening libvulkan - * @param featureFlags Which adrenotools driver features to enable - * @param tmpLibDir A writable directory to hold patched libraries, only used on api < 29 due to the lack of memfd support. If nullptr is passed and the API version is < 29 memfd usage will be attempted and if unsupported nullptr will be returned - * @param hookLibDir The directory holding the built hooks. - * IMPORTANT: This path MUST point to whatever `getApplicationInfo().nativeLibraryDir` (Kotlin code) returns. - * Failing to do so will result in this function returning a valid ptr but then the hook will fail and either the original driver is loaded as fallback, or vkEnumeratePhysicalDevices returns 0 devices. - * @param customDriverDir The directory to load a custom GPU driver named according to `customDriverName` from. Only used if ADRENOTOOLS_DRIVER_CUSTOM is set in `featureFlags`. - * IMPORTANT: This path MUST NOT be on sdcard/storage. i.e. use ANativeActivity::internalDataPath and often looks like "/data/user/0/com.example.app/files/". - * Otherwise you will get permission denied because dlopen() can't be done on *.so libraries that any random user or application can manipulate (which would be a security risk). - * @param customDriverName The soname of the custom driver to load. Only used if ADRENOTOOLS_DRIVER_CUSTOM is set in `featureFlags` - * @param fileRedirectDir The directory which to redirect all file accesses performed by the driver to. Only used if ADRENOTOOLS_DRIVER_FILE_REDIRECT is set in `featureFlags` - * @param userMappingHandle A pointer to a void* which will be set to the mapping handle if ADRENOTOOLS_DRIVER_GPU_MAPPING_IMPORT is set in `featureFlags` - */ -void *adrenotools_open_libvulkan(int dlopenMode, int featureFlags, const char *tmpLibDir, const char *hookLibDir, const char *customDriverDir, const char *customDriverName, const char *fileRedirectDir, void **userMappingHandle); - -/** - * @brief Imports the given CPU mapped memory range into the GSL allocator. This should then be followed by a call to vkAllocateMemory with a matching size which will return a VkDeviceMemory view over the input region - * @param handle Mapping handle that was returned by adrenotools_open_libvulkan - * @param hostPtr The host pointer to import - * @param size The size of the region to import - * @return True on success - */ -bool adrenotools_import_user_mem(void *handle, void *hostPtr, uint64_t size); - -/** - * @brief Maps GPU memory and imports it into the GSL allocator. This should then be followed by a call to adrenotools_mem_cpu_map to map the memory on the CPU, then finally vkAllocateMemory with a matching size - * @param handle Mapping handle that was returned by adrenotools_open_libvulkan - * @param size Pointer to a variable containing the size of the region to import, will be updated to contain the required size of the region to allocate CPU side - * @return true on success - */ -bool adrenotools_mem_gpu_allocate(void *handle, uint64_t *size); - -/** - * @brief Maps the last mapping allocated using adrenotools_mem_gpu_allocate into the given host memory region, such that vkAllocateMemory can then be called - * @param handle Mapping handle that was returned by adrenotools_open_libvulkan - * @param hostPtr A pointer to where the mapping should be mapped - * @param size The size of the mapping. MUST be equal to the size returned by adrenotools_mem_gpu_allocate - */ -bool adrenotools_mem_cpu_map(void *handle, void *hostPtr, uint64_t size); - -/** - * @note This function should be called after adrenotools_open_libvulkan and Vulkan driver init to check if the mapping import hook loaded successfully - * @return True if the mapping was successfully imported (or initialization succeeded) - */ -bool adrenotools_validate_gpu_mapping(void *handle); - -/** - * @brief Provides a way to force the GPU to run at the maximum possible clocks (thermal constraints will still be applied) - */ -void adrenotools_set_turbo(bool turbo); - -#ifdef __cplusplus -} -#endif diff --git a/externals/libadrenotools/include/adrenotools/priv.h b/externals/libadrenotools/include/adrenotools/priv.h deleted file mode 100644 index 742d24f247..0000000000 --- a/externals/libadrenotools/include/adrenotools/priv.h +++ /dev/null @@ -1,27 +0,0 @@ -// SPDX-License-Identifier: BSD-2-Clause -// Copyright © 2021 Billy Laws - -#pragma once - -#include - -/** - * @brief Bitfield enum of additional driver features that can be used with adrenotools_open_libvulkan - */ -enum { - ADRENOTOOLS_DRIVER_CUSTOM = 1 << 0, - ADRENOTOOLS_DRIVER_FILE_REDIRECT = 1 << 1, - ADRENOTOOLS_DRIVER_GPU_MAPPING_IMPORT = 1 << 2, -}; - -#define ADRENOTOOLS_GPU_MAPPING_SUCCEEDED_MAGIC 0xDEADBEEF - -/** - * @brief A replacement GPU memory mapping for use with ADRENOTOOLS_DRIVER_GPU_MAPPING_IMPORT - */ -struct adrenotools_gpu_mapping { - void *host_ptr; - uint64_t gpu_addr; //!< The GPU address of the mapping to import, if mapping import/init succeeds this will be set to ADRENOTOOLS_GPU_MAPPING_SUCCEEDED_MAGIC - uint64_t size; - uint64_t flags; -}; \ No newline at end of file diff --git a/externals/libadrenotools/lib/linkernsbypass/CMakeLists.txt b/externals/libadrenotools/lib/linkernsbypass/CMakeLists.txt deleted file mode 100644 index c2e92b0422..0000000000 --- a/externals/libadrenotools/lib/linkernsbypass/CMakeLists.txt +++ /dev/null @@ -1,19 +0,0 @@ -cmake_minimum_required(VERSION 3.14) - -if(NOT ${CMAKE_ANDROID_ARCH_ABI} STREQUAL arm64-v8a) - message(FATAL_ERROR "Unsupported target architecture: ${CMAKE_ANDROID_ARCH_ABI}. Please make an issue on the repo!") -endif() - -project(linkernsbypass LANGUAGES CXX) - -set(SOURCES android_linker_ns.cpp - android_linker_ns.h - elf_soname_patcher.cpp - elf_soname_patcher.h) - -add_library(linkernsbypass STATIC ${SOURCES}) - - -target_compile_options(linkernsbypass PRIVATE -Wall -Wextra) -target_link_libraries(linkernsbypass android dl) -target_include_directories(linkernsbypass PUBLIC .) diff --git a/externals/libadrenotools/lib/linkernsbypass/LICENSE b/externals/libadrenotools/lib/linkernsbypass/LICENSE deleted file mode 100644 index a8f664a745..0000000000 --- a/externals/libadrenotools/lib/linkernsbypass/LICENSE +++ /dev/null @@ -1,24 +0,0 @@ -BSD 2-Clause License - -Copyright (c) 2021, Billy Laws - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - -1. Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. - -2. 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. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER 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. diff --git a/externals/libadrenotools/lib/linkernsbypass/README.md b/externals/libadrenotools/lib/linkernsbypass/README.md deleted file mode 100644 index 264f23a39a..0000000000 --- a/externals/libadrenotools/lib/linkernsbypass/README.md +++ /dev/null @@ -1,9 +0,0 @@ -### Android Linker Namespace Bypass Library -Provides access to the hidden linker namespace functionality in Android 9+ and exposes an interface for hooking libraries similar to a runtime equivalent of `LD_PRELOAD`. -See the `android_linker_ns.h` header for an API reference. - -#### Support -Android 9+ -Arm64 - -Android 8 and arm32 could be supported with some trivial changes, feel free to open an issue if you have a use for this library on either of them. diff --git a/externals/libadrenotools/lib/linkernsbypass/android_linker_ns.cpp b/externals/libadrenotools/lib/linkernsbypass/android_linker_ns.cpp deleted file mode 100644 index 3bd58992c2..0000000000 --- a/externals/libadrenotools/lib/linkernsbypass/android_linker_ns.cpp +++ /dev/null @@ -1,192 +0,0 @@ -// SPDX-License-Identifier: BSD-2-Clause -// Copyright © 2021 Billy Laws - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "elf_soname_patcher.h" -#include "android_linker_ns.h" - -using loader_android_create_namespace_t = android_namespace_t *(*)(const char *, const char *, const char *, uint64_t, const char *, android_namespace_t *, const void *); -static loader_android_create_namespace_t loader_android_create_namespace; - -static bool lib_loaded; - - -/* Public API */ -bool linkernsbypass_load_status() { - return lib_loaded; -} - -struct android_namespace_t *android_create_namespace(const char *name, - const char *ld_library_path, - const char *default_library_path, - uint64_t type, - const char *permitted_when_isolated_path, - android_namespace_t *parent_namespace) { - auto caller{__builtin_return_address(0)}; - return loader_android_create_namespace(name, ld_library_path, default_library_path, type, - permitted_when_isolated_path, parent_namespace, caller); -} - -struct android_namespace_t *android_create_namespace_escape(const char *name, - const char *ld_library_path, - const char *default_library_path, - uint64_t type, - const char *permitted_when_isolated_path, - android_namespace_t *parent_namespace) { - auto caller{reinterpret_cast(&dlopen)}; - return loader_android_create_namespace(name, ld_library_path, default_library_path, type, - permitted_when_isolated_path, parent_namespace, caller); -} - -android_get_exported_namespace_t android_get_exported_namespace; - -android_link_namespaces_all_libs_t android_link_namespaces_all_libs; - -android_link_namespaces_t android_link_namespaces; - -bool linkernsbypass_link_namespace_to_default_all_libs(android_namespace_t *to) { - // Creating a shared namespace with the default parent will give a copy of the default namespace that we can actually access - // This is needed since there is no way to access a direct handle to the default namespace as it's not exported - static auto defaultNs{android_create_namespace_escape("default_copy", nullptr, nullptr, ANDROID_NAMESPACE_TYPE_SHARED, nullptr, nullptr)}; - return android_link_namespaces_all_libs(to, defaultNs); -} - -void *linkernsbypass_namespace_dlopen(const char *filename, int flags, android_namespace_t *ns) { - android_dlextinfo extInfo{ - .flags = ANDROID_DLEXT_USE_NAMESPACE, - .library_namespace = ns - }; - - return android_dlopen_ext(filename, flags, &extInfo); -} - -#ifndef __NR_memfd_create - #if defined(__aarch64__) - #define __NR_memfd_create 279 - #else - #error Unsupported target architecture! - #endif -#endif - -void *linkernsbypass_namespace_dlopen_unique(const char *libPath, const char *libTargetDir, int flags, android_namespace_t *ns) { - static std::array PathBuf{}; - - // Used as a unique ID for overwriting soname and creating target lib files - static uint16_t TargetId{}; - - int libTargetFd{[&] () { - if (libTargetDir) { - snprintf(PathBuf.data(), PathBuf.size(), "%s/%d_patched.so", libTargetDir, TargetId); - return open(PathBuf.data(), O_CREAT | O_RDWR, S_IRUSR | S_IWUSR); - } else { - // If memfd isn't supported errno will contain ENOSYS after calling - errno = 0; - int fd{static_cast(syscall(__NR_memfd_create, libPath, 0))}; - if (errno == ENOSYS || fd < 0) - return -1; - else - return fd; - } - }()}; - if (libTargetFd == -1) - return nullptr; - - // Partially overwrite soname with 3 digits (replacing lib...) with to make sure a cached so isn't loaded - std::array sonameOverwrite{}; - snprintf(sonameOverwrite.data(), sonameOverwrite.size(), "%03u", TargetId++); - - if (!elf_soname_patch(libPath, libTargetFd, sonameOverwrite.data())) - return nullptr; - - // Load our patched library into the hook namespace - android_dlextinfo hookExtInfo{ - .flags = ANDROID_DLEXT_USE_NAMESPACE | ANDROID_DLEXT_USE_LIBRARY_FD, - .library_fd = libTargetFd, - .library_namespace = ns - }; - - // Make a path that looks about right - snprintf(PathBuf.data(), PathBuf.size(), "/proc/self/fd/%d", libTargetFd); - - return android_dlopen_ext(PathBuf.data(), flags, &hookExtInfo); -} - -static void *align_ptr(void *ptr) { - return reinterpret_cast(reinterpret_cast(ptr) & ~(getpagesize() - 1)); -} - -/* Private */ -__attribute__((constructor)) static void resolve_linker_symbols() { - using loader_dlopen_t = void *(*)(const char *, int, const void *); - - if (android_get_device_api_level() < 28) - return; - - // ARM64 specific function walking to locate the internal dlopen handler - auto loader_dlopen{[]() { - union BranchLinked { - uint32_t raw; - - struct { - int32_t offset : 26; //!< 26-bit branch offset - uint8_t sig : 6; //!< 6-bit signature - }; - - bool Verify() { - return sig == 0x25; - } - }; - static_assert(sizeof(BranchLinked) == 4, "BranchLinked is wrong size"); - - // Some devices ship with --X mapping for exexecutables so work around that - mprotect(align_ptr(reinterpret_cast(&dlopen)), getpagesize(), PROT_WRITE | PROT_READ | PROT_EXEC); - - // dlopen is just a wrapper for __loader_dlopen that passes the return address as the third arg hence we can just walk it to find __loader_dlopen - auto blInstr{reinterpret_cast(&dlopen)}; - while (!blInstr->Verify()) - blInstr++; - - return reinterpret_cast(blInstr + blInstr->offset); - }()}; - - // Protect the loader_dlopen function to remove the BTI attribute (since this is an internal function that isn't intended to be jumped indirectly to) - mprotect(align_ptr(reinterpret_cast(&loader_dlopen)), getpagesize(), PROT_WRITE | PROT_READ | PROT_EXEC); - - // Passing dlopen as a caller address tricks the linker into using the internal unrestricted namespace letting us access libraries that are normally forbidden in the classloader namespace imposed on apps - auto ldHandle{loader_dlopen("ld-android.so", RTLD_LAZY, reinterpret_cast(&dlopen))}; - if (!ldHandle) - return; - - android_link_namespaces_all_libs = reinterpret_cast(dlsym(ldHandle, "__loader_android_link_namespaces_all_libs")); - if (!android_link_namespaces_all_libs) - return; - - android_link_namespaces = reinterpret_cast(dlsym(ldHandle, "__loader_android_link_namespaces")); - if (!android_link_namespaces) - return; - - auto libdlAndroidHandle{loader_dlopen("libdl_android.so", RTLD_LAZY, reinterpret_cast(&dlopen))}; - if (!libdlAndroidHandle) - return; - - loader_android_create_namespace = reinterpret_cast(dlsym(libdlAndroidHandle, "__loader_android_create_namespace")); - if (!loader_android_create_namespace) - return; - - android_get_exported_namespace = reinterpret_cast(dlsym(libdlAndroidHandle, "__loader_android_get_exported_namespace")); - if (!android_get_exported_namespace) - return; - - // Lib is now safe to use - lib_loaded = true; -} diff --git a/externals/libadrenotools/lib/linkernsbypass/android_linker_ns.h b/externals/libadrenotools/lib/linkernsbypass/android_linker_ns.h deleted file mode 100644 index 77ec4005a5..0000000000 --- a/externals/libadrenotools/lib/linkernsbypass/android_linker_ns.h +++ /dev/null @@ -1,81 +0,0 @@ -// SPDX-License-Identifier: BSD-2-Clause -// Copyright © 2021 Billy Laws - -#pragma once - -#ifdef __cplusplus -extern "C" { -#endif - -#include - -// https://cs.android.com/android/platform/superproject/+/0a492a4685377d41fef2b12e9af4ebfa6feef9c2:art/libnativeloader/include/nativeloader/dlext_namespaces.h;l=25;bpv=1;bpt=1 -enum { - ANDROID_NAMESPACE_TYPE_REGULAR = 0, - ANDROID_NAMESPACE_TYPE_ISOLATED = 1, - ANDROID_NAMESPACE_TYPE_SHARED = 2, - ANDROID_NAMESPACE_TYPE_EXEMPT_LIST_ENABLED = 0x08000000, - ANDROID_NAMESPACE_TYPE_ALSO_USED_AS_ANONYMOUS = 0x10000000, - ANDROID_NAMESPACE_TYPE_SHARED_ISOLATED = ANDROID_NAMESPACE_TYPE_SHARED | ANDROID_NAMESPACE_TYPE_ISOLATED, -}; - -/** - * @brief Checks if linkernsbypass loaded successfully and is safe to use - * @note IMPORTANT: This should be called before any calls to the rest of the library are made - * @return true if loading succeeded - */ -bool linkernsbypass_load_status(); - -// https://cs.android.com/android/platform/superproject/+/0a492a4685377d41fef2b12e9af4ebfa6feef9c2:art/libnativeloader/include/nativeloader/dlext_namespaces.h;l=86;bpv=1;bpt=1 -struct android_namespace_t *android_create_namespace(const char *name, - const char *ld_library_path, - const char *default_library_path, - uint64_t type, - const char *permitted_when_isolated_path, - struct android_namespace_t *parent_namespace); - -struct android_namespace_t *android_create_namespace_escape(const char *name, - const char *ld_library_path, - const char *default_library_path, - uint64_t type, - const char *permitted_when_isolated_path, - struct android_namespace_t *parent_namespace); - -// https://cs.android.com/android/platform/superproject/+/dcb01ef31026b3b8aeb72dada3370af63fe66bbd:bionic/linker/linker.cpp;l=3554 -typedef struct android_namespace_t *(*android_get_exported_namespace_t)(const char *); -extern android_get_exported_namespace_t android_get_exported_namespace; - -// https://cs.android.com/android/platform/superproject/+/dcb01ef31026b3b8aeb72dada3370af63fe66bbd:bionic/linker/linker.cpp;l=2499 -typedef bool (*android_link_namespaces_all_libs_t)(struct android_namespace_t *, struct android_namespace_t *); -extern android_link_namespaces_all_libs_t android_link_namespaces_all_libs; - -// https://cs.android.com/android/platform/superproject/+/dcb01ef31026b3b8aeb72dada3370af63fe66bbd:bionic/linker/linker.cpp;l=2473 -typedef bool (*android_link_namespaces_t)(struct android_namespace_t *, struct android_namespace_t *, const char *); -extern android_link_namespaces_t android_link_namespaces; - -/** - * @brief Like android_link_namespaces_all_libs but links from the default namespace - */ -bool linkernsbypass_link_namespace_to_default_all_libs(struct android_namespace_t *to); - -/** - * @brief Loads a library into a namespace - * @note IMPORTANT: If `filename` is compiled with the '-z global' linker flag and RTLD_GLOBAL is supplied in `flags` the library will be added to the namespace's LD_PRELOAD list - * @param filename The name of the library to load - * @param flags The rtld flags for `filename` - * @param ns The namespace to dlopen into - */ -void *linkernsbypass_namespace_dlopen(const char *filename, int flags, struct android_namespace_t *ns); - -/** - * @brief Force loads a unique instance of a library into a namespace - * @param libPath The path to the library to load with hooks applied - * @param libTargetDir A temporary directory to hold the soname patched library at `libPath`, will attempt to use memfd if nullptr - * @param flags The rtld flags for `libName` - * @param ns The namespace to dlopen into - */ -void *linkernsbypass_namespace_dlopen_unique(const char *libPath, const char *libTargetDir, int flags, struct android_namespace_t *ns); - -#ifdef __cplusplus -} -#endif diff --git a/externals/libadrenotools/lib/linkernsbypass/elf_soname_patcher.cpp b/externals/libadrenotools/lib/linkernsbypass/elf_soname_patcher.cpp deleted file mode 100644 index db619ab534..0000000000 --- a/externals/libadrenotools/lib/linkernsbypass/elf_soname_patcher.cpp +++ /dev/null @@ -1,67 +0,0 @@ -// SPDX-License-Identifier: BSD-2-Clause -// Copyright © 2021 Billy Laws - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "elf_soname_patcher.h" - -bool elf_soname_patch(const char *libPath, int targetFd, const char *sonamePatch) { - struct stat libStat{}; - if (stat(libPath, &libStat)) - return false; - - if (ftruncate(targetFd, libStat.st_size) == -1) - return false; - - // Map the memory so we can read our elf into it - auto mappedLib{reinterpret_cast(mmap(nullptr, libStat.st_size, PROT_READ | PROT_WRITE, MAP_SHARED, targetFd, 0))}; - if (!mappedLib) - return false; - - int libFd{open(libPath, O_RDONLY)}; - if (libFd == false) - return false; - - // Read lib elf into target file - if (read(libFd, mappedLib, libStat.st_size) != libStat.st_size) - return false; - - // No longer needed - close(libFd); - - auto eHdr{reinterpret_cast(mappedLib)}; - auto sHdrEntries{reinterpret_cast(mappedLib + eHdr->e_shoff)}; - - // Iterate over section headers to find the .dynamic section - for (ElfW(Half) i{}; i < eHdr->e_shnum; i++) { - auto &sHdr{sHdrEntries[i]}; - if (sHdr.sh_type == SHT_DYNAMIC) { - auto strTab{reinterpret_cast(mappedLib + sHdrEntries[sHdr.sh_link].sh_offset)}; - auto dynHdrEntries{reinterpret_cast(mappedLib + sHdr.sh_offset)}; - - // Iterate over .dynamic entries to find DT_SONAME - for (ElfW(Xword) k{}; k < (sHdr.sh_size / sHdr.sh_entsize); k++) { - auto &dynHdrEntry{dynHdrEntries[k]}; - if (dynHdrEntry.d_tag == DT_SONAME) { - char *soname{strTab + dynHdrEntry.d_un.d_val}; - - // Partially replace the old soname with the soname patch - size_t charIdx{}; - for (; soname[charIdx] != 0 && sonamePatch[charIdx] != 0; charIdx++) - soname[charIdx] = sonamePatch[charIdx]; - - return true; - } - } - } - } - - return false; -} diff --git a/externals/libadrenotools/lib/linkernsbypass/elf_soname_patcher.h b/externals/libadrenotools/lib/linkernsbypass/elf_soname_patcher.h deleted file mode 100644 index 0b2c186ffc..0000000000 --- a/externals/libadrenotools/lib/linkernsbypass/elf_soname_patcher.h +++ /dev/null @@ -1,21 +0,0 @@ -// SPDX-License-Identifier: BSD-2-Clause -// Copyright © 2021 Billy Laws - -#pragma once - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @brief Overwrites a portion of the soname in an elf by loading it into shared memory and modifying .dynstr - * @note IMPORTANT: The supplied soname patch will overwrite the first strlen(sonamePatch) chars of the soname - * @param elfPath Full path to the elf to patch - * @param targetFd FD to use for storing the patched library - * @return True on success - */ -bool elf_soname_patch(const char *elfPath, int targetFd, const char *newSoname); - -#ifdef __cplusplus -} -#endif diff --git a/externals/libadrenotools/src/bcenabler.cpp b/externals/libadrenotools/src/bcenabler.cpp deleted file mode 100644 index 1deb41df40..0000000000 --- a/externals/libadrenotools/src/bcenabler.cpp +++ /dev/null @@ -1,135 +0,0 @@ -// SPDX-License-Identifier: BSD-2-Clause -// Copyright © 2021 Billy Laws - -#include -#include -#include -#include -#include -#include -#include "gen/bcenabler_patch.h" - -enum adrenotools_bcn_type adrenotools_get_bcn_type(uint32_t major, uint32_t minor, uint32_t vendorId) { - if (vendorId != 0x5143 || major != 512) - return ADRENOTOOLS_BCN_INCOMPATIBLE; - - if (minor >= 514) - return ADRENOTOOLS_BCN_BLOB; - - return ADRENOTOOLS_BCN_PATCH; -} - -// Searches /proc/self/maps for the first free page after the given address -static void *find_free_page(uintptr_t address) { - std::ifstream procMaps("/proc/self/maps"); - - uintptr_t end{}; - - for (std::string line; std::getline(procMaps, line); ) { - std::size_t addressSeparator{line.find('-')}; - uintptr_t start{std::strtoull(line.substr(0, addressSeparator).c_str(), nullptr, 16)}; - - if (end > address && start != end) - return reinterpret_cast(end); - - end = std::strtoull(line.substr(addressSeparator + 1, line.find( ' ')).c_str(), nullptr, 16); - } - - return nullptr; -} - -static void *align_ptr(void *ptr) { - return reinterpret_cast(reinterpret_cast(ptr) & ~(getpagesize() - 1)); -} - -bool adrenotools_patch_bcn(void *vkGetPhysicalDeviceFormatPropertiesFn) { - union Branch { - struct { - int32_t offset : 26; //!< 26-bit branch offset - uint8_t sig : 6; //!< 6-bit signature (0x25 for linked, 0x5 for jump) - }; - - uint32_t raw{}; - }; - static_assert(sizeof(Branch) == 4, "Branch size is invalid"); - - // Find the nearest unmapped page where we can place patch code - void *patchPage{find_free_page(reinterpret_cast(vkGetPhysicalDeviceFormatPropertiesFn))}; - if (!patchPage) - return false; - - // Map patch region - void *ptr{mmap(patchPage, getpagesize(), PROT_READ | PROT_WRITE | PROT_EXEC, MAP_PRIVATE | MAP_ANONYMOUS | MAP_FIXED, 0, 0)}; - if (ptr != patchPage) - return false; - - // Allow reading from the blob's .text section since some devices enable ---X - // Protect two pages just in case we happen to land on a page boundary - if (mprotect(align_ptr(vkGetPhysicalDeviceFormatPropertiesFn), getpagesize() * 2, PROT_WRITE | PROT_READ | PROT_EXEC)) - return false; - - // First branch in this function is targeted at the function we want to patch - Branch *blInst{reinterpret_cast(vkGetPhysicalDeviceFormatPropertiesFn)}; - - constexpr uint8_t BranchLinkSignature{0x25}; - - // Search for first instruction with the BL signature - while (blInst->sig != BranchLinkSignature) - blInst++; - - // Internal QGL format conversion function that we need to patch - uint32_t *convFormatFn{reinterpret_cast(blInst) + blInst->offset}; - - // See mprotect call above - // This time we also set PROT_WRITE so we can write our patch to the page - if (mprotect(align_ptr(convFormatFn), getpagesize() * 2, PROT_WRITE | PROT_READ | PROT_EXEC)) - return false; - - // This would normally set the default result to 0 (error) in the format not found case - constexpr uint32_t ClearResultSignature{0x2a1f03e0}; - - // We replace it with a branch to our own extended if statement which adds in the extra things for BCn - uint32_t *clearResultPtr{convFormatFn}; - while (*clearResultPtr != ClearResultSignature) - clearResultPtr++; - - // Ensure we don't write out of bounds - if (PatchRawData_size > getpagesize()) - return false; - - // Copy the patch function to our mapped page - memcpy(patchPage, PatchRawData, PatchRawData_size); - - // Fixup the patch code so it correctly returns back to the driver after running - constexpr uint32_t PatchReturnFixupMagic{0xffffffff}; - constexpr uint8_t BranchSignature{0x5}; - - uint32_t *fixupTargetPtr{clearResultPtr + 1}; - auto *fixupPtr{reinterpret_cast(patchPage)}; - for (long unsigned int i{}; i < (PatchRawData_size / sizeof(uint32_t)); i++, fixupPtr++) { - if (*fixupPtr == PatchReturnFixupMagic) { - Branch branchToDriver{ - { - .offset = static_cast((reinterpret_cast(fixupTargetPtr) - reinterpret_cast(fixupPtr)) / sizeof(int32_t)), - .sig = BranchSignature, - } - }; - - *fixupPtr = branchToDriver.raw; - } - } - - Branch branchToPatch{ - { - .offset = static_cast((reinterpret_cast(patchPage) - reinterpret_cast(clearResultPtr)) / sizeof(int32_t)), - .sig = BranchSignature, - } - }; - - *clearResultPtr = branchToPatch.raw; - - asm volatile("ISB"); - - // Done! - return true; -} diff --git a/externals/libadrenotools/src/bcenabler_patch.s b/externals/libadrenotools/src/bcenabler_patch.s deleted file mode 100644 index 8766e7880d..0000000000 --- a/externals/libadrenotools/src/bcenabler_patch.s +++ /dev/null @@ -1,83 +0,0 @@ - cmp w0, 131 - bne .L2 - mov w0, 71 - b .L3 -.L2: - cmp w0, 133 - bne .L4 - mov w0, 71 - b .L3 -.L4: - cmp w0, 132 - bne .L5 - mov w0, 72 - b .L3 -.L5: - cmp w0, 134 - bne .L6 - mov w0, 72 - b .L3 -.L6: - cmp w0, 135 - bne .L7 - mov w0, 74 - b .L3 -.L7: - cmp w0, 136 - bne .L8 - mov w0, 75 - b .L3 -.L8: - cmp w0, 137 - bne .L9 - mov w0, 77 - b .L3 -.L9: - cmp w0, 138 - bne .L10 - mov w0, 78 - b .L3 -.L10: - cmp w0, 139 - bne .L11 - mov w0, 80 - b .L3 -.L11: - cmp w0, 140 - bne .L12 - mov w0, 81 - b .L3 -.L12: - cmp w0, 141 - bne .L13 - mov w0, 83 - b .L3 -.L13: - cmp w0, 142 - bne .L14 - mov w0, 84 - b .L3 -.L14: - cmp w0, 143 - bne .L15 - mov w0, 95 - b .L3 -.L15: - cmp w0, 144 - bne .L16 - mov w0, 96 - b .L3 -.L16: - cmp w0, 145 - bne .L17 - mov w0, 98 - b .L3 -.L17: - cmp w0, 146 - bne .L18 - mov w0, 99 - b .L3 -.L18: - mov w0, 0 -.L3: - .word 0xffffffff // Branch fixup diff --git a/externals/libadrenotools/src/driver.cpp b/externals/libadrenotools/src/driver.cpp deleted file mode 100644 index 4ddee4aaa4..0000000000 --- a/externals/libadrenotools/src/driver.cpp +++ /dev/null @@ -1,210 +0,0 @@ -// SPDX-License-Identifier: BSD-2-Clause -// Copyright © 2021 Billy Laws - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "hook/kgsl.h" -#include "hook/hook_impl_params.h" -#include -#include - -void *adrenotools_open_libvulkan(int dlopenFlags, int featureFlags, const char *tmpLibDir, const char *hookLibDir, const char *customDriverDir, const char *customDriverName, const char *fileRedirectDir, void **userMappingHandle) { - // Bail out if linkernsbypass failed to load, this probably means we're on api < 28 - if (!linkernsbypass_load_status()) - return nullptr; - - // Always use memfd on Q+ since it's guaranteed to work - if (android_get_device_api_level() >= 29) - tmpLibDir = nullptr; - - // Verify that params for specific features are only passed if they are enabled - if (!(featureFlags & ADRENOTOOLS_DRIVER_FILE_REDIRECT) && fileRedirectDir) - return nullptr; - - if (!(featureFlags & ADRENOTOOLS_DRIVER_CUSTOM) && (customDriverDir || customDriverName)) - return nullptr; - - if (!(featureFlags & ADRENOTOOLS_DRIVER_GPU_MAPPING_IMPORT) && userMappingHandle) - return nullptr; - - // Verify that params for enabled features are correct - struct stat buf{}; - - if (featureFlags & ADRENOTOOLS_DRIVER_CUSTOM) { - if (!customDriverName || !customDriverDir) - return nullptr; - - if (stat((std::string(customDriverDir) + customDriverName).c_str(), &buf) != 0) - return nullptr; - } - - // Verify that params for enabled features are correct - if (featureFlags & ADRENOTOOLS_DRIVER_FILE_REDIRECT) { - if (!fileRedirectDir) - return nullptr; - - if (stat(fileRedirectDir, &buf) != 0) - return nullptr; - } - - // Create a namespace that can isolate our hook from the classloader namespace - auto hookNs{android_create_namespace("adrenotools-libvulkan", hookLibDir, nullptr, ANDROID_NAMESPACE_TYPE_SHARED, nullptr, nullptr)}; - - // Link it to the default namespace so the hook can use libandroid etc - if (!linkernsbypass_link_namespace_to_default_all_libs(hookNs)) - return nullptr; - - // Preload the hook implementation, otherwise we get a weird issue where despite being in NEEDED of the hook lib the hook's symbols will overwrite ours and cause an infinite loop - auto hookImpl{linkernsbypass_namespace_dlopen("libhook_impl.so", RTLD_NOW, hookNs)}; - if (!hookImpl) - return nullptr; - - // Pass parameters to the hook implementation - auto initHookParam{reinterpret_cast(dlsym(hookImpl, "init_hook_param"))}; - if (!initHookParam) - return nullptr; - - - auto importMapping{[&]() -> adrenotools_gpu_mapping * { - if (featureFlags & ADRENOTOOLS_DRIVER_GPU_MAPPING_IMPORT) { - // This will be leaked, but it's not a big deal since it's only a few bytes - adrenotools_gpu_mapping *mapping{new adrenotools_gpu_mapping{}}; - *userMappingHandle = mapping; - return mapping; - } else { - return nullptr; - } - }()}; - - initHookParam(new HookImplParams(featureFlags, tmpLibDir, hookLibDir, customDriverDir, customDriverName, fileRedirectDir, importMapping)); - - // Load the libvulkan hook into the isolated namespace - if (!linkernsbypass_namespace_dlopen("libmain_hook.so", RTLD_GLOBAL, hookNs)) - return nullptr; - - return linkernsbypass_namespace_dlopen_unique("/system/lib64/libvulkan.so", tmpLibDir, dlopenFlags, hookNs); -} - -bool adrenotools_import_user_mem(void *handle, void *hostPtr, uint64_t size) { - auto importMapping{reinterpret_cast(handle)}; - - kgsl_gpuobj_import_useraddr addr{ - .virtaddr = reinterpret_cast(hostPtr), - }; - - kgsl_gpuobj_import userMemImport{ - .priv = reinterpret_cast(&addr), - .priv_len = size, - .flags = KGSL_CACHEMODE_WRITEBACK << KGSL_CACHEMODE_SHIFT | KGSL_MEMFLAGS_IOCOHERENT, - .type = KGSL_USER_MEM_TYPE_ADDR, - - }; - - kgsl_gpuobj_info info{}; - - int kgslFd{open("/dev/kgsl-3d0", O_RDWR)}; - if (kgslFd < 0) - return false; - - int ret{ioctl(kgslFd, IOCTL_KGSL_GPUOBJ_IMPORT, &userMemImport)}; - if (ret) - goto err; - - info.id = userMemImport.id; - ret = ioctl(kgslFd, IOCTL_KGSL_GPUOBJ_INFO, &info); - if (ret) - goto err; - - importMapping->host_ptr = hostPtr; - importMapping->gpu_addr = info.gpuaddr; - importMapping->size = size; - importMapping->flags = 0xc2600; //!< Unknown flags, but they are required for the mapping to work - - close(kgslFd); - return true; - -err: - close(kgslFd); - return false; -} - -bool adrenotools_mem_gpu_allocate(void *handle, uint64_t *size) { - auto mapping{reinterpret_cast(handle)}; - - kgsl_gpuobj_alloc gpuobjAlloc{ - .size = *size, - .flags = KGSL_CACHEMODE_WRITEBACK << KGSL_CACHEMODE_SHIFT | KGSL_MEMFLAGS_IOCOHERENT, - }; - - kgsl_gpuobj_info info{}; - - int kgslFd{open("/dev/kgsl-3d0", O_RDWR)}; - if (kgslFd < 0) - return false; - - int ret{ioctl(kgslFd, IOCTL_KGSL_GPUOBJ_ALLOC, &gpuobjAlloc)}; - if (ret) - goto err; - - *size = gpuobjAlloc.mmapsize; - - info.id = gpuobjAlloc.id; - - ret = ioctl(kgslFd, IOCTL_KGSL_GPUOBJ_INFO, &info); - if (ret) - goto err; - - mapping->host_ptr = nullptr; - mapping->gpu_addr = info.gpuaddr; - mapping->size = *size; - mapping->flags = 0xc2600; //!< Unknown flags, but they are required for the mapping to work - - close(kgslFd); - return true; - -err: - close(kgslFd); - return false; -} - - -bool adrenotools_mem_cpu_map(void *handle, void *hostPtr, uint64_t size) { - auto mapping{reinterpret_cast(handle)}; - - int kgslFd{open("/dev/kgsl-3d0", O_RDWR)}; - if (kgslFd < 0) - return false; - - mapping->host_ptr = mmap(hostPtr, size, PROT_READ | PROT_WRITE, MAP_SHARED | MAP_FIXED, kgslFd, mapping->gpu_addr); - close(kgslFd); - return mapping->host_ptr != nullptr; -} - -bool adrenotools_validate_gpu_mapping(void *handle) { - auto importMapping{reinterpret_cast(handle)}; - return importMapping->gpu_addr == ADRENOTOOLS_GPU_MAPPING_SUCCEEDED_MAGIC; -} - -void adrenotools_set_turbo(bool turbo) { - uint32_t enable{turbo ? 0U : 1U}; - kgsl_device_getproperty prop{ - .type = KGSL_PROP_PWRCTRL, - .value = reinterpret_cast(&enable), - .sizebytes = sizeof(enable), - }; - - int kgslFd{open("/dev/kgsl-3d0", O_RDWR)}; - if (kgslFd < 0) - return; - - ioctl(kgslFd, IOCTL_KGSL_SETPROPERTY, &prop); - close (kgslFd); -} diff --git a/externals/libadrenotools/src/hook/CMakeLists.txt b/externals/libadrenotools/src/hook/CMakeLists.txt deleted file mode 100644 index ebff0639d7..0000000000 --- a/externals/libadrenotools/src/hook/CMakeLists.txt +++ /dev/null @@ -1,27 +0,0 @@ -add_library(hook_impl SHARED hook_impl.cpp hook_impl.h hook_impl_params.h) - -target_compile_options(hook_impl PRIVATE -Wall -Wextra) -target_link_libraries(hook_impl linkernsbypass log) -target_include_directories(hook_impl PRIVATE ../../include) -set_target_properties(hook_impl PROPERTIES CXX_VISIBILITY_PRESET hidden) - -add_library(main_hook SHARED main_hook.c) - -target_compile_options(main_hook PRIVATE -Wall -Wextra) -target_link_options(main_hook PRIVATE -z global) -target_link_libraries(main_hook hook_impl) -set_target_properties(main_hook PROPERTIES CXX_VISIBILITY_PRESET hidden) - -add_library(file_redirect_hook SHARED file_redirect_hook.c) - -target_compile_options(file_redirect_hook PRIVATE -Wall -Wextra) -target_link_options(file_redirect_hook PRIVATE -z global) -target_link_libraries(file_redirect_hook hook_impl) -set_target_properties(file_redirect_hook PROPERTIES CXX_VISIBILITY_PRESET hidden) - -add_library(gsl_alloc_hook SHARED gsl_alloc_hook.c) - -target_compile_options(gsl_alloc_hook PRIVATE -Wall -Wextra) -target_link_options(gsl_alloc_hook PRIVATE -z global) -target_link_libraries(gsl_alloc_hook hook_impl) -set_target_properties(gsl_alloc_hook PROPERTIES CXX_VISIBILITY_PRESET hidden) diff --git a/externals/libadrenotools/src/hook/file_redirect_hook.c b/externals/libadrenotools/src/hook/file_redirect_hook.c deleted file mode 100644 index aa3b6d2f2d..0000000000 --- a/externals/libadrenotools/src/hook/file_redirect_hook.c +++ /dev/null @@ -1,5 +0,0 @@ -#include "hook_impl.h" - -__attribute__((visibility("default"))) FILE *fopen(const char *filename, const char *mode) { - return hook_fopen(filename, mode); -} \ No newline at end of file diff --git a/externals/libadrenotools/src/hook/gsl_alloc_hook.c b/externals/libadrenotools/src/hook/gsl_alloc_hook.c deleted file mode 100644 index 07f332d9b5..0000000000 --- a/externals/libadrenotools/src/hook/gsl_alloc_hook.c +++ /dev/null @@ -1,13 +0,0 @@ -#include "hook_impl.h" - -__attribute__((visibility("default"))) int gsl_memory_alloc_pure(uint32_t size, uint32_t flags, void *memDesc) { - return hook_gsl_memory_alloc_pure_64((uint64_t)size, flags, memDesc); -} - -__attribute__((visibility("default"))) int gsl_memory_alloc_pure_64(uint64_t size, uint32_t flags, void *memDesc) { - return hook_gsl_memory_alloc_pure_64(size, flags, memDesc); -} - -__attribute__((visibility("default"))) int gsl_memory_free_pure(void *memDesc) { - return hook_gsl_memory_free_pure(memDesc); -} diff --git a/externals/libadrenotools/src/hook/hook_impl.cpp b/externals/libadrenotools/src/hook/hook_impl.cpp deleted file mode 100644 index 50e79a946b..0000000000 --- a/externals/libadrenotools/src/hook/hook_impl.cpp +++ /dev/null @@ -1,229 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "kgsl.h" -#include "hook_impl_params.h" -#include "hook_impl.h" - -#define TAG "hook_impl" -#define LOGI(fmt, ...) __android_log_print(ANDROID_LOG_INFO, TAG, fmt, ##__VA_ARGS__) - -const HookImplParams *hook_params; //!< Bunch of info needed to load/patch the driver -int (*gsl_memory_alloc_pure_sym)(uint32_t, uint32_t, void *); -int (*gsl_memory_alloc_pure_64_sym)(uint64_t, uint32_t, void *); -int (*gsl_memory_free_pure_sym)(void *); -int kgsl_fd; - -using gsl_memory_alloc_pure_t = decltype(gsl_memory_alloc_pure_sym); -using gsl_memory_alloc_pure_64_t = decltype(gsl_memory_alloc_pure_64_sym); -using gsl_memory_free_pure_t = decltype(gsl_memory_free_pure_sym); - -__attribute__((visibility("default"))) void init_hook_param(const void *param) { - hook_params = reinterpret_cast(param); -} - -__attribute__((visibility("default"))) void init_gsl(void *alloc, void *alloc64, void *free) { - gsl_memory_alloc_pure_sym = reinterpret_cast(alloc); - gsl_memory_alloc_pure_64_sym = reinterpret_cast(alloc64); - gsl_memory_free_pure_sym = reinterpret_cast(free); -} - -__attribute__((visibility("default"))) void *hook_android_dlopen_ext(const char *filename, int flags, const android_dlextinfo *extinfo) { - auto fallback{[&]() { - LOGI("hook_android_dlopen_ext: falling back!"); - return android_dlopen_ext(filename, flags, extinfo); - }}; - - LOGI("hook_android_dlopen_ext: filename: %s", filename); - - // Ignore non-vulkan libraries - if (!strstr(filename, "vulkan.")) - return android_dlopen_ext(filename, flags, extinfo); - - if (extinfo->library_namespace == nullptr || !(extinfo->flags & ANDROID_DLEXT_USE_NAMESPACE)) { - LOGI("hook_android_dlopen_ext: hook failed: namespace not supplied!"); - return fallback(); - } - - // customDriverDir will be empty if ADRENOTOOLS_DRIVER_CUSTOM isn't set therefore it's fine to have either way - auto driverNs{android_create_namespace(filename, hook_params->customDriverDir.c_str(), - hook_params->hookLibDir.c_str(), ANDROID_NAMESPACE_TYPE_SHARED, - nullptr, extinfo->library_namespace)}; - if (!driverNs) { - LOGI("hook_android_dlopen_ext: hook failed: namespace not supplied!"); - return fallback(); - } - - // We depend on libandroid which is unlikely to be in the supplied driver namespace so we have to link it over - android_link_namespaces(driverNs, nullptr, "libandroid.so"); - - // Preload ourself, a new instance will be created since we have different linker ancestory - // If we don't preload we get a weird issue where despite being in NEEDED of the hook lib the hook's symbols will overwrite ours and cause an infinite loop - auto hookImpl{linkernsbypass_namespace_dlopen("libhook_impl.so", RTLD_NOW, driverNs)}; - if (!hookImpl) - return nullptr; - - // Pass parameters to ourself - auto initHookParam{reinterpret_cast(dlsym(hookImpl, "init_hook_param"))}; - if (!initHookParam) - return nullptr; - - initHookParam(hook_params); - - if (hook_params->featureFlags & ADRENOTOOLS_DRIVER_FILE_REDIRECT) { - if (!linkernsbypass_namespace_dlopen("libfile_redirect_hook.so", RTLD_GLOBAL, driverNs)) { - LOGI("hook_android_dlopen_ext: hook failed: failed to apply libfopen_redirect_hook!"); - return fallback(); - } - - LOGI("hook_android_dlopen_ext: applied libfile_redirect_hook"); - } - - // Use our new namespace to load the vulkan driver - auto newExtinfo{*extinfo}; - newExtinfo.library_namespace = driverNs; - - if (hook_params->featureFlags & ADRENOTOOLS_DRIVER_GPU_MAPPING_IMPORT) { - if (!linkernsbypass_namespace_dlopen("libgsl_alloc_hook.so", RTLD_GLOBAL, driverNs)) { - LOGI("hook_android_dlopen_ext: hook failed: failed to apply libgsl_alloc_hook!"); - return fallback(); - } - - auto libgslHandle{android_dlopen_ext("vkbgsl.so", RTLD_NOW, &newExtinfo)}; - if (!libgslHandle) { - libgslHandle = android_dlopen_ext("notgsl.so", RTLD_NOW, &newExtinfo); - if (!libgslHandle) - libgslHandle = android_dlopen_ext("libgsl.so", RTLD_NOW, &newExtinfo); - } - - if (libgslHandle) { - gsl_memory_alloc_pure_sym = reinterpret_cast(dlsym(libgslHandle, "gsl_memory_alloc_pure")); - gsl_memory_alloc_pure_64_sym = reinterpret_cast(dlsym(libgslHandle, "gsl_memory_alloc_pure_64")); - gsl_memory_free_pure_sym = reinterpret_cast(dlsym(libgslHandle, "gsl_memory_free_pure")); - if ((gsl_memory_alloc_pure_sym || gsl_memory_alloc_pure_64_sym) && gsl_memory_free_pure_sym) { - auto initGsl{reinterpret_cast(dlsym(hookImpl, "init_gsl"))}; - if (!initGsl) - return fallback(); - - initGsl(gsl_memory_alloc_pure_sym, gsl_memory_alloc_pure_64_sym, gsl_memory_free_pure_sym); - LOGI("hook_android_dlopen_ext: applied libgsl_alloc_hook"); - hook_params->nextGpuMapping->gpu_addr = ADRENOTOOLS_GPU_MAPPING_SUCCEEDED_MAGIC; - } - } - - if (!((gsl_memory_alloc_pure_sym || gsl_memory_alloc_pure_64_sym) && gsl_memory_free_pure_sym)) - LOGI("hook_android_dlopen_ext: hook failed: failed to apply libgsl_alloc_hook!"); - } - - // TODO: If there is already an instance of a Vulkan driver loaded hooks won't be applied, this will only be the case for skiavk generally - // To fix this we would need to search /proc/self/maps for the file to a loaded instance of the library in order to read it to patch the soname and load it uniquely - if (hook_params->featureFlags & ADRENOTOOLS_DRIVER_CUSTOM) { - LOGI("hook_android_dlopen_ext: loading custom driver: %s%s", hook_params->customDriverDir.c_str(), hook_params->customDriverName.c_str()); - void *handle{android_dlopen_ext(hook_params->customDriverName.c_str(), flags, &newExtinfo)}; - if (!handle) { - LOGI("hook_android_dlopen_ext: hook failed: failed to load custom driver: %s!", dlerror()); - return fallback(); - } - - return handle; - } else { - LOGI("hook_android_dlopen_ext: loading default driver: %s", filename); - return android_dlopen_ext(filename, flags, &newExtinfo); - } -} - -__attribute__((visibility("default"))) void *hook_android_load_sphal_library(const char *filename, int flags) { - LOGI("hook_android_load_sphal_library: filename: %s", filename); - - // https://android.googlesource.com/platform/system/core/+/master/libvndksupport/linker.cpp - for (const char *name : {"sphal", "vendor", "default"}) { - if (auto vendorNs{android_get_exported_namespace(name)}) { - android_dlextinfo dlextinfo{ - .flags = ANDROID_DLEXT_USE_NAMESPACE, - .library_namespace = vendorNs, - }; - - return hook_android_dlopen_ext(filename, flags, &dlextinfo); - } - } - - return nullptr; -} - -__attribute__((visibility("default"))) FILE *hook_fopen(const char *filename, const char *mode) { - if (!strncmp("/proc", filename, 5) || !strncmp("/sys", filename, 4)) { - LOGI("hook_fopen: passthrough: %s", filename); - return fopen(filename, mode); - } - - auto replacement{hook_params->fileRedirectDir + filename}; - LOGI("hook_fopen: %s -> %s", filename, replacement.c_str()); - - return fopen(replacement.c_str(), mode); -} - -static constexpr uintptr_t GslMemDescImportedPrivMagic{0xdeadb33f}; -struct GslMemDesc { - void *hostptr; - uint64_t gpuaddr; - uint64_t size; - uint64_t flags; - uintptr_t priv; -}; - -__attribute__((visibility("default"))) int hook_gsl_memory_alloc_pure_64(uint64_t size, uint32_t flags, void *memDesc) { - auto gslMemDesc{reinterpret_cast(memDesc)}; - if (hook_params->nextGpuMapping && hook_params->nextGpuMapping->size == size && (hook_params->nextGpuMapping->flags & flags) == hook_params->nextGpuMapping->flags) { - auto &nextMapping{*hook_params->nextGpuMapping}; - - gslMemDesc->hostptr = nextMapping.host_ptr; - gslMemDesc->gpuaddr = nextMapping.gpu_addr; - gslMemDesc->size = nextMapping.size; - gslMemDesc->flags = nextMapping.flags; - gslMemDesc->priv = GslMemDescImportedPrivMagic; - hook_params->nextGpuMapping->size = 0; - hook_params->nextGpuMapping->gpu_addr = ADRENOTOOLS_GPU_MAPPING_SUCCEEDED_MAGIC; - return 0; - } else { - if (gsl_memory_alloc_pure_64_sym) - return gsl_memory_alloc_pure_64_sym(size, flags, gslMemDesc); - else - return gsl_memory_alloc_pure_sym((uint32_t)size, flags, gslMemDesc); - } -} - -__attribute__((visibility("default"))) int hook_gsl_memory_free_pure(void *memDesc) { - auto gslMemDesc{reinterpret_cast(memDesc)}; - - if (gslMemDesc->priv == GslMemDescImportedPrivMagic) { - if (!kgsl_fd) - kgsl_fd = open("/dev/kgsl-3d0", O_RDWR); - - kgsl_gpumem_get_info info{ - .gpuaddr = gslMemDesc->gpuaddr - }; - - if (ioctl(kgsl_fd, IOCTL_KGSL_GPUMEM_GET_INFO, &info) < 0) { - LOGI("IOCTL_KGSL_GPUMEM_GET_INFO failed"); - return 0; - } - - kgsl_gpuobj_free args{ - .id = info.id, - }; - - if (ioctl(kgsl_fd, IOCTL_KGSL_GPUOBJ_FREE, &args) < 0) - LOGI("IOCTL_KGSL_GPUOBJ_FREE failed"); - - return 0; - } else { - return gsl_memory_free_pure_sym(memDesc); - } -} diff --git a/externals/libadrenotools/src/hook/hook_impl.h b/externals/libadrenotools/src/hook/hook_impl.h deleted file mode 100644 index 2ce2471e1d..0000000000 --- a/externals/libadrenotools/src/hook/hook_impl.h +++ /dev/null @@ -1,30 +0,0 @@ -// SPDX-License-Identifier: BSD-2-Clause -// Copyright © 2021 Billy Laws - -#pragma once - -#ifdef __cplusplus -extern "C" { -#endif - -#include -#include - -void init_hook_param(const void *param); - -void init_gsl(void *alloc, void *alloc64, void *free); - -void *hook_android_dlopen_ext(const char *filename, int flags, const android_dlextinfo *extinfo); - -void *hook_android_load_sphal_library(const char *filename, int flags); - -FILE *hook_fopen(const char *filename, const char *mode); - -int hook_gsl_memory_alloc_pure_64(uint64_t size, uint32_t flags, void *memDesc); - -int hook_gsl_memory_free_pure(void *memDesc); - -#ifdef __cplusplus -} -#endif - diff --git a/externals/libadrenotools/src/hook/hook_impl_params.h b/externals/libadrenotools/src/hook/hook_impl_params.h deleted file mode 100644 index 8a3bd1673e..0000000000 --- a/externals/libadrenotools/src/hook/hook_impl_params.h +++ /dev/null @@ -1,31 +0,0 @@ -// SPDX-License-Identifier: BSD-2-Clause -// Copyright © 2021 Billy Laws - -#pragma once - -#include -#include - -/** - * @brief Holds the parameters needed for all hooks - * @note See comments for adrenotools_open_libvulkan as a reference for member variables - */ -struct HookImplParams { - int featureFlags; - std::string tmpLibDir; - std::string hookLibDir; - std::string customDriverDir; - std::string customDriverName; - std::string fileRedirectDir; - adrenotools_gpu_mapping *nextGpuMapping; - - HookImplParams(int featureFlags, const char *tmpLibDir, const char *hookLibDir, const char *customDriverDir, - const char *customDriverName, const char *fileRedirectDir, adrenotools_gpu_mapping *nextGpuMapping) - : featureFlags(featureFlags), - tmpLibDir(tmpLibDir ? tmpLibDir : ""), - hookLibDir(hookLibDir), - customDriverDir(customDriverDir ? customDriverDir : ""), - customDriverName(customDriverName ? customDriverName : ""), - fileRedirectDir(fileRedirectDir ? fileRedirectDir : ""), - nextGpuMapping(nextGpuMapping) {} -}; diff --git a/externals/libadrenotools/src/hook/kgsl.h b/externals/libadrenotools/src/hook/kgsl.h deleted file mode 100644 index 6d4d93d6af..0000000000 --- a/externals/libadrenotools/src/hook/kgsl.h +++ /dev/null @@ -1,2124 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ -/* - * Copyright (c) 2018-2021, The Linux Foundation. All rights reserved. - * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved. - */ - -#ifndef _UAPI_MSM_KGSL_H -#define _UAPI_MSM_KGSL_H - -#include -#include - -/* - * The KGSL version has proven not to be very useful in userspace if features - * are cherry picked into other trees out of order so it is frozen as of 3.14. - * It is left here for backwards compatabilty and as a reminder that - * software releases are never linear. Also, I like pie. - */ - -#define KGSL_VERSION_MAJOR 3 -#define KGSL_VERSION_MINOR 14 - -/* - * We have traditionally mixed context and issueibcmds / command batch flags - * together into a big flag stew. This worked fine until we started adding a - * lot more command batch flags and we started running out of bits. Turns out - * we have a bit of room in the context type / priority mask that we could use - * for command batches, but that means we need to split out the flags into two - * coherent sets. - * - * If any future definitions are for both context and cmdbatch add both defines - * and link the cmdbatch to the context define as we do below. Otherwise feel - * free to add exclusive bits to either set. - */ - -/* --- context flags --- */ -#define KGSL_CONTEXT_SAVE_GMEM 0x00000001 -#define KGSL_CONTEXT_NO_GMEM_ALLOC 0x00000002 -/* This is a cmdbatch exclusive flag - use the CMDBATCH equivalent instead */ -#define KGSL_CONTEXT_SUBMIT_IB_LIST 0x00000004 -#define KGSL_CONTEXT_CTX_SWITCH 0x00000008 -#define KGSL_CONTEXT_PREAMBLE 0x00000010 -#define KGSL_CONTEXT_TRASH_STATE 0x00000020 -#define KGSL_CONTEXT_PER_CONTEXT_TS 0x00000040 -#define KGSL_CONTEXT_USER_GENERATED_TS 0x00000080 -/* This is a cmdbatch exclusive flag - use the CMDBATCH equivalent instead */ -#define KGSL_CONTEXT_END_OF_FRAME 0x00000100 -#define KGSL_CONTEXT_NO_FAULT_TOLERANCE 0x00000200 -/* This is a cmdbatch exclusive flag - use the CMDBATCH equivalent instead */ -#define KGSL_CONTEXT_SYNC 0x00000400 -#define KGSL_CONTEXT_PWR_CONSTRAINT 0x00000800 -#define KGSL_CONTEXT_PRIORITY_MASK 0x0000F000 -#define KGSL_CONTEXT_PRIORITY_SHIFT 12 -#define KGSL_CONTEXT_PRIORITY_UNDEF 0 - -#define KGSL_CONTEXT_IFH_NOP 0x00010000 -#define KGSL_CONTEXT_SECURE 0x00020000 -#define KGSL_CONTEXT_NO_SNAPSHOT 0x00040000 -#define KGSL_CONTEXT_SPARSE 0x00080000 - -#define KGSL_CONTEXT_PREEMPT_STYLE_MASK 0x0E000000 -#define KGSL_CONTEXT_PREEMPT_STYLE_SHIFT 25 -#define KGSL_CONTEXT_PREEMPT_STYLE_DEFAULT 0x0 -#define KGSL_CONTEXT_PREEMPT_STYLE_RINGBUFFER 0x1 -#define KGSL_CONTEXT_PREEMPT_STYLE_FINEGRAIN 0x2 - -#define KGSL_CONTEXT_TYPE_MASK 0x01F00000 -#define KGSL_CONTEXT_TYPE_SHIFT 20 -#define KGSL_CONTEXT_TYPE_ANY 0 -#define KGSL_CONTEXT_TYPE_GL 1 -#define KGSL_CONTEXT_TYPE_CL 2 -#define KGSL_CONTEXT_TYPE_C2D 3 -#define KGSL_CONTEXT_TYPE_RS 4 -#define KGSL_CONTEXT_TYPE_VK 5 -#define KGSL_CONTEXT_TYPE_UNKNOWN 0x1E - -#define KGSL_CONTEXT_INVALIDATE_ON_FAULT 0x10000000 -#define KGSL_CONTEXT_LPAC 0x20000000 -#define KGSL_CONTEXT_FAULT_INFO 0x40000000 - -#define KGSL_CONTEXT_INVALID 0xffffffff - -/* - * --- command batch flags --- - * The bits that are linked to a KGSL_CONTEXT equivalent are either legacy - * definitions or bits that are valid for both contexts and cmdbatches. To be - * safe the other 8 bits that are still available in the context field should be - * omitted here in case we need to share - the other bits are available for - * cmdbatch only flags as needed - */ -#define KGSL_CMDBATCH_MEMLIST 0x00000001 -#define KGSL_CMDBATCH_MARKER 0x00000002 -#define KGSL_CMDBATCH_SUBMIT_IB_LIST KGSL_CONTEXT_SUBMIT_IB_LIST /* 0x004 */ -#define KGSL_CMDBATCH_CTX_SWITCH KGSL_CONTEXT_CTX_SWITCH /* 0x008 */ -#define KGSL_CMDBATCH_PROFILING 0x00000010 -/* - * KGSL_CMDBATCH_PROFILING must also be set for KGSL_CMDBATCH_PROFILING_KTIME - * to take effect, as the latter only affects the time data returned. - */ -#define KGSL_CMDBATCH_PROFILING_KTIME 0x00000020 -#define KGSL_CMDBATCH_END_OF_FRAME KGSL_CONTEXT_END_OF_FRAME /* 0x100 */ -#define KGSL_CMDBATCH_SYNC KGSL_CONTEXT_SYNC /* 0x400 */ -#define KGSL_CMDBATCH_PWR_CONSTRAINT KGSL_CONTEXT_PWR_CONSTRAINT /* 0x800 */ -#define KGSL_CMDBATCH_SPARSE 0x1000 /* 0x1000 */ -/* RECURRING bits must be set for LSR workload with IOCTL_KGSL_RECURRING_COMMAND. */ -#define KGSL_CMDBATCH_START_RECURRING 0x00100000 -#define KGSL_CMDBATCH_STOP_RECURRING 0x00200000 - -/* - * Reserve bits [16:19] and bits [28:31] for possible bits shared between - * contexts and command batches. Update this comment as new flags are added. - */ - -/* - * gpu_command_object flags - these flags communicate the type of command or - * memory object being submitted for a GPU command - */ - -/* Flags for GPU command objects */ -#define KGSL_CMDLIST_IB 0x00000001U -#define KGSL_CMDLIST_CTXTSWITCH_PREAMBLE 0x00000002U -#define KGSL_CMDLIST_IB_PREAMBLE 0x00000004U - -/* Flags for GPU command memory objects */ -#define KGSL_OBJLIST_MEMOBJ 0x00000008U -#define KGSL_OBJLIST_PROFILE 0x00000010U - -/* Flags for GPU command sync points */ -#define KGSL_CMD_SYNCPOINT_TYPE_TIMESTAMP 0 -#define KGSL_CMD_SYNCPOINT_TYPE_FENCE 1 -#define KGSL_CMD_SYNCPOINT_TYPE_TIMELINE 2 - -/* --- Memory allocation flags --- */ - -/* General allocation hints */ -#define KGSL_MEMFLAGS_SECURE (1ULL << 3) -#define KGSL_MEMFLAGS_GPUREADONLY (1ULL << 24) -#define KGSL_MEMFLAGS_GPUWRITEONLY (1ULL << 25) -#define KGSL_MEMFLAGS_FORCE_32BIT (1ULL << 32) - -/* Flag for binding all the virt range to single phys data */ -#define KGSL_SPARSE_BIND_MULTIPLE_TO_PHYS 0x400000000ULL -#define KGSL_SPARSE_BIND 0x1ULL -#define KGSL_SPARSE_UNBIND 0x2ULL - -/* Memory caching hints */ -#define KGSL_CACHEMODE_MASK 0x0C000000U -#define KGSL_CACHEMODE_SHIFT 26 - -#define KGSL_CACHEMODE_WRITECOMBINE 0 -#define KGSL_CACHEMODE_UNCACHED 1 -#define KGSL_CACHEMODE_WRITETHROUGH 2 -#define KGSL_CACHEMODE_WRITEBACK 3 - -#define KGSL_MEMFLAGS_USE_CPU_MAP (1ULL << 28) -#define KGSL_MEMFLAGS_SPARSE_PHYS (1ULL << 29) -#define KGSL_MEMFLAGS_SPARSE_VIRT (1ULL << 30) -#define KGSL_MEMFLAGS_IOCOHERENT (1ULL << 31) -#define KGSL_MEMFLAGS_GUARD_PAGE (1ULL << 33) -#define KGSL_MEMFLAGS_VBO (1ULL << 34) - -/* Memory types for which allocations are made */ -#define KGSL_MEMTYPE_MASK 0x0000FF00 -#define KGSL_MEMTYPE_SHIFT 8 - -#define KGSL_MEMTYPE_OBJECTANY 0 -#define KGSL_MEMTYPE_FRAMEBUFFER 1 -#define KGSL_MEMTYPE_RENDERBUFFER 2 -#define KGSL_MEMTYPE_ARRAYBUFFER 3 -#define KGSL_MEMTYPE_ELEMENTARRAYBUFFER 4 -#define KGSL_MEMTYPE_VERTEXARRAYBUFFER 5 -#define KGSL_MEMTYPE_TEXTURE 6 -#define KGSL_MEMTYPE_SURFACE 7 -#define KGSL_MEMTYPE_EGL_SURFACE 8 -#define KGSL_MEMTYPE_GL 9 -#define KGSL_MEMTYPE_CL 10 -#define KGSL_MEMTYPE_CL_BUFFER_MAP 11 -#define KGSL_MEMTYPE_CL_BUFFER_NOMAP 12 -#define KGSL_MEMTYPE_CL_IMAGE_MAP 13 -#define KGSL_MEMTYPE_CL_IMAGE_NOMAP 14 -#define KGSL_MEMTYPE_CL_KERNEL_STACK 15 -#define KGSL_MEMTYPE_COMMAND 16 -#define KGSL_MEMTYPE_2D 17 -#define KGSL_MEMTYPE_EGL_IMAGE 18 -#define KGSL_MEMTYPE_EGL_SHADOW 19 -#define KGSL_MEMTYPE_MULTISAMPLE 20 -#define KGSL_MEMTYPE_KERNEL 255 - -/* - * Alignment hint, passed as the power of 2 exponent. - * i.e 4k (2^12) would be 12, 64k (2^16)would be 16. - */ -#define KGSL_MEMALIGN_MASK 0x00FF0000 -#define KGSL_MEMALIGN_SHIFT 16 - -enum kgsl_user_mem_type { - KGSL_USER_MEM_TYPE_PMEM = 0x00000000, - KGSL_USER_MEM_TYPE_ASHMEM = 0x00000001, - KGSL_USER_MEM_TYPE_ADDR = 0x00000002, - KGSL_USER_MEM_TYPE_ION = 0x00000003, - /* - * ION type is retained for backwards compatibility but Ion buffers are - * dma-bufs so try to use that naming if we can - */ - KGSL_USER_MEM_TYPE_DMABUF = 0x00000003, - KGSL_USER_MEM_TYPE_MAX = 0x00000007, -}; -#define KGSL_MEMFLAGS_USERMEM_MASK 0x000000e0 -#define KGSL_MEMFLAGS_USERMEM_SHIFT 5 - -/* - * Unfortunately, enum kgsl_user_mem_type starts at 0 which does not - * leave a good value for allocated memory. In the flags we use - * 0 to indicate allocated memory and thus need to add 1 to the enum - * values. - */ -#define KGSL_USERMEM_FLAG(x) (((x) + 1) << KGSL_MEMFLAGS_USERMEM_SHIFT) - -#define KGSL_MEMFLAGS_NOT_USERMEM 0 -#define KGSL_MEMFLAGS_USERMEM_PMEM KGSL_USERMEM_FLAG(KGSL_USER_MEM_TYPE_PMEM) -#define KGSL_MEMFLAGS_USERMEM_ASHMEM \ - KGSL_USERMEM_FLAG(KGSL_USER_MEM_TYPE_ASHMEM) -#define KGSL_MEMFLAGS_USERMEM_ADDR KGSL_USERMEM_FLAG(KGSL_USER_MEM_TYPE_ADDR) -#define KGSL_MEMFLAGS_USERMEM_ION KGSL_USERMEM_FLAG(KGSL_USER_MEM_TYPE_ION) - -/* --- generic KGSL flag values --- */ - -#define KGSL_FLAGS_NORMALMODE 0x00000000 -#define KGSL_FLAGS_SAFEMODE 0x00000001 -#define KGSL_FLAGS_INITIALIZED0 0x00000002 -#define KGSL_FLAGS_INITIALIZED 0x00000004 -#define KGSL_FLAGS_STARTED 0x00000008 -#define KGSL_FLAGS_ACTIVE 0x00000010 -#define KGSL_FLAGS_RESERVED0 0x00000020 -#define KGSL_FLAGS_RESERVED1 0x00000040 -#define KGSL_FLAGS_RESERVED2 0x00000080 -#define KGSL_FLAGS_SOFT_RESET 0x00000100 -#define KGSL_FLAGS_PER_CONTEXT_TIMESTAMPS 0x00000200 - -/* Server Side Sync Timeout in milliseconds */ -#define KGSL_SYNCOBJ_SERVER_TIMEOUT 2000 - -/* UBWC Modes */ -#define KGSL_UBWC_NONE 0 -#define KGSL_UBWC_1_0 1 -#define KGSL_UBWC_2_0 2 -#define KGSL_UBWC_3_0 3 -#define KGSL_UBWC_4_0 4 - -/* - * Reset status values for context - */ -enum kgsl_ctx_reset_stat { - KGSL_CTX_STAT_NO_ERROR = 0x00000000, - KGSL_CTX_STAT_GUILTY_CONTEXT_RESET_EXT = 0x00000001, - KGSL_CTX_STAT_INNOCENT_CONTEXT_RESET_EXT = 0x00000002, - KGSL_CTX_STAT_UNKNOWN_CONTEXT_RESET_EXT = 0x00000003 -}; - -#define KGSL_CONVERT_TO_MBPS(val) \ - (val*1000*1000U) - -struct kgsl_devinfo { - - unsigned int device_id; - /* - * chip revision id - * coreid:8 majorrev:8 minorrev:8 patch:8 - */ - unsigned int chip_id; - unsigned int mmu_enabled; - unsigned long gmem_gpubaseaddr; - /* - * This field contains the adreno revision - * number 200, 205, 220, etc... - */ - unsigned int gpu_id; - __kernel_size_t gmem_sizebytes; -}; - -/* - * struct kgsl_devmemstore - this structure defines the region of memory - * that can be mmap()ed from this driver. The timestamp fields are volatile - * because they are written by the GPU - * @soptimestamp: Start of pipeline timestamp written by GPU before the - * commands in concern are processed - * @sbz: Unused, kept for 8 byte alignment - * @eoptimestamp: End of pipeline timestamp written by GPU after the - * commands in concern are processed - * @sbz2: Unused, kept for 8 byte alignment - * @preempted: Indicates if the context was preempted - * @sbz3: Unused, kept for 8 byte alignment - * @ref_wait_ts: Timestamp on which to generate interrupt, unused now. - * @sbz4: Unused, kept for 8 byte alignment - * @current_context: The current context the GPU is working on - * @sbz5: Unused, kept for 8 byte alignment - */ -struct kgsl_devmemstore { - volatile unsigned int soptimestamp; - unsigned int sbz; - volatile unsigned int eoptimestamp; - unsigned int sbz2; - volatile unsigned int preempted; - unsigned int sbz3; - volatile unsigned int ref_wait_ts; - unsigned int sbz4; - unsigned int current_context; - unsigned int sbz5; -}; - -#define KGSL_MEMSTORE_OFFSET(ctxt_id, field) \ - ((ctxt_id)*sizeof(struct kgsl_devmemstore) + \ - offsetof(struct kgsl_devmemstore, field)) - -/* timestamp id*/ -enum kgsl_timestamp_type { - KGSL_TIMESTAMP_CONSUMED = 0x00000001, /* start-of-pipeline timestamp */ - KGSL_TIMESTAMP_RETIRED = 0x00000002, /* end-of-pipeline timestamp*/ - KGSL_TIMESTAMP_QUEUED = 0x00000003, -}; - -/* property types - used with kgsl_device_getproperty */ -#define KGSL_PROP_DEVICE_INFO 0x1 -#define KGSL_PROP_DEVICE_SHADOW 0x2 -#define KGSL_PROP_DEVICE_POWER 0x3 -#define KGSL_PROP_SHMEM 0x4 -#define KGSL_PROP_SHMEM_APERTURES 0x5 -#define KGSL_PROP_MMU_ENABLE 0x6 -#define KGSL_PROP_INTERRUPT_WAITS 0x7 -#define KGSL_PROP_VERSION 0x8 -#define KGSL_PROP_GPU_RESET_STAT 0x9 -#define KGSL_PROP_PWRCTRL 0xE -#define KGSL_PROP_PWR_CONSTRAINT 0x12 -#define KGSL_PROP_UCHE_GMEM_VADDR 0x13 -#define KGSL_PROP_SP_GENERIC_MEM 0x14 -#define KGSL_PROP_UCODE_VERSION 0x15 -#define KGSL_PROP_GPMU_VERSION 0x16 -#define KGSL_PROP_HIGHEST_BANK_BIT 0x17 -#define KGSL_PROP_DEVICE_BITNESS 0x18 -#define KGSL_PROP_DEVICE_QDSS_STM 0x19 -#define KGSL_PROP_MIN_ACCESS_LENGTH 0x1A -#define KGSL_PROP_UBWC_MODE 0x1B -#define KGSL_PROP_DEVICE_QTIMER 0x20 -#define KGSL_PROP_L3_PWR_CONSTRAINT 0x22 -#define KGSL_PROP_SECURE_BUFFER_ALIGNMENT 0x23 -#define KGSL_PROP_SECURE_CTXT_SUPPORT 0x24 -#define KGSL_PROP_SPEED_BIN 0x25 -#define KGSL_PROP_GAMING_BIN 0x26 -#define KGSL_PROP_QUERY_CAPABILITIES 0x27 -#define KGSL_PROP_CONTEXT_PROPERTY 0x28 -#define KGSL_PROP_GPU_MODEL 0x29 -#define KGSL_PROP_VK_DEVICE_ID 0x2A -#define KGSL_PROP_IS_LPAC_ENABLED 0x2B - -/* - * kgsl_capabilities_properties returns a list of supported properties. - * If the user passes 0 for 'count' the kernel will set it to the number of - * supported properties. The list is expected to be 'count * sizeof(__u32)' - * bytes long. The kernel will return the actual number of entries copied into - * list via 'count'. - */ -struct kgsl_capabilities_properties { - __u64 list; - __u32 count; -}; - -/* - * KGSL_QUERY_CAPS_PROPERTIES returns a list of the valid properties in the - * kernel. The subtype data should be struct kgsl_capabilities_properties - */ -#define KGSL_QUERY_CAPS_PROPERTIES 1 - -/* - * kgsl_capabilities allows the user to query kernel capabilities. The 'data' - * type should be set appropriately for the querytype (see above). Pass 0 to - * 'size' and the kernel will set it to the expected size of 'data' that is - * appropriate for querytype (in bytes). - */ -struct kgsl_capabilities { - __u64 data; - __u64 size; - __u32 querytype; -}; - -struct kgsl_shadowprop { - unsigned long gpuaddr; - __kernel_size_t size; - unsigned int flags; /* contains KGSL_FLAGS_ values */ -}; - -struct kgsl_qdss_stm_prop { - __u64 gpuaddr; - __u64 size; -}; - -struct kgsl_qtimer_prop { - __u64 gpuaddr; - __u64 size; -}; - -struct kgsl_version { - unsigned int drv_major; - unsigned int drv_minor; - unsigned int dev_major; - unsigned int dev_minor; -}; - -struct kgsl_sp_generic_mem { - __u64 local; - __u64 pvt; -}; - -struct kgsl_ucode_version { - unsigned int pfp; - unsigned int pm4; -}; - -struct kgsl_gpmu_version { - unsigned int major; - unsigned int minor; - unsigned int features; -}; - -struct kgsl_context_property { - __u64 data; - __u32 size; - __u32 type; - __u32 contextid; -}; - -struct kgsl_context_property_fault { - __s32 faults; - __u32 timestamp; -}; - -struct kgsl_gpu_model { - char gpu_model[32]; -}; - -/* Context property sub types */ -#define KGSL_CONTEXT_PROP_FAULTS 1 - -/* Performance counter groups */ - -#define KGSL_PERFCOUNTER_GROUP_CP 0x0 -#define KGSL_PERFCOUNTER_GROUP_RBBM 0x1 -#define KGSL_PERFCOUNTER_GROUP_PC 0x2 -#define KGSL_PERFCOUNTER_GROUP_VFD 0x3 -#define KGSL_PERFCOUNTER_GROUP_HLSQ 0x4 -#define KGSL_PERFCOUNTER_GROUP_VPC 0x5 -#define KGSL_PERFCOUNTER_GROUP_TSE 0x6 -#define KGSL_PERFCOUNTER_GROUP_RAS 0x7 -#define KGSL_PERFCOUNTER_GROUP_UCHE 0x8 -#define KGSL_PERFCOUNTER_GROUP_TP 0x9 -#define KGSL_PERFCOUNTER_GROUP_SP 0xA -#define KGSL_PERFCOUNTER_GROUP_RB 0xB -#define KGSL_PERFCOUNTER_GROUP_PWR 0xC -#define KGSL_PERFCOUNTER_GROUP_VBIF 0xD -#define KGSL_PERFCOUNTER_GROUP_VBIF_PWR 0xE -#define KGSL_PERFCOUNTER_GROUP_MH 0xF -#define KGSL_PERFCOUNTER_GROUP_PA_SU 0x10 -#define KGSL_PERFCOUNTER_GROUP_SQ 0x11 -#define KGSL_PERFCOUNTER_GROUP_SX 0x12 -#define KGSL_PERFCOUNTER_GROUP_TCF 0x13 -#define KGSL_PERFCOUNTER_GROUP_TCM 0x14 -#define KGSL_PERFCOUNTER_GROUP_TCR 0x15 -#define KGSL_PERFCOUNTER_GROUP_L2 0x16 -#define KGSL_PERFCOUNTER_GROUP_VSC 0x17 -#define KGSL_PERFCOUNTER_GROUP_CCU 0x18 -#define KGSL_PERFCOUNTER_GROUP_LRZ 0x19 -#define KGSL_PERFCOUNTER_GROUP_CMP 0x1A -#define KGSL_PERFCOUNTER_GROUP_ALWAYSON 0x1B -#define KGSL_PERFCOUNTER_GROUP_SP_PWR 0x1C -#define KGSL_PERFCOUNTER_GROUP_TP_PWR 0x1D -#define KGSL_PERFCOUNTER_GROUP_RB_PWR 0x1E -#define KGSL_PERFCOUNTER_GROUP_CCU_PWR 0x1F -#define KGSL_PERFCOUNTER_GROUP_UCHE_PWR 0x20 -#define KGSL_PERFCOUNTER_GROUP_CP_PWR 0x21 -#define KGSL_PERFCOUNTER_GROUP_GPMU_PWR 0x22 -#define KGSL_PERFCOUNTER_GROUP_ALWAYSON_PWR 0x23 -#define KGSL_PERFCOUNTER_GROUP_GLC 0x24 -#define KGSL_PERFCOUNTER_GROUP_FCHE 0x25 -#define KGSL_PERFCOUNTER_GROUP_MHUB 0x26 -#define KGSL_PERFCOUNTER_GROUP_GMU_XOCLK 0x27 -#define KGSL_PERFCOUNTER_GROUP_GMU_GMUCLK 0x28 -#define KGSL_PERFCOUNTER_GROUP_GMU_PERF 0x29 -#define KGSL_PERFCOUNTER_GROUP_SW 0x2a -#define KGSL_PERFCOUNTER_GROUP_UFC 0x2b -#define KGSL_PERFCOUNTER_GROUP_BV_CP 0x2c -#define KGSL_PERFCOUNTER_GROUP_BV_PC 0x2d -#define KGSL_PERFCOUNTER_GROUP_BV_VFD 0x2e -#define KGSL_PERFCOUNTER_GROUP_BV_VPC 0x2f -#define KGSL_PERFCOUNTER_GROUP_BV_TP 0x30 -#define KGSL_PERFCOUNTER_GROUP_BV_SP 0x31 -#define KGSL_PERFCOUNTER_GROUP_BV_UFC 0x32 -#define KGSL_PERFCOUNTER_GROUP_BV_TSE 0x33 -#define KGSL_PERFCOUNTER_GROUP_BV_RAS 0x34 -#define KGSL_PERFCOUNTER_GROUP_BV_LRZ 0x35 -#define KGSL_PERFCOUNTER_GROUP_BV_HLSQ 0x36 -#define KGSL_PERFCOUNTER_GROUP_MAX 0x37 - -#define KGSL_PERFCOUNTER_NOT_USED 0xFFFFFFFF -#define KGSL_PERFCOUNTER_BROKEN 0xFFFFFFFE - -/* structure holds list of ibs */ -struct kgsl_ibdesc { - unsigned long gpuaddr; - unsigned long __pad; - __kernel_size_t sizedwords; - unsigned int ctrl; -}; - -/** - * struct kgsl_cmdbatch_profiling_buffer - * @wall_clock_s: Ringbuffer submission time (seconds). - * If KGSL_CMDBATCH_PROFILING_KTIME is set, time is provided - * in kernel clocks, otherwise wall clock time is used. - * @wall_clock_ns: Ringbuffer submission time (nanoseconds). - * If KGSL_CMDBATCH_PROFILING_KTIME is set time is provided - * in kernel clocks, otherwise wall clock time is used. - * @gpu_ticks_queued: GPU ticks at ringbuffer submission - * @gpu_ticks_submitted: GPU ticks when starting cmdbatch execution - * @gpu_ticks_retired: GPU ticks when finishing cmdbatch execution - * - * This structure defines the profiling buffer used to measure cmdbatch - * execution time - */ -struct kgsl_cmdbatch_profiling_buffer { - __u64 wall_clock_s; - __u64 wall_clock_ns; - __u64 gpu_ticks_queued; - __u64 gpu_ticks_submitted; - __u64 gpu_ticks_retired; -}; - -/* ioctls */ -#define KGSL_IOC_TYPE 0x09 - -/* - * get misc info about the GPU - * type should be a value from enum kgsl_property_type - * value points to a structure that varies based on type - * sizebytes is sizeof() that structure - * for KGSL_PROP_DEVICE_INFO, use struct kgsl_devinfo - * this structure contaings hardware versioning info. - * for KGSL_PROP_DEVICE_SHADOW, use struct kgsl_shadowprop - * this is used to find mmap() offset and sizes for mapping - * struct kgsl_memstore into userspace. - */ -struct kgsl_device_getproperty { - unsigned int type; - void __user *value; - __kernel_size_t sizebytes; -}; - -#define IOCTL_KGSL_DEVICE_GETPROPERTY \ - _IOWR(KGSL_IOC_TYPE, 0x2, struct kgsl_device_getproperty) - -/* IOCTL_KGSL_DEVICE_READ (0x3) - removed 03/2012 - */ - -/* block until the GPU has executed past a given timestamp - * timeout is in milliseconds. - */ -struct kgsl_device_waittimestamp { - unsigned int timestamp; - unsigned int timeout; -}; - -#define IOCTL_KGSL_DEVICE_WAITTIMESTAMP \ - _IOW(KGSL_IOC_TYPE, 0x6, struct kgsl_device_waittimestamp) - -struct kgsl_device_waittimestamp_ctxtid { - unsigned int context_id; - unsigned int timestamp; - unsigned int timeout; -}; - -#define IOCTL_KGSL_DEVICE_WAITTIMESTAMP_CTXTID \ - _IOW(KGSL_IOC_TYPE, 0x7, struct kgsl_device_waittimestamp_ctxtid) - -/* DEPRECATED: issue indirect commands to the GPU. - * drawctxt_id must have been created with IOCTL_KGSL_DRAWCTXT_CREATE - * ibaddr and sizedwords must specify a subset of a buffer created - * with IOCTL_KGSL_SHAREDMEM_FROM_PMEM - * flags may be a mask of KGSL_CONTEXT_ values - * timestamp is a returned counter value which can be passed to - * other ioctls to determine when the commands have been executed by - * the GPU. - * - * This function is deprecated - consider using IOCTL_KGSL_SUBMIT_COMMANDS - * instead - */ -struct kgsl_ringbuffer_issueibcmds { - unsigned int drawctxt_id; - unsigned long ibdesc_addr; - unsigned int numibs; - unsigned int timestamp; /*output param */ - unsigned int flags; -}; - -#define IOCTL_KGSL_RINGBUFFER_ISSUEIBCMDS \ - _IOWR(KGSL_IOC_TYPE, 0x10, struct kgsl_ringbuffer_issueibcmds) - -/* read the most recently executed timestamp value - * type should be a value from enum kgsl_timestamp_type - */ -struct kgsl_cmdstream_readtimestamp { - unsigned int type; - unsigned int timestamp; /*output param */ -}; - -#define IOCTL_KGSL_CMDSTREAM_READTIMESTAMP_OLD \ - _IOR(KGSL_IOC_TYPE, 0x11, struct kgsl_cmdstream_readtimestamp) - -#define IOCTL_KGSL_CMDSTREAM_READTIMESTAMP \ - _IOWR(KGSL_IOC_TYPE, 0x11, struct kgsl_cmdstream_readtimestamp) - -/* free memory when the GPU reaches a given timestamp. - * gpuaddr specify a memory region created by a - * IOCTL_KGSL_SHAREDMEM_FROM_PMEM call - * type should be a value from enum kgsl_timestamp_type - */ -struct kgsl_cmdstream_freememontimestamp { - unsigned long gpuaddr; - unsigned int type; - unsigned int timestamp; -}; - -#define IOCTL_KGSL_CMDSTREAM_FREEMEMONTIMESTAMP \ - _IOW(KGSL_IOC_TYPE, 0x12, struct kgsl_cmdstream_freememontimestamp) - -/* - * Previous versions of this header had incorrectly defined - * IOCTL_KGSL_CMDSTREAM_FREEMEMONTIMESTAMP as a read-only ioctl instead - * of a write only ioctl. To ensure binary compatibility, the following - * #define will be used to intercept the incorrect ioctl - */ - -#define IOCTL_KGSL_CMDSTREAM_FREEMEMONTIMESTAMP_OLD \ - _IOR(KGSL_IOC_TYPE, 0x12, struct kgsl_cmdstream_freememontimestamp) - -/* create a draw context, which is used to preserve GPU state. - * The flags field may contain a mask KGSL_CONTEXT_* values - */ -struct kgsl_drawctxt_create { - unsigned int flags; - unsigned int drawctxt_id; /*output param */ -}; - -#define IOCTL_KGSL_DRAWCTXT_CREATE \ - _IOWR(KGSL_IOC_TYPE, 0x13, struct kgsl_drawctxt_create) - -/* destroy a draw context */ -struct kgsl_drawctxt_destroy { - unsigned int drawctxt_id; -}; - -#define IOCTL_KGSL_DRAWCTXT_DESTROY \ - _IOW(KGSL_IOC_TYPE, 0x14, struct kgsl_drawctxt_destroy) - -/* - * add a block of pmem, fb, ashmem or user allocated address - * into the GPU address space - */ -struct kgsl_map_user_mem { - int fd; - unsigned long gpuaddr; /*output param */ - __kernel_size_t len; - __kernel_size_t offset; - unsigned long hostptr; /*input param */ - enum kgsl_user_mem_type memtype; - unsigned int flags; -}; - -#define IOCTL_KGSL_MAP_USER_MEM \ - _IOWR(KGSL_IOC_TYPE, 0x15, struct kgsl_map_user_mem) - -struct kgsl_cmdstream_readtimestamp_ctxtid { - unsigned int context_id; - unsigned int type; - unsigned int timestamp; /*output param */ -}; - -#define IOCTL_KGSL_CMDSTREAM_READTIMESTAMP_CTXTID \ - _IOWR(KGSL_IOC_TYPE, 0x16, struct kgsl_cmdstream_readtimestamp_ctxtid) - -struct kgsl_cmdstream_freememontimestamp_ctxtid { - unsigned int context_id; - unsigned long gpuaddr; - unsigned int type; - unsigned int timestamp; -}; - -#define IOCTL_KGSL_CMDSTREAM_FREEMEMONTIMESTAMP_CTXTID \ - _IOW(KGSL_IOC_TYPE, 0x17, \ - struct kgsl_cmdstream_freememontimestamp_ctxtid) - -/* add a block of pmem or fb into the GPU address space */ -struct kgsl_sharedmem_from_pmem { - int pmem_fd; - unsigned long gpuaddr; /*output param */ - unsigned int len; - unsigned int offset; -}; - -#define IOCTL_KGSL_SHAREDMEM_FROM_PMEM \ - _IOWR(KGSL_IOC_TYPE, 0x20, struct kgsl_sharedmem_from_pmem) - -/* remove memory from the GPU's address space */ -struct kgsl_sharedmem_free { - unsigned long gpuaddr; -}; - -#define IOCTL_KGSL_SHAREDMEM_FREE \ - _IOW(KGSL_IOC_TYPE, 0x21, struct kgsl_sharedmem_free) - -struct kgsl_cff_user_event { - unsigned char cff_opcode; - unsigned int op1; - unsigned int op2; - unsigned int op3; - unsigned int op4; - unsigned int op5; - unsigned int __pad[2]; -}; - -#define IOCTL_KGSL_CFF_USER_EVENT \ - _IOW(KGSL_IOC_TYPE, 0x31, struct kgsl_cff_user_event) - -struct kgsl_gmem_desc { - unsigned int x; - unsigned int y; - unsigned int width; - unsigned int height; - unsigned int pitch; -}; - -struct kgsl_buffer_desc { - void *hostptr; - unsigned long gpuaddr; - int size; - unsigned int format; - unsigned int pitch; - unsigned int enabled; -}; - -struct kgsl_bind_gmem_shadow { - unsigned int drawctxt_id; - struct kgsl_gmem_desc gmem_desc; - unsigned int shadow_x; - unsigned int shadow_y; - struct kgsl_buffer_desc shadow_buffer; - unsigned int buffer_id; -}; - -#define IOCTL_KGSL_DRAWCTXT_BIND_GMEM_SHADOW \ - _IOW(KGSL_IOC_TYPE, 0x22, struct kgsl_bind_gmem_shadow) - -/* add a block of memory into the GPU address space */ - -/* - * IOCTL_KGSL_SHAREDMEM_FROM_VMALLOC deprecated 09/2012 - * use IOCTL_KGSL_GPUMEM_ALLOC instead - */ - -struct kgsl_sharedmem_from_vmalloc { - unsigned long gpuaddr; /*output param */ - unsigned int hostptr; - unsigned int flags; -}; - -#define IOCTL_KGSL_SHAREDMEM_FROM_VMALLOC \ - _IOWR(KGSL_IOC_TYPE, 0x23, struct kgsl_sharedmem_from_vmalloc) - -/* - * This is being deprecated in favor of IOCTL_KGSL_GPUMEM_CACHE_SYNC which - * supports both directions (flush and invalidate). This code will still - * work, but by definition it will do a flush of the cache which might not be - * what you want to have happen on a buffer following a GPU operation. It is - * safer to go with IOCTL_KGSL_GPUMEM_CACHE_SYNC - */ - -#define IOCTL_KGSL_SHAREDMEM_FLUSH_CACHE \ - _IOW(KGSL_IOC_TYPE, 0x24, struct kgsl_sharedmem_free) - -struct kgsl_drawctxt_set_bin_base_offset { - unsigned int drawctxt_id; - unsigned int offset; -}; - -#define IOCTL_KGSL_DRAWCTXT_SET_BIN_BASE_OFFSET \ - _IOW(KGSL_IOC_TYPE, 0x25, struct kgsl_drawctxt_set_bin_base_offset) - -enum kgsl_cmdwindow_type { - KGSL_CMDWINDOW_MIN = 0x00000000, - KGSL_CMDWINDOW_2D = 0x00000000, - KGSL_CMDWINDOW_3D = 0x00000001, /* legacy */ - KGSL_CMDWINDOW_MMU = 0x00000002, - KGSL_CMDWINDOW_ARBITER = 0x000000FF, - KGSL_CMDWINDOW_MAX = 0x000000FF, -}; - -/* write to the command window */ -struct kgsl_cmdwindow_write { - enum kgsl_cmdwindow_type target; - unsigned int addr; - unsigned int data; -}; - -#define IOCTL_KGSL_CMDWINDOW_WRITE \ - _IOW(KGSL_IOC_TYPE, 0x2e, struct kgsl_cmdwindow_write) - -struct kgsl_gpumem_alloc { - unsigned long gpuaddr; /* output param */ - __kernel_size_t size; - unsigned int flags; -}; - -#define IOCTL_KGSL_GPUMEM_ALLOC \ - _IOWR(KGSL_IOC_TYPE, 0x2f, struct kgsl_gpumem_alloc) - -struct kgsl_cff_syncmem { - unsigned long gpuaddr; - __kernel_size_t len; - unsigned int __pad[2]; /* For future binary compatibility */ -}; - -#define IOCTL_KGSL_CFF_SYNCMEM \ - _IOW(KGSL_IOC_TYPE, 0x30, struct kgsl_cff_syncmem) - -/* - * A timestamp event allows the user space to register an action following an - * expired timestamp. Note IOCTL_KGSL_TIMESTAMP_EVENT has been redefined to - * _IOWR to support fences which need to return a fd for the priv parameter. - */ - -struct kgsl_timestamp_event { - int type; /* Type of event (see list below) */ - unsigned int timestamp; /* Timestamp to trigger event on */ - unsigned int context_id; /* Context for the timestamp */ - void __user *priv; /* Pointer to the event specific blob */ - __kernel_size_t len; /* Size of the event specific blob */ -}; - -#define IOCTL_KGSL_TIMESTAMP_EVENT_OLD \ - _IOW(KGSL_IOC_TYPE, 0x31, struct kgsl_timestamp_event) - -/* A genlock timestamp event releases an existing lock on timestamp expire */ - -#define KGSL_TIMESTAMP_EVENT_GENLOCK 1 - -struct kgsl_timestamp_event_genlock { - int handle; /* Handle of the genlock lock to release */ -}; - -/* A fence timestamp event releases an existing lock on timestamp expire */ - -#define KGSL_TIMESTAMP_EVENT_FENCE 2 - -struct kgsl_timestamp_event_fence { - int fence_fd; /* Fence to signal */ -}; - -/* - * Set a property within the kernel. Uses the same structure as - * IOCTL_KGSL_GETPROPERTY - */ - -#define IOCTL_KGSL_SETPROPERTY \ - _IOW(KGSL_IOC_TYPE, 0x32, struct kgsl_device_getproperty) - -#define IOCTL_KGSL_TIMESTAMP_EVENT \ - _IOWR(KGSL_IOC_TYPE, 0x33, struct kgsl_timestamp_event) - -/** - * struct kgsl_gpumem_alloc_id - argument to IOCTL_KGSL_GPUMEM_ALLOC_ID - * @id: returned id value for this allocation. - * @flags: mask of KGSL_MEM* values requested and actual flags on return. - * @size: requested size of the allocation and actual size on return. - * @mmapsize: returned size to pass to mmap() which may be larger than 'size' - * @gpuaddr: returned GPU address for the allocation - * - * Allocate memory for access by the GPU. The flags and size fields are echoed - * back by the kernel, so that the caller can know if the request was - * adjusted. - * - * Supported flags: - * KGSL_MEMFLAGS_GPUREADONLY: the GPU will be unable to write to the buffer - * KGSL_MEMTYPE*: usage hint for debugging aid - * KGSL_MEMALIGN*: alignment hint, may be ignored or adjusted by the kernel. - * KGSL_MEMFLAGS_USE_CPU_MAP: If set on call and return, the returned GPU - * address will be 0. Calling mmap() will set the GPU address. - */ -struct kgsl_gpumem_alloc_id { - unsigned int id; - unsigned int flags; - __kernel_size_t size; - __kernel_size_t mmapsize; - unsigned long gpuaddr; -/* private: reserved for future use*/ - unsigned long __pad[2]; -}; - -#define IOCTL_KGSL_GPUMEM_ALLOC_ID \ - _IOWR(KGSL_IOC_TYPE, 0x34, struct kgsl_gpumem_alloc_id) - -/** - * struct kgsl_gpumem_free_id - argument to IOCTL_KGSL_GPUMEM_FREE_ID - * @id: GPU allocation id to free - * - * Free an allocation by id, in case a GPU address has not been assigned or - * is unknown. Freeing an allocation by id with this ioctl or by GPU address - * with IOCTL_KGSL_SHAREDMEM_FREE are equivalent. - */ -struct kgsl_gpumem_free_id { - unsigned int id; -/* private: reserved for future use*/ - unsigned int __pad; -}; - -#define IOCTL_KGSL_GPUMEM_FREE_ID \ - _IOWR(KGSL_IOC_TYPE, 0x35, struct kgsl_gpumem_free_id) - -/** - * struct kgsl_gpumem_get_info - argument to IOCTL_KGSL_GPUMEM_GET_INFO - * @gpuaddr: GPU address to query. Also set on return. - * @id: GPU allocation id to query. Also set on return. - * @flags: returned mask of KGSL_MEM* values. - * @size: returned size of the allocation. - * @mmapsize: returned size to pass mmap(), which may be larger than 'size' - * @useraddr: returned address of the userspace mapping for this buffer - * - * This ioctl allows querying of all user visible attributes of an existing - * allocation, by either the GPU address or the id returned by a previous - * call to IOCTL_KGSL_GPUMEM_ALLOC_ID. Legacy allocation ioctls may not - * return all attributes so this ioctl can be used to look them up if needed. - * - */ -struct kgsl_gpumem_get_info { - unsigned long gpuaddr; - unsigned int id; - unsigned int flags; - __kernel_size_t size; - __kernel_size_t mmapsize; - unsigned long useraddr; -/* private: reserved for future use*/ - unsigned long __pad[4]; -}; - -#define IOCTL_KGSL_GPUMEM_GET_INFO\ - _IOWR(KGSL_IOC_TYPE, 0x36, struct kgsl_gpumem_get_info) - -/** - * struct kgsl_gpumem_sync_cache - argument to IOCTL_KGSL_GPUMEM_SYNC_CACHE - * @gpuaddr: GPU address of the buffer to sync. - * @id: id of the buffer to sync. Either gpuaddr or id is sufficient. - * @op: a mask of KGSL_GPUMEM_CACHE_* values - * @offset: offset into the buffer - * @length: number of bytes starting from offset to perform - * the cache operation on - * - * Sync the L2 cache for memory headed to and from the GPU - this replaces - * KGSL_SHAREDMEM_FLUSH_CACHE since it can handle cache management for both - * directions - * - */ -struct kgsl_gpumem_sync_cache { - unsigned long gpuaddr; - unsigned int id; - unsigned int op; - __kernel_size_t offset; - __kernel_size_t length; -}; - -#define KGSL_GPUMEM_CACHE_CLEAN (1 << 0) -#define KGSL_GPUMEM_CACHE_TO_GPU KGSL_GPUMEM_CACHE_CLEAN - -#define KGSL_GPUMEM_CACHE_INV (1 << 1) -#define KGSL_GPUMEM_CACHE_FROM_GPU KGSL_GPUMEM_CACHE_INV - -#define KGSL_GPUMEM_CACHE_FLUSH \ - (KGSL_GPUMEM_CACHE_CLEAN | KGSL_GPUMEM_CACHE_INV) - -/* Flag to ensure backwards compatibility of kgsl_gpumem_sync_cache struct */ -#define KGSL_GPUMEM_CACHE_RANGE (1 << 31U) - -#define IOCTL_KGSL_GPUMEM_SYNC_CACHE \ - _IOW(KGSL_IOC_TYPE, 0x37, struct kgsl_gpumem_sync_cache) - -/** - * struct kgsl_perfcounter_get - argument to IOCTL_KGSL_PERFCOUNTER_GET - * @groupid: Performance counter group ID - * @countable: Countable to select within the group - * @offset: Return offset of the reserved LO counter - * @offset_hi: Return offset of the reserved HI counter - * - * Get an available performance counter from a specified groupid. The offset - * of the performance counter will be returned after successfully assigning - * the countable to the counter for the specified group. An error will be - * returned and an offset of 0 if the groupid is invalid or there are no - * more counters left. After successfully getting a perfcounter, the user - * must call kgsl_perfcounter_put(groupid, contable) when finished with - * the perfcounter to clear up perfcounter resources. - * - */ -struct kgsl_perfcounter_get { - unsigned int groupid; - unsigned int countable; - unsigned int offset; - unsigned int offset_hi; -/* private: reserved for future use */ - unsigned int __pad; /* For future binary compatibility */ -}; - -#define IOCTL_KGSL_PERFCOUNTER_GET \ - _IOWR(KGSL_IOC_TYPE, 0x38, struct kgsl_perfcounter_get) - -/** - * struct kgsl_perfcounter_put - argument to IOCTL_KGSL_PERFCOUNTER_PUT - * @groupid: Performance counter group ID - * @countable: Countable to release within the group - * - * Put an allocated performance counter to allow others to have access to the - * resource that was previously taken. This is only to be called after - * successfully getting a performance counter from kgsl_perfcounter_get(). - * - */ -struct kgsl_perfcounter_put { - unsigned int groupid; - unsigned int countable; -/* private: reserved for future use */ - unsigned int __pad[2]; /* For future binary compatibility */ -}; - -#define IOCTL_KGSL_PERFCOUNTER_PUT \ - _IOW(KGSL_IOC_TYPE, 0x39, struct kgsl_perfcounter_put) - -/** - * struct kgsl_perfcounter_query - argument to IOCTL_KGSL_PERFCOUNTER_QUERY - * @groupid: Performance counter group ID - * @countable: Return active countables array - * @size: Size of active countables array - * @max_counters: Return total number counters for the group ID - * - * Query the available performance counters given a groupid. The array - * *countables is used to return the current active countables in counters. - * The size of the array is passed in so the kernel will only write at most - * size or counter->size for the group id. The total number of available - * counters for the group ID is returned in max_counters. - * If the array or size passed in are invalid, then only the maximum number - * of counters will be returned, no data will be written to *countables. - * If the groupid is invalid an error code will be returned. - * - */ -struct kgsl_perfcounter_query { - unsigned int groupid; - /* Array to return the current countable for up to size counters */ - unsigned int __user *countables; - unsigned int count; - unsigned int max_counters; -/* private: reserved for future use */ - unsigned int __pad[2]; /* For future binary compatibility */ -}; - -#define IOCTL_KGSL_PERFCOUNTER_QUERY \ - _IOWR(KGSL_IOC_TYPE, 0x3A, struct kgsl_perfcounter_query) - -/** - * struct kgsl_perfcounter_query - argument to IOCTL_KGSL_PERFCOUNTER_QUERY - * @groupid: Performance counter group IDs - * @countable: Performance counter countable IDs - * @value: Return performance counter reads - * @size: Size of all arrays (groupid/countable pair and return value) - * - * Read in the current value of a performance counter given by the groupid - * and countable. - * - */ - -struct kgsl_perfcounter_read_group { - unsigned int groupid; - unsigned int countable; - unsigned long long value; -}; - -struct kgsl_perfcounter_read { - struct kgsl_perfcounter_read_group __user *reads; - unsigned int count; -/* private: reserved for future use */ - unsigned int __pad[2]; /* For future binary compatibility */ -}; - -#define IOCTL_KGSL_PERFCOUNTER_READ \ - _IOWR(KGSL_IOC_TYPE, 0x3B, struct kgsl_perfcounter_read) -/* - * struct kgsl_gpumem_sync_cache_bulk - argument to - * IOCTL_KGSL_GPUMEM_SYNC_CACHE_BULK - * @id_list: list of GPU buffer ids of the buffers to sync - * @count: number of GPU buffer ids in id_list - * @op: a mask of KGSL_GPUMEM_CACHE_* values - * - * Sync the cache for memory headed to and from the GPU. Certain - * optimizations can be made on the cache operation based on the total - * size of the working set of memory to be managed. - */ -struct kgsl_gpumem_sync_cache_bulk { - unsigned int __user *id_list; - unsigned int count; - unsigned int op; -/* private: reserved for future use */ - unsigned int __pad[2]; /* For future binary compatibility */ -}; - -#define IOCTL_KGSL_GPUMEM_SYNC_CACHE_BULK \ - _IOWR(KGSL_IOC_TYPE, 0x3C, struct kgsl_gpumem_sync_cache_bulk) - -/* - * struct kgsl_cmd_syncpoint_timestamp - * @context_id: ID of a KGSL context - * @timestamp: GPU timestamp - * - * This structure defines a syncpoint comprising a context/timestamp pair. A - * list of these may be passed by IOCTL_KGSL_SUBMIT_COMMANDS to define - * dependencies that must be met before the command can be submitted to the - * hardware - */ -struct kgsl_cmd_syncpoint_timestamp { - unsigned int context_id; - unsigned int timestamp; -}; - -struct kgsl_cmd_syncpoint_fence { - int fd; -}; - -/* - * struct kgsl_cmd_syncpoint_timeline - * @timelines: Address of an array of &struct kgsl_timeline_val - * @count: Number of entries in @timelines - * @timelines_size: Size of each entry in @timelines - * - * Define a syncpoint for a number of timelines. This syncpoint will - * be satisfied when all of the specified timelines are signaled. - */ -struct kgsl_cmd_syncpoint_timeline { - __u64 timelines; - __u32 count; - __u32 timelines_size; -}; - -/** - * struct kgsl_cmd_syncpoint - Define a sync point for a command batch - * @type: type of sync point defined here - * @priv: Pointer to the type specific buffer - * @size: Size of the type specific buffer - * - * This structure contains pointers defining a specific command sync point. - * The pointer and size should point to a type appropriate structure. - */ -struct kgsl_cmd_syncpoint { - int type; - void __user *priv; - __kernel_size_t size; -}; - -/* Flag to indicate that the cmdlist may contain memlists */ -#define KGSL_IBDESC_MEMLIST 0x1 - -/* Flag to point out the cmdbatch profiling buffer in the memlist */ -#define KGSL_IBDESC_PROFILING_BUFFER 0x2 - -/** - * struct kgsl_submit_commands - Argument to IOCTL_KGSL_SUBMIT_COMMANDS - * @context_id: KGSL context ID that owns the commands - * @flags: - * @cmdlist: User pointer to a list of kgsl_ibdesc structures - * @numcmds: Number of commands listed in cmdlist - * @synclist: User pointer to a list of kgsl_cmd_syncpoint structures - * @numsyncs: Number of sync points listed in synclist - * @timestamp: On entry the a user defined timestamp, on exist the timestamp - * assigned to the command batch - * - * This structure specifies a command to send to the GPU hardware. This is - * similar to kgsl_issueibcmds expect that it doesn't support the legacy way to - * submit IB lists and it adds sync points to block the IB until the - * dependencies are satisified. This entry point is the new and preferred way - * to submit commands to the GPU. The memory list can be used to specify all - * memory that is referrenced in the current set of commands. - */ - -struct kgsl_submit_commands { - unsigned int context_id; - unsigned int flags; - struct kgsl_ibdesc __user *cmdlist; - unsigned int numcmds; - struct kgsl_cmd_syncpoint __user *synclist; - unsigned int numsyncs; - unsigned int timestamp; -/* private: reserved for future use */ - unsigned int __pad[4]; -}; - -#define IOCTL_KGSL_SUBMIT_COMMANDS \ - _IOWR(KGSL_IOC_TYPE, 0x3D, struct kgsl_submit_commands) - -/** - * struct kgsl_device_constraint - device constraint argument - * @context_id: KGSL context ID - * @type: type of constraint i.e pwrlevel/none - * @data: constraint data - * @size: size of the constraint data - */ -struct kgsl_device_constraint { - unsigned int type; - unsigned int context_id; - void __user *data; - __kernel_size_t size; -}; - -/* Constraint Type*/ -#define KGSL_CONSTRAINT_NONE 0 -#define KGSL_CONSTRAINT_PWRLEVEL 1 - -/* L3 constraint Type */ -#define KGSL_CONSTRAINT_L3_NONE 2 -#define KGSL_CONSTRAINT_L3_PWRLEVEL 3 - -/* PWRLEVEL constraint level*/ -/* set to min frequency */ -#define KGSL_CONSTRAINT_PWR_MIN 0 -/* set to max frequency */ -#define KGSL_CONSTRAINT_PWR_MAX 1 - -struct kgsl_device_constraint_pwrlevel { - unsigned int level; -}; - -/** - * struct kgsl_syncsource_create - Argument to IOCTL_KGSL_SYNCSOURCE_CREATE - * @id: returned id for the syncsource that was created. - * - * This ioctl creates a userspace sync timeline. - */ - -struct kgsl_syncsource_create { - unsigned int id; -/* private: reserved for future use */ - unsigned int __pad[3]; -}; - -#define IOCTL_KGSL_SYNCSOURCE_CREATE \ - _IOWR(KGSL_IOC_TYPE, 0x40, struct kgsl_syncsource_create) - -/** - * struct kgsl_syncsource_destroy - Argument to IOCTL_KGSL_SYNCSOURCE_DESTROY - * @id: syncsource id to destroy - * - * This ioctl creates a userspace sync timeline. - */ - -struct kgsl_syncsource_destroy { - unsigned int id; -/* private: reserved for future use */ - unsigned int __pad[3]; -}; - -#define IOCTL_KGSL_SYNCSOURCE_DESTROY \ - _IOWR(KGSL_IOC_TYPE, 0x41, struct kgsl_syncsource_destroy) - -/** - * struct kgsl_syncsource_create_fence - Argument to - * IOCTL_KGSL_SYNCSOURCE_CREATE_FENCE - * @id: syncsource id - * @fence_fd: returned sync_fence fd - * - * Create a fence that may be signaled by userspace by calling - * IOCTL_KGSL_SYNCSOURCE_SIGNAL_FENCE. There are no order dependencies between - * these fences. - */ -struct kgsl_syncsource_create_fence { - unsigned int id; - int fence_fd; -/* private: reserved for future use */ - unsigned int __pad[4]; -}; - -/** - * struct kgsl_syncsource_signal_fence - Argument to - * IOCTL_KGSL_SYNCSOURCE_SIGNAL_FENCE - * @id: syncsource id - * @fence_fd: sync_fence fd to signal - * - * Signal a fence that was created by a IOCTL_KGSL_SYNCSOURCE_CREATE_FENCE - * call using the same syncsource id. This allows a fence to be shared - * to other processes but only signaled by the process owning the fd - * used to create the fence. - */ -#define IOCTL_KGSL_SYNCSOURCE_CREATE_FENCE \ - _IOWR(KGSL_IOC_TYPE, 0x42, struct kgsl_syncsource_create_fence) - -struct kgsl_syncsource_signal_fence { - unsigned int id; - int fence_fd; -/* private: reserved for future use */ - unsigned int __pad[4]; -}; - -#define IOCTL_KGSL_SYNCSOURCE_SIGNAL_FENCE \ - _IOWR(KGSL_IOC_TYPE, 0x43, struct kgsl_syncsource_signal_fence) - -/** - * struct kgsl_cff_sync_gpuobj - Argument to IOCTL_KGSL_CFF_SYNC_GPUOBJ - * @offset: Offset into the GPU object to sync - * @length: Number of bytes to sync - * @id: ID of the GPU object to sync - */ -struct kgsl_cff_sync_gpuobj { - __u64 offset; - __u64 length; - unsigned int id; -}; - -#define IOCTL_KGSL_CFF_SYNC_GPUOBJ \ - _IOW(KGSL_IOC_TYPE, 0x44, struct kgsl_cff_sync_gpuobj) - -/** - * struct kgsl_gpuobj_alloc - Argument to IOCTL_KGSL_GPUOBJ_ALLOC - * @size: Size in bytes of the object to allocate - * @flags: mask of KGSL_MEMFLAG_* bits - * @va_len: Size in bytes of the virtual region to allocate - * @mmapsize: Returns the mmap() size of the object - * @id: Returns the GPU object ID of the new object - * @metadata_len: Length of the metdata to copy from the user - * @metadata: Pointer to the user specified metadata to store for the object - */ -struct kgsl_gpuobj_alloc { - __u64 size; - __u64 flags; - __u64 va_len; - __u64 mmapsize; - unsigned int id; - unsigned int metadata_len; - __u64 metadata; -}; - -/* Let the user know that this header supports the gpuobj metadata */ -#define KGSL_GPUOBJ_ALLOC_METADATA_MAX 64 - -#define IOCTL_KGSL_GPUOBJ_ALLOC \ - _IOWR(KGSL_IOC_TYPE, 0x45, struct kgsl_gpuobj_alloc) - -/** - * struct kgsl_gpuobj_free - Argument to IOCTL_KGLS_GPUOBJ_FREE - * @flags: Mask of: KGSL_GUPOBJ_FREE_ON_EVENT - * @priv: Pointer to the private object if KGSL_GPUOBJ_FREE_ON_EVENT is - * specified - * @id: ID of the GPU object to free - * @type: If KGSL_GPUOBJ_FREE_ON_EVENT is specified, the type of asynchronous - * event to free on - * @len: Length of the data passed in priv - */ -struct kgsl_gpuobj_free { - __u64 flags; - __u64 __user priv; - unsigned int id; - unsigned int type; - unsigned int len; -}; - -#define KGSL_GPUOBJ_FREE_ON_EVENT 1 - -#define KGSL_GPU_EVENT_TIMESTAMP 1 -#define KGSL_GPU_EVENT_FENCE 2 - -/** - * struct kgsl_gpu_event_timestamp - Specifies a timestamp event to free a GPU - * object on - * @context_id: ID of the timestamp event to wait for - * @timestamp: Timestamp of the timestamp event to wait for - */ -struct kgsl_gpu_event_timestamp { - unsigned int context_id; - unsigned int timestamp; -}; - -/** - * struct kgsl_gpu_event_fence - Specifies a fence ID to to free a GPU object on - * @fd: File descriptor for the fence - */ -struct kgsl_gpu_event_fence { - int fd; -}; - -#define IOCTL_KGSL_GPUOBJ_FREE \ - _IOW(KGSL_IOC_TYPE, 0x46, struct kgsl_gpuobj_free) - -/** - * struct kgsl_gpuobj_info - argument to IOCTL_KGSL_GPUOBJ_INFO - * @gpuaddr: GPU address of the object - * @flags: Current flags for the object - * @size: Size of the object - * @va_len: VA size of the object - * @va_addr: Virtual address of the object (if it is mapped) - * id - GPU object ID of the object to query - */ -struct kgsl_gpuobj_info { - __u64 gpuaddr; - __u64 flags; - __u64 size; - __u64 va_len; - __u64 va_addr; - unsigned int id; -}; - -#define IOCTL_KGSL_GPUOBJ_INFO \ - _IOWR(KGSL_IOC_TYPE, 0x47, struct kgsl_gpuobj_info) - - -/** - * struct kgsl_gpuobj_import - argument to IOCTL_KGSL_GPUOBJ_IMPORT - * @priv: Pointer to the private data for the import type - * @priv_len: Length of the private data - * @flags: Mask of KGSL_MEMFLAG_ flags - * @type: Type of the import (KGSL_USER_MEM_TYPE_*) - * @id: Returns the ID of the new GPU object - */ -struct kgsl_gpuobj_import { - __u64 __user priv; - __u64 priv_len; - __u64 flags; - unsigned int type; - unsigned int id; -}; - -/** - * struct kgsl_gpuobj_import_dma_buf - import a dmabuf object - * @fd: File descriptor for the dma-buf object - */ -struct kgsl_gpuobj_import_dma_buf { - int fd; -}; - -/** - * struct kgsl_gpuobj_import_useraddr - import an object based on a useraddr - * @virtaddr: Virtual address of the object to import - */ -struct kgsl_gpuobj_import_useraddr { - __u64 virtaddr; -}; - -#define IOCTL_KGSL_GPUOBJ_IMPORT \ - _IOWR(KGSL_IOC_TYPE, 0x48, struct kgsl_gpuobj_import) - -/** - * struct kgsl_gpuobj_sync_obj - Individual GPU object to sync - * @offset: Offset within the GPU object to sync - * @length: Number of bytes to sync - * @id: ID of the GPU object to sync - * @op: Cache operation to execute - */ - -struct kgsl_gpuobj_sync_obj { - __u64 offset; - __u64 length; - unsigned int id; - unsigned int op; -}; - -/** - * struct kgsl_gpuobj_sync - Argument for IOCTL_KGSL_GPUOBJ_SYNC - * @objs: Pointer to an array of kgsl_gpuobj_sync_obj structs - * @obj_len: Size of each item in the array - * @count: Number of items in the array - */ - -struct kgsl_gpuobj_sync { - __u64 __user objs; - unsigned int obj_len; - unsigned int count; -}; - -#define IOCTL_KGSL_GPUOBJ_SYNC \ - _IOW(KGSL_IOC_TYPE, 0x49, struct kgsl_gpuobj_sync) - -/** - * struct kgsl_command_object - GPU command object - * @offset: GPU address offset of the object - * @gpuaddr: GPU address of the object - * @size: Size of the object - * @flags: Current flags for the object - * @id - GPU command object ID - */ -struct kgsl_command_object { - __u64 offset; - __u64 gpuaddr; - __u64 size; - unsigned int flags; - unsigned int id; -}; - -/** - * struct kgsl_command_syncpoint - GPU syncpoint object - * @priv: Pointer to the type specific buffer - * @size: Size of the type specific buffer - * @type: type of sync point defined here - */ -struct kgsl_command_syncpoint { - __u64 __user priv; - __u64 size; - unsigned int type; -}; - -/** - * struct kgsl_command_object - Argument for IOCTL_KGSL_GPU_COMMAND - * @flags: Current flags for the object - * @cmdlist: List of kgsl_command_objects for submission - * @cmd_size: Size of kgsl_command_objects structure - * @numcmds: Number of kgsl_command_objects in command list - * @objlist: List of kgsl_command_objects for tracking - * @obj_size: Size of kgsl_command_objects structure - * @numobjs: Number of kgsl_command_objects in object list - * @synclist: List of kgsl_command_syncpoints - * @sync_size: Size of kgsl_command_syncpoint structure - * @numsyncs: Number of kgsl_command_syncpoints in syncpoint list - * @context_id: Context ID submittin ghte kgsl_gpu_command - * @timestamp: Timestamp for the submitted commands - */ -struct kgsl_gpu_command { - __u64 flags; - __u64 __user cmdlist; - unsigned int cmdsize; - unsigned int numcmds; - __u64 __user objlist; - unsigned int objsize; - unsigned int numobjs; - __u64 __user synclist; - unsigned int syncsize; - unsigned int numsyncs; - unsigned int context_id; - unsigned int timestamp; -}; - -#define IOCTL_KGSL_GPU_COMMAND \ - _IOWR(KGSL_IOC_TYPE, 0x4A, struct kgsl_gpu_command) - -/** - * struct kgsl_preemption_counters_query - argument to - * IOCTL_KGSL_PREEMPTIONCOUNTER_QUERY - * @counters: Return preemption counters array - * @size_user: Size allocated by userspace - * @size_priority_level: Size of preemption counters for each - * priority level - * @max_priority_level: Return max number of priority levels - * - * Query the available preemption counters. The array counters - * is used to return preemption counters. The size of the array - * is passed in so the kernel will only write at most size_user - * or max available preemption counters. The total number of - * preemption counters is returned in max_priority_level. If the - * array or size passed in are invalid, then an error is - * returned back. - */ -struct kgsl_preemption_counters_query { - __u64 __user counters; - unsigned int size_user; - unsigned int size_priority_level; - unsigned int max_priority_level; -}; - -#define IOCTL_KGSL_PREEMPTIONCOUNTER_QUERY \ - _IOWR(KGSL_IOC_TYPE, 0x4B, struct kgsl_preemption_counters_query) - -/** - * struct kgsl_gpuobj_set_info - argument for IOCTL_KGSL_GPUOBJ_SET_INFO - * @flags: Flags to indicate which parameters to change - * @metadata: If KGSL_GPUOBJ_SET_INFO_METADATA is set, a pointer to the new - * metadata - * @id: GPU memory object ID to change - * @metadata_len: If KGSL_GPUOBJ_SET_INFO_METADATA is set, the length of the - * new metadata string - * @type: If KGSL_GPUOBJ_SET_INFO_TYPE is set, the new type of the memory object - */ - -#define KGSL_GPUOBJ_SET_INFO_METADATA (1 << 0) -#define KGSL_GPUOBJ_SET_INFO_TYPE (1 << 1) - -struct kgsl_gpuobj_set_info { - __u64 flags; - __u64 metadata; - unsigned int id; - unsigned int metadata_len; - unsigned int type; -}; - -#define IOCTL_KGSL_GPUOBJ_SET_INFO \ - _IOW(KGSL_IOC_TYPE, 0x4C, struct kgsl_gpuobj_set_info) - -/** - * struct kgsl_sparse_phys_alloc - Argument for IOCTL_KGSL_SPARSE_PHYS_ALLOC - * @size: Size in bytes to back - * @pagesize: Pagesize alignment required - * @flags: Flags for this allocation - * @id: Returned ID for this allocation - */ -struct kgsl_sparse_phys_alloc { - __u64 size; - __u64 pagesize; - __u64 flags; - unsigned int id; -}; - -#define IOCTL_KGSL_SPARSE_PHYS_ALLOC \ - _IOWR(KGSL_IOC_TYPE, 0x50, struct kgsl_sparse_phys_alloc) - -/** - * struct kgsl_sparse_phys_free - Argument for IOCTL_KGSL_SPARSE_PHYS_FREE - * @id: ID to free - */ -struct kgsl_sparse_phys_free { - unsigned int id; -}; - -#define IOCTL_KGSL_SPARSE_PHYS_FREE \ - _IOW(KGSL_IOC_TYPE, 0x51, struct kgsl_sparse_phys_free) - -/** - * struct kgsl_sparse_virt_alloc - Argument for IOCTL_KGSL_SPARSE_VIRT_ALLOC - * @size: Size in bytes to reserve - * @pagesize: Pagesize alignment required - * @flags: Flags for this allocation - * @id: Returned ID for this allocation - * @gpuaddr: Returned GPU address for this allocation - */ -struct kgsl_sparse_virt_alloc { - __u64 size; - __u64 pagesize; - __u64 flags; - __u64 gpuaddr; - unsigned int id; -}; - -#define IOCTL_KGSL_SPARSE_VIRT_ALLOC \ - _IOWR(KGSL_IOC_TYPE, 0x52, struct kgsl_sparse_virt_alloc) - -/** - * struct kgsl_sparse_virt_free - Argument for IOCTL_KGSL_SPARSE_VIRT_FREE - * @id: ID to free - */ -struct kgsl_sparse_virt_free { - unsigned int id; -}; - -#define IOCTL_KGSL_SPARSE_VIRT_FREE \ - _IOW(KGSL_IOC_TYPE, 0x53, struct kgsl_sparse_virt_free) - -/** - * struct kgsl_sparse_binding_object - Argument for kgsl_sparse_bind - * @virtoffset: Offset into the virtual ID - * @physoffset: Offset into the physical ID (bind only) - * @size: Size in bytes to reserve - * @flags: Flags for this kgsl_sparse_binding_object - * @id: Physical ID to bind (bind only) - */ -struct kgsl_sparse_binding_object { - __u64 virtoffset; - __u64 physoffset; - __u64 size; - __u64 flags; - unsigned int id; -}; - -/** - * struct kgsl_sparse_bind - Argument for IOCTL_KGSL_SPARSE_BIND - * @list: List of kgsl_sparse_bind_objects to bind/unbind - * @id: Virtual ID to bind/unbind - * @size: Size of kgsl_sparse_bind_object - * @count: Number of elements in list - * - */ -struct kgsl_sparse_bind { - __u64 __user list; - unsigned int id; - unsigned int size; - unsigned int count; -}; - -#define IOCTL_KGSL_SPARSE_BIND \ - _IOW(KGSL_IOC_TYPE, 0x54, struct kgsl_sparse_bind) - -/** - * struct kgsl_gpu_sparse_command - Argument for - * IOCTL_KGSL_GPU_SPARSE_COMMAND - * @flags: Current flags for the object - * @sparselist: List of kgsl_sparse_binding_object to bind/unbind - * @synclist: List of kgsl_command_syncpoints - * @sparsesize: Size of kgsl_sparse_binding_object - * @numsparse: Number of elements in list - * @sync_size: Size of kgsl_command_syncpoint structure - * @numsyncs: Number of kgsl_command_syncpoints in syncpoint list - * @context_id: Context ID submitting the kgsl_gpu_command - * @timestamp: Timestamp for the submitted commands - * @id: Virtual ID to bind/unbind - */ -struct kgsl_gpu_sparse_command { - __u64 flags; - __u64 __user sparselist; - __u64 __user synclist; - unsigned int sparsesize; - unsigned int numsparse; - unsigned int syncsize; - unsigned int numsyncs; - unsigned int context_id; - unsigned int timestamp; - unsigned int id; -}; - -#define IOCTL_KGSL_GPU_SPARSE_COMMAND \ - _IOWR(KGSL_IOC_TYPE, 0x55, struct kgsl_gpu_sparse_command) - -#define KGSL_GPUMEM_RANGE_OP_BIND 1 -#define KGSL_GPUMEM_RANGE_OP_UNBIND 2 - -/** - * struct kgsl_gpumem_bind_range - specifies a bind operation for a virtual - * buffer object - * @child_offset: Offset to the start of memory within the child buffer object - * (not used for KGSL_GPUMEM_RANGE_OP_UNBIND operations) - * @target_offset: GPU address offset within the target VBO - * @length: Amount of memory to map/unmap (in bytes) - * @child_id: The GPU buffer ID for the child object to map/unmap in the VBO - * @op: One of KGSL_GPUMEM_RANGE_OP_BIND or KGSL_GPUMEM_RANGE_OP_UNBIND - * - * This defines a specific bind operation to a virtual buffer object specified - * in &struct kgsl_gpumem_bind_ranges. When @op is KGSL_GPUMEM_RANGE_OP_BIND the - * physical memory starting at @child_offset in the memory object identified by - * @child_id will be mapped into the target virtual buffer object starting at - * @offset for @length bytes. - * - * When @op is KGSL_GPUMEM_RANGE_OP_UNBIND any entries in the target virtual - * buffer object between @offset and @length that belong to @child_id will be - * removed. - */ -struct kgsl_gpumem_bind_range { - __u64 child_offset; - __u64 target_offset; - __u64 length; - __u32 child_id; - __u32 op; -}; - -#define KGSL_GPUMEM_BIND_ASYNC (1UL << 0) -#define KGSL_GPUMEM_BIND_FENCE_OUT (1UL << 1) - -/** - * struct kgsl_gpumem_bind_ranges - Argument to IOCTL_KGSL_GPUMEM_BIND_RANGES to - * either map or unmap a child buffer object into a virtual buffer object. - * @ranges: User memory pointer to an array of range operations of type &struct - * kgsl_gpumem_bind_range - * @ranges_nents: Number of entries in @ranges - * @ranges_size: Size of each entry in @ranges in bytes - * @id: GPU buffer object identifier for the target virtual buffer object - * @flags: Bitmap of KGSL_GPUMEM_BIND_ASYNC and KGSL_GPUMEM_BIND_FENCE_OUT - * @fence_id: If KGSL_GPUMEM_BIND_FENCE_OUT is set in @flags contains the - * identifier for the sync fence that will be signaled after the operation - * completes - * - * Describes a number of range operations to perform on a virtual buffer object - * identified by @id. Ranges should be a __u64 representation of an array of - * &struct kgsl_gpumem_bind_range entries. @ranges_nents will contain the number - * of entries in the array, and @ranges_size will contain the size of each entry - * in the array. If KGSL_GPUMEM_BIND_ASYNC is set the operation will be - * performed asynchronously and the operation will immediately return to the - * user. Otherwise the calling context will block until the operation has - * completed. - * - * If KGSL_GPUMEM_BIND_ASYNC and KGSL_GPUMEM_BIND_FENCE_OUT are both set a sync - * fence will be created and returned in @fence_id. The fence will be signaled - * when the bind operation has completed. - */ -struct kgsl_gpumem_bind_ranges { - __u64 ranges; - __u32 ranges_nents; - __u32 ranges_size; - __u32 id; - __u32 flags; - int fence_id; - /* private: 64 bit compatibility */ - __u32 padding; -}; - -#define IOCTL_KGSL_GPUMEM_BIND_RANGES \ - _IOWR(KGSL_IOC_TYPE, 0x56, struct kgsl_gpumem_bind_ranges) - -#define KGSL_GPU_AUX_COMMAND_BIND (1 << 0) -#define KGSL_GPU_AUX_COMMAND_TIMELINE (1 << 1) -/* Reuse the same flag that GPU COMMAND uses */ -#define KGSL_GPU_AUX_COMMAND_SYNC KGSL_CMDBATCH_SYNC - -/** - * struct kgsl_gpu_aux_command_bind - Descriptor for a GPU AUX bind command - * @rangeslist: Pointer to a list of &struct kgsl_gpumem_bind_range items - * @numranges Number of entries in @rangeslist - * @rangesize: Size of each entry in @rangeslist - * @target: The GPU memory ID for the target virtual buffer object - * - * Describe a GPU AUX command to bind ranges in a virtual buffer object. - * @rangeslist points to a &struct kgsl_gpumem_bind_ranges which is the same - * struct that is used by IOCTl_KGSL_GPUMEM_BIND_RANGES. @numrages is the size - * of the array in @rangeslist and @rangesize is the size of each entity in - * @rangeslist. @target points to the GPU ID for the target VBO object. - */ -struct kgsl_gpu_aux_command_bind { - __u64 rangeslist; - __u64 numranges; - __u64 rangesize; - __u32 target; -/* private: Padding for 64 bit compatibility */ - __u32 padding; -}; - -/** - * struct kgsl_aux_command_generic - Container for an AUX command - * @priv: Pointer to the type specific buffer - * @size: Size of the type specific buffer - * @type: type of sync point defined here - * - * Describes a generic container for GPU aux commands. @priv is a user pointer - * to the command struct matching @type of size @size. - */ -struct kgsl_gpu_aux_command_generic { - __u64 priv; - __u64 size; - __u32 type; -/* private: Padding for 64 bit compatibility */ - __u32 padding; -}; - -/** - * struct kgsl_gpu_aux_command - Argument for IOCTL_KGSL_GPU_AUX_COMMAND - * @flags: flags for the object - * @cmdlist: List of &struct kgsl_gpu_aux_command_generic objects - * @cmd_size: Size of each entry in @cmdlist - * @numcmds: Number of entries in @cmdlist - * @synclist: List of &struct kgsl_command_syncpoint objects - * @syncsize: Size of each entry in @synclist - * @numsyncs: Number of entries in @synclist - * @context_id: ID of the context submtting the aux command - * @timestamp: Timestamp for the command submission - * - * Describe a GPU auxiliary command. Auxiliary commands are tasks that are not - * performed on hardware but can be queued like normal GPU commands. Like GPU - * commands AUX commands are assigned a timestamp and processed in order in the - * queue. They can also have standard sync objects attached. The only - * difference is that AUX commands usually perform some sort of administrative - * task in the CPU and are retired in the dispatcher. - * - * For bind operations flags must have one of the KGSL_GPU_AUX_COMMAND_* flags - * set. If sync objects are attached KGSL_GPU_AUX_COMMAND_SYNC must be set. - * @cmdlist points to an array of &struct kgsl_gpu_aux_command_generic structs - * which in turn will have a pointer to a specific command type. - * @numcmds is the number of commands in the list and @cmdsize is the size - * of each entity in @cmdlist. - * - * If KGSL_GPU_AUX_COMMAND_SYNC is specified @synclist will point to an array of - * &struct kgsl_command_syncpoint items in the same fashion as a GPU hardware - * command. @numsyncs and @syncsize describe the list. - * - * @context_id is the context that is submitting the command and @timestamp - * contains the timestamp for the operation. - */ -struct kgsl_gpu_aux_command { - __u64 flags; - __u64 cmdlist; - __u32 cmdsize; - __u32 numcmds; - __u64 synclist; - __u32 syncsize; - __u32 numsyncs; - __u32 context_id; - __u32 timestamp; -}; - -#define IOCTL_KGSL_GPU_AUX_COMMAND \ - _IOWR(KGSL_IOC_TYPE, 0x57, struct kgsl_gpu_aux_command) - -/** - * struct kgsl_timeline_create - Argument for IOCTL_KGSL_TIMELINE_CREATE - * @seqno: Initial sequence number for the timeline - * @id: Timeline identifier [out] - * - * Create a new semaphore timeline and return the identifier in @id. - * The identifier is global for the device and can be used to - * identify the timeline in all subsequent commands. - */ -struct kgsl_timeline_create { - __u64 seqno; - __u32 id; -/* private: padding for 64 bit compatibility */ - __u32 padding; -}; - -#define IOCTL_KGSL_TIMELINE_CREATE \ - _IOWR(KGSL_IOC_TYPE, 0x58, struct kgsl_timeline_create) - -/** - * struct kgsl_timeline_val - A container to store a timeline/sequence number - * pair. - * @seqno: Sequence number to signal/query - * @timeline: The timeline identifier to signal/query - * - * A container to store a timeline/seqno pair used by the query and signal - * ioctls. - */ -struct kgsl_timeline_val { - __u64 seqno; - __u32 timeline; -/* private: padding for 64 bit compatibility */ - __u32 padding; -}; - -#define KGSL_TIMELINE_WAIT_ALL 1 -#define KGSL_TIMELINE_WAIT_ANY 2 - -/** - * struct kgsl_timeline_wait - Argument for IOCTL_KGSL_TIMELINE_WAIT - * @tv_sec: Number of seconds to wait for the signal - * @tv_nsec: Number of nanoseconds to wait for the signal - * @timelines: Address of an array of &struct kgsl_timeline_val entries - * @count: Number of entries in @timeline - * @timelines_size: Size of each entry in @timelines - * @flags: One of KGSL_TIMELINE_WAIT_ALL or KGSL_TIMELINE_WAIT_ANY - * - * Wait for the timelines listed in @timelines to be signaled. If @flags is - * equal to KGSL_TIMELINE_WAIT_ALL then wait for all timelines or if - * KGSL_TIMELINE_WAIT_ANY is specified then wait for any of the timelines to - * signal. @tv_sec and @tv_nsec indicates the number of seconds and nanoseconds - * that the process should be blocked waiting for the signal. - */ -struct kgsl_timeline_wait { - __s64 tv_sec; - __s64 tv_nsec; - __u64 timelines; - __u32 count; - __u32 timelines_size; - __u32 flags; -/* private: padding for 64 bit compatibility */ - __u32 padding; -}; - -#define IOCTL_KGSL_TIMELINE_WAIT \ - _IOW(KGSL_IOC_TYPE, 0x59, struct kgsl_timeline_wait) - -#define IOCTL_KGSL_TIMELINE_QUERY \ - _IOWR(KGSL_IOC_TYPE, 0x5A, struct kgsl_timeline_val) - -/** - * struct kgsl_timeline_signal - argument for IOCTL_KGSL_TIMELINE_SIGNAL - * @timelines: Address of an array of &struct kgsl_timeline_val entries - * @count: Number of entries in @timelines - * @timelines_size: Size of each entry in @timelines - * - * Signal an array of timelines of type @struct kgsl_timeline_val. - */ -struct kgsl_timeline_signal { - __u64 timelines; - __u32 count; - __u32 timelines_size; -}; - -#define IOCTL_KGSL_TIMELINE_SIGNAL \ - _IOW(KGSL_IOC_TYPE, 0x5B, struct kgsl_timeline_signal) - -/** - * struct kgsl_timeline_fence_get - argument for IOCTL_KGSL_TIMELINE_FENCE_GET - * @seqno: Sequence number for the fence - * @timeline: Timeline to create the fence on - * @handle: Contains the fence fd for a successful operation [out] - * - * Create a sync file descriptor for the seqnum on the timeline and return it in - * @handle. Can be polled and queried just like any other sync file descriptor - */ -struct kgsl_timeline_fence_get { - __u64 seqno; - __u32 timeline; - int handle; -}; - -#define IOCTL_KGSL_TIMELINE_FENCE_GET \ - _IOWR(KGSL_IOC_TYPE, 0x5C, struct kgsl_timeline_fence_get) -/** - * IOCTL_KGSL_TIMELINE_DESTROY takes a u32 identifier for the timeline to - * destroy - */ -#define IOCTL_KGSL_TIMELINE_DESTROY _IOW(KGSL_IOC_TYPE, 0x5D, __u32) - -/** - * struct kgsl_gpu_aux_command_timeline - An aux command for timeline signals - * @timelines: An array of &struct kgsl_timeline_val elements - * @count: The number of entries in @timelines - * @timelines_size: The size of each element in @timelines - * - * An aux command for timeline signals that can be pointed to by - * &struct kgsl_aux_command_generic when the type is - * KGSL_GPU_AUX_COMMAND_TIMELINE. - */ -struct kgsl_gpu_aux_command_timeline { - __u64 timelines; - __u32 count; - __u32 timelines_size; -}; - -/* Macros for fault type used in kgsl_fault structure */ -#define KGSL_FAULT_TYPE_NO_FAULT 0 -#define KGSL_FAULT_TYPE_PAGEFAULT 1 -#define KGSL_FAULT_TYPE_MAX 2 - -/* Macros to be used in kgsl_pagefault_report structure */ -#define KGSL_PAGEFAULT_TYPE_NONE 0 -#define KGSL_PAGEFAULT_TYPE_READ (1 << 0) -#define KGSL_PAGEFAULT_TYPE_WRITE (1 << 1) -#define KGSL_PAGEFAULT_TYPE_TRANSLATION (1 << 2) -#define KGSL_PAGEFAULT_TYPE_PERMISSION (1 << 3) -#define KGSL_PAGEFAULT_TYPE_EXTERNAL (1 << 4) -#define KGSL_PAGEFAULT_TYPE_TRANSACTION_STALLED (1 << 5) - -/** - * struct kgsl_pagefault_report - Descriptor for each page fault - * @fault_addr: page fault address - * @fault_type: type of page fault - * - * Contains information about supported GPU page fault. - * Supported fault type: KGSL_PAGEFAULT_TYPE_* - */ -struct kgsl_pagefault_report { - __u64 fault_addr; - /* private: reserved for future use */ - __u64 reserved[2]; - __u32 fault_type; - /* private: padding for 64 bit compatibility */ - __u32 __pad; -}; - -/** - * struct kgsl_fault - Descriptor for each GPU fault type - * @fault: User memory pointer to list of specific fault type - * @type: Type of gpu fault - * @count: Number of entries in @fault - * @size: Size of each entry in @fault in bytes - * - * Contains information about each GPU fault type. If user passes 0 for all the fields, KGSL - * will return the @count and @type of fault. Based on this, user can allocate a buffer for - * specific fault type, fill the @fault and specify the structure size of type specific fault - * in @size. User can walk through @fault list to parse the fault type specific information. - * - * Supported type: KGSL_FAULT_TYPE_* - */ -struct kgsl_fault { - __u64 fault; - __u32 type; - __u32 count; - __u32 size; - /* private: padding for 64 bit compatibility */ - __u32 padding; -}; - -/** - * struct kgsl_fault_report - Container for list of GPU faults - * @faultlist: User memory pointer to list of fault descriptor &struct kgsl_fault - * @faultnents: Number of entries in @faultlist. Each entry corresponds to a fault type i.e. - * KGSL_FAULT_TYPE_* - * @faultsize: Size of each entry in @faultlist in bytes - * @context_id: ID of a KGSL context - * - * Returns a list of GPU faults for a context identified by @context_id. If the user specifies - * @context_id only, then KGSL will set the @faultnents to the number of fault types it has - * for that context. - * - * User is expected to allocate an array of @struct kgsl_fault with @faultnents number of entries - * and fill the @faultlist field. On calling @IOCTL_KGSL_GET_FAULT_REPORT, KGSL will return the - * type and count for each fault. Based on this, user needs to update the @kgsl_fault structure. - * Then, it should call the @IOCTL_KGSL_GET_FAULT_REPORT again for kernel to fill the fault - * information. - */ -struct kgsl_fault_report { - __u64 faultlist; - __u32 faultnents; - __u32 faultsize; - __u32 context_id; - /* private: padding for 64 bit compatibility */ - __u32 padding; -}; - -#define IOCTL_KGSL_GET_FAULT_REPORT \ - _IOWR(KGSL_IOC_TYPE, 0x5E, struct kgsl_fault_report) - -/** - * struct kgsl_recurring_object - Argument for IOCTL_KGSL_RECURRING_COMMAND - * @flags: Current flags for the object - * @cmdlist: List of kgsl_command_objects for submission - * @cmd_size: Size of kgsl_command_objects structure - * @numcmds: Number of kgsl_command_objects in command list - * @objlist: List of kgsl_command_objects for tracking - * @obj_size: Size of kgsl_command_objects structure - * @numobjs: Number of kgsl_command_objects in object list - * @context_id: Context ID submitting the kgsl_recurring_command - */ -struct kgsl_recurring_command { - __u64 flags; - __u64 __user cmdlist; - __u32 cmdsize; - __u32 numcmds; - __u64 __user objlist; - __u32 objsize; - __u32 numobjs; - __u32 context_id; - /* private: Padding for 64 bit compatibility */ - __u32 padding; -}; - -#define IOCTL_KGSL_RECURRING_COMMAND \ - _IOWR(KGSL_IOC_TYPE, 0x5F, struct kgsl_recurring_command) - -#endif /* _UAPI_MSM_KGSL_H */ \ No newline at end of file diff --git a/externals/libadrenotools/src/hook/main_hook.c b/externals/libadrenotools/src/hook/main_hook.c deleted file mode 100644 index 067537f324..0000000000 --- a/externals/libadrenotools/src/hook/main_hook.c +++ /dev/null @@ -1,9 +0,0 @@ -#include "hook_impl.h" - -__attribute__((visibility("default"))) void *android_dlopen_ext(const char *filename, int flags, const android_dlextinfo *extinfo) { - return hook_android_dlopen_ext(filename, flags, extinfo); -} - -__attribute__((visibility("default"))) void *android_load_sphal_library(const char *filename, int flags) { - return hook_android_load_sphal_library(filename, flags); -} \ No newline at end of file diff --git a/externals/libadrenotools/tools/ADPKG.md b/externals/libadrenotools/tools/ADPKG.md deleted file mode 100644 index ad18f0b663..0000000000 --- a/externals/libadrenotools/tools/ADPKG.md +++ /dev/null @@ -1,96 +0,0 @@ -# Android Driver Package Format - -## Contents -- `meta.json` that follows `Schema` -- `.so` main driver shared library -- `*.so` all libraries depended on by the main driver library, these must have their sonames altered if they wish to replace the system version of the library - -## Example -- `meta.json`: -```json -{ - "schemaVersion": 1, - "name": "Qualcomm v615 Vulkan driver", - "description": "Proprietary Vulkan driver for Adreno 6xx and Adreno 7xx", - "author": "ByLaws", - "packageVersion": "2", - "vendor": "Qualcomm", - "driverVersion": "0.615.0", - "minApi": 27, - "libraryName": "vulkan.ad0615.so" -} -``` - -- `vulkan.ad0615.so`: main patched driver -- `notadreno_utils.so`, `notdmabufheap.so`, `notgsl.so`, `notllvm-glnext.so`, `notllvm-qgl.so`: patched-soname versions of libraries specific to each driver version -- `android.hardware.graphics.mappershim.so`, `vendor.qti.hardware.display.mapperextensionsshim.so`, `vendor.qti.hardware.display.mappershim.so`: qtimapper-shim libs - -## Creation -I recommend running blob-patcher.py to patch a set of blobs from a device dump with mapper ver as 5, then copying in the qtimapper-shim files from the adrenotools releases page. -```bash -$ mkdir outpkg -$ patch.py outpkg vulkan.adreno.so vulkan.ad0615.so 1 -$ vim outpkg/meta.json -$ cp qtimapper-shim-rel/* outpkg -``` - -## Schema -```json -{ - "$schema": "https://json-schema.org/draft/2020-12/schema", - "title": "ADPKG Schema", - "type": "object", - "properties": { - "schemaVersion": { - "type": "number", - "example": 1 - }, - "name": { - "type": "string", - "example": "Qualcomm Adreno Driver" - }, - "vendor": { - "enum": [ - "Qualcomm", - "Mesa" - ], - }, - "driverVersion": { - "type": "string", - "pattern": "^[0-9]+.[0-9]+.[0-9]+(-.+)?$", - "example": "512.604.0" - }, - "author": { - "type": "string", - "example": "Billy Laws" - }, - "description": { - "type": "string", - "description": "Additional description of the driver, this shouldn't contain redundant information that is already covered by the other fields such as the version and only denote details important for the user" - }, - "packageVersion": { - "type": "string", - "example": "3029-bylaws" - }, - "minApi": { - "type": "number", - "description": "The minimum Android API version required by the driver to function correctly", - "example": 27 - }, - "libraryName": { - "type": "string", - "description": "The name of the main shared library object", - "example": "vulkan.adreno.so" - }, - }, - "required": [ - "schemaVersion", - "name", - "author", - "packageVersion", - "vendor", - "driverVersion", - "minApi", - ] -} -``` diff --git a/externals/libadrenotools/tools/README.md b/externals/libadrenotools/tools/README.md deleted file mode 100644 index 5c0be8d36d..0000000000 --- a/externals/libadrenotools/tools/README.md +++ /dev/null @@ -1,7 +0,0 @@ -## 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 -acc-shim allows for suppling arguments to the underlying LLVM-based shader compiler library - - diff --git a/externals/libadrenotools/tools/acc-shim/README.md b/externals/libadrenotools/tools/acc-shim/README.md deleted file mode 100644 index ac9d7f2f15..0000000000 --- a/externals/libadrenotools/tools/acc-shim/README.md +++ /dev/null @@ -1,12 +0,0 @@ -## Adreno Compiler Collection parameter shim - -### TODO -Make some sort of API for this so parameters can be changed through adrenotools in realtime. - -### Compilation -``` -$ sed -i 's/libllvm-glnext/notreal-glnext/g' libllvm-glnext.so -$ mv libllvm-glnext.so notreal-glnext.so -$ aarch64-linux-android28-clang vk_acc_shim.cpp -o notllvm-glnext.so --shared -fpic -$ sed -i 's/libllvm-glnext/notllvm-glnext/g' vulkan.adreno.so -``` diff --git a/externals/libadrenotools/tools/acc-shim/vk_acc_shim.cpp b/externals/libadrenotools/tools/acc-shim/vk_acc_shim.cpp deleted file mode 100644 index 2bccb05347..0000000000 --- a/externals/libadrenotools/tools/acc-shim/vk_acc_shim.cpp +++ /dev/null @@ -1,108 +0,0 @@ -#include -#include -#include -#include - -thread_local int satisfy_driver_emutls; - -// Check libllvm-glnext.so in older drivers for a full list of these, newer ones are slightly more awkward due to the split -enum class OptionType : uint32_t { - ArgsStringList = 1, - QcArgsString = 4, - OptLevelInt = 0x101, - NoOptsInt = 0x10D, -}; - -struct StringListVal { - uint32_t len; - const char **entry; -}; - -struct Option -{ - OptionType type; - // PAD - union { - bool boolVal; - int intVal; - float floatVal; - StringListVal *strVals; - const char *strVal; - }; -}; - - -struct OptionsSet -{ - Option *options; - uint32_t num; -}; - - -int CompileHook(void *state, OptionsSet *opts); - -decltype(CompileHook) *OrigCompile{}; - -int CompileHook(void *state, OptionsSet *opts) { - constexpr size_t ReplacementOptsNum = 201; - - Option replacementOpts[ReplacementOptsNum]; - uint32_t patchedOptNum{}; - - // Insert your desired args here - results will be written to stderr - const char *argv[] = {"-help", "-help-hidden", "", NULL }; - StringListVal listVal{ - .len = 3, - .entry = argv, - }; - - replacementOpts[patchedOptNum++] = { - .type = OptionType::ArgsStringList, - .strVals = &listVal - }; - - const char *opt ="Verbose=true Quiet=false"; - replacementOpts[patchedOptNum++] = { - .type = OptionType::QcArgsString, - .strVal = opt - }; - - if (opts->num + patchedOptNum > ReplacementOptsNum) - __builtin_trap(); - - memcpy(&replacementOpts[patchedOptNum], opts->options, sizeof(Option) * opts->num); - - OptionsSet optList{ - .options = replacementOpts, - .num = opts->num + patchedOptNum - }; - - return OrigCompile(state, &optList); -} - - -struct LlvmInterface { - uint32_t unk0[3]; - // PAD - void *makeContext; - void *delContext; - decltype(CompileHook) *compile; - void *unk; -}; - -extern "C" int LoadACC(LlvmInterface *impl); - -extern "C" __attribute__((visibility("default"))) int LoadACC(LlvmInterface *impl) { - void *hnd = dlopen("notreal-glnext.so", RTLD_NOW); - - auto origLoadACC = reinterpret_cast(dlsym(hnd, "LoadACC")); - if (!origLoadACC) - __builtin_trap(); - - int ret = origLoadACC(impl); - - OrigCompile = impl->compile; - impl->compile = &CompileHook; - - return ret; -} diff --git a/externals/libadrenotools/tools/blob-patcher.py b/externals/libadrenotools/tools/blob-patcher.py deleted file mode 100755 index 2464d7f234..0000000000 --- a/externals/libadrenotools/tools/blob-patcher.py +++ /dev/null @@ -1,67 +0,0 @@ -#!/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, shim_mapper): - try: - os.mkdir(out_dir) - os.mkdir(out_dir + "/hw") - 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 (shim_mapper < 2): - replacement_list += [("vendor.qti.hardware.display.mapper@2.0.so", "vendor.qti.hardware.display.mappershim.so"), - ("android.hardware.graphics.mapper@2.0.so", "android.hardware.graphics.mappershim.so"), - ("vendor.qti.hardware.display.mapperextensions@1.0.so", "vendor.qti.hardware.display.mapperextensionsshim.so"), - ("vendor.qti.hardware.display.mapperextensions@1.1.so", "vendor.qti.hardware.display.mapperextensionsshim.so")] - if (shim_mapper < 3): - replacement_list += [("vendor.qti.hardware.display.mapper@3.0.so", "vendor.qti.hardware.display.mappershim.so"), - ("android.hardware.graphics.mapper@3.0.so", "android.hardware.graphics.mappershim.so")] - if (shim_mapper < 4): - replacement_list += [("vendor.qti.hardware.display.mapper@4.0.so", "vendor.qti.hardware.display.mappershim.so"), - ("android.hardware.graphics.mapper@4.0.so", "android.hardware.graphics.mappershim.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 + "/hw/", replacement_list, vulkan_libname, vulkan_newname) - -if (len(sys.argv)!= 6): - print(" ") - sys.exit() - - - -root_path = sys.argv[1] -out_path = sys.argv[2] -vulkan_libname = sys.argv[3] -vulkan_newname = sys.argv[4] -shim_mapper = int(sys.argv[5]) -vendor_path = root_path + "/vendor/" - -if (len(vulkan_newname) != len(vulkan_libname)): - print("Errror") - sys.exit() - -for libdir in ["/lib64/", "/lib/"]: - patch_references(vendor_path + libdir, out_path + libdir, vulkan_libname, vulkan_newname, shim_mapper) -print("done!") - diff --git a/externals/libadrenotools/tools/qtimapper-shim/.clang-format b/externals/libadrenotools/tools/qtimapper-shim/.clang-format deleted file mode 100644 index ede5d7e18b..0000000000 --- a/externals/libadrenotools/tools/qtimapper-shim/.clang-format +++ /dev/null @@ -1,9 +0,0 @@ -BasedOnStyle: Google -AllowShortFunctionsOnASingleLine: Inline -ColumnLimit: 100 -CommentPragmas: NOLINT:.* -DerivePointerAlignment: false -IndentWidth: 2 -PointerAlignment: Left -TabWidth: 2 -UseTab: Never diff --git a/externals/libadrenotools/tools/qtimapper-shim/Android.bp b/externals/libadrenotools/tools/qtimapper-shim/Android.bp deleted file mode 100644 index bc4a66bee0..0000000000 --- a/externals/libadrenotools/tools/qtimapper-shim/Android.bp +++ /dev/null @@ -1,37 +0,0 @@ -cc_defaults { - name: "shim_defaults", - - srcs: [ - "shim.cpp", - "ext/gr_utils.cpp", - "ext/gr_adreno_info.cpp", - ], - - shared_libs: [ - "liblog", - "libcutils", - "libhidlbase", - "libhardware", - "libutils", - ], - - cflags: [ - "-Wno-error", - "-Wno-unused-parameter", - ], -} - -cc_library_shared { - name: "vendor.qti.hardware.display.mappershim", - defaults: ["shim_defaults"], -} - -cc_library_shared { - name: "vendor.qti.hardware.display.mapperextensionsshim", - defaults: ["shim_defaults"], -} - -cc_library_shared { - name: "android.hardware.graphics.mappershim", - defaults: ["shim_defaults"], -} diff --git a/externals/libadrenotools/tools/qtimapper-shim/README.md b/externals/libadrenotools/tools/qtimapper-shim/README.md deleted file mode 100644 index 6e2489396e..0000000000 --- a/externals/libadrenotools/tools/qtimapper-shim/README.md +++ /dev/null @@ -1,19 +0,0 @@ -## 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.mappershim -make vendor.qti.hardware.display.mapperextensionsshim -make android.hardware.graphics.mappershim -``` -and grab SOs out of outputs dir diff --git a/externals/libadrenotools/tools/qtimapper-shim/ext/QtiGrallocDefs.h b/externals/libadrenotools/tools/qtimapper-shim/ext/QtiGrallocDefs.h deleted file mode 100644 index e0ccbe1d25..0000000000 --- a/externals/libadrenotools/tools/qtimapper-shim/ext/QtiGrallocDefs.h +++ /dev/null @@ -1,173 +0,0 @@ -/* - * Copyright (c) 2020-2021 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. - */ - -#ifndef __QTIGRALLOCDEFS_H__ -#define __QTIGRALLOCDEFS_H__ - -// From gralloc_priv.h - -/* Gralloc usage bits indicating the type of allocation that should be used */ -/* Refer to BufferUsage in hardware/interfaces/graphics/common//types.hal */ - -/* The bits below are in officially defined vendor space - * i.e bits 28-31 and 48-63*/ -/* Non linear, Universal Bandwidth Compression */ -#define GRALLOC_USAGE_PRIVATE_ALLOC_UBWC (UINT32_C(1) << 28) - -/* Set this for allocating uncached memory (using O_DSYNC), - * cannot be used with noncontiguous heaps */ -#define GRALLOC_USAGE_PRIVATE_UNCACHED (UINT32_C(1) << 29) - -/* This flag is used to indicate 10 bit format. - * When both GRALLOC_USAGE_PRIVATE_ALLOC_UBWC & GRALLOC_USAGE_PRIVATE_10BIT - * are set then it will indicate UBWC_TP10 format. - * When only GRALLOC_USAGE_PRIVATE_10BIT is set it will indicate linear P010 format. - */ -#define GRALLOC_USAGE_PRIVATE_10BIT (UINT32_C(1) << 30) - -/* This flag is used for SECURE display usecase */ -#define GRALLOC_USAGE_PRIVATE_SECURE_DISPLAY (UINT32_C(1) << 31) - -/* This flag is used to indicate video NV21 format */ -#define GRALLOC_USAGE_PRIVATE_VIDEO_NV21_ENCODER 1ULL << 48 - -/* unused legacy flags */ -#define GRALLOC_USAGE_PRIVATE_MM_HEAP 0 -#define GRALLOC_USAGE_PRIVATE_IOMMU_HEAP 0 - -/* This flag is set for WFD usecase */ -#define GRALLOC_USAGE_PRIVATE_WFD 1ULL << 51 - -/* This flag is set for HEIF usecase */ -#define GRALLOC_USAGE_PRIVATE_HEIF (UINT32_C(1) << 27) - -/* TODO(user): Remove when clients stop referencing this flag */ -#define GRALLOC_USAGE_PRIVATE_10BIT_TP 0 - -/* This flag indicates PI format is being used */ -#define GRALLOC_USAGE_PRIVATE_ALLOC_UBWC_PI 1ULL << 49 - -/* This flag is set while CDSP accesses the buffer */ -#define GRALLOC_USAGE_PRIVATE_CDSP 1ULL << 50 - -// OEM specific HAL formats -#define HAL_PIXEL_FORMAT_RGBA_5551 6 -#define HAL_PIXEL_FORMAT_RGBA_4444 7 -#define HAL_PIXEL_FORMAT_NV12_ENCODEABLE 0x102 -#define HAL_PIXEL_FORMAT_NV21_ENCODEABLE 0x7FA30C00 -#define HAL_PIXEL_FORMAT_YCbCr_420_SP_VENUS 0x7FA30C04 -#define HAL_PIXEL_FORMAT_YCbCr_420_SP_TILED 0x7FA30C03 -#define HAL_PIXEL_FORMAT_YCbCr_420_SP 0x109 -#define HAL_PIXEL_FORMAT_YCrCb_420_SP_ADRENO 0x7FA30C01 -#define HAL_PIXEL_FORMAT_YCrCb_422_SP 0x10B -#define HAL_PIXEL_FORMAT_R_8 0x10D -#define HAL_PIXEL_FORMAT_RG_88 0x10E -#define HAL_PIXEL_FORMAT_YCbCr_444_SP 0x10F -#define HAL_PIXEL_FORMAT_YCrCb_444_SP 0x110 -#define HAL_PIXEL_FORMAT_YCrCb_422_I 0x111 -#define HAL_PIXEL_FORMAT_BGRX_8888 0x112 -#define HAL_PIXEL_FORMAT_NV21_ZSL 0x113 -#define HAL_PIXEL_FORMAT_YCrCb_420_SP_VENUS 0x114 -#define HAL_PIXEL_FORMAT_BGR_565 0x115 -#define HAL_PIXEL_FORMAT_RAW8 0x123 -#define HAL_PIXEL_FORMAT_NV12_HEIF 0x116 - -// 10 bit -#define HAL_PIXEL_FORMAT_ARGB_2101010 0x117 -#define HAL_PIXEL_FORMAT_RGBX_1010102 0x118 -#define HAL_PIXEL_FORMAT_XRGB_2101010 0x119 -#define HAL_PIXEL_FORMAT_BGRA_1010102 0x11A -#define HAL_PIXEL_FORMAT_ABGR_2101010 0x11B -#define HAL_PIXEL_FORMAT_BGRX_1010102 0x11C -#define HAL_PIXEL_FORMAT_XBGR_2101010 0x11D -#define HAL_PIXEL_FORMAT_YCbCr_420_P010 0x36 // HAL_PIXEL_FORMAT_YCBCR_P010 -#define HAL_PIXEL_FORMAT_YCbCr_420_P010_UBWC 0x124 -#define HAL_PIXEL_FORMAT_YCbCr_420_P010_VENUS 0x7FA30C0A - -#define HAL_PIXEL_FORMAT_CbYCrY_422_I 0x120 -#define HAL_PIXEL_FORMAT_BGR_888 0x121 - -#define HAL_PIXEL_FORMAT_INTERLACE 0x180 - -// Camera utils format -#define HAL_PIXEL_FORMAT_NV12_LINEAR_FLEX 0x125 -#define HAL_PIXEL_FORMAT_NV12_UBWC_FLEX 0x126 -#define HAL_PIXEL_FORMAT_MULTIPLANAR_FLEX 0x127 -#define HAL_PIXEL_FORMAT_NV12_UBWC_FLEX_2_BATCH 0x128 -#define HAL_PIXEL_FORMAT_NV12_UBWC_FLEX_4_BATCH 0x129 -#define HAL_PIXEL_FORMAT_NV12_UBWC_FLEX_8_BATCH 0x130 - -// FSC Formats -#define HAL_PIXEL_FORMAT_RGB888_UBWC_FSC 0x131 -#define HAL_PIXEL_FORMAT_RGB101010_UBWC_FSC 0x132 - -// v4l2_fourcc('Y', 'U', 'Y', 'L'). 24 bpp YUYV 4:2:2 10 bit per component -#define HAL_PIXEL_FORMAT_YCbCr_422_I_10BIT 0x4C595559 - -// v4l2_fourcc('Y', 'B', 'W', 'C'). 10 bit per component. This compressed -// format reduces the memory access bandwidth -#define HAL_PIXEL_FORMAT_YCbCr_422_I_10BIT_COMPRESSED 0x43574259 - -// UBWC aligned Venus format -#define HAL_PIXEL_FORMAT_YCbCr_420_SP_VENUS_UBWC 0x7FA30C06 -#define HAL_PIXEL_FORMAT_YCbCr_420_TP10_UBWC 0x7FA30C09 - -// Khronos ASTC formats -#define HAL_PIXEL_FORMAT_COMPRESSED_RGBA_ASTC_4x4_KHR 0x93B0 -#define HAL_PIXEL_FORMAT_COMPRESSED_RGBA_ASTC_5x4_KHR 0x93B1 -#define HAL_PIXEL_FORMAT_COMPRESSED_RGBA_ASTC_5x5_KHR 0x93B2 -#define HAL_PIXEL_FORMAT_COMPRESSED_RGBA_ASTC_6x5_KHR 0x93B3 -#define HAL_PIXEL_FORMAT_COMPRESSED_RGBA_ASTC_6x6_KHR 0x93B4 -#define HAL_PIXEL_FORMAT_COMPRESSED_RGBA_ASTC_8x5_KHR 0x93B5 -#define HAL_PIXEL_FORMAT_COMPRESSED_RGBA_ASTC_8x6_KHR 0x93B6 -#define HAL_PIXEL_FORMAT_COMPRESSED_RGBA_ASTC_8x8_KHR 0x93B7 -#define HAL_PIXEL_FORMAT_COMPRESSED_RGBA_ASTC_10x5_KHR 0x93B8 -#define HAL_PIXEL_FORMAT_COMPRESSED_RGBA_ASTC_10x6_KHR 0x93B9 -#define HAL_PIXEL_FORMAT_COMPRESSED_RGBA_ASTC_10x8_KHR 0x93BA -#define HAL_PIXEL_FORMAT_COMPRESSED_RGBA_ASTC_10x10_KHR 0x93BB -#define HAL_PIXEL_FORMAT_COMPRESSED_RGBA_ASTC_12x10_KHR 0x93BC -#define HAL_PIXEL_FORMAT_COMPRESSED_RGBA_ASTC_12x12_KHR 0x93BD -#define HAL_PIXEL_FORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR 0x93D0 -#define HAL_PIXEL_FORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR 0x93D1 -#define HAL_PIXEL_FORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR 0x93D2 -#define HAL_PIXEL_FORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR 0x93D3 -#define HAL_PIXEL_FORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR 0x93D4 -#define HAL_PIXEL_FORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR 0x93D5 -#define HAL_PIXEL_FORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR 0x93D6 -#define HAL_PIXEL_FORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR 0x93D7 -#define HAL_PIXEL_FORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR 0x93D8 -#define HAL_PIXEL_FORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR 0x93D9 -#define HAL_PIXEL_FORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR 0x93DA -#define HAL_PIXEL_FORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR 0x93DB -#define HAL_PIXEL_FORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR 0x93DC -#define HAL_PIXEL_FORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR 0x93DD - -enum { BUFFER_TYPE_UI = 0, BUFFER_TYPE_VIDEO }; - -#endif //__QTIGRALLOCDEFS_H__ diff --git a/externals/libadrenotools/tools/qtimapper-shim/ext/common.h b/externals/libadrenotools/tools/qtimapper-shim/ext/common.h deleted file mode 100644 index 73e80cb1d6..0000000000 --- a/externals/libadrenotools/tools/qtimapper-shim/ext/common.h +++ /dev/null @@ -1,86 +0,0 @@ -/* - * 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 -#include -#include -#include - -#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& descriptors)>; - virtual Return interfaceChain(interfaceChain_cb _hidl_cb) { - ALOGE("%s", __func__); - std::terminate(); - } - - virtual Return debug(const hidl_handle& fd, const hidl_vec& options) { - ALOGE("%s", __func__); - std::terminate(); - } - - using interfaceDescriptor_cb = std::function; - virtual Return interfaceDescriptor(interfaceDescriptor_cb _hidl_cb) { - ALOGE("%s", __func__); - std::terminate(); - } - - using getHashChain_cb = std::function>& hashchain)>; - virtual Return getHashChain(getHashChain_cb _hidl_cb) { - ALOGE("%s", __func__); - std::terminate(); - } - - virtual Return setHALInstrumentation() { - ALOGE("%s", __func__); - std::terminate(); - } - - virtual Return linkToDeath(const sp& recipient, uint64_t cookie) { - ALOGE("%s", __func__); - std::terminate(); - } - - virtual Return ping() { - ALOGE("%s", __func__); - std::terminate(); - } - - using getDebugInfo_cb = std::function; - virtual Return getDebugInfo(getDebugInfo_cb _hidl_cb) { - ALOGE("%s", __func__); - std::terminate(); - } - - virtual Return notifySyspropsChanged() { - ALOGE("%s", __func__); - std::terminate(); - } - - virtual Return unlinkToDeath(const sp& recipient) { - ALOGE("%s", __func__); - std::terminate(); - } -}; diff --git a/externals/libadrenotools/tools/qtimapper-shim/ext/gr_adreno_info.cpp b/externals/libadrenotools/tools/qtimapper-shim/ext/gr_adreno_info.cpp deleted file mode 100644 index 30610e810d..0000000000 --- a/externals/libadrenotools/tools/qtimapper-shim/ext/gr_adreno_info.cpp +++ /dev/null @@ -1,344 +0,0 @@ -/* - * Copyright (c) 2011-2018, 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. - */ - -#include "gr_adreno_info.h" - -#include -#include -#include - -#include - -#include "gr_utils.h" -#include "gralloc_priv.h" - -using std::lock_guard; -using std::mutex; - -namespace gralloc { - -AdrenoMemInfo* AdrenoMemInfo::s_instance = nullptr; - -AdrenoMemInfo* AdrenoMemInfo::GetInstance() { - static mutex s_lock; - lock_guard obj(s_lock); - if (!s_instance) { - s_instance = new AdrenoMemInfo(); - } - - return s_instance; -} - -AdrenoMemInfo::AdrenoMemInfo() { - libadreno_utils_ = ::dlopen("libadreno_utils.so", RTLD_NOW); - if (libadreno_utils_) { - *reinterpret_cast(&LINK_adreno_compute_aligned_width_and_height) = - ::dlsym(libadreno_utils_, "compute_aligned_width_and_height"); - *reinterpret_cast(&LINK_adreno_compute_fmt_aligned_width_and_height) = - ::dlsym(libadreno_utils_, "compute_fmt_aligned_width_and_height"); - *reinterpret_cast(&LINK_adreno_compute_padding) = - ::dlsym(libadreno_utils_, "compute_surface_padding"); - *reinterpret_cast(&LINK_adreno_compute_compressedfmt_aligned_width_and_height) = - ::dlsym(libadreno_utils_, "compute_compressedfmt_aligned_width_and_height"); - *reinterpret_cast(&LINK_adreno_isUBWCSupportedByGpu) = - ::dlsym(libadreno_utils_, "isUBWCSupportedByGpu"); - *reinterpret_cast(&LINK_adreno_get_gpu_pixel_alignment) = - ::dlsym(libadreno_utils_, "get_gpu_pixel_alignment"); - *reinterpret_cast(&LINK_adreno_get_metadata_blob_size) = - ::dlsym(libadreno_utils_, "adreno_get_metadata_blob_size"); - *reinterpret_cast(&LINK_adreno_init_memory_layout) = - ::dlsym(libadreno_utils_, "adreno_init_memory_layout"); - *reinterpret_cast(&LINK_adreno_get_aligned_gpu_buffer_size) = - ::dlsym(libadreno_utils_, "adreno_get_aligned_gpu_buffer_size"); - } else { - ALOGE(" Failed to load libadreno_utils.so"); - } - - // Check if the overriding property debug.gralloc.gfx_ubwc_disable - // that disables UBWC allocations for the graphics stack is set - char property[PROPERTY_VALUE_MAX]; - property_get(DISABLE_UBWC_PROP, property, "0"); - if (!(strncmp(property, "1", PROPERTY_VALUE_MAX)) || - !(strncmp(property, "true", PROPERTY_VALUE_MAX))) { - gfx_ubwc_disable_ = true; - } - - property_get(DISABLE_AHARDWAREBUFFER_PROP, property, "0"); - if (!(strncmp(property, "1", PROPERTY_VALUE_MAX)) || - !(strncmp(property, "true", PROPERTY_VALUE_MAX))) { - gfx_ahardware_buffer_disable_ = true; - } -} - -AdrenoMemInfo::~AdrenoMemInfo() { - if (libadreno_utils_) { - ::dlclose(libadreno_utils_); - } -} - -void AdrenoMemInfo::AlignUnCompressedRGB(int width, int height, int format, int tile_enabled, - unsigned int* aligned_w, unsigned int* aligned_h) { - *aligned_w = (unsigned int)ALIGN(width, 32); - *aligned_h = (unsigned int)ALIGN(height, 32); - - int bpp = 4; - switch (format) { - case HAL_PIXEL_FORMAT_RGB_888: - case HAL_PIXEL_FORMAT_BGR_888: - bpp = 3; - break; - case HAL_PIXEL_FORMAT_RGB_565: - case HAL_PIXEL_FORMAT_BGR_565: - case HAL_PIXEL_FORMAT_RGBA_5551: - case HAL_PIXEL_FORMAT_RGBA_4444: - bpp = 2; - break; - default: - break; - } - - int raster_mode = 0; // Adreno unknown raster mode. - int padding_threshold = 512; // Threshold for padding surfaces. - // the function below computes aligned width and aligned height - // based on linear or macro tile mode selected. - if (LINK_adreno_compute_fmt_aligned_width_and_height) { - // We call into adreno_utils only for RGB formats. So plane_id is 0 and - // num_samples is 1 always. We may have to add uitility function to - // find out these if there is a need to call this API for YUV formats. - LINK_adreno_compute_fmt_aligned_width_and_height( - width, height, 0 /*plane_id*/, GetGpuPixelFormat(format), 1 /*num_samples*/, tile_enabled, - raster_mode, padding_threshold, reinterpret_cast(aligned_w), - reinterpret_cast(aligned_h)); - } else if (LINK_adreno_compute_aligned_width_and_height) { - LINK_adreno_compute_aligned_width_and_height( - width, height, bpp, tile_enabled, raster_mode, padding_threshold, - reinterpret_cast(aligned_w), reinterpret_cast(aligned_h)); - } else if (LINK_adreno_compute_padding) { - int surface_tile_height = 1; // Linear surface - *aligned_w = UINT(LINK_adreno_compute_padding(width, bpp, surface_tile_height, raster_mode, - padding_threshold)); - ALOGW("%s: Warning!! Old GFX API is used to calculate stride", __FUNCTION__); - } else { - ALOGW( - "%s: Warning!! Symbols compute_surface_padding and " - "compute_fmt_aligned_width_and_height and " - "compute_aligned_width_and_height not found", - __FUNCTION__); - } -} - -void AdrenoMemInfo::AlignCompressedRGB(int width, int height, int format, unsigned int* aligned_w, - unsigned int* aligned_h) { - if (LINK_adreno_compute_compressedfmt_aligned_width_and_height) { - int bytesPerPixel = 0; - int raster_mode = 0; // Adreno unknown raster mode. - int padding_threshold = 512; // Threshold for padding - // surfaces. - - LINK_adreno_compute_compressedfmt_aligned_width_and_height( - width, height, format, 0, raster_mode, padding_threshold, reinterpret_cast(aligned_w), - reinterpret_cast(aligned_h), &bytesPerPixel); - } else { - *aligned_w = (unsigned int)ALIGN(width, 32); - *aligned_h = (unsigned int)ALIGN(height, 32); - ALOGW("%s: Warning!! compute_compressedfmt_aligned_width_and_height not found", __FUNCTION__); - } -} - -bool AdrenoMemInfo::IsUBWCSupportedByGPU(int format) { - if (!gfx_ubwc_disable_ && LINK_adreno_isUBWCSupportedByGpu) { - ADRENOPIXELFORMAT gpu_format = GetGpuPixelFormat(format); - return LINK_adreno_isUBWCSupportedByGpu(gpu_format); - } - - return false; -} - -uint32_t AdrenoMemInfo::GetGpuPixelAlignment() { - if (LINK_adreno_get_gpu_pixel_alignment) { - return LINK_adreno_get_gpu_pixel_alignment(); - } - - return 1; -} - -ADRENOPIXELFORMAT AdrenoMemInfo::GetGpuPixelFormat(int hal_format) { - switch (hal_format) { - case HAL_PIXEL_FORMAT_RGBA_8888: - return ADRENO_PIXELFORMAT_R8G8B8A8; - case HAL_PIXEL_FORMAT_RGBX_8888: - return ADRENO_PIXELFORMAT_R8G8B8X8; - case HAL_PIXEL_FORMAT_BGRA_8888: - return ADRENO_PIXELFORMAT_B8G8R8A8_UNORM; - case HAL_PIXEL_FORMAT_RGB_888: - return ADRENO_PIXELFORMAT_R8G8B8; - case HAL_PIXEL_FORMAT_RGB_565: - return ADRENO_PIXELFORMAT_B5G6R5; - case HAL_PIXEL_FORMAT_BGR_565: - return ADRENO_PIXELFORMAT_R5G6B5; - case HAL_PIXEL_FORMAT_RGBA_5551: - return ADRENO_PIXELFORMAT_R5G5B5A1; - case HAL_PIXEL_FORMAT_RGBA_4444: - return ADRENO_PIXELFORMAT_R4G4B4A4; - case HAL_PIXEL_FORMAT_RGBA_1010102: - return ADRENO_PIXELFORMAT_R10G10B10A2_UNORM; - case HAL_PIXEL_FORMAT_RGBX_1010102: - return ADRENO_PIXELFORMAT_R10G10B10X2_UNORM; - case HAL_PIXEL_FORMAT_ABGR_2101010: - return ADRENO_PIXELFORMAT_A2B10G10R10_UNORM; - case HAL_PIXEL_FORMAT_RGBA_FP16: - return ADRENO_PIXELFORMAT_R16G16B16A16_FLOAT; - case HAL_PIXEL_FORMAT_NV12_ENCODEABLE: - return ADRENO_PIXELFORMAT_NV12; - case HAL_PIXEL_FORMAT_YCbCr_420_SP_VENUS: - case HAL_PIXEL_FORMAT_YCbCr_420_SP_VENUS_UBWC: - return ADRENO_PIXELFORMAT_NV12_EXT; - case HAL_PIXEL_FORMAT_YCbCr_420_TP10_UBWC: - return ADRENO_PIXELFORMAT_TP10; - case HAL_PIXEL_FORMAT_YCbCr_420_P010: - case HAL_PIXEL_FORMAT_YCbCr_420_P010_UBWC: - case HAL_PIXEL_FORMAT_YCbCr_420_P010_VENUS: - return ADRENO_PIXELFORMAT_P010; - case HAL_PIXEL_FORMAT_DEPTH_16: - return ADRENO_PIXELFORMAT_D16_UNORM; - case HAL_PIXEL_FORMAT_DEPTH_24: - return ADRENO_PIXELFORMAT_D24_UNORM_X8_UINT; - case HAL_PIXEL_FORMAT_DEPTH_24_STENCIL_8: - return ADRENO_PIXELFORMAT_D24_UNORM_S8_UINT; - case HAL_PIXEL_FORMAT_DEPTH_32F: - return ADRENO_PIXELFORMAT_D32_FLOAT; - case HAL_PIXEL_FORMAT_STENCIL_8: - return ADRENO_PIXELFORMAT_S8_UINT; - case HAL_PIXEL_FORMAT_COMPRESSED_RGBA_ASTC_4x4_KHR: - return ADRENO_PIXELFORMAT_ASTC_4X4; - case HAL_PIXEL_FORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR: - return ADRENO_PIXELFORMAT_ASTC_4X4_SRGB; - case HAL_PIXEL_FORMAT_COMPRESSED_RGBA_ASTC_5x4_KHR: - return ADRENO_PIXELFORMAT_ASTC_5X4; - case HAL_PIXEL_FORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR: - return ADRENO_PIXELFORMAT_ASTC_5X4_SRGB; - case HAL_PIXEL_FORMAT_COMPRESSED_RGBA_ASTC_5x5_KHR: - return ADRENO_PIXELFORMAT_ASTC_5X5; - case HAL_PIXEL_FORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR: - return ADRENO_PIXELFORMAT_ASTC_5X5_SRGB; - case HAL_PIXEL_FORMAT_COMPRESSED_RGBA_ASTC_6x5_KHR: - return ADRENO_PIXELFORMAT_ASTC_6X5; - case HAL_PIXEL_FORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR: - return ADRENO_PIXELFORMAT_ASTC_6X5_SRGB; - case HAL_PIXEL_FORMAT_COMPRESSED_RGBA_ASTC_6x6_KHR: - return ADRENO_PIXELFORMAT_ASTC_6X6; - case HAL_PIXEL_FORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR: - return ADRENO_PIXELFORMAT_ASTC_6X6_SRGB; - case HAL_PIXEL_FORMAT_COMPRESSED_RGBA_ASTC_8x5_KHR: - return ADRENO_PIXELFORMAT_ASTC_8X5; - case HAL_PIXEL_FORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR: - return ADRENO_PIXELFORMAT_ASTC_8X5_SRGB; - case HAL_PIXEL_FORMAT_COMPRESSED_RGBA_ASTC_8x6_KHR: - return ADRENO_PIXELFORMAT_ASTC_8X6; - case HAL_PIXEL_FORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR: - return ADRENO_PIXELFORMAT_ASTC_8X6_SRGB; - case HAL_PIXEL_FORMAT_COMPRESSED_RGBA_ASTC_8x8_KHR: - return ADRENO_PIXELFORMAT_ASTC_8X8; - case HAL_PIXEL_FORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR: - return ADRENO_PIXELFORMAT_ASTC_8X8_SRGB; - case HAL_PIXEL_FORMAT_COMPRESSED_RGBA_ASTC_10x5_KHR: - return ADRENO_PIXELFORMAT_ASTC_10X5; - case HAL_PIXEL_FORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR: - return ADRENO_PIXELFORMAT_ASTC_10X5_SRGB; - case HAL_PIXEL_FORMAT_COMPRESSED_RGBA_ASTC_10x6_KHR: - return ADRENO_PIXELFORMAT_ASTC_10X6; - case HAL_PIXEL_FORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR: - return ADRENO_PIXELFORMAT_ASTC_10X6_SRGB; - case HAL_PIXEL_FORMAT_COMPRESSED_RGBA_ASTC_10x8_KHR: - return ADRENO_PIXELFORMAT_ASTC_10X8; - case HAL_PIXEL_FORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR: - return ADRENO_PIXELFORMAT_ASTC_10X8_SRGB; - case HAL_PIXEL_FORMAT_COMPRESSED_RGBA_ASTC_10x10_KHR: - return ADRENO_PIXELFORMAT_ASTC_10X10; - case HAL_PIXEL_FORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR: - return ADRENO_PIXELFORMAT_ASTC_10X10_SRGB; - case HAL_PIXEL_FORMAT_COMPRESSED_RGBA_ASTC_12x10_KHR: - return ADRENO_PIXELFORMAT_ASTC_12X10; - case HAL_PIXEL_FORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR: - return ADRENO_PIXELFORMAT_ASTC_12X10_SRGB; - case HAL_PIXEL_FORMAT_COMPRESSED_RGBA_ASTC_12x12_KHR: - return ADRENO_PIXELFORMAT_ASTC_12X12; - case HAL_PIXEL_FORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR: - return ADRENO_PIXELFORMAT_ASTC_12X12_SRGB; - default: - ALOGE("%s: No map for format: 0x%x", __FUNCTION__, hal_format); - break; - } - - return ADRENO_PIXELFORMAT_UNKNOWN; -} - -uint32_t AdrenoMemInfo::AdrenoGetMetadataBlobSize() { - if (LINK_adreno_get_metadata_blob_size) { - return LINK_adreno_get_metadata_blob_size(); - } - return 0; -} - -int AdrenoMemInfo::AdrenoInitMemoryLayout(void* metadata_blob, int width, int height, int depth, - int format, int num_samples, int isUBWC, uint64_t usage, - uint32_t num_planes) { - if (LINK_adreno_init_memory_layout) { - surface_tile_mode_t tile_mode = static_cast(isUBWC); - return LINK_adreno_init_memory_layout(metadata_blob, width, height, depth, - GetGpuPixelFormat(format), num_samples, tile_mode, usage, - num_planes); - } - return -1; -} - -uint32_t AdrenoMemInfo::AdrenoGetAlignedGpuBufferSize(void* metadata_blob) { - if (LINK_adreno_get_aligned_gpu_buffer_size) { - return LINK_adreno_get_aligned_gpu_buffer_size(metadata_blob); - } - return -1; -} - -bool AdrenoMemInfo::AdrenoSizeAPIAvaliable() { - if (gfx_ahardware_buffer_disable_) { - return false; - } - - return (LINK_adreno_get_metadata_blob_size && LINK_adreno_init_memory_layout && - LINK_adreno_get_aligned_gpu_buffer_size); -} - -bool AdrenoMemInfo::IsPISupportedByGPU(int format, uint64_t usage) { - if (LINK_adreno_isPISupportedByGpu) { - return LINK_adreno_isPISupportedByGpu(format, usage); - } - return false; -} - -} // namespace gralloc diff --git a/externals/libadrenotools/tools/qtimapper-shim/ext/gr_adreno_info.h b/externals/libadrenotools/tools/qtimapper-shim/ext/gr_adreno_info.h deleted file mode 100644 index 590d18ba67..0000000000 --- a/externals/libadrenotools/tools/qtimapper-shim/ext/gr_adreno_info.h +++ /dev/null @@ -1,234 +0,0 @@ -/* - * Copyright (c) 2011-2018, 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. - */ - -#ifndef __GR_ADRENO_INFO_H__ -#define __GR_ADRENO_INFO_H__ - -#include -#include - -namespace gralloc { - -// Adreno Pixel Formats -typedef enum { - ADRENO_PIXELFORMAT_UNKNOWN = 0, - ADRENO_PIXELFORMAT_R16G16B16A16_FLOAT = 10, - ADRENO_PIXELFORMAT_R10G10B10A2_UNORM = 24, // Vertex, Normalized GL_UNSIGNED_INT_10_10_10_2_OES - ADRENO_PIXELFORMAT_R8G8B8A8 = 28, - ADRENO_PIXELFORMAT_R8G8B8A8_SRGB = 29, - ADRENO_PIXELFORMAT_D32_FLOAT = 40, - ADRENO_PIXELFORMAT_D24_UNORM_S8_UINT = 45, - ADRENO_PIXELFORMAT_D16_UNORM = 55, - ADRENO_PIXELFORMAT_B5G6R5 = 85, - ADRENO_PIXELFORMAT_B5G5R5A1 = 86, - ADRENO_PIXELFORMAT_B8G8R8A8_UNORM = 87, - ADRENO_PIXELFORMAT_B8G8R8A8 = 90, - ADRENO_PIXELFORMAT_B8G8R8A8_SRGB = 91, - ADRENO_PIXELFORMAT_B8G8R8X8_SRGB = 93, - ADRENO_PIXELFORMAT_NV12 = 103, - ADRENO_PIXELFORMAT_P010 = 104, - ADRENO_PIXELFORMAT_YUY2 = 107, - ADRENO_PIXELFORMAT_B4G4R4A4 = 115, - ADRENO_PIXELFORMAT_NV12_EXT = 506, // NV12 with non-std alignment and offsets - ADRENO_PIXELFORMAT_R8G8B8X8 = 507, // GL_RGB8 (Internal) - ADRENO_PIXELFORMAT_R8G8B8 = 508, // GL_RGB8 - ADRENO_PIXELFORMAT_A1B5G5R5 = 519, // GL_RGB5_A1 - ADRENO_PIXELFORMAT_R8G8B8X8_SRGB = 520, // GL_SRGB8 - ADRENO_PIXELFORMAT_R8G8B8_SRGB = 521, // GL_SRGB8 - ADRENO_PIXELFORMAT_A2B10G10R10_UNORM = 532, - // Vertex, Normalized GL_UNSIGNED_INT_10_10_10_2_OES - ADRENO_PIXELFORMAT_R10G10B10X2_UNORM = 537, - ADRENO_PIXELFORMAT_D24_UNORM_X8_UINT = 548, - ADRENO_PIXELFORMAT_D24_UNORM = 549, - ADRENO_PIXELFORMAT_D32_FLOAT_X24S8_UINT = 551, - ADRENO_PIXELFORMAT_S8_UINT = 552, - ADRENO_PIXELFORMAT_ASTC_4X4 = 568, // ASTC Compressed - ADRENO_PIXELFORMAT_ASTC_5X4 = 569, // ASTC Compressed - ADRENO_PIXELFORMAT_ASTC_5X5 = 570, // ASTC Compressed - ADRENO_PIXELFORMAT_ASTC_6X5 = 571, // ASTC Compressed - ADRENO_PIXELFORMAT_ASTC_6X6 = 572, // ASTC Compressed - ADRENO_PIXELFORMAT_ASTC_8X5 = 573, // ASTC Compressed - ADRENO_PIXELFORMAT_ASTC_8X6 = 574, // ASTC Compressed - ADRENO_PIXELFORMAT_ASTC_8X8 = 575, // ASTC Compressed - ADRENO_PIXELFORMAT_ASTC_10X5 = 576, // ASTC Compressed - ADRENO_PIXELFORMAT_ASTC_10X6 = 577, // ASTC Compressed - ADRENO_PIXELFORMAT_ASTC_10X8 = 578, // ASTC Compressed - ADRENO_PIXELFORMAT_ASTC_10X10 = 579, // ASTC Compressed - ADRENO_PIXELFORMAT_ASTC_12X10 = 580, // ASTC Compressed - ADRENO_PIXELFORMAT_ASTC_12X12 = 581, // ASTC Compressed - ADRENO_PIXELFORMAT_ASTC_4X4_SRGB = 582, // ASTC Compressed - ADRENO_PIXELFORMAT_ASTC_5X4_SRGB = 583, // ASTC Compressed - ADRENO_PIXELFORMAT_ASTC_5X5_SRGB = 584, // ASTC Compressed - ADRENO_PIXELFORMAT_ASTC_6X5_SRGB = 585, // ASTC Compressed - ADRENO_PIXELFORMAT_ASTC_6X6_SRGB = 586, // ASTC Compressed - ADRENO_PIXELFORMAT_ASTC_8X5_SRGB = 587, // ASTC Compressed - ADRENO_PIXELFORMAT_ASTC_8X6_SRGB = 588, // ASTC Compressed - ADRENO_PIXELFORMAT_ASTC_8X8_SRGB = 589, // ASTC Compressed - ADRENO_PIXELFORMAT_ASTC_10X5_SRGB = 590, // ASTC Compressed - ADRENO_PIXELFORMAT_ASTC_10X6_SRGB = 591, // ASTC Compressed - ADRENO_PIXELFORMAT_ASTC_10X8_SRGB = 592, // ASTC Compressed - ADRENO_PIXELFORMAT_ASTC_10X10_SRGB = 593, // ASTC Compressed - ADRENO_PIXELFORMAT_ASTC_12X10_SRGB = 594, // ASTC Compressed - ADRENO_PIXELFORMAT_ASTC_12X12_SRGB = 595, // ASTC Compressed - // Vertex, Normalized GL_UNSIGNED_INT_10_10_10_2_OES - ADRENO_PIXELFORMAT_R5G6B5 = 610, // RGBA version of B5G6R5 - ADRENO_PIXELFORMAT_R5G5B5A1 = 611, // RGBA version of B5G5R5A1 - ADRENO_PIXELFORMAT_R4G4B4A4 = 612, // RGBA version of B4G4R4A4 - ADRENO_PIXELFORMAT_UYVY = 614, // YUV 4:2:2 packed progressive (1 plane) - ADRENO_PIXELFORMAT_NV21 = 619, - ADRENO_PIXELFORMAT_Y8U8V8A8 = 620, // YUV 4:4:4 packed (1 plane) - ADRENO_PIXELFORMAT_Y8 = 625, // Single 8-bit luma only channel YUV format - ADRENO_PIXELFORMAT_TP10 = 654, // YUV 4:2:0 planar 10 bits/comp (2 planes) -} ADRENOPIXELFORMAT; - -typedef enum { - SURFACE_TILE_MODE_DISABLE = 0x0, // used for linear surface - SURFACE_TILE_MODE_ENABLE = 0x1 // used for tiled surface -} surface_tile_mode_t; - -class AdrenoMemInfo { - public: - /* - * Function to compute aligned width and aligned height based on - * width, height, format and usage flags. - * - * @return aligned width, aligned height - */ - void GetAlignedWidthAndHeight(int width, int height, int format, int usage, - unsigned int* aligned_w, unsigned int* aligned_h, bool ubwc_enabled, - bool tile_enabled); - - /* - * Function to compute the adreno aligned width and aligned height - * based on the width and format. - * - * @return aligned width, aligned height - */ - void AlignUnCompressedRGB(int width, int height, int format, int tileEnabled, - unsigned int* aligned_w, unsigned int* aligned_h); - - /* - * Function to compute the adreno aligned width and aligned height - * based on the width and format. - * - * @return aligned width, aligned height - */ - void AlignCompressedRGB(int width, int height, int format, unsigned int* aligned_w, - unsigned int* aligned_h); - - /* - * Function to compute the pixel alignment requirement. - * - * @return alignment - */ - uint32_t GetGpuPixelAlignment(); - - /* - * Function to query whether GPU supports UBWC for given HAL format - * @return > 0 : supported - * 0 : not supported - */ - bool IsUBWCSupportedByGPU(int format); - - /* - * Function to check if GPU supports PI or not - */ - bool IsPISupportedByGPU(int format, uint64_t usage); - /* - * Function to get the corresponding Adreno format for given HAL format - */ - ADRENOPIXELFORMAT GetGpuPixelFormat(int hal_format); - - /* - * Function to get graphics metadata blob size - * @return graphics metadata size - */ - uint32_t AdrenoGetMetadataBlobSize(); - - /* - * Function to populate the graphics metadata blob - * @return 1 : Successful - * 2 : Unsuccessful - */ - int AdrenoInitMemoryLayout(void* metadata_blob, int width, int height, int depth, int format, - int num_samples, int isUBWC, uint64_t usage, uint32_t num_planes); - /* - * Function to get buffer size for based on graphcis metadata - * @return buffer size - */ - uint32_t AdrenoGetAlignedGpuBufferSize(void* metadata_blob); - - /* - * Function to check if adreno size calculation APIs are avaliable - * @return true : Avaliable - * false : Unavaliable - */ - bool AdrenoSizeAPIAvaliable(); - - static AdrenoMemInfo* GetInstance(); - - private: - AdrenoMemInfo(); - ~AdrenoMemInfo(); - // link(s)to adreno surface padding library. - int (*LINK_adreno_compute_padding)(int width, int bpp, int surface_tile_height, - int screen_tile_height, int padding_threshold) = NULL; - void (*LINK_adreno_compute_aligned_width_and_height)(int width, int height, int bpp, - int tile_mode, int raster_mode, - int padding_threshold, int* aligned_w, - int* aligned_h) = NULL; - void (*LINK_adreno_compute_fmt_aligned_width_and_height)(int width, int height, int plane_id, - int format, int num_samples, - int tile_mode, int raster_mode, - int padding_threshold, int* aligned_w, - int* aligned_h) = NULL; - void (*LINK_adreno_compute_compressedfmt_aligned_width_and_height)( - int width, int height, int format, int tile_mode, int raster_mode, int padding_threshold, - int* aligned_w, int* aligned_h, int* bpp) = NULL; - int (*LINK_adreno_isUBWCSupportedByGpu)(ADRENOPIXELFORMAT format) = NULL; - unsigned int (*LINK_adreno_get_gpu_pixel_alignment)() = NULL; - - uint32_t (*LINK_adreno_get_metadata_blob_size)() = NULL; - int (*LINK_adreno_init_memory_layout)(void* metadata_blob, int width, int height, int depth, - ADRENOPIXELFORMAT format, int num_samples, - surface_tile_mode_t tile_mode, uint64_t usage, - uint32_t num_planes) = NULL; - uint32_t (*LINK_adreno_get_aligned_gpu_buffer_size)(void* metadata_blob) = NULL; - int (*LINK_adreno_isPISupportedByGpu)(int format, uint64_t usage) = NULL; - - bool gfx_ubwc_disable_ = false; - bool gfx_ahardware_buffer_disable_ = false; - void* libadreno_utils_ = NULL; - - static AdrenoMemInfo* s_instance; -}; - -} // namespace gralloc - -#endif // __GR_ADRENO_INFO_H__ diff --git a/externals/libadrenotools/tools/qtimapper-shim/ext/gr_priv_handle.h b/externals/libadrenotools/tools/qtimapper-shim/ext/gr_priv_handle.h deleted file mode 100644 index 3efbea4b78..0000000000 --- a/externals/libadrenotools/tools/qtimapper-shim/ext/gr_priv_handle.h +++ /dev/null @@ -1,190 +0,0 @@ -/* - * Copyright (c) 2011-2019, 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 -#include -#include -#ifdef __cplusplus -#include -#endif - -#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(exp) - -#pragma pack(push, 4) -#ifdef __cplusplus -struct private_handle_t : public native_handle_t { -#else -struct private_handle_t { - native_handle_t nativeHandle; -#endif - 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 - PRIV_FLAGS_UBWC_ALIGNED_PI = 0x40000000, // PI format - }; - - // 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; -#ifdef __cplusplus - 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(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(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(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("handle = %p invalid magic(%c%c%c%c/%c%c%c%c)", hnd, - 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; } -#endif -}; -#pragma pack(pop) - -#endif // __GR_PRIV_HANDLE_H__ diff --git a/externals/libadrenotools/tools/qtimapper-shim/ext/gr_utils.cpp b/externals/libadrenotools/tools/qtimapper-shim/ext/gr_utils.cpp deleted file mode 100644 index a83ef20a6b..0000000000 --- a/externals/libadrenotools/tools/qtimapper-shim/ext/gr_utils.cpp +++ /dev/null @@ -1,662 +0,0 @@ -/* - * Copyright (c) 2011-2019, 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. - */ - -#include "gr_utils.h" - -#include - -#include "gr_adreno_info.h" - -#define ASTC_BLOCK_SIZE 16 - -#ifndef COLOR_FMT_P010_UBWC -#define COLOR_FMT_P010_UBWC 9 -#endif - -namespace gralloc { - -bool IsUncompressedRGBFormat(int format) { - switch (format) { - case HAL_PIXEL_FORMAT_RGBA_8888: - case HAL_PIXEL_FORMAT_RGBX_8888: - case HAL_PIXEL_FORMAT_RGB_888: - case HAL_PIXEL_FORMAT_RGB_565: - case HAL_PIXEL_FORMAT_BGR_565: - case HAL_PIXEL_FORMAT_BGRA_8888: - case HAL_PIXEL_FORMAT_RGBA_5551: - case HAL_PIXEL_FORMAT_RGBA_4444: - case HAL_PIXEL_FORMAT_R_8: - case HAL_PIXEL_FORMAT_RG_88: - case HAL_PIXEL_FORMAT_BGRX_8888: - case HAL_PIXEL_FORMAT_RGBA_1010102: - case HAL_PIXEL_FORMAT_ARGB_2101010: - case HAL_PIXEL_FORMAT_RGBX_1010102: - case HAL_PIXEL_FORMAT_XRGB_2101010: - case HAL_PIXEL_FORMAT_BGRA_1010102: - case HAL_PIXEL_FORMAT_ABGR_2101010: - case HAL_PIXEL_FORMAT_BGRX_1010102: - case HAL_PIXEL_FORMAT_XBGR_2101010: - case HAL_PIXEL_FORMAT_RGBA_FP16: - case HAL_PIXEL_FORMAT_BGR_888: - return true; - default: - break; - } - - return false; -} - -bool IsCompressedRGBFormat(int format) { - switch (format) { - case HAL_PIXEL_FORMAT_COMPRESSED_RGBA_ASTC_4x4_KHR: - case HAL_PIXEL_FORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR: - case HAL_PIXEL_FORMAT_COMPRESSED_RGBA_ASTC_5x4_KHR: - case HAL_PIXEL_FORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR: - case HAL_PIXEL_FORMAT_COMPRESSED_RGBA_ASTC_5x5_KHR: - case HAL_PIXEL_FORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR: - case HAL_PIXEL_FORMAT_COMPRESSED_RGBA_ASTC_6x5_KHR: - case HAL_PIXEL_FORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR: - case HAL_PIXEL_FORMAT_COMPRESSED_RGBA_ASTC_6x6_KHR: - case HAL_PIXEL_FORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR: - case HAL_PIXEL_FORMAT_COMPRESSED_RGBA_ASTC_8x5_KHR: - case HAL_PIXEL_FORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR: - case HAL_PIXEL_FORMAT_COMPRESSED_RGBA_ASTC_8x6_KHR: - case HAL_PIXEL_FORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR: - case HAL_PIXEL_FORMAT_COMPRESSED_RGBA_ASTC_8x8_KHR: - case HAL_PIXEL_FORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR: - case HAL_PIXEL_FORMAT_COMPRESSED_RGBA_ASTC_10x5_KHR: - case HAL_PIXEL_FORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR: - case HAL_PIXEL_FORMAT_COMPRESSED_RGBA_ASTC_10x6_KHR: - case HAL_PIXEL_FORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR: - case HAL_PIXEL_FORMAT_COMPRESSED_RGBA_ASTC_10x8_KHR: - case HAL_PIXEL_FORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR: - case HAL_PIXEL_FORMAT_COMPRESSED_RGBA_ASTC_10x10_KHR: - case HAL_PIXEL_FORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR: - case HAL_PIXEL_FORMAT_COMPRESSED_RGBA_ASTC_12x10_KHR: - case HAL_PIXEL_FORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR: - case HAL_PIXEL_FORMAT_COMPRESSED_RGBA_ASTC_12x12_KHR: - case HAL_PIXEL_FORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR: - return true; - default: - break; - } - - return false; -} - -uint32_t GetBppForUncompressedRGB(int format) { - uint32_t bpp = 0; - switch (format) { - case HAL_PIXEL_FORMAT_RGBA_FP16: - bpp = 8; - break; - case HAL_PIXEL_FORMAT_RGBA_8888: - case HAL_PIXEL_FORMAT_RGBX_8888: - case HAL_PIXEL_FORMAT_BGRA_8888: - case HAL_PIXEL_FORMAT_BGRX_8888: - case HAL_PIXEL_FORMAT_RGBA_1010102: - case HAL_PIXEL_FORMAT_ARGB_2101010: - case HAL_PIXEL_FORMAT_RGBX_1010102: - case HAL_PIXEL_FORMAT_XRGB_2101010: - case HAL_PIXEL_FORMAT_BGRA_1010102: - case HAL_PIXEL_FORMAT_ABGR_2101010: - case HAL_PIXEL_FORMAT_BGRX_1010102: - case HAL_PIXEL_FORMAT_XBGR_2101010: - bpp = 4; - break; - case HAL_PIXEL_FORMAT_RGB_888: - case HAL_PIXEL_FORMAT_BGR_888: - bpp = 3; - break; - case HAL_PIXEL_FORMAT_RGB_565: - case HAL_PIXEL_FORMAT_BGR_565: - case HAL_PIXEL_FORMAT_RGBA_5551: - case HAL_PIXEL_FORMAT_RGBA_4444: - bpp = 2; - break; - default: - ALOGE("Error : %s New format request = 0x%x", __FUNCTION__, format); - break; - } - - return bpp; -} - -bool CpuCanAccess(uint64_t usage) { - return CpuCanRead(usage) || CpuCanWrite(usage); -} - -bool CpuCanRead(uint64_t usage) { - if (usage & BufferUsage::CPU_READ_MASK) { - return true; - } - - return false; -} - -bool CpuCanWrite(uint64_t usage) { - if (usage & BufferUsage::CPU_WRITE_MASK) { - // Application intends to use CPU for rendering - return true; - } - - return false; -} - -uint32_t GetDataAlignment(int format, uint64_t usage) { - uint32_t align = UINT(getpagesize()); - if (format == HAL_PIXEL_FORMAT_YCbCr_420_SP_TILED) { - align = SIZE_8K; - } - - if (usage & BufferUsage::PROTECTED) { - if ((usage & BufferUsage::CAMERA_OUTPUT) || (usage & GRALLOC_USAGE_PRIVATE_SECURE_DISPLAY)) { - // The alignment here reflects qsee mmu V7L/V8L requirement - align = SZ_2M; - } else { - align = SECURE_ALIGN; - } - } - - return align; -} - -bool IsGPUFlagSupported(uint64_t usage) { - bool ret = true; - if ((usage & BufferUsage::GPU_MIPMAP_COMPLETE)) { - ALOGE("GPU_MIPMAP_COMPLETE not supported"); - ret = false; - } - - if ((usage & BufferUsage::GPU_CUBE_MAP)) { - ALOGE("GPU_CUBE_MAP not supported"); - ret = false; - } - - return ret; -} - -// Returns the final buffer size meant to be allocated with ion -unsigned int GetSize(const BufferInfo& info, unsigned int alignedw, unsigned int alignedh) { - unsigned int size = 0; - int format = info.format; - int width = info.width; - int height = info.height; - uint64_t usage = info.usage; - - if (!IsGPUFlagSupported(usage)) { - ALOGE("Unsupported GPU usage flags present 0x%" PRIx64, usage); - return 0; - } - - if (IsUBwcEnabled(format, usage)) { - size = GetUBwcSize(width, height, format, alignedw, alignedh); - } else if (IsUncompressedRGBFormat(format)) { - uint32_t bpp = GetBppForUncompressedRGB(format); - size = alignedw * alignedh * bpp; - } else if (IsCompressedRGBFormat(format)) { - size = alignedw * alignedh * ASTC_BLOCK_SIZE; - } else { - // Below switch should be for only YUV/custom formats - switch (format) { - case HAL_PIXEL_FORMAT_RAW16: - case HAL_PIXEL_FORMAT_Y16: - size = alignedw * alignedh * 2; - break; - case HAL_PIXEL_FORMAT_RAW10: - case HAL_PIXEL_FORMAT_RAW12: - size = ALIGN(alignedw * alignedh, SIZE_4K); - break; - case HAL_PIXEL_FORMAT_RAW8: - case HAL_PIXEL_FORMAT_Y8: - size = alignedw * alignedh * 1; - break; - // adreno formats - case HAL_PIXEL_FORMAT_YCrCb_420_SP_ADRENO: // NV21 - size = ALIGN(alignedw * alignedh, SIZE_4K); - size += (unsigned int)ALIGN(2 * ALIGN(width / 2, 32) * ALIGN(height / 2, 32), SIZE_4K); - break; - case HAL_PIXEL_FORMAT_YCbCr_420_SP_TILED: // NV12 - // The chroma plane is subsampled, - // but the pitch in bytes is unchanged - // The GPU needs 4K alignment, but the video decoder needs 8K - size = ALIGN(alignedw * alignedh, SIZE_8K); - size += ALIGN(alignedw * (unsigned int)ALIGN(height / 2, 32), SIZE_8K); - break; - case HAL_PIXEL_FORMAT_YV12: - if ((format == HAL_PIXEL_FORMAT_YV12) && ((width & 1) || (height & 1))) { - ALOGE("w or h is odd for the YV12 format"); - return 0; - } - size = alignedw * alignedh + (ALIGN(alignedw / 2, 16) * (alignedh / 2)) * 2; - size = ALIGN(size, (unsigned int)SIZE_4K); - break; - case HAL_PIXEL_FORMAT_YCbCr_420_SP: - case HAL_PIXEL_FORMAT_YCrCb_420_SP: - size = ALIGN((alignedw * alignedh) + (alignedw * alignedh) / 2 + 1, SIZE_4K); - break; - case HAL_PIXEL_FORMAT_YCbCr_420_P010: - size = ALIGN((alignedw * alignedh * 2) + (alignedw * alignedh) + 1, SIZE_4K); - break; - case HAL_PIXEL_FORMAT_YCbCr_422_SP: - case HAL_PIXEL_FORMAT_YCrCb_422_SP: - case HAL_PIXEL_FORMAT_YCbCr_422_I: - case HAL_PIXEL_FORMAT_YCrCb_422_I: - case HAL_PIXEL_FORMAT_CbYCrY_422_I: - if (width & 1) { - ALOGE("width is odd for the YUV422_SP format"); - return 0; - } - size = ALIGN(alignedw * alignedh * 2, SIZE_4K); - break; - case HAL_PIXEL_FORMAT_BLOB: - case HAL_PIXEL_FORMAT_RAW_OPAQUE: - if (height != 1) { - ALOGE("%s: Buffers with HAL_PIXEL_FORMAT_BLOB must have height 1 ", __FUNCTION__); - return 0; - } - size = (unsigned int)width; - break; - case HAL_PIXEL_FORMAT_NV21_ZSL: - size = ALIGN((alignedw * alignedh) + (alignedw * alignedh) / 2, SIZE_4K); - break; - default: - ALOGE("%s: Unrecognized pixel format: 0x%x", __FUNCTION__, format); - return 0; - } - } - auto align = GetDataAlignment(format, usage); - size = ALIGN(size, align) * info.layer_count; - return size; -} - -// Explicitly defined UBWC formats -bool IsUBwcFormat(int format) { - switch (format) { - case HAL_PIXEL_FORMAT_YCbCr_420_SP_VENUS_UBWC: - case HAL_PIXEL_FORMAT_YCbCr_420_TP10_UBWC: - case HAL_PIXEL_FORMAT_YCbCr_420_P010_UBWC: - return true; - default: - return false; - } -} - -bool IsUBwcSupported(int format) { - // Existing HAL formats with UBWC support - switch (format) { - case HAL_PIXEL_FORMAT_BGR_565: - case HAL_PIXEL_FORMAT_RGBA_8888: - case HAL_PIXEL_FORMAT_RGBX_8888: - case HAL_PIXEL_FORMAT_NV12_ENCODEABLE: - case HAL_PIXEL_FORMAT_YCbCr_420_SP_VENUS: - case HAL_PIXEL_FORMAT_RGBA_1010102: - case HAL_PIXEL_FORMAT_RGBX_1010102: - case HAL_PIXEL_FORMAT_DEPTH_16: - case HAL_PIXEL_FORMAT_DEPTH_24: - case HAL_PIXEL_FORMAT_DEPTH_24_STENCIL_8: - case HAL_PIXEL_FORMAT_DEPTH_32F: - case HAL_PIXEL_FORMAT_STENCIL_8: - return true; - default: - break; - } - - return false; -} - -bool IsUBwcPISupported(int format, uint64_t usage) { - if (usage & BufferUsage::COMPOSER_OVERLAY || !(usage & GRALLOC_USAGE_PRIVATE_ALLOC_UBWC_PI)) { - return false; - } - - // As of now only two formats - switch (format) { - case HAL_PIXEL_FORMAT_YCbCr_420_SP_VENUS_UBWC: - case HAL_PIXEL_FORMAT_YCbCr_420_TP10_UBWC: { - if ((usage & BufferUsage::GPU_TEXTURE) || (usage & BufferUsage::GPU_RENDER_TARGET)) { - if (AdrenoMemInfo::GetInstance()) { - return AdrenoMemInfo::GetInstance()->IsPISupportedByGPU(format, usage); - } - } else { - return true; - } - } - } - - return false; -} - -bool IsUBwcEnabled(int format, uint64_t usage) { - // Allow UBWC, if client is using an explicitly defined UBWC pixel format. - if (IsUBwcFormat(format)) { - return true; - } - - // Allow UBWC, if an OpenGL client sets UBWC usage flag and GPU plus MDP - // support the format. OR if a non-OpenGL client like Rotator, sets UBWC - // usage flag and MDP supports the format. - if (((usage & GRALLOC_USAGE_PRIVATE_ALLOC_UBWC) || - (usage & GRALLOC_USAGE_PRIVATE_ALLOC_UBWC_PI) || - (usage & BufferUsage::COMPOSER_CLIENT_TARGET)) && - IsUBwcSupported(format)) { - bool enable = true; - // Query GPU for UBWC only if buffer is intended to be used by GPU. - if ((usage & BufferUsage::GPU_TEXTURE) || (usage & BufferUsage::GPU_RENDER_TARGET)) { - if (AdrenoMemInfo::GetInstance()) { - enable = AdrenoMemInfo::GetInstance()->IsUBWCSupportedByGPU(format); - } - } - - // Allow UBWC, only if CPU usage flags are not set - if (enable && !(CpuCanAccess(usage))) { - return true; - } - } - - return false; -} - -void GetRgbUBwcBlockSize(uint32_t bpp, int* block_width, int* block_height) { - *block_width = 0; - *block_height = 0; - - switch (bpp) { - case 2: - case 4: - *block_width = 16; - *block_height = 4; - break; - case 8: - *block_width = 8; - *block_height = 4; - break; - case 16: - *block_width = 4; - *block_height = 4; - break; - default: - ALOGE("%s: Unsupported bpp: %d", __FUNCTION__, bpp); - break; - } -} - -unsigned int GetRgbUBwcMetaBufferSize(int width, int height, uint32_t bpp) { - unsigned int size = 0; - int meta_width, meta_height; - int block_width, block_height; - - GetRgbUBwcBlockSize(bpp, &block_width, &block_height); - if (!block_width || !block_height) { - ALOGE("%s: Unsupported bpp: %d", __FUNCTION__, bpp); - return size; - } - - // Align meta buffer height to 16 blocks - meta_height = ALIGN(((height + block_height - 1) / block_height), 16); - - // Align meta buffer width to 64 blocks - meta_width = ALIGN(((width + block_width - 1) / block_width), 64); - - // Align meta buffer size to 4K - size = (unsigned int)ALIGN((meta_width * meta_height), 4096); - - return size; -} - -unsigned int GetUBwcSize(int width, int height, int format, unsigned int alignedw, - unsigned int alignedh) { - unsigned int size = 0; - uint32_t bpp = 0; - switch (format) { - case HAL_PIXEL_FORMAT_BGR_565: - case HAL_PIXEL_FORMAT_RGBA_8888: - case HAL_PIXEL_FORMAT_RGBX_8888: - case HAL_PIXEL_FORMAT_RGBA_1010102: - case HAL_PIXEL_FORMAT_RGBX_1010102: - bpp = GetBppForUncompressedRGB(format); - size = alignedw * alignedh * bpp; - size += GetRgbUBwcMetaBufferSize(width, height, bpp); - break; - default: - ALOGE("%s: Unsupported pixel format: 0x%x", __FUNCTION__, format); - break; - } - - return size; -} - -unsigned int GetRgbMetaSize(int format, uint32_t width, uint32_t height, uint64_t usage) { - unsigned int meta_size = 0; - if (!IsUBwcEnabled(format, usage)) { - return meta_size; - } - uint32_t bpp = GetBppForUncompressedRGB(format); - switch (format) { - case HAL_PIXEL_FORMAT_BGR_565: - case HAL_PIXEL_FORMAT_RGBA_8888: - case HAL_PIXEL_FORMAT_RGBX_8888: - case HAL_PIXEL_FORMAT_RGBA_1010102: - case HAL_PIXEL_FORMAT_RGBX_1010102: - case HAL_PIXEL_FORMAT_RGBA_FP16: - meta_size = GetRgbUBwcMetaBufferSize(width, height, bpp); - break; - default: - ALOGE("%s:Unsupported RGB format: 0x%x", __FUNCTION__, format); - break; - } - return meta_size; -} - -bool CanUseAdrenoForSize(int buffer_type, uint64_t usage) { - if (buffer_type == BUFFER_TYPE_VIDEO || !GetAdrenoSizeAPIStatus()) { - return false; - } - - if ((usage & BufferUsage::PROTECTED) && - ((usage & BufferUsage::CAMERA_OUTPUT) || (usage & GRALLOC_USAGE_PRIVATE_SECURE_DISPLAY))) { - return false; - } - - return true; -} - -bool GetAdrenoSizeAPIStatus() { - AdrenoMemInfo* adreno_mem_info = AdrenoMemInfo::GetInstance(); - if (adreno_mem_info) { - return adreno_mem_info->AdrenoSizeAPIAvaliable(); - } - return false; -} - -bool UseUncached(int format, uint64_t usage) { - if ((usage & GRALLOC_USAGE_PRIVATE_UNCACHED) || (usage & BufferUsage::PROTECTED)) { - return true; - } - - // CPU read rarely - if ((usage & BufferUsage::CPU_READ_MASK) == static_cast(BufferUsage::CPU_READ_RARELY)) { - return true; - } - - // CPU write rarely - if ((usage & BufferUsage::CPU_WRITE_MASK) == - static_cast(BufferUsage::CPU_WRITE_RARELY)) { - return true; - } - - if ((usage & BufferUsage::SENSOR_DIRECT_DATA) || (usage & BufferUsage::GPU_DATA_BUFFER)) { - return true; - } - - if (format && IsUBwcEnabled(format, usage)) { - return true; - } - - return false; -} - -uint64_t GetHandleFlags(int format, uint64_t usage) { - uint64_t priv_flags = 0; - - if (usage & BufferUsage::VIDEO_ENCODER) { - priv_flags |= private_handle_t::PRIV_FLAGS_VIDEO_ENCODER; - } - - if (usage & BufferUsage::CAMERA_OUTPUT) { - priv_flags |= private_handle_t::PRIV_FLAGS_CAMERA_WRITE; - } - - if (usage & BufferUsage::CAMERA_INPUT) { - priv_flags |= private_handle_t::PRIV_FLAGS_CAMERA_READ; - } - - if (usage & BufferUsage::COMPOSER_OVERLAY) { - priv_flags |= private_handle_t::PRIV_FLAGS_DISP_CONSUMER; - } - - if (usage & BufferUsage::GPU_TEXTURE) { - priv_flags |= private_handle_t::PRIV_FLAGS_HW_TEXTURE; - } - - if (usage & GRALLOC_USAGE_PRIVATE_SECURE_DISPLAY) { - priv_flags |= private_handle_t::PRIV_FLAGS_SECURE_DISPLAY; - } - - if (IsUBwcEnabled(format, usage)) { - if (IsUBwcPISupported(format, usage)) { - priv_flags |= private_handle_t::PRIV_FLAGS_UBWC_ALIGNED_PI; - } else { - priv_flags |= private_handle_t::PRIV_FLAGS_UBWC_ALIGNED; - } - } - - if (usage & (BufferUsage::CPU_READ_MASK | BufferUsage::CPU_WRITE_MASK)) { - priv_flags |= private_handle_t::PRIV_FLAGS_CPU_RENDERED; - } - - if ((usage & (BufferUsage::VIDEO_ENCODER | BufferUsage::VIDEO_DECODER | - BufferUsage::CAMERA_OUTPUT | BufferUsage::GPU_RENDER_TARGET))) { - priv_flags |= private_handle_t::PRIV_FLAGS_NON_CPU_WRITER; - } - - if (!UseUncached(format, usage)) { - priv_flags |= private_handle_t::PRIV_FLAGS_CACHED; - } - - return priv_flags; -} - -int GetImplDefinedFormat(uint64_t usage, int format) { - int gr_format = format; - - // If input format is HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED then based on - // the usage bits, gralloc assigns a format. - if (format == HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED || - format == HAL_PIXEL_FORMAT_YCbCr_420_888) { - if ((usage & GRALLOC_USAGE_PRIVATE_ALLOC_UBWC || usage & GRALLOC_USAGE_PRIVATE_ALLOC_UBWC_PI) && - format != HAL_PIXEL_FORMAT_YCbCr_420_888) { - gr_format = HAL_PIXEL_FORMAT_YCbCr_420_SP_VENUS_UBWC; - } else if (usage & BufferUsage::VIDEO_ENCODER) { - if (usage & GRALLOC_USAGE_PRIVATE_VIDEO_NV21_ENCODER) { - gr_format = HAL_PIXEL_FORMAT_NV21_ENCODEABLE; // NV21 - } else if (usage & GRALLOC_USAGE_PRIVATE_HEIF) { - gr_format = HAL_PIXEL_FORMAT_NV12_HEIF; - } else if (format == HAL_PIXEL_FORMAT_YCbCr_420_888) { - gr_format = HAL_PIXEL_FORMAT_YCbCr_420_SP_VENUS; - } else { - gr_format = HAL_PIXEL_FORMAT_NV12_ENCODEABLE; // NV12 - } - } else if (usage & BufferUsage::CAMERA_INPUT) { - if (usage & BufferUsage::CAMERA_OUTPUT) { - // Assumed ZSL if both producer and consumer camera flags set - gr_format = HAL_PIXEL_FORMAT_NV21_ZSL; // NV21 - } else { - gr_format = HAL_PIXEL_FORMAT_YCrCb_420_SP; // NV21 - } - } else if (usage & BufferUsage::CAMERA_OUTPUT) { - if (format == HAL_PIXEL_FORMAT_YCbCr_420_888) { - gr_format = HAL_PIXEL_FORMAT_NV21_ZSL; // NV21 - } else { - gr_format = HAL_PIXEL_FORMAT_YCbCr_420_SP_VENUS; // NV12 preview - } - } else if (usage & BufferUsage::COMPOSER_OVERLAY) { - // XXX: If we still haven't set a format, default to RGBA8888 - gr_format = HAL_PIXEL_FORMAT_RGBA_8888; - } else if (format == HAL_PIXEL_FORMAT_YCbCr_420_888) { - // If no other usage flags are detected, default the - // flexible YUV format to NV21_ZSL - gr_format = HAL_PIXEL_FORMAT_NV21_ZSL; - } - } - - return gr_format; -} - -bool HasAlphaComponent(int32_t format) { - switch (format) { - case HAL_PIXEL_FORMAT_RGBA_8888: - case HAL_PIXEL_FORMAT_BGRA_8888: - case HAL_PIXEL_FORMAT_RGBA_5551: - case HAL_PIXEL_FORMAT_RGBA_4444: - case HAL_PIXEL_FORMAT_RGBA_1010102: - case HAL_PIXEL_FORMAT_ARGB_2101010: - case HAL_PIXEL_FORMAT_BGRA_1010102: - case HAL_PIXEL_FORMAT_ABGR_2101010: - case HAL_PIXEL_FORMAT_RGBA_FP16: - return true; - default: - return false; - } -} - -void GetRGBPlaneInfo(const BufferInfo& info, int32_t format, int32_t width, int32_t height, - int32_t /* flags */, int* plane_count, PlaneLayoutInfo* plane_info) { - uint64_t usage = info.usage; - *plane_count = 1; - uint32_t bpp = 0; - if (IsUncompressedRGBFormat(format)) { - bpp = GetBppForUncompressedRGB(format); - } - plane_info->component = - (PlaneComponent)(PLANE_COMPONENT_R | PLANE_COMPONENT_G | PLANE_COMPONENT_B); - if (HasAlphaComponent(format)) { - plane_info->component = (PlaneComponent)(plane_info->component | PLANE_COMPONENT_A); - } - plane_info->size = GetSize(info, width, height); - plane_info->step = bpp; - plane_info->offset = GetRgbMetaSize(format, width, height, usage); - plane_info->h_subsampling = 0; - plane_info->v_subsampling = 0; - plane_info->stride = width; - plane_info->stride_bytes = width * plane_info->step; - plane_info->scanlines = height; -} - -} // namespace gralloc diff --git a/externals/libadrenotools/tools/qtimapper-shim/ext/gr_utils.h b/externals/libadrenotools/tools/qtimapper-shim/ext/gr_utils.h deleted file mode 100644 index 13b21577c5..0000000000 --- a/externals/libadrenotools/tools/qtimapper-shim/ext/gr_utils.h +++ /dev/null @@ -1,156 +0,0 @@ -/* - * Copyright (c) 2011-2016,2018-2019, 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. - */ - -#ifndef __GR_UTILS_H__ -#define __GR_UTILS_H__ - -#include "gralloc_priv.h" -#include "types/common.h" - -#define SZ_2M 0x200000 -#define SZ_1M 0x100000 -#define SZ_4K 0x1000 - -#define SIZE_4K 4096 -#define SIZE_8K 8192 - -#ifdef SLAVE_SIDE_CP -#define SECURE_ALIGN SZ_1M -#else // MASTER_SIDE_CP -#define SECURE_ALIGN SZ_4K -#endif - -#define INT(exp) static_cast(exp) -#define UINT(exp) static_cast(exp) - -using android::hardware::graphics::common::V1_1::BufferUsage; - -namespace gralloc { -struct BufferInfo { - BufferInfo(int w, int h, int f, uint64_t usage = 0) - : width(w), height(h), format(f), layer_count(1), usage(usage) {} - int width; - int height; - int format; - int layer_count; - uint64_t usage; -}; - -template -inline Type1 ALIGN(Type1 x, Type2 align) { - return (Type1)((x + (Type1)align - 1) & ~((Type1)align - 1)); -} - -enum PlaneComponent { - /* luma */ - PLANE_COMPONENT_Y = 1 << 0, - /* chroma blue */ - PLANE_COMPONENT_Cb = 1 << 1, - /* chroma red */ - PLANE_COMPONENT_Cr = 1 << 2, - - /* red */ - PLANE_COMPONENT_R = 1 << 10, - /* green */ - PLANE_COMPONENT_G = 1 << 11, - /* blue */ - PLANE_COMPONENT_B = 1 << 12, - - /* alpha */ - PLANE_COMPONENT_A = 1 << 20, - - /* raw data plane */ - PLANE_COMPONENT_RAW = 1 << 30, - - /* meta information plane */ - PLANE_COMPONENT_META = 1 << 31, -}; - -struct PlaneLayoutInfo { - /** Components represented the type of plane. */ - PlaneComponent component; - - /** horizontal subsampling. Must be a positive power of 2. */ - uint32_t h_subsampling; - - /** vertical subsampling. Must be a positive power of 2. */ - uint32_t v_subsampling; - - /** offset to the first byte of the top-left pixel of the plane - * and it is calculated from the start of the buffer. - * Add base of the handle with offset to get the first byte of the plane. - */ - uint32_t offset; - - /** step is the distance in bytes from one pixel value to the next. */ - int32_t step; - - /** stride of the plane in pixels */ - int32_t stride; - - /** stride of the plane in in bytes */ - int32_t stride_bytes; - - /** plane height or vertical stride */ - int32_t scanlines; - - /** size of the plane in bytes */ - uint32_t size; -}; - -bool IsCompressedRGBFormat(int format); -bool IsUncompressedRGBFormat(int format); -uint32_t GetBppForUncompressedRGB(int format); -bool CpuCanAccess(uint64_t usage); -bool CpuCanRead(uint64_t usage); -bool CpuCanWrite(uint64_t usage); -unsigned int GetSize(const BufferInfo& d, unsigned int alignedw, unsigned int alignedh); -void GetRGBPlaneInfo(const BufferInfo& info, int32_t format, int32_t width, int32_t height, - int32_t flags, int* plane_count, PlaneLayoutInfo* plane_info); -unsigned int GetRgbMetaSize(int format, uint32_t width, uint32_t height, uint64_t usage); -bool IsUBwcFormat(int format); -bool IsUBwcSupported(int format); -bool IsUBwcPISupported(int format, uint64_t usage); -bool IsUBwcEnabled(int format, uint64_t usage); -void GetRgbUBwcBlockSize(uint32_t bpp, int* block_width, int* block_height); -unsigned int GetRgbUBwcMetaBufferSize(int width, int height, uint32_t bpp); -unsigned int GetUBwcSize(int width, int height, int format, unsigned int alignedw, - unsigned int alignedh); -uint32_t GetDataAlignment(int format, uint64_t usage); -bool CanUseAdrenoForSize(int buffer_type, uint64_t usage); -bool GetAdrenoSizeAPIStatus(); -bool UseUncached(int format, uint64_t usage); -uint64_t GetHandleFlags(int format, uint64_t usage); -int GetImplDefinedFormat(uint64_t usage, int format); -int GetCustomFormatFlags(int format, uint64_t usage, int* custom_format, uint64_t* priv_flags); -bool IsGPUFlagSupported(uint64_t usage); -bool HasAlphaComponent(int32_t format); -} // namespace gralloc - -#endif // __GR_UTILS_H__ diff --git a/externals/libadrenotools/tools/qtimapper-shim/ext/gralloc_priv.h b/externals/libadrenotools/tools/qtimapper-shim/ext/gralloc_priv.h deleted file mode 100644 index 8a333a6bde..0000000000 --- a/externals/libadrenotools/tools/qtimapper-shim/ext/gralloc_priv.h +++ /dev/null @@ -1,103 +0,0 @@ -/* - * Copyright (c) 2011-2021, 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 __GRALLOC_PRIV_H__ -#define __GRALLOC_PRIV_H__ - -#include -#include - -#include "QtiGrallocDefs.h" -#include "gr_priv_handle.h" - -//#pragma message "Warning: gralloc_priv.h is deprecated" - -#define GRALLOC_PROP_PREFIX "vendor.gralloc." -#define GRALLOC_PROP(prop_name) GRALLOC_PROP_PREFIX prop_name - -#define DISABLE_UBWC_PROP GRALLOC_PROP("disable_ubwc") -#define DISABLE_AHARDWAREBUFFER_PROP GRALLOC_PROP("disable_ahardware_buffer") -#define ENABLE_FB_UBWC_PROP GRALLOC_PROP("enable_fb_ubwc") -#define MAP_FB_MEMORY_PROP GRALLOC_PROP("map_fb_memory") -#define USE_SYSTEM_HEAP_FOR_SENSORS GRALLOC_PROP("use_system_heap_for_sensors") - -#define ROUND_UP_PAGESIZE(x) roundUpToPageSize(x) -inline int roundUpToPageSize(int x) { - return (x + (getpagesize() - 1)) & ~(getpagesize() - 1); -} - -/* Legacy gralloc1 definitions */ -/* Some clients may still be using the old flags */ -#define GRALLOC1_PRODUCER_USAGE_PRIVATE_ADSP_HEAP GRALLOC_USAGE_PRIVATE_ADSP_HEAP -#define GRALLOC1_PRODUCER_USAGE_PRIVATE_ALLOC_UBWC GRALLOC_USAGE_PRIVATE_ALLOC_UBWC -#define GRALLOC1_PRODUCER_USAGE_PRIVATE_UNCACHED GRALLOC_USAGE_PRIVATE_UNCACHED -#define GRALLOC1_CONSUMER_USAGE_PRIVATE_SECURE_DISPLAY GRALLOC_USAGE_PRIVATE_SECURE_DISPLAY -#define GRALLOC1_PRODUCER_USAGE_PRIVATE_MM_HEAP GRALLOC_USAGE_PRIVATE_MM_HEAP -#define GRALLOC1_PRODUCER_USAGE_PRIVATE_10BIT GRALLOC_USAGE_PRIVATE_10BIT -#define GRALLOC1_PRODUCER_USAGE_PRIVATE_10BIT_TP GRALLOC_USAGE_PRIVATE_10BIT_TP -#define GRALLOC1_CONSUMER_USAGE_PRIVATE_10BIT_TP GRALLOC_USAGE_PRIVATE_10BIT_TP -#define GRALLOC1_PRODUCER_USAGE_PRIVATE_VIDEO_NV21_ENCODER GRALLOC_USAGE_PRIVATE_VIDEO_NV21_ENCODER - -// for PERFORM API : -#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 - -/* possible values for inverse gamma correction */ -#define HAL_IGC_NOT_SPECIFIED 0 -#define HAL_IGC_s_RGB 1 - -/* Color Space: Values maps to ColorSpace_t in qdMetadata.h */ -#define HAL_CSC_ITU_R_601 0 -#define HAL_CSC_ITU_R_601_FR 1 -#define HAL_CSC_ITU_R_709 2 -#define HAL_CSC_ITU_R_709_FR 3 -#define HAL_CSC_ITU_R_2020 4 -#define HAL_CSC_ITU_R_2020_FR 5 - -/* possible formats for 3D content*/ -enum { - HAL_NO_3D = 0x0, - HAL_3D_SIDE_BY_SIDE_L_R = 0x1, - HAL_3D_SIDE_BY_SIDE_R_L = 0x2, - HAL_3D_TOP_BOTTOM = 0x4, - HAL_3D_IN_SIDE_BY_SIDE_L_R = 0x10000, // unused legacy format -}; - -/* Flag to determine interlaced content - * Value maps to Flags presents in types.hal of QtiMapperextensions - */ -enum { - LAYOUT_INTERLACED_FLAG = 1 << 0, -}; - -#endif // __GRALLOC_PRIV_H__ diff --git a/externals/libadrenotools/tools/qtimapper-shim/ext/mapper.h b/externals/libadrenotools/tools/qtimapper-shim/ext/mapper.h deleted file mode 100644 index ae3bdbba9b..0000000000 --- a/externals/libadrenotools/tools/qtimapper-shim/ext/mapper.h +++ /dev/null @@ -1,183 +0,0 @@ -/* - * 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 -#include -#include -#include -#include - -#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 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 getService(const std::string& /* serviceName */, const bool /* getStub */); -}; - -} // namespace V2_0 -namespace V3_0 { - -struct IMapper : public IBase { - static sp getService(const std::string& /* serviceName */, const bool /* getStub */); -}; - -} // namespace V3_0 -namespace V4_0 { - -struct IMapper : public IBase { - static sp getService(const std::string& /* serviceName */, const bool /* getStub */); -}; - -} // namespace V4_0 -} // namespace android::hardware::graphics::mapper - -namespace vendor::qti::hardware::display::mapper { -namespace V4_0 { - -struct IQtiMapper : public IBase { - static Return> castFrom(const sp& /* parent */, - bool /* emitError */); -}; - -} // namespace V4_0 -namespace V3_0 { - -struct IQtiMapper : public IBase { - static Return> castFrom(const sp& /* parent */, - bool /* emitError */); -}; - -} // namespace V3_0 -namespace V2_0 { - -struct IQtiMapper : public IBase { - using createDescriptor_cb = std::function& descriptor)>; - virtual Return createDescriptor( - const graphics::mapper::V2_0::IMapper::BufferDescriptorInfo& descriptorInfo, - createDescriptor_cb _hidl_cb) { - ALOGE("%s", __func__); - std::terminate(); - } - - using importBuffer_cb = std::function; - virtual Return importBuffer(const hidl_handle& rawHandle, importBuffer_cb _hidl_cb) { - ALOGE("%s", __func__); - std::terminate(); - } - - virtual Return freeBuffer(void* buffer) { - ALOGE("%s", __func__); - std::terminate(); - } - - using lock_cb = std::function; - virtual Return lock(void* buffer, - hidl_bitfield 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; - virtual Return lockYCbCr(void* buffer, - hidl_bitfield 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; - virtual Return unlock(void* buffer, unlock_cb _hidl_cb) { - ALOGE("%s", __func__); - std::terminate(); - } - - virtual Return validateBufferSize( - void* buffer, const graphics::mapper::V2_0::IMapper::BufferDescriptorInfo& descriptorInfo, - uint32_t stride) { - ALOGE("%s", __func__); - std::terminate(); - } - - using getTransportSize_cb = - std::function; - virtual Return getTransportSize(void* buffer, getTransportSize_cb _hidl_cb) { - ALOGE("%s", __func__); - std::terminate(); - } - - using createDescriptor_2_1_cb = std::function& descriptor)>; - virtual Return 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& extensions)>; - virtual Return getMapperExtensions(getMapperExtensions_cb _hidl_cb); - - static Return> castFrom(const sp& /* parent */, - bool /* emitError */); -}; - -} // namespace V2_0 -} // namespace vendor::qti::hardware::display::mapper diff --git a/externals/libadrenotools/tools/qtimapper-shim/ext/mapperextensions.h b/externals/libadrenotools/tools/qtimapper-shim/ext/mapperextensions.h deleted file mode 100644 index 078cb90b26..0000000000 --- a/externals/libadrenotools/tools/qtimapper-shim/ext/mapperextensions.h +++ /dev/null @@ -1,224 +0,0 @@ -/* - * 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 -#include -#include -#include -#include - -#include "gralloc_priv.h" -#include "types/mapperextensions.h" - -namespace vendor::qti::hardware::display::mapperextensions { -namespace V1_0 { - -struct IQtiMapperExtensions : public IBase { - IQtiMapperExtensions(){}; -}; - -} // namespace V1_0 -namespace V1_1 { -using Error = V1_0::Error; -using PlaneLayout = V1_0::PlaneLayout; - -struct IQtiMapperExtensions : public IBase { - IQtiMapperExtensions(); - - gralloc1_device_t* gralloc; - GRALLOC1_PFN_PERFORM perform; - - using getMapSecureBufferFlag_cb = std::function; - virtual ::android::hardware::Return getMapSecureBufferFlag( - void* buffer, getMapSecureBufferFlag_cb _hidl_cb) { - ALOGE("%s", __func__); - std::terminate(); - } - - // Used, passthrough - using getInterlacedFlag_cb = std::function; - virtual ::android::hardware::Return getInterlacedFlag(void* buffer, - getInterlacedFlag_cb _hidl_cb); - - using getCustomDimensions_cb = - std::function; - virtual ::android::hardware::Return getCustomDimensions(void* buffer, - getCustomDimensions_cb _hidl_cb) { - ALOGE("%s", __func__); - std::terminate(); - } - - // Used, passthrough - using getRgbDataAddress_cb = std::function; - virtual ::android::hardware::Return getRgbDataAddress(void* buffer, - getRgbDataAddress_cb _hidl_cb); - - using calculateBufferAttributes_cb = - std::function; - virtual ::android::hardware::Return 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; - virtual ::android::hardware::Return getColorSpace(void* buffer, getColorSpace_cb _hidl_cb) { - ALOGE("%s", __func__); - std::terminate(); - } - - // Used, passthrough with hidl fixups - using getYuvPlaneInfo_cb = std::function& layout)>; - virtual ::android::hardware::Return 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; - virtual ::android::hardware::Return 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; - virtual ::android::hardware::Return getFd(void* buffer, getFd_cb _hidl_cb); - - // Used, cast private data with no passthrough - using getWidth_cb = std::function; - virtual ::android::hardware::Return getWidth(void* buffer, getWidth_cb _hidl_cb); - - // Used, cast private data with no passthrough - using getHeight_cb = std::function; - virtual ::android::hardware::Return getHeight(void* buffer, getHeight_cb _hidl_cb); - - // Used, cast private data with no passthrough - using getOffset_cb = std::function; - virtual ::android::hardware::Return getOffset(void* buffer, getOffset_cb _hidl_cb); - - // Used, cast private data with no passthrough - using getSize_cb = std::function; - virtual ::android::hardware::Return getSize(void* buffer, getSize_cb _hidl_cb); - - using getUnalignedWidth_cb = - std::function; - virtual ::android::hardware::Return getUnalignedWidth(void* buffer, - getUnalignedWidth_cb _hidl_cb); - - using getUnalignedHeight_cb = - std::function; - virtual ::android::hardware::Return getUnalignedHeight(void* buffer, - getUnalignedHeight_cb _hidl_cb); - - using getLayerCount_cb = std::function; - virtual ::android::hardware::Return getLayerCount(void* buffer, getLayerCount_cb _hidl_cb); - - using getId_cb = std::function; - virtual ::android::hardware::Return getId(void* buffer, getId_cb _hidl_cb); - - using getUsageFlags_cb = std::function; - virtual ::android::hardware::Return getUsageFlags(void* buffer, getUsageFlags_cb _hidl_cb); - - // Used, cast private data with no passthrough - using getFormat_cb = std::function; - virtual ::android::hardware::Return getFormat(void* buffer, getFormat_cb _hidl_cb); - - // Used, cast private data with no passthrough - using getPrivateFlags_cb = std::function; - virtual ::android::hardware::Return getPrivateFlags(void* buffer, - getPrivateFlags_cb _hidl_cb); - - using getSurfaceMetadata_cb = std::function; - virtual ::android::hardware::Return getSurfaceMetadata(void* buffer, - getSurfaceMetadata_cb _hidl_cb) { - ALOGE("%s", __func__); - std::terminate(); - } - - // Used, PAIN - using getFormatLayout_cb = std::function& plane_info)>; - virtual ::android::hardware::Return getFormatLayout(int32_t format, uint64_t usage, - int32_t flags, int32_t width, - int32_t height, - getFormatLayout_cb _hidl_cb); - - // 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> castFrom( - android::sp const& /* parent */, bool /* emitError */); -}; - -} // namespace V1_1 -} // namespace vendor::qti::hardware::display::mapperextensions diff --git a/externals/libadrenotools/tools/qtimapper-shim/ext/types/common.h b/externals/libadrenotools/tools/qtimapper-shim/ext/types/common.h deleted file mode 100644 index 6f327baf3b..0000000000 --- a/externals/libadrenotools/tools/qtimapper-shim/ext/types/common.h +++ /dev/null @@ -1,6744 +0,0 @@ -#ifndef HIDL_GENERATED_ANDROID_HARDWARE_GRAPHICS_COMMON_V1_0_TYPES_H -#define HIDL_GENERATED_ANDROID_HARDWARE_GRAPHICS_COMMON_V1_0_TYPES_H - -#include -#include -#include -#include - -namespace android { -namespace hardware { -namespace graphics { -namespace common { -namespace V1_0 { - -// Forward declaration for forward reference support: -enum class PixelFormat : int32_t; -enum class BufferUsage : uint64_t; -enum class Transform : int32_t; -enum class Dataspace : int32_t; -enum class ColorMode : int32_t; -enum class ColorTransform : int32_t; -enum class Hdr : int32_t; - -/** - * Common enumeration and structure definitions for all graphics HALs. - * - * - * Pixel formats for graphics buffers. - */ -enum class PixelFormat : int32_t { - /** - * 32-bit format that has 8-bit R, G, B, and A components, in that order, - * from the lowest memory address to the highest memory address. - * - * The component values are unsigned normalized to the range [0, 1], whose - * interpretation is defined by the dataspace. - */ - RGBA_8888 = 1 /* 0x1 */, - /** - * 32-bit format that has 8-bit R, G, B, and unused components, in that - * order, from the lowest memory address to the highest memory address. - * - * The component values are unsigned normalized to the range [0, 1], whose - * interpretation is defined by the dataspace. - */ - RGBX_8888 = 2 /* 0x2 */, - /** - * 24-bit format that has 8-bit R, G, and B components, in that order, - * from the lowest memory address to the highest memory address. - * - * The component values are unsigned normalized to the range [0, 1], whose - * interpretation is defined by the dataspace. - */ - RGB_888 = 3 /* 0x3 */, - /** - * 16-bit packed format that has 5-bit R, 6-bit G, and 5-bit B components, - * in that order, from the most-sigfinicant bits to the least-significant - * bits. - * - * The component values are unsigned normalized to the range [0, 1], whose - * interpretation is defined by the dataspace. - */ - RGB_565 = 4 /* 0x4 */, - /** - * 32-bit format that has 8-bit B, G, R, and A components, in that order, - * from the lowest memory address to the highest memory address. - * - * The component values are unsigned normalized to the range [0, 1], whose - * interpretation is defined by the dataspace. - */ - BGRA_8888 = 5 /* 0x5 */, - /** - * Legacy formats deprecated in favor of YCBCR_420_888. - */ - YCBCR_422_SP = 16 /* 0x10 */, - YCRCB_420_SP = 17 /* 0x11 */, - YCBCR_422_I = 20 /* 0x14 */, - /** - * 64-bit format that has 16-bit R, G, B, and A components, in that order, - * from the lowest memory address to the highest memory address. - * - * The component values are signed floats, whose interpretation is defined - * by the dataspace. - */ - RGBA_FP16 = 22 /* 0x16 */, - /** - * RAW16 is a single-channel, 16-bit, little endian format, typically - * representing raw Bayer-pattern images from an image sensor, with minimal - * processing. - * - * The exact pixel layout of the data in the buffer is sensor-dependent, and - * needs to be queried from the camera device. - * - * Generally, not all 16 bits are used; more common values are 10 or 12 - * bits. If not all bits are used, the lower-order bits are filled first. - * All parameters to interpret the raw data (black and white points, - * color space, etc) must be queried from the camera device. - * - * This format assumes - * - an even width - * - an even height - * - a horizontal stride multiple of 16 pixels - * - a vertical stride equal to the height - * - strides are specified in pixels, not in bytes - * - * size = stride * height * 2 - * - * This format must be accepted by the allocator when used with the - * following usage flags: - * - * - BufferUsage::CAMERA_* - * - BufferUsage::CPU_* - * - BufferUsage::RENDERSCRIPT - * - * The mapping of the dataspace to buffer contents for RAW16 is as - * follows: - * - * Dataspace value | Buffer contents - * -------------------------------+----------------------------------------- - * Dataspace::ARBITRARY | Raw image sensor data, layout is as - * | defined above. - * Dataspace::DEPTH | Unprocessed implementation-dependent raw - * | depth measurements, opaque with 16 bit - * | samples. - * Other | Unsupported - */ - RAW16 = 32 /* 0x20 */, - /** - * BLOB is used to carry task-specific data which does not have a standard - * image structure. The details of the format are left to the two - * endpoints. - * - * A typical use case is for transporting JPEG-compressed images from the - * Camera HAL to the framework or to applications. - * - * Buffers of this format must have a height of 1, and width equal to their - * size in bytes. - * - * The mapping of the dataspace to buffer contents for BLOB is as - * follows: - * - * Dataspace value | Buffer contents - * -------------------------------+----------------------------------------- - * Dataspace::JFIF | An encoded JPEG image - * Dataspace::DEPTH | An android_depth_points buffer - * Dataspace::SENSOR | Sensor event data. - * Other | Unsupported - */ - BLOB = 33 /* 0x21 */, - /** - * A format indicating that the choice of format is entirely up to the - * allocator. - * - * The allocator should examine the usage bits passed in when allocating a - * buffer with this format, and it should derive the pixel format from - * those usage flags. This format must never be used with any of the - * BufferUsage::CPU_* usage flags. - * - * Even when the internally chosen format has an alpha component, the - * clients must assume the alpha vlaue to be 1.0. - * - * The interpretation of the component values is defined by the dataspace. - */ - IMPLEMENTATION_DEFINED = 34 /* 0x22 */, - /** - * This format allows platforms to use an efficient YCbCr/YCrCb 4:2:0 - * buffer layout, while still describing the general format in a - * layout-independent manner. While called YCbCr, it can be used to - * describe formats with either chromatic ordering, as well as - * whole planar or semiplanar layouts. - * - * This format must be accepted by the allocator when BufferUsage::CPU_* - * are set. - * - * Buffers with this format must be locked with IMapper::lockYCbCr. - * Locking with IMapper::lock must return an error. - * - * The interpretation of the component values is defined by the dataspace. - */ - YCBCR_420_888 = 35 /* 0x23 */, - /** - * RAW_OPAQUE is a format for unprocessed raw image buffers coming from an - * image sensor. The actual structure of buffers of this format is - * implementation-dependent. - * - * This format must be accepted by the allocator when used with the - * following usage flags: - * - * - BufferUsage::CAMERA_* - * - BufferUsage::CPU_* - * - BufferUsage::RENDERSCRIPT - * - * The mapping of the dataspace to buffer contents for RAW_OPAQUE is as - * follows: - * - * Dataspace value | Buffer contents - * -------------------------------+----------------------------------------- - * Dataspace::ARBITRARY | Raw image sensor data. - * Other | Unsupported - */ - RAW_OPAQUE = 36 /* 0x24 */, - /** - * RAW10 is a single-channel, 10-bit per pixel, densely packed in each row, - * unprocessed format, usually representing raw Bayer-pattern images coming from - * an image sensor. - * - * In an image buffer with this format, starting from the first pixel of each - * row, each 4 consecutive pixels are packed into 5 bytes (40 bits). Each one - * of the first 4 bytes contains the top 8 bits of each pixel, The fifth byte - * contains the 2 least significant bits of the 4 pixels, the exact layout data - * for each 4 consecutive pixels is illustrated below (Pi[j] stands for the jth - * bit of the ith pixel): - * - * bit 7 bit 0 - * =====|=====|=====|=====|=====|=====|=====|=====| - * Byte 0: |P0[9]|P0[8]|P0[7]|P0[6]|P0[5]|P0[4]|P0[3]|P0[2]| - * |-----|-----|-----|-----|-----|-----|-----|-----| - * Byte 1: |P1[9]|P1[8]|P1[7]|P1[6]|P1[5]|P1[4]|P1[3]|P1[2]| - * |-----|-----|-----|-----|-----|-----|-----|-----| - * Byte 2: |P2[9]|P2[8]|P2[7]|P2[6]|P2[5]|P2[4]|P2[3]|P2[2]| - * |-----|-----|-----|-----|-----|-----|-----|-----| - * Byte 3: |P3[9]|P3[8]|P3[7]|P3[6]|P3[5]|P3[4]|P3[3]|P3[2]| - * |-----|-----|-----|-----|-----|-----|-----|-----| - * Byte 4: |P3[1]|P3[0]|P2[1]|P2[0]|P1[1]|P1[0]|P0[1]|P0[0]| - * =============================================== - * - * This format assumes - * - a width multiple of 4 pixels - * - an even height - * - a vertical stride equal to the height - * - strides are specified in bytes, not in pixels - * - * size = stride * height - * - * When stride is equal to width * (10 / 8), there will be no padding bytes at - * the end of each row, the entire image data is densely packed. When stride is - * larger than width * (10 / 8), padding bytes will be present at the end of each - * row (including the last row). - * - * This format must be accepted by the allocator when used with the - * following usage flags: - * - * - BufferUsage::CAMERA_* - * - BufferUsage::CPU_* - * - BufferUsage::RENDERSCRIPT - * - * The mapping of the dataspace to buffer contents for RAW10 is as - * follows: - * - * Dataspace value | Buffer contents - * -------------------------------+----------------------------------------- - * Dataspace::ARBITRARY | Raw image sensor data. - * Other | Unsupported - */ - RAW10 = 37 /* 0x25 */, - /** - * RAW12 is a single-channel, 12-bit per pixel, densely packed in each row, - * unprocessed format, usually representing raw Bayer-pattern images coming from - * an image sensor. - * - * In an image buffer with this format, starting from the first pixel of each - * row, each two consecutive pixels are packed into 3 bytes (24 bits). The first - * and second byte contains the top 8 bits of first and second pixel. The third - * byte contains the 4 least significant bits of the two pixels, the exact layout - * data for each two consecutive pixels is illustrated below (Pi[j] stands for - * the jth bit of the ith pixel): - * - * bit 7 bit 0 - * ======|======|======|======|======|======|======|======| - * Byte 0: |P0[11]|P0[10]|P0[ 9]|P0[ 8]|P0[ 7]|P0[ 6]|P0[ 5]|P0[ 4]| - * |------|------|------|------|------|------|------|------| - * Byte 1: |P1[11]|P1[10]|P1[ 9]|P1[ 8]|P1[ 7]|P1[ 6]|P1[ 5]|P1[ 4]| - * |------|------|------|------|------|------|------|------| - * Byte 2: |P1[ 3]|P1[ 2]|P1[ 1]|P1[ 0]|P0[ 3]|P0[ 2]|P0[ 1]|P0[ 0]| - * ======================================================= - * - * This format assumes: - * - a width multiple of 4 pixels - * - an even height - * - a vertical stride equal to the height - * - strides are specified in bytes, not in pixels - * - * size = stride * height - * - * When stride is equal to width * (12 / 8), there will be no padding bytes at - * the end of each row, the entire image data is densely packed. When stride is - * larger than width * (12 / 8), padding bytes will be present at the end of - * each row (including the last row). - * - * This format must be accepted by the allocator when used with the - * following usage flags: - * - * - BufferUsage::CAMERA_* - * - BufferUsage::CPU_* - * - BufferUsage::RENDERSCRIPT - * - * The mapping of the dataspace to buffer contents for RAW12 is as - * follows: - * - * Dataspace value | Buffer contents - * -------------------------------+----------------------------------------- - * Dataspace::ARBITRARY | Raw image sensor data. - * Other | Unsupported - */ - RAW12 = 38 /* 0x26 */, - /** - * 0x27 to 0x2A are reserved for flexible formats - * - * - * 32-bit packed format that has 2-bit A, 10-bit B, G, and R components, - * in that order, from the most-sigfinicant bits to the least-significant - * bits. - * - * The component values are unsigned normalized to the range [0, 1], whose - * interpretation is defined by the dataspace. - */ - RGBA_1010102 = 43 /* 0x2B */, - /** - * 0x100 - 0x1FF - * - * This range is reserved for vendor extensions. Formats in this range - * must support BufferUsage::GPU_TEXTURE. Clients must assume they do not - * have an alpha component. - * - * - * Y8 is a YUV planar format comprised of a WxH Y plane, with each pixel - * being represented by 8 bits. It is equivalent to just the Y plane from - * YV12. - * - * This format assumes - * - an even width - * - an even height - * - a horizontal stride multiple of 16 pixels - * - a vertical stride equal to the height - * - * size = stride * height - * - * This format must be accepted by the allocator when used with the - * following usage flags: - * - * - BufferUsage::CAMERA_* - * - BufferUsage::CPU_* - * - * The component values are unsigned normalized to the range [0, 1], whose - * interpretation is defined by the dataspace. - */ - Y8 = 538982489 /* 0x20203859 */, - /** - * Y16 is a YUV planar format comprised of a WxH Y plane, with each pixel - * being represented by 16 bits. It is just like Y8, but has double the - * bits per pixel (little endian). - * - * This format assumes - * - an even width - * - an even height - * - a horizontal stride multiple of 16 pixels - * - a vertical stride equal to the height - * - strides are specified in pixels, not in bytes - * - * size = stride * height * 2 - * - * This format must be accepted by the allocator when used with the - * following usage flags: - * - * - BufferUsage::CAMERA_* - * - BufferUsage::CPU_* - * - * The component values are unsigned normalized to the range [0, 1], whose - * interpretation is defined by the dataspace. When the dataspace is - * Dataspace::DEPTH, each pixel is a distance value measured by a depth - * camera, plus an associated confidence value. - */ - Y16 = 540422489 /* 0x20363159 */, - /** - * YV12 is a 4:2:0 YCrCb planar format comprised of a WxH Y plane followed - * by (W/2) x (H/2) Cr and Cb planes. - * - * This format assumes - * - an even width - * - an even height - * - a horizontal stride multiple of 16 pixels - * - a vertical stride equal to the height - * - * y_size = stride * height - * c_stride = ALIGN(stride/2, 16) - * c_size = c_stride * height/2 - * size = y_size + c_size * 2 - * cr_offset = y_size - * cb_offset = y_size + c_size - * - * This range is reserved for vendor extensions. Formats in this range - * must support BufferUsage::GPU_TEXTURE. Clients must assume they do not - * have an alpha component. - * - * This format must be accepted by the allocator when used with the - * following usage flags: - * - * - BufferUsage::CAMERA_* - * - BufferUsage::CPU_* - * - BufferUsage::GPU_TEXTURE - * - * The component values are unsigned normalized to the range [0, 1], whose - * interpretation is defined by the dataspace. - */ - YV12 = 842094169 /* 0x32315659 */, -}; - -/** - * Buffer usage definitions. - */ -enum class BufferUsage : uint64_t { - /** - * bit 0-3 is an enum - */ - CPU_READ_MASK = 15ull /* 0xfULL */, - /** - * buffer is never read by CPU - */ - CPU_READ_NEVER = 0ull, - /** - * buffer is rarely read by CPU - */ - CPU_READ_RARELY = 2ull, - /** - * buffer is often read by CPU - */ - CPU_READ_OFTEN = 3ull, - /** - * bit 4-7 is an enum - */ - CPU_WRITE_MASK = 240ull /* (0xfULL << 4) */, - /** - * buffer is never written by CPU - */ - CPU_WRITE_NEVER = 0ull /* (0 << 4) */, - /** - * buffer is rarely written by CPU - */ - CPU_WRITE_RARELY = 32ull /* (2 << 4) */, - /** - * buffer is often written by CPU - */ - CPU_WRITE_OFTEN = 48ull /* (3 << 4) */, - /** - * buffer is used as a GPU texture - */ - GPU_TEXTURE = 256ull /* (1ULL << 8) */, - /** - * buffer is used as a GPU render target - */ - GPU_RENDER_TARGET = 512ull /* (1ULL << 9) */, - /** - * bit 10 must be zero - * - * - * buffer is used as a composer HAL overlay layer - */ - COMPOSER_OVERLAY = 2048ull /* (1ULL << 11) */, - /** - * buffer is used as a composer HAL client target - */ - COMPOSER_CLIENT_TARGET = 4096ull /* (1ULL << 12) */, - /** - * bit 13 must be zero - * - * - * Buffer is allocated with hardware-level protection against copying the - * contents (or information derived from the contents) into unprotected - * memory. - */ - PROTECTED = 16384ull /* (1ULL << 14) */, - /** - * buffer is used as a hwcomposer HAL cursor layer - */ - COMPOSER_CURSOR = 32768ull /* (1ULL << 15) */, - /** - * buffer is used as a video encoder input - */ - VIDEO_ENCODER = 65536ull /* (1ULL << 16) */, - /** - * buffer is used as a camera HAL output - */ - CAMERA_OUTPUT = 131072ull /* (1ULL << 17) */, - /** - * buffer is used as a camera HAL input - */ - CAMERA_INPUT = 262144ull /* (1ULL << 18) */, - /** - * bit 19 must be zero - * - * - * buffer is used as a renderscript allocation - */ - RENDERSCRIPT = 1048576ull /* (1ULL << 20) */, - /** - * bit 21 must be zero - * - * - * buffer is used as a video decoder output - */ - VIDEO_DECODER = 4194304ull /* (1ULL << 22) */, - /** - * buffer is used as a sensor direct report output - */ - SENSOR_DIRECT_DATA = 8388608ull /* (1ULL << 23) */, - /** - * buffer is used as as an OpenGL shader storage or uniform - * buffer object - */ - GPU_DATA_BUFFER = 16777216ull /* (1ULL << 24) */, - /** - * bits 25-27 must be zero and are reserved for future versions - * - * - * bits 28-31 are reserved for vendor extensions - */ - VENDOR_MASK = 4026531840ull /* (0xfULL << 28) */, - /** - * bits 32-47 must be zero and are reserved for future versions - * - * - * bits 48-63 are reserved for vendor extensions - */ - VENDOR_MASK_HI = 18446462598732840960ull /* (0xffffULL << 48) */, -}; - -/** - * Transformation definitions - */ -enum class Transform : int32_t { - /** - * Horizontal flip. FLIP_H/FLIP_V is applied before ROT_90. - */ - FLIP_H = 1 /* (1 << 0) */, - /** - * Vertical flip. FLIP_H/FLIP_V is applied before ROT_90. - */ - FLIP_V = 2 /* (1 << 1) */, - /** - * 90 degree clockwise rotation. FLIP_H/FLIP_V is applied before ROT_90. - */ - ROT_90 = 4 /* (1 << 2) */, - /** - * Commonly used combinations. - */ - ROT_180 = 3 /* (FLIP_H | FLIP_V) */, - ROT_270 = 7 /* ((FLIP_H | FLIP_V) | ROT_90) */, -}; - -/** - * Dataspace Definitions - * ====================== - * - * Dataspace is the definition of how pixel values should be interpreted. - * - * For many formats, this is the colorspace of the image data, which includes - * primaries (including white point) and the transfer characteristic function, - * which describes both gamma curve and numeric range (within the bit depth). - * - * Other dataspaces include depth measurement data from a depth camera. - * - * A dataspace is comprised of a number of fields. - * - * Version - * -------- - * The top 2 bits represent the revision of the field specification. This is - * currently always 0. - * - * - * bits 31-30 29 - 0 - * +-----+----------------------------------------------------+ - * fields | Rev | Revision specific fields | - * +-----+----------------------------------------------------+ - * - * Field layout for version = 0: - * ---------------------------- - * - * A dataspace is comprised of the following fields: - * Standard - * Transfer function - * Range - * - * bits 31-30 29-27 26 - 22 21 - 16 15 - 0 - * +-----+-----+--------+--------+----------------------------+ - * fields | 0 |Range|Transfer|Standard| Legacy and custom | - * +-----+-----+--------+--------+----------------------------+ - * VV RRR TTTTT SSSSSS LLLLLLLL LLLLLLLL - * - * If range, transfer and standard fields are all 0 (e.g. top 16 bits are - * all zeroes), the bottom 16 bits contain either a legacy dataspace value, - * or a custom value. - */ -enum class Dataspace : int32_t { - /** - * Default-assumption data space, when not explicitly specified. - * - * It is safest to assume the buffer is an image with sRGB primaries and - * encoding ranges, but the consumer and/or the producer of the data may - * simply be using defaults. No automatic gamma transform should be - * expected, except for a possible display gamma transform when drawn to a - * screen. - */ - UNKNOWN = 0 /* 0x0 */, - /** - * Arbitrary dataspace with manually defined characteristics. Definition - * for colorspaces or other meaning must be communicated separately. - * - * This is used when specifying primaries, transfer characteristics, - * etc. separately. - * - * A typical use case is in video encoding parameters (e.g. for H.264), - * where a colorspace can have separately defined primaries, transfer - * characteristics, etc. - */ - ARBITRARY = 1 /* 0x1 */, - /** - * Color-description aspects - * - * The following aspects define various characteristics of the color - * specification. These represent bitfields, so that a data space value - * can specify each of them independently. - */ - STANDARD_SHIFT = 16, - /** - * Standard aspect - * - * Defines the chromaticity coordinates of the source primaries in terms of - * the CIE 1931 definition of x and y specified in ISO 11664-1. - */ - STANDARD_MASK = 4128768 /* (63 << STANDARD_SHIFT) */, - /** - * Chromacity coordinates are unknown or are determined by the application. - * Implementations shall use the following suggested standards: - * - * All YCbCr formats: BT709 if size is 720p or larger (since most video - * content is letterboxed this corresponds to width is - * 1280 or greater, or height is 720 or greater). - * BT601_625 if size is smaller than 720p or is JPEG. - * All RGB formats: BT709. - * - * For all other formats standard is undefined, and implementations should use - * an appropriate standard for the data represented. - */ - STANDARD_UNSPECIFIED = 0 /* (0 << STANDARD_SHIFT) */, - /** - * Primaries: x y - * green 0.300 0.600 - * blue 0.150 0.060 - * red 0.640 0.330 - * white (D65) 0.3127 0.3290 - * - * Use the unadjusted KR = 0.2126, KB = 0.0722 luminance interpretation - * for RGB conversion. - */ - STANDARD_BT709 = 65536 /* (1 << STANDARD_SHIFT) */, - /** - * Primaries: x y - * green 0.290 0.600 - * blue 0.150 0.060 - * red 0.640 0.330 - * white (D65) 0.3127 0.3290 - * - * KR = 0.299, KB = 0.114. This adjusts the luminance interpretation - * for RGB conversion from the one purely determined by the primaries - * to minimize the color shift into RGB space that uses BT.709 - * primaries. - */ - STANDARD_BT601_625 = 131072 /* (2 << STANDARD_SHIFT) */, - /** - * Primaries: x y - * green 0.290 0.600 - * blue 0.150 0.060 - * red 0.640 0.330 - * white (D65) 0.3127 0.3290 - * - * Use the unadjusted KR = 0.222, KB = 0.071 luminance interpretation - * for RGB conversion. - */ - STANDARD_BT601_625_UNADJUSTED = 196608 /* (3 << STANDARD_SHIFT) */, - /** - * Primaries: x y - * green 0.310 0.595 - * blue 0.155 0.070 - * red 0.630 0.340 - * white (D65) 0.3127 0.3290 - * - * KR = 0.299, KB = 0.114. This adjusts the luminance interpretation - * for RGB conversion from the one purely determined by the primaries - * to minimize the color shift into RGB space that uses BT.709 - * primaries. - */ - STANDARD_BT601_525 = 262144 /* (4 << STANDARD_SHIFT) */, - /** - * Primaries: x y - * green 0.310 0.595 - * blue 0.155 0.070 - * red 0.630 0.340 - * white (D65) 0.3127 0.3290 - * - * Use the unadjusted KR = 0.212, KB = 0.087 luminance interpretation - * for RGB conversion (as in SMPTE 240M). - */ - STANDARD_BT601_525_UNADJUSTED = 327680 /* (5 << STANDARD_SHIFT) */, - /** - * Primaries: x y - * green 0.170 0.797 - * blue 0.131 0.046 - * red 0.708 0.292 - * white (D65) 0.3127 0.3290 - * - * Use the unadjusted KR = 0.2627, KB = 0.0593 luminance interpretation - * for RGB conversion. - */ - STANDARD_BT2020 = 393216 /* (6 << STANDARD_SHIFT) */, - /** - * Primaries: x y - * green 0.170 0.797 - * blue 0.131 0.046 - * red 0.708 0.292 - * white (D65) 0.3127 0.3290 - * - * Use the unadjusted KR = 0.2627, KB = 0.0593 luminance interpretation - * for RGB conversion using the linear domain. - */ - STANDARD_BT2020_CONSTANT_LUMINANCE = 458752 /* (7 << STANDARD_SHIFT) */, - /** - * Primaries: x y - * green 0.21 0.71 - * blue 0.14 0.08 - * red 0.67 0.33 - * white (C) 0.310 0.316 - * - * Use the unadjusted KR = 0.30, KB = 0.11 luminance interpretation - * for RGB conversion. - */ - STANDARD_BT470M = 524288 /* (8 << STANDARD_SHIFT) */, - /** - * Primaries: x y - * green 0.243 0.692 - * blue 0.145 0.049 - * red 0.681 0.319 - * white (C) 0.310 0.316 - * - * Use the unadjusted KR = 0.254, KB = 0.068 luminance interpretation - * for RGB conversion. - */ - STANDARD_FILM = 589824 /* (9 << STANDARD_SHIFT) */, - /** - * SMPTE EG 432-1 and SMPTE RP 431-2. (DCI-P3) - * Primaries: x y - * green 0.265 0.690 - * blue 0.150 0.060 - * red 0.680 0.320 - * white (D65) 0.3127 0.3290 - */ - STANDARD_DCI_P3 = 655360 /* (10 << STANDARD_SHIFT) */, - /** - * Adobe RGB - * Primaries: x y - * green 0.210 0.710 - * blue 0.150 0.060 - * red 0.640 0.330 - * white (D65) 0.3127 0.3290 - */ - STANDARD_ADOBE_RGB = 720896 /* (11 << STANDARD_SHIFT) */, - TRANSFER_SHIFT = 22, - /** - * Transfer aspect - * - * Transfer characteristics are the opto-electronic transfer characteristic - * at the source as a function of linear optical intensity (luminance). - * - * For digital signals, E corresponds to the recorded value. Normally, the - * transfer function is applied in RGB space to each of the R, G and B - * components independently. This may result in color shift that can be - * minized by applying the transfer function in Lab space only for the L - * component. Implementation may apply the transfer function in RGB space - * for all pixel formats if desired. - */ - TRANSFER_MASK = 130023424 /* (31 << TRANSFER_SHIFT) */, - /** - * Transfer characteristics are unknown or are determined by the - * application. - * - * Implementations should use the following transfer functions: - * - * For YCbCr formats: use TRANSFER_SMPTE_170M - * For RGB formats: use TRANSFER_SRGB - * - * For all other formats transfer function is undefined, and implementations - * should use an appropriate standard for the data represented. - */ - TRANSFER_UNSPECIFIED = 0 /* (0 << TRANSFER_SHIFT) */, - /** - * Transfer characteristic curve: - * E = L - * L - luminance of image 0 <= L <= 1 for conventional colorimetry - * E - corresponding electrical signal - */ - TRANSFER_LINEAR = 4194304 /* (1 << TRANSFER_SHIFT) */, - /** - * Transfer characteristic curve: - * - * E = 1.055 * L^(1/2.4) - 0.055 for 0.0031308 <= L <= 1 - * = 12.92 * L for 0 <= L < 0.0031308 - * L - luminance of image 0 <= L <= 1 for conventional colorimetry - * E - corresponding electrical signal - */ - TRANSFER_SRGB = 8388608 /* (2 << TRANSFER_SHIFT) */, - /** - * BT.601 525, BT.601 625, BT.709, BT.2020 - * - * Transfer characteristic curve: - * E = 1.099 * L ^ 0.45 - 0.099 for 0.018 <= L <= 1 - * = 4.500 * L for 0 <= L < 0.018 - * L - luminance of image 0 <= L <= 1 for conventional colorimetry - * E - corresponding electrical signal - */ - TRANSFER_SMPTE_170M = 12582912 /* (3 << TRANSFER_SHIFT) */, - /** - * Assumed display gamma 2.2. - * - * Transfer characteristic curve: - * E = L ^ (1/2.2) - * L - luminance of image 0 <= L <= 1 for conventional colorimetry - * E - corresponding electrical signal - */ - TRANSFER_GAMMA2_2 = 16777216 /* (4 << TRANSFER_SHIFT) */, - /** - * display gamma 2.6. - * - * Transfer characteristic curve: - * E = L ^ (1/2.6) - * L - luminance of image 0 <= L <= 1 for conventional colorimetry - * E - corresponding electrical signal - */ - TRANSFER_GAMMA2_6 = 20971520 /* (5 << TRANSFER_SHIFT) */, - /** - * display gamma 2.8. - * - * Transfer characteristic curve: - * E = L ^ (1/2.8) - * L - luminance of image 0 <= L <= 1 for conventional colorimetry - * E - corresponding electrical signal - */ - TRANSFER_GAMMA2_8 = 25165824 /* (6 << TRANSFER_SHIFT) */, - /** - * SMPTE ST 2084 (Dolby Perceptual Quantizer) - * - * Transfer characteristic curve: - * E = ((c1 + c2 * L^n) / (1 + c3 * L^n)) ^ m - * c1 = c3 - c2 + 1 = 3424 / 4096 = 0.8359375 - * c2 = 32 * 2413 / 4096 = 18.8515625 - * c3 = 32 * 2392 / 4096 = 18.6875 - * m = 128 * 2523 / 4096 = 78.84375 - * n = 0.25 * 2610 / 4096 = 0.1593017578125 - * L - luminance of image 0 <= L <= 1 for HDR colorimetry. - * L = 1 corresponds to 10000 cd/m2 - * E - corresponding electrical signal - */ - TRANSFER_ST2084 = 29360128 /* (7 << TRANSFER_SHIFT) */, - /** - * ARIB STD-B67 Hybrid Log Gamma - * - * Transfer characteristic curve: - * E = r * L^0.5 for 0 <= L <= 1 - * = a * ln(L - b) + c for 1 < L - * a = 0.17883277 - * b = 0.28466892 - * c = 0.55991073 - * r = 0.5 - * L - luminance of image 0 <= L for HDR colorimetry. L = 1 corresponds - * to reference white level of 100 cd/m2 - * E - corresponding electrical signal - */ - TRANSFER_HLG = 33554432 /* (8 << TRANSFER_SHIFT) */, - RANGE_SHIFT = 27, - /** - * Range aspect - * - * Defines the range of values corresponding to the unit range of 0-1. - * This is defined for YCbCr only, but can be expanded to RGB space. - */ - RANGE_MASK = 939524096 /* (7 << RANGE_SHIFT) */, - /** - * Range is unknown or are determined by the application. Implementations - * shall use the following suggested ranges: - * - * All YCbCr formats: limited range. - * All RGB or RGBA formats (including RAW and Bayer): full range. - * All Y formats: full range - * - * For all other formats range is undefined, and implementations should use - * an appropriate range for the data represented. - */ - RANGE_UNSPECIFIED = 0 /* (0 << RANGE_SHIFT) */, - /** - * Full range uses all values for Y, Cb and Cr from - * 0 to 2^b-1, where b is the bit depth of the color format. - */ - RANGE_FULL = 134217728 /* (1 << RANGE_SHIFT) */, - /** - * Limited range uses values 16/256*2^b to 235/256*2^b for Y, and - * 1/16*2^b to 15/16*2^b for Cb, Cr, R, G and B, where b is the bit depth of - * the color format. - * - * E.g. For 8-bit-depth formats: - * Luma (Y) samples should range from 16 to 235, inclusive - * Chroma (Cb, Cr) samples should range from 16 to 240, inclusive - * - * For 10-bit-depth formats: - * Luma (Y) samples should range from 64 to 940, inclusive - * Chroma (Cb, Cr) samples should range from 64 to 960, inclusive - */ - RANGE_LIMITED = 268435456 /* (2 << RANGE_SHIFT) */, - /** - * Extended range is used for scRGB. Intended for use with - * floating point pixel formats. [0.0 - 1.0] is the standard - * sRGB space. Values outside the range 0.0 - 1.0 can encode - * color outside the sRGB gamut. - * Used to blend / merge multiple dataspaces on a single display. - */ - RANGE_EXTENDED = 402653184 /* (3 << RANGE_SHIFT) */, - /** - * Legacy dataspaces - * - * - * sRGB linear encoding: - * - * The red, green, and blue components are stored in sRGB space, but - * are linear, not gamma-encoded. - * The RGB primaries and the white point are the same as BT.709. - * - * The values are encoded using the full range ([0,255] for 8-bit) for all - * components. - */ - SRGB_LINEAR = 512 /* 0x200 */, - V0_SRGB_LINEAR = 138477568 /* ((STANDARD_BT709 | TRANSFER_LINEAR) | RANGE_FULL) */, - /** - * scRGB linear encoding: - * - * The red, green, and blue components are stored in extended sRGB space, - * but are linear, not gamma-encoded. - * The RGB primaries and the white point are the same as BT.709. - * - * The values are floating point. - * A pixel value of 1.0, 1.0, 1.0 corresponds to sRGB white (D65) at 80 nits. - * Values beyond the range [0.0 - 1.0] would correspond to other colors - * spaces and/or HDR content. - */ - V0_SCRGB_LINEAR = 406913024 /* ((STANDARD_BT709 | TRANSFER_LINEAR) | RANGE_EXTENDED) */, - /** - * sRGB gamma encoding: - * - * The red, green and blue components are stored in sRGB space, and - * converted to linear space when read, using the SRGB transfer function - * for each of the R, G and B components. When written, the inverse - * transformation is performed. - * - * The alpha component, if present, is always stored in linear space and - * is left unmodified when read or written. - * - * Use full range and BT.709 standard. - */ - SRGB = 513 /* 0x201 */, - V0_SRGB = 142671872 /* ((STANDARD_BT709 | TRANSFER_SRGB) | RANGE_FULL) */, - /** - * scRGB: - * - * The red, green, and blue components are stored in extended sRGB space, - * but are linear, not gamma-encoded. - * The RGB primaries and the white point are the same as BT.709. - * - * The values are floating point. - * A pixel value of 1.0, 1.0, 1.0 corresponds to sRGB white (D65) at 80 nits. - * Values beyond the range [0.0 - 1.0] would correspond to other colors - * spaces and/or HDR content. - */ - V0_SCRGB = 411107328 /* ((STANDARD_BT709 | TRANSFER_SRGB) | RANGE_EXTENDED) */, - /** - * YCbCr Colorspaces - * ----------------- - * - * Primaries are given using (x,y) coordinates in the CIE 1931 definition - * of x and y specified by ISO 11664-1. - * - * Transfer characteristics are the opto-electronic transfer characteristic - * at the source as a function of linear optical intensity (luminance). - * - * - * JPEG File Interchange Format (JFIF) - * - * Same model as BT.601-625, but all values (Y, Cb, Cr) range from 0 to 255 - * - * Use full range, BT.601 transfer and BT.601_625 standard. - */ - JFIF = 257 /* 0x101 */, - V0_JFIF = 146931712 /* ((STANDARD_BT601_625 | TRANSFER_SMPTE_170M) | RANGE_FULL) */, - /** - * ITU-R Recommendation 601 (BT.601) - 625-line - * - * Standard-definition television, 625 Lines (PAL) - * - * Use limited range, BT.601 transfer and BT.601_625 standard. - */ - BT601_625 = 258 /* 0x102 */, - V0_BT601_625 = 281149440 /* ((STANDARD_BT601_625 | TRANSFER_SMPTE_170M) | RANGE_LIMITED) */, - /** - * ITU-R Recommendation 601 (BT.601) - 525-line - * - * Standard-definition television, 525 Lines (NTSC) - * - * Use limited range, BT.601 transfer and BT.601_525 standard. - */ - BT601_525 = 259 /* 0x103 */, - V0_BT601_525 = 281280512 /* ((STANDARD_BT601_525 | TRANSFER_SMPTE_170M) | RANGE_LIMITED) */, - /** - * ITU-R Recommendation 709 (BT.709) - * - * High-definition television - * - * Use limited range, BT.709 transfer and BT.709 standard. - */ - BT709 = 260 /* 0x104 */, - V0_BT709 = 281083904 /* ((STANDARD_BT709 | TRANSFER_SMPTE_170M) | RANGE_LIMITED) */, - /** - * SMPTE EG 432-1 and SMPTE RP 431-2. - * - * Digital Cinema DCI-P3 - * - * Use full range, linear transfer and D65 DCI-P3 standard - */ - DCI_P3_LINEAR = 139067392 /* ((STANDARD_DCI_P3 | TRANSFER_LINEAR) | RANGE_FULL) */, - /** - * SMPTE EG 432-1 and SMPTE RP 431-2. - * - * Digital Cinema DCI-P3 - * - * Use full range, gamma 2.6 transfer and D65 DCI-P3 standard - * Note: Application is responsible for gamma encoding the data as - * a 2.6 gamma encoding is not supported in HW. - */ - DCI_P3 = 155844608 /* ((STANDARD_DCI_P3 | TRANSFER_GAMMA2_6) | RANGE_FULL) */, - /** - * Display P3 - * - * Display P3 uses same primaries and white-point as DCI-P3 - * linear transfer function makes this the same as DCI_P3_LINEAR. - */ - DISPLAY_P3_LINEAR = 139067392 /* ((STANDARD_DCI_P3 | TRANSFER_LINEAR) | RANGE_FULL) */, - /** - * Display P3 - * - * Use same primaries and white-point as DCI-P3 - * but sRGB transfer function. - */ - DISPLAY_P3 = 143261696 /* ((STANDARD_DCI_P3 | TRANSFER_SRGB) | RANGE_FULL) */, - /** - * Adobe RGB - * - * Use full range, gamma 2.2 transfer and Adobe RGB primaries - * Note: Application is responsible for gamma encoding the data as - * a 2.2 gamma encoding is not supported in HW. - */ - ADOBE_RGB = 151715840 /* ((STANDARD_ADOBE_RGB | TRANSFER_GAMMA2_2) | RANGE_FULL) */, - /** - * ITU-R Recommendation 2020 (BT.2020) - * - * Ultra High-definition television - * - * Use full range, linear transfer and BT2020 standard - */ - BT2020_LINEAR = 138805248 /* ((STANDARD_BT2020 | TRANSFER_LINEAR) | RANGE_FULL) */, - /** - * ITU-R Recommendation 2020 (BT.2020) - * - * Ultra High-definition television - * - * Use full range, BT.709 transfer and BT2020 standard - */ - BT2020 = 147193856 /* ((STANDARD_BT2020 | TRANSFER_SMPTE_170M) | RANGE_FULL) */, - /** - * ITU-R Recommendation 2020 (BT.2020) - * - * Ultra High-definition television - * - * Use full range, SMPTE 2084 (PQ) transfer and BT2020 standard - */ - BT2020_PQ = 163971072 /* ((STANDARD_BT2020 | TRANSFER_ST2084) | RANGE_FULL) */, - /** - * Data spaces for non-color formats - * - * - * The buffer contains depth ranging measurements from a depth camera. - * This value is valid with formats: - * HAL_PIXEL_FORMAT_Y16: 16-bit samples, consisting of a depth measurement - * and an associated confidence value. The 3 MSBs of the sample make - * up the confidence value, and the low 13 LSBs of the sample make up - * the depth measurement. - * For the confidence section, 0 means 100% confidence, 1 means 0% - * confidence. The mapping to a linear float confidence value between - * 0.f and 1.f can be obtained with - * float confidence = (((depthSample >> 13) - 1) & 0x7) / 7.0f; - * The depth measurement can be extracted simply with - * uint16_t range = (depthSample & 0x1FFF); - * HAL_PIXEL_FORMAT_BLOB: A depth point cloud, as - * a variable-length float (x,y,z, confidence) coordinate point list. - * The point cloud will be represented with the android_depth_points - * structure. - */ - DEPTH = 4096 /* 0x1000 */, - /** - * The buffer contains sensor events from sensor direct report. - * This value is valid with formats: - * HAL_PIXEL_FORMAT_BLOB: an array of sensor event structure that forms - * a lock free queue. Format of sensor event structure is specified - * in Sensors HAL. - */ - SENSOR = 4097 /* 0x1001 */, -}; - -/** - * Color modes that may be supported by a display. - * - * Definitions: - * Rendering intent generally defines the goal in mapping a source (input) - * color to a destination device color for a given color mode. - * - * It is important to keep in mind three cases where mapping may be applied: - * 1. The source gamut is much smaller than the destination (display) gamut - * 2. The source gamut is much larger than the destination gamut (this will - * ordinarily be handled using colorimetric rendering, below) - * 3. The source and destination gamuts are roughly equal, although not - * completely overlapping - * Also, a common requirement for mappings is that skin tones should be - * preserved, or at least remain natural in appearance. - * - * Colorimetric Rendering Intent (All cases): - * Colorimetric indicates that colors should be preserved. In the case - * that the source gamut lies wholly within the destination gamut or is - * about the same (#1, #3), this will simply mean that no manipulations - * (no saturation boost, for example) are applied. In the case where some - * source colors lie outside the destination gamut (#2, #3), those will - * need to be mapped to colors that are within the destination gamut, - * while the already in-gamut colors remain unchanged. - * - * Non-colorimetric transforms can take many forms. There are no hard - * rules and it's left to the implementation to define. - * Two common intents are described below. - * - * Stretched-Gamut Enhancement Intent (Source < Destination): - * When the destination gamut is much larger than the source gamut (#1), the - * source primaries may be redefined to reflect the full extent of the - * destination space, or to reflect an intermediate gamut. - * Skin-tone preservation would likely be applied. An example might be sRGB - * input displayed on a DCI-P3 capable device, with skin-tone preservation. - * - * Within-Gamut Enhancement Intent (Source >= Destination): - * When the device (destination) gamut is not larger than the source gamut - * (#2 or #3), but the appearance of a larger gamut is desired, techniques - * such as saturation boost may be applied to the source colors. Skin-tone - * preservation may be applied. There is no unique method for within-gamut - * enhancement; it would be defined within a flexible color mode. - * - */ -enum class ColorMode : int32_t { - /** - * DEFAULT is the "native" gamut of the display. - * White Point: Vendor/OEM defined - * Panel Gamma: Vendor/OEM defined (typically 2.2) - * Rendering Intent: Vendor/OEM defined (typically 'enhanced') - */ - NATIVE = 0, - /** - * STANDARD_BT601_625 corresponds with display - * settings that implement the ITU-R Recommendation BT.601 - * or Rec 601. Using 625 line version - * Rendering Intent: Colorimetric - * Primaries: - * x y - * green 0.290 0.600 - * blue 0.150 0.060 - * red 0.640 0.330 - * white (D65) 0.3127 0.3290 - * - * KR = 0.299, KB = 0.114. This adjusts the luminance interpretation - * for RGB conversion from the one purely determined by the primaries - * to minimize the color shift into RGB space that uses BT.709 - * primaries. - * - * Gamma Correction (GC): - * - * if Vlinear < 0.018 - * Vnonlinear = 4.500 * Vlinear - * else - * Vnonlinear = 1.099 * (Vlinear)^(0.45) – 0.099 - */ - STANDARD_BT601_625 = 1, - /** - * Primaries: - * x y - * green 0.290 0.600 - * blue 0.150 0.060 - * red 0.640 0.330 - * white (D65) 0.3127 0.3290 - * - * Use the unadjusted KR = 0.222, KB = 0.071 luminance interpretation - * for RGB conversion. - * - * Gamma Correction (GC): - * - * if Vlinear < 0.018 - * Vnonlinear = 4.500 * Vlinear - * else - * Vnonlinear = 1.099 * (Vlinear)^(0.45) – 0.099 - */ - STANDARD_BT601_625_UNADJUSTED = 2, - /** - * Primaries: - * x y - * green 0.310 0.595 - * blue 0.155 0.070 - * red 0.630 0.340 - * white (D65) 0.3127 0.3290 - * - * KR = 0.299, KB = 0.114. This adjusts the luminance interpretation - * for RGB conversion from the one purely determined by the primaries - * to minimize the color shift into RGB space that uses BT.709 - * primaries. - * - * Gamma Correction (GC): - * - * if Vlinear < 0.018 - * Vnonlinear = 4.500 * Vlinear - * else - * Vnonlinear = 1.099 * (Vlinear)^(0.45) – 0.099 - */ - STANDARD_BT601_525 = 3, - /** - * Primaries: - * x y - * green 0.310 0.595 - * blue 0.155 0.070 - * red 0.630 0.340 - * white (D65) 0.3127 0.3290 - * - * Use the unadjusted KR = 0.212, KB = 0.087 luminance interpretation - * for RGB conversion (as in SMPTE 240M). - * - * Gamma Correction (GC): - * - * if Vlinear < 0.018 - * Vnonlinear = 4.500 * Vlinear - * else - * Vnonlinear = 1.099 * (Vlinear)^(0.45) – 0.099 - */ - STANDARD_BT601_525_UNADJUSTED = 4, - /** - * REC709 corresponds with display settings that implement - * the ITU-R Recommendation BT.709 / Rec. 709 for high-definition television. - * Rendering Intent: Colorimetric - * Primaries: - * x y - * green 0.300 0.600 - * blue 0.150 0.060 - * red 0.640 0.330 - * white (D65) 0.3127 0.3290 - * - * HDTV REC709 Inverse Gamma Correction (IGC): V represents normalized - * (with [0 to 1] range) value of R, G, or B. - * - * if Vnonlinear < 0.081 - * Vlinear = Vnonlinear / 4.5 - * else - * Vlinear = ((Vnonlinear + 0.099) / 1.099) ^ (1/0.45) - * - * HDTV REC709 Gamma Correction (GC): - * - * if Vlinear < 0.018 - * Vnonlinear = 4.5 * Vlinear - * else - * Vnonlinear = 1.099 * (Vlinear) ^ 0.45 – 0.099 - */ - STANDARD_BT709 = 5, - /** - * DCI_P3 corresponds with display settings that implement - * SMPTE EG 432-1 and SMPTE RP 431-2 - * Rendering Intent: Colorimetric - * Primaries: - * x y - * green 0.265 0.690 - * blue 0.150 0.060 - * red 0.680 0.320 - * white (D65) 0.3127 0.3290 - * - * Gamma: 2.6 - */ - DCI_P3 = 6, - /** - * SRGB corresponds with display settings that implement - * the sRGB color space. Uses the same primaries as ITU-R Recommendation - * BT.709 - * Rendering Intent: Colorimetric - * Primaries: - * x y - * green 0.300 0.600 - * blue 0.150 0.060 - * red 0.640 0.330 - * white (D65) 0.3127 0.3290 - * - * PC/Internet (sRGB) Inverse Gamma Correction (IGC): - * - * if Vnonlinear ≤ 0.03928 - * Vlinear = Vnonlinear / 12.92 - * else - * Vlinear = ((Vnonlinear + 0.055)/1.055) ^ 2.4 - * - * PC/Internet (sRGB) Gamma Correction (GC): - * - * if Vlinear ≤ 0.0031308 - * Vnonlinear = 12.92 * Vlinear - * else - * Vnonlinear = 1.055 * (Vlinear)^(1/2.4) – 0.055 - */ - SRGB = 7, - /** - * ADOBE_RGB corresponds with the RGB color space developed - * by Adobe Systems, Inc. in 1998. - * Rendering Intent: Colorimetric - * Primaries: - * x y - * green 0.210 0.710 - * blue 0.150 0.060 - * red 0.640 0.330 - * white (D65) 0.3127 0.3290 - * - * Gamma: 2.2 - */ - ADOBE_RGB = 8, - /** - * DISPLAY_P3 is a color space that uses the DCI_P3 primaries, - * the D65 white point and the SRGB transfer functions. - * Rendering Intent: Colorimetric - * Primaries: - * x y - * green 0.265 0.690 - * blue 0.150 0.060 - * red 0.680 0.320 - * white (D65) 0.3127 0.3290 - * - * PC/Internet (sRGB) Gamma Correction (GC): - * - * if Vlinear ≤ 0.0030186 - * Vnonlinear = 12.92 * Vlinear - * else - * Vnonlinear = 1.055 * (Vlinear)^(1/2.4) – 0.055 - * - * Note: In most cases sRGB transfer function will be fine. - */ - DISPLAY_P3 = 9, -}; - -/** - * Color transforms that may be applied by hardware composer to the whole - * display. - */ -enum class ColorTransform : int32_t { - /** - * Applies no transform to the output color - */ - IDENTITY = 0, - /** - * Applies an arbitrary transform defined by a 4x4 affine matrix - */ - ARBITRARY_MATRIX = 1, - /** - * Applies a transform that inverts the value or luminance of the color, but - * does not modify hue or saturation - */ - VALUE_INVERSE = 2, - /** - * Applies a transform that maps all colors to shades of gray - */ - GRAYSCALE = 3, - /** - * Applies a transform which corrects for protanopic color blindness - */ - CORRECT_PROTANOPIA = 4, - /** - * Applies a transform which corrects for deuteranopic color blindness - */ - CORRECT_DEUTERANOPIA = 5, - /** - * Applies a transform which corrects for tritanopic color blindness - */ - CORRECT_TRITANOPIA = 6, -}; - -/** - * Supported HDR formats. Must be kept in sync with equivalents in Display.java. - */ -enum class Hdr : int32_t { - /** - * Device supports Dolby Vision HDR - */ - DOLBY_VISION = 1, - /** - * Device supports HDR10 - */ - HDR10 = 2, - /** - * Device supports hybrid log-gamma HDR - */ - HLG = 3, -}; - -// -// type declarations for package -// - -template -static inline std::string toString(int32_t o); -static inline std::string toString(::android::hardware::graphics::common::V1_0::PixelFormat o); - -constexpr int32_t operator|(const ::android::hardware::graphics::common::V1_0::PixelFormat lhs, - const ::android::hardware::graphics::common::V1_0::PixelFormat rhs) { - return static_cast(static_cast(lhs) | static_cast(rhs)); -} -constexpr int32_t operator|(const int32_t lhs, - const ::android::hardware::graphics::common::V1_0::PixelFormat rhs) { - return static_cast(lhs | static_cast(rhs)); -} -constexpr int32_t operator|(const ::android::hardware::graphics::common::V1_0::PixelFormat lhs, - const int32_t rhs) { - return static_cast(static_cast(lhs) | rhs); -} -constexpr int32_t operator&(const ::android::hardware::graphics::common::V1_0::PixelFormat lhs, - const ::android::hardware::graphics::common::V1_0::PixelFormat rhs) { - return static_cast(static_cast(lhs) & static_cast(rhs)); -} -constexpr int32_t operator&(const int32_t lhs, - const ::android::hardware::graphics::common::V1_0::PixelFormat rhs) { - return static_cast(lhs & static_cast(rhs)); -} -constexpr int32_t operator&(const ::android::hardware::graphics::common::V1_0::PixelFormat lhs, - const int32_t rhs) { - return static_cast(static_cast(lhs) & rhs); -} -constexpr int32_t& operator|=(int32_t& v, - const ::android::hardware::graphics::common::V1_0::PixelFormat e) { - v |= static_cast(e); - return v; -} -constexpr int32_t& operator&=(int32_t& v, - const ::android::hardware::graphics::common::V1_0::PixelFormat e) { - v &= static_cast(e); - return v; -} - -template -static inline std::string toString(uint64_t o); -static inline std::string toString(::android::hardware::graphics::common::V1_0::BufferUsage o); - -constexpr uint64_t operator|(const ::android::hardware::graphics::common::V1_0::BufferUsage lhs, - const ::android::hardware::graphics::common::V1_0::BufferUsage rhs) { - return static_cast(static_cast(lhs) | static_cast(rhs)); -} -constexpr uint64_t operator|(const uint64_t lhs, - const ::android::hardware::graphics::common::V1_0::BufferUsage rhs) { - return static_cast(lhs | static_cast(rhs)); -} -constexpr uint64_t operator|(const ::android::hardware::graphics::common::V1_0::BufferUsage lhs, - const uint64_t rhs) { - return static_cast(static_cast(lhs) | rhs); -} -constexpr uint64_t operator&(const ::android::hardware::graphics::common::V1_0::BufferUsage lhs, - const ::android::hardware::graphics::common::V1_0::BufferUsage rhs) { - return static_cast(static_cast(lhs) & static_cast(rhs)); -} -constexpr uint64_t operator&(const uint64_t lhs, - const ::android::hardware::graphics::common::V1_0::BufferUsage rhs) { - return static_cast(lhs & static_cast(rhs)); -} -constexpr uint64_t operator&(const ::android::hardware::graphics::common::V1_0::BufferUsage lhs, - const uint64_t rhs) { - return static_cast(static_cast(lhs) & rhs); -} -constexpr uint64_t& operator|=(uint64_t& v, - const ::android::hardware::graphics::common::V1_0::BufferUsage e) { - v |= static_cast(e); - return v; -} -constexpr uint64_t& operator&=(uint64_t& v, - const ::android::hardware::graphics::common::V1_0::BufferUsage e) { - v &= static_cast(e); - return v; -} - -template -static inline std::string toString(int32_t o); -static inline std::string toString(::android::hardware::graphics::common::V1_0::Transform o); - -constexpr int32_t operator|(const ::android::hardware::graphics::common::V1_0::Transform lhs, - const ::android::hardware::graphics::common::V1_0::Transform rhs) { - return static_cast(static_cast(lhs) | static_cast(rhs)); -} -constexpr int32_t operator|(const int32_t lhs, - const ::android::hardware::graphics::common::V1_0::Transform rhs) { - return static_cast(lhs | static_cast(rhs)); -} -constexpr int32_t operator|(const ::android::hardware::graphics::common::V1_0::Transform lhs, - const int32_t rhs) { - return static_cast(static_cast(lhs) | rhs); -} -constexpr int32_t operator&(const ::android::hardware::graphics::common::V1_0::Transform lhs, - const ::android::hardware::graphics::common::V1_0::Transform rhs) { - return static_cast(static_cast(lhs) & static_cast(rhs)); -} -constexpr int32_t operator&(const int32_t lhs, - const ::android::hardware::graphics::common::V1_0::Transform rhs) { - return static_cast(lhs & static_cast(rhs)); -} -constexpr int32_t operator&(const ::android::hardware::graphics::common::V1_0::Transform lhs, - const int32_t rhs) { - return static_cast(static_cast(lhs) & rhs); -} -constexpr int32_t& operator|=(int32_t& v, - const ::android::hardware::graphics::common::V1_0::Transform e) { - v |= static_cast(e); - return v; -} -constexpr int32_t& operator&=(int32_t& v, - const ::android::hardware::graphics::common::V1_0::Transform e) { - v &= static_cast(e); - return v; -} - -template -static inline std::string toString(int32_t o); -static inline std::string toString(::android::hardware::graphics::common::V1_0::Dataspace o); - -constexpr int32_t operator|(const ::android::hardware::graphics::common::V1_0::Dataspace lhs, - const ::android::hardware::graphics::common::V1_0::Dataspace rhs) { - return static_cast(static_cast(lhs) | static_cast(rhs)); -} -constexpr int32_t operator|(const int32_t lhs, - const ::android::hardware::graphics::common::V1_0::Dataspace rhs) { - return static_cast(lhs | static_cast(rhs)); -} -constexpr int32_t operator|(const ::android::hardware::graphics::common::V1_0::Dataspace lhs, - const int32_t rhs) { - return static_cast(static_cast(lhs) | rhs); -} -constexpr int32_t operator&(const ::android::hardware::graphics::common::V1_0::Dataspace lhs, - const ::android::hardware::graphics::common::V1_0::Dataspace rhs) { - return static_cast(static_cast(lhs) & static_cast(rhs)); -} -constexpr int32_t operator&(const int32_t lhs, - const ::android::hardware::graphics::common::V1_0::Dataspace rhs) { - return static_cast(lhs & static_cast(rhs)); -} -constexpr int32_t operator&(const ::android::hardware::graphics::common::V1_0::Dataspace lhs, - const int32_t rhs) { - return static_cast(static_cast(lhs) & rhs); -} -constexpr int32_t& operator|=(int32_t& v, - const ::android::hardware::graphics::common::V1_0::Dataspace e) { - v |= static_cast(e); - return v; -} -constexpr int32_t& operator&=(int32_t& v, - const ::android::hardware::graphics::common::V1_0::Dataspace e) { - v &= static_cast(e); - return v; -} - -template -static inline std::string toString(int32_t o); -static inline std::string toString(::android::hardware::graphics::common::V1_0::ColorMode o); - -constexpr int32_t operator|(const ::android::hardware::graphics::common::V1_0::ColorMode lhs, - const ::android::hardware::graphics::common::V1_0::ColorMode rhs) { - return static_cast(static_cast(lhs) | static_cast(rhs)); -} -constexpr int32_t operator|(const int32_t lhs, - const ::android::hardware::graphics::common::V1_0::ColorMode rhs) { - return static_cast(lhs | static_cast(rhs)); -} -constexpr int32_t operator|(const ::android::hardware::graphics::common::V1_0::ColorMode lhs, - const int32_t rhs) { - return static_cast(static_cast(lhs) | rhs); -} -constexpr int32_t operator&(const ::android::hardware::graphics::common::V1_0::ColorMode lhs, - const ::android::hardware::graphics::common::V1_0::ColorMode rhs) { - return static_cast(static_cast(lhs) & static_cast(rhs)); -} -constexpr int32_t operator&(const int32_t lhs, - const ::android::hardware::graphics::common::V1_0::ColorMode rhs) { - return static_cast(lhs & static_cast(rhs)); -} -constexpr int32_t operator&(const ::android::hardware::graphics::common::V1_0::ColorMode lhs, - const int32_t rhs) { - return static_cast(static_cast(lhs) & rhs); -} -constexpr int32_t& operator|=(int32_t& v, - const ::android::hardware::graphics::common::V1_0::ColorMode e) { - v |= static_cast(e); - return v; -} -constexpr int32_t& operator&=(int32_t& v, - const ::android::hardware::graphics::common::V1_0::ColorMode e) { - v &= static_cast(e); - return v; -} - -template -static inline std::string toString(int32_t o); -static inline std::string toString(::android::hardware::graphics::common::V1_0::ColorTransform o); - -constexpr int32_t operator|(const ::android::hardware::graphics::common::V1_0::ColorTransform lhs, - const ::android::hardware::graphics::common::V1_0::ColorTransform rhs) { - return static_cast(static_cast(lhs) | static_cast(rhs)); -} -constexpr int32_t operator|(const int32_t lhs, - const ::android::hardware::graphics::common::V1_0::ColorTransform rhs) { - return static_cast(lhs | static_cast(rhs)); -} -constexpr int32_t operator|(const ::android::hardware::graphics::common::V1_0::ColorTransform lhs, - const int32_t rhs) { - return static_cast(static_cast(lhs) | rhs); -} -constexpr int32_t operator&(const ::android::hardware::graphics::common::V1_0::ColorTransform lhs, - const ::android::hardware::graphics::common::V1_0::ColorTransform rhs) { - return static_cast(static_cast(lhs) & static_cast(rhs)); -} -constexpr int32_t operator&(const int32_t lhs, - const ::android::hardware::graphics::common::V1_0::ColorTransform rhs) { - return static_cast(lhs & static_cast(rhs)); -} -constexpr int32_t operator&(const ::android::hardware::graphics::common::V1_0::ColorTransform lhs, - const int32_t rhs) { - return static_cast(static_cast(lhs) & rhs); -} -constexpr int32_t& operator|=(int32_t& v, - const ::android::hardware::graphics::common::V1_0::ColorTransform e) { - v |= static_cast(e); - return v; -} -constexpr int32_t& operator&=(int32_t& v, - const ::android::hardware::graphics::common::V1_0::ColorTransform e) { - v &= static_cast(e); - return v; -} - -template -static inline std::string toString(int32_t o); -static inline std::string toString(::android::hardware::graphics::common::V1_0::Hdr o); - -constexpr int32_t operator|(const ::android::hardware::graphics::common::V1_0::Hdr lhs, - const ::android::hardware::graphics::common::V1_0::Hdr rhs) { - return static_cast(static_cast(lhs) | static_cast(rhs)); -} -constexpr int32_t operator|(const int32_t lhs, - const ::android::hardware::graphics::common::V1_0::Hdr rhs) { - return static_cast(lhs | static_cast(rhs)); -} -constexpr int32_t operator|(const ::android::hardware::graphics::common::V1_0::Hdr lhs, - const int32_t rhs) { - return static_cast(static_cast(lhs) | rhs); -} -constexpr int32_t operator&(const ::android::hardware::graphics::common::V1_0::Hdr lhs, - const ::android::hardware::graphics::common::V1_0::Hdr rhs) { - return static_cast(static_cast(lhs) & static_cast(rhs)); -} -constexpr int32_t operator&(const int32_t lhs, - const ::android::hardware::graphics::common::V1_0::Hdr rhs) { - return static_cast(lhs & static_cast(rhs)); -} -constexpr int32_t operator&(const ::android::hardware::graphics::common::V1_0::Hdr lhs, - const int32_t rhs) { - return static_cast(static_cast(lhs) & rhs); -} -constexpr int32_t& operator|=(int32_t& v, - const ::android::hardware::graphics::common::V1_0::Hdr e) { - v |= static_cast(e); - return v; -} -constexpr int32_t& operator&=(int32_t& v, - const ::android::hardware::graphics::common::V1_0::Hdr e) { - v &= static_cast(e); - return v; -} - -// -// type header definitions for package -// - -template <> -inline std::string toString<::android::hardware::graphics::common::V1_0::PixelFormat>(int32_t o) { - using ::android::hardware::details::toHexString; - std::string os; - ::android::hardware::hidl_bitfield<::android::hardware::graphics::common::V1_0::PixelFormat> - flipped = 0; - bool first = true; - if ((o & ::android::hardware::graphics::common::V1_0::PixelFormat::RGBA_8888) == - static_cast(::android::hardware::graphics::common::V1_0::PixelFormat::RGBA_8888)) { - os += (first ? "" : " | "); - os += "RGBA_8888"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_0::PixelFormat::RGBA_8888; - } - if ((o & ::android::hardware::graphics::common::V1_0::PixelFormat::RGBX_8888) == - static_cast(::android::hardware::graphics::common::V1_0::PixelFormat::RGBX_8888)) { - os += (first ? "" : " | "); - os += "RGBX_8888"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_0::PixelFormat::RGBX_8888; - } - if ((o & ::android::hardware::graphics::common::V1_0::PixelFormat::RGB_888) == - static_cast(::android::hardware::graphics::common::V1_0::PixelFormat::RGB_888)) { - os += (first ? "" : " | "); - os += "RGB_888"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_0::PixelFormat::RGB_888; - } - if ((o & ::android::hardware::graphics::common::V1_0::PixelFormat::RGB_565) == - static_cast(::android::hardware::graphics::common::V1_0::PixelFormat::RGB_565)) { - os += (first ? "" : " | "); - os += "RGB_565"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_0::PixelFormat::RGB_565; - } - if ((o & ::android::hardware::graphics::common::V1_0::PixelFormat::BGRA_8888) == - static_cast(::android::hardware::graphics::common::V1_0::PixelFormat::BGRA_8888)) { - os += (first ? "" : " | "); - os += "BGRA_8888"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_0::PixelFormat::BGRA_8888; - } - if ((o & ::android::hardware::graphics::common::V1_0::PixelFormat::YCBCR_422_SP) == - static_cast( - ::android::hardware::graphics::common::V1_0::PixelFormat::YCBCR_422_SP)) { - os += (first ? "" : " | "); - os += "YCBCR_422_SP"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_0::PixelFormat::YCBCR_422_SP; - } - if ((o & ::android::hardware::graphics::common::V1_0::PixelFormat::YCRCB_420_SP) == - static_cast( - ::android::hardware::graphics::common::V1_0::PixelFormat::YCRCB_420_SP)) { - os += (first ? "" : " | "); - os += "YCRCB_420_SP"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_0::PixelFormat::YCRCB_420_SP; - } - if ((o & ::android::hardware::graphics::common::V1_0::PixelFormat::YCBCR_422_I) == - static_cast(::android::hardware::graphics::common::V1_0::PixelFormat::YCBCR_422_I)) { - os += (first ? "" : " | "); - os += "YCBCR_422_I"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_0::PixelFormat::YCBCR_422_I; - } - if ((o & ::android::hardware::graphics::common::V1_0::PixelFormat::RGBA_FP16) == - static_cast(::android::hardware::graphics::common::V1_0::PixelFormat::RGBA_FP16)) { - os += (first ? "" : " | "); - os += "RGBA_FP16"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_0::PixelFormat::RGBA_FP16; - } - if ((o & ::android::hardware::graphics::common::V1_0::PixelFormat::RAW16) == - static_cast(::android::hardware::graphics::common::V1_0::PixelFormat::RAW16)) { - os += (first ? "" : " | "); - os += "RAW16"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_0::PixelFormat::RAW16; - } - if ((o & ::android::hardware::graphics::common::V1_0::PixelFormat::BLOB) == - static_cast(::android::hardware::graphics::common::V1_0::PixelFormat::BLOB)) { - os += (first ? "" : " | "); - os += "BLOB"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_0::PixelFormat::BLOB; - } - if ((o & ::android::hardware::graphics::common::V1_0::PixelFormat::IMPLEMENTATION_DEFINED) == - static_cast( - ::android::hardware::graphics::common::V1_0::PixelFormat::IMPLEMENTATION_DEFINED)) { - os += (first ? "" : " | "); - os += "IMPLEMENTATION_DEFINED"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_0::PixelFormat::IMPLEMENTATION_DEFINED; - } - if ((o & ::android::hardware::graphics::common::V1_0::PixelFormat::YCBCR_420_888) == - static_cast( - ::android::hardware::graphics::common::V1_0::PixelFormat::YCBCR_420_888)) { - os += (first ? "" : " | "); - os += "YCBCR_420_888"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_0::PixelFormat::YCBCR_420_888; - } - if ((o & ::android::hardware::graphics::common::V1_0::PixelFormat::RAW_OPAQUE) == - static_cast(::android::hardware::graphics::common::V1_0::PixelFormat::RAW_OPAQUE)) { - os += (first ? "" : " | "); - os += "RAW_OPAQUE"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_0::PixelFormat::RAW_OPAQUE; - } - if ((o & ::android::hardware::graphics::common::V1_0::PixelFormat::RAW10) == - static_cast(::android::hardware::graphics::common::V1_0::PixelFormat::RAW10)) { - os += (first ? "" : " | "); - os += "RAW10"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_0::PixelFormat::RAW10; - } - if ((o & ::android::hardware::graphics::common::V1_0::PixelFormat::RAW12) == - static_cast(::android::hardware::graphics::common::V1_0::PixelFormat::RAW12)) { - os += (first ? "" : " | "); - os += "RAW12"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_0::PixelFormat::RAW12; - } - if ((o & ::android::hardware::graphics::common::V1_0::PixelFormat::RGBA_1010102) == - static_cast( - ::android::hardware::graphics::common::V1_0::PixelFormat::RGBA_1010102)) { - os += (first ? "" : " | "); - os += "RGBA_1010102"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_0::PixelFormat::RGBA_1010102; - } - if ((o & ::android::hardware::graphics::common::V1_0::PixelFormat::Y8) == - static_cast(::android::hardware::graphics::common::V1_0::PixelFormat::Y8)) { - os += (first ? "" : " | "); - os += "Y8"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_0::PixelFormat::Y8; - } - if ((o & ::android::hardware::graphics::common::V1_0::PixelFormat::Y16) == - static_cast(::android::hardware::graphics::common::V1_0::PixelFormat::Y16)) { - os += (first ? "" : " | "); - os += "Y16"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_0::PixelFormat::Y16; - } - if ((o & ::android::hardware::graphics::common::V1_0::PixelFormat::YV12) == - static_cast(::android::hardware::graphics::common::V1_0::PixelFormat::YV12)) { - os += (first ? "" : " | "); - os += "YV12"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_0::PixelFormat::YV12; - } - if (o != flipped) { - os += (first ? "" : " | "); - os += toHexString(o & (~flipped)); - } - os += " ("; - os += toHexString(o); - os += ")"; - return os; -} - -static inline std::string toString(::android::hardware::graphics::common::V1_0::PixelFormat o) { - using ::android::hardware::details::toHexString; - if (o == ::android::hardware::graphics::common::V1_0::PixelFormat::RGBA_8888) { - return "RGBA_8888"; - } - if (o == ::android::hardware::graphics::common::V1_0::PixelFormat::RGBX_8888) { - return "RGBX_8888"; - } - if (o == ::android::hardware::graphics::common::V1_0::PixelFormat::RGB_888) { - return "RGB_888"; - } - if (o == ::android::hardware::graphics::common::V1_0::PixelFormat::RGB_565) { - return "RGB_565"; - } - if (o == ::android::hardware::graphics::common::V1_0::PixelFormat::BGRA_8888) { - return "BGRA_8888"; - } - if (o == ::android::hardware::graphics::common::V1_0::PixelFormat::YCBCR_422_SP) { - return "YCBCR_422_SP"; - } - if (o == ::android::hardware::graphics::common::V1_0::PixelFormat::YCRCB_420_SP) { - return "YCRCB_420_SP"; - } - if (o == ::android::hardware::graphics::common::V1_0::PixelFormat::YCBCR_422_I) { - return "YCBCR_422_I"; - } - if (o == ::android::hardware::graphics::common::V1_0::PixelFormat::RGBA_FP16) { - return "RGBA_FP16"; - } - if (o == ::android::hardware::graphics::common::V1_0::PixelFormat::RAW16) { - return "RAW16"; - } - if (o == ::android::hardware::graphics::common::V1_0::PixelFormat::BLOB) { - return "BLOB"; - } - if (o == ::android::hardware::graphics::common::V1_0::PixelFormat::IMPLEMENTATION_DEFINED) { - return "IMPLEMENTATION_DEFINED"; - } - if (o == ::android::hardware::graphics::common::V1_0::PixelFormat::YCBCR_420_888) { - return "YCBCR_420_888"; - } - if (o == ::android::hardware::graphics::common::V1_0::PixelFormat::RAW_OPAQUE) { - return "RAW_OPAQUE"; - } - if (o == ::android::hardware::graphics::common::V1_0::PixelFormat::RAW10) { - return "RAW10"; - } - if (o == ::android::hardware::graphics::common::V1_0::PixelFormat::RAW12) { - return "RAW12"; - } - if (o == ::android::hardware::graphics::common::V1_0::PixelFormat::RGBA_1010102) { - return "RGBA_1010102"; - } - if (o == ::android::hardware::graphics::common::V1_0::PixelFormat::Y8) { - return "Y8"; - } - if (o == ::android::hardware::graphics::common::V1_0::PixelFormat::Y16) { - return "Y16"; - } - if (o == ::android::hardware::graphics::common::V1_0::PixelFormat::YV12) { - return "YV12"; - } - std::string os; - os += toHexString(static_cast(o)); - return os; -} - -template <> -inline std::string toString<::android::hardware::graphics::common::V1_0::BufferUsage>(uint64_t o) { - using ::android::hardware::details::toHexString; - std::string os; - ::android::hardware::hidl_bitfield<::android::hardware::graphics::common::V1_0::BufferUsage> - flipped = 0; - bool first = true; - if ((o & ::android::hardware::graphics::common::V1_0::BufferUsage::CPU_READ_MASK) == - static_cast( - ::android::hardware::graphics::common::V1_0::BufferUsage::CPU_READ_MASK)) { - os += (first ? "" : " | "); - os += "CPU_READ_MASK"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_0::BufferUsage::CPU_READ_MASK; - } - if ((o & ::android::hardware::graphics::common::V1_0::BufferUsage::CPU_READ_NEVER) == - static_cast( - ::android::hardware::graphics::common::V1_0::BufferUsage::CPU_READ_NEVER)) { - os += (first ? "" : " | "); - os += "CPU_READ_NEVER"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_0::BufferUsage::CPU_READ_NEVER; - } - if ((o & ::android::hardware::graphics::common::V1_0::BufferUsage::CPU_READ_RARELY) == - static_cast( - ::android::hardware::graphics::common::V1_0::BufferUsage::CPU_READ_RARELY)) { - os += (first ? "" : " | "); - os += "CPU_READ_RARELY"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_0::BufferUsage::CPU_READ_RARELY; - } - if ((o & ::android::hardware::graphics::common::V1_0::BufferUsage::CPU_READ_OFTEN) == - static_cast( - ::android::hardware::graphics::common::V1_0::BufferUsage::CPU_READ_OFTEN)) { - os += (first ? "" : " | "); - os += "CPU_READ_OFTEN"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_0::BufferUsage::CPU_READ_OFTEN; - } - if ((o & ::android::hardware::graphics::common::V1_0::BufferUsage::CPU_WRITE_MASK) == - static_cast( - ::android::hardware::graphics::common::V1_0::BufferUsage::CPU_WRITE_MASK)) { - os += (first ? "" : " | "); - os += "CPU_WRITE_MASK"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_0::BufferUsage::CPU_WRITE_MASK; - } - if ((o & ::android::hardware::graphics::common::V1_0::BufferUsage::CPU_WRITE_NEVER) == - static_cast( - ::android::hardware::graphics::common::V1_0::BufferUsage::CPU_WRITE_NEVER)) { - os += (first ? "" : " | "); - os += "CPU_WRITE_NEVER"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_0::BufferUsage::CPU_WRITE_NEVER; - } - if ((o & ::android::hardware::graphics::common::V1_0::BufferUsage::CPU_WRITE_RARELY) == - static_cast( - ::android::hardware::graphics::common::V1_0::BufferUsage::CPU_WRITE_RARELY)) { - os += (first ? "" : " | "); - os += "CPU_WRITE_RARELY"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_0::BufferUsage::CPU_WRITE_RARELY; - } - if ((o & ::android::hardware::graphics::common::V1_0::BufferUsage::CPU_WRITE_OFTEN) == - static_cast( - ::android::hardware::graphics::common::V1_0::BufferUsage::CPU_WRITE_OFTEN)) { - os += (first ? "" : " | "); - os += "CPU_WRITE_OFTEN"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_0::BufferUsage::CPU_WRITE_OFTEN; - } - if ((o & ::android::hardware::graphics::common::V1_0::BufferUsage::GPU_TEXTURE) == - static_cast( - ::android::hardware::graphics::common::V1_0::BufferUsage::GPU_TEXTURE)) { - os += (first ? "" : " | "); - os += "GPU_TEXTURE"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_0::BufferUsage::GPU_TEXTURE; - } - if ((o & ::android::hardware::graphics::common::V1_0::BufferUsage::GPU_RENDER_TARGET) == - static_cast( - ::android::hardware::graphics::common::V1_0::BufferUsage::GPU_RENDER_TARGET)) { - os += (first ? "" : " | "); - os += "GPU_RENDER_TARGET"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_0::BufferUsage::GPU_RENDER_TARGET; - } - if ((o & ::android::hardware::graphics::common::V1_0::BufferUsage::COMPOSER_OVERLAY) == - static_cast( - ::android::hardware::graphics::common::V1_0::BufferUsage::COMPOSER_OVERLAY)) { - os += (first ? "" : " | "); - os += "COMPOSER_OVERLAY"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_0::BufferUsage::COMPOSER_OVERLAY; - } - if ((o & ::android::hardware::graphics::common::V1_0::BufferUsage::COMPOSER_CLIENT_TARGET) == - static_cast( - ::android::hardware::graphics::common::V1_0::BufferUsage::COMPOSER_CLIENT_TARGET)) { - os += (first ? "" : " | "); - os += "COMPOSER_CLIENT_TARGET"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_0::BufferUsage::COMPOSER_CLIENT_TARGET; - } - if ((o & ::android::hardware::graphics::common::V1_0::BufferUsage::PROTECTED) == - static_cast(::android::hardware::graphics::common::V1_0::BufferUsage::PROTECTED)) { - os += (first ? "" : " | "); - os += "PROTECTED"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_0::BufferUsage::PROTECTED; - } - if ((o & ::android::hardware::graphics::common::V1_0::BufferUsage::COMPOSER_CURSOR) == - static_cast( - ::android::hardware::graphics::common::V1_0::BufferUsage::COMPOSER_CURSOR)) { - os += (first ? "" : " | "); - os += "COMPOSER_CURSOR"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_0::BufferUsage::COMPOSER_CURSOR; - } - if ((o & ::android::hardware::graphics::common::V1_0::BufferUsage::VIDEO_ENCODER) == - static_cast( - ::android::hardware::graphics::common::V1_0::BufferUsage::VIDEO_ENCODER)) { - os += (first ? "" : " | "); - os += "VIDEO_ENCODER"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_0::BufferUsage::VIDEO_ENCODER; - } - if ((o & ::android::hardware::graphics::common::V1_0::BufferUsage::CAMERA_OUTPUT) == - static_cast( - ::android::hardware::graphics::common::V1_0::BufferUsage::CAMERA_OUTPUT)) { - os += (first ? "" : " | "); - os += "CAMERA_OUTPUT"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_0::BufferUsage::CAMERA_OUTPUT; - } - if ((o & ::android::hardware::graphics::common::V1_0::BufferUsage::CAMERA_INPUT) == - static_cast( - ::android::hardware::graphics::common::V1_0::BufferUsage::CAMERA_INPUT)) { - os += (first ? "" : " | "); - os += "CAMERA_INPUT"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_0::BufferUsage::CAMERA_INPUT; - } - if ((o & ::android::hardware::graphics::common::V1_0::BufferUsage::RENDERSCRIPT) == - static_cast( - ::android::hardware::graphics::common::V1_0::BufferUsage::RENDERSCRIPT)) { - os += (first ? "" : " | "); - os += "RENDERSCRIPT"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_0::BufferUsage::RENDERSCRIPT; - } - if ((o & ::android::hardware::graphics::common::V1_0::BufferUsage::VIDEO_DECODER) == - static_cast( - ::android::hardware::graphics::common::V1_0::BufferUsage::VIDEO_DECODER)) { - os += (first ? "" : " | "); - os += "VIDEO_DECODER"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_0::BufferUsage::VIDEO_DECODER; - } - if ((o & ::android::hardware::graphics::common::V1_0::BufferUsage::SENSOR_DIRECT_DATA) == - static_cast( - ::android::hardware::graphics::common::V1_0::BufferUsage::SENSOR_DIRECT_DATA)) { - os += (first ? "" : " | "); - os += "SENSOR_DIRECT_DATA"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_0::BufferUsage::SENSOR_DIRECT_DATA; - } - if ((o & ::android::hardware::graphics::common::V1_0::BufferUsage::GPU_DATA_BUFFER) == - static_cast( - ::android::hardware::graphics::common::V1_0::BufferUsage::GPU_DATA_BUFFER)) { - os += (first ? "" : " | "); - os += "GPU_DATA_BUFFER"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_0::BufferUsage::GPU_DATA_BUFFER; - } - if ((o & ::android::hardware::graphics::common::V1_0::BufferUsage::VENDOR_MASK) == - static_cast( - ::android::hardware::graphics::common::V1_0::BufferUsage::VENDOR_MASK)) { - os += (first ? "" : " | "); - os += "VENDOR_MASK"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_0::BufferUsage::VENDOR_MASK; - } - if ((o & ::android::hardware::graphics::common::V1_0::BufferUsage::VENDOR_MASK_HI) == - static_cast( - ::android::hardware::graphics::common::V1_0::BufferUsage::VENDOR_MASK_HI)) { - os += (first ? "" : " | "); - os += "VENDOR_MASK_HI"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_0::BufferUsage::VENDOR_MASK_HI; - } - if (o != flipped) { - os += (first ? "" : " | "); - os += toHexString(o & (~flipped)); - } - os += " ("; - os += toHexString(o); - os += ")"; - return os; -} - -static inline std::string toString(::android::hardware::graphics::common::V1_0::BufferUsage o) { - using ::android::hardware::details::toHexString; - if (o == ::android::hardware::graphics::common::V1_0::BufferUsage::CPU_READ_MASK) { - return "CPU_READ_MASK"; - } - if (o == ::android::hardware::graphics::common::V1_0::BufferUsage::CPU_READ_NEVER) { - return "CPU_READ_NEVER"; - } - if (o == ::android::hardware::graphics::common::V1_0::BufferUsage::CPU_READ_RARELY) { - return "CPU_READ_RARELY"; - } - if (o == ::android::hardware::graphics::common::V1_0::BufferUsage::CPU_READ_OFTEN) { - return "CPU_READ_OFTEN"; - } - if (o == ::android::hardware::graphics::common::V1_0::BufferUsage::CPU_WRITE_MASK) { - return "CPU_WRITE_MASK"; - } - if (o == ::android::hardware::graphics::common::V1_0::BufferUsage::CPU_WRITE_NEVER) { - return "CPU_WRITE_NEVER"; - } - if (o == ::android::hardware::graphics::common::V1_0::BufferUsage::CPU_WRITE_RARELY) { - return "CPU_WRITE_RARELY"; - } - if (o == ::android::hardware::graphics::common::V1_0::BufferUsage::CPU_WRITE_OFTEN) { - return "CPU_WRITE_OFTEN"; - } - if (o == ::android::hardware::graphics::common::V1_0::BufferUsage::GPU_TEXTURE) { - return "GPU_TEXTURE"; - } - if (o == ::android::hardware::graphics::common::V1_0::BufferUsage::GPU_RENDER_TARGET) { - return "GPU_RENDER_TARGET"; - } - if (o == ::android::hardware::graphics::common::V1_0::BufferUsage::COMPOSER_OVERLAY) { - return "COMPOSER_OVERLAY"; - } - if (o == ::android::hardware::graphics::common::V1_0::BufferUsage::COMPOSER_CLIENT_TARGET) { - return "COMPOSER_CLIENT_TARGET"; - } - if (o == ::android::hardware::graphics::common::V1_0::BufferUsage::PROTECTED) { - return "PROTECTED"; - } - if (o == ::android::hardware::graphics::common::V1_0::BufferUsage::COMPOSER_CURSOR) { - return "COMPOSER_CURSOR"; - } - if (o == ::android::hardware::graphics::common::V1_0::BufferUsage::VIDEO_ENCODER) { - return "VIDEO_ENCODER"; - } - if (o == ::android::hardware::graphics::common::V1_0::BufferUsage::CAMERA_OUTPUT) { - return "CAMERA_OUTPUT"; - } - if (o == ::android::hardware::graphics::common::V1_0::BufferUsage::CAMERA_INPUT) { - return "CAMERA_INPUT"; - } - if (o == ::android::hardware::graphics::common::V1_0::BufferUsage::RENDERSCRIPT) { - return "RENDERSCRIPT"; - } - if (o == ::android::hardware::graphics::common::V1_0::BufferUsage::VIDEO_DECODER) { - return "VIDEO_DECODER"; - } - if (o == ::android::hardware::graphics::common::V1_0::BufferUsage::SENSOR_DIRECT_DATA) { - return "SENSOR_DIRECT_DATA"; - } - if (o == ::android::hardware::graphics::common::V1_0::BufferUsage::GPU_DATA_BUFFER) { - return "GPU_DATA_BUFFER"; - } - if (o == ::android::hardware::graphics::common::V1_0::BufferUsage::VENDOR_MASK) { - return "VENDOR_MASK"; - } - if (o == ::android::hardware::graphics::common::V1_0::BufferUsage::VENDOR_MASK_HI) { - return "VENDOR_MASK_HI"; - } - std::string os; - os += toHexString(static_cast(o)); - return os; -} - -template <> -inline std::string toString<::android::hardware::graphics::common::V1_0::Transform>(int32_t o) { - using ::android::hardware::details::toHexString; - std::string os; - ::android::hardware::hidl_bitfield<::android::hardware::graphics::common::V1_0::Transform> - flipped = 0; - bool first = true; - if ((o & ::android::hardware::graphics::common::V1_0::Transform::FLIP_H) == - static_cast(::android::hardware::graphics::common::V1_0::Transform::FLIP_H)) { - os += (first ? "" : " | "); - os += "FLIP_H"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_0::Transform::FLIP_H; - } - if ((o & ::android::hardware::graphics::common::V1_0::Transform::FLIP_V) == - static_cast(::android::hardware::graphics::common::V1_0::Transform::FLIP_V)) { - os += (first ? "" : " | "); - os += "FLIP_V"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_0::Transform::FLIP_V; - } - if ((o & ::android::hardware::graphics::common::V1_0::Transform::ROT_90) == - static_cast(::android::hardware::graphics::common::V1_0::Transform::ROT_90)) { - os += (first ? "" : " | "); - os += "ROT_90"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_0::Transform::ROT_90; - } - if ((o & ::android::hardware::graphics::common::V1_0::Transform::ROT_180) == - static_cast(::android::hardware::graphics::common::V1_0::Transform::ROT_180)) { - os += (first ? "" : " | "); - os += "ROT_180"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_0::Transform::ROT_180; - } - if ((o & ::android::hardware::graphics::common::V1_0::Transform::ROT_270) == - static_cast(::android::hardware::graphics::common::V1_0::Transform::ROT_270)) { - os += (first ? "" : " | "); - os += "ROT_270"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_0::Transform::ROT_270; - } - if (o != flipped) { - os += (first ? "" : " | "); - os += toHexString(o & (~flipped)); - } - os += " ("; - os += toHexString(o); - os += ")"; - return os; -} - -static inline std::string toString(::android::hardware::graphics::common::V1_0::Transform o) { - using ::android::hardware::details::toHexString; - if (o == ::android::hardware::graphics::common::V1_0::Transform::FLIP_H) { - return "FLIP_H"; - } - if (o == ::android::hardware::graphics::common::V1_0::Transform::FLIP_V) { - return "FLIP_V"; - } - if (o == ::android::hardware::graphics::common::V1_0::Transform::ROT_90) { - return "ROT_90"; - } - if (o == ::android::hardware::graphics::common::V1_0::Transform::ROT_180) { - return "ROT_180"; - } - if (o == ::android::hardware::graphics::common::V1_0::Transform::ROT_270) { - return "ROT_270"; - } - std::string os; - os += toHexString(static_cast(o)); - return os; -} - -template <> -inline std::string toString<::android::hardware::graphics::common::V1_0::Dataspace>(int32_t o) { - using ::android::hardware::details::toHexString; - std::string os; - ::android::hardware::hidl_bitfield<::android::hardware::graphics::common::V1_0::Dataspace> - flipped = 0; - bool first = true; - if ((o & ::android::hardware::graphics::common::V1_0::Dataspace::UNKNOWN) == - static_cast(::android::hardware::graphics::common::V1_0::Dataspace::UNKNOWN)) { - os += (first ? "" : " | "); - os += "UNKNOWN"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_0::Dataspace::UNKNOWN; - } - if ((o & ::android::hardware::graphics::common::V1_0::Dataspace::ARBITRARY) == - static_cast(::android::hardware::graphics::common::V1_0::Dataspace::ARBITRARY)) { - os += (first ? "" : " | "); - os += "ARBITRARY"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_0::Dataspace::ARBITRARY; - } - if ((o & ::android::hardware::graphics::common::V1_0::Dataspace::STANDARD_SHIFT) == - static_cast( - ::android::hardware::graphics::common::V1_0::Dataspace::STANDARD_SHIFT)) { - os += (first ? "" : " | "); - os += "STANDARD_SHIFT"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_0::Dataspace::STANDARD_SHIFT; - } - if ((o & ::android::hardware::graphics::common::V1_0::Dataspace::STANDARD_MASK) == - static_cast(::android::hardware::graphics::common::V1_0::Dataspace::STANDARD_MASK)) { - os += (first ? "" : " | "); - os += "STANDARD_MASK"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_0::Dataspace::STANDARD_MASK; - } - if ((o & ::android::hardware::graphics::common::V1_0::Dataspace::STANDARD_UNSPECIFIED) == - static_cast( - ::android::hardware::graphics::common::V1_0::Dataspace::STANDARD_UNSPECIFIED)) { - os += (first ? "" : " | "); - os += "STANDARD_UNSPECIFIED"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_0::Dataspace::STANDARD_UNSPECIFIED; - } - if ((o & ::android::hardware::graphics::common::V1_0::Dataspace::STANDARD_BT709) == - static_cast( - ::android::hardware::graphics::common::V1_0::Dataspace::STANDARD_BT709)) { - os += (first ? "" : " | "); - os += "STANDARD_BT709"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_0::Dataspace::STANDARD_BT709; - } - if ((o & ::android::hardware::graphics::common::V1_0::Dataspace::STANDARD_BT601_625) == - static_cast( - ::android::hardware::graphics::common::V1_0::Dataspace::STANDARD_BT601_625)) { - os += (first ? "" : " | "); - os += "STANDARD_BT601_625"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_0::Dataspace::STANDARD_BT601_625; - } - if ((o & ::android::hardware::graphics::common::V1_0::Dataspace::STANDARD_BT601_625_UNADJUSTED) == - static_cast( - ::android::hardware::graphics::common::V1_0::Dataspace::STANDARD_BT601_625_UNADJUSTED)) { - os += (first ? "" : " | "); - os += "STANDARD_BT601_625_UNADJUSTED"; - first = false; - flipped |= - ::android::hardware::graphics::common::V1_0::Dataspace::STANDARD_BT601_625_UNADJUSTED; - } - if ((o & ::android::hardware::graphics::common::V1_0::Dataspace::STANDARD_BT601_525) == - static_cast( - ::android::hardware::graphics::common::V1_0::Dataspace::STANDARD_BT601_525)) { - os += (first ? "" : " | "); - os += "STANDARD_BT601_525"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_0::Dataspace::STANDARD_BT601_525; - } - if ((o & ::android::hardware::graphics::common::V1_0::Dataspace::STANDARD_BT601_525_UNADJUSTED) == - static_cast( - ::android::hardware::graphics::common::V1_0::Dataspace::STANDARD_BT601_525_UNADJUSTED)) { - os += (first ? "" : " | "); - os += "STANDARD_BT601_525_UNADJUSTED"; - first = false; - flipped |= - ::android::hardware::graphics::common::V1_0::Dataspace::STANDARD_BT601_525_UNADJUSTED; - } - if ((o & ::android::hardware::graphics::common::V1_0::Dataspace::STANDARD_BT2020) == - static_cast( - ::android::hardware::graphics::common::V1_0::Dataspace::STANDARD_BT2020)) { - os += (first ? "" : " | "); - os += "STANDARD_BT2020"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_0::Dataspace::STANDARD_BT2020; - } - if ((o & ::android::hardware::graphics::common::V1_0::Dataspace:: - STANDARD_BT2020_CONSTANT_LUMINANCE) == - static_cast(::android::hardware::graphics::common::V1_0::Dataspace:: - STANDARD_BT2020_CONSTANT_LUMINANCE)) { - os += (first ? "" : " | "); - os += "STANDARD_BT2020_CONSTANT_LUMINANCE"; - first = false; - flipped |= - ::android::hardware::graphics::common::V1_0::Dataspace::STANDARD_BT2020_CONSTANT_LUMINANCE; - } - if ((o & ::android::hardware::graphics::common::V1_0::Dataspace::STANDARD_BT470M) == - static_cast( - ::android::hardware::graphics::common::V1_0::Dataspace::STANDARD_BT470M)) { - os += (first ? "" : " | "); - os += "STANDARD_BT470M"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_0::Dataspace::STANDARD_BT470M; - } - if ((o & ::android::hardware::graphics::common::V1_0::Dataspace::STANDARD_FILM) == - static_cast(::android::hardware::graphics::common::V1_0::Dataspace::STANDARD_FILM)) { - os += (first ? "" : " | "); - os += "STANDARD_FILM"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_0::Dataspace::STANDARD_FILM; - } - if ((o & ::android::hardware::graphics::common::V1_0::Dataspace::STANDARD_DCI_P3) == - static_cast( - ::android::hardware::graphics::common::V1_0::Dataspace::STANDARD_DCI_P3)) { - os += (first ? "" : " | "); - os += "STANDARD_DCI_P3"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_0::Dataspace::STANDARD_DCI_P3; - } - if ((o & ::android::hardware::graphics::common::V1_0::Dataspace::STANDARD_ADOBE_RGB) == - static_cast( - ::android::hardware::graphics::common::V1_0::Dataspace::STANDARD_ADOBE_RGB)) { - os += (first ? "" : " | "); - os += "STANDARD_ADOBE_RGB"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_0::Dataspace::STANDARD_ADOBE_RGB; - } - if ((o & ::android::hardware::graphics::common::V1_0::Dataspace::TRANSFER_SHIFT) == - static_cast( - ::android::hardware::graphics::common::V1_0::Dataspace::TRANSFER_SHIFT)) { - os += (first ? "" : " | "); - os += "TRANSFER_SHIFT"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_0::Dataspace::TRANSFER_SHIFT; - } - if ((o & ::android::hardware::graphics::common::V1_0::Dataspace::TRANSFER_MASK) == - static_cast(::android::hardware::graphics::common::V1_0::Dataspace::TRANSFER_MASK)) { - os += (first ? "" : " | "); - os += "TRANSFER_MASK"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_0::Dataspace::TRANSFER_MASK; - } - if ((o & ::android::hardware::graphics::common::V1_0::Dataspace::TRANSFER_UNSPECIFIED) == - static_cast( - ::android::hardware::graphics::common::V1_0::Dataspace::TRANSFER_UNSPECIFIED)) { - os += (first ? "" : " | "); - os += "TRANSFER_UNSPECIFIED"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_0::Dataspace::TRANSFER_UNSPECIFIED; - } - if ((o & ::android::hardware::graphics::common::V1_0::Dataspace::TRANSFER_LINEAR) == - static_cast( - ::android::hardware::graphics::common::V1_0::Dataspace::TRANSFER_LINEAR)) { - os += (first ? "" : " | "); - os += "TRANSFER_LINEAR"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_0::Dataspace::TRANSFER_LINEAR; - } - if ((o & ::android::hardware::graphics::common::V1_0::Dataspace::TRANSFER_SRGB) == - static_cast(::android::hardware::graphics::common::V1_0::Dataspace::TRANSFER_SRGB)) { - os += (first ? "" : " | "); - os += "TRANSFER_SRGB"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_0::Dataspace::TRANSFER_SRGB; - } - if ((o & ::android::hardware::graphics::common::V1_0::Dataspace::TRANSFER_SMPTE_170M) == - static_cast( - ::android::hardware::graphics::common::V1_0::Dataspace::TRANSFER_SMPTE_170M)) { - os += (first ? "" : " | "); - os += "TRANSFER_SMPTE_170M"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_0::Dataspace::TRANSFER_SMPTE_170M; - } - if ((o & ::android::hardware::graphics::common::V1_0::Dataspace::TRANSFER_GAMMA2_2) == - static_cast( - ::android::hardware::graphics::common::V1_0::Dataspace::TRANSFER_GAMMA2_2)) { - os += (first ? "" : " | "); - os += "TRANSFER_GAMMA2_2"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_0::Dataspace::TRANSFER_GAMMA2_2; - } - if ((o & ::android::hardware::graphics::common::V1_0::Dataspace::TRANSFER_GAMMA2_6) == - static_cast( - ::android::hardware::graphics::common::V1_0::Dataspace::TRANSFER_GAMMA2_6)) { - os += (first ? "" : " | "); - os += "TRANSFER_GAMMA2_6"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_0::Dataspace::TRANSFER_GAMMA2_6; - } - if ((o & ::android::hardware::graphics::common::V1_0::Dataspace::TRANSFER_GAMMA2_8) == - static_cast( - ::android::hardware::graphics::common::V1_0::Dataspace::TRANSFER_GAMMA2_8)) { - os += (first ? "" : " | "); - os += "TRANSFER_GAMMA2_8"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_0::Dataspace::TRANSFER_GAMMA2_8; - } - if ((o & ::android::hardware::graphics::common::V1_0::Dataspace::TRANSFER_ST2084) == - static_cast( - ::android::hardware::graphics::common::V1_0::Dataspace::TRANSFER_ST2084)) { - os += (first ? "" : " | "); - os += "TRANSFER_ST2084"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_0::Dataspace::TRANSFER_ST2084; - } - if ((o & ::android::hardware::graphics::common::V1_0::Dataspace::TRANSFER_HLG) == - static_cast(::android::hardware::graphics::common::V1_0::Dataspace::TRANSFER_HLG)) { - os += (first ? "" : " | "); - os += "TRANSFER_HLG"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_0::Dataspace::TRANSFER_HLG; - } - if ((o & ::android::hardware::graphics::common::V1_0::Dataspace::RANGE_SHIFT) == - static_cast(::android::hardware::graphics::common::V1_0::Dataspace::RANGE_SHIFT)) { - os += (first ? "" : " | "); - os += "RANGE_SHIFT"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_0::Dataspace::RANGE_SHIFT; - } - if ((o & ::android::hardware::graphics::common::V1_0::Dataspace::RANGE_MASK) == - static_cast(::android::hardware::graphics::common::V1_0::Dataspace::RANGE_MASK)) { - os += (first ? "" : " | "); - os += "RANGE_MASK"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_0::Dataspace::RANGE_MASK; - } - if ((o & ::android::hardware::graphics::common::V1_0::Dataspace::RANGE_UNSPECIFIED) == - static_cast( - ::android::hardware::graphics::common::V1_0::Dataspace::RANGE_UNSPECIFIED)) { - os += (first ? "" : " | "); - os += "RANGE_UNSPECIFIED"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_0::Dataspace::RANGE_UNSPECIFIED; - } - if ((o & ::android::hardware::graphics::common::V1_0::Dataspace::RANGE_FULL) == - static_cast(::android::hardware::graphics::common::V1_0::Dataspace::RANGE_FULL)) { - os += (first ? "" : " | "); - os += "RANGE_FULL"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_0::Dataspace::RANGE_FULL; - } - if ((o & ::android::hardware::graphics::common::V1_0::Dataspace::RANGE_LIMITED) == - static_cast(::android::hardware::graphics::common::V1_0::Dataspace::RANGE_LIMITED)) { - os += (first ? "" : " | "); - os += "RANGE_LIMITED"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_0::Dataspace::RANGE_LIMITED; - } - if ((o & ::android::hardware::graphics::common::V1_0::Dataspace::RANGE_EXTENDED) == - static_cast( - ::android::hardware::graphics::common::V1_0::Dataspace::RANGE_EXTENDED)) { - os += (first ? "" : " | "); - os += "RANGE_EXTENDED"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_0::Dataspace::RANGE_EXTENDED; - } - if ((o & ::android::hardware::graphics::common::V1_0::Dataspace::SRGB_LINEAR) == - static_cast(::android::hardware::graphics::common::V1_0::Dataspace::SRGB_LINEAR)) { - os += (first ? "" : " | "); - os += "SRGB_LINEAR"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_0::Dataspace::SRGB_LINEAR; - } - if ((o & ::android::hardware::graphics::common::V1_0::Dataspace::V0_SRGB_LINEAR) == - static_cast( - ::android::hardware::graphics::common::V1_0::Dataspace::V0_SRGB_LINEAR)) { - os += (first ? "" : " | "); - os += "V0_SRGB_LINEAR"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_0::Dataspace::V0_SRGB_LINEAR; - } - if ((o & ::android::hardware::graphics::common::V1_0::Dataspace::V0_SCRGB_LINEAR) == - static_cast( - ::android::hardware::graphics::common::V1_0::Dataspace::V0_SCRGB_LINEAR)) { - os += (first ? "" : " | "); - os += "V0_SCRGB_LINEAR"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_0::Dataspace::V0_SCRGB_LINEAR; - } - if ((o & ::android::hardware::graphics::common::V1_0::Dataspace::SRGB) == - static_cast(::android::hardware::graphics::common::V1_0::Dataspace::SRGB)) { - os += (first ? "" : " | "); - os += "SRGB"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_0::Dataspace::SRGB; - } - if ((o & ::android::hardware::graphics::common::V1_0::Dataspace::V0_SRGB) == - static_cast(::android::hardware::graphics::common::V1_0::Dataspace::V0_SRGB)) { - os += (first ? "" : " | "); - os += "V0_SRGB"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_0::Dataspace::V0_SRGB; - } - if ((o & ::android::hardware::graphics::common::V1_0::Dataspace::V0_SCRGB) == - static_cast(::android::hardware::graphics::common::V1_0::Dataspace::V0_SCRGB)) { - os += (first ? "" : " | "); - os += "V0_SCRGB"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_0::Dataspace::V0_SCRGB; - } - if ((o & ::android::hardware::graphics::common::V1_0::Dataspace::JFIF) == - static_cast(::android::hardware::graphics::common::V1_0::Dataspace::JFIF)) { - os += (first ? "" : " | "); - os += "JFIF"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_0::Dataspace::JFIF; - } - if ((o & ::android::hardware::graphics::common::V1_0::Dataspace::V0_JFIF) == - static_cast(::android::hardware::graphics::common::V1_0::Dataspace::V0_JFIF)) { - os += (first ? "" : " | "); - os += "V0_JFIF"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_0::Dataspace::V0_JFIF; - } - if ((o & ::android::hardware::graphics::common::V1_0::Dataspace::BT601_625) == - static_cast(::android::hardware::graphics::common::V1_0::Dataspace::BT601_625)) { - os += (first ? "" : " | "); - os += "BT601_625"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_0::Dataspace::BT601_625; - } - if ((o & ::android::hardware::graphics::common::V1_0::Dataspace::V0_BT601_625) == - static_cast(::android::hardware::graphics::common::V1_0::Dataspace::V0_BT601_625)) { - os += (first ? "" : " | "); - os += "V0_BT601_625"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_0::Dataspace::V0_BT601_625; - } - if ((o & ::android::hardware::graphics::common::V1_0::Dataspace::BT601_525) == - static_cast(::android::hardware::graphics::common::V1_0::Dataspace::BT601_525)) { - os += (first ? "" : " | "); - os += "BT601_525"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_0::Dataspace::BT601_525; - } - if ((o & ::android::hardware::graphics::common::V1_0::Dataspace::V0_BT601_525) == - static_cast(::android::hardware::graphics::common::V1_0::Dataspace::V0_BT601_525)) { - os += (first ? "" : " | "); - os += "V0_BT601_525"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_0::Dataspace::V0_BT601_525; - } - if ((o & ::android::hardware::graphics::common::V1_0::Dataspace::BT709) == - static_cast(::android::hardware::graphics::common::V1_0::Dataspace::BT709)) { - os += (first ? "" : " | "); - os += "BT709"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_0::Dataspace::BT709; - } - if ((o & ::android::hardware::graphics::common::V1_0::Dataspace::V0_BT709) == - static_cast(::android::hardware::graphics::common::V1_0::Dataspace::V0_BT709)) { - os += (first ? "" : " | "); - os += "V0_BT709"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_0::Dataspace::V0_BT709; - } - if ((o & ::android::hardware::graphics::common::V1_0::Dataspace::DCI_P3_LINEAR) == - static_cast(::android::hardware::graphics::common::V1_0::Dataspace::DCI_P3_LINEAR)) { - os += (first ? "" : " | "); - os += "DCI_P3_LINEAR"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_0::Dataspace::DCI_P3_LINEAR; - } - if ((o & ::android::hardware::graphics::common::V1_0::Dataspace::DCI_P3) == - static_cast(::android::hardware::graphics::common::V1_0::Dataspace::DCI_P3)) { - os += (first ? "" : " | "); - os += "DCI_P3"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_0::Dataspace::DCI_P3; - } - if ((o & ::android::hardware::graphics::common::V1_0::Dataspace::DISPLAY_P3_LINEAR) == - static_cast( - ::android::hardware::graphics::common::V1_0::Dataspace::DISPLAY_P3_LINEAR)) { - os += (first ? "" : " | "); - os += "DISPLAY_P3_LINEAR"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_0::Dataspace::DISPLAY_P3_LINEAR; - } - if ((o & ::android::hardware::graphics::common::V1_0::Dataspace::DISPLAY_P3) == - static_cast(::android::hardware::graphics::common::V1_0::Dataspace::DISPLAY_P3)) { - os += (first ? "" : " | "); - os += "DISPLAY_P3"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_0::Dataspace::DISPLAY_P3; - } - if ((o & ::android::hardware::graphics::common::V1_0::Dataspace::ADOBE_RGB) == - static_cast(::android::hardware::graphics::common::V1_0::Dataspace::ADOBE_RGB)) { - os += (first ? "" : " | "); - os += "ADOBE_RGB"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_0::Dataspace::ADOBE_RGB; - } - if ((o & ::android::hardware::graphics::common::V1_0::Dataspace::BT2020_LINEAR) == - static_cast(::android::hardware::graphics::common::V1_0::Dataspace::BT2020_LINEAR)) { - os += (first ? "" : " | "); - os += "BT2020_LINEAR"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_0::Dataspace::BT2020_LINEAR; - } - if ((o & ::android::hardware::graphics::common::V1_0::Dataspace::BT2020) == - static_cast(::android::hardware::graphics::common::V1_0::Dataspace::BT2020)) { - os += (first ? "" : " | "); - os += "BT2020"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_0::Dataspace::BT2020; - } - if ((o & ::android::hardware::graphics::common::V1_0::Dataspace::BT2020_PQ) == - static_cast(::android::hardware::graphics::common::V1_0::Dataspace::BT2020_PQ)) { - os += (first ? "" : " | "); - os += "BT2020_PQ"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_0::Dataspace::BT2020_PQ; - } - if ((o & ::android::hardware::graphics::common::V1_0::Dataspace::DEPTH) == - static_cast(::android::hardware::graphics::common::V1_0::Dataspace::DEPTH)) { - os += (first ? "" : " | "); - os += "DEPTH"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_0::Dataspace::DEPTH; - } - if ((o & ::android::hardware::graphics::common::V1_0::Dataspace::SENSOR) == - static_cast(::android::hardware::graphics::common::V1_0::Dataspace::SENSOR)) { - os += (first ? "" : " | "); - os += "SENSOR"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_0::Dataspace::SENSOR; - } - if (o != flipped) { - os += (first ? "" : " | "); - os += toHexString(o & (~flipped)); - } - os += " ("; - os += toHexString(o); - os += ")"; - return os; -} - -static inline std::string toString(::android::hardware::graphics::common::V1_0::Dataspace o) { - using ::android::hardware::details::toHexString; - if (o == ::android::hardware::graphics::common::V1_0::Dataspace::UNKNOWN) { - return "UNKNOWN"; - } - if (o == ::android::hardware::graphics::common::V1_0::Dataspace::ARBITRARY) { - return "ARBITRARY"; - } - if (o == ::android::hardware::graphics::common::V1_0::Dataspace::STANDARD_SHIFT) { - return "STANDARD_SHIFT"; - } - if (o == ::android::hardware::graphics::common::V1_0::Dataspace::STANDARD_MASK) { - return "STANDARD_MASK"; - } - if (o == ::android::hardware::graphics::common::V1_0::Dataspace::STANDARD_UNSPECIFIED) { - return "STANDARD_UNSPECIFIED"; - } - if (o == ::android::hardware::graphics::common::V1_0::Dataspace::STANDARD_BT709) { - return "STANDARD_BT709"; - } - if (o == ::android::hardware::graphics::common::V1_0::Dataspace::STANDARD_BT601_625) { - return "STANDARD_BT601_625"; - } - if (o == ::android::hardware::graphics::common::V1_0::Dataspace::STANDARD_BT601_625_UNADJUSTED) { - return "STANDARD_BT601_625_UNADJUSTED"; - } - if (o == ::android::hardware::graphics::common::V1_0::Dataspace::STANDARD_BT601_525) { - return "STANDARD_BT601_525"; - } - if (o == ::android::hardware::graphics::common::V1_0::Dataspace::STANDARD_BT601_525_UNADJUSTED) { - return "STANDARD_BT601_525_UNADJUSTED"; - } - if (o == ::android::hardware::graphics::common::V1_0::Dataspace::STANDARD_BT2020) { - return "STANDARD_BT2020"; - } - if (o == - ::android::hardware::graphics::common::V1_0::Dataspace::STANDARD_BT2020_CONSTANT_LUMINANCE) { - return "STANDARD_BT2020_CONSTANT_LUMINANCE"; - } - if (o == ::android::hardware::graphics::common::V1_0::Dataspace::STANDARD_BT470M) { - return "STANDARD_BT470M"; - } - if (o == ::android::hardware::graphics::common::V1_0::Dataspace::STANDARD_FILM) { - return "STANDARD_FILM"; - } - if (o == ::android::hardware::graphics::common::V1_0::Dataspace::STANDARD_DCI_P3) { - return "STANDARD_DCI_P3"; - } - if (o == ::android::hardware::graphics::common::V1_0::Dataspace::STANDARD_ADOBE_RGB) { - return "STANDARD_ADOBE_RGB"; - } - if (o == ::android::hardware::graphics::common::V1_0::Dataspace::TRANSFER_SHIFT) { - return "TRANSFER_SHIFT"; - } - if (o == ::android::hardware::graphics::common::V1_0::Dataspace::TRANSFER_MASK) { - return "TRANSFER_MASK"; - } - if (o == ::android::hardware::graphics::common::V1_0::Dataspace::TRANSFER_UNSPECIFIED) { - return "TRANSFER_UNSPECIFIED"; - } - if (o == ::android::hardware::graphics::common::V1_0::Dataspace::TRANSFER_LINEAR) { - return "TRANSFER_LINEAR"; - } - if (o == ::android::hardware::graphics::common::V1_0::Dataspace::TRANSFER_SRGB) { - return "TRANSFER_SRGB"; - } - if (o == ::android::hardware::graphics::common::V1_0::Dataspace::TRANSFER_SMPTE_170M) { - return "TRANSFER_SMPTE_170M"; - } - if (o == ::android::hardware::graphics::common::V1_0::Dataspace::TRANSFER_GAMMA2_2) { - return "TRANSFER_GAMMA2_2"; - } - if (o == ::android::hardware::graphics::common::V1_0::Dataspace::TRANSFER_GAMMA2_6) { - return "TRANSFER_GAMMA2_6"; - } - if (o == ::android::hardware::graphics::common::V1_0::Dataspace::TRANSFER_GAMMA2_8) { - return "TRANSFER_GAMMA2_8"; - } - if (o == ::android::hardware::graphics::common::V1_0::Dataspace::TRANSFER_ST2084) { - return "TRANSFER_ST2084"; - } - if (o == ::android::hardware::graphics::common::V1_0::Dataspace::TRANSFER_HLG) { - return "TRANSFER_HLG"; - } - if (o == ::android::hardware::graphics::common::V1_0::Dataspace::RANGE_SHIFT) { - return "RANGE_SHIFT"; - } - if (o == ::android::hardware::graphics::common::V1_0::Dataspace::RANGE_MASK) { - return "RANGE_MASK"; - } - if (o == ::android::hardware::graphics::common::V1_0::Dataspace::RANGE_UNSPECIFIED) { - return "RANGE_UNSPECIFIED"; - } - if (o == ::android::hardware::graphics::common::V1_0::Dataspace::RANGE_FULL) { - return "RANGE_FULL"; - } - if (o == ::android::hardware::graphics::common::V1_0::Dataspace::RANGE_LIMITED) { - return "RANGE_LIMITED"; - } - if (o == ::android::hardware::graphics::common::V1_0::Dataspace::RANGE_EXTENDED) { - return "RANGE_EXTENDED"; - } - if (o == ::android::hardware::graphics::common::V1_0::Dataspace::SRGB_LINEAR) { - return "SRGB_LINEAR"; - } - if (o == ::android::hardware::graphics::common::V1_0::Dataspace::V0_SRGB_LINEAR) { - return "V0_SRGB_LINEAR"; - } - if (o == ::android::hardware::graphics::common::V1_0::Dataspace::V0_SCRGB_LINEAR) { - return "V0_SCRGB_LINEAR"; - } - if (o == ::android::hardware::graphics::common::V1_0::Dataspace::SRGB) { - return "SRGB"; - } - if (o == ::android::hardware::graphics::common::V1_0::Dataspace::V0_SRGB) { - return "V0_SRGB"; - } - if (o == ::android::hardware::graphics::common::V1_0::Dataspace::V0_SCRGB) { - return "V0_SCRGB"; - } - if (o == ::android::hardware::graphics::common::V1_0::Dataspace::JFIF) { - return "JFIF"; - } - if (o == ::android::hardware::graphics::common::V1_0::Dataspace::V0_JFIF) { - return "V0_JFIF"; - } - if (o == ::android::hardware::graphics::common::V1_0::Dataspace::BT601_625) { - return "BT601_625"; - } - if (o == ::android::hardware::graphics::common::V1_0::Dataspace::V0_BT601_625) { - return "V0_BT601_625"; - } - if (o == ::android::hardware::graphics::common::V1_0::Dataspace::BT601_525) { - return "BT601_525"; - } - if (o == ::android::hardware::graphics::common::V1_0::Dataspace::V0_BT601_525) { - return "V0_BT601_525"; - } - if (o == ::android::hardware::graphics::common::V1_0::Dataspace::BT709) { - return "BT709"; - } - if (o == ::android::hardware::graphics::common::V1_0::Dataspace::V0_BT709) { - return "V0_BT709"; - } - if (o == ::android::hardware::graphics::common::V1_0::Dataspace::DCI_P3_LINEAR) { - return "DCI_P3_LINEAR"; - } - if (o == ::android::hardware::graphics::common::V1_0::Dataspace::DCI_P3) { - return "DCI_P3"; - } - if (o == ::android::hardware::graphics::common::V1_0::Dataspace::DISPLAY_P3_LINEAR) { - return "DISPLAY_P3_LINEAR"; - } - if (o == ::android::hardware::graphics::common::V1_0::Dataspace::DISPLAY_P3) { - return "DISPLAY_P3"; - } - if (o == ::android::hardware::graphics::common::V1_0::Dataspace::ADOBE_RGB) { - return "ADOBE_RGB"; - } - if (o == ::android::hardware::graphics::common::V1_0::Dataspace::BT2020_LINEAR) { - return "BT2020_LINEAR"; - } - if (o == ::android::hardware::graphics::common::V1_0::Dataspace::BT2020) { - return "BT2020"; - } - if (o == ::android::hardware::graphics::common::V1_0::Dataspace::BT2020_PQ) { - return "BT2020_PQ"; - } - if (o == ::android::hardware::graphics::common::V1_0::Dataspace::DEPTH) { - return "DEPTH"; - } - if (o == ::android::hardware::graphics::common::V1_0::Dataspace::SENSOR) { - return "SENSOR"; - } - std::string os; - os += toHexString(static_cast(o)); - return os; -} - -template <> -inline std::string toString<::android::hardware::graphics::common::V1_0::ColorMode>(int32_t o) { - using ::android::hardware::details::toHexString; - std::string os; - ::android::hardware::hidl_bitfield<::android::hardware::graphics::common::V1_0::ColorMode> - flipped = 0; - bool first = true; - if ((o & ::android::hardware::graphics::common::V1_0::ColorMode::NATIVE) == - static_cast(::android::hardware::graphics::common::V1_0::ColorMode::NATIVE)) { - os += (first ? "" : " | "); - os += "NATIVE"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_0::ColorMode::NATIVE; - } - if ((o & ::android::hardware::graphics::common::V1_0::ColorMode::STANDARD_BT601_625) == - static_cast( - ::android::hardware::graphics::common::V1_0::ColorMode::STANDARD_BT601_625)) { - os += (first ? "" : " | "); - os += "STANDARD_BT601_625"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_0::ColorMode::STANDARD_BT601_625; - } - if ((o & ::android::hardware::graphics::common::V1_0::ColorMode::STANDARD_BT601_625_UNADJUSTED) == - static_cast( - ::android::hardware::graphics::common::V1_0::ColorMode::STANDARD_BT601_625_UNADJUSTED)) { - os += (first ? "" : " | "); - os += "STANDARD_BT601_625_UNADJUSTED"; - first = false; - flipped |= - ::android::hardware::graphics::common::V1_0::ColorMode::STANDARD_BT601_625_UNADJUSTED; - } - if ((o & ::android::hardware::graphics::common::V1_0::ColorMode::STANDARD_BT601_525) == - static_cast( - ::android::hardware::graphics::common::V1_0::ColorMode::STANDARD_BT601_525)) { - os += (first ? "" : " | "); - os += "STANDARD_BT601_525"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_0::ColorMode::STANDARD_BT601_525; - } - if ((o & ::android::hardware::graphics::common::V1_0::ColorMode::STANDARD_BT601_525_UNADJUSTED) == - static_cast( - ::android::hardware::graphics::common::V1_0::ColorMode::STANDARD_BT601_525_UNADJUSTED)) { - os += (first ? "" : " | "); - os += "STANDARD_BT601_525_UNADJUSTED"; - first = false; - flipped |= - ::android::hardware::graphics::common::V1_0::ColorMode::STANDARD_BT601_525_UNADJUSTED; - } - if ((o & ::android::hardware::graphics::common::V1_0::ColorMode::STANDARD_BT709) == - static_cast( - ::android::hardware::graphics::common::V1_0::ColorMode::STANDARD_BT709)) { - os += (first ? "" : " | "); - os += "STANDARD_BT709"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_0::ColorMode::STANDARD_BT709; - } - if ((o & ::android::hardware::graphics::common::V1_0::ColorMode::DCI_P3) == - static_cast(::android::hardware::graphics::common::V1_0::ColorMode::DCI_P3)) { - os += (first ? "" : " | "); - os += "DCI_P3"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_0::ColorMode::DCI_P3; - } - if ((o & ::android::hardware::graphics::common::V1_0::ColorMode::SRGB) == - static_cast(::android::hardware::graphics::common::V1_0::ColorMode::SRGB)) { - os += (first ? "" : " | "); - os += "SRGB"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_0::ColorMode::SRGB; - } - if ((o & ::android::hardware::graphics::common::V1_0::ColorMode::ADOBE_RGB) == - static_cast(::android::hardware::graphics::common::V1_0::ColorMode::ADOBE_RGB)) { - os += (first ? "" : " | "); - os += "ADOBE_RGB"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_0::ColorMode::ADOBE_RGB; - } - if ((o & ::android::hardware::graphics::common::V1_0::ColorMode::DISPLAY_P3) == - static_cast(::android::hardware::graphics::common::V1_0::ColorMode::DISPLAY_P3)) { - os += (first ? "" : " | "); - os += "DISPLAY_P3"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_0::ColorMode::DISPLAY_P3; - } - if (o != flipped) { - os += (first ? "" : " | "); - os += toHexString(o & (~flipped)); - } - os += " ("; - os += toHexString(o); - os += ")"; - return os; -} - -static inline std::string toString(::android::hardware::graphics::common::V1_0::ColorMode o) { - using ::android::hardware::details::toHexString; - if (o == ::android::hardware::graphics::common::V1_0::ColorMode::NATIVE) { - return "NATIVE"; - } - if (o == ::android::hardware::graphics::common::V1_0::ColorMode::STANDARD_BT601_625) { - return "STANDARD_BT601_625"; - } - if (o == ::android::hardware::graphics::common::V1_0::ColorMode::STANDARD_BT601_625_UNADJUSTED) { - return "STANDARD_BT601_625_UNADJUSTED"; - } - if (o == ::android::hardware::graphics::common::V1_0::ColorMode::STANDARD_BT601_525) { - return "STANDARD_BT601_525"; - } - if (o == ::android::hardware::graphics::common::V1_0::ColorMode::STANDARD_BT601_525_UNADJUSTED) { - return "STANDARD_BT601_525_UNADJUSTED"; - } - if (o == ::android::hardware::graphics::common::V1_0::ColorMode::STANDARD_BT709) { - return "STANDARD_BT709"; - } - if (o == ::android::hardware::graphics::common::V1_0::ColorMode::DCI_P3) { - return "DCI_P3"; - } - if (o == ::android::hardware::graphics::common::V1_0::ColorMode::SRGB) { - return "SRGB"; - } - if (o == ::android::hardware::graphics::common::V1_0::ColorMode::ADOBE_RGB) { - return "ADOBE_RGB"; - } - if (o == ::android::hardware::graphics::common::V1_0::ColorMode::DISPLAY_P3) { - return "DISPLAY_P3"; - } - std::string os; - os += toHexString(static_cast(o)); - return os; -} - -template <> -inline std::string toString<::android::hardware::graphics::common::V1_0::ColorTransform>( - int32_t o) { - using ::android::hardware::details::toHexString; - std::string os; - ::android::hardware::hidl_bitfield<::android::hardware::graphics::common::V1_0::ColorTransform> - flipped = 0; - bool first = true; - if ((o & ::android::hardware::graphics::common::V1_0::ColorTransform::IDENTITY) == - static_cast(::android::hardware::graphics::common::V1_0::ColorTransform::IDENTITY)) { - os += (first ? "" : " | "); - os += "IDENTITY"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_0::ColorTransform::IDENTITY; - } - if ((o & ::android::hardware::graphics::common::V1_0::ColorTransform::ARBITRARY_MATRIX) == - static_cast( - ::android::hardware::graphics::common::V1_0::ColorTransform::ARBITRARY_MATRIX)) { - os += (first ? "" : " | "); - os += "ARBITRARY_MATRIX"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_0::ColorTransform::ARBITRARY_MATRIX; - } - if ((o & ::android::hardware::graphics::common::V1_0::ColorTransform::VALUE_INVERSE) == - static_cast( - ::android::hardware::graphics::common::V1_0::ColorTransform::VALUE_INVERSE)) { - os += (first ? "" : " | "); - os += "VALUE_INVERSE"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_0::ColorTransform::VALUE_INVERSE; - } - if ((o & ::android::hardware::graphics::common::V1_0::ColorTransform::GRAYSCALE) == - static_cast( - ::android::hardware::graphics::common::V1_0::ColorTransform::GRAYSCALE)) { - os += (first ? "" : " | "); - os += "GRAYSCALE"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_0::ColorTransform::GRAYSCALE; - } - if ((o & ::android::hardware::graphics::common::V1_0::ColorTransform::CORRECT_PROTANOPIA) == - static_cast( - ::android::hardware::graphics::common::V1_0::ColorTransform::CORRECT_PROTANOPIA)) { - os += (first ? "" : " | "); - os += "CORRECT_PROTANOPIA"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_0::ColorTransform::CORRECT_PROTANOPIA; - } - if ((o & ::android::hardware::graphics::common::V1_0::ColorTransform::CORRECT_DEUTERANOPIA) == - static_cast( - ::android::hardware::graphics::common::V1_0::ColorTransform::CORRECT_DEUTERANOPIA)) { - os += (first ? "" : " | "); - os += "CORRECT_DEUTERANOPIA"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_0::ColorTransform::CORRECT_DEUTERANOPIA; - } - if ((o & ::android::hardware::graphics::common::V1_0::ColorTransform::CORRECT_TRITANOPIA) == - static_cast( - ::android::hardware::graphics::common::V1_0::ColorTransform::CORRECT_TRITANOPIA)) { - os += (first ? "" : " | "); - os += "CORRECT_TRITANOPIA"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_0::ColorTransform::CORRECT_TRITANOPIA; - } - if (o != flipped) { - os += (first ? "" : " | "); - os += toHexString(o & (~flipped)); - } - os += " ("; - os += toHexString(o); - os += ")"; - return os; -} - -static inline std::string toString(::android::hardware::graphics::common::V1_0::ColorTransform o) { - using ::android::hardware::details::toHexString; - if (o == ::android::hardware::graphics::common::V1_0::ColorTransform::IDENTITY) { - return "IDENTITY"; - } - if (o == ::android::hardware::graphics::common::V1_0::ColorTransform::ARBITRARY_MATRIX) { - return "ARBITRARY_MATRIX"; - } - if (o == ::android::hardware::graphics::common::V1_0::ColorTransform::VALUE_INVERSE) { - return "VALUE_INVERSE"; - } - if (o == ::android::hardware::graphics::common::V1_0::ColorTransform::GRAYSCALE) { - return "GRAYSCALE"; - } - if (o == ::android::hardware::graphics::common::V1_0::ColorTransform::CORRECT_PROTANOPIA) { - return "CORRECT_PROTANOPIA"; - } - if (o == ::android::hardware::graphics::common::V1_0::ColorTransform::CORRECT_DEUTERANOPIA) { - return "CORRECT_DEUTERANOPIA"; - } - if (o == ::android::hardware::graphics::common::V1_0::ColorTransform::CORRECT_TRITANOPIA) { - return "CORRECT_TRITANOPIA"; - } - std::string os; - os += toHexString(static_cast(o)); - return os; -} - -template <> -inline std::string toString<::android::hardware::graphics::common::V1_0::Hdr>(int32_t o) { - using ::android::hardware::details::toHexString; - std::string os; - ::android::hardware::hidl_bitfield<::android::hardware::graphics::common::V1_0::Hdr> flipped = 0; - bool first = true; - if ((o & ::android::hardware::graphics::common::V1_0::Hdr::DOLBY_VISION) == - static_cast(::android::hardware::graphics::common::V1_0::Hdr::DOLBY_VISION)) { - os += (first ? "" : " | "); - os += "DOLBY_VISION"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_0::Hdr::DOLBY_VISION; - } - if ((o & ::android::hardware::graphics::common::V1_0::Hdr::HDR10) == - static_cast(::android::hardware::graphics::common::V1_0::Hdr::HDR10)) { - os += (first ? "" : " | "); - os += "HDR10"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_0::Hdr::HDR10; - } - if ((o & ::android::hardware::graphics::common::V1_0::Hdr::HLG) == - static_cast(::android::hardware::graphics::common::V1_0::Hdr::HLG)) { - os += (first ? "" : " | "); - os += "HLG"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_0::Hdr::HLG; - } - if (o != flipped) { - os += (first ? "" : " | "); - os += toHexString(o & (~flipped)); - } - os += " ("; - os += toHexString(o); - os += ")"; - return os; -} - -static inline std::string toString(::android::hardware::graphics::common::V1_0::Hdr o) { - using ::android::hardware::details::toHexString; - if (o == ::android::hardware::graphics::common::V1_0::Hdr::DOLBY_VISION) { - return "DOLBY_VISION"; - } - if (o == ::android::hardware::graphics::common::V1_0::Hdr::HDR10) { - return "HDR10"; - } - if (o == ::android::hardware::graphics::common::V1_0::Hdr::HLG) { - return "HLG"; - } - std::string os; - os += toHexString(static_cast(o)); - return os; -} - -} // namespace V1_0 -} // namespace common -} // namespace graphics -} // namespace hardware -} // namespace android - -// -// global type declarations for package -// - -namespace android { -namespace hardware { -namespace details { -template <> -constexpr std::array<::android::hardware::graphics::common::V1_0::PixelFormat, 20> - hidl_enum_values<::android::hardware::graphics::common::V1_0::PixelFormat> = { - ::android::hardware::graphics::common::V1_0::PixelFormat::RGBA_8888, - ::android::hardware::graphics::common::V1_0::PixelFormat::RGBX_8888, - ::android::hardware::graphics::common::V1_0::PixelFormat::RGB_888, - ::android::hardware::graphics::common::V1_0::PixelFormat::RGB_565, - ::android::hardware::graphics::common::V1_0::PixelFormat::BGRA_8888, - ::android::hardware::graphics::common::V1_0::PixelFormat::YCBCR_422_SP, - ::android::hardware::graphics::common::V1_0::PixelFormat::YCRCB_420_SP, - ::android::hardware::graphics::common::V1_0::PixelFormat::YCBCR_422_I, - ::android::hardware::graphics::common::V1_0::PixelFormat::RGBA_FP16, - ::android::hardware::graphics::common::V1_0::PixelFormat::RAW16, - ::android::hardware::graphics::common::V1_0::PixelFormat::BLOB, - ::android::hardware::graphics::common::V1_0::PixelFormat::IMPLEMENTATION_DEFINED, - ::android::hardware::graphics::common::V1_0::PixelFormat::YCBCR_420_888, - ::android::hardware::graphics::common::V1_0::PixelFormat::RAW_OPAQUE, - ::android::hardware::graphics::common::V1_0::PixelFormat::RAW10, - ::android::hardware::graphics::common::V1_0::PixelFormat::RAW12, - ::android::hardware::graphics::common::V1_0::PixelFormat::RGBA_1010102, - ::android::hardware::graphics::common::V1_0::PixelFormat::Y8, - ::android::hardware::graphics::common::V1_0::PixelFormat::Y16, - ::android::hardware::graphics::common::V1_0::PixelFormat::YV12, -}; -} // namespace details -} // namespace hardware -} // namespace android - -namespace android { -namespace hardware { -namespace details { -template <> -constexpr std::array<::android::hardware::graphics::common::V1_0::BufferUsage, 23> - hidl_enum_values<::android::hardware::graphics::common::V1_0::BufferUsage> = { - ::android::hardware::graphics::common::V1_0::BufferUsage::CPU_READ_MASK, - ::android::hardware::graphics::common::V1_0::BufferUsage::CPU_READ_NEVER, - ::android::hardware::graphics::common::V1_0::BufferUsage::CPU_READ_RARELY, - ::android::hardware::graphics::common::V1_0::BufferUsage::CPU_READ_OFTEN, - ::android::hardware::graphics::common::V1_0::BufferUsage::CPU_WRITE_MASK, - ::android::hardware::graphics::common::V1_0::BufferUsage::CPU_WRITE_NEVER, - ::android::hardware::graphics::common::V1_0::BufferUsage::CPU_WRITE_RARELY, - ::android::hardware::graphics::common::V1_0::BufferUsage::CPU_WRITE_OFTEN, - ::android::hardware::graphics::common::V1_0::BufferUsage::GPU_TEXTURE, - ::android::hardware::graphics::common::V1_0::BufferUsage::GPU_RENDER_TARGET, - ::android::hardware::graphics::common::V1_0::BufferUsage::COMPOSER_OVERLAY, - ::android::hardware::graphics::common::V1_0::BufferUsage::COMPOSER_CLIENT_TARGET, - ::android::hardware::graphics::common::V1_0::BufferUsage::PROTECTED, - ::android::hardware::graphics::common::V1_0::BufferUsage::COMPOSER_CURSOR, - ::android::hardware::graphics::common::V1_0::BufferUsage::VIDEO_ENCODER, - ::android::hardware::graphics::common::V1_0::BufferUsage::CAMERA_OUTPUT, - ::android::hardware::graphics::common::V1_0::BufferUsage::CAMERA_INPUT, - ::android::hardware::graphics::common::V1_0::BufferUsage::RENDERSCRIPT, - ::android::hardware::graphics::common::V1_0::BufferUsage::VIDEO_DECODER, - ::android::hardware::graphics::common::V1_0::BufferUsage::SENSOR_DIRECT_DATA, - ::android::hardware::graphics::common::V1_0::BufferUsage::GPU_DATA_BUFFER, - ::android::hardware::graphics::common::V1_0::BufferUsage::VENDOR_MASK, - ::android::hardware::graphics::common::V1_0::BufferUsage::VENDOR_MASK_HI, -}; -} // namespace details -} // namespace hardware -} // namespace android - -namespace android { -namespace hardware { -namespace details { -template <> -constexpr std::array<::android::hardware::graphics::common::V1_0::Transform, 5> - hidl_enum_values<::android::hardware::graphics::common::V1_0::Transform> = { - ::android::hardware::graphics::common::V1_0::Transform::FLIP_H, - ::android::hardware::graphics::common::V1_0::Transform::FLIP_V, - ::android::hardware::graphics::common::V1_0::Transform::ROT_90, - ::android::hardware::graphics::common::V1_0::Transform::ROT_180, - ::android::hardware::graphics::common::V1_0::Transform::ROT_270, -}; -} // namespace details -} // namespace hardware -} // namespace android - -namespace android { -namespace hardware { -namespace details { -template <> -constexpr std::array<::android::hardware::graphics::common::V1_0::Dataspace, 57> - hidl_enum_values<::android::hardware::graphics::common::V1_0::Dataspace> = { - ::android::hardware::graphics::common::V1_0::Dataspace::UNKNOWN, - ::android::hardware::graphics::common::V1_0::Dataspace::ARBITRARY, - ::android::hardware::graphics::common::V1_0::Dataspace::STANDARD_SHIFT, - ::android::hardware::graphics::common::V1_0::Dataspace::STANDARD_MASK, - ::android::hardware::graphics::common::V1_0::Dataspace::STANDARD_UNSPECIFIED, - ::android::hardware::graphics::common::V1_0::Dataspace::STANDARD_BT709, - ::android::hardware::graphics::common::V1_0::Dataspace::STANDARD_BT601_625, - ::android::hardware::graphics::common::V1_0::Dataspace::STANDARD_BT601_625_UNADJUSTED, - ::android::hardware::graphics::common::V1_0::Dataspace::STANDARD_BT601_525, - ::android::hardware::graphics::common::V1_0::Dataspace::STANDARD_BT601_525_UNADJUSTED, - ::android::hardware::graphics::common::V1_0::Dataspace::STANDARD_BT2020, - ::android::hardware::graphics::common::V1_0::Dataspace::STANDARD_BT2020_CONSTANT_LUMINANCE, - ::android::hardware::graphics::common::V1_0::Dataspace::STANDARD_BT470M, - ::android::hardware::graphics::common::V1_0::Dataspace::STANDARD_FILM, - ::android::hardware::graphics::common::V1_0::Dataspace::STANDARD_DCI_P3, - ::android::hardware::graphics::common::V1_0::Dataspace::STANDARD_ADOBE_RGB, - ::android::hardware::graphics::common::V1_0::Dataspace::TRANSFER_SHIFT, - ::android::hardware::graphics::common::V1_0::Dataspace::TRANSFER_MASK, - ::android::hardware::graphics::common::V1_0::Dataspace::TRANSFER_UNSPECIFIED, - ::android::hardware::graphics::common::V1_0::Dataspace::TRANSFER_LINEAR, - ::android::hardware::graphics::common::V1_0::Dataspace::TRANSFER_SRGB, - ::android::hardware::graphics::common::V1_0::Dataspace::TRANSFER_SMPTE_170M, - ::android::hardware::graphics::common::V1_0::Dataspace::TRANSFER_GAMMA2_2, - ::android::hardware::graphics::common::V1_0::Dataspace::TRANSFER_GAMMA2_6, - ::android::hardware::graphics::common::V1_0::Dataspace::TRANSFER_GAMMA2_8, - ::android::hardware::graphics::common::V1_0::Dataspace::TRANSFER_ST2084, - ::android::hardware::graphics::common::V1_0::Dataspace::TRANSFER_HLG, - ::android::hardware::graphics::common::V1_0::Dataspace::RANGE_SHIFT, - ::android::hardware::graphics::common::V1_0::Dataspace::RANGE_MASK, - ::android::hardware::graphics::common::V1_0::Dataspace::RANGE_UNSPECIFIED, - ::android::hardware::graphics::common::V1_0::Dataspace::RANGE_FULL, - ::android::hardware::graphics::common::V1_0::Dataspace::RANGE_LIMITED, - ::android::hardware::graphics::common::V1_0::Dataspace::RANGE_EXTENDED, - ::android::hardware::graphics::common::V1_0::Dataspace::SRGB_LINEAR, - ::android::hardware::graphics::common::V1_0::Dataspace::V0_SRGB_LINEAR, - ::android::hardware::graphics::common::V1_0::Dataspace::V0_SCRGB_LINEAR, - ::android::hardware::graphics::common::V1_0::Dataspace::SRGB, - ::android::hardware::graphics::common::V1_0::Dataspace::V0_SRGB, - ::android::hardware::graphics::common::V1_0::Dataspace::V0_SCRGB, - ::android::hardware::graphics::common::V1_0::Dataspace::JFIF, - ::android::hardware::graphics::common::V1_0::Dataspace::V0_JFIF, - ::android::hardware::graphics::common::V1_0::Dataspace::BT601_625, - ::android::hardware::graphics::common::V1_0::Dataspace::V0_BT601_625, - ::android::hardware::graphics::common::V1_0::Dataspace::BT601_525, - ::android::hardware::graphics::common::V1_0::Dataspace::V0_BT601_525, - ::android::hardware::graphics::common::V1_0::Dataspace::BT709, - ::android::hardware::graphics::common::V1_0::Dataspace::V0_BT709, - ::android::hardware::graphics::common::V1_0::Dataspace::DCI_P3_LINEAR, - ::android::hardware::graphics::common::V1_0::Dataspace::DCI_P3, - ::android::hardware::graphics::common::V1_0::Dataspace::DISPLAY_P3_LINEAR, - ::android::hardware::graphics::common::V1_0::Dataspace::DISPLAY_P3, - ::android::hardware::graphics::common::V1_0::Dataspace::ADOBE_RGB, - ::android::hardware::graphics::common::V1_0::Dataspace::BT2020_LINEAR, - ::android::hardware::graphics::common::V1_0::Dataspace::BT2020, - ::android::hardware::graphics::common::V1_0::Dataspace::BT2020_PQ, - ::android::hardware::graphics::common::V1_0::Dataspace::DEPTH, - ::android::hardware::graphics::common::V1_0::Dataspace::SENSOR, -}; -} // namespace details -} // namespace hardware -} // namespace android - -namespace android { -namespace hardware { -namespace details { -template <> -constexpr std::array<::android::hardware::graphics::common::V1_0::ColorMode, 10> - hidl_enum_values<::android::hardware::graphics::common::V1_0::ColorMode> = { - ::android::hardware::graphics::common::V1_0::ColorMode::NATIVE, - ::android::hardware::graphics::common::V1_0::ColorMode::STANDARD_BT601_625, - ::android::hardware::graphics::common::V1_0::ColorMode::STANDARD_BT601_625_UNADJUSTED, - ::android::hardware::graphics::common::V1_0::ColorMode::STANDARD_BT601_525, - ::android::hardware::graphics::common::V1_0::ColorMode::STANDARD_BT601_525_UNADJUSTED, - ::android::hardware::graphics::common::V1_0::ColorMode::STANDARD_BT709, - ::android::hardware::graphics::common::V1_0::ColorMode::DCI_P3, - ::android::hardware::graphics::common::V1_0::ColorMode::SRGB, - ::android::hardware::graphics::common::V1_0::ColorMode::ADOBE_RGB, - ::android::hardware::graphics::common::V1_0::ColorMode::DISPLAY_P3, -}; -} // namespace details -} // namespace hardware -} // namespace android - -namespace android { -namespace hardware { -namespace details { -template <> -constexpr std::array<::android::hardware::graphics::common::V1_0::ColorTransform, 7> - hidl_enum_values<::android::hardware::graphics::common::V1_0::ColorTransform> = { - ::android::hardware::graphics::common::V1_0::ColorTransform::IDENTITY, - ::android::hardware::graphics::common::V1_0::ColorTransform::ARBITRARY_MATRIX, - ::android::hardware::graphics::common::V1_0::ColorTransform::VALUE_INVERSE, - ::android::hardware::graphics::common::V1_0::ColorTransform::GRAYSCALE, - ::android::hardware::graphics::common::V1_0::ColorTransform::CORRECT_PROTANOPIA, - ::android::hardware::graphics::common::V1_0::ColorTransform::CORRECT_DEUTERANOPIA, - ::android::hardware::graphics::common::V1_0::ColorTransform::CORRECT_TRITANOPIA, -}; -} // namespace details -} // namespace hardware -} // namespace android - -namespace android { -namespace hardware { -namespace details { -template <> -constexpr std::array<::android::hardware::graphics::common::V1_0::Hdr, 3> - hidl_enum_values<::android::hardware::graphics::common::V1_0::Hdr> = { - ::android::hardware::graphics::common::V1_0::Hdr::DOLBY_VISION, - ::android::hardware::graphics::common::V1_0::Hdr::HDR10, - ::android::hardware::graphics::common::V1_0::Hdr::HLG, -}; -} // namespace details -} // namespace hardware -} // namespace android - -#endif // HIDL_GENERATED_ANDROID_HARDWARE_GRAPHICS_COMMON_V1_0_TYPES_H - -#ifndef HIDL_GENERATED_ANDROID_HARDWARE_GRAPHICS_COMMON_V1_1_TYPES_H -#define HIDL_GENERATED_ANDROID_HARDWARE_GRAPHICS_COMMON_V1_1_TYPES_H - -#include -#include -#include -#include - -namespace android { -namespace hardware { -namespace graphics { -namespace common { -namespace V1_1 { - -// Forward declaration for forward reference support: -enum class PixelFormat : int32_t; -enum class BufferUsage : uint64_t; -enum class Dataspace : int32_t; -enum class ColorMode : int32_t; -enum class RenderIntent : int32_t; - -/** - * Pixel formats for graphics buffers. - */ -enum class PixelFormat : int32_t { - /** - * 32-bit format that has 8-bit R, G, B, and A components, in that order, - * from the lowest memory address to the highest memory address. - * - * The component values are unsigned normalized to the range [0, 1], whose - * interpretation is defined by the dataspace. - */ - RGBA_8888 = 1 /* 0x1 */, - /** - * 32-bit format that has 8-bit R, G, B, and unused components, in that - * order, from the lowest memory address to the highest memory address. - * - * The component values are unsigned normalized to the range [0, 1], whose - * interpretation is defined by the dataspace. - */ - RGBX_8888 = 2 /* 0x2 */, - /** - * 24-bit format that has 8-bit R, G, and B components, in that order, - * from the lowest memory address to the highest memory address. - * - * The component values are unsigned normalized to the range [0, 1], whose - * interpretation is defined by the dataspace. - */ - RGB_888 = 3 /* 0x3 */, - /** - * 16-bit packed format that has 5-bit R, 6-bit G, and 5-bit B components, - * in that order, from the most-sigfinicant bits to the least-significant - * bits. - * - * The component values are unsigned normalized to the range [0, 1], whose - * interpretation is defined by the dataspace. - */ - RGB_565 = 4 /* 0x4 */, - /** - * 32-bit format that has 8-bit B, G, R, and A components, in that order, - * from the lowest memory address to the highest memory address. - * - * The component values are unsigned normalized to the range [0, 1], whose - * interpretation is defined by the dataspace. - */ - BGRA_8888 = 5 /* 0x5 */, - /** - * Legacy formats deprecated in favor of YCBCR_420_888. - */ - YCBCR_422_SP = 16 /* 0x10 */, - YCRCB_420_SP = 17 /* 0x11 */, - YCBCR_422_I = 20 /* 0x14 */, - /** - * 64-bit format that has 16-bit R, G, B, and A components, in that order, - * from the lowest memory address to the highest memory address. - * - * The component values are signed floats, whose interpretation is defined - * by the dataspace. - */ - RGBA_FP16 = 22 /* 0x16 */, - /** - * RAW16 is a single-channel, 16-bit, little endian format, typically - * representing raw Bayer-pattern images from an image sensor, with minimal - * processing. - * - * The exact pixel layout of the data in the buffer is sensor-dependent, and - * needs to be queried from the camera device. - * - * Generally, not all 16 bits are used; more common values are 10 or 12 - * bits. If not all bits are used, the lower-order bits are filled first. - * All parameters to interpret the raw data (black and white points, - * color space, etc) must be queried from the camera device. - * - * This format assumes - * - an even width - * - an even height - * - a horizontal stride multiple of 16 pixels - * - a vertical stride equal to the height - * - strides are specified in pixels, not in bytes - * - * size = stride * height * 2 - * - * This format must be accepted by the allocator when used with the - * following usage flags: - * - * - BufferUsage::CAMERA_* - * - BufferUsage::CPU_* - * - BufferUsage::RENDERSCRIPT - * - * The mapping of the dataspace to buffer contents for RAW16 is as - * follows: - * - * Dataspace value | Buffer contents - * -------------------------------+----------------------------------------- - * Dataspace::ARBITRARY | Raw image sensor data, layout is as - * | defined above. - * Dataspace::DEPTH | Unprocessed implementation-dependent raw - * | depth measurements, opaque with 16 bit - * | samples. - * Other | Unsupported - */ - RAW16 = 32 /* 0x20 */, - /** - * BLOB is used to carry task-specific data which does not have a standard - * image structure. The details of the format are left to the two - * endpoints. - * - * A typical use case is for transporting JPEG-compressed images from the - * Camera HAL to the framework or to applications. - * - * Buffers of this format must have a height of 1, and width equal to their - * size in bytes. - * - * The mapping of the dataspace to buffer contents for BLOB is as - * follows: - * - * Dataspace value | Buffer contents - * -------------------------------+----------------------------------------- - * Dataspace::JFIF | An encoded JPEG image - * Dataspace::DEPTH | An android_depth_points buffer - * Dataspace::SENSOR | Sensor event data. - * Other | Unsupported - */ - BLOB = 33 /* 0x21 */, - /** - * A format indicating that the choice of format is entirely up to the - * allocator. - * - * The allocator should examine the usage bits passed in when allocating a - * buffer with this format, and it should derive the pixel format from - * those usage flags. This format must never be used with any of the - * BufferUsage::CPU_* usage flags. - * - * Even when the internally chosen format has an alpha component, the - * clients must assume the alpha vlaue to be 1.0. - * - * The interpretation of the component values is defined by the dataspace. - */ - IMPLEMENTATION_DEFINED = 34 /* 0x22 */, - /** - * This format allows platforms to use an efficient YCbCr/YCrCb 4:2:0 - * buffer layout, while still describing the general format in a - * layout-independent manner. While called YCbCr, it can be used to - * describe formats with either chromatic ordering, as well as - * whole planar or semiplanar layouts. - * - * This format must be accepted by the allocator when BufferUsage::CPU_* - * are set. - * - * Buffers with this format must be locked with IMapper::lockYCbCr. - * Locking with IMapper::lock must return an error. - * - * The interpretation of the component values is defined by the dataspace. - */ - YCBCR_420_888 = 35 /* 0x23 */, - /** - * RAW_OPAQUE is a format for unprocessed raw image buffers coming from an - * image sensor. The actual structure of buffers of this format is - * implementation-dependent. - * - * This format must be accepted by the allocator when used with the - * following usage flags: - * - * - BufferUsage::CAMERA_* - * - BufferUsage::CPU_* - * - BufferUsage::RENDERSCRIPT - * - * The mapping of the dataspace to buffer contents for RAW_OPAQUE is as - * follows: - * - * Dataspace value | Buffer contents - * -------------------------------+----------------------------------------- - * Dataspace::ARBITRARY | Raw image sensor data. - * Other | Unsupported - */ - RAW_OPAQUE = 36 /* 0x24 */, - /** - * RAW10 is a single-channel, 10-bit per pixel, densely packed in each row, - * unprocessed format, usually representing raw Bayer-pattern images coming from - * an image sensor. - * - * In an image buffer with this format, starting from the first pixel of each - * row, each 4 consecutive pixels are packed into 5 bytes (40 bits). Each one - * of the first 4 bytes contains the top 8 bits of each pixel, The fifth byte - * contains the 2 least significant bits of the 4 pixels, the exact layout data - * for each 4 consecutive pixels is illustrated below (Pi[j] stands for the jth - * bit of the ith pixel): - * - * bit 7 bit 0 - * =====|=====|=====|=====|=====|=====|=====|=====| - * Byte 0: |P0[9]|P0[8]|P0[7]|P0[6]|P0[5]|P0[4]|P0[3]|P0[2]| - * |-----|-----|-----|-----|-----|-----|-----|-----| - * Byte 1: |P1[9]|P1[8]|P1[7]|P1[6]|P1[5]|P1[4]|P1[3]|P1[2]| - * |-----|-----|-----|-----|-----|-----|-----|-----| - * Byte 2: |P2[9]|P2[8]|P2[7]|P2[6]|P2[5]|P2[4]|P2[3]|P2[2]| - * |-----|-----|-----|-----|-----|-----|-----|-----| - * Byte 3: |P3[9]|P3[8]|P3[7]|P3[6]|P3[5]|P3[4]|P3[3]|P3[2]| - * |-----|-----|-----|-----|-----|-----|-----|-----| - * Byte 4: |P3[1]|P3[0]|P2[1]|P2[0]|P1[1]|P1[0]|P0[1]|P0[0]| - * =============================================== - * - * This format assumes - * - a width multiple of 4 pixels - * - an even height - * - a vertical stride equal to the height - * - strides are specified in bytes, not in pixels - * - * size = stride * height - * - * When stride is equal to width * (10 / 8), there will be no padding bytes at - * the end of each row, the entire image data is densely packed. When stride is - * larger than width * (10 / 8), padding bytes will be present at the end of each - * row (including the last row). - * - * This format must be accepted by the allocator when used with the - * following usage flags: - * - * - BufferUsage::CAMERA_* - * - BufferUsage::CPU_* - * - BufferUsage::RENDERSCRIPT - * - * The mapping of the dataspace to buffer contents for RAW10 is as - * follows: - * - * Dataspace value | Buffer contents - * -------------------------------+----------------------------------------- - * Dataspace::ARBITRARY | Raw image sensor data. - * Other | Unsupported - */ - RAW10 = 37 /* 0x25 */, - /** - * RAW12 is a single-channel, 12-bit per pixel, densely packed in each row, - * unprocessed format, usually representing raw Bayer-pattern images coming from - * an image sensor. - * - * In an image buffer with this format, starting from the first pixel of each - * row, each two consecutive pixels are packed into 3 bytes (24 bits). The first - * and second byte contains the top 8 bits of first and second pixel. The third - * byte contains the 4 least significant bits of the two pixels, the exact layout - * data for each two consecutive pixels is illustrated below (Pi[j] stands for - * the jth bit of the ith pixel): - * - * bit 7 bit 0 - * ======|======|======|======|======|======|======|======| - * Byte 0: |P0[11]|P0[10]|P0[ 9]|P0[ 8]|P0[ 7]|P0[ 6]|P0[ 5]|P0[ 4]| - * |------|------|------|------|------|------|------|------| - * Byte 1: |P1[11]|P1[10]|P1[ 9]|P1[ 8]|P1[ 7]|P1[ 6]|P1[ 5]|P1[ 4]| - * |------|------|------|------|------|------|------|------| - * Byte 2: |P1[ 3]|P1[ 2]|P1[ 1]|P1[ 0]|P0[ 3]|P0[ 2]|P0[ 1]|P0[ 0]| - * ======================================================= - * - * This format assumes: - * - a width multiple of 4 pixels - * - an even height - * - a vertical stride equal to the height - * - strides are specified in bytes, not in pixels - * - * size = stride * height - * - * When stride is equal to width * (12 / 8), there will be no padding bytes at - * the end of each row, the entire image data is densely packed. When stride is - * larger than width * (12 / 8), padding bytes will be present at the end of - * each row (including the last row). - * - * This format must be accepted by the allocator when used with the - * following usage flags: - * - * - BufferUsage::CAMERA_* - * - BufferUsage::CPU_* - * - BufferUsage::RENDERSCRIPT - * - * The mapping of the dataspace to buffer contents for RAW12 is as - * follows: - * - * Dataspace value | Buffer contents - * -------------------------------+----------------------------------------- - * Dataspace::ARBITRARY | Raw image sensor data. - * Other | Unsupported - */ - RAW12 = 38 /* 0x26 */, - /** - * 0x27 to 0x2A are reserved for flexible formats - * - * - * 32-bit packed format that has 2-bit A, 10-bit B, G, and R components, - * in that order, from the most-sigfinicant bits to the least-significant - * bits. - * - * The component values are unsigned normalized to the range [0, 1], whose - * interpretation is defined by the dataspace. - */ - RGBA_1010102 = 43 /* 0x2B */, - /** - * 0x100 - 0x1FF - * - * This range is reserved for vendor extensions. Formats in this range - * must support BufferUsage::GPU_TEXTURE. Clients must assume they do not - * have an alpha component. - * - * - * Y8 is a YUV planar format comprised of a WxH Y plane, with each pixel - * being represented by 8 bits. It is equivalent to just the Y plane from - * YV12. - * - * This format assumes - * - an even width - * - an even height - * - a horizontal stride multiple of 16 pixels - * - a vertical stride equal to the height - * - * size = stride * height - * - * This format must be accepted by the allocator when used with the - * following usage flags: - * - * - BufferUsage::CAMERA_* - * - BufferUsage::CPU_* - * - * The component values are unsigned normalized to the range [0, 1], whose - * interpretation is defined by the dataspace. - */ - Y8 = 538982489 /* 0x20203859 */, - /** - * Y16 is a YUV planar format comprised of a WxH Y plane, with each pixel - * being represented by 16 bits. It is just like Y8, but has double the - * bits per pixel (little endian). - * - * This format assumes - * - an even width - * - an even height - * - a horizontal stride multiple of 16 pixels - * - a vertical stride equal to the height - * - strides are specified in pixels, not in bytes - * - * size = stride * height * 2 - * - * This format must be accepted by the allocator when used with the - * following usage flags: - * - * - BufferUsage::CAMERA_* - * - BufferUsage::CPU_* - * - * The component values are unsigned normalized to the range [0, 1], whose - * interpretation is defined by the dataspace. When the dataspace is - * Dataspace::DEPTH, each pixel is a distance value measured by a depth - * camera, plus an associated confidence value. - */ - Y16 = 540422489 /* 0x20363159 */, - /** - * YV12 is a 4:2:0 YCrCb planar format comprised of a WxH Y plane followed - * by (W/2) x (H/2) Cr and Cb planes. - * - * This format assumes - * - an even width - * - an even height - * - a horizontal stride multiple of 16 pixels - * - a vertical stride equal to the height - * - * y_size = stride * height - * c_stride = ALIGN(stride/2, 16) - * c_size = c_stride * height/2 - * size = y_size + c_size * 2 - * cr_offset = y_size - * cb_offset = y_size + c_size - * - * This range is reserved for vendor extensions. Formats in this range - * must support BufferUsage::GPU_TEXTURE. Clients must assume they do not - * have an alpha component. - * - * This format must be accepted by the allocator when used with the - * following usage flags: - * - * - BufferUsage::CAMERA_* - * - BufferUsage::CPU_* - * - BufferUsage::GPU_TEXTURE - * - * The component values are unsigned normalized to the range [0, 1], whose - * interpretation is defined by the dataspace. - */ - YV12 = 842094169 /* 0x32315659 */, - /** - * 16-bit format that has a single 16-bit depth component. - * - * The component values are unsigned normalized to the range [0, 1], whose - * interpretation is defined by the dataspace. - */ - DEPTH_16 = 48 /* 0x30 */, - /** - * 32-bit format that has a single 24-bit depth component and, optionally, - * 8 bits that are unused. - * - * The component values are unsigned normalized to the range [0, 1], whose - * interpretation is defined by the dataspace. - */ - DEPTH_24 = 49 /* 0x31 */, - /** - * 32-bit format that has a 24-bit depth component and an 8-bit stencil - * component packed into 32-bits. - * - * The depth component values are unsigned normalized to the range [0, 1], - * whose interpretation is defined by the dataspace. The stencil values are - * unsigned integers, whose interpretation is defined by the dataspace. - */ - DEPTH_24_STENCIL_8 = 50 /* 0x32 */, - /** - * 32-bit format that has a single 32-bit depth component. - * - * The component values are signed floats, whose interpretation is defined - * by the dataspace. - */ - DEPTH_32F = 51 /* 0x33 */, - /** - * Two-component format that has a 32-bit depth component, an 8-bit stencil - * component, and optionally 24-bits unused. - * - * The depth component values are signed floats, whose interpretation is - * defined by the dataspace. The stencil bits are unsigned integers, whose - * interpretation is defined by the dataspace. - */ - DEPTH_32F_STENCIL_8 = 52 /* 0x34 */, - /** - * 8-bit format that has a single 8-bit stencil component. - * - * The component values are unsigned integers, whose interpretation is - * defined by the dataspace. - */ - STENCIL_8 = 53 /* 0x35 */, - /** - * P010 is a 4:2:0 YCbCr semiplanar format comprised of a WxH Y plane - * followed immediately by a Wx(H/2) CbCr plane. Each sample is - * represented by a 16-bit little-endian value, with the lower 6 bits set - * to zero. - * - * This format assumes - * - an even height - * - a vertical stride equal to the height - * - * stride_in_bytes = stride * 2 - * y_size = stride_in_bytes * height - * cbcr_size = stride_in_bytes * (height / 2) - * cb_offset = y_size - * cr_offset = cb_offset + 2 - * - * This format must be accepted by the allocator when used with the - * following usage flags: - * - * - BufferUsage::VIDEO_* - * - BufferUsage::CPU_* - * - BufferUsage::GPU_TEXTURE - * - * The component values are unsigned normalized to the range [0, 1], whose - * interpretation is defined by the dataspace. - * - * This format is appropriate for 10bit video content. - * - * Buffers with this format must be locked with IMapper::lockYCbCr - * or with IMapper::lock. - */ - YCBCR_P010 = 54 /* 0x36 */, -}; - -/** - * Buffer usage definitions. - */ -enum class BufferUsage : uint64_t { - /** - * bit 0-3 is an enum - */ - CPU_READ_MASK = 15ull /* 0xfULL */, - /** - * buffer is never read by CPU - */ - CPU_READ_NEVER = 0ull, - /** - * buffer is rarely read by CPU - */ - CPU_READ_RARELY = 2ull, - /** - * buffer is often read by CPU - */ - CPU_READ_OFTEN = 3ull, - /** - * bit 4-7 is an enum - */ - CPU_WRITE_MASK = 240ull /* (0xfULL << 4) */, - /** - * buffer is never written by CPU - */ - CPU_WRITE_NEVER = 0ull /* (0 << 4) */, - /** - * buffer is rarely written by CPU - */ - CPU_WRITE_RARELY = 32ull /* (2 << 4) */, - /** - * buffer is often written by CPU - */ - CPU_WRITE_OFTEN = 48ull /* (3 << 4) */, - /** - * buffer is used as a GPU texture - */ - GPU_TEXTURE = 256ull /* (1ULL << 8) */, - /** - * buffer is used as a GPU render target - */ - GPU_RENDER_TARGET = 512ull /* (1ULL << 9) */, - /** - * bit 10 must be zero - * - * - * buffer is used as a composer HAL overlay layer - */ - COMPOSER_OVERLAY = 2048ull /* (1ULL << 11) */, - /** - * buffer is used as a composer HAL client target - */ - COMPOSER_CLIENT_TARGET = 4096ull /* (1ULL << 12) */, - /** - * bit 13 must be zero - * - * - * Buffer is allocated with hardware-level protection against copying the - * contents (or information derived from the contents) into unprotected - * memory. - */ - PROTECTED = 16384ull /* (1ULL << 14) */, - /** - * buffer is used as a hwcomposer HAL cursor layer - */ - COMPOSER_CURSOR = 32768ull /* (1ULL << 15) */, - /** - * buffer is used as a video encoder input - */ - VIDEO_ENCODER = 65536ull /* (1ULL << 16) */, - /** - * buffer is used as a camera HAL output - */ - CAMERA_OUTPUT = 131072ull /* (1ULL << 17) */, - /** - * buffer is used as a camera HAL input - */ - CAMERA_INPUT = 262144ull /* (1ULL << 18) */, - /** - * bit 19 must be zero - * - * - * buffer is used as a renderscript allocation - */ - RENDERSCRIPT = 1048576ull /* (1ULL << 20) */, - /** - * bit 21 must be zero - * - * - * buffer is used as a video decoder output - */ - VIDEO_DECODER = 4194304ull /* (1ULL << 22) */, - /** - * buffer is used as a sensor direct report output - */ - SENSOR_DIRECT_DATA = 8388608ull /* (1ULL << 23) */, - /** - * buffer is used as as an OpenGL shader storage or uniform - * buffer object - */ - GPU_DATA_BUFFER = 16777216ull /* (1ULL << 24) */, - /** - * bits 25-27 must be zero and are reserved for future versions - * - * - * bits 28-31 are reserved for vendor extensions - */ - VENDOR_MASK = 4026531840ull /* (0xfULL << 28) */, - /** - * bits 32-47 must be zero and are reserved for future versions - * - * - * bits 48-63 are reserved for vendor extensions - */ - VENDOR_MASK_HI = 18446462598732840960ull /* (0xffffULL << 48) */, - /** - * buffer is used as a cube map texture - */ - GPU_CUBE_MAP = 33554432ull /* (1ULL << 25) */, - /** - * buffer contains a complete mipmap hierarchy - */ - GPU_MIPMAP_COMPLETE = 67108864ull /* (1ULL << 26) */, -}; - -enum class Dataspace : int32_t { - /** - * Default-assumption data space, when not explicitly specified. - * - * It is safest to assume the buffer is an image with sRGB primaries and - * encoding ranges, but the consumer and/or the producer of the data may - * simply be using defaults. No automatic gamma transform should be - * expected, except for a possible display gamma transform when drawn to a - * screen. - */ - UNKNOWN = 0 /* 0x0 */, - /** - * Arbitrary dataspace with manually defined characteristics. Definition - * for colorspaces or other meaning must be communicated separately. - * - * This is used when specifying primaries, transfer characteristics, - * etc. separately. - * - * A typical use case is in video encoding parameters (e.g. for H.264), - * where a colorspace can have separately defined primaries, transfer - * characteristics, etc. - */ - ARBITRARY = 1 /* 0x1 */, - /** - * Color-description aspects - * - * The following aspects define various characteristics of the color - * specification. These represent bitfields, so that a data space value - * can specify each of them independently. - */ - STANDARD_SHIFT = 16, - /** - * Standard aspect - * - * Defines the chromaticity coordinates of the source primaries in terms of - * the CIE 1931 definition of x and y specified in ISO 11664-1. - */ - STANDARD_MASK = 4128768 /* (63 << STANDARD_SHIFT) */, - /** - * Chromacity coordinates are unknown or are determined by the application. - * Implementations shall use the following suggested standards: - * - * All YCbCr formats: BT709 if size is 720p or larger (since most video - * content is letterboxed this corresponds to width is - * 1280 or greater, or height is 720 or greater). - * BT601_625 if size is smaller than 720p or is JPEG. - * All RGB formats: BT709. - * - * For all other formats standard is undefined, and implementations should use - * an appropriate standard for the data represented. - */ - STANDARD_UNSPECIFIED = 0 /* (0 << STANDARD_SHIFT) */, - /** - * Primaries: x y - * green 0.300 0.600 - * blue 0.150 0.060 - * red 0.640 0.330 - * white (D65) 0.3127 0.3290 - * - * Use the unadjusted KR = 0.2126, KB = 0.0722 luminance interpretation - * for RGB conversion. - */ - STANDARD_BT709 = 65536 /* (1 << STANDARD_SHIFT) */, - /** - * Primaries: x y - * green 0.290 0.600 - * blue 0.150 0.060 - * red 0.640 0.330 - * white (D65) 0.3127 0.3290 - * - * KR = 0.299, KB = 0.114. This adjusts the luminance interpretation - * for RGB conversion from the one purely determined by the primaries - * to minimize the color shift into RGB space that uses BT.709 - * primaries. - */ - STANDARD_BT601_625 = 131072 /* (2 << STANDARD_SHIFT) */, - /** - * Primaries: x y - * green 0.290 0.600 - * blue 0.150 0.060 - * red 0.640 0.330 - * white (D65) 0.3127 0.3290 - * - * Use the unadjusted KR = 0.222, KB = 0.071 luminance interpretation - * for RGB conversion. - */ - STANDARD_BT601_625_UNADJUSTED = 196608 /* (3 << STANDARD_SHIFT) */, - /** - * Primaries: x y - * green 0.310 0.595 - * blue 0.155 0.070 - * red 0.630 0.340 - * white (D65) 0.3127 0.3290 - * - * KR = 0.299, KB = 0.114. This adjusts the luminance interpretation - * for RGB conversion from the one purely determined by the primaries - * to minimize the color shift into RGB space that uses BT.709 - * primaries. - */ - STANDARD_BT601_525 = 262144 /* (4 << STANDARD_SHIFT) */, - /** - * Primaries: x y - * green 0.310 0.595 - * blue 0.155 0.070 - * red 0.630 0.340 - * white (D65) 0.3127 0.3290 - * - * Use the unadjusted KR = 0.212, KB = 0.087 luminance interpretation - * for RGB conversion (as in SMPTE 240M). - */ - STANDARD_BT601_525_UNADJUSTED = 327680 /* (5 << STANDARD_SHIFT) */, - /** - * Primaries: x y - * green 0.170 0.797 - * blue 0.131 0.046 - * red 0.708 0.292 - * white (D65) 0.3127 0.3290 - * - * Use the unadjusted KR = 0.2627, KB = 0.0593 luminance interpretation - * for RGB conversion. - */ - STANDARD_BT2020 = 393216 /* (6 << STANDARD_SHIFT) */, - /** - * Primaries: x y - * green 0.170 0.797 - * blue 0.131 0.046 - * red 0.708 0.292 - * white (D65) 0.3127 0.3290 - * - * Use the unadjusted KR = 0.2627, KB = 0.0593 luminance interpretation - * for RGB conversion using the linear domain. - */ - STANDARD_BT2020_CONSTANT_LUMINANCE = 458752 /* (7 << STANDARD_SHIFT) */, - /** - * Primaries: x y - * green 0.21 0.71 - * blue 0.14 0.08 - * red 0.67 0.33 - * white (C) 0.310 0.316 - * - * Use the unadjusted KR = 0.30, KB = 0.11 luminance interpretation - * for RGB conversion. - */ - STANDARD_BT470M = 524288 /* (8 << STANDARD_SHIFT) */, - /** - * Primaries: x y - * green 0.243 0.692 - * blue 0.145 0.049 - * red 0.681 0.319 - * white (C) 0.310 0.316 - * - * Use the unadjusted KR = 0.254, KB = 0.068 luminance interpretation - * for RGB conversion. - */ - STANDARD_FILM = 589824 /* (9 << STANDARD_SHIFT) */, - /** - * SMPTE EG 432-1 and SMPTE RP 431-2. (DCI-P3) - * Primaries: x y - * green 0.265 0.690 - * blue 0.150 0.060 - * red 0.680 0.320 - * white (D65) 0.3127 0.3290 - */ - STANDARD_DCI_P3 = 655360 /* (10 << STANDARD_SHIFT) */, - /** - * Adobe RGB - * Primaries: x y - * green 0.210 0.710 - * blue 0.150 0.060 - * red 0.640 0.330 - * white (D65) 0.3127 0.3290 - */ - STANDARD_ADOBE_RGB = 720896 /* (11 << STANDARD_SHIFT) */, - TRANSFER_SHIFT = 22, - /** - * Transfer aspect - * - * Transfer characteristics are the opto-electronic transfer characteristic - * at the source as a function of linear optical intensity (luminance). - * - * For digital signals, E corresponds to the recorded value. Normally, the - * transfer function is applied in RGB space to each of the R, G and B - * components independently. This may result in color shift that can be - * minized by applying the transfer function in Lab space only for the L - * component. Implementation may apply the transfer function in RGB space - * for all pixel formats if desired. - */ - TRANSFER_MASK = 130023424 /* (31 << TRANSFER_SHIFT) */, - /** - * Transfer characteristics are unknown or are determined by the - * application. - * - * Implementations should use the following transfer functions: - * - * For YCbCr formats: use TRANSFER_SMPTE_170M - * For RGB formats: use TRANSFER_SRGB - * - * For all other formats transfer function is undefined, and implementations - * should use an appropriate standard for the data represented. - */ - TRANSFER_UNSPECIFIED = 0 /* (0 << TRANSFER_SHIFT) */, - /** - * Transfer characteristic curve: - * E = L - * L - luminance of image 0 <= L <= 1 for conventional colorimetry - * E - corresponding electrical signal - */ - TRANSFER_LINEAR = 4194304 /* (1 << TRANSFER_SHIFT) */, - /** - * Transfer characteristic curve: - * - * E = 1.055 * L^(1/2.4) - 0.055 for 0.0031308 <= L <= 1 - * = 12.92 * L for 0 <= L < 0.0031308 - * L - luminance of image 0 <= L <= 1 for conventional colorimetry - * E - corresponding electrical signal - */ - TRANSFER_SRGB = 8388608 /* (2 << TRANSFER_SHIFT) */, - /** - * BT.601 525, BT.601 625, BT.709, BT.2020 - * - * Transfer characteristic curve: - * E = 1.099 * L ^ 0.45 - 0.099 for 0.018 <= L <= 1 - * = 4.500 * L for 0 <= L < 0.018 - * L - luminance of image 0 <= L <= 1 for conventional colorimetry - * E - corresponding electrical signal - */ - TRANSFER_SMPTE_170M = 12582912 /* (3 << TRANSFER_SHIFT) */, - /** - * Assumed display gamma 2.2. - * - * Transfer characteristic curve: - * E = L ^ (1/2.2) - * L - luminance of image 0 <= L <= 1 for conventional colorimetry - * E - corresponding electrical signal - */ - TRANSFER_GAMMA2_2 = 16777216 /* (4 << TRANSFER_SHIFT) */, - /** - * display gamma 2.6. - * - * Transfer characteristic curve: - * E = L ^ (1/2.6) - * L - luminance of image 0 <= L <= 1 for conventional colorimetry - * E - corresponding electrical signal - */ - TRANSFER_GAMMA2_6 = 20971520 /* (5 << TRANSFER_SHIFT) */, - /** - * display gamma 2.8. - * - * Transfer characteristic curve: - * E = L ^ (1/2.8) - * L - luminance of image 0 <= L <= 1 for conventional colorimetry - * E - corresponding electrical signal - */ - TRANSFER_GAMMA2_8 = 25165824 /* (6 << TRANSFER_SHIFT) */, - /** - * SMPTE ST 2084 (Dolby Perceptual Quantizer) - * - * Transfer characteristic curve: - * E = ((c1 + c2 * L^n) / (1 + c3 * L^n)) ^ m - * c1 = c3 - c2 + 1 = 3424 / 4096 = 0.8359375 - * c2 = 32 * 2413 / 4096 = 18.8515625 - * c3 = 32 * 2392 / 4096 = 18.6875 - * m = 128 * 2523 / 4096 = 78.84375 - * n = 0.25 * 2610 / 4096 = 0.1593017578125 - * L - luminance of image 0 <= L <= 1 for HDR colorimetry. - * L = 1 corresponds to 10000 cd/m2 - * E - corresponding electrical signal - */ - TRANSFER_ST2084 = 29360128 /* (7 << TRANSFER_SHIFT) */, - /** - * ARIB STD-B67 Hybrid Log Gamma - * - * Transfer characteristic curve: - * E = r * L^0.5 for 0 <= L <= 1 - * = a * ln(L - b) + c for 1 < L - * a = 0.17883277 - * b = 0.28466892 - * c = 0.55991073 - * r = 0.5 - * L - luminance of image 0 <= L for HDR colorimetry. L = 1 corresponds - * to reference white level of 100 cd/m2 - * E - corresponding electrical signal - */ - TRANSFER_HLG = 33554432 /* (8 << TRANSFER_SHIFT) */, - RANGE_SHIFT = 27, - /** - * Range aspect - * - * Defines the range of values corresponding to the unit range of 0-1. - * This is defined for YCbCr only, but can be expanded to RGB space. - */ - RANGE_MASK = 939524096 /* (7 << RANGE_SHIFT) */, - /** - * Range is unknown or are determined by the application. Implementations - * shall use the following suggested ranges: - * - * All YCbCr formats: limited range. - * All RGB or RGBA formats (including RAW and Bayer): full range. - * All Y formats: full range - * - * For all other formats range is undefined, and implementations should use - * an appropriate range for the data represented. - */ - RANGE_UNSPECIFIED = 0 /* (0 << RANGE_SHIFT) */, - /** - * Full range uses all values for Y, Cb and Cr from - * 0 to 2^b-1, where b is the bit depth of the color format. - */ - RANGE_FULL = 134217728 /* (1 << RANGE_SHIFT) */, - /** - * Limited range uses values 16/256*2^b to 235/256*2^b for Y, and - * 1/16*2^b to 15/16*2^b for Cb, Cr, R, G and B, where b is the bit depth of - * the color format. - * - * E.g. For 8-bit-depth formats: - * Luma (Y) samples should range from 16 to 235, inclusive - * Chroma (Cb, Cr) samples should range from 16 to 240, inclusive - * - * For 10-bit-depth formats: - * Luma (Y) samples should range from 64 to 940, inclusive - * Chroma (Cb, Cr) samples should range from 64 to 960, inclusive - */ - RANGE_LIMITED = 268435456 /* (2 << RANGE_SHIFT) */, - /** - * Extended range is used for scRGB. Intended for use with - * floating point pixel formats. [0.0 - 1.0] is the standard - * sRGB space. Values outside the range 0.0 - 1.0 can encode - * color outside the sRGB gamut. - * Used to blend / merge multiple dataspaces on a single display. - */ - RANGE_EXTENDED = 402653184 /* (3 << RANGE_SHIFT) */, - /** - * Legacy dataspaces - * - * - * sRGB linear encoding: - * - * The red, green, and blue components are stored in sRGB space, but - * are linear, not gamma-encoded. - * The RGB primaries and the white point are the same as BT.709. - * - * The values are encoded using the full range ([0,255] for 8-bit) for all - * components. - */ - SRGB_LINEAR = 512 /* 0x200 */, - V0_SRGB_LINEAR = 138477568 /* ((STANDARD_BT709 | TRANSFER_LINEAR) | RANGE_FULL) */, - /** - * scRGB linear encoding: - * - * The red, green, and blue components are stored in extended sRGB space, - * but are linear, not gamma-encoded. - * The RGB primaries and the white point are the same as BT.709. - * - * The values are floating point. - * A pixel value of 1.0, 1.0, 1.0 corresponds to sRGB white (D65) at 80 nits. - * Values beyond the range [0.0 - 1.0] would correspond to other colors - * spaces and/or HDR content. - */ - V0_SCRGB_LINEAR = 406913024 /* ((STANDARD_BT709 | TRANSFER_LINEAR) | RANGE_EXTENDED) */, - /** - * sRGB gamma encoding: - * - * The red, green and blue components are stored in sRGB space, and - * converted to linear space when read, using the SRGB transfer function - * for each of the R, G and B components. When written, the inverse - * transformation is performed. - * - * The alpha component, if present, is always stored in linear space and - * is left unmodified when read or written. - * - * Use full range and BT.709 standard. - */ - SRGB = 513 /* 0x201 */, - V0_SRGB = 142671872 /* ((STANDARD_BT709 | TRANSFER_SRGB) | RANGE_FULL) */, - /** - * scRGB: - * - * The red, green, and blue components are stored in extended sRGB space, - * but are linear, not gamma-encoded. - * The RGB primaries and the white point are the same as BT.709. - * - * The values are floating point. - * A pixel value of 1.0, 1.0, 1.0 corresponds to sRGB white (D65) at 80 nits. - * Values beyond the range [0.0 - 1.0] would correspond to other colors - * spaces and/or HDR content. - */ - V0_SCRGB = 411107328 /* ((STANDARD_BT709 | TRANSFER_SRGB) | RANGE_EXTENDED) */, - /** - * YCbCr Colorspaces - * ----------------- - * - * Primaries are given using (x,y) coordinates in the CIE 1931 definition - * of x and y specified by ISO 11664-1. - * - * Transfer characteristics are the opto-electronic transfer characteristic - * at the source as a function of linear optical intensity (luminance). - * - * - * JPEG File Interchange Format (JFIF) - * - * Same model as BT.601-625, but all values (Y, Cb, Cr) range from 0 to 255 - * - * Use full range, BT.601 transfer and BT.601_625 standard. - */ - JFIF = 257 /* 0x101 */, - V0_JFIF = 146931712 /* ((STANDARD_BT601_625 | TRANSFER_SMPTE_170M) | RANGE_FULL) */, - /** - * ITU-R Recommendation 601 (BT.601) - 625-line - * - * Standard-definition television, 625 Lines (PAL) - * - * Use limited range, BT.601 transfer and BT.601_625 standard. - */ - BT601_625 = 258 /* 0x102 */, - V0_BT601_625 = 281149440 /* ((STANDARD_BT601_625 | TRANSFER_SMPTE_170M) | RANGE_LIMITED) */, - /** - * ITU-R Recommendation 601 (BT.601) - 525-line - * - * Standard-definition television, 525 Lines (NTSC) - * - * Use limited range, BT.601 transfer and BT.601_525 standard. - */ - BT601_525 = 259 /* 0x103 */, - V0_BT601_525 = 281280512 /* ((STANDARD_BT601_525 | TRANSFER_SMPTE_170M) | RANGE_LIMITED) */, - /** - * ITU-R Recommendation 709 (BT.709) - * - * High-definition television - * - * Use limited range, BT.709 transfer and BT.709 standard. - */ - BT709 = 260 /* 0x104 */, - V0_BT709 = 281083904 /* ((STANDARD_BT709 | TRANSFER_SMPTE_170M) | RANGE_LIMITED) */, - /** - * SMPTE EG 432-1 and SMPTE RP 431-2. - * - * Digital Cinema DCI-P3 - * - * Use full range, linear transfer and D65 DCI-P3 standard - */ - DCI_P3_LINEAR = 139067392 /* ((STANDARD_DCI_P3 | TRANSFER_LINEAR) | RANGE_FULL) */, - /** - * SMPTE EG 432-1 and SMPTE RP 431-2. - * - * Digital Cinema DCI-P3 - * - * Use full range, gamma 2.6 transfer and D65 DCI-P3 standard - * Note: Application is responsible for gamma encoding the data as - * a 2.6 gamma encoding is not supported in HW. - */ - DCI_P3 = 155844608 /* ((STANDARD_DCI_P3 | TRANSFER_GAMMA2_6) | RANGE_FULL) */, - /** - * Display P3 - * - * Display P3 uses same primaries and white-point as DCI-P3 - * linear transfer function makes this the same as DCI_P3_LINEAR. - */ - DISPLAY_P3_LINEAR = 139067392 /* ((STANDARD_DCI_P3 | TRANSFER_LINEAR) | RANGE_FULL) */, - /** - * Display P3 - * - * Use same primaries and white-point as DCI-P3 - * but sRGB transfer function. - */ - DISPLAY_P3 = 143261696 /* ((STANDARD_DCI_P3 | TRANSFER_SRGB) | RANGE_FULL) */, - /** - * Adobe RGB - * - * Use full range, gamma 2.2 transfer and Adobe RGB primaries - * Note: Application is responsible for gamma encoding the data as - * a 2.2 gamma encoding is not supported in HW. - */ - ADOBE_RGB = 151715840 /* ((STANDARD_ADOBE_RGB | TRANSFER_GAMMA2_2) | RANGE_FULL) */, - /** - * ITU-R Recommendation 2020 (BT.2020) - * - * Ultra High-definition television - * - * Use full range, linear transfer and BT2020 standard - */ - BT2020_LINEAR = 138805248 /* ((STANDARD_BT2020 | TRANSFER_LINEAR) | RANGE_FULL) */, - /** - * ITU-R Recommendation 2020 (BT.2020) - * - * Ultra High-definition television - * - * Use full range, BT.709 transfer and BT2020 standard - */ - BT2020 = 147193856 /* ((STANDARD_BT2020 | TRANSFER_SMPTE_170M) | RANGE_FULL) */, - /** - * ITU-R Recommendation 2020 (BT.2020) - * - * Ultra High-definition television - * - * Use full range, SMPTE 2084 (PQ) transfer and BT2020 standard - */ - BT2020_PQ = 163971072 /* ((STANDARD_BT2020 | TRANSFER_ST2084) | RANGE_FULL) */, - /** - * Data spaces for non-color formats - * - * - * The buffer contains depth ranging measurements from a depth camera. - * This value is valid with formats: - * HAL_PIXEL_FORMAT_Y16: 16-bit samples, consisting of a depth measurement - * and an associated confidence value. The 3 MSBs of the sample make - * up the confidence value, and the low 13 LSBs of the sample make up - * the depth measurement. - * For the confidence section, 0 means 100% confidence, 1 means 0% - * confidence. The mapping to a linear float confidence value between - * 0.f and 1.f can be obtained with - * float confidence = (((depthSample >> 13) - 1) & 0x7) / 7.0f; - * The depth measurement can be extracted simply with - * uint16_t range = (depthSample & 0x1FFF); - * HAL_PIXEL_FORMAT_BLOB: A depth point cloud, as - * a variable-length float (x,y,z, confidence) coordinate point list. - * The point cloud will be represented with the android_depth_points - * structure. - */ - DEPTH = 4096 /* 0x1000 */, - /** - * The buffer contains sensor events from sensor direct report. - * This value is valid with formats: - * HAL_PIXEL_FORMAT_BLOB: an array of sensor event structure that forms - * a lock free queue. Format of sensor event structure is specified - * in Sensors HAL. - */ - SENSOR = 4097 /* 0x1001 */, - /** - * ITU-R Recommendation 2020 (BT.2020) - * - * Ultra High-definition television - * - * Use limited range, BT.709 transfer and BT2020 standard - */ - BT2020_ITU = 281411584 /* ((STANDARD_BT2020 | TRANSFER_SMPTE_170M) | RANGE_LIMITED) */, - /** - * ITU-R Recommendation 2100 (BT.2100) - * - * High dynamic range television - * - * Use limited/full range, PQ/HLG transfer, and BT2020 standard - * limited range is the preferred / normative definition for BT.2100 - */ - BT2020_ITU_PQ = 298188800 /* ((STANDARD_BT2020 | TRANSFER_ST2084) | RANGE_LIMITED) */, - BT2020_ITU_HLG = 302383104 /* ((STANDARD_BT2020 | TRANSFER_HLG) | RANGE_LIMITED) */, - BT2020_HLG = 168165376 /* ((STANDARD_BT2020 | TRANSFER_HLG) | RANGE_FULL) */, -}; - -enum class ColorMode : int32_t { - /** - * DEFAULT is the "native" gamut of the display. - * White Point: Vendor/OEM defined - * Panel Gamma: Vendor/OEM defined (typically 2.2) - * Rendering Intent: Vendor/OEM defined (typically 'enhanced') - */ - NATIVE = 0, - /** - * STANDARD_BT601_625 corresponds with display - * settings that implement the ITU-R Recommendation BT.601 - * or Rec 601. Using 625 line version - * Rendering Intent: Colorimetric - * Primaries: - * x y - * green 0.290 0.600 - * blue 0.150 0.060 - * red 0.640 0.330 - * white (D65) 0.3127 0.3290 - * - * KR = 0.299, KB = 0.114. This adjusts the luminance interpretation - * for RGB conversion from the one purely determined by the primaries - * to minimize the color shift into RGB space that uses BT.709 - * primaries. - * - * Gamma Correction (GC): - * - * if Vlinear < 0.018 - * Vnonlinear = 4.500 * Vlinear - * else - * Vnonlinear = 1.099 * (Vlinear)^(0.45) – 0.099 - */ - STANDARD_BT601_625 = 1, - /** - * Primaries: - * x y - * green 0.290 0.600 - * blue 0.150 0.060 - * red 0.640 0.330 - * white (D65) 0.3127 0.3290 - * - * Use the unadjusted KR = 0.222, KB = 0.071 luminance interpretation - * for RGB conversion. - * - * Gamma Correction (GC): - * - * if Vlinear < 0.018 - * Vnonlinear = 4.500 * Vlinear - * else - * Vnonlinear = 1.099 * (Vlinear)^(0.45) – 0.099 - */ - STANDARD_BT601_625_UNADJUSTED = 2, - /** - * Primaries: - * x y - * green 0.310 0.595 - * blue 0.155 0.070 - * red 0.630 0.340 - * white (D65) 0.3127 0.3290 - * - * KR = 0.299, KB = 0.114. This adjusts the luminance interpretation - * for RGB conversion from the one purely determined by the primaries - * to minimize the color shift into RGB space that uses BT.709 - * primaries. - * - * Gamma Correction (GC): - * - * if Vlinear < 0.018 - * Vnonlinear = 4.500 * Vlinear - * else - * Vnonlinear = 1.099 * (Vlinear)^(0.45) – 0.099 - */ - STANDARD_BT601_525 = 3, - /** - * Primaries: - * x y - * green 0.310 0.595 - * blue 0.155 0.070 - * red 0.630 0.340 - * white (D65) 0.3127 0.3290 - * - * Use the unadjusted KR = 0.212, KB = 0.087 luminance interpretation - * for RGB conversion (as in SMPTE 240M). - * - * Gamma Correction (GC): - * - * if Vlinear < 0.018 - * Vnonlinear = 4.500 * Vlinear - * else - * Vnonlinear = 1.099 * (Vlinear)^(0.45) – 0.099 - */ - STANDARD_BT601_525_UNADJUSTED = 4, - /** - * REC709 corresponds with display settings that implement - * the ITU-R Recommendation BT.709 / Rec. 709 for high-definition television. - * Rendering Intent: Colorimetric - * Primaries: - * x y - * green 0.300 0.600 - * blue 0.150 0.060 - * red 0.640 0.330 - * white (D65) 0.3127 0.3290 - * - * HDTV REC709 Inverse Gamma Correction (IGC): V represents normalized - * (with [0 to 1] range) value of R, G, or B. - * - * if Vnonlinear < 0.081 - * Vlinear = Vnonlinear / 4.5 - * else - * Vlinear = ((Vnonlinear + 0.099) / 1.099) ^ (1/0.45) - * - * HDTV REC709 Gamma Correction (GC): - * - * if Vlinear < 0.018 - * Vnonlinear = 4.5 * Vlinear - * else - * Vnonlinear = 1.099 * (Vlinear) ^ 0.45 – 0.099 - */ - STANDARD_BT709 = 5, - /** - * DCI_P3 corresponds with display settings that implement - * SMPTE EG 432-1 and SMPTE RP 431-2 - * Rendering Intent: Colorimetric - * Primaries: - * x y - * green 0.265 0.690 - * blue 0.150 0.060 - * red 0.680 0.320 - * white (D65) 0.3127 0.3290 - * - * Gamma: 2.6 - */ - DCI_P3 = 6, - /** - * SRGB corresponds with display settings that implement - * the sRGB color space. Uses the same primaries as ITU-R Recommendation - * BT.709 - * Rendering Intent: Colorimetric - * Primaries: - * x y - * green 0.300 0.600 - * blue 0.150 0.060 - * red 0.640 0.330 - * white (D65) 0.3127 0.3290 - * - * PC/Internet (sRGB) Inverse Gamma Correction (IGC): - * - * if Vnonlinear ≤ 0.03928 - * Vlinear = Vnonlinear / 12.92 - * else - * Vlinear = ((Vnonlinear + 0.055)/1.055) ^ 2.4 - * - * PC/Internet (sRGB) Gamma Correction (GC): - * - * if Vlinear ≤ 0.0031308 - * Vnonlinear = 12.92 * Vlinear - * else - * Vnonlinear = 1.055 * (Vlinear)^(1/2.4) – 0.055 - */ - SRGB = 7, - /** - * ADOBE_RGB corresponds with the RGB color space developed - * by Adobe Systems, Inc. in 1998. - * Rendering Intent: Colorimetric - * Primaries: - * x y - * green 0.210 0.710 - * blue 0.150 0.060 - * red 0.640 0.330 - * white (D65) 0.3127 0.3290 - * - * Gamma: 2.2 - */ - ADOBE_RGB = 8, - /** - * DISPLAY_P3 is a color space that uses the DCI_P3 primaries, - * the D65 white point and the SRGB transfer functions. - * Rendering Intent: Colorimetric - * Primaries: - * x y - * green 0.265 0.690 - * blue 0.150 0.060 - * red 0.680 0.320 - * white (D65) 0.3127 0.3290 - * - * PC/Internet (sRGB) Gamma Correction (GC): - * - * if Vlinear ≤ 0.0030186 - * Vnonlinear = 12.92 * Vlinear - * else - * Vnonlinear = 1.055 * (Vlinear)^(1/2.4) – 0.055 - * - * Note: In most cases sRGB transfer function will be fine. - */ - DISPLAY_P3 = 9, - /** - * BT2020 corresponds with display settings that implement the ITU-R - * Recommendation BT.2020 / Rec. 2020 for UHDTV. - * - * Primaries: - * x y - * green 0.170 0.797 - * blue 0.131 0.046 - * red 0.708 0.292 - * white (D65) 0.3127 0.3290 - * - * Inverse Gamma Correction (IGC): V represents normalized (with [0 to 1] - * range) value of R, G, or B. - * - * if Vnonlinear < b * 4.5 - * Vlinear = Vnonlinear / 4.5 - * else - * Vlinear = ((Vnonlinear + (a - 1)) / a) ^ (1/0.45) - * - * Gamma Correction (GC): - * - * if Vlinear < b - * Vnonlinear = 4.5 * Vlinear - * else - * Vnonlinear = a * Vlinear ^ 0.45 - (a - 1) - * - * where - * - * a = 1.09929682680944, b = 0.018053968510807 - * - * For practical purposes, these a/b values can be used instead - * - * a = 1.099, b = 0.018 for 10-bit display systems - * a = 1.0993, b = 0.0181 for 12-bit display systems - */ - BT2020 = 10, - /** - * BT2100_PQ and BT2100_HLG correspond with display settings that - * implement the ITU-R Recommendation BT.2100 / Rec. 2100 for HDR TV. - * - * Primaries: - * x y - * green 0.170 0.797 - * blue 0.131 0.046 - * red 0.708 0.292 - * white (D65) 0.3127 0.3290 - * - * For BT2100_PQ, the transfer function is Perceptual Quantizer (PQ). For - * BT2100_HLG, the transfer function is Hybrid Log-Gamma (HLG). - */ - BT2100_PQ = 11, - BT2100_HLG = 12, -}; - -/** - * RenderIntent defines the mapping from color mode colors to display colors. - * - * A render intent must not change how it maps colors when the color mode - * changes. That is to say that when a render intent maps color C to color C', - * the fact that color C can have different pixel values in different color - * modes should not affect the mapping. - * - * RenderIntent overrides the render intents defined for individual color - * modes. It is ignored when the color mode is ColorMode::NATIVE, because - * ColorMode::NATIVE colors are already display colors. - */ -enum class RenderIntent : int32_t { - /** - * Colors in the display gamut are unchanged. Colors out of the display - * gamut are hard-clipped. - * - * This implies that the display must have been calibrated unless - * ColorMode::NATIVE is the only supported color mode. - */ - COLORIMETRIC = 0, - /** - * Enhance colors that are in the display gamut. Colors out of the display - * gamut are hard-clipped. - * - * The enhancement typically picks the biggest standard color space (e.g. - * DCI-P3) that is narrower than the display gamut and stretches it to the - * display gamut. The stretching is recommended to preserve skin tones. - */ - ENHANCE = 1, - /** - * Tone map high-dynamic-range colors to the display's dynamic range. The - * dynamic range of the colors are communicated separately. After tone - * mapping, the mapping to the display gamut is as defined in - * COLORIMETRIC. - */ - TONE_MAP_COLORIMETRIC = 2, - /** - * Tone map high-dynamic-range colors to the display's dynamic range. The - * dynamic range of the colors are communicated separately. After tone - * mapping, the mapping to the display gamut is as defined in ENHANCE. - * - * The tone mapping step and the enhancing step must match - * TONE_MAP_COLORIMETRIC and ENHANCE respectively when they are also - * supported. - */ - TONE_MAP_ENHANCE = 3, -}; - -// -// type declarations for package -// - -template -static inline std::string toString(int32_t o); -static inline std::string toString(::android::hardware::graphics::common::V1_1::PixelFormat o); - -constexpr int32_t operator|(const ::android::hardware::graphics::common::V1_1::PixelFormat lhs, - const ::android::hardware::graphics::common::V1_1::PixelFormat rhs) { - return static_cast(static_cast(lhs) | static_cast(rhs)); -} -constexpr int32_t operator|(const int32_t lhs, - const ::android::hardware::graphics::common::V1_1::PixelFormat rhs) { - return static_cast(lhs | static_cast(rhs)); -} -constexpr int32_t operator|(const ::android::hardware::graphics::common::V1_1::PixelFormat lhs, - const int32_t rhs) { - return static_cast(static_cast(lhs) | rhs); -} -constexpr int32_t operator&(const ::android::hardware::graphics::common::V1_1::PixelFormat lhs, - const ::android::hardware::graphics::common::V1_1::PixelFormat rhs) { - return static_cast(static_cast(lhs) & static_cast(rhs)); -} -constexpr int32_t operator&(const int32_t lhs, - const ::android::hardware::graphics::common::V1_1::PixelFormat rhs) { - return static_cast(lhs & static_cast(rhs)); -} -constexpr int32_t operator&(const ::android::hardware::graphics::common::V1_1::PixelFormat lhs, - const int32_t rhs) { - return static_cast(static_cast(lhs) & rhs); -} -constexpr int32_t& operator|=(int32_t& v, - const ::android::hardware::graphics::common::V1_1::PixelFormat e) { - v |= static_cast(e); - return v; -} -constexpr int32_t& operator&=(int32_t& v, - const ::android::hardware::graphics::common::V1_1::PixelFormat e) { - v &= static_cast(e); - return v; -} - -template -static inline std::string toString(uint64_t o); -static inline std::string toString(::android::hardware::graphics::common::V1_1::BufferUsage o); - -constexpr uint64_t operator|(const ::android::hardware::graphics::common::V1_1::BufferUsage lhs, - const ::android::hardware::graphics::common::V1_1::BufferUsage rhs) { - return static_cast(static_cast(lhs) | static_cast(rhs)); -} -constexpr uint64_t operator|(const uint64_t lhs, - const ::android::hardware::graphics::common::V1_1::BufferUsage rhs) { - return static_cast(lhs | static_cast(rhs)); -} -constexpr uint64_t operator|(const ::android::hardware::graphics::common::V1_1::BufferUsage lhs, - const uint64_t rhs) { - return static_cast(static_cast(lhs) | rhs); -} -constexpr uint64_t operator&(const ::android::hardware::graphics::common::V1_1::BufferUsage lhs, - const ::android::hardware::graphics::common::V1_1::BufferUsage rhs) { - return static_cast(static_cast(lhs) & static_cast(rhs)); -} -constexpr uint64_t operator&(const uint64_t lhs, - const ::android::hardware::graphics::common::V1_1::BufferUsage rhs) { - return static_cast(lhs & static_cast(rhs)); -} -constexpr uint64_t operator&(const ::android::hardware::graphics::common::V1_1::BufferUsage lhs, - const uint64_t rhs) { - return static_cast(static_cast(lhs) & rhs); -} -constexpr uint64_t& operator|=(uint64_t& v, - const ::android::hardware::graphics::common::V1_1::BufferUsage e) { - v |= static_cast(e); - return v; -} -constexpr uint64_t& operator&=(uint64_t& v, - const ::android::hardware::graphics::common::V1_1::BufferUsage e) { - v &= static_cast(e); - return v; -} - -template -static inline std::string toString(int32_t o); -static inline std::string toString(::android::hardware::graphics::common::V1_1::Dataspace o); - -constexpr int32_t operator|(const ::android::hardware::graphics::common::V1_1::Dataspace lhs, - const ::android::hardware::graphics::common::V1_1::Dataspace rhs) { - return static_cast(static_cast(lhs) | static_cast(rhs)); -} -constexpr int32_t operator|(const int32_t lhs, - const ::android::hardware::graphics::common::V1_1::Dataspace rhs) { - return static_cast(lhs | static_cast(rhs)); -} -constexpr int32_t operator|(const ::android::hardware::graphics::common::V1_1::Dataspace lhs, - const int32_t rhs) { - return static_cast(static_cast(lhs) | rhs); -} -constexpr int32_t operator&(const ::android::hardware::graphics::common::V1_1::Dataspace lhs, - const ::android::hardware::graphics::common::V1_1::Dataspace rhs) { - return static_cast(static_cast(lhs) & static_cast(rhs)); -} -constexpr int32_t operator&(const int32_t lhs, - const ::android::hardware::graphics::common::V1_1::Dataspace rhs) { - return static_cast(lhs & static_cast(rhs)); -} -constexpr int32_t operator&(const ::android::hardware::graphics::common::V1_1::Dataspace lhs, - const int32_t rhs) { - return static_cast(static_cast(lhs) & rhs); -} -constexpr int32_t& operator|=(int32_t& v, - const ::android::hardware::graphics::common::V1_1::Dataspace e) { - v |= static_cast(e); - return v; -} -constexpr int32_t& operator&=(int32_t& v, - const ::android::hardware::graphics::common::V1_1::Dataspace e) { - v &= static_cast(e); - return v; -} - -template -static inline std::string toString(int32_t o); -static inline std::string toString(::android::hardware::graphics::common::V1_1::ColorMode o); - -constexpr int32_t operator|(const ::android::hardware::graphics::common::V1_1::ColorMode lhs, - const ::android::hardware::graphics::common::V1_1::ColorMode rhs) { - return static_cast(static_cast(lhs) | static_cast(rhs)); -} -constexpr int32_t operator|(const int32_t lhs, - const ::android::hardware::graphics::common::V1_1::ColorMode rhs) { - return static_cast(lhs | static_cast(rhs)); -} -constexpr int32_t operator|(const ::android::hardware::graphics::common::V1_1::ColorMode lhs, - const int32_t rhs) { - return static_cast(static_cast(lhs) | rhs); -} -constexpr int32_t operator&(const ::android::hardware::graphics::common::V1_1::ColorMode lhs, - const ::android::hardware::graphics::common::V1_1::ColorMode rhs) { - return static_cast(static_cast(lhs) & static_cast(rhs)); -} -constexpr int32_t operator&(const int32_t lhs, - const ::android::hardware::graphics::common::V1_1::ColorMode rhs) { - return static_cast(lhs & static_cast(rhs)); -} -constexpr int32_t operator&(const ::android::hardware::graphics::common::V1_1::ColorMode lhs, - const int32_t rhs) { - return static_cast(static_cast(lhs) & rhs); -} -constexpr int32_t& operator|=(int32_t& v, - const ::android::hardware::graphics::common::V1_1::ColorMode e) { - v |= static_cast(e); - return v; -} -constexpr int32_t& operator&=(int32_t& v, - const ::android::hardware::graphics::common::V1_1::ColorMode e) { - v &= static_cast(e); - return v; -} - -template -static inline std::string toString(int32_t o); -static inline std::string toString(::android::hardware::graphics::common::V1_1::RenderIntent o); - -constexpr int32_t operator|(const ::android::hardware::graphics::common::V1_1::RenderIntent lhs, - const ::android::hardware::graphics::common::V1_1::RenderIntent rhs) { - return static_cast(static_cast(lhs) | static_cast(rhs)); -} -constexpr int32_t operator|(const int32_t lhs, - const ::android::hardware::graphics::common::V1_1::RenderIntent rhs) { - return static_cast(lhs | static_cast(rhs)); -} -constexpr int32_t operator|(const ::android::hardware::graphics::common::V1_1::RenderIntent lhs, - const int32_t rhs) { - return static_cast(static_cast(lhs) | rhs); -} -constexpr int32_t operator&(const ::android::hardware::graphics::common::V1_1::RenderIntent lhs, - const ::android::hardware::graphics::common::V1_1::RenderIntent rhs) { - return static_cast(static_cast(lhs) & static_cast(rhs)); -} -constexpr int32_t operator&(const int32_t lhs, - const ::android::hardware::graphics::common::V1_1::RenderIntent rhs) { - return static_cast(lhs & static_cast(rhs)); -} -constexpr int32_t operator&(const ::android::hardware::graphics::common::V1_1::RenderIntent lhs, - const int32_t rhs) { - return static_cast(static_cast(lhs) & rhs); -} -constexpr int32_t& operator|=(int32_t& v, - const ::android::hardware::graphics::common::V1_1::RenderIntent e) { - v |= static_cast(e); - return v; -} -constexpr int32_t& operator&=(int32_t& v, - const ::android::hardware::graphics::common::V1_1::RenderIntent e) { - v &= static_cast(e); - return v; -} - -// -// type header definitions for package -// - -template <> -inline std::string toString<::android::hardware::graphics::common::V1_1::PixelFormat>(int32_t o) { - using ::android::hardware::details::toHexString; - std::string os; - ::android::hardware::hidl_bitfield<::android::hardware::graphics::common::V1_1::PixelFormat> - flipped = 0; - bool first = true; - if ((o & ::android::hardware::graphics::common::V1_1::PixelFormat::RGBA_8888) == - static_cast(::android::hardware::graphics::common::V1_1::PixelFormat::RGBA_8888)) { - os += (first ? "" : " | "); - os += "RGBA_8888"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_1::PixelFormat::RGBA_8888; - } - if ((o & ::android::hardware::graphics::common::V1_1::PixelFormat::RGBX_8888) == - static_cast(::android::hardware::graphics::common::V1_1::PixelFormat::RGBX_8888)) { - os += (first ? "" : " | "); - os += "RGBX_8888"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_1::PixelFormat::RGBX_8888; - } - if ((o & ::android::hardware::graphics::common::V1_1::PixelFormat::RGB_888) == - static_cast(::android::hardware::graphics::common::V1_1::PixelFormat::RGB_888)) { - os += (first ? "" : " | "); - os += "RGB_888"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_1::PixelFormat::RGB_888; - } - if ((o & ::android::hardware::graphics::common::V1_1::PixelFormat::RGB_565) == - static_cast(::android::hardware::graphics::common::V1_1::PixelFormat::RGB_565)) { - os += (first ? "" : " | "); - os += "RGB_565"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_1::PixelFormat::RGB_565; - } - if ((o & ::android::hardware::graphics::common::V1_1::PixelFormat::BGRA_8888) == - static_cast(::android::hardware::graphics::common::V1_1::PixelFormat::BGRA_8888)) { - os += (first ? "" : " | "); - os += "BGRA_8888"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_1::PixelFormat::BGRA_8888; - } - if ((o & ::android::hardware::graphics::common::V1_1::PixelFormat::YCBCR_422_SP) == - static_cast( - ::android::hardware::graphics::common::V1_1::PixelFormat::YCBCR_422_SP)) { - os += (first ? "" : " | "); - os += "YCBCR_422_SP"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_1::PixelFormat::YCBCR_422_SP; - } - if ((o & ::android::hardware::graphics::common::V1_1::PixelFormat::YCRCB_420_SP) == - static_cast( - ::android::hardware::graphics::common::V1_1::PixelFormat::YCRCB_420_SP)) { - os += (first ? "" : " | "); - os += "YCRCB_420_SP"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_1::PixelFormat::YCRCB_420_SP; - } - if ((o & ::android::hardware::graphics::common::V1_1::PixelFormat::YCBCR_422_I) == - static_cast(::android::hardware::graphics::common::V1_1::PixelFormat::YCBCR_422_I)) { - os += (first ? "" : " | "); - os += "YCBCR_422_I"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_1::PixelFormat::YCBCR_422_I; - } - if ((o & ::android::hardware::graphics::common::V1_1::PixelFormat::RGBA_FP16) == - static_cast(::android::hardware::graphics::common::V1_1::PixelFormat::RGBA_FP16)) { - os += (first ? "" : " | "); - os += "RGBA_FP16"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_1::PixelFormat::RGBA_FP16; - } - if ((o & ::android::hardware::graphics::common::V1_1::PixelFormat::RAW16) == - static_cast(::android::hardware::graphics::common::V1_1::PixelFormat::RAW16)) { - os += (first ? "" : " | "); - os += "RAW16"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_1::PixelFormat::RAW16; - } - if ((o & ::android::hardware::graphics::common::V1_1::PixelFormat::BLOB) == - static_cast(::android::hardware::graphics::common::V1_1::PixelFormat::BLOB)) { - os += (first ? "" : " | "); - os += "BLOB"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_1::PixelFormat::BLOB; - } - if ((o & ::android::hardware::graphics::common::V1_1::PixelFormat::IMPLEMENTATION_DEFINED) == - static_cast( - ::android::hardware::graphics::common::V1_1::PixelFormat::IMPLEMENTATION_DEFINED)) { - os += (first ? "" : " | "); - os += "IMPLEMENTATION_DEFINED"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_1::PixelFormat::IMPLEMENTATION_DEFINED; - } - if ((o & ::android::hardware::graphics::common::V1_1::PixelFormat::YCBCR_420_888) == - static_cast( - ::android::hardware::graphics::common::V1_1::PixelFormat::YCBCR_420_888)) { - os += (first ? "" : " | "); - os += "YCBCR_420_888"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_1::PixelFormat::YCBCR_420_888; - } - if ((o & ::android::hardware::graphics::common::V1_1::PixelFormat::RAW_OPAQUE) == - static_cast(::android::hardware::graphics::common::V1_1::PixelFormat::RAW_OPAQUE)) { - os += (first ? "" : " | "); - os += "RAW_OPAQUE"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_1::PixelFormat::RAW_OPAQUE; - } - if ((o & ::android::hardware::graphics::common::V1_1::PixelFormat::RAW10) == - static_cast(::android::hardware::graphics::common::V1_1::PixelFormat::RAW10)) { - os += (first ? "" : " | "); - os += "RAW10"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_1::PixelFormat::RAW10; - } - if ((o & ::android::hardware::graphics::common::V1_1::PixelFormat::RAW12) == - static_cast(::android::hardware::graphics::common::V1_1::PixelFormat::RAW12)) { - os += (first ? "" : " | "); - os += "RAW12"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_1::PixelFormat::RAW12; - } - if ((o & ::android::hardware::graphics::common::V1_1::PixelFormat::RGBA_1010102) == - static_cast( - ::android::hardware::graphics::common::V1_1::PixelFormat::RGBA_1010102)) { - os += (first ? "" : " | "); - os += "RGBA_1010102"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_1::PixelFormat::RGBA_1010102; - } - if ((o & ::android::hardware::graphics::common::V1_1::PixelFormat::Y8) == - static_cast(::android::hardware::graphics::common::V1_1::PixelFormat::Y8)) { - os += (first ? "" : " | "); - os += "Y8"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_1::PixelFormat::Y8; - } - if ((o & ::android::hardware::graphics::common::V1_1::PixelFormat::Y16) == - static_cast(::android::hardware::graphics::common::V1_1::PixelFormat::Y16)) { - os += (first ? "" : " | "); - os += "Y16"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_1::PixelFormat::Y16; - } - if ((o & ::android::hardware::graphics::common::V1_1::PixelFormat::YV12) == - static_cast(::android::hardware::graphics::common::V1_1::PixelFormat::YV12)) { - os += (first ? "" : " | "); - os += "YV12"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_1::PixelFormat::YV12; - } - if ((o & ::android::hardware::graphics::common::V1_1::PixelFormat::DEPTH_16) == - static_cast(::android::hardware::graphics::common::V1_1::PixelFormat::DEPTH_16)) { - os += (first ? "" : " | "); - os += "DEPTH_16"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_1::PixelFormat::DEPTH_16; - } - if ((o & ::android::hardware::graphics::common::V1_1::PixelFormat::DEPTH_24) == - static_cast(::android::hardware::graphics::common::V1_1::PixelFormat::DEPTH_24)) { - os += (first ? "" : " | "); - os += "DEPTH_24"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_1::PixelFormat::DEPTH_24; - } - if ((o & ::android::hardware::graphics::common::V1_1::PixelFormat::DEPTH_24_STENCIL_8) == - static_cast( - ::android::hardware::graphics::common::V1_1::PixelFormat::DEPTH_24_STENCIL_8)) { - os += (first ? "" : " | "); - os += "DEPTH_24_STENCIL_8"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_1::PixelFormat::DEPTH_24_STENCIL_8; - } - if ((o & ::android::hardware::graphics::common::V1_1::PixelFormat::DEPTH_32F) == - static_cast(::android::hardware::graphics::common::V1_1::PixelFormat::DEPTH_32F)) { - os += (first ? "" : " | "); - os += "DEPTH_32F"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_1::PixelFormat::DEPTH_32F; - } - if ((o & ::android::hardware::graphics::common::V1_1::PixelFormat::DEPTH_32F_STENCIL_8) == - static_cast( - ::android::hardware::graphics::common::V1_1::PixelFormat::DEPTH_32F_STENCIL_8)) { - os += (first ? "" : " | "); - os += "DEPTH_32F_STENCIL_8"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_1::PixelFormat::DEPTH_32F_STENCIL_8; - } - if ((o & ::android::hardware::graphics::common::V1_1::PixelFormat::STENCIL_8) == - static_cast(::android::hardware::graphics::common::V1_1::PixelFormat::STENCIL_8)) { - os += (first ? "" : " | "); - os += "STENCIL_8"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_1::PixelFormat::STENCIL_8; - } - if ((o & ::android::hardware::graphics::common::V1_1::PixelFormat::YCBCR_P010) == - static_cast(::android::hardware::graphics::common::V1_1::PixelFormat::YCBCR_P010)) { - os += (first ? "" : " | "); - os += "YCBCR_P010"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_1::PixelFormat::YCBCR_P010; - } - if (o != flipped) { - os += (first ? "" : " | "); - os += toHexString(o & (~flipped)); - } - os += " ("; - os += toHexString(o); - os += ")"; - return os; -} - -static inline std::string toString(::android::hardware::graphics::common::V1_1::PixelFormat o) { - using ::android::hardware::details::toHexString; - if (o == ::android::hardware::graphics::common::V1_1::PixelFormat::RGBA_8888) { - return "RGBA_8888"; - } - if (o == ::android::hardware::graphics::common::V1_1::PixelFormat::RGBX_8888) { - return "RGBX_8888"; - } - if (o == ::android::hardware::graphics::common::V1_1::PixelFormat::RGB_888) { - return "RGB_888"; - } - if (o == ::android::hardware::graphics::common::V1_1::PixelFormat::RGB_565) { - return "RGB_565"; - } - if (o == ::android::hardware::graphics::common::V1_1::PixelFormat::BGRA_8888) { - return "BGRA_8888"; - } - if (o == ::android::hardware::graphics::common::V1_1::PixelFormat::YCBCR_422_SP) { - return "YCBCR_422_SP"; - } - if (o == ::android::hardware::graphics::common::V1_1::PixelFormat::YCRCB_420_SP) { - return "YCRCB_420_SP"; - } - if (o == ::android::hardware::graphics::common::V1_1::PixelFormat::YCBCR_422_I) { - return "YCBCR_422_I"; - } - if (o == ::android::hardware::graphics::common::V1_1::PixelFormat::RGBA_FP16) { - return "RGBA_FP16"; - } - if (o == ::android::hardware::graphics::common::V1_1::PixelFormat::RAW16) { - return "RAW16"; - } - if (o == ::android::hardware::graphics::common::V1_1::PixelFormat::BLOB) { - return "BLOB"; - } - if (o == ::android::hardware::graphics::common::V1_1::PixelFormat::IMPLEMENTATION_DEFINED) { - return "IMPLEMENTATION_DEFINED"; - } - if (o == ::android::hardware::graphics::common::V1_1::PixelFormat::YCBCR_420_888) { - return "YCBCR_420_888"; - } - if (o == ::android::hardware::graphics::common::V1_1::PixelFormat::RAW_OPAQUE) { - return "RAW_OPAQUE"; - } - if (o == ::android::hardware::graphics::common::V1_1::PixelFormat::RAW10) { - return "RAW10"; - } - if (o == ::android::hardware::graphics::common::V1_1::PixelFormat::RAW12) { - return "RAW12"; - } - if (o == ::android::hardware::graphics::common::V1_1::PixelFormat::RGBA_1010102) { - return "RGBA_1010102"; - } - if (o == ::android::hardware::graphics::common::V1_1::PixelFormat::Y8) { - return "Y8"; - } - if (o == ::android::hardware::graphics::common::V1_1::PixelFormat::Y16) { - return "Y16"; - } - if (o == ::android::hardware::graphics::common::V1_1::PixelFormat::YV12) { - return "YV12"; - } - if (o == ::android::hardware::graphics::common::V1_1::PixelFormat::DEPTH_16) { - return "DEPTH_16"; - } - if (o == ::android::hardware::graphics::common::V1_1::PixelFormat::DEPTH_24) { - return "DEPTH_24"; - } - if (o == ::android::hardware::graphics::common::V1_1::PixelFormat::DEPTH_24_STENCIL_8) { - return "DEPTH_24_STENCIL_8"; - } - if (o == ::android::hardware::graphics::common::V1_1::PixelFormat::DEPTH_32F) { - return "DEPTH_32F"; - } - if (o == ::android::hardware::graphics::common::V1_1::PixelFormat::DEPTH_32F_STENCIL_8) { - return "DEPTH_32F_STENCIL_8"; - } - if (o == ::android::hardware::graphics::common::V1_1::PixelFormat::STENCIL_8) { - return "STENCIL_8"; - } - if (o == ::android::hardware::graphics::common::V1_1::PixelFormat::YCBCR_P010) { - return "YCBCR_P010"; - } - std::string os; - os += toHexString(static_cast(o)); - return os; -} - -template <> -inline std::string toString<::android::hardware::graphics::common::V1_1::BufferUsage>(uint64_t o) { - using ::android::hardware::details::toHexString; - std::string os; - ::android::hardware::hidl_bitfield<::android::hardware::graphics::common::V1_1::BufferUsage> - flipped = 0; - bool first = true; - if ((o & ::android::hardware::graphics::common::V1_1::BufferUsage::CPU_READ_MASK) == - static_cast( - ::android::hardware::graphics::common::V1_1::BufferUsage::CPU_READ_MASK)) { - os += (first ? "" : " | "); - os += "CPU_READ_MASK"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_1::BufferUsage::CPU_READ_MASK; - } - if ((o & ::android::hardware::graphics::common::V1_1::BufferUsage::CPU_READ_NEVER) == - static_cast( - ::android::hardware::graphics::common::V1_1::BufferUsage::CPU_READ_NEVER)) { - os += (first ? "" : " | "); - os += "CPU_READ_NEVER"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_1::BufferUsage::CPU_READ_NEVER; - } - if ((o & ::android::hardware::graphics::common::V1_1::BufferUsage::CPU_READ_RARELY) == - static_cast( - ::android::hardware::graphics::common::V1_1::BufferUsage::CPU_READ_RARELY)) { - os += (first ? "" : " | "); - os += "CPU_READ_RARELY"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_1::BufferUsage::CPU_READ_RARELY; - } - if ((o & ::android::hardware::graphics::common::V1_1::BufferUsage::CPU_READ_OFTEN) == - static_cast( - ::android::hardware::graphics::common::V1_1::BufferUsage::CPU_READ_OFTEN)) { - os += (first ? "" : " | "); - os += "CPU_READ_OFTEN"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_1::BufferUsage::CPU_READ_OFTEN; - } - if ((o & ::android::hardware::graphics::common::V1_1::BufferUsage::CPU_WRITE_MASK) == - static_cast( - ::android::hardware::graphics::common::V1_1::BufferUsage::CPU_WRITE_MASK)) { - os += (first ? "" : " | "); - os += "CPU_WRITE_MASK"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_1::BufferUsage::CPU_WRITE_MASK; - } - if ((o & ::android::hardware::graphics::common::V1_1::BufferUsage::CPU_WRITE_NEVER) == - static_cast( - ::android::hardware::graphics::common::V1_1::BufferUsage::CPU_WRITE_NEVER)) { - os += (first ? "" : " | "); - os += "CPU_WRITE_NEVER"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_1::BufferUsage::CPU_WRITE_NEVER; - } - if ((o & ::android::hardware::graphics::common::V1_1::BufferUsage::CPU_WRITE_RARELY) == - static_cast( - ::android::hardware::graphics::common::V1_1::BufferUsage::CPU_WRITE_RARELY)) { - os += (first ? "" : " | "); - os += "CPU_WRITE_RARELY"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_1::BufferUsage::CPU_WRITE_RARELY; - } - if ((o & ::android::hardware::graphics::common::V1_1::BufferUsage::CPU_WRITE_OFTEN) == - static_cast( - ::android::hardware::graphics::common::V1_1::BufferUsage::CPU_WRITE_OFTEN)) { - os += (first ? "" : " | "); - os += "CPU_WRITE_OFTEN"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_1::BufferUsage::CPU_WRITE_OFTEN; - } - if ((o & ::android::hardware::graphics::common::V1_1::BufferUsage::GPU_TEXTURE) == - static_cast( - ::android::hardware::graphics::common::V1_1::BufferUsage::GPU_TEXTURE)) { - os += (first ? "" : " | "); - os += "GPU_TEXTURE"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_1::BufferUsage::GPU_TEXTURE; - } - if ((o & ::android::hardware::graphics::common::V1_1::BufferUsage::GPU_RENDER_TARGET) == - static_cast( - ::android::hardware::graphics::common::V1_1::BufferUsage::GPU_RENDER_TARGET)) { - os += (first ? "" : " | "); - os += "GPU_RENDER_TARGET"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_1::BufferUsage::GPU_RENDER_TARGET; - } - if ((o & ::android::hardware::graphics::common::V1_1::BufferUsage::COMPOSER_OVERLAY) == - static_cast( - ::android::hardware::graphics::common::V1_1::BufferUsage::COMPOSER_OVERLAY)) { - os += (first ? "" : " | "); - os += "COMPOSER_OVERLAY"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_1::BufferUsage::COMPOSER_OVERLAY; - } - if ((o & ::android::hardware::graphics::common::V1_1::BufferUsage::COMPOSER_CLIENT_TARGET) == - static_cast( - ::android::hardware::graphics::common::V1_1::BufferUsage::COMPOSER_CLIENT_TARGET)) { - os += (first ? "" : " | "); - os += "COMPOSER_CLIENT_TARGET"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_1::BufferUsage::COMPOSER_CLIENT_TARGET; - } - if ((o & ::android::hardware::graphics::common::V1_1::BufferUsage::PROTECTED) == - static_cast(::android::hardware::graphics::common::V1_1::BufferUsage::PROTECTED)) { - os += (first ? "" : " | "); - os += "PROTECTED"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_1::BufferUsage::PROTECTED; - } - if ((o & ::android::hardware::graphics::common::V1_1::BufferUsage::COMPOSER_CURSOR) == - static_cast( - ::android::hardware::graphics::common::V1_1::BufferUsage::COMPOSER_CURSOR)) { - os += (first ? "" : " | "); - os += "COMPOSER_CURSOR"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_1::BufferUsage::COMPOSER_CURSOR; - } - if ((o & ::android::hardware::graphics::common::V1_1::BufferUsage::VIDEO_ENCODER) == - static_cast( - ::android::hardware::graphics::common::V1_1::BufferUsage::VIDEO_ENCODER)) { - os += (first ? "" : " | "); - os += "VIDEO_ENCODER"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_1::BufferUsage::VIDEO_ENCODER; - } - if ((o & ::android::hardware::graphics::common::V1_1::BufferUsage::CAMERA_OUTPUT) == - static_cast( - ::android::hardware::graphics::common::V1_1::BufferUsage::CAMERA_OUTPUT)) { - os += (first ? "" : " | "); - os += "CAMERA_OUTPUT"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_1::BufferUsage::CAMERA_OUTPUT; - } - if ((o & ::android::hardware::graphics::common::V1_1::BufferUsage::CAMERA_INPUT) == - static_cast( - ::android::hardware::graphics::common::V1_1::BufferUsage::CAMERA_INPUT)) { - os += (first ? "" : " | "); - os += "CAMERA_INPUT"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_1::BufferUsage::CAMERA_INPUT; - } - if ((o & ::android::hardware::graphics::common::V1_1::BufferUsage::RENDERSCRIPT) == - static_cast( - ::android::hardware::graphics::common::V1_1::BufferUsage::RENDERSCRIPT)) { - os += (first ? "" : " | "); - os += "RENDERSCRIPT"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_1::BufferUsage::RENDERSCRIPT; - } - if ((o & ::android::hardware::graphics::common::V1_1::BufferUsage::VIDEO_DECODER) == - static_cast( - ::android::hardware::graphics::common::V1_1::BufferUsage::VIDEO_DECODER)) { - os += (first ? "" : " | "); - os += "VIDEO_DECODER"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_1::BufferUsage::VIDEO_DECODER; - } - if ((o & ::android::hardware::graphics::common::V1_1::BufferUsage::SENSOR_DIRECT_DATA) == - static_cast( - ::android::hardware::graphics::common::V1_1::BufferUsage::SENSOR_DIRECT_DATA)) { - os += (first ? "" : " | "); - os += "SENSOR_DIRECT_DATA"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_1::BufferUsage::SENSOR_DIRECT_DATA; - } - if ((o & ::android::hardware::graphics::common::V1_1::BufferUsage::GPU_DATA_BUFFER) == - static_cast( - ::android::hardware::graphics::common::V1_1::BufferUsage::GPU_DATA_BUFFER)) { - os += (first ? "" : " | "); - os += "GPU_DATA_BUFFER"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_1::BufferUsage::GPU_DATA_BUFFER; - } - if ((o & ::android::hardware::graphics::common::V1_1::BufferUsage::VENDOR_MASK) == - static_cast( - ::android::hardware::graphics::common::V1_1::BufferUsage::VENDOR_MASK)) { - os += (first ? "" : " | "); - os += "VENDOR_MASK"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_1::BufferUsage::VENDOR_MASK; - } - if ((o & ::android::hardware::graphics::common::V1_1::BufferUsage::VENDOR_MASK_HI) == - static_cast( - ::android::hardware::graphics::common::V1_1::BufferUsage::VENDOR_MASK_HI)) { - os += (first ? "" : " | "); - os += "VENDOR_MASK_HI"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_1::BufferUsage::VENDOR_MASK_HI; - } - if ((o & ::android::hardware::graphics::common::V1_1::BufferUsage::GPU_CUBE_MAP) == - static_cast( - ::android::hardware::graphics::common::V1_1::BufferUsage::GPU_CUBE_MAP)) { - os += (first ? "" : " | "); - os += "GPU_CUBE_MAP"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_1::BufferUsage::GPU_CUBE_MAP; - } - if ((o & ::android::hardware::graphics::common::V1_1::BufferUsage::GPU_MIPMAP_COMPLETE) == - static_cast( - ::android::hardware::graphics::common::V1_1::BufferUsage::GPU_MIPMAP_COMPLETE)) { - os += (first ? "" : " | "); - os += "GPU_MIPMAP_COMPLETE"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_1::BufferUsage::GPU_MIPMAP_COMPLETE; - } - if (o != flipped) { - os += (first ? "" : " | "); - os += toHexString(o & (~flipped)); - } - os += " ("; - os += toHexString(o); - os += ")"; - return os; -} - -static inline std::string toString(::android::hardware::graphics::common::V1_1::BufferUsage o) { - using ::android::hardware::details::toHexString; - if (o == ::android::hardware::graphics::common::V1_1::BufferUsage::CPU_READ_MASK) { - return "CPU_READ_MASK"; - } - if (o == ::android::hardware::graphics::common::V1_1::BufferUsage::CPU_READ_NEVER) { - return "CPU_READ_NEVER"; - } - if (o == ::android::hardware::graphics::common::V1_1::BufferUsage::CPU_READ_RARELY) { - return "CPU_READ_RARELY"; - } - if (o == ::android::hardware::graphics::common::V1_1::BufferUsage::CPU_READ_OFTEN) { - return "CPU_READ_OFTEN"; - } - if (o == ::android::hardware::graphics::common::V1_1::BufferUsage::CPU_WRITE_MASK) { - return "CPU_WRITE_MASK"; - } - if (o == ::android::hardware::graphics::common::V1_1::BufferUsage::CPU_WRITE_NEVER) { - return "CPU_WRITE_NEVER"; - } - if (o == ::android::hardware::graphics::common::V1_1::BufferUsage::CPU_WRITE_RARELY) { - return "CPU_WRITE_RARELY"; - } - if (o == ::android::hardware::graphics::common::V1_1::BufferUsage::CPU_WRITE_OFTEN) { - return "CPU_WRITE_OFTEN"; - } - if (o == ::android::hardware::graphics::common::V1_1::BufferUsage::GPU_TEXTURE) { - return "GPU_TEXTURE"; - } - if (o == ::android::hardware::graphics::common::V1_1::BufferUsage::GPU_RENDER_TARGET) { - return "GPU_RENDER_TARGET"; - } - if (o == ::android::hardware::graphics::common::V1_1::BufferUsage::COMPOSER_OVERLAY) { - return "COMPOSER_OVERLAY"; - } - if (o == ::android::hardware::graphics::common::V1_1::BufferUsage::COMPOSER_CLIENT_TARGET) { - return "COMPOSER_CLIENT_TARGET"; - } - if (o == ::android::hardware::graphics::common::V1_1::BufferUsage::PROTECTED) { - return "PROTECTED"; - } - if (o == ::android::hardware::graphics::common::V1_1::BufferUsage::COMPOSER_CURSOR) { - return "COMPOSER_CURSOR"; - } - if (o == ::android::hardware::graphics::common::V1_1::BufferUsage::VIDEO_ENCODER) { - return "VIDEO_ENCODER"; - } - if (o == ::android::hardware::graphics::common::V1_1::BufferUsage::CAMERA_OUTPUT) { - return "CAMERA_OUTPUT"; - } - if (o == ::android::hardware::graphics::common::V1_1::BufferUsage::CAMERA_INPUT) { - return "CAMERA_INPUT"; - } - if (o == ::android::hardware::graphics::common::V1_1::BufferUsage::RENDERSCRIPT) { - return "RENDERSCRIPT"; - } - if (o == ::android::hardware::graphics::common::V1_1::BufferUsage::VIDEO_DECODER) { - return "VIDEO_DECODER"; - } - if (o == ::android::hardware::graphics::common::V1_1::BufferUsage::SENSOR_DIRECT_DATA) { - return "SENSOR_DIRECT_DATA"; - } - if (o == ::android::hardware::graphics::common::V1_1::BufferUsage::GPU_DATA_BUFFER) { - return "GPU_DATA_BUFFER"; - } - if (o == ::android::hardware::graphics::common::V1_1::BufferUsage::VENDOR_MASK) { - return "VENDOR_MASK"; - } - if (o == ::android::hardware::graphics::common::V1_1::BufferUsage::VENDOR_MASK_HI) { - return "VENDOR_MASK_HI"; - } - if (o == ::android::hardware::graphics::common::V1_1::BufferUsage::GPU_CUBE_MAP) { - return "GPU_CUBE_MAP"; - } - if (o == ::android::hardware::graphics::common::V1_1::BufferUsage::GPU_MIPMAP_COMPLETE) { - return "GPU_MIPMAP_COMPLETE"; - } - std::string os; - os += toHexString(static_cast(o)); - return os; -} - -template <> -inline std::string toString<::android::hardware::graphics::common::V1_1::Dataspace>(int32_t o) { - using ::android::hardware::details::toHexString; - std::string os; - ::android::hardware::hidl_bitfield<::android::hardware::graphics::common::V1_1::Dataspace> - flipped = 0; - bool first = true; - if ((o & ::android::hardware::graphics::common::V1_1::Dataspace::UNKNOWN) == - static_cast(::android::hardware::graphics::common::V1_1::Dataspace::UNKNOWN)) { - os += (first ? "" : " | "); - os += "UNKNOWN"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_1::Dataspace::UNKNOWN; - } - if ((o & ::android::hardware::graphics::common::V1_1::Dataspace::ARBITRARY) == - static_cast(::android::hardware::graphics::common::V1_1::Dataspace::ARBITRARY)) { - os += (first ? "" : " | "); - os += "ARBITRARY"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_1::Dataspace::ARBITRARY; - } - if ((o & ::android::hardware::graphics::common::V1_1::Dataspace::STANDARD_SHIFT) == - static_cast( - ::android::hardware::graphics::common::V1_1::Dataspace::STANDARD_SHIFT)) { - os += (first ? "" : " | "); - os += "STANDARD_SHIFT"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_1::Dataspace::STANDARD_SHIFT; - } - if ((o & ::android::hardware::graphics::common::V1_1::Dataspace::STANDARD_MASK) == - static_cast(::android::hardware::graphics::common::V1_1::Dataspace::STANDARD_MASK)) { - os += (first ? "" : " | "); - os += "STANDARD_MASK"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_1::Dataspace::STANDARD_MASK; - } - if ((o & ::android::hardware::graphics::common::V1_1::Dataspace::STANDARD_UNSPECIFIED) == - static_cast( - ::android::hardware::graphics::common::V1_1::Dataspace::STANDARD_UNSPECIFIED)) { - os += (first ? "" : " | "); - os += "STANDARD_UNSPECIFIED"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_1::Dataspace::STANDARD_UNSPECIFIED; - } - if ((o & ::android::hardware::graphics::common::V1_1::Dataspace::STANDARD_BT709) == - static_cast( - ::android::hardware::graphics::common::V1_1::Dataspace::STANDARD_BT709)) { - os += (first ? "" : " | "); - os += "STANDARD_BT709"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_1::Dataspace::STANDARD_BT709; - } - if ((o & ::android::hardware::graphics::common::V1_1::Dataspace::STANDARD_BT601_625) == - static_cast( - ::android::hardware::graphics::common::V1_1::Dataspace::STANDARD_BT601_625)) { - os += (first ? "" : " | "); - os += "STANDARD_BT601_625"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_1::Dataspace::STANDARD_BT601_625; - } - if ((o & ::android::hardware::graphics::common::V1_1::Dataspace::STANDARD_BT601_625_UNADJUSTED) == - static_cast( - ::android::hardware::graphics::common::V1_1::Dataspace::STANDARD_BT601_625_UNADJUSTED)) { - os += (first ? "" : " | "); - os += "STANDARD_BT601_625_UNADJUSTED"; - first = false; - flipped |= - ::android::hardware::graphics::common::V1_1::Dataspace::STANDARD_BT601_625_UNADJUSTED; - } - if ((o & ::android::hardware::graphics::common::V1_1::Dataspace::STANDARD_BT601_525) == - static_cast( - ::android::hardware::graphics::common::V1_1::Dataspace::STANDARD_BT601_525)) { - os += (first ? "" : " | "); - os += "STANDARD_BT601_525"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_1::Dataspace::STANDARD_BT601_525; - } - if ((o & ::android::hardware::graphics::common::V1_1::Dataspace::STANDARD_BT601_525_UNADJUSTED) == - static_cast( - ::android::hardware::graphics::common::V1_1::Dataspace::STANDARD_BT601_525_UNADJUSTED)) { - os += (first ? "" : " | "); - os += "STANDARD_BT601_525_UNADJUSTED"; - first = false; - flipped |= - ::android::hardware::graphics::common::V1_1::Dataspace::STANDARD_BT601_525_UNADJUSTED; - } - if ((o & ::android::hardware::graphics::common::V1_1::Dataspace::STANDARD_BT2020) == - static_cast( - ::android::hardware::graphics::common::V1_1::Dataspace::STANDARD_BT2020)) { - os += (first ? "" : " | "); - os += "STANDARD_BT2020"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_1::Dataspace::STANDARD_BT2020; - } - if ((o & ::android::hardware::graphics::common::V1_1::Dataspace:: - STANDARD_BT2020_CONSTANT_LUMINANCE) == - static_cast(::android::hardware::graphics::common::V1_1::Dataspace:: - STANDARD_BT2020_CONSTANT_LUMINANCE)) { - os += (first ? "" : " | "); - os += "STANDARD_BT2020_CONSTANT_LUMINANCE"; - first = false; - flipped |= - ::android::hardware::graphics::common::V1_1::Dataspace::STANDARD_BT2020_CONSTANT_LUMINANCE; - } - if ((o & ::android::hardware::graphics::common::V1_1::Dataspace::STANDARD_BT470M) == - static_cast( - ::android::hardware::graphics::common::V1_1::Dataspace::STANDARD_BT470M)) { - os += (first ? "" : " | "); - os += "STANDARD_BT470M"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_1::Dataspace::STANDARD_BT470M; - } - if ((o & ::android::hardware::graphics::common::V1_1::Dataspace::STANDARD_FILM) == - static_cast(::android::hardware::graphics::common::V1_1::Dataspace::STANDARD_FILM)) { - os += (first ? "" : " | "); - os += "STANDARD_FILM"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_1::Dataspace::STANDARD_FILM; - } - if ((o & ::android::hardware::graphics::common::V1_1::Dataspace::STANDARD_DCI_P3) == - static_cast( - ::android::hardware::graphics::common::V1_1::Dataspace::STANDARD_DCI_P3)) { - os += (first ? "" : " | "); - os += "STANDARD_DCI_P3"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_1::Dataspace::STANDARD_DCI_P3; - } - if ((o & ::android::hardware::graphics::common::V1_1::Dataspace::STANDARD_ADOBE_RGB) == - static_cast( - ::android::hardware::graphics::common::V1_1::Dataspace::STANDARD_ADOBE_RGB)) { - os += (first ? "" : " | "); - os += "STANDARD_ADOBE_RGB"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_1::Dataspace::STANDARD_ADOBE_RGB; - } - if ((o & ::android::hardware::graphics::common::V1_1::Dataspace::TRANSFER_SHIFT) == - static_cast( - ::android::hardware::graphics::common::V1_1::Dataspace::TRANSFER_SHIFT)) { - os += (first ? "" : " | "); - os += "TRANSFER_SHIFT"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_1::Dataspace::TRANSFER_SHIFT; - } - if ((o & ::android::hardware::graphics::common::V1_1::Dataspace::TRANSFER_MASK) == - static_cast(::android::hardware::graphics::common::V1_1::Dataspace::TRANSFER_MASK)) { - os += (first ? "" : " | "); - os += "TRANSFER_MASK"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_1::Dataspace::TRANSFER_MASK; - } - if ((o & ::android::hardware::graphics::common::V1_1::Dataspace::TRANSFER_UNSPECIFIED) == - static_cast( - ::android::hardware::graphics::common::V1_1::Dataspace::TRANSFER_UNSPECIFIED)) { - os += (first ? "" : " | "); - os += "TRANSFER_UNSPECIFIED"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_1::Dataspace::TRANSFER_UNSPECIFIED; - } - if ((o & ::android::hardware::graphics::common::V1_1::Dataspace::TRANSFER_LINEAR) == - static_cast( - ::android::hardware::graphics::common::V1_1::Dataspace::TRANSFER_LINEAR)) { - os += (first ? "" : " | "); - os += "TRANSFER_LINEAR"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_1::Dataspace::TRANSFER_LINEAR; - } - if ((o & ::android::hardware::graphics::common::V1_1::Dataspace::TRANSFER_SRGB) == - static_cast(::android::hardware::graphics::common::V1_1::Dataspace::TRANSFER_SRGB)) { - os += (first ? "" : " | "); - os += "TRANSFER_SRGB"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_1::Dataspace::TRANSFER_SRGB; - } - if ((o & ::android::hardware::graphics::common::V1_1::Dataspace::TRANSFER_SMPTE_170M) == - static_cast( - ::android::hardware::graphics::common::V1_1::Dataspace::TRANSFER_SMPTE_170M)) { - os += (first ? "" : " | "); - os += "TRANSFER_SMPTE_170M"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_1::Dataspace::TRANSFER_SMPTE_170M; - } - if ((o & ::android::hardware::graphics::common::V1_1::Dataspace::TRANSFER_GAMMA2_2) == - static_cast( - ::android::hardware::graphics::common::V1_1::Dataspace::TRANSFER_GAMMA2_2)) { - os += (first ? "" : " | "); - os += "TRANSFER_GAMMA2_2"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_1::Dataspace::TRANSFER_GAMMA2_2; - } - if ((o & ::android::hardware::graphics::common::V1_1::Dataspace::TRANSFER_GAMMA2_6) == - static_cast( - ::android::hardware::graphics::common::V1_1::Dataspace::TRANSFER_GAMMA2_6)) { - os += (first ? "" : " | "); - os += "TRANSFER_GAMMA2_6"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_1::Dataspace::TRANSFER_GAMMA2_6; - } - if ((o & ::android::hardware::graphics::common::V1_1::Dataspace::TRANSFER_GAMMA2_8) == - static_cast( - ::android::hardware::graphics::common::V1_1::Dataspace::TRANSFER_GAMMA2_8)) { - os += (first ? "" : " | "); - os += "TRANSFER_GAMMA2_8"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_1::Dataspace::TRANSFER_GAMMA2_8; - } - if ((o & ::android::hardware::graphics::common::V1_1::Dataspace::TRANSFER_ST2084) == - static_cast( - ::android::hardware::graphics::common::V1_1::Dataspace::TRANSFER_ST2084)) { - os += (first ? "" : " | "); - os += "TRANSFER_ST2084"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_1::Dataspace::TRANSFER_ST2084; - } - if ((o & ::android::hardware::graphics::common::V1_1::Dataspace::TRANSFER_HLG) == - static_cast(::android::hardware::graphics::common::V1_1::Dataspace::TRANSFER_HLG)) { - os += (first ? "" : " | "); - os += "TRANSFER_HLG"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_1::Dataspace::TRANSFER_HLG; - } - if ((o & ::android::hardware::graphics::common::V1_1::Dataspace::RANGE_SHIFT) == - static_cast(::android::hardware::graphics::common::V1_1::Dataspace::RANGE_SHIFT)) { - os += (first ? "" : " | "); - os += "RANGE_SHIFT"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_1::Dataspace::RANGE_SHIFT; - } - if ((o & ::android::hardware::graphics::common::V1_1::Dataspace::RANGE_MASK) == - static_cast(::android::hardware::graphics::common::V1_1::Dataspace::RANGE_MASK)) { - os += (first ? "" : " | "); - os += "RANGE_MASK"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_1::Dataspace::RANGE_MASK; - } - if ((o & ::android::hardware::graphics::common::V1_1::Dataspace::RANGE_UNSPECIFIED) == - static_cast( - ::android::hardware::graphics::common::V1_1::Dataspace::RANGE_UNSPECIFIED)) { - os += (first ? "" : " | "); - os += "RANGE_UNSPECIFIED"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_1::Dataspace::RANGE_UNSPECIFIED; - } - if ((o & ::android::hardware::graphics::common::V1_1::Dataspace::RANGE_FULL) == - static_cast(::android::hardware::graphics::common::V1_1::Dataspace::RANGE_FULL)) { - os += (first ? "" : " | "); - os += "RANGE_FULL"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_1::Dataspace::RANGE_FULL; - } - if ((o & ::android::hardware::graphics::common::V1_1::Dataspace::RANGE_LIMITED) == - static_cast(::android::hardware::graphics::common::V1_1::Dataspace::RANGE_LIMITED)) { - os += (first ? "" : " | "); - os += "RANGE_LIMITED"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_1::Dataspace::RANGE_LIMITED; - } - if ((o & ::android::hardware::graphics::common::V1_1::Dataspace::RANGE_EXTENDED) == - static_cast( - ::android::hardware::graphics::common::V1_1::Dataspace::RANGE_EXTENDED)) { - os += (first ? "" : " | "); - os += "RANGE_EXTENDED"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_1::Dataspace::RANGE_EXTENDED; - } - if ((o & ::android::hardware::graphics::common::V1_1::Dataspace::SRGB_LINEAR) == - static_cast(::android::hardware::graphics::common::V1_1::Dataspace::SRGB_LINEAR)) { - os += (first ? "" : " | "); - os += "SRGB_LINEAR"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_1::Dataspace::SRGB_LINEAR; - } - if ((o & ::android::hardware::graphics::common::V1_1::Dataspace::V0_SRGB_LINEAR) == - static_cast( - ::android::hardware::graphics::common::V1_1::Dataspace::V0_SRGB_LINEAR)) { - os += (first ? "" : " | "); - os += "V0_SRGB_LINEAR"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_1::Dataspace::V0_SRGB_LINEAR; - } - if ((o & ::android::hardware::graphics::common::V1_1::Dataspace::V0_SCRGB_LINEAR) == - static_cast( - ::android::hardware::graphics::common::V1_1::Dataspace::V0_SCRGB_LINEAR)) { - os += (first ? "" : " | "); - os += "V0_SCRGB_LINEAR"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_1::Dataspace::V0_SCRGB_LINEAR; - } - if ((o & ::android::hardware::graphics::common::V1_1::Dataspace::SRGB) == - static_cast(::android::hardware::graphics::common::V1_1::Dataspace::SRGB)) { - os += (first ? "" : " | "); - os += "SRGB"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_1::Dataspace::SRGB; - } - if ((o & ::android::hardware::graphics::common::V1_1::Dataspace::V0_SRGB) == - static_cast(::android::hardware::graphics::common::V1_1::Dataspace::V0_SRGB)) { - os += (first ? "" : " | "); - os += "V0_SRGB"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_1::Dataspace::V0_SRGB; - } - if ((o & ::android::hardware::graphics::common::V1_1::Dataspace::V0_SCRGB) == - static_cast(::android::hardware::graphics::common::V1_1::Dataspace::V0_SCRGB)) { - os += (first ? "" : " | "); - os += "V0_SCRGB"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_1::Dataspace::V0_SCRGB; - } - if ((o & ::android::hardware::graphics::common::V1_1::Dataspace::JFIF) == - static_cast(::android::hardware::graphics::common::V1_1::Dataspace::JFIF)) { - os += (first ? "" : " | "); - os += "JFIF"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_1::Dataspace::JFIF; - } - if ((o & ::android::hardware::graphics::common::V1_1::Dataspace::V0_JFIF) == - static_cast(::android::hardware::graphics::common::V1_1::Dataspace::V0_JFIF)) { - os += (first ? "" : " | "); - os += "V0_JFIF"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_1::Dataspace::V0_JFIF; - } - if ((o & ::android::hardware::graphics::common::V1_1::Dataspace::BT601_625) == - static_cast(::android::hardware::graphics::common::V1_1::Dataspace::BT601_625)) { - os += (first ? "" : " | "); - os += "BT601_625"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_1::Dataspace::BT601_625; - } - if ((o & ::android::hardware::graphics::common::V1_1::Dataspace::V0_BT601_625) == - static_cast(::android::hardware::graphics::common::V1_1::Dataspace::V0_BT601_625)) { - os += (first ? "" : " | "); - os += "V0_BT601_625"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_1::Dataspace::V0_BT601_625; - } - if ((o & ::android::hardware::graphics::common::V1_1::Dataspace::BT601_525) == - static_cast(::android::hardware::graphics::common::V1_1::Dataspace::BT601_525)) { - os += (first ? "" : " | "); - os += "BT601_525"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_1::Dataspace::BT601_525; - } - if ((o & ::android::hardware::graphics::common::V1_1::Dataspace::V0_BT601_525) == - static_cast(::android::hardware::graphics::common::V1_1::Dataspace::V0_BT601_525)) { - os += (first ? "" : " | "); - os += "V0_BT601_525"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_1::Dataspace::V0_BT601_525; - } - if ((o & ::android::hardware::graphics::common::V1_1::Dataspace::BT709) == - static_cast(::android::hardware::graphics::common::V1_1::Dataspace::BT709)) { - os += (first ? "" : " | "); - os += "BT709"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_1::Dataspace::BT709; - } - if ((o & ::android::hardware::graphics::common::V1_1::Dataspace::V0_BT709) == - static_cast(::android::hardware::graphics::common::V1_1::Dataspace::V0_BT709)) { - os += (first ? "" : " | "); - os += "V0_BT709"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_1::Dataspace::V0_BT709; - } - if ((o & ::android::hardware::graphics::common::V1_1::Dataspace::DCI_P3_LINEAR) == - static_cast(::android::hardware::graphics::common::V1_1::Dataspace::DCI_P3_LINEAR)) { - os += (first ? "" : " | "); - os += "DCI_P3_LINEAR"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_1::Dataspace::DCI_P3_LINEAR; - } - if ((o & ::android::hardware::graphics::common::V1_1::Dataspace::DCI_P3) == - static_cast(::android::hardware::graphics::common::V1_1::Dataspace::DCI_P3)) { - os += (first ? "" : " | "); - os += "DCI_P3"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_1::Dataspace::DCI_P3; - } - if ((o & ::android::hardware::graphics::common::V1_1::Dataspace::DISPLAY_P3_LINEAR) == - static_cast( - ::android::hardware::graphics::common::V1_1::Dataspace::DISPLAY_P3_LINEAR)) { - os += (first ? "" : " | "); - os += "DISPLAY_P3_LINEAR"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_1::Dataspace::DISPLAY_P3_LINEAR; - } - if ((o & ::android::hardware::graphics::common::V1_1::Dataspace::DISPLAY_P3) == - static_cast(::android::hardware::graphics::common::V1_1::Dataspace::DISPLAY_P3)) { - os += (first ? "" : " | "); - os += "DISPLAY_P3"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_1::Dataspace::DISPLAY_P3; - } - if ((o & ::android::hardware::graphics::common::V1_1::Dataspace::ADOBE_RGB) == - static_cast(::android::hardware::graphics::common::V1_1::Dataspace::ADOBE_RGB)) { - os += (first ? "" : " | "); - os += "ADOBE_RGB"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_1::Dataspace::ADOBE_RGB; - } - if ((o & ::android::hardware::graphics::common::V1_1::Dataspace::BT2020_LINEAR) == - static_cast(::android::hardware::graphics::common::V1_1::Dataspace::BT2020_LINEAR)) { - os += (first ? "" : " | "); - os += "BT2020_LINEAR"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_1::Dataspace::BT2020_LINEAR; - } - if ((o & ::android::hardware::graphics::common::V1_1::Dataspace::BT2020) == - static_cast(::android::hardware::graphics::common::V1_1::Dataspace::BT2020)) { - os += (first ? "" : " | "); - os += "BT2020"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_1::Dataspace::BT2020; - } - if ((o & ::android::hardware::graphics::common::V1_1::Dataspace::BT2020_PQ) == - static_cast(::android::hardware::graphics::common::V1_1::Dataspace::BT2020_PQ)) { - os += (first ? "" : " | "); - os += "BT2020_PQ"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_1::Dataspace::BT2020_PQ; - } - if ((o & ::android::hardware::graphics::common::V1_1::Dataspace::DEPTH) == - static_cast(::android::hardware::graphics::common::V1_1::Dataspace::DEPTH)) { - os += (first ? "" : " | "); - os += "DEPTH"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_1::Dataspace::DEPTH; - } - if ((o & ::android::hardware::graphics::common::V1_1::Dataspace::SENSOR) == - static_cast(::android::hardware::graphics::common::V1_1::Dataspace::SENSOR)) { - os += (first ? "" : " | "); - os += "SENSOR"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_1::Dataspace::SENSOR; - } - if ((o & ::android::hardware::graphics::common::V1_1::Dataspace::BT2020_ITU) == - static_cast(::android::hardware::graphics::common::V1_1::Dataspace::BT2020_ITU)) { - os += (first ? "" : " | "); - os += "BT2020_ITU"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_1::Dataspace::BT2020_ITU; - } - if ((o & ::android::hardware::graphics::common::V1_1::Dataspace::BT2020_ITU_PQ) == - static_cast(::android::hardware::graphics::common::V1_1::Dataspace::BT2020_ITU_PQ)) { - os += (first ? "" : " | "); - os += "BT2020_ITU_PQ"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_1::Dataspace::BT2020_ITU_PQ; - } - if ((o & ::android::hardware::graphics::common::V1_1::Dataspace::BT2020_ITU_HLG) == - static_cast( - ::android::hardware::graphics::common::V1_1::Dataspace::BT2020_ITU_HLG)) { - os += (first ? "" : " | "); - os += "BT2020_ITU_HLG"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_1::Dataspace::BT2020_ITU_HLG; - } - if ((o & ::android::hardware::graphics::common::V1_1::Dataspace::BT2020_HLG) == - static_cast(::android::hardware::graphics::common::V1_1::Dataspace::BT2020_HLG)) { - os += (first ? "" : " | "); - os += "BT2020_HLG"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_1::Dataspace::BT2020_HLG; - } - if (o != flipped) { - os += (first ? "" : " | "); - os += toHexString(o & (~flipped)); - } - os += " ("; - os += toHexString(o); - os += ")"; - return os; -} - -static inline std::string toString(::android::hardware::graphics::common::V1_1::Dataspace o) { - using ::android::hardware::details::toHexString; - if (o == ::android::hardware::graphics::common::V1_1::Dataspace::UNKNOWN) { - return "UNKNOWN"; - } - if (o == ::android::hardware::graphics::common::V1_1::Dataspace::ARBITRARY) { - return "ARBITRARY"; - } - if (o == ::android::hardware::graphics::common::V1_1::Dataspace::STANDARD_SHIFT) { - return "STANDARD_SHIFT"; - } - if (o == ::android::hardware::graphics::common::V1_1::Dataspace::STANDARD_MASK) { - return "STANDARD_MASK"; - } - if (o == ::android::hardware::graphics::common::V1_1::Dataspace::STANDARD_UNSPECIFIED) { - return "STANDARD_UNSPECIFIED"; - } - if (o == ::android::hardware::graphics::common::V1_1::Dataspace::STANDARD_BT709) { - return "STANDARD_BT709"; - } - if (o == ::android::hardware::graphics::common::V1_1::Dataspace::STANDARD_BT601_625) { - return "STANDARD_BT601_625"; - } - if (o == ::android::hardware::graphics::common::V1_1::Dataspace::STANDARD_BT601_625_UNADJUSTED) { - return "STANDARD_BT601_625_UNADJUSTED"; - } - if (o == ::android::hardware::graphics::common::V1_1::Dataspace::STANDARD_BT601_525) { - return "STANDARD_BT601_525"; - } - if (o == ::android::hardware::graphics::common::V1_1::Dataspace::STANDARD_BT601_525_UNADJUSTED) { - return "STANDARD_BT601_525_UNADJUSTED"; - } - if (o == ::android::hardware::graphics::common::V1_1::Dataspace::STANDARD_BT2020) { - return "STANDARD_BT2020"; - } - if (o == - ::android::hardware::graphics::common::V1_1::Dataspace::STANDARD_BT2020_CONSTANT_LUMINANCE) { - return "STANDARD_BT2020_CONSTANT_LUMINANCE"; - } - if (o == ::android::hardware::graphics::common::V1_1::Dataspace::STANDARD_BT470M) { - return "STANDARD_BT470M"; - } - if (o == ::android::hardware::graphics::common::V1_1::Dataspace::STANDARD_FILM) { - return "STANDARD_FILM"; - } - if (o == ::android::hardware::graphics::common::V1_1::Dataspace::STANDARD_DCI_P3) { - return "STANDARD_DCI_P3"; - } - if (o == ::android::hardware::graphics::common::V1_1::Dataspace::STANDARD_ADOBE_RGB) { - return "STANDARD_ADOBE_RGB"; - } - if (o == ::android::hardware::graphics::common::V1_1::Dataspace::TRANSFER_SHIFT) { - return "TRANSFER_SHIFT"; - } - if (o == ::android::hardware::graphics::common::V1_1::Dataspace::TRANSFER_MASK) { - return "TRANSFER_MASK"; - } - if (o == ::android::hardware::graphics::common::V1_1::Dataspace::TRANSFER_UNSPECIFIED) { - return "TRANSFER_UNSPECIFIED"; - } - if (o == ::android::hardware::graphics::common::V1_1::Dataspace::TRANSFER_LINEAR) { - return "TRANSFER_LINEAR"; - } - if (o == ::android::hardware::graphics::common::V1_1::Dataspace::TRANSFER_SRGB) { - return "TRANSFER_SRGB"; - } - if (o == ::android::hardware::graphics::common::V1_1::Dataspace::TRANSFER_SMPTE_170M) { - return "TRANSFER_SMPTE_170M"; - } - if (o == ::android::hardware::graphics::common::V1_1::Dataspace::TRANSFER_GAMMA2_2) { - return "TRANSFER_GAMMA2_2"; - } - if (o == ::android::hardware::graphics::common::V1_1::Dataspace::TRANSFER_GAMMA2_6) { - return "TRANSFER_GAMMA2_6"; - } - if (o == ::android::hardware::graphics::common::V1_1::Dataspace::TRANSFER_GAMMA2_8) { - return "TRANSFER_GAMMA2_8"; - } - if (o == ::android::hardware::graphics::common::V1_1::Dataspace::TRANSFER_ST2084) { - return "TRANSFER_ST2084"; - } - if (o == ::android::hardware::graphics::common::V1_1::Dataspace::TRANSFER_HLG) { - return "TRANSFER_HLG"; - } - if (o == ::android::hardware::graphics::common::V1_1::Dataspace::RANGE_SHIFT) { - return "RANGE_SHIFT"; - } - if (o == ::android::hardware::graphics::common::V1_1::Dataspace::RANGE_MASK) { - return "RANGE_MASK"; - } - if (o == ::android::hardware::graphics::common::V1_1::Dataspace::RANGE_UNSPECIFIED) { - return "RANGE_UNSPECIFIED"; - } - if (o == ::android::hardware::graphics::common::V1_1::Dataspace::RANGE_FULL) { - return "RANGE_FULL"; - } - if (o == ::android::hardware::graphics::common::V1_1::Dataspace::RANGE_LIMITED) { - return "RANGE_LIMITED"; - } - if (o == ::android::hardware::graphics::common::V1_1::Dataspace::RANGE_EXTENDED) { - return "RANGE_EXTENDED"; - } - if (o == ::android::hardware::graphics::common::V1_1::Dataspace::SRGB_LINEAR) { - return "SRGB_LINEAR"; - } - if (o == ::android::hardware::graphics::common::V1_1::Dataspace::V0_SRGB_LINEAR) { - return "V0_SRGB_LINEAR"; - } - if (o == ::android::hardware::graphics::common::V1_1::Dataspace::V0_SCRGB_LINEAR) { - return "V0_SCRGB_LINEAR"; - } - if (o == ::android::hardware::graphics::common::V1_1::Dataspace::SRGB) { - return "SRGB"; - } - if (o == ::android::hardware::graphics::common::V1_1::Dataspace::V0_SRGB) { - return "V0_SRGB"; - } - if (o == ::android::hardware::graphics::common::V1_1::Dataspace::V0_SCRGB) { - return "V0_SCRGB"; - } - if (o == ::android::hardware::graphics::common::V1_1::Dataspace::JFIF) { - return "JFIF"; - } - if (o == ::android::hardware::graphics::common::V1_1::Dataspace::V0_JFIF) { - return "V0_JFIF"; - } - if (o == ::android::hardware::graphics::common::V1_1::Dataspace::BT601_625) { - return "BT601_625"; - } - if (o == ::android::hardware::graphics::common::V1_1::Dataspace::V0_BT601_625) { - return "V0_BT601_625"; - } - if (o == ::android::hardware::graphics::common::V1_1::Dataspace::BT601_525) { - return "BT601_525"; - } - if (o == ::android::hardware::graphics::common::V1_1::Dataspace::V0_BT601_525) { - return "V0_BT601_525"; - } - if (o == ::android::hardware::graphics::common::V1_1::Dataspace::BT709) { - return "BT709"; - } - if (o == ::android::hardware::graphics::common::V1_1::Dataspace::V0_BT709) { - return "V0_BT709"; - } - if (o == ::android::hardware::graphics::common::V1_1::Dataspace::DCI_P3_LINEAR) { - return "DCI_P3_LINEAR"; - } - if (o == ::android::hardware::graphics::common::V1_1::Dataspace::DCI_P3) { - return "DCI_P3"; - } - if (o == ::android::hardware::graphics::common::V1_1::Dataspace::DISPLAY_P3_LINEAR) { - return "DISPLAY_P3_LINEAR"; - } - if (o == ::android::hardware::graphics::common::V1_1::Dataspace::DISPLAY_P3) { - return "DISPLAY_P3"; - } - if (o == ::android::hardware::graphics::common::V1_1::Dataspace::ADOBE_RGB) { - return "ADOBE_RGB"; - } - if (o == ::android::hardware::graphics::common::V1_1::Dataspace::BT2020_LINEAR) { - return "BT2020_LINEAR"; - } - if (o == ::android::hardware::graphics::common::V1_1::Dataspace::BT2020) { - return "BT2020"; - } - if (o == ::android::hardware::graphics::common::V1_1::Dataspace::BT2020_PQ) { - return "BT2020_PQ"; - } - if (o == ::android::hardware::graphics::common::V1_1::Dataspace::DEPTH) { - return "DEPTH"; - } - if (o == ::android::hardware::graphics::common::V1_1::Dataspace::SENSOR) { - return "SENSOR"; - } - if (o == ::android::hardware::graphics::common::V1_1::Dataspace::BT2020_ITU) { - return "BT2020_ITU"; - } - if (o == ::android::hardware::graphics::common::V1_1::Dataspace::BT2020_ITU_PQ) { - return "BT2020_ITU_PQ"; - } - if (o == ::android::hardware::graphics::common::V1_1::Dataspace::BT2020_ITU_HLG) { - return "BT2020_ITU_HLG"; - } - if (o == ::android::hardware::graphics::common::V1_1::Dataspace::BT2020_HLG) { - return "BT2020_HLG"; - } - std::string os; - os += toHexString(static_cast(o)); - return os; -} - -template <> -inline std::string toString<::android::hardware::graphics::common::V1_1::ColorMode>(int32_t o) { - using ::android::hardware::details::toHexString; - std::string os; - ::android::hardware::hidl_bitfield<::android::hardware::graphics::common::V1_1::ColorMode> - flipped = 0; - bool first = true; - if ((o & ::android::hardware::graphics::common::V1_1::ColorMode::NATIVE) == - static_cast(::android::hardware::graphics::common::V1_1::ColorMode::NATIVE)) { - os += (first ? "" : " | "); - os += "NATIVE"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_1::ColorMode::NATIVE; - } - if ((o & ::android::hardware::graphics::common::V1_1::ColorMode::STANDARD_BT601_625) == - static_cast( - ::android::hardware::graphics::common::V1_1::ColorMode::STANDARD_BT601_625)) { - os += (first ? "" : " | "); - os += "STANDARD_BT601_625"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_1::ColorMode::STANDARD_BT601_625; - } - if ((o & ::android::hardware::graphics::common::V1_1::ColorMode::STANDARD_BT601_625_UNADJUSTED) == - static_cast( - ::android::hardware::graphics::common::V1_1::ColorMode::STANDARD_BT601_625_UNADJUSTED)) { - os += (first ? "" : " | "); - os += "STANDARD_BT601_625_UNADJUSTED"; - first = false; - flipped |= - ::android::hardware::graphics::common::V1_1::ColorMode::STANDARD_BT601_625_UNADJUSTED; - } - if ((o & ::android::hardware::graphics::common::V1_1::ColorMode::STANDARD_BT601_525) == - static_cast( - ::android::hardware::graphics::common::V1_1::ColorMode::STANDARD_BT601_525)) { - os += (first ? "" : " | "); - os += "STANDARD_BT601_525"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_1::ColorMode::STANDARD_BT601_525; - } - if ((o & ::android::hardware::graphics::common::V1_1::ColorMode::STANDARD_BT601_525_UNADJUSTED) == - static_cast( - ::android::hardware::graphics::common::V1_1::ColorMode::STANDARD_BT601_525_UNADJUSTED)) { - os += (first ? "" : " | "); - os += "STANDARD_BT601_525_UNADJUSTED"; - first = false; - flipped |= - ::android::hardware::graphics::common::V1_1::ColorMode::STANDARD_BT601_525_UNADJUSTED; - } - if ((o & ::android::hardware::graphics::common::V1_1::ColorMode::STANDARD_BT709) == - static_cast( - ::android::hardware::graphics::common::V1_1::ColorMode::STANDARD_BT709)) { - os += (first ? "" : " | "); - os += "STANDARD_BT709"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_1::ColorMode::STANDARD_BT709; - } - if ((o & ::android::hardware::graphics::common::V1_1::ColorMode::DCI_P3) == - static_cast(::android::hardware::graphics::common::V1_1::ColorMode::DCI_P3)) { - os += (first ? "" : " | "); - os += "DCI_P3"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_1::ColorMode::DCI_P3; - } - if ((o & ::android::hardware::graphics::common::V1_1::ColorMode::SRGB) == - static_cast(::android::hardware::graphics::common::V1_1::ColorMode::SRGB)) { - os += (first ? "" : " | "); - os += "SRGB"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_1::ColorMode::SRGB; - } - if ((o & ::android::hardware::graphics::common::V1_1::ColorMode::ADOBE_RGB) == - static_cast(::android::hardware::graphics::common::V1_1::ColorMode::ADOBE_RGB)) { - os += (first ? "" : " | "); - os += "ADOBE_RGB"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_1::ColorMode::ADOBE_RGB; - } - if ((o & ::android::hardware::graphics::common::V1_1::ColorMode::DISPLAY_P3) == - static_cast(::android::hardware::graphics::common::V1_1::ColorMode::DISPLAY_P3)) { - os += (first ? "" : " | "); - os += "DISPLAY_P3"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_1::ColorMode::DISPLAY_P3; - } - if ((o & ::android::hardware::graphics::common::V1_1::ColorMode::BT2020) == - static_cast(::android::hardware::graphics::common::V1_1::ColorMode::BT2020)) { - os += (first ? "" : " | "); - os += "BT2020"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_1::ColorMode::BT2020; - } - if ((o & ::android::hardware::graphics::common::V1_1::ColorMode::BT2100_PQ) == - static_cast(::android::hardware::graphics::common::V1_1::ColorMode::BT2100_PQ)) { - os += (first ? "" : " | "); - os += "BT2100_PQ"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_1::ColorMode::BT2100_PQ; - } - if ((o & ::android::hardware::graphics::common::V1_1::ColorMode::BT2100_HLG) == - static_cast(::android::hardware::graphics::common::V1_1::ColorMode::BT2100_HLG)) { - os += (first ? "" : " | "); - os += "BT2100_HLG"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_1::ColorMode::BT2100_HLG; - } - if (o != flipped) { - os += (first ? "" : " | "); - os += toHexString(o & (~flipped)); - } - os += " ("; - os += toHexString(o); - os += ")"; - return os; -} - -static inline std::string toString(::android::hardware::graphics::common::V1_1::ColorMode o) { - using ::android::hardware::details::toHexString; - if (o == ::android::hardware::graphics::common::V1_1::ColorMode::NATIVE) { - return "NATIVE"; - } - if (o == ::android::hardware::graphics::common::V1_1::ColorMode::STANDARD_BT601_625) { - return "STANDARD_BT601_625"; - } - if (o == ::android::hardware::graphics::common::V1_1::ColorMode::STANDARD_BT601_625_UNADJUSTED) { - return "STANDARD_BT601_625_UNADJUSTED"; - } - if (o == ::android::hardware::graphics::common::V1_1::ColorMode::STANDARD_BT601_525) { - return "STANDARD_BT601_525"; - } - if (o == ::android::hardware::graphics::common::V1_1::ColorMode::STANDARD_BT601_525_UNADJUSTED) { - return "STANDARD_BT601_525_UNADJUSTED"; - } - if (o == ::android::hardware::graphics::common::V1_1::ColorMode::STANDARD_BT709) { - return "STANDARD_BT709"; - } - if (o == ::android::hardware::graphics::common::V1_1::ColorMode::DCI_P3) { - return "DCI_P3"; - } - if (o == ::android::hardware::graphics::common::V1_1::ColorMode::SRGB) { - return "SRGB"; - } - if (o == ::android::hardware::graphics::common::V1_1::ColorMode::ADOBE_RGB) { - return "ADOBE_RGB"; - } - if (o == ::android::hardware::graphics::common::V1_1::ColorMode::DISPLAY_P3) { - return "DISPLAY_P3"; - } - if (o == ::android::hardware::graphics::common::V1_1::ColorMode::BT2020) { - return "BT2020"; - } - if (o == ::android::hardware::graphics::common::V1_1::ColorMode::BT2100_PQ) { - return "BT2100_PQ"; - } - if (o == ::android::hardware::graphics::common::V1_1::ColorMode::BT2100_HLG) { - return "BT2100_HLG"; - } - std::string os; - os += toHexString(static_cast(o)); - return os; -} - -template <> -inline std::string toString<::android::hardware::graphics::common::V1_1::RenderIntent>(int32_t o) { - using ::android::hardware::details::toHexString; - std::string os; - ::android::hardware::hidl_bitfield<::android::hardware::graphics::common::V1_1::RenderIntent> - flipped = 0; - bool first = true; - if ((o & ::android::hardware::graphics::common::V1_1::RenderIntent::COLORIMETRIC) == - static_cast( - ::android::hardware::graphics::common::V1_1::RenderIntent::COLORIMETRIC)) { - os += (first ? "" : " | "); - os += "COLORIMETRIC"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_1::RenderIntent::COLORIMETRIC; - } - if ((o & ::android::hardware::graphics::common::V1_1::RenderIntent::ENHANCE) == - static_cast(::android::hardware::graphics::common::V1_1::RenderIntent::ENHANCE)) { - os += (first ? "" : " | "); - os += "ENHANCE"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_1::RenderIntent::ENHANCE; - } - if ((o & ::android::hardware::graphics::common::V1_1::RenderIntent::TONE_MAP_COLORIMETRIC) == - static_cast( - ::android::hardware::graphics::common::V1_1::RenderIntent::TONE_MAP_COLORIMETRIC)) { - os += (first ? "" : " | "); - os += "TONE_MAP_COLORIMETRIC"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_1::RenderIntent::TONE_MAP_COLORIMETRIC; - } - if ((o & ::android::hardware::graphics::common::V1_1::RenderIntent::TONE_MAP_ENHANCE) == - static_cast( - ::android::hardware::graphics::common::V1_1::RenderIntent::TONE_MAP_ENHANCE)) { - os += (first ? "" : " | "); - os += "TONE_MAP_ENHANCE"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_1::RenderIntent::TONE_MAP_ENHANCE; - } - if (o != flipped) { - os += (first ? "" : " | "); - os += toHexString(o & (~flipped)); - } - os += " ("; - os += toHexString(o); - os += ")"; - return os; -} - -static inline std::string toString(::android::hardware::graphics::common::V1_1::RenderIntent o) { - using ::android::hardware::details::toHexString; - if (o == ::android::hardware::graphics::common::V1_1::RenderIntent::COLORIMETRIC) { - return "COLORIMETRIC"; - } - if (o == ::android::hardware::graphics::common::V1_1::RenderIntent::ENHANCE) { - return "ENHANCE"; - } - if (o == ::android::hardware::graphics::common::V1_1::RenderIntent::TONE_MAP_COLORIMETRIC) { - return "TONE_MAP_COLORIMETRIC"; - } - if (o == ::android::hardware::graphics::common::V1_1::RenderIntent::TONE_MAP_ENHANCE) { - return "TONE_MAP_ENHANCE"; - } - std::string os; - os += toHexString(static_cast(o)); - return os; -} - -} // namespace V1_1 -} // namespace common -} // namespace graphics -} // namespace hardware -} // namespace android - -// -// global type declarations for package -// - -namespace android { -namespace hardware { -namespace details { -template <> -constexpr std::array<::android::hardware::graphics::common::V1_1::PixelFormat, 27> - hidl_enum_values<::android::hardware::graphics::common::V1_1::PixelFormat> = { - ::android::hardware::graphics::common::V1_1::PixelFormat::RGBA_8888, - ::android::hardware::graphics::common::V1_1::PixelFormat::RGBX_8888, - ::android::hardware::graphics::common::V1_1::PixelFormat::RGB_888, - ::android::hardware::graphics::common::V1_1::PixelFormat::RGB_565, - ::android::hardware::graphics::common::V1_1::PixelFormat::BGRA_8888, - ::android::hardware::graphics::common::V1_1::PixelFormat::YCBCR_422_SP, - ::android::hardware::graphics::common::V1_1::PixelFormat::YCRCB_420_SP, - ::android::hardware::graphics::common::V1_1::PixelFormat::YCBCR_422_I, - ::android::hardware::graphics::common::V1_1::PixelFormat::RGBA_FP16, - ::android::hardware::graphics::common::V1_1::PixelFormat::RAW16, - ::android::hardware::graphics::common::V1_1::PixelFormat::BLOB, - ::android::hardware::graphics::common::V1_1::PixelFormat::IMPLEMENTATION_DEFINED, - ::android::hardware::graphics::common::V1_1::PixelFormat::YCBCR_420_888, - ::android::hardware::graphics::common::V1_1::PixelFormat::RAW_OPAQUE, - ::android::hardware::graphics::common::V1_1::PixelFormat::RAW10, - ::android::hardware::graphics::common::V1_1::PixelFormat::RAW12, - ::android::hardware::graphics::common::V1_1::PixelFormat::RGBA_1010102, - ::android::hardware::graphics::common::V1_1::PixelFormat::Y8, - ::android::hardware::graphics::common::V1_1::PixelFormat::Y16, - ::android::hardware::graphics::common::V1_1::PixelFormat::YV12, - ::android::hardware::graphics::common::V1_1::PixelFormat::DEPTH_16, - ::android::hardware::graphics::common::V1_1::PixelFormat::DEPTH_24, - ::android::hardware::graphics::common::V1_1::PixelFormat::DEPTH_24_STENCIL_8, - ::android::hardware::graphics::common::V1_1::PixelFormat::DEPTH_32F, - ::android::hardware::graphics::common::V1_1::PixelFormat::DEPTH_32F_STENCIL_8, - ::android::hardware::graphics::common::V1_1::PixelFormat::STENCIL_8, - ::android::hardware::graphics::common::V1_1::PixelFormat::YCBCR_P010, -}; -} // namespace details -} // namespace hardware -} // namespace android - -namespace android { -namespace hardware { -namespace details { -template <> -constexpr std::array<::android::hardware::graphics::common::V1_1::BufferUsage, 25> - hidl_enum_values<::android::hardware::graphics::common::V1_1::BufferUsage> = { - ::android::hardware::graphics::common::V1_1::BufferUsage::CPU_READ_MASK, - ::android::hardware::graphics::common::V1_1::BufferUsage::CPU_READ_NEVER, - ::android::hardware::graphics::common::V1_1::BufferUsage::CPU_READ_RARELY, - ::android::hardware::graphics::common::V1_1::BufferUsage::CPU_READ_OFTEN, - ::android::hardware::graphics::common::V1_1::BufferUsage::CPU_WRITE_MASK, - ::android::hardware::graphics::common::V1_1::BufferUsage::CPU_WRITE_NEVER, - ::android::hardware::graphics::common::V1_1::BufferUsage::CPU_WRITE_RARELY, - ::android::hardware::graphics::common::V1_1::BufferUsage::CPU_WRITE_OFTEN, - ::android::hardware::graphics::common::V1_1::BufferUsage::GPU_TEXTURE, - ::android::hardware::graphics::common::V1_1::BufferUsage::GPU_RENDER_TARGET, - ::android::hardware::graphics::common::V1_1::BufferUsage::COMPOSER_OVERLAY, - ::android::hardware::graphics::common::V1_1::BufferUsage::COMPOSER_CLIENT_TARGET, - ::android::hardware::graphics::common::V1_1::BufferUsage::PROTECTED, - ::android::hardware::graphics::common::V1_1::BufferUsage::COMPOSER_CURSOR, - ::android::hardware::graphics::common::V1_1::BufferUsage::VIDEO_ENCODER, - ::android::hardware::graphics::common::V1_1::BufferUsage::CAMERA_OUTPUT, - ::android::hardware::graphics::common::V1_1::BufferUsage::CAMERA_INPUT, - ::android::hardware::graphics::common::V1_1::BufferUsage::RENDERSCRIPT, - ::android::hardware::graphics::common::V1_1::BufferUsage::VIDEO_DECODER, - ::android::hardware::graphics::common::V1_1::BufferUsage::SENSOR_DIRECT_DATA, - ::android::hardware::graphics::common::V1_1::BufferUsage::GPU_DATA_BUFFER, - ::android::hardware::graphics::common::V1_1::BufferUsage::VENDOR_MASK, - ::android::hardware::graphics::common::V1_1::BufferUsage::VENDOR_MASK_HI, - ::android::hardware::graphics::common::V1_1::BufferUsage::GPU_CUBE_MAP, - ::android::hardware::graphics::common::V1_1::BufferUsage::GPU_MIPMAP_COMPLETE, -}; -} // namespace details -} // namespace hardware -} // namespace android - -namespace android { -namespace hardware { -namespace details { -template <> -constexpr std::array<::android::hardware::graphics::common::V1_1::Dataspace, 61> - hidl_enum_values<::android::hardware::graphics::common::V1_1::Dataspace> = { - ::android::hardware::graphics::common::V1_1::Dataspace::UNKNOWN, - ::android::hardware::graphics::common::V1_1::Dataspace::ARBITRARY, - ::android::hardware::graphics::common::V1_1::Dataspace::STANDARD_SHIFT, - ::android::hardware::graphics::common::V1_1::Dataspace::STANDARD_MASK, - ::android::hardware::graphics::common::V1_1::Dataspace::STANDARD_UNSPECIFIED, - ::android::hardware::graphics::common::V1_1::Dataspace::STANDARD_BT709, - ::android::hardware::graphics::common::V1_1::Dataspace::STANDARD_BT601_625, - ::android::hardware::graphics::common::V1_1::Dataspace::STANDARD_BT601_625_UNADJUSTED, - ::android::hardware::graphics::common::V1_1::Dataspace::STANDARD_BT601_525, - ::android::hardware::graphics::common::V1_1::Dataspace::STANDARD_BT601_525_UNADJUSTED, - ::android::hardware::graphics::common::V1_1::Dataspace::STANDARD_BT2020, - ::android::hardware::graphics::common::V1_1::Dataspace::STANDARD_BT2020_CONSTANT_LUMINANCE, - ::android::hardware::graphics::common::V1_1::Dataspace::STANDARD_BT470M, - ::android::hardware::graphics::common::V1_1::Dataspace::STANDARD_FILM, - ::android::hardware::graphics::common::V1_1::Dataspace::STANDARD_DCI_P3, - ::android::hardware::graphics::common::V1_1::Dataspace::STANDARD_ADOBE_RGB, - ::android::hardware::graphics::common::V1_1::Dataspace::TRANSFER_SHIFT, - ::android::hardware::graphics::common::V1_1::Dataspace::TRANSFER_MASK, - ::android::hardware::graphics::common::V1_1::Dataspace::TRANSFER_UNSPECIFIED, - ::android::hardware::graphics::common::V1_1::Dataspace::TRANSFER_LINEAR, - ::android::hardware::graphics::common::V1_1::Dataspace::TRANSFER_SRGB, - ::android::hardware::graphics::common::V1_1::Dataspace::TRANSFER_SMPTE_170M, - ::android::hardware::graphics::common::V1_1::Dataspace::TRANSFER_GAMMA2_2, - ::android::hardware::graphics::common::V1_1::Dataspace::TRANSFER_GAMMA2_6, - ::android::hardware::graphics::common::V1_1::Dataspace::TRANSFER_GAMMA2_8, - ::android::hardware::graphics::common::V1_1::Dataspace::TRANSFER_ST2084, - ::android::hardware::graphics::common::V1_1::Dataspace::TRANSFER_HLG, - ::android::hardware::graphics::common::V1_1::Dataspace::RANGE_SHIFT, - ::android::hardware::graphics::common::V1_1::Dataspace::RANGE_MASK, - ::android::hardware::graphics::common::V1_1::Dataspace::RANGE_UNSPECIFIED, - ::android::hardware::graphics::common::V1_1::Dataspace::RANGE_FULL, - ::android::hardware::graphics::common::V1_1::Dataspace::RANGE_LIMITED, - ::android::hardware::graphics::common::V1_1::Dataspace::RANGE_EXTENDED, - ::android::hardware::graphics::common::V1_1::Dataspace::SRGB_LINEAR, - ::android::hardware::graphics::common::V1_1::Dataspace::V0_SRGB_LINEAR, - ::android::hardware::graphics::common::V1_1::Dataspace::V0_SCRGB_LINEAR, - ::android::hardware::graphics::common::V1_1::Dataspace::SRGB, - ::android::hardware::graphics::common::V1_1::Dataspace::V0_SRGB, - ::android::hardware::graphics::common::V1_1::Dataspace::V0_SCRGB, - ::android::hardware::graphics::common::V1_1::Dataspace::JFIF, - ::android::hardware::graphics::common::V1_1::Dataspace::V0_JFIF, - ::android::hardware::graphics::common::V1_1::Dataspace::BT601_625, - ::android::hardware::graphics::common::V1_1::Dataspace::V0_BT601_625, - ::android::hardware::graphics::common::V1_1::Dataspace::BT601_525, - ::android::hardware::graphics::common::V1_1::Dataspace::V0_BT601_525, - ::android::hardware::graphics::common::V1_1::Dataspace::BT709, - ::android::hardware::graphics::common::V1_1::Dataspace::V0_BT709, - ::android::hardware::graphics::common::V1_1::Dataspace::DCI_P3_LINEAR, - ::android::hardware::graphics::common::V1_1::Dataspace::DCI_P3, - ::android::hardware::graphics::common::V1_1::Dataspace::DISPLAY_P3_LINEAR, - ::android::hardware::graphics::common::V1_1::Dataspace::DISPLAY_P3, - ::android::hardware::graphics::common::V1_1::Dataspace::ADOBE_RGB, - ::android::hardware::graphics::common::V1_1::Dataspace::BT2020_LINEAR, - ::android::hardware::graphics::common::V1_1::Dataspace::BT2020, - ::android::hardware::graphics::common::V1_1::Dataspace::BT2020_PQ, - ::android::hardware::graphics::common::V1_1::Dataspace::DEPTH, - ::android::hardware::graphics::common::V1_1::Dataspace::SENSOR, - ::android::hardware::graphics::common::V1_1::Dataspace::BT2020_ITU, - ::android::hardware::graphics::common::V1_1::Dataspace::BT2020_ITU_PQ, - ::android::hardware::graphics::common::V1_1::Dataspace::BT2020_ITU_HLG, - ::android::hardware::graphics::common::V1_1::Dataspace::BT2020_HLG, -}; -} // namespace details -} // namespace hardware -} // namespace android - -namespace android { -namespace hardware { -namespace details { -template <> -constexpr std::array<::android::hardware::graphics::common::V1_1::ColorMode, 13> - hidl_enum_values<::android::hardware::graphics::common::V1_1::ColorMode> = { - ::android::hardware::graphics::common::V1_1::ColorMode::NATIVE, - ::android::hardware::graphics::common::V1_1::ColorMode::STANDARD_BT601_625, - ::android::hardware::graphics::common::V1_1::ColorMode::STANDARD_BT601_625_UNADJUSTED, - ::android::hardware::graphics::common::V1_1::ColorMode::STANDARD_BT601_525, - ::android::hardware::graphics::common::V1_1::ColorMode::STANDARD_BT601_525_UNADJUSTED, - ::android::hardware::graphics::common::V1_1::ColorMode::STANDARD_BT709, - ::android::hardware::graphics::common::V1_1::ColorMode::DCI_P3, - ::android::hardware::graphics::common::V1_1::ColorMode::SRGB, - ::android::hardware::graphics::common::V1_1::ColorMode::ADOBE_RGB, - ::android::hardware::graphics::common::V1_1::ColorMode::DISPLAY_P3, - ::android::hardware::graphics::common::V1_1::ColorMode::BT2020, - ::android::hardware::graphics::common::V1_1::ColorMode::BT2100_PQ, - ::android::hardware::graphics::common::V1_1::ColorMode::BT2100_HLG, -}; -} // namespace details -} // namespace hardware -} // namespace android - -namespace android { -namespace hardware { -namespace details { -template <> -constexpr std::array<::android::hardware::graphics::common::V1_1::RenderIntent, 4> - hidl_enum_values<::android::hardware::graphics::common::V1_1::RenderIntent> = { - ::android::hardware::graphics::common::V1_1::RenderIntent::COLORIMETRIC, - ::android::hardware::graphics::common::V1_1::RenderIntent::ENHANCE, - ::android::hardware::graphics::common::V1_1::RenderIntent::TONE_MAP_COLORIMETRIC, - ::android::hardware::graphics::common::V1_1::RenderIntent::TONE_MAP_ENHANCE, -}; -} // namespace details -} // namespace hardware -} // namespace android - -#endif // HIDL_GENERATED_ANDROID_HARDWARE_GRAPHICS_COMMON_V1_1_TYPES_H diff --git a/externals/libadrenotools/tools/qtimapper-shim/ext/types/mapper.h b/externals/libadrenotools/tools/qtimapper-shim/ext/types/mapper.h deleted file mode 100644 index ce126427de..0000000000 --- a/externals/libadrenotools/tools/qtimapper-shim/ext/types/mapper.h +++ /dev/null @@ -1,250 +0,0 @@ -#ifndef HIDL_GENERATED_ANDROID_HARDWARE_GRAPHICS_MAPPER_V2_0_TYPES_H -#define HIDL_GENERATED_ANDROID_HARDWARE_GRAPHICS_MAPPER_V2_0_TYPES_H - -#include -#include -#include -#include - -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 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 -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(static_cast(lhs) | static_cast(rhs)); -} -constexpr int32_t operator|(const int32_t lhs, - const ::android::hardware::graphics::mapper::V2_0::Error rhs) { - return static_cast(lhs | static_cast(rhs)); -} -constexpr int32_t operator|(const ::android::hardware::graphics::mapper::V2_0::Error lhs, - const int32_t rhs) { - return static_cast(static_cast(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(static_cast(lhs) & static_cast(rhs)); -} -constexpr int32_t operator&(const int32_t lhs, - const ::android::hardware::graphics::mapper::V2_0::Error rhs) { - return static_cast(lhs & static_cast(rhs)); -} -constexpr int32_t operator&(const ::android::hardware::graphics::mapper::V2_0::Error lhs, - const int32_t rhs) { - return static_cast(static_cast(lhs) & rhs); -} -constexpr int32_t& operator|=(int32_t& v, - const ::android::hardware::graphics::mapper::V2_0::Error e) { - v |= static_cast(e); - return v; -} -constexpr int32_t& operator&=(int32_t& v, - const ::android::hardware::graphics::mapper::V2_0::Error e) { - v &= static_cast(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(::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(::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(::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(::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(::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(::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(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 diff --git a/externals/libadrenotools/tools/qtimapper-shim/ext/types/mapperextensions.h b/externals/libadrenotools/tools/qtimapper-shim/ext/types/mapperextensions.h deleted file mode 100644 index 79fddd18e4..0000000000 --- a/externals/libadrenotools/tools/qtimapper-shim/ext/types/mapperextensions.h +++ /dev/null @@ -1,707 +0,0 @@ -#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 -#include -#include -#include - -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 -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(static_cast(lhs) | static_cast(rhs)); -} -constexpr int32_t operator|( - const int32_t lhs, const ::vendor::qti::hardware::display::mapperextensions::V1_0::Error rhs) { - return static_cast(lhs | static_cast(rhs)); -} -constexpr int32_t operator|( - const ::vendor::qti::hardware::display::mapperextensions::V1_0::Error lhs, const int32_t rhs) { - return static_cast(static_cast(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(static_cast(lhs) & static_cast(rhs)); -} -constexpr int32_t operator&( - const int32_t lhs, const ::vendor::qti::hardware::display::mapperextensions::V1_0::Error rhs) { - return static_cast(lhs & static_cast(rhs)); -} -constexpr int32_t operator&( - const ::vendor::qti::hardware::display::mapperextensions::V1_0::Error lhs, const int32_t rhs) { - return static_cast(static_cast(lhs) & rhs); -} -constexpr int32_t& operator|=( - int32_t& v, const ::vendor::qti::hardware::display::mapperextensions::V1_0::Error e) { - v |= static_cast(e); - return v; -} -constexpr int32_t& operator&=( - int32_t& v, const ::vendor::qti::hardware::display::mapperextensions::V1_0::Error e) { - v &= static_cast(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 -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(static_cast(lhs) | static_cast(rhs)); -} -constexpr uint32_t operator|( - const uint32_t lhs, - const ::vendor::qti::hardware::display::mapperextensions::V1_0::PlaneComponent rhs) { - return static_cast(lhs | static_cast(rhs)); -} -constexpr uint32_t operator|( - const ::vendor::qti::hardware::display::mapperextensions::V1_0::PlaneComponent lhs, - const uint32_t rhs) { - return static_cast(static_cast(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(static_cast(lhs) & static_cast(rhs)); -} -constexpr uint32_t operator&( - const uint32_t lhs, - const ::vendor::qti::hardware::display::mapperextensions::V1_0::PlaneComponent rhs) { - return static_cast(lhs & static_cast(rhs)); -} -constexpr uint32_t operator&( - const ::vendor::qti::hardware::display::mapperextensions::V1_0::PlaneComponent lhs, - const uint32_t rhs) { - return static_cast(static_cast(lhs) & rhs); -} -constexpr uint32_t& operator|=( - uint32_t& v, const ::vendor::qti::hardware::display::mapperextensions::V1_0::PlaneComponent e) { - v |= static_cast(e); - return v; -} -constexpr uint32_t& operator&=( - uint32_t& v, const ::vendor::qti::hardware::display::mapperextensions::V1_0::PlaneComponent e) { - v &= static_cast(e); - return v; -} - -template -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(static_cast(lhs) | static_cast(rhs)); -} -constexpr int32_t operator|( - const int32_t lhs, const ::vendor::qti::hardware::display::mapperextensions::V1_0::Flags rhs) { - return static_cast(lhs | static_cast(rhs)); -} -constexpr int32_t operator|( - const ::vendor::qti::hardware::display::mapperextensions::V1_0::Flags lhs, const int32_t rhs) { - return static_cast(static_cast(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(static_cast(lhs) & static_cast(rhs)); -} -constexpr int32_t operator&( - const int32_t lhs, const ::vendor::qti::hardware::display::mapperextensions::V1_0::Flags rhs) { - return static_cast(lhs & static_cast(rhs)); -} -constexpr int32_t operator&( - const ::vendor::qti::hardware::display::mapperextensions::V1_0::Flags lhs, const int32_t rhs) { - return static_cast(static_cast(lhs) & rhs); -} -constexpr int32_t& operator|=( - int32_t& v, const ::vendor::qti::hardware::display::mapperextensions::V1_0::Flags e) { - v |= static_cast(e); - return v; -} -constexpr int32_t& operator&=( - int32_t& v, const ::vendor::qti::hardware::display::mapperextensions::V1_0::Flags e) { - v &= static_cast(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(::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( - ::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( - ::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( - ::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(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(::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(::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(::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(::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(::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(::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(::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(::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(::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(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(::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(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 diff --git a/externals/libadrenotools/tools/qtimapper-shim/shim.cpp b/externals/libadrenotools/tools/qtimapper-shim/shim.cpp deleted file mode 100644 index 34dd68296c..0000000000 --- a/externals/libadrenotools/tools/qtimapper-shim/shim.cpp +++ /dev/null @@ -1,472 +0,0 @@ -/* - * 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 -#include -#include -#include -#include -#include -#include -#include - -#include "ext/common.h" -#include "ext/gr_utils.h" -#include "ext/mapper.h" -#include "ext/mapperextensions.h" - -using namespace android::hardware; -using namespace android; - -// These two functions are used by the blob and aren't present on Q so weakly stub them -extern "C" uint64_t __attribute__((weak)) atrace_get_enabled_tags() { - return 0; -} - -namespace android::hardware::details { -void __attribute__((weak)) return_status::onValueRetrieval() const {} -} // namespace android::hardware::details - -bool IBase::isRemote() const { - return false; -} - -sp (*Mapper20GetService)(const std::string&, const bool); -sp (*Mapper30GetService)(const std::string&, const bool); -sp (*Mapper40GetService)(const std::string&, const bool); - -Return> (*QtiMapper20CastFrom)( - const sp&, bool); -Return> (*QtiMapper30CastFrom)( - const sp&, bool); -Return> (*QtiMapper40CastFrom)( - const sp&, bool); - -Return> ( - *MapperExtensions11CastFrom)( - const sp&, bool); - -__attribute__((constructor)) static void initShim() { - void* qtiMapper40Hnd = - dlopen("vendor.qti.hardware.display.mapper@4.0.so", RTLD_LAZY | RTLD_LOCAL); - if (qtiMapper40Hnd) { - void* mapper40Hnd = dlopen("android.hardware.graphics.mapper@4.0.so", RTLD_LAZY | RTLD_LOCAL); - if (mapper40Hnd) { - Mapper40GetService = reinterpret_cast( - dlsym(mapper40Hnd, - "_ZN7android8hardware8graphics6mapper4V4_07IMapper10getServiceERKNSt3__112basic_" - "stringIcNS5_11char_traitsIcEENS5_9allocatorIcEEEEb")); - QtiMapper40CastFrom = reinterpret_cast(dlsym( - qtiMapper40Hnd, - "_ZN6vendor3qti8hardware7display6mapper4V4_010IQtiMapper8castFromERKN7android2spINS6_" - "8hardware8graphics6mapper4V4_07IMapperEEEb")); - - ALOGD("%s: Mapper 4.0 present", __func__); - } - } - - void* qtiMapper30Hnd = - dlopen("vendor.qti.hardware.display.mapper@3.0.so", RTLD_LAZY | RTLD_LOCAL); - if (qtiMapper30Hnd) { - void* mapper30Hnd = dlopen("android.hardware.graphics.mapper@3.0.so", RTLD_LAZY | RTLD_LOCAL); - if (mapper30Hnd) { - Mapper30GetService = reinterpret_cast( - dlsym(mapper30Hnd, - "_ZN7android8hardware8graphics6mapper4V3_07IMapper10getServiceERKNSt3__112basic_" - "stringIcNS5_11char_traitsIcEENS5_9allocatorIcEEEEb")); - QtiMapper30CastFrom = reinterpret_cast(dlsym( - qtiMapper30Hnd, - "_ZN6vendor3qti8hardware7display6mapper4V3_010IQtiMapper8castFromERKN7android2spINS6_" - "8hardware8graphics6mapper4V3_07IMapperEEEb")); - ALOGD("%s: Mapper 3.0 present", __func__); - } - } - - void* qtiMapper20Hnd = - dlopen("vendor.qti.hardware.display.mapper@2.0.so", RTLD_LAZY | RTLD_LOCAL); - if (qtiMapper20Hnd) { - void* mapper20Hnd = dlopen("android.hardware.graphics.mapper@2.0.so", RTLD_LAZY | RTLD_LOCAL); - if (mapper20Hnd) { - Mapper20GetService = reinterpret_cast( - dlsym(mapper20Hnd, - "_ZN7android8hardware8graphics6mapper4V2_07IMapper10getServiceERKNSt3__112basic_" - "stringIcNS5_11char_traitsIcEENS5_9allocatorIcEEEEb")); - QtiMapper20CastFrom = reinterpret_cast(dlsym( - qtiMapper20Hnd, - "_ZN6vendor3qti8hardware7display6mapper4V2_010IQtiMapper8castFromERKN7android2spINS6_" - "8hardware8graphics6mapper4V2_07IMapperEEEb")); - ALOGD("%s: Mapper 2.0 present", __func__); - } - } - - void* mapperExtensions11Hnd = - dlopen("vendor.qti.hardware.display.mapperextensions@1.1.so", RTLD_LAZY | RTLD_LOCAL); - if (mapperExtensions11Hnd) { - MapperExtensions11CastFrom = reinterpret_cast(dlsym( - mapperExtensions11Hnd, - "_ZN6vendor3qti8hardware7display16mapperextensions4V1_" - "120IQtiMapperExtensions8castFromERKN7android2spINS3_4V1_020IQtiMapperExtensionsEEEb")); - ALOGD("%s: Mapper Extensions 1.1 present", __func__); - } -} - -namespace android::hardware::graphics::mapper { -namespace V2_0 { - -sp IMapper::getService(const std::string& serviceName, const bool getStub) { - if (Mapper20GetService) return Mapper20GetService(serviceName, getStub); - return nullptr; -} - -} // namespace V2_0 -namespace V3_0 { - -sp IMapper::getService(const std::string& serviceName, const bool getStub) { - if (Mapper30GetService) return Mapper30GetService(serviceName, getStub); - return nullptr; -} - -} // namespace V3_0 -namespace V4_0 { - -sp IMapper::getService(const std::string& serviceName, const bool getStub) { - if (Mapper40GetService) return Mapper40GetService(serviceName, getStub); - return nullptr; -} - -} // namespace V4_0 -} // namespace android::hardware::graphics::mapper -namespace vendor::qti::hardware::display { -namespace mapper { -namespace V4_0 { - -Return> IQtiMapper::castFrom(const sp& parent, - bool emitError) { - if (QtiMapper40CastFrom) return QtiMapper40CastFrom(parent, emitError); - return nullptr; -} - -} // namespace V4_0 -namespace V3_0 { - -Return> IQtiMapper::castFrom(const sp& parent, - bool emitError) { - if (QtiMapper30CastFrom) return QtiMapper30CastFrom(parent, emitError); - return nullptr; -} - -} // namespace V3_0 -namespace V2_0 { - -Return> IQtiMapper::castFrom(const sp& parent, - bool emitError) { - if (QtiMapper20CastFrom) return QtiMapper20CastFrom(parent, emitError); - - return new IQtiMapper(); -} - -Return IQtiMapper::getMapperExtensions(getMapperExtensions_cb _hidl_cb) { - sp ext{ - new mapperextensions::V1_0::IQtiMapperExtensions()}; - _hidl_cb(graphics::mapper::V2_0::Error::NONE, ext); - return Void(); -} - -} // namespace V2_0 -} // namespace mapper -namespace mapperextensions { -namespace V1_1 { - -IQtiMapperExtensions::IQtiMapperExtensions() { - ALOGI("IQtiMapperExtensions shim active"); - - 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( - gralloc->getFunction(gralloc, GRALLOC1_FUNCTION_PERFORM)); - if (!perform) { - ALOGE("Failed to get gralloc perform helper!"); - std::terminate(); - } - - ALOGD("Opened gralloc1 HAL"); -} - -Return> IQtiMapperExtensions::castFrom( - android::sp const& parent, bool emitError) { - if (MapperExtensions11CastFrom) return MapperExtensions11CastFrom(parent, emitError); - return new IQtiMapperExtensions(); -} - -Return 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) - ? Error::BAD_BUFFER - : Error::NONE; - _hidl_cb(err, rgb_data); - - ALOGV("%s: err: %d rgb_data: %p", __func__, err, rgb_data); - return Void(); -} - -Return IQtiMapperExtensions::getInterlacedFlag(void* buffer, getInterlacedFlag_cb _hidl_cb) { - int flag = 0; - auto perform = reinterpret_cast( - gralloc->getFunction(gralloc, GRALLOC1_FUNCTION_PERFORM)); - auto err = perform(gralloc, GRALLOC1_MODULE_PERFORM_GET_INTERLACE_FLAG, buffer, &flag) - ? Error::BAD_BUFFER - : Error::NONE; - _hidl_cb(err, flag); - ALOGV("%s: err: %d flag: %d", __func__, err, flag); - return Void(); -} -Return IQtiMapperExtensions::getFd(void* buffer, getFd_cb hidl_cb) { - auto err = Error::BAD_BUFFER; - int fd = 0; - auto hnd = static_cast(buffer); - if (buffer != nullptr && private_handle_t::validate(hnd) == 0) { - err = Error::NONE; - fd = hnd->fd; - } - hidl_cb(err, fd); - ALOGV("%s: fd: %d", __func__, fd); - return Void(); -} - -Return IQtiMapperExtensions::getWidth(void* buffer, getWidth_cb hidl_cb) { - auto err = Error::BAD_BUFFER; - int width = 0; - auto hnd = static_cast(buffer); - if (buffer != nullptr && private_handle_t::validate(hnd) == 0) { - err = Error::NONE; - width = hnd->width; - } - hidl_cb(err, width); - ALOGV("%s: width: %d", __func__, width); - return Void(); -} - -Return IQtiMapperExtensions::getHeight(void* buffer, getHeight_cb hidl_cb) { - auto err = Error::BAD_BUFFER; - int height = 0; - auto hnd = static_cast(buffer); - if (buffer != nullptr && private_handle_t::validate(hnd) == 0) { - err = Error::NONE; - height = hnd->height; - } - hidl_cb(err, height); - ALOGV("%s: height: %d", __func__, height); - return Void(); -} - -Return IQtiMapperExtensions::getFormat(void* buffer, getFormat_cb hidl_cb) { - auto err = Error::BAD_BUFFER; - int format = 0; - auto hnd = static_cast(buffer); - if (buffer != nullptr && private_handle_t::validate(hnd) == 0) { - err = Error::NONE; - format = hnd->format; - } - hidl_cb(err, format); - - ALOGV("%s: format: %d", __func__, format); - return Void(); -} - -Return IQtiMapperExtensions::getPrivateFlags(void* buffer, getPrivateFlags_cb hidl_cb) { - auto err = Error::BAD_BUFFER; - int flags = 0; - auto hnd = static_cast(buffer); - if (buffer != nullptr && private_handle_t::validate(hnd) == 0) { - err = Error::NONE; - flags = hnd->flags; - } - hidl_cb(err, flags); - ALOGV("%s: flags: %d", __func__, flags); - return Void(); -} - -Return IQtiMapperExtensions::getUnalignedWidth(void* buffer, getUnalignedWidth_cb hidl_cb) { - auto err = Error::BAD_BUFFER; - int unaligned_width = 0; - auto hnd = static_cast(buffer); - if (buffer != nullptr && private_handle_t::validate(hnd) == 0) { - err = Error::NONE; - unaligned_width = hnd->unaligned_width; - } - hidl_cb(err, unaligned_width); - - ALOGV("%s: unaligned_width: %u", __func__, unaligned_width); - return Void(); -} - -Return IQtiMapperExtensions::getUnalignedHeight(void* buffer, getUnalignedHeight_cb hidl_cb) { - auto err = Error::BAD_BUFFER; - int unaligned_height = 0; - auto hnd = static_cast(buffer); - if (buffer != nullptr && private_handle_t::validate(hnd) == 0) { - err = Error::NONE; - unaligned_height = hnd->unaligned_height; - } - hidl_cb(err, unaligned_height); - ALOGV("%s: unaligned_height: %u", __func__, unaligned_height); - return Void(); -} - -Return IQtiMapperExtensions::getLayerCount(void* buffer, getLayerCount_cb hidl_cb) { - auto err = Error::BAD_BUFFER; - unsigned int layer_count = 0; - auto hnd = static_cast(buffer); - if (buffer != nullptr && private_handle_t::validate(hnd) == 0) { - err = Error::NONE; - layer_count = hnd->layer_count; - } - hidl_cb(err, layer_count); - ALOGV("%s: layer_count: %u", __func__, layer_count); - return Void(); -} - -Return IQtiMapperExtensions::getId(void* buffer, getId_cb hidl_cb) { - auto err = Error::BAD_BUFFER; - uint64_t id = 0; - auto hnd = static_cast(buffer); - if (buffer != nullptr && private_handle_t::validate(hnd) == 0) { - err = Error::NONE; - id = hnd->id; - } - hidl_cb(err, id); - ALOGV("%s: id: %" PRIu64, __func__, id); - return Void(); -} - -Return IQtiMapperExtensions::getUsageFlags(void* buffer, getUsageFlags_cb hidl_cb) { - auto err = Error::BAD_BUFFER; - uint64_t usage = 0; - auto hnd = static_cast(buffer); - if (buffer != nullptr && private_handle_t::validate(hnd) == 0) { - err = Error::NONE; - usage = hnd->usage; - } - hidl_cb(err, usage); - ALOGV("%s: usage: %" PRIu64, __func__, usage); - - return Void(); -} - -Return IQtiMapperExtensions::getSize(void* buffer, getSize_cb hidl_cb) { - auto err = Error::BAD_BUFFER; - unsigned int size = 0; - auto hnd = static_cast(buffer); - if (buffer != nullptr && private_handle_t::validate(hnd) == 0) { - err = Error::NONE; - size = hnd->size; - } - hidl_cb(err, size); - ALOGV("%s: size: %u", __func__, size); - return Void(); -} - -Return IQtiMapperExtensions::getOffset(void* buffer, getOffset_cb hidl_cb) { - auto err = Error::BAD_BUFFER; - unsigned int offset = 0; - auto hnd = static_cast(buffer); - if (buffer != nullptr && private_handle_t::validate(hnd) == 0) { - err = Error::NONE; - offset = hnd->offset; - } - hidl_cb(err, offset); - ALOGV("%s: offset: %u", __func__, offset); - return Void(); -} - -Return IQtiMapperExtensions::getFormatLayout(int32_t format, uint64_t usage, int32_t flags, - int32_t width, int32_t height, - getFormatLayout_cb _hidl_cb) { - hidl_vec plane_info; - unsigned int alignedw = 0, alignedh = 0, tile_enabled = 0; - int plane_count = 0; - uint64_t size = 0; - int custom_format = gralloc::GetImplDefinedFormat(usage, format); - gralloc::BufferInfo info(width, height, custom_format, usage); - - auto err = perform(gralloc, GRALLOC_MODULE_PERFORM_GET_ATTRIBUTES, width, height, custom_format, - usage, usage, &alignedw, &alignedh, &tile_enabled) - ? Error::BAD_BUFFER - : Error::NONE; - if (err != Error::NONE) { - _hidl_cb(err, 0, plane_info); - return Void(); - } - - size = gralloc::GetSize(info, alignedw, alignedh); - gralloc::PlaneLayoutInfo plane_layout[8] = {}; - - if (gralloc::IsUncompressedRGBFormat(custom_format) || - gralloc::IsCompressedRGBFormat(custom_format)) { - gralloc::GetRGBPlaneInfo(info, custom_format, alignedw, alignedh, flags, &plane_count, - plane_layout); - } else { - ALOGE("%s: unsupported format %d", __func__, format); - err = Error::BAD_BUFFER; - _hidl_cb(err, size, plane_info); - return Void(); - } - - plane_info.resize(plane_count); - for (int i = 0; i < plane_count; i++) { - plane_info[i].component = plane_layout[i].component; - plane_info[i].h_subsampling = plane_layout[i].h_subsampling; - plane_info[i].v_subsampling = plane_layout[i].v_subsampling; - plane_info[i].offset = plane_layout[i].offset; - plane_info[i].pixel_increment = plane_layout[i].step; - plane_info[i].stride = plane_layout[i].stride; - plane_info[i].stride_bytes = plane_layout[i].stride_bytes; - plane_info[i].scanlines = plane_layout[i].scanlines; - plane_info[i].size = plane_layout[i].size; - } - - _hidl_cb(err, size, plane_info); - return Void(); -} - -} // namespace V1_1 -} // namespace mapperextensions -} // namespace vendor::qti::hardware::display