Update contrib.
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".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
14 // template\Template_Variant\Specific\lcd.cpp
15 // Implementation of an LCD driver.
16 // This file is part of the Template 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.
24 #include <videodriver.h>
27 #include <kernel/kernel.h>
28 #include <kernel/kern_priv.h>
29 #include <kernel/kpower.h>
30 #include <template_assp_priv.h>
34 // If the display supports Contrast and/or Brightness control then supply the following defines:
35 // This is only example code... you may need to modify it for your hardware
36 const TInt KConfigInitialDisplayContrast = 128;
37 const TInt KConfigLcdMinDisplayContrast = 1;
38 const TInt KConfigLcdMaxDisplayContrast = 255;
39 const TInt KConfigInitialDisplayBrightness = 128;
40 const TInt KConfigLcdMinDisplayBrightness = 1;
41 const TInt KConfigLcdMaxDisplayBrightness = 255;
44 // define a macro to calculate the screen buffer size
45 // This is only example code... you may need to modify it for your hardware
46 // aBpp is the number of bits-per-pixel, aPpl is the number of pixels per line and
47 // aLpp number of lines per panel
48 #define FRAME_BUFFER_SIZE(aBpp,aPpl,aLpp) (aBpp*aPpl*aLpp)/8
52 // define the physical screen dimensions
53 // This is only example code... you need to modify it for your hardware
54 const TUint KConfigLcdWidth = 640; // 640 pixels per line
55 const TUint KConfigLcdHeight = 480; // 480 lines per panel
58 // define the characteristics of the LCD display
59 // This is only example code... you need to modify it for your hardware
60 const TBool KConfigLcdIsMono = EFalse;
61 const TBool KConfigLcdPixelOrderLandscape = ETrue;
62 const TBool KConfigLcdPixelOrderRGB = ETrue;
63 const TInt KConfigLcdMaxDisplayColors = 65536;
67 // define the display dimensions in TWIPs
68 // A TWIP is a 20th of a point. A point is a 72nd of an inch
69 // Therefore a TWIP is a 1440th of an inch
70 // This is only example code... you need to modify it for your hardware
71 const TInt KConfigLcdWidthInTwips = 9638; // = 6.69 inches
72 const TInt KConfigLcdHeightInTwips = 7370; // = 5.11 inches
75 // define the available display modes
76 // This is only example code... you need to modify it for your hardware
77 const TInt KConfigLcdNumberOfDisplayModes = 1;
78 const TInt KConfigLcdInitialDisplayMode = 0;
82 TInt iOffsetToFirstVideoBuffer;
83 TInt iLenghtOfVideoBufferInBytes;
84 TInt iOffsetBetweenLines;
88 static const SLcdConfig Lcd_Mode_Config[KConfigLcdNumberOfDisplayModes]=
92 0, // iOffsetToFirstVideoBuffer
93 FRAME_BUFFER_SIZE(8, KConfigLcdWidth, KConfigLcdHeight), // iLenghtOfVideoBufferInBytes
94 KConfigLcdWidth, // iOffsetBetweenLines
95 ETrue, // iIsPalettized
107 // Add any private functions and data you require
109 NONSHARABLE_CLASS(DLcdPowerHandler) : public DPowerHandler
115 // from DPowerHandler
116 void PowerDown(TPowerState);
125 TInt HalFunction(TInt aFunction, TAny* a1, TAny* a2);
127 void PowerUpLcd(TBool aSecure);
130 void ScreenInfo(TScreenInfoV01& aInfo);
131 void WsSwitchOnScreen();
132 void WsSwitchOffScreen();
134 void SwitchDisplay(TBool aSecure);
136 void SetBacklightState(TBool aState);
139 TInt SetContrast(TInt aContrast);
140 TInt SetBrightness(TInt aBrightness);
143 TInt SetPaletteEntry(TInt aEntry, TInt aColor);
144 TInt GetPaletteEntry(TInt aEntry, TInt* aColor);
145 TInt NumberOfPaletteEntries();
146 TInt GetCurrentDisplayModeInfo(TVideoInfoV01& aInfo, TBool aSecure);
147 TInt GetSpecifiedDisplayModeInfo(TInt aMode, TVideoInfoV01& aInfo);
148 TInt SetDisplayMode(TInt aMode);
150 TInt GetDisplayColors(TInt* aColors);
154 TBool iDisplayOn; // to prevent a race condition with WServer trying to power up/down at the same time
155 DPlatChunkHw* iChunk;
156 DPlatChunkHw* iSecureChunk;
157 TBool iWsSwitchOnScreen;
158 TBool iSecureDisplay;
159 TDynamicDfcQue* iDfcQ;
163 TVideoInfoV01 iVideoInfo;
164 TVideoInfoV01 iSecureVideoInfo;
165 NFastMutex iLock; // protects against being preempted whilst manipulating iVideoInfo/iSecureVideoInfo
167 TPhysAddr iSecurevRamPhys;
178 @param aPtr a pointer to an instance of DLcdPowerHandler
179 @param aFunction the function number
180 @param a1 an arbitrary parameter
181 @param a2 an arbitrary parameter
183 LOCAL_C TInt halFunction(TAny* aPtr, TInt aFunction, TAny* a1, TAny* a2)
185 DLcdPowerHandler* pH=(DLcdPowerHandler*)aPtr;
186 return pH->HalFunction(aFunction,a1,a2);
190 DFC for receiving messages from the power handler
191 @param aPtr a pointer to an instance of DLcdPowerHandler
193 void rxMsg(TAny* aPtr)
195 DLcdPowerHandler& h=*(DLcdPowerHandler*)aPtr;
200 DFC for powering up the device
202 @param aPtr aPtr a pointer to an instance of DLcdPowerHandler
204 void power_up_dfc(TAny* aPtr)
206 ((DLcdPowerHandler*)aPtr)->PowerUpDfc();
210 DFC for powering down the device
212 @param aPtr aPtr a pointer to an instance of DLcdPowerHandler
214 void power_down_dfc(TAny* aPtr)
216 ((DLcdPowerHandler*)aPtr)->PowerDownDfc();
223 DLcdPowerHandler::DLcdPowerHandler() :
224 DPowerHandler(KLitLcd),
225 iMsgQ(rxMsg,this,NULL,1),
226 iPowerUpDfc(&power_up_dfc,this,6),
227 iPowerDownDfc(&power_down_dfc,this,7),
228 iBacklightOn(EFalse),
229 iContrast(KConfigInitialDisplayContrast),
230 iBrightness(KConfigInitialDisplayBrightness)
234 DLcdPowerHandler::~DLcdPowerHandler()
241 Second-phase constructor
243 Called by factory function at ordinal 0
245 TInt DLcdPowerHandler::Create()
247 const TInt KLCDDfcQPriority=27; // Equal to Kern::DfcQue0() priority
248 TInt r = Kern::DynamicDfcQCreate(iDfcQ, KLCDDfcQPriority, _L("LCDPowerHandler"));
255 TInt vSize = ((TemplateAssp*)Arch::TheAsic())->VideoRamSize();
256 ivRamPhys = TTemplate::VideoRamPhys(); // EXAMPLE ONLY: assume TTemplate interface class
257 r = DPlatChunkHw::New(iChunk,ivRamPhys,vSize,EMapAttrUserRw|EMapAttrBufferedC);
261 //create "secure" screen immediately after normal one
262 iSecurevRamPhys = ivRamPhys + vSize;
263 TInt r2 = DPlatChunkHw::New(iSecureChunk,iSecurevRamPhys,vSize,EMapAttrUserRw|EMapAttrBufferedC);
267 TUint* pV=(TUint*)iChunk->LinearAddress();
269 __KTRACE_OPT(KEXTENSION,Kern::Printf("DLcdPowerHandler::Create: VideoRamSize=%x, VideoRamPhys=%08x, VideoRamLin=%08x",vSize,ivRamPhys,pV));
271 // TO DO: (mandatory)
272 // initialise the palette for the initial display mode
273 // NOTE: the palette could either be a buffer allocated in system RAM (usually contiguous to Video buffer)
274 // or could be offered as part of the hardware block that implemenst the lcd control
277 TUint* pV2=(TUint*)iSecureChunk->LinearAddress();
279 __KTRACE_OPT(KEXTENSION,Kern::Printf("DLcdPowerHandler::Create: Secure display VideoRamSize=%x, VideoRamPhys=%08x, VideoRamLin=%08x",vSize,iSecurevRamPhys,pV2));
281 // TO DO: (mandatory)
282 // initialise the secure screen's palette for the initial display mode
285 // setup the video info structure, this'll be used to remember the video settings
286 iVideoInfo.iDisplayMode = KConfigLcdInitialDisplayMode;
287 iVideoInfo.iOffsetToFirstPixel = Lcd_Mode_Config[KConfigLcdInitialDisplayMode].iOffsetToFirstVideoBuffer;
288 iVideoInfo.iIsPalettized = Lcd_Mode_Config[KConfigLcdInitialDisplayMode].iIsPalettized;
289 iVideoInfo.iOffsetBetweenLines = Lcd_Mode_Config[KConfigLcdInitialDisplayMode].iOffsetBetweenLines;
290 iVideoInfo.iBitsPerPixel = Lcd_Mode_Config[KConfigLcdInitialDisplayMode].iBitsPerPixel;
292 iVideoInfo.iSizeInPixels.iWidth = KConfigLcdWidth;
293 iVideoInfo.iSizeInPixels.iHeight = KConfigLcdHeight;
294 iVideoInfo.iSizeInTwips.iWidth = KConfigLcdWidthInTwips;
295 iVideoInfo.iSizeInTwips.iHeight = KConfigLcdHeightInTwips;
296 iVideoInfo.iIsMono = KConfigLcdIsMono;
297 iVideoInfo.iVideoAddress=(TInt)pV;
298 iVideoInfo.iIsPixelOrderLandscape = KConfigLcdPixelOrderLandscape;
299 iVideoInfo.iIsPixelOrderRGB = KConfigLcdPixelOrderRGB;
301 iSecureVideoInfo = iVideoInfo;
302 iSecureVideoInfo.iVideoAddress = (TInt)pV2;
305 iSecureDisplay = EFalse;
307 // install the HAL function
308 r=Kern::AddHalEntry(EHalGroupDisplay, halFunction, this);
312 iPowerUpDfc.SetDfcQ(iDfcQ);
313 iPowerDownDfc.SetDfcQ(iDfcQ);
314 iMsgQ.SetDfcQ(iDfcQ);
317 // install the power handler
318 // power up the screen
329 May be called as a result of a power transition or from the HAL
330 If called from HAL, then the display may be already be on (iDisplayOn == ETrue)
332 void DLcdPowerHandler::DisplayOn()
334 __KTRACE_OPT(KPOWER, Kern::Printf("DisplayOn %d", iDisplayOn));
335 if (!iDisplayOn) // may have been powered up already
338 PowerUpLcd(iSecureDisplay);
339 SetContrast(iContrast);
340 SetBrightness(iBrightness);
346 May be called as a result of a power transition or from the HAL
347 If called from Power Manager, then the display may be already be off (iDisplayOn == EFalse)
348 if the platform is in silent running mode
350 void DLcdPowerHandler::DisplayOff()
352 __KTRACE_OPT(KPOWER, Kern::Printf("DisplayOff %d", iDisplayOn));
361 Switch between secure and non-secure displays
363 @param aSecure ETrue if switching to secure display
365 void DLcdPowerHandler::SwitchDisplay(TBool aSecure)
371 //switch to secure display
373 iSecureDisplay = ETrue;
381 //switch from secure display
383 iSecureDisplay = EFalse;
390 DFC to power up the display
392 void DLcdPowerHandler::PowerUpDfc()
394 __KTRACE_OPT(KPOWER, Kern::Printf("PowerUpDfc"));
397 PowerUpDone(); // must be called from a different thread than PowerUp()
401 DFC to power down the display
403 void DLcdPowerHandler::PowerDownDfc()
405 __KTRACE_OPT(KPOWER, Kern::Printf("PowerDownDfc"));
407 PowerDownDone(); // must be called from a different thread than PowerUp()
411 Schedule the power-down DFC
413 void DLcdPowerHandler::PowerDown(TPowerState)
415 iPowerDownDfc.Enque(); // schedules DFC to execute on this driver's thread
419 Schedule the power-up DFC
421 void DLcdPowerHandler::PowerUp()
423 iPowerUpDfc.Enque(); // schedules DFC to execute on this driver's thread
429 @param aSecure ETrue if powering up the secure display
431 void DLcdPowerHandler::PowerUpLcd(TBool aSecure)
434 // TO DO: (mandatory)
435 // Power up the display and configure it ready for use
436 // Examples of things that may need initializing are:
438 // line & frame timings
440 // Configuring the DMA engine to map the video buffer in ivRamPhys or iSecurevRamPhys
441 // contrast, brightness, backlight
448 Power down the display and the backlight
450 void DLcdPowerHandler::PowerDownLcd()
452 SetBacklightState(EFalse);
454 // TO DO: (mandatory)
455 // Power down the display & disable LCD DMA.
456 // May need to wait until the current frame has been output
463 @param aValue the contrast setting
465 TInt DLcdPowerHandler::SetContrast(TInt aValue)
467 __KTRACE_OPT(KEXTENSION,Kern::Printf("SetContrast(%d)", aValue));
469 if (aValue >= KConfigLcdMinDisplayContrast && aValue <= KConfigLcdMaxDisplayContrast)
473 // TO DO: (mandatory)
483 Set the Lcd brightness
485 @param aValue the brightness setting
487 TInt DLcdPowerHandler::SetBrightness(TInt aValue)
489 __KTRACE_OPT(KEXTENSION,Kern::Printf("SetBrightness(%d)", aValue));
491 if (aValue >= KConfigLcdMinDisplayBrightness && aValue <= KConfigLcdMaxDisplayBrightness)
495 // TO DO: (mandatory)
496 // set the brightness
504 Turn the backlight on
506 void DLcdPowerHandler::BacklightOn()
508 // TO DO: (mandatory)
509 // turn the backlight on
514 Turn the backlight off
516 void DLcdPowerHandler::BacklightOff()
518 // TO DO: (mandatory)
519 // turn the backlight off
524 Set the state of the backlight
526 @param aState ETrue if setting the backlight on
528 void DLcdPowerHandler::SetBacklightState(TBool aState)
537 void DLcdPowerHandler::ScreenInfo(TScreenInfoV01& anInfo)
539 __KTRACE_OPT(KEXTENSION,Kern::Printf("DLcdPowerHandler::ScreenInfo"));
540 anInfo.iWindowHandleValid=EFalse;
541 anInfo.iWindowHandle=NULL;
542 anInfo.iScreenAddressValid=ETrue;
543 anInfo.iScreenAddress=(TAny *)(iChunk->LinearAddress());
544 anInfo.iScreenSize.iWidth=KConfigLcdWidth;
545 anInfo.iScreenSize.iHeight=KConfigLcdHeight;
549 Handle a message from the power handler
551 void DLcdPowerHandler::HandleMsg(void)
554 TMessageBase* msg = iMsgQ.iMessage;
562 msg->Complete(KErrNone,ETrue);
566 Send a message to the power-handler message queue to turn the display on
568 void DLcdPowerHandler::WsSwitchOnScreen()
570 TThreadMessage& m=Kern::Message();
572 m.SendReceive(&iMsgQ); // send a message and block Client thread until keyboard has been powered up
576 Send a message to the power-handler message queue to turn the display off
578 void DLcdPowerHandler::WsSwitchOffScreen()
580 TThreadMessage& m=Kern::Message();
582 m.SendReceive(&iMsgQ); // send a message and block Client thread until keyboard has been powered down
586 Return information about the current display mode
588 @param aInfo a structure supplied by the caller to be filled by this function.
589 @param aSecure ETrue if requesting information about the secure display
590 @return KErrNone if successful
592 TInt DLcdPowerHandler::GetCurrentDisplayModeInfo(TVideoInfoV01& aInfo, TBool aSecure)
594 __KTRACE_OPT(KEXTENSION,Kern::Printf("GetCurrentDisplayModeInfo"));
595 NKern::FMWait(&iLock);
597 aInfo = iSecureVideoInfo;
600 NKern::FMSignal(&iLock);
605 Return information about the specified display mode
607 @param aMode the display mode to query
608 @param aInfo a structure supplied by the caller to be filled by this function.
609 @return KErrNone if successful
611 TInt DLcdPowerHandler::GetSpecifiedDisplayModeInfo(TInt aMode, TVideoInfoV01& aInfo)
613 __KTRACE_OPT(KEXTENSION,Kern::Printf("GetSpecifiedDisplayModeInfo mode is %d",aMode));
615 if (aMode < 0 || aMode >= KConfigLcdNumberOfDisplayModes)
618 NKern::FMWait(&iLock);
620 NKern::FMSignal(&iLock);
622 if (aMode != aInfo.iDisplayMode)
624 aInfo.iOffsetToFirstPixel=Lcd_Mode_Config[aMode].iOffsetToFirstVideoBuffer;
625 aInfo.iIsPalettized = Lcd_Mode_Config[aMode].iIsPalettized;
626 aInfo.iOffsetBetweenLines=Lcd_Mode_Config[aMode].iOffsetBetweenLines;
627 aInfo.iBitsPerPixel = Lcd_Mode_Config[aMode].iBitsPerPixel;
635 @param aMode the display mode to set
637 TInt DLcdPowerHandler::SetDisplayMode(TInt aMode)
640 __KTRACE_OPT(KEXTENSION,Kern::Printf("SetDisplayMode = %d", aMode));
642 if (aMode < 0 || aMode >= KConfigLcdNumberOfDisplayModes)
645 NKern::FMWait(&iLock);
647 // store the current mode
648 iVideoInfo.iDisplayMode = aMode;
649 iVideoInfo.iOffsetToFirstPixel = Lcd_Mode_Config[aMode].iOffsetToFirstVideoBuffer;
650 iVideoInfo.iIsPalettized = Lcd_Mode_Config[aMode].iIsPalettized;
651 iVideoInfo.iOffsetBetweenLines = Lcd_Mode_Config[aMode].iOffsetBetweenLines;
652 iVideoInfo.iBitsPerPixel = Lcd_Mode_Config[aMode].iBitsPerPixel;
654 // store the current mode for secure screen
655 iSecureVideoInfo.iDisplayMode = aMode;
656 iSecureVideoInfo.iOffsetToFirstPixel = Lcd_Mode_Config[aMode].iOffsetToFirstVideoBuffer;
657 iSecureVideoInfo.iIsPalettized = Lcd_Mode_Config[aMode].iIsPalettized;
658 iSecureVideoInfo.iOffsetBetweenLines = Lcd_Mode_Config[aMode].iOffsetBetweenLines;
659 iSecureVideoInfo.iBitsPerPixel = Lcd_Mode_Config[aMode].iBitsPerPixel;
661 // TO DO: (mandatory)
662 // set bits per pixel on hardware
663 // May need to reconfigure DMA if video buffer size and location have changed
665 NKern::FMSignal(&iLock);
667 __KTRACE_OPT(KEXTENSION,Kern::Printf("SetDisplayMode mode = %d, otfp = %d, palettized = %d, bpp = %d, obl = %d",
668 aMode, iVideoInfo.iOffsetToFirstPixel, iVideoInfo.iIsPalettized, iVideoInfo.iBitsPerPixel, iVideoInfo.iOffsetBetweenLines));
674 Fill the video memory with an initial pattern or image
675 This will be displayed on boot-up
677 void DLcdPowerHandler::SplashScreen()
680 // replace the example code below to display a different spash screen
682 // initialise the video ram to be a splash screen
683 __KTRACE_OPT(KEXTENSION,Kern::Printf("SplashScreen"));
686 TUint8 * p = (TUint8*)(iVideoInfo.iVideoAddress + iVideoInfo.iOffsetToFirstPixel);
689 TUint rsh = KConfigLcdHeight;
690 TUint rsw = KConfigLcdWidth;
691 for (y = 0; y < rsh>>1; y++)
694 for (x = 0; x < rsw; x++)
695 *p++ = (x < y || (rsw-x<y)) ? 1 : 2;
696 p = q + iVideoInfo.iOffsetBetweenLines;
698 for (y = rsh>>1; y < rsh; y++)
701 for (x = 0; x < rsw; x++)
702 *p++ = ((x < rsh-y) || (rsw-x<rsh-y)) ? 1 : 2;
703 p = q + iVideoInfo.iOffsetBetweenLines;
706 p = (TUint8*)(iSecureVideoInfo.iVideoAddress + iSecureVideoInfo.iOffsetToFirstPixel);
708 //draw >< on secure screen
709 for (y = 0; y < rsh>>1; y++)
712 for (x = 0; x < rsw; x++)
713 *p++ = (x < y || (rsw-x<y)) ? 1 : 2;
714 p = q + iSecureVideoInfo.iOffsetBetweenLines;
716 for (y = rsh>>1; y < rsh; y++)
719 for (x = 0; x < rsw; x++)
720 *p++ = ((x < rsh-y) || (rsw-x<rsh-y)) ? 1 : 2;
721 p = q + iSecureVideoInfo.iOffsetBetweenLines;
727 Get the size of the pallete
729 @return the number of pallete entries
731 TInt DLcdPowerHandler::NumberOfPaletteEntries() //only call when holding mutex
733 // TO DO: (mandatory)
734 // Calculate the number of Palette entries - this is normally
735 // calculated from the bits per-pixel.
736 // This is only example code... you may need to modify it for your hardware
738 TInt num = iVideoInfo.iIsPalettized ? 1<<iVideoInfo.iBitsPerPixel : 0;
740 __KTRACE_OPT(KEXTENSION,Kern::Printf("NumberOfPaletteEntries = %d", num));
747 Retrieve the palette entry at a particular offset
749 @param aEntry the palette index
750 @param aColor a caller-supplied pointer to a location where the returned RGB color is to be stored
751 @return KErrNone if successful
752 KErrNotSupported if the current vide mode does not support a palette
753 KErrArgument if aEntry is out of range
755 TInt DLcdPowerHandler::GetPaletteEntry(TInt aEntry, TInt* aColor)
757 NKern::FMWait(&iLock);
758 if (!iVideoInfo.iIsPalettized)
760 NKern::FMSignal(&iLock);
761 return KErrNotSupported;
764 if ((aEntry < 0) || (aEntry >= NumberOfPaletteEntries()))
766 NKern::FMSignal(&iLock);
770 // TO DO: (mandatory)
771 // read the RGB value of the palette entry into aColor
772 // NOTE: the palette could either be a buffer allocated in system RAM (usually contiguous to Video buffer)
773 // or could be offered as part of the hardware block that implemenst the lcd control
775 NKern::FMSignal(&iLock);
777 __KTRACE_OPT(KEXTENSION,Kern::Printf("GetPaletteEntry %d color 0x%x", aEntry, aColor));
783 Set the palette entry at a particular offset
785 @param aEntry the palette index
786 @param aColor the RGB color to store
787 @return KErrNone if successful
788 KErrNotSupported if the current vide mode does not support a palette
789 KErrArgument if aEntry is out of range
791 TInt DLcdPowerHandler::SetPaletteEntry(TInt aEntry, TInt aColor)
794 NKern::FMWait(&iLock);
795 if (!iVideoInfo.iIsPalettized)
797 NKern::FMSignal(&iLock);
798 return KErrNotSupported;
801 if ((aEntry < 0) || (aEntry >= NumberOfPaletteEntries())) //check entry in range
803 NKern::FMSignal(&iLock);
807 // TO DO: (mandatory)
808 // update the palette entry for the secure and non-secure screen
809 // NOTE: the palette could either be a buffer allocated in system RAM (usually contiguous to Video buffer)
810 // or could be offered as part of the hardware block that implemenst the lcd control
812 __KTRACE_OPT(KEXTENSION,Kern::Printf("SetPaletteEntry %d to 0x%x", aEntry, aColor ));
818 a HAL entry handling function for HAL group attribute EHalGroupDisplay
820 @param a1 an arbitrary argument
821 @param a2 an arbitrary argument
822 @return KErrNone if successful
824 TInt DLcdPowerHandler::HalFunction(TInt aFunction, TAny* a1, TAny* a2)
826 __e32_memory_barrier(); // Ensure changes from other clients are picked up
831 case EDisplayHalScreenInfo:
833 TPckgBuf<TScreenInfoV01> vPckg;
835 Kern::InfoCopy(*(TDes8*)a1,vPckg);
839 case EDisplayHalWsRegisterSwitchOnScreenHandling:
840 iWsSwitchOnScreen=(TBool)a1;
843 case EDisplayHalWsSwitchOnScreen:
847 case EDisplayHalMaxDisplayContrast:
849 TInt mc=KConfigLcdMaxDisplayContrast;
850 kumemput32(a1,&mc,sizeof(mc));
853 case EDisplayHalSetDisplayContrast:
854 if(!Kern::CurrentThreadHasCapability(ECapabilityWriteDeviceData,__PLATSEC_DIAGNOSTIC_STRING("Checked by Hal function EDisplayHalSetDisplayContrast")))
855 return KErrPermissionDenied;
856 r=SetContrast(TInt(a1));
859 case EDisplayHalDisplayContrast:
860 kumemput32(a1,&iContrast,sizeof(iContrast));
863 case EDisplayHalMaxDisplayBrightness:
865 TInt mc=KConfigLcdMaxDisplayBrightness;
866 kumemput32(a1,&mc,sizeof(mc));
870 case EDisplayHalSetDisplayBrightness:
871 if(!Kern::CurrentThreadHasCapability(ECapabilityWriteDeviceData,__PLATSEC_DIAGNOSTIC_STRING("Checked by Hal function EDisplayHalSetDisplayBrightness")))
872 return KErrPermissionDenied;
873 r=SetBrightness(TInt(a1));
876 case EDisplayHalDisplayBrightness:
877 kumemput32(a1,&iBrightness,sizeof(iBrightness));
880 case EDisplayHalSetBacklightOn:
881 if(!Kern::CurrentThreadHasCapability(ECapabilityWriteDeviceData,__PLATSEC_DIAGNOSTIC_STRING("Checked by Hal function EDisplayHalSetBacklightOn")))
882 return KErrPermissionDenied;
883 if (Kern::MachinePowerStatus()<ELow)
886 SetBacklightState(TBool(a1));
889 case EDisplayHalBacklightOn:
890 kumemput32(a1,&iBacklightOn,sizeof(TInt));
893 case EDisplayHalModeCount:
895 TInt ndm = KConfigLcdNumberOfDisplayModes;
896 kumemput32(a1, &ndm, sizeof(ndm));
900 case EDisplayHalSetMode:
901 if(!Kern::CurrentThreadHasCapability(ECapabilityMultimediaDD,__PLATSEC_DIAGNOSTIC_STRING("Checked by Hal function EDisplayHalSetMode")))
902 return KErrPermissionDenied;
903 r = SetDisplayMode((TInt)a1);
906 case EDisplayHalMode:
907 kumemput32(a1, &iVideoInfo.iDisplayMode, sizeof(iVideoInfo.iDisplayMode));
910 case EDisplayHalSetPaletteEntry:
911 if(!Kern::CurrentThreadHasCapability(ECapabilityMultimediaDD,__PLATSEC_DIAGNOSTIC_STRING("Checked by Hal function EDisplayHalSetPaletteEntry")))
912 return KErrPermissionDenied;
913 r = SetPaletteEntry((TInt)a1, (TInt)a2);
916 case EDisplayHalPaletteEntry:
919 kumemget32(&entry, a1, sizeof(TInt));
921 r = GetPaletteEntry(entry, &x);
923 kumemput32(a2, &x, sizeof(x));
927 case EDisplayHalSetState:
929 if(!Kern::CurrentThreadHasCapability(ECapabilityPowerMgmt,__PLATSEC_DIAGNOSTIC_STRING("Checked by Hal function EDisplayHalSetState")))
930 return KErrPermissionDenied;
942 case EDisplayHalState:
943 kumemput32(a1, &iDisplayOn, sizeof(TBool));
946 case EDisplayHalColors:
948 TInt mdc = KConfigLcdMaxDisplayColors;
949 kumemput32(a1, &mdc, sizeof(mdc));
953 case EDisplayHalCurrentModeInfo:
955 TPckgBuf<TVideoInfoV01> vPckg;
956 r = GetCurrentDisplayModeInfo(vPckg(), (TBool)a2);
958 Kern::InfoCopy(*(TDes8*)a1,vPckg);
962 case EDisplayHalSpecifiedModeInfo:
964 TPckgBuf<TVideoInfoV01> vPckg;
966 kumemget32(&mode, a1, sizeof(mode));
967 r = GetSpecifiedDisplayModeInfo(mode, vPckg());
969 Kern::InfoCopy(*(TDes8*)a2,vPckg);
973 case EDisplayHalSecure:
974 kumemput32(a1, &iSecureDisplay, sizeof(TBool));
977 case EDisplayHalSetSecure:
979 if(!Kern::CurrentThreadHasCapability(ECapabilityMultimediaDD,__PLATSEC_DIAGNOSTIC_STRING("Checked by Hal function EDisplayHalSetSecure")))
980 return KErrPermissionDenied;
981 SwitchDisplay((TBool)a1);
990 __e32_memory_barrier(); // Ensure any changes are propagated to other clients
996 DECLARE_STANDARD_EXTENSION()
998 __KTRACE_OPT(KPOWER,Kern::Printf("Starting LCD power manager"));
1000 // create LCD power handler
1001 TInt r=KErrNoMemory;
1002 DLcdPowerHandler* pH=new DLcdPowerHandler;
1006 __KTRACE_OPT(KPOWER,Kern::Printf("Returns %d",r));