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.

825 lines
21 KiB

  1. // $Header: G:/SwDev/WDM/Video/bt848/rcs/Device.cpp 1.18 1998/05/13 14:44:33 tomz Exp $
  2. #include "device.h"
  3. #include "capmain.h"
  4. const I2C_Offset = 0x110;
  5. const GPIO_Cntl_Offset = 0x10D;
  6. const GPIO_OutputOffset = 0x118;
  7. const GPIO_DataOffset = 0x200;
  8. // Global functions/data exposing public class info to the "C" modules
  9. PsDevice *gpPsDevice = NULL;
  10. BYTE *gpjBaseAddr = NULL;
  11. VOID *gpHwDeviceExtension = NULL;
  12. DWORD GetSizeHwDeviceExtension( )
  13. {
  14. return ( sizeof( HW_DEVICE_EXTENSION ) + sizeof( PsDevice ));
  15. }
  16. DWORD GetSizeStreamEx( )
  17. {
  18. // return the size of the largest possible channel object
  19. DWORD dwMax = sizeof( VBIChannel );
  20. dwMax = max( dwMax, sizeof( AlterVideoChannel<VBIChannel> ));
  21. dwMax = max( dwMax, sizeof( InterVideoChannel ));
  22. DWORD dwReq = 2 * dwMax; // paired stuff has two of them together
  23. dwReq += sizeof( STREAMEX );
  24. return ( dwReq );
  25. }
  26. /* Function: GetDeviceExt
  27. * Purpose: Used in creation of risc programs to obtain physical addresses
  28. */
  29. PsDevice *GetCurrentDevice()
  30. {
  31. // This is only used for I2C stuff. Remove this ASAP.
  32. return gpPsDevice;
  33. }
  34. /* Function: SetCurrentDevice
  35. * Purpose: Remembers the currently active device
  36. * Input: PsDevice *
  37. * Output: None
  38. */
  39. void SetCurrentDevice( PsDevice *dev )
  40. {
  41. // This is only used for I2C stuff. Remove this ASAP.
  42. gpPsDevice = dev;
  43. }
  44. /* Function: GetBase
  45. * Purpose: Returns the base address of the currently active device
  46. * Input: None
  47. * Output: LPBYTE
  48. */
  49. BYTE *GetBase()
  50. {
  51. return gpjBaseAddr;
  52. }
  53. /* Function: SetBase
  54. * Purpose: Remembers the base address of the currently active device
  55. * Input: None
  56. * Output: LPBYTE
  57. */
  58. void SetBase(BYTE *base)
  59. {
  60. gpjBaseAddr = base;
  61. }
  62. PsDevice::PsDevice( DWORD dwBase ) :
  63. BaseAddress_( (LPBYTE)dwBase ),
  64. LastFreq_( 0 ),
  65. dwCurCookie_( 0 ),
  66. I2CAddr_( 0 ),
  67. xBar( PinTypes_ ),
  68. CaptureContrll_( xtals_ )
  69. {
  70. SetCurrentDevice ( this );
  71. for ( int i = 0; i < (sizeof(videochannels)/sizeof(videochannels[0])); i++ ) {
  72. videochannels [i] = 0;
  73. }
  74. I2CIsInitOK();
  75. #ifdef HARDWAREI2C
  76. I2CInitHWMode( 100000 ); // assume frequency = 100Khz
  77. #else
  78. I2CInitSWMode( 100000 ); // assume frequency = 100Khz
  79. I2CSWStart();
  80. I2CSWStop();
  81. #endif
  82. GPIOIsInitOK();
  83. DebugOut((0, "*** Base Address = %x\n", BaseAddress_));
  84. }
  85. PsDevice::~PsDevice()
  86. {
  87. for ( int i = 0; i < (sizeof(videochannels)/sizeof(videochannels[0])); i++ ) {
  88. VideoChannel *pvcTemp = videochannels [i];
  89. videochannels [i] = NULL;
  90. delete pvcTemp;
  91. }
  92. }
  93. /* Method: PsDevice::AddBuf
  94. * Purpose: Adds next buffer to be used to the queue
  95. * Input: VideoChan: VxDVideoChannel &
  96. * pBufAddr: PVOID - address of the next buffer
  97. * Output: None
  98. */
  99. void PsDevice::AddBuffer( VideoChannel &VideoChan, PHW_STREAM_REQUEST_BLOCK pSrb )
  100. {
  101. // bogus channel, bye-bye
  102. if ( !IsOurChannel( VideoChan ) ) {
  103. DebugOut((0, "PsDevice::Addbuffer - not our channel (pSrb=%x) (&VideoChan=%x)\n", pSrb, &VideoChan ) );
  104. return;
  105. }
  106. DebugOut((1, "PsDevice::Addbuffer - adding (pSrb=%x) (&VideoChan=%x)\n", pSrb, &VideoChan ) );
  107. VideoChan.AddSRB( pSrb );
  108. }
  109. void PsDevice::Start( VideoChannel &VidChan )
  110. {
  111. VidChan.Start();
  112. }
  113. void PsDevice::Pause( VideoChannel &VidChan )
  114. {
  115. *(DWORD*)(gpjBaseAddr+0x10c) &= ~3; // disable interrupts [TMZ] [!!!]
  116. // [TMZ] [!!!]
  117. for ( int i = 0; i < (sizeof(videochannels)/sizeof(videochannels[0])); i++ )
  118. {
  119. if ( videochannels[i] == &VidChan )
  120. {
  121. DebugOut((1, "'PsDevice::Pause called on videochannels[%d]\n", i));
  122. }
  123. }
  124. VidChan.Pause();
  125. }
  126. /* Method: PsDevice::Create
  127. * Purpose: Calls into the channel ( stream ) to create RISC programs for it.
  128. * Input: VideoChan: VxDVideoChannel &
  129. * Parms: StartParms &, parameters to create stream with
  130. * Output: ErrorCode
  131. */
  132. ErrorCode PsDevice::Create( VideoChannel &VidChan )
  133. {
  134. return VidChan.Create();
  135. }
  136. /* Method: PsDevice::Stop
  137. * Purpose: Adds next buffer to be used to the queue
  138. * Input: VideoChan: VxDVideoChannel &
  139. * Output: None
  140. */
  141. void PsDevice::Stop( VideoChannel &VidChan )
  142. {
  143. *(DWORD*)(gpjBaseAddr+0x10c) &= ~3; // disable interrupts [TMZ] [!!!]
  144. VidChan.Stop();
  145. }
  146. #if NEED_CLIPPING
  147. /* Method: PsDevice::SetClipping
  148. * Purpose: Propagates the call down a video channel
  149. * Input: VideoChan: VxDVideoChannel & - reference
  150. * dwData: DWORD - a pointer to RGNDATA in reality
  151. * Output: None
  152. */
  153. void PsDevice::SetClipping( VideoChannel &VidChan, const RGNDATA & rgnData )
  154. {
  155. if ( !rgnData.rdh.nCount )
  156. return;
  157. if ( FullSizeChannel_ ) {
  158. // have to decrese hight of all rectangles in half and decrease top in half
  159. unsigned i;
  160. for ( i = 0; i < rgnData.rdh.nCount; i++ ) {
  161. TRect *lpR = (TRect *)rgnData.Buffer + i;
  162. // make all even
  163. lpR->top++;
  164. lpR->top &= ~1;
  165. lpR->bottom++;
  166. lpR->bottom &= ~1;
  167. lpR->top /= 2;
  168. lpR->bottom /= 2;
  169. }
  170. FullSizeChannel_->SetClipping( rgnData );
  171. SlaveChannel_ ->SetClipping( rgnData );
  172. } else
  173. VidChan.SetClipping( rgnData );
  174. }
  175. #endif
  176. /* Method: PsDevice::IsVideoChannel
  177. * Purpose:
  178. */
  179. bool PsDevice::IsVideoChannel( VideoChannel &aChan )
  180. {
  181. return bool( &aChan == videochannels [VS_Field1] || &aChan == videochannels [VS_Field2] );
  182. }
  183. /* Method: PsDevice::IsVBIChannel
  184. * Purpose:
  185. */
  186. bool PsDevice::IsVBIChannel( VideoChannel &aChan )
  187. {
  188. return bool( &aChan == videochannels [VS_VBI1] || &aChan == videochannels [VS_VBI2] );
  189. }
  190. /* Method: PsDevice::IsOurChannel
  191. * Purpose: Verifies the channel
  192. * Input: aChan: VideoChannel &, reference to a channel
  193. * Output: true if our, false otherwise
  194. */
  195. bool PsDevice::IsOurChannel( VideoChannel &aChan )
  196. {
  197. return IsVideoChannel( aChan ) || IsVBIChannel( aChan );
  198. }
  199. /* Method: PsDevice::DoOpen
  200. * Purpose: This function performs opening of a video channel
  201. * Input: st: VideoStream, stream to open
  202. * Output: ErrorCode
  203. */
  204. ErrorCode PsDevice::DoOpen( VideoStream st )
  205. {
  206. DebugOut((1, "PsDevice::DoOpen(%d)\n", st));
  207. if ( !videochannels [st] )
  208. {
  209. DebugOut((1, " PsDevice::DoOpen(%d) failed - videochannel not created\n", st));
  210. return Fail;
  211. }
  212. videochannels [st]->Init( &CaptureContrll_ );
  213. if ( videochannels [st]->OpenChannel() != Success ) {
  214. DebugOut((1, " PsDevice::DoOpen(%d) failed - videochannel open failed\n", st));
  215. VideoChannel *pvcTemp = videochannels [st];
  216. videochannels [st] = NULL;
  217. delete pvcTemp;
  218. return Fail;
  219. }
  220. return Success;
  221. }
  222. /* Method: PsDevice::OpenChannel
  223. * Purpose: This function opens a channel requested by the capture driver
  224. * Input: hVM: VMHANDLE - handle of the VM making a call
  225. * pRegs: CLIENT_STRUCT * - pointer to the structure with VM's registers
  226. * Output: None
  227. */
  228. ErrorCode PsDevice::OpenChannel( PVOID pStrmEx, VideoStream st )
  229. {
  230. PVOID addr = &((PSTREAMEX)pStrmEx)->videochannelmem[0];
  231. ((PSTREAMEX)pStrmEx)->videochannel = addr;
  232. DebugOut((1, "PsDevice::OpenChannel(%x,%d)\n", addr, st));
  233. if ( videochannels [st] )
  234. {
  235. DebugOut((1, " PsDevice::OpenChannel(%x,%d) failed - already open\n", addr, st));
  236. return Fail;
  237. }
  238. videochannels[st] = new( addr ) VideoChannel( st );
  239. videochannels[st]->SetStrmEx( pStrmEx ) ;
  240. DebugOut((1, " PsDevice::OpenChannel(%x,%d), videochannels[%d] = %x\n", addr, st, st, videochannels[st]));
  241. return DoOpen( st );
  242. }
  243. /* Method: PsDevice::OpenInterChannel
  244. * Purpose: This function opens video channel that produces interleaved fields
  245. * Input: addr: PVOID, address for the palcement new
  246. * st: VideoStream, stream to open ( VBI or video )
  247. * Output: None
  248. */
  249. ErrorCode PsDevice::OpenInterChannel( PVOID pStrmEx, VideoStream st )
  250. {
  251. PVOID addr = &((PSTREAMEX)pStrmEx)->videochannelmem[0];
  252. ((PSTREAMEX)pStrmEx)->videochannel = addr;
  253. DebugOut((1, "PsDevice::OpenInterChannel(%x,%d)\n", addr, st));
  254. // only odd channel can be paired
  255. if ( !( st & 1 ) || videochannels [st] || videochannels [st-1] )
  256. {
  257. DebugOut((1, " PsDevice::OpenInterChannel(%x,%d) failed - stream not odd or already open\n", addr, st));
  258. return Fail;
  259. }
  260. if ( OpenChannel( (PBYTE)addr + sizeof( InterVideoChannel ), VideoStream( st - 1 ) ) == Success )
  261. {
  262. videochannels[st] = new( addr ) InterVideoChannel( st, *videochannels [st-1] );
  263. videochannels[st]->SetStrmEx( pStrmEx ) ;
  264. if ( DoOpen( st ) != Success )
  265. {
  266. DebugOut((1, " PsDevice::OpenInterChannel(%x,%d) failed - DoOpen failed\n", addr, st));
  267. CloseChannel( videochannels [st-1] );
  268. return Fail;
  269. }
  270. }
  271. else
  272. {
  273. DebugOut((1, " PsDevice::OpenInterChannel(%x,%d) failed - OpenChannel failed\n", addr, st));
  274. return Fail;
  275. }
  276. return Success;
  277. }
  278. /* Method: PsDevice::OpenAlterChannel
  279. * Purpose: This function opens video channel that produces alternating fields
  280. * Input: addr: PVOID, address for the palcement new
  281. * st: VideoStream, stream to open ( VBI or video )
  282. * Output: None
  283. */
  284. ErrorCode PsDevice::OpenAlterChannel( PVOID pStrmEx, VideoStream st )
  285. {
  286. PVOID addr = &((PSTREAMEX)pStrmEx)->videochannelmem[0];
  287. ((PSTREAMEX)pStrmEx)->videochannel = addr;
  288. DebugOut((1, "PsDevice::OpenAlterChannel(%x,%d)\n", addr, st));
  289. // only odd channel can be paired
  290. if ( !( st & 1 ) || videochannels [st] || videochannels [st-1] )
  291. {
  292. DebugOut((1, " PsDevice::OpenAlterChannel(%x,%d) failed - stream not odd or already open\n", addr, st));
  293. return Fail;
  294. }
  295. if ( OpenChannel( (PBYTE)addr + sizeof( AlterVideoChannel<VideoChannel> ), VideoStream( st -1 ) ) == Success )
  296. {
  297. videochannels[st] = new( addr ) AlterVideoChannel<VideoChannel>( st, *videochannels [st-1] );
  298. videochannels[st]->SetStrmEx( pStrmEx ) ;
  299. videochannels[st-1]->SetStrmEx( pStrmEx ) ;
  300. if ( DoOpen( st ) != Success )
  301. {
  302. DebugOut((1, " PsDevice::OpenAlterChannel(%x,%d) failed - DoOpen failed\n", addr, st));
  303. CloseChannel( videochannels [st-1] );
  304. return Fail;
  305. }
  306. }
  307. else
  308. {
  309. DebugOut((1, " PsDevice::OpenAlterChannel(%x,%d) failed - OpenChannel failed\n", addr, st));
  310. return Fail;
  311. }
  312. return Success;
  313. }
  314. /* Method: PsDevice::OpenVBIChannel
  315. * Purpose: This function opens video channel that produces alternating fields
  316. * Input: addr: PVOID, address for the palcement new
  317. * st: VideoStream, stream to open ( VBI or video )
  318. * Output: None
  319. */
  320. ErrorCode PsDevice::OpenVBIChannel( PVOID pStrmEx )
  321. {
  322. PVOID addr = &((PSTREAMEX)pStrmEx)->videochannelmem[0];
  323. ((PSTREAMEX)pStrmEx)->videochannel = addr;
  324. DebugOut((1, "PsDevice::OpenVBIChannel(%x)\n", addr));
  325. if ( videochannels [VS_VBI1] || videochannels [VS_VBI2] )
  326. {
  327. DebugOut((1, " PsDevice::OpenVBIChannel(%x) failed - already open\n", addr));
  328. return Fail;
  329. }
  330. VBIChannel *tmp = new( (PBYTE)addr + sizeof( VBIAlterChannel ) ) VBIChannel( VS_VBI1 );
  331. videochannels [VS_VBI1] = tmp;
  332. DebugOut((1, " PsDevice::OpenVBIChannel(%x), videochannels[VS_VBI1(%d)] = %x\n", addr, VS_VBI1, videochannels[VS_VBI1]));
  333. if ( !tmp )
  334. {
  335. DebugOut((1, " PsDevice::OpenVBIChannel(%x) failed - new VBIChannel failed\n", addr));
  336. return Fail;
  337. }
  338. if ( DoOpen( VS_VBI1 ) != Success )
  339. {
  340. DebugOut((1, " PsDevice::OpenVBIChannel(%x) failed - DoOpen(VS_VBI1) failed\n", addr));
  341. return Fail;
  342. }
  343. videochannels [VS_VBI2] = new( addr ) VBIAlterChannel( VS_VBI2, *tmp );
  344. DebugOut((1, " PsDevice::OpenVBIChannel(%x), videochannels[VS_VBI2(%d)] = %x\n", addr, VS_VBI2, videochannels[VS_VBI2]));
  345. if (!videochannels [VS_VBI2])
  346. {
  347. DebugOut((1, " PsDevice::OpenVBIChannel(%x) failed - new VBIAlterChannel failed\n", addr));
  348. return Fail;
  349. }
  350. if ( DoOpen( VS_VBI2 ) != Success )
  351. {
  352. DebugOut((1, " PsDevice::OpenVBIChannel(%x) failed - DoOpen(VS_VBI1) failed\n", addr));
  353. CloseChannel( videochannels [VS_VBI1] );
  354. return Fail;
  355. }
  356. videochannels[VS_VBI1]->SetStrmEx( pStrmEx ) ;
  357. videochannels[VS_VBI2]->SetStrmEx( pStrmEx ) ;
  358. return Success;
  359. }
  360. /* Method: PsDevice::CloseChannel
  361. * Purpose: Closes a video channel
  362. * Input: ToClose: VideoChannel *
  363. * Output: None
  364. */
  365. void PsDevice::CloseChannel( VideoChannel *ToClose )
  366. {
  367. *(DWORD*)(gpjBaseAddr+0x10c) &= ~3; // disable interrupts [TMZ] [!!!]
  368. DebugOut((1, "PsDevice::CloseChannel(%x)\n", ToClose));
  369. if ( IsOurChannel( *ToClose ) )
  370. {
  371. // this is a bit ugly solution to make CLOSE_STREAM SRB clean
  372. if ( ToClose->GetStreamType() == Single )
  373. {
  374. VideoStream st = ToClose->GetStreamID();
  375. DebugOut((1, " PsDevice::CloseChannel(%x) - closing single channel (stream == %d)\n", ToClose, st));
  376. VideoChannel * pvcTemp = videochannels [st];
  377. videochannels [st] = NULL;
  378. delete pvcTemp;
  379. }
  380. else
  381. {
  382. DebugOut((1, " PsDevice::CloseChannel(%x) - closing paired channel\n", ToClose));
  383. ClosePairedChannel( ToClose );
  384. }
  385. }
  386. else
  387. {
  388. DebugOut((1, " PsDevice::CloseChannel(%x) ignored - not our channel\n", ToClose));
  389. }
  390. }
  391. /* Method: PsDevice::ClosePairedChannel
  392. * Purpose: This function opens a channel requested by the capture driver
  393. * Input: hVM: VMHANDLE - handle of the VM making a call
  394. * pRegs: CLIENT_STRUCT * - pointer to the structure with VM's registers
  395. * Output: None
  396. */
  397. void PsDevice::ClosePairedChannel( VideoChannel *ToClose )
  398. {
  399. *(DWORD*)(gpjBaseAddr+0x10c) &= ~3; // disable interrupts [TMZ] [!!!]
  400. DebugOut((1, "PsDevice::ClosePairedChannel(%x)\n", ToClose));
  401. if ( IsOurChannel( *ToClose ) )
  402. {
  403. VideoStream st = ToClose->GetStreamID();
  404. DebugOut((1, " PsDevice::ClosePairedChannel(%x) - closing paired channel (stream == %d)\n", ToClose, st));
  405. DebugOut((1, " PsDevice::ClosePairedChannel(%x) - streams[%d] = %x\n", ToClose, st, videochannels[st]));
  406. DebugOut((1, " PsDevice::ClosePairedChannel(%x) - streams[%d] = %x\n", ToClose, st-1, videochannels[st-1]));
  407. VideoChannel *pvcTemp;
  408. pvcTemp = videochannels [st];
  409. videochannels [st] = NULL;
  410. delete pvcTemp;
  411. pvcTemp = videochannels [st-1];
  412. videochannels [st-1] = NULL;
  413. delete pvcTemp;
  414. }
  415. else
  416. {
  417. DebugOut((1, " PsDevice::ClosePairedChannel(%x) ignored - not our channel\n", ToClose));
  418. }
  419. }
  420. /* Method: PsDevice::SetSaturation
  421. * Purpose:
  422. * Input:
  423. * Output: None
  424. */
  425. void PsDevice::SetSaturation( LONG Data )
  426. {
  427. CaptureContrll_.SetSaturation( Data );
  428. }
  429. /* Method: PsDevice::SetHue
  430. * Purpose:
  431. * Input:
  432. * Output: None
  433. */
  434. void PsDevice::SetHue( LONG Data )
  435. {
  436. CaptureContrll_.SetHue( Data );
  437. }
  438. /* Method: PsDevice::SetBrightness
  439. * Purpose:
  440. * Input:
  441. * Output: None
  442. */
  443. void PsDevice::SetBrightness( LONG Data )
  444. {
  445. CaptureContrll_.SetBrightness( Data );
  446. }
  447. /* Method: PsDevice::SetSVideo
  448. * Purpose:
  449. * Input:
  450. * Output: None
  451. */
  452. void PsDevice::SetSVideo( LONG Data )
  453. {
  454. CaptureContrll_.SetSVideo( Data );
  455. }
  456. /* Method: PsDevice::SetContrast
  457. * Purpose:
  458. * Input:
  459. * Output: None
  460. */
  461. void PsDevice::SetContrast( LONG Data )
  462. {
  463. CaptureContrll_.SetContrast( Data );
  464. }
  465. /* Method: PsDevice::SetFormat
  466. * Purpose:
  467. * Input:
  468. * Output: None
  469. */
  470. void PsDevice::SetFormat( LONG Data )
  471. {
  472. CaptureContrll_.SetFormat( Data );
  473. // notify all video channels that video timing has changed
  474. LONG time = Data == KS_AnalogVideo_NTSC_M ? 333667 : 400000;
  475. for ( int i = 0; i < (sizeof(videochannels)/sizeof(videochannels[0])); i++ )
  476. {
  477. if ( videochannels [i] )
  478. {
  479. DebugOut((1, "PsDevice::SetFormat(%d) SetTimePerFrame on videochannels[%d]\n", Data, i));
  480. videochannels [i]->SetTimePerFrame( time );
  481. }
  482. }
  483. }
  484. /* Method: PsDevice::SetConnector
  485. * Purpose:
  486. * Input:
  487. * Output: None
  488. */
  489. void PsDevice::SetConnector( LONG Data )
  490. {
  491. CaptureContrll_.SetConnector( Data );
  492. }
  493. /* Method: PsDevice::GetSaturation
  494. * Purpose:
  495. * Input: pData: PLONG
  496. * Output: None
  497. */
  498. LONG PsDevice::GetSaturation()
  499. {
  500. return CaptureContrll_.GetSaturation();
  501. }
  502. /* Method: PsDevice::GetHue
  503. * Purpose:
  504. * Input: pData: PLONG
  505. * Output: None
  506. */
  507. LONG PsDevice::GetHue()
  508. {
  509. return CaptureContrll_.GetHue();
  510. }
  511. /* Method: PsDevice::GetBrightness
  512. * Purpose:
  513. * Input: pData: PLONG
  514. * Output: None
  515. */
  516. LONG PsDevice::GetBrightness()
  517. {
  518. return CaptureContrll_.GetBrightness();
  519. }
  520. /* Method: PsDevice::GetSVideo
  521. * Purpose:
  522. * Input: pData: PLONG
  523. * Output: None
  524. */
  525. LONG PsDevice::GetSVideo()
  526. {
  527. return CaptureContrll_.GetSVideo();
  528. }
  529. /* Method: PsDevice::GetContrast
  530. * Purpose:
  531. * Input: pData: PLONG
  532. * Output: None
  533. */
  534. LONG PsDevice::GetContrast()
  535. {
  536. return CaptureContrll_.GetContrast();
  537. }
  538. /* Method: PsDevice::GetFormat
  539. * Purpose:
  540. * Input: pData: PLONG
  541. * Output: None
  542. */
  543. LONG PsDevice::GetFormat()
  544. {
  545. return CaptureContrll_.GetFormat();
  546. }
  547. /* Method: PsDevice::GetConnector
  548. * Purpose:
  549. * Input: pData: PLONG
  550. * Output: None
  551. */
  552. LONG PsDevice::GetConnector()
  553. {
  554. return CaptureContrll_.GetConnector();
  555. }
  556. /* Method: PsDevice::ChangeNotifyChannels
  557. * Purpose: Invoked to notify channels of some global changes
  558. */
  559. void PsDevice::ChangeNotifyChannels( IN PHW_STREAM_REQUEST_BLOCK pSrb )
  560. {
  561. // We should only do this once per "system" stream.
  562. // Video streams don't seem to care.
  563. // That just leaves one VBI notification required
  564. videochannels [VS_VBI1]->ChangeNotification( pSrb );
  565. }
  566. /* Method: PsDevice::GetSupportedStandards
  567. * Purpose: Obtains video standards device can support
  568. * Input: None
  569. * Output: LONG
  570. */
  571. LONG PsDevice::GetSupportedStandards()
  572. {
  573. return CaptureContrll_.GetSupportedStandards();
  574. }
  575. bool PsDevice::InitOK()
  576. {
  577. return CaptureContrll_.InitOK();
  578. }
  579. #ifndef HARDWAREI2C
  580. //===========================================================================
  581. // Bt848 software I2C stuff
  582. //===========================================================================
  583. /*
  584. * If we build with software I2C then these routines fake the Hardware I2C routines
  585. * so the tuner code keeps working
  586. */
  587. ErrorCode PsDevice::I2CHWRead( BYTE address, BYTE *value )
  588. {
  589. ErrorCode error;
  590. error = I2CSWStart();
  591. if(error) {
  592. return error;
  593. }
  594. error = I2CSWWrite( address | 0x01 );
  595. if(error) {
  596. return error;
  597. }
  598. error = I2CSWRead( value );
  599. if(error) {
  600. return error;
  601. }
  602. error = I2CSWSendNACK();
  603. if(error) {
  604. return error;
  605. }
  606. error = I2CSWStop();
  607. return error;
  608. }
  609. ErrorCode PsDevice::I2CHWWrite3( BYTE address, BYTE value1, BYTE value2 )
  610. {
  611. ErrorCode error;
  612. error = I2CSWStart();
  613. if(error) {
  614. return error;
  615. }
  616. error = I2CSWWrite( address );
  617. if(error) {
  618. return error;
  619. }
  620. error = I2CSWWrite( value1 );
  621. if(error) {
  622. return error;
  623. }
  624. error = I2CSWWrite( value2 );
  625. if(error) {
  626. return error;
  627. }
  628. error = I2CSWStop();
  629. return error;
  630. }
  631. #endif
  632. //////////////////////////////////////////////////////////////////
  633. #ifdef __cplusplus
  634. extern "C" {
  635. #endif
  636. #include <stdarg.h>
  637. #ifdef __cplusplus
  638. }
  639. #endif
  640. // #include "capdebug.h"
  641. #define DEBUG_PRINT_PREFIX " ---: "
  642. // #define DEBUG_PRINT_PREFIX "bt848wdm: "
  643. long DebugLevel = 0;
  644. BOOL bNewLine = TRUE;
  645. extern "C" void MyDebugPrint(long DebugPrintLevel, char * DebugMessage, ... )
  646. {
  647. if (DebugPrintLevel <= DebugLevel)
  648. {
  649. char debugPrintBuffer[256] ;
  650. va_list marker;
  651. va_start( marker, DebugMessage ); // Initialize variable arguments.
  652. vsprintf( debugPrintBuffer,
  653. DebugMessage,
  654. marker );
  655. if( bNewLine )
  656. {
  657. DbgPrint(("%s", DEBUG_PRINT_PREFIX));
  658. }
  659. DbgPrint((debugPrintBuffer));
  660. if( debugPrintBuffer[strlen(debugPrintBuffer)-1] == '\n')
  661. {
  662. bNewLine = TRUE;
  663. }
  664. else
  665. {
  666. bNewLine = FALSE;
  667. }
  668. va_end( marker ); // Reset variable arguments.
  669. }
  670. }
  671. #if TRACE_CALLS
  672. #define MAX_TRACE_DEPTH 10
  673. unsigned long ulTraceDepth = 0;
  674. char achIndentBuffer[100];
  675. char * IndentStr( )
  676. {
  677. unsigned long ul = ulTraceDepth < MAX_TRACE_DEPTH ? ulTraceDepth : MAX_TRACE_DEPTH;
  678. unsigned long x;
  679. char * lpszBuf = achIndentBuffer;
  680. for( x = 0; x < ul; x++)
  681. {
  682. // indent two spaces per depth increment
  683. *lpszBuf++ = ' ';
  684. *lpszBuf++ = ' ';
  685. }
  686. sprintf (lpszBuf, "[%lu]", ulTraceDepth);
  687. return( achIndentBuffer );
  688. }
  689. Trace::Trace(char *pszFunc)
  690. {
  691. psz = pszFunc;
  692. DebugOut((0, "%s %s\n", IndentStr(), psz));
  693. ulTraceDepth++;
  694. }
  695. Trace::~Trace()
  696. {
  697. ulTraceDepth--;
  698. // DebugOut((0, "%s %s\n", IndentStr(), psz));
  699. }
  700. #endif