예제 #1
0
ULONG  MACH_DisplayVideo(ULONG BufferOffset) {
    if (!(pRegs->chipflags&MACH_NEED_RESETUP)) {
       WaitForIdle(2);
       WRITEREG(MMIO,BUS_CNTL,READREG(MMIO,BUS_CNTL)|BUS_CNTL_MASK);
       WRITEREG(MMIO,SCALER_BUF0_OFFSET,BufferOffset);
       pRegs->offset=BufferOffset;
       return RC_SUCCESS;
    }
    WaitForIdle(12);

    WRITEREG(MMIO,OVERLAY_SCALE_CNTL,pRegs->scale_cntl);
    WRITEREG(MMIO,OVERLAY_SCALE_INC,pRegs->scale_inc);
    WRITEREG(MMIO,VIDEO_FORMAT,pRegs->format);
    WRITEREG(MMIO,SCALER_BUF0_PITCH,pRegs->pitch);
    WRITEREG(MMIO,SCALER_HEIGHT_WIDTH,pRegs->height_width);
    WRITEREG(MMIO,CAPTURE_CONFIG,pRegs->config);
    WRITEREG(MMIO,OVERLAY_Y_X,pRegs->y_x);
    WRITEREG(MMIO,OVERLAY_Y_X_END,pRegs->y_x_end);
    WRITEREG(MMIO,SCALER_BUF0_OFFSET,BufferOffset);
    pRegs->offset=BufferOffset;
    WRITEREG(MMIO,OVERLAY_GRAPHICS_KEY_MSK,pRegs->key_msk);
    WRITEREG(MMIO,OVERLAY_GRAPHICS_KEY_CLR,pRegs->key_clr);
    WRITEREG(MMIO,OVERLAY_KEY_CNTL,pRegs->key_cntl);
    pRegs->chipflags&=~MACH_NEED_RESETUP;
    return RC_SUCCESS;

}
예제 #2
0
int CGraphics_Threaded::GetVideoModes(CVideoMode *pModes, int MaxModes)
{
	if(g_Config.m_GfxDisplayAllModes)
	{
		int Count = sizeof(g_aFakeModes)/sizeof(CVideoMode);
		mem_copy(pModes, g_aFakeModes, sizeof(g_aFakeModes));
		if(MaxModes < Count)
			Count = MaxModes;
		return Count;
	}

	// add videomodes command
	CImageInfo Image;
	mem_zero(&Image, sizeof(Image));

	int NumModes = 0;
	CCommandBuffer::SCommand_VideoModes Cmd;
	Cmd.m_pModes = pModes;
	Cmd.m_MaxModes = MaxModes;
	Cmd.m_pNumModes = &NumModes;
	m_pCommandBuffer->AddCommand(Cmd);

	// kick the buffer and wait for the result and return it
	KickCommandBuffer();
	WaitForIdle();
	return NumModes;
}
예제 #3
0
void CGraphics_Threaded::ScreenshotDirect(const char *pFilename)
{
	// add swap command
	CImageInfo Image;
	mem_zero(&Image, sizeof(Image));

	CCommandBuffer::SCommand_Screenshot Cmd;
	Cmd.m_pImage = &Image;
	m_pCommandBuffer->AddCommand(Cmd);

	// kick the buffer and wait for the result
	KickCommandBuffer();
	WaitForIdle();

	if(Image.m_pData)
	{
		// find filename
		char aWholePath[1024];
		png_t Png; // ignore_convention

		IOHANDLE File = m_pStorage->OpenFile(pFilename, IOFLAG_WRITE, IStorage::TYPE_SAVE, aWholePath, sizeof(aWholePath));
		if(File)
			io_close(File);

		// save png
		char aBuf[256];
		str_format(aBuf, sizeof(aBuf), "saved screenshot to '%s'", aWholePath);
		m_pConsole->Print(IConsole::OUTPUT_LEVEL_STANDARD, "client", aBuf);
		png_open_file_write(&Png, aWholePath); // ignore_convention
		png_set_data(&Png, Image.m_Width, Image.m_Height, 8, PNG_TRUECOLOR, (unsigned char *)Image.m_pData); // ignore_convention
		png_close_file(&Png); // ignore_convention

		mem_free(Image.m_pData);
	}
}
예제 #4
0
int NV1SetupGraphicsEngine(int width,int height,int bpp)
{
  graphicsEngineOk=1;

  WaitForIdle();
  /* Possibly enable the hardware engines here. Should already be on though */
 
  DisableFifo();

  EnableFlowThru(); 

  ResetEngine();

  EnableOptimisations();

  InitDMAInstance();

  ClearAndEnableInterrupts();

  ClearOutContext();

  ClearOutHashTables();

  LoadChannelContext();

  SetUpObjects(bpp);

  EnableChannel();

  EnableFifo();

  return graphicsEngineOk;

}
int I2C::devPresent(uint8_t addr)
{
    if(m_ready)
    {
    	WaitForIdle();
        m_par.mailbox.hdr   = (addr << 1);
        m_par.mailbox.count = 0;
        m_par.mailbox.reg_count = 0;
        m_par.mailbox.cmd   = I2C_CMD_SEND;
        WaitForIdle();

        return m_par.mailbox.sts == I2C_OK ? 1 : 0;
    }
    else
        return 0;
}
int I2C::rx(int32_t reg, uint8_t *buf, int count)
{
    int rcnt = getRegByteCount(reg);
    
    if(m_ready)
    {
    	WaitForIdle();
        m_par.mailbox.cmd       = I2C_CMD_LOCKED;
        m_par.mailbox.hdr       = (m_adr << 1);
        m_par.mailbox.buffer    = buf;
        m_par.mailbox.count     = count;
        m_par.mailbox.reg       = reg;
        m_par.mailbox.reg_count = rcnt;
        m_par.mailbox.cmd       = I2C_CMD_RECEIVE;
        WaitForIdle();

        return m_par.mailbox.sts == I2C_OK ? 0 : -1;
    }
    else
        return -1;
}
예제 #7
0
bool CInputThread::PushEvent(IInputEvent*pEvent)
{
	CAutoLockEx<CCrtSection> lock(m_lock);
	if(m_bClose) return false;
	ResetEvent(m_hWaitForIdle);
	
	if(m_events.push(pEvent))
	{
		lock.UnLock();
		if(m_bAutoWaitForIdle) return WaitForIdle();
		return true;
	}
	return false;
}
예제 #8
0
bool CGraphics_Threaded::SetVSync(bool State)
{
	// add vsnc command
	bool RetOk = 0;
	CCommandBuffer::SCommand_VSync Cmd;
	Cmd.m_VSync = State ? 1 : 0;
	Cmd.m_pRetOk = &RetOk;
	m_pCommandBuffer->AddCommand(Cmd);

	// kick the command buffer
	KickCommandBuffer();
	WaitForIdle();
	return RetOk;
}
예제 #9
0
static int hci_unlink_urb (urb_t * urb)
{
	hci_t * hci;

	if (!urb) /* just to be sure */
		return -EINVAL;

	if (!urb->dev || !urb->dev->bus)
		return -ENODEV;

	hci = (hci_t *) urb->dev->bus->hcpriv;

	/* a request to the virtual root hub */
	if (usb_pipedevice (urb->pipe) == hci->rh.devnum) {
		return rh_unlink_urb (urb);
	}


	if (!list_empty (&urb->urb_list)) { /* URB active? */
		unsigned long flags;
		spin_lock_irqsave (&hci->urb_list_lock, flags);
		if (SetCancel(hci,urb)) {
			//not in active DMA chain
			list_del (&urb->urb_list);	//remove from probable endpoint queue
			list_add (&urb->urb_list, &hci->return_list);
		}
		spin_unlock_irqrestore (&hci->urb_list_lock, flags);
		if (!(urb->transfer_flags & (USB_ASYNC_UNLINK | USB_TIMEOUT_KILLED)) ) {
			/* synchron without callback */
			WaitForIdle(hci, urb);
		}
	} else { /* hcd does not own URB but we keep the driver happy anyway */
		if (urb->complete && (urb->transfer_flags & USB_ASYNC_UNLINK)) {
//			unsigned long flags;
			urb->status = -ENOENT;
			urb->actual_length = 0;

//			spin_lock_irqsave (&hci->urb_list_lock, flags);
			urb->complete (urb);
//			spin_unlock_irqrestore (&hci->urb_list_lock, flags);

			urb->status = 0;
		} else {
			urb->status = -ENOENT;
		}
	}

	return 0;
}
예제 #10
0
void CGraphics_Threaded::ReadBackbuffer(unsigned char **ppPixels, int x, int y, int w, int h)
{
	if(!ppPixels)
		return;

	// add swap command
	CImageInfo Image;
	mem_zero(&Image, sizeof(Image));

	CCommandBuffer::SCommand_Screenshot Cmd;
	Cmd.m_pImage = &Image;
	Cmd.m_X = x; Cmd.m_Y = y;
	Cmd.m_W = w; Cmd.m_H = h;
	m_pCommandBuffer->AddCommand(Cmd);

	// kick the buffer and wait for the result
	KickCommandBuffer();
	WaitForIdle();

	*ppPixels = (unsigned char *)Image.m_pData; // take ownership!
}
예제 #11
0
ULONG MACH_CheckHW(void) {
static USHORT MACHList[]={0x4754,0x4755,0x475a,0x4757,
                            0x4756,0x4742,0x4744,0x4749,
                            0x4750,0x4751,0x4c49,0x4c42,
                            0x4c50,0x4c47,0x474d,0x4c4d};
ULONG i,rc,temp;
    rc=pci_read_dword(&PciDevice,0,&temp);
    if (rc) return RC_ERROR;
    temp>>=16; //temp=PCI DEVICE ID
    i=0;
    while ((temp!=MACHList[i])&&(i<16)) i++;
    if (i==16) return RC_ERROR;
    rc=pci_read_dword(&PciDevice,0x10,&temp);
    if (rc) return RC_ERROR;
    temp&=0xfff00000;//mask out lower bits
    MMIO=PhysToLin(temp+0x7ff800,0x800);
    if (MMIO==NULL) return RC_ERROR;
    //enable block 1 access
    WaitForIdle(7);
    WRITEREG(MMIO,BUS_CNTL,READREG(MMIO,BUS_CNTL)|BUS_CNTL_MASK);
    WRITEREG(MMIO,SCALER_COLOUR_CNTL, (0x00) | (0x10 << 8) | (0x10 << 16) );
    WRITEREG(MMIO,SCALER_H_COEFF0, (0x00) | (0x20 << 8) );
    WRITEREG(MMIO,SCALER_H_COEFF1, (0x0D) | (0x20 << 8) | (0x06 << 16) | (0x0D << 24) );
    WRITEREG(MMIO,SCALER_H_COEFF2, (0x0D) | (0x1C << 8) | (0x0A << 16) | (0x0D << 24) );
    WRITEREG(MMIO,SCALER_H_COEFF3, (0x0C) | (0x1A << 8) | (0x0E << 16) | (0x0C << 24) );
    WRITEREG(MMIO,SCALER_H_COEFF4, (0x0C) | (0x14 << 8) | (0x14 << 16) | (0x0C << 24) );
    pRegs->scale_cntl=0x0c; //filtering on, red temp=6500K
    pRegs->chipflags|=MACH_NEED_RESETUP;
    HideVideo=MACH_HideVideo;
    VideoCaps=MACH_VideoCaps;
    SetVideoAttr=MACH_SetVideoAttr;
    GetVideoAttr=MACH_GetVideoAttr;
    DisplayVideo=MACH_DisplayVideo;
    SetupVideo=MACH_SetupVideo;
    RestoreVideo=MACH_RestoreVideo;
    return RC_SUCCESS;


}
예제 #12
0
void CGraphics_Threaded::Resize(int w, int h)
{
	if(m_ScreenWidth == w && m_ScreenHeight == h)
		return;

	if(h > 4*w/5)
		h = 4*w/5;
	if(w > 21*h/9)
		w = 21*h/9;

	m_ScreenWidth = w;
	m_ScreenHeight = h;

	CCommandBuffer::SCommand_Resize Cmd;
	Cmd.m_Width = w;
	Cmd.m_Height = h;
	m_pCommandBuffer->AddCommand(Cmd);

	// kick the command buffer
	KickCommandBuffer();
	WaitForIdle();
}
예제 #13
0
void CGraphicsBackend_Threaded::RunBuffer(CCommandBuffer *pBuffer)
{
    WaitForIdle();
    m_pBuffer = pBuffer;
    m_Activity.signal();
}
예제 #14
0
void NV1Sync(void)
{
  WaitForIdle();
}
예제 #15
0
int WIN_NewViewport( GRAPH * graph)
{
   int      i;
   HWND     window;
   HDC      dc;
   TEXTMETRIC  tm;
   tpWindowData   wd;
   HMENU    sysmenu;

   /* test the parameters */
   if (!graph) return 1;

   /* initialize if not yet done */
   if (WIN_Init() != 0) {
      externalerror("Can't initialize GDI.");
      return(1);
   }

   /* allocate device dependency info */
   wd = calloc(1, sizeof(tWindowData));
   if (!wd) return 1;
   graph->devdep = (char *)wd;

   /* Create the window */
   i = GetSystemMetrics( SM_CYSCREEN) / 3;
   window = CreateWindow( WindowName, graph->plotname, WS_OVERLAPPEDWINDOW,
      0, 0, WinLineWidth, i * 2 - 22, NULL, NULL, hInst, NULL);
   if (!window) return 1;
   
   /* change the background color of all windows (both new and already plotted) 
      by assessing the registered window class */
   if (isblack)
      SetClassLong(window, GCLP_HBRBACKGROUND, (int)GetStockObject( BLACK_BRUSH));
   else
      SetClassLong(window, GCLP_HBRBACKGROUND, (int)GetStockObject( WHITE_BRUSH));	   
   
   
   wd->wnd = window;
   SetWindowLong( window, 0, (long)graph);

   /* show window */
   ShowWindow( window, SW_SHOWNORMAL);

   /* get the mask */
   GetClientRect( window, &(wd->Area));

   /* get the DC */
   dc = GetDC( window);
   wd->hDC = dc;

   /* set the Color Index */
   wd->ColorIndex = 0;

   /* still no flag */
   wd->PaintFlag = 0;
   wd->FirstFlag = 1;

   /* modify system menue */
   sysmenu = GetSystemMenu( window, FALSE);
   AppendMenu( sysmenu, MF_SEPARATOR, 0, NULL);
   AppendMenu( sysmenu, MF_STRING, ID_DRUCKEN,   STR_DRUCKEN);
   AppendMenu( sysmenu, MF_STRING, ID_DRUCKEINR, STR_DRUCKEINR);
   AppendMenu( sysmenu, MF_STRING, ID_HARDCOPY, STR_HARDCOPY);
   AppendMenu( sysmenu, MF_STRING, ID_HARDCOPY_BW, STR_HARDCOPY_BW);

   /* set default parameters of DC */
   SetBkColor( dc, ColorTable[0]);
   SetBkMode(  dc, TRANSPARENT );

   /* set font */
   SelectObject( dc, PlotFont);

   /* query the font parameters */
   if (GetTextMetrics( dc, &tm)) {
      graph->fontheight = tm.tmHeight;
      graph->fontwidth  = tm.tmAveCharWidth;
   }

   /* set viewport parameters */
   graph->viewport.height  = wd->Area.bottom;
   graph->viewport.width   = wd->Area.right;

   /* set absolute parameters */
   graph->absolute.xpos    = 0;
   graph->absolute.ypos    = 0;
   graph->absolute.width   = wd->Area.right;
   graph->absolute.height  = wd->Area.bottom;

   /* wait until the window is really there */
   WaitForIdle();

   /* ready */
   return(0);
}
예제 #16
0
ULONG MACH_HideVideo(void) {
    WaitForIdle(4);
    WRITEREG(MMIO,BUS_CNTL,READREG(MMIO,BUS_CNTL)|BUS_CNTL_MASK);
    WRITEREG(MMIO,OVERLAY_SCALE_CNTL,READREG(MMIO,OVERLAY_SCALE_CNTL)&0x3fffffff);
    return RC_SUCCESS;
}