39#include <sys/callout.h>
41#include <sys/kernel.h>
43#include <sys/module.h>
45#include <sys/sysctl.h>
55#include <dev/evdev/input.h>
56#include <dev/evdev/evdev.h>
58#include <sys/ioccom.h>
62#define USB_DEBUG_VAR uep_debug
66static int uep_debug = 0;
68static SYSCTL_NODE(_hw_usb, OID_AUTO, uep, CTLFLAG_RW | CTLFLAG_MPSAFE, 0,
71 &uep_debug, 0,
"Debug level");
78#define UEP_PACKET_LEN_MAX 16
79#define UEP_PACKET_LEN_REPORT 5
80#define UEP_PACKET_LEN_REPORT2 6
81#define UEP_PACKET_DIAG 0x0a
82#define UEP_PACKET_REPORT_MASK 0xe0
83#define UEP_PACKET_REPORT 0x80
84#define UEP_PACKET_REPORT_PRESSURE 0xc0
85#define UEP_PACKET_REPORT_PLAYER 0xa0
86#define UEP_PACKET_LEN_MASK
88#define UEP_FIFO_BUF_SIZE 8
89#define UEP_FIFO_QUEUE_MAXLEN 50
101 struct evdev_dev *evdev;
107#define UEP_ENABLED 0x01
123static evdev_open_t uep_ev_open;
124static evdev_close_t uep_ev_close;
126static const struct evdev_methods uep_evdev_methods = {
127 .ev_open = &uep_ev_open,
128 .ev_close = &uep_ev_close,
145 .basename[0] =
"uep",
185 if ((buf[0] & 0xFE) != 0x80) {
186 DPRINTF(
"bad input packet format 0x%.2x\n", buf[0]);
211 x = (buf[1] << 7) | buf[2];
212 y = (buf[3] << 7) | buf[4];
214 DPRINTFN(2,
"x %u y %u\n", x, y);
217 touch = buf[0] & (1 << 0);
219 evdev_push_abs(sc->evdev, ABS_X, x);
220 evdev_push_abs(sc->evdev, ABS_Y, y);
222 evdev_push_key(sc->evdev, BTN_TOUCH, touch);
223 evdev_sync(sc->evdev);
244 if (
len > (
int)
sizeof(buf)) {
288 if (pkt_len <=
len) {
325 .flags = {.pipe_bof = 1,.short_xfer_ok = 1,},
332 {
USB_VPI(USB_VENDOR_EGALAX, USB_PRODUCT_EGALAX_TPANEL, 0)},
333 {
USB_VPI(USB_VENDOR_EGALAX, USB_PRODUCT_EGALAX_TPANEL2, 0)},
334 {
USB_VPI(USB_VENDOR_EGALAX2, USB_PRODUCT_EGALAX2_TPANEL, 0)},
361 mtx_init(&sc->
mtx,
"uep lock", NULL, MTX_DEF);
372 sc->evdev = evdev_alloc();
373 evdev_set_name(sc->evdev, device_get_desc(
dev));
374 evdev_set_phys(sc->evdev, device_get_nameunit(
dev));
378 evdev_set_methods(sc->evdev, sc, &uep_evdev_methods);
379 evdev_support_prop(sc->evdev, INPUT_PROP_DIRECT);
380 evdev_support_event(sc->evdev, EV_SYN);
381 evdev_support_event(sc->evdev, EV_ABS);
382 evdev_support_event(sc->evdev, EV_KEY);
383 evdev_support_key(sc->evdev, BTN_TOUCH);
384 evdev_support_abs(sc->evdev, ABS_X, 0,
UEP_MAX_X, 0, 0, 0);
385 evdev_support_abs(sc->evdev, ABS_Y, 0,
UEP_MAX_Y, 0, 0, 0);
387 error = evdev_register_mtx(sc->evdev, &sc->
mtx);
395 UID_ROOT, GID_OPERATOR, 0644);
419 evdev_free(sc->evdev);
426 mtx_destroy(&sc->
mtx);
434uep_ev_close(
struct evdev_dev *evdev)
436 struct uep_softc *sc = evdev_get_softc(evdev);
438 mtx_assert(&sc->
mtx, MA_OWNED);
445uep_ev_open(
struct evdev_dev *evdev)
447 struct uep_softc *sc = evdev_get_softc(evdev);
449 mtx_assert(&sc->
mtx, MA_OWNED);
493 if (fflags & FREAD) {
511 if (fflags & FREAD) {
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+")
u_char buf[UEP_PACKET_LEN_MAX]
struct usb_xfer * xfer[UEP_N_TRANSFER]
enum usb_hc_mode usb_mode
struct usbd_lookup_info info
struct usb_device * device
#define UEP_PACKET_REPORT_MASK
#define UEP_FIFO_QUEUE_MAXLEN
static usb_callback_t uep_intr_callback
static usb_fifo_close_t uep_close
static device_method_t uep_methods[]
#define UEP_PACKET_REPORT
#define UEP_PACKET_LEN_REPORT
static void uep_process_pkt(struct uep_softc *sc, u_char *buf)
DRIVER_MODULE(uep, uhub, uep_driver, uep_devclass, NULL, NULL)
static device_probe_t uep_probe
static int get_pkt_len(u_char *buf)
USB_PNP_HOST_INFO(uep_devs)
static usb_fifo_cmd_t uep_start_read
#define UEP_PACKET_LEN_MAX
static struct usb_fifo_methods uep_fifo_methods
MODULE_DEPEND(uep, usb, 1, 1, 1)
static usb_fifo_cmd_t uep_stop_read
static device_detach_t uep_detach
static usb_fifo_open_t uep_open
#define UEP_PACKET_LEN_REPORT2
#define UEP_FIFO_BUF_SIZE
static devclass_t uep_devclass
static const struct usb_config uep_config[UEP_N_TRANSFER]
static driver_t uep_driver
#define UEP_PACKET_REPORT_PRESSURE
static const STRUCT_USB_HOST_ID uep_devs[]
static void uep_put_queue(struct uep_softc *, u_char *)
static device_attach_t uep_attach
#define UEP_PACKET_REPORT_PLAYER
void usbd_copy_out(struct usb_page_cache *cache, usb_frlength_t offset, void *ptr, usb_frlength_t len)
const char * usb_get_serial(struct usb_device *udev)
const char * usbd_errstr(usb_error_t err)
int usbd_lookup_id_by_uaa(const struct usb_device_id *id, usb_size_t sizeof_id, struct usb_attach_arg *uaa)
void usbd_transfer_submit(struct usb_xfer *xfer)
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)
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)
int usb_fifo_alloc_buffer(struct usb_fifo *f, uint32_t bufsize, uint16_t nbuf)
void * usb_fifo_softc(struct usb_fifo *fifo)
void() usb_fifo_close_t(struct usb_fifo *fifo, int fflags)
void usb_fifo_detach(struct usb_fifo_sc *f_sc)
void usb_fifo_put_data_linear(struct usb_fifo *fifo, void *ptr, usb_size_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)
void() usb_fifo_cmd_t(struct usb_fifo *fifo)
void usb_fifo_free_buffer(struct usb_fifo *f)
#define USB_ST_TRANSFERRED
void() usb_callback_t(struct usb_xfer *, usb_error_t)
int() usb_fifo_open_t(struct usb_fifo *fifo, int fflags)
#define USB_VPI(vend, prod, info)
#define STRUCT_USB_HOST_ID
#define USB_GET_STATE(xfer)
uint32_t usb_fifo_put_bytes_max(struct usb_fifo *fifo)