aboutsummaryrefslogtreecommitdiffstats
path: root/host/include
diff options
context:
space:
mode:
Diffstat (limited to 'host/include')
-rw-r--r--host/include/uhd/transport/CMakeLists.txt3
-rw-r--r--host/include/uhd/transport/usb_control.hpp65
-rw-r--r--host/include/uhd/transport/usb_device_handle.hpp79
-rw-r--r--host/include/uhd/transport/usb_zero_copy.hpp62
4 files changed, 209 insertions, 0 deletions
diff --git a/host/include/uhd/transport/CMakeLists.txt b/host/include/uhd/transport/CMakeLists.txt
index 93e9a6485..0f1cbf2a2 100644
--- a/host/include/uhd/transport/CMakeLists.txt
+++ b/host/include/uhd/transport/CMakeLists.txt
@@ -25,6 +25,9 @@ INSTALL(FILES
if_addrs.hpp
udp_simple.hpp
udp_zero_copy.hpp
+ usb_control.hpp
+ usb_zero_copy.hpp
+ usb_device_handle.hpp
vrt_if_packet.hpp
zero_copy.hpp
DESTINATION ${INCLUDE_DIR}/uhd/transport
diff --git a/host/include/uhd/transport/usb_control.hpp b/host/include/uhd/transport/usb_control.hpp
new file mode 100644
index 000000000..6137ecf84
--- /dev/null
+++ b/host/include/uhd/transport/usb_control.hpp
@@ -0,0 +1,65 @@
+//
+// Copyright 2010 Ettus Research LLC
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see <http://www.gnu.org/licenses/>.
+//
+
+#ifndef INCLUDED_UHD_TRANSPORT_USB_CONTROL_HPP
+#define INCLUDED_UHD_TRANSPORT_USB_CONTROL_HPP
+
+#include "usb_device_handle.hpp"
+
+namespace uhd { namespace transport {
+
+class UHD_API usb_control : boost::noncopyable {
+public:
+ typedef boost::shared_ptr<usb_control> sptr;
+
+ /*!
+ * Create a new usb control transport:
+ * This transport is for sending and receiving control information from
+ * the host to device using the Default Control Pipe.
+ *
+ * \param handle a device handle that uniquely identifies a USB device
+ */
+ static sptr make(usb_device_handle::sptr handle);
+
+ /*!
+ * Submit a USB device request:
+ * Blocks until the request returns
+ *
+ * For format and corresponding USB request fields
+ * see USB Specification Revision 2.0 - 9.3 USB Device Requests
+ *
+ * Usage is device specific
+ *
+ * \param request_type 1-byte bitmask (bmRequestType)
+ * \param request 1-byte (bRequest)
+ * \param value 2-byte (wValue)
+ * \param index 2-byte (wIndex)
+ * \param buff buffer to hold send or receive data
+ * \param length 2-byte (wLength)
+ * \return number of bytes submitted
+ */
+ virtual size_t submit(boost::uint8_t request_type,
+ boost::uint8_t request,
+ boost::uint16_t value,
+ boost::uint16_t index,
+ unsigned char *buff,
+ boost::uint16_t length) = 0;
+};
+
+}} //namespace
+
+#endif /* INCLUDED_UHD_TRANSPORT_USB_CONTROL_HPP */
diff --git a/host/include/uhd/transport/usb_device_handle.hpp b/host/include/uhd/transport/usb_device_handle.hpp
new file mode 100644
index 000000000..78c78f6b5
--- /dev/null
+++ b/host/include/uhd/transport/usb_device_handle.hpp
@@ -0,0 +1,79 @@
+//
+// Copyright 2010 Ettus Research LLC
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see <http://www.gnu.org/licenses/>.
+//
+
+#ifndef INCLUDED_UHD_TRANSPORT_USB_DEVICE_HANDLE_HPP
+#define INCLUDED_UHD_TRANSPORT_USB_DEVICE_HANDLE_HPP
+
+#include <uhd/config.hpp>
+#include <boost/utility.hpp>
+#include <boost/shared_ptr.hpp>
+#include <boost/cstdint.hpp>
+#include <vector>
+
+namespace uhd { namespace transport {
+
+/*!
+ * Device handle class that represents a USB device
+ * Used for identifying devices on the USB bus and selecting which device is
+ * used when creating a USB transport. A minimal subset of USB descriptor
+ * fields are used. Fields can be found in the USB 2.0 specification Table
+ * 9-8 (Standard Device Descriptor). In addition to fields of the device
+ * descriptor, the interface returns the device's USB device address.
+ *
+ * Note: The USB 2.0 Standard Device Descriptor contains an index rather then
+ * a true descriptor serial number string. This interface returns the
+ * actual string descriptor.
+ */
+class UHD_API usb_device_handle : boost::noncopyable {
+public:
+ typedef boost::shared_ptr<usb_device_handle> sptr;
+
+ /*!
+ * Return the device's serial number
+ * \return a string describing the device's serial number
+ */
+ virtual UHD_API std::string get_serial() const = 0;
+
+ /*!
+ * Return the device's Vendor ID (usually assigned by the USB-IF)
+ * \return a Vendor ID
+ */
+ virtual UHD_API boost::uint16_t get_vendor_id() const = 0;
+
+ /*!
+ * Return the device's Product ID (usually assigned by manufacturer)
+ * \return a Product ID
+ */
+ virtual UHD_API boost::uint16_t get_product_id() const = 0;
+
+ /*!
+ * Return the device's USB address
+ * \return a Product ID
+ */
+ virtual UHD_API boost::uint16_t get_device_addr() const = 0;
+
+ /*!
+ * Return a vector of USB devices on this host
+ * \return a vector of USB device handles
+ */
+ static UHD_API std::vector<usb_device_handle::sptr> get_device_list();
+
+}; //namespace usb
+
+}} //namespace
+
+#endif /* INCLUDED_UHD_TRANSPORT_USB_DEVICE_HANDLE_HPP */
diff --git a/host/include/uhd/transport/usb_zero_copy.hpp b/host/include/uhd/transport/usb_zero_copy.hpp
new file mode 100644
index 000000000..2edd6d91d
--- /dev/null
+++ b/host/include/uhd/transport/usb_zero_copy.hpp
@@ -0,0 +1,62 @@
+//
+// Copyright 2010 Ettus Research LLC
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see <http://www.gnu.org/licenses/>.
+//
+
+#ifndef INCLUDED_UHD_TRANSPORT_USB_ZERO_COPY_HPP
+#define INCLUDED_UHD_TRANSPORT_USB_ZERO_COPY_HPP
+
+#include "usb_device_handle.hpp"
+#include <uhd/transport/zero_copy.hpp>
+
+namespace uhd { namespace transport {
+
+/*!
+ * A zero copy usb transport provides an efficient way to handle data.
+ * by avoiding the extra copy when recv() or send() is called on the handle.
+ * Rather, the zero copy transport gives the caller memory references.
+ * The caller informs the transport when it is finished with the reference.
+ *
+ * On linux systems, the zero copy transport can use a kernel packet ring.
+ * If no platform specific solution is available, make returns a boost asio
+ * implementation that wraps functionality around standard send/recv calls.
+ */
+class UHD_API usb_zero_copy : public virtual zero_copy_if {
+public:
+ typedef boost::shared_ptr<usb_zero_copy> sptr;
+
+ /*!
+ * Make a new zero copy usb transport:
+ * This transport is for sending and receiving between the host
+ * and a pair of USB bulk transfer endpoints.
+ * The primary usage for this transport is data transactions.
+ * The underlying implementation may be platform specific.
+ *
+ * \param handle a device handle that uniquely identifying the device
+ * \param rx_endpoint an integer specifiying an IN endpoint number
+ * \param tx_endpoint an integer specifiying an OUT endpoint number
+ * \param buff_size total number of bytes of buffer space to allocate
+ * \param block_size number of bytes allocated for each I/O transaction
+ */
+ static sptr make(usb_device_handle::sptr handle,
+ unsigned int rx_endpoint,
+ unsigned int tx_endpoint,
+ size_t buff_size = 0,
+ size_t block_size = 0);
+};
+
+}} //namespace
+
+#endif /* INCLUDED_UHD_TRANSPORT_USB_ZERO_COPY_HPP */