/*-
* Copyright (c) 1999-2001
* Shin Takemura and PocketBSD Project. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the PocketBSD project
* and its contributors.
* 4. Neither the name of the project nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
/* Add a suspend hook to power saving */
sc->sc_powerstate = 0;
sc->sc_powerhook = powerhook_establish(device_xname(self),
sed1356_power, sc);
if (sc->sc_powerhook == NULL)
aprint_normal_dev(self, "WARNING: unable to establish power hook\n");
static void
sed1356_init_backlight(struct sed1356_softc *sc, int inattach)
{
int val = -1;
if (sc->sc_lcd_inited & BACKLIGHT_INITED)
return;
if (config_hook_call(CONFIG_HOOK_GET,
CONFIG_HOOK_POWER_LCDLIGHT, &val) != -1) {
/* we can get real light state */
VPRINTF(("sed1356_init_backlight: real backlight=%d\n", val));
if (val == 0)
sc->sc_powerstate &= ~PWRSTAT_BACKLIGHT;
else
sc->sc_powerstate |= PWRSTAT_BACKLIGHT;
sc->sc_lcd_inited |= BACKLIGHT_INITED;
} else if (inattach) {
/*
we cannot get real light state in attach time
because light device not yet attached.
we will retry in !inattach.
temporary assume light is on.
*/
sc->sc_powerstate |= PWRSTAT_BACKLIGHT;
} else {
/* we cannot get real light state, so work by myself state */
sc->sc_lcd_inited |= BACKLIGHT_INITED;
}
}
void
sed1356_init_brightness(struct sed1356_softc *sc, int inattach)
{
int val = -1;
if (sc->sc_lcd_inited & BRIGHTNESS_INITED)
return;
VPRINTF(("sed1356_init_brightness\n"));
if (config_hook_call(CONFIG_HOOK_GET,
CONFIG_HOOK_BRIGHTNESS_MAX, &val) != -1) {
/* we can get real brightness max */
VPRINTF(("sed1356_init_brightness: "
"real brightness max=%d\n", val));
sc->sc_max_brightness = val;
val = -1;
if (config_hook_call(CONFIG_HOOK_GET,
CONFIG_HOOK_BRIGHTNESS, &val) != -1) {
/* we can get real brightness */
VPRINTF(("sed1356_init_brightness: "
"real brightness=%d\n", val));
sc->sc_brightness_save = sc->sc_brightness = val;
} else {
sc->sc_brightness_save =
sc->sc_brightness = sc->sc_max_brightness;
}
sc->sc_lcd_inited |= BRIGHTNESS_INITED;
} else if (inattach) {
/*
* we cannot get real brightness in attach time
* because brightness device not yet attached.
* we will retry in !inattach.
*/
sc->sc_max_brightness = -1;
sc->sc_brightness = -1;
sc->sc_brightness_save = -1;
} else {
/* we cannot get real brightness */
sc->sc_lcd_inited |= BRIGHTNESS_INITED;
}
}
void
sed1356_init_contrast(struct sed1356_softc *sc, int inattach)
{
int val = -1;
if (sc->sc_lcd_inited & CONTRAST_INITED)
return;
VPRINTF(("sed1356_init_contrast\n"));
if (config_hook_call(CONFIG_HOOK_GET,
CONFIG_HOOK_CONTRAST_MAX, &val) != -1) {
/* we can get real contrast max */
VPRINTF(("sed1356_init_contrast: "
"real contrast max=%d\n", val));
sc->sc_max_contrast = val;
val = -1;
if (config_hook_call(CONFIG_HOOK_GET,
CONFIG_HOOK_CONTRAST, &val) != -1) {
/* we can get real contrast */
VPRINTF(("sed1356_init_contrast: "
"real contrast=%d\n", val));
sc->sc_contrast = val;
} else {
sc->sc_contrast = sc->sc_max_contrast;
}
sc->sc_lcd_inited |= CONTRAST_INITED;
} else if (inattach) {
/*
* we cannot get real contrast in attach time
* because contrast device not yet attached.
* we will retry in !inattach.
*/
sc->sc_max_contrast = -1;
sc->sc_contrast = -1;
} else {
/* we cannot get real contrast */
sc->sc_lcd_inited |= CONTRAST_INITED;
}
}