Index | Thread | Search

From:
Mark Kettenis <mark.kettenis@xs4all.nl>
Subject:
Re: qcpas: generate apm events upon ac state changes
To:
Landry Breuil <landry@openbsd.org>
Cc:
tech@openbsd.org, patrick@openbsd.org
Date:
Fri, 08 Nov 2024 19:28:16 +0100

Download raw body.

Thread
  • Mark Kettenis:

    qcpas: generate apm events upon ac state changes

  • > Date: Fri, 8 Nov 2024 19:06:44 +0100
    > From: Landry Breuil <landry@openbsd.org>
    > 
    > hi,
    > 
    > small diff that allows qcpas to send apm events when the ac is plugged
    > in/unplugged, thanks jca@ for the pointer.
    > 
    > in userland, that's used by sysutils/upower that gives me the fancy battery/ac
    > status via xfce4-power-manager on the x13s, before that it never got events on
    > ac state changes, only the battery levels.
    > 
    > i don't know if events should be sent upon battery level changes, i know upower
    > doesn't use them as it reads the 'remaining capacity' value from
    > hw.sensors.qcpas0, cf https://gitlab.freedesktop.org/upower/upower/-/blob/master/src/openbsd/up-backend.c?ref_type=heads#L393.
    > 
    > will also test on the omnibook x14 in a few.
    > 
    > Index: qcpas.c
    > ===================================================================
    > RCS file: /cvs/src/sys/dev/fdt/qcpas.c,v
    > diff -u -p -r1.7 qcpas.c
    > --- qcpas.c     1 Sep 2024 03:14:48 -0000       1.7
    > +++ qcpas.c     8 Nov 2024 17:51:25 -0000
    > @@ -1532,9 +1532,13 @@ qcpas_pmic_rtr_bat_status(struct qcpas_s
    >                 info->minutes_left = (60 * delta) / abs(bat->rate);
    >  
    >         if (bat->power_state & BATTMGR_PWR_STATE_AC_ON) {
    > +               if (info->ac_state != APM_AC_ON)
    > +                       apm_record_event(APM_POWER_CHANGE);
    >                 info->ac_state = APM_AC_ON;
    >                 hw_power = 1;
    >         } else {
    > +               if (info->ac_state != APM_AC_OFF)
    > +                       apm_record_event(APM_POWER_CHANGE);
    >                 info->ac_state = APM_AC_OFF;
    >                 hw_power = 0;
    >         }
    > 
    > i'm also attaching a small test program that prints apm events received by
    > kqueue on stderr.
    > 
    > comments ?
    
    Looks good to me.  We can worry about battery status notifications later.
    
    ok kettenis@
    
    
    
  • Mark Kettenis:

    qcpas: generate apm events upon ac state changes