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.

366 lines
10 KiB

  1. // $Header: G:/SwDev/WDM/Video/bt848/rcs/Pisces.h 1.8 1998/05/06 18:25:31 tomz Exp $
  2. #ifndef __PISCES_H
  3. #define __PISCES_H
  4. #include "preg.h"
  5. #ifndef __FIELD_H
  6. #include "field.h"
  7. #endif
  8. #ifndef __DECODER_H
  9. #include "decoder.h"
  10. #endif
  11. #ifndef __RISCENG_H
  12. #include "risceng.h"
  13. #endif
  14. typedef void (*EVENTHANDLER)( DWORD dwCB, PVOID pTag );
  15. const PiscesStreams = 4;
  16. #define BIT(x) ((DWORD)1 << (x))
  17. const VSYNC_I = BIT(1); // 0x00000001
  18. const I2CDONE_I = BIT(8); // 0x00000100
  19. const GPINT_I = BIT(9); // 0x00000200
  20. const RISC_I = BIT(11); // 0x00000800
  21. const FBUS_I = BIT(12); // 0x00001000
  22. const FTRGT_I = BIT(13); // 0x00002000
  23. const FDSR_I = BIT(14); // 0x00004000
  24. const PPERR_I = BIT(15); // 0x00008000
  25. const RIPERR_I = BIT(16); // 0x00010000
  26. const PABORT_I = BIT(17); // 0x00020000
  27. const OCERR_I = BIT(18); // 0x00040000
  28. const SCERR_I = BIT(19); // 0x00080000
  29. const DMAERR_I = BIT(20); // 0x00100000
  30. const PARITY_I = (BIT(15)|BIT(16)); // 0x00018000
  31. const EN_TRITON1_BUG_FIX = BIT(23); // 0x00800000
  32. /* Class: IntrIdxAss
  33. * Purpose: Used to assiciate a number program will generate with IRQ and
  34. * an index in the array
  35. */
  36. class IntrIdxAss
  37. {
  38. public:
  39. int IntNo;
  40. int Idx;
  41. IntrIdxAss() : IntNo( 0 ), Idx( 0 ) {}
  42. IntrIdxAss( int key, int value ) : IntNo( key ), Idx( value ) {}
  43. int operator ==( const IntrIdxAss &rhs ) { return IntNo == rhs.IntNo; }
  44. };
  45. /* Type: IntrToIdxDict
  46. * Purpose: Holds values of interrupt number and array index associated
  47. * Note Use TArrayAsVector instead of TIArrayAsVector ( it contains pointers,
  48. * after all ) because compiler insists on calling vector_new which is
  49. * non-existent in the VxD libs
  50. */
  51. typedef IntrIdxAss *IntrToIdxDict [12];
  52. /* Type: ProgramsArray
  53. * Purpose: Defines an array that holds created programs
  54. * Note: Elements in the array alternate, i.e. even program, odd, even...
  55. */
  56. typedef RiscPrgHandle ProgramsArray [12];
  57. // class CProgArray
  58. //
  59. // assumptions:
  60. // 1. Array size is 12.
  61. // 2. The prog array has fixed locations for specific purposes:
  62. // 0 VBIO
  63. // 1 ODD
  64. // 2 ODD Sync
  65. // 3 VBIE
  66. // 4 EVEN
  67. // 5 EVEN Sync
  68. // --------------------
  69. // 6 VBIO
  70. // 7 ODD
  71. // 8 ODD Sync
  72. // 9 VBIE
  73. // 10 EVEN
  74. // 11 EVEN Sync
  75. #define MAX_PROGS 12
  76. class CProgArray {
  77. private:
  78. DWORD dwCurrNdx_ ;
  79. RiscPrgHandle rpArray[MAX_PROGS] ;
  80. public:
  81. CProgArray () { Clear() ;}
  82. virtual ~CProgArray () { }
  83. // Clear sets all array elements handles to NULL
  84. void Clear() {
  85. dwCurrNdx_ = 0 ;
  86. memset( &rpArray[0], '\0', sizeof( rpArray ) ) ;
  87. }
  88. // overload for accessing the array
  89. inline RiscPrgHandle & operator [] (DWORD n) {
  90. n %= MAX_PROGS ; // prevent invalid accesses
  91. return rpArray[n] ;
  92. }
  93. // Return the index of the given handle. Assumes that the handle
  94. // was given by this class and is valid and current.
  95. DWORD GetIndex(RiscPrgHandle hRp)
  96. {
  97. for (int i = 0 ; i < MAX_PROGS ; i++)
  98. if (rpArray[i] == hRp)
  99. return i ;
  100. return (DWORD) -1 ;
  101. }
  102. //
  103. // Count Methods
  104. //
  105. // Returns the number of elements. Static for now.
  106. inline DWORD NumElements() { return MAX_PROGS ; }
  107. // Returns the number of non-null programs
  108. DWORD Count() {
  109. DWORD n = 0 ;
  110. for (int i = 0 ; i < MAX_PROGS ; i++)
  111. if (rpArray[i])
  112. n++ ;
  113. return n ;
  114. }
  115. // Returns the number of video programs
  116. inline DWORD CountVideoProgs() {
  117. DWORD n = 0 ;
  118. if (rpArray[1]) n++ ;
  119. if (rpArray[4]) n++ ;
  120. if (rpArray[7]) n++ ;
  121. if (rpArray[10]) n++ ;
  122. return n ;
  123. }
  124. // Returns the number of vbi programs
  125. inline DWORD CountVbiProgs() {
  126. DWORD n = 0 ;
  127. if (rpArray[0]) n++ ;
  128. if (rpArray[3]) n++ ;
  129. if (rpArray[6]) n++ ;
  130. if (rpArray[9]) n++ ;
  131. return n ;
  132. }
  133. // Returns number of programs which actually transfer data
  134. inline DWORD CountDMAProgs() {
  135. return CountVideoProgs() + CountVbiProgs() ;
  136. }
  137. //
  138. // Find Methods
  139. //
  140. // Returns the first non-null riscprogram. Returns Null if array is empty.
  141. RiscPrgHandle First() {
  142. RiscPrgHandle hRp = NULL ;
  143. for (dwCurrNdx_ = 0 ; dwCurrNdx_ < MAX_PROGS ; dwCurrNdx_++) {
  144. if (rpArray[dwCurrNdx_]) {
  145. hRp = rpArray[dwCurrNdx_++] ;
  146. break ;
  147. }
  148. }
  149. return hRp ;
  150. }
  151. // Returns the next non-null riscprogram. Returns null if there are none left.
  152. RiscPrgHandle Next() {
  153. RiscPrgHandle hRp = NULL ;
  154. for ( ; dwCurrNdx_ < MAX_PROGS ; dwCurrNdx_++) {
  155. if (rpArray[dwCurrNdx_]) {
  156. hRp = rpArray[dwCurrNdx_++] ;
  157. break ;
  158. }
  159. }
  160. return hRp ;
  161. }
  162. } ;
  163. const VBIOStartLocation = 0;
  164. const OddStartLocation = 1;
  165. const OddSyncStartLoc = 2;
  166. const VBIEStartLocation = 3;
  167. const EvenStartLocation = 4;
  168. const EvenSyncStartLoc = 5;
  169. const DistBetweenProgs = 6;
  170. const ProgsWithinField = 3;
  171. /* Class: BtPisces
  172. * Purpose: Controls the BtPisces video capture chip
  173. * Attributes:
  174. * Operations:
  175. * Note: Every time any of the Set functions is called, operation must stop.
  176. * After all changes are done execution can resume. This means that all RISC
  177. * programs are destroyed ( if they exist ), changes made, new RISC programs
  178. * are created ( if needed )
  179. */
  180. class BtPisces
  181. {
  182. DECLARE_COLORCONTROL;
  183. DECLARE_INTERRUPTSTATUS;
  184. DECLARE_INTERRUPTMASK;
  185. DECLARE_CONTROL;
  186. DECLARE_CAPTURECONTROL;
  187. DECLARE_COLORFORMAT;
  188. DECLARE_GPIODATAIO;
  189. DECLARE_GPIOOUTPUTENABLECONTROL;
  190. public:
  191. Decoder PsDecoder_;
  192. private:
  193. // all possible data streams
  194. FieldWithScaler Even_;
  195. FieldWithScaler Odd_;
  196. VBIField VBIE_;
  197. VBIField VBIO_;
  198. RISCEng Engine_;
  199. RISCProgram Starter_;
  200. RISCProgram *Skippers_ [PiscesStreams * MaxProgsForField];
  201. RISCProgram SyncEvenEnd1_;
  202. RISCProgram SyncEvenEnd2_;
  203. RISCProgram SyncOddEnd1_;
  204. RISCProgram SyncOddEnd2_;
  205. CProgArray CreatedProgs_;
  206. CProgArray ActiveProgs_;
  207. IntrToIdxDict InterruptToIdx_;
  208. int nSkipped_;
  209. int OldIdx_;
  210. // this is the indirection array that maps an index from the CreatedProgs_
  211. // array into the Skippers_ array. It is needed because it is much simpler
  212. // to assign a strict relationships between a created program and a skipper
  213. // for it than trying to figure out what skipper program is available
  214. // when a created program needs to be skipped
  215. int SkipperIdxArr_ [ProgsWithinField * 2 * MaxProgsForField];
  216. bool Paused_;
  217. bool Update_;
  218. bool Inited_;
  219. DWORD dwPlanarAdjust_;
  220. void Init();
  221. bool CreateSyncCodes();
  222. void ProcessRISCIntr();
  223. protected:
  224. // type-unsafe method of getting field associated with a stream
  225. // Field & GetField( StreamInfo &str ) { return *(Field*)str.tag; }
  226. int GetIdxFromStream( Field &aField );
  227. RiscPrgHandle AddProgram( Field &aStream, int NumberToAdd );
  228. void ProcessPresentPrograms();
  229. void AssignIntNumbers();
  230. void ProcessSyncPrograms();
  231. void LinkThePrograms();
  232. void Skip( int idx );
  233. void Restart();
  234. void GetStarted( bool &EvenWasStarted, bool &OddWasStarted,
  235. bool &VBIEWasStarted, bool &VBIOWasStarted );
  236. void RestartStreams( bool EvenWasStarted, bool OddWasStarted,
  237. bool VBIEWasStarted, bool VBIOWasStarted );
  238. void CreateStarter( bool EvenWasStarted );
  239. int GetPassed();
  240. // void AdjustTime( LARGE_INTEGER &t, int passed );
  241. RiscPrgHandle GetProgram( int pos, int &idx );
  242. public:
  243. void PairedPause( int idx );
  244. void DumpRiscPrograms();
  245. // decoder 'set' group
  246. virtual void SetBrightness( DWORD value );
  247. virtual void SetSaturation( DWORD value );
  248. virtual void SetConnector ( DWORD value );
  249. virtual void SetContrast ( DWORD value );
  250. virtual void SetHue ( DWORD value );
  251. virtual void SetSVideo ( DWORD value );
  252. virtual void SetFormat ( DWORD value );
  253. virtual LONG GetSaturation();
  254. virtual LONG GetHue ();
  255. virtual LONG GetBrightness();
  256. virtual LONG GetSVideo ();
  257. virtual LONG GetContrast ();
  258. virtual LONG GetFormat ();
  259. virtual LONG GetConnector ();
  260. virtual LONG GetSupportedStandards();
  261. void SetPlanarAdjust( DWORD val ) { dwPlanarAdjust_ = val; }
  262. void TurnVFilter( State s );
  263. // scaler group
  264. virtual ErrorCode SetAnalogWindow( MRect &r, Field &aField );
  265. virtual ErrorCode SetDigitalWindow( MRect &r, Field &aField );
  266. // color space converter group
  267. virtual void SetPixelFormat( ColFmt, Field &aField );
  268. ColFmt GetPixelFormat( Field &aField );
  269. // streaming operation functions
  270. virtual ErrorCode Create( Field &aField );
  271. virtual void Start( Field &aField );
  272. virtual void Stop( Field &aField );
  273. void Pause( Field &aField );
  274. void Continue();
  275. State Interrupt();
  276. // void ProcessAddBuffer( StreamInfo aStream );
  277. void ProcessBufferAtInterrupt( PVOID pTag );
  278. void SetBufPitch( DWORD dwP, Field &aField )
  279. { aField.SetBufPitch( dwP ); }
  280. void SetBufQuePtr( Field &aField, VidBufQueue *pQ )
  281. { aField.SetBufQuePtr( pQ ); }
  282. VidBufQueue &GetCurrentQue( Field &aField )
  283. { return aField.GetCurrentQue(); }
  284. virtual ErrorCode AllocateStream( Field *&Field, VideoStream st );
  285. DWORD GetDataBuffer( int idx ) { return CreatedProgs_ [idx]->GetDataBuffer(); }
  286. bool InitOK();
  287. BtPisces( DWORD *xtals );
  288. ~BtPisces();
  289. };
  290. inline bool BtPisces::InitOK()
  291. {
  292. return Inited_;
  293. }
  294. #endif