hweval_zoran.c
上传用户:super_houu
上传日期:2008-09-21
资源大小:4099k
文件大小:30k
- /*******************************************************************************
- * Copyright(c) Philips Consumer Electronics B.V. 2001
- * The attached material and the information contained therein is proprietary
- * to Philips and is issued only under strict confidentiality arrangements.
- * It shall not be used, reproduced, copied in whole or in part, adapted,
- * modified, or disseminated without a written license of Philips.
- * It must be returned to Philips upon its first request.
- *
- * Project: SA-MP ( Super Audio Media Player )
- * File %name: hweval.c %
- * %version: 5 %
- * %date_modified: Thu Jul 18 14:22:09 2002 %
- * %derived_by: potm %
- * Creation date: Mon Apr 08 10:37:53 2002
- * First author: klerxm
- *
- * Advanced Systems and Applications Lab - Eindhoven
- *
- * Continuus %full_filespec: hweval.c~5:csrc:1 %
- *
- * Description: Source file of Furore2 hardware evaluation routines
- *
- * Change history:
- *
- * Rev Date Who Comments
- * ---- ---------- -------- -----------------------------------------------------
- * 1 2002-04-02 klerxm Initial version
- * 2 2002-05-27 klerxm Solved problem in SDRAM test
- * 3 2002-07-18 klerxm Enable capturing after engine has jumped
- * 4 2002-07-18 klerxm Updated function descriptions
- * 5 2003-03-25 potm Corrected atomic register access
- * 6 2003-06-25 potm Rewritten for easier hw debugging
- *
- *******************************************************************************/
- /*******************************************************************************
- * Include Files
- *******************************************************************************/
- #include "config.h"
- /* This file is for SACD only.*/
- #if D_SUPPORT_SACD
- #include <embedded.h>
- #include "includesysdefs.h"
- #include "kernelker_api.h"
- #include "Playcoresampsamp_apm.h"
- #include "Playcoresampsamp_gen.h"
- #include "Playcorenav_sacdglue_test.h"
- #include "Playcorenav_sacdglue_be.h"
- #include "decoderlow_leveldec_ll_reg.h"
- #define UInt16 UINT16
- #define UInt32 UINT32
- #define SACD_Read16(adr) (*((UINT16*)(MK_FP(0x1000,adr))))
- #define SACD_Write16(adr,val) (*((UINT16*)(MK_FP(0x1000,adr))) = (val))
- #ifdef tr_printf
- #undef tr_printf
- #define tr_printf(msg) (printf ## msg)
- #endif
- #ifdef SACD_HW_EVAL
- extern UINT8 secondtest;
- #endif
- /*******************************************************************************
- * Macro Definitions
- *******************************************************************************/
- /*******************************************************************************
- * The following defines can be used to set the type of Basic Engine Interface
- * connected to the Furore2. A complete engine interface type consists of a
- * logical OR of each of the bitfields described below. (Note: For IIS types
- * bits 3 to 9 don't care)
- *
- * 2-0 Engine interface type
- * ------xx xxxxx000 Normal IIS mode
- * ------xx xxxxx001 Stopped clock IIS mode
- * -------- -----010 FEC interface
- * -------- -----100 UDE synchronous mode
- * -------- -----101 UDE asynchronous mode handshake to stop data
- * -------- -----111 UDE asynchronous mode handshake per byte
- *
- * 5-3 Input sync selection (not applicable for IIS modes)
- * -------- --000--- If sync is '0' then active sync
- * -------- --001--- If sync is '1' then active sync
- * -------- --010--- Edge from '0' to '1' indicates first byte of a sector
- * -------- --011--- Edge from '1' to '0' indicates first byte of a sector
- * -------- --100--- No sync at input. Furore2 will generate her own sync signal
- * every 2064 bytes
- * 6 Input data request (not applicable for IIS modes)
- * -------- -1------ If REQ output is '1' then Furore2 requests new input data
- * -------- -0------ If REQ output is '0' then Furore2 requests new input data
- *
- * 7 Data send (not applicable for IIS modes)
- * -------- 1------- If SENB input is '1' then engine will send new data
- * -------- 0------- If SENB input is '0' then engine will send new data
- *
- * 8 Error indication (not applicable for IIS modes)
- * -------1 -------- If SERR input is '1' then error of that sector
- * -------0 -------- If SERR input is '0' then error of that sector
- *
- * 9 External input (not applicable for IIS modes)
- * ------1- -------- The host is master on the UDE bus. The external 'REQ' signal
- * from the Host interface is fed to the REQ output signal from
- * Furore2.
- * ------0- -------- Furore2 is master on the UDE bus and can request new data.
- *
- * 10-15 Not used (Don't care)
- * xxxxxx-- --------
- *
- *******************************************************************************/
- #define BE_IF_TYP_IIS_NORMAL 0x0000
- #define BE_IF_TYP_IIS_STOPPED_CLK 0x0001
- #define BE_IF_TYP_FEC 0x0002
- #define BE_IF_TYP_UDE_SYNCHR 0x0004
- #define BE_IF_TYP_UDE_ASYNC_HS2DATA 0x0005
- #define BE_IF_TYP_UDE_ASYNC_HS2BYTE 0x0007
- #define BE_IF_SYNC_0 0x0000
- #define BE_IF_SYNC_1 0x0008
- #define BE_IF_SYNC_POS_EDGE 0x0010
- #define BE_IF_SYNC_NEG_EDGE 0x0018
- #define BE_IF_SYNC_NO_SYNC 0x0020
- #define BE_IF_REQ_0 0x0000
- #define BE_IF_REQ_1 0x0040
- #define BE_IF_SENB_0 0x0000
- #define BE_IF_SENB_1 0x0080
- #define BE_IF_ERR_0 0x0000
- #define BE_IF_ERR_1 0x0100
- #define BE_IF_EXT_FUR2 0x0000
- #define BE_IF_EXT_HOST 0x0200
- /* Set the next define to one or more of the defines above */
- #define BE_IF_TYPE BE_IF_TYP_IIS_NORMAL
- #define SE_INT_FSD 0x0001
- #define SE_INT_SPL 0x0002
- #define SE_INT_ESD 0x0004
- #define SE_INT_TSD 0x0008
- #define SE_INT_LSD 0x0010
- #define SE_INT_FSC 0x0020
- #define SE_INT_LSC 0x0040
- #define SE_INT_EDC 0x0080
- #define SE_INT_SNC 0x0100
- #define SE_INT_FUL 0x0200
- #define SE_INT_NBH 0x0400
- #define SE_INT_DIS 0x0800
- #define ERROR_HOST_ID 0x00000001
- #define ERROR_PI_BUS 0x00000002
- #define ERROR_SDRAM 0x00000004
- #define ERROR_BUFFER 0x00000008
- #define BUFFERSIZE (132*2048ul)
- /*******************************************************************************
- * The following defines can be used to set the Audio Input Clock Frequency
- * to either 256Fs or 384Fs
- *******************************************************************************/
- #define DCL_256FS 0x0100
- #define DCL_384FS 0x0000
- /* Set the next define to one of the defines above */
- #define DCL_AUDIO_IN DCL_384FS
- #define FURORE_BASE 0x500000ul //0x50000000ul
- /*******************************************************************************
- * Type definitions
- *******************************************************************************/
- typedef enum {
- SE_IDLE,
- SE_SEARCHING,
- SE_FIRSTSYNC,
- SE_INLOCK,
- SE_FIRSTCAPTURED,
- SE_LASTCAPTURED
- } SeStates;
- /*******************************************************************************
- * Function prototypes
- *******************************************************************************/
- /*******************************************************************************
- * Local functions
- *******************************************************************************/
- unsigned long captureSectorAtNum = 510ul;
- int NumToCapture = 9;
- //#error Please implement the delay function to provide a delay of about n second
- void delay(int n)
- {
- usleep(1000000ul);
- }
- /*******************************************************************************
- * Data Definitions
- *******************************************************************************/
- /* Current status of the capturing process */
- static int seState;
- static unsigned short seErrors;
- static unsigned long bufferStart;
- #ifdef SACD_HW_EVAL
- /* SACD Master TOC of the Philips 'No SACD Mark' test disc */
- const unsigned char Mtoc[] = {
- #include "playcorenav_SACDsacd_mtoc.hex"
- };
- #endif
- /*******************************************************************************
- * Exported functions
- *******************************************************************************/
- /*******************************************************************************
- * Name : Furore2Write
- * Purpose : Write one hword to Furore2 memory/registers.
- * Input : addr Address to write to
- * val Hword to write
- * Output : -
- * Returns : -
- * Remarks : SAD16-03
- *******************************************************************************/
- void Furore2Write( unsigned long addr, unsigned short val )
- {
- SAMP(UInt16) furBase;
- /* Save base-address (16 MSB address-bits) */
- furBase = (SAMP(UInt16))((addr>>7)&0xFFFF);
- #if 1 //zoran
- SACD_Write16(0x80, furBase);
- SACD_Write16(addr&0x7E, val);
- #else
- /* Activate H_A_sel and put base-address on data bus */
- *(volatile SAMP(UInt16)*)(FURORE_BASE|0x80) = furBase;
- /* Negate H_A_sel and write data */
- *(volatile SAMP(UInt16)*)(FURORE_BASE+(addr&0x7E)) = val;
- #endif
- /* Wait at least Twait (30 sys_clk cycles) */
- //#error insert required delay here
- #if 1 //ZORAN
- {
- int i;
- for(i = 0; i < 8; i++);
- }
- //usleep(0UL); //1 us, sys_clk = 27~35MHZ
- #endif
- }
- /*******************************************************************************
- * Name : Furore2Read
- * Purpose : Read one hword from Furore2 memory/registers.
- * Input : addr Address to read from
- * Output : -
- * Returns : Hword to read
- * Remarks : SAD16-03
- *******************************************************************************/
- unsigned short Furore2Read( unsigned long Addr )
- {
- unsigned short dummy;
- /* Activate H_A_sel and put base-address on data bus */
- // *(volatile unsigned short*)(FURORE_BASE | 0x80) = (unsigned short)((Addr>>7)&0xFFFF);
- #if 1 //zoran
- SACD_Write16(0x80, (unsigned short)((Addr>>7)&0xFFFF));
- #endif
- /* Read once */
- // dummy = *(volatile unsigned short*)(FURORE_BASE + (Addr&0x7E));
- dummy = SACD_Read16(Addr&0x7E);
- /* Wait at least Twait (30 sys_clk cycles) */
- //#error insert required delay here
- #if 1 //ZORAN
- {
- int i;
- for(i = 0; i < 8; i++);
- }
- //usleep(0UL); //1 us, sys_clk = 27~35MHZ
- #endif
- /* Read twice and return result */
- // dummy = *(volatile unsigned short*)(FURORE_BASE | 0x80);
- dummy = SACD_Read16(0x80);
- return dummy;
- }
- #define FURORE_SEL_PCM 0x7FE18Aul
- #define EXTERNAL_PCM_INPUT 1
- #define INTERNAL_PCM_INPUT 0 //PCM is internally generated by decimation filter.
- #define FURORE_SEL_DSD_PCM0 0x7fe192ul
- #define FURORE_SEL_DSD_PCM1 0x7fe194ul
- #define FURORE_SEL_DSD_PCM2 0x7fe196ul
- void FuroreSetInternalInputPCMMode(void)
- {
- Furore2Write(FURORE_SEL_PCM, INTERNAL_PCM_INPUT);
- }
- /*
- Desc: For medias other than SACD, set external PCM input mode.
- */
- void FuroreSetExternalInputPCMMode(void)
- {
- DAC_SACD_SetMute(TRUE);
- SACD_XMIT2_TIMING();
- #if 0 //todo: check later.
- /* Prepare the Furore for capturing */
- Furore2Write(0x7F9608, (0)); /* VBR_BOT */
- Furore2Write(0x7F960A, ((BUFFERSIZE) >> 8)); /* VBR_TOP */
- Furore2Write(0x7F860E, 0x0000); /* VBR_WRIL */
- Furore2Write(0x7F860C, 0); /* VBR_WRIH */
- Furore2Write(0x7F8612, 0x0000); /* VBR_REAL */
- Furore2Write(0x7F8610, 0); /* VBR_REAH */
- Furore2Write(0x7F9200, 0x0001); /* SE_RST */
- Furore2Write(0x7F9236, BE_IF_TYPE ); /* SE_BE_IF */
- Furore2Write(0x7F920C, 0x0000); /* SE_EMR */
- Furore2Write(0x7F9204, 0x0BFF); /* SE_IER */
- #if 0
- Furore2Write(0x7F8216, (unsigned short)Begin); /* SE_CAPL */
- Furore2Write(0x7F8214, (unsigned short)(Begin>>16)+3); /* SE_CAPH */
- Furore2Write(0x7F821A, (unsigned short)End); /* SE_LSTL */
- Furore2Write(0x7F8218, (unsigned short)(End>>16)+3); /* SE_LSTH */
- #endif
- Furore2Write(0x7FE108, DCL_AUDIO_IN ); /* LLD_DCL */
- Furore2Write(0x7FE10C, 0x0100); /* FAD_MOD */
- Furore2Write(0x7FE1B2, 0xCC00); /* FAD_IN_SEL */
- Furore2Write(0x7FE18C, 0x0000); /* SEL_DSD_DEB */
- Furore2Write(0x7FE192, 0x9999); /* SW_MAT0 */
- Furore2Write(0x7FE194, 0x7B99); /* SW_MAT1 */
- Furore2Write(0x7FE196, 0xFE7B); /* SW_MAT2 */
- Furore2Write(0x7FE700, 0x0000); /* DEL_ENA */
- /* Clear interrupts */
- Furore2Read(0x7F9206); /* SE_ISR */
- #endif
- Furore2Write(0x7FE18Cul, 0x0000); /* SEL_DSD_DEB */
- Furore2Write(FURORE_SEL_PCM, EXTERNAL_PCM_INPUT);
- Furore2Write(FURORE_SEL_DSD_PCM0, PCM_LE_RI | (PCM_CE_LF << 8));
- Furore2Write(FURORE_SEL_DSD_PCM1, PCM_LS_RS | (PCM_DCLK << 8) | (PCM_WCLK << 12));
- DAC_SACD_SetMute(FALSE);
- }
- //The following functions are for testing hardware environment only.
- #ifdef SACD_HW_EVAL
- /*******************************************************************************
- * Name : Furore2Init
- * Purpose : Initialises Furore2 chip and programs all registers necessary
- * to capture the requested number of sectors. Also programs
- * postprocessing to output mutes on all channels.
- * Input : Begin Physical sector number where to start capturing.
- * End Physical sector number where to stop capturing.
- * Output : -
- * Returns : Result of initialisation is a bitmask consisting of:
- * ERROR_HOST_ID 0x00000001
- * ERROR_PI_BUS 0x00000002
- * ERROR_SDRAM 0x00000004
- * ERROR_BUFFER 0x00000008
- * Remarks : -
- *******************************************************************************/
- int Furore2Init( unsigned long Begin, unsigned long End )
- {
- int Error = 0;
- unsigned long i;
- unsigned short d,HostId;
- unsigned long errorAddress = 0xFFFFFFFFul;
- int validBuffer = 0;
- static int secondaryTestDoneOnce = 0;
- tr_printf(("Initialising Furore... "));
- /* Reset host interface */
- Furore2Write(0x7FE000ul, 0x0707);
- /* Set wait to 6 */
- Furore2Write(0x7FED00ul, 0x0c0c);
- /* Check for Furore 2 cut 2 ID */
- HostId = Furore2Read(0x7FED02ul);
- if( HostId==0xC2F2 )
- {
- /* Swap reads/writes */
- Furore2Write(0x7FE008ul, 0x0606);
- }
- else if( HostId!=0xF2C2 )
- {
- Error |= ERROR_HOST_ID;
- }
- /* Check host ID */
- if( Furore2Read(0x7FE006ul) != 0x5510 )
- {
- Error |= ERROR_HOST_ID;
- }
- #if 0
- /* Perform PI bus test */
- for( i=0; i<130 && !(Error & ERROR_PI_BUS); i++ )
- {
- Furore2Write(0x7F9204ul, 1<<(i%13));
- if ( (Furore2Read(0x7F9204ul)&0x1FFF) != (1<<(i%13)) ) Error |= ERROR_PI_BUS;
- }
- /* Perform SDRAM test */
- for ( i=0,d=0; i<0x7F8000ul; i+=16 )
- {
- Furore2Write(i, d);
- if (d==0xFFFF ) d=0; else d++;
- }
- bufferStart = 0;
- for ( i=0,d=0; i<0x7F8000ul; i+=16 )
- {
- if ( Furore2Read(i) != d)
- {
- if(!(Error & ERROR_SDRAM))
- {
- errorAddress = i;
- Error |= ERROR_SDRAM;
- }
- if(!validBuffer)
- {
- if((i - bufferStart) >= BUFFERSIZE)
- {
- validBuffer = 1;
- }
- else
- {
- bufferStart = i + 16;
- }
- }
- }
- if ( d==0xFFFF ) d=0; else d++;
- }
- if((i - bufferStart) >= BUFFERSIZE)
- {
- validBuffer = 1;
- }
- if(!validBuffer)
- {
- Error |= ERROR_BUFFER;
- }
- if(Error & ERROR_SDRAM)
- {
- tr_printf(("FAILEDnSDRAM test failed, "));
- if(Error & ERROR_BUFFER)
- {
- tr_printf(("unable to allocate buffer in SDRAMn"));
- }
- else
- {
- tr_printf(("buffer allocated in SDRAMn"));
- }
- }
- if(!secondaryTestDoneOnce)
- {
- if(!(Error & ERROR_SDRAM))
- {
- for ( i=0; i<0x7F8000ul; i+=2 )
- {
- Furore2Write(i, 0xFFFF);
- }
- for(i = bufferStart; i < bufferStart + BUFFERSIZE; i++)
- {
- if(Furore2Read(i) != 0xFFFF)
- {
- tr_printf(("FAILEDnSecondary SDRAM test failed for selected buffer space at 0x%08lXn", i));
- Error |= ERROR_SDRAM;
- Error |= ERROR_BUFFER;
- break;
- }
- }
- secondaryTestDoneOnce = 1;
- }
- if(!(Error & ERROR_SDRAM))
- {
- for(i = 0; i < 0x7F8000ul; i+=2 )
- {
- if(Furore2Read(i) != 0xFFFF)
- {
- tr_printf(("FAILEDnSecondary SDRAM test failed at 0x%08lXn", i));
- Error |= ERROR_SDRAM;
- break;
- }
- }
- }
- }
- #else
- validBuffer = 1;
- #endif
- /* Prepare the Furore for capturing */
- Furore2Write(0x7F9608ul, (bufferStart >> 8)); /* VBR_BOT */
- Furore2Write(0x7F960Aul, ((bufferStart + BUFFERSIZE) >> 8)); /* VBR_TOP */
- Furore2Write(0x7F860Eul, 0x0000); /* VBR_WRIL */
- Furore2Write(0x7F860Cul, (bufferStart >> 16)); /* VBR_WRIH */
- Furore2Write(0x7F8612ul, 0x0000); /* VBR_REAL */
- Furore2Write(0x7F8610ul, (bufferStart >> 16)); /* VBR_REAH */
- Furore2Write(0x7F9200ul, 0x0001); /* SE_RST */
- Furore2Write(0x7F9236ul, BE_IF_TYPE ); /* SE_BE_IF */
- Furore2Write(0x7F920Cul, 0x0000); /* SE_EMR */
- Furore2Write(0x7F9204ul, 0x0BFF); /* SE_IER */
- Furore2Write(0x7F8216ul, (unsigned short)Begin); /* SE_CAPL */
- Furore2Write(0x7F8214ul, (unsigned short)(Begin>>16)+3); /* SE_CAPH */
- Furore2Write(0x7F8218ul, (unsigned short)(End>>16)+3); /* SE_LSTH */
- Furore2Write(0x7F821Aul, (unsigned short)End); /* SE_LSTL */
- Furore2Write(0x7FE108ul, DCL_AUDIO_IN ); /* LLD_DCL */
- Furore2Write(0x7FE10Cul, 0x0100); /* FAD_MOD */
- Furore2Write(0x7FE1B2ul, 0xCC00); /* FAD_IN_SEL */
- Furore2Write(0x7FE18Cul, 0x0000); /* SEL_DSD_DEB */
- Furore2Write(0x7FE192ul, 0x9999); /* SW_MAT0 */
- Furore2Write(0x7FE194ul, 0x7B99); /* SW_MAT1 */
- Furore2Write(0x7FE196ul, 0xFE7B); /* SW_MAT2 */
- Furore2Write(0x7FE700ul, 0x0000); /* DEL_ENA */
- /* Clear interrupts */
- Furore2Read(0x7F9206ul); /* SE_ISR */
- seState = SE_IDLE;
- seErrors = 0;
- if (!Error)
- {
- tr_printf(("OK.n"));
- }
- else
- {
- tr_printf(("error code %un", Error));
- if(Error & ERROR_SDRAM)
- {
- tr_printf(("Example of not working SDRAM address: 0x%08lXn", errorAddress));
- }
- }
- return Error;
- }
- /*******************************************************************************
- * Name : Furore2EnableCapturing
- * Purpose : Programs the Furore2 sectorprocessor to start capturing.
- * Input : -
- * Output : -
- * Returns : -
- * Remarks : -
- *******************************************************************************/
- void Furore2EnableCapturing()
- {
- Furore2Write(0x7F920A, 0x0001); /* SE_ENA */
- seState = SE_SEARCHING;
- /* If no timed syncs are detected, it is considered an error.
- The flag will be cleared if and when timed syncs are detected */
- seErrors |= SE_INT_TSD;
- }
- /*******************************************************************************
- * Name : Furore2GetStatus
- * Purpose : Returns the current state of the capturing process along with
- * possible errors that have a occurred so far.
- * When capturing is started, the furore will go through the states
- * until either a blocking error occurs or the capturing is finished.
- * Input : -
- * Output : *pErrors An unsigned short (bit pattern) indicating
- * which errors occurred since last Furore2
- * initialisation
- * 0x0004 SE_INT_ESD early syncs detected
- * 0x0008 SE_INT_TSD NO timed syncs were detected!!
- * 0x0010 SE_INT_LSD late syncs detected
- * 0x0080 SE_INT_EDC erroneous sector
- * 0x0100 SE_INT_SNC sector number continuity error
- * 0x0200 SE_INT_FUL buffer full
- * 0x0800 SE_INT_DIS sector processor disabled
- *
- * *pISR The value of the interrupt status register
- * at the moment this function was called
- *
- * Returns : 0 SE_IDLE Capturing hasn't been started yet
- * 1 SE_SEARCHING Capturing was started, but no sync was
- * detected
- * 2 SE_FIRSTSYNC First sync was detected, but the sector
- * processor isn't in lock yet
- * 3 SE_INLOCK The sector processor is in lock, but the
- * first sector wasn't captured yet
- * 4 SE_FIRSTCAPTURED First sector was captured, last sector wasn't
- * 5 SE_LASTCAPTURED Last sector was captured, capturing complete
- *
- *
- * Remarks : -
- *******************************************************************************/
- unsigned short Furore2GetStatus(unsigned short *pErrors, unsigned short *pISR)
- {
- unsigned short isr = Furore2Read(0x7F9206);
- *pISR = isr;
- if( (seState == SE_SEARCHING) &&
- (isr & SE_INT_FSD) )
- {
- isr &= ~SE_INT_FSD;
- seState = SE_FIRSTSYNC;
- }
- if( (seState == SE_FIRSTSYNC) &&
- (isr & SE_INT_SPL) )
- {
- isr &= ~SE_INT_SPL;
- seState = SE_INLOCK;
- }
- if( (seState == SE_INLOCK) &&
- (isr & SE_INT_FSC) )
- {
- isr &= ~SE_INT_FSC;
- seState = SE_FIRSTCAPTURED;
- }
- if( (seState == SE_FIRSTCAPTURED) &&
- (isr & SE_INT_LSC) )
- {
- isr &= ~SE_INT_LSC;
- seState = SE_LASTCAPTURED;
- }
- seErrors |= isr & (SE_INT_DIS|SE_INT_ESD|SE_INT_LSD|SE_INT_EDC|SE_INT_SNC|SE_INT_FUL);
- /* Clear the TSD flag if there have been timed syncs */
- seErrors &= ~(isr & SE_INT_TSD);
- if(pErrors)
- {
- *pErrors = seErrors;
- }
- return seState;
- }
- void SACD_Isr(void)
- {
- int Error;
- int i, j;
- /*unsigned short isr = 0, oldisr = 0, enabled = 1;*/
- unsigned short curh, curl;
- unsigned short errorBits, f2status, temp;
- unsigned short enabled, isr;
- enabled = Furore2Read(0x7F920A);
- f2status = Furore2GetStatus(&errorBits, &isr);
- if(1) //todo: was errorBits)
- {
- #if 0 //todo enable later.
- tr_printf((" EN:0x%04X E:0x%04X isr:", enabled, errorBits));
- temp = isr;
- for(j = 0; j < 16; j++)
- {
- tr_printf(("%s", (temp & 0x8000) ? "1" : "0"));
- temp <<= 1;
- }
- #endif
- curh = Furore2Read(0x7F921C);
- curl = Furore2Read(0x7F921E);
- #if 1 //remove later.
- tr_printf(("%04Xn", curl));
- #else
- tr_printf((" SN:0x%04X%04Xn", curh, curl));
- #endif
- }
- }
- #ifdef SACD_HW_EVAL
- /*******************************************************************************
- * Name : Furore2Verify
- * Purpose : Compares the data that was read against the contents of
- * the SACD Master TOC of the Philips 'No SACD Mark' test disc.
- * Input : -
- * Output : -
- * Returns : 0 Verification successful.
- * >0 Number of mismatching bytes.
- * -1 Signature of TOC is invalid (no bytes matched).
- * Remarks : To use this function, sectors 510-519 of the disc should have
- * been read in the buffer using the functions Furore2Init() and
- * Furore2GetStatus().
- *******************************************************************************/
- int Furore2Verify()
- {
- unsigned long i;
- int Swap=0, Count=0;
- unsigned short Signature=Furore2Read(bufferStart);
- if( Signature==0x5341 ) Swap=0;
- else if( Signature==0x4153 ) Swap=1;
- else Count=-1;
- if( Count==0 )
- {
- for(i=0;i<sizeof(Mtoc)&&i<BUFFERSIZE;i+=2)
- {
- if( Furore2Read(bufferStart+i)!=((Mtoc[Swap?i+1:i]<<8)|Mtoc[Swap?i:i+1]) ) Count+=2;
- }
- }
- return Count;
- }
- /*******************************************************************************
- * The following function is an example of how the test routines above
- * can be used. The following actions will be performed:
- * 1. Furore2 will be initialised and sector processor will be programmed to
- * capture the SACD Master TOC of the disc (logical sectors 510 to 519).
- * 2. The Furore2 sectorprocessor will be started after the engine has jumped to
- * the wanted position.
- * 3. In a loop the status of the capturing process will be retrieved until
- * capturing stops.
- * 4. The captured data is verified against the SACD Master TOC of the Philips
- * 'No SACD Mark' test disc.
- *******************************************************************************/
- int CaptureMasterToc(void)
- {
- int Error;
- int i, j;
- /*unsigned short isr = 0, oldisr = 0, enabled = 1;*/
- unsigned short curh, curl;
- unsigned short errorBits, f2status, temp;
- unsigned short enabled, isr;
- // PE_SACD_AbortPlayback(1);
- Error = SAMP(BE_ReadToc)();
- if (Error) tr_printf(("ReadToc failedn")); else tr_printf(("ReadToc okn"));
- /* Initialise Furore2 and program sector processor to capture the SACD Master TOC */
- if (Error == 0)
- {
- Error = Furore2Init( captureSectorAtNum, captureSectorAtNum + NumToCapture);
- if (Error)
- {
- if(!(Error & (ERROR_HOST_ID|ERROR_PI_BUS|ERROR_BUFFER)))
- {
- tr_printf(("Only SDRAM test failed. Continuing with buffer in working part of SDRAM.n"));
- }
- else
- {
- return Error;
- }
- }
- }
- /* Seek to the wanted postition and enable capturing */
- Error = SAMP(BE_Seek)( captureSectorAtNum - 4 + 0x30000ul); //sacd todo: was - 510
- if (Error == 0)
- {
- Furore2EnableCapturing();
- }
- if (Error)
- {
- tr_printf(("Seek failedn"));
- return Error;
- }
- else
- {
- tr_printf(("Seek okn"));
- }
- i = 0;
- do
- {
- /* Wait for about a second */
- delay(1);
- enabled = Furore2Read(0x7F920A);
- f2status = Furore2GetStatus(&errorBits, &isr);
- tr_printf((" SE_ENA:0x%04X errorBits:0x%04X isr:", enabled, errorBits));
- temp = isr;
- for(j = 0; j < 16; j++)
- {
- tr_printf(("%s", (temp & 0x8000) ? "1" : "0"));
- temp <<= 1;
- }
- curh = Furore2Read(0x7F921C);
- curl = Furore2Read(0x7F921E);
- tr_printf((" SE_CUR:0x%04X%04Xn", curh, curl));
- i++;
- }
- while(enabled && (i < 20));
- // PE_SACD_AbortPlayback(1);
- if(f2status == SE_LASTCAPTURED)
- {
- tr_printf(("Capturing ok. (errorBits = 0x%04X)n", errorBits));
- /* Verify captured data */
- Error = Furore2Verify();
- if (Error) tr_printf(("Verification failed at byte %dn", Error)); else tr_printf(("Verification okn"));
- }
- else
- {
- tr_printf(("Capturing failed.nStatus was "));
- switch(f2status)
- {
- case SE_IDLE:
- tr_printf(("IDLE"));
- break;
- case SE_SEARCHING:
- tr_printf(("SEARCHING"));
- break;
- case SE_FIRSTSYNC:
- tr_printf(("FIRSTSYNC"));
- break;
- case SE_INLOCK:
- tr_printf(("INLOCK"));
- break;
- case SE_FIRSTCAPTURED:
- tr_printf(("FIRSTCAPTURED"));
- break;
- case SE_LASTCAPTURED:
- tr_printf(("LASTCAPTURED"));
- break;
- default:
- tr_printf(("UNKNOWN"));
- break;
- }
- tr_printf((" at the end of the loop (errorbits = 0x%04X)n", errorBits));
- }
- return Error;
- }
- void ShowCurrentSector()
- {
- unsigned short curh, curl;
- curh = Furore2Read(0x7F921C);
- curl = Furore2Read(0x7F921E);
- tr_printf(("SE_CUR:0x%04X%04Xn", curh, curl));
- }
- void PspKeyDetection()
- {
- int Error, i, j;
- unsigned short isr, oldisr = 0;
- tr_printf(("Starting PSP detection...n"));
- Furore2Write(0x7F9204, 0x1FFF);
- Furore2Write(0x7F920A, 0x1000);
- Furore2Write(0x7F9222, 0x029F);
- Error = SAMP(BE_Seek)( 0x2F000 );
- if(Error)
- {
- tr_printf(("Seek failed.n"));
- }
- else
- {
- tr_printf(("Seek ok.n"));
- for(i = 0; i < 10 && !(oldisr & 0x1000); i++)
- {
- oldisr = isr = Furore2Read(0x7F9206);
- tr_printf((" SE_ISR:0x%04X (", isr));
- for(j = 0; j < 16; j++)
- {
- tr_printf(("%s", (isr & 0x8000) ? "1" : "0"));
- isr <<= 1;
- }
- tr_printf((") pll_lock:%un", (Furore2Read(0x7f9222) >> 10) & 1));
- /* Wait for about 1 second */
- delay(1);
- }
- if(oldisr & 0x1000)
- {
- tr_printf(("PSP key detection successful.n"));
- }
- else
- {
- tr_printf(("PSP key not detected yet.n"));
- Error = SAMP(BE_Seek)( 0x80000 );
- /* Wait for about 3 seconds */
- delay(3);
- if(Error)
- {
- tr_printf(("Uh oh.n"));
- }
- oldisr = isr = Furore2Read(0x7F9206);
- tr_printf((" SE_ISR:0x%04X (", isr));
- for(j = 0; j < 16; j++)
- {
- tr_printf(("%s", (isr & 0x8000) ? "1" : "0"));
- isr <<= 1;
- }
- tr_printf((")n"));
- if(oldisr & 0x1000)
- {
- tr_printf(("Success.n"));
- }
- else
- {
- tr_printf(("Failure.n"));
- }
- }
- }
- }
- #endif
- #endif
- #endif // D_SUPPORT_SACD