📄 mv_inp.c
字号:
NOTES:
in_under_level and in_over_level must be multiple of 4 bytes
PRECONDITIONS:
None
POSTCONDITIONS:
None
CALLING SEQUENCE:
*/
void
MV_INP_set_warning_levels(
MV_INP_BUF_SIZE in_under_level, /* in unit of bytes */
MV_INP_BUF_SIZE in_over_level /* in unit of bytes */
)
/*EMP=======================================================================*/
{
/* Store new values in status struct */
GV_MV_INP_status.inp_over_level = in_over_level; /* in bytes */
GV_MV_INP_status.inp_under_level = in_under_level; /* in bytes */
/* Store new values in registers */
MV_drv_set_video_fifo_under(in_under_level);
MV_drv_set_video_fifo_over(in_over_level);
} /* End of MV_INP_set_warning_levels */
/*MPF=======================================================================*/
/*
FUNCTION NAME: MV_INP_get_status
PACKAGE: INP
SCOPE: PLATEFORM
DESCRIPTION:
Get the video input buffer status.
It retrieves :
- size of the video fifo
- under level
- over level
- fullness of video buffer
- freespace in the video buffer
- SDRAM base address
Units are bytes.
PRECONDITIONS:
None
POSTCONDITIONS:
None
CALLING SEQUENCE:
*/
void
MV_INP_get_status(
MV_INP_BUF_SIZE * ou_buf_size_ptr, /* in unit of bytes */
MV_INP_BUF_SIZE * ou_under_level_ptr, /* in unit of bytes */
MV_INP_BUF_SIZE * ou_over_level_ptr, /* in unit of bytes */
MV_INP_BUF_SIZE * ou_fullness_ptr, /* in unit of bytes */
MV_INP_BUF_SIZE * ou_freespace_ptr, /* in unit of bytes */
unsigned long * ou_SDRAM_base_addr_ptr
)
/*EMP=======================================================================*/
{
MV_INP_BUF_SIZE lv_fullness;
*ou_under_level_ptr = GV_MV_INP_status.inp_under_level;
*ou_over_level_ptr = GV_MV_INP_status.inp_over_level;
*ou_buf_size_ptr = GV_MV_INP_status.inp_buffer_size;
/* to mesure fifo fullness, we read VIDEO_FIFO_BFMO_CUR (read) in units
of bytes */
lv_fullness = MV_drv_video_fifo_bfmo_cur(); /* in bytes */
*ou_fullness_ptr = lv_fullness;
*ou_freespace_ptr = GV_MV_INP_status.inp_buffer_size - lv_fullness;
*ou_SDRAM_base_addr_ptr = GV_MV_INP_status.SDRAM_base_addr;
} /* End of MV_INP_get_status */
/*MPF=======================================================================*/
/*
FUNCTION NAME: MV_INP_set_format
PACKAGE: INP
SCOPE: PLATEFORM
DESCRIPTION:
Set the format of the data going into the video input buffer.
The format can be PES, MPEG1 or ES.
PRECONDITIONS:
None
POSTCONDITIONS:
None
CALLING SEQUENCE:
*/
void
MV_INP_set_format(
MV_INP_FORMAT in_format /* In: Video data format */
)
/*EMP=======================================================================*/
{
GV_MV_INP_status.inp_data_format = in_format;
MV_drv_set_video_format_selection((MV_DATA_FORMAT)in_format);
} /* End of MV_INP_set_format */
/*MPF=======================================================================*/
/*
FUNCTION NAME: MV_INP_fill_buffer
PACKAGE: INP
SCOPE: PLATEFORM
DESCRIPTION:
Put data into the video input buffer. The maximum number of MV_INP_DATA
to load must be specified. When the video input buffer is full before
this maximum number is loaded, no more data is loaded and a
MV_INP_BUFFER_FULL_EVENT is notify to application if it has enabled event.
The actual number of MV_INP_DATA loaded is returned.
NOTES:
data are written in the video fifo from current write ptr.
So, to use correctly this API, MSP must stop to send data before call
MV_INP_fill_buffer().
PRECONDITIONS:
MSP must stop to send data before call this API.
POSTCONDITIONS:
MSP must update its write_pointer with returned ou_data_loaded_ptr
parameter, if after it wants to restart to send data into video
fifo without lose the data we have written via CPU.
CALLING SEQUENCE:
*/
void
MV_INP_fill_buffer(
MV_INP_DATA * in_data_ptr, /* In: Pointer to video data */
MV_INP_SIZE in_data_size, /* In: Nr of MV_INP_DATA to load */
MV_INP_SIZE * ou_data_loaded_ptr /* Out: Nr of MV_INP_DATA loaded */
)
/*EMP=======================================================================*/
{
MV_REG_SIZE lv_writeptr_offset;
MV_REG_SIZE lv_fifo_start_adr;
MV_REG_SIZE lv_fifo_size;
MV_REG_SIZE lv_bfmo;
signed long lv_nr_to_load;
MV_INP_SIZE lv_load_count;
MV_BIT lv_fifo_disable;
MV_VIDEO_BUF_CTRL lv_buf_ctrl;
UInt32 lv_protection_level;
#ifdef DV_DEBUG
register unsigned long lv_info0;
register unsigned long lv_info1;
#endif
#ifdef _UNIX_
MV_REG_SIZE lv_bfmu;
#endif
tmosalDisableInterruptsNoSysCall(&lv_protection_level);
/* retrieval of video buffer synchronisation mode and fifo_disable */
lv_fifo_disable = MV_drv_video_fifo_disable();
lv_buf_ctrl = MV_drv_video_synchronisation_mode();
/* Set buffer to stop to allow new data (MSP must be stopped before) */
MV_drv_set_video_fifo_disable(MV_BIT_ON);
MV_drv_set_video_synchronisation_mode(MV_VIDEO_BUF_CTRL_STOP);
/* probably not sufficient because some data are read before stop */
lv_fifo_start_adr = MV_drv_video_fifo_start(); /* offset % beginning of SDRAM */
lv_fifo_size = MV_drv_video_fifo_size();
lv_bfmo = MV_drv_video_fifo_bfmo_cur(); /* in bytes */
#ifdef _UNIX_
lv_bfmu = MV_drv_video_fifo_bfmu_cur(); /* in bytes */
#endif
lv_writeptr_offset = (MV_drv_video_fifo_rdpt_cur() + lv_bfmo);
lv_writeptr_offset = lv_writeptr_offset % lv_fifo_size; /* for fifo wrap around */
/* Calculate the nr of MV_INP_DATA free in the input buffer */
lv_nr_to_load = GV_MV_INP_status.inp_buffer_size - lv_bfmo; /* in bytes */
/* Determine how many MV_INP_DATA to load */
if (lv_nr_to_load <= 0)
{
lv_nr_to_load = 0;
}
else if (lv_nr_to_load > in_data_size)
{
lv_nr_to_load = in_data_size;
}
/* acces SDRAM in bytes units */
/* Load the determined nr of MV_INP_DATA */
for ( lv_load_count = 0; lv_load_count < lv_nr_to_load; lv_load_count++)
{
*(unsigned char *)(GV_MV_INP_status.SDRAM_base_addr + lv_fifo_start_adr + lv_writeptr_offset) = *in_data_ptr;
lv_writeptr_offset++;
lv_writeptr_offset = lv_writeptr_offset % lv_fifo_size; /* for fifo wrap around */
in_data_ptr++;
}
/* Indicate the actual nr loaded */
*ou_data_loaded_ptr = lv_load_count;
#ifdef _UNIX_
/* update bfm's */
MV_drv_set_video_fifo_bfmo_cur(lv_bfmo + lv_load_count);
MV_drv_set_video_fifo_bfmu_cur(lv_bfmu + lv_load_count);
#else
/* update bfm */
MV_drv_set_video_fifo_nxt_value(lv_load_count);
MV_drv_set_video_fifo_bfm_dec(MV_BIT_OFF);
MV_drv_set_video_fifo_bfm_update(MV_BIT_ON);
#endif
if (lv_load_count < in_data_size)
{
#ifdef DV_DEBUG
lv_info0 = MV_drv_video_fifo_bfmo_cur();
lv_info1 = MV_drv_video_fifo_bfmu_cur();
#endif
DV_DBG_STORE_EVENT(IPVD_DBG_EV_VIDEO_FIFO_FULL,IPVD_DBG_MAJOR_BEHAVIOR_LEVEL,lv_info0,lv_info1,0,0);
if (GV_MV_INP_status.inp_event_enabled & MV_INP_BUFFER_FULL_EVENT)
{
/* Notify the application. */
GV_MV_INP_status.function_ptr(MV_INP_BUFFER_FULL_EVENT);
}
}
/* restore video buffer synchronisation mode and fifo_disable mode */
MV_drv_set_video_fifo_disable(lv_fifo_disable);
MV_drv_set_video_synchronisation_mode(lv_buf_ctrl);
tmosalEnableInterruptsNoSysCall(lv_protection_level);
} /* End of MV_INP_fill_buffer */
/*MPF=======================================================================*/
/*
FUNCTION NAME: MV_INP_fill_still_buffer
PACKAGE: INP
SCOPE: PLATEFORM
DESCRIPTION:
Put data into the still fifo. The maximum number of MV_INP_DATA
to load must be specified. When the still fifo is full before
this maximum number is loaded, no more data is loaded and a
MV_INP_STILL_FIFO_FULL_EVENT is notify to application if it has enabled event.
The actual number of MV_INP_DATA loaded is returned.
NOTES:
data can be written in the still fifo in 2 different ways :
- in_enabled = MV_INP_FROM_START_ENABLED means data will be written from
start address of the still fifo.
- in_enabled = MV_INP_FROM_START_DISABLED means data will be written from
a write_pointer which is maintain by SW in the still fifo.
Moreover, there is no wrap around on this still_fifo, that is to say when
write_pointer is at the end it stops to write data inside.
PRECONDITIONS:
None
POSTCONDITIONS:
None
CALLING SEQUENCE:
*/
void
MV_INP_fill_still_buffer(
MV_INP_FROM_START in_enabled,
MV_INP_DATA * in_data_ptr, /* In: Pointer to video data */
MV_INP_SIZE in_data_size, /* In: Nr of MV_INP_DATA to load */
MV_INP_SIZE * ou_data_loaded_ptr /* Out: Nr of MV_INP_DATA loaded */
)
/*EMP=======================================================================*/
{
MV_REG_SIZE lv_still_fifo_start_adr;
signed long lv_nr_to_load;
MV_INP_SIZE lv_load_count;
MV_INP_SIZE lv_still_fifo_wptr;
UInt32 lv_protection_level;
tmosalDisableInterruptsNoSysCall(&lv_protection_level);
lv_still_fifo_start_adr = MV_drv_still_fifo_start(); /* offset */
lv_still_fifo_wptr = GV_MV_DEC_status.dec_end_of_still_pict_wptr;
if (in_enabled == MV_INP_FROM_START_ENABLED)
{
lv_still_fifo_wptr = 0;
/* retrieve total size of the still fifo */
lv_nr_to_load = MV_drv_still_fifo_size(); /* in bytes */
/* Determine how many MV_INP_DATA to load */
if (lv_nr_to_load > in_data_size)
{
lv_nr_to_load = in_data_size;
}
/* acces SDRAM bytes */
/* Load the determined nr of MV_INP_DATA */
for ( lv_load_count = 0; lv_load_count < lv_nr_to_load; lv_load_count++)
{
*(unsigned char *)(GV_MV_INP_status.SDRAM_base_addr + lv_still_fifo_start_adr + lv_still_fifo_wptr) = *in_data_ptr;
lv_still_fifo_wptr++;
in_data_ptr++;
}
/* Indicate the actual nr loaded */
*ou_data_loaded_ptr = lv_load_count;
}
else
{
/* Calculate the nr of MV_INP_DATA free in the still fifo */
lv_nr_to_load = MV_drv_still_fifo_size() - lv_still_fifo_wptr; /* in bytes */
/* Determine how many MV_INP_DATA to load */
if (lv_nr_to_load > in_data_size)
{
lv_nr_to_load = in_data_size;
}
/* acces SDRAM bytes */
/* Load the determined nr of MV_INP_DATA */
for ( lv_load_count = 0; lv_load_count < lv_nr_to_load; lv_load_count++)
{
*(unsigned char *)(GV_MV_INP_status.SDRAM_base_addr + lv_still_fifo_start_adr + lv_still_fifo_wptr) = *in_data_ptr;
lv_still_fifo_wptr++;
in_data_ptr++;
}
/* Indicate the actual nr loaded */
*ou_data_loaded_ptr = lv_load_count;
}
/* Update write pointer of still fifo in global status variable, because
it is used by FBM_synchro_vs */
GV_MV_DEC_status.dec_end_of_still_pict_wptr = lv_still_fifo_wptr;
tmosalEnableInterruptsNoSysCall(lv_protection_level);
if (lv_load_count < in_data_size)
{
DV_DBG_STORE_EVENT( IPVD_DBG_EV_STILL_FIFO_FULL,IPVD_DBG_MAJOR_BEHAVIOR_LEVEL,0,0,0,0);
if (GV_MV_INP_status.inp_event_enabled & MV_INP_STILL_FIFO_FULL_EVENT)
{
/* Notify the application. */
GV_MV_INP_status.function_ptr(MV_INP_STILL_FIFO_FULL_EVENT);
}
}
} /* End of MV_INP_fill_still_buffer */
/*MPF=======================================================================*/
/*
FUNCTION NAME: MV_INP_install_notify
PACKAGE: INP
SCOPE: PLATEFORM
DESCRIPTION:
Install a notification callback function.
The function installed must be provided by the application.
When an event occurs and when the event has been enabled,
the notify function is called back with the occurring event as
parameter (in_event).
By default, the events are disabled.
With MV_INP_enable_notification(), they can be enabled.
PRECONDITIONS:
None
POSTCONDITIONS:
after call to this function, calling to MV_INP_enable_notification() or
MV_INP_disable_notification() is possible
CALLING SEQUENCE:
*/
void
MV_INP_install_notify(
void (*in_function_ptr)(MV_INP_EVENT in_event)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -