io_sdram.c
上传用户:super_houu
上传日期:2008-09-21
资源大小:4099k
文件大小:8k
- #include "config.h"
- #include "Includesysdefs.h"
- #include "Decoderlow_levelDEC_LL_Api.h"
- #include "PlaycoreCoremainCoreGDef.h"
- #include "cpucpu_api.h"
- #include "DecoderDEC_Set_DVP_Gen_Regs.h"
- #include "PlaycoreCaptureLogompeg_encenc.h"
- #ifdef SUPPORT_CAPTURE_LOGO
- #define MEM_ADDR(x) (UINT32)(x<<9)
- #define field_size() (UINT32)FB_FIELD_SIZE_DVD
- #define ref1_ytop_addr() MEM_ADDR((LONG)(OSD_BUFFER_SIZE_DVD + VCB_SIZE_DVD + ACB_SIZE_DVD + SPB_SIZE_DVD + APP_BUFFER_SIZE_DVD + NAV_BUFFER_SIZE_DVD))
- #define ref1_ybot_addr() (ref1_ytop_addr()+field_size()*512)
- #define ref1_ctop_addr() (ref1_ybot_addr()+field_size()*512)
- #define ref1_cbot_addr() (ref1_ctop_addr()+(field_size()+1)/2*512)
- #define ref2_ytop_addr() MEM_ADDR((LONG)(OSD_BUFFER_SIZE_DVD + VCB_SIZE_DVD + ACB_SIZE_DVD + SPB_SIZE_DVD + APP_BUFFER_SIZE_DVD + NAV_BUFFER_SIZE_DVD + R1FB_SIZE_DVD))
- #define ref2_ybot_addr() (ref2_ytop_addr()+field_size()*512)
- #define ref2_ctop_addr() (ref2_ybot_addr()+field_size()*512)
- #define ref2_cbot_addr() (ref2_ctop_addr()+(field_size()+1)/2*512)
- #define b_ytop_addr(x) (x? ref2_cbot_addr():(ref2_cbot_addr()+(field_size()+1)/2*512))
- #define b_ybot_addr() (b_ytop_addr(0)+field_size()*512)
- #define b_ctop_addr(x) (x? (b_ytop_addr(x)+field_size()*512):(b_ybot_addr()+field_size()*512))
- #define b_cbot_addr() (b_ctop_addr(0)+(field_size()+1)/2*512)
- static BYTE bIsFlashSpaceWriteable = FALSE;
- BOOL write_2_sdram( unsigned short x);
- typedef enum
- {
- REF1_BUFFER = 1,
- REF2_BUFFER = 2,
- B_BUFFER = 3
- }BUFFER_TYPE;
- /**********************************************************************************
- Purpose : read from Y buffer in SDRAM
- Input Parameters : buff - buffer to fill with read data
- offset - offset from start addr of the Y buffer ( top or bot ) in SDRAM
- num_of_pix - number of pixels to read
- Return Value :
- Comment: :
- **********************************************************************************/
- void read_Y_data( UINT16 *buff , unsigned long offset, int num_of_pixs )
- {
- UINT32 addr;
- offset = offset /2;
- num_of_pixs = num_of_pixs/2;
- if( pLogoCapture->TopFld )
- {
- switch( pLogoCapture->CurrDispBuff )
- {
- case REF1_BUFFER:
- addr = (UINT32)ref1_ytop_addr() + (UINT32)offset;
- break;
- case REF2_BUFFER:
- addr = (UINT32)ref2_ytop_addr() + (UINT32)offset;
- break;
- case B_BUFFER:
- addr = (UINT32)b_ytop_addr(pLogoCapture->bSingleField) + (UINT32)offset;
- }
- }
- else
- {
- switch( pLogoCapture->CurrDispBuff )
- {
- case REF1_BUFFER:
- addr = (UINT32)ref1_ybot_addr() + (UINT32)offset;
- break;
- case REF2_BUFFER:
- addr = (UINT32)ref2_ybot_addr() + (UINT32)offset;
- break;
- case B_BUFFER:
- addr = (UINT32)b_ybot_addr() + (UINT32)offset;
- break;
- }
- }
- wai_sem(SEM_DRAM_ID);
- I49_ReadDRAMData( addr, buff, num_of_pixs );
- sig_sem(SEM_DRAM_ID);
- #ifdef _DEBUG
- if(0 == offset)
- tr_printf(("Y addr: %lx, CurrDispBuff:%xn", addr, pLogoCapture->CurrDispBuff));
- #endif
- }
- /**********************************************************************************
- Purpose : read from C buffer in SDRAM
- Input Parameters : buff - buffer to fill with read data
- offset - offset from start addr of the C buffer ( top or bot ) in SDRAM
- num_of_pix - number of pixels to read
- Return Value :
- Comment: :
- **********************************************************************************/
- void read_C_data( UINT16 *buff , unsigned long offset, int num_of_pixs )
- {
- UINT32 addr;
- offset = offset/2;
- num_of_pixs = num_of_pixs/2;
- if( pLogoCapture->TopFld )
- {
- switch( pLogoCapture->CurrDispBuff )
- {
- case REF1_BUFFER:
- addr = ref1_ctop_addr() + offset;
- break;
- case REF2_BUFFER:
- addr = ref2_ctop_addr() + offset;
- break;
- case B_BUFFER:
- addr = b_ctop_addr(pLogoCapture->bSingleField) + offset;
- }
- }
- else
- {
- switch( pLogoCapture->CurrDispBuff )
- {
- case REF1_BUFFER:
- addr = ref1_cbot_addr() + offset;
- break;
- case REF2_BUFFER:
- addr = ref2_cbot_addr() + offset;
- break;
- case B_BUFFER:
- addr = b_cbot_addr() + offset;
- }
- }
- wai_sem(SEM_DRAM_ID);
- I49_ReadDRAMData( addr, buff, num_of_pixs );
- sig_sem(SEM_DRAM_ID);
- #ifdef _DEBUG
- if(0 == offset)
- tr_printf(("C addr: %lx, CurrDispBuff:%xn", addr, pLogoCapture->CurrDispBuff));
- #endif
- }
- /**********************************************************************************
- Purpose : initializations for capture logo IO
- Input Parameters : none
- Return Value :
- Comment: :
- **********************************************************************************/
- void init_io(void)
- {
- int i;
- int status;
- //ui_tmp_string("wait");
- if ( !CheckAddressWritable((unsigned short far *) MK_FP(LOGO_SEG , 0x0000)))
- {
- {
- unsigned short far* sectorAddr = MK_FP( LOGO_SEG , 0 );
- Erase_One_Sector(sectorAddr);
- }
- for( i=1 ; i<LOGO_SIZE_IN_BLOCKS; i++)
- {
- unsigned short far* sectorAddr = MK_FP( SEG_LOGO_BLOCK2 + (i - 1)*SIZE_LOGO_BLOCK2, 0);
- Erase_One_Sector(sectorAddr);
- }
- bIsFlashSpaceWriteable = FALSE;
- }else
- bIsFlashSpaceWriteable = TRUE;
-
- if(IS_CLIPS_TYPE_JPG)//LeonH_0829_2003_a
- {
- pLogoCapture->CurrDispBuff = REF2_BUFFER; // on jpeg always displayed ref2
- }
- else
- {
- // I49_SetPar_bits( DVP_GEN2_ADDR, DVPGEN2_PSO_ON_MASK, DVPGEN2_PSO_ON_MASK );
- DEC_Set_DVP_Gen_For_PSO_OnOff(TRUE);
-
- status = I49_ReadStatus(I64_STATUS_2) & 0x300;
- switch( status )
- {
- case 0x100:
- pLogoCapture->CurrDispBuff = REF1_BUFFER;
- break;
- case 0x200:
- pLogoCapture->CurrDispBuff = REF2_BUFFER;
- break;
- default:
- pLogoCapture->CurrDispBuff = B_BUFFER;
- }
- //printf("buff = %xn", status );
- }
- #ifdef _DEBUG
- tr_printf(("I49_STATUS_2:%xn", status));
- #endif
-
- if(576 == pLogoCapture->Vsize && B_BUFFER == pLogoCapture->CurrDispBuff) // Jerry CAI, a temp fix as SDRAM config for pal DVD is unknown.
- pLogoCapture->CurrDispBuff = REF1_BUFFER;
-
-
- pLogoCapture->FlashADDR = LOGO_ADDR;
- gps->captureLogoKWords =-1;
- }
- /**********************************************************************************
- Purpose :
- Input Parameters :
- Output Parameters:
- Return Value :
- Comment: :
- **********************************************************************************/
- void io_end()
- {
- if( !IS_CLIPS_TYPE_JPG)//LeonH_0829_2003_a
- {
- if( gps->prog_inter_select ) // set back force progressiv bit to DVP
- // I49_SetPar_bits( DVP_GEN2_ADDR, DVPGEN2_PSO_ON_MASK, DVPGEN2_PSO_ON_MASK );
- DEC_Set_DVP_Gen_For_PSO_OnOff(TRUE);
- else
- // I49_SetPar_bits( DVP_GEN2_ADDR, 0, DVPGEN2_PSO_ON_MASK );
- DEC_Set_DVP_Gen_For_PSO_OnOff(FALSE);
- }
- }
- /**********************************************************************************
- Purpose : output bitstream to flash
- Input Parameters :
- Output Parameters:
- Return Value :
- Comment: :
- **********************************************************************************/
- void output(unsigned short x)
- {
- if(pLogoCapture->sectors_cnt < LOGO_SIZE_IN_DVD_SECTORS)
- {
- if ( bIsFlashSpaceWriteable )
- write_2_sdram( x);
- else
- write_2_flash( x);
- }
- }
- /**********************************************************************************
- Purpose :
- Input Parameters :
- Output Parameters:
- Return Value :
- Comment: :
- **********************************************************************************/
- #ifdef _DEBUG
- #define WRITE_2_SRAM
- #endif
- BOOL write_2_sdram( unsigned short x)
- {
-
- static int first_time = 1;
-
- *(pLogoCapture->FlashADDR) = (x<<8)|(x>>8);
- pLogoCapture->FlashADDR ++;
- return 1;
- }
- /**********************************************************************************
- Purpose :
- Input Parameters :
- Output Parameters:
- Return Value :
- Comment: :
- **********************************************************************************/
- int write_2_flash( unsigned short x )
- {
- int ret;
- x = (x<<8)|(x>>8);
- ret = Nor_Write(pLogoCapture->FlashADDR,
- (unsigned char far *)&x, 2);
- pLogoCapture->FlashADDR ++;
- //if( ret != 1 )
- // ui_tmp_string("Fail");
- return ret;
- }
- #endif