📄 l2_dramimg.c
字号:
/*++
Copyright (c) 2001 Sunplus Technology Co., Ltd.
Module Name:
L2_dram.c
Abstract:
Module related to L2 DRAM Image Processing functions
Environment:
Keil C51 Compiler
Revision History:
11/12/2001 YPWang created
--*/
//=============================================================================
//Header file
//=============================================================================
#include "general.h"
//Joe@2003.2.25 14:50 add begin
extern UCHAR L1_ScaleImage(ULONG SrcAddr, USHORT SrcHsize, USHORT SrcVsize,ULONG DstAddr, USHORT DstHsize, USHORT DstVsize, ULONG TempAddr);
//Joe@2003.2.25 14:50 add end
//=============================================================================
//Symbol
//=============================================================================
//-----------------------------------------------------------------------------
//Constant
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
//Variable
//-----------------------------------------------------------------------------
//=============================================================================
//Program
//=============================================================================
//-----------------------------------------------------------------------------
//L2_SetAGBAddr
//-----------------------------------------------------------------------------
/*
routine description:
Set image buffer A address
arguments:
AGBAddr - Starting address of image buffer A
return value:
0x00 - success
others - error
*/
UCHAR L2_SetAGBAddr(ULONG AGBAddr) USING_0
{
//PRINT_L2(" L2_SetAGGAddr: Enter\n");
//PRINT_L2(" L2_SetAGGAddr: AGBAddr=0x%lx\n",AGBAddr);
// set image buffer B starting address
XBYTE[0x2771] = (UCHAR)(AGBAddr);
XBYTE[0x2772] = (UCHAR)(AGBAddr >> 8);
XBYTE[0x2773] = (UCHAR)(AGBAddr >> 16);
//PRINT_L2(" L2_SetAGBAddr: Exit\n");
return L2K_SUCCESS;
}
//-----------------------------------------------------------------------------
//L2_SetBGBAddr
//-----------------------------------------------------------------------------
/*
routine description:
Set image buffer B address
arguments:
AGBAddr - Starting address of image buffer B
return value:
0x00 - success
others - error
*/
UCHAR L2_SetBGBAddr(ULONG BGBAddr) USING_0
{
//PRINT_L2(" L2_SetBGGAddr: Enter\n");
//PRINT_L2(" L2_SetBGBAddr: BGBAddr=0x%lx\n",BGBAddr);
// set image buffer B starting address
XBYTE[0x2774] = (UCHAR)(BGBAddr);
XBYTE[0x2775] = (UCHAR)(BGBAddr >> 8);
XBYTE[0x2776] = (UCHAR)(BGBAddr >> 16);
//PRINT_L2(" L2_SetBGGAddr: Exit\n");
return L2K_SUCCESS;
}
//-----------------------------------------------------------------------------
//L2_SetAGBSize
//-----------------------------------------------------------------------------
/*
routine description:
Set size of image buffer A
arguments:
AGBHsize- Image buffer A width
AGBVsize- Image buffer A height
return value:
0x00 - success
others - error
*/
UCHAR L2_SetAGBSize(USHORT AGBHsize, USHORT AGBVsize) USING_0
{
//PRINT_L2(" L2_SetAGBSize: Enter\n");
//PRINT_L2(" L2_SetAGBSize: AGBHsize=%d, AGBVsize=%d\n",AGBHsize,AGBVsize);
XBYTE[0x2777] = (UCHAR)(AGBHsize);
XBYTE[0x2778] = (UCHAR)(AGBHsize >> 8);
XBYTE[0x2779] = (UCHAR)(AGBVsize);
XBYTE[0x277A] = (UCHAR)(AGBVsize >> 8);
//PRINT_L2(" L2_SetAGGSize: Exit\n");
return L2K_SUCCESS;
}
//-----------------------------------------------------------------------------
//L2_SetBGBSize
//-----------------------------------------------------------------------------
/*
routine description:
Set size of image buffer B
arguments:
AGBHsize- Image buffer B width
AGBVsize- Image buffer B height
return value:
0x00 - success
others - error
*/
UCHAR L2_SetBGBSize(USHORT BGBHsize, USHORT BGBVsize) USING_0
{
//PRINT_L2(" L2_SetBGBSize: Enter\n");
//PRINT_L2(" L2_SetBGBSize: BGBHsize=%d, BGBVsize=%d\n",BGBHsize,BGBVsize);
XBYTE[0x277B] = (UCHAR)(BGBHsize);
XBYTE[0x277C] = (UCHAR)(BGBHsize >> 8);
XBYTE[0x277D] = (UCHAR)(BGBVsize);
XBYTE[0x277E] = (UCHAR)(BGBVsize >> 8);
//PRINT_L2(" L2_SetBGGSize: Exit\n");
return L2K_SUCCESS;
}
//-----------------------------------------------------------------------------
//L2_DoDRAMDMA
//-----------------------------------------------------------------------------
/*
routine description:
DMA function in the DRAM.
The data is moved from the source address to the destination address.
The addresses are byte address, and the size is based on number of bytes.
arguments:
SrcAddr - source data address of the DMA
DstAaddr- destination data address
nByte - number of bytes to be transferred
return value:
0x00 - success
others - error
*/
UCHAR L2_DoDRAMDMA(ULONG SrcAddr, ULONG DstAddr, ULONG nByte) USING_0
{
ULONG i;
//PRINT_L2(" L2_DoDRAMDMA: Enter\n");
//PRINT_L2(" L2_DoDRAMDMA: SrcAddr=0x%lx, DstAddr=0x%lx, nByte=%ld\n",SrcAddr,DstAddr,nByte);
XBYTE[0x2770] = 0x60; // Set DRAM to DRAM DMA mode
for(i=nByte; i>=1024; i=i-1024)
{
XBYTE[0x278B] = 0x00;
XBYTE[0x2771] = (UCHAR)(SrcAddr >> 1);
XBYTE[0x2772] = (UCHAR)(SrcAddr >> 9);
XBYTE[0x2773] = (UCHAR)(SrcAddr >> 17);
XBYTE[0x278B]|= (UCHAR)(SrcAddr) & 0x01;
XBYTE[0x2774] = (UCHAR)(DstAddr >> 1);
XBYTE[0x2775] = (UCHAR)(DstAddr >> 9);
XBYTE[0x2776] = (UCHAR)(DstAddr >> 17);
XBYTE[0x278B]|= ((UCHAR)DstAddr & 0x01) << 1;
XBYTE[0x2789] = 0xFF; // 1024 bytes
XBYTE[0x278A] = 0x03;
XBYTE[0x27A1] = 0x80; // start operation
while(!(XBYTE[0x27B0] & 0x80)); // wait operation done
SrcAddr+=1024;
DstAddr+=1024;
}
if(i!=0)
{
XBYTE[0x278B] = 0x00;
XBYTE[0x2771] = (UCHAR)(SrcAddr >> 1);
XBYTE[0x2772] = (UCHAR)(SrcAddr >> 9);
XBYTE[0x2773] = (UCHAR)(SrcAddr >> 17);
XBYTE[0x278B]|= (UCHAR)(SrcAddr) & 0x01;
XBYTE[0x2774] = (UCHAR)(DstAddr >> 1);
XBYTE[0x2775] = (UCHAR)(DstAddr >> 9);
XBYTE[0x2776] = (UCHAR)(DstAddr >> 17);
XBYTE[0x278B]|= ((UCHAR)(DstAddr) & 0x01) << 1;
XBYTE[0x2789] = (UCHAR)(i-1); // the last bytes
XBYTE[0x278A] = (UCHAR)((i-1)>>8);
XBYTE[0x27A1] = 0x80; // start operation
while(!(XBYTE[0x27B0] & 0x80)); // wait operation done
}
//PRINT_L2(" L2_DoDRAMDMA: Exit\n");
return L2K_SUCCESS;
}
//-----------------------------------------------------------------------------
//L2_ScaleUpImage
//-----------------------------------------------------------------------------
/*
routine description:
The function scales up the image stored in the source address
and the result image is written back to the destination address.
Free space is needed to store the temporary image after the first
one-dimensional operation.
arguments:
SrcAddr - Source image address (in the DRAM)
DstAddr - Destination image address
SrcHsize- Source image width (in pixels)
SrcVsize- Source image height
DstHsize- Destination image width
DstVsize- Destination image height
TempAddr- Free space address
return value:
0x00 - success
others - error
*/
UCHAR L2_ScaleUpImage(ULONG SrcAddr, USHORT SrcHsize, USHORT SrcVsize,ULONG DstAddr, USHORT DstHsize, USHORT DstVsize, ULONG TempAddr) USING_0
{
//PRINT_L2(" L2_ScaleUpImage: Enter\n");
//Joe@2003.2.25 14:51 modify begin
//joe delete old code, and add followed one line code
L1_ScaleImage(SrcAddr, SrcHsize, SrcVsize, DstAddr, DstHsize, DstVsize, TempAddr);
//Joe@2003.2.25 14:51 modify end
//PRINT_L2(" L2_ScaleUpImage: Exit\n");
return L2K_SUCCESS;
}
//patch5.0@richie@sdram mapping begin
//-----------------------------------------------------------------------------
//L2_ScaleUpImage_H
//-----------------------------------------------------------------------------
/*
routine description:
The function scales up the image stored in the source address
and the result image is written back to the destination address.
arguments:
SrcAddr - Source image address (in the DRAM)
DstAddr - Destination image address
SrcHsize- Source image width (in pixels)
SrcVsize- Source image height (in pixels)
DstHsize- Destination image width
return value:
0x00 - success
others - error
*/
UCHAR L2_ScaleUpImage_H(ULONG SrcAddr, USHORT SrcHsize, USHORT SrcVsize, ULONG DstAddr, USHORT DstHsize) USING_0
{
USHORT factor;
//PRINT_L2(" L2_ScaleUpImage: Enter\n");
//PRINT_DRAM(" L2_ScaleUpImage: SrcAddr=%lx, SrcHsize=%d, SrcVsize=%d, DstAddr=%lx, DstHsize=%d, DstVsize=%d, TempAddr=%lx\n",SrcAddr,SrcHsize,SrcVsize,DstAddr,DstHsize,DstVsize,TempAddr);
factor = ((ULONG)SrcHsize<<16)/DstHsize;
//PRINT_DRAM(" L2_ScaleUpImage: Vertical factor=%x\n",factor);
if(factor!=0)
{
XBYTE[0x2770] = 0x16; // set scaling-up mode
XBYTE[0x277F] = (UCHAR)(factor); // assign scaling factor
XBYTE[0x2780] = (UCHAR)(factor >> 8); // assign scaling factor
XBYTE[0x2771] = (UCHAR)(SrcAddr);
XBYTE[0x2772] = (UCHAR)(SrcAddr >> 8);
XBYTE[0x2773] = (UCHAR)(SrcAddr >> 16);
XBYTE[0x2774] = (UCHAR)(DstAddr);
XBYTE[0x2775] = (UCHAR)(DstAddr >> 8);
XBYTE[0x2776] = (UCHAR)(DstAddr >> 16);
XBYTE[0x2777] = (UCHAR)(SrcHsize);
XBYTE[0x2778] = (UCHAR)(SrcHsize >> 8);
XBYTE[0x2779] = (UCHAR)(SrcVsize);
XBYTE[0x277A] = (UCHAR)(SrcVsize >> 8);
XBYTE[0x277B] = (UCHAR)(DstHsize);
XBYTE[0x277C] = (UCHAR)(DstHsize >> 8);
XBYTE[0x277D] = (UCHAR)(SrcVsize);
XBYTE[0x277E] = (UCHAR)(SrcVsize >> 8);
XBYTE[0x27A1] = 0x80; // start operation
while(!(XBYTE[0x27B0] & 0x80)); // wait operation done
}
else
{
L2_CopyImage(SrcAddr, SrcHsize, SrcVsize, 0, 0, SrcHsize, SrcVsize, DstAddr, DstHsize, SrcVsize, 0, 0);
}
//PRINT_L2(" L2_ScaleUpImage: Exit\n");
return L2K_SUCCESS;
}
//-----------------------------------------------------------------------------
//L2_ScaleUpImage_V
//-----------------------------------------------------------------------------
/*
routine description:
The function scales up the image stored in the source address
and the result image is written back to the destination address.
arguments:
SrcAddr - Source image address (in the DRAM)
DstAddr - Destination image address
SrcHsize- Source image width (in pixels)
SrcVsize- Source image height
DstVsize- Destination image height
return value:
0x00 - success
others - error
*/
UCHAR L2_ScaleUpImage_V(ULONG SrcAddr, USHORT SrcHsize, USHORT SrcVsize ,ULONG DstAddr, USHORT DstVsize) USING_0
{
USHORT factor;
//PRINT_L2(" L2_ScaleUpImage: Enter\n");
//PRINT_DRAM(" L2_ScaleUpImage: SrcAddr=%lx, SrcHsize=%d, SrcVsize=%d, DstAddr=%lx, DstHsize=%d, DstVsize=%d, TempAddr=%lx\n",SrcAddr,SrcHsize,SrcVsize,DstAddr,DstHsize,DstVsize,TempAddr);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -