Lines Matching +full:assigned +full:- +full:resolution +full:- +full:bits
38 * CYAPA - Cypress APA trackpad with I2C Interface driver
49 * +--------------------+------------+
53 * | Button +------------+
56 * +--------------------+............|
58 * +---------------------------------+
63 * IMPS/2 emulation - Emulates the IntelliMouse protocol.
65 * Jitter supression - Implements 2-pixel hysteresis with memory.
67 * Jump detecion - Detect jumps caused by touchpad.
69 * Two finger scrolling - Use two fingers for Z axis scrolling.
71 * Button down/2nd finger - While one finger clicks and holds down the
76 * Thumb/Button Area - The lower 15%* of the trackpad will not affect
83 * Track-pad button - Push physical button. Left 2/3rds of the pad
96 * please try to place at least one finger off-axis (a little above or
139 #define CYAPA_BUFMASK (CYAPA_BUFSIZE - 1)
182 int delta_x; /* accumulation -> report */
196 struct cyapa_fifo rfifo; /* device->host */
197 struct cyapa_fifo wfifo; /* host->device */
207 int zenabled; /* z-axis enabled (mode 1 or 2) */
312 mtx_lock(&sc->mutex); in cyapa_lock()
319 mtx_unlock(&sc->mutex); in cyapa_unlock()
322 #define CYAPA_LOCK_ASSERT(sc) mtx_assert(&(sc)->mutex, MA_OWNED);
326 * with sc->mutex held (cyapa_lock(sc)).
334 if (sc->data_signal || !fifo_empty(sc, &sc->rfifo)) { in cyapa_notify()
335 KNOTE_LOCKED(&sc->selinfo.si_note, 0); in cyapa_notify()
336 if (sc->blocked || sc->isselect) { in cyapa_notify()
337 if (sc->blocked) { in cyapa_notify()
338 sc->blocked = 0; in cyapa_notify()
339 wakeup(&sc->blocked); in cyapa_notify()
341 if (sc->isselect) { in cyapa_notify()
342 sc->isselect = 0; in cyapa_notify()
343 selwakeup(&sc->selinfo); in cyapa_notify()
393 --retries; in init_device()
411 if (strncmp(cap->prod_ida, "CYTRA", 5) != 0) { in init_device()
413 cap->prod_ida); in init_device()
442 config_intrhook_disestablish(&sc->intr_hook); in cyapa_start()
449 0, 0, "cyapa-poll"); in cyapa_start()
499 * 0x67 - cypress trackpad on the acer c720 in cyapa_probe()
523 sc->reporting_mode = 1; in cyapa_attach()
531 mtx_init(&sc->mutex, "cyapa", NULL, MTX_DEF); in cyapa_attach()
533 sc->dev = dev; in cyapa_attach()
535 knlist_init_mtx(&sc->selinfo.si_note, &sc->mutex); in cyapa_attach()
537 sc->cap_resx = ((cap.max_abs_xy_high << 4) & 0x0F00) | in cyapa_attach()
539 sc->cap_resy = ((cap.max_abs_xy_high << 8) & 0x0F00) | in cyapa_attach()
541 sc->cap_phyx = ((cap.phy_siz_xy_high << 4) & 0x0F00) | in cyapa_attach()
543 sc->cap_phyy = ((cap.phy_siz_xy_high << 8) & 0x0F00) | in cyapa_attach()
545 sc->cap_buttons = cap.buttons >> 3 & in cyapa_attach()
548 device_printf(dev, "%5.5s-%6.6s-%2.2s buttons=%c%c%c res=%dx%d\n", in cyapa_attach()
550 ((sc->cap_buttons & CYAPA_FNGR_LEFT) ? 'L' : '-'), in cyapa_attach()
551 ((sc->cap_buttons & CYAPA_FNGR_MIDDLE) ? 'M' : '-'), in cyapa_attach()
552 ((sc->cap_buttons & CYAPA_FNGR_RIGHT) ? 'R' : '-'), in cyapa_attach()
553 sc->cap_resx, sc->cap_resy); in cyapa_attach()
555 sc->hw.buttons = 5; in cyapa_attach()
556 sc->hw.iftype = MOUSE_IF_PS2; in cyapa_attach()
557 sc->hw.type = MOUSE_MOUSE; in cyapa_attach()
558 sc->hw.model = MOUSE_MODEL_INTELLI; in cyapa_attach()
559 sc->hw.hwid = addr; in cyapa_attach()
561 sc->mode.protocol = MOUSE_PROTO_PS2; in cyapa_attach()
562 sc->mode.rate = 100; in cyapa_attach()
563 sc->mode.resolution = 4; in cyapa_attach()
564 sc->mode.accelfactor = 1; in cyapa_attach()
565 sc->mode.level = 0; in cyapa_attach()
566 sc->mode.packetsize = MOUSE_PS2_PACKETSIZE; in cyapa_attach()
568 sc->intr_hook.ich_func = cyapa_start; in cyapa_attach()
569 sc->intr_hook.ich_arg = sc->dev; in cyapa_attach()
572 sc->evdev = evdev_alloc(); in cyapa_attach()
573 evdev_set_name(sc->evdev, device_get_desc(sc->dev)); in cyapa_attach()
574 evdev_set_phys(sc->evdev, device_get_nameunit(sc->dev)); in cyapa_attach()
575 evdev_set_id(sc->evdev, BUS_I2C, 0, 0, 1); in cyapa_attach()
576 evdev_set_flag(sc->evdev, EVDEV_FLAG_MT_STCOMPAT); in cyapa_attach()
577 evdev_set_flag(sc->evdev, EVDEV_FLAG_MT_AUTOREL); in cyapa_attach()
579 evdev_support_event(sc->evdev, EV_SYN); in cyapa_attach()
580 evdev_support_event(sc->evdev, EV_ABS); in cyapa_attach()
581 evdev_support_event(sc->evdev, EV_KEY); in cyapa_attach()
582 evdev_support_prop(sc->evdev, INPUT_PROP_POINTER); in cyapa_attach()
583 if (sc->cap_buttons & CYAPA_FNGR_LEFT) in cyapa_attach()
584 evdev_support_key(sc->evdev, BTN_LEFT); in cyapa_attach()
585 if (sc->cap_buttons & CYAPA_FNGR_RIGHT) in cyapa_attach()
586 evdev_support_key(sc->evdev, BTN_RIGHT); in cyapa_attach()
587 if (sc->cap_buttons & CYAPA_FNGR_MIDDLE) in cyapa_attach()
588 evdev_support_key(sc->evdev, BTN_MIDDLE); in cyapa_attach()
589 if (sc->cap_buttons == CYAPA_FNGR_LEFT) in cyapa_attach()
590 evdev_support_prop(sc->evdev, INPUT_PROP_BUTTONPAD); in cyapa_attach()
592 evdev_support_abs(sc->evdev, ABS_MT_SLOT, in cyapa_attach()
593 0, CYAPA_MAX_MT - 1, 0, 0, 0); in cyapa_attach()
594 evdev_support_abs(sc->evdev, ABS_MT_TRACKING_ID, -1, 15, 0, 0, 0); in cyapa_attach()
595 evdev_support_abs(sc->evdev, ABS_MT_POSITION_X, 0, sc->cap_resx, 0, 0, in cyapa_attach()
596 sc->cap_phyx != 0 ? sc->cap_resx / sc->cap_phyx : 0); in cyapa_attach()
597 evdev_support_abs(sc->evdev, ABS_MT_POSITION_Y, 0, sc->cap_resy, 0, 0, in cyapa_attach()
598 sc->cap_phyy != 0 ? sc->cap_resy / sc->cap_phyy : 0); in cyapa_attach()
599 evdev_support_abs(sc->evdev, ABS_MT_PRESSURE, 0, 255, 0, 0, 0); in cyapa_attach()
601 if (evdev_register(sc->evdev) != 0) { in cyapa_attach()
602 mtx_destroy(&sc->mutex); in cyapa_attach()
608 if (config_intrhook_establish(&sc->intr_hook) != 0) { in cyapa_attach()
610 evdev_free(sc->evdev); in cyapa_attach()
612 mtx_destroy(&sc->mutex); in cyapa_attach()
616 sc->devnode = make_dev(&cyapa_cdevsw, unit, in cyapa_attach()
619 sc->devnode->si_drv1 = sc; in cyapa_attach()
633 while (sc->poll_thread_running) { in cyapa_detach()
634 sc->detaching = 1; in cyapa_detach()
635 mtx_sleep(&sc->detaching, &sc->mutex, PCATCH, "cyapadet", hz); in cyapa_detach()
639 destroy_dev(sc->devnode); in cyapa_detach()
641 knlist_clear(&sc->selinfo.si_note, 0); in cyapa_detach()
642 seldrain(&sc->selinfo); in cyapa_detach()
643 knlist_destroy(&sc->selinfo.si_note); in cyapa_detach()
645 evdev_free(sc->evdev); in cyapa_detach()
648 mtx_destroy(&sc->mutex); in cyapa_detach()
663 priv->sc = dev->si_drv1; in cyapaopen()
667 cyapa_lock(priv->sc); in cyapaopen()
668 priv->sc->count++; in cyapaopen()
669 cyapa_unlock(priv->sc); in cyapaopen()
685 cyapa_lock(priv->sc); in cyapa_cdevpriv_dtor()
686 priv->sc->count--; in cyapa_cdevpriv_dtor()
687 cyapa_unlock(priv->sc); in cyapa_cdevpriv_dtor()
701 sc = dev->si_drv1; in cyaparead()
705 if (fifo_empty(sc, &sc->rfifo) && in cyaparead()
706 (sc->data_signal || sc->delta_x || sc->delta_y || in cyaparead()
707 sc->track_but != sc->reported_but)) { in cyaparead()
715 sc->data_signal = 0; in cyaparead()
716 delta_x = sc->delta_x; in cyaparead()
717 delta_y = sc->delta_y; in cyaparead()
718 delta_z = sc->delta_z; in cyaparead()
721 sc->data_signal = 1; in cyaparead()
723 if (delta_x < -256) { in cyaparead()
724 delta_x = -256; in cyaparead()
725 sc->data_signal = 1; in cyaparead()
729 sc->data_signal = 1; in cyaparead()
731 if (delta_y < -256) { in cyaparead()
732 delta_y = -256; in cyaparead()
733 sc->data_signal = 1; in cyaparead()
737 sc->data_signal = 1; in cyaparead()
739 if (delta_z < -256) { in cyaparead()
740 delta_z = -256; in cyaparead()
741 sc->data_signal = 1; in cyaparead()
743 but = sc->track_but; in cyaparead()
746 sc->delta_x -= delta_x; in cyaparead()
747 sc->delta_y -= delta_y; in cyaparead()
748 sc->delta_z -= delta_z; in cyaparead()
749 sc->reported_but = but; in cyaparead()
757 delta_x = cyapa_fuzz(delta_x, &sc->fuzz_x); in cyaparead()
758 delta_y = cyapa_fuzz(delta_y, &sc->fuzz_y); in cyaparead()
759 delta_z = cyapa_fuzz(delta_z, &sc->fuzz_z); in cyaparead()
777 fifo_write_char(sc, &sc->rfifo, c0); in cyaparead()
778 fifo_write_char(sc, &sc->rfifo, (uint8_t)delta_x); in cyaparead()
779 fifo_write_char(sc, &sc->rfifo, (uint8_t)delta_y); in cyaparead()
780 switch(sc->zenabled) { in cyaparead()
782 /* Z axis all 8 bits */ in cyaparead()
783 fifo_write_char(sc, &sc->rfifo, (uint8_t)delta_z); in cyaparead()
787 * Z axis low 4 bits + 4th button and 5th button in cyaparead()
788 * (high 2 bits must be left 0). Auto-scale in cyaparead()
789 * delta_z to fit to avoid a wrong-direction in cyaparead()
792 while (delta_z > 7 || delta_z < -8) in cyaparead()
795 fifo_write_char(sc, &sc->rfifo, c0); in cyaparead()
804 /* Blocking / Non-blocking */ in cyaparead()
806 didread = (uio->uio_resid == 0); in cyaparead()
808 while ((ioflag & IO_NDELAY) == 0 && fifo_empty(sc, &sc->rfifo)) { in cyaparead()
809 if (sc->data_signal) in cyaparead()
811 sc->blocked = 1; in cyaparead()
812 error = mtx_sleep(&sc->blocked, &sc->mutex, PCATCH, "cyablk", 0); in cyaparead()
818 while (error == 0 && uio->uio_resid && in cyaparead()
819 (n = fifo_ready(sc, &sc->rfifo)) > 0) { in cyaparead()
820 if (n > uio->uio_resid) in cyaparead()
821 n = uio->uio_resid; in cyaparead()
822 ptr = fifo_read(sc, &sc->rfifo, 0); in cyaparead()
828 fifo_read(sc, &sc->rfifo, n); in cyaparead()
849 sc = dev->si_drv1; in cyapawrite()
852 * Copy data from userland. This will also cross-over the end in cyapawrite()
856 while ((n = fifo_space(sc, &sc->wfifo)) > 0 && uio->uio_resid) { in cyapawrite()
857 if (n > uio->uio_resid) in cyapawrite()
858 n = uio->uio_resid; in cyapawrite()
859 ptr = fifo_write(sc, &sc->wfifo, 0); in cyapawrite()
865 fifo_write(sc, &sc->wfifo, n); in cyapawrite()
869 cmd_completed = (fifo_ready(sc, &sc->wfifo) != 0); in cyapawrite()
870 while (fifo_ready(sc, &sc->wfifo) && cmd_completed && error == 0) { in cyapawrite()
871 if (sc->ps2_cmd == 0) in cyapawrite()
872 sc->ps2_cmd = fifo_read_char(sc, &sc->wfifo); in cyapawrite()
873 switch(sc->ps2_cmd) { in cyapawrite()
876 sc->scaling_mode = 0; in cyapawrite()
877 fifo_write_char(sc, &sc->rfifo, 0xFA); in cyapawrite()
881 sc->scaling_mode = 1; in cyapawrite()
882 fifo_write_char(sc, &sc->rfifo, 0xFA); in cyapawrite()
885 /* SET RESOLUTION +1 byte */ in cyapawrite()
886 if (sc->ps2_acked == 0) { in cyapawrite()
887 sc->ps2_acked = 1; in cyapawrite()
888 fifo_write_char(sc, &sc->rfifo, 0xFA); in cyapawrite()
890 if (fifo_ready(sc, &sc->wfifo) == 0) { in cyapawrite()
894 sc->mode.resolution = fifo_read_char(sc, &sc->wfifo); in cyapawrite()
895 fifo_write_char(sc, &sc->rfifo, 0xFA); in cyapawrite()
911 * byte2: resolution counts/mm in cyapawrite()
915 if (sc->remote_mode) in cyapawrite()
917 if (sc->reporting_mode) in cyapawrite()
919 if (sc->scaling_mode) in cyapawrite()
921 if (sc->track_but & CYAPA_FNGR_LEFT) in cyapawrite()
923 if (sc->track_but & CYAPA_FNGR_MIDDLE) in cyapawrite()
925 if (sc->track_but & CYAPA_FNGR_RIGHT) in cyapawrite()
927 fifo_write_char(sc, &sc->rfifo, 0xFA); in cyapawrite()
928 fifo_write_char(sc, &sc->rfifo, c0); in cyapawrite()
929 fifo_write_char(sc, &sc->rfifo, 0x00); in cyapawrite()
930 fifo_write_char(sc, &sc->rfifo, 100); in cyapawrite()
934 sc->remote_mode = 0; in cyapawrite()
935 fifo_write_char(sc, &sc->rfifo, 0xFA); in cyapawrite()
936 sc->delta_x = 0; in cyapawrite()
937 sc->delta_y = 0; in cyapawrite()
938 sc->delta_z = 0; in cyapawrite()
945 fifo_write_char(sc, &sc->rfifo, 0xFA); in cyapawrite()
946 sc->data_signal = 1; in cyapawrite()
950 fifo_write_char(sc, &sc->rfifo, 0xFA); in cyapawrite()
954 fifo_write_char(sc, &sc->rfifo, 0xFA); in cyapawrite()
958 sc->remote_mode = 1; in cyapawrite()
959 fifo_write_char(sc, &sc->rfifo, 0xFA); in cyapawrite()
960 sc->delta_x = 0; in cyapawrite()
961 sc->delta_y = 0; in cyapawrite()
962 sc->delta_z = 0; in cyapawrite()
968 * If we send 0x00 - normal PS/2 mouse, no Z-axis in cyapawrite()
970 * If we send 0x03 - Intellimouse, data packet has in cyapawrite()
971 * an additional Z movement byte (8 bits signed). in cyapawrite()
974 * If we send 0x04 - Now includes z-axis and the in cyapawrite()
977 fifo_write_char(sc, &sc->rfifo, 0xFA); in cyapawrite()
978 switch(sc->zenabled) { in cyapawrite()
980 fifo_write_char(sc, &sc->rfifo, 0x03); in cyapawrite()
983 fifo_write_char(sc, &sc->rfifo, 0x04); in cyapawrite()
986 fifo_write_char(sc, &sc->rfifo, 0x00); in cyapawrite()
989 sc->delta_x = 0; in cyapawrite()
990 sc->delta_y = 0; in cyapawrite()
991 sc->delta_z = 0; in cyapawrite()
999 if (sc->ps2_acked == 0) { in cyapawrite()
1000 sc->ps2_acked = 1; in cyapawrite()
1001 fifo_write_char(sc, &sc->rfifo, 0xFA); in cyapawrite()
1003 if (fifo_ready(sc, &sc->wfifo) == 0) { in cyapawrite()
1007 sc->mode.rate = fifo_read_char(sc, &sc->wfifo); in cyapawrite()
1008 fifo_write_char(sc, &sc->rfifo, 0xFA); in cyapawrite()
1017 if (sc->zenabled == 0 && sc->mode.rate == 200) in cyapawrite()
1018 sc->zenabled = -1; in cyapawrite()
1019 else if (sc->zenabled == -1 && sc->mode.rate == 100) in cyapawrite()
1020 sc->zenabled = -2; in cyapawrite()
1021 else if (sc->zenabled == -1 && sc->mode.rate == 200) in cyapawrite()
1022 sc->zenabled = -3; in cyapawrite()
1023 else if (sc->zenabled == -2 && sc->mode.rate == 80) in cyapawrite()
1024 sc->zenabled = 1; /* z-axis mode */ in cyapawrite()
1025 else if (sc->zenabled == -3 && sc->mode.rate == 80) in cyapawrite()
1026 sc->zenabled = 2; /* z-axis+but4/5 */ in cyapawrite()
1027 if (sc->mode.level) in cyapawrite()
1028 sc->zenabled = 1; in cyapawrite()
1032 fifo_write_char(sc, &sc->rfifo, 0xFA); in cyapawrite()
1033 sc->reporting_mode = 1; in cyapawrite()
1040 fifo_write_char(sc, &sc->rfifo, 0xFA); in cyapawrite()
1041 sc->reporting_mode = 1; in cyapawrite()
1047 * (reset sampling rate, resolution, scaling and in cyapawrite()
1050 fifo_write_char(sc, &sc->rfifo, 0xFA); in cyapawrite()
1051 sc->mode.rate = 100; in cyapawrite()
1052 sc->mode.resolution = 4; in cyapawrite()
1053 sc->scaling_mode = 0; in cyapawrite()
1054 sc->reporting_mode = 1; in cyapawrite()
1055 sc->remote_mode = 0; in cyapawrite()
1056 sc->delta_x = 0; in cyapawrite()
1057 sc->delta_y = 0; in cyapawrite()
1058 sc->delta_z = 0; in cyapawrite()
1068 fifo_write_char(sc, &sc->rfifo, 0xFA); in cyapawrite()
1069 sc->data_signal = 1; in cyapawrite()
1075 fifo_reset(sc, &sc->rfifo); /* should we do this? */ in cyapawrite()
1076 fifo_reset(sc, &sc->wfifo); /* should we do this? */ in cyapawrite()
1077 fifo_write_char(sc, &sc->rfifo, 0xFA); in cyapawrite()
1078 sc->delta_x = 0; in cyapawrite()
1079 sc->delta_y = 0; in cyapawrite()
1080 sc->delta_z = 0; in cyapawrite()
1081 sc->zenabled = 0; in cyapawrite()
1082 sc->mode.level = 0; in cyapawrite()
1085 printf("unknown command %02x\n", sc->ps2_cmd); in cyapawrite()
1089 sc->ps2_cmd = 0; in cyapawrite()
1090 sc->ps2_acked = 0; in cyapawrite()
1095 if (error == 0 && (cmd_completed || uio->uio_resid)) in cyapawrite()
1115 sc = dev->si_drv1; in cyapakqfilter()
1117 switch(kn->kn_filter) { in cyapakqfilter()
1119 kn->kn_fop = &cyapa_filtops; in cyapakqfilter()
1120 kn->kn_hook = (void *)sc; in cyapakqfilter()
1125 knlist = &sc->selinfo.si_note; in cyapakqfilter()
1137 sc = dev->si_drv1; in cyapapoll()
1142 if (sc->data_signal || !fifo_empty(sc, &sc->rfifo)) in cyapapoll()
1145 sc->isselect = 1; in cyapapoll()
1146 selrecord(td, &sc->selinfo); in cyapapoll()
1160 sc = (struct cyapa_softc *)kn->kn_hook; in cyapafiltdetach()
1162 knlist = &sc->selinfo.si_note; in cyapafiltdetach()
1172 sc = (struct cyapa_softc *)kn->kn_hook; in cyapafilt()
1175 ready = fifo_ready(sc, &sc->rfifo) || sc->data_signal; in cyapafilt()
1187 sc = dev->si_drv1; in cyapaioctl()
1193 *(mousehw_t *)data = sc->hw; in cyapaioctl()
1194 if (sc->mode.level == 0) in cyapaioctl()
1195 ((mousehw_t *)data)->model = MOUSE_MODEL_GENERIC; in cyapaioctl()
1199 *(mousemode_t *)data = sc->mode; in cyapaioctl()
1200 ((mousemode_t *)data)->resolution = in cyapaioctl()
1201 MOUSE_RES_LOW - sc->mode.resolution; in cyapaioctl()
1202 switch (sc->mode.level) { in cyapaioctl()
1204 ((mousemode_t *)data)->protocol = MOUSE_PROTO_PS2; in cyapaioctl()
1205 ((mousemode_t *)data)->packetsize = in cyapaioctl()
1209 ((mousemode_t *)data)->protocol = MOUSE_PROTO_PS2; in cyapaioctl()
1210 ((mousemode_t *)data)->packetsize = in cyapaioctl()
1217 *(int *)data = sc->mode.level; in cyapaioctl()
1226 sc->mode.level = *(int *)data ? 2 : 0; in cyapaioctl()
1227 sc->zenabled = sc->mode.level ? 1 : 0; in cyapaioctl()
1261 bus = device_get_parent(sc->dev); in cyapa_poll_thread()
1264 sc->poll_thread_running = 1; in cyapa_poll_thread()
1266 while (!sc->detaching) { in cyapa_poll_thread()
1268 error = iicbus_request_bus(bus, sc->dev, IIC_WAIT); in cyapa_poll_thread()
1270 error = cyapa_read_bytes(sc->dev, CMD_DEV_STATUS, in cyapa_poll_thread()
1277 * For some reason the device can crap-out. If it in cyapa_poll_thread()
1283 (unsigned)(ticks - last_reset) > TIME_TO_RESET)) { in cyapa_poll_thread()
1286 init_device(sc->dev, NULL, 2); in cyapa_poll_thread()
1288 iicbus_release_bus(bus, sc->dev); in cyapa_poll_thread()
1291 ++sc->poll_ticks; in cyapa_poll_thread()
1293 if (sc->count == 0) { in cyapa_poll_thread()
1323 sc->poll_thread_running = 0; in cyapa_poll_thread()
1345 uint16_t but; /* high bits used for simulated but4/but5 */ in cyapa_raw_input()
1347 thumbarea_begin = sc->cap_resy - in cyapa_raw_input()
1348 ((sc->cap_resy * cyapa_thumbarea_percent) / 100); in cyapa_raw_input()
1355 if ((regs->stat & CYAPA_STAT_RUNNING) == 0) { in cyapa_raw_input()
1356 regs->fngr = 0; in cyapa_raw_input()
1360 nfingers = CYAPA_FNGR_NUMFINGERS(regs->fngr); in cyapa_raw_input()
1365 regs->stat, in cyapa_raw_input()
1366 ((regs->fngr & CYAPA_FNGR_LEFT) ? 'L' : '-'), in cyapa_raw_input()
1367 ((regs->fngr & CYAPA_FNGR_MIDDLE) ? 'M' : '-'), in cyapa_raw_input()
1368 ((regs->fngr & CYAPA_FNGR_RIGHT) ? 'R' : '-'), in cyapa_raw_input()
1376 sc->evdev, regs->touch[i].id); in cyapa_raw_input()
1377 if (slot == -1) { in cyapa_raw_input()
1380 regs->touch[i].id); in cyapa_raw_input()
1383 evdev_push_abs(sc->evdev, ABS_MT_SLOT, slot); in cyapa_raw_input()
1384 evdev_push_abs(sc->evdev, ABS_MT_TRACKING_ID, in cyapa_raw_input()
1385 regs->touch[i].id); in cyapa_raw_input()
1386 evdev_push_abs(sc->evdev, ABS_MT_POSITION_X, in cyapa_raw_input()
1388 evdev_push_abs(sc->evdev, ABS_MT_POSITION_Y, in cyapa_raw_input()
1390 evdev_push_abs(sc->evdev, ABS_MT_PRESSURE, in cyapa_raw_input()
1393 if (sc->cap_buttons & CYAPA_FNGR_LEFT) in cyapa_raw_input()
1394 evdev_push_key(sc->evdev, BTN_LEFT, in cyapa_raw_input()
1395 regs->fngr & CYAPA_FNGR_LEFT); in cyapa_raw_input()
1396 if (sc->cap_buttons & CYAPA_FNGR_RIGHT) in cyapa_raw_input()
1397 evdev_push_key(sc->evdev, BTN_RIGHT, in cyapa_raw_input()
1398 regs->fngr & CYAPA_FNGR_RIGHT); in cyapa_raw_input()
1399 if (sc->cap_buttons & CYAPA_FNGR_MIDDLE) in cyapa_raw_input()
1400 evdev_push_key(sc->evdev, BTN_MIDDLE, in cyapa_raw_input()
1401 regs->fngr & CYAPA_FNGR_MIDDLE); in cyapa_raw_input()
1402 evdev_sync(sc->evdev); in cyapa_raw_input()
1413 regs->touch[i].id); in cyapa_raw_input()
1417 --afingers; in cyapa_raw_input()
1419 regs->touch[i] = regs->touch[i+1]; in cyapa_raw_input()
1434 * Track timing for finger-downs. Used to detect false-3-finger in cyapa_raw_input()
1435 * button-down. in cyapa_raw_input()
1441 if (sc->track_nfingers == 0) in cyapa_raw_input()
1442 sc->finger1_ticks = sc->poll_ticks; in cyapa_raw_input()
1445 if (sc->track_nfingers <= 0) in cyapa_raw_input()
1446 sc->finger1_ticks = sc->poll_ticks; in cyapa_raw_input()
1447 if (sc->track_nfingers <= 1) in cyapa_raw_input()
1448 sc->finger2_ticks = sc->poll_ticks; in cyapa_raw_input()
1452 if (sc->track_nfingers <= 0) in cyapa_raw_input()
1453 sc->finger1_ticks = sc->poll_ticks; in cyapa_raw_input()
1454 if (sc->track_nfingers <= 1) in cyapa_raw_input()
1455 sc->finger2_ticks = sc->poll_ticks; in cyapa_raw_input()
1456 if (sc->track_nfingers <= 2) in cyapa_raw_input()
1457 sc->finger3_ticks = sc->poll_ticks; in cyapa_raw_input()
1460 newfinger = sc->track_nfingers < afingers; in cyapa_raw_input()
1461 lessfingers = sc->track_nfingers > afingers; in cyapa_raw_input()
1462 sc->track_nfingers = afingers; in cyapa_raw_input()
1468 click_x = sc->track_x; in cyapa_raw_input()
1469 click_y = sc->track_y; in cyapa_raw_input()
1470 sc->track_x = -1; in cyapa_raw_input()
1471 sc->track_y = -1; in cyapa_raw_input()
1472 sc->track_z = -1; in cyapa_raw_input()
1473 sc->fuzz_x = 0; in cyapa_raw_input()
1474 sc->fuzz_y = 0; in cyapa_raw_input()
1475 sc->fuzz_z = 0; in cyapa_raw_input()
1476 sc->touch_x = -1; in cyapa_raw_input()
1477 sc->touch_y = -1; in cyapa_raw_input()
1478 sc->touch_z = -1; in cyapa_raw_input()
1479 sc->track_id = -1; in cyapa_raw_input()
1480 sc->track_but = 0; in cyapa_raw_input()
1485 * The id assigned on touch can move around in the array, in cyapa_raw_input()
1494 if (sc->track_id == regs->touch[i].id) in cyapa_raw_input()
1499 sc->track_x = -1; in cyapa_raw_input()
1500 sc->track_y = -1; in cyapa_raw_input()
1501 sc->track_z = -1; in cyapa_raw_input()
1507 sc->track_id = regs->touch[i].id; in cyapa_raw_input()
1509 else if ((sc->track_but || in cyapa_raw_input()
1512 j = regs->touch[0].id == sc->track_id ? 1 : 0; in cyapa_raw_input()
1515 sc->track_x = -1; in cyapa_raw_input()
1516 sc->track_y = -1; in cyapa_raw_input()
1517 sc->track_z = -1; in cyapa_raw_input()
1518 sc->track_id = regs->touch[i].id; in cyapa_raw_input()
1523 /* Two finger scrolling - reset after timeout */ in cyapa_raw_input()
1524 if (sc->track_z != -1 && afingers != 2 && in cyapa_raw_input()
1525 (sc->poll_ticks - sc->track_z_ticks) > cyapa_scroll_stick_ticks) { in cyapa_raw_input()
1526 sc->track_z = -1; in cyapa_raw_input()
1527 sc->track_z_ticks = 0; in cyapa_raw_input()
1531 if (!(regs->fngr & CYAPA_FNGR_LEFT) && in cyapa_raw_input()
1532 ((afingers && sc->track_z != -1) || in cyapa_raw_input()
1535 if (afingers == 2 && (sc->poll_ticks - sc->finger2_ticks) in cyapa_raw_input()
1539 sc->delta_z += z / ZSCALE - sc->track_z; in cyapa_raw_input()
1540 if (sc->track_z == -1) { in cyapa_raw_input()
1541 sc->delta_z = 0; in cyapa_raw_input()
1543 if (sc->touch_z == -1) in cyapa_raw_input()
1544 sc->touch_z = z; /* not used atm */ in cyapa_raw_input()
1545 sc->track_z = z / ZSCALE; in cyapa_raw_input()
1546 sc->track_z_ticks = sc->poll_ticks; in cyapa_raw_input()
1554 if (sc->track_x != -1 && sc->track_y < thumbarea_begin && in cyapa_raw_input()
1555 (afingers > 1 || (sc->poll_ticks - sc->finger1_ticks) in cyapa_raw_input()
1557 sc->delta_x += x - sc->track_x; in cyapa_raw_input()
1558 sc->delta_y -= y - sc->track_y; in cyapa_raw_input()
1559 if (sc->delta_x > sc->cap_resx) in cyapa_raw_input()
1560 sc->delta_x = sc->cap_resx; in cyapa_raw_input()
1561 if (sc->delta_x < -sc->cap_resx) in cyapa_raw_input()
1562 sc->delta_x = -sc->cap_resx; in cyapa_raw_input()
1563 if (sc->delta_y > sc->cap_resy) in cyapa_raw_input()
1564 sc->delta_y = sc->cap_resy; in cyapa_raw_input()
1565 if (sc->delta_y < -sc->cap_resy) in cyapa_raw_input()
1566 sc->delta_y = -sc->cap_resy; in cyapa_raw_input()
1568 if (abs(sc->delta_y) > sc->cap_resy / 2 || in cyapa_raw_input()
1569 abs(sc->delta_x) > sc->cap_resx / 2) { in cyapa_raw_input()
1572 sc->delta_x, sc->delta_y); in cyapa_raw_input()
1573 sc->delta_x = sc->delta_y = 0; in cyapa_raw_input()
1576 if (sc->touch_x == -1) { in cyapa_raw_input()
1577 sc->touch_x = x; in cyapa_raw_input()
1578 sc->touch_y = y; in cyapa_raw_input()
1580 sc->track_x = x; in cyapa_raw_input()
1581 sc->track_y = y; in cyapa_raw_input()
1586 afingers == 0 && sc->poll_ticks - sc->finger1_ticks in cyapa_raw_input()
1588 sc->poll_ticks - sc->finger1_ticks < cyapa_tapclick_max_ticks); in cyapa_raw_input()
1590 if (regs->fngr & CYAPA_FNGR_LEFT || is_tapclick) { in cyapa_raw_input()
1591 if (sc->track_but) { in cyapa_raw_input()
1592 but = sc->track_but; in cyapa_raw_input()
1594 if (click_x < sc->cap_resx * 2 / 3) in cyapa_raw_input()
1596 else if (click_y < sc->cap_resy / 2) in cyapa_raw_input()
1601 if (click_x < sc->cap_resx * 2 / 3 || in cyapa_raw_input()
1604 else if (click_y < sc->cap_resy / 2 && in cyapa_raw_input()
1620 sc->track_but = but; in cyapa_raw_input()
1621 if (sc->delta_x || sc->delta_y || sc->delta_z || in cyapa_raw_input()
1622 sc->track_but != sc->reported_but) { in cyapa_raw_input()
1623 sc->active_tick = ticks; in cyapa_raw_input()
1624 if (sc->remote_mode == 0 && sc->reporting_mode) in cyapa_raw_input()
1625 sc->data_signal = 1; in cyapa_raw_input()
1627 } else if ((unsigned)(ticks - sc->active_tick) >= TIME_TO_IDLE) { in cyapa_raw_input()
1628 sc->active_tick = ticks - TIME_TO_IDLE; /* prevent overflow */ in cyapa_raw_input()
1637 printf("%i >> %i << %i\n", isidle, sc->track_id, sc->delta_y); in cyapa_raw_input()
1648 bus = device_get_parent(sc->dev); in cyapa_set_power_mode()
1649 error = iicbus_request_bus(bus, sc->dev, IIC_WAIT); in cyapa_set_power_mode()
1651 error = cyapa_read_bytes(sc->dev, CMD_POWER_MODE, in cyapa_set_power_mode()
1655 error = cyapa_write_bytes(sc->dev, CMD_POWER_MODE, in cyapa_set_power_mode()
1658 iicbus_release_bus(bus, sc->dev); in cyapa_set_power_mode()
1667 * Returns non-zero if the fifo is empty
1675 return (fifo->rindex == fifo->windex); in fifo_empty()
1689 n = CYAPA_BUFSIZE - (fifo->rindex & CYAPA_BUFMASK); in fifo_ready()
1690 if (n > (size_t)(fifo->windex - fifo->rindex)) in fifo_ready()
1691 n = (size_t)(fifo->windex - fifo->rindex); in fifo_ready()
1708 if (n > (CYAPA_BUFSIZE - (fifo->rindex & CYAPA_BUFMASK))) { in fifo_read()
1710 return (fifo->buf); in fifo_read()
1712 ptr = fifo->buf + (fifo->rindex & CYAPA_BUFMASK); in fifo_read()
1713 fifo->rindex += n; in fifo_read()
1725 if (fifo->rindex == fifo->windex) { in fifo_read_char()
1729 c = fifo->buf[fifo->rindex & CYAPA_BUFMASK]; in fifo_read_char()
1730 ++fifo->rindex; in fifo_read_char()
1746 if (fifo->windex - fifo->rindex < CYAPA_BUFSIZE) { in fifo_write_char()
1747 fifo->buf[fifo->windex & CYAPA_BUFMASK] = c; in fifo_write_char()
1748 ++fifo->windex; in fifo_write_char()
1763 n = CYAPA_BUFSIZE - (fifo->windex & CYAPA_BUFMASK); in fifo_space()
1764 if (n > (size_t)(CYAPA_BUFSIZE - (fifo->windex - fifo->rindex))) in fifo_space()
1765 n = (size_t)(CYAPA_BUFSIZE - (fifo->windex - fifo->rindex)); in fifo_space()
1776 ptr = fifo->buf + (fifo->windex & CYAPA_BUFMASK); in fifo_write()
1777 fifo->windex += n; in fifo_write()
1788 fifo->rindex = 0; in fifo_reset()
1789 fifo->windex = 0; in fifo_reset()
1803 --fuzz; in cyapa_fuzz()
1805 --delta; in cyapa_fuzz()