summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrew F. Davis2018-07-24 08:20:35 -0500
committerAlistair Strachan2018-08-31 13:00:04 -0500
commit8eaa2bfcd5a0abbd52051f14de0c0e200e98175b (patch)
tree624db8896f88f8680bb2e8a1e100497230716b65 /libhwcomposer/hal_public.h
parent86a022aa92b8f174df250113f4717737b9edfd25 (diff)
downloadhardware-ti-am57x-8eaa2bfcd5a0abbd52051f14de0c0e200e98175b.tar.gz
hardware-ti-am57x-8eaa2bfcd5a0abbd52051f14de0c0e200e98175b.tar.xz
hardware-ti-am57x-8eaa2bfcd5a0abbd52051f14de0c0e200e98175b.zip
libhwcomposer: Add initial support
Add basic HW Composer support that allows boot to UI. More functionality will be added incrementally. Test: Boot to UI with BeagleBoard X15 Change-Id: I9803cc892dfe85b8b9929229ba3b86f2bd9d36bc Signed-off-by: Andrew F. Davis <afd@ti.com>
Diffstat (limited to 'libhwcomposer/hal_public.h')
-rw-r--r--libhwcomposer/hal_public.h245
1 files changed, 245 insertions, 0 deletions
diff --git a/libhwcomposer/hal_public.h b/libhwcomposer/hal_public.h
new file mode 100644
index 0000000..5ca9bd2
--- /dev/null
+++ b/libhwcomposer/hal_public.h
@@ -0,0 +1,245 @@
1/* Copyright (c) Imagination Technologies Ltd.
2 *
3 * The contents of this file are subject to the MIT license as set out below.
4 *
5 * Permission is hereby granted, free of charge, to any person obtaining a copy
6 * of this software and associated documentation files (the "Software"), to deal
7 * in the Software without restriction, including without limitation the rights
8 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 * copies of the Software, and to permit persons to whom the Software is
10 * furnished to do so, subject to the following conditions:
11 *
12 * The above copyright notice and this permission notice shall be included in
13 * all copies or substantial portions of the Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 * THE SOFTWARE.
22 */
23
24#ifndef HAL_PUBLIC_H
25#define HAL_PUBLIC_H
26
27/* Authors of third party hardware composer (HWC) modules will need to include
28 * this header to access functionality in the gralloc and framebuffer HALs.
29 */
30
31#include <hardware/gralloc.h>
32#include <hardware/memtrack.h>
33
34#define ALIGN(x,a) (((x) + (a) - 1L) & ~((a) - 1L))
35#define HW_ALIGN 16
36
37/* This can be tuned down as appropriate for the SOC.
38 *
39 * IMG formats are usually a single sub-alloc.
40 * Some OEM video formats are two sub-allocs (Y, UV planes).
41 * Future OEM video formats might be three sub-allocs (Y, U, V planes).
42 */
43#define MAX_SUB_ALLOCS 3
44
45/* Format is not YCbCr (e.g. a RGB format) - bIsYUVFormat should be false */
46#define YUV_CHROMA_ORDER_NONE 0
47/* Cb follows Y */
48#define YUV_CHROMA_ORDER_CBCR_UV 1
49/* Cr follows Y */
50#define YUV_CHROMA_ORDER_CRCB_VU 2
51
52typedef struct
53{
54 native_handle_t base;
55
56 /* These fields can be sent cross process. They are also valid
57 * to duplicate within the same process.
58 *
59 * A table is stored within psPrivateData on gralloc_module_t (this
60 * is obviously per-process) which maps stamps to a mapped
61 * PVRSRV_CLIENT_MEM_INFO in that process. Each map entry has a lock
62 * count associated with it, satisfying the requirements of the
63 * Android API. This also prevents us from leaking maps/allocations.
64 *
65 * This table has entries inserted either by alloc()
66 * (alloc_device_t) or map() (gralloc_module_t). Entries are removed
67 * by free() (alloc_device_t) and unmap() (gralloc_module_t).
68 *
69 * As a special case for framebuffer_device_t, framebuffer_open()
70 * will add and framebuffer_close() will remove from this table.
71 */
72
73#define IMG_NATIVE_HANDLE_NUMFDS MAX_SUB_ALLOCS
74 /* The `fd' field is used to "export" a meminfo to another process.
75 * Therefore, it is allocated by alloc_device_t, and consumed by
76 * gralloc_module_t. The framebuffer_device_t does not need a handle,
77 * and the special value IMG_FRAMEBUFFER_FD is used instead.
78 */
79 int fd[MAX_SUB_ALLOCS];
80
81#define IMG_NATIVE_HANDLE_NUMINTS \
82 ((sizeof(unsigned long long) / sizeof(int)) + 5 + MAX_SUB_ALLOCS + 1 + MAX_SUB_ALLOCS + MAX_SUB_ALLOCS)
83 /* A KERNEL unique identifier for any exported kernel meminfo. Each
84 * exported kernel meminfo will have a unique stamp, but note that in
85 * userspace, several meminfos across multiple processes could have
86 * the same stamp. As the native_handle can be dup(2)'d, there could be
87 * multiple handles with the same stamp but different file descriptors.
88 */
89 unsigned long long ui64Stamp;
90
91 /* This is used for buffer usage validation when locking a buffer,
92 * and also in WSEGL (for the composition bypass feature).
93 */
94 int usage;
95
96 /* In order to do efficient cache flushes we need the buffer dimensions
97 * and format. These are available on the ANativeWindowBuffer,
98 * but the platform doesn't pass them down to the graphics HAL.
99 */
100 int iWidth;
101 int iHeight;
102 int iFormat;
103 unsigned int uiBpp;
104
105 /* The ion allocation path doesn't allow for the allocation size and
106 * mapping flags to be communicated cross-process automatically.
107 * Cache these here so we can map buffers in client processes.
108 */
109 unsigned int uiAllocSize[MAX_SUB_ALLOCS];
110 unsigned int uiFlags;
111 /* For multi-planar allocations, there will be multiple hstrides */
112 int aiStride[MAX_SUB_ALLOCS];
113
114 /* For multi-planar allocations, there will be multiple vstrides */
115 int aiVStride[MAX_SUB_ALLOCS];
116
117}
118__attribute__((aligned(sizeof(int)),packed)) IMG_native_handle_t;
119
120typedef struct
121{
122 int l, t, w, h;
123}
124IMG_write_lock_rect_t;
125
126typedef int (*IMG_buffer_format_compute_params_pfn)(
127 unsigned int uiPlane, int *piWidth, int *piHeight,
128 int *piStride, int *piVStride, unsigned long *pulPlaneOffset);
129
130typedef struct IMG_buffer_format_public_t
131{
132 /* Buffer formats are returned as a linked list */
133 struct IMG_buffer_format_public_t *psNext;
134
135 /* HAL_PIXEL_FORMAT_... enumerant */
136 int iHalPixelFormat;
137
138 /* WSEGL_PIXELFORMAT_... enumerant */
139 int iWSEGLPixelFormat;
140
141 /* Friendly name for format */
142 const char *const szName;
143
144 /* Bits (not bytes) per pixel */
145 unsigned int uiBpp;
146
147 /* Supported HW usage bits. If this is GRALLOC_USAGE_HW_MASK, all usages
148 * are supported. Used for HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED.
149 */
150 int iSupportedUsage;
151
152 /* YUV output format */
153 int bIsYUVFormat;
154
155 /* YCBCR_ORDERING_* defined the order of the Cb/Cr values */
156 int eYUVChromaOrder;
157
158 /* Utility function for adjusting YUV per-plane parameters */
159 IMG_buffer_format_compute_params_pfn pfnComputeParams;
160}
161IMG_buffer_format_public_t;
162
163typedef struct
164{
165 /* Base memtrack record, copied to caller */
166 struct memtrack_record base;
167
168 /* Record type, for filtering cached records */
169 enum memtrack_type eType;
170
171 /* Process ID, for filtering cached records */
172 pid_t pid;
173}
174IMG_memtrack_record_public_t;
175
176typedef struct IMG_gralloc_module_public_t
177{
178 gralloc_module_t base;
179
180 /* This function is deprecated and might be NULL. Do not use it. */
181 int (*GetPhyAddrs)(gralloc_module_t const* module,
182 buffer_handle_t handle, void **ppvPhyAddr);
183
184 /* Obtain HAL's registered format list */
185 const IMG_buffer_format_public_t *(*GetBufferFormats)(void);
186
187 int (*GetImplementationFormat) (struct IMG_gralloc_module_public_t const *psGrallocModule, int usage);
188
189 int (*GetMemTrackRecords)(struct IMG_gralloc_module_public_t const *module,
190 IMG_memtrack_record_public_t **ppsRecords,
191 size_t *puNumRecords);
192
193 /* Custom-blit components in lieu of overlay hardware */
194 int (*Blit)(struct IMG_gralloc_module_public_t const *module,
195 buffer_handle_t src,
196 void *dest[MAX_SUB_ALLOCS], int format);
197
198 int (*Blit2)(struct IMG_gralloc_module_public_t const *module,
199 buffer_handle_t src, buffer_handle_t dest,
200 int w, int h, int x, int y);
201
202 int (*Blit3)(struct IMG_gralloc_module_public_t const *module,
203 unsigned long long ui64SrcStamp, int iSrcWidth,
204 int iSrcHeight, int iSrcFormat, int eSrcRotation,
205 buffer_handle_t dest, int eDestRotation);
206}
207IMG_gralloc_module_public_t;
208
209/**
210 * pixel format definitions
211 */
212
213enum {
214 /*
215 * 0x100 = 0x1FF
216 *
217 * This range is reserved for pixel formats that are specific to the HAL
218 * implementation. Implementations can use any value in this range to
219 * communicate video pixel formats between their HAL modules. These
220 * formats must not have an alpha channel. Additionally, an EGLimage
221 * created from a gralloc buffer of one of these formats must be
222 * supported for use with the GL_OES_EGL_image_external OpenGL ES
223 * extension.
224 */
225
226 /*
227 * These are vendor specific pixel format, by (informal) convention
228 * IMGTec formats start from the top of the range, TI formats start from
229 * the bottom
230 */
231 HAL_PIXEL_FORMAT_TI_NV12 = 0x100,
232 HAL_PIXEL_FORMAT_TI_UNUSED = 0x101,
233 HAL_PIXEL_FORMAT_TI_NV12_1D = 0x102,
234 HAL_PIXEL_FORMAT_TI_Y8 = 0x103,
235 HAL_PIXEL_FORMAT_TI_Y16 = 0x104,
236 HAL_PIXEL_FORMAT_TI_UYVY = 0x105,
237 HAL_PIXEL_FORMAT_BGRX_8888 = 0x1FF,
238
239 /* generic format missing from Android list, not specific to vendor
240 * implementation
241 */
242 HAL_PIXEL_FORMAT_NV12 = 0x3231564E, // FourCC for NV12
243};
244
245#endif /* HAL_PUBLIC_H */