good idea

Caveat: All this refers to CVS versions of HAL and pm-utils, and thus won't work for older versions.

When you suspend or hibernate, sometimes you have to do crazy things to the video adapter.
I'm lucky with my Toshiba, I don't need any extra options, but some people will need kernel options, vbe options or dpms commands.
In the past this used to be done via per-distro or manual hacks learned from obscure websites.
For instance, FC5 hard-codes different card vendors to do different things, and this over-simplified approach actually breaks resume for my Intel card.
What is needed is fine grained white-listing of certain laptop models and video-cards based on the vendor id and product id.
Now this is great in theory, but certain laptop vendors (as opposed to video card vendors) do funny things to the hardware on the cards.
Luckily we can use the sub vendor id and the sub product id, which should be set as the laptop vendor.
This is found to be just as accurate as the dmi data, as it's practically working at that level anyway.

Recently I added the video_adapter_pm namespace into Hal which lets us specify using FDI files what a computer actually needs to do the suspend and resume.
This means that once the laptop with the oddity has been added, then other laptops of the same type will start to “just work” without the user needing to poke around in config files.
This works in a similar way to how the USB quirk system works in the kernel — someone identifies the problem, and fixes it for everyone.

Now, the observant among you may notice the methods on org.freedesktop.Hal.Device.VideoAdapterPM: SuspendVideo and ResumeVideo.
When these are called, the the hal-system-video-* scripts are called, that actually do the hacks mentioned in the spec (like using the dpms and vbetool commands).
This means that any application that wishes to resume any connected video adapter just has to find a UDI with the capability video_adapter_pm and then execute SuspendVideo and ResumeVideo on it without worrying about any details.

It just so happens, that pm-utils does exactly this!
This means that HAL is used as an abstract layer, with pm-utils driving the video suspend and resume.
It's all a happy coincidence that pm-utils itself is called by HAL during the global Suspend() and Hibernate() methods, but there's no reason these methods can't be used by other software such as powersaved.

That was the good. Now for the bad.

In order to do the right thing for the right machine we have to know the videocard vid, pid, subvid and subpid, which I'm guessing most of you don't know off by heart.
HAL to the rescue. Using this prototype script we can search for video card devices and then generate the correct XML entry for you automatically.
You answer a few easy questions:

Section 1/3 : Kernel parameters
Use S3_BIOS (y|n): n
Use S3_MODE (y|n): n

Section 2/3 : Suspend actions
Use DPMS to force the screen off (y|n): y
Use vbestate restore (y|n): n
Use vbemode restore (y|n): n

Section 2/3 : Resume actions
Set VGA text mode to mode 3 (y|n): n
Use DPMS to force the screen on (y|n): y
Use VGA vbe post (y|n): n

Okay, maybe not so easy, but if you already know you need S3_MODE and S3_BIOS manually entered on the grub command line for resume to work then you just need to say yes to these and no to the others.

So the script does its thing, and you get a nice lump of XML in your home directory:

[hughsie@hughsie-laptop docs]$ cat /home/hughsie/autogenerated_video.fdi
<?xml version=”1.0″ encoding=”ISO-8859-1″?> <!– -*- SGML -*- –>
<deviceinfo version=”0.2″>
    system.manufacturer: TOSHIBA
    system.product:      Satellite Pro A10
    bios.release_date:   09/02/2003
    bios.version:        Version 1.30
    <match key=”pci.vendor_id” int=”0x8086″> <!– Intel Corporation –>
      <match key=”pci.product_id” int=”0x3582″> <!– 82852/855GM Integrated Graphics Device –>
        <match key=”pci.subsys_vendor_id” int=”0x1179″> <!– Toshiba America Info Systems –>
          <match key=”pci.subsys_product_id” int=”0x2″> <!– Unknown (0x0002) –>
            <merge key=”video_adapter_pm.dpms_suspend” type=”bool”>true</merge>
            <merge key=”video_adapter_pm.dpms_on” type=”bool”>true</merge>
            <append key=”info.capabilities” type=”strlist”>video_adapter_pm</append>
            <append key=”info.interfaces” type=”strlist”>org.freedesktop.Hal.Device.VideoAdapterPM</append>
            <append key=”org.freedesktop.Hal.Device.VideoAdapterPM.method_names” type=”strlist”>SuspendVideo</append>
            <append key=”org.freedesktop.Hal.Device.VideoAdapterPM.method_signatures” type=”strlist”></append>
            <append key=”org.freedesktop.Hal.Device.VideoAdapterPM.method_execpaths” type=”strlist”>hal-system-video-suspend</append>
            <append key=”org.freedesktop.Hal.Device.VideoAdapterPM.method_names” type=”strlist”>ResumeVideo</append>
            <append key=”org.freedesktop.Hal.Device.VideoAdapterPM.method_signatures” type=”strlist”></append>
            <append key=”org.freedesktop.Hal.Device.VideoAdapterPM.method_execpaths” type=”strlist”>hal-system-video-resume</append>

Now, copy this file into /usr/share/hal/fdi/policy/10osvendor/ or just take the <device>…</device> information and add to 10-video-power-policy.fdi
Restart HAL, and it all should “just work”. :-)
The idea is that as people get hardware working, we can get these lumps of XML into HAL cvs so that other people don't have the same problems.
The actual utopian possibility is that hardware manufacturers actually send this info from internal testing, but I'm not holding my breath on this one.

Now, please don't send me hundreds of emails saying “this works : here's my lump of XML” as the script is not finished yet.
I'll announce it on this blog as soon as it's been tested really well, but I would appreciate if you could leave a comment if it works for you, or if you think the script needs any bugfixing or other improvements.

Published by


Richard has over 10 years of experience developing open source software. He is the maintainer of GNOME Software, PackageKit, GNOME Packagekit, GNOME Power Manager, GNOME Color Manager, colord, and UPower and also contributes to many other projects and opensource standards. Richard has three main areas of interest on the free desktop, color management, package management, and power management. Richard graduated a few years ago from the University of Surrey with a Masters in Electronics Engineering. He now works for Red Hat in the desktop group, and also manages a company selling open source calibration equipment. Richard's outside interests include taking photos and eating good food.

One thought on “good idea”

  1. s2ram from basically follows the same goal. It also has a whitelist already which you might use. s2ram also has the advantage that if you don't know which parameters/workarounds are necessary, you can try them with s2ram: So you'd start with ./s2ram (if your laptop is already listed you are lucky) ./s2ram -f (force, if it works, great) ./s2ram –acpi_sleep=1 ./s2ram –acpi_sleep=2 ./s2ram –acpi_sleep=3 1=s3_bios, 2=s3_mode, 3=both ./s2ram –vbe_save ./s2ram –vbe_post So, the first invocation that works for your laptop should be submitted. There is also a great documentation. Why not join forces with

Comments are closed.