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)
This commit is contained in:
tsutsui 2012-01-27 14:48:22 +00:00
parent 3e9c4933e3
commit 63752ed247
2 changed files with 27 additions and 37 deletions

View File

@ -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 <nonaka@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, device_t, void *);
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 self, void *aux)
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 self, void *aux)
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)
{

View File

@ -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 scoop_softc *, int);
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 self, void *aux)
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 *sc, int pin, int flags)
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 (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);
}
}
#if 0
else if (sc0 != NULL) {
scoop_gpio_pin_write(sc0,
SCOOP0_BACKLIGHT_CONT, cont);
}
#endif
}
/*