ite8181.c revision 1.8 1 1.8 sato /* $NetBSD: ite8181.c,v 1.8 2001/02/27 08:54:18 sato Exp $ */
2 1.1 sato
3 1.1 sato /*-
4 1.8 sato * Copyright (c) 2000,2001 SATO Kazumi
5 1.1 sato * All rights reserved.
6 1.1 sato *
7 1.1 sato * Redistribution and use in source and binary forms, with or without
8 1.1 sato * modification, are permitted provided that the following conditions
9 1.1 sato * are met:
10 1.1 sato * 1. Redistributions of source code must retain the above copyright
11 1.1 sato * notice, this list of conditions and the following disclaimer.
12 1.1 sato * 2. Redistributions in binary form must reproduce the above copyright
13 1.1 sato * notice, this list of conditions and the following disclaimer in the
14 1.1 sato * documentation and/or other materials provided with the distribution.
15 1.1 sato *
16 1.1 sato * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
17 1.1 sato * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 1.1 sato * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 1.1 sato * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
20 1.1 sato * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 1.1 sato * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 1.1 sato * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 1.1 sato * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 1.1 sato * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 1.1 sato * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 1.1 sato * SUCH DAMAGE.
27 1.1 sato *
28 1.1 sato */
29 1.1 sato
30 1.1 sato #include <sys/param.h>
31 1.1 sato #include <sys/kernel.h>
32 1.1 sato #include <sys/device.h>
33 1.1 sato #include <sys/systm.h>
34 1.1 sato #include <sys/boot_flag.h>
35 1.2 sato #include <sys/buf.h>
36 1.1 sato
37 1.1 sato #include <uvm/uvm_extern.h>
38 1.1 sato
39 1.1 sato #include <dev/wscons/wsconsio.h>
40 1.1 sato
41 1.1 sato #include <machine/bootinfo.h>
42 1.1 sato #include <machine/bus.h>
43 1.1 sato #include <machine/autoconf.h>
44 1.1 sato #include <machine/config_hook.h>
45 1.1 sato #include <machine/platid.h>
46 1.1 sato #include <machine/platid_mask.h>
47 1.1 sato
48 1.1 sato #include <hpcmips/dev/ite8181reg.h>
49 1.1 sato #include <hpcmips/dev/ite8181var.h>
50 1.1 sato #include "bivideo.h"
51 1.1 sato #if NBIVIDEO > 0
52 1.7 uch #include <dev/hpc/bivideovar.h>
53 1.1 sato #endif
54 1.7 uch #include <dev/hpc/hpccmapvar.h>
55 1.1 sato
56 1.1 sato #define ITE8181DEBUG
57 1.1 sato #ifdef ITE8181DEBUG
58 1.1 sato #ifndef ITE8181DEBUG_CONF
59 1.1 sato #define ITE8181DEBUG_CONF 0
60 1.1 sato #endif
61 1.1 sato int ite8181_debug = ITE8181DEBUG_CONF;
62 1.1 sato #define DPRINTF(arg) if (ite8181_debug) printf arg
63 1.1 sato #define DPRINTFN(n, arg) if (ite8181_debug > (n)) printf arg
64 1.1 sato #define VPRINTF(arg) if (bootverbose || ite8181_debug) printf arg
65 1.1 sato #define VPRINTFN(n, arg) if (bootverbose || ite8181_debug > (n)) printf arg
66 1.1 sato #else
67 1.1 sato #define DPRINTF(arg)
68 1.1 sato #define DPRINTFN(n, arg)
69 1.1 sato #define VPRINTF(arg) if (bootverbose) printf arg
70 1.1 sato #define VPRINTFN(n, arg) if (bootverbose) printf arg
71 1.1 sato #endif
72 1.1 sato
73 1.1 sato #ifndef ITE8181_LCD_CONTROL_ENABLE
74 1.1 sato int ite8181_lcd_control_disable = 1;
75 1.1 sato #else /* ITE8181_LCD_CONTROL_ENABLE */
76 1.1 sato int ite8181_lcd_control_disable = 0;
77 1.1 sato #endif /* ITE8181_LCD_CONTROL_ENABLE */
78 1.1 sato
79 1.2 sato #define ITE8181_WINCE_CMAP
80 1.2 sato
81 1.2 sato /*
82 1.2 sato * XXX:
83 1.2 sato * IBM WorkPad z50 power unit has too weak power.
84 1.2 sato * So we must wait too many times to access some device
85 1.2 sato * after LCD panel and BackLight on.
86 1.2 sato * Currently delay is not enough ??? FIXME
87 1.2 sato */
88 1.2 sato #ifndef ITE8181_LCD_ON_SELF_DELAY
89 1.3 sato #define ITE8181_LCD_ON_SELF_DELAY 1000
90 1.2 sato #endif /* ITE8181_LCD_ON__SELF_DELAY */
91 1.2 sato #ifndef ITE8181_LCD_ON_DELAY
92 1.2 sato #define ITE8181_LCD_ON_DELAY 2000
93 1.2 sato #endif /* ITE8181_LCD_ON_DELAY */
94 1.2 sato int ite8181_lcd_on_self_delay = ITE8181_LCD_ON_SELF_DELAY; /* msec */
95 1.2 sato int ite8181_lcd_on_delay = ITE8181_LCD_ON_DELAY; /* msec */
96 1.2 sato
97 1.1 sato #define MSEC 1000
98 1.1 sato /*
99 1.1 sato * function prototypes
100 1.1 sato */
101 1.1 sato static void ite8181_config_write_4 __P((bus_space_tag_t, bus_space_handle_t, int, int));
102 1.1 sato static int ite8181_config_read_4 __P((bus_space_tag_t, bus_space_handle_t, int));
103 1.1 sato
104 1.1 sato static void ite8181_gui_write_4 __P((struct ite8181_softc *, int, int));
105 1.1 sato static int ite8181_gui_read_4 __P((struct ite8181_softc *, int));
106 1.1 sato
107 1.1 sato static void ite8181_gui_write_1 __P((struct ite8181_softc *, int, int));
108 1.1 sato static int ite8181_gui_read_1 __P((struct ite8181_softc *, int));
109 1.1 sato
110 1.1 sato static void ite8181_graphics_write_1 __P((struct ite8181_softc *, int, int));
111 1.1 sato static int ite8181_graphics_read_1 __P((struct ite8181_softc *, int));
112 1.1 sato
113 1.1 sato static void ite8181_ema_write_1 __P((struct ite8181_softc *, int, int));
114 1.1 sato static int ite8181_ema_read_1 __P((struct ite8181_softc *, int));
115 1.1 sato
116 1.1 sato static void ite8181_power __P((int, void *));
117 1.1 sato static int ite8181_hardpower __P((void *, int, long, void *));
118 1.1 sato static int ite8181_fbinit __P((struct hpcfb_fbconf *));
119 1.1 sato static int ite8181_ioctl __P((void *, u_long, caddr_t, int, struct proc *));
120 1.1 sato static paddr_t ite8181_mmap __P((void *, off_t offset, int));
121 1.1 sato static void ite8181_erase_cursor __P((struct ite8181_softc *));
122 1.1 sato static int ite8181_lcd_power __P((struct ite8181_softc *, int));
123 1.8 sato
124 1.8 sato static void ite8181_update_powerstate __P((struct ite8181_softc *, int));
125 1.8 sato void ite8181_get_backlight __P((struct ite8181_softc *));
126 1.8 sato void ite8181_init_brightness __P((struct ite8181_softc *));
127 1.8 sato void ite8181_init_contrast __P((struct ite8181_softc *));
128 1.8 sato void ite8181_set_brightness __P((struct ite8181_softc *, int));
129 1.8 sato void ite8181_set_contrast __P((struct ite8181_softc *, int));
130 1.8 sato
131 1.1 sato /*
132 1.1 sato * static variables
133 1.1 sato */
134 1.1 sato struct hpcfb_accessops ite8181_ha = {
135 1.1 sato ite8181_ioctl, ite8181_mmap
136 1.1 sato };
137 1.1 sato
138 1.1 sato inline int
139 1.1 sato ite8181_config_read_4(iot, ioh, byteoffset)
140 1.1 sato bus_space_tag_t iot;
141 1.1 sato bus_space_handle_t ioh;
142 1.1 sato int byteoffset;
143 1.1 sato {
144 1.1 sato return bus_space_read_4(iot, ioh, ITE8181_CONF_OFFSET + byteoffset);
145 1.1 sato }
146 1.1 sato
147 1.1 sato inline void
148 1.1 sato ite8181_config_write_4(iot, ioh, byteoffset, data)
149 1.1 sato bus_space_tag_t iot;
150 1.1 sato bus_space_handle_t ioh;
151 1.1 sato int byteoffset;
152 1.1 sato int data;
153 1.1 sato {
154 1.1 sato bus_space_write_4(iot, ioh, ITE8181_CONF_OFFSET + byteoffset, data);
155 1.1 sato }
156 1.1 sato
157 1.1 sato inline int
158 1.1 sato ite8181_gui_read_4(sc, byteoffset)
159 1.1 sato struct ite8181_softc *sc;
160 1.1 sato int byteoffset;
161 1.1 sato {
162 1.1 sato return bus_space_read_4(sc->sc_iot, sc->sc_ioh,
163 1.1 sato sc->sc_gba + byteoffset);
164 1.1 sato }
165 1.1 sato
166 1.1 sato inline void
167 1.1 sato ite8181_gui_write_4(sc, byteoffset, data)
168 1.1 sato struct ite8181_softc *sc;
169 1.1 sato int byteoffset;
170 1.1 sato int data;
171 1.1 sato {
172 1.1 sato bus_space_write_4(sc->sc_iot, sc->sc_ioh, sc->sc_gba + byteoffset, data);
173 1.1 sato }
174 1.1 sato
175 1.1 sato inline int
176 1.1 sato ite8181_gui_read_1(sc, byteoffset)
177 1.1 sato struct ite8181_softc *sc;
178 1.1 sato int byteoffset;
179 1.1 sato {
180 1.1 sato return bus_space_read_1(sc->sc_iot, sc->sc_ioh,
181 1.1 sato sc->sc_gba + byteoffset);
182 1.1 sato }
183 1.1 sato
184 1.1 sato inline void
185 1.1 sato ite8181_gui_write_1(sc, byteoffset, data)
186 1.1 sato struct ite8181_softc *sc;
187 1.1 sato int byteoffset;
188 1.1 sato int data;
189 1.1 sato {
190 1.1 sato bus_space_write_1(sc->sc_iot, sc->sc_ioh, sc->sc_gba + byteoffset, data);
191 1.1 sato }
192 1.1 sato
193 1.1 sato inline int
194 1.1 sato ite8181_graphics_read_1(sc, byteoffset)
195 1.1 sato struct ite8181_softc *sc;
196 1.1 sato int byteoffset;
197 1.1 sato {
198 1.1 sato return bus_space_read_1(sc->sc_iot, sc->sc_ioh,
199 1.1 sato sc->sc_sba + byteoffset);
200 1.1 sato }
201 1.1 sato
202 1.1 sato inline void
203 1.1 sato ite8181_graphics_write_1(sc, byteoffset, data)
204 1.1 sato struct ite8181_softc *sc;
205 1.1 sato int byteoffset;
206 1.1 sato int data;
207 1.1 sato {
208 1.1 sato bus_space_write_1(sc->sc_iot, sc->sc_ioh, sc->sc_sba + byteoffset, data);
209 1.1 sato }
210 1.1 sato
211 1.1 sato inline int
212 1.1 sato ite8181_ema_read_1(sc, byteoffset)
213 1.1 sato struct ite8181_softc *sc;
214 1.1 sato int byteoffset;
215 1.1 sato {
216 1.1 sato ite8181_graphics_write_1(sc, ITE8181_EMA_EXAX, byteoffset);
217 1.1 sato return ite8181_graphics_read_1(sc, ITE8181_EMA_EXADATA);
218 1.1 sato }
219 1.1 sato
220 1.1 sato inline void
221 1.1 sato ite8181_ema_write_1(sc, byteoffset, data)
222 1.1 sato struct ite8181_softc *sc;
223 1.1 sato int byteoffset;
224 1.1 sato int data;
225 1.1 sato {
226 1.1 sato ite8181_graphics_write_1(sc, ITE8181_EMA_EXAX, byteoffset);
227 1.1 sato ite8181_graphics_write_1(sc, ITE8181_EMA_EXADATA, data);
228 1.1 sato }
229 1.1 sato
230 1.1 sato int
231 1.1 sato ite8181_probe(iot, ioh)
232 1.1 sato bus_space_tag_t iot;
233 1.1 sato bus_space_handle_t ioh;
234 1.1 sato {
235 1.1 sato unsigned long regval;
236 1.1 sato
237 1.1 sato #if NBIVIDEO > 0
238 1.1 sato if (bivideo_dont_attach) /* some video driver already attached */
239 1.1 sato return (0);
240 1.1 sato #endif /* NBIVIDEO > 0 */
241 1.1 sato
242 1.1 sato regval = ite8181_config_read_4(iot, ioh, ITE8181_ID);
243 1.1 sato VPRINTF(("ite8181_probe: vendor id=%04lx product id=%04lx\n",
244 1.1 sato regval & 0xffff, (regval >> 16) & 0xffff));
245 1.1 sato if (regval != ((ITE8181_PRODUCT_ID << 16) | ITE8181_VENDER_ID))
246 1.1 sato return (0);
247 1.1 sato
248 1.1 sato return (1);
249 1.1 sato }
250 1.1 sato
251 1.1 sato void
252 1.1 sato ite8181_attach(sc)
253 1.1 sato struct ite8181_softc *sc;
254 1.1 sato {
255 1.1 sato unsigned long regval;
256 1.1 sato struct hpcfb_attach_args ha;
257 1.1 sato int console = (bootinfo->bi_cnuse & BI_CNUSE_SERIAL) ? 0 : 1;
258 1.1 sato
259 1.6 sato printf(": ");
260 1.6 sato if (ite8181_fbinit(&sc->sc_fbconf) != 0) {
261 1.6 sato /* just return so that hpcfb will not be attached */
262 1.6 sato return;
263 1.6 sato }
264 1.6 sato
265 1.1 sato regval = ite8181_config_read_4(sc->sc_iot, sc->sc_ioh, ITE8181_CLASS);
266 1.6 sato printf("ITE8181 Rev.%02lx", regval & ITE8181_REV_MASK);
267 1.6 sato if (console) {
268 1.6 sato printf(", console");
269 1.6 sato }
270 1.6 sato printf("\n");
271 1.6 sato printf("%s: framebuffer address: 0x%08lx\n",
272 1.6 sato sc->sc_dev.dv_xname, (u_long)bootinfo->fb_addr);
273 1.1 sato
274 1.1 sato /* set base offsets */
275 1.1 sato sc->sc_mba = ite8181_config_read_4(sc->sc_iot, sc->sc_ioh, ITE8181_MBA);
276 1.1 sato DPRINTFN(1, ("ite8181: Memory base offset %08x\n", sc->sc_mba));
277 1.1 sato sc->sc_gba = ite8181_config_read_4(sc->sc_iot, sc->sc_ioh, ITE8181_GBA);
278 1.1 sato DPRINTFN(1, ("ite8181: GUI base offset %08x\n", sc->sc_gba));
279 1.1 sato sc->sc_sba = ite8181_config_read_4(sc->sc_iot, sc->sc_ioh, ITE8181_SBA);
280 1.1 sato DPRINTFN(1, ("ite8181: Graphics base offset %08x\n", sc->sc_sba));
281 1.1 sato
282 1.1 sato /* assume lcd is on */
283 1.1 sato sc->sc_lcd = 1;
284 1.1 sato
285 1.1 sato /* Add a power hook to power saving */
286 1.1 sato sc->sc_powerhook = powerhook_establish(ite8181_power, sc);
287 1.1 sato if (sc->sc_powerhook == NULL)
288 1.1 sato printf("%s: WARNING: unable to establish power hook\n",
289 1.1 sato sc->sc_dev.dv_xname);
290 1.1 sato
291 1.1 sato /* Add a hard power hook to power saving */
292 1.1 sato sc->sc_hardpowerhook = config_hook(CONFIG_HOOK_PMEVENT,
293 1.1 sato CONFIG_HOOK_PMEVENT_HARDPOWER,
294 1.1 sato CONFIG_HOOK_SHARE,
295 1.1 sato ite8181_hardpower, sc);
296 1.1 sato if (sc->sc_hardpowerhook == NULL)
297 1.1 sato printf("%s: WARNING: unable to establish hard power hook\n",
298 1.1 sato sc->sc_dev.dv_xname);
299 1.1 sato
300 1.1 sato ite8181_erase_cursor(sc);
301 1.1 sato
302 1.8 sato /* initialize backlight brightness and lcd contrast */
303 1.8 sato sc->sc_brightness = sc->sc_contrast =
304 1.8 sato sc->sc_max_brightness = sc->sc_max_contrast = -1;
305 1.8 sato ite8181_get_backlight(sc);
306 1.8 sato ite8181_init_brightness(sc);
307 1.8 sato ite8181_init_contrast(sc);
308 1.8 sato
309 1.1 sato if (console && hpcfb_cnattach(&sc->sc_fbconf) != 0) {
310 1.1 sato panic("ite8181_attach: can't init fb console");
311 1.1 sato }
312 1.1 sato
313 1.1 sato ha.ha_console = console;
314 1.1 sato ha.ha_accessops = &ite8181_ha;
315 1.1 sato ha.ha_accessctx = sc;
316 1.1 sato ha.ha_curfbconf = 0;
317 1.1 sato ha.ha_nfbconf = 1;
318 1.1 sato ha.ha_fbconflist = &sc->sc_fbconf;
319 1.1 sato ha.ha_curdspconf = 0;
320 1.1 sato ha.ha_ndspconf = 1;
321 1.1 sato ha.ha_dspconflist = &sc->sc_dspconf;
322 1.1 sato
323 1.1 sato config_found(&sc->sc_dev, &ha, hpcfbprint);
324 1.1 sato
325 1.1 sato #if NBIVIDEO > 0
326 1.1 sato /*
327 1.1 sato * bivideo is no longer need
328 1.1 sato */
329 1.1 sato bivideo_dont_attach = 1;
330 1.1 sato #endif /* NBIVIDEO > 0 */
331 1.1 sato }
332 1.1 sato
333 1.1 sato int ite8181_lcd_power(sc, on)
334 1.1 sato struct ite8181_softc *sc;
335 1.1 sato int on;
336 1.1 sato {
337 1.1 sato int lcd_p;
338 1.1 sato int lcd_s;
339 1.1 sato int lcd_seq;
340 1.1 sato int loop = 10;
341 1.1 sato
342 1.1 sato if (ite8181_lcd_control_disable) {
343 1.1 sato VPRINTF(("ite8171_lcd_control_disable!: %s\n", on?"on":"off"));
344 1.1 sato return 0;
345 1.1 sato }
346 1.1 sato
347 1.1 sato if (sc->sc_lcd != on) {
348 1.1 sato ite8181_ema_write_1(sc, ITE8181_EMA_ENABLEEMA,
349 1.1 sato ITE8181_EMA_ENABLEPASS);
350 1.1 sato lcd_p = ite8181_ema_read_1(sc, ITE8181_EMA_LCDPOWER);
351 1.1 sato lcd_s = ite8181_ema_read_1(sc, ITE8181_EMA_LCDPOWERSTAT);
352 1.1 sato lcd_seq = ite8181_ema_read_1(sc, ITE8181_EMA_LCDPOWERSEQ);
353 1.1 sato DPRINTFN(1,("ite8181_lcd_power(%d)< p=%x, s=%x, seq=%x\n",
354 1.1 sato on,
355 1.1 sato lcd_p, lcd_s, lcd_seq));
356 1.1 sato if (on) {
357 1.1 sato sc->sc_lcd = 1;
358 1.1 sato lcd_seq |= (ITE8181_PUP0|ITE8181_PUP1|ITE8181_PUP2);
359 1.1 sato ite8181_ema_write_1(sc, ITE8181_EMA_LCDPOWERSEQ, lcd_seq);
360 1.1 sato lcd_p &= ~ITE8181_LCDSTANDBY;
361 1.1 sato ite8181_ema_write_1(sc, ITE8181_EMA_LCDPOWER, lcd_p);
362 1.1 sato /*
363 1.1 sato * XXX:
364 1.1 sato * IBM WorkPad z50 power unit has too weak power.
365 1.1 sato * So we must wait too many times to access self device
366 1.1 sato * after LCD panel and BackLight on.
367 1.1 sato * Currently delay is not enough ??? FIXME
368 1.1 sato */
369 1.2 sato delay(ite8181_lcd_on_self_delay*MSEC);
370 1.1 sato while (loop--) {
371 1.1 sato lcd_p = ite8181_ema_read_1(sc, ITE8181_EMA_LCDPOWER);
372 1.1 sato lcd_s = ite8181_ema_read_1(sc, ITE8181_EMA_LCDPOWERSTAT);
373 1.1 sato lcd_seq = ite8181_ema_read_1(sc, ITE8181_EMA_LCDPOWERSEQ);
374 1.1 sato DPRINTFN(1,("ite8181_lcd_power(%d)%d| p=%x, s=%x, seq=%x\n",
375 1.1 sato on, loop,
376 1.1 sato lcd_p, lcd_s, lcd_seq));
377 1.1 sato /* XXX the states which are not described in manual.*/
378 1.1 sato if (!(lcd_s&ITE8181_LCDPSTANDBY) &&
379 1.1 sato !(lcd_s&ITE8181_LCDPUP) &&
380 1.1 sato (lcd_s&ITE8181_LCDPON))
381 1.1 sato break;
382 1.1 sato delay(100);
383 1.1 sato }
384 1.1 sato lcd_s |= ITE8181_PPTOBEON;
385 1.1 sato ite8181_ema_write_1(sc, ITE8181_EMA_LCDPOWERSTAT, lcd_s);
386 1.1 sato } else {
387 1.1 sato sc->sc_lcd = 0;
388 1.1 sato lcd_p |= ITE8181_LCDSTANDBY;
389 1.1 sato ite8181_ema_write_1(sc, ITE8181_EMA_LCDPOWER, lcd_p);
390 1.1 sato while (loop--) {
391 1.1 sato lcd_p = ite8181_ema_read_1(sc, ITE8181_EMA_LCDPOWER);
392 1.1 sato lcd_s = ite8181_ema_read_1(sc, ITE8181_EMA_LCDPOWERSTAT);
393 1.1 sato lcd_seq = ite8181_ema_read_1(sc, ITE8181_EMA_LCDPOWERSEQ);
394 1.1 sato DPRINTFN(1,("ite8181_lcd_power(%d)%d| p=%x, s=%x, seq=%x\n",
395 1.1 sato on, loop,
396 1.1 sato lcd_p, lcd_s, lcd_seq));
397 1.1 sato /* XXX the states which are not described in manual.*/
398 1.1 sato if ((lcd_s&ITE8181_LCDPSTANDBY) &&
399 1.1 sato !(lcd_s&ITE8181_LCDPDOWN) &&
400 1.1 sato !(lcd_s&ITE8181_LCDPON))
401 1.1 sato break;
402 1.1 sato delay(100);
403 1.1 sato }
404 1.1 sato lcd_s &= ~ITE8181_PPTOBEON;
405 1.1 sato ite8181_ema_write_1(sc, ITE8181_EMA_LCDPOWERSTAT, lcd_s);
406 1.1 sato }
407 1.1 sato DPRINTFN(1,("ite8181_lcd_power(%d)> p=%x, s=%x, seq=%x\n",
408 1.1 sato on,
409 1.1 sato ite8181_ema_read_1(sc, ITE8181_EMA_LCDPOWER),
410 1.1 sato ite8181_ema_read_1(sc, ITE8181_EMA_LCDPOWERSTAT),
411 1.1 sato ite8181_ema_read_1(sc, ITE8181_EMA_LCDPOWERSEQ)));
412 1.1 sato ite8181_ema_write_1(sc, ITE8181_EMA_ENABLEEMA,
413 1.1 sato ITE8181_EMA_DISABLEPASS);
414 1.1 sato }
415 1.1 sato return 0;
416 1.1 sato }
417 1.1 sato
418 1.1 sato static void
419 1.1 sato ite8181_erase_cursor(sc)
420 1.1 sato struct ite8181_softc *sc;
421 1.1 sato {
422 1.1 sato ite8181_gui_write_1(sc, ITE8181_GUI_C1C, 0); /* Cursor 1 Control Reg. */
423 1.1 sato /* other ? */
424 1.1 sato }
425 1.1 sato
426 1.8 sato static void
427 1.8 sato ite8181_update_powerstate(sc, updates)
428 1.8 sato struct ite8181_softc *sc;
429 1.8 sato int updates;
430 1.8 sato {
431 1.8 sato if (updates & PWRSTAT_LCD)
432 1.8 sato config_hook_call(CONFIG_HOOK_POWERCONTROL,
433 1.8 sato CONFIG_HOOK_POWERCONTROL_LCD,
434 1.8 sato (void*)!(sc->sc_powerstate & PWRSTAT_SUSPEND));
435 1.8 sato
436 1.8 sato if (updates & PWRSTAT_BACKLIGHT)
437 1.8 sato config_hook_call(CONFIG_HOOK_POWERCONTROL,
438 1.8 sato CONFIG_HOOK_POWERCONTROL_LCDLIGHT,
439 1.8 sato (void*)(!(sc->sc_powerstate & PWRSTAT_SUSPEND) &&
440 1.8 sato (sc->sc_powerstate & PWRSTAT_BACKLIGHT)));
441 1.8 sato }
442 1.8 sato
443 1.1 sato static void
444 1.1 sato ite8181_power(why, arg)
445 1.1 sato int why;
446 1.1 sato void *arg;
447 1.1 sato {
448 1.1 sato }
449 1.1 sato
450 1.1 sato static int
451 1.1 sato ite8181_hardpower(ctx, type, id, msg)
452 1.1 sato void *ctx;
453 1.1 sato int type;
454 1.1 sato long id;
455 1.1 sato void *msg;
456 1.1 sato {
457 1.1 sato struct ite8181_softc *sc = ctx;
458 1.1 sato int why = (int)msg;
459 1.1 sato
460 1.1 sato switch (why) {
461 1.1 sato case PWR_STANDBY:
462 1.8 sato sc->sc_powerstate |= PWRSTAT_SUSPEND;
463 1.8 sato ite8181_update_powerstate(sc, PWRSTAT_ALL);
464 1.1 sato /* ite8181_lcd_power(sc, 0); */
465 1.1 sato delay(MSEC);
466 1.1 sato break;
467 1.1 sato case PWR_SUSPEND:
468 1.8 sato sc->sc_powerstate |= PWRSTAT_SUSPEND;
469 1.8 sato ite8181_update_powerstate(sc, PWRSTAT_ALL);
470 1.1 sato ite8181_lcd_power(sc, 0);
471 1.1 sato delay(MSEC);
472 1.1 sato break;
473 1.1 sato case PWR_RESUME:
474 1.8 sato sc->sc_powerstate &= ~PWRSTAT_SUSPEND;
475 1.8 sato ite8181_update_powerstate(sc, PWRSTAT_ALL);
476 1.1 sato delay(MSEC);
477 1.1 sato ite8181_lcd_power(sc, 1);
478 1.1 sato /*
479 1.1 sato * XXX:
480 1.1 sato * IBM WorkPad z50 power unit has too weak power.
481 1.1 sato * So we must wait too many times to access other devices
482 1.1 sato * after LCD panel and BackLight on.
483 1.1 sato */
484 1.2 sato delay(ite8181_lcd_on_delay*MSEC);
485 1.1 sato break;
486 1.1 sato }
487 1.1 sato
488 1.1 sato /*
489 1.1 sato * you should wait until the
490 1.1 sato * power state transit sequence will end.
491 1.1 sato */
492 1.1 sato
493 1.1 sato return (0);
494 1.1 sato }
495 1.1 sato
496 1.1 sato static int
497 1.1 sato ite8181_fbinit(fb)
498 1.1 sato struct hpcfb_fbconf *fb;
499 1.1 sato {
500 1.1 sato
501 1.1 sato /*
502 1.1 sato * get fb settings from bootinfo
503 1.1 sato */
504 1.1 sato if (bootinfo == NULL ||
505 1.1 sato bootinfo->fb_addr == 0 ||
506 1.1 sato bootinfo->fb_line_bytes == 0 ||
507 1.1 sato bootinfo->fb_width == 0 ||
508 1.1 sato bootinfo->fb_height == 0) {
509 1.1 sato printf("no frame buffer infomation.\n");
510 1.1 sato return (-1);
511 1.1 sato }
512 1.1 sato
513 1.1 sato /* zero fill */
514 1.1 sato bzero(fb, sizeof(*fb));
515 1.1 sato
516 1.1 sato fb->hf_conf_index = 0; /* configuration index */
517 1.1 sato fb->hf_nconfs = 1; /* how many configurations */
518 1.1 sato strcpy(fb->hf_name, "built-in video");
519 1.1 sato /* frame buffer name */
520 1.1 sato strcpy(fb->hf_conf_name, "default");
521 1.1 sato /* configuration name */
522 1.1 sato fb->hf_height = bootinfo->fb_height;
523 1.1 sato fb->hf_width = bootinfo->fb_width;
524 1.4 takemura fb->hf_baseaddr = (u_long)bootinfo->fb_addr;
525 1.4 takemura fb->hf_offset = (u_long)bootinfo->fb_addr -
526 1.4 takemura mips_ptob(mips_btop(bootinfo->fb_addr));
527 1.1 sato /* frame buffer start offset */
528 1.1 sato fb->hf_bytes_per_line = bootinfo->fb_line_bytes;
529 1.1 sato fb->hf_nplanes = 1;
530 1.1 sato fb->hf_bytes_per_plane = bootinfo->fb_height *
531 1.1 sato bootinfo->fb_line_bytes;
532 1.1 sato
533 1.1 sato fb->hf_access_flags |= HPCFB_ACCESS_BYTE;
534 1.1 sato fb->hf_access_flags |= HPCFB_ACCESS_WORD;
535 1.1 sato fb->hf_access_flags |= HPCFB_ACCESS_DWORD;
536 1.1 sato
537 1.1 sato switch (bootinfo->fb_type) {
538 1.1 sato /*
539 1.1 sato * gray scale
540 1.1 sato */
541 1.1 sato case BIFB_D2_M2L_3:
542 1.1 sato case BIFB_D2_M2L_3x2:
543 1.1 sato fb->hf_access_flags |= HPCFB_ACCESS_REVERSE;
544 1.1 sato /* fall through */
545 1.1 sato case BIFB_D2_M2L_0:
546 1.1 sato case BIFB_D2_M2L_0x2:
547 1.1 sato fb->hf_class = HPCFB_CLASS_GRAYSCALE;
548 1.1 sato fb->hf_access_flags |= HPCFB_ACCESS_STATIC;
549 1.1 sato fb->hf_pack_width = 8;
550 1.1 sato fb->hf_pixels_per_pack = 4;
551 1.1 sato fb->hf_pixel_width = 2;
552 1.5 sato fb->hf_class_data_length = sizeof(struct hf_gray_tag);
553 1.5 sato fb->hf_u.hf_gray.hf_flags = 0; /* reserved for future use */
554 1.5 sato break;
555 1.5 sato
556 1.5 sato case BIFB_D4_M2L_F:
557 1.5 sato case BIFB_D4_M2L_Fx2:
558 1.5 sato fb->hf_access_flags |= HPCFB_ACCESS_REVERSE;
559 1.5 sato /* fall through */
560 1.5 sato case BIFB_D4_M2L_0:
561 1.5 sato case BIFB_D4_M2L_0x2:
562 1.5 sato fb->hf_class = HPCFB_CLASS_GRAYSCALE;
563 1.5 sato fb->hf_access_flags |= HPCFB_ACCESS_STATIC;
564 1.5 sato fb->hf_pack_width = 8;
565 1.5 sato fb->hf_pixels_per_pack = 2;
566 1.5 sato fb->hf_pixel_width = 4;
567 1.1 sato fb->hf_class_data_length = sizeof(struct hf_gray_tag);
568 1.1 sato fb->hf_u.hf_gray.hf_flags = 0; /* reserved for future use */
569 1.1 sato break;
570 1.1 sato
571 1.1 sato /*
572 1.1 sato * indexed color
573 1.1 sato */
574 1.1 sato case BIFB_D8_FF:
575 1.1 sato fb->hf_access_flags |= HPCFB_ACCESS_REVERSE;
576 1.1 sato /* fall through */
577 1.1 sato case BIFB_D8_00:
578 1.1 sato fb->hf_class = HPCFB_CLASS_INDEXCOLOR;
579 1.1 sato fb->hf_access_flags |= HPCFB_ACCESS_STATIC;
580 1.1 sato fb->hf_pack_width = 8;
581 1.1 sato fb->hf_pixels_per_pack = 1;
582 1.1 sato fb->hf_pixel_width = 8;
583 1.1 sato fb->hf_class_data_length = sizeof(struct hf_indexed_tag);
584 1.1 sato fb->hf_u.hf_indexed.hf_flags = 0; /* reserved for future use */
585 1.1 sato break;
586 1.1 sato
587 1.1 sato /*
588 1.1 sato * RGB color
589 1.1 sato */
590 1.1 sato case BIFB_D16_FFFF:
591 1.1 sato fb->hf_access_flags |= HPCFB_ACCESS_REVERSE;
592 1.1 sato /* fall through */
593 1.1 sato case BIFB_D16_0000:
594 1.1 sato fb->hf_class = HPCFB_CLASS_RGBCOLOR;
595 1.1 sato fb->hf_access_flags |= HPCFB_ACCESS_STATIC;
596 1.1 sato #if BYTE_ORDER == LITTLE_ENDIAN
597 1.1 sato fb->hf_swap_flags = HPCFB_SWAP_BYTE;
598 1.1 sato #endif
599 1.1 sato fb->hf_pack_width = 16;
600 1.1 sato fb->hf_pixels_per_pack = 1;
601 1.1 sato fb->hf_pixel_width = 16;
602 1.1 sato
603 1.1 sato fb->hf_class_data_length = sizeof(struct hf_rgb_tag);
604 1.1 sato fb->hf_u.hf_rgb.hf_flags = 0; /* reserved for future use */
605 1.1 sato
606 1.1 sato fb->hf_u.hf_rgb.hf_red_width = 5;
607 1.1 sato fb->hf_u.hf_rgb.hf_red_shift = 11;
608 1.1 sato fb->hf_u.hf_rgb.hf_green_width = 6;
609 1.1 sato fb->hf_u.hf_rgb.hf_green_shift = 5;
610 1.1 sato fb->hf_u.hf_rgb.hf_blue_width = 5;
611 1.1 sato fb->hf_u.hf_rgb.hf_blue_shift = 0;
612 1.1 sato fb->hf_u.hf_rgb.hf_alpha_width = 0;
613 1.1 sato fb->hf_u.hf_rgb.hf_alpha_shift = 0;
614 1.1 sato break;
615 1.1 sato
616 1.1 sato default:
617 1.1 sato printf("unknown type (=%d).\n", bootinfo->fb_type);
618 1.1 sato return (-1);
619 1.1 sato break;
620 1.1 sato }
621 1.1 sato
622 1.1 sato return (0); /* no error */
623 1.1 sato }
624 1.1 sato
625 1.1 sato int
626 1.1 sato ite8181_ioctl(v, cmd, data, flag, p)
627 1.1 sato void *v;
628 1.1 sato u_long cmd;
629 1.1 sato caddr_t data;
630 1.1 sato int flag;
631 1.1 sato struct proc *p;
632 1.1 sato {
633 1.1 sato struct ite8181_softc *sc = (struct ite8181_softc *)v;
634 1.1 sato struct hpcfb_fbconf *fbconf;
635 1.1 sato struct hpcfb_dspconf *dspconf;
636 1.1 sato struct wsdisplay_cmap *cmap;
637 1.8 sato struct wsdisplay_param *dispparam;
638 1.1 sato
639 1.1 sato switch (cmd) {
640 1.1 sato case WSDISPLAYIO_GETCMAP:
641 1.1 sato cmap = (struct wsdisplay_cmap*)data;
642 1.1 sato
643 1.1 sato if (sc->sc_fbconf.hf_class != HPCFB_CLASS_INDEXCOLOR ||
644 1.1 sato sc->sc_fbconf.hf_pack_width != 8 ||
645 1.1 sato 256 <= cmap->index ||
646 1.1 sato 256 < (cmap->index + cmap->count))
647 1.1 sato return (EINVAL);
648 1.1 sato
649 1.1 sato if (!uvm_useracc(cmap->red, cmap->count, B_WRITE) ||
650 1.1 sato !uvm_useracc(cmap->green, cmap->count, B_WRITE) ||
651 1.1 sato !uvm_useracc(cmap->blue, cmap->count, B_WRITE))
652 1.1 sato return (EFAULT);
653 1.1 sato
654 1.2 sato #ifdef ITE8181_WINCE_CMAP
655 1.1 sato copyout(&bivideo_cmap_r[cmap->index], cmap->red, cmap->count);
656 1.1 sato copyout(&bivideo_cmap_g[cmap->index], cmap->green,cmap->count);
657 1.1 sato copyout(&bivideo_cmap_b[cmap->index], cmap->blue, cmap->count);
658 1.1 sato return (0);
659 1.2 sato #else /* ITE8181_WINCE_CMAP */
660 1.2 sato return EINVAL;
661 1.2 sato #endif /* ITE8181_WINCE_CMAP */
662 1.1 sato
663 1.1 sato case WSDISPLAYIO_PUTCMAP:
664 1.1 sato /*
665 1.1 sato * This driver can't set color map.
666 1.1 sato */
667 1.1 sato return (EINVAL);
668 1.1 sato
669 1.8 sato
670 1.8 sato case WSDISPLAYIO_GETPARAM:
671 1.8 sato dispparam = (struct wsdisplay_param*)data;
672 1.8 sato switch (dispparam->param) {
673 1.8 sato case WSDISPLAYIO_PARAM_BACKLIGHT:
674 1.8 sato VPRINTF(("ite8181_ioctl: GETPARAM:BACKLIGHT call\n"));
675 1.8 sato if (sc->sc_max_brightness == -1)
676 1.8 sato ite8181_init_brightness(sc);
677 1.8 sato ite8181_get_backlight(sc);
678 1.8 sato dispparam->min = 0;
679 1.8 sato dispparam->max = 1;
680 1.8 sato if (sc->sc_max_brightness > 0)
681 1.8 sato dispparam->curval = sc->sc_brightness > 0? 1: 0;
682 1.8 sato else
683 1.8 sato dispparam->curval =
684 1.8 sato (sc->sc_powerstate & PWRSTAT_BACKLIGHT) ? 1 : 0;
685 1.8 sato VPRINTF(("ite8181_ioctl: GETPARAM:BACKLIGHT:%d\n",
686 1.8 sato dispparam->curval));
687 1.8 sato return 0;
688 1.8 sato break;
689 1.8 sato case WSDISPLAYIO_PARAM_CONTRAST:
690 1.8 sato VPRINTF(("ite8181_ioctl: GETPARAM:CONTRAST call\n"));
691 1.8 sato if (sc->sc_max_contrast == -1)
692 1.8 sato ite8181_init_contrast(sc);
693 1.8 sato if (sc->sc_max_contrast > 0) {
694 1.8 sato dispparam->min = 0;
695 1.8 sato dispparam->max = sc->sc_max_contrast;
696 1.8 sato dispparam->curval = sc->sc_contrast;
697 1.8 sato VPRINTF(("ite8181_ioctl: GETPARAM:CONTRAST max=%d, current=%d\n", sc->sc_max_contrast, sc->sc_contrast));
698 1.8 sato return 0;
699 1.8 sato } else {
700 1.8 sato VPRINTF(("ite8181_ioctl: GETPARAM:CONTRAST ret\n"));
701 1.8 sato return (EINVAL);
702 1.8 sato }
703 1.8 sato break;
704 1.8 sato case WSDISPLAYIO_PARAM_BRIGHTNESS:
705 1.8 sato VPRINTF(("ite8181_ioctl: GETPARAM:BRIGHTNESS call\n"));
706 1.8 sato if (sc->sc_max_brightness == -1)
707 1.8 sato ite8181_init_brightness(sc);
708 1.8 sato if (sc->sc_max_brightness > 0) {
709 1.8 sato dispparam->min = 0;
710 1.8 sato dispparam->max = sc->sc_max_brightness;
711 1.8 sato dispparam->curval = sc->sc_brightness;
712 1.8 sato VPRINTF(("ite8181_ioctl: GETPARAM:BRIGHTNESS max=%d, current=%d\n", sc->sc_max_brightness, sc->sc_brightness));
713 1.8 sato return 0;
714 1.8 sato } else {
715 1.8 sato VPRINTF(("ite8181_ioctl: GETPARAM:BRIGHTNESS ret\n"));
716 1.8 sato return (EINVAL);
717 1.8 sato }
718 1.8 sato return (EINVAL);
719 1.8 sato default:
720 1.8 sato return (EINVAL);
721 1.8 sato }
722 1.8 sato return (0);
723 1.8 sato
724 1.8 sato case WSDISPLAYIO_SETPARAM:
725 1.8 sato dispparam = (struct wsdisplay_param*)data;
726 1.8 sato switch (dispparam->param) {
727 1.8 sato case WSDISPLAYIO_PARAM_BACKLIGHT:
728 1.8 sato VPRINTF(("ite8181_ioctl: SETPARAM:BACKLIGHT call\n"));
729 1.8 sato if (dispparam->curval < 0 ||
730 1.8 sato 1 < dispparam->curval)
731 1.8 sato return (EINVAL);
732 1.8 sato if (sc->sc_max_brightness == -1)
733 1.8 sato ite8181_init_brightness(sc);
734 1.8 sato VPRINTF(("ite8181_ioctl: SETPARAM:max brightness=%d\n", sc->sc_max_brightness));
735 1.8 sato if (sc->sc_max_brightness > 0) { /* dimmer */
736 1.8 sato if (dispparam->curval == 0){
737 1.8 sato sc->sc_brightness_save = sc->sc_brightness;
738 1.8 sato ite8181_set_brightness(sc, 0); /* min */
739 1.8 sato } else {
740 1.8 sato if (sc->sc_brightness_save == 0)
741 1.8 sato sc->sc_brightness_save = sc->sc_max_brightness;
742 1.8 sato ite8181_set_brightness(sc, sc->sc_brightness_save);
743 1.8 sato }
744 1.8 sato VPRINTF(("ite8181_ioctl: SETPARAM:BACKLIGHT: brightness=%d\n", sc->sc_brightness));
745 1.8 sato } else { /* off */
746 1.8 sato if (dispparam->curval == 0)
747 1.8 sato sc->sc_powerstate &= ~PWRSTAT_BACKLIGHT;
748 1.8 sato else
749 1.8 sato sc->sc_powerstate |= PWRSTAT_BACKLIGHT;
750 1.8 sato VPRINTF(("ite8181_ioctl: SETPARAM:BACKLIGHT: powerstate %d\n",
751 1.8 sato (sc->sc_powerstate & PWRSTAT_BACKLIGHT)?1:0));
752 1.8 sato ite8181_update_powerstate(sc, PWRSTAT_BACKLIGHT);
753 1.8 sato VPRINTF(("ite8181_ioctl: SETPARAM:BACKLIGHT:%d\n",
754 1.8 sato (sc->sc_powerstate & PWRSTAT_BACKLIGHT)?1:0));
755 1.8 sato }
756 1.8 sato return 0;
757 1.8 sato break;
758 1.8 sato case WSDISPLAYIO_PARAM_CONTRAST:
759 1.8 sato VPRINTF(("ite8181_ioctl: SETPARAM:CONTRAST call\n"));
760 1.8 sato if (sc->sc_max_contrast == -1)
761 1.8 sato ite8181_init_contrast(sc);
762 1.8 sato if (dispparam->curval < 0 ||
763 1.8 sato sc->sc_max_contrast < dispparam->curval)
764 1.8 sato return (EINVAL);
765 1.8 sato if (sc->sc_max_contrast > 0) {
766 1.8 sato int org = sc->sc_contrast;
767 1.8 sato ite8181_set_contrast(sc, dispparam->curval);
768 1.8 sato VPRINTF(("ite8181_ioctl: SETPARAM:CONTRAST org=%d, current=%d\n", org, sc->sc_contrast));
769 1.8 sato return 0;
770 1.8 sato } else {
771 1.8 sato VPRINTF(("ite8181_ioctl: SETPARAM:CONTRAST ret\n"));
772 1.8 sato return (EINVAL);
773 1.8 sato }
774 1.8 sato break;
775 1.8 sato case WSDISPLAYIO_PARAM_BRIGHTNESS:
776 1.8 sato VPRINTF(("ite8181_ioctl: SETPARAM:BRIGHTNESS call\n"));
777 1.8 sato if (sc->sc_max_brightness == -1)
778 1.8 sato ite8181_init_brightness(sc);
779 1.8 sato if (dispparam->curval < 0 ||
780 1.8 sato sc->sc_max_brightness < dispparam->curval)
781 1.8 sato return (EINVAL);
782 1.8 sato if (sc->sc_max_brightness > 0) {
783 1.8 sato int org = sc->sc_brightness;
784 1.8 sato ite8181_set_brightness(sc, dispparam->curval);
785 1.8 sato VPRINTF(("ite8181_ioctl: SETPARAM:BRIGHTNESS org=%d, current=%d\n", org, sc->sc_brightness));
786 1.8 sato return 0;
787 1.8 sato } else {
788 1.8 sato VPRINTF(("ite8181_ioctl: SETPARAM:BRIGHTNESS ret\n"));
789 1.8 sato return (EINVAL);
790 1.8 sato }
791 1.8 sato break;
792 1.8 sato default:
793 1.8 sato return (EINVAL);
794 1.8 sato }
795 1.8 sato return (0);
796 1.8 sato
797 1.1 sato case HPCFBIO_GCONF:
798 1.1 sato fbconf = (struct hpcfb_fbconf *)data;
799 1.1 sato if (fbconf->hf_conf_index != 0 &&
800 1.1 sato fbconf->hf_conf_index != HPCFB_CURRENT_CONFIG) {
801 1.1 sato return (EINVAL);
802 1.1 sato }
803 1.1 sato *fbconf = sc->sc_fbconf; /* structure assignment */
804 1.1 sato return (0);
805 1.1 sato case HPCFBIO_SCONF:
806 1.1 sato fbconf = (struct hpcfb_fbconf *)data;
807 1.1 sato if (fbconf->hf_conf_index != 0 &&
808 1.1 sato fbconf->hf_conf_index != HPCFB_CURRENT_CONFIG) {
809 1.1 sato return (EINVAL);
810 1.1 sato }
811 1.1 sato /*
812 1.1 sato * nothing to do because we have only one configration
813 1.1 sato */
814 1.1 sato return (0);
815 1.1 sato case HPCFBIO_GDSPCONF:
816 1.1 sato dspconf = (struct hpcfb_dspconf *)data;
817 1.1 sato if ((dspconf->hd_unit_index != 0 &&
818 1.1 sato dspconf->hd_unit_index != HPCFB_CURRENT_UNIT) ||
819 1.1 sato (dspconf->hd_conf_index != 0 &&
820 1.1 sato dspconf->hd_conf_index != HPCFB_CURRENT_CONFIG)) {
821 1.1 sato return (EINVAL);
822 1.1 sato }
823 1.1 sato *dspconf = sc->sc_dspconf; /* structure assignment */
824 1.1 sato return (0);
825 1.1 sato case HPCFBIO_SDSPCONF:
826 1.1 sato dspconf = (struct hpcfb_dspconf *)data;
827 1.1 sato if ((dspconf->hd_unit_index != 0 &&
828 1.1 sato dspconf->hd_unit_index != HPCFB_CURRENT_UNIT) ||
829 1.1 sato (dspconf->hd_conf_index != 0 &&
830 1.1 sato dspconf->hd_conf_index != HPCFB_CURRENT_CONFIG)) {
831 1.1 sato return (EINVAL);
832 1.1 sato }
833 1.1 sato /*
834 1.1 sato * nothing to do
835 1.1 sato * because we have only one unit and one configration
836 1.1 sato */
837 1.1 sato return (0);
838 1.1 sato case HPCFBIO_GOP:
839 1.1 sato case HPCFBIO_SOP:
840 1.1 sato /*
841 1.1 sato * curently not implemented...
842 1.1 sato */
843 1.1 sato return (EINVAL);
844 1.1 sato }
845 1.1 sato
846 1.1 sato return (ENOTTY);
847 1.1 sato }
848 1.1 sato
849 1.1 sato paddr_t
850 1.1 sato ite8181_mmap(ctx, offset, prot)
851 1.1 sato void *ctx;
852 1.1 sato off_t offset;
853 1.1 sato int prot;
854 1.1 sato {
855 1.1 sato struct ite8181_softc *sc = (struct ite8181_softc *)ctx;
856 1.1 sato
857 1.1 sato if (offset < 0 ||
858 1.1 sato (sc->sc_fbconf.hf_bytes_per_plane +
859 1.1 sato sc->sc_fbconf.hf_offset) < offset)
860 1.1 sato return -1;
861 1.1 sato
862 1.4 takemura return mips_btop((u_long)bootinfo->fb_addr + offset);
863 1.8 sato }
864 1.8 sato
865 1.8 sato void
866 1.8 sato ite8181_get_backlight(sc)
867 1.8 sato struct ite8181_softc *sc;
868 1.8 sato {
869 1.8 sato int val = -1;
870 1.8 sato
871 1.8 sato if (sc->sc_max_brightness < 0) {
872 1.8 sato if (config_hook_call(CONFIG_HOOK_GET,
873 1.8 sato CONFIG_HOOK_POWER_LCDLIGHT, &val) != -1) {
874 1.8 sato if (val == 0)
875 1.8 sato sc->sc_powerstate &= ~PWRSTAT_BACKLIGHT;
876 1.8 sato else
877 1.8 sato sc->sc_powerstate |= PWRSTAT_BACKLIGHT;
878 1.8 sato }
879 1.8 sato }
880 1.8 sato }
881 1.8 sato
882 1.8 sato void
883 1.8 sato ite8181_init_brightness(sc)
884 1.8 sato struct ite8181_softc *sc;
885 1.8 sato {
886 1.8 sato int val = -1;
887 1.8 sato
888 1.8 sato if (config_hook_call(CONFIG_HOOK_GET,
889 1.8 sato CONFIG_HOOK_BRIGHTNESS, &val) != -1) {
890 1.8 sato sc->sc_brightness = val;
891 1.8 sato }
892 1.8 sato val = -1;
893 1.8 sato if (config_hook_call(CONFIG_HOOK_GET,
894 1.8 sato CONFIG_HOOK_BRIGHTNESS_MAX, &val) != -1) {
895 1.8 sato sc->sc_brightness_save = sc->sc_max_brightness = val;
896 1.8 sato }
897 1.8 sato return;
898 1.8 sato }
899 1.8 sato
900 1.8 sato
901 1.8 sato void
902 1.8 sato ite8181_init_contrast(sc)
903 1.8 sato struct ite8181_softc *sc;
904 1.8 sato {
905 1.8 sato int val = -1;
906 1.8 sato
907 1.8 sato if (config_hook_call(CONFIG_HOOK_GET,
908 1.8 sato CONFIG_HOOK_CONTRAST, &val) != -1) {
909 1.8 sato sc->sc_contrast = val;
910 1.8 sato }
911 1.8 sato val = -1;
912 1.8 sato if (config_hook_call(CONFIG_HOOK_GET,
913 1.8 sato CONFIG_HOOK_CONTRAST_MAX, &val) != -1) {
914 1.8 sato sc->sc_max_contrast = val;
915 1.8 sato }
916 1.8 sato return;
917 1.8 sato }
918 1.8 sato
919 1.8 sato void
920 1.8 sato ite8181_set_brightness(sc, val)
921 1.8 sato struct ite8181_softc *sc;
922 1.8 sato int val;
923 1.8 sato {
924 1.8 sato sc->sc_brightness = val;
925 1.8 sato
926 1.8 sato config_hook_call(CONFIG_HOOK_SET, CONFIG_HOOK_BRIGHTNESS, &val);
927 1.8 sato if (config_hook_call(CONFIG_HOOK_GET,
928 1.8 sato CONFIG_HOOK_BRIGHTNESS, &val) != -1) {
929 1.8 sato sc->sc_brightness = val;
930 1.8 sato }
931 1.8 sato }
932 1.8 sato
933 1.8 sato void
934 1.8 sato ite8181_set_contrast(sc, val)
935 1.8 sato struct ite8181_softc *sc;
936 1.8 sato int val;
937 1.8 sato {
938 1.8 sato sc->sc_contrast = val;
939 1.8 sato
940 1.8 sato config_hook_call(CONFIG_HOOK_SET, CONFIG_HOOK_CONTRAST, &val);
941 1.8 sato if (config_hook_call(CONFIG_HOOK_GET,
942 1.8 sato CONFIG_HOOK_CONTRAST, &val) != -1) {
943 1.8 sato sc->sc_contrast = val;
944 1.8 sato }
945 1.1 sato }
946