From 178ac3f1c9950d383c8f64b3df464c0f943c4a23 Mon Sep 17 00:00:00 2001 From: Ben Hilburn Date: Tue, 4 Feb 2014 11:04:07 -0800 Subject: Merging USRP X300 and X310 support!! --- host/lib/usrp/b200/b200_impl.cpp | 8 ++++---- host/lib/usrp/b200/b200_impl.hpp | 14 ++++---------- 2 files changed, 8 insertions(+), 14 deletions(-) (limited to 'host/lib/usrp/b200') diff --git a/host/lib/usrp/b200/b200_impl.cpp b/host/lib/usrp/b200/b200_impl.cpp index ab437af6b..8ed8e99af 100644 --- a/host/lib/usrp/b200/b200_impl.cpp +++ b/host/lib/usrp/b200/b200_impl.cpp @@ -53,9 +53,9 @@ static device_addrs_t b200_find(const device_addr_t &hint) //return an empty list of addresses when type is set to non-b200 if (hint.has_key("type") and hint["type"] != "b200") return b200_addrs; - //Return an empty list of addresses when an address is specified, - //since an address is intended for a different, non-USB, device. - if (hint.has_key("addr")) return b200_addrs; + //Return an empty list of addresses when an address or resource is specified, + //since an address and resource is intended for a different, non-USB, device. + if (hint.has_key("addr") || hint.has_key("resource")) return b200_addrs; unsigned int vid, pid; @@ -332,7 +332,7 @@ b200_impl::b200_impl(const device_addr_t &device_addr) data_xport_args // param hints ); while (_data_transport->get_recv_buff(0.0)){} //flush ctrl xport - _demux.reset(new recv_packet_demuxer_3000(_data_transport)); + _demux = recv_packet_demuxer_3000::make(_data_transport); //////////////////////////////////////////////////////////////////// // Init codec - turns on clocks diff --git a/host/lib/usrp/b200/b200_impl.hpp b/host/lib/usrp/b200/b200_impl.hpp index bee42679b..c88d14ad5 100644 --- a/host/lib/usrp/b200/b200_impl.hpp +++ b/host/lib/usrp/b200/b200_impl.hpp @@ -80,8 +80,9 @@ static const boost::uint32_t B200_LOCAL_RESP_SID = FLIP_SID(B200_LOCAL_CTRL_SID) **********************************************************************/ //! Implementation guts -struct b200_impl : public uhd::device +class b200_impl : public uhd::device { +public: //structors b200_impl(const uhd::device_addr_t &); ~b200_impl(void); @@ -91,8 +92,7 @@ struct b200_impl : public uhd::device uhd::tx_streamer::sptr get_tx_stream(const uhd::stream_args_t &args); bool recv_async_msg(uhd::async_metadata_t &, double); - uhd::property_tree::sptr _tree; - +private: //controllers b200_iface::sptr _iface; radio_ctrl_core_3000::sptr _local_ctrl; @@ -104,13 +104,7 @@ struct b200_impl : public uhd::device //transports uhd::transport::zero_copy_if::sptr _data_transport; uhd::transport::zero_copy_if::sptr _ctrl_transport; - boost::shared_ptr _demux; - - //device properties interface - uhd::property_tree::sptr get_tree(void) const - { - return _tree; - } + uhd::usrp::recv_packet_demuxer_3000::sptr _demux; boost::weak_ptr _rx_streamer; boost::weak_ptr _tx_streamer; -- cgit v1.2.3 From a8caec5f93976c081d488118f53a72dca49efdf6 Mon Sep 17 00:00:00 2001 From: Ashish Chaudhari Date: Wed, 19 Feb 2014 19:22:52 -0800 Subject: b200: Fixed bug in rx_dsp_core_3000 that would assume 3 halfbands and X300 settings interface. --- host/lib/usrp/b200/b200_impl.cpp | 2 +- host/lib/usrp/cores/rx_dsp_core_3000.cpp | 67 +++++++++++++++++++------------- host/lib/usrp/cores/rx_dsp_core_3000.hpp | 5 ++- 3 files changed, 44 insertions(+), 30 deletions(-) (limited to 'host/lib/usrp/b200') diff --git a/host/lib/usrp/b200/b200_impl.cpp b/host/lib/usrp/b200/b200_impl.cpp index 8ed8e99af..74e61143b 100644 --- a/host/lib/usrp/b200/b200_impl.cpp +++ b/host/lib/usrp/b200/b200_impl.cpp @@ -510,7 +510,7 @@ void b200_impl::setup_radio(const size_t dspno) // create rx dsp control objects //////////////////////////////////////////////////////////////////// perif.framer = rx_vita_core_3000::make(perif.ctrl, TOREG(SR_RX_CTRL)); - perif.ddc = rx_dsp_core_3000::make(perif.ctrl, TOREG(SR_RX_DSP)); + perif.ddc = rx_dsp_core_3000::make(perif.ctrl, TOREG(SR_RX_DSP), true /*is_b200?*/); perif.ddc->set_link_rate(10e9/8); //whatever _tree->access(mb_path / "tick_rate") .subscribe(boost::bind(&rx_vita_core_3000::set_tick_rate, perif.framer, _1)) diff --git a/host/lib/usrp/cores/rx_dsp_core_3000.cpp b/host/lib/usrp/cores/rx_dsp_core_3000.cpp index 67d0be017..86846667f 100644 --- a/host/lib/usrp/cores/rx_dsp_core_3000.cpp +++ b/host/lib/usrp/cores/rx_dsp_core_3000.cpp @@ -1,5 +1,5 @@ // -// Copyright 2011-2013 Ettus Research LLC +// Copyright 2011-2014 Ettus Research LLC // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by @@ -48,9 +48,10 @@ class rx_dsp_core_3000_impl : public rx_dsp_core_3000{ public: rx_dsp_core_3000_impl( wb_iface::sptr iface, - const size_t dsp_base + const size_t dsp_base, + const bool is_b200 ): - _iface(iface), _dsp_base(dsp_base) + _iface(iface), _dsp_base(dsp_base), _is_b200(is_b200) { // previously uninitialized - assuming zero for all _link_rate = _host_extra_scaling = _fxpt_scalar_correction = 0.0; @@ -119,32 +120,43 @@ public: hb1 = 1; decim /= 2; } - if (decim % 2 == 0){ + //the third half-band is not supported by the B200 + if (decim % 2 == 0 && !_is_b200){ hb2 = 1; decim /= 2; } - // Encode Halfband config for setting register programming. - if (hb2) { // Implies HB1 and HB0 also asserted - hb_enable=3; - } else if (hb1) { // Implies HB0 is also asserted - hb_enable=2; - } else if (hb0) { - hb_enable=1; - } else { - hb_enable=0; - } - - _iface->poke32(REG_DSP_RX_DECIM, (hb_enable << 8) | (decim & 0xff)); - - if (decim > 1 and hb0 == 0 and hb1 == 0 and hb2 == 0) - { - UHD_MSG(warning) << boost::format( - "The requested decimation is odd; the user should expect passband CIC rolloff.\n" - "Select an even decimation to ensure that a halfband filter is enabled.\n" - "Decimations factorable by 4 will enable 2 halfbands, those factorable by 8 will enable 3 halfbands.\n" - "decimation = dsp_rate/samp_rate -> %d = (%f MHz)/(%f MHz)\n" - ) % decim_rate % (_tick_rate/1e6) % (rate/1e6); + if (_is_b200) { + _iface->poke32(REG_DSP_RX_DECIM, (hb1 << 9) | (hb0 << 8) | (decim & 0xff)); + + if (decim > 1 and hb0 == 0 and hb1 == 0) { + UHD_MSG(warning) << boost::format( + "The requested decimation is odd; the user should expect CIC rolloff.\n" + "Select an even decimation to ensure that a halfband filter is enabled.\n" + "decimation = dsp_rate/samp_rate -> %d = (%f MHz)/(%f MHz)\n" + ) % decim_rate % (_tick_rate/1e6) % (rate/1e6); + } + } else { + // Encode Halfband config for setting register programming. + if (hb2) { // Implies HB1 and HB0 also asserted + hb_enable=3; + } else if (hb1) { // Implies HB0 is also asserted + hb_enable=2; + } else if (hb0) { + hb_enable=1; + } else { + hb_enable=0; + } + _iface->poke32(REG_DSP_RX_DECIM, (hb_enable << 8) | (decim & 0xff)); + + if (decim > 1 and hb0 == 0 and hb1 == 0 and hb2 == 0) { + UHD_MSG(warning) << boost::format( + "The requested decimation is odd; the user should expect passband CIC rolloff.\n" + "Select an even decimation to ensure that a halfband filter is enabled.\n" + "Decimations factorable by 4 will enable 2 halfbands, those factorable by 8 will enable 3 halfbands.\n" + "decimation = dsp_rate/samp_rate -> %d = (%f MHz)/(%f MHz)\n" + ) % decim_rate % (_tick_rate/1e6) % (rate/1e6); + } } // Calculate CIC decimation (i.e., without halfband decimators) @@ -223,11 +235,12 @@ public: private: wb_iface::sptr _iface; const size_t _dsp_base; + const bool _is_b200; //TODO: Obsolete this when we switch to the new DDC on the B200 double _tick_rate, _link_rate; double _scaling_adjustment, _dsp_extra_scaling, _host_extra_scaling, _fxpt_scalar_correction; }; -rx_dsp_core_3000::sptr rx_dsp_core_3000::make(wb_iface::sptr iface, const size_t dsp_base) +rx_dsp_core_3000::sptr rx_dsp_core_3000::make(wb_iface::sptr iface, const size_t dsp_base, const bool is_b200 /* = false */) { - return sptr(new rx_dsp_core_3000_impl(iface, dsp_base)); + return sptr(new rx_dsp_core_3000_impl(iface, dsp_base, is_b200)); } diff --git a/host/lib/usrp/cores/rx_dsp_core_3000.hpp b/host/lib/usrp/cores/rx_dsp_core_3000.hpp index 02e5587a2..f35e1e3d3 100644 --- a/host/lib/usrp/cores/rx_dsp_core_3000.hpp +++ b/host/lib/usrp/cores/rx_dsp_core_3000.hpp @@ -1,5 +1,5 @@ // -// Copyright 2011-2013 Ettus Research LLC +// Copyright 2011-2014 Ettus Research LLC // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by @@ -33,7 +33,8 @@ public: static sptr make( uhd::wb_iface::sptr iface, - const size_t dsp_base + const size_t dsp_base, + const bool is_b200 = false //TODO: Obsolete this when we switch to the new DDC on the B200 ); virtual void set_mux(const std::string &mode, const bool fe_swapped = false) = 0; -- cgit v1.2.3 From fd1e2f8fc1b481b1f0c80798172a601a507914f3 Mon Sep 17 00:00:00 2001 From: Martin Braun Date: Tue, 25 Feb 2014 16:34:03 +0100 Subject: b200: Added channel mapping capabilities --- host/lib/usrp/b200/b200_impl.cpp | 9 +++-- host/lib/usrp/b200/b200_impl.hpp | 11 +++--- host/lib/usrp/b200/b200_io_impl.cpp | 69 ++++++++++++++++--------------------- 3 files changed, 42 insertions(+), 47 deletions(-) (limited to 'host/lib/usrp/b200') diff --git a/host/lib/usrp/b200/b200_impl.cpp b/host/lib/usrp/b200/b200_impl.cpp index 74e61143b..66df1f3bc 100644 --- a/host/lib/usrp/b200/b200_impl.cpp +++ b/host/lib/usrp/b200/b200_impl.cpp @@ -1,5 +1,5 @@ // -// Copyright 2012-2013 Ettus Research LLC +// Copyright 2012-2014 Ettus Research LLC // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by @@ -373,12 +373,15 @@ b200_impl::b200_impl(const device_addr_t &device_addr) //////////////////////////////////////////////////////////////////// // create frontend mapping //////////////////////////////////////////////////////////////////// + std::vector default_map(2, 0); default_map[1] = 1; // Set this to A->0 B->1 even if there's only A + _tree->create >(mb_path / "rx_chan_dsp_mapping").set(default_map); + _tree->create >(mb_path / "tx_chan_dsp_mapping").set(default_map); _tree->create(mb_path / "rx_subdev_spec") .set(subdev_spec_t()) - .subscribe(boost::bind(&b200_impl::update_rx_subdev_spec, this, _1)); + .subscribe(boost::bind(&b200_impl::update_subdev_spec, this, "rx", _1)); _tree->create(mb_path / "tx_subdev_spec") .set(subdev_spec_t()) - .subscribe(boost::bind(&b200_impl::update_tx_subdev_spec, this, _1)); + .subscribe(boost::bind(&b200_impl::update_subdev_spec, this, "tx", _1)); //////////////////////////////////////////////////////////////////// // setup radio control diff --git a/host/lib/usrp/b200/b200_impl.hpp b/host/lib/usrp/b200/b200_impl.hpp index c88d14ad5..a370e54f9 100644 --- a/host/lib/usrp/b200/b200_impl.hpp +++ b/host/lib/usrp/b200/b200_impl.hpp @@ -127,8 +127,7 @@ private: void set_mb_eeprom(const uhd::usrp::mboard_eeprom_t &); void check_fw_compat(void); void check_fpga_compat(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_subdev_spec(const std::string &tx_rx, const uhd::usrp::subdev_spec_t &); void update_time_source(const std::string &); void update_clock_source(const std::string &); void update_bandsel(const std::string& which, double freq); @@ -150,8 +149,12 @@ private: bool ant_rx2; }; std::vector _radio_perifs; - void setup_radio(const size_t which_radio); - void handle_overflow(const size_t index); + + /*! \brief Setup the DSP chain for one radio front-end. + * + */ + void setup_radio(const size_t radio_index); + void handle_overflow(const size_t radio_index); struct gpio_state { boost::uint32_t tx_bandsel_a, tx_bandsel_b, rx_bandsel_a, rx_bandsel_b, rx_bandsel_c, codec_arst, mimo, ref_sel; diff --git a/host/lib/usrp/b200/b200_io_impl.cpp b/host/lib/usrp/b200/b200_io_impl.cpp index 4768aa37b..4f072c4d4 100644 --- a/host/lib/usrp/b200/b200_io_impl.cpp +++ b/host/lib/usrp/b200/b200_io_impl.cpp @@ -72,44 +72,31 @@ void b200_impl::update_tx_samp_rate(const size_t dspno, const double rate) /*********************************************************************** * frontend selection **********************************************************************/ -void b200_impl::update_rx_subdev_spec(const uhd::usrp::subdev_spec_t &spec) +void b200_impl::update_subdev_spec(const std::string &tx_rx, const uhd::usrp::subdev_spec_t &spec) { //sanity checking - if (spec.size()) validate_subdev_spec(_tree, spec, "rx"); + if (spec.size()) validate_subdev_spec(_tree, spec, tx_rx); UHD_ASSERT_THROW(spec.size() <= _radio_perifs.size()); - if (spec.size() > 0) + if (spec.size() >= 1) { UHD_ASSERT_THROW(spec[0].db_name == "A"); - UHD_ASSERT_THROW(spec[0].sd_name == "A"); + UHD_ASSERT_THROW(spec[0].sd_name == "A" or spec[0].sd_name == "B"); } - if (spec.size() > 1) + if (spec.size() == 2) { - //TODO we can support swapping at a later date, only this combo is supported UHD_ASSERT_THROW(spec[1].db_name == "A"); - UHD_ASSERT_THROW(spec[1].sd_name == "B"); + UHD_ASSERT_THROW( + (spec[0].sd_name == "A" and spec[1].sd_name == "B") or + (spec[0].sd_name == "B" and spec[1].sd_name == "A") + ); } - this->update_enables(); -} - -void b200_impl::update_tx_subdev_spec(const uhd::usrp::subdev_spec_t &spec) -{ - //sanity checking - if (spec.size()) validate_subdev_spec(_tree, spec, "tx"); - UHD_ASSERT_THROW(spec.size() <= _radio_perifs.size()); - - if (spec.size() > 0) - { - UHD_ASSERT_THROW(spec[0].db_name == "A"); - UHD_ASSERT_THROW(spec[0].sd_name == "A"); - } - if (spec.size() > 1) - { - //TODO we can support swapping at a later date, only this combo is supported - UHD_ASSERT_THROW(spec[1].db_name == "A"); - UHD_ASSERT_THROW(spec[1].sd_name == "B"); + std::vector chan_to_dsp_map(spec.size(), 0); + for (size_t i = 0; i < spec.size(); i++) { + chan_to_dsp_map[i] = (spec[i].sd_name == "A") ? 0 : 1; } + _tree->access >("/mboards/0" / (tx_rx + "_chan_dsp_mapping")).set(chan_to_dsp_map); this->update_enables(); } @@ -238,13 +225,14 @@ rx_streamer::sptr b200_impl::get_rx_stream(const uhd::stream_args_t &args_) boost::shared_ptr my_streamer; for (size_t stream_i = 0; stream_i < args.channels.size(); stream_i++) { - const size_t chan = args.channels[stream_i]; - radio_perifs_t &perif = _radio_perifs[chan]; + const size_t radio_index = _tree->access >("/mboards/0/rx_chan_dsp_mapping") + .get().at(args.channels[stream_i]); + radio_perifs_t &perif = _radio_perifs[radio_index]; if (args.otw_format == "sc16") perif.ctrl->poke32(TOREG(SR_RX_FMT), 0); if (args.otw_format == "sc12") perif.ctrl->poke32(TOREG(SR_RX_FMT), 1); if (args.otw_format == "fc32") perif.ctrl->poke32(TOREG(SR_RX_FMT), 2); if (args.otw_format == "sc8") perif.ctrl->poke32(TOREG(SR_RX_FMT), 3); - const boost::uint32_t sid = chan?B200_RX_DATA1_SID:B200_RX_DATA0_SID; + const boost::uint32_t sid = radio_index ? B200_RX_DATA1_SID : B200_RX_DATA0_SID; //calculate packet size static const size_t hdr_size = 0 @@ -283,7 +271,7 @@ rx_streamer::sptr b200_impl::get_rx_stream(const uhd::stream_args_t &args_) &recv_packet_demuxer_3000::get_recv_buff, _demux, sid, _1 ), true /*flush*/); my_streamer->set_overflow_handler(stream_i, boost::bind( - &b200_impl::handle_overflow, this, chan + &b200_impl::handle_overflow, this, radio_index )); my_streamer->set_issue_stream_cmd(stream_i, boost::bind( &rx_vita_core_3000::issue_stream_command, perif.framer, _1 @@ -292,21 +280,21 @@ rx_streamer::sptr b200_impl::get_rx_stream(const uhd::stream_args_t &args_) //sets all tick and samp rates on this streamer this->update_tick_rate(this->get_tick_rate()); - _tree->access(str(boost::format("/mboards/0/rx_dsps/%u/rate/value") % chan)).update(); + _tree->access(str(boost::format("/mboards/0/rx_dsps/%u/rate/value") % radio_index)).update(); } this->update_enables(); return my_streamer; } -void b200_impl::handle_overflow(const size_t i) +void b200_impl::handle_overflow(const size_t radio_index) { boost::shared_ptr my_streamer = - boost::dynamic_pointer_cast(_radio_perifs[i].rx_streamer.lock()); + boost::dynamic_pointer_cast(_radio_perifs[radio_index].rx_streamer.lock()); if (my_streamer->get_num_channels() == 2) //MIMO time { //find out if we were in continuous mode before stopping - const bool in_continuous_streaming_mode = _radio_perifs[i].framer->in_continuous_streaming_mode(); + const bool in_continuous_streaming_mode = _radio_perifs[radio_index].framer->in_continuous_streaming_mode(); //stop streaming my_streamer->issue_stream_cmd(stream_cmd_t::STREAM_MODE_STOP_CONTINUOUS); //flush demux @@ -319,11 +307,11 @@ void b200_impl::handle_overflow(const size_t i) { stream_cmd_t stream_cmd(stream_cmd_t::STREAM_MODE_START_CONTINUOUS); stream_cmd.stream_now = false; - stream_cmd.time_spec = _radio_perifs[i].time64->get_time_now() + time_spec_t(0.01); + stream_cmd.time_spec = _radio_perifs[radio_index].time64->get_time_now() + time_spec_t(0.01); my_streamer->issue_stream_cmd(stream_cmd); } } - else _radio_perifs[i].framer->handle_overflow(); + else _radio_perifs[radio_index].framer->handle_overflow(); } /*********************************************************************** @@ -340,8 +328,9 @@ tx_streamer::sptr b200_impl::get_tx_stream(const uhd::stream_args_t &args_) boost::shared_ptr my_streamer; for (size_t stream_i = 0; stream_i < args.channels.size(); stream_i++) { - const size_t chan = args.channels[stream_i]; - radio_perifs_t &perif = _radio_perifs[chan]; + const size_t radio_index = _tree->access >("/mboards/0/tx_chan_dsp_mapping") + .get().at(args.channels[stream_i]); + radio_perifs_t &perif = _radio_perifs[radio_index]; if (args.otw_format == "sc16") perif.ctrl->poke32(TOREG(SR_TX_FMT), 0); if (args.otw_format == "sc12") perif.ctrl->poke32(TOREG(SR_TX_FMT), 1); if (args.otw_format == "fc32") perif.ctrl->poke32(TOREG(SR_TX_FMT), 2); @@ -382,13 +371,13 @@ tx_streamer::sptr b200_impl::get_tx_stream(const uhd::stream_args_t &args_) my_streamer->set_async_receiver(boost::bind( &async_md_type::pop_with_timed_wait, _async_task_data->async_md, _1, _2 )); - my_streamer->set_xport_chan_sid(stream_i, true, chan?B200_TX_DATA1_SID:B200_TX_DATA0_SID); + my_streamer->set_xport_chan_sid(stream_i, true, radio_index ? B200_TX_DATA1_SID : B200_TX_DATA0_SID); my_streamer->set_enable_trailer(false); //TODO not implemented trailer support yet perif.tx_streamer = my_streamer; //store weak pointer //sets all tick and samp rates on this streamer this->update_tick_rate(this->get_tick_rate()); - _tree->access(str(boost::format("/mboards/0/tx_dsps/%u/rate/value") % chan)).update(); + _tree->access(str(boost::format("/mboards/0/tx_dsps/%u/rate/value") % radio_index)).update(); } this->update_enables(); -- cgit v1.2.3 From a92d2f82104a0ac841e7f91001826e718f2b1656 Mon Sep 17 00:00:00 2001 From: Moritz Fischer Date: Sun, 23 Mar 2014 20:30:36 +0100 Subject: b200: Added missing include to b200_impl * In order to use std::ceil and std::floor, on older compilers we need to still add an include for cmath. Tested-by: Marcus D. Leech Signed-off-by: Moritz Fischer --- host/lib/usrp/b200/b200_impl.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'host/lib/usrp/b200') diff --git a/host/lib/usrp/b200/b200_impl.cpp b/host/lib/usrp/b200/b200_impl.cpp index 66df1f3bc..a7f9b11bd 100644 --- a/host/lib/usrp/b200/b200_impl.cpp +++ b/host/lib/usrp/b200/b200_impl.cpp @@ -32,6 +32,7 @@ #include #include #include +#include using namespace uhd; using namespace uhd::usrp; -- cgit v1.2.3