Module Name: src Committed By: tsutsui Date: Fri Jan 27 14:48:22 UTC 2012
Modified Files: src/sys/arch/zaurus/dev: lcdctl.c scoop.c Log Message: Allow calling scoop_set_backlight() even before scoop is attached and schedule initial values in that case as ioexp does. Suggested by nonaka@. Now lcdctl no longer has to defer lcdctl_set_brightness() by config_finalize_register(9), which is a bit too late. (i.e. no backlight during USB/SD probe by config_interrupt(9) in previous) To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/sys/arch/zaurus/dev/lcdctl.c cvs rdiff -u -r1.9 -r1.10 src/sys/arch/zaurus/dev/scoop.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/arch/zaurus/dev/lcdctl.c diff -u src/sys/arch/zaurus/dev/lcdctl.c:1.1 src/sys/arch/zaurus/dev/lcdctl.c:1.2 --- src/sys/arch/zaurus/dev/lcdctl.c:1.1 Wed Jan 25 16:51:17 2012 +++ src/sys/arch/zaurus/dev/lcdctl.c Fri Jan 27 14:48:22 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: lcdctl.c,v 1.1 2012/01/25 16:51:17 tsutsui Exp $ */ +/* $NetBSD: lcdctl.c,v 1.2 2012/01/27 14:48:22 tsutsui Exp $ */ /*- * Copyright (C) 2012 NONAKA Kimihiro <non...@netbsd.org> @@ -26,7 +26,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: lcdctl.c,v 1.1 2012/01/25 16:51:17 tsutsui Exp $"); +__KERNEL_RCSID(0, "$NetBSD: lcdctl.c,v 1.2 2012/01/27 14:48:22 tsutsui Exp $"); #include "ioexp.h" @@ -79,7 +79,6 @@ static void lcdctl_attach(device_t, devi CFATTACH_DECL_NEW(lcdctl, sizeof(struct lcdctl_softc), lcdctl_match, lcdctl_attach, NULL, NULL); -static int lcdctl_finalize(device_t); static void lcdctl_brightness_up(device_t); static void lcdctl_brightness_down(device_t); static void lcdctl_display_on(device_t); @@ -119,8 +118,10 @@ lcdctl_attach(device_t parent, device_t sc->sc_nbacklighttbl = __arraycount(lcdctl_backlight_c3000); sc->sc_backlighttbl = lcdctl_backlight_c3000; - /* schedule adjustment of LCD brightness after all devices are ready */ - config_finalize_register(self, lcdctl_finalize); + /* Start with approximately 40% of full brightness. */ + lcdctl_set_brightness(sc, 3); + + lcdctl_sc = sc; if (!pmf_event_register(self, PMFE_DISPLAY_BRIGHTNESS_UP, lcdctl_brightness_up, true)) @@ -136,19 +137,6 @@ lcdctl_attach(device_t parent, device_t aprint_error_dev(self, "couldn't register event handler\n"); } -static int -lcdctl_finalize(device_t dv) -{ - struct lcdctl_softc *sc = device_private(dv); - - /* Start with approximately 40% of full brightness. */ - lcdctl_set_brightness(sc, 3); - - lcdctl_sc = sc; - - return 0; -} - static void lcdctl_brightness_up(device_t dv) { Index: src/sys/arch/zaurus/dev/scoop.c diff -u src/sys/arch/zaurus/dev/scoop.c:1.9 src/sys/arch/zaurus/dev/scoop.c:1.10 --- src/sys/arch/zaurus/dev/scoop.c:1.9 Tue Jul 19 15:11:49 2011 +++ src/sys/arch/zaurus/dev/scoop.c Fri Jan 27 14:48:22 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: scoop.c,v 1.9 2011/07/19 15:11:49 dyoung Exp $ */ +/* $NetBSD: scoop.c,v 1.10 2012/01/27 14:48:22 tsutsui Exp $ */ /* $OpenBSD: zaurus_scoop.c,v 1.12 2005/11/17 05:26:31 uwe Exp $ */ /* @@ -18,7 +18,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: scoop.c,v 1.9 2011/07/19 15:11:49 dyoung Exp $"); +__KERNEL_RCSID(0, "$NetBSD: scoop.c,v 1.10 2012/01/27 14:48:22 tsutsui Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -58,6 +58,10 @@ static int scoop_gpio_pin_read(struct sc static void scoop_gpio_pin_write(struct scoop_softc *, int, int); static void scoop_gpio_pin_ctl(struct scoop_softc *, int, int); +static struct scoop_softc *backlight_sc; +static uint8_t backlight_on_init = 1; +static uint8_t backlight_cont_init = 0; + enum scoop_card { SD_CARD, CF_CARD /* socket 0 (external) */ @@ -108,9 +112,13 @@ scoopattach(device_t parent, device_t se if (ZAURUS_ISC3000 && sc->sc_dev->dv_unit == 1) { scoop_gpio_pin_ctl(sc, SCOOP1_AKIN_PULLUP, GPIO_PIN_OUTPUT); scoop_gpio_pin_write(sc, SCOOP1_AKIN_PULLUP, GPIO_PIN_LOW); + backlight_sc = sc; + scoop_set_backlight(backlight_on_init, backlight_cont_init); } else if (ZAURUS_ISC860) { scoop_gpio_pin_ctl(sc, SCOOP0_AKIN_PULLUP, GPIO_PIN_OUTPUT); scoop_gpio_pin_write(sc, SCOOP0_AKIN_PULLUP, GPIO_PIN_LOW); + backlight_sc = sc; + scoop_set_backlight(backlight_on_init, backlight_cont_init); } } @@ -161,25 +169,19 @@ scoop_gpio_pin_ctl(struct scoop_softc *s void scoop_set_backlight(int on, int cont) { - struct scoop_softc *sc; -#if 0 - struct scoop_softc *sc0; + struct scoop_softc *sc = backlight_sc; - sc0 = device_lookup_private(&scoop_cd, 0); -#endif - - sc = device_lookup_private(&scoop_cd, 1); - if (sc != NULL) { - /* C3000 */ - scoop_gpio_pin_write(sc, SCOOP1_BACKLIGHT_CONT, !cont); - scoop_gpio_pin_write(sc, SCOOP1_BACKLIGHT_ON, on); - } -#if 0 - else if (sc0 != NULL) { - scoop_gpio_pin_write(sc0, - SCOOP0_BACKLIGHT_CONT, cont); + if (sc == NULL) { + backlight_cont_init = cont; + backlight_on_init = on; + } else { + if (ZAURUS_ISC3000) { + scoop_gpio_pin_write(sc, SCOOP1_BACKLIGHT_CONT, !cont); + scoop_gpio_pin_write(sc, SCOOP1_BACKLIGHT_ON, on); + } else if (ZAURUS_ISC860) { + scoop_gpio_pin_write(sc, SCOOP0_BACKLIGHT_CONT, cont); + } } -#endif } /*