drm_hwcomposer: Create make target to test filegroups
Android.bp contains filegroups that are not built by default (e.g. using $ mmma external/drm_hwcomposer) Fix it. To ensure build will work on wide range of Android versions, pull depended headers from AOSP-11 tree: 1. Mali: "device/linaro/hikey/gralloc960" 2. Imagination: "hardware/ti/am57x/libhwcomposer" and put it into ./tests/test_include directory. Signed-off-by: Roman Stratiienko <r.stratiienko@gmail.com>
This commit is contained in:
parent
fa0023394b
commit
e398334e97
9 changed files with 1115 additions and 0 deletions
|
|
@ -1,4 +1,23 @@
|
|||
cc_library_shared {
|
||||
name: "hwcomposer.filegroups_build_test",
|
||||
defaults: ["hwcomposer.drm_defaults"],
|
||||
whole_static_libs: ["drm_hwcomposer"],
|
||||
|
||||
srcs: [
|
||||
":drm_hwcomposer_platformhisi",
|
||||
":drm_hwcomposer_platformimagination",
|
||||
":drm_hwcomposer_platformmediatek",
|
||||
":drm_hwcomposer_platformmeson",
|
||||
],
|
||||
|
||||
local_include_dirs: [
|
||||
"test_include",
|
||||
],
|
||||
|
||||
cppflags: [
|
||||
"-DDISABLE_LEGACY_GETTERS",
|
||||
],
|
||||
}
|
||||
|
||||
cc_test {
|
||||
name: "hwc-drm-tests",
|
||||
|
|
|
|||
53
tests/test_include/gralloc_helper.h
Normal file
53
tests/test_include/gralloc_helper.h
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
// clang-format off
|
||||
/*
|
||||
* Copyright (C) 2010-2017 ARM Limited. All rights reserved.
|
||||
*
|
||||
* 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_HELPER_H_
|
||||
#define GRALLOC_HELPER_H_
|
||||
|
||||
#include <sys/mman.h>
|
||||
#include <android/log.h>
|
||||
|
||||
#ifndef AWAR
|
||||
#define AWAR(fmt, args...) \
|
||||
__android_log_print(ANDROID_LOG_WARN, "[Gralloc-Warning]", "%s:%d " fmt, __func__, __LINE__, ##args)
|
||||
#endif
|
||||
#ifndef AINF
|
||||
#define AINF(fmt, args...) __android_log_print(ANDROID_LOG_INFO, "[Gralloc]", fmt, ##args)
|
||||
#endif
|
||||
#ifndef AERR
|
||||
#define AERR(fmt, args...) \
|
||||
__android_log_print(ANDROID_LOG_ERROR, "[Gralloc-ERROR]", "%s:%d " fmt, __func__, __LINE__, ##args)
|
||||
#endif
|
||||
#ifndef AERR_IF
|
||||
#define AERR_IF(eq, fmt, args...) \
|
||||
if ((eq)) \
|
||||
AERR(fmt, args)
|
||||
#endif
|
||||
|
||||
#define GRALLOC_ALIGN(value, base) (((value) + ((base)-1)) & ~((base)-1))
|
||||
|
||||
#define GRALLOC_UNUSED(x) ((void)x)
|
||||
|
||||
static inline size_t round_up_to_page_size(size_t x)
|
||||
{
|
||||
return (x + (PAGE_SIZE - 1)) & ~(PAGE_SIZE - 1);
|
||||
}
|
||||
|
||||
#endif /* GRALLOC_HELPER_H_ */
|
||||
// clang-format on
|
||||
69
tests/test_include/gralloc_priv.h
Normal file
69
tests/test_include/gralloc_priv.h
Normal file
|
|
@ -0,0 +1,69 @@
|
|||
// clang-format off
|
||||
/*
|
||||
* Copyright (C) 2017 ARM Limited. All rights reserved.
|
||||
*
|
||||
* 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 <stdint.h>
|
||||
#include <pthread.h>
|
||||
#include <errno.h>
|
||||
#include <linux/fb.h>
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/mman.h>
|
||||
#include <cutils/native_handle.h>
|
||||
#include <utils/Log.h>
|
||||
|
||||
#if GRALLOC_USE_GRALLOC1_API
|
||||
#include <hardware/gralloc1.h>
|
||||
#else
|
||||
#include <hardware/gralloc.h>
|
||||
#endif
|
||||
/**
|
||||
* mali_gralloc_formats.h needs the define for GRALLOC_MODULE_API_VERSION_0_3 and
|
||||
* GRALLOC_MODULE_API_VERSION_1_0, so include <gralloc1.h> or <gralloc.h> before
|
||||
* including mali_gralloc_formats.h
|
||||
**/
|
||||
#include "mali_gralloc_formats.h"
|
||||
#include "mali_gralloc_usages.h"
|
||||
#include "gralloc_helper.h"
|
||||
|
||||
#if defined(GRALLOC_MODULE_API_VERSION_0_3) || \
|
||||
(defined(GRALLOC_MODULE_API_VERSION_1_0) && !defined(GRALLOC_DISABLE_PRIVATE_BUFFER_DEF))
|
||||
|
||||
/*
|
||||
* This header file contains the private buffer definition. For gralloc 0.3 it will
|
||||
* always be exposed, but for gralloc 1.0 it will be removed at some point in the future.
|
||||
*
|
||||
* GRALLOC_DISABLE_PRIVATE_BUFFER_DEF is intended for DDKs to test while implementing
|
||||
* the new private API.
|
||||
*/
|
||||
#include "mali_gralloc_buffer.h"
|
||||
#endif
|
||||
|
||||
#if defined(GRALLOC_MODULE_API_VERSION_1_0)
|
||||
|
||||
/* gralloc 1.0 supports the new private interface that abstracts
|
||||
* the private buffer definition to a set of defined APIs.
|
||||
*/
|
||||
#include "mali_gralloc_private_interface.h"
|
||||
#endif
|
||||
|
||||
#endif /* GRALLOC_PRIV_H_ */
|
||||
// clang-format on
|
||||
247
tests/test_include/img_gralloc1_public.h
Normal file
247
tests/test_include/img_gralloc1_public.h
Normal file
|
|
@ -0,0 +1,247 @@
|
|||
// clang-format off
|
||||
/* Copyright (c) Imagination Technologies Ltd.
|
||||
*
|
||||
* The contents of this file are subject to the MIT license as set out below.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef HAL_PUBLIC_H
|
||||
#define HAL_PUBLIC_H
|
||||
|
||||
/* Authors of third party hardware composer (HWC) modules will need to include
|
||||
* this header to access functionality in the gralloc and framebuffer HALs.
|
||||
*/
|
||||
|
||||
#include <hardware/gralloc.h>
|
||||
#include <hardware/memtrack.h>
|
||||
|
||||
#define ALIGN(x,a) (((x) + (a) - 1L) & ~((a) - 1L))
|
||||
#define HW_ALIGN 16
|
||||
|
||||
/* This can be tuned down as appropriate for the SOC.
|
||||
*
|
||||
* IMG formats are usually a single sub-alloc.
|
||||
* Some OEM video formats are two sub-allocs (Y, UV planes).
|
||||
* Future OEM video formats might be three sub-allocs (Y, U, V planes).
|
||||
*/
|
||||
#define MAX_SUB_ALLOCS 3
|
||||
|
||||
/* Format is not YCbCr (e.g. a RGB format) - bIsYUVFormat should be false */
|
||||
#define YUV_CHROMA_ORDER_NONE 0
|
||||
/* Cb follows Y */
|
||||
#define YUV_CHROMA_ORDER_CBCR_UV 1
|
||||
/* Cr follows Y */
|
||||
#define YUV_CHROMA_ORDER_CRCB_VU 2
|
||||
|
||||
typedef struct
|
||||
{
|
||||
native_handle_t base;
|
||||
|
||||
/* These fields can be sent cross process. They are also valid
|
||||
* to duplicate within the same process.
|
||||
*
|
||||
* A table is stored within psPrivateData on gralloc_module_t (this
|
||||
* is obviously per-process) which maps stamps to a mapped
|
||||
* PVRSRV_CLIENT_MEM_INFO in that process. Each map entry has a lock
|
||||
* count associated with it, satisfying the requirements of the
|
||||
* Android API. This also prevents us from leaking maps/allocations.
|
||||
*
|
||||
* This table has entries inserted either by alloc()
|
||||
* (alloc_device_t) or map() (gralloc_module_t). Entries are removed
|
||||
* by free() (alloc_device_t) and unmap() (gralloc_module_t).
|
||||
*
|
||||
* As a special case for framebuffer_device_t, framebuffer_open()
|
||||
* will add and framebuffer_close() will remove from this table.
|
||||
*/
|
||||
|
||||
#define IMG_NATIVE_HANDLE_NUMFDS MAX_SUB_ALLOCS
|
||||
/* The `fd' field is used to "export" a meminfo to another process.
|
||||
* Therefore, it is allocated by alloc_device_t, and consumed by
|
||||
* gralloc_module_t. The framebuffer_device_t does not need a handle,
|
||||
* and the special value IMG_FRAMEBUFFER_FD is used instead.
|
||||
*/
|
||||
int fd[MAX_SUB_ALLOCS];
|
||||
|
||||
#define IMG_NATIVE_HANDLE_NUMINTS \
|
||||
((sizeof(unsigned long long) / sizeof(int)) + 5 + MAX_SUB_ALLOCS + 1 + MAX_SUB_ALLOCS + MAX_SUB_ALLOCS)
|
||||
/* A KERNEL unique identifier for any exported kernel meminfo. Each
|
||||
* exported kernel meminfo will have a unique stamp, but note that in
|
||||
* userspace, several meminfos across multiple processes could have
|
||||
* the same stamp. As the native_handle can be dup(2)'d, there could be
|
||||
* multiple handles with the same stamp but different file descriptors.
|
||||
*/
|
||||
unsigned long long ui64Stamp;
|
||||
|
||||
/* This is used for buffer usage validation when locking a buffer,
|
||||
* and also in WSEGL (for the composition bypass feature).
|
||||
*/
|
||||
int usage;
|
||||
|
||||
/* In order to do efficient cache flushes we need the buffer dimensions
|
||||
* and format. These are available on the ANativeWindowBuffer,
|
||||
* but the platform doesn't pass them down to the graphics HAL.
|
||||
*/
|
||||
int iWidth;
|
||||
int iHeight;
|
||||
int iFormat;
|
||||
unsigned int uiBpp;
|
||||
|
||||
/* The ion allocation path doesn't allow for the allocation size and
|
||||
* mapping flags to be communicated cross-process automatically.
|
||||
* Cache these here so we can map buffers in client processes.
|
||||
*/
|
||||
unsigned int uiAllocSize[MAX_SUB_ALLOCS];
|
||||
unsigned int uiFlags;
|
||||
/* For multi-planar allocations, there will be multiple hstrides */
|
||||
int aiStride[MAX_SUB_ALLOCS];
|
||||
|
||||
/* For multi-planar allocations, there will be multiple vstrides */
|
||||
int aiVStride[MAX_SUB_ALLOCS];
|
||||
|
||||
}
|
||||
__attribute__((aligned(sizeof(int)),packed)) IMG_native_handle_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int l, t, w, h;
|
||||
}
|
||||
IMG_write_lock_rect_t;
|
||||
|
||||
typedef int (*IMG_buffer_format_compute_params_pfn)(
|
||||
unsigned int uiPlane, int *piWidth, int *piHeight,
|
||||
int *piStride, int *piVStride, unsigned long *pulPlaneOffset);
|
||||
|
||||
typedef struct IMG_buffer_format_public_t
|
||||
{
|
||||
/* Buffer formats are returned as a linked list */
|
||||
struct IMG_buffer_format_public_t *psNext;
|
||||
|
||||
/* HAL_PIXEL_FORMAT_... enumerant */
|
||||
int iHalPixelFormat;
|
||||
|
||||
/* WSEGL_PIXELFORMAT_... enumerant */
|
||||
int iWSEGLPixelFormat;
|
||||
|
||||
/* Friendly name for format */
|
||||
const char *const szName;
|
||||
|
||||
/* Bits (not bytes) per pixel */
|
||||
unsigned int uiBpp;
|
||||
|
||||
/* Supported HW usage bits. If this is GRALLOC_USAGE_HW_MASK, all usages
|
||||
* are supported. Used for HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED.
|
||||
*/
|
||||
int iSupportedUsage;
|
||||
|
||||
/* YUV output format */
|
||||
int bIsYUVFormat;
|
||||
|
||||
/* YCBCR_ORDERING_* defined the order of the Cb/Cr values */
|
||||
int eYUVChromaOrder;
|
||||
|
||||
/* Utility function for adjusting YUV per-plane parameters */
|
||||
IMG_buffer_format_compute_params_pfn pfnComputeParams;
|
||||
}
|
||||
IMG_buffer_format_public_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
/* Base memtrack record, copied to caller */
|
||||
struct memtrack_record base;
|
||||
|
||||
/* Record type, for filtering cached records */
|
||||
enum memtrack_type eType;
|
||||
|
||||
/* Process ID, for filtering cached records */
|
||||
pid_t pid;
|
||||
}
|
||||
IMG_memtrack_record_public_t;
|
||||
|
||||
typedef struct IMG_gralloc_module_public_t
|
||||
{
|
||||
gralloc_module_t base;
|
||||
|
||||
/* This function is deprecated and might be NULL. Do not use it. */
|
||||
int (*GetPhyAddrs)(gralloc_module_t const* module,
|
||||
buffer_handle_t handle, void **ppvPhyAddr);
|
||||
|
||||
/* Obtain HAL's registered format list */
|
||||
const IMG_buffer_format_public_t *(*GetBufferFormats)(void);
|
||||
|
||||
int (*GetImplementationFormat) (struct IMG_gralloc_module_public_t const *psGrallocModule, int usage);
|
||||
|
||||
int (*GetMemTrackRecords)(struct IMG_gralloc_module_public_t const *module,
|
||||
IMG_memtrack_record_public_t **ppsRecords,
|
||||
size_t *puNumRecords);
|
||||
|
||||
/* Custom-blit components in lieu of overlay hardware */
|
||||
int (*Blit)(struct IMG_gralloc_module_public_t const *module,
|
||||
buffer_handle_t src,
|
||||
void *dest[MAX_SUB_ALLOCS], int format);
|
||||
|
||||
int (*Blit2)(struct IMG_gralloc_module_public_t const *module,
|
||||
buffer_handle_t src, buffer_handle_t dest,
|
||||
int w, int h, int x, int y);
|
||||
|
||||
int (*Blit3)(struct IMG_gralloc_module_public_t const *module,
|
||||
unsigned long long ui64SrcStamp, int iSrcWidth,
|
||||
int iSrcHeight, int iSrcFormat, int eSrcRotation,
|
||||
buffer_handle_t dest, int eDestRotation);
|
||||
}
|
||||
IMG_gralloc_module_public_t;
|
||||
|
||||
/**
|
||||
* pixel format definitions
|
||||
*/
|
||||
|
||||
enum {
|
||||
/*
|
||||
* 0x100 = 0x1FF
|
||||
*
|
||||
* This range is reserved for pixel formats that are specific to the HAL
|
||||
* implementation. Implementations can use any value in this range to
|
||||
* communicate video pixel formats between their HAL modules. These
|
||||
* formats must not have an alpha channel. Additionally, an EGLimage
|
||||
* created from a gralloc buffer of one of these formats must be
|
||||
* supported for use with the GL_OES_EGL_image_external OpenGL ES
|
||||
* extension.
|
||||
*/
|
||||
|
||||
/*
|
||||
* These are vendor specific pixel format, by (informal) convention
|
||||
* IMGTec formats start from the top of the range, TI formats start from
|
||||
* the bottom
|
||||
*/
|
||||
HAL_PIXEL_FORMAT_TI_NV12 = 0x100,
|
||||
HAL_PIXEL_FORMAT_TI_UNUSED = 0x101,
|
||||
HAL_PIXEL_FORMAT_TI_NV12_1D = 0x102,
|
||||
HAL_PIXEL_FORMAT_TI_Y8 = 0x103,
|
||||
HAL_PIXEL_FORMAT_TI_Y16 = 0x104,
|
||||
HAL_PIXEL_FORMAT_TI_UYVY = 0x105,
|
||||
HAL_PIXEL_FORMAT_BGRX_8888 = 0x1FF,
|
||||
|
||||
/* generic format missing from Android list, not specific to vendor
|
||||
* implementation
|
||||
*/
|
||||
HAL_PIXEL_FORMAT_NV12 = 0x3231564E, // FourCC for NV12
|
||||
};
|
||||
|
||||
#endif /* HAL_PUBLIC_H */
|
||||
// clang-format on
|
||||
271
tests/test_include/mali_gralloc_buffer.h
Normal file
271
tests/test_include/mali_gralloc_buffer.h
Normal file
|
|
@ -0,0 +1,271 @@
|
|||
// clang-format off
|
||||
/*
|
||||
* Copyright (C) 2017 ARM Limited. All rights reserved.
|
||||
*
|
||||
* 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 MALI_GRALLOC_BUFFER_H_
|
||||
#define MALI_GRALLOC_BUFFER_H_
|
||||
|
||||
#include <errno.h>
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/mman.h>
|
||||
|
||||
#include "mali_gralloc_private_interface_types.h"
|
||||
|
||||
/* NOTE:
|
||||
* If your framebuffer device driver is integrated with dma_buf, you will have to
|
||||
* change this IOCTL definition to reflect your integration with the framebuffer
|
||||
* device.
|
||||
* Expected return value is a structure filled with a file descriptor
|
||||
* backing your framebuffer device memory.
|
||||
*/
|
||||
struct fb_dmabuf_export
|
||||
{
|
||||
__u32 fd;
|
||||
__u32 flags;
|
||||
};
|
||||
#define FBIOGET_DMABUF _IOR('F', 0x21, struct fb_dmabuf_export)
|
||||
|
||||
/* the max string size of GRALLOC_HARDWARE_GPU0 & GRALLOC_HARDWARE_FB0
|
||||
* 8 is big enough for "gpu0" & "fb0" currently
|
||||
*/
|
||||
#define MALI_GRALLOC_HARDWARE_MAX_STR_LEN 8
|
||||
#define NUM_FB_BUFFERS 2
|
||||
|
||||
/* Define number of shared file descriptors */
|
||||
#define GRALLOC_ARM_NUM_FDS 2
|
||||
|
||||
#define NUM_INTS_IN_PRIVATE_HANDLE ((sizeof(struct private_handle_t) - sizeof(native_handle)) / sizeof(int) - sNumFds)
|
||||
|
||||
#define SZ_4K 0x00001000
|
||||
#define SZ_2M 0x00200000
|
||||
|
||||
struct private_handle_t;
|
||||
|
||||
#ifndef __cplusplus
|
||||
/* C99 with pedantic don't allow anonymous unions which is used in below struct
|
||||
* Disable pedantic for C for this struct only.
|
||||
*/
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wpedantic"
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
struct private_handle_t : public native_handle
|
||||
{
|
||||
#else
|
||||
struct private_handle_t
|
||||
{
|
||||
struct native_handle nativeHandle;
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
/* Never intended to be used from C code */
|
||||
enum
|
||||
{
|
||||
PRIV_FLAGS_FRAMEBUFFER = 0x00000001,
|
||||
PRIV_FLAGS_USES_ION_COMPOUND_HEAP = 0x00000002,
|
||||
PRIV_FLAGS_USES_ION = 0x00000004,
|
||||
PRIV_FLAGS_USES_ION_DMA_HEAP = 0x00000008
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
LOCK_STATE_WRITE = 1 << 31,
|
||||
LOCK_STATE_MAPPED = 1 << 30,
|
||||
LOCK_STATE_READ_MASK = 0x3FFFFFFF
|
||||
};
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Shared file descriptor for dma_buf sharing. This must be the first element in the
|
||||
* structure so that binder knows where it is and can properly share it between
|
||||
* processes.
|
||||
* DO NOT MOVE THIS ELEMENT!
|
||||
*/
|
||||
int share_fd;
|
||||
int share_attr_fd;
|
||||
|
||||
// ints
|
||||
int magic;
|
||||
int req_format;
|
||||
uint64_t internal_format;
|
||||
int byte_stride;
|
||||
int flags;
|
||||
int size;
|
||||
int width;
|
||||
int height;
|
||||
int internalWidth;
|
||||
int internalHeight;
|
||||
int stride;
|
||||
union
|
||||
{
|
||||
void *base;
|
||||
uint64_t padding;
|
||||
};
|
||||
union {
|
||||
uint64_t consumer_usage;
|
||||
uint64_t usage;
|
||||
};
|
||||
uint64_t producer_usage;
|
||||
uint64_t backing_store_id;
|
||||
int backing_store_size;
|
||||
int writeOwner;
|
||||
int allocating_pid;
|
||||
int remote_pid;
|
||||
int ref_count;
|
||||
// locally mapped shared attribute area
|
||||
union
|
||||
{
|
||||
void *attr_base;
|
||||
uint64_t padding3;
|
||||
};
|
||||
|
||||
mali_gralloc_yuv_info yuv_info;
|
||||
|
||||
// Following members is for framebuffer only
|
||||
int fd;
|
||||
union
|
||||
{
|
||||
off_t offset;
|
||||
uint64_t padding4;
|
||||
};
|
||||
|
||||
/*
|
||||
* min_pgsz denotes minimum phys_page size used by this buffer.
|
||||
* if buffer memory is physical contiguous set min_pgsz to buff->size
|
||||
* if not sure buff's real phys_page size, you can use SZ_4K for safe.
|
||||
*/
|
||||
int min_pgsz;
|
||||
#ifdef __cplusplus
|
||||
/*
|
||||
* We track the number of integers in the structure. There are 16 unconditional
|
||||
* integers (magic - pid, yuv_info, fd and offset). Note that the fd element is
|
||||
* considered an int not an fd because it is not intended to be used outside the
|
||||
* surface flinger process. The GRALLOC_ARM_NUM_INTS variable is used to track the
|
||||
* number of integers that are conditionally included. Similar considerations apply
|
||||
* to the number of fds.
|
||||
*/
|
||||
static const int sNumFds = GRALLOC_ARM_NUM_FDS;
|
||||
static const int sMagic = 0x3141592;
|
||||
|
||||
private_handle_t(int _flags, int _size, void *_base, uint64_t _consumer_usage, uint64_t _producer_usage,
|
||||
int fb_file, off_t fb_offset)
|
||||
: share_fd(-1)
|
||||
, share_attr_fd(-1)
|
||||
, magic(sMagic)
|
||||
, flags(_flags)
|
||||
, size(_size)
|
||||
, width(0)
|
||||
, height(0)
|
||||
, stride(0)
|
||||
, base(_base)
|
||||
, consumer_usage(_consumer_usage)
|
||||
, producer_usage(_producer_usage)
|
||||
, backing_store_id(0x0)
|
||||
, backing_store_size(0)
|
||||
, writeOwner(0)
|
||||
, allocating_pid(getpid())
|
||||
, remote_pid(-1)
|
||||
, ref_count(1)
|
||||
, attr_base(MAP_FAILED)
|
||||
, yuv_info(MALI_YUV_NO_INFO)
|
||||
, fd(fb_file)
|
||||
, offset(fb_offset)
|
||||
{
|
||||
version = sizeof(native_handle);
|
||||
numFds = sNumFds;
|
||||
numInts = NUM_INTS_IN_PRIVATE_HANDLE;
|
||||
}
|
||||
|
||||
private_handle_t(int _flags, int _size, int _min_pgsz, uint64_t _consumer_usage, uint64_t _producer_usage,
|
||||
int _shared_fd, int _req_format, uint64_t _internal_format, int _byte_stride, int _width,
|
||||
int _height, int _stride, int _internalWidth, int _internalHeight, int _backing_store_size)
|
||||
: share_fd(_shared_fd)
|
||||
, share_attr_fd(-1)
|
||||
, magic(sMagic)
|
||||
, req_format(_req_format)
|
||||
, internal_format(_internal_format)
|
||||
, byte_stride(_byte_stride)
|
||||
, flags(_flags)
|
||||
, size(_size)
|
||||
, width(_width)
|
||||
, height(_height)
|
||||
, internalWidth(_internalWidth)
|
||||
, internalHeight(_internalHeight)
|
||||
, stride(_stride)
|
||||
, base(NULL)
|
||||
, consumer_usage(_consumer_usage)
|
||||
, producer_usage(_producer_usage)
|
||||
, backing_store_id(0x0)
|
||||
, backing_store_size(_backing_store_size)
|
||||
, writeOwner(0)
|
||||
, allocating_pid(getpid())
|
||||
, remote_pid(-1)
|
||||
, ref_count(1)
|
||||
, attr_base(MAP_FAILED)
|
||||
, yuv_info(MALI_YUV_NO_INFO)
|
||||
, fd(-1)
|
||||
, offset(0)
|
||||
, min_pgsz(_min_pgsz)
|
||||
{
|
||||
version = sizeof(native_handle);
|
||||
numFds = sNumFds;
|
||||
numInts = NUM_INTS_IN_PRIVATE_HANDLE;
|
||||
}
|
||||
|
||||
~private_handle_t()
|
||||
{
|
||||
magic = 0;
|
||||
}
|
||||
|
||||
bool usesPhysicallyContiguousMemory()
|
||||
{
|
||||
return (flags & PRIV_FLAGS_FRAMEBUFFER) ? true : false;
|
||||
}
|
||||
|
||||
static int validate(const native_handle *h)
|
||||
{
|
||||
const private_handle_t *hnd = (const private_handle_t *)h;
|
||||
|
||||
if (!h || h->version != sizeof(native_handle) || h->numInts != NUM_INTS_IN_PRIVATE_HANDLE ||
|
||||
h->numFds != sNumFds || hnd->magic != sMagic)
|
||||
{
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static private_handle_t *dynamicCast(const native_handle *in)
|
||||
{
|
||||
if (validate(in) == 0)
|
||||
{
|
||||
return (private_handle_t *)in;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
#endif
|
||||
};
|
||||
#ifndef __cplusplus
|
||||
/* Restore previous diagnostic for pedantic */
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
|
||||
#endif /* MALI_GRALLOC_BUFFER_H_ */
|
||||
// clang-format on
|
||||
270
tests/test_include/mali_gralloc_formats.h
Normal file
270
tests/test_include/mali_gralloc_formats.h
Normal file
|
|
@ -0,0 +1,270 @@
|
|||
// clang-format off
|
||||
/*
|
||||
* Copyright (C) 2016-2017 ARM Limited. All rights reserved.
|
||||
*
|
||||
* 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 MALI_GRALLOC_FORMATS_H_
|
||||
#define MALI_GRALLOC_FORMATS_H_
|
||||
|
||||
#include <system/graphics.h>
|
||||
|
||||
/* Internal formats are represented in gralloc as a 64bit identifier
|
||||
* where the 32 lower bits are a base format and the 32 upper bits are modifiers.
|
||||
*
|
||||
* Modifier bits are divided into mutually exclusive ones and those that are not.
|
||||
*/
|
||||
/* Internal format type */
|
||||
typedef uint64_t mali_gralloc_internal_format;
|
||||
|
||||
/* Internal format masks */
|
||||
#define MALI_GRALLOC_INTFMT_FMT_MASK 0x00000000ffffffffULL
|
||||
#define MALI_GRALLOC_INTFMT_EXT_MASK 0xffffffff00000000ULL
|
||||
#define MALI_GRALLOC_INTFMT_ME_EXT_MASK 0x0000ffff00000000ULL
|
||||
#define MALI_GRALLOC_INTFMT_REG_EXT_MASK 0xffff000000000000ULL
|
||||
|
||||
/* Internal base formats */
|
||||
|
||||
/* Base formats that do not have an identical HAL match
|
||||
* are defined starting at the Android private range
|
||||
*/
|
||||
#define MALI_GRALLOC_FORMAT_INTERNAL_RANGE_BASE 0x100
|
||||
|
||||
typedef enum
|
||||
{
|
||||
MALI_GRALLOC_FORMAT_TYPE_USAGE,
|
||||
MALI_GRALLOC_FORMAT_TYPE_INTERNAL,
|
||||
} mali_gralloc_format_type;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
/* Internal definitions for HAL formats. */
|
||||
MALI_GRALLOC_FORMAT_INTERNAL_RGBA_8888 = HAL_PIXEL_FORMAT_RGBA_8888,
|
||||
MALI_GRALLOC_FORMAT_INTERNAL_RGBX_8888 = HAL_PIXEL_FORMAT_RGBX_8888,
|
||||
MALI_GRALLOC_FORMAT_INTERNAL_RGB_888 = HAL_PIXEL_FORMAT_RGB_888,
|
||||
MALI_GRALLOC_FORMAT_INTERNAL_RGB_565 = HAL_PIXEL_FORMAT_RGB_565,
|
||||
MALI_GRALLOC_FORMAT_INTERNAL_BGRA_8888 = HAL_PIXEL_FORMAT_BGRA_8888,
|
||||
MALI_GRALLOC_FORMAT_INTERNAL_YV12 = HAL_PIXEL_FORMAT_YV12,
|
||||
MALI_GRALLOC_FORMAT_INTERNAL_Y8 = HAL_PIXEL_FORMAT_Y8,
|
||||
MALI_GRALLOC_FORMAT_INTERNAL_Y16 = HAL_PIXEL_FORMAT_Y16,
|
||||
MALI_GRALLOC_FORMAT_INTERNAL_YUV420_888 = HAL_PIXEL_FORMAT_YCbCr_420_888,
|
||||
|
||||
/* Camera specific HAL formats */
|
||||
MALI_GRALLOC_FORMAT_INTERNAL_RAW16 = HAL_PIXEL_FORMAT_RAW16,
|
||||
MALI_GRALLOC_FORMAT_INTERNAL_RAW12 = HAL_PIXEL_FORMAT_RAW12,
|
||||
MALI_GRALLOC_FORMAT_INTERNAL_RAW10 = HAL_PIXEL_FORMAT_RAW10,
|
||||
MALI_GRALLOC_FORMAT_INTERNAL_BLOB = HAL_PIXEL_FORMAT_BLOB,
|
||||
|
||||
/* Flexible YUV formats would be parsed but not have any representation as
|
||||
* internal format itself but one of the ones below
|
||||
*/
|
||||
|
||||
/* The internal private formats that have no HAL equivivalent are defined
|
||||
* afterwards starting at a specific base range */
|
||||
MALI_GRALLOC_FORMAT_INTERNAL_NV12 = MALI_GRALLOC_FORMAT_INTERNAL_RANGE_BASE,
|
||||
MALI_GRALLOC_FORMAT_INTERNAL_NV21,
|
||||
MALI_GRALLOC_FORMAT_INTERNAL_YUV422_8BIT,
|
||||
|
||||
/* Extended YUV formats
|
||||
*
|
||||
* NOTE: P010, P210, and Y410 are only supported uncompressed.
|
||||
*/
|
||||
MALI_GRALLOC_FORMAT_INTERNAL_Y0L2,
|
||||
MALI_GRALLOC_FORMAT_INTERNAL_P010,
|
||||
MALI_GRALLOC_FORMAT_INTERNAL_P210,
|
||||
MALI_GRALLOC_FORMAT_INTERNAL_Y210,
|
||||
MALI_GRALLOC_FORMAT_INTERNAL_Y410,
|
||||
|
||||
/* Add more internal formats here. Make sure decode_internal_format() is updated. */
|
||||
|
||||
/* These are legacy 0.3 gralloc formats used only by the wrap/unwrap macros. */
|
||||
MALI_GRALLOC_FORMAT_INTERNAL_YV12_WRAP,
|
||||
MALI_GRALLOC_FORMAT_INTERNAL_Y8_WRAP,
|
||||
MALI_GRALLOC_FORMAT_INTERNAL_Y16_WRAP,
|
||||
|
||||
MALI_GRALLOC_FORMAT_INTERNAL_RANGE_LAST,
|
||||
} mali_gralloc_pixel_format;
|
||||
|
||||
/* Format Modifier Bits Locations */
|
||||
#define MALI_GRALLOC_INTFMT_ME_EXTENSION_BIT_START 32
|
||||
#define MALI_GRALLOC_INTFMT_EXTENSION_BIT_START (MALI_GRALLOC_INTFMT_ME_EXTENSION_BIT_START + 16)
|
||||
|
||||
/* Mutually Exclusive Modifier Bits */
|
||||
|
||||
/* This format will use AFBC */
|
||||
#define MALI_GRALLOC_INTFMT_AFBC_BASIC (1ULL << (MALI_GRALLOC_INTFMT_ME_EXTENSION_BIT_START + 0))
|
||||
|
||||
/* This format uses AFBC split block mode */
|
||||
#define MALI_GRALLOC_INTFMT_AFBC_SPLITBLK (1ULL << (MALI_GRALLOC_INTFMT_ME_EXTENSION_BIT_START + 1))
|
||||
|
||||
#define MALI_GRALLOC_INTFMT_UNUSED (1ULL << (MALI_GRALLOC_INTFMT_ME_EXTENSION_BIT_START + 2))
|
||||
|
||||
/* This format uses AFBC wide block mode */
|
||||
#define MALI_GRALLOC_INTFMT_AFBC_WIDEBLK (1ULL << (MALI_GRALLOC_INTFMT_ME_EXTENSION_BIT_START + 3))
|
||||
|
||||
/* Regular Modifier Bits */
|
||||
#define MALI_GRALLOC_INTFMT_AFBC_TILED_HEADERS (1ULL << (MALI_GRALLOC_INTFMT_EXTENSION_BIT_START + 0))
|
||||
|
||||
/* This mask should be used to check or clear support for AFBC for an internal format
|
||||
* These bits are mutually exclusive so this mask should not be used to enable support
|
||||
*/
|
||||
#define MALI_GRALLOC_INTFMT_AFBCENABLE_MASK \
|
||||
((uint64_t)(MALI_GRALLOC_INTFMT_AFBC_BASIC | MALI_GRALLOC_INTFMT_AFBC_SPLITBLK | MALI_GRALLOC_INTFMT_AFBC_WIDEBLK))
|
||||
|
||||
/* These are legacy Gralloc 0.3 support macros for passing private formats through the 0.3 alloc interface.
|
||||
* It packs modifier bits together with base format into a 32 bit format identifier.
|
||||
* Gralloc 1.0 interface should use private functions to set private buffer format in the buffer descriptor.
|
||||
*
|
||||
* Packing:
|
||||
*
|
||||
* Bits 15-0: mali_gralloc_pixel_format format
|
||||
* Bits 23-16: mutually exclusive modifier bits
|
||||
* Bits 31-24: regular modifier bits
|
||||
*/
|
||||
static inline int mali_gralloc_format_wrapper(int format, int modifiers)
|
||||
{
|
||||
/* Internal formats that are identical to HAL formats
|
||||
* have the same definition. This is convenient for
|
||||
* client parsing code to not have to parse them separately.
|
||||
*
|
||||
* For 3 of the HAL YUV formats that have very large definitions
|
||||
* this causes problems for packing in modifier bits.
|
||||
* Because of this reason we redefine these three formats
|
||||
* while packing/unpacking them.
|
||||
*/
|
||||
if (format == MALI_GRALLOC_FORMAT_INTERNAL_YV12)
|
||||
{
|
||||
format = MALI_GRALLOC_FORMAT_INTERNAL_YV12_WRAP;
|
||||
}
|
||||
else if (format == MALI_GRALLOC_FORMAT_INTERNAL_Y8)
|
||||
{
|
||||
format = MALI_GRALLOC_FORMAT_INTERNAL_Y8_WRAP;
|
||||
}
|
||||
else if (format == MALI_GRALLOC_FORMAT_INTERNAL_Y16)
|
||||
{
|
||||
format = MALI_GRALLOC_FORMAT_INTERNAL_Y16_WRAP;
|
||||
}
|
||||
|
||||
return (modifiers | format);
|
||||
}
|
||||
|
||||
static inline uint64_t mali_gralloc_format_unwrap(int x)
|
||||
{
|
||||
uint64_t internal_format = (uint64_t)(((((uint64_t)(x)) & 0xff000000) << 24) | // Regular modifier bits
|
||||
((((uint64_t)(x)) & 0x00ff0000) << 16) | // Mutually exclusive modifier bits
|
||||
(((uint64_t)(x)) & 0x0000ffff)); // Private format
|
||||
|
||||
uint64_t base_format = internal_format & MALI_GRALLOC_INTFMT_FMT_MASK;
|
||||
uint64_t modifiers = internal_format & MALI_GRALLOC_INTFMT_EXT_MASK;
|
||||
|
||||
if (base_format == MALI_GRALLOC_FORMAT_INTERNAL_YV12_WRAP)
|
||||
{
|
||||
base_format = MALI_GRALLOC_FORMAT_INTERNAL_YV12;
|
||||
}
|
||||
else if (base_format == MALI_GRALLOC_FORMAT_INTERNAL_Y8_WRAP)
|
||||
{
|
||||
base_format = MALI_GRALLOC_FORMAT_INTERNAL_Y8;
|
||||
}
|
||||
else if (base_format == MALI_GRALLOC_FORMAT_INTERNAL_Y16_WRAP)
|
||||
{
|
||||
base_format = MALI_GRALLOC_FORMAT_INTERNAL_Y16;
|
||||
}
|
||||
|
||||
return (modifiers | base_format);
|
||||
}
|
||||
|
||||
#define GRALLOC_PRIVATE_FORMAT_WRAPPER(x) (mali_gralloc_format_wrapper(x, 0))
|
||||
#define GRALLOC_PRIVATE_FORMAT_WRAPPER_AFBC(x) (mali_gralloc_format_wrapper(x, (MALI_GRALLOC_INTFMT_AFBC_BASIC >> 16)))
|
||||
#define GRALLOC_PRIVATE_FORMAT_WRAPPER_AFBC_SPLITBLK(x) \
|
||||
(mali_gralloc_format_wrapper(x, (MALI_GRALLOC_INTFMT_AFBC_SPLITBLK >> 16)))
|
||||
#define GRALLOC_PRIVATE_FORMAT_WRAPPER_AFBC_WIDEBLK(x) \
|
||||
(mali_gralloc_format_wrapper(x, (MALI_GRALLOC_INTFMT_AFBC_WIDEBLK >> 16)))
|
||||
#define GRALLOC_PRIVATE_FORMAT_WRAPPER_AFBC_TILED_HEADERS_BASIC(x) \
|
||||
(mali_gralloc_format_wrapper(x, (MALI_GRALLOC_INTFMT_AFBC_TILED_HEADERS >> 24) | \
|
||||
(MALI_GRALLOC_INTFMT_AFBC_BASIC >> 16)))
|
||||
#define GRALLOC_PRIVATE_FORMAT_WRAPPER_AFBC_TILED_HEADERS_WIDE(x) \
|
||||
(mali_gralloc_format_wrapper(x, (MALI_GRALLOC_INTFMT_AFBC_TILED_HEADERS >> 24) | \
|
||||
(MALI_GRALLOC_INTFMT_AFBC_WIDEBLK >> 16)))
|
||||
#define GRALLOC_PRIVATE_FORMAT_UNWRAP(x) mali_gralloc_format_unwrap(x)
|
||||
|
||||
/* IP block capability masks */
|
||||
#define MALI_GRALLOC_FORMAT_CAPABILITY_OPTIONS_PRESENT ((uint64_t)(1 << 0))
|
||||
#define MALI_GRALLOC_FORMAT_CAPABILITY_AFBC_BASIC ((uint64_t)(1 << 1))
|
||||
#define MALI_GRALLOC_FORMAT_CAPABILITY_AFBC_SPLITBLK ((uint64_t)(1 << 2))
|
||||
#define MALI_GRALLOC_FORMAT_CAPABILITY_AFBC_WIDEBLK ((uint64_t)(1 << 3))
|
||||
#define MALI_GRALLOC_FORMAT_CAPABILITY_AFBC_WIDEBLK_YUV_DISABLE ((uint64_t)(1 << 4))
|
||||
#define MALI_GRALLOC_FORMAT_CAPABILITY_AFBC_YUV_NOREAD ((uint64_t)(1 << 5))
|
||||
#define MALI_GRALLOC_FORMAT_CAPABILITY_AFBC_YUV_NOWRITE ((uint64_t)(1 << 6))
|
||||
#define MALI_GRALLOC_FORMAT_CAPABILITY_AFBC_TILED_HEADERS ((uint64_t)(1 << 7))
|
||||
|
||||
#define MALI_GRALLOC_FORMAT_CAPABILITY_AFBCENABLE_MASK \
|
||||
((uint64_t)(MALI_GRALLOC_FORMAT_CAPABILITY_AFBC_BASIC | MALI_GRALLOC_FORMAT_CAPABILITY_AFBC_SPLITBLK | \
|
||||
MALI_GRALLOC_FORMAT_CAPABILITY_AFBC_WIDEBLK | MALI_GRALLOC_FORMAT_CAPABILITY_AFBC_TILED_HEADERS))
|
||||
|
||||
struct mali_gralloc_format_caps
|
||||
{
|
||||
uint64_t caps_mask;
|
||||
};
|
||||
typedef struct mali_gralloc_format_caps mali_gralloc_format_caps;
|
||||
|
||||
#define MALI_GRALLOC_FORMATCAPS_SYM_NAME mali_gralloc_format_capabilities
|
||||
#define MALI_GRALLOC_FORMATCAPS_SYM_NAME_STR "mali_gralloc_format_capabilities"
|
||||
|
||||
/* Producer and Consumer definitions */
|
||||
typedef enum
|
||||
{
|
||||
MALI_GRALLOC_PRODUCER_VIDEO_DECODER,
|
||||
MALI_GRALLOC_PRODUCER_GPU,
|
||||
MALI_GRALLOC_PRODUCER_CAMERA,
|
||||
} mali_gralloc_producer_type;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
|
||||
/* For surface composition in SurfaceFlinger a producer
|
||||
* will not know what consumer will process a buffer.
|
||||
*
|
||||
* MALI_GRALLOC_CONSUMER_GPU_OR_DISPLAY means the GPU
|
||||
* MUST support the given format but it should be allocated
|
||||
* with preference to the DPU.
|
||||
*/
|
||||
MALI_GRALLOC_CONSUMER_GPU_OR_DISPLAY,
|
||||
MALI_GRALLOC_CONSUMER_VIDEO_ENCODER,
|
||||
|
||||
/* This is used when no known "premium" dpu is configured.
|
||||
* For example, HDLCD/CLCD would be such a dpu.
|
||||
*/
|
||||
MALI_GRALLOC_CONSUMER_GPU_EXCL,
|
||||
} mali_gralloc_consumer_type;
|
||||
|
||||
/* Internal prototypes */
|
||||
#if defined(GRALLOC_LIBRARY_BUILD)
|
||||
uint64_t mali_gralloc_select_format(uint64_t req_format, mali_gralloc_format_type type, uint64_t usage,
|
||||
int buffer_size);
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
void mali_gralloc_get_gpu_caps(struct mali_gralloc_format_caps *gpu_caps);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* MALI_GRALLOC_FORMATS_H_ */
|
||||
// clang-format on
|
||||
88
tests/test_include/mali_gralloc_private_interface_types.h
Normal file
88
tests/test_include/mali_gralloc_private_interface_types.h
Normal file
|
|
@ -0,0 +1,88 @@
|
|||
// clang-format off
|
||||
/*
|
||||
* Copyright (C) 2017 ARM Limited. All rights reserved.
|
||||
*
|
||||
* 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 MALI_GRALLOC_PRIVATE_INTERFACE_TYPES_H_
|
||||
#define MALI_GRALLOC_PRIVATE_INTERFACE_TYPES_H_
|
||||
|
||||
#define GRALLOC_ARM_BUFFER_ATTR_HDR_INFO_SUPPORT
|
||||
|
||||
typedef enum
|
||||
{
|
||||
MALI_HDR_NO_INFO,
|
||||
MALI_HDR_ST2084,
|
||||
MALI_HDR_HLG,
|
||||
MALI_HDR_LAST
|
||||
} mali_transfer_function;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
//values are in units of 0.00002
|
||||
uint16_t x;
|
||||
uint16_t y;
|
||||
} primaries;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
primaries r;
|
||||
primaries g;
|
||||
primaries b;
|
||||
primaries w;
|
||||
uint16_t minDisplayLuminance; // in cd/m^2
|
||||
uint16_t maxDisplayLuminance; // in 0.0001 cd/m^2
|
||||
uint16_t maxContentLightLevel; // in cd/m^2
|
||||
uint16_t maxFrameAverageLightLevel; // in cd/m^2
|
||||
mali_transfer_function eotf;
|
||||
} mali_hdr_info;
|
||||
|
||||
enum
|
||||
{
|
||||
/* CROP_RECT and YUV_TRANS are intended to be
|
||||
* written by producers and read by consumers.
|
||||
* A producer should write these parameters before
|
||||
* it queues a buffer to the consumer.
|
||||
*/
|
||||
|
||||
/* CROP RECT, defined as an int array of top, left, height, width. Origin in top-left corner */
|
||||
GRALLOC_ARM_BUFFER_ATTR_CROP_RECT = 1,
|
||||
|
||||
/* Set if the AFBC format used a YUV transform before compressing */
|
||||
GRALLOC_ARM_BUFFER_ATTR_AFBC_YUV_TRANS = 2,
|
||||
|
||||
/* Set if the AFBC format uses sparse allocation */
|
||||
GRALLOC_ARM_BUFFER_ATTR_AFBC_SPARSE_ALLOC = 3,
|
||||
|
||||
/* HDR Informations*/
|
||||
GRALLOC_ARM_BUFFER_ATTR_HDR_INFO = 4,
|
||||
|
||||
GRALLOC_ARM_BUFFER_ATTR_LAST
|
||||
};
|
||||
|
||||
typedef uint32_t buf_attr;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
MALI_YUV_NO_INFO,
|
||||
MALI_YUV_BT601_NARROW,
|
||||
MALI_YUV_BT601_WIDE,
|
||||
MALI_YUV_BT709_NARROW,
|
||||
MALI_YUV_BT709_WIDE
|
||||
} mali_gralloc_yuv_info;
|
||||
|
||||
#endif /* MALI_GRALLOC_PRIVATE_INTERFACE_TYPES_H_ */
|
||||
// clang-format on
|
||||
94
tests/test_include/mali_gralloc_usages.h
Normal file
94
tests/test_include/mali_gralloc_usages.h
Normal file
|
|
@ -0,0 +1,94 @@
|
|||
// clang-format off
|
||||
/*
|
||||
* (C) COPYRIGHT 2017 ARM Limited. All rights reserved.
|
||||
* 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 MALI_GRALLOC_USAGES_H_
|
||||
#define MALI_GRALLOC_USAGES_H_
|
||||
|
||||
/*
|
||||
* Below usage types overlap, this is intentional.
|
||||
* The reason is that for Gralloc 0.3 there are very
|
||||
* few usage flags we have at our disposal.
|
||||
*
|
||||
* The overlapping is handled by processing the definitions
|
||||
* in a specific order.
|
||||
*
|
||||
* MALI_GRALLOC_USAGE_PRIVATE_FORMAT and MALI_GRALLOC_USAGE_NO_AFBC
|
||||
* don't overlap and are processed first.
|
||||
*
|
||||
* MALI_GRALLOC_USAGE_YUV_CONF are only for YUV formats and clients
|
||||
* using MALI_GRALLOC_USAGE_NO_AFBC must never allocate YUV formats.
|
||||
* The latter is strictly enforced and allocations will fail.
|
||||
*
|
||||
* MALI_GRALLOC_USAGE_AFBC_PADDING is only valid if MALI_GRALLOC_USAGE_NO_AFBC
|
||||
* is not present.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Gralloc private usage 0-3 are the same in 0.3 and 1.0.
|
||||
* We defined based our usages based on what is available.
|
||||
*/
|
||||
#if defined(GRALLOC_MODULE_API_VERSION_1_0)
|
||||
typedef enum
|
||||
{
|
||||
/* The client has specified a private format in the format parameter */
|
||||
MALI_GRALLOC_USAGE_PRIVATE_FORMAT = (int)GRALLOC1_PRODUCER_USAGE_PRIVATE_3,
|
||||
|
||||
/* Buffer won't be allocated as AFBC */
|
||||
MALI_GRALLOC_USAGE_NO_AFBC = (int)(GRALLOC1_PRODUCER_USAGE_PRIVATE_1 | GRALLOC1_PRODUCER_USAGE_PRIVATE_2),
|
||||
|
||||
/* Valid only for YUV allocations */
|
||||
MALI_GRALLOC_USAGE_YUV_CONF_0 = 0,
|
||||
MALI_GRALLOC_USAGE_YUV_CONF_1 = (int)GRALLOC1_PRODUCER_USAGE_PRIVATE_1,
|
||||
MALI_GRALLOC_USAGE_YUV_CONF_2 = (int)GRALLOC1_PRODUCER_USAGE_PRIVATE_0,
|
||||
MALI_GRALLOC_USAGE_YUV_CONF_3 = (int)(GRALLOC1_PRODUCER_USAGE_PRIVATE_0 | GRALLOC1_PRODUCER_USAGE_PRIVATE_1),
|
||||
MALI_GRALLOC_USAGE_YUV_CONF_MASK = MALI_GRALLOC_USAGE_YUV_CONF_3,
|
||||
|
||||
/* A very specific alignment is requested on some buffers */
|
||||
MALI_GRALLOC_USAGE_AFBC_PADDING = (int)GRALLOC1_PRODUCER_USAGE_PRIVATE_2,
|
||||
|
||||
} mali_gralloc_usage_type;
|
||||
#elif defined(GRALLOC_MODULE_API_VERSION_0_3)
|
||||
typedef enum
|
||||
{
|
||||
/* The client has specified a private format in the format parameter */
|
||||
MALI_GRALLOC_USAGE_PRIVATE_FORMAT = (int)GRALLOC_USAGE_PRIVATE_3,
|
||||
|
||||
/* Buffer won't be allocated as AFBC */
|
||||
MALI_GRALLOC_USAGE_NO_AFBC = (int)(GRALLOC_USAGE_PRIVATE_1 | GRALLOC_USAGE_PRIVATE_2),
|
||||
|
||||
/* Valid only for YUV allocations */
|
||||
MALI_GRALLOC_USAGE_YUV_CONF_0 = 0,
|
||||
MALI_GRALLOC_USAGE_YUV_CONF_1 = (int)GRALLOC_USAGE_PRIVATE_1,
|
||||
MALI_GRALLOC_USAGE_YUV_CONF_2 = (int)GRALLOC_USAGE_PRIVATE_0,
|
||||
MALI_GRALLOC_USAGE_YUV_CONF_3 = (int)(GRALLOC_USAGE_PRIVATE_0 | GRALLOC_USAGE_PRIVATE_1),
|
||||
MALI_GRALLOC_USAGE_YUV_CONF_MASK = MALI_GRALLOC_USAGE_YUV_CONF_3,
|
||||
|
||||
/* A very specific alignment is requested on some buffers */
|
||||
MALI_GRALLOC_USAGE_AFBC_PADDING = GRALLOC_USAGE_PRIVATE_2,
|
||||
|
||||
} mali_gralloc_usage_type;
|
||||
#else
|
||||
#if defined(GRALLOC_LIBRARY_BUILD)
|
||||
#error "Please include mali_gralloc_module.h before including other gralloc headers when building gralloc itself"
|
||||
#else
|
||||
#error "Please include either gralloc.h or gralloc1.h header before including gralloc_priv.h"
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#endif /*MALI_GRALLOC_USAGES_H_*/
|
||||
// clang-format on
|
||||
Loading…
Add table
Add a link
Reference in a new issue