Hi, in the course of the development of our noise figure measurement tool (CANFI http://www.canfi.eu) we tried to use librtlsdr with E4k dongles. Unfortunately it turned out that the original library is too "deaf" - the noise figure is too high due to not enough gain.
After some discussions I found that Leif already had solved this problem and provides a patched version of the librtlsdr code (latest version http://www.sm5bsz.com/linuxdsp/hware/rtlsdr/rtl-sdr-linrad4.tbz). Essentially, the main contribution I needed was the additional gain modes discussed here http://lists.osmocom.org/pipermail/osmocom-sdr/2012-October/000296.html I used the /E4K_GAIN_MODE_SENSITIVITY /As I did not want to use a "foreign" library (mainly due to the fact that providing a Windows DLL is some work...), I had a look at what would be needed to address the issues mentioned here http://lists.osmocom.org/pipermail/osmocom-sdr/2012-October/000297.html and made a number of patches to merge Leif's changes back into the "normal" library. While at it I also merged other (unrelated) changes I found in Leif's code. Recently I created a fork for this (https://github.com/dl8aau/librtlsdr), but can of course also provide separate patches. (side note: the above fixes the initial issue by using rtlsdr_set_tuner_gain() to also set the IF gain - the original function for E4000 only dealt with LNA and mixer gain. But the implementation of this function is not the same for the different tuners anyway: rtlsdr_set_tuner_gain() sets mixer gain by a fixed algorithm together with LNA gain (E4K and R820T). For E4K only there is an additional function rtlsdr_set_tuner_if_gain() - but the caller needs to know the "details" of the IF gain stages. For other tuners there is no way to change the IF gain currently - rtlsdr_set_tuner_gain() sets it to to a fixed value on R820T. FC0013 only sets LNA gain for rtlsdr_set_tuner_gain(), FC2580 does nothing and for FC0012 I'm not clear. So currently, the function of rtlsdr_set_tuner_gain() is not consistent at all and rtlsdr_set_tuner_if_gain() is only supported on E4000. It was ok for the CANFI application on E4K, as I could set LNA, mixer and IF gain through rtlsdr_set_tuner_gain() and rtlsdr_set_tuner_if_gain(), but it was more "by chance"... So maybe it would make more sense to implement the rtlsdr_set_tuner_gain() the way Leif did and set suitable combinations for LNA, mixer and IF gain for two modes: good sensitivity and good linearity. Do this not only for E4K, but also for the other tuners that allow for manual gain control. Additionally, support setting LNA, mixer and IF gain separately. IMHO that would be cleaner. At least for R820T I need a way to control the LNA, mixer and IF gain - or use an optimized table of gain settings. ) Regards, Alexander
