| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: lmu.c,v 1.2 2020/02/06 02:17:24 macallan Exp $ */ | | 1 | /* $NetBSD: lmu.c,v 1.3 2020/04/23 09:47:31 macallan Exp $ */ |
2 | | | 2 | |
3 | /*- | | 3 | /*- |
4 | * Copyright (c) 2020 Michael Lorenz | | 4 | * Copyright (c) 2020 Michael Lorenz |
5 | * All rights reserved. | | 5 | * All rights reserved. |
6 | * | | 6 | * |
7 | * Redistribution and use in source and binary forms, with or without | | 7 | * Redistribution and use in source and binary forms, with or without |
8 | * modification, are permitted provided that the following conditions | | 8 | * modification, are permitted provided that the following conditions |
9 | * are met: | | 9 | * are met: |
10 | * 1. Redistributions of source code must retain the above copyright | | 10 | * 1. Redistributions of source code must retain the above copyright |
11 | * notice, this list of conditions and the following disclaimer. | | 11 | * notice, this list of conditions and the following disclaimer. |
12 | * 2. Redistributions in binary form must reproduce the above copyright | | 12 | * 2. Redistributions in binary form must reproduce the above copyright |
13 | * notice, this list of conditions and the following disclaimer in the | | 13 | * notice, this list of conditions and the following disclaimer in the |
14 | * documentation and/or other materials provided with the distribution. | | 14 | * documentation and/or other materials provided with the distribution. |
| @@ -21,52 +21,50 @@ | | | @@ -21,52 +21,50 @@ |
21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | | 21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | | 22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
23 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | | 23 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
24 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | | 24 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
25 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | | 25 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
26 | * POSSIBILITY OF SUCH DAMAGE. | | 26 | * POSSIBILITY OF SUCH DAMAGE. |
27 | */ | | 27 | */ |
28 | | | 28 | |
29 | /* | | 29 | /* |
30 | * ambient light controller found in PowerBook5,6 | | 30 | * ambient light controller found in PowerBook5,6 |
31 | */ | | 31 | */ |
32 | | | 32 | |
33 | #include <sys/cdefs.h> | | 33 | #include <sys/cdefs.h> |
34 | __KERNEL_RCSID(0, "$NetBSD: lmu.c,v 1.2 2020/02/06 02:17:24 macallan Exp $"); | | 34 | __KERNEL_RCSID(0, "$NetBSD: lmu.c,v 1.3 2020/04/23 09:47:31 macallan Exp $"); |
35 | | | 35 | |
36 | #include <sys/param.h> | | 36 | #include <sys/param.h> |
37 | #include <sys/systm.h> | | 37 | #include <sys/systm.h> |
38 | #include <sys/device.h> | | 38 | #include <sys/device.h> |
39 | #include <sys/conf.h> | | 39 | #include <sys/conf.h> |
40 | #include <sys/bus.h> | | 40 | #include <sys/bus.h> |
41 | #include <sys/time.h> | | 41 | #include <sys/time.h> |
42 | #include <sys/callout.h> | | 42 | #include <sys/callout.h> |
43 | | | 43 | |
44 | #include <dev/ofw/openfirm.h> | | | |
45 | | | | |
46 | #include <dev/i2c/i2cvar.h> | | 44 | #include <dev/i2c/i2cvar.h> |
47 | | | 45 | |
48 | #include <dev/sysmon/sysmonvar.h> | | 46 | #include <dev/sysmon/sysmonvar.h> |
49 | | | 47 | |
50 | struct lmu_softc { | | 48 | struct lmu_softc { |
51 | device_t sc_dev; | | 49 | device_t sc_dev; |
52 | i2c_tag_t sc_i2c; | | 50 | i2c_tag_t sc_i2c; |
53 | i2c_addr_t sc_addr; | | 51 | i2c_addr_t sc_addr; |
54 | int sc_node; | | 52 | int sc_node; |
55 | | | 53 | |
56 | struct sysmon_envsys *sc_sme; | | 54 | struct sysmon_envsys *sc_sme; |
57 | envsys_data_t sc_sensors[2]; | | 55 | envsys_data_t sc_sensors[2]; |
58 | callout_t sc_adjust; | | 56 | callout_t sc_adjust; |
59 | int sc_thresh, sc_hyst, sc_level; | | 57 | int sc_thresh, sc_hyst, sc_level; |
60 | int sc_lid_state, sc_video_state; | | 58 | int sc_lid_state, sc_video_state; |
61 | }; | | 59 | }; |
62 | | | 60 | |
63 | static int lmu_match(device_t, cfdata_t, void *); | | 61 | static int lmu_match(device_t, cfdata_t, void *); |
64 | static void lmu_attach(device_t, device_t, void *); | | 62 | static void lmu_attach(device_t, device_t, void *); |
65 | | | 63 | |
66 | static void lmu_sensors_refresh(struct sysmon_envsys *, envsys_data_t *); | | 64 | static void lmu_sensors_refresh(struct sysmon_envsys *, envsys_data_t *); |
67 | static void lmu_set_brightness(struct lmu_softc *, int); | | 65 | static void lmu_set_brightness(struct lmu_softc *, int); |
68 | static int lmu_get_brightness(struct lmu_softc *, int); | | 66 | static int lmu_get_brightness(struct lmu_softc *, int); |
69 | static void lmu_adjust(void *); | | 67 | static void lmu_adjust(void *); |
70 | | | 68 | |
71 | CFATTACH_DECL_NEW(lmu, sizeof(struct lmu_softc), | | 69 | CFATTACH_DECL_NEW(lmu, sizeof(struct lmu_softc), |
72 | lmu_match, lmu_attach, NULL, NULL); | | 70 | lmu_match, lmu_attach, NULL, NULL); |