📄 srvctr.c
字号:
/**************************************************
*
* srvctr.c
*
* CVS ID: $Id: srvctr.c,v 1.37 2007/09/26 15:13:21 dellorto Exp $
* Author: Fabio Dell'Orto [FD] - STM
* Date: $Date: 2007/09/26 15:13:21 $
* Revision: $Revision: 1.37 $
*
* Description:
*
*
***************************************************
*
* COPYRIGHT (C) ST Microelectronics 2005
* All Rights Reserved
*
*******************************************************************************
* \brief Servo control & initialisation procedures
*
* \par Change History:
*
* - BB040315 Added output interface initalization according to module
* configuration settings
*
* - PH040601a Modified profile handling. Introduced profile union
* and pointer to it. So it can be switched ROM/RAM
*
* - PH040601- Changes:
* - Renamed procedure servo_init_cmd() to dsp_init()
* - Split up 1st state in init_Servo_for_new_disc
* because of execution time
* - New TTM profile variable idle_value used
*
* - ST040628 Changes:
* - Introduced initialisation for recoveries
* - Introduced setting of acquisition decimation factor in set_speed()
* - Introduced management of decimation factor changes in set_speed(),
* jump_check_ttm(), set_relock_request()
* - Added erased CD-RW detection in jump_ttm_check()
* - Introduced T_ths (threshold to assume target_T reached) calculation
* in start_jump()
* - Added reporting error during stop sequence in stop_servo()
* - Added call of scheduled start command in init_servo_for_new disc()
*
* - BB040923g Fixed and simplified forcing reading toc and calibration jump
* calculation
*
* - BB040928a Code rom and ram size optimisation:
* - Optimised check_servo() and evaluation of check_servo() result
*
* - BB041012a Fixed set set_relock_request() at requests after jumps from lead in
*
* - BB041109b Fixed noise during long jump, do not execute audio_init()
* if ttm_speed did not changed
*
* - MR041215 Optimized TTM controller
* - Increased controller bandwidth, CLV 1X 17Hz/35Hz
* (inside/outside).
* - Added hold functionality, ST7 can force the TTM
* controller to hold its state and output.
* - During a defect (DEFOK) and during a short jump the state
* of the controller is held (implemented in the DSP).
*
* - BB050114c Modified servo_init_for_new_disc_cmd() to not fail if called
* during servo_init_cmd() is executing
* - MR20050106 Problem: Turntable motor often came to a halt or rotated
* backwards after a jump from track 1 to the last track or vice
* versa. The fixes are described in the following points: a, b
* and c.
* - MR20050106a Changed the thresholds that determine whether or not the
* correct TTM velocity has been reached in CLV mode. Especially
* the value for the phase was too high.
* - MR20050106b Introduced a timer which makes sure that the TTM velocity is
* within the defined range for at certain period of time before
* the DSP notifies the ST7 that the correct speed has been
* reached.
* UPDATE: Time is set to 0 is it is negative for higher speeds
* and it the condition is catched by MR20050106b
* - MR20050106c When the TTM controller switches to hold mode (either by the
* ST7, during a short jump or a defect) it will not be allowed
* to brake the TTM. If the TTM controller output is negative
* during the hold mode then its output is set to zero.
* - PH050126a Introduced Rejumping to the last recovery position
* - BB050224b Fixed interrupted loader execution with new active command
* - BB050411a Fixed seek command from current position during seek execution
* - BB050411b Fixed stopping of toc reading
* - PH050504b Improved aux_ttm_calculation + relock pll after jump
* in set_speed and set_relock_request
* - PH050504c Modified RATE track coressing freuquency
* - PH050504d Enabled RATE_CTRL4.dfc_freq_lock
* - MR050523a Fixed frequency/FG-period error calculation in TTM controller.
* - MR050523b DSP detects high frequency FG pulses and reports this to the
* ST7. High frequency FG pulses are an indication for an to slow
* spinning or stopped TTM.
* - MR050523c Changed limit on TTM controller output from one +/- level to
* a maximum and a minimum level.
* - HW050530a jump_ttm_check: If relock PLL requested, adjust UNLOCKED_GAINS
* variable to improve lock of PLL. Reset this setting if state is
* left
* - ST "close tracks" jumping strategie for jumps smaller 20 tracks
* not to land after target sector or have no margin to relock PLL
* in time
* - BB050714b Fixed ESP synchronisation with during CLV speed
* (CLV buffer not empty)
* - BB050719a Fixed access to variables with flags which are written in ISR
* - ST Fixed starting_trk calculation in case of CLOSE_TRACKS
* - BB050719e Fixed switching speed between CAV and CLV
* - BB050809b Fixed muting when shockproof controller is off
* - BB050810k Fixed sevo pause event generating and handling
* - BB050815h Fixed speed setting from temporary CLV to CAV
* - BB051115a Implemented workaround to fix left channel noise
* - MR051115a Increase the focus and radial control loop by bandwith a factor 1.5
for speeds >= 4xCAV and > 2xCLV.
* - MR051115b Modified function speed_set() for controlling the switching of
* the control loop bandwidth
* -HW060125a Rom optimized function set_speed
* -HW060125a Use ttm speed 5xCAV instead of 6xCAV to prevent
* switching on outer disk to SCP_CLV Mode.
* -HW060123a Implemented workaround to fix TT motor problems after ECC reset for
* "left channel noise" problem
* -strange noise in pause mode
* -not accurat jumping means in some cases need many rejumps to find target
* - BB060502 QUICKFIX Play after Eject
***************************************************
*
* STM CVS Log:
*
* $Log: srvctr.c,v $ * Revision 1.37 2007/09/26 15:13:21 dellorto * bug fixing in access check * * Revision 1.36 2007/08/14 15:30:14 dellorto * multiple mechanisms *
* Revision 1.35 2007/04/11 14:21:04 belardi
* Integration of HAVE_CD_MECHA modification by [GP]
*
* Revision 1.34 2007/03/16 14:19:12 dellorto
* used new profiles
* modifications to hold ttm during short jump
* fixed reset of sledge condition to normal
*
* Revision 1.33 2006/11/21 13:58:43 dellorto
* improved hostif reporting of servo parameters in case of restart
*
* Revision 1.32 2006/11/10 16:30:42 dellorto
* added (re)setting of servo parameters for hostif
*
* Revision 1.31 2006/10/31 11:10:34 marcucci
* No more static functions for Jump Table
*
* Revision 1.30 2006/10/09 15:11:29 dellorto
* no message
*
* Revision 1.29 2006/09/18 09:55:25 belardi
* Corrected CVS keyword usage
*
* Revision 1.28 2006/09/18 09:25:37 belardi
* AddeLogg$ CVS keyword into file header
*
*
******************************************************************************/
#include "gendef.h"
#include "hwreg.h"
#include "srvinc.h"
#include "loader.h"
#include "monitor.h"
#include "controller.h"
#include "pdebug.h"
#if (DEBUG_INCLUDE_PCDEB == 1)
#include "dbgdef.h"
#include "dbgext.h"
#endif
#ifndef APM_PICKUP
#include "hostif_high.h"
#endif
#if (HAVE_CD_MECHA == 1)
uint8 corrective_jumps_counter;
#endif
uint32 T_actual;
#if (HAVE_CD_MECHA == 1)
uint32 lastplay_T;
uint32 previous_T;
uint32 lastrecovery_T;
uint8 start_mode;
uint8 data_mode;
uint8 end_mode;
uint32 target_T;
uint32 endplay_T;
uint16 starting_trk;
uint16 target_trk;
sint16 delta_trk;
sint16 skip_trk;
uint16 T_ths;
/******************************************************************************/
/* Function: sector_2_trk */
/* */
/*! \brief
* \param
* \return
* \remark
*/
/******************************************************************************/
uint16 sector_2_trk(uint32 sector)
{
return square_root(DISC_C * sector + DISC_R2);
}
/******************************************************************************/
/* Function: decimation_init */
/* */
/*! \brief Initialize registers of decimation block
* \param void
* \return void
* \remark
*/
/******************************************************************************/
void decimation_init(void)
{
DFRS = 0x00;
DFCR.all = 0x11;
AFDR = 150; /* 90 kHz */
AFRS = 8;
AFCF = 0xBA;
}
/******************************************************************************/
/* Function: rate_init */
/* */
/*! \brief Initialize RATE registers
* \param void
* \return void
* \remark
*/
/******************************************************************************/
void rate_init(void)
{
/* E-F */
RA_CTRL1.all = 0x88;
/* RA_CTRL1.field.agc_dis = 1; */
/* RA_CTRL1.field.linear_te = 0; (classic TE (E-F)) */
/* RA_CTRL1.field.speed = 0x08; */
RA_CTRL2.all = 0x42;
RA_CTRL3.all = OPU_PRO_LOW_RATE_PLL_GAIN;
/* Max P gain */
/* ntracks is ok if -32 < ntracks < 32 */
RA_ADDR = 0x00;
RA_DATA = 0x8D; /* FREEZE PLL DURING DEFECT PH050504d */
RA_ADDR = 0x06;
RA_DATA = 0x07;
/* RATE hf lost threshold */
RA_ADDR = 0x01;
RA_DATA = 0xE0;
/* RATE profile generator clk : 106 kHz */
RA_ADDR = 0x02;
RA_DATA = 0x21;
/* Profile max speed 106/xxx16 kHz 3.7 */
RA_ADDR = 0x04;
RA_DATA = 0x09; /* PH050504c */
/* Not too sharp acc. profile */
RA_ADDR = 0x05;
RA_DATA = 0x10;
RA_ADDR = 0x07;
RA_DATA = 0xFA;
/* Observe linear TE */
RA_ADDR = 0x09;
RA_DATA = 0x08;
}
/******************************************************************************/
/* Function: init_servo */
/* */
/*! \brief Core function of SERVO_INIT state
* \param void
* \return RETVAL - BUSY, READY or ERROR
* \remark Loading DSP Code into its PRAM, initialize DECIMATION + RATE
*/
/******************************************************************************/
RETVAL init_servo(void)
{
RETVAL init_servo_result;
init_servo_result = IN_PROGRESS;
switch (init_servo_state)
{
case STATE_1:
switch (load_dsp())
{
case IN_PROGRESS:
break;
case OK:
init_servo_state = STATE_2;
break;
//case LOAD_DSP_ERROR:
default:
init_servo_result = LOAD_DSP_ERROR;
break;
}
break;
//case STATE_2:
default:
#ifdef APM_PICKUP
if (!DRIVER_LOADER_IS_ON)
{
DRIVER_OFF;
}
#endif
sledge_fsm_call(SLEDGE_CALLER_INIT_CMD);
//oif_requested_speed = CLV | CLV_1X;
//oif_ttm_speed = CLV | CLV_1X;
//ttm_speed = INIT_SPEED;
decimation_init();
servo_misc_flags.field.init_done = 1;
if (servo_misc_flags.field.init_for_new_disc_request)
{
servo_misc_flags.field.init_for_new_disc_request = 0;
init_servo_result = INIT_FOR_NEW_DISC_REQUEST;
}
else
{
init_servo_result = OK;
}
break;
}
return init_servo_result;
}
/******************************************************************************/
/* Function: init_servo_for_new_disc */
/* */
/*! \brief Core function of SERVO_INIT_FOR_NEW_DISC state
* \param void
* \return RETVAL - BUSY, READY or ERROR
* \remark Programming DSP coefficients, initialize AFE, Channel, parts of RATE,
* CIRC, OIF. Stop TTM, move sledge to home position.
*/
/******************************************************************************/
RETVAL init_servo_for_new_disc(void)
{
RETVAL init_servo_for_new_disc_result;
init_servo_for_new_disc_result = IN_PROGRESS;
switch (init_servo_for_new_disc_state)
{
case STATE_1:
dsp_init();
nlc_init();
afe_init();
rate_init();
acq_init();
ecc_init();
//oif_init();
clv_init();
#if (DEBUG_INCLUDE_PCDEB == 1)
if (buffer_mode == BUFFER_MODE_CLV)
{
target_ttm_speed = INIT_SPEED_DEBUG;
}
else
#endif
{
target_ttm_speed = INIT_SPEED;
}
servo_startup_flags.all = SERVO_STARTUP_FLAGS_INIT;
/* servo_startup_flags.field.fe_adjust_done = 0; */
/* servo_startup_flags.field.ttm_started = 0; */
/* servo_startup_flags.field.hf_found = 0; */
/* servo_startup_flags.field.te_adjust_done = 0; */
/* servo_startup_flags.field.agc_focus_done = 0; */
/* servo_startup_flags.field.agc_tracking_done = 0; */
/* servo_startup_flags.field.mode1_found = 0; */
/* servo_startup_flags.field.first_startup_sequence_completed = 0; */
servo_misc_flags.field.sledge_home_request = 0;
DISABLE_INTERRUPTS();
oif_mute_control.audio_on = 0;
//oif_mute_control.mute1_on = 1; // BTODO
//oif_mute_control.mute2_on = 1;
ENABLE_INTERRUPTS();
CDinfo = 0x00;
//servo_reset_play_data_cmd(); // cannot call from Servo because it waits on the Servo semaphore!
servo_reset_play_data_cmd_from_servo();
reset_toc(TOC_RESET_ALL);
#ifdef APM_PICKUP
ACT_AND_TT_ON_SCBM;
brake_ttm();
init_servo_for_new_disc_state = STATE_2;
#else
DRIVER_ON;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -