Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
From: Michael Niedermayer <michael@niedermayer.cc>
To: FFmpeg development discussions and patches <ffmpeg-devel@ffmpeg.org>
Subject: [FFmpeg-devel] [PATCH 7/7] avradio/sdr: workaround inverted gain parameter on sdrplay
Date: Mon, 17 Jul 2023 02:27:04 +0200
Message-ID: <20230717002704.3092192-7-michael@niedermayer.cc> (raw)
In-Reply-To: <20230717002704.3092192-1-michael@niedermayer.cc>

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
---
 libavradio/sdr.h        | 1 +
 libavradio/sdrdemux.c   | 1 +
 libavradio/sdrinradio.c | 7 +++++++
 3 files changed, 9 insertions(+)

diff --git a/libavradio/sdr.h b/libavradio/sdr.h
index 395b056531..27ec1db4f3 100644
--- a/libavradio/sdr.h
+++ b/libavradio/sdr.h
@@ -257,6 +257,7 @@ typedef struct SDRContext {
     int missing_streams;
 
     int rtlsdr_fixes;
+    int sdrplay_fixes;
 } SDRContext;
 
 typedef struct ModulationDescriptor {
diff --git a/libavradio/sdrdemux.c b/libavradio/sdrdemux.c
index 5214aea7be..1b3061a406 100644
--- a/libavradio/sdrdemux.c
+++ b/libavradio/sdrdemux.c
@@ -2180,6 +2180,7 @@ const AVOption ff_sdr_options[] = {
 
     { "driver"  , "sdr driver name"  , OFFSET(driver_name), AV_OPT_TYPE_STRING, {.str = NULL}, 0, 0, DEC},
     { "rtlsdr_fixes" , "workaround rtlsdr issues", OFFSET(rtlsdr_fixes), AV_OPT_TYPE_INT , {.i64 = -1}, -1, 1, DEC},
+    { "sdrplay_fixes" , "workaround sdrplay issues", OFFSET(sdrplay_fixes), AV_OPT_TYPE_INT , {.i64 = -1}, -1, 1, DEC},
     { "sdr_sr"  , "sdr sample rate"  , OFFSET(sdr_sample_rate ), AV_OPT_TYPE_INT , {.i64 = 0}, 0, INT_MAX, DEC},
     { "sdr_freq", "sdr frequency"    , OFFSET(wanted_freq), AV_OPT_TYPE_INT64 , {.i64 = 9000000}, 0, INT64_MAX, DEC},
     { "gain" , "sdr overall gain",  OFFSET(sdr_gain),  AV_OPT_TYPE_INT , {.i64 =  GAIN_SDR_AGC}, -3, INT_MAX, DEC, "gain"},
diff --git a/libavradio/sdrinradio.c b/libavradio/sdrinradio.c
index 63a9cade78..f824a1d190 100644
--- a/libavradio/sdrinradio.c
+++ b/libavradio/sdrinradio.c
@@ -76,6 +76,11 @@ static int sdrindev_set_gain_callback(SDRContext *sdr, float gain)
     if (sdr->sdr_gain == GAIN_DEFAULT)
         return 0;
 
+    //sdrplay has a inverted gain range, not using max_gain as this is a user parameter
+    if (sdr->sdrplay_fixes > 0) {
+        gain = FFMIN(48 - gain, 45);
+    }
+
     if (soapy) {
         int ret = SoapySDRDevice_setGainMode(soapy, SOAPY_SDR_RX, 0, sdr->sdr_gain == GAIN_SDR_AGC);
         if (ret) {
@@ -192,6 +197,8 @@ static int sdrindev_initial_hw_setup(AVFormatContext *s)
 
     if (sdr->rtlsdr_fixes < 0)
         sdr->rtlsdr_fixes = !strcmp(sdr->driver_name, "rtlsdr");
+    if (sdr->sdrplay_fixes < 0)
+        sdr->sdrplay_fixes = !strcmp(sdr->driver_name, "sdrplay");
 
     SoapySDRKwargs_set(&args, "driver", sdr->driver_name);
     sdr->soapy = soapy = SoapySDRDevice_make(&args);
-- 
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".

  parent reply	other threads:[~2023-07-17  0:28 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-17  0:26 [FFmpeg-devel] [PATCH 1/7] avradio/sdrdemux: icarrier just needs phase 2 block size Michael Niedermayer
2023-07-17  0:26 ` [FFmpeg-devel] [PATCH 2/7] avradio/sdr: compensate for RTLSDR frequency limitations Michael Niedermayer
2023-07-17  0:27 ` [FFmpeg-devel] [PATCH 3/7] avradio/sdrinradio: Print all tunable elements Michael Niedermayer
2023-07-17  0:27 ` [FFmpeg-devel] [PATCH 4/7] avradio/sdrdemux: Use a local noise floor in FM Probing Michael Niedermayer
2023-07-17  0:27 ` [FFmpeg-devel] [PATCH 5/7] avradio/sdrdemux: adjust bandwidth to 200khz for FM probing Michael Niedermayer
2023-07-17  0:27 ` [FFmpeg-devel] [PATCH 6/7] avradio/sdr: Support setting gain value manually and automatic Michael Niedermayer
2023-07-17  0:27 ` Michael Niedermayer [this message]
2023-07-18 21:26 ` [FFmpeg-devel] [PATCH 1/7] avradio/sdrdemux: icarrier just needs phase 2 block size Michael Niedermayer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230717002704.3092192-7-michael@niedermayer.cc \
    --to=michael@niedermayer.cc \
    --cc=ffmpeg-devel@ffmpeg.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
		ffmpegdev@gitmailbox.com
	public-inbox-index ffmpegdev

Example config snippet for mirrors.


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git