Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 37 additions & 26 deletions host/libraries/libbladeRF/src/board/bladerf2/bladerf2.c
Original file line number Diff line number Diff line change
Expand Up @@ -1439,19 +1439,34 @@ static int bladerf2_get_quick_tune(struct bladerf *dev,
pm = _get_band_port_map_by_freq(ch, freq);

if (BLADERF_CHANNEL_IS_TX(ch)) {
if (board_data->quick_tune_tx_profile < NUM_BBP_FASTLOCK_PROFILES) {
/* Assign Nios and RFFE profile numbers */
quick_tune->nios_profile = board_data->quick_tune_tx_profile++;
log_verbose("Quick tune assigned Nios TX fast lock index: %u\n",
quick_tune->nios_profile);
quick_tune->rffe_profile =
quick_tune->nios_profile % NUM_RFFE_FASTLOCK_PROFILES;
log_verbose("Quick tune assigned RFFE TX fast lock index: %u\n",
quick_tune->rffe_profile);
} else {
log_error("Reached maximum number of TX quick tune profiles.");
return BLADERF_ERR_UNEXPECTED;
}
/* Profile indices wrap instead of running out.
*
* The counter only ever incremented, and was reset in exactly one
* place: board initialisation. An application that keeps asking for
* quick tunes therefore had a hard budget of 256 for the lifetime of
* the device handle, after which every further call failed with
* BLADERF_ERR_UNEXPECTED and no way to recover short of reopening.
*
* That budget is not a hardware limit on how many retune targets may
* exist over time. The RFIC holds NUM_RFFE_FASTLOCK_PROFILES slots
* and the Nios holds NUM_BBP_FASTLOCK_PROFILES; both are caches that
* the code already overwrites - the RFFE index is assigned modulo the
* slot count, so profile 8 has always overwritten profile 0. Letting
* the Nios index wrap in the same way makes the two consistent and
* keeps a long-running sweep working.
*
* Measured on a bladeRF 2.0 micro xA4 sweeping 70 MHz - 6 GHz with
* 4700 stops: the counter reached 256 after roughly 165-229 s and
* every subsequent retune to a new frequency failed.
*/
quick_tune->nios_profile =
board_data->quick_tune_tx_profile++ % NUM_BBP_FASTLOCK_PROFILES;
log_verbose("Quick tune assigned Nios TX fast lock index: %u\n",
quick_tune->nios_profile);
quick_tune->rffe_profile =
quick_tune->nios_profile % NUM_RFFE_FASTLOCK_PROFILES;
log_verbose("Quick tune assigned RFFE TX fast lock index: %u\n",
quick_tune->rffe_profile);

/* Create a fast lock profile in the RFIC */
CHECK_STATUS(
Expand All @@ -1468,19 +1483,15 @@ static int bladerf2_get_quick_tune(struct bladerf *dev,
quick_tune->spdt = (pm->spdt << 6) | (pm->spdt << 4);

} else {
if (board_data->quick_tune_rx_profile < NUM_BBP_FASTLOCK_PROFILES) {
/* Assign Nios and RFFE profile numbers */
quick_tune->nios_profile = board_data->quick_tune_rx_profile++;
log_verbose("Quick tune assigned Nios RX fast lock index: %u\n",
quick_tune->nios_profile);
quick_tune->rffe_profile =
quick_tune->nios_profile % NUM_RFFE_FASTLOCK_PROFILES;
log_verbose("Quick tune assigned RFFE RX fast lock index: %u\n",
quick_tune->rffe_profile);
} else {
log_error("Reached maximum number of RX quick tune profiles.");
return BLADERF_ERR_UNEXPECTED;
}
/* Profile indices wrap instead of running out; see the TX branch. */
quick_tune->nios_profile =
board_data->quick_tune_rx_profile++ % NUM_BBP_FASTLOCK_PROFILES;
log_verbose("Quick tune assigned Nios RX fast lock index: %u\n",
quick_tune->nios_profile);
quick_tune->rffe_profile =
quick_tune->nios_profile % NUM_RFFE_FASTLOCK_PROFILES;
log_verbose("Quick tune assigned RFFE RX fast lock index: %u\n",
quick_tune->rffe_profile);

/* Create a fast lock profile in the RFIC */
CHECK_STATUS(
Expand Down