From patchwork Mon Jul 24 18:35:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Niedermayer X-Patchwork-Id: 42945 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:be1d:b0:130:ccc6:6c4b with SMTP id ge29csp2111479pzb; Mon, 24 Jul 2023 11:35:53 -0700 (PDT) X-Google-Smtp-Source: APBJJlHHMT+Fw+zyYaFNGMB+ahdJotkATg6ozJbw3FGx/lmLRk2qZmoP5traDIOL1sccux62Po2n X-Received: by 2002:a17:906:7394:b0:994:577:f9dd with SMTP id f20-20020a170906739400b009940577f9ddmr10118212ejl.9.1690223753465; Mon, 24 Jul 2023 11:35:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690223753; cv=none; d=google.com; s=arc-20160816; b=lr1IOgDFDlXjiIRAnJ4TinZwRoRqdkHZLPdbG6nhtAxP2PV7DaHyMDMpJQiA7J9ADO sBsm0xvrzrSw+n1RVYfrVrNGCeIxJTeyn1naqtxcixk0mftc5DNyMrh/q8JHS8XZZOcI 2clbO3XhcAfsLBARkaH545lv4vYjhs+oFVAN7YVCJvHFdnkNO/KUrMevKSYWu/hm09Rh Tu9g1oMGx/N6bcAyGSU+DxGawQ2c6kreYufx1TlOcKDJVQrTAMLLpt2u4k2kCBmg22C3 DSraaBHGxXjT3bt8AaAJO6+3nDSI+ZrAFg/12ejOweH8dcrKa6SBkMQdjOrd659uB2rc gh5w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:message-id:date:to:from :delivered-to; bh=T9tgcU7fd+nA4TXdokv1BrEl9E5N8bVbt5oXfQkXMpA=; fh=YYwLYmpaV0Fpw/rxmSKNRLS2XzDkAlGbHATiKOPtZrY=; b=oR2q0U4e1dLERRkddlR9D0EMZc9nN6RJxRJ2J0orqx0klR7dOsWb5LYTpCMSJ16Y8T P8ybeur1Tnx9n55M7mgd5xhO4wSFsMy0JTHH2COK46QRy8wsBhZ5gwMp2T2NN04fat23 t7zdMKAhqZiqCKPIwSPYnr/PIzaY/m8R7HTNHg7nwUcrufVNG2h3NoF1GGm62lb+9sD/ 59r/T0NKUxe3RQUj4TEcpj0dXsrjyvPaAJWqVANu28E6I9RhetQfQ/BDWjkIxx6Z3BYS 9f/4Lk8oBz6/4URZbam6dBoR3bTM6V+dq6UdfXvrhMJLbCvRxFBROT1RnGGPDHLaQq3x XOhA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id b15-20020a170906d10f00b009889baa6a24si6976754ejz.1032.2023.07.24.11.35.47; Mon, 24 Jul 2023 11:35:53 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id E99E068C794; Mon, 24 Jul 2023 21:35:43 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: qF/8Wl0DsxBL 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) {