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

📄 msapi_miu.c

📁 mstar 776 开发的车载dvd
💻 C
📖 第 1 页 / 共 3 页
字号:
}

/******************************************************************************/
/// API for MIU Copy::
/// Memory Copy Interface
/// @param srcaddr \b IN Source address
/// @param dstaddr \b IN Destination address
/// @param len \b IN Size
/// @param type \b IN The Type of Memory copy
/******************************************************************************/
void msAPI_MIU_Copy(U32 srcaddr, U32 dstaddr, U32 len, MEMCOPYTYPE type)
{
    APIMIU_DBG(printf("MIU Src = 0x%08LX, Dst = 0x%08LX, Len = 0x%LX , Type = 0x%02bx\n", srcaddr, dstaddr, len, type));
    MDrv_MIU_Copy(srcaddr, dstaddr, len, type);
}

#if 0//(DISPLAY_LOGO)
/******************************************************************************/
/// API for MIU Load LOGO::
/// Copy LOGO from flash to SDRAM
/// @param u32Flashaddr \b IN Flash address
/// @param u32Dstaddr \b IN SDRAM address
/// @param u32Len \b IN LOGO size in bytes
/******************************************************************************/
void msAPI_MIU_LoadLogo(U32 u32Flashaddr, U32 u32Dstaddr, U32 u32Len)
{
    MDrv_MIU_XCopy(MCPY_LOADLOGO, u32Flashaddr, u32Dstaddr, u32Len);
}
#endif

/******************************************************************************/
/// API for MIU Clear SDRAM::
/// Memory Clear Interface
/// @param miu \b IN MIU Selection. (0: MIU0, 1: MIU1)
/// @param addr \b IN Starting address
/// @param len \b IN Size in byte
/// @param clear_value \b IN One-byte value to set
/******************************************************************************/
void msAPI_MIU_Clear(U8 miu, U32 addr, U32 len, U8 clear_value)
{
	miu=miu;   //for remove warnning message
    MDrv_GE_ClearFrameBuffer( addr, len, clear_value);

}

/******************************************************************************/
/// API for MIU Get Specific Bin information::
/// Get Bin Information
/// @param pBinInfo \b OUT Bin Information
/// @return Success or not
/******************************************************************************/
BOOLEAN msAPI_MIU_Get_BinInfo(BINFORMAT *pBinInfo)
{
    return MDrv_MIU_Get_BinInfo(pBinInfo);
}

/******************************************************************************/
/// API for MIU Set Flash Bin Packet Header Address::
/// Set Header address
/// @param addr \b IN Header address
/******************************************************************************/
void msAPI_MIU_Set_BinHeader_Addr(U32 addr)
{
    MDrv_MIU_Set_BinHeader_Addr(addr);
}

/******************************************************************************/
/// API for MIU Get Flash Bin Packet Header Address::
/// Get Header address
/// @return Header address
/******************************************************************************/
U32 msAPI_MIU_Get_BinHeader_Addr(void)
{
    return MDrv_MIU_Get_BinHeader_Addr();
}

/******************************************************************************/
#if(SWCHECKSUM_SWITCH)
#define CCSLength 32
void msAPI_MIU_CCS(void)
{
    U8 CCSBufer[CCSLength], i;

    if(CCSAddress >= CODE_MAP_BASE_ADR + CODE_MAP_LEN)
        CCSAddress = CODE_MAP_BASE_ADR;

    if (((CCSAddress - CODE_MAP_BASE_ADR) & 0xFFFF) == 0x0)
    {
        if (CCSValue != 0)
        {
            APIFLASH_DBG(printf("CCSF::%08LX\n", CCSAddress));
            while(1);
        }
    }

    MDrv_MIU_XCopy(MCPY_CCS, CCSAddress, (U16)&CCSBufer[0] - XDATASDRAM_START_ADDR, CCSLength);
    CCSAddress += CCSLength;

    for(i=0; i<CCSLength; i++)
        CCSValue += CCSBufer[i];
}
#endif

#if ENABLE_SSC
/*
void msAPI_MIU_SscEnable(BOOLEAN enable)
{
	MDrv_MIU_SscEnable(enable);
}
BOOLEAN msAPI_MIU_SscStatus(void)
{
	return MDrv_MIU_SscStatus();
}
void msAPI_MIU_SscStep(U8 StepValue)
{
	MDrv_MIU_SscStep(StepValue);
}
U8 msAPI_MIU_SscStepValue(void)
{
	return MDrv_MIU_SscStepValue();
}
void msAPI_MIU_SscSpan(U16 SpanValue)
{
	MDrv_MIU_SscSpan(SpanValue);
}
U16 msAPI_MIU_SscSpanValue(void)
{
	return MDrv_MIU_SscSpanValue();
}

void msAPI_MIU_SscSetup(U16 SpanValue,U16 StepValue )
{
    MDrv_MIU_SscSpan( SpanValue );
    MDrv_MIU_SscStep( StepValue);
    MDrv_MIU_SscEnable(ENABLE);
}
*/
void msAPI_MIU_SetSsc(U16 u16Periodx100Hz, U16 u16Percentx100, BOOLEAN bEnable)
{
	MDrv_MIU_SetSsc(u16Periodx100Hz, u16Percentx100, bEnable);
}

#endif

void msAPI_MIU_SetRoundRobin(BOOLEAN bEnable)
{
    MDrv_MIU_SetRoundRobin(bEnable);
}

#if 0
BOOLEAN msAPI_MIU_LoadSDRAMFont_Decompress(U32 srcAddr, U32 u32DstAddr, FONT_BIN_HEADER *pFontBinHeader, ST_LOAD_FONT_SDRAM_REPORT *pFontSdramReport)
{
    U32 u32SDRAMAddr;
    U16 u16;
    U16 u16LineBytes, u16CharGlyphBytes;
    int i;
    U8 offset_align;
    U8 u8shift;
    U32 size_bak;

    pFontSdramReport->u32StartAddr = u32DstAddr;
    pFontSdramReport->u32SdramLen = 0;

    MDrv_MIU_Copy(srcAddr,((U16)pFontBinHeader-XDATASDRAM_START_ADDR),sizeof(FONT_BIN_HEADER),MIU_SDRAM2SDRAM);

    // Load bbox info to SDRAM
    if (pFontBinHeader->u32BBoxOffset != 0)
    {
        U32 u32Len = pFontBinHeader->u32CharNum * 4;
        u32Len = ((u32Len+(MIU_ALIGN_UNIT-1))/MIU_ALIGN_UNIT)*MIU_ALIGN_UNIT;
        MDrv_MIU_Copy(srcAddr+pFontBinHeader->u32BBoxOffset, u32DstAddr, u32Len,MIU_SDRAM2SDRAM);
        pFontSdramReport->u32BBoxAddr = u32DstAddr;
        u32DstAddr += u32Len;
        pFontSdramReport->u32SdramLen += u32Len;
    }
    else
    {
        pFontSdramReport->u32BBoxAddr = 0;
    }

    // Load codemap to SDRAM
    if (pFontBinHeader->u32CodemapBlockNum != 0 && pFontBinHeader->u32CodemapOffset != 0)
    {
        U32 u32Len = pFontBinHeader->u32CodemapBlockNum * sizeof(CHAR_CODEMAP_BLOCK);    // each block contains 6 bytes. 2 bytes for start and 2 for end.
        u32Len = ((u32Len+(MIU_ALIGN_UNIT-1))/MIU_ALIGN_UNIT)*MIU_ALIGN_UNIT;
        MDrv_MIU_Copy(srcAddr+pFontBinHeader->u32CodemapOffset, u32DstAddr, u32Len,MIU_SDRAM2SDRAM);
        pFontSdramReport->u32CodemapAddr = u32DstAddr;
        u32DstAddr += u32Len;
        pFontSdramReport->u32SdramLen += u32Len;
    }
    else
    {
        pFontBinHeader->u32CodemapBlockNum = 0;
        pFontBinHeader->u32CodemapOffset = 0;

        pFontSdramReport->u32CodemapAddr = 0;
    }

    // Below load glyph data to SDRAM
    u32DstAddr = GE_ADDR_ALIGNMENT(u32DstAddr);
    pFontSdramReport->u32GlyphAddr = u32DstAddr;
    u16LineBytes = msAPI_Font_GetLineBytes(pFontBinHeader);
    u16CharGlyphBytes = msAPI_Font_GetCharGlyphBytes(pFontBinHeader);

    u32SDRAMAddr=srcAddr+(U32)pFontBinHeader->u32FontGlyphOffset;


    switch (pFontBinHeader->u32Compression)
    {
        case FONT_COMPRESSION_NONE:

            MDrv_MIU_Copy(u32SDRAMAddr,u32DstAddr, msAPI_Font_GetFontGlyphBytes(pFontBinHeader),MIU_SDRAM2SDRAM);
            break;

        case FONT_COMPRESSION_BOUND_RECTANGLE:
        #if 0
            if (pFontBinHeader->u32BPP == 2 && u8TargetBPP == FONT_TARGET_BPP_I2_VARIANT)
            {
                if (!msAPI_MIU_LoadSDRAMFont_I2_To_3_I1(pFontBinHeader, u32SDRAMAddr, u32DstAddr, pFontSdramReport->u32BBoxAddr))
                {
                    return FALSE;
                }
            }
            else
            {
                if (pFontSdramReport->u32BBoxAddr == 0)
                {
                    return FALSE;
                }
                // Clear entire buffer to 0.
                MDrv_GE_ClearFrameBuffer(u32DstAddr, msAPI_Font_GetFontGlyphBytes(pFontBinHeader), 0);

                for (u16=0; u16<pFontBinHeader->u32CharNum; u16++)
                {
                    GET_Y_BBOX_FROM_SDRAM_TO_SRAM(pFontSdramReport->u32BBoxAddr, u16);

                    if (g_SRAM_BBox.u8Height != 0)
                    {
                        U16 offset = g_SRAM_BBox.u8Y0 * u16LineBytes;
                        U16 copysize = g_SRAM_BBox.u8Height * u16LineBytes;

                        MDrv_MIU_Copy(u32SDRAMAddr, u32DstAddr+ offset, copysize, MIU_SDRAM2SDRAM);

                        u32SDRAMAddr += copysize;
                    }
                    u32DstAddr += u16CharGlyphBytes;
                }
            }
            break;

        #endif

            if (pFontSdramReport->u32BBoxAddr == 0)
            {
                return FALSE;
            }

            // Clear entire buffer to 0.
            MDrv_GE_ClearFrameBuffer( u32DstAddr, msAPI_Font_GetFontGlyphBytes(pFontBinHeader), 0);

            for (u16=0; u16<pFontBinHeader->u32CharNum; u16++)
            {
                GET_Y_BBOX_FROM_SDRAM_TO_SRAM(pFontSdramReport->u32BBoxAddr, u16);

                if (g_SRAM_BBox.u8Height != 0)
                {
                    U16 offset = g_SRAM_BBox.u8Y0 * u16LineBytes;

                    U16 copysize = (g_SRAM_BBox.u8Height) * u16LineBytes;

                    size_bak =copysize;

#if 1
                    if( (u32DstAddr + offset)%MIU_ALIGN_UNIT != 0)
                    {
                         offset_align = 1;
                         u8shift = offset - (offset/MIU_ALIGN_UNIT)*MIU_ALIGN_UNIT;
                         copysize += u8shift;
                         offset = (offset/MIU_ALIGN_UNIT)*MIU_ALIGN_UNIT;
                    }
                    else {
                        u8shift = 0;
                        offset_align = 0;
                    }

#endif

                    //printf("u8Y0 = %02bx, u8Height = %02bx\n", g_SRAM_BBox.u8Y0, g_SRAM_BBox.u8Height);
//                    MDrv_MIU_XCopy(MCPY_LOADFONT, u32SDRAMAddr-u8shift, u32DstAddr + offset, ((copysize +(MIU_ALIGN_UNIT-1))/MIU_ALIGN_UNIT)*MIU_ALIGN_UNIT   );
                    MDrv_MIU_Copy(u32SDRAMAddr-u8shift,  u32DstAddr + offset, ((copysize +(MIU_ALIGN_UNIT-1))/MIU_ALIGN_UNIT)*MIU_ALIGN_UNIT ,MIU_SDRAM2SDRAM);
	             	i = ((copysize+(MIU_ALIGN_UNIT-1))/MIU_ALIGN_UNIT)*MIU_ALIGN_UNIT - copysize;
                    if( i != 0)
                    {
                        MDrv_Sys_SetXdataWindow1Base( (u32DstAddr + offset + copysize ) / (4096) );
                        while(i)
                        {
                            XBYTE[0xf000+((u32DstAddr + offset + copysize + i - 1)%4096)] = 0;
                            i--;
                        }
                    }

#if 1
                    if(offset_align)
                    {
                        MDrv_Sys_SetXdataWindow1Base( (u32DstAddr + offset) / (4096) );
                        i = 0;
                        while(u8shift)
                        {
                            XBYTE[0xf000+((u32DstAddr + offset + i )%4096)] = 0;
                            i++;
                            u8shift--;
                        }

                    }
#endif
                    copysize = size_bak;
                    u32SDRAMAddr += copysize;
                }
                u32DstAddr += u16CharGlyphBytes;
            }
            break;

        default:
            msWarning(ERR_FONT_WRONG_FORMAT);
            return FALSE;
    }

    // Note that u32FontGlyphBytes may indicate the size of compressed data.
    // So need to update the actual data size here.
    pFontBinHeader->u32FontGlyphBytes = msAPI_Font_GetFontGlyphBytes(pFontBinHeader);
    pFontSdramReport->u32SdramLen += pFontBinHeader->u32FontGlyphBytes;

    //printf("Load font: %ld ms\n", MDrv_Timer_TimeDifferenceFromCurrent(t0));
    return TRUE;
}
#endif

#undef MSAPI_MIU_C

⌨️ 快捷键说明

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