| @@ -1,872 +1,871 @@ | | | @@ -1,872 +1,871 @@ |
1 | /* $NetBSD: genfb.c,v 1.67.2.1 2019/08/15 12:21:27 martin Exp $ */ | | 1 | /* $NetBSD: genfb.c,v 1.67.2.2 2020/04/15 14:15:17 martin Exp $ */ |
2 | | | 2 | |
3 | /*- | | 3 | /*- |
4 | * Copyright (c) 2007 Michael Lorenz | | 4 | * Copyright (c) 2007 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. |
15 | * | | 15 | * |
16 | * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS | | 16 | * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS |
17 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED | | 17 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED |
18 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | | 18 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
19 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS | | 19 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS |
20 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | | 20 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
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 | #include <sys/cdefs.h> | | 29 | #include <sys/cdefs.h> |
30 | __KERNEL_RCSID(0, "$NetBSD: genfb.c,v 1.67.2.1 2019/08/15 12:21:27 martin Exp $"); | | 30 | __KERNEL_RCSID(0, "$NetBSD: genfb.c,v 1.67.2.2 2020/04/15 14:15:17 martin Exp $"); |
31 | | | 31 | |
32 | #include <sys/param.h> | | 32 | #include <sys/param.h> |
33 | #include <sys/systm.h> | | 33 | #include <sys/systm.h> |
34 | #include <sys/kernel.h> | | 34 | #include <sys/kernel.h> |
35 | #include <sys/device.h> | | 35 | #include <sys/device.h> |
36 | #include <sys/proc.h> | | 36 | #include <sys/proc.h> |
37 | #include <sys/mutex.h> | | 37 | #include <sys/mutex.h> |
38 | #include <sys/ioctl.h> | | 38 | #include <sys/ioctl.h> |
39 | #include <sys/kernel.h> | | 39 | #include <sys/kernel.h> |
40 | #include <sys/systm.h> | | 40 | #include <sys/systm.h> |
41 | #include <sys/kmem.h> | | 41 | #include <sys/kmem.h> |
42 | | | 42 | |
43 | #include <dev/wscons/wsconsio.h> | | 43 | #include <dev/wscons/wsconsio.h> |
44 | #include <dev/wscons/wsdisplayvar.h> | | 44 | #include <dev/wscons/wsdisplayvar.h> |
45 | #include <dev/rasops/rasops.h> | | 45 | #include <dev/rasops/rasops.h> |
46 | #include <dev/wsfont/wsfont.h> | | 46 | #include <dev/wsfont/wsfont.h> |
47 | | | 47 | |
48 | #include <dev/wscons/wsdisplay_vconsvar.h> | | 48 | #include <dev/wscons/wsdisplay_vconsvar.h> |
49 | | | 49 | |
50 | #include <dev/wsfb/genfbvar.h> | | 50 | #include <dev/wsfb/genfbvar.h> |
51 | | | 51 | |
52 | #include <dev/videomode/videomode.h> | | 52 | #include <dev/videomode/videomode.h> |
53 | #include <dev/videomode/edidvar.h> | | 53 | #include <dev/videomode/edidvar.h> |
54 | | | 54 | |
55 | #ifdef GENFB_DISABLE_TEXT | | 55 | #ifdef GENFB_DISABLE_TEXT |
56 | #include <sys/reboot.h> | | 56 | #include <sys/reboot.h> |
57 | #define DISABLESPLASH (boothowto & (RB_SINGLE | RB_USERCONF | RB_ASKNAME | \ | | 57 | #define DISABLESPLASH (boothowto & (RB_SINGLE | RB_USERCONF | RB_ASKNAME | \ |
58 | AB_VERBOSE | AB_DEBUG) ) | | 58 | AB_VERBOSE | AB_DEBUG) ) |
59 | #endif | | 59 | #endif |
60 | | | 60 | |
61 | #ifdef _KERNEL_OPT | | 61 | #ifdef _KERNEL_OPT |
62 | #include "opt_genfb.h" | | 62 | #include "opt_genfb.h" |
63 | #include "opt_wsfb.h" | | 63 | #include "opt_wsfb.h" |
64 | #include "opt_rasops.h" | | 64 | #include "opt_rasops.h" |
65 | #endif | | 65 | #endif |
66 | | | 66 | |
67 | #ifdef GENFB_DEBUG | | 67 | #ifdef GENFB_DEBUG |
68 | #define GPRINTF panic | | 68 | #define GPRINTF panic |
69 | #else | | 69 | #else |
70 | #define GPRINTF aprint_debug | | 70 | #define GPRINTF aprint_debug |
71 | #endif | | 71 | #endif |
72 | | | 72 | |
73 | #define GENFB_BRIGHTNESS_STEP 15 | | 73 | #define GENFB_BRIGHTNESS_STEP 15 |
74 | #define GENFB_CHAR_WIDTH_MM 3 | | 74 | #define GENFB_CHAR_WIDTH_MM 3 |
75 | | | 75 | |
76 | static int genfb_ioctl(void *, void *, u_long, void *, int, struct lwp *); | | 76 | static int genfb_ioctl(void *, void *, u_long, void *, int, struct lwp *); |
77 | static paddr_t genfb_mmap(void *, void *, off_t, int); | | 77 | static paddr_t genfb_mmap(void *, void *, off_t, int); |
78 | static void genfb_pollc(void *, int); | | 78 | static void genfb_pollc(void *, int); |
79 | | | 79 | |
80 | static void genfb_init_screen(void *, struct vcons_screen *, int, long *); | | 80 | static void genfb_init_screen(void *, struct vcons_screen *, int, long *); |
81 | static int genfb_calc_hsize(struct genfb_softc *); | | 81 | static int genfb_calc_hsize(struct genfb_softc *); |
82 | static int genfb_calc_cols(struct genfb_softc *); | | 82 | static int genfb_calc_cols(struct genfb_softc *); |
83 | | | 83 | |
84 | static int genfb_putcmap(struct genfb_softc *, struct wsdisplay_cmap *); | | 84 | static int genfb_putcmap(struct genfb_softc *, struct wsdisplay_cmap *); |
85 | static int genfb_getcmap(struct genfb_softc *, struct wsdisplay_cmap *); | | 85 | static int genfb_getcmap(struct genfb_softc *, struct wsdisplay_cmap *); |
86 | static int genfb_putpalreg(struct genfb_softc *, uint8_t, uint8_t, | | 86 | static int genfb_putpalreg(struct genfb_softc *, uint8_t, uint8_t, |
87 | uint8_t, uint8_t); | | 87 | uint8_t, uint8_t); |
88 | static void genfb_init_palette(struct genfb_softc *); | | 88 | static void genfb_init_palette(struct genfb_softc *); |
89 | | | 89 | |
90 | static void genfb_brightness_up(device_t); | | 90 | static void genfb_brightness_up(device_t); |
91 | static void genfb_brightness_down(device_t); | | 91 | static void genfb_brightness_down(device_t); |
92 | | | 92 | |
93 | extern const u_char rasops_cmap[768]; | | 93 | extern const u_char rasops_cmap[768]; |
94 | | | 94 | |
95 | static int genfb_cnattach_called = 0; | | 95 | static int genfb_cnattach_called = 0; |
96 | static int genfb_enabled = 1; | | 96 | static int genfb_enabled = 1; |
97 | | | 97 | |
98 | static struct genfb_softc *genfb_softc = NULL; | | 98 | static struct genfb_softc *genfb_softc = NULL; |
99 | | | 99 | |
100 | void | | 100 | void |
101 | genfb_init(struct genfb_softc *sc) | | 101 | genfb_init(struct genfb_softc *sc) |
102 | { | | 102 | { |
103 | prop_dictionary_t dict; | | 103 | prop_dictionary_t dict; |
104 | uint64_t cmap_cb, pmf_cb, mode_cb, bl_cb, br_cb, fbaddr; | | 104 | uint64_t cmap_cb, pmf_cb, mode_cb, bl_cb, br_cb, fbaddr; |
105 | uint32_t fboffset; | | 105 | uint64_t fboffset; |
106 | bool console; | | 106 | bool console; |
107 | | | 107 | |
108 | dict = device_properties(sc->sc_dev); | | 108 | dict = device_properties(sc->sc_dev); |
109 | #ifdef GENFB_DEBUG | | 109 | #ifdef GENFB_DEBUG |
110 | printf("%s", prop_dictionary_externalize(dict)); | | 110 | printf("%s", prop_dictionary_externalize(dict)); |
111 | #endif | | 111 | #endif |
112 | prop_dictionary_get_bool(dict, "is_console", &console); | | 112 | prop_dictionary_get_bool(dict, "is_console", &console); |
113 | | | 113 | |
114 | if (!prop_dictionary_get_uint32(dict, "width", &sc->sc_width)) { | | 114 | if (!prop_dictionary_get_uint32(dict, "width", &sc->sc_width)) { |
115 | GPRINTF("no width property\n"); | | 115 | GPRINTF("no width property\n"); |
116 | return; | | 116 | return; |
117 | } | | 117 | } |
118 | if (!prop_dictionary_get_uint32(dict, "height", &sc->sc_height)) { | | 118 | if (!prop_dictionary_get_uint32(dict, "height", &sc->sc_height)) { |
119 | GPRINTF("no height property\n"); | | 119 | GPRINTF("no height property\n"); |
120 | return; | | 120 | return; |
121 | } | | 121 | } |
122 | if (!prop_dictionary_get_uint32(dict, "depth", &sc->sc_depth)) { | | 122 | if (!prop_dictionary_get_uint32(dict, "depth", &sc->sc_depth)) { |
123 | GPRINTF("no depth property\n"); | | 123 | GPRINTF("no depth property\n"); |
124 | return; | | 124 | return; |
125 | } | | 125 | } |
126 | | | 126 | |
127 | /* XXX should be a 64bit value */ | | 127 | if (!prop_dictionary_get_uint64(dict, "address", &fboffset)) { |
128 | if (!prop_dictionary_get_uint32(dict, "address", &fboffset)) { | | | |
129 | GPRINTF("no address property\n"); | | 128 | GPRINTF("no address property\n"); |
130 | return; | | 129 | return; |
131 | } | | 130 | } |
132 | | | 131 | |
133 | sc->sc_fboffset = fboffset; | | 132 | sc->sc_fboffset = (bus_addr_t)fboffset; |
134 | | | 133 | |
135 | sc->sc_fbaddr = NULL; | | 134 | sc->sc_fbaddr = NULL; |
136 | if (prop_dictionary_get_uint64(dict, "virtual_address", &fbaddr)) { | | 135 | if (prop_dictionary_get_uint64(dict, "virtual_address", &fbaddr)) { |
137 | sc->sc_fbaddr = (void *)(uintptr_t)fbaddr; | | 136 | sc->sc_fbaddr = (void *)(uintptr_t)fbaddr; |
138 | } | | 137 | } |
139 | | | 138 | |
140 | sc->sc_shadowfb = NULL; | | 139 | sc->sc_shadowfb = NULL; |
141 | if (!prop_dictionary_get_bool(dict, "enable_shadowfb", | | 140 | if (!prop_dictionary_get_bool(dict, "enable_shadowfb", |
142 | &sc->sc_enable_shadowfb)) | | 141 | &sc->sc_enable_shadowfb)) |
143 | #ifdef GENFB_SHADOWFB | | 142 | #ifdef GENFB_SHADOWFB |
144 | sc->sc_enable_shadowfb = true; | | 143 | sc->sc_enable_shadowfb = true; |
145 | #else | | 144 | #else |
146 | sc->sc_enable_shadowfb = false; | | 145 | sc->sc_enable_shadowfb = false; |
147 | #endif | | 146 | #endif |
148 | | | 147 | |
149 | if (!prop_dictionary_get_uint32(dict, "linebytes", &sc->sc_stride)) | | 148 | if (!prop_dictionary_get_uint32(dict, "linebytes", &sc->sc_stride)) |
150 | sc->sc_stride = (sc->sc_width * sc->sc_depth) >> 3; | | 149 | sc->sc_stride = (sc->sc_width * sc->sc_depth) >> 3; |
151 | | | 150 | |
152 | /* | | 151 | /* |
153 | * deal with a bug in the Raptor firmware which always sets | | 152 | * deal with a bug in the Raptor firmware which always sets |
154 | * stride = width even when depth != 8 | | 153 | * stride = width even when depth != 8 |
155 | */ | | 154 | */ |
156 | if (sc->sc_stride < sc->sc_width * (sc->sc_depth >> 3)) | | 155 | if (sc->sc_stride < sc->sc_width * (sc->sc_depth >> 3)) |
157 | sc->sc_stride = sc->sc_width * (sc->sc_depth >> 3); | | 156 | sc->sc_stride = sc->sc_width * (sc->sc_depth >> 3); |
158 | | | 157 | |
159 | sc->sc_fbsize = sc->sc_height * sc->sc_stride; | | 158 | sc->sc_fbsize = sc->sc_height * sc->sc_stride; |
160 | | | 159 | |
161 | /* optional colour map callback */ | | 160 | /* optional colour map callback */ |
162 | sc->sc_cmcb = NULL; | | 161 | sc->sc_cmcb = NULL; |
163 | if (prop_dictionary_get_uint64(dict, "cmap_callback", &cmap_cb)) { | | 162 | if (prop_dictionary_get_uint64(dict, "cmap_callback", &cmap_cb)) { |
164 | if (cmap_cb != 0) | | 163 | if (cmap_cb != 0) |
165 | sc->sc_cmcb = (void *)(vaddr_t)cmap_cb; | | 164 | sc->sc_cmcb = (void *)(vaddr_t)cmap_cb; |
166 | } | | 165 | } |
167 | | | 166 | |
168 | /* optional pmf callback */ | | 167 | /* optional pmf callback */ |
169 | sc->sc_pmfcb = NULL; | | 168 | sc->sc_pmfcb = NULL; |
170 | if (prop_dictionary_get_uint64(dict, "pmf_callback", &pmf_cb)) { | | 169 | if (prop_dictionary_get_uint64(dict, "pmf_callback", &pmf_cb)) { |
171 | if (pmf_cb != 0) | | 170 | if (pmf_cb != 0) |
172 | sc->sc_pmfcb = (void *)(vaddr_t)pmf_cb; | | 171 | sc->sc_pmfcb = (void *)(vaddr_t)pmf_cb; |
173 | } | | 172 | } |
174 | | | 173 | |
175 | /* optional mode callback */ | | 174 | /* optional mode callback */ |
176 | sc->sc_modecb = NULL; | | 175 | sc->sc_modecb = NULL; |
177 | if (prop_dictionary_get_uint64(dict, "mode_callback", &mode_cb)) { | | 176 | if (prop_dictionary_get_uint64(dict, "mode_callback", &mode_cb)) { |
178 | if (mode_cb != 0) | | 177 | if (mode_cb != 0) |
179 | sc->sc_modecb = (void *)(vaddr_t)mode_cb; | | 178 | sc->sc_modecb = (void *)(vaddr_t)mode_cb; |
180 | } | | 179 | } |
181 | | | 180 | |
182 | /* optional backlight control callback */ | | 181 | /* optional backlight control callback */ |
183 | sc->sc_backlight = NULL; | | 182 | sc->sc_backlight = NULL; |
184 | if (prop_dictionary_get_uint64(dict, "backlight_callback", &bl_cb)) { | | 183 | if (prop_dictionary_get_uint64(dict, "backlight_callback", &bl_cb)) { |
185 | if (bl_cb != 0) { | | 184 | if (bl_cb != 0) { |
186 | sc->sc_backlight = (void *)(vaddr_t)bl_cb; | | 185 | sc->sc_backlight = (void *)(vaddr_t)bl_cb; |
187 | aprint_naive_dev(sc->sc_dev, | | 186 | aprint_naive_dev(sc->sc_dev, |
188 | "enabling backlight control\n"); | | 187 | "enabling backlight control\n"); |
189 | } | | 188 | } |
190 | } | | 189 | } |
191 | | | 190 | |
192 | /* optional brightness control callback */ | | 191 | /* optional brightness control callback */ |
193 | sc->sc_brightness = NULL; | | 192 | sc->sc_brightness = NULL; |
194 | if (prop_dictionary_get_uint64(dict, "brightness_callback", &br_cb)) { | | 193 | if (prop_dictionary_get_uint64(dict, "brightness_callback", &br_cb)) { |
195 | if (br_cb != 0) { | | 194 | if (br_cb != 0) { |
196 | sc->sc_brightness = (void *)(vaddr_t)br_cb; | | 195 | sc->sc_brightness = (void *)(vaddr_t)br_cb; |
197 | aprint_naive_dev(sc->sc_dev, | | 196 | aprint_naive_dev(sc->sc_dev, |
198 | "enabling brightness control\n"); | | 197 | "enabling brightness control\n"); |
199 | if (console && | | 198 | if (console && |
200 | sc->sc_brightness->gpc_upd_parameter != NULL) { | | 199 | sc->sc_brightness->gpc_upd_parameter != NULL) { |
201 | pmf_event_register(sc->sc_dev, | | 200 | pmf_event_register(sc->sc_dev, |
202 | PMFE_DISPLAY_BRIGHTNESS_UP, | | 201 | PMFE_DISPLAY_BRIGHTNESS_UP, |
203 | genfb_brightness_up, TRUE); | | 202 | genfb_brightness_up, TRUE); |
204 | pmf_event_register(sc->sc_dev, | | 203 | pmf_event_register(sc->sc_dev, |
205 | PMFE_DISPLAY_BRIGHTNESS_DOWN, | | 204 | PMFE_DISPLAY_BRIGHTNESS_DOWN, |
206 | genfb_brightness_down, TRUE); | | 205 | genfb_brightness_down, TRUE); |
207 | } | | 206 | } |
208 | } | | 207 | } |
209 | } | | 208 | } |
210 | } | | 209 | } |
211 | | | 210 | |
212 | int | | 211 | int |
213 | genfb_attach(struct genfb_softc *sc, struct genfb_ops *ops) | | 212 | genfb_attach(struct genfb_softc *sc, struct genfb_ops *ops) |
214 | { | | 213 | { |
215 | struct wsemuldisplaydev_attach_args aa; | | 214 | struct wsemuldisplaydev_attach_args aa; |
216 | prop_dictionary_t dict; | | 215 | prop_dictionary_t dict; |
217 | struct rasops_info *ri; | | 216 | struct rasops_info *ri; |
218 | uint16_t crow; | | 217 | uint16_t crow; |
219 | long defattr; | | 218 | long defattr; |
220 | bool console; | | 219 | bool console; |
221 | #ifdef SPLASHSCREEN | | 220 | #ifdef SPLASHSCREEN |
222 | int i, j; | | 221 | int i, j; |
223 | int error = ENXIO; | | 222 | int error = ENXIO; |
224 | #endif | | 223 | #endif |
225 | | | 224 | |
226 | dict = device_properties(sc->sc_dev); | | 225 | dict = device_properties(sc->sc_dev); |
227 | prop_dictionary_get_bool(dict, "is_console", &console); | | 226 | prop_dictionary_get_bool(dict, "is_console", &console); |
228 | | | 227 | |
229 | if (prop_dictionary_get_uint16(dict, "cursor-row", &crow) == false) | | 228 | if (prop_dictionary_get_uint16(dict, "cursor-row", &crow) == false) |
230 | crow = 0; | | 229 | crow = 0; |
231 | if (prop_dictionary_get_bool(dict, "clear-screen", &sc->sc_want_clear) | | 230 | if (prop_dictionary_get_bool(dict, "clear-screen", &sc->sc_want_clear) |
232 | == false) | | 231 | == false) |
233 | sc->sc_want_clear = true; | | 232 | sc->sc_want_clear = true; |
234 | | | 233 | |
235 | aprint_verbose_dev(sc->sc_dev, "framebuffer at %p, size %dx%d, depth %d, " | | 234 | aprint_verbose_dev(sc->sc_dev, "framebuffer at %p, size %dx%d, depth %d, " |
236 | "stride %d\n", | | 235 | "stride %d\n", |
237 | sc->sc_fboffset ? (void *)(intptr_t)sc->sc_fboffset : sc->sc_fbaddr, | | 236 | sc->sc_fboffset ? (void *)(intptr_t)sc->sc_fboffset : sc->sc_fbaddr, |
238 | sc->sc_width, sc->sc_height, sc->sc_depth, sc->sc_stride); | | 237 | sc->sc_width, sc->sc_height, sc->sc_depth, sc->sc_stride); |
239 | | | 238 | |
240 | sc->sc_defaultscreen_descr = (struct wsscreen_descr){ | | 239 | sc->sc_defaultscreen_descr = (struct wsscreen_descr){ |
241 | "default", | | 240 | "default", |
242 | 0, 0, | | 241 | 0, 0, |
243 | NULL, | | 242 | NULL, |
244 | 8, 16, | | 243 | 8, 16, |
245 | WSSCREEN_WSCOLORS | WSSCREEN_HILIT | WSSCREEN_UNDERLINE | | | 244 | WSSCREEN_WSCOLORS | WSSCREEN_HILIT | WSSCREEN_UNDERLINE | |
246 | WSSCREEN_RESIZE, | | 245 | WSSCREEN_RESIZE, |
247 | NULL | | 246 | NULL |
248 | }; | | 247 | }; |
249 | sc->sc_screens[0] = &sc->sc_defaultscreen_descr; | | 248 | sc->sc_screens[0] = &sc->sc_defaultscreen_descr; |
250 | sc->sc_screenlist = (struct wsscreen_list){1, sc->sc_screens}; | | 249 | sc->sc_screenlist = (struct wsscreen_list){1, sc->sc_screens}; |
251 | memcpy(&sc->sc_ops, ops, sizeof(struct genfb_ops)); | | 250 | memcpy(&sc->sc_ops, ops, sizeof(struct genfb_ops)); |
252 | sc->sc_mode = WSDISPLAYIO_MODE_EMUL; | | 251 | sc->sc_mode = WSDISPLAYIO_MODE_EMUL; |
253 | if (sc->sc_modecb != NULL) | | 252 | if (sc->sc_modecb != NULL) |
254 | sc->sc_modecb->gmc_setmode(sc, sc->sc_mode); | | 253 | sc->sc_modecb->gmc_setmode(sc, sc->sc_mode); |
255 | | | 254 | |
256 | sc->sc_accessops.ioctl = genfb_ioctl; | | 255 | sc->sc_accessops.ioctl = genfb_ioctl; |
257 | sc->sc_accessops.mmap = genfb_mmap; | | 256 | sc->sc_accessops.mmap = genfb_mmap; |
258 | sc->sc_accessops.pollc = genfb_pollc; | | 257 | sc->sc_accessops.pollc = genfb_pollc; |
259 | | | 258 | |
260 | if (sc->sc_enable_shadowfb) { | | 259 | if (sc->sc_enable_shadowfb) { |
261 | sc->sc_shadowfb = kmem_alloc(sc->sc_fbsize, KM_SLEEP); | | 260 | sc->sc_shadowfb = kmem_alloc(sc->sc_fbsize, KM_SLEEP); |
262 | if (sc->sc_want_clear == false) | | 261 | if (sc->sc_want_clear == false) |
263 | memcpy(sc->sc_shadowfb, sc->sc_fbaddr, sc->sc_fbsize); | | 262 | memcpy(sc->sc_shadowfb, sc->sc_fbaddr, sc->sc_fbsize); |
264 | aprint_verbose_dev(sc->sc_dev, | | 263 | aprint_verbose_dev(sc->sc_dev, |
265 | "shadow framebuffer enabled, size %zu KB\n", | | 264 | "shadow framebuffer enabled, size %zu KB\n", |
266 | sc->sc_fbsize >> 10); | | 265 | sc->sc_fbsize >> 10); |
267 | } | | 266 | } |
268 | | | 267 | |
269 | vcons_init(&sc->vd, sc, &sc->sc_defaultscreen_descr, | | 268 | vcons_init(&sc->vd, sc, &sc->sc_defaultscreen_descr, |
270 | &sc->sc_accessops); | | 269 | &sc->sc_accessops); |
271 | sc->vd.init_screen = genfb_init_screen; | | 270 | sc->vd.init_screen = genfb_init_screen; |
272 | | | 271 | |
273 | /* Do not print anything between this point and the screen | | 272 | /* Do not print anything between this point and the screen |
274 | * clear operation below. Otherwise it will be lost. */ | | 273 | * clear operation below. Otherwise it will be lost. */ |
275 | | | 274 | |
276 | ri = &sc->sc_console_screen.scr_ri; | | 275 | ri = &sc->sc_console_screen.scr_ri; |
277 | | | 276 | |
278 | vcons_init_screen(&sc->vd, &sc->sc_console_screen, 1, | | 277 | vcons_init_screen(&sc->vd, &sc->sc_console_screen, 1, |
279 | &defattr); | | 278 | &defattr); |
280 | sc->sc_console_screen.scr_flags |= VCONS_SCREEN_IS_STATIC; | | 279 | sc->sc_console_screen.scr_flags |= VCONS_SCREEN_IS_STATIC; |
281 | | | 280 | |
282 | #ifdef SPLASHSCREEN | | 281 | #ifdef SPLASHSCREEN |
283 | /* | | 282 | /* |
284 | * If system isn't going to go multiuser, or user has requested to see | | 283 | * If system isn't going to go multiuser, or user has requested to see |
285 | * boot text, don't render splash screen immediately | | 284 | * boot text, don't render splash screen immediately |
286 | */ | | 285 | */ |
287 | if (DISABLESPLASH) | | 286 | if (DISABLESPLASH) |
288 | #endif | | 287 | #endif |
289 | vcons_redraw_screen(&sc->sc_console_screen); | | 288 | vcons_redraw_screen(&sc->sc_console_screen); |
290 | | | 289 | |
291 | sc->sc_defaultscreen_descr.textops = &ri->ri_ops; | | 290 | sc->sc_defaultscreen_descr.textops = &ri->ri_ops; |
292 | sc->sc_defaultscreen_descr.capabilities = ri->ri_caps; | | 291 | sc->sc_defaultscreen_descr.capabilities = ri->ri_caps; |
293 | sc->sc_defaultscreen_descr.nrows = ri->ri_rows; | | 292 | sc->sc_defaultscreen_descr.nrows = ri->ri_rows; |
294 | sc->sc_defaultscreen_descr.ncols = ri->ri_cols; | | 293 | sc->sc_defaultscreen_descr.ncols = ri->ri_cols; |
295 | | | 294 | |
296 | if (crow >= ri->ri_rows) { | | 295 | if (crow >= ri->ri_rows) { |
297 | crow = 0; | | 296 | crow = 0; |
298 | sc->sc_want_clear = 1; | | 297 | sc->sc_want_clear = 1; |
299 | } | | 298 | } |
300 | | | 299 | |
301 | if (console) | | 300 | if (console) |
302 | wsdisplay_cnattach(&sc->sc_defaultscreen_descr, ri, 0, crow, | | 301 | wsdisplay_cnattach(&sc->sc_defaultscreen_descr, ri, 0, crow, |
303 | defattr); | | 302 | defattr); |
304 | | | 303 | |
305 | /* Clear the whole screen to bring it to a known state. */ | | 304 | /* Clear the whole screen to bring it to a known state. */ |
306 | if (sc->sc_want_clear) | | 305 | if (sc->sc_want_clear) |
307 | (*ri->ri_ops.eraserows)(ri, 0, ri->ri_rows, defattr); | | 306 | (*ri->ri_ops.eraserows)(ri, 0, ri->ri_rows, defattr); |
308 | | | 307 | |
309 | #ifdef SPLASHSCREEN | | 308 | #ifdef SPLASHSCREEN |
310 | j = 0; | | 309 | j = 0; |
311 | for (i = 0; i < uimin(1 << sc->sc_depth, 256); i++) { | | 310 | for (i = 0; i < uimin(1 << sc->sc_depth, 256); i++) { |
312 | if (i >= SPLASH_CMAP_OFFSET && | | 311 | if (i >= SPLASH_CMAP_OFFSET && |
313 | i < SPLASH_CMAP_OFFSET + SPLASH_CMAP_SIZE) { | | 312 | i < SPLASH_CMAP_OFFSET + SPLASH_CMAP_SIZE) { |
314 | splash_get_cmap(i, | | 313 | splash_get_cmap(i, |
315 | &sc->sc_cmap_red[i], | | 314 | &sc->sc_cmap_red[i], |
316 | &sc->sc_cmap_green[i], | | 315 | &sc->sc_cmap_green[i], |
317 | &sc->sc_cmap_blue[i]); | | 316 | &sc->sc_cmap_blue[i]); |
318 | } else { | | 317 | } else { |
319 | sc->sc_cmap_red[i] = rasops_cmap[j]; | | 318 | sc->sc_cmap_red[i] = rasops_cmap[j]; |
320 | sc->sc_cmap_green[i] = rasops_cmap[j + 1]; | | 319 | sc->sc_cmap_green[i] = rasops_cmap[j + 1]; |
321 | sc->sc_cmap_blue[i] = rasops_cmap[j + 2]; | | 320 | sc->sc_cmap_blue[i] = rasops_cmap[j + 2]; |
322 | } | | 321 | } |
323 | j += 3; | | 322 | j += 3; |
324 | } | | 323 | } |
325 | genfb_restore_palette(sc); | | 324 | genfb_restore_palette(sc); |
326 | | | 325 | |
327 | sc->sc_splash.si_depth = sc->sc_depth; | | 326 | sc->sc_splash.si_depth = sc->sc_depth; |
328 | sc->sc_splash.si_bits = sc->sc_console_screen.scr_ri.ri_origbits; | | 327 | sc->sc_splash.si_bits = sc->sc_console_screen.scr_ri.ri_origbits; |
329 | sc->sc_splash.si_hwbits = sc->sc_fbaddr; | | 328 | sc->sc_splash.si_hwbits = sc->sc_fbaddr; |
330 | sc->sc_splash.si_width = sc->sc_width; | | 329 | sc->sc_splash.si_width = sc->sc_width; |
331 | sc->sc_splash.si_height = sc->sc_height; | | 330 | sc->sc_splash.si_height = sc->sc_height; |
332 | sc->sc_splash.si_stride = sc->sc_stride; | | 331 | sc->sc_splash.si_stride = sc->sc_stride; |
333 | sc->sc_splash.si_fillrect = NULL; | | 332 | sc->sc_splash.si_fillrect = NULL; |
334 | if (!DISABLESPLASH) { | | 333 | if (!DISABLESPLASH) { |
335 | error = splash_render(&sc->sc_splash, | | 334 | error = splash_render(&sc->sc_splash, |
336 | SPLASH_F_CENTER|SPLASH_F_FILL); | | 335 | SPLASH_F_CENTER|SPLASH_F_FILL); |
337 | if (error) { | | 336 | if (error) { |
338 | SCREEN_ENABLE_DRAWING(&sc->sc_console_screen); | | 337 | SCREEN_ENABLE_DRAWING(&sc->sc_console_screen); |
339 | genfb_init_palette(sc); | | 338 | genfb_init_palette(sc); |
340 | vcons_replay_msgbuf(&sc->sc_console_screen); | | 339 | vcons_replay_msgbuf(&sc->sc_console_screen); |
341 | } | | 340 | } |
342 | } | | 341 | } |
343 | #else | | 342 | #else |
344 | genfb_init_palette(sc); | | 343 | genfb_init_palette(sc); |
345 | if (console) | | 344 | if (console) |
346 | vcons_replay_msgbuf(&sc->sc_console_screen); | | 345 | vcons_replay_msgbuf(&sc->sc_console_screen); |
347 | #endif | | 346 | #endif |
348 | | | 347 | |
349 | if (genfb_softc == NULL) | | 348 | if (genfb_softc == NULL) |
350 | genfb_softc = sc; | | 349 | genfb_softc = sc; |
351 | | | 350 | |
352 | aa.console = console; | | 351 | aa.console = console; |
353 | aa.scrdata = &sc->sc_screenlist; | | 352 | aa.scrdata = &sc->sc_screenlist; |
354 | aa.accessops = &sc->sc_accessops; | | 353 | aa.accessops = &sc->sc_accessops; |
355 | aa.accesscookie = &sc->vd; | | 354 | aa.accesscookie = &sc->vd; |
356 | | | 355 | |
357 | #ifdef GENFB_DISABLE_TEXT | | 356 | #ifdef GENFB_DISABLE_TEXT |
358 | if (!DISABLESPLASH && error == 0) | | 357 | if (!DISABLESPLASH && error == 0) |
359 | SCREEN_DISABLE_DRAWING(&sc->sc_console_screen); | | 358 | SCREEN_DISABLE_DRAWING(&sc->sc_console_screen); |
360 | #endif | | 359 | #endif |
361 | | | 360 | |
362 | config_found_ia(sc->sc_dev, "wsemuldisplaydev", &aa, | | 361 | config_found_ia(sc->sc_dev, "wsemuldisplaydev", &aa, |
363 | wsemuldisplaydevprint); | | 362 | wsemuldisplaydevprint); |
364 | | | 363 | |
365 | return 0; | | 364 | return 0; |
366 | } | | 365 | } |
367 | | | 366 | |
368 | static int | | 367 | static int |
369 | genfb_ioctl(void *v, void *vs, u_long cmd, void *data, int flag, | | 368 | genfb_ioctl(void *v, void *vs, u_long cmd, void *data, int flag, |
370 | struct lwp *l) | | 369 | struct lwp *l) |
371 | { | | 370 | { |
372 | struct vcons_data *vd = v; | | 371 | struct vcons_data *vd = v; |
373 | struct genfb_softc *sc = vd->cookie; | | 372 | struct genfb_softc *sc = vd->cookie; |
374 | struct wsdisplay_fbinfo *wdf; | | 373 | struct wsdisplay_fbinfo *wdf; |
375 | struct vcons_screen *ms = vd->active; | | 374 | struct vcons_screen *ms = vd->active; |
376 | struct wsdisplay_param *param; | | 375 | struct wsdisplay_param *param; |
377 | int new_mode, error, val, ret; | | 376 | int new_mode, error, val, ret; |
378 | | | 377 | |
379 | switch (cmd) { | | 378 | switch (cmd) { |
380 | case WSDISPLAYIO_GINFO: | | 379 | case WSDISPLAYIO_GINFO: |
381 | if (ms == NULL) | | 380 | if (ms == NULL) |
382 | return ENODEV; | | 381 | return ENODEV; |
383 | wdf = (void *)data; | | 382 | wdf = (void *)data; |
384 | wdf->height = ms->scr_ri.ri_height; | | 383 | wdf->height = ms->scr_ri.ri_height; |
385 | wdf->width = ms->scr_ri.ri_width; | | 384 | wdf->width = ms->scr_ri.ri_width; |
386 | wdf->depth = ms->scr_ri.ri_depth; | | 385 | wdf->depth = ms->scr_ri.ri_depth; |
387 | wdf->cmsize = 256; | | 386 | wdf->cmsize = 256; |
388 | return 0; | | 387 | return 0; |
389 | | | 388 | |
390 | case WSDISPLAYIO_GETCMAP: | | 389 | case WSDISPLAYIO_GETCMAP: |
391 | return genfb_getcmap(sc, | | 390 | return genfb_getcmap(sc, |
392 | (struct wsdisplay_cmap *)data); | | 391 | (struct wsdisplay_cmap *)data); |
393 | | | 392 | |
394 | case WSDISPLAYIO_PUTCMAP: | | 393 | case WSDISPLAYIO_PUTCMAP: |
395 | return genfb_putcmap(sc, | | 394 | return genfb_putcmap(sc, |
396 | (struct wsdisplay_cmap *)data); | | 395 | (struct wsdisplay_cmap *)data); |
397 | | | 396 | |
398 | case WSDISPLAYIO_LINEBYTES: | | 397 | case WSDISPLAYIO_LINEBYTES: |
399 | *(u_int *)data = sc->sc_stride; | | 398 | *(u_int *)data = sc->sc_stride; |
400 | return 0; | | 399 | return 0; |
401 | | | 400 | |
402 | case WSDISPLAYIO_SMODE: | | 401 | case WSDISPLAYIO_SMODE: |
403 | new_mode = *(int *)data; | | 402 | new_mode = *(int *)data; |
404 | | | 403 | |
405 | /* notify the bus backend */ | | 404 | /* notify the bus backend */ |
406 | error = 0; | | 405 | error = 0; |
407 | if (sc->sc_ops.genfb_ioctl) | | 406 | if (sc->sc_ops.genfb_ioctl) |
408 | error = sc->sc_ops.genfb_ioctl(sc, vs, | | 407 | error = sc->sc_ops.genfb_ioctl(sc, vs, |
409 | cmd, data, flag, l); | | 408 | cmd, data, flag, l); |
410 | if (error && error != EPASSTHROUGH) | | 409 | if (error && error != EPASSTHROUGH) |
411 | return error; | | 410 | return error; |
412 | | | 411 | |
413 | if (new_mode != sc->sc_mode) { | | 412 | if (new_mode != sc->sc_mode) { |
414 | sc->sc_mode = new_mode; | | 413 | sc->sc_mode = new_mode; |
415 | if (sc->sc_modecb != NULL) | | 414 | if (sc->sc_modecb != NULL) |
416 | sc->sc_modecb->gmc_setmode(sc, | | 415 | sc->sc_modecb->gmc_setmode(sc, |
417 | sc->sc_mode); | | 416 | sc->sc_mode); |
418 | if (new_mode == WSDISPLAYIO_MODE_EMUL) { | | 417 | if (new_mode == WSDISPLAYIO_MODE_EMUL) { |
419 | genfb_restore_palette(sc); | | 418 | genfb_restore_palette(sc); |
420 | vcons_redraw_screen(ms); | | 419 | vcons_redraw_screen(ms); |
421 | } | | 420 | } |
422 | } | | 421 | } |
423 | return 0; | | 422 | return 0; |
424 | | | 423 | |
425 | case WSDISPLAYIO_SSPLASH: | | 424 | case WSDISPLAYIO_SSPLASH: |
426 | #if defined(SPLASHSCREEN) | | 425 | #if defined(SPLASHSCREEN) |
427 | if(*(int *)data == 1) { | | 426 | if(*(int *)data == 1) { |
428 | SCREEN_DISABLE_DRAWING(&sc->sc_console_screen); | | 427 | SCREEN_DISABLE_DRAWING(&sc->sc_console_screen); |
429 | splash_render(&sc->sc_splash, | | 428 | splash_render(&sc->sc_splash, |
430 | SPLASH_F_CENTER|SPLASH_F_FILL); | | 429 | SPLASH_F_CENTER|SPLASH_F_FILL); |
431 | } else { | | 430 | } else { |
432 | SCREEN_ENABLE_DRAWING(&sc->sc_console_screen); | | 431 | SCREEN_ENABLE_DRAWING(&sc->sc_console_screen); |
433 | genfb_init_palette(sc); | | 432 | genfb_init_palette(sc); |
434 | } | | 433 | } |
435 | vcons_redraw_screen(ms); | | 434 | vcons_redraw_screen(ms); |
436 | return 0; | | 435 | return 0; |
437 | #else | | 436 | #else |
438 | return ENODEV; | | 437 | return ENODEV; |
439 | #endif | | 438 | #endif |
440 | case WSDISPLAYIO_GETPARAM: | | 439 | case WSDISPLAYIO_GETPARAM: |
441 | param = (struct wsdisplay_param *)data; | | 440 | param = (struct wsdisplay_param *)data; |
442 | switch (param->param) { | | 441 | switch (param->param) { |
443 | case WSDISPLAYIO_PARAM_BRIGHTNESS: | | 442 | case WSDISPLAYIO_PARAM_BRIGHTNESS: |
444 | if (sc->sc_brightness == NULL) | | 443 | if (sc->sc_brightness == NULL) |
445 | return EPASSTHROUGH; | | 444 | return EPASSTHROUGH; |
446 | param->min = 0; | | 445 | param->min = 0; |
447 | param->max = 255; | | 446 | param->max = 255; |
448 | return sc->sc_brightness->gpc_get_parameter( | | 447 | return sc->sc_brightness->gpc_get_parameter( |
449 | sc->sc_brightness->gpc_cookie, | | 448 | sc->sc_brightness->gpc_cookie, |
450 | ¶m->curval); | | 449 | ¶m->curval); |
451 | case WSDISPLAYIO_PARAM_BACKLIGHT: | | 450 | case WSDISPLAYIO_PARAM_BACKLIGHT: |
452 | if (sc->sc_backlight == NULL) | | 451 | if (sc->sc_backlight == NULL) |
453 | return EPASSTHROUGH; | | 452 | return EPASSTHROUGH; |
454 | param->min = 0; | | 453 | param->min = 0; |
455 | param->max = 1; | | 454 | param->max = 1; |
456 | return sc->sc_backlight->gpc_get_parameter( | | 455 | return sc->sc_backlight->gpc_get_parameter( |
457 | sc->sc_backlight->gpc_cookie, | | 456 | sc->sc_backlight->gpc_cookie, |
458 | ¶m->curval); | | 457 | ¶m->curval); |
459 | } | | 458 | } |
460 | return EPASSTHROUGH; | | 459 | return EPASSTHROUGH; |
461 | | | 460 | |
462 | case WSDISPLAYIO_SETPARAM: | | 461 | case WSDISPLAYIO_SETPARAM: |
463 | param = (struct wsdisplay_param *)data; | | 462 | param = (struct wsdisplay_param *)data; |
464 | switch (param->param) { | | 463 | switch (param->param) { |
465 | case WSDISPLAYIO_PARAM_BRIGHTNESS: | | 464 | case WSDISPLAYIO_PARAM_BRIGHTNESS: |
466 | if (sc->sc_brightness == NULL) | | 465 | if (sc->sc_brightness == NULL) |
467 | return EPASSTHROUGH; | | 466 | return EPASSTHROUGH; |
468 | val = param->curval; | | 467 | val = param->curval; |
469 | if (val < 0) val = 0; | | 468 | if (val < 0) val = 0; |
470 | if (val > 255) val = 255; | | 469 | if (val > 255) val = 255; |
471 | return sc->sc_brightness->gpc_set_parameter( | | 470 | return sc->sc_brightness->gpc_set_parameter( |
472 | sc->sc_brightness->gpc_cookie, val); | | 471 | sc->sc_brightness->gpc_cookie, val); |
473 | case WSDISPLAYIO_PARAM_BACKLIGHT: | | 472 | case WSDISPLAYIO_PARAM_BACKLIGHT: |
474 | if (sc->sc_backlight == NULL) | | 473 | if (sc->sc_backlight == NULL) |
475 | return EPASSTHROUGH; | | 474 | return EPASSTHROUGH; |
476 | val = param->curval; | | 475 | val = param->curval; |
477 | if (val < 0) val = 0; | | 476 | if (val < 0) val = 0; |
478 | if (val > 1) val = 1; | | 477 | if (val > 1) val = 1; |
479 | return sc->sc_backlight->gpc_set_parameter( | | 478 | return sc->sc_backlight->gpc_set_parameter( |
480 | sc->sc_backlight->gpc_cookie, val); | | 479 | sc->sc_backlight->gpc_cookie, val); |
481 | } | | 480 | } |
482 | return EPASSTHROUGH; | | 481 | return EPASSTHROUGH; |
483 | } | | 482 | } |
484 | ret = EPASSTHROUGH; | | 483 | ret = EPASSTHROUGH; |
485 | if (sc->sc_ops.genfb_ioctl) | | 484 | if (sc->sc_ops.genfb_ioctl) |
486 | ret = sc->sc_ops.genfb_ioctl(sc, vs, cmd, data, flag, l); | | 485 | ret = sc->sc_ops.genfb_ioctl(sc, vs, cmd, data, flag, l); |
487 | if (ret != EPASSTHROUGH) | | 486 | if (ret != EPASSTHROUGH) |
488 | return ret; | | 487 | return ret; |
489 | /* | | 488 | /* |
490 | * XXX | | 489 | * XXX |
491 | * handle these only if there either is no ioctl() handler or it didn't | | 490 | * handle these only if there either is no ioctl() handler or it didn't |
492 | * know how to deal with them. This allows bus frontends to override | | 491 | * know how to deal with them. This allows bus frontends to override |
493 | * them but still provides fallback implementations | | 492 | * them but still provides fallback implementations |
494 | */ | | 493 | */ |
495 | switch (cmd) { | | 494 | switch (cmd) { |
496 | case WSDISPLAYIO_GET_EDID: { | | 495 | case WSDISPLAYIO_GET_EDID: { |
497 | | | 496 | |
498 | struct wsdisplayio_edid_info *d = data; | | 497 | struct wsdisplayio_edid_info *d = data; |
499 | return wsdisplayio_get_edid(sc->sc_dev, d); | | 498 | return wsdisplayio_get_edid(sc->sc_dev, d); |
500 | } | | 499 | } |
501 | | | 500 | |
502 | case WSDISPLAYIO_GET_FBINFO: { | | 501 | case WSDISPLAYIO_GET_FBINFO: { |
503 | struct wsdisplayio_fbinfo *fbi = data; | | 502 | struct wsdisplayio_fbinfo *fbi = data; |
504 | return wsdisplayio_get_fbinfo(&ms->scr_ri, fbi); | | 503 | return wsdisplayio_get_fbinfo(&ms->scr_ri, fbi); |
505 | } | | 504 | } |
506 | } | | 505 | } |
507 | return EPASSTHROUGH; | | 506 | return EPASSTHROUGH; |
508 | } | | 507 | } |
509 | | | 508 | |
510 | static paddr_t | | 509 | static paddr_t |
511 | genfb_mmap(void *v, void *vs, off_t offset, int prot) | | 510 | genfb_mmap(void *v, void *vs, off_t offset, int prot) |
512 | { | | 511 | { |
513 | struct vcons_data *vd = v; | | 512 | struct vcons_data *vd = v; |
514 | struct genfb_softc *sc = vd->cookie; | | 513 | struct genfb_softc *sc = vd->cookie; |
515 | | | 514 | |
516 | if (sc->sc_ops.genfb_mmap) | | 515 | if (sc->sc_ops.genfb_mmap) |
517 | return sc->sc_ops.genfb_mmap(sc, vs, offset, prot); | | 516 | return sc->sc_ops.genfb_mmap(sc, vs, offset, prot); |
518 | | | 517 | |
519 | return -1; | | 518 | return -1; |
520 | } | | 519 | } |
521 | | | 520 | |
522 | static void | | 521 | static void |
523 | genfb_pollc(void *v, int on) | | 522 | genfb_pollc(void *v, int on) |
524 | { | | 523 | { |
525 | struct vcons_data *vd = v; | | 524 | struct vcons_data *vd = v; |
526 | struct genfb_softc *sc = vd->cookie; | | 525 | struct genfb_softc *sc = vd->cookie; |
527 | | | 526 | |
528 | if (sc == NULL) | | 527 | if (sc == NULL) |
529 | return; | | 528 | return; |
530 | | | 529 | |
531 | if (on) | | 530 | if (on) |
532 | genfb_enable_polling(sc->sc_dev); | | 531 | genfb_enable_polling(sc->sc_dev); |
533 | else | | 532 | else |
534 | genfb_disable_polling(sc->sc_dev); | | 533 | genfb_disable_polling(sc->sc_dev); |
535 | } | | 534 | } |
536 | | | 535 | |
537 | static void | | 536 | static void |
538 | genfb_init_screen(void *cookie, struct vcons_screen *scr, | | 537 | genfb_init_screen(void *cookie, struct vcons_screen *scr, |
539 | int existing, long *defattr) | | 538 | int existing, long *defattr) |
540 | { | | 539 | { |
541 | struct genfb_softc *sc = cookie; | | 540 | struct genfb_softc *sc = cookie; |
542 | struct rasops_info *ri = &scr->scr_ri; | | 541 | struct rasops_info *ri = &scr->scr_ri; |
543 | int wantcols; | | 542 | int wantcols; |
544 | bool is_bgr; | | 543 | bool is_bgr; |
545 | | | 544 | |
546 | ri->ri_depth = sc->sc_depth; | | 545 | ri->ri_depth = sc->sc_depth; |
547 | ri->ri_width = sc->sc_width; | | 546 | ri->ri_width = sc->sc_width; |
548 | ri->ri_height = sc->sc_height; | | 547 | ri->ri_height = sc->sc_height; |
549 | ri->ri_stride = sc->sc_stride; | | 548 | ri->ri_stride = sc->sc_stride; |
550 | ri->ri_flg = RI_CENTER; | | 549 | ri->ri_flg = RI_CENTER; |
551 | if (sc->sc_want_clear) | | 550 | if (sc->sc_want_clear) |
552 | ri->ri_flg |= RI_FULLCLEAR; | | 551 | ri->ri_flg |= RI_FULLCLEAR; |
553 | | | 552 | |
554 | scr->scr_flags |= VCONS_LOADFONT; | | 553 | scr->scr_flags |= VCONS_LOADFONT; |
555 | | | 554 | |
556 | if (sc->sc_shadowfb != NULL) { | | 555 | if (sc->sc_shadowfb != NULL) { |
557 | ri->ri_hwbits = (char *)sc->sc_fbaddr; | | 556 | ri->ri_hwbits = (char *)sc->sc_fbaddr; |
558 | ri->ri_bits = (char *)sc->sc_shadowfb; | | 557 | ri->ri_bits = (char *)sc->sc_shadowfb; |
559 | } else { | | 558 | } else { |
560 | ri->ri_bits = (char *)sc->sc_fbaddr; | | 559 | ri->ri_bits = (char *)sc->sc_fbaddr; |
561 | scr->scr_flags |= VCONS_DONT_READ; | | 560 | scr->scr_flags |= VCONS_DONT_READ; |
562 | } | | 561 | } |
563 | | | 562 | |
564 | if (existing && sc->sc_want_clear) | | 563 | if (existing && sc->sc_want_clear) |
565 | ri->ri_flg |= RI_CLEAR; | | 564 | ri->ri_flg |= RI_CLEAR; |
566 | | | 565 | |
567 | switch (ri->ri_depth) { | | 566 | switch (ri->ri_depth) { |
568 | case 32: | | 567 | case 32: |
569 | case 24: | | 568 | case 24: |
570 | ri->ri_flg |= RI_ENABLE_ALPHA; | | 569 | ri->ri_flg |= RI_ENABLE_ALPHA; |
571 | | | 570 | |
572 | is_bgr = false; | | 571 | is_bgr = false; |
573 | prop_dictionary_get_bool(device_properties(sc->sc_dev), | | 572 | prop_dictionary_get_bool(device_properties(sc->sc_dev), |
574 | "is_bgr", &is_bgr); | | 573 | "is_bgr", &is_bgr); |
575 | if (is_bgr) { | | 574 | if (is_bgr) { |
576 | /* someone requested BGR */ | | 575 | /* someone requested BGR */ |
577 | ri->ri_rnum = 8; | | 576 | ri->ri_rnum = 8; |
578 | ri->ri_gnum = 8; | | 577 | ri->ri_gnum = 8; |
579 | ri->ri_bnum = 8; | | 578 | ri->ri_bnum = 8; |
580 | ri->ri_rpos = 0; | | 579 | ri->ri_rpos = 0; |
581 | ri->ri_gpos = 8; | | 580 | ri->ri_gpos = 8; |
582 | ri->ri_bpos = 16; | | 581 | ri->ri_bpos = 16; |
583 | } else { | | 582 | } else { |
584 | /* assume RGB */ | | 583 | /* assume RGB */ |
585 | ri->ri_rnum = 8; | | 584 | ri->ri_rnum = 8; |
586 | ri->ri_gnum = 8; | | 585 | ri->ri_gnum = 8; |
587 | ri->ri_bnum = 8; | | 586 | ri->ri_bnum = 8; |
588 | ri->ri_rpos = 16; | | 587 | ri->ri_rpos = 16; |
589 | ri->ri_gpos = 8; | | 588 | ri->ri_gpos = 8; |
590 | ri->ri_bpos = 0; | | 589 | ri->ri_bpos = 0; |
591 | } | | 590 | } |
592 | break; | | 591 | break; |
593 | | | 592 | |
594 | case 16: | | 593 | case 16: |
595 | case 15: | | 594 | case 15: |
596 | ri->ri_flg |= RI_ENABLE_ALPHA; | | 595 | ri->ri_flg |= RI_ENABLE_ALPHA; |
597 | break; | | 596 | break; |
598 | | | 597 | |
599 | case 8: | | 598 | case 8: |
600 | if (sc->sc_cmcb != NULL) | | 599 | if (sc->sc_cmcb != NULL) |
601 | ri->ri_flg |= RI_ENABLE_ALPHA | RI_8BIT_IS_RGB; | | 600 | ri->ri_flg |= RI_ENABLE_ALPHA | RI_8BIT_IS_RGB; |
602 | break; | | 601 | break; |
603 | | | 602 | |
604 | case 2: | | 603 | case 2: |
605 | ri->ri_flg |= RI_ENABLE_ALPHA; | | 604 | ri->ri_flg |= RI_ENABLE_ALPHA; |
606 | break; | | 605 | break; |
607 | | | 606 | |
608 | default: | | 607 | default: |
609 | break; | | 608 | break; |
610 | } | | 609 | } |
611 | | | 610 | |
612 | wantcols = genfb_calc_cols(sc); | | 611 | wantcols = genfb_calc_cols(sc); |
613 | | | 612 | |
614 | rasops_init(ri, 0, wantcols); | | 613 | rasops_init(ri, 0, wantcols); |
615 | ri->ri_caps = WSSCREEN_WSCOLORS | WSSCREEN_HILIT | WSSCREEN_UNDERLINE | | | 614 | ri->ri_caps = WSSCREEN_WSCOLORS | WSSCREEN_HILIT | WSSCREEN_UNDERLINE | |
616 | WSSCREEN_RESIZE; | | 615 | WSSCREEN_RESIZE; |
617 | rasops_reconfig(ri, sc->sc_height / ri->ri_font->fontheight, | | 616 | rasops_reconfig(ri, sc->sc_height / ri->ri_font->fontheight, |
618 | sc->sc_width / ri->ri_font->fontwidth); | | 617 | sc->sc_width / ri->ri_font->fontwidth); |
619 | | | 618 | |
620 | /* TODO: actually center output */ | | 619 | /* TODO: actually center output */ |
621 | ri->ri_hw = scr; | | 620 | ri->ri_hw = scr; |
622 | | | 621 | |
623 | #ifdef GENFB_DISABLE_TEXT | | 622 | #ifdef GENFB_DISABLE_TEXT |
624 | if (scr == &sc->sc_console_screen && !DISABLESPLASH) | | 623 | if (scr == &sc->sc_console_screen && !DISABLESPLASH) |
625 | SCREEN_DISABLE_DRAWING(&sc->sc_console_screen); | | 624 | SCREEN_DISABLE_DRAWING(&sc->sc_console_screen); |
626 | #endif | | 625 | #endif |
627 | } | | 626 | } |
628 | | | 627 | |
629 | /* Returns the width of the display in millimeters, or 0 if not known. */ | | 628 | /* Returns the width of the display in millimeters, or 0 if not known. */ |
630 | static int | | 629 | static int |
631 | genfb_calc_hsize(struct genfb_softc *sc) | | 630 | genfb_calc_hsize(struct genfb_softc *sc) |
632 | { | | 631 | { |
633 | device_t dev = sc->sc_dev; | | 632 | device_t dev = sc->sc_dev; |
634 | prop_dictionary_t dict = device_properties(dev); | | 633 | prop_dictionary_t dict = device_properties(dev); |
635 | prop_data_t edid_data; | | 634 | prop_data_t edid_data; |
636 | struct edid_info edid; | | 635 | struct edid_info edid; |
637 | const char *edid_ptr; | | 636 | const char *edid_ptr; |
638 | | | 637 | |
639 | edid_data = prop_dictionary_get(dict, "EDID"); | | 638 | edid_data = prop_dictionary_get(dict, "EDID"); |
640 | if (edid_data == NULL || prop_data_size(edid_data) < 128) | | 639 | if (edid_data == NULL || prop_data_size(edid_data) < 128) |
641 | return 0; | | 640 | return 0; |
642 | | | 641 | |
643 | edid_ptr = prop_data_data_nocopy(edid_data); | | 642 | edid_ptr = prop_data_data_nocopy(edid_data); |
644 | if (edid_parse(__UNCONST(edid_ptr), &edid) != 0) | | 643 | if (edid_parse(__UNCONST(edid_ptr), &edid) != 0) |
645 | return 0; | | 644 | return 0; |
646 | | | 645 | |
647 | return (int)edid.edid_max_hsize * 10; | | 646 | return (int)edid.edid_max_hsize * 10; |
648 | } | | 647 | } |
649 | | | 648 | |
650 | /* Return the minimum number of character columns based on DPI */ | | 649 | /* Return the minimum number of character columns based on DPI */ |
651 | static int | | 650 | static int |
652 | genfb_calc_cols(struct genfb_softc *sc) | | 651 | genfb_calc_cols(struct genfb_softc *sc) |
653 | { | | 652 | { |
654 | const int hsize = genfb_calc_hsize(sc); | | 653 | const int hsize = genfb_calc_hsize(sc); |
655 | | | 654 | |
656 | return MAX(RASOPS_DEFAULT_WIDTH, hsize / GENFB_CHAR_WIDTH_MM); | | 655 | return MAX(RASOPS_DEFAULT_WIDTH, hsize / GENFB_CHAR_WIDTH_MM); |
657 | } | | 656 | } |
658 | | | 657 | |
659 | static int | | 658 | static int |
660 | genfb_putcmap(struct genfb_softc *sc, struct wsdisplay_cmap *cm) | | 659 | genfb_putcmap(struct genfb_softc *sc, struct wsdisplay_cmap *cm) |
661 | { | | 660 | { |
662 | u_char *r, *g, *b; | | 661 | u_char *r, *g, *b; |
663 | u_int index = cm->index; | | 662 | u_int index = cm->index; |
664 | u_int count = cm->count; | | 663 | u_int count = cm->count; |
665 | int i, error; | | 664 | int i, error; |
666 | u_char rbuf[256], gbuf[256], bbuf[256]; | | 665 | u_char rbuf[256], gbuf[256], bbuf[256]; |
667 | | | 666 | |
668 | #ifdef GENFB_DEBUG | | 667 | #ifdef GENFB_DEBUG |
669 | aprint_debug("putcmap: %d %d\n",index, count); | | 668 | aprint_debug("putcmap: %d %d\n",index, count); |
670 | #endif | | 669 | #endif |
671 | if (index >= 256 || count > 256 || index + count > 256) | | 670 | if (index >= 256 || count > 256 || index + count > 256) |
672 | return EINVAL; | | 671 | return EINVAL; |
673 | | | 672 | |
674 | error = copyin(cm->red, &rbuf[index], count); | | 673 | error = copyin(cm->red, &rbuf[index], count); |
675 | if (error) | | 674 | if (error) |
676 | return error; | | 675 | return error; |
677 | error = copyin(cm->green, &gbuf[index], count); | | 676 | error = copyin(cm->green, &gbuf[index], count); |
678 | if (error) | | 677 | if (error) |
679 | return error; | | 678 | return error; |
680 | error = copyin(cm->blue, &bbuf[index], count); | | 679 | error = copyin(cm->blue, &bbuf[index], count); |
681 | if (error) | | 680 | if (error) |
682 | return error; | | 681 | return error; |
683 | | | 682 | |
684 | memcpy(&sc->sc_cmap_red[index], &rbuf[index], count); | | 683 | memcpy(&sc->sc_cmap_red[index], &rbuf[index], count); |
685 | memcpy(&sc->sc_cmap_green[index], &gbuf[index], count); | | 684 | memcpy(&sc->sc_cmap_green[index], &gbuf[index], count); |
686 | memcpy(&sc->sc_cmap_blue[index], &bbuf[index], count); | | 685 | memcpy(&sc->sc_cmap_blue[index], &bbuf[index], count); |
687 | | | 686 | |
688 | r = &sc->sc_cmap_red[index]; | | 687 | r = &sc->sc_cmap_red[index]; |
689 | g = &sc->sc_cmap_green[index]; | | 688 | g = &sc->sc_cmap_green[index]; |
690 | b = &sc->sc_cmap_blue[index]; | | 689 | b = &sc->sc_cmap_blue[index]; |
691 | | | 690 | |
692 | for (i = 0; i < count; i++) { | | 691 | for (i = 0; i < count; i++) { |
693 | genfb_putpalreg(sc, index, *r, *g, *b); | | 692 | genfb_putpalreg(sc, index, *r, *g, *b); |
694 | index++; | | 693 | index++; |
695 | r++, g++, b++; | | 694 | r++, g++, b++; |
696 | } | | 695 | } |
697 | return 0; | | 696 | return 0; |
698 | } | | 697 | } |
699 | | | 698 | |
700 | static int | | 699 | static int |
701 | genfb_getcmap(struct genfb_softc *sc, struct wsdisplay_cmap *cm) | | 700 | genfb_getcmap(struct genfb_softc *sc, struct wsdisplay_cmap *cm) |
702 | { | | 701 | { |
703 | u_int index = cm->index; | | 702 | u_int index = cm->index; |
704 | u_int count = cm->count; | | 703 | u_int count = cm->count; |
705 | int error; | | 704 | int error; |
706 | | | 705 | |
707 | if (index >= 256 || count > 256 || index + count > 256) | | 706 | if (index >= 256 || count > 256 || index + count > 256) |
708 | return EINVAL; | | 707 | return EINVAL; |
709 | | | 708 | |
710 | error = copyout(&sc->sc_cmap_red[index], cm->red, count); | | 709 | error = copyout(&sc->sc_cmap_red[index], cm->red, count); |
711 | if (error) | | 710 | if (error) |
712 | return error; | | 711 | return error; |
713 | error = copyout(&sc->sc_cmap_green[index], cm->green, count); | | 712 | error = copyout(&sc->sc_cmap_green[index], cm->green, count); |
714 | if (error) | | 713 | if (error) |
715 | return error; | | 714 | return error; |
716 | error = copyout(&sc->sc_cmap_blue[index], cm->blue, count); | | 715 | error = copyout(&sc->sc_cmap_blue[index], cm->blue, count); |
717 | if (error) | | 716 | if (error) |
718 | return error; | | 717 | return error; |
719 | | | 718 | |
720 | return 0; | | 719 | return 0; |
721 | } | | 720 | } |
722 | | | 721 | |
723 | void | | 722 | void |
724 | genfb_restore_palette(struct genfb_softc *sc) | | 723 | genfb_restore_palette(struct genfb_softc *sc) |
725 | { | | 724 | { |
726 | int i; | | 725 | int i; |
727 | | | 726 | |
728 | if (sc->sc_depth <= 8) { | | 727 | if (sc->sc_depth <= 8) { |
729 | for (i = 0; i < (1 << sc->sc_depth); i++) { | | 728 | for (i = 0; i < (1 << sc->sc_depth); i++) { |
730 | genfb_putpalreg(sc, i, sc->sc_cmap_red[i], | | 729 | genfb_putpalreg(sc, i, sc->sc_cmap_red[i], |
731 | sc->sc_cmap_green[i], sc->sc_cmap_blue[i]); | | 730 | sc->sc_cmap_green[i], sc->sc_cmap_blue[i]); |
732 | } | | 731 | } |
733 | } | | 732 | } |
734 | } | | 733 | } |
735 | | | 734 | |
736 | static void | | 735 | static void |
737 | genfb_init_palette(struct genfb_softc *sc) | | 736 | genfb_init_palette(struct genfb_softc *sc) |
738 | { | | 737 | { |
739 | int i, j, tmp; | | 738 | int i, j, tmp; |
740 | | | 739 | |
741 | if (sc->sc_depth == 8) { | | 740 | if (sc->sc_depth == 8) { |
742 | /* generate an r3g3b2 colour map */ | | 741 | /* generate an r3g3b2 colour map */ |
743 | for (i = 0; i < 256; i++) { | | 742 | for (i = 0; i < 256; i++) { |
744 | tmp = i & 0xe0; | | 743 | tmp = i & 0xe0; |
745 | /* | | 744 | /* |
746 | * replicate bits so 0xe0 maps to a red value of 0xff | | 745 | * replicate bits so 0xe0 maps to a red value of 0xff |
747 | * in order to make white look actually white | | 746 | * in order to make white look actually white |
748 | */ | | 747 | */ |
749 | tmp |= (tmp >> 3) | (tmp >> 6); | | 748 | tmp |= (tmp >> 3) | (tmp >> 6); |
750 | sc->sc_cmap_red[i] = tmp; | | 749 | sc->sc_cmap_red[i] = tmp; |
751 | | | 750 | |
752 | tmp = (i & 0x1c) << 3; | | 751 | tmp = (i & 0x1c) << 3; |
753 | tmp |= (tmp >> 3) | (tmp >> 6); | | 752 | tmp |= (tmp >> 3) | (tmp >> 6); |
754 | sc->sc_cmap_green[i] = tmp; | | 753 | sc->sc_cmap_green[i] = tmp; |
755 | | | 754 | |
756 | tmp = (i & 0x03) << 6; | | 755 | tmp = (i & 0x03) << 6; |
757 | tmp |= tmp >> 2; | | 756 | tmp |= tmp >> 2; |
758 | tmp |= tmp >> 4; | | 757 | tmp |= tmp >> 4; |
759 | sc->sc_cmap_blue[i] = tmp; | | 758 | sc->sc_cmap_blue[i] = tmp; |
760 | | | 759 | |
761 | genfb_putpalreg(sc, i, sc->sc_cmap_red[i], | | 760 | genfb_putpalreg(sc, i, sc->sc_cmap_red[i], |
762 | sc->sc_cmap_green[i], | | 761 | sc->sc_cmap_green[i], |
763 | sc->sc_cmap_blue[i]); | | 762 | sc->sc_cmap_blue[i]); |
764 | } | | 763 | } |
765 | } else { | | 764 | } else { |
766 | /* steal rasops' ANSI cmap */ | | 765 | /* steal rasops' ANSI cmap */ |
767 | j = 0; | | 766 | j = 0; |
768 | for (i = 0; i < 256; i++) { | | 767 | for (i = 0; i < 256; i++) { |
769 | sc->sc_cmap_red[i] = rasops_cmap[j]; | | 768 | sc->sc_cmap_red[i] = rasops_cmap[j]; |
770 | sc->sc_cmap_green[i] = rasops_cmap[j + 1]; | | 769 | sc->sc_cmap_green[i] = rasops_cmap[j + 1]; |
771 | sc->sc_cmap_blue[i] = rasops_cmap[j + 2]; | | 770 | sc->sc_cmap_blue[i] = rasops_cmap[j + 2]; |
772 | j += 3; | | 771 | j += 3; |
773 | } | | 772 | } |
774 | } | | 773 | } |
775 | } | | 774 | } |
776 | | | 775 | |
777 | static int | | 776 | static int |
778 | genfb_putpalreg(struct genfb_softc *sc, uint8_t idx, uint8_t r, uint8_t g, | | 777 | genfb_putpalreg(struct genfb_softc *sc, uint8_t idx, uint8_t r, uint8_t g, |
779 | uint8_t b) | | 778 | uint8_t b) |
780 | { | | 779 | { |
781 | | | 780 | |
782 | if (sc->sc_cmcb) { | | 781 | if (sc->sc_cmcb) { |
783 | | | 782 | |
784 | sc->sc_cmcb->gcc_set_mapreg(sc->sc_cmcb->gcc_cookie, | | 783 | sc->sc_cmcb->gcc_set_mapreg(sc->sc_cmcb->gcc_cookie, |
785 | idx, r, g, b); | | 784 | idx, r, g, b); |
786 | } | | 785 | } |
787 | return 0; | | 786 | return 0; |
788 | } | | 787 | } |
789 | | | 788 | |
790 | void | | 789 | void |
791 | genfb_cnattach(void) | | 790 | genfb_cnattach(void) |
792 | { | | 791 | { |
793 | genfb_cnattach_called = 1; | | 792 | genfb_cnattach_called = 1; |
794 | } | | 793 | } |
795 | | | 794 | |
796 | void | | 795 | void |
797 | genfb_disable(void) | | 796 | genfb_disable(void) |
798 | { | | 797 | { |
799 | genfb_enabled = 0; | | 798 | genfb_enabled = 0; |
800 | } | | 799 | } |
801 | | | 800 | |
802 | int | | 801 | int |
803 | genfb_is_console(void) | | 802 | genfb_is_console(void) |
804 | { | | 803 | { |
805 | return genfb_cnattach_called; | | 804 | return genfb_cnattach_called; |
806 | } | | 805 | } |
807 | | | 806 | |
808 | int | | 807 | int |
809 | genfb_is_enabled(void) | | 808 | genfb_is_enabled(void) |
810 | { | | 809 | { |
811 | return genfb_enabled; | | 810 | return genfb_enabled; |
812 | } | | 811 | } |
813 | | | 812 | |
814 | int | | 813 | int |
815 | genfb_borrow(bus_addr_t addr, bus_space_handle_t *hdlp) | | 814 | genfb_borrow(bus_addr_t addr, bus_space_handle_t *hdlp) |
816 | { | | 815 | { |
817 | struct genfb_softc *sc = genfb_softc; | | 816 | struct genfb_softc *sc = genfb_softc; |
818 | | | 817 | |
819 | if (sc && sc->sc_ops.genfb_borrow) | | 818 | if (sc && sc->sc_ops.genfb_borrow) |
820 | return sc->sc_ops.genfb_borrow(sc, addr, hdlp); | | 819 | return sc->sc_ops.genfb_borrow(sc, addr, hdlp); |
821 | return 0; | | 820 | return 0; |
822 | } | | 821 | } |
823 | | | 822 | |
824 | static void | | 823 | static void |
825 | genfb_brightness_up(device_t dev) | | 824 | genfb_brightness_up(device_t dev) |
826 | { | | 825 | { |
827 | struct genfb_softc *sc = device_private(dev); | | 826 | struct genfb_softc *sc = device_private(dev); |
828 | | | 827 | |
829 | KASSERT(sc->sc_brightness != NULL && | | 828 | KASSERT(sc->sc_brightness != NULL && |
830 | sc->sc_brightness->gpc_upd_parameter != NULL); | | 829 | sc->sc_brightness->gpc_upd_parameter != NULL); |
831 | | | 830 | |
832 | (void)sc->sc_brightness->gpc_upd_parameter( | | 831 | (void)sc->sc_brightness->gpc_upd_parameter( |
833 | sc->sc_brightness->gpc_cookie, GENFB_BRIGHTNESS_STEP); | | 832 | sc->sc_brightness->gpc_cookie, GENFB_BRIGHTNESS_STEP); |
834 | } | | 833 | } |
835 | | | 834 | |
836 | static void | | 835 | static void |
837 | genfb_brightness_down(device_t dev) | | 836 | genfb_brightness_down(device_t dev) |
838 | { | | 837 | { |
839 | struct genfb_softc *sc = device_private(dev); | | 838 | struct genfb_softc *sc = device_private(dev); |
840 | | | 839 | |
841 | KASSERT(sc->sc_brightness != NULL && | | 840 | KASSERT(sc->sc_brightness != NULL && |
842 | sc->sc_brightness->gpc_upd_parameter != NULL); | | 841 | sc->sc_brightness->gpc_upd_parameter != NULL); |
843 | | | 842 | |
844 | (void)sc->sc_brightness->gpc_upd_parameter( | | 843 | (void)sc->sc_brightness->gpc_upd_parameter( |
845 | sc->sc_brightness->gpc_cookie, - GENFB_BRIGHTNESS_STEP); | | 844 | sc->sc_brightness->gpc_cookie, - GENFB_BRIGHTNESS_STEP); |
846 | } | | 845 | } |
847 | | | 846 | |
848 | void | | 847 | void |
849 | genfb_enable_polling(device_t dev) | | 848 | genfb_enable_polling(device_t dev) |
850 | { | | 849 | { |
851 | struct genfb_softc *sc = device_private(dev); | | 850 | struct genfb_softc *sc = device_private(dev); |
852 | | | 851 | |
853 | if (sc->sc_console_screen.scr_vd) { | | 852 | if (sc->sc_console_screen.scr_vd) { |
854 | SCREEN_ENABLE_DRAWING(&sc->sc_console_screen); | | 853 | SCREEN_ENABLE_DRAWING(&sc->sc_console_screen); |
855 | vcons_hard_switch(&sc->sc_console_screen); | | 854 | vcons_hard_switch(&sc->sc_console_screen); |
856 | vcons_enable_polling(&sc->vd); | | 855 | vcons_enable_polling(&sc->vd); |
857 | if (sc->sc_ops.genfb_enable_polling) | | 856 | if (sc->sc_ops.genfb_enable_polling) |
858 | (*sc->sc_ops.genfb_enable_polling)(sc); | | 857 | (*sc->sc_ops.genfb_enable_polling)(sc); |
859 | } | | 858 | } |
860 | } | | 859 | } |
861 | | | 860 | |
862 | void | | 861 | void |
863 | genfb_disable_polling(device_t dev) | | 862 | genfb_disable_polling(device_t dev) |
864 | { | | 863 | { |
865 | struct genfb_softc *sc = device_private(dev); | | 864 | struct genfb_softc *sc = device_private(dev); |
866 | | | 865 | |
867 | if (sc->sc_console_screen.scr_vd) { | | 866 | if (sc->sc_console_screen.scr_vd) { |
868 | if (sc->sc_ops.genfb_disable_polling) | | 867 | if (sc->sc_ops.genfb_disable_polling) |
869 | (*sc->sc_ops.genfb_disable_polling)(sc); | | 868 | (*sc->sc_ops.genfb_disable_polling)(sc); |
870 | vcons_disable_polling(&sc->vd); | | 869 | vcons_disable_polling(&sc->vd); |
871 | } | | 870 | } |
872 | } | | 871 | } |