gqrx
gqrx copied to clipboard
Gain level setting not applied by default on SDRplay RSPdx
Gqrx 2.14.4 on Fedora 34 with SDRplay RSPdx (using SoapySDR 0.7.2 with SDRplay RSP API 3.07.1). Gain (IFGR and RFGR) level seems to be set to a minimal gain when Gqrx is started. The sliders are displayed with correct values in Gqrx, but I have to manually check and uncheck the "Hardware AGC" checkbox to make the values be actually applied.
I think the most likely explanation is a bug in gr-osmosdr. Unfortunately I don't have SDRplay hardware to test with, so there's not much I can do for now.
I encounter the same with an SDRplay RSP2pro using gr-osmosdr from willcode. I analyzed the problem with gdb and found the following cause.
In gr-osmosdr/lib/source_impl.cc, function bool source_impl::set_gain_mode( bool automatic, size_t chan )
does this:
if ( _gain_mode[ chan ] != automatic ) {
_gain_mode[ chan ] = automatic;
...
}
This is apparently the only place where _gain_mode
is written. It is initially an empty map, and on the first call, the condition check accesses a map element before it is initialized. That returns 0
, meaning no automatic gain. So if the "Hardware AGC" box is not checked on start, the function is called with automatic == 0
, and then wrongly assumes that this has been already set. Unfortunately, the default inside the SDRplay specific routines is to have AGC enabled, causing an inconsistency. The manual gain settings are then overridden by the AGC.
By checking the AGC box before starting, the function gets called with a nonzero value in automatic
, so _gain_mode[ chan ]
gets properly initialized and the change is propagated to the SDRplay driver. Unchecking AGC again then works as expected.
That particular piece of code still exists in the upstream code of gr-osmosdr from osmocom, apparently also without proper initialization.
In theory, GQRX could work around this by emulating the check/uncheck of the AGC box in software, but it would be better if gr-osmosdr was fixed to correctly initialize _gain_mode
or check if _gain_mode[ chan ]
exists before reading it.
This change in gr-osmosdr/lib/source_impl.cc fixes it for me:
- if ( _gain_mode[ chan ] != automatic ) {
+ if ( (_gain_mode.count(chan) == 0) || (_gain_mode[ chan ] != automatic) ) {
Upstream ticket: https://osmocom.org/issues/5562
The issue was patched downstream in Fedora. Let's hope it will also be fixed in upstream and/or in other Linux distributions.
Closing the ticket since this has to be fixed in gr-osmosdr, not Gqrx.
Perhaps the issue would get more visibility in Osmocom's gitea instance: https://gitea.osmocom.org/sdr/gr-osmosdr/issues