From 138cd052f5345990507de630001421dc49937b20 Mon Sep 17 00:00:00 2001 From: rtlsdrblog Date: Wed, 20 Sep 2023 12:10:13 +1200 Subject: [PATCH] add blog v4 upconverter gpio switch In future blog v4 production batches (out in several months time), it will be possible to turn off the upconverter when tuned outside of the HF bands. The code controls the GPIOs to turn off the upconverter when it is not in use. --- include/rtlsdr_i2c.h | 1 + src/tuner_r82xx.c | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/include/rtlsdr_i2c.h b/include/rtlsdr_i2c.h index 6faf141..b683896 100644 --- a/include/rtlsdr_i2c.h +++ b/include/rtlsdr_i2c.h @@ -2,6 +2,7 @@ #define __I2C_H int rtlsdr_check_dongle_model(void *dev, char *manufact_check, char *product_check); +int rtlsdr_set_bias_tee_gpio(void *dev, int gpio, int on); uint32_t rtlsdr_get_tuner_clock(void *dev); int rtlsdr_i2c_write_fn(void *dev, uint8_t addr, uint8_t *buf, int len); int rtlsdr_i2c_read_fn(void *dev, uint8_t addr, uint8_t *buf, int len); diff --git a/src/tuner_r82xx.c b/src/tuner_r82xx.c index 1510fc3..38d4802 100644 --- a/src/tuner_r82xx.c +++ b/src/tuner_r82xx.c @@ -1151,6 +1151,12 @@ int r82xx_set_freq(struct r82xx_priv *priv, uint32_t freq) cable_2_in = (band == HF) ? 0x08 : 0x00; rc = r82xx_write_reg_mask(priv, 0x06, cable_2_in, 0x08); + if (rc < 0) + goto err; + + /* Control upconverter GPIO switch on newer batches */ + rc = rtlsdr_set_bias_tee_gpio(priv->rtl_dev, 5, !cable_2_in); + if (rc < 0) goto err;