#ifdef TBS6980 const GUID KSPROPSETID_BdaTunerExtensionProperties = {0xfaa8f3e5, 0x31d4, 0x4e41, {0x88, 0xef, 0xd9, 0xeb, 0x71, 0x6f, 0x6e, 0xc9}}; #define HZ_22K_OFF 0 #define HZ_22K_ON 1 #define Value_Data_Burst_ON 1 #define Value_Tone_Burst_ON 0 #define Value_Burst_OFF 2 const BYTE DISEQC_TX_BUFFER_SIZE = 150; // 3 bytes per message * 50 messages const BYTE DISEQC_RX_BUFFER_SIZE = 8; // reply fifo size, hardware limitation typedef enum _TBSDVBSExtensionPropertiesCMDMode { TBSDVBSCMD_LNBPOWER=0x00, TBSDVBSCMD_MOTOR=0x01, TBSDVBSCMD_22KTONEDATA=0x02, TBSDVBSCMD_DISEQC=0x03 } TBSDVBSExtensionPropertiesCMDMode; // this is defined in bda tuner/demod driver source (splmedia.h) typedef enum { KSPROPERTY_BDA_DISEQC_MESSAGE = 0, //Custom property for Diseqc messaging KSPROPERTY_BDA_DISEQC_INIT, //Custom property for Intializing Diseqc. KSPROPERTY_BDA_SCAN_FREQ, //Not supported KSPROPERTY_BDA_CHANNEL_CHANGE, //Custom property for changing channel KSPROPERTY_BDA_DEMOD_INFO, //Custom property for returning demod FW state and version KSPROPERTY_BDA_EFFECTIVE_FREQ, //Not supported KSPROPERTY_BDA_SIGNAL_STATUS, //Custom property for returning signal quality, strength, BER and other attributes KSPROPERTY_BDA_LOCK_STATUS, //Custom property for returning demod lock indicators KSPROPERTY_BDA_ERROR_CONTROL, //Custom property for controlling error correction and BER window KSPROPERTY_BDA_CHANNEL_INFO, //Custom property for exposing the locked values of frequency,symbol rate etc after //corrections and adjustments KSPROPERTY_BDA_NBC_PARAMS } KSPROPERTY_BDA_TUNER_EXTENSION; /*******************************************************************************************************/ /* PHANTOM_LNB_BURST */ /*******************************************************************************************************/ typedef enum _PHANTOMLnbburst { PHANTOM_LNB_BURST_MODULATED=1, /* Modulated: Tone B */ PHANTOM_LNB_BURST_UNMODULATED, /* Not modulated: Tone A */ PHANTOM_LNB_BURST_UNDEF=0 /* undefined (results in an error) */ } PHANTOM_LNB_BURST; /*******************************************************************************************************/ /* PHANTOM_RXMODE */ /*******************************************************************************************************/ typedef enum _PHANTOMRxMode { PHANTOM_RXMODE_INTERROGATION=0, /* Demod expects multiple devices attached */ PHANTOM_RXMODE_QUICKREPLY=1, /* demod expects 1 rx (rx is suspended after 1st rx received) */ PHANTOM_RXMODE_NOREPLY=2 /* demod expects to receive no Rx message(s) */ } PHANTOM_RXMODE; // DVB-S/S2 DiSEqC message parameters typedef struct _DISEQC_MESSAGE_PARAMS { UCHAR uc_diseqc_send_message[DISEQC_TX_BUFFER_SIZE+1]; UCHAR uc_diseqc_send_message_length; UCHAR uc_diseqc_receive_message[DISEQC_RX_BUFFER_SIZE+1]; UCHAR uc_diseqc_receive_message_length; PHANTOM_LNB_BURST burst_tone; //Burst tone at last-message: (modulated = ToneB; Un-modulated = ToneA). PHANTOM_RXMODE receive_mode; //Reply mode: interrogation/no reply/quick reply. TBSDVBSExtensionPropertiesCMDMode tbscmd_mode; UCHAR HZ_22K; // HZ_22K_OFF | HZ_22K_ON UCHAR Tone_Data_Burst; // Data_Burst_ON | Tone_Burst_ON |Tone_Data_Disable UCHAR uc_parity_errors; //Parity errors: 0 indicates no errors; binary 1 indicates an error. UCHAR uc_reply_errors; //1 in bit i indicates error in byte i. BOOL b_last_message; //Indicates if current message is the last message (TRUE means last message). BOOL b_LNBPower;//liuzheng added for lnb power static } DISEQC_MESSAGE_PARAMS, *PDISEQC_MESSAGE_PARAMS; #endif void CMyGraph::GetSignalState( int* pnStrength, int* pnQuality, int* pnLock ) { HRESULT hr; if (pnStrength) *pnStrength = 0; if (pnQuality) *pnQuality = 0; if (pnLock) *pnLock = 0; if (m_pTunerDevice == NULL) return; IBDA_Topology *bdaNetTop = NULL; if ((hr = m_pTunerDevice->QueryInterface(IID_IBDA_Topology, (void **)&bdaNetTop)) != S_OK) return; ULONG NodeTypes; ULONG NodeType[32]; CComPtr iNode; long longVal = 0; BYTE byteVal = 0; CHK( "Fail to get node types.", SUCCEEDED( hr = bdaNetTop->GetNodeTypes(&NodeTypes, 32, NodeType))); for ( unsigned int i=0 ; iGetControlNode(0, 1, NodeType[i], &iNode); if (hr == S_OK) { CComPtr pSigStats; hr = iNode->QueryInterface(IID_IBDA_SignalStatistics, (void **)(&pSigStats)); if (hr == S_OK) { longVal = 0; if (SUCCEEDED(hr = pSigStats->get_SignalStrength(&longVal))) if (pnStrength) *pnStrength = min(max(longVal,0),100); longVal = 0; if (SUCCEEDED(hr = pSigStats->get_SignalQuality(&longVal))) if (pnQuality) *pnQuality = min(max(longVal,0),100); byteVal = 0; if (SUCCEEDED(hr = pSigStats->get_SignalLocked(&byteVal))) if (pnLock) *pnLock = byteVal; pSigStats.Release(); } iNode.Release(); } } bdaNetTop->Release(); bdaNetTop = NULL; return; } BOOL CMyGraph::LockChannel( BOOL bJcsat4A, BOOL bHorizontal, unsigned long ulFrequency, BOOL bDvbS2 ) { HRESULT hr; IDVBSTuningSpace *pIDVBSTuningSpace = NULL; if (hr = m_pITuningSpace->QueryInterface(IID_IDVBSTuningSpace, reinterpret_cast(&pIDVBSTuningSpace))) return FALSE; pIDVBSTuningSpace->put_HighOscillator(11200000); pIDVBSTuningSpace->put_LowOscillator(11200000); if (bJcsat4A) pIDVBSTuningSpace->put_LNBSwitch(10000000); else pIDVBSTuningSpace->put_LNBSwitch(20000000); #ifdef TBS6980 // これがなくても動くと思うのだが、TBS6980では衛星切り替えできず if ((hr = TBSSet22KHz( bJcsat4A? true: false)) != S_OK) return FALSE; #endif CComPtr pITuneRequest ; CHK( "Fail to create ITuneRequest.", SUCCEEDED( pIDVBSTuningSpace->CreateTuneRequest( &pITuneRequest ) ) ) ; CComQIPtr pIRequest( pITuneRequest ) ; CComPtr pILocator ; CHK( "Fail to get IDVBSLocator", SUCCEEDED( pILocator.CoCreateInstance( CLSID_DVBSLocator ) ) ) ; pILocator->put_CarrierFrequency( ulFrequency * 1000 ) ; pILocator->put_InnerFEC( BDA_FEC_VITERBI ) ; if (bDvbS2) { pILocator->put_InnerFECRate( BDA_BCC_RATE_3_5 ) ; pILocator->put_Modulation( BDA_MOD_8PSK ) ; pILocator->put_SymbolRate( 23303 ) ; } else { pILocator->put_InnerFECRate( BDA_BCC_RATE_3_4 ) ; pILocator->put_Modulation( BDA_MOD_QPSK ) ; pILocator->put_SymbolRate( 21096 ) ; } pILocator->put_OuterFEC( BDA_FEC_RS_204_188 ) ; pILocator->put_OuterFECRate( BDA_BCC_RATE_NOT_SET ) ; if (bHorizontal) pILocator->put_SignalPolarisation( BDA_POLARISATION_LINEAR_H ) ; else pILocator->put_SignalPolarisation( BDA_POLARISATION_LINEAR_V ) ; pIRequest->put_Locator( pILocator ) ; CComQIPtr pTuner( m_pNetworkProvider ) ; CHK( "Fail to put tune request.", SUCCEEDED( pTuner->put_TuneRequest( pIRequest ) ) ) ; pIDVBSTuningSpace->Release(); int nLock; GetSignalState( NULL, NULL, &nLock ) ; return nLock != 0 ; } #ifdef TBS6980 HRESULT CMyGraph::get_pin_property_set(IBaseFilter *pfilter, int sdir, IKsPropertySet **pkspropertyset) { HRESULT hr = E_FAIL; *pkspropertyset = NULL; IEnumPins* pPinEnum = NULL; pfilter->EnumPins(&pPinEnum); if (pPinEnum) { IPin* pPin=NULL; while (!(*pkspropertyset) && SUCCEEDED(pPinEnum->Next(1, &pPin, NULL))) { PIN_DIRECTION dir; if (SUCCEEDED(pPin->QueryDirection(&dir)) && ((sdir==0 && dir==PINDIR_INPUT) || (sdir==1 && dir==PINDIR_OUTPUT) || (sdir==-1)) ) { hr = pPin->QueryInterface(IID_IKsPropertySet, (void **) pkspropertyset); } pPin->Release(); } pPinEnum->Release(); } return hr; } HRESULT CMyGraph::TBSSet22KHz( bool active ) { HRESULT hr; DWORD TypeSupport=0; if ((hr = m_pPropsetTunerPin->QuerySupported(KSPROPSETID_BdaTunerExtensionProperties, KSPROPERTY_BDA_DISEQC_MESSAGE, &TypeSupport)) != S_OK) { return S_FALSE; } DWORD bytesReturned; DISEQC_MESSAGE_PARAMS DiSEqCRequest; ZeroMemory(&DiSEqCRequest, sizeof(DiSEqCRequest)); DiSEqCRequest.tbscmd_mode = TBSDVBSCMD_22KTONEDATA; DiSEqCRequest.Tone_Data_Burst = Value_Burst_OFF; DiSEqCRequest.HZ_22K = active? HZ_22K_ON : HZ_22K_OFF; hr = m_pPropsetTunerPin->Get(KSPROPSETID_BdaTunerExtensionProperties, KSPROPERTY_BDA_DISEQC_MESSAGE, &DiSEqCRequest,sizeof(DISEQC_MESSAGE_PARAMS), &DiSEqCRequest, sizeof(DISEQC_MESSAGE_PARAMS), &bytesReturned); return hr; } #endif void CMyGraph::LoadTunerDevice( void ) { 元のコード #ifdef TBS6980 HRESULT hr; hr = get_pin_property_set(m_pTunerDevice, -1, &m_pPropsetTunerPin); CHK( "Fail to get pin for property_set.", hr == S_OK); #endif }