Classes | Macros | Functions
usbhost.c File Reference
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <stddef.h>
#include <sys/ioctl.h>
#include <sys/types.h>
#include <sys/time.h>
#include <sys/inotify.h>
#include <dirent.h>
#include <fcntl.h>
#include <errno.h>
#include <ctype.h>
#include <poll.h>
#include <pthread.h>
#include <linux/usbdevice_fs.h>
#include <asm/byteorder.h>
#include "usbhost.h"
Include dependency graph for usbhost.c:

Go to the source code of this file.

Classes

struct  usb_device
 
struct  usb_host_context
 

Macros

#define _GNU_SOURCE
 
#define D(...)
 
#define DEV_BUS_DIR   DEV_DIR "/bus"
 
#define DEV_DIR   "/dev"
 
#define MAX_DESCRIPTORS_LENGTH   4096
 
#define MAX_STRING_DESCRIPTOR_LENGTH   255
 
#define MAX_USBFS_WD_COUNT   10
 
#define USB_FS_DIR   DEV_BUS_DIR "/usb"
 
#define USB_FS_ID_FORMAT   USB_FS_DIR "/%03d/%03d"
 
#define USB_FS_ID_SCANNER   USB_FS_DIR "/%d/%d"
 

Functions

static int badname (const char *name)
 
static int find_existing_devices (usb_device_added_cb added_cb, void *client_data)
 
static int find_existing_devices_bus (char *busname, usb_device_added_cb added_cb, void *client_data)
 
void usb_descriptor_iter_init (struct usb_device *device, struct usb_descriptor_iter *iter)
 
struct usb_descriptor_header * usb_descriptor_iter_next (struct usb_descriptor_iter *iter)
 
int usb_device_bulk_transfer (struct usb_device *device, int endpoint, void *buffer, unsigned int length, unsigned int timeout)
 
int usb_device_claim_interface (struct usb_device *device, unsigned int interface)
 
void usb_device_close (struct usb_device *device)
 
int usb_device_connect_kernel_driver (struct usb_device *device, unsigned int interface, int connect)
 
int usb_device_control_transfer (struct usb_device *device, int requestType, int request, int value, int index, void *buffer, int length, unsigned int timeout)
 
size_t usb_device_get_descriptors_length (const struct usb_device *device)
 
const struct usb_device_descriptor * usb_device_get_device_descriptor (struct usb_device *device)
 
int usb_device_get_fd (struct usb_device *device)
 
char * usb_device_get_manufacturer_name (struct usb_device *device, int timeout)
 
const char * usb_device_get_name (struct usb_device *device)
 
char * usb_device_get_name_from_unique_id (int id)
 
uint16_t usb_device_get_product_id (struct usb_device *device)
 
char * usb_device_get_product_name (struct usb_device *device, int timeout)
 
const unsigned char * usb_device_get_raw_descriptors (const struct usb_device *device)
 
char * usb_device_get_serial (struct usb_device *device, int timeout)
 
char * usb_device_get_string (struct usb_device *device, int id, int timeout)
 
int usb_device_get_string_ucs2 (struct usb_device *device, int id, int timeout, void **ucs2_out, size_t *response_size)
 
int usb_device_get_unique_id (struct usb_device *device)
 
int usb_device_get_unique_id_from_name (const char *name)
 
uint16_t usb_device_get_vendor_id (struct usb_device *device)
 
int usb_device_get_version (struct usb_device *device)
 
int usb_device_is_writeable (struct usb_device *device)
 
struct usb_deviceusb_device_new (const char *dev_name, int fd)
 
struct usb_deviceusb_device_open (const char *dev_name)
 
int usb_device_release_interface (struct usb_device *device, unsigned int interface)
 
static int usb_device_reopen_writeable (struct usb_device *device)
 
int usb_device_reset (struct usb_device *device)
 
int usb_device_set_configuration (struct usb_device *device, int configuration)
 
int usb_device_set_interface (struct usb_device *device, unsigned int interface, unsigned int alt_setting)
 
void usb_host_cleanup (struct usb_host_context *context)
 
int usb_host_get_fd (struct usb_host_context *context)
 
struct usb_host_contextusb_host_init ()
 
int usb_host_load (struct usb_host_context *context, usb_device_added_cb added_cb, usb_device_removed_cb removed_cb, usb_discovery_done_cb discovery_done_cb, void *client_data)
 
int usb_host_read_event (struct usb_host_context *context)
 
void usb_host_run (struct usb_host_context *context, usb_device_added_cb added_cb, usb_device_removed_cb removed_cb, usb_discovery_done_cb discovery_done_cb, void *client_data)
 
int usb_request_cancel (struct usb_request *req)
 
void usb_request_free (struct usb_request *req)
 
struct usb_requestusb_request_new (struct usb_device *dev, const struct usb_endpoint_descriptor *ep_desc)
 
int usb_request_queue (struct usb_request *req)
 
struct usb_requestusb_request_wait (struct usb_device *dev, int timeoutMillis)
 
static void watch_existing_subdirs (struct usb_host_context *context, int *wds, int wd_count)
 

Macro Definition Documentation

#define _GNU_SOURCE

Definition at line 18 of file usbhost.c.

#define D (   ...)

Definition at line 33 of file usbhost.c.

#define DEV_BUS_DIR   DEV_DIR "/bus"

Definition at line 59 of file usbhost.c.

#define DEV_DIR   "/dev"

Definition at line 58 of file usbhost.c.

#define MAX_DESCRIPTORS_LENGTH   4096

Definition at line 79 of file usbhost.c.

#define MAX_STRING_DESCRIPTOR_LENGTH   255

Definition at line 65 of file usbhost.c.

#define MAX_USBFS_WD_COUNT   10

Definition at line 67 of file usbhost.c.

#define USB_FS_DIR   DEV_BUS_DIR "/usb"

Definition at line 60 of file usbhost.c.

#define USB_FS_ID_FORMAT   USB_FS_DIR "/%03d/%03d"

Definition at line 62 of file usbhost.c.

#define USB_FS_ID_SCANNER   USB_FS_DIR "/%d/%d"

Definition at line 61 of file usbhost.c.

Function Documentation

static int badname ( const char *  name)
inlinestatic

Definition at line 89 of file usbhost.c.

static int find_existing_devices ( usb_device_added_cb  added_cb,
void client_data 
)
static

Definition at line 121 of file usbhost.c.

static int find_existing_devices_bus ( char *  busname,
usb_device_added_cb  added_cb,
void client_data 
)
static

Definition at line 97 of file usbhost.c.

void usb_descriptor_iter_init ( struct usb_device device,
struct usb_descriptor_iter iter 
)

Definition at line 587 of file usbhost.c.

struct usb_descriptor_header* usb_descriptor_iter_next ( struct usb_descriptor_iter iter)

Definition at line 594 of file usbhost.c.

int usb_device_bulk_transfer ( struct usb_device device,
int  endpoint,
void buffer,
unsigned int  length,
unsigned int  timeout 
)

Definition at line 666 of file usbhost.c.

int usb_device_claim_interface ( struct usb_device device,
unsigned int  interface 
)

Definition at line 604 of file usbhost.c.

void usb_device_close ( struct usb_device device)

Definition at line 364 of file usbhost.c.

int usb_device_connect_kernel_driver ( struct usb_device device,
unsigned int  interface,
int  connect 
)

Definition at line 614 of file usbhost.c.

int usb_device_control_transfer ( struct usb_device device,
int  requestType,
int  request,
int  value,
int  index,
void buffer,
int  length,
unsigned int  timeout 
)

Definition at line 640 of file usbhost.c.

size_t usb_device_get_descriptors_length ( const struct usb_device device)

Definition at line 466 of file usbhost.c.

const struct usb_device_descriptor* usb_device_get_device_descriptor ( struct usb_device device)

Definition at line 462 of file usbhost.c.

int usb_device_get_fd ( struct usb_device device)

Definition at line 415 of file usbhost.c.

char* usb_device_get_manufacturer_name ( struct usb_device device,
int  timeout 
)

Definition at line 558 of file usbhost.c.

const char* usb_device_get_name ( struct usb_device device)

Definition at line 422 of file usbhost.c.

char* usb_device_get_name_from_unique_id ( int  id)

Definition at line 441 of file usbhost.c.

uint16_t usb_device_get_product_id ( struct usb_device device)

Definition at line 456 of file usbhost.c.

char* usb_device_get_product_name ( struct usb_device device,
int  timeout 
)

Definition at line 564 of file usbhost.c.

const unsigned char* usb_device_get_raw_descriptors ( const struct usb_device device)

Definition at line 470 of file usbhost.c.

char* usb_device_get_serial ( struct usb_device device,
int  timeout 
)

Definition at line 576 of file usbhost.c.

char* usb_device_get_string ( struct usb_device device,
int  id,
int  timeout 
)

Definition at line 537 of file usbhost.c.

int usb_device_get_string_ucs2 ( struct usb_device device,
int  id,
int  timeout,
void **  ucs2_out,
size_t response_size 
)

Definition at line 488 of file usbhost.c.

int usb_device_get_unique_id ( struct usb_device device)

Definition at line 427 of file usbhost.c.

int usb_device_get_unique_id_from_name ( const char *  name)

Definition at line 434 of file usbhost.c.

uint16_t usb_device_get_vendor_id ( struct usb_device device)

Definition at line 450 of file usbhost.c.

int usb_device_get_version ( struct usb_device device)

Definition at line 570 of file usbhost.c.

int usb_device_is_writeable ( struct usb_device device)

Definition at line 582 of file usbhost.c.

struct usb_device* usb_device_new ( const char *  dev_name,
int  fd 
)

Definition at line 370 of file usbhost.c.

struct usb_device* usb_device_open ( const char *  dev_name)

Definition at line 323 of file usbhost.c.

int usb_device_release_interface ( struct usb_device device,
unsigned int  interface 
)

Definition at line 609 of file usbhost.c.

static int usb_device_reopen_writeable ( struct usb_device device)
static

Definition at line 399 of file usbhost.c.

int usb_device_reset ( struct usb_device device)

Reset USB bus for the device

Definition at line 682 of file usbhost.c.

int usb_device_set_configuration ( struct usb_device device,
int  configuration 
)

Definition at line 625 of file usbhost.c.

int usb_device_set_interface ( struct usb_device device,
unsigned int  interface,
unsigned int  alt_setting 
)

Definition at line 630 of file usbhost.c.

void usb_host_cleanup ( struct usb_host_context context)

Definition at line 179 of file usbhost.c.

int usb_host_get_fd ( struct usb_host_context context)

Definition at line 185 of file usbhost.c.

struct usb_host_context* usb_host_init ( void  )

Definition at line 163 of file usbhost.c.

int usb_host_load ( struct usb_host_context context,
usb_device_added_cb  added_cb,
usb_device_removed_cb  removed_cb,
usb_discovery_done_cb  discovery_done_cb,
void client_data 
)

Definition at line 190 of file usbhost.c.

int usb_host_read_event ( struct usb_host_context context)

Definition at line 229 of file usbhost.c.

void usb_host_run ( struct usb_host_context context,
usb_device_added_cb  added_cb,
usb_device_removed_cb  removed_cb,
usb_discovery_done_cb  discovery_done_cb,
void client_data 
)

Definition at line 307 of file usbhost.c.

int usb_request_cancel ( struct usb_request req)

Definition at line 776 of file usbhost.c.

void usb_request_free ( struct usb_request req)

Definition at line 720 of file usbhost.c.

struct usb_request* usb_request_new ( struct usb_device dev,
const struct usb_endpoint_descriptor *  ep_desc 
)

Definition at line 687 of file usbhost.c.

int usb_request_queue ( struct usb_request req)

Definition at line 726 of file usbhost.c.

struct usb_request* usb_request_wait ( struct usb_device dev,
int  timeoutMillis 
)

Definition at line 742 of file usbhost.c.

static void watch_existing_subdirs ( struct usb_host_context context,
int *  wds,
int  wd_count 
)
static

Definition at line 144 of file usbhost.c.



librealsense2
Author(s): Sergey Dorodnicov , Doron Hirshberg , Mark Horn , Reagan Lopez , Itay Carpis
autogenerated on Mon May 3 2021 02:50:30