exregistercallback issue for lid open/close notification

hi all,

there is a conflict in the definition mentioned for ExRegisterCallback() and DxgkDdiNotifyAcpiEvent () for PO_CB_LID_SWITCH_STATE case.

in ExRegisterCallback()
-> Argument2 for PO_CB_LID_SWITCH_STATE gives TRUE if the current state of the lid switch is CLOSED and FALSE otherwise.

and in DxgkDdiNotifyAcpiEvent()
-> Argument for PO_CB_LID_SWITCH_STATE gives 1 for lid open and 0 for lid closed.

i have a small doubt …how can the same power object give different notification argument values ?

I am using ExRegisterCallback() for Lid Open/Close and when i close the lid i get FALSE and when i open the lid i get TRUE in Argument2 ie., essentially i am getting opposite notifications …

am I doing something wrong …or have i missed something ? or is it that the ExRegisterCallback gives what was the status just before the close/open event happening ?

hi guys …
i am stuck with this as of now …
some inputs from you guys will be of great help…

have attached my code for your reference …
its a simple check for TRUE or FALSE of Argument2 values.

lidstatecallback(
PVOID CallBackContext,
PVOID Argument1,
PVOID Argument2
)
{
int value = 0;

UsbSamp_DbgPrint(1, (“<<<<<<<<<<<<<<<<>>>>>>>>>>>>>\n”));
UsbSamp_DbgPrint(1, (“Argument1: 0x%x, Argument2: 0x%x\n”, Argument1, Argument2));

if(PO_CB_LID_SWITCH_STATE == (int)Argument1)
{
UsbSamp_DbgPrint(1, (“lidstatecallback: PO_CB_LID_SWITCH_STATE \n”));

//===========Getting Opposite values from callback================
if(TRUE ==(int)Argument2)
{
UsbSamp_DbgPrint(1, (“lidstatecallback: LID SWITCH CLOSED \n”));
}
else
{
UsbSamp_DbgPrint(1, (“lidstatecallback: LID SWITCH OPEN \n”));
}
//======================================================

}

}

Sounds like the docs for ExRegisterCallback PO_CB_LID_SWITCH_STATE have it backwards? I mean, try it and it does what it does, right?

I, personally, never believe the WDK documentation more than I believe my own eyes. Try three laptops with different BIOSes. If they all behave similarly, file a bug on the doc page.

Peter
OSR

xxxxx@gmail.com wrote:

hi guys …
i am stuck with this as of now …
some inputs from you guys will be of great help…

have attached my code for your reference …
its a simple check for TRUE or FALSE of Argument2 values.

lidstatecallback(
PVOID CallBackContext,
PVOID Argument1,
PVOID Argument2
)
{
int value = 0;

UsbSamp_DbgPrint(1, (“<<<<<<<<<<<<<<<<>>>>>>>>>>>>>\n”));
> UsbSamp_DbgPrint(1, (“Argument1: 0x%x, Argument2: 0x%x\n”, Argument1, Argument2));
>
> if(PO_CB_LID_SWITCH_STATE == (int)Argument1)
> {
> UsbSamp_DbgPrint(1, (“lidstatecallback: PO_CB_LID_SWITCH_STATE \n”));
>
> //===========Getting Opposite values from callback================
> if(TRUE ==(int)Argument2)
> {
> UsbSamp_DbgPrint(1, (“lidstatecallback: LID SWITCH CLOSED \n”));
> }
> else
> {
> UsbSamp_DbgPrint(1, (“lidstatecallback: LID SWITCH OPEN \n”));

As I read the documentation, you have this backwards.

http://msdn.microsoft.com/en-us/library/windows/hardware/ff559695(v=vs.85).aspx

PO_CB_LID_SWITCH_STATE

0 - Indicates that the lid is being closed.

1 - Indicates that the lid is being opened.


Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.

Hi Tim and Peter … thanks for your replies …

@Peter Viscarola:
ya … looks like the WDK has it backwards… i tried with two different laptops … HP and Sony … both give the opposite status … i have raised a report to MSDN also … waiting for their response …

@Tim Roberts:
but i am using ExRegisterCallback(http://msdn.microsoft.com/en-us/library/windows/hardware/ff545534(v=vs.85).aspx) function for which Argument2 value gives TRUE(1) when lid is closed and FALSE(0) when lid is open … hence i am getting opposite status of lid open/close.
i mentioned DxgkDdiNotifyAcpiEvent() function as a reference for PO_CB_LID_SWITCH_STATE status values returned. Also another reference i found was in GUID_LIDSWITCH_STATE_CHANGE definition in wdm.h which mentions in the comments that
// 0 - closed
// 1 - opened
so … now i am in a little confusion about how to proceed …

thanks,
shreenivasa

The docs CAN be wrong. It’s not all that unusual. The docs are NOT definitive.

Trust your experience and just go with that.

Peter
OSR

xxxxx@gmail.com wrote:

@Tim Roberts:
but i am using ExRegisterCallback(http://msdn.microsoft.com/en-us/library/windows/hardware/ff545534(v=vs.85).aspx) function for which Argument2 value gives TRUE(1) when lid is closed and FALSE(0) when lid is open … hence i am getting opposite status of lid open/close.
i mentioned DxgkDdiNotifyAcpiEvent() function as a reference for PO_CB_LID_SWITCH_STATE status values returned. Also another reference i found was in GUID_LIDSWITCH_STATE_CHANGE definition in wdm.h which mentions in the comments that
// 0 - closed
// 1 - opened
so … now i am in a little confusion about how to proceed …

Personally, and this is really my personal opinion, those things should
not be documented on the ExRegisterCallback page to begin with.
ExRegisterCallback is a general-purpose kernel API. The fact that there
happen to be drivers in the system that offer callbacks is completely
unrelated to the API itself. They have gathered here options from a
wide variety of other kernel sources, and since their primary purpose on
this page is to document the API, it is perhaps not surprising that they
have mistakes in the details from other drivers.

I would consider the DxgkDdiNotifyAcpiEvent documentation more reliable,
since that API is closer to the creator of the event.


Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.

Hi Tim and Peter,
thanks for your inputs …

now i am using PoRegisterPowerSettingCallback() with GUID of GUID_LIDSWITCH_STATES_CHANGE. I get the callback when lid is closed/open.
so i am not using the ExRegisterCallback() …

thanks again for your inputs … it was helpful.

shreeni