diff --git a/lib/include/srslte/phy/ch_estimation/chest_dl.h b/lib/include/srslte/phy/ch_estimation/chest_dl.h index fded05479..a5a6ae111 100644 --- a/lib/include/srslte/phy/ch_estimation/chest_dl.h +++ b/lib/include/srslte/phy/ch_estimation/chest_dl.h @@ -52,12 +52,15 @@ typedef struct SRSLTE_API { float noise_estimate; float noise_estimate_dbm; float snr_db; + float snr_ant_port_db[SRSLTE_MAX_PORTS][SRSLTE_MAX_PORTS]; float rsrp; float rsrp_dbm; float rsrp_neigh_dbm; float rsrp_port_dbm[SRSLTE_MAX_PORTS]; + float rsrp_ant_port_dbm[SRSLTE_MAX_PORTS][SRSLTE_MAX_PORTS]; float rsrq; float rsrq_db; + float rsrq_ant_port_db[SRSLTE_MAX_PORTS][SRSLTE_MAX_PORTS]; float rssi_dbm; float cfo; } srslte_chest_dl_res_t; @@ -149,8 +152,4 @@ SRSLTE_API int srslte_chest_dl_estimate_cfg(srslte_chest_dl_t* q, cf_t* input[SRSLTE_MAX_PORTS], srslte_chest_dl_res_t* res); -/* These functions are exceptions and return values from last call to chest_dl_estimate */ -SRSLTE_API float srslte_chest_dl_get_rsrq_ant_port(srslte_chest_dl_t* q, uint32_t ant_idx, uint32_t port_idx); -SRSLTE_API float srslte_chest_dl_get_rsrp_ant_port(srslte_chest_dl_t* q, uint32_t ant_idx, uint32_t port); - #endif // SRSLTE_CHEST_DL_H diff --git a/lib/src/phy/ch_estimation/chest_dl.c b/lib/src/phy/ch_estimation/chest_dl.c index 9a875349b..7aa0804b5 100644 --- a/lib/src/phy/ch_estimation/chest_dl.c +++ b/lib/src/phy/ch_estimation/chest_dl.c @@ -766,24 +766,15 @@ static float get_rsrq(srslte_chest_dl_t* q) return n / q->nof_rx_antennas; } -float srslte_chest_dl_get_rsrq_ant_port(srslte_chest_dl_t *q, uint32_t ant_idx, uint32_t port_idx) { - return q->cell.nof_prb*q->rsrp[ant_idx][port_idx] / q->rssi[ant_idx][port_idx]; -} - -float srslte_chest_dl_get_rsrp_ant_port(srslte_chest_dl_t* q, uint32_t ant_idx, uint32_t port) -{ - return q->rsrp[ant_idx][port]; -} - static float get_rsrp_port(srslte_chest_dl_t* q, uint32_t port) { float sum = 0.0f; - for (int j = 0; j < q->cell.nof_ports; ++j) { - sum +=q->rsrp[port][j]; + for (int j = 0; j < q->nof_rx_antennas; ++j) { + sum += q->rsrp[j][port]; } - if (q->cell.nof_ports) { - sum /= q->cell.nof_ports; + if (q->nof_rx_antennas) { + sum /= q->nof_rx_antennas; } return sum; @@ -855,6 +846,15 @@ static void fill_res(srslte_chest_dl_t* q, srslte_chest_dl_res_t* res) for (uint32_t port_id = 0; port_id < q->cell.nof_ports; port_id++) { res->rsrp_port_dbm[port_id] = dbm(get_rsrp_port(q, port_id)); + for (uint32_t a = 0; a < q->nof_rx_antennas; a++) { + if (q->noise_estimate[a]) { + res->snr_ant_port_db[a][port_id] = db(q->rsrp[a][port_id] / q->noise_estimate[a][port_id]); + } else { + res->snr_ant_port_db[a][port_id] = 0.0; + } + res->rsrp_ant_port_dbm[a][port_id] = db(q->rsrp[a][port_id]); + res->rsrq_ant_port_db[a][port_id] = db(q->cell.nof_prb * q->rsrp[a][port_id] / q->rssi[a][port_id]); + } } }