View | Details | Raw Unified | Return to bug 226968 | Differences between
and this patch

Collapse All | Expand All

(-)sys/dev/usb/input/ukbd.c (-13 / +12 lines)
Lines 386-395 Link Here
386
static void
386
static void
387
ukbd_start_timer(struct ukbd_softc *sc)
387
ukbd_start_timer(struct ukbd_softc *sc)
388
{
388
{
389
	sbintime_t delay, prec;
389
	sbintime_t delay, prec, now;
390
390
391
	now = sbinuptime();
391
	delay = SBT_1MS * sc->sc_delay;
392
	delay = SBT_1MS * sc->sc_delay;
392
	sc->sc_co_basetime += delay;
393
	sc->sc_co_basetime += delay;
394
	/* check if we fell behind */
395
	if (sc->sc_co_basetime < now)
396
		sc->sc_co_basetime = now;
393
	/* This is rarely called, so prefer precision to efficiency. */
397
	/* This is rarely called, so prefer precision to efficiency. */
394
	prec = qmin(delay >> 7, SBT_1MS * 10);
398
	prec = qmin(delay >> 7, SBT_1MS * 10);
395
	usb_callout_reset_sbt(&sc->sc_callout, sc->sc_co_basetime, prec,
399
	usb_callout_reset_sbt(&sc->sc_callout, sc->sc_co_basetime, prec,
Lines 510-516 Link Here
510
static void
514
static void
511
ukbd_interrupt(struct ukbd_softc *sc)
515
ukbd_interrupt(struct ukbd_softc *sc)
512
{
516
{
513
	struct timeval ctv;
514
	uint32_t n_mod;
517
	uint32_t n_mod;
515
	uint32_t o_mod;
518
	uint32_t o_mod;
516
	uint32_t now = sc->sc_time_ms;
519
	uint32_t now = sc->sc_time_ms;
Lines 522-528 Link Here
522
	UKBD_LOCK_ASSERT();
525
	UKBD_LOCK_ASSERT();
523
526
524
	if (sc->sc_ndata.keycode[0] == KEY_ERROR)
527
	if (sc->sc_ndata.keycode[0] == KEY_ERROR)
525
		return;
528
		goto done;
526
529
527
	n_mod = sc->sc_ndata.modifiers;
530
	n_mod = sc->sc_ndata.modifiers;
528
	o_mod = sc->sc_odata.modifiers;
531
	o_mod = sc->sc_odata.modifiers;
Lines 585-592 Link Here
585
			sc->sc_delay = sc->sc_kbd.kb_delay2;
588
			sc->sc_delay = sc->sc_kbd.kb_delay2;
586
		} else {
589
		} else {
587
			/* New key. */
590
			/* New key. */
588
			microuptime(&ctv);
591
			sc->sc_co_basetime = sbinuptime();
589
			sc->sc_co_basetime = tvtosbt(ctv);
590
			sc->sc_delay = sc->sc_kbd.kb_delay1;
592
			sc->sc_delay = sc->sc_kbd.kb_delay1;
591
		}
593
		}
592
		ukbd_put_key(sc, key | KEY_PRESS);
594
		ukbd_put_key(sc, key | KEY_PRESS);
Lines 606-612 Link Here
606
	sc->sc_odata = sc->sc_ndata;
608
	sc->sc_odata = sc->sc_ndata;
607
609
608
	memcpy(sc->sc_otime, sc->sc_ntime, sizeof(sc->sc_otime));
610
	memcpy(sc->sc_otime, sc->sc_ntime, sizeof(sc->sc_otime));
609
611
done:
610
	ukbd_event_keyinput(sc);
612
	ukbd_event_keyinput(sc);
611
}
613
}
612
614
Lines 648-659 Link Here
648
650
649
	ukbd_interrupt(sc);
651
	ukbd_interrupt(sc);
650
652
651
	/* Make sure any leftover key events gets read out */
653
	/* check if timer should be started */
652
	ukbd_event_keyinput(sc);
654
	if (sc->sc_delay != 0)
653
654
	if (ukbd_any_key_pressed(sc) || (sc->sc_inputs != 0)) {
655
		ukbd_start_timer(sc);
655
		ukbd_start_timer(sc);
656
	}
657
}
656
}
658
657
659
static uint8_t
658
static uint8_t
Lines 838-846 Link Here
838
837
839
		ukbd_interrupt(sc);
838
		ukbd_interrupt(sc);
840
839
841
		if (ukbd_any_key_pressed(sc) != 0) {
840
		/* check if timer should be started */
841
		if (sc->sc_delay != 0)
842
			ukbd_start_timer(sc);
842
			ukbd_start_timer(sc);
843
		}
844
843
845
	case USB_ST_SETUP:
844
	case USB_ST_SETUP:
846
tr_setup:
845
tr_setup:

Return to bug 226968