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

📄 halgxm.cpp

📁 WinCE 3.0 BSP, 包含Inter SA1110, Intel_815E, Advantech_PCM9574 等
💻 CPP
📖 第 1 页 / 共 3 页
字号:

    TRUE if successful, else FALSE.

****/

BOOL SetVideoDisplay(DWORD * VidCfg, BOOL State)
{
//	DEBUGENTER( SetVideoDisplay );

    if(State == TRUE)   // Enable video output in GXi
        *VidCfg |= VC_VCFG_ENABLE;
    else                // Disable video output in GXi
        *VidCfg &= ~VC_VCFG_ENABLE;

    return(TRUE);
}

/****

NAME: SetVideoFormat

DESCRIPTION

    Selects the video format to UYVY, YUYV, YVYU or RGB

RETURN VALUE

    TRUE if successful, else FALSE.

****/

BOOL SetVideoFormat(DWORD * VidCfg, DWORD Format)
{
	//DEBUGENTER( SetVideoFormat );

	DWORD	VPStatus;
    *VidCfg &= ~VC_VCFG_VID_FMT;
    *VidCfg &= ~VC_VCFG_GV_SCALE_SEL;
    *VidCfg &= ~VC_VCFG_CSC_BYPASS;
    switch(Format)
    {
        case YVYU:
            *VidCfg |= (VC_VF_Y0VY1U << 2);
            break;

        case YUYV:
            *VidCfg |= (VC_VF_Y0UY1V << 2);
            break;

        case UYVY:
            *VidCfg |= (VC_VF_UY0VY1 << 2);
            break;

        case RGB8:
            *VidCfg |= VC_VCFG_GV_SCALE_SEL;
            *VidCfg |= VC_VCFG_CSC_BYPASS;
            break;
// Added the foll -Balaji
// TODO check
        case EMMA:
            *VidCfg &= 0xfffffff3;	// Enable Hi-speed timing + 4:2:0 format
            *VidCfg |= 0x40000008;	// Enable Hi-speed timing + 4:2:0 format
            break;
    }

// This is done to fix a bug when we are using videoport. If videoport is active, then
// then set the right format type.
	if (Format != EMMA) {
	    VPStatus = MEM_READ_32(pDriverData->VIPLinear, 0x00000008);
//jp
		VPStatus &= 0x00000001;
		if(VPStatus == 1) {
			*VidCfg &= 0xfffffff3;
            *VidCfg |= (VC_VF_UY0VY1 << 2);
		}
	}

	//if(pDriverData->ProcessorID >= 0x44)
    //{
    //    if(pDriverData->SysInfo1.CoreLogic == SYSINFO1_CORE_5520)
    //        *VidCfg |= 0x06000000;
    //    else  // 5530 or above
            *VidCfg |= 0x40000000;
    //}
    //else
    //{
    //    *VidCfg |= VC_VCFG_EARLY_RDY;
    //}
    return(TRUE);
}

/****

NAME: SetVideoPosition

DESCRIPTION

    Sets the position and size of the overlay window
    If SizeValid then use passed in Width, Height else
    use saved state.

RETURN VALUE

    TRUE if successful, else FALSE.

****/

BOOL SetVideoPosition(DWORD * VidCfg, DWORD XPos, DWORD YPos, DWORD Width, DWORD Height, BOOL SizeValid)
{
	//DEBUGENTER( SetVideoPosition );

    DWORD PanX, PanY;
//	DWORD VPStatus;
//	DWORD dwtemp;
    static DWORD XSize = 0;
    static DWORD YSize = 0;

    if(SizeValid)
    {
        XSize = Width;
        YSize = Height;
    }

    // Get current pan position
    PanX = pDriverData->wPanX;
    PanY = pDriverData->wPanY;

    if(pDriverData->wPanY > YPos)
    {
        PanY = YPos;
    }
    if(pDriverData->wPanX > XPos)
    {
        PanX = XPos;
    }

#ifdef DURANGO	
	RETAILMSG( 0, ( TEXT("Durango start gfx_set_video_window \n") ) );
	gfx_set_video_window((short)(XPos), (short)(YPos), 
		(unsigned short)XSize, (unsigned short) YSize);
#else
    MEM_WRITE_32(pDriverData->RegLinear, VC_VID_X_POS, 
        ((XPos + XSize + pDriverData->hTiming - PanX) << 16) | 
          XPos + pDriverData->hTiming - PanX);

    MEM_WRITE_32(pDriverData->RegLinear, VC_VID_Y_POS, 
        ((YPos + YSize + pDriverData->vTiming - PanY) << 16) | 
          YPos + pDriverData->vTiming - PanY);
#endif
/*	if (OverlayData.VidFormat != EMMA ) {
	    VPStatus = MEM_READ_32(pDriverData->VIPLinear, 0x00000008);
//jp
		VPStatus &= 0x00000001;
		if(VPStatus == 1) {
		    MEM_WRITE_32(pDriverData->RegLinear, VC_VID_Y_POS, 
				(((YPos + YSize + pDriverData->vTiming - PanY) - 0x28) << 16) | 
		          ((YPos + pDriverData->vTiming - PanY) - 0x28));
			dwtemp = XPos + pDriverData->hTiming - PanX;
			if (dwtemp < 0x40){
				dwtemp = 0;
				MEM_WRITE_32(pDriverData->RegLinear, VC_VID_X_POS, 
					((XPos + XSize + pDriverData->hTiming - PanX) << 16) | 
			          dwtemp);
			}else {
				MEM_WRITE_32(pDriverData->RegLinear, VC_VID_X_POS, 
					((XPos + XSize + pDriverData->hTiming - PanX) << 16) | 
			          ((XPos + pDriverData->hTiming - PanX) - 0x40));
			}

		}
	}
*/
    // Save these for the cursor code to use during panning, also
    // used by SetVideoSource
    pDriverData->Video.XPos = XPos;
    pDriverData->Video.YPos = YPos;
    pDriverData->Video.XSize = XSize;
    pDriverData->Video.YSize = YSize;
    return(TRUE);
}

/****

NAME: SetScaleFactor

DESCRIPTION

    Sets the scale factor for the video overlay window

    VidCfg is a pointer to the value returned by BeginLoad()

RETURN VALUE

    TRUE if successful, else FALSE.

****/

BOOL SetScaleFactor(DWORD * VidCfg, DWORD DstWidth, DWORD DstHeight, DWORD SrcWidth, DWORD SrcHeight)
{
//	DEBUGENTER( SetScaleFactor );

    DWORD XScale, YScale, VPStatus;

// This is done to fix a bug when we are using videoport. If videoport is active, then
// then we multiply the srcheight by 2.
	if (OverlayData.VidFormat != EMMA ) {
	    VPStatus = MEM_READ_32(pDriverData->VIPLinear, 0x00000008);
//jp
		VPStatus &= 0x00000001;
		if(VPStatus == 1) {
			SrcHeight *=2;
			if (SrcHeight > DstHeight)
				SrcHeight = DstHeight;
		}
	}

    XScale = (0x2000 * (SrcWidth - 1)) / (DstWidth - 1);
// jp This is done to fix a bug with emma thru dhruva dvd playback In this mode the max
// scale factor is ff7 instead of 1fff.
	if (OverlayData.VidFormat == EMMA ) {
	    YScale = (0xff8 * (SrcHeight - 1)) / (DstHeight - 1);
		if(YScale < 0x900)
			YScale = 0xff7;
	}
	else
        YScale = (0x2000 * (SrcHeight - 1)) / (DstHeight - 1);

    if(XScale == 0x2000)
    {
        XScale = 0x1FFF;
        *VidCfg &= ~VC_VCFG_X_FILTER_ON;
    }
    else
        *VidCfg |= VC_VCFG_X_FILTER_ON;

    if(YScale == 0x2000)
    {
        YScale = 0x1FFF;
        *VidCfg &= ~VC_VCFG_Y_FILTER_ON;
    }
    else
        *VidCfg |= VC_VCFG_Y_FILTER_ON;

// Right now we always do 1X - jp
//    XScale = 0x1FFF;
//    YScale = 0x1FFF;
    
// jp hack to get rid of the green data underneath the video.
	if (OverlayData.VidFormat != EMMA ) {
		if(VPStatus == 1 ) {
			if(pDriverData->dwWidth == 640) {
				YScale -=0xff;
				XScale = 0x1c00;
			} else {
				YScale -=0x350;
			}
		}
	}

    // Save these for the cursor code to use during panning, also
    // used by SetVideoSource and SetVideoOffset
    pDriverData->Video.XScale = XScale;
    pDriverData->Video.YScale = YScale;

    MEM_WRITE_32(pDriverData->RegLinear, VC_VID_SCALE, (YScale << 16) | XScale);
//jp
	if (OverlayData.VidFormat != EMMA ) {
		if(VPStatus == 1 ) {
			SrcHeight /=2;
		}
	}

    return(TRUE);
}

BOOL DhruvaSetScale(DWORD * VidCfg, DWORD DstWidth, DWORD DstHeight, DWORD SrcWidth, DWORD SrcHeight)
{
//	DEBUGENTER( DhruvaSetScale );

    DWORD XScale, YScale, VPStatus;

// This is done to fix a bug when we are using videoport. If videoport is active, then
// then we multiply the srcheight by 2.
	if (OverlayData.VidFormat != EMMA ) {
	    VPStatus = MEM_READ_32(pDriverData->VIPLinear, 0x00000008);
//jp
		VPStatus &= 0x00000001;
		if(VPStatus == 1) {
			SrcHeight *=2;
			if (SrcHeight > DstHeight)
				SrcHeight = DstHeight;
		}
	}

    XScale = (0x2000 * (SrcWidth - 1)) / (DstWidth - 1);
// jp This is done to fix a bug with emma thru dhruva dvd playback In this mode the max
// scale factor is ff7 instead of 1fff.
	if (OverlayData.VidFormat == EMMA ) {
	    YScale = (0xff8 * (SrcHeight - 1)) / (DstHeight - 1);
		if(YScale < 0x900)
			YScale = 0xff7;
	}
	else
        YScale = (0x2000 * (SrcHeight - 1)) / (DstHeight - 1);

    if(XScale == 0x2000)
    {
        XScale = 0x1FFF;
        *VidCfg &= ~VC_VCFG_X_FILTER_ON;
    }
    else
        *VidCfg |= VC_VCFG_X_FILTER_ON;

    if(YScale == 0x2000)
    {
        YScale = 0x1FFF;
        *VidCfg &= ~VC_VCFG_Y_FILTER_ON;
    }
    else
        *VidCfg |= VC_VCFG_Y_FILTER_ON;

// Right now we always do 1X - jp
//    XScale = 0x1FFF;
//    YScale = 0x1FFF;
    
// jp hack to get rid of the green data underneath the video.
	if (OverlayData.VidFormat != EMMA ) {
		if(VPStatus == 1 ) {
			if(pDriverData->dwWidth == 640) {
				YScale -=0xff;
				XScale = 0x1c00;
			} else {
				YScale -=0x350;
			}
		}
	}

    // Save these for the cursor code to use during panning, also
    // used by SetVideoSource and SetVideoOffset
    pDriverData->Video.XScale = XScale;
    pDriverData->Video.YScale = YScale;

    MEM_WRITE_32(pDriverData->RegLinear, VC_VID_SCALE, (YScale << 16) | XScale);
//jp
	if (OverlayData.VidFormat != EMMA ) {
		if(VPStatus == 1 ) {
			SrcHeight /=2;
		}
	}

    return(TRUE);
}

/****

NAME: SetVideoSource

DESCRIPTION

    Sets the source data line size, left clipping, and MPEG2 field
     
    VidCfg is a pointer to the value returned by BeginLoad()

RETURN VALUE

    TRUE if successful, else FALSE.

****/

BOOL SetVideoSource(DWORD * VidCfg, DWORD XPos, DWORD Pitch)
{
	DWORD VPStatus;
//	DEBUGENTER( SetVideoSource );

    pDriverData->Video.Pitch = Pitch;
    pDriverData->Video.XClip = XPos;

    *VidCfg &= ~VC_VCFG_LINE_SIZE;
    *VidCfg &= ~VC_VCFG_INIT_RD_ADDR;
    *VidCfg &= ~VC_VCFG_LINE_SIZE_MSB;
    *VidCfg &= ~VC_VCFG_MPEG2_ON;

    // Set INIT_RD_ADDR for left clipping
    if(pDriverData->wPanX > pDriverData->Video.XPos)
    {
        XPos += ((pDriverData->wPanX - pDriverData->Video.XPos) * 
                 pDriverData->Video.XScale) / 0x1FFF;
    }
    *VidCfg |= ((WORD)XPos >> 1) << 16;

	if (pDriverData->DeviceID == DHRUVA) {
		if (OverlayData.VidFormat != EMMA ) {
		    VPStatus = MEM_READ_32(pDriverData->VIPLinear, 0x00000008);
//jp	
			VPStatus &= 0x00000001;
			if(VPStatus == 1) {
			    *VidCfg &= (0xff00) << 16;
			    *VidCfg |= (0x0028) << 16;
			}
		}
	}

    //if(pDriverData->SysInfo1.CoreLogic == SYSINFO1_CORE_5520)
    //{
    //    // Check if MPEG2 and set the Pitch
    //    if(Pitch > 768)
    //    {
    //        *VidCfg |= ((Pitch >> 3) & 0xFF) << 8;
    //        *VidCfg |= VC_VCFG_MPEG2_ON;
    //    }
    //    else
    //    {
    //        *VidCfg |= ((Pitch >> 2) & 0xFF) << 8;
    //        *VidCfg &= ~VC_VCFG_MPEG2_ON;
    //    }
    //}
    //else
    //{
        *VidCfg |= ((Pitch >> 2) & 0xFF) << 8;
        if((Pitch >> 2) & 0x100)
        {
            *VidCfg |= VC_VCFG_LINE_SIZE_MSB;
        }
    //}
    return(TRUE);
}

/****

NAME: BeginLoad

DESCRIPTION

    Setup the hardware to not latch register writes.

    VidCfg is a pointer to be filled in by this function
    which will contain the state of the VC_VID_CFG register.

RETURN VALUE

    TRUE if successful, else FALSE.

****/

BOOL BeginLoad(DWORD * VidCfg)
{
//	DEBUGENTER( BeginLoad );

    *VidCfg = MEM_READ_32(pDriverData->RegLinear, VC_VID_CFG);
    *VidCfg &= ~VC_VCFG_REG_UPDATE;
    MEM_WRITE_32(pDriverData->RegLinear, VC_VID_CFG, *VidCfg);

    return(TRUE);
}

/****

NAME: EndLoad

DESCRIPTION

    Setup the hardware to latch register writes on next VSYNC

    VidCfg contains the state of the VC_VID_CFG register to
    be loaded into the hardware.

RETURN VALUE

    TRUE if successful, else FALSE.

****/

BOOL EndLoad(DWORD VidCfg)
{
//	DEBUGENTER( EndLoad );

    VidCfg |= VC_VCFG_REG_UPDATE;
    MEM_WRITE_32(pDriverData->RegLinear, VC_VID_CFG, VidCfg);

    return(TRUE);
}


#endif //DD_SUPPORT

⌨️ 快捷键说明

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