removed FRAME_LENGTH_COMPLEX_SAMPLES from pcie_interface.h and adapted functions that were still using it
added gain control (only used by emos-raw at the moment) emos-raw now supports multiple cards and has a scope git-svn-id: http://svn.eurecom.fr/openair4G/trunk@5122 818b1a75-f10b-46b9-bf7c-635c3b92a50f
This commit is contained in:
@@ -37,9 +37,9 @@
|
||||
#define MAX_FIRMWARE_BLOCK_SIZE_B 262144
|
||||
#define MAX_PRINTK_BUFFER_B 1024
|
||||
|
||||
#define FRAME_LENGTH_COMPLEX_SAMPLES 76800
|
||||
// #define FRAME_LENGTH_COMPLEX_SAMPLES 76800
|
||||
// Buffer size per channel: FRAME_LENGTH_COMPLEX_SAMPLES+2048 smp/frame: LTE frame+tail, *4 (7.68*4 MsmpPS), *4 Bytes/smp
|
||||
#define ADAC_BUFFERSZ_PERCHAN_B ((FRAME_LENGTH_COMPLEX_SAMPLES+2048)*4*4)
|
||||
#define ADAC_BUFFERSZ_PERCHAN_B ((76800+2048)*4*4)
|
||||
|
||||
#define BIGSHM_SIZE_PAGES ((( MAX_FIRMWARE_BLOCK_SIZE_B + \
|
||||
MAX_PRINTK_BUFFER_B + \
|
||||
@@ -305,6 +305,12 @@ typedef struct
|
||||
#define TEST_ADACLOOP_MASK (1<<4)
|
||||
#define TEST_ADACLOOP_EN (1<<4)
|
||||
|
||||
typedef enum {
|
||||
BW5,
|
||||
BW10,
|
||||
BW20
|
||||
} exmimo_bw_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint32_t multicard_syncmode;
|
||||
|
||||
@@ -0,0 +1,64 @@
|
||||
#include "openair0_lib.h"
|
||||
#include "gain_control.h"
|
||||
//#define DEBUG_PHY
|
||||
#define min(a,b) (((a)<(b))?(a):(b))
|
||||
#define max(a,b) (((a)>(b))?(a):(b))
|
||||
|
||||
void gain_control_all (unsigned int rx_power_fil_dB, unsigned int card) {
|
||||
unsigned int ant;
|
||||
for (ant=0;ant<4;ant++)
|
||||
gain_control (rx_power_fil_dB,ant,card);
|
||||
}
|
||||
|
||||
void gain_control (unsigned int rx_power_fil_dB, unsigned int ant, unsigned int card) {
|
||||
|
||||
exmimo_config_t *p_exmimo_config = openair0_exmimo_pci[card].exmimo_config_ptr;
|
||||
unsigned int rf_mode, rx_gain, LNA;
|
||||
|
||||
rx_gain = p_exmimo_config->rf.rx_gain[ant][0];
|
||||
rf_mode = p_exmimo_config->rf.rf_mode[ant];
|
||||
LNA = rf_mode & LNAGAINMASK;
|
||||
|
||||
// Gain control with hysterisis
|
||||
|
||||
if (rx_power_fil_dB < TARGET_RX_POWER_MIN) { //increase gain
|
||||
switch (LNA) {
|
||||
case LNAByp:
|
||||
p_exmimo_config->rf.rf_mode[ant] = (rf_mode & (~LNAGAINMASK)) | LNAMed;
|
||||
break;
|
||||
case LNAMed:
|
||||
p_exmimo_config->rf.rf_mode[ant] = (rf_mode & (~LNAGAINMASK)) | LNAMax;
|
||||
break;
|
||||
case LNAMax:
|
||||
p_exmimo_config->rf.rx_gain[ant][0] = min(30,rx_gain+5);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if (rx_power_fil_dB > TARGET_RX_POWER_MAX) { //decrease gain
|
||||
if (rx_gain==0) {
|
||||
switch (LNA) {
|
||||
case LNAMax:
|
||||
p_exmimo_config->rf.rf_mode[ant] = (rf_mode & (~LNAGAINMASK)) | LNAMed;
|
||||
break;
|
||||
case LNAMed:
|
||||
p_exmimo_config->rf.rf_mode[ant] = (rf_mode & (~LNAGAINMASK)) | LNAByp;
|
||||
break;
|
||||
case LNAByp:
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
else {
|
||||
p_exmimo_config->rf.rx_gain[ant][0] = max(0,(int)rx_gain-5);
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef DEBUG_PHY
|
||||
LOG_D(PHY,"AGC for chain %d: rx_power_fil_dB=%d, rx_gain=%d, LNA=%d (1=Byp,2=Med,3=Max)\n",ant,rx_power_fil_dB,p_exmimo_config->rf.rx_gain[ant][0],(p_exmimo_config->rf.rf_mode&LNAGAINMASK)>>14);
|
||||
#endif //DEBUG_PHY
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
#define TARGET_RX_POWER 55 // Target digital power for the AGC
|
||||
#define TARGET_RX_POWER_MAX 55 // Maximum digital power for AGC
|
||||
#define TARGET_RX_POWER_MIN 50 // Minimum digital power for AGC
|
||||
|
||||
void gain_control_all (unsigned int rx_power_fil_dB, unsigned int card);
|
||||
void gain_control (unsigned int rx_power_fil_dB, unsigned int ant, unsigned int card);
|
||||
@@ -19,6 +19,8 @@ extern "C" {
|
||||
|
||||
#define TRACE 1
|
||||
|
||||
#define FRAME_LENGTH_COMPLEX_SAMPLES 76800
|
||||
|
||||
static bool any_bad_argument(const octave_value_list &args)
|
||||
{
|
||||
octave_value v;
|
||||
|
||||
@@ -24,7 +24,7 @@ static bool any_bad_argument(const octave_value_list &args)
|
||||
if (args.length()!=3)
|
||||
{
|
||||
error(FCNNAME);
|
||||
error("syntax: oarf_send_frame(card,sig,nbits)\n card (starting from 0), sig is a 2D or 4D vector (depending on no. of antennas), nbits is number of bits to quantize the signal to.");
|
||||
error("syntax: oarf_send_frame(card,sig,nbits)\n card (starting from 0), sig is a 2D array (size depends on no. of antennas and resampling factor), nbits is number of bits to quantize the signal to.");
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -38,15 +38,16 @@ static bool any_bad_argument(const octave_value_list &args)
|
||||
|
||||
v=args(1);
|
||||
printf("signal: R %d, C %d\n",v.rows(),v.columns());
|
||||
return false;
|
||||
|
||||
v=args(2);
|
||||
if ((!v.is_real_scalar()) || (v.scalar_value()!=8) || (v.scalar_value()!=16))
|
||||
if ((!v.is_real_scalar()) && (v.scalar_value()!=8) && (v.scalar_value()!=16))
|
||||
{
|
||||
error(FCNNAME);
|
||||
error("nbits must be either 8 (CBMIMO) or 16 (ExpressMIMO)bits.");
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -60,9 +61,8 @@ DEFUN_DLD (oarf_send_frame, args, nargout,"Send frame")
|
||||
|
||||
octave_value returnvalue;
|
||||
int i, ret;
|
||||
unsigned int length,aa,nbits, numcols;
|
||||
unsigned int length,aa,nbits,numcols;
|
||||
unsigned int resampling_factor[4];
|
||||
int dummy=0;
|
||||
|
||||
ret = openair0_open();
|
||||
if ( ret != 0 )
|
||||
@@ -84,17 +84,19 @@ DEFUN_DLD (oarf_send_frame, args, nargout,"Send frame")
|
||||
|
||||
numcols = args(1).columns();
|
||||
|
||||
printf("colums = %d, rows = %d\n\n\n", numcols, args(1).rows());
|
||||
//printf("colums = %d, rows = %d\n\n\n", numcols, args(1).rows());
|
||||
|
||||
if ( numcols<1 || (numcols > openair0_num_antennas[card]))
|
||||
{
|
||||
error(FCNNAME);
|
||||
error("input array must be of column size 1..%d.", openair0_num_antennas[card]);
|
||||
error("input array must be of column size %d.", openair0_num_antennas[card]);
|
||||
return octave_value_list();
|
||||
}
|
||||
|
||||
for (i=0;i<4;i++)
|
||||
for (i=0;i<4;i++) {
|
||||
resampling_factor[i] = (openair0_exmimo_pci[card].exmimo_config_ptr)->framing.resampling_factor[i];
|
||||
printf("card %d, ant %d, resampling %d\n",card,i,resampling_factor[i]);
|
||||
}
|
||||
|
||||
for (i=0;i<numcols;i++){
|
||||
if (args(1).rows()<(76800*(1 << (2-resampling_factor[i]))))
|
||||
@@ -117,8 +119,7 @@ DEFUN_DLD (oarf_send_frame, args, nargout,"Send frame")
|
||||
{
|
||||
for (i=0;i<(76800*(1 << (2-resampling_factor[aa])));i++)
|
||||
{
|
||||
if (i<64)
|
||||
printf("%d: %d,%d\n",i,(short)real(dx(i,aa)),(short)imag(dx(i,aa)));
|
||||
//if (i<64) printf("%d: %d,%d\n",i,(short)real(dx(i,aa)),(short)imag(dx(i,aa)));
|
||||
((short*) openair0_exmimo_pci[card].dac_head[aa])[2*i] = (short)(real(dx(i,aa)));
|
||||
((short*) openair0_exmimo_pci[card].dac_head[aa])[1+(2*i)] = (short)(imag(dx(i,aa)));
|
||||
}
|
||||
@@ -127,8 +128,7 @@ DEFUN_DLD (oarf_send_frame, args, nargout,"Send frame")
|
||||
{
|
||||
for (i=0;i<(76800*(1 << (2-resampling_factor[aa])));i++)
|
||||
{
|
||||
if (i<64)
|
||||
printf("%d: %d,%d\n",i,char(real(dx(i,aa))),char(imag(dx(i,aa))));
|
||||
//if (i<64) printf("%d: %d,%d\n",i,char(real(dx(i,aa))),char(imag(dx(i,aa))));
|
||||
((char*) openair0_exmimo_pci[card].dac_head[aa])[2*i] = char(real(dx(i,aa)));
|
||||
((char*) openair0_exmimo_pci[card].dac_head[aa])[1+(2*i)] = char(imag(dx(i,aa)));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user