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.

229 lines
7.7 KiB

  1. // $Header: G:/SwDev/WDM/Video/bt848/rcs/Decoder.h 1.2 1998/04/29 22:43:32 tomz Exp $
  2. #ifndef __DECODER_H
  3. #define __DECODER_H
  4. #include "regField.h"
  5. #include "viddefs.h"
  6. #include "retcode.h"
  7. const int PAL_xtal = 35;
  8. const int NTSC_xtal = 28;
  9. /////////////////////////////////////////////////////////////////////////////
  10. // CLASS CRegInfo
  11. //
  12. // Description:
  13. // Provides min, max, and default values for a register. To use this class,
  14. // user will declare an object of this class and provide min, max and default
  15. // values of the register.
  16. //
  17. // Attributes:
  18. // int intMin - minumum value
  19. // int intMax - maximum value
  20. // int intDefault - default value
  21. //
  22. // Methods:
  23. // Min() : return minimum value of the register
  24. // Max() : return maximum value of the register
  25. // Default(): return default value of the register
  26. // OutOfRange() : check if an value is out of range
  27. //
  28. /////////////////////////////////////////////////////////////////////////////
  29. class CRegInfo
  30. {
  31. int intMin; // minumum value
  32. int intMax; // maximum value
  33. int intDefault; // default value
  34. public:
  35. CRegInfo( void )
  36. {
  37. intMin = 0;
  38. intMax = 0;
  39. intDefault = 0;
  40. }
  41. CRegInfo( int min, int max, int def )
  42. {
  43. intMin = min;
  44. intMax = max;
  45. intDefault = def;
  46. }
  47. // return min, max and default value of a register
  48. inline int Min( void ) const { return intMin; }
  49. inline int Max( void ) const { return intMax; }
  50. inline int Default( void ) const { return intDefault; }
  51. // check if an value is out of range of a register
  52. inline bool OutOfRange( int x )
  53. {
  54. if( (x > intMax) || (x < intMin) )
  55. return true;
  56. return false;
  57. }
  58. };
  59. /////////////////////////////////////////////////////////////////////////////
  60. // CLASS Decoder
  61. //
  62. // Description:
  63. // This class encapsulates the register fields in the decoder portion of
  64. // the Bt848.
  65. // A complete set of functions are developed to manipulate all the
  66. // register fields in the decoder for the Bt848.
  67. // For Read-Write register field, "Set..." function is provided to modify
  68. // the content of the reigster field. And either "Get..." (for more
  69. // than 1 bit) or "Is..." (for 1 bit) function is provided to obtain the
  70. // value of the register field.
  71. // For Read-Only register field, only "Get..." (for more than 1 bit) or
  72. // "Is..." (for 1 bit) function is provided to obtain the content of the
  73. // register field.
  74. // When there are odd-field complements to the even-field register field,
  75. // same value is set to both odd and even register fields.
  76. // Several direct register content modifying/retrieval functions are
  77. // implemented for direct access to the register contents. They were
  78. // originally developed for testing purpose only. They are retained in the
  79. // class for convenience only and usage of these functions must be very cautious.
  80. //
  81. // Methods:
  82. // See below
  83. //
  84. // Note: 1) Scaling registers are not implemented.
  85. // 2) Odd-fields are set to the same value as the even-field registers
  86. /////////////////////////////////////////////////////////////////////////////
  87. class Decoder
  88. {
  89. protected:
  90. #include "Declare.h"
  91. // used for checking if parameter out of register's range
  92. CRegInfo m_regHue, m_regSaturationNTSC, m_regSaturationSECAM,
  93. m_regContrast, m_regBrightness;
  94. // used for checking parameter range
  95. CRegInfo m_param;
  96. // value set to after calculations
  97. WORD m_satParam, m_conParam, m_hueParam, m_briParam;
  98. // to be used to adjust contrast
  99. int regBright; // brightness register value before adjustment
  100. WORD regContrast; // contrast register value before adjustment
  101. DWORD Xtals_ [2];
  102. public:
  103. // constructor and destructor
  104. Decoder( DWORD *xtals );
  105. ~Decoder();
  106. // Device Status register (DSTATUS)
  107. virtual BYTE GetDeviceStatusReg( void );
  108. virtual bool IsVideoPresent( void );
  109. virtual bool IsDeviceInHLock( void );
  110. virtual bool IsEvenField( void );
  111. virtual bool Is525LinesVideo( void );
  112. virtual bool IsCrystal0Selected( void );
  113. virtual bool IsLumaOverflow( void );
  114. virtual void ResetLumaOverflow( void );
  115. virtual bool IsChromaOverflow( void );
  116. virtual void ResetChromaOverflow( void );
  117. // Input Format register (IFORM)
  118. virtual ErrorCode SetVideoInput( Connector );
  119. virtual int GetVideoInput( void );
  120. virtual ErrorCode SetCrystal( Crystal );
  121. virtual int GetCrystal( void );
  122. virtual ErrorCode SetVideoFormat( VideoFormat );
  123. virtual int GetVideoFormat( void );
  124. // Temporal Decimation register (TDEC)
  125. virtual ErrorCode SetRate( bool, VidField, int );
  126. // Brightness Control register (BRIGHT)
  127. virtual ErrorCode SetBrightness( int );
  128. virtual int GetBrightness( void );
  129. // Miscellaneous Control register (E_CONTROL, O_CONTROL)
  130. virtual void SetLumaNotchFilter( bool );
  131. virtual bool IsLumaNotchFilter( void );
  132. virtual void SetCompositeVideo( bool );
  133. virtual bool IsCompositeVideo( void );
  134. virtual void SetLumaDecimation( bool );
  135. virtual bool IsLumaDecimation( void );
  136. virtual void SetCbFirst( bool );
  137. virtual bool IsCbFirst( void );
  138. // Luma Gain register (CON_MSB, CONTRAST_LO)
  139. virtual ErrorCode SetContrast( int );
  140. virtual int GetContrast( void );
  141. // Chroma Gain register (SAT_U_MSB, SAT_V_MSB, SAT_U_LO, SAT_V_LO)
  142. virtual ErrorCode SetSaturation( int );
  143. virtual int GetSaturation( void );
  144. // Hue Control register (HUE)
  145. virtual ErrorCode SetHue( int );
  146. virtual int GetHue( void );
  147. // SC Loop Control register (E_SCLOOP, O_SCLOOP)
  148. virtual void SetChromaAGC( bool );
  149. virtual bool IsChromaAGC( void );
  150. virtual void SetLowColorAutoRemoval( bool );
  151. virtual bool IsLowColorAutoRemoval( void );
  152. virtual ErrorCode SetHorizontalFilter( HorizFilter );
  153. virtual int GetHorizontalFilter( void );
  154. // Output Format register (OFORM)
  155. virtual void SetFullOutputRange( bool );
  156. virtual bool IsFullOutputRange( void );
  157. virtual ErrorCode SetLumaCoring( CoringLevel );
  158. virtual int GetLumaCoring( void );
  159. // Vertical Scaling register (E_VSCALE_HI, O_VSCALE_HI)
  160. virtual void SetChromaComb( bool );
  161. virtual bool IsChromaComb( void );
  162. // AGC Delay register (ADELAY)
  163. virtual void SetAGCDelay( BYTE );
  164. virtual int GetAGCDelay( void );
  165. // Burst Delay register (BDELAY)
  166. virtual void SetBurstDelay( BYTE );
  167. virtual int GetBurstDelay( void );
  168. // ADC Interface register (ADC)
  169. virtual void SetAnalogThresholdLow( bool );
  170. virtual bool IsAnalogThresholdLow( void );
  171. virtual void SetAGCFunction( bool );
  172. virtual bool IsAGCFunction( void );
  173. virtual void PowerDown( bool );
  174. virtual bool IsPowerDown( void );
  175. virtual void SetLumaADC( bool );
  176. virtual bool IsLumaADC( void );
  177. virtual void SetChromaADC( bool );
  178. virtual bool IsChromaADC( void );
  179. virtual void SetAdaptiveAGC( bool );
  180. virtual bool IsAdaptiveAGC( void );
  181. // Software Reset register (SRESET)
  182. virtual void SoftwareReset( void );
  183. virtual LONG GetSupportedStandards();
  184. protected:
  185. // mapping function
  186. virtual ErrorCode Mapping( int, CRegInfo, int *, CRegInfo );
  187. // check registry key value to determine if contrast should be adjusted
  188. virtual bool IsAdjustContrast( void );
  189. private:
  190. void SelectCrystal( int );
  191. };
  192. #endif // __DECODER_H