You are not logged in.

#1 2012-08-21 17:41:14

olaf.the.lost.viking
Member
Registered: 2011-07-19
Posts: 21

[SOLVED] systemd and pm-utils quirks (gma500_gfx)

Hi,

I have a netbook with the infamous poulsbo/gma500 chipset. To suspend it on the console (I am not yet at X ;-) ) I need to add the --quirk-vbemode-restore option to pm-suspend as described in the wiki [1]. How can I get the same effect when migrating to systemd (and therefore switching to systemctl and dropping pm-utils)?

Thanks

[1] https://wiki.archlinux.org/index.php/Poulsbo

Last edited by olaf.the.lost.viking (2012-08-22 23:13:22)


I switched to OlafLostViking to match the IRC alias.

Offline

#2 2012-08-21 18:51:07

lahwaacz
Wiki Admin
From: Czech Republic
Registered: 2012-05-29
Posts: 748

Re: [SOLVED] systemd and pm-utils quirks (gma500_gfx)

The code is in /usr/lib/pm-utils/sleep.d/98video-quirk-db-handler and /usr/lib/pm-utils/sleep.d/99video. The substantial part is

# save/restore the vbe mode
vbe_savemode() { vbe vbemode get |savestate vbemode; }
vbe_restoremode()
{
    # this is a little mode complicated to handle special-casing mode 3.
    local vbemode=$(restorestate vbemode)
    if [ "$vbemode" = "3" ]; then
        vbe vgamode set $vbemode
    else
        vbe vbemode set $vbemode
    fi
}

Note that vbe function only forwards its arguments to vbetool. You could place something like this into /usr/lib/systemd/system-sleep/99video

#!/bin/sh

TMPFILE=/tmp/gma500-state

vbe_savemode() {
    vbetool vbemode get > $TMPFILE
}

vbe_restoremode() {
    # this is a little mode complicated to handle special-casing mode 3.
    local vbemode=$(cat $TMPFILE)
    if [ "$vbemode" = "3" ]; then
        vbetool vgamode set $vbemode
    else
        vbetool vbemode set $vbemode
    fi
}

if [[ $1 == "pre" ]]; then
    vbe_savemode
elif [[ $1 == "post" ]]; then
    [ -O /tmp/gma500-state ] && vbe_restoremode
fi

Offline

#3 2012-08-21 20:31:45

olaf.the.lost.viking
Member
Registered: 2011-07-19
Posts: 21

Re: [SOLVED] systemd and pm-utils quirks (gma500_gfx)

Great! Thank you for your help.

I'll report back if it doesn't work as intended ;-)


I switched to OlafLostViking to match the IRC alias.

Offline

#4 2012-08-22 23:14:36

olaf.the.lost.viking
Member
Registered: 2011-07-19
Posts: 21

Re: [SOLVED] systemd and pm-utils quirks (gma500_gfx)

OK, even better: it looks like suspending via pm-utils or /sys/power/state is not possible without some quirks. But systemd seems to suspend and hibernate this system even without any added scripts. Nice. Even though I'd prefer it to work all the time, I can use the netbook with systemd smile


I switched to OlafLostViking to match the IRC alias.

Offline

#5 2018-07-15 02:37:40

shtrom
Member
Registered: 2009-06-10
Posts: 7
Website

Re: [SOLVED] systemd and pm-utils quirks (gma500_gfx)

lahwaacz wrote:

You could place something like this into /usr/lib/systemd/system-sleep/99video

#!/bin/sh

TMPFILE=/tmp/gma500-state

vbe_savemode() {
    vbetool vbemode get > $TMPFILE
}

vbe_restoremode() {
    # this is a little mode complicated to handle special-casing mode 3.
    local vbemode=$(cat $TMPFILE)
    if [ "$vbemode" = "3" ]; then
        vbetool vgamode set $vbemode
    else
        vbetool vbemode set $vbemode
    fi
}

if [[ $1 == "pre" ]]; then
    vbe_savemode
elif [[ $1 == "post" ]]; then
    [ -O /tmp/gma500-state ] && vbe_restoremode
fi

Note that `==` is not valid in POSIX `sh`. You need to use a single `=`:

Sadly enough, while the script then ran, the solution didn't work.

I came up with a hack that, however, did. I updated the script as follows (including the POSIX `sh` fix):

if [ "$1" = "pre" ]; then
    vbe_savemode
    DISPLAY=:0 sudo -Eu $USER xrandr --output LVDS-1 --off
elif [ "$1" = "post" ]; then
    [ -O $TMPFILE ] && vbe_restoremode
    (sleep 1; DISPLAY=:0 sudo -Eu $USER xrandr --output LVDS-1 --auto) &
fi

It's dirty, but I have a single user on this machine (you'll need to set the `$USER` variable), and this Just Works^{tm}.

Last edited by shtrom (2018-07-15 03:18:28)

Offline

#6 2018-07-15 11:06:57

WorMzy
Forum Moderator
From: Scotland
Registered: 2010-06-16
Posts: 11,784
Website

Re: [SOLVED] systemd and pm-utils quirks (gma500_gfx)

Thanks for sharing. I'm going to go ahead and close this six year old topic now.


Sakura:-
Mobo: MSI MAG X570S TORPEDO MAX // Processor: AMD Ryzen 9 5950X @4.9GHz // GFX: AMD Radeon RX 5700 XT // RAM: 32GB (4x 8GB) Corsair DDR4 (@ 3000MHz) // Storage: 1x 3TB HDD, 6x 1TB SSD, 2x 120GB SSD, 1x 275GB M2 SSD

Making lemonade from lemons since 2015.

Offline

Board footer

Powered by FluxBB