📄 device.h
字号:
/*+++ *******************************************************************\
*
* 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.
*
\******************************************************************* ---*/
#ifndef _DEVICE_H_
#define _DEVICE_H_
extern "C"
{
#include <wdm.h>
}
#include <windef.h>
#include <ks.h>
#include <ksmedia.h>
#include "basepin.h"
#include "cxcopyprotectprop.h"
#include "pcbconfig.h"
#include "ExtI2CInterface.h"
#include "sidewinderprivate.h"
#include "Polaris_reg.h"
#define I2C_EXT 1
#define I2C_EXT_2 2
#define I2C_INT 3
class DemodI2C;
class UsbI2cInterface;
//class FormatData;
class CrossbarProperties;
class ITunerProperties;
class DriverI2C;
class I2cIF;
class IVideoDecoder;
class Merlin;
class SyncRegIo;
class IDataTransfer;
class CUsbInterface;
class PolarisUsbInterface;
class PcbConfig;
class IR_Control;
class IBdaTuner;
class DirectIF;
class Colibri;
class Flatrion;
class PolarisGPIOPin;
////////////////////////////////////////////////////////////////////////////////
/*
this following macro used for detect TS1 or TS1 's source
As we have three TS source from the design.we use bitmap to
detect source.
for example:
bit: 7 6 5 4 3 2 1 0
X X X X X X X X
--jerry
////////////////////////////////////////////////////////////////////////////////
#define TYPE_Analog_TV 1
#define TYPE_DIF_TV 2
#define TYPE_Ex_AV 4
#define TYPE_Digital 8
*/
////////////////////////////////////////////////////////////////
#define REV_A0 0x00
#define REV_A1 0x01
#define REV_B0 0x02
typedef enum {
/*! Set to Sleep mode, maximum power save, maximum start time */
modeSleep,
/*! Set to Standby, intermediate power save, not active, intermediate start time */
modeStandby,
/*! Set to Running, fully powered, active */
modeRunning,
/*! Used to indicate an error condition in the driver - the driver must be re-initialised */
modeError
}zlModeE;
typedef enum{
Raw_Video = 0,
Audio,
Vbi, //VANC
Sliced_cc, //HANC
TS1,
TS2
}TRANSFER_TYPE;
typedef enum {
TUNER_MODE_ANALOG,
TUNER_MODE_DIGITAL
}TUNER_MODE;
typedef enum {
GRAPH_MODE_UNASSIGNED,
GRAPH_MODE_ANALOG,
GRAPH_MODE_DIGITAL
}GRAPH_MODE;
typedef enum _TUNER_CATEGORY
{
ANALOG_TUNER = 0,
DIGITAL_TUNER = 1,
HYBRID_TUNER = 2
}TUNER_CATEGORY;
typedef enum
{
POLARIS_BOARD_DVT=0,
POLARIS_BOARD_EVK=1,
POLARIS_BOARD_FPGA=2,
POLARIS_BOARD_UNSUPPORTED
}BOARD_TYPE;
typedef enum _REV_ID
{
POLARIS_REVID_T0=0,
POLARIS_REVID_A0,
POLARIS_REVID_INVALID=0xff
}POLARIS_REV_ID;
#define TUNER_SERIAL_NUM_SIZE 32
////////////////////////////////////
//set/get i2c
#define I2C_SPEED_1M 0x0 //00--1Mb/s, 01-400kb/s, 10--100kb/s, 11--5Mb/s
#define I2C_SPEED_400K 0x1 //00--1Mb/s, 01-400kb/s, 10--100kb/s, 11--5Mb/s
#define I2C_SPEED_100K 0x2 //00--1Mb/s, 01-400kb/s, 10--100kb/s, 11--5Mb/s
#define I2C_SPEED_5M 0x3 //00--1Mb/s, 01-400kb/s, 10--100kb/s, 11--5Mb/s
#define I2C_STOP 0x0 // 0-- STOP transaction
#define I2C_NOSTOP 0x1 // 1-- do not transmit STOP at end of transaction
#define I2C_SYNC 0x1 // 1--alllow slave to insert clock wait states
#define DEVICE_STREAM_NONE 0x0
#define DEVICE_STREAM_VIDEO 0x01
#define DEVICE_STREAM_AUDIO 0x02
#define DEVICE_STREAM_TS_MPEG 0x04
#define DEVICE_STREAM_VBI 0x08
#define DEVICE_STREAM_SLICED_CC 0x10
#define DEVICE_STREAM_TS2_MPEG 0x20
#define DEVICE_STREAM_ALL 0x3f
// the below definitions are used to identify the Hardware state
// and Stream state whether it is in Analog mode / Digital mode
typedef enum{
None = 0,
AnalogStream,
DigitalStream
}STREAM_TYPE;
class Device
{
public:
Device(PKSDEVICE p_ks_dev);
~Device();
BOOLEAN acquireResources(BasePin* p_pin);
BOOLEAN releaseResources(BasePin* p_pin);
NTSTATUS start(BasePin* p_pin);
NTSTATUS stop(BasePin* p_pin);
VOID lockDeviceState();
VOID unlockDeviceState();
BOOLEAN isRunning();
NTSTATUS prePowerControl();
NTSTATUS setPowerMode(AV_MODE mode);
NTSTATUS powerSuspend();
VOID updatePinDataRanges();
//Accessors functions
IVideoDecoder* getVidDec();
Merlin* getAudDec();
SyncRegIo* getSyncRegIo();
IR_Control* getIR_Control();
PolarisUsbInterface*getPolarisUsbInterface();
CUsbInterface* getUsb();
CrossbarProperties* getCrossbarProperties();
ITunerProperties* getTunerProperties();
PDEVICE_OBJECT getPdo();
DWORD getMediumId();
DWORD getVbiPinIndex();
VOID setTunerMode(TUNER_MODE tunerMode) { _tuner_mode = tunerMode;}
TUNER_MODE getTunerMode() { return _tuner_mode;}
VOID setCrossbarInputPin(
DWORD pin_input_type,
DWORD input_mux=0,
DWORD input_mux2=0,
DWORD gpio_mask=0,
DWORD gpio_setting=0);
//Called by tuner object
VOID setMode(ULONG mode); //Set mode to TV or FM.
VOID notifyPreChannelChange();
VOID notifyPostChannelChange();
BOOLEAN setVideoStandard(DWORD new_video_standard);
VOID notifyPinFormatChange(BasePin* p_pin);
// Static methods passed to av stream
static NTSTATUS dispatchCreate(PKSDEVICE p_ks_dev);
static NTSTATUS dispatchPnpStart(
PKSDEVICE p_ks_dev,
PIRP p_irp,
PCM_RESOURCE_LIST p_trans_res_list,
PCM_RESOURCE_LIST p_raw_res_list);
static VOID dispatchPnpStop(PKSDEVICE p_ks_dev, PIRP p_irp);
static VOID dispatchPnpSurpriseRemoval(
KSDEVICE *p_ks_dev,
IRP *p_irp);
static VOID dispatchRemove(PKSDEVICE p_ks_dev, PIRP p_irp);
static NTSTATUS dispatchQueryPower(
PKSDEVICE p_ks_dev,
PIRP p_irp,
DEVICE_POWER_STATE dev_to,
DEVICE_POWER_STATE dev_from,
SYSTEM_POWER_STATE sys_to,
SYSTEM_POWER_STATE sys_from,
POWER_ACTION action);
static VOID dispatchSetPower(
PKSDEVICE p_ks_dev,
PIRP p_irp,
DEVICE_POWER_STATE to,
DEVICE_POWER_STATE from);
DWORD getStreamRunning();
VOID pauseDigitalStream();
VOID resumeDigitalStream();
// TS Filter
NTSTATUS registerTSFilter();
VOID setSamplerate(DWORD rate);
DWORD getSamplerate();
VOID acquireTunerMutex();
VOID releaseTunerMutex();
DirectIF* getDirectIF() { return _p_DIF;}
Colibri* getColibri() { return _p_colibri;}
GRAPH_MODE getCurrentGraphMode() { return _current_graph_mode;}
BOOLEAN DeviceActive(VOID);
PVOID getFilterTemplate() { return _p_filter_template; }
//////////////////////Tuner/////////////////////////////////////////////////////////////////////////////////////
IBdaTuner* getBdaTuner() {return _p_bda_tuner;}
//////////////////////Polaris interal control/////////////////////////////////////////////////////////////////////
I2cIF* getI2CInterface(int i2c_interface_select = 0);
I2cIF* getDigitalI2C(){_p_DigitalI2C->addRef(); return _p_DigitalI2C; }
I2cIF* getAnalogI2C(){_p_AnalogI2C->addRef(); return _p_AnalogI2C; }
PolarisGPIOPin* getGPIOPin() { return _p_GPIOPin; }
PcbConfig* getPcbConfig();
VOID setfwLoadThreadActive(BOOL active) {_fwload_thread_active = active;}
I2cIF* createBdaTuner(DWORD tuner_and_demod_type);
VOID resetAnalogTuner();
DWORD getCurrentConfig();
VOID setCurrentConfig(DWORD config_num);
////////////////////////////////////////////////////////////////////////////////////////////////////////////
// power functions
DEVICE_POWER_STATE getDevPowerState() { return _power_state; }
void setDevPowerState(DEVICE_POWER_STATE dps) { _power_state = dps; }
BOOLEAN IsDevicePoweredUp();
BOOL IsDeviceSurpriseRemoved() { return _bSurpriseRemoval; }
// HW initialization functions
NTSTATUS checkHwInitialization();
NTSTATUS waitHwInitialized();
void setHwInitEvent();
// soft encoder functions
BOOLEAN IsSoftEncoderEnabled() { return _enable_soft_encoder; }
// registering serial number with Tuner
NTSTATUS CreateTunerSerialNumber(IN GUID categoryGUID,IN PWCHAR p_serial_num);
VOID GenerateSerialNumber(IN OUT PWCHAR p_serial_num,ULONG instance_no);
Colibri* getColobri();
DWORD is_ENABLE_HANC_AUDIO(){ return _enable_hanc_audio; }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -