diff options
Diffstat (limited to 'sys/dev/atkbdc')
-rw-r--r-- | sys/dev/atkbdc/atkbd.c | 14 | ||||
-rw-r--r-- | sys/dev/atkbdc/atkbdc_isa.c | 4 | ||||
-rw-r--r-- | sys/dev/atkbdc/psm.c | 46 |
3 files changed, 61 insertions, 3 deletions
diff --git a/sys/dev/atkbdc/atkbd.c b/sys/dev/atkbdc/atkbd.c index 403afcd6c2e2..e046b59803b0 100644 --- a/sys/dev/atkbdc/atkbd.c +++ b/sys/dev/atkbdc/atkbd.c @@ -1249,6 +1249,7 @@ setup_kbd_port(KBDC kbdc, int port, int intr) static int get_kbd_echo(KBDC kbdc) { + int data; /* enable the keyboard port, but disable the keyboard intr. */ if (setup_kbd_port(kbdc, TRUE, FALSE)) /* CONTROLLER ERROR: there is very little we can do... */ @@ -1256,7 +1257,18 @@ get_kbd_echo(KBDC kbdc) /* see if something is present */ write_kbd_command(kbdc, KBDC_ECHO); - if (read_kbd_data(kbdc) != KBD_ECHO) { + data = read_kbd_data(kbdc); + + /* + * Some i8042 falsely return KBD_ACK for ECHO comamnd. + * Thought it is not a correct behavior for AT keyboard, we accept + * and consume it to prevent resetting the whole keyboard after the + * first interrupt. + */ + if (data == KBD_ACK) + data = read_kbd_data(kbdc); + + if (data != KBD_ECHO) { empty_both_buffers(kbdc, 10); test_controller(kbdc); test_kbd_port(kbdc); diff --git a/sys/dev/atkbdc/atkbdc_isa.c b/sys/dev/atkbdc/atkbdc_isa.c index 2f7b9eceda94..057ebbc7ec0d 100644 --- a/sys/dev/atkbdc/atkbdc_isa.c +++ b/sys/dev/atkbdc/atkbdc_isa.c @@ -238,8 +238,8 @@ atkbdc_isa_attach(device_t dev) } *(atkbdc_softc_t **)device_get_softc(dev) = sc; - bus_generic_probe(dev); - bus_generic_attach(dev); + bus_identify_children(dev); + bus_attach_children(dev); return 0; } diff --git a/sys/dev/atkbdc/psm.c b/sys/dev/atkbdc/psm.c index 1a02dbcec020..8563b5f93aa2 100644 --- a/sys/dev/atkbdc/psm.c +++ b/sys/dev/atkbdc/psm.c @@ -66,6 +66,7 @@ #include <sys/param.h> #include <sys/systm.h> #include <sys/kernel.h> +#include <sys/lock.h> #include <sys/module.h> #include <sys/bus.h> #include <sys/conf.h> @@ -607,6 +608,7 @@ static d_read_t psmread; static d_write_t psmwrite; static d_ioctl_t psmioctl; static d_poll_t psmpoll; +static d_kqfilter_t psmkqfilter; static int psmopen(struct psm_softc *); static int psmclose(struct psm_softc *); @@ -759,6 +761,7 @@ static struct cdevsw psm_cdevsw = { .d_write = psmwrite, .d_ioctl = psmioctl, .d_poll = psmpoll, + .d_kqfilter = psmkqfilter, .d_name = PSM_DRIVER_NAME, }; @@ -1955,6 +1958,7 @@ psmattach(device_t dev) sc->state = PSM_VALID; callout_init(&sc->callout, 0); callout_init(&sc->softcallout, 0); + knlist_init_mtx(&sc->rsel.si_note, &Giant); /* Setup our interrupt handler */ rid = KBDC_RID_AUX; @@ -2066,6 +2070,8 @@ psmdetach(device_t dev) destroy_dev(sc->cdev); destroy_dev(sc->bdev); + knlist_clear(&sc->rsel.si_note, 1); + knlist_destroy(&sc->rsel.si_note); callout_drain(&sc->callout); callout_drain(&sc->softcallout); @@ -5221,6 +5227,7 @@ next: wakeup(sc); } selwakeuppri(&sc->rsel, PZERO); + KNOTE_LOCKED(&sc->rsel.si_note, 0); if (sc->async != NULL) { pgsigio(&sc->async, SIGIO, 0); } @@ -5258,6 +5265,45 @@ psmpoll(struct cdev *dev, int events, struct thread *td) return (revents); } +static void +psmfilter_detach(struct knote *kn) +{ + struct psm_softc *sc = kn->kn_hook; + + knlist_remove(&sc->rsel.si_note, kn, 0); +} + +static int +psmfilter(struct knote *kn, long hint) +{ + struct psm_softc *sc = kn->kn_hook; + + GIANT_REQUIRED; + + return (sc->queue.count != 0 ? 1 : 0); +} + +static const struct filterops psmfiltops = { + .f_isfd = 1, + .f_detach = psmfilter_detach, + .f_event = psmfilter, +}; + +static int +psmkqfilter(struct cdev *dev, struct knote *kn) +{ + struct psm_softc *sc = dev->si_drv1; + + if (kn->kn_filter != EVFILT_READ) + return(EOPNOTSUPP); + + kn->kn_fop = &psmfiltops; + kn->kn_hook = sc; + knlist_add(&sc->rsel.si_note, kn, 1); + + return (0); +} + /* vendor/model specific routines */ static int mouse_id_proc1(KBDC kbdc, int res, int scale, int *status) |