Skip to content

Commit

Permalink
The changes seem to never end!
Browse files Browse the repository at this point in the history
- add settings to the tuner settings dialog (eg. multi-channel decrypt mode) and fix some existing exceptions and field availability issues in there
- add new idle modes to enable lower power use (Unload) or faster tuning (AlwaysOn)
- tidy up usage of helper classes that only exist to show card name in combo boxes
- remove obsolete DB column Card.recordingFormat
- more flexible implementation of plugin device change callbacks
- add LNB type to DVB-S tuning details
- remove no-longer-needed MD debug
- remove not-working Conexant direct tuning
- limit tuner selection in SmarDTV USB CI plugin to reasonable selections
  • Loading branch information
mm1352000 committed Jul 5, 2012
1 parent ea7b234 commit 419f0da
Show file tree
Hide file tree
Showing 63 changed files with 1,700 additions and 1,664 deletions.
Expand Up @@ -292,7 +292,7 @@ private List<Schedule>[] AssignSchedulesToCards(IList<Schedule> Schedules)
{
if (schedule.IsOverlapping(assignedShedule))
{
if (!(schedule.isSameTransponder(assignedShedule) && card.supportSubChannels))
if (!schedule.isSameTransponder(assignedShedule))
{
free = false;
//_overlap = true;
Expand Down
226 changes: 1 addition & 225 deletions TvEngine3/TVLibrary/Plugins/CustomDevices/Conexant/Conexant.cs
Expand Up @@ -33,7 +33,7 @@ namespace TvEngine
/// A base class for handling DiSEqC for various Conexant-based devices including Hauppauge, Geniatech
/// and DVBSky.
/// </summary>
public class Conexant : BaseCustomDevice/*, ICustomTuner*/, IDiseqcDevice
public class Conexant : BaseCustomDevice, IDiseqcDevice
{
#region enums

Expand Down Expand Up @@ -68,63 +68,6 @@ private enum CxDiseqcReceiveMode : uint
NoReply, // Expecting no response.
}

private enum CxModulation
{
Undefined = 0,
DvbsQpsk,
DvbsBpsk,
// Digicipher II (Dish TV)
DciiQpskMux,
DciiQpskSplitI,
DciiQpskSplitQ
}

[Flags]
private enum CxFecRate
{
None = 0,
Rate1_2 = 1,
Rate2_3 = 2,
Rate3_4 = 4,
Rate4_5 = 8,
Rate5_6 = 16,
Rate6_7 = 32,
Rate7_8 = 64,
Rate5_11 = 128, // DC II
Rate3_5 = 256 // DC II
}

private enum CxSpectralInversion
{
Undefined = 0,
Off, // Uninverted, check only nominal inversion.
On, // Inverted, check only nominal inversion.
OnBoth, // Uninverted, check both inversions.
OffBoth // Inverted, check both inversions.
}

private enum CxSampleFrequency
{
Undefined = 0,
Nominal,
DciiNominal,
External
}

private enum CxPolarisation
{
Undefined = 0,
High, // 18 V = linear horizontal or circular left
Low // 13 V = linear vertical or circular right
}

private enum CxTone22k
{
Undefined = 0,
On,
Off
}

#endregion

#region structs
Expand All @@ -147,20 +90,6 @@ private struct DiseqcMessageParams
public bool IsLastMessage;
}

[StructLayout(LayoutKind.Sequential, Pack = 1)]
private struct ChannelParams
{
public UInt32 Frequency;
public CxModulation Modulation;
public CxFecRate FecRate;
public UInt32 SymbolRate;
public CxSpectralInversion SpectralInversion;
public CxSampleFrequency SampleRate;
public CxPolarisation Polarisation;
public CxTone22k Tone22k;
public UInt32 FecRates; // CxFecRate values OR'd together.
}

#endregion

#region constants
Expand All @@ -175,7 +104,6 @@ private struct ChannelParams
private const int DiseqcMessageParamsSize = 188;
private const int MaxDiseqcTxMessageLength = 151; // 3 bytes per message * 50 messages, plus NULL termination
private const int MaxDiseqcRxMessageLength = 9; // reply first-in-first-out buffer size (hardware limited)
private const int ChannelParamsSize = 36;

#endregion

Expand Down Expand Up @@ -306,158 +234,6 @@ public override bool Initialise(IBaseFilter tunerFilter, CardType tunerType, Str

#endregion

#region ICustomTuner members

/// <summary>
/// Check if the device implements specialised tuning for a given channel.
/// </summary>
/// <param name="channel">The channel to check.</param>
/// <returns><c>true</c> if the device supports specialised tuning for the channel, otherwise <c>false</c></returns>
public bool CanTuneChannel(IChannel channel)
{
if (channel is DVBSChannel)
{
return true;
}
return false;
}

/// <summary>
/// Tune to a given channel using the specialised tuning method.
/// </summary>
/// <param name="channel">The channel to tune.</param>
/// <returns><c>true</c> if the channel is successfully tuned, otherwise <c>false</c></returns>
public bool Tune(IChannel channel)
{
Log.Debug("Conexant: tune to channel");

if (!_isConexant || _propertySet == null)
{
Log.Debug("Conexant: device not initialised or interface not supported");
return false;
}
if (!CanTuneChannel(channel))
{
Log.Debug("Conexant: tuning is not supported for this channel");
return false;
}

DVBSChannel dvbsChannel = channel as DVBSChannel;
ChannelParams tuningParams = new ChannelParams();

// See OnBeforeTune() in the Genpix plugin for more details about these mappings.
bool isDigicipher = false;
CxModulation modulation = CxModulation.Undefined;
switch (dvbsChannel.ModulationType)
{
case ModulationType.ModNotSet:
modulation = CxModulation.DvbsQpsk;
break;
case ModulationType.ModBpsk:
modulation = CxModulation.DvbsBpsk;
break;
case ModulationType.Mod768Qam:
modulation = CxModulation.DciiQpskMux;
isDigicipher = true;
break;
case ModulationType.Mod896Qam:
modulation = CxModulation.DciiQpskSplitI;
isDigicipher = true;
break;
case ModulationType.Mod1024Qam:
modulation = CxModulation.DciiQpskSplitQ;
isDigicipher = true;
break;
}
tuningParams.Modulation = modulation;

CxFecRate fecRate = CxFecRate.None;
switch (dvbsChannel.InnerFecRate)
{
case BinaryConvolutionCodeRate.Rate1_2:
fecRate = CxFecRate.Rate1_2;
break;
case BinaryConvolutionCodeRate.Rate2_3:
fecRate = CxFecRate.Rate2_3;
break;
case BinaryConvolutionCodeRate.Rate3_4:
fecRate = CxFecRate.Rate3_4;
break;
case BinaryConvolutionCodeRate.Rate4_5:
fecRate = CxFecRate.Rate4_5;
break;
case BinaryConvolutionCodeRate.Rate5_6:
fecRate = CxFecRate.Rate5_6;
break;
// Probably DC II only.
case BinaryConvolutionCodeRate.Rate6_7:
fecRate = CxFecRate.Rate6_7;
break;
case BinaryConvolutionCodeRate.Rate7_8:
fecRate = CxFecRate.Rate7_8;
break;
// DC II, not DVB-S2.
case BinaryConvolutionCodeRate.Rate5_11:
fecRate = CxFecRate.Rate5_11;
break;
// DC II, not DVB-S2.
case BinaryConvolutionCodeRate.Rate3_5:
fecRate = CxFecRate.Rate3_5;
break;
}
tuningParams.FecRate = fecRate;
tuningParams.SymbolRate = (UInt32)dvbsChannel.SymbolRate;
tuningParams.SpectralInversion = CxSpectralInversion.OffBoth; // Not sure what should be used here.
if (isDigicipher)
{
tuningParams.SampleRate = CxSampleFrequency.DciiNominal;
}
else
{
tuningParams.SampleRate = CxSampleFrequency.Nominal;
}
if (dvbsChannel.Polarisation == Polarisation.LinearH || dvbsChannel.Polarisation == Polarisation.CircularL)
{
tuningParams.Polarisation = CxPolarisation.High;
}
else
{
tuningParams.Polarisation = CxPolarisation.Low;
}

uint lnbLof;
uint lnbSwitchFrequency;
Polarisation polarisation;
LnbTypeConverter.GetLnbTuningParameters(dvbsChannel, out lnbLof, out lnbSwitchFrequency, out polarisation);

// Convert to intermediate frequency in kHz.
tuningParams.Frequency = (UInt32)dvbsChannel.Frequency - lnbLof;

tuningParams.Tone22k = CxTone22k.Off;
if (dvbsChannel.Frequency > lnbSwitchFrequency)
{
tuningParams.Tone22k = CxTone22k.On;
}

Marshal.StructureToPtr(tuningParams, _paramBuffer, true);
DVB_MMI.DumpBinary(_paramBuffer, 0, ChannelParamsSize);

int hr = _propertySet.Set(BdaExtensionPropertySet, (int)BdaExtensionProperty.ChannelChange,
_instanceBuffer, InstanceSize,
_paramBuffer, ChannelParamsSize + 16
);
if (hr == 0)
{
Log.Debug("Conexant: result = success");
return true;
}

Log.Debug("Conexant: result = failure, hr = 0x{0:x} ({1})", hr, HResult.GetDXErrorString(hr));
return false;
}

#endregion

#region IDiseqcDevice members

/// <summary>
Expand Down
Expand Up @@ -486,15 +486,15 @@ public override bool Initialise(IBaseFilter tunerFilter, CardType tunerType, Str
return true;
}

#region graph state change callbacks
#region device state change callbacks

/// <summary>
/// This callback is invoked after a tune request is submitted, when the device's BDA graph is running
/// but before signal lock is checked.
/// This callback is invoked after a tune request is submitted, when the device is running but before
/// signal lock is checked.
/// </summary>
/// <param name="tuner">The tuner instance that this device instance is associated with.</param>
/// <param name="currentChannel">The channel that the tuner is tuned to.</param>
public override void OnGraphRunning(ITVCard tuner, IChannel currentChannel)
public override void OnRunning(ITVCard tuner, IChannel currentChannel)
{
// Ensure the MMI handler thread is always running when the graph is running.
StartMmiHandlerThread();
Expand Down
Expand Up @@ -990,19 +990,19 @@ public override bool Initialise(IBaseFilter tunerFilter, CardType tunerType, Str
return true;
}

#region graph state change callbacks
#region device state change callbacks

/// <summary>
/// This callback is invoked before a tune request is assembled.
/// </summary>
/// <param name="tuner">The tuner instance that this device instance is associated with.</param>
/// <param name="currentChannel">The channel that the tuner is currently tuned to..</param>
/// <param name="channel">The channel that the tuner will been tuned to.</param>
/// <param name="forceGraphStart">Ensure that the tuner's BDA graph is running when the tune request is submitted.</param>
public override void OnBeforeTune(ITVCard tuner, IChannel currentChannel, ref IChannel channel, out bool forceGraphStart)
/// <param name="action">The action to take, if any.</param>
public override void OnBeforeTune(ITVCard tuner, IChannel currentChannel, ref IChannel channel, out DeviceAction action)
{
Log.Debug("Digital Everywhere: on before tune callback");
forceGraphStart = false;
action = DeviceAction.Default;

if (!_isDigitalEverywhere)
{
Expand Down Expand Up @@ -1064,12 +1064,12 @@ public override void OnBeforeTune(ITVCard tuner, IChannel currentChannel, ref IC
}

/// <summary>
/// This callback is invoked after a tune request is submitted, when the device's BDA graph is running
/// but before signal lock is checked.
/// This callback is invoked after a tune request is submitted, when the device is running but before
/// signal lock is checked.
/// </summary>
/// <param name="tuner">The tuner instance that this device instance is associated with.</param>
/// <param name="currentChannel">The channel that the tuner is tuned to.</param>
public override void OnGraphRunning(ITVCard tuner, IChannel currentChannel)
public override void OnRunning(ITVCard tuner, IChannel currentChannel)
{
// Ensure the MMI handler thread is always running when the graph is running.
StartMmiHandlerThread();
Expand Down
Expand Up @@ -160,19 +160,19 @@ public override bool Initialise(IBaseFilter tunerFilter, CardType tunerType, Str
return true;
}

#region graph state change callbacks
#region device state change callbacks

/// <summary>
/// This callback is invoked before a tune request is assembled.
/// </summary>
/// <param name="tuner">The tuner instance that this device instance is associated with.</param>
/// <param name="currentChannel">The channel that the tuner is currently tuned to..</param>
/// <param name="channel">The channel that the tuner will been tuned to.</param>
/// <param name="forceGraphStart">Ensure that the tuner's BDA graph is running when the tune request is submitted.</param>
public override void OnBeforeTune(ITVCard tuner, IChannel currentChannel, ref IChannel channel, out bool forceGraphStart)
/// <param name="action">The action to take, if any.</param>
public override void OnBeforeTune(ITVCard tuner, IChannel currentChannel, ref IChannel channel, out DeviceAction action)
{
Log.Debug("Geniatech: on before tune callback");
forceGraphStart = false;
action = DeviceAction.Default;

if (!_isGeniatech || _propertySet == null)
{
Expand Down

0 comments on commit 419f0da

Please sign in to comment.