srsLTE/lib/include/srslte/phy/dft/dft.h

162 lines
5.8 KiB
C
Raw Normal View History

/**
2014-01-28 03:41:17 -08:00
*
* \section COPYRIGHT
2014-01-28 03:41:17 -08:00
*
2015-11-13 04:22:33 -08:00
* Copyright 2013-2015 Software Radio Systems Limited
*
* \section LICENSE
*
* This file is part of the srsLTE library.
*
* 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
* published by the Free Software Foundation, either version 3 of
* the License, or (at your option) any later version.
*
* srsLTE is distributed in the hope that it will be useful,
2014-01-28 03:41:17 -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.
2014-01-28 03:41:17 -08:00
*
2015-05-08 08:05:40 -07:00
* A copy of the GNU Affero General Public License can be found in
* the LICENSE file in the top-level directory of this distribution
* and at http://www.gnu.org/licenses/.
*
2014-01-28 03:41:17 -08:00
*/
2014-01-28 03:41:17 -08:00
#ifndef DFT_H_
#define DFT_H_
2014-06-20 07:35:37 -07:00
#include <stdbool.h>
#include "srslte/config.h"
2014-01-28 03:41:17 -08:00
/**********************************************************************************************
* File: dft.h
*
* Description: Generic DFT module.
* Supports one-dimensional complex and real transforms. Options are set
* using the dft_plan_set_x functions.
*
* Options (default is false):
*
* mirror - Rearranges negative and positive frequency bins. Swaps after
* transform for FORWARD, swaps before transform for BACKWARD.
* db - Provides output in dB (10*log10(x)).
* norm - Normalizes output (by sqrt(len) for complex, len for real).
* dc - Handles insertion and removal of null DC carrier internally.
*
* Reference:
*********************************************************************************************/
2014-01-28 03:41:17 -08:00
typedef enum {
2015-03-18 11:14:24 -07:00
SRSLTE_DFT_COMPLEX, SRSLTE_REAL
}srslte_dft_mode_t;
2014-01-28 03:41:17 -08:00
typedef enum {
2015-03-18 11:14:24 -07:00
SRSLTE_DFT_FORWARD, SRSLTE_DFT_BACKWARD
}srslte_dft_dir_t;
2014-01-28 03:41:17 -08:00
typedef struct SRSLTE_API {
int init_size; // DFT length used in the first initialization
2014-06-20 07:35:37 -07:00
int size; // DFT length
void *in; // Input buffer
void *out; // Output buffer
void *p; // DFT plan
bool is_guru;
2014-06-20 07:35:37 -07:00
bool forward; // Forward transform?
bool mirror; // Shift negative and positive frequencies?
bool db; // Provide output in dB?
bool norm; // Normalize output?
bool dc; // Handle insertion/removal of null DC carrier internally?
2015-03-18 11:14:24 -07:00
srslte_dft_dir_t dir; // Forward/Backward
srslte_dft_mode_t mode; // Complex/Real
2015-03-18 05:41:50 -07:00
}srslte_dft_plan_t;
2014-01-28 03:41:17 -08:00
SRSLTE_API void srslte_dft_load();
2014-01-28 03:41:17 -08:00
SRSLTE_API void srslte_dft_exit();
SRSLTE_API int srslte_dft_plan(srslte_dft_plan_t *plan,
2015-03-18 11:14:24 -07:00
int dft_points,
srslte_dft_dir_t dir,
srslte_dft_mode_t type);
SRSLTE_API int srslte_dft_plan_c(srslte_dft_plan_t *plan,
2015-03-18 11:14:24 -07:00
int dft_points,
srslte_dft_dir_t dir);
SRSLTE_API int srslte_dft_plan_guru_c(srslte_dft_plan_t *plan,
int dft_points,
srslte_dft_dir_t dir,
cf_t *in_buffer,
cf_t *out_buffer,
int istride,
int ostride,
int how_many,
int idist,
int odist);
2015-03-18 11:14:24 -07:00
SRSLTE_API int srslte_dft_plan_r(srslte_dft_plan_t *plan,
int dft_points,
srslte_dft_dir_t dir);
SRSLTE_API int srslte_dft_replan(srslte_dft_plan_t *plan,
const int new_dft_points);
SRSLTE_API int srslte_dft_replan_guru_c(srslte_dft_plan_t *plan,
const int new_dft_points,
cf_t *in_buffer,
cf_t *out_buffer,
int istride,
int ostride,
int how_many,
int idist,
int odist);
SRSLTE_API int srslte_dft_replan_c(srslte_dft_plan_t *plan,
int new_dft_points);
SRSLTE_API int srslte_dft_replan_r(srslte_dft_plan_t *plan,
int new_dft_points);
2015-03-18 11:14:24 -07:00
SRSLTE_API void srslte_dft_plan_free(srslte_dft_plan_t *plan);
2014-01-28 03:41:17 -08:00
2014-06-20 07:35:37 -07:00
/* Set options */
2014-01-28 03:41:17 -08:00
2015-03-18 11:14:24 -07:00
SRSLTE_API void srslte_dft_plan_set_mirror(srslte_dft_plan_t *plan,
bool val);
SRSLTE_API void srslte_dft_plan_set_db(srslte_dft_plan_t *plan,
bool val);
SRSLTE_API void srslte_dft_plan_set_norm(srslte_dft_plan_t *plan,
bool val);
SRSLTE_API void srslte_dft_plan_set_dc(srslte_dft_plan_t *plan,
bool val);
2014-01-28 03:41:17 -08:00
/* Compute DFT */
SRSLTE_API void srslte_dft_run(srslte_dft_plan_t *plan,
const void *in,
2015-03-18 11:14:24 -07:00
void *out);
SRSLTE_API void srslte_dft_run_c_zerocopy(srslte_dft_plan_t *plan,
const cf_t *in,
2015-10-06 06:31:20 -07:00
cf_t *out);
SRSLTE_API void srslte_dft_run_c(srslte_dft_plan_t *plan,
const cf_t *in,
2015-03-18 11:14:24 -07:00
cf_t *out);
SRSLTE_API void srslte_dft_run_guru_c(srslte_dft_plan_t *plan);
2015-03-18 11:14:24 -07:00
SRSLTE_API void srslte_dft_run_r(srslte_dft_plan_t *plan,
const float *in,
2015-03-18 11:14:24 -07:00
float *out);
2014-01-28 03:41:17 -08:00
#endif // DFT_H_
2014-01-28 03:41:17 -08:00