📄 srvchn.c
字号:
/************************************************** * * srvchn.c * * CVS ID: $Id: srvchn.c,v 1.50 2007/11/15 15:10:14 belardi Exp $ * Author: Fabio Dell'Orto [FD] - STM * Date: $Date: 2007/11/15 15:10:14 $ * Revision: $Revision: 1.50 $ * * Description: * * *************************************************** * * COPYRIGHT (C) ST Microelectronics 2005 * All Rights Reserved * ******************************************************************************* * \brief Channel management procedures (Acquisition / ECC / Audio) * * \par Change History: * * - BB040130 Current Q subcode is stored in q_cadr..q_aframe * * - BB040315 Added output interface initialisation according to module * configuration settings * * - BB040608h Improved execution of calibration jump calculation * * - PH040728a Changes: * - Changed Order FOCUS_ON->START_TTM to START_TTM->FOCUS_ON * - HF check moved from start_ttm() over focus_on() to te_adjust() * - Declared local functions "static" * - Introduced uint8, int8, int16, uint16, int32, uint32 * - Usage of doxygen headers * - BB040923a Code rom and ram size optimisation: * - subcode variables collected in structures and * compiler need less code to copy them to i2c buffer * - BB040923h Added lastplay_T time to be able correctly restart play * from stop position * - BB040929b Fixed word and serial clock level (low - left channel) * - BB041007f Fixed setting of output interface when i2s_out_ratio == 0 * and spdif_out_ratio != 0 * - BB041014 Fixed external clock * - BB041022b Fixed external clock (user manual error) * - BB041109a Added fade-in, fade-out functionality * - BB041109b Fixed noise during long jump, do not execute audio_init() * if ttm_speed did not changed * - BB041110a Fixed seek to target time * - It was possible that cd_flags.new_T is set but T_actual is * not updated * - PH041110a Disabled CDEX source of CIRC interrupt to avoid reset with MU23AD * - PH050126a Introduced Rejumping to the last recovery position * - YNM050210 Fixed time information report after execution of PAUSE commmands (S-ONE only) * - BB050304 Fixed output interface when configured for 2.1168MHz * (audio_init() made more robust) * - BB050414b Improved EMC performance by turning off sdram clock * - BB050414c Extended get subcode service command * - BB050412b Fixed execution of BEGINMEDIA / ENDMEDIA actions (FAR113) * - BB050506b Fixed recovery on false subcode interrupts (CD with interruption) * - HW050530 Adjust LOCKING_GAINS and UNLOCKED_GAINSin acq_init() * - AH050714a Improved multiple fingerprint playability * - BB050714b Fixed ESP synchronisation with during CLV speed * (CLV buffer not empty) * - BB050719a Fixed access to variables with flags which are written in ISR * - BB050719c Fixed mute when having pause event and going to pause * - BB050809b Fixed muting when shockproof controller is off * - BB050810g Fixed play_until_end_track when play requested close to the end * of track (less then 19 frames) * - BB050810k Fixed sevo pause event generating and handling * - BB050815d Added fade in/out support * - BB050815g Added difference between UNWRITTEN_DISC error if hf problem * or erased cdrw () * - BB050815h Fixed speed setting from temporary CLV to CAV * - BB050921b Seek will not end with error if able to access time bigger * than requested - fixed some copy protected CDs * - BB050921d Improved search without ESP (added seek with relative play time) * - BB050921d Fixed search with very short relative endplay time * - BB051017a Fixed muting when fade in/out is used (mute modes different * than mute data zero) * - HW051101 Improved pll locking with "Delphi CDR" * - BB051103a Fixed search with play until end track and repeat track * - BB060822a Removed endplay handling from interrupt and moved to * active check servo state * *************************************************** * * STM CVS Log: * * $Log: srvchn.c,v $ * Revision 1.50 2007/11/15 15:10:14 belardi * Removed compiler warning * * Revision 1.49 2007/11/15 14:41:08 marcucci * Fix for USB Stop (see FIX_4_USB_STOP) * * Revision 1.48 2007/10/12 13:20:34 marcucci * Added the possibility to set I2S in Philips or Sony LSImode * * Revision 1.47 2007/09/26 15:12:39 dellorto * modified handling of the pause position * * Revision 1.46 2007/09/26 12:01:26 marcucci * Fix for pause at end of the disc. * * Revision 1.45 2007/08/14 15:30:14 dellorto * multiple mechanisms * * Revision 1.44 2007/08/09 09:02:12 marcucci * jitter_val() function addedd * * Revision 1.43 2007/04/11 14:21:04 belardi * Integration of HAVE_CD_MECHA modification by [GP] * * Revision 1.42 2007/03/22 08:10:30 marcucci * Modified mute_on() and mute_of() for new way to enable/disable interrupt * * Revision 1.41 2007/02/22 16:50:09 marcucci * Modified oif_init to allow I2S Word Clock and Bit Clock Level Programmable * Through CIS command * * Revision 1.40 2006/11/27 19:54:53 belardi * Added parameter to bd_dma_init() call in oif_init() * * Revision 1.39 2006/11/20 13:59:49 marcucci * new oif_init() procedure for Audio Config Command. * Added SPDIF Mute * * Revision 1.38 2006/11/08 16:49:27 marcucci * Correct mute in oif_init * * Revision 1.37 2006/11/08 08:51:45 marcucci * Mute on I2S working * * Revision 1.36 2006/10/31 11:10:19 marcucci * No more static functions for Jump Table * * Revision 1.35 2006/09/18 09:55:25 belardi * Corrected CVS keyword usage * * Revision 1.34 2006/09/18 09:25:37 belardi * Added Log CVS keyword into file header * * ******************************************************************************/#include "gendef.h"#include "hwreg.h"#include "hwinit.h"#include "osal.h"#include "srvinc.h"#include "isrchdl.h"uint16 jitter_percentage_val;uint16 hf_level;OIF_MODE_STRUCT oif_mode;OIF_MUTE_STRUCT oif_mute_control;tTimeEvent_type acq_subcode_event_type;#ifdef APM_PICKUP #include "service.h"#else #include "plr_conf.h"#endif #include "bkdhdl.h"extern volatile uint8 src_restart_done;#if (HAVE_CD_MECHA == 1)#ifdef APM_PICKUPuint8 oif_ttm_speed;uint8 oif_requested_speed;void CIRC_Int_irq(void);void initialize_audio(void);void oif_isr_irq(void);/*-------------------------- Local declarations ------------------------------*/static const uint8 i2s_swapping_mode[3][2][2] ={ {{I2S_SWAP_16LL,I2S_SWAP_16LM},{I2S_SWAP_16RL,I2S_SWAP_16RM}}, {{I2S_SWAP_24LL,I2S_SWAP_24LM},{I2S_SWAP_24RL,I2S_SWAP_24RM}}, {{I2S_SWAP_32LL,I2S_SWAP_32LM},{I2S_SWAP_32RL,I2S_SWAP_32RM}}};#define OIF_I2S_SWAPPING_MODE(fl) i2s_swapping_mode[fl][OIF_I2S_RIGHT_ALLIG][OIF_I2S_MSB_FIRST]static const uint8 spdif_out_ratio[17][4] ={ { 0, 0, 0, 0}, { 0, 0, 0, 0}, { 1, 0, 0, 0}, { 0, 0, 0, 0}, { 2, 1, 0, 0}, { 3, 0, 0, 0}, { 4, 2, 1, 0}, { 0, 0, 0, 0}, { 5, 0, 0, 0}, { 6, 3, 0, 1}, { 7, 0, 0, 0}, { 0, 0, 0, 0}, { 8, 4, 2, 0}, { 9, 0, 0, 0}, {10, 5, 0, 0}, { 0, 0, 0, 0}, {12, 6, 3, 2}};static const uint8 i2s_out_ratio[17][4][3] ={ {{ 1, 0, 0}, { 0, 0, 0}, { 0, 0, 0}, { 0, 0, 0}}, {{ 0, 1, 0}, { 0, 0, 0}, { 0, 0, 0}, { 0, 0, 0}}, {{ 2, 0, 1}, { 1, 0, 0}, { 0, 0, 0}, { 0, 0, 0}}, {{ 3, 2, 0}, { 0, 1, 0}, { 0, 0, 0}, { 0, 0, 0}}, {{ 4, 0, 2}, { 2, 0, 1}, { 1, 0, 0}, { 0, 0, 0}}, {{ 6, 4, 3}, { 3, 2, 0}, { 0, 1, 0}, { 1, 0, 0}}, {{ 8, 0, 4}, { 4, 0, 2}, { 2, 0, 1}, { 0, 0, 0}}, {{ 9, 6, 0}, { 0, 3, 0}, { 0, 0, 0}, { 0, 1, 0}}, {{10, 0, 5}, { 5, 0, 0}, { 0, 0, 0}, { 0, 0, 0}}, {{12, 8, 6}, { 6, 4, 3}, { 3, 2, 0}, { 2, 0, 1}}, {{14, 0, 7}, { 7, 0, 0}, { 0, 0, 0}, { 0, 0, 0}}, {{15, 10, 0}, { 0, 5, 0}, { 0, 0, 0}, { 0, 0, 0}}, {{16, 0, 8}, { 8, 0, 4}, { 4, 0, 2}, { 0, 0, 0}}, {{18, 12, 9}, { 9, 6, 0}, { 0, 3, 0}, { 3, 2, 0}}, {{20, 0, 10}, {10, 0, 5}, { 5, 0, 0}, { 0, 0, 0}}, {{21, 14, 0}, { 0, 7, 0}, { 0, 0, 0}, { 0, 0, 0}}, {{24, 16, 12}, {12, 8, 6}, { 6, 4, 3}, { 4, 0, 2}}};#endif // APM_PICKUP/*-------------------------- Function implementation -------------------------*//******************************************************************************//* Function: acquisition_init *//* *//*! \brief Initialization of the Acquisition block * \param void * \return void * \remark *//******************************************************************************/void acq_init(void){ ACQ_PLL_CTRL1.all = 0x36; // ACQ_PLL_CTRL1.field.auto_relock = 1; // ACQ_PLL_CTRL1.field.force_media = 1; // ACQ_PLL_CTRL1.field.cd_mode = 0; // ACQ_PLL_CTRL1.field.toc_mode = 1; // ACQ_PLL_CTRL1.field.ill_rl_cor = 1; ACQ_PLL_CTRL2.all = 0x1D; // ACQ_PLL_CTRL2.field.fine_slice_en = 1; // ACQ_PLL_CTRL2.field.force_slice = 0; // ACQ_PLL_CTRL2.field.frz_slice_dfct = 1; // ACQ_PLL_CTRL2.field.frz_boost_dfct = 1; // ACQ_PLL_CTRL2.field.frz_frq_dfct = 1; // ACQ_PLL_CTRL2.field.sel_acq_defect = 0; // ACQ_PLL_CTRL2.field.no_event_dfct = 0; ACQ_LOCKING_GAINS.all = 0x68; // HW050530 // ACQ_LOCKING_GAINS.field.phase = 8; // ACQ_LOCKING_GAINS.field.frequency = 6; ACQ_UNLOCKED_GAINS.all = 0x46; // HW050530 // ACQ_UNLOCKED_GAINS.field.phase = 6; // ACQ_UNLOCKED_GAINS.field.frequency = 4;#ifdef APM_PICKUP ACQ_LOCKED_GAINS.all = 0x46; // HW051101 old value 0x24 // ACQ_LOCKED_GAINS.field.phase = 4; // ACQ_LOCKED_GAINS.field.frequency = 2;#else // ACQ_LOCKED_GAINS.all = 0x57; ACQ_LOCKED_GAINS.all = 0x46;#endif ACQ_SLICER_GAINS.all = 0x66; /* AH050714a old value 54 */ // ACQ_SLICER_GAINS.field.base = 6; /* old value 4 */ // ACQ_SLICER_GAINS.field.slc_viol = 6; /* old value 5 */ ACQ_SLICER_CTRL.all = 0x03; // ACQ_SLICER_CTRL.field.offset = 3; // ACQ_SLICER_CTRL.field.gain_fineslc = 0; ACQ_SLICE_CMD = 0x00;#ifdef APM_PICKUP ACQ_EFM_CTRL1.all = 0x06; // ACQ_EFM_CTRL1.field.efm_win = 6;#else // ACQ_EFM_CTRL1.all = 0x02; ACQ_EFM_CTRL1.all = 0x06;#endif ACQ_EFM_CTRL2.all = 0x00; // ACQ_EFM_CTRL2.field.s0_interp_bypass = 0; // ACQ_EFM_CTRL2.field.stop_byteclk = 0; // ACQ_EFM_CTRL2.field.auto_buffer = 0; ACQ_CHA_CTRL1.all = 0x02; // ACQ_CHA_CTRL1.field.dec_ratio = 2; ACQ_CHA_CTRL2.all = 0x1C; // ACQ_CHA_CTRL2.field.eq_bypass = 0; // ACQ_CHA_CTRL2.field.force_boost = 0; // ACQ_CHA_CTRL2.field.hpf_fc = 3; // ACQ_CHA_CTRL2.field.squelch_en = 1; // ACQ_CHA_CTRL2.field.cor_boost_en = 0; ACQ_BOOST.all = 0x00; // ACQ_BOOST.field.boost_offset = 0; // ACQ_BOOST.field.loop_gain = 0; ACQ_DEFECT_MUX.all = 0x2A; // ACQ_DEFECT_MUX.field.freeze = 2; // ACQ_DEFECT_MUX.field.squelch = 2; // ACQ_DEFECT_MUX.field.dsp = 2; // ACQ_DEFECT_MUX.field.erasure = 0; ACQ_DEFECT_CTRL1.all = 0xE2; // ACQ_DEFECT_CTRL1.field.thres = 2; // ACQ_DEFECT_CTRL1.field.width = 2; // ACQ_DEFECT_CTRL1.field.filter = 3; ACQ_DEFECT_CTRL2 = 0x00; OSAL_isr_install(OSAL_ISR_ACQ, 0x0f, acq_isr_irq); // FTODO ACQ_INT_CTRL.all = 0xB8; /* BB050414c */ // ACQ_INT_CTRL.field.mask_bad_crcs = 0; // Mask Sector Interrupts when SUB-Q CRC check fails // ACQ_INT_CTRL.field.lba_int_en = 1; // Enable Sector Interrupt. // ACQ_INT_CTRL.field.dfct_int_en = 1; // Long defect Interrupt Enable // ACQ_INT_CTRL.field.sec_int_en = 1; // BB040205 Enable Seconds change Interrupt. // ACQ_INT_CTRL.field.nsl_int_en = 1; // Non successive LBAs Interrupt enable}#endif // HAVE_CD_MECHA/******************************************************************************//* Function: ecc_init *//* *//*! \brief Initialization of ECC clock reregisters and BER counters * \param void * \return void * \remark *//******************************************************************************/void ecc_init(void){#if (HAVE_CD_MECHA == 1) clear_ecc_error_cntr();#endif ECC_MODE.all = 0x00; ECC_CTRL.all = 0x4C; ECC_ECR.all = 0x02; ECC_IT_EN.all = 0x05; //PH050112_1#ifdef APM_PICKUP OSAL_isr_install(OSAL_ISR_CIRC, 0x0f, CIRC_Int_irq);#endif}#ifdef APM_PICKUP/******************************************************************************//* Function: audio_init *//* *//*! \brief Initialization of output interface settings * \param void * \return void * \remark Output is set according to the parameters * (a) interface type [analog;spdif;iis] * (b) current disc speed [CLV;CAV;1x;2x;4x] * (c) Mute format [high-z; data 0; line 0] * (d) IIS\EIAJ, frame len [16-32], word len [16-32] and position in frame * (e) External clock provided or not * (f) Mute/ No mute on ROM/Audio track * (g) de-emphasis, interpolation and mute *//******************************************************************************/void audio_init(t_bool config_changed){ /* first check if audio init is already requested */ if (0 == oif_mode.audio_init) { /* check if speed changed or force is requested because configuration is changed */ if ((FALSE != config_changed) || (oif_ttm_speed != oif_requested_speed)) {#ifdef USE_MU23AD oif_ttm_speed = oif_requested_speed; /* be sure that output is muted */ /* BB050304 With output interface configured for 2.1168MHz MUTE_SPDIF_FORCE bit is never set, anyway it is better to check if interface is muted only if it used */ start_timer(MUTE_TIMER, T20ms); OIF_AP_MUTE_CTRL.all = MUTE_I2S_OFF | MUTE_I2S_FORCE | MUTE_SPDIF_OFF | MUTE_SPDIF_FORCE; if (!IS_OIF_MUTED()) { /* if audio not muted turn it off and request for audio init */ oif_mode.audio_init = 1; } else#endif { /* when muted initialised audio */ initialize_audio(); } } } else { /* if speed change requested imidietly after audio init is requested update oif_ttm_speed */ oif_ttm_speed = oif_requested_speed; }}/******************************************************************************//* Function: initialize_audio *//* *//*! \brief * \param void * \return void * \remark *//******************************************************************************/void initialize_audio(void){ uint8 oif_frm_len; uint8 oif_freq; uint8 oif_speed; uint8 oif_mute; /* select OIF clock frequency */#if 0 // BBTODO
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -