📄 controller.c
字号:
/************************************************** * * controller.c * * CVS ID: $Id: controller.c,v 1.273 2007/11/15 14:24:09 trubac Exp $ * Author: Raffaele Belardi [RB] - STM * Date: $Date: 2007/11/15 14:24:09 $ * Revision: $Revision: 1.273 $ * * Description: * * Main entry point for the controller task. * *************************************************** * * COPYRIGHT (C) ST Microelectronics 2005 * All Rights Reserved * *************************************************** * * \brief Controller * * \par Change History: * * * - DR060912 Info.Update To Capture Module Regarding Play Mode * / ROM Mode buffer access(Flag - Play_Mode) * - BB060920c Removed tag string pointer from t_SongInfos * (copying structure easier and safer) * - BB060926a Fixed CD exchange (WUT74-18-102531) * - BB060929a Improved no TOC and Copyprotected CD support * ****************************************************************************** * * STM CVS Log: * * $Log: controller.c,v $ * Revision 1.273 2007/11/15 14:24:09 trubac * Handling of wrong sectors for CA playback (WMA,MP3,AAC) * Added error limits for CD sector acquisition * * Revision 1.272 2007/11/13 15:39:41 marcucci * Fix for Absolute/Relative Track # * * Revision 1.271 2007/10/31 15:29:40 marcucci * Fix for Bad Time reporting in controller_process_preevents * * Revision 1.270 2007/10/30 16:50:01 belardi * Removed code added in PRE20 for Visteon issue #122, new CAP/CTR does not need it and it gives problem on track change during FB * * Revision 1.269 2007/10/22 12:32:27 trubac * STOP event from USB is not cleared by ctr_stop_USB_transition() * * Revision 1.268 2007/10/04 13:13:10 marcucci * Fix for Protected CD * * Revision 1.267 2007/10/02 12:14:24 trubac * Fix for SDC sticking of transition to play from search mode * * Revision 1.266 2007/10/02 08:57:53 belardi * Commented out unused function * * Revision 1.265 2007/09/26 12:00:43 marcucci * Fix for Issue#122, * * Revision 1.264 2007/09/21 05:25:32 hara * Initial implementation for WMDRM feature into A+. * * Revision 1.263 2007/09/19 07:36:06 belardi * Bug fix for scratch disc: if corrupted file is detected, it's necessary to copy next->current song info * * Revision 1.262 2007/09/14 10:10:26 marcucci * Added a patch to report DISC_ERROR in case of Read Error during READ TOC * in the ctr_read_toc_transition function CTR_TOC_FSM_READING case * * Revision 1.261 2007/08/21 08:11:32 belardi * Added error #define * * Revision 1.260 2007/08/15 13:37:24 trubac * fixing CD mounting killed by unplugging other device * * Revision 1.259 2007/07/31 11:59:57 belardi * Removed compiler warning * * Revision 1.258 2007/07/25 13:43:05 trubac * Mounting device low memory measures copied from 3.1, Not used * volumes deleted before new mounting * * Revision 1.257 2007/07/12 16:44:26 longauer * init/close usb controller cmd/status path partly implemented * * Revision 1.256 2007/07/10 13:53:33 longauer * usb events renaming * * Revision 1.255 2007/07/02 11:23:36 marcucci * Random Seed initialization for CD-DA Added * * Revision 1.254 2007/06/12 09:04:50 sedmik * Several fixes: * - CmdFB param song nr, time = 0 (track change checking) * - command FB, F=1, time=0;- prevent BOS event when new forced command is comming * - devices mount ~ invalid USB/SDC volumes are deleted before new mount operation (saving X_array space) * * Revision 1.253 2007/06/04 16:58:44 longauer * USBtask rearrangement in order to support more logical units; new file usb_pri.h added with USBtask private declarations; USB compilation switches added; constants renaming; * * Revision 1.252 2007/03/19 17:57:51 belardi * Integration of Optomech AAC decoder P150307 * * Revision 1.251 2007/03/13 16:31:41 longauer * temporary_usb_status added in order to preserve USB_STATUS data * * Revision 1.250 2007/03/08 09:24:05 chlapik * in ctr_data_transition() error sent via status channel to PLY, not via pre_eos channel * * Revision 1.249 2007/02/27 11:03:16 belardi * Reverted back to pre-Optomech patch (1.247) * * Revision 1.247 2007/02/23 13:34:56 chlapik * removed useless debug code * * Revision 1.246 2007/02/22 18:41:03 belardi * Code re-arrangement to remove compiler warning * * Revision 1.245 2007/02/21 20:18:13 longauer * usb states and error reorganization; usb state is propagated to player task = usb * state messaging * * Revision 1.244 2007/02/21 09:15:42 chlapik * new CTR - CAP interface: ESP history removed from CTR * * Revision 1.242 2007/02/01 16:32:06 chlapik * fixed bug - song number setting in GetCurrentPosition() function * * Revision 1.241 2007/02/01 15:25:14 chlapik * fixed bug - in cd_extent transition Search structure was used instead of WriteSearch * * Revision 1.240 2007/02/01 13:26:50 chlapik * fixed bug - for CA CDs put last data from file to FB (new EOS for CDDA created bug for CA) * * Revision 1.239 2007/01/30 09:38:16 chlapik * fixed bug: * song_number and xid sent from CTR to PLY is not set in CTR task but it is provided by DEC to AB * * Revision 1.238 2007/01/29 14:32:00 chlapik * support for USB devices with any block size (not only 512B) * * Revision 1.237 2007/01/18 07:56:47 chlapik * ctr_CD_data_for_CTR_transition() modified for new EOS (CDDA) - EOS with first sector of next chunk * * Revision 1.236 2007/01/03 09:52:14 chlapik * fixed bug - if fast seek cmd coming while prebuffering of next song for CDDA, modify cap_write_q_tno inside CAP from CTR to current played song * * Revision 1.235 2006/12/19 11:04:02 belardi * Integration of Optomech AAC decode P061219 * * Revision 1.234 2006/12/13 09:29:36 belardi * Added initialization of new field of STRUCT_Q_SUBCODE to support DirNo parameter in MsgTimeInfo * * Revision 1.233 2006/12/06 14:31:38 chlapik * fixed bugs: * - in cd_extent WriteSearch should be used instead of Search par. * - if continuous playback, then clear FB_mode variable for CAP * * Revision 1.232 2006/12/06 13:34:20 marcucci * Have Update Fix * * Revision 1.231 2006/12/04 15:40:27 chlapik * fixed bug - init of ctr read transition was missing * * Revision 1.230 2006/12/04 15:19:35 chlapik * fixed bug - for read transition we must wait with cap cmd start till last read request is finished * * Revision 1.229 2006/12/04 13:27:26 chlapik * if Layer I & II disabled, then CTR refuses to play these files * * Revision 1.228 2006/12/04 09:16:16 chlapik * fixed bug - if CAP reports error for xfer cmd, then propagate it to PLY * * Revision 1.227 2006/12/01 10:32:06 chlapik * fixed bug - for cmd data read don't start CAP in case of USB * * Revision 1.226 2006/11/30 11:07:04 belardi * Changed host_update_file_index to uint16 to comply with XAR_SafeIndex() * * Revision 1.225 2006/11/28 09:24:08 belardi * m4a decoder alfa release from Optomech * * Revision 1.224 2006/11/27 19:39:45 belardi * Host Update protocol addition * * Revision 1.223 2006/11/25 08:46:18 belardi * Ununsed function removal to free code space * * Revision 1.222 2006/11/24 10:17:40 chlapik * fixed bug for SDC - macro for USB was used for SDC * * Revision 1.221 2006/11/20 15:13:15 marcucci * ctr_update_transition() improved * * Revision 1.220 2006/11/20 09:08:58 sedmik * SDC alignment * * Revision 1.219 2006/11/14 16:51:15 belardi * removed unreachable statements to reduce compiler warnings * * Revision 1.218 2006/11/13 14:59:21 chlapik * emphasis valid in current_song_info * * Revision 1.217 2006/11/10 08:49:48 chlapik * fixed bug - if cmd with current pos. then when determining dev, check if current pos valid, if not, set dev according to file id * * Revision 1.216 2006/11/08 08:49:39 marcucci * HAVE_UPDATE form CD and USB * * Revision 1.215 2006/11/06 16:41:13 chlapik * fixed bug - after loading of code, if play cmd coming earlier that pause is really reached (prebuffering finished), then clear of pause parameter of play transition needed * * Revision 1.214 2006/11/02 12:10:33 chlapik * - checked all global variables used by DMA CH0 interrupt and DEC or CTR task - disable/enable scheduling/interrupts used for protection * - functions AudioBufferResetPosition() and ResetAudioBuffer() check if DMA xfer is not active, only then do the modification of AB variables * - CDDA - repeat of last xfer: * - mark AB element used for repeat xfer as not empty in order that DEC doesn't reconfigure SRC, DMA, OIF * - after repeated xfer is finished, if new data available, start DMA xfer again, but set source address correctly, not one from previous xfer * * Revision 1.213 2006/10/31 14:14:18 chlapik * support for Layer I & II: * - Layer type, sample rate and channel number are determined by BitrateParser before playback * - mp3 decoder checks if these parameters found in valid header matches, if not scan bitstream per bytes * * Revision 1.212 2006/10/31 11:12:25 marcucci * Modified to make HAVE_UPDATE Working * * Revision 1.211 2006/10/27 13:16:11 chlapik * - fixed bug in com. with CAP - before sending new cmd, always clear responses - ready and PRE EOS * - when CTR is going to send ready to PLY and new cmd is already pending for CTR, don't send ready but only in special cases - logic modified * - multiply ready - if CTR forwards CAP error, then clear high 16 bits, where device and cmd is encoded * - waiting for read ready before sending new cmd to CAP - logic can be switched off with define * - preparation for read ready sent from CAP to CTR in subcode channel and not in read channel * * Revision 1.210 2006/10/23 14:02:03 chlapik * fixed bug - if dummy read (always one sector), then don't check if whole read xfer finished (only for normal reads) * * Revision 1.209 2006/10/23 09:02:31 marcucci * Add new ctr_update_transition() procedure * * Revision 1.208 2006/10/20 12:26:52 belardi * Minor change to remove compiler warning * * Revision 1.207 2006/10/20 08:47:32 chlapik * - fixed issues with pause and pause release cmds coming while play/search/pause_at cmds active - exception - don't cancel prebuffering cmd (play/search/pause_at) * - cmd INIT sent to CAP not from controller_cmd() (called by PLY) but from process_preevents() - otherwise it can happen that CAP executes INIT earlier than CTR activates FSM for checking READY from CAP * - fixed bugs in device handling macros - missing brackets for whole macro * * Revision 1.206 2006/10/18 09:52:09 chlapik * read toc and mount cmds contain also force_execution functionality * * Revision 1.205 2006/10/18 08:55:02 chlapik * fixed bug - prebuffering not working with error TWO_BUF_IN_PAR_ERROR * * Revision 1.204 2006/10/17 14:19:36 chlapik * - multiple ready * - modified devices handling: type of last cmd from PLY to CTR stored for each device separately * - CTR checks if there is not wrong unforced cmd for prebuffering while old one is still not finished * - new CTR - CAP interface: * - CTR is able to process info about amount of really provided data from CAP, re-ask for rest of data again * - number of xfered data calculates CTR itself (temporarily) * - sector lba in read requests for CDDA added * - CTR doesn't use ctr_read_cmd() * - CTR has posibility to work without ESP_HISTORY * * Revision 1.203 2006/10/17 09:45:32 trubac * toc reading and mounting improvement by BB * * Revision 1.202 2006/10/05 11:33:29 trubac * XAR_ReallocateTOC must be before CD_UpdateTracksInfo * * Revision 1.201 2006/09/26 10:19:19 belardi * Removed unused variable * * Revision 1.200 2006/09/19 11:03:57 chlapik * solved misunderstanding of Play_Mode and buffering_mode bits in cmd to CAP - buffering_mode is again present in cmd structure * * Revision 1.199 2006/09/18 13:22:27 chlapik * fixed bug - if FF cmd cancelled by FB * - wrong determination of search mode in process_preevents (not only data params but also play params must be checked) * - again checking errors for read requests from CAP * * Revision 1.198 2006/09/15 19:31:13 belardi * Merged the m8_cav2_cm80506_cs3563. * - name change printf-> dprintf * - name change X_LAST_ITEM * - changed xfer_prameters fields * - removed XAR_RelocateTOC * * ****************************************************/#include "gendef.h"#include "osal.h"#include "hwreg.h"#include "hwinit.h"//#include "hwinit.h" // for switch_buf_path#include "xfile.h"#include "id3tag.h"#include "filesys.h"#include "apdevsys.h"#include "framebuffer.h"#include "audiobuffer.h" // ResetAB#if (0 != HAVE_WMDRM)#include "WMDRM_Receiver.h"#endif#if (0 != HAVE_USB)#include "usb.h"#endif#if (0 != HAVE_SDC)#include "sdc.h"#endif /* HAVE_SDC */#include "FATsupport.h"#include "iso9660.h"#include "capture.h"#include "controller.h"#include "decoder_task.h"#include "cddevice.h"#ifdef APM_PICKUP#include "ssong.h"#include "service.h" /* for debug printf */#else#include "audio_support.h"#endif#include "srvinc.h"#include "toc.h"#if (1==HAVE_CDTEXT)#include "text.h"#endif#include <string.h> //[OK] memcpy#if (0 != HAVE_UPDATE)#include "blgendef.h"#include "bspi_util.h"#endif /* HAVE_UPDATE */#ifndef APM_PICKUP#include "hostif_low.h"#include "hostif_high.h"#endif#include "utility.h" //[MM]#if (0 != HAVE_AAC)#include "aactag.h"#endif /* HAVE_AAC */#ifdef APM_PICKUP#define TOC_SPEED (CAV | CAV_4X_OUT_DISC)#define MOUNT_SPEED (CAV | CAV_4X_OUT_DISC)#else#define TOC_SPEED (SCP_CLV | CLV_2X)#define MOUNT_SPEED (SCP_CLV | CLV_2X)#endifextern volatile uint32 sf_type;extern uint32 rndNextSeed;#if (0 != HAVE_HOST_UPDATE)/* [RB] changes the behaviour of the controller_update_fsm *//* 0 = update local flash *//* 1 = send update file to host */t_bool use_host_update_fsm = FALSE;#endifstatic t_fsm controller_init_new_disc_fsm;static t_fsm controller_read_toc_fsm;static t_fsm controller_mount_fs_fsm;static t_fsm controller_tag_fsm;t_fsm controller_CD_data_for_TASK_fsm;static t_fsm controller_CD_data_for_CTR_fsm;#if (0 != HAVE_USB)t_fsm controller_USB_data_for_TASK_fsm;static t_fsm controller_USB_data_for_CTR_fsm;#endif#if (0 != HAVE_SDC)t_fsm controller_SDC_data_for_TASK_fsm;static t_fsm controller_SDC_data_for_CTR_fsm;#endif /* HAVE_SDC */static t_fsm controller_play_fsm;static t_fsm controller_stop_fsm;static t_fsm controller_stop_device_fsm;static t_fsm controller_wait_capture_fsm;static t_fsm controller_stop_filesys_fsm;static t_fsm controller_stop_decoder_fsm;static t_fsm controller_stop_USB_fsm;static t_fsm controller_stop_CD_fsm;#if (0 != HAVE_SDC)static t_fsm controller_stop_SDC_fsm;#endif /* HAVE_SDC */static t_fsm controller_cd_extent_fsm;static t_fsm controller_data_fsm;static t_fsm controller_esp_fsm;static t_fsm controller_read_fsm;#if (0 != HAVE_UPDATE)static t_fsm controller_update_fsm;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -