38
|
1 |
/*
|
|
2 |
* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
|
3 |
* All rights reserved.
|
|
4 |
* This component and the accompanying materials are made available
|
|
5 |
* under the terms of the License "Eclipse Public License v1.0"
|
|
6 |
* which accompanies this distribution, and is available
|
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
8 |
*
|
|
9 |
* Initial Contributors:
|
|
10 |
* Nokia Corporation - initial contribution.
|
|
11 |
*
|
|
12 |
* Contributors:
|
|
13 |
*
|
|
14 |
* Description: Minimalistic frame buffer driver
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
#ifndef _SVPFRAMEBUFFER_H
|
|
19 |
#define _SVPFRAMEBUFFER_H
|
|
20 |
|
|
21 |
#include <display.h>
|
|
22 |
|
|
23 |
#include <videodriver.h>
|
|
24 |
#include <system.h>
|
|
25 |
|
|
26 |
#define __SVPFRAMEBUFFER_DEBUG
|
|
27 |
|
|
28 |
#ifdef __SVPFRAMEBUFFER_DEBUG
|
|
29 |
|
|
30 |
#define __GCE_DEBUG_PRINT(a) Kern::Printf(a)
|
|
31 |
#define __GCE_DEBUG_PRINT2(a,b) Kern::Printf(a,b)
|
|
32 |
|
|
33 |
#else
|
|
34 |
|
|
35 |
#define __GCE_DEBUG_PRINT(a)
|
|
36 |
#define __GCE_DEBUG_PRINT2(a,b)
|
|
37 |
|
|
38 |
#endif
|
|
39 |
|
|
40 |
// Macro to calculate the screen buffer size
|
|
41 |
// aBpp is the number of bits-per-pixel, aPpl is the number of pixels per line and aLpp number of lines per panel
|
|
42 |
#define FRAME_BUFFER_SIZE(aBpp,aPpl,aLpp) ((aBpp/8)*aPpl*aLpp)
|
|
43 |
|
|
44 |
_LIT(KLitLcd,"SYBORG_FB");
|
|
45 |
|
|
46 |
const TUint KConfigLcdWidth = 640;
|
|
47 |
const TUint KConfigLcdHeight = 480;
|
|
48 |
const TInt KConfigLcdWidthInTwips = 9638;
|
|
49 |
const TInt KConfigLcdHeightInTwips = 7370;
|
|
50 |
const TBool KConfigIsMono = 0;
|
|
51 |
const TBool KConfigIsPalettized = 0;
|
|
52 |
const TInt KCOnfigOffsetToFirstPixel = 0;
|
|
53 |
const TBool KConfigPixelOrderRGB = 0;
|
|
54 |
const TBool KConfigPixelOrderLandscape = 1;
|
|
55 |
const TInt KConfigLcdDisplayMode = 2;
|
|
56 |
//const TInt KConfigLcdDisplayMode = 1;
|
|
57 |
const TInt KConfigLcdNumberOfDisplayModes = 3;
|
|
58 |
|
|
59 |
|
|
60 |
const TInt KConfigBitsPerPixel = 24;
|
|
61 |
const TInt KCOnfigOffsetBetweenLines = 2560;
|
|
62 |
|
|
63 |
const TInt KVSyncDfcPriority = 7 ; //priority of DFC within the queue (0 to 7, where 7 is highest)
|
|
64 |
|
|
65 |
/********************************************************************/
|
|
66 |
/* Class Definition */
|
|
67 |
/********************************************************************/
|
|
68 |
/**
|
|
69 |
* This class defines a callback mechanism that is used by a resource user to specify its callback. It contains a
|
|
70 |
* function pointer and data pointer. The function pointer specifies the user callback function to be invoked by the
|
|
71 |
* resource while the data pointer specifies the data to be passed to the callback function.
|
|
72 |
*/
|
|
73 |
class TLcdUserCallBack
|
|
74 |
{
|
|
75 |
public:
|
|
76 |
// The constructor for the callback mechanism.
|
|
77 |
TLcdUserCallBack(TInt (*aFunction)(TUint aResID, TAny* aPtr), TAny* aPtr)
|
|
78 |
|
|
79 |
{
|
|
80 |
iCbFn = aFunction;
|
|
81 |
iDataPtr = aPtr;
|
|
82 |
}
|
|
83 |
|
|
84 |
public:
|
|
85 |
// The callback function pointer.
|
|
86 |
TInt (*iCbFn)(TUint aResID, TAny* aPtr);
|
|
87 |
|
|
88 |
// Pointer to the data structure to be passed to the callback function.
|
|
89 |
TAny *iDataPtr;
|
|
90 |
};
|
|
91 |
|
|
92 |
class DLcdPowerHandler : public DPowerHandler
|
|
93 |
{
|
|
94 |
public: // from DPowerHandler
|
|
95 |
void PowerDown(TPowerState);
|
|
96 |
void PowerUp();
|
|
97 |
public: // to prevent a race condition with WServer trying to power up/down at the same time
|
|
98 |
void PowerUpDfc();
|
|
99 |
void PowerDownDfc();
|
|
100 |
public:
|
|
101 |
DLcdPowerHandler();
|
|
102 |
TInt Create();
|
|
103 |
void DisplayOn();
|
|
104 |
void DisplayOff();
|
|
105 |
TInt HalFunction(TInt aFunction, TAny* a1, TAny* a2);
|
|
106 |
|
|
107 |
void PowerUpLcd(TBool aSecure);
|
|
108 |
void PowerDownLcd();
|
|
109 |
|
|
110 |
void ScreenInfo(TScreenInfoV01& aInfo);
|
|
111 |
void WsSwitchOnScreen();
|
|
112 |
void WsSwitchOffScreen();
|
|
113 |
void HandleMsg(TMessageBase* aMsg);
|
|
114 |
void SwitchDisplay(TBool aSecure);
|
|
115 |
|
|
116 |
private:
|
|
117 |
TInt GetCurrentDisplayModeInfo(TVideoInfoV01& aInfo, TBool aSecure);
|
|
118 |
TInt GetSpecifiedDisplayModeInfo(TInt aMode, TVideoInfoV01& aInfo);
|
|
119 |
TInt SetDisplayMode(TInt aMode);
|
|
120 |
TInt AllocateFrameBuffer();
|
|
121 |
|
|
122 |
public:
|
|
123 |
IMPORT_C static TInt RegisterCallback(TLcdUserCallBack* aCbPtr);
|
|
124 |
IMPORT_C static void DeRegisterCallback(TLcdUserCallBack* aCbPtr);
|
|
125 |
|
|
126 |
private:
|
|
127 |
TBool iDisplayOn;
|
|
128 |
DPlatChunkHw* iChunk;
|
|
129 |
DPlatChunkHw* iSecureChunk;
|
|
130 |
TBool iWsSwitchOnScreen;
|
|
131 |
TBool iSecureDisplay;
|
|
132 |
|
|
133 |
public:
|
|
134 |
TDfcQue* iDfcQ;
|
|
135 |
TMessageQue iMsgQ; // to prevent a race condition with Power Manager trying to power up/down at the same time
|
|
136 |
TDfc iPowerUpDfc;
|
|
137 |
TDfc iPowerDownDfc;
|
|
138 |
|
|
139 |
private:
|
|
140 |
NFastMutex iLock;
|
|
141 |
TPhysAddr ivRamPhys;
|
|
142 |
TPhysAddr iSecurevRamPhys;
|
|
143 |
TLcdUserCallBack * iAppCallBk[2];
|
|
144 |
|
|
145 |
public:
|
|
146 |
TVideoInfoV01 iVideoInfo;
|
|
147 |
TVideoInfoV01 iSecureVideoInfo;
|
|
148 |
TInt iSize;
|
|
149 |
TLinAddr iPortAddr;
|
|
150 |
TPhysAddr iCompositionPhysical;
|
|
151 |
static DLcdPowerHandler * pLcd;
|
|
152 |
|
|
153 |
enum {
|
|
154 |
FB_ID = 0,
|
|
155 |
FB_BASE = 1,
|
|
156 |
FB_HEIGHT = 2,
|
|
157 |
FB_WIDTH = 3,
|
|
158 |
FB_ORIENTATION = 4,
|
|
159 |
FB_BLANK = 5,
|
|
160 |
FB_INT_MASK = 6,
|
|
161 |
/* begin new interface */
|
|
162 |
FB_INTERRUPT_CAUSE = 7,
|
|
163 |
FB_BPP = 8,
|
|
164 |
FB_COLOR_ORDER = 9,
|
|
165 |
FB_BYTE_ORDER = 10,
|
|
166 |
FB_PIXEL_ORDER = 11,
|
|
167 |
FB_ROW_PITCH = 12,
|
|
168 |
FB_ENABLED = 13,
|
|
169 |
FB_PALETTE_START = 0x400 >> 2,
|
|
170 |
FB_PALETTE_END = FB_PALETTE_START+256-1,
|
|
171 |
/* end new interface */
|
|
172 |
};
|
|
173 |
|
|
174 |
#define FB_INT_VSYNC (1U << 0)
|
|
175 |
#define FB_INT_BASE_UPDATE_DONE (1U << 1)
|
|
176 |
|
|
177 |
};
|
|
178 |
|
|
179 |
class DDisplayPddSyborg : public DDisplayPdd
|
|
180 |
{
|
|
181 |
|
|
182 |
public:
|
|
183 |
DDisplayPddSyborg();
|
|
184 |
~DDisplayPddSyborg();
|
|
185 |
|
|
186 |
/**
|
|
187 |
Called by the LDD to handle the device specific part of switching to Legacy mode.
|
|
188 |
|
|
189 |
@return KErrNone if successful; or one of the other system wide error codes.
|
|
190 |
*/
|
|
191 |
virtual TInt SetLegacyMode();
|
|
192 |
|
|
193 |
/**
|
|
194 |
Called by the LDD to handle the device specific part of switching to GCE mode.
|
|
195 |
|
|
196 |
@return KErrNone if successful; or one of the other system wide error codes.
|
|
197 |
*/
|
|
198 |
virtual TInt SetGceMode();
|
|
199 |
|
|
200 |
/**
|
|
201 |
Called by the LDD to handle the device specific part of setting the rotation.
|
|
202 |
|
|
203 |
@return KErrNone if successful; or one of the other system wide error codes.
|
|
204 |
*/
|
|
205 |
virtual TInt SetRotation(TInt aRotation);
|
|
206 |
|
|
207 |
/**
|
|
208 |
Called by the LDD to handle the device specific part of posting a User Buffer.
|
|
209 |
|
|
210 |
@return KErrNone if successful; or one of the other system wide error codes.
|
|
211 |
*/
|
|
212 |
virtual TInt PostUserBuffer(TBufferNode* aNode);
|
|
213 |
|
|
214 |
/**
|
|
215 |
Called by the LDD to handle the device specific part of posting a Composition Buffer
|
|
216 |
|
|
217 |
@return KErrNone if successful; or one of the other system wide error codes.
|
|
218 |
*/
|
|
219 |
virtual TInt PostCompositionBuffer(TBufferNode* aNode);
|
|
220 |
|
|
221 |
/**
|
|
222 |
Called by the LDD to handle the device specific part of posting the Legacy Buffuer
|
|
223 |
|
|
224 |
@return KErrNone if successful; or one of the other system wide error codes.
|
|
225 |
*/
|
|
226 |
virtual TInt PostLegacyBuffer();
|
|
227 |
|
|
228 |
/**
|
|
229 |
Called by the LDD to handle device specific cleanup operations when a channel is closed.
|
|
230 |
|
|
231 |
@return KErrNone if successful; or one of the other system wide error codes.
|
|
232 |
*/
|
|
233 |
virtual TInt CloseMsg();
|
|
234 |
|
|
235 |
/**
|
|
236 |
Called by the LDD to handle device specific initialisation tasks when a channel is opened.
|
|
237 |
|
|
238 |
@param aUnit The screen/hardware unit number.
|
|
239 |
@return KErrNone if successful; or one of the other system wide error codes.
|
|
240 |
*/
|
|
241 |
virtual TInt CreateChannelSetup(TInt aUnit);
|
|
242 |
|
|
243 |
/**
|
|
244 |
Called by the LDD in order to detect whether a post operation is pending. This type of
|
|
245 |
information is specific to the actual physical device.
|
|
246 |
|
|
247 |
@return ETrue if a Post operation is pending otherwise EFalse.
|
|
248 |
*/
|
|
249 |
virtual TBool PostPending();
|
|
250 |
|
|
251 |
/**
|
|
252 |
Called by the LDD to retrieve the DFC Queue created in the PDD.
|
|
253 |
|
|
254 |
@param aUnit The screen/hardware unit number.
|
|
255 |
@return A pointer to the TDfcQue object created in the PDD.
|
|
256 |
*/
|
|
257 |
virtual TDfcQue* DfcQ(TInt aUnit);
|
|
258 |
|
|
259 |
public:
|
|
260 |
static void VSyncDfcFn(TAny* aChannel);
|
|
261 |
|
|
262 |
private:
|
|
263 |
TDfcQue* iDfcQ;
|
|
264 |
|
|
265 |
//generic display info
|
|
266 |
TVideoInfoV01 iScreenInfo;
|
|
267 |
|
|
268 |
//Pointer to a buffer in the Pending state
|
|
269 |
TBufferNode* iPendingBuffer;
|
|
270 |
|
|
271 |
//Pointer to a buffer in the Active state
|
|
272 |
TBufferNode* iActiveBuffer;
|
|
273 |
|
|
274 |
DChunk * iChunk;
|
|
275 |
TLcdUserCallBack* iLcdCallback;
|
|
276 |
|
|
277 |
public:
|
|
278 |
TDfc iVSyncDfc;
|
|
279 |
};
|
|
280 |
|
|
281 |
|
|
282 |
/**
|
|
283 |
PDD Factory class
|
|
284 |
*/
|
|
285 |
|
|
286 |
class DDisplayPddFactory : public DPhysicalDevice
|
|
287 |
{
|
|
288 |
public:
|
|
289 |
DDisplayPddFactory();
|
|
290 |
|
|
291 |
virtual TInt Install();
|
|
292 |
virtual void GetCaps(TDes8& aDes) const;
|
|
293 |
virtual TInt Create(DBase*& aChannel, TInt aUnit, const TDesC8* aInfo, const TVersion& aVer);
|
|
294 |
virtual TInt Validate(TInt aDeviceType, const TDesC8* anInfo, const TVersion& aVer);
|
|
295 |
};
|
|
296 |
|
|
297 |
#endif
|