os/kernelhwsrv/bsptemplate/asspandvariant/template_variant/specific/lcd.cpp
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
sl@0
     1
// Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
sl@0
     2
// All rights reserved.
sl@0
     3
// This component and the accompanying materials are made available
sl@0
     4
// under the terms of the License "Eclipse Public License v1.0"
sl@0
     5
// which accompanies this distribution, and is available
sl@0
     6
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
sl@0
     7
//
sl@0
     8
// Initial Contributors:
sl@0
     9
// Nokia Corporation - initial contribution.
sl@0
    10
//
sl@0
    11
// Contributors:
sl@0
    12
//
sl@0
    13
// Description:
sl@0
    14
// template\Template_Variant\Specific\lcd.cpp
sl@0
    15
// Implementation of an LCD driver. 
sl@0
    16
// This file is part of the Template Base port
sl@0
    17
// N.B. This sample code assumes that the display supports setting the backlight on or off, 
sl@0
    18
// as well as adjusting the contrast and the brightness.
sl@0
    19
// 
sl@0
    20
//
sl@0
    21
sl@0
    22
sl@0
    23
sl@0
    24
#include <videodriver.h>
sl@0
    25
#include "platform.h"
sl@0
    26
#include <nkern.h>
sl@0
    27
#include <kernel/kernel.h>
sl@0
    28
#include <kernel/kern_priv.h>
sl@0
    29
#include <kernel/kpower.h>
sl@0
    30
#include <template_assp_priv.h>
sl@0
    31
sl@0
    32
sl@0
    33
// TO DO: (mandatory)
sl@0
    34
// If the display supports Contrast and/or Brightness control then supply the following defines:
sl@0
    35
// This is only example code... you may need to modify it for your hardware
sl@0
    36
const TInt KConfigInitialDisplayContrast	= 128;
sl@0
    37
const TInt KConfigLcdMinDisplayContrast		= 1;
sl@0
    38
const TInt KConfigLcdMaxDisplayContrast		= 255;
sl@0
    39
const TInt KConfigInitialDisplayBrightness	= 128;
sl@0
    40
const TInt KConfigLcdMinDisplayBrightness	= 1;
sl@0
    41
const TInt KConfigLcdMaxDisplayBrightness	= 255;
sl@0
    42
sl@0
    43
// TO DO: (mandatory)
sl@0
    44
// define a macro to calculate the screen buffer size
sl@0
    45
// This is only example code... you may need to modify it for your hardware
sl@0
    46
// aBpp is the number of bits-per-pixel, aPpl is the number of pixels per line and 
sl@0
    47
// aLpp number of lines per panel
sl@0
    48
#define FRAME_BUFFER_SIZE(aBpp,aPpl,aLpp)	(aBpp*aPpl*aLpp)/8	
sl@0
    49
																
sl@0
    50
sl@0
    51
// TO DO: (mandatory)
sl@0
    52
// define the physical screen dimensions
sl@0
    53
// This is only example code... you need to modify it for your hardware
sl@0
    54
const TUint	KConfigLcdWidth					= 640;		// 640 pixels per line
sl@0
    55
const TUint	KConfigLcdHeight				= 480;		// 480 lines per panel
sl@0
    56
sl@0
    57
// TO DO: (mandatory)
sl@0
    58
// define the characteristics of the LCD display
sl@0
    59
// This is only example code... you need to modify it for your hardware
sl@0
    60
const TBool	KConfigLcdIsMono				= EFalse;
sl@0
    61
const TBool	KConfigLcdPixelOrderLandscape	= ETrue;
sl@0
    62
const TBool	KConfigLcdPixelOrderRGB			= ETrue;
sl@0
    63
const TInt	KConfigLcdMaxDisplayColors		= 65536;
sl@0
    64
sl@0
    65
sl@0
    66
// TO DO: (mandatory)
sl@0
    67
// define the display dimensions in TWIPs
sl@0
    68
// A TWIP is a 20th of a point.  A point is a 72nd of an inch
sl@0
    69
// Therefore a TWIP is a 1440th of an inch
sl@0
    70
// This is only example code... you need to modify it for your hardware
sl@0
    71
const TInt	KConfigLcdWidthInTwips			= 9638;		// = 6.69 inches
sl@0
    72
const TInt	KConfigLcdHeightInTwips			= 7370;		// = 5.11 inches
sl@0
    73
sl@0
    74
// TO DO: (mandatory)
sl@0
    75
// define the available display modes
sl@0
    76
// This is only example code... you need to modify it for your hardware
sl@0
    77
const TInt  KConfigLcdNumberOfDisplayModes	= 1;
sl@0
    78
const TInt  KConfigLcdInitialDisplayMode	= 0;
sl@0
    79
struct SLcdConfig
sl@0
    80
	{
sl@0
    81
	TInt iMode;
sl@0
    82
	TInt iOffsetToFirstVideoBuffer;
sl@0
    83
	TInt iLenghtOfVideoBufferInBytes;
sl@0
    84
	TInt iOffsetBetweenLines;
sl@0
    85
	TBool iIsPalettized;
sl@0
    86
	TInt iBitsPerPixel;
sl@0
    87
	};
sl@0
    88
static const SLcdConfig Lcd_Mode_Config[KConfigLcdNumberOfDisplayModes]=
sl@0
    89
	{
sl@0
    90
		{
sl@0
    91
		0,								// iMode
sl@0
    92
		0,								// iOffsetToFirstVideoBuffer
sl@0
    93
		FRAME_BUFFER_SIZE(8, KConfigLcdWidth, KConfigLcdHeight),	// iLenghtOfVideoBufferInBytes
sl@0
    94
		KConfigLcdWidth,				// iOffsetBetweenLines
sl@0
    95
		ETrue,							// iIsPalettized
sl@0
    96
		8								// iBitsPerPixel
sl@0
    97
		}
sl@0
    98
	};	
sl@0
    99
sl@0
   100
sl@0
   101
sl@0
   102
_LIT(KLitLcd,"LCD");
sl@0
   103
sl@0
   104
//
sl@0
   105
// TO DO: (optional)
sl@0
   106
//
sl@0
   107
// Add any private functions and data you require
sl@0
   108
//
sl@0
   109
NONSHARABLE_CLASS(DLcdPowerHandler) : public DPowerHandler
sl@0
   110
	{
sl@0
   111
public: 
sl@0
   112
	DLcdPowerHandler();
sl@0
   113
	~DLcdPowerHandler();
sl@0
   114
	
sl@0
   115
	// from DPowerHandler
sl@0
   116
	void PowerDown(TPowerState);
sl@0
   117
	void PowerUp();
sl@0
   118
sl@0
   119
	void PowerUpDfc();
sl@0
   120
	void PowerDownDfc();
sl@0
   121
sl@0
   122
	TInt Create();
sl@0
   123
	void DisplayOn();
sl@0
   124
	void DisplayOff();
sl@0
   125
	TInt HalFunction(TInt aFunction, TAny* a1, TAny* a2);
sl@0
   126
sl@0
   127
	void PowerUpLcd(TBool aSecure);
sl@0
   128
	void PowerDownLcd();
sl@0
   129
sl@0
   130
	void ScreenInfo(TScreenInfoV01& aInfo);
sl@0
   131
	void WsSwitchOnScreen();
sl@0
   132
	void WsSwitchOffScreen();
sl@0
   133
	void HandleMsg();
sl@0
   134
	void SwitchDisplay(TBool aSecure);
sl@0
   135
sl@0
   136
	void SetBacklightState(TBool aState);
sl@0
   137
	void BacklightOn();
sl@0
   138
	void BacklightOff();
sl@0
   139
	TInt SetContrast(TInt aContrast);
sl@0
   140
	TInt SetBrightness(TInt aBrightness);
sl@0
   141
sl@0
   142
private:
sl@0
   143
	TInt SetPaletteEntry(TInt aEntry, TInt aColor);
sl@0
   144
	TInt GetPaletteEntry(TInt aEntry, TInt* aColor);
sl@0
   145
	TInt NumberOfPaletteEntries();
sl@0
   146
	TInt GetCurrentDisplayModeInfo(TVideoInfoV01& aInfo, TBool aSecure);
sl@0
   147
	TInt GetSpecifiedDisplayModeInfo(TInt aMode, TVideoInfoV01& aInfo);
sl@0
   148
	TInt SetDisplayMode(TInt aMode);
sl@0
   149
	void SplashScreen();
sl@0
   150
	TInt GetDisplayColors(TInt* aColors);
sl@0
   151
sl@0
   152
private:
sl@0
   153
	TBool iIsPalettized;
sl@0
   154
	TBool iDisplayOn;				// to prevent a race condition with WServer trying to power up/down at the same time
sl@0
   155
	DPlatChunkHw* iChunk;
sl@0
   156
	DPlatChunkHw* iSecureChunk;
sl@0
   157
	TBool iWsSwitchOnScreen;
sl@0
   158
 	TBool iSecureDisplay;
sl@0
   159
	TDynamicDfcQue* iDfcQ;
sl@0
   160
	TMessageQue iMsgQ;
sl@0
   161
	TDfc iPowerUpDfc;
sl@0
   162
	TDfc iPowerDownDfc;	
sl@0
   163
	TVideoInfoV01 iVideoInfo;
sl@0
   164
	TVideoInfoV01 iSecureVideoInfo;
sl@0
   165
	NFastMutex iLock;				// protects against being preempted whilst manipulating iVideoInfo/iSecureVideoInfo
sl@0
   166
	TPhysAddr ivRamPhys;
sl@0
   167
	TPhysAddr iSecurevRamPhys;
sl@0
   168
sl@0
   169
	TBool iBacklightOn;
sl@0
   170
	TInt iContrast;
sl@0
   171
	TInt iBrightness;
sl@0
   172
	};
sl@0
   173
sl@0
   174
sl@0
   175
/**
sl@0
   176
HAL handler function
sl@0
   177
sl@0
   178
@param	aPtr a pointer to an instance of DLcdPowerHandler
sl@0
   179
@param	aFunction the function number
sl@0
   180
@param	a1 an arbitrary parameter
sl@0
   181
@param	a2 an arbitrary parameter
sl@0
   182
*/
sl@0
   183
LOCAL_C TInt halFunction(TAny* aPtr, TInt aFunction, TAny* a1, TAny* a2)
sl@0
   184
	{
sl@0
   185
	DLcdPowerHandler* pH=(DLcdPowerHandler*)aPtr;
sl@0
   186
	return pH->HalFunction(aFunction,a1,a2);
sl@0
   187
	}
sl@0
   188
sl@0
   189
/**
sl@0
   190
DFC for receiving messages from the power handler
sl@0
   191
@param	aPtr a pointer to an instance of DLcdPowerHandler
sl@0
   192
*/
sl@0
   193
void rxMsg(TAny* aPtr)
sl@0
   194
	{
sl@0
   195
	DLcdPowerHandler& h=*(DLcdPowerHandler*)aPtr;
sl@0
   196
	h.HandleMsg();
sl@0
   197
	}
sl@0
   198
sl@0
   199
/**
sl@0
   200
DFC for powering up the device
sl@0
   201
sl@0
   202
@param aPtr	aPtr a pointer to an instance of DLcdPowerHandler
sl@0
   203
*/
sl@0
   204
void power_up_dfc(TAny* aPtr)
sl@0
   205
	{
sl@0
   206
	((DLcdPowerHandler*)aPtr)->PowerUpDfc();
sl@0
   207
	}
sl@0
   208
sl@0
   209
/**
sl@0
   210
DFC for powering down the device
sl@0
   211
sl@0
   212
@param aPtr	aPtr a pointer to an instance of DLcdPowerHandler
sl@0
   213
*/
sl@0
   214
void power_down_dfc(TAny* aPtr)
sl@0
   215
	{
sl@0
   216
	((DLcdPowerHandler*)aPtr)->PowerDownDfc();
sl@0
   217
	}
sl@0
   218
sl@0
   219
sl@0
   220
/**
sl@0
   221
Default constructor
sl@0
   222
*/
sl@0
   223
DLcdPowerHandler::DLcdPowerHandler() :
sl@0
   224
		DPowerHandler(KLitLcd),
sl@0
   225
		iMsgQ(rxMsg,this,NULL,1),
sl@0
   226
		iPowerUpDfc(&power_up_dfc,this,6),
sl@0
   227
		iPowerDownDfc(&power_down_dfc,this,7),
sl@0
   228
		iBacklightOn(EFalse),
sl@0
   229
		iContrast(KConfigInitialDisplayContrast),
sl@0
   230
		iBrightness(KConfigInitialDisplayBrightness)
sl@0
   231
	{
sl@0
   232
	}
sl@0
   233
sl@0
   234
DLcdPowerHandler::~DLcdPowerHandler()
sl@0
   235
	{
sl@0
   236
	if (iDfcQ)
sl@0
   237
		iDfcQ->Destroy();
sl@0
   238
	}
sl@0
   239
sl@0
   240
/**
sl@0
   241
Second-phase constructor 
sl@0
   242
sl@0
   243
Called by factory function at ordinal 0
sl@0
   244
*/
sl@0
   245
TInt DLcdPowerHandler::Create()
sl@0
   246
	{
sl@0
   247
	const TInt KLCDDfcQPriority=27; // Equal to Kern::DfcQue0() priority
sl@0
   248
	TInt r = Kern::DynamicDfcQCreate(iDfcQ, KLCDDfcQPriority, _L("LCDPowerHandler"));
sl@0
   249
	if (r != KErrNone)
sl@0
   250
		{
sl@0
   251
		return r;
sl@0
   252
		}
sl@0
   253
sl@0
   254
	// map the video RAM
sl@0
   255
	TInt vSize = ((TemplateAssp*)Arch::TheAsic())->VideoRamSize();
sl@0
   256
	ivRamPhys = TTemplate::VideoRamPhys();				// EXAMPLE ONLY: assume TTemplate interface class
sl@0
   257
	r = DPlatChunkHw::New(iChunk,ivRamPhys,vSize,EMapAttrUserRw|EMapAttrBufferedC);
sl@0
   258
	if (r != KErrNone)
sl@0
   259
		return r;
sl@0
   260
	
sl@0
   261
	//create "secure" screen immediately after normal one
sl@0
   262
	iSecurevRamPhys =  ivRamPhys + vSize;
sl@0
   263
	TInt r2 = DPlatChunkHw::New(iSecureChunk,iSecurevRamPhys,vSize,EMapAttrUserRw|EMapAttrBufferedC);
sl@0
   264
	if (r2 != KErrNone)
sl@0
   265
		return r2;
sl@0
   266
sl@0
   267
	TUint* pV=(TUint*)iChunk->LinearAddress();
sl@0
   268
sl@0
   269
	__KTRACE_OPT(KEXTENSION,Kern::Printf("DLcdPowerHandler::Create: VideoRamSize=%x, VideoRamPhys=%08x, VideoRamLin=%08x",vSize,ivRamPhys,pV));
sl@0
   270
sl@0
   271
	// TO DO: (mandatory)
sl@0
   272
	// initialise the palette for the initial display mode
sl@0
   273
	// NOTE: the palette could either be a buffer allocated in system RAM (usually contiguous to Video buffer)
sl@0
   274
	//		 or could be offered as part of the hardware block that implemenst the lcd control
sl@0
   275
	//
sl@0
   276
sl@0
   277
	TUint* pV2=(TUint*)iSecureChunk->LinearAddress();
sl@0
   278
sl@0
   279
	__KTRACE_OPT(KEXTENSION,Kern::Printf("DLcdPowerHandler::Create: Secure display VideoRamSize=%x, VideoRamPhys=%08x, VideoRamLin=%08x",vSize,iSecurevRamPhys,pV2));
sl@0
   280
sl@0
   281
	// TO DO: (mandatory)
sl@0
   282
	// initialise the secure screen's palette for the initial display mode
sl@0
   283
	//
sl@0
   284
	
sl@0
   285
	// setup the video info structure, this'll be used to remember the video settings
sl@0
   286
	iVideoInfo.iDisplayMode = KConfigLcdInitialDisplayMode;
sl@0
   287
	iVideoInfo.iOffsetToFirstPixel = Lcd_Mode_Config[KConfigLcdInitialDisplayMode].iOffsetToFirstVideoBuffer;
sl@0
   288
	iVideoInfo.iIsPalettized = Lcd_Mode_Config[KConfigLcdInitialDisplayMode].iIsPalettized;
sl@0
   289
	iVideoInfo.iOffsetBetweenLines = Lcd_Mode_Config[KConfigLcdInitialDisplayMode].iOffsetBetweenLines;
sl@0
   290
	iVideoInfo.iBitsPerPixel = Lcd_Mode_Config[KConfigLcdInitialDisplayMode].iBitsPerPixel;
sl@0
   291
sl@0
   292
	iVideoInfo.iSizeInPixels.iWidth = KConfigLcdWidth;
sl@0
   293
	iVideoInfo.iSizeInPixels.iHeight = KConfigLcdHeight;
sl@0
   294
	iVideoInfo.iSizeInTwips.iWidth = KConfigLcdWidthInTwips;
sl@0
   295
	iVideoInfo.iSizeInTwips.iHeight = KConfigLcdHeightInTwips;
sl@0
   296
	iVideoInfo.iIsMono = KConfigLcdIsMono;
sl@0
   297
	iVideoInfo.iVideoAddress=(TInt)pV;
sl@0
   298
	iVideoInfo.iIsPixelOrderLandscape = KConfigLcdPixelOrderLandscape;
sl@0
   299
	iVideoInfo.iIsPixelOrderRGB = KConfigLcdPixelOrderRGB;
sl@0
   300
sl@0
   301
	iSecureVideoInfo = iVideoInfo;
sl@0
   302
	iSecureVideoInfo.iVideoAddress = (TInt)pV2;
sl@0
   303
sl@0
   304
	iDisplayOn = EFalse;
sl@0
   305
	iSecureDisplay = EFalse;
sl@0
   306
sl@0
   307
	// install the HAL function
sl@0
   308
	r=Kern::AddHalEntry(EHalGroupDisplay, halFunction, this);
sl@0
   309
	if (r!=KErrNone)
sl@0
   310
		return r;
sl@0
   311
sl@0
   312
	iPowerUpDfc.SetDfcQ(iDfcQ);
sl@0
   313
	iPowerDownDfc.SetDfcQ(iDfcQ);
sl@0
   314
	iMsgQ.SetDfcQ(iDfcQ);
sl@0
   315
	iMsgQ.Receive();
sl@0
   316
sl@0
   317
	// install the power handler
sl@0
   318
	// power up the screen
sl@0
   319
	Add();
sl@0
   320
	DisplayOn();
sl@0
   321
sl@0
   322
	SplashScreen();
sl@0
   323
	
sl@0
   324
	return KErrNone;
sl@0
   325
	}
sl@0
   326
sl@0
   327
/**
sl@0
   328
Turn the display on
sl@0
   329
May be called as a result of a power transition or from the HAL
sl@0
   330
If called from HAL, then the display may be already be on (iDisplayOn == ETrue)
sl@0
   331
*/
sl@0
   332
void DLcdPowerHandler::DisplayOn()
sl@0
   333
	{
sl@0
   334
	__KTRACE_OPT(KPOWER, Kern::Printf("DisplayOn %d", iDisplayOn));
sl@0
   335
	if (!iDisplayOn)				// may have been powered up already
sl@0
   336
		{
sl@0
   337
		iDisplayOn = ETrue;
sl@0
   338
		PowerUpLcd(iSecureDisplay);
sl@0
   339
		SetContrast(iContrast);
sl@0
   340
		SetBrightness(iBrightness);
sl@0
   341
		}
sl@0
   342
	}
sl@0
   343
sl@0
   344
/**
sl@0
   345
Turn the display off
sl@0
   346
May be called as a result of a power transition or from the HAL
sl@0
   347
If called from Power Manager, then the display may be already be off (iDisplayOn == EFalse)
sl@0
   348
if the platform is in silent running mode
sl@0
   349
*/
sl@0
   350
void DLcdPowerHandler::DisplayOff()
sl@0
   351
	{
sl@0
   352
	__KTRACE_OPT(KPOWER, Kern::Printf("DisplayOff %d", iDisplayOn));
sl@0
   353
	if (iDisplayOn)
sl@0
   354
		{
sl@0
   355
		iDisplayOn = EFalse;
sl@0
   356
		PowerDownLcd();
sl@0
   357
		}
sl@0
   358
	}
sl@0
   359
sl@0
   360
/**
sl@0
   361
Switch between secure and non-secure displays
sl@0
   362
sl@0
   363
@param aSecure ETrue if switching to secure display
sl@0
   364
*/
sl@0
   365
void DLcdPowerHandler::SwitchDisplay(TBool aSecure)
sl@0
   366
 	{
sl@0
   367
 	if (aSecure)
sl@0
   368
 		{
sl@0
   369
 		if (!iSecureDisplay)
sl@0
   370
 			{
sl@0
   371
 			//switch to secure display
sl@0
   372
 			DisplayOff();
sl@0
   373
 			iSecureDisplay = ETrue;
sl@0
   374
 			DisplayOn();
sl@0
   375
 			}
sl@0
   376
 		}
sl@0
   377
 	else
sl@0
   378
 		{
sl@0
   379
 		if (iSecureDisplay)
sl@0
   380
 			{
sl@0
   381
 			//switch from secure display
sl@0
   382
 			DisplayOff();
sl@0
   383
 			iSecureDisplay = EFalse;
sl@0
   384
 			DisplayOn();
sl@0
   385
 			}
sl@0
   386
 		}
sl@0
   387
 	}
sl@0
   388
sl@0
   389
/**
sl@0
   390
DFC to power up the display
sl@0
   391
*/
sl@0
   392
void DLcdPowerHandler::PowerUpDfc()
sl@0
   393
	{
sl@0
   394
	__KTRACE_OPT(KPOWER, Kern::Printf("PowerUpDfc"));
sl@0
   395
	DisplayOn();
sl@0
   396
sl@0
   397
	PowerUpDone();				// must be called from a different thread than PowerUp()
sl@0
   398
	}
sl@0
   399
sl@0
   400
/**
sl@0
   401
DFC to power down the display
sl@0
   402
*/
sl@0
   403
void DLcdPowerHandler::PowerDownDfc()
sl@0
   404
	{
sl@0
   405
	__KTRACE_OPT(KPOWER, Kern::Printf("PowerDownDfc"));
sl@0
   406
	DisplayOff();
sl@0
   407
	PowerDownDone();			// must be called from a different thread than PowerUp()
sl@0
   408
	}
sl@0
   409
sl@0
   410
/**
sl@0
   411
Schedule the power-down DFC
sl@0
   412
*/
sl@0
   413
void DLcdPowerHandler::PowerDown(TPowerState)
sl@0
   414
	{
sl@0
   415
	iPowerDownDfc.Enque();		// schedules DFC to execute on this driver's thread
sl@0
   416
	}
sl@0
   417
sl@0
   418
/**
sl@0
   419
Schedule the power-up DFC
sl@0
   420
*/
sl@0
   421
void DLcdPowerHandler::PowerUp()
sl@0
   422
	{
sl@0
   423
	iPowerUpDfc.Enque();		// schedules DFC to execute on this driver's thread
sl@0
   424
	}
sl@0
   425
sl@0
   426
/**
sl@0
   427
Power up the display
sl@0
   428
sl@0
   429
@param aSecure ETrue if powering up the secure display
sl@0
   430
*/
sl@0
   431
void DLcdPowerHandler::PowerUpLcd(TBool aSecure)
sl@0
   432
    {
sl@0
   433
sl@0
   434
	// TO DO: (mandatory)
sl@0
   435
	// Power up the display and configure it ready for use
sl@0
   436
	// Examples of things that may need initializing are:
sl@0
   437
	// panel dimensions
sl@0
   438
	// line & frame timings
sl@0
   439
	// bits-per-pixel
sl@0
   440
	// Configuring the DMA engine to map the video buffer in ivRamPhys or iSecurevRamPhys
sl@0
   441
	// contrast, brightness, backlight
sl@0
   442
	// power
sl@0
   443
	// etc. etc.
sl@0
   444
	//
sl@0
   445
    }
sl@0
   446
sl@0
   447
/**
sl@0
   448
Power down the display and the backlight
sl@0
   449
*/
sl@0
   450
void DLcdPowerHandler::PowerDownLcd()
sl@0
   451
    {
sl@0
   452
	SetBacklightState(EFalse);
sl@0
   453
sl@0
   454
	// TO DO: (mandatory)
sl@0
   455
	// Power down the display & disable LCD DMA.
sl@0
   456
	// May need to wait until the current frame has been output
sl@0
   457
	//
sl@0
   458
    }
sl@0
   459
sl@0
   460
/**
sl@0
   461
Set the Lcd contrast
sl@0
   462
sl@0
   463
@param aValue the contrast setting
sl@0
   464
*/
sl@0
   465
TInt DLcdPowerHandler::SetContrast(TInt aValue)
sl@0
   466
	{
sl@0
   467
	__KTRACE_OPT(KEXTENSION,Kern::Printf("SetContrast(%d)", aValue));
sl@0
   468
sl@0
   469
	if (aValue >= KConfigLcdMinDisplayContrast && aValue <= KConfigLcdMaxDisplayContrast)
sl@0
   470
		{
sl@0
   471
		iContrast=aValue;
sl@0
   472
		
sl@0
   473
		// TO DO: (mandatory)
sl@0
   474
		// set the contrast
sl@0
   475
		//
sl@0
   476
		return KErrNone;
sl@0
   477
		}
sl@0
   478
sl@0
   479
	return KErrArgument;
sl@0
   480
	}
sl@0
   481
sl@0
   482
/**
sl@0
   483
Set the Lcd brightness
sl@0
   484
sl@0
   485
@param aValue the brightness setting
sl@0
   486
*/
sl@0
   487
TInt DLcdPowerHandler::SetBrightness(TInt aValue)
sl@0
   488
	{
sl@0
   489
	__KTRACE_OPT(KEXTENSION,Kern::Printf("SetBrightness(%d)", aValue));
sl@0
   490
sl@0
   491
	if (aValue >= KConfigLcdMinDisplayBrightness && aValue <= KConfigLcdMaxDisplayBrightness)
sl@0
   492
		{
sl@0
   493
		iBrightness=aValue;
sl@0
   494
sl@0
   495
		// TO DO: (mandatory)
sl@0
   496
		// set the brightness
sl@0
   497
		//
sl@0
   498
		return KErrNone;
sl@0
   499
		}
sl@0
   500
	return KErrArgument;
sl@0
   501
	}
sl@0
   502
sl@0
   503
/**
sl@0
   504
Turn the backlight on
sl@0
   505
*/
sl@0
   506
void DLcdPowerHandler::BacklightOn()
sl@0
   507
    {
sl@0
   508
	// TO DO: (mandatory)
sl@0
   509
	// turn the backlight on
sl@0
   510
	//
sl@0
   511
    }
sl@0
   512
sl@0
   513
/**
sl@0
   514
Turn the backlight off
sl@0
   515
*/
sl@0
   516
void DLcdPowerHandler::BacklightOff()
sl@0
   517
    {
sl@0
   518
	// TO DO: (mandatory)
sl@0
   519
	// turn the backlight off
sl@0
   520
	//
sl@0
   521
    }
sl@0
   522
sl@0
   523
/**
sl@0
   524
Set the state of the backlight
sl@0
   525
sl@0
   526
@param aState ETrue if setting the backlight on
sl@0
   527
*/
sl@0
   528
void DLcdPowerHandler::SetBacklightState(TBool aState)
sl@0
   529
	{
sl@0
   530
	iBacklightOn=aState;
sl@0
   531
	if (iBacklightOn)
sl@0
   532
		BacklightOn();
sl@0
   533
	else
sl@0
   534
		BacklightOff();
sl@0
   535
	}
sl@0
   536
sl@0
   537
void DLcdPowerHandler::ScreenInfo(TScreenInfoV01& anInfo)
sl@0
   538
	{
sl@0
   539
	__KTRACE_OPT(KEXTENSION,Kern::Printf("DLcdPowerHandler::ScreenInfo"));
sl@0
   540
	anInfo.iWindowHandleValid=EFalse;
sl@0
   541
	anInfo.iWindowHandle=NULL;
sl@0
   542
	anInfo.iScreenAddressValid=ETrue;
sl@0
   543
	anInfo.iScreenAddress=(TAny *)(iChunk->LinearAddress());
sl@0
   544
	anInfo.iScreenSize.iWidth=KConfigLcdWidth;
sl@0
   545
	anInfo.iScreenSize.iHeight=KConfigLcdHeight;
sl@0
   546
	}
sl@0
   547
sl@0
   548
/**
sl@0
   549
Handle a message from the power handler
sl@0
   550
*/
sl@0
   551
void DLcdPowerHandler::HandleMsg(void)
sl@0
   552
	{
sl@0
   553
	
sl@0
   554
	TMessageBase* msg = iMsgQ.iMessage;
sl@0
   555
	if (msg == NULL)
sl@0
   556
		return;
sl@0
   557
sl@0
   558
	if (msg->iValue)
sl@0
   559
		DisplayOn();
sl@0
   560
	else
sl@0
   561
		DisplayOff();
sl@0
   562
	msg->Complete(KErrNone,ETrue);
sl@0
   563
	}
sl@0
   564
sl@0
   565
/**
sl@0
   566
Send a message to the power-handler message queue to turn the display on
sl@0
   567
*/
sl@0
   568
void DLcdPowerHandler::WsSwitchOnScreen()
sl@0
   569
	{
sl@0
   570
	TThreadMessage& m=Kern::Message();
sl@0
   571
	m.iValue = ETrue;
sl@0
   572
	m.SendReceive(&iMsgQ);		// send a message and block Client thread until keyboard has been powered up
sl@0
   573
	}
sl@0
   574
sl@0
   575
/**
sl@0
   576
Send a message to the power-handler message queue to turn the display off
sl@0
   577
*/
sl@0
   578
void DLcdPowerHandler::WsSwitchOffScreen()
sl@0
   579
	{
sl@0
   580
	TThreadMessage& m=Kern::Message();
sl@0
   581
	m.iValue = EFalse;
sl@0
   582
	m.SendReceive(&iMsgQ);		// send a message and block Client thread until keyboard has been powered down
sl@0
   583
	}
sl@0
   584
sl@0
   585
/**
sl@0
   586
Return information about the current display mode
sl@0
   587
sl@0
   588
@param	aInfo a structure supplied by the caller to be filled by this function.
sl@0
   589
@param	aSecure ETrue if requesting information about the secure display
sl@0
   590
@return	KErrNone if successful
sl@0
   591
*/
sl@0
   592
TInt DLcdPowerHandler::GetCurrentDisplayModeInfo(TVideoInfoV01& aInfo, TBool aSecure)
sl@0
   593
	{
sl@0
   594
	__KTRACE_OPT(KEXTENSION,Kern::Printf("GetCurrentDisplayModeInfo"));
sl@0
   595
	NKern::FMWait(&iLock);
sl@0
   596
	if (aSecure)
sl@0
   597
 		aInfo = iSecureVideoInfo;
sl@0
   598
 	else
sl@0
   599
 		aInfo = iVideoInfo;
sl@0
   600
	NKern::FMSignal(&iLock);
sl@0
   601
	return KErrNone;
sl@0
   602
	}
sl@0
   603
sl@0
   604
/**
sl@0
   605
Return information about the specified display mode
sl@0
   606
sl@0
   607
@param	aMode the display mode to query
sl@0
   608
@param	aInfo a structure supplied by the caller to be filled by this function.
sl@0
   609
@return	KErrNone if successful
sl@0
   610
*/
sl@0
   611
TInt DLcdPowerHandler::GetSpecifiedDisplayModeInfo(TInt aMode, TVideoInfoV01& aInfo)
sl@0
   612
	{
sl@0
   613
	__KTRACE_OPT(KEXTENSION,Kern::Printf("GetSpecifiedDisplayModeInfo mode is %d",aMode));
sl@0
   614
sl@0
   615
	if (aMode < 0 || aMode >= KConfigLcdNumberOfDisplayModes)
sl@0
   616
		return KErrArgument;
sl@0
   617
sl@0
   618
	NKern::FMWait(&iLock);
sl@0
   619
	aInfo = iVideoInfo;
sl@0
   620
	NKern::FMSignal(&iLock);
sl@0
   621
sl@0
   622
	if (aMode != aInfo.iDisplayMode)
sl@0
   623
		{
sl@0
   624
		aInfo.iOffsetToFirstPixel=Lcd_Mode_Config[aMode].iOffsetToFirstVideoBuffer;
sl@0
   625
		aInfo.iIsPalettized = Lcd_Mode_Config[aMode].iIsPalettized;
sl@0
   626
		aInfo.iOffsetBetweenLines=Lcd_Mode_Config[aMode].iOffsetBetweenLines;
sl@0
   627
		aInfo.iBitsPerPixel = Lcd_Mode_Config[aMode].iBitsPerPixel;
sl@0
   628
		}
sl@0
   629
	return KErrNone;
sl@0
   630
	}
sl@0
   631
sl@0
   632
/**
sl@0
   633
Set the display mode
sl@0
   634
sl@0
   635
@param	aMode the display mode to set
sl@0
   636
*/
sl@0
   637
TInt DLcdPowerHandler::SetDisplayMode(TInt aMode)
sl@0
   638
	{
sl@0
   639
sl@0
   640
	__KTRACE_OPT(KEXTENSION,Kern::Printf("SetDisplayMode = %d", aMode));
sl@0
   641
sl@0
   642
	if (aMode < 0 || aMode >= KConfigLcdNumberOfDisplayModes)
sl@0
   643
		return KErrArgument;
sl@0
   644
sl@0
   645
	NKern::FMWait(&iLock);
sl@0
   646
sl@0
   647
	// store the current mode
sl@0
   648
	iVideoInfo.iDisplayMode = aMode;
sl@0
   649
	iVideoInfo.iOffsetToFirstPixel = Lcd_Mode_Config[aMode].iOffsetToFirstVideoBuffer;
sl@0
   650
	iVideoInfo.iIsPalettized = Lcd_Mode_Config[aMode].iIsPalettized;
sl@0
   651
	iVideoInfo.iOffsetBetweenLines = Lcd_Mode_Config[aMode].iOffsetBetweenLines;
sl@0
   652
	iVideoInfo.iBitsPerPixel = Lcd_Mode_Config[aMode].iBitsPerPixel;
sl@0
   653
sl@0
   654
	// store the current mode for secure screen
sl@0
   655
	iSecureVideoInfo.iDisplayMode = aMode;
sl@0
   656
	iSecureVideoInfo.iOffsetToFirstPixel = Lcd_Mode_Config[aMode].iOffsetToFirstVideoBuffer;
sl@0
   657
	iSecureVideoInfo.iIsPalettized = Lcd_Mode_Config[aMode].iIsPalettized;
sl@0
   658
	iSecureVideoInfo.iOffsetBetweenLines = Lcd_Mode_Config[aMode].iOffsetBetweenLines;
sl@0
   659
	iSecureVideoInfo.iBitsPerPixel = Lcd_Mode_Config[aMode].iBitsPerPixel;
sl@0
   660
	
sl@0
   661
	// TO DO: (mandatory)
sl@0
   662
	// set bits per pixel on hardware
sl@0
   663
	// May need to reconfigure DMA if video buffer size and location have changed
sl@0
   664
	//
sl@0
   665
	NKern::FMSignal(&iLock);
sl@0
   666
sl@0
   667
	__KTRACE_OPT(KEXTENSION,Kern::Printf("SetDisplayMode mode = %d, otfp = %d, palettized = %d, bpp = %d, obl = %d",
sl@0
   668
		aMode, iVideoInfo.iOffsetToFirstPixel, iVideoInfo.iIsPalettized, iVideoInfo.iBitsPerPixel, iVideoInfo.iOffsetBetweenLines));
sl@0
   669
sl@0
   670
	return KErrNone;
sl@0
   671
	}
sl@0
   672
sl@0
   673
/**
sl@0
   674
Fill the video memory with an initial pattern or image
sl@0
   675
This will be displayed on boot-up
sl@0
   676
*/
sl@0
   677
void DLcdPowerHandler::SplashScreen()
sl@0
   678
	{
sl@0
   679
	// TO DO: (optional)
sl@0
   680
	// replace the example code below to display a different spash screen
sl@0
   681
sl@0
   682
	// initialise the video ram to be a splash screen
sl@0
   683
	__KTRACE_OPT(KEXTENSION,Kern::Printf("SplashScreen"));
sl@0
   684
sl@0
   685
	TUint x,y;
sl@0
   686
	TUint8 * p = (TUint8*)(iVideoInfo.iVideoAddress + iVideoInfo.iOffsetToFirstPixel);
sl@0
   687
sl@0
   688
	//draw >< on screen
sl@0
   689
	TUint rsh = KConfigLcdHeight;
sl@0
   690
	TUint rsw = KConfigLcdWidth;
sl@0
   691
	for (y = 0; y < rsh>>1; y++)
sl@0
   692
		{
sl@0
   693
		TUint8* q = p;
sl@0
   694
		for (x = 0; x < rsw; x++)
sl@0
   695
			*p++ = (x < y || (rsw-x<y)) ? 1 : 2;
sl@0
   696
		p = q + iVideoInfo.iOffsetBetweenLines;
sl@0
   697
		}
sl@0
   698
	for (y = rsh>>1; y < rsh; y++)
sl@0
   699
		{
sl@0
   700
		TUint8* q = p;
sl@0
   701
		for (x = 0; x < rsw; x++)
sl@0
   702
			*p++ = ((x < rsh-y) || (rsw-x<rsh-y)) ? 1 : 2;
sl@0
   703
		p = q + iVideoInfo.iOffsetBetweenLines;
sl@0
   704
		}
sl@0
   705
sl@0
   706
	p = (TUint8*)(iSecureVideoInfo.iVideoAddress + iSecureVideoInfo.iOffsetToFirstPixel);
sl@0
   707
sl@0
   708
	//draw >< on secure screen
sl@0
   709
	for (y = 0; y < rsh>>1; y++)
sl@0
   710
		{
sl@0
   711
		TUint8* q = p;
sl@0
   712
		for (x = 0; x < rsw; x++)
sl@0
   713
			*p++ = (x < y || (rsw-x<y)) ? 1 : 2;
sl@0
   714
		p = q + iSecureVideoInfo.iOffsetBetweenLines;
sl@0
   715
		}
sl@0
   716
	for (y = rsh>>1; y < rsh; y++)
sl@0
   717
		{
sl@0
   718
		TUint8* q = p;
sl@0
   719
		for (x = 0; x < rsw; x++)
sl@0
   720
			*p++ = ((x < rsh-y) || (rsw-x<rsh-y)) ? 1 : 2;
sl@0
   721
		p = q + iSecureVideoInfo.iOffsetBetweenLines;
sl@0
   722
		}
sl@0
   723
	}
sl@0
   724
sl@0
   725
sl@0
   726
/**
sl@0
   727
Get the size of the pallete
sl@0
   728
sl@0
   729
@return	the number of pallete entries
sl@0
   730
*/
sl@0
   731
TInt DLcdPowerHandler::NumberOfPaletteEntries()		//only call when holding mutex
sl@0
   732
	{
sl@0
   733
	// TO DO: (mandatory)
sl@0
   734
	// Calculate the number of Palette entries - this is normally 
sl@0
   735
	// calculated from the bits per-pixel.
sl@0
   736
	// This is only example code... you may need to modify it for your hardware
sl@0
   737
	//
sl@0
   738
	TInt num = iVideoInfo.iIsPalettized ? 1<<iVideoInfo.iBitsPerPixel : 0;
sl@0
   739
sl@0
   740
	__KTRACE_OPT(KEXTENSION,Kern::Printf("NumberOfPaletteEntries = %d", num));
sl@0
   741
sl@0
   742
	return num;
sl@0
   743
	}
sl@0
   744
sl@0
   745
sl@0
   746
/** 
sl@0
   747
Retrieve the palette entry at a particular offset
sl@0
   748
sl@0
   749
@param	aEntry the palette index
sl@0
   750
@param	aColor a caller-supplied pointer to a location where the returned RGB color is to be stored
sl@0
   751
@return	KErrNone if successful
sl@0
   752
		KErrNotSupported if the current vide mode does not support a palette
sl@0
   753
		KErrArgument if aEntry is out of range
sl@0
   754
*/
sl@0
   755
TInt DLcdPowerHandler::GetPaletteEntry(TInt aEntry, TInt* aColor)
sl@0
   756
	{
sl@0
   757
	NKern::FMWait(&iLock);
sl@0
   758
	if (!iVideoInfo.iIsPalettized)
sl@0
   759
		{
sl@0
   760
		NKern::FMSignal(&iLock);
sl@0
   761
		return KErrNotSupported;
sl@0
   762
		}
sl@0
   763
sl@0
   764
	if ((aEntry < 0) || (aEntry >= NumberOfPaletteEntries()))
sl@0
   765
		{
sl@0
   766
		NKern::FMSignal(&iLock);
sl@0
   767
		return KErrArgument;
sl@0
   768
		}
sl@0
   769
sl@0
   770
	// TO DO: (mandatory)
sl@0
   771
	// read the RGB value of the palette entry into aColor
sl@0
   772
	// NOTE: the palette could either be a buffer allocated in system RAM (usually contiguous to Video buffer)
sl@0
   773
	//		 or could be offered as part of the hardware block that implemenst the lcd control
sl@0
   774
	//
sl@0
   775
	NKern::FMSignal(&iLock);
sl@0
   776
sl@0
   777
	__KTRACE_OPT(KEXTENSION,Kern::Printf("GetPaletteEntry %d color 0x%x", aEntry, aColor));
sl@0
   778
sl@0
   779
	return KErrNone;
sl@0
   780
	}
sl@0
   781
sl@0
   782
/** 
sl@0
   783
Set the palette entry at a particular offset
sl@0
   784
sl@0
   785
@param	aEntry the palette index
sl@0
   786
@param	aColor the RGB color to store
sl@0
   787
@return	KErrNone if successful
sl@0
   788
		KErrNotSupported if the current vide mode does not support a palette
sl@0
   789
		KErrArgument if aEntry is out of range
sl@0
   790
*/
sl@0
   791
TInt DLcdPowerHandler::SetPaletteEntry(TInt aEntry, TInt aColor)
sl@0
   792
	{
sl@0
   793
sl@0
   794
	NKern::FMWait(&iLock);
sl@0
   795
	if (!iVideoInfo.iIsPalettized)
sl@0
   796
		{
sl@0
   797
		NKern::FMSignal(&iLock);
sl@0
   798
		return KErrNotSupported;
sl@0
   799
		}
sl@0
   800
sl@0
   801
	if ((aEntry < 0) || (aEntry >= NumberOfPaletteEntries()))	//check entry in range
sl@0
   802
		{
sl@0
   803
		NKern::FMSignal(&iLock);
sl@0
   804
		return KErrArgument;
sl@0
   805
		}
sl@0
   806
sl@0
   807
	// TO DO: (mandatory)
sl@0
   808
	// update the palette entry for the secure and non-secure screen
sl@0
   809
	// NOTE: the palette could either be a buffer allocated in system RAM (usually contiguous to Video buffer)
sl@0
   810
	//		 or could be offered as part of the hardware block that implemenst the lcd control
sl@0
   811
	//
sl@0
   812
	__KTRACE_OPT(KEXTENSION,Kern::Printf("SetPaletteEntry %d to 0x%x", aEntry, aColor ));
sl@0
   813
sl@0
   814
	return KErrNone;
sl@0
   815
	}
sl@0
   816
sl@0
   817
/**
sl@0
   818
a HAL entry handling function for HAL group attribute EHalGroupDisplay
sl@0
   819
sl@0
   820
@param	a1 an arbitrary argument
sl@0
   821
@param	a2 an arbitrary argument
sl@0
   822
@return	KErrNone if successful
sl@0
   823
*/
sl@0
   824
TInt DLcdPowerHandler::HalFunction(TInt aFunction, TAny* a1, TAny* a2)
sl@0
   825
	{
sl@0
   826
	__e32_memory_barrier(); // Ensure changes from other clients are picked up
sl@0
   827
sl@0
   828
	TInt r=KErrNone;
sl@0
   829
	switch(aFunction)
sl@0
   830
		{
sl@0
   831
		case EDisplayHalScreenInfo:
sl@0
   832
			{
sl@0
   833
			TPckgBuf<TScreenInfoV01> vPckg;
sl@0
   834
			ScreenInfo(vPckg());
sl@0
   835
			Kern::InfoCopy(*(TDes8*)a1,vPckg);
sl@0
   836
			break;
sl@0
   837
			}
sl@0
   838
sl@0
   839
		case EDisplayHalWsRegisterSwitchOnScreenHandling:
sl@0
   840
			iWsSwitchOnScreen=(TBool)a1;
sl@0
   841
			break;
sl@0
   842
		
sl@0
   843
		case EDisplayHalWsSwitchOnScreen:
sl@0
   844
			WsSwitchOnScreen();
sl@0
   845
			break;
sl@0
   846
sl@0
   847
		case EDisplayHalMaxDisplayContrast:
sl@0
   848
			{
sl@0
   849
			TInt mc=KConfigLcdMaxDisplayContrast;
sl@0
   850
			kumemput32(a1,&mc,sizeof(mc));
sl@0
   851
			break;
sl@0
   852
			}
sl@0
   853
		case EDisplayHalSetDisplayContrast:
sl@0
   854
			if(!Kern::CurrentThreadHasCapability(ECapabilityWriteDeviceData,__PLATSEC_DIAGNOSTIC_STRING("Checked by Hal function EDisplayHalSetDisplayContrast")))
sl@0
   855
				return KErrPermissionDenied;
sl@0
   856
			r=SetContrast(TInt(a1));
sl@0
   857
			break;
sl@0
   858
		
sl@0
   859
		case EDisplayHalDisplayContrast:
sl@0
   860
			kumemput32(a1,&iContrast,sizeof(iContrast));
sl@0
   861
			break;
sl@0
   862
sl@0
   863
		case EDisplayHalMaxDisplayBrightness:
sl@0
   864
			{
sl@0
   865
			TInt mc=KConfigLcdMaxDisplayBrightness;
sl@0
   866
			kumemput32(a1,&mc,sizeof(mc));
sl@0
   867
			break;
sl@0
   868
			}
sl@0
   869
		
sl@0
   870
		case EDisplayHalSetDisplayBrightness:
sl@0
   871
			if(!Kern::CurrentThreadHasCapability(ECapabilityWriteDeviceData,__PLATSEC_DIAGNOSTIC_STRING("Checked by Hal function EDisplayHalSetDisplayBrightness")))
sl@0
   872
				return KErrPermissionDenied;
sl@0
   873
			r=SetBrightness(TInt(a1));
sl@0
   874
			break;
sl@0
   875
		
sl@0
   876
		case EDisplayHalDisplayBrightness:
sl@0
   877
			kumemput32(a1,&iBrightness,sizeof(iBrightness));
sl@0
   878
			break;
sl@0
   879
		
sl@0
   880
		case EDisplayHalSetBacklightOn:
sl@0
   881
			if(!Kern::CurrentThreadHasCapability(ECapabilityWriteDeviceData,__PLATSEC_DIAGNOSTIC_STRING("Checked by Hal function EDisplayHalSetBacklightOn")))
sl@0
   882
				return KErrPermissionDenied;
sl@0
   883
			if (Kern::MachinePowerStatus()<ELow)
sl@0
   884
				r=KErrBadPower;
sl@0
   885
			else
sl@0
   886
				SetBacklightState(TBool(a1));
sl@0
   887
			break;
sl@0
   888
		
sl@0
   889
		case EDisplayHalBacklightOn:
sl@0
   890
			kumemput32(a1,&iBacklightOn,sizeof(TInt));
sl@0
   891
			break;
sl@0
   892
sl@0
   893
		case EDisplayHalModeCount:
sl@0
   894
			{
sl@0
   895
			TInt ndm = KConfigLcdNumberOfDisplayModes;
sl@0
   896
			kumemput32(a1, &ndm, sizeof(ndm));
sl@0
   897
			break;
sl@0
   898
			}
sl@0
   899
		
sl@0
   900
		case EDisplayHalSetMode:
sl@0
   901
			if(!Kern::CurrentThreadHasCapability(ECapabilityMultimediaDD,__PLATSEC_DIAGNOSTIC_STRING("Checked by Hal function EDisplayHalSetMode")))
sl@0
   902
				return KErrPermissionDenied;
sl@0
   903
			r = SetDisplayMode((TInt)a1);
sl@0
   904
			break;
sl@0
   905
		
sl@0
   906
		case EDisplayHalMode:
sl@0
   907
			kumemput32(a1, &iVideoInfo.iDisplayMode, sizeof(iVideoInfo.iDisplayMode));
sl@0
   908
			break;
sl@0
   909
sl@0
   910
		case EDisplayHalSetPaletteEntry:
sl@0
   911
			if(!Kern::CurrentThreadHasCapability(ECapabilityMultimediaDD,__PLATSEC_DIAGNOSTIC_STRING("Checked by Hal function EDisplayHalSetPaletteEntry")))
sl@0
   912
				return KErrPermissionDenied;
sl@0
   913
			r = SetPaletteEntry((TInt)a1, (TInt)a2);
sl@0
   914
			break;
sl@0
   915
		
sl@0
   916
		case EDisplayHalPaletteEntry:
sl@0
   917
			{
sl@0
   918
			TInt entry;
sl@0
   919
			kumemget32(&entry, a1, sizeof(TInt));
sl@0
   920
			TInt x;
sl@0
   921
			r = GetPaletteEntry(entry, &x);
sl@0
   922
			if (r == KErrNone)
sl@0
   923
				kumemput32(a2, &x, sizeof(x));
sl@0
   924
			break;
sl@0
   925
			}
sl@0
   926
		
sl@0
   927
		case EDisplayHalSetState:
sl@0
   928
			{
sl@0
   929
			if(!Kern::CurrentThreadHasCapability(ECapabilityPowerMgmt,__PLATSEC_DIAGNOSTIC_STRING("Checked by Hal function EDisplayHalSetState")))
sl@0
   930
				return KErrPermissionDenied;
sl@0
   931
			if ((TBool)a1)
sl@0
   932
				{
sl@0
   933
				WsSwitchOnScreen();
sl@0
   934
				}
sl@0
   935
			else
sl@0
   936
				{
sl@0
   937
				WsSwitchOffScreen();
sl@0
   938
				}
sl@0
   939
			break;
sl@0
   940
			}
sl@0
   941
sl@0
   942
		case EDisplayHalState:
sl@0
   943
			kumemput32(a1, &iDisplayOn, sizeof(TBool));
sl@0
   944
			break;
sl@0
   945
sl@0
   946
		case EDisplayHalColors:
sl@0
   947
			{
sl@0
   948
			TInt mdc = KConfigLcdMaxDisplayColors;
sl@0
   949
			kumemput32(a1, &mdc, sizeof(mdc));
sl@0
   950
			break;
sl@0
   951
			}
sl@0
   952
sl@0
   953
		case EDisplayHalCurrentModeInfo:
sl@0
   954
			{
sl@0
   955
			TPckgBuf<TVideoInfoV01> vPckg;
sl@0
   956
			r = GetCurrentDisplayModeInfo(vPckg(), (TBool)a2);
sl@0
   957
			if (KErrNone == r)
sl@0
   958
				Kern::InfoCopy(*(TDes8*)a1,vPckg);
sl@0
   959
			}
sl@0
   960
			break;
sl@0
   961
sl@0
   962
		case EDisplayHalSpecifiedModeInfo:
sl@0
   963
			{
sl@0
   964
			TPckgBuf<TVideoInfoV01> vPckg;
sl@0
   965
			TInt mode;
sl@0
   966
			kumemget32(&mode, a1, sizeof(mode));
sl@0
   967
			r = GetSpecifiedDisplayModeInfo(mode, vPckg());
sl@0
   968
			if (KErrNone == r)
sl@0
   969
				Kern::InfoCopy(*(TDes8*)a2,vPckg);
sl@0
   970
			}
sl@0
   971
			break;
sl@0
   972
			
sl@0
   973
		case EDisplayHalSecure:
sl@0
   974
			kumemput32(a1, &iSecureDisplay, sizeof(TBool));
sl@0
   975
			break;
sl@0
   976
sl@0
   977
		case EDisplayHalSetSecure:
sl@0
   978
			{
sl@0
   979
			if(!Kern::CurrentThreadHasCapability(ECapabilityMultimediaDD,__PLATSEC_DIAGNOSTIC_STRING("Checked by Hal function EDisplayHalSetSecure")))
sl@0
   980
				return KErrPermissionDenied;
sl@0
   981
			SwitchDisplay((TBool)a1);
sl@0
   982
			}
sl@0
   983
			break;
sl@0
   984
sl@0
   985
		default:
sl@0
   986
			r=KErrNotSupported;
sl@0
   987
			break;
sl@0
   988
		}
sl@0
   989
sl@0
   990
	__e32_memory_barrier(); // Ensure any changes are propagated to other clients
sl@0
   991
sl@0
   992
	return r;
sl@0
   993
	}
sl@0
   994
sl@0
   995
sl@0
   996
DECLARE_STANDARD_EXTENSION()
sl@0
   997
	{
sl@0
   998
	__KTRACE_OPT(KPOWER,Kern::Printf("Starting LCD power manager"));
sl@0
   999
sl@0
  1000
	// create LCD power handler
sl@0
  1001
	TInt r=KErrNoMemory;
sl@0
  1002
	DLcdPowerHandler* pH=new DLcdPowerHandler;
sl@0
  1003
	if (pH)
sl@0
  1004
		r=pH->Create();
sl@0
  1005
sl@0
  1006
	__KTRACE_OPT(KPOWER,Kern::Printf("Returns %d",r));
sl@0
  1007
	return r;
sl@0
  1008
	}
sl@0
  1009