|
| int | pg2sdr_set_lna_gain (pg2sdr_device *dev, unsigned gain) |
| | Set LNA stage gain step.
|
| |
| int | pg2sdr_set_mix_gain (pg2sdr_device *dev, unsigned gain) |
| | Set MIX stage gain step.
|
| |
| int | pg2sdr_set_vga_gain (pg2sdr_device *dev, unsigned gain) |
| | Set VGA stage gain step.
|
| |
| int | pg2sdr_get_stage_gains (pg2sdr_device *dev, unsigned *lna, unsigned *mix, unsigned *vga) |
| | Get per-stage gain step settings.
|
| |
| int | pg2sdr_set_lna_gain_db (pg2sdr_device *dev, double gain_db) |
| | Set LNA stage gain in dB.
|
| |
| int | pg2sdr_set_mix_gain_db (pg2sdr_device *dev, double gain_db) |
| | Set MIX stage gain in dB.
|
| |
| int | pg2sdr_set_vga_gain_db (pg2sdr_device *dev, double gain_db) |
| | Set VGA stage gain in dB.
|
| |
| int | pg2sdr_get_stage_gains_db (pg2sdr_device *dev, double *lna_db, double *mix_db, double *vga_db) |
| | Get per-stage gain settings in dB.
|
| |
| int | pg2sdr_set_total_gain_db (pg2sdr_device *dev, double gain_db) |
| | Set total gain, in dB.
|
| |
| int | pg2sdr_get_total_gain_db (pg2sdr_device *dev, double *gain_db) |
| | Get total gain setting, in dB.
|
| |
The tuner on PG2SDR hardware has three controllable gain-stages. In order, starting from the RF input, these stages are LNA, MIX, and VGA. Each stage has a configurable gain setting that can be set to one of 16 possible gain steps.
libpg2sdr provides three types of API for setting the gain of these stages, and matching getters to retrieve gain:
- Total gain setting across all stages, in dB: pg2sdr_set_total_gain_db(), pg2sdr_get_total_gain_db(). This uses a precomputed table to convert between total gain and combined stage gains. This is the API you probably want to use unless you have special requirements.
- Gain setting per stage, in terms of dB: pg2sdr_set_lna_gain_db(), pg2sdr_set_mix_gain_db(), pg2sdr_set_vga_gain_db(), pg2sdr_get_stage_gains_db(). This API operates in terms of approximate gain in dB per stage, using a calibration table to convert between dB and hardware gain steps.
- Direct control of hardware gain step settings: pg2sdr_set_lna_gain(), pg2sdr_set_mix_gain(), pg2sdr_set_vga_gain(), pg2sdr_get_stage_gains(). This is a low-level API that works in terms of hardware gain steps, which do not directly correspond to any particular amplification ratio.
The gain APIs that deal in terms of dB rely on a set of gain tables, which provide conversions between hardware gain steps and values in dB. libpg2sdr provides a built-in set of tables by default. The conversion tables can be inspected or updated via pg2sdr_get_gain_tables() and pg2sdr_set_gain_tables().
All of the gain APIs can be called while streaming data, and take effect immediately when called.
◆ pg2sdr_get_stage_gains()
| int pg2sdr_get_stage_gains |
( |
pg2sdr_device * |
dev, |
|
|
unsigned * |
lna, |
|
|
unsigned * |
mix, |
|
|
unsigned * |
vga |
|
) |
| |
Get per-stage gain step settings.
This retrieves current hardware gain settings, in terms of the low-level hardware gain step for each stage.
- Parameters
-
| [in] | dev | the device to query |
| [out] | lna | if not NULL, location to store the current LNA gain step |
| [out] | mix | if not NULL, location to store the current MIX gain step |
| [out] | vga | if not NULL, location to store the current VGA gain step |
- Return values
-
- See also
- pg2sdr_set_lna_gain()
-
pg2sdr_set_mix_gain()
-
pg2sdr_set_vga_gain()
◆ pg2sdr_get_stage_gains_db()
| int pg2sdr_get_stage_gains_db |
( |
pg2sdr_device * |
dev, |
|
|
double * |
lna_db, |
|
|
double * |
mix_db, |
|
|
double * |
vga_db |
|
) |
| |
Get per-stage gain settings in dB.
This retrieves current hardware gain settings, converting hardware gain step settings to a gain in dB using the currently set gain table.
- Parameters
-
| [in] | dev | the device to query |
| [out] | lna_db | if not NULL, location to store the current LNA gain |
| [out] | mix_db | if not NULL, location to store the current MIX gain |
| [out] | vga_db | if not NULL, location to store the current VGA gain |
- Return values
-
- See also
- pg2sdr_set_lna_gain_db()
-
pg2sdr_set_mix_gain_db()
-
pg2sdr_set_vga_gain_db()
-
pg2sdr_get_gain_tables()
◆ pg2sdr_get_total_gain_db()
| int pg2sdr_get_total_gain_db |
( |
pg2sdr_device * |
dev, |
|
|
double * |
gain_db |
|
) |
| |
Get total gain setting, in dB.
This retrieves current hardware gain settings, and converts them to a total gain value in dB using the currently set gain table.
If the current gain was set by calling pg2sdr_set_total_gain_db() then the returned gain reflects the recorded gain setting for the entry in the gain table that was used. If the current gain was set by setting individual gain stages, then an estimated total gain is returned by looking at the gain table for each stage individually; this estimated total may not exactly match the total gain measurements in the gain table.
- Parameters
-
| [in] | dev | the device to query |
| [out] | gain_db | location to store the current total gain, in dB |
- Return values
-
- See also
- pg2sdr_set_total_gain_db()
-
pg2sdr_get_gain_tables()
◆ pg2sdr_set_lna_gain()
Set LNA stage gain step.
- Parameters
-
| [in] | dev | the device to configure |
| [in] | gain | the LNA gain step to set, in the range [0..15] |
- Return values
-
- See also
- pg2sdr_get_stage_gains()
◆ pg2sdr_set_lna_gain_db()
| int pg2sdr_set_lna_gain_db |
( |
pg2sdr_device * |
dev, |
|
|
double |
gain_db |
|
) |
| |
Set LNA stage gain in dB.
The requested dB value will be converted to a hardware gain step using the currently set gain table. The actual dB value may not exactly match the requested value.
- Parameters
-
| [in] | dev | the device to configure |
| [in] | gain_db | the LNA gain to set, in dB |
- Return values
-
- See also
- pg2sdr_get_stage_gains_db()
-
pg2sdr_set_gain_tables()
◆ pg2sdr_set_mix_gain()
Set MIX stage gain step.
- Parameters
-
| [in] | dev | the device to configure |
| [in] | gain | the MIX gain step to set, in the range [0..15] |
- Return values
-
- See also
- pg2sdr_get_stage_gains()
◆ pg2sdr_set_mix_gain_db()
| int pg2sdr_set_mix_gain_db |
( |
pg2sdr_device * |
dev, |
|
|
double |
gain_db |
|
) |
| |
Set MIX stage gain in dB.
The requested dB value will be converted to a hardware gain step using the currently set gain table. The actual dB value may not exactly match the requested value.
- Parameters
-
| [in] | dev | the device to configure |
| [in] | gain_db | the MIX gain to set, in dB |
- Return values
-
- See also
- pg2sdr_get_stage_gains_db()
-
pg2sdr_set_gain_tables()
◆ pg2sdr_set_total_gain_db()
| int pg2sdr_set_total_gain_db |
( |
pg2sdr_device * |
dev, |
|
|
double |
gain_db |
|
) |
| |
Set total gain, in dB.
The requested dB value is converted to a set of hardware gain steps for each stage, using the currently set gain table. The actual dB value may not exactly match the requested value.
- Parameters
-
| [in] | dev | the device to configure |
| [in] | gain_db | the total gain to set, in dB |
- Return values
-
- See also
- pg2sdr_get_total_gain_db()
-
pg2sdr_set_gain_tables()
◆ pg2sdr_set_vga_gain()
Set VGA stage gain step.
- Parameters
-
| [in] | dev | the device to configure |
| [in] | gain | the VGA gain step to set, in the range [0..15] |
- Return values
-
- See also
- pg2sdr_get_stage_gains()
◆ pg2sdr_set_vga_gain_db()
| int pg2sdr_set_vga_gain_db |
( |
pg2sdr_device * |
dev, |
|
|
double |
gain_db |
|
) |
| |
Set VGA stage gain in dB.
The requested dB value will be converted to a hardware gain step using the currently set gain table. The actual dB value may not exactly match the requested value.
- Parameters
-
| [in] | dev | the device to configure |
| [in] | gain_db | the VGA gain to set, in dB |
- Return values
-
- See also
- pg2sdr_get_stage_gains_db()
-
pg2sdr_set_gain_tables()