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.

323 lines
10 KiB

  1. #pragma once
  2. //==========================================================================;
  3. //
  4. // Decoder - Main decoder declarations
  5. //
  6. // $Date: 21 Aug 1998 21:46:28 $
  7. // $Revision: 1.1 $
  8. // $Author: Tashjian $
  9. //
  10. // $Copyright: (c) 1997 - 1998 ATI Technologies Inc. All Rights Reserved. $
  11. //
  12. //==========================================================================;
  13. #include "viddefs.h"
  14. #include "retcode.h"
  15. #include "capmain.h"
  16. #include "register.h"
  17. /////////////////////////////////////////////////////////////////////////////
  18. // CLASS CRegInfo
  19. //
  20. // Description:
  21. // Provides min, max, and default values for a register. To use this class,
  22. // user will declare an object of this class and provide min, max and default
  23. // values of the register.
  24. //
  25. // Attributes:
  26. // int intMin - minumum value
  27. // int intMax - maximum value
  28. // int intDefault - default value
  29. //
  30. // Methods:
  31. // Min() : return minimum value of the register
  32. // Max() : return maximum value of the register
  33. // Default(): return default value of the register
  34. // OutOfRange() : check if an value is out of range
  35. //
  36. /////////////////////////////////////////////////////////////////////////////
  37. class CRegInfo
  38. {
  39. int intMin; // minumum value
  40. int intMax; // maximum value
  41. int intDefault; // default value
  42. public:
  43. CRegInfo()
  44. {
  45. intMin = 0;
  46. intMax = 0;
  47. intDefault = 0;
  48. }
  49. CRegInfo(int min, int max, int def)
  50. {
  51. intMin = min;
  52. intMax = max;
  53. intDefault = def;
  54. }
  55. // return min, max and default value of a register
  56. inline int Min() const { return intMin; }
  57. inline int Max() const { return intMax; }
  58. inline int Default() const { return intDefault; }
  59. // check if an value is out of range of a register
  60. inline BOOL OutOfRange(int x)
  61. {
  62. if((x > intMax) || (x < intMin))
  63. return TRUE;
  64. return FALSE;
  65. }
  66. };
  67. /////////////////////////////////////////////////////////////////////////////
  68. // CLASS Decoder
  69. //
  70. // Description:
  71. // This class encapsulates the register fields in the decoder portion of
  72. // the Bt848.
  73. // A complete set of functions are developed to manipulate all the
  74. // register fields in the decoder for the Bt848.
  75. // For Read-Write register field, "Set..." function is provided to modify
  76. // the content of the reigster field. And either "Get..." (for more
  77. // than 1 bit) or "Is..." (for 1 bit) function is provided to obtain the
  78. // value of the register field.
  79. // For Read-Only register field, only "Get..." (for more than 1 bit) or
  80. // "Is..." (for 1 bit) function is provided to obtain the content of the
  81. // register field.
  82. // When there are odd-field complements to the even-field register field,
  83. // same value is set to both odd and even register fields.
  84. // Several direct register content modifying/retrieval functions are
  85. // implemented for direct access to the register contents. They were
  86. // originally developed for testing purpose only. They are retained in the
  87. // class for convenience only and usage of these functions must be very cautious.
  88. //
  89. // Methods:
  90. // See below
  91. //
  92. // Note: 1) Scaling registers are not implemented.
  93. // 2) Odd-fields are set to the same value as the even-field registers
  94. /////////////////////////////////////////////////////////////////////////////
  95. class Decoder
  96. {
  97. protected:
  98. RegisterB decRegSTATUS;
  99. RegField decFieldHLOC;
  100. RegField decFieldNUML;
  101. RegField decFieldCSEL;
  102. RegField decFieldSTATUS_RES;
  103. RegField decFieldLOF;
  104. RegField decFieldCOF;
  105. RegisterB decRegIFORM;
  106. RegField decFieldHACTIVE;
  107. RegField decFieldMUXSEL;
  108. RegField decFieldXTSEL;
  109. RegField decFieldFORMAT;
  110. RegisterB decRegTDEC;
  111. RegField decFieldDEC_FIELD;
  112. RegField decFieldDEC_FIELDALIGN;
  113. RegField decFieldDEC_RAT;
  114. RegisterB decRegBRIGHT;
  115. RegisterB decRegMISCCONTROL;
  116. RegField decFieldLNOTCH;
  117. RegField decFieldCOMP;
  118. RegField decFieldLDEC;
  119. RegField decFieldMISCCONTROL_RES;
  120. RegField decFieldCON_MSB;
  121. RegField decFieldSAT_U_MSB;
  122. RegField decFieldSAT_V_MSB;
  123. RegisterB decRegCONTRAST_LO;
  124. RegisterB decRegSAT_U_LO;
  125. RegisterB decRegSAT_V_LO;
  126. RegisterB decRegHUE;
  127. RegisterB decRegSCLOOP;
  128. RegField decFieldCAGC;
  129. RegField decFieldCKILL;
  130. RegisterB decRegWC_UP;
  131. RegisterB decRegOFORM;
  132. RegField decFieldVBI_FRAME;
  133. RegField decFieldCODE;
  134. RegField decFieldLEN;
  135. RegisterB decRegVSCALE_HI;
  136. RegField decFieldYCOMB;
  137. RegField decFieldCOMB;
  138. RegField decFieldINT;
  139. RegisterB decRegTEST;
  140. RegisterB decRegVPOLE;
  141. RegField decFieldOUT_EN;
  142. RegField decFieldDVALID;
  143. RegField decFieldVACTIVE;
  144. RegField decFieldCBFLAG;
  145. RegField decFieldFIELD;
  146. RegField decFieldACTIVE;
  147. RegField decFieldHRESET;
  148. RegField decFieldVRESET;
  149. RegisterB decRegADELAY;
  150. RegisterB decRegBDELAY;
  151. RegisterB decRegADC;
  152. RegField decFieldCLK_SLEEP;
  153. RegField decFieldC_SLEEP;
  154. RegField decFieldCRUSH;
  155. RegisterB decRegVTC;
  156. RegField decFieldHSFMT;
  157. RegisterB decRegWC_DN;
  158. RegisterB decRegSRESET;
  159. RegisterB decRegODD_MISCCONTROL;
  160. RegField decFieldODD_LNOTCH;
  161. RegField decFieldODD_COMP;
  162. RegField decFieldODD_LDEC;
  163. RegField decFieldODD_CBSENSE;
  164. RegField decFieldODD_MISCCONTROL_RES;
  165. RegField decFieldODD_CON_MSB;
  166. RegField decFieldODD_SAT_U_MSB;
  167. RegField decFieldODD_SAT_V_MSB;
  168. RegisterB decRegODD_SCLOOP;
  169. RegField decFieldODD_CAGC;
  170. RegField decFieldODD_CKILL;
  171. RegField decFieldODD_HFILT;
  172. RegisterB decRegODD_VSCALE_HI;
  173. RegField decFieldODD_YCOMB;
  174. RegField decFieldODD_COMB;
  175. RegField decFieldODD_INT;
  176. RegisterB decRegODD_VTC;
  177. RegField decFieldODD_HSFMT;
  178. // used for checking if parameter out of register's range
  179. CRegInfo m_regHue, m_regSaturationNTSC, m_regSaturationSECAM,
  180. m_regContrast, m_regBrightness;
  181. // used for checking parameter range
  182. CRegInfo m_param;
  183. // value set to after calculations
  184. WORD m_satParam, m_conParam, m_hueParam, m_briParam;
  185. // to be used to adjust contrast
  186. int regBright; // brightness register value before adjustment
  187. WORD regContrast; // contrast register value before adjustment
  188. // for 829 vs 829a setup
  189. unsigned m_outputEnablePolarity;
  190. DWORD m_videoStandard; //Paul
  191. DWORD m_supportedVideoStandards; //Paul: The standards supported by the decoder AND'd with standards supported by Crystal
  192. public:
  193. // constructor and destructor
  194. Decoder(PDEVICE_PARMS);
  195. virtual ~Decoder();
  196. void * operator new(size_t size, void * pAllocation) { return(pAllocation);}
  197. void operator delete(void * pAllocation) {}
  198. void GetVideoDecoderCaps(PKSPROPERTY_VIDEODECODER_CAPS_S caps);
  199. void GetVideoDecoderStatus(PKSPROPERTY_VIDEODECODER_STATUS_S status);
  200. DWORD GetVideoDecoderStandard();
  201. ULONG GetVideoDeocderStandardsSupportedInThisConfiguration()
  202. { return m_supportedVideoStandards; }
  203. BOOL SetVideoDecoderStandard(DWORD standard);
  204. // Device Status register (DSTATUS)
  205. virtual BOOL Is525LinesVideo();
  206. virtual BOOL IsCrystal0Selected();
  207. virtual BOOL IsLumaOverflow();
  208. virtual void ResetLumaOverflow();
  209. virtual BOOL IsChromaOverflow();
  210. virtual void ResetChromaOverflow();
  211. // Input Format register (IFORM)
  212. virtual ErrorCode SetVideoInput(Connector);
  213. virtual Connector GetVideoInput();
  214. virtual ErrorCode SetCrystal(Crystal);
  215. virtual int GetCrystal();
  216. virtual ErrorCode SetVideoFormat(VideoFormat);
  217. virtual int GetVideoFormat();
  218. // Temporal Decimation register (TDEC)
  219. virtual ErrorCode SetRate(BOOL, VidField, int);
  220. // Brightness Control register (BRIGHT)
  221. virtual ErrorCode SetBrightness(int);
  222. virtual int GetBrightness();
  223. // Miscellaneous Control register (E_CONTROL, O_CONTROL)
  224. virtual void SetLumaNotchFilter(BOOL);
  225. virtual BOOL IsLumaNotchFilter();
  226. virtual void SetCompositeVideo(BOOL);
  227. virtual void SetLumaDecimation(BOOL);
  228. // Luma Gain register (CON_MSB, CONTRAST_LO)
  229. virtual ErrorCode SetContrast(int);
  230. virtual int GetContrast();
  231. // Chroma Gain register (SAT_U_MSB, SAT_V_MSB, SAT_U_LO, SAT_V_LO)
  232. virtual ErrorCode SetSaturation(int);
  233. virtual int GetSaturation();
  234. // Hue Control register (HUE)
  235. virtual ErrorCode SetHue(int);
  236. virtual int GetHue();
  237. // SC Loop Control register (E_SCLOOP, O_SCLOOP)
  238. virtual void SetChromaAGC(BOOL);
  239. virtual BOOL IsChromaAGC();
  240. virtual void SetLowColorAutoRemoval(BOOL);
  241. // Output Format register (OFORM)
  242. virtual void SetVBIFrameMode(BOOL);
  243. virtual BOOL IsVBIFrameMode();
  244. virtual void SetCodeInsertionEnabled(BOOL);
  245. virtual BOOL IsCodeInsertionEnabled();
  246. virtual void Set16BitDataStream(BOOL);
  247. virtual BOOL Is16BitDataStream();
  248. // Vertical Scaling register (E_VSCALE_HI, O_VSCALE_HI)
  249. virtual void SetChromaComb(BOOL);
  250. virtual BOOL IsChromaComb();
  251. virtual void SetInterlaced(BOOL);
  252. virtual BOOL IsInterlaced();
  253. // VPOLE register
  254. void SetOutputEnablePolarity(int i)
  255. {m_outputEnablePolarity = i;}
  256. int GetOutputEnablePolarity()
  257. {return m_outputEnablePolarity;}
  258. virtual void SetOutputEnabled(BOOL);
  259. virtual BOOL IsOutputEnabled();
  260. virtual void SetHighOdd(BOOL);
  261. virtual BOOL IsHighOdd();
  262. // ADC Interface register (ADC)
  263. virtual void PowerDown(BOOL);
  264. virtual BOOL IsPowerDown();
  265. virtual void SetChromaADC(BOOL);
  266. virtual void SetAdaptiveAGC(BOOL);
  267. virtual BOOL IsAdaptiveAGC();
  268. // Software Reset register (SRESET)
  269. virtual void SoftwareReset();
  270. // Test Control register (TEST)
  271. virtual void AdjustInertialDampener(BOOL);
  272. protected:
  273. // mapping function
  274. virtual ErrorCode Mapping(int, CRegInfo, int *, CRegInfo);
  275. // check registry key value to determine if contrast should be adjusted
  276. virtual BOOL IsAdjustContrast();
  277. private:
  278. void SelectCrystal(char);
  279. };