diff options
author | 2011-04-06 21:16:13 +0000 | |
---|---|---|
committer | 2011-04-06 21:16:13 +0000 | |
commit | b67bea7ddd8620ef0dd4a91467c50819268c16f7 (patch) | |
tree | 88c57c1912a017b68e645aac486dcfa13ee899b0 | |
parent | comment typo (diff) | |
download | wireguard-openbsd-b67bea7ddd8620ef0dd4a91467c50819268c16f7.tar.xz wireguard-openbsd-b67bea7ddd8620ef0dd4a91467c50819268c16f7.zip |
Don't enumerate _DOD for attaching acpivout(4), since:
- ACPI spec. says _DOD is not required for brightness controls,
- The list returned by _DOD might be wrong,
- It's an unnecessary work to do.
Instead, decision to attach will be based on the actual methods
found, similarly like in the other ACPI drivers.
Tested by several on tech@.
OK kettenis@, marco@, pirofti@.
pirofti@ asked me to note here that devices not supporting brightness
controls won't attach from now on. This shouldn't be a concern for
you, since such devices weren't doing anything at all, anyway.
-rw-r--r-- | sys/dev/acpi/acpivar.h | 10 | ||||
-rw-r--r-- | sys/dev/acpi/acpivideo.c | 85 | ||||
-rw-r--r-- | sys/dev/acpi/acpivout.c | 32 |
3 files changed, 24 insertions, 103 deletions
diff --git a/sys/dev/acpi/acpivar.h b/sys/dev/acpi/acpivar.h index e9a172b5681..ed21551dea5 100644 --- a/sys/dev/acpi/acpivar.h +++ b/sys/dev/acpi/acpivar.h @@ -1,4 +1,4 @@ -/* $OpenBSD: acpivar.h,v 1.69 2011/01/02 04:56:57 jordan Exp $ */ +/* $OpenBSD: acpivar.h,v 1.70 2011/04/06 21:16:13 martynas Exp $ */ /* * Copyright (c) 2005 Thorsten Lockert <tholo@sigmasoft.com> * @@ -49,9 +49,6 @@ struct acpivideo_softc { struct acpi_softc *sc_acpi; struct aml_node *sc_devnode; - - int *sc_dod; - size_t sc_dod_len; }; struct acpi_attach_args { @@ -63,11 +60,6 @@ struct acpi_attach_args { const char *aaa_dev; }; -struct acpivideo_attach_args { - struct acpi_attach_args aaa; - int dod; -}; - struct acpi_mem_map { vaddr_t baseva; u_int8_t *va; diff --git a/sys/dev/acpi/acpivideo.c b/sys/dev/acpi/acpivideo.c index 149139f7bee..7608e58740a 100644 --- a/sys/dev/acpi/acpivideo.c +++ b/sys/dev/acpi/acpivideo.c @@ -1,4 +1,4 @@ -/* $OpenBSD: acpivideo.c,v 1.7 2010/07/27 06:12:50 deraadt Exp $ */ +/* $OpenBSD: acpivideo.c,v 1.8 2011/04/06 21:16:13 martynas Exp $ */ /* * Copyright (c) 2008 Federico G. Schwindt <fgsch@openbsd.org> * Copyright (c) 2009 Paul Irofti <pirofti@openbsd.org> @@ -54,7 +54,6 @@ void acpivideo_attach(struct device *, struct device *, void *); int acpivideo_notify(struct aml_node *, int, void *); void acpivideo_set_policy(struct acpivideo_softc *, int); -void acpivideo_get_dod(struct acpivideo_softc *); int acpi_foundvout(struct aml_node *, void *); int acpivideo_print(void *, const char *); @@ -101,8 +100,6 @@ acpivideo_attach(struct device *parent, struct device *self, void *aux) acpivideo_set_policy(sc, DOS_SWITCH_BY_OSPM | DOS_BRIGHTNESS_BY_OSPM); - acpivideo_get_dod(sc); - aml_find_node(aaa->aaa_node, "_DCS", acpi_foundvout, sc); aml_find_node(aaa->aaa_node, "_BCL", acpi_foundvout, sc); } @@ -137,7 +134,7 @@ acpivideo_set_policy(struct acpivideo_softc *sc, int policy) args.type = AML_OBJTYPE_INTEGER; aml_evalname(sc->sc_acpi, sc->sc_devnode, "_DOS", 1, &args, &res); - DPRINTF(("%s: set policy to %d", DEVNAME(sc), aml_val2int(&res))); + DPRINTF(("%s: set policy to %X\n", DEVNAME(sc), aml_val2int(&res))); aml_freevalue(&res); } @@ -145,45 +142,23 @@ acpivideo_set_policy(struct acpivideo_softc *sc, int policy) int acpi_foundvout(struct aml_node *node, void *arg) { - struct aml_value res; - int i, addr; - char fattach = 0; - struct acpivideo_softc *sc = (struct acpivideo_softc *)arg; struct device *self = (struct device *)arg; - struct acpivideo_attach_args av; + struct acpi_attach_args aaa; + node = node->parent; - if (sc->sc_dod == NULL) - return (0); - DPRINTF(("Inside acpi_foundvout()")); - if (aml_evalname(sc->sc_acpi, node->parent, "_ADR", 0, NULL, &res)) { - DPRINTF(("%s: no _ADR\n", DEVNAME(sc))); + DPRINTF(("Inside acpi_foundvout()\n")); + if (node->parent != sc->sc_devnode) return (0); - } - addr = aml_val2int(&res); - DPRINTF(("_ADR: %X\n", addr)); - aml_freevalue(&res); - for (i = 0; i < sc->sc_dod_len; i++) - if (addr == (sc->sc_dod[i]&0xffff)) { - DPRINTF(("Matched: %X\n", sc->sc_dod[i])); - fattach = 1; - break; - } - if (fattach) { - memset(&av, 0, sizeof(av)); - av.aaa.aaa_iot = sc->sc_acpi->sc_iot; - av.aaa.aaa_memt = sc->sc_acpi->sc_memt; - av.aaa.aaa_node = node->parent; - av.aaa.aaa_name = "acpivout"; - av.dod = sc->sc_dod[i]; - /* - * Make sure we don't attach twice if both _BCL and - * _DCS methods are found by zeroing the DOD address. - */ - sc->sc_dod[i] = 0; - - config_found(self, &av, acpivideo_print); + if (aml_searchname(node, "_BCM") && aml_searchname(node, "_BQC")) { + memset(&aaa, 0, sizeof(aaa)); + aaa.aaa_iot = sc->sc_acpi->sc_iot; + aaa.aaa_memt = sc->sc_acpi->sc_memt; + aaa.aaa_node = node; + aaa.aaa_name = "acpivout"; + + config_found(self, &aaa, acpivideo_print); } return (0); @@ -204,38 +179,6 @@ acpivideo_print(void *aux, const char *pnp) return (UNCONF); } -void -acpivideo_get_dod(struct acpivideo_softc * sc) -{ - struct aml_value res; - int i; - - if (aml_evalname(sc->sc_acpi, sc->sc_devnode, "_DOD", 0, NULL, &res)) { - DPRINTF(("%s: no _DOD\n", DEVNAME(sc))); - return; - } - sc->sc_dod_len = res.length; - if (sc->sc_dod_len == 0) { - sc->sc_dod = NULL; - aml_freevalue(&res); - return; - } - sc->sc_dod = malloc(sc->sc_dod_len * sizeof(int), M_DEVBUF, - M_WAITOK|M_ZERO); - if (sc->sc_dod == NULL) { - aml_freevalue(&res); - return; - } - - for (i = 0; i < sc->sc_dod_len; i++) { - sc->sc_dod[i] = aml_val2int(res.v_package[i]); - DPRINTF(("DOD: %X ", sc->sc_dod[i])); - } - DPRINTF(("\n")); - - aml_freevalue(&res); -} - int acpivideo_getpcibus(struct acpivideo_softc *sc, struct aml_node *node) { diff --git a/sys/dev/acpi/acpivout.c b/sys/dev/acpi/acpivout.c index 160ebfa6850..c28fbeec551 100644 --- a/sys/dev/acpi/acpivout.c +++ b/sys/dev/acpi/acpivout.c @@ -1,4 +1,4 @@ -/* $OpenBSD: acpivout.c,v 1.7 2010/08/08 20:45:18 kettenis Exp $ */ +/* $OpenBSD: acpivout.c,v 1.8 2011/04/06 21:16:13 martynas Exp $ */ /* * Copyright (c) 2009 Paul Irofti <pirofti@openbsd.org> * @@ -58,16 +58,6 @@ struct acpivout_softc { int *sc_bcl; size_t sc_bcl_len; - - int sc_dod; - int sc_vout_type; -#define ACPIVOUT_OTHER 0 -#define ACPIVOUT_VGA 1 -#define ACPIVOUT_TV 2 -#define ACPIVOUT_DVI 3 -#define ACPIVOUT_LCD 4 - -#define ACPIVOUT_TYPE_MASK 0x0f00 }; void acpivout_brightness_cycle(struct acpivout_softc *); @@ -97,12 +87,12 @@ struct cfdriver acpivout_cd = { int acpivout_match(struct device *parent, void *match, void *aux) { - struct acpivideo_attach_args *av = aux; + struct acpi_attach_args *aaa = aux; struct cfdata *cf = match; - if (av->aaa.aaa_name == NULL || - strcmp(av->aaa.aaa_name, cf->cf_driver->cd_name) != 0 || - av->aaa.aaa_table != NULL) + if (aaa->aaa_name == NULL || + strcmp(aaa->aaa_name, cf->cf_driver->cd_name) != 0 || + aaa->aaa_table != NULL) return (0); return (1); @@ -112,24 +102,20 @@ void acpivout_attach(struct device *parent, struct device *self, void *aux) { struct acpivout_softc *sc = (struct acpivout_softc *)self; - struct acpivideo_attach_args *av = aux; + struct acpi_attach_args *aaa = aux; sc->sc_acpi = ((struct acpivideo_softc *)parent)->sc_acpi; - sc->sc_devnode = av->aaa.aaa_node; - - sc->sc_vout_type = (av->dod & ACPIVOUT_TYPE_MASK) >> 8; + sc->sc_devnode = aaa->aaa_node; printf(": %s\n", sc->sc_devnode->name); - aml_register_notify(sc->sc_devnode, av->aaa.aaa_dev, + aml_register_notify(sc->sc_devnode, aaa->aaa_dev, acpivout_notify, sc, ACPIDEV_NOPOLL); ws_get_param = acpivout_get_param; ws_set_param = acpivout_set_param; - if (sc->sc_vout_type == ACPIVOUT_LCD || - sc->sc_vout_type == ACPIVOUT_VGA) - acpivout_get_bcl(sc); + acpivout_get_bcl(sc); } int |