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.

495 lines
22 KiB

  1. //==========================================================================;
  2. //
  3. // XBarProp.CPP
  4. // WDM Audio/Video CrossBar MiniDriver.
  5. // AIW hardware platform.
  6. // WDM Properties management.
  7. // Copyright (c) 1996 - 1997 ATI Technologies Inc. All Rights Reserved.
  8. //
  9. //==========================================================================;
  10. extern "C"
  11. {
  12. #include "strmini.h"
  13. #include "ksmedia.h"
  14. #include "wdmdebug.h"
  15. }
  16. #include "wdmdrv.h"
  17. #include "atixbar.h"
  18. #include "aticonfg.h"
  19. /*^^*
  20. * AdapterGetProperty()
  21. * Purpose : Called when SRB_GET_PROPERTY SRB is received.
  22. *
  23. * Inputs : PHW_STREAM_REQUEST_BLOCK pSrb : pointer to the current Srb
  24. *
  25. * Outputs : BOOL : returns returns FALSE, if it is not a XBar property
  26. * it also returns the required property
  27. * Author : IKLEBANOV
  28. *^^*/
  29. BOOL CWDMAVXBar::AdapterGetProperty( PHW_STREAM_REQUEST_BLOCK pSrb)
  30. {
  31. PSTREAM_PROPERTY_DESCRIPTOR pSpd = pSrb->CommandData.PropertyInfo;
  32. ULONG uiPropertyId = pSpd->Property->Id; // index of the property
  33. if( !::IsEqualGUID(( const struct _GUID &)PROPSETID_VIDCAP_CROSSBAR, ( const struct _GUID &)pSpd->Property->Set))
  34. return( FALSE);
  35. OutputDebugInfo(( "CWDMAVXBar:AdapterGetProperty() Id = %d\n", uiPropertyId));
  36. switch( uiPropertyId)
  37. {
  38. case KSPROPERTY_CROSSBAR_CAPS:
  39. ASSERT( pSpd->PropertyOutputSize >= sizeof( PKSPROPERTY_CROSSBAR_CAPS_S));
  40. {
  41. PKSPROPERTY_CROSSBAR_CAPS_S pAVXBarCaps = ( PKSPROPERTY_CROSSBAR_CAPS_S)pSpd->PropertyInfo;
  42. // Copy the input property info to the output property info
  43. ::RtlCopyMemory( pAVXBarCaps, pSpd->Property, sizeof( KSPROPERTY));
  44. pAVXBarCaps->NumberOfInputs = m_nNumberOfVideoInputs + m_nNumberOfAudioInputs;
  45. pAVXBarCaps->NumberOfOutputs = m_nNumberOfVideoOutputs + m_nNumberOfAudioOutputs;
  46. }
  47. pSrb->ActualBytesTransferred = sizeof( KSPROPERTY_CROSSBAR_CAPS_S);
  48. break;
  49. case KSPROPERTY_CROSSBAR_PININFO:
  50. ASSERT( pSpd->PropertyOutputSize >= sizeof( KSPROPERTY_CROSSBAR_PININFO_S));
  51. {
  52. PKSPROPERTY_CROSSBAR_PININFO_S pPinInfo = ( PKSPROPERTY_CROSSBAR_PININFO_S)pSpd->PropertyInfo;
  53. ULONG nPinIndex;
  54. // Copy the input property info to the output property info
  55. ::RtlCopyMemory( pPinInfo, pSpd->Property, sizeof( KSPROPERTY_CROSSBAR_PININFO_S));
  56. nPinIndex = pPinInfo->Index;
  57. if( pPinInfo->Direction == KSPIN_DATAFLOW_IN)
  58. {
  59. // input pin info is required
  60. if ( nPinIndex < m_nNumberOfVideoInputs + m_nNumberOfAudioInputs)
  61. {
  62. pPinInfo->RelatedPinIndex = m_pXBarInputPinsInfo[nPinIndex].nRelatedPinNumber;
  63. pPinInfo->PinType = m_pXBarInputPinsInfo[nPinIndex].AudioVideoPinType;
  64. pPinInfo->Medium = * m_pXBarInputPinsInfo[nPinIndex].pMedium;
  65. }
  66. else
  67. return ( FALSE);
  68. }
  69. else
  70. {
  71. // output pin info is required
  72. if ( nPinIndex < m_nNumberOfVideoOutputs + m_nNumberOfAudioOutputs)
  73. {
  74. pPinInfo->RelatedPinIndex = m_pXBarOutputPinsInfo[nPinIndex].nRelatedPinNumber;
  75. pPinInfo->PinType = m_pXBarOutputPinsInfo[nPinIndex].AudioVideoPinType;
  76. pPinInfo->Medium = * m_pXBarOutputPinsInfo[nPinIndex].pMedium;
  77. }
  78. else
  79. return ( FALSE);
  80. }
  81. }
  82. pSrb->ActualBytesTransferred = sizeof( KSPROPERTY_CROSSBAR_PININFO_S);
  83. break;
  84. case KSPROPERTY_CROSSBAR_CAN_ROUTE:
  85. ASSERT( pSpd->PropertyOutputSize >= sizeof( KSPROPERTY_CROSSBAR_ROUTE_S));
  86. {
  87. PKSPROPERTY_CROSSBAR_ROUTE_S pRouteInfo = ( PKSPROPERTY_CROSSBAR_ROUTE_S)pSpd->PropertyInfo;
  88. ULONG nInputPin, nOutputPin;
  89. int nAudioSource;
  90. // Copy the input property info to the output property info
  91. ::RtlCopyMemory( pRouteInfo, pSpd->Property, sizeof( KSPROPERTY_CROSSBAR_ROUTE_S));
  92. nInputPin = pRouteInfo->IndexInputPin;
  93. nOutputPin = pRouteInfo->IndexOutputPin;
  94. if( nInputPin != -1)
  95. {
  96. if(( nInputPin < ( m_nNumberOfVideoInputs + m_nNumberOfAudioInputs)) &&
  97. ( nOutputPin < ( m_nNumberOfVideoOutputs + m_nNumberOfAudioOutputs)))
  98. {
  99. // both input and output pins index are valid
  100. if(( m_pXBarInputPinsInfo[nInputPin].AudioVideoPinType <= KS_PhysConn_Video_SCART) &&
  101. ( m_pXBarOutputPinsInfo[nOutputPin].AudioVideoPinType <= KS_PhysConn_Video_SCART))
  102. {
  103. // Video pins connection is required
  104. pRouteInfo->CanRoute = ( m_pXBarInputPinsInfo[nInputPin].AudioVideoPinType ==
  105. m_pXBarOutputPinsInfo[nOutputPin].AudioVideoPinType);
  106. }
  107. else // is video pins connection required?
  108. {
  109. if(( m_pXBarInputPinsInfo[nInputPin].AudioVideoPinType >= KS_PhysConn_Audio_Tuner) &&
  110. ( m_pXBarOutputPinsInfo[nOutputPin].AudioVideoPinType >= KS_PhysConn_Audio_Tuner))
  111. {
  112. // Audio pins connection is required
  113. switch( m_pXBarInputPinsInfo[nInputPin].AudioVideoPinType)
  114. {
  115. case KS_PhysConn_Audio_Line:
  116. nAudioSource = AUDIOSOURCE_LINEIN;
  117. break;
  118. case KS_PhysConn_Audio_Tuner:
  119. nAudioSource = AUDIOSOURCE_TVAUDIO;
  120. break;
  121. default:
  122. TRAP;
  123. return( FALSE);
  124. }
  125. pRouteInfo->CanRoute = m_CATIConfiguration.CanConnectAudioSource( nAudioSource);
  126. }
  127. else
  128. // mixed video - audio connection is required
  129. pRouteInfo->CanRoute = FALSE;
  130. }
  131. }
  132. else // are the pins index valid?
  133. {
  134. // either input and output pins index is invalid
  135. TRAP;
  136. OutputDebugError(( "CWDMAVXBar:Get...CAN_ROUTE() InPin = %d, OutPin = %d\n",
  137. nInputPin, nOutputPin));
  138. return( FALSE);
  139. }
  140. }
  141. else // if( nInputPin != -1)
  142. {
  143. // There is a new notion of nInputPin = -1. It's valid only for Audio muting
  144. if( nOutputPin < ( m_nNumberOfVideoOutputs + m_nNumberOfAudioOutputs))
  145. {
  146. if( m_pXBarOutputPinsInfo[nOutputPin].AudioVideoPinType >= KS_PhysConn_Audio_Tuner)
  147. pRouteInfo->CanRoute = m_CATIConfiguration.CanConnectAudioSource( AUDIOSOURCE_MUTE);
  148. else
  149. // we support muting for Audio output pin only
  150. pRouteInfo->CanRoute = FALSE;
  151. }
  152. else
  153. {
  154. // output pin index is invalid
  155. TRAP;
  156. OutputDebugError(( "CWDMAVXBar:Get...CAN_ROUTE() InPin = %d, OutPin = %d\n",
  157. nInputPin, nOutputPin));
  158. return( FALSE);
  159. }
  160. }
  161. }
  162. pSrb->ActualBytesTransferred = sizeof( KSPROPERTY_CROSSBAR_ROUTE_S);
  163. break;
  164. case KSPROPERTY_CROSSBAR_ROUTE:
  165. ASSERT( pSpd->PropertyOutputSize >= sizeof( KSPROPERTY_CROSSBAR_ROUTE_S));
  166. {
  167. PKSPROPERTY_CROSSBAR_ROUTE_S pRouteInfo = ( PKSPROPERTY_CROSSBAR_ROUTE_S)pSpd->PropertyInfo;
  168. ULONG nOutputPin;
  169. // Copy the input property info to the output property info
  170. ::RtlCopyMemory( pRouteInfo, pSpd->Property, sizeof( KSPROPERTY_CROSSBAR_ROUTE_S));
  171. nOutputPin = pRouteInfo->IndexOutputPin;
  172. if( nOutputPin < m_nNumberOfVideoOutputs + m_nNumberOfAudioOutputs)
  173. pRouteInfo->IndexInputPin = m_pXBarOutputPinsInfo[nOutputPin].nConnectedToPin;
  174. else
  175. {
  176. TRAP;
  177. OutputDebugError(( "CWDMAVXBar:Get...ROUTE() OutPin = %d\n",
  178. nOutputPin));
  179. pRouteInfo->IndexInputPin = -1;
  180. }
  181. }
  182. pSrb->ActualBytesTransferred = sizeof( KSPROPERTY_CROSSBAR_ROUTE_S);
  183. break;
  184. default:
  185. TRAP;
  186. return( FALSE);
  187. }
  188. return( TRUE);
  189. }
  190. /*^^*
  191. * AdapterSetProperty()
  192. * Purpose : Called when SRB_GET_PROPERTY SRB is received.
  193. *
  194. * Inputs : PHW_STREAM_REQUEST_BLOCK pSrb : pointer to the current Srb
  195. *
  196. * Outputs : BOOL : returns FALSE, if it is not a XBar property
  197. * it also sets the required property
  198. * Author : IKLEBANOV
  199. *^^*/
  200. BOOL CWDMAVXBar::AdapterSetProperty( PHW_STREAM_REQUEST_BLOCK pSrb)
  201. {
  202. PSTREAM_PROPERTY_DESCRIPTOR pSpd = pSrb->CommandData.PropertyInfo;
  203. ULONG uiPropertyId = pSpd->Property->Id; // index of the property
  204. BOOL bResult = TRUE;
  205. if( !::IsEqualGUID( ( const struct _GUID &)PROPSETID_VIDCAP_CROSSBAR, ( const struct _GUID &)pSpd->Property->Set))
  206. return( FALSE);
  207. OutputDebugInfo(( "CWDMAVXBar:AdapterSetProperty() Id = %d\n", uiPropertyId));
  208. switch( uiPropertyId)
  209. {
  210. case KSPROPERTY_CROSSBAR_ROUTE:
  211. ASSERT( pSpd->PropertyOutputSize >= sizeof( KSPROPERTY_CROSSBAR_ROUTE_S));
  212. {
  213. PKSPROPERTY_CROSSBAR_ROUTE_S pRouteInfo = ( PKSPROPERTY_CROSSBAR_ROUTE_S)pSpd->PropertyInfo;
  214. ULONG nInputPin, nOutputPin;
  215. int nAudioSource;
  216. // Copy the input property info to the output property info
  217. ::RtlCopyMemory( pRouteInfo, pSpd->Property, sizeof( KSPROPERTY_CROSSBAR_ROUTE_S));
  218. nInputPin = pRouteInfo->IndexInputPin;
  219. nOutputPin = pRouteInfo->IndexOutputPin;
  220. if( nInputPin != -1)
  221. {
  222. if(( nInputPin < ( m_nNumberOfVideoInputs + m_nNumberOfAudioInputs)) &&
  223. ( nOutputPin < ( m_nNumberOfVideoOutputs + m_nNumberOfAudioOutputs)))
  224. {
  225. // both input and output pins index are valid
  226. if(( m_pXBarInputPinsInfo[nInputPin].AudioVideoPinType <= KS_PhysConn_Video_SCART) &&
  227. ( m_pXBarOutputPinsInfo[nOutputPin].AudioVideoPinType <= KS_PhysConn_Video_SCART))
  228. {
  229. // Video pins connection is required
  230. pRouteInfo->CanRoute = ( m_pXBarInputPinsInfo[nInputPin].AudioVideoPinType ==
  231. m_pXBarOutputPinsInfo[nOutputPin].AudioVideoPinType);
  232. }
  233. else // is video pins connection required?
  234. {
  235. if(( m_pXBarInputPinsInfo[nInputPin].AudioVideoPinType >= KS_PhysConn_Audio_Tuner) &&
  236. ( m_pXBarOutputPinsInfo[nOutputPin].AudioVideoPinType >= KS_PhysConn_Audio_Tuner))
  237. {
  238. // Audio pins connection is required
  239. switch( m_pXBarInputPinsInfo[nInputPin].AudioVideoPinType)
  240. {
  241. case KS_PhysConn_Audio_Line:
  242. nAudioSource = AUDIOSOURCE_LINEIN;
  243. break;
  244. case KS_PhysConn_Audio_Tuner:
  245. nAudioSource = AUDIOSOURCE_TVAUDIO;
  246. break;
  247. default:
  248. TRAP;
  249. return( FALSE);
  250. }
  251. if( m_pXBarOutputPinsInfo[nOutputPin].nConnectedToPin == nInputPin)
  252. // the connection has been made already
  253. pRouteInfo->CanRoute = TRUE;
  254. else // are Audio pins connected already?
  255. {
  256. // the connection has to be made
  257. pRouteInfo->CanRoute = m_CATIConfiguration.CanConnectAudioSource( nAudioSource);
  258. if( pRouteInfo->CanRoute)
  259. {
  260. if( m_CATIConfiguration.ConnectAudioSource( m_pI2CScript,
  261. nAudioSource))
  262. {
  263. // update driver state after routing
  264. m_pXBarOutputPinsInfo[nOutputPin].nConnectedToPin = nInputPin;
  265. m_pXBarOutputPinsInfo[nOutputPin].nRelatedPinNumber = m_pXBarInputPinsInfo[nInputPin].nRelatedPinNumber;
  266. }
  267. else
  268. bResult = FALSE;
  269. }
  270. }
  271. }
  272. else
  273. // mixed audio - video connection is required, fail
  274. pRouteInfo->CanRoute = FALSE;
  275. }
  276. }
  277. else // are the pins index valid?
  278. {
  279. // either input and output pins index is invalid
  280. TRAP;
  281. OutputDebugError(( "CWDMAVXBar:Set...ROUTE() In = %d, Out = %d\n",
  282. nInputPin, nOutputPin));
  283. return( FALSE);
  284. }
  285. }
  286. else // if( nInputPin != -1)
  287. {
  288. // There is a new notion of nInputPin = -1. It's valid only for Audio muting
  289. if( nOutputPin < ( m_nNumberOfVideoOutputs + m_nNumberOfAudioOutputs))
  290. {
  291. if( m_pXBarOutputPinsInfo[nOutputPin].AudioVideoPinType >= KS_PhysConn_Audio_Tuner)
  292. if( m_pXBarOutputPinsInfo[nOutputPin].nConnectedToPin == nInputPin)
  293. // the connection has been made already
  294. pRouteInfo->CanRoute = TRUE;
  295. else // are Audio pins connected already?
  296. {
  297. // the connection has to be made
  298. pRouteInfo->CanRoute = m_CATIConfiguration.CanConnectAudioSource( AUDIOSOURCE_MUTE);
  299. if( pRouteInfo->CanRoute)
  300. {
  301. if( m_CATIConfiguration.ConnectAudioSource( m_pI2CScript,
  302. AUDIOSOURCE_MUTE))
  303. // update driver state after routing
  304. m_pXBarOutputPinsInfo[nOutputPin].nConnectedToPin = nInputPin;
  305. else
  306. bResult = FALSE;
  307. }
  308. }
  309. else
  310. // we support muting for Audio output pin only
  311. pRouteInfo->CanRoute = FALSE;
  312. }
  313. else
  314. {
  315. // output pin index is invalid
  316. TRAP;
  317. OutputDebugError(( "CWDMAVXBar:Get...CAN_ROUTE() InPin = %d, OutPin = %d\n",
  318. nInputPin, nOutputPin));
  319. return( FALSE);
  320. }
  321. }
  322. }
  323. pSrb->ActualBytesTransferred = sizeof( KSPROPERTY_CROSSBAR_ROUTE_S);
  324. break;
  325. default:
  326. TRAP;
  327. return( FALSE);
  328. }
  329. return( bResult);
  330. }
  331. /*^^*
  332. * SetWDMAVXBarKSTopology()
  333. * Purpose : Sets the KSTopology structure
  334. * Called during CWDMAVXBar class construction time.
  335. *
  336. * Inputs : none
  337. *
  338. * Outputs : none
  339. * Author : IKLEBANOV
  340. *^^*/
  341. void CWDMAVXBar::SetWDMAVXBarKSTopology( void)
  342. {
  343. GUID wdmXBarTopologyCategory[] =
  344. {
  345. STATIC_KSCATEGORY_CROSSBAR
  346. };
  347. ::RtlCopyMemory( &m_wdmAVXBarTopologyCategory, wdmXBarTopologyCategory, sizeof( wdmXBarTopologyCategory));
  348. m_wdmAVXBarTopology.CategoriesCount = 1;
  349. m_wdmAVXBarTopology.Categories = &m_wdmAVXBarTopologyCategory;
  350. m_wdmAVXBarTopology.TopologyNodesCount = 0;
  351. m_wdmAVXBarTopology.TopologyNodes = NULL;
  352. m_wdmAVXBarTopology.TopologyConnectionsCount = 0;
  353. m_wdmAVXBarTopology.TopologyConnections = NULL;
  354. }
  355. /*^^*
  356. * SetWDMAVXBarProperties()
  357. * Purpose : Sets the KSProperty structures array
  358. * Called during CWDMAVXBar class construction time.
  359. *
  360. * Inputs : none
  361. *
  362. * Outputs : none
  363. * Author : IKLEBANOV
  364. *^^*/
  365. void CWDMAVXBar::SetWDMAVXBarKSProperties( void)
  366. {
  367. DEFINE_KSPROPERTY_TABLE( wdmAVXBarPropertiesCrossBar)
  368. {
  369. DEFINE_KSPROPERTY_ITEM
  370. (
  371. KSPROPERTY_CROSSBAR_CAPS, // 1
  372. TRUE, // GetSupported or Handler
  373. sizeof(KSPROPERTY_CROSSBAR_CAPS_S), // MinProperty
  374. sizeof(KSPROPERTY_CROSSBAR_CAPS_S), // MinData
  375. FALSE, // SetSupported or Handler
  376. NULL, // Values
  377. 0, // RelationsCount
  378. NULL, // Relations
  379. NULL, // SupportHandler
  380. sizeof( ULONG) // SerializedSize
  381. ),
  382. DEFINE_KSPROPERTY_ITEM
  383. (
  384. KSPROPERTY_CROSSBAR_PININFO, // 1
  385. TRUE, // GetSupported or Handler
  386. sizeof(KSPROPERTY_CROSSBAR_PININFO_S), // MinProperty
  387. sizeof(KSPROPERTY_CROSSBAR_PININFO_S), // MinData
  388. FALSE, // SetSupported or Handler
  389. NULL, // Values
  390. 0, // RelationsCount
  391. NULL, // Relations
  392. NULL, // SupportHandler
  393. 0 // SerializedSize
  394. ),
  395. DEFINE_KSPROPERTY_ITEM
  396. (
  397. KSPROPERTY_CROSSBAR_CAN_ROUTE, // 1
  398. TRUE, // GetSupported or Handler
  399. sizeof(KSPROPERTY_CROSSBAR_ROUTE_S), // MinProperty
  400. sizeof(KSPROPERTY_CROSSBAR_ROUTE_S), // MinData
  401. FALSE, // SetSupported or Handler
  402. NULL, // Values
  403. 0, // RelationsCount
  404. NULL, // Relations
  405. NULL, // SupportHandler
  406. sizeof( ULONG) // SerializedSize
  407. ),
  408. DEFINE_KSPROPERTY_ITEM
  409. (
  410. KSPROPERTY_CROSSBAR_ROUTE, // 1
  411. TRUE, // GetSupported or Handler
  412. sizeof(KSPROPERTY_CROSSBAR_ROUTE_S), // MinProperty
  413. sizeof(KSPROPERTY_CROSSBAR_ROUTE_S), // MinData
  414. TRUE, // SetSupported or Handler
  415. NULL, // Values
  416. 0, // RelationsCount
  417. NULL, // Relations
  418. NULL, // SupportHandler
  419. sizeof( ULONG) // SerializedSize
  420. )
  421. };
  422. DEFINE_KSPROPERTY_SET_TABLE( wdmAVXBarPropertySet)
  423. {
  424. DEFINE_KSPROPERTY_SET
  425. (
  426. &PROPSETID_VIDCAP_CROSSBAR, // Set
  427. KSPROPERTIES_AVXBAR_NUMBER_CROSSBAR, // PropertiesCount
  428. m_wdmAVXBarPropertiesCrossBar, // PropertyItems
  429. 0, // FastIoCount
  430. NULL // FastIoTable
  431. )
  432. };
  433. ::RtlCopyMemory( m_wdmAVXBarPropertiesCrossBar, wdmAVXBarPropertiesCrossBar, sizeof( wdmAVXBarPropertiesCrossBar));
  434. ::RtlCopyMemory( &m_wdmAVXBarPropertySet, wdmAVXBarPropertySet, sizeof( wdmAVXBarPropertySet));
  435. }
  436.