diff options
author | Martin Braun <martin.braun@ettus.com> | 2019-07-31 14:34:36 -0700 |
---|---|---|
committer | Martin Braun <martin.braun@ettus.com> | 2019-11-26 11:49:34 -0800 |
commit | d717feaf3d6ce6f8823a6437000e0394b5b68134 (patch) | |
tree | 210870b5f95c8c7994b78357f11e70302b1839ef /host/lib/rfnoc/radio_control_impl.cpp | |
parent | bf986d32632199917dc811f00465ecf409c64a76 (diff) | |
download | uhd-d717feaf3d6ce6f8823a6437000e0394b5b68134.tar.gz uhd-d717feaf3d6ce6f8823a6437000e0394b5b68134.tar.bz2 uhd-d717feaf3d6ce6f8823a6437000e0394b5b68134.zip |
rfnoc: radio: Introduce coerce_rate() method
This is a helper method for property resolution, where set_rate() is not
appropriate.
Diffstat (limited to 'host/lib/rfnoc/radio_control_impl.cpp')
-rw-r--r-- | host/lib/rfnoc/radio_control_impl.cpp | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/host/lib/rfnoc/radio_control_impl.cpp b/host/lib/rfnoc/radio_control_impl.cpp index f71c73289..9648b5dbf 100644 --- a/host/lib/rfnoc/radio_control_impl.cpp +++ b/host/lib/rfnoc/radio_control_impl.cpp @@ -175,9 +175,12 @@ radio_control_impl::radio_control_impl(make_args_ptr make_args) {&_spp_prop.back()}, [this, chan, &spp = _spp_prop.back()]() { RFNOC_LOG_TRACE("Calling resolver for spp@" << chan); + // TODO: Replace the magic number 16 (the protocol overhead) + // with something else that is calculated based on the CHDR width const int mtu = - static_cast<int>(get_mtu({res_source_info::OUTPUT_EDGE, chan})); - const int max_spp_per_mtu = mtu / (_samp_width / 8) - (mtu % _spc); + static_cast<int>(get_mtu({res_source_info::OUTPUT_EDGE, chan})) - 16; + const int mtu_samps = mtu / (_samp_width / 8); + const int max_spp_per_mtu = mtu_samps - (mtu_samps % _spc); if (spp.get() > max_spp_per_mtu) { RFNOC_LOG_WARNING("spp value " << spp.get() << " exceeds MTU of " << mtu << "! Coercing to " @@ -196,13 +199,15 @@ radio_control_impl::radio_control_impl(make_args_ptr make_args) "spp must be greater than zero! Coercing to " << spp.get()); } }); + // Note: The following resolver calls coerce_rate(), which is virtual. + // At run time, it will use the implementation by the child class. add_property_resolver({&_samp_rate_in.back(), &_samp_rate_out.back()}, {&_samp_rate_in.back(), &_samp_rate_out.back()}, [this, chan, &samp_rate_in = _samp_rate_in.at(chan), &samp_rate_out = _samp_rate_out.at(chan)]() { RFNOC_LOG_TRACE("Calling resolver for samp_rate@" << chan); - samp_rate_in = set_rate(samp_rate_in.get()); + samp_rate_in = coerce_rate(samp_rate_in.get()); samp_rate_out = samp_rate_in.get(); }); // Resolvers for type: These are constants |