Partial check-in of R820T tuner controller. Tuning is not yet functional.

This commit is contained in:
dennis.sheirer
2014-05-16 20:13:41 +00:00
parent 39a6868519
commit f70fca55b7
8 changed files with 947 additions and 545 deletions

View File

@@ -292,37 +292,37 @@ public class TunerManager
}
break;
case RAFAELMICRO_R820T:
// try
// {
// R820TTunerController controller =
// new R820TTunerController( device );
//
// controller.init();
//
// RTL2832Tuner rtlTuner =
// new RTL2832Tuner( tunerClass, controller );
//
//
// TunerConfiguration config =
// getTunerConfiguration( rtlTuner );
//
// if( config != null )
// {
// rtlTuner.apply( config );
// }
//
// mTuners.add( rtlTuner );
// status = sLOADED;
// name = rtlTuner.getName();
// reason = null;
// }
// catch( SourceException se )
// {
// status = sNOT_LOADED;
// reason = "Error constructing E4K tuner "
// + "controller - " + se.getLocalizedMessage();
// }
// break;
try
{
R820TTunerController controller =
new R820TTunerController( device );
controller.init();
RTL2832Tuner rtlTuner =
new RTL2832Tuner( tunerClass, controller );
TunerConfiguration config =
getTunerConfiguration( rtlTuner );
if( config != null )
{
rtlTuner.apply( config );
}
mTuners.add( rtlTuner );
status = sLOADED;
name = rtlTuner.getName();
reason = null;
}
catch( SourceException se )
{
status = sNOT_LOADED;
reason = "Error constructing E4K tuner "
+ "controller - " + se.getLocalizedMessage();
}
break;
case FITIPOWER_FC0012:
case FITIPOWER_FC0013:
case RAFAELMICRO_R828D:

View File

@@ -142,7 +142,6 @@ public abstract class RTL2832TunerController extends TunerController
private Descriptor mDescriptor;
public static final int sTWO_TO_22_POWER = 4194304;
public static final int sOSCILLATOR_FREQUENCY = 28800000; //28.8 MHz
public static final SampleRate sDEFAULT_SAMPLE_RATE = SampleRate.RATE_1_200MHZ;
private SampleRate mSampleRate = sDEFAULT_SAMPLE_RATE;
@@ -159,6 +158,7 @@ public abstract class RTL2832TunerController extends TunerController
private AtomicInteger mSampleCounter = new AtomicInteger();
private double mSampleRateAverageSum;
private int mSampleRateAverageCount;
protected int mOscillatorFrequency = 28800000; //28.8 MHz
/**
* Abstract tuner controller device. Use the static getTunerClass() method
@@ -304,7 +304,7 @@ public abstract class RTL2832TunerController extends TunerController
public void setIFFrequency( int frequency ) throws UsbException
{
long ifFrequency = ( (long)sTWO_TO_22_POWER * (long)frequency ) /
(long)sOSCILLATOR_FREQUENCY * -1;
(long)mOscillatorFrequency * -1;
/* Write byte 2 (high) */
writeDemodRegister( mUSBDevice,
@@ -1080,7 +1080,7 @@ public abstract class RTL2832TunerController extends TunerController
int ratio = Integer.rotateLeft( high, 16 ) | low;
int rate = (int)( sOSCILLATOR_FREQUENCY * sTWO_TO_22_POWER / ratio );
int rate = (int)( mOscillatorFrequency * sTWO_TO_22_POWER / ratio );
SampleRate sampleRate = SampleRate.getClosest( rate );
@@ -1479,7 +1479,7 @@ public abstract class RTL2832TunerController extends TunerController
{
if( mRunning.compareAndSet( false, true ) )
{
Log.debug( "RTL2832TunerController [" + mDescriptor.getSerial() + "] - starting sample fetch thread" );
Log.debug( "RTL2832TunerController [" + getUniqueID() + "] - starting sample fetch thread" );
ArrayList<UsbIrp> irps = new ArrayList<UsbIrp>();

View File

@@ -0,0 +1,4 @@
[Dolphin]
Timestamp=2014,5,10,7,19,1
Version=3
ViewMode=1

View File

@@ -22,14 +22,18 @@ import javax.xml.bind.annotation.XmlAttribute;
import source.tuner.TunerConfiguration;
import source.tuner.TunerType;
import source.tuner.rtl.RTL2832TunerController.SampleRate;
import source.tuner.rtl.r820t.R820TTunerController.R820TGain;
import source.tuner.rtl.r820t.R820TTunerController.R820TLNAGain;
import source.tuner.rtl.r820t.R820TTunerController.R820TMixerGain;
import source.tuner.rtl.r820t.R820TTunerController.R820TVGAGain;
public class R820TTunerConfiguration extends TunerConfiguration
{
// private R820TGain mMasterGain = R820TGain.AUTOMATIC;
// private R820TMixerGain mMixerGain = R820TMixerGain.AUTOMATIC;
// private R820TLNAGain mLNAGain = R820TLNAGain.AUTOMATIC;
// private R820TEnhanceGain mEnhanceGain = R820TEnhanceGain.AUTOMATIC;
private double mFrequencyCorrection = -12.0d;
private R820TGain mMasterGain = R820TGain.GAIN_36;
private R820TMixerGain mMixerGain = R820TMixerGain.GAIN_15;
private R820TLNAGain mLNAGain = R820TLNAGain.GAIN_21;
private R820TVGAGain mVGAGain = R820TVGAGain.GAIN_210;
private double mFrequencyCorrection = 0.0d;
private SampleRate mSampleRate = SampleRate.RATE_1_200MHZ;
/**
@@ -48,53 +52,53 @@ public class R820TTunerConfiguration extends TunerConfiguration
@Override
public TunerType getTunerType()
{
return TunerType.ELONICS_E4000;
return TunerType.RAFAELMICRO_R820T;
}
// @XmlAttribute( name = "master_gain" )
// public R820TGain getMasterGain()
// {
// return mMasterGain;
// }
//
// public void setMasterGain( R820TGain gain )
// {
// mMasterGain = gain;
// }
//
// @XmlAttribute( name = "mixer_gain" )
// public R820TMixerGain getMixerGain()
// {
// return mMixerGain;
// }
//
// public void setMixerGain( R820TMixerGain mixerGain )
// {
// mMixerGain = mixerGain;
// }
//
// @XmlAttribute( name = "lna_gain" )
// public R820TLNAGain getLNAGain()
// {
// return mLNAGain;
// }
//
// public void setLNAGain( R820TLNAGain lnaGain )
// {
// mLNAGain = lnaGain;
// }
//
// @XmlAttribute( name = "enhance_gain" )
// public R820TEnhanceGain getEnhanceGain()
// {
// return mEnhanceGain;
// }
//
// public void setEnhanceGain( R820TEnhanceGain enhanceGain )
// {
// mEnhanceGain = enhanceGain;
// }
//
@XmlAttribute( name = "master_gain" )
public R820TGain getMasterGain()
{
return mMasterGain;
}
public void setMasterGain( R820TGain gain )
{
mMasterGain = gain;
}
@XmlAttribute( name = "mixer_gain" )
public R820TMixerGain getMixerGain()
{
return mMixerGain;
}
public void setMixerGain( R820TMixerGain mixerGain )
{
mMixerGain = mixerGain;
}
@XmlAttribute( name = "lna_gain" )
public R820TLNAGain getLNAGain()
{
return mLNAGain;
}
public void setLNAGain( R820TLNAGain lnaGain )
{
mLNAGain = lnaGain;
}
@XmlAttribute( name = "vga_gain" )
public R820TVGAGain getVGAGain()
{
return mVGAGain;
}
public void setVGAGain( R820TVGAGain vgaGain )
{
mVGAGain = vgaGain;
}
@XmlAttribute( name = "frequency_correction" )
public double getFrequencyCorrection()
{

View File

@@ -49,11 +49,17 @@ import source.tuner.TunerConfiguration;
import source.tuner.TunerConfigurationAssignment;
import source.tuner.TunerType;
import source.tuner.rtl.RTL2832TunerController.SampleRate;
import source.tuner.rtl.r820t.R820TTunerController.R820TGain;
import source.tuner.rtl.r820t.R820TTunerController.R820TLNAGain;
import source.tuner.rtl.r820t.R820TTunerController.R820TMixerGain;
import source.tuner.rtl.r820t.R820TTunerController.R820TVGAGain;
import controller.ResourceManager;
public class R820TTunerConfigurationPanel extends JPanel
{
private static final long serialVersionUID = 1L;
private static final R820TGain DEFAULT_GAIN = R820TGain.GAIN_279;
private ResourceManager mResourceManager;
private R820TTunerController mController;
private R820TTunerConfiguration mSelectedConfig;
@@ -65,10 +71,10 @@ public class R820TTunerConfigurationPanel extends JPanel
private JTextField mName;
private JSpinner mFrequencyCorrection;
// private JComboBox<R820TGain> mComboMasterGain;
// private JComboBox<R820TMixerGain> mComboMixerGain;
// private JComboBox<R820TLNAGain> mComboLNAGain;
// private JComboBox<R820TEnhanceGain> mComboEnhanceGain;
private JComboBox<R820TGain> mComboMasterGain;
private JComboBox<R820TMixerGain> mComboMixerGain;
private JComboBox<R820TLNAGain> mComboLNAGain;
private JComboBox<R820TVGAGain> mComboVGAGain;
private JComboBox<SampleRate> mComboSampleRate;
@@ -122,21 +128,21 @@ public class R820TTunerConfigurationPanel extends JPanel
mComboConfigurations.setSelectedItem( mSelectedConfig );
// mComboConfigurations.addActionListener( new ActionListener()
// {
// @Override
// public void actionPerformed( ActionEvent e )
// {
// R820TTunerConfiguration selected =
// (R820TTunerConfiguration)mComboConfigurations
// .getItemAt( mComboConfigurations.getSelectedIndex() );
//
// if( selected != null )
// {
// update( selected );
// }
// }
// });
mComboConfigurations.addActionListener( new ActionListener()
{
@Override
public void actionPerformed( ActionEvent e )
{
R820TTunerConfiguration selected =
(R820TTunerConfiguration)mComboConfigurations
.getItemAt( mComboConfigurations.getSelectedIndex() );
if( selected != null )
{
update( selected );
}
}
});
add( mComboConfigurations, "span 2,wrap" );
@@ -205,11 +211,11 @@ public class R820TTunerConfigurationPanel extends JPanel
{
JOptionPane.showMessageDialog(
R820TTunerConfigurationPanel.this,
"E4K Tuner Controller - couldn't apply "
"R820T Tuner Controller - couldn't apply "
+ "frequency correction value: " + value +
e1.getLocalizedMessage() );
Log.error( "E4K Tuner Controller - couldn't apply "
Log.error( "R820T Tuner Controller - couldn't apply "
+ "frequency correction value: " + value +
e1.getLocalizedMessage() );
}
@@ -245,11 +251,11 @@ public class R820TTunerConfigurationPanel extends JPanel
{
JOptionPane.showMessageDialog(
R820TTunerConfigurationPanel.this,
"E4K Tuner Controller - couldn't apply the sample "
"R820T Tuner Controller - couldn't apply the sample "
+ "rate setting [" + sampleRate.getLabel() + "] " +
eSampleRate.getLocalizedMessage() );
Log.error( "E4K Tuner Controller - couldn't apply sample "
Log.error( "R820T Tuner Controller - couldn't apply sample "
+ "rate setting [" + sampleRate.getLabel() + "] " +
eSampleRate.getLocalizedMessage() );
}
@@ -266,301 +272,317 @@ public class R820TTunerConfigurationPanel extends JPanel
gainPanel.setBorder( BorderFactory.createTitledBorder( "Gain" ) );
/* Master Gain Control */
// mComboMasterGain = new JComboBox<R820TGain>( R820TGain.values() );
// mComboMasterGain.setSelectedItem( mSelectedConfig.getMasterGain() );
//
// mComboMasterGain.addActionListener( new ActionListener()
// {
// @Override
// public void actionPerformed( ActionEvent arg0 )
// {
// try
// {
// R820TGain gain = (R820TGain)mComboMasterGain.getSelectedItem();
//
// mController.setGain( (R820TGain)mComboMasterGain.getSelectedItem(), true );
//
// if( gain == R820TGain.MANUAL )
// {
// mComboMixerGain.setSelectedItem(
// mController.getMixerGain( true ) );
// mComboMixerGain.setEnabled( true );
//
// mComboLNAGain.setSelectedItem(
// mController.getLNAGain( true ) );
// mComboLNAGain.setEnabled( true );
//
// mComboEnhanceGain.setEnabled( true );
// mComboEnhanceGain.setSelectedItem(
// mController.getEnhanceGain( true ) );
// }
// else
// {
// mComboMixerGain.setEnabled( false );
// mComboMixerGain.setSelectedItem( gain.getMixerGain() );
//
// mComboLNAGain.setEnabled( false );
// mComboLNAGain.setSelectedItem( gain.getLNAGain() );
//
// mComboEnhanceGain.setEnabled( false );
// mComboEnhanceGain.setSelectedItem( gain.getEnhanceGain() );
// }
//
// mSelectedConfig.setMasterGain( gain );
// save();
// }
// catch ( UsbException e )
// {
// JOptionPane.showMessageDialog(
// R820TTunerConfigurationPanel.this,
// "E4K Tuner Controller - couldn't apply the gain "
// + "setting - " + e.getLocalizedMessage() );
//
// Log.error( "E4K Tuner Controller - couldn't apply "
// + "gain setting - " + e.getLocalizedMessage() );
// }
// }
// } );
// mComboMasterGain.setToolTipText( "<html>Select <b>AUTOMATIC</b> for auto "
// + "gain, <b>MANUAL</b> to enable<br> independent control of "
// + "<i>Mixer</i>, <i>LNA</i> and <i>Enhance</i> gain<br>"
// + "settings, or one of the individual gain settings for<br>"
// + "semi-manual gain control</html>" );
// gainPanel.add( mComboMasterGain );
// gainPanel.add( new JLabel( "Master" ), "wrap" );
//
// /* Mixer Gain Control */
// mComboMixerGain = new JComboBox<R820TMixerGain>( R820TMixerGain.values() );
// mComboMixerGain.setSelectedItem( mSelectedConfig.getMixerGain() );
// mComboMixerGain.addActionListener( new ActionListener()
// {
// @Override
// public void actionPerformed( ActionEvent arg0 )
// {
// EventQueue.invokeLater( new Runnable()
// {
// @Override
// public void run()
// {
// try
// {
// R820TMixerGain mixerGain =
// (R820TMixerGain)mComboMixerGain.getSelectedItem();
//
// if( mComboMixerGain.isEnabled() )
// {
// mController.setMixerGain( mixerGain, true );
// }
//
// mSelectedConfig.setMixerGain( mixerGain );
// save();
// }
// catch ( UsbException e )
// {
// JOptionPane.showMessageDialog(
// R820TTunerConfigurationPanel.this,
// "E4K Tuner Controller - couldn't apply the mixer "
// + "gain setting - " + e.getLocalizedMessage() );
//
// Log.error( "E4K Tuner Controller - couldn't apply mixer "
// + "gain setting - " + e.getLocalizedMessage() );
// }
// }
// } );
// }
// } );
// mComboMixerGain.setToolTipText( "<html>Mixer Gain. Set master gain "
// + "to <b>MASTER</b> to enable adjustment</html>" );
// mComboMixerGain.setEnabled( false );
// gainPanel.add( mComboMixerGain );
// gainPanel.add( new JLabel( "Mixer" ), "wrap" );
//
// /* LNA Gain Control */
// mComboLNAGain = new JComboBox<R820TLNAGain>( R820TLNAGain.values() );
// mComboLNAGain.setSelectedItem( mSelectedConfig.getLNAGain() );
// mComboLNAGain.addActionListener( new ActionListener()
// {
// @Override
// public void actionPerformed( ActionEvent arg0 )
// {
// try
// {
// R820TLNAGain lnaGain = (R820TLNAGain)mComboLNAGain.getSelectedItem();
//
// if( mComboLNAGain.isEnabled() )
// {
// mController.setLNAGain( lnaGain, true );
// }
//
// mSelectedConfig.setLNAGain( lnaGain );
// save();
// }
// catch ( UsbException e )
// {
// JOptionPane.showMessageDialog(
// R820TTunerConfigurationPanel.this,
// "E4K Tuner Controller - couldn't apply the LNA "
// + "gain setting - " + e.getLocalizedMessage() );
//
// Log.error( "E4K Tuner Controller - couldn't apply LNA "
// + "gain setting - " + e.getLocalizedMessage() );
// }
// }
// } );
// mComboLNAGain.setToolTipText( "<html>LNA Gain. Set master gain "
// + "to <b>MANUAL</b> to enable adjustment</html>" );
// mComboLNAGain.setEnabled( false );
// gainPanel.add( mComboLNAGain );
// gainPanel.add( new JLabel( "LNA" ), "wrap" );
//
// /* Enhance Gain Control */
// mComboEnhanceGain = new JComboBox<R820TEnhanceGain>( R820TEnhanceGain.values() );
// mComboEnhanceGain.setSelectedItem( mSelectedConfig.getEnhanceGain() );
// mComboEnhanceGain.addActionListener( new ActionListener()
// {
// @Override
// public void actionPerformed( ActionEvent arg0 )
// {
// try
// {
// R820TEnhanceGain enhanceGain =
// (R820TEnhanceGain)mComboEnhanceGain.getSelectedItem();
//
// if( mComboEnhanceGain.isEnabled() )
// {
// mController.setEnhanceGain( enhanceGain, true );
// }
//
// mSelectedConfig.setEnhanceGain( enhanceGain );
// save();
// }
// catch ( UsbException e )
// {
// JOptionPane.showMessageDialog(
// R820TTunerConfigurationPanel.this,
// "E4K Tuner Controller - couldn't apply the enhance "
// + "gain setting - " + e.getLocalizedMessage() );
//
// Log.error( "E4K Tuner Controller - couldn't apply enhance "
// + "gain setting - " + e.getLocalizedMessage() );
// }
// }
// } );
// mComboEnhanceGain.setToolTipText( "<html>Enhance Gain. Set master gain "
// + "to <b>MANUAL</b> to enable adjustment</html>" );
// mComboEnhanceGain.setEnabled( false );
// gainPanel.add( mComboEnhanceGain );
// gainPanel.add( new JLabel( "Enhance" ), "wrap" );
//
// add( gainPanel, "span" );
//
// /**
// * Create a new configuration
// */
// mNewConfiguration = new JButton( "New" );
//
// mNewConfiguration.addActionListener( new ActionListener()
// {
// @Override
// public void actionPerformed( ActionEvent e )
// {
// TunerConfiguration config =
// mResourceManager.getSettingsManager()
// .addNewTunerConfiguration(
// TunerType.ELONICS_E4000,
// "New Configuration" );
//
// mComboConfigurations.setModel( getModel() );
//
// mComboConfigurations.setSelectedItem( config );
//
// repaint();
// }
// } );
//
// add( mNewConfiguration );
//
// /**
// * Delete the currently selected configuration
// */
// mDeleteConfiguration = new JButton( "Delete" );
//
// mDeleteConfiguration.addActionListener( new ActionListener()
// {
// @Override
// public void actionPerformed( ActionEvent e )
// {
// R820TTunerConfiguration selected =
// (R820TTunerConfiguration)mComboConfigurations
// .getItemAt( mComboConfigurations.getSelectedIndex() );
//
// if( selected != null )
// {
// int n = JOptionPane.showConfirmDialog(
// R820TTunerConfigurationPanel.this,
// "Are you sure you want to delete '"
// + selected.getName() + "'?",
// "Are you sure?",
// JOptionPane.YES_NO_OPTION );
//
// if( n == JOptionPane.YES_OPTION )
// {
// mResourceManager.getSettingsManager()
// .deleteTunerConfiguration( selected );
//
// mComboConfigurations.setModel( getModel() );
//
// mComboConfigurations.setSelectedIndex( 0 );
//
// repaint();
// }
// }
// }
// } );
//
// add( mDeleteConfiguration, "wrap" );
// }
//
// /**
// * Updates gui controls with the values from the tuner configuration
// * @param config - tuner configuration
// */
// private void update( R820TTunerConfiguration config )
// {
// mSelectedConfig = config;
//
// try
// {
// mController.apply( config );
//
// mName.setText( config.getName() );
// mFrequencyCorrection.setValue( config.getFrequencyCorrection() );
//
// mComboMixerGain.setSelectedItem( mSelectedConfig.getMixerGain() );
// mComboLNAGain.setSelectedItem( mSelectedConfig.getLNAGain() );
// mComboEnhanceGain.setSelectedItem( mSelectedConfig.getEnhanceGain() );
//
// /* Apply master gain last so that the Mixer, LNA, and Enhance gain
// * settings are updated with the master setting where necessary */
// mComboMasterGain.setSelectedItem( mSelectedConfig.getMasterGain() );
//
// mComboSampleRate.setSelectedItem( mSelectedConfig.getSampleRate() );
//
// mResourceManager.getSettingsManager().setSelectedTunerConfiguration(
// TunerType.ELONICS_E4000, mController.getUniqueID(), config );
// }
// catch ( SourceException e1 )
// {
// JOptionPane.showMessageDialog(
// R820TTunerConfigurationPanel.this,
// "E4K Tuner Controller - couldn't "
// + "apply the tuner configuration settings - " +
// e1.getLocalizedMessage() );
//
// Log.error( "E4K Tuner Controller - couldn't apply "
// + "config [" + config.getName() + "] - " +
// e1.getLocalizedMessage() );
// }
mComboMasterGain = new JComboBox<R820TGain>( R820TGain.values() );
mComboMasterGain.setSelectedItem( mSelectedConfig.getMasterGain() );
mComboMasterGain.addActionListener( new ActionListener()
{
@Override
public void actionPerformed( ActionEvent arg0 )
{
try
{
R820TGain gain = (R820TGain)mComboMasterGain.getSelectedItem();
mController.setGain( (R820TGain)mComboMasterGain.getSelectedItem(), true );
if( gain == R820TGain.MANUAL )
{
mComboMixerGain.setSelectedItem(
mController.getMixerGain( true ) );
mComboMixerGain.setEnabled( true );
mComboLNAGain.setSelectedItem(
mController.getLNAGain( true ) );
mComboLNAGain.setEnabled( true );
mComboVGAGain.setEnabled( true );
mComboVGAGain.setSelectedItem(
mController.getVGAGain( true ) );
}
else
{
mComboMixerGain.setEnabled( false );
mComboMixerGain.setSelectedItem( gain.getMixerGain() );
mComboLNAGain.setEnabled( false );
mComboLNAGain.setSelectedItem( gain.getLNAGain() );
mComboVGAGain.setEnabled( false );
mComboVGAGain.setSelectedItem( gain.getVGAGain() );
}
mSelectedConfig.setMasterGain( gain );
save();
}
catch ( UsbException e )
{
JOptionPane.showMessageDialog(
R820TTunerConfigurationPanel.this,
"R820T Tuner Controller - couldn't apply the gain "
+ "setting - " + e.getLocalizedMessage() );
Log.error( "R820T Tuner Controller - couldn't apply "
+ "gain setting - " + e.getLocalizedMessage() );
}
}
} );
mComboMasterGain.setToolTipText( "<html>Select <b>AUTOMATIC</b> for auto "
+ "gain, <b>MANUAL</b> to enable<br> independent control of "
+ "<i>Mixer</i>, <i>LNA</i> and <i>Enhance</i> gain<br>"
+ "settings, or one of the individual gain settings for<br>"
+ "semi-manual gain control</html>" );
gainPanel.add( mComboMasterGain );
gainPanel.add( new JLabel( "Master" ), "wrap" );
/* Mixer Gain Control */
mComboMixerGain = new JComboBox<R820TMixerGain>( R820TMixerGain.values() );
mComboMixerGain.setSelectedItem( mSelectedConfig.getMixerGain() );
mComboMixerGain.addActionListener( new ActionListener()
{
@Override
public void actionPerformed( ActionEvent arg0 )
{
EventQueue.invokeLater( new Runnable()
{
@Override
public void run()
{
try
{
R820TMixerGain mixerGain =
(R820TMixerGain)mComboMixerGain.getSelectedItem();
if( mixerGain == null )
{
mixerGain = DEFAULT_GAIN.getMixerGain();
}
if( mComboMixerGain.isEnabled() )
{
mController.setMixerGain( mixerGain, true );
}
mSelectedConfig.setMixerGain( mixerGain );
save();
}
catch ( UsbException e )
{
JOptionPane.showMessageDialog(
R820TTunerConfigurationPanel.this,
"R820T Tuner Controller - couldn't apply the mixer "
+ "gain setting - " + e.getLocalizedMessage() );
Log.error( "R820T Tuner Controller - couldn't apply mixer "
+ "gain setting - " + e.getLocalizedMessage() );
}
}
} );
}
} );
mComboMixerGain.setToolTipText( "<html>Mixer Gain. Set master gain "
+ "to <b>MASTER</b> to enable adjustment</html>" );
mComboMixerGain.setEnabled( false );
gainPanel.add( mComboMixerGain );
gainPanel.add( new JLabel( "Mixer" ), "wrap" );
/* LNA Gain Control */
mComboLNAGain = new JComboBox<R820TLNAGain>( R820TLNAGain.values() );
mComboLNAGain.setSelectedItem( mSelectedConfig.getLNAGain() );
mComboLNAGain.addActionListener( new ActionListener()
{
@Override
public void actionPerformed( ActionEvent arg0 )
{
try
{
R820TLNAGain lnaGain =
(R820TLNAGain)mComboLNAGain.getSelectedItem();
if ( lnaGain == null )
{
lnaGain = DEFAULT_GAIN.getLNAGain();
}
if( mComboLNAGain.isEnabled() )
{
mController.setLNAGain( lnaGain, true );
}
mSelectedConfig.setLNAGain( lnaGain );
save();
}
catch ( UsbException e )
{
JOptionPane.showMessageDialog(
R820TTunerConfigurationPanel.this,
"R820T Tuner Controller - couldn't apply the LNA "
+ "gain setting - " + e.getLocalizedMessage() );
Log.error( "R820T Tuner Controller - couldn't apply LNA "
+ "gain setting - " + e.getLocalizedMessage() );
}
}
} );
mComboLNAGain.setToolTipText( "<html>LNA Gain. Set master gain "
+ "to <b>MANUAL</b> to enable adjustment</html>" );
mComboLNAGain.setEnabled( false );
gainPanel.add( mComboLNAGain );
gainPanel.add( new JLabel( "LNA" ), "wrap" );
/* VGA Gain Control */
mComboVGAGain = new JComboBox<R820TVGAGain>( R820TVGAGain.values() );
mComboVGAGain.setSelectedItem( mSelectedConfig.getVGAGain() );
mComboVGAGain.addActionListener( new ActionListener()
{
@Override
public void actionPerformed( ActionEvent arg0 )
{
try
{
R820TVGAGain vgaGain =
(R820TVGAGain)mComboVGAGain.getSelectedItem();
if( vgaGain == null )
{
vgaGain = DEFAULT_GAIN.getVGAGain();
}
if( mComboVGAGain.isEnabled() )
{
mController.setVGAGain( vgaGain, true );
}
mSelectedConfig.setVGAGain( vgaGain );
save();
}
catch ( UsbException e )
{
JOptionPane.showMessageDialog(
R820TTunerConfigurationPanel.this,
"R820T Tuner Controller - couldn't apply the VGA "
+ "gain setting - " + e.getLocalizedMessage() );
Log.error( "R820T Tuner Controller - couldn't apply VGA "
+ "gain setting - " + e.getLocalizedMessage() );
}
}
} );
mComboVGAGain.setToolTipText( "<html>VGA Gain. Set master gain "
+ "to <b>MANUAL</b> to enable adjustment</html>" );
mComboVGAGain.setEnabled( false );
gainPanel.add( mComboVGAGain );
gainPanel.add( new JLabel( "VGA" ), "wrap" );
add( gainPanel, "span" );
/**
* Create a new configuration
*/
mNewConfiguration = new JButton( "New" );
mNewConfiguration.addActionListener( new ActionListener()
{
@Override
public void actionPerformed( ActionEvent e )
{
TunerConfiguration config =
mResourceManager.getSettingsManager()
.addNewTunerConfiguration(
TunerType.RAFAELMICRO_R820T,
"New Configuration" );
mComboConfigurations.setModel( getModel() );
mComboConfigurations.setSelectedItem( config );
repaint();
}
} );
add( mNewConfiguration );
/**
* Delete the currently selected configuration
*/
mDeleteConfiguration = new JButton( "Delete" );
mDeleteConfiguration.addActionListener( new ActionListener()
{
@Override
public void actionPerformed( ActionEvent e )
{
R820TTunerConfiguration selected =
(R820TTunerConfiguration)mComboConfigurations
.getItemAt( mComboConfigurations.getSelectedIndex() );
if( selected != null )
{
int n = JOptionPane.showConfirmDialog(
R820TTunerConfigurationPanel.this,
"Are you sure you want to delete '"
+ selected.getName() + "'?",
"Are you sure?",
JOptionPane.YES_NO_OPTION );
if( n == JOptionPane.YES_OPTION )
{
mResourceManager.getSettingsManager()
.deleteTunerConfiguration( selected );
mComboConfigurations.setModel( getModel() );
mComboConfigurations.setSelectedIndex( 0 );
repaint();
}
}
}
} );
add( mDeleteConfiguration, "wrap" );
}
/**
* Updates gui controls with the values from the tuner configuration
* @param config - tuner configuration
*/
private void update( R820TTunerConfiguration config )
{
mSelectedConfig = config;
try
{
mController.apply( config );
mName.setText( config.getName() );
mFrequencyCorrection.setValue( config.getFrequencyCorrection() );
mComboMixerGain.setSelectedItem( mSelectedConfig.getMixerGain() );
mComboLNAGain.setSelectedItem( mSelectedConfig.getLNAGain() );
mComboVGAGain.setSelectedItem( mSelectedConfig.getVGAGain() );
/* Apply master gain last so that the Mixer, LNA, and VGA gain
* settings are updated with the master setting where necessary */
mComboMasterGain.setSelectedItem( mSelectedConfig.getMasterGain() );
mComboSampleRate.setSelectedItem( mSelectedConfig.getSampleRate() );
mResourceManager.getSettingsManager().setSelectedTunerConfiguration(
TunerType.RAFAELMICRO_R820T, mController.getUniqueID(), config );
}
catch ( SourceException e1 )
{
JOptionPane.showMessageDialog(
R820TTunerConfigurationPanel.this,
"R820T Tuner Controller - couldn't "
+ "apply the tuner configuration settings - " +
e1.getLocalizedMessage() );
Log.error( "R820T Tuner Controller - couldn't apply "
+ "config [" + config.getName() + "] - " +
e1.getLocalizedMessage() );
}
}
/**

View File

@@ -30,13 +30,15 @@ import source.SourceException;
import source.tuner.TunerConfiguration;
import source.tuner.TunerType;
import source.tuner.rtl.RTL2832TunerController;
import source.tuner.rtl.RTL2832TunerController.Address;
import source.tuner.rtl.RTL2832TunerController.Block;
import source.tuner.usb.USBTunerDevice;
import controller.ResourceManager;
public class R820TTunerController extends RTL2832TunerController
{
public static final int MIN_FREQUENCY = 24000000;
public static final int MAX_FREQUENCY = 176600000;
public static final int MAX_FREQUENCY = 1766000000;
public static final byte VERSION = (byte)49;
private byte mI2CAddress = (byte)0x34;
@@ -70,25 +72,44 @@ public class R820TTunerController extends RTL2832TunerController
}
@Override
public void apply( TunerConfiguration config ) throws SourceException
public void apply( TunerConfiguration tunerConfig ) throws SourceException
{
Log.error( "********* Apply tuner config not yet implemented - R820T tuner controller" );
if( tunerConfig != null &&
tunerConfig instanceof R820TTunerConfiguration )
{
R820TTunerConfiguration config = (R820TTunerConfiguration)tunerConfig;
try
{
SampleRate sampleRate = config.getSampleRate();
setSampleRate( sampleRate );
double correction = config.getFrequencyCorrection();
setFrequencyCorrection( correction );
R820TGain masterGain = config.getMasterGain();
setGain( masterGain, true );
if( masterGain == R820TGain.MANUAL )
{
R820TMixerGain mixerGain = config.getMixerGain();
setMixerGain( mixerGain, true );
R820TLNAGain lnaGain = config.getLNAGain();
setLNAGain( lnaGain, true );
R820TVGAGain vgaGain = config.getVGAGain();
setVGAGain( vgaGain, true );
}
}
catch( UsbException e )
{
throw new SourceException( "R820TTunerController - usb error "
+ "while applying tuner config", e );
}
}
}
public void init() throws SourceException
{
try
{
initializeRegisters();
}
catch( UsbException e )
{
throw new SourceException( "R820TTunerController - error setting "
+ "registers to initial startup value", e );
}
}
public JPanel getEditor( ResourceManager resourceManager )
{
return new R820TTunerEditorPanel( this, resourceManager );
@@ -103,67 +124,263 @@ public class R820TTunerController extends RTL2832TunerController
@Override
public void setTunedFrequency( int frequency ) throws SourceException
{
}
public void initTuner( boolean controlI2CRepeater ) throws UsbException
{
if( controlI2CRepeater )
Log.info( "R820T - setting frequency to " + frequency );
try
{
enableI2CRepeater( mUSBDevice, true );
}
boolean i2CRepeaterControl = false;
if( controlI2CRepeater )
{
boolean controlI2C = false;
setMux( frequency, controlI2C );
setPLL( frequency, controlI2C );
enableI2CRepeater( mUSBDevice, false );
}
catch( UsbException e )
{
throw new SourceException( "R820TTunerController - exception "
+ "while setting frequency [" + frequency + "] - " +
e.getLocalizedMessage() );
}
}
private void setMux( int frequency, boolean controlI2C ) throws UsbException
{
FrequencyRange range = FrequencyRange.getRangeForFrequency( frequency );
/* Set open drain */
writeR820TRegister( Register.DRAIN, range.getOpenDrain(), controlI2C );
/* RF_MUX, Polymux */
writeR820TRegister( Register.RF_POLY_MUX, range.getRFMuxPolyMux(), controlI2C );
/* TF Band */
writeR820TRegister( Register.TF_BAND, range.getTFC(), controlI2C );
/* XTAL CAP & Drive */
writeR820TRegister( Register.PLL_XTAL_CAPACITOR_AND_DRIVE,
range.getXTALHighCap0P(), controlI2C );
/* Register 8 - what is it? */
writeR820TRegister( Register.UNKNOWN_REGISTER_8, (byte)0x00, controlI2C );
/* Register 9 - what is it? */
writeR820TRegister( Register.UNKNOWN_REGISTER_9, (byte)0x00, controlI2C );
}
public void init() throws SourceException
{
try
{
/* Dummy write to test USB interface */
writeRegister( mUSBDevice, Block.USB,
Address.USB_SYSCTL.getAddress(), (short)0x09, 1 );
initBaseband( mUSBDevice );
enableI2CRepeater( mUSBDevice, true );
boolean i2CRepeaterControl = false;
initTuner( i2CRepeaterControl );
enableI2CRepeater( mUSBDevice, false );
/* Initialize the super class */
super.init();
}
catch( UsbException e )
{
e.printStackTrace();
throw new SourceException( "E4K Tuner Controller - error during "
+ "init()", e );
}
}
public void initTuner( boolean controlI2C ) throws UsbException
{
initializeRegisters( controlI2C );
setTVStandard( controlI2C );
systemFrequencySelect( 0, controlI2C );
getGain();
}
/**
* Partially implements the r82xx_set_tv_standard() method from librtlsdr.
* Sets standard to digital tv to support sdr operations only.
*/
private void setTVStandard() throws UsbException
private void setTVStandard( boolean controlI2C ) throws UsbException
{
enableI2CRepeater( mUSBDevice, true );
Log.info( "Setting TV Standard" );
/* Init Flag & Xtal check Result */
writeR820TRegister( Register.XTAL_CHECK, (byte)0x00, false );
writeR820TRegister( Register.XTAL_CHECK, (byte)0x00, controlI2C );
/* Set version */
writeR820TRegister( Register.VERSION, VERSION, false );
writeR820TRegister( Register.VERSION, VERSION, controlI2C );
/* LT Gain Test */
writeR820TRegister( Register.LNA_TOP, (byte)0x00, false );
writeR820TRegister( Register.LNA_TOP, (byte)0x00, controlI2C );
int calibrationCode = 0;
for( int x = 0; x < 2; x++ )
{
/* Set filter cap */
writeR820TRegister( Register.FILTER_CAPACITOR, (byte)0x6B, false );
writeR820TRegister( Register.FILTER_CAPACITOR, (byte)0x6B, controlI2C );
/* Set calibration clock on */
writeR820TRegister( Register.CALIBRATION_CLOCK, (byte)0x04, false );
writeR820TRegister( Register.CALIBRATION_CLOCK, (byte)0x04, controlI2C );
/* XTAL capacitor 0pF for PLL */
writeR820TRegister( Register.PLL_XTAL_CAPACITOR, (byte)0x00, false );
writeR820TRegister( Register.PLL_XTAL_CAPACITOR, (byte)0x00, controlI2C );
setPLL( 5600 * 1000, false );
setPLL( 5600 * 1000, controlI2C );
/* Start trigger */
writeR820TRegister( Register.CALIBRATION_TRIGGER, (byte)0x10, controlI2C );
/* Stop trigger */
writeR820TRegister( Register.CALIBRATION_TRIGGER, (byte)0x00, controlI2C );
/* Set calibration clock off */
writeR820TRegister( Register.CALIBRATION_CLOCK, (byte)0x00, controlI2C );
calibrationCode = getCalibrationCode( controlI2C );
if( calibrationSuccessful( calibrationCode ) )
{
Log.info( "Calibration successful!!" );
break;
}
else
{
Log.info( "Calibration NOT successful!!" );
}
}
enableI2CRepeater( mUSBDevice, false );
if( calibrationCode == 0x0F )
{
calibrationCode = 0;
}
/* Write calibration code */
writeR820TRegister( Register.FILTER_CALIBRATION_CODE,
(byte)calibrationCode, controlI2C );
/* Set BW, Filter gain & HP Corner */
writeR820TRegister( Register.BANDWIDTH_FILTER_GAIN_HIGHPASS_FILTER_CORNER,
(byte)0x6B, controlI2C );
/* Set Image_R */
writeR820TRegister( Register.IMAGE_REVERSE, (byte)0x00, controlI2C );
/* Set filter_3db, V6MHz */
writeR820TRegister( Register.FILTER_GAIN, (byte)0x10, controlI2C );
/* Channel filter extension */
writeR820TRegister( Register.CHANNEL_FILTER_EXTENSION, (byte)0x60, controlI2C );
/* Loop through */
writeR820TRegister( Register.LOOP_THROUGH, (byte)0x00, controlI2C );
/* Loop through attenuation */
writeR820TRegister( Register.LOOP_THROUGH_ATTENUATION, (byte)0x00, controlI2C );
/* Filter extension widest */
writeR820TRegister( Register.FILTER_EXTENSION_WIDEST, (byte)0x00, controlI2C );
/* RF poly filter current */
writeR820TRegister( Register.RF_POLY_FILTER_CURRENT, (byte)0x60, controlI2C );
Log.info( "Done Setting TV Standard" );
}
private boolean calibrationSuccessful( int calibrationCode )
{
return calibrationCode != 0 && calibrationCode != 0x0F;
}
private int getCalibrationCode( boolean controlI2C ) throws UsbException
{
return getStatusRegister( 4, controlI2C ) & 0x0F;
}
private void systemFrequencySelect( int frequency, boolean controlI2C )
throws UsbException
{
/* Set pre_detect to off */
writeR820TRegister( Register.PRE_DETECT, (byte)0x00, controlI2C );
/* LNA top? */
writeR820TRegister( Register.LNA_TOP, (byte)0xE5, controlI2C );
byte mixer_top;
byte cp_cur;
byte div_buf_cur;
if( frequency == 506000000 ||
frequency == 666000000 ||
frequency == 818000000 )
{
mixer_top = (byte)0x14;
cp_cur = (byte)0x28;
div_buf_cur = (byte)0x20;
}
else
{
mixer_top = (byte)0x24;
cp_cur = (byte)0x38;
div_buf_cur = (byte)0x30;
}
writeR820TRegister( Register.MIXER_TOP, mixer_top, controlI2C );
writeR820TRegister( Register.LNA_VTH_L, (byte)0x53, controlI2C );
writeR820TRegister( Register.MIXER_VTH_L, (byte)0x76, controlI2C );
/* Air-In only for Astrometa */
writeR820TRegister( Register.AIR_CABLE1_INPUT_SELECTOR, (byte)0x00, controlI2C );
writeR820TRegister( Register.CABLE2_INPUT_SELECTOR, (byte)0x00, controlI2C );
writeR820TRegister( Register.CP_CUR, cp_cur, controlI2C );
writeR820TRegister( Register.DIVIDER_BUFFER_CURRENT, div_buf_cur, controlI2C );
writeR820TRegister( Register.FILTER_CURRENT, (byte)0x40, controlI2C );
/* Set LNA - omitted, because this is redundant to first 2 writes */
/* Write discharge mode */
writeR820TRegister( Register.MIXER_TOP2, mixer_top, controlI2C );
/* LNA discharge current */
writeR820TRegister( Register.LNA_DISCHARGE_CURRENT, (byte)0x14, controlI2C );
/* AGC clock 1 khz, external det1 cap 1u */
writeR820TRegister( Register.AGC_CLOCK, (byte)0x00, controlI2C );
writeR820TRegister( Register.UNKNOWN_REGISTER_10, (byte)0x00, controlI2C );
}
private void setPLL( int frequency, boolean controlI2C ) throws UsbException
{
/* Set reference divider to 0 */
writeR820TRegister( Register.PLL_XTAL_CAPACITOR, (byte)0x00, false );
writeR820TRegister( Register.PLL_XTAL_CAPACITOR, (byte)0x00, controlI2C );
/* Set PLL autotune to 128kHz */
writeR820TRegister( Register.PLL_AUTOTUNE, (byte)0x00, false );
writeR820TRegister( Register.PLL_AUTOTUNE, (byte)0x00, controlI2C );
/* Set VCO current to 100 */
writeR820TRegister( Register.VCO_CURRENT, (byte)0x80, false );
writeR820TRegister( Register.VCO_CURRENT, (byte)0x80, controlI2C );
/* Calculate divider */
int mix_div =2;
@@ -171,8 +388,11 @@ public class R820TTunerController extends RTL2832TunerController
int div_num = 0;
int vco_min = 1770000;
int vco_max = vco_min * 2;
int vco_power_ref = 2;
int freq_khz = (int)( ( frequency + 500 ) / 1000 );
int pll_ref = mOscillatorFrequency;
int pll_ref_khz = ( mOscillatorFrequency + 500 ) / 1000;
while( mix_div <= 64 )
{
@@ -193,6 +413,95 @@ public class R820TTunerController extends RTL2832TunerController
mix_div = mix_div << 1;
}
int statusRegister4 = getStatusRegister( 4, controlI2C );
int vco_fine_tune = ( statusRegister4 & 0x30 ) >> 4;
if( vco_fine_tune > vco_power_ref )
{
div_num--;
}
else if( vco_fine_tune < vco_power_ref )
{
div_num++;
}
writeR820TRegister( Register.DIVIDER, (byte)( div_num << 5 ), controlI2C );
long vco_freq = (long)frequency * (long)mix_div;
int nint = (int)( vco_freq / ( 2 * pll_ref ) );
int vco_fra = (int)( ( vco_freq - ( 2 * pll_ref * nint ) ) / 1000 );
if( nint > (( 128 / vco_power_ref ) - 1 ) )
{
Log.error( "R820T Tuner Controller - no valid PLL value for frequency [" + frequency + "]" );
}
int ni = ( nint - 13 ) / 4;
int si = nint - ( 4 * ni ) - 13;
writeR820TRegister( Register.UNKNOWN_REGISTER_14, (byte)ni, controlI2C );
/* PW_SDM */
if( vco_fra > 0 )
{
writeR820TRegister( Register.PW_SDM, (byte)0x08, controlI2C );
}
else
{
writeR820TRegister( Register.PW_SDM, (byte)0x00, controlI2C );
}
/* sdm calculator */
int n_sdm = 2;
int sdm = 0;
while( vco_fra > 1 )
{
if( vco_fra > ( 2 * pll_ref_khz / n_sdm ) )
{
sdm+= 32768 / ( n_sdm / 2 );
vco_fra -= 2 * pll_ref_khz / n_sdm;
if( n_sdm >= 0x8000 )
{
break;
}
}
n_sdm <<= 1;
}
writeR820TRegister( Register.SDM_MSB, (byte)( sdm >> 8 ), controlI2C );
writeR820TRegister( Register.SDM_LSB, (byte)( sdm & 0xFF ), controlI2C );
if( !isPLLLocked( controlI2C ) )
{
/* Increase VCO current */
writeR820TRegister( Register.VCO_CURRENT, (byte)0x60, controlI2C );
if( !isPLLLocked( controlI2C ) )
{
throw new UsbException( "R820T Tuner Controller - couldn't "
+ "achieve PLL lock on frequency [" + frequency + "]" );
}
}
/* set pll autotune to 8kHz */
writeR820TRegister( Register.PLL_AUTOTUNE, (byte)0x08, controlI2C );
}
/**
* Indicates if the Phase Locked Loop (PLL) is locked. Checks status
* register 2 to see if the PLL locked indicator bit is set.
*/
private boolean isPLLLocked( boolean controlI2C ) throws UsbException
{
int register = getStatusRegister( 2, controlI2C );
return ( register & 0x40 ) == 0x40;
}
/**
@@ -201,35 +510,29 @@ public class R820TTunerController extends RTL2832TunerController
* needs to be called once, upon initialization.
* @throws UsbException
*/
private void initializeRegisters() throws UsbException
private void initializeRegisters( boolean controlI2C ) throws UsbException
{
enableI2CRepeater( mUSBDevice, true );
for( int x = 5; x < mShadowRegister.length; x++ )
{
writeI2CRegister( mUSBDevice,
mI2CAddress,
(byte)x,
(byte)mShadowRegister[ x ],
false );
controlI2C );
}
enableI2CRepeater( mUSBDevice, false );
}
private void readStatusRegisters( boolean controlI2C ) throws UsbException
private int getStatusRegister( int register, boolean controlI2C ) throws UsbException
{
/* Set the I2C bus to register 0 to read 5 bytes */
writeI2CRegister( mUSBDevice, mI2CAddress, (byte)0, (byte)5, controlI2C );
byte[] data = new byte[ 5 ];
byte[] status = read( mUSBDevice, Block.IIC, (byte)0, data );
for( int x = 0; x < 5; x++ )
{
mShadowRegister[ x ] = status[ x ];
}
if( 0 <= register && register <= 4 )
{
return readI2CRegister( mUSBDevice, mI2CAddress, (byte)register, controlI2C );
}
else
{
throw new IllegalArgumentException( "R820T Tuner Controller - "
+ "attempt to read unknown status register #" + register );
}
}
public void writeR820TRegister( Register register,
@@ -259,7 +562,55 @@ public class R820TTunerController extends RTL2832TunerController
controlI2C );
}
public enum VGAGain
private void getGain() throws UsbException
{
int gain = getStatusRegister( 3, true );
Log.info( "Gain original value is [" + gain + "]" );
int converted = ( ( gain & 0x0F ) << 1 ) + ( ( gain & 0xF0 ) >> 4 );
Log.info( "Gain converted value is [" + converted + "]" );
}
public void setGain( R820TGain gain, boolean controlI2C ) throws UsbException
{
setLNAGain( gain.getLNAGain(), controlI2C );
setMixerGain( gain.getMixerGain(), controlI2C );
setVGAGain( gain.getVGAGain(), controlI2C );
}
public void setLNAGain( R820TLNAGain gain, boolean controlI2C ) throws UsbException
{
writeR820TRegister( Register.LNA_GAIN, gain.getSetting(), controlI2C );
}
public R820TLNAGain getLNAGain( boolean controlI2C ) throws UsbException
{
return null;
}
public void setMixerGain( R820TMixerGain gain, boolean controlI2C ) throws UsbException
{
writeR820TRegister( Register.MIXER_GAIN, gain.getSetting(), controlI2C );
}
public R820TMixerGain getMixerGain( boolean controlI2C ) throws UsbException
{
return null;
}
public void setVGAGain( R820TVGAGain gain, boolean controlI2C ) throws UsbException
{
writeR820TRegister( Register.VGA_GAIN, gain.getSetting(), controlI2C );
}
public R820TVGAGain getVGAGain( boolean controlI2C ) throws UsbException
{
return null;
}
public enum R820TVGAGain
{
GAIN_0( "0", 0x00 ),
GAIN_26( "26", 0x01 ),
@@ -281,7 +632,7 @@ public class R820TTunerController extends RTL2832TunerController
private String mLabel;
private int mSetting;
private VGAGain( String label, int setting )
private R820TVGAGain( String label, int setting )
{
mLabel = label;
mSetting = setting;
@@ -298,7 +649,7 @@ public class R820TTunerController extends RTL2832TunerController
}
}
public enum LNAGain
public enum R820TLNAGain
{
AUTOMATIC( "Automatic", 0x00 ),
GAIN_0( "0", 0x10 ),
@@ -321,7 +672,7 @@ public class R820TTunerController extends RTL2832TunerController
private String mLabel;
private int mSetting;
private LNAGain( String label, int setting )
private R820TLNAGain( String label, int setting )
{
mLabel = label;
mSetting = setting;
@@ -338,7 +689,7 @@ public class R820TTunerController extends RTL2832TunerController
}
}
public enum MixerGain
public enum R820TMixerGain
{
AUTOMATIC( "Automatic", 0x10 ),
GAIN_0( "0", 0x00 ),
@@ -361,7 +712,7 @@ public class R820TTunerController extends RTL2832TunerController
private String mLabel;
private int mSetting;
private MixerGain( String label, int setting )
private R820TMixerGain( String label, int setting )
{
mLabel = label;
mSetting = setting;
@@ -378,47 +729,47 @@ public class R820TTunerController extends RTL2832TunerController
}
}
public enum Gain
public enum R820TGain
{
AUTOMATIC( "Automatic", VGAGain.GAIN_312, LNAGain.AUTOMATIC, MixerGain.AUTOMATIC ),
MANUAL( "Manual", VGAGain.GAIN_210, LNAGain.GAIN_112, MixerGain.GAIN_105 ),
GAIN_0( "0", VGAGain.GAIN_210, LNAGain.GAIN_0, MixerGain.GAIN_0 ),
GAIN_9( "9", VGAGain.GAIN_210, LNAGain.GAIN_9, MixerGain.GAIN_0 ),
GAIN_14( "14", VGAGain.GAIN_210, LNAGain.GAIN_9, MixerGain.GAIN_5 ),
GAIN_26( "26", VGAGain.GAIN_210, LNAGain.GAIN_21, MixerGain.GAIN_5 ),
GAIN_36( "36", VGAGain.GAIN_210, LNAGain.GAIN_21, MixerGain.GAIN_15 ),
GAIN_76( "76", VGAGain.GAIN_210, LNAGain.GAIN_61, MixerGain.GAIN_15 ),
GAIN_86( "86", VGAGain.GAIN_210, LNAGain.GAIN_61, MixerGain.GAIN_25 ),
GAIN_124( "124", VGAGain.GAIN_210, LNAGain.GAIN_99, MixerGain.GAIN_25 ),
GAIN_143( "143", VGAGain.GAIN_210, LNAGain.GAIN_99, MixerGain.GAIN_44 ),
GAIN_156( "156", VGAGain.GAIN_210, LNAGain.GAIN_112, MixerGain.GAIN_44 ),
GAIN_165( "165", VGAGain.GAIN_210, LNAGain.GAIN_112, MixerGain.GAIN_53 ),
GAIN_196( "196", VGAGain.GAIN_210, LNAGain.GAIN_143, MixerGain.GAIN_53 ),
GAIN_208( "208", VGAGain.GAIN_210, LNAGain.GAIN_143, MixerGain.GAIN_63 ),
GAIN_228( "228", VGAGain.GAIN_210, LNAGain.GAIN_165, MixerGain.GAIN_63 ),
GAIN_253( "253", VGAGain.GAIN_210, LNAGain.GAIN_165, MixerGain.GAIN_88 ),
GAIN_279( "279", VGAGain.GAIN_210, LNAGain.GAIN_191, MixerGain.GAIN_88 ),
GAIN_296( "296", VGAGain.GAIN_210, LNAGain.GAIN_191, MixerGain.GAIN_105 ),
GAIN_327( "327", VGAGain.GAIN_210, LNAGain.GAIN_222, MixerGain.GAIN_105 ),
GAIN_337( "337", VGAGain.GAIN_210, LNAGain.GAIN_222, MixerGain.GAIN_115 ),
GAIN_363( "363", VGAGain.GAIN_210, LNAGain.GAIN_248, MixerGain.GAIN_115 ),
GAIN_371( "371", VGAGain.GAIN_210, LNAGain.GAIN_248, MixerGain.GAIN_123 ),
GAIN_385( "385", VGAGain.GAIN_210, LNAGain.GAIN_262, MixerGain.GAIN_123 ),
GAIN_401( "401", VGAGain.GAIN_210, LNAGain.GAIN_262, MixerGain.GAIN_139 ),
GAIN_420( "420", VGAGain.GAIN_210, LNAGain.GAIN_281, MixerGain.GAIN_139 ),
GAIN_433( "433", VGAGain.GAIN_210, LNAGain.GAIN_281, MixerGain.GAIN_152 ),
GAIN_438( "438", VGAGain.GAIN_210, LNAGain.GAIN_286, MixerGain.GAIN_152 ),
GAIN_444( "444", VGAGain.GAIN_210, LNAGain.GAIN_286, MixerGain.GAIN_158 ),
GAIN_479( "479", VGAGain.GAIN_210, LNAGain.GAIN_321, MixerGain.GAIN_158 ),
GAIN_482( "482", VGAGain.GAIN_210, LNAGain.GAIN_321, MixerGain.GAIN_161 ),
GAIN_495( "495", VGAGain.GAIN_210, LNAGain.GAIN_334, MixerGain.GAIN_161 );
AUTOMATIC( "Automatic", R820TVGAGain.GAIN_312, R820TLNAGain.AUTOMATIC, R820TMixerGain.AUTOMATIC ),
MANUAL( "Manual", R820TVGAGain.GAIN_210, R820TLNAGain.GAIN_112, R820TMixerGain.GAIN_105 ),
GAIN_0( "0", R820TVGAGain.GAIN_210, R820TLNAGain.GAIN_0, R820TMixerGain.GAIN_0 ),
GAIN_9( "9", R820TVGAGain.GAIN_210, R820TLNAGain.GAIN_9, R820TMixerGain.GAIN_0 ),
GAIN_14( "14", R820TVGAGain.GAIN_210, R820TLNAGain.GAIN_9, R820TMixerGain.GAIN_5 ),
GAIN_26( "26", R820TVGAGain.GAIN_210, R820TLNAGain.GAIN_21, R820TMixerGain.GAIN_5 ),
GAIN_36( "36", R820TVGAGain.GAIN_210, R820TLNAGain.GAIN_21, R820TMixerGain.GAIN_15 ),
GAIN_76( "76", R820TVGAGain.GAIN_210, R820TLNAGain.GAIN_61, R820TMixerGain.GAIN_15 ),
GAIN_86( "86", R820TVGAGain.GAIN_210, R820TLNAGain.GAIN_61, R820TMixerGain.GAIN_25 ),
GAIN_124( "124", R820TVGAGain.GAIN_210, R820TLNAGain.GAIN_99, R820TMixerGain.GAIN_25 ),
GAIN_143( "143", R820TVGAGain.GAIN_210, R820TLNAGain.GAIN_99, R820TMixerGain.GAIN_44 ),
GAIN_156( "156", R820TVGAGain.GAIN_210, R820TLNAGain.GAIN_112, R820TMixerGain.GAIN_44 ),
GAIN_165( "165", R820TVGAGain.GAIN_210, R820TLNAGain.GAIN_112, R820TMixerGain.GAIN_53 ),
GAIN_196( "196", R820TVGAGain.GAIN_210, R820TLNAGain.GAIN_143, R820TMixerGain.GAIN_53 ),
GAIN_208( "208", R820TVGAGain.GAIN_210, R820TLNAGain.GAIN_143, R820TMixerGain.GAIN_63 ),
GAIN_228( "228", R820TVGAGain.GAIN_210, R820TLNAGain.GAIN_165, R820TMixerGain.GAIN_63 ),
GAIN_253( "253", R820TVGAGain.GAIN_210, R820TLNAGain.GAIN_165, R820TMixerGain.GAIN_88 ),
GAIN_279( "279", R820TVGAGain.GAIN_210, R820TLNAGain.GAIN_191, R820TMixerGain.GAIN_88 ),
GAIN_296( "296", R820TVGAGain.GAIN_210, R820TLNAGain.GAIN_191, R820TMixerGain.GAIN_105 ),
GAIN_327( "327", R820TVGAGain.GAIN_210, R820TLNAGain.GAIN_222, R820TMixerGain.GAIN_105 ),
GAIN_337( "337", R820TVGAGain.GAIN_210, R820TLNAGain.GAIN_222, R820TMixerGain.GAIN_115 ),
GAIN_363( "363", R820TVGAGain.GAIN_210, R820TLNAGain.GAIN_248, R820TMixerGain.GAIN_115 ),
GAIN_371( "371", R820TVGAGain.GAIN_210, R820TLNAGain.GAIN_248, R820TMixerGain.GAIN_123 ),
GAIN_385( "385", R820TVGAGain.GAIN_210, R820TLNAGain.GAIN_262, R820TMixerGain.GAIN_123 ),
GAIN_401( "401", R820TVGAGain.GAIN_210, R820TLNAGain.GAIN_262, R820TMixerGain.GAIN_139 ),
GAIN_420( "420", R820TVGAGain.GAIN_210, R820TLNAGain.GAIN_281, R820TMixerGain.GAIN_139 ),
GAIN_433( "433", R820TVGAGain.GAIN_210, R820TLNAGain.GAIN_281, R820TMixerGain.GAIN_152 ),
GAIN_438( "438", R820TVGAGain.GAIN_210, R820TLNAGain.GAIN_286, R820TMixerGain.GAIN_152 ),
GAIN_444( "444", R820TVGAGain.GAIN_210, R820TLNAGain.GAIN_286, R820TMixerGain.GAIN_158 ),
GAIN_479( "479", R820TVGAGain.GAIN_210, R820TLNAGain.GAIN_321, R820TMixerGain.GAIN_158 ),
GAIN_482( "482", R820TVGAGain.GAIN_210, R820TLNAGain.GAIN_321, R820TMixerGain.GAIN_161 ),
GAIN_495( "495", R820TVGAGain.GAIN_210, R820TLNAGain.GAIN_334, R820TMixerGain.GAIN_161 );
private String mLabel;
private VGAGain mVGAGain;
private LNAGain mLNAGain;
private MixerGain mMixerGain;
private R820TVGAGain mVGAGain;
private R820TLNAGain mLNAGain;
private R820TMixerGain mMixerGain;
private Gain( String label, VGAGain vga, LNAGain lna, MixerGain mixer )
private R820TGain( String label, R820TVGAGain vga, R820TLNAGain lna, R820TMixerGain mixer )
{
mLabel = label;
mVGAGain = vga;
@@ -431,17 +782,17 @@ public class R820TTunerController extends RTL2832TunerController
return mLabel;
}
public VGAGain getVGAGain()
public R820TVGAGain getVGAGain()
{
return mVGAGain;
}
public LNAGain getLNAGain()
public R820TLNAGain getLNAGain()
{
return mLNAGain;
}
public MixerGain getMixerGain()
public R820TMixerGain getMixerGain()
{
return mMixerGain;
}
@@ -526,46 +877,52 @@ public class R820TTunerController extends RTL2832TunerController
public enum FrequencyRange
{
BAND_024( 24000000, 49999999, 0x08, 0x02, 0xDF, 0x02, 0x01 ),
BAND_050( 50000000, 54999999, 0x08, 0x02, 0xBE, 0x02, 0x01 ),
BAND_055( 55000000, 59999999, 0x08, 0x02, 0x8B, 0x02, 0x01 ),
BAND_060( 60000000, 64999999, 0x08, 0x02, 0x7B, 0x02, 0x01 ),
BAND_065( 65000000, 69999999, 0x08, 0x02, 0x69, 0x02, 0x01 ),
BAND_070( 70000000, 74999999, 0x08, 0x02, 0x58, 0x02, 0x01 ),
BAND_075( 75000000, 79999999, 0x00, 0x02, 0x44, 0x02, 0x01 ),
BAND_080( 80000000, 89999999, 0x00, 0x02, 0x44, 0x02, 0x01 ),
BAND_090( 90000000, 99999999, 0x00, 0x02, 0x34, 0x01, 0x01 ),
BAND_100( 100000000, 109999999, 0x00, 0x02, 0x34, 0x01, 0x01 ),
BAND_110( 110000000, 119999999, 0x00, 0x02, 0x24, 0x01, 0x01 ),
BAND_120( 120000000, 139999999, 0x00, 0x02, 0x24, 0x01, 0x01 ),
BAND_140( 140000000, 179999999, 0x00, 0x02, 0x14, 0x01, 0x01 ),
BAND_180( 180000000, 219999999, 0x00, 0x02, 0x13, 0x00, 0x00 ),
BAND_220( 220000000, 249999999, 0x00, 0x02, 0x13, 0x00, 0x00 ),
BAND_250( 250000000, 279999999, 0x00, 0x02, 0x11, 0x00, 0x00 ),
BAND_280( 280000000, 309999999, 0x00, 0x02, 0x00, 0x00, 0x00 ),
BAND_310( 310000000, 449999999, 0x00, 0x41, 0x00, 0x00, 0x00 ),
BAND_450( 450000000, 587999999, 0x00, 0x41, 0x00, 0x00, 0x00 ),
BAND_588( 588000000, 649999999, 0x00, 0x40, 0x00, 0x00, 0x00 ),
BAND_650( 650000000, 1766000000, 0x00, 0x40, 0x00, 0x00, 0x00 ),
BAND_UNK( 0, 0, 0, 0, 0, 0, 0 );
RANGE_024( 24000000, 49999999, 0x08, 0x02, 0xDF, 0x02, 0x01 ),
RANGE_050( 50000000, 54999999, 0x08, 0x02, 0xBE, 0x02, 0x01 ),
RANGE_055( 55000000, 59999999, 0x08, 0x02, 0x8B, 0x02, 0x01 ),
RANGE_060( 60000000, 64999999, 0x08, 0x02, 0x7B, 0x02, 0x01 ),
RANGE_065( 65000000, 69999999, 0x08, 0x02, 0x69, 0x02, 0x01 ),
RANGE_070( 70000000, 74999999, 0x08, 0x02, 0x58, 0x02, 0x01 ),
RANGE_075( 75000000, 79999999, 0x00, 0x02, 0x44, 0x02, 0x01 ),
RANGE_080( 80000000, 89999999, 0x00, 0x02, 0x44, 0x02, 0x01 ),
RANGE_090( 90000000, 99999999, 0x00, 0x02, 0x34, 0x01, 0x01 ),
RANGE_100( 100000000, 109999999, 0x00, 0x02, 0x34, 0x01, 0x01 ),
RANGE_110( 110000000, 119999999, 0x00, 0x02, 0x24, 0x01, 0x01 ),
RANGE_120( 120000000, 139999999, 0x00, 0x02, 0x24, 0x01, 0x01 ),
RANGE_140( 140000000, 179999999, 0x00, 0x02, 0x14, 0x01, 0x01 ),
RANGE_180( 180000000, 219999999, 0x00, 0x02, 0x13, 0x00, 0x00 ),
RANGE_220( 220000000, 249999999, 0x00, 0x02, 0x13, 0x00, 0x00 ),
RANGE_250( 250000000, 279999999, 0x00, 0x02, 0x11, 0x00, 0x00 ),
RANGE_280( 280000000, 309999999, 0x00, 0x02, 0x00, 0x00, 0x00 ),
RANGE_310( 310000000, 449999999, 0x00, 0x41, 0x00, 0x00, 0x00 ),
RANGE_450( 450000000, 587999999, 0x00, 0x41, 0x00, 0x00, 0x00 ),
RANGE_588( 588000000, 649999999, 0x00, 0x40, 0x00, 0x00, 0x00 ),
RANGE_650( 650000000, 1766000000, 0x00, 0x40, 0x00, 0x00, 0x00 ),
RANGE_UNK( 0, 0, 0, 0, 0, 0, 0 );
private int mMinFrequency;
private int mMaxFrequency;
private int mOpenD;
private int mRFMuxPloy;
private int mOpenDrain;
private int mRFMux_PolyMux;
private int mTF_c;
private int mXtalCap20p;
private int mXtalCap10p;
private FrequencyRange( int minFrequency,
int maxFrequency,
int openD,
int openDrain,
int rfMuxPloy,
int tf_c,
int xtalCap20p,
int xtalCap10p )
{
mMinFrequency = minFrequency;
mMaxFrequency = maxFrequency;
mOpenDrain = openDrain;
mRFMux_PolyMux = rfMuxPloy;
mTF_c = tf_c;
mXtalCap20p = xtalCap20p;
mXtalCap10p = xtalCap10p;
}
public boolean contains( int frequency )
@@ -583,7 +940,7 @@ public class R820TTunerController extends RTL2832TunerController
}
}
return BAND_UNK;
return RANGE_UNK;
}
public int getMinFrequency()
@@ -596,14 +953,14 @@ public class R820TTunerController extends RTL2832TunerController
return mMaxFrequency;
}
public byte getOpenD()
public byte getOpenDrain()
{
return (byte)mOpenD;
return (byte)mOpenDrain;
}
public byte getRFMuxPloy()
public byte getRFMuxPolyMux()
{
return (byte)mRFMuxPloy;
return (byte)mRFMux_PolyMux;
}
public byte getTFC()
@@ -621,9 +978,14 @@ public class R820TTunerController extends RTL2832TunerController
return (byte)mXtalCap10p;
}
public byte getXTALCap0P()
public byte getXTALLowCap0P()
{
return (byte)0x0;
return (byte)0x08;
}
public byte getXTALHighCap0P()
{
return (byte)0x10;
}
}

View File

@@ -84,7 +84,7 @@ public class R820TTunerEditorPanel extends JPanel implements FrequencyChangeList
}
catch ( SourceException e )
{
Log.error( "E4KTunerController - error setting frequency [" +
Log.error( "R820T Tuner Controller - error setting frequency [" +
frequency + "] - " + e.getLocalizedMessage() );
}
}