[android-sdk/device-ti-proprietary-open.git] / jacinto6 / sgx_src / eurasia_km / services4 / 3rdparty / dc_omapfb3_linux / omaplfb.h
1 /*************************************************************************/ /*!
2 @Title OMAP Linux display driver structures and prototypes
3 @Copyright Copyright (c) Imagination Technologies Ltd. All Rights Reserved
4 @License Dual MIT/GPLv2
6 The contents of this file are subject to the MIT license as set out below.
8 Permission is hereby granted, free of charge, to any person obtaining a copy
9 of this software and associated documentation files (the "Software"), to deal
10 in the Software without restriction, including without limitation the rights
11 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12 copies of the Software, and to permit persons to whom the Software is
13 furnished to do so, subject to the following conditions:
15 The above copyright notice and this permission notice shall be included in
16 all copies or substantial portions of the Software.
18 Alternatively, the contents of this file may be used under the terms of
19 the GNU General Public License Version 2 ("GPL") in which case the provisions
20 of GPL are applicable instead of those above.
22 If you wish to allow use of your version of this file only under the terms of
23 GPL, and not to allow others to use your version of this file under the terms
24 of the MIT license, indicate your decision by deleting the provisions above
25 and replace them with the notice and other provisions required by GPL as set
26 out in the file called "GPL-COPYING" included in this distribution. If you do
27 not delete the provisions above, a recipient may use your version of this file
28 under the terms of either the MIT license or GPL.
30 This License is also included in this distribution in the file called
31 "MIT-COPYING".
33 EXCEPT AS OTHERWISE STATED IN A NEGOTIATED AGREEMENT: (A) THE SOFTWARE IS
34 PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
35 BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
36 PURPOSE AND NONINFRINGEMENT; AND (B) IN NO EVENT SHALL THE AUTHORS OR
37 COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
38 IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
39 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
40 */ /**************************************************************************/
41 #ifndef __OMAPLFB_H__
42 #define __OMAPLFB_H__
44 #include <linux/version.h>
46 #include <asm/atomic.h>
48 #include <linux/kernel.h>
49 #include <linux/console.h>
50 #include <linux/fb.h>
51 #include <linux/module.h>
52 #include <linux/string.h>
53 #include <linux/notifier.h>
54 #include <linux/mutex.h>
56 #ifdef CONFIG_HAS_EARLYSUSPEND
57 #include <linux/earlysuspend.h>
58 #endif
60 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
61 #define OMAPLFB_CONSOLE_LOCK() console_lock()
62 #define OMAPLFB_CONSOLE_UNLOCK() console_unlock()
63 #else
64 #define OMAPLFB_CONSOLE_LOCK() acquire_console_sem()
65 #define OMAPLFB_CONSOLE_UNLOCK() release_console_sem()
66 #endif
68 #define unref__ __attribute__ ((unused))
70 typedef void * OMAPLFB_HANDLE;
72 typedef bool OMAPLFB_BOOL, *OMAPLFB_PBOOL;
73 #define OMAPLFB_FALSE false
74 #define OMAPLFB_TRUE true
76 typedef atomic_t OMAPLFB_ATOMIC_BOOL;
78 typedef atomic_t OMAPLFB_ATOMIC_INT;
80 /* OMAPLFB buffer structure */
81 typedef struct OMAPLFB_BUFFER_TAG
82 {
83 struct OMAPLFB_BUFFER_TAG *psNext;
84 struct OMAPLFB_DEVINFO_TAG *psDevInfo;
86 struct work_struct sWork;
88 /* Position of this buffer in the virtual framebuffer */
89 unsigned long ulYOffset;
91 /* IMG structures used, to minimise API function code */
92 /* replace with own structures where necessary */
93 IMG_SYS_PHYADDR sSysAddr;
94 IMG_CPU_VIRTADDR sCPUVAddr;
95 PVRSRV_SYNC_DATA *psSyncData;
97 OMAPLFB_HANDLE hCmdComplete;
98 unsigned long ulSwapInterval;
99 } OMAPLFB_BUFFER;
101 /* OMAPLFB swapchain structure */
102 typedef struct OMAPLFB_SWAPCHAIN_TAG
103 {
104 /* Swap chain ID */
105 unsigned int uiSwapChainID;
107 /* number of buffers in swapchain */
108 unsigned long ulBufferCount;
110 /* list of buffers in the swapchain */
111 OMAPLFB_BUFFER *psBuffer;
113 /* Swap chain work queue */
114 struct workqueue_struct *psWorkQueue;
116 /*
117 * Set if we didn't manage to wait for VSync on last swap,
118 * or if we think we need to wait for VSync on the next flip.
119 * The flag helps to avoid jitter when the screen is
120 * unblanked, by forcing an extended wait for VSync before
121 * attempting the next flip.
122 */
123 OMAPLFB_BOOL bNotVSynced;
125 /* Previous number of blank events */
126 int iBlankEvents;
128 /* Framebuffer Device ID for messages (e.g. printk) */
129 unsigned int uiFBDevID;
130 } OMAPLFB_SWAPCHAIN;
132 typedef struct OMAPLFB_FBINFO_TAG
133 {
134 unsigned long ulFBSize;
135 unsigned long ulBufferSize;
136 unsigned long ulRoundedBufferSize;
137 unsigned long ulWidth;
138 unsigned long ulHeight;
139 unsigned long ulByteStride;
140 unsigned long ulPhysicalWidthmm;
141 unsigned long ulPhysicalHeightmm;
143 /* IMG structures used, to minimise API function code */
144 /* replace with own structures where necessary */
145 IMG_SYS_PHYADDR sSysAddr;//system physical address
146 IMG_CPU_VIRTADDR sCPUVAddr;
148 /* pixelformat of system/primary surface */
149 PVRSRV_PIXEL_FORMAT ePixelFormat;
151 #if defined(CONFIG_DSSCOMP)
152 OMAPLFB_BOOL bIs2D;
153 IMG_SYS_PHYADDR *psPageList;
154 struct ion_handle *psIONHandle;
155 IMG_UINT32 uiBytesPerPixel;
156 #endif
157 } OMAPLFB_FBINFO;
159 /* kernel device information structure */
160 typedef struct OMAPLFB_DEVINFO_TAG
161 {
162 /* Framebuffer Device ID */
163 unsigned int uiFBDevID;
165 /* PVR Device ID */
166 unsigned int uiPVRDevID;
168 /* Swapchain create/destroy mutex */
169 struct mutex sCreateSwapChainMutex;
171 /* system surface info */
172 OMAPLFB_BUFFER sSystemBuffer;
174 /* jump table into PVR services */
175 PVRSRV_DC_DISP2SRV_KMJTABLE sPVRJTable;
177 /* jump table into DC */
178 PVRSRV_DC_SRV2DISP_KMJTABLE sDCJTable;
180 /* fb info structure */
181 OMAPLFB_FBINFO sFBInfo;
183 /* Only one swapchain supported by this device so hang it here */
184 OMAPLFB_SWAPCHAIN *psSwapChain;
186 /* Swap chain ID */
187 unsigned int uiSwapChainID;
189 /* True if PVR Services is flushing its command queues */
190 OMAPLFB_ATOMIC_BOOL sFlushCommands;
192 /* pointer to linux frame buffer information structure */
193 struct fb_info *psLINFBInfo;
195 /* Linux Framebuffer event notification block */
196 struct notifier_block sLINNotifBlock;
198 /* IMG structures used, to minimise API function code */
199 /* replace with own structures where necessary */
201 /* Address of the surface being displayed */
202 IMG_DEV_VIRTADDR sDisplayDevVAddr;
204 DISPLAY_INFO sDisplayInfo;
206 /* Display format */
207 DISPLAY_FORMAT sDisplayFormat;
209 /* Display dimensions */
210 DISPLAY_DIMS sDisplayDim;
212 /* True if screen is blanked */
213 OMAPLFB_ATOMIC_BOOL sBlanked;
215 /* Number of blank/unblank events */
216 OMAPLFB_ATOMIC_INT sBlankEvents;
218 #ifdef CONFIG_HAS_EARLYSUSPEND
219 /* Set by early suspend */
220 OMAPLFB_ATOMIC_BOOL sEarlySuspendFlag;
222 struct early_suspend sEarlySuspend;
223 #endif
225 #if defined(SUPPORT_DRI_DRM)
226 OMAPLFB_ATOMIC_BOOL sLeaveVT;
227 #endif
229 } OMAPLFB_DEVINFO;
231 #define OMAPLFB_PAGE_SIZE 4096
233 /* DEBUG only printk */
234 #ifdef DEBUG
235 #define DEBUG_PRINTK(x) printk x
236 #else
237 #define DEBUG_PRINTK(x)
238 #endif
240 #define DISPLAY_DEVICE_NAME "PowerVR OMAP Linux Display Driver"
241 #define DRVNAME "omaplfb"
242 #define DEVNAME DRVNAME
243 #define DRIVER_PREFIX DRVNAME
245 /*!
246 *****************************************************************************
247 * Error values
248 *****************************************************************************/
249 typedef enum _OMAPLFB_ERROR_
250 {
251 OMAPLFB_OK = 0,
252 OMAPLFB_ERROR_GENERIC = 1,
253 OMAPLFB_ERROR_OUT_OF_MEMORY = 2,
254 OMAPLFB_ERROR_TOO_FEW_BUFFERS = 3,
255 OMAPLFB_ERROR_INVALID_PARAMS = 4,
256 OMAPLFB_ERROR_INIT_FAILURE = 5,
257 OMAPLFB_ERROR_CANT_REGISTER_CALLBACK = 6,
258 OMAPLFB_ERROR_INVALID_DEVICE = 7,
259 OMAPLFB_ERROR_DEVICE_REGISTER_FAILED = 8,
260 OMAPLFB_ERROR_SET_UPDATE_MODE_FAILED = 9
261 } OMAPLFB_ERROR;
263 typedef enum _OMAPLFB_UPDATE_MODE_
264 {
265 OMAPLFB_UPDATE_MODE_UNDEFINED = 0,
266 OMAPLFB_UPDATE_MODE_MANUAL = 1,
267 OMAPLFB_UPDATE_MODE_AUTO = 2,
268 OMAPLFB_UPDATE_MODE_DISABLED = 3
269 } OMAPLFB_UPDATE_MODE;
271 #ifndef UNREFERENCED_PARAMETER
272 #define UNREFERENCED_PARAMETER(param) (param) = (param)
273 #endif
275 OMAPLFB_ERROR OMAPLFBInit(void);
276 OMAPLFB_ERROR OMAPLFBDeInit(void);
278 /* OS Specific APIs */
279 OMAPLFB_DEVINFO *OMAPLFBGetDevInfoPtr(unsigned uiFBDevID);
280 unsigned OMAPLFBMaxFBDevIDPlusOne(void);
281 void *OMAPLFBAllocKernelMem(unsigned long ulSize);
282 void OMAPLFBFreeKernelMem(void *pvMem);
283 OMAPLFB_ERROR OMAPLFBGetLibFuncAddr(char *szFunctionName, PFN_DC_GET_PVRJTABLE *ppfnFuncTable);
284 OMAPLFB_ERROR OMAPLFBCreateSwapQueue (OMAPLFB_SWAPCHAIN *psSwapChain);
285 void OMAPLFBDestroySwapQueue(OMAPLFB_SWAPCHAIN *psSwapChain);
286 void OMAPLFBInitBufferForSwap(OMAPLFB_BUFFER *psBuffer);
287 void OMAPLFBSwapHandler(OMAPLFB_BUFFER *psBuffer);
288 void OMAPLFBQueueBufferForSwap(OMAPLFB_SWAPCHAIN *psSwapChain, OMAPLFB_BUFFER *psBuffer);
289 void OMAPLFBFlip(OMAPLFB_DEVINFO *psDevInfo, OMAPLFB_BUFFER *psBuffer);
290 OMAPLFB_UPDATE_MODE OMAPLFBGetUpdateMode(OMAPLFB_DEVINFO *psDevInfo);
291 OMAPLFB_BOOL OMAPLFBSetUpdateMode(OMAPLFB_DEVINFO *psDevInfo, OMAPLFB_UPDATE_MODE eMode);
292 OMAPLFB_BOOL OMAPLFBWaitForVSync(OMAPLFB_DEVINFO *psDevInfo);
293 OMAPLFB_BOOL OMAPLFBManualSync(OMAPLFB_DEVINFO *psDevInfo);
294 OMAPLFB_BOOL OMAPLFBCheckModeAndSync(OMAPLFB_DEVINFO *psDevInfo);
295 OMAPLFB_ERROR OMAPLFBUnblankDisplay(OMAPLFB_DEVINFO *psDevInfo);
296 OMAPLFB_ERROR OMAPLFBEnableLFBEventNotification(OMAPLFB_DEVINFO *psDevInfo);
297 OMAPLFB_ERROR OMAPLFBDisableLFBEventNotification(OMAPLFB_DEVINFO *psDevInfo);
298 void OMAPLFBCreateSwapChainLockInit(OMAPLFB_DEVINFO *psDevInfo);
299 void OMAPLFBCreateSwapChainLockDeInit(OMAPLFB_DEVINFO *psDevInfo);
300 void OMAPLFBCreateSwapChainLock(OMAPLFB_DEVINFO *psDevInfo);
301 void OMAPLFBCreateSwapChainUnLock(OMAPLFB_DEVINFO *psDevInfo);
302 void OMAPLFBAtomicBoolInit(OMAPLFB_ATOMIC_BOOL *psAtomic, OMAPLFB_BOOL bVal);
303 void OMAPLFBAtomicBoolDeInit(OMAPLFB_ATOMIC_BOOL *psAtomic);
304 void OMAPLFBAtomicBoolSet(OMAPLFB_ATOMIC_BOOL *psAtomic, OMAPLFB_BOOL bVal);
305 OMAPLFB_BOOL OMAPLFBAtomicBoolRead(OMAPLFB_ATOMIC_BOOL *psAtomic);
306 void OMAPLFBAtomicIntInit(OMAPLFB_ATOMIC_INT *psAtomic, int iVal);
307 void OMAPLFBAtomicIntDeInit(OMAPLFB_ATOMIC_INT *psAtomic);
308 void OMAPLFBAtomicIntSet(OMAPLFB_ATOMIC_INT *psAtomic, int iVal);
309 int OMAPLFBAtomicIntRead(OMAPLFB_ATOMIC_INT *psAtomic);
310 void OMAPLFBAtomicIntInc(OMAPLFB_ATOMIC_INT *psAtomic);
312 #if defined(DEBUG)
313 void OMAPLFBPrintInfo(OMAPLFB_DEVINFO *psDevInfo);
314 #else
315 #define OMAPLFBPrintInfo(psDevInfo)
316 #endif
318 #endif /* __OMAPLFB_H__ */
320 /******************************************************************************
321 End of file (omaplfb.h)
322 ******************************************************************************/