FreeBSD kernel usb device Code
|
#include <sys/param.h>
#include <sys/bus.h>
#include <sys/callout.h>
#include <sys/conf.h>
#include <sys/kernel.h>
#include <sys/lock.h>
#include <sys/module.h>
#include <sys/mutex.h>
#include <sys/condvar.h>
#include <sys/sysctl.h>
#include <sys/systm.h>
#include <sys/consio.h>
#include <sys/fbio.h>
#include <dev/fb/fbreg.h>
#include <dev/syscons/syscons.h>
#include <dev/videomode/videomode.h>
#include <dev/videomode/edidvar.h>
#include <dev/usb/usb.h>
#include <dev/usb/usbdi.h>
#include <dev/usb/usbdi_util.h>
#include "usbdevs.h"
#include <dev/usb/video/udl.h>
#include "fb_if.h"
#include <dev/usb/usb_debug.h>
Go to the source code of this file.
Macros | |
#define | USB_DEBUG_VAR udl_debug |
#define | UDL_FPS_MAX 60 |
#define | UDL_FPS_MIN 1 |
Functions | |
static | SYSCTL_NODE (_hw_usb, OID_AUTO, udl, CTLFLAG_RW|CTLFLAG_MPSAFE, 0, "USB UDL") |
SYSCTL_INT (_hw_usb_udl, OID_AUTO, fps, CTLFLAG_RWTUN, &udl_fps, 0, "Frames Per Second, 1-60") | |
MALLOC_DEFINE (M_USB_DL, "USB", "USB DisplayLink") | |
static void | udl_select_chip (struct udl_softc *, struct usb_attach_arg *) |
static int | udl_init_chip (struct udl_softc *) |
static void | udl_select_mode (struct udl_softc *) |
static int | udl_init_resolution (struct udl_softc *) |
static void | udl_fbmem_alloc (struct udl_softc *) |
static int | udl_cmd_write_buf_le16 (struct udl_softc *, const uint8_t *, uint32_t, uint8_t, int) |
static int | udl_cmd_buf_copy_le16 (struct udl_softc *, uint32_t, uint32_t, uint8_t, int) |
static void | udl_cmd_insert_int_1 (struct udl_cmd_buf *, uint8_t) |
static void | udl_cmd_insert_int_3 (struct udl_cmd_buf *, uint32_t) |
static void | udl_cmd_insert_buf_le16 (struct udl_cmd_buf *, const uint8_t *, uint32_t) |
static void | udl_cmd_write_reg_1 (struct udl_cmd_buf *, uint8_t, uint8_t) |
static void | udl_cmd_write_reg_3 (struct udl_cmd_buf *, uint8_t, uint32_t) |
static int | udl_power_save (struct udl_softc *, int, int) |
DRIVER_MODULE (udl, uhub, udl_driver, udl_devclass, NULL, NULL) | |
MODULE_DEPEND (udl, usb, 1, 1, 1) | |
MODULE_DEPEND (udl, fbd, 1, 1, 1) | |
MODULE_DEPEND (udl, videomode, 1, 1, 1) | |
MODULE_VERSION (udl, 1) | |
static void | udl_buffer_init (void *arg) |
SYSINIT (udl_buffer_init, SI_SUB_LOCK, SI_ORDER_FIRST, udl_buffer_init, NULL) | |
CTASSERT (sizeof(struct udl_buffer)< PAGE_SIZE) | |
static void * | udl_buffer_alloc (uint32_t size) |
static void | udl_buffer_free (void *_buf, uint32_t size) |
static uint32_t | udl_get_fb_size (struct udl_softc *sc) |
static uint32_t | udl_get_fb_width (struct udl_softc *sc) |
static uint32_t | udl_get_fb_height (struct udl_softc *sc) |
static uint32_t | udl_get_fb_hz (struct udl_softc *sc) |
static void | udl_callout (void *arg) |
static int | udl_probe (device_t dev) |
static int | udl_attach (device_t dev) |
static int | udl_detach (device_t dev) |
static struct fb_info * | udl_fb_getinfo (device_t dev) |
static int | udl_fb_setblankmode (void *arg, int mode) |
static struct udl_cmd_buf * | udl_cmd_buf_alloc_locked (struct udl_softc *sc, int flags) |
static struct udl_cmd_buf * | udl_cmd_buf_alloc (struct udl_softc *sc, int flags) |
static void | udl_cmd_buf_send (struct udl_softc *sc, struct udl_cmd_buf *cb) |
static struct udl_cmd_buf * | udl_fb_synchronize_locked (struct udl_softc *sc) |
static void | udl_bulk_write_callback (struct usb_xfer *xfer, usb_error_t error) |
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) |
static int | udl_poll (struct udl_softc *sc, uint32_t *buf) |
static int | udl_read_1 (struct udl_softc *sc, uint16_t addr, uint8_t *buf) |
static int | udl_write_1 (struct udl_softc *sc, uint16_t addr, uint8_t buf) |
static int | udl_read_edid (struct udl_softc *sc, uint8_t *buf) |
static uint8_t | udl_lookup_mode (uint16_t hdisplay, uint16_t vdisplay, uint8_t hz, uint16_t chip, uint32_t clock) |
static int | udl_set_enc_key (struct udl_softc *sc, uint8_t *buf, uint8_t len) |
static void | udl_init_fb_offsets (struct udl_cmd_buf *cb, uint32_t start16, uint32_t stride16, uint32_t start8, uint32_t stride8) |
Variables | |
static int | udl_fps = 25 |
static struct mtx | udl_buffer_mtx |
static struct udl_buffer_head | udl_buffer_head |
static usb_callback_t | udl_bulk_write_callback |
static device_probe_t | udl_probe |
static device_attach_t | udl_attach |
static device_detach_t | udl_detach |
static fb_getinfo_t | udl_fb_getinfo |
static fb_setblankmode_t | udl_fb_setblankmode |
static const struct usb_config | udl_config [UDL_N_TRANSFER] |
static devclass_t | udl_devclass |
static device_method_t | udl_methods [] |
static driver_t | udl_driver |
static const STRUCT_USB_HOST_ID | udl_devs [] |
CTASSERT | ( | ) |
DRIVER_MODULE | ( | udl | , |
uhub | , | ||
udl_driver | , | ||
udl_devclass | , | ||
NULL | , | ||
NULL | |||
) |
MALLOC_DEFINE | ( | M_USB_DL | , |
"USB" | , | ||
"USB DisplayLink" | |||
) |
MODULE_DEPEND | ( | udl | , |
fbd | , | ||
1 | , | ||
1 | , | ||
1 | |||
) |
MODULE_DEPEND | ( | udl | , |
usb | , | ||
1 | , | ||
1 | , | ||
1 | |||
) |
MODULE_DEPEND | ( | udl | , |
videomode | , | ||
1 | , | ||
1 | , | ||
1 | |||
) |
MODULE_VERSION | ( | udl | , |
1 | |||
) |
SYSCTL_INT | ( | _hw_usb_udl | , |
OID_AUTO | , | ||
fps | , | ||
CTLFLAG_RWTUN | , | ||
& | udl_fps, | ||
0 | , | ||
"Frames Per | Second, | ||
1-60" | |||
) |
|
static |
SYSINIT | ( | udl_buffer_init | , |
SI_SUB_LOCK | , | ||
SI_ORDER_FIRST | , | ||
udl_buffer_init | , | ||
NULL | |||
) |
|
static |
Definition at line 315 of file udl.c.
References usbd_lookup_info::bIfaceIndex, dev, usb_attach_arg::device, device_set_usb_desc(), DLMAX, DLUNK, DPRINTF, error, usb_attach_arg::info, udl_softc::sc_callout, udl_softc::sc_chip, udl_softc::sc_cmd_buf_free, udl_softc::sc_cmd_buf_pending, udl_softc::sc_cmd_buf_temp, udl_softc::sc_cur_mode, udl_softc::sc_cv, udl_softc::sc_def_chip, udl_softc::sc_def_mode, udl_softc::sc_fb_addr, udl_softc::sc_fb_info, udl_softc::sc_fb_size, udl_softc::sc_fbdev, udl_softc::sc_mtx, udl_softc::sc_udev, udl_softc::sc_xfer, udl_softc::sc_xfer_head, UDL_BULK_WRITE_0, UDL_BULK_WRITE_1, udl_callout(), UDL_CMD_MAX_BUFFERS, udl_config, udl_detach, udl_fb_setblankmode, udl_fbmem_alloc(), udl_get_fb_height(), udl_get_fb_hz(), udl_get_fb_width(), udl_init_chip(), udl_init_resolution(), UDL_LOCK, UDL_MAX_MODES, udl_modes, UDL_N_TRANSFER, udl_select_chip(), udl_select_mode(), UDL_UNLOCK, USB_ERR_NORMAL_COMPLETION, USB_GET_DRIVER_INFO, usbd_errstr(), usbd_transfer_setup(), and usbd_xfer_set_priv().
|
static |
Definition at line 197 of file udl.c.
References size, udl_buffer::size, udl_buffer_head, and udl_buffer_mtx.
Referenced by udl_fbmem_alloc().
|
static |
Definition at line 220 of file udl.c.
References size, udl_buffer::size, udl_buffer_head, and udl_buffer_mtx.
Referenced by udl_detach().
|
static |
Definition at line 187 of file udl.c.
References udl_buffer_head, and udl_buffer_mtx.
|
static |
Definition at line 590 of file udl.c.
References error, udl_cmd_buf::off, udl_softc::sc_cmd_buf_free, udl_softc::sc_cmd_buf_pending, udl_softc::sc_cv, UDL_CMD_MAX_FRAMES, udl_fb_synchronize_locked(), USB_ERR_CANCELLED, USB_GET_STATE, USB_ST_SETUP, USB_ST_TRANSFERRED, usbd_transfer_submit(), usbd_xfer_get_priv(), usbd_xfer_set_frame_data(), usbd_xfer_set_frames(), usbd_xfer_set_stall(), and usbd_xfer_softc().
|
static |
Definition at line 274 of file udl.c.
References udl_softc::sc_callout, udl_softc::sc_power_save, udl_softc::sc_sync_off, udl_softc::sc_xfer, UDL_BULK_WRITE_0, UDL_BULK_WRITE_1, udl_callout(), udl_fps, UDL_FPS_MAX, UDL_FPS_MIN, udl_get_fb_size(), and usbd_transfer_start().
Referenced by udl_attach(), and udl_callout().
|
static |
Definition at line 523 of file udl.c.
References udl_cmd_buf_alloc_locked(), UDL_LOCK, and UDL_UNLOCK.
Referenced by udl_cmd_buf_copy_le16(), udl_cmd_write_buf_le16(), udl_init_resolution(), and udl_power_save().
|
static |
Definition at line 506 of file udl.c.
References udl_cmd_buf::off, udl_softc::sc_cmd_buf_free, udl_softc::sc_cv, and udl_softc::sc_mtx.
Referenced by udl_cmd_buf_alloc(), and udl_fb_synchronize_locked().
|
static |
Definition at line 1136 of file udl.c.
References UDL_BULK_CMD_FB_COPY, UDL_BULK_CMD_FB_WORD, UDL_BULK_SOC, udl_cmd_buf_alloc(), udl_cmd_buf_send(), udl_cmd_insert_int_1(), and udl_cmd_insert_int_3().
Referenced by udl_init_resolution().
|
static |
Definition at line 534 of file udl.c.
References udl_softc::sc_cmd_buf_free, udl_softc::sc_cmd_buf_pending, udl_softc::sc_gone, udl_softc::sc_xfer, UDL_BULK_CMD_EOC, UDL_BULK_SOC, UDL_BULK_WRITE_0, UDL_BULK_WRITE_1, udl_cmd_insert_int_1(), UDL_LOCK, UDL_UNLOCK, and usbd_transfer_start().
Referenced by udl_cmd_buf_copy_le16(), udl_cmd_write_buf_le16(), udl_init_resolution(), and udl_power_save().
|
static |
Definition at line 904 of file udl.c.
References len, and udl_cmd_buf::off.
Referenced by udl_cmd_write_buf_le16(), and udl_fb_synchronize_locked().
|
static |
Definition at line 853 of file udl.c.
References udl_cmd_buf::off, and value.
Referenced by udl_cmd_buf_copy_le16(), udl_cmd_buf_send(), udl_cmd_write_buf_le16(), udl_cmd_write_reg_1(), and udl_fb_synchronize_locked().
|
static |
Definition at line 875 of file udl.c.
References udl_cmd_buf::off, and value.
Referenced by udl_cmd_buf_copy_le16(), udl_cmd_write_buf_le16(), and udl_fb_synchronize_locked().
|
static |
Definition at line 1116 of file udl.c.
References udl_cmd_buf::off, UDL_BULK_CMD_FB_WORD, UDL_BULK_CMD_FB_WRITE, UDL_BULK_SOC, udl_cmd_buf_alloc(), udl_cmd_buf_send(), udl_cmd_insert_buf_le16(), udl_cmd_insert_int_1(), and udl_cmd_insert_int_3().
Referenced by udl_init_resolution().
|
static |
Definition at line 917 of file udl.c.
References reg, UDL_BULK_CMD_REG_WRITE_1, UDL_BULK_SOC, udl_cmd_insert_int_1(), and val.
Referenced by udl_cmd_write_reg_3(), udl_init_fb_offsets(), udl_init_resolution(), and udl_power_save().
|
static |
Definition at line 927 of file udl.c.
References reg, udl_cmd_write_reg_1(), and val.
Referenced by udl_init_fb_offsets().
|
static |
Definition at line 657 of file udl.c.
References DPRINTF, error, index, len, r, req, udl_softc::sc_udev, USB_DEFAULT_TIMEOUT, usbd_do_request_flags(), usbd_errstr(), USETW, and value.
Referenced by udl_poll(), udl_read_1(), udl_read_edid(), udl_set_enc_key(), and udl_write_1().
|
static |
Definition at line 444 of file udl.c.
References dev, udl_softc::sc_callout, udl_softc::sc_cv, udl_softc::sc_fb_addr, udl_softc::sc_fb_copy, udl_softc::sc_fb_size, udl_softc::sc_gone, udl_softc::sc_mtx, udl_softc::sc_xfer, udl_buffer_free(), UDL_LOCK, UDL_N_TRANSFER, UDL_UNLOCK, and usbd_transfer_unsetup().
|
static |
Definition at line 473 of file udl.c.
References dev, and udl_softc::sc_fb_info.
|
static |
Definition at line 481 of file udl.c.
References udl_softc::sc_fb_addr, udl_get_fb_size(), and udl_power_save().
|
static |
Definition at line 552 of file udl.c.
References udl_softc::sc_fb_addr, udl_softc::sc_fb_copy, udl_softc::sc_sync_off, UDL_BULK_CMD_FB_WORD, UDL_BULK_CMD_FB_WRITE, UDL_BULK_SOC, udl_cmd_buf_alloc_locked(), udl_cmd_insert_buf_le16(), udl_cmd_insert_int_1(), udl_cmd_insert_int_3(), UDL_CMD_MAX_PIXEL_COUNT, and udl_get_fb_size().
Referenced by udl_bulk_write_callback().
|
static |
Definition at line 834 of file udl.c.
References udl_softc::sc_fb_addr, udl_softc::sc_fb_copy, udl_softc::sc_fb_size, size, udl_buffer_alloc(), and udl_get_fb_size().
Referenced by udl_attach().
|
static |
Definition at line 258 of file udl.c.
References udl_softc::sc_cur_mode, and udl_modes.
Referenced by udl_attach().
|
static |
Definition at line 266 of file udl.c.
References udl_softc::sc_cur_mode, and udl_modes.
Referenced by udl_attach().
|
static |
Definition at line 241 of file udl.c.
References udl_softc::sc_cur_mode, and udl_modes.
Referenced by udl_callout(), udl_fb_setblankmode(), udl_fb_synchronize_locked(), udl_fbmem_alloc(), and udl_init_resolution().
|
static |
Definition at line 250 of file udl.c.
References udl_softc::sc_cur_mode, and udl_modes.
Referenced by udl_attach().
|
static |
Definition at line 936 of file udl.c.
References DL120, DL125, DL160, DL165, DPRINTF, error, udl_softc::sc_chip, udl_softc::sc_edid, udl_null_key_1, udl_poll(), udl_read_1(), udl_read_edid(), udl_set_enc_key(), udl_write_1(), and USB_ERR_NORMAL_COMPLETION.
Referenced by udl_attach().
|
static |
Definition at line 992 of file udl.c.
References udl_cmd_write_reg_1(), udl_cmd_write_reg_3(), UDL_REG_ADDR_START16, UDL_REG_ADDR_START8, UDL_REG_ADDR_STRIDE16, UDL_REG_ADDR_STRIDE8, and UDL_REG_SYNC.
Referenced by udl_init_resolution().
|
static |
Definition at line 1004 of file udl.c.
References __aligned, error, udl_mode::mode, udl_softc::sc_cur_mode, udl_cmd_buf_alloc(), udl_cmd_buf_copy_le16(), udl_cmd_buf_send(), UDL_CMD_MAX_PIXEL_COUNT, udl_cmd_write_buf_le16(), udl_cmd_write_reg_1(), udl_get_fb_size(), udl_init_fb_offsets(), UDL_MODE_SIZE, udl_modes, UDL_REG_SCREEN, UDL_REG_SCREEN_ON, and UDL_REG_SYNC.
Referenced by udl_attach().
|
static |
Definition at line 746 of file udl.c.
References UDL_MAX_MODES, and udl_modes.
Referenced by udl_select_mode().
|
static |
Definition at line 678 of file udl.c.
References error, UDL_CTRL_CMD_POLL, udl_ctrl_msg(), USB_ERR_NORMAL_COMPLETION, and UT_READ_VENDOR_DEVICE.
Referenced by udl_init_chip().
|
static |
Definition at line 633 of file udl.c.
References DPRINTF, udl_softc::sc_power_save, udl_cmd_buf_alloc(), udl_cmd_buf_send(), udl_cmd_write_reg_1(), UDL_REG_SCREEN, UDL_REG_SCREEN_OFF, UDL_REG_SCREEN_ON, and UDL_REG_SYNC.
Referenced by udl_fb_setblankmode().
|
static |
Definition at line 300 of file udl.c.
References usbd_lookup_info::bConfigIndex, usbd_lookup_info::bIfaceIndex, dev, usb_attach_arg::info, udl_devs, usb_attach_arg::usb_mode, USB_MODE_HOST, and usbd_lookup_id_by_uaa().
|
static |
Definition at line 691 of file udl.c.
References addr, error, UDL_CTRL_CMD_READ_1, udl_ctrl_msg(), USB_ERR_NORMAL_COMPLETION, and UT_READ_VENDOR_DEVICE.
Referenced by udl_init_chip().
|
static |
Definition at line 714 of file udl.c.
References error, fail, offset, UDL_CTRL_CMD_READ_EDID, udl_ctrl_msg(), USB_ERR_NORMAL_COMPLETION, and UT_READ_VENDOR_DEVICE.
Referenced by udl_init_chip().
|
static |
Definition at line 778 of file udl.c.
References usbd_lookup_info::bcdDevice, usb_attach_arg::device, DL120, DL125, DL160, DL165, DL195, DPRINTF, usbd_lookup_info::idProduct, usbd_lookup_info::idVendor, usb_attach_arg::info, udl_softc::sc_chip, and usb_get_serial().
Referenced by udl_attach().
|
static |
Definition at line 1055 of file udl.c.
References DPRINTF, index, udl_mode::mode, udl_softc::sc_chip, udl_softc::sc_cur_mode, udl_softc::sc_edid, udl_softc::sc_edid_info, udl_lookup_mode(), and UDL_MAX_MODES.
Referenced by udl_attach().
|
static |
Definition at line 824 of file udl.c.
References error, len, UDL_CTRL_CMD_SET_KEY, udl_ctrl_msg(), and UT_WRITE_VENDOR_DEVICE.
Referenced by udl_init_chip().
|
static |
Definition at line 704 of file udl.c.
References addr, error, UDL_CTRL_CMD_WRITE_1, udl_ctrl_msg(), and UT_WRITE_VENDOR_DEVICE.
Referenced by udl_init_chip().
|
static |
Definition at line 81 of file udl.c.
Referenced by udl_buffer_alloc(), udl_buffer_free(), and udl_buffer_init().
|
static |
Definition at line 80 of file udl.c.
Referenced by udl_buffer_alloc(), udl_buffer_free(), and udl_buffer_init().
|
static |
|
static |
Definition at line 110 of file udl.c.
Referenced by udl_attach().
|
static |
Definition at line 92 of file udl.c.
Referenced by udl_attach().
|
static |
|
static |
|
static |
Definition at line 94 of file udl.c.
Referenced by udl_attach().
|
static |
Definition at line 76 of file udl.c.
Referenced by udl_callout().
|
static |