2015-02-09 02:32:47 -08:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
* \section COPYRIGHT
|
|
|
|
*
|
2015-05-08 08:05:40 -07:00
|
|
|
* Copyright 2013-2015 The srsLTE Developers. See the
|
2015-02-09 02:32:47 -08:00
|
|
|
* COPYRIGHT file at the top-level directory of this distribution.
|
|
|
|
*
|
|
|
|
* \section LICENSE
|
|
|
|
*
|
2015-03-20 05:01:08 -07:00
|
|
|
* This file is part of the srsLTE library.
|
2015-02-09 02:32:47 -08:00
|
|
|
*
|
2015-03-20 05:01:08 -07:00
|
|
|
* srsLTE is free software: you can redistribute it and/or modify
|
2015-05-08 08:05:40 -07:00
|
|
|
* it under the terms of the GNU Affero General Public License as
|
2015-02-09 02:32:47 -08:00
|
|
|
* published by the Free Software Foundation, either version 3 of
|
|
|
|
* the License, or (at your option) any later version.
|
|
|
|
*
|
2015-03-20 05:01:08 -07:00
|
|
|
* srsLTE is distributed in the hope that it will be useful,
|
2015-02-09 02:32:47 -08:00
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
2015-05-08 08:05:40 -07:00
|
|
|
* GNU Affero General Public License for more details.
|
2015-02-09 02:32:47 -08:00
|
|
|
*
|
2015-05-08 08:05:40 -07:00
|
|
|
* A copy of the GNU Affero General Public License can be found in
|
2015-02-09 02:32:47 -08:00
|
|
|
* the LICENSE file in the top-level directory of this distribution
|
|
|
|
* and at http://www.gnu.org/licenses/.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdint.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <strings.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <stdbool.h>
|
|
|
|
#include <assert.h>
|
|
|
|
#include <math.h>
|
|
|
|
|
2015-03-18 05:31:13 -07:00
|
|
|
#include "srslte/phch/cqi.h"
|
|
|
|
#include "srslte/common/phy_common.h"
|
|
|
|
#include "srslte/utils/bit.h"
|
|
|
|
#include "srslte/utils/vector.h"
|
|
|
|
#include "srslte/utils/debug.h"
|
2015-02-09 02:32:47 -08:00
|
|
|
|
|
|
|
|
2015-03-18 11:14:24 -07:00
|
|
|
int srslte_cqi_hl_subband_pack(srslte_cqi_hl_subband_t *msg, uint32_t N, uint8_t *buff, uint32_t buff_len)
|
2015-02-09 02:32:47 -08:00
|
|
|
{
|
|
|
|
uint8_t *body_ptr = buff;
|
2015-03-18 11:14:24 -07:00
|
|
|
srslte_bit_pack(msg->wideband_cqi, &body_ptr, 4);
|
|
|
|
srslte_bit_pack(msg->subband_diff_cqi, &body_ptr, 2*N);
|
2015-02-13 01:02:10 -08:00
|
|
|
|
|
|
|
return 4+2*N;
|
2015-02-09 02:32:47 -08:00
|
|
|
}
|
|
|
|
|
2015-03-18 11:14:24 -07:00
|
|
|
int srslte_cqi_ue_subband_pack(srslte_cqi_ue_subband_t *msg, uint32_t L, uint8_t *buff, uint32_t buff_len)
|
2015-02-09 02:32:47 -08:00
|
|
|
{
|
|
|
|
uint8_t *body_ptr = buff;
|
2015-03-18 11:14:24 -07:00
|
|
|
srslte_bit_pack(msg->wideband_cqi, &body_ptr, 4);
|
|
|
|
srslte_bit_pack(msg->subband_diff_cqi, &body_ptr, 2);
|
|
|
|
srslte_bit_pack(msg->subband_diff_cqi, &body_ptr, L);
|
2015-02-13 01:02:10 -08:00
|
|
|
|
|
|
|
return 4+2+L;
|
2015-02-09 02:32:47 -08:00
|
|
|
}
|
2015-02-13 01:02:10 -08:00
|
|
|
|
2015-03-18 11:14:24 -07:00
|
|
|
int srslte_cqi_format2_wideband_pack(srslte_cqi_format2_wideband_t *msg, uint8_t *buff, uint32_t buff_len)
|
2015-02-13 01:02:10 -08:00
|
|
|
{
|
|
|
|
uint8_t *body_ptr = buff;
|
2015-03-18 11:14:24 -07:00
|
|
|
srslte_bit_pack(msg->wideband_cqi, &body_ptr, 4);
|
2015-02-13 01:02:10 -08:00
|
|
|
return 4;
|
|
|
|
}
|
|
|
|
|
2015-03-18 11:14:24 -07:00
|
|
|
int srslte_cqi_format2_subband_pack(srslte_cqi_format2_subband_t *msg, uint8_t *buff, uint32_t buff_len)
|
2015-02-13 01:02:10 -08:00
|
|
|
{
|
|
|
|
uint8_t *body_ptr = buff;
|
2015-03-18 11:14:24 -07:00
|
|
|
srslte_bit_pack(msg->subband_cqi, &body_ptr, 4);
|
|
|
|
srslte_bit_pack(msg->subband_label, &body_ptr, 1);
|
2015-02-13 01:02:10 -08:00
|
|
|
return 4+1;
|
|
|
|
}
|
|
|
|
|