author | arunabha |
Tue, 09 Feb 2010 19:13:57 +0000 | |
changeset 25 | 524118fd998f |
parent 0 | 6663340f3fc9 |
child 34 | 161f6b2f6990 |
permissions | -rwxr-xr-x |
0 | 1 |
// Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies). |
2 |
// All rights reserved. |
|
3 |
// This component and the accompanying materials are made available |
|
4 |
// under the terms of the License "Eclipse Public License v1.0" |
|
5 |
// which accompanies this distribution, and is available |
|
6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 |
// |
|
8 |
// Initial Contributors: |
|
9 |
// Nokia Corporation - initial contribution. |
|
10 |
// |
|
11 |
// Contributors: |
|
12 |
// |
|
13 |
// Description: |
|
14 |
// omap3530/beagle_drivers/lcd/lcd.cpp |
|
15 |
// Implementation of an LCD driver. |
|
16 |
// This file is part of the Beagle Base port |
|
17 |
// N.B. This sample code assumes that the display supports setting the backlight on or off, |
|
18 |
// as well as adjusting the contrast and the brightness. |
|
19 |
// |
|
20 |
||
21 |
||
22 |
||
23 |
||
24 |
||
25 |
#include <videodriver.h> |
|
26 |
#include <platform.h> |
|
27 |
#include <nkern.h> |
|
28 |
#include <kernel.h> |
|
29 |
#include <kern_priv.h> |
|
30 |
#include <kpower.h> |
|
31 |
#include <assp/omap3530_assp/omap3530_assp_priv.h> |
|
32 |
#include <assp/omap3530_assp/omap3530_hardware_base.h> |
|
33 |
#include <assp/omap3530_assp/omap3530_prcm.h> |
|
34 |
||
35 |
#define DSS_SYSCONFIG 0x48050010 |
|
36 |
#define DISPC_SYSSTATUS 0x48050414 |
|
37 |
||
38 |
#define DISPC_SYSCONFIG 0x48050410 |
|
39 |
#define DISPC_CONFIG 0x48050444 |
|
40 |
#define DISPC_DEFAULT_COLOR0 0x4805044c |
|
41 |
#define DISPC_TRANS_COLOR0 0x48050454 |
|
42 |
||
43 |
#define DISPC_TIMING_H 0x48050464 |
|
44 |
#define DISPC_TIMING_V 0x48050468 |
|
45 |
#define DISPC_POL_FREQ 0x4805046c |
|
46 |
#define DISPC_DIVISOR 0x48050470 |
|
47 |
#define DISPC_SIZE_LCD 0x4805047c |
|
48 |
||
49 |
#define DISPC_GFX_BA1 0x48050480 |
|
50 |
#define DISPC_GFX_BA2 0x48050484 |
|
51 |
#define DISPC_GFX_POSITION 0x48050488 |
|
52 |
#define DISPC_GFX_SIZE 0x4805048c |
|
53 |
#define DISPC_GFX_ATTRIBUTES 0x480504a0 |
|
54 |
||
55 |
#define DISPC_GFX_FIFO_THRESHOLD 0x480504a4 |
|
56 |
#define DISPC_GFX_FIFO_SIZE_STATUS 0x480504a8 |
|
57 |
#define DISPC_GFX_ROW_INC 0x480504ac |
|
58 |
#define DISPC_GFX_PIXEL_INC 0x480504b0 |
|
59 |
#define DISPC_GFX_WINDOW_SKIP 0x480504b4 |
|
60 |
#define DISPC_GFX_TABLE_BA 0x480504b8 |
|
61 |
||
62 |
#define DISPC_CONTROL 0x48050440 |
|
63 |
||
64 |
#define GET_REGISTER(Reg) *( (TUint *) Omap3530HwBase::TVirtual<Reg>::Value ) |
|
65 |
#define SET_REGISTER(Reg,Val) *( (TUint *) Omap3530HwBase::TVirtual<Reg>::Value ) = Val |
|
66 |
||
67 |
#define _MODE_1280x1024_ |
|
68 |
//#define _MODE_1024x768_ |
|
69 |
#ifdef _MODE_800x600_ |
|
70 |
// ModeLine "800x600@60" 40.0 800 840 968 1056 600 601 605 628 +hsync +vsync |
|
71 |
// Decoded by: http://www.tkk.fi/Misc/Electronics/faq/vga2rgb/calc.html |
|
72 |
# define PIXEL_CLK 40000 |
|
73 |
# define H_DISP 800 |
|
74 |
# define H_FPORCH 40 |
|
75 |
# define H_SYNC 128 |
|
76 |
# define H_BPORCH 88 |
|
77 |
# define H_SYNC_POL 1 |
|
78 |
# define V_DISP 600 |
|
79 |
# define V_FPORCH 1 |
|
80 |
# define V_SYNC 4 |
|
81 |
# define V_BPORCH 23 |
|
82 |
# define V_SYNC_POL 1 |
|
83 |
# define INTERLACE_ENABLE 0 |
|
84 |
#endif |
|
85 |
#ifdef _MODE_1024x768_ |
|
86 |
// ModeLine "1024x768@60" 65.0 1024 1048 1184 1344 768 771 777 806 -hsync -vsync |
|
87 |
// Decoded by: http://www.tkk.fi/Misc/Electronics/faq/vga2rgb/calc.html |
|
88 |
# define PIXEL_CLK 65000 |
|
89 |
# define H_DISP 1024 |
|
90 |
# define H_FPORCH 24 |
|
91 |
# define H_SYNC 136 |
|
92 |
# define H_BPORCH 160 |
|
93 |
# define H_SYNC_POL 0 |
|
94 |
# define V_DISP 768 |
|
95 |
# define V_FPORCH 3 |
|
96 |
# define V_SYNC 6 |
|
97 |
# define V_BPORCH 29 |
|
98 |
# define V_SYNC_POL 0 |
|
99 |
# define INTERLACE_ENABLE 0 |
|
100 |
#endif |
|
101 |
#ifdef _MODE_1280x1024_ |
|
102 |
// ModeLine "1280x1024@60" 108.0 1280 1328 1440 1688 1024 1025 1028 1066 +hsync +vsync |
|
103 |
// Decoded by: http://www.tkk.fi/Misc/Electronics/faq/vga2rgb/calc.html |
|
104 |
# define PIXEL_CLK 108000 |
|
105 |
# define H_DISP 1280 |
|
106 |
# define H_FPORCH 48 |
|
107 |
# define H_SYNC 112 |
|
108 |
# define H_BPORCH 248 |
|
109 |
# define H_SYNC_POL 1 |
|
110 |
# define V_DISP 1024 |
|
111 |
# define V_FPORCH 1 |
|
112 |
# define V_SYNC 3 |
|
113 |
# define V_BPORCH 38 |
|
114 |
# define V_SYNC_POL 1 |
|
115 |
# define INTERLACE_ENABLE 0 |
|
116 |
#endif |
|
117 |
||
118 |
||
119 |
||
120 |
// TO DO: (mandatory) |
|
121 |
// If the display supports Contrast and/or Brightness control then supply the following defines: |
|
122 |
// This is only example code... you may need to modify it for your hardware |
|
123 |
const TInt KConfigInitialDisplayContrast = 128; |
|
124 |
const TInt KConfigLcdMinDisplayContrast = 1; |
|
125 |
const TInt KConfigLcdMaxDisplayContrast = 255; |
|
126 |
const TInt KConfigInitialDisplayBrightness = 128; |
|
127 |
const TInt KConfigLcdMinDisplayBrightness = 1; |
|
128 |
const TInt KConfigLcdMaxDisplayBrightness = 255; |
|
129 |
||
130 |
// TO DO: (mandatory) |
|
131 |
// define a macro to calculate the screen buffer size |
|
132 |
// This is only example code... you may need to modify it for your hardware |
|
133 |
// aBpp is the number of bits-per-pixel, aPpl is the number of pixels per line and |
|
134 |
// aLpp number of lines per panel |
|
135 |
#define FRAME_BUFFER_SIZE(aBpp,aPpl,aLpp) (aBpp*aPpl*aLpp)/8 |
|
136 |
||
137 |
||
138 |
// TO DO: (mandatory) |
|
139 |
// define the physical screen dimensions |
|
140 |
// This is only example code... you need to modify it for your hardware |
|
25
524118fd998f
Fixes for the Keyboard mapping , serial Mouse and the LCD drivers
arunabha
parents:
0
diff
changeset
|
141 |
|
524118fd998f
Fixes for the Keyboard mapping , serial Mouse and the LCD drivers
arunabha
parents:
0
diff
changeset
|
142 |
|
524118fd998f
Fixes for the Keyboard mapping , serial Mouse and the LCD drivers
arunabha
parents:
0
diff
changeset
|
143 |
/* |
524118fd998f
Fixes for the Keyboard mapping , serial Mouse and the LCD drivers
arunabha
parents:
0
diff
changeset
|
144 |
Modified to scale up the display size to a 640x640 , which could be used for VGA layouts as well |
524118fd998f
Fixes for the Keyboard mapping , serial Mouse and the LCD drivers
arunabha
parents:
0
diff
changeset
|
145 |
|
0 | 146 |
const TUint KConfigLcdWidth = 360;//640; // 640 pixels per line |
147 |
const TUint KConfigLcdHeight = 640;//480; // 480 lines per panel |
|
25
524118fd998f
Fixes for the Keyboard mapping , serial Mouse and the LCD drivers
arunabha
parents:
0
diff
changeset
|
148 |
*/ |
524118fd998f
Fixes for the Keyboard mapping , serial Mouse and the LCD drivers
arunabha
parents:
0
diff
changeset
|
149 |
|
524118fd998f
Fixes for the Keyboard mapping , serial Mouse and the LCD drivers
arunabha
parents:
0
diff
changeset
|
150 |
const TUint KConfigLcdWidth = 640; // 640 pixels per line |
524118fd998f
Fixes for the Keyboard mapping , serial Mouse and the LCD drivers
arunabha
parents:
0
diff
changeset
|
151 |
const TUint KConfigLcdHeight = 640; // 640 lines per panel |
524118fd998f
Fixes for the Keyboard mapping , serial Mouse and the LCD drivers
arunabha
parents:
0
diff
changeset
|
152 |
|
524118fd998f
Fixes for the Keyboard mapping , serial Mouse and the LCD drivers
arunabha
parents:
0
diff
changeset
|
153 |
|
0 | 154 |
|
155 |
// TO DO: (mandatory) |
|
156 |
// define the characteristics of the LCD display |
|
157 |
// This is only example code... you need to modify it for your hardware |
|
158 |
const TBool KConfigLcdIsMono = EFalse; |
|
159 |
const TBool KConfigLcdPixelOrderLandscape = ETrue; |
|
160 |
const TBool KConfigLcdPixelOrderRGB = ETrue; |
|
161 |
const TInt KConfigLcdMaxDisplayColors = 65536; //24bit: 16777216; |
|
162 |
||
163 |
||
164 |
// TO DO: (mandatory) |
|
165 |
// define the display dimensions in TWIPs |
|
166 |
// A TWIP is a 20th of a point. A point is a 72nd of an inch |
|
167 |
// Therefore a TWIP is a 1440th of an inch |
|
168 |
// This is only example code... you need to modify it for your hardware |
|
25
524118fd998f
Fixes for the Keyboard mapping , serial Mouse and the LCD drivers
arunabha
parents:
0
diff
changeset
|
169 |
//const TInt KConfigLcdWidthInTwips = 9638;//10800; // = 6.69 inches //15*1440; |
524118fd998f
Fixes for the Keyboard mapping , serial Mouse and the LCD drivers
arunabha
parents:
0
diff
changeset
|
170 |
//const TInt KConfigLcdHeightInTwips = 7370;//11232;//5616; // = 5.11 inches //12*1440; |
524118fd998f
Fixes for the Keyboard mapping , serial Mouse and the LCD drivers
arunabha
parents:
0
diff
changeset
|
171 |
|
524118fd998f
Fixes for the Keyboard mapping , serial Mouse and the LCD drivers
arunabha
parents:
0
diff
changeset
|
172 |
// Modified Twips in accordance with VGA changes - Not sure if it helps or is needed |
524118fd998f
Fixes for the Keyboard mapping , serial Mouse and the LCD drivers
arunabha
parents:
0
diff
changeset
|
173 |
|
524118fd998f
Fixes for the Keyboard mapping , serial Mouse and the LCD drivers
arunabha
parents:
0
diff
changeset
|
174 |
const TInt KConfigLcdWidthInTwips = 2670; // = 6.69 inches //15*1440; |
524118fd998f
Fixes for the Keyboard mapping , serial Mouse and the LCD drivers
arunabha
parents:
0
diff
changeset
|
175 |
const TInt KConfigLcdHeightInTwips = 3550; //5616; // = 5.11 inches //12*1440; |
0 | 176 |
|
177 |
// TO DO: (mandatory) |
|
178 |
// define the available display modes |
|
179 |
// This is only example code... you need to modify it for your hardware |
|
180 |
const TInt KConfigLcdNumberOfDisplayModes = 1; |
|
181 |
const TInt KConfigLcdInitialDisplayMode = 0; |
|
182 |
struct SLcdConfig |
|
183 |
{ |
|
184 |
TInt iMode; |
|
185 |
TInt iOffsetToFirstVideoBuffer; |
|
186 |
TInt iLenghtOfVideoBufferInBytes; |
|
187 |
TInt iOffsetBetweenLines; |
|
188 |
TBool iIsPalettized; |
|
189 |
TInt iBitsPerPixel; |
|
190 |
}; |
|
191 |
static const SLcdConfig Lcd_Mode_Config[KConfigLcdNumberOfDisplayModes]= |
|
192 |
{ |
|
193 |
{ |
|
194 |
0, // iMode |
|
195 |
0, // iOffsetToFirstVideoBuffer |
|
196 |
FRAME_BUFFER_SIZE(16, KConfigLcdWidth, KConfigLcdHeight), // iLenghtOfVideoBufferInBytes |
|
197 |
KConfigLcdWidth*2, // iOffsetBetweenLines |
|
198 |
EFalse, // iIsPalettized |
|
199 |
16 // iBitsPerPixel |
|
200 |
} |
|
201 |
}; |
|
202 |
||
203 |
||
204 |
||
205 |
_LIT(KLitLcd,"LCD"); |
|
206 |
||
207 |
// |
|
208 |
// TO DO: (optional) |
|
209 |
// |
|
210 |
// Add any private functions and data you require |
|
211 |
// |
|
212 |
NONSHARABLE_CLASS(DLcdPowerHandler) : public DPowerHandler |
|
213 |
{ |
|
214 |
public: |
|
215 |
DLcdPowerHandler(); |
|
216 |
||
217 |
// from DPowerHandler |
|
218 |
void PowerDown(TPowerState); |
|
219 |
void PowerUp(); |
|
220 |
||
221 |
void PowerUpDfc(); |
|
222 |
void PowerDownDfc(); |
|
223 |
||
224 |
TInt Create(); |
|
225 |
void DisplayOn(); |
|
226 |
void DisplayOff(); |
|
227 |
TInt HalFunction(TInt aFunction, TAny* a1, TAny* a2); |
|
228 |
||
229 |
void PowerUpLcd(TBool aSecure); |
|
230 |
void PowerDownLcd(); |
|
231 |
||
232 |
void ScreenInfo(TScreenInfoV01& aInfo); |
|
233 |
void WsSwitchOnScreen(); |
|
234 |
void WsSwitchOffScreen(); |
|
235 |
void HandleMsg(); |
|
236 |
void SwitchDisplay(TBool aSecure); |
|
237 |
||
238 |
void SetBacklightState(TBool aState); |
|
239 |
void BacklightOn(); |
|
240 |
void BacklightOff(); |
|
241 |
TInt SetContrast(TInt aContrast); |
|
242 |
TInt SetBrightness(TInt aBrightness); |
|
243 |
||
244 |
private: |
|
245 |
TInt SetPaletteEntry(TInt aEntry, TInt aColor); |
|
246 |
TInt GetPaletteEntry(TInt aEntry, TInt* aColor); |
|
247 |
TInt NumberOfPaletteEntries(); |
|
248 |
TInt GetCurrentDisplayModeInfo(TVideoInfoV01& aInfo, TBool aSecure); |
|
249 |
TInt GetSpecifiedDisplayModeInfo(TInt aMode, TVideoInfoV01& aInfo); |
|
250 |
TInt SetDisplayMode(TInt aMode); |
|
251 |
void SplashScreen(); |
|
252 |
TInt GetDisplayColors(TInt* aColors); |
|
253 |
||
254 |
private: |
|
255 |
TBool iIsPalettized; |
|
256 |
TBool iDisplayOn; // to prevent a race condition with WServer trying to power up/down at the same time |
|
257 |
DPlatChunkHw* iChunk; |
|
258 |
DPlatChunkHw* iSecureChunk; |
|
259 |
TBool iWsSwitchOnScreen; |
|
260 |
TBool iSecureDisplay; |
|
261 |
TDfcQue* iDfcQ; |
|
262 |
TMessageQue iMsgQ; |
|
263 |
TDfc iPowerUpDfc; |
|
264 |
TDfc iPowerDownDfc; |
|
265 |
TVideoInfoV01 iVideoInfo; |
|
266 |
TVideoInfoV01 iSecureVideoInfo; |
|
267 |
NFastMutex iLock; // protects against being preempted whilst manipulating iVideoInfo/iSecureVideoInfo |
|
268 |
TPhysAddr ivRamPhys; |
|
269 |
TPhysAddr iSecurevRamPhys; |
|
270 |
||
271 |
TBool iBacklightOn; |
|
272 |
TInt iContrast; |
|
273 |
TInt iBrightness; |
|
274 |
}; |
|
275 |
||
276 |
||
277 |
/** |
|
278 |
HAL handler function |
|
279 |
||
280 |
@param aPtr a pointer to an instance of DLcdPowerHandler |
|
281 |
@param aFunction the function number |
|
282 |
@param a1 an arbitrary parameter |
|
283 |
@param a2 an arbitrary parameter |
|
284 |
*/ |
|
285 |
LOCAL_C TInt halFunction(TAny* aPtr, TInt aFunction, TAny* a1, TAny* a2) |
|
286 |
{ |
|
287 |
DLcdPowerHandler* pH=(DLcdPowerHandler*)aPtr; |
|
288 |
return pH->HalFunction(aFunction,a1,a2); |
|
289 |
} |
|
290 |
||
291 |
/** |
|
292 |
DFC for receiving messages from the power handler |
|
293 |
@param aPtr a pointer to an instance of DLcdPowerHandler |
|
294 |
*/ |
|
295 |
void rxMsg(TAny* aPtr) |
|
296 |
{ |
|
297 |
DLcdPowerHandler& h=*(DLcdPowerHandler*)aPtr; |
|
298 |
h.HandleMsg(); |
|
299 |
} |
|
300 |
||
301 |
/** |
|
302 |
DFC for powering up the device |
|
303 |
||
304 |
@param aPtr aPtr a pointer to an instance of DLcdPowerHandler |
|
305 |
*/ |
|
306 |
void power_up_dfc(TAny* aPtr) |
|
307 |
{ |
|
308 |
((DLcdPowerHandler*)aPtr)->PowerUpDfc(); |
|
309 |
} |
|
310 |
||
311 |
/** |
|
312 |
DFC for powering down the device |
|
313 |
||
314 |
@param aPtr aPtr a pointer to an instance of DLcdPowerHandler |
|
315 |
*/ |
|
316 |
void power_down_dfc(TAny* aPtr) |
|
317 |
{ |
|
318 |
((DLcdPowerHandler*)aPtr)->PowerDownDfc(); |
|
319 |
} |
|
320 |
||
321 |
||
322 |
/** |
|
323 |
Default constructor |
|
324 |
*/ |
|
325 |
DLcdPowerHandler::DLcdPowerHandler() : |
|
326 |
DPowerHandler(KLitLcd), |
|
327 |
iMsgQ(rxMsg,this,NULL,1), |
|
328 |
iPowerUpDfc(&power_up_dfc,this,6), |
|
329 |
iPowerDownDfc(&power_down_dfc,this,7), |
|
330 |
iBacklightOn(EFalse), |
|
331 |
iContrast(KConfigInitialDisplayContrast), |
|
332 |
iBrightness(KConfigInitialDisplayBrightness) |
|
333 |
{ |
|
334 |
} |
|
335 |
||
336 |
||
337 |
/** |
|
338 |
Second-phase constructor |
|
339 |
||
340 |
Called by factory function at ordinal 0 |
|
341 |
*/ |
|
342 |
TInt DLcdPowerHandler::Create() |
|
343 |
{ |
|
344 |
iDfcQ=Kern::DfcQue0(); // use low priority DFC queue for this driver |
|
345 |
||
346 |
// map the video RAM |
|
347 |
||
348 |
//TPhysAddr videoRamPhys; |
|
349 |
TInt vSize = Lcd_Mode_Config[KConfigLcdInitialDisplayMode].iLenghtOfVideoBufferInBytes; //KConfigLcdWidth*KConfigLcdHeight*3; //VideoRamSize(); |
|
350 |
TInt r = Epoc::AllocPhysicalRam( 2*vSize, ivRamPhys ); |
|
351 |
if ( r!=KErrNone ) |
|
352 |
{ |
|
353 |
Kern::Fault( "AllocVRam", r ); |
|
354 |
} |
|
355 |
||
356 |
//TInt vSize = ((Omap3530BoardAssp*)Arch::TheAsic())->VideoRamSize(); |
|
357 |
//ivRamPhys = TOmap3530Assp::VideoRamPhys(); // EXAMPLE ONLY: assume TOmap3530Assp interface class |
|
358 |
r = DPlatChunkHw::New(iChunk,ivRamPhys,vSize,EMapAttrUserRw|EMapAttrBufferedC); |
|
359 |
if (r != KErrNone) |
|
360 |
return r; |
|
361 |
||
362 |
//create "secure" screen immediately after normal one |
|
363 |
iSecurevRamPhys = ivRamPhys + vSize; |
|
364 |
TInt r2 = DPlatChunkHw::New(iSecureChunk,iSecurevRamPhys,vSize,EMapAttrUserRw|EMapAttrBufferedC); |
|
365 |
if (r2 != KErrNone) |
|
366 |
return r2; |
|
367 |
||
368 |
TUint* pV=(TUint*)iChunk->LinearAddress(); |
|
369 |
||
370 |
__KTRACE_OPT(KEXTENSION,Kern::Printf("DLcdPowerHandler::Create: VideoRamSize=%x, VideoRamPhys=%08x, VideoRamLin=%08x",vSize,ivRamPhys,pV)); |
|
371 |
||
372 |
// TO DO: (mandatory) |
|
373 |
// initialise the palette for the initial display mode |
|
374 |
// NOTE: the palette could either be a buffer allocated in system RAM (usually contiguous to Video buffer) |
|
375 |
// or could be offered as part of the hardware block that implemenst the lcd control |
|
376 |
// |
|
377 |
||
378 |
TUint* pV2=(TUint*)iSecureChunk->LinearAddress(); |
|
379 |
||
380 |
__KTRACE_OPT(KEXTENSION,Kern::Printf("DLcdPowerHandler::Create: Secure display VideoRamSize=%x, VideoRamPhys=%08x, VideoRamLin=%08x",vSize,iSecurevRamPhys,pV2)); |
|
381 |
||
382 |
// TO DO: (mandatory) |
|
383 |
// initialise the secure screen's palette for the initial display mode |
|
384 |
// |
|
385 |
||
386 |
// setup the video info structure, this'll be used to remember the video settings |
|
387 |
iVideoInfo.iDisplayMode = KConfigLcdInitialDisplayMode; |
|
388 |
iVideoInfo.iOffsetToFirstPixel = Lcd_Mode_Config[KConfigLcdInitialDisplayMode].iOffsetToFirstVideoBuffer; |
|
389 |
iVideoInfo.iIsPalettized = Lcd_Mode_Config[KConfigLcdInitialDisplayMode].iIsPalettized; |
|
390 |
iVideoInfo.iOffsetBetweenLines = Lcd_Mode_Config[KConfigLcdInitialDisplayMode].iOffsetBetweenLines; |
|
391 |
iVideoInfo.iBitsPerPixel = Lcd_Mode_Config[KConfigLcdInitialDisplayMode].iBitsPerPixel; |
|
392 |
||
393 |
iVideoInfo.iSizeInPixels.iWidth = KConfigLcdWidth; |
|
394 |
iVideoInfo.iSizeInPixels.iHeight = KConfigLcdHeight; |
|
395 |
iVideoInfo.iSizeInTwips.iWidth = KConfigLcdWidthInTwips; |
|
396 |
iVideoInfo.iSizeInTwips.iHeight = KConfigLcdHeightInTwips; |
|
397 |
iVideoInfo.iIsMono = KConfigLcdIsMono; |
|
398 |
iVideoInfo.iVideoAddress=(TInt)pV; |
|
399 |
iVideoInfo.iIsPixelOrderLandscape = KConfigLcdPixelOrderLandscape; |
|
400 |
iVideoInfo.iIsPixelOrderRGB = KConfigLcdPixelOrderRGB; |
|
401 |
||
402 |
iSecureVideoInfo = iVideoInfo; |
|
403 |
iSecureVideoInfo.iVideoAddress = (TInt)pV2; |
|
404 |
||
405 |
iDisplayOn = EFalse; |
|
406 |
iSecureDisplay = EFalse; |
|
407 |
||
408 |
// install the HAL function |
|
409 |
r=Kern::AddHalEntry(EHalGroupDisplay, halFunction, this); |
|
410 |
if (r!=KErrNone) |
|
411 |
return r; |
|
412 |
||
413 |
iPowerUpDfc.SetDfcQ(iDfcQ); |
|
414 |
iPowerDownDfc.SetDfcQ(iDfcQ); |
|
415 |
iMsgQ.SetDfcQ(iDfcQ); |
|
416 |
iMsgQ.Receive(); |
|
417 |
||
418 |
// install the power handler |
|
419 |
// power up the screen |
|
420 |
Add(); |
|
421 |
DisplayOn(); |
|
422 |
||
423 |
SplashScreen(); |
|
424 |
||
425 |
return KErrNone; |
|
426 |
} |
|
427 |
||
428 |
/** |
|
429 |
Turn the display on |
|
430 |
May be called as a result of a power transition or from the HAL |
|
431 |
If called from HAL, then the display may be already be on (iDisplayOn == ETrue) |
|
432 |
*/ |
|
433 |
void DLcdPowerHandler::DisplayOn() |
|
434 |
{ |
|
435 |
__KTRACE_OPT(KBOOT, Kern::Printf("DisplayOn %d", iDisplayOn)); |
|
436 |
if (!iDisplayOn) // may have been powered up already |
|
437 |
{ |
|
438 |
iDisplayOn = ETrue; |
|
439 |
PowerUpLcd(iSecureDisplay); |
|
440 |
SetContrast(iContrast); |
|
441 |
SetBrightness(iBrightness); |
|
442 |
} |
|
443 |
} |
|
444 |
||
445 |
/** |
|
446 |
Turn the display off |
|
447 |
May be called as a result of a power transition or from the HAL |
|
448 |
If called from Power Manager, then the display may be already be off (iDisplayOn == EFalse) |
|
449 |
if the platform is in silent running mode |
|
450 |
*/ |
|
451 |
void DLcdPowerHandler::DisplayOff() |
|
452 |
{ |
|
453 |
__KTRACE_OPT(KBOOT, Kern::Printf("DisplayOff %d", iDisplayOn)); |
|
454 |
if (iDisplayOn) |
|
455 |
{ |
|
456 |
iDisplayOn = EFalse; |
|
457 |
PowerDownLcd(); |
|
458 |
} |
|
459 |
} |
|
460 |
||
461 |
/** |
|
462 |
Switch between secure and non-secure displays |
|
463 |
||
464 |
@param aSecure ETrue if switching to secure display |
|
465 |
*/ |
|
466 |
void DLcdPowerHandler::SwitchDisplay(TBool aSecure) |
|
467 |
{ |
|
468 |
if (aSecure) |
|
469 |
{ |
|
470 |
if (!iSecureDisplay) |
|
471 |
{ |
|
472 |
//switch to secure display |
|
473 |
DisplayOff(); |
|
474 |
iSecureDisplay = ETrue; |
|
475 |
DisplayOn(); |
|
476 |
} |
|
477 |
} |
|
478 |
else |
|
479 |
{ |
|
480 |
if (iSecureDisplay) |
|
481 |
{ |
|
482 |
//switch from secure display |
|
483 |
DisplayOff(); |
|
484 |
iSecureDisplay = EFalse; |
|
485 |
DisplayOn(); |
|
486 |
} |
|
487 |
} |
|
488 |
} |
|
489 |
||
490 |
/** |
|
491 |
DFC to power up the display |
|
492 |
*/ |
|
493 |
void DLcdPowerHandler::PowerUpDfc() |
|
494 |
{ |
|
495 |
__KTRACE_OPT(KPOWER, Kern::Printf("PowerUpDfc")); |
|
496 |
DisplayOn(); |
|
497 |
||
498 |
PowerUpDone(); // must be called from a different thread than PowerUp() |
|
499 |
} |
|
500 |
||
501 |
/** |
|
502 |
DFC to power down the display |
|
503 |
*/ |
|
504 |
void DLcdPowerHandler::PowerDownDfc() |
|
505 |
{ |
|
506 |
__KTRACE_OPT(KPOWER, Kern::Printf("PowerDownDfc")); |
|
507 |
DisplayOff(); |
|
508 |
PowerDownDone(); // must be called from a different thread than PowerUp() |
|
509 |
} |
|
510 |
||
511 |
/** |
|
512 |
Schedule the power-down DFC |
|
513 |
*/ |
|
514 |
void DLcdPowerHandler::PowerDown(TPowerState) |
|
515 |
{ |
|
516 |
iPowerDownDfc.Enque(); // schedules DFC to execute on this driver's thread |
|
517 |
} |
|
518 |
||
519 |
/** |
|
520 |
Schedule the power-up DFC |
|
521 |
*/ |
|
522 |
void DLcdPowerHandler::PowerUp() |
|
523 |
{ |
|
524 |
iPowerUpDfc.Enque(); // schedules DFC to execute on this driver's thread |
|
525 |
} |
|
526 |
||
527 |
/** |
|
528 |
Power up the display |
|
529 |
||
530 |
@param aSecure ETrue if powering up the secure display |
|
531 |
*/ |
|
532 |
void DLcdPowerHandler::PowerUpLcd(TBool aSecure) |
|
533 |
{ |
|
534 |
||
535 |
TUint32 l = 0x0; |
|
536 |
||
537 |
// Set up the Display Subsystem to control a DVI monitor |
|
538 |
||
539 |
// The following four lines need to be replaced by a call to the GPIO driver which should call the PowerClock driver |
|
540 |
// PowerClock::GpioActive(0, PowerClock::E1s, PowerClock::ECpu10, PowerClock::EBus10); |
|
541 |
// PowerClock::GpioAccess(0, PowerClock::EAuto); |
|
542 |
Prcm::SetClockState( Prcm::EClkGpio1_F, Prcm::EClkOn ); |
|
543 |
Prcm::SetClockState( Prcm::EClkGpio1_I, Prcm::EClkAuto ); |
|
544 |
*( (TUint *) Omap3530HwBase::TVirtual<0x48310034>::Value ) = 0xfefffedf; //GPIO1 output enable p3336 |
|
545 |
*( (TUint *) Omap3530HwBase::TVirtual<0x48310094>::Value ) = 0x01000120; //GPIO1 set data out p3336 |
|
546 |
// const TUint KCM_CLKSEL_DSS = Omap3530HwBase::TVirtual<0x48004E40>::Value; |
|
547 |
// Prcm::Set(KCM_CLKSEL_DSS, 0xffffffffu, 0x00001006); |
|
548 |
||
549 |
Prcm::SetDivider( Prcm::EClkDss1_F, 2 ); |
|
550 |
Prcm::SetDivider( Prcm::EClkTv_F, 1 ); |
|
551 |
||
552 |
||
553 |
SET_REGISTER( DSS_SYSCONFIG, 0x00000010 ); // Display Subsystem reset |
|
554 |
while ( !( GET_REGISTER( DISPC_SYSSTATUS ) & 1 ) ); // Spin until reset complete |
|
555 |
||
556 |
TInt8 MIDLEMODE = 0x2; // Smart Standby. MStandby is asserted based on the internal activity of the module. |
|
557 |
TInt8 CLOCKACTIVITY = 0x0; // interface and functional clocks can be switched off. |
|
558 |
TInt8 SIDLEMODE = 0x2; // Smart idle. Idle request is acknowledged based on the internal activity of the module |
|
559 |
TInt8 ENWAKEUP = 0x1; // Wakeup is enabled. |
|
560 |
TInt8 SOFTRESET = 0x0; // Normal mode |
|
561 |
TInt8 AUTOIDLE = 0x1; // Automatic L3 and L4 interface clock gating strategy is applied based on interface activity |
|
562 |
l = MIDLEMODE<<12 | CLOCKACTIVITY<<8 | SIDLEMODE<<3 | ENWAKEUP<<2 | SOFTRESET<<1 | AUTOIDLE; |
|
563 |
SET_REGISTER( DISPC_SYSCONFIG, l ); |
|
564 |
||
565 |
TInt8 LOADMOAD = 0x2; //Frame data only loaded every frame |
|
566 |
l = LOADMOAD<<1; |
|
567 |
SET_REGISTER( DISPC_CONFIG, l ); |
|
568 |
||
569 |
SET_REGISTER( DISPC_DEFAULT_COLOR0, 0xFFFFFFFF ); |
|
570 |
SET_REGISTER( DISPC_TRANS_COLOR0, 0x00000000 ); |
|
571 |
||
572 |
TUint8 hbp = H_BPORCH - 1; // Horizontal Back Porch |
|
573 |
TUint8 hfp = H_FPORCH - 1; // Horizontal front porch |
|
574 |
TUint8 hsw = H_SYNC - 1; // Horizontal synchronization pulse width |
|
575 |
if ( hsw > 63 ) |
|
576 |
{ |
|
577 |
hsw = 63; |
|
578 |
Kern::Printf("[LCD] H_SYNC too big"); |
|
579 |
} |
|
580 |
l = hbp<<20 | hfp<<8 | hsw; |
|
581 |
SET_REGISTER( DISPC_TIMING_H, l ); |
|
582 |
||
583 |
TUint8 vbp = V_BPORCH; // Vertical back porch |
|
584 |
TUint8 vfp = V_FPORCH; // Vertical front porch |
|
585 |
TUint8 vsw = V_SYNC; // Vertical synchronization pulse width |
|
586 |
__ASSERT_ALWAYS( vbp<=255, Kern::Fault("LCD", 1) ); |
|
587 |
__ASSERT_ALWAYS( vfp<=255, Kern::Fault("LCD", 1) ); |
|
588 |
__ASSERT_ALWAYS( vsw>=1 && vsw<=255, Kern::Fault("LCD", 1) ); |
|
589 |
l = vbp<<20 | vfp<<8 | vsw; |
|
590 |
SET_REGISTER( DISPC_TIMING_V, l ); |
|
591 |
||
592 |
TUint8 onoff= 0; |
|
593 |
TUint8 rf = 0; |
|
594 |
TUint8 ieo = 0; |
|
595 |
TUint8 ipc = 1; // Invert Pixel Clock |
|
596 |
TUint8 ihs = H_SYNC_POL ? 0 : 1; // Invert HSYNC (0: Positive Sync polarity, 1: Negative Sync polarity) |
|
597 |
TUint8 ivs = V_SYNC_POL ? 0 : 1; // Invert VSYNC (0: Positive Sync polarity, 1: Negative Sync polarity) |
|
598 |
TUint8 acbi = 0; |
|
599 |
TUint16 acb = 0x28; // AC-bias pin frequency |
|
600 |
l = onoff<<17 | rf<<16 | ieo<<15 | ipc<<14 | ihs<<13 | ivs<<12 | acbi<<8 | acb; |
|
601 |
SET_REGISTER( DISPC_POL_FREQ, l ); |
|
602 |
||
603 |
TUint8 lcd = 1; // Display Controller Logic Clock Divisor |
|
604 |
TUint8 pcd = ( 432000 + (PIXEL_CLK - 1) ) / PIXEL_CLK; // Pixel Clock Divisor - add (PIXEL_CLK - 1) to avoid rounding error |
|
605 |
__ASSERT_ALWAYS( lcd>=1 && lcd<=255, Kern::Fault("LCD", 1) ); |
|
606 |
__ASSERT_ALWAYS( pcd>=2 && pcd<=255, Kern::Fault("LCD", 1) ); |
|
607 |
l = lcd<<16 | pcd; |
|
608 |
SET_REGISTER( DISPC_DIVISOR, l ); |
|
609 |
||
610 |
TUint16 ppl = H_DISP - 1; // Pixels per line |
|
611 |
TUint16 llp = V_DISP - 1; // Lines per panel |
|
612 |
__ASSERT_ALWAYS( ppl>=1 && ppl<=2048, Kern::Fault("LCD", 1) ); |
|
613 |
__ASSERT_ALWAYS( llp>=1 && llp<=2048, Kern::Fault("LCD", 1) ); |
|
614 |
l = llp<<16 | ppl; |
|
615 |
SET_REGISTER( DISPC_SIZE_LCD, l ); |
|
616 |
||
617 |
||
618 |
// Setup a graphics region (GFX) |
|
619 |
||
620 |
// Set GFX frame buffer |
|
621 |
SET_REGISTER( DISPC_GFX_BA1, ivRamPhys ); |
|
622 |
||
623 |
// Center the GFX |
|
624 |
TInt16 gfxposy = ( V_DISP - KConfigLcdHeight ) / 2; |
|
625 |
TInt16 gfxposx = ( H_DISP - KConfigLcdWidth ) / 2; |
|
626 |
l = ( gfxposy << 16 ) | gfxposx; |
|
627 |
SET_REGISTER( DISPC_GFX_POSITION, l ); |
|
628 |
||
629 |
// Set the GFX dimensions |
|
630 |
TInt16 gfxsizey = KConfigLcdHeight - 1; |
|
631 |
TInt16 gfxsizex = KConfigLcdWidth - 1; |
|
632 |
l = gfxsizey<<16 | gfxsizex; |
|
633 |
SET_REGISTER( DISPC_GFX_SIZE, l ); |
|
634 |
||
635 |
TInt8 GFXSELFREFRESH = 0x0; |
|
636 |
TInt8 GFXARBITRATION = 0x0; |
|
637 |
TInt8 GFXROTATION = 0x0; |
|
638 |
TInt8 GFXFIFOPRELOAD = 0x0; |
|
639 |
TInt8 GFXENDIANNESS = 0x0; |
|
640 |
TInt8 GFXNIBBLEMODE = 0x0; |
|
641 |
TInt8 GFXCHANNELOUT = 0x0; |
|
642 |
TInt8 GFXBURSTSIZE = 0x2; // 16x32bit bursts |
|
643 |
TInt8 GFXREPLICATIONENABLE = 0x0; // Disable Graphics replication logic |
|
644 |
TInt8 GFXFORMAT = 0x6; // RGB16=0x6, RGB24-unpacked=0x8, RGB24-packed=0x9 |
|
645 |
TInt8 GFXENABLE = 0x1; // Graphics enabled |
|
646 |
l = GFXSELFREFRESH<<15 | GFXARBITRATION<<14 | GFXROTATION<<12 | GFXFIFOPRELOAD<<11 | GFXENDIANNESS<<10 | GFXNIBBLEMODE<<9 | GFXCHANNELOUT<8 | GFXBURSTSIZE<<6 | GFXREPLICATIONENABLE<<5 | GFXFORMAT<<1 | GFXENABLE; |
|
647 |
SET_REGISTER( DISPC_GFX_ATTRIBUTES, l ); |
|
648 |
||
649 |
TInt16 GFXFIFOHIGHTHRESHOLD = 0x3fc; // Graphics FIFO High Threshold |
|
650 |
TInt16 GFXFIFOLOWTHRESHOLD = 0x3BC; // Graphics FIFO Low Threshold |
|
651 |
l = GFXFIFOHIGHTHRESHOLD<<16 | GFXFIFOLOWTHRESHOLD; |
|
652 |
SET_REGISTER(DISPC_GFX_FIFO_THRESHOLD, l); |
|
653 |
||
654 |
TInt16 GFXFIFOSIZE = 0x400; // Number of bytes defining the FIFO value |
|
655 |
l = GFXFIFOSIZE; |
|
656 |
SET_REGISTER(DISPC_GFX_FIFO_SIZE_STATUS, l); |
|
657 |
||
658 |
TInt32 GFXROWINC = 0x1; |
|
659 |
l = GFXROWINC; |
|
660 |
SET_REGISTER(DISPC_GFX_ROW_INC, l); |
|
661 |
||
662 |
TInt16 GFXPIXELINC = 0x1; |
|
663 |
l = GFXPIXELINC; |
|
664 |
SET_REGISTER(DISPC_GFX_PIXEL_INC, l); |
|
665 |
||
666 |
TInt32 GFXWINDOWSKIP = 0x0; |
|
667 |
l = GFXWINDOWSKIP; |
|
668 |
SET_REGISTER(DISPC_GFX_WINDOW_SKIP, l); |
|
669 |
||
670 |
// TO DO: Sort out the Gamma table + pallets |
|
671 |
TInt32 GFXTABLEBA = 0x807ff000; |
|
672 |
l = GFXTABLEBA; |
|
673 |
SET_REGISTER(DISPC_GFX_TABLE_BA, l); |
|
674 |
||
675 |
||
676 |
// Propigate all the shadowed registers |
|
677 |
||
678 |
TInt8 SPATIALTEMPORALDITHERINGFRAMES = 0; |
|
679 |
TInt8 LCDENABLEPOL = 0; |
|
680 |
TInt8 LCDENABLESIGNAL = 0; |
|
681 |
TInt8 PCKFREEENABLE = 0; |
|
682 |
TInt8 TDMUNUSEDBITS = 0; |
|
683 |
TInt8 TDMCYCLEFORMAT = 0; |
|
684 |
TInt8 TDMPARALLELMODE = 0; |
|
685 |
TInt8 TDMENABLE = 0; |
|
686 |
TInt8 HT = 0; |
|
687 |
TInt8 GPOUT1 = 1; |
|
688 |
TInt8 GPOUT0 = 1; |
|
689 |
TInt8 GPIN1 = 0; |
|
690 |
TInt8 GPIN0 = 0; |
|
691 |
TInt8 OVERLAYOPTIMIZATION = 0; |
|
692 |
TInt8 RFBIMODE = 0; |
|
693 |
TInt8 SECURE = 0; |
|
694 |
TInt8 TFTDATALINES = 0x3; |
|
695 |
TInt8 STDITHERENABLE = 0; |
|
696 |
TInt8 GODIGITAL = 1; |
|
697 |
TInt8 GOLCD = 1; |
|
698 |
TInt8 M8B = 0; |
|
699 |
TInt8 STNTFT = 1; |
|
700 |
TInt8 MONOCOLOR = 0; |
|
701 |
TInt8 DIGITALENABLE = 1; |
|
702 |
TInt8 LCDENABLE = 1; |
|
703 |
l = SPATIALTEMPORALDITHERINGFRAMES<<30 | LCDENABLEPOL<<29 | LCDENABLESIGNAL<<28 | PCKFREEENABLE<<27 | |
|
704 |
TDMUNUSEDBITS<<25 | TDMCYCLEFORMAT<<23 | TDMPARALLELMODE<<21 | TDMENABLE<<20 | HT<<17 | GPOUT1<<16 | |
|
705 |
GPOUT0<<15 | GPIN1<<14 | GPIN0<<13 | OVERLAYOPTIMIZATION<<12 | RFBIMODE<<11 | SECURE<<10 | |
|
706 |
TFTDATALINES<<8 | STDITHERENABLE<<7 | GODIGITAL<<6 | GOLCD<<5 | M8B<<4 | STNTFT<<3 | |
|
707 |
MONOCOLOR<<2 | DIGITALENABLE<<1 | LCDENABLE; |
|
708 |
NKern::Sleep(1); |
|
709 |
SET_REGISTER(DISPC_CONTROL, l); |
|
710 |
NKern::Sleep(1); |
|
711 |
||
712 |
} |
|
713 |
||
714 |
||
715 |
/** |
|
716 |
Power down the display and the backlight |
|
717 |
*/ |
|
718 |
void DLcdPowerHandler::PowerDownLcd() |
|
719 |
{ |
|
720 |
SetBacklightState(EFalse); |
|
721 |
||
722 |
// TO DO: (mandatory) |
|
723 |
// Power down the display & disable LCD DMA. |
|
724 |
// May need to wait until the current frame has been output |
|
725 |
// |
|
726 |
||
727 |
SET_REGISTER(DISPC_CONTROL, 0); |
|
728 |
||
729 |
} |
|
730 |
||
731 |
/** |
|
732 |
Set the Lcd contrast |
|
733 |
||
734 |
@param aValue the contrast setting |
|
735 |
*/ |
|
736 |
TInt DLcdPowerHandler::SetContrast(TInt aValue) |
|
737 |
{ |
|
738 |
__KTRACE_OPT(KEXTENSION,Kern::Printf("SetContrast(%d)", aValue)); |
|
739 |
||
740 |
if (aValue >= KConfigLcdMinDisplayContrast && aValue <= KConfigLcdMaxDisplayContrast) |
|
741 |
{ |
|
742 |
iContrast=aValue; |
|
743 |
||
744 |
// TO DO: (mandatory) |
|
745 |
// set the contrast |
|
746 |
// |
|
747 |
return KErrNone; |
|
748 |
} |
|
749 |
||
750 |
return KErrArgument; |
|
751 |
} |
|
752 |
||
753 |
/** |
|
754 |
Set the Lcd brightness |
|
755 |
||
756 |
@param aValue the brightness setting |
|
757 |
*/ |
|
758 |
TInt DLcdPowerHandler::SetBrightness(TInt aValue) |
|
759 |
{ |
|
760 |
__KTRACE_OPT(KEXTENSION,Kern::Printf("SetBrightness(%d)", aValue)); |
|
761 |
||
762 |
if (aValue >= KConfigLcdMinDisplayBrightness && aValue <= KConfigLcdMaxDisplayBrightness) |
|
763 |
{ |
|
764 |
iBrightness=aValue; |
|
765 |
||
766 |
// TO DO: (mandatory) |
|
767 |
// set the brightness |
|
768 |
// |
|
769 |
return KErrNone; |
|
770 |
} |
|
771 |
return KErrArgument; |
|
772 |
} |
|
773 |
||
774 |
/** |
|
775 |
Turn the backlight on |
|
776 |
*/ |
|
777 |
void DLcdPowerHandler::BacklightOn() |
|
778 |
{ |
|
779 |
// TO DO: (mandatory) |
|
780 |
// turn the backlight on |
|
781 |
// |
|
782 |
} |
|
783 |
||
784 |
/** |
|
785 |
Turn the backlight off |
|
786 |
*/ |
|
787 |
void DLcdPowerHandler::BacklightOff() |
|
788 |
{ |
|
789 |
// TO DO: (mandatory) |
|
790 |
// turn the backlight off |
|
791 |
// |
|
792 |
} |
|
793 |
||
794 |
/** |
|
795 |
Set the state of the backlight |
|
796 |
||
797 |
@param aState ETrue if setting the backlight on |
|
798 |
*/ |
|
799 |
void DLcdPowerHandler::SetBacklightState(TBool aState) |
|
800 |
{ |
|
801 |
iBacklightOn=aState; |
|
802 |
if (iBacklightOn) |
|
803 |
BacklightOn(); |
|
804 |
else |
|
805 |
BacklightOff(); |
|
806 |
} |
|
807 |
||
808 |
void DLcdPowerHandler::ScreenInfo(TScreenInfoV01& anInfo) |
|
809 |
{ |
|
810 |
__KTRACE_OPT(KEXTENSION,Kern::Printf("DLcdPowerHandler::ScreenInfo")); |
|
811 |
anInfo.iWindowHandleValid=EFalse; |
|
812 |
anInfo.iWindowHandle=NULL; |
|
813 |
anInfo.iScreenAddressValid=ETrue; |
|
814 |
anInfo.iScreenAddress=(TAny *)(iChunk->LinearAddress()); |
|
815 |
anInfo.iScreenSize.iWidth=KConfigLcdWidth; |
|
816 |
anInfo.iScreenSize.iHeight=KConfigLcdHeight; |
|
817 |
} |
|
818 |
||
819 |
/** |
|
820 |
Handle a message from the power handler |
|
821 |
*/ |
|
822 |
void DLcdPowerHandler::HandleMsg(void) |
|
823 |
{ |
|
824 |
||
825 |
TMessageBase* msg = iMsgQ.iMessage; |
|
826 |
if (msg == NULL) |
|
827 |
return; |
|
828 |
||
829 |
if (msg->iValue) |
|
830 |
DisplayOn(); |
|
831 |
else |
|
832 |
DisplayOff(); |
|
833 |
msg->Complete(KErrNone,ETrue); |
|
834 |
} |
|
835 |
||
836 |
/** |
|
837 |
Send a message to the power-handler message queue to turn the display on |
|
838 |
*/ |
|
839 |
void DLcdPowerHandler::WsSwitchOnScreen() |
|
840 |
{ |
|
841 |
TThreadMessage& m=Kern::Message(); |
|
842 |
m.iValue = ETrue; |
|
843 |
m.SendReceive(&iMsgQ); // send a message and block Client thread until keyboard has been powered up |
|
844 |
} |
|
845 |
||
846 |
/** |
|
847 |
Send a message to the power-handler message queue to turn the display off |
|
848 |
*/ |
|
849 |
void DLcdPowerHandler::WsSwitchOffScreen() |
|
850 |
{ |
|
851 |
TThreadMessage& m=Kern::Message(); |
|
852 |
m.iValue = EFalse; |
|
853 |
m.SendReceive(&iMsgQ); // send a message and block Client thread until keyboard has been powered down |
|
854 |
} |
|
855 |
||
856 |
/** |
|
857 |
Return information about the current display mode |
|
858 |
||
859 |
@param aInfo a structure supplied by the caller to be filled by this function. |
|
860 |
@param aSecure ETrue if requesting information about the secure display |
|
861 |
@return KErrNone if successful |
|
862 |
*/ |
|
863 |
TInt DLcdPowerHandler::GetCurrentDisplayModeInfo(TVideoInfoV01& aInfo, TBool aSecure) |
|
864 |
{ |
|
865 |
__KTRACE_OPT(KEXTENSION,Kern::Printf("GetCurrentDisplayModeInfo")); |
|
866 |
NKern::FMWait(&iLock); |
|
867 |
if (aSecure) |
|
868 |
aInfo = iSecureVideoInfo; |
|
869 |
else |
|
870 |
aInfo = iVideoInfo; |
|
871 |
NKern::FMSignal(&iLock); |
|
872 |
return KErrNone; |
|
873 |
} |
|
874 |
||
875 |
/** |
|
876 |
Return information about the specified display mode |
|
877 |
||
878 |
@param aMode the display mode to query |
|
879 |
@param aInfo a structure supplied by the caller to be filled by this function. |
|
880 |
@return KErrNone if successful |
|
881 |
*/ |
|
882 |
TInt DLcdPowerHandler::GetSpecifiedDisplayModeInfo(TInt aMode, TVideoInfoV01& aInfo) |
|
883 |
{ |
|
884 |
__KTRACE_OPT(KEXTENSION,Kern::Printf("GetSpecifiedDisplayModeInfo mode is %d",aMode)); |
|
885 |
||
886 |
if (aMode < 0 || aMode >= KConfigLcdNumberOfDisplayModes) |
|
887 |
return KErrArgument; |
|
888 |
||
889 |
NKern::FMWait(&iLock); |
|
890 |
aInfo = iVideoInfo; |
|
891 |
NKern::FMSignal(&iLock); |
|
892 |
||
893 |
if (aMode != aInfo.iDisplayMode) |
|
894 |
{ |
|
895 |
aInfo.iOffsetToFirstPixel=Lcd_Mode_Config[aMode].iOffsetToFirstVideoBuffer; |
|
896 |
aInfo.iIsPalettized = Lcd_Mode_Config[aMode].iIsPalettized; |
|
897 |
aInfo.iOffsetBetweenLines=Lcd_Mode_Config[aMode].iOffsetBetweenLines; |
|
898 |
aInfo.iBitsPerPixel = Lcd_Mode_Config[aMode].iBitsPerPixel; |
|
899 |
} |
|
900 |
return KErrNone; |
|
901 |
} |
|
902 |
||
903 |
/** |
|
904 |
Set the display mode |
|
905 |
||
906 |
@param aMode the display mode to set |
|
907 |
*/ |
|
908 |
TInt DLcdPowerHandler::SetDisplayMode(TInt aMode) |
|
909 |
{ |
|
910 |
||
911 |
__KTRACE_OPT(KEXTENSION,Kern::Printf("SetDisplayMode = %d", aMode)); |
|
912 |
||
913 |
if (aMode < 0 || aMode >= KConfigLcdNumberOfDisplayModes) |
|
914 |
return KErrArgument; |
|
915 |
||
916 |
NKern::FMWait(&iLock); |
|
917 |
||
918 |
// store the current mode |
|
919 |
iVideoInfo.iDisplayMode = aMode; |
|
920 |
iVideoInfo.iOffsetToFirstPixel = Lcd_Mode_Config[aMode].iOffsetToFirstVideoBuffer; |
|
921 |
iVideoInfo.iIsPalettized = Lcd_Mode_Config[aMode].iIsPalettized; |
|
922 |
iVideoInfo.iOffsetBetweenLines = Lcd_Mode_Config[aMode].iOffsetBetweenLines; |
|
923 |
iVideoInfo.iBitsPerPixel = Lcd_Mode_Config[aMode].iBitsPerPixel; |
|
924 |
||
925 |
// store the current mode for secure screen |
|
926 |
iSecureVideoInfo.iDisplayMode = aMode; |
|
927 |
iSecureVideoInfo.iOffsetToFirstPixel = Lcd_Mode_Config[aMode].iOffsetToFirstVideoBuffer; |
|
928 |
iSecureVideoInfo.iIsPalettized = Lcd_Mode_Config[aMode].iIsPalettized; |
|
929 |
iSecureVideoInfo.iOffsetBetweenLines = Lcd_Mode_Config[aMode].iOffsetBetweenLines; |
|
930 |
iSecureVideoInfo.iBitsPerPixel = Lcd_Mode_Config[aMode].iBitsPerPixel; |
|
931 |
||
932 |
// TO DO: (mandatory) |
|
933 |
// set bits per pixel on hardware |
|
934 |
// May need to reconfigure DMA if video buffer size and location have changed |
|
935 |
// |
|
936 |
NKern::FMSignal(&iLock); |
|
937 |
||
938 |
__KTRACE_OPT(KEXTENSION,Kern::Printf("SetDisplayMode mode = %d, otfp = %d, palettized = %d, bpp = %d, obl = %d", |
|
939 |
aMode, iVideoInfo.iOffsetToFirstPixel, iVideoInfo.iIsPalettized, iVideoInfo.iBitsPerPixel, iVideoInfo.iOffsetBetweenLines)); |
|
940 |
||
941 |
return KErrNone; |
|
942 |
} |
|
943 |
||
944 |
/** |
|
945 |
Fill the video memory with an initial pattern or image |
|
946 |
This will be displayed on boot-up |
|
947 |
*/ |
|
948 |
void DLcdPowerHandler::SplashScreen() |
|
949 |
{ |
|
950 |
// TO DO: (optional) |
|
951 |
// replace the example code below to display a different spash screen |
|
952 |
||
953 |
__KTRACE_OPT(KEXTENSION,Kern::Printf("Splash SCreen +")); |
|
954 |
TUint* pV=(TUint*)(iVideoInfo.iVideoAddress + iVideoInfo.iOffsetToFirstPixel); |
|
955 |
__KTRACE_OPT(KEXTENSION,Kern::Printf("Splash SCreen FB @ %x",pV)); |
|
956 |
||
957 |
//Fill the framebuffer with bars |
|
958 |
||
959 |
for (TInt y = 0; y<KConfigLcdHeight; ++y) |
|
960 |
{ |
|
961 |
for(TInt x = 0; x<KConfigLcdHeight; ++x) |
|
962 |
{ |
|
963 |
TUint8 r = 0x00; |
|
964 |
TUint8 g = 0x00; |
|
965 |
TUint8 b = 0x00; |
|
966 |
TUint16 rgb = ((r&0xf8) << 8) | ((g&0xfc) << 3) | ((b&0xf8) >> 3); |
|
967 |
||
968 |
TUint16* px = reinterpret_cast<TUint16*>(pV) + y*KConfigLcdWidth + x; |
|
969 |
*px = rgb; |
|
970 |
} |
|
971 |
} |
|
972 |
||
973 |
__KTRACE_OPT(KEXTENSION,Kern::Printf("Splash SCreen -")); |
|
974 |
} |
|
975 |
||
976 |
||
977 |
/** |
|
978 |
Get the size of the pallete |
|
979 |
||
980 |
@return the number of pallete entries |
|
981 |
*/ |
|
982 |
TInt DLcdPowerHandler::NumberOfPaletteEntries() //only call when holding mutex |
|
983 |
{ |
|
984 |
// TO DO: (mandatory) |
|
985 |
// Calculate the number of Palette entries - this is normally |
|
986 |
// calculated from the bits per-pixel. |
|
987 |
// This is only example code... you may need to modify it for your hardware |
|
988 |
// |
|
989 |
TInt num = iVideoInfo.iIsPalettized ? 1<<iVideoInfo.iBitsPerPixel : 0; |
|
990 |
||
991 |
__KTRACE_OPT(KEXTENSION,Kern::Printf("NumberOfPaletteEntries = %d", num)); |
|
992 |
||
993 |
return num; |
|
994 |
} |
|
995 |
||
996 |
||
997 |
/** |
|
998 |
Retrieve the palette entry at a particular offset |
|
999 |
||
1000 |
@param aEntry the palette index |
|
1001 |
@param aColor a caller-supplied pointer to a location where the returned RGB color is to be stored |
|
1002 |
@return KErrNone if successful |
|
1003 |
KErrNotSupported if the current vide mode does not support a palette |
|
1004 |
KErrArgument if aEntry is out of range |
|
1005 |
*/ |
|
1006 |
TInt DLcdPowerHandler::GetPaletteEntry(TInt aEntry, TInt* aColor) |
|
1007 |
{ |
|
1008 |
NKern::FMWait(&iLock); |
|
1009 |
if (!iVideoInfo.iIsPalettized) |
|
1010 |
{ |
|
1011 |
NKern::FMSignal(&iLock); |
|
1012 |
return KErrNotSupported; |
|
1013 |
} |
|
1014 |
||
1015 |
if ((aEntry < 0) || (aEntry >= NumberOfPaletteEntries())) |
|
1016 |
{ |
|
1017 |
NKern::FMSignal(&iLock); |
|
1018 |
return KErrArgument; |
|
1019 |
} |
|
1020 |
||
1021 |
// TO DO: (mandatory) |
|
1022 |
// read the RGB value of the palette entry into aColor |
|
1023 |
// NOTE: the palette could either be a buffer allocated in system RAM (usually contiguous to Video buffer) |
|
1024 |
// or could be offered as part of the hardware block that implemenst the lcd control |
|
1025 |
// |
|
1026 |
NKern::FMSignal(&iLock); |
|
1027 |
||
1028 |
__KTRACE_OPT(KEXTENSION,Kern::Printf("GetPaletteEntry %d color 0x%x", aEntry, aColor)); |
|
1029 |
||
1030 |
return KErrNone; |
|
1031 |
} |
|
1032 |
||
1033 |
/** |
|
1034 |
Set the palette entry at a particular offset |
|
1035 |
||
1036 |
@param aEntry the palette index |
|
1037 |
@param aColor the RGB color to store |
|
1038 |
@return KErrNone if successful |
|
1039 |
KErrNotSupported if the current vide mode does not support a palette |
|
1040 |
KErrArgument if aEntry is out of range |
|
1041 |
*/ |
|
1042 |
TInt DLcdPowerHandler::SetPaletteEntry(TInt aEntry, TInt aColor) |
|
1043 |
{ |
|
1044 |
||
1045 |
NKern::FMWait(&iLock); |
|
1046 |
if (!iVideoInfo.iIsPalettized) |
|
1047 |
{ |
|
1048 |
NKern::FMSignal(&iLock); |
|
1049 |
return KErrNotSupported; |
|
1050 |
} |
|
1051 |
||
1052 |
if ((aEntry < 0) || (aEntry >= NumberOfPaletteEntries())) //check entry in range |
|
1053 |
{ |
|
1054 |
NKern::FMSignal(&iLock); |
|
1055 |
return KErrArgument; |
|
1056 |
} |
|
1057 |
||
1058 |
// TO DO: (mandatory) |
|
1059 |
// update the palette entry for the secure and non-secure screen |
|
1060 |
// NOTE: the palette could either be a buffer allocated in system RAM (usually contiguous to Video buffer) |
|
1061 |
// or could be offered as part of the hardware block that implemenst the lcd control |
|
1062 |
// |
|
1063 |
__KTRACE_OPT(KEXTENSION,Kern::Printf("SetPaletteEntry %d to 0x%x", aEntry, aColor )); |
|
1064 |
||
1065 |
return KErrNone; |
|
1066 |
} |
|
1067 |
||
1068 |
/** |
|
1069 |
a HAL entry handling function for HAL group attribute EHalGroupDisplay |
|
1070 |
||
1071 |
@param a1 an arbitrary argument |
|
1072 |
@param a2 an arbitrary argument |
|
1073 |
@return KErrNone if successful |
|
1074 |
*/ |
|
1075 |
TInt DLcdPowerHandler::HalFunction(TInt aFunction, TAny* a1, TAny* a2) |
|
1076 |
{ |
|
1077 |
TInt r=KErrNone; |
|
1078 |
switch(aFunction) |
|
1079 |
{ |
|
1080 |
case EDisplayHalScreenInfo: |
|
1081 |
{ |
|
1082 |
TPckgBuf<TScreenInfoV01> vPckg; |
|
1083 |
ScreenInfo(vPckg()); |
|
1084 |
Kern::InfoCopy(*(TDes8*)a1,vPckg); |
|
1085 |
break; |
|
1086 |
} |
|
1087 |
||
1088 |
case EDisplayHalWsRegisterSwitchOnScreenHandling: |
|
1089 |
iWsSwitchOnScreen=(TBool)a1; |
|
1090 |
break; |
|
1091 |
||
1092 |
case EDisplayHalWsSwitchOnScreen: |
|
1093 |
WsSwitchOnScreen(); |
|
1094 |
break; |
|
1095 |
||
1096 |
case EDisplayHalMaxDisplayContrast: |
|
1097 |
{ |
|
1098 |
TInt mc=KConfigLcdMaxDisplayContrast; |
|
1099 |
kumemput32(a1,&mc,sizeof(mc)); |
|
1100 |
break; |
|
1101 |
} |
|
1102 |
case EDisplayHalSetDisplayContrast: |
|
1103 |
__KTRACE_OPT(KEXTENSION,Kern::Printf("EDisplayHalSetDisplayContrast")); |
|
1104 |
if(!Kern::CurrentThreadHasCapability(ECapabilityWriteDeviceData,__PLATSEC_DIAGNOSTIC_STRING("Checked by Hal function EDisplayHalSetDisplayContrast"))) |
|
1105 |
return KErrPermissionDenied; |
|
1106 |
r=SetContrast(TInt(a1)); |
|
1107 |
break; |
|
1108 |
||
1109 |
case EDisplayHalDisplayContrast: |
|
1110 |
kumemput32(a1,&iContrast,sizeof(iContrast)); |
|
1111 |
break; |
|
1112 |
||
1113 |
case EDisplayHalMaxDisplayBrightness: |
|
1114 |
{ |
|
1115 |
TInt mc=KConfigLcdMaxDisplayBrightness; |
|
1116 |
kumemput32(a1,&mc,sizeof(mc)); |
|
1117 |
break; |
|
1118 |
} |
|
1119 |
||
1120 |
case EDisplayHalSetDisplayBrightness: |
|
1121 |
__KTRACE_OPT(KEXTENSION,Kern::Printf("EDisplayHalSetDisplayBrightness")); |
|
1122 |
if(!Kern::CurrentThreadHasCapability(ECapabilityWriteDeviceData,__PLATSEC_DIAGNOSTIC_STRING("Checked by Hal function EDisplayHalSetDisplayBrightness"))) |
|
1123 |
return KErrPermissionDenied; |
|
1124 |
r=SetBrightness(TInt(a1)); |
|
1125 |
break; |
|
1126 |
||
1127 |
case EDisplayHalDisplayBrightness: |
|
1128 |
kumemput32(a1,&iBrightness,sizeof(iBrightness)); |
|
1129 |
break; |
|
1130 |
||
1131 |
case EDisplayHalSetBacklightOn: |
|
1132 |
if(!Kern::CurrentThreadHasCapability(ECapabilityWriteDeviceData,__PLATSEC_DIAGNOSTIC_STRING("Checked by Hal function EDisplayHalSetBacklightOn"))) |
|
1133 |
return KErrPermissionDenied; |
|
1134 |
if (Kern::MachinePowerStatus()<ELow) |
|
1135 |
r=KErrBadPower; |
|
1136 |
else |
|
1137 |
SetBacklightState(TBool(a1)); |
|
1138 |
break; |
|
1139 |
||
1140 |
case EDisplayHalBacklightOn: |
|
1141 |
kumemput32(a1,&iBacklightOn,sizeof(TInt)); |
|
1142 |
break; |
|
1143 |
||
1144 |
case EDisplayHalModeCount: |
|
1145 |
{ |
|
1146 |
TInt ndm = KConfigLcdNumberOfDisplayModes; |
|
1147 |
kumemput32(a1, &ndm, sizeof(ndm)); |
|
1148 |
break; |
|
1149 |
} |
|
1150 |
||
1151 |
case EDisplayHalSetMode: |
|
1152 |
if(!Kern::CurrentThreadHasCapability(ECapabilityMultimediaDD,__PLATSEC_DIAGNOSTIC_STRING("Checked by Hal function EDisplayHalSetMode"))) |
|
1153 |
return KErrPermissionDenied; |
|
1154 |
r = SetDisplayMode((TInt)a1); |
|
1155 |
break; |
|
1156 |
||
1157 |
case EDisplayHalMode: |
|
1158 |
kumemput32(a1, &iVideoInfo.iDisplayMode, sizeof(iVideoInfo.iDisplayMode)); |
|
1159 |
break; |
|
1160 |
||
1161 |
case EDisplayHalSetPaletteEntry: |
|
1162 |
if(!Kern::CurrentThreadHasCapability(ECapabilityMultimediaDD,__PLATSEC_DIAGNOSTIC_STRING("Checked by Hal function EDisplayHalSetPaletteEntry"))) |
|
1163 |
return KErrPermissionDenied; |
|
1164 |
r = SetPaletteEntry((TInt)a1, (TInt)a2); |
|
1165 |
break; |
|
1166 |
||
1167 |
case EDisplayHalPaletteEntry: |
|
1168 |
{ |
|
1169 |
TInt entry; |
|
1170 |
kumemget32(&entry, a1, sizeof(TInt)); |
|
1171 |
TInt x; |
|
1172 |
r = GetPaletteEntry(entry, &x); |
|
1173 |
if (r == KErrNone) |
|
1174 |
kumemput32(a2, &x, sizeof(x)); |
|
1175 |
break; |
|
1176 |
} |
|
1177 |
||
1178 |
case EDisplayHalSetState: |
|
1179 |
{ |
|
1180 |
if(!Kern::CurrentThreadHasCapability(ECapabilityPowerMgmt,__PLATSEC_DIAGNOSTIC_STRING("Checked by Hal function EDisplayHalSetState"))) |
|
1181 |
return KErrPermissionDenied; |
|
1182 |
if ((TBool)a1) |
|
1183 |
{ |
|
1184 |
WsSwitchOnScreen(); |
|
1185 |
} |
|
1186 |
else |
|
1187 |
{ |
|
1188 |
WsSwitchOffScreen(); |
|
1189 |
} |
|
1190 |
break; |
|
1191 |
} |
|
1192 |
||
1193 |
case EDisplayHalState: |
|
1194 |
kumemput32(a1, &iDisplayOn, sizeof(TBool)); |
|
1195 |
break; |
|
1196 |
||
1197 |
case EDisplayHalColors: |
|
1198 |
{ |
|
1199 |
TInt mdc = KConfigLcdMaxDisplayColors; |
|
1200 |
kumemput32(a1, &mdc, sizeof(mdc)); |
|
1201 |
break; |
|
1202 |
} |
|
1203 |
||
1204 |
case EDisplayHalCurrentModeInfo: |
|
1205 |
{ |
|
1206 |
TPckgBuf<TVideoInfoV01> vPckg; |
|
1207 |
r = GetCurrentDisplayModeInfo(vPckg(), (TBool)a2); |
|
1208 |
if (KErrNone == r) |
|
1209 |
Kern::InfoCopy(*(TDes8*)a1,vPckg); |
|
1210 |
} |
|
1211 |
break; |
|
1212 |
||
1213 |
case EDisplayHalSpecifiedModeInfo: |
|
1214 |
{ |
|
1215 |
TPckgBuf<TVideoInfoV01> vPckg; |
|
1216 |
TInt mode; |
|
1217 |
kumemget32(&mode, a1, sizeof(mode)); |
|
1218 |
r = GetSpecifiedDisplayModeInfo(mode, vPckg()); |
|
1219 |
if (KErrNone == r) |
|
1220 |
Kern::InfoCopy(*(TDes8*)a2,vPckg); |
|
1221 |
} |
|
1222 |
break; |
|
1223 |
||
1224 |
case EDisplayHalSecure: |
|
1225 |
kumemput32(a1, &iSecureDisplay, sizeof(TBool)); |
|
1226 |
break; |
|
1227 |
||
1228 |
case EDisplayHalSetSecure: |
|
1229 |
{ |
|
1230 |
if(!Kern::CurrentThreadHasCapability(ECapabilityMultimediaDD,__PLATSEC_DIAGNOSTIC_STRING("Checked by Hal function EDisplayHalSetSecure"))) |
|
1231 |
return KErrPermissionDenied; |
|
1232 |
SwitchDisplay((TBool)a1); |
|
1233 |
} |
|
1234 |
break; |
|
1235 |
||
1236 |
default: |
|
1237 |
r=KErrNotSupported; |
|
1238 |
break; |
|
1239 |
} |
|
1240 |
return r; |
|
1241 |
} |
|
1242 |
||
1243 |
||
1244 |
DECLARE_STANDARD_EXTENSION() |
|
1245 |
{ |
|
1246 |
__KTRACE_OPT(KPOWER,Kern::Printf("Starting LCD power manager")); |
|
1247 |
||
1248 |
// create LCD power handler |
|
1249 |
TInt r=KErrNoMemory; |
|
1250 |
DLcdPowerHandler* pH=new DLcdPowerHandler; |
|
1251 |
if (pH) |
|
1252 |
r=pH->Create(); |
|
1253 |
||
1254 |
__KTRACE_OPT(KPOWER,Kern::Printf("Returns %d",r)); |
|
1255 |
return r; |
|
1256 |
} |
|
1257 |