summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorFederico G. Schwindt <fgsch@cvs.openbsd.org>2008-07-02 03:14:55 +0000
committerFederico G. Schwindt <fgsch@cvs.openbsd.org>2008-07-02 03:14:55 +0000
commit0663d2ea94f31772153644b774af3381dac91ba9 (patch)
tree2a49d8264b2e69783e0dec8b528a9738be455267 /sys
parent65b37a21a126fd55ab9c0560b90ab73b095f6e87 (diff)
add acpivideo. for now almost an empty skel so others can work on
suspend/resume. eventually it will also manage output switching and brightness where supported. prodded by marco@
Diffstat (limited to 'sys')
-rw-r--r--sys/dev/acpi/acpi.c24
-rw-r--r--sys/dev/acpi/acpivideo.c131
-rw-r--r--sys/dev/acpi/files.acpi7
3 files changed, 160 insertions, 2 deletions
diff --git a/sys/dev/acpi/acpi.c b/sys/dev/acpi/acpi.c
index 1599cb0e52c..485986ac7bf 100644
--- a/sys/dev/acpi/acpi.c
+++ b/sys/dev/acpi/acpi.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: acpi.c,v 1.124 2008/06/11 04:42:09 marco Exp $ */
+/* $OpenBSD: acpi.c,v 1.125 2008/07/02 03:14:54 fgsch Exp $ */
/*
* Copyright (c) 2005 Thorsten Lockert <tholo@sigmasoft.com>
* Copyright (c) 2005 Jordan Hargrave <jordan@openbsd.org>
@@ -70,6 +70,7 @@ int acpi_foundec(struct aml_node *, void *);
int acpi_foundtmp(struct aml_node *, void *);
int acpi_foundprt(struct aml_node *, void *);
int acpi_foundprw(struct aml_node *, void *);
+int acpi_foundvideo(struct aml_node *, void *);
int acpi_inidev(struct aml_node *, void *);
int acpi_loadtables(struct acpi_softc *, struct acpi_rsdp *);
@@ -593,6 +594,9 @@ acpi_attach(struct device *parent, struct device *self, void *aux)
/* attach docks */
aml_find_node(&aml_root, "_DCK", acpi_founddock, sc);
+ /* attach video */
+ aml_find_node(&aml_root, "_DOS", acpi_foundvideo, sc);
+
/* create list of devices we want to query when APM come in */
SLIST_INIT(&sc->sc_ac);
SLIST_INIT(&sc->sc_bat);
@@ -2021,4 +2025,22 @@ acpi_founddock(struct aml_node *node, void *arg)
return 0;
}
+
+int
+acpi_foundvideo(struct aml_node *node, void *arg)
+{
+ struct acpi_softc *sc = (struct acpi_softc *)arg;
+ struct device *self = (struct device *)arg;
+ struct acpi_attach_args aaa;
+
+ memset(&aaa, 0, sizeof(aaa));
+ aaa.aaa_iot = sc->sc_iot;
+ aaa.aaa_memt = sc->sc_memt;
+ aaa.aaa_node = node->parent;
+ aaa.aaa_name = "acpivideo";
+
+ config_found(self, &aaa, acpi_print);
+
+ return (0);
+}
#endif /* SMALL_KERNEL */
diff --git a/sys/dev/acpi/acpivideo.c b/sys/dev/acpi/acpivideo.c
new file mode 100644
index 00000000000..7659182a296
--- /dev/null
+++ b/sys/dev/acpi/acpivideo.c
@@ -0,0 +1,131 @@
+/* $OpenBSD: acpivideo.c,v 1.1 2008/07/02 03:14:54 fgsch Exp $ */
+/*
+ * Copyright (c) 2008 Federico G. Schwindt <fgsch@openbsd.org>
+ *
+ * Permission to use, copy, modify, and/or distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/device.h>
+
+#include <machine/bus.h>
+
+#include <dev/acpi/acpireg.h>
+#include <dev/acpi/acpivar.h>
+#include <dev/acpi/acpidev.h>
+#include <dev/acpi/amltypes.h>
+#include <dev/acpi/dsdt.h>
+
+#ifdef ACPIVIDEO_DEBUG
+#define DPRINTF(x) printf x
+#else
+#define DPRINTF(x)
+#endif
+
+/* _DOS Enable/Disable Output Switching */
+#define DOS_SWITCH_BY_OSPM 0
+#define DOS_SWITCH_BY_BIOS 1
+#define DOS_SWITCH_LOCKED 2
+#define DOS_SWITCH_BY_OSPM_EXT 3
+#define DOS_BRIGHTNESS_BY_OSPM 4
+
+/* Notifications for Displays Devices */
+#define NOTIFY_OUTPUT_SWITCHED 0x80
+#define NOTIFY_OUTPUT_CHANGED 0x81
+#define NOTIFY_OUTPUT_CYCLE_KEY 0x82
+#define NOTIFY_OUTPUT_NEXT_KEY 0x83
+#define NOTIFY_OUTPUT_PREV_KEY 0x84
+
+struct acpivideo_softc {
+ struct device sc_dev;
+
+ struct acpi_softc *sc_acpi;
+ struct aml_node *sc_devnode;
+};
+
+int acpivideo_match(struct device *, void *, void *);
+void acpivideo_attach(struct device *, struct device *, void *);
+
+struct cfattach acpivideo_ca = {
+ sizeof(struct acpivideo_softc), acpivideo_match, acpivideo_attach
+};
+
+struct cfdriver acpivideo_cd = {
+ NULL, "acpivideo", DV_DULL
+};
+
+int acpivideo_notify(struct aml_node *, int, void *);
+void acpivideo_set_policy(struct acpivideo_softc *, int);
+
+int
+acpivideo_match(struct device *parent, void *match, void *aux)
+{
+ struct acpi_attach_args *aaa = aux;
+ struct cfdata *cf = match;
+
+ if (aaa->aaa_name == NULL || strcmp(aaa->aaa_name,
+ cf->cf_driver->cd_name) != 0 || aaa->aaa_table != NULL)
+ return (0);
+
+ return (1);
+}
+
+void
+acpivideo_attach(struct device *parent, struct device *self, void *aux)
+{
+ struct acpivideo_softc *sc = (struct acpivideo_softc *)self;
+ struct acpi_attach_args *aa = aux;
+
+ sc->sc_acpi = (struct acpi_softc *)parent;
+ sc->sc_devnode = aa->aaa_node;
+
+ printf(": %s\n", sc->sc_devnode->name);
+
+ aml_register_notify(sc->sc_devnode, aa->aaa_dev,
+ acpivideo_notify, sc, ACPIDEV_NOPOLL);
+
+ acpivideo_set_policy(sc,
+ DOS_SWITCH_BY_OSPM | DOS_BRIGHTNESS_BY_OSPM);
+}
+
+int
+acpivideo_notify(struct aml_node *node, int notify, void *arg)
+{
+ struct acpivideo_softc *sc = arg;
+
+ switch (notify) {
+ case NOTIFY_OUTPUT_SWITCHED:
+ case NOTIFY_OUTPUT_CHANGED:
+ DPRINTF(("%s: event 0x%02x\n", DEVNAME(sc), notify));
+ break;
+
+ default:
+ printf("%s: unknown event 0x%02x\n", DEVNAME(sc), notify);
+ break;
+ }
+
+ return (0);
+}
+
+void
+acpivideo_set_policy(struct acpivideo_softc *sc, int policy)
+{
+ struct aml_value args, res;
+
+ memset(&args, 0, sizeof(args));
+ args.v_integer = policy;
+ args.type = AML_OBJTYPE_INTEGER;
+ aml_evalname(sc->sc_acpi, sc->sc_devnode, "_DOS", 1, &args, &res);
+ aml_freevalue(&res);
+}
diff --git a/sys/dev/acpi/files.acpi b/sys/dev/acpi/files.acpi
index cc34895db3f..f40ba2b9888 100644
--- a/sys/dev/acpi/files.acpi
+++ b/sys/dev/acpi/files.acpi
@@ -1,4 +1,4 @@
-# $OpenBSD: files.acpi,v 1.19 2008/06/24 08:24:57 sobrado Exp $
+# $OpenBSD: files.acpi,v 1.20 2008/07/02 03:14:54 fgsch Exp $
#
# Config file and device description for machine-independent ACPI code.
# Included by ports that need it.
@@ -75,3 +75,8 @@ file dev/acpi/acpiasus.c acpiasus
device acpithinkpad
attach acpithinkpad at acpi
file dev/acpi/acpithinkpad.c acpithinkpad
+
+# ACPI video
+device acpivideo
+attach acpivideo at acpi
+file dev/acpi/acpivideo.c acpivideo