📄 osd_osi.c
字号:
//vulcan/drv/gfx/osd_osi.c/*----------------------------------------------------------------------------+|| This source code has been made available to you by IBM on an AS-IS| basis. Anyone receiving this source is licensed under IBM| copyrights to use it in any way he or she deems fit, including| copying it, modifying it, compiling it, and redistributing it either| with or without modifications. No license under IBM patents or| patent applications is to be implied by the copyright license.|| Any user of this software should understand that IBM cannot provide| technical support for this software and will not be responsible for| any consequences resulting from the use of this software.|| Any person who transfers this source code or any derivative work| must include the IBM copyright notice, this paragraph, and the| preceding two paragraphs in the transferred software.|| COPYRIGHT I B M CORPORATION 1998| LICENSED MATERIAL - PROGRAM PROPERTY OF I B M+----------------------------------------------------------------------------*/////Comment: // OSI function of OSD controls //Revision Log: // Sept/28/2001 Created by YYD// Oct/17/2001 Merged with GFX driver by YYD// Jun/05/2002 Ported to Vulcan OSD by YYD// Oct/21/2002 Set CHFSR to 1x horizontal scaling by default// Add handling of OSD_DISP_CNTL_ANIM,// OSD_DISP_CNTL_ANIMR, and OSD_DISP_CNTL_CHFSR in// osd_osi_set_display_parm() and // osd_osi_get_display_parm() -- BJC#include "os/os-types.h"#include "os/pm-alloc.h"#include "os/os-sync.h"#include "os/os-generic.h"#include "gfx_surface.h"#include "osd_atom.h"#include "osd_osi.h"#include "osd_local.h"// #define __OSD_OSI_DEBUG#ifdef __OSD_OSI_DEBUG #define __DRV_DEBUG#endif#include "os/drv_debug.h"#ifndef NULL // My local NULL definition #define NULL ((void *)0)#endif//////////////////////////////////////////////////////////////////////////////// Graphics device interfaces//////////////////////////////////////////////////////////////////////////////#define __OSD_GRAPH_DEVICE_INIT (0x00000001)#define __OSD_GRAPH_DEVICE_ENABLED (0x00000002)typedef struct __OSD_GRAPH_DEVICE_STRUCTURE__{ GFX_SURFACE_T *pSurface; UINT uAttr;} OSD_GRAPH_DEVICE_T;static OSD_GRAPH_DEVICE_T gOSDDev[GFX_NUMOF_VISUAL_DEVICES];static MUTEX_T *gOSDMutex;static INT osd_osi_init_device_hw(GFX_VISUAL_DEVICE_ID_T graphDev){ gOSDDev[graphDev].uAttr = __OSD_GRAPH_DEVICE_INIT; gOSDDev[graphDev].pSurface = NULL; switch(graphDev) { case GFX_VDEV_OSDCUR: osd_atom_set_plane_control(OSD_PLANE_A_DISABLE, OSD_PLANE_CURSOR); osd_atom_set_plane_control(OSD_PLANE_A_BMLA, OSD_PLANE_CURSOR|0); osd_atom_set_plane_control(OSD_PLANE_A_422_AVERAGING, OSD_PLANE_CURSOR|0); break; case GFX_VDEV_OSDGFX: osd_atom_set_plane_control(OSD_PLANE_A_DISABLE, OSD_PLANE_GRAPHICS); osd_atom_set_plane_control(OSD_PLANE_A_BMLA, OSD_PLANE_GRAPHICS|0); osd_atom_set_plane_control(OSD_PLANE_A_422_AVERAGING, OSD_PLANE_GRAPHICS|0); osd_atom_set_plane_control(OSD_PLANE_G_PER_COLOR_BLEND_MODE, OSD_PLANE_GRAPHICS | 0); break; case GFX_VDEV_OSDIMG: osd_atom_set_plane_control(OSD_PLANE_A_DISABLE, OSD_PLANE_IMAGE); osd_atom_set_plane_control(OSD_PLANE_A_BMLA, OSD_PLANE_IMAGE|0); break; default: PDEBUG("Invalid device ID!\n"); } return 0;}static INT osd_osi_deinit_device_hw(GFX_VISUAL_DEVICE_ID_T graphDev){ if(gOSDDev[graphDev].pSurface) { GFX_SURFACE_T *pCurr = gOSDDev[graphDev].pSurface; while(pCurr) { GFX_SURFACE_T *pNext = pCurr->pNextAttach; if(graphDev != pCurr->attachedDev) { PDEBUG("Attached surface shows that it is not attached to me!\n"); } // anyway, detach it pCurr->attachedDev = GFX_VDEV_NULL; pCurr->pNextAttach = NULL; pCurr = pNext; } gOSDDev[graphDev].pSurface = NULL; } gOSDDev[graphDev].uAttr = 0; switch(graphDev) { case GFX_VDEV_OSDCUR: osd_atom_set_plane_control(OSD_PLANE_A_DISABLE, OSD_PLANE_CURSOR); break; case GFX_VDEV_OSDGFX: osd_atom_set_plane_control(OSD_PLANE_A_DISABLE, OSD_PLANE_GRAPHICS); osd_atom_set_plane_control(OSD_PLANE_G_PER_COLOR_BLEND_MODE, OSD_PLANE_GRAPHICS | 0); break; case GFX_VDEV_OSDIMG: osd_atom_set_plane_control(OSD_PLANE_A_DISABLE, OSD_PLANE_IMAGE); break; default: PDEBUG("Invalid device ID!\n"); } return 0;}INT osd_osi_init(void){ int i; if(gOSDMutex) return 0; // already done gOSDMutex = os_create_mutex (); if(!gOSDMutex) { PDEBUG("Failed to create lock for resources!\n"); return -1; } ///////////////////////// if(os_get_mutex(gOSDMutex)) { PDEBUG("Failed on mutex!\n"); os_delete_mutex(gOSDMutex); gOSDMutex = NULL; return -1; } _OS_MEMSET(&gOSDDev[0], 0,sizeof(gOSDDev)); for(i=0; i<GFX_NUMOF_VISUAL_DEVICES; i++) osd_osi_init_device_hw((GFX_VISUAL_DEVICE_ID_T)i); osd_atom_set_display_control(OSD_CNTL_AFVP, 0); // Anti-flicker video plane, 0 disable, 1 enable osd_atom_set_display_control(OSD_CNTL_EDAF, 0); // Enable display anti-flicker, 0 disable, 1 enable osd_atom_set_display_control(OSD_CNTL_AFDT, 0); // Anti-flicker detection threshold, 2 bits attr osd_atom_set_display_control(OSD_CNTL_VPAFC, 0); // Video plane anti-flicker correction, 2 bits attr osd_atom_set_display_control(OSD_CNTL_E32BCO, 0); osd_atom_set_display_control(OSD_CNTL_ANIM, 0);// Animation mode, 0 no, 1 yes osd_atom_set_display_control(OSD_CNTL_ANIMR, 0);// Animation rate, 3 bits attr osd_atom_set_display_control(OSD_CNTL_CHFSR, 256);// Custom horizontal FIR scaling ratio, 9 bits attr -- BJC 102102 osd_atom_set_display_control(OSD_CNTL_BACKCOLOR,0x0088);// black color// osd_atom_set_display_control(OSD_CNTL_BACKCOLOR,0x2222);// NOT black color os_release_mutex(gOSDMutex); ///////////////////////// return gOSDMutex != NULL ? 0 : -1;}INT osd_osi_deinit(void){ int i; MUTEX_T *mutex; if(!gOSDMutex) return 0; // already done // wait for any unfinished operation ///////////////////////// if(os_get_mutex(gOSDMutex)) { PDEBUG("Failed on mutex!\n"); return -1; } mutex = gOSDMutex; // save first gOSDMutex = NULL; // no one can enter correctly now for(i=0; i<GFX_NUMOF_VISUAL_DEVICES; i++) osd_osi_deinit_device_hw((GFX_VISUAL_DEVICE_ID_T)i); _OS_MEMSET(&gOSDDev[0], 0, sizeof(gOSDDev)); osd_atom_set_display_control(OSD_CNTL_AFVP, 0); // Anti-flicker video plane, 0 disable, 1 enable osd_atom_set_display_control(OSD_CNTL_EDAF, 0); // Enable display anti-flicker, 0 disable, 1 enable osd_atom_set_display_control(OSD_CNTL_AFDT, 0); // Anti-flicker detection threshold, 2 bits attr osd_atom_set_display_control(OSD_CNTL_VPAFC, 0); // Video plane anti-flicker correction, 2 bits attr osd_atom_set_display_control(OSD_CNTL_E32BCO, 0); osd_atom_set_display_control(OSD_CNTL_ANIM, 0);// Animation mode, 0 no, 1 yes osd_atom_set_display_control(OSD_CNTL_ANIMR, 0);// Animation rate, 3 bits attr osd_atom_set_display_control(OSD_CNTL_CHFSR, 256);// Custom horizontal FIR scaling ratio, 9 bits attr -- BJC 102102 osd_atom_set_display_control(OSD_CNTL_BACKCOLOR,0x0088);// black color os_release_mutex(mutex); ///////////////////////// os_delete_mutex(mutex); return 0;}// local helper funcstatic void __update_device_surface(GFX_VISUAL_DEVICE_ID_T graphDev, GFX_SURFACE_T * pSurface){ switch(graphDev) { case GFX_VDEV_OSDCUR: // set the buffer addresses for OSD osd_atom_set_base_address(OSD_ADDR_CURSOR_BASE, pSurface->uBufferBase >> 7); osd_atom_set_base_address(OSD_ADDR_CURSOR_LINK, (pSurface->uBufferBase&127) >> 5); osd_atom_set_plane_control(OSD_PLANE_A_BMLA, OSD_PLANE_CURSOR|1); osd_atom_set_plane_control(OSD_PLANE_A_ENABLE, OSD_PLANE_CURSOR); break; case GFX_VDEV_OSDGFX: // set the buffer addresses for OSD PDEBUG("OSD_ADDR_GRAPHICS_BASE is being set to 0x%8.8x...0x%8.8x\n",pSurface->uBufferBase ,pSurface->uBufferBase >> 7); osd_atom_set_base_address(OSD_ADDR_GRAPHICS_BASE, pSurface->uBufferBase >> 7); osd_atom_set_base_address(OSD_ADDR_GRAPHICS_LINK, (pSurface->uBufferBase&127) >> 5); osd_atom_set_plane_control(OSD_PLANE_A_BMLA, OSD_PLANE_GRAPHICS|1); osd_atom_set_plane_control(OSD_PLANE_A_ENABLE, OSD_PLANE_GRAPHICS); osd_atom_set_plane_control(OSD_PLANE_G_PER_COLOR_BLEND_MODE, OSD_PLANE_GRAPHICS | 1); if(pSurface->twinheader) { PDEBUG("TwinHeader surface, back ground will not be shown\n"); osd_atom_set_base_address(OSD_ADDR_IMAGE_BASE, pSurface->uBufferBase2 >> 7); osd_atom_set_base_address(OSD_ADDR_IMAGE_LINK, (pSurface->uBufferBase2&127) >> 5); osd_atom_set_plane_control(OSD_PLANE_A_BMLA, OSD_PLANE_IMAGE|1); osd_atom_set_plane_control(OSD_PLANE_A_ENABLE, OSD_PLANE_IMAGE); // should we ? osd_atom_set_display_control(OSD_CNTL_E32BCO, 1); } else { osd_atom_set_display_control(OSD_CNTL_E32BCO, 0); if(!IS_OSD_SURFACE_CLUT(pSurface->uPlaneConfig)) { osd_atom_set_plane_control(OSD_PLANE_G_PER_COLOR_BLEND_MODE, OSD_PLANE_GRAPHICS | 0); } } break; case GFX_VDEV_OSDIMG: // set the buffer addresses for OSD if(osd_atom_get_display_control(OSD_CNTL_E32BCO)) {#if 1 // fixme: Sould we enable attaching of img while we use twinheader surface PDEBUG("We get TwinHeader surface attched. Attached IMG surface will not be seen!\n"); return;#else osd_atom_set_display_control(OSD_CNTL_E32BCO, 0);#endif } osd_atom_set_base_address(OSD_ADDR_IMAGE_BASE, pSurface->uBufferBase >> 7); osd_atom_set_base_address(OSD_ADDR_IMAGE_LINK, (pSurface->uBufferBase&127) >> 5); osd_atom_set_plane_control(OSD_PLANE_A_BMLA, OSD_PLANE_IMAGE|1); osd_atom_set_plane_control(OSD_PLANE_A_ENABLE, OSD_PLANE_IMAGE); osd_atom_set_plane_control(OSD_PLANE_G_PER_COLOR_BLEND_MODE, OSD_PLANE_GRAPHICS | 0); break; default: // GFX_VDEV_NULL break; }}// attach a already attached surface will move it to top most.INT osd_osi_attach_comp_gfx_surface(GFX_VISUAL_DEVICE_ID_T graphDev, GFX_SURFACE_T * pSurface){ if(!gfx_osi_pSurface_valid(pSurface) || GFX_VDEV_NULL == graphDev) { PDEBUG("Invalid surface or device %d!\n", (INT)graphDev); return -1; // we cann't do it } if(!IS_SURFACE_OSD_COMP(pSurface->uPlaneConfig)) { PDEBUG("The surface is incompatible with OSD device !\n"); return -1; // we cann't do it } if(GFX_VDEV_NULL != pSurface->attachedDev && graphDev != pSurface->attachedDev) { PDEBUG("The surface is already attached to someone else !\n"); return -1; // we cann't do it } if(!(gOSDDev[graphDev].uAttr & __OSD_GRAPH_DEVICE_INIT)) { PDEBUG("Device %d is not initlized!\n", (INT)graphDev); return -1; } // already attached device if(graphDev == pSurface->attachedDev) { ///////////////////////// if(os_get_mutex(gOSDMutex)) { PDEBUG("Failed on mutex!\n"); return -1; } if(gOSDDev[graphDev].pSurface) { GFX_SURFACE_T *pCurr = gOSDDev[graphDev].pSurface; GFX_SURFACE_T *pPrev = NULL; // look it up and make sure it is while(pCurr && pCurr != pSurface) { pPrev = pCurr; pCurr = pCurr->pNextAttach; } if(!pCurr) // not find { os_release_mutex(gOSDMutex); ///////////////////////// PDEBUG("Warning: Surface 0x%8.8x is reported to be attached to device %d but actually not!\n", (INT)pSurface, (INT)graphDev); } else // if(!pCurr) // not find { if(pCurr != gOSDDev[graphDev].pSurface) // it is not the top most one { // we need to adjust the links and update the surface // pPrev should never be NULL at this point pPrev->pNextAttach = pCurr->pNextAttach; pSurface->pNextAttach = gOSDDev[graphDev].pSurface; pSurface->attachedDev = graphDev; gOSDDev[graphDev].pSurface = pSurface; } __update_device_surface(graphDev, pSurface); os_release_mutex(gOSDMutex); ///////////////////////// PDEBUG("Success!\n"); return 0; } } else // if(gOSDDev[graphDev].pSurface) { os_release_mutex(gOSDMutex); ///////////////////////// PDEBUG("Warning: Surface 0x%8.8x is reported to be attached to device %d but actually not!\n", (INT)pSurface, (INT)graphDev); } } // default attach // the first time attach of unattached device // check for compatibility switch(graphDev) { case GFX_VDEV_OSDCUR: if(!(pSurface->uPlaneConfig & OSD_PLANE_CURSOR)) { PDEBUG("Surface is incompatible with cursor device!\n"); return -1; } break; case GFX_VDEV_OSDGFX: if(!(pSurface->uPlaneConfig & OSD_PLANE_GRAPHICS)) { PDEBUG("Surface is incompatible with graphics device!\n"); return -1;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -