-/* $OpenBSD: adb.c,v 1.47 2022/10/21 22:42:36 gkoehler Exp $ */
+/* $OpenBSD: adb.c,v 1.48 2022/10/23 03:43:03 gkoehler Exp $ */
/* $NetBSD: adb.c,v 1.6 1999/08/16 06:28:09 tsubai Exp $ */
/* $NetBSD: adb_direct.c,v 1.14 2000/06/08 22:10:45 tsubai Exp $ */
#ifndef SMALL_KERNEL
void adb_shutdown(void *);
struct task adb_shutdown_task = TASK_INITIALIZER(adb_shutdown, NULL);
+#ifdef SUSPEND
+void adb_suspend(void *);
+struct task adb_suspend_task = TASK_INITIALIZER(adb_suspend, NULL);
+struct taskq *adb_suspendq;
+#endif
#endif
#ifdef ADB_DEBUG
prsignal(initprocess, SIGUSR2);
}
}
+
+#ifdef SUSPEND
+void
+adb_suspend(void *arg)
+{
+ extern struct cfdriver apm_cd;
+
+ if (apm_cd.cd_ndevs > 0)
+ sleep_state(apm_cd.cd_devs[0], SLEEP_SUSPEND);
+}
+#endif
#endif /* !SMALL_KERNEL */
void
{
#ifndef SMALL_KERNEL
switch (lid_action) {
+#ifdef SUSPEND
case 1:
- /* Suspend. */
+ task_add(adb_suspendq, &adb_suspend_task);
break;
+#endif
case 2:
/* Hibernate. */
break;
case 1:
task_add(systq, &adb_shutdown_task);
break;
+#ifdef SUSPEND
case 2:
- /* Suspend. */
+ task_add(adb_suspendq, &adb_suspend_task);
break;
+#endif
}
#endif
}
int totaladbs;
int adbindex, adbaddr;
+#if !defined(SMALL_KERNEL) && defined(SUSPEND)
+ adb_suspendq = taskq_create(sc->sc_dev.dv_xname, 1, IPL_TTY, 0);
+ if (adb_suspendq == NULL) {
+ printf(": can't create taskq\n");
+ return;
+ }
+#endif
+
ca->ca_reg[0] += ca->ca_baseaddr;
sc->sc_regbase = mapiodev(ca->ca_reg[0], ca->ca_reg[1]);
-/* $OpenBSD: apm.c,v 1.33 2022/03/13 12:33:01 mpi Exp $ */
+/* $OpenBSD: apm.c,v 1.34 2022/10/23 03:43:03 gkoehler Exp $ */
/*-
* Copyright (c) 2001 Alexander Guy. All rights reserved.
printf(": battery flags 0x%X, ", info.flags);
printf("%d%% charged\n", ((info.cur_charge * 100) / info.max_charge));
+
+#ifdef SUSPEND
+ device_register_wakeup(self);
+#endif
}
int
{
switch (sleepmode) {
case SLEEP_SUSPEND:
- /* TODO blink the light */
return 0;
default:
return EOPNOTSUPP;
int
sleep_setstate(void *v)
{
- printf("TODO sleep_setstate\n");
return 0;
}