int pckbd_enable(void *v, int on) { struct pckbd_softc *sc = v; int res; u_char cmd[1]; if (on) { if (sc->sc_enabled) { #ifdef DIAGNOSTIC printf("pckbd_enable: bad enable\n"); #endif return EBUSY; } pckbport_slot_enable(sc->id->t_kbctag, sc->id->t_kbcslot, 1); cmd[0] = KBC_ENABLE; res = pckbport_poll_cmd(sc->id->t_kbctag, sc->id->t_kbcslot, cmd, 1, 0, NULL, 0); if (res) { printf("pckbd_enable: command error\n"); return (res); } res = pckbd_set_xtscancode(sc->id->t_kbctag, sc->id->t_kbcslot); if (res) return res; sc->sc_enabled = 1; } else { if (sc->id->t_isconsole) return EBUSY; cmd[0] = KBC_DISABLE; res = pckbport_enqueue_cmd(sc->id->t_kbctag, sc->id->t_kbcslot, cmd, 1, 0, 1, 0); if (res) { printf("pckbd_disable: command error\n"); return res; } pckbport_slot_enable(sc->id->t_kbctag, sc->id->t_kbcslot, 0); sc->sc_enabled = 0; } return 0; }
static void do_enable(struct pms_softc *sc) { u_char cmd[2]; int res; sc->inputstate = 0; sc->buttons = 0; pckbport_slot_enable(sc->sc_kbctag, sc->sc_kbcslot, 1); #ifdef PMS_SYNAPTICS_TOUCHPAD if (sc->protocol == PMS_SYNAPTICS) pms_synaptics_enable(sc); #endif #ifdef PMS_ELANTECH_TOUCHPAD if (sc->protocol == PMS_ELANTECH) pms_elantech_enable(sc); #endif cmd[0] = PMS_DEV_ENABLE; res = pckbport_enqueue_cmd(sc->sc_kbctag, sc->sc_kbcslot, cmd, 1, 0, 1, 0); if (res) aprint_error("pms_enable: command error %d\n", res); if (sc->protocol == PMS_UNKNOWN) sc->protocol = pms_protocol(sc->sc_kbctag, sc->sc_kbcslot); DPRINTF(("pms_enable: using %s protocol\n", pms_protocols[sc->protocol].name)); #if 0 { u_char scmd[2]; scmd[0] = PMS_SET_RES; scmd[1] = 3; /* 8 counts/mm */ res = pckbport_enqueue_cmd(sc->sc_kbctag, sc->sc_kbcslot, scmd, 2, 0, 1, 0); if (res) printf("pms_enable: setup error1 (%d)\n", res); scmd[0] = PMS_SET_SCALE21; res = pckbport_enqueue_cmd(sc->sc_kbctag, sc->sc_kbcslot, scmd, 1, 0, 1, 0); if (res) printf("pms_enable: setup error2 (%d)\n", res); scmd[0] = PMS_SET_SAMPLE; scmd[1] = 100; /* 100 samples/sec */ res = pckbport_enqueue_cmd(sc->sc_kbctag, sc->sc_kbcslot, scmd, 2, 0, 1, 0); if (res) printf("pms_enable: setup error3 (%d)\n", res); } #endif }
static void do_disable(struct pms_softc *sc) { u_char cmd[1]; int res; cmd[0] = PMS_DEV_DISABLE; res = pckbport_enqueue_cmd(sc->sc_kbctag, sc->sc_kbcslot, cmd, 1, 0, 1, 0); if (res) aprint_error("pms_disable: command error\n"); pckbport_slot_enable(sc->sc_kbctag, sc->sc_kbcslot, 0); }
static bool pckbd_suspend(device_t dv, const pmf_qual_t *qual) { struct pckbd_softc *sc = device_private(dv); u_char cmd[1]; int res; /* XXX duped from pckbd_enable, but we want to disable * it even if it's the console kbd */ cmd[0] = KBC_DISABLE; res = pckbport_enqueue_cmd(sc->id->t_kbctag, sc->id->t_kbcslot, cmd, 1, 0, 1, 0); if (res) return false; pckbport_slot_enable(sc->id->t_kbctag, sc->id->t_kbcslot, 0); sc->sc_enabled = 0; return true; }
void pmsattach(device_t parent, device_t self, void *aux) { struct pms_softc *sc = device_private(self); struct pckbport_attach_args *pa = aux; struct wsmousedev_attach_args a; u_char cmd[2], resp[2]; int res; sc->sc_dev = self; sc->sc_kbctag = pa->pa_tag; sc->sc_kbcslot = pa->pa_slot; aprint_naive("\n"); aprint_normal("\n"); /* Flush any garbage. */ pckbport_flush(pa->pa_tag, pa->pa_slot); /* reset the device */ cmd[0] = PMS_RESET; res = pckbport_poll_cmd(pa->pa_tag, pa->pa_slot, cmd, 1, 2, resp, 1); if (res || resp[0] != PMS_RSTDONE || resp[1] != 0) { aprint_debug("pmsattach: reset error\n"); return; } sc->inputstate = 0; sc->buttons = 0; sc->protocol = PMS_UNKNOWN; #ifdef PMS_SYNAPTICS_TOUCHPAD /* Probe for synaptics touchpad. */ if (pms_synaptics_probe_init(sc) == 0) { sc->protocol = PMS_SYNAPTICS; } else #endif #ifdef PMS_ELANTECH_TOUCHPAD if (pms_elantech_probe_init(sc) == 0) { sc->protocol = PMS_ELANTECH; } else #endif /* Install generic handler. */ pckbport_set_inputhandler(sc->sc_kbctag, sc->sc_kbcslot, pmsinput, sc, device_xname(sc->sc_dev)); a.accessops = &pms_accessops; a.accesscookie = sc; /* * Attach the wsmouse, saving a handle to it. * Note that we don't need to check this pointer against NULL * here or in pmsintr, because if this fails pms_enable() will * never be called, so pmsinput() will never be called. */ sc->sc_wsmousedev = config_found_ia(self, "wsmousedev", &a, wsmousedevprint); /* no interrupts until enabled */ cmd[0] = PMS_DEV_DISABLE; res = pckbport_poll_cmd(pa->pa_tag, pa->pa_slot, cmd, 1, 0, 0, 0); if (res) aprint_error("pmsattach: disable error\n"); pckbport_slot_enable(sc->sc_kbctag, sc->sc_kbcslot, 0); kthread_create(PRI_NONE, 0, NULL, pms_reset_thread, sc, &sc->sc_event_thread, device_xname(sc->sc_dev)); #ifndef PMS_DISABLE_POWERHOOK sc->sc_suspended = 0; #endif if (!pmf_device_register(self, pms_suspend, pms_resume)) aprint_error_dev(self, "couldn't establish power handler\n"); }