-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Reconcile SDRPlay gains with SoapySDR abstractions #27
base: master
Are you sure you want to change the base?
Conversation
…RFGR' without listing them for backward compatibility
new-gain-controls
Thanks for opening this PR, David. If I remember correctly (I had even forgotten about creating #10 a while ago. thanks for finding it), the values for the 'lnastates' and 'ifgains' tables came from @SDRplay , and I I think they are similar to the values used in the SDRuno application, which is the reference we used when designing and coding the SoapySDRPlay driver, to keep things consistent for the users. Also on a different but related project, the new GNU Radio OOT module for SDRplay RSPs based on API version 3.X (https://github.com/fventuri/gr-sdrplay3), I used the tables from the SDRplay API specification guide (see here for instance: https://github.com/fventuri/gr-sdrplay3/blob/master/lib/rspduo_impl.cc#L265-L285), so that could be a possible approach too. Franco |
That is correct, the tables of LNA and IF configurations for the "default" gains were provided by @SDRplay in the initial commit. I can't find them in the API documentation but presumably they are taken from SDRuno. I think this is great to have, and it is a nice way to override the default multi-stage gain allocation algorithm from SoapySDR The challenge of this PR is trying to keep things similar to SDRuno while at the same time keeping things similar to the other SoapySDR drivers. After all, SoapySDR is supposed to be an abstraction layer that hides some of the variation from radio to radio :-) So, based on the previous discussion and These are my remaining questions:
My preference is to convert everything to decibels (including the RF gain and the aggregate |
Would it be possible to add gain step in ::getGainRange() ? |
@nmaster2042 we can easily add 1 dB step size for IF gain and overall gain. The actual step spacing for RF gain is nonlinear, so I think we will need to expose it with a false 1 dB step size and then round to the closest value in the LNA state table during |
@dlaw Before we get started, I'd like to have some feedback from the usual folks (@SDRplay , @vsonnier , @guruofquality , @nmaster2042 , @jketterl ) on what they should look like based on your comment above (#27 (comment)) Just to make sure we are all on the same page, this is the current behavior of the SoapySDRPlay3 driver regarding gains/attenuations (based on what the source code does):
With this information and the suggestion (and questions) from @dlaw I'd like to start a discussion on how to improve the gain/attenuation controls. I also would like to limit as much possible any 'breaking' changes, that would affect client applications that use the driver (CubicSDR, gqrx, and many others, see here: https://github.com/pothosware/SoapySDR/wiki#platforms); for instance, as suggested above, we could leave the meaning and behavior of 'IFGR' and 'RFGR' unchanged, add two new gain controls called simply 'IF' and 'RF', and 'hide' the old controls (by having listGains() not return them), but I am not sure what the impact would be on the client applications, and the users using them. Comments, ideas, objections are welcome. Franco |
From a user point of view, I have high interest in @dlaw 's PR. I totally agree to make SoapySDRPlay3 gain controls acts like other Soapy drivers instead of the gain reduction control and rename gains to RF and IF. Regarding (#27 (comment)):
@fventuri regarding "breaking change" I agree it would be better to add 2 new sliders IF and RF, keeping the old ones. To select the driver gain control behavior of the driver, what about adding a configurable feature CMakefile ? Like the existing RF_GAIN_IN_MENU feature, a new RF_GAIN_REDUCTION (= 0 by default) could be added, so user can chose at build time if he wants IF/RF or IFGR/RFGR returned by listGains ? |
Thanks for your feedback @nmaster2042 I think you and @dlaw have a very strong point about the gains being exposed in dB. Even more importantly, since this is a SoapySDR driver, I think it should conform to the SoapySDR driver gain API (see here and below: https://github.com/pothosware/SoapySDR/blob/master/include/SoapySDR/Device.hpp#L671).
Based on that I think that using the raw LNA state index for the Unfortunately this raises another tricky problem. If you look at the 'Gain Reduction Tables' in chapter 5 of the SDRplay API specification document, you'll see that the gain reduction provided by a certain LNA state depends on the selected frequency. For instance for the RSPduo with LNAstate=4, you have a gain reduction of 37dB for rfHz in the range 0-60MHz, but that gain reduction drops to 20dB (i.e. 17db lower) in the range 60-420MHz. I wonder if it is because of these 'quirks' that in SDRuno they decided to keep the RF gain/attenuation control as just a pure integer index (i.e. not as a value in dB). It is also possible that they do adjust that LNAstate index whenever the selected frequency changes range (for instance from 0-60MHz to 60-420MHz) to avoid sudden changes in attenuation, but I can also see how that could make the code more complicated (if you have Windows and SDRuno installed, it would be an interesting thing to find out). Franco |
Based on this discussion, I would suggest that we express all gains in decibels and we do not perform any automatic change to the LNA state when the frequency is changed. This would mean that the RF gain in decibels may change when the frequency changes. However -- and I think this is important -- if you change back to your original frequency, you will also recover your original gain. I don't want to toggle from 61 MHz to 59 MHz then back to 61 MHz and find that some algorithm scrambled up my IF and RF gains. I believe that CubicSDR already automatically refreshes the gain slider values whenever a different setting (such as the frequency) is changed. (This is why the existing RFGR slider automatically updates itself when a different LNA state is selected from the menu.) Here is a specific proposal for what every function should do:
|
@dlaw - thanks for your useful comment and ideas. For this first part of my reply I am referring specifically to the RF gain/gain reduction (i.e. LNA state); more on the IF gain below. The suggestion of having the RF gain frequency dependent has some consequences that need to be considered; imagine the scenario where the hypothetical user with his/her RSPduo goes from 59MHz to 61MHz, changes gain at 61MHZ, then they move up to 421MHz, change the gain to some other value there, then they go to 1001MHZ, change their gain again, finally they go back to 59MHz; what value of RF gain should the RSPduo set to to at this point? the original that they had at the beginning of their tuning around the bands? also what value of RF gain should the RSPduo have if then they switch to say 1500MHz? the same that they had when they were at 1001MHz? If this were the case, should the SoapySDRPlay code be able to remember and store the RF gain settings for each frequency (or range of frequencies) they visited? Also if they were initially at say 61MHz with an RF gain reduction of 62 (LNAstate=9), and they change frequency to 59MHz (where LNAstate=9 is invalid), what should the SoapySDRPlay driver do? As per the IF gain, there's also to take into account what to do if the AGC is enabled; what would be the meaning of the value of Franco |
Hello @fventuri , @dlaw and all. I'm not repeating my arguments I wrote long before, but here is a quick summary of hopfully simple suggestions :
In other words :
@dlaw solution although interesting, seems complicated and not without drawbacks as @fventuri said. And since @fventuri will probably be (too much) kind enough to try to implement all this, and worse support all the following bugs let's preserve his sanity :) The incredible job he has done on the Duo support would have exhausted my patience long ago, so what about small quality of life changes this time ?
That was a hell to do it right : The gain sliders sort-of continously re-read the current gains by The funny thing is if the gain sliders were not hidden when 'AGC on', you would probably see the displayed gain value change in realtime as adapted by the AGC algorithm. |
Thanks for all the thoughts @vsonnier. I agree, there is a lot to be said for putting LNA state in the menu and keeping it out of the gain sliders completely. That was actually my first attempt at solution for this problem (see #26). I will be happy to do the work to implement any solution, as soon as there is some agreement about what I should do. So please all continue the discussion and let's try to find a consensus about what is best for the project! 😃 One area where I really disagree with @vsonnier is about the negative numbers. I think it is perfectly sensible for a positive gain reduction to equal a negative gain.
The alternative seems confusing to anyone who has used SDRPlay previously:
At that point, since the shifting is arbitrary anyway, you might as well map it to an IF range from 0 to 39. I don't think supporting So, here is a "simpler, quality of life" proposal based on @vsonnier suggestions:
|
If the gain is called SDRUno now shows either "Gain Reduction" or "Gain" controls depending of the user preference.
Exactly. Same arguments for the Anyway I'm not that attached to any convention, but be assured that the first thing some users will ask is "We the hell the scale is negative numbers ?" |
new-gain-controls
branch onto latest mastersetGain
implementation and add a corresponding genericgetGainRange
.Let's use this PR to discuss whether this proposal represents the desired semantics for a change. I will be happy to make any additional updates once we come to a consensus.
This PR addresses #10, supersedes #26, and is related to the discussion in cjcliffe/CubicSDR#825.
Cheers,
David