Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/hpcmips VR41xx's PIU (Touch panel I/F unit) suport.



details:   https://anonhg.NetBSD.org/src/rev/4e9b33a8f47b
branches:  trunk
changeset: 479941:4e9b33a8f47b
user:      takemura <takemura%NetBSD.org@localhost>
date:      Tue Dec 28 03:15:16 1999 +0000

description:
VR41xx's PIU (Touch panel I/F unit) suport.
Currently it emulates relative pointing device like mouse, but it should
behave like an absolute pointing device. It needs more works in wsmouse side.

diffstat:

 sys/arch/hpcmips/conf/GENERIC       |   16 +-
 sys/arch/hpcmips/conf/files.hpcmips |    7 +-
 sys/arch/hpcmips/vr/icureg.h        |    4 +-
 sys/arch/hpcmips/vr/mra.c           |  111 +++++++
 sys/arch/hpcmips/vr/vrip.c          |    4 +-
 sys/arch/hpcmips/vr/vrpiu.c         |  554 ++++++++++++++++++++++++++++++++++++
 sys/arch/hpcmips/vr/vrpiureg.h      |  156 ++++++++++
 sys/arch/hpcmips/vr/vrpiuvar.h      |   53 +++
 8 files changed, 892 insertions(+), 13 deletions(-)

diffs (truncated from 987 to 300 lines):

diff -r 95a917331276 -r 4e9b33a8f47b sys/arch/hpcmips/conf/GENERIC
--- a/sys/arch/hpcmips/conf/GENERIC     Tue Dec 28 02:54:51 1999 +0000
+++ b/sys/arch/hpcmips/conf/GENERIC     Tue Dec 28 03:15:16 1999 +0000
@@ -2,7 +2,7 @@
 # Distribution kernel (any  model) kernel config file
 
 #
-#      $NetBSD: GENERIC,v 1.18 1999/12/23 06:26:08 takemura Exp $
+#      $NetBSD: GENERIC,v 1.19 1999/12/28 03:15:16 takemura Exp $
 #
 include                "arch/hpcmips/conf/std.hpcmips"
 
@@ -101,13 +101,6 @@
 #options       FONT_VT220L8x8
 options        FONT_VT220L8x10
 
-# Workstation Console attachments
-fb*            at      mainbus0
-wsdisplay*     at      fb?
-wskbd*         at      vrkiu? mux 1
-#wsmouse*      at      pms? mux 0
-
-
 vrip*  at mainbus0
 vrcmu* at vrip? addr 0x0b000060 size 0x20
 vrbcu* at vrip? addr 0x0b000000 size 0x20
@@ -119,6 +112,13 @@
 vrgiu* at vrip? addr 0x0b000100 size 0x20 intr 8
 vrpmu* at vrip? addr 0x0b0000a0 size 0x20 intr 1 # power switch
 vrdsu* at vrip? addr 0x0b0000e0 size 0x08
+vrpiu* at vrip? addr 0x0b000120 size 0x1a0 intr 5
+
+# Workstation Console attachments
+fb*            at      mainbus0
+wsdisplay*     at      fb?
+wskbd*         at      vrkiu? mux 1
+wsmouse*       at      vrpiu? mux 0
 
 #
 # MC-R300
diff -r 95a917331276 -r 4e9b33a8f47b sys/arch/hpcmips/conf/files.hpcmips
--- a/sys/arch/hpcmips/conf/files.hpcmips       Tue Dec 28 02:54:51 1999 +0000
+++ b/sys/arch/hpcmips/conf/files.hpcmips       Tue Dec 28 03:15:16 1999 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: files.hpcmips,v 1.12 1999/12/23 06:26:08 takemura Exp $
+#      $NetBSD: files.hpcmips,v 1.13 1999/12/28 03:15:17 takemura Exp $
 
 # maxpartitions must be first item in files.${ARCH}.
 maxpartitions 8
@@ -146,6 +146,11 @@
 attach vrdsu at vrip
 file arch/hpcmips/vr/vrdsu.c                   vrdsu needs-flag
 
+device vrpiu: wsmousedev
+attach vrpiu at vrip
+file arch/hpcmips/vr/vrpiu.c                   vrpiu
+file arch/hpcmips/vr/mra.c                     vrpiu
+
 #
 #      TOSHIBA TX3912/3922
 #
diff -r 95a917331276 -r 4e9b33a8f47b sys/arch/hpcmips/vr/icureg.h
--- a/sys/arch/hpcmips/vr/icureg.h      Tue Dec 28 02:54:51 1999 +0000
+++ b/sys/arch/hpcmips/vr/icureg.h      Tue Dec 28 03:15:16 1999 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: icureg.h,v 1.1.1.1 1999/09/16 12:23:32 takemura Exp $  */
+/*     $NetBSD: icureg.h,v 1.2 1999/12/28 03:15:17 takemura Exp $      */
 
 /*-
  * Copyright (c) 1999 Shin Takemura. All rights reserved.
@@ -60,7 +60,7 @@
 #define SYSINT1_BAT                    (1<<0)  /* Battery intr */
 
 
-#define PIUINT_REG_W           0x002   /* Level2 PIU intr reg */
+#define ICUPIUINT_REG_W                0x002   /* Level2 PIU intr reg */
 #define MPIUINT_REG_W          0x00e   /* Level2 Mask PIU intr reg */
 
 #define                PIUINT_PADCMD           (1<<6)  /* PIU command scan intr */
diff -r 95a917331276 -r 4e9b33a8f47b sys/arch/hpcmips/vr/mra.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/arch/hpcmips/vr/mra.c Tue Dec 28 03:15:16 1999 +0000
@@ -0,0 +1,111 @@
+/*     $NetBSD: mra.c,v 1.1 1999/12/28 03:15:18 takemura Exp $ */
+
+/*
+ * Copyright (c) 1999 Shin Takemura All rights reserved.
+ * Copyright (c) 1999 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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.
+ *
+ */
+
+#include <sys/param.h>
+#include <sys/systm.h>
+
+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));
+
+/*
+ * multiple regression analysis
+ * Y = AX1 + BX2 + C
+ */
+int
+mra_Y_AX1_BX2_C(y, ys, x1, x1s, x2, x2s, n, scale, a, b, c)
+       int *y, ys, *x1, x1s, *x2, x2s, n, scale, *a, *b, *c;
+{
+       int i;
+       int64_t X1a, X2a, Ya;
+       int64_t X1X1s, X2X2s, X1X2s;
+       int64_t YYs, X1Ys, X2Ys;
+       int64_t S11, S22, S12;
+       int64_t SYY, S1Y, S2Y;
+       int64_t A, B, C, M;
+#define AA(p, s, i)    (*((long*)(((char*)(p)) + (s) * (i))))
+#define X1(i)          AA(x1, x1s, i)
+#define X2(i)          AA(x2, x2s, i)
+#define Y(i)           AA(y, ys, i)
+
+       /*
+        * get avarage and sum
+        */
+       X1a = 0;        X2a = 0;        Ya = 0;
+       X1X1s = 0;      X2X2s = 0;      X1X2s = 0;
+       X1Ys = 0;       X2Ys = 0;       YYs = 0;
+       for (i = 0; i < n; i++) {
+               X1a += X1(i);
+               X2a += X2(i);
+               Ya += Y(i);
+
+               X1X1s += X1(i) * X1(i);
+               X2X2s += X2(i) * X2(i);
+               X1X2s += X1(i) * X2(i);
+
+               X1Ys += X1(i) * Y(i);
+               X2Ys += X2(i) * Y(i);
+               YYs += Y(i) * Y(i);
+       }
+       X1a /= n;       X2a /= n;       Ya /= n;
+
+       S11 = X1X1s - n * X1a * X1a;
+       S22 = X2X2s - n * X2a * X2a;
+       S12 = X1X2s - n * X1a * X2a;
+
+       SYY = YYs - n * Ya * Ya;
+       S1Y = X1Ys - n * X1a * Ya;
+       S2Y = X2Ys - n * X2a * Ya;
+
+#if 0
+       printf("X1a=%d X2a=%d Ya=%d\n", (int)X1a, (int)X2a, (int)Ya);
+       printf("X1X1s=%d X2X2s=%d X1X2s=%d\n", (int)X1X1s, (int)X2X2s, (int)X1X2s);
+       printf("X1Ys=%d X2Ys=%d YYs=%d\n", (int)X1Ys, (int)X2Ys, (int)YYs);
+       printf("S11=%d S22=%d S12=%d\n", (int)S11, (int)S22, (int)S12);
+       printf("SYY=%d S1Y=%d S2Y=%d\n", (int)SYY, (int)S1Y, (int)S2Y);
+#endif
+
+       M = (S11 * S22 - S12 * S12);
+       if (M == 0) {
+               /* error */
+               return -1;
+       }
+
+       A = (S1Y * S22 - S2Y * S12) * scale / M;
+       B = (S2Y * S11 - S1Y * S12) * scale / M;
+       C = Ya - (A * X1a + B * X2a) / scale;
+
+#if 0
+       printf("A=%d B=%d C=%d\n", (int)A, (int)B, (int)C);
+#endif
+       *a = A;
+       *b = B;
+       *c = C;
+
+       return (0);
+}
diff -r 95a917331276 -r 4e9b33a8f47b sys/arch/hpcmips/vr/vrip.c
--- a/sys/arch/hpcmips/vr/vrip.c        Tue Dec 28 02:54:51 1999 +0000
+++ b/sys/arch/hpcmips/vr/vrip.c        Tue Dec 28 03:15:16 1999 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: vrip.c,v 1.3 1999/12/23 06:26:10 takemura Exp $        */
+/*     $NetBSD: vrip.c,v 1.4 1999/12/28 03:15:18 takemura Exp $        */
 
 /*-
  * Copyright (c) 1999
@@ -82,7 +82,7 @@
        bus_addr_t      ih_hreg;
        bus_addr_t      ih_mhreg;
 } intrhand[MAX_LEVEL1] = {
-       [5] = { 0, 0, 0, 0, PIUINT_REG_W,       MPIUINT_REG_W   },
+       [5] = { 0, 0, 0, 0, ICUPIUINT_REG_W,    MPIUINT_REG_W   },
        [6] = { 0, 0, 0, 0, AIUINT_REG_W,       MAIUINT_REG_W   },
        [7] = { 0, 0, 0, 0, KIUINT_REG_W,       MKIUINT_REG_W   },
        [8] = { 0, 0, 0, 0, GIUINT_L_REG_W,     MGIUINT_L_REG_W, GIUINT_H_REG_W,        MGIUINT_H_REG_W },
diff -r 95a917331276 -r 4e9b33a8f47b sys/arch/hpcmips/vr/vrpiu.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/arch/hpcmips/vr/vrpiu.c       Tue Dec 28 03:15:16 1999 +0000
@@ -0,0 +1,554 @@
+/*     $NetBSD: vrpiu.c,v 1.1 1999/12/28 03:15:18 takemura Exp $       */
+
+/*
+ * Copyright (c) 1999 Shin Takemura All rights reserved.
+ * Copyright (c) 1999 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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.
+ *
+ */
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/device.h>
+#include <sys/kernel.h>
+
+#include <dev/wscons/wsconsio.h>
+#include <dev/wscons/wsmousevar.h>
+
+#include <machine/bus.h>
+
+#include <hpcmips/vr/vripvar.h>
+#include <hpcmips/vr/cmureg.h>
+#include <hpcmips/vr/vrpiuvar.h>
+#include <hpcmips/vr/vrpiureg.h>
+
+/*
+ * contant and macro definitions
+ */
+#define VRPIUDEBUG
+#ifdef VRPIUDEBUG
+int    vrpiu_debug = 0;
+#define        DPRINTF(arg) if (vrpiu_debug) printf arg;
+#else
+#define        DPRINTF(arg)
+#endif
+
+#define SCALE  (1024*1024)
+
+/*
+ * data types
+ */
+/* struct vrpiu_softc is defined in vrpiuvar.h */
+
+/*
+ * function prototypes
+ */
+static int     vrpiumatch __P((struct device *, struct cfdata *, void *));
+static void    vrpiuattach __P((struct device *, struct device *, void *));
+
+static void    vrpiu_write __P((struct vrpiu_softc *, int, unsigned short));
+static u_short vrpiu_read __P((struct vrpiu_softc *, int));
+
+static int     vrpiu_intr __P((void *));
+static void    vrpiu_reset_param __P((struct vrpiu_softc *sc));
+static void    vrpiu_timeout __P((void *));
+#ifdef DEBUG
+static void    vrpiu_dump_cntreg __P((unsigned int cmd));
+#endif
+
+static int     vrpiu_enable __P((void *));
+static int     vrpiu_ioctl __P((void *, u_long, caddr_t, int, struct proc *));
+static void    vrpiu_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,



Home | Main Index | Thread Index | Old Index