1 /* $NetBSD: j6x0tp.c,v 1.11 2006/05/23 01:34:49 uwe Exp $ */ 2 3 /* 4 * Copyright (c) 2003 Valeriy E. Ushakov 5 * All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions 9 * are met: 10 * 1. Redistributions of source code must retain the above copyright 11 * notice, this list of conditions and the following disclaimer. 12 * 2. Redistributions in binary form must reproduce the above copyright 13 * notice, this list of conditions and the following disclaimer in the 14 * documentation and/or other materials provided with the distribution. 15 * 3. The name of the author may not be used to endorse or promote products 16 * derived from this software without specific prior written permission 17 * 18 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 19 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 20 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 21 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 22 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 23 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 27 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 */ 29 30 #include <sys/cdefs.h> 31 __KERNEL_RCSID(0, "$NetBSD: j6x0tp.c,v 1.11 2006/05/23 01:34:49 uwe Exp $"); 32 33 #include <sys/param.h> 34 #include <sys/kernel.h> 35 #include <sys/device.h> 36 #include <sys/malloc.h> 37 #include <sys/systm.h> 38 #include <sys/callout.h> 39 #ifdef GPROF 40 #include <sys/gmon.h> 41 #endif 42 43 #include "opt_j6x0tp.h" 44 45 #include <dev/wscons/wsconsio.h> 46 #include <dev/wscons/wsmousevar.h> 47 #include <dev/wscons/wskbdvar.h> 48 #include <dev/wscons/wsksymvar.h> 49 #include <dev/wscons/wsksymdef.h> 50 #include <dev/hpc/hpctpanelvar.h> 51 52 #include <machine/platid.h> 53 #include <machine/platid_mask.h> 54 55 #include <machine/intr.h> 56 57 #include <sh3/exception.h> 58 #include <sh3/intcreg.h> 59 #include <sh3/pfcreg.h> 60 #include <sh3/adcreg.h> 61 62 #include <sh3/dev/adcvar.h> 63 64 65 #define J6X0TP_DEBUG 66 #if 0 /* XXX: disabled in favor of local version that uses printf_nolog */ 67 #define DPRINTF_ENABLE 68 #define DPRINTF_DEBUG j6x0tp_debug 69 #define DPRINTF_LEVEL 0 70 #include <machine/debug.h> 71 #else 72 #ifdef J6X0TP_DEBUG 73 volatile int j6x0tp_debug = 0; 74 #define DPRINTF_PRINTF printf_nolog 75 #define DPRINTF(arg) if (j6x0tp_debug) DPRINTF_PRINTF arg 76 #define DPRINTFN(n, arg) if (j6x0tp_debug > (n)) DPRINTF_PRINTF arg 77 #else 78 #define DPRINTF(arg) ((void)0) 79 #define DPRINTFN(n, arg) ((void)0) 80 #endif 81 #endif 82 83 84 /* 85 * PFC bits pertinent to Jornada 6x0 touchpanel 86 */ 87 #define PHDR_TP_PEN_DOWN 0x08 88 89 #define SCPDR_TP_SCAN_ENABLE 0x20 90 #define SCPDR_TP_SCAN_Y 0x02 91 #define SCPDR_TP_SCAN_X 0x01 92 93 /* 94 * A/D converter channels to get x/y from 95 */ 96 #define ADC_CHANNEL_TP_Y 1 97 #define ADC_CHANNEL_TP_X 2 98 99 /* 100 * Default (read: my device :) raw X/Y values for framebuffer edges. 101 * XXX: defopt these? 102 */ 103 #define J6X0TP_FB_LEFT 38 104 #define J6X0TP_FB_RIGHT 950 105 #define J6X0TP_FB_TOP 80 106 #define J6X0TP_FB_BOTTOM 900 107 108 /* 109 * Bottom of the n'th hard icon (n = 1..4) 110 */ 111 #define J6X0TP_HARD_ICON_MAX_Y(n) \ 112 (J6X0TP_FB_TOP + ((J6X0TP_FB_BOTTOM - J6X0TP_FB_TOP) / 4) * (n)) 113 114 115 struct j6x0tp_softc { 116 struct device sc_dev; 117 118 #define J6X0TP_WSMOUSE_ENABLED 0x01 119 #define J6X0TP_WSKBD_ENABLED 0x02 120 int sc_enabled; 121 122 int sc_hard_icon; 123 124 struct callout sc_touch_ch; 125 126 struct device *sc_wsmousedev; 127 struct device *sc_wskbddev; 128 129 struct tpcalib_softc sc_tpcalib; /* calibration info for wsmouse */ 130 }; 131 132 133 /* config machinery */ 134 static int j6x0tp_match(struct device *, struct cfdata *, void *); 135 static void j6x0tp_attach(struct device *, struct device *, void *); 136 137 /* wsmouse accessops */ 138 static int j6x0tp_wsmouse_enable(void *); 139 static int j6x0tp_wsmouse_ioctl(void *, u_long, caddr_t, int, 140 struct lwp *); 141 static void j6x0tp_wsmouse_disable(void *); 142 143 /* wskbd accessops */ 144 static int j6x0tp_wskbd_enable(void *, int); 145 static void j6x0tp_wskbd_set_leds(void *, int); 146 static int j6x0tp_wskbd_ioctl(void *, u_long, caddr_t, int, 147 struct lwp *); 148 149 /* internal driver routines */ 150 static void j6x0tp_enable(struct j6x0tp_softc *); 151 static void j6x0tp_disable(struct j6x0tp_softc *); 152 static int j6x0tp_set_enable(struct j6x0tp_softc *, int, int); 153 static int j6x0tp_intr(void *); 154 static void j6x0tp_start_polling(void *); 155 static void j6x0tp_stop_polling(struct j6x0tp_softc *); 156 static void j6x0tp_callout_wsmouse(void *); 157 static void j6x0tp_callout_wskbd(void *); 158 static void j6x0tp_wsmouse_input(struct j6x0tp_softc *, int, int); 159 static void j6x0tp_get_raw_xy(int *, int *); 160 static int j6x0tp_get_hard_icon(int, int); 161 162 163 static const struct wsmouse_accessops j6x0tp_accessops = { 164 j6x0tp_wsmouse_enable, 165 j6x0tp_wsmouse_ioctl, 166 j6x0tp_wsmouse_disable 167 }; 168 169 static const struct wsmouse_calibcoords j6x0tp_default_calib = { 170 0, 0, 639, 239, 171 4, 172 {{ J6X0TP_FB_LEFT, J6X0TP_FB_TOP, 0, 0 }, 173 { J6X0TP_FB_RIGHT, J6X0TP_FB_TOP, 639, 0 }, 174 { J6X0TP_FB_LEFT, J6X0TP_FB_BOTTOM, 0, 239 }, 175 { J6X0TP_FB_RIGHT, J6X0TP_FB_BOTTOM, 639, 239 }} 176 }; 177 178 static const struct wskbd_accessops j6x0tp_wskbd_accessops = { 179 j6x0tp_wskbd_enable, 180 j6x0tp_wskbd_set_leds, 181 j6x0tp_wskbd_ioctl 182 }; 183 184 185 #ifndef J6X0TP_SETTINGS_ICON_KEYSYM 186 #define J6X0TP_SETTINGS_ICON_KEYSYM KS_Home 187 #endif 188 #ifndef J6X0TP_PGUP_ICON_KEYSYM 189 #define J6X0TP_PGUP_ICON_KEYSYM KS_Prior 190 #endif 191 #ifndef J6X0TP_PGDN_ICON_KEYSYM 192 #define J6X0TP_PGDN_ICON_KEYSYM KS_Next 193 #endif 194 #ifndef J6X0TP_SWITCH_ICON_KEYSYM 195 #define J6X0TP_SWITCH_ICON_KEYSYM KS_End 196 #endif 197 198 static const keysym_t j6x0tp_wskbd_keydesc[] = { 199 KS_KEYCODE(1), J6X0TP_SETTINGS_ICON_KEYSYM, 200 KS_KEYCODE(2), J6X0TP_PGUP_ICON_KEYSYM, 201 KS_KEYCODE(3), J6X0TP_PGDN_ICON_KEYSYM, 202 KS_KEYCODE(4), J6X0TP_SWITCH_ICON_KEYSYM 203 }; 204 205 static const struct wscons_keydesc j6x0tp_wskbd_keydesctab[] = { 206 { KB_US, 0, 207 sizeof(j6x0tp_wskbd_keydesc)/sizeof(keysym_t), 208 j6x0tp_wskbd_keydesc 209 }, 210 {0, 0, 0, 0} 211 }; 212 213 static const struct wskbd_mapdata j6x0tp_wskbd_keymapdata = { 214 j6x0tp_wskbd_keydesctab, KB_US 215 }; 216 217 218 CFATTACH_DECL(j6x0tp, sizeof(struct j6x0tp_softc), 219 j6x0tp_match, j6x0tp_attach, NULL, NULL); 220 221 222 static int 223 j6x0tp_match(struct device *parent, struct cfdata *cf, void *aux) 224 { 225 226 /* 227 * XXX: platid_mask_MACH_HP_LX also matches 360LX. It's not 228 * confirmed whether touch panel in 360LX is connected this 229 * way. We may need to regroup platid masks. 230 */ 231 if (!platid_match(&platid, &platid_mask_MACH_HP_JORNADA_6XX) 232 && !platid_match(&platid, &platid_mask_MACH_HP_LX)) 233 return (0); 234 235 if (strcmp(cf->cf_name, "j6x0tp") != 0) 236 return (0); 237 238 return (1); 239 } 240 241 242 /* 243 * Attach the touch panel driver and its ws* children. 244 * 245 * Note that we have to use submatch to distinguish between children 246 * because ws{kbd,mouse}_match match unconditionally. 247 */ 248 static void 249 j6x0tp_attach(struct device *parent, struct device *self, void *aux) 250 { 251 struct j6x0tp_softc *sc = (struct j6x0tp_softc *)self; 252 struct wsmousedev_attach_args wsma; 253 struct wskbddev_attach_args wska; 254 255 printf("\n"); 256 257 sc->sc_enabled = 0; 258 sc->sc_hard_icon = 0; 259 260 /* touch-panel as a pointing device */ 261 wsma.accessops = &j6x0tp_accessops; 262 wsma.accesscookie = sc; 263 264 sc->sc_wsmousedev = config_found_ia(self, "wsmousedev", &wsma, 265 wsmousedevprint); 266 if (sc->sc_wsmousedev == NULL) 267 return; 268 269 /* on-screen "hard icons" as a keyboard device */ 270 wska.console = 0; 271 wska.keymap = &j6x0tp_wskbd_keymapdata; 272 wska.accessops = &j6x0tp_wskbd_accessops; 273 wska.accesscookie = sc; 274 275 sc->sc_wskbddev = config_found_ia(self, "wskbddev", &wska, 276 wskbddevprint); 277 278 /* init calibration, set default parameters */ 279 tpcalib_init(&sc->sc_tpcalib); 280 tpcalib_ioctl(&sc->sc_tpcalib, WSMOUSEIO_SCALIBCOORDS, 281 (caddr_t)__UNCONST(&j6x0tp_default_calib), 0, 0); 282 283 /* used when in polling mode */ 284 callout_init(&sc->sc_touch_ch); 285 286 /* establish interrupt handler, but disable until opened */ 287 intc_intr_establish(SH7709_INTEVT2_IRQ3, IST_EDGE, IPL_TTY, 288 j6x0tp_intr, sc); 289 intc_intr_disable(SH7709_INTEVT2_IRQ3); 290 } 291 292 293 /* 294 * Enable touch panel: we start in interrupt mode. 295 * Must be called as spltty(). 296 */ 297 static void 298 j6x0tp_enable(struct j6x0tp_softc *sc) 299 { 300 301 DPRINTFN(2, ("%s: enable\n", sc->sc_dev.dv_xname)); 302 intc_intr_enable(SH7709_INTEVT2_IRQ3); 303 } 304 305 306 /* 307 * Disable touch panel: disable interrupt, cancel pending callout. 308 * Must be called as spltty(). 309 */ 310 static void 311 j6x0tp_disable(struct j6x0tp_softc *sc) 312 { 313 314 DPRINTFN(2, ("%s: disable\n", sc->sc_dev.dv_xname)); 315 intc_intr_disable(SH7709_INTEVT2_IRQ3); 316 callout_stop(&sc->sc_touch_ch); 317 } 318 319 320 static int 321 j6x0tp_set_enable(struct j6x0tp_softc *sc, int on, int child) 322 { 323 int s = spltty(); 324 325 if (on) { 326 if (!sc->sc_enabled) 327 j6x0tp_enable(sc); 328 sc->sc_enabled |= child; 329 } else { 330 sc->sc_enabled &= ~child; 331 if (!sc->sc_enabled) 332 j6x0tp_disable(sc); 333 } 334 335 splx(s); 336 return (0); 337 } 338 339 340 static int 341 j6x0tp_wsmouse_enable(void *self) 342 { 343 struct j6x0tp_softc *sc = (struct j6x0tp_softc *)self; 344 345 DPRINTFN(1, ("%s: wsmouse enable\n", sc->sc_dev.dv_xname)); 346 return (j6x0tp_set_enable(sc, 1, J6X0TP_WSMOUSE_ENABLED)); 347 } 348 349 350 static void 351 j6x0tp_wsmouse_disable(void *self) 352 { 353 struct j6x0tp_softc *sc = (struct j6x0tp_softc *)self; 354 355 DPRINTFN(1, ("%s: wsmouse disable\n", sc->sc_dev.dv_xname)); 356 j6x0tp_set_enable(sc, 0, J6X0TP_WSMOUSE_ENABLED); 357 } 358 359 360 static int 361 j6x0tp_wskbd_enable(void *self, int on) 362 { 363 struct j6x0tp_softc *sc = (struct j6x0tp_softc *)self; 364 365 DPRINTFN(1, ("%s: wskbd %sable\n", sc->sc_dev.dv_xname, 366 on ? "en" : "dis")); 367 return (j6x0tp_set_enable(sc, on, J6X0TP_WSKBD_ENABLED)); 368 } 369 370 371 static int 372 j6x0tp_intr(void *self) 373 { 374 struct j6x0tp_softc *sc = (struct j6x0tp_softc *)self; 375 376 uint8_t irr0; 377 uint8_t phdr, touched; 378 unsigned int steady, tremor_timeout; 379 380 irr0 = _reg_read_1(SH7709_IRR0); 381 if ((irr0 & IRR0_IRQ3) == 0) { 382 #ifdef DIAGNOSTIC 383 printf("%s: irr0 %02x?\n", sc->sc_dev.dv_xname, irr0); 384 #endif 385 return (0); 386 } 387 388 if (!sc->sc_enabled) { 389 DPRINTFN(1, ("%s: intr: !sc_enabled\n", sc->sc_dev.dv_xname)); 390 intc_intr_disable(SH7709_INTEVT2_IRQ3); 391 goto served; 392 } 393 394 395 /* 396 * Number of times the "touched" bit should be read 397 * consecutively. 398 */ 399 # define TREMOR_THRESHOLD 0x300 400 401 steady = 0; 402 tremor_timeout = TREMOR_THRESHOLD * 16; /* XXX: arbitrary */ 403 touched = PHDR_TP_PEN_DOWN; /* we start with "touched" state */ 404 405 do { 406 phdr = _reg_read_1(SH7709_PHDR); 407 408 if ((phdr & PHDR_TP_PEN_DOWN) == touched) 409 ++steady; 410 else { 411 steady = 0; 412 touched = phdr & PHDR_TP_PEN_DOWN; 413 } 414 415 if (--tremor_timeout == 0) { 416 DPRINTF(("%s: tremor timeout!\n", 417 sc->sc_dev.dv_xname)); 418 goto served; 419 } 420 } while (steady < TREMOR_THRESHOLD); 421 422 if (touched) { 423 intc_intr_disable(SH7709_INTEVT2_IRQ3); 424 425 /* 426 * ADC readings are not stable yet, so schedule 427 * callout instead of accessing ADC from the interrupt 428 * handler only to immediately delay(). 429 */ 430 callout_reset(&sc->sc_touch_ch, hz/32, 431 j6x0tp_start_polling, sc); 432 } else 433 DPRINTFN(1, ("%s: tremor\n", sc->sc_dev.dv_xname)); 434 served: 435 /* clear the interrupt (XXX: protect access?) */ 436 _reg_write_1(SH7709_IRR0, irr0 & ~IRR0_IRQ3); 437 438 return (1); 439 } 440 441 442 /* 443 * Called from the interrupt handler at spltty() upon first touch. 444 * Decide if we are going to report this touch as a mouse click/drag 445 * or as a key press. 446 */ 447 static void 448 j6x0tp_start_polling(void *self) 449 { 450 struct j6x0tp_softc *sc = (struct j6x0tp_softc *)self; 451 uint8_t phdr; 452 int do_mouse, do_kbd; 453 int rawx, rawy; 454 int icon; 455 456 phdr = _reg_read_1(SH7709_PHDR); 457 if ((phdr & PHDR_TP_PEN_DOWN) == 0) { 458 DPRINTFN(2, ("%s: start: pen is not down\n", 459 sc->sc_dev.dv_xname)); 460 j6x0tp_stop_polling(sc); 461 } 462 463 j6x0tp_get_raw_xy(&rawx, &rawy); 464 DPRINTFN(2, ("%s: start: %4d %4d -> ", 465 sc->sc_dev.dv_xname, rawx, rawy)); 466 467 do_mouse = sc->sc_enabled & J6X0TP_WSMOUSE_ENABLED; 468 #ifdef J6X0TP_WSMOUSE_EXCLUSIVE 469 if (do_mouse) 470 do_kbd = 0; 471 else 472 #endif 473 do_kbd = sc->sc_enabled & J6X0TP_WSKBD_ENABLED; 474 475 icon = 0; 476 if (do_kbd) 477 icon = j6x0tp_get_hard_icon(rawx, rawy); 478 479 if (icon != 0) { 480 DPRINTFN(2, ("icon %d\n", icon)); 481 sc->sc_hard_icon = icon; 482 wskbd_input(sc->sc_wskbddev, WSCONS_EVENT_KEY_DOWN, icon); 483 callout_reset(&sc->sc_touch_ch, hz/32, 484 j6x0tp_callout_wskbd, sc); 485 } else if (do_mouse) { 486 DPRINTFN(2, ("mouse\n")); 487 j6x0tp_wsmouse_input(sc, rawx, rawy); 488 callout_reset(&sc->sc_touch_ch, hz/32, 489 j6x0tp_callout_wsmouse, sc); 490 } else { 491 DPRINTFN(2, ("ignore\n")); 492 j6x0tp_stop_polling(sc); 493 } 494 } 495 496 497 /* 498 * Re-enable touch panel interrupt. 499 * Called as spltty() when polling code detects pen-up. 500 */ 501 static void 502 j6x0tp_stop_polling(struct j6x0tp_softc *sc) 503 { 504 uint8_t irr0; 505 506 DPRINTFN(2, ("%s: stop\n", sc->sc_dev.dv_xname)); 507 508 /* clear pending interrupt signal before re-enabling the interrupt */ 509 irr0 = _reg_read_1(SH7709_IRR0); 510 if ((irr0 & IRR0_IRQ3) != 0) 511 _reg_write_1(SH7709_IRR0, irr0 & ~IRR0_IRQ3); 512 513 intc_intr_enable(SH7709_INTEVT2_IRQ3); 514 } 515 516 517 /* 518 * We are reporting this touch as a keyboard event. 519 * Poll touch screen waiting for pen-up. 520 */ 521 static void 522 j6x0tp_callout_wskbd(void *self) 523 { 524 struct j6x0tp_softc *sc = (struct j6x0tp_softc *)self; 525 uint8_t phdr; 526 int s; 527 528 s = spltty(); 529 530 if (!sc->sc_enabled) { 531 DPRINTFN(1, ("%s: wskbd callout: !sc_enabled\n", 532 sc->sc_dev.dv_xname)); 533 splx(s); 534 return; 535 } 536 537 phdr = _reg_read_1(SH7709_PHDR); 538 if ((phdr & PHDR_TP_PEN_DOWN) != 0) { 539 /* 540 * Pen is still down, continue polling. Wskbd's 541 * auto-repeat takes care of repeating the key. 542 */ 543 callout_schedule(&sc->sc_touch_ch, hz/32); 544 } else { 545 wskbd_input(sc->sc_wskbddev, 546 WSCONS_EVENT_KEY_UP, sc->sc_hard_icon); 547 j6x0tp_stop_polling(sc); 548 } 549 splx(s); 550 } 551 552 553 /* 554 * We are reporting this touch as a mouse click/drag. 555 */ 556 static void 557 j6x0tp_callout_wsmouse(void *self) 558 { 559 struct j6x0tp_softc *sc = (struct j6x0tp_softc *)self; 560 uint8_t phdr; 561 int rawx, rawy; 562 int s; 563 564 s = spltty(); 565 566 if (!sc->sc_enabled) { 567 DPRINTFN(1, ("%s: wsmouse callout: !sc_enabled\n", 568 sc->sc_dev.dv_xname)); 569 splx(s); 570 return; 571 } 572 573 phdr = _reg_read_1(SH7709_PHDR); 574 if ((phdr & PHDR_TP_PEN_DOWN) != 0) { 575 j6x0tp_get_raw_xy(&rawx, &rawy); 576 j6x0tp_wsmouse_input(sc, rawx, rawy); /* mouse dragged */ 577 callout_schedule(&sc->sc_touch_ch, hz/32); 578 } else { 579 wsmouse_input(sc->sc_wsmousedev, 0, 0, 0, 0, /* button up */ 580 WSMOUSE_INPUT_DELTA); 581 j6x0tp_stop_polling(sc); 582 } 583 splx(s); 584 } 585 586 587 /* 588 * Report mouse click/drag. 589 */ 590 static void 591 j6x0tp_wsmouse_input(struct j6x0tp_softc *sc, int rawx, int rawy) 592 { 593 int x, y; 594 595 tpcalib_trans(&sc->sc_tpcalib, rawx, rawy, &x, &y); 596 597 DPRINTFN(3, ("%s: %4d %4d -> %3d %3d\n", 598 sc->sc_dev.dv_xname, rawx, rawy, x, y)); 599 600 wsmouse_input(sc->sc_wsmousedev, 601 1, /* button */ 602 x, y, 603 0, /* flags */ 604 WSMOUSE_INPUT_ABSOLUTE_X | WSMOUSE_INPUT_ABSOLUTE_Y); 605 } 606 607 608 /* 609 * Read raw X/Y coordinates from the ADC. 610 * XXX: protect accesses to SCPDR? 611 */ 612 static void 613 j6x0tp_get_raw_xy(int *rawxp, int *rawyp) 614 { 615 uint8_t scpdr; 616 617 /* Y axis */ 618 scpdr = _reg_read_1(SH7709_SCPDR); 619 scpdr |= SCPDR_TP_SCAN_ENABLE; 620 scpdr &= ~SCPDR_TP_SCAN_Y; /* pull low to scan */ 621 _reg_write_1(SH7709_SCPDR, scpdr); 622 delay(10); 623 624 *rawyp = adc_sample_channel(ADC_CHANNEL_TP_Y); 625 626 /* X axis */ 627 scpdr = _reg_read_1(SH7709_SCPDR); 628 scpdr |= SCPDR_TP_SCAN_Y; 629 scpdr &= ~SCPDR_TP_SCAN_X; /* pull low to scan */ 630 _reg_write_1(SH7709_SCPDR, scpdr); 631 delay(10); 632 633 *rawxp = adc_sample_channel(ADC_CHANNEL_TP_X); 634 635 /* restore SCPDR */ 636 scpdr = _reg_read_1(SH7709_SCPDR); 637 scpdr |= SCPDR_TP_SCAN_X; 638 scpdr &= ~SCPDR_TP_SCAN_ENABLE; 639 _reg_write_1(SH7709_SCPDR, scpdr); 640 } 641 642 643 /* 644 * Check if the (rawx, rawy) is inside one of the 4 hard icons. 645 * Return the icon number 1..4, or 0 if not inside an icon. 646 */ 647 static int 648 j6x0tp_get_hard_icon(int rawx, int rawy) 649 { 650 if (rawx <= J6X0TP_FB_RIGHT) 651 return (0); 652 653 if (rawy < J6X0TP_HARD_ICON_MAX_Y(1)) 654 return (1); 655 else if (rawy < J6X0TP_HARD_ICON_MAX_Y(2)) 656 return (2); 657 else if (rawy < J6X0TP_HARD_ICON_MAX_Y(3)) 658 return (3); 659 else 660 return (4); 661 } 662 663 664 static int 665 j6x0tp_wsmouse_ioctl(void *self, u_long cmd, caddr_t data, int flag, 666 struct lwp *l) 667 { 668 struct j6x0tp_softc *sc = (struct j6x0tp_softc *)self; 669 670 return hpc_tpanel_ioctl(&sc->sc_tpcalib, cmd, data, flag, l); 671 } 672 673 674 static int 675 j6x0tp_wskbd_ioctl(void *self, u_long cmd, caddr_t data, int flag, 676 struct lwp *l) 677 { 678 /* struct j6x0tp_softc *sc = (struct j6x0tp_softc *)self; */ 679 680 switch (cmd) { 681 case WSKBDIO_GTYPE: 682 *(int *)data = WSKBD_TYPE_HPC_BTN; /* may be use new type? */ 683 return (0); 684 685 case WSKBDIO_GETLEDS: 686 *(int *)data = 0; 687 return (0); 688 689 default: 690 return (EPASSTHROUGH); 691 } 692 } 693 694 695 static void 696 j6x0tp_wskbd_set_leds(void *self, int leds) 697 { 698 699 /* nothing to do*/ 700 return; 701 } 702