int acpibat_notify(struct aml_node *node, int notify_type, void *arg) { struct acpibat_softc *sc = arg; int64_t sta; dnprintf(10, "acpibat_notify: %.2x %s\n", notify_type, sc->sc_devnode->name); /* Check if installed state of battery has changed */ if (aml_evalinteger(sc->sc_acpi, node, "_STA", 0, NULL, &sta) == 0) { if (sta & STA_BATTERY) sc->sc_bat_present = 1; else sc->sc_bat_present = 0; } switch (notify_type) { case 0x00: /* Poll sensors */ case 0x80: /* _BST changed */ acpibat_getbst(sc); break; case 0x81: /* _BIF changed */ acpibat_getbif(sc); break; default: break; } acpibat_refresh(sc); return (0); }
void acpibat_attach(struct device *parent, struct device *self, void *aux) { struct acpibat_softc *sc = (struct acpibat_softc *)self; struct acpi_attach_args *aa = aux; struct aml_value res; sc->sc_acpi = (struct acpi_softc *)parent; sc->sc_devnode = aa->aaa_node; if (aml_evalname(sc->sc_acpi, sc->sc_devnode, "_STA", 0, NULL, &res)) { dnprintf(10, "%s: no _STA\n", DEVNAME(sc)); return; } if ((res.v_integer & STA_BATTERY) != 0) { sc->sc_bat_present = 1; acpibat_getbif(sc); acpibat_getbst(sc); printf(": %s", sc->sc_devnode->name); if (sc->sc_bif.bif_model[0]) printf(" model \"%s\"", sc->sc_bif.bif_model); if (sc->sc_bif.bif_serial[0]) printf(" serial %s", sc->sc_bif.bif_serial); if (sc->sc_bif.bif_type[0]) printf(" type %s", sc->sc_bif.bif_type); if (sc->sc_bif.bif_oem[0]) printf(" oem \"%s\"", sc->sc_bif.bif_oem); printf("\n"); } else { sc->sc_bat_present = 0; printf(": %s not present\n", sc->sc_devnode->name); } aml_freevalue(&res); /* create sensors */ acpibat_monitor(sc); /* populate sensors */ acpibat_refresh(sc); aml_register_notify(sc->sc_devnode, aa->aaa_dev, acpibat_notify, sc, ACPIDEV_POLL); }
int acpibat_notify(struct aml_node *node, int notify_type, void *arg) { struct acpibat_softc *sc = arg; struct aml_value res; int present dnprintf(10, "acpibat_notify: %.2x %s\n", notify_type, sc->sc_devnode->name); /* Check if installed state of battery has changed */ memset(&res, 0, sizeof(res)); if (aml_evalname(sc->sc_acpi, node, "_STA", 0, NULL, &res) == 0) { present = res.v_integer & STA_BATTERY; if (!sc->sc_bat_present && present) { printf("%s: %s inserted\n", DEVNAME(sc), sc->sc_devnode->name); sc->sc_bat_present = 1; } else if (sc->sc_bat_present && !present) { printf("%s: %s removed\n", DEVNAME(sc), sc->sc_devnode->name); sc->sc_bat_present = 0; } } switch (notify_type) { case 0x80: /* _BST changed */ break; case 0x81: /* _BIF changed */ break; default: break; } acpibat_refresh(sc); return (0); }