Skip to content

Commit

Permalink
Implement SetTuningParameters() in the Twinhan class and update SetTo…
Browse files Browse the repository at this point in the history
…neState() to use the new generic tone state enums merged from my main branch.
  • Loading branch information
mm1352000 committed Dec 25, 2011
1 parent 15b4d6e commit 2c50074
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 32 deletions.
Expand Up @@ -160,7 +160,7 @@ public IHardwareProvider HWProvider
{
Log.Log.WriteFile("Twinhan card detected");
_diSEqCMotor = new DiSEqCMotor(_twinhan);
_HWProvider = _twinhan;
_HWProvider = _twinhan;
Log.Log.WriteFile("Twinhan registering CI menu capabilities");
_ciMenu = _twinhan; // Register Twinhan CI Menu capabilities when CAM detected and ready
return;
Expand Down Expand Up @@ -844,28 +844,7 @@ public DVBSChannel SetDVBS2Modulation(ScanParameters parameters, DVBSChannel cha
{
if (_twinhan != null)
{
//DVB-S2 modulation parameters for Twinhan
if (channel.ModulationType == ModulationType.ModQpsk)
{
channel.ModulationType = ModulationType.Mod8Vsb;
}
if (channel.ModulationType == ModulationType.Mod8Psk)
{
channel.ModulationType = ModulationType.Mod8Vsb;
}
if (channel.ModulationType == ModulationType.Mod16Apsk)
{
channel.ModulationType = ModulationType.Mod16Vsb;
}
if (channel.ModulationType == ModulationType.Mod32Apsk)
{
channel.ModulationType = ModulationType.ModOqpsk;
}
Log.Log.WriteFile("Twinhan DVB-S2 modulation set to:{0}", channel.ModulationType);
Log.Log.WriteFile("Twinhan DVB-S2 Pilot set to:{0}", channel.Pilot);
Log.Log.WriteFile("Twinhan DVB-S2 RollOff set to:{0}", channel.Rolloff);
Log.Log.WriteFile("Twinhan DVB-S2 fec set to:{0}", channel.InnerFecRate);
return channel;
return _twinhan.SetTuningParameters(channel);
}
if (_hauppauge != null)
{
Expand Down
Expand Up @@ -1168,21 +1168,33 @@ public bool SetLnbPowerState(bool powerOn)
/// <param name="toneBurstState">The tone/data burst state.</param>
/// <param name="tone22kState">The 22 kHz legacy tone state.</param>
/// <returns><c>true</c> if the tone state is set successfully, otherwise <c>false</c></returns>
private bool SetToneState(TwinhanToneBurst toneBurstState, Twinhan22k tone22kState)
private bool SetToneState(ToneBurst toneBurstState, Tone22k tone22kState)
{
Log.Log.Debug("Twinhan: set tone state, burst = {0}, 22 kHz = {1}", toneBurstState, tone22kState);

LnbParams lnbParams = new LnbParams();
lnbParams.PowerOn = true;
lnbParams.ToneBurst = toneBurstState;
lnbParams.ToneBurst = TwinhanToneBurst.Off;
if (toneBurstState == ToneBurst.ToneBurst)
{
lnbParams.ToneBurst = TwinhanToneBurst.ToneBurst;
}
else if (toneBurstState == ToneBurst.DataBurst)
{
lnbParams.ToneBurst = TwinhanToneBurst.DataBurst;
}
// It is not critical to set the LNB frequencies as these are set
// on the tuning space in the tuning request. Even when attempting
// to use the custom tuning method you specify the intermediate
// frequency.
lnbParams.LowBandLof = 0;
lnbParams.HighBandLof = 0;
lnbParams.SwitchFrequency = 0;
lnbParams.Tone22k = tone22kState;
lnbParams.Tone22k = Twinhan22k.Off;
if (tone22kState == Tone22k.On)
{
lnbParams.Tone22k = Twinhan22k.On;
}
lnbParams.DiseqcPort = TwinhanDiseqcPort.Null;

Marshal.StructureToPtr(lnbParams, _responseBuffer, true);
Expand Down Expand Up @@ -1230,6 +1242,32 @@ public void ResetDevice()
}
}

/// <summary>
/// Set DVB-S2 tuning parameters that could not previously be set through BDA interfaces.
/// </summary>
/// <param name="channel">The channel to tune.</param>
/// <returns>The channel with DVB-S2 parameters set.</returns>
public DVBSChannel SetTuningParameters(DVBSChannel channel)
{
Log.Log.Debug("Twinhan: set tuning parameters");
if (channel.ModulationType == ModulationType.ModQpsk || channel.ModulationType == ModulationType.Mod8Psk)
{
channel.ModulationType = ModulationType.Mod8Vsb;
}
// I don't think any Twinhan tuners or clones support demodulating anything
// higher than 8 PSK. Nevertheless...
else if (channel.ModulationType == ModulationType.Mod16Apsk)
{
channel.ModulationType = ModulationType.Mod16Vsb;
}
else if (channel.ModulationType == ModulationType.Mod32Apsk)
{
channel.ModulationType = ModulationType.ModOqpsk;
}
Log.Log.Debug(" modulation = {0}", channel.ModulationType);
return channel;
}

/// <summary>
/// Set the PIDs for hardware pid filtering. This function is untested. As far as
/// I'm aware PID filtering is only supported by the VP-7021 (Starbox) and
Expand Down Expand Up @@ -1996,22 +2034,22 @@ public bool CustomTune(IChannel channel, ScanParameters parameters)
/// <returns><c>true</c> if the command is successfully sent, otherwise <c>false</c></returns>
public bool SendDiseqcCommand(ScanParameters parameters, DVBSChannel channel)
{
bool isHighBand = BandTypeConverter.IsHiBand(channel, parameters);
TwinhanToneBurst toneBurst = TwinhanToneBurst.Off;
bool successDiseqc = true;
bool isHighBand = BandTypeConverter.IsHiBand(channel, parameters);
ToneBurst toneBurst = ToneBurst.Off;
if (channel.DisEqc == DisEqcType.SimpleA)
{
toneBurst = TwinhanToneBurst.ToneBurst;
toneBurst = ToneBurst.ToneBurst;
}
else if (channel.DisEqc == DisEqcType.SimpleB)
{
toneBurst = TwinhanToneBurst.DataBurst;
toneBurst = ToneBurst.DataBurst;
}

Twinhan22k tone22k = Twinhan22k.Off;
Tone22k tone22k = Tone22k.Off;
if (isHighBand)
{
tone22k = Twinhan22k.On;
tone22k = Tone22k.On;
}

// TODO: it is important to call SetToneState() before SendDiSEqCCommand()
Expand Down

0 comments on commit 2c50074

Please sign in to comment.