PERFORCE change 166075 for review

Hans Petter Selasky hselasky at FreeBSD.org
Tue Jul 14 10:28:03 UTC 2009


http://perforce.freebsd.org/chv.cgi?CH=166075

Change 166075 by hselasky at hselasky_laptop001 on 2009/07/14 10:27:47

	
	USB input
	 - add support for setting the UMS polling rate through -F option
	   passed to moused.
	 - reminded by Alexander Best
	
	PR:		usb/125264

Affected files ...

.. //depot/projects/usb/src/sys/dev/usb/input/ums.c#19 edit

Differences ...

==== //depot/projects/usb/src/sys/dev/usb/input/ums.c#19 (text+ko) ====

@@ -140,6 +140,8 @@
 
 	struct usb_xfer *sc_xfer[UMS_N_TRANSFER];
 
+	int sc_pollrate;
+
 	uint8_t	sc_buttons;
 	uint8_t	sc_iid;
 	uint8_t	sc_temp[64];
@@ -514,6 +516,8 @@
 		DPRINTF("error=%s\n", usbd_errstr(err));
 		goto detach;
 	}
+
+	/* Get HID descriptor */
 	err = usbd_req_get_hid_desc(uaa->device, NULL, &d_ptr,
 	    &d_len, M_TEMP, uaa->info.bIfaceIndex);
 
@@ -653,6 +657,23 @@
 ums_start_read(struct usb_fifo *fifo)
 {
 	struct ums_softc *sc = usb_fifo_softc(fifo);
+	int rate;
+
+	/* Check if we should override the default polling interval */
+	rate = sc->sc_pollrate;
+	/* Range check rate */
+	if (rate > 1000)
+		rate = 1000;
+	/* Check for set rate */
+	if ((rate > 0) && (sc->sc_xfer[UMS_INTR_DT] != NULL)) {
+		DPRINTF("Setting pollrate = %d\n", rate);
+		/* Stop current transfer, if any */
+		usbd_transfer_stop(sc->sc_xfer[UMS_INTR_DT]);
+		/* Set new interval */
+		usbd_xfer_set_interval(sc->sc_xfer[UMS_INTR_DT], 1000 / rate);
+		/* Only set pollrate once */
+		sc->sc_pollrate = 0;
+	}
 
 	usbd_transfer_start(sc->sc_xfer[UMS_INTR_DT]);
 }
@@ -791,6 +812,9 @@
 			sc->sc_mode.level = mode.level;
 		}
 
+		/* store polling rate */
+		sc->sc_pollrate = mode.rate;
+
 		if (sc->sc_mode.level == 0) {
 			if (sc->sc_buttons > MOUSE_MSC_MAXBUTTON)
 				sc->sc_hw.buttons = MOUSE_MSC_MAXBUTTON;


More information about the p4-projects mailing list