Statistics
| Branch: | Tag: | Revision:

root / host / include / uhd / transport / usb_zero_copy.hpp @ 687e118e

History | View | Annotate | Download (2.5 kB)

1
//
2
// Copyright 2010 Ettus Research LLC
3
//
4
// This program is free software: you can redistribute it and/or modify
5
// it under the terms of the GNU General Public License as published by
6
// the Free Software Foundation, either version 3 of the License, or
7
// (at your option) any later version.
8
//
9
// This program is distributed in the hope that it will be useful,
10
// but WITHOUT ANY WARRANTY; without even the implied warranty of
11
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
// GNU General Public License for more details.
13
//
14
// You should have received a copy of the GNU General Public License
15
// along with this program.  If not, see <http://www.gnu.org/licenses/>.
16
//
17

    
18
#ifndef INCLUDED_UHD_TRANSPORT_USB_ZERO_COPY_HPP
19
#define INCLUDED_UHD_TRANSPORT_USB_ZERO_COPY_HPP
20

    
21
#include "usb_device_handle.hpp"
22
#include <uhd/transport/zero_copy.hpp>
23

    
24
namespace uhd { namespace transport {
25

    
26
/*!
27
 * A zero copy usb transport provides an efficient way to handle data.
28
 * by avoiding the extra copy when recv() or send() is called on the handle.
29
 * Rather, the zero copy transport gives the caller memory references.
30
 * The caller informs the transport when it is finished with the reference.
31
 *
32
 * On linux systems, the zero copy transport can use a kernel packet ring.
33
 * If no platform specific solution is available, make returns a boost asio
34
 * implementation that wraps functionality around standard send/recv calls.
35
 */
36
class UHD_API usb_zero_copy : public virtual zero_copy_if {
37
public:
38
    typedef boost::shared_ptr<usb_zero_copy> sptr;
39

    
40
    /*!
41
     * Make a new zero copy usb transport:
42
     * This transport is for sending and receiving between the host
43
     * and a pair of USB bulk transfer endpoints.
44
     * The primary usage for this transport is data transactions.
45
     * The underlying implementation may be platform specific.
46
     *
47
     * \param handle a device handle that uniquely identifying the device
48
     * \param rx_endpoint an integer specifiying an IN endpoint number 
49
     * \param tx_endpoint an integer specifiying an OUT endpoint number
50
     * \param buff_size total number of bytes of buffer space to allocate 
51
     * \param block_size number of bytes allocated for each I/O transaction 
52
     */
53
    static sptr make(usb_device_handle::sptr handle,
54
                     unsigned int rx_endpoint,
55
                     unsigned int tx_endpoint,
56
                     size_t buff_size = 0, 
57
                     size_t block_size = 0);
58
};
59

    
60
}} //namespace
61

    
62
#endif /* INCLUDED_UHD_TRANSPORT_USB_ZERO_COPY_HPP */