diff --git a/include/tuner_r82xx.h b/include/tuner_r82xx.h index f6c206a..c9a7a03 100644 --- a/include/tuner_r82xx.h +++ b/include/tuner_r82xx.h @@ -116,5 +116,6 @@ int r82xx_init(struct r82xx_priv *priv); int r82xx_set_freq(struct r82xx_priv *priv, uint32_t freq); int r82xx_set_gain(struct r82xx_priv *priv, int set_manual_gain, int gain); int r82xx_set_bandwidth(struct r82xx_priv *priv, int bandwidth, uint32_t rate); +int r82xx_toggle_test(struct r82xx_priv *priv, int toggle); #endif diff --git a/src/librtlsdr.c b/src/librtlsdr.c index 5b33310..9162d67 100644 --- a/src/librtlsdr.c +++ b/src/librtlsdr.c @@ -1177,6 +1177,16 @@ int rtlsdr_set_agc_mode(rtlsdr_dev_t *dev, int on) if (!dev) return -1; + /* FOR TESTING ONLY. Uncomment to enable repurposing the RTL AGC button + * for switching registers on/off. Uses to test functions of registers easily. */ + + /* + rtlsdr_set_i2c_repeater(dev, 1); + r82xx_toggle_test(&dev->r82xx_p, on); + rtlsdr_set_i2c_repeater(dev, 0); + return 0; + */ + return rtlsdr_demod_write_reg(dev, 0, 0x19, on ? 0x25 : 0x05, 1); } diff --git a/src/tuner_r82xx.c b/src/tuner_r82xx.c index dbdf4e9..d42241a 100644 --- a/src/tuner_r82xx.c +++ b/src/tuner_r82xx.c @@ -1105,6 +1105,25 @@ int r82xx_set_bandwidth(struct r82xx_priv *priv, int bw, uint32_t rate) return priv->int_freq; } + +int r82xx_toggle_test(struct r82xx_priv *priv, int toggle) +{ + int rc; + + if (toggle) + { + fprintf(stderr, "TOGGLE ON \n"); + rc = r82xx_write_reg_mask(priv, 0x17, 0x08, 0x08); /* open_d notch on */ + } + else + { + fprintf(stderr, "TOGGLE OFF \n"); + rc = r82xx_write_reg_mask(priv, 0x17, 0x00, 0x08); /* open_d notch off */ + } + + return rc; +} + #undef FILT_HP_BW1 #undef FILT_HP_BW2