zlcd.c revision 1.8 1 1.8 nonaka /* $NetBSD: zlcd.c,v 1.8 2009/01/29 12:28:15 nonaka Exp $ */
2 1.1 ober /* $OpenBSD: zaurus_lcd.c,v 1.20 2006/06/02 20:50:14 miod Exp $ */
3 1.1 ober /* NetBSD: lubbock_lcd.c,v 1.1 2003/08/09 19:38:53 bsh Exp */
4 1.1 ober
5 1.1 ober /*
6 1.1 ober * Copyright (c) 2002, 2003 Genetec Corporation. All rights reserved.
7 1.1 ober * Written by Hiroyuki Bessho for Genetec Corporation.
8 1.1 ober *
9 1.1 ober * Redistribution and use in source and binary forms, with or without
10 1.1 ober * modification, are permitted provided that the following conditions
11 1.1 ober * are met:
12 1.1 ober * 1. Redistributions of source code must retain the above copyright
13 1.1 ober * notice, this list of conditions and the following disclaimer.
14 1.1 ober * 2. Redistributions in binary form must reproduce the above copyright
15 1.1 ober * notice, this list of conditions and the following disclaimer in the
16 1.1 ober * documentation and/or other materials provided with the distribution.
17 1.1 ober * 3. The name of Genetec Corporation may not be used to endorse or
18 1.1 ober * promote products derived from this software without specific prior
19 1.1 ober * written permission.
20 1.1 ober *
21 1.1 ober * THIS SOFTWARE IS PROVIDED BY GENETEC CORPORATION ``AS IS'' AND
22 1.1 ober * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
23 1.1 ober * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
24 1.1 ober * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GENETEC CORPORATION
25 1.1 ober * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26 1.1 ober * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27 1.1 ober * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28 1.1 ober * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29 1.1 ober * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30 1.1 ober * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31 1.1 ober * POSSIBILITY OF SUCH DAMAGE.
32 1.1 ober */
33 1.1 ober
34 1.1 ober /*
35 1.1 ober * LCD driver for Sharp Zaurus (based on the Intel Lubbock driver).
36 1.1 ober *
37 1.1 ober * Controlling LCD is almost completely done through PXA2X0's
38 1.1 ober * integrated LCD controller. Codes for it is arm/xscale/pxa2x0_lcd.c.
39 1.1 ober *
40 1.1 ober * Codes in this file provide platform specific things including:
41 1.1 ober * LCD on/off switch and backlight brightness
42 1.1 ober * LCD panel geometry
43 1.1 ober */
44 1.1 ober
45 1.1 ober #include <sys/cdefs.h>
46 1.8 nonaka __KERNEL_RCSID(0, "$NetBSD: zlcd.c,v 1.8 2009/01/29 12:28:15 nonaka Exp $");
47 1.1 ober
48 1.1 ober #include <sys/param.h>
49 1.1 ober #include <sys/systm.h>
50 1.1 ober #include <sys/conf.h>
51 1.1 ober #include <sys/uio.h>
52 1.1 ober #include <sys/malloc.h>
53 1.1 ober
54 1.1 ober #include <dev/cons.h>
55 1.1 ober #include <dev/wscons/wsconsio.h>
56 1.1 ober #include <dev/wscons/wsdisplayvar.h>
57 1.1 ober #include <dev/wscons/wscons_callbacks.h>
58 1.1 ober
59 1.6 nonaka #include <dev/hpc/hpcfbio.h>
60 1.6 nonaka
61 1.1 ober #include <machine/bus.h>
62 1.1 ober #include <arm/xscale/pxa2x0var.h>
63 1.1 ober #include <arm/xscale/pxa2x0reg.h>
64 1.1 ober #include <arm/xscale/pxa2x0_lcd.h>
65 1.1 ober
66 1.1 ober #include <zaurus/dev/scoopvar.h>
67 1.1 ober #include <zaurus/dev/zsspvar.h>
68 1.1 ober #include <zaurus/zaurus/zaurus_var.h>
69 1.1 ober
70 1.1 ober /*
71 1.1 ober * wsdisplay glue
72 1.1 ober */
73 1.2 peter static struct pxa2x0_wsscreen_descr lcd_std_screen = {
74 1.2 peter .c = {
75 1.2 peter .name = "std",
76 1.2 peter .textops = &pxa2x0_lcd_emulops,
77 1.2 peter .fontwidth = 8,
78 1.2 peter .fontheight = 16,
79 1.2 peter .capabilities = WSSCREEN_WSCOLORS,
80 1.1 ober },
81 1.2 peter .depth = 16, /* bits per pixel */
82 1.4 ober .flags = RI_ROTATE_CW, /* quarter clockwise rotation */
83 1.1 ober };
84 1.1 ober
85 1.1 ober static const struct wsscreen_descr *lcd_scr_descr[] = {
86 1.2 peter &lcd_std_screen.c
87 1.1 ober };
88 1.1 ober
89 1.2 peter static const struct wsscreen_list lcd_screen_list = {
90 1.2 peter .nscreens = __arraycount(lcd_scr_descr),
91 1.2 peter .screens = lcd_scr_descr,
92 1.1 ober };
93 1.1 ober
94 1.5 christos static int lcd_ioctl(void *, void *, u_long, void *, int, struct lwp *);
95 1.2 peter static int lcd_param(struct pxa2x0_lcd_softc *, u_long,
96 1.2 peter struct wsdisplay_param *);
97 1.2 peter static int lcd_show_screen(void *, void *, int,
98 1.2 peter void (*)(void *, int, int), void *);
99 1.1 ober
100 1.2 peter struct wsdisplay_accessops lcd_accessops = {
101 1.1 ober lcd_ioctl,
102 1.1 ober pxa2x0_lcd_mmap,
103 1.1 ober pxa2x0_lcd_alloc_screen,
104 1.1 ober pxa2x0_lcd_free_screen,
105 1.1 ober lcd_show_screen,
106 1.2 peter NULL,
107 1.2 peter NULL,
108 1.2 peter NULL,
109 1.1 ober };
110 1.1 ober
111 1.1 ober #define CURRENT_DISPLAY &sharp_zaurus_C3000
112 1.1 ober
113 1.1 ober const struct lcd_panel_geometry sharp_zaurus_C3000 =
114 1.1 ober {
115 1.1 ober 480, /* Width */
116 1.1 ober 640, /* Height */
117 1.1 ober 0, /* No extra lines */
118 1.1 ober
119 1.1 ober LCDPANEL_ACTIVE | LCDPANEL_VSP | LCDPANEL_HSP,
120 1.1 ober 1, /* clock divider */
121 1.1 ober 0, /* AC bias pin freq */
122 1.1 ober
123 1.1 ober 0x28, /* horizontal sync pulse width */
124 1.1 ober 0x2e, /* BLW */
125 1.1 ober 0x7d, /* ELW */
126 1.1 ober
127 1.1 ober 2, /* vertical sync pulse width */
128 1.1 ober 1, /* BFW */
129 1.1 ober 0, /* EFW */
130 1.1 ober };
131 1.1 ober
132 1.1 ober struct sharp_lcd_backlight {
133 1.1 ober int duty; /* LZ9JG18 DAC value */
134 1.1 ober int cont; /* BACKLIGHT_CONT signal */
135 1.1 ober int on; /* BACKLIGHT_ON signal */
136 1.1 ober };
137 1.1 ober
138 1.1 ober #define CURRENT_BACKLIGHT sharp_zaurus_C3000_bl
139 1.1 ober
140 1.1 ober const struct sharp_lcd_backlight sharp_zaurus_C3000_bl[] = {
141 1.2 peter { 0x00, 0, 0 }, /* 0: Off */
142 1.2 peter { 0x00, 0, 1 }, /* 1: 0% */
143 1.2 peter { 0x01, 0, 1 }, /* 2: 20% */
144 1.2 peter { 0x07, 0, 1 }, /* 3: 40% */
145 1.2 peter { 0x01, 1, 1 }, /* 4: 60% */
146 1.2 peter { 0x07, 1, 1 }, /* 5: 80% */
147 1.2 peter { 0x11, 1, 1 }, /* 6: 100% */
148 1.2 peter { -1, -1, -1 }, /* 7: Invalid */
149 1.1 ober };
150 1.1 ober
151 1.8 nonaka static int lcd_match(device_t, cfdata_t, void *);
152 1.8 nonaka static void lcd_attach(device_t, device_t, void *);
153 1.1 ober
154 1.8 nonaka CFATTACH_DECL_NEW(zlcd, sizeof(struct pxa2x0_lcd_softc),
155 1.1 ober lcd_match, lcd_attach, NULL, NULL);
156 1.1 ober
157 1.3 nonaka void lcd_cnattach(void);
158 1.1 ober int lcd_max_brightness(void);
159 1.1 ober int lcd_get_brightness(void);
160 1.1 ober void lcd_set_brightness(int);
161 1.1 ober void lcd_set_brightness_internal(int);
162 1.1 ober int lcd_get_backlight(void);
163 1.1 ober void lcd_set_backlight(int);
164 1.1 ober void lcd_blank(int);
165 1.1 ober void lcd_power(int, void *);
166 1.1 ober
167 1.1 ober static int
168 1.8 nonaka lcd_match(device_t parent, cfdata_t cf, void *aux)
169 1.1 ober {
170 1.1 ober
171 1.1 ober return 1;
172 1.1 ober }
173 1.1 ober
174 1.1 ober static void
175 1.8 nonaka lcd_attach(device_t parent, device_t self, void *aux)
176 1.1 ober {
177 1.8 nonaka struct pxa2x0_lcd_softc *sc = device_private(self);
178 1.1 ober struct wsemuldisplaydev_attach_args aa;
179 1.1 ober
180 1.8 nonaka sc->dev = self;
181 1.8 nonaka
182 1.3 nonaka pxa2x0_lcd_attach_sub(sc, aux, CURRENT_DISPLAY);
183 1.1 ober
184 1.1 ober aa.console = glass_console;
185 1.1 ober aa.scrdata = &lcd_screen_list;
186 1.1 ober aa.accessops = &lcd_accessops;
187 1.1 ober aa.accesscookie = sc;
188 1.1 ober
189 1.2 peter (void) config_found(self, &aa, wsemuldisplaydevprint);
190 1.1 ober
191 1.1 ober /* Start with approximately 40% of full brightness. */
192 1.1 ober lcd_set_brightness(3);
193 1.1 ober
194 1.8 nonaka (void) powerhook_establish(device_xname(sc->dev), lcd_power, sc);
195 1.1 ober }
196 1.1 ober
197 1.3 nonaka void
198 1.3 nonaka lcd_cnattach(void)
199 1.3 nonaka {
200 1.3 nonaka
201 1.3 nonaka pxa2x0_lcd_cnattach(&lcd_std_screen, CURRENT_DISPLAY);
202 1.3 nonaka }
203 1.3 nonaka
204 1.1 ober /*
205 1.1 ober * wsdisplay accessops overrides
206 1.1 ober */
207 1.2 peter static int
208 1.5 christos lcd_ioctl(void *v, void *vs, u_long cmd, void *data, int flag, struct lwp *l)
209 1.1 ober {
210 1.1 ober struct pxa2x0_lcd_softc *sc = (struct pxa2x0_lcd_softc *)v;
211 1.6 nonaka struct hpcfb_fbconf *fbconf;
212 1.6 nonaka struct hpcfb_dspconf *dspconf;
213 1.1 ober int res = EINVAL;
214 1.1 ober
215 1.1 ober switch (cmd) {
216 1.1 ober case WSDISPLAYIO_GETPARAM:
217 1.1 ober case WSDISPLAYIO_SETPARAM:
218 1.1 ober res = lcd_param(sc, cmd, (struct wsdisplay_param *)data);
219 1.1 ober break;
220 1.6 nonaka
221 1.6 nonaka case HPCFBIO_GCONF:
222 1.6 nonaka fbconf = (struct hpcfb_fbconf *)data;
223 1.6 nonaka if (fbconf->hf_conf_index != 0 &&
224 1.6 nonaka fbconf->hf_conf_index != HPCFB_CURRENT_CONFIG) {
225 1.6 nonaka break;
226 1.6 nonaka }
227 1.6 nonaka
228 1.6 nonaka fbconf->hf_conf_index = 0;
229 1.6 nonaka fbconf->hf_nconfs = 1;
230 1.6 nonaka fbconf->hf_class = HPCFB_CLASS_RGBCOLOR;
231 1.6 nonaka strlcpy(fbconf->hf_name, "Sharp Zaurus frame buffer",
232 1.6 nonaka sizeof(fbconf->hf_name));
233 1.6 nonaka strlcpy(fbconf->hf_conf_name, "default",
234 1.6 nonaka sizeof(fbconf->hf_conf_name));
235 1.6 nonaka fbconf->hf_width = sc->geometry->panel_width;
236 1.6 nonaka fbconf->hf_height = sc->geometry->panel_height;
237 1.6 nonaka fbconf->hf_baseaddr = (u_long)sc->active->buf_va;
238 1.6 nonaka fbconf->hf_offset = 0;
239 1.6 nonaka fbconf->hf_bytes_per_line = sc->geometry->panel_width *
240 1.6 nonaka sc->active->depth / 8;
241 1.6 nonaka fbconf->hf_nplanes = 1;
242 1.6 nonaka fbconf->hf_bytes_per_plane = sc->geometry->panel_width *
243 1.6 nonaka sc->geometry->panel_height * sc->active->depth / 8;
244 1.6 nonaka fbconf->hf_pack_width = sc->active->depth;
245 1.6 nonaka fbconf->hf_pixels_per_pack = 1;
246 1.6 nonaka fbconf->hf_pixel_width = sc->active->depth;
247 1.6 nonaka fbconf->hf_access_flags = (0
248 1.6 nonaka | HPCFB_ACCESS_BYTE
249 1.6 nonaka | HPCFB_ACCESS_WORD
250 1.6 nonaka | HPCFB_ACCESS_DWORD);
251 1.6 nonaka fbconf->hf_order_flags = 0;
252 1.6 nonaka fbconf->hf_reg_offset = 0;
253 1.6 nonaka
254 1.6 nonaka fbconf->hf_class_data_length = sizeof(struct hf_rgb_tag);
255 1.6 nonaka fbconf->hf_u.hf_rgb.hf_flags = 0;
256 1.6 nonaka fbconf->hf_u.hf_rgb.hf_red_width = 5;
257 1.6 nonaka fbconf->hf_u.hf_rgb.hf_red_shift = 11;
258 1.6 nonaka fbconf->hf_u.hf_rgb.hf_green_width = 6;
259 1.6 nonaka fbconf->hf_u.hf_rgb.hf_green_shift = 5;
260 1.6 nonaka fbconf->hf_u.hf_rgb.hf_blue_width = 5;
261 1.6 nonaka fbconf->hf_u.hf_rgb.hf_blue_shift = 0;
262 1.6 nonaka fbconf->hf_u.hf_rgb.hf_alpha_width = 0;
263 1.6 nonaka fbconf->hf_u.hf_rgb.hf_alpha_shift = 0;
264 1.6 nonaka
265 1.6 nonaka fbconf->hf_ext_size = 0;
266 1.6 nonaka fbconf->hf_ext_data = NULL;
267 1.6 nonaka
268 1.6 nonaka res = 0;
269 1.6 nonaka break;
270 1.6 nonaka
271 1.6 nonaka case HPCFBIO_SCONF:
272 1.6 nonaka fbconf = (struct hpcfb_fbconf *)data;
273 1.6 nonaka if (fbconf->hf_conf_index != 0 &&
274 1.6 nonaka fbconf->hf_conf_index != HPCFB_CURRENT_CONFIG) {
275 1.6 nonaka break;
276 1.6 nonaka }
277 1.6 nonaka /* nothing to do because we have only one configuration */
278 1.6 nonaka res = 0;
279 1.6 nonaka break;
280 1.6 nonaka
281 1.6 nonaka case HPCFBIO_GDSPCONF:
282 1.6 nonaka dspconf = (struct hpcfb_dspconf *)data;
283 1.6 nonaka if ((dspconf->hd_unit_index != 0 &&
284 1.6 nonaka dspconf->hd_unit_index != HPCFB_CURRENT_UNIT) ||
285 1.6 nonaka (dspconf->hd_conf_index != 0 &&
286 1.6 nonaka dspconf->hd_conf_index != HPCFB_CURRENT_CONFIG)) {
287 1.6 nonaka break;
288 1.6 nonaka }
289 1.6 nonaka
290 1.6 nonaka dspconf->hd_unit_index = 0;
291 1.6 nonaka dspconf->hd_nunits = 1;
292 1.6 nonaka dspconf->hd_class = HPCFB_DSP_CLASS_COLORLCD;
293 1.6 nonaka strlcpy(dspconf->hd_name, "Sharp Zaurus LCD",
294 1.6 nonaka sizeof(dspconf->hd_name));
295 1.6 nonaka dspconf->hd_op_flags = 0;
296 1.6 nonaka dspconf->hd_conf_index = 0;
297 1.6 nonaka dspconf->hd_nconfs = 1;
298 1.6 nonaka strlcpy(dspconf->hd_conf_name, "default",
299 1.6 nonaka sizeof(dspconf->hd_conf_name));
300 1.6 nonaka dspconf->hd_width = sc->geometry->panel_width;
301 1.6 nonaka dspconf->hd_height = sc->geometry->panel_height;
302 1.6 nonaka dspconf->hd_xdpi = HPCFB_DSP_DPI_UNKNOWN;
303 1.6 nonaka dspconf->hd_ydpi = HPCFB_DSP_DPI_UNKNOWN;
304 1.6 nonaka
305 1.6 nonaka res = 0;
306 1.6 nonaka break;
307 1.6 nonaka
308 1.6 nonaka case HPCFBIO_SDSPCONF:
309 1.6 nonaka dspconf = (struct hpcfb_dspconf *)data;
310 1.6 nonaka if ((dspconf->hd_unit_index != 0 &&
311 1.6 nonaka dspconf->hd_unit_index != HPCFB_CURRENT_UNIT) ||
312 1.6 nonaka (dspconf->hd_conf_index != 0 &&
313 1.6 nonaka dspconf->hd_conf_index != HPCFB_CURRENT_CONFIG)) {
314 1.6 nonaka break;
315 1.6 nonaka }
316 1.6 nonaka /*
317 1.6 nonaka * nothing to do
318 1.6 nonaka * because we have only one unit and one configuration
319 1.6 nonaka */
320 1.6 nonaka res = 0;
321 1.6 nonaka break;
322 1.6 nonaka
323 1.6 nonaka case HPCFBIO_GOP:
324 1.6 nonaka case HPCFBIO_SOP:
325 1.6 nonaka /* curently not implemented... */
326 1.6 nonaka break;
327 1.1 ober }
328 1.1 ober
329 1.1 ober if (res == EINVAL)
330 1.1 ober res = pxa2x0_lcd_ioctl(v, vs, cmd, data, flag, l);
331 1.1 ober return res;
332 1.1 ober }
333 1.1 ober
334 1.2 peter static int
335 1.1 ober lcd_show_screen(void *v, void *cookie, int waitok,
336 1.2 peter void (*cb_func)(void *, int, int), void *cb_arg)
337 1.1 ober {
338 1.1 ober int error;
339 1.1 ober
340 1.2 peter error = pxa2x0_lcd_show_screen(v, cookie, waitok, cb_func, cb_arg);
341 1.1 ober if (error)
342 1.1 ober return (error);
343 1.1 ober
344 1.1 ober /* Turn on LCD */
345 1.2 peter lcd_set_brightness(lcd_get_brightness());
346 1.1 ober
347 1.1 ober return 0;
348 1.1 ober }
349 1.1 ober
350 1.1 ober /*
351 1.1 ober * wsdisplay I/O controls
352 1.1 ober */
353 1.2 peter static int
354 1.6 nonaka lcd_param(struct pxa2x0_lcd_softc *sc, u_long cmd, struct wsdisplay_param *dp)
355 1.1 ober {
356 1.1 ober int res = EINVAL;
357 1.1 ober
358 1.1 ober switch (dp->param) {
359 1.1 ober case WSDISPLAYIO_PARAM_BACKLIGHT:
360 1.1 ober if (cmd == WSDISPLAYIO_GETPARAM) {
361 1.1 ober dp->min = 0;
362 1.1 ober dp->max = 1;
363 1.1 ober dp->curval = lcd_get_backlight();
364 1.1 ober res = 0;
365 1.1 ober } else if (cmd == WSDISPLAYIO_SETPARAM) {
366 1.1 ober lcd_set_backlight(dp->curval);
367 1.1 ober res = 0;
368 1.1 ober }
369 1.1 ober break;
370 1.1 ober
371 1.1 ober case WSDISPLAYIO_PARAM_CONTRAST:
372 1.1 ober /* unsupported */
373 1.1 ober res = ENOTTY;
374 1.1 ober break;
375 1.1 ober
376 1.1 ober case WSDISPLAYIO_PARAM_BRIGHTNESS:
377 1.1 ober if (cmd == WSDISPLAYIO_GETPARAM) {
378 1.1 ober dp->min = 1;
379 1.1 ober dp->max = lcd_max_brightness();
380 1.1 ober dp->curval = lcd_get_brightness();
381 1.1 ober res = 0;
382 1.1 ober } else if (cmd == WSDISPLAYIO_SETPARAM) {
383 1.1 ober lcd_set_brightness(dp->curval);
384 1.1 ober res = 0;
385 1.1 ober }
386 1.1 ober break;
387 1.1 ober }
388 1.1 ober
389 1.1 ober return res;
390 1.1 ober }
391 1.1 ober
392 1.1 ober /*
393 1.1 ober * LCD backlight
394 1.1 ober */
395 1.1 ober
396 1.1 ober static int lcdbrightnesscurval = 1;
397 1.1 ober static int lcdislit = 1;
398 1.1 ober static int lcdisblank = 0;
399 1.1 ober
400 1.1 ober int
401 1.1 ober lcd_max_brightness(void)
402 1.1 ober {
403 1.1 ober int i;
404 1.1 ober
405 1.1 ober for (i = 0; CURRENT_BACKLIGHT[i].duty != -1; i++)
406 1.1 ober continue;
407 1.1 ober return i - 1;
408 1.1 ober }
409 1.1 ober
410 1.1 ober int
411 1.1 ober lcd_get_brightness(void)
412 1.1 ober {
413 1.1 ober
414 1.1 ober return lcdbrightnesscurval;
415 1.1 ober }
416 1.1 ober
417 1.1 ober void
418 1.1 ober lcd_set_brightness(int newval)
419 1.1 ober {
420 1.1 ober int maxval;
421 1.1 ober
422 1.1 ober maxval = lcd_max_brightness();
423 1.1 ober if (newval < 0)
424 1.1 ober newval = 0;
425 1.1 ober else if (newval > maxval)
426 1.1 ober newval = maxval;
427 1.1 ober
428 1.1 ober if (lcd_get_backlight() && !lcdisblank)
429 1.1 ober lcd_set_brightness_internal(newval);
430 1.1 ober
431 1.1 ober if (newval > 0)
432 1.1 ober lcdbrightnesscurval = newval;
433 1.1 ober }
434 1.1 ober
435 1.1 ober void
436 1.1 ober lcd_set_brightness_internal(int newval)
437 1.1 ober {
438 1.1 ober static int curval = 1;
439 1.1 ober int i;
440 1.1 ober
441 1.1 ober /*
442 1.1 ober * It appears that the C3000 backlight can draw too much power if we
443 1.1 ober * switch it from a low to a high brightness. Increasing brightness
444 1.1 ober * in steps avoids this issue.
445 1.1 ober */
446 1.1 ober if (newval > curval) {
447 1.1 ober for (i = curval + 1; i <= newval; i++) {
448 1.1 ober (void)zssp_ic_send(ZSSP_IC_LZ9JG18,
449 1.1 ober CURRENT_BACKLIGHT[i].duty);
450 1.1 ober scoop_set_backlight(CURRENT_BACKLIGHT[i].on,
451 1.1 ober CURRENT_BACKLIGHT[i].cont);
452 1.1 ober delay(5000);
453 1.1 ober }
454 1.1 ober } else {
455 1.1 ober (void)zssp_ic_send(ZSSP_IC_LZ9JG18,
456 1.1 ober CURRENT_BACKLIGHT[newval].duty);
457 1.1 ober scoop_set_backlight(CURRENT_BACKLIGHT[newval].on,
458 1.1 ober CURRENT_BACKLIGHT[newval].cont);
459 1.1 ober }
460 1.1 ober
461 1.1 ober curval = newval;
462 1.1 ober }
463 1.1 ober
464 1.1 ober int
465 1.1 ober lcd_get_backlight(void)
466 1.1 ober {
467 1.1 ober
468 1.1 ober return lcdislit;
469 1.1 ober }
470 1.1 ober
471 1.1 ober void
472 1.2 peter lcd_set_backlight(int onoff)
473 1.1 ober {
474 1.1 ober
475 1.2 peter if (!onoff) {
476 1.1 ober lcd_set_brightness(0);
477 1.1 ober lcdislit = 0;
478 1.1 ober } else {
479 1.1 ober lcdislit = 1;
480 1.1 ober lcd_set_brightness(lcd_get_brightness());
481 1.1 ober }
482 1.1 ober }
483 1.1 ober
484 1.1 ober void
485 1.1 ober lcd_blank(int blank)
486 1.1 ober {
487 1.1 ober
488 1.1 ober if (blank) {
489 1.1 ober lcd_set_brightness(0);
490 1.1 ober lcdisblank = 1;
491 1.1 ober } else {
492 1.1 ober lcdisblank = 0;
493 1.1 ober lcd_set_brightness(lcd_get_brightness());
494 1.1 ober }
495 1.1 ober }
496 1.1 ober
497 1.1 ober void
498 1.1 ober lcd_power(int why, void *v)
499 1.1 ober {
500 1.1 ober
501 1.1 ober switch (why) {
502 1.1 ober case PWR_SUSPEND:
503 1.1 ober case PWR_STANDBY:
504 1.1 ober lcd_set_brightness(0);
505 1.1 ober pxa2x0_lcd_power(why, v);
506 1.1 ober break;
507 1.1 ober
508 1.1 ober case PWR_RESUME:
509 1.1 ober pxa2x0_lcd_power(why, v);
510 1.1 ober lcd_set_brightness(lcd_get_brightness());
511 1.1 ober break;
512 1.1 ober }
513 1.1 ober }
514