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.

506 lines
13 KiB

  1. //==========================================================================;
  2. //
  3. // TSndHdw.CPP
  4. // WDM TVAudio MiniDriver.
  5. // AIW / AIWPro hardware platform.
  6. // WDM Properties required hardware settings.
  7. // Copyright (c) 1996 - 1997 ATI Technologies Inc. All Rights Reserved.
  8. //
  9. // $Date: 03 Jun 1999 13:40:00 $
  10. // $Revision: 1.7 $
  11. // $Author: tom $
  12. //
  13. //==========================================================================;
  14. extern "C"
  15. {
  16. #include "strmini.h"
  17. #include "ksmedia.h"
  18. #include "wdmdebug.h"
  19. }
  20. #include "wdmdrv.h"
  21. #include "atitvsnd.h"
  22. #include "aticonfg.h"
  23. /*^^*
  24. * GetAudioOperationMode()
  25. * Purpose : Called when SRB_GET_PROPERTY SRB SetMode is received. Sets the requested
  26. * audio operation mode ( Stereo/SAP). The function will always try to carry the
  27. * request on in asynchronous mode. It fails, it will response synchronous mode
  28. * of execution.
  29. *
  30. * Inputs : PULONG pulMode : the pointer to return current Mode
  31. *
  32. * Outputs : BOOL : returns FALSE, if it is not a XBar property
  33. * it also sets the required property
  34. * Author : IKLEBANOV
  35. *^^*/
  36. BOOL CWDMTVAudio::GetAudioOperationMode( PULONG pulAudioMode)
  37. {
  38. I2CPacket i2cPacket;
  39. UCHAR uchReadValue;
  40. UCHAR uchWriteValue;
  41. BOOL bResult, bStereoIndicator, bSAPIndicator;
  42. UCHAR uchRead16Value[2];
  43. UCHAR uchWrite16Value[3];
  44. if( pulAudioMode == NULL)
  45. return( FALSE);
  46. switch( m_uiAudioConfiguration)
  47. {
  48. case ATI_AUDIO_CONFIG_1:
  49. case ATI_AUDIO_CONFIG_5:
  50. // stereo indication is read back from I2C expander
  51. if( m_CATIConfiguration.GetTVAudioSignalProperties( m_pI2CScript,
  52. &bStereoIndicator,
  53. &bSAPIndicator))
  54. {
  55. // language A and mono alsways present
  56. *pulAudioMode = KS_TVAUDIO_MODE_LANG_A | KS_TVAUDIO_MODE_MONO;
  57. if( bStereoIndicator)
  58. *pulAudioMode |= KS_TVAUDIO_MODE_STEREO;
  59. if( bSAPIndicator)
  60. *pulAudioMode |= KS_TVAUDIO_MODE_LANG_B;
  61. bResult = TRUE;
  62. }
  63. else
  64. bResult = FALSE;
  65. break;
  66. case ATI_AUDIO_CONFIG_2:
  67. case ATI_AUDIO_CONFIG_7:
  68. // Signal properties are read back from the Audio chip itself
  69. uchWriteValue = 0; // register 0 should be read
  70. i2cPacket.uchChipAddress = m_uchAudioChipAddress;
  71. i2cPacket.puchWriteBuffer = &uchWriteValue;
  72. i2cPacket.puchReadBuffer = &uchReadValue;
  73. i2cPacket.cbWriteCount = 1;
  74. i2cPacket.cbReadCount = 1;
  75. i2cPacket.usFlags = I2COPERATION_READ;
  76. m_pI2CScript->PerformI2CPacketOperation( &i2cPacket);
  77. if( i2cPacket.uchI2CResult == I2C_STATUS_NOERROR)
  78. {
  79. // language A and mono alsways present
  80. *pulAudioMode = KS_TVAUDIO_MODE_LANG_A | KS_TVAUDIO_MODE_MONO;
  81. if( uchReadValue & AUDIO_TDA9850_Indicator_Stereo)
  82. *pulAudioMode |= KS_TVAUDIO_MODE_STEREO;
  83. if( uchReadValue & AUDIO_TDA9850_Indicator_SAP)
  84. *pulAudioMode |= KS_TVAUDIO_MODE_LANG_B;
  85. bResult = TRUE;
  86. }
  87. else
  88. bResult = FALSE;
  89. break;
  90. case ATI_AUDIO_CONFIG_3:
  91. case ATI_AUDIO_CONFIG_4:
  92. // Stereo nor SAP are supported
  93. *pulAudioMode = KS_TVAUDIO_MODE_MONO;
  94. bResult = TRUE;
  95. break;
  96. case ATI_AUDIO_CONFIG_6:
  97. // Signal properties are read back from the Audio chip itself
  98. i2cPacket.uchChipAddress = m_uchAudioChipAddress;
  99. i2cPacket.puchWriteBuffer = NULL;
  100. i2cPacket.puchReadBuffer = &uchReadValue;
  101. i2cPacket.cbWriteCount = 0;
  102. i2cPacket.cbReadCount = 1;
  103. i2cPacket.usFlags = I2COPERATION_READ;
  104. m_pI2CScript->PerformI2CPacketOperation( &i2cPacket);
  105. if( i2cPacket.uchI2CResult == I2C_STATUS_NOERROR)
  106. {
  107. // mono alsways present
  108. *pulAudioMode = KS_TVAUDIO_MODE_MONO;
  109. if( uchReadValue & AUDIO_TDA9851_Indicator_Stereo)
  110. *pulAudioMode |= KS_TVAUDIO_MODE_STEREO;
  111. bResult = TRUE;
  112. }
  113. else
  114. bResult = FALSE;
  115. break;
  116. case ATI_AUDIO_CONFIG_8:
  117. i2cPacket.uchChipAddress = m_uchAudioChipAddress;
  118. i2cPacket.puchWriteBuffer = uchWrite16Value;
  119. i2cPacket.puchReadBuffer = uchRead16Value;
  120. i2cPacket.cbWriteCount = 3;
  121. i2cPacket.cbReadCount = 2;
  122. i2cPacket.usFlags = I2COPERATION_READ;
  123. uchWrite16Value[0] = 0x11;
  124. uchWrite16Value[1] = 0x02;
  125. uchWrite16Value[2] = 0x00;
  126. bResult = m_pI2CScript->PerformI2CPacketOperation(&i2cPacket);
  127. if(bResult)
  128. {
  129. if( i2cPacket.uchI2CResult != I2CSCRIPT_NOERROR)
  130. return(FALSE);
  131. }
  132. else
  133. return(FALSE);
  134. // language A and mono alsways present
  135. *pulAudioMode = KS_TVAUDIO_MODE_LANG_A | KS_TVAUDIO_MODE_MONO;
  136. //Determine STEREO/SAP
  137. if(uchRead16Value[0] & 0x40)
  138. *pulAudioMode |= KS_TVAUDIO_MODE_LANG_B;
  139. if(uchRead16Value[1] & 0x01)
  140. *pulAudioMode |= KS_TVAUDIO_MODE_STEREO;
  141. break;
  142. default:
  143. bResult = FALSE;
  144. break;
  145. }
  146. return( bResult);
  147. }
  148. /*^^*
  149. * SetAudioOperationMode()
  150. * Purpose : Called when SRB_SET_PROPERTY SRB SetMode is received. Sets the requested
  151. * audio operation mode ( Stereo/SAP). The function will always try to carry the
  152. * request on in asynchronous mode. It fails, it will response synchronous mode
  153. * of execution.
  154. *
  155. * Inputs : ULONG ulModeToSet : the requested mode to set
  156. *
  157. * Outputs : BOOL : returns FALSE, if it is not a XBar property
  158. * it also sets the required property
  159. * Author : IKLEBANOV
  160. *^^*/
  161. BOOL CWDMTVAudio::SetAudioOperationMode( ULONG ulModeToSet)
  162. {
  163. I2CPacket i2cPacket;
  164. USHORT cbWriteLength;
  165. UCHAR auchI2CBuffer[2];
  166. UCHAR uchDeviceMode = 0;
  167. UCHAR uchWrite16Value[5];
  168. BOOL bResult;
  169. switch( m_uiAudioConfiguration)
  170. {
  171. case ATI_AUDIO_CONFIG_5:
  172. // TEA5571
  173. case ATI_AUDIO_CONFIG_1:
  174. // TEA5582 can not be forced in mono mode; nothing to do
  175. m_ulTVAudioMode = ulModeToSet;
  176. return( TRUE);
  177. case ATI_AUDIO_CONFIG_2:
  178. case ATI_AUDIO_CONFIG_7:
  179. // TDA9850
  180. if( ulModeToSet & KS_TVAUDIO_MODE_STEREO)
  181. uchDeviceMode |= AUDIO_TDA9850_Control_Stereo;
  182. if( ulModeToSet & KS_TVAUDIO_MODE_LANG_B)
  183. uchDeviceMode |= AUDIO_TDA9850_Control_SAP;
  184. auchI2CBuffer[0] = AUDIO_TDA9850_Reg_Control3;
  185. auchI2CBuffer[1] = uchDeviceMode;
  186. cbWriteLength = 2; // SubAddress + Control Register value
  187. break;
  188. case ATI_AUDIO_CONFIG_6:
  189. // TDA9851
  190. uchDeviceMode = TDA9851_AVL_ATTACK_730;
  191. if( ulModeToSet & KS_TVAUDIO_MODE_STEREO)
  192. uchDeviceMode |= AUDIO_TDA9851_Control_Stereo;
  193. auchI2CBuffer[0] = uchDeviceMode;
  194. cbWriteLength = 1; // Control Register value
  195. break;
  196. case ATI_AUDIO_CONFIG_8:
  197. if( ulModeToSet & KS_TVAUDIO_MODE_STEREO)
  198. {
  199. i2cPacket.uchChipAddress = m_uchAudioChipAddress;
  200. i2cPacket.cbReadCount = 0;
  201. i2cPacket.usFlags = I2COPERATION_WRITE;
  202. i2cPacket.puchWriteBuffer = uchWrite16Value;
  203. i2cPacket.cbWriteCount = 5;
  204. //SubAddr 0x10 Reg 0x30 Val 0x2003
  205. uchWrite16Value[0] = 0x10;
  206. uchWrite16Value[1] = 0x00;
  207. uchWrite16Value[2] = 0x30;
  208. uchWrite16Value[3] = 0x20;
  209. #ifdef I2S_CAPTURE
  210. #pragma message ("\n!!! PAY ATTENTION: Driver has been build with ITT CHIP I2S CAPTURE CONFIGURED !!!\n")
  211. uchWrite16Value[4] = 0xe3;
  212. #else
  213. uchWrite16Value[4] = 0x03;
  214. #endif
  215. bResult = m_pI2CScript->PerformI2CPacketOperation( &i2cPacket);
  216. if(bResult)
  217. {
  218. if( i2cPacket.uchI2CResult != I2CSCRIPT_NOERROR)
  219. return(FALSE);
  220. }
  221. else
  222. return(FALSE);
  223. //SubAddr 0x10 Reg 0x20 Val 0x0020
  224. uchWrite16Value[0] = 0x10;
  225. uchWrite16Value[1] = 0x00;
  226. uchWrite16Value[2] = 0x20;
  227. uchWrite16Value[3] = 0x00;
  228. uchWrite16Value[4] = 0x20;
  229. bResult = m_pI2CScript->PerformI2CPacketOperation( &i2cPacket);
  230. if(bResult)
  231. {
  232. if( i2cPacket.uchI2CResult != I2CSCRIPT_NOERROR)
  233. return(FALSE);
  234. }
  235. else
  236. return(FALSE);
  237. //SubAddr 0x12 Reg 0xE Val 0x2403
  238. uchWrite16Value[0] = 0x12;
  239. uchWrite16Value[1] = 0x00;
  240. uchWrite16Value[2] = 0x0e;
  241. uchWrite16Value[3] = 0x24;
  242. uchWrite16Value[4] = 0x03;
  243. bResult = m_pI2CScript->PerformI2CPacketOperation( &i2cPacket);
  244. if(bResult)
  245. {
  246. if( i2cPacket.uchI2CResult != I2CSCRIPT_NOERROR)
  247. return(FALSE);
  248. }
  249. else
  250. return(FALSE);
  251. //SubAddr 0x12 Reg 0x08 Val 0x0320
  252. uchWrite16Value[0] = 0x12;
  253. uchWrite16Value[1] = 0x00;
  254. uchWrite16Value[2] = 0x08;
  255. uchWrite16Value[3] = 0x03;
  256. uchWrite16Value[4] = 0x20;
  257. bResult = m_pI2CScript->PerformI2CPacketOperation( &i2cPacket);
  258. if(bResult)
  259. {
  260. if( i2cPacket.uchI2CResult != I2CSCRIPT_NOERROR)
  261. return(FALSE);
  262. }
  263. else
  264. return(FALSE);
  265. return(TRUE);
  266. }
  267. if(ulModeToSet & KS_TVAUDIO_MODE_MONO)
  268. {
  269. if(ulModeToSet & KS_TVAUDIO_MODE_LANG_A)
  270. {
  271. i2cPacket.uchChipAddress = m_uchAudioChipAddress;
  272. i2cPacket.cbReadCount = 0;
  273. i2cPacket.usFlags = I2COPERATION_WRITE;
  274. i2cPacket.puchWriteBuffer = uchWrite16Value;
  275. i2cPacket.cbWriteCount = 5;
  276. //SubAddr 0x10 Reg 0x30 Val 0x2003
  277. uchWrite16Value[0] = 0x10;
  278. uchWrite16Value[1] = 0x00;
  279. uchWrite16Value[2] = 0x30;
  280. uchWrite16Value[3] = 0x20;
  281. #ifdef I2S_CAPTURE
  282. #pragma message ("\n!!! PAY ATTENTION: Driver has been build with ITT CHIP I2S CAPTURE CONFIGURED !!!\n")
  283. uchWrite16Value[4] = 0xe3;
  284. #else
  285. uchWrite16Value[4] = 0x03;
  286. #endif
  287. bResult = m_pI2CScript->PerformI2CPacketOperation( &i2cPacket);
  288. if(bResult)
  289. {
  290. if( i2cPacket.uchI2CResult != I2CSCRIPT_NOERROR)
  291. return(FALSE);
  292. }
  293. else
  294. return(FALSE);
  295. //SubAddr 0x10 Reg 0x20 Val 0x0020
  296. uchWrite16Value[0] = 0x10;
  297. uchWrite16Value[1] = 0x00;
  298. uchWrite16Value[2] = 0x20;
  299. uchWrite16Value[3] = 0x00;
  300. uchWrite16Value[4] = 0x20;
  301. bResult = m_pI2CScript->PerformI2CPacketOperation( &i2cPacket);
  302. if(bResult)
  303. {
  304. if( i2cPacket.uchI2CResult != I2CSCRIPT_NOERROR)
  305. return(FALSE);
  306. }
  307. else
  308. return(FALSE);
  309. //SubAddr 0x12 Reg 0xE Val 0x2403
  310. uchWrite16Value[0] = 0x12;
  311. uchWrite16Value[1] = 0x00;
  312. uchWrite16Value[2] = 0x0e;
  313. uchWrite16Value[3] = 0x24;
  314. uchWrite16Value[4] = 0x03;
  315. bResult = m_pI2CScript->PerformI2CPacketOperation( &i2cPacket);
  316. if(bResult)
  317. {
  318. if( i2cPacket.uchI2CResult != I2CSCRIPT_NOERROR)
  319. return(FALSE);
  320. }
  321. else
  322. return(FALSE);
  323. //SubAddr 0x12 Reg 0x08 Val 0x0330
  324. uchWrite16Value[0] = 0x12;
  325. uchWrite16Value[1] = 0x00;
  326. uchWrite16Value[2] = 0x08;
  327. uchWrite16Value[3] = 0x03;
  328. uchWrite16Value[4] = 0x30; //Mono
  329. bResult = m_pI2CScript->PerformI2CPacketOperation( &i2cPacket);
  330. if(bResult)
  331. {
  332. if( i2cPacket.uchI2CResult != I2CSCRIPT_NOERROR)
  333. return(FALSE);
  334. }
  335. else
  336. return(FALSE);
  337. return(TRUE);
  338. }
  339. if( ulModeToSet & KS_TVAUDIO_MODE_LANG_B)
  340. {
  341. i2cPacket.uchChipAddress = m_uchAudioChipAddress;
  342. i2cPacket.cbReadCount = 0;
  343. i2cPacket.usFlags = I2COPERATION_WRITE;
  344. i2cPacket.puchWriteBuffer = uchWrite16Value;
  345. i2cPacket.cbWriteCount = 5;
  346. //SubAddr 0x10 Reg 0x30 Val 0x2003
  347. uchWrite16Value[0] = 0x10;
  348. uchWrite16Value[1] = 0x00;
  349. uchWrite16Value[2] = 0x30;
  350. uchWrite16Value[3] = 0x20;
  351. #ifdef I2S_CAPTURE
  352. #pragma message ("\n!!! PAY ATTENTION: Driver has been build with ITT CHIP I2S CAPTURE CONFIGURED !!!\n")
  353. uchWrite16Value[4] = 0xe3;
  354. #else
  355. uchWrite16Value[4] = 0x03;
  356. #endif
  357. bResult = m_pI2CScript->PerformI2CPacketOperation( &i2cPacket);
  358. if(bResult)
  359. {
  360. if( i2cPacket.uchI2CResult != I2CSCRIPT_NOERROR)
  361. return(FALSE);
  362. }
  363. else
  364. return(FALSE);
  365. //SubAddr 0x10 Reg 0x20 Val 0x0021
  366. uchWrite16Value[0] = 0x10;
  367. uchWrite16Value[1] = 0x00;
  368. uchWrite16Value[2] = 0x20;
  369. uchWrite16Value[3] = 0x00;
  370. uchWrite16Value[4] = 0x21;
  371. bResult = m_pI2CScript->PerformI2CPacketOperation( &i2cPacket);
  372. if(bResult)
  373. {
  374. if( i2cPacket.uchI2CResult != I2CSCRIPT_NOERROR)
  375. return(FALSE);
  376. }
  377. else
  378. return(FALSE);
  379. //SubAddr 0x12 Reg 0xE Val 0x2400
  380. uchWrite16Value[0] = 0x12;
  381. uchWrite16Value[1] = 0x00;
  382. uchWrite16Value[2] = 0x0e;
  383. uchWrite16Value[3] = 0x24;
  384. uchWrite16Value[4] = 0x00;
  385. bResult = m_pI2CScript->PerformI2CPacketOperation( &i2cPacket);
  386. if(bResult)
  387. {
  388. if( i2cPacket.uchI2CResult != I2CSCRIPT_NOERROR)
  389. return(FALSE);
  390. }
  391. else
  392. return(FALSE);
  393. //SubAddr 0x12 Reg 0x08 Val 0x0110
  394. uchWrite16Value[0] = 0x12;
  395. uchWrite16Value[1] = 0x00;
  396. uchWrite16Value[2] = 0x08;
  397. uchWrite16Value[3] = 0x01;
  398. uchWrite16Value[4] = 0x10;
  399. bResult = m_pI2CScript->PerformI2CPacketOperation( &i2cPacket);
  400. if(bResult)
  401. {
  402. if( i2cPacket.uchI2CResult != I2CSCRIPT_NOERROR)
  403. return(FALSE);
  404. }
  405. else
  406. return(FALSE);
  407. return(TRUE);
  408. }
  409. }
  410. return(FALSE);
  411. default:
  412. return( FALSE);
  413. }
  414. i2cPacket.uchChipAddress = m_uchAudioChipAddress;
  415. i2cPacket.cbReadCount = 0;
  416. i2cPacket.cbWriteCount = cbWriteLength;
  417. i2cPacket.puchReadBuffer = NULL;
  418. i2cPacket.puchWriteBuffer = auchI2CBuffer;
  419. i2cPacket.usFlags = 0;
  420. // synchronous mode of operation
  421. return( m_pI2CScript->PerformI2CPacketOperation( &i2cPacket));
  422. }