Operating System Can windows/MP automatically shut down, if TV is off? (1 Viewer)

kiwijunglist

Super Moderator
  • Team MediaPortal
  • June 10, 2008
    6,746
    1,751
    New Zealand
    Home Country
    New Zealand New Zealand
    it needs to record to a file, or have a history with time stamps, since I will test with single display.
     

    kiwijunglist

    Super Moderator
  • Team MediaPortal
  • June 10, 2008
    6,746
    1,751
    New Zealand
    Home Country
    New Zealand New Zealand
    The WDDM driver model needs to handle ACPI messages from the hardware. Quick test on NVidia and ATI showed that both pass them properly along the chain to the OS, which then passes them down to individual windows. At least on my two boxes.

    You don't find them under Windows Messages. You need to read the WDDM SDK include files. It's all nice in there :sneaky: Short view on dispmprt.h will open your eyes :p

    I can see hotplug, display changes and display power changes fine here.

    Of course we cannot send commands to HDMI devices without a CEC Module or hooking ourselves into the GPU driver. But we can see what the displays are doing.


    if you build just a little standalone exe test script that will record pwr on/off I can test it for you.

    Can do...


    @Scythe42 - BUMP :)

    PS. I've tried working on this myself but I can't figure out how to access
    http://msdn.microsoft.com/en-us/library/windows/desktop/hh448380(v=vs.85).aspx
    using autohotkey.

    Here is sample autohotkey code for accessing a different class, maybe you can give me pointer on how to adapt?
    Code:
    ; Initialize Monitor handle
    hMon := DllCall("MonitorFromPoint"
    , "int64", 0 ; point on monitor
    , "uint", 1) ; flag to return primary monitor on failure
     
    ; Find number of Physical Monitors
    DllCall("dxva2\GetNumberOfPhysicalMonitorsFromHMONITOR"
    , "int", hMon
    , "uint*", nMon)
     
    ; Get Physical Monitor from handle
    VarSetCapacity(Physical_Monitor, (A_PtrSize ? A_PtrSize : 4) + 128, 0)
     
    DllCall("dxva2\GetPhysicalMonitorsFromHMONITOR"
    , "int", hMon   ; monitor handle
    , "uint", nMon   ; monitor array size
    , "int", &Physical_Monitor)   ; point to array with monitor
     
    hPhysMon := NumGet(Physical_Monitor)
     
     
    DllCall("dxva2\GetMonitorBrightness"
    , "int", hPhysMon
    , "uint*", minBright
    , "uint*", curBright
    , "uint*", maxBright)
     
     
    DllCall("dxva2\GetMonitorCapabilities"
    , "int", hPhysMon
    , "uint*", pdwMonitorCap
    , "uint*", pdwMonitorSup)
    		 
    MsgBox % "Monitor description: " . StrGet(&Physical_Monitor+(A_PtrSize ? A_PtrSize : 4), "utf-16")
    . "`nMinimum brightness: " . minBright
    . "`nMaximum brightness: " . maxBright
    . "`nCurrent brightness: " . curBright
    		. "`nPdwMonitorCapabilities: " . pdwMonitorCap
    		. "`nPdwMonitorSupport: " . pdwMonitorSup
     

    tourettes

    Retired Team Member
  • Premium Supporter
  • January 7, 2005
    17,301
    4,800
    Of course we cannot send commands to HDMI devices without a CEC Module or hooking ourselves into the GPU driver. But we can see what the displays are doing.

    I was under an impression that today's GPUs aren't having any CEC functionality so it wound't even help if GPU drivers are poked around.
     

    kiwijunglist

    Super Moderator
  • Team MediaPortal
  • June 10, 2008
    6,746
    1,751
    New Zealand
    Home Country
    New Zealand New Zealand
    PS. My goal is to make 2 scripts that simply do the following

    1. If (TV is on) { do nothing } else { run external commandline to blast the TV }
    Turn off the TV whenever HTPC goes to sleep.

    2. If (TV is off) { do nothing } else { run external commandline to blast the TV }
    Turn on TV whenever HTPC manually wakes up or if I press green button on remote.
     
    Last edited:

    Scythe42

    Retired Team Member
  • Premium Supporter
  • June 20, 2009
    2,065
    2,703
    51
    Berlin
    Home Country
    Germany Germany
    Of course we cannot send commands to HDMI devices without a CEC Module or hooking ourselves into the GPU driver. But we can see what the displays are doing.

    I was under an impression that today's GPUs aren't having any CEC functionality so it wound't even help if GPU drivers are poked around.

    To my knowledge Pin 13/17 are not physically disconnected on any GPU as this would break HDMI hotplugging as well which obviously works. You turn off the display and Windows detects this. This means CEC is possible as well in theory unless the firmware artificially blocks stuff. Need to poke around here more if I get bored.

    But for detecting display turning on/off: The additional and removal of an HDMI audio render together with a resolution change should be accurate enough for most systems to detect this by normal messages from Windows. Some GPUs even send out proper ACPI events to Windows about this, but this seems to be rare (only found it in drivers for nvidia chipsets).

    In general providing an action on turning display on/off when using HDMI for MP should be possible for the majority of setups.
     

    tourettes

    Retired Team Member
  • Premium Supporter
  • January 7, 2005
    17,301
    4,800
    Of course we cannot send commands to HDMI devices without a CEC Module or hooking ourselves into the GPU driver. But we can see what the displays are doing.

    I was under an impression that today's GPUs aren't having any CEC functionality so it wound't even help if GPU drivers are poked around.

    To my knowledge Pin 13/17 are not physically disconnected on any GPU as this would break HDMI hotplugging as well which obviously works. You turn off the display and Windows detects this. This means CEC is possible as well in theory unless the firmware artificially blocks stuff. Need to poke around here more if I get bored.

    Would be nice to get CEC out of current GPUs if possible.
     

    kiwijunglist

    Super Moderator
  • Team MediaPortal
  • June 10, 2008
    6,746
    1,751
    New Zealand
    Home Country
    New Zealand New Zealand
    But for detecting display turning on/off: The additional and removal of an HDMI audio render together with a resolution change should be accurate enough for most systems to detect this by normal messages from Windows.

    http://msdn.microsoft.com/en-us/library/windows/desktop/aa394122(v=vs.85).aspx
    I used Win32_DesktopMonitor Class and there are no changes within this class when i power off my Desktop's Dell LCD Monitor (DVI) or my Lounge PC's Samsung LCD TV (HDMI, Audio via SPDIF).
     

    Scythe42

    Retired Team Member
  • Premium Supporter
  • June 20, 2009
    2,065
    2,703
    51
    Berlin
    Home Country
    Germany Germany
    WMI does not work here. You need to put several messages send by Windows into context. They are already tracked by WndProc in MediaPorta.cs. It is just a matter of tracking certain states and put them in a context to achieve the wished goal in a reliable way.
     

    Users who are viewing this thread

    Top Bottom