void
pckbdattach(device_t parent, device_t self, void *aux)
{
	struct pckbd_softc *sc = device_private(self);
	struct pckbport_attach_args *pa = aux;
	struct wskbddev_attach_args a;
	int isconsole;
	u_char cmd[1];

	aprint_naive("\n");
	aprint_normal("\n");

	sc->sc_dev = self;
	isconsole = pckbd_is_console(pa->pa_tag, pa->pa_slot);

	if (isconsole) {
		sc->id = &pckbd_consdata;

		/*
		 * Some keyboards are not enabled after a reset,
		 * so make sure it is enabled now.
		 */
		cmd[0] = KBC_ENABLE;
		(void) pckbport_poll_cmd(sc->id->t_kbctag, sc->id->t_kbcslot,
				      cmd, 1, 0, 0, 0);
		sc->sc_enabled = 1;
	} else {
		sc->id = malloc(sizeof(struct pckbd_internal),
				M_DEVBUF, M_WAITOK);
		(void) pckbd_init(sc->id, pa->pa_tag, pa->pa_slot, 0);

		/* no interrupts until enabled */
		cmd[0] = KBC_DISABLE;
		(void) pckbport_poll_cmd(sc->id->t_kbctag, sc->id->t_kbcslot,
				      cmd, 1, 0, 0, 0);
		sc->sc_enabled = 0;
	}

	sc->id->t_sc = sc;

	pckbport_set_inputhandler(sc->id->t_kbctag, sc->id->t_kbcslot,
			       pckbd_input, sc, device_xname(sc->sc_dev));

	a.console = isconsole;

	a.keymap = &pckbd_keymapdata;

	a.accessops = &pckbd_accessops;
	a.accesscookie = sc;

	if (!pmf_device_register(self, pckbd_suspend, pckbd_resume))
		aprint_error_dev(self, "couldn't establish power handler\n");

	/*
	 * Attach the wskbd, saving a handle to it.
	 * XXX XXX XXX
	 */
	sc->sc_wskbddev = config_found_ia(self, "wskbddev", &a, wskbddevprint);
}
示例#2
0
文件: pckbd.c 项目: MarginC/kame
void
pckbdattach(struct device *parent, struct device *self, void *aux)
{
	struct pckbd_softc *sc = (void *)self;
	struct pckbport_attach_args *pa = aux;
	struct wskbddev_attach_args a;
	int isconsole;
	u_char cmd[1];

	printf("\n");

	isconsole = pckbd_is_console(pa->pa_tag, pa->pa_slot);

	if (isconsole) {
		sc->id = &pckbd_consdata;

		/* 
		 * Some keyboards are not enabled after a reset, 
		 * so make sure it is enabled now.
		 */
		cmd[0] = KBC_ENABLE;
		(void) pckbport_poll_cmd(sc->id->t_kbctag, sc->id->t_kbcslot,
				      cmd, 1, 0, 0, 0);
		sc->sc_enabled = 1;
	} else {
		sc->id = malloc(sizeof(struct pckbd_internal),
				M_DEVBUF, M_WAITOK);
		(void) pckbd_init(sc->id, pa->pa_tag, pa->pa_slot, 0);

		/* no interrupts until enabled */
		cmd[0] = KBC_DISABLE;
		(void) pckbport_poll_cmd(sc->id->t_kbctag, sc->id->t_kbcslot,
				      cmd, 1, 0, 0, 0);
		sc->sc_enabled = 0;
	}

	sc->id->t_sc = sc;

	pckbport_set_inputhandler(sc->id->t_kbctag, sc->id->t_kbcslot,
			       pckbd_input, sc, sc->sc_dev.dv_xname);

	a.console = isconsole;

	a.keymap = &pckbd_keymapdata;

	a.accessops = &pckbd_accessops;
	a.accesscookie = sc;

	/*
	 * Attach the wskbd, saving a handle to it.
	 * XXX XXX XXX
	 */
	sc->sc_wskbddev = config_found(self, &a, wskbddevprint);
}
示例#3
0
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");
}