⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mv_inp.c

📁 tuner扫描
💻 C
📖 第 1 页 / 共 3 页
字号:
/*==========================================================================*/
/*     (Copyright (C) 2003 Koninklijke Philips Electronics N.V.             */
/*     All rights reserved.                                                 */
/*     This source code and any compilation or derivative thereof is the    */
/*     proprietary information of Koninklijke Philips Electronics N.V.      */
/*     and is confidential in nature.                                       */
/*     Under no circumstances is this software to be exposed to or placed   */
/*     under an Open Source License of any type without the expressed       */
/*     written permission of Koninklijke Philips Electronics N.V.           */
/*==========================================================================*/
/*==========================================================================*/
/*                                                                          
       SOURCE_FILE:    MV_INP.C

       PACKAGE:        INP
       COMPONENT:      MV      
                                                                            
       (C) 1998: Philips Semiconductors                                
                                                                            */ 
/*==========================================================================*/
/*MPP:::INP======================================================*/

/* PACKAGE NAME:       INP

   SCOPE:              PLATEFORM
      
   ORIGINAL AUTHOR:    B.LEMESLE

   DESCRIPTION :  
   Basic functionality of the video input package.
   The input package of the video component contains all the functionalities
   concerning the input processing of the audio data. This includes the data
   format of the video data in the input buffer, the configuration of the
   input buffers etc...

   DATA TYPES:

   FUNCTIONS:
   MV_INP_bufuse
   MV_INP_init
   MV_INP_set_defaults
   MV_INP_term
   MV_INP_reset_buffer
   MV_INP_set_warning_levels
   MV_INP_get_status
   MV_INP_set_format
   MV_INP_fill_buffer
   MV_INP_fill_still_buffer
   MV_INP_install_notify
   MV_INP_enable_notification
   MV_INP_disable_notification

                                                                            */
/*EMP=======================================================================*/

/*==========================================================================*/
/*       I N C L U D E S                                                    */ 
/*==========================================================================*/
#include "standard.h"
#include "tmosal.h"
#include "mv_inpl.h"
#include "mv_inpp.h"
#include "mv_itvl.h"
#include "dv_dbg.h"
#include "ipvd_dbgl.h"
#include "mv_dec.h"
#include "mv_decl.h"
# include "mv_drv.h"
#include "fbm_api.h"

/*==========================================================================*/
/*       G L O B A L   D A T A   D E C L A R A T I O N S                    */
/*==========================================================================*/
BOOLEAN GV_cmd_buf_start = FALSE;

MV_INP_STATUS GV_MV_INP_status;
static const MV_INP_STATUS GV_MV_INP_status_init = MV_INP_STATUS_INIT;

/*==========================================================================*/
/*       L O C A L   S Y M B O L   D E F I N I T I O N S                    */
/*==========================================================================*/

/*==========================================================================*/
/*       L O C A L   D A T A   D E C L A R A T I O N S                      */
/*==========================================================================*/

/*==========================================================================*/
/*       L O C A L   F U N C T I O N S   P R O T O T Y P E S                */
/*==========================================================================*/
static void  LF_VIDEO_FIFO_UNDER_handler    (void);
static void  LF_VIDEO_FIFO_OVER_handler    (void);
static void  LF_VIDEO_FIFO_EMPTY_handler    (void);
static void  LF_VIDEO_FIFO_FULL_handler    (void);
static void  LF_VIDEO_FIFO_PTR_UPDATED_handler    (void);
static void  LF_SYSTEM_EVENT_handler    (void);
static void  LF_NEW_VIDEO_DTS_handler   (void);
static void  LF_NEW_VIDEO_PTS_handler   (void);

/*==========================================================================*/
/*       G L O B A L  F U N C T I O N S                                     */ 
/*==========================================================================*/
/*MPF=======================================================================*/
/*  
    FUNCTION NAME:     MV_INP_bufuse

    PACKAGE:           INP

    SCOPE:             PLATEFORM

    DESCRIPTION:
    Depending on some (run-time) configuration parameters, the sizes (and
    alignments) of the buffers required by the package are computed.
    With this information the application can allocate these buffers and pass
    them to the package upon initialization.
    Actually, application decides of the size of the still fifo for Picture
    in Picture trickmode(in unit of bytes).

    PRECONDITIONS:
    This function may be called before MV_INP_init().
    
    POSTCONDITIONS:
    
    CALLING SEQUENCE:
    */
void
MV_INP_bufuse(
   MV_INP_BUFCFG * in_bufcfg_ptr, /* In: run-time config. parameters */
   MV_INP_BUFFERS * ou_bufuse_ptr /* Out: required sizes and alignment */
   )
/*EMP=======================================================================*/
{
   ou_bufuse_ptr->still_fifo_size = in_bufcfg_ptr->still_fifo_size;
   ou_bufuse_ptr->still_fifo_addr = (void *)0xFFFFFC00; /* 32 bits alignement */
   
   ou_bufuse_ptr->video_fifo_size = in_bufcfg_ptr->video_fifo_size;
   ou_bufuse_ptr->video_fifo_addr = (void *)0xFFFFFC00; /* 32 bits alignement */
   
} /* End of MV_INP_bufuse */


/*MPF=======================================================================*/
/*  
    FUNCTION NAME:     MV_INP_init

    PACKAGE:           INP

    SCOPE:             PLATEFORM

    DESCRIPTION:
    This function initializes the video input package.
    It claims all resources needed by the package and subsequently sets it
    to its default state as specified for the MV_INP_set_defaults() function. 

    The required buffers are passed as parameters.
    This function must be called before any other function of the MV_INP
    package (except MV_INP_bufuse())

    !!! MV_DEC_init must be called before MV_INP_init

    PRECONDITIONS:
    This function may be called after MV_INP_bufuse().

    POSTCONDITIONS:
    The drivers are set in the same mode than after call to
    MV_INP_set_defaults().
    
    CALLING SEQUENCE:
    */
void
MV_INP_init(    
   MV_INP_BUFFERS * in_buffers_ptr /* In: application allocated buffers */
   )
/*EMP=======================================================================*/
{
   /* retrive absolute SDRAM base address */
   GV_MV_INP_status.SDRAM_base_addr = (unsigned long)in_buffers_ptr->SDRAM_base_addr;

   /* initialize video and still fifo start and stop adresses (offset) */
   MV_drv_set_video_fifo_start((unsigned long)((unsigned long)in_buffers_ptr->video_fifo_addr
                                               - (unsigned long)in_buffers_ptr->SDRAM_base_addr));
   /* offset % video_fifo_start (in bytes) */
   MV_drv_set_video_fifo_size((unsigned long)in_buffers_ptr->video_fifo_size);

   MV_drv_set_still_fifo_start((unsigned long)in_buffers_ptr->still_fifo_addr
                               - (unsigned long)in_buffers_ptr->SDRAM_base_addr);
   /* offset % still_fifo_start (in bytes) */
   MV_drv_set_still_fifo_size((unsigned long)in_buffers_ptr->still_fifo_size); /* in bytes */
   
   /* Install SYSTEM_EVENT_handler */
   MV_drv_set_system_event_clear(0xffffffff)
      MV_ITV_install_isr(LF_SYSTEM_EVENT_handler, MV_ITV_SYSTEM_EVENT, FALSE);
   MV_drv_set_system_event_enable( MV_INP_SYSTEM_EVENT_NEED_DTS | MV_INP_SYSTEM_EVENT_DTS_EMULATION | MV_drv_system_event_enable());
   
   /* Install VIDEO_FIFO_PTR_UPDATED_handler */
   MV_ITV_install_isr(LF_VIDEO_FIFO_PTR_UPDATED_handler, MV_ITV_VIDEO_FIFO_PTR_UPDATED, TRUE);
   /* Install VIDEO_FIFO_UNDER_handler */
   MV_ITV_install_isr(LF_VIDEO_FIFO_UNDER_handler, MV_ITV_VIDEO_FIFO_UNDER, FALSE);
   /* Install VIDEO_FIFO_OVER_handler */
   MV_ITV_install_isr(LF_VIDEO_FIFO_OVER_handler, MV_ITV_VIDEO_FIFO_OVER, FALSE);
   /* Install VIDEO_FIFO_EMPTY_handler */
   MV_ITV_install_isr(LF_VIDEO_FIFO_EMPTY_handler, MV_ITV_VIDEO_FIFO_EMPTY, FALSE);
   /* Install VIDEO_FIFO_FULL_handler */
   MV_ITV_install_isr(LF_VIDEO_FIFO_FULL_handler, MV_ITV_VIDEO_FIFO_FULL, FALSE);
   /* Install NEW_VIDEO_DTS_handler */
   MV_ITV_install_isr(LF_NEW_VIDEO_DTS_handler, MV_ITV_NEW_VIDEO_DTS, TRUE);
   /* Install NEW_VIDEO_PTS_handler */
   MV_ITV_install_isr(LF_NEW_VIDEO_PTS_handler, MV_ITV_NEW_VIDEO_PTS, TRUE);

   MV_INP_set_defaults();
   
} /* End of MV_INP_init */

/*MPF=======================================================================*/
/*  
    FUNCTION NAME:     MV_INP_set_defaults

    PACKAGE:           INP

    SCOPE:             PLATEFORM

    DESCRIPTION:
    Sets the video input buffer package to its default settings.
    Following values will be configured after this call :

    INPUT DATA format : ES
    UNDER level : 10000 bytes from the bottom of the video buffer
    OVER level  : 160000 bytes from the bottom of the video buffer
    EVENT to notify to application : MV_INP_NO_EVENT
    CALLBACK notification function : NULL


    PRECONDITIONS:
    In this API, The video input fifo is reset, that implies the
    read_pointer and the buffer fullness measurement are setted to 0,
    so application must reset before the write pointer to stay coherent.

    POSTCONDITIONS:
    None
    
    CALLING SEQUENCE:
*/
void
MV_INP_set_defaults(    
   void
   )
/*EMP=======================================================================*/
{
   unsigned long      lv_SDRAM_base_addr;
   
   /* retrieve address and size of SDRAM because it is only initialized
      once in MV_DEC_init() */
   lv_SDRAM_base_addr = GV_MV_INP_status.SDRAM_base_addr;
   
   /* assign default value to GV_INP_status (defined in mv_inpl.h) */
   GV_MV_INP_status = GV_MV_INP_status_init;

   /* restore address and size of SDRAM */
   GV_MV_INP_status.SDRAM_base_addr = lv_SDRAM_base_addr;

   /* reset video input fifo */
   MV_drv_set_video_fifo_disable(MV_BIT_ON);
   MV_drv_set_video_synchronisation_mode(MV_VIDEO_BUF_CTRL_STOP);
   MV_INP_reset_buffer();
   
   /* Update internal status */
   GV_MV_INP_status.inp_buffer_size = MV_drv_video_fifo_size(); /* in bytes */

   /*  Set default values for registers */
   MV_drv_set_video_format_selection(GV_MV_INP_status.inp_data_format);
   MV_drv_set_video_fifo_under(GV_MV_INP_status.inp_under_level); /* in bytes */
   MV_drv_set_video_fifo_over(GV_MV_INP_status.inp_over_level); /* in bytes */

} /* End of MV_INP_set_defaults */

/*MPF=======================================================================*/
/*  
    FUNCTION NAME:     MV_INP_term

    PACKAGE:           INP

    SCOPE:             PLATEFORM

    DESCRIPTION:
    Deinitialise the video input buffer package.
    Frees all resources allocated by MV_INP_init call.

    PRECONDITIONS:
    None

    POSTCONDITIONS:
    After calling to this API, only MV_INP_bufuse() and MV_INP_init()
    can be called.
    
    CALLING SEQUENCE:
*/
void
MV_INP_term(    
void
)
/*EMP=======================================================================*/
{
   /* Deinstall SYSTEM_EVENT_handler */
   MV_ITV_deinstall_isr(MV_ITV_SYSTEM_EVENT);
   /* Deinstall VIDEO_FIFO_PTR_UPDATED_handler */
   MV_ITV_deinstall_isr(MV_ITV_VIDEO_FIFO_PTR_UPDATED);
   /* Deinstall VIDEO_FIFO_UNDER_handler */
   MV_ITV_deinstall_isr(MV_ITV_VIDEO_FIFO_UNDER);
   /* Deinstall VIDEO_FIFO_OVER_handler */
   MV_ITV_deinstall_isr(MV_ITV_VIDEO_FIFO_OVER);
   /* Deinstall VIDEO_FIFO_EMPTY_handler */
   MV_ITV_deinstall_isr(MV_ITV_VIDEO_FIFO_EMPTY);   
   /* Deinstall VIDEO_FIFO_FULL_handler */
   MV_ITV_deinstall_isr(MV_ITV_VIDEO_FIFO_FULL);
   /* Deinstall NEW_VIDEO_DTS_handler */
   MV_ITV_deinstall_isr(MV_ITV_NEW_VIDEO_DTS);
   /* Deinstall NEW_VIDEO_PTS_handler */
   MV_ITV_deinstall_isr(MV_ITV_NEW_VIDEO_PTS);
   /* Deinstall NEW_VIDEO_PES_handler */
   MV_ITV_deinstall_isr(MV_ITV_NEW_VIDEO_PES);
   
} /* End of MV_INP_term */

/*MPF=======================================================================*/
/*  
    FUNCTION NAME:     MV_INP_reset_buffer

    PACKAGE:           INP

    SCOPE:             PLATEFORM

    DESCRIPTION:
    Flush the video input buffer.

    The video input buffer is cleared. This can be useful when video data
    in the input buffer should be discarded for instance when changing to
    another video stream.

    NOTES:
    This function should not be called during decoding because internal
    decoder pipelines are not cleared.

    This function coulb be called directly from an ISR

    In this API, the read_pointer and the buffer fullness measurement
    are setted to 0,so application must reset before the write pointer
    to stay coherent.

    PRECONDITIONS:
    None

    POSTCONDITIONS:
    None
    
    CALLING SEQUENCE:
*/
void
MV_INP_reset_buffer(    
void
)
/*EMP=======================================================================*/
{
   UInt32 lv_protection_level;
   
   /* when a video reset is performed so that discontinuity handling is stopped */
   tmosalDisableInterruptsNoSysCall(&lv_protection_level); 
   GV_MV_DEC_status.dec_discontinuity_detected = FALSE;
   GV_MV_DEC_status.dec_dts_found = FALSE;
   GV_MV_DEC_status.dec_pts_found = FALSE;
   tmosalEnableInterruptsNoSysCall(lv_protection_level);
   
#ifdef _UNIX_
   MV_drv_set_video_fifo_bfmo_cur(0);
   MV_drv_set_video_fifo_bfmu_cur(0);
   MV_drv_set_video_fifo_rdpt_cur(0);

#else /* used for QT */

   /* stop sending data from video fifo to decoding core */
   MV_drv_set_video_fifo_disable(MV_BIT_ON);
   MV_drv_set_video_synchronisation_mode(MV_VIDEO_BUF_CTRL_STOP);
   
   /* set read ptr to video fifo start address */
   /* because of HW bug, mechanism of increment/decrement works */
   /* for bfm but not for rdpt */
   MV_drv_set_video_fifo_nxt_value(0);
   MV_drv_set_video_fifo_bfm_dec(MV_BIT_OFF);
   MV_drv_set_video_fifo_rdpt_update(MV_BIT_ON);

   /* reset bfm */
   MV_drv_set_clear_video_fifo_bfm(MV_BIT_ON);

#endif
   
} /* End of MV_INP_reset_buffer */

/*MPF=======================================================================*/
/*  
    FUNCTION NAME:     MV_INP_set_warning_levels

    PACKAGE:           INP

    SCOPE:             PLATEFORM

    DESCRIPTION:
    Configures of the underflow and overflow levels for the video input buffer.
    underflow and overflow level are specified in units of bytes.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -