Revision ad55e25a

b/host/lib/transport/libusb1_base.cpp
21 21

  
22 22
using namespace uhd::transport;
23 23

  
24
/**********************************************************
25
 * Helper Methods
26
 **********************************************************/
27
/*
28
 * Check for FSF device
29
 * Compare the device's descriptor Vendor ID
30
 * \param dev pointer to libusb_device
31
 * \return true if Vendor ID matches 0xfffe
32
 */
24 33
bool check_fsf_device(libusb_device *dev)
25 34
{
26 35
    libusb_device_descriptor desc;
......
32 41
    return desc.idVendor == 0xfffe;
33 42
}
34 43

  
44
/**********************************************************
45
 * libusb namespace 
46
 **********************************************************/
35 47
void libusb::init(libusb_context **ctx, int debug_level)
36 48
{
37 49
    if (libusb_init(ctx) < 0)
b/host/lib/transport/libusb1_base.hpp
25 25
namespace uhd { namespace transport {
26 26

  
27 27
namespace libusb {
28
    /*
29
     * Initialize libusb and set debug level
30
     * Takes a pointer to context pointer because that's
31
     * how libusb rolls. Debug levels.
32
     *     
33
     *   Level 0: no messages ever printed by the library (default)
34
     *   Level 1: error messages are printed to stderr
35
     *   Level 2: warning and error messages are printed to stderr
36
     *   Level 3: informational messages are printed to stdout, warning
37
     *            and error messages are printed to stderr
38
     *
39
     * \param ctx pointer to context pointer
40
     * \param debug_level
41
     */
28 42
    void init(libusb_context **ctx, int debug_level);
29 43

  
44
    /*
45
     * Get a list of Free Software Foundation devices (Vendor ID 0xfffe)
46
     * As opposed to the public USB device handle interface, which returns
47
     * generic identifiers, this call returns device pointers speficic
48
     * to libusb.
49
     * \param ctx the libusb context used for init
50
     * \return a vector of libusb devices
51
     */
30 52
    std::vector<libusb_device *> get_fsf_device_list(libusb_context *ctx);
31 53

  
54
    /*
55
     * Open the device specified by a generic handle
56
     * Find the libusb_device cooresponding to the generic handle
57
     * and open it for I/O, which returns a libusb_device_handle
58
     * ready for an interface
59
     * \param ctx the libusb context used for init
60
     * \return a libusb_device_handle ready for action 
61
     */
32 62
    libusb_device_handle *open_device(libusb_context *ctx,
33 63
                                      usb_device_handle::sptr handle);
34 64

  
65
    /*
66
     * Compare a libusb device with a generic handle 
67
     * Check the descriptors and open the device to check the
68
     * serial number string. Compare values against the given
69
     * handle. The libusb context is already implied in the
70
     * libusb_device.
71
     * \param dev a libusb_device pointer
72
     * \param handle a generic handle specifier
73
     * \return true if handle and device match, false otherwise
74
     */
35 75
    bool compare_device(libusb_device *dev, usb_device_handle::sptr handle);
36 76

  
77
    /*
78
     * Open an interface to the device
79
     * This is a logical operation for operating system housekeeping as
80
     * nothing is sent over the bus. The interface much correspond
81
     * to the USB device descriptors.
82
     * \param dev_handle libusb handle to an opened device
83
     * \param interface integer of the interface to use
84
     * \return true on success, false on error
85
     */
37 86
    bool open_interface(libusb_device_handle *dev_handle, int interface);
38 87

  
88
    /*
89
     * Get serial number 
90
     * The standard USB device descriptor contains an index to an
91
     * actual serial number string descriptor. The index is readily
92
     * readble, but the string descriptor requires probing the device.
93
     * Because this call attempts to open the device, it may not
94
     * succeed because not all USB devices are readily opened.
95
     * The default language is used for the request (English).
96
     * \param dev a libusb_device pointer
97
     * \return string serial number or 0 on error or unavailablity
98
     */
39 99
    std::string get_serial(libusb_device *dev);
40 100
}
41 101

  
b/host/lib/transport/libusb1_control.cpp
48 48
{
49 49
    libusb::init(&_ctx, libusb_debug_level);
50 50

  
51
    // Find and open the libusb_device corresponding to the
52
    // given handle and return the libusb_device_handle
53
    // that can be used for I/O purposes.
51 54
    _dev_handle = libusb::open_device(_ctx, handle);
52 55

  
56
    // Open USB interfaces for control using magic value
57
    // IN interface:      2
58
    // OUT interface:     1
59
    // Control interface: 0
53 60
    libusb::open_interface(_dev_handle, 0);
54 61
}
55 62

  
b/host/lib/transport/libusb1_device_handle.cpp
22 22

  
23 23
const int libusb_debug_level = 0;
24 24

  
25
/****************************************************************
26
 * libusb USB device handle implementation class
27
 ***************************************************************/
25 28
class libusb1_device_handle_impl : public usb_device_handle {
26 29
public:
27 30
    libusb1_device_handle_impl(std::string serial,
b/host/lib/transport/libusb1_zero_copy.cpp
30 30

  
31 31
/***********************************************************************
32 32
 * Helper functions
33
 *
34
 * Print to stdout the values of a libusb_transfer struct
35 33
 ***********************************************************************/
34
/*
35
 * Print the values of a libusb_transfer struct
36
 * http://libusb.sourceforge.net/api-1.0/structlibusb__transfer.html
37
 */
36 38
void pp_transfer(libusb_transfer *lut)
37 39
{
38 40
    std::cout << "Libusb transfer"       << std::endl;
......
46 48
}
47 49

  
48 50
/***********************************************************************
49
 * USB asynchronous phony zero_copy endpoint
51
 * USB asynchronous zero_copy endpoint
50 52
 *   This endpoint implementation provides asynchronous I/O to libusb-1.0
51 53
 *   devices. Each endpoint is directional and two can be combined to
52 54
 *   create a bidirectional interface. It is a zero copy implementation

Also available in: Unified diff