FreeBSD kernel usb device Code
udl.c
Go to the documentation of this file.
1/* $OpenBSD: udl.c,v 1.81 2014/12/09 07:05:06 doug Exp $ */
2/* $FreeBSD$ */
3
4/*-
5 * Copyright (c) 2015 Hans Petter Selasky <hselasky@freebsd.org>
6 * Copyright (c) 2009 Marcus Glocker <mglocker@openbsd.org>
7 *
8 * Permission to use, copy, modify, and distribute this software for any
9 * purpose with or without fee is hereby granted, provided that the above
10 * copyright notice and this permission notice appear in all copies.
11 *
12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
13 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
14 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
15 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
16 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
17 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
18 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
19 */
20
21/*
22 * Driver for the "DisplayLink DL-120 / DL-160" graphic chips based on
23 * the reversed engineered specifications of Florian Echtler
24 * <floe@butterbrot.org>:
25 *
26 * http://floe.butterbrot.org/displaylink/doku.php
27 */
28
29#include <sys/param.h>
30#include <sys/bus.h>
31#include <sys/callout.h>
32#include <sys/conf.h>
33#include <sys/kernel.h>
34#include <sys/lock.h>
35#include <sys/module.h>
36#include <sys/mutex.h>
37#include <sys/condvar.h>
38#include <sys/sysctl.h>
39#include <sys/systm.h>
40#include <sys/consio.h>
41#include <sys/fbio.h>
42
43#include <dev/fb/fbreg.h>
44#include <dev/syscons/syscons.h>
45
46#include <dev/videomode/videomode.h>
47#include <dev/videomode/edidvar.h>
48
49#include <dev/usb/usb.h>
50#include <dev/usb/usbdi.h>
51#include <dev/usb/usbdi_util.h>
52#include "usbdevs.h"
53
54#include <dev/usb/video/udl.h>
55
56#include "fb_if.h"
57
58#undef DPRINTF
59#undef DPRINTFN
60#define USB_DEBUG_VAR udl_debug
61#include <dev/usb/usb_debug.h>
62
63static SYSCTL_NODE(_hw_usb, OID_AUTO, udl, CTLFLAG_RW | CTLFLAG_MPSAFE, 0,
64 "USB UDL");
65
66#ifdef USB_DEBUG
67static int udl_debug = 0;
68
69SYSCTL_INT(_hw_usb_udl, OID_AUTO, debug, CTLFLAG_RWTUN,
70 &udl_debug, 0, "Debug level");
71#endif
72
73#define UDL_FPS_MAX 60
74#define UDL_FPS_MIN 1
75
76static int udl_fps = 25;
77SYSCTL_INT(_hw_usb_udl, OID_AUTO, fps, CTLFLAG_RWTUN,
78 &udl_fps, 0, "Frames Per Second, 1-60");
79
80static struct mtx udl_buffer_mtx;
82
83MALLOC_DEFINE(M_USB_DL, "USB", "USB DisplayLink");
84
85/*
86 * Prototypes.
87 */
89
90static device_probe_t udl_probe;
91static device_attach_t udl_attach;
92static device_detach_t udl_detach;
93static fb_getinfo_t udl_fb_getinfo;
94static fb_setblankmode_t udl_fb_setblankmode;
95
96static void udl_select_chip(struct udl_softc *, struct usb_attach_arg *);
97static int udl_init_chip(struct udl_softc *);
98static void udl_select_mode(struct udl_softc *);
99static int udl_init_resolution(struct udl_softc *);
100static void udl_fbmem_alloc(struct udl_softc *);
101static int udl_cmd_write_buf_le16(struct udl_softc *, const uint8_t *, uint32_t, uint8_t, int);
102static int udl_cmd_buf_copy_le16(struct udl_softc *, uint32_t, uint32_t, uint8_t, int);
103static void udl_cmd_insert_int_1(struct udl_cmd_buf *, uint8_t);
104static void udl_cmd_insert_int_3(struct udl_cmd_buf *, uint32_t);
105static void udl_cmd_insert_buf_le16(struct udl_cmd_buf *, const uint8_t *, uint32_t);
106static void udl_cmd_write_reg_1(struct udl_cmd_buf *, uint8_t, uint8_t);
107static void udl_cmd_write_reg_3(struct udl_cmd_buf *, uint8_t, uint32_t);
108static int udl_power_save(struct udl_softc *, int, int);
109
110static const struct usb_config udl_config[UDL_N_TRANSFER] = {
111 [UDL_BULK_WRITE_0] = {
112 .type = UE_BULK,
113 .endpoint = UE_ADDR_ANY,
114 .direction = UE_DIR_TX,
115 .flags = {.pipe_bof = 1,.force_short_xfer = 1,.ext_buffer = 1,},
117 .callback = &udl_bulk_write_callback,
118 .frames = UDL_CMD_MAX_FRAMES,
119 .timeout = 5000, /* 5 seconds */
120 },
121 [UDL_BULK_WRITE_1] = {
122 .type = UE_BULK,
123 .endpoint = UE_ADDR_ANY,
124 .direction = UE_DIR_TX,
125 .flags = {.pipe_bof = 1,.force_short_xfer = 1,.ext_buffer = 1,},
127 .callback = &udl_bulk_write_callback,
128 .frames = UDL_CMD_MAX_FRAMES,
129 .timeout = 5000, /* 5 seconds */
130 },
131};
132
133/*
134 * Driver glue.
135 */
136static devclass_t udl_devclass;
137
138static device_method_t udl_methods[] = {
139 DEVMETHOD(device_probe, udl_probe),
140 DEVMETHOD(device_attach, udl_attach),
141 DEVMETHOD(device_detach, udl_detach),
142 DEVMETHOD(fb_getinfo, udl_fb_getinfo),
143 DEVMETHOD_END
144};
145
146static driver_t udl_driver = {
147 .name = "udl",
148 .methods = udl_methods,
149 .size = sizeof(struct udl_softc),
150};
151
152DRIVER_MODULE(udl, uhub, udl_driver, udl_devclass, NULL, NULL);
153MODULE_DEPEND(udl, usb, 1, 1, 1);
154MODULE_DEPEND(udl, fbd, 1, 1, 1);
155MODULE_DEPEND(udl, videomode, 1, 1, 1);
157
158/*
159 * Matching devices.
160 */
161static const STRUCT_USB_HOST_ID udl_devs[] = {
162 {USB_VPI(USB_VENDOR_DISPLAYLINK, USB_PRODUCT_DISPLAYLINK_LCD4300U, DL120)},
163 {USB_VPI(USB_VENDOR_DISPLAYLINK, USB_PRODUCT_DISPLAYLINK_LCD8000U, DL120)},
164 {USB_VPI(USB_VENDOR_DISPLAYLINK, USB_PRODUCT_DISPLAYLINK_GUC2020, DL160)},
165 {USB_VPI(USB_VENDOR_DISPLAYLINK, USB_PRODUCT_DISPLAYLINK_LD220, DL165)},
166 {USB_VPI(USB_VENDOR_DISPLAYLINK, USB_PRODUCT_DISPLAYLINK_VCUD60, DL160)},
167 {USB_VPI(USB_VENDOR_DISPLAYLINK, USB_PRODUCT_DISPLAYLINK_DLDVI, DL160)},
168 {USB_VPI(USB_VENDOR_DISPLAYLINK, USB_PRODUCT_DISPLAYLINK_VGA10, DL120)},
169 {USB_VPI(USB_VENDOR_DISPLAYLINK, USB_PRODUCT_DISPLAYLINK_WSDVI, DLUNK)},
170 {USB_VPI(USB_VENDOR_DISPLAYLINK, USB_PRODUCT_DISPLAYLINK_EC008, DL160)},
171 {USB_VPI(USB_VENDOR_DISPLAYLINK, USB_PRODUCT_DISPLAYLINK_HPDOCK, DL160)},
172 {USB_VPI(USB_VENDOR_DISPLAYLINK, USB_PRODUCT_DISPLAYLINK_NL571, DL160)},
173 {USB_VPI(USB_VENDOR_DISPLAYLINK, USB_PRODUCT_DISPLAYLINK_M01061, DL195)},
174 {USB_VPI(USB_VENDOR_DISPLAYLINK, USB_PRODUCT_DISPLAYLINK_NBDOCK, DL165)},
175 {USB_VPI(USB_VENDOR_DISPLAYLINK, USB_PRODUCT_DISPLAYLINK_SWDVI, DLUNK)},
176 {USB_VPI(USB_VENDOR_DISPLAYLINK, USB_PRODUCT_DISPLAYLINK_UM7X0, DL120)},
177 {USB_VPI(USB_VENDOR_DISPLAYLINK, USB_PRODUCT_DISPLAYLINK_CONV, DL160)},
178 {USB_VPI(USB_VENDOR_DISPLAYLINK, USB_PRODUCT_DISPLAYLINK_PLUGABLE, DL160)},
179 {USB_VPI(USB_VENDOR_DISPLAYLINK, USB_PRODUCT_DISPLAYLINK_LUM70, DL125)},
180 {USB_VPI(USB_VENDOR_DISPLAYLINK, USB_PRODUCT_DISPLAYLINK_POLARIS2, DLUNK)},
181 {USB_VPI(USB_VENDOR_DISPLAYLINK, USB_PRODUCT_DISPLAYLINK_LT1421, DLUNK)},
182 {USB_VPI(USB_VENDOR_DISPLAYLINK, USB_PRODUCT_DISPLAYLINK_ITEC, DL165)},
183 {USB_VPI(USB_VENDOR_DISPLAYLINK, USB_PRODUCT_DISPLAYLINK_DVI_19, DL165)},
184};
185
186static void
188{
189 mtx_init(&udl_buffer_mtx, "USB", "UDL", MTX_DEF);
190 TAILQ_INIT(&udl_buffer_head);
191}
192SYSINIT(udl_buffer_init, SI_SUB_LOCK, SI_ORDER_FIRST, udl_buffer_init, NULL);
193
194CTASSERT(sizeof(struct udl_buffer) < PAGE_SIZE);
195
196static void *
198{
199 struct udl_buffer *buf;
200 mtx_lock(&udl_buffer_mtx);
201 TAILQ_FOREACH(buf, &udl_buffer_head, entry) {
202 if (buf->size == size) {
203 TAILQ_REMOVE(&udl_buffer_head, buf, entry);
204 break;
205 }
206 }
207 mtx_unlock(&udl_buffer_mtx);
208 if (buf != NULL) {
209 uint8_t *ptr = ((uint8_t *)buf) - size;
210 /* wipe and recycle buffer */
211 memset(ptr, 0, size);
212 /* return buffer pointer */
213 return (ptr);
214 }
215 /* allocate new buffer */
216 return (malloc(size + sizeof(*buf), M_USB_DL, M_WAITOK | M_ZERO));
217}
218
219static void
220udl_buffer_free(void *_buf, uint32_t size)
221{
222 struct udl_buffer *buf;
223
224 /* check for NULL pointer */
225 if (_buf == NULL)
226 return;
227 /* compute pointer to recycle list */
228 buf = (struct udl_buffer *)(((uint8_t *)_buf) + size);
229
230 /*
231 * Memory mapped buffers should never be freed.
232 * Put display buffer into a recycle list.
233 */
234 mtx_lock(&udl_buffer_mtx);
235 buf->size = size;
236 TAILQ_INSERT_TAIL(&udl_buffer_head, buf, entry);
237 mtx_unlock(&udl_buffer_mtx);
238}
239
240static uint32_t
242{
243 unsigned i = sc->sc_cur_mode;
244
245 return ((uint32_t)udl_modes[i].hdisplay *
246 (uint32_t)udl_modes[i].vdisplay * 2);
247}
248
249static uint32_t
251{
252 unsigned i = sc->sc_cur_mode;
253
254 return (udl_modes[i].hdisplay);
255}
256
257static uint32_t
259{
260 unsigned i = sc->sc_cur_mode;
261
262 return (udl_modes[i].vdisplay);
263}
264
265static uint32_t
267{
268 unsigned i = sc->sc_cur_mode;
269
270 return (udl_modes[i].hz);
271}
272
273static void
274udl_callout(void *arg)
275{
276 struct udl_softc *sc = arg;
277 const uint32_t max = udl_get_fb_size(sc);
278 int fps;
279
280 if (sc->sc_power_save == 0) {
281 fps = udl_fps;
282
283 /* figure out number of frames per second */
284 if (fps < UDL_FPS_MIN)
285 fps = UDL_FPS_MIN;
286 else if (fps > UDL_FPS_MAX)
287 fps = UDL_FPS_MAX;
288
289 if (sc->sc_sync_off >= max)
290 sc->sc_sync_off = 0;
293 } else {
294 fps = 1;
295 }
296 callout_reset(&sc->sc_callout, hz / fps, &udl_callout, sc);
297}
298
299static int
300udl_probe(device_t dev)
301{
302 struct usb_attach_arg *uaa = device_get_ivars(dev);
303
304 if (uaa->usb_mode != USB_MODE_HOST)
305 return (ENXIO);
306 if (uaa->info.bConfigIndex != 0)
307 return (ENXIO);
308 if (uaa->info.bIfaceIndex != 0)
309 return (ENXIO);
310
311 return (usbd_lookup_id_by_uaa(udl_devs, sizeof(udl_devs), uaa));
312}
313
314static int
315udl_attach(device_t dev)
316{
317 struct sysctl_ctx_list *ctx = device_get_sysctl_ctx(dev);
318 struct sysctl_oid *tree = device_get_sysctl_tree(dev);
319 struct udl_softc *sc = device_get_softc(dev);
320 struct usb_attach_arg *uaa = device_get_ivars(dev);
321 int error;
322 int i;
323
325
326 mtx_init(&sc->sc_mtx, "UDL lock", NULL, MTX_DEF);
327 cv_init(&sc->sc_cv, "UDLCV");
328 callout_init_mtx(&sc->sc_callout, &sc->sc_mtx, 0);
329 sc->sc_udev = uaa->device;
330
332 sc->sc_xfer, udl_config, UDL_N_TRANSFER, sc, &sc->sc_mtx);
333
334 if (error) {
335 DPRINTF("usbd_transfer_setup error=%s\n", usbd_errstr(error));
336 goto detach;
337 }
340
341 TAILQ_INIT(&sc->sc_xfer_head[0]);
342 TAILQ_INIT(&sc->sc_xfer_head[1]);
343 TAILQ_INIT(&sc->sc_cmd_buf_free);
344 TAILQ_INIT(&sc->sc_cmd_buf_pending);
345
346 sc->sc_def_chip = -1;
347 sc->sc_chip = USB_GET_DRIVER_INFO(uaa);
348 sc->sc_def_mode = -1;
350
351 /* Allow chip ID to be overwritten */
352 SYSCTL_ADD_INT(ctx, SYSCTL_CHILDREN(tree), OID_AUTO, "chipid_force",
353 CTLFLAG_RWTUN, &sc->sc_def_chip, 0, "chip ID");
354
355 /* Export current chip ID */
356 SYSCTL_ADD_INT(ctx, SYSCTL_CHILDREN(tree), OID_AUTO, "chipid",
357 CTLFLAG_RD, &sc->sc_chip, 0, "chip ID");
358
359 if (sc->sc_def_chip > -1 && sc->sc_def_chip <= DLMAX) {
360 device_printf(dev, "Forcing chip ID to 0x%04x\n", sc->sc_def_chip);
361 sc->sc_chip = sc->sc_def_chip;
362 }
363 /*
364 * The product might have more than one chip
365 */
366 if (sc->sc_chip == DLUNK)
367 udl_select_chip(sc, uaa);
368
369 for (i = 0; i != UDL_CMD_MAX_BUFFERS; i++) {
370 struct udl_cmd_buf *cb = &sc->sc_cmd_buf_temp[i];
371
372 TAILQ_INSERT_TAIL(&sc->sc_cmd_buf_free, cb, entry);
373 }
374
375 /*
376 * Initialize chip.
377 */
378 error = udl_init_chip(sc);
380 goto detach;
381
382 /*
383 * Select edid mode.
384 */
385 udl_select_mode(sc);
386
387 /* Allow default mode to be overwritten */
388 SYSCTL_ADD_INT(ctx, SYSCTL_CHILDREN(tree), OID_AUTO, "mode_force",
389 CTLFLAG_RWTUN, &sc->sc_def_mode, 0, "mode");
390
391 /* Export current mode */
392 SYSCTL_ADD_INT(ctx, SYSCTL_CHILDREN(tree), OID_AUTO, "mode",
393 CTLFLAG_RD, &sc->sc_cur_mode, 0, "mode");
394
395 i = sc->sc_def_mode;
396 if (i > -1 && i < UDL_MAX_MODES) {
397 if (udl_modes[i].chip <= sc->sc_chip) {
398 device_printf(dev, "Forcing mode to %d\n", i);
399 sc->sc_cur_mode = i;
400 }
401 }
402 /* Printout current mode */
403 device_printf(dev, "Mode selected %dx%d @ %dHz\n",
404 (int)udl_get_fb_width(sc),
405 (int)udl_get_fb_height(sc),
406 (int)udl_get_fb_hz(sc));
407
409
410 /* Allocate frame buffer */
411 udl_fbmem_alloc(sc);
412
413 UDL_LOCK(sc);
414 udl_callout(sc);
415 UDL_UNLOCK(sc);
416
417 sc->sc_fb_info.fb_name = device_get_nameunit(dev);
418 sc->sc_fb_info.fb_size = sc->sc_fb_size;
419 sc->sc_fb_info.fb_bpp = 16;
420 sc->sc_fb_info.fb_depth = 16;
421 sc->sc_fb_info.fb_width = udl_get_fb_width(sc);
422 sc->sc_fb_info.fb_height = udl_get_fb_height(sc);
423 sc->sc_fb_info.fb_stride = sc->sc_fb_info.fb_width * 2;
424 sc->sc_fb_info.fb_pbase = 0;
425 sc->sc_fb_info.fb_vbase = (uintptr_t)sc->sc_fb_addr;
426 sc->sc_fb_info.fb_priv = sc;
427 sc->sc_fb_info.setblankmode = &udl_fb_setblankmode;
428
429 sc->sc_fbdev = device_add_child(dev, "fbd", -1);
430 if (sc->sc_fbdev == NULL)
431 goto detach;
432 if (device_probe_and_attach(sc->sc_fbdev) != 0)
433 goto detach;
434
435 return (0);
436
437detach:
439
440 return (ENXIO);
441}
442
443static int
444udl_detach(device_t dev)
445{
446 struct udl_softc *sc = device_get_softc(dev);
447
448 /* delete all child devices */
449 device_delete_children(dev);
450
451 UDL_LOCK(sc);
452 sc->sc_gone = 1;
453 callout_stop(&sc->sc_callout);
454 UDL_UNLOCK(sc);
455
457
458 callout_drain(&sc->sc_callout);
459
460 mtx_destroy(&sc->sc_mtx);
461 cv_destroy(&sc->sc_cv);
462
463 /* put main framebuffer into a recycle list, if any */
465
466 /* free shadow framebuffer memory, if any */
467 free(sc->sc_fb_copy, M_USB_DL);
468
469 return (0);
470}
471
472static struct fb_info *
473udl_fb_getinfo(device_t dev)
474{
475 struct udl_softc *sc = device_get_softc(dev);
476
477 return (&sc->sc_fb_info);
478}
479
480static int
481udl_fb_setblankmode(void *arg, int mode)
482{
483 struct udl_softc *sc = arg;
484
485 switch (mode) {
486 case V_DISPLAY_ON:
487 udl_power_save(sc, 1, M_WAITOK);
488 break;
489 case V_DISPLAY_BLANK:
490 udl_power_save(sc, 1, M_WAITOK);
491 if (sc->sc_fb_addr != 0) {
492 const uint32_t max = udl_get_fb_size(sc);
493
494 memset((void *)sc->sc_fb_addr, 0, max);
495 }
496 break;
497 case V_DISPLAY_STAND_BY:
498 case V_DISPLAY_SUSPEND:
499 udl_power_save(sc, 0, M_WAITOK);
500 break;
501 }
502 return (0);
503}
504
505static struct udl_cmd_buf *
507{
508 struct udl_cmd_buf *cb;
509
510 while ((cb = TAILQ_FIRST(&sc->sc_cmd_buf_free)) == NULL) {
511 if (flags != M_WAITOK)
512 break;
513 cv_wait(&sc->sc_cv, &sc->sc_mtx);
514 }
515 if (cb != NULL) {
516 TAILQ_REMOVE(&sc->sc_cmd_buf_free, cb, entry);
517 cb->off = 0;
518 }
519 return (cb);
520}
521
522static struct udl_cmd_buf *
523udl_cmd_buf_alloc(struct udl_softc *sc, int flags)
524{
525 struct udl_cmd_buf *cb;
526
527 UDL_LOCK(sc);
528 cb = udl_cmd_buf_alloc_locked(sc, flags);
529 UDL_UNLOCK(sc);
530 return (cb);
531}
532
533static void
535{
536 UDL_LOCK(sc);
537 if (sc->sc_gone) {
538 TAILQ_INSERT_TAIL(&sc->sc_cmd_buf_free, cb, entry);
539 } else {
540 /* mark end of command stack */
543
544 TAILQ_INSERT_TAIL(&sc->sc_cmd_buf_pending, cb, entry);
547 }
548 UDL_UNLOCK(sc);
549}
550
551static struct udl_cmd_buf *
553{
554 const uint32_t max = udl_get_fb_size(sc);
555
556 /* check if framebuffer is not ready */
557 if (sc->sc_fb_addr == NULL ||
558 sc->sc_fb_copy == NULL)
559 return (NULL);
560
561 while (sc->sc_sync_off < max) {
562 uint32_t delta = max - sc->sc_sync_off;
563
564 if (delta > UDL_CMD_MAX_PIXEL_COUNT * 2)
565 delta = UDL_CMD_MAX_PIXEL_COUNT * 2;
566 if (bcmp(sc->sc_fb_addr + sc->sc_sync_off, sc->sc_fb_copy + sc->sc_sync_off, delta) != 0) {
567 struct udl_cmd_buf *cb;
568
569 cb = udl_cmd_buf_alloc_locked(sc, M_NOWAIT);
570 if (cb == NULL)
571 goto done;
572 memcpy(sc->sc_fb_copy + sc->sc_sync_off,
573 sc->sc_fb_addr + sc->sc_sync_off, delta);
577 udl_cmd_insert_int_1(cb, delta / 2);
578 udl_cmd_insert_buf_le16(cb, sc->sc_fb_copy + sc->sc_sync_off, delta);
579 sc->sc_sync_off += delta;
580 return (cb);
581 } else {
582 sc->sc_sync_off += delta;
583 }
584 }
585done:
586 return (NULL);
587}
588
589static void
591{
592 struct udl_softc *sc = usbd_xfer_softc(xfer);
593 struct udl_cmd_head *phead = usbd_xfer_get_priv(xfer);
594 struct udl_cmd_buf *cb;
595 unsigned i;
596
597 switch (USB_GET_STATE(xfer)) {
599 TAILQ_CONCAT(&sc->sc_cmd_buf_free, phead, entry);
600 case USB_ST_SETUP:
601tr_setup:
602 for (i = 0; i != UDL_CMD_MAX_FRAMES; i++) {
603 cb = TAILQ_FIRST(&sc->sc_cmd_buf_pending);
604 if (cb == NULL) {
606 if (cb == NULL)
607 break;
608 } else {
609 TAILQ_REMOVE(&sc->sc_cmd_buf_pending, cb, entry);
610 }
611 TAILQ_INSERT_TAIL(phead, cb, entry);
612 usbd_xfer_set_frame_data(xfer, i, cb->buf, cb->off);
613 }
614 if (i != 0) {
615 usbd_xfer_set_frames(xfer, i);
617 }
618 break;
619 default:
620 TAILQ_CONCAT(&sc->sc_cmd_buf_free, phead, entry);
621 if (error != USB_ERR_CANCELLED) {
622 /* try clear stall first */
624 goto tr_setup;
625 }
626 break;
627 }
628 /* wakeup any waiters */
629 cv_signal(&sc->sc_cv);
630}
631
632static int
633udl_power_save(struct udl_softc *sc, int on, int flags)
634{
635 struct udl_cmd_buf *cb;
636
637 /* get new buffer */
638 cb = udl_cmd_buf_alloc(sc, flags);
639 if (cb == NULL)
640 return (EAGAIN);
641
642 DPRINTF("screen %s\n", on ? "ON" : "OFF");
643
644 sc->sc_power_save = on ? 0 : 1;
645
646 if (on)
648 else
650
652 udl_cmd_buf_send(sc, cb);
653 return (0);
654}
655
656static int
657udl_ctrl_msg(struct udl_softc *sc, uint8_t rt, uint8_t r,
658 uint16_t index, uint16_t value, uint8_t *buf, size_t len)
659{
661 int error;
662
663 req.bmRequestType = rt;
664 req.bRequest = r;
665 USETW(req.wIndex, index);
666 USETW(req.wValue, value);
667 USETW(req.wLength, len);
668
670 &req, buf, 0, NULL, USB_DEFAULT_TIMEOUT);
671
672 DPRINTF("%s\n", usbd_errstr(error));
673
674 return (error);
675}
676
677static int
678udl_poll(struct udl_softc *sc, uint32_t *buf)
679{
680 uint32_t lbuf;
681 int error;
682
684 UDL_CTRL_CMD_POLL, 0x0000, 0x0000, (uint8_t *)&lbuf, sizeof(lbuf));
686 *buf = le32toh(lbuf);
687 return (error);
688}
689
690static int
691udl_read_1(struct udl_softc *sc, uint16_t addr, uint8_t *buf)
692{
693 uint8_t lbuf[1];
694 int error;
695
697 UDL_CTRL_CMD_READ_1, addr, 0x0000, lbuf, 1);
699 *buf = *(uint8_t *)lbuf;
700 return (error);
701}
702
703static int
704udl_write_1(struct udl_softc *sc, uint16_t addr, uint8_t buf)
705{
706 int error;
707
709 UDL_CTRL_CMD_WRITE_1, addr, 0x0000, &buf, 1);
710 return (error);
711}
712
713static int
714udl_read_edid(struct udl_softc *sc, uint8_t *buf)
715{
716 uint8_t lbuf[64];
717 uint16_t offset;
718 int error;
719
720 offset = 0;
721
723 UDL_CTRL_CMD_READ_EDID, 0x00a1, (offset << 8), lbuf, 64);
725 goto fail;
726 bcopy(lbuf + 1, buf + offset, 63);
727 offset += 63;
728
730 UDL_CTRL_CMD_READ_EDID, 0x00a1, (offset << 8), lbuf, 64);
732 goto fail;
733 bcopy(lbuf + 1, buf + offset, 63);
734 offset += 63;
735
737 UDL_CTRL_CMD_READ_EDID, 0x00a1, (offset << 8), lbuf, 3);
739 goto fail;
740 bcopy(lbuf + 1, buf + offset, 2);
741fail:
742 return (error);
743}
744
745static uint8_t
746udl_lookup_mode(uint16_t hdisplay, uint16_t vdisplay, uint8_t hz,
747 uint16_t chip, uint32_t clock)
748{
749 uint8_t idx;
750
751 /*
752 * Check first if we have a matching mode with pixelclock
753 */
754 for (idx = 0; idx != UDL_MAX_MODES; idx++) {
755 if ((udl_modes[idx].hdisplay == hdisplay) &&
756 (udl_modes[idx].vdisplay == vdisplay) &&
757 (udl_modes[idx].clock == clock) &&
758 (udl_modes[idx].chip <= chip)) {
759 return (idx);
760 }
761 }
762
763 /*
764 * If not, check for matching mode with update frequency
765 */
766 for (idx = 0; idx != UDL_MAX_MODES; idx++) {
767 if ((udl_modes[idx].hdisplay == hdisplay) &&
768 (udl_modes[idx].vdisplay == vdisplay) &&
769 (udl_modes[idx].hz == hz) &&
770 (udl_modes[idx].chip <= chip)) {
771 return (idx);
772 }
773 }
774 return (idx);
775}
776
777static void
779{
780 const char *pserial;
781
782 pserial = usb_get_serial(uaa->device);
783
784 sc->sc_chip = DL120;
785
786 if ((uaa->info.idVendor == USB_VENDOR_DISPLAYLINK) &&
787 (uaa->info.idProduct == USB_PRODUCT_DISPLAYLINK_WSDVI)) {
788 /*
789 * WS Tech DVI is DL120 or DL160. All deviced uses the
790 * same revision (0.04) so iSerialNumber must be used
791 * to determin which chip it is.
792 */
793
794 if (strlen(pserial) > 7) {
795 if (strncmp(pserial, "0198-13", 7) == 0)
796 sc->sc_chip = DL160;
797 }
798 DPRINTF("iSerialNumber (%s) used to select chip (%d)\n",
799 pserial, sc->sc_chip);
800 }
801 if ((uaa->info.idVendor == USB_VENDOR_DISPLAYLINK) &&
802 (uaa->info.idProduct == USB_PRODUCT_DISPLAYLINK_SWDVI)) {
803 /*
804 * SUNWEIT DVI is DL160, DL125, DL165 or DL195. Major revision
805 * can be used to differ between DL1x0 and DL1x5. Minor to
806 * differ between DL1x5. iSerialNumber seems not to be uniqe.
807 */
808
809 sc->sc_chip = DL160;
810
811 if (uaa->info.bcdDevice >= 0x100) {
812 sc->sc_chip = DL165;
813 if (uaa->info.bcdDevice == 0x104)
814 sc->sc_chip = DL195;
815 if (uaa->info.bcdDevice == 0x108)
816 sc->sc_chip = DL125;
817 }
818 DPRINTF("bcdDevice (%02x) used to select chip (%d)\n",
819 uaa->info.bcdDevice, sc->sc_chip);
820 }
821}
822
823static int
824udl_set_enc_key(struct udl_softc *sc, uint8_t *buf, uint8_t len)
825{
826 int error;
827
829 UDL_CTRL_CMD_SET_KEY, 0x0000, 0x0000, buf, len);
830 return (error);
831}
832
833static void
835{
836 uint32_t size;
837
838 size = udl_get_fb_size(sc);
839 size = round_page(size);
840 /* check for zero size */
841 if (size == 0)
842 size = PAGE_SIZE;
843 /*
844 * It is assumed that allocations above PAGE_SIZE bytes will
845 * be PAGE_SIZE aligned for use with mmap()
846 */
848 sc->sc_fb_copy = malloc(size, M_USB_DL, M_WAITOK | M_ZERO);
849 sc->sc_fb_size = size;
850}
851
852static void
853udl_cmd_insert_int_1(struct udl_cmd_buf *cb, uint8_t value)
854{
855
856 cb->buf[cb->off] = value;
857 cb->off += 1;
858}
859
860#if 0
861static void
862udl_cmd_insert_int_2(struct udl_cmd_buf *cb, uint16_t value)
863{
864 uint16_t lvalue;
865
866 lvalue = htobe16(value);
867 bcopy(&lvalue, cb->buf + cb->off, 2);
868
869 cb->off += 2;
870}
871
872#endif
873
874static void
875udl_cmd_insert_int_3(struct udl_cmd_buf *cb, uint32_t value)
876{
877 uint32_t lvalue;
878
879#if BYTE_ORDER == BIG_ENDIAN
880 lvalue = htobe32(value) << 8;
881#else
882 lvalue = htobe32(value) >> 8;
883#endif
884 bcopy(&lvalue, cb->buf + cb->off, 3);
885
886 cb->off += 3;
887}
888
889#if 0
890static void
891udl_cmd_insert_int_4(struct udl_cmd_buf *cb, uint32_t value)
892{
893 uint32_t lvalue;
894
895 lvalue = htobe32(value);
896 bcopy(&lvalue, cb->buf + cb->off, 4);
897
898 cb->off += 4;
899}
900
901#endif
902
903static void
904udl_cmd_insert_buf_le16(struct udl_cmd_buf *cb, const uint8_t *buf, uint32_t len)
905{
906 uint32_t x;
907
908 for (x = 0; x != len; x += 2) {
909 /* byte swap from little endian to big endian */
910 cb->buf[cb->off + x + 0] = buf[x + 1];
911 cb->buf[cb->off + x + 1] = buf[x + 0];
912 }
913 cb->off += len;
914}
915
916static void
917udl_cmd_write_reg_1(struct udl_cmd_buf *cb, uint8_t reg, uint8_t val)
918{
919
924}
925
926static void
927udl_cmd_write_reg_3(struct udl_cmd_buf *cb, uint8_t reg, uint32_t val)
928{
929
930 udl_cmd_write_reg_1(cb, reg + 0, (val >> 16) & 0xff);
931 udl_cmd_write_reg_1(cb, reg + 1, (val >> 8) & 0xff);
932 udl_cmd_write_reg_1(cb, reg + 2, (val >> 0) & 0xff);
933}
934
935static int
937{
938 uint32_t ui32;
939 uint8_t ui8;
940 int error;
941
942 error = udl_poll(sc, &ui32);
944 return (error);
945 DPRINTF("poll=0x%08x\n", ui32);
946
947 /* Some products may use later chip too */
948 switch (ui32 & 0xff) {
949 case 0xf1: /* DL1x5 */
950 switch (sc->sc_chip) {
951 case DL120:
952 sc->sc_chip = DL125;
953 break;
954 case DL160:
955 sc->sc_chip = DL165;
956 break;
957 }
958 break;
959 }
960 DPRINTF("chip 0x%04x\n", sc->sc_chip);
961
962 error = udl_read_1(sc, 0xc484, &ui8);
964 return (error);
965 DPRINTF("read 0x%02x from 0xc484\n", ui8);
966
967 error = udl_write_1(sc, 0xc41f, 0x01);
969 return (error);
970 DPRINTF("write 0x01 to 0xc41f\n");
971
972 error = udl_read_edid(sc, sc->sc_edid);
974 return (error);
975 DPRINTF("read EDID\n");
976
977 error = udl_set_enc_key(sc, __DECONST(void *, udl_null_key_1),
978 sizeof(udl_null_key_1));
980 return (error);
981 DPRINTF("set encryption key\n");
982
983 error = udl_write_1(sc, 0xc40b, 0x00);
985 return (error);
986 DPRINTF("write 0x00 to 0xc40b\n");
987
989}
990
991static void
992udl_init_fb_offsets(struct udl_cmd_buf *cb, uint32_t start16, uint32_t stride16,
993 uint32_t start8, uint32_t stride8)
994{
1001}
1002
1003static int
1005{
1006 const uint32_t max = udl_get_fb_size(sc);
1007 const uint8_t *buf = udl_modes[sc->sc_cur_mode].mode;
1008 struct udl_cmd_buf *cb;
1009 uint32_t delta;
1010 uint32_t i;
1011 int error;
1012
1013 /* get new buffer */
1014 cb = udl_cmd_buf_alloc(sc, M_WAITOK);
1015 if (cb == NULL)
1016 return (EAGAIN);
1017
1018 /* write resolution values and set video memory offsets */
1020 for (i = 0; i < UDL_MODE_SIZE; i++)
1021 udl_cmd_write_reg_1(cb, i, buf[i]);
1023
1024 udl_init_fb_offsets(cb, 0x000000, 0x000a00, 0x555555, 0x000500);
1025 udl_cmd_buf_send(sc, cb);
1026
1027 /* fill screen with black color */
1028 for (i = 0; i < max; i += delta) {
1029 static const uint8_t udl_black[UDL_CMD_MAX_PIXEL_COUNT * 2] __aligned(4);
1030
1031 delta = max - i;
1032 if (delta > UDL_CMD_MAX_PIXEL_COUNT * 2)
1033 delta = UDL_CMD_MAX_PIXEL_COUNT * 2;
1034 if (i == 0)
1035 error = udl_cmd_write_buf_le16(sc, udl_black, i, delta / 2, M_WAITOK);
1036 else
1037 error = udl_cmd_buf_copy_le16(sc, 0, i, delta / 2, M_WAITOK);
1038 if (error)
1039 return (error);
1040 }
1041
1042 /* get new buffer */
1043 cb = udl_cmd_buf_alloc(sc, M_WAITOK);
1044 if (cb == NULL)
1045 return (EAGAIN);
1046
1047 /* show framebuffer content */
1050 udl_cmd_buf_send(sc, cb);
1051 return (0);
1052}
1053
1054static void
1056{
1057 struct udl_mode mode;
1058 int index = UDL_MAX_MODES;
1059 int i;
1060
1061 /* try to get the preferred mode from EDID */
1062 edid_parse(sc->sc_edid, &sc->sc_edid_info);
1063#ifdef USB_DEBUG
1064 edid_print(&sc->sc_edid_info);
1065#endif
1066 if (sc->sc_edid_info.edid_preferred_mode != NULL) {
1067 mode.hz =
1068 (sc->sc_edid_info.edid_preferred_mode->dot_clock * 1000) /
1069 (sc->sc_edid_info.edid_preferred_mode->htotal *
1070 sc->sc_edid_info.edid_preferred_mode->vtotal);
1071 mode.clock =
1072 sc->sc_edid_info.edid_preferred_mode->dot_clock / 10;
1073 mode.hdisplay =
1074 sc->sc_edid_info.edid_preferred_mode->hdisplay;
1075 mode.vdisplay =
1076 sc->sc_edid_info.edid_preferred_mode->vdisplay;
1077 index = udl_lookup_mode(mode.hdisplay, mode.vdisplay, mode.hz,
1078 sc->sc_chip, mode.clock);
1079 sc->sc_cur_mode = index;
1080 } else {
1081 DPRINTF("no preferred mode found!\n");
1082 }
1083
1084 if (index == UDL_MAX_MODES) {
1085 DPRINTF("no mode line found\n");
1086
1087 i = 0;
1088 while (i < sc->sc_edid_info.edid_nmodes) {
1089 mode.hz =
1090 (sc->sc_edid_info.edid_modes[i].dot_clock * 1000) /
1091 (sc->sc_edid_info.edid_modes[i].htotal *
1092 sc->sc_edid_info.edid_modes[i].vtotal);
1093 mode.clock =
1094 sc->sc_edid_info.edid_modes[i].dot_clock / 10;
1095 mode.hdisplay =
1096 sc->sc_edid_info.edid_modes[i].hdisplay;
1097 mode.vdisplay =
1098 sc->sc_edid_info.edid_modes[i].vdisplay;
1099 index = udl_lookup_mode(mode.hdisplay, mode.vdisplay,
1100 mode.hz, sc->sc_chip, mode.clock);
1101 if (index < UDL_MAX_MODES)
1102 if ((sc->sc_cur_mode == UDL_MAX_MODES) ||
1103 (index > sc->sc_cur_mode))
1104 sc->sc_cur_mode = index;
1105 i++;
1106 }
1107 }
1108 /*
1109 * If no mode found use default.
1110 */
1111 if (sc->sc_cur_mode == UDL_MAX_MODES)
1112 sc->sc_cur_mode = udl_lookup_mode(800, 600, 60, sc->sc_chip, 0);
1113}
1114
1115static int
1116udl_cmd_write_buf_le16(struct udl_softc *sc, const uint8_t *buf, uint32_t off,
1117 uint8_t pixels, int flags)
1118{
1119 struct udl_cmd_buf *cb;
1120
1121 cb = udl_cmd_buf_alloc(sc, flags);
1122 if (cb == NULL)
1123 return (EAGAIN);
1124
1128 udl_cmd_insert_int_1(cb, pixels);
1129 udl_cmd_insert_buf_le16(cb, buf, 2 * pixels);
1130 udl_cmd_buf_send(sc, cb);
1131
1132 return (0);
1133}
1134
1135static int
1136udl_cmd_buf_copy_le16(struct udl_softc *sc, uint32_t src, uint32_t dst,
1137 uint8_t pixels, int flags)
1138{
1139 struct udl_cmd_buf *cb;
1140
1141 cb = udl_cmd_buf_alloc(sc, flags);
1142 if (cb == NULL)
1143 return (EAGAIN);
1144
1147 udl_cmd_insert_int_3(cb, dst);
1148 udl_cmd_insert_int_1(cb, pixels);
1149 udl_cmd_insert_int_3(cb, src);
1150 udl_cmd_buf_send(sc, cb);
1151
1152 return (0);
1153}
static int debug
Definition: cfumass.c:73
struct ehci_hw_softc __aligned
uint16_t len
Definition: ehci.h:41
uint8_t size
Definition: if_axge.c:89
uint32_t reg
Definition: if_rum.c:283
uint32_t val
Definition: if_rum.c:284
uint8_t r
Definition: if_run.c:612
uint16_t fail
Definition: if_runreg.h:2
struct @109 error
uint32_t value
u_int index
device_t dev
uint64_t * addr
Definition: udl.h:39
uint32_t size
Definition: udl.h:41
uint32_t off
Definition: udl.h:48
Definition: udl.h:275
const uint8_t * mode
Definition: udl.h:281
Definition: udl.h:63
int sc_chip
Definition: udl.h:82
uint8_t * sc_fb_addr
Definition: udl.h:79
uint8_t * sc_fb_copy
Definition: udl.h:80
struct usb_xfer * sc_xfer[UDL_N_TRANSFER]
Definition: udl.h:67
struct udl_cmd_head sc_cmd_buf_pending
Definition: udl.h:75
uint32_t sc_fb_size
Definition: udl.h:78
struct callout sc_callout
Definition: udl.h:66
int sc_cur_mode
Definition: udl.h:92
struct fb_info sc_fb_info
Definition: udl.h:70
uint32_t sc_sync_off
Definition: udl.h:77
struct udl_cmd_head sc_cmd_buf_free
Definition: udl.h:74
struct mtx sc_mtx
Definition: udl.h:64
struct edid_info sc_edid_info
Definition: udl.h:72
int sc_def_mode
Definition: udl.h:91
struct usb_device * sc_udev
Definition: udl.h:68
struct udl_cmd_head sc_xfer_head[2]
Definition: udl.h:73
uint8_t sc_power_save
Definition: udl.h:93
device_t sc_fbdev
Definition: udl.h:69
uint8_t sc_gone
Definition: udl.h:94
uint8_t sc_edid[128]
Definition: udl.h:71
struct cv sc_cv
Definition: udl.h:65
struct udl_cmd_buf sc_cmd_buf_temp[UDL_CMD_MAX_BUFFERS]
Definition: udl.h:76
int sc_def_chip
Definition: udl.h:81
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
uint16_t idProduct
Definition: usbdi.h:409
uint8_t bIfaceIndex
Definition: usbdi.h:417
uint8_t bConfigIndex
Definition: usbdi.h:419
uint16_t idVendor
Definition: usbdi.h:408
uint16_t bcdDevice
Definition: usbdi.h:410
MODULE_DEPEND(udl, usb, 1, 1, 1)
DRIVER_MODULE(udl, uhub, udl_driver, udl_devclass, NULL, NULL)
static int udl_init_resolution(struct udl_softc *)
Definition: udl.c:1004
static void udl_select_chip(struct udl_softc *, struct usb_attach_arg *)
Definition: udl.c:778
static struct mtx udl_buffer_mtx
Definition: udl.c:80
static void udl_cmd_insert_int_3(struct udl_cmd_buf *, uint32_t)
Definition: udl.c:875
static void udl_init_fb_offsets(struct udl_cmd_buf *cb, uint32_t start16, uint32_t stride16, uint32_t start8, uint32_t stride8)
Definition: udl.c:992
static int udl_fps
Definition: udl.c:76
static usb_callback_t udl_bulk_write_callback
Definition: udl.c:88
static device_method_t udl_methods[]
Definition: udl.c:138
SYSINIT(udl_buffer_init, SI_SUB_LOCK, SI_ORDER_FIRST, udl_buffer_init, NULL)
static int udl_ctrl_msg(struct udl_softc *sc, uint8_t rt, uint8_t r, uint16_t index, uint16_t value, uint8_t *buf, size_t len)
Definition: udl.c:657
static void udl_cmd_write_reg_3(struct udl_cmd_buf *, uint8_t, uint32_t)
Definition: udl.c:927
static void udl_cmd_write_reg_1(struct udl_cmd_buf *, uint8_t, uint8_t)
Definition: udl.c:917
static int udl_read_1(struct udl_softc *sc, uint16_t addr, uint8_t *buf)
Definition: udl.c:691
static void udl_buffer_free(void *_buf, uint32_t size)
Definition: udl.c:220
static const STRUCT_USB_HOST_ID udl_devs[]
Definition: udl.c:161
static void udl_cmd_buf_send(struct udl_softc *sc, struct udl_cmd_buf *cb)
Definition: udl.c:534
static int udl_cmd_buf_copy_le16(struct udl_softc *, uint32_t, uint32_t, uint8_t, int)
Definition: udl.c:1136
static void * udl_buffer_alloc(uint32_t size)
Definition: udl.c:197
static int udl_set_enc_key(struct udl_softc *sc, uint8_t *buf, uint8_t len)
Definition: udl.c:824
static SYSCTL_NODE(_hw_usb, OID_AUTO, udl, CTLFLAG_RW|CTLFLAG_MPSAFE, 0, "USB UDL")
#define UDL_FPS_MIN
Definition: udl.c:74
static uint32_t udl_get_fb_hz(struct udl_softc *sc)
Definition: udl.c:266
static device_detach_t udl_detach
Definition: udl.c:92
static struct udl_cmd_buf * udl_fb_synchronize_locked(struct udl_softc *sc)
Definition: udl.c:552
static void udl_cmd_insert_int_1(struct udl_cmd_buf *, uint8_t)
Definition: udl.c:853
MALLOC_DEFINE(M_USB_DL, "USB", "USB DisplayLink")
static int udl_init_chip(struct udl_softc *)
Definition: udl.c:936
static const struct usb_config udl_config[UDL_N_TRANSFER]
Definition: udl.c:110
static int udl_poll(struct udl_softc *sc, uint32_t *buf)
Definition: udl.c:678
static device_attach_t udl_attach
Definition: udl.c:91
static int udl_cmd_write_buf_le16(struct udl_softc *, const uint8_t *, uint32_t, uint8_t, int)
Definition: udl.c:1116
static void udl_select_mode(struct udl_softc *)
Definition: udl.c:1055
CTASSERT(sizeof(struct udl_buffer)< PAGE_SIZE)
static void udl_buffer_init(void *arg)
Definition: udl.c:187
static struct udl_cmd_buf * udl_cmd_buf_alloc_locked(struct udl_softc *sc, int flags)
Definition: udl.c:506
static int udl_write_1(struct udl_softc *sc, uint16_t addr, uint8_t buf)
Definition: udl.c:704
static struct udl_buffer_head udl_buffer_head
Definition: udl.c:81
static devclass_t udl_devclass
Definition: udl.c:136
static fb_setblankmode_t udl_fb_setblankmode
Definition: udl.c:94
static int udl_power_save(struct udl_softc *, int, int)
Definition: udl.c:633
static uint8_t udl_lookup_mode(uint16_t hdisplay, uint16_t vdisplay, uint8_t hz, uint16_t chip, uint32_t clock)
Definition: udl.c:746
static void udl_fbmem_alloc(struct udl_softc *)
Definition: udl.c:834
static driver_t udl_driver
Definition: udl.c:146
static struct udl_cmd_buf * udl_cmd_buf_alloc(struct udl_softc *sc, int flags)
Definition: udl.c:523
#define UDL_FPS_MAX
Definition: udl.c:73
static uint32_t udl_get_fb_height(struct udl_softc *sc)
Definition: udl.c:258
SYSCTL_INT(_hw_usb_udl, OID_AUTO, fps, CTLFLAG_RWTUN, &udl_fps, 0, "Frames Per Second, 1-60")
static uint32_t udl_get_fb_width(struct udl_softc *sc)
Definition: udl.c:250
static int udl_read_edid(struct udl_softc *sc, uint8_t *buf)
Definition: udl.c:714
static void udl_cmd_insert_buf_le16(struct udl_cmd_buf *, const uint8_t *, uint32_t)
Definition: udl.c:904
static uint32_t udl_get_fb_size(struct udl_softc *sc)
Definition: udl.c:241
static device_probe_t udl_probe
Definition: udl.c:90
static void udl_callout(void *arg)
Definition: udl.c:274
static fb_getinfo_t udl_fb_getinfo
Definition: udl.c:93
MODULE_VERSION(udl, 1)
#define UDL_REG_ADDR_START8
Definition: udl.h:126
#define DL120
Definition: udl.h:85
#define UDL_REG_ADDR_STRIDE8
Definition: udl.h:127
#define UDL_CMD_MAX_FRAMES
Definition: udl.h:29
#define UDL_REG_SCREEN_OFF
Definition: udl.h:131
#define UDL_BULK_CMD_EOC
Definition: udl.h:112
#define UDL_REG_SCREEN
Definition: udl.h:129
#define UDL_CTRL_CMD_WRITE_1
Definition: udl.h:104
#define UDL_BULK_CMD_FB_WRITE
Definition: udl.h:118
#define UDL_BULK_CMD_FB_WORD
Definition: udl.h:116
#define UDL_BULK_SOC
Definition: udl.h:109
#define DL165
Definition: udl.h:87
#define UDL_CTRL_CMD_READ_1
Definition: udl.h:105
#define UDL_CTRL_CMD_SET_KEY
Definition: udl.h:107
#define DLUNK
Definition: udl.h:90
#define DL160
Definition: udl.h:86
#define UDL_MODE_SIZE
Definition: udl.h:134
#define UDL_CMD_MAX_PIXEL_COUNT
Definition: udl.h:32
static const struct udl_mode udl_modes[UDL_MAX_MODES]
Definition: udl.h:284
#define UDL_REG_SYNC
Definition: udl.h:132
@ UDL_N_TRANSFER
Definition: udl.h:57
@ UDL_BULK_WRITE_1
Definition: udl.h:56
@ UDL_BULK_WRITE_0
Definition: udl.h:55
#define DLMAX
Definition: udl.h:89
#define UDL_MAX_MODES
Definition: udl.h:35
#define UDL_REG_SCREEN_ON
Definition: udl.h:130
#define UDL_REG_ADDR_STRIDE16
Definition: udl.h:125
#define UDL_BULK_CMD_REG_WRITE_1
Definition: udl.h:111
#define UDL_CTRL_CMD_READ_EDID
Definition: udl.h:103
#define DL195
Definition: udl.h:88
#define UDL_CMD_MAX_BUFFERS
Definition: udl.h:33
static const uint8_t udl_null_key_1[]
Definition: udl.h:315
#define UDL_LOCK(sc)
Definition: udl.h:97
#define DL125
Definition: udl.h:84
#define UDL_BULK_CMD_FB_COPY
Definition: udl.h:119
#define UDL_CMD_MAX_DATA_SIZE
Definition: udl.h:30
#define UDL_CTRL_CMD_POLL
Definition: udl.h:106
#define UDL_REG_ADDR_START16
Definition: udl.h:124
#define UDL_UNLOCK(sc)
Definition: udl.h:98
#define DPRINTF(...)
Definition: umass.c:179
#define UE_ADDR_ANY
Definition: usb.h:537
#define UE_BULK
Definition: usb.h:543
#define UT_WRITE_VENDOR_DEVICE
Definition: usb.h:184
#define UT_READ_VENDOR_DEVICE
Definition: usb.h:180
@ USB_MODE_HOST
Definition: usb.h:778
#define UE_DIR_TX
Definition: usb.h:534
const char * usb_get_serial(struct usb_device *udev)
Definition: usb_device.c:293
#define USETW(w, v)
Definition: usb_endian.h:77
const char * usbd_errstr(usb_error_t err)
Definition: usb_error.c:93
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
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_xfer_get_priv(struct usb_xfer *xfer)
void usbd_transfer_unsetup(struct usb_xfer **pxfer, uint16_t n_setup)
void usbd_xfer_set_frame_data(struct usb_xfer *xfer, usb_frcount_t frindex, void *ptr, usb_frlength_t len)
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_set_priv(struct usb_xfer *xfer, void *ptr)
void * usbd_xfer_softc(struct usb_xfer *xfer)
void usbd_xfer_set_stall(struct usb_xfer *xfer)
void device_set_usb_desc(device_t dev)
Definition: usb_util.c:73
#define USB_DEFAULT_TIMEOUT
Definition: usbdi.h:89
#define USB_ST_SETUP
Definition: usbdi.h:502
usb_error_t
Definition: usbdi.h:45
@ USB_ERR_NORMAL_COMPLETION
Definition: usbdi.h:46
@ 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