diff options
-rw-r--r-- | sys/arch/arm/arm/arm32_machdep.c | 52 | ||||
-rw-r--r-- | sys/arch/arm/include/cpu.h | 6 | ||||
-rw-r--r-- | sys/arch/zaurus/dev/zts.c | 97 |
3 files changed, 72 insertions, 83 deletions
diff --git a/sys/arch/arm/arm/arm32_machdep.c b/sys/arch/arm/arm/arm32_machdep.c index 0b9483bd5fb..09e5b559e0b 100644 --- a/sys/arch/arm/arm/arm32_machdep.c +++ b/sys/arch/arm/arm/arm32_machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: arm32_machdep.c,v 1.25 2007/05/26 20:56:49 drahn Exp $ */ +/* $OpenBSD: arm32_machdep.c,v 1.26 2007/05/29 21:09:43 robert Exp $ */ /* $NetBSD: arm32_machdep.c,v 1.42 2003/12/30 12:33:15 pk Exp $ */ /* @@ -119,16 +119,6 @@ int allowaperture = 0; /* Permit console keyboard to do a nice halt. */ int kbd_reset; int lid_suspend; - -/* Touch pad scaling disable flag and scaling parameters. */ -extern int zts_rawmode; -struct ztsscale { - int ts_minx; - int ts_maxx; - int ts_miny; - int ts_maxy; -}; -extern struct ztsscale zts_scale; extern int xscale_maxspeed; #endif @@ -424,7 +414,6 @@ cpu_sysctl(name, namelen, oldp, oldlenp, newp, newlen, p) return (sysctl_int(oldp, oldlenp, newp, newlen, &cpu_apmwarn)); #endif #if defined(__zaurus__) -#include "zts.h" case CPU_KBDRESET: if (securelevel > 0) return (sysctl_rdint(oldp, oldlenp, newp, @@ -447,45 +436,6 @@ cpu_sysctl(name, namelen, oldp, oldlenp, newp, newlen, p) pxa2x0_maxspeed(&xscale_maxspeed); return err; } - - case CPU_ZTSRAWMODE: -#if NZTS > 0 - return (sysctl_int(oldp, oldlenp, newp, newlen, - &zts_rawmode)); -#else - return (EINVAL); -#endif /* NZTS > 0 */ - case CPU_ZTSSCALE: - { - int err = EINVAL; -#if NZTS > 0 - struct ztsscale *p = newp; - struct ztsscale ts; - int s; - - if (!newp && newlen == 0) - return (sysctl_struct(oldp, oldlenp, 0, 0, - &zts_scale, sizeof zts_scale)); - - if (!(newlen == sizeof zts_scale && - p->ts_minx < p->ts_maxx && p->ts_miny < p->ts_maxy && - p->ts_minx >= 0 && p->ts_maxx >= 0 && - p->ts_miny >= 0 && p->ts_maxy >= 0 && - p->ts_minx < 32768 && p->ts_maxx < 32768 && - p->ts_miny < 32768 && p->ts_maxy < 32768)) - return (EINVAL); - - ts = zts_scale; - err = sysctl_struct(oldp, oldlenp, newp, newlen, - &ts, sizeof ts); - if (err == 0) { - s = splhigh(); - zts_scale = ts; - splx(s); - } -#endif /* NZTS > 0 */ - return (err); - } #endif default: diff --git a/sys/arch/arm/include/cpu.h b/sys/arch/arm/include/cpu.h index db0450d3b52..c39ad0d5ec6 100644 --- a/sys/arch/arm/include/cpu.h +++ b/sys/arch/arm/include/cpu.h @@ -1,4 +1,4 @@ -/* $OpenBSD: cpu.h,v 1.16 2007/05/14 07:07:09 art Exp $ */ +/* $OpenBSD: cpu.h,v 1.17 2007/05/29 21:09:43 robert Exp $ */ /* $NetBSD: cpu.h,v 1.34 2003/06/23 11:01:08 martin Exp $ */ /* @@ -62,8 +62,6 @@ #define CPU_ALLOWAPERTURE 6 /* int: allow mmap of /dev/xf86 */ #define CPU_APMWARN 7 /* APM battery warning percentage */ #define CPU_KBDRESET 8 /* int: console keyboard reset */ -#define CPU_ZTSRAWMODE 9 /* int: zts returns unscaled x/y */ -#define CPU_ZTSSCALE 10 /* struct: zts scaling parameters */ #define CPU_MAXSPEED 11 /* int: number of valid machdep ids */ #define CPU_LIDSUSPEND 12 /* int: closing lid causes suspend */ #define CPU_MAXID 13 /* number of valid machdep ids */ @@ -78,8 +76,6 @@ { "allowaperture", CTLTYPE_INT }, \ { "apmwarn", CTLTYPE_INT }, \ { "kbdreset", CTLTYPE_INT }, \ - { "ztsrawmode", CTLTYPE_INT }, \ - { "ztsscale", CTLTYPE_STRUCT }, \ { "maxspeed", CTLTYPE_INT }, \ { "lidsuspend", CTLTYPE_INT } \ } diff --git a/sys/arch/zaurus/dev/zts.c b/sys/arch/zaurus/dev/zts.c index 60b96acef80..af22ee16537 100644 --- a/sys/arch/zaurus/dev/zts.c +++ b/sys/arch/zaurus/dev/zts.c @@ -1,4 +1,4 @@ -/* $OpenBSD: zts.c,v 1.10 2007/04/10 22:37:17 miod Exp $ */ +/* $OpenBSD: zts.c,v 1.11 2007/05/29 21:09:43 robert Exp $ */ /* * Copyright (c) 2005 Dale Rahn <drahn@openbsd.org> * @@ -35,6 +35,12 @@ #include <arm/xscale/pxa2x0var.h> #include <arm/xscale/pxa2x0_lcd.h> +#ifdef ZTS_DEBUG +#define DPRINTF(x) do { printf x; } while (0) +#else +#define DPRINTF(x) +#endif + /* * ADS784x touch screen controller */ @@ -53,20 +59,14 @@ #define CCNT_HS_400_VGA_C3K 6250 /* 15.024us */ -/* XXX need to ask zaurus_lcd.c for the screen dimension */ -#define CURRENT_DISPLAY (&sharp_zaurus_C3000) -extern const struct lcd_panel_geometry sharp_zaurus_C3000; - -/* Settable via sysctl. */ -int zts_rawmode; -struct ztsscale { - int ts_minx; - int ts_maxx; - int ts_miny; - int ts_maxy; +struct tsscale { + int minx, maxx; + int miny, maxy; + int swapxy; + int resx, resy; } zts_scale = { /* C3000 */ - 209, 3620, 312, 3780 + 209, 3620, 312, 3780, 0, 640, 480 }; int zts_match(struct device *, void *, void *); @@ -88,8 +88,9 @@ struct zts_softc { struct device *sc_wsmousedev; int sc_oldx; int sc_oldy; - int sc_resx; - int sc_resy; + int sc_rawmode; + + struct tsscale sc_tsscale; }; struct cfattach zts_ca = { @@ -137,10 +138,10 @@ zts_attach(struct device *parent, struct device *self, void *aux) a.accessops = &zts_accessops; a.accesscookie = sc; printf("\n"); - - sc->sc_resx = CURRENT_DISPLAY->panel_height; - sc->sc_resy = CURRENT_DISPLAY->panel_width; + /* Copy the default scalue values to each softc */ + bcopy(&zts_scale, &sc->sc_tsscale, sizeof(sc->sc_tsscale)); + sc->sc_wsmousedev = config_found(self, &a, wsmousedevprint); } @@ -514,14 +515,14 @@ zts_irq(void *v) if (down) { zts_avgpos(&tp); - if (!zts_rawmode) { - struct ztsscale *tsp = &zts_scale; - + if (!sc->sc_rawmode) { /* Scale down to the screen resolution. */ - tp.x = ((tp.x - tsp->ts_minx) * sc->sc_resx) / - (tsp->ts_maxx - tsp->ts_minx); - tp.y = ((tp.y - tsp->ts_miny) * sc->sc_resy) / - (tsp->ts_maxy - tsp->ts_miny); + tp.x = ((tp.x - sc->sc_tsscale.minx) * + sc->sc_tsscale.resx) / + (sc->sc_tsscale.maxx - sc->sc_tsscale.minx); + tp.y = ((tp.y - sc->sc_tsscale.miny) * + sc->sc_tsscale.resy) / + (sc->sc_tsscale.maxy - sc->sc_tsscale.miny); } } @@ -542,6 +543,9 @@ zts_irq(void *v) } if (down || sc->sc_buttons != down) { + DPRINTF(("%s: tp.z = %d, tp.x = %d, tp.y = %d\n", + sc->sc_dev.dv_xname, tp.z, tp.x, tp.y)); + wsmouse_input(sc->sc_wsmousedev, down, tp.x, tp.y, 0 /* z */, 0 /* w */, WSMOUSE_INPUT_ABSOLUTE_X | WSMOUSE_INPUT_ABSOLUTE_Y | @@ -557,12 +561,51 @@ zts_irq(void *v) int zts_ioctl(void *v, u_long cmd, caddr_t data, int flag, struct proc *p) { + int error = 0; + struct zts_softc *sc = v; + struct wsmouse_calibcoords *wsmc = (struct wsmouse_calibcoords *)data; + + DPRINTF(("zts_ioctl(%d, '%c', %d)\n", + IOCPARM_LEN(cmd), IOCGROUP(cmd), cmd & 0xff)); switch (cmd) { + case WSMOUSEIO_SCALIBCOORDS: + if (!(wsmc->minx >= 0 && wsmc->maxx >= 0 && + wsmc->miny >= 0 && wsmc->maxy >= 0 && + wsmc->resx >= 0 && wsmc->resy >= 0 && + wsmc->minx < 32768 && wsmc->maxx < 32768 && + wsmc->miny < 32768 && wsmc->maxy < 32768 && + wsmc->resx < 32768 && wsmc->resy < 32768 && + wsmc->swapxy >= 0 && wsmc->swapxy <= 1 && + wsmc->samplelen >= 0 && wsmc->samplelen <= 1)) + return (EINVAL); + + sc->sc_tsscale.minx = wsmc->minx; + sc->sc_tsscale.maxx = wsmc->maxx; + sc->sc_tsscale.miny = wsmc->miny; + sc->sc_tsscale.maxy = wsmc->maxy; + sc->sc_tsscale.swapxy = wsmc->swapxy; + sc->sc_tsscale.resx = wsmc->resx; + sc->sc_tsscale.resy = wsmc->resy; + sc->sc_rawmode = wsmc->samplelen; + break; + case WSMOUSEIO_GCALIBCOORDS: + wsmc->minx = sc->sc_tsscale.minx; + wsmc->maxx = sc->sc_tsscale.maxx; + wsmc->miny = sc->sc_tsscale.miny; + wsmc->maxy = sc->sc_tsscale.maxy; + wsmc->swapxy = sc->sc_tsscale.swapxy; + wsmc->resx = sc->sc_tsscale.resx; + wsmc->resy = sc->sc_tsscale.resy; + wsmc->samplelen = sc->sc_rawmode; + break; case WSMOUSEIO_GTYPE: *(u_int *)data = WSMOUSE_TYPE_TPANEL; - return (0); + break; + default: + error = ENOTTY; + break; } - return (-1); + return (error); } |