disable DAGC by default, add control function

This adds rtlsdr_set_agc_mode() to enable/disable it.
Thanks to Leif Asbrink for finding this setting.

Signed-off-by: Steve Markgraf <steve@steve-m.de>
This commit is contained in:
Steve Markgraf 2012-07-07 20:59:48 +02:00
parent 98d1b864b6
commit f3cf83e3d7
2 changed files with 21 additions and 3 deletions

View File

@ -206,6 +206,15 @@ RTLSDR_API uint32_t rtlsdr_get_sample_rate(rtlsdr_dev_t *dev);
*/ */
RTLSDR_API int rtlsdr_set_testmode(rtlsdr_dev_t *dev, int on); RTLSDR_API int rtlsdr_set_testmode(rtlsdr_dev_t *dev, int on);
/*!
* Enable or disable the internal digital AGC of the RTL2832.
*
* \param dev the device handle given by rtlsdr_open()
* \param digital AGC mode, 1 means enabled, 0 disabled
* \return 0 on success
*/
RTLSDR_API int rtlsdr_set_agc_mode(rtlsdr_dev_t *dev, int on);
/* streaming functions */ /* streaming functions */
RTLSDR_API int rtlsdr_reset_buffer(rtlsdr_dev_t *dev); RTLSDR_API int rtlsdr_reset_buffer(rtlsdr_dev_t *dev);

View File

@ -485,12 +485,13 @@ void rtlsdr_init_baseband(rtlsdr_dev_t *dev)
for (i = 0; i < sizeof (fir_coeff); i++) for (i = 0; i < sizeof (fir_coeff); i++)
rtlsdr_demod_write_reg(dev, 1, 0x1c + i, fir_coeff[i], 1); rtlsdr_demod_write_reg(dev, 1, 0x1c + i, fir_coeff[i], 1);
rtlsdr_demod_write_reg(dev, 0, 0x19, 0x25, 1); /* enable SDR mode, disable DAGC (bit 5) */
rtlsdr_demod_write_reg(dev, 0, 0x19, 0x05, 1);
/* init FSM state-holding register */ /* init FSM state-holding register */
rtlsdr_demod_write_reg(dev, 1, 0x93, 0xf0, 1); rtlsdr_demod_write_reg(dev, 1, 0x93, 0xf0, 1);
/* disable AGC (en_dagc, bit 0) */ /* disable AGC (en_dagc, bit 0) (this seems to have no effect) */
rtlsdr_demod_write_reg(dev, 1, 0x11, 0x00, 1); rtlsdr_demod_write_reg(dev, 1, 0x11, 0x00, 1);
/* disable PID filter (enable_PID = 0) */ /* disable PID filter (enable_PID = 0) */
@ -842,7 +843,15 @@ int rtlsdr_set_testmode(rtlsdr_dev_t *dev, int on)
if (!dev) if (!dev)
return -1; return -1;
return rtlsdr_demod_write_reg(dev, 0, 0x19, on ? 0x23 : 0x25 , 1); return rtlsdr_demod_write_reg(dev, 0, 0x19, on ? 0x03 : 0x05, 1);
}
int rtlsdr_set_agc_mode(rtlsdr_dev_t *dev, int on)
{
if (!dev)
return -1;
return rtlsdr_demod_write_reg(dev, 0, 0x19, on ? 0x25 : 0x05, 1);
} }
static rtlsdr_dongle_t *find_known_device(uint16_t vid, uint16_t pid) static rtlsdr_dongle_t *find_known_device(uint16_t vid, uint16_t pid)