#1643 Adds support for RTL2832 with embedded R828D tuner and RTL-SDR.com V4 dongles. Introduces Bias-T support for all RTL-2832 dongles.

This commit is contained in:
Dennis Sheirer
2023-10-22 07:35:32 -04:00
parent 9468fd189b
commit 0d652b9153
12 changed files with 882 additions and 474 deletions

View File

@@ -55,9 +55,11 @@ import io.github.dsheirer.source.tuner.rtl.RTL2832UnknownTunerEditor;
import io.github.dsheirer.source.tuner.rtl.e4k.E4KEmbeddedTuner; 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.E4KTunerConfiguration;
import io.github.dsheirer.source.tuner.rtl.e4k.E4KTunerEditor; 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.r8x.R8xTunerEditor;
import io.github.dsheirer.source.tuner.rtl.r820t.R820TTunerConfiguration; import io.github.dsheirer.source.tuner.rtl.r8x.r820t.R820TEmbeddedTuner;
import io.github.dsheirer.source.tuner.rtl.r820t.R820TTunerEditor; 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.DiscoveredRspTuner;
import io.github.dsheirer.source.tuner.sdrplay.RspTuner; import io.github.dsheirer.source.tuner.sdrplay.RspTuner;
import io.github.dsheirer.source.tuner.sdrplay.api.DeviceSelectionMode; import io.github.dsheirer.source.tuner.sdrplay.api.DeviceSelectionMode;
@@ -367,7 +369,8 @@ public class TunerFactory
{ {
case ELONICS_E4000 -> new E4KEmbeddedTuner(adapter); case ELONICS_E4000 -> new E4KEmbeddedTuner(adapter);
case RAFAELMICRO_R820T -> new R820TEmbeddedTuner(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);
}; };
} }
@@ -394,6 +397,8 @@ public class TunerFactory
return new HackRFTunerConfiguration(uniqueID); return new HackRFTunerConfiguration(uniqueID);
case RAFAELMICRO_R820T: case RAFAELMICRO_R820T:
return new R820TTunerConfiguration(uniqueID); return new R820TTunerConfiguration(uniqueID);
case RAFAELMICRO_R828D:
return new R828DTunerConfiguration(uniqueID);
case RECORDING: case RECORDING:
return RecordingTunerConfiguration.create(); return RecordingTunerConfiguration.create();
case RSP_1: case RSP_1:
@@ -475,7 +480,8 @@ public class TunerFactory
case ELONICS_E4000: case ELONICS_E4000:
return new E4KTunerEditor(userPreferences, tunerManager, discoveredTuner); return new E4KTunerEditor(userPreferences, tunerManager, discoveredTuner);
case RAFAELMICRO_R820T: case RAFAELMICRO_R820T:
return new R820TTunerEditor(userPreferences, tunerManager, discoveredTuner); case RAFAELMICRO_R828D:
return new R8xTunerEditor(userPreferences, tunerManager, discoveredTuner);
} }
} }
return new RTL2832UnknownTunerEditor(userPreferences, tunerManager, discoveredTuner); return new RTL2832UnknownTunerEditor(userPreferences, tunerManager, discoveredTuner);

View File

@@ -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 * 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 * it under the terms of the GNU General Public License as published by
@@ -31,7 +31,8 @@ import io.github.dsheirer.source.tuner.fcd.proplusV2.FCD2TunerConfiguration;
import io.github.dsheirer.source.tuner.hackrf.HackRFTunerConfiguration; import io.github.dsheirer.source.tuner.hackrf.HackRFTunerConfiguration;
import io.github.dsheirer.source.tuner.recording.RecordingTunerConfiguration; import io.github.dsheirer.source.tuner.recording.RecordingTunerConfiguration;
import io.github.dsheirer.source.tuner.rtl.e4k.E4KTunerConfiguration; 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; import io.github.dsheirer.source.tuner.sdrplay.RspTunerConfiguration;
/** /**
@@ -47,6 +48,7 @@ import io.github.dsheirer.source.tuner.sdrplay.RspTunerConfiguration;
@JsonSubTypes.Type(value = HackRFTunerConfiguration.class, name = "hackRFTunerConfiguration"), @JsonSubTypes.Type(value = HackRFTunerConfiguration.class, name = "hackRFTunerConfiguration"),
@JsonSubTypes.Type(value = RecordingTunerConfiguration.class, name = "recordingTunerConfiguration"), @JsonSubTypes.Type(value = RecordingTunerConfiguration.class, name = "recordingTunerConfiguration"),
@JsonSubTypes.Type(value = R820TTunerConfiguration.class, name = "r820TTunerConfiguration"), @JsonSubTypes.Type(value = R820TTunerConfiguration.class, name = "r820TTunerConfiguration"),
@JsonSubTypes.Type(value = R828DTunerConfiguration.class, name = "r828DTunerConfiguration"),
@JsonSubTypes.Type(value = RspTunerConfiguration.class, name = "rspTunerConfiguration"), @JsonSubTypes.Type(value = RspTunerConfiguration.class, name = "rspTunerConfiguration"),
}) })
@JacksonXmlRootElement(localName = "tuner_configuration") @JacksonXmlRootElement(localName = "tuner_configuration")

View File

@@ -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 * 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 * it under the terms of the GNU General Public License as published by
@@ -24,7 +24,8 @@ import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement; import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement;
import io.github.dsheirer.source.tuner.configuration.TunerConfiguration; import io.github.dsheirer.source.tuner.configuration.TunerConfiguration;
import io.github.dsheirer.source.tuner.rtl.e4k.E4KTunerConfiguration; 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 * RTL2832 tuner configuration
@@ -33,11 +34,13 @@ import io.github.dsheirer.source.tuner.rtl.r820t.R820TTunerConfiguration;
@JsonSubTypes({ @JsonSubTypes({
@JsonSubTypes.Type(value = E4KTunerConfiguration.class, name = "e4KTunerConfiguration"), @JsonSubTypes.Type(value = E4KTunerConfiguration.class, name = "e4KTunerConfiguration"),
@JsonSubTypes.Type(value = R820TTunerConfiguration.class, name = "r820TTunerConfiguration"), @JsonSubTypes.Type(value = R820TTunerConfiguration.class, name = "r820TTunerConfiguration"),
@JsonSubTypes.Type(value = R828DTunerConfiguration.class, name = "r828DTunerConfiguration"),
}) })
@JacksonXmlRootElement(localName = "tuner_configuration") @JacksonXmlRootElement(localName = "tuner_configuration")
public abstract class RTL2832TunerConfiguration extends TunerConfiguration public abstract class RTL2832TunerConfiguration extends TunerConfiguration
{ {
private RTL2832TunerController.SampleRate mSampleRate = RTL2832TunerController.SampleRate.RATE_2_400MHZ; private RTL2832TunerController.SampleRate mSampleRate = RTL2832TunerController.SampleRate.RATE_2_400MHZ;
private boolean mBiasTEnabled = false;
/** /**
* Default constructor to support Jackson * Default constructor to support Jackson
@@ -61,4 +64,23 @@ public abstract class RTL2832TunerConfiguration extends TunerConfiguration
{ {
mSampleRate = sampleRate; mSampleRate = sampleRate;
} }
/**
* Sets the enabled state of the Bias-T
* @param enabled true to turn-on the bias-T
*/
public void setBiasT(boolean enabled)
{
mBiasTEnabled = enabled;
}
/**
* Indicates if the Bias-T is enabled.
* @return true if enabled.
*/
@JacksonXmlProperty(isAttribute = true, localName = "bias_t")
public boolean isBiasT()
{
return mBiasTEnabled;
}
} }

View File

@@ -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 * 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 * it under the terms of the GNU General Public License as published by
@@ -66,6 +66,7 @@ public class RTL2832TunerController extends USBTunerController
private Descriptor mDescriptor; private Descriptor mDescriptor;
private EmbeddedTuner mEmbeddedTuner; private EmbeddedTuner mEmbeddedTuner;
private long mTunedFrequency = 0; private long mTunedFrequency = 0;
private boolean mBiasTEnabled = false;
private ReentrantLock mLock = new ReentrantLock(); private ReentrantLock mLock = new ReentrantLock();
/** /**
@@ -174,7 +175,7 @@ public class RTL2832TunerController extends USBTunerController
try try
{ {
writeRegister(Block.USB, Address.USB_SYSCTL.getAddress(), 0x09, 1); writeRegister(Block.USB, Address.USB_SYSCTL, 0x09, 1);
} }
catch(LibUsbException lue) catch(LibUsbException lue)
{ {
@@ -195,7 +196,7 @@ public class RTL2832TunerController extends USBTunerController
try try
{ {
writeRegister(Block.USB, Address.USB_SYSCTL.getAddress(), 0x09, 1); writeRegister(Block.USB, Address.USB_SYSCTL, 0x09, 1);
} }
catch(LibUsbException lue) catch(LibUsbException lue)
{ {
@@ -238,7 +239,7 @@ public class RTL2832TunerController extends USBTunerController
if(tunerType == TunerType.UNKNOWN) 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)); mEmbeddedTuner = TunerFactory.getRtlEmbeddedTuner(tunerType, new ControllerAdapter(this));
@@ -299,6 +300,26 @@ public class RTL2832TunerController extends USBTunerController
return null; return null;
} }
/**
* Sets the enabled state of the bias-t
* @param enabled true to turn-on the bias-t or false to turn-off the bias-t.
*/
public void setBiasT(boolean enabled)
{
setGPIOOutput((byte)0x01);
setGPIOBit((byte)0x01, enabled);
mBiasTEnabled = enabled;
}
/**
* Indicates if the bias-t is enabled.
* @return true if enabled.
*/
public boolean isBiasT()
{
return mBiasTEnabled;
}
/** /**
* Overrides updates for measured frequency error so that the updates can also be applied to the * Overrides updates for measured frequency error so that the updates can also be applied to the
* frequency error correction manager for automatic PPM updating. * frequency error correction manager for automatic PPM updating.
@@ -437,8 +458,8 @@ public class RTL2832TunerController extends USBTunerController
*/ */
public void resetUSBBuffer() throws LibUsbException public void resetUSBBuffer() throws LibUsbException
{ {
writeRegister(Block.USB, Address.USB_EPA_CTL.getAddress(), 0x1002, 2); writeRegister(Block.USB, Address.USB_EPA_CTL, 0x1002, 2);
writeRegister(Block.USB, Address.USB_EPA_CTL.getAddress(), 0x0000, 2); writeRegister(Block.USB, Address.USB_EPA_CTL, 0x0000, 2);
} }
/** /**
@@ -448,13 +469,13 @@ public class RTL2832TunerController extends USBTunerController
public void initBaseband() throws LibUsbException public void initBaseband() throws LibUsbException
{ {
/* Initialize USB */ /* Initialize USB */
writeRegister(Block.USB, Address.USB_SYSCTL.getAddress(), 0x09, 1); writeRegister(Block.USB, Address.USB_SYSCTL, 0x09, 1);
writeRegister(Block.USB, Address.USB_EPA_MAXPKT.getAddress(), 0x0002, 2); writeRegister(Block.USB, Address.USB_EPA_MAXPKT, 0x0002, 2);
writeRegister(Block.USB, Address.USB_EPA_CTL.getAddress(), 0x1002, 2); writeRegister(Block.USB, Address.USB_EPA_CTL, 0x1002, 2);
/* Power on demod */ /* Power on demod */
writeRegister(Block.SYS, Address.DEMOD_CTL_1.getAddress(), 0x22, 1); writeRegister(Block.SYS, Address.DEMOD_CTL_1, 0x22, 1);
writeRegister(Block.SYS, Address.DEMOD_CTL.getAddress(), 0xE8, 1); writeRegister(Block.SYS, Address.DEMOD_CTL, 0xE8, 1);
/* Reset demod */ /* Reset demod */
writeDemodRegister(Page.ONE, (short) 0x01, 0x14, 1); //Bit 3 = soft reset writeDemodRegister(Page.ONE, (short) 0x01, 0x14, 1); //Bit 3 = soft reset
@@ -513,7 +534,7 @@ public class RTL2832TunerController extends USBTunerController
*/ */
private void deinitBaseband() throws IllegalArgumentException, UsbDisconnectedException private void deinitBaseband() throws IllegalArgumentException, UsbDisconnectedException
{ {
writeRegister(Block.SYS, Address.DEMOD_CTL.getAddress(), 0x20, 1); writeRegister(Block.SYS, Address.DEMOD_CTL, 0x20, 1);
} }
/** /**
@@ -527,7 +548,7 @@ public class RTL2832TunerController extends USBTunerController
private void setGPIOBit(byte bitMask, boolean enabled) throws LibUsbException private void setGPIOBit(byte bitMask, boolean enabled) throws LibUsbException
{ {
//Get current register value //Get current register value
int value = readRegister(Block.SYS, Address.GPO.getAddress(), 1); int value = readRegister(Block.SYS, Address.GPO, 1);
//Update the masked bits //Update the masked bits
if(enabled) if(enabled)
@@ -540,7 +561,7 @@ public class RTL2832TunerController extends USBTunerController
} }
//Write the change back to the device //Write the change back to the device
writeRegister(Block.SYS, Address.GPO.getAddress(), value, 1); writeRegister(Block.SYS, Address.GPO, value, 1);
} }
/** /**
@@ -553,16 +574,16 @@ public class RTL2832TunerController extends USBTunerController
private void setGPIOOutput(byte bitMask) throws LibUsbException private void setGPIOOutput(byte bitMask) throws LibUsbException
{ {
//Get current register value //Get current register value
int value = readRegister(Block.SYS, Address.GPD.getAddress(), 1); int value = readRegister(Block.SYS, Address.GPD, 1);
//Mask the value and rewrite it //Mask the value and rewrite it
writeRegister(Block.SYS, Address.GPO.getAddress(), value & ~bitMask, 1); writeRegister(Block.SYS, Address.GPO, value & ~bitMask, 1);
//Get current register value //Get current register value
value = readRegister(Block.SYS, Address.GPOE.getAddress(), 1); value = readRegister(Block.SYS, Address.GPOE, 1);
//Mask the value and rewrite it //Mask the value and rewrite it
writeRegister(Block.SYS, Address.GPOE.getAddress(), value | bitMask, 1); writeRegister(Block.SYS, Address.GPOE, value | bitMask, 1);
} }
/** /**
@@ -720,7 +741,7 @@ public class RTL2832TunerController extends USBTunerController
* @param length of value in bytes * @param length of value in bytes
* @throws LibUsbException on error * @throws LibUsbException on error
*/ */
private void writeRegister(Block block, short address, int value, int length) throws LibUsbException private void writeRegister(Block block, Address address, int value, int length) throws LibUsbException
{ {
ByteBuffer buffer = ByteBuffer.allocateDirect(length); ByteBuffer buffer = ByteBuffer.allocateDirect(length);
buffer.order(ByteOrder.BIG_ENDIAN); buffer.order(ByteOrder.BIG_ENDIAN);
@@ -740,7 +761,7 @@ public class RTL2832TunerController extends USBTunerController
} }
buffer.rewind(); buffer.rewind();
write(address, block, buffer); write(address.getAddress(), block, buffer);
} }
/** /**
@@ -751,10 +772,10 @@ public class RTL2832TunerController extends USBTunerController
* @return value read * @return value read
* @throws LibUsbException on error * @throws LibUsbException on error
*/ */
private int readRegister(Block block, short address, int length) throws LibUsbException private int readRegister(Block block, Address address, int length) throws LibUsbException
{ {
ByteBuffer buffer = ByteBuffer.allocateDirect(2); ByteBuffer buffer = ByteBuffer.allocateDirect(2);
read(address, block, buffer); read(address.getAddress(), block, buffer);
buffer.order(ByteOrder.LITTLE_ENDIAN); buffer.order(ByteOrder.LITTLE_ENDIAN);
if(length == 2) if(length == 2)
@@ -869,11 +890,11 @@ public class RTL2832TunerController extends USBTunerController
if(type == TunerTypeCheck.FC2580) if(type == TunerTypeCheck.FC2580)
{ {
return ((value & 0x7F) == type.getCheckValue()); return ((value & 0x7F) == (type.getCheckValue() & 0xFF));
} }
else else
{ {
return (value == type.getCheckValue()); return (value == (type.getCheckValue() & 0xFF));
} }
} }
catch(LibUsbException e) catch(LibUsbException e)
@@ -973,7 +994,7 @@ public class RTL2832TunerController extends USBTunerController
public void setSampleRateFrequencyCorrection(int ppm) throws SourceException 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) 0x3F, (offset & 0xFF), 1);
writeDemodRegister(Page.ONE, (short) 0x3E, (Integer.rotateRight(offset, 8) & 0xFF), 1); writeDemodRegister(Page.ONE, (short) 0x3E, (Integer.rotateRight(offset, 8) & 0xFF), 1);
/* Test to retune controller to apply frequency correction */ /* Test to retune controller to apply frequency correction */
@@ -983,7 +1004,7 @@ public class RTL2832TunerController extends USBTunerController
} }
catch(Exception e) 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);
} }
} }
@@ -1027,7 +1048,7 @@ public class RTL2832TunerController extends USBTunerController
try try
{ {
/* Tell the RTL-2832 to address the EEPROM */ /* Tell the RTL-2832 to address the EEPROM */
writeRegister(Block.I2C, EEPROM_ADDRESS, (byte) offset, 1); writeRegister(Block.I2C, Address.EEPROM, (byte) offset, 1);
} }
catch(LibUsbException e) catch(LibUsbException e)
{ {
@@ -1068,7 +1089,7 @@ public class RTL2832TunerController extends USBTunerController
} }
int offsetAndValue = Integer.rotateLeft((0xFF & offset), 8) | (0xFF & value); int offsetAndValue = Integer.rotateLeft((0xFF & offset), 8) | (0xFF & value);
writeRegister(Block.I2C, EEPROM_ADDRESS, offsetAndValue, 2); writeRegister(Block.I2C, Address.EEPROM, offsetAndValue, 2);
} }
public enum Address public enum Address
@@ -1093,7 +1114,8 @@ public class RTL2832TunerController extends USBTunerController
SYSINTE_1(0x3009), SYSINTE_1(0x3009),
SYSINTS_1(0x300A), SYSINTS_1(0x300A),
DEMOD_CTL_1(0x300B), DEMOD_CTL_1(0x300B),
IR_SUSPEND(0x300C); IR_SUSPEND(0x300C),
EEPROM(0xA0);
private int mAddress; private int mAddress;
@@ -1314,6 +1336,14 @@ public class RTL2832TunerController extends USBTunerController
getLabels(); 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() public boolean isValid()
{ {
return mData[0] != (byte)0x0 && mData[1] != (byte)0x0; return mData[0] != (byte)0x0 && mData[1] != (byte)0x0;
@@ -1479,6 +1509,15 @@ public class RTL2832TunerController extends USBTunerController
return mController.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. * Device handle for the tuner controller.
* @return * @return

View File

@@ -41,6 +41,7 @@ import javax.swing.JComboBox;
import javax.swing.JLabel; import javax.swing.JLabel;
import javax.swing.JOptionPane; import javax.swing.JOptionPane;
import javax.swing.JSeparator; import javax.swing.JSeparator;
import javax.swing.JToggleButton;
import javax.swing.SpinnerNumberModel; import javax.swing.SpinnerNumberModel;
import javax.usb.UsbException; import javax.usb.UsbException;
@@ -52,6 +53,7 @@ public class E4KTunerEditor extends TunerEditor<RTL2832Tuner, E4KTunerConfigurat
private final static Logger mLog = LoggerFactory.getLogger(E4KTunerEditor.class); private final static Logger mLog = LoggerFactory.getLogger(E4KTunerEditor.class);
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
private JButton mTunerInfoButton; private JButton mTunerInfoButton;
private JToggleButton mBiasTButton;
private JComboBox<SampleRate> mSampleRateCombo; private JComboBox<SampleRate> mSampleRateCombo;
private JComboBox<E4KGain> mMasterGainCombo; private JComboBox<E4KGain> mMasterGainCombo;
private JComboBox<E4KMixerGain> mMixerGainCombo; private JComboBox<E4KMixerGain> mMixerGainCombo;
@@ -95,7 +97,8 @@ public class E4KTunerEditor extends TunerEditor<RTL2832Tuner, E4KTunerConfigurat
add(getTunerInfoButton()); add(getTunerInfoButton());
add(new JLabel("Status:")); add(new JLabel("Status:"));
add(getTunerStatusLabel(), "wrap"); add(getTunerStatusLabel());
add(getBiasTButton(), "wrap");
add(getButtonPanel(), "span,align left"); add(getButtonPanel(), "span,align left");
@@ -144,6 +147,8 @@ public class E4KTunerEditor extends TunerEditor<RTL2832Tuner, E4KTunerConfigurat
if(hasTuner()) if(hasTuner())
{ {
getBiasTButton().setEnabled(true);
getBiasTButton().setSelected(getConfiguration().isBiasT());
getTunerInfoButton().setEnabled(true); getTunerInfoButton().setEnabled(true);
getSampleRateCombo().setEnabled(true); getSampleRateCombo().setEnabled(true);
getSampleRateCombo().setSelectedItem(getConfiguration().getSampleRate()); getSampleRateCombo().setSelectedItem(getConfiguration().getSampleRate());
@@ -174,6 +179,8 @@ public class E4KTunerEditor extends TunerEditor<RTL2832Tuner, E4KTunerConfigurat
} }
else else
{ {
getBiasTButton().setEnabled(false);
getBiasTButton().setSelected(false);
getTunerInfoButton().setEnabled(false); getTunerInfoButton().setEnabled(false);
getSampleRateCombo().setEnabled(false); getSampleRateCombo().setEnabled(false);
getMasterGainCombo().setEnabled(false); getMasterGainCombo().setEnabled(false);
@@ -187,6 +194,28 @@ public class E4KTunerEditor extends TunerEditor<RTL2832Tuner, E4KTunerConfigurat
setLoading(false); setLoading(false);
} }
/**
* Bias-T toggle button
* @return
*/
private JToggleButton getBiasTButton()
{
if(mBiasTButton == null)
{
mBiasTButton = new JToggleButton("Bias-T");
mBiasTButton.setEnabled(false);
mBiasTButton.addActionListener(e -> {
if(!isLoading())
{
getTuner().getController().setBiasT(mBiasTButton.isSelected());
save();
}
});
}
return mBiasTButton;
}
private JComboBox getIfGainCombo() private JComboBox getIfGainCombo()
{ {
if(mIfGainCombo == null) if(mIfGainCombo == null)
@@ -459,7 +488,7 @@ public class E4KTunerEditor extends TunerEditor<RTL2832Tuner, E4KTunerConfigurat
double value = ((SpinnerNumberModel)getFrequencyCorrectionSpinner().getModel()).getNumber().doubleValue(); double value = ((SpinnerNumberModel)getFrequencyCorrectionSpinner().getModel()).getNumber().doubleValue();
config.setFrequencyCorrection(value); config.setFrequencyCorrection(value);
config.setAutoPPMCorrectionEnabled(getAutoPPMCheckBox().isSelected()); config.setAutoPPMCorrectionEnabled(getAutoPPMCheckBox().isSelected());
config.setBiasT(getTuner().getController().isBiasT());
config.setSampleRate((SampleRate)getSampleRateCombo().getSelectedItem()); config.setSampleRate((SampleRate)getSampleRateCombo().getSelectedItem());
config.setMasterGain((E4KGain)getMasterGainCombo().getSelectedItem()); config.setMasterGain((E4KGain)getMasterGainCombo().getSelectedItem());
config.setMixerGain((E4KMixerGain)getMixerGainCombo().getSelectedItem()); config.setMixerGain((E4KMixerGain)getMixerGainCombo().getSelectedItem());

View File

@@ -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 * 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 * it under the terms of the GNU General Public License as published by
@@ -16,87 +16,78 @@
* along with this program. If not, see <http://www.gnu.org/licenses/> * along with this program. If not, see <http://www.gnu.org/licenses/>
* **************************************************************************** * ****************************************************************************
*/ */
package io.github.dsheirer.source.tuner.rtl.r820t; package io.github.dsheirer.source.tuner.rtl.r8x;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty; import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
import io.github.dsheirer.source.tuner.TunerType;
import io.github.dsheirer.source.tuner.rtl.RTL2832TunerConfiguration; import io.github.dsheirer.source.tuner.rtl.RTL2832TunerConfiguration;
/** /**
* RTL-2832 with embedded R820T tuner configuration * RTL-2832 with embedded R8xxx tuner configuration
*/ */
public class R820TTunerConfiguration extends RTL2832TunerConfiguration public abstract class R8xTunerConfiguration extends RTL2832TunerConfiguration
{ {
private R820TEmbeddedTuner.R820TGain mMasterGain = R820TEmbeddedTuner.R820TGain.GAIN_327; private R8xEmbeddedTuner.MasterGain mMasterMasterGain = R8xEmbeddedTuner.MasterGain.GAIN_327;
private R820TEmbeddedTuner.R820TMixerGain mMixerGain = R820TEmbeddedTuner.R820TMixerGain.GAIN_105; private R8xEmbeddedTuner.MixerGain mMixerGain = R8xEmbeddedTuner.MixerGain.GAIN_105;
private R820TEmbeddedTuner.R820TLNAGain mLNAGain = R820TEmbeddedTuner.R820TLNAGain.GAIN_222; private R8xEmbeddedTuner.LNAGain mLNAGain = R8xEmbeddedTuner.LNAGain.GAIN_222;
private R820TEmbeddedTuner.R820TVGAGain mVGAGain = R820TEmbeddedTuner.R820TVGAGain.GAIN_210; private R8xEmbeddedTuner.VGAGain mVGAGain = R8xEmbeddedTuner.VGAGain.GAIN_210;
/** /**
* Default constructor for JAXB * Default constructor for JAXB
*/ */
public R820TTunerConfiguration() public R8xTunerConfiguration()
{ {
} }
@JsonIgnore
@Override
public TunerType getTunerType()
{
return TunerType.RAFAELMICRO_R820T;
}
/** /**
* Constructs an instance * Constructs an instance
* *
* @param uniqueID for the tuner * @param uniqueID for the tuner
*/ */
public R820TTunerConfiguration(String uniqueID) public R8xTunerConfiguration(String uniqueID)
{ {
super(uniqueID); super(uniqueID);
} }
@JacksonXmlProperty(isAttribute = true, localName = "master_gain") @JacksonXmlProperty(isAttribute = true, localName = "master_gain")
public R820TEmbeddedTuner.R820TGain getMasterGain() public R8xEmbeddedTuner.MasterGain getMasterGain()
{ {
return mMasterGain; return mMasterMasterGain;
} }
public void setMasterGain(R820TEmbeddedTuner.R820TGain gain) public void setMasterGain(R8xEmbeddedTuner.MasterGain masterGain)
{ {
mMasterGain = gain; mMasterMasterGain = masterGain;
} }
@JacksonXmlProperty(isAttribute = true, localName = "mixer_gain") @JacksonXmlProperty(isAttribute = true, localName = "mixer_gain")
public R820TEmbeddedTuner.R820TMixerGain getMixerGain() public R8xEmbeddedTuner.MixerGain getMixerGain()
{ {
return mMixerGain; return mMixerGain;
} }
public void setMixerGain(R820TEmbeddedTuner.R820TMixerGain mixerGain) public void setMixerGain(R8xEmbeddedTuner.MixerGain mixerGain)
{ {
mMixerGain = mixerGain; mMixerGain = mixerGain;
} }
@JacksonXmlProperty(isAttribute = true, localName = "lna_gain") @JacksonXmlProperty(isAttribute = true, localName = "lna_gain")
public R820TEmbeddedTuner.R820TLNAGain getLNAGain() public R8xEmbeddedTuner.LNAGain getLNAGain()
{ {
return mLNAGain; return mLNAGain;
} }
public void setLNAGain(R820TEmbeddedTuner.R820TLNAGain lnaGain) public void setLNAGain(R8xEmbeddedTuner.LNAGain lnaGain)
{ {
mLNAGain = lnaGain; mLNAGain = lnaGain;
} }
@JacksonXmlProperty(isAttribute = true, localName = "vga_gain") @JacksonXmlProperty(isAttribute = true, localName = "vga_gain")
public R820TEmbeddedTuner.R820TVGAGain getVGAGain() public R8xEmbeddedTuner.VGAGain getVGAGain()
{ {
return mVGAGain; return mVGAGain;
} }
public void setVGAGain(R820TEmbeddedTuner.R820TVGAGain vgaGain) public void setVGAGain(R8xEmbeddedTuner.VGAGain vgaGain)
{ {
mVGAGain = vgaGain; mVGAGain = vgaGain;
} }

View File

@@ -16,7 +16,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/> * along with this program. If not, see <http://www.gnu.org/licenses/>
* **************************************************************************** * ****************************************************************************
*/ */
package io.github.dsheirer.source.tuner.rtl.r820t; package io.github.dsheirer.source.tuner.rtl.r8x;
import io.github.dsheirer.preference.UserPreferences; import io.github.dsheirer.preference.UserPreferences;
import io.github.dsheirer.source.SourceException; import io.github.dsheirer.source.SourceException;
@@ -25,10 +25,6 @@ import io.github.dsheirer.source.tuner.manager.TunerManager;
import io.github.dsheirer.source.tuner.rtl.RTL2832Tuner; import io.github.dsheirer.source.tuner.rtl.RTL2832Tuner;
import io.github.dsheirer.source.tuner.rtl.RTL2832TunerController; import io.github.dsheirer.source.tuner.rtl.RTL2832TunerController;
import io.github.dsheirer.source.tuner.rtl.RTL2832TunerController.SampleRate; import io.github.dsheirer.source.tuner.rtl.RTL2832TunerController.SampleRate;
import io.github.dsheirer.source.tuner.rtl.r820t.R820TEmbeddedTuner.R820TGain;
import io.github.dsheirer.source.tuner.rtl.r820t.R820TEmbeddedTuner.R820TLNAGain;
import io.github.dsheirer.source.tuner.rtl.r820t.R820TEmbeddedTuner.R820TMixerGain;
import io.github.dsheirer.source.tuner.rtl.r820t.R820TEmbeddedTuner.R820TVGAGain;
import io.github.dsheirer.source.tuner.ui.TunerEditor; import io.github.dsheirer.source.tuner.ui.TunerEditor;
import net.miginfocom.swing.MigLayout; import net.miginfocom.swing.MigLayout;
import org.slf4j.Logger; import org.slf4j.Logger;
@@ -40,20 +36,25 @@ import javax.swing.JComboBox;
import javax.swing.JLabel; import javax.swing.JLabel;
import javax.swing.JOptionPane; import javax.swing.JOptionPane;
import javax.swing.JSeparator; import javax.swing.JSeparator;
import javax.swing.JToggleButton;
import javax.swing.SpinnerNumberModel; import javax.swing.SpinnerNumberModel;
import javax.usb.UsbException; import javax.usb.UsbException;
public class R820TTunerEditor extends TunerEditor<RTL2832Tuner,R820TTunerConfiguration> /**
* R8xxx Tuner Editor
*/
public class R8xTunerEditor extends TunerEditor<RTL2832Tuner, R8xTunerConfiguration>
{ {
private final static Logger mLog = LoggerFactory.getLogger(R820TTunerEditor.class); private final static Logger mLog = LoggerFactory.getLogger(R8xTunerEditor.class);
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
private static final R820TGain DEFAULT_GAIN = R820TGain.GAIN_279; private static final R8xEmbeddedTuner.MasterGain DEFAULT_GAIN = R8xEmbeddedTuner.MasterGain.GAIN_279;
private JButton mTunerInfoButton; private JButton mTunerInfoButton;
private JToggleButton mBiasTButton;
private JComboBox<SampleRate> mSampleRateCombo; private JComboBox<SampleRate> mSampleRateCombo;
private JComboBox<R820TGain> mMasterGainCombo; private JComboBox<R8xEmbeddedTuner.MasterGain> mMasterGainCombo;
private JComboBox<R820TMixerGain> mMixerGainCombo; private JComboBox<R8xEmbeddedTuner.MixerGain> mMixerGainCombo;
private JComboBox<R820TLNAGain> mLNAGainCombo; private JComboBox<R8xEmbeddedTuner.LNAGain> mLNAGainCombo;
private JComboBox<R820TVGAGain> mVGAGainCombo; private JComboBox<R8xEmbeddedTuner.VGAGain> mVGAGainCombo;
/** /**
* Constructs an instance * Constructs an instance
@@ -61,7 +62,7 @@ public class R820TTunerEditor extends TunerEditor<RTL2832Tuner,R820TTunerConfigu
* @param tunerManager for saving configurations * @param tunerManager for saving configurations
* @param discoveredTuner to edit * @param discoveredTuner to edit
*/ */
public R820TTunerEditor(UserPreferences userPreferences, TunerManager tunerManager, DiscoveredTuner discoveredTuner) public R8xTunerEditor(UserPreferences userPreferences, TunerManager tunerManager, DiscoveredTuner discoveredTuner)
{ {
super(userPreferences, tunerManager, discoveredTuner); super(userPreferences, tunerManager, discoveredTuner);
init(); init();
@@ -69,19 +70,24 @@ public class R820TTunerEditor extends TunerEditor<RTL2832Tuner,R820TTunerConfigu
} }
/** /**
* Access the R820T embedded tuner * Access the R8xxx embedded tuner
* @return R820T tuner if there is a tuner, or null otherwise * @return R8xxx tuner if there is a tuner, or null otherwise
*/ */
private R820TEmbeddedTuner getEmbeddedTuner() private R8xEmbeddedTuner getEmbeddedTuner()
{ {
if(hasTuner()) if(hasTuner())
{ {
return (R820TEmbeddedTuner)getTuner().getController().getEmbeddedTuner(); return (R8xEmbeddedTuner) getTuner().getController().getEmbeddedTuner();
} }
return null; return null;
} }
private String getLogPrefix()
{
return getEmbeddedTuner().getTunerType().getLabel() + " Tuner Controller - ";
}
private void init() private void init()
{ {
setLayout(new MigLayout("fill,wrap 3", "[right][grow,fill][fill]", setLayout(new MigLayout("fill,wrap 3", "[right][grow,fill][fill]",
@@ -92,7 +98,8 @@ public class R820TTunerEditor extends TunerEditor<RTL2832Tuner,R820TTunerConfigu
add(getTunerInfoButton()); add(getTunerInfoButton());
add(new JLabel("Status:")); add(new JLabel("Status:"));
add(getTunerStatusLabel(), "wrap"); add(getTunerStatusLabel());
add(getBiasTButton(), "wrap");
add(getButtonPanel(), "span,align left"); add(getButtonPanel(), "span,align left");
@@ -145,15 +152,17 @@ public class R820TTunerEditor extends TunerEditor<RTL2832Tuner,R820TTunerConfigu
if(hasTuner()) if(hasTuner())
{ {
getBiasTButton().setEnabled(true);
getBiasTButton().setSelected(getConfiguration().isBiasT());
getTunerInfoButton().setEnabled(true); getTunerInfoButton().setEnabled(true);
getSampleRateCombo().setEnabled(true); getSampleRateCombo().setEnabled(true);
getSampleRateCombo().setSelectedItem(getConfiguration().getSampleRate()); getSampleRateCombo().setSelectedItem(getConfiguration().getSampleRate());
getMasterGainCombo().setEnabled(true); getMasterGainCombo().setEnabled(true);
R820TGain gain = getConfiguration().getMasterGain(); R8xEmbeddedTuner.MasterGain gain = getConfiguration().getMasterGain();
getMasterGainCombo().setEnabled(true); getMasterGainCombo().setEnabled(true);
getMasterGainCombo().setSelectedItem(gain); getMasterGainCombo().setSelectedItem(gain);
if(gain == R820TGain.MANUAL) if(gain == R8xEmbeddedTuner.MasterGain.MANUAL)
{ {
getMixerGainCombo().setSelectedItem(getConfiguration().getMixerGain()); getMixerGainCombo().setSelectedItem(getConfiguration().getMixerGain());
getMixerGainCombo().setEnabled(true); getMixerGainCombo().setEnabled(true);
@@ -178,6 +187,8 @@ public class R820TTunerEditor extends TunerEditor<RTL2832Tuner,R820TTunerConfigu
} }
else else
{ {
getBiasTButton().setEnabled(false);
getBiasTButton().setSelected(false);
getTunerInfoButton().setEnabled(false); getTunerInfoButton().setEnabled(false);
getSampleRateCombo().setEnabled(false); getSampleRateCombo().setEnabled(false);
getMasterGainCombo().setEnabled(false); getMasterGainCombo().setEnabled(false);
@@ -191,6 +202,28 @@ public class R820TTunerEditor extends TunerEditor<RTL2832Tuner,R820TTunerConfigu
setLoading(false); setLoading(false);
} }
/**
* Bias-T toggle button
* @return
*/
private JToggleButton getBiasTButton()
{
if(mBiasTButton == null)
{
mBiasTButton = new JToggleButton("Bias-T");
mBiasTButton.setEnabled(false);
mBiasTButton.addActionListener(e -> {
if(!isLoading())
{
getTuner().getController().setBiasT(mBiasTButton.isSelected());
save();
}
});
}
return mBiasTButton;
}
/** /**
* Hyperlink button that provides tuner information * Hyperlink button that provides tuner information
*/ */
@@ -200,7 +233,7 @@ public class R820TTunerEditor extends TunerEditor<RTL2832Tuner,R820TTunerConfigu
{ {
mTunerInfoButton = new JButton("Info"); mTunerInfoButton = new JButton("Info");
mTunerInfoButton.setEnabled(false); mTunerInfoButton.setEnabled(false);
mTunerInfoButton.addActionListener(e -> JOptionPane.showMessageDialog(R820TTunerEditor.this, mTunerInfoButton.addActionListener(e -> JOptionPane.showMessageDialog(R8xTunerEditor.this,
getTunerInfo(), "Tuner Info", JOptionPane.INFORMATION_MESSAGE)); getTunerInfo(), "Tuner Info", JOptionPane.INFORMATION_MESSAGE));
} }
@@ -211,13 +244,13 @@ public class R820TTunerEditor extends TunerEditor<RTL2832Tuner,R820TTunerConfigu
{ {
if(mVGAGainCombo == null) if(mVGAGainCombo == null)
{ {
mVGAGainCombo = new JComboBox<>(R820TVGAGain.values()); mVGAGainCombo = new JComboBox<>(R8xEmbeddedTuner.VGAGain.values());
mVGAGainCombo.setEnabled(false); mVGAGainCombo.setEnabled(false);
mVGAGainCombo.addActionListener(arg0 -> mVGAGainCombo.addActionListener(arg0 ->
{ {
try try
{ {
R820TVGAGain vgaGain = (R820TVGAGain) mVGAGainCombo.getSelectedItem(); R8xEmbeddedTuner.VGAGain vgaGain = (R8xEmbeddedTuner.VGAGain) mVGAGainCombo.getSelectedItem();
if(vgaGain == null) if(vgaGain == null)
{ {
@@ -233,9 +266,9 @@ public class R820TTunerEditor extends TunerEditor<RTL2832Tuner,R820TTunerConfigu
} }
catch(UsbException e) catch(UsbException e)
{ {
JOptionPane.showMessageDialog(R820TTunerEditor.this, "R820T Tuner Controller - " + JOptionPane.showMessageDialog(R8xTunerEditor.this, getLogPrefix() +
"couldn't apply the VGA gain setting - " + e.getLocalizedMessage()); "couldn't apply the VGA gain setting - " + e.getLocalizedMessage());
mLog.error("R820T Tuner Controller - couldn't apply VGA gain setting", e); mLog.error(getLogPrefix() + "couldn't apply VGA gain setting", e);
} }
}); });
mVGAGainCombo.setToolTipText("<html>VGA Gain. Set master gain to <b>MANUAL</b> to enable adjustment</html>"); mVGAGainCombo.setToolTipText("<html>VGA Gain. Set master gain to <b>MANUAL</b> to enable adjustment</html>");
@@ -248,13 +281,13 @@ public class R820TTunerEditor extends TunerEditor<RTL2832Tuner,R820TTunerConfigu
{ {
if(mLNAGainCombo == null) if(mLNAGainCombo == null)
{ {
mLNAGainCombo = new JComboBox<>(R820TLNAGain.values()); mLNAGainCombo = new JComboBox<>(R8xEmbeddedTuner.LNAGain.values());
mLNAGainCombo.setEnabled(false); mLNAGainCombo.setEnabled(false);
mLNAGainCombo.addActionListener(arg0 -> mLNAGainCombo.addActionListener(arg0 ->
{ {
try try
{ {
R820TLNAGain lnaGain = (R820TLNAGain) mLNAGainCombo.getSelectedItem(); R8xEmbeddedTuner.LNAGain lnaGain = (R8xEmbeddedTuner.LNAGain) mLNAGainCombo.getSelectedItem();
if(lnaGain == null) if(lnaGain == null)
{ {
@@ -270,9 +303,9 @@ public class R820TTunerEditor extends TunerEditor<RTL2832Tuner,R820TTunerConfigu
} }
catch(UsbException e) catch(UsbException e)
{ {
JOptionPane.showMessageDialog(R820TTunerEditor.this, "R820T Tuner Controller - " + JOptionPane.showMessageDialog(R8xTunerEditor.this, getLogPrefix() +
"couldn't apply the LNA gain setting - " + e.getLocalizedMessage()); "couldn't apply the LNA gain setting - " + e.getLocalizedMessage());
mLog.error("R820T Tuner Controller - couldn't apply LNA " + "gain setting - ", e); mLog.error(getLogPrefix() + "couldn't apply LNA " + "gain setting - ", e);
} }
}); });
mLNAGainCombo.setToolTipText("<html>LNA Gain. Set master gain to <b>MANUAL</b> to enable adjustment</html>"); mLNAGainCombo.setToolTipText("<html>LNA Gain. Set master gain to <b>MANUAL</b> to enable adjustment</html>");
@@ -300,11 +333,11 @@ public class R820TTunerEditor extends TunerEditor<RTL2832Tuner,R820TTunerConfigu
} }
catch(SourceException | LibUsbException eSampleRate) catch(SourceException | LibUsbException eSampleRate)
{ {
JOptionPane.showMessageDialog(R820TTunerEditor.this, JOptionPane.showMessageDialog(R8xTunerEditor.this,
"R820T Tuner Controller - couldn't apply the sample rate setting [" + getLogPrefix() + "couldn't apply the sample rate setting [" +
sampleRate.getLabel() + "] " + eSampleRate.getLocalizedMessage()); sampleRate.getLabel() + "] " + eSampleRate.getLocalizedMessage());
mLog.error("R820T Tuner Controller - couldn't apply sample rate setting [" + sampleRate.getLabel() + mLog.error(getLogPrefix() + "couldn't apply sample rate setting [" + sampleRate.getLabel() +
"]", eSampleRate); "]", eSampleRate);
} }
} }
@@ -318,7 +351,7 @@ public class R820TTunerEditor extends TunerEditor<RTL2832Tuner,R820TTunerConfigu
{ {
if(mMixerGainCombo == null) if(mMixerGainCombo == null)
{ {
mMixerGainCombo = new JComboBox<>(R820TMixerGain.values()); mMixerGainCombo = new JComboBox<>(R8xEmbeddedTuner.MixerGain.values());
mMixerGainCombo.setEnabled(false); mMixerGainCombo.setEnabled(false);
mMixerGainCombo.addActionListener(arg0 -> mMixerGainCombo.addActionListener(arg0 ->
{ {
@@ -326,7 +359,7 @@ public class R820TTunerEditor extends TunerEditor<RTL2832Tuner,R820TTunerConfigu
{ {
try try
{ {
R820TMixerGain mixerGain = (R820TMixerGain) mMixerGainCombo.getSelectedItem(); R8xEmbeddedTuner.MixerGain mixerGain = (R8xEmbeddedTuner.MixerGain) mMixerGainCombo.getSelectedItem();
if(mixerGain == null) if(mixerGain == null)
{ {
@@ -342,10 +375,10 @@ public class R820TTunerEditor extends TunerEditor<RTL2832Tuner,R820TTunerConfigu
} }
catch(UsbException e) catch(UsbException e)
{ {
JOptionPane.showMessageDialog(R820TTunerEditor.this, "R820T Tuner Controller - " + JOptionPane.showMessageDialog(R8xTunerEditor.this, getLogPrefix() +
"couldn't apply the mixer gain setting - " + e.getLocalizedMessage()); "couldn't apply the mixer gain setting - " + e.getLocalizedMessage());
mLog.error("R820T Tuner Controller - couldn't apply mixer gain setting - ", e); mLog.error(getLogPrefix() + "couldn't apply mixer gain setting - ", e);
} }
} }
}); });
@@ -359,7 +392,7 @@ public class R820TTunerEditor extends TunerEditor<RTL2832Tuner,R820TTunerConfigu
{ {
if(mMasterGainCombo == null) if(mMasterGainCombo == null)
{ {
mMasterGainCombo = new JComboBox<>(R820TGain.values()); mMasterGainCombo = new JComboBox<>(R8xEmbeddedTuner.MasterGain.values());
mMasterGainCombo.setEnabled(false); mMasterGainCombo.setEnabled(false);
mMasterGainCombo.addActionListener(arg0 -> mMasterGainCombo.addActionListener(arg0 ->
{ {
@@ -367,10 +400,10 @@ public class R820TTunerEditor extends TunerEditor<RTL2832Tuner,R820TTunerConfigu
{ {
try try
{ {
R820TGain gain = (R820TGain)getMasterGainCombo().getSelectedItem(); R8xEmbeddedTuner.MasterGain gain = (R8xEmbeddedTuner.MasterGain)getMasterGainCombo().getSelectedItem();
getEmbeddedTuner().setGain((R820TGain)getMasterGainCombo().getSelectedItem(), true); getEmbeddedTuner().setGain((R8xEmbeddedTuner.MasterGain)getMasterGainCombo().getSelectedItem(), true);
if(gain == R820TGain.MANUAL) if(gain == R8xEmbeddedTuner.MasterGain.MANUAL)
{ {
getMixerGainCombo().setSelectedItem(gain.getMixerGain()); getMixerGainCombo().setSelectedItem(gain.getMixerGain());
getMixerGainCombo().setEnabled(true); getMixerGainCombo().setEnabled(true);
@@ -397,9 +430,9 @@ public class R820TTunerEditor extends TunerEditor<RTL2832Tuner,R820TTunerConfigu
} }
catch(UsbException e) catch(UsbException e)
{ {
JOptionPane.showMessageDialog(R820TTunerEditor.this, "R820T Tuner Controller - " + JOptionPane.showMessageDialog(R8xTunerEditor.this, getLogPrefix() +
"couldn't apply the gain setting - " + e.getLocalizedMessage()); "couldn't apply the gain setting - " + e.getLocalizedMessage());
mLog.error("R820T Tuner Controller - couldn't apply gain setting - ", e); mLog.error(getLogPrefix() + "couldn't apply gain setting - ", e);
} }
} }
}); });
@@ -442,7 +475,7 @@ public class R820TTunerEditor extends TunerEditor<RTL2832Tuner,R820TTunerConfigu
{ {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
RTL2832TunerController.Descriptor descriptor = getTuner().getController().getDescriptor(); RTL2832TunerController.Descriptor descriptor = getTuner().getController().getDescriptor();
sb.append("<html><h3>RTL-2832 with R820T Tuner</h3>"); sb.append("<html><h3>RTL-2832 with " + getEmbeddedTuner().getTunerType().getLabel() + " Tuner</h3>");
if(descriptor == null) if(descriptor == null)
{ {
@@ -485,21 +518,21 @@ public class R820TTunerEditor extends TunerEditor<RTL2832Tuner,R820TTunerConfigu
{ {
if(hasConfiguration() && !isLoading()) if(hasConfiguration() && !isLoading())
{ {
R820TTunerConfiguration config = getConfiguration(); R8xTunerConfiguration config = getConfiguration();
config.setBiasT(getTuner().getController().isBiasT());
config.setFrequency(getFrequencyControl().getFrequency()); config.setFrequency(getFrequencyControl().getFrequency());
double value = ((SpinnerNumberModel)getFrequencyCorrectionSpinner().getModel()).getNumber().doubleValue(); double value = ((SpinnerNumberModel)getFrequencyCorrectionSpinner().getModel()).getNumber().doubleValue();
config.setFrequencyCorrection(value); config.setFrequencyCorrection(value);
config.setAutoPPMCorrectionEnabled(getAutoPPMCheckBox().isSelected()); config.setAutoPPMCorrectionEnabled(getAutoPPMCheckBox().isSelected());
config.setSampleRate((SampleRate)getSampleRateCombo().getSelectedItem()); config.setSampleRate((SampleRate)getSampleRateCombo().getSelectedItem());
R820TGain gain = (R820TGain)getMasterGainCombo().getSelectedItem(); R8xEmbeddedTuner.MasterGain gain = (R8xEmbeddedTuner.MasterGain)getMasterGainCombo().getSelectedItem();
config.setMasterGain(gain); config.setMasterGain(gain);
R820TMixerGain mixerGain = (R820TMixerGain)getMixerGainCombo().getSelectedItem(); R8xEmbeddedTuner.MixerGain mixerGain = (R8xEmbeddedTuner.MixerGain)getMixerGainCombo().getSelectedItem();
config.setMixerGain(mixerGain); config.setMixerGain(mixerGain);
R820TLNAGain lnaGain = (R820TLNAGain)getLNAGainCombo().getSelectedItem(); R8xEmbeddedTuner.LNAGain lnaGain = (R8xEmbeddedTuner.LNAGain)getLNAGainCombo().getSelectedItem();
config.setLNAGain(lnaGain); config.setLNAGain(lnaGain);
R820TVGAGain vgaGain = (R820TVGAGain)getVGAGainCombo().getSelectedItem(); R8xEmbeddedTuner.VGAGain vgaGain = (R8xEmbeddedTuner.VGAGain)getVGAGainCombo().getSelectedItem();
config.setVGAGain(vgaGain); config.setVGAGain(vgaGain);
saveConfiguration(); saveConfiguration();
} }

View File

@@ -0,0 +1,85 @@
/*
* *****************************************************************************
* 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
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
* ****************************************************************************
*/
package io.github.dsheirer.source.tuner.rtl.r8x.r820t;
import io.github.dsheirer.source.SourceException;
import io.github.dsheirer.source.tuner.TunerType;
import io.github.dsheirer.source.tuner.rtl.RTL2832TunerController;
import io.github.dsheirer.source.tuner.rtl.r8x.R8xEmbeddedTuner;
import javax.usb.UsbException;
/**
* Rafael Micro R820T and R820T2 Embedded Tuner implementation
*/
public class R820TEmbeddedTuner extends R8xEmbeddedTuner
{
private static final byte I2C_ADDRESS = (byte) 0x34;
private static final int VCO_POWER_REF = 2;
/**
* Constructs an instance
* @param adapter for accessing RTL2832USBController interfaces
*/
public R820TEmbeddedTuner(RTL2832TunerController.ControllerAdapter adapter)
{
super(adapter, VCO_POWER_REF);
}
@Override
public TunerType getTunerType()
{
return TunerType.RAFAELMICRO_R820T;
}
@Override
public byte getI2CAddress()
{
return I2C_ADDRESS;
}
/**
* Sets the center frequency. Setting the frequency is a two-part process
* of setting the multiplexer and then setting the Oscillator (PLL).
*/
@Override
public synchronized void setTunedFrequency(long frequency) throws SourceException
{
getAdapter().getLock().lock();
try
{
getAdapter().enableI2CRepeater();
boolean controlI2C = false;
long offsetFrequency = frequency + IF_FREQUENCY;
setMux(offsetFrequency, controlI2C);
setPLL(offsetFrequency, controlI2C);
getAdapter().disableI2CRepeater();
}
catch(UsbException e)
{
throw new SourceException("R820TTunerController - exception while setting frequency [" + frequency + "] - " +
e.getLocalizedMessage());
}
finally
{
getAdapter().getLock().unlock();
}
}
}

View File

@@ -0,0 +1,52 @@
/*
* *****************************************************************************
* 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
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
* ****************************************************************************
*/
package io.github.dsheirer.source.tuner.rtl.r8x.r820t;
import com.fasterxml.jackson.annotation.JsonIgnore;
import io.github.dsheirer.source.tuner.TunerType;
import io.github.dsheirer.source.tuner.rtl.r8x.R8xTunerConfiguration;
/**
* RTL-2832 with embedded R820T tuner configuration
*/
public class R820TTunerConfiguration extends R8xTunerConfiguration
{
/**
* Empty constructor for Jackson serialization
*/
public R820TTunerConfiguration()
{
}
/**
* Constructs an instance
* @param uniqueId for the tuner
*/
public R820TTunerConfiguration(String uniqueId)
{
super(uniqueId);
}
@JsonIgnore
@Override
public TunerType getTunerType()
{
return TunerType.RAFAELMICRO_R820T;
}
}

View File

@@ -0,0 +1,127 @@
/*
* *****************************************************************************
* 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
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
* ****************************************************************************
*/
package io.github.dsheirer.source.tuner.rtl.r8x.r828d;
import io.github.dsheirer.source.SourceException;
import io.github.dsheirer.source.tuner.TunerType;
import io.github.dsheirer.source.tuner.rtl.RTL2832TunerController;
import io.github.dsheirer.source.tuner.rtl.r8x.R8xEmbeddedTuner;
import javax.usb.UsbException;
/**
* Rafael Micro R828D Embedded Tuner implementation
*/
public class R828DEmbeddedTuner extends R8xEmbeddedTuner
{
private static final byte I2C_ADDRESS = (byte) 0x74;
private static final int VCO_POWER_REF = 1;
/**
* RTL-SDR.com blog V4 dongle indicator.
*/
private final boolean mIsV4Dongle;
/**
* Constructs an instance
* @param adapter for accessing RTL2832USBController interfaces
*/
public R828DEmbeddedTuner(RTL2832TunerController.ControllerAdapter adapter)
{
super(adapter, VCO_POWER_REF);
//Set flag to indicate if this is a V4 dongle that supports notch filtering.
mIsV4Dongle = adapter.isV4Dongle();
}
@Override
public TunerType getTunerType()
{
return TunerType.RAFAELMICRO_R828D;
}
@Override
public byte getI2CAddress()
{
return I2C_ADDRESS;
}
/**
* Sets the center frequency. Setting the frequency is a two-part process
* of setting the multiplexer and then setting the Oscillator (PLL).
*/
@Override
public synchronized void setTunedFrequency(long frequency) throws SourceException
{
getAdapter().getLock().lock();
try
{
getAdapter().enableI2CRepeater();
boolean controlI2C = false;
long offsetFrequency = frequency + IF_FREQUENCY;
setMux(offsetFrequency, controlI2C);
setPLL(offsetFrequency, controlI2C);
//Select the RF input
if(mIsV4Dongle)
{
//Disable notch filtering if frequency falls into a notched band, otherwise enable it.
boolean isNotchFilterFrequency = (frequency < 2_200_000) ||
(85_000_000 < frequency && frequency < 112_000_000) ||
(172_000_000 < frequency && frequency < 242_000_000);
writeRegister(Register.DRAIN, isNotchFilterFrequency ? (byte)0x00 : (byte)0x08, controlI2C);
if(frequency <= 28_800_000) //Use cable 2 input
{
writeRegister(Register.INPUT_SELECTOR_AIR, (byte)0x20, controlI2C); //disabled
writeRegister(Register.INPUT_SELECTOR_CABLE_1, (byte)0x00, controlI2C); //disabled
writeRegister(Register.INPUT_SELECTOR_CABLE_2, (byte)0x08, controlI2C); //enabled
}
else if(frequency < 250_000_000)
{
writeRegister(Register.INPUT_SELECTOR_AIR, (byte)0x20, controlI2C); //disabled
writeRegister(Register.INPUT_SELECTOR_CABLE_1, (byte)0x40, controlI2C); //enabled
writeRegister(Register.INPUT_SELECTOR_CABLE_2, (byte)0x00, controlI2C); //disabled
}
else
{
writeRegister(Register.INPUT_SELECTOR_AIR, (byte)0x00, controlI2C); //enabled
writeRegister(Register.INPUT_SELECTOR_CABLE_1, (byte)0x00, controlI2C); //disabled
writeRegister(Register.INPUT_SELECTOR_CABLE_2, (byte)0x00, controlI2C); //disabled
}
}
else
{
byte air_cable_in = (frequency > 345_000_000) ? (byte)0x00 : (byte)0x60;
writeRegister(Register.INPUT_SELECTOR_AIR_AND_CABLE_1, air_cable_in, controlI2C);
}
getAdapter().disableI2CRepeater();
}
catch(UsbException e)
{
throw new SourceException("R820TTunerController - exception while setting frequency [" + frequency + "] - " +
e.getLocalizedMessage());
}
finally
{
getAdapter().getLock().unlock();
}
}
}

View File

@@ -0,0 +1,52 @@
/*
* *****************************************************************************
* 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
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
* ****************************************************************************
*/
package io.github.dsheirer.source.tuner.rtl.r8x.r828d;
import com.fasterxml.jackson.annotation.JsonIgnore;
import io.github.dsheirer.source.tuner.TunerType;
import io.github.dsheirer.source.tuner.rtl.r8x.R8xTunerConfiguration;
/**
* RTL-2832 with embedded R828D tuner configuration
*/
public class R828DTunerConfiguration extends R8xTunerConfiguration
{
/**
* Empty constructor for Jackson serialization
*/
public R828DTunerConfiguration()
{
}
/**
* Constructs an instance
* @param uniqueId for the tuner
*/
public R828DTunerConfiguration(String uniqueId)
{
super(uniqueId);
}
@JsonIgnore
@Override
public TunerType getTunerType()
{
return TunerType.RAFAELMICRO_R828D;
}
}