static void vrkiu_scan(struct vrkiu_chip* chip) { int i, j, modified, mask; unsigned short scandata[KIU_NSCANLINE/2]; if (!chip->kc_enabled) return; for (i = 0; i < KIU_NSCANLINE / 2; i++) { scandata[i] = vrkiu_read(chip, KIUDATP + i * 2); } eliminate_phantom_keys(chip, scandata); for (i = 0; i < KIU_NSCANLINE / 2; i++) { modified = scandata[i] ^ chip->kc_scandata[i]; chip->kc_scandata[i] = scandata[i]; mask = 1; for (j = 0; j < 16; j++, mask <<= 1) { /* * Simultaneous keypresses are resolved by registering * the one with the lowest bit index first. */ if (modified & mask) { int key = i * 16 + j; DPRINTF(("vrkiu_scan: %s(%d,%d)\n", (scandata[i] & mask) ? "down" : "up", i, j)); hpckbd_input(chip->kc_hpckbd, (scandata[i] & mask), key); } } } }
void tc5165buf_soft(void *arg) { struct tc5165buf_chip *scc = arg; bus_space_tag_t t = scc->scc_cst; bus_space_handle_t h = scc->scc_csh; u_int16_t mask, rpat, edge; int i, j, type, val; int s; hpckbd_input_hook(scc->scc_hpckbd); /* clear scanlines */ (void)bus_space_read_2(t, h, 0); delay(3); for (i = 0; i < TC5165_COLUMN_MAX; i++) { rpat = bus_space_read_2(t, h, 2 << i); delay(3); (void)bus_space_read_2(t, h, 0); delay(3); if ((edge = (rpat ^ scc->scc_buf[i]))) { scc->scc_buf[i] = rpat; for (j = 0, mask = 1; j < TC5165_ROW_MAX; j++, mask <<= 1) { if (mask & edge) { type = mask & rpat ? 1 : 0; val = j * TC5165_COLUMN_MAX + i; DPRINTF(("%d %d\n", j, i)); hpckbd_input(scc->scc_hpckbd, type, val); } } } } s = spltty(); scc->scc_queued = 0; splx(s); }