Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/arch/zaurus Reorganlization zlcd(4) and ztp(4) device at...



details:   https://anonhg.NetBSD.org/src/rev/9920483398b3
branches:  trunk
changeset: 773039:9920483398b3
user:      tsutsui <tsutsui%NetBSD.org@localhost>
date:      Wed Jan 25 16:51:17 2012 +0000

description:
Reorganlization zlcd(4) and ztp(4) device attachments from nonaka@:
 - ztp depends on zssp so attach ztp at zssp rather than pxaip
 - split LCD backlight controls from zlcd(4) into new lcdctl device
   to share it among forthcoming SL-C7x0 variants

diffstat:

 sys/arch/zaurus/conf/GENERIC      |    5 +-
 sys/arch/zaurus/conf/INSTALL      |    4 +-
 sys/arch/zaurus/conf/files.zaurus |   11 +-
 sys/arch/zaurus/dev/lcdctl.c      |  341 ++++++++++++++++++++++++++++++++++++++
 sys/arch/zaurus/dev/lcdctlvar.h   |   36 ++++
 sys/arch/zaurus/dev/zkbd.c        |   17 +-
 sys/arch/zaurus/dev/zlcd.c        |  275 ++----------------------------
 sys/arch/zaurus/dev/zlcdvar.h     |   11 +-
 sys/arch/zaurus/dev/zssp.c        |   53 +++++-
 sys/arch/zaurus/dev/zsspvar.h     |    6 +-
 sys/arch/zaurus/dev/ztp.c         |   24 +-
 sys/arch/zaurus/zaurus/machdep.c  |    5 +-
 12 files changed, 495 insertions(+), 293 deletions(-)

diffs (truncated from 1168 to 300 lines):

diff -r f6e18471dfbb -r 9920483398b3 sys/arch/zaurus/conf/GENERIC
--- a/sys/arch/zaurus/conf/GENERIC      Wed Jan 25 16:48:44 2012 +0000
+++ b/sys/arch/zaurus/conf/GENERIC      Wed Jan 25 16:51:17 2012 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: GENERIC,v 1.48 2011/12/18 05:49:33 dholland Exp $
+#      $NetBSD: GENERIC,v 1.49 2012/01/25 16:51:17 tsutsui Exp $
 #
 # GENERIC machine description file
 #
@@ -209,7 +209,7 @@
 zssp0 at pxaip?
 
 # touchpad
-ztp0 at pxaip?
+ztp0 at zssp?
 wsmouse* at ztp? mux 0
 
 # keyboard
@@ -224,6 +224,7 @@
 lcd0 at pxaip?
 options        PXA2X0_LCD_WRITETHROUGH
 wsdisplay* at lcd? console ?
+lcdctl0 at zssp0
 
 # WM8750 Audio
 zaudio0 at iic? addr 0x1b
diff -r f6e18471dfbb -r 9920483398b3 sys/arch/zaurus/conf/INSTALL
--- a/sys/arch/zaurus/conf/INSTALL      Wed Jan 25 16:48:44 2012 +0000
+++ b/sys/arch/zaurus/conf/INSTALL      Wed Jan 25 16:51:17 2012 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: INSTALL,v 1.11 2011/11/19 17:17:41 nonaka Exp $
+# $NetBSD: INSTALL,v 1.12 2012/01/25 16:51:17 tsutsui Exp $
 #
 # INSTALL config file (GENERIC with memory disk root)
 #
@@ -49,7 +49,7 @@
 
 no zrc0 at pxaip?
 
-no ztp0 at pxaip?
+no ztp0 at zssp?
 no wsmouse* at ztp?
 
 no zaudio0 at iic?
diff -r f6e18471dfbb -r 9920483398b3 sys/arch/zaurus/conf/files.zaurus
--- a/sys/arch/zaurus/conf/files.zaurus Wed Jan 25 16:48:44 2012 +0000
+++ b/sys/arch/zaurus/conf/files.zaurus Wed Jan 25 16:51:17 2012 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: files.zaurus,v 1.9 2011/06/19 16:20:09 nonaka Exp $
+#      $NetBSD: files.zaurus,v 1.10 2012/01/25 16:51:17 tsutsui Exp $
 #
 # Sharp Zaurus specific configuration info
 #
@@ -67,7 +67,7 @@
 file arch/zaurus/dev/ioexp.c           ioexp needs-flag
 
 # Dedicated SSP unit for ADC, touch screen, and backlight
-device zssp
+device zssp {}
 attach zssp at pxaip
 file arch/zaurus/dev/zssp.c            zssp
 
@@ -75,6 +75,11 @@
 attach lcd at pxaip with zlcd
 file arch/zaurus/dev/zlcd.c            zlcd
 
+# backlight, brightness Controller
+device lcdctl
+attach lcdctl at zssp
+file arch/zaurus/dev/lcdctl.c          lcdctl needs-flag
+
 # GPIO keyboard
 device zkbd: wskbddev
 attach zkbd at pxaip
@@ -82,7 +87,7 @@
 
 # Zaurus touchpad
 device ztp: wsmousedev, hpctpanel
-attach ztp at pxaip
+attach ztp at zssp
 file arch/zaurus/dev/ztp.c             ztp
 
 # WM8750 audio
diff -r f6e18471dfbb -r 9920483398b3 sys/arch/zaurus/dev/lcdctl.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/arch/zaurus/dev/lcdctl.c      Wed Jan 25 16:51:17 2012 +0000
@@ -0,0 +1,341 @@
+/*     $NetBSD: lcdctl.c,v 1.1 2012/01/25 16:51:17 tsutsui Exp $       */
+
+/*-
+ * Copyright (C) 2012 NONAKA Kimihiro <nonaka%netbsd.org@localhost>
+ * 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 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.
+ */
+
+#include <sys/cdefs.h>
+__KERNEL_RCSID(0, "$NetBSD: lcdctl.c,v 1.1 2012/01/25 16:51:17 tsutsui Exp $");
+
+#include "ioexp.h"
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/device.h>
+#include <sys/bus.h>
+
+#include <dev/wscons/wsconsio.h>
+#include <dev/wscons/wsdisplayvar.h>
+
+#include <zaurus/zaurus/zaurus_var.h>
+#include <zaurus/dev/lcdctlvar.h>
+#include <zaurus/dev/zsspvar.h>
+#include <zaurus/dev/scoopvar.h>
+#include <zaurus/dev/ioexpvar.h>
+
+struct lcdctl_backlight {
+       int     duty;           /* LZ9JG18 DAC value */
+       int     cont;           /* BACKLIGHT_CONT signal */
+       int     on;             /* BACKLIGHT_ON signal */
+};
+
+struct lcdctl_softc {
+       device_t        sc_dev;
+
+       int             sc_brightness;
+       int             sc_brightnesscurval;
+       bool            sc_islit;
+       bool            sc_isblank;
+
+       int             sc_nbacklighttbl;
+       const struct lcdctl_backlight *sc_backlighttbl;
+};
+
+/* for SL-C1000/SL-C3x00 */
+static const struct lcdctl_backlight lcdctl_backlight_c3000[] = {
+       { 0x00, 0,  0 },        /* 0:  Off */
+       { 0x00, 0,  1 },        /* 1:   0% */
+       { 0x01, 0,  1 },        /* 2:  20% */
+       { 0x07, 0,  1 },        /* 3:  40% */
+       { 0x01, 1,  1 },        /* 4:  60% */
+       { 0x07, 1,  1 },        /* 5:  80% */
+       { 0x11, 1,  1 }         /* 6: 100% */
+};
+
+static int     lcdctl_match(device_t, cfdata_t, void *);
+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);
+static void lcdctl_display_off(device_t);
+
+static void lcdctl_set_brightness(struct lcdctl_softc *, int);
+static void lcdctl_set_blank(struct lcdctl_softc *, bool);
+static void lcdctl_set_backlight(struct lcdctl_softc *, bool);
+
+static struct lcdctl_softc *lcdctl_sc;
+
+static int
+lcdctl_match(device_t parent, cfdata_t cf, void *aux)
+{
+       struct zssp_attach_args *aa = aux;
+
+       if (strcmp("lcdctl", aa->zaa_name))
+               return 0;
+
+       return 1;
+}
+
+static void
+lcdctl_attach(device_t parent, device_t self, void *aux)
+{
+       struct lcdctl_softc *sc = device_private(self);
+
+       sc->sc_dev = self;
+
+       aprint_normal("\n");
+       aprint_naive("\n");
+
+       sc->sc_brightness = sc->sc_brightnesscurval = 1;
+       sc->sc_islit = true;
+       sc->sc_isblank = false;
+
+       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);
+
+       if (!pmf_event_register(self, PMFE_DISPLAY_BRIGHTNESS_UP,
+           lcdctl_brightness_up, true))
+               aprint_error_dev(self, "couldn't register event handler\n");
+       if (!pmf_event_register(self, PMFE_DISPLAY_BRIGHTNESS_DOWN,
+           lcdctl_brightness_down, true))
+               aprint_error_dev(self, "couldn't register event handler\n");
+       if (!pmf_event_register(self, PMFE_DISPLAY_ON,
+           lcdctl_display_on, true))
+               aprint_error_dev(self, "couldn't register event handler\n");
+       if (!pmf_event_register(self, PMFE_DISPLAY_OFF,
+           lcdctl_display_off, true))
+               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)
+{
+       struct lcdctl_softc *sc = device_private(dv);
+
+       lcdctl_set_brightness(sc, sc->sc_brightness + 1);
+}
+
+static void
+lcdctl_brightness_down(device_t dv)
+{
+       struct lcdctl_softc *sc = device_private(dv);
+
+       lcdctl_set_brightness(sc, sc->sc_brightness - 1);
+}
+
+static void
+lcdctl_display_on(device_t dv)
+{
+       struct lcdctl_softc *sc = device_private(dv);
+
+       lcdctl_set_blank(sc, false);
+       lcdctl_set_backlight(sc, true);
+}
+
+static void
+lcdctl_display_off(device_t dv)
+{
+       struct lcdctl_softc *sc = device_private(dv);
+
+       lcdctl_set_backlight(sc, false);
+       lcdctl_set_blank(sc, true);
+}
+
+static __inline void
+set_backlight(const struct lcdctl_backlight *bl)
+{
+
+       (void) zssp_ic_send(ZSSP_IC_LZ9JG18, bl->duty);
+       if (ZAURUS_ISC1000)
+               ioexp_set_backlight(bl->on, bl->cont);
+       else
+               scoop_set_backlight(bl->on, bl->cont);
+}
+
+static void
+lcdctl_set_brightness_internal(struct lcdctl_softc *sc, int newval)
+{
+       int i;
+
+       /*
+        * It appears that the C3000 backlight can draw too much power if we
+        * switch it from a low to a high brightness.  Increasing brightness
+        * in steps avoids this issue.
+        */
+       if (newval > sc->sc_brightnesscurval) {
+               for (i = sc->sc_brightnesscurval + 1; i <= newval; i++) {
+                       set_backlight(&sc->sc_backlighttbl[i]);
+                       delay(5000);
+               }
+       } else
+               set_backlight(&sc->sc_backlighttbl[newval]);



Home | Main Index | Thread Index | Old Index