⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 osdadjust.c

📁 GM5621原代码
💻 C
字号:
/*
	$Workfile:   OsdAdjust.c  $
	$Revision:   1.34  $
	$Date:   May 18 2006 03:33:00  $
*/
//******************************************************************
//
//          Copyright (C) 2002. GENESIS MICROCHIP INC.
//  All rights reserved.  No part of this program may be reproduced.
//
//	Genesis Microchip Corp., 2150 Gold Street
//			Alviso, CA 95002	USA
//  Genesis Microchip Inc., 165 Commerce Valley Dr. West
//          Thornhill, Ontario, Canada, L3T 7V8
//
//================================================================
//
//  MODULE: OsdAdjust.c
//
//  USAGE : This module contains osd adjuster functions
//
//
//******************************************************************
#include ".\inc\all.h"
#include "math.h"
//******************************************************************
//	L O C A L   D E F I N I T I O N S
//******************************************************************
#define 	xDEBUG_OSD

// flags of vertical and horizontal positionings
#define 	H_POS_ADJ 1
#define 	V_POS_ADJ 0

// floating window parameters
#define NO_SYNC_OSD_MAX_X NUM_OSD_POSITIONS
#define NO_SYNC_OSD_MIN_X 1
#define NO_SYNC_OSD_MAX_Y NUM_OSD_POSITIONS
#define NO_SYNC_OSD_MIN_Y 1
#define NO_SYNC_OSD_X_STEPS 1
#define NO_SYNC_OSD_Y_STEPS 1
#define	FLOATING_RATE_UNIT_MS	20
#define	FLOATING_RATE_PREF		1

//******************************************************************
//	G L O B A L   V A R I A B L E S
//******************************************************************
BYTE ROM SM_EventTable[] = 
{ 
    OE_EnterState,
    OE_ExitState,
    OE_TransitionComplete,
    OE_AnyEvent
};

extern DWORD D_PrevSysTimer;				// prev. time
//******************************************************************
//	C O D E
//******************************************************************
static BYTE __near calcExtraTime(void)
{
	DWORD D_CurTime = gm_ReadSystemTime();	// current time
	// if CheckOSDTimers() hasn't been run in a while (after a long Auto Adjust
	// for instance) then see how much time we should add to our new timer
	// so it doesn't time out early.  Otherwise if D_PrevSysTimer is 2 seconds
	// away from D_CurTime, then when ChckOSDTimers() runs, we'll lose 2 seconds
	// off our time.
	return (BYTE)(labs(D_CurTime - D_PrevSysTimer) / (W_OsdTimerResolution * 10));

}

void far ResetOSDTimer()
{

	#ifdef DEBUG_OSD
		gm_Print("Reset osd timer", 0);
	#endif
	// if CheckOSDTimers() hasn't been run in a while (after a long Auto Adjust
	// for instance) then see how much time we should add to our new timer
	// so it doesn't time out early.  Otherwise if D_PrevSysTimer is 2 seconds
	// away from D_CurTime, then when ChckOSDTimers() runs, we'll lose 2 seconds
	// off our time.
	gW_OsdTimers[B_OSD_TimeoutTid] = UserPrefOSDTimeout + calcExtraTime();
}


void far ResetTimer()
{
	OsdTimerData	Un_Timer;
	Un_Timer.D_Value = gm_OsdGetCurrentSATOffsetDWord();
   if (Un_Timer.OsdTimer.TimerVal == 0)
      gW_OsdTimers[(Un_Timer.OsdTimer.TimerId & TIMER_ID_MASK)] = 0;
   else
      gW_OsdTimers[(Un_Timer.OsdTimer.TimerId & TIMER_ID_MASK)] = Un_Timer.OsdTimer.TimerVal + calcExtraTime();
	#ifdef DEBUG_OSD
		gm_Print("ResetTimer %d", Un_Timer.OsdTimer.TimerId & TIMER_ID_MASK);
		gm_Print("Timer Count = %d", gW_OsdTimers[Un_Timer.OsdTimer.TimerId & TIMER_ID_MASK]);
	#endif
}


void far SetPowerOnFlag()
{
    UserPrefSwitches |= PowerOn;
    #ifdef DEBUG_OSD
	    gm_Print("PowerOnFlag = %d", UserPrefSwitches);
    #endif
}


void far ClearPowerOnFlag()
{
    UserPrefSwitches &= ~PowerOn;
    #ifdef DEBUG_OSD
	    gm_Print("PowerOnFlag = %d", UserPrefSwitches);
    #endif
}

BYTE far GetPowerOnFlag(void)
{
#ifdef NVRAM_BLOCK_ModeIndependentUserPreferences_WB_Used
	return(UserPrefSwitches & PowerOn);
#else // if not stored in NVRAM then always come on when power restored.
	return gmd_TRUE;
#endif //NVRAM_BLOCK_ModeIndependentUserPreferences_WB_Used
}


void far RequestSoftPowerOff()
{
    SendMsg(&PowerHandlerQ, MTP_SOFTKEY_OFF);

    #ifdef DEBUG_OSD
		gm_Print ("RequestSoftPowerOff",0);
    #endif

#if 0//!defined(TUCSON) && ENABLE_HDCP && NEW_HDCP_SEQ
    gm_ClearRegBitsByte(HDCP_CONTROL, HDCP_EN);	 
    gm_WriteRegByte(HDCP_ADDR, 0);
#endif

}


void far RequestSoftPowerOn()
{
    SendMsg(&PowerHandlerQ, MTP_SOFTKEY_ON);

    #ifdef DEBUG_OSD
    	gm_Print ("RequestSoftPowerOn",0);
    #endif
}


void far RequestNoSyncSleep()  	
{
    #ifdef DEBUG_OSD
	    gm_Print ("RequestNoSyncSleep",0);
    #endif
}


void far SendPowerDownMessage()
{
    SendMsg(&PowerHandlerQ, MTP_POWER_DOWN);
    #ifdef DEBUG_OSD
	    gm_Print ("SendPowerDownMessage",0);
    #endif
}


void far SetSplashScreenOff()
{
    SystemFlags.SplashScreen = gmd_FALSE;
    InitModeHandler();
}


#ifdef Action_AdjustOsdHPos_WB_Used
void far AdjustOsdHPos()
{
    PositionAdjDialog (H_POS_ADJ, ADJV_HPosOSD);
    #ifdef DEBUG_OSD
	    gm_Print ("AdjustOsdHPos",0);
    #endif
}
#endif

#ifdef Action_AdjustOsdVPos_WB_Used
void far AdjustOsdVPos()
{
    PositionAdjDialog (V_POS_ADJ, ADJV_VPosOSD);
    #ifdef DEBUG_OSD
	    gm_Print ("AdjustOsdHPos",0);
    #endif
}
#endif


void far AdjustOsdHVPos()
{
    PositionAdjDialog (H_POS_ADJ, ADJV_HPosOSD);
    #ifdef DEBUG_OSD
	    gm_Print ("AdjustOsdHVPos",0);
    #endif
}

#ifdef Action_StartFloating_WB_Used
void far OsdFloating(void)
{
	static WORD B_OsdXDirection = NO_SYNC_OSD_X_STEPS;
	static WORD B_OsdYDirection = NO_SYNC_OSD_Y_STEPS;

	UserPrefMenuXPos += B_OsdXDirection;
	UserPrefMenuYPos += B_OsdYDirection;

	if(((UserPrefMenuXPos + NO_SYNC_OSD_X_STEPS) > NO_SYNC_OSD_MAX_X) ||
	((UserPrefMenuXPos - NO_SYNC_OSD_X_STEPS) < NO_SYNC_OSD_MIN_X))
		B_OsdXDirection = -B_OsdXDirection;

	if(((UserPrefMenuYPos + NO_SYNC_OSD_Y_STEPS) > NO_SYNC_OSD_MAX_Y) ||
	((UserPrefMenuYPos - NO_SYNC_OSD_Y_STEPS)< NO_SYNC_OSD_MIN_Y))
		B_OsdYDirection = -B_OsdYDirection;

	PositionAdjDialog (H_POS_ADJ, ADJV_MenuXPos);
}
#endif

#ifdef Action_DoAutoConfig_WB_Used
void far DoAutoConfig()
{
    #ifdef DEBUG_OSD
		gm_Print ("DoAutoConfig",0);
    #endif
}
#endif

//
// Audio adjusters
//
#ifdef Action_AdjustAudioBalance_WB_Used
void far AdjustAudioBalance()
{
    #ifdef DEBUG_OSD
		gm_Print ("AdjustAudioBalance",0);
    #endif
}
#endif

#ifdef Action_AdjustAudioVolume_WB_Used
void far AdjustAudioVolume()
{
    #ifdef DEBUG_OSD
		gm_Print ("AdjustAudioVolume",0);
    #endif
}
#endif

#ifdef Action_AdjustBlackLevel_WB_Used
void far AdjustBlackLevel()
{
    #ifdef DEBUG_OSD
		gm_Print ("AdjustBlackLevel",0);
    #endif

   // for black level
   AdjustColor();
}
#endif

#ifdef Action_AdjustGammaMoire_WB_Used
void far AdjustGammaMoire()		
{
    #ifdef DEBUG_OSD
		gm_Print ("AdjustGammaMoire",0);
    #endif
}
#endif

#ifdef Action_AdjustOSDTimeout_WB_Used
void far AdjustOSDTimeout()		
{
    #ifdef DEBUG_OSD
		gm_Print ("AdjustOSDTimeout",0);
    #endif
}
#endif

#ifdef Action_AdjustsRGB_WB_Used
void far AdjustsRGB()  			
{
    #ifdef DEBUG_OSD
		gm_Print ("AdjustsRGB",0);
    #endif
}
#endif

#ifdef Action_InputSelect_WB_Used
void far InputSelect()  		
{
    #ifdef DEBUG_OSD
		gm_Print ("InputSelect",0);
    #endif
}
#endif


#ifdef TestPrimitives_WB_Used
ROM BYTE Test_Attribs[] = { 0x3d, 0x3d,0x3d,0x3d };
ROM BYTE Font16x16_1BPP[] =
{
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x0F, 0xFF, 0x03, 0xFF, 0x01,
0xFF, 0x00, 0x7F, 0x00, 0x3F, 0x00, 0x3F, 0x00, 0x1F, 0x00, 0x1F, 0x00, 0x1F, 0x00, 0x1F, 0x00,
};

ROM BYTE Font16x16_2BPP[] =
{
0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0x56,
0xAA, 0xAA, 0x5A, 0x55, 0xAA, 0xAA, 0x56, 0x55, 0xAA, 0xAA, 0x55, 0x55, 0xAA, 0x6A, 0x55, 0x55,
0xAA, 0x5A, 0x55, 0x05, 0xAA, 0x56, 0x55, 0x00, 0xAA, 0x55, 0x15, 0x00, 0xAA, 0x55, 0x05, 0x00,
0xAA, 0x55, 0x05, 0x00, 0x6A, 0x55, 0x01, 0x00, 0x6A, 0x55, 0x01, 0x00, 0x6A, 0x55, 0x01, 0x00,
};

ROM BYTE Font16x16_4BPP[] =
{
0x50, 0x55, 0x55, 0x55, 0x30, 0x33, 0x33, 0x33, 0x01, 0x55, 0x55, 0x55, 0x05, 0x33, 0x33, 0x33,
0x11, 0x50, 0x55, 0x55, 0x55, 0x30, 0x33, 0x33, 0x11, 0x01, 0x55, 0x55, 0x55, 0x05, 0x33, 0x33,
0x11, 0x11, 0x50, 0x55, 0x55, 0x05, 0x30, 0x33, 0x11, 0x11, 0x01, 0x55, 0x55, 0x60, 0x06, 0x33,
0x11, 0x11, 0x11, 0x50, 0x05, 0x66, 0x66, 0x30, 0x11, 0x11, 0x11, 0x01, 0x60, 0x66, 0x66, 0x06,
0x10, 0x11, 0x11, 0x01, 0x60, 0x66, 0x66, 0x66, 0x02, 0x11, 0x11, 0x40, 0x04, 0x66, 0x66, 0x66,
0x22, 0x10, 0x01, 0x44, 0x44, 0x60, 0x66, 0x66, 0x22, 0x02, 0x40, 0x44, 0x44, 0x04, 0x66, 0x66,
0x22, 0x22, 0x40, 0x44, 0x44, 0x44, 0x60, 0x66, 0x22, 0x22, 0x02, 0x44, 0x44, 0x44, 0x04, 0x66,
0x22, 0x22, 0x22, 0x40, 0x44, 0x44, 0x44, 0x60, 0x22, 0x22, 0x22, 0x02, 0x44, 0x44, 0x44, 0x04,
};

void far TestPrimitives(void)
{
/*

1bpp hw indices: 	0xc1, 0xc2, 0xc3, 0xc4
attribute: 0x3d

2bpp hw indices:  	0x00, 0x01, 0x02, 0x03
Attrib: 0x80

4bpp hw indices:    0x02
Attrib: 0xc0

*/

    BYTE op;
    op = OsdGetCurrentSATOffsetByte();
    switch( op )
    {
    case 0: // OsdC_FillRect_Char
        // OsdC_FillRect_Char (BYTE xPos, BYTE yPos, BYTE width, BYTE height, BYTE character)
        // OsdC_FillRect_Attrib(BYTE xPos, BYTE yPos, BYTE width, BYTE height, BYTE attribute)
        gm_Print( "****Test: OsdC_FillRect_Char, OsdC_FillRect_Attrib****", 0 );
        OsdC_FillRect_Char (10, 16, 2, 2, 0xc1);
        OsdC_FillRect_Attrib(10, 16, 2, 2, 0x3d);
        break;

    case 1: // OsdC_SetIconAttrib
        {
            //OsdC_SetIcon_Attrib  (BYTE xPos, BYTE yPos, BYTE width , BYTE height, BYTE far *pntTbl);
            OsdC_FillRect_Char (14, 16, 2, 2, 0xc2);
            OsdC_SetIcon_Attrib  (14, 16, 2 , 2, (BYTE far *)(&Test_Attribs[0]));
        }
        break;

    case 2: // OsdC_LoadIcon
        {
            WORD Addr1bpp;
            WORD Addr2bpp;
            WORD Addr4bpp;

            Addr1bpp = OsdC_FontAddress(0, 0xc1);
            Addr2bpp = OsdC_FontAddress(2, 0x00);
            Addr4bpp = OsdC_FontAddress(3, 0x02);
            
            gm_Print( "Addr1bpp %x", Addr1bpp);
            gm_Print( "Addr2bpp %x", Addr2bpp);
            gm_Print( "Addr4bpp %x", Addr4bpp);

            // Clear fonts
            OsdC_CCFFill(Addr1bpp, 16, 0);
            OsdC_CCFFill(Addr2bpp, 32, 0);
            OsdC_CCFFill(Addr4bpp, 64, 0);

            // Reload the same fonts
            //void far gm_OsdC_LoadIcon(BYTE tblId, BYTE index_Table, WORD size, BYTE *pntTbl);
            //OsdC_LoadIcon(0, 0xc1, 32, Font16x16_1BPP);
            //OsdC_LoadIcon(2, 0x00, 64, Font16x16_2BPP);
            //OsdC_LoadIcon(3, 0x02, 128, Font16x16_4BPP);
        }
        break;
    }
}
#endif

#ifdef Action_AdjustOsdDirection_WB_Used
void far AdjustOsdDirection (void)
{
	gm_OsdC_SetDirection(UserPrefOsdDirection);
}
#endif

#ifdef Action_InitPanelNameForDynamicControl_WB_Used
#include <embedded.h>
#if USING_PANEL_ARRAY
extern PanelArrayType ROM PanelArray[];
#define	PANEL_NAME	PanelArray[B_PanelIndex].Name
#else
char c_PanelName[]=PanelName;
#define	PANEL_NAME	c_PanelName
#endif

void far InitPanelNameForDynamicControl(void)
{
	UserPrefPtrSegment	=	FP_SEG(PANEL_NAME);
	UserPrefPtrOffset	=	FP_OFF(PANEL_NAME);
}
#endif

#ifdef Action_ChangeLockUnlockOSD_WB_Used 
void far ChangeLockUnlockOSD(void)
{
	if(UserPrefLockUnlockOSD)
   {
		UserPrefLockUnlockOSD = 0;
  		//gm_Print("Change flag => %d ",UserPrefLockUnlockOSD);
   }
   else
   {
   	UserPrefLockUnlockOSD = 1;
  		//gm_Print("Change flag => %d ",UserPrefLockUnlockOSD);      
   }

}
#endif

#ifdef Action_SelectOnOffBitmapButton_WB_Used
void far SelectOnOffBitmapButton(void)
{
	BYTE B_CsIndex = 1;
	ST_OSD_ONOFFBITMAPBUTTON_CTRL ROM* Sp_Ctrl = (ST_OSD_ONOFFBITMAPBUTTON_CTRL ROM*)gm_GetTileActionOperand();
    if(gm_GetAdjusterValue(Sp_Ctrl->Accociate) == Sp_Ctrl->ControlID)
    	B_CsIndex = 3;
    gm_DrawBitmapBase((ST_OSD_BITMAPBUTTON_CTRL ROM*)Sp_Ctrl ,B_CsIndex);
}
#endif //Action_SelectOnOffBitmapButton_WB_Used

#ifdef Action_UnselectOnOffBitmapButton_WB_Used
void far UnselectOnOffBitmapButton(void)
{
	BYTE B_CsIndex = 0;
	ST_OSD_ONOFFBITMAPBUTTON_CTRL ROM* Sp_Ctrl = (ST_OSD_ONOFFBITMAPBUTTON_CTRL ROM*)gm_GetTileActionOperand();
    if(gm_GetAdjusterValue(Sp_Ctrl->Accociate) == Sp_Ctrl->ControlID)
    	B_CsIndex = 2;
    gm_DrawBitmapBase((ST_OSD_BITMAPBUTTON_CTRL ROM*)Sp_Ctrl ,B_CsIndex);
}
#endif //Action_UnselectOnOffBitmapButton_WB_Used

#ifdef Action_ResetOnOffBitmapButton_WB_Used
void far ResetOnOffBitmapButton(void)
{
	ST_OSD_ONOFFBITMAPBUTTON_CTRL ROM* Sp_Ctrl = (ST_OSD_ONOFFBITMAPBUTTON_CTRL ROM*)gm_GetTileActionOperand();
    if(gm_GetAdjusterValue(Sp_Ctrl->Accociate) == Sp_Ctrl->ControlID)
    {
    	gm_SetAdjusterValue (Sp_Ctrl->Accociate, 0);
    	gm_DrawBitmapBase((ST_OSD_BITMAPBUTTON_CTRL ROM*)Sp_Ctrl ,1);
    }
}
#endif //Action_ResetOnOffBitmapButton_WB_Used


#ifdef Action_SetOnOffBitmapButton_WB_Used
void far SetOnOffBitmapButton(void)
{
	ST_OSD_ONOFFBITMAPBUTTON_CTRL ROM* Sp_Ctrl = (ST_OSD_ONOFFBITMAPBUTTON_CTRL ROM*)gm_GetTileActionOperand();
    gm_SetAdjusterValue (Sp_Ctrl->Accociate, Sp_Ctrl->ControlID);
    gm_DrawBitmapBase((ST_OSD_BITMAPBUTTON_CTRL ROM*)Sp_Ctrl ,3);
}
#endif //Action_SetOnOffBitmapButton_WB_Used


#ifdef Action_ToggleOnOffBitmapButton_WB_Used
void far ToggleOnOffBitmapButton(void)
{
	BYTE B_Val;
	ST_OSD_ONOFFBITMAPBUTTON_CTRL ROM* Sp_Ctrl = (ST_OSD_ONOFFBITMAPBUTTON_CTRL ROM*)gm_GetTileActionOperand();
    B_Val = (BYTE)gm_GetAdjusterValue(Sp_Ctrl->Accociate);
	if(B_Val != Sp_Ctrl->ControlID)
    {
        gm_SetAdjusterValue (Sp_Ctrl->Accociate, Sp_Ctrl->ControlID);
        gm_DrawBitmapBase((ST_OSD_BITMAPBUTTON_CTRL ROM*)Sp_Ctrl ,3);		
    }
	else
    {
    	gm_SetAdjusterValue (Sp_Ctrl->Accociate, 0);
    	gm_DrawBitmapBase((ST_OSD_BITMAPBUTTON_CTRL ROM*)Sp_Ctrl ,1);
    }
}
#endif //Action_ToggleOnOffBitmapButton_WB_Used

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -