300 lines
8.3 KiB
C++
300 lines
8.3 KiB
C++
//***************************************************************************
|
||
//
|
||
// FileName: hlight.cpp
|
||
// $Workfile: hlight.cpp $
|
||
//
|
||
// Author:
|
||
// TOSHIBA [PCS](PSY) Seiichi Nakamura
|
||
// Copyright (c) 1997 TOSHIBA CORPORATION
|
||
//
|
||
// Description:
|
||
//
|
||
//***************************************************************************
|
||
// $Header: /DVD Drivers/ZIVA2PC.WDM/hlight.cpp 2 99/02/22 1:39p Yagi $
|
||
// $Modtime: 99/02/22 11:03a $
|
||
// $Nokeywords:$
|
||
//***************************************************************************
|
||
#include "includes.h"
|
||
|
||
#include "hal.h"
|
||
#include "wdmkserv.h"
|
||
#include "mpevent.h"
|
||
#include "classlib.h"
|
||
#include "ctime.h"
|
||
#include "schdat.h"
|
||
#include "ccque.h"
|
||
#include "ctvctrl.h"
|
||
#include "hlight.h"
|
||
#include "hwdevex.h"
|
||
|
||
//***************************************************************************
|
||
//
|
||
//***************************************************************************
|
||
|
||
HlightControl::HlightControl( void )
|
||
{
|
||
|
||
};
|
||
|
||
HlightControl::~HlightControl( void )
|
||
{
|
||
|
||
};
|
||
|
||
|
||
//---------------------------------------------------------------------------
|
||
//
|
||
//---------------------------------------------------------------------------
|
||
void HlightControl::Init( PHW_DEVICE_EXTENSION pHwDevExt )
|
||
{
|
||
ASSERT( pHwDevExt != NULL );
|
||
|
||
m_pHwDevExt = pHwDevExt;
|
||
KeInitializeTimer( &m_StartTimer );
|
||
KeInitializeTimer( &m_EndTimer );
|
||
KeInitializeDpc( &m_HlightStartDPC, HlightStartDpc, (PVOID)this );
|
||
KeInitializeDpc( &m_HlightEndDPC, HlightEndDpc, (PVOID)this );
|
||
m_SetupStartTimer = FALSE;
|
||
m_SetupEndTimer = FALSE;
|
||
};
|
||
|
||
|
||
void HlightControl::OpenControl( void )
|
||
{
|
||
RtlZeroMemory( &m_HlightInfo,sizeof( KSPROPERTY_SPHLI ));
|
||
m_SetupStartTimer = FALSE;
|
||
m_SetupEndTimer = FALSE;
|
||
};
|
||
|
||
void HlightControl::CloseControl( void )
|
||
{
|
||
if( m_SetupStartTimer == TRUE )
|
||
{
|
||
KeCancelTimer( &m_StartTimer );
|
||
m_SetupStartTimer = FALSE;
|
||
};
|
||
if( m_SetupEndTimer == TRUE )
|
||
{
|
||
KeCancelTimer( &m_EndTimer );
|
||
m_SetupEndTimer = FALSE;
|
||
};
|
||
|
||
};
|
||
|
||
void HlightControl::Set( PKSPROPERTY_SPHLI Info )
|
||
{
|
||
DWORD tmpSTC,boardSTC;
|
||
|
||
tmpSTC = (DWORD)(m_pHwDevExt->ticktime.GetStreamTime() * 9 / 1000);
|
||
DBG_PRINTF( ("DVDWDM: StartPTM=0x%08x, EndPTM=0x%08x\n\r", Info->StartPTM, Info->EndPTM ));
|
||
|
||
m_pHwDevExt->mpboard.GetSTC(&boardSTC);
|
||
|
||
if( boardSTC > tmpSTC )
|
||
{
|
||
DBG_PRINTF( ("DVDWDM: Stream STC=0x%08x BardSTC = 0x%08x Diff %d msec\n\r",
|
||
tmpSTC, boardSTC,(boardSTC-tmpSTC) / 90 ));
|
||
}
|
||
else
|
||
{
|
||
DBG_PRINTF( ("DVDWDM: Stream STC=0x%08x BardSTC = 0x%08x Diff %d msec\n\r",
|
||
tmpSTC, boardSTC,(tmpSTC - boardSTC) / 90 ));
|
||
};
|
||
|
||
if( m_pHwDevExt->dvdstrm.GetState() == Play )
|
||
{
|
||
DBG_PRINTF((" Modify STC LINE=%d\r\n",__LINE__ ));
|
||
tmpSTC = boardSTC;
|
||
};
|
||
|
||
// <20>S<EFBFBD><53><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>R<EFBFBD><52><EFBFBD>g<EFBFBD><67><EFBFBD>[<5B><><EFBFBD>̏ꍇ
|
||
if(RtlCompareMemory( &m_HlightInfo,Info,sizeof(*Info)) == 0 )
|
||
{
|
||
DBG_PRINTF( ("DVDWDM: same control \n\r\n\r\n\r" ));
|
||
return;
|
||
};
|
||
|
||
|
||
// <20>^<5E>C<EFBFBD>}<7D>[<5B><><EFBFBD>͂<EFBFBD><CD82>Ă<EFBFBD><C482><EFBFBD>EndPTM<54>ƁA<C681>V<EFBFBD><56><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>StartPTM<54><4D><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ŁA<C581><41><EFBFBD>AEndPTM<54><4D>
|
||
// <20>^<5E>C<EFBFBD>}<7D>[<5B><><EFBFBD>Z<EFBFBD>b<EFBFBD>g<EFBFBD><67><EFBFBD><EFBFBD><EFBFBD>Ă<EFBFBD><C482><EFBFBD><EFBFBD>Ƃ<EFBFBD><C682>́AEndPTM<54>̃^<5E>C<EFBFBD>}<7D>[<5B><><EFBFBD>j<EFBFBD><6A><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||
if( m_HlightInfo.EndPTM == Info->StartPTM && m_SetupEndTimer == TRUE )
|
||
{
|
||
KeCancelTimer( &m_EndTimer );
|
||
m_SetupEndTimer = FALSE;
|
||
};
|
||
|
||
m_HlightInfo = *Info;
|
||
|
||
// <20>n<EFBFBD>C<EFBFBD><43><EFBFBD>C<EFBFBD>g<EFBFBD>n<EFBFBD>e<EFBFBD>e<EFBFBD>̏ꍇ
|
||
if( (Info->StartX==Info->StopX && Info->StartY==Info->StopY) || (Info->HLISS == 0 ) )
|
||
{
|
||
if( m_pHwDevExt->dvdstrm.GetState() != Stop )
|
||
{
|
||
if( Info->StartPTM!=0 && Info->EndPTM!=0 ){
|
||
HwSet();
|
||
}
|
||
};
|
||
return;
|
||
}
|
||
|
||
// <20>^<5E>C<EFBFBD>}<7D>[<5B><><EFBFBD>͂<EFBFBD><CD82>āA<C481><41><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ׂ<EFBFBD><D782><EFBFBD><EFBFBD>ǂ<EFBFBD><C782><EFBFBD>?
|
||
if( tmpSTC < Info->StartPTM && Info->StartPTM != 0xffffffff )
|
||
{
|
||
// <09>^<5E>C<EFBFBD>}<7D>[<5B>K<EFBFBD>v
|
||
DBG_PRINTF( ("DVDWDM: SetSubpic ScheduleTimer wait %d msec \n\r", (Info->StartPTM-tmpSTC)/90 ));
|
||
|
||
LARGE_INTEGER WaitTime;
|
||
|
||
// <20>}<7D>C<EFBFBD>i<EFBFBD>X<EFBFBD>̒l<CC92><6C><EFBFBD>K<EFBFBD>v
|
||
WaitTime = RtlConvertLongToLargeInteger( Info->StartPTM - tmpSTC ) ;
|
||
WaitTime.QuadPart = WaitTime.QuadPart * 1000 / 9 * -1;
|
||
|
||
// <20><><EFBFBD>j<EFBFBD><6A><EFBFBD>[<5B>\<5C><><EFBFBD>Ȃǂ̎<C782><CC8E>ɁA<C981>n<EFBFBD>C<EFBFBD><43><EFBFBD>C<EFBFBD>g<EFBFBD><67><EFBFBD>\<5C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>̂<EFBFBD><CC82>x<EFBFBD><78><EFBFBD>̂<EFBFBD>
|
||
// <20>X<EFBFBD>g<EFBFBD>b<EFBFBD>v<EFBFBD><76><EFBFBD><EFBFBD><EFBFBD>̃n<CC83>C<EFBFBD><43><EFBFBD>C<EFBFBD>g<EFBFBD><67><EFBFBD><EFBFBD><E290B3><EFBFBD><EFBFBD><EFBFBD>B
|
||
if( m_pHwDevExt->dvdstrm.GetState() == Stop
|
||
&& (Info->StartPTM - tmpSTC) / 90 < 600 )
|
||
{
|
||
WaitTime.QuadPart = WaitTime.QuadPart / 2;
|
||
};
|
||
|
||
ASSERT( KeGetCurrentIrql() <= DISPATCH_LEVEL );
|
||
|
||
if( m_SetupStartTimer == FALSE )
|
||
{
|
||
m_SetupStartTimer = TRUE;
|
||
KeSetTimer( &m_StartTimer, WaitTime, &m_HlightStartDPC );
|
||
}
|
||
else
|
||
{
|
||
// <20><><EFBFBD>łɃ^<5E>C<EFBFBD>}<7D>[<5B><><EFBFBD>Z<EFBFBD>b<EFBFBD>g<EFBFBD><67><EFBFBD><EFBFBD><EFBFBD>Ă<EFBFBD><C482><EFBFBD>
|
||
DBG_PRINTF( ("DVDWDM: same control 2 !!!!!\n\r\n\r\n\r" ));
|
||
HwSet();
|
||
};
|
||
}
|
||
else
|
||
{
|
||
// <20>^<5E>C<EFBFBD>}<7D>[<5B>s<EFBFBD>K<EFBFBD>v
|
||
|
||
DBG_PRINTF( ("DVDWDM: SetSubpic ScheduleTimer NO WAIT!! \n\r"));
|
||
if( m_SetupStartTimer == TRUE )
|
||
{
|
||
KeCancelTimer( &m_StartTimer );
|
||
m_SetupStartTimer = FALSE;
|
||
DBG_BREAK();
|
||
};
|
||
HwSet();
|
||
};
|
||
|
||
// EndPTM<54>̏<EFBFBD><CC8F><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ׂ<EFBFBD><D782><EFBFBD><EFBFBD>ǂ<EFBFBD><C782><EFBFBD>
|
||
if( tmpSTC < Info->EndPTM && Info->EndPTM != 0xffffffff)
|
||
{
|
||
// <09>^<5E>C<EFBFBD>}<7D>[<5B>K<EFBFBD>v
|
||
DBG_PRINTF( ("DVDWDM: SetSubpic ScheduleTimer EndPTM wait %d msec \n\r", (Info->EndPTM-tmpSTC)/90 ));
|
||
|
||
LARGE_INTEGER WaitTime;
|
||
|
||
// <20>}<7D>C<EFBFBD>i<EFBFBD>X<EFBFBD>̒l<CC92><6C><EFBFBD>K<EFBFBD>v
|
||
WaitTime = RtlConvertLongToLargeInteger( Info->EndPTM - tmpSTC ) ;
|
||
WaitTime.QuadPart = WaitTime.QuadPart * 1000 / 9 * -1;
|
||
|
||
ASSERT( KeGetCurrentIrql() <= DISPATCH_LEVEL );
|
||
|
||
if( m_SetupEndTimer == FALSE )
|
||
{
|
||
m_SetupEndTimer = TRUE;
|
||
KeSetTimer( &m_EndTimer, WaitTime, &m_HlightEndDPC );
|
||
}
|
||
else
|
||
{
|
||
// <20><><EFBFBD>łɃ^<5E>C<EFBFBD>}<7D>[<5B><><EFBFBD>Z<EFBFBD>b<EFBFBD>g<EFBFBD><67><EFBFBD><EFBFBD><EFBFBD>Ă<EFBFBD><C482><EFBFBD>
|
||
DBG_PRINTF( ("DVDWDM: EndPTM same control 2 !!!!!\n\r\n\r\n\r" ));
|
||
HwSet();
|
||
};
|
||
};
|
||
|
||
|
||
};
|
||
|
||
|
||
void HlightControl::HwSet( void )
|
||
{
|
||
DWORD boardSTC,StreamSTC;
|
||
|
||
SubpHlightStruc NewHlight; // High-light inf structure
|
||
|
||
StreamSTC = (DWORD)(m_pHwDevExt->ticktime.GetStreamTime() * 9 / 1000);
|
||
m_pHwDevExt->mpboard.GetSTC(&boardSTC);
|
||
|
||
// STC<54>̕
|
||
if( m_pHwDevExt->dvdstrm.GetState() == Play )
|
||
StreamSTC = boardSTC;
|
||
|
||
if( // <20>n<EFBFBD>C<EFBFBD><43><EFBFBD>C<EFBFBD>g<EFBFBD>ʒu<CA92><75><EFBFBD>A<EFBFBD><41><EFBFBD><EFBFBD><EFBFBD>ɂȂ<C982><C882>Ă<EFBFBD><C482>邩?
|
||
(m_HlightInfo.StartX==m_HlightInfo.StopX && m_HlightInfo.StartY==m_HlightInfo.StopY)
|
||
// <20><><EFBFBD><EFBFBD><EFBFBD>ȃn<C883>C<EFBFBD><43><EFBFBD>C<EFBFBD>g<EFBFBD>ɂȂ<C982><C882>Ă<EFBFBD><C482>邩?
|
||
|| ( m_HlightInfo.HLISS == 0 )
|
||
// EndPTM<54>̎<EFBFBD><CC8E>ԂɂȂ<C982><C882>Ă<EFBFBD><C482>邩?
|
||
|| (( m_HlightInfo.EndPTM != 0xffffffff ) && (StreamSTC >= m_HlightInfo.EndPTM ))
|
||
)
|
||
{ // Off
|
||
DBG_PRINTF( ("DVDWDM: HighLight(OFF)\n\r") );
|
||
NewHlight.Hlight_Switch = Hlight_Off;
|
||
}
|
||
else
|
||
{ // On
|
||
DBG_PRINTF( ("DVDWDM: HighLight(ON)\n\r") );
|
||
NewHlight.Hlight_Switch = Hlight_On;
|
||
};
|
||
|
||
NewHlight.Hlight_StartX = (DWORD)(m_HlightInfo.StartX);
|
||
NewHlight.Hlight_StartY = (DWORD)(m_HlightInfo.StartY);
|
||
NewHlight.Hlight_EndX = (DWORD)(m_HlightInfo.StopX);
|
||
NewHlight.Hlight_EndY = (DWORD)(m_HlightInfo.StopY);
|
||
NewHlight.Hlight_Color = (DWORD)( m_HlightInfo.ColCon.emph2col<<12 | m_HlightInfo.ColCon.emph1col<<8 | m_HlightInfo.ColCon.patcol<<4 | m_HlightInfo.ColCon.backcol );
|
||
NewHlight.Hlight_Contrast = (DWORD)( m_HlightInfo.ColCon.emph2con<<12 | m_HlightInfo.ColCon.emph1con<<8 | m_HlightInfo.ColCon.patcon<<4 | m_HlightInfo.ColCon.backcon );
|
||
|
||
DBG_PRINTF(( " Set Subpic Hlight! boardSTC=0x%x, startSTC=0x%x, EndSTC=0x%x\r\n",
|
||
boardSTC, m_HlightInfo.StartPTM,m_HlightInfo.EndPTM));
|
||
|
||
DBG_PRINTF( ("-- StartX = %d, StartY = %d, EndX = %d, EndY = %d\n\r",
|
||
NewHlight.Hlight_StartX,NewHlight.Hlight_StartY,NewHlight.Hlight_EndX,NewHlight.Hlight_EndY ));
|
||
|
||
if( NewHlight.Hlight_Switch == Hlight_Off && m_pHwDevExt->dvdstrm.GetState() == Stop )
|
||
{
|
||
DBG_PRINTF( ("DVDWDM: SetSubpic Hilight Decoder Stopping \n\r") );
|
||
return;
|
||
};
|
||
|
||
if( !m_pHwDevExt->dvdstrm.SetSubpicProperty( SubpicProperty_Hilight, &(NewHlight) ) ){
|
||
DBG_PRINTF( ("DVDWDM: SetSubpic Hilight Error\n\r") );
|
||
DBG_BREAK();
|
||
}
|
||
};
|
||
|
||
|
||
//***************************************************************************
|
||
// call back function
|
||
//***************************************************************************
|
||
|
||
void HlightControl::HlightStartDpc( IN PKDPC Dpc, IN PVOID context, IN PVOID arg1, IN PVOID arg2 )
|
||
{
|
||
DBG_PRINTF((" Start DPC !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Irql=%d\r\n", KeGetCurrentIrql() ));
|
||
|
||
HlightControl *This = (HlightControl *)context;
|
||
This->m_SetupStartTimer = FALSE;
|
||
This->HwSet();
|
||
};
|
||
void HlightControl::HlightEndDpc( IN PKDPC Dpc, IN PVOID context, IN PVOID arg1, IN PVOID arg2 )
|
||
{
|
||
DBG_PRINTF((" End DPC !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Irql=%d\r\n", KeGetCurrentIrql() ));
|
||
|
||
HlightControl *This = (HlightControl *)context;
|
||
This->m_SetupEndTimer = FALSE;
|
||
This->HwSet();
|
||
};
|
||
|
||
|
||
//***************************************************************************
|
||
// End of hlight.cpp
|
||
//***************************************************************************
|