Permalink
Browse files

Added ironhide-acpidetect

  • Loading branch information...
1 parent 2253d2b commit d68da10b0cd13a30c5d4b7709e1efe5e89f6a8a9 @MrMEEE committed Sep 1, 2011
Showing with 22 additions and 0 deletions.
  1. +22 −0 files/ironhide-acpidetect
View
@@ -0,0 +1,22 @@
+csplit -s -k -f Scope $1 '/Scope/' {99} 1>/dev/null 2>/dev/null
+
+for i in `ls Scope*`; do
+ if [[ `cat $i |grep PS0 |wc -l` > 0 ]] || [[ `cat $i |grep PS3 |wc -l` > 0 ]]; then
+ csplit -s -k -f Method $i '/Method/' {99} 1>/dev/null 2>/dev/null
+ for k in `ls Method*`; do
+ if [[ `cat $k |grep PS0 |wc -l` > 0 ]] && [[ `cat $k |grep ON |wc -l` > 0 ]]; then
+ echo "Enable Command: `head -1 $i | cut -f2 -d\( | cut -f1 -d\)`.ON"
+ elif [[ `cat $k |grep PS0 |wc -l` > 0 ]] && [[ `cat $k |grep OFF |wc -l` > 0 ]]; then
+ echo "Disable Command: `head -1 $i | cut -f2 -d\( | cut -f1 -d\)`.OFF"
+ elif [[ `cat $k |grep PS3 |wc -l` > 0 ]] && [[ `cat $k |grep ON |wc -l` > 0 ]]; then
+ echo "Enable Command: `head -1 $i | cut -f2 -d\( | cut -f1 -d\)`.ON"
+ elif [[ `cat $k |grep PS3 |wc -l` > 0 ]] && [[ `cat $k |grep OFF |wc -l` > 0 ]]; then
+ echo "Disable Command: `head -1 $i | cut -f2 -d\( | cut -f1 -d\)`.OFF"
+ fi
+ echo
+ done
+ rm Method*
+ fi
+done
+
+rm Scope*

8 comments on commit d68da10

Contributor

Lekensteyn replied Sep 1, 2011

Nice attempt, but calling ON and OFF is wrong. It disables a power resource which may be in use by other devices. You should look at the PS# methods which is used for device power states.

It would be cool to know exactly what the PS# methods do in each case. For what I can tell, in many cases they are only preparing the system for suspend/hibernate/shutdown/reboot, so that the state of the discrete card is read back again correctly when the OS is loaded again in the system.
@Lekensteyn, what do you think?

Contributor

Lekensteyn replied Sep 2, 2011

PS0 sets the Fully On state, PS3 the Off state. Higher values save more power but loose device context too (in the case of a graphics card. this may crash the X server if it uses the nvidia card).
I'm not sure what you mean by "the state of the discrete card is read back again correctly when the OS is loaded", AFAIK all devices are in the D3 state when the system is off. On power on, the devices are activated again (D# with 0 <= # < 3)

Owner

MrMEEE replied Sep 2, 2011

OK...

Can we agree on what would be the right command based on???:

Scope (_SB.PCI0.PEG0.PEGP)
[... a bunch of lines below...]
Method (_PS0, 0, NotSerialized)
{
Store (Zero, _PSC)
If (LNotEqual (DGPS, Zero))
{
_ON ()
Store (Zero, DGPS)
}

        Store (SID, SIDN)
    }

    Method (_PS1, 0, NotSerialized)
    {
        Store (One, _PSC)
    }

    Method (_PS3, 0, NotSerialized)
    {
        If (LEqual (OPCE, 0x03))
        {
            If (LEqual (DGPS, Zero))
            {
                _OFF ()
                Store (One, DGPS)
            }

            Store (0x02, OPCE)
        }

        Store (0x03, _PSC)
    }

    Method (_STA, 0, NotSerialized)
    {
        Return (0x0F)
    }
Owner

MrMEEE replied Sep 2, 2011

So, is this: "We can't do anything in general"??

OFF will ever be a function called by PS3, ON will ever be a function called by PS0.

PS1 appears sometimes but is empty, PS2 never appearead AFAIK.

About what are the right calls, my investigation leads me to separate for levels of calls (higher is better):

  • 1: ON and OFF calls
  • 2: PS0 and PS3 calls, knowing that calling PS3 requires to call DSM on the same device with some arguments
  • 3: NVOP, NV3D, WMMX (depending on brand): for each table I've seen, they have ever been one of these 3 calls, that, when called with the good arguments, was calling at least DSM with the good arguments (sometimes PS0 if you call them with different arguments, and even PS3 after calling DSM)
  • 4: Same as 3, but not with guessing args like we actually do for DSM, but by passing var from the tables. There are plenty of vars hardcoded as buffers, integers, ... in those tables, my opinion is that they have an use, so agrs should be those vars.

So, the only thing we may ever do in general is to make an automatic reverser that will look for NVOP, NV3D or WMMX, DSM functions (that often appears twice), PS0 and PS3 one, reverse them to find what arguments they need or what var they need at what value, found corresponding args for higher level functions, and find them in existing one.

But that requires the highest possible level of knowledge in ACPI, maybe we should look for an ASL expert...

Please sign in to comment.