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
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
|
/*************************************************************************/ /*!
@Title Dummy 3rd party display driver structures and prototypes
@Copyright Copyright (c) Imagination Technologies Ltd. All Rights Reserved
@License Dual MIT/GPLv2
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.
Alternatively, the contents of this file may be used under the terms of
the GNU General Public License Version 2 ("GPL") in which case the provisions
of GPL are applicable instead of those above.
If you wish to allow use of your version of this file only under the terms of
GPL, and not to allow others to use your version of this file under the terms
of the MIT license, indicate your decision by deleting the provisions above
and replace them with the notice and other provisions required by GPL as set
out in the file called "GPL-COPYING" included in this distribution. If you do
not delete the provisions above, a recipient may use your version of this file
under the terms of either the MIT license or GPL.
This License is also included in this distribution in the file called
"MIT-COPYING".
EXCEPT AS OTHERWISE STATED IN A NEGOTIATED AGREEMENT: (A) 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; AND (B) 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.
*/ /**************************************************************************/
/**************************************************************************
The 3rd party driver is a specification of an API to integrate the
IMG PowerVR Services driver with 3rd Party display hardware.
It is NOT a specification for a display controller driver, rather a
specification to extend the API for a pre-existing driver for the display hardware.
The 3rd party driver interface provides IMG PowerVR client drivers (e.g. PVR2D)
with an API abstraction of the system's underlying display hardware, allowing
the client drivers to indirectly control the display hardware and access its
associated memory.
Functions of the API include
- query primary surface attributes (width, height, stride, pixel format,
CPU physical and virtual address)
- swap/flip chain creation and subsequent query of surface attributes
- asynchronous display surface flipping, taking account of asynchronous
read (flip) and write (render) operations to the display surface
Note: having queried surface attributes the client drivers are able to map
the display memory to any IMG PowerVR Services device by calling
PVRSRVMapDeviceClassMemory with the display surface handle.
This code is intended to be an example of how a pre-existing display driver
may be extended to support the 3rd Party Display interface to
PowerVR Services - IMG is not providing a display driver implementation
**************************************************************************/
#ifndef __DC_NOHW_H__
#define __DC_NOHW_H__
#if defined(__cplusplus)
extern "C" {
#endif
#if defined(USE_BASE_VIDEO_FRAMEBUFFER)
#if defined (ENABLE_DISPLAY_MODE_TRACKING)
#error Cannot have both USE_BASE_VIDEO_FRAMEBUFFER and ENABLE_DISPLAY_MODE_TRACKING defined
#endif
#endif
#if !defined(DC_NOHW_BUFFER_WIDTH) && !defined(DC_NOHW_BUFFER_HEIGHT)
/* Default buffer size */
#define DC_NOHW_BUFFER_WIDTH 320
#define DC_NOHW_BUFFER_HEIGHT 240
#endif
#define DC_NOHW_BUFFER_BIT_DEPTH 32
#define DC_NOHW_BUFFER_PIXEL_FORMAT PVRSRV_PIXEL_FORMAT_ARGB8888
#define DC_NOHW_DEPTH_BITS_PER_BYTE 8
#define dc_nohw_byte_depth_from_bit_depth(bit_depth) (((IMG_UINT32)(bit_depth) + DC_NOHW_DEPTH_BITS_PER_BYTE - 1)/DC_NOHW_DEPTH_BITS_PER_BYTE)
#define dc_nohw_bit_depth_from_byte_depth(byte_depth) ((IMG_UINT32)(byte_depth) * DC_NOHW_DEPTH_BITS_PER_BYTE)
#define dc_nohw_roundup_bit_depth(bd) dc_nohw_bit_depth_from_byte_depth(dc_nohw_byte_depth_from_bit_depth(bd))
#define dc_nohw_byte_stride(width, bit_depth) ((IMG_UINT32)(width) * dc_nohw_byte_depth_from_bit_depth(bit_depth))
#if defined(DC_NOHW_GET_BUFFER_DIMENSIONS)
IMG_BOOL GetBufferDimensions(IMG_UINT32 *pui32Width, IMG_UINT32 *pui32Height, PVRSRV_PIXEL_FORMAT *pePixelFormat, IMG_UINT32 *pui32Stride);
#else
#define DC_NOHW_BUFFER_BYTE_STRIDE dc_nohw_byte_stride(DC_NOHW_BUFFER_WIDTH, DC_NOHW_BUFFER_BIT_DEPTH)
#endif
extern IMG_BOOL IMG_IMPORT PVRGetDisplayClassJTable(PVRSRV_DC_DISP2SRV_KMJTABLE *psJTable);
#define DC_NOHW_MAXFORMATS (1)
#define DC_NOHW_MAXDIMS (1)
#define DC_NOHW_MAX_BACKBUFFERS (3)
typedef void * DC_HANDLE;
typedef struct DC_NOHW_BUFFER_TAG
{
DC_HANDLE hSwapChain;
DC_HANDLE hMemChunk;
/* member using IMG structures to minimise API function code */
/* replace with own structures where necessary */
#if defined(DC_NOHW_DISCONTIG_BUFFERS)
IMG_SYS_PHYADDR *psSysAddr;
#else
IMG_SYS_PHYADDR sSysAddr;
#endif
IMG_DEV_VIRTADDR sDevVAddr;
IMG_CPU_VIRTADDR sCPUVAddr;
PVRSRV_SYNC_DATA* psSyncData;
struct DC_NOHW_BUFFER_TAG *psNext;
} DC_NOHW_BUFFER;
/* DC_NOHW buffer structure */
typedef struct DC_NOHW_SWAPCHAIN_TAG
{
unsigned long ulBufferCount;
DC_NOHW_BUFFER *psBuffer;
} DC_NOHW_SWAPCHAIN;
/* kernel device information structure */
typedef struct DC_NOHW_DEVINFO_TAG
{
unsigned int uiDeviceID;
/* system surface info */
DC_NOHW_BUFFER sSystemBuffer;
/* number of supported display formats */
unsigned long ulNumFormats;
/* number of supported display dims */
unsigned long ulNumDims;
/* jump table into PVR services */
PVRSRV_DC_DISP2SRV_KMJTABLE sPVRJTable;
/* jump table into DC */
PVRSRV_DC_SRV2DISP_KMJTABLE sDCJTable;
/*
handle for connection to kernel services
- OS specific - may not be required
*/
DC_HANDLE hPVRServices;
/* back buffer info */
DC_NOHW_BUFFER asBackBuffers[DC_NOHW_MAX_BACKBUFFERS];
/* ref count */
unsigned long ulRefCount;
DC_NOHW_SWAPCHAIN *psSwapChain;
/* member using IMG structures to minimise API function code */
/* replace with own structures where necessary */
DISPLAY_INFO sDisplayInfo;
/* system surface info */
DISPLAY_FORMAT sSysFormat;
DISPLAY_DIMS sSysDims;
IMG_UINT32 ui32BufferSize;
/* list of supported display formats */
DISPLAY_FORMAT asDisplayFormatList[DC_NOHW_MAXFORMATS];
/* list of supported display formats */
DISPLAY_DIMS asDisplayDimList[DC_NOHW_MAXDIMS];
/* back buffer info */
DISPLAY_FORMAT sBackBufferFormat[DC_NOHW_MAXFORMATS];
} DC_NOHW_DEVINFO;
/*!
*****************************************************************************
* Error values
*****************************************************************************/
typedef enum _DC_ERROR_
{
DC_OK = 0,
DC_ERROR_GENERIC = 1,
DC_ERROR_OUT_OF_MEMORY = 2,
DC_ERROR_TOO_FEW_BUFFERS = 3,
DC_ERROR_INVALID_PARAMS = 4,
DC_ERROR_INIT_FAILURE = 5,
DC_ERROR_CANT_REGISTER_CALLBACK = 6,
DC_ERROR_INVALID_DEVICE = 7,
DC_ERROR_DEVICE_REGISTER_FAILED = 8
} DC_ERROR;
#ifndef UNREFERENCED_PARAMETER
#define UNREFERENCED_PARAMETER(param) (param) = (param)
#endif
DC_ERROR Init(void);
DC_ERROR Deinit(void);
#if defined(USE_BASE_VIDEO_FRAMEBUFFER) || defined (ENABLE_DISPLAY_MODE_TRACKING)
DC_ERROR OpenMiniport(void);
DC_ERROR CloseMiniport(void);
#endif /* #if defined(USE_BASE_VIDEO_FRAMEBUFFER) || defined (ENABLE_DISPLAY_MODE_TRACKING) */
#if defined(USE_BASE_VIDEO_FRAMEBUFFER)
PVRSRV_ERROR SetupDevInfo (DC_NOHW_DEVINFO *psDevInfo);
PVRSRV_ERROR FreeBackBuffers (DC_NOHW_DEVINFO *psDevInfo);
#endif
#if defined (ENABLE_DISPLAY_MODE_TRACKING)
DC_ERROR Shadow_Desktop_Resolution(DC_NOHW_DEVINFO *psDevInfo);
#endif /* #if defined (ENABLE_DISPLAY_MODE_TRACKING) */
#if !defined(DC_NOHW_DISCONTIG_BUFFERS) && !defined(USE_BASE_VIDEO_FRAMEBUFFER)
IMG_SYS_PHYADDR CpuPAddrToSysPAddr(IMG_CPU_PHYADDR cpu_paddr);
IMG_CPU_PHYADDR SysPAddrToCpuPAddr(IMG_SYS_PHYADDR sys_paddr);
#endif
/* OS Specific APIs */
DC_ERROR OpenPVRServices (DC_HANDLE *phPVRServices);
DC_ERROR ClosePVRServices (DC_HANDLE hPVRServices);
#if defined(DC_NOHW_DISCONTIG_BUFFERS)
DC_ERROR AllocDiscontigMemory(unsigned long ulSize,
DC_HANDLE * phMemChunk,
IMG_CPU_VIRTADDR *pLinAddr,
IMG_SYS_PHYADDR **pPhysAddr);
void FreeDiscontigMemory(unsigned long ulSize,
DC_HANDLE hMemChunk,
IMG_CPU_VIRTADDR LinAddr,
IMG_SYS_PHYADDR *pPhysAddr);
#else
DC_ERROR AllocContigMemory(unsigned long ulSize,
DC_HANDLE * phMemHandle,
IMG_CPU_VIRTADDR *pLinAddr,
IMG_CPU_PHYADDR *pPhysAddr);
void FreeContigMemory(unsigned long ulSize,
DC_HANDLE hMemChunk,
IMG_CPU_VIRTADDR LinAddr,
IMG_CPU_PHYADDR PhysAddr);
#endif
void *AllocKernelMem(unsigned long ulSize);
void FreeKernelMem (void *pvMem);
DC_ERROR GetLibFuncAddr (DC_HANDLE hExtDrv, char *szFunctionName, PFN_DC_GET_PVRJTABLE *ppfnFuncTable);
#if defined(__cplusplus)
}
#endif
#endif /* __DC_NOHW_H__ */
/******************************************************************************
End of file (dc_nohw.h)
******************************************************************************/
|