Source code of Windows XP (NT5)
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.

299 lines
8.3 KiB

  1. //***************************************************************************
  2. //
  3. // FileName: hlight.cpp
  4. // $Workfile: hlight.cpp $
  5. //
  6. // Author:
  7. // TOSHIBA [PCS](PSY) Seiichi Nakamura
  8. // Copyright (c) 1997 TOSHIBA CORPORATION
  9. //
  10. // Description:
  11. //
  12. //***************************************************************************
  13. // $Header: /DVD Drivers/ZIVA2PC.WDM/hlight.cpp 2 99/02/22 1:39p Yagi $
  14. // $Modtime: 99/02/22 11:03a $
  15. // $Nokeywords:$
  16. //***************************************************************************
  17. #include "includes.h"
  18. #include "hal.h"
  19. #include "wdmkserv.h"
  20. #include "mpevent.h"
  21. #include "classlib.h"
  22. #include "ctime.h"
  23. #include "schdat.h"
  24. #include "ccque.h"
  25. #include "ctvctrl.h"
  26. #include "hlight.h"
  27. #include "hwdevex.h"
  28. //***************************************************************************
  29. //
  30. //***************************************************************************
  31. HlightControl::HlightControl( void )
  32. {
  33. };
  34. HlightControl::~HlightControl( void )
  35. {
  36. };
  37. //---------------------------------------------------------------------------
  38. //
  39. //---------------------------------------------------------------------------
  40. void HlightControl::Init( PHW_DEVICE_EXTENSION pHwDevExt )
  41. {
  42. ASSERT( pHwDevExt != NULL );
  43. m_pHwDevExt = pHwDevExt;
  44. KeInitializeTimer( &m_StartTimer );
  45. KeInitializeTimer( &m_EndTimer );
  46. KeInitializeDpc( &m_HlightStartDPC, HlightStartDpc, (PVOID)this );
  47. KeInitializeDpc( &m_HlightEndDPC, HlightEndDpc, (PVOID)this );
  48. m_SetupStartTimer = FALSE;
  49. m_SetupEndTimer = FALSE;
  50. };
  51. void HlightControl::OpenControl( void )
  52. {
  53. RtlZeroMemory( &m_HlightInfo,sizeof( KSPROPERTY_SPHLI ));
  54. m_SetupStartTimer = FALSE;
  55. m_SetupEndTimer = FALSE;
  56. };
  57. void HlightControl::CloseControl( void )
  58. {
  59. if( m_SetupStartTimer == TRUE )
  60. {
  61. KeCancelTimer( &m_StartTimer );
  62. m_SetupStartTimer = FALSE;
  63. };
  64. if( m_SetupEndTimer == TRUE )
  65. {
  66. KeCancelTimer( &m_EndTimer );
  67. m_SetupEndTimer = FALSE;
  68. };
  69. };
  70. void HlightControl::Set( PKSPROPERTY_SPHLI Info )
  71. {
  72. DWORD tmpSTC,boardSTC;
  73. tmpSTC = (DWORD)(m_pHwDevExt->ticktime.GetStreamTime() * 9 / 1000);
  74. DBG_PRINTF( ("DVDWDM: StartPTM=0x%08x, EndPTM=0x%08x\n\r", Info->StartPTM, Info->EndPTM ));
  75. m_pHwDevExt->mpboard.GetSTC(&boardSTC);
  76. if( boardSTC > tmpSTC )
  77. {
  78. DBG_PRINTF( ("DVDWDM: Stream STC=0x%08x BardSTC = 0x%08x Diff %d msec\n\r",
  79. tmpSTC, boardSTC,(boardSTC-tmpSTC) / 90 ));
  80. }
  81. else
  82. {
  83. DBG_PRINTF( ("DVDWDM: Stream STC=0x%08x BardSTC = 0x%08x Diff %d msec\n\r",
  84. tmpSTC, boardSTC,(tmpSTC - boardSTC) / 90 ));
  85. };
  86. if( m_pHwDevExt->dvdstrm.GetState() == Play )
  87. {
  88. DBG_PRINTF((" Modify STC LINE=%d\r\n",__LINE__ ));
  89. tmpSTC = boardSTC;
  90. };
  91. // �S�������R���g���[���̏ꍇ
  92. if(RtlCompareMemory( &m_HlightInfo,Info,sizeof(*Info)) == 0 )
  93. {
  94. DBG_PRINTF( ("DVDWDM: same control \n\r\n\r\n\r" ));
  95. return;
  96. };
  97. // �^�C�}�[���͂��Ă���EndPTM�ƁA�V��������StartPTM�������ŁA���AEndPTM��
  98. // �^�C�}�[���Z�b�g�����Ă����Ƃ��́AEndPTM�̃^�C�}�[���j������
  99. if( m_HlightInfo.EndPTM == Info->StartPTM && m_SetupEndTimer == TRUE )
  100. {
  101. KeCancelTimer( &m_EndTimer );
  102. m_SetupEndTimer = FALSE;
  103. };
  104. m_HlightInfo = *Info;
  105. // �n�C���C�g�n�e�e�̏ꍇ
  106. if( (Info->StartX==Info->StopX && Info->StartY==Info->StopY) || (Info->HLISS == 0 ) )
  107. {
  108. if( m_pHwDevExt->dvdstrm.GetState() != Stop )
  109. {
  110. if( Info->StartPTM!=0 && Info->EndPTM!=0 ){
  111. HwSet();
  112. }
  113. };
  114. return;
  115. }
  116. // �^�C�}�[���͂��āA�������ׂ����ǂ���?
  117. if( tmpSTC < Info->StartPTM && Info->StartPTM != 0xffffffff )
  118. {
  119. // �^�C�}�[�K�v
  120. DBG_PRINTF( ("DVDWDM: SetSubpic ScheduleTimer wait %d msec \n\r", (Info->StartPTM-tmpSTC)/90 ));
  121. LARGE_INTEGER WaitTime;
  122. // �}�C�i�X�̒l���K�v
  123. WaitTime = RtlConvertLongToLargeInteger( Info->StartPTM - tmpSTC ) ;
  124. WaitTime.QuadPart = WaitTime.QuadPart * 1000 / 9 * -1;
  125. // ���j���[�\���Ȃǂ̎��ɁA�n�C���C�g���\���������̂��x���̂�
  126. // �X�g�b�v�����̃n�C���C�g���␳�����B
  127. if( m_pHwDevExt->dvdstrm.GetState() == Stop
  128. && (Info->StartPTM - tmpSTC) / 90 < 600 )
  129. {
  130. WaitTime.QuadPart = WaitTime.QuadPart / 2;
  131. };
  132. ASSERT( KeGetCurrentIrql() <= DISPATCH_LEVEL );
  133. if( m_SetupStartTimer == FALSE )
  134. {
  135. m_SetupStartTimer = TRUE;
  136. KeSetTimer( &m_StartTimer, WaitTime, &m_HlightStartDPC );
  137. }
  138. else
  139. {
  140. // ���łɃ^�C�}�[���Z�b�g�����Ă���
  141. DBG_PRINTF( ("DVDWDM: same control 2 !!!!!\n\r\n\r\n\r" ));
  142. HwSet();
  143. };
  144. }
  145. else
  146. {
  147. // �^�C�}�[�s�K�v
  148. DBG_PRINTF( ("DVDWDM: SetSubpic ScheduleTimer NO WAIT!! \n\r"));
  149. if( m_SetupStartTimer == TRUE )
  150. {
  151. KeCancelTimer( &m_StartTimer );
  152. m_SetupStartTimer = FALSE;
  153. DBG_BREAK();
  154. };
  155. HwSet();
  156. };
  157. // EndPTM�̏��������ׂ����ǂ���
  158. if( tmpSTC < Info->EndPTM && Info->EndPTM != 0xffffffff)
  159. {
  160. // �^�C�}�[�K�v
  161. DBG_PRINTF( ("DVDWDM: SetSubpic ScheduleTimer EndPTM wait %d msec \n\r", (Info->EndPTM-tmpSTC)/90 ));
  162. LARGE_INTEGER WaitTime;
  163. // �}�C�i�X�̒l���K�v
  164. WaitTime = RtlConvertLongToLargeInteger( Info->EndPTM - tmpSTC ) ;
  165. WaitTime.QuadPart = WaitTime.QuadPart * 1000 / 9 * -1;
  166. ASSERT( KeGetCurrentIrql() <= DISPATCH_LEVEL );
  167. if( m_SetupEndTimer == FALSE )
  168. {
  169. m_SetupEndTimer = TRUE;
  170. KeSetTimer( &m_EndTimer, WaitTime, &m_HlightEndDPC );
  171. }
  172. else
  173. {
  174. // ���łɃ^�C�}�[���Z�b�g�����Ă���
  175. DBG_PRINTF( ("DVDWDM: EndPTM same control 2 !!!!!\n\r\n\r\n\r" ));
  176. HwSet();
  177. };
  178. };
  179. };
  180. void HlightControl::HwSet( void )
  181. {
  182. DWORD boardSTC,StreamSTC;
  183. SubpHlightStruc NewHlight; // High-light inf structure
  184. StreamSTC = (DWORD)(m_pHwDevExt->ticktime.GetStreamTime() * 9 / 1000);
  185. m_pHwDevExt->mpboard.GetSTC(&boardSTC);
  186. // STC�̕␳
  187. if( m_pHwDevExt->dvdstrm.GetState() == Play )
  188. StreamSTC = boardSTC;
  189. if( // �n�C���C�g�ʒu���A�����ɂȂ��Ă��邩?
  190. (m_HlightInfo.StartX==m_HlightInfo.StopX && m_HlightInfo.StartY==m_HlightInfo.StopY)
  191. // �����ȃn�C���C�g�ɂȂ��Ă��邩?
  192. || ( m_HlightInfo.HLISS == 0 )
  193. // EndPTM�̎��ԂɂȂ��Ă��邩?
  194. || (( m_HlightInfo.EndPTM != 0xffffffff ) && (StreamSTC >= m_HlightInfo.EndPTM ))
  195. )
  196. { // Off
  197. DBG_PRINTF( ("DVDWDM: HighLight(OFF)\n\r") );
  198. NewHlight.Hlight_Switch = Hlight_Off;
  199. }
  200. else
  201. { // On
  202. DBG_PRINTF( ("DVDWDM: HighLight(ON)\n\r") );
  203. NewHlight.Hlight_Switch = Hlight_On;
  204. };
  205. NewHlight.Hlight_StartX = (DWORD)(m_HlightInfo.StartX);
  206. NewHlight.Hlight_StartY = (DWORD)(m_HlightInfo.StartY);
  207. NewHlight.Hlight_EndX = (DWORD)(m_HlightInfo.StopX);
  208. NewHlight.Hlight_EndY = (DWORD)(m_HlightInfo.StopY);
  209. NewHlight.Hlight_Color = (DWORD)( m_HlightInfo.ColCon.emph2col<<12 | m_HlightInfo.ColCon.emph1col<<8 | m_HlightInfo.ColCon.patcol<<4 | m_HlightInfo.ColCon.backcol );
  210. NewHlight.Hlight_Contrast = (DWORD)( m_HlightInfo.ColCon.emph2con<<12 | m_HlightInfo.ColCon.emph1con<<8 | m_HlightInfo.ColCon.patcon<<4 | m_HlightInfo.ColCon.backcon );
  211. DBG_PRINTF(( " Set Subpic Hlight! boardSTC=0x%x, startSTC=0x%x, EndSTC=0x%x\r\n",
  212. boardSTC, m_HlightInfo.StartPTM,m_HlightInfo.EndPTM));
  213. DBG_PRINTF( ("-- StartX = %d, StartY = %d, EndX = %d, EndY = %d\n\r",
  214. NewHlight.Hlight_StartX,NewHlight.Hlight_StartY,NewHlight.Hlight_EndX,NewHlight.Hlight_EndY ));
  215. if( NewHlight.Hlight_Switch == Hlight_Off && m_pHwDevExt->dvdstrm.GetState() == Stop )
  216. {
  217. DBG_PRINTF( ("DVDWDM: SetSubpic Hilight Decoder Stopping \n\r") );
  218. return;
  219. };
  220. if( !m_pHwDevExt->dvdstrm.SetSubpicProperty( SubpicProperty_Hilight, &(NewHlight) ) ){
  221. DBG_PRINTF( ("DVDWDM: SetSubpic Hilight Error\n\r") );
  222. DBG_BREAK();
  223. }
  224. };
  225. //***************************************************************************
  226. // call back function
  227. //***************************************************************************
  228. void HlightControl::HlightStartDpc( IN PKDPC Dpc, IN PVOID context, IN PVOID arg1, IN PVOID arg2 )
  229. {
  230. DBG_PRINTF((" Start DPC !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Irql=%d\r\n", KeGetCurrentIrql() ));
  231. HlightControl *This = (HlightControl *)context;
  232. This->m_SetupStartTimer = FALSE;
  233. This->HwSet();
  234. };
  235. void HlightControl::HlightEndDpc( IN PKDPC Dpc, IN PVOID context, IN PVOID arg1, IN PVOID arg2 )
  236. {
  237. DBG_PRINTF((" End DPC !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Irql=%d\r\n", KeGetCurrentIrql() ));
  238. HlightControl *This = (HlightControl *)context;
  239. This->m_SetupEndTimer = FALSE;
  240. This->HwSet();
  241. };
  242. //***************************************************************************
  243. // End of hlight.cpp
  244. //***************************************************************************