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.

619 lines
22 KiB

  1. //==========================================================================;
  2. //
  3. // WDMTuner.CPP
  4. // WDM Tuner MiniDriver.
  5. // Philips Tuner.
  6. // CATIWDMTuner class implementation.
  7. // Copyright (c) 1996 - 1997 ATI Technologies Inc. All Rights Reserved.
  8. //
  9. // $Date: 10 Aug 1999 16:15:44 $
  10. // $Revision: 1.6 $
  11. // $Author: KLEBANOV $
  12. //
  13. //==========================================================================;
  14. extern "C"
  15. {
  16. #include "strmini.h"
  17. #include "ksmedia.h"
  18. #include "wdmdebug.h"
  19. }
  20. #include "atitunep.h"
  21. #include "wdmdrv.h"
  22. #include "aticonfg.h"
  23. #define ATI_TVAUDIO_SUPPORT
  24. /*^^*
  25. * AdapterCompleteInitialization()
  26. * Purpose : Called when SRB_COMPLETE_UNINITIALIZATION SRB is received.
  27. *
  28. * Inputs : PHW_STREAM_REQUEST_BLOCK pSrb : pointer to the current Srb
  29. *
  30. * Outputs : BOOL : returns TRUE
  31. * Author : IKLEBANOV
  32. *^^*/
  33. NTSTATUS CATIWDMTuner::AdapterCompleteInitialization( PHW_STREAM_REQUEST_BLOCK pSrb)
  34. {
  35. PADAPTER_DATA_EXTENSION pPrivateData = ( PADAPTER_DATA_EXTENSION)( pSrb->HwDeviceExtension);
  36. PDEVICE_OBJECT pDeviceObject = pPrivateData->PhysicalDeviceObject;
  37. KSPIN_MEDIUM mediumKSPin;
  38. NTSTATUS ntStatus;
  39. UINT nIndex;
  40. HANDLE hFolder;
  41. ULONG ulInstance;
  42. ENSURE
  43. {
  44. nIndex = 0;
  45. switch( m_ulNumberOfPins)
  46. {
  47. case 2:
  48. // TVTuner with TVAudio
  49. ::RtlCopyMemory( &m_pTVTunerPinsMediumInfo[nIndex ++], &ATITVTunerVideoOutMedium, sizeof( KSPIN_MEDIUM));
  50. #ifdef ATI_TVAUDIO_SUPPORT
  51. #pragma message ("\n!!! PAY ATTENTION: Tuner PinMedium is compiled with TVAudio support !!!\n")
  52. ::RtlCopyMemory( &m_pTVTunerPinsMediumInfo[nIndex], &ATITVTunerTVAudioOutMedium, sizeof( KSPIN_MEDIUM));
  53. #else
  54. #pragma message ("\n!!! PAY ATTENTION: Tuner PinMedium is compiled without TVAudio support !!!\n")
  55. ::RtlCopyMemory( &m_pTVTunerPinsMediumInfo[nIndex ++], &ATIXBarAudioTunerInMedium, sizeof( KSPIN_MEDIUM));
  56. #endif
  57. break;
  58. case 3:
  59. // TVTuner with TVAudio with separate FM Audio output
  60. ::RtlCopyMemory( &m_pTVTunerPinsMediumInfo[nIndex ++], &ATITVTunerVideoOutMedium, sizeof( KSPIN_MEDIUM));
  61. #ifdef ATI_TVAUDIO_SUPPORT
  62. ::RtlCopyMemory( &m_pTVTunerPinsMediumInfo[nIndex ++], &ATITVTunerTVAudioOutMedium, sizeof( KSPIN_MEDIUM));
  63. #else
  64. ::RtlCopyMemory( &m_pTVTunerPinsMediumInfo[nIndex ++], &ATIXBarAudioTunerInMedium, sizeof( KSPIN_MEDIUM));
  65. #endif
  66. case 1:
  67. // it can be FM Tuner only.
  68. ::RtlCopyMemory( &m_pTVTunerPinsMediumInfo[nIndex], &ATITVTunerRadioAudioOutMedium, sizeof( KSPIN_MEDIUM));
  69. break;
  70. }
  71. ulInstance = ::GetDriverInstanceNumber( pDeviceObject);
  72. hFolder = ::OpenRegistryFolder( pDeviceObject, UNICODE_WDM_REG_PIN_MEDIUMS);
  73. for( nIndex = 0; nIndex < m_ulNumberOfPins; nIndex ++)
  74. {
  75. if( ::ReadPinMediumFromRegistryFolder( hFolder, nIndex, &mediumKSPin))
  76. ::RtlCopyMemory( &m_pTVTunerPinsMediumInfo[nIndex], &mediumKSPin, sizeof( KSPIN_MEDIUM));
  77. m_pTVTunerPinsMediumInfo[nIndex].Id = ulInstance;
  78. // all the possible pins exposed are the outputs
  79. m_pTVTunerPinsDirectionInfo[nIndex] = TRUE;
  80. }
  81. if( hFolder != NULL)
  82. ::ZwClose( hFolder);
  83. ntStatus = StreamClassRegisterFilterWithNoKSPins( \
  84. pDeviceObject , // IN PDEVICE_OBJECT DeviceObject,
  85. &KSCATEGORY_TVTUNER, // IN GUID * InterfaceClassGUID
  86. m_ulNumberOfPins, // IN ULONG PinCount,
  87. m_pTVTunerPinsDirectionInfo, // IN ULONG * Flags,
  88. m_pTVTunerPinsMediumInfo, // IN KSPIN_MEDIUM * MediumList,
  89. NULL); // IN GUID * CategoryList
  90. if( !NT_SUCCESS( ntStatus))
  91. FAIL;
  92. OutputDebugInfo(( "CATIWDMTuner:AdapterCompleteInitialization() exit\n"));
  93. } END_ENSURE;
  94. if( !NT_SUCCESS( ntStatus))
  95. OutputDebugError(( "CATIWDMTuner:AdapterCompleteInitialization() ntStatus=%x\n", ntStatus));
  96. return( ntStatus);
  97. }
  98. /*^^*
  99. * AdapterUnInitialize()
  100. * Purpose : Called when SRB_UNINITIALIZE_DEVICE SRB is received.
  101. *
  102. * Inputs : PHW_STREAM_REQUEST_BLOCK pSrb : pointer to the current Srb
  103. *
  104. * Outputs : BOOL : returns TRUE
  105. * Author : IKLEBANOV
  106. *^^*/
  107. BOOL CATIWDMTuner::AdapterUnInitialize( PHW_STREAM_REQUEST_BLOCK pSrb)
  108. {
  109. OutputDebugTrace(( "CATIWDMTuner:AdapterUnInitialize()\n"));
  110. // just deallocate the any memory was allocated at run-time
  111. if( m_pTVTunerPinsMediumInfo != NULL)
  112. {
  113. ::ExFreePool( m_pTVTunerPinsMediumInfo);
  114. m_pTVTunerPinsMediumInfo = NULL;
  115. }
  116. if( m_pTVTunerPinsDirectionInfo != NULL)
  117. {
  118. ::ExFreePool( m_pTVTunerPinsDirectionInfo);
  119. m_pTVTunerPinsDirectionInfo = NULL;
  120. }
  121. pSrb->Status = STATUS_SUCCESS;
  122. return( TRUE);
  123. }
  124. /*^^*
  125. * AdapterGetStreamInfo()
  126. * Purpose : fills in HW_STREAM_HEADER for StreamClass driver
  127. *
  128. * Inputs : PHW_STREAM_REQUEST_BLOCK pSrb : pointer to the current Srb
  129. *
  130. * Outputs : BOOL : returns TRUE
  131. * Author : IKLEBANOV
  132. *^^*/
  133. BOOL CATIWDMTuner::AdapterGetStreamInfo( PHW_STREAM_REQUEST_BLOCK pSrb)
  134. {
  135. // pick up the pointer to the stream header data structure
  136. PHW_STREAM_HEADER pStreamHeader = ( PHW_STREAM_HEADER)&( pSrb->CommandData.StreamBuffer->StreamHeader);
  137. // no streams are supported
  138. DEBUG_ASSERT( pSrb->NumberOfBytesToTransfer >= sizeof( HW_STREAM_HEADER));
  139. OutputDebugTrace(( "CATIWDMTuner:AdapterGetStreamInfo()\n"));
  140. m_wdmTunerStreamHeader.NumberOfStreams = 0;
  141. m_wdmTunerStreamHeader.SizeOfHwStreamInformation = sizeof( HW_STREAM_INFORMATION);
  142. m_wdmTunerStreamHeader.NumDevPropArrayEntries = 1;
  143. m_wdmTunerStreamHeader.DevicePropertiesArray = &m_wdmTunerPropertySet;
  144. m_wdmTunerStreamHeader.NumDevEventArrayEntries = 0;
  145. m_wdmTunerStreamHeader.DeviceEventsArray = NULL;
  146. m_wdmTunerStreamHeader.Topology = &m_wdmTunerTopology;
  147. * pStreamHeader = m_wdmTunerStreamHeader;
  148. pSrb->Status = STATUS_SUCCESS;
  149. return( TRUE);
  150. }
  151. /*^^*
  152. * AdapterQueryUnload()
  153. * Purpose : Called when the class driver is about to unload the MiniDriver
  154. * The MiniDriver checks if any open stream left.
  155. *
  156. * Inputs : PHW_STREAM_REQUEST_BLOCK pSrb : pointer to the current Srb
  157. *
  158. * Outputs : BOOL : returns TRUE
  159. * Author : IKLEBANOV
  160. *^^*/
  161. BOOL CATIWDMTuner::AdapterQueryUnload( PHW_STREAM_REQUEST_BLOCK pSrb)
  162. {
  163. OutputDebugTrace(( "CATIWDMTuner:AdapterQueryUnload()\n"));
  164. pSrb->Status = STATUS_SUCCESS;
  165. return( TRUE);
  166. }
  167. /*^^*
  168. * operator new
  169. * Purpose : CATIWDMTuner class overloaded operator new.
  170. * Provides placement for a CATIWDMTuner class object from the PADAPTER_DEVICE_EXTENSION
  171. * allocated by the StreamClassDriver for the MiniDriver.
  172. *
  173. * Inputs : UINT size_t : size of the object to be placed
  174. * PVOID pAllocation : casted pointer to the CWDMTuner allocated data
  175. *
  176. * Outputs : PVOID : pointer of the CATIWDMTuner class object
  177. * Author : IKLEBANOV
  178. *^^*/
  179. PVOID CATIWDMTuner::operator new( size_t size_t, PVOID pAllocation)
  180. {
  181. if( size_t != sizeof( CATIWDMTuner))
  182. {
  183. OutputDebugError(( "CATIWDMTuner: operator new() fails\n"));
  184. return( NULL);
  185. }
  186. else
  187. return( pAllocation);
  188. }
  189. /*^^*
  190. * ~CATIWDMTuner()
  191. * Purpose : CATIWDMTuner class destructor.
  192. * Frees the allocated memory.
  193. *
  194. * Inputs : none
  195. *
  196. * Outputs : none
  197. * Author : IKLEBANOV
  198. *^^*/
  199. CATIWDMTuner::~CATIWDMTuner()
  200. {
  201. OutputDebugTrace(( "CATIWDMTuner:~CATIWDMTuner()\n"));
  202. if( m_pTVTunerPinsMediumInfo != NULL)
  203. {
  204. ::ExFreePool( m_pTVTunerPinsMediumInfo);
  205. m_pTVTunerPinsMediumInfo = NULL;
  206. }
  207. if( m_pTVTunerPinsDirectionInfo != NULL)
  208. {
  209. ::ExFreePool( m_pTVTunerPinsDirectionInfo);
  210. m_pTVTunerPinsDirectionInfo = NULL;
  211. }
  212. }
  213. /*^^*
  214. * CATIWDMTuner()
  215. * Purpose : CATIWDMTuner class constructor.
  216. * Performs checking of the hardware presence. Sets the hardware in an initial state.
  217. *
  218. * Inputs : CI2CScript * pCScript : pointer to the I2CScript class object
  219. * PUINT puiError : pointer to return a completion error code
  220. *
  221. * Outputs : none
  222. * Author : IKLEBANOV
  223. *^^*/
  224. CATIWDMTuner::CATIWDMTuner( PPORT_CONFIGURATION_INFORMATION pConfigInfo, CI2CScript * pCScript, PUINT puiErrorCode)
  225. :m_CATIConfiguration( pConfigInfo, pCScript, puiErrorCode)
  226. {
  227. UINT uiError;
  228. OutputDebugTrace(( "CATIWDMTuner:CATIWDMTuner() enter\n"));
  229. // error code was carried over from ATIConfiguration class constructor
  230. uiError = * puiErrorCode;
  231. m_pTVTunerPinsMediumInfo = NULL;
  232. m_pTVTunerPinsDirectionInfo = NULL;
  233. m_ulPowerState = PowerDeviceD0;
  234. ENSURE
  235. {
  236. if( uiError != WDMMINI_NOERROR)
  237. // ATIConfiguration Class object was constructed with an error
  238. FAIL;
  239. if( pCScript == NULL)
  240. {
  241. uiError = WDMMINI_INVALIDPARAM;
  242. FAIL;
  243. }
  244. if( !m_CATIConfiguration.GetTunerConfiguration( &m_uiTunerId, &m_uchTunerI2CAddress) ||
  245. ( !m_uchTunerI2CAddress))
  246. {
  247. // there was no hardware information found
  248. uiError = WDMMINI_NOHARDWARE;
  249. FAIL;
  250. }
  251. // Set tuner capabilities ( RO properties) based upon the TunerId
  252. if( !SetTunerWDMCapabilities( m_uiTunerId) || ( !m_ulNumberOfPins))
  253. {
  254. // there is unsupported hardware was found
  255. uiError = WDMMINI_UNKNOWNHARDWARE;
  256. FAIL;
  257. }
  258. m_pTVTunerPinsMediumInfo = ( PKSPIN_MEDIUM) \
  259. ::ExAllocatePool( NonPagedPool, sizeof( KSPIN_MEDIUM) * m_ulNumberOfPins);
  260. if( m_pTVTunerPinsMediumInfo == NULL)
  261. {
  262. uiError = WDMMINI_ERROR_MEMORYALLOCATION;
  263. FAIL;
  264. }
  265. m_pTVTunerPinsDirectionInfo = ( PBOOL) \
  266. ::ExAllocatePool( NonPagedPool, sizeof( BOOL) * m_ulNumberOfPins);
  267. if( m_pTVTunerPinsDirectionInfo == NULL)
  268. {
  269. uiError = WDMMINI_ERROR_MEMORYALLOCATION;
  270. FAIL;
  271. }
  272. m_pI2CScript = pCScript;
  273. SetWDMTunerKSProperties();
  274. SetWDMTunerKSTopology();
  275. // Set run-time WDM properties at the last
  276. m_ulVideoStandard = ( m_ulNumberOfStandards == 1) ?
  277. // unknown standard or the only one
  278. m_wdmTunerCaps.ulStandardsSupported : 0x0L;
  279. m_ulTunerInput = 0L; // unknown input or the only one
  280. m_ulTuningFrequency = 0L; // unknown tuning frequency
  281. #ifndef ATI_TVAUDIO_SUPPORT
  282. {
  283. // this code is needed to initilaize TVAudio path off the tuner
  284. // if there is no separate MiniDriver for TVAudio is assumed
  285. UINT uiAudioConfiguration;
  286. UCHAR uchAudioI2CAddress;
  287. if( m_CATIConfiguration.GetAudioConfiguration( &uiAudioConfiguration,
  288. &uchAudioI2CAddress))
  289. {
  290. m_CATIConfiguration.InitializeAudioConfiguration( pCScript,
  291. uiAudioConfiguration,
  292. uchAudioI2CAddress);
  293. }
  294. }
  295. #endif // ATI_TVAUDIO_SUPPORT
  296. * puiErrorCode = WDMMINI_NOERROR;
  297. OutputDebugTrace(( "CATIWDMTuner:CATIWDMTuner() exit\n"));
  298. return;
  299. } END_ENSURE;
  300. * puiErrorCode = uiError;
  301. OutputDebugError(( "CATIWDMTuner:CATIWDMTuner() Error = %x\n", uiError));
  302. }
  303. /*^^*
  304. * SetTunerCapabilities()
  305. * Purpose : Sets the capabilities ( RO properties) based upon the Tuner Id
  306. *
  307. * Inputs : UINT puiTunerId : Tuner Id
  308. *
  309. * Outputs : returns TRUE, if there is a supported Tuner Id specified;
  310. * also sets the following WDM Tuner properities:
  311. * Author : IKLEBANOV
  312. *^^*/
  313. BOOL CATIWDMTuner::SetTunerWDMCapabilities( UINT uiTunerId)
  314. {
  315. ::RtlZeroMemory( &m_wdmTunerCaps, sizeof( ATI_KSPROPERTY_TUNER_CAPS));
  316. m_ulIntermediateFrequency = 0x0L;
  317. switch( uiTunerId)
  318. {
  319. case 0x01: // FI1236 NTSC M/N North America
  320. m_ulNumberOfStandards = 3;
  321. m_wdmTunerCaps.ulStandardsSupported = KS_AnalogVideo_NTSC_M |
  322. KS_AnalogVideo_PAL_M |
  323. KS_AnalogVideo_PAL_N;
  324. m_wdmTunerCaps.ulNumberOfInputs = 1;
  325. m_wdmTunerCaps.ulMinFrequency = 54000000L;
  326. m_wdmTunerCaps.ulMaxFrequency = 801250000L;
  327. m_ulIntermediateFrequency = 45750000L;
  328. m_ulSupportedModes = KSPROPERTY_TUNER_MODE_TV;
  329. m_ulNumberOfPins = 2;
  330. break;
  331. case 0x02: // FI1236J NTSC M/N Japan
  332. m_ulNumberOfStandards = 1;
  333. m_wdmTunerCaps.ulStandardsSupported = KS_AnalogVideo_NTSC_M_J;
  334. m_wdmTunerCaps.ulNumberOfInputs = 1;
  335. m_wdmTunerCaps.ulMinFrequency = 54000000L;
  336. m_wdmTunerCaps.ulMaxFrequency = 765250000L;
  337. m_ulIntermediateFrequency = 45750000L;
  338. m_ulSupportedModes = KSPROPERTY_TUNER_MODE_TV;
  339. m_ulNumberOfPins = 2;
  340. break;
  341. case 0x03: // FI1216 PAL B/G
  342. m_ulNumberOfStandards = 2;
  343. m_wdmTunerCaps.ulStandardsSupported = KS_AnalogVideo_PAL_B |
  344. KS_AnalogVideo_PAL_G;
  345. m_wdmTunerCaps.ulNumberOfInputs = 1;
  346. m_wdmTunerCaps.ulMinFrequency = 54000000L;
  347. m_wdmTunerCaps.ulMaxFrequency = 855250000L;
  348. m_ulIntermediateFrequency = 38900000L;
  349. m_ulSupportedModes = KSPROPERTY_TUNER_MODE_TV;
  350. m_ulNumberOfPins = 2;
  351. break;
  352. case 0x04: // FI1246 MK2 PAL I
  353. m_ulNumberOfStandards = 1;
  354. m_wdmTunerCaps.ulStandardsSupported = KS_AnalogVideo_PAL_I;
  355. m_wdmTunerCaps.ulNumberOfInputs = 1;
  356. m_wdmTunerCaps.ulMinFrequency = 45750000L;
  357. m_wdmTunerCaps.ulMaxFrequency = 855250000L;
  358. m_ulIntermediateFrequency = 38900000L;
  359. m_ulSupportedModes = KSPROPERTY_TUNER_MODE_TV;
  360. m_ulNumberOfPins = 2;
  361. break;
  362. case 0x05: // FI1216 PAL B/G, SECAM L/L'
  363. m_ulNumberOfStandards = 3;
  364. m_wdmTunerCaps.ulStandardsSupported = KS_AnalogVideo_PAL_B |
  365. KS_AnalogVideo_PAL_G |
  366. KS_AnalogVideo_SECAM_L;
  367. m_wdmTunerCaps.ulNumberOfInputs = 1;
  368. m_wdmTunerCaps.ulMinFrequency = 54000000L;
  369. m_wdmTunerCaps.ulMaxFrequency = 855250000L;
  370. m_ulIntermediateFrequency = 38900000L;
  371. m_ulSupportedModes = KSPROPERTY_TUNER_MODE_TV;
  372. m_ulNumberOfPins = 2;
  373. break;
  374. case 0x06: // FR1236MK2 NTSC M/N North America + Japan
  375. m_ulNumberOfStandards = 4;
  376. m_wdmTunerCaps.ulStandardsSupported = KS_AnalogVideo_NTSC_M |
  377. KS_AnalogVideo_PAL_M |
  378. KS_AnalogVideo_NTSC_M_J |
  379. KS_AnalogVideo_PAL_N;
  380. m_wdmTunerCaps.ulNumberOfInputs = 1;
  381. m_wdmTunerCaps.ulMinFrequency = 54000000L;
  382. m_wdmTunerCaps.ulMaxFrequency = 801250000L;
  383. m_ulIntermediateFrequency = 45750000L;
  384. m_ulSupportedModes = KSPROPERTY_TUNER_MODE_TV;
  385. m_ulNumberOfPins = 2;
  386. break;
  387. case 0x07: // FI1256 PAL D/K China
  388. m_ulNumberOfStandards = 1;
  389. m_wdmTunerCaps.ulStandardsSupported = KS_AnalogVideo_PAL_D |
  390. KS_AnalogVideo_SECAM_D;
  391. m_wdmTunerCaps.ulNumberOfInputs = 1;
  392. m_wdmTunerCaps.ulMinFrequency = 48250000L;
  393. m_wdmTunerCaps.ulMaxFrequency = 855250000L;
  394. m_ulIntermediateFrequency = 38000000L;
  395. m_ulSupportedModes = KSPROPERTY_TUNER_MODE_TV;
  396. m_ulNumberOfPins = 2;
  397. break;
  398. case 0x08: // NTSC North America NEC FM Tuner
  399. m_ulNumberOfStandards = 3;
  400. m_wdmTunerCaps.ulStandardsSupported = KS_AnalogVideo_NTSC_M |
  401. KS_AnalogVideo_PAL_M |
  402. KS_AnalogVideo_PAL_N;
  403. m_wdmTunerCaps.ulNumberOfInputs = 2;
  404. m_wdmTunerCaps.ulMinFrequency = 54000000L;
  405. m_wdmTunerCaps.ulMaxFrequency = 801250000L;
  406. m_ulIntermediateFrequency = 45750000L;
  407. m_ulSupportedModes = KSPROPERTY_TUNER_MODE_TV |
  408. KSPROPERTY_TUNER_MODE_FM_RADIO;
  409. m_ulNumberOfPins = 2;
  410. break;
  411. case 0x10: // NTSC North America Alps Tuner
  412. case 0x11: // NTSC North America Alps Tuner
  413. m_ulNumberOfStandards = 3;
  414. m_wdmTunerCaps.ulStandardsSupported = KS_AnalogVideo_NTSC_M |
  415. KS_AnalogVideo_PAL_M |
  416. KS_AnalogVideo_PAL_N;
  417. m_wdmTunerCaps.ulNumberOfInputs = 1;
  418. m_wdmTunerCaps.ulMinFrequency = 54000000L;
  419. m_wdmTunerCaps.ulMaxFrequency = 801250000L;
  420. m_ulIntermediateFrequency = 45750000L;
  421. m_ulSupportedModes = KSPROPERTY_TUNER_MODE_TV;
  422. m_ulNumberOfPins = 2;
  423. break;
  424. case 0x12: // NTSC North America Alps Tuner with FM
  425. m_ulNumberOfStandards = 3;
  426. m_wdmTunerCaps.ulStandardsSupported = KS_AnalogVideo_NTSC_M |
  427. KS_AnalogVideo_PAL_M |
  428. KS_AnalogVideo_PAL_N;
  429. m_wdmTunerCaps.ulNumberOfInputs = 1;
  430. m_wdmTunerCaps.ulMinFrequency = 54000000L;
  431. m_wdmTunerCaps.ulMaxFrequency = 801250000L;
  432. m_ulIntermediateFrequency = 45750000L;
  433. m_ulSupportedModes = KSPROPERTY_TUNER_MODE_TV |
  434. KSPROPERTY_TUNER_MODE_FM_RADIO;
  435. m_ulNumberOfPins = 2;
  436. break;
  437. case 0x0D: // Temic 4006 FN5 PAL B/G + PAL/I + PAL D + SECAM D/K
  438. m_ulNumberOfStandards = 6;
  439. m_wdmTunerCaps.ulStandardsSupported = KS_AnalogVideo_PAL_B |
  440. KS_AnalogVideo_PAL_G |
  441. KS_AnalogVideo_PAL_I |
  442. KS_AnalogVideo_PAL_D |
  443. KS_AnalogVideo_SECAM_D |
  444. KS_AnalogVideo_SECAM_K;
  445. m_wdmTunerCaps.ulNumberOfInputs = 1;
  446. m_wdmTunerCaps.ulMinFrequency = 45000000L;
  447. m_wdmTunerCaps.ulMaxFrequency = 868000000L;
  448. m_ulIntermediateFrequency = 38900000L;
  449. m_ulSupportedModes = KSPROPERTY_TUNER_MODE_TV;
  450. m_ulNumberOfPins = 2;
  451. break;
  452. default:
  453. return( FALSE);
  454. }
  455. m_ulTunerMode = KSPROPERTY_TUNER_MODE_TV;
  456. m_wdmTunerCaps.ulTuningGranularity = 62500L;
  457. m_wdmTunerCaps.ulSettlingTime = 150;
  458. m_wdmTunerCaps.ulStrategy = KS_TUNER_STRATEGY_PLL;
  459. return( TRUE);
  460. }
  461. /*^^*
  462. * AdapterSetPowerState()
  463. * Purpose : Sets Power Managemeny mode
  464. *
  465. * Inputs : PHW_STREAM_REQUEST_BLOCK pSrb : pointer to the current Srb
  466. *
  467. * Outputs : NTSTATUS as the result of operation
  468. * Author : TOM
  469. *^^*/
  470. NTSTATUS CATIWDMTuner::AdapterSetPowerState( PHW_STREAM_REQUEST_BLOCK pSrb)
  471. {
  472. PADAPTER_DATA_EXTENSION pPrivateData =
  473. ( PADAPTER_DATA_EXTENSION)(( PHW_STREAM_REQUEST_BLOCK)pSrb)->HwDeviceExtension;
  474. CI2CScript * pCScript = &pPrivateData->CScript;
  475. DEVICE_POWER_STATE nDeviceState = pSrb->CommandData.DeviceState;
  476. LARGE_INTEGER liWakeUpTime;
  477. NTSTATUS ntStatus;
  478. m_pPendingDeviceSrb = pSrb;
  479. ntStatus = STATUS_ADAPTER_HARDWARE_ERROR;
  480. switch( nDeviceState)
  481. {
  482. case PowerDeviceD0:
  483. case PowerDeviceD3:
  484. if( nDeviceState != m_ulPowerState)
  485. {
  486. m_CATIConfiguration.SetTunerPowerState( m_pI2CScript,
  487. ( nDeviceState == PowerDeviceD0 ? TRUE : FALSE));
  488. // if transition form D3 to D0 we have to restore frequency
  489. if(( nDeviceState == PowerDeviceD0) && ( m_ulPowerState == PowerDeviceD3))
  490. {
  491. // we have to wait approx. 10ms for tuner to power up
  492. liWakeUpTime.QuadPart = ATIHARDWARE_TUNER_WAKEUP_DELAY;
  493. KeDelayExecutionThread( KernelMode, FALSE, &liWakeUpTime);
  494. // now we have to restore frequency
  495. if( SetTunerFrequency( m_ulTuningFrequency))
  496. ntStatus = STATUS_SUCCESS;
  497. else
  498. ntStatus = STATUS_ADAPTER_HARDWARE_ERROR;
  499. }
  500. else
  501. ntStatus = STATUS_SUCCESS;
  502. m_ulPowerState = nDeviceState;
  503. }
  504. else
  505. ntStatus = STATUS_SUCCESS;
  506. break;
  507. case PowerDeviceD1:
  508. case PowerDeviceD2:
  509. ntStatus = STATUS_SUCCESS;
  510. break;
  511. default:
  512. ntStatus = STATUS_INVALID_PARAMETER;
  513. break;
  514. }
  515. return( ntStatus);
  516. }