Power Management RRS feed

  • Question

  • Dear All,

    I'am working on imx53 freescale processor which uses wince7. As of now i'am working on power management module.

    Just for testing purpose I configured the backlight OFF  through registry settings in platform.reg .It's working fine.

    I used the following settings

        "ACUserIdle"=dword:a        ; in seconds //change made by sriram//0
        "ACSystemIdle"=dword:5      ; in seconds
        "ACSuspend"=dword:0 ; in seconds

    But I need to do the same from application, which is not working out. I've used the function below from application

    hResult=SetPowerRequirement( _T("bkl1:"),D4, POWER_NAME , NULL, 0 );  

    I'am very new to wince, so someone please guide me out so as to make it work from application.


    Thursday, May 8, 2014 6:49 AM


All replies

  • try with SetPowerRequirement( _T("bkl1:"),D4, POWER_FORCE , NULL, 0 );  or

    SetDevicePower(_T("bkl1:"), POWER_NAME, D4);

    Please mark as answer, if it is correct.
    Please vote,if it is helpful post.

    • Marked as answer by Srirammadhu Thursday, May 8, 2014 9:04 AM
    • Unmarked as answer by Srirammadhu Thursday, May 8, 2014 12:53 PM
    Thursday, May 8, 2014 7:59 AM
  • I tried both, it has no effect. Is there any other settings that i should take care of??
    Thursday, May 8, 2014 9:04 AM
  • SetDevicePower(_T("bkl1:"), POWER_NAME, D4); should work if your driver is Power-managed. What is the API returning ?

    Setting backlight off through registry settings implies your backlight driver is of power-manageable class. 

    Have you handled the following IOCTLs


    Sharing the code and registry settings of the driver would be better.
    Please mark as answer if it works.
    Please vote if the answer is helpful.


    Thursday, May 8, 2014 10:41 AM
  • Actually the control is not entering the ioctl function.


        DWORD pddContext,
        DWORD dwIoControlCode,
        LPBYTE lpInBuf,
        DWORD nInBufSize,
        LPBYTE lpOutBuf,
        DWORD nOutBufSize, 
        LPDWORD lpBytesReturned

    I am getting error 2(file not found)while using SetDevicePower(_T("bkl1:"), POWER_NAME, D4); from application.

    And no error while using SetPowerRequirement( _T("bkl1:"),D4, POWER_FORCE , NULL, 0 ); - but backlight not turning OFF.

    Through registry settings it is working, the settings are listedabove.

    Thursday, May 8, 2014 11:54 AM
  • "file not found" error implies The device is not found. Which implies BKL1 is not a registered device. 

    SetPowerRequirement does not return error code(It returns zero to imply failure). You need to use GetLastError. Point to be checked.

    This seems like a device driver implementation problem.Please check your Driver registry settings for proper Prefix and Index. 

    To be sure, Implement a custom IOCTL in your device driver, and call the IOCTL using DeviceIoControl API with Handle created using "BKL1" prefix. 

    Please mark as answer if it works.
    Please vote if the answer is helpful.


    • Edited by RYaceT Thursday, May 8, 2014 5:04 PM
    Thursday, May 8, 2014 1:52 PM
  • Are you sure your device has a  driver for backlight? if you don't have the backlight driver, backlight power management can be handled in display driver. i saw these kind of implementation in some BSP where they don't have the backlight driver and the backlight can be power on/off by display driver itself.check your BSP for backlight driver? if not, you have to pass the display driver class guid to power of the backlight and display.

    The above registry settings is working because, power states are not specific for a particular device driver, and it is common for all the drivers where their device state is mapped for a particular power states. suppose if the backlight power is handled in display driver, display driver device states say for example D4 is mapped to the power state useridle then changing the Useridle value in the registry will effect to the corresponding device states mapped to the power state  user idle.

    if i were you, my approach will be learning the power management basics then get in to the issue. it will save your time.

    Please mark as answer, if it is correct.
    Please vote,if it is helpful post.

    Thursday, May 8, 2014 2:21 PM
  • To add to what Vinoth is saying, I've seen systems where the backlight driver was present but not using the power managed GUID, but used the Display driver to perform DeviceIoControl requests into the Backlight driver when the Display driver was powered up or down.

    Not having the Power Managed GUID setup for your backlight driver will prevent the OS from using the Power Managed IOCTLs with the device.

    Thursday, May 8, 2014 5:32 PM
  • Thanks Vinoth.

    But I do have the backlight driver . May be I try with the display driver.

    Friday, May 9, 2014 4:54 AM
  • And are you sure that your Backlight driver is "BLK1" ? Or Loading with Some other Subscript ...?

    --- Misbah

    Senior Design Engineer T.E.S Electroni Solutions (Bangalore-India)

    Friday, May 9, 2014 7:05 AM
  • Its is the same name BKL1 . 
    Friday, May 9, 2014 8:56 AM
  • Hi Vinoth,

    As you had mentioned in one of your blog on customizing power management, on changing the flag return value to true for setsystempowerstate,I tried the same but its again not working out. I'am a newbie to WINCE, so can you please tell me the changes that has to be done in both driver registry settings as well in apllication??It would be of great help to me.

    As I gone through all blogs and documents on power management ,power management seems to be a quite direct process.But its seriously not in my case



    Tuesday, May 13, 2014 5:02 AM
  • how did you change the PM drivers, have you cloned to your BSP or changed in public?

    what are the parameters you have passed for setsystempowerstate. Try this


    Please mark as answer, if it is correct.
    Please vote,if it is helpful post.

    Tuesday, May 13, 2014 6:45 AM
  • This was my parameters passed

        if(ERROR_SUCCESS != dwErr)
            RETAILMSG(1, (TEXT("user idle  failed = %d"),dwErr));       
            //tprResult = TPR_FAIL;
            //goto exit;
    RETAILMSG(1,(TEXT("user idle pass")));

    I tried cloning it to my BSP, but i got linking error.I'am not aware of cloning. So later i changed it in my public itself and tried the above code snippet, which dint work. As changing in public is not advisable i reverted back the changes now.

    I will try with your function now and get back

    Tuesday, May 13, 2014 7:11 AM
  • Should i also set acuseridle,acsystemidle and asuspend timeouts in registry settings???

    Because when i set these timers , system suspend is working in driver level itself without running my application. But i want that to be done from application.


    Tuesday, May 13, 2014 7:22 AM
  • which power state you have allowed the  apps to change (UserIdle or SystemIdle)?

    in my blog, i have shown it for UserIdle. but the API i have shown it for SystemIdle. If you changed the UserIdle code in the driver, call "UserIdle" as an argument in the API as shown above.

    it is not advisable to change the public code,you have to sysgen capture to achieve this as shown in the below sample blogs

    since you are not familiar with cloning, you can clone it and do it locally later. first you attack a single issue then if it is solved, you can go for cloning the PM.

    For testing purpose you can change the code in the public now and build it.

    * GO to solution explorer,

    * navigate to the PM folder.

    * right click it and do Build and Sysgen 

    * PM will be built and placed in release dir.

    * perform "make run time image". 

    This should include the updated PM.dll to your binary

    Please mark as answer, if it is correct.
    Please vote,if it is helpful post.

    • Marked as answer by Srirammadhu Tuesday, May 13, 2014 8:32 AM
    Tuesday, May 13, 2014 7:55 AM
  • if you need, you can do that from app.

    see this blog to do this,

    Please mark as answer, if it is correct.
    Please vote,if it is helpful post.

    Tuesday, May 13, 2014 8:02 AM
  • Thanks a lot vinoth for your quick reply.

    I 'll get back to you with results

    Tuesday, May 13, 2014 8:17 AM
  • I tried with your function SetSystemPowerState(L"SystemIdle",NULL,POWER_FORCE); its giving error -invalid arguments. Later i changed to the API i tried(as mentioned above) - useridle is passing but system idle and system suspend are failing and my system gets hanged. (I have changed corresponding apps flag in public).

    Later tried with cloning, its building with no errors. But PN is not loading in the sense i am not getting retail messages that i had put in PM files. 

    Is there any reason why Setsystempowerstate is not working for systemidle and suspend???? It works only for system reset.



    Wednesday, May 14, 2014 4:30 AM
  • Hi vinoth ,

    even after setting the app flags in pwstates to true ,  SetSystemPowerState to system idle and suspend is not working. It is getting hanged. I dont understand why it is getting hanged. pls help me out.



    Monday, May 19, 2014 9:58 AM
  • proceed with debug build and post the debug messages here while calling the setsystempowerstate from your application

    Please mark as answer, if it is correct.
    Please vote,if it is helpful post.

    Monday, May 19, 2014 10:11 AM
  • Finally done with cloning. Followed the procedures that you shared for sysgen capture.

    Will post the debug messages .


    Monday, May 19, 2014 3:10 PM