Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F140113325
D937.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
2 KB
Referenced Files
None
Subscribers
None
D937.diff
View Options
Index: head/etc/devd/apple.conf
===================================================================
--- head/etc/devd/apple.conf
+++ head/etc/devd/apple.conf
@@ -71,4 +71,10 @@
action "camcontrol eject cd0";
};
-
+# Equivalent to the ACPI/ACAD notify
+notify 10 {
+ match "system" "PMU";
+ match "subsystem" "POWER";
+ match "type" "ACLINE";
+ action "/etc/rc.d/power_profile $notify";
+}
Index: head/sys/powerpc/powermac/pmu.c
===================================================================
--- head/sys/powerpc/powermac/pmu.c
+++ head/sys/powerpc/powermac/pmu.c
@@ -35,6 +35,7 @@
#include <sys/bus.h>
#include <sys/conf.h>
#include <sys/kernel.h>
+#include <sys/kthread.h>
#include <sys/clock.h>
#include <sys/proc.h>
#include <sys/reboot.h>
@@ -183,6 +184,9 @@
static uint8_t pmu_read_reg(struct pmu_softc *sc, u_int offset);
static void pmu_write_reg(struct pmu_softc *sc, u_int offset, uint8_t value);
static int pmu_intr_state(struct pmu_softc *);
+static void pmu_battquery_proc(void);
+static void pmu_battery_notify(struct pmu_battstate *batt,
+ struct pmu_battstate *old);
/* these values shows that number of data returned after 'send' cmd is sent */
static signed char pm_send_cmd_type[] = {
@@ -256,6 +260,13 @@
-1, -1, -1, -1, -1, -1, -1, -1,
};
+static struct proc *pmubattproc;
+static struct kproc_desc pmu_batt_kp = {
+ "pmu_batt",
+ pmu_battquery_proc,
+ &pmubattproc
+};
+
/* We only have one of each device, so globals are safe */
static device_t pmu = NULL;
static device_t pmu_extint = NULL;
@@ -420,6 +431,8 @@
struct sysctl_oid *oid, *battroot;
char battnum[2];
+ /* Only start the battery monitor if we have a battery. */
+ kproc_start(&pmu_batt_kp);
SYSCTL_ADD_PROC(ctx, SYSCTL_CHILDREN(tree), OID_AUTO,
"acline", CTLTYPE_INT | CTLFLAG_RD, sc, 0,
pmu_acline_state, "I", "AC Line Status");
@@ -914,6 +927,39 @@
return (0);
}
+static void
+pmu_battery_notify(struct pmu_battstate *batt, struct pmu_battstate *old)
+{
+ char notify_buf[16];
+ int acline;
+
+ acline = (batt->state & PMU_PWR_AC_PRESENT) ? 1 : 0;
+ if (acline != (old->state & PMU_PWR_AC_PRESENT)) {
+ snprintf(notify_buf, sizeof(notify_buf),
+ "notify=0x%02x", acline);
+ devctl_notify("PMU", "POWER", "ACLINE", notify_buf);
+ }
+}
+
+static void
+pmu_battquery_proc()
+{
+ struct pmu_softc *sc;
+ struct pmu_battstate batt;
+ struct pmu_battstate cur_batt;
+ int error;
+
+ sc = device_get_softc(pmu);
+
+ error = pmu_query_battery(sc, 0, &cur_batt);
+ while (1) {
+ error = pmu_query_battery(sc, 0, &batt);
+ pmu_battery_notify(&batt, &cur_batt);
+ cur_batt = batt;
+ pause("pmu_batt", hz);
+ }
+}
+
static int
pmu_acline_state(SYSCTL_HANDLER_ARGS)
{
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Dec 21, 10:11 AM (17 h, 35 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
27111244
Default Alt Text
D937.diff (2 KB)
Attached To
Mode
D937: Add an AC line monitor so power_profile can work
Attached
Detach File
Event Timeline
Log In to Comment