pe_sacd.c
上传用户:super_houu
上传日期:2008-09-21
资源大小:4099k
文件大小:7k
- /*
- File name: PE_SACD.C
- Description: Presentation engine for SACD.
- Author: Jerry CAI, ZORAN China.
- Created on: August 18, 2003
- */
- #include "config.h"
- #if D_SUPPORT_SACD
- #include "playcoresampsamp_gen.h"
- #include "drivedrv_api.h"
- #include "drivezfeplmplm_pfi.h"
- #include "kerneleventdef.h"
- #include "kernelker_api.h"
- #ifdef _DEBUG
- #include "decoderdecoder.h";
- #endif
- #include "playcorecoremaincoregdef.h"
- #include "playcorenav_cddape_cd.h"
- #include "decoderadp_api.h"
- #include "decoderlow_leveldec_ll_api.h"
- #include "drivedrv_defs.h"
- #include "drivezfeplmplm_pfi.h"
- void dec_sacd(void);
- static void dec_sacd_destruct(void);
- void PE_SACD_AbortPlayback(BOOL bRemainInStandby);
- #define MASTER_TOC1_SA 510
- #define MASTER_TOC2_SA 520
- #define MASTER_TOC3_SA 530
- #define MASTER_TOC_LEN 10
- void READ_ADP_BUFFER(void);
- /*
- Desc: Set up timing for XMT2.
- */
- void SACD_XMIT2_TIMING(void)
- {
- //TODO: To support both SAD and card reader, a GPIO should be allocated for chip select purpose.
- asm
- {
- pushf
- cli
- mov dx, 0a18h // ; XMIT02:Setup period for CS2
- mov ax, 0000h //; (was 0002h)
- out dx, ax
- mov dx, 0a1ah // ; XMITr12:Read period for CS2
- mov ax, 001ch //jerry was 13h
- out dx, ax
- mov dx, 0a1ch // ; XMITw12:Write period for CS2
- mov ax, 001ch //; //jerry was 13h
- out dx, ax
- mov dx, 0a1eh // ; XMITw12:Hold period for CS2
- mov ax, 0000h
- out dx, ax
- mov dx, 0a20h // ; XMIT32:Recovery period for CS2
- mov ax, 0001h
- out dx, ax
- // mov dx, 0a2ch // ; xmi_config addr
- // mov ax, 012ch //; was 012ch. changed to enable DSPWAIT for CS2
- // out dx, ax
- popf
- }
- }
- /*
- Desc: system initialization for SACD playback.
- 1.Setup bus timing
- 2.setup decoder.
- */
- SAMP(ErrCode) SAMP(BE_Init)(void)
- {
- SACD_XMIT2_TIMING();
- dec_sacd();
- return SAMP(ERR_OK);
- }
- /*
- Desc: system cleanup after SACD playback
- */
- SAMP(ErrCode) SAMP(BE_Term)(void)
- {
- PE_SACD_AbortPlayback(1);
- dec_sacd_destruct();
- return SAMP(ERR_OK);
- }
- /*
- Desc: open tray
- This function is asynchronous.
- */
- SAMP(ErrCode) SAMP(BE_TrayOpen)(void)
- {
- SAMP(BE_Term)();
- ie_send(IE_CORE_CMD_EJECT);
- return SAMP(ERR_OK);
- }
- /*
- Desc: close tray
- This function is asynchronous.
- */
- SAMP(ErrCode) SAMP(BE_TrayClose)(void)
- {
- ie_send(IE_CORE_CMD_CLOSE_TRAY);
- return SAMP(ERR_OK);
- }
- SAMP(ErrCode) SAMP(BE_GetDataArea)(SAMP(UInt32)* startDataArea, SAMP(UInt32)* endDataArea, SAMP(UInt32)* endLayer0)
- {
- //SACD disc is not recognized.
- if(DEC_DISC_TYPE_SACD != g_disc_type)
- return SAMP(ERR_FAILED);
- drv_get_disc_data_zone(startDataArea, endDataArea, endLayer0);
- return SAMP(ERR_OK);
- }
- /*
- Desc: Play a SACD segment.
- In: UInt32 dwStartAddress, physical start aaddress of the segment.
- ULONG ulBlocksCnt, number of sectors to play.
- Out: TRUE, succeed.
- */
- BOOL PE_SACD_PlaySegment(UINT32 dwStartAddress)
- {
- UINT32 blockcnt;
- DWORD startDataArea, endDataArea, endLayer0;
- drv_abort_play();
- DEC_Stop_DVP_ADP_cmd(0);
- // DEC_PlaybackCommand(DEC_PLAYBACK_CMD_STOP, 0);
- // DEC_LL_SyncHostCommand(DEC_API_COMMAND_STOP, 0);
-
- /* get disc's data zone information */
- drv_get_disc_data_zone(&startDataArea, &endDataArea, &endLayer0);
- if(IS_OPPOSITE && dwStartAddress > endLayer0)
- {
- blockcnt = endDataArea - dwStartAddress + 1;
- dwStartAddress |= 0x1000000;
- }
- else if(IS_OPPOSITE)
- {
- blockcnt = endDataArea - (~endLayer0)+ endLayer0 - dwStartAddress + 2;
- }
- else
- blockcnt = endDataArea - dwStartAddress + 1;
- #ifndef CHECK_SACD_ADP_CODE_BUFFER
- DEC_LL_SetDVDStartEndSector( dwStartAddress, 0xfffffffful );
- #else
- DEC_LL_SetDVDStartEndSector( dwStartAddress, 20 );
- #endif
- drv_play_dvd( (unsigned long) dwStartAddress, blockcnt, DRVF_PLAY_DVD_DUMP_DATA); //DRVF_PLAY_DVD_AV_DATA); //DRVF_PLAY_DVD_DUMP_DATA );//todo: check later.
- // DEC_LL_SyncHostCommand(DEC_API_COMMAND_PLAY,0);
- DEC_PlaybackCommand(DEC_PLAYBACK_CMD_PLAY, NULL);
- return TRUE;
- }
- SAMP(ErrCode) SAMP(BE_ReadToc)(void)
- {
- return SAMP(ERR_OK);
- }
- /*
- Desc: Request SACD data from FE
- */
- SAMP(ErrCode) SAMP(BE_Seek)(SAMP(UInt32) pos)
- {
- if(get_cbselect() != DEC_LL_CBSELECT_SACD)
- {
- dec_sacd();
- }
- if(TRUE == PE_SACD_PlaySegment(pos))
- {
- return SAMP(ERR_OK);
- }
- else
- {
- return SAMP(ERR_FAILED);
- }
- }
- /*
- Desc: set the minimal data transfer rate of the basic engine.
- ZORAN's system will always run at the highest data transfer rate of around 17M bit/sec.
- */
- SAMP(ErrCode) SAMP(BE_SetTransferRate)(SAMP(UInt32) rate)
- {
- return SAMP(ERR_OK);
- }
- /*
- Desc: abort SACD playback
- */
- void PE_SACD_AbortPlayback(BOOL bRemainInStandby)
- {
- drv_abort_play();
- DEC_Stop_DVP_ADP_cmd(0);
- // DEC_PlaybackCommand(DEC_PLAYBACK_CMD_STOP, 0);
- // DEC_LL_SyncHostCommand(DEC_API_COMMAND_STOP, 0);
- if (! bRemainInStandby)
- drv_spindown();
- return;
- }
- #ifdef _DEBUG
- #define AUDIO_BUFER_ADDR 360448UL //(204 + 500)*512
- #define AUDIO_BUFFER_SIZE 25600UL //50*512
- /*
- Desc: print the ADP buffer to hyper terminal.
- */
- void READ_ADP_BUFFER(void)
- {
- unsigned int buffer[32];
- unsigned long addr = AUDIO_BUFER_ADDR;
- int i;
- while( addr < AUDIO_BUFER_ADDR+AUDIO_BUFFER_SIZE )
- {
- DEC_ReadDRAMData(addr, buffer, 32 );
- addr +=32;
- for(i=0; i<32;i++ )
- {
- printf("0x%x,n", buffer[i]);
- }
- }
- printf("};n");
- }
- #endif //_DEBUG
- void dec_sacd(void)
- {
- // dec_sacd_destruct(); //todo: remove later.
- DEC_SetDiskType(DEC_DISC_TYPE_SACD);
- DEC_prepare_to_decode();
- DEC_SetSID(DEC_SID_TYPE_AUDIO, SACD_SID);
- //sacd todo: check later.
- #ifndef SACD_HW_EVAL
- // DEC_PlaybackCommand(DEC_PLAYBACK_CMD_PLAY, NULL); //to get amclk
- #endif
- #ifdef AUDIO_DAC_SUPPORT_DSD
- DAC_Set_DSD_Mode(1);
- #endif
- }
- static void dec_sacd_destruct(void)
- {
- DEC_SetDiskType(DEC_DISC_TYPE_DVD_VIDEO);
- //todo: check what to do with Dien peng.
- g_disc_type = DEC_DISC_TYPE_DVD_VIDEO;
- DEC_prepare_to_decode();
- #ifdef AUDIO_DAC_SUPPORT_DSD
- DAC_Set_DSD_Mode(0);
- #endif
- g_disc_type = DEC_DISC_TYPE_VCD; //jerry cai new!
- {
- // 20040908 - added to fix DVD-R problem
- if(DEC_DISC_TYPE_SACD != g_disc_type)
- { tr_printf(("n logo display part !"));
- // if( !WhiteNoiseMode) //ZKR ML092304 Change if sentense.
- Logo_display();
- }
- DEC_UpdateAudAnalogParameters(); // Update audio analog setting
- }
- return;
- }
- #endif