summaryrefslogtreecommitdiff
path: root/moorefield_hdmi/include/pvr/hal/hal_public.h
blob: 19910c10f70a7ec868711180a9712505f004af61 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
/* 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

#define PVR_ANDROID_HAS_SET_BUFFERS_DATASPACE
#define PVR_ANDROID_HAS_SET_BUFFERS_DATASPACE_2

#include "img_gralloc_common_public.h"

/* Extension pixel formats used by Intel components */

#undef  HAL_PIXEL_FORMAT_NV12

#define HAL_PIXEL_FORMAT_UYVY                 0x107
#define HAL_PIXEL_FORMAT_INTEL_YV12           0x108
#define HAL_PIXEL_FORMAT_INTEL_ZSL            0x109
#define HAL_PIXEL_FORMAT_NV12                 0x3231564E
#define HAL_PIXEL_FORMAT_NV21                 0x3132564E
#define HAL_PIXEL_FORMAT_I420                 0x30323449
#define HAL_PIXEL_FORMAT_YUY2                 0x32595559
#define HAL_PIXEL_FORMAT_NV12_VED             0x7FA00E00
#define HAL_PIXEL_FORMAT_NV12_VEDT            0x7FA00F00

/* Extension API used by Intel components */

#define GRALLOC_GET_BUFFER_CPU_ADDRESSES_IMG  108
#define GRALLOC_PUT_BUFFER_CPU_ADDRESSES_IMG  109

#define GRALLOC_GET_DISPLAY_DEVICE_IMG        1000
#define GRALLOC_GET_DISPLAY_STATUS_IMG        1001

#include "img_gralloc.h"
#include "img_gralloc1.h"

typedef const gralloc_module_t gralloc0_t;
typedef gralloc1_device_t      gralloc1_t;

static inline int gralloc_is_v1_img(const hw_module_t *m)
{
	return ((m->module_api_version >> 8) & 0xff) == 1;
}

static inline int gralloc_open_img(const hw_device_t **d)
{
	const hw_module_t *m;
	int err;

	err = hw_get_module(GRALLOC_HARDWARE_MODULE_ID, &m);
	if (err)
		return err;

	if (gralloc_is_v1_img(m))
		return gralloc1_open(m, (gralloc1_t **)d);
	else
		return gralloc_open(m, (alloc_device_t **)d);
}

static inline int gralloc_close_img(const hw_device_t *d)
{
	if (gralloc_is_v1_img(d->module))
		return gralloc1_close((gralloc1_t *)d);
	else
		return gralloc_close((alloc_device_t *)d);
}

static inline int gralloc_register_img
	(const hw_device_t *d, buffer_handle_t handle)
{
	if (gralloc_is_v1_img(d->module))
		return gralloc1_register_img((gralloc1_t *)d, handle);
	else
		return gralloc0_register_img((gralloc0_t *)d->module, handle);
}

static inline int gralloc_unregister_img
	(const hw_device_t *d, buffer_handle_t handle)
{
	if (gralloc_is_v1_img(d->module))
		return gralloc1_unregister_img((gralloc1_t *)d, handle);
	else
		return gralloc0_unregister_img((gralloc0_t *)d->module, handle);
}

static inline int gralloc_device_alloc_img
	(const hw_device_t *d, int w, int h, int format, int usage,
	 buffer_handle_t *handle, int *stride)
{
	if (gralloc_is_v1_img(d->module)) {
		usage = (usage | ((usage & 0x33) << 1)) & ~0x11;
		return gralloc1_device_alloc_img((gralloc1_t *)d, w, h, format,
										 usage, handle, stride);
	} else
		return gralloc0_device_alloc_img((alloc_device_t *)d, w, h, format,
										 usage, handle, stride);
}

static inline int gralloc_device_free_img
	(const hw_device_t *d, buffer_handle_t handle)
{
	if (gralloc_is_v1_img(d->module))
		return gralloc1_device_free_img((gralloc1_t *)d, handle);
	else
		return gralloc0_device_free_img((alloc_device_t *)d, handle);
}

static inline int gralloc_lock_async_img
	(const hw_device_t *d, buffer_handle_t handle, int usage,
	 const gralloc1_rect_t *r, void **vaddr, int acquireFence)
{
	if (gralloc_is_v1_img(d->module)) {
		usage = (usage | ((usage & 0x33) << 1)) & ~0x11;
		return gralloc1_lock_async_img((gralloc1_t *)d,
									   handle, usage, r, vaddr, acquireFence);
	} else
		return gralloc0_lock_async_img((gralloc0_t *)d->module,
									   handle, usage, r, vaddr, acquireFence);
}

static inline int gralloc_unlock_async_img
	(const hw_device_t *d, buffer_handle_t handle, int *releaseFence)
{
	if (gralloc_is_v1_img(d->module))
		return gralloc1_unlock_async_img((gralloc1_t *)d,
										 handle, releaseFence);
	else
		return gralloc0_unlock_async_img((gralloc0_t *)d->module,
										 handle, releaseFence);
}

static inline int gralloc_blit_handle_to_handle_img
	(const hw_device_t *d, buffer_handle_t src, buffer_handle_t dest,
	 int w, int h, int x, int y, int transform, int input_fence,
	 int *output_fence)
{
	if (gralloc_is_v1_img(d->module))
		return gralloc1_blit_handle_to_handle_img((gralloc1_t *)d,
												  src, dest, w, h, x, y,
												  transform, input_fence,
												  output_fence);
	else
		return gralloc0_blit_handle_to_handle_img((gralloc0_t *)d->module,
												  src, dest, w, h, x, y,
												  transform, input_fence,
												  output_fence);
}


static inline int gralloc_get_buffer_cpu_addresses_img
	(const hw_device_t *d, buffer_handle_t handle, void **vaddrs,
	 size_t *sizes)
{
	if (gralloc_is_v1_img(d->module))
		return gralloc1_get_buffer_cpu_addresses_img((gralloc1_t *)d,
													 handle, vaddrs, sizes);
	else
		return gralloc0_get_buffer_cpu_addresses_img((gralloc0_t *)d->module,
													 handle, vaddrs, sizes);
}

static inline int gralloc_put_buffer_cpu_addresses_img
	(const hw_device_t *d, buffer_handle_t handle)
{
	if (gralloc_is_v1_img(d->module))
		return gralloc1_put_buffer_cpu_addresses_img((gralloc1_t *)d,
													 handle);
	else
		return gralloc0_put_buffer_cpu_addresses_img((gralloc0_t *)d->module,
													 handle);
}

static inline int gralloc_get_display_device_img
	(const hw_device_t *d, void **ppvDispDev)
{
	if (gralloc_is_v1_img(d->module))
		return gralloc1_get_display_device_img((gralloc1_t *)d,
											   ppvDispDev);
	else
		return gralloc0_get_display_device_img((gralloc0_t *)d->module,
											   ppvDispDev);
}

static inline int gralloc_get_display_status_img
	(const hw_device_t *d, buffer_handle_t handle, uint32_t *pui32Status)
{
	if (gralloc_is_v1_img(d->module))
		return gralloc1_get_display_status_img((gralloc1_t *)d,
											   handle, pui32Status);
	else
		return gralloc0_get_display_status_img((gralloc0_t *)d->module,
											   handle, pui32Status);
}

#endif /* HAL_PUBLIC_H */