📄 itunerproperties.cpp
字号:
/*+++ *******************************************************************\
*
* Copyright and Disclaimer:
*
* ---------------------------------------------------------------
* This software is provided "AS IS" without warranty of any kind,
* either expressed or implied, including but not limited to the
* implied warranties of noninfringement, merchantability and/or
* fitness for a particular purpose.
* ---------------------------------------------------------------
*
* Copyright (c) 2008 Conexant Systems, Inc.
* All rights reserved.
*
\******************************************************************* ---*/
#include "ITunerProperties.h"
#include "device.h"
#include "debug.h"
#include "registryAccess.h"
#include "tunerinfo.h"
#include "miscfuncs.h"
#include "IVideoDecoder.h"
#include "Merlin.h"
#include "DirectIF.h"
#include "gentuner.h"
#include "GenSiTuner.h"
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////
//ITunerProperties::ITunerProperties
//
// Initialize member variables to some default values for the tuner
//
ITunerProperties::ITunerProperties(Device* p_device, I2cIF* p_i2c):
_mode(KSPROPERTY_TUNER_MODE_TV),
_input(0),
_standard(KS_AnalogVideo_NTSC_M),
_frequency(0),
_country_code(0xFFFFFFFF),
_tuning_flags(KS_TUNER_TUNING_EXACT),
_tuner_type(TUNER_TYPE_NOT_DEFINED),
_p_device(p_device),
_p_tuner1(NULL),
_p_tuner2(NULL),
_channel_change_thread_object(NULL),
_received_change_frequency(FALSE),
_use_pll_tune(FALSE)
{
}
ITunerProperties::~ITunerProperties()
{
_p_device->acquireTunerMutex();
delete _p_tuner1;
delete _p_tuner2;
_p_tuner1 = NULL;
_p_tuner2 = NULL;
_p_device->releaseTunerMutex();
}
/////////////////////////////////////////////////////////////////////////////////////////
//ITunerProperties::static_getCaps
//
// DDK entry point for KSPROPERTY_TUNER_CAPS
//
// For this property, we need to fill in the supported modes, and mediums for the tuner
// output pins. The child class is called to get the supported modes.
//
NTSTATUS ITunerProperties::static_getCaps(
PIRP p_irp,
PKSPROPERTY_TUNER_CAPS_S p_request,
PKSPROPERTY_TUNER_CAPS_S p_data)
{
//Get the filter
PKSFILTER p_filter = KsGetFilterFromIrp(p_irp);
if(!p_filter)
{
return STATUS_UNSUCCESSFUL;
}
PKSDEVICE p_ks_device = KsFilterGetDevice(p_filter);
Device* p_device = (Device*)p_ks_device->Context;
//Get the ITunerProperties object from the filter
ITunerProperties* p_properties = p_device->getTunerProperties();
if(!p_properties)
{
return STATUS_UNSUCCESSFUL;
}
// set activity state
//TODO p_device->setCfpmActivityState(analogTuner_pwr_block,true);
// verify whether the device is powered up or not
//TODO p_device->setCfpmPowerMode(analogTuner_pwr_block, WAKEUP);
//Fill in the data buffer.
RtlZeroMemory(p_data, sizeof(*p_data));
p_device->acquireTunerMutex();
p_data->ModesSupported = 0;
if(p_properties->_p_tuner1)
{
p_data->ModesSupported |= p_properties->_p_tuner1->getSupportedModes();
}
if(p_properties->_p_tuner2)
{
p_data->ModesSupported |= p_properties->_p_tuner2->getSupportedModes();
}
p_device->releaseTunerMutex();
// Fill in Mediums here - should be common across tuners.
p_data->VideoMedium = g_tuner_mediums[PIN_INDEX_VIDEO];
p_data->VideoMedium.Id = p_device->getMediumId();
p_data->TVAudioMedium = g_tuner_mediums[PIN_INDEX_TV_AUDIO];
p_data->TVAudioMedium.Id = p_device->getMediumId();
p_data->RadioAudioMedium.Set = GUID_NULL;
// set activity state
//TODO p_device->setCfpmActivityState(analogTuner_pwr_block,false);
return STATUS_SUCCESS;
}
/////////////////////////////////////////////////////////////////////////////////////////
//ITunerProperties::static_getModeCaps
//
// This is the static DDK entry point for KSPROPERTY_TUNER_MODE_CAPS
//
// We must fill in the capabilities structure for a specific mode, passed in to us.
// We query the child class for the mode capabilities.
//
NTSTATUS ITunerProperties::static_getModeCaps(
PIRP p_irp,
PKSPROPERTY_TUNER_MODE_CAPS_S p_request,
PKSPROPERTY_TUNER_MODE_CAPS_S p_data)
{
//Get the filter
PKSFILTER p_filter = KsGetFilterFromIrp(p_irp);
if(!p_filter)
{
return STATUS_UNSUCCESSFUL;
}
PKSDEVICE p_ks_device = KsFilterGetDevice(p_filter);
Device* p_device = (Device*)p_ks_device->Context;
//Get the ITunerProperties object from the filter
ITunerProperties* p_properties = p_device->getTunerProperties();
if(!p_properties)
{
return STATUS_UNSUCCESSFUL;
}
// set activity state
//TODO p_device->setCfpmActivityState(analogTuner_pwr_block,true);
// verify whether the device is powered up or not
//TODO p_device->setCfpmPowerMode(analogTuner_pwr_block, WAKEUP);
ULONG mode = p_request->Mode;
ITuner* p_tuner = p_properties->getTuner(mode);
if(!p_tuner)
{
// set activity state
//TODO p_device->setCfpmActivityState(analogTuner_pwr_block,false);
return STATUS_UNSUCCESSFUL;
}
p_device->acquireTunerMutex();
p_data->StandardsSupported = p_tuner->getSupportedStandards(mode);
p_data->MinFrequency = p_tuner->getMinFrequency(mode);
p_data->MaxFrequency = p_tuner->getMaxFrequency(mode);
p_data->TuningGranularity = GRANULARITY_TV;
p_data->NumberOfInputs = p_tuner->getNumInputs(mode);
p_data->SettlingTime = TUNER_SETTLING_TIME;
p_device->releaseTunerMutex();
// set activity state
//TODO p_device->setCfpmActivityState(analogTuner_pwr_block,false);
return STATUS_SUCCESS;
}
/////////////////////////////////////////////////////////////////////////////////////////
//ITunerProperties::static_getMode
//
// This is the static DDK entry point for KSPROPERTY_TUNER_MODE
//
// We need to return the current tuner mode. (TV or FM, usually)
// It's stored in the base class.
//
NTSTATUS ITunerProperties::static_getMode(
PIRP p_irp,
PKSPROPERTY_TUNER_MODE_S p_request,
PKSPROPERTY_TUNER_MODE_S p_data)
{
//Get the filter
PKSFILTER p_filter = KsGetFilterFromIrp(p_irp);
if(!p_filter)
{
return STATUS_UNSUCCESSFUL;
}
PKSDEVICE p_ks_device = KsFilterGetDevice(p_filter);
Device* p_device = (Device*)p_ks_device->Context;
//Get the ITunerProperties object from the filter
ITunerProperties* p_properties = p_device->getTunerProperties();
if(!p_properties)
{
return STATUS_UNSUCCESSFUL;
}
//Fill in p_data->Mode based on the current mode (TV, FM, etc.)
p_data->Mode = p_properties->_mode;
return STATUS_SUCCESS;
}
/////////////////////////////////////////////////////////////////////////////////////////
//ITunerProperties::static_setMode
//
// static DDK entry point for KSPROPERTY_TUNER_MODE (set handler)
//
// Sets the mode to TV or FM.
// Calls the child class to set the mode. There is a version of setMode() in the base
// class, but it can be overridden by child classes that need to do anything special.
//
NTSTATUS ITunerProperties::static_setMode(
PIRP p_irp,
PKSPROPERTY_TUNER_MODE_S p_request,
PKSPROPERTY_TUNER_MODE_S p_data)
{
//Get the filter
PKSFILTER p_filter = KsGetFilterFromIrp(p_irp);
if(!p_filter)
{
return STATUS_UNSUCCESSFUL;
}
PKSDEVICE p_ks_device = KsFilterGetDevice(p_filter);
Device* p_device = (Device*)p_ks_device->Context;
//Get the ITunerProperties object from the filter
ITunerProperties* p_properties = p_device->getTunerProperties();
if(!p_properties)
{
return STATUS_UNSUCCESSFUL;
}
// set activity state
//TODO
// p_device->setCfpmActivityState(analogTuner_pwr_block,true);
// verify whether the device is powered up or not
// p_device->setCfpmPowerMode(analogTuner_pwr_block, WAKEUP);
/*
if ((!p_properties->_p_device->IsBoardCombo()) &&
(p_properties->_p_device->getCurrentGraphMode() == GRAPH_MODE_DIGITAL)
)
{
// set activity state
p_device->setCfpmActivityState(analogTuner_pwr_block,false);
DbgLogWarn(("ITunerProperties::static_setMode : Tuner already acquired by BDA !!!\n"));
return STATUS_INSUFFICIENT_RESOURCES;
}
*/
NTSTATUS status = p_properties->setMode(p_request->Mode);
if(NT_SUCCESS(status))
{
p_properties->_mode = p_request->Mode;
}
// set activity state
//TODO p_device->setCfpmActivityState(analogTuner_pwr_block,false);
return status;
}
/////////////////////////////////////////////////////////////////////////////////////////
//ITunerProperties::static_getStandard
//
// static DDK entry point for KSPROPERTY_TUNER_STANDARD
//
// get the current video standard. It's stored in the base class.
//
NTSTATUS ITunerProperties::static_getStandard(
PIRP p_irp,
PKSPROPERTY_TUNER_STANDARD_S p_request,
PKSPROPERTY_TUNER_STANDARD_S p_data)
{
//Get the filter
PKSFILTER p_filter = KsGetFilterFromIrp(p_irp);
if(!p_filter)
{
return STATUS_UNSUCCESSFUL;
}
PKSDEVICE p_ks_device = KsFilterGetDevice(p_filter);
Device* p_device = (Device*)p_ks_device->Context;
//Get the ITunerProperties object from the filter
ITunerProperties* p_properties = p_device->getTunerProperties();
if(!p_properties)
{
return STATUS_UNSUCCESSFUL;
}
p_data->Standard = p_properties->_standard;
return STATUS_SUCCESS;
}
/////////////////////////////////////////////////////////////////////////////////////////
//ITunerProperties::static_setStandard
//
// Static DDK entry point for KSPROPERTY_TUNER_STANDARD
//
// Set the video standard associated with the tuner. It's stored in the base class.
//
NTSTATUS ITunerProperties::static_setStandard(
PIRP p_irp,
PKSPROPERTY_TUNER_STANDARD_S p_request,
PKSPROPERTY_TUNER_STANDARD_S p_data)
{
//Get the filter
PKSFILTER p_filter = KsGetFilterFromIrp(p_irp);
if(!p_filter)
{
return STATUS_UNSUCCESSFUL;
}
PKSDEVICE p_ks_device = KsFilterGetDevice(p_filter);
Device* p_device = (Device*)p_ks_device->Context;
//Get the ITunerProperties object from the filter
ITunerProperties* p_properties = p_device->getTunerProperties();
if(!p_properties)
{
return STATUS_UNSUCCESSFUL;
}
p_properties->_standard = p_request->Standard;
return STATUS_SUCCESS;
}
/////////////////////////////////////////////////////////////////////////////////////////
//ITunerProperties::static_getFrequency
//
// Static DDK entry point for KSPROPERTY_TUNER_FREQUENCY
//
// Gets the current frequency. (Stored in the base class)
//
NTSTATUS ITunerProperties::static_getFrequency(
PIRP p_irp,
PKSPROPERTY_TUNER_FREQUENCY_S p_request,
PKSPROPERTY_TUNER_FREQUENCY_S p_data)
{
//Get the filter
PKSFILTER p_filter = KsGetFilterFromIrp(p_irp);
if(!p_filter)
{
return STATUS_UNSUCCESSFUL;
}
PKSDEVICE p_ks_device = KsFilterGetDevice(p_filter);
Device* p_device = (Device*)p_ks_device->Context;
//Get the ITunerProperties object from the filter
ITunerProperties* p_properties = p_device->getTunerProperties();
if(!p_properties)
{
return STATUS_UNSUCCESSFUL;
}
p_data->Frequency = p_properties->_frequency;
p_data->TuningFlags = p_properties->_tuning_flags;
p_data->Country = p_properties->_country_code;
return STATUS_SUCCESS;
}
/////////////////////////////////////////////////////////////////////////////////////////
//ITunerProperties::static_setFrequency
//
// Static DDK entry point for KSPROPERTY_TUNER_FREQUENCY (set handler)
//
// Set the frequency. Calls the non-static helper function baseSetFrequency
//
NTSTATUS ITunerProperties::static_setFrequency(
PIRP p_irp,
PKSPROPERTY_TUNER_FREQUENCY_S p_request,
PKSPROPERTY_TUNER_FREQUENCY_S p_data)
{
//Get the filter
PKSFILTER p_filter = KsGetFilterFromIrp(p_irp);
if(!p_filter)
{
return STATUS_UNSUCCESSFUL;
}
PKSDEVICE p_ks_device = KsFilterGetDevice(p_filter);
Device* p_device = (Device*)p_ks_device->Context;
//Get the ITunerProperties object from the filter
ITunerProperties* p_properties = p_device->getTunerProperties();
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -