Lines Matching refs:sc
139 struct uhid_softc *sc = usbd_xfer_softc(xfer); in uhid_intr_write_callback() local
148 if (usb_fifo_get_data(sc->sc_fifo.fp[USB_FIFO_TX], pc, in uhid_intr_write_callback()
195 struct uhid_softc *sc = usbd_xfer_softc(xfer); in uhid_intr_read_callback() local
206 if (sc->input_dev && sc->input_dev->devType == INDEV_TYPE_MOUSE) { in uhid_intr_read_callback()
207 mouse_report_events(sc->input_dev, pc->buffer, actlen); in uhid_intr_read_callback()
211 usbd_xfer_set_frame_len(xfer, 0, sc->sc_isize); in uhid_intr_read_callback()
218 usbd_xfer_set_frame_len(xfer, 0, sc->sc_isize); in uhid_intr_read_callback()
252 struct uhid_softc *sc = usbd_xfer_softc(xfer); in uhid_write_callback() local
255 uint32_t size = sc->sc_osize; in uhid_write_callback()
263 if (sc->sc_oid) { in uhid_write_callback()
265 if (usb_fifo_get_data(sc->sc_fifo.fp[USB_FIFO_TX], pc, in uhid_write_callback()
283 if (usb_fifo_get_data(sc->sc_fifo.fp[USB_FIFO_TX], pc, in uhid_write_callback()
289 (&req, sc->sc_iface_no, in uhid_write_callback()
305 usb_fifo_get_data_error(sc->sc_fifo.fp[USB_FIFO_TX]); in uhid_write_callback()
313 struct uhid_softc *sc = usbd_xfer_softc(xfer); in uhid_read_callback() local
323 usb_fifo_put_data(sc->sc_fifo.fp[USB_FIFO_RX], pc, sizeof(req), in uhid_read_callback()
324 sc->sc_isize, 1); in uhid_read_callback()
329 if (usb_fifo_put_bytes_max(sc->sc_fifo.fp[USB_FIFO_RX]) > 0) { in uhid_read_callback()
331 (&req, sc->sc_iface_no, UHID_INPUT_REPORT, in uhid_read_callback()
332 sc->sc_iid, sc->sc_isize); in uhid_read_callback()
337 usbd_xfer_set_frame_len(xfer, 1, sc->sc_isize); in uhid_read_callback()
338 usbd_xfer_set_frames(xfer, sc->sc_isize ? 2 : 1); in uhid_read_callback()
345 usb_fifo_put_data_error(sc->sc_fifo.fp[USB_FIFO_RX]); in uhid_read_callback()
391 struct uhid_softc *sc = usb_fifo_softc(fifo); in uhid_start_read() local
393 if (sc->sc_flags & UHID_FLAG_IMMED) { in uhid_start_read()
394 usbd_transfer_start(sc->sc_xfer[UHID_CTRL_DT_RD]); in uhid_start_read()
396 usbd_transfer_start(sc->sc_xfer[UHID_INTR_DT_RD]); in uhid_start_read()
403 struct uhid_softc *sc = usb_fifo_softc(fifo); in uhid_stop_read() local
405 usbd_transfer_stop(sc->sc_xfer[UHID_CTRL_DT_RD]); in uhid_stop_read()
406 usbd_transfer_stop(sc->sc_xfer[UHID_INTR_DT_RD]); in uhid_stop_read()
412 struct uhid_softc *sc = usb_fifo_softc(fifo); in uhid_start_write() local
414 if ((sc->sc_flags & UHID_FLAG_IMMED) || in uhid_start_write()
415 sc->sc_xfer[UHID_INTR_DT_WR] == NULL) { in uhid_start_write()
416 usbd_transfer_start(sc->sc_xfer[UHID_CTRL_DT_WR]); in uhid_start_write()
418 usbd_transfer_start(sc->sc_xfer[UHID_INTR_DT_WR]); in uhid_start_write()
425 struct uhid_softc *sc = usb_fifo_softc(fifo); in uhid_stop_write() local
427 usbd_transfer_stop(sc->sc_xfer[UHID_CTRL_DT_WR]); in uhid_stop_write()
428 usbd_transfer_stop(sc->sc_xfer[UHID_INTR_DT_WR]); in uhid_stop_write()
432 uhid_get_report(struct uhid_softc *sc, uint8_t type, in uhid_get_report() argument
452 err = usbd_req_get_report(sc->sc_udev, NULL, kern_data, in uhid_get_report()
453 len, sc->sc_iface_index, type, id); in uhid_get_report()
473 uhid_set_report(struct uhid_softc *sc, uint8_t type, in uhid_set_report() argument
497 err = usbd_req_set_report(sc->sc_udev, NULL, kern_data, in uhid_set_report()
498 len, sc->sc_iface_index, type, id); in uhid_set_report()
513 struct uhid_softc *sc = usb_fifo_softc(fifo); in uhid_open() local
521 mtx_lock(&sc->sc_mtx); in uhid_open()
522 sc->sc_flags &= ~UHID_FLAG_IMMED; in uhid_open()
523 mtx_unlock(&sc->sc_mtx); in uhid_open()
526 sc->sc_isize + 1, UHID_FRAME_NUM)) { in uhid_open()
532 sc->sc_osize + 1, UHID_FRAME_NUM)) { in uhid_open()
552 struct uhid_softc *sc = usb_fifo_softc(fifo); in uhid_ioctl() local
564 if (sc->sc_repdesc_size > ugd.ugd_maxlen) { in uhid_ioctl()
567 size = sc->sc_repdesc_size; in uhid_ioctl()
572 error = copyout(sc->sc_repdesc_ptr, ugd.ugd_data, size); in uhid_ioctl()
591 error = uhid_get_report(sc, UHID_INPUT_REPORT, in uhid_ioctl()
592 sc->sc_iid, NULL, NULL, sc->sc_isize); in uhid_ioctl()
596 mtx_lock(&sc->sc_mtx); in uhid_ioctl()
597 sc->sc_flags |= UHID_FLAG_IMMED; in uhid_ioctl()
598 mtx_unlock(&sc->sc_mtx); in uhid_ioctl()
600 mtx_lock(&sc->sc_mtx); in uhid_ioctl()
601 sc->sc_flags &= ~UHID_FLAG_IMMED; in uhid_ioctl()
602 mtx_unlock(&sc->sc_mtx); in uhid_ioctl()
618 size = sc->sc_isize; in uhid_ioctl()
619 id = sc->sc_iid; in uhid_ioctl()
622 size = sc->sc_osize; in uhid_ioctl()
623 id = sc->sc_oid; in uhid_ioctl()
626 size = sc->sc_fsize; in uhid_ioctl()
627 id = sc->sc_fid; in uhid_ioctl()
634 error = uhid_get_report(sc, ugd.ugd_report_type, id, in uhid_ioctl()
649 size = sc->sc_isize; in uhid_ioctl()
650 id = sc->sc_iid; in uhid_ioctl()
653 size = sc->sc_osize; in uhid_ioctl()
654 id = sc->sc_oid; in uhid_ioctl()
657 size = sc->sc_fsize; in uhid_ioctl()
658 id = sc->sc_fid; in uhid_ioctl()
665 error = uhid_set_report(sc, ugd.ugd_report_type, id, in uhid_ioctl()
736 struct uhid_softc *sc = device_get_softc(dev); in uhid_attach() local
741 DPRINTFN(10, "sc=%p\n", sc); in uhid_attach()
745 mtx_init(&sc->sc_mtx, "uhid lock", NULL, MTX_DEF | MTX_RECURSE); in uhid_attach()
747 sc->sc_udev = uaa->device; in uhid_attach()
749 sc->sc_iface_no = uaa->info.bIfaceNum; in uhid_attach()
750 sc->sc_iface_index = uaa->info.bIfaceIndex; in uhid_attach()
753 &uaa->info.bIfaceIndex, sc->sc_xfer, uhid_config, in uhid_attach()
754 UHID_N_TRANSFER, sc, &sc->sc_mtx); in uhid_attach()
764 sc->sc_repdesc_size = sizeof(uhid_graphire_report_descr); in uhid_attach()
765 sc->sc_repdesc_ptr = __DECONST(void *, &uhid_graphire_report_descr); in uhid_attach()
766 sc->sc_flags |= UHID_FLAG_STATIC_DESC; in uhid_attach()
784 sc->sc_repdesc_size = sizeof(uhid_graphire3_4x5_report_descr); in uhid_attach()
785 sc->sc_repdesc_ptr = __DECONST(void *, &uhid_graphire3_4x5_report_descr); in uhid_attach()
786 sc->sc_flags |= UHID_FLAG_STATIC_DESC; in uhid_attach()
804 sc->sc_repdesc_size = sizeof(uhid_xb360gp_report_descr); in uhid_attach()
805 sc->sc_repdesc_ptr = __DECONST(void *, &uhid_xb360gp_report_descr); in uhid_attach()
806 sc->sc_flags |= UHID_FLAG_STATIC_DESC; in uhid_attach()
809 if (sc->sc_repdesc_ptr == NULL) { in uhid_attach()
811 &sc->sc_repdesc_ptr, &sc->sc_repdesc_size, in uhid_attach()
828 sc->sc_isize = hid_report_size in uhid_attach()
829 (sc->sc_repdesc_ptr, sc->sc_repdesc_size, hid_input, &sc->sc_iid); in uhid_attach()
831 sc->sc_osize = hid_report_size in uhid_attach()
832 (sc->sc_repdesc_ptr, sc->sc_repdesc_size, hid_output, &sc->sc_oid); in uhid_attach()
834 sc->sc_fsize = hid_report_size in uhid_attach()
835 (sc->sc_repdesc_ptr, sc->sc_repdesc_size, hid_feature, &sc->sc_fid); in uhid_attach()
837 if (sc->sc_isize > UHID_BSIZE) { in uhid_attach()
840 sc->sc_isize); in uhid_attach()
841 sc->sc_isize = UHID_BSIZE; in uhid_attach()
843 if (sc->sc_osize > UHID_BSIZE) { in uhid_attach()
846 sc->sc_osize); in uhid_attach()
847 sc->sc_osize = UHID_BSIZE; in uhid_attach()
849 if (sc->sc_fsize > UHID_BSIZE) { in uhid_attach()
852 sc->sc_fsize); in uhid_attach()
853 sc->sc_fsize = UHID_BSIZE; in uhid_attach()
856 error = usb_fifo_attach(uaa->device, sc, &sc->sc_mtx, in uhid_attach()
857 &uhid_fifo_methods, &sc->sc_fifo, in uhid_attach()
864 sc->input_dev = (InputDevice*)zalloc(sizeof(InputDevice)); in uhid_attach()
865 if (sc->input_dev) { in uhid_attach()
867 sc->input_dev->devType = INDEV_TYPE_MOUSE; in uhid_attach()
868 sc->input_dev->devName = "mouse"; in uhid_attach()
870 sc->input_dev->devType = INDEV_TYPE_UNKNOWN; in uhid_attach()
871 sc->input_dev->devName = "other"; in uhid_attach()
874 ret = RegisterInputDevice(sc->input_dev); in uhid_attach()
876 DPRINTF("%s register failed, ret = %d!\n", sc->input_dev->devName, ret); in uhid_attach()
877 free(sc->input_dev); in uhid_attach()
878 sc->input_dev = NULL; in uhid_attach()
879 } else if (sc->input_dev->devType == INDEV_TYPE_MOUSE) { in uhid_attach()
881 mtx_lock(&sc->sc_mtx); in uhid_attach()
882 sc->sc_flags &= ~UHID_FLAG_IMMED; in uhid_attach()
883 usbd_transfer_start(sc->sc_xfer[UHID_INTR_DT_RD]); in uhid_attach()
884 mtx_unlock(&sc->sc_mtx); in uhid_attach()
898 struct uhid_softc *sc = device_get_softc(dev); in uhid_detach() local
902 if (sc->input_dev) { in uhid_detach()
903 if (sc->input_dev->devType == INDEV_TYPE_MOUSE) { in uhid_detach()
904 usbd_transfer_stop(sc->sc_xfer[UHID_INTR_DT_RD]); in uhid_detach()
907 UnregisterInputDevice(sc->input_dev); in uhid_detach()
908 free(sc->input_dev); in uhid_detach()
909 sc->input_dev = NULL; in uhid_detach()
912 usb_fifo_detach(&sc->sc_fifo); in uhid_detach()
914 usbd_transfer_unsetup(sc->sc_xfer, UHID_N_TRANSFER); in uhid_detach()
916 if (sc->sc_repdesc_ptr) { in uhid_detach()
917 if (!(sc->sc_flags & UHID_FLAG_STATIC_DESC)) { in uhid_detach()
918 free(sc->sc_repdesc_ptr); in uhid_detach()
921 mtx_destroy(&sc->sc_mtx); in uhid_detach()