<div dir="ltr"><div>This patch fixes a regression of rtl-sdr dongles with the FC00012 tuner.    </div><div><br></div><div>The code to switch on the FC00012 tuner by pulling it's ~RESET line<br></div><div>low ended up with an off-by-one error in a refactor a long time ago,</div><div><br></div><div>The FC00012 only continued to work by accident as a different bug in</div><div>rtlsdr_set_gpio_output had a side-effect of pulling low the FC00012's</div><div>~RESET line</div><div><br></div><div>When the rtl_set_gpio_output bug was fixed in ba64a7459a43 the side-</div><div>effect also went away, leaving the FC00012 tuner in reset, and failing</div><div>to be detected (or indeed work at all).</div><div><br></div><div>This patch fixes the original off-by-one error.  It's been tested</div><div>on an FC00012 in a GTek T803 from both warm and cold starts, but needs testing on the FC2580 as both the FC00012 and FC2580 are brought out of reset by a GPIO off the RTL (at least in some designs). If the FC2580 actually uses a different pin, this code will also break.  (I'm only going from vague memory that the FC2580 used the same pin.)</div><div><br></div><div>---</div><div> src/librtlsdr.c | 8 ++++----</div><div> 1 file changed, 4 insertions(+), 4 deletions(-)</div><div><br></div><div>diff --git a/src/librtlsdr.c b/src/librtlsdr.c</div><div>index b369a5d..678fadd 100644</div><div>--- a/src/librtlsdr.c</div><div>+++ b/src/librtlsdr.c</div><div>@@ -1565,11 +1565,11 @@ int rtlsdr_open(rtlsdr_dev_t **out_dev, uint32_t index)</div><div> <span style="white-space:pre">       </span>}</div><div><br></div><div> <span style="white-space:pre">  </span>/* initialise GPIOs */</div><div>-<span style="white-space:pre">       </span>rtlsdr_set_gpio_output(dev, 5);</div><div>+<span style="white-space:pre">      </span>rtlsdr_set_gpio_output(dev, 4);</div><div><br></div><div> <span style="white-space:pre">    </span>/* reset tuner before probing */</div><div>-<span style="white-space:pre">     </span>rtlsdr_set_gpio_bit(dev, 5, 1);</div><div>-<span style="white-space:pre">      </span>rtlsdr_set_gpio_bit(dev, 5, 0);</div><div>+<span style="white-space:pre">      </span>rtlsdr_set_gpio_bit(dev, 4, 1);</div><div>+<span style="white-space:pre">      </span>rtlsdr_set_gpio_bit(dev, 4, 0);</div><div><br></div><div> <span style="white-space:pre">    </span>reg = rtlsdr_i2c_read_reg(dev, FC2580_I2C_ADDR, FC2580_CHECK_ADDR);</div><div> <span style="white-space:pre"> </span>if ((reg & 0x7f) == FC2580_CHECK_VAL) {</div><div>@@ -1581,7 +1581,7 @@ int rtlsdr_open(rtlsdr_dev_t **out_dev, uint32_t index)</div><div> <span style="white-space:pre">     </span>reg = rtlsdr_i2c_read_reg(dev, FC0012_I2C_ADDR, FC0012_CHECK_ADDR);</div><div> <span style="white-space:pre"> </span>if (reg == FC0012_CHECK_VAL) {</div><div> <span style="white-space:pre">              </span>fprintf(stderr, "Found Fitipower FC0012 tuner\n");</div><div>-<span style="white-space:pre">         </span>rtlsdr_set_gpio_output(dev, 6);</div><div>+<span style="white-space:pre">              </span>rtlsdr_set_gpio_output(dev, 5);</div><div> <span style="white-space:pre">             </span>dev->tuner_type = RTLSDR_TUNER_FC0012;</div><div> <span style="white-space:pre">           </span>goto found;</div><div> <span style="white-space:pre"> </span>}</div><div>--</div><div>2.13.2</div><div><br></div></div>