Deleted Added
full compact
acpi_sony.c (143002) acpi_sony.c (150003)
1/*-
2 * Copyright (c) 2004 Takanori Watanabe
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 *
14 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 */
26
27#include <sys/cdefs.h>
1/*-
2 * Copyright (c) 2004 Takanori Watanabe
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 *
14 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 */
26
27#include <sys/cdefs.h>
28__FBSDID("$FreeBSD: head/sys/dev/acpi_support/acpi_sony.c 143002 2005-03-02 09:22:34Z obrien $");
28__FBSDID("$FreeBSD: head/sys/dev/acpi_support/acpi_sony.c 150003 2005-09-11 18:39:03Z obrien $");
29
30#include "opt_acpi.h"
31#include <sys/param.h>
32#include <sys/kernel.h>
33#include <sys/bus.h>
29
30#include "opt_acpi.h"
31#include <sys/param.h>
32#include <sys/kernel.h>
33#include <sys/bus.h>
34#include "acpi.h"
34#include <contrib/dev/acpica/acpi.h>
35#include "acpi_if.h"
36#include <sys/module.h>
37#include <dev/acpica/acpivar.h>
38#include <sys/sysctl.h>
39
40#define _COMPONENT ACPI_OEM
41ACPI_MODULE_NAME("Sony")
42
43#define ACPI_SONY_GET_BRIGHTNESS "GBRT"
44#define ACPI_SONY_SET_BRIGHTNESS "SBRT"
45#define ACPI_SONY_GET_PID "GPID"
46
47/*
48 * SNY5001
49 * [GS]BRT [GS]PBR [GS]CTR [GS]PCR [GS]CMI [CDPW GCDP]? GWDP PWAK PWRN
50 *
51 */
52
53struct acpi_sony_softc {
54 int pid;
55};
56static struct acpi_sony_name_list
57{
58 char *nodename;
59 char *getmethod;
60 char *setmethod;
61 char *comment;
62} acpi_sony_oids[] = {
63 { "brightness", "GBRT", "SBRT", "Display Brightness"},
64 { "ctr", "GCTR", "SCTR", "??"},
65 { "pcr", "GPCR", "SPCR", "???"},
66#if 0
67 { "cmi", "GCMI", "SCMI", "????"},
68#endif
69 { "wdp", "GWDP", NULL, "?????"},
70 { "cdp", "GCDP", "CDPW", "??????"}, /*shares [\GL03]&0x8 flag*/
71 {NULL, NULL,NULL}
72};
73
74static int acpi_sony_probe(device_t dev);
75static int acpi_sony_attach(device_t dev);
76static int acpi_sony_detach(device_t dev);
77static int sysctl_acpi_sony_gen_handler(SYSCTL_HANDLER_ARGS);
78
79static device_method_t acpi_sony_methods[] = {
80 /* Device interface */
81 DEVMETHOD(device_probe, acpi_sony_probe),
82 DEVMETHOD(device_attach, acpi_sony_attach),
83 DEVMETHOD(device_detach, acpi_sony_detach),
84
85 {0, 0}
86};
87
88static driver_t acpi_sony_driver = {
89 "acpi_sony",
90 acpi_sony_methods,
91 sizeof(struct acpi_sony_softc),
92};
93
94static devclass_t acpi_sony_devclass;
95
96DRIVER_MODULE(acpi_sony, acpi, acpi_sony_driver, acpi_sony_devclass,
97 0, 0);
98MODULE_DEPEND(acpi_sony, acpi, 1, 1, 1);
99static char *sny_id[] = {"SNY5001", NULL};
100
101static int
102acpi_sony_probe(device_t dev)
103{
104 struct acpi_sony_softc *sc;
105 int ret = ENXIO;
106
107 sc = device_get_softc(dev);
108
109 if (ACPI_ID_PROBE(device_get_parent(dev), dev, sny_id)) {
110 device_set_desc(dev, "Sony notebook controller");
111 ret = 0;
112 }
113 return (ret);
114}
115
116static int
117acpi_sony_attach(device_t dev)
118{
119 struct acpi_sony_softc *sc;
120 int i;
121
122 sc = device_get_softc(dev);
123 acpi_GetInteger(acpi_get_handle(dev), ACPI_SONY_GET_PID, &sc->pid);
124 device_printf(dev, "PID %x\n", sc->pid);
125 for (i = 0 ; acpi_sony_oids[i].nodename != NULL; i++){
126 SYSCTL_ADD_PROC(device_get_sysctl_ctx(dev),
127 SYSCTL_CHILDREN(device_get_sysctl_tree(dev)),
128 i, acpi_sony_oids[i].nodename , CTLTYPE_INT |
129 ((acpi_sony_oids[i].setmethod)? CTLFLAG_RW: CTLFLAG_RD),
130 dev, i, sysctl_acpi_sony_gen_handler, "I",
131 acpi_sony_oids[i].comment);
132 }
133 return (0);
134}
135
136static int
137acpi_sony_detach(device_t dev)
138{
139 return (0);
140}
141
142#if 0
143static int
144acpi_sony_suspend(device_t dev)
145{
146 struct acpi_sony_softc *sc = device_get_softc(dev);
147 return (0);
148}
149
150static int
151acpi_sony_resume(device_t dev)
152{
153 return (0);
154}
155#endif
156
157static int
158sysctl_acpi_sony_gen_handler(SYSCTL_HANDLER_ARGS)
159{
160 device_t dev = arg1;
161 int function = oidp->oid_arg2;
162 int error = 0, val;
163
164 acpi_GetInteger(acpi_get_handle(dev),
165 acpi_sony_oids[function].getmethod, &val);
166 error = sysctl_handle_int(oidp, &val, 0, req);
167 if (error || !req->newptr || !acpi_sony_oids[function].setmethod)
168 return (error);
169 acpi_SetInteger(acpi_get_handle(dev),
170 acpi_sony_oids[function].setmethod, val);
171 return (0);
172}
35#include "acpi_if.h"
36#include <sys/module.h>
37#include <dev/acpica/acpivar.h>
38#include <sys/sysctl.h>
39
40#define _COMPONENT ACPI_OEM
41ACPI_MODULE_NAME("Sony")
42
43#define ACPI_SONY_GET_BRIGHTNESS "GBRT"
44#define ACPI_SONY_SET_BRIGHTNESS "SBRT"
45#define ACPI_SONY_GET_PID "GPID"
46
47/*
48 * SNY5001
49 * [GS]BRT [GS]PBR [GS]CTR [GS]PCR [GS]CMI [CDPW GCDP]? GWDP PWAK PWRN
50 *
51 */
52
53struct acpi_sony_softc {
54 int pid;
55};
56static struct acpi_sony_name_list
57{
58 char *nodename;
59 char *getmethod;
60 char *setmethod;
61 char *comment;
62} acpi_sony_oids[] = {
63 { "brightness", "GBRT", "SBRT", "Display Brightness"},
64 { "ctr", "GCTR", "SCTR", "??"},
65 { "pcr", "GPCR", "SPCR", "???"},
66#if 0
67 { "cmi", "GCMI", "SCMI", "????"},
68#endif
69 { "wdp", "GWDP", NULL, "?????"},
70 { "cdp", "GCDP", "CDPW", "??????"}, /*shares [\GL03]&0x8 flag*/
71 {NULL, NULL,NULL}
72};
73
74static int acpi_sony_probe(device_t dev);
75static int acpi_sony_attach(device_t dev);
76static int acpi_sony_detach(device_t dev);
77static int sysctl_acpi_sony_gen_handler(SYSCTL_HANDLER_ARGS);
78
79static device_method_t acpi_sony_methods[] = {
80 /* Device interface */
81 DEVMETHOD(device_probe, acpi_sony_probe),
82 DEVMETHOD(device_attach, acpi_sony_attach),
83 DEVMETHOD(device_detach, acpi_sony_detach),
84
85 {0, 0}
86};
87
88static driver_t acpi_sony_driver = {
89 "acpi_sony",
90 acpi_sony_methods,
91 sizeof(struct acpi_sony_softc),
92};
93
94static devclass_t acpi_sony_devclass;
95
96DRIVER_MODULE(acpi_sony, acpi, acpi_sony_driver, acpi_sony_devclass,
97 0, 0);
98MODULE_DEPEND(acpi_sony, acpi, 1, 1, 1);
99static char *sny_id[] = {"SNY5001", NULL};
100
101static int
102acpi_sony_probe(device_t dev)
103{
104 struct acpi_sony_softc *sc;
105 int ret = ENXIO;
106
107 sc = device_get_softc(dev);
108
109 if (ACPI_ID_PROBE(device_get_parent(dev), dev, sny_id)) {
110 device_set_desc(dev, "Sony notebook controller");
111 ret = 0;
112 }
113 return (ret);
114}
115
116static int
117acpi_sony_attach(device_t dev)
118{
119 struct acpi_sony_softc *sc;
120 int i;
121
122 sc = device_get_softc(dev);
123 acpi_GetInteger(acpi_get_handle(dev), ACPI_SONY_GET_PID, &sc->pid);
124 device_printf(dev, "PID %x\n", sc->pid);
125 for (i = 0 ; acpi_sony_oids[i].nodename != NULL; i++){
126 SYSCTL_ADD_PROC(device_get_sysctl_ctx(dev),
127 SYSCTL_CHILDREN(device_get_sysctl_tree(dev)),
128 i, acpi_sony_oids[i].nodename , CTLTYPE_INT |
129 ((acpi_sony_oids[i].setmethod)? CTLFLAG_RW: CTLFLAG_RD),
130 dev, i, sysctl_acpi_sony_gen_handler, "I",
131 acpi_sony_oids[i].comment);
132 }
133 return (0);
134}
135
136static int
137acpi_sony_detach(device_t dev)
138{
139 return (0);
140}
141
142#if 0
143static int
144acpi_sony_suspend(device_t dev)
145{
146 struct acpi_sony_softc *sc = device_get_softc(dev);
147 return (0);
148}
149
150static int
151acpi_sony_resume(device_t dev)
152{
153 return (0);
154}
155#endif
156
157static int
158sysctl_acpi_sony_gen_handler(SYSCTL_HANDLER_ARGS)
159{
160 device_t dev = arg1;
161 int function = oidp->oid_arg2;
162 int error = 0, val;
163
164 acpi_GetInteger(acpi_get_handle(dev),
165 acpi_sony_oids[function].getmethod, &val);
166 error = sysctl_handle_int(oidp, &val, 0, req);
167 if (error || !req->newptr || !acpi_sony_oids[function].setmethod)
168 return (error);
169 acpi_SetInteger(acpi_get_handle(dev),
170 acpi_sony_oids[function].setmethod, val);
171 return (0);
172}