FreeBSD kernel usb device Code
usb_hid.c File Reference
#include <sys/stdint.h>
#include <sys/stddef.h>
#include <sys/param.h>
#include <sys/queue.h>
#include <sys/types.h>
#include <sys/systm.h>
#include <sys/kernel.h>
#include <sys/bus.h>
#include <sys/module.h>
#include <sys/lock.h>
#include <sys/mutex.h>
#include <sys/condvar.h>
#include <sys/sysctl.h>
#include <sys/sx.h>
#include <sys/unistd.h>
#include <sys/callout.h>
#include <sys/malloc.h>
#include <sys/priv.h>
#include <dev/usb/usb.h>
#include <dev/usb/usbdi.h>
#include <dev/usb/usbdi_util.h>
#include <dev/usb/usbhid.h>
#include <dev/usb/usb_core.h>
#include <dev/usb/usb_debug.h>
#include <dev/usb/usb_process.h>
#include <dev/usb/usb_device.h>
#include <dev/usb/usb_request.h>
Include dependency graph for usb_hid.c:

Go to the source code of this file.

Data Structures

struct  hid_pos_data
 
struct  hid_data
 

Macros

#define USB_DEBUG_VAR   usb_debug
 
#define MAXUSAGE   64
 
#define MAXPUSH   4
 
#define MAXID   16
 

Functions

static void hid_clear_local (struct hid_item *)
 
static uint8_t hid_get_byte (struct hid_data *s, const uint16_t wSize)
 
static void hid_switch_rid (struct hid_data *s, struct hid_item *c, int32_t next_rID)
 
struct hid_datahid_start_parse (const void *d, usb_size_t len, int kindset)
 
void hid_end_parse (struct hid_data *s)
 
int hid_get_item (struct hid_data *s, struct hid_item *h)
 
int hid_report_size (const void *buf, usb_size_t len, enum hid_kind k, uint8_t *id)
 
int hid_locate (const void *desc, usb_size_t size, int32_t u, enum hid_kind k, uint8_t index, struct hid_location *loc, uint32_t *flags, uint8_t *id)
 
static uint32_t hid_get_data_sub (const uint8_t *buf, usb_size_t len, struct hid_location *loc, int is_signed)
 
int32_t hid_get_data (const uint8_t *buf, usb_size_t len, struct hid_location *loc)
 
uint32_t hid_get_data_unsigned (const uint8_t *buf, usb_size_t len, struct hid_location *loc)
 
void hid_put_data_unsigned (uint8_t *buf, usb_size_t len, struct hid_location *loc, unsigned int value)
 
int hid_is_collection (const void *desc, usb_size_t size, int32_t usage)
 
struct usb_hid_descriptorhid_get_descriptor_from_usb (struct usb_config_descriptor *cd, struct usb_interface_descriptor *id)
 
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)
 
int hid_is_mouse (const void *d_ptr, uint16_t d_len)
 
int hid_is_keyboard (const void *d_ptr, uint16_t d_len)
 

Macro Definition Documentation

#define MAXID   16

Definition at line 74 of file usb_hid.c.

Referenced by hid_switch_rid().

#define MAXPUSH   4

Definition at line 73 of file usb_hid.c.

Referenced by hid_get_item().

#define MAXUSAGE   64

Definition at line 72 of file usb_hid.c.

Referenced by hid_get_item().

#define USB_DEBUG_VAR   usb_debug

Definition at line 60 of file usb_hid.c.

Function Documentation

void hid_end_parse ( struct hid_data s)

Definition at line 200 of file usb_hid.c.

Referenced by hid_is_collection(), hid_is_mouse(), hid_locate(), and hid_report_size().

Here is the caller graph for this function:

static uint8_t hid_get_byte ( struct hid_data s,
const uint16_t  wSize 
)
static

Definition at line 212 of file usb_hid.c.

References hid_data::end, and hid_data::p.

Referenced by hid_get_item().

Here is the caller graph for this function:

int32_t hid_get_data ( const uint8_t *  buf,
usb_size_t  len,
struct hid_location loc 
)

Definition at line 694 of file usb_hid.c.

References hid_get_data_sub().

Referenced by ukbd_intr_callback(), and ums_intr_callback().

Here is the call graph for this function:

Here is the caller graph for this function:

static uint32_t hid_get_data_sub ( const uint8_t *  buf,
usb_size_t  len,
struct hid_location loc,
int  is_signed 
)
static

Definition at line 650 of file usb_hid.c.

References data, n, hid_location::pos, and hid_location::size.

Referenced by hid_get_data(), and hid_get_data_unsigned().

Here is the caller graph for this function:

uint32_t hid_get_data_unsigned ( const uint8_t *  buf,
usb_size_t  len,
struct hid_location loc 
)

Definition at line 700 of file usb_hid.c.

References hid_get_data_sub().

Here is the call graph for this function:

struct usb_hid_descriptor* hid_get_descriptor_from_usb ( struct usb_config_descriptor cd,
struct usb_interface_descriptor id 
)
read

Definition at line 776 of file usb_hid.c.

References usb_descriptor::bDescriptorType, usb_descriptor::bLength, desc, UDESC_HID, UDESC_INTERFACE, usb_desc_foreach(), and USB_HID_DESCRIPTOR_SIZE.

Referenced by usbd_req_get_hid_desc().

Here is the call graph for this function:

Here is the caller graph for this function:

int hid_is_collection ( const void *  desc,
usb_size_t  size,
int32_t  usage 
)

Definition at line 746 of file usb_hid.c.

References hid_collection, hid_end_parse(), hid_get_item(), hid_input, hid_start_parse(), hid_item::kind, and hid_item::usage.

Referenced by hid_is_keyboard().

Here is the call graph for this function:

Here is the caller graph for this function:

int hid_is_keyboard ( const void *  d_ptr,
uint16_t  d_len 
)

Definition at line 918 of file usb_hid.c.

References hid_is_collection(), HID_USAGE2, HUG_KEYBOARD, and HUP_GENERIC_DESKTOP.

Referenced by ukbd_probe().

Here is the call graph for this function:

Here is the caller graph for this function:

int hid_is_mouse ( const void *  d_ptr,
uint16_t  d_len 
)

Definition at line 860 of file usb_hid.c.

References hid_item::collection, hid_item::flags, hid_collection, hid_end_parse(), hid_endcollection, hid_get_item(), hid_input, hid_start_parse(), HID_USAGE2, HIO_CONST, HIO_RELATIVE, HUG_MOUSE, HUG_X, HUG_Y, HUP_GENERIC_DESKTOP, hid_item::kind, and hid_item::usage.

Referenced by ukbd_probe(), and ums_probe().

Here is the call graph for this function:

Here is the caller graph for this function:

int hid_locate ( const void *  desc,
usb_size_t  size,
int32_t  u,
enum hid_kind  k,
uint8_t  index,
struct hid_location loc,
uint32_t *  flags,
uint8_t *  id 
)

Definition at line 616 of file usb_hid.c.

References hid_item::flags, hid_end_parse(), hid_get_item(), hid_start_parse(), HIO_CONST, hid_item::kind, hid_item::loc, hid_item::report_ID, hid_location::size, and hid_item::usage.

Referenced by ukbd_parse_hid(), and ums_hid_parse().

Here is the call graph for this function:

Here is the caller graph for this function:

void hid_put_data_unsigned ( uint8_t *  buf,
usb_size_t  len,
struct hid_location loc,
unsigned int  value 
)

Definition at line 709 of file usb_hid.c.

References data, n, hid_location::pos, and hid_location::size.

Referenced by ukbd_set_leds_callback().

Here is the caller graph for this function:

int hid_report_size ( const void *  buf,
usb_size_t  len,
enum hid_kind  k,
uint8_t *  id 
)

Definition at line 563 of file usb_hid.c.

References hid_location::count, hid_end_parse(), hid_get_item(), hid_start_parse(), hid_item::kind, hid_item::loc, hid_location::pos, hid_item::report_ID, and hid_location::size.

Referenced by atp_attach(), ucycom_attach(), uhid_attach(), ukbd_parse_hid(), ums_attach(), and wsp_attach().

Here is the call graph for this function:

Here is the caller graph for this function:

struct hid_data* hid_start_parse ( const void *  d,
usb_size_t  len,
int  kindset 
)
read

Definition at line 179 of file usb_hid.c.

References hid_data::end, hid_data::kindset, len, hid_data::p, and hid_data::start.

Referenced by hid_is_collection(), hid_is_mouse(), hid_locate(), and hid_report_size().

Here is the caller graph for this function:

static void hid_switch_rid ( struct hid_data s,
struct hid_item c,
int32_t  next_rID 
)
static

Definition at line 124 of file usb_hid.c.

References DPRINTF, hid_data::last_pos, hid_item::loc, MAXID, hid_pos_data::pos, hid_location::pos, hid_item::report_ID, and hid_pos_data::rid.

Referenced by hid_get_item().

Here is the caller graph for this function:

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 
)