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
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
|
/*************************************************************************/ /*!
@Title OMAP Linux 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.
*/ /**************************************************************************/
#ifndef __OMAPLFB_H__
#define __OMAPLFB_H__
#include <linux/version.h>
#include <asm/atomic.h>
#include <linux/kernel.h>
#include <linux/console.h>
#include <linux/fb.h>
#include <linux/module.h>
#include <linux/string.h>
#include <linux/notifier.h>
#include <linux/mutex.h>
#ifdef CONFIG_HAS_EARLYSUSPEND
#include <linux/earlysuspend.h>
#endif
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
#define OMAPLFB_CONSOLE_LOCK() console_lock()
#define OMAPLFB_CONSOLE_UNLOCK() console_unlock()
#else
#define OMAPLFB_CONSOLE_LOCK() acquire_console_sem()
#define OMAPLFB_CONSOLE_UNLOCK() release_console_sem()
#endif
#define unref__ __attribute__ ((unused))
typedef void * OMAPLFB_HANDLE;
typedef bool OMAPLFB_BOOL, *OMAPLFB_PBOOL;
#define OMAPLFB_FALSE false
#define OMAPLFB_TRUE true
typedef atomic_t OMAPLFB_ATOMIC_BOOL;
typedef atomic_t OMAPLFB_ATOMIC_INT;
/* OMAPLFB buffer structure */
typedef struct OMAPLFB_BUFFER_TAG
{
struct OMAPLFB_BUFFER_TAG *psNext;
struct OMAPLFB_DEVINFO_TAG *psDevInfo;
struct work_struct sWork;
/* Position of this buffer in the virtual framebuffer */
unsigned long ulYOffset;
/* IMG structures used, to minimise API function code */
/* replace with own structures where necessary */
IMG_SYS_PHYADDR sSysAddr;
IMG_CPU_VIRTADDR sCPUVAddr;
PVRSRV_SYNC_DATA *psSyncData;
OMAPLFB_HANDLE hCmdComplete;
unsigned long ulSwapInterval;
} OMAPLFB_BUFFER;
/* OMAPLFB swapchain structure */
typedef struct OMAPLFB_SWAPCHAIN_TAG
{
/* Swap chain ID */
unsigned int uiSwapChainID;
/* number of buffers in swapchain */
unsigned long ulBufferCount;
/* list of buffers in the swapchain */
OMAPLFB_BUFFER *psBuffer;
/* Swap chain work queue */
struct workqueue_struct *psWorkQueue;
/*
* Set if we didn't manage to wait for VSync on last swap,
* or if we think we need to wait for VSync on the next flip.
* The flag helps to avoid jitter when the screen is
* unblanked, by forcing an extended wait for VSync before
* attempting the next flip.
*/
OMAPLFB_BOOL bNotVSynced;
/* Previous number of blank events */
int iBlankEvents;
/* Framebuffer Device ID for messages (e.g. printk) */
unsigned int uiFBDevID;
} OMAPLFB_SWAPCHAIN;
typedef struct OMAPLFB_FBINFO_TAG
{
unsigned long ulFBSize;
unsigned long ulBufferSize;
unsigned long ulRoundedBufferSize;
unsigned long ulWidth;
unsigned long ulHeight;
unsigned long ulByteStride;
unsigned long ulPhysicalWidthmm;
unsigned long ulPhysicalHeightmm;
/* IMG structures used, to minimise API function code */
/* replace with own structures where necessary */
IMG_SYS_PHYADDR sSysAddr;//system physical address
IMG_CPU_VIRTADDR sCPUVAddr;
/* pixelformat of system/primary surface */
PVRSRV_PIXEL_FORMAT ePixelFormat;
#if defined(CONFIG_DSSCOMP)
OMAPLFB_BOOL bIs2D;
IMG_SYS_PHYADDR *psPageList;
struct ion_handle *psIONHandle;
IMG_UINT32 uiBytesPerPixel;
#endif
} OMAPLFB_FBINFO;
/* kernel device information structure */
typedef struct OMAPLFB_DEVINFO_TAG
{
/* Framebuffer Device ID */
unsigned int uiFBDevID;
/* PVR Device ID */
unsigned int uiPVRDevID;
/* Swapchain create/destroy mutex */
struct mutex sCreateSwapChainMutex;
/* system surface info */
OMAPLFB_BUFFER sSystemBuffer;
/* jump table into PVR services */
PVRSRV_DC_DISP2SRV_KMJTABLE sPVRJTable;
/* jump table into DC */
PVRSRV_DC_SRV2DISP_KMJTABLE sDCJTable;
/* fb info structure */
OMAPLFB_FBINFO sFBInfo;
/* Only one swapchain supported by this device so hang it here */
OMAPLFB_SWAPCHAIN *psSwapChain;
/* Swap chain ID */
unsigned int uiSwapChainID;
/* True if PVR Services is flushing its command queues */
OMAPLFB_ATOMIC_BOOL sFlushCommands;
/* pointer to linux frame buffer information structure */
struct fb_info *psLINFBInfo;
/* Linux Framebuffer event notification block */
struct notifier_block sLINNotifBlock;
/* IMG structures used, to minimise API function code */
/* replace with own structures where necessary */
/* Address of the surface being displayed */
IMG_DEV_VIRTADDR sDisplayDevVAddr;
DISPLAY_INFO sDisplayInfo;
/* Display format */
DISPLAY_FORMAT sDisplayFormat;
/* Display dimensions */
DISPLAY_DIMS sDisplayDim;
/* True if screen is blanked */
OMAPLFB_ATOMIC_BOOL sBlanked;
/* Number of blank/unblank events */
OMAPLFB_ATOMIC_INT sBlankEvents;
#ifdef CONFIG_HAS_EARLYSUSPEND
/* Set by early suspend */
OMAPLFB_ATOMIC_BOOL sEarlySuspendFlag;
struct early_suspend sEarlySuspend;
#endif
#if defined(SUPPORT_DRI_DRM)
OMAPLFB_ATOMIC_BOOL sLeaveVT;
#endif
} OMAPLFB_DEVINFO;
#define OMAPLFB_PAGE_SIZE 4096
/* DEBUG only printk */
#ifdef DEBUG
#define DEBUG_PRINTK(x) printk x
#else
#define DEBUG_PRINTK(x)
#endif
#define DISPLAY_DEVICE_NAME "PowerVR OMAP Linux Display Driver"
#define DRVNAME "omaplfb"
#define DEVNAME DRVNAME
#define DRIVER_PREFIX DRVNAME
/*!
*****************************************************************************
* Error values
*****************************************************************************/
typedef enum _OMAPLFB_ERROR_
{
OMAPLFB_OK = 0,
OMAPLFB_ERROR_GENERIC = 1,
OMAPLFB_ERROR_OUT_OF_MEMORY = 2,
OMAPLFB_ERROR_TOO_FEW_BUFFERS = 3,
OMAPLFB_ERROR_INVALID_PARAMS = 4,
OMAPLFB_ERROR_INIT_FAILURE = 5,
OMAPLFB_ERROR_CANT_REGISTER_CALLBACK = 6,
OMAPLFB_ERROR_INVALID_DEVICE = 7,
OMAPLFB_ERROR_DEVICE_REGISTER_FAILED = 8,
OMAPLFB_ERROR_SET_UPDATE_MODE_FAILED = 9
} OMAPLFB_ERROR;
typedef enum _OMAPLFB_UPDATE_MODE_
{
OMAPLFB_UPDATE_MODE_UNDEFINED = 0,
OMAPLFB_UPDATE_MODE_MANUAL = 1,
OMAPLFB_UPDATE_MODE_AUTO = 2,
OMAPLFB_UPDATE_MODE_DISABLED = 3
} OMAPLFB_UPDATE_MODE;
#ifndef UNREFERENCED_PARAMETER
#define UNREFERENCED_PARAMETER(param) (param) = (param)
#endif
OMAPLFB_ERROR OMAPLFBInit(void);
OMAPLFB_ERROR OMAPLFBDeInit(void);
/* OS Specific APIs */
OMAPLFB_DEVINFO *OMAPLFBGetDevInfoPtr(unsigned uiFBDevID);
unsigned OMAPLFBMaxFBDevIDPlusOne(void);
void *OMAPLFBAllocKernelMem(unsigned long ulSize);
void OMAPLFBFreeKernelMem(void *pvMem);
OMAPLFB_ERROR OMAPLFBGetLibFuncAddr(char *szFunctionName, PFN_DC_GET_PVRJTABLE *ppfnFuncTable);
OMAPLFB_ERROR OMAPLFBCreateSwapQueue (OMAPLFB_SWAPCHAIN *psSwapChain);
void OMAPLFBDestroySwapQueue(OMAPLFB_SWAPCHAIN *psSwapChain);
void OMAPLFBInitBufferForSwap(OMAPLFB_BUFFER *psBuffer);
void OMAPLFBSwapHandler(OMAPLFB_BUFFER *psBuffer);
void OMAPLFBQueueBufferForSwap(OMAPLFB_SWAPCHAIN *psSwapChain, OMAPLFB_BUFFER *psBuffer);
void OMAPLFBFlip(OMAPLFB_DEVINFO *psDevInfo, OMAPLFB_BUFFER *psBuffer);
OMAPLFB_UPDATE_MODE OMAPLFBGetUpdateMode(OMAPLFB_DEVINFO *psDevInfo);
OMAPLFB_BOOL OMAPLFBSetUpdateMode(OMAPLFB_DEVINFO *psDevInfo, OMAPLFB_UPDATE_MODE eMode);
OMAPLFB_BOOL OMAPLFBWaitForVSync(OMAPLFB_DEVINFO *psDevInfo);
OMAPLFB_BOOL OMAPLFBManualSync(OMAPLFB_DEVINFO *psDevInfo);
OMAPLFB_BOOL OMAPLFBCheckModeAndSync(OMAPLFB_DEVINFO *psDevInfo);
OMAPLFB_ERROR OMAPLFBUnblankDisplay(OMAPLFB_DEVINFO *psDevInfo);
OMAPLFB_ERROR OMAPLFBEnableLFBEventNotification(OMAPLFB_DEVINFO *psDevInfo);
OMAPLFB_ERROR OMAPLFBDisableLFBEventNotification(OMAPLFB_DEVINFO *psDevInfo);
void OMAPLFBCreateSwapChainLockInit(OMAPLFB_DEVINFO *psDevInfo);
void OMAPLFBCreateSwapChainLockDeInit(OMAPLFB_DEVINFO *psDevInfo);
void OMAPLFBCreateSwapChainLock(OMAPLFB_DEVINFO *psDevInfo);
void OMAPLFBCreateSwapChainUnLock(OMAPLFB_DEVINFO *psDevInfo);
void OMAPLFBAtomicBoolInit(OMAPLFB_ATOMIC_BOOL *psAtomic, OMAPLFB_BOOL bVal);
void OMAPLFBAtomicBoolDeInit(OMAPLFB_ATOMIC_BOOL *psAtomic);
void OMAPLFBAtomicBoolSet(OMAPLFB_ATOMIC_BOOL *psAtomic, OMAPLFB_BOOL bVal);
OMAPLFB_BOOL OMAPLFBAtomicBoolRead(OMAPLFB_ATOMIC_BOOL *psAtomic);
void OMAPLFBAtomicIntInit(OMAPLFB_ATOMIC_INT *psAtomic, int iVal);
void OMAPLFBAtomicIntDeInit(OMAPLFB_ATOMIC_INT *psAtomic);
void OMAPLFBAtomicIntSet(OMAPLFB_ATOMIC_INT *psAtomic, int iVal);
int OMAPLFBAtomicIntRead(OMAPLFB_ATOMIC_INT *psAtomic);
void OMAPLFBAtomicIntInc(OMAPLFB_ATOMIC_INT *psAtomic);
#if defined(DEBUG)
void OMAPLFBPrintInfo(OMAPLFB_DEVINFO *psDevInfo);
#else
#define OMAPLFBPrintInfo(psDevInfo)
#endif
#endif /* __OMAPLFB_H__ */
/******************************************************************************
End of file (omaplfb.h)
******************************************************************************/
|