aboutsummaryrefslogtreecommitdiffstats
path: root/host/lib/usrp
diff options
context:
space:
mode:
authorJosh Blum <josh@joshknows.com>2011-02-17 18:55:55 -0800
committerJosh Blum <josh@joshknows.com>2011-02-17 18:55:55 -0800
commite128948a96f8587eb7e965ad462c61fc25b87536 (patch)
tree311740d3e29f5cf21ab216300943a6e0218c6047 /host/lib/usrp
parentdd75aa585afb9e59fcbb61507ad1a44fa4a00d38 (diff)
downloaduhd-e128948a96f8587eb7e965ad462c61fc25b87536.tar.gz
uhd-e128948a96f8587eb7e965ad462c61fc25b87536.tar.bz2
uhd-e128948a96f8587eb7e965ad462c61fc25b87536.zip
usrp: support for multiple dsps in props and implemented in usrp1
usrp1 previously had 1 rx and 1 tx dsp with multiple freq params, it now has N and M dsps each with one freq param. This is more consistent with the multi-dsp model. The hack here is to only apply stream commands and sample rate changes to dsp0.
Diffstat (limited to 'host/lib/usrp')
-rw-r--r--host/lib/usrp/multi_usrp.cpp22
-rw-r--r--host/lib/usrp/tune_helper.cpp29
-rw-r--r--host/lib/usrp/usrp1/dsp_impl.cpp93
-rw-r--r--host/lib/usrp/usrp1/mboard_impl.cpp14
-rw-r--r--host/lib/usrp/usrp1/usrp1_impl.hpp16
5 files changed, 78 insertions, 96 deletions
diff --git a/host/lib/usrp/multi_usrp.cpp b/host/lib/usrp/multi_usrp.cpp
index 5130d3ae8..2e38a9ff8 100644
--- a/host/lib/usrp/multi_usrp.cpp
+++ b/host/lib/usrp/multi_usrp.cpp
@@ -193,7 +193,7 @@ public:
_rx_dsp(chan)[DSP_PROP_STREAM_CMD] = stream_cmd;
return;
}
- for (size_t c = 0; m < get_rx_num_channels(); m++){
+ for (size_t c = 0; c < get_rx_num_channels(); c++){
issue_stream_cmd(stream_cmd, c);
}
}
@@ -245,13 +245,13 @@ public:
return _rx_subdev(chan)[SUBDEV_PROP_NAME].as<std::string>();
}
- void set_rx_rate(double rate){
+ void set_rx_rate(double rate, size_t chan){
if (chan != ALL_CHANS){
_rx_dsp(chan)[DSP_PROP_HOST_RATE] = rate;
do_samp_rate_warning_message(rate, get_rx_rate(chan), "RX");
return;
}
- for (size_t c = 0; m < get_rx_num_channels(); m++){
+ for (size_t c = 0; c < get_rx_num_channels(); c++){
set_rx_rate(rate, c);
}
}
@@ -261,13 +261,13 @@ public:
}
tune_result_t set_rx_freq(const tune_request_t &tune_request, size_t chan){
- tune_result_t r = tune_rx_subdev_and_dsp(_rx_subdev(chan), _rx_dsp(chan), chan%rx_cpm(), tune_request);
+ tune_result_t r = tune_rx_subdev_and_dsp(_rx_subdev(chan), _rx_dsp(chan), tune_request);
do_tune_freq_warning_message(tune_request.target_freq, get_rx_freq(chan), "RX");
return r;
}
double get_rx_freq(size_t chan){
- return derive_freq_from_rx_subdev_and_dsp(_rx_subdev(chan), _rx_dsp(chan), chan%rx_cpm());
+ return derive_freq_from_rx_subdev_and_dsp(_rx_subdev(chan), _rx_dsp(chan));
}
freq_range_t get_rx_freq_range(size_t chan){
@@ -347,13 +347,13 @@ public:
return tx_cpm()*get_num_mboards(); //total num channels
}
- void set_tx_rate(double rate){
+ void set_tx_rate(double rate, size_t chan){
if (chan != ALL_CHANS){
_tx_dsp(chan)[DSP_PROP_HOST_RATE] = rate;
do_samp_rate_warning_message(rate, get_tx_rate(chan), "TX");
return;
}
- for (size_t c = 0; m < get_tx_num_channels(); m++){
+ for (size_t c = 0; c < get_tx_num_channels(); c++){
set_tx_rate(rate, c);
}
}
@@ -363,13 +363,13 @@ public:
}
tune_result_t set_tx_freq(const tune_request_t &tune_request, size_t chan){
- tune_result_t r = tune_tx_subdev_and_dsp(_tx_subdev(chan), _tx_dsp(chan), chan%tx_cpm(), tune_request);
+ tune_result_t r = tune_tx_subdev_and_dsp(_tx_subdev(chan), _tx_dsp(chan), tune_request);
do_tune_freq_warning_message(tune_request.target_freq, get_tx_freq(chan), "TX");
return r;
}
double get_tx_freq(size_t chan){
- return derive_freq_from_tx_subdev_and_dsp(_tx_subdev(chan), _tx_dsp(chan), chan%tx_cpm());
+ return derive_freq_from_tx_subdev_and_dsp(_tx_subdev(chan), _tx_dsp(chan));
}
freq_range_t get_tx_freq_range(size_t chan){
@@ -453,11 +453,11 @@ private:
}
wax::obj _rx_dsp(size_t chan){
prop_names_t dsp_names = _mboard(chan/rx_cpm())[MBOARD_PROP_RX_DSP_NAMES].as<prop_names_t>();
- return _mboard(chan/rx_cpm())[named_prop_t(MBOARD_PROP_RX_DSP, dsp_names.at(chan%rx_cpm())];
+ return _mboard(chan/rx_cpm())[named_prop_t(MBOARD_PROP_RX_DSP, dsp_names.at(chan%rx_cpm()))];
}
wax::obj _tx_dsp(size_t chan){
prop_names_t dsp_names = _mboard(chan/tx_cpm())[MBOARD_PROP_TX_DSP_NAMES].as<prop_names_t>();
- return _mboard(chan/tx_cpm())[named_prop_t(MBOARD_PROP_TX_DSP, dsp_names.at(chan%tx_cpm())];
+ return _mboard(chan/tx_cpm())[named_prop_t(MBOARD_PROP_TX_DSP, dsp_names.at(chan%tx_cpm()))];
}
wax::obj _rx_dboard(size_t chan){
std::string db_name = get_rx_subdev_spec(chan/rx_cpm()).at(chan%rx_cpm()).db_name;
diff --git a/host/lib/usrp/tune_helper.cpp b/host/lib/usrp/tune_helper.cpp
index eccee7f4b..ced80c187 100644
--- a/host/lib/usrp/tune_helper.cpp
+++ b/host/lib/usrp/tune_helper.cpp
@@ -30,12 +30,11 @@ using namespace uhd::usrp;
**********************************************************************/
static tune_result_t tune_xx_subdev_and_dsp(
dboard_iface::unit_t unit,
- wax::obj subdev, wax::obj dsp, size_t chan,
+ wax::obj subdev, wax::obj dsp,
const tune_request_t &tune_request
){
wax::obj subdev_freq_proxy = subdev[SUBDEV_PROP_FREQ];
- std::string freq_name = dsp[DSP_PROP_FREQ_SHIFT_NAMES].as<prop_names_t>().at(chan);
- wax::obj dsp_freq_proxy = dsp[named_prop_t(DSP_PROP_FREQ_SHIFT, freq_name)];
+ wax::obj dsp_freq_proxy = dsp[DSP_PROP_FREQ_SHIFT];
//------------------------------------------------------------------
//-- calculate the LO offset, only used with automatic policy
@@ -105,13 +104,11 @@ static tune_result_t tune_xx_subdev_and_dsp(
}
static double derive_freq_from_xx_subdev_and_dsp(
- dboard_iface::unit_t unit,
- wax::obj subdev, wax::obj dsp, size_t chan
+ dboard_iface::unit_t unit, wax::obj subdev, wax::obj dsp
){
//extract actual dsp and IF frequencies
double actual_inter_freq = subdev[SUBDEV_PROP_FREQ].as<double>();
- std::string freq_name = dsp[DSP_PROP_FREQ_SHIFT_NAMES].as<prop_names_t>().at(chan);
- double actual_dsp_freq = dsp[named_prop_t(DSP_PROP_FREQ_SHIFT, freq_name)].as<double>();
+ double actual_dsp_freq = dsp[DSP_PROP_FREQ_SHIFT].as<double>();
//invert the sign on the dsp freq given the following conditions
if (unit == dboard_iface::UNIT_TX) actual_dsp_freq *= -1.0;
@@ -123,30 +120,28 @@ static double derive_freq_from_xx_subdev_and_dsp(
* RX Tune
**********************************************************************/
tune_result_t usrp::tune_rx_subdev_and_dsp(
- wax::obj subdev, wax::obj ddc, size_t chan,
- const tune_request_t &tune_request
+ wax::obj subdev, wax::obj ddc, const tune_request_t &tune_request
){
- return tune_xx_subdev_and_dsp(dboard_iface::UNIT_RX, subdev, ddc, chan, tune_request);
+ return tune_xx_subdev_and_dsp(dboard_iface::UNIT_RX, subdev, ddc, tune_request);
}
double usrp::derive_freq_from_rx_subdev_and_dsp(
- wax::obj subdev, wax::obj ddc, size_t chan
+ wax::obj subdev, wax::obj ddc
){
- return derive_freq_from_xx_subdev_and_dsp(dboard_iface::UNIT_RX, subdev, ddc, chan);
+ return derive_freq_from_xx_subdev_and_dsp(dboard_iface::UNIT_RX, subdev, ddc);
}
/***********************************************************************
* TX Tune
**********************************************************************/
tune_result_t usrp::tune_tx_subdev_and_dsp(
- wax::obj subdev, wax::obj duc, size_t chan,
- const tune_request_t &tune_request
+ wax::obj subdev, wax::obj duc, const tune_request_t &tune_request
){
- return tune_xx_subdev_and_dsp(dboard_iface::UNIT_TX, subdev, duc, chan, tune_request);
+ return tune_xx_subdev_and_dsp(dboard_iface::UNIT_TX, subdev, duc, tune_request);
}
double usrp::derive_freq_from_tx_subdev_and_dsp(
- wax::obj subdev, wax::obj duc, size_t chan
+ wax::obj subdev, wax::obj duc
){
- return derive_freq_from_xx_subdev_and_dsp(dboard_iface::UNIT_TX, subdev, duc, chan);
+ return derive_freq_from_xx_subdev_and_dsp(dboard_iface::UNIT_TX, subdev, duc);
}
diff --git a/host/lib/usrp/usrp1/dsp_impl.cpp b/host/lib/usrp/usrp1/dsp_impl.cpp
index 370f4831f..9d6aca874 100644
--- a/host/lib/usrp/usrp1/dsp_impl.cpp
+++ b/host/lib/usrp/usrp1/dsp_impl.cpp
@@ -34,23 +34,25 @@ using namespace uhd::usrp;
**********************************************************************/
void usrp1_impl::rx_dsp_init(void)
{
- _rx_dsp_proxy = wax_obj_proxy::make(
- boost::bind(&usrp1_impl::rx_dsp_get, this, _1, _2),
- boost::bind(&usrp1_impl::rx_dsp_set, this, _1, _2));
-
- rx_dsp_set(DSP_PROP_HOST_RATE, _clock_ctrl->get_master_clock_freq() / 16);
+ for (size_t i = 0; i < this->get_num_ddcs(); i++){
+ _rx_dsp_proxies[str(boost::format("dsp%d")%i)] = wax_obj_proxy::make(
+ boost::bind(&usrp1_impl::rx_dsp_get, this, _1, _2, i),
+ boost::bind(&usrp1_impl::rx_dsp_set, this, _1, _2, i)
+ );
+ rx_dsp_set(DSP_PROP_HOST_RATE, _clock_ctrl->get_master_clock_freq() / 16, i);
+ }
}
/***********************************************************************
* RX DDC Get
**********************************************************************/
-void usrp1_impl::rx_dsp_get(const wax::obj &key_, wax::obj &val){
+void usrp1_impl::rx_dsp_get(const wax::obj &key_, wax::obj &val, size_t which_dsp){
named_prop_t key = named_prop_t::extract(key_);
switch(key.as<dsp_prop_t>()){
case DSP_PROP_NAME:
- val = str(boost::format("usrp1 ddc %uX %s")
- % this->get_num_ddcs()
+ val = str(boost::format("usrp1 ddc%d %s")
+ % which_dsp
% (this->has_rx_halfband()? "+ hb" : "")
);
return;
@@ -60,16 +62,7 @@ void usrp1_impl::rx_dsp_get(const wax::obj &key_, wax::obj &val){
return;
case DSP_PROP_FREQ_SHIFT:
- val = _rx_dsp_freqs[key.name];
- return;
-
- case DSP_PROP_FREQ_SHIFT_NAMES:{
- prop_names_t names;
- for(size_t i = 0; i < this->get_num_ddcs(); i++){
- names.push_back(boost::lexical_cast<std::string>(i));
- }
- val = names;
- }
+ val = _rx_dsp_freqs[which_dsp];
return;
case DSP_PROP_CODEC_RATE:
@@ -88,7 +81,7 @@ void usrp1_impl::rx_dsp_get(const wax::obj &key_, wax::obj &val){
/***********************************************************************
* RX DDC Set
**********************************************************************/
-void usrp1_impl::rx_dsp_set(const wax::obj &key_, const wax::obj &val){
+void usrp1_impl::rx_dsp_set(const wax::obj &key_, const wax::obj &val, size_t which_dsp){
named_prop_t key = named_prop_t::extract(key_);
switch(key.as<dsp_prop_t>()) {
@@ -97,16 +90,17 @@ void usrp1_impl::rx_dsp_set(const wax::obj &key_, const wax::obj &val){
boost::uint32_t reg_word = dsp_type1::calc_cordic_word_and_update(
new_freq, _clock_ctrl->get_master_clock_freq());
- static const uhd::dict<std::string, boost::uint32_t>
- freq_name_to_reg_val = boost::assign::map_list_of
- ("0", FR_RX_FREQ_0) ("1", FR_RX_FREQ_1)
- ("2", FR_RX_FREQ_2) ("3", FR_RX_FREQ_3)
- ;
- _iface->poke32(freq_name_to_reg_val[key.name], ~reg_word + 1);
- _rx_dsp_freqs[key.name] = new_freq;
+ static const boost::uint32_t dsp_index_to_reg_val[4] = {
+ FR_RX_FREQ_0, FR_RX_FREQ_1, FR_RX_FREQ_2, FR_RX_FREQ_3
+ };
+ _iface->poke32(dsp_index_to_reg_val[which_dsp], ~reg_word + 1);
+ _rx_dsp_freqs[which_dsp] = new_freq;
return;
}
- case DSP_PROP_HOST_RATE: {
+
+ case DSP_PROP_HOST_RATE:
+ if (which_dsp != 0) return; //only for dsp[0] as this is vectorized
+ {
size_t rate = size_t(_clock_ctrl->get_master_clock_freq() / val.as<double>());
if ((rate & 0x01) || (rate < 4) || (rate > 256)) {
@@ -123,6 +117,11 @@ void usrp1_impl::rx_dsp_set(const wax::obj &key_, const wax::obj &val){
}
return;
+ case DSP_PROP_STREAM_CMD:
+ if (which_dsp != 0) return; //only for dsp[0] as this is vectorized
+ _soft_time_ctrl->issue_stream_cmd(val.as<stream_cmd_t>());
+ return;
+
default: UHD_THROW_PROP_SET_ERROR();
}
@@ -133,24 +132,25 @@ void usrp1_impl::rx_dsp_set(const wax::obj &key_, const wax::obj &val){
**********************************************************************/
void usrp1_impl::tx_dsp_init(void)
{
- _tx_dsp_proxy = wax_obj_proxy::make(
- boost::bind(&usrp1_impl::tx_dsp_get, this, _1, _2),
- boost::bind(&usrp1_impl::tx_dsp_set, this, _1, _2));
-
- //initial config and update
- tx_dsp_set(DSP_PROP_HOST_RATE, _clock_ctrl->get_master_clock_freq() * 2 / 16);
+ for (size_t i = 0; i < this->get_num_ducs(); i++){
+ _tx_dsp_proxies[str(boost::format("dsp%d")%i)] = wax_obj_proxy::make(
+ boost::bind(&usrp1_impl::tx_dsp_get, this, _1, _2, i),
+ boost::bind(&usrp1_impl::tx_dsp_set, this, _1, _2, i)
+ );
+ tx_dsp_set(DSP_PROP_HOST_RATE, _clock_ctrl->get_master_clock_freq() / 16, i);
+ }
}
/***********************************************************************
* TX DUC Get
**********************************************************************/
-void usrp1_impl::tx_dsp_get(const wax::obj &key_, wax::obj &val){
+void usrp1_impl::tx_dsp_get(const wax::obj &key_, wax::obj &val, size_t which_dsp){
named_prop_t key = named_prop_t::extract(key_);
switch(key.as<dsp_prop_t>()) {
case DSP_PROP_NAME:
- val = str(boost::format("usrp1 duc %uX %s")
- % this->get_num_ducs()
+ val = str(boost::format("usrp1 duc%d %s")
+ % which_dsp
% (this->has_tx_halfband()? "+ hb" : "")
);
return;
@@ -160,16 +160,7 @@ void usrp1_impl::tx_dsp_get(const wax::obj &key_, wax::obj &val){
return;
case DSP_PROP_FREQ_SHIFT:
- val = _tx_dsp_freqs[key.name];
- return;
-
- case DSP_PROP_FREQ_SHIFT_NAMES:{
- prop_names_t names;
- for(size_t i = 0; i < this->get_num_ducs(); i++){
- names.push_back(boost::lexical_cast<std::string>(i));
- }
- val = names;
- }
+ val = _tx_dsp_freqs[which_dsp];
return;
case DSP_PROP_CODEC_RATE:
@@ -188,7 +179,7 @@ void usrp1_impl::tx_dsp_get(const wax::obj &key_, wax::obj &val){
/***********************************************************************
* TX DUC Set
**********************************************************************/
-void usrp1_impl::tx_dsp_set(const wax::obj &key_, const wax::obj &val){
+void usrp1_impl::tx_dsp_set(const wax::obj &key_, const wax::obj &val, size_t which_dsp){
named_prop_t key = named_prop_t::extract(key_);
switch(key.as<dsp_prop_t>()) {
@@ -197,15 +188,17 @@ void usrp1_impl::tx_dsp_set(const wax::obj &key_, const wax::obj &val){
double new_freq = val.as<double>();
//map the freq shift key to a subdev spec to a particular codec chip
- std::string db_name = _tx_subdev_spec.at(boost::lexical_cast<size_t>(key.name)).db_name;
+ std::string db_name = _tx_subdev_spec.at(which_dsp).db_name;
if (db_name == "A") _codec_ctrls[DBOARD_SLOT_A]->set_duc_freq(new_freq);
if (db_name == "B") _codec_ctrls[DBOARD_SLOT_B]->set_duc_freq(new_freq);
- _tx_dsp_freqs[key.name] = new_freq;
+ _tx_dsp_freqs[which_dsp] = new_freq;
return;
}
- case DSP_PROP_HOST_RATE: {
+ case DSP_PROP_HOST_RATE:
+ if (which_dsp != 0) return; //only for dsp[0] as this is vectorized
+ {
size_t rate = size_t(_clock_ctrl->get_master_clock_freq() * 2 / val.as<double>());
if ((rate & 0x01) || (rate < 8) || (rate > 512)) {
diff --git a/host/lib/usrp/usrp1/mboard_impl.cpp b/host/lib/usrp/usrp1/mboard_impl.cpp
index 6d5bf466d..26d3e41d4 100644
--- a/host/lib/usrp/usrp1/mboard_impl.cpp
+++ b/host/lib/usrp/usrp1/mboard_impl.cpp
@@ -280,21 +280,19 @@ void usrp1_impl::mboard_get(const wax::obj &key_, wax::obj &val)
return;
case MBOARD_PROP_RX_DSP:
- UHD_ASSERT_THROW(key.name == "");
- val = _rx_dsp_proxy->get_link();
+ val = _rx_dsp_proxies.get(key.name)->get_link();
return;
case MBOARD_PROP_RX_DSP_NAMES:
- val = prop_names_t(1, "");
+ val = _rx_dsp_proxies.keys();
return;
case MBOARD_PROP_TX_DSP:
- UHD_ASSERT_THROW(key.name == "");
- val = _tx_dsp_proxy->get_link();
+ val = _tx_dsp_proxies.get(key.name)->get_link();
return;
case MBOARD_PROP_TX_DSP_NAMES:
- val = prop_names_t(1, "");
+ val = _tx_dsp_proxies.keys();
return;
case MBOARD_PROP_CLOCK_CONFIG:
@@ -342,10 +340,6 @@ void usrp1_impl::mboard_set(const wax::obj &key, const wax::obj &val)
//handle the get request conditioned on the key
switch(key.as<mboard_prop_t>()){
- case MBOARD_PROP_STREAM_CMD:
- _soft_time_ctrl->issue_stream_cmd(val.as<stream_cmd_t>());
- return;
-
case MBOARD_PROP_RX_SUBDEV_SPEC:
_rx_subdev_spec = val.as<subdev_spec_t>();
if (_rx_subdev_spec.size() > this->get_num_ddcs()){
diff --git a/host/lib/usrp/usrp1/usrp1_impl.hpp b/host/lib/usrp/usrp1/usrp1_impl.hpp
index 1d9f6709f..9755c466d 100644
--- a/host/lib/usrp/usrp1/usrp1_impl.hpp
+++ b/host/lib/usrp/usrp1/usrp1_impl.hpp
@@ -182,19 +182,19 @@ private:
//rx dsp functions and settings
void rx_dsp_init(void);
- void rx_dsp_get(const wax::obj &, wax::obj &);
- void rx_dsp_set(const wax::obj &, const wax::obj &);
- uhd::dict<std::string, double> _rx_dsp_freqs;
+ void rx_dsp_get(const wax::obj &, wax::obj &, size_t);
+ void rx_dsp_set(const wax::obj &, const wax::obj &, size_t);
+ uhd::dict<size_t, double> _rx_dsp_freqs;
size_t _rx_dsp_decim;
- wax_obj_proxy::sptr _rx_dsp_proxy;
+ uhd::dict<std::string, wax_obj_proxy::sptr> _rx_dsp_proxies;
//tx dsp functions and settings
void tx_dsp_init(void);
- void tx_dsp_get(const wax::obj &, wax::obj &);
- void tx_dsp_set(const wax::obj &, const wax::obj &);
- uhd::dict<std::string, double> _tx_dsp_freqs;
+ void tx_dsp_get(const wax::obj &, wax::obj &, size_t);
+ void tx_dsp_set(const wax::obj &, const wax::obj &, size_t);
+ uhd::dict<size_t, double> _tx_dsp_freqs;
size_t _tx_dsp_interp;
- wax_obj_proxy::sptr _tx_dsp_proxy;
+ uhd::dict<std::string, wax_obj_proxy::sptr> _tx_dsp_proxies;
//transports
uhd::transport::usb_zero_copy::sptr _data_transport;