power_control.c 4.4 KB
Newer Older
ghaddab's avatar
ghaddab committed
1
/*******************************************************************************
2
    OpenAirInterface
ghaddab's avatar
ghaddab committed
3 4 5 6 7 8 9 10 11 12 13 14 15 16
    Copyright(c) 1999 - 2014 Eurecom

    OpenAirInterface is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.


    OpenAirInterface is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
17 18
    along with OpenAirInterface.The full GNU General Public License is
   included in this distribution in the file called "COPYING". If not,
ghaddab's avatar
ghaddab committed
19 20 21 22 23
   see <http://www.gnu.org/licenses/>.

  Contact Information
  OpenAirInterface Admin: openair_admin@eurecom.fr
  OpenAirInterface Tech : openair_tech@eurecom.fr
24
  OpenAirInterface Dev  : openair4g-devel@lists.eurecom.fr
25

ghaddab's avatar
ghaddab committed
26
  Address      : Eurecom, Campus SophiaTech, 450 Route des Chappes, CS 50193 - 06904 Biot Sophia Antipolis cedex, FRANCE
ghaddab's avatar
ghaddab committed
27 28

 *******************************************************************************/
29 30 31 32 33 34 35
#include "PHY/defs.h"
#include "PHY/impl_defs_lte.h"

//#define DEBUG_PC 1

/*
double ratioPB[2][4]={{ 1.0,4.0/5.0,3.0/5.0,2.0/5.0},
36
          { 5.0/4.0,1.0,3.0/4.0,1.0/2.0}};
37 38
*/

39 40 41 42 43
double ratioPB[2][4]= {{ 0.00000,  -0.96910,  -2.21849,  -3.97940},
  { 0.96910,   0.00000,  -1.24939,  -3.01030}
};

double pa_values[8]= {-6.0,-4.77,-3.0,-1.77,0.0,1.0,2.0,3.0};
44

45 46
double get_pa_dB(PDSCH_CONFIG_DEDICATED *pdsch_config_dedicated)
{
47
  return(pa_values[pdsch_config_dedicated->p_a]);
48
}
49

50 51 52
double computeRhoA_eNB(PDSCH_CONFIG_DEDICATED *pdsch_config_dedicated,
                       LTE_eNB_DLSCH_t *dlsch_eNB,int dl_power_off)
{
53 54 55 56
  double rho_a_dB;
  double sqrt_rho_a_lin;

  rho_a_dB = pa_values[ pdsch_config_dedicated->p_a];
57 58

  if(!dl_power_off)
59
    rho_a_dB-=10*log10(2);
60 61 62

  sqrt_rho_a_lin= pow(10,(0.05*rho_a_dB));

63
  dlsch_eNB->sqrt_rho_a= (short) (sqrt_rho_a_lin*pow(2,13));
64 65 66

#ifdef DEBUG_PC
  printf("sqrt_rho_a(eNB):%d\n",dlsch_eNB->sqrt_rho_a);
67
#endif
68 69

  return(rho_a_dB);
70 71 72 73
}

double computeRhoB_eNB(PDSCH_CONFIG_DEDICATED  *pdsch_config_dedicated,
                       PDSCH_CONFIG_COMMON *pdsch_config_common,
74
                       uint8_t n_antenna_port,
75
                       LTE_eNB_DLSCH_t *dlsch_eNB,
76 77
                       int dl_power_off)
{
78 79 80

  double rho_a_dB, rho_b_dB;
  double sqrt_rho_b_lin;
81

82
  rho_a_dB= computeRhoA_eNB(pdsch_config_dedicated,dlsch_eNB,dl_power_off);
83

84 85 86 87 88
  if(n_antenna_port>1)
    rho_b_dB= ratioPB[1][pdsch_config_common->p_b] + rho_a_dB;
  else
    rho_b_dB= ratioPB[0][pdsch_config_common->p_b] + rho_a_dB;

89 90
  sqrt_rho_b_lin= pow(10,(0.05*rho_b_dB));

91 92
  dlsch_eNB->sqrt_rho_b= (short) (sqrt_rho_b_lin*pow(2,13));

93
#ifdef DEBUG_PC
94
  printf("sqrt_rho_b(eNB):%d\n",dlsch_eNB->sqrt_rho_b);
95 96
#endif
  return(rho_b_dB);
97 98 99
}


100
double computeRhoA_UE(PDSCH_CONFIG_DEDICATED *pdsch_config_dedicated,
101
                      LTE_UE_DLSCH_t *dlsch_ue,
102 103 104
                      unsigned char dl_power_off)
{

105 106 107 108
  double rho_a_dB;
  double sqrt_rho_a_lin;

  rho_a_dB = pa_values[ pdsch_config_dedicated->p_a];
109 110

  if(!dl_power_off)
111
    rho_a_dB-=10*log10(2);
112 113 114

  sqrt_rho_a_lin= pow(10,(0.05*rho_a_dB));

115
  dlsch_ue->sqrt_rho_a= (short) (sqrt_rho_a_lin*pow(2,13));
116 117 118

#ifdef DEBUG_PC
  printf("sqrt_rho_a(ue):%d\n",dlsch_ue->sqrt_rho_a);
119
#endif
120 121

  return(rho_a_dB);
122 123 124 125
}

double computeRhoB_UE(PDSCH_CONFIG_DEDICATED  *pdsch_config_dedicated,
                      PDSCH_CONFIG_COMMON *pdsch_config_common,
126
                      uint8_t n_antenna_port,
127
                      LTE_UE_DLSCH_t *dlsch_ue,
128 129
                      unsigned char dl_power_off)
{
130 131 132

  double rho_a_dB, rho_b_dB;
  double sqrt_rho_b_lin;
133

134
  rho_a_dB= computeRhoA_UE(pdsch_config_dedicated,dlsch_ue,dl_power_off);
135

136 137 138 139 140
  if(n_antenna_port>1)
    rho_b_dB= ratioPB[1][pdsch_config_common->p_b] + rho_a_dB;
  else
    rho_b_dB= ratioPB[0][pdsch_config_common->p_b] + rho_a_dB;

141 142
  sqrt_rho_b_lin= pow(10,(0.05*rho_b_dB));

143 144
  dlsch_ue->sqrt_rho_b= (short) (sqrt_rho_b_lin*pow(2,13));

145
#ifdef DEBUG_PC
146
  printf("sqrt_rho_b(ue):%d\n",dlsch_ue->sqrt_rho_b);
147 148
#endif
  return(rho_b_dB);
149 150 151
}