Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

288 lines
8.0 KiB

  1. // $Header: G:/SwDev/WDM/Video/bt848/rcs/Device.h 1.10 1998/05/11 20:27:07 tomz Exp $
  2. #ifndef __DEVICE_H
  3. #define __DEVICE_H
  4. #ifdef __cplusplus
  5. extern "C" {
  6. #endif
  7. #ifndef _STREAM_H
  8. #include "strmini.h"
  9. #endif
  10. #ifdef __cplusplus
  11. }
  12. #endif
  13. #ifndef __PISCES_H
  14. #include "pisces.h"
  15. #endif
  16. #ifndef __MYTYPES_H
  17. #include "mytypes.h"
  18. #endif
  19. #ifndef __VIDCH_H
  20. #include "vidch.h"
  21. #endif
  22. #ifndef __I2C_H
  23. #include "bti2c.h"
  24. #endif
  25. #ifndef __GPIO_H
  26. #include "gpio.h"
  27. #endif
  28. #include "xbar.h"
  29. #ifndef __I2C_H__
  30. #include <i2cgpio.h>
  31. #endif
  32. #define TUNER_BRAND_TEMIC 1
  33. #define TUNER_BRAND_PHILIPS 2
  34. #define TUNER_BRAND_ALPS 3
  35. typedef struct _TUNER_INFO
  36. {
  37. ULONG TunerBrand; // Brand of tuner
  38. BYTE TunerI2CAddress; // I2C address for Temic tuner
  39. WORD TunerBandCtrlLow; // Ctrl code for VHF low
  40. WORD TunerBandCtrlMid; // Ctrl code for VHF high
  41. WORD TunerBandCtrlHigh; // Ctrl code for UHF
  42. } TUNER_INFO, *PTUNER_INFO;
  43. extern LONG PinTypes_ []; // just allocate maximum possible
  44. extern DWORD xtals_ []; // no more than 2 xtals
  45. extern TUNER_INFO TunerInfo;
  46. void ReadXBarRegistryValues( IN PDEVICE_OBJECT PhysicalDeviceObject );
  47. void ReadXTalRegistryValues( IN PDEVICE_OBJECT PhysicalDeviceObject );
  48. void ReadTunerRegistryValues( IN PDEVICE_OBJECT PhysicalDeviceObject );
  49. VOID AdapterSetCrossbarProperty( PHW_STREAM_REQUEST_BLOCK pSrb );
  50. VOID AdapterGetCrossbarProperty( PHW_STREAM_REQUEST_BLOCK pSrb );
  51. void AdapterSetVideoProcAmpProperty( PHW_STREAM_REQUEST_BLOCK pSrb );
  52. void AdapterGetVideoProcAmpProperty( PHW_STREAM_REQUEST_BLOCK pSrb );
  53. void AdapterSetVideoDecProperty( PHW_STREAM_REQUEST_BLOCK pSrb );
  54. void AdapterGetVideoDecProperty( PHW_STREAM_REQUEST_BLOCK pSrb );
  55. void AdapterSetTunerProperty( PHW_STREAM_REQUEST_BLOCK pSrb );
  56. void AdapterGetTunerProperty( PHW_STREAM_REQUEST_BLOCK pSrb );
  57. void AdapterSetTVAudioProperty( PHW_STREAM_REQUEST_BLOCK pSrb );
  58. void AdapterGetTVAudioProperty( PHW_STREAM_REQUEST_BLOCK pSrb );
  59. void HandleIRP( PHW_STREAM_REQUEST_BLOCK pSrb );
  60. // Forward declarations
  61. class PsDevice;
  62. extern void SetCurrentDevice( PsDevice *dev );
  63. extern BYTE *GetBase();
  64. extern void SetBase(BYTE *base);
  65. /* Class: PsDevice
  66. * Purpose: This is the class that encapsulates the adapter in the WDM model.
  67. */
  68. class PsDevice
  69. {
  70. public:
  71. PsDevice( DWORD dwBase );
  72. ~PsDevice();
  73. void *operator new( size_t, void *buf ) { return buf; }
  74. void operator delete( void *, size_t ) {}
  75. LPBYTE GetBaseAddress() { return BaseAddress_; }
  76. bool InitOK();
  77. PDEVICE_OBJECT PDO; // Physical Device Object
  78. State Interrupt() { return CaptureContrll_.Interrupt(); }
  79. ErrorCode OpenChannel( PVOID pStrmEx, VideoStream st );
  80. void CloseChannel( VideoChannel *ToClose );
  81. ErrorCode OpenInterChannel( PVOID pStrmEx, VideoStream st );
  82. ErrorCode OpenAlterChannel( PVOID pStrmEx, VideoStream st );
  83. ErrorCode OpenVBIChannel( PVOID pStrmEx );
  84. void ClosePairedChannel( VideoChannel *ToClose );
  85. bool IsVideoChannel( VideoChannel &aChan );
  86. bool IsVBIChannel( VideoChannel &aChan );
  87. bool IsOurChannel( VideoChannel &aChan );
  88. ErrorCode DoOpen( VideoStream st );
  89. void AddBuffer( VideoChannel &aChan, PHW_STREAM_REQUEST_BLOCK );
  90. ErrorCode Create( VideoChannel &VidChan );
  91. void Start( VideoChannel &VidChan );
  92. void Stop( VideoChannel &VidChan );
  93. void Pause( VideoChannel &VidChan );
  94. void EnableAudio( State s );
  95. void SetVideoState( PHW_STREAM_REQUEST_BLOCK pSrb );
  96. void GetVideoState( PHW_STREAM_REQUEST_BLOCK pSrb );
  97. void SetClockMaster( PHW_STREAM_REQUEST_BLOCK pSrb );
  98. // tuner methods
  99. void SetChannel( long lFreq );
  100. int GetPllOffset( PULONG busy, ULONG &lastFreq );
  101. I2C i2c;
  102. GPIO gpio;
  103. BtPisces CaptureContrll_;
  104. CrossBar xBar;
  105. void SetSaturation( LONG Data );
  106. void SetHue( LONG Data );
  107. void SetBrightness( LONG Data );
  108. void SetSVideo( LONG Data );
  109. void SetContrast( LONG Data );
  110. void SetFormat( LONG Data );
  111. void SetConnector( LONG Data );
  112. LONG GetSaturation();
  113. LONG GetHue();
  114. LONG GetBrightness();
  115. LONG GetSVideo();
  116. LONG GetContrast();
  117. LONG GetFormat();
  118. LONG GetConnector();
  119. public:
  120. // this should be before the capture controller, as CapCtrl uses the base address
  121. LPBYTE BaseAddress_;
  122. VideoChannel *videochannels [4];
  123. long LastFreq_;
  124. DWORD dwCurCookie_;
  125. BYTE I2CAddr_;
  126. #ifdef HAUPPAUGEI2CPROVIDER
  127. // new private members of PsDevice for Hauppauge I2C Provider:
  128. LARGE_INTEGER LastI2CAccessTime;
  129. DWORD dwExpiredCookie;
  130. DWORD dwI2CClientTimeout;
  131. #endif
  132. static void STREAMAPI CreateVideo( PHW_STREAM_REQUEST_BLOCK pSrb );
  133. static void STREAMAPI DestroyVideo( PHW_STREAM_REQUEST_BLOCK pSrb );
  134. static void STREAMAPI DestroyVideoNoComplete( PHW_STREAM_REQUEST_BLOCK pSrb );
  135. static void STREAMAPI StartVideo( PHW_STREAM_REQUEST_BLOCK pSrb );
  136. // tuner and video standard notifications are handled here
  137. void ChangeNotifyChannels( IN PHW_STREAM_REQUEST_BLOCK pSrb );
  138. static NTSTATUS STDMETHODCALLTYPE I2COpen( PDEVICE_OBJECT, ULONG, PI2CControl );
  139. static NTSTATUS STDMETHODCALLTYPE I2CAccess( PDEVICE_OBJECT, PI2CControl );
  140. // callbacks
  141. LONG GetSupportedStandards();
  142. void GetStreamProperty( PHW_STREAM_REQUEST_BLOCK pSrb );
  143. void SetStreamProperty( PHW_STREAM_REQUEST_BLOCK pSrb );
  144. void GetStreamConnectionProperty( PHW_STREAM_REQUEST_BLOCK pSrb );
  145. void ProcessSetDataFormat( PHW_STREAM_REQUEST_BLOCK pSrb );
  146. //void *operator new( size_t, void *buf ) { return buf; }
  147. //void operator delete( void *, size_t ) {}
  148. // I2C API
  149. bool I2CIsInitOK( void );
  150. #ifdef HARDWAREI2C
  151. ErrorCode I2CInitHWMode( long freq );
  152. void I2CSetFreq( long freq );
  153. int I2CReadDiv( void );
  154. ErrorCode I2CHWRead( BYTE address, BYTE *value );
  155. ErrorCode I2CHWWrite2( BYTE address, BYTE value1 );
  156. ErrorCode I2CHWWrite3( BYTE address, BYTE value1, BYTE value2 );
  157. int I2CReadSync( void );
  158. #else
  159. // tuner.cpp contains code to fake these using Software I2C just
  160. // to make the older tuner code work until it is seperated out
  161. ErrorCode I2CHWRead( BYTE address, BYTE *value );
  162. ErrorCode I2CHWWrite3( BYTE address, BYTE value1, BYTE value2 );
  163. #endif
  164. int I2CGetLastError( void );
  165. void StoreI2CAddress( BYTE addr );
  166. BYTE GetI2CAddress();
  167. #ifdef HAUPPAUGEI2CPROVIDER
  168. ErrorCode I2CInitSWMode( long freq );
  169. ErrorCode I2CSWStart( void );
  170. ErrorCode I2CSWStop( void );
  171. ErrorCode I2CSWRead( BYTE * value );
  172. ErrorCode I2CSWWrite( BYTE value );
  173. ErrorCode I2CSWSendACK( void );
  174. ErrorCode I2CSWSendNACK( void );
  175. // ErrorCode I2CSWSetSCL( Level );
  176. // int I2CSWReadSCL( void );
  177. // ErrorCode I2CSWSetSDA( Level );
  178. // int I2CSWReadSDA( void );
  179. #endif
  180. // GPIO API
  181. bool GPIOIsInitOK( void );
  182. void SetGPCLKMODE( State s );
  183. int GetGPCLKMODE( void );
  184. void SetGPIOMODE( GPIOMode mode );
  185. int GetGPIOMODE( void );
  186. void SetGPWEC( State s );
  187. int GetGPWEC( void );
  188. void SetGPINTI( State s );
  189. int GetGPINTI( void );
  190. void SetGPINTC( State s );
  191. int GetGPINTC( void );
  192. ErrorCode SetGPOEBit( int bit, State s );
  193. void SetGPOE( DWORD value );
  194. int GetGPOEBit( int bit );
  195. DWORD GetGPOE( void );
  196. ErrorCode SetGPIEBit( int bit , State s );
  197. void SetGPIE( DWORD value );
  198. int GetGPIEBit( int bit );
  199. DWORD GetGPIE( void );
  200. ErrorCode SetGPDATA( GPIOReg *data, int size, int offset );
  201. ErrorCode GetGPDATA( GPIOReg *data, int size, int offset );
  202. ErrorCode SetGPDATABits( int fromBit, int toBit, DWORD value, int offset );
  203. ErrorCode GetGPDATABits( int fromBit, int toBit, DWORD *value, int offset );
  204. };
  205. inline void PsDevice::StoreI2CAddress( BYTE addr )
  206. {
  207. I2CAddr_ = addr;
  208. }
  209. inline BYTE PsDevice::GetI2CAddress()
  210. {
  211. return I2CAddr_;
  212. }
  213. #endif