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

📄 sa2video.cpp

📁 Xcale270Bsp包,wince平台
💻 CPP
📖 第 1 页 / 共 4 页
字号:
						return S_OK;
					}
				}
			}
		}

		
		if(FAILED(code))
			return code;

		DispDrvrDirtyRectDump((LPRECT)&bounds);
	}
	return code;
}

SCODE SA2Video::BltPrepare(GPEBltParms *pBltParms)
{
	DEBUGMSG(GPE_ZONE_LINE,(TEXT("SA2Video::BltPrepare\r\n")));

	if(pBltParms->pDst != m_pPrimarySurface)
		pBltParms->pBlt = EmulatedBlt;
	else
		pBltParms->pBlt = (SCODE (GPE::*)(struct GPEBltParms *))WrappedEmulatedBlt;
	return S_OK;
}

// This function would be used to undo the setting of clip registers etc

SCODE SA2Video::BltComplete(GPEBltParms *pBltParms)
{
	return S_OK;
}

int SA2Video::InVBlank(void)
{
#ifdef DD_ENABLE
	static	BOOL	value = FALSE;
	DEBUGMSG (GPE_ZONE_INIT, (TEXT("SA2Video::InVBlank\r\n")));
	value = !value;
	return value;
#else
	return 0;
#endif
}

SCODE SA2Video::SetPalette(const PALETTEENTRY *source,unsigned short firstEntry,unsigned short numEntries)
{
    if (bpp==8) 
	{
		if (firstEntry < 0 || firstEntry + numEntries > 256) {
			return E_INVALIDARG;
		}
		DispDrvrSetPalette(source,firstEntry,numEntries);
	}
	return S_OK;
}


ULONG *APIENTRY DrvGetMasks(DHPDEV dhpdev)
{
        return BitMasks;
}

/* add new function by Xiexy 06-09-05 */
VIDEO_POWER_STATE
PmToVideoPowerState(CEDEVICE_POWER_STATE pmDx)
{
	VIDEO_POWER_STATE vps;

	switch(pmDx) {
	case D0:        // turn the display on
		vps = VideoPowerOn;
		break;

	case D1:        // if asked for a state we don't support, go to the next lower one
	case D2:
	case D3:
	case D4:
		vps = VideoPowerOff;
		break;

	default:
		DEBUGMSG(1, (L"PmToVideoPowerState: mapping unknown PM state %d to VideoPowerOn\r\n", pmDx));
		vps = VideoPowerOn;
		break;
	}

	return vps;
}
/* end of new function by Xiexy */

/* add new function by Xiexy 06-09-05 */
// this routine maps video power states to PM power states.
CEDEVICE_POWER_STATE
VideoToPmPowerState(VIDEO_POWER_STATE vps)
{
	CEDEVICE_POWER_STATE pmDx;

	switch(vps)
	{
	case VideoPowerOn:
		pmDx = D0;
		break;

	case VideoPowerStandBy:
		pmDx = D1;
		break;

	case VideoPowerSuspend:
		pmDx = D2;
		break;

	case VideoPowerOff:
		pmDx = D4;
		break;

	default:
		pmDx = D0;
		DEBUGMSG(1, (L"VideoToPmPowerState: mapping unknown video state %d to pm state %d\r\n",
		         vps, pmDx));
		break;
	}

	return pmDx;
}
/* end of new function by Xiexy */

ULONG SA2Video::DrvEscape(SURFOBJ *pso, ULONG iEsc, ULONG cjIn, PVOID pvIn, ULONG cjOut, PVOID pvOut)
{
    int RetVal = 0; // default return value: "not supported"
	DWORD EscapeFunction;
	GXDeviceInfo *pgxoi;
	
	// 新增调试信息
	//RETAILMSG(1,(TEXT("Entern ControlLCD!\r\n")));

#ifndef BSP_NOIPM
	VIDEO_POWER_MANAGEMENT *vpm;
	static HANDLE	DisplayInactivityTOEvent;
	static int FirstTime;
#endif

    switch (iEsc) {

#ifndef BSP_NOIPM
		case SETPOWERMANAGEMENT:

				if(FirstTime==0)
				{
					DisplayInactivityTOEvent = CreateEvent(NULL, FALSE, FALSE, DISPLAY_INACTIVITY_TO_STR);
					FirstTime++;
				}
				
				vpm = (VIDEO_POWER_MANAGEMENT *)pvIn;
				if(vpm->PowerState == VideoPowerSuspend)
				{
//					NKDbgPrintfW(TEXT("SuspendiGamma\r\n"));
					SetEvent(DisplayInactivityTOEvent);
				}
				break;
#endif
		
		case QUERYESCSUPPORT:
			EscapeFunction = *(DWORD *)pvIn;
			if ((EscapeFunction == GETVFRAMEPHYSICAL)	||
				(EscapeFunction == GETVFRAMELEN)		||
				(EscapeFunction == GETPALETTERAMPHYSICAL) ||
				(EscapeFunction == VERTICALBLANKINTERRUPT) ||
				(EscapeFunction == SCROLL)				||
				(EscapeFunction == OVERLAY2_ENABLE)		||
				(EscapeFunction == OVERLAY2_DISABLE)	||
				(EscapeFunction == OVERLAY1_ENABLE)		||
				(EscapeFunction == OVERLAY1_DISABLE)	||
				(EscapeFunction == GET_OVERLAY1_ADDRESS)||
				(EscapeFunction == GET_OVERLAY2_ADDRESS)||
				(EscapeFunction == CAMERA_INITIALIZE)||
				(EscapeFunction == CAMERA_START_VIDEO_CAPTURE)||
				(EscapeFunction == CAMERA_STOP_VIDEO_CAPTURE)||
				(EscapeFunction == CAMERA_RELEASE_FRAME)||
				(EscapeFunction == GETGXINFO))
				RetVal = 1;
            break;

		// Provide the mapped virtual address of the frame buffer ram
		// for direct frame buffer manipulation.
		case GETVFRAMEPHYSICAL: 
			if (cjIn < NUM_FRAME_BUFFERS)
			{
				// This works as long as the frame buffers are in a contiguous region.
				*(DWORD *)pvOut = (ULONG)FRAME_BUFFER_0_BASE_VIRTUAL + cjIn * (DispDrvr_cdwStride * DispDrvr_cyScreen);
				RetVal = 1;
			} else
			{
				*(DWORD *)pvOut = NULL;
			}
			break;

		// Provide the length of the frame buffer in bytes
		case GETVFRAMELEN:
			*(DWORD *)pvOut = (ULONG)DispDrvr_cdwStride * DispDrvr_cyScreen;
			RetVal = 1;
			break;

		// Provide the mapped virtual address of the palette ram
		// for direct palette buffer manipulation.
		case GETPALETTERAMPHYSICAL:
			*(DWORD *)pvOut = (ULONG)PALETTE_BUFFER_BASE_VIRTUAL;
			RetVal = 1;
			break;
		case VERTICALBLANKINTERRUPT:
			RetVal = 1;
			break;

		case SCROLL:
			ScrollBuffer(cjIn);
			break;

		case OVERLAY2_ENABLE:
			Overlay2_Enable((P_XLLP_OVERLAY_T)pvIn);
			RetVal = 1;			
			break;

		case OVERLAY2_DISABLE:
			Overlay2_Disable((P_XLLP_OVERLAY_T)pvIn);

			RetVal = 1;			
			break;

		case GET_OVERLAY1_ADDRESS:
			RetVal = 1;			
			break;

		case GET_OVERLAY2_ADDRESS:

			RetVal = 1;
			// Check the DMA length to see if everything will fit into SRAM.
			// If it does, then locate the descriptors and the frame buffers there.
			// Otherwise, locate it in external memory.
			Overlay2_DMA_Length((P_XLLP_OVERLAY_T)pvIn);

			if ((((P_XLLP_OVERLAY_T)pvIn)->ch2_size + ((P_XLLP_OVERLAY_T)pvIn)->ch3_size + ((P_XLLP_OVERLAY_T)pvIn)->ch4_size) <= 0x3FFA0) // 0x40000 is the SRAM size - 0x60 for the three descriptors 
				// if using RGB or packed mode, there's only one descriptor, so this would really only use 0x20
			{
				
				XllpLCD._OVERLAY2_Y_CHANNEL_BASE_PHYSICAL = OVERLAY2_SRAM_PHYSICAL_BASE_ADDRESS;
				XllpLCD._OVERLAY2_Cb_CHANNEL_BASE_PHYSICAL = OVERLAY2_SRAM_PHYSICAL_BASE_ADDRESS + ((P_XLLP_OVERLAY_T)pvIn)->ch2_size;
				XllpLCD._OVERLAY2_Cr_CHANNEL_BASE_PHYSICAL = OVERLAY2_SRAM_PHYSICAL_BASE_ADDRESS + ((P_XLLP_OVERLAY_T)pvIn)->ch2_size + ((P_XLLP_OVERLAY_T)pvIn)->ch3_size;
				XllpLCD._DMA_CHANNEL_2_Y_FRAME_DESCRIPTOR_BASE_PHYSICAL = SRAM_DMA_CHANNEL_2_Y_FRAME_DESCRIPTOR_BASE_PHYSICAL;
				XllpLCD._DMA_CHANNEL_3_Cb_FRAME_DESCRIPTOR_BASE_PHYSICAL = SRAM_DMA_CHANNEL_3_Cb_FRAME_DESCRIPTOR_BASE_PHYSICAL;
				XllpLCD._DMA_CHANNEL_4_Cr_FRAME_DESCRIPTOR_BASE_PHYSICAL = SRAM_DMA_CHANNEL_4_Cr_FRAME_DESCRIPTOR_BASE_PHYSICAL;

				if (frameDescriptorCh2_YCbCr_Y)
					VirtualFree((PVOID)frameDescriptorCh2_YCbCr_Y,0,MEM_RELEASE);

				frameDescriptorCh2_YCbCr_Y = (volatile LCD_FRAME_DESCRIPTOR *)VirtualAllocCopy(sizeof(LCD_FRAME_DESCRIPTOR), "DispDrvrInitialize : lcdFrameDescriptor", (PVOID)(SRAM_DMA_CHANNEL_2_Y_FRAME_DESCRIPTOR_BASE_VIRTUAL));
				if (!frameDescriptorCh2_YCbCr_Y)
				{
					RetVal = 0;	
					break;
				}

				if (frameDescriptorCh3_YCbCr_Cb)
					VirtualFree((PVOID)frameDescriptorCh3_YCbCr_Cb,0,MEM_RELEASE);

				frameDescriptorCh3_YCbCr_Cb = (volatile LCD_FRAME_DESCRIPTOR *)VirtualAllocCopy(sizeof(LCD_FRAME_DESCRIPTOR), "DispDrvrInitialize : lcdFrameDescriptor", (PVOID)(SRAM_DMA_CHANNEL_3_Cb_FRAME_DESCRIPTOR_BASE_VIRTUAL));
				if (!frameDescriptorCh3_YCbCr_Cb)
				{
					RetVal = 0;	
					break;
				}

				if (frameDescriptorCh4_YCbCr_Cr)
					VirtualFree((PVOID)frameDescriptorCh4_YCbCr_Cr,0,MEM_RELEASE);

				frameDescriptorCh4_YCbCr_Cr = (volatile LCD_FRAME_DESCRIPTOR *)VirtualAllocCopy(sizeof(LCD_FRAME_DESCRIPTOR), "DispDrvrInitialize : lcdFrameDescriptor", (PVOID)(SRAM_DMA_CHANNEL_4_Cr_FRAME_DESCRIPTOR_BASE_VIRTUAL));
				if (!frameDescriptorCh4_YCbCr_Cr)
				{
					RetVal = 0;	
					break;
				}



			} else
			{
				XllpLCD._OVERLAY2_Y_CHANNEL_BASE_PHYSICAL = OVERLAY2_SDRAM_PHYSICAL_BASE_ADDRESS;
				XllpLCD._OVERLAY2_Cb_CHANNEL_BASE_PHYSICAL = OVERLAY2_SDRAM_PHYSICAL_BASE_ADDRESS + ((P_XLLP_OVERLAY_T)pvIn)->ch2_size;
				XllpLCD._OVERLAY2_Cr_CHANNEL_BASE_PHYSICAL = OVERLAY2_SDRAM_PHYSICAL_BASE_ADDRESS + ((P_XLLP_OVERLAY_T)pvIn)->ch2_size + ((P_XLLP_OVERLAY_T)pvIn)->ch3_size;
				XllpLCD._DMA_CHANNEL_2_Y_FRAME_DESCRIPTOR_BASE_PHYSICAL = SDRAM_DMA_CHANNEL_2_Y_FRAME_DESCRIPTOR_BASE_PHYSICAL;
				XllpLCD._DMA_CHANNEL_3_Cb_FRAME_DESCRIPTOR_BASE_PHYSICAL = SDRAM_DMA_CHANNEL_3_Cb_FRAME_DESCRIPTOR_BASE_PHYSICAL;
				XllpLCD._DMA_CHANNEL_4_Cr_FRAME_DESCRIPTOR_BASE_PHYSICAL = SDRAM_DMA_CHANNEL_4_Cr_FRAME_DESCRIPTOR_BASE_PHYSICAL;

				if (frameDescriptorCh2_YCbCr_Y)
					VirtualFree((PVOID)frameDescriptorCh2_YCbCr_Y,0,MEM_RELEASE);

				frameDescriptorCh2_YCbCr_Y = (volatile LCD_FRAME_DESCRIPTOR *)VirtualAllocCopy(sizeof(LCD_FRAME_DESCRIPTOR), "DispDrvrInitialize : lcdFrameDescriptor", (PVOID)(SDRAM_DMA_CHANNEL_2_Y_FRAME_DESCRIPTOR_BASE_VIRTUAL));
				if (!frameDescriptorCh2_YCbCr_Y)
				{
					RetVal = 0;	
					break;
				}

				if (frameDescriptorCh3_YCbCr_Cb)
					VirtualFree((PVOID)frameDescriptorCh3_YCbCr_Cb,0,MEM_RELEASE);

				frameDescriptorCh3_YCbCr_Cb = (volatile LCD_FRAME_DESCRIPTOR *)VirtualAllocCopy(sizeof(LCD_FRAME_DESCRIPTOR), "DispDrvrInitialize : lcdFrameDescriptor", (PVOID)(SDRAM_DMA_CHANNEL_3_Cb_FRAME_DESCRIPTOR_BASE_VIRTUAL));
				if (!frameDescriptorCh3_YCbCr_Cb)
				{
					RetVal = 0;	
					break;
				}

				if (frameDescriptorCh4_YCbCr_Cr)
					VirtualFree((PVOID)frameDescriptorCh4_YCbCr_Cr,0,MEM_RELEASE);

				frameDescriptorCh4_YCbCr_Cr = (volatile LCD_FRAME_DESCRIPTOR *)VirtualAllocCopy(sizeof(LCD_FRAME_DESCRIPTOR), "DispDrvrInitialize : lcdFrameDescriptor", (PVOID)(SDRAM_DMA_CHANNEL_4_Cr_FRAME_DESCRIPTOR_BASE_VIRTUAL));
				if (!frameDescriptorCh4_YCbCr_Cr)
				{
					RetVal = 0;	
					break;
				}


			}

			XllpLCD.frameDescriptorCh2_YCbCr_Y = frameDescriptorCh2_YCbCr_Y;
			XllpLCD.frameDescriptorCh3_YCbCr_Cb = frameDescriptorCh3_YCbCr_Cb; 
			XllpLCD.frameDescriptorCh4_YCbCr_Cr = frameDescriptorCh4_YCbCr_Cr;

			((P_XLLP_OVERLAY_T)pvIn)->CH2_Y = OVERLAY2_SRAM_VIRTUAL_BASE_ADDRESS;
			((P_XLLP_OVERLAY_T)pvIn)->CH3_Cb = OVERLAY2_SRAM_VIRTUAL_BASE_ADDRESS + ((P_XLLP_OVERLAY_T)pvIn)->ch2_size;
			((P_XLLP_OVERLAY_T)pvIn)->CH4_Cr = OVERLAY2_SRAM_VIRTUAL_BASE_ADDRESS + ((P_XLLP_OVERLAY_T)pvIn)->ch2_size + ((P_XLLP_OVERLAY_T)pvIn)->ch3_size;
			((P_XLLP_OVERLAY_T)pvIn)->OverlayBPP = O_BPP_16;
			((P_XLLP_OVERLAY_T)pvIn)->TmpBPP = XllpLCD.BPP;

			break;
		
		case CAMERA_INITIALIZE:
			RetVal = CameraInit((P_CAMERA_APP_T)pvIn);
			break;

		case CAMERA_START_VIDEO_CAPTURE:
			CameraStartVideoCapture();
			RetVal = 1;
			break;
		
		case CAMERA_STOP_VIDEO_CAPTURE:
			CameraStopVideoCapture();
			RetVal = 1;
			break;
		
		case CAMERA_RELEASE_FRAME:
			CameraReleaseFrame((P_CAMERA_APP_T)pvIn);
			RetVal = 1;
			break;
		
//		case CAMERA_CAPTURE_STILL_IMAGE:
//			CameraCaptureStillImage();
//			break;

		case GETGXINFO:
			// Fill out the GAPI data structure.  Assumes 16bpp or 8bpp, with RGB565 format.
			// Must change cBPP and ffFormat fields to accomodate other formats.
			// All of the button data that follows must be filled out to match the specific OEM device.
			// The data that is used to fill out the data structure here is copied from
			// the Microsoft example.  
			if ((cjOut >= sizeof(GXDeviceInfo)) && (pvOut != NULL) ) 
			{
				if (((GXDeviceInfo *) pvOut)->idVersion == kidVersion100) 
				{
					pgxoi = (GXDeviceInfo *) pvOut;
					pgxoi->idVersion = kidVersion100;
					pgxoi->pvFrameBuffer = (void *) FRAME_BUFFER_0_BASE_VIRTUAL;
					
					// cbStride reflects the physical properties of the display regardless of orientation.
					// Using a native portrait mode display, stride will always be 480.
					// If using native landscape mode display, stride would be 640.
					if (((DispDrvr_cxScreen == 240) && (DispDrvr_cyScreen == 320)) ||
					    ((DispDrvr_cxScreen == 320) && (DispDrvr_cyScreen == 240)) )
					{
						if (bpp == 16)
						{
							pgxoi->cbStride = 480;
							pgxoi->cBPP = 16;
						}
						if (bpp == 8)
						{
							pgxoi->cbStride = 240;
							pgxoi->cBPP = 16;
						}
					}

					// Using a native landscape mode display, stride will always be 1280.
					// If using native portrait mode display, stride would be 960.

					if (((DispDrvr_cxScreen == 480) && (DispDrvr_cyScreen == 640)) ||
						((DispDrvr_cxScreen == 640) && (DispDrvr_cyScreen == 480)) )
					{
						if (bpp == 16)
						{

⌨️ 快捷键说明

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