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

📄 gfx_osi_surface.c

📁 IBM source for pallas/vulcan/vesta
💻 C
📖 第 1 页 / 共 4 页
字号:
//vulcan/drv/gfx/gfx_osi_surface.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 GFX surface helper functions //Revision Log:   //  Oct/17/2001                                             Created by YYD//  Jun/04/2002                       Ported to Vulcan architecture by YYD//  Oct/21/2002     Enabled horizontal scaling in region header when a new//                  region is created.  Default scaling is set to 1x in //                  osd_osi_init() and is changed with the OSD_CNTL_CHFSR//                  control to osd_atom_set_display_control().         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 "hw/physical-mem.h"#include "gfx_osi_local.h"// #define __GFX_SURFACE_DEBUG#ifdef __GFX_SURFACE_DEBUG    #define __DRV_DEBUG#endif#include "os/drv_debug.h"#ifndef NULL    // My local NULL definition    #define NULL ((void *)0)#endifextern ULONG guGraphicsVideoOffset;//////////////////////////////////////////////////////////////////////////////// Graphics surface defination//////////////////////////////////////////////////////////////////////////////static UINT __justify_gfx_byte(UINT bpl){    return (bpl%GFX_SURFACE_LINE_JUSTIFY)         ?  (bpl + GFX_SURFACE_LINE_JUSTIFY - (bpl%GFX_SURFACE_LINE_JUSTIFY))        :  bpl;}void gfx_osi_init_surface_t(GFX_SURFACE_T * pSurface){    if(!pSurface) return;    _OS_MEMSET(pSurface, 0, sizeof(GFX_SURFACE_T));    pSurface->attachedDev = GFX_VDEV_NULL;    return;}// used to empty a new unused surface_t for next stepsINT gfx_osi_reset_surface_palette(GFX_SURFACE_T *pSurface){    GFX_PALETTE_T  *pgPal;    UINT uNumPal;    if(!pSurface )    {	    PDEBUG("pSurface is NULL!");	    return -1;    }    if(!gfx_osi_pSurface_alloc(pSurface))    {	    PDEBUG("pSurface is not initialized !");	    return -1;    }    if(!pSurface->pPalette )    {	    return 0;   // we don't have palette    }    switch(pSurface->uPlaneConfig)    {    case GFX_SURFACE_CLUT4BPPP_ARGB:      case GFX_SURFACE_CLUT4BPP_ARGB:       case GFX_SURFACE_CLUT4BPP_AYCBCR:     case GFX_SURFACE_CLUT4BPPP_AYCBCR:    case GFX_SURFACE_CURSOR4BPP_YCBCR:    case GFX_SURFACE_CURSOR4BPPP_YCBCR:    case GFX_SURFACE_CURSOR4BPP_RGB:    case GFX_SURFACE_CURSOR4BPPP_RGB:        pgPal = gGFX_RGB4_Palette;        uNumPal=16;             // for cursor compatible        break;    case GFX_SURFACE_CLUT2BPPP_ARGB:      case GFX_SURFACE_CLUT2BPP_ARGB:       case GFX_SURFACE_CLUT2BPP_AYCBCR:     case GFX_SURFACE_CLUT2BPPP_AYCBCR:    case GFX_SURFACE_CURSOR2BPP_YCBCR:    case GFX_SURFACE_CURSOR2BPPP_YCBCR:    case GFX_SURFACE_CURSOR2BPP_RGB:    case GFX_SURFACE_CURSOR2BPPP_RGB:        pgPal = gGFX_RGB2_Palette;        uNumPal=4;             // for cursor compatible        break;    case GFX_SURFACE_CLUT8BPP_ARGB:    case GFX_SURFACE_CLUT8BPP_AYCBCR:     case GFX_SURFACE_CLUT8BPPP_ARGB:    case GFX_SURFACE_CLUT8BPPP_AYCBCR:         pgPal = gGFX_RGB8_Palette;        uNumPal=256;             // for cursor compatible        break;    default:        PDEBUG("Invalid plane config 0x%8.8x !\n", pSurface->uPlaneConfig);        return -1;    }    return gfx_osi_set_surface_palette(pSurface, pgPal, 0, uNumPal);}INT gfx_osi_set_surface_palette(GFX_SURFACE_T *pSurface, GFX_PALETTE_T *pPal, UINT uStart, UINT uNumEntry){    UINT uMaxPal, i;//printk("gfx_osi_set_surface_palette called starting at number %d num entries = %d\n",uStart,uNumEntry);    if(!pSurface || !pPal)    {	    PDEBUG("pSurface / pPal is NULL!");	    return -1;    }    if(!gfx_osi_pSurface_alloc(pSurface))    {	    PDEBUG("pSurface is not initialized !");	    return -1;    }    if(!pSurface->pPalette )    {	    PDEBUG("pSurface doesn't have palette !");	    return 0;   // we don't have palette    }    uMaxPal = 1<<pSurface->plane[0].uPixelSize;    if(uStart >= uMaxPal || uNumEntry == 0)    {       PDEBUG("Palette index s(%d) n(%d) out of range!\n", uStart, uNumEntry);       return 0;    }    if(uStart + uNumEntry > uMaxPal)        uNumEntry = uMaxPal - uStart;    PDEBUGE("Set palette %d to %d\n",  uStart, uStart + uNumEntry-1);    if(IS_GFX_SURFACE_YUV(pSurface->uPlaneConfig))    {        if(pSurface->uAttr&__GFX_SURFACE_OSDCURSOR)  // cursor        {            STB_OSD_C_PALETTE_T *pPhyPal = (STB_OSD_C_PALETTE_T *)pSurface->pPal + uStart;            GFX_PALETTE_T *pLogPal = pSurface->pPalette + uStart;            for(i=0; i<uNumEntry; i++)            {                pLogPal[i] = pPal[i];				if(pPal[i].a)				{					pPhyPal[i].y  = pLogPal[i].r >> 2;  // 6 bits					pPhyPal[i].cb = pLogPal[i].g >> 4;  // 4 bits					pPhyPal[i].cr = pLogPal[i].b >> 4;  // 4 bits				}				else	// transparent				{					pPhyPal[i].y  = 0; 					pPhyPal[i].cb = 0; 					pPhyPal[i].cr = 0; 				}                pPhyPal[i].peep   = 0;                pPhyPal[i].steady = 1;                PDEBUGE("CUR PALETTE %03d = %04x (argb = %d, %d, %d, %d)\n",                    i, *((USHORT *)&pPhyPal[i]), pPal[i].a, pPal[i].r, pPal[i].g, pPal[i].b);            }        }        else        {            STB_OSD_GI_PALETTE_T *pPhyPal = (STB_OSD_GI_PALETTE_T *)pSurface->pPal + uStart;            GFX_PALETTE_T *pLogPal = pSurface->pPalette + uStart; printk("setting surface palette for yuv\n");            for(i=0; i<uNumEntry; i++)            {                UINT alpha;                pLogPal[i] = pPal[i];                                //  0 	0 - 25			4                //.25	26 - 90			3                //.50	91 - 155		2                //.75	156 - 220		1                //1.0	221 - 255		0                alpha = (285 - pPal[i].a) / 65;                                if(alpha > 3)   // transparenet                {                    pPhyPal[i].y = pPhyPal[i].cb = pPhyPal[i].cr = 0;                }                else                {                    pPhyPal[i].y  = pLogPal[i].r >> 2;  // 6 bits                    pPhyPal[i].cb = pLogPal[i].g >> 4;  // 4 bits                    pPhyPal[i].cr = pLogPal[i].b >> 4;  // 4 bits                    pPhyPal[i].bf0 = (alpha&1) ? 1 : 0;                    pPhyPal[i].bf1 = (alpha&2) ? 1 : 0;                }                PDEBUGE("PALETTE %03d = %04x (argb = %d, %d, %d, %d)\n",                    i, *((USHORT *)&pPhyPal[i]), pPal[i].a, pPal[i].r, pPal[i].g, pPal[i].b);            }        }    }    else    // rgb surface, we need to convert palette to yuv    {        if(pSurface->uAttr&__GFX_SURFACE_OSDCURSOR)  // cursor        {            STB_OSD_C_PALETTE_T *pPhyPal = (STB_OSD_C_PALETTE_T *)pSurface->pPal + uStart;            GFX_PALETTE_T *pLogPal = pSurface->pPalette + uStart;            for(i=0; i<uNumEntry; i++)            {                BYTE y,u,v;                gfx_osi_rgb2ycbcr(                    pPal[i].r, pPal[i].g, pPal[i].b,                      &y,  &u,  &v);                pLogPal[i] = pPal[i];				if(pPal[i].a)				{					pPhyPal[i].y  = y >> 2;  // 6 bits					pPhyPal[i].cb = u >> 4;  // 4 bits					pPhyPal[i].cr = v >> 4;  // 4 bits				}				else	// transparent				{					pPhyPal[i].y  = 0; 					pPhyPal[i].cb = 0; 					pPhyPal[i].cr = 0; 				}                pPhyPal[i].peep   = 0;                pPhyPal[i].steady = 1;                PDEBUGE("CUR PALETTE %03d = %04x (argb = %d, %d, %d, %d)\n",                    i, *((USHORT *)&pPhyPal[i]), pPal[i].a, pPal[i].r, pPal[i].g, pPal[i].b);            }        }        else        {            STB_OSD_GI_PALETTE_T *pPhyPal = (STB_OSD_GI_PALETTE_T *)pSurface->pPal + uStart;            GFX_PALETTE_T *pLogPal = pSurface->pPalette + uStart;//printk("setting surface palette for rgb");            for(i=0; i<uNumEntry; i++)            {                UINT alpha;                BYTE y,u,v;                gfx_osi_rgb2ycbcr(                    pPal[i].r, pPal[i].g, pPal[i].b,                      &y,  &u,  &v);                pLogPal[i] = pPal[i];                                //  0 	0 - 25			4                //.25	26 - 90			3                //.50	91 - 155		2                //.75	156 - 220		1                //1.0	221 - 255		0                alpha = (285 - pPal[i].a) / 65;                //printk("   alpha = %d\n", alpha);		                if(alpha > 3)   // transparenet                {                    pPhyPal[i].y = pPhyPal[i].cb = pPhyPal[i].cr = 0;                }                else                {                    pPhyPal[i].y  = y >> 2;  // 6 bits                    pPhyPal[i].cb = u >> 4;  // 4 bits                    pPhyPal[i].cr = v >> 4;  // 4 bits                    pPhyPal[i].bf0 = (alpha&1) ? 1 : 0;                    pPhyPal[i].bf1 = (alpha&2) ? 1 : 0;                }//printk("PALETTE %03d = %04x (argb = %d, %d, %d, %d)\n",//                    i, *((USHORT *)&pPhyPal[i]), pPal[i].a, pPal[i].r, pPal[i].g, pPal[i].b);                PDEBUGE("PALETTE %03d = %04x (argb = %d, %d, %d, %d)\n",                    i, *((USHORT *)&pPhyPal[i]), pPal[i].a, pPal[i].r, pPal[i].g, pPal[i].b);            }        }    }    return 0;}INT gfx_osi_get_surface_palette(GFX_SURFACE_T *pSurface, GFX_PALETTE_T *pPal, UINT uStart, UINT uNumEntry){    UINT uMaxPal;    if(!pSurface || !pPal)    {	    PDEBUG("pSurface / pPal is NULL!");	    return -1;    }

⌨️ 快捷键说明

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