Date: Thu, 19 Nov 2009 22:35:02 GMT From: Hans Petter Selasky <hselasky@FreeBSD.org> To: Perforce Change Reviews <perforce@FreeBSD.org> Subject: PERFORCE change 170842 for review Message-ID: <200911192235.nAJMZ2XH072195@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://p4web.freebsd.org/chv.cgi?CH=170842 Change 170842 by hselasky@hselasky_laptop001 on 2009/11/19 22:34:49 USB input: - ATP patch from Rohit Grover: - fixes some minor issues and makes the control transfer fully asynchronous Affected files ... .. //depot/projects/usb/src/sys/dev/usb/input/atp.c#2 edit Differences ... ==== //depot/projects/usb/src/sys/dev/usb/input/atp.c#2 (text+ko) ==== @@ -341,6 +341,7 @@ enum { ATP_INTR_DT, + ATP_RESET, ATP_N_TRANSFER, }; @@ -421,6 +422,7 @@ /* device initialization and shutdown */ static usb_error_t atp_req_get_report(struct usb_device *udev, void *data); static int atp_set_device_mode(device_t dev, interface_mode mode); +static void atp_reset_callback(struct usb_xfer *, usb_error_t); static int atp_enable(struct atp_softc *sc); static void atp_disable(struct atp_softc *sc); static int atp_softc_populate(struct atp_softc *); @@ -501,6 +503,40 @@ return (0); } +void +atp_reset_callback(struct usb_xfer *xfer, usb_error_t error) +{ + usb_device_request_t req; + struct usb_page_cache *pc; + struct atp_softc *sc = usbd_xfer_softc(xfer); + + switch (USB_GET_STATE(xfer)) { + case USB_ST_SETUP: + sc->sc_mode_bytes[0] = RAW_SENSOR_MODE; + req.bmRequestType = UT_WRITE_CLASS_INTERFACE; + req.bRequest = UR_SET_REPORT; + USETW2(req.wValue, + (uint8_t)0x03 /* type */, (uint8_t)0x00 /* id */); + USETW(req.wIndex, 0); + USETW(req.wLength, MODE_LENGTH); + + pc = usbd_xfer_get_frame(xfer, 0); + usbd_copy_in(pc, 0, &req, sizeof(req)); + pc = usbd_xfer_get_frame(xfer, 1); + usbd_copy_in(pc, 0, sc->sc_mode_bytes, MODE_LENGTH); + + usbd_xfer_set_frame_len(xfer, 0, sizeof(req)); + usbd_xfer_set_frame_len(xfer, 1, MODE_LENGTH); + usbd_xfer_set_frames(xfer, 2); + usbd_transfer_submit(xfer); + break; + + case USB_ST_TRANSFERRED: + default: + break; + } +} + static int atp_enable(struct atp_softc *sc) { @@ -1515,6 +1551,14 @@ .bufsize = 0, /* use wMaxPacketSize */ .callback = &atp_intr, }, + [ATP_RESET] = { + .type = UE_CONTROL, + .endpoint = 0, /* Control pipe */ + .direction = UE_DIR_ANY, + .bufsize = sizeof(struct usb_device_request) + MODE_LENGTH, + .callback = &atp_reset_callback, + .interval = 0, /* no pre-delay */ + }, }; static int @@ -1530,7 +1574,7 @@ return (ENXIO); if (usbd_lookup_id_by_uaa(atp_devs, sizeof(atp_devs), uaa) == 0) - return BUS_PROBE_SPECIFIC; + return 0; else return ENXIO; } @@ -1542,12 +1586,6 @@ struct usb_attach_arg *uaa = device_get_ivars(dev); usb_error_t err; - /* ensure that the probe was successful */ - if (uaa->driver_info >= ATP_N_DEV_PARAMS) { - DPRINTF("device probe returned bad id: %lu\n", - uaa->driver_info); - return (ENXIO); - } DPRINTFN(ATP_LLEVEL_INFO, "sc=%p\n", sc); sc->sc_dev = dev; @@ -1626,7 +1664,6 @@ atp_detach(device_t dev) { struct atp_softc *sc; - int err; sc = device_get_softc(dev); if (sc->sc_state & ATP_ENABLED) { @@ -1641,12 +1678,6 @@ mtx_destroy(&sc->sc_mutex); - err = atp_set_device_mode(dev, HID_MODE); - if (err != 0) { - DPRINTF("failed to reset mode to 'HID' (%d)\n", err); - return (err); - } - return (0); } @@ -1823,10 +1854,7 @@ if (sc->sc_idlecount >= ATP_IDLENESS_THRESHOLD) { DPRINTFN(ATP_LLEVEL_INFO, "idle\n"); sc->sc_idlecount = 0; - - mtx_unlock(&sc->sc_mutex); - atp_set_device_mode(sc->sc_dev,RAW_SENSOR_MODE); - mtx_lock(&sc->sc_mutex); + usbd_transfer_start(sc->sc_xfer[ATP_RESET]); } } else { sc->sc_idlecount = 0;
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200911192235.nAJMZ2XH072195>