FreeBSD kernel usb device Code
ucycom.c
Go to the documentation of this file.
1#include <sys/cdefs.h>
2__FBSDID("$FreeBSD$");
3
4/*-
5 * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
6 *
7 * Copyright (c) 2004 Dag-Erling Coïdan Smørgrav
8 * All rights reserved.
9 *
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
12 * are met:
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer
15 * in this position and unchanged.
16 * 2. Redistributions in binary form must reproduce the above copyright
17 * notice, this list of conditions and the following disclaimer in the
18 * documentation and/or other materials provided with the distribution.
19 * 3. The name of the author may not be used to endorse or promote products
20 * derived from this software without specific prior written permission.
21 *
22 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
23 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
24 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
25 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
26 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
27 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
31 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 */
33
34/*
35 * Device driver for Cypress CY7C637xx and CY7C640/1xx series USB to
36 * RS232 bridges.
37 */
38
39#include <sys/stdint.h>
40#include <sys/stddef.h>
41#include <sys/param.h>
42#include <sys/queue.h>
43#include <sys/types.h>
44#include <sys/systm.h>
45#include <sys/kernel.h>
46#include <sys/bus.h>
47#include <sys/module.h>
48#include <sys/lock.h>
49#include <sys/mutex.h>
50#include <sys/condvar.h>
51#include <sys/sysctl.h>
52#include <sys/sx.h>
53#include <sys/unistd.h>
54#include <sys/callout.h>
55#include <sys/malloc.h>
56#include <sys/priv.h>
57
58#include <dev/hid/hid.h>
59
60#include <dev/usb/usb.h>
61#include <dev/usb/usbdi.h>
62#include <dev/usb/usbdi_util.h>
63#include <dev/usb/usbhid.h>
64#include "usbdevs.h"
65
66#define USB_DEBUG_VAR usb_debug
67#include <dev/usb/usb_debug.h>
68#include <dev/usb/usb_process.h>
69
71
72#define UCYCOM_MAX_IOLEN (1024 + 2) /* bytes */
73
74#define UCYCOM_IFACE_INDEX 0
75
76enum {
80};
81
85
88 struct mtx sc_mtx;
89
90 uint32_t sc_model;
91#define MODEL_CY7C63743 0x63743
92#define MODEL_CY7C64013 0x64013
93
94 uint16_t sc_flen; /* feature report length */
95 uint16_t sc_ilen; /* input report length */
96 uint16_t sc_olen; /* output report length */
97
98 uint8_t sc_fid; /* feature report id */
99 uint8_t sc_iid; /* input report id */
100 uint8_t sc_oid; /* output report id */
101 uint8_t sc_cfg;
102#define UCYCOM_CFG_RESET 0x80
103#define UCYCOM_CFG_PARODD 0x20
104#define UCYCOM_CFG_PAREN 0x10
105#define UCYCOM_CFG_STOPB 0x08
106#define UCYCOM_CFG_DATAB 0x03
107 uint8_t sc_ist; /* status flags from last input */
108 uint8_t sc_iface_no;
109 uint8_t sc_temp_cfg[32];
110};
111
112/* prototypes */
113
114static device_probe_t ucycom_probe;
115static device_attach_t ucycom_attach;
116static device_detach_t ucycom_detach;
117static void ucycom_free_softc(struct ucycom_softc *);
118
121
122static void ucycom_free(struct ucom_softc *);
123static void ucycom_cfg_open(struct ucom_softc *);
124static void ucycom_start_read(struct ucom_softc *);
125static void ucycom_stop_read(struct ucom_softc *);
126static void ucycom_start_write(struct ucom_softc *);
127static void ucycom_stop_write(struct ucom_softc *);
128static void ucycom_cfg_write(struct ucycom_softc *, uint32_t, uint8_t);
129static int ucycom_pre_param(struct ucom_softc *, struct termios *);
130static void ucycom_cfg_param(struct ucom_softc *, struct termios *);
131static void ucycom_poll(struct ucom_softc *ucom);
132
134 [UCYCOM_CTRL_RD] = {
135 .type = UE_CONTROL,
136 .endpoint = 0x00, /* Control pipe */
137 .direction = UE_DIR_ANY,
138 .bufsize = (sizeof(struct usb_device_request) + UCYCOM_MAX_IOLEN),
139 .callback = &ucycom_ctrl_write_callback,
140 .timeout = 1000, /* 1 second */
141 },
142
143 [UCYCOM_INTR_RD] = {
144 .type = UE_INTERRUPT,
145 .endpoint = UE_ADDR_ANY,
146 .direction = UE_DIR_IN,
147 .flags = {.pipe_bof = 1,.short_xfer_ok = 1,},
148 .bufsize = UCYCOM_MAX_IOLEN,
149 .callback = &ucycom_intr_read_callback,
150 },
151};
152
153static const struct ucom_callback ucycom_callback = {
155 .ucom_cfg_open = &ucycom_cfg_open,
156 .ucom_pre_param = &ucycom_pre_param,
157 .ucom_start_read = &ucycom_start_read,
158 .ucom_stop_read = &ucycom_stop_read,
159 .ucom_start_write = &ucycom_start_write,
160 .ucom_stop_write = &ucycom_stop_write,
161 .ucom_poll = &ucycom_poll,
162 .ucom_free = &ucycom_free,
163};
164
165static device_method_t ucycom_methods[] = {
166 DEVMETHOD(device_probe, ucycom_probe),
167 DEVMETHOD(device_attach, ucycom_attach),
168 DEVMETHOD(device_detach, ucycom_detach),
169 DEVMETHOD_END
170};
171
172static devclass_t ucycom_devclass;
173
174static driver_t ucycom_driver = {
175 .name = "ucycom",
176 .methods = ucycom_methods,
177 .size = sizeof(struct ucycom_softc),
178};
179
180/*
181 * Supported devices
182 */
184 {USB_VPI(USB_VENDOR_DELORME, USB_PRODUCT_DELORME_EARTHMATE, MODEL_CY7C64013)},
185};
186
188MODULE_DEPEND(ucycom, ucom, 1, 1, 1);
189MODULE_DEPEND(ucycom, usb, 1, 1, 1);
190MODULE_DEPEND(ucycom, hid, 1, 1, 1);
191MODULE_VERSION(ucycom, 1);
193
194#define UCYCOM_DEFAULT_RATE 4800
195#define UCYCOM_DEFAULT_CFG 0x03 /* N-8-1 */
196
197static int
198ucycom_probe(device_t dev)
199{
200 struct usb_attach_arg *uaa = device_get_ivars(dev);
201
202 if (uaa->usb_mode != USB_MODE_HOST) {
203 return (ENXIO);
204 }
205 if (uaa->info.bConfigIndex != 0) {
206 return (ENXIO);
207 }
208 if (uaa->info.bIfaceIndex != UCYCOM_IFACE_INDEX) {
209 return (ENXIO);
210 }
211 return (usbd_lookup_id_by_uaa(ucycom_devs, sizeof(ucycom_devs), uaa));
212}
213
214static int
215ucycom_attach(device_t dev)
216{
217 struct usb_attach_arg *uaa = device_get_ivars(dev);
218 struct ucycom_softc *sc = device_get_softc(dev);
219 void *urd_ptr = NULL;
220 int32_t error;
221 uint16_t urd_len;
222 uint8_t iface_index;
223
224 sc->sc_udev = uaa->device;
225
227 mtx_init(&sc->sc_mtx, "ucycom", NULL, MTX_DEF);
229
230 DPRINTF("\n");
231
232 /* get chip model */
233 sc->sc_model = USB_GET_DRIVER_INFO(uaa);
234 if (sc->sc_model == 0) {
235 device_printf(dev, "unsupported device\n");
236 goto detach;
237 }
238 device_printf(dev, "Cypress CY7C%X USB to RS232 bridge\n", sc->sc_model);
239
240 /* get report descriptor */
241
243 &urd_ptr, &urd_len, M_USBDEV,
245
246 if (error) {
247 device_printf(dev, "failed to get report "
248 "descriptor: %s\n",
250 goto detach;
251 }
252 /* get report sizes */
253
254 sc->sc_flen = hid_report_size_max(urd_ptr, urd_len, hid_feature, &sc->sc_fid);
255 sc->sc_ilen = hid_report_size_max(urd_ptr, urd_len, hid_input, &sc->sc_iid);
256 sc->sc_olen = hid_report_size_max(urd_ptr, urd_len, hid_output, &sc->sc_oid);
257
258 if ((sc->sc_ilen > UCYCOM_MAX_IOLEN) || (sc->sc_ilen < 1) ||
259 (sc->sc_olen > UCYCOM_MAX_IOLEN) || (sc->sc_olen < 2) ||
260 (sc->sc_flen > UCYCOM_MAX_IOLEN) || (sc->sc_flen < 5)) {
261 device_printf(dev, "invalid report size i=%d, o=%d, f=%d, max=%d\n",
262 sc->sc_ilen, sc->sc_olen, sc->sc_flen,
264 goto detach;
265 }
266 sc->sc_iface_no = uaa->info.bIfaceNum;
267
268 iface_index = UCYCOM_IFACE_INDEX;
269 error = usbd_transfer_setup(uaa->device, &iface_index,
271 sc, &sc->sc_mtx);
272 if (error) {
273 device_printf(dev, "allocating USB "
274 "transfers failed\n");
275 goto detach;
276 }
277 error = ucom_attach(&sc->sc_super_ucom, &sc->sc_ucom, 1, sc,
278 &ucycom_callback, &sc->sc_mtx);
279 if (error) {
280 goto detach;
281 }
283
284 if (urd_ptr) {
285 free(urd_ptr, M_USBDEV);
286 }
287
288 return (0); /* success */
289
290detach:
291 if (urd_ptr) {
292 free(urd_ptr, M_USBDEV);
293 }
295 return (ENXIO);
296}
297
298static int
299ucycom_detach(device_t dev)
300{
301 struct ucycom_softc *sc = device_get_softc(dev);
302
305
306 device_claim_softc(dev);
307
309
310 return (0);
311}
312
314
315static void
317{
318 if (ucom_unref(&sc->sc_super_ucom)) {
319 mtx_destroy(&sc->sc_mtx);
320 device_free_softc(sc);
321 }
322}
323
324static void
326{
328}
329
330static void
332{
333 struct ucycom_softc *sc = ucom->sc_parent;
334
335 /* set default configuration */
337}
338
339static void
341{
342 struct ucycom_softc *sc = ucom->sc_parent;
343
345}
346
347static void
349{
350 struct ucycom_softc *sc = ucom->sc_parent;
351
353}
354
355static void
357{
358 struct ucycom_softc *sc = ucom->sc_parent;
359
361}
362
363static void
365{
366 struct ucycom_softc *sc = ucom->sc_parent;
367
369}
370
371static void
373{
374 struct ucycom_softc *sc = usbd_xfer_softc(xfer);
375 struct usb_device_request req;
376 struct usb_page_cache *pc0, *pc1;
377 uint8_t data[2];
378 uint8_t offset;
379 uint32_t actlen;
380
381 pc0 = usbd_xfer_get_frame(xfer, 0);
382 pc1 = usbd_xfer_get_frame(xfer, 1);
383
384 switch (USB_GET_STATE(xfer)) {
386tr_transferred:
387 case USB_ST_SETUP:
388
389 switch (sc->sc_model) {
390 case MODEL_CY7C63743:
391 offset = 1;
392 break;
393 case MODEL_CY7C64013:
394 offset = 2;
395 break;
396 default:
397 offset = 0;
398 break;
399 }
400
401 if (ucom_get_data(&sc->sc_ucom, pc1, offset,
402 sc->sc_olen - offset, &actlen)) {
403 req.bmRequestType = UT_WRITE_CLASS_INTERFACE;
404 req.bRequest = UR_SET_REPORT;
405 USETW2(req.wValue, UHID_OUTPUT_REPORT, sc->sc_oid);
406 req.wIndex[0] = sc->sc_iface_no;
407 req.wIndex[1] = 0;
408 USETW(req.wLength, sc->sc_olen);
409
410 switch (sc->sc_model) {
411 case MODEL_CY7C63743:
412 data[0] = actlen;
413 break;
414 case MODEL_CY7C64013:
415 data[0] = 0;
416 data[1] = actlen;
417 break;
418 default:
419 break;
420 }
421
422 usbd_copy_in(pc0, 0, &req, sizeof(req));
423 usbd_copy_in(pc1, 0, data, offset);
424
425 usbd_xfer_set_frame_len(xfer, 0, sizeof(req));
426 usbd_xfer_set_frame_len(xfer, 1, sc->sc_olen);
427 usbd_xfer_set_frames(xfer, sc->sc_olen ? 2 : 1);
429 }
430 return;
431
432 default: /* Error */
433 if (error == USB_ERR_CANCELLED) {
434 return;
435 }
436 DPRINTF("error=%s\n",
438 goto tr_transferred;
439 }
440}
441
442static void
443ucycom_cfg_write(struct ucycom_softc *sc, uint32_t baud, uint8_t cfg)
444{
445 struct usb_device_request req;
446 uint16_t len;
447 usb_error_t err;
448
449 len = sc->sc_flen;
450 if (len > sizeof(sc->sc_temp_cfg)) {
451 len = sizeof(sc->sc_temp_cfg);
452 }
453 sc->sc_cfg = cfg;
454
455 req.bmRequestType = UT_WRITE_CLASS_INTERFACE;
456 req.bRequest = UR_SET_REPORT;
457 USETW2(req.wValue, UHID_FEATURE_REPORT, sc->sc_fid);
458 req.wIndex[0] = sc->sc_iface_no;
459 req.wIndex[1] = 0;
460 USETW(req.wLength, len);
461
462 sc->sc_temp_cfg[0] = (baud & 0xff);
463 sc->sc_temp_cfg[1] = (baud >> 8) & 0xff;
464 sc->sc_temp_cfg[2] = (baud >> 16) & 0xff;
465 sc->sc_temp_cfg[3] = (baud >> 24) & 0xff;
466 sc->sc_temp_cfg[4] = cfg;
467
468 err = ucom_cfg_do_request(sc->sc_udev, &sc->sc_ucom,
469 &req, sc->sc_temp_cfg, 0, 1000);
470 if (err) {
471 DPRINTFN(0, "device request failed, err=%s "
472 "(ignored)\n", usbd_errstr(err));
473 }
474}
475
476static int
477ucycom_pre_param(struct ucom_softc *ucom, struct termios *t)
478{
479 switch (t->c_ospeed) {
480 case 600:
481 case 1200:
482 case 2400:
483 case 4800:
484 case 9600:
485 case 19200:
486 case 38400:
487 case 57600:
488#if 0
489 /*
490 * Stock chips only support standard baud rates in the 600 - 57600
491 * range, but higher rates can be achieved using custom firmware.
492 */
493 case 115200:
494 case 153600:
495 case 192000:
496#endif
497 break;
498 default:
499 return (EINVAL);
500 }
501 return (0);
502}
503
504static void
505ucycom_cfg_param(struct ucom_softc *ucom, struct termios *t)
506{
507 struct ucycom_softc *sc = ucom->sc_parent;
508 uint8_t cfg;
509
510 DPRINTF("\n");
511
512 if (t->c_cflag & CIGNORE) {
513 cfg = sc->sc_cfg;
514 } else {
515 cfg = 0;
516 switch (t->c_cflag & CSIZE) {
517 default:
518 case CS8:
519 ++cfg;
520 case CS7:
521 ++cfg;
522 case CS6:
523 ++cfg;
524 case CS5:
525 break;
526 }
527
528 if (t->c_cflag & CSTOPB)
529 cfg |= UCYCOM_CFG_STOPB;
530 if (t->c_cflag & PARENB)
531 cfg |= UCYCOM_CFG_PAREN;
532 if (t->c_cflag & PARODD)
533 cfg |= UCYCOM_CFG_PARODD;
534 }
535
536 ucycom_cfg_write(sc, t->c_ospeed, cfg);
537}
538
539static void
541{
542 struct ucycom_softc *sc = usbd_xfer_softc(xfer);
543 struct usb_page_cache *pc;
544 uint8_t buf[2];
545 uint32_t offset;
546 int len;
547 int actlen;
548
549 usbd_xfer_status(xfer, &actlen, NULL, NULL, NULL);
550 pc = usbd_xfer_get_frame(xfer, 0);
551
552 switch (USB_GET_STATE(xfer)) {
554 switch (sc->sc_model) {
555 case MODEL_CY7C63743:
556 if (actlen < 1) {
557 goto tr_setup;
558 }
559 usbd_copy_out(pc, 0, buf, 1);
560
561 sc->sc_ist = buf[0] & ~0x07;
562 len = buf[0] & 0x07;
563
564 actlen--;
565 offset = 1;
566
567 break;
568
569 case MODEL_CY7C64013:
570 if (actlen < 2) {
571 goto tr_setup;
572 }
573 usbd_copy_out(pc, 0, buf, 2);
574
575 sc->sc_ist = buf[0] & ~0x07;
576 len = buf[1];
577
578 actlen -= 2;
579 offset = 2;
580
581 break;
582
583 default:
584 DPRINTFN(0, "unsupported model number\n");
585 goto tr_setup;
586 }
587
588 if (len > actlen)
589 len = actlen;
590 if (len)
591 ucom_put_data(&sc->sc_ucom, pc, offset, len);
592 /* FALLTHROUGH */
593 case USB_ST_SETUP:
594tr_setup:
595 usbd_xfer_set_frame_len(xfer, 0, sc->sc_ilen);
597 return;
598
599 default: /* Error */
600 if (error != USB_ERR_CANCELLED) {
601 /* try to clear stall first */
603 goto tr_setup;
604 }
605 return;
606 }
607}
608
609static void
611{
612 struct ucycom_softc *sc = ucom->sc_parent;
614}
uint16_t len
Definition: ehci.h:41
struct @109 error
uint16_t data
device_t dev
void(* ucom_cfg_param)(struct ucom_softc *, struct termios *)
Definition: usb_serial.h:95
void * sc_parent
Definition: usb_serial.h:170
struct ucom_super_softc sc_super_ucom
Definition: ucycom.c:83
uint8_t sc_fid
Definition: ucycom.c:98
uint16_t sc_olen
Definition: ucycom.c:96
uint8_t sc_iface_no
Definition: ucycom.c:108
uint8_t sc_oid
Definition: ucycom.c:100
struct usb_device * sc_udev
Definition: ucycom.c:86
uint16_t sc_flen
Definition: ucycom.c:94
struct usb_xfer * sc_xfer[UCYCOM_N_TRANSFER]
Definition: ucycom.c:87
struct ucom_softc sc_ucom
Definition: ucycom.c:84
uint16_t sc_ilen
Definition: ucycom.c:95
uint8_t sc_ist
Definition: ucycom.c:107
struct mtx sc_mtx
Definition: ucycom.c:88
uint8_t sc_iid
Definition: ucycom.c:99
uint8_t sc_cfg
Definition: ucycom.c:101
uint32_t sc_model
Definition: ucycom.c:90
uint8_t sc_temp_cfg[32]
Definition: ucycom.c:109
enum usb_hc_mode usb_mode
Definition: usbdi.h:432
struct usbd_lookup_info info
Definition: usbdi.h:426
struct usb_device * device
Definition: usbdi.h:430
uint8_t type
Definition: usbdi.h:238
uint8_t bIfaceNum
Definition: usbdi.h:418
uint8_t bIfaceIndex
Definition: usbdi.h:417
uint8_t bConfigIndex
Definition: usbdi.h:419
static driver_t ucycom_driver
Definition: ucycom.c:174
static device_detach_t ucycom_detach
Definition: ucycom.c:116
static device_method_t ucycom_methods[]
Definition: ucycom.c:165
#define MODEL_CY7C64013
Definition: ucycom.c:92
static const struct usb_config ucycom_config[UCYCOM_N_TRANSFER]
Definition: ucycom.c:133
DRIVER_MODULE(ucycom, uhub, ucycom_driver, ucycom_devclass, NULL, 0)
static void ucycom_cfg_open(struct ucom_softc *)
Definition: ucycom.c:331
static void ucycom_start_write(struct ucom_softc *)
Definition: ucycom.c:356
UCOM_UNLOAD_DRAIN(ucycom)
MODULE_DEPEND(ucycom, ucom, 1, 1, 1)
static device_attach_t ucycom_attach
Definition: ucycom.c:115
static usb_callback_t ucycom_intr_read_callback
Definition: ucycom.c:120
static void ucycom_free(struct ucom_softc *)
Definition: ucycom.c:325
#define UCYCOM_CFG_PARODD
Definition: ucycom.c:103
static devclass_t ucycom_devclass
Definition: ucycom.c:172
#define UCYCOM_IFACE_INDEX
Definition: ucycom.c:74
#define UCYCOM_CFG_STOPB
Definition: ucycom.c:105
static void ucycom_stop_write(struct ucom_softc *)
Definition: ucycom.c:364
USB_PNP_HOST_INFO(ucycom_devs)
static void ucycom_cfg_param(struct ucom_softc *, struct termios *)
Definition: ucycom.c:505
#define UCYCOM_DEFAULT_RATE
Definition: ucycom.c:194
MODULE_VERSION(ucycom, 1)
#define UCYCOM_MAX_IOLEN
Definition: ucycom.c:72
__FBSDID("$FreeBSD$")
static const struct ucom_callback ucycom_callback
Definition: ucycom.c:153
static const STRUCT_USB_HOST_ID ucycom_devs[]
Definition: ucycom.c:183
static device_probe_t ucycom_probe
Definition: ucycom.c:114
static void ucycom_start_read(struct ucom_softc *)
Definition: ucycom.c:340
#define MODEL_CY7C63743
Definition: ucycom.c:91
#define UCYCOM_CFG_PAREN
Definition: ucycom.c:104
static void ucycom_cfg_write(struct ucycom_softc *, uint32_t, uint8_t)
Definition: ucycom.c:443
#define UCYCOM_DEFAULT_CFG
Definition: ucycom.c:195
static void ucycom_free_softc(struct ucycom_softc *)
Definition: ucycom.c:316
static int ucycom_pre_param(struct ucom_softc *, struct termios *)
Definition: ucycom.c:477
static void ucycom_poll(struct ucom_softc *ucom)
Definition: ucycom.c:610
static usb_callback_t ucycom_ctrl_write_callback
Definition: ucycom.c:119
static void ucycom_stop_read(struct ucom_softc *)
Definition: ucycom.c:348
@ UCYCOM_CTRL_RD
Definition: ucycom.c:77
@ UCYCOM_INTR_RD
Definition: ucycom.c:78
@ UCYCOM_N_TRANSFER
Definition: ucycom.c:79
#define DPRINTF(...)
Definition: umass.c:179
#define UE_INTERRUPT
Definition: usb.h:544
#define UE_DIR_ANY
Definition: usb.h:535
#define UE_ADDR_ANY
Definition: usb.h:537
#define UE_DIR_IN
Definition: usb.h:531
@ USB_MODE_HOST
Definition: usb.h:778
#define UT_WRITE_CLASS_INTERFACE
Definition: usb.h:177
#define UE_CONTROL
Definition: usb.h:541
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
#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
usb_error_t usbd_req_get_hid_desc(struct usb_device *udev, struct mtx *mtx, void **descp, uint16_t *sizep, struct malloc_type *mem, uint8_t iface_index)
Definition: usb_hid.c:113
uint16_t offset
Definition: usb_if.m:54
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
uint8_t ucom_get_data(struct ucom_softc *sc, struct usb_page_cache *pc, uint32_t offset, uint32_t len, uint32_t *actlen)
Definition: usb_serial.c:1384
int ucom_attach(struct ucom_super_softc *ssc, struct ucom_softc *sc, int subunits, void *parent, const struct ucom_callback *callback, struct mtx *mtx)
Definition: usb_serial.c:267
int ucom_unref(struct ucom_super_softc *ssc)
Definition: usb_serial.c:1730
void ucom_ref(struct ucom_super_softc *ssc)
Definition: usb_serial.c:1695
void ucom_set_pnpinfo_usb(struct ucom_super_softc *ssc, device_t dev)
Definition: usb_serial.c:549
void ucom_detach(struct ucom_super_softc *ssc, struct ucom_softc *sc)
Definition: usb_serial.c:336
void ucom_put_data(struct ucom_softc *sc, struct usb_page_cache *pc, uint32_t offset, uint32_t len)
Definition: usb_serial.c:1462
#define ucom_cfg_do_request(udev, com, req, ptr, flags, timo)
Definition: usb_serial.h:208
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_transfer_poll(struct usb_xfer **ppxfer, uint16_t max)
void * usbd_xfer_softc(struct usb_xfer *xfer)
void usbd_xfer_set_stall(struct usb_xfer *xfer)
void usbd_transfer_stop(struct usb_xfer *xfer)
void usbd_xfer_status(struct usb_xfer *xfer, int *actlen, int *sumlen, int *aframes, int *nframes)
void device_set_usb_desc(device_t dev)
Definition: usb_util.c:73
#define USB_ST_SETUP
Definition: usbdi.h:502
usb_error_t
Definition: usbdi.h:45
@ USB_ERR_CANCELLED
Definition: usbdi.h:51
#define USB_ST_TRANSFERRED
Definition: usbdi.h:503
void() usb_callback_t(struct usb_xfer *, usb_error_t)
Definition: usbdi.h:94
#define USB_VPI(vend, prod, info)
Definition: usbdi.h:367
#define STRUCT_USB_HOST_ID
Definition: usbdi.h:258
#define USB_GET_DRIVER_INFO(did)
Definition: usbdi.h:400
#define USB_GET_STATE(xfer)
Definition: usbdi.h:515
#define UHID_FEATURE_REPORT
Definition: usbhid.h:68
#define UHID_OUTPUT_REPORT
Definition: usbhid.h:67
#define UR_SET_REPORT
Definition: usbhid.h:46