diff options
author | Josh Blum <josh@joshknows.com> | 2011-10-04 18:08:47 -0700 |
---|---|---|
committer | Josh Blum <josh@joshknows.com> | 2011-11-03 20:37:10 -0700 |
commit | 66c95c12a1d2f7b79bdf5b9b871d1b957c56606f (patch) | |
tree | 120f3106559b856c7ab64579663b962f5827f6f1 /host/include | |
parent | abed04b3c6d70c260d8725831b8aa6e944f52749 (diff) | |
download | uhd-66c95c12a1d2f7b79bdf5b9b871d1b957c56606f.tar.gz uhd-66c95c12a1d2f7b79bdf5b9b871d1b957c56606f.tar.bz2 uhd-66c95c12a1d2f7b79bdf5b9b871d1b957c56606f.zip |
uhd: lots of work releated to streamer work and usrp2 implementation
Diffstat (limited to 'host/include')
-rw-r--r-- | host/include/uhd/device.hpp | 8 | ||||
-rw-r--r-- | host/include/uhd/device_deprecated.ipp | 46 | ||||
-rw-r--r-- | host/include/uhd/streamer.hpp | 81 |
3 files changed, 76 insertions, 59 deletions
diff --git a/host/include/uhd/device.hpp b/host/include/uhd/device.hpp index f76739907..c96139858 100644 --- a/host/include/uhd/device.hpp +++ b/host/include/uhd/device.hpp @@ -76,11 +76,11 @@ public: */ static sptr make(const device_addr_t &hint, size_t which = 0); - //! Make a new receive streamer given the list of channels - virtual rx_streamer::sptr get_rx_streamer(const std::vector<size_t> &channels) = 0; + //! Make a new receive streamer from the streamer arguments + virtual rx_streamer::sptr get_rx_streamer(const streamer_args &args) = 0; - //! Make a new transmit streamer given the list of channels - virtual tx_streamer::sptr get_tx_streamer(const std::vector<size_t> &channels) = 0; + //! Make a new transmit streamer from the streamer arguments + virtual tx_streamer::sptr get_tx_streamer(const streamer_args &args) = 0; /*! * Receive and asynchronous message from the device. diff --git a/host/include/uhd/device_deprecated.ipp b/host/include/uhd/device_deprecated.ipp index ba0edb1bc..4647a050e 100644 --- a/host/include/uhd/device_deprecated.ipp +++ b/host/include/uhd/device_deprecated.ipp @@ -77,16 +77,16 @@ size_t send( send_mode_t send_mode, double timeout = 0.1 ){ - if (_tx_streamer.get() == NULL or _tx_streamer->get_num_channels() != buffs.size()){ + if (_tx_streamer.get() == NULL or _tx_streamer->get_num_channels() != buffs.size() or _send_tid != io_type.tid){ + _send_tid = io_type.tid; std::vector<size_t> chans(buffs.size()); for (size_t ch = 0; ch < chans.size(); ch++) chans[ch] = ch; _tx_streamer.reset(); //cleanup possible old one - _tx_streamer = get_tx_streamer(chans); - _send_tid = io_type_t::CUSTOM_TYPE; - } - if (io_type.tid != _send_tid){ - _send_tid = io_type.tid; - _tx_streamer->set_format((_send_tid == io_type_t::COMPLEX_FLOAT32)? "fc32" : "sc16", "sc16"); + streamer_args args; + args.cpu_format = (_send_tid == io_type_t::COMPLEX_FLOAT32)? "fc32" : "sc16"; + args.otw_format = "sc16"; + args.channels = chans; + _tx_streamer = get_tx_streamer(args); } const size_t nsamps = (send_mode == SEND_MODE_ONE_PACKET)? std::min(nsamps_per_buff, get_max_send_samps_per_packet()) : @@ -133,16 +133,16 @@ size_t recv( recv_mode_t recv_mode, double timeout = 0.1 ){ - if (_rx_streamer.get() == NULL or _rx_streamer->get_num_channels() != buffs.size()){ + if (_rx_streamer.get() == NULL or _rx_streamer->get_num_channels() != buffs.size() or _recv_tid != io_type.tid){ + _recv_tid = io_type.tid; std::vector<size_t> chans(buffs.size()); for (size_t ch = 0; ch < chans.size(); ch++) chans[ch] = ch; _rx_streamer.reset(); //cleanup possible old one - _rx_streamer = get_rx_streamer(chans); - _recv_tid = io_type_t::CUSTOM_TYPE; - } - if (io_type.tid != _recv_tid){ - _recv_tid = io_type.tid; - _rx_streamer->set_format((_recv_tid == io_type_t::COMPLEX_FLOAT32)? "fc32" : "sc16", "sc16"); + streamer_args args; + args.cpu_format = (_send_tid == io_type_t::COMPLEX_FLOAT32)? "fc32" : "sc16"; + args.otw_format = "sc16"; + args.channels = chans; + _rx_streamer = get_rx_streamer(args); } const size_t nsamps = (recv_mode == RECV_MODE_ONE_PACKET)? std::min(nsamps_per_buff, get_max_recv_samps_per_packet()) : @@ -156,10 +156,13 @@ size_t recv( */ size_t get_max_send_samps_per_packet(void){ if (_tx_streamer.get() == NULL){ - std::vector<size_t> chans(1, 0); - _tx_streamer = get_tx_streamer(chans); + streamer_args args; + args.cpu_format = "fc32"; + args.otw_format = "sc16"; + _tx_streamer = get_tx_streamer(args); + _send_tid = io_type_t::COMPLEX_FLOAT32; } - return _tx_streamer->get_items_per_packet(); + return _tx_streamer->get_max_num_samps(); } /*! @@ -168,10 +171,13 @@ size_t get_max_send_samps_per_packet(void){ */ size_t get_max_recv_samps_per_packet(void){ if (_rx_streamer.get() == NULL){ - std::vector<size_t> chans(1, 0); - _rx_streamer = get_rx_streamer(chans); + streamer_args args; + args.cpu_format = "fc32"; + args.otw_format = "sc16"; + _rx_streamer = get_rx_streamer(args); + _recv_tid = io_type_t::COMPLEX_FLOAT32; } - return _rx_streamer->get_items_per_packet(); + return _rx_streamer->get_max_num_samps(); } private: diff --git a/host/include/uhd/streamer.hpp b/host/include/uhd/streamer.hpp index d96eeb2b7..7a80d0f36 100644 --- a/host/include/uhd/streamer.hpp +++ b/host/include/uhd/streamer.hpp @@ -23,23 +23,30 @@ #include <uhd/types/ref_vector.hpp> #include <boost/utility.hpp> #include <boost/shared_ptr.hpp> +#include <vector> #include <string> namespace uhd{ /*! - * A streamer is the host interface to RX or TX samples. - * It represents the layer between the samples on the host - * and samples inside the device's DSP processing. + * A struct of parameters to construct a streamer. + * + * Note: + * Not all combinations of CPU and OTW format have conversion support. + * You may however write and register your own conversion routines. */ -class UHD_API streamer : boost::noncopyable{ -public: - //! Get the number of channels associated with this streamer - virtual size_t get_num_channels(void) const = 0; +struct UHD_API streamer_args{ + + //! Convenience constructor for streamer args + streamer_args( + const std::string &cpu = "fc32", + const std::string &otw = "sc16" + ){ + cpu_format = cpu; + otw_format = otw; + } /*! - * \brief Set the format for all channels in this streamer. - * * The CPU format is a string that describes the format of host memory. * Common CPU formats are: * - fc32 - complex<float> @@ -50,43 +57,47 @@ public: * - f64 - double * - s16 - int16_t * - s8 - int8_t - * + */ + std::string cpu_format; + + /*! * The OTW format is a string that describes the format over-the-wire. * Common OTW format are: * - sc16 - Q16 I16 * - sc8 - Q8_1 I8_1 Q8_0 I8_0 * - s16 - R16_1 R16_0 * - s8 - R8_3 R8_2 R8_1 R8_0 - * + */ + std::string otw_format; + + /*! * The args parameter is currently unused. Leave it blank. * The intention is that a user with a custom DSP design * may want to pass args and do something special with it. - * - * Note: - * Not all combinations of CPU and OTW format have conversion support. - * You may however write and register your own conversion routines. - * - * \param cpu_format the data format for samples used on the host - * \param otw_format the data format of the samples over the wire - * \param args optional arguments to augment the format */ - virtual void set_format( - const std::string &cpu_format, - const std::string &otw_format, - const std::string &args = "" - ) = 0; - - //! Get the number of bytes per CPU item/sample - virtual size_t get_bytes_per_cpu_item(void) const = 0; - - //! Get the number of bytes per OTW item/sample - virtual size_t get_bytes_per_otw_item(void) const = 0; + std::string args; - //! Get the max number of items/samples per packet - virtual size_t get_items_per_packet(void) const = 0; + /*! + * The channels is a list of channel numbers. + * Leave this blank to default to channel 0. + * Set channels for a multi-channel application. + * Channel mapping depends on the front-end selection. + */ + std::vector<size_t> channels; +}; - //TODO enumerate cpu and otw format options +/*! + * A streamer is the host interface to RX or TX samples. + * It represents the layer between the samples on the host + * and samples inside the device's DSP processing. + */ +class UHD_API streamer : boost::noncopyable{ +public: + //! Get the number of channels associated with this streamer + virtual size_t get_num_channels(void) const = 0; + //! Get the max number of samples per buffer per packet + virtual size_t get_max_num_samps(void) const = 0; }; //! A receive streamer to receive host samples @@ -124,7 +135,7 @@ public: */ virtual size_t recv( const buffs_type &buffs, - size_t nsamps_per_buff, + const size_t nsamps_per_buff, rx_metadata_t &metadata, double timeout = 0.1 ) = 0; @@ -161,7 +172,7 @@ public: */ virtual size_t send( const buffs_type &buffs, - size_t nsamps_per_buff, + const size_t nsamps_per_buff, const tx_metadata_t &metadata, double timeout = 0.1 ) = 0; |