Android-cuttlefish cvd tool
Classes | Macros | Functions
usb_linux.cpp File Reference
#include <ctype.h>
#include <dirent.h>
#include <errno.h>
#include <fcntl.h>
#include <pthread.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/ioctl.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
#include <linux/usbdevice_fs.h>
#include <linux/version.h>
#include <linux/usb/ch9.h>
#include <android-base/file.h>
#include <android-base/stringprintf.h>
#include <chrono>
#include <memory>
#include <thread>
#include "usb.h"
#include "util.h"
Include dependency graph for usb_linux.cpp:

Classes

struct  usb_handle
 
class  LinuxUsbTransport
 

Macros

#define MAX_RETRIES   2
 
#define WAIT_FOR_DISCONNECT_TIMEOUT   3
 
#define DBG(x...)
 
#define DBG1(x...)
 
#define MAX_USBFS_BULK_WRITE_SIZE   (256 * 1024)
 
#define MAX_USBFS_BULK_READ_SIZE   (16 * 1024)
 
#define MIN_USBFS_BULK_WRITE_SIZE   (16 * 1024)
 

Functions

static int badname (const char *name)
 
static int check (void *_desc, int len, unsigned type, int size)
 
static int filter_usb_device (char *sysfs_name, char *ptr, int len, int writable, ifc_match_func callback, int *ept_in_id, int *ept_out_id, int *ifc_id)
 
static int read_sysfs_string (const char *sysfs_name, const char *sysfs_node, char *buf, int bufsize)
 
static int read_sysfs_number (const char *sysfs_name, const char *sysfs_node)
 
static int convert_to_devfs_name (const char *sysfs_name, char *devname, int devname_size)
 
static std::unique_ptr< usb_handlefind_usb_device (const char *base, ifc_match_func callback)
 
std::unique_ptr< UsbTransportusb_open (ifc_match_func callback, uint32_t timeout_ms)
 

Macro Definition Documentation

◆ DBG

#define DBG (   x...)

◆ DBG1

#define DBG1 (   x...)

◆ MAX_RETRIES

#define MAX_RETRIES   2

◆ MAX_USBFS_BULK_READ_SIZE

#define MAX_USBFS_BULK_READ_SIZE   (16 * 1024)

◆ MAX_USBFS_BULK_WRITE_SIZE

#define MAX_USBFS_BULK_WRITE_SIZE   (256 * 1024)

◆ MIN_USBFS_BULK_WRITE_SIZE

#define MIN_USBFS_BULK_WRITE_SIZE   (16 * 1024)

◆ WAIT_FOR_DISCONNECT_TIMEOUT

#define WAIT_FOR_DISCONNECT_TIMEOUT   3

Function Documentation

◆ badname()

static int badname ( const char *  name)
inlinestatic

◆ check()

static int check ( void *  _desc,
int  len,
unsigned  type,
int  size 
)
static

◆ convert_to_devfs_name()

static int convert_to_devfs_name ( const char *  sysfs_name,
char *  devname,
int  devname_size 
)
static

◆ filter_usb_device()

static int filter_usb_device ( char *  sysfs_name,
char *  ptr,
int  len,
int  writable,
ifc_match_func  callback,
int *  ept_in_id,
int *  ept_out_id,
int *  ifc_id 
)
static

◆ find_usb_device()

static std::unique_ptr< usb_handle > find_usb_device ( const char *  base,
ifc_match_func  callback 
)
static

◆ read_sysfs_number()

static int read_sysfs_number ( const char *  sysfs_name,
const char *  sysfs_node 
)
static

◆ read_sysfs_string()

static int read_sysfs_string ( const char *  sysfs_name,
const char *  sysfs_node,
char *  buf,
int  bufsize 
)
static

◆ usb_open()

std::unique_ptr< UsbTransport > usb_open ( ifc_match_func  callback,
uint32_t  timeout_ms 
)