Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/hpcmips TX3912 touch panel support



details:   https://anonhg.NetBSD.org/src/rev/7d2bcb98e6b1
branches:  trunk
changeset: 480285:7d2bcb98e6b1
user:      uch <uch%NetBSD.org@localhost>
date:      Sat Jan 08 21:07:02 2000 +0000

description:
TX3912 touch panel support
        TX3912 SIB module + ADC part of UCB1200 (companion chip of TX3912)

diffstat:

 sys/arch/hpcmips/conf/TX3912      |    6 +-
 sys/arch/hpcmips/dev/ucb1200.c    |  756 ++++++++++++++++++++++++++++++++++++++
 sys/arch/hpcmips/dev/ucb1200reg.h |  140 +++++++
 sys/arch/hpcmips/dev/ucb1200var.h |  107 +++++
 sys/arch/hpcmips/tx/tx39sib.c     |  288 ++++++++++++++
 sys/arch/hpcmips/tx/tx39sibreg.h  |  248 ++++++++++++
 sys/arch/hpcmips/tx/tx39sibvar.h  |   37 +
 7 files changed, 1579 insertions(+), 3 deletions(-)

diffs (truncated from 1628 to 300 lines):

diff -r d4dc8e6027ac -r 7d2bcb98e6b1 sys/arch/hpcmips/conf/TX3912
--- a/sys/arch/hpcmips/conf/TX3912      Sat Jan 08 20:46:29 2000 +0000
+++ b/sys/arch/hpcmips/conf/TX3912      Sat Jan 08 21:07:02 2000 +0000
@@ -2,7 +2,7 @@
 # Distribution kernel (TX3912 based model) kernel config file
 
 #
-#      $NetBSD: TX3912,v 1.4 2000/01/07 15:19:14 uch Exp $
+#      $NetBSD: TX3912,v 1.5 2000/01/08 21:07:04 uch Exp $
 #
 include                "arch/hpcmips/conf/std.hpcmips"
 
@@ -91,13 +91,13 @@
 it8368e*       at      txcsbus? regcs 2 regcsbase 0 regcssize 0x20 regcswidth 16 iocs 8 iocsbase 0 iocssize 0x4000000 iocswidth 16 irq1 161 irq2 168 irq3 98
 
 # PHILIPS UCB1200 modem/audio analog front-end
-#ucb*          at      tx39sib? slot 0
+ucb*           at      tx39sib? slot 0
 
 # WS console uses SUN or VT100 terminal emulation
 fb*            at      tx3912video?
 wsdisplay*     at      fb?
 wskbd*         at      skbd? mux 1
-#wsmouse*      at      ucb? mux 0
+wsmouse*       at      ucb? mux 0
 
 options        WSEMUL_VT100
 options        WSDISPLAY_DEFAULTSCREENS=4
diff -r d4dc8e6027ac -r 7d2bcb98e6b1 sys/arch/hpcmips/dev/ucb1200.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/arch/hpcmips/dev/ucb1200.c    Sat Jan 08 21:07:02 2000 +0000
@@ -0,0 +1,756 @@
+/*     $NetBSD: ucb1200.c,v 1.1 2000/01/08 21:07:04 uch Exp $ */
+
+/*
+ * Copyright (c) 2000, by UCHIYAMA Yasushi
+ * 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. The name of the developer may NOT 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.
+ *
+ */
+
+/*
+ * Device driver for PHILIPS UCB1200 Advanced modem/audio analog front-end
+ */
+#define UCB1200DEBUG
+
+#include "opt_tx39_debug.h"
+#include "opt_use_poll.h"
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/device.h>
+
+#include <machine/bus.h>
+#include <machine/intr.h>
+#include <machine/bootinfo.h> /* bootinfo */
+
+#include <dev/wscons/wsconsio.h>
+#include <dev/wscons/wsmousevar.h>
+
+#include <hpcmips/tx/tx39var.h>
+#include <hpcmips/tx/tx39sibvar.h>
+#include <hpcmips/tx/tx39sibreg.h>
+#include <hpcmips/tx/tx39icureg.h>
+
+#include <hpcmips/tx/tx3912videovar.h> /* debug */
+
+#include <hpcmips/dev/ucb1200var.h>
+#include <hpcmips/dev/ucb1200reg.h>
+
+#ifdef UCB1200DEBUG
+int    ucb1200_debug = 1;
+#define        DPRINTF(arg) if (ucb1200_debug) printf arg;
+#define        DPRINTFN(n, arg) if (ucb1200_debug > (n)) printf arg;
+#else
+#define        DPRINTF(arg)
+#endif
+
+int    ucb1200_match   __P((struct device*, struct cfdata*, void*));
+void   ucb1200_attach  __P((struct device*, struct device*, void*));
+int    ucb1200_idcheck __P((bus_space_tag_t));
+
+void   ucb1200_dump __P((struct ucb1200_softc*));
+int    ucb1200_sibintr __P((void*));
+int    ucb1200_poll __P((void*));
+
+int    ucb1200_adc_async __P((void*));
+int    ucb1200_input __P((struct ucb1200_softc*));
+
+void   ucb1200_intr_ack_sync __P((struct ucb1200_softc*));
+int    ucb1200_adc_sync __P((struct ucb1200_softc*, int, int*));
+
+int    ucb_ts_enable __P((void*));
+int    ucb_ts_ioctl __P((void*, u_long, caddr_t, int, struct proc*));
+void   ucb_ts_disable __P((void*));
+
+/* mra is defined in mra.c */
+int mra_Y_AX1_BX2_C __P((int *y, int ys, int *x1, int x1s, int *x2, int x2s,
+                        int n, int scale, int *a, int *b, int *c));
+
+struct cfattach ucb_ca = {
+       sizeof(struct ucb1200_softc), ucb1200_match, ucb1200_attach
+};
+
+const struct wsmouse_accessops ucb_ts_accessops = {
+       ucb_ts_enable,
+       ucb_ts_ioctl,
+       ucb_ts_disable,
+};
+
+/* 
+ * XXX currently no calibration method. this is temporary hack.
+ */
+#include <machine/platid.h>
+#define NSAMPLE        5
+
+struct calibration_sample *calibration_sample_lookup __P((void));
+int    ucb1200_tp_calibration __P((struct ucb1200_softc*));
+
+struct calibration_sample {
+       int cs_xraw, cs_yraw, cs_x, cs_y;       
+};
+
+struct calibration_sample_table {
+       platid_t        cst_platform;
+       struct calibration_sample cst_sample[NSAMPLE];
+} calibration_sample_table[] = {
+       {{{PLATID_WILD, PLATID_MACH_COMPAQ_C_8XX}},  /* uch machine */
+        {{ 507, 510, 320, 120 },
+         { 898, 757,  40,  40 },
+         { 900, 255,  40, 200 },
+         { 109, 249, 600, 200 },
+         { 110, 753, 600,  40 }}},
+       
+       {{{PLATID_WILD, PLATID_MACH_COMPAQ_C_2010}}, /* uch machine */
+        {{ 506, 487, 320, 120 },
+         { 880, 250,  40,  40 },
+         { 880, 718,  40, 200 },
+         { 140, 726, 600, 200 },
+         { 137, 250, 600,  40 }}},
+        
+       {{{PLATID_WILD, PLATID_MACH_SHARP_MOBILON_HC4100}}, /* uch machine */
+        {{ 497, 501, 320, 120 },
+         { 752, 893,  40,  40 },
+         { 242, 891,  40, 200 },
+         { 241, 115, 600, 200 },
+         { 747, 101, 600,  40 }}},
+       
+       {{{PLATID_UNKNOWN, PLATID_UNKNOWN}}, 
+        {{0, 0, 0, 0}, 
+         {0, 0, 0, 0}, 
+         {0, 0, 0, 0}, 
+         {0, 0, 0, 0}, 
+         {0, 0, 0, 0}}},
+};
+
+struct calibration_sample*
+calibration_sample_lookup()
+{
+       struct calibration_sample_table *tab;
+       platid_mask_t mask;
+       
+       for (tab = calibration_sample_table; 
+            tab->cst_platform.dw.dw1 != PLATID_UNKNOWN; tab++) {
+
+               mask = PLATID_DEREF(&tab->cst_platform);                
+               
+               if (platid_match(&platid, &mask)) {
+                       return tab->cst_sample;
+               }
+       }
+       
+       return 0;
+}
+
+int
+ucb1200_tp_calibration(sc)
+       struct ucb1200_softc *sc;
+{
+#define SCALE  (1024*1024)
+       struct calibration_sample *cs;
+       int s, n;
+
+       tx3912video_calibration_pattern();
+
+       sc->sc_prmxs = bootinfo->fb_width;
+       sc->sc_prmys = bootinfo->fb_height;
+       sc->sc_maxx = bootinfo->fb_width - 1;
+       sc->sc_maxy = bootinfo->fb_height - 1;
+
+       if (!(cs = calibration_sample_lookup())) {
+               printf(": no calibration data\n");
+               return 1;
+       }
+
+       s = sizeof(struct calibration_sample);
+       n = NSAMPLE;
+       
+       if (mra_Y_AX1_BX2_C(&cs->cs_x, s, &cs->cs_xraw, s, &cs->cs_yraw, s,
+                           n, SCALE, &sc->sc_prmax, &sc->sc_prmbx,
+                           &sc->sc_prmcx) ||
+           mra_Y_AX1_BX2_C(&cs->cs_y, s, &cs->cs_xraw, s, &cs->cs_yraw, s,
+                           n, SCALE, &sc->sc_prmay,
+                           &sc->sc_prmby, &sc->sc_prmcy)) {
+               printf(": MRA error");
+
+               return 1;
+       } else {
+               DPRINTF((": Ax=%d Bx=%d Cx=%d",
+                        sc->sc_prmax, sc->sc_prmbx, sc->sc_prmcx));
+               DPRINTF((" Ay=%d By=%d Cy=%d\n",
+                        sc->sc_prmay, sc->sc_prmby, sc->sc_prmcy));
+       }
+       
+       return 0;
+}
+
+int
+ucb1200_match(parent, cf, aux)
+       struct device *parent;
+       struct cfdata *cf;
+       void *aux;
+{
+       struct txsib_attach_args *sa = aux;
+       
+       if (sa->sa_slot != 0) /* UCB1200 must be subframe 0 */
+               return 0;
+
+       return txsibsf0_reg_read(sa->sa_tc, UCB1200_ID_REG) == UCB1200_ID 
+               ? 1 : 0;
+}
+
+void
+ucb1200_attach(parent, self, aux)
+       struct device *parent;
+       struct device *self;
+       void *aux;
+{
+       struct txsib_attach_args *sa = aux;
+       struct ucb1200_softc *sc = (void*)self;
+       struct wsmousedev_attach_args wsmaa;
+
+       sc->sc_tc = sa->sa_tc;
+       sc->sc_parent = parent;
+       
+       tx_intr_establish(sc->sc_tc, 
+                         MAKEINTR(1, TX39_INTRSTATUS1_SIBIRQPOSINT),
+                         IST_EDGE, IPL_TTY, ucb1200_sibintr, sc);
+
+       ucb1200_tp_calibration(sc);
+#ifdef UCB1200DEBUG    
+       ucb1200_dump(sc);
+#endif
+
+       wsmaa.accessops = &ucb_ts_accessops;
+       wsmaa.accesscookie = sc;
+
+       printf("\n");
+
+       /*
+        * attach the wsmouse
+        */
+       sc->sc_wsmousedev = config_found(self, &wsmaa, wsmousedevprint);
+}
+
+int
+ucb1200_poll(arg)
+       void *arg;
+{
+       struct ucb1200_softc *sc = arg; 
+       
+       if (sc->sm_state != UCBADC_IDLE) {
+               printf("%s: %s busy\n", sc->sc_dev.dv_xname, 
+                      sc->sc_parent->dv_xname);
+               return POLL_CONT;
+       }
+
+       if (sc->sc_polling_finish) {
+               sc->sc_polling_finish = 0;
+               return POLL_END;
+       }



Home | Main Index | Thread Index | Old Index