libpg2sdr
Host library for the ProStick Gen 2 SDR
Loading...
Searching...
No Matches
Filter calibration tables

Data Structures

struct  pg2sdr_bandpass_table_t
 Tuner bandpass filter table entry. More...
 

Functions

int pg2sdr_set_bandpass_table (pg2sdr_device *dev, const pg2sdr_bandpass_table_t *bandpass_table, size_t bandpass_table_size)
 Set the filter calibration tables used for bandpass filter selection.
 
int pg2sdr_get_bandpass_table (pg2sdr_device *dev, pg2sdr_bandpass_table_t **bandpass_table, size_t *bandpass_table_size)
 Get the current filter calibration tables used for bandpass filter selection.
 

Detailed Description

The tuner hardware in a PG2SDR device has a configurable bandpass filter that is applied to the mixed IF signal before reaching the ADC. libpg2sdr needs to configure this filter appropriaely for the requested sampling rate and bandwidth requirements requested.

The mapping from hardware settings to actual filter characteristics is mostly undocumented and not particularly regular, so libpg2sdr includes a calibration table that contains empirical measurements of the filter characteristics for each combination of filter settings. At runtime, this table is scanned to find filter hardware settings that best match libpg2sdr's requirements.

libpg2sdr includes a built-in calibration table that is used by default, but an alternative table can be provided by used code via the pg2sdr_set_bandpass_table() and pg2sdr_get_bandpass_table() APIs.

Function Documentation

◆ pg2sdr_get_bandpass_table()

int pg2sdr_get_bandpass_table ( pg2sdr_device dev,
pg2sdr_bandpass_table_t **  bandpass_table,
size_t *  bandpass_table_size 
)

Get the current filter calibration tables used for bandpass filter selection.

Creates and returns a copy of the currently used filter calibration table. This copy is a snapshot as at the time of the call, and will not reflect future changes to the calibration table.

A copy of the current calibration table will be allocated and returned via bandpass_table. It is the caller's responsibility to free this array via free() when done.

Parameters
[in]devthe device to query
[out]bandpass_tablestorage for a pointer to a copy of the filter calibration table
[out]bandpass_table_sizestores the length of the array stored in bandpass_table
Return values
PG2SDR_SUCCESSsuccess
PG2SDR_ERROR_BAD_ARGUMENTif bandpass_table or bandpass_table_size are NULL
<0negative error code on failure

◆ pg2sdr_set_bandpass_table()

int pg2sdr_set_bandpass_table ( pg2sdr_device dev,
const pg2sdr_bandpass_table_t bandpass_table,
size_t  bandpass_table_size 
)

Set the filter calibration tables used for bandpass filter selection.

Update the internal filter calibration table. Filter calibration tables are device-specific.

This can be called at any time, but changes to the calibration table do not retrospectively affect the chosen filter settings (the hardware settings are not modified when the calibration table is updated).

A copy of the table is made at the point when pg2sdr_set_gain_tables() is called; ownership of provided table (and responsibility for freeing any allocated memory) stays with the caller.

bandpass_table must be exactly bandpass_table_size entries long, and must have at least one entry.

Parameters
[in]devthe device to configure
[in]bandpass_tablepointer to an array of length bandpass_table_size entries
[in]bandpass_table_sizenumber of entries in bandpass_table
Return values
PG2SDR_SUCCESSsuccess
PG2SDR_ERROR_BAD_ARGUMENTif bandpass_table is NULL or bandpass_table_size is 0
<0negative error code on failure