From 9fc513c961775c9682123394fe5d42ef914bbbd6 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Tue, 11 Oct 2011 17:46:44 -0700 Subject: e100: performed streamer API update to e100 impl --- host/lib/usrp/e100/e100_impl.cpp | 18 ++- host/lib/usrp/e100/e100_impl.hpp | 18 +-- host/lib/usrp/e100/io_impl.cpp | 241 +++++++++++++++++++++++---------------- 3 files changed, 161 insertions(+), 116 deletions(-) (limited to 'host/lib/usrp/e100') diff --git a/host/lib/usrp/e100/e100_impl.cpp b/host/lib/usrp/e100/e100_impl.cpp index 564a05a7e..deb52b2d7 100644 --- a/host/lib/usrp/e100/e100_impl.cpp +++ b/host/lib/usrp/e100/e100_impl.cpp @@ -271,8 +271,9 @@ e100_impl::e100_impl(const uhd::device_addr_t &device_addr){ .subscribe(boost::bind(&rx_dsp_core_200::set_tick_rate, _rx_dsps[dspno], _1)); fs_path rx_dsp_path = mb_path / str(boost::format("rx_dsps/%u") % dspno); _tree->create(rx_dsp_path / "rate/value") + .set(1e6) //some default .coerce(boost::bind(&rx_dsp_core_200::set_host_rate, _rx_dsps[dspno], _1)) - .subscribe(boost::bind(&e100_impl::update_rx_samp_rate, this, _1)); + .subscribe(boost::bind(&e100_impl::update_rx_samp_rate, this, dspno, _1)); _tree->create(rx_dsp_path / "freq/value") .coerce(boost::bind(&rx_dsp_core_200::set_freq, _rx_dsps[dspno], _1)); _tree->create(rx_dsp_path / "freq/range") @@ -291,8 +292,9 @@ e100_impl::e100_impl(const uhd::device_addr_t &device_addr){ _tree->access(mb_path / "tick_rate") .subscribe(boost::bind(&tx_dsp_core_200::set_tick_rate, _tx_dsp, _1)); _tree->create(mb_path / "tx_dsps/0/rate/value") + .set(1e6) //some default .coerce(boost::bind(&tx_dsp_core_200::set_host_rate, _tx_dsp, _1)) - .subscribe(boost::bind(&e100_impl::update_tx_samp_rate, this, _1)); + .subscribe(boost::bind(&e100_impl::update_tx_samp_rate, this, 0, _1)); _tree->create(mb_path / "tx_dsps/0/freq/value") .coerce(boost::bind(&tx_dsp_core_200::set_freq, _tx_dsp, _1)); _tree->create(mb_path / "tx_dsps/0/freq/range") @@ -376,16 +378,10 @@ e100_impl::e100_impl(const uhd::device_addr_t &device_addr){ //////////////////////////////////////////////////////////////////// // do some post-init tasks //////////////////////////////////////////////////////////////////// - _tree->access(mb_path / "tick_rate").update() //update and then subscribe the clock callback - .subscribe(boost::bind(&e100_clock_ctrl::set_fpga_clock_rate, _clock_ctrl, _1)); + this->update_rates(); - //and now that the tick rate is set, init the host rates to something - BOOST_FOREACH(const std::string &name, _tree->list(mb_path / "rx_dsps")){ - _tree->access(mb_path / "rx_dsps" / name / "rate" / "value").set(1e6); - } - BOOST_FOREACH(const std::string &name, _tree->list(mb_path / "tx_dsps")){ - _tree->access(mb_path / "tx_dsps" / name / "rate" / "value").set(1e6); - } + _tree->access(mb_path / "tick_rate") //now subscribe the clock rate setter + .subscribe(boost::bind(&e100_clock_ctrl::set_fpga_clock_rate, _clock_ctrl, _1)); _tree->access(mb_path / "rx_subdev_spec").set(subdev_spec_t("A:"+_dboard_manager->get_rx_subdev_names()[0])); _tree->access(mb_path / "tx_subdev_spec").set(subdev_spec_t("A:"+_dboard_manager->get_tx_subdev_names()[0])); diff --git a/host/lib/usrp/e100/e100_impl.hpp b/host/lib/usrp/e100/e100_impl.hpp index 4b2ec5ee0..954d6bd93 100644 --- a/host/lib/usrp/e100/e100_impl.hpp +++ b/host/lib/usrp/e100/e100_impl.hpp @@ -33,11 +33,10 @@ #include #include #include -#include -#include #include #include #include +#include #ifndef INCLUDED_E100_IMPL_HPP #define INCLUDED_E100_IMPL_HPP @@ -78,11 +77,9 @@ public: ~e100_impl(void); //the io interface - size_t send(const send_buffs_type &, size_t, const uhd::tx_metadata_t &, const uhd::io_type_t &, send_mode_t, double); - size_t recv(const recv_buffs_type &, size_t, uhd::rx_metadata_t &, const uhd::io_type_t &, recv_mode_t, double); + uhd::rx_streamer::sptr get_rx_stream(const uhd::stream_args_t &args); + uhd::tx_streamer::sptr get_tx_stream(const uhd::stream_args_t &args); bool recv_async_msg(uhd::async_metadata_t &, double); - size_t get_max_send_samps_per_packet(void) const; - size_t get_max_recv_samps_per_packet(void) const; private: uhd::property_tree::sptr _tree; @@ -110,7 +107,6 @@ private: uhd::usrp::dboard_iface::sptr _dboard_iface; //handle io stuff - uhd::otw_type_t _rx_otw_type, _tx_otw_type; UHD_PIMPL_DECL(io_impl) _io_impl; void io_init(void); @@ -119,12 +115,16 @@ private: return _tree; } + std::vector > _rx_streamers; + std::vector > _tx_streamers; + double update_rx_codec_gain(const double); //sets A and B at once void set_mb_eeprom(const uhd::usrp::mboard_eeprom_t &); void set_db_eeprom(const std::string &, const uhd::usrp::dboard_eeprom_t &); void update_tick_rate(const double rate); - void update_rx_samp_rate(const double rate); - void update_tx_samp_rate(const double rate); + void update_rx_samp_rate(const size_t, const double rate); + void update_tx_samp_rate(const size_t, const double rate); + void update_rates(void); void update_rx_subdev_spec(const uhd::usrp::subdev_spec_t &); void update_tx_subdev_spec(const uhd::usrp::subdev_spec_t &); void update_clock_source(const std::string &); diff --git a/host/lib/usrp/e100/io_impl.cpp b/host/lib/usrp/e100/io_impl.cpp index 0b81c1a86..5936ee2d7 100644 --- a/host/lib/usrp/e100/io_impl.cpp +++ b/host/lib/usrp/e100/io_impl.cpp @@ -35,6 +35,7 @@ #include //open, close #include #include +#include using namespace uhd; using namespace uhd::usrp; @@ -60,10 +61,6 @@ struct e100_impl::io_impl{ //which is after the states and booty which may hold managed buffers. recv_packet_demuxer::sptr demuxer; - //state management for the vrt packet handler code - sph::recv_packet_handler recv_handler; - sph::send_packet_handler send_handler; - //a pirate's life is the life for me! void recv_pirate_loop( spi_iface::sptr //keep a sptr to iface which shares gpio147 @@ -159,16 +156,6 @@ void e100_impl::io_impl::handle_irq(void){ **********************************************************************/ void e100_impl::io_init(void){ - //setup rx otw type - _rx_otw_type.width = 16; - _rx_otw_type.shift = 0; - _rx_otw_type.byteorder = uhd::otw_type_t::BO_LITTLE_ENDIAN; - - //setup tx otw type - _tx_otw_type.width = 16; - _tx_otw_type.shift = 0; - _tx_otw_type.byteorder = uhd::otw_type_t::BO_LITTLE_ENDIAN; - //create new io impl _io_impl = UHD_PIMPL_MAKE(io_impl, ()); _io_impl->demuxer = recv_packet_demuxer::make(_data_transport, _rx_dsps.size(), E100_RX_SID_BASE); @@ -178,6 +165,10 @@ void e100_impl::io_init(void){ _fpga_ctrl->poke32(E100_REG_CLEAR_RX, 0); _fpga_ctrl->poke32(E100_REG_CLEAR_TX, 0); + //allocate streamer weak ptrs containers + _rx_streamers.resize(_rx_dsps.size()); + _tx_streamers.resize(1/*known to be 1 dsp*/); + //prepare the async msg buffer for incoming messages _fpga_ctrl->poke32(E100_REG_SR_ERR_CTRL, 1 << 0); //clear while ((_fpga_ctrl->peek32(E100_REG_RB_ERR_STATUS) & (1 << 2)) == 0){} //wait for idle @@ -187,37 +178,58 @@ void e100_impl::io_init(void){ _io_impl->pirate_task = task::make(boost::bind( &e100_impl::io_impl::recv_pirate_loop, _io_impl.get(), _aux_spi_iface )); - - //init some handler stuff - _io_impl->recv_handler.set_vrt_unpacker(&vrt::if_hdr_unpack_le); - _io_impl->recv_handler.set_converter(_rx_otw_type); - _io_impl->send_handler.set_vrt_packer(&vrt::if_hdr_pack_le); - _io_impl->send_handler.set_converter(_tx_otw_type); - _io_impl->send_handler.set_max_samples_per_packet(get_max_send_samps_per_packet()); } void e100_impl::update_tick_rate(const double rate){ _io_impl->tick_rate = rate; - boost::mutex::scoped_lock recv_lock = _io_impl->recv_handler.get_scoped_lock(); - _io_impl->recv_handler.set_tick_rate(rate); - boost::mutex::scoped_lock send_lock = _io_impl->send_handler.get_scoped_lock(); - _io_impl->send_handler.set_tick_rate(rate); + + //update the tick rate on all existing streamers -> thread safe + for (size_t i = 0; i < _rx_streamers.size(); i++){ + boost::shared_ptr my_streamer = + boost::dynamic_pointer_cast(_rx_streamers[i].lock()); + if (my_streamer.get() == NULL) continue; + my_streamer->set_tick_rate(rate); + } + for (size_t i = 0; i < _tx_streamers.size(); i++){ + boost::shared_ptr my_streamer = + boost::dynamic_pointer_cast(_tx_streamers[i].lock()); + if (my_streamer.get() == NULL) continue; + my_streamer->set_tick_rate(rate); + } } -void e100_impl::update_rx_samp_rate(const double rate){ - boost::mutex::scoped_lock recv_lock = _io_impl->recv_handler.get_scoped_lock(); - _io_impl->recv_handler.set_samp_rate(rate); - const double adj = _rx_dsps.front()->get_scaling_adjustment(); - _io_impl->recv_handler.set_scale_factor(adj/32767.); +void e100_impl::update_rx_samp_rate(const size_t dspno, const double rate){ + boost::shared_ptr my_streamer = + boost::dynamic_pointer_cast(_rx_streamers[dspno].lock()); + if (my_streamer.get() == NULL) return; + + my_streamer->set_samp_rate(rate); + const double adj = _rx_dsps[dspno]->get_scaling_adjustment(); + my_streamer->set_scale_factor(adj); +} + +void e100_impl::update_tx_samp_rate(const size_t dspno, const double rate){ + boost::shared_ptr my_streamer = + boost::dynamic_pointer_cast(_tx_streamers[dspno].lock()); + if (my_streamer.get() == NULL) return; + + my_streamer->set_samp_rate(rate); } -void e100_impl::update_tx_samp_rate(const double rate){ - boost::mutex::scoped_lock send_lock = _io_impl->send_handler.get_scoped_lock(); - _io_impl->send_handler.set_samp_rate(rate); +void e100_impl::update_rates(void){ + const fs_path mb_path = "/mboards/0"; + _tree->access(mb_path / "tick_rate").update(); + + //and now that the tick rate is set, init the host rates to something + BOOST_FOREACH(const std::string &name, _tree->list(mb_path / "rx_dsps")){ + _tree->access(mb_path / "rx_dsps" / name / "rate" / "value").update(); + } + BOOST_FOREACH(const std::string &name, _tree->list(mb_path / "tx_dsps")){ + _tree->access(mb_path / "tx_dsps" / name / "rate" / "value").update(); + } } void e100_impl::update_rx_subdev_spec(const uhd::usrp::subdev_spec_t &spec){ - boost::mutex::scoped_lock recv_lock = _io_impl->recv_handler.get_scoped_lock(); fs_path root = "/mboards/0/dboards"; //sanity checking @@ -231,22 +243,9 @@ void e100_impl::update_rx_subdev_spec(const uhd::usrp::subdev_spec_t &spec){ _rx_dsps[i]->set_mux(conn, fe_swapped); } _rx_fe->set_mux(fe_swapped); - - //resize for the new occupancy - _io_impl->recv_handler.resize(spec.size()); - - //bind new callbacks for the handler - for (size_t i = 0; i < _io_impl->recv_handler.size(); i++){ - _rx_dsps[i]->set_nsamps_per_packet(get_max_recv_samps_per_packet()); //seems to be a good place to set this - _io_impl->recv_handler.set_xport_chan_get_buff(i, boost::bind( - &recv_packet_demuxer::get_recv_buff, _io_impl->demuxer, i, _1 - )); - _io_impl->recv_handler.set_overflow_handler(i, boost::bind(&rx_dsp_core_200::handle_overflow, _rx_dsps[i])); - } } void e100_impl::update_tx_subdev_spec(const uhd::usrp::subdev_spec_t &spec){ - boost::mutex::scoped_lock send_lock = _io_impl->send_handler.get_scoped_lock(); fs_path root = "/mboards/0/dboards"; //sanity checking @@ -255,73 +254,123 @@ void e100_impl::update_tx_subdev_spec(const uhd::usrp::subdev_spec_t &spec){ //set the mux for this spec const std::string conn = _tree->access(root / spec[0].db_name / "tx_frontends" / spec[0].sd_name / "connection").get(); _tx_fe->set_mux(conn); +} - //resize for the new occupancy - _io_impl->send_handler.resize(spec.size()); - - //bind new callbacks for the handler - for (size_t i = 0; i < _io_impl->send_handler.size(); i++){ - _io_impl->send_handler.set_xport_chan_get_buff(i, boost::bind( - &zero_copy_if::get_send_buff, _data_transport, _1 - )); - } +/*********************************************************************** + * Async Recv + **********************************************************************/ +bool e100_impl::recv_async_msg( + async_metadata_t &async_metadata, double timeout +){ + boost::this_thread::disable_interruption di; //disable because the wait can throw + return _io_impl->async_msg_fifo.pop_with_timed_wait(async_metadata, timeout); } /*********************************************************************** - * Data Send + * Receive streamer **********************************************************************/ -size_t e100_impl::get_max_send_samps_per_packet(void) const{ +rx_streamer::sptr e100_impl::get_rx_stream(const uhd::stream_args_t &args_){ + stream_args_t args = args_; + + //setup defaults for unspecified values + args.otw_format = args.otw_format.empty()? "sc16" : args.otw_format; + args.channels = args.channels.empty()? std::vector(1, 0) : args.channels; + + //calculate packet size static const size_t hdr_size = 0 + vrt::max_if_hdr_words32*sizeof(boost::uint32_t) + + sizeof(vrt::if_packet_info_t().tlr) //forced to have trailer - sizeof(vrt::if_packet_info_t().cid) //no class id ever used ; - size_t bpp = _data_transport->get_send_frame_size() - hdr_size; - return bpp/_tx_otw_type.get_sample_size(); -} + const size_t bpp = _data_transport->get_recv_frame_size() - hdr_size; + const size_t spp = bpp/convert::get_bytes_per_item(args.otw_format); + + //make the new streamer given the samples per packet + boost::shared_ptr my_streamer = boost::make_shared(spp); + + //init some streamer stuff + my_streamer->resize(args.channels.size()); + my_streamer->set_vrt_unpacker(&vrt::if_hdr_unpack_le); + + //set the converter + uhd::convert::id_type id; + id.input_markup = args.otw_format + "_item32_le"; + id.num_inputs = 1; + id.output_markup = args.cpu_format; + id.num_outputs = 1; + id.args = args.args; + my_streamer->set_converter(id); + + //bind callbacks for the handler + for (size_t chan_i = 0; chan_i < args.channels.size(); chan_i++){ + const size_t dsp = args.channels[chan_i]; + _rx_dsps[dsp]->set_nsamps_per_packet(spp); //seems to be a good place to set this + _rx_dsps[dsp]->set_format(args.otw_format, 0x400); + my_streamer->set_xport_chan_get_buff(chan_i, boost::bind( + &recv_packet_demuxer::get_recv_buff, _io_impl->demuxer, dsp, _1 + )); + my_streamer->set_overflow_handler(chan_i, boost::bind( + &rx_dsp_core_200::handle_overflow, _rx_dsps[dsp] + )); + _rx_streamers[dsp] = my_streamer; //store weak pointer + } -size_t e100_impl::send( - const send_buffs_type &buffs, size_t nsamps_per_buff, - const tx_metadata_t &metadata, const io_type_t &io_type, - send_mode_t send_mode, double timeout -){ - return _io_impl->send_handler.send( - buffs, nsamps_per_buff, - metadata, io_type, - send_mode, timeout - ); + //sets all tick and samp rates on this streamer + this->update_rates(); + + return my_streamer; } /*********************************************************************** - * Data Recv + * Transmit streamer **********************************************************************/ -size_t e100_impl::get_max_recv_samps_per_packet(void) const{ +tx_streamer::sptr e100_impl::get_tx_stream(const uhd::stream_args_t &args_){ + stream_args_t args = args_; + + //setup defaults for unspecified values + args.otw_format = args.otw_format.empty()? "sc16" : args.otw_format; + args.channels = args.channels.empty()? std::vector(1, 0) : args.channels; + + if (args.otw_format != "sc16"){ + throw uhd::value_error("USRP TX cannot handle requested wire format: " + args.otw_format); + } + + //calculate packet size static const size_t hdr_size = 0 + vrt::max_if_hdr_words32*sizeof(boost::uint32_t) - + sizeof(vrt::if_packet_info_t().tlr) //forced to have trailer - sizeof(vrt::if_packet_info_t().cid) //no class id ever used ; - size_t bpp = _data_transport->get_recv_frame_size() - hdr_size; - return bpp/_rx_otw_type.get_sample_size(); -} + static const size_t bpp = _data_transport->get_send_frame_size() - hdr_size; + const size_t spp = bpp/convert::get_bytes_per_item(args.otw_format); + + //make the new streamer given the samples per packet + boost::shared_ptr my_streamer = boost::make_shared(spp); + + //init some streamer stuff + my_streamer->resize(args.channels.size()); + my_streamer->set_vrt_packer(&vrt::if_hdr_pack_le); + + //set the converter + uhd::convert::id_type id; + id.input_markup = args.cpu_format; + id.num_inputs = 1; + id.output_markup = args.otw_format + "_item32_le"; + id.num_outputs = 1; + id.args = args.args; + my_streamer->set_converter(id); + + //bind callbacks for the handler + for (size_t chan_i = 0; chan_i < args.channels.size(); chan_i++){ + const size_t dsp = args.channels[chan_i]; + UHD_ASSERT_THROW(dsp == 0); //always 0 + my_streamer->set_xport_chan_get_buff(chan_i, boost::bind( + &zero_copy_if::get_send_buff, _data_transport, _1 + )); + _tx_streamers[dsp] = my_streamer; //store weak pointer + } -size_t e100_impl::recv( - const recv_buffs_type &buffs, size_t nsamps_per_buff, - rx_metadata_t &metadata, const io_type_t &io_type, - recv_mode_t recv_mode, double timeout -){ - return _io_impl->recv_handler.recv( - buffs, nsamps_per_buff, - metadata, io_type, - recv_mode, timeout - ); -} + //sets all tick and samp rates on this streamer + this->update_rates(); -/*********************************************************************** - * Async Recv - **********************************************************************/ -bool e100_impl::recv_async_msg( - async_metadata_t &async_metadata, double timeout -){ - boost::this_thread::disable_interruption di; //disable because the wait can throw - return _io_impl->async_msg_fifo.pop_with_timed_wait(async_metadata, timeout); + return my_streamer; } -- cgit v1.2.3 From c885da11389ee275f9c5206b9f8a2155a5393a8a Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Wed, 12 Oct 2011 00:39:04 -0700 Subject: uhd: renamed convert markup to format removed convert args added simd level got orc and neon updated --- host/include/uhd/convert.hpp | 16 ++++----- host/lib/convert/convert_common.hpp | 16 ++++----- host/lib/convert/convert_fc32_with_sse2.cpp | 8 ++--- host/lib/convert/convert_fc64_with_sse2.cpp | 8 ++--- host/lib/convert/convert_impl.cpp | 37 +++++++++----------- host/lib/convert/convert_with_neon.cpp | 8 ++--- host/lib/convert/convert_with_orc.cpp | 12 +++---- host/lib/transport/super_recv_packet_handler.hpp | 4 +-- host/lib/transport/super_send_packet_handler.hpp | 4 +-- host/lib/usrp/b100/io_impl.cpp | 10 +++--- host/lib/usrp/e100/io_impl.cpp | 10 +++--- host/lib/usrp/usrp1/io_impl.cpp | 10 +++--- host/lib/usrp/usrp2/io_impl.cpp | 10 +++--- host/tests/convert_test.cpp | 44 ++++++++++++------------ host/tests/sph_recv_test.cpp | 28 +++++++-------- host/tests/sph_send_test.cpp | 8 ++--- 16 files changed, 110 insertions(+), 123 deletions(-) (limited to 'host/lib/usrp/e100') diff --git a/host/include/uhd/convert.hpp b/host/include/uhd/convert.hpp index a0b502ab0..c42edfdec 100644 --- a/host/include/uhd/convert.hpp +++ b/host/include/uhd/convert.hpp @@ -42,17 +42,17 @@ namespace uhd{ namespace convert{ enum priority_type{ PRIORITY_GENERAL = 0, PRIORITY_LIBORC = 1, - PRIORITY_CUSTOM = 2, + PRIORITY_SIMD = 2, + PRIORITY_CUSTOM = 3, PRIORITY_EMPTY = -1, }; //! Identify a conversion routine in the registry struct id_type : boost::equality_comparable{ - std::string input_markup; + std::string input_format; size_t num_inputs; - std::string output_markup; + std::string output_format; size_t num_outputs; - std::string args; std::string to_pp_string(void) const; }; @@ -80,15 +80,15 @@ namespace uhd{ namespace convert{ /*! * Register the size of a particular item. - * \param markup the item markup + * \param format the item format * \param size the size in bytes */ UHD_API void register_bytes_per_item( - const std::string &markup, const size_t size + const std::string &format, const size_t size ); - //! Convert an item markup to a size in bytes - UHD_API size_t get_bytes_per_item(const std::string &markup); + //! Convert an item format to a size in bytes + UHD_API size_t get_bytes_per_item(const std::string &format); }} //namespace diff --git a/host/lib/convert/convert_common.hpp b/host/lib/convert/convert_common.hpp index 56b718292..34fb848c3 100644 --- a/host/lib/convert/convert_common.hpp +++ b/host/lib/convert/convert_common.hpp @@ -23,30 +23,28 @@ #include #include -#define _DECLARE_CONVERTER(fcn, in_mark, num_in, out_mark, num_out, prio) \ +#define _DECLARE_CONVERTER(fcn, in_form, num_in, out_form, num_out, prio) \ static void fcn( \ const uhd::convert::input_type &inputs, \ const uhd::convert::output_type &outputs, \ - const size_t nsamps, \ - const double scale_factor \ + const size_t nsamps, const double scale_factor \ ); \ UHD_STATIC_BLOCK(__register_##fcn##_##prio){ \ uhd::convert::id_type id; \ - id.input_markup = #in_mark; \ + id.input_format = #in_form; \ id.num_inputs = num_in; \ - id.output_markup = #out_mark; \ + id.output_format = #out_form; \ id.num_outputs = num_out; \ uhd::convert::register_converter(id, fcn, prio); \ } \ static void fcn( \ const uhd::convert::input_type &inputs, \ const uhd::convert::output_type &outputs, \ - const size_t nsamps, \ - const double scale_factor \ + const size_t nsamps, const double scale_factor \ ) -#define DECLARE_CONVERTER(in_mark, num_in, out_mark, num_out, prio) \ - _DECLARE_CONVERTER(__convert_##in_mark##_##num_in##_##out_mark##_##num_out, in_mark, num_in, out_mark, num_out, prio) +#define DECLARE_CONVERTER(in_form, num_in, out_form, num_out, prio) \ + _DECLARE_CONVERTER(__convert_##in_form##_##num_in##_##out_form##_##num_out, in_form, num_in, out_form, num_out, prio) /*********************************************************************** * Typedefs diff --git a/host/lib/convert/convert_fc32_with_sse2.cpp b/host/lib/convert/convert_fc32_with_sse2.cpp index b8d1aa8cc..24a939d6c 100644 --- a/host/lib/convert/convert_fc32_with_sse2.cpp +++ b/host/lib/convert/convert_fc32_with_sse2.cpp @@ -21,7 +21,7 @@ using namespace uhd::convert; -DECLARE_CONVERTER(fc32, 1, sc16_item32_le, 1, PRIORITY_CUSTOM){ +DECLARE_CONVERTER(fc32, 1, sc16_item32_le, 1, PRIORITY_SIMD){ const fc32_t *input = reinterpret_cast(inputs[0]); item32_t *output = reinterpret_cast(outputs[0]); @@ -64,7 +64,7 @@ DECLARE_CONVERTER(fc32, 1, sc16_item32_le, 1, PRIORITY_CUSTOM){ } } -DECLARE_CONVERTER(fc32, 1, sc16_item32_be, 1, PRIORITY_CUSTOM){ +DECLARE_CONVERTER(fc32, 1, sc16_item32_be, 1, PRIORITY_SIMD){ const fc32_t *input = reinterpret_cast(inputs[0]); item32_t *output = reinterpret_cast(outputs[0]); @@ -106,7 +106,7 @@ DECLARE_CONVERTER(fc32, 1, sc16_item32_be, 1, PRIORITY_CUSTOM){ } } -DECLARE_CONVERTER(sc16_item32_le, 1, fc32, 1, PRIORITY_CUSTOM){ +DECLARE_CONVERTER(sc16_item32_le, 1, fc32, 1, PRIORITY_SIMD){ const item32_t *input = reinterpret_cast(inputs[0]); fc32_t *output = reinterpret_cast(outputs[0]); @@ -151,7 +151,7 @@ DECLARE_CONVERTER(sc16_item32_le, 1, fc32, 1, PRIORITY_CUSTOM){ } } -DECLARE_CONVERTER(sc16_item32_be, 1, fc32, 1, PRIORITY_CUSTOM){ +DECLARE_CONVERTER(sc16_item32_be, 1, fc32, 1, PRIORITY_SIMD){ const item32_t *input = reinterpret_cast(inputs[0]); fc32_t *output = reinterpret_cast(outputs[0]); diff --git a/host/lib/convert/convert_fc64_with_sse2.cpp b/host/lib/convert/convert_fc64_with_sse2.cpp index a4f2df2e7..837bb584e 100644 --- a/host/lib/convert/convert_fc64_with_sse2.cpp +++ b/host/lib/convert/convert_fc64_with_sse2.cpp @@ -21,7 +21,7 @@ using namespace uhd::convert; -DECLARE_CONVERTER(fc64, 1, sc16_item32_le, 1, PRIORITY_CUSTOM){ +DECLARE_CONVERTER(fc64, 1, sc16_item32_le, 1, PRIORITY_SIMD){ const fc64_t *input = reinterpret_cast(inputs[0]); item32_t *output = reinterpret_cast(outputs[0]); @@ -68,7 +68,7 @@ DECLARE_CONVERTER(fc64, 1, sc16_item32_le, 1, PRIORITY_CUSTOM){ } } -DECLARE_CONVERTER(fc64, 1, sc16_item32_be, 1, PRIORITY_CUSTOM){ +DECLARE_CONVERTER(fc64, 1, sc16_item32_be, 1, PRIORITY_SIMD){ const fc64_t *input = reinterpret_cast(inputs[0]); item32_t *output = reinterpret_cast(outputs[0]); @@ -114,7 +114,7 @@ DECLARE_CONVERTER(fc64, 1, sc16_item32_be, 1, PRIORITY_CUSTOM){ } } -DECLARE_CONVERTER(sc16_item32_le, 1, fc64, 1, PRIORITY_CUSTOM){ +DECLARE_CONVERTER(sc16_item32_le, 1, fc64, 1, PRIORITY_SIMD){ const item32_t *input = reinterpret_cast(inputs[0]); fc64_t *output = reinterpret_cast(outputs[0]); @@ -163,7 +163,7 @@ DECLARE_CONVERTER(sc16_item32_le, 1, fc64, 1, PRIORITY_CUSTOM){ } } -DECLARE_CONVERTER(sc16_item32_be, 1, fc64, 1, PRIORITY_CUSTOM){ +DECLARE_CONVERTER(sc16_item32_be, 1, fc64, 1, PRIORITY_SIMD){ const item32_t *input = reinterpret_cast(inputs[0]); fc64_t *output = reinterpret_cast(outputs[0]); diff --git a/host/lib/convert/convert_impl.cpp b/host/lib/convert/convert_impl.cpp index 280957c2a..df03b44f9 100644 --- a/host/lib/convert/convert_impl.cpp +++ b/host/lib/convert/convert_impl.cpp @@ -27,29 +27,26 @@ using namespace uhd; bool convert::operator==(const convert::id_type &lhs, const convert::id_type &rhs){ - return - (lhs.input_markup == rhs.input_markup) and - (lhs.num_inputs == rhs.num_inputs) and - (lhs.output_markup == rhs.output_markup) and - (lhs.num_outputs == rhs.num_outputs) and - (lhs.args == rhs.args) + return true + and (lhs.input_format == rhs.input_format) + and (lhs.num_inputs == rhs.num_inputs) + and (lhs.output_format == rhs.output_format) + and (lhs.num_outputs == rhs.num_outputs) ; } std::string convert::id_type::to_pp_string(void) const{ return str(boost::format( "conversion ID\n" - " Input markup: %s\n" + " Input format: %s\n" " Num inputs: %d\n" - " Output markup: %s\n" + " Output format: %s\n" " Num outputs: %d\n" - " Optional args: %s\n" ) - % this->input_markup + % this->input_format % this->num_inputs - % this->output_markup + % this->output_format % this->num_outputs - % this->args ); } @@ -101,30 +98,30 @@ convert::function_type convert::get_converter(const id_type &id){ } /*********************************************************************** - * Mappings for item markup to byte size for all items we can + * Mappings for item format to byte size for all items we can **********************************************************************/ typedef uhd::dict item_size_type; UHD_SINGLETON_FCN(item_size_type, get_item_size_table); void register_bytes_per_item( - const std::string &markup, const size_t size + const std::string &format, const size_t size ){ - get_item_size_table()[markup] = size; + get_item_size_table()[format] = size; } -size_t convert::get_bytes_per_item(const std::string &markup){ - if (get_item_size_table().has_key(markup)) return get_item_size_table()[markup]; +size_t convert::get_bytes_per_item(const std::string &format){ + if (get_item_size_table().has_key(format)) return get_item_size_table()[format]; //OK. I am sorry about this. //We didnt find a match, so lets find a match for the first term. //This is partially a hack because of the way I append strings. //But as long as life is kind, we can keep this. - const size_t pos = markup.find("_"); + const size_t pos = format.find("_"); if (pos != std::string::npos){ - return get_bytes_per_item(markup.substr(0, pos)); + return get_bytes_per_item(format.substr(0, pos)); } - throw uhd::key_error("Cannot find an item size:\n" + markup); + throw uhd::key_error("Cannot find an item size:\n" + format); } UHD_STATIC_BLOCK(convert_register_item_sizes){ diff --git a/host/lib/convert/convert_with_neon.cpp b/host/lib/convert/convert_with_neon.cpp index e5f08cad9..c7ad62104 100644 --- a/host/lib/convert/convert_with_neon.cpp +++ b/host/lib/convert/convert_with_neon.cpp @@ -20,7 +20,7 @@ using namespace uhd::convert; -DECLARE_CONVERTER(convert_fc32_1_to_item32_1_nswap, PRIORITY_CUSTOM){ +DECLARE_CONVERTER(fc32, 1, sc16_item32_le, 1, PRIORITY_SIMD){ const fc32_t *input = reinterpret_cast(inputs[0]); item32_t *output = reinterpret_cast(outputs[0]); @@ -37,10 +37,10 @@ DECLARE_CONVERTER(convert_fc32_1_to_item32_1_nswap, PRIORITY_CUSTOM){ } for (; i < nsamps; i++) - output[i] = fc32_to_item32(input[i], float(scale_factor)); + output[i] = fc32_to_item32_sc16(input[i], scale_factor); } -DECLARE_CONVERTER(convert_item32_1_to_fc32_1_nswap, PRIORITY_CUSTOM){ +DECLARE_CONVERTER(sc16_item32_le, 1, fc32, 1, PRIORITY_SIMD){ const item32_t *input = reinterpret_cast(inputs[0]); fc32_t *output = reinterpret_cast(outputs[0]); @@ -57,5 +57,5 @@ DECLARE_CONVERTER(convert_item32_1_to_fc32_1_nswap, PRIORITY_CUSTOM){ } for (; i < nsamps; i++) - output[i] = item32_to_fc32(input[i], float(scale_factor)); + output[i] = item32_sc16_to_fc32(input[i], scale_factor); } diff --git a/host/lib/convert/convert_with_orc.cpp b/host/lib/convert/convert_with_orc.cpp index 844c2595c..0c46bcf1e 100644 --- a/host/lib/convert/convert_with_orc.cpp +++ b/host/lib/convert/convert_with_orc.cpp @@ -29,26 +29,26 @@ extern void _convert_sc16_1_to_item32_1_nswap_orc(void *, const void *, float, i extern void _convert_item32_1_to_sc16_1_nswap_orc(void *, const void *, float, int); } -DECLARE_CONVERTER(convert_fc32_1_to_item32_1_nswap, PRIORITY_LIBORC){ +DECLARE_CONVERTER(fc32, 1, sc16_item32_le, 1, PRIORITY_LIBORC){ _convert_fc32_1_to_item32_1_nswap_orc(outputs[0], inputs[0], scale_factor, nsamps); } -DECLARE_CONVERTER(convert_fc32_1_to_item32_1_bswap, PRIORITY_LIBORC){ +DECLARE_CONVERTER(fc32, 1, sc16_item32_be, 1, PRIORITY_LIBORC){ _convert_fc32_1_to_item32_1_bswap_orc(outputs[0], inputs[0], scale_factor, nsamps); } -DECLARE_CONVERTER(convert_item32_1_to_fc32_1_nswap, PRIORITY_LIBORC){ +DECLARE_CONVERTER(sc16_item32_le, 1, fc32, 1, PRIORITY_LIBORC){ _convert_item32_1_to_fc32_1_nswap_orc(outputs[0], inputs[0], scale_factor, nsamps); } -DECLARE_CONVERTER(convert_item32_1_to_fc32_1_bswap, PRIORITY_LIBORC){ +DECLARE_CONVERTER(sc16_item32_be, 1, fc32, 1, PRIORITY_LIBORC){ _convert_item32_1_to_fc32_1_bswap_orc(outputs[0], inputs[0], scale_factor, nsamps); } -DECLARE_CONVERTER(convert_sc16_1_to_item32_1_nswap, PRIORITY_LIBORC){ +DECLARE_CONVERTER(sc16, 1, sc16_item32_le, 1, PRIORITY_LIBORC){ _convert_sc16_1_to_item32_1_nswap_orc(outputs[0], inputs[0], scale_factor, nsamps); } -DECLARE_CONVERTER(convert_item32_1_to_sc16_1_nswap, PRIORITY_LIBORC){ +DECLARE_CONVERTER(sc16_item32_le, 1, sc16, 1, PRIORITY_LIBORC){ _convert_item32_1_to_sc16_1_nswap_orc(outputs[0], inputs[0], scale_factor, nsamps); } diff --git a/host/lib/transport/super_recv_packet_handler.hpp b/host/lib/transport/super_recv_packet_handler.hpp index 6762a8a00..2310d6aea 100644 --- a/host/lib/transport/super_recv_packet_handler.hpp +++ b/host/lib/transport/super_recv_packet_handler.hpp @@ -125,8 +125,8 @@ public: void set_converter(const uhd::convert::id_type &id){ _io_buffs.resize(id.num_outputs); _converter = uhd::convert::get_converter(id); - _bytes_per_otw_item = uhd::convert::get_bytes_per_item(id.input_markup); - _bytes_per_cpu_item = uhd::convert::get_bytes_per_item(id.output_markup); + _bytes_per_otw_item = uhd::convert::get_bytes_per_item(id.input_format); + _bytes_per_cpu_item = uhd::convert::get_bytes_per_item(id.output_format); } //! Set the transport channel's overflow handler diff --git a/host/lib/transport/super_send_packet_handler.hpp b/host/lib/transport/super_send_packet_handler.hpp index 5b5ee2981..779259d4f 100644 --- a/host/lib/transport/super_send_packet_handler.hpp +++ b/host/lib/transport/super_send_packet_handler.hpp @@ -101,8 +101,8 @@ public: void set_converter(const uhd::convert::id_type &id){ _io_buffs.resize(id.num_inputs); _converter = uhd::convert::get_converter(id); - _bytes_per_otw_item = uhd::convert::get_bytes_per_item(id.output_markup); - _bytes_per_cpu_item = uhd::convert::get_bytes_per_item(id.input_markup); + _bytes_per_otw_item = uhd::convert::get_bytes_per_item(id.output_format); + _bytes_per_cpu_item = uhd::convert::get_bytes_per_item(id.input_format); } /*! diff --git a/host/lib/usrp/b100/io_impl.cpp b/host/lib/usrp/b100/io_impl.cpp index 82298dca6..28b19f14e 100644 --- a/host/lib/usrp/b100/io_impl.cpp +++ b/host/lib/usrp/b100/io_impl.cpp @@ -218,11 +218,10 @@ rx_streamer::sptr b100_impl::get_rx_stream(const uhd::stream_args_t &args_){ //set the converter uhd::convert::id_type id; - id.input_markup = args.otw_format + "_item32_le"; + id.input_format = args.otw_format + "_item32_le"; id.num_inputs = 1; - id.output_markup = args.cpu_format; + id.output_format = args.cpu_format; id.num_outputs = 1; - id.args = args.args; my_streamer->set_converter(id); //bind callbacks for the handler @@ -276,11 +275,10 @@ tx_streamer::sptr b100_impl::get_tx_stream(const uhd::stream_args_t &args_){ //set the converter uhd::convert::id_type id; - id.input_markup = args.cpu_format; + id.input_format = args.cpu_format; id.num_inputs = 1; - id.output_markup = args.otw_format + "_item32_le"; + id.output_format = args.otw_format + "_item32_le"; id.num_outputs = 1; - id.args = args.args; my_streamer->set_converter(id); //bind callbacks for the handler diff --git a/host/lib/usrp/e100/io_impl.cpp b/host/lib/usrp/e100/io_impl.cpp index 5936ee2d7..c47eb8940 100644 --- a/host/lib/usrp/e100/io_impl.cpp +++ b/host/lib/usrp/e100/io_impl.cpp @@ -294,11 +294,10 @@ rx_streamer::sptr e100_impl::get_rx_stream(const uhd::stream_args_t &args_){ //set the converter uhd::convert::id_type id; - id.input_markup = args.otw_format + "_item32_le"; + id.input_format = args.otw_format + "_item32_le"; id.num_inputs = 1; - id.output_markup = args.cpu_format; + id.output_format = args.cpu_format; id.num_outputs = 1; - id.args = args.args; my_streamer->set_converter(id); //bind callbacks for the handler @@ -352,11 +351,10 @@ tx_streamer::sptr e100_impl::get_tx_stream(const uhd::stream_args_t &args_){ //set the converter uhd::convert::id_type id; - id.input_markup = args.cpu_format; + id.input_format = args.cpu_format; id.num_inputs = 1; - id.output_markup = args.otw_format + "_item32_le"; + id.output_format = args.otw_format + "_item32_le"; id.num_outputs = 1; - id.args = args.args; my_streamer->set_converter(id); //bind callbacks for the handler diff --git a/host/lib/usrp/usrp1/io_impl.cpp b/host/lib/usrp/usrp1/io_impl.cpp index f46f4741b..534d33959 100644 --- a/host/lib/usrp/usrp1/io_impl.cpp +++ b/host/lib/usrp/usrp1/io_impl.cpp @@ -600,11 +600,10 @@ rx_streamer::sptr usrp1_impl::get_rx_stream(const uhd::stream_args_t &args_){ //set the converter uhd::convert::id_type id; - id.input_markup = args.otw_format + "_item16_usrp1"; + id.input_format = args.otw_format + "_item16_usrp1"; id.num_inputs = 1; - id.output_markup = args.cpu_format; + id.output_format = args.cpu_format; id.num_outputs = args.channels.size(); - id.args = args.args; my_streamer->set_converter(id); //save as weak ptr for update access @@ -653,11 +652,10 @@ tx_streamer::sptr usrp1_impl::get_tx_stream(const uhd::stream_args_t &args_){ //set the converter uhd::convert::id_type id; - id.input_markup = args.cpu_format; + id.input_format = args.cpu_format; id.num_inputs = args.channels.size(); - id.output_markup = args.otw_format + "_item16_usrp1"; + id.output_format = args.otw_format + "_item16_usrp1"; id.num_outputs = 1; - id.args = args.args; my_streamer->set_converter(id); //save as weak ptr for update access diff --git a/host/lib/usrp/usrp2/io_impl.cpp b/host/lib/usrp/usrp2/io_impl.cpp index f1d0aee2a..660156285 100644 --- a/host/lib/usrp/usrp2/io_impl.cpp +++ b/host/lib/usrp/usrp2/io_impl.cpp @@ -391,11 +391,10 @@ rx_streamer::sptr usrp2_impl::get_rx_stream(const uhd::stream_args_t &args_){ //set the converter uhd::convert::id_type id; - id.input_markup = args.otw_format + "_item32_be"; + id.input_format = args.otw_format + "_item32_be"; id.num_inputs = 1; - id.output_markup = args.cpu_format; + id.output_format = args.cpu_format; id.num_outputs = 1; - id.args = args.args; my_streamer->set_converter(id); //bind callbacks for the handler @@ -459,11 +458,10 @@ tx_streamer::sptr usrp2_impl::get_tx_stream(const uhd::stream_args_t &args_){ //set the converter uhd::convert::id_type id; - id.input_markup = args.cpu_format; + id.input_format = args.cpu_format; id.num_inputs = 1; - id.output_markup = args.otw_format + "_item32_be"; + id.output_format = args.otw_format + "_item32_be"; id.num_outputs = 1; - id.args = args.args; my_streamer->set_converter(id); //bind callbacks for the handler diff --git a/host/tests/convert_test.cpp b/host/tests/convert_test.cpp index 9dabcf54e..b63ff6752 100644 --- a/host/tests/convert_test.cpp +++ b/host/tests/convert_test.cpp @@ -75,7 +75,7 @@ static void test_convert_types_sc16( //run the loopback and test convert::id_type in_id = id; convert::id_type out_id = id; - std::swap(out_id.input_markup, out_id.output_markup); + std::swap(out_id.input_format, out_id.output_format); std::swap(out_id.num_inputs, out_id.num_outputs); loopback(nsamps, in_id, out_id, input, output); BOOST_CHECK_EQUAL_COLLECTIONS(input.begin(), input.end(), output.begin(), output.end()); @@ -83,9 +83,9 @@ static void test_convert_types_sc16( BOOST_AUTO_TEST_CASE(test_convert_types_be_sc16){ convert::id_type id; - id.input_markup = "sc16"; + id.input_format = "sc16"; id.num_inputs = 1; - id.output_markup = "sc16_item32_be"; + id.output_format = "sc16_item32_be"; id.num_outputs = 1; //try various lengths to test edge cases @@ -96,9 +96,9 @@ BOOST_AUTO_TEST_CASE(test_convert_types_be_sc16){ BOOST_AUTO_TEST_CASE(test_convert_types_le_sc16){ convert::id_type id; - id.input_markup = "sc16"; + id.input_format = "sc16"; id.num_inputs = 1; - id.output_markup = "sc16_item32_le"; + id.output_format = "sc16_item32_le"; id.num_outputs = 1; //try various lengths to test edge cases @@ -126,7 +126,7 @@ static void test_convert_types_for_floats( //run the loopback and test convert::id_type in_id = id; convert::id_type out_id = id; - std::swap(out_id.input_markup, out_id.output_markup); + std::swap(out_id.input_format, out_id.output_format); std::swap(out_id.num_inputs, out_id.num_outputs); loopback(nsamps, in_id, out_id, input, output); for (size_t i = 0; i < nsamps; i++){ @@ -137,9 +137,9 @@ static void test_convert_types_for_floats( BOOST_AUTO_TEST_CASE(test_convert_types_be_fc32){ convert::id_type id; - id.input_markup = "fc32"; + id.input_format = "fc32"; id.num_inputs = 1; - id.output_markup = "sc16_item32_be"; + id.output_format = "sc16_item32_be"; id.num_outputs = 1; //try various lengths to test edge cases @@ -150,9 +150,9 @@ BOOST_AUTO_TEST_CASE(test_convert_types_be_fc32){ BOOST_AUTO_TEST_CASE(test_convert_types_le_fc32){ convert::id_type id; - id.input_markup = "fc32"; + id.input_format = "fc32"; id.num_inputs = 1; - id.output_markup = "sc16_item32_le"; + id.output_format = "sc16_item32_le"; id.num_outputs = 1; //try various lengths to test edge cases @@ -163,9 +163,9 @@ BOOST_AUTO_TEST_CASE(test_convert_types_le_fc32){ BOOST_AUTO_TEST_CASE(test_convert_types_be_fc64){ convert::id_type id; - id.input_markup = "fc64"; + id.input_format = "fc64"; id.num_inputs = 1; - id.output_markup = "sc16_item32_be"; + id.output_format = "sc16_item32_be"; id.num_outputs = 1; //try various lengths to test edge cases @@ -176,9 +176,9 @@ BOOST_AUTO_TEST_CASE(test_convert_types_be_fc64){ BOOST_AUTO_TEST_CASE(test_convert_types_le_fc64){ convert::id_type id; - id.input_markup = "fc64"; + id.input_format = "fc64"; id.num_inputs = 1; - id.output_markup = "sc16_item32_le"; + id.output_format = "sc16_item32_le"; id.num_outputs = 1; //try various lengths to test edge cases @@ -192,15 +192,15 @@ BOOST_AUTO_TEST_CASE(test_convert_types_le_fc64){ **********************************************************************/ BOOST_AUTO_TEST_CASE(test_convert_types_fc32_to_sc16){ convert::id_type in_id; - in_id.input_markup = "fc32"; + in_id.input_format = "fc32"; in_id.num_inputs = 1; - in_id.output_markup = "sc16_item32_le"; + in_id.output_format = "sc16_item32_le"; in_id.num_outputs = 1; convert::id_type out_id; - out_id.input_markup = "sc16_item32_le"; + out_id.input_format = "sc16_item32_le"; out_id.num_inputs = 1; - out_id.output_markup = "sc16"; + out_id.output_format = "sc16"; out_id.num_outputs = 1; const size_t nsamps = 13; @@ -233,15 +233,15 @@ BOOST_AUTO_TEST_CASE(test_convert_types_fc32_to_sc16){ **********************************************************************/ BOOST_AUTO_TEST_CASE(test_convert_types_sc16_to_fc32){ convert::id_type in_id; - in_id.input_markup = "sc16"; + in_id.input_format = "sc16"; in_id.num_inputs = 1; - in_id.output_markup = "sc16_item32_le"; + in_id.output_format = "sc16_item32_le"; in_id.num_outputs = 1; convert::id_type out_id; - out_id.input_markup = "sc16_item32_le"; + out_id.input_format = "sc16_item32_le"; out_id.num_inputs = 1; - out_id.output_markup = "fc32"; + out_id.output_format = "fc32"; out_id.num_outputs = 1; const size_t nsamps = 13; diff --git a/host/tests/sph_recv_test.cpp b/host/tests/sph_recv_test.cpp index 6fab2ad5f..85d06aa0d 100644 --- a/host/tests/sph_recv_test.cpp +++ b/host/tests/sph_recv_test.cpp @@ -107,9 +107,9 @@ private: BOOST_AUTO_TEST_CASE(test_sph_recv_one_channel_normal){ //////////////////////////////////////////////////////////////////////// uhd::convert::id_type id; - id.input_markup = "sc16_item32_be"; + id.input_format = "sc16_item32_be"; id.num_inputs = 1; - id.output_markup = "fc32"; + id.output_format = "fc32"; id.num_outputs = 1; dummy_recv_xport_class dummy_recv_xport("big"); @@ -178,9 +178,9 @@ BOOST_AUTO_TEST_CASE(test_sph_recv_one_channel_normal){ BOOST_AUTO_TEST_CASE(test_sph_recv_one_channel_sequence_error){ //////////////////////////////////////////////////////////////////////// uhd::convert::id_type id; - id.input_markup = "sc16_item32_be"; + id.input_format = "sc16_item32_be"; id.num_inputs = 1; - id.output_markup = "fc32"; + id.output_format = "fc32"; id.num_outputs = 1; dummy_recv_xport_class dummy_recv_xport("big"); @@ -259,9 +259,9 @@ BOOST_AUTO_TEST_CASE(test_sph_recv_one_channel_sequence_error){ BOOST_AUTO_TEST_CASE(test_sph_recv_one_channel_inline_message){ //////////////////////////////////////////////////////////////////////// uhd::convert::id_type id; - id.input_markup = "sc16_item32_be"; + id.input_format = "sc16_item32_be"; id.num_inputs = 1; - id.output_markup = "fc32"; + id.output_format = "fc32"; id.num_outputs = 1; dummy_recv_xport_class dummy_recv_xport("big"); @@ -351,9 +351,9 @@ BOOST_AUTO_TEST_CASE(test_sph_recv_one_channel_inline_message){ BOOST_AUTO_TEST_CASE(test_sph_recv_multi_channel_normal){ //////////////////////////////////////////////////////////////////////// uhd::convert::id_type id; - id.input_markup = "sc16_item32_be"; + id.input_format = "sc16_item32_be"; id.num_inputs = 1; - id.output_markup = "fc32"; + id.output_format = "fc32"; id.num_outputs = 1; uhd::transport::vrt::if_packet_info_t ifpi; @@ -434,9 +434,9 @@ BOOST_AUTO_TEST_CASE(test_sph_recv_multi_channel_normal){ BOOST_AUTO_TEST_CASE(test_sph_recv_multi_channel_sequence_error){ //////////////////////////////////////////////////////////////////////// uhd::convert::id_type id; - id.input_markup = "sc16_item32_be"; + id.input_format = "sc16_item32_be"; id.num_inputs = 1; - id.output_markup = "fc32"; + id.output_format = "fc32"; id.num_outputs = 1; uhd::transport::vrt::if_packet_info_t ifpi; @@ -527,9 +527,9 @@ BOOST_AUTO_TEST_CASE(test_sph_recv_multi_channel_sequence_error){ BOOST_AUTO_TEST_CASE(test_sph_recv_multi_channel_time_error){ //////////////////////////////////////////////////////////////////////// uhd::convert::id_type id; - id.input_markup = "sc16_item32_be"; + id.input_format = "sc16_item32_be"; id.num_inputs = 1; - id.output_markup = "fc32"; + id.output_format = "fc32"; id.num_outputs = 1; uhd::transport::vrt::if_packet_info_t ifpi; @@ -615,9 +615,9 @@ BOOST_AUTO_TEST_CASE(test_sph_recv_multi_channel_time_error){ BOOST_AUTO_TEST_CASE(test_sph_recv_multi_channel_fragment){ //////////////////////////////////////////////////////////////////////// uhd::convert::id_type id; - id.input_markup = "sc16_item32_be"; + id.input_format = "sc16_item32_be"; id.num_inputs = 1; - id.output_markup = "fc32"; + id.output_format = "fc32"; id.num_outputs = 1; uhd::transport::vrt::if_packet_info_t ifpi; diff --git a/host/tests/sph_send_test.cpp b/host/tests/sph_send_test.cpp index 9a91008af..25a3f97ee 100644 --- a/host/tests/sph_send_test.cpp +++ b/host/tests/sph_send_test.cpp @@ -92,9 +92,9 @@ private: BOOST_AUTO_TEST_CASE(test_sph_send_one_channel_one_packet_mode){ //////////////////////////////////////////////////////////////////////// uhd::convert::id_type id; - id.input_markup = "fc32"; + id.input_format = "fc32"; id.num_inputs = 1; - id.output_markup = "sc16_item32_be"; + id.output_format = "sc16_item32_be"; id.num_outputs = 1; dummy_send_xport_class dummy_send_xport("big"); @@ -150,9 +150,9 @@ BOOST_AUTO_TEST_CASE(test_sph_send_one_channel_one_packet_mode){ BOOST_AUTO_TEST_CASE(test_sph_send_one_channel_full_buffer_mode){ //////////////////////////////////////////////////////////////////////// uhd::convert::id_type id; - id.input_markup = "fc32"; + id.input_format = "fc32"; id.num_inputs = 1; - id.output_markup = "sc16_item32_be"; + id.output_format = "sc16_item32_be"; id.num_outputs = 1; dummy_send_xport_class dummy_send_xport("big"); -- cgit v1.2.3 From ae9e89d76b2eb86a29995f04aaab1aa59ee93f04 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Sun, 16 Oct 2011 10:43:48 -0700 Subject: usrp: added get_tx/rx_rates --- host/include/uhd/usrp/multi_usrp.hpp | 16 ++++++++++++++++ host/lib/usrp/b100/b100_impl.cpp | 4 ++++ host/lib/usrp/cores/rx_dsp_core_200.cpp | 21 ++++++++++++++++----- host/lib/usrp/cores/rx_dsp_core_200.hpp | 2 ++ host/lib/usrp/cores/tx_dsp_core_200.cpp | 21 ++++++++++++++++----- host/lib/usrp/cores/tx_dsp_core_200.hpp | 2 ++ host/lib/usrp/e100/e100_impl.cpp | 4 ++++ host/lib/usrp/multi_usrp.cpp | 8 ++++++++ host/lib/usrp/usrp1/io_impl.cpp | 27 ++++++++++++++++++++++----- host/lib/usrp/usrp1/usrp1_impl.cpp | 8 ++++++-- host/lib/usrp/usrp1/usrp1_impl.hpp | 2 ++ host/lib/usrp/usrp2/usrp2_impl.cpp | 4 ++++ 12 files changed, 102 insertions(+), 17 deletions(-) (limited to 'host/lib/usrp/e100') diff --git a/host/include/uhd/usrp/multi_usrp.hpp b/host/include/uhd/usrp/multi_usrp.hpp index ee7bf8424..baa47b39e 100644 --- a/host/include/uhd/usrp/multi_usrp.hpp +++ b/host/include/uhd/usrp/multi_usrp.hpp @@ -18,7 +18,9 @@ #ifndef INCLUDED_UHD_USRP_MULTI_USRP_HPP #define INCLUDED_UHD_USRP_MULTI_USRP_HPP +//define API capabilities for compile time detection of new features #define UHD_USRP_MULTI_USRP_REF_SOURCES_API +#define UHD_USRP_MULTI_USRP_GET_RATES_API #include #include @@ -367,6 +369,13 @@ public: */ virtual double get_rx_rate(size_t chan = 0) = 0; + /*! + * Get a range of possible RX rates. + * \param chan the channel index 0 to N-1 + * \return the meta range of rates + */ + virtual meta_range_t get_rx_rates(size_t chan = 0) = 0; + /*! * Set the RX center frequency. * \param tune_request tune request instructions @@ -567,6 +576,13 @@ public: */ virtual double get_tx_rate(size_t chan = 0) = 0; + /*! + * Get a range of possible TX rates. + * \param chan the channel index 0 to N-1 + * \return the meta range of rates + */ + virtual meta_range_t get_tx_rates(size_t chan = 0) = 0; + /*! * Set the TX center frequency. * \param tune_request tune request instructions diff --git a/host/lib/usrp/b100/b100_impl.cpp b/host/lib/usrp/b100/b100_impl.cpp index d1928735b..bb91d415d 100644 --- a/host/lib/usrp/b100/b100_impl.cpp +++ b/host/lib/usrp/b100/b100_impl.cpp @@ -296,6 +296,8 @@ b100_impl::b100_impl(const device_addr_t &device_addr){ _tree->access(mb_path / "tick_rate") .subscribe(boost::bind(&rx_dsp_core_200::set_tick_rate, _rx_dsps[dspno], _1)); fs_path rx_dsp_path = mb_path / str(boost::format("rx_dsps/%u") % dspno); + _tree->create(rx_dsp_path / "rate/range") + .publish(boost::bind(&rx_dsp_core_200::get_host_rates, _rx_dsps[dspno])); _tree->create(rx_dsp_path / "rate/value") .set(1e6) //some default .coerce(boost::bind(&rx_dsp_core_200::set_host_rate, _rx_dsps[dspno], _1)) @@ -317,6 +319,8 @@ b100_impl::b100_impl(const device_addr_t &device_addr){ _tx_dsp->set_link_rate(B100_LINK_RATE_BPS); _tree->access(mb_path / "tick_rate") .subscribe(boost::bind(&tx_dsp_core_200::set_tick_rate, _tx_dsp, _1)); + _tree->create(mb_path / "tx_dsps/0/rate/range") + .publish(boost::bind(&tx_dsp_core_200::get_host_rates, _tx_dsp)); _tree->create(mb_path / "tx_dsps/0/rate/value") .set(1e6) //some default .coerce(boost::bind(&tx_dsp_core_200::set_host_rate, _tx_dsp, _1)) diff --git a/host/lib/usrp/cores/rx_dsp_core_200.cpp b/host/lib/usrp/cores/rx_dsp_core_200.cpp index b121bc849..6d306d507 100644 --- a/host/lib/usrp/cores/rx_dsp_core_200.cpp +++ b/host/lib/usrp/cores/rx_dsp_core_200.cpp @@ -134,12 +134,23 @@ public: _link_rate = rate/sizeof(boost::uint16_t); //in samps/s (allows for 8sc) } + uhd::meta_range_t get_host_rates(void){ + meta_range_t range; + for (int rate = 512; rate > 256; rate -= 4){ + range.push_back(range_t(_tick_rate/rate)); + } + for (int rate = 256; rate > 128; rate -= 2){ + range.push_back(range_t(_tick_rate/rate)); + } + for (int rate = 128; rate >= int(std::ceil(_tick_rate/_link_rate)); rate -= 1){ + range.push_back(range_t(_tick_rate/rate)); + } + return range; + } + double set_host_rate(const double rate){ - size_t decim_rate = uhd::clip( - boost::math::iround(_tick_rate/rate), size_t(std::ceil(_tick_rate/_link_rate)), 512 - ); - if (decim_rate > 128) decim_rate &= ~0x1; //CIC up to 128, have to use 1 HB - if (decim_rate > 256) decim_rate &= ~0x3; //CIC up to 128, have to use 2 HB + const size_t decim_rate = this->get_host_rates().clip( + boost::math::iround(_tick_rate/rate), true); size_t decim = decim_rate; //determine which half-band filters are activated diff --git a/host/lib/usrp/cores/rx_dsp_core_200.hpp b/host/lib/usrp/cores/rx_dsp_core_200.hpp index ddd6f2abf..89b8c1f51 100644 --- a/host/lib/usrp/cores/rx_dsp_core_200.hpp +++ b/host/lib/usrp/cores/rx_dsp_core_200.hpp @@ -48,6 +48,8 @@ public: virtual double set_host_rate(const double rate) = 0; + virtual uhd::meta_range_t get_host_rates(void) = 0; + virtual double get_scaling_adjustment(void) = 0; virtual uhd::meta_range_t get_freq_range(void) = 0; diff --git a/host/lib/usrp/cores/tx_dsp_core_200.cpp b/host/lib/usrp/cores/tx_dsp_core_200.cpp index f37b53527..1d571ea7c 100644 --- a/host/lib/usrp/cores/tx_dsp_core_200.cpp +++ b/host/lib/usrp/cores/tx_dsp_core_200.cpp @@ -74,12 +74,23 @@ public: _link_rate = rate/sizeof(boost::uint16_t); //in samps/s (allows for 8sc) } + uhd::meta_range_t get_host_rates(void){ + meta_range_t range; + for (int rate = 512; rate > 256; rate -= 4){ + range.push_back(range_t(_tick_rate/rate)); + } + for (int rate = 256; rate > 128; rate -= 2){ + range.push_back(range_t(_tick_rate/rate)); + } + for (int rate = 128; rate >= int(std::ceil(_tick_rate/_link_rate)); rate -= 1){ + range.push_back(range_t(_tick_rate/rate)); + } + return range; + } + double set_host_rate(const double rate){ - size_t interp_rate = uhd::clip( - boost::math::iround(_tick_rate/rate), size_t(std::ceil(_tick_rate/_link_rate)), 512 - ); - if (interp_rate > 128) interp_rate &= ~0x1; //CIC up to 128, have to use 1 HB - if (interp_rate > 256) interp_rate &= ~0x3; //CIC up to 128, have to use 2 HB + const size_t interp_rate = this->get_host_rates().clip( + boost::math::iround(_tick_rate/rate), true); size_t interp = interp_rate; //determine which half-band filters are activated diff --git a/host/lib/usrp/cores/tx_dsp_core_200.hpp b/host/lib/usrp/cores/tx_dsp_core_200.hpp index 65f822558..e6be63557 100644 --- a/host/lib/usrp/cores/tx_dsp_core_200.hpp +++ b/host/lib/usrp/cores/tx_dsp_core_200.hpp @@ -40,6 +40,8 @@ public: virtual double set_host_rate(const double rate) = 0; + virtual uhd::meta_range_t get_host_rates(void) = 0; + virtual uhd::meta_range_t get_freq_range(void) = 0; virtual double set_freq(const double freq) = 0; diff --git a/host/lib/usrp/e100/e100_impl.cpp b/host/lib/usrp/e100/e100_impl.cpp index deb52b2d7..6cb404000 100644 --- a/host/lib/usrp/e100/e100_impl.cpp +++ b/host/lib/usrp/e100/e100_impl.cpp @@ -270,6 +270,8 @@ e100_impl::e100_impl(const uhd::device_addr_t &device_addr){ _tree->access(mb_path / "tick_rate") .subscribe(boost::bind(&rx_dsp_core_200::set_tick_rate, _rx_dsps[dspno], _1)); fs_path rx_dsp_path = mb_path / str(boost::format("rx_dsps/%u") % dspno); + _tree->create(rx_dsp_path / "rate/range") + .publish(boost::bind(&rx_dsp_core_200::get_host_rates, _rx_dsps[dspno])); _tree->create(rx_dsp_path / "rate/value") .set(1e6) //some default .coerce(boost::bind(&rx_dsp_core_200::set_host_rate, _rx_dsps[dspno], _1)) @@ -291,6 +293,8 @@ e100_impl::e100_impl(const uhd::device_addr_t &device_addr){ _tx_dsp->set_link_rate(E100_TX_LINK_RATE_BPS); _tree->access(mb_path / "tick_rate") .subscribe(boost::bind(&tx_dsp_core_200::set_tick_rate, _tx_dsp, _1)); + _tree->create(mb_path / "tx_dsps/0/rate/range") + .publish(boost::bind(&tx_dsp_core_200::get_host_rates, _tx_dsp)); _tree->create(mb_path / "tx_dsps/0/rate/value") .set(1e6) //some default .coerce(boost::bind(&tx_dsp_core_200::set_host_rate, _tx_dsp, _1)) diff --git a/host/lib/usrp/multi_usrp.cpp b/host/lib/usrp/multi_usrp.cpp index ab841487f..97c5ea630 100644 --- a/host/lib/usrp/multi_usrp.cpp +++ b/host/lib/usrp/multi_usrp.cpp @@ -477,6 +477,10 @@ public: return _tree->access(rx_dsp_root(chan) / "rate" / "value").get(); } + meta_range_t get_rx_rates(size_t chan){ + return _tree->access(rx_dsp_root(chan) / "rate" / "range").get(); + } + tune_result_t set_rx_freq(const tune_request_t &tune_request, size_t chan){ tune_result_t r = tune_xx_subdev_and_dsp(RX_SIGN, _tree->subtree(rx_dsp_root(chan)), _tree->subtree(rx_rf_fe_root(chan)), tune_request); do_tune_freq_warning_message(tune_request.target_freq, get_rx_freq(chan), "RX"); @@ -587,6 +591,10 @@ public: return _tree->access(tx_dsp_root(chan) / "rate" / "value").get(); } + meta_range_t get_tx_rates(size_t chan){ + return _tree->access(tx_dsp_root(chan) / "rate" / "range").get(); + } + tune_result_t set_tx_freq(const tune_request_t &tune_request, size_t chan){ tune_result_t r = tune_xx_subdev_and_dsp(TX_SIGN, _tree->subtree(tx_dsp_root(chan)), _tree->subtree(tx_rf_fe_root(chan)), tune_request); do_tune_freq_warning_message(tune_request.target_freq, get_tx_freq(chan), "TX"); diff --git a/host/lib/usrp/usrp1/io_impl.cpp b/host/lib/usrp/usrp1/io_impl.cpp index 12950d385..31c834109 100644 --- a/host/lib/usrp/usrp1/io_impl.cpp +++ b/host/lib/usrp/usrp1/io_impl.cpp @@ -442,7 +442,6 @@ void usrp1_impl::update_tx_subdev_spec(const uhd::usrp::subdev_spec_t &spec){ this->restore_tx(s); } - void usrp1_impl::update_tick_rate(const double rate){ //updating this variable should: //update dboard iface -> it has a reference @@ -450,11 +449,29 @@ void usrp1_impl::update_tick_rate(const double rate){ _master_clock_rate = rate; } +uhd::meta_range_t usrp1_impl::get_rx_dsp_host_rates(void){ + meta_range_t range; + const size_t div = this->has_rx_halfband()? 2 : 1; + for (int rate = 256; rate >= 4; rate -= div){ + range.push_back(range_t(_master_clock_rate/rate)); + } + return range; +} + +uhd::meta_range_t usrp1_impl::get_tx_dsp_host_rates(void){ + meta_range_t range; + const size_t div = this->has_tx_halfband()? 2 : 1; + for (int rate = 256; rate >= 8; rate -= div){ + range.push_back(range_t(_master_clock_rate/rate)); + } + return range; +} + double usrp1_impl::update_rx_samp_rate(size_t dspno, const double samp_rate){ const size_t div = this->has_rx_halfband()? 2 : 1; - const size_t rate = uhd::clip( - boost::math::iround(_master_clock_rate / samp_rate), 4, 256) & ~(div-1); + const size_t rate = this->get_rx_dsp_host_rates().clip( + boost::math::iround(_master_clock_rate / samp_rate), true); if (rate < 8 and this->has_rx_halfband()) UHD_MSG(warning) << "USRP1 cannot achieve decimations below 8 when the half-band filter is present.\n" @@ -482,8 +499,8 @@ double usrp1_impl::update_rx_samp_rate(size_t dspno, const double samp_rate){ double usrp1_impl::update_tx_samp_rate(size_t dspno, const double samp_rate){ const size_t div = this->has_tx_halfband()? 2 : 1; - const size_t rate = uhd::clip( - boost::math::iround(_master_clock_rate / samp_rate), 8, 256) & ~(div-1); + const size_t rate = this->get_tx_dsp_host_rates().clip( + boost::math::iround(_master_clock_rate / samp_rate), true); if (dspno == 0){ //only care if dsp0 is set since its homogeneous bool s = this->disable_tx(); diff --git a/host/lib/usrp/usrp1/usrp1_impl.cpp b/host/lib/usrp/usrp1/usrp1_impl.cpp index 5788c536f..1a61f8136 100644 --- a/host/lib/usrp/usrp1/usrp1_impl.cpp +++ b/host/lib/usrp/usrp1/usrp1_impl.cpp @@ -283,8 +283,10 @@ usrp1_impl::usrp1_impl(const device_addr_t &device_addr){ _tree->create(mb_path / "rx_dsps"); //dummy in case we have none for (size_t dspno = 0; dspno < get_num_ddcs(); dspno++){ fs_path rx_dsp_path = mb_path / str(boost::format("rx_dsps/%u") % dspno); + _tree->create(rx_dsp_path / "rate/range") + .publish(boost::bind(&usrp1_impl::get_rx_dsp_host_rates, this)); _tree->create(rx_dsp_path / "rate/value") - .set(1e6) + .set(1e6) //some default rate .coerce(boost::bind(&usrp1_impl::update_rx_samp_rate, this, dspno, _1)); _tree->create(rx_dsp_path / "freq/value") .coerce(boost::bind(&usrp1_impl::update_rx_dsp_freq, this, dspno, _1)); @@ -304,8 +306,10 @@ usrp1_impl::usrp1_impl(const device_addr_t &device_addr){ _tree->create(mb_path / "tx_dsps"); //dummy in case we have none for (size_t dspno = 0; dspno < get_num_ducs(); dspno++){ fs_path tx_dsp_path = mb_path / str(boost::format("tx_dsps/%u") % dspno); + _tree->create(tx_dsp_path / "rate/range") + .publish(boost::bind(&usrp1_impl::get_tx_dsp_host_rates, this)); _tree->create(tx_dsp_path / "rate/value") - .set(1e6) + .set(1e6) //some default rate .coerce(boost::bind(&usrp1_impl::update_tx_samp_rate, this, dspno, _1)); _tree->create(tx_dsp_path / "freq/value") .coerce(boost::bind(&usrp1_impl::update_tx_dsp_freq, this, dspno, _1)); diff --git a/host/lib/usrp/usrp1/usrp1_impl.hpp b/host/lib/usrp/usrp1/usrp1_impl.hpp index 6f427c31e..ec313daf6 100644 --- a/host/lib/usrp/usrp1/usrp1_impl.hpp +++ b/host/lib/usrp/usrp1/usrp1_impl.hpp @@ -98,6 +98,8 @@ private: void update_tick_rate(const double rate); uhd::meta_range_t get_rx_dsp_freq_range(void); uhd::meta_range_t get_tx_dsp_freq_range(void); + uhd::meta_range_t get_rx_dsp_host_rates(void); + uhd::meta_range_t get_tx_dsp_host_rates(void); static uhd::usrp::dboard_iface::sptr make_dboard_iface( usrp1_iface::sptr, diff --git a/host/lib/usrp/usrp2/usrp2_impl.cpp b/host/lib/usrp/usrp2/usrp2_impl.cpp index 2d89ddaf4..24178d10c 100644 --- a/host/lib/usrp/usrp2/usrp2_impl.cpp +++ b/host/lib/usrp/usrp2/usrp2_impl.cpp @@ -480,6 +480,8 @@ usrp2_impl::usrp2_impl(const device_addr_t &_device_addr){ _mbc[mb].rx_dsp_xports[dspno]->get_recv_buff(0.01).get(); //recv with timeout for lingering _mbc[mb].rx_dsp_xports[dspno]->get_recv_buff(0.01).get(); //recv with timeout for expected fs_path rx_dsp_path = mb_path / str(boost::format("rx_dsps/%u") % dspno); + _tree->create(rx_dsp_path / "rate/range") + .publish(boost::bind(&rx_dsp_core_200::get_host_rates, _mbc[mb].rx_dsps[dspno])); _tree->create(rx_dsp_path / "rate/value") .set(1e6) //some default .coerce(boost::bind(&rx_dsp_core_200::set_host_rate, _mbc[mb].rx_dsps[dspno], _1)) @@ -501,6 +503,8 @@ usrp2_impl::usrp2_impl(const device_addr_t &_device_addr){ _mbc[mb].tx_dsp->set_link_rate(USRP2_LINK_RATE_BPS); _tree->access(mb_path / "tick_rate") .subscribe(boost::bind(&tx_dsp_core_200::set_tick_rate, _mbc[mb].tx_dsp, _1)); + _tree->create(mb_path / "tx_dsps/0/rate/range") + .publish(boost::bind(&tx_dsp_core_200::get_host_rates, _mbc[mb].tx_dsp)); _tree->create(mb_path / "tx_dsps/0/rate/value") .set(1e6) //some default .coerce(boost::bind(&tx_dsp_core_200::set_host_rate, _mbc[mb].tx_dsp, _1)) -- cgit v1.2.3 From bd08f403e3936d9c35b04f8990605dd49310fbfd Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Sun, 23 Oct 2011 18:04:18 -0700 Subject: usrp: register properties for correction and dc offset --- host/lib/usrp/b100/b100_impl.cpp | 18 +++++++++++++++++- host/lib/usrp/e100/e100_impl.cpp | 18 +++++++++++++++++- host/lib/usrp/usrp2/usrp2_impl.cpp | 18 +++++++++++++++++- 3 files changed, 51 insertions(+), 3 deletions(-) (limited to 'host/lib/usrp/e100') diff --git a/host/lib/usrp/b100/b100_impl.cpp b/host/lib/usrp/b100/b100_impl.cpp index bb91d415d..ec31ce04e 100644 --- a/host/lib/usrp/b100/b100_impl.cpp +++ b/host/lib/usrp/b100/b100_impl.cpp @@ -276,12 +276,28 @@ b100_impl::b100_impl(const device_addr_t &device_addr){ //////////////////////////////////////////////////////////////////// _rx_fe = rx_frontend_core_200::make(_fpga_ctrl, B100_REG_SR_ADDR(B100_SR_RX_FRONT)); _tx_fe = tx_frontend_core_200::make(_fpga_ctrl, B100_REG_SR_ADDR(B100_SR_TX_FRONT)); - //TODO lots of properties to expose here for frontends + _tree->create(mb_path / "rx_subdev_spec") .subscribe(boost::bind(&b100_impl::update_rx_subdev_spec, this, _1)); _tree->create(mb_path / "tx_subdev_spec") .subscribe(boost::bind(&b100_impl::update_tx_subdev_spec, this, _1)); + _tree->create >(mb_path / "dboards" / "A" / "rx_frontends" / "dc_offset" / "value") + .coerce(boost::bind(&rx_frontend_core_200::set_dc_offset, _rx_fe, _1)) + .set(std::complex(0.0, 0.0)); + _tree->create(mb_path / "dboards" / "A" / "rx_frontends" / "dc_offset" / "enable") + .subscribe(boost::bind(&rx_frontend_core_200::set_dc_offset_auto, _rx_fe, _1)) + .set(true); + _tree->create >(mb_path / "dboards" / "A" / "rx_frontends" / "correction" / "value") + .subscribe(boost::bind(&rx_frontend_core_200::set_correction, _rx_fe, _1)) + .set(std::complex(0.0, 0.0)); + _tree->create >(mb_path / "dboards" / "A" / "tx_frontends" / "dc_offset" / "value") + .coerce(boost::bind(&tx_frontend_core_200::set_dc_offset, _tx_fe, _1)) + .set(std::complex(0.0, 0.0)); + _tree->create >(mb_path / "dboards" / "A" / "tx_frontends" / "correction" / "value") + .subscribe(boost::bind(&tx_frontend_core_200::set_correction, _tx_fe, _1)) + .set(std::complex(0.0, 0.0)); + //////////////////////////////////////////////////////////////////// // create rx dsp control objects //////////////////////////////////////////////////////////////////// diff --git a/host/lib/usrp/e100/e100_impl.cpp b/host/lib/usrp/e100/e100_impl.cpp index 6cb404000..bdf5a9b85 100644 --- a/host/lib/usrp/e100/e100_impl.cpp +++ b/host/lib/usrp/e100/e100_impl.cpp @@ -250,12 +250,28 @@ e100_impl::e100_impl(const uhd::device_addr_t &device_addr){ //////////////////////////////////////////////////////////////////// _rx_fe = rx_frontend_core_200::make(_fpga_ctrl, E100_REG_SR_ADDR(UE_SR_RX_FRONT)); _tx_fe = tx_frontend_core_200::make(_fpga_ctrl, E100_REG_SR_ADDR(UE_SR_TX_FRONT)); - //TODO lots of properties to expose here for frontends + _tree->create(mb_path / "rx_subdev_spec") .subscribe(boost::bind(&e100_impl::update_rx_subdev_spec, this, _1)); _tree->create(mb_path / "tx_subdev_spec") .subscribe(boost::bind(&e100_impl::update_tx_subdev_spec, this, _1)); + _tree->create >(mb_path / "dboards" / "A" / "rx_frontends" / "dc_offset" / "value") + .coerce(boost::bind(&rx_frontend_core_200::set_dc_offset, _rx_fe, _1)) + .set(std::complex(0.0, 0.0)); + _tree->create(mb_path / "dboards" / "A" / "rx_frontends" / "dc_offset" / "enable") + .subscribe(boost::bind(&rx_frontend_core_200::set_dc_offset_auto, _rx_fe, _1)) + .set(true); + _tree->create >(mb_path / "dboards" / "A" / "rx_frontends" / "correction" / "value") + .subscribe(boost::bind(&rx_frontend_core_200::set_correction, _rx_fe, _1)) + .set(std::complex(0.0, 0.0)); + _tree->create >(mb_path / "dboards" / "A" / "tx_frontends" / "dc_offset" / "value") + .coerce(boost::bind(&tx_frontend_core_200::set_dc_offset, _tx_fe, _1)) + .set(std::complex(0.0, 0.0)); + _tree->create >(mb_path / "dboards" / "A" / "tx_frontends" / "correction" / "value") + .subscribe(boost::bind(&tx_frontend_core_200::set_correction, _tx_fe, _1)) + .set(std::complex(0.0, 0.0)); + //////////////////////////////////////////////////////////////////// // create rx dsp control objects //////////////////////////////////////////////////////////////////// diff --git a/host/lib/usrp/usrp2/usrp2_impl.cpp b/host/lib/usrp/usrp2/usrp2_impl.cpp index 24178d10c..6f215471e 100644 --- a/host/lib/usrp/usrp2/usrp2_impl.cpp +++ b/host/lib/usrp/usrp2/usrp2_impl.cpp @@ -456,12 +456,28 @@ usrp2_impl::usrp2_impl(const device_addr_t &_device_addr){ _mbc[mb].tx_fe = tx_frontend_core_200::make( _mbc[mb].iface, U2_REG_SR_ADDR(SR_TX_FRONT) ); - //TODO lots of properties to expose here for frontends + _tree->create(mb_path / "rx_subdev_spec") .subscribe(boost::bind(&usrp2_impl::update_rx_subdev_spec, this, mb, _1)); _tree->create(mb_path / "tx_subdev_spec") .subscribe(boost::bind(&usrp2_impl::update_tx_subdev_spec, this, mb, _1)); + _tree->create >(mb_path / "dboards" / "A" / "rx_frontends" / "dc_offset" / "value") + .coerce(boost::bind(&rx_frontend_core_200::set_dc_offset, _mbc[mb].rx_fe, _1)) + .set(std::complex(0.0, 0.0)); + _tree->create(mb_path / "dboards" / "A" / "rx_frontends" / "dc_offset" / "enable") + .subscribe(boost::bind(&rx_frontend_core_200::set_dc_offset_auto, _mbc[mb].rx_fe, _1)) + .set(true); + _tree->create >(mb_path / "dboards" / "A" / "rx_frontends" / "correction" / "value") + .subscribe(boost::bind(&rx_frontend_core_200::set_correction, _mbc[mb].rx_fe, _1)) + .set(std::complex(0.0, 0.0)); + _tree->create >(mb_path / "dboards" / "A" / "tx_frontends" / "dc_offset" / "value") + .coerce(boost::bind(&tx_frontend_core_200::set_dc_offset, _mbc[mb].tx_fe, _1)) + .set(std::complex(0.0, 0.0)); + _tree->create >(mb_path / "dboards" / "A" / "tx_frontends" / "correction" / "value") + .subscribe(boost::bind(&tx_frontend_core_200::set_correction, _mbc[mb].tx_fe, _1)) + .set(std::complex(0.0, 0.0)); + //////////////////////////////////////////////////////////////// // create rx dsp control objects //////////////////////////////////////////////////////////////// -- cgit v1.2.3 From a62645089202ac2ac39a55c48d3876474b54223e Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Mon, 24 Oct 2011 10:36:41 -0700 Subject: usrp: prefer name iq_balance for api call --- host/include/uhd/usrp/multi_usrp.hpp | 11 +++++------ host/lib/usrp/b100/b100_impl.cpp | 8 ++++---- host/lib/usrp/cores/rx_frontend_core_200.cpp | 2 +- host/lib/usrp/cores/rx_frontend_core_200.hpp | 2 +- host/lib/usrp/cores/tx_frontend_core_200.cpp | 2 +- host/lib/usrp/cores/tx_frontend_core_200.hpp | 2 +- host/lib/usrp/e100/e100_impl.cpp | 8 ++++---- host/lib/usrp/multi_usrp.cpp | 12 ++++++------ host/lib/usrp/usrp2/usrp2_impl.cpp | 8 ++++---- 9 files changed, 27 insertions(+), 28 deletions(-) (limited to 'host/lib/usrp/e100') diff --git a/host/include/uhd/usrp/multi_usrp.hpp b/host/include/uhd/usrp/multi_usrp.hpp index 1cbe3a684..0cf50aa0d 100644 --- a/host/include/uhd/usrp/multi_usrp.hpp +++ b/host/include/uhd/usrp/multi_usrp.hpp @@ -21,8 +21,7 @@ //define API capabilities for compile time detection of new features #define UHD_USRP_MULTI_USRP_REF_SOURCES_API #define UHD_USRP_MULTI_USRP_GET_RATES_API -#define UHD_USRP_MULTI_USRP_DC_OFFSET_API -#define UHD_USRP_MULTI_USRP_CORRECTION_API +#define UHD_USRP_MULTI_USRP_FRONTEND_CAL_API #include #include @@ -555,13 +554,13 @@ public: virtual void set_rx_dc_offset(const std::complex &offset, size_t chan = ALL_CHANS) = 0; /*! - * Set the RX frontend IQ imbalance and gain correction. + * Set the RX frontend IQ imbalance correction. * Use this to adjust the magnitude and phase of I and Q. * * \param correction the complex correction value * \param chan the channel index 0 to N-1 */ - virtual void set_rx_correction(const std::complex &correction, size_t chan = ALL_CHANS) = 0; + virtual void set_rx_iq_balance(const std::complex &correction, size_t chan = ALL_CHANS) = 0; /******************************************************************* * TX methods @@ -769,13 +768,13 @@ public: virtual void set_tx_dc_offset(const std::complex &offset, size_t chan = ALL_CHANS) = 0; /*! - * Set the TX frontend IQ imbalance and gain correction. + * Set the TX frontend IQ imbalance correction. * Use this to adjust the magnitude and phase of I and Q. * * \param correction the complex correction value * \param chan the channel index 0 to N-1 */ - virtual void set_tx_correction(const std::complex &correction, size_t chan = ALL_CHANS) = 0; + virtual void set_tx_iq_balance(const std::complex &correction, size_t chan = ALL_CHANS) = 0; }; diff --git a/host/lib/usrp/b100/b100_impl.cpp b/host/lib/usrp/b100/b100_impl.cpp index ec31ce04e..0edaac914 100644 --- a/host/lib/usrp/b100/b100_impl.cpp +++ b/host/lib/usrp/b100/b100_impl.cpp @@ -288,14 +288,14 @@ b100_impl::b100_impl(const device_addr_t &device_addr){ _tree->create(mb_path / "dboards" / "A" / "rx_frontends" / "dc_offset" / "enable") .subscribe(boost::bind(&rx_frontend_core_200::set_dc_offset_auto, _rx_fe, _1)) .set(true); - _tree->create >(mb_path / "dboards" / "A" / "rx_frontends" / "correction" / "value") - .subscribe(boost::bind(&rx_frontend_core_200::set_correction, _rx_fe, _1)) + _tree->create >(mb_path / "dboards" / "A" / "rx_frontends" / "iq_balance" / "value") + .subscribe(boost::bind(&rx_frontend_core_200::set_iq_balance, _rx_fe, _1)) .set(std::complex(0.0, 0.0)); _tree->create >(mb_path / "dboards" / "A" / "tx_frontends" / "dc_offset" / "value") .coerce(boost::bind(&tx_frontend_core_200::set_dc_offset, _tx_fe, _1)) .set(std::complex(0.0, 0.0)); - _tree->create >(mb_path / "dboards" / "A" / "tx_frontends" / "correction" / "value") - .subscribe(boost::bind(&tx_frontend_core_200::set_correction, _tx_fe, _1)) + _tree->create >(mb_path / "dboards" / "A" / "tx_frontends" / "iq_balance" / "value") + .subscribe(boost::bind(&tx_frontend_core_200::set_iq_balance, _tx_fe, _1)) .set(std::complex(0.0, 0.0)); //////////////////////////////////////////////////////////////////// diff --git a/host/lib/usrp/cores/rx_frontend_core_200.cpp b/host/lib/usrp/cores/rx_frontend_core_200.cpp index bb87cb600..d42022947 100644 --- a/host/lib/usrp/cores/rx_frontend_core_200.cpp +++ b/host/lib/usrp/cores/rx_frontend_core_200.cpp @@ -63,7 +63,7 @@ public: _iface->poke32(REG_RX_FE_OFFSET_Q, flags | _q_dc_off); } - void set_correction(const std::complex &cor){ + void set_iq_balance(const std::complex &cor){ _iface->poke32(REG_RX_FE_MAG_CORRECTION, fs_to_bits(std::abs(cor), 18)); _iface->poke32(REG_RX_FE_PHASE_CORRECTION, fs_to_bits(std::atan2(cor.real(), cor.imag()), 18)); } diff --git a/host/lib/usrp/cores/rx_frontend_core_200.hpp b/host/lib/usrp/cores/rx_frontend_core_200.hpp index 73dfbdc72..5755424c8 100644 --- a/host/lib/usrp/cores/rx_frontend_core_200.hpp +++ b/host/lib/usrp/cores/rx_frontend_core_200.hpp @@ -37,7 +37,7 @@ public: virtual std::complex set_dc_offset(const std::complex &off) = 0; - virtual void set_correction(const std::complex &cor) = 0; + virtual void set_iq_balance(const std::complex &cor) = 0; }; diff --git a/host/lib/usrp/cores/tx_frontend_core_200.cpp b/host/lib/usrp/cores/tx_frontend_core_200.cpp index 71555e47f..327e8d344 100644 --- a/host/lib/usrp/cores/tx_frontend_core_200.cpp +++ b/host/lib/usrp/cores/tx_frontend_core_200.cpp @@ -61,7 +61,7 @@ public: return std::complex(i_dc_off/scaler, q_dc_off/scaler); } - void set_correction(const std::complex &cor){ + void set_iq_balance(const std::complex &cor){ _iface->poke32(REG_TX_FE_MAG_CORRECTION, fs_to_bits(std::abs(cor), 18)); _iface->poke32(REG_TX_FE_PHASE_CORRECTION, fs_to_bits(std::atan2(cor.real(), cor.imag()), 18)); } diff --git a/host/lib/usrp/cores/tx_frontend_core_200.hpp b/host/lib/usrp/cores/tx_frontend_core_200.hpp index f905e447d..8ee0f3e6d 100644 --- a/host/lib/usrp/cores/tx_frontend_core_200.hpp +++ b/host/lib/usrp/cores/tx_frontend_core_200.hpp @@ -35,7 +35,7 @@ public: virtual std::complex set_dc_offset(const std::complex &off) = 0; - virtual void set_correction(const std::complex &cor) = 0; + virtual void set_iq_balance(const std::complex &cor) = 0; }; diff --git a/host/lib/usrp/e100/e100_impl.cpp b/host/lib/usrp/e100/e100_impl.cpp index bdf5a9b85..4c5f5f066 100644 --- a/host/lib/usrp/e100/e100_impl.cpp +++ b/host/lib/usrp/e100/e100_impl.cpp @@ -262,14 +262,14 @@ e100_impl::e100_impl(const uhd::device_addr_t &device_addr){ _tree->create(mb_path / "dboards" / "A" / "rx_frontends" / "dc_offset" / "enable") .subscribe(boost::bind(&rx_frontend_core_200::set_dc_offset_auto, _rx_fe, _1)) .set(true); - _tree->create >(mb_path / "dboards" / "A" / "rx_frontends" / "correction" / "value") - .subscribe(boost::bind(&rx_frontend_core_200::set_correction, _rx_fe, _1)) + _tree->create >(mb_path / "dboards" / "A" / "rx_frontends" / "iq_balance" / "value") + .subscribe(boost::bind(&rx_frontend_core_200::set_iq_balance, _rx_fe, _1)) .set(std::complex(0.0, 0.0)); _tree->create >(mb_path / "dboards" / "A" / "tx_frontends" / "dc_offset" / "value") .coerce(boost::bind(&tx_frontend_core_200::set_dc_offset, _tx_fe, _1)) .set(std::complex(0.0, 0.0)); - _tree->create >(mb_path / "dboards" / "A" / "tx_frontends" / "correction" / "value") - .subscribe(boost::bind(&tx_frontend_core_200::set_correction, _tx_fe, _1)) + _tree->create >(mb_path / "dboards" / "A" / "tx_frontends" / "iq_balance" / "value") + .subscribe(boost::bind(&tx_frontend_core_200::set_iq_balance, _tx_fe, _1)) .set(std::complex(0.0, 0.0)); //////////////////////////////////////////////////////////////////// diff --git a/host/lib/usrp/multi_usrp.cpp b/host/lib/usrp/multi_usrp.cpp index 5a6acc2c5..7b3890c9b 100644 --- a/host/lib/usrp/multi_usrp.cpp +++ b/host/lib/usrp/multi_usrp.cpp @@ -567,13 +567,13 @@ public: } } - void set_rx_correction(const std::complex &offset, size_t chan){ + void set_rx_iq_balance(const std::complex &offset, size_t chan){ if (chan != ALL_CHANS){ - _tree->access >(rx_rf_fe_root(chan).branch_path() / "correction" / "value").set(offset); + _tree->access >(rx_rf_fe_root(chan).branch_path() / "iq_balance" / "value").set(offset); return; } for (size_t c = 0; c < get_rx_num_channels(); c++){ - this->set_rx_correction(offset, c); + this->set_rx_iq_balance(offset, c); } } @@ -701,13 +701,13 @@ public: } } - void set_tx_correction(const std::complex &offset, size_t chan){ + void set_tx_iq_balance(const std::complex &offset, size_t chan){ if (chan != ALL_CHANS){ - _tree->access >(tx_rf_fe_root(chan).branch_path() / "correction" / "value").set(offset); + _tree->access >(tx_rf_fe_root(chan).branch_path() / "iq_balance" / "value").set(offset); return; } for (size_t c = 0; c < get_tx_num_channels(); c++){ - this->set_tx_correction(offset, c); + this->set_tx_iq_balance(offset, c); } } diff --git a/host/lib/usrp/usrp2/usrp2_impl.cpp b/host/lib/usrp/usrp2/usrp2_impl.cpp index 6f215471e..50916fb37 100644 --- a/host/lib/usrp/usrp2/usrp2_impl.cpp +++ b/host/lib/usrp/usrp2/usrp2_impl.cpp @@ -468,14 +468,14 @@ usrp2_impl::usrp2_impl(const device_addr_t &_device_addr){ _tree->create(mb_path / "dboards" / "A" / "rx_frontends" / "dc_offset" / "enable") .subscribe(boost::bind(&rx_frontend_core_200::set_dc_offset_auto, _mbc[mb].rx_fe, _1)) .set(true); - _tree->create >(mb_path / "dboards" / "A" / "rx_frontends" / "correction" / "value") - .subscribe(boost::bind(&rx_frontend_core_200::set_correction, _mbc[mb].rx_fe, _1)) + _tree->create >(mb_path / "dboards" / "A" / "rx_frontends" / "iq_balance" / "value") + .subscribe(boost::bind(&rx_frontend_core_200::set_iq_balance, _mbc[mb].rx_fe, _1)) .set(std::complex(0.0, 0.0)); _tree->create >(mb_path / "dboards" / "A" / "tx_frontends" / "dc_offset" / "value") .coerce(boost::bind(&tx_frontend_core_200::set_dc_offset, _mbc[mb].tx_fe, _1)) .set(std::complex(0.0, 0.0)); - _tree->create >(mb_path / "dboards" / "A" / "tx_frontends" / "correction" / "value") - .subscribe(boost::bind(&tx_frontend_core_200::set_correction, _mbc[mb].tx_fe, _1)) + _tree->create >(mb_path / "dboards" / "A" / "tx_frontends" / "iq_balance" / "value") + .subscribe(boost::bind(&tx_frontend_core_200::set_iq_balance, _mbc[mb].tx_fe, _1)) .set(std::complex(0.0, 0.0)); //////////////////////////////////////////////////////////////// -- cgit v1.2.3 From dedfa65256470f31a20c99a210457937d3f36056 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Tue, 25 Oct 2011 19:26:11 -0700 Subject: usrp: reorganize frontend paths in tree for correction stuff --- host/lib/usrp/b100/b100_impl.cpp | 13 ++++++++----- host/lib/usrp/e100/e100_impl.cpp | 13 ++++++++----- host/lib/usrp/multi_usrp.cpp | 22 +++++++++++++++++----- host/lib/usrp/usrp1/usrp1_impl.cpp | 5 +++-- host/lib/usrp/usrp2/usrp2_impl.cpp | 13 ++++++++----- 5 files changed, 44 insertions(+), 22 deletions(-) (limited to 'host/lib/usrp/e100') diff --git a/host/lib/usrp/b100/b100_impl.cpp b/host/lib/usrp/b100/b100_impl.cpp index 0edaac914..944b669b2 100644 --- a/host/lib/usrp/b100/b100_impl.cpp +++ b/host/lib/usrp/b100/b100_impl.cpp @@ -282,19 +282,22 @@ b100_impl::b100_impl(const device_addr_t &device_addr){ _tree->create(mb_path / "tx_subdev_spec") .subscribe(boost::bind(&b100_impl::update_tx_subdev_spec, this, _1)); - _tree->create >(mb_path / "dboards" / "A" / "rx_frontends" / "dc_offset" / "value") + const fs_path rx_fe_path = mb_path / "rx_frontends" / "A"; + const fs_path tx_fe_path = mb_path / "rx_frontends" / "A"; + + _tree->create >(rx_fe_path / "dc_offset" / "value") .coerce(boost::bind(&rx_frontend_core_200::set_dc_offset, _rx_fe, _1)) .set(std::complex(0.0, 0.0)); - _tree->create(mb_path / "dboards" / "A" / "rx_frontends" / "dc_offset" / "enable") + _tree->create(rx_fe_path / "dc_offset" / "enable") .subscribe(boost::bind(&rx_frontend_core_200::set_dc_offset_auto, _rx_fe, _1)) .set(true); - _tree->create >(mb_path / "dboards" / "A" / "rx_frontends" / "iq_balance" / "value") + _tree->create >(rx_fe_path / "iq_balance" / "value") .subscribe(boost::bind(&rx_frontend_core_200::set_iq_balance, _rx_fe, _1)) .set(std::complex(0.0, 0.0)); - _tree->create >(mb_path / "dboards" / "A" / "tx_frontends" / "dc_offset" / "value") + _tree->create >(tx_fe_path / "dc_offset" / "value") .coerce(boost::bind(&tx_frontend_core_200::set_dc_offset, _tx_fe, _1)) .set(std::complex(0.0, 0.0)); - _tree->create >(mb_path / "dboards" / "A" / "tx_frontends" / "iq_balance" / "value") + _tree->create >(tx_fe_path / "iq_balance" / "value") .subscribe(boost::bind(&tx_frontend_core_200::set_iq_balance, _tx_fe, _1)) .set(std::complex(0.0, 0.0)); diff --git a/host/lib/usrp/e100/e100_impl.cpp b/host/lib/usrp/e100/e100_impl.cpp index 4c5f5f066..064686dd2 100644 --- a/host/lib/usrp/e100/e100_impl.cpp +++ b/host/lib/usrp/e100/e100_impl.cpp @@ -256,19 +256,22 @@ e100_impl::e100_impl(const uhd::device_addr_t &device_addr){ _tree->create(mb_path / "tx_subdev_spec") .subscribe(boost::bind(&e100_impl::update_tx_subdev_spec, this, _1)); - _tree->create >(mb_path / "dboards" / "A" / "rx_frontends" / "dc_offset" / "value") + const fs_path rx_fe_path = mb_path / "rx_frontends" / "A"; + const fs_path tx_fe_path = mb_path / "rx_frontends" / "A"; + + _tree->create >(rx_fe_path / "dc_offset" / "value") .coerce(boost::bind(&rx_frontend_core_200::set_dc_offset, _rx_fe, _1)) .set(std::complex(0.0, 0.0)); - _tree->create(mb_path / "dboards" / "A" / "rx_frontends" / "dc_offset" / "enable") + _tree->create(rx_fe_path / "dc_offset" / "enable") .subscribe(boost::bind(&rx_frontend_core_200::set_dc_offset_auto, _rx_fe, _1)) .set(true); - _tree->create >(mb_path / "dboards" / "A" / "rx_frontends" / "iq_balance" / "value") + _tree->create >(rx_fe_path / "iq_balance" / "value") .subscribe(boost::bind(&rx_frontend_core_200::set_iq_balance, _rx_fe, _1)) .set(std::complex(0.0, 0.0)); - _tree->create >(mb_path / "dboards" / "A" / "tx_frontends" / "dc_offset" / "value") + _tree->create >(tx_fe_path / "dc_offset" / "value") .coerce(boost::bind(&tx_frontend_core_200::set_dc_offset, _tx_fe, _1)) .set(std::complex(0.0, 0.0)); - _tree->create >(mb_path / "dboards" / "A" / "tx_frontends" / "iq_balance" / "value") + _tree->create >(tx_fe_path / "iq_balance" / "value") .subscribe(boost::bind(&tx_frontend_core_200::set_iq_balance, _tx_fe, _1)) .set(std::complex(0.0, 0.0)); diff --git a/host/lib/usrp/multi_usrp.cpp b/host/lib/usrp/multi_usrp.cpp index 2e7c76a06..43534ff37 100644 --- a/host/lib/usrp/multi_usrp.cpp +++ b/host/lib/usrp/multi_usrp.cpp @@ -548,7 +548,7 @@ public: void set_rx_dc_offset(const bool enb, size_t chan){ if (chan != ALL_CHANS){ - _tree->access(rx_rf_fe_root(chan).branch_path() / "dc_offset" / "enable").set(enb); + _tree->access(rx_fe_root(chan) / "dc_offset" / "enable").set(enb); return; } for (size_t c = 0; c < get_rx_num_channels(); c++){ @@ -558,7 +558,7 @@ public: void set_rx_dc_offset(const std::complex &offset, size_t chan){ if (chan != ALL_CHANS){ - _tree->access >(rx_rf_fe_root(chan).branch_path() / "dc_offset" / "value").set(offset); + _tree->access >(rx_fe_root(chan) / "dc_offset" / "value").set(offset); return; } for (size_t c = 0; c < get_rx_num_channels(); c++){ @@ -568,7 +568,7 @@ public: void set_rx_iq_balance(const std::complex &offset, size_t chan){ if (chan != ALL_CHANS){ - _tree->access >(rx_rf_fe_root(chan).branch_path() / "iq_balance" / "value").set(offset); + _tree->access >(rx_fe_root(chan) / "iq_balance" / "value").set(offset); return; } for (size_t c = 0; c < get_rx_num_channels(); c++){ @@ -692,7 +692,7 @@ public: void set_tx_dc_offset(const std::complex &offset, size_t chan){ if (chan != ALL_CHANS){ - _tree->access >(tx_rf_fe_root(chan).branch_path() / "dc_offset" / "value").set(offset); + _tree->access >(tx_fe_root(chan) / "dc_offset" / "value").set(offset); return; } for (size_t c = 0; c < get_tx_num_channels(); c++){ @@ -702,7 +702,7 @@ public: void set_tx_iq_balance(const std::complex &offset, size_t chan){ if (chan != ALL_CHANS){ - _tree->access >(tx_rf_fe_root(chan).branch_path() / "iq_balance" / "value").set(offset); + _tree->access >(tx_fe_root(chan) / "iq_balance" / "value").set(offset); return; } for (size_t c = 0; c < get_tx_num_channels(); c++){ @@ -758,6 +758,18 @@ private: return mb_root(mcp.mboard) / "tx_dsps" / name; } + fs_path rx_fe_root(const size_t chan){ + mboard_chan_pair mcp = rx_chan_to_mcp(chan); + const subdev_spec_pair_t spec = get_rx_subdev_spec(mcp.mboard).at(mcp.chan); + return mb_root(mcp.mboard) / "rx_frontends" / spec.db_name; + } + + fs_path tx_fe_root(const size_t chan){ + mboard_chan_pair mcp = tx_chan_to_mcp(chan); + const subdev_spec_pair_t spec = get_tx_subdev_spec(mcp.mboard).at(mcp.chan); + return mb_root(mcp.mboard) / "tx_frontends" / spec.db_name; + } + fs_path rx_rf_fe_root(const size_t chan){ mboard_chan_pair mcp = rx_chan_to_mcp(chan); const subdev_spec_pair_t spec = get_rx_subdev_spec(mcp.mboard).at(mcp.chan); diff --git a/host/lib/usrp/usrp1/usrp1_impl.cpp b/host/lib/usrp/usrp1/usrp1_impl.cpp index fcc4f36ae..6634b43da 100644 --- a/host/lib/usrp/usrp1/usrp1_impl.cpp +++ b/host/lib/usrp/usrp1/usrp1_impl.cpp @@ -272,10 +272,11 @@ usrp1_impl::usrp1_impl(const device_addr_t &device_addr){ .subscribe(boost::bind(&usrp1_impl::update_tx_subdev_spec, this, _1)); BOOST_FOREACH(const std::string &db, _dbc.keys()){ - _tree->create >(mb_path / "dboards" / db / "rx_frontends" / "dc_offset" / "value") + const fs_path rx_fe_path = mb_path / "rx_frontends" / db; + _tree->create >(rx_fe_path / "dc_offset" / "value") .coerce(boost::bind(&usrp1_impl::set_rx_dc_offset, this, db, _1)) .set(std::complex(0.0, 0.0)); - _tree->create(mb_path / "dboards" / db / "rx_frontends" / "dc_offset" / "enable") + _tree->create(rx_fe_path / "dc_offset" / "enable") .subscribe(boost::bind(&usrp1_impl::set_enb_rx_dc_offset, this, db, _1)) .set(true); } diff --git a/host/lib/usrp/usrp2/usrp2_impl.cpp b/host/lib/usrp/usrp2/usrp2_impl.cpp index 50916fb37..db707b6af 100644 --- a/host/lib/usrp/usrp2/usrp2_impl.cpp +++ b/host/lib/usrp/usrp2/usrp2_impl.cpp @@ -462,19 +462,22 @@ usrp2_impl::usrp2_impl(const device_addr_t &_device_addr){ _tree->create(mb_path / "tx_subdev_spec") .subscribe(boost::bind(&usrp2_impl::update_tx_subdev_spec, this, mb, _1)); - _tree->create >(mb_path / "dboards" / "A" / "rx_frontends" / "dc_offset" / "value") + const fs_path rx_fe_path = mb_path / "rx_frontends" / "A"; + const fs_path tx_fe_path = mb_path / "rx_frontends" / "A"; + + _tree->create >(rx_fe_path / "dc_offset" / "value") .coerce(boost::bind(&rx_frontend_core_200::set_dc_offset, _mbc[mb].rx_fe, _1)) .set(std::complex(0.0, 0.0)); - _tree->create(mb_path / "dboards" / "A" / "rx_frontends" / "dc_offset" / "enable") + _tree->create(rx_fe_path / "dc_offset" / "enable") .subscribe(boost::bind(&rx_frontend_core_200::set_dc_offset_auto, _mbc[mb].rx_fe, _1)) .set(true); - _tree->create >(mb_path / "dboards" / "A" / "rx_frontends" / "iq_balance" / "value") + _tree->create >(rx_fe_path / "iq_balance" / "value") .subscribe(boost::bind(&rx_frontend_core_200::set_iq_balance, _mbc[mb].rx_fe, _1)) .set(std::complex(0.0, 0.0)); - _tree->create >(mb_path / "dboards" / "A" / "tx_frontends" / "dc_offset" / "value") + _tree->create >(tx_fe_path / "dc_offset" / "value") .coerce(boost::bind(&tx_frontend_core_200::set_dc_offset, _mbc[mb].tx_fe, _1)) .set(std::complex(0.0, 0.0)); - _tree->create >(mb_path / "dboards" / "A" / "tx_frontends" / "iq_balance" / "value") + _tree->create >(tx_fe_path / "iq_balance" / "value") .subscribe(boost::bind(&tx_frontend_core_200::set_iq_balance, _mbc[mb].tx_fe, _1)) .set(std::complex(0.0, 0.0)); -- cgit v1.2.3 From fbc5b54f49eec3f27e5a351d27260783898b0bea Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Wed, 26 Oct 2011 19:23:24 -0700 Subject: somebody made a typo --- host/lib/usrp/b100/b100_impl.cpp | 2 +- host/lib/usrp/e100/e100_impl.cpp | 2 +- host/lib/usrp/usrp2/usrp2_impl.cpp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) (limited to 'host/lib/usrp/e100') diff --git a/host/lib/usrp/b100/b100_impl.cpp b/host/lib/usrp/b100/b100_impl.cpp index 944b669b2..a047a9a53 100644 --- a/host/lib/usrp/b100/b100_impl.cpp +++ b/host/lib/usrp/b100/b100_impl.cpp @@ -283,7 +283,7 @@ b100_impl::b100_impl(const device_addr_t &device_addr){ .subscribe(boost::bind(&b100_impl::update_tx_subdev_spec, this, _1)); const fs_path rx_fe_path = mb_path / "rx_frontends" / "A"; - const fs_path tx_fe_path = mb_path / "rx_frontends" / "A"; + const fs_path tx_fe_path = mb_path / "tx_frontends" / "A"; _tree->create >(rx_fe_path / "dc_offset" / "value") .coerce(boost::bind(&rx_frontend_core_200::set_dc_offset, _rx_fe, _1)) diff --git a/host/lib/usrp/e100/e100_impl.cpp b/host/lib/usrp/e100/e100_impl.cpp index 064686dd2..00916ec2b 100644 --- a/host/lib/usrp/e100/e100_impl.cpp +++ b/host/lib/usrp/e100/e100_impl.cpp @@ -257,7 +257,7 @@ e100_impl::e100_impl(const uhd::device_addr_t &device_addr){ .subscribe(boost::bind(&e100_impl::update_tx_subdev_spec, this, _1)); const fs_path rx_fe_path = mb_path / "rx_frontends" / "A"; - const fs_path tx_fe_path = mb_path / "rx_frontends" / "A"; + const fs_path tx_fe_path = mb_path / "tx_frontends" / "A"; _tree->create >(rx_fe_path / "dc_offset" / "value") .coerce(boost::bind(&rx_frontend_core_200::set_dc_offset, _rx_fe, _1)) diff --git a/host/lib/usrp/usrp2/usrp2_impl.cpp b/host/lib/usrp/usrp2/usrp2_impl.cpp index db707b6af..ac3ee2e69 100644 --- a/host/lib/usrp/usrp2/usrp2_impl.cpp +++ b/host/lib/usrp/usrp2/usrp2_impl.cpp @@ -463,7 +463,7 @@ usrp2_impl::usrp2_impl(const device_addr_t &_device_addr){ .subscribe(boost::bind(&usrp2_impl::update_tx_subdev_spec, this, mb, _1)); const fs_path rx_fe_path = mb_path / "rx_frontends" / "A"; - const fs_path tx_fe_path = mb_path / "rx_frontends" / "A"; + const fs_path tx_fe_path = mb_path / "tx_frontends" / "A"; _tree->create >(rx_fe_path / "dc_offset" / "value") .coerce(boost::bind(&rx_frontend_core_200::set_dc_offset, _mbc[mb].rx_fe, _1)) -- cgit v1.2.3 From 0e7c8c388a5dcbd70631526b42e08178300b93c4 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Thu, 27 Oct 2011 12:32:06 -0700 Subject: e100/b100: moved gpio regs and compat readback --- host/lib/usrp/b100/b100_impl.cpp | 14 ++++-- host/lib/usrp/b100/b100_impl.hpp | 2 +- host/lib/usrp/b100/b100_regs.hpp | 42 ++---------------- host/lib/usrp/b100/dboard_iface.cpp | 71 +++++------------------------- host/lib/usrp/e100/dboard_iface.cpp | 71 +++++------------------------- host/lib/usrp/e100/e100_impl.cpp | 26 +++++++---- host/lib/usrp/e100/e100_impl.hpp | 3 +- host/lib/usrp/e100/e100_regs.hpp | 42 ++---------------- host/usrp_e_utils/CMakeLists.txt | 2 - host/usrp_e_utils/usrp-e-debug-pins.c | 78 -------------------------------- host/usrp_e_utils/usrp-e-gpio.c | 83 ----------------------------------- 11 files changed, 58 insertions(+), 376 deletions(-) delete mode 100644 host/usrp_e_utils/usrp-e-debug-pins.c delete mode 100644 host/usrp_e_utils/usrp-e-gpio.c (limited to 'host/lib/usrp/e100') diff --git a/host/lib/usrp/b100/b100_impl.cpp b/host/lib/usrp/b100/b100_impl.cpp index a047a9a53..6bebc75ab 100644 --- a/host/lib/usrp/b100/b100_impl.cpp +++ b/host/lib/usrp/b100/b100_impl.cpp @@ -457,13 +457,19 @@ void b100_impl::check_fw_compat(void){ } void b100_impl::check_fpga_compat(void){ - const boost::uint16_t fpga_compat_num = _fpga_ctrl->peek16(B100_REG_MISC_COMPAT); - if (fpga_compat_num != B100_FPGA_COMPAT_NUM){ + const boost::uint32_t fpga_compat_num = _fpga_ctrl->peek32(B100_REG_RB_COMPAT); + boost::uint16_t fpga_major = fpga_compat_num >> 16, fpga_minor = fpga_compat_num & 0xffff; + if (fpga_major == 0){ //old version scheme + fpga_major = fpga_minor; + fpga_minor = 0; + } + if (fpga_major != B100_FPGA_COMPAT_NUM){ throw uhd::runtime_error(str(boost::format( - "Expected FPGA compatibility number 0x%x, but got 0x%x:\n" + "Expected FPGA compatibility number %d, but got %d:\n" "The FPGA build is not compatible with the host code build." - ) % B100_FPGA_COMPAT_NUM % fpga_compat_num)); + ) % int(B100_FPGA_COMPAT_NUM) % fpga_major)); } + _tree->create("/mboards/0/fpga_version").set(str(boost::format("%u.%u") % fpga_major % fpga_minor)); } double b100_impl::update_rx_codec_gain(const double gain){ diff --git a/host/lib/usrp/b100/b100_impl.hpp b/host/lib/usrp/b100/b100_impl.hpp index 25badc967..0984260be 100644 --- a/host/lib/usrp/b100/b100_impl.hpp +++ b/host/lib/usrp/b100/b100_impl.hpp @@ -47,7 +47,7 @@ static const double B100_LINK_RATE_BPS = 256e6/8; //pratical link rate static const std::string B100_FW_FILE_NAME = "usrp_b100_fw.ihx"; static const std::string B100_FPGA_FILE_NAME = "usrp_b100_fpga.bin"; static const boost::uint16_t B100_FW_COMPAT_NUM = 0x02; -static const boost::uint16_t B100_FPGA_COMPAT_NUM = 0x05; +static const boost::uint16_t B100_FPGA_COMPAT_NUM = 0x08; static const boost::uint32_t B100_RX_SID_BASE = 2; static const boost::uint32_t B100_TX_ASYNC_SID = 1; static const double B100_DEFAULT_TICK_RATE = 64e6; diff --git a/host/lib/usrp/b100/b100_regs.hpp b/host/lib/usrp/b100/b100_regs.hpp index 5e24f9937..491e16eef 100644 --- a/host/lib/usrp/b100/b100_regs.hpp +++ b/host/lib/usrp/b100/b100_regs.hpp @@ -31,7 +31,6 @@ #define B100_REG_MISC_RX_LEN B100_REG_MISC_BASE + 10 #define B100_REG_MISC_TX_LEN B100_REG_MISC_BASE + 12 #define B100_REG_MISC_XFER_RATE B100_REG_MISC_BASE + 14 -#define B100_REG_MISC_COMPAT B100_REG_MISC_BASE + 16 ///////////////////////////////////////////////////// // Slave 1 -- UART @@ -61,43 +60,6 @@ #define B100_REG_I2C_BASE B100_REG_SLAVE(3) -//////////////////////////////////////////////// -// Slave 4 -- GPIO - -#define B100_REG_GPIO_BASE B100_REG_SLAVE(4) - -#define B100_REG_GPIO_RX_IO B100_REG_GPIO_BASE + 0 -#define B100_REG_GPIO_TX_IO B100_REG_GPIO_BASE + 2 -#define B100_REG_GPIO_RX_DDR B100_REG_GPIO_BASE + 4 -#define B100_REG_GPIO_TX_DDR B100_REG_GPIO_BASE + 6 -#define B100_REG_GPIO_RX_SEL B100_REG_GPIO_BASE + 8 -#define B100_REG_GPIO_TX_SEL B100_REG_GPIO_BASE + 10 -#define B100_REG_GPIO_RX_DBG B100_REG_GPIO_BASE + 12 -#define B100_REG_GPIO_TX_DBG B100_REG_GPIO_BASE + 14 - -//possible bit values for sel when dbg is 0: -#define GPIO_SEL_SW 0 // if pin is an output, set by software in the io reg -#define GPIO_SEL_ATR 1 // if pin is an output, set by ATR logic - -//possible bit values for sel when dbg is 1: -#define GPIO_SEL_DEBUG_0 0 // if pin is an output, debug lines from FPGA fabric -#define GPIO_SEL_DEBUG_1 1 // if pin is an output, debug lines from FPGA fabric - -/////////////////////////////////////////////////// -// Slave 6 -- ATR Controller -// 16 regs - -#define B100_REG_ATR_BASE B100_REG_SLAVE(6) - -#define B100_REG_ATR_IDLE_RXSIDE B100_REG_ATR_BASE + 0 -#define B100_REG_ATR_IDLE_TXSIDE B100_REG_ATR_BASE + 2 -#define B100_REG_ATR_INTX_RXSIDE B100_REG_ATR_BASE + 4 -#define B100_REG_ATR_INTX_TXSIDE B100_REG_ATR_BASE + 6 -#define B100_REG_ATR_INRX_RXSIDE B100_REG_ATR_BASE + 8 -#define B100_REG_ATR_INRX_TXSIDE B100_REG_ATR_BASE + 10 -#define B100_REG_ATR_FULL_RXSIDE B100_REG_ATR_BASE + 12 -#define B100_REG_ATR_FULL_TXSIDE B100_REG_ATR_BASE + 14 - /////////////////////////////////////////////////// // Slave 7 -- Readback Mux 32 @@ -108,6 +70,8 @@ #define B100_REG_RB_TIME_PPS_SECS B100_REG_RB_MUX_32_BASE + 8 #define B100_REG_RB_TIME_PPS_TICKS B100_REG_RB_MUX_32_BASE + 12 #define B100_REG_RB_MISC_TEST32 B100_REG_RB_MUX_32_BASE + 16 +#define B100_REG_RB_COMPAT B100_REG_RB_MUX_32_BASE + 24 +#define B100_REG_RB_GPIO B100_REG_RB_MUX_32_BASE + 28 //////////////////////////////////////////////////// // Slaves 8 & 9 -- Settings Bus @@ -132,6 +96,8 @@ #define B100_SR_CLEAR_TX_FIFO 62 // 1 reg #define B100_SR_GLOBAL_RESET 63 // 1 reg +#define B100_SR_GPIO 128 + #define B100_REG_SR_ADDR(n) (B100_REG_SLAVE(8) + (4*(n))) #define B100_REG_SR_MISC_TEST32 B100_REG_SR_ADDR(B100_SR_REG_TEST32) diff --git a/host/lib/usrp/b100/dboard_iface.cpp b/host/lib/usrp/b100/dboard_iface.cpp index 229215a4e..39ad5c5ac 100644 --- a/host/lib/usrp/b100/dboard_iface.cpp +++ b/host/lib/usrp/b100/dboard_iface.cpp @@ -15,7 +15,7 @@ // along with this program. If not, see . // -#include "wb_iface.hpp" +#include "gpio_core_200.hpp" #include #include "b100_regs.hpp" #include "clock_ctrl.hpp" @@ -45,13 +45,11 @@ public: _spi_iface = spi_iface; _clock = clock; _codec = codec; + _gpio = gpio_core_200::make(_wb_iface, B100_REG_SR_ADDR(B100_SR_GPIO), B100_REG_RB_GPIO); //init the clock rate shadows this->set_clock_rate(UNIT_RX, _clock->get_fpga_clock_rate()); this->set_clock_rate(UNIT_TX, _clock->get_fpga_clock_rate()); - - _wb_iface->poke16(B100_REG_GPIO_RX_DBG, 0); - _wb_iface->poke16(B100_REG_GPIO_TX_DBG, 0); } ~b100_dboard_iface(void){ @@ -104,6 +102,7 @@ private: spi_iface::sptr _spi_iface; b100_clock_ctrl::sptr _clock; b100_codec_ctrl::sptr _codec; + gpio_core_200::sptr _gpio; }; /*********************************************************************** @@ -160,77 +159,27 @@ double b100_dboard_iface::get_codec_rate(unit_t){ * GPIO **********************************************************************/ void b100_dboard_iface::_set_pin_ctrl(unit_t unit, boost::uint16_t value){ - UHD_ASSERT_THROW(GPIO_SEL_ATR == 1); //make this assumption - switch(unit){ - case UNIT_RX: _wb_iface->poke16(B100_REG_GPIO_RX_SEL, value); return; - case UNIT_TX: _wb_iface->poke16(B100_REG_GPIO_TX_SEL, value); return; - } + return _gpio->set_pin_ctrl(unit, value); } void b100_dboard_iface::_set_gpio_ddr(unit_t unit, boost::uint16_t value){ - switch(unit){ - case UNIT_RX: _wb_iface->poke16(B100_REG_GPIO_RX_DDR, value); return; - case UNIT_TX: _wb_iface->poke16(B100_REG_GPIO_TX_DDR, value); return; - } + return _gpio->set_gpio_ddr(unit, value); } void b100_dboard_iface::_set_gpio_out(unit_t unit, boost::uint16_t value){ - switch(unit){ - case UNIT_RX: _wb_iface->poke16(B100_REG_GPIO_RX_IO, value); return; - case UNIT_TX: _wb_iface->poke16(B100_REG_GPIO_TX_IO, value); return; - } + return _gpio->set_gpio_out(unit, value); } boost::uint16_t b100_dboard_iface::read_gpio(unit_t unit){ - switch(unit){ - case UNIT_RX: return _wb_iface->peek16(B100_REG_GPIO_RX_IO); - case UNIT_TX: return _wb_iface->peek16(B100_REG_GPIO_TX_IO); - default: UHD_THROW_INVALID_CODE_PATH(); - } + return _gpio->read_gpio(unit); } void b100_dboard_iface::_set_atr_reg(unit_t unit, atr_reg_t atr, boost::uint16_t value){ - //define mapping of unit to atr regs to register address - static const uhd::dict< - unit_t, uhd::dict - > unit_to_atr_to_addr = map_list_of - (UNIT_RX, map_list_of - (ATR_REG_IDLE, B100_REG_ATR_IDLE_RXSIDE) - (ATR_REG_TX_ONLY, B100_REG_ATR_INTX_RXSIDE) - (ATR_REG_RX_ONLY, B100_REG_ATR_INRX_RXSIDE) - (ATR_REG_FULL_DUPLEX, B100_REG_ATR_FULL_RXSIDE) - ) - (UNIT_TX, map_list_of - (ATR_REG_IDLE, B100_REG_ATR_IDLE_TXSIDE) - (ATR_REG_TX_ONLY, B100_REG_ATR_INTX_TXSIDE) - (ATR_REG_RX_ONLY, B100_REG_ATR_INRX_TXSIDE) - (ATR_REG_FULL_DUPLEX, B100_REG_ATR_FULL_TXSIDE) - ) - ; - _wb_iface->poke16(unit_to_atr_to_addr[unit][atr], value); + return _gpio->set_atr_reg(unit, atr, value); } -void b100_dboard_iface::set_gpio_debug(unit_t unit, int which){ - //set this unit to all outputs - this->set_gpio_ddr(unit, 0xffff); - - //calculate the debug selections - boost::uint32_t dbg_sels = 0x0; - int sel = (which == 0)? GPIO_SEL_DEBUG_0 : GPIO_SEL_DEBUG_1; - for(size_t i = 0; i < 16; i++) dbg_sels |= sel << i; - - //set the debug on and which debug selection - switch(unit){ - case UNIT_RX: - _wb_iface->poke16(B100_REG_GPIO_RX_DBG, 0xffff); - _wb_iface->poke16(B100_REG_GPIO_RX_SEL, dbg_sels); - return; - - case UNIT_TX: - _wb_iface->poke16(B100_REG_GPIO_TX_DBG, 0xffff); - _wb_iface->poke16(B100_REG_GPIO_TX_SEL, dbg_sels); - return; - } +void b100_dboard_iface::set_gpio_debug(unit_t, int){ + throw uhd::not_implemented_error("no set_gpio_debug implemented"); } /*********************************************************************** diff --git a/host/lib/usrp/e100/dboard_iface.cpp b/host/lib/usrp/e100/dboard_iface.cpp index d45577bd9..6afc7bc48 100644 --- a/host/lib/usrp/e100/dboard_iface.cpp +++ b/host/lib/usrp/e100/dboard_iface.cpp @@ -15,7 +15,7 @@ // along with this program. If not, see . // -#include "wb_iface.hpp" +#include "gpio_core_200.hpp" #include #include "e100_regs.hpp" #include "clock_ctrl.hpp" @@ -45,13 +45,11 @@ public: _spi_iface = spi_iface; _clock = clock; _codec = codec; + _gpio = gpio_core_200::make(_wb_iface, E100_REG_SR_ADDR(UE_SR_GPIO), E100_REG_RB_GPIO); //init the clock rate shadows this->set_clock_rate(UNIT_RX, _clock->get_fpga_clock_rate()); this->set_clock_rate(UNIT_TX, _clock->get_fpga_clock_rate()); - - _wb_iface->poke16(E100_REG_GPIO_RX_DBG, 0); - _wb_iface->poke16(E100_REG_GPIO_TX_DBG, 0); } ~e100_dboard_iface(void){ @@ -104,6 +102,7 @@ private: spi_iface::sptr _spi_iface; e100_clock_ctrl::sptr _clock; e100_codec_ctrl::sptr _codec; + gpio_core_200::sptr _gpio; }; /*********************************************************************** @@ -160,77 +159,27 @@ double e100_dboard_iface::get_codec_rate(unit_t){ * GPIO **********************************************************************/ void e100_dboard_iface::_set_pin_ctrl(unit_t unit, boost::uint16_t value){ - UHD_ASSERT_THROW(GPIO_SEL_ATR == 1); //make this assumption - switch(unit){ - case UNIT_RX: _wb_iface->poke16(E100_REG_GPIO_RX_SEL, value); return; - case UNIT_TX: _wb_iface->poke16(E100_REG_GPIO_TX_SEL, value); return; - } + return _gpio->set_pin_ctrl(unit, value); } void e100_dboard_iface::_set_gpio_ddr(unit_t unit, boost::uint16_t value){ - switch(unit){ - case UNIT_RX: _wb_iface->poke16(E100_REG_GPIO_RX_DDR, value); return; - case UNIT_TX: _wb_iface->poke16(E100_REG_GPIO_TX_DDR, value); return; - } + return _gpio->set_gpio_ddr(unit, value); } void e100_dboard_iface::_set_gpio_out(unit_t unit, boost::uint16_t value){ - switch(unit){ - case UNIT_RX: _wb_iface->poke16(E100_REG_GPIO_RX_IO, value); return; - case UNIT_TX: _wb_iface->poke16(E100_REG_GPIO_TX_IO, value); return; - } + return _gpio->set_gpio_out(unit, value); } boost::uint16_t e100_dboard_iface::read_gpio(unit_t unit){ - switch(unit){ - case UNIT_RX: return _wb_iface->peek16(E100_REG_GPIO_RX_IO); - case UNIT_TX: return _wb_iface->peek16(E100_REG_GPIO_TX_IO); - default: UHD_THROW_INVALID_CODE_PATH(); - } + return _gpio->read_gpio(unit); } void e100_dboard_iface::_set_atr_reg(unit_t unit, atr_reg_t atr, boost::uint16_t value){ - //define mapping of unit to atr regs to register address - static const uhd::dict< - unit_t, uhd::dict - > unit_to_atr_to_addr = map_list_of - (UNIT_RX, map_list_of - (ATR_REG_IDLE, E100_REG_ATR_IDLE_RXSIDE) - (ATR_REG_TX_ONLY, E100_REG_ATR_INTX_RXSIDE) - (ATR_REG_RX_ONLY, E100_REG_ATR_INRX_RXSIDE) - (ATR_REG_FULL_DUPLEX, E100_REG_ATR_FULL_RXSIDE) - ) - (UNIT_TX, map_list_of - (ATR_REG_IDLE, E100_REG_ATR_IDLE_TXSIDE) - (ATR_REG_TX_ONLY, E100_REG_ATR_INTX_TXSIDE) - (ATR_REG_RX_ONLY, E100_REG_ATR_INRX_TXSIDE) - (ATR_REG_FULL_DUPLEX, E100_REG_ATR_FULL_TXSIDE) - ) - ; - _wb_iface->poke16(unit_to_atr_to_addr[unit][atr], value); + return _gpio->set_atr_reg(unit, atr, value); } -void e100_dboard_iface::set_gpio_debug(unit_t unit, int which){ - //set this unit to all outputs - this->set_gpio_ddr(unit, 0xffff); - - //calculate the debug selections - boost::uint32_t dbg_sels = 0x0; - int sel = (which == 0)? GPIO_SEL_DEBUG_0 : GPIO_SEL_DEBUG_1; - for(size_t i = 0; i < 16; i++) dbg_sels |= sel << i; - - //set the debug on and which debug selection - switch(unit){ - case UNIT_RX: - _wb_iface->poke16(E100_REG_GPIO_RX_DBG, 0xffff); - _wb_iface->poke16(E100_REG_GPIO_RX_SEL, dbg_sels); - return; - - case UNIT_TX: - _wb_iface->poke16(E100_REG_GPIO_TX_DBG, 0xffff); - _wb_iface->poke16(E100_REG_GPIO_TX_SEL, dbg_sels); - return; - } +void e100_dboard_iface::set_gpio_debug(unit_t, int){ + throw uhd::not_implemented_error("no set_gpio_debug implemented"); } /*********************************************************************** diff --git a/host/lib/usrp/e100/e100_impl.cpp b/host/lib/usrp/e100/e100_impl.cpp index 00916ec2b..8fe9081b1 100644 --- a/host/lib/usrp/e100/e100_impl.cpp +++ b/host/lib/usrp/e100/e100_impl.cpp @@ -167,15 +167,7 @@ e100_impl::e100_impl(const uhd::device_addr_t &device_addr){ ); //check that the compatibility is correct - const boost::uint16_t fpga_compat_num = _fpga_ctrl->peek16(E100_REG_MISC_COMPAT); - if (fpga_compat_num != E100_FPGA_COMPAT_NUM){ - throw uhd::runtime_error(str(boost::format( - "\nPlease update the FPGA image for your device.\n" - "See the application notes for USRP E-Series for instructions.\n" - "Expected FPGA compatibility number 0x%x, but got 0x%x:\n" - "The FPGA build is not compatible with the host code build." - ) % E100_FPGA_COMPAT_NUM % fpga_compat_num)); - } + this->check_fpga_compat(); //////////////////////////////////////////////////////////////////// // Create controller objects @@ -455,3 +447,19 @@ sensor_value_t e100_impl::get_ref_locked(void){ const bool lock = _clock_ctrl->get_locked(); return sensor_value_t("Ref", lock, "locked", "unlocked"); } + +void e100_impl::check_fpga_compat(void){ + const boost::uint32_t fpga_compat_num = _fpga_ctrl->peek32(E100_REG_RB_COMPAT); + boost::uint16_t fpga_major = fpga_compat_num >> 16, fpga_minor = fpga_compat_num & 0xffff; + if (fpga_major == 0){ //old version scheme + fpga_major = fpga_minor; + fpga_minor = 0; + } + if (fpga_major != E100_FPGA_COMPAT_NUM){ + throw uhd::runtime_error(str(boost::format( + "Expected FPGA compatibility number %d, but got %d:\n" + "The FPGA build is not compatible with the host code build." + ) % int(E100_FPGA_COMPAT_NUM) % fpga_major)); + } + _tree->create("/mboards/0/fpga_version").set(str(boost::format("%u.%u") % fpga_major % fpga_minor)); +} diff --git a/host/lib/usrp/e100/e100_impl.hpp b/host/lib/usrp/e100/e100_impl.hpp index 954d6bd93..f3e481b93 100644 --- a/host/lib/usrp/e100/e100_impl.hpp +++ b/host/lib/usrp/e100/e100_impl.hpp @@ -48,7 +48,7 @@ static const double E100_RX_LINK_RATE_BPS = 166e6/3/2*2; static const double E100_TX_LINK_RATE_BPS = 166e6/3/1*2; static const std::string E100_I2C_DEV_NODE = "/dev/i2c-3"; static const std::string E100_UART_DEV_NODE = "/dev/ttyO0"; -static const boost::uint16_t E100_FPGA_COMPAT_NUM = 0x06; +static const boost::uint16_t E100_FPGA_COMPAT_NUM = 0x08; static const boost::uint32_t E100_RX_SID_BASE = 2; static const boost::uint32_t E100_TX_ASYNC_SID = 1; static const double E100_DEFAULT_CLOCK_RATE = 64e6; @@ -129,6 +129,7 @@ private: void update_tx_subdev_spec(const uhd::usrp::subdev_spec_t &); void update_clock_source(const std::string &); uhd::sensor_value_t get_ref_locked(void); + void check_fpga_compat(void); }; diff --git a/host/lib/usrp/e100/e100_regs.hpp b/host/lib/usrp/e100/e100_regs.hpp index 28ef707dc..f24f5895b 100644 --- a/host/lib/usrp/e100/e100_regs.hpp +++ b/host/lib/usrp/e100/e100_regs.hpp @@ -31,7 +31,6 @@ #define E100_REG_MISC_RX_LEN E100_REG_MISC_BASE + 10 #define E100_REG_MISC_TX_LEN E100_REG_MISC_BASE + 12 #define E100_REG_MISC_XFER_RATE E100_REG_MISC_BASE + 14 -#define E100_REG_MISC_COMPAT E100_REG_MISC_BASE + 16 ///////////////////////////////////////////////////// // Slave 1 -- UART @@ -67,43 +66,6 @@ #define E100_REG_ERR_BUFF E100_REG_SLAVE(5) -//////////////////////////////////////////////// -// Slave 4 -- GPIO - -#define E100_REG_GPIO_BASE E100_REG_SLAVE(4) - -#define E100_REG_GPIO_RX_IO E100_REG_GPIO_BASE + 0 -#define E100_REG_GPIO_TX_IO E100_REG_GPIO_BASE + 2 -#define E100_REG_GPIO_RX_DDR E100_REG_GPIO_BASE + 4 -#define E100_REG_GPIO_TX_DDR E100_REG_GPIO_BASE + 6 -#define E100_REG_GPIO_RX_SEL E100_REG_GPIO_BASE + 8 -#define E100_REG_GPIO_TX_SEL E100_REG_GPIO_BASE + 10 -#define E100_REG_GPIO_RX_DBG E100_REG_GPIO_BASE + 12 -#define E100_REG_GPIO_TX_DBG E100_REG_GPIO_BASE + 14 - -//possible bit values for sel when dbg is 0: -#define GPIO_SEL_SW 0 // if pin is an output, set by software in the io reg -#define GPIO_SEL_ATR 1 // if pin is an output, set by ATR logic - -//possible bit values for sel when dbg is 1: -#define GPIO_SEL_DEBUG_0 0 // if pin is an output, debug lines from FPGA fabric -#define GPIO_SEL_DEBUG_1 1 // if pin is an output, debug lines from FPGA fabric - -/////////////////////////////////////////////////// -// Slave 6 -- ATR Controller -// 16 regs - -#define E100_REG_ATR_BASE E100_REG_SLAVE(6) - -#define E100_REG_ATR_IDLE_RXSIDE E100_REG_ATR_BASE + 0 -#define E100_REG_ATR_IDLE_TXSIDE E100_REG_ATR_BASE + 2 -#define E100_REG_ATR_INTX_RXSIDE E100_REG_ATR_BASE + 4 -#define E100_REG_ATR_INTX_TXSIDE E100_REG_ATR_BASE + 6 -#define E100_REG_ATR_INRX_RXSIDE E100_REG_ATR_BASE + 8 -#define E100_REG_ATR_INRX_TXSIDE E100_REG_ATR_BASE + 10 -#define E100_REG_ATR_FULL_RXSIDE E100_REG_ATR_BASE + 12 -#define E100_REG_ATR_FULL_TXSIDE E100_REG_ATR_BASE + 14 - /////////////////////////////////////////////////// // Slave 7 -- Readback Mux 32 @@ -115,6 +77,8 @@ #define E100_REG_RB_TIME_PPS_TICKS E100_REG_RB_MUX_32_BASE + 12 #define E100_REG_RB_MISC_TEST32 E100_REG_RB_MUX_32_BASE + 16 #define E100_REG_RB_ERR_STATUS E100_REG_RB_MUX_32_BASE + 20 +#define E100_REG_RB_COMPAT E100_REG_RB_MUX_32_BASE + 24 +#define E100_REG_RB_GPIO E100_REG_RB_MUX_32_BASE + 28 //////////////////////////////////////////////////// // Slave 8 -- Settings Bus @@ -141,6 +105,8 @@ #define UE_SR_CLEAR_TX_FIFO 62 // 1 reg #define UE_SR_GLOBAL_RESET 63 // 1 reg +#define UE_SR_GPIO 128 + #define E100_REG_SR_ADDR(n) (E100_REG_SLAVE(8) + (4*(n))) #define E100_REG_SR_MISC_TEST32 E100_REG_SR_ADDR(UE_SR_REG_TEST32) diff --git a/host/usrp_e_utils/CMakeLists.txt b/host/usrp_e_utils/CMakeLists.txt index 721a40093..2b099cc5d 100644 --- a/host/usrp_e_utils/CMakeLists.txt +++ b/host/usrp_e_utils/CMakeLists.txt @@ -29,8 +29,6 @@ IF(ENABLE_USRP_E_UTILS) SET(usrp_e_utils_sources usrp-e-loopback.cpp usrp-e-wb-test.cpp - usrp-e-debug-pins.c - usrp-e-gpio.c ) #for each source: build an executable and install diff --git a/host/usrp_e_utils/usrp-e-debug-pins.c b/host/usrp_e_utils/usrp-e-debug-pins.c deleted file mode 100644 index 570ae63d8..000000000 --- a/host/usrp_e_utils/usrp-e-debug-pins.c +++ /dev/null @@ -1,78 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include - -#include -#include "e100_regs.hpp" - -// Usage: usrp_e_gpio - -static int fp; - -static int read_reg(__u16 reg) -{ - int ret; - struct usrp_e_ctl16 d; - - d.offset = reg; - d.count = 1; - ret = ioctl(fp, USRP_E_READ_CTL16, &d); - return d.buf[0]; -} - -static void write_reg(__u16 reg, __u16 val) -{ - int ret; - struct usrp_e_ctl16 d; - - d.offset = reg; - d.count = 1; - d.buf[0] = val; - ret = ioctl(fp, USRP_E_WRITE_CTL16, &d); -} - -int main(int argc, char *argv[]) -{ - int test; - - test = 0; - if (argc < 2) { - printf("%s 0|1|off\n", argv[0]); - return -1; - } - - fp = open("/dev/usrp_e0", O_RDWR); - printf("fp = %d\n", fp); - if (fp < 0) { - perror("Open failed"); - return -1; - } - - if (strcmp(argv[1], "0") == 0) { - printf("Selected 0 based on %s\n", argv[1]); - write_reg(E100_REG_GPIO_TX_DDR, 0xFFFF); - write_reg(E100_REG_GPIO_RX_DDR, 0xFFFF); - write_reg(E100_REG_GPIO_TX_SEL, 0x0); - write_reg(E100_REG_GPIO_RX_SEL, 0x0); - write_reg(E100_REG_GPIO_TX_DBG, 0xFFFF); - write_reg(E100_REG_GPIO_RX_DBG, 0xFFFF); - } else if (strcmp(argv[1], "1") == 0) { - printf("Selected 1 based on %s\n", argv[1]); - write_reg(E100_REG_GPIO_TX_DDR, 0xFFFF); - write_reg(E100_REG_GPIO_RX_DDR, 0xFFFF); - write_reg(E100_REG_GPIO_TX_SEL, 0xFFFF); - write_reg(E100_REG_GPIO_RX_SEL, 0xFFFF); - write_reg(E100_REG_GPIO_TX_DBG, 0xFFFF); - write_reg(E100_REG_GPIO_RX_DBG, 0xFFFF); - } else { - printf("Selected off based on %s\n", argv[1]); - write_reg(E100_REG_GPIO_TX_DDR, 0x0); - write_reg(E100_REG_GPIO_RX_DDR, 0x0); - } - - return 0; -} diff --git a/host/usrp_e_utils/usrp-e-gpio.c b/host/usrp_e_utils/usrp-e-gpio.c deleted file mode 100644 index 4b788e945..000000000 --- a/host/usrp_e_utils/usrp-e-gpio.c +++ /dev/null @@ -1,83 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include - -#include "linux/usrp_e.h" -#include "e100_regs.hpp" - -// Usage: usrp_e_gpio - -static int fp; - -static int read_reg(__u16 reg) -{ - int ret; - struct usrp_e_ctl16 d; - - d.offset = reg; - d.count = 1; - ret = ioctl(fp, USRP_E_READ_CTL16, &d); - return d.buf[0]; -} - -static void write_reg(__u16 reg, __u16 val) -{ - int ret; - struct usrp_e_ctl16 d; - - d.offset = reg; - d.count = 1; - d.buf[0] = val; - ret = ioctl(fp, USRP_E_WRITE_CTL16, &d); -} - -int main(int argc, char *argv[]) -{ - int i, test, data_in; - - test = 0; - if (argc > 1) - test = 1; - - fp = open("/dev/usrp_e0", O_RDWR); - printf("fp = %d\n", fp); - - write_reg(E100_REG_GPIO_TX_DDR, 0x0); - write_reg(E100_REG_GPIO_RX_DDR, 0xFFFF); - - for (i=0; i < 16; i++) { - write_reg(E100_REG_GPIO_RX_IO, 1 << i); - sleep(1); - if (test) { - data_in = read_reg(E100_REG_GPIO_TX_IO); - if (data_in != (1 << i)) - printf("Read failed, wrote: %X read: %X\n", \ - 1 << i, data_in); - } - } - - write_reg(E100_REG_GPIO_RX_DDR, 0x0); - write_reg(E100_REG_GPIO_TX_DDR, 0xFFFF); - - sleep(1); - - for (i=0; i < 16; i++) { - write_reg(E100_REG_GPIO_TX_IO, 1 << i); - sleep(1); - if (test) { - data_in = read_reg(E100_REG_GPIO_RX_IO); - if (data_in != (1 << i)) - printf("Read failed, wrote: %X read: %X\n", \ - 1 << i, data_in); - } - } - - write_reg(E100_REG_GPIO_RX_DDR, 0x0); - write_reg(E100_REG_GPIO_TX_DDR, 0x0); - - return 0; -} -- cgit v1.2.3 From 9c598203327943b6ec042b031849ec6d7d907479 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Fri, 4 Nov 2011 23:23:47 +0000 Subject: e100/b100: init tree before filling it git log --- host/lib/usrp/b100/b100_impl.cpp | 2 +- host/lib/usrp/e100/e100_impl.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'host/lib/usrp/e100') diff --git a/host/lib/usrp/b100/b100_impl.cpp b/host/lib/usrp/b100/b100_impl.cpp index 6bebc75ab..c15816cc2 100644 --- a/host/lib/usrp/b100/b100_impl.cpp +++ b/host/lib/usrp/b100/b100_impl.cpp @@ -139,6 +139,7 @@ UHD_STATIC_BLOCK(register_b100_device){ * Structors **********************************************************************/ b100_impl::b100_impl(const device_addr_t &device_addr){ + _tree = property_tree::make(); //extract the FPGA path for the B100 std::string b100_fpga_image = find_image_path( @@ -226,7 +227,6 @@ b100_impl::b100_impl(const device_addr_t &device_addr){ //////////////////////////////////////////////////////////////////// // Initialize the properties tree //////////////////////////////////////////////////////////////////// - _tree = property_tree::make(); _tree->create("/name").set("B-Series Device"); const fs_path mb_path = "/mboards/0"; _tree->create(mb_path / "name").set("B100 (B-Hundo)"); diff --git a/host/lib/usrp/e100/e100_impl.cpp b/host/lib/usrp/e100/e100_impl.cpp index 8fe9081b1..2e3a635a6 100644 --- a/host/lib/usrp/e100/e100_impl.cpp +++ b/host/lib/usrp/e100/e100_impl.cpp @@ -106,6 +106,7 @@ UHD_STATIC_BLOCK(register_e100_device){ * Structors **********************************************************************/ e100_impl::e100_impl(const uhd::device_addr_t &device_addr){ + _tree = property_tree::make(); //setup the main interface into fpga const std::string node = device_addr["node"]; @@ -179,7 +180,6 @@ e100_impl::e100_impl(const uhd::device_addr_t &device_addr){ //////////////////////////////////////////////////////////////////// // Initialize the properties tree //////////////////////////////////////////////////////////////////// - _tree = property_tree::make(); _tree->create("/name").set("E-Series Device"); const fs_path mb_path = "/mboards/0"; _tree->create(mb_path / "name").set(str(boost::format("%s (euewanee)") % model)); -- cgit v1.2.3 From 8bb81824ea3544352cf528cbd67efd04bde681c9 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Sat, 5 Nov 2011 12:14:14 -0700 Subject: usrp: parse rx stream args scalar --- host/lib/usrp/b100/io_impl.cpp | 3 ++- host/lib/usrp/e100/io_impl.cpp | 3 ++- host/lib/usrp/usrp2/io_impl.cpp | 3 ++- 3 files changed, 6 insertions(+), 3 deletions(-) (limited to 'host/lib/usrp/e100') diff --git a/host/lib/usrp/b100/io_impl.cpp b/host/lib/usrp/b100/io_impl.cpp index 28b19f14e..abbd9864f 100644 --- a/host/lib/usrp/b100/io_impl.cpp +++ b/host/lib/usrp/b100/io_impl.cpp @@ -199,6 +199,7 @@ rx_streamer::sptr b100_impl::get_rx_stream(const uhd::stream_args_t &args_){ //setup defaults for unspecified values args.otw_format = args.otw_format.empty()? "sc16" : args.otw_format; args.channels = args.channels.empty()? std::vector(1, 0) : args.channels; + const unsigned sc8_scalar = unsigned(args.args.cast("scalar", 0x400)); //calculate packet size static const size_t hdr_size = 0 @@ -228,7 +229,7 @@ rx_streamer::sptr b100_impl::get_rx_stream(const uhd::stream_args_t &args_){ for (size_t chan_i = 0; chan_i < args.channels.size(); chan_i++){ const size_t dsp = args.channels[chan_i]; _rx_dsps[dsp]->set_nsamps_per_packet(spp); //seems to be a good place to set this - _rx_dsps[dsp]->set_format(args.otw_format, 0x400); + _rx_dsps[dsp]->set_format(args.otw_format, sc8_scalar); my_streamer->set_xport_chan_get_buff(chan_i, boost::bind( &recv_packet_demuxer::get_recv_buff, _io_impl->demuxer, dsp, _1 )); diff --git a/host/lib/usrp/e100/io_impl.cpp b/host/lib/usrp/e100/io_impl.cpp index c47eb8940..3b0828b45 100644 --- a/host/lib/usrp/e100/io_impl.cpp +++ b/host/lib/usrp/e100/io_impl.cpp @@ -275,6 +275,7 @@ rx_streamer::sptr e100_impl::get_rx_stream(const uhd::stream_args_t &args_){ //setup defaults for unspecified values args.otw_format = args.otw_format.empty()? "sc16" : args.otw_format; args.channels = args.channels.empty()? std::vector(1, 0) : args.channels; + const unsigned sc8_scalar = unsigned(args.args.cast("scalar", 0x400)); //calculate packet size static const size_t hdr_size = 0 @@ -304,7 +305,7 @@ rx_streamer::sptr e100_impl::get_rx_stream(const uhd::stream_args_t &args_){ for (size_t chan_i = 0; chan_i < args.channels.size(); chan_i++){ const size_t dsp = args.channels[chan_i]; _rx_dsps[dsp]->set_nsamps_per_packet(spp); //seems to be a good place to set this - _rx_dsps[dsp]->set_format(args.otw_format, 0x400); + _rx_dsps[dsp]->set_format(args.otw_format, sc8_scalar); my_streamer->set_xport_chan_get_buff(chan_i, boost::bind( &recv_packet_demuxer::get_recv_buff, _io_impl->demuxer, dsp, _1 )); diff --git a/host/lib/usrp/usrp2/io_impl.cpp b/host/lib/usrp/usrp2/io_impl.cpp index 660156285..d144c08bf 100644 --- a/host/lib/usrp/usrp2/io_impl.cpp +++ b/host/lib/usrp/usrp2/io_impl.cpp @@ -372,6 +372,7 @@ rx_streamer::sptr usrp2_impl::get_rx_stream(const uhd::stream_args_t &args_){ //setup defaults for unspecified values args.otw_format = args.otw_format.empty()? "sc16" : args.otw_format; args.channels = args.channels.empty()? std::vector(1, 0) : args.channels; + const unsigned sc8_scalar = unsigned(args.args.cast("scalar", 0x400)); //calculate packet size static const size_t hdr_size = 0 @@ -406,7 +407,7 @@ rx_streamer::sptr usrp2_impl::get_rx_stream(const uhd::stream_args_t &args_){ if (chan < num_chan_so_far){ const size_t dsp = num_chan_so_far - chan - 1; _mbc[mb].rx_dsps[dsp]->set_nsamps_per_packet(spp); //seems to be a good place to set this - _mbc[mb].rx_dsps[dsp]->set_format(args.otw_format, 0x400); + _mbc[mb].rx_dsps[dsp]->set_format(args.otw_format, sc8_scalar); my_streamer->set_xport_chan_get_buff(chan_i, boost::bind( &zero_copy_if::get_recv_buff, _mbc[mb].rx_dsp_xports[dsp], _1 )); -- cgit v1.2.3 From d9035414a27f484b89816e6e99c7f14d1769dee0 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Sat, 30 Jul 2011 10:11:49 -0700 Subject: usrp: work on dboard code to use subtrees to populate frontend props --- host/include/uhd/usrp/dboard_base.hpp | 62 +------ host/include/uhd/usrp/dboard_manager.hpp | 24 +-- host/lib/usrp/b100/b100_impl.cpp | 21 +-- host/lib/usrp/dboard/CMakeLists.txt | 22 +-- host/lib/usrp/dboard_base.cpp | 41 +---- host/lib/usrp/dboard_ctor_args.hpp | 2 + host/lib/usrp/dboard_manager.cpp | 273 ++++--------------------------- host/lib/usrp/e100/e100_impl.cpp | 21 +-- host/lib/usrp/usrp1/usrp1_impl.cpp | 21 +-- host/lib/usrp/usrp2/usrp2_impl.cpp | 21 +-- 10 files changed, 85 insertions(+), 423 deletions(-) (limited to 'host/lib/usrp/e100') diff --git a/host/include/uhd/usrp/dboard_base.hpp b/host/include/uhd/usrp/dboard_base.hpp index 7e9557a95..31b3643c7 100644 --- a/host/include/uhd/usrp/dboard_base.hpp +++ b/host/include/uhd/usrp/dboard_base.hpp @@ -19,7 +19,7 @@ #define INCLUDED_UHD_USRP_DBOARD_BASE_HPP #include -#include +#include #include #include #include @@ -28,43 +28,6 @@ namespace uhd{ namespace usrp{ - /*! - * Possible subdev connection types: - * - * A complex subdevice is physically connected to both channels, - * which may be connected in one of two ways: IQ or QI (swapped). - * - * A real subdevice is only physically connected one channel, - * either only the I channel or only the Q channel. - */ - enum subdev_conn_t{ - SUBDEV_CONN_COMPLEX_IQ = 'C', - SUBDEV_CONN_COMPLEX_QI = 'c', - SUBDEV_CONN_REAL_I = 'R', - SUBDEV_CONN_REAL_Q = 'r' - }; - - /*! - * Possible device subdev properties - */ - enum subdev_prop_t{ - SUBDEV_PROP_NAME, //ro, std::string - SUBDEV_PROP_OTHERS, //ro, prop_names_t - SUBDEV_PROP_SENSOR, //ro, sensor_value_t - SUBDEV_PROP_SENSOR_NAMES, //ro, prop_names_t - SUBDEV_PROP_GAIN, //rw, double - SUBDEV_PROP_GAIN_RANGE, //ro, gain_range_t - SUBDEV_PROP_GAIN_NAMES, //ro, prop_names_t - SUBDEV_PROP_FREQ, //rw, double - SUBDEV_PROP_FREQ_RANGE, //ro, freq_range_t - SUBDEV_PROP_ANTENNA, //rw, std::string - SUBDEV_PROP_ANTENNA_NAMES, //ro, prop_names_t - SUBDEV_PROP_CONNECTION, //ro, subdev_conn_t - SUBDEV_PROP_ENABLED, //rw, bool - SUBDEV_PROP_USE_LO_OFFSET, //ro, bool - SUBDEV_PROP_BANDWIDTH //rw, double - }; - /*! * A daughter board dboard_base class for all dboards. * Only other dboard dboard_base classes should inherit this. @@ -81,19 +44,14 @@ public: //structors dboard_base(ctor_args_t); - virtual ~dboard_base(void); - - //interface - virtual void rx_get(const wax::obj &key, wax::obj &val) = 0; - virtual void rx_set(const wax::obj &key, const wax::obj &val) = 0; - virtual void tx_get(const wax::obj &key, wax::obj &val) = 0; - virtual void tx_set(const wax::obj &key, const wax::obj &val) = 0; protected: std::string get_subdev_name(void); dboard_iface::sptr get_iface(void); dboard_id_t get_rx_id(void); dboard_id_t get_tx_id(void); + property_tree::sptr get_rx_subtree(void); + property_tree::sptr get_tx_subtree(void); private: UHD_PIMPL_DECL(impl) _impl; @@ -109,8 +67,6 @@ public: * Create a new xcvr dboard object, override in subclasses. */ xcvr_dboard_base(ctor_args_t); - - virtual ~xcvr_dboard_base(void); }; /*! @@ -123,12 +79,6 @@ public: * Create a new rx dboard object, override in subclasses. */ rx_dboard_base(ctor_args_t); - - virtual ~rx_dboard_base(void); - - //override here so the derived classes cannot - void tx_get(const wax::obj &key, wax::obj &val); - void tx_set(const wax::obj &key, const wax::obj &val); }; /*! @@ -141,12 +91,6 @@ public: * Create a new rx dboard object, override in subclasses. */ tx_dboard_base(ctor_args_t); - - virtual ~tx_dboard_base(void); - - //override here so the derived classes cannot - void rx_get(const wax::obj &key, wax::obj &val); - void rx_set(const wax::obj &key, const wax::obj &val); }; }} //namespace diff --git a/host/include/uhd/usrp/dboard_manager.hpp b/host/include/uhd/usrp/dboard_manager.hpp index 091769a5c..d3a3ffb5c 100644 --- a/host/include/uhd/usrp/dboard_manager.hpp +++ b/host/include/uhd/usrp/dboard_manager.hpp @@ -20,11 +20,12 @@ #include #include -#include #include #include #include #include +#include +#include namespace uhd{ namespace usrp{ @@ -37,11 +38,6 @@ class UHD_API dboard_manager : boost::noncopyable{ public: typedef boost::shared_ptr sptr; - //! It does what it says... - static void populate_prop_tree_from_subdev( - property_tree::sptr subtree, wax::obj subdev - ); - //dboard constructor (each dboard should have a ::make with this signature) typedef dboard_base::sptr(*dboard_ctor_t)(dboard_base::ctor_args_t); @@ -57,7 +53,7 @@ public: const dboard_id_t &dboard_id, dboard_ctor_t dboard_ctor, const std::string &name, - const prop_names_t &subdev_names = prop_names_t(1, "0") + const std::vector &subdev_names = std::vector(1, "0") ); /*! @@ -74,27 +70,25 @@ public: const dboard_id_t &tx_dboard_id, dboard_ctor_t dboard_ctor, const std::string &name, - const prop_names_t &subdev_names = prop_names_t(1, "0") + const std::vector &subdev_names = std::vector(1, "0") ); /*! * Make a new dboard manager. * \param rx_dboard_id the id of the rx dboard * \param tx_dboard_id the id of the tx dboard + * \param gdboard_id the id of the grand-dboard * \param iface the custom dboard interface + * \param subtree the subtree to load with props * \return an sptr to the new dboard manager */ static sptr make( dboard_id_t rx_dboard_id, dboard_id_t tx_dboard_id, - dboard_iface::sptr iface + dboard_id_t gdboard_id, + dboard_iface::sptr iface, + property_tree::sptr subtree ); - - //dboard manager interface - virtual prop_names_t get_rx_subdev_names(void) = 0; - virtual prop_names_t get_tx_subdev_names(void) = 0; - virtual wax::obj get_rx_subdev(const std::string &subdev_name) = 0; - virtual wax::obj get_tx_subdev(const std::string &subdev_name) = 0; }; }} //namespace diff --git a/host/lib/usrp/b100/b100_impl.cpp b/host/lib/usrp/b100/b100_impl.cpp index c15816cc2..c506559be 100644 --- a/host/lib/usrp/b100/b100_impl.cpp +++ b/host/lib/usrp/b100/b100_impl.cpp @@ -404,22 +404,9 @@ b100_impl::b100_impl(const device_addr_t &device_addr){ _dboard_iface = make_b100_dboard_iface(_fpga_ctrl, _fpga_i2c_ctrl, _fpga_spi_ctrl, _clock_ctrl, _codec_ctrl); _tree->create(mb_path / "dboards/A/iface").set(_dboard_iface); _dboard_manager = dboard_manager::make( - rx_db_eeprom.id, - ((gdb_eeprom.id == dboard_id_t::none())? tx_db_eeprom : gdb_eeprom).id, - _dboard_iface + rx_db_eeprom.id, tx_db_eeprom.id, gdb_eeprom.id, + _dboard_iface, _tree->subtree(mb_path / "dboards/A") ); - BOOST_FOREACH(const std::string &name, _dboard_manager->get_rx_subdev_names()){ - dboard_manager::populate_prop_tree_from_subdev( - _tree->subtree(mb_path / "dboards/A/rx_frontends" / name), - _dboard_manager->get_rx_subdev(name) - ); - } - BOOST_FOREACH(const std::string &name, _dboard_manager->get_tx_subdev_names()){ - dboard_manager::populate_prop_tree_from_subdev( - _tree->subtree(mb_path / "dboards/A/tx_frontends" / name), - _dboard_manager->get_tx_subdev(name) - ); - } //initialize io handling this->io_init(); @@ -432,8 +419,8 @@ b100_impl::b100_impl(const device_addr_t &device_addr){ _tree->access(mb_path / "tick_rate") //now subscribe the clock rate setter .subscribe(boost::bind(&b100_clock_ctrl::set_fpga_clock_rate, _clock_ctrl, _1)); - _tree->access(mb_path / "rx_subdev_spec").set(subdev_spec_t("A:"+_dboard_manager->get_rx_subdev_names()[0])); - _tree->access(mb_path / "tx_subdev_spec").set(subdev_spec_t("A:"+_dboard_manager->get_tx_subdev_names()[0])); + _tree->access(mb_path / "rx_subdev_spec").set(subdev_spec_t("A:" + _tree->list(mb_path / "dboards/A/rx_frontends").at(0))); + _tree->access(mb_path / "tx_subdev_spec").set(subdev_spec_t("A:" + _tree->list(mb_path / "dboards/A/tx_frontends").at(0))); _tree->access(mb_path / "clock_source/value").set("internal"); _tree->access(mb_path / "time_source/value").set("none"); } diff --git a/host/lib/usrp/dboard/CMakeLists.txt b/host/lib/usrp/dboard/CMakeLists.txt index c7b46e7c4..b5474ed16 100644 --- a/host/lib/usrp/dboard/CMakeLists.txt +++ b/host/lib/usrp/dboard/CMakeLists.txt @@ -20,16 +20,16 @@ ######################################################################## LIBUHD_APPEND_SOURCES( - ${CMAKE_CURRENT_SOURCE_DIR}/db_basic_and_lf.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/db_rfx.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/db_xcvr2450.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/db_sbx.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/db_wbx_common.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/db_wbx_simple.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/db_dbsrx.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/db_unknown.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/db_tvrx.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/db_dbsrx2.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/db_tvrx2.cpp + #${CMAKE_CURRENT_SOURCE_DIR}/db_basic_and_lf.cpp + #${CMAKE_CURRENT_SOURCE_DIR}/db_rfx.cpp + #${CMAKE_CURRENT_SOURCE_DIR}/db_xcvr2450.cpp + #${CMAKE_CURRENT_SOURCE_DIR}/db_sbx.cpp + #${CMAKE_CURRENT_SOURCE_DIR}/db_wbx_common.cpp + #${CMAKE_CURRENT_SOURCE_DIR}/db_wbx_simple.cpp + #${CMAKE_CURRENT_SOURCE_DIR}/db_dbsrx.cpp + #${CMAKE_CURRENT_SOURCE_DIR}/db_unknown.cpp + #${CMAKE_CURRENT_SOURCE_DIR}/db_tvrx.cpp + #${CMAKE_CURRENT_SOURCE_DIR}/db_dbsrx2.cpp + #${CMAKE_CURRENT_SOURCE_DIR}/db_tvrx2.cpp ) diff --git a/host/lib/usrp/dboard_base.cpp b/host/lib/usrp/dboard_base.cpp index e14c9d144..fe14c02b9 100644 --- a/host/lib/usrp/dboard_base.cpp +++ b/host/lib/usrp/dboard_base.cpp @@ -20,6 +20,7 @@ #include #include +using namespace uhd; using namespace uhd::usrp; /*********************************************************************** @@ -34,10 +35,6 @@ dboard_base::dboard_base(ctor_args_t args){ _impl->args = *static_cast(args); } -dboard_base::~dboard_base(void){ - /* NOP */ -} - std::string dboard_base::get_subdev_name(void){ return _impl->args.sd_name; } @@ -54,6 +51,14 @@ dboard_id_t dboard_base::get_tx_id(void){ return _impl->args.tx_id; } +property_tree::sptr dboard_base::get_rx_subtree(void){ + return _impl->args.rx_subtree; +} + +property_tree::sptr dboard_base::get_tx_subtree(void){ + return _impl->args.tx_subtree; +} + /*********************************************************************** * xcvr dboard dboard_base class **********************************************************************/ @@ -70,10 +75,6 @@ xcvr_dboard_base::xcvr_dboard_base(ctor_args_t args) : dboard_base(args){ } } -xcvr_dboard_base::~xcvr_dboard_base(void){ - /* NOP */ -} - /*********************************************************************** * rx dboard dboard_base class **********************************************************************/ @@ -86,18 +87,6 @@ rx_dboard_base::rx_dboard_base(ctor_args_t args) : dboard_base(args){ } } -rx_dboard_base::~rx_dboard_base(void){ - /* NOP */ -} - -void rx_dboard_base::tx_get(const wax::obj &, wax::obj &){ - throw uhd::runtime_error("cannot call tx_get on a rx dboard"); -} - -void rx_dboard_base::tx_set(const wax::obj &, const wax::obj &){ - throw uhd::runtime_error("cannot call tx_set on a rx dboard"); -} - /*********************************************************************** * tx dboard dboard_base class **********************************************************************/ @@ -109,15 +98,3 @@ tx_dboard_base::tx_dboard_base(ctor_args_t args) : dboard_base(args){ ) % get_rx_id().to_pp_string() % dboard_id_t::none().to_pp_string())); } } - -tx_dboard_base::~tx_dboard_base(void){ - /* NOP */ -} - -void tx_dboard_base::rx_get(const wax::obj &, wax::obj &){ - throw uhd::runtime_error("cannot call rx_get on a tx dboard"); -} - -void tx_dboard_base::rx_set(const wax::obj &, const wax::obj &){ - throw uhd::runtime_error("cannot call rx_set on a tx dboard"); -} diff --git a/host/lib/usrp/dboard_ctor_args.hpp b/host/lib/usrp/dboard_ctor_args.hpp index 708f2ea08..99c071ff8 100644 --- a/host/lib/usrp/dboard_ctor_args.hpp +++ b/host/lib/usrp/dboard_ctor_args.hpp @@ -18,6 +18,7 @@ #ifndef INCLUDED_LIBUHD_USRP_DBOARD_CTOR_ARGS_HPP #define INCLUDED_LIBUHD_USRP_DBOARD_CTOR_ARGS_HPP +#include #include #include #include @@ -29,6 +30,7 @@ namespace uhd{ namespace usrp{ std::string sd_name; dboard_iface::sptr db_iface; dboard_id_t rx_id, tx_id; + property_tree::sptr rx_subtree, tx_subtree; }; }} //namespace diff --git a/host/lib/usrp/dboard_manager.cpp b/host/lib/usrp/dboard_manager.cpp index 0326c28ce..816fba0c4 100644 --- a/host/lib/usrp/dboard_manager.cpp +++ b/host/lib/usrp/dboard_manager.cpp @@ -79,7 +79,7 @@ bool operator==(const dboard_key_t &lhs, const dboard_key_t &rhs){ * storage and registering for dboards **********************************************************************/ //dboard registry tuple: dboard constructor, canonical name, subdev names -typedef boost::tuple args_t; +typedef boost::tuple > args_t; //map a dboard id to a dboard constructor typedef uhd::dict id_to_args_map_t; @@ -89,7 +89,7 @@ static void register_dboard_key( const dboard_key_t &dboard_key, dboard_manager::dboard_ctor_t dboard_ctor, const std::string &name, - const prop_names_t &subdev_names + const std::vector &subdev_names ){ UHD_LOGV(always) << "registering: " << name << std::endl; if (get_id_to_args_map().has_key(dboard_key)){ @@ -110,7 +110,7 @@ void dboard_manager::register_dboard( const dboard_id_t &dboard_id, dboard_ctor_t dboard_ctor, const std::string &name, - const prop_names_t &subdev_names + const std::vector &subdev_names ){ register_dboard_key(dboard_key_t(dboard_id), dboard_ctor, name, subdev_names); } @@ -120,7 +120,7 @@ void dboard_manager::register_dboard( const dboard_id_t &tx_dboard_id, dboard_ctor_t dboard_ctor, const std::string &name, - const prop_names_t &subdev_names + const std::vector &subdev_names ){ register_dboard_key(dboard_key_t(rx_dboard_id, tx_dboard_id), dboard_ctor, name, subdev_names); } @@ -143,46 +143,6 @@ std::string dboard_id_t::to_pp_string(void) const{ return str(boost::format("%s (%s)") % this->to_cname() % this->to_string()); } -/*********************************************************************** - * internal helper classes - **********************************************************************/ -/*! - * A special wax proxy object that forwards calls to a subdev. - * A sptr to an instance will be used in the properties structure. - */ -class subdev_proxy : boost::noncopyable, public wax::obj{ -public: - typedef boost::shared_ptr sptr; - enum type_t{RX_TYPE, TX_TYPE}; - - //structors - subdev_proxy(dboard_base::sptr subdev, type_t type): - _subdev(subdev), _type(type) - { - /* NOP */ - } - -private: - dboard_base::sptr _subdev; - type_t _type; - - //forward the get calls to the rx or tx - void get(const wax::obj &key, wax::obj &val){ - switch(_type){ - case RX_TYPE: return _subdev->rx_get(key, val); - case TX_TYPE: return _subdev->tx_get(key, val); - } - } - - //forward the set calls to the rx or tx - void set(const wax::obj &key, const wax::obj &val){ - switch(_type){ - case RX_TYPE: return _subdev->rx_set(key, val); - case TX_TYPE: return _subdev->tx_set(key, val); - } - } -}; - /*********************************************************************** * dboard manager implementation class **********************************************************************/ @@ -192,23 +152,18 @@ public: dboard_manager_impl( dboard_id_t rx_dboard_id, dboard_id_t tx_dboard_id, - dboard_iface::sptr iface + dboard_iface::sptr iface, + property_tree::sptr subtree ); ~dboard_manager_impl(void); - //dboard_iface - prop_names_t get_rx_subdev_names(void); - prop_names_t get_tx_subdev_names(void); - wax::obj get_rx_subdev(const std::string &subdev_name); - wax::obj get_tx_subdev(const std::string &subdev_name); - private: - void init(dboard_id_t, dboard_id_t); + void init(dboard_id_t, dboard_id_t, property_tree::sptr); //list of rx and tx dboards in this dboard_manager //each dboard here is actually a subdevice proxy //the subdevice proxy is internal to the cpp file - uhd::dict _rx_dboards; - uhd::dict _tx_dboards; + uhd::dict _rx_dboards; + uhd::dict _tx_dboards; dboard_iface::sptr _iface; void set_nice_dboard_if(void); }; @@ -219,10 +174,16 @@ private: dboard_manager::sptr dboard_manager::make( dboard_id_t rx_dboard_id, dboard_id_t tx_dboard_id, - dboard_iface::sptr iface + dboard_id_t gdboard_id, + dboard_iface::sptr iface, + property_tree::sptr subtree ){ return dboard_manager::sptr( - new dboard_manager_impl(rx_dboard_id, tx_dboard_id, iface) + new dboard_manager_impl( + rx_dboard_id, + (gdboard_id == dboard_id_t::none())? tx_dboard_id : gdboard_id, + iface, subtree + ) ); } @@ -232,21 +193,22 @@ dboard_manager::sptr dboard_manager::make( dboard_manager_impl::dboard_manager_impl( dboard_id_t rx_dboard_id, dboard_id_t tx_dboard_id, - dboard_iface::sptr iface + dboard_iface::sptr iface, + property_tree::sptr subtree ): _iface(iface) { try{ - this->init(rx_dboard_id, tx_dboard_id); + this->init(rx_dboard_id, tx_dboard_id, subtree); } catch(const std::exception &e){ UHD_MSG(error) << "The daughterboard manager encountered a recoverable error in init" << std::endl << e.what(); - this->init(dboard_id_t::none(), dboard_id_t::none()); + this->init(dboard_id_t::none(), dboard_id_t::none(), subtree); } } void dboard_manager_impl::init( - dboard_id_t rx_dboard_id, dboard_id_t tx_dboard_id + dboard_id_t rx_dboard_id, dboard_id_t tx_dboard_id, property_tree::sptr subtree ){ //find the dboard key matches for the dboard ids dboard_key_t rx_dboard_key, tx_dboard_key, xcvr_dboard_key; @@ -283,7 +245,7 @@ void dboard_manager_impl::init( if (xcvr_dboard_key.is_xcvr()){ //extract data for the xcvr dboard key - dboard_ctor_t dboard_ctor; std::string name; prop_names_t subdevs; + dboard_ctor_t dboard_ctor; std::string name; std::vector subdevs; boost::tie(dboard_ctor, name, subdevs) = get_id_to_args_map()[xcvr_dboard_key]; //create the xcvr object for each subdevice @@ -291,15 +253,11 @@ void dboard_manager_impl::init( db_ctor_args.sd_name = subdev; db_ctor_args.rx_id = rx_dboard_id; db_ctor_args.tx_id = tx_dboard_id; + db_ctor_args.rx_subtree = subtree->subtree("rx_frontends/" + subdev); + db_ctor_args.tx_subtree = subtree->subtree("tx_frontends/" + subdev); dboard_base::sptr xcvr_dboard = dboard_ctor(&db_ctor_args); - //create a rx proxy for this xcvr board - _rx_dboards[subdev] = subdev_proxy::sptr( - new subdev_proxy(xcvr_dboard, subdev_proxy::RX_TYPE) - ); - //create a tx proxy for this xcvr board - _tx_dboards[subdev] = subdev_proxy::sptr( - new subdev_proxy(xcvr_dboard, subdev_proxy::TX_TYPE) - ); + _rx_dboards[subdev] = xcvr_dboard; + _tx_dboards[subdev] = xcvr_dboard; } } @@ -312,7 +270,7 @@ void dboard_manager_impl::init( } //extract data for the rx dboard key - dboard_ctor_t rx_dboard_ctor; std::string rx_name; prop_names_t rx_subdevs; + dboard_ctor_t rx_dboard_ctor; std::string rx_name; std::vector rx_subdevs; boost::tie(rx_dboard_ctor, rx_name, rx_subdevs) = get_id_to_args_map()[rx_dboard_key]; //make the rx subdevs @@ -320,11 +278,9 @@ void dboard_manager_impl::init( db_ctor_args.sd_name = subdev; db_ctor_args.rx_id = rx_dboard_id; db_ctor_args.tx_id = dboard_id_t::none(); - dboard_base::sptr rx_dboard = rx_dboard_ctor(&db_ctor_args); - //create a rx proxy for this rx board - _rx_dboards[subdev] = subdev_proxy::sptr( - new subdev_proxy(rx_dboard, subdev_proxy::RX_TYPE) - ); + db_ctor_args.rx_subtree = subtree->subtree("rx_frontends/" + subdev); + db_ctor_args.tx_subtree = property_tree::sptr(); //null + _rx_dboards[subdev] = rx_dboard_ctor(&db_ctor_args); } //force the tx key to the unknown board for bad combinations @@ -333,7 +289,7 @@ void dboard_manager_impl::init( } //extract data for the tx dboard key - dboard_ctor_t tx_dboard_ctor; std::string tx_name; prop_names_t tx_subdevs; + dboard_ctor_t tx_dboard_ctor; std::string tx_name; std::vector tx_subdevs; boost::tie(tx_dboard_ctor, tx_name, tx_subdevs) = get_id_to_args_map()[tx_dboard_key]; //make the tx subdevs @@ -341,11 +297,9 @@ void dboard_manager_impl::init( db_ctor_args.sd_name = subdev; db_ctor_args.rx_id = dboard_id_t::none(); db_ctor_args.tx_id = tx_dboard_id; - dboard_base::sptr tx_dboard = tx_dboard_ctor(&db_ctor_args); - //create a tx proxy for this tx board - _tx_dboards[subdev] = subdev_proxy::sptr( - new subdev_proxy(tx_dboard, subdev_proxy::TX_TYPE) - ); + db_ctor_args.rx_subtree = property_tree::sptr(); //null + db_ctor_args.tx_subtree = subtree->subtree("tx_frontends/" + subdev); + _tx_dboards[subdev] = tx_dboard_ctor(&db_ctor_args); } } } @@ -354,30 +308,6 @@ dboard_manager_impl::~dboard_manager_impl(void){UHD_SAFE_CALL( set_nice_dboard_if(); )} -prop_names_t dboard_manager_impl::get_rx_subdev_names(void){ - return _rx_dboards.keys(); -} - -prop_names_t dboard_manager_impl::get_tx_subdev_names(void){ - return _tx_dboards.keys(); -} - -wax::obj dboard_manager_impl::get_rx_subdev(const std::string &subdev_name){ - if (not _rx_dboards.has_key(subdev_name)) throw uhd::key_error( - str(boost::format("Unknown rx subdev name %s") % subdev_name) - ); - //get a link to the rx subdev proxy - return _rx_dboards[subdev_name]->get_link(); -} - -wax::obj dboard_manager_impl::get_tx_subdev(const std::string &subdev_name){ - if (not _tx_dboards.has_key(subdev_name)) throw uhd::key_error( - str(boost::format("Unknown tx subdev name %s") % subdev_name) - ); - //get a link to the tx subdev proxy - return _tx_dboards[subdev_name]->get_link(); -} - void dboard_manager_impl::set_nice_dboard_if(void){ //make a list of possible unit types std::vector units = boost::assign::list_of @@ -392,137 +322,4 @@ void dboard_manager_impl::set_nice_dboard_if(void){ _iface->set_pin_ctrl(unit, 0x0000); //all gpio _iface->set_clock_enabled(unit, false); //clock off } - - //disable all rx subdevices - BOOST_FOREACH(const std::string &sd_name, this->get_rx_subdev_names()){ - this->get_rx_subdev(sd_name)[SUBDEV_PROP_ENABLED] = false; - } - - //disable all tx subdevices - BOOST_FOREACH(const std::string &sd_name, this->get_tx_subdev_names()){ - this->get_tx_subdev(sd_name)[SUBDEV_PROP_ENABLED] = false; - } -} - -/*********************************************************************** - * Populate a properties tree from a subdev waxy object - **********************************************************************/ -#include -#include - -static sensor_value_t get_sensor(wax::obj subdev, const std::string &name){ - return subdev[named_prop_t(SUBDEV_PROP_SENSOR, name)].as(); -} - -static void set_gain(wax::obj subdev, const std::string &name, const double gain){ - subdev[named_prop_t(SUBDEV_PROP_GAIN, name)] = gain; -} - -static double get_gain(wax::obj subdev, const std::string &name){ - return subdev[named_prop_t(SUBDEV_PROP_GAIN, name)].as(); -} - -static meta_range_t get_gain_range(wax::obj subdev, const std::string &name){ - return subdev[named_prop_t(SUBDEV_PROP_GAIN_RANGE, name)].as(); -} - -static void set_freq(wax::obj subdev, const double freq){ - subdev[SUBDEV_PROP_FREQ] = freq; -} - -static double get_freq(wax::obj subdev){ - return subdev[SUBDEV_PROP_FREQ].as(); -} - -static meta_range_t get_freq_range(wax::obj subdev){ - return subdev[SUBDEV_PROP_FREQ_RANGE].as(); -} - -static void set_ant(wax::obj subdev, const std::string &ant){ - subdev[SUBDEV_PROP_ANTENNA] = ant; -} - -static std::string get_ant(wax::obj subdev){ - return subdev[SUBDEV_PROP_ANTENNA].as(); -} - -static std::vector get_ants(wax::obj subdev){ - return subdev[SUBDEV_PROP_ANTENNA_NAMES].as >(); -} - -static std::string get_conn(wax::obj subdev){ - switch(subdev[SUBDEV_PROP_CONNECTION].as()){ - case SUBDEV_CONN_COMPLEX_IQ: return "IQ"; - case SUBDEV_CONN_COMPLEX_QI: return "QI"; - case SUBDEV_CONN_REAL_I: return "I"; - case SUBDEV_CONN_REAL_Q: return "Q"; - } - UHD_THROW_INVALID_CODE_PATH(); -} - -static bool get_use_lo_off(wax::obj subdev){ - return subdev[SUBDEV_PROP_USE_LO_OFFSET].as(); -} - -static bool get_set_enb(wax::obj subdev, const bool enb){ - subdev[SUBDEV_PROP_ENABLED] = enb; - return subdev[SUBDEV_PROP_ENABLED].as(); -} - -static void set_bw(wax::obj subdev, const double freq){ - subdev[SUBDEV_PROP_BANDWIDTH] = freq; -} - -static double get_bw(wax::obj subdev){ - return subdev[SUBDEV_PROP_BANDWIDTH].as(); -} - -void dboard_manager::populate_prop_tree_from_subdev( - property_tree::sptr subtree, wax::obj subdev -){ - subtree->create("name").set(subdev[SUBDEV_PROP_NAME].as()); - - const prop_names_t sensor_names = subdev[SUBDEV_PROP_SENSOR_NAMES].as(); - subtree->create("sensors"); //phony property so this dir exists - BOOST_FOREACH(const std::string &name, sensor_names){ - subtree->create("sensors/" + name) - .publish(boost::bind(&get_sensor, subdev, name)); - } - - const prop_names_t gain_names = subdev[SUBDEV_PROP_GAIN_NAMES].as(); - subtree->create("gains"); //phony property so this dir exists - BOOST_FOREACH(const std::string &name, gain_names){ - subtree->create("gains/" + name + "/value") - .publish(boost::bind(&get_gain, subdev, name)) - .subscribe(boost::bind(&set_gain, subdev, name, _1)); - subtree->create("gains/" + name + "/range") - .publish(boost::bind(&get_gain_range, subdev, name)); - } - - subtree->create("freq/value") - .publish(boost::bind(&get_freq, subdev)) - .subscribe(boost::bind(&set_freq, subdev, _1)); - - subtree->create("freq/range") - .publish(boost::bind(&get_freq_range, subdev)); - - subtree->create("antenna/value") - .publish(boost::bind(&get_ant, subdev)) - .subscribe(boost::bind(&set_ant, subdev, _1)); - - subtree->create >("antenna/options") - .publish(boost::bind(&get_ants, subdev)); - - subtree->create("connection") - .publish(boost::bind(&get_conn, subdev)); - - subtree->create("enabled") - .coerce(boost::bind(&get_set_enb, subdev, _1)); - - subtree->create("use_lo_offset") - .publish(boost::bind(&get_use_lo_off, subdev)); - - subtree->create("bandwidth/value") - .publish(boost::bind(&get_bw, subdev)) - .subscribe(boost::bind(&set_bw, subdev, _1)); } diff --git a/host/lib/usrp/e100/e100_impl.cpp b/host/lib/usrp/e100/e100_impl.cpp index 2e3a635a6..c0a8f46f3 100644 --- a/host/lib/usrp/e100/e100_impl.cpp +++ b/host/lib/usrp/e100/e100_impl.cpp @@ -370,22 +370,9 @@ e100_impl::e100_impl(const uhd::device_addr_t &device_addr){ _dboard_iface = make_e100_dboard_iface(_fpga_ctrl, _fpga_i2c_ctrl, _fpga_spi_ctrl, _clock_ctrl, _codec_ctrl); _tree->create(mb_path / "dboards/A/iface").set(_dboard_iface); _dboard_manager = dboard_manager::make( - rx_db_eeprom.id, - ((gdb_eeprom.id == dboard_id_t::none())? tx_db_eeprom : gdb_eeprom).id, - _dboard_iface + rx_db_eeprom.id, tx_db_eeprom.id, gdb_eeprom.id, + _dboard_iface, _tree->subtree(mb_path / "dboards/A") ); - BOOST_FOREACH(const std::string &name, _dboard_manager->get_rx_subdev_names()){ - dboard_manager::populate_prop_tree_from_subdev( - _tree->subtree(mb_path / "dboards/A/rx_frontends" / name), - _dboard_manager->get_rx_subdev(name) - ); - } - BOOST_FOREACH(const std::string &name, _dboard_manager->get_tx_subdev_names()){ - dboard_manager::populate_prop_tree_from_subdev( - _tree->subtree(mb_path / "dboards/A/tx_frontends" / name), - _dboard_manager->get_tx_subdev(name) - ); - } //initialize io handling this->io_init(); @@ -398,8 +385,8 @@ e100_impl::e100_impl(const uhd::device_addr_t &device_addr){ _tree->access(mb_path / "tick_rate") //now subscribe the clock rate setter .subscribe(boost::bind(&e100_clock_ctrl::set_fpga_clock_rate, _clock_ctrl, _1)); - _tree->access(mb_path / "rx_subdev_spec").set(subdev_spec_t("A:"+_dboard_manager->get_rx_subdev_names()[0])); - _tree->access(mb_path / "tx_subdev_spec").set(subdev_spec_t("A:"+_dboard_manager->get_tx_subdev_names()[0])); + _tree->access(mb_path / "rx_subdev_spec").set(subdev_spec_t("A:" + _tree->list(mb_path / "dboards/A/rx_frontends").at(0))); + _tree->access(mb_path / "tx_subdev_spec").set(subdev_spec_t("A:" + _tree->list(mb_path / "dboards/A/tx_frontends").at(0))); _tree->access(mb_path / "clock_source/value").set("internal"); _tree->access(mb_path / "time_source/value").set("none"); diff --git a/host/lib/usrp/usrp1/usrp1_impl.cpp b/host/lib/usrp/usrp1/usrp1_impl.cpp index 6634b43da..4be5a3a2b 100644 --- a/host/lib/usrp/usrp1/usrp1_impl.cpp +++ b/host/lib/usrp/usrp1/usrp1_impl.cpp @@ -363,29 +363,16 @@ usrp1_impl::usrp1_impl(const device_addr_t &device_addr){ ); _tree->create(mb_path / "dboards" / db/ "iface").set(_dbc[db].dboard_iface); _dbc[db].dboard_manager = dboard_manager::make( - rx_db_eeprom.id, - ((gdb_eeprom.id == dboard_id_t::none())? tx_db_eeprom : gdb_eeprom).id, - _dbc[db].dboard_iface + rx_db_eeprom.id, tx_db_eeprom.id, gdb_eeprom.id, + _dbc[db].dboard_iface, _tree->subtree(mb_path / "dboards" / db) ); - BOOST_FOREACH(const std::string &name, _dbc[db].dboard_manager->get_rx_subdev_names()){ - dboard_manager::populate_prop_tree_from_subdev( - _tree->subtree(mb_path / "dboards" / db/ "rx_frontends" / name), - _dbc[db].dboard_manager->get_rx_subdev(name) - ); - } - BOOST_FOREACH(const std::string &name, _dbc[db].dboard_manager->get_tx_subdev_names()){ - dboard_manager::populate_prop_tree_from_subdev( - _tree->subtree(mb_path / "dboards" / db/ "tx_frontends" / name), - _dbc[db].dboard_manager->get_tx_subdev(name) - ); - } //init the subdev specs if we have a dboard (wont leave this loop empty) if (rx_db_eeprom.id != dboard_id_t::none() or _rx_subdev_spec.empty()){ - _rx_subdev_spec = subdev_spec_t(db + ":" + _dbc[db].dboard_manager->get_rx_subdev_names()[0]); + _rx_subdev_spec = subdev_spec_t(db + ":" + _tree->list(mb_path / "dboards" / db / "rx_frontends").at(0)); } if (tx_db_eeprom.id != dboard_id_t::none() or _tx_subdev_spec.empty()){ - _tx_subdev_spec = subdev_spec_t(db + ":" + _dbc[db].dboard_manager->get_tx_subdev_names()[0]); + _tx_subdev_spec = subdev_spec_t(db + ":" + _tree->list(mb_path / "dboards" / db / "tx_frontends").at(0)); } } diff --git a/host/lib/usrp/usrp2/usrp2_impl.cpp b/host/lib/usrp/usrp2/usrp2_impl.cpp index ac3ee2e69..bb3bfc7e4 100644 --- a/host/lib/usrp/usrp2/usrp2_impl.cpp +++ b/host/lib/usrp/usrp2/usrp2_impl.cpp @@ -597,22 +597,9 @@ usrp2_impl::usrp2_impl(const device_addr_t &_device_addr){ _mbc[mb].dboard_iface = make_usrp2_dboard_iface(_mbc[mb].iface, _mbc[mb].clock); _tree->create(mb_path / "dboards/A/iface").set(_mbc[mb].dboard_iface); _mbc[mb].dboard_manager = dboard_manager::make( - rx_db_eeprom.id, - ((gdb_eeprom.id == dboard_id_t::none())? tx_db_eeprom : gdb_eeprom).id, - _mbc[mb].dboard_iface + rx_db_eeprom.id, tx_db_eeprom.id, gdb_eeprom.id, + _mbc[mb].dboard_iface, _tree->subtree(mb_path / "dboards/A") ); - BOOST_FOREACH(const std::string &name, _mbc[mb].dboard_manager->get_rx_subdev_names()){ - dboard_manager::populate_prop_tree_from_subdev( - _tree->subtree(mb_path / "dboards/A/rx_frontends" / name), - _mbc[mb].dboard_manager->get_rx_subdev(name) - ); - } - BOOST_FOREACH(const std::string &name, _mbc[mb].dboard_manager->get_tx_subdev_names()){ - dboard_manager::populate_prop_tree_from_subdev( - _tree->subtree(mb_path / "dboards/A/tx_frontends" / name), - _mbc[mb].dboard_manager->get_tx_subdev(name) - ); - } } //initialize io handling @@ -623,8 +610,8 @@ usrp2_impl::usrp2_impl(const device_addr_t &_device_addr){ BOOST_FOREACH(const std::string &mb, _mbc.keys()){ fs_path root = "/mboards/" + mb; - _tree->access(root / "rx_subdev_spec").set(subdev_spec_t("A:"+_mbc[mb].dboard_manager->get_rx_subdev_names()[0])); - _tree->access(root / "tx_subdev_spec").set(subdev_spec_t("A:"+_mbc[mb].dboard_manager->get_tx_subdev_names()[0])); + _tree->access(root / "rx_subdev_spec").set(subdev_spec_t("A:" + _tree->list(root / "dboards/A/rx_frontends").at(0))); + _tree->access(root / "tx_subdev_spec").set(subdev_spec_t("A:" + _tree->list(root / "dboards/A/tx_frontends").at(0))); _tree->access(root / "clock_source/value").set("internal"); _tree->access(root / "time_source/value").set("none"); -- cgit v1.2.3