moving targets/ARCH to sdr/
This commit is contained in:
@@ -0,0 +1,185 @@
|
||||
/*
|
||||
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The OpenAirInterface Software Alliance licenses this file to You under
|
||||
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.openairinterface.org/?page_id=698
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*-------------------------------------------------------------------------------
|
||||
* For more information about the OpenAirInterface (OAI) Software Alliance:
|
||||
* contact@openairinterface.org
|
||||
*/
|
||||
|
||||
/*! \file common_lib.c
|
||||
* \brief common APIs for different RF frontend device
|
||||
* \author HongliangXU, Navid Nikaein
|
||||
* \date 2015
|
||||
* \version 0.2
|
||||
* \company Eurecom
|
||||
* \maintainer: navid.nikaein@eurecom.fr
|
||||
* \note
|
||||
* \warning
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <strings.h>
|
||||
#include <dlfcn.h>
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "common_lib.h"
|
||||
#include "assertions.h"
|
||||
#include "common/utils/load_module_shlib.h"
|
||||
#include "common/utils/LOG/log.h"
|
||||
//#include "targets/RT/USER/lte-softmodem.h"
|
||||
#include "executables/softmodem-common.h"
|
||||
|
||||
const char* devtype_names[MAX_RF_DEV_TYPE] = {
|
||||
"",
|
||||
"EXMIMO",
|
||||
"USRP B200",
|
||||
"USRP X300",
|
||||
"USRP N300",
|
||||
"USRP X400",
|
||||
"BLADERF",
|
||||
"LMSSDR",
|
||||
"IRIS",
|
||||
"No HW",
|
||||
"ADRV9371_ZC706",
|
||||
"UEDv2",
|
||||
"RFSIMULATOR"
|
||||
};
|
||||
|
||||
const char *get_devname(int devtype) {
|
||||
if (devtype < MAX_RF_DEV_TYPE && devtype !=MIN_RF_DEV_TYPE )
|
||||
return devtype_names[devtype];
|
||||
return "none";
|
||||
}
|
||||
|
||||
int set_device(openair0_device *device)
|
||||
{
|
||||
const char *devname = get_devname(device->type);
|
||||
if (strcmp(devname,"none") != 0) {
|
||||
LOG_I(HW,"[%s] has loaded %s device.\n",((device->host_type == RAU_HOST) ? "RAU": "RRU"),devname);
|
||||
} else {
|
||||
LOG_E(HW,"[%s] invalid HW device.\n",((device->host_type == RAU_HOST) ? "RAU": "RRU"));
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int set_transport(openair0_device *device)
|
||||
{
|
||||
switch (device->transp_type) {
|
||||
case ETHERNET_TP:
|
||||
LOG_I(HW,"[%s] has loaded ETHERNET trasport protocol.\n",((device->host_type == RAU_HOST) ? "RAU": "RRU"));
|
||||
return 0;
|
||||
break;
|
||||
|
||||
case NONE_TP:
|
||||
LOG_I(HW,"[%s] has not loaded a transport protocol.\n",((device->host_type == RAU_HOST) ? "RAU": "RRU"));
|
||||
return 0;
|
||||
break;
|
||||
|
||||
default:
|
||||
LOG_E(HW,"[%s] invalid transport protocol.\n",((device->host_type == RAU_HOST) ? "RAU": "RRU"));
|
||||
return -1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
typedef int(*devfunc_t)(openair0_device *, openair0_config_t *, eth_params_t *);
|
||||
|
||||
|
||||
/* look for the interface library and load it */
|
||||
int load_lib(openair0_device *device,
|
||||
openair0_config_t *openair0_cfg,
|
||||
eth_params_t *cfg,
|
||||
uint8_t flag)
|
||||
{
|
||||
loader_shlibfunc_t shlib_fdesc[1];
|
||||
int ret=0;
|
||||
char *deflibname=OAI_RF_LIBNAME;
|
||||
|
||||
openair0_cfg->recplay_mode = read_recplayconfig(&(openair0_cfg->recplay_conf),&(device->recplay_state));
|
||||
|
||||
if ( openair0_cfg->recplay_mode == RECPLAY_REPLAYMODE ) {
|
||||
deflibname=OAI_IQPLAYER_LIBNAME;
|
||||
shlib_fdesc[0].fname="device_init";
|
||||
set_softmodem_optmask(SOFTMODEM_RECPLAY_BIT); // softmodem has to know we use the iqplayer to workaround randomized algorithms
|
||||
} else if (IS_SOFTMODEM_RFSIM && flag == RAU_LOCAL_RADIO_HEAD) {
|
||||
deflibname=OAI_RFSIM_LIBNAME;
|
||||
shlib_fdesc[0].fname="device_init";
|
||||
} else if (flag == RAU_LOCAL_RADIO_HEAD) {
|
||||
if (IS_SOFTMODEM_RFSIM)
|
||||
deflibname="rfsimulator";
|
||||
else
|
||||
deflibname=OAI_RF_LIBNAME;
|
||||
shlib_fdesc[0].fname="device_init";
|
||||
} else if (flag == RAU_REMOTE_THIRDPARTY_RADIO_HEAD) {
|
||||
deflibname=OAI_THIRDPARTY_TP_LIBNAME;
|
||||
shlib_fdesc[0].fname="transport_init";
|
||||
} else {
|
||||
deflibname=OAI_TP_LIBNAME;
|
||||
shlib_fdesc[0].fname="transport_init";
|
||||
}
|
||||
|
||||
char *devname=NULL;
|
||||
paramdef_t device_params[]=DEVICE_PARAMS_DESC ;
|
||||
int numparams = sizeof(device_params)/sizeof(paramdef_t);
|
||||
int devname_pidx = config_paramidx_fromname(device_params,numparams, CONFIG_DEVICEOPT_NAME);
|
||||
device_params[devname_pidx].defstrval=deflibname;
|
||||
|
||||
config_get(device_params,numparams,DEVICE_SECTION);
|
||||
|
||||
ret=load_module_shlib(devname,shlib_fdesc,1,NULL);
|
||||
AssertFatal( (ret >= 0),
|
||||
"Library %s couldn't be loaded\n",devname);
|
||||
|
||||
return ((devfunc_t)shlib_fdesc[0].fptr)(device,openair0_cfg,cfg);
|
||||
}
|
||||
|
||||
|
||||
int openair0_device_load(openair0_device *device,
|
||||
openair0_config_t *openair0_cfg)
|
||||
{
|
||||
int rc=0;
|
||||
rc=load_lib(device, openair0_cfg, NULL,RAU_LOCAL_RADIO_HEAD );
|
||||
|
||||
if ( rc >= 0) {
|
||||
if ( set_device(device) < 0) {
|
||||
LOG_E(HW, "%s %d:Unsupported radio head\n", __FILE__, __LINE__);
|
||||
return -1;
|
||||
}
|
||||
} else
|
||||
AssertFatal(false, "can't open the radio device: %s\n", get_devname(device->type));
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
||||
int openair0_transport_load(openair0_device *device,
|
||||
openair0_config_t *openair0_cfg,
|
||||
eth_params_t *eth_params)
|
||||
{
|
||||
int rc;
|
||||
rc=load_lib(device, openair0_cfg, eth_params, RAU_REMOTE_RADIO_HEAD);
|
||||
|
||||
if ( rc >= 0) {
|
||||
if ( set_transport(device) < 0) {
|
||||
LOG_E(HW, "%s %d:Unsupported transport protocol\n", __FILE__, __LINE__);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
return rc;
|
||||
}
|
||||
@@ -0,0 +1,637 @@
|
||||
/*
|
||||
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The OpenAirInterface Software Alliance licenses this file to You under
|
||||
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.openairinterface.org/?page_id=698
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*-------------------------------------------------------------------------------
|
||||
* For more information about the OpenAirInterface (OAI) Software Alliance:
|
||||
* contact@openairinterface.org
|
||||
*/
|
||||
|
||||
/*! \file common_lib.h
|
||||
* \brief common APIs for different RF frontend device
|
||||
* \author HongliangXU, Navid Nikaein
|
||||
* \date 2015
|
||||
* \version 0.2
|
||||
* \company Eurecom
|
||||
* \maintainer: navid.nikaein@eurecom.fr
|
||||
* \note
|
||||
* \warning
|
||||
*/
|
||||
|
||||
#ifndef COMMON_LIB_H
|
||||
#define COMMON_LIB_H
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <sys/types.h>
|
||||
#include <openair1/PHY/TOOLS/tools_defs.h>
|
||||
#include "record_player.h"
|
||||
#include <common/utils/threadPool/thread-pool.h>
|
||||
|
||||
/* default name of shared library implementing the radio front end */
|
||||
#define OAI_RF_LIBNAME "oai_device"
|
||||
/* name of shared library implementing the transport */
|
||||
#define OAI_TP_LIBNAME "oai_transpro"
|
||||
/* name of shared library implementing a third-party transport */
|
||||
#define OAI_THIRDPARTY_TP_LIBNAME "thirdparty_transpro"
|
||||
/* name of shared library implementing the rf simulator */
|
||||
#define OAI_RFSIM_LIBNAME "rfsimulator"
|
||||
/* name of shared library implementing the iq player */
|
||||
#define OAI_IQPLAYER_LIBNAME "oai_iqplayer"
|
||||
|
||||
/* flags for BBU to determine whether the attached radio head is local or remote */
|
||||
#define RAU_LOCAL_RADIO_HEAD 0
|
||||
#define RAU_REMOTE_RADIO_HEAD 1
|
||||
#define RAU_REMOTE_THIRDPARTY_RADIO_HEAD 2
|
||||
#define MAX_WRITE_THREAD_PACKAGE 10
|
||||
#define MAX_WRITE_THREAD_BUFFER_SIZE 8
|
||||
#define MAX_CARDS 8
|
||||
|
||||
typedef int64_t openair0_timestamp;
|
||||
typedef volatile int64_t openair0_vtimestamp;
|
||||
|
||||
|
||||
/*!\brief structure holds the parameters to configure USRP devices*/
|
||||
typedef struct openair0_device_t openair0_device;
|
||||
|
||||
//#define USRP_GAIN_OFFSET (56.0) // 86 calibrated for USRP B210 @ 2.6 GHz to get equivalent RS EPRE in OAI to SMBV100 output
|
||||
|
||||
typedef enum {
|
||||
max_gain=0,med_gain,byp_gain
|
||||
} rx_gain_t;
|
||||
|
||||
typedef enum {
|
||||
duplex_mode_TDD=1,duplex_mode_FDD=0
|
||||
} duplex_mode_t;
|
||||
|
||||
|
||||
/** @addtogroup _GENERIC_PHY_RF_INTERFACE_
|
||||
* @{
|
||||
*/
|
||||
/*!\brief RF device types
|
||||
*/
|
||||
typedef enum {
|
||||
MIN_RF_DEV_TYPE = 0,
|
||||
/*!\brief device is ExpressMIMO */
|
||||
EXMIMO_DEV,
|
||||
/*!\brief device is USRP B200/B210*/
|
||||
USRP_B200_DEV,
|
||||
/*!\brief device is USRP X300/X310*/
|
||||
USRP_X300_DEV,
|
||||
/*!\brief device is USRP N300/N310*/
|
||||
USRP_N300_DEV,
|
||||
/*!\brief device is USRP X400/X410*/
|
||||
USRP_X400_DEV,
|
||||
/*!\brief device is BLADE RF*/
|
||||
BLADERF_DEV,
|
||||
/*!\brief device is LMSSDR (SoDeRa)*/
|
||||
LMSSDR_DEV,
|
||||
/*!\brief device is Iris */
|
||||
IRIS_DEV,
|
||||
/*!\brief device is NONE*/
|
||||
NONE_DEV,
|
||||
/*!\brief device is ADRV9371_ZC706 */
|
||||
ADRV9371_ZC706_DEV,
|
||||
/*!\brief device is UEDv2 */
|
||||
UEDv2_DEV,
|
||||
RFSIMULATOR,
|
||||
MAX_RF_DEV_TYPE
|
||||
} dev_type_t;
|
||||
/* list of names of devices, needs to match dev_type_t */
|
||||
extern const char* devtype_names[MAX_RF_DEV_TYPE];
|
||||
|
||||
/*!\brief transport protocol types
|
||||
*/
|
||||
typedef enum {
|
||||
MIN_TRANSP_TYPE = 0,
|
||||
/*!\brief transport protocol ETHERNET */
|
||||
ETHERNET_TP,
|
||||
/*!\brief no transport protocol*/
|
||||
NONE_TP,
|
||||
MAX_TRANSP_TYPE
|
||||
} transport_type_t;
|
||||
|
||||
|
||||
/*!\brief openair0 device host type */
|
||||
typedef enum {
|
||||
MIN_HOST_TYPE = 0,
|
||||
/*!\brief device functions within a RAU */
|
||||
RAU_HOST,
|
||||
/*!\brief device functions within a RRU */
|
||||
RRU_HOST,
|
||||
MAX_HOST_TYPE
|
||||
} host_type_t;
|
||||
|
||||
|
||||
/*! \brief RF Gain clibration */
|
||||
typedef struct {
|
||||
//! Frequency for which RX chain was calibrated
|
||||
double freq;
|
||||
//! Offset to be applied to RX gain
|
||||
double offset;
|
||||
} rx_gain_calib_table_t;
|
||||
|
||||
/*! \brief Clock source types */
|
||||
typedef enum {
|
||||
//! this means the paramter has not been set
|
||||
unset=-1,
|
||||
//! This tells the underlying hardware to use the internal reference
|
||||
internal=0,
|
||||
//! This tells the underlying hardware to use the external reference
|
||||
external=1,
|
||||
//! This tells the underlying hardware to use the gpsdo reference
|
||||
gpsdo=2
|
||||
} clock_source_t;
|
||||
|
||||
/*! \brief Structure used for initializing UDP read threads */
|
||||
typedef struct {
|
||||
openair0_device *device;
|
||||
int thread_id;
|
||||
pthread_t pthread;
|
||||
notifiedFIFO_t *resp;
|
||||
} udp_ctx_t;
|
||||
|
||||
|
||||
/*! \brief RF frontend parameters set by application */
|
||||
typedef struct {
|
||||
//! Module ID for this configuration
|
||||
int Mod_id;
|
||||
//! device log level
|
||||
int log_level;
|
||||
//! duplexing mode
|
||||
duplex_mode_t duplex_mode;
|
||||
//! number of downlink resource blocks
|
||||
int num_rb_dl;
|
||||
//! number of samples per frame
|
||||
unsigned int samples_per_frame;
|
||||
//! the sample rate for both transmit and receive.
|
||||
double sample_rate;
|
||||
//! flag to indicate that the device is doing mmapped DMA transfers
|
||||
int mmapped_dma;
|
||||
//! offset in samples between TX and RX paths
|
||||
int tx_sample_advance;
|
||||
//! samples per packet on the fronthaul interface
|
||||
int samples_per_packet;
|
||||
//! number of RX channels (=RX antennas)
|
||||
int rx_num_channels;
|
||||
//! number of TX channels (=TX antennas)
|
||||
int tx_num_channels;
|
||||
//! \brief RX base addresses for mmapped_dma or direct access
|
||||
int32_t *rxbase[4];
|
||||
//! \brief RX buffer size for direct access
|
||||
int rxsize;
|
||||
//! \brief TX base addresses for mmapped_dma or direct access
|
||||
int32_t *txbase[4];
|
||||
//! \brief Center frequency in Hz for RX.
|
||||
//! index: [0..rx_num_channels[
|
||||
double rx_freq[4];
|
||||
//! \brief Center frequency in Hz for TX.
|
||||
//! index: [0..rx_num_channels[ !!! see lte-ue.c:427 FIXME iterates over rx_num_channels
|
||||
double tx_freq[4];
|
||||
double tune_offset;
|
||||
//! \brief memory
|
||||
//! \brief Pointer to Calibration table for RX gains
|
||||
rx_gain_calib_table_t *rx_gain_calib_table;
|
||||
//! mode for rxgain (ExpressMIMO2)
|
||||
rx_gain_t rxg_mode[4];
|
||||
//! \brief Gain for RX in dB.
|
||||
//! index: [0..rx_num_channels]
|
||||
double rx_gain[4];
|
||||
//! \brief Gain offset (for calibration) in dB
|
||||
//! index: [0..rx_num_channels]
|
||||
double rx_gain_offset[4];
|
||||
//! gain for TX in dB
|
||||
double tx_gain[4];
|
||||
//! RX bandwidth in Hz
|
||||
double rx_bw;
|
||||
//! TX bandwidth in Hz
|
||||
double tx_bw;
|
||||
//! clock source
|
||||
clock_source_t clock_source;
|
||||
//! timing_source
|
||||
clock_source_t time_source;
|
||||
//! Manual SDR IP address
|
||||
//#if defined(EXMIMO) || defined(OAI_USRP) || defined(OAI_BLADERF) || defined(OAI_LMSSDR)
|
||||
char *sdr_addrs;
|
||||
//! Auto calibration flag
|
||||
int autocal[4];
|
||||
//! rf devices work with x bits iqs when oai have its own iq format
|
||||
//! the two following parameters are used to convert iqs
|
||||
int iq_txshift;
|
||||
int iq_rxrescale;
|
||||
//! Configuration file for LMS7002M
|
||||
char *configFilename;
|
||||
//! remote IP/MAC addr for Ethernet interface
|
||||
char *remote_addr;
|
||||
//! remote port number for Ethernet interface
|
||||
unsigned int remote_port;
|
||||
//! local IP/MAC addr for Ethernet interface (eNB/BBU, UE)
|
||||
char *my_addr;
|
||||
//! local port number for Ethernet interface (eNB/BBU, UE)
|
||||
unsigned int my_port;
|
||||
//! record player configuration, definition in record_player.h
|
||||
uint32_t recplay_mode;
|
||||
recplay_conf_t *recplay_conf;
|
||||
//! number of samples per tti
|
||||
unsigned int samples_per_tti;
|
||||
//! the sample rate for receive.
|
||||
double rx_sample_rate;
|
||||
//! the sample rate for transmit.
|
||||
double tx_sample_rate;
|
||||
//! check for threequarter sampling rate
|
||||
int8_t threequarter_fs;
|
||||
//! Flag to indicate this configuration is for NR
|
||||
int nr_flag;
|
||||
//! NR band number
|
||||
int nr_band;
|
||||
//! NR scs for raster
|
||||
int nr_scs_for_raster;
|
||||
//! Core IDs for RX FH
|
||||
int rxfh_cores[4];
|
||||
//! Core IDs for TX FH
|
||||
int txfh_cores[4];
|
||||
} openair0_config_t;
|
||||
|
||||
/*! \brief RF mapping */
|
||||
typedef struct {
|
||||
//! card id
|
||||
int card;
|
||||
//! rf chain id
|
||||
int chain;
|
||||
} openair0_rf_map;
|
||||
|
||||
|
||||
typedef struct {
|
||||
char *remote_addr;
|
||||
//! remote port number for Ethernet interface (control)
|
||||
uint16_t remote_portc;
|
||||
//! remote port number for Ethernet interface (user)
|
||||
uint16_t remote_portd;
|
||||
//! local IP/MAC addr for Ethernet interface (eNB/RAU, UE)
|
||||
char *my_addr;
|
||||
//! local port number (control) for Ethernet interface (eNB/RAU, UE)
|
||||
uint16_t my_portc;
|
||||
//! local port number (user) for Ethernet interface (eNB/RAU, UE)
|
||||
uint16_t my_portd;
|
||||
//! local Ethernet interface (eNB/RAU, UE)
|
||||
char *local_if_name;
|
||||
//! transport type preference (RAW/UDP)
|
||||
uint8_t transp_preference;
|
||||
//! compression enable (0: No comp/ 1: A-LAW)
|
||||
uint8_t if_compress;
|
||||
} eth_params_t;
|
||||
|
||||
typedef struct {
|
||||
//! Tx buffer for if device, keep one per subframe now to allow multithreading
|
||||
void *tx[10];
|
||||
//! Tx buffer (PRACH) for if device
|
||||
void *tx_prach;
|
||||
//! Rx buffer for if device
|
||||
void *rx;
|
||||
} if_buffer_t;
|
||||
|
||||
typedef struct {
|
||||
openair0_timestamp timestamp;
|
||||
void *buff[MAX_WRITE_THREAD_BUFFER_SIZE];// buffer to be write;
|
||||
int nsamps;
|
||||
int cc;
|
||||
signed char first_packet;
|
||||
signed char last_packet;
|
||||
int flags_msb;
|
||||
} openair0_write_package_t;
|
||||
|
||||
typedef struct {
|
||||
openair0_write_package_t write_package[MAX_WRITE_THREAD_PACKAGE];
|
||||
int start;
|
||||
int end;
|
||||
/// \internal This variable is protected by \ref mutex_write
|
||||
int count_write;
|
||||
/// pthread struct for trx write thread
|
||||
pthread_t pthread_write;
|
||||
/// pthread attributes for trx write thread
|
||||
pthread_attr_t attr_write;
|
||||
/// condition varible for trx write thread
|
||||
pthread_cond_t cond_write;
|
||||
/// mutex for trx write thread
|
||||
pthread_mutex_t mutex_write;
|
||||
/// to inform the thread to exit
|
||||
bool write_thread_exit;
|
||||
} openair0_thread_t;
|
||||
|
||||
typedef struct fhstate_s {
|
||||
openair0_timestamp TS[8];
|
||||
openair0_timestamp TS0;
|
||||
openair0_timestamp olddeltaTS[8];
|
||||
openair0_timestamp oldTS[8];
|
||||
openair0_timestamp TS_read;
|
||||
int first_read;
|
||||
uint32_t *buff[8];
|
||||
uint32_t buff_size;
|
||||
int r[8];
|
||||
int active;
|
||||
} fhstate_t;
|
||||
|
||||
/*!\brief structure holds the parameters to configure USRP devices */
|
||||
struct openair0_device_t {
|
||||
/*!tx write thread*/
|
||||
openair0_thread_t write_thread;
|
||||
|
||||
/*!brief Module ID of this device */
|
||||
int Mod_id;
|
||||
|
||||
/*!brief Component Carrier ID of this device */
|
||||
int CC_id;
|
||||
|
||||
/*!brief Type of this device */
|
||||
dev_type_t type;
|
||||
|
||||
/*!brief Transport protocol type that the device supports (in case I/Q samples need to be transported) */
|
||||
transport_type_t transp_type;
|
||||
|
||||
/*!brief Type of the device's host (RAU/RRU) */
|
||||
host_type_t host_type;
|
||||
|
||||
/* !brief RF frontend parameters set by application */
|
||||
openair0_config_t *openair0_cfg;
|
||||
|
||||
/* !brief ETH params set by application */
|
||||
eth_params_t *eth_params;
|
||||
//! record player data, definition in record_player.h
|
||||
recplay_state_t *recplay_state;
|
||||
/* !brief Indicates if device already initialized */
|
||||
int is_init;
|
||||
|
||||
|
||||
/*!brief Can be used by driver to hold internal structure*/
|
||||
void *priv;
|
||||
|
||||
/*!brief pointer to FH state, used in ECPRI split 8*/
|
||||
fhstate_t fhstate;
|
||||
|
||||
/*!brief message response for notification fifo*/
|
||||
notifiedFIFO_t *respudpTX;
|
||||
|
||||
/*!brief UDP TX thread context*/
|
||||
udp_ctx_t **utx;
|
||||
|
||||
/*!brief Used in ECPRI split 8 to indicate numerator of sampling rate ratio*/
|
||||
int sampling_rate_ratio_n;
|
||||
|
||||
/*!brief Used in ECPRI split 8 to indicate denominator of sampling rate ratio*/
|
||||
int sampling_rate_ratio_d;
|
||||
|
||||
/*!brief Used in ECPRI split 8 to indicate the TX/RX timing offset*/
|
||||
int txrx_offset;
|
||||
|
||||
/* Functions API, which are called by the application*/
|
||||
|
||||
/*! \brief Called to start the transceiver. Return 0 if OK, < 0 if error
|
||||
@param device pointer to the device structure specific to the RF hardware target
|
||||
*/
|
||||
int (*trx_start_func)(openair0_device *device);
|
||||
|
||||
/*! \brief Called to configure the device
|
||||
@param device pointer to the device structure specific to the RF hardware target
|
||||
*/
|
||||
|
||||
|
||||
int (*trx_config_func)(openair0_device* device, openair0_config_t *openair0_cfg);
|
||||
|
||||
/*! \brief Called to send a request message between RAU-RRU on control port
|
||||
@param device pointer to the device structure specific to the RF hardware target
|
||||
@param msg pointer to the message structure passed between RAU-RRU
|
||||
@param msg_len length of the message
|
||||
*/
|
||||
int (*trx_ctlsend_func)(openair0_device *device, void *msg, ssize_t msg_len);
|
||||
|
||||
/*! \brief Called to receive a reply message between RAU-RRU on control port
|
||||
@param device pointer to the device structure specific to the RF hardware target
|
||||
@param msg pointer to the message structure passed between RAU-RRU
|
||||
@param msg_len length of the message
|
||||
*/
|
||||
int (*trx_ctlrecv_func)(openair0_device *device, void *msg, ssize_t msg_len);
|
||||
|
||||
/*! \brief Called to send samples to the RF target
|
||||
@param device pointer to the device structure specific to the RF hardware target
|
||||
@param timestamp The timestamp at whicch the first sample MUST be sent
|
||||
@param buff Buffer which holds the samples (2 dimensional)
|
||||
@param nsamps number of samples to be sent
|
||||
@param number of antennas
|
||||
@param flags flags must be set to true if timestamp parameter needs to be applied
|
||||
*/
|
||||
int (*trx_write_func)(openair0_device *device, openair0_timestamp timestamp, void **buff, int nsamps,int antenna_id, int flags);
|
||||
|
||||
/*! \brief Called to send samples to the RF target
|
||||
@param device pointer to the device structure specific to the RF hardware target
|
||||
@param timestamp The timestamp at whicch the first sample MUST be sent
|
||||
@param buff Buffer which holds the samples (1 dimensional)
|
||||
@param nsamps number of samples to be sent
|
||||
@param antenna_id index of the antenna if the device has multiple anteannas
|
||||
@param flags flags must be set to true if timestamp parameter needs to be applied
|
||||
*/
|
||||
int (*trx_write_func2)(openair0_device *device, openair0_timestamp timestamp, void **buff, int fd_ind,int nsamps, int flags,int nant);
|
||||
|
||||
/*! \brief Receive samples from hardware.
|
||||
* Read \ref nsamps samples from each channel to buffers. buff[0] is the array for
|
||||
* the first channel. *ptimestamp is the time at which the first sample
|
||||
* was received.
|
||||
* \param device the hardware to use
|
||||
* \param[out] ptimestamp the time at which the first sample was received.
|
||||
* \param[out] buff An array of pointers to buffers for received samples. The buffers must be large enough to hold the number of samples \ref nsamps.
|
||||
* \param nsamps Number of samples. One sample is 2 byte I + 2 byte Q => 4 byte.
|
||||
* \param num_antennas number of antennas from which to receive samples
|
||||
* \returns the number of sample read
|
||||
*/
|
||||
|
||||
int (*trx_read_func)(openair0_device *device, openair0_timestamp *ptimestamp, void **buff, int nsamps,int num_antennas);
|
||||
|
||||
/*! \brief Receive samples from hardware, this version provides a single antenna at a time and returns.
|
||||
* Read \ref nsamps samples from each channel to buffers. buff[0] is the array for
|
||||
* the first channel. *ptimestamp is the time at which the first sample
|
||||
* was received.
|
||||
* \param device the hardware to use
|
||||
* \param[out] ptimestamp the time at which the first sample was received.
|
||||
* \param[out] buff A pointer to a buffer[ant_id][] for received samples. The buffer[ant_id] must be large enough to hold the number of samples \ref nsamps * the number of packets.
|
||||
* \param nsamps Number of samples. One sample is 2 byte I + 2 byte Q => 4 byte.
|
||||
* \param packet_idx offset into
|
||||
* \param antenna_id Index of antenna from which samples were received
|
||||
* \returns the number of sample read
|
||||
*/
|
||||
int (*trx_read_func2)(openair0_device *device, openair0_timestamp *ptimestamp, uint32_t **buff, int nsamps);
|
||||
|
||||
/*! \brief print the device statistics
|
||||
* \param device the hardware to use
|
||||
* \returns 0 on success
|
||||
*/
|
||||
int (*trx_get_stats_func)(openair0_device *device);
|
||||
|
||||
/*! \brief Reset device statistics
|
||||
* \param device the hardware to use
|
||||
* \returns 0 in success
|
||||
*/
|
||||
int (*trx_reset_stats_func)(openair0_device *device);
|
||||
|
||||
/*! \brief Terminate operation of the transceiver -- free all associated resources
|
||||
* \param device the hardware to use
|
||||
*/
|
||||
void (*trx_end_func)(openair0_device *device);
|
||||
|
||||
/*! \brief Stop operation of the transceiver
|
||||
*/
|
||||
int (*trx_stop_func)(openair0_device *device);
|
||||
|
||||
/* Functions API related to UE*/
|
||||
|
||||
/*! \brief Set RX feaquencies
|
||||
* \param device the hardware to use
|
||||
* \param openair0_cfg RF frontend parameters set by application
|
||||
* \param exmimo_dump_config dump EXMIMO configuration
|
||||
* \returns 0 in success
|
||||
*/
|
||||
int (*trx_set_freq_func)(openair0_device *device, openair0_config_t *openair0_cfg,int exmimo_dump_config);
|
||||
|
||||
/*! \brief Set gains
|
||||
* \param device the hardware to use
|
||||
* \param openair0_cfg RF frontend parameters set by application
|
||||
* \returns 0 in success
|
||||
*/
|
||||
int (*trx_set_gains_func)(openair0_device *device, openair0_config_t *openair0_cfg);
|
||||
|
||||
/*! \brief RRU Configuration callback
|
||||
* \param idx RU index
|
||||
* \param arg pointer to capabilities or configuration
|
||||
*/
|
||||
void (*configure_rru)(int idx, void *arg);
|
||||
|
||||
/*! \brief Pointer to generic RRU private information
|
||||
*/
|
||||
|
||||
|
||||
void *thirdparty_priv;
|
||||
|
||||
/*! \brief Callback for Third-party RRU Initialization routine
|
||||
\param device the hardware configuration to use
|
||||
*/
|
||||
int (*thirdparty_init)(openair0_device *device);
|
||||
/*! \brief Callback for Third-party RRU Cleanup routine
|
||||
\param device the hardware configuration to use
|
||||
*/
|
||||
int (*thirdparty_cleanup)(openair0_device *device);
|
||||
|
||||
/*! \brief Callback for Third-party start streaming routine
|
||||
\param device the hardware configuration to use
|
||||
*/
|
||||
int (*thirdparty_startstreaming)(openair0_device *device);
|
||||
|
||||
/*! \brief RRU Configuration callback
|
||||
* \param idx RU index
|
||||
* \param arg pointer to capabilities or configuration
|
||||
*/
|
||||
int (*trx_write_init)(openair0_device *device);
|
||||
/* \brief Get internal parameter
|
||||
* \param id parameter to get
|
||||
* \return a pointer to the parameter
|
||||
*/
|
||||
void *(*get_internal_parameter)(char *id);
|
||||
/* \brief timing statistics for TX fronthaul (ethernet)
|
||||
*/
|
||||
time_stats_t tx_fhaul;
|
||||
};
|
||||
|
||||
/* type of device init function, implemented in shared lib */
|
||||
typedef int(*oai_device_initfunc_t)(openair0_device *device, openair0_config_t *openair0_cfg);
|
||||
/* type of transport init function, implemented in shared lib */
|
||||
typedef int(*oai_transport_initfunc_t)(openair0_device *device, openair0_config_t *openair0_cfg, eth_params_t *eth_params);
|
||||
#define UE_MAGICDL 0xA5A5A5A5A5A5A5A5 // UE DL FDD record
|
||||
#define UE_MAGICUL 0x5A5A5A5A5A5A5A5A // UE UL FDD record
|
||||
|
||||
#define ENB_MAGICDL 0xB5B5B5B5B5B5B5B5 // eNB DL FDD record
|
||||
#define ENB_MAGICUL 0x5B5B5B5B5B5B5B5B // eNB UL FDD record
|
||||
|
||||
#define OPTION_LZ4 0x00000001 // LZ4 compression (option_value is set to compressed size)
|
||||
|
||||
|
||||
typedef struct {
|
||||
uint64_t magic; // Magic value (see defines above)
|
||||
uint32_t size; // Number of samples per antenna to follow this header
|
||||
uint32_t nbAnt; // Total number of antennas following this header
|
||||
// Samples per antenna follow this header,
|
||||
// i.e. nbAnt = 2 => this header+samples_antenna_0+samples_antenna_1
|
||||
// data following this header in bytes is nbAnt*size*sizeof(sample_t)
|
||||
uint64_t timestamp; // Timestamp value of first sample
|
||||
uint32_t option_value; // Option value
|
||||
uint32_t option_flag; // Option flag
|
||||
} samplesBlockHeader_t;
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
|
||||
#define DEVICE_SECTION "device"
|
||||
#define CONFIG_HLP_DEVICE "Identifies the oai device (the interface to RF) to use, the shared lib \"lib_<name>.so\" will be loaded"
|
||||
|
||||
#define CONFIG_DEVICEOPT_NAME "name"
|
||||
|
||||
/* inclusion for device configuration */
|
||||
/*---------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/
|
||||
/* config parameters for oai device */
|
||||
/* optname helpstr paramflags XXXptr defXXXval type numelt */
|
||||
/*---------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/
|
||||
#define DEVICE_PARAMS_DESC {\
|
||||
{ CONFIG_DEVICEOPT_NAME, CONFIG_HLP_DEVICE, 0, strptr:&devname, defstrval:NULL, TYPE_STRING, 0}\
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*! \brief get device name from device type */
|
||||
const char *get_devname(int devtype);
|
||||
/*! \brief Initialize openair RF target. It returns 0 if OK */
|
||||
int openair0_device_load(openair0_device *device, openair0_config_t *openair0_cfg);
|
||||
/*! \brief Initialize transport protocol . It returns 0 if OK */
|
||||
int openair0_transport_load(openair0_device *device, openair0_config_t *openair0_cfg, eth_params_t *eth_params);
|
||||
|
||||
|
||||
/*! \brief Get current timestamp of USRP
|
||||
* \param device the hardware to use
|
||||
*/
|
||||
openair0_timestamp get_usrp_time(openair0_device *device);
|
||||
|
||||
/*! \brief Set RX frequencies
|
||||
* \param device the hardware to use
|
||||
* \param openair0_cfg RF frontend parameters set by application
|
||||
* \returns 0 in success
|
||||
*/
|
||||
int openair0_set_rx_frequencies(openair0_device *device, openair0_config_t *openair0_cfg);
|
||||
/*! \brief read the iq record/player configuration */
|
||||
extern int read_recplayconfig(recplay_conf_t **recplay_conf, recplay_state_t **recplay_state);
|
||||
/*! \brief store recorded iqs from memory to file. */
|
||||
extern void iqrecorder_end(openair0_device *device);
|
||||
|
||||
|
||||
#include <unistd.h>
|
||||
#ifndef gettid
|
||||
#define gettid() syscall(__NR_gettid)
|
||||
#endif
|
||||
/*@}*/
|
||||
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // COMMON_LIB_H
|
||||
|
||||
@@ -0,0 +1,120 @@
|
||||
/*
|
||||
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The OpenAirInterface Software Alliance licenses this file to You under
|
||||
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.openairinterface.org/?page_id=698
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*-------------------------------------------------------------------------------
|
||||
* For more information about the OpenAirInterface (OAI) Software Alliance:
|
||||
* contact@openairinterface.org
|
||||
*/
|
||||
|
||||
/** record_player.c
|
||||
*
|
||||
* \author: Nokia bellLabs B. Mongazon F. Taburet
|
||||
*
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <stdio.h>
|
||||
#include <sys/sysinfo.h>
|
||||
#include <sys/resource.h>
|
||||
#include "common/utils/LOG/log.h"
|
||||
#include "assertions.h"
|
||||
#include "common_lib.h"
|
||||
#include "record_player.h"
|
||||
|
||||
/*! \brief read the oai recorder or player configuration, called from common device code
|
||||
* \param recplay_conf: store parameters
|
||||
* recplay_state: store recorder or player data while the device runs
|
||||
*/
|
||||
int read_recplayconfig(recplay_conf_t **recplay_conf, recplay_state_t **recplay_state) {
|
||||
unsigned int u_sf_record = 0; // record mode
|
||||
unsigned int u_sf_replay = 0; // replay mode
|
||||
*recplay_conf = calloc(sizeof(recplay_conf_t),1);
|
||||
paramdef_t device_recplay_params[]=DEVICE_RECPLAY_PARAMS_DESC ;
|
||||
config_get(device_recplay_params,sizeof(device_recplay_params)/sizeof(paramdef_t),DEVICE_RECPLAY_SECTION);
|
||||
|
||||
if (u_sf_record || u_sf_replay ) {
|
||||
struct sysinfo systeminfo;
|
||||
*recplay_state = calloc(sizeof(recplay_state_t),1);
|
||||
|
||||
if ( *recplay_state == NULL) {
|
||||
LOG_E(HW,"calloc error in %s\n", __FILE__);
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Use mmap for IQ files for systems with less than 6GB total RAM
|
||||
sysinfo(&systeminfo);
|
||||
|
||||
if (systeminfo.totalram < 6144000000 && ((*recplay_conf)->use_mmap == 1)) {
|
||||
LOG_W(HW,"System with %f GB of mem (<6GB), mmap usage disabled\n",systeminfo.totalram/10E9);
|
||||
(*recplay_conf)->use_mmap = 0;
|
||||
}
|
||||
} else { /* record player enabled */
|
||||
free(*recplay_conf);
|
||||
*recplay_conf=NULL;
|
||||
}
|
||||
|
||||
if (u_sf_replay == 1)
|
||||
return RECPLAY_REPLAYMODE;
|
||||
else if (u_sf_record == 1)
|
||||
return RECPLAY_RECORDMODE;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*! \brief Terminate operation of the oai iq recorder. to be called by any device
|
||||
* used in record mode
|
||||
* \param device, the hardware used
|
||||
*/
|
||||
void iqrecorder_end(openair0_device *device) {
|
||||
if (device->recplay_state != NULL) { // subframes store
|
||||
iqfile_header_t fh = {device->type,device->openair0_cfg->tx_sample_advance, device->openair0_cfg->rx_bw,0,OAIIQFILE_ID};
|
||||
recplay_state_t *rs = device->recplay_state;
|
||||
recplay_conf_t *rc = device->openair0_cfg[0].recplay_conf;
|
||||
rs->pFile = fopen (rc->u_sf_filename,"wb+");
|
||||
|
||||
if (rs->pFile == NULL) {
|
||||
LOG_E(HW,"Cannot open %s\n", rc->u_sf_filename);
|
||||
} else {
|
||||
unsigned int i = 0;
|
||||
unsigned int modu = 0;
|
||||
|
||||
if ((modu = rs->nbSamplesBlocks % 10) != 0) {
|
||||
rs->nbSamplesBlocks -= modu; // store entire number of frames
|
||||
}
|
||||
|
||||
fh.nbSamplesBlocks=rs->nbSamplesBlocks;
|
||||
LOG_I(HW,"Writing file header to %s \n", rc->u_sf_filename );
|
||||
fwrite(&fh, sizeof(fh), 1, rs->pFile);
|
||||
LOG_UI(HW,"Writing %u subframes to %s \n",rs->nbSamplesBlocks, rc->u_sf_filename );
|
||||
uint8_t *ptr=(uint8_t *)rs->ms_sample;
|
||||
|
||||
for (i = 0; i < rs->nbSamplesBlocks; i++) {
|
||||
int blockBytes=sizeof(iqrec_t)+((iqrec_t *)ptr)->nbBytes;
|
||||
fwrite(ptr, sizeof(unsigned char), blockBytes, rs->pFile);
|
||||
ptr+=blockBytes;
|
||||
}
|
||||
|
||||
fclose (rs->pFile);
|
||||
LOG_UI(HW,"File %s closed\n",rc->u_sf_filename );
|
||||
}
|
||||
|
||||
if (rs->ms_sample != NULL) {
|
||||
free((void *)rs->ms_sample);
|
||||
rs->ms_sample = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,133 @@
|
||||
#ifndef __RECORD_PLAYER_H
|
||||
#define __RECORD_PLAYER_H
|
||||
/*
|
||||
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The OpenAirInterface Software Alliance licenses this file to You under
|
||||
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.openairinterface.org/?page_id=698
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*-------------------------------------------------------------------------------
|
||||
* For more information about the OpenAirInterface (OAI) Software Alliance:
|
||||
* contact@openairinterface.org
|
||||
*/
|
||||
|
||||
/** sdr/COMMON/record-player.h
|
||||
*
|
||||
* \author: bruno.mongazon-cazavet@nokia-bell-labs.com
|
||||
*/
|
||||
|
||||
#include <sys/mman.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
#include "common/config/config_paramdesc.h"
|
||||
#include "common/config/config_userapi.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
/* inclusions for record player */
|
||||
#define RECPLAY_DISABLED 0
|
||||
#define RECPLAY_RECORDMODE 1
|
||||
#define RECPLAY_REPLAYMODE 2
|
||||
|
||||
#define BELL_LABS_IQ_HEADER 0xabababababababab
|
||||
#define BELL_LABS_IQ_PER_SF 7680 // Up to 5MHz bw for now
|
||||
#define BELL_LABS_IQ_BYTES_PER_SF (BELL_LABS_IQ_PER_SF * 4)
|
||||
#define MAX_BELL_LABS_IQ_BYTES_PER_SF BELL_LABS_IQ_BYTES_PER_SF*10
|
||||
|
||||
#define OAIIQFILE_ID {'O', 'I','Q','F'}
|
||||
typedef struct {
|
||||
uint64_t devtype;
|
||||
uint64_t tx_sample_advance;
|
||||
double bw;
|
||||
unsigned int nbSamplesBlocks;
|
||||
char oaiid[4];
|
||||
} iqfile_header_t;
|
||||
|
||||
typedef struct {
|
||||
int64_t header;
|
||||
int64_t ts;
|
||||
int64_t nbBytes;
|
||||
int64_t rfu2; // pad for 256 bits alignement required by AVX2
|
||||
} iqrec_t;
|
||||
#define DEF_NB_SF 120000 // default nb of sf or ms to capture (2 minutes at 5MHz)
|
||||
#define DEF_SF_FILE "/tmp/iqfile" // default subframes file name
|
||||
#define DEF_SF_DELAY_READ 700 // default read delay µs (860=real)
|
||||
#define DEF_SF_DELAY_WRITE 15 // default write delay µs (15=real)
|
||||
#define DEF_SF_NB_LOOP 5 // default nb loops
|
||||
|
||||
|
||||
/* help strings definition for config options, used in CMDLINE_XXX_DESC macros and printed when -h option is used */
|
||||
#define CONFIG_HLP_SF_FILE "Path of the file used for subframes record or replay"
|
||||
#define CONFIG_HLP_SF_REC "Record subframes from device driver into a file for later replay"
|
||||
#define CONFIG_HLP_SF_REP "Replay subframes from a file using the oai replay driver"
|
||||
#define CONFIG_HLP_SF_MAX "Maximum count of subframes to be recorded in subframe file"
|
||||
#define CONFIG_HLP_SF_LOOPS "Number of loops to replay of the entire subframes file"
|
||||
#define CONFIG_HLP_SF_RDELAY "Delay in microseconds to read a subframe in replay mode"
|
||||
#define CONFIG_HLP_SF_WDELAY "Delay in microseconds to write a subframe in replay mode"
|
||||
#define CONFIG_HLP_USE_MMAP "In replay mode, map iq file in memory before replaying"
|
||||
/* keyword strings for config options, used in CMDLINE_XXX_DESC macros and printed when -h option is used */
|
||||
#define CONFIG_OPT_SF_FILE "subframes-file"
|
||||
#define CONFIG_OPT_SF_REC "subframes-record"
|
||||
#define CONFIG_OPT_SF_REP "subframes-replay"
|
||||
#define CONFIG_OPT_SF_MAX "subframes-max"
|
||||
#define CONFIG_OPT_SF_LOOPS "subframes-loops"
|
||||
#define CONFIG_OPT_SF_RDELAY "subframes-read-delay"
|
||||
#define CONFIG_OPT_SF_WDELAY "subframes-write-delay"
|
||||
#define CONFIG_OPT_USE_MMAP "use-mmap"
|
||||
#define DEVICE_RECPLAY_SECTION "device.recplay"
|
||||
/* For information only - the macro is not usable in C++ */
|
||||
/*---------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/
|
||||
/* command line parameters for USRP record/playback */
|
||||
/* optname helpstr paramflags XXXptr defXXXval type numelt */
|
||||
/*---------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/
|
||||
#define DEVICE_RECPLAY_PARAMS_DESC { \
|
||||
{CONFIG_OPT_SF_FILE, CONFIG_HLP_SF_FILE, 0, strptr:&((*recplay_conf)->u_sf_filename), defstrval:DEF_SF_FILE, TYPE_STRING, 0}, \
|
||||
{CONFIG_OPT_SF_REC, CONFIG_HLP_SF_REC, PARAMFLAG_BOOL, uptr:&(u_sf_record), defuintval:0, TYPE_UINT, 0}, \
|
||||
{CONFIG_OPT_SF_REP, CONFIG_HLP_SF_REP, PARAMFLAG_BOOL, uptr:&(u_sf_replay), defuintval:0, TYPE_UINT, 0}, \
|
||||
{CONFIG_OPT_SF_MAX, CONFIG_HLP_SF_MAX, 0, uptr:&((*recplay_conf)->u_sf_max), defintval:DEF_NB_SF, TYPE_UINT, 0}, \
|
||||
{CONFIG_OPT_SF_LOOPS, CONFIG_HLP_SF_LOOPS, 0, uptr:&((*recplay_conf)->u_sf_loops), defintval:DEF_SF_NB_LOOP, TYPE_UINT, 0}, \
|
||||
{CONFIG_OPT_SF_RDELAY, CONFIG_HLP_SF_RDELAY, 0, uptr:&((*recplay_conf)->u_sf_read_delay), defintval:DEF_SF_DELAY_READ, TYPE_UINT, 0}, \
|
||||
{CONFIG_OPT_SF_WDELAY, CONFIG_HLP_SF_WDELAY, 0, uptr:&((*recplay_conf)->u_sf_write_delay), defintval:DEF_SF_DELAY_WRITE, TYPE_UINT, 0}, \
|
||||
{CONFIG_OPT_USE_MMAP, CONFIG_HLP_USE_MMAP, PARAMFLAG_BOOL, uptr:&((*recplay_conf)->use_mmap), defuintval:1, TYPE_UINT, 0}, \
|
||||
}/*! \brief Record Player Configuration and state */
|
||||
typedef struct {
|
||||
char *u_sf_filename; // subframes file path
|
||||
unsigned int u_sf_max ; // max number of recorded subframes
|
||||
unsigned int u_sf_loops ; // number of loops in replay mode
|
||||
unsigned int u_sf_read_delay; // read delay in replay mode
|
||||
unsigned int u_sf_write_delay ; // write delay in replay mode
|
||||
unsigned int use_mmap; // default is to use mmap
|
||||
} recplay_conf_t;
|
||||
|
||||
typedef struct {
|
||||
size_t mapsize;
|
||||
FILE *pFile;
|
||||
int fd;
|
||||
iqrec_t *ms_sample; // memory for all subframes
|
||||
unsigned int nbSamplesBlocks;
|
||||
uint8_t *currentPtr;
|
||||
uint64_t currentTs;
|
||||
unsigned int curSamplesBlock;
|
||||
int64_t wrap_count;
|
||||
size_t maxSizeBytes;
|
||||
} recplay_state_t;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif // __RECORD_PLAYER_H
|
||||
|
||||
Reference in New Issue
Block a user