buffer.c
来自「ESS3890+SL原代码(1*16内存)」· C语言 代码 · 共 892 行 · 第 1/2 页
C
892 行
wait a little while, then kill the buscon. We then advance the wrptr by the normal amount, even though we didn't complete the dma. (It would be messy if the wrptr ends up in a "not nice" location). ****************************************************************************/void ABV_stop_filling(void){ oh_my(0x12); mvd[xport_flush_output] = 0x1; mvd[xport_flush_output] = 0x0; gbl_gate_control |= flush_xporta; mvd[gate_control] = gbl_gate_control; risc_sleep_a_bit(600); gbl_gate_control &= ~flush_xporta; mvd[gate_control] = gbl_gate_control; buscon_zap(xporta); ABV_filling = 0; ABV_wrptr_advance(ABV_write);}/**************************************************************************** Kill the video xport buscon. ****************************************************************************/void VBV_stop_filling(void){ mvd[xport_flush_output] = 0x2; mvd[xport_flush_output] = 0x0; gbl_gate_control |= flush_xportv; mvd[gate_control] = gbl_gate_control; risc_sleep_a_bit(10000); gbl_gate_control &= ~flush_xportv; mvd[gate_control] = gbl_gate_control; buscon_zap(xportv); VBV_filling = 0; VBV_wrptr_advance(VBV_write);}/**************************************************************************** Kill the xport buscon. ****************************************************************************/void VBV_ABV_stop_filling(void){ mvd[tdmctl0] = 0x400; /* Kill TDM */ mvd[tdmrcvslots0] = 0; mvd[xport_misc] = XPORT_RESET; /* Kill transport */ XPORT_restore_e0_c0(); /* Restore XPORT CAM */ VBV_stop_filling(); ABV_stop_filling();}/**************************************************************************** Kill the hufdec buscon. Then we reset the hufdec gateway fifo. ****************************************************************************/void ABV_stop_draining(void){ buscon_zap(hufdeca); gbl_gate_fiforeset |= 0x80; mvd[gate_fiforeset] = gbl_gate_fiforeset; gbl_gate_fiforeset &= ~0x80; mvd[gate_fiforeset] = gbl_gate_fiforeset; ABV_draining = 0;}void VBV_stop_draining(void){ buscon_zap(hufdecv); gbl_gate_fiforeset |= 0x40; mvd[gate_fiforeset] = gbl_gate_fiforeset; gbl_gate_fiforeset &= ~0x40; mvd[gate_fiforeset] = gbl_gate_fiforeset; VBV_draining = 0;#ifdef VCDLC /* LC code need to reset VP related.. * reset the rest of the train */ hardware_reset(0);#else /* * Instead of calling hardware_reset(0), just reset huffman to * clean state here since hardware_reset(0) does too much * things about VP stuff. */ HUFF_reset_output_fifo_and_state();#endif}/**************************************************************************** Kill the hufdec buscon. Then we reset the hufdec gateway fifo. Then we reset the huffman, the cmdq, the VP and VP buscon. ****************************************************************************/void VBV_ABV_stop_draining(void){ buscon_zap(hufdeca); buscon_zap(hufdecv); gbl_gate_fiforeset |= 0xc0; mvd[gate_fiforeset] = gbl_gate_fiforeset; gbl_gate_fiforeset &= ~0xc0; mvd[gate_fiforeset] = gbl_gate_fiforeset; VBV_draining = 0; ABV_draining = 0;#ifdef VCDLC /* LC code need to reset VP related.. * reset the rest of the train */ hardware_reset(0);#else /* * Instead of calling hardware_reset(0), just reset huffman to * clean state here since hardware_reset(0) does too much * things about VP stuff. */ HUFF_reset_output_fifo_and_state();#endif}void ABV_flush_gateway(){#if (defined WMA_DEC && !(defined WMA_DEMO)) ABV_stop_filling(); ABV_wrptr_save = ABV_wrptr; ABV_start_filling(); if (!ABV_draining) ABV_start_draining();#endif}#if (defined WMA_DEC && !(defined WMA_DEMO))void ABV_flush_cleanup(void){ ABV_stop_draining(); ABV_rdptr = ABV_wrptr_save; ABV_fullness = ABV_wrptr -ABV_rdptr; if (ABV_fullness < 0) ABV_fullness += ABV_size; ABV_start_draining(); if (!ABV_filling) ABV_start_filling();}#endifstatic int VBV_wrptr_save;/**************************************************************************** Kill the video xport buscon, then restart it again. If we don't have video huffdec buscon at this moment, kick it off. ****************************************************************************/void processEndOfStill(void){ VBV_stop_filling(); VBV_wrptr_save = VBV_wrptr; VBV_start_filling(); if (!VBV_draining) VBV_start_draining();}/**************************************************************************** Kill the video huffdec buscon, then restart it again. If we don't have video xport buscon at this moment, kick it off. ****************************************************************************/void doneEndOfStill(void){ buscon_zap(hufdecv); VBV_draining = 0; VBV_rdptr = VBV_wrptr_save; VBV_start_draining(); if (!VBV_filling) VBV_start_filling();}/**************************************************************************** Kill the d2a buscon. Then we reset the d2a gateway fifo. ****************************************************************************/#ifndef ECHOvoid PCM_stop_take_out(void){#ifndef ZERO_BUFFER buscon_zap(d2a); gbl_gate_fiforeset |= gate_d2a_bit; mvd[gate_fiforeset] = gbl_gate_fiforeset; gbl_gate_fiforeset &= ~gate_d2a_bit; mvd[gate_fiforeset] = gbl_gate_fiforeset; PCM_starved = 1;#endif /* * In the ZERO_BUFFER case, we never zap d2a, and starving situation * is detected automatically in PCM_take_out. */}#endif/**************************************************************************** Initialise the PCM and the zero buffer. ****************************************************************************/void PCM_init(){ PCM_clear_buffer(); PCM_clear_zero_buffer(); PCM_rdptr = PCM_start; PCM_raw_wrptr = PCM_start; /* * Initialize ATFS. Otherwise, ATFS will not start! Some audio DAC * has noise. */ LOW_reset_audio_port(); buscon_xfer(d2a, 0, PCM_rdptr, 384, 1);}#ifdef CDG/************************************************************************ XPORTA interrupt service. ************************************************************************/void Is_xporta_isr(){ if (CDG_started) { int mask = mvd[buscon_dma_irqmasks]; if (done_but_needed(xporta)) { xporta_xfer_end(); xporta_xfer(); if (!ABV_filling) buscon_irq_disable(buscon_xporta_runbit); } }}#endif/************************************************************************ Buscon interrupt service. ************************************************************************/void BUSCON_interrupt_service(void){ int mask = mvd[buscon_dma_irqmasks];#ifdef ECHO if (done_but_needed(a2d)) {#ifndef DSC_SW_DETECT_CENTER if (MIC_dma_reject > 0) { MIC_dma_reject--; } else #endif BUF_advance_ptr(MIC_wrptr, ECHO_AF, MIC);#ifdef DSC_SW_DETECT_CENTER if (!MIC_is_turned_on) { /* * We are still in the process of turning on MIC. So we'll * only get (3 * ECHO_AF) of samples */ if (MIC_wrptr >= (MIC_start + (3 * ECHO_AF))) { MIC_filling = 0; MIC_got_sample = 1; } }#endif if (!MIC_filling) { buscon_irq_disable(buscon_a2d_runbit); } else { buscon_xfer(a2d, 0, MIC_wrptr, ECHO_AF, 1); } }#endif if (done_but_needed(d2a)) {#ifdef ECHO MIX_take_out();#else PCM_take_out();#endif } if (done_but_needed(xportv)) { xportv_xfer_end(); xportv_xfer(); if (!VBV_filling) buscon_irq_disable(buscon_xportv_runbit); } if (done_but_needed(xporta)) { xporta_xfer_end(); xporta_xfer(); if (!ABV_filling) buscon_irq_disable(buscon_xporta_runbit); } if (done_but_needed(hufdecv)) { hufdecv_xfer_end(); hufdecv_xfer(); if (!VBV_draining) buscon_irq_disable(buscon_hufdecv_runbit); } if (done_but_needed(hufdeca)) { hufdeca_xfer_end(); hufdeca_xfer(); if (!ABV_draining) buscon_irq_disable(buscon_hufdeca_runbit); }}DEBUGVAR(take_out_level, 0);/**************************************************************************** Just finished a PCM_xfer of 384 stereo samples to the audio DAC. Start a new one if there is data in the PCM buffer. The buffer is empty if PCM_rdptr == PCM_wrptr. ****************************************************************************/#if (!ECHO || ZERO_BUFFER) void PCM_take_out(void){ int amount_of_pcm_data; int PCM_resync; assert(take_out_level==0);#ifdef DEBUG take_out_level++;#endif if (!PCM_starved) { /* Last time we didn't starve. Update read ptr */ PCM_rdptr += 384; if (PCM_rdptr >= PCM_end) { PCM_rdptr = PCM_start; } PCM_resync = 384; } else { if (vcx_karaokey) { #ifdef SPATIAL if (SPA_level) PCM_resync = 0x480; /* karaoke + spatializer */ else#endif PCM_resync = 0x600; /* karaoke only */ } else { PCM_resync = 768; } } PCM_update_occupancy(amount_of_pcm_data); if (amount_of_pcm_data >= PCM_resync) {#ifdef ZERO_BUFFER buscon_xfer(d2a, 0, PCM_rdptr, 384, 1); if (PCM_starved) oh_my(8); oh_my(0xa);#else if (PCM_starved) { oh_my(8); LOW_reset_audio_port();#ifdef ES3207A DSC_reset_audio();#endif } oh_my(0xa); buscon_xfer(d2a, 0, PCM_rdptr, 384, 1); if (PCM_starved) buscon_irq_enable(buscon_d2a_runbit);#endif PCM_starved = 0;#ifdef TRACE_MP3_AUDIOBREAK if (MP3_is_decoding) MP3_is_takeout = 1; else MP3_is_takeout = 0;#endif } else {#ifdef ZERO_BUFFER buscon_xfer(d2a, 0, PCM_zero_start, PCM_zero_size, 1); if (!PCM_starved) {#ifdef OH_MY oh_my(9);#endif if ((AUD_n_frames)&&(!dbg_console)&&(!vcx_playvideo_only)) { KEYDEBUGINC(1, PCM_starvings); DBG_log_error(99, 3, amount_of_pcm_data, VID_decoding_in_progress, 0, 0); } }#else if (!PCM_starved) {#ifdef OH_MY oh_my(9);#endif buscon_irq_disable(buscon_d2a_runbit); if ((AUD_n_frames)&&(!dbg_console)&&(!vcx_playvideo_only)) { KEYDEBUGINC(1, PCM_starvings); DBG_log_error(99, 3, amount_of_pcm_data, VID_decoding_in_progress, 0, 0); } }#endif PCM_starved = 1;#ifdef TRACE_MP3_AUDIOBREAK if (MP3_is_takeout && MP3_system_crash) { mvd[riface_irqmask] = 0; while (1) VCX_service(); }#endif }#ifdef DEBUG take_out_level--;#endif}#endif /* end of ifndef ECHO */#if 0/************************************************************************** Clear the entire PCM buffer. **************************************************************************/void PCM_clear_buffer(void){ int p; VP_ucode(NCMDQ_VP_ucode, clearalldp); VP_ucode_wait(); p = PCM_start; while (p < PCM_end) { VP_xfer(NCMDQ_VP_xfer, VPCMD_R_DP, 0, 0, p, 128, 1); p += 128; } VP_xfer_wait();}/************************************************************************** Clear the zero buffer. **************************************************************************/void PCM_clear_zero_buffer(void){ VP_ucode(NCMDQ_VP_ucode, clearalldp); VP_ucode_wait(); VP_xfer(NCMDQ_VP_xfer, VPCMD_R_DP, 0, 0, PCM_zero_start, PCM_zero_size, 1); VP_xfer_wait();}#endif/************************************************************************ * Load de-emphasis parameters from ROM to DRAM. * ************************************************************************/#ifdef PRE_EMPHASISvoid CDDA_init(void){ int i; unsigned int * pdest = (unsigned int *) dram(EMPH_BP_start); unsigned int * psrc = T_bp_demp; for (i = 0; i < (T_bp_demp_SZ / 4); i++) *pdest++ = *psrc++; pdest = (unsigned int *) dram(EMPH_SAVE_start); for (i = 0; i < EMPH_SAVE_size; i++) *pdest++ = 0;}#endif/************************************************************************ * Set ABV, VBV pointers back to VCD defaults ************************************************************************/void VBV_ABV_default(void){ ABV_start = VCD_ABV_start; ABV_size = VCD_ABV_size; ABV_end = VCD_ABV_end; VBV_start = VCD_VBV_start; VBV_size = VCD_VBV_size; VBV_end = VCD_VBV_end;}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?