Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch/hpcmips Add LCD and battery control support for Sha...
details: https://anonhg.NetBSD.org/src/rev/f993461f7d48
branches: trunk
changeset: 583334:f993461f7d48
user: nakayama <nakayama%NetBSD.org@localhost>
date: Sat Jul 30 22:40:33 2005 +0000
description:
Add LCD and battery control support for Sharp Telios series.
diffstat:
sys/arch/hpcmips/conf/GENERIC | 5 +-
sys/arch/hpcmips/conf/TX3922 | 6 +-
sys/arch/hpcmips/conf/files.hpcmips | 7 +-
sys/arch/hpcmips/dev/plumvideo.c | 154 +++++++++++++++-
sys/arch/hpcmips/dev/teliosio.c | 309 ++++++++++++++++++++++++++++++++++++
sys/arch/hpcmips/dev/teliosioreg.h | 55 ++++++
sys/arch/hpcmips/tx/tx39biureg.h | 5 +-
sys/arch/hpcmips/tx/tx39biuvar.h | 10 +-
sys/arch/hpcmips/tx/txcsbus.c | 25 ++-
9 files changed, 547 insertions(+), 29 deletions(-)
diffs (truncated from 805 to 300 lines):
diff -r 5be697bcaf99 -r f993461f7d48 sys/arch/hpcmips/conf/GENERIC
--- a/sys/arch/hpcmips/conf/GENERIC Sat Jul 30 21:15:51 2005 +0000
+++ b/sys/arch/hpcmips/conf/GENERIC Sat Jul 30 22:40:33 2005 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: GENERIC,v 1.171 2005/07/30 06:35:35 yamt Exp $
+# $NetBSD: GENERIC,v 1.172 2005/07/30 22:40:33 nakayama Exp $
#
# GENERIC machine description file
#
@@ -24,7 +24,7 @@
options INCLUDE_CONFIG_FILE # embed config file in kernel binary
-#ident "GENERIC-$Revision: 1.171 $"
+#ident "GENERIC-$Revision: 1.172 $"
maxusers 16
@@ -409,6 +409,7 @@
# Sharp Telios HC-AJ1/AJ2/AJ3, HC-VJ1C
#
txcsbus1 at tx39biu? platform SHARP_TELIOS
+teliosio* at txcsbus1 regcs 13 regcswidth 16
#optpoint* at tx39spi? slot 0
#wsmouse* at optpoint? mux 0
diff -r 5be697bcaf99 -r f993461f7d48 sys/arch/hpcmips/conf/TX3922
--- a/sys/arch/hpcmips/conf/TX3922 Sat Jul 30 21:15:51 2005 +0000
+++ b/sys/arch/hpcmips/conf/TX3922 Sat Jul 30 22:40:33 2005 +0000
@@ -1,7 +1,7 @@
#
# Distribution kernel (TOSHIBA TX3922 based model) kernel config file
#
-# $NetBSD: TX3922,v 1.65 2005/07/30 06:35:35 yamt Exp $
+# $NetBSD: TX3922,v 1.66 2005/07/30 22:40:33 nakayama Exp $
#
include "arch/hpcmips/conf/std.hpcmips"
@@ -159,6 +159,10 @@
m38813c* at txcsbus2 iocs 8 iocswidth 16 iocsbase 0 iocssize 8
hpckbd* at m38813c?
+# Sharp Telios LCD and battery control driver
+# register space: KUCS3
+teliosio* at txcsbus1 regcs 13 regcswidth 16
+
# TC6358TB(Plum2)
# register space: CS3,
# I/O space: MCS0 & MCS1, IRQ: 8:21 (IO[5] positive)
diff -r 5be697bcaf99 -r f993461f7d48 sys/arch/hpcmips/conf/files.hpcmips
--- a/sys/arch/hpcmips/conf/files.hpcmips Sat Jul 30 21:15:51 2005 +0000
+++ b/sys/arch/hpcmips/conf/files.hpcmips Sat Jul 30 22:40:33 2005 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: files.hpcmips,v 1.97 2005/05/04 07:54:39 hamajima Exp $
+# $NetBSD: files.hpcmips,v 1.98 2005/07/30 22:40:33 nakayama Exp $
# maxpartitions must be first item in files.${ARCH}.
maxpartitions 8
@@ -367,6 +367,11 @@
file dev/hpc/video_subr.c tx3912video | plumvideo
+# Sharp Telios LCD and battery control driver
+device teliosio
+attach teliosio at txcsbus
+file arch/hpcmips/dev/teliosio.c teliosio
+
#
# Real-time clock (not optional)
#
diff -r 5be697bcaf99 -r f993461f7d48 sys/arch/hpcmips/dev/plumvideo.c
--- a/sys/arch/hpcmips/dev/plumvideo.c Sat Jul 30 21:15:51 2005 +0000
+++ b/sys/arch/hpcmips/dev/plumvideo.c Sat Jul 30 22:40:33 2005 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: plumvideo.c,v 1.35 2004/12/12 21:03:06 abs Exp $ */
+/* $NetBSD: plumvideo.c,v 1.36 2005/07/30 22:40:33 nakayama Exp $ */
/*-
* Copyright (c) 1999-2002 The NetBSD Foundation, Inc.
@@ -37,7 +37,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: plumvideo.c,v 1.35 2004/12/12 21:03:06 abs Exp $");
+__KERNEL_RCSID(0, "$NetBSD: plumvideo.c,v 1.36 2005/07/30 22:40:33 nakayama Exp $");
#undef PLUMVIDEODEBUG
@@ -96,6 +96,10 @@
void *sc_powerhook; /* power management hook */
int sc_console;
+ int sc_backlight;
+ int sc_brightness;
+ int sc_max_brightness;
+
/* control register */
bus_space_tag_t sc_regt;
bus_space_handle_t sc_regh;
@@ -138,6 +142,9 @@
void __plumvideo_clut_access(struct plumvideo_softc *, u_int32_t *, int, int,
void (*)(bus_space_tag_t, bus_space_handle_t, u_int32_t *, int, int));
static void _flush_cache(void) __attribute__((__unused__)); /* !!! */
+static void plumvideo_init_backlight(struct plumvideo_softc *);
+static void plumvideo_backlight(struct plumvideo_softc *, int);
+static void plumvideo_brightness(struct plumvideo_softc *, int);
#ifdef PLUMVIDEODEBUG
void plumvideo_dump(struct plumvideo_softc*);
@@ -177,6 +184,9 @@
return;
}
+ /* initialize backlight and brightness values */
+ plumvideo_init_backlight(sc);
+
/* power control */
plumvideo_power(sc, 0, 0,
(void *)(console ? PWR_RESUME : PWR_SUSPEND));
@@ -426,6 +436,7 @@
struct hpcfb_fbconf *fbconf;
struct hpcfb_dspconf *dspconf;
struct wsdisplay_cmap *cmap;
+ struct wsdisplay_param *dispparam;
u_int8_t *r, *g, *b;
u_int32_t *rgb;
int idx, error;
@@ -490,6 +501,59 @@
plumvideo_clut_set(sc, rgb, idx, cnt);
goto out;
+ case WSDISPLAYIO_SVIDEO:
+ if (*(int *)data == WSDISPLAYIO_VIDEO_OFF)
+ plumvideo_backlight(sc, 0);
+ else
+ plumvideo_backlight(sc, 1);
+ return 0;
+
+ case WSDISPLAYIO_GVIDEO:
+ *(int *)data = sc->sc_backlight ?
+ WSDISPLAYIO_VIDEO_ON : WSDISPLAYIO_VIDEO_OFF;
+ return 0;
+
+ case WSDISPLAYIO_GETPARAM:
+ dispparam = (struct wsdisplay_param *)data;
+ switch (dispparam->param) {
+ case WSDISPLAYIO_PARAM_BACKLIGHT:
+ dispparam->min = 0;
+ dispparam->max = 1;
+ dispparam->curval = sc->sc_backlight;
+ break;
+ case WSDISPLAYIO_PARAM_BRIGHTNESS:
+ if (sc->sc_max_brightness <= 0)
+ return EINVAL;
+ dispparam->min = 0;
+ dispparam->max = sc->sc_max_brightness;
+ dispparam->curval = sc->sc_brightness;
+ break;
+ default:
+ return EINVAL;
+ }
+ return 0;
+
+ case WSDISPLAYIO_SETPARAM:
+ dispparam = (struct wsdisplay_param * )data;
+ switch (dispparam->param) {
+ case WSDISPLAYIO_PARAM_BACKLIGHT:
+ if (dispparam->curval < 0 || 1 < dispparam->curval)
+ return EINVAL;
+ plumvideo_backlight(sc, dispparam->curval);
+ break;
+ case WSDISPLAYIO_PARAM_BRIGHTNESS:
+ if (sc->sc_max_brightness <= 0)
+ return EINVAL;
+ if (dispparam->curval < 0 ||
+ sc->sc_max_brightness < dispparam->curval)
+ return EINVAL;
+ plumvideo_brightness(sc, dispparam->curval);
+ break;
+ default:
+ return EINVAL;
+ }
+ return 0;
+
case HPCFBIO_GCONF:
fbconf = (struct hpcfb_fbconf *)data;
if (fbconf->hf_conf_index != 0 &&
@@ -701,9 +765,6 @@
plumvideo_power(void *ctx, int type, long id, void *msg)
{
struct plumvideo_softc *sc = ctx;
- plum_chipset_tag_t pc = sc->sc_pc;
- bus_space_tag_t regt = sc->sc_regt;
- bus_space_handle_t regh = sc->sc_regh;
int why = (int)msg;
switch (why) {
@@ -713,29 +774,88 @@
DPRINTF(("%s: ON\n", sc->sc_dev.dv_xname));
/* power on */
- /* LCD power on and display on */
- plum_power_establish(pc, PLUM_PWR_LCD);
- /* back-light on */
- plum_power_establish(pc, PLUM_PWR_BKL);
- plum_conf_write(regt, regh, PLUM_VIDEO_PLLUM_REG,
- PLUM_VIDEO_PLLUM_MAX);
+ plumvideo_backlight(sc, 1);
break;
case PWR_SUSPEND:
/* FALLTHROUGH */
case PWR_STANDBY:
DPRINTF(("%s: OFF\n", sc->sc_dev.dv_xname));
- /* back-light off */
- plum_conf_write(regt, regh, PLUM_VIDEO_PLLUM_REG,
- PLUM_VIDEO_PLLUM_MIN);
- plum_power_disestablish(pc, PLUM_PWR_BKL);
- /* power down */
- plum_power_disestablish(pc, PLUM_PWR_LCD);
+ /* power off */
+ plumvideo_backlight(sc, 0);
break;
}
return (0);
}
+static void
+plumvideo_init_backlight(struct plumvideo_softc *sc)
+{
+ int val;
+
+ val = -1;
+ if (config_hook_call(CONFIG_HOOK_GET,
+ CONFIG_HOOK_POWER_LCDLIGHT, &val) != -1) {
+ /* we can get real backlight state */
+ sc->sc_backlight = val;
+ }
+
+ val = -1;
+ if (config_hook_call(CONFIG_HOOK_GET,
+ CONFIG_HOOK_BRIGHTNESS_MAX, &val) != -1) {
+ /* we can get real brightness max */
+ sc->sc_max_brightness = val;
+
+ val = -1;
+ if (config_hook_call(CONFIG_HOOK_GET,
+ CONFIG_HOOK_BRIGHTNESS, &val) != -1) {
+ /* we can get real brightness */
+ sc->sc_brightness = val;
+ } else {
+ sc->sc_brightness = sc->sc_max_brightness;
+ }
+ }
+}
+
+static void
+plumvideo_backlight(struct plumvideo_softc *sc, int on)
+{
+ plum_chipset_tag_t pc = sc->sc_pc;
+ bus_space_tag_t regt = sc->sc_regt;
+ bus_space_handle_t regh = sc->sc_regh;
+
+ sc->sc_backlight = on;
+ if (on) {
+ /* LCD on */
+ plum_power_establish(pc, PLUM_PWR_LCD);
+ /* backlight on */
+ plum_power_establish(pc, PLUM_PWR_BKL);
+ plum_conf_write(regt, regh, PLUM_VIDEO_PLLUM_REG,
+ PLUM_VIDEO_PLLUM_MAX);
+ } else {
+ /* backlight off */
+ plum_conf_write(regt, regh, PLUM_VIDEO_PLLUM_REG,
+ PLUM_VIDEO_PLLUM_MIN);
+ plum_power_disestablish(pc, PLUM_PWR_BKL);
+ /* LCD off */
+ plum_power_disestablish(pc, PLUM_PWR_LCD);
+ }
+ /* call machine dependent backlight control */
+ config_hook_call(CONFIG_HOOK_SET,
+ CONFIG_HOOK_POWER_LCDLIGHT, (void *)on);
+}
+
+static void
+plumvideo_brightness(struct plumvideo_softc *sc, int val)
+{
+
+ sc->sc_brightness = val;
+ /* call machine dependent brightness control */
+ if (sc->sc_backlight)
+ config_hook_call(CONFIG_HOOK_SET,
+ CONFIG_HOOK_BRIGHTNESS, &val);
+}
+
#ifdef PLUMVIDEODEBUG
void
plumvideo_dump(struct plumvideo_softc *sc)
diff -r 5be697bcaf99 -r f993461f7d48 sys/arch/hpcmips/dev/teliosio.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
Home |
Main Index |
Thread Index |
Old Index