mirror of
https://github.com/DSheirer/sdrtrunk.git
synced 2026-11-15 01:57:39 -05:00
Co-authored-by: Denny <denny@denny-desktop>
This commit is contained in:
@@ -19,6 +19,8 @@ import io.github.dsheirer.source.SourceException;
|
|||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
import java.text.DecimalFormat;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Monitors measured frequency error PPM values from the tuner and (when enabled) applies the current
|
* Monitors measured frequency error PPM values from the tuner and (when enabled) applies the current
|
||||||
* error measurement to the tuner controller to adjust the tuner's PPM and align the frequency value.
|
* error measurement to the tuner controller to adjust the tuner's PPM and align the frequency value.
|
||||||
@@ -32,6 +34,7 @@ public class FrequencyErrorCorrectionManager
|
|||||||
private long mObservationPeriodStart;
|
private long mObservationPeriodStart;
|
||||||
private double mPPMRequired;
|
private double mPPMRequired;
|
||||||
private boolean mEnabled = true;
|
private boolean mEnabled = true;
|
||||||
|
private DecimalFormat mDecimalFormat = new DecimalFormat("0.0");
|
||||||
private TunerController mTunerController;
|
private TunerController mTunerController;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -72,7 +75,7 @@ public class FrequencyErrorCorrectionManager
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
mLog.info("Auto-Correcting Tuner PPM to [" + frequencyCorrection + "]");
|
mLog.info("Auto-Correcting Tuner PPM to [" + mDecimalFormat.format(frequencyCorrection) + "]");
|
||||||
|
|
||||||
mTunerController.setFrequencyCorrection(frequencyCorrection);
|
mTunerController.setFrequencyCorrection(frequencyCorrection);
|
||||||
reset();
|
reset();
|
||||||
|
|||||||
@@ -41,6 +41,7 @@ import java.text.DecimalFormat;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.EnumSet;
|
import java.util.EnumSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.concurrent.locks.ReentrantLock;
|
||||||
|
|
||||||
public class AirspyTunerController extends USBTunerController
|
public class AirspyTunerController extends USBTunerController
|
||||||
{
|
{
|
||||||
@@ -79,6 +80,7 @@ public class AirspyTunerController extends USBTunerController
|
|||||||
private AirspyDeviceInformation mDeviceInfo;
|
private AirspyDeviceInformation mDeviceInfo;
|
||||||
private List<AirspySampleRate> mSampleRates = new ArrayList<>();
|
private List<AirspySampleRate> mSampleRates = new ArrayList<>();
|
||||||
private int mSampleRate = 0;
|
private int mSampleRate = 0;
|
||||||
|
private ReentrantLock mLock = new ReentrantLock();
|
||||||
private USBTransferProcessor mUSBTransferProcessor;
|
private USBTransferProcessor mUSBTransferProcessor;
|
||||||
|
|
||||||
public AirspyTunerController(Device device) throws SourceException
|
public AirspyTunerController(Device device) throws SourceException
|
||||||
@@ -347,32 +349,35 @@ public class AirspyTunerController extends USBTunerController
|
|||||||
@Override
|
@Override
|
||||||
public void setTunedFrequency(long frequency) throws SourceException
|
public void setTunedFrequency(long frequency) throws SourceException
|
||||||
{
|
{
|
||||||
if(FREQUENCY_MIN <= frequency && frequency <= FREQUENCY_MAX)
|
mLock.lock();
|
||||||
|
|
||||||
|
try
|
||||||
{
|
{
|
||||||
ByteBuffer buffer = ByteBuffer.allocateDirect(4);
|
if(FREQUENCY_MIN <= frequency && frequency <= FREQUENCY_MAX)
|
||||||
|
|
||||||
buffer.order(ByteOrder.LITTLE_ENDIAN);
|
|
||||||
|
|
||||||
buffer.putInt((int) frequency);
|
|
||||||
|
|
||||||
buffer.rewind();
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
{
|
||||||
write(Command.SET_FREQUENCY, 0, 0, buffer);
|
ByteBuffer buffer = ByteBuffer.allocateDirect(4);
|
||||||
|
buffer.order(ByteOrder.LITTLE_ENDIAN);
|
||||||
|
buffer.putInt((int) frequency);
|
||||||
|
buffer.rewind();
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
write(Command.SET_FREQUENCY, 0, 0, buffer);
|
||||||
|
}
|
||||||
|
catch(UsbException e)
|
||||||
|
{
|
||||||
|
mLog.error("error setting frequency [" + frequency + "]", e);
|
||||||
|
throw new SourceException("error setting frequency [" + frequency + "]", e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch(UsbException e)
|
else
|
||||||
{
|
{
|
||||||
mLog.error("error setting frequency [" + frequency + "]", e);
|
throw new SourceException("Frequency [" + frequency + "] outside " + "of tunable range " + FREQUENCY_MIN + "-" + FREQUENCY_MAX);
|
||||||
|
|
||||||
throw new SourceException("error setting frequency [" +
|
|
||||||
frequency + "]", e);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
finally
|
||||||
{
|
{
|
||||||
throw new SourceException("Frequency [" + frequency + "] outside "
|
mLock.unlock();
|
||||||
+ "of tunable range " + FREQUENCY_MIN + "-" + FREQUENCY_MAX);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -494,14 +499,22 @@ public class AirspyTunerController extends USBTunerController
|
|||||||
* @throws LibUsbException on unsuccessful read operation
|
* @throws LibUsbException on unsuccessful read operation
|
||||||
* @throws UsbException on USB error
|
* @throws UsbException on USB error
|
||||||
*/
|
*/
|
||||||
public void setMixerAGC(boolean enabled)
|
public void setMixerAGC(boolean enabled) throws LibUsbException, UsbException
|
||||||
throws LibUsbException, UsbException
|
|
||||||
{
|
{
|
||||||
int result = readByte(Command.SET_MIXER_AGC, 0, (enabled ? 1 : 0), true);
|
mLock.lock();
|
||||||
|
|
||||||
if(result != LibUsb.SUCCESS)
|
try
|
||||||
{
|
{
|
||||||
throw new UsbException("Couldnt set mixer AGC enabled: " + enabled);
|
int result = readByte(Command.SET_MIXER_AGC, 0, (enabled ? 1 : 0), true);
|
||||||
|
|
||||||
|
if(result != LibUsb.SUCCESS)
|
||||||
|
{
|
||||||
|
throw new UsbException("Couldnt set mixer AGC enabled: " + enabled);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
mLock.unlock();;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -514,11 +527,20 @@ public class AirspyTunerController extends USBTunerController
|
|||||||
*/
|
*/
|
||||||
public void setLNAAGC(boolean enabled) throws LibUsbException, UsbException
|
public void setLNAAGC(boolean enabled) throws LibUsbException, UsbException
|
||||||
{
|
{
|
||||||
int result = readByte(Command.SET_LNA_AGC, 0, (enabled ? 1 : 0), true);
|
mLock.lock();
|
||||||
|
|
||||||
if(result != LibUsb.SUCCESS)
|
try
|
||||||
{
|
{
|
||||||
throw new UsbException("Couldnt set LNA AGC enabled: " + enabled);
|
int result = readByte(Command.SET_LNA_AGC, 0, (enabled ? 1 : 0), true);
|
||||||
|
|
||||||
|
if(result != LibUsb.SUCCESS)
|
||||||
|
{
|
||||||
|
throw new UsbException("Couldnt set LNA AGC enabled: " + enabled);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
mLock.unlock();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -542,22 +564,30 @@ public class AirspyTunerController extends USBTunerController
|
|||||||
* @throws UsbException on error in USB transfer
|
* @throws UsbException on error in USB transfer
|
||||||
* @throws IllegalArgumentException if gain value is invalid
|
* @throws IllegalArgumentException if gain value is invalid
|
||||||
*/
|
*/
|
||||||
public void setLNAGain(int gain)
|
public void setLNAGain(int gain) throws LibUsbException, UsbException, IllegalArgumentException
|
||||||
throws LibUsbException, UsbException, IllegalArgumentException
|
|
||||||
{
|
{
|
||||||
if(LNA_GAIN_MIN <= gain && gain <= LNA_GAIN_MAX)
|
mLock.lock();
|
||||||
{
|
|
||||||
int result = readByte(Command.SET_LNA_GAIN, 0, gain, true);
|
|
||||||
|
|
||||||
if(result != LibUsb.SUCCESS)
|
try
|
||||||
|
{
|
||||||
|
if(LNA_GAIN_MIN <= gain && gain <= LNA_GAIN_MAX)
|
||||||
{
|
{
|
||||||
throw new UsbException("Couldnt set LNA gain to: " + gain);
|
int result = readByte(Command.SET_LNA_GAIN, 0, gain, true);
|
||||||
|
|
||||||
|
if(result != LibUsb.SUCCESS)
|
||||||
|
{
|
||||||
|
throw new UsbException("Couldnt set LNA gain to: " + gain);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw new IllegalArgumentException("LNA gain value [" + gain +
|
||||||
|
"] is outside value range: " + LNA_GAIN_MIN + "-" + LNA_GAIN_MAX);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
finally
|
||||||
{
|
{
|
||||||
throw new IllegalArgumentException("LNA gain value [" + gain +
|
mLock.unlock();
|
||||||
"] is outside value range: " + LNA_GAIN_MIN + "-" + LNA_GAIN_MAX);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -569,22 +599,30 @@ public class AirspyTunerController extends USBTunerController
|
|||||||
* @throws UsbException on error in USB transfer
|
* @throws UsbException on error in USB transfer
|
||||||
* @throws IllegalArgumentException if gain value is invalid
|
* @throws IllegalArgumentException if gain value is invalid
|
||||||
*/
|
*/
|
||||||
public void setMixerGain(int gain)
|
public void setMixerGain(int gain) throws LibUsbException, UsbException, IllegalArgumentException
|
||||||
throws LibUsbException, UsbException, IllegalArgumentException
|
|
||||||
{
|
{
|
||||||
if(MIXER_GAIN_MIN <= gain && gain <= MIXER_GAIN_MAX)
|
mLock.lock();
|
||||||
{
|
|
||||||
int result = readByte(Command.SET_MIXER_GAIN, 0, gain, true);
|
|
||||||
|
|
||||||
if(result != LibUsb.SUCCESS)
|
try
|
||||||
|
{
|
||||||
|
if(MIXER_GAIN_MIN <= gain && gain <= MIXER_GAIN_MAX)
|
||||||
{
|
{
|
||||||
throw new UsbException("Couldnt set mixer gain to: " + gain);
|
int result = readByte(Command.SET_MIXER_GAIN, 0, gain, true);
|
||||||
|
|
||||||
|
if(result != LibUsb.SUCCESS)
|
||||||
|
{
|
||||||
|
throw new UsbException("Couldnt set mixer gain to: " + gain);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw new IllegalArgumentException("Mixer gain value [" + gain +
|
||||||
|
"] is outside value range: " + MIXER_GAIN_MIN + "-" + MIXER_GAIN_MAX);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
finally
|
||||||
{
|
{
|
||||||
throw new IllegalArgumentException("Mixer gain value [" + gain +
|
mLock.unlock();
|
||||||
"] is outside value range: " + MIXER_GAIN_MIN + "-" + MIXER_GAIN_MAX);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -596,22 +634,30 @@ public class AirspyTunerController extends USBTunerController
|
|||||||
* @throws UsbException on error in USB transfer
|
* @throws UsbException on error in USB transfer
|
||||||
* @throws IllegalArgumentException if gain value is invalid
|
* @throws IllegalArgumentException if gain value is invalid
|
||||||
*/
|
*/
|
||||||
public void setIFGain(int gain)
|
public void setIFGain(int gain) throws LibUsbException, UsbException, IllegalArgumentException
|
||||||
throws LibUsbException, UsbException, IllegalArgumentException
|
|
||||||
{
|
{
|
||||||
if(IF_GAIN_MIN <= gain && gain <= IF_GAIN_MAX)
|
mLock.lock();
|
||||||
{
|
|
||||||
int result = readByte(Command.SET_VGA_GAIN, 0, gain, true);
|
|
||||||
|
|
||||||
if(result != LibUsb.SUCCESS)
|
try
|
||||||
|
{
|
||||||
|
if(IF_GAIN_MIN <= gain && gain <= IF_GAIN_MAX)
|
||||||
{
|
{
|
||||||
throw new UsbException("Couldnt set VGA gain to: " + gain);
|
int result = readByte(Command.SET_VGA_GAIN, 0, gain, true);
|
||||||
|
|
||||||
|
if(result != LibUsb.SUCCESS)
|
||||||
|
{
|
||||||
|
throw new UsbException("Couldnt set VGA gain to: " + gain);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw new IllegalArgumentException("VGA gain value [" + gain +
|
||||||
|
"] is outside value range: " + IF_GAIN_MIN + "-" + IF_GAIN_MAX);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
finally
|
||||||
{
|
{
|
||||||
throw new IllegalArgumentException("VGA gain value [" + gain +
|
mLock.unlock();
|
||||||
"] is outside value range: " + IF_GAIN_MIN + "-" + IF_GAIN_MAX);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -42,6 +42,7 @@ import javax.usb.UsbException;
|
|||||||
import java.nio.ByteBuffer;
|
import java.nio.ByteBuffer;
|
||||||
import java.nio.ByteOrder;
|
import java.nio.ByteOrder;
|
||||||
import java.nio.IntBuffer;
|
import java.nio.IntBuffer;
|
||||||
|
import java.util.concurrent.locks.ReentrantLock;
|
||||||
|
|
||||||
public abstract class FCDTunerController extends TunerController
|
public abstract class FCDTunerController extends TunerController
|
||||||
{
|
{
|
||||||
@@ -60,6 +61,7 @@ public abstract class FCDTunerController extends TunerController
|
|||||||
|
|
||||||
private FCDConfiguration mConfiguration = new FCDConfiguration();
|
private FCDConfiguration mConfiguration = new FCDConfiguration();
|
||||||
protected ComplexMixer mComplexMixer;
|
protected ComplexMixer mComplexMixer;
|
||||||
|
protected ReentrantLock mLock = new ReentrantLock();
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -302,6 +304,8 @@ public abstract class FCDTunerController extends TunerController
|
|||||||
*/
|
*/
|
||||||
public void setTunedFrequency(long frequency) throws SourceException
|
public void setTunedFrequency(long frequency) throws SourceException
|
||||||
{
|
{
|
||||||
|
mLock.lock();
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
send(FCDCommand.APP_SET_FREQUENCY_HZ, frequency);
|
send(FCDCommand.APP_SET_FREQUENCY_HZ, frequency);
|
||||||
@@ -311,6 +315,10 @@ public abstract class FCDTunerController extends TunerController
|
|||||||
throw new SourceException("Couldn't set FCD Local " +
|
throw new SourceException("Couldn't set FCD Local " +
|
||||||
"Oscillator Frequency [" + frequency + "]", e);
|
"Oscillator Frequency [" + frequency + "]", e);
|
||||||
}
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
mLock.unlock();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -176,10 +176,18 @@ public class FCD1TunerController extends FCDTunerController
|
|||||||
* @throws UsbException
|
* @throws UsbException
|
||||||
* @throws UsbClaimException
|
* @throws UsbClaimException
|
||||||
*/
|
*/
|
||||||
public void setLNAGain(LNAGain gain)
|
public void setLNAGain(LNAGain gain) throws UsbException, UsbClaimException
|
||||||
throws UsbException, UsbClaimException
|
|
||||||
{
|
{
|
||||||
send(FCDCommand.APP_SET_LNA_GAIN, gain.getSetting());
|
mLock.lock();
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
send(FCDCommand.APP_SET_LNA_GAIN, gain.getSetting());
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
mLock.unlock();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -269,7 +277,16 @@ public class FCD1TunerController extends FCDTunerController
|
|||||||
//Merge the results
|
//Merge the results
|
||||||
long correction = longGain | phase;
|
long correction = longGain | phase;
|
||||||
|
|
||||||
send(FCDCommand.APP_SET_IQ_CORRECTION, correction);
|
mLock.lock();
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
send(FCDCommand.APP_SET_IQ_CORRECTION, correction);
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
mLock.unlock();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -402,15 +419,16 @@ public class FCD1TunerController extends FCDTunerController
|
|||||||
//Merge the results
|
//Merge the results
|
||||||
long correction = shiftedQuadrature | maskedInphase;
|
long correction = shiftedQuadrature | maskedInphase;
|
||||||
|
|
||||||
// Log.info( "FCD1: setting iq correction," +
|
mLock.lock();
|
||||||
// " inphase:" + inphase +
|
|
||||||
// " masked inphase:" + maskedInphase +
|
|
||||||
// " quad:" + quadrature +
|
|
||||||
// " masked quad:" + maskedQuadrature +
|
|
||||||
// " shifted quadrature:" + shiftedQuadrature +
|
|
||||||
// " correction:" + correction );
|
|
||||||
|
|
||||||
send(FCDCommand.APP_SET_DC_CORRECTION, correction);
|
try
|
||||||
|
{
|
||||||
|
send(FCDCommand.APP_SET_DC_CORRECTION, correction);
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
mLock.unlock();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void getDCIQCorrection() throws UsbClaimException,
|
private void getDCIQCorrection() throws UsbClaimException,
|
||||||
@@ -464,10 +482,18 @@ public class FCD1TunerController extends FCDTunerController
|
|||||||
return mLNAEnhance;
|
return mLNAEnhance;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setLNAEnhance(LNAEnhance enhance)
|
public void setLNAEnhance(LNAEnhance enhance) throws UsbClaimException, UsbException
|
||||||
throws UsbClaimException, UsbException
|
|
||||||
{
|
{
|
||||||
send(FCDCommand.APP_SET_LNA_ENHANCE, enhance.getSetting());
|
mLock.lock();
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
send(FCDCommand.APP_SET_LNA_ENHANCE, enhance.getSetting());
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
mLock.unlock();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void getMixerGainSetting() throws UsbClaimException, UsbException
|
private void getMixerGainSetting() throws UsbClaimException, UsbException
|
||||||
@@ -488,7 +514,16 @@ public class FCD1TunerController extends FCDTunerController
|
|||||||
|
|
||||||
public void setMixerGain(MixerGain gain) throws UsbClaimException, UsbException
|
public void setMixerGain(MixerGain gain) throws UsbClaimException, UsbException
|
||||||
{
|
{
|
||||||
send(FCDCommand.APP_SET_MIXER_GAIN, gain.getSetting());
|
mLock.lock();
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
send(FCDCommand.APP_SET_MIXER_GAIN, gain.getSetting());
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
mLock.unlock();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum Block
|
public enum Block
|
||||||
|
|||||||
@@ -83,6 +83,8 @@ public class FCD2TunerController extends FCDTunerController
|
|||||||
|
|
||||||
public void setLNAGain(boolean enabled) throws SourceException
|
public void setLNAGain(boolean enabled) throws SourceException
|
||||||
{
|
{
|
||||||
|
mLock.lock();
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
send(FCDCommand.APP_SET_LNA_GAIN, enabled ? 1 : 0);
|
send(FCDCommand.APP_SET_LNA_GAIN, enabled ? 1 : 0);
|
||||||
@@ -91,10 +93,16 @@ public class FCD2TunerController extends FCDTunerController
|
|||||||
{
|
{
|
||||||
throw new SourceException("error while setting LNA Gain", e);
|
throw new SourceException("error while setting LNA Gain", e);
|
||||||
}
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
mLock.unlock();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setMixerGain(boolean enabled) throws SourceException
|
public void setMixerGain(boolean enabled) throws SourceException
|
||||||
{
|
{
|
||||||
|
mLock.lock();
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
send(FCDCommand.APP_SET_MIXER_GAIN, enabled ? 1 : 0);
|
send(FCDCommand.APP_SET_MIXER_GAIN, enabled ? 1 : 0);
|
||||||
@@ -103,6 +111,10 @@ public class FCD2TunerController extends FCDTunerController
|
|||||||
{
|
{
|
||||||
throw new SourceException("error while setting Mixer Gain", e);
|
throw new SourceException("error while setting Mixer Gain", e);
|
||||||
}
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
mLock.unlock();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -159,6 +171,8 @@ public class FCD2TunerController extends FCDTunerController
|
|||||||
|
|
||||||
public void setDCCorrection(int value)
|
public void setDCCorrection(int value)
|
||||||
{
|
{
|
||||||
|
mLock.lock();
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
send(FCDCommand.APP_SET_DC_CORRECTION, value);
|
send(FCDCommand.APP_SET_DC_CORRECTION, value);
|
||||||
@@ -167,6 +181,10 @@ public class FCD2TunerController extends FCDTunerController
|
|||||||
{
|
{
|
||||||
mLog.error("error setting dc correction to [" + value + "]", e);
|
mLog.error("error setting dc correction to [" + value + "]", e);
|
||||||
}
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
mLock.unlock();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getIQCorrection()
|
public int getIQCorrection()
|
||||||
@@ -191,6 +209,8 @@ public class FCD2TunerController extends FCDTunerController
|
|||||||
|
|
||||||
public void setIQCorrection(int value)
|
public void setIQCorrection(int value)
|
||||||
{
|
{
|
||||||
|
mLock.lock();
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
send(FCDCommand.APP_SET_IQ_CORRECTION, value);
|
send(FCDCommand.APP_SET_IQ_CORRECTION, value);
|
||||||
@@ -199,5 +219,9 @@ public class FCD2TunerController extends FCDTunerController
|
|||||||
{
|
{
|
||||||
mLog.error("error setting IQ correction to [" + value + "]", e);
|
mLog.error("error setting IQ correction to [" + value + "]", e);
|
||||||
}
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
mLock.unlock();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -41,6 +41,7 @@ import java.nio.ByteBuffer;
|
|||||||
import java.nio.ByteOrder;
|
import java.nio.ByteOrder;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.EnumSet;
|
import java.util.EnumSet;
|
||||||
|
import java.util.concurrent.locks.ReentrantLock;
|
||||||
|
|
||||||
public class HackRFTunerController extends USBTunerController
|
public class HackRFTunerController extends USBTunerController
|
||||||
{
|
{
|
||||||
@@ -69,6 +70,7 @@ public class HackRFTunerController extends USBTunerController
|
|||||||
private Device mDevice;
|
private Device mDevice;
|
||||||
private DeviceDescriptor mDeviceDescriptor;
|
private DeviceDescriptor mDeviceDescriptor;
|
||||||
private DeviceHandle mDeviceHandle;
|
private DeviceHandle mDeviceHandle;
|
||||||
|
private ReentrantLock mLock = new ReentrantLock();
|
||||||
|
|
||||||
public HackRFTunerController(Device device, DeviceDescriptor descriptor) throws SourceException
|
public HackRFTunerController(Device device, DeviceDescriptor descriptor) throws SourceException
|
||||||
{
|
{
|
||||||
@@ -246,9 +248,16 @@ public class HackRFTunerController extends USBTunerController
|
|||||||
*/
|
*/
|
||||||
public void setBasebandFilter(BasebandFilter filter) throws UsbException
|
public void setBasebandFilter(BasebandFilter filter) throws UsbException
|
||||||
{
|
{
|
||||||
write(Request.BASEBAND_FILTER_BANDWIDTH_SET,
|
mLock.lock();
|
||||||
filter.getLowValue(),
|
|
||||||
filter.getHighValue());
|
try
|
||||||
|
{
|
||||||
|
write(Request.BASEBAND_FILTER_BANDWIDTH_SET, filter.getLowValue(), filter.getHighValue());
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
mLock.unlock();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -256,9 +265,17 @@ public class HackRFTunerController extends USBTunerController
|
|||||||
*/
|
*/
|
||||||
public void setAmplifierEnabled(boolean enabled) throws UsbException
|
public void setAmplifierEnabled(boolean enabled) throws UsbException
|
||||||
{
|
{
|
||||||
write(Request.AMP_ENABLE, (enabled ? 1 : 0), 0);
|
mLock.lock();
|
||||||
|
|
||||||
mAmplifierEnabled = enabled;
|
try
|
||||||
|
{
|
||||||
|
write(Request.AMP_ENABLE, (enabled ? 1 : 0), 0);
|
||||||
|
mAmplifierEnabled = enabled;
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
mLock.unlock();;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean getAmplifier()
|
public boolean getAmplifier()
|
||||||
@@ -271,11 +288,18 @@ public class HackRFTunerController extends USBTunerController
|
|||||||
*/
|
*/
|
||||||
public void setLNAGain(HackRFLNAGain gain) throws UsbException
|
public void setLNAGain(HackRFLNAGain gain) throws UsbException
|
||||||
{
|
{
|
||||||
int result = readByte(Request.SET_LNA_GAIN, 0, gain.getValue(), true);
|
try
|
||||||
|
|
||||||
if(result != 1)
|
|
||||||
{
|
{
|
||||||
throw new UsbException("couldn't set lna gain to " + gain);
|
int result = readByte(Request.SET_LNA_GAIN, 0, gain.getValue(), true);
|
||||||
|
|
||||||
|
if(result != 1)
|
||||||
|
{
|
||||||
|
throw new UsbException("couldn't set lna gain to " + gain);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
mLock.unlock();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -284,11 +308,20 @@ public class HackRFTunerController extends USBTunerController
|
|||||||
*/
|
*/
|
||||||
public void setVGAGain(HackRFVGAGain gain) throws UsbException
|
public void setVGAGain(HackRFVGAGain gain) throws UsbException
|
||||||
{
|
{
|
||||||
int result = readByte(Request.SET_VGA_GAIN, 0, gain.getValue(), true);
|
mLock.lock();
|
||||||
|
|
||||||
if(result != 1)
|
try
|
||||||
{
|
{
|
||||||
throw new UsbException("couldn't set vga gain to " + gain);
|
int result = readByte(Request.SET_VGA_GAIN, 0, gain.getValue(), true);
|
||||||
|
|
||||||
|
if(result != 1)
|
||||||
|
{
|
||||||
|
throw new UsbException("couldn't set vga gain to " + gain);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
mLock.unlock();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -303,27 +336,34 @@ public class HackRFTunerController extends USBTunerController
|
|||||||
@Override
|
@Override
|
||||||
public void setTunedFrequency(long frequency) throws SourceException
|
public void setTunedFrequency(long frequency) throws SourceException
|
||||||
{
|
{
|
||||||
ByteBuffer buffer = ByteBuffer.allocateDirect(8);
|
mLock.lock();
|
||||||
buffer.order(ByteOrder.LITTLE_ENDIAN);
|
|
||||||
|
|
||||||
int mhz = (int)(frequency / 1E6);
|
|
||||||
int hz = (int)(frequency - (mhz * 1E6));
|
|
||||||
|
|
||||||
buffer.putInt(mhz);
|
|
||||||
buffer.putInt(hz);
|
|
||||||
|
|
||||||
buffer.rewind();
|
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
write(Request.SET_FREQUENCY, 0, 0, buffer);
|
ByteBuffer buffer = ByteBuffer.allocateDirect(8);
|
||||||
}
|
buffer.order(ByteOrder.LITTLE_ENDIAN);
|
||||||
catch(UsbException e)
|
|
||||||
{
|
|
||||||
mLog.error("error setting frequency [" + frequency + "]", e);
|
|
||||||
|
|
||||||
throw new SourceException("error setting frequency [" +
|
int mhz = (int)(frequency / 1E6);
|
||||||
frequency + "]", e);
|
int hz = (int)(frequency - (mhz * 1E6));
|
||||||
|
|
||||||
|
buffer.putInt(mhz);
|
||||||
|
buffer.putInt(hz);
|
||||||
|
|
||||||
|
buffer.rewind();
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
write(Request.SET_FREQUENCY, 0, 0, buffer);
|
||||||
|
}
|
||||||
|
catch(UsbException e)
|
||||||
|
{
|
||||||
|
mLog.error("error setting frequency [" + frequency + "]", e);
|
||||||
|
throw new SourceException("error setting frequency [" + frequency + "]", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
mLock.unlock();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -46,6 +46,7 @@ import java.nio.ByteOrder;
|
|||||||
import java.nio.charset.Charset;
|
import java.nio.charset.Charset;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
import java.util.concurrent.locks.ReentrantLock;
|
||||||
|
|
||||||
public abstract class RTL2832TunerController extends USBTunerController
|
public abstract class RTL2832TunerController extends USBTunerController
|
||||||
{
|
{
|
||||||
@@ -60,6 +61,7 @@ public abstract class RTL2832TunerController extends USBTunerController
|
|||||||
public final static long TIMEOUT_US = 1000000l; //uSeconds
|
public final static long TIMEOUT_US = 1000000l; //uSeconds
|
||||||
public final static byte REQUEST_ZERO = (byte) 0;
|
public final static byte REQUEST_ZERO = (byte) 0;
|
||||||
public final static byte EEPROM_ADDRESS = (byte) 0xA0;
|
public final static byte EEPROM_ADDRESS = (byte) 0xA0;
|
||||||
|
protected ReentrantLock mLock = new ReentrantLock();
|
||||||
|
|
||||||
public final static byte[] sFIR_COEFFICIENTS =
|
public final static byte[] sFIR_COEFFICIENTS =
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -384,6 +384,8 @@ public class E4KTunerController extends RTL2832TunerController
|
|||||||
actualFrequency = calculateActualFrequency(pll, z, x);
|
actualFrequency = calculateActualFrequency(pll, z, x);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mLock.lock();
|
||||||
|
|
||||||
/* Apply the actual frequency */
|
/* Apply the actual frequency */
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -428,6 +430,10 @@ public class E4KTunerController extends RTL2832TunerController
|
|||||||
throw new SourceException("E4K tuner controller - error tuning "
|
throw new SourceException("E4K tuner controller - error tuning "
|
||||||
+ "frequency [" + frequency + "]", e);
|
+ "frequency [" + frequency + "]", e);
|
||||||
}
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
mLock.unlock();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private long calculateActualFrequency(PLL pll, byte z, int x)
|
private long calculateActualFrequency(PLL pll, byte z, int x)
|
||||||
@@ -657,38 +663,46 @@ public class E4KTunerController extends RTL2832TunerController
|
|||||||
* @param gain
|
* @param gain
|
||||||
* @throws UsbException
|
* @throws UsbException
|
||||||
*/
|
*/
|
||||||
public void setLNAGain(E4KLNAGain gain, boolean controlI2CRepeater)
|
public void setLNAGain(E4KLNAGain gain, boolean controlI2CRepeater) throws UsbException
|
||||||
throws UsbException
|
|
||||||
{
|
{
|
||||||
if(controlI2CRepeater)
|
mLock.lock();
|
||||||
|
|
||||||
|
try
|
||||||
{
|
{
|
||||||
enableI2CRepeater(mDeviceHandle, true);
|
if(controlI2CRepeater)
|
||||||
|
{
|
||||||
|
enableI2CRepeater(mDeviceHandle, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(gain == E4KLNAGain.AUTOMATIC)
|
||||||
|
{
|
||||||
|
writeMaskedE4KRegister(Register.AGC1,
|
||||||
|
AGC1_MOD_MASK,
|
||||||
|
AGCMode.IF_SERIAL_LNA_AUTON.getValue(),
|
||||||
|
false);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
writeMaskedE4KRegister(Register.AGC1,
|
||||||
|
AGC1_MOD_MASK,
|
||||||
|
AGCMode.SERIAL.getValue(),
|
||||||
|
false);
|
||||||
|
|
||||||
|
|
||||||
|
writeMaskedE4KRegister(E4KLNAGain.getRegister(),
|
||||||
|
E4KLNAGain.getMask(),
|
||||||
|
gain.getValue(),
|
||||||
|
false);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(controlI2CRepeater)
|
||||||
|
{
|
||||||
|
enableI2CRepeater(mDeviceHandle, false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
finally
|
||||||
if(gain == E4KLNAGain.AUTOMATIC)
|
|
||||||
{
|
{
|
||||||
writeMaskedE4KRegister(Register.AGC1,
|
mLock.unlock();
|
||||||
AGC1_MOD_MASK,
|
|
||||||
AGCMode.IF_SERIAL_LNA_AUTON.getValue(),
|
|
||||||
false);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
writeMaskedE4KRegister(Register.AGC1,
|
|
||||||
AGC1_MOD_MASK,
|
|
||||||
AGCMode.SERIAL.getValue(),
|
|
||||||
false);
|
|
||||||
|
|
||||||
|
|
||||||
writeMaskedE4KRegister(E4KLNAGain.getRegister(),
|
|
||||||
E4KLNAGain.getMask(),
|
|
||||||
gain.getValue(),
|
|
||||||
false);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(controlI2CRepeater)
|
|
||||||
{
|
|
||||||
enableI2CRepeater(mDeviceHandle, false);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -699,8 +713,16 @@ public class E4KTunerController extends RTL2832TunerController
|
|||||||
*/
|
*/
|
||||||
public E4KLNAGain getLNAGain(boolean controlI2CRepeater) throws UsbException
|
public E4KLNAGain getLNAGain(boolean controlI2CRepeater) throws UsbException
|
||||||
{
|
{
|
||||||
return E4KLNAGain.fromRegisterValue(
|
mLock.lock();
|
||||||
readE4KRegister(E4KLNAGain.getRegister(), controlI2CRepeater));
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
return E4KLNAGain.fromRegisterValue(readE4KRegister(E4KLNAGain.getRegister(), controlI2CRepeater));
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
mLock.unlock();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -711,13 +733,18 @@ public class E4KTunerController extends RTL2832TunerController
|
|||||||
* @param gain
|
* @param gain
|
||||||
* @throws UsbException
|
* @throws UsbException
|
||||||
*/
|
*/
|
||||||
public void setEnhanceGain(E4KEnhanceGain gain, boolean controlI2CRepeater)
|
public void setEnhanceGain(E4KEnhanceGain gain, boolean controlI2CRepeater) throws UsbException
|
||||||
throws UsbException
|
|
||||||
{
|
{
|
||||||
writeMaskedE4KRegister(E4KEnhanceGain.getRegister(),
|
mLock.lock();
|
||||||
E4KEnhanceGain.getMask(),
|
|
||||||
gain.getValue(),
|
try
|
||||||
controlI2CRepeater);
|
{
|
||||||
|
writeMaskedE4KRegister(E4KEnhanceGain.getRegister(), E4KEnhanceGain.getMask(), gain.getValue(), controlI2CRepeater);
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
mLock.unlock();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -728,72 +755,90 @@ public class E4KTunerController extends RTL2832TunerController
|
|||||||
* @return
|
* @return
|
||||||
* @throws UsbException
|
* @throws UsbException
|
||||||
*/
|
*/
|
||||||
public E4KEnhanceGain getEnhanceGain(boolean controlI2CRepeater)
|
public E4KEnhanceGain getEnhanceGain(boolean controlI2CRepeater) throws UsbException
|
||||||
throws UsbException
|
|
||||||
{
|
{
|
||||||
return E4KEnhanceGain.fromRegisterValue(
|
mLock.lock();
|
||||||
readE4KRegister(E4KEnhanceGain.getRegister(), controlI2CRepeater));
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setMixerGain(E4KMixerGain gain, boolean controlI2CRepeater)
|
try
|
||||||
throws UsbException
|
|
||||||
{
|
|
||||||
if(controlI2CRepeater)
|
|
||||||
{
|
{
|
||||||
enableI2CRepeater(mDeviceHandle, true);
|
return E4KEnhanceGain.fromRegisterValue(readE4KRegister(E4KEnhanceGain.getRegister(), controlI2CRepeater));
|
||||||
}
|
}
|
||||||
|
finally
|
||||||
boolean localI2CRepeaterControl = false;
|
|
||||||
|
|
||||||
if(gain == E4KMixerGain.AUTOMATIC)
|
|
||||||
{
|
{
|
||||||
writeMaskedE4KRegister(Register.AGC7,
|
mLock.unlock();
|
||||||
AGC7_MIXER_GAIN_MASK,
|
|
||||||
AGC7_MIX_GAIN_AUTO,
|
|
||||||
localI2CRepeaterControl);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
writeMaskedE4KRegister(Register.AGC7,
|
|
||||||
AGC7_MIXER_GAIN_MASK,
|
|
||||||
AGC7_MIX_GAIN_MANUAL,
|
|
||||||
localI2CRepeaterControl);
|
|
||||||
|
|
||||||
/* Set the desired manual gain setting */
|
|
||||||
writeMaskedE4KRegister(E4KMixerGain.getRegister(),
|
|
||||||
E4KMixerGain.getMask(),
|
|
||||||
gain.getValue(),
|
|
||||||
localI2CRepeaterControl);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(controlI2CRepeater)
|
|
||||||
{
|
|
||||||
enableI2CRepeater(mDeviceHandle, false);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public E4KMixerGain getMixerGain(boolean controlI2CRepeater)
|
public void setMixerGain(E4KMixerGain gain, boolean controlI2CRepeater) throws UsbException
|
||||||
throws UsbException
|
|
||||||
{
|
{
|
||||||
byte autoOrManual = readMaskedE4KRegister(Register.AGC7,
|
mLock.lock();
|
||||||
AGC7_MIXER_GAIN_MASK,
|
|
||||||
controlI2CRepeater);
|
|
||||||
|
|
||||||
if(autoOrManual == AGC7_MIX_GAIN_AUTO)
|
try
|
||||||
{
|
{
|
||||||
return E4KMixerGain.AUTOMATIC;
|
if(controlI2CRepeater)
|
||||||
|
{
|
||||||
|
enableI2CRepeater(mDeviceHandle, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean localI2CRepeaterControl = false;
|
||||||
|
|
||||||
|
if(gain == E4KMixerGain.AUTOMATIC)
|
||||||
|
{
|
||||||
|
writeMaskedE4KRegister(Register.AGC7,
|
||||||
|
AGC7_MIXER_GAIN_MASK,
|
||||||
|
AGC7_MIX_GAIN_AUTO,
|
||||||
|
localI2CRepeaterControl);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
writeMaskedE4KRegister(Register.AGC7,
|
||||||
|
AGC7_MIXER_GAIN_MASK,
|
||||||
|
AGC7_MIX_GAIN_MANUAL,
|
||||||
|
localI2CRepeaterControl);
|
||||||
|
|
||||||
|
/* Set the desired manual gain setting */
|
||||||
|
writeMaskedE4KRegister(E4KMixerGain.getRegister(),
|
||||||
|
E4KMixerGain.getMask(),
|
||||||
|
gain.getValue(),
|
||||||
|
localI2CRepeaterControl);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(controlI2CRepeater)
|
||||||
|
{
|
||||||
|
enableI2CRepeater(mDeviceHandle, false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
finally
|
||||||
{
|
{
|
||||||
int register = readE4KRegister(E4KMixerGain.getRegister(),
|
mLock.unlock();
|
||||||
controlI2CRepeater);
|
|
||||||
|
|
||||||
return E4KMixerGain.fromRegisterValue(register);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setIFStage1Gain(IFStage1Gain gain,
|
public E4KMixerGain getMixerGain(boolean controlI2CRepeater) throws UsbException
|
||||||
boolean controlI2CRepeater) throws UsbException
|
{
|
||||||
|
mLock.lock();
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
byte autoOrManual = readMaskedE4KRegister(Register.AGC7, AGC7_MIXER_GAIN_MASK, controlI2CRepeater);
|
||||||
|
|
||||||
|
if(autoOrManual == AGC7_MIX_GAIN_AUTO)
|
||||||
|
{
|
||||||
|
return E4KMixerGain.AUTOMATIC;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
int register = readE4KRegister(E4KMixerGain.getRegister(), controlI2CRepeater);
|
||||||
|
return E4KMixerGain.fromRegisterValue(register);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
mLock.unlock();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setIFStage1Gain(IFStage1Gain gain, boolean controlI2CRepeater) throws UsbException
|
||||||
{
|
{
|
||||||
writeMaskedE4KRegister(IFStage1Gain.getRegister(),
|
writeMaskedE4KRegister(IFStage1Gain.getRegister(),
|
||||||
IFStage1Gain.getMask(),
|
IFStage1Gain.getMask(),
|
||||||
@@ -959,8 +1004,7 @@ public class E4KTunerController extends RTL2832TunerController
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setBand(long frequency,
|
public void setBand(long frequency, boolean controlI2CRepeater) throws UsbException
|
||||||
boolean controlI2CRepeater) throws UsbException
|
|
||||||
{
|
{
|
||||||
if(controlI2CRepeater)
|
if(controlI2CRepeater)
|
||||||
{
|
{
|
||||||
@@ -997,8 +1041,7 @@ public class E4KTunerController extends RTL2832TunerController
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setRFFilter(long frequency,
|
private void setRFFilter(long frequency, boolean controlI2CRepeater) throws UsbException
|
||||||
boolean controlI2CRepeater) throws UsbException
|
|
||||||
{
|
{
|
||||||
RFFilter filter = RFFilter.fromFrequency(frequency);
|
RFFilter filter = RFFilter.fromFrequency(frequency);
|
||||||
|
|
||||||
|
|||||||
@@ -180,6 +180,8 @@ public class R820TTunerController extends RTL2832TunerController
|
|||||||
@Override
|
@Override
|
||||||
public void setTunedFrequency(long frequency) throws SourceException
|
public void setTunedFrequency(long frequency) throws SourceException
|
||||||
{
|
{
|
||||||
|
mLock.lock();
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
enableI2CRepeater(mDeviceHandle, true);
|
enableI2CRepeater(mDeviceHandle, true);
|
||||||
@@ -200,6 +202,10 @@ public class R820TTunerController extends RTL2832TunerController
|
|||||||
+ "while setting frequency [" + frequency + "] - " +
|
+ "while setting frequency [" + frequency + "] - " +
|
||||||
e.getLocalizedMessage());
|
e.getLocalizedMessage());
|
||||||
}
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
mLock.unlock();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -693,7 +699,16 @@ public class R820TTunerController extends RTL2832TunerController
|
|||||||
*/
|
*/
|
||||||
public void setLNAGain(R820TLNAGain gain, boolean controlI2C) throws UsbException
|
public void setLNAGain(R820TLNAGain gain, boolean controlI2C) throws UsbException
|
||||||
{
|
{
|
||||||
writeR820TRegister(Register.LNA_GAIN, gain.getSetting(), controlI2C);
|
mLock.lock();
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
writeR820TRegister(Register.LNA_GAIN, gain.getSetting(), controlI2C);
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
mLock.unlock();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -701,7 +716,16 @@ public class R820TTunerController extends RTL2832TunerController
|
|||||||
*/
|
*/
|
||||||
public void setMixerGain(R820TMixerGain gain, boolean controlI2C) throws UsbException
|
public void setMixerGain(R820TMixerGain gain, boolean controlI2C) throws UsbException
|
||||||
{
|
{
|
||||||
writeR820TRegister(Register.MIXER_GAIN, gain.getSetting(), controlI2C);
|
mLock.lock();
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
writeR820TRegister(Register.MIXER_GAIN, gain.getSetting(), controlI2C);
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
mLock.unlock();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -709,7 +733,16 @@ public class R820TTunerController extends RTL2832TunerController
|
|||||||
*/
|
*/
|
||||||
public void setVGAGain(R820TVGAGain gain, boolean controlI2C) throws UsbException
|
public void setVGAGain(R820TVGAGain gain, boolean controlI2C) throws UsbException
|
||||||
{
|
{
|
||||||
writeR820TRegister(Register.VGA_GAIN, gain.getSetting(), controlI2C);
|
mLock.lock();
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
writeR820TRegister(Register.VGA_GAIN, gain.getSetting(), controlI2C);
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
mLock.unlock();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user