📄 gfx_inf_helper.c
字号:
} os_release_mutex(gGFXMutex); ///////////////////////////// return rtn;}// not yet publicatedint gfx_inf_h_reconfig_surface_dimension(int hSurface, UINT uNewWidth, UINT uNewHeight){ int rtn = -1; if(hSurface < 0 || hSurface >= (int)guMaxHandles) { PDEBUG("Bad parm\n"); return -1; } ///////////////////////////// if(os_get_mutex(gGFXMutex)) { PDEBUG("Failed on mutex!\n"); return -1; } if(gfx_osi_pSurface_alloc(&gpHandles[hSurface].surface)) { rtn = gfx_osi_reconfig_surface_dimension(&gpHandles[hSurface].surface, uNewWidth, uNewHeight); } os_release_mutex(gGFXMutex); ///////////////////////////// return rtn;}// not supported yetint gfx_inf_h_get_subplane_pseudo_surface(GFX_GET_SUBPLANE_PSEUDO_SURFACE_PARM_T *pParm){ int rtn = -1; return rtn;}// limited use onlyint _gfx_inf_h_get_surface_local(GFX_SURFACE_LOCAL_INFO_T *pInfo){ int rtn= -1; int hSurface; if(NULL == pInfo || pInfo->hSurface < 0 || pInfo->hSurface >= (int)guMaxHandles) { PDEBUG("Bad parm\n"); return -1; } hSurface = pInfo->hSurface; ///////////////////////////// if(os_get_mutex(gGFXMutex)) { PDEBUG("Failed on mutex!\n"); return -1; } if(gfx_osi_pSurface_alloc(&gpHandles[hSurface].surface)) { int i; pInfo->uPlaneConfig = gpHandles[hSurface].surface.uPlaneConfig; //pInfo->pPalette = gpHandles[hSurface].surface.pPalette; for(i=0; i<GET_GFX_SURFACE_SUBPLANES(pInfo->uPlaneConfig); i++) { // should I mmap them here ? Currently I'm not doing that. pInfo->plane[i].pPlane = gpHandles[hSurface].surface.plane[i].pBuffer; pInfo->plane[i].uBytePerLine = gpHandles[hSurface].surface.plane[i].uBytePerLine; pInfo->plane[i].uPixelSize = gpHandles[hSurface].surface.plane[i].uPixelSize; pInfo->plane[i].uPixelJustify = gpHandles[hSurface].surface.plane[i].uPixelJustify; pInfo->plane[i].uWidth = gpHandles[hSurface].surface.plane[i].uAllocWidth; pInfo->plane[i].uHeight = gpHandles[hSurface].surface.plane[i].uAllocHeight; pInfo->plane[i].a = gpHandles[hSurface].surface.plane[i].a; pInfo->plane[i].r = gpHandles[hSurface].surface.plane[i].r; pInfo->plane[i].g = gpHandles[hSurface].surface.plane[i].g; pInfo->plane[i].b = gpHandles[hSurface].surface.plane[i].b; } rtn = 0; } os_release_mutex(gGFXMutex); ///////////////////////////// return rtn;}int gfx_inf_h_get_surface_info(GFX_SURFACE_INFO_T *pInfo){ int rtn= -1; int hSurface; if(NULL == pInfo || pInfo->hSurface < 0 || pInfo->hSurface >= (int)guMaxHandles) { PDEBUG("Bad parm\n"); return -1; } hSurface = pInfo->hSurface; ///////////////////////////// if(os_get_mutex(gGFXMutex)) { PDEBUG("Failed on mutex!\n"); return -1; } if(gfx_osi_pSurface_alloc(&gpHandles[hSurface].surface)) { int i; gfx_osi_get_surface_physical_parm(&gpHandles[hSurface].phy, &gpHandles[hSurface].surface); pInfo->uPlaneConfig = gpHandles[hSurface].surface.uPlaneConfig; for(i=0; i<GET_GFX_SURFACE_SUBPLANES(pInfo->uPlaneConfig); i++) { // should I mmap them here ? Currently I'm not doing that. pInfo->plane[i].uBytePerLine = gpHandles[hSurface].surface.plane[i].uBytePerLine; pInfo->plane[i].uPixelSize = gpHandles[hSurface].surface.plane[i].uPixelSize; pInfo->plane[i].uPixelJustify = gpHandles[hSurface].surface.plane[i].uPixelJustify; pInfo->plane[i].uWidth = gpHandles[hSurface].surface.plane[i].uAllocWidth; pInfo->plane[i].uHeight = gpHandles[hSurface].surface.plane[i].uAllocHeight; pInfo->plane[i].a = gpHandles[hSurface].surface.plane[i].a; pInfo->plane[i].r = gpHandles[hSurface].surface.plane[i].r; pInfo->plane[i].g = gpHandles[hSurface].surface.plane[i].g; pInfo->plane[i].b = gpHandles[hSurface].surface.plane[i].b; pInfo->plane[i].plane.uBase = gpHandles[hSurface].phy.uPlanePhysicalBaseAddr[i]; pInfo->plane[i].plane.uSize = gpHandles[hSurface].phy.uPlanePhysicalSize[i]; pInfo->plane[i].plane.uOffset = gpHandles[hSurface].phy.uPlanePhysicalOffset[i]; } rtn = 0; } os_release_mutex(gGFXMutex); ///////////////////////////// return rtn;}int gfx_inf_h_lock_surface(GFX_SURFACE_INFO_T *pInfo){ int rtn= -1; int hSurface; if(NULL == pInfo || pInfo->hSurface < 0 || pInfo->hSurface >= (int)guMaxHandles) { PDEBUG("Bad parm\n"); return -1; } hSurface = pInfo->hSurface; ///////////////////////////// if(os_get_mutex(gGFXMutex)) { PDEBUG("Failed on mutex!\n"); return -1; } if(gfx_osi_pSurface_alloc(&gpHandles[hSurface].surface)) { int i; gfx_osi_get_surface_physical_parm(&gpHandles[hSurface].phy, &gpHandles[hSurface].surface); if(0 == gpHandles[hSurface].uLocks) guLockedHandles ++; gpHandles[hSurface].uLocks ++; pInfo->uPlaneConfig = gpHandles[hSurface].surface.uPlaneConfig; for(i=0; i<GET_GFX_SURFACE_SUBPLANES(pInfo->uPlaneConfig); i++) { // should I mmap them here ? Currently I'm not doing that. pInfo->plane[i].uBytePerLine = gpHandles[hSurface].surface.plane[i].uBytePerLine; pInfo->plane[i].uPixelSize = gpHandles[hSurface].surface.plane[i].uPixelSize; pInfo->plane[i].uPixelJustify = gpHandles[hSurface].surface.plane[i].uPixelJustify; pInfo->plane[i].uWidth = gpHandles[hSurface].surface.plane[i].uAllocWidth; pInfo->plane[i].uHeight = gpHandles[hSurface].surface.plane[i].uAllocHeight; pInfo->plane[i].a = gpHandles[hSurface].surface.plane[i].a; pInfo->plane[i].r = gpHandles[hSurface].surface.plane[i].r; pInfo->plane[i].g = gpHandles[hSurface].surface.plane[i].g; pInfo->plane[i].b = gpHandles[hSurface].surface.plane[i].b; pInfo->plane[i].plane.uBase = gpHandles[hSurface].phy.uPlanePhysicalBaseAddr[i]; pInfo->plane[i].plane.uSize = gpHandles[hSurface].phy.uPlanePhysicalSize[i]; pInfo->plane[i].plane.uOffset = gpHandles[hSurface].phy.uPlanePhysicalOffset[i]; } rtn = 0; } os_release_mutex(gGFXMutex); ///////////////////////////// return rtn;}int gfx_inf_h_unlock_surface(int hSurface){ int rtn= -1; if(hSurface < 0 || hSurface >= (int)guMaxHandles) { PDEBUG("Bad parm\n"); return -1; } ///////////////////////////// if(os_get_mutex(gGFXMutex)) { PDEBUG("Failed on mutex!\n"); return -1; } if(gfx_osi_pSurface_alloc(&gpHandles[hSurface].surface) && gpHandles[hSurface].uLocks > 0) { gpHandles[hSurface].uLocks --; if(0 == gpHandles[hSurface].uLocks) guLockedHandles --; rtn = 0; } else { PDEBUG("Surface invalid or not locked\n"); } os_release_mutex(gGFXMutex); ///////////////////////////// return rtn;}// this is a dirty slow process, but it is needed indeedint _gfx_inf_h_validate_surface_address(ULONG uPlanePhysicalBaseAddr, ULONG uPlanePhysicalSize){ int rtn = -1; ///////////////////////////// if(os_get_mutex(gGFXMutex)) { PDEBUG("Failed on mutex!\n"); return -1; } if(guLockedHandles > 0) { UINT i, j=0, candi=guMaxHandles; for(i=0; i<guMaxHandles; i++) { if(gpHandles[i].uLocks > 0) { for(j=0; j<GET_GFX_SURFACE_SUBPLANES(gpHandles[i].surface.uPlaneConfig); j++) { PDEBUG("Checking %d [%d] = 0x%8.8x / %d \n", i, j, (UINT)gpHandles[i].phy.uPlanePhysicalBaseAddr[j], (UINT)gpHandles[i].phy.uPlanePhysicalSize[j]); if(gpHandles[i].phy.uPlanePhysicalBaseAddr[j] == uPlanePhysicalBaseAddr) { PDEBUG("Candidate %d [%d] = 0x%8.8x / %d \n", i, j, (UINT)gpHandles[i].phy.uPlanePhysicalBaseAddr[j], (UINT)gpHandles[i].phy.uPlanePhysicalSize[j]); candi = i; i = guMaxHandles; break; } } } } // check if it fits // first, check if we find it, then its size is ok if( candi < guMaxHandles /* && gpHandles[candi].phy.uPlanePhysicalSize[j] >= uPlanePhysicalSize*/) rtn = 0; // yes else // no { PDEBUG("Failed to find 0x%8.8x / %d in my surface pool\n", (UINT)uPlanePhysicalBaseAddr, (UINT)uPlanePhysicalSize); } } os_release_mutex(gGFXMutex); ///////////////////////////// return rtn;}int gfx_inf_h_attach_surface(GFX_SURFACE_VDEV_PARM_T *pParm){ int rtn= -1; if(NULL == pParm || pParm->hSurface < 0 || pParm->hSurface >= (int)guMaxHandles) { PDEBUG("Bad parm\n"); return -1; } ///////////////////////////// if(os_get_mutex(gGFXMutex)) { PDEBUG("Failed on mutex!\n"); return -1; } rtn = osd_osi_attach_comp_gfx_surface(pParm->graphDev, &gpHandles[pParm->hSurface].surface); os_release_mutex(gGFXMutex); ///////////////////////////// return rtn;}int gfx_inf_h_detach_surface(GFX_SURFACE_VDEV_PARM_T *pParm){ int rtn= -1; if(NULL == pParm || pParm->hSurface < 0 || pParm->hSurface >= (int)guMaxHandles) { PDEBUG("Bad parm\n"); return -1; } ///////////////////////////// if(os_get_mutex(gGFXMutex)) { PDEBUG("Failed on mutex!\n"); return -1; } if(GFX_VDEV_NULL == pParm->graphDev) { rtn = osd_osi_detach_comp_gfx_surface(gpHandles[pParm->hSurface].surface.attachedDev, &gpHandles[pParm->hSurface].surface); } else { rtn = osd_osi_detach_comp_gfx_surface(pParm->graphDev, &gpHandles[pParm->hSurface].surface); } os_release_mutex(gGFXMutex); ///////////////////////////// return rtn;}/* * Detach one surface and attach another, optionally synchronized with the OSD * animation interrupt. If pParm->bWaitForSwap is set, this function will sleep * and not return until the next OSD animation interrupt occurs. */int gfx_inf_h_swap_surface(GFX_2SURFACE_VDEV_PARM_T *pParm){ int rtn = -1; /* * If pParm->UseOsdAnimInt was set and pParm->bWaitForSwap was not set * in the last call to gfx_inf_h_swap_surface(), osdanim_swap.bReadyForSwap will still * be set if the OSD animation interrupt has not occurred. For this condition, * gfx_inf_h_swap_surface() may be called at a maximum frequency not to exceed * the OSD animation interrupt frequency. */ if(osdanim_swap.bReadyForSwap) { printk(KERN_INFO "gfx_inf_h_swap_surface() called before previous request finished\n"); return -1; } if(NULL == pParm || pParm->hOldSurface < 0 || pParm->hOldSurface >= (int)guMaxHandles || pParm->hNewSurface < 0 || pParm->hNewSurface >= (int)guMaxHandles) { PDEBUG("Bad parm\n"); return -1; } if(pParm->bUseOsdAnimInt) { pParm->missedInts = osdanim_swap.missedInts; if(osdanim_swap.missedInts > 0) { osdanim_swap.missedInts = 0; PDEBUG("missed %d osd animation interrupts\n", pParm->missedInts); } } else { pParm->missedInts = 0; } ///////////////////////////// if(os_get_mutex(gGFXMutex)) { PDEBUG("Failed on mutex!\n"); return -1; } if(pParm->bUseOsdAnimInt) { osdanim_swap.hGraphDev = pParm->graphDev; osdanim_swap.hOldSurface = pParm->hOldSurface; osdanim_swap.hNewSurface = pParm->hNewSurface; sema_init(&osdanim_swap.sem, 0); osdanim_swap.bReadyForSwap = 1; /* signal ready for swap */ if(pParm->bWaitForSwap) { down_interruptible(&osdanim_swap.sem); /* wait for swap to take place */ } osdanim_swap.missedInts--; rtn = 0; } else { rtn = 0; if(pParm->hOldSurface != 0) { rtn |= osd_osi_detach_comp_gfx_surface(pParm->graphDev, &gpHandles[pParm->hOldSurface].surface); } rtn |= osd_osi_attach_comp_gfx_surface(pParm->graphDev, &gpHandles[pParm->hNewSurface].surface); } os_release_mutex(gGFXMutex); ///////////////////////////// return rtn;}int gfx_inf_h_get_screen_info(GFX_SCREEN_INFO_T *pInfo){ if(NULL == pInfo) { PDEBUG("Bad parm\n"); return -1; } ///////////////////////////// if(os_get_mutex(gGFXMutex)) { PDEBUG("Failed on mutex!\n"); return -1; } _OS_MEMCPY(pInfo, &gScreenInfo, sizeof(GFX_SCREEN_INFO_T)); os_release_mutex(gGFXMutex); ///////////////////////////// return 0;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -