From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTP id 4439F46904 for ; Mon, 24 Jul 2023 18:35:45 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id B521C68C78C; Mon, 24 Jul 2023 21:35:43 +0300 (EEST) Received: from relay5-d.mail.gandi.net (relay5-d.mail.gandi.net [217.70.183.197]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 6B56668C741 for ; Mon, 24 Jul 2023 21:35:37 +0300 (EEST) Received: by mail.gandi.net (Postfix) with ESMTPSA id 8A6DA1C0007 for ; Mon, 24 Jul 2023 18:35:36 +0000 (UTC) From: Michael Niedermayer To: FFmpeg development discussions and patches Date: Mon, 24 Jul 2023 20:35:30 +0200 Message-Id: <20230724183535.2677937-1-michael@niedermayer.cc> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 X-GND-Sasl: michael@niedermayer.cc Subject: [FFmpeg-devel] [PATCH 1/6] avradio/sdrinradio: Check tuner before applying rtlsdr frequency correction X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: Signed-off-by: Michael Niedermayer --- libavradio/sdrinradio.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/libavradio/sdrinradio.c b/libavradio/sdrinradio.c index c24a30d746..5c14250f8c 100644 --- a/libavradio/sdrinradio.c +++ b/libavradio/sdrinradio.c @@ -103,6 +103,7 @@ static int64_t sdrindev_set_frequency_callback(SDRContext *sdr, int64_t freq) SoapySDRDevice *soapy = sdr->soapy; if (soapy) { if (sdr->rtlsdr_fixes>0) { + AVDictionaryEntry *e = av_dict_get(sdr->driver_dict, "tuner", NULL, 0); // The official unmodified RTLSDR needs to be put in Direct sampling Q-ADC mode below 24Mhz and non direct sampling above const char *value = freq < 24000000 ? "2" : "0"; if (!sdr->current_direct_samp || strcmp(value, sdr->current_direct_samp)) { @@ -112,12 +113,14 @@ static int64_t sdrindev_set_frequency_callback(SDRContext *sdr, int64_t freq) } else sdr->current_direct_samp = value; } - //The R820T has a 16 bit fractional PLL which can do only multiplies of 439.45 - //Its more complex but this approximation works - //It has to be noted that SOAPY does not tell us about this, instead saopy - //pretends whatever we ask for we get exactly, but we dont - //For more details see: michelebavaro.blogspot.com/2014/05/gnss-carrier-phase-rtlsdr-and.html - freq = lrint(freq / 439.45) * 439.45; + if (e && strstr(e->value, "R820T")) { + //The R820T has a 16 bit fractional PLL which can do only multiplies of 439.45 + //Its more complex but this approximation works + //It has to be noted that SOAPY does not tell us about this, instead saopy + //pretends whatever we ask for we get exactly, but we dont + //For more details see: michelebavaro.blogspot.com/2014/05/gnss-carrier-phase-rtlsdr-and.html + freq = lrint(freq / 439.45) * 439.45; + } } if (SoapySDRDevice_setFrequency(soapy, SOAPY_SDR_RX, 0, freq, NULL) != 0) { -- 2.31.1 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".