Skip to content

Commit

Permalink
#1643 Adds support for RTL2832 with embedded R828D tuner and RTL-SDR.…
Browse files Browse the repository at this point in the history
…com V4 dongles.
  • Loading branch information
Dennis Sheirer committed Oct 22, 2023
1 parent 9468fd1 commit a9fbe4b
Show file tree
Hide file tree
Showing 11 changed files with 747 additions and 439 deletions.
16 changes: 11 additions & 5 deletions src/main/java/io/github/dsheirer/source/tuner/TunerFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,11 @@
import io.github.dsheirer.source.tuner.rtl.e4k.E4KEmbeddedTuner;
import io.github.dsheirer.source.tuner.rtl.e4k.E4KTunerConfiguration;
import io.github.dsheirer.source.tuner.rtl.e4k.E4KTunerEditor;
import io.github.dsheirer.source.tuner.rtl.r820t.R820TEmbeddedTuner;
import io.github.dsheirer.source.tuner.rtl.r820t.R820TTunerConfiguration;
import io.github.dsheirer.source.tuner.rtl.r820t.R820TTunerEditor;
import io.github.dsheirer.source.tuner.rtl.r8x.R8xTunerEditor;
import io.github.dsheirer.source.tuner.rtl.r8x.r820t.R820TEmbeddedTuner;
import io.github.dsheirer.source.tuner.rtl.r8x.r820t.R820TTunerConfiguration;
import io.github.dsheirer.source.tuner.rtl.r8x.r828d.R828DEmbeddedTuner;
import io.github.dsheirer.source.tuner.rtl.r8x.r828d.R828DTunerConfiguration;
import io.github.dsheirer.source.tuner.sdrplay.DiscoveredRspTuner;
import io.github.dsheirer.source.tuner.sdrplay.RspTuner;
import io.github.dsheirer.source.tuner.sdrplay.api.DeviceSelectionMode;
Expand Down Expand Up @@ -367,7 +369,8 @@ public static EmbeddedTuner getRtlEmbeddedTuner(TunerType tunerType,
{
case ELONICS_E4000 -> new E4KEmbeddedTuner(adapter);
case RAFAELMICRO_R820T -> new R820TEmbeddedTuner(adapter);
default -> throw new SourceException("Unsupported/Unrecognized Tuner Type");
case RAFAELMICRO_R828D -> new R828DEmbeddedTuner(adapter);
default -> throw new SourceException("Unsupported/Unrecognized Tuner Type: " + tunerType);
};
}

Expand All @@ -394,6 +397,8 @@ public static TunerConfiguration getTunerConfiguration(TunerType type, String un
return new HackRFTunerConfiguration(uniqueID);
case RAFAELMICRO_R820T:
return new R820TTunerConfiguration(uniqueID);
case RAFAELMICRO_R828D:
return new R828DTunerConfiguration(uniqueID);
case RECORDING:
return RecordingTunerConfiguration.create();
case RSP_1:
Expand Down Expand Up @@ -475,7 +480,8 @@ else if(discoveredRspTuner instanceof DiscoveredRspDuoTuner2 duoTuner2)
case ELONICS_E4000:
return new E4KTunerEditor(userPreferences, tunerManager, discoveredTuner);
case RAFAELMICRO_R820T:
return new R820TTunerEditor(userPreferences, tunerManager, discoveredTuner);
case RAFAELMICRO_R828D:
return new R8xTunerEditor(userPreferences, tunerManager, discoveredTuner);
}
}
return new RTL2832UnknownTunerEditor(userPreferences, tunerManager, discoveredTuner);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* *****************************************************************************
* Copyright (C) 2014-2022 Dennis Sheirer
* Copyright (C) 2014-2023 Dennis Sheirer
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -31,7 +31,8 @@
import io.github.dsheirer.source.tuner.hackrf.HackRFTunerConfiguration;
import io.github.dsheirer.source.tuner.recording.RecordingTunerConfiguration;
import io.github.dsheirer.source.tuner.rtl.e4k.E4KTunerConfiguration;
import io.github.dsheirer.source.tuner.rtl.r820t.R820TTunerConfiguration;
import io.github.dsheirer.source.tuner.rtl.r8x.r820t.R820TTunerConfiguration;
import io.github.dsheirer.source.tuner.rtl.r8x.r828d.R828DTunerConfiguration;
import io.github.dsheirer.source.tuner.sdrplay.RspTunerConfiguration;

/**
Expand All @@ -47,6 +48,7 @@
@JsonSubTypes.Type(value = HackRFTunerConfiguration.class, name = "hackRFTunerConfiguration"),
@JsonSubTypes.Type(value = RecordingTunerConfiguration.class, name = "recordingTunerConfiguration"),
@JsonSubTypes.Type(value = R820TTunerConfiguration.class, name = "r820TTunerConfiguration"),
@JsonSubTypes.Type(value = R828DTunerConfiguration.class, name = "r828DTunerConfiguration"),
@JsonSubTypes.Type(value = RspTunerConfiguration.class, name = "rspTunerConfiguration"),
})
@JacksonXmlRootElement(localName = "tuner_configuration")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* *****************************************************************************
* Copyright (C) 2014-2022 Dennis Sheirer
* Copyright (C) 2014-2023 Dennis Sheirer
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand All @@ -24,7 +24,8 @@
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement;
import io.github.dsheirer.source.tuner.configuration.TunerConfiguration;
import io.github.dsheirer.source.tuner.rtl.e4k.E4KTunerConfiguration;
import io.github.dsheirer.source.tuner.rtl.r820t.R820TTunerConfiguration;
import io.github.dsheirer.source.tuner.rtl.r8x.r820t.R820TTunerConfiguration;
import io.github.dsheirer.source.tuner.rtl.r8x.r828d.R828DTunerConfiguration;

/**
* RTL2832 tuner configuration
Expand All @@ -33,6 +34,7 @@
@JsonSubTypes({
@JsonSubTypes.Type(value = E4KTunerConfiguration.class, name = "e4KTunerConfiguration"),
@JsonSubTypes.Type(value = R820TTunerConfiguration.class, name = "r820TTunerConfiguration"),
@JsonSubTypes.Type(value = R828DTunerConfiguration.class, name = "r828DTunerConfiguration"),
})
@JacksonXmlRootElement(localName = "tuner_configuration")
public abstract class RTL2832TunerConfiguration extends TunerConfiguration
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* *****************************************************************************
* Copyright (C) 2014-2022 Dennis Sheirer
* Copyright (C) 2014-2023 Dennis Sheirer
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -238,7 +238,7 @@ protected void deviceStart() throws SourceException

if(tunerType == TunerType.UNKNOWN)
{
throw new SourceException("Unrecognized embedded tuner type for RTL-2832");
throw new SourceException("Unrecognized RTL-2832 embedded tuner type: " + tunerType);
}

mEmbeddedTuner = TunerFactory.getRtlEmbeddedTuner(tunerType, new ControllerAdapter(this));
Expand Down Expand Up @@ -869,11 +869,11 @@ private boolean isTuner(TunerTypeCheck type, boolean controlI2CRepeater)

if(type == TunerTypeCheck.FC2580)
{
return ((value & 0x7F) == type.getCheckValue());
return ((value & 0x7F) == (type.getCheckValue() & 0xFF));
}
else
{
return (value == type.getCheckValue());
return (value == (type.getCheckValue() & 0xFF));
}
}
catch(LibUsbException e)
Expand Down Expand Up @@ -973,7 +973,7 @@ private int getUSBTransferBufferSize(double sampleRate)

public void setSampleRateFrequencyCorrection(int ppm) throws SourceException
{
int offset = -ppm * TWO_TO_22_POWER / 1000000;
int offset = -ppm * TWO_TO_22_POWER / 1_000_000;
writeDemodRegister(Page.ONE, (short) 0x3F, (offset & 0xFF), 1);
writeDemodRegister(Page.ONE, (short) 0x3E, (Integer.rotateRight(offset, 8) & 0xFF), 1);
/* Test to retune controller to apply frequency correction */
Expand All @@ -983,7 +983,7 @@ public void setSampleRateFrequencyCorrection(int ppm) throws SourceException
}
catch(Exception e)
{
throw new SourceException("couldn't set sample rate frequency correction", e);
throw new SourceException("Couldn't set sample rate frequency correction", e);
}
}

Expand Down Expand Up @@ -1314,6 +1314,14 @@ public Descriptor(byte[] data)
getLabels();
}

/**
* Indicates if this is a rtl-sdr.com V4 R828D dongle with notch filtering.
*/
public boolean isRtlSdrV4()
{
return "RTLSDRBlog".equals(getVendorLabel()) && "Blog V4".equals(getProductLabel());
}

public boolean isValid()
{
return mData[0] != (byte)0x0 && mData[1] != (byte)0x0;
Expand Down Expand Up @@ -1479,6 +1487,15 @@ public boolean isRunning()
return mController.isRunning();
}

/**
* Indicates if this is a rtl-sdr.com V4 dongle with support for notch filtering.
* @return true if this is a V4 R828D tuner.
*/
public boolean isV4Dongle()
{
return mController.getDescriptor().isRtlSdrV4();
}

/**
* Device handle for the tuner controller.
* @return
Expand Down
Loading

0 comments on commit a9fbe4b

Please sign in to comment.