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

📄 hw_screen.c

📁 瑞星微公司RK27XX系列芯片的SDK开发包
💻 C
📖 第 1 页 / 共 3 页
字号:
        DestAddr = DestRGBAddr + 4 * Bufoffset + (Line % LineFactor) * 4 * DWidth;

        DWDMA_LLPCfg(SourAddr, DestAddr, LLPList, Datalen);
    }

    if (Screen_GetType() == MCULCD)
        DWDMA_LLPEnd(LLPList - 1);
    else
        DWDMA_LLPChange(LLPList - 1, &LCDCDev.LLPTable);
}




/*---------------------------------------------------------
Name  :  Screen_CreatLLPMPEG2
Dec   :  设置MPEG2 YUV的相关LLP链接
Params:  Screen -> JPEG YUV背景的相关配置参数
Return:
Author:  nzy
Date  :
-----------------------------------------------------------*/
void Screen_CreatLLPMPEG2(BACKGRND *Screen)
{
    UINT32 Line,ScaleStep,Lineoffset,Bufoffset;
    UINT32 SWidth,DWidth,DarkOffset,Datalen;
    UINT32 CurYTemp,CurUVTemp,UVTemp;
    UINT32 SourYAddr,SourUVAddr,DestYAddr,DestUVAddr;
    UINT32 VirTolLine=0,VirLine=0,ActLine=0,ActLine2=0;
    DWDMALLP *LLPList;

    SWidth     = Screen->RawXSize/4;
    DWidth     = Screen->ViewXSize/4;
    Datalen    = Screen->RawXSize>Screen->ViewXSize ? DWidth : SWidth;
    Bufoffset  = Screen->RawXSize>Screen->ViewXSize ? 0 : ((DWidth-SWidth)/2)&0xfffc;
    Lineoffset = Screen->RawYSize>Screen->ViewYSize ? 0 : ((Screen->ViewYSize -Screen->RawYSize)/2) &0xfffe;
    SourYAddr  = Screen->SdramAddr;
    SourUVAddr = (Screen->SdramAddr2) ? (Screen->SdramAddr2) : (Screen->SdramAddr+Screen->RawXSize*((Screen->RawYSize+15) &0xfff0));
    DestYAddr  = (UINT32)RegLCDC_BUF;
    DestUVAddr = DestYAddr + 16*DWidth;
    ScaleStep  = Screen->LCDCConfig.ScaleY;
    LLPList    = Screen->LLPList;
    DarkOffset = (Lineoffset<=2) ? 2 : 0;


    DWDMA_LLPCfg((UINT32)SDRAM_DARK_Y, DestYAddr, LLPList, 4*DWidth);
    DWDMA_LLPCfg((UINT32)SDRAM_DARK_UV, DestUVAddr, LLPList+1, 4*DWidth);
    if (Screen_GetType()==MCULCD)
        DWDMA_LLPEnd(LLPList+1);
    else
        DWDMA_LLPChange(LLPList+1, Screen->LLPList+6);

    LLPList+=2;

    if ( Screen->RawYSize*ScaleStep > 480*0x200 )   //抽奇数行
    {
        ScaleStep = (ScaleStep>=0x3ff) ? (UINT32)(Screen->RawYSize/2-1)*0x200/(LCDCDev.YSize-1) : ScaleStep/2;
        Screen->LCDCConfig.ScaleY = ScaleStep;
        Screen->LCDCConfig.LineUVAddr[0] = Screen->ViewXSize*4/4;
        Screen->LCDCConfig.LineUVAddr[1] = Screen->ViewXSize*5/4;
        Screen->LCDCConfig.LineUVAddr[2] = Screen->ViewXSize*6/4;
        Screen->LCDCConfig.LineUVAddr[3] = Screen->ViewXSize*7/4;

        SourYAddr += 4*(Screen->OffsetX/4);
        SourUVAddr += 4*(Screen->OffsetX/4);

        for ( Line=0; Line<LCDCDev.YSize; Line++,LLPList+=2 )
        {
            VirTolLine += ScaleStep;
            VirLine = (VirTolLine>>9);

            if (ScaleStep < 0x300)    VirLine += 1;
            if (ScaleStep < 0x200)    VirLine += 1;

            if (VirLine > ActLine)
            {
                CurYTemp = CurUVTemp = ((VirLine-1)==ActLine) ? 1 : 2;
                if ( (ActLine*2<Lineoffset) || (ActLine*2>=(Screen->RawYSize+Lineoffset)) )
                {
                    DWDMA_LLPCfg((UINT32)SDRAM_DARK_Y, DestYAddr+4*Bufoffset+(ActLine&0x03)*4*DWidth, LLPList, CurYTemp*Datalen);
                    DWDMA_LLPCfg((UINT32)SDRAM_DARK_UV, DestUVAddr+4*Bufoffset+(ActLine&0x03)*4*DWidth, LLPList+1, CurUVTemp*Datalen);
                }
                else
                {
                    if (2==CurYTemp)
                    {
                        DWDMA_LLPCfg(SourYAddr+(ActLine*2-Lineoffset)*4*SWidth, DestYAddr+4*Bufoffset+(ActLine&0x03)*4*DWidth, LLPList, Datalen);
                        DWDMA_LLPCfg(SourYAddr+((ActLine+1)*2-Lineoffset)*4*SWidth, DestYAddr+4*Bufoffset+((ActLine+1)&0x03)*4*DWidth, LLPList+1, Datalen);
                        CurUVTemp = 0;
                    }
                    else
                    {
                        DWDMA_LLPCfg(SourYAddr+(ActLine*2-Lineoffset)*4*SWidth, DestYAddr+4*Bufoffset+(ActLine&0x03)*4*DWidth, LLPList, Datalen);
                        CurUVTemp = (VirLine==ActLine2) ? 1 : 2;
                        if ((2==CurUVTemp)&&((ActLine2&0x03)==3))      CurUVTemp = 1;
                        DWDMA_LLPCfg(SourUVAddr+((ActLine2*2-Lineoffset)/2)*4*SWidth, DestUVAddr+4*Bufoffset+(ActLine2&0x03)*4*DWidth, LLPList+1, CurUVTemp*Datalen);
                    }
                }
                DWDMA_EnableDSR(LLPList);
                DWDMA_EnableDSR(LLPList+1);

                ActLine += CurYTemp;
                ActLine2 += CurUVTemp;
            }
            else
            {
                DWDMA_LLPCfg(SourYAddr, SourYAddr, LLPList, 1);
                DWDMA_LLPCfg(SourUVAddr, SourUVAddr, LLPList+1, 1);
            }
        }

    }
    else    //不抽行
    {
        for ( Line=0; Line<LCDCDev.YSize; Line++,LLPList+=2 )
        {
            VirTolLine += ScaleStep;
            VirLine = (VirTolLine>>9);

            if (ScaleStep < 0x300)    VirLine += 1;
            if (ScaleStep < 0x200)    VirLine += 1;

            if (VirLine > ActLine)
            {
                CurYTemp = ((VirLine-1)==ActLine) ? 1 : 2;
                if ((2==CurYTemp)&&((ActLine&0x03)==3))      CurYTemp = 1;

                if ((ActLine<Lineoffset)||(ActLine>=Screen->RawYSize+Lineoffset))
                {
                    DWDMA_LLPCfg((UINT32)SDRAM_DARK_Y, DestYAddr+4*Bufoffset+(ActLine&0x03)*4*DWidth, LLPList, CurYTemp*Datalen);
                    UVTemp = ((ActLine+CurYTemp-1)&0x03)>>1;
                    DWDMA_LLPCfg((UINT32)SDRAM_DARK_UV, DestUVAddr+4*Bufoffset+(UVTemp)*4*DWidth, LLPList+1, Datalen);
                }
                else
                {
                    DWDMA_LLPCfg(SourYAddr+(ActLine-Lineoffset)*4*SWidth, DestYAddr+4*Bufoffset+(ActLine&0x03)*4*DWidth, LLPList, CurYTemp*Datalen);
                    UVTemp = ((ActLine+CurYTemp-1)&0x03)>>1;
                    DWDMA_LLPCfg(SourUVAddr+((ActLine-Lineoffset)/2)*4*SWidth, DestUVAddr+4*Bufoffset+(UVTemp)*4*DWidth, LLPList+1, Datalen);
                }
                DWDMA_EnableDSR(LLPList);
                DWDMA_EnableDSR(LLPList+1);

                ActLine += CurYTemp;
            }
            else
            {
                DWDMA_LLPCfg(SourYAddr, SourYAddr, LLPList, 1);
                DWDMA_LLPCfg(SourUVAddr, SourUVAddr, LLPList+1, 1);
            }
        }
    }

    DWDMA_LLPChange(LLPList-1, &LCDCDev.LLPTable);//上一屏的LLP的最后位置链接到当前屏的LLP的首位置

    if (Screen_GetType()!=MCULCD)
    {
        DWDMA_LLPChange(Screen->LLPList+5, LLPList);
        for (Line=0; Line<4; Line++,LLPList++)
            DWDMA_LLPCfg(SourYAddr, SourYAddr, LLPList, 1);
        DWDMA_LLPChange(LLPList-1, Screen->LLPList+6);
    }
    else
    {
        DWDMA_LLPEnd(Screen->LLPList+3);//传完LCD的前两行后停止LLP链接
    }

}


/*---------------------------------------------------------
Name  :  Screen_CreatLLPAlpha
Dec   :  设置RGB565的相关LLP链接
Params:  Screen -> RGB565前景的相关配置参数
Return:
Author:  nzy
Date  :
-----------------------------------------------------------*/
void Screen_CreatLLPAlpha(FRONTGRND *FrontGrnd)
{
    UINT32 Line, RawXSize;
    UINT32 SdramFifoAddr, FifoAddr;
    UINT32 ViewXSize, ViewYSize;
    DWDMALLP *LLPList;

    RawXSize = FrontGrnd->RawXSize;
    ViewXSize = FrontGrnd->ViewXSize;
    ViewYSize = FrontGrnd->ViewYSize;
    SdramFifoAddr = FrontGrnd->SdramAddr;
    FifoAddr = (FrontGrnd->AlphaConfig.FifoAddr << 2) | LCDC_DWDMA_FIFO;
    LLPList = FrontGrnd->LLPList;

    for (Line = 0; Line < ViewYSize - 1; Line++, LLPList++)
        DWDMA_LLPCfg(SdramFifoAddr + Line*RawXSize*2, FifoAddr, LLPList, ViewXSize / 2);

    DWDMA_LLPCfg((UINT32)SDRAM_DARK_RGB, FifoAddr, LLPList, ViewXSize / 2);
    DWDMA_LLPChange(LLPList, FrontGrnd->LLPList);

    DWDMA_LLPCfg((UINT32)SDRAM_DARK_RGB, FifoAddr, &AlphaDarkLLP, ViewXSize / 2);
    DWDMA_LLPEnd(&AlphaDarkLLP);
}


/*---------------------------------------------------------
Name  :  Screen_Change
Dec   :  将LLP指向当前所设置背景
Params:  Screen -> 当前背景的相关配置参数
Return:
Author:  nzy
Date  :
-----------------------------------------------------------*/
void Screen_Change(SCREEN *BScreen)
{
    LCDCCONFIG *pCurr, *pNext;

    pCurr = &(LCDCDev.Screen->LCDCConfig);
    pNext = &(BScreen->LCDCConfig);

    if (memcmp(pCurr, pNext, sizeof(LCDCCONFIG)) != 0)
        LCDCDev.ReConfig = 1;

    LCDCDev.Screen = BScreen;
}


/*---------------------------------------------------------
Name  :  Screen_ChangeAlpha
Dec   :  将LLP指向当前所设置前景
Params:  Screen -> 当前前景的相关配置参数
Return:
Author:  nzy
Date  :
-----------------------------------------------------------*/
void Screen_ChangeAlpha(FRONTGRND *FScreen)
{
    ALPHACONFIG *pCurr, *pNext;

    if (FScreen == NULL)
        Screen_SetAlphaEn(FIFOEnable);

    pCurr = &(LCDCDev.FrontGrnd->AlphaConfig);
    pNext = &(FScreen->AlphaConfig);

    if (memcmp(pCurr, pNext, sizeof(ALPHACONFIG)) != 0)
        LCDCDev.ReConfigAlpha = 1;

    LCDCDev.FrontGrnd = FScreen;
}


/*---------------------------------------------------------
Name  :  Screen_SetAlpha
Dec   :  设置前景Alpha参数
Params:  Alpha -> 前景的Alpha参数
Return:
Author:  nzy
Date  :
-----------------------------------------------------------*/
void Screen_SetAlpha(UINT16 Alpha)
{
    if (LCDCDev.FrontGrnd != 0)
    {
        LCDCDev.FrontGrnd->AlphaConfig.AlphaLevel = Alpha;
        LCDCDev.ReConfigAlpha = 0x1;
    }
}


/*---------------------------------------------------------
Name  :  Screen_Display
Dec   :  设置显示状态
Params:  ON  -> 打开显示
         OFF -> 关闭显示
Return:
Author:  nzy
Date  :
-----------------------------------------------------------*/
void Screen_Display(DISSTATUS Status)
{
    if (Screen_GetType() == TVOUT)
        return;

    if (Screen_GetType() == MCULCD)
    {
        Lcdctrl_McuBypassMode(BYPASS);
        if (Status == ON)
            Mcupanel_Standby(MCU_NORMAL);
        else
            Mcupanel_Standby(MCU_STANDBY);
        //Lcdctrl_Display(Status);
        Lcdctrl_McuBypassMode(BUFFER);
    }
    else
    {
        if (Status == OFF)
        {
            Rgbpanel_Standby(RGB_STANDBY);
            Intr_Disable( INTC_LCDC );
            WriteReg32(DWDMA_ChEnReg, 0xf00);						// enable
            WriteReg32(DWDMA_ClearBlock, 0x0f);
        }
        else
        {
            Intr_Enable( INTC_LCDC );
            Rgbpanel_Standby(RGB_NORMAL);
        }
        //Lcdctrl_Display(Status);
    }
    Lcdctrl_Display(Status);

}


/*---------------------------------------------------------
Name  :  Screen_ScanDirSet
Dec   :  设置扫描方向
Params:  XSize  -> LCD的X方向宽度
         YSize  -> LCD的Y方向高度
Return:
Author:  nzy
Date  :
-----------------------------------------------------------*/
void Screen_ScanDirSet(UINT16 XSize, UINT16 YSize)
{
    if (Screen_GetType() != MCULCD)
        return;

    LCDCDev.XSize = XSize;
    LCDCDev.YSize = YSize;

    Lcdctrl_McuBypassMode(BYPASS);
    Mcupanel_ScanDirSet(XSize, YSize);
    LcdCtrl_MCUIFparaSet(XSize, YSize);
    Lcdctrl_McuBypassMode(BUFFER);
}


/*---------------------------------------------------------
Name  :  Screen_GetMCUIFStatus
Dec   :  设置为MCU接口时,获取当前LCDC的刷屏状态
Params:
Return:  BUSY -> 正在刷屏
         IDLE -> 空闲时刻
Author:  nzy
Date  :
-----------------------------------------------------------*/
MCUIFSTATUS Screen_GetMCUIFStatus(void)
{
    UINT32 temp;

    if (Screen_GetType() == MCULCD)
    {
        temp = Lcdctrl_GetStatus(); //MCU interface busy
        return temp;
    }
    return IDLE;
}


/*---------------------------------------------------------
Name  :  Screen_SetMcuIFWaitTime
Dec   :  设置MCU屏刷屏速率
Params:
Return:
Author:  nzy
Date  :
-----------------------------------------------------------*/
void Screen_SetMcuIFWaitTime(UINT16 FreqMHZ)
{
    UINT32 MixASTime;
    UINT32 MixAHTime;
    UINT32 wetime;
    UINT32 MCUIFWait;

    if (Screen_GetType() != MCULCD)
        return;

    MixASTime = (FreqMHZ > 100) ? 3 : 2;
    wetime = 11;
    MixAHTime = 2;
    MCUIFWait = (MixASTime << 7) + (wetime << 3) + (MixAHTime << 0);

    LcdCtrl_SetMcuIFWaitTime(MCUIFWait);
}


/*---------------------------------------------------------
Name  :  Screen_SetTvout
Dec   :  设置TV画面大小
Params:  TVoutOption -> TVOUT设置选项
         pTVoutPara  -> TVOUT设置参数
         Para1       -> TVOUT设置附加参数1
         Para2       -> TVOUT设置附加参数2
Return:
Author:  nzy
Date  :
-----------------------------------------------------------*/
void Screen_SetTvout(TVOUTOPTION TVoutOption, TVOUTPARA *pTVoutPara, UINT32 Para1, UINT32 Para2)
{

    switch (TVoutOption)
    {
        case TVOUT_Adjust:
            Tvout_PostAdjust(pTVoutPara->Oddtion.Shife, Para1);
            break;
        case TVOUT_Scale:
            Tvout_ScalAdjust(pTVoutPara->Oddtion.Zoom, Para1);
            break;
        case TVOUT_Status:
            Tvout_SetStatus(pTVoutPara->Oddtion.Status);
            break;
        case TVOUT_Test:
            Tvout_SetTest(pTVoutPara->Oddtion.Status);
            break;
        case TVOUT_Disp:
            Tvout_Display(pTVoutPara->Oddtion.Disp, pTVoutPara->Mode);
            break;
        case TVOUT_Size:
            LcdCtrl_SetTvImageSize(Para1, Para2, pTVoutPara);
            //Tvout_SizeSet(pTVoutPara);
            break;
        default:
            break;
    }
}


⌨️ 快捷键说明

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