1.3.13.1607/3_00_00_08+flat+Lindent
[sgx.git] / pvr / omaplfb.h
1 /**********************************************************************
2  *
3  * Copyright(c) 2008 Imagination Technologies Ltd. All rights reserved.
4  * 
5  * This program is free software; you can redistribute it and/or modify it
6  * under the terms and conditions of the GNU General Public License,
7  * version 2, as published by the Free Software Foundation.
8  * 
9  * This program is distributed in the hope it will be useful but, except 
10  * as otherwise stated in writing, without any warranty; without even the 
11  * implied warranty of merchantability or fitness for a particular purpose. 
12  * See the GNU General Public License for more details.
13  * 
14  * You should have received a copy of the GNU General Public License along with
15  * this program; if not, write to the Free Software Foundation, Inc.,
16  * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
17  * 
18  * The full GNU General Public License is included in this distribution in
19  * the file called "COPYING".
20  *
21  * Contact Information:
22  * Imagination Technologies Ltd. <gpl-support@imgtec.com>
23  * Home Park Estate, Kings Langley, Herts, WD4 8LZ, UK 
24  *
25  ******************************************************************************/
26
27 #ifndef __OMAPLFB_H__
28 #define __OMAPLFB_H__
29
30 extern IMG_BOOL PVRGetDisplayClassJTable(PVRSRV_DC_DISP2SRV_KMJTABLE *
31                                          psJTable);
32
33 #define OMAPLCD_IRQ                     25
34
35 #define OMAPLCD_SYSCONFIG               0x0410
36 #define OMAPLCD_CONFIG                  0x0444
37 #define OMAPLCD_DEFAULT_COLOR0          0x044C
38 #define OMAPLCD_TIMING_H                0x0464
39 #define OMAPLCD_TIMING_V                0x0468
40 #define OMAPLCD_POL_FREQ                0x046C
41 #define OMAPLCD_DIVISOR                 0x0470
42 #define OMAPLCD_SIZE_DIG                0x0478
43 #define OMAPLCD_SIZE_LCD                0x047C
44 #define OMAPLCD_GFX_POSITION            0x0488
45 #define OMAPLCD_GFX_SIZE                0x048C
46 #define OMAPLCD_GFX_ATTRIBUTES          0x04a0
47 #define OMAPLCD_GFX_FIFO_THRESHOLD      0x04a4
48 #define OMAPLCD_GFX_WINDOW_SKIP         0x04b4
49
50 #define OMAPLCD_IRQSTATUS               0x0418
51 #define OMAPLCD_IRQENABLE               0x041c
52 #define OMAPLCD_CONTROL                 0x0440
53 #define OMAPLCD_GFX_BA0                 0x0480
54 #define OMAPLCD_GFX_BA1                 0x0484
55 #define OMAPLCD_GFX_ROW_INC             0x04ac
56 #define OMAPLCD_GFX_PIX_INC             0x04b0
57 #define OMAPLCD_VID1_BA0                0x04bc
58 #define OMAPLCD_VID1_BA1                0x04c0
59 #define OMAPLCD_VID1_ROW_INC            0x04d8
60 #define OMAPLCD_VID1_PIX_INC            0x04dc
61
62 #define OMAP_CONTROL_GODIGITAL          (1 << 6)
63 #define OMAP_CONTROL_GOLCD              (1 << 5)
64 #define OMAP_CONTROL_DIGITALENABLE      (1 << 1)
65 #define OMAP_CONTROL_LCDENABLE          (1 << 0)
66
67 #define OMAPLCD_INTMASK_VSYNC           (1 << 1)
68 #define OMAPLCD_INTMASK_OFF             0
69
70 typedef struct OMAPLFB_BUFFER_TAG {
71         IMG_SYS_PHYADDR sSysAddr;
72         IMG_CPU_VIRTADDR sCPUVAddr;
73         IMG_UINT32 ui32BufferSize;
74         PVRSRV_SYNC_DATA *psSyncData;
75         struct OMAPLFB_BUFFER_TAG *psNext;
76 } OMAPLFB_BUFFER;
77
78 typedef struct OMAPLFB_VSYNC_FLIP_ITEM_TAG {
79
80         IMG_HANDLE hCmdComplete;
81
82         IMG_SYS_PHYADDR *sSysAddr;
83
84         IMG_UINT32 ui32SwapInterval;
85
86         IMG_BOOL bValid;
87
88         IMG_BOOL bFlipped;
89
90         IMG_BOOL bCmdCompleted;
91
92 } OMAPLFB_VSYNC_FLIP_ITEM;
93
94 typedef struct PVRPDP_SWAPCHAIN_TAG {
95
96         IMG_UINT32 ui32BufferCount;
97
98         OMAPLFB_BUFFER *psBuffer;
99
100         OMAPLFB_VSYNC_FLIP_ITEM *psVSyncFlips;
101
102         IMG_UINT32 ui32InsertIndex;
103
104         IMG_UINT32 ui32RemoveIndex;
105
106         IMG_VOID *pvRegs;
107
108         PVRSRV_DC_DISP2SRV_KMJTABLE *psPVRJTable;
109
110         IMG_BOOL bFlushCommands;
111
112         IMG_UINT32 ui32SetFlushStateRefCount;
113
114         IMG_BOOL bBlanked;
115
116         spinlock_t *psSwapChainLock;
117 } OMAPLFB_SWAPCHAIN;
118
119 typedef struct OMAPLFB_FBINFO_TAG {
120         IMG_SYS_PHYADDR sSysAddr;
121         IMG_CPU_VIRTADDR sCPUVAddr;
122         IMG_UINT32 ui32FBSize;
123         IMG_UINT32 ui32BufferSize;
124         IMG_UINT32 ui32RoundedBufferSize;
125         IMG_UINT32 ui32Width;
126         IMG_UINT32 ui32Height;
127         IMG_UINT32 ui32ByteStride;
128
129         PVRSRV_PIXEL_FORMAT ePixelFormat;
130 } OMAPLFB_FBINFO;
131
132 typedef struct OMAPLFB_DEVINFO_TAG {
133         IMG_UINT32 ui32DeviceID;
134         DISPLAY_INFO sDisplayInfo;
135
136         OMAPLFB_BUFFER sSystemBuffer;
137
138         DISPLAY_FORMAT sDisplayFormat;
139
140         DISPLAY_DIMS sDisplayDim;
141
142         PVRSRV_DC_DISP2SRV_KMJTABLE sPVRJTable;
143
144         PVRSRV_DC_SRV2DISP_KMJTABLE sDCJTable;
145
146         OMAPLFB_FBINFO sFBInfo;
147
148         IMG_UINT32 ui32RefCount;
149
150         OMAPLFB_SWAPCHAIN *psSwapChain;
151
152         IMG_BOOL bFlushCommands;
153
154         IMG_DEV_VIRTADDR sDisplayDevVAddr;
155
156         struct fb_info *psLINFBInfo;
157
158         struct notifier_block sLINNotifBlock;
159
160         IMG_BOOL bDeviceSuspended;
161
162         spinlock_t *psSwapChainLock;
163 } OMAPLFB_DEVINFO;
164
165 #define OMAPLFB_PAGE_SIZE 4096
166 #define OMAPLFB_PAGE_MASK (OMAPLFB_PAGE_SIZE - 1)
167 #define OMAPLFB_PAGE_TRUNC (~OMAPLFB_PAGE_MASK)
168
169 #define OMAPLFB_PAGE_ROUNDUP(x) (((x) + OMAPLFB_PAGE_MASK) & OMAPLFB_PAGE_TRUNC)
170
171 #ifdef  DEBUG
172 #define DEBUG_PRINTK(x) printk x
173 #else
174 #define DEBUG_PRINTK(x)
175 #endif
176
177 #define DISPLAY_DEVICE_NAME "PowerVR OMAP Linux Display Driver"
178 #define DRVNAME "omaplfb"
179 #define DEVNAME DRVNAME
180 #define DRIVER_PREFIX DRVNAME
181
182 PVRSRV_ERROR OMAPLFBInit(IMG_VOID);
183 PVRSRV_ERROR OMAPLFBDeinit(IMG_VOID);
184
185 #ifdef  LDM_PLATFORM
186 IMG_VOID OMAPLFBDriverSuspend(IMG_VOID);
187 IMG_VOID OMAPLFBDriverResume(IMG_VOID);
188 #endif
189
190 IMG_VOID *OMAPLFBAllocKernelMem(IMG_UINT32 ui32Size);
191 IMG_VOID OMAPLFBFreeKernelMem(IMG_VOID * pvMem);
192 PVRSRV_ERROR OMAPLFBGetLibFuncAddr(IMG_CHAR * szFunctionName,
193                                    PFN_DC_GET_PVRJTABLE * ppfnFuncTable);
194 PVRSRV_ERROR OMAPLFBInstallVSyncISR(OMAPLFB_SWAPCHAIN * psSwapChain);
195 PVRSRV_ERROR OMAPLFBUninstallVSyncISR(OMAPLFB_SWAPCHAIN * psSwapChain);
196 IMG_BOOL OMAPLFBVSyncIHandler(OMAPLFB_SWAPCHAIN * psSwapChain);
197 IMG_VOID OMAPLFBEnableVSyncInterrupt(OMAPLFB_SWAPCHAIN * psSwapChain);
198 IMG_VOID OMAPLFBDisableVSyncInterrupt(OMAPLFB_SWAPCHAIN * psSwapChain);
199 #if defined (SUPPORT_TI_DSS_FW)
200 IMG_VOID OMAPLFBEnableDisplayRegisterAccess(IMG_VOID);
201 IMG_VOID OMAPLFBDisableDisplayRegisterAccess(IMG_VOID);
202 #endif
203 #if defined (CONFIG_OMAP2_DSS)
204 IMG_VOID OMAPLFBFlipDSS2(OMAPLFB_SWAPCHAIN * psSwapChain, IMG_UINT32 aPhyAddr);
205 #endif
206 IMG_VOID OMAPLFBFlip(OMAPLFB_SWAPCHAIN * psSwapChain, IMG_UINT32 aPhyAddr);
207
208 #endif