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

Collapse All | Expand All

(-)sys/dev/usb/input/ukbd.c (-13 / +17 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();
392
393
	/* check if initial delay passed and fallback to key repeat delay */
394
	if (sc->sc_delay == 0)
395
		sc->sc_delay = sc->sc_kbd.kb_delay2;
396
397
	/* compute timeout */
391
	delay = SBT_1MS * sc->sc_delay;
398
	delay = SBT_1MS * sc->sc_delay;
392
	sc->sc_co_basetime += delay;
399
	sc->sc_co_basetime += delay;
400
401
	/* check if we are running behind */
402
	if (sc->sc_co_basetime < now)
403
		sc->sc_co_basetime = now;
404
393
	/* This is rarely called, so prefer precision to efficiency. */
405
	/* This is rarely called, so prefer precision to efficiency. */
394
	prec = qmin(delay >> 7, SBT_1MS * 10);
406
	prec = qmin(delay >> 7, SBT_1MS * 10);
395
	usb_callout_reset_sbt(&sc->sc_callout, sc->sc_co_basetime, prec,
407
	usb_callout_reset_sbt(&sc->sc_callout, sc->sc_co_basetime, prec,
Lines 510-516 Link Here
510
static void
522
static void
511
ukbd_interrupt(struct ukbd_softc *sc)
523
ukbd_interrupt(struct ukbd_softc *sc)
512
{
524
{
513
	struct timeval ctv;
514
	uint32_t n_mod;
525
	uint32_t n_mod;
515
	uint32_t o_mod;
526
	uint32_t o_mod;
516
	uint32_t now = sc->sc_time_ms;
527
	uint32_t now = sc->sc_time_ms;
Lines 580-593 Link Here
580
				break;
591
				break;
581
			}
592
			}
582
		}
593
		}
583
		if (j < UKBD_NKEYCODE) {
594
		if (j == UKBD_NKEYCODE) {
584
			/* Old key repeating. */
595
			/* New key - set initial delay and [re]start timer */
585
			sc->sc_delay = sc->sc_kbd.kb_delay2;
596
			sc->sc_co_basetime = sbinuptime();
586
		} else {
587
			/* New key. */
588
			microuptime(&ctv);
589
			sc->sc_co_basetime = tvtosbt(ctv);
590
			sc->sc_delay = sc->sc_kbd.kb_delay1;
597
			sc->sc_delay = sc->sc_kbd.kb_delay1;
598
			ukbd_start_timer(sc);
591
		}
599
		}
592
		ukbd_put_key(sc, key | KEY_PRESS);
600
		ukbd_put_key(sc, key | KEY_PRESS);
593
601
Lines 838-847 Link Here
838
846
839
		ukbd_interrupt(sc);
847
		ukbd_interrupt(sc);
840
848
841
		if (ukbd_any_key_pressed(sc) != 0) {
842
			ukbd_start_timer(sc);
843
		}
844
845
	case USB_ST_SETUP:
849
	case USB_ST_SETUP:
846
tr_setup:
850
tr_setup:
847
		if (sc->sc_inputs < UKBD_IN_BUF_FULL) {
851
		if (sc->sc_inputs < UKBD_IN_BUF_FULL) {

Return to bug 226968