66#include "../include/sane/config.h"
67#include "../include/sane/sane.h"
76#ifndef USB_CLASS_PER_INTERFACE
80#define USB_CLASS_PER_INTERFACE 0x00
81#define USB_CLASS_AUDIO 0x01
82#define USB_CLASS_COMM 0x02
83#define USB_CLASS_HID 0x03
84#define USB_CLASS_PRINTER 0x07
85#define USB_CLASS_MASS_STORAGE 0x08
86#define USB_CLASS_HUB 0x09
87#define USB_CLASS_DATA 0x0a
88#define USB_CLASS_VENDOR_SPEC 0xff
93#define USB_DT_DEVICE 0x01
94#define USB_DT_CONFIG 0x02
95#define USB_DT_STRING 0x03
96#define USB_DT_INTERFACE 0x04
97#define USB_DT_ENDPOINT 0x05
98#define USB_DT_HID 0x21
99#define USB_DT_REPORT 0x22
100#define USB_DT_PHYSICAL 0x23
101#define USB_DT_HUB 0x29
106#define USB_DT_DEVICE_SIZE 18
107#define USB_DT_CONFIG_SIZE 9
108#define USB_DT_INTERFACE_SIZE 9
109#define USB_DT_ENDPOINT_SIZE 7
110#define USB_DT_ENDPOINT_AUDIO_SIZE 9
111#define USB_DT_HUB_NONVAR_SIZE 7
116#define USB_ENDPOINT_ADDRESS_MASK 0x0f
117#define USB_ENDPOINT_DIR_MASK 0x80
118#define USB_ENDPOINT_TYPE_MASK 0x03
119#define USB_ENDPOINT_TYPE_CONTROL 0
120#define USB_ENDPOINT_TYPE_ISOCHRONOUS 1
121#define USB_ENDPOINT_TYPE_BULK 2
122#define USB_ENDPOINT_TYPE_INTERRUPT 3
127#define USB_REQ_GET_STATUS 0x00
128#define USB_REQ_CLEAR_FEATURE 0x01
129#define USB_REQ_SET_FEATURE 0x03
130#define USB_REQ_SET_ADDRESS 0x05
131#define USB_REQ_GET_DESCRIPTOR 0x06
132#define USB_REQ_SET_DESCRIPTOR 0x07
133#define USB_REQ_GET_CONFIGURATION 0x08
134#define USB_REQ_SET_CONFIGURATION 0x09
135#define USB_REQ_GET_INTERFACE 0x0A
136#define USB_REQ_SET_INTERFACE 0x0B
137#define USB_REQ_SYNCH_FRAME 0x0C
142#define USB_TYPE_STANDARD (0x00 << 5)
143#define USB_TYPE_CLASS (0x01 << 5)
144#define USB_TYPE_VENDOR (0x02 << 5)
145#define USB_TYPE_RESERVED (0x03 << 5)
150#define USB_RECIP_DEVICE 0x00
151#define USB_RECIP_INTERFACE 0x01
152#define USB_RECIP_ENDPOINT 0x02
153#define USB_RECIP_OTHER 0x03
161#define USB_TYPE_MASK (0x03 << 5)
162#define USB_RECIP_MASK 0x1f
167#define USB_DIR_OUT 0x00
168#define USB_DIR_IN 0x80
172struct sanei_usb_dev_descriptor
175 unsigned int bcd_usb;
176 unsigned int bcd_dev;
178 SANE_Byte dev_sub_class;
179 SANE_Byte dev_protocol;
180 SANE_Byte max_packet_size;
202 int development_mode);
213 SANE_String_Const be_name);
280 SANE_Word * vendor, SANE_Word * product);
298 SANE_Word * product);
313 SANE_Status (*attach) (SANE_String_Const devname));
378#define HAVE_SANEI_USB_SET_TIMEOUT
388#define HAVE_SANEI_USB_CLEAR_HALT
458 SANE_Int value, SANE_Int index, SANE_Int len,
499 SANE_Status (*attach) (
const char *dev));
SANE_Status sanei_usb_read_int(SANE_Int dn, SANE_Byte *buffer, size_t *size)
Initiate a interrupt transfer read.
SANE_String sanei_usb_testing_get_backend(void)
Returns backend name for testing.
void sanei_usb_attach_matching_devices(const char *name, SANE_Status(*attach)(const char *dev))
Expand device name patterns into a list of devices.
SANE_Status sanei_usb_testing_enable_replay(SANE_String_Const path, int development_mode)
Initialize sanei_usb for replay testing.
void sanei_usb_testing_record_message(SANE_String_Const message)
Records a debug message in the captured USB data if testing mode is enabled.
SANE_Status sanei_usb_open(SANE_String_Const devname, SANE_Int *dn)
Open a USB device.
SANE_Status sanei_usb_release_interface(SANE_Int dn, SANE_Int interface_number)
Initiate release interface.
void sanei_usb_set_endpoint(SANE_Int dn, SANE_Int ep_type, SANE_Int ep)
Set the endpoint for the USB communication.
SANE_Status sanei_usb_write_bulk(SANE_Int dn, const SANE_Byte *buffer, size_t *size)
Initiate a bulk transfer write.
SANE_Status sanei_usb_clear_halt(SANE_Int dn)
Clear halt condition on bulk endpoints.
SANE_Bool sanei_usb_is_replay_mode_enabled(void)
Returns SANE_TRUE if replay testing mode is enabled, i.e.
void sanei_usb_exit(void)
End sanei_usb use, freeing resources when needed.
void sanei_usb_init(void)
Initialize sanei_usb.
void sanei_usb_testing_record_clear(void)
Clears currently recorded data.
SANE_Status sanei_usb_testing_enable_record(SANE_String_Const path, SANE_String_Const be_name)
Initialize sanei_usb for recording.
SANE_Status sanei_usb_control_msg(SANE_Int dn, SANE_Int rtype, SANE_Int req, SANE_Int value, SANE_Int index, SANE_Int len, SANE_Byte *data)
Send/receive a control message to/from a USB device.
SANE_Status sanei_usb_get_vendor_product_byname(SANE_String_Const devname, SANE_Word *vendor, SANE_Word *product)
Get the vendor and product ids by device name.
SANE_Int sanei_usb_get_endpoint(SANE_Int dn, SANE_Int ep_type)
Retrieve the endpoint used for the USB communication.
SANE_Status sanei_usb_find_devices(SANE_Int vendor, SANE_Int product, SANE_Status(*attach)(SANE_String_Const devname))
Find devices that match given vendor and product ids.
SANE_Status sanei_usb_get_vendor_product(SANE_Int dn, SANE_Word *vendor, SANE_Word *product)
Get the vendor and product ids.
void sanei_usb_close(SANE_Int dn)
Close a USB device.
void sanei_usb_scan_devices(void)
Search for USB devices.
SANE_Status sanei_usb_get_descriptor(SANE_Int dn, struct sanei_usb_dev_descriptor *desc)
Get some information from the device descriptor.
SANE_Status sanei_usb_set_altinterface(SANE_Int dn, SANE_Int alternate)
Initiate a set altinterface.
void sanei_usb_set_timeout(SANE_Int timeout)
Set the libusb timeout for bulk and interrupt reads.
SANE_Status sanei_usb_claim_interface(SANE_Int dn, SANE_Int interface_number)
Initiate claim interface.
SANE_Status sanei_usb_set_configuration(SANE_Int dn, SANE_Int configuration)
Initiate set configuration.
SANE_Status sanei_usb_read_bulk(SANE_Int dn, SANE_Byte *buffer, size_t *size)
Initiate a bulk transfer read.
SANE_Status sanei_usb_reset(SANE_Int dn)
Reset device.