FreeBSD kernel usb device Code
|
#include <sys/cdefs.h>
#include "opt_evdev.h"
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/kernel.h>
#include <sys/malloc.h>
#include <sys/module.h>
#include <sys/lock.h>
#include <sys/mutex.h>
#include <sys/bus.h>
#include <sys/conf.h>
#include <sys/fcntl.h>
#include <sys/file.h>
#include <sys/selinfo.h>
#include <sys/poll.h>
#include <sys/sysctl.h>
#include <dev/hid/hid.h>
#include <dev/usb/usb.h>
#include <dev/usb/usbdi.h>
#include <dev/usb/usbdi_util.h>
#include <dev/usb/usbhid.h>
#include "usbdevs.h"
#include <dev/usb/usb_debug.h>
#include <sys/mouse.h>
Go to the source code of this file.
Data Structures | |
struct | wsp_tuning |
struct | bt_data |
struct | wsp_tp |
struct | tp_header |
struct | tp_finger |
struct | wsp_param |
struct | wsp_dev_params |
struct | wsp_softc |
Macros | |
#define | USB_DEBUG_VAR wsp_debug |
#define | WSP_DRIVER_NAME "wsp" |
#define | WSP_BUFFER_MAX 1024 |
#define | WSP_CLAMP(x, low, high) |
#define | FINGER_TYPE1 (13 * 2) |
#define | FINGER_TYPE2 (15 * 2) |
#define | FINGER_TYPE3 (19 * 2) |
#define | FINGER_TYPE4 (23 * 2) |
#define | BUTTON_TYPE2 15 |
#define | BUTTON_TYPE3 23 |
#define | BUTTON_TYPE4 31 |
#define | HAS_INTEGRATED_BUTTON 1 |
#define | FSIZE_TYPE1 (14 * 2) |
#define | FSIZE_TYPE2 (14 * 2) |
#define | FSIZE_TYPE3 (14 * 2) |
#define | FSIZE_TYPE4 (15 * 2) |
#define | MAX_FINGERS 16 |
#define | SIZEOF_FINGER sizeof(struct tp_finger) |
#define | SIZEOF_ALL_FINGERS (MAX_FINGERS * SIZEOF_FINGER) |
#define | MAX_FINGER_ORIENTATION 16384 |
#define | SN_PRESSURE 45 /* pressure signal-to-noise ratio */ |
#define | SN_WIDTH 25 /* width signal-to-noise ratio */ |
#define | SN_COORD 250 /* coordinate signal-to-noise ratio */ |
#define | SN_ORIENT 10 /* orientation signal-to-noise ratio */ |
#define | WSP_DEV(v, p, i) { USB_VPI(USB_VENDOR_##v, USB_PRODUCT_##v##_##p, i) } |
#define | WSP_FIFO_BUF_SIZE 8 /* bytes */ |
#define | WSP_FIFO_QUEUE_MAXLEN 50 /* units */ |
#define | WSP_ENABLED 0x01 |
#define | WSP_EVDEV_OPENED 0x02 |
#define | WSP_UNTOUCH 0x00 |
#define | WSP_FIRST_TOUCH 0x01 |
#define | WSP_SECOND_TOUCH 0x02 |
#define | WSP_TOUCHING 0x04 |
#define | WSP_DZ_MAX_COUNT 32 |
#define | WSP_TAP_THRESHOLD 3 |
#define | WSP_TAP_MAX_COUNT 20 |
#define | MAX_DISTANCE 2500 /* the max allowed distance */ |
#define | WSP_SCR_NONE 0 |
#define | WSP_SCR_VER 1 |
#define | WSP_SCR_HOR 2 |
Enumerations | |
enum | tp_type { TYPE1 , TYPE2 , TYPE3 , TYPE4 , TYPE_CNT } |
enum | { WSP_FLAG_WELLSPRING1 , WSP_FLAG_WELLSPRING2 , WSP_FLAG_WELLSPRING3 , WSP_FLAG_WELLSPRING4 , WSP_FLAG_WELLSPRING4A , WSP_FLAG_WELLSPRING5 , WSP_FLAG_WELLSPRING6A , WSP_FLAG_WELLSPRING6 , WSP_FLAG_WELLSPRING5A , WSP_FLAG_WELLSPRING7 , WSP_FLAG_WELLSPRING7A , WSP_FLAG_WELLSPRING8 , WSP_FLAG_WELLSPRING9 , WSP_FLAG_MAX } |
enum | { WSP_INTR_DT , WSP_N_TRANSFER } |
Functions | |
__FBSDID ("$FreeBSD$") | |
static | SYSCTL_NODE (_hw_usb, OID_AUTO, wsp, CTLFLAG_RW|CTLFLAG_MPSAFE, 0, "USB wsp") |
static void | wsp_runing_rangecheck (struct wsp_tuning *ptun) |
SYSCTL_INT (_hw_usb_wsp, OID_AUTO, scale_factor, CTLFLAG_RWTUN, &wsp_tuning.scale_factor, 0, "movement scale factor") | |
SYSCTL_INT (_hw_usb_wsp, OID_AUTO, z_factor, CTLFLAG_RWTUN, &wsp_tuning.z_factor, 0, "Z-axis scale factor") | |
SYSCTL_INT (_hw_usb_wsp, OID_AUTO, z_invert, CTLFLAG_RWTUN, &wsp_tuning.z_invert, 0, "enable Z-axis inversion") | |
SYSCTL_INT (_hw_usb_wsp, OID_AUTO, pressure_touch_threshold, CTLFLAG_RWTUN, &wsp_tuning.pressure_touch_threshold, 0, "touch pressure threshold") | |
SYSCTL_INT (_hw_usb_wsp, OID_AUTO, pressure_untouch_threshold, CTLFLAG_RWTUN, &wsp_tuning.pressure_untouch_threshold, 0, "untouch pressure threshold") | |
SYSCTL_INT (_hw_usb_wsp, OID_AUTO, pressure_tap_threshold, CTLFLAG_RWTUN, &wsp_tuning.pressure_tap_threshold, 0, "tap pressure threshold") | |
SYSCTL_INT (_hw_usb_wsp, OID_AUTO, scr_hor_threshold, CTLFLAG_RWTUN, &wsp_tuning.scr_hor_threshold, 0, "horizontal scrolling threshold") | |
SYSCTL_INT (_hw_usb_wsp, OID_AUTO, enable_single_tap_clicks, CTLFLAG_RWTUN, &wsp_tuning.enable_single_tap_clicks, 0, "enable single tap clicks") | |
static int | wsp_enable (struct wsp_softc *sc) |
static void | wsp_disable (struct wsp_softc *sc) |
static void | wsp_reset_buf (struct wsp_softc *sc) |
static void | wsp_add_to_queue (struct wsp_softc *, int, int, int, uint32_t) |
static usb_error_t | wsp_set_device_mode (struct wsp_softc *sc, uint8_t on) |
static int | wsp_probe (device_t self) |
static int | wsp_attach (device_t dev) |
static int | wsp_detach (device_t dev) |
static void | wsp_intr_callback (struct usb_xfer *xfer, usb_error_t error) |
static void | wsp_start_read (struct wsp_softc *sc) |
static void | wsp_stop_read (struct wsp_softc *sc) |
static int | wsp_open (struct usb_fifo *fifo, int fflags) |
static void | wsp_close (struct usb_fifo *fifo, int fflags) |
static void | wsp_fifo_start_read (struct usb_fifo *fifo) |
static void | wsp_fifo_stop_read (struct usb_fifo *fifo) |
int | wsp_ioctl (struct usb_fifo *fifo, u_long cmd, void *addr, int fflags) |
DRIVER_MODULE (wsp, uhub, wsp_driver, wsp_devclass, NULL, 0) | |
MODULE_DEPEND (wsp, usb, 1, 1, 1) | |
MODULE_DEPEND (wsp, hid, 1, 1, 1) | |
MODULE_VERSION (wsp, 1) | |
USB_PNP_HOST_INFO (wsp_devs) | |
Variables | |
static struct wsp_tuning | wsp_tuning |
struct bt_data | __packed |
struct wsp_tp | wsp_tp [TYPE_CNT] |
static const struct wsp_dev_params | wsp_dev_params [WSP_FLAG_MAX] |
static const STRUCT_USB_HOST_ID | wsp_devs [] |
static usb_fifo_cmd_t | wsp_fifo_start_read |
static usb_fifo_cmd_t | wsp_fifo_stop_read |
static usb_fifo_open_t | wsp_open |
static usb_fifo_close_t | wsp_close |
static usb_fifo_ioctl_t | wsp_ioctl |
static struct usb_fifo_methods | wsp_fifo_methods |
static device_probe_t | wsp_probe |
static device_attach_t | wsp_attach |
static device_detach_t | wsp_detach |
static usb_callback_t | wsp_intr_callback |
static const struct usb_config | wsp_config [WSP_N_TRANSFER] |
static device_method_t | wsp_methods [] |
static driver_t | wsp_driver |
static devclass_t | wsp_devclass |
#define SIZEOF_ALL_FINGERS (MAX_FINGERS * SIZEOF_FINGER) |
#define WSP_CLAMP | ( | x, | |
low, | |||
high | |||
) |
#define WSP_DEV | ( | v, | |
p, | |||
i | |||
) | { USB_VPI(USB_VENDOR_##v, USB_PRODUCT_##v##_##p, i) } |
anonymous enum |
__FBSDID | ( | "$FreeBSD$" | ) |
DRIVER_MODULE | ( | wsp | , |
uhub | , | ||
wsp_driver | , | ||
wsp_devclass | , | ||
NULL | , | ||
0 | |||
) |
MODULE_DEPEND | ( | wsp | , |
hid | , | ||
1 | , | ||
1 | , | ||
1 | |||
) |
MODULE_DEPEND | ( | wsp | , |
usb | , | ||
1 | , | ||
1 | , | ||
1 | |||
) |
MODULE_VERSION | ( | wsp | , |
1 | |||
) |
SYSCTL_INT | ( | _hw_usb_wsp | , |
OID_AUTO | , | ||
enable_single_tap_clicks | , | ||
CTLFLAG_RWTUN | , | ||
&wsp_tuning. | enable_single_tap_clicks, | ||
0 | , | ||
"enable single tap clicks" | |||
) |
SYSCTL_INT | ( | _hw_usb_wsp | , |
OID_AUTO | , | ||
pressure_tap_threshold | , | ||
CTLFLAG_RWTUN | , | ||
&wsp_tuning. | pressure_tap_threshold, | ||
0 | , | ||
"tap pressure threshold" | |||
) |
SYSCTL_INT | ( | _hw_usb_wsp | , |
OID_AUTO | , | ||
pressure_touch_threshold | , | ||
CTLFLAG_RWTUN | , | ||
&wsp_tuning. | pressure_touch_threshold, | ||
0 | , | ||
"touch pressure threshold" | |||
) |
SYSCTL_INT | ( | _hw_usb_wsp | , |
OID_AUTO | , | ||
pressure_untouch_threshold | , | ||
CTLFLAG_RWTUN | , | ||
&wsp_tuning. | pressure_untouch_threshold, | ||
0 | , | ||
"untouch pressure threshold" | |||
) |
SYSCTL_INT | ( | _hw_usb_wsp | , |
OID_AUTO | , | ||
scale_factor | , | ||
CTLFLAG_RWTUN | , | ||
&wsp_tuning. | scale_factor, | ||
0 | , | ||
"movement scale factor" | |||
) |
SYSCTL_INT | ( | _hw_usb_wsp | , |
OID_AUTO | , | ||
scr_hor_threshold | , | ||
CTLFLAG_RWTUN | , | ||
&wsp_tuning. | scr_hor_threshold, | ||
0 | , | ||
"horizontal scrolling threshold" | |||
) |
SYSCTL_INT | ( | _hw_usb_wsp | , |
OID_AUTO | , | ||
z_factor | , | ||
CTLFLAG_RWTUN | , | ||
&wsp_tuning. | z_factor, | ||
0 | , | ||
"Z-axis scale factor" | |||
) |
SYSCTL_INT | ( | _hw_usb_wsp | , |
OID_AUTO | , | ||
z_invert | , | ||
CTLFLAG_RWTUN | , | ||
&wsp_tuning. | z_invert, | ||
0 | , | ||
"enable Z-axis inversion" | |||
) |
|
static |
USB_PNP_HOST_INFO | ( | wsp_devs | ) |
|
static |
Definition at line 1295 of file wsp.c.
References usb_fifo_sc::fp, wsp_softc::sc_fifo, wsp_softc::sc_mode, usb_fifo_put_data_linear(), and USB_FIFO_RX.
Referenced by wsp_intr_callback().
|
static |
Definition at line 748 of file wsp.c.
References usbd_lookup_info::bIfaceIndex, wsp_tp::caps, dev, usb_attach_arg::device, device_set_usb_desc(), DPRINTF, HAS_INTEGRATED_BUTTON, usbd_lookup_info::idProduct, usbd_lookup_info::idVendor, usb_attach_arg::info, MAX_FINGERS, wsp_dev_params::o, wsp_dev_params::p, wsp_softc::sc_fifo, wsp_softc::sc_hw, wsp_softc::sc_mode, wsp_softc::sc_mutex, wsp_softc::sc_params, wsp_softc::sc_touch, wsp_softc::sc_usb_device, wsp_softc::sc_xfer, wsp_softc::scr_mode, wsp_dev_params::tp, wsp_softc::tp_datalen, USB_ERR_NORMAL_COMPLETION, usb_fifo_attach(), USB_GET_DRIVER_INFO, usb_get_serial(), usbd_errstr(), usbd_req_get_hid_desc(), usbd_transfer_setup(), wsp_dev_params::w, WSP_BUFFER_MAX, wsp_config, wsp_detach, wsp_fifo_methods, WSP_N_TRANSFER, WSP_SCR_NONE, wsp_set_device_mode(), WSP_UNTOUCH, wsp_dev_params::x, and wsp_dev_params::y.
|
static |
Definition at line 1398 of file wsp.c.
References wsp_softc::sc_fflags, wsp_softc::sc_state, usb_fifo_free_buffer(), usb_fifo_softc(), wsp_disable(), and WSP_EVDEV_OPENED.
|
static |
Definition at line 898 of file wsp.c.
References dev, wsp_softc::sc_fifo, wsp_softc::sc_mutex, wsp_softc::sc_state, wsp_softc::sc_xfer, usb_fifo_detach(), usbd_transfer_unsetup(), wsp_disable(), WSP_ENABLED, WSP_N_TRANSFER, and wsp_set_device_mode().
|
static |
Definition at line 708 of file wsp.c.
References wsp_softc::sc_state.
Referenced by wsp_close(), and wsp_detach().
|
static |
Definition at line 697 of file wsp.c.
References wsp_softc::sc_state, wsp_softc::sc_status, and WSP_ENABLED.
Referenced by wsp_open().
|
static |
Definition at line 1414 of file wsp.c.
References usb_fifo_softc(), and wsp_start_read().
|
static |
Definition at line 1422 of file wsp.c.
References wsp_softc::sc_state, usb_fifo_softc(), WSP_EVDEV_OPENED, and wsp_stop_read().
|
static |
Definition at line 923 of file wsp.c.
References tp_finger::abs_x, tp_finger::abs_y, wsp_tp::button, wsp_tp::caps, wsp_tp::delta, wsp_softc::distance, wsp_softc::dt_sum, wsp_softc::dx_sum, wsp_softc::dy_sum, wsp_softc::dz_count, wsp_softc::dz_sum, wsp_tuning::enable_single_tap_clicks, error, wsp_softc::finger, usb_fifo_sc::fp, wsp_tp::fsize, HAS_INTEGRATED_BUTTON, tp_header::ibt, wsp_softc::ibtn, wsp_softc::index, wsp_softc::intr_count, len, wsp_param::max, MAX_DISTANCE, MAX_FINGERS, wsp_param::min, tp_finger::multi, wsp_softc::ntaps, wsp_dev_params::o, wsp_softc::o_ntouch, wsp_tp::offset, tp_finger::orientation, tp_finger::origin, wsp_softc::pos_x, wsp_softc::pos_y, wsp_softc::pre_pos_x, wsp_softc::pre_pos_y, tp_finger::pressure, wsp_tuning::pressure_tap_threshold, wsp_tuning::pressure_touch_threshold, wsp_tuning::pressure_untouch_threshold, wsp_softc::rdx, wsp_softc::rdy, wsp_softc::rdz, tp_finger::rel_x, tp_finger::rel_y, wsp_softc::sc_fifo, wsp_softc::sc_params, wsp_softc::sc_status, wsp_softc::sc_touch, wsp_tuning::scale_factor, wsp_tuning::scr_hor_threshold, wsp_softc::scr_mode, slot, tp_finger::tool_major, tp_finger::tool_minor, tp_finger::touch_major, tp_finger::touch_minor, wsp_dev_params::tp, wsp_softc::tp_datalen, TYPE1, USB_ERR_CANCELLED, usb_fifo_put_bytes_max(), USB_FIFO_RX, USB_GET_STATE, USB_ST_SETUP, USB_ST_TRANSFERRED, usbd_copy_out(), usbd_transfer_submit(), usbd_xfer_get_frame(), usbd_xfer_set_frame_len(), usbd_xfer_set_stall(), usbd_xfer_softc(), usbd_xfer_status(), wsp_add_to_queue(), WSP_DZ_MAX_COUNT, WSP_FIRST_TOUCH, wsp_runing_rangecheck(), WSP_SCR_HOR, WSP_SCR_NONE, WSP_SCR_VER, WSP_SECOND_TOUCH, WSP_TAP_MAX_COUNT, WSP_TAP_THRESHOLD, WSP_TOUCHING, wsp_tuning, WSP_UNTOUCH, wsp_dev_params::y, wsp_tuning::z_factor, and wsp_tuning::z_invert.
int wsp_ioctl | ( | struct usb_fifo * | fifo, |
u_long | cmd, | ||
void * | addr, | ||
int | fflags | ||
) |
Definition at line 1467 of file wsp.c.
References addr, error, wsp_softc::sc_hw, wsp_softc::sc_mode, wsp_softc::sc_mutex, wsp_softc::sc_pollrate, wsp_softc::sc_status, status, usb_fifo_softc(), and wsp_reset_buf().
|
static |
Definition at line 1369 of file wsp.c.
References wsp_softc::sc_fflags, wsp_softc::sc_state, usb_fifo_alloc_buffer(), usb_fifo_free_buffer(), usb_fifo_softc(), wsp_enable(), WSP_EVDEV_OPENED, WSP_FIFO_BUF_SIZE, and WSP_FIFO_QUEUE_MAXLEN.
|
static |
Definition at line 715 of file wsp.c.
References usbd_lookup_info::bIfaceIndex, usb_attach_arg::device, id, usb_interface::idesc, usb_attach_arg::info, UICLASS_HID, UIPROTO_MOUSE, usb_attach_arg::usb_mode, USB_MODE_HOST, usbd_get_iface(), usbd_lookup_id_by_uaa(), and wsp_devs.
|
static |
Definition at line 1334 of file wsp.c.
References usb_fifo_sc::fp, wsp_softc::sc_fifo, usb_fifo_reset(), and USB_FIFO_RX.
Referenced by wsp_ioctl().
|
static |
Definition at line 118 of file wsp.c.
References wsp_tuning::enable_single_tap_clicks, wsp_tuning::pressure_tap_threshold, wsp_tuning::pressure_touch_threshold, wsp_tuning::pressure_untouch_threshold, wsp_tuning::scale_factor, wsp_tuning::scr_hor_threshold, WSP_CLAMP, wsp_tuning::z_factor, and wsp_tuning::z_invert.
Referenced by wsp_intr_callback().
|
static |
Definition at line 661 of file wsp.c.
References DPRINTF, wsp_tp::iface_index, wsp_softc::sc_params, wsp_softc::sc_usb_device, wsp_dev_params::tp, TYPE3, UHID_FEATURE_REPORT, wsp_tp::um_req_idx, wsp_tp::um_size, wsp_tp::um_switch_idx, wsp_tp::um_switch_off, wsp_tp::um_switch_on, USB_ERR_NORMAL_COMPLETION, usbd_req_get_report(), and usbd_req_set_report().
Referenced by wsp_attach(), and wsp_detach().
|
static |
Definition at line 1341 of file wsp.c.
References wsp_softc::sc_pollrate, wsp_softc::sc_xfer, usbd_transfer_start(), usbd_transfer_stop(), usbd_xfer_set_interval(), and WSP_INTR_DT.
Referenced by wsp_fifo_start_read().
|
static |
Definition at line 1363 of file wsp.c.
References wsp_softc::sc_xfer, usbd_transfer_stop(), and WSP_INTR_DT.
Referenced by wsp_fifo_stop_read().
|
static |
|
static |
Definition at line 646 of file wsp.c.
Referenced by wsp_attach().
|
static |
Definition at line 643 of file wsp.c.
Referenced by wsp_attach().
|
static |
|
static |
Definition at line 473 of file wsp.c.
Referenced by wsp_probe().
|
static |
|
static |
Definition at line 614 of file wsp.c.
Referenced by wsp_attach().
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
Referenced by wsp_intr_callback().