FreeBSD kernel usb device Code
ulpt.c
Go to the documentation of this file.
1#include <sys/cdefs.h>
2__FBSDID("$FreeBSD$");
3
4/* $NetBSD: ulpt.c,v 1.60 2003/10/04 21:19:50 augustss Exp $ */
5
6/*-
7 * SPDX-License-Identifier: BSD-2-Clause-NetBSD
8 *
9 * Copyright (c) 1998, 2003 The NetBSD Foundation, Inc.
10 * All rights reserved.
11 *
12 * This code is derived from software contributed to The NetBSD Foundation
13 * by Lennart Augustsson (lennart@augustsson.net) at
14 * Carlstedt Research & Technology.
15 *
16 * Redistribution and use in source and binary forms, with or without
17 * modification, are permitted provided that the following conditions
18 * are met:
19 * 1. Redistributions of source code must retain the above copyright
20 * notice, this list of conditions and the following disclaimer.
21 * 2. Redistributions in binary form must reproduce the above copyright
22 * notice, this list of conditions and the following disclaimer in the
23 * documentation and/or other materials provided with the distribution.
24 *
25 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
26 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
27 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
28 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
29 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
30 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
31 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
32 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
33 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
34 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
35 * POSSIBILITY OF SUCH DAMAGE.
36 */
37
38/*
39 * Printer Class spec: http://www.usb.org/developers/data/devclass/usbprint109.PDF
40 * Printer Class spec: http://www.usb.org/developers/devclass_docs/usbprint11.pdf
41 */
42
43#include <sys/stdint.h>
44#include <sys/stddef.h>
45#include <sys/param.h>
46#include <sys/queue.h>
47#include <sys/types.h>
48#include <sys/systm.h>
49#include <sys/kernel.h>
50#include <sys/bus.h>
51#include <sys/module.h>
52#include <sys/lock.h>
53#include <sys/mutex.h>
54#include <sys/condvar.h>
55#include <sys/sysctl.h>
56#include <sys/sx.h>
57#include <sys/unistd.h>
58#include <sys/callout.h>
59#include <sys/malloc.h>
60#include <sys/priv.h>
61#include <sys/syslog.h>
62#include <sys/selinfo.h>
63#include <sys/conf.h>
64#include <sys/fcntl.h>
65
66#include <dev/usb/usb.h>
67#include <dev/usb/usbdi.h>
68#include <dev/usb/usbdi_util.h>
69#include <dev/usb/usbhid.h>
70#include "usbdevs.h"
71
72#define USB_DEBUG_VAR ulpt_debug
73#include <dev/usb/usb_debug.h>
74#include <dev/usb/usb_process.h>
75
76#ifdef USB_DEBUG
77static int ulpt_debug = 0;
78
79static SYSCTL_NODE(_hw_usb, OID_AUTO, ulpt, CTLFLAG_RW | CTLFLAG_MPSAFE, 0,
80 "USB ulpt");
81SYSCTL_INT(_hw_usb_ulpt, OID_AUTO, debug, CTLFLAG_RWTUN,
82 &ulpt_debug, 0, "Debug level");
83#endif
84
85#define ULPT_BSIZE (1<<15) /* bytes */
86#define ULPT_IFQ_MAXLEN 2 /* units */
87
88#define UR_GET_DEVICE_ID 0x00
89#define UR_GET_PORT_STATUS 0x01
90#define UR_SOFT_RESET 0x02
91
92#define LPS_NERR 0x08 /* printer no error */
93#define LPS_SELECT 0x10 /* printer selected */
94#define LPS_NOPAPER 0x20 /* printer out of paper */
95#define LPS_INVERT (LPS_SELECT|LPS_NERR)
96#define LPS_MASK (LPS_SELECT|LPS_NERR|LPS_NOPAPER)
97
98enum {
103};
104
108 struct mtx sc_mtx;
110
111 device_t sc_dev;
115
116 int sc_fflags; /* current open flags, FREAD and
117 * FWRITE */
118 uint8_t sc_iface_no;
120 uint8_t sc_zlps; /* number of consequtive zero length
121 * packets received */
122};
123
124/* prototypes */
125
126static device_probe_t ulpt_probe;
127static device_attach_t ulpt_attach;
128static device_detach_t ulpt_detach;
129
133
134static void ulpt_reset(struct ulpt_softc *);
135static void ulpt_watchdog(void *);
136
145
148 .f_ioctl = &ulpt_ioctl,
149 .f_open = &ulpt_open,
150 .f_start_read = &ulpt_start_read,
151 .f_start_write = &ulpt_start_write,
152 .f_stop_read = &ulpt_stop_read,
153 .f_stop_write = &ulpt_stop_write,
154 .basename[0] = "ulpt",
155};
156
159 .f_ioctl = &ulpt_ioctl,
160 .f_open = &unlpt_open,
161 .f_start_read = &ulpt_start_read,
162 .f_start_write = &ulpt_start_write,
163 .f_stop_read = &ulpt_stop_read,
164 .f_stop_write = &ulpt_stop_write,
165 .basename[0] = "unlpt",
166};
167
168static void
170{
171 struct usb_device_request req;
172
173 DPRINTFN(2, "\n");
174
175 req.bRequest = UR_SOFT_RESET;
176 USETW(req.wValue, 0);
177 USETW(req.wIndex, sc->sc_iface_no);
178 USETW(req.wLength, 0);
179
180 /*
181 * There was a mistake in the USB printer 1.0 spec that gave the
182 * request type as UT_WRITE_CLASS_OTHER; it should have been
183 * UT_WRITE_CLASS_INTERFACE. Many printers use the old one,
184 * so we try both.
185 */
186
187 mtx_lock(&sc->sc_mtx);
188 req.bmRequestType = UT_WRITE_CLASS_OTHER;
190 &req, NULL, 0, NULL, 2 * USB_MS_HZ)) { /* 1.0 */
191 req.bmRequestType = UT_WRITE_CLASS_INTERFACE;
193 &req, NULL, 0, NULL, 2 * USB_MS_HZ)) { /* 1.1 */
194 /* ignore error */
195 }
196 }
197 mtx_unlock(&sc->sc_mtx);
198}
199
200static void
202{
203 struct ulpt_softc *sc = usbd_xfer_softc(xfer);
204 struct usb_fifo *f = sc->sc_fifo_open[USB_FIFO_TX];
205 struct usb_page_cache *pc;
206 int actlen, max;
207
208 usbd_xfer_status(xfer, &actlen, NULL, NULL, NULL);
209
210 if (f == NULL) {
211 /* should not happen */
212 DPRINTF("no FIFO\n");
213 return;
214 }
215 DPRINTF("state=0x%x actlen=%d\n", USB_GET_STATE(xfer), actlen);
216
217 switch (USB_GET_STATE(xfer)) {
219 case USB_ST_SETUP:
220tr_setup:
221 pc = usbd_xfer_get_frame(xfer, 0);
222 max = usbd_xfer_max_len(xfer);
223 if (usb_fifo_get_data(f, pc, 0, max, &actlen, 0)) {
224 usbd_xfer_set_frame_len(xfer, 0, actlen);
226 }
227 break;
228
229 default: /* Error */
230 if (error != USB_ERR_CANCELLED) {
231 /* try to clear stall first */
233 goto tr_setup;
234 }
235 break;
236 }
237}
238
239static void
241{
242 struct ulpt_softc *sc = usbd_xfer_softc(xfer);
243 struct usb_fifo *f = sc->sc_fifo_open[USB_FIFO_RX];
244 struct usb_page_cache *pc;
245 int actlen;
246
247 usbd_xfer_status(xfer, &actlen, NULL, NULL, NULL);
248
249 if (f == NULL) {
250 /* should not happen */
251 DPRINTF("no FIFO\n");
252 return;
253 }
254 DPRINTF("state=0x%x\n", USB_GET_STATE(xfer));
255
256 switch (USB_GET_STATE(xfer)) {
258
259 if (actlen == 0) {
260 if (sc->sc_zlps == 4) {
261 /* enable BULK throttle */
262 usbd_xfer_set_interval(xfer, 500); /* ms */
263 } else {
264 sc->sc_zlps++;
265 }
266 } else {
267 /* disable BULK throttle */
268
269 usbd_xfer_set_interval(xfer, 0);
270 sc->sc_zlps = 0;
271 }
272
273 pc = usbd_xfer_get_frame(xfer, 0);
274 usb_fifo_put_data(f, pc, 0, actlen, 1);
275
276 case USB_ST_SETUP:
277tr_setup:
278 if (usb_fifo_put_bytes_max(f) != 0) {
281 }
282 break;
283
284 default: /* Error */
285 /* disable BULK throttle */
286 usbd_xfer_set_interval(xfer, 0);
287 sc->sc_zlps = 0;
288
289 if (error != USB_ERR_CANCELLED) {
290 /* try to clear stall first */
292 goto tr_setup;
293 }
294 break;
295 }
296}
297
298static void
300{
301 struct ulpt_softc *sc = usbd_xfer_softc(xfer);
302 struct usb_device_request req;
303 struct usb_page_cache *pc;
304 uint8_t cur_status;
305 uint8_t new_status;
306
307 switch (USB_GET_STATE(xfer)) {
309
310 pc = usbd_xfer_get_frame(xfer, 1);
311 usbd_copy_out(pc, 0, &cur_status, 1);
312
313 cur_status = (cur_status ^ LPS_INVERT) & LPS_MASK;
314 new_status = cur_status & ~sc->sc_last_status;
315 sc->sc_last_status = cur_status;
316
317 if (new_status & LPS_SELECT)
318 log(LOG_NOTICE, "%s: offline\n",
319 device_get_nameunit(sc->sc_dev));
320 else if (new_status & LPS_NOPAPER)
321 log(LOG_NOTICE, "%s: out of paper\n",
322 device_get_nameunit(sc->sc_dev));
323 else if (new_status & LPS_NERR)
324 log(LOG_NOTICE, "%s: output error\n",
325 device_get_nameunit(sc->sc_dev));
326 break;
327
328 case USB_ST_SETUP:
329 req.bmRequestType = UT_READ_CLASS_INTERFACE;
330 req.bRequest = UR_GET_PORT_STATUS;
331 USETW(req.wValue, 0);
332 req.wIndex[0] = sc->sc_iface_no;
333 req.wIndex[1] = 0;
334 USETW(req.wLength, 1);
335
336 pc = usbd_xfer_get_frame(xfer, 0);
337 usbd_copy_in(pc, 0, &req, sizeof(req));
338
339 usbd_xfer_set_frame_len(xfer, 0, sizeof(req));
340 usbd_xfer_set_frame_len(xfer, 1, 1);
341 usbd_xfer_set_frames(xfer, 2);
343 break;
344
345 default: /* Error */
346 DPRINTF("error=%s\n", usbd_errstr(error));
347 if (error != USB_ERR_CANCELLED) {
348 /* wait for next watchdog timeout */
349 }
350 break;
351 }
352}
353
354static const struct usb_config ulpt_config[ULPT_N_TRANSFER] = {
355 [ULPT_BULK_DT_WR] = {
356 .type = UE_BULK,
357 .endpoint = UE_ADDR_ANY,
358 .direction = UE_DIR_OUT,
359 .bufsize = ULPT_BSIZE,
360 .flags = {.pipe_bof = 1,.proxy_buffer = 1},
361 .callback = &ulpt_write_callback,
362 },
363
364 [ULPT_BULK_DT_RD] = {
365 .type = UE_BULK,
366 .endpoint = UE_ADDR_ANY,
367 .direction = UE_DIR_IN,
368 .bufsize = ULPT_BSIZE,
369 .flags = {.pipe_bof = 1,.short_xfer_ok = 1,.proxy_buffer = 1},
370 .callback = &ulpt_read_callback,
371 },
372
373 [ULPT_INTR_DT_RD] = {
374 .type = UE_CONTROL,
375 .endpoint = 0x00, /* Control pipe */
376 .direction = UE_DIR_ANY,
377 .bufsize = sizeof(struct usb_device_request) + 1,
378 .callback = &ulpt_status_callback,
379 .timeout = 1000, /* 1 second */
380 },
381};
382
383static void
385{
386 struct ulpt_softc *sc = usb_fifo_softc(fifo);
387
389}
390
391static void
393{
394 struct ulpt_softc *sc = usb_fifo_softc(fifo);
395
397}
398
399static void
401{
402 struct ulpt_softc *sc = usb_fifo_softc(fifo);
403
405}
406
407static void
409{
410 struct ulpt_softc *sc = usb_fifo_softc(fifo);
411
413}
414
415static int
416ulpt_open(struct usb_fifo *fifo, int fflags)
417{
418 struct ulpt_softc *sc = usb_fifo_softc(fifo);
419
420 /* we assume that open is a serial process */
421
422 if (sc->sc_fflags == 0) {
423 /* reset USB parallel port */
424
425 ulpt_reset(sc);
426 }
427 return (unlpt_open(fifo, fflags));
428}
429
430static int
431unlpt_open(struct usb_fifo *fifo, int fflags)
432{
433 struct ulpt_softc *sc = usb_fifo_softc(fifo);
434
435 if (sc->sc_fflags & fflags) {
436 return (EBUSY);
437 }
438 if (fflags & FREAD) {
439 /* clear stall first */
440 mtx_lock(&sc->sc_mtx);
442 mtx_unlock(&sc->sc_mtx);
443 if (usb_fifo_alloc_buffer(fifo,
446 return (ENOMEM);
447 }
448 /* set which FIFO is opened */
449 sc->sc_fifo_open[USB_FIFO_RX] = fifo;
450 }
451 if (fflags & FWRITE) {
452 /* clear stall first */
453 mtx_lock(&sc->sc_mtx);
455 mtx_unlock(&sc->sc_mtx);
456 if (usb_fifo_alloc_buffer(fifo,
459 return (ENOMEM);
460 }
461 /* set which FIFO is opened */
462 sc->sc_fifo_open[USB_FIFO_TX] = fifo;
463 }
464 sc->sc_fflags |= fflags & (FREAD | FWRITE);
465 return (0);
466}
467
468static void
469ulpt_close(struct usb_fifo *fifo, int fflags)
470{
471 struct ulpt_softc *sc = usb_fifo_softc(fifo);
472
473 sc->sc_fflags &= ~(fflags & (FREAD | FWRITE));
474
475 if (fflags & (FREAD | FWRITE)) {
477 }
478}
479
480static int
481ulpt_ioctl(struct usb_fifo *fifo, u_long cmd, void *data,
482 int fflags)
483{
484 return (ENODEV);
485}
486
488 /* Uni-directional USB printer */
492
493 /* Bi-directional USB printer */
497
498 /* 1284 USB printer */
502};
503
504static int
505ulpt_probe(device_t dev)
506{
507 struct usb_attach_arg *uaa = device_get_ivars(dev);
508 int error;
509
510 DPRINTFN(11, "\n");
511
512 if (uaa->usb_mode != USB_MODE_HOST)
513 return (ENXIO);
514
516 if (error)
517 return (error);
518
519 return (BUS_PROBE_GENERIC);
520}
521
522static int
523ulpt_attach(device_t dev)
524{
525 struct usb_attach_arg *uaa = device_get_ivars(dev);
526 struct ulpt_softc *sc = device_get_softc(dev);
528 int unit = device_get_unit(dev);
529 int error;
530 uint8_t iface_index = uaa->info.bIfaceIndex;
531 uint8_t alt_index;
532
533 DPRINTFN(11, "sc=%p\n", sc);
534
535 sc->sc_dev = dev;
536 sc->sc_udev = uaa->device;
537
539
540 mtx_init(&sc->sc_mtx, "ulpt lock", NULL, MTX_DEF | MTX_RECURSE);
541
543
544 /* search through all the descriptors looking for bidir mode */
545
547 alt_index = 0xFF;
548 while (1) {
549 if (id == NULL) {
550 break;
551 }
552 if ((id->bDescriptorType == UDESC_INTERFACE) &&
553 (id->bLength >= sizeof(*id))) {
554 if (id->bInterfaceNumber != uaa->info.bIfaceNum) {
555 break;
556 } else {
557 alt_index++;
558 if ((id->bInterfaceClass == UICLASS_PRINTER) &&
559 (id->bInterfaceSubClass == UISUBCLASS_PRINTER) &&
560 (id->bInterfaceProtocol == UIPROTO_PRINTER_BI)) {
561 goto found;
562 }
563 }
564 }
565 id = (void *)usb_desc_foreach(
566 usbd_get_config_descriptor(uaa->device), (void *)id);
567 }
568 goto detach;
569
570found:
571
572 DPRINTF("setting alternate "
573 "config number: %d\n", alt_index);
574
575 if (alt_index) {
577 (uaa->device, iface_index, alt_index);
578
579 if (error) {
580 DPRINTF("could not set alternate "
581 "config, error=%s\n", usbd_errstr(error));
582 goto detach;
583 }
584 }
585 sc->sc_iface_no = id->bInterfaceNumber;
586
587 error = usbd_transfer_setup(uaa->device, &iface_index,
589 sc, &sc->sc_mtx);
590 if (error) {
591 DPRINTF("error=%s\n", usbd_errstr(error));
592 goto detach;
593 }
594 device_printf(sc->sc_dev, "using bi-directional mode\n");
595
596#if 0
597/*
598 * This code is disabled because for some mysterious reason it causes
599 * printing not to work. But only sometimes, and mostly with
600 * UHCI and less often with OHCI. *sigh*
601 */
602 {
604 struct usb_device_request req;
605 int len, alen;
606
607 req.bmRequestType = UT_READ_CLASS_INTERFACE;
608 req.bRequest = UR_GET_DEVICE_ID;
609 USETW(req.wValue, cd->bConfigurationValue);
610 USETW2(req.wIndex, id->bInterfaceNumber, id->bAlternateSetting);
611 USETW(req.wLength, sizeof devinfo - 1);
613 &alen, USB_DEFAULT_TIMEOUT);
614 if (error) {
615 device_printf(sc->sc_dev, "cannot get device id\n");
616 } else if (alen <= 2) {
617 device_printf(sc->sc_dev, "empty device id, no "
618 "printer connected?\n");
619 } else {
620 /* devinfo now contains an IEEE-1284 device ID */
621 len = ((devinfo[0] & 0xff) << 8) | (devinfo[1] & 0xff);
622 if (len > sizeof devinfo - 3)
623 len = sizeof devinfo - 3;
624 devinfo[len] = 0;
625 printf("%s: device id <", device_get_nameunit(sc->sc_dev));
626 ieee1284_print_id(devinfo + 2);
627 printf(">\n");
628 }
629 }
630#endif
631
632 error = usb_fifo_attach(uaa->device, sc, &sc->sc_mtx,
634 unit, -1, uaa->info.bIfaceIndex,
635 UID_ROOT, GID_OPERATOR, 0644);
636 if (error) {
637 goto detach;
638 }
639 error = usb_fifo_attach(uaa->device, sc, &sc->sc_mtx,
641 unit, -1, uaa->info.bIfaceIndex,
642 UID_ROOT, GID_OPERATOR, 0644);
643 if (error) {
644 goto detach;
645 }
646 /* start reading of status */
647
648 mtx_lock(&sc->sc_mtx);
649 ulpt_watchdog(sc);
650 mtx_unlock(&sc->sc_mtx);
651 return (0);
652
653detach:
655 return (ENOMEM);
656}
657
658static int
659ulpt_detach(device_t dev)
660{
661 struct ulpt_softc *sc = device_get_softc(dev);
662
663 DPRINTF("sc=%p\n", sc);
664
667
668 mtx_lock(&sc->sc_mtx);
670 mtx_unlock(&sc->sc_mtx);
671
674 mtx_destroy(&sc->sc_mtx);
675
676 return (0);
677}
678
679#if 0
680/* XXX This does not belong here. */
681
682/*
683 * Compare two strings until the second ends.
684 */
685
686static uint8_t
687ieee1284_compare(const char *a, const char *b)
688{
689 while (1) {
690 if (*b == 0) {
691 break;
692 }
693 if (*a != *b) {
694 return 1;
695 }
696 b++;
697 a++;
698 }
699 return 0;
700}
701
702/*
703 * Print select parts of an IEEE 1284 device ID.
704 */
705void
706ieee1284_print_id(char *str)
707{
708 char *p, *q;
709
710 for (p = str - 1; p; p = strchr(p, ';')) {
711 p++; /* skip ';' */
712 if (ieee1284_compare(p, "MFG:") == 0 ||
713 ieee1284_compare(p, "MANUFACTURER:") == 0 ||
714 ieee1284_compare(p, "MDL:") == 0 ||
715 ieee1284_compare(p, "MODEL:") == 0) {
716 q = strchr(p, ';');
717 if (q)
718 printf("%.*s", (int)(q - p + 1), p);
719 }
720 }
721}
722
723#endif
724
725static void
727{
728 struct ulpt_softc *sc = arg;
729
730 mtx_assert(&sc->sc_mtx, MA_OWNED);
731
732 /*
733 * Only read status while the device is not opened, due to
734 * possible hardware or firmware bug in some printers.
735 */
736 if (sc->sc_fflags == 0)
738
740 hz, &ulpt_watchdog, sc);
741}
742
743static devclass_t ulpt_devclass;
744
745static device_method_t ulpt_methods[] = {
746 DEVMETHOD(device_probe, ulpt_probe),
747 DEVMETHOD(device_attach, ulpt_attach),
748 DEVMETHOD(device_detach, ulpt_detach),
749 DEVMETHOD_END
750};
751
752static driver_t ulpt_driver = {
753 .name = "ulpt",
754 .methods = ulpt_methods,
755 .size = sizeof(struct ulpt_softc),
756};
757
759MODULE_DEPEND(ulpt, usb, 1, 1, 1);
static int debug
Definition: cfumass.c:73
static SYSCTL_NODE(_hw_usb, OID_AUTO, dwc_otg, CTLFLAG_RW|CTLFLAG_MPSAFE, 0, "USB DWC OTG")
SYSCTL_INT(_hw_usb_dwc_otg, OID_AUTO, phy_type, CTLFLAG_RDTUN, &dwc_otg_phy_type, 0, "DWC OTG PHY TYPE - 0/1/2/3 - ULPI/HSIC/INTERNAL/UTMI+")
uint16_t len
Definition: ehci.h:41
struct @109 error
uint8_t id
Definition: if_usievar.h:4
device_t dev
uint8_t sc_zlps
Definition: ulpt.c:120
struct usb_fifo_sc sc_fifo
Definition: ulpt.c:106
device_t sc_dev
Definition: ulpt.c:111
struct usb_fifo * sc_fifo_open[2]
Definition: ulpt.c:113
struct usb_fifo_sc sc_fifo_noreset
Definition: ulpt.c:107
struct usb_device * sc_udev
Definition: ulpt.c:112
int sc_fflags
Definition: ulpt.c:116
struct usb_callout sc_watchdog
Definition: ulpt.c:109
uint8_t sc_iface_no
Definition: ulpt.c:118
uint8_t sc_last_status
Definition: ulpt.c:119
struct mtx sc_mtx
Definition: ulpt.c:108
struct usb_xfer * sc_xfer[ULPT_N_TRANSFER]
Definition: ulpt.c:114
enum usb_hc_mode usb_mode
Definition: usbdi.h:432
struct usbd_lookup_info info
Definition: usbdi.h:426
struct usb_interface * iface
Definition: usbdi.h:431
struct usb_device * device
Definition: usbdi.h:430
uByte bConfigurationValue
Definition: usb.h:390
uint8_t type
Definition: usbdi.h:238
usb_fifo_close_t * f_close
Definition: usbdi.h:536
uint8_t bIfaceNum
Definition: usbdi.h:418
uint8_t bIfaceIndex
Definition: usbdi.h:417
USB_PNP_HOST_INFO(ulpt_devs)
static usb_fifo_close_t ulpt_close
Definition: ulpt.c:137
static usb_fifo_ioctl_t ulpt_ioctl
Definition: ulpt.c:142
static usb_fifo_cmd_t ulpt_start_read
Definition: ulpt.c:138
static usb_callback_t ulpt_write_callback
Definition: ulpt.c:130
#define ULPT_BSIZE
Definition: ulpt.c:85
static usb_fifo_cmd_t ulpt_start_write
Definition: ulpt.c:139
#define LPS_SELECT
Definition: ulpt.c:93
static struct usb_fifo_methods unlpt_fifo_methods
Definition: ulpt.c:157
static void ulpt_watchdog(void *)
Definition: ulpt.c:726
static void ulpt_reset(struct ulpt_softc *)
Definition: ulpt.c:169
static const STRUCT_USB_HOST_ID ulpt_devs[]
Definition: ulpt.c:487
static device_attach_t ulpt_attach
Definition: ulpt.c:127
static driver_t ulpt_driver
Definition: ulpt.c:752
static const struct usb_config ulpt_config[ULPT_N_TRANSFER]
Definition: ulpt.c:354
#define LPS_NOPAPER
Definition: ulpt.c:94
static usb_fifo_cmd_t ulpt_stop_read
Definition: ulpt.c:140
static device_detach_t ulpt_detach
Definition: ulpt.c:128
static usb_fifo_open_t unlpt_open
Definition: ulpt.c:144
static usb_fifo_cmd_t ulpt_stop_write
Definition: ulpt.c:141
DRIVER_MODULE(ulpt, uhub, ulpt_driver, ulpt_devclass, NULL, 0)
__FBSDID("$FreeBSD$")
static device_method_t ulpt_methods[]
Definition: ulpt.c:745
#define UR_GET_PORT_STATUS
Definition: ulpt.c:89
#define UR_GET_DEVICE_ID
Definition: ulpt.c:88
MODULE_DEPEND(ulpt, usb, 1, 1, 1)
static usb_callback_t ulpt_status_callback
Definition: ulpt.c:132
#define LPS_MASK
Definition: ulpt.c:96
#define ULPT_IFQ_MAXLEN
Definition: ulpt.c:86
static usb_callback_t ulpt_read_callback
Definition: ulpt.c:131
static usb_fifo_open_t ulpt_open
Definition: ulpt.c:143
#define LPS_NERR
Definition: ulpt.c:92
static device_probe_t ulpt_probe
Definition: ulpt.c:126
MODULE_VERSION(ulpt, 1)
@ ULPT_N_TRANSFER
Definition: ulpt.c:102
@ ULPT_INTR_DT_RD
Definition: ulpt.c:101
@ ULPT_BULK_DT_WR
Definition: ulpt.c:99
@ ULPT_BULK_DT_RD
Definition: ulpt.c:100
static struct usb_fifo_methods ulpt_fifo_methods
Definition: ulpt.c:146
#define UR_SOFT_RESET
Definition: ulpt.c:90
static devclass_t ulpt_devclass
Definition: ulpt.c:743
#define LPS_INVERT
Definition: ulpt.c:95
#define DPRINTF(...)
Definition: umass.c:179
#define UE_DIR_ANY
Definition: usb.h:535
#define UIPROTO_PRINTER_1284
Definition: usb.h:465
#define UE_ADDR_ANY
Definition: usb.h:537
#define UE_BULK
Definition: usb.h:543
#define UT_WRITE_CLASS_OTHER
Definition: usb.h:178
#define UISUBCLASS_PRINTER
Definition: usb.h:462
#define UIPROTO_PRINTER_BI
Definition: usb.h:464
#define UT_READ_CLASS_INTERFACE
Definition: usb.h:173
#define UE_DIR_IN
Definition: usb.h:531
#define UDESC_INTERFACE
Definition: usb.h:199
#define UE_DIR_OUT
Definition: usb.h:532
@ USB_MODE_HOST
Definition: usb.h:778
#define UICLASS_PRINTER
Definition: usb.h:461
#define UT_WRITE_CLASS_INTERFACE
Definition: usb.h:177
#define UE_CONTROL
Definition: usb.h:541
#define UIPROTO_PRINTER_UNI
Definition: usb.h:463
void usbd_copy_in(struct usb_page_cache *cache, usb_frlength_t offset, const void *ptr, usb_frlength_t len)
Definition: usb_busdma.c:166
void usbd_copy_out(struct usb_page_cache *cache, usb_frlength_t offset, void *ptr, usb_frlength_t len)
Definition: usb_busdma.c:283
usb_error_t usbd_set_alt_interface_index(struct usb_device *udev, uint8_t iface_index, uint8_t alt_index)
Definition: usb_device.c:1034
struct usb_interface_descriptor * usbd_get_interface_descriptor(struct usb_interface *iface)
Definition: usb_device.c:2654
struct usb_config_descriptor * usbd_get_config_descriptor(struct usb_device *udev)
Definition: usb_device.c:2616
#define USETW2(w, b1, b0)
Definition: usb_endian.h:100
#define USETW(w, v)
Definition: usb_endian.h:77
const char * usbd_errstr(usb_error_t err)
Definition: usb_error.c:93
const void * req
Definition: usb_if.m:51
INTERFACE usb
Definition: usb_if.m:35
int usbd_lookup_id_by_uaa(const struct usb_device_id *id, usb_size_t sizeof_id, struct usb_attach_arg *uaa)
Definition: usb_lookup.c:143
struct usb_descriptor * usb_desc_foreach(struct usb_config_descriptor *cd, struct usb_descriptor *_desc)
Definition: usb_parse.c:74
usb_error_t usbd_do_request_flags(struct usb_device *udev, struct mtx *mtx, struct usb_device_request *req, void *data, uint16_t flags, uint16_t *actlen, usb_timeout_t timeout)
Definition: usb_request.c:405
void usbd_transfer_submit(struct usb_xfer *xfer)
void usbd_xfer_set_frames(struct usb_xfer *xfer, usb_frcount_t n)
void usbd_transfer_unsetup(struct usb_xfer **pxfer, uint16_t n_setup)
void usbd_xfer_set_frame_len(struct usb_xfer *xfer, usb_frcount_t frindex, usb_frlength_t len)
struct usb_page_cache * usbd_xfer_get_frame(struct usb_xfer *xfer, usb_frcount_t frindex)
usb_error_t usbd_transfer_setup(struct usb_device *udev, const uint8_t *ifaces, struct usb_xfer **ppxfer, const struct usb_config *setup_start, uint16_t n_setup, void *priv_sc, struct mtx *xfer_mtx)
Definition: usb_transfer.c:987
void usbd_transfer_start(struct usb_xfer *xfer)
void * usbd_xfer_softc(struct usb_xfer *xfer)
void usbd_xfer_set_stall(struct usb_xfer *xfer)
void usbd_xfer_set_interval(struct usb_xfer *xfer, int i)
void usbd_transfer_stop(struct usb_xfer *xfer)
void usbd_xfer_status(struct usb_xfer *xfer, int *actlen, int *sumlen, int *aframes, int *nframes)
usb_frlength_t usbd_xfer_max_len(struct usb_xfer *xfer)
void device_set_usb_desc(device_t dev)
Definition: usb_util.c:73
int usb_fifo_alloc_buffer(struct usb_fifo *f, uint32_t bufsize, uint16_t nbuf)
#define USB_DEFAULT_TIMEOUT
Definition: usbdi.h:89
#define USB_MS_HZ
Definition: usbdi.h:118
int() usb_fifo_ioctl_t(struct usb_fifo *fifo, u_long cmd, void *addr, int fflags)
Definition: usbdi.h:101
#define USB_IFACE_SUBCLASS(isc)
Definition: usbdi.h:388
void * usb_fifo_softc(struct usb_fifo *fifo)
void() usb_fifo_close_t(struct usb_fifo *fifo, int fflags)
Definition: usbdi.h:100
#define usb_callout_init_mtx(c, m, f)
Definition: usbdi.h:480
void usb_fifo_detach(struct usb_fifo_sc *f_sc)
#define USB_ST_SETUP
Definition: usbdi.h:502
void usb_fifo_put_data(struct usb_fifo *fifo, struct usb_page_cache *pc, usb_frlength_t offset, usb_frlength_t len, uint8_t what)
int usb_fifo_attach(struct usb_device *udev, void *priv_sc, struct mtx *priv_mtx, struct usb_fifo_methods *pm, struct usb_fifo_sc *f_sc, uint16_t unit, int16_t subunit, uint8_t iface_index, uid_t uid, gid_t gid, int mode)
#define usb_callout_reset(c,...)
Definition: usbdi.h:481
usb_error_t
Definition: usbdi.h:45
@ USB_ERR_CANCELLED
Definition: usbdi.h:51
void() usb_fifo_cmd_t(struct usb_fifo *fifo)
Definition: usbdi.h:102
void usb_fifo_free_buffer(struct usb_fifo *f)
#define USB_IFACE_CLASS(ic)
Definition: usbdi.h:385
uint8_t usb_fifo_get_data(struct usb_fifo *fifo, struct usb_page_cache *pc, usb_frlength_t offset, usb_frlength_t len, usb_frlength_t *actlen, uint8_t what)
#define USB_SHORT_XFER_OK
Definition: usbdi.h:82
#define usb_callout_drain(c)
Definition: usbdi.h:497
#define USB_ST_TRANSFERRED
Definition: usbdi.h:503
#define USB_IFACE_PROTOCOL(ip)
Definition: usbdi.h:391
#define USB_FIFO_RX
Definition: usbdi.h:527
void() usb_callback_t(struct usb_xfer *, usb_error_t)
Definition: usbdi.h:94
#define USB_FIFO_TX
Definition: usbdi.h:526
int() usb_fifo_open_t(struct usb_fifo *fifo, int fflags)
Definition: usbdi.h:99
#define STRUCT_USB_HOST_ID
Definition: usbdi.h:258
#define usb_callout_stop(c)
Definition: usbdi.h:489
#define USB_GET_STATE(xfer)
Definition: usbdi.h:515
uint32_t usb_fifo_put_bytes_max(struct usb_fifo *fifo)