Beispiel #1
0
// blocking function
kal_int32 API IMGPROC_WaitComplete(MMDI_SCENERIO_ID owner)
{
	kal_uint32 flags;
	kal_status status;
#if (defined(DRV_IDP_6219_SERIES))
	ASSERT(owner == imgproc_dcb.owner);
	ASSERT(imgproc_dcb.mask != FILTER_NONE);
	status = kal_retrieve_eg_events(IMGPROC_Events,IMGPROC_EVENT ,KAL_AND_CONSUME,&flags,KAL_SUSPEND);
	ASSERT(status == KAL_SUCCESS);
#elif (defined(DRV_IDP_6228_SERIES))
	status = kal_retrieve_eg_events(IMGPROC_Events,IMGPROC_EVENT ,KAL_AND_CONSUME,&flags,KAL_SUSPEND);
	if (status!=KAL_SUCCESS)
		ASSERT(0);
#endif
	return NO_ERROR;
}
void IspWaitOneFrameDone(ISP_VSYNC_TIME_OUT_UNIT TimeOut)
{
    kal_uint32 EventGroup;
    if(TimeOut ==0 || TimeOut > IspVsyncTimeOut500MS)
        TimeOut = IspVsyncTimeOut500MS;
    
    _IspVsyncTimeOutReportStart(TimeOut);
    kal_set_eg_events(IspEventId,0,KAL_AND);
    kal_retrieve_eg_events(IspEventId,CAMERA_ISP_FRAME_READY_EVENT,KAL_OR_CONSUME,&EventGroup,KAL_SUSPEND);
    _IspVsyncTimeOutReportRelease();		
}
void L1Audio_FreeAudioID( uint16 aud_id )
{
   uint32 savedMask;
   uint32 retrieved_events;
   kal_retrieve_eg_events(l1audio.aud_events,(1<<aud_id),KAL_OR_CONSUME,&retrieved_events,0);
   ASSERT( (l1audio.runningState & (1 << aud_id)) == 0 );
   ASSERT( l1audio.id_flag & (1<<aud_id) );
   savedMask = SaveAndSetIRQMask();
   l1audio.id_flag &= ~(1<<aud_id);
   l1audio.retrieved_events &= ~(1<<aud_id);
   RestoreIRQMask( savedMask );
}
Beispiel #4
0
/*****************************************************************************
 * FUNCTION
 *  srv_cbm_lock
 * DESCRIPTION
 *  
 * PARAMETERS
 *  
 * RETURNS
 *  void
 *****************************************************************************/
void srv_cbm_lock(void)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
    kal_uint32 retrieved_events;
    
    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    kal_retrieve_eg_events(g_cbm_srv_cxt_ptr->nwk_srv.wait_event, 
        CBM_NWK_DISALLOW_EVENT, KAL_OR_CONSUME, 
        &retrieved_events, KAL_SUSPEND);
}
kal_bool IC_USB_POWER_ON(kal_uint8 iccd_index,kal_bool blocking)
{
	kal_uint8 index;	
	kal_uint32 event_group;
	

	if(g_UsbHostIccd[iccd_index].start_event_id == 0)
	{
		g_UsbHostIccd[iccd_index].start_event_id = kal_create_event_group("ICUSB_ENUMERATION"); 
	}
	else
	{
		/* Receive all events that may exist after previous detatch */
		kal_retrieve_eg_events(g_UsbHostIccd[iccd_index].start_event_id, EVENT_ICUSB_ENUMERATION_DONE|EVENT_ICUSB_ENUMERATION_FAIL, 
							KAL_OR_CONSUME, &event_group, KAL_NO_SUSPEND);
	}

//	for (index = USB_EXT_IP_NUM; index< USB_IP_NUM; index++)  // only enable ICUSB Drive
	for (index = 0; index< USB_IP_NUM; index++)
		USBD_Init(index);

	ICUSB_Drv_Init();
			
	if (blocking == KAL_TRUE)
	{
		kal_retrieve_eg_events(g_UsbHostIccd[iccd_index].start_event_id, EVENT_ICUSB_ENUMERATION_DONE|EVENT_ICUSB_ENUMERATION_FAIL, 
						KAL_OR_CONSUME, &event_group, KAL_SUSPEND);	
		if (event_group & EVENT_ICUSB_ENUMERATION_FAIL)
			return KAL_FALSE;
		else
			return KAL_TRUE;
	}
	else
	{
		return KAL_TRUE;
	}
}
kal_bool IC_USB_Reset_Card(kal_uint8 iccd_index)
{
	kal_uint32 event_group;
	
// SIM Driver reset level :  1. ICCD Reset   2. USB Reset
	USB_Host_ICCD_Reset_Card(iccd_index);

	kal_retrieve_eg_events(g_UsbHostIccd[iccd_index].start_event_id, EVENT_ICUSB_ENUMERATION_DONE|EVENT_ICUSB_ENUMERATION_FAIL, 
						KAL_OR_CONSUME, &event_group, KAL_SUSPEND);	

	if (event_group & EVENT_ICUSB_ENUMERATION_FAIL)
		return KAL_FALSE;
	else
		return KAL_TRUE;
}
/*************************************************************************
* FUNCTION
*   ec_task_main
*
* DESCRIPTION
*   This function implements xyz task's entry function
*
* PARAMETERS
*
* RETURNS
*   None
*
* GLOBALS AFFECTED
*
*************************************************************************/
void ec_task_main( task_entry_struct * task_entry_ptr )
{	
    kal_uint32 event_group;
    /*initialize function*/
    if (e_compass_sensor_data.event == NULL)
      e_compass_sensor_data.event = kal_create_event_group("ECEVT");
    e_compass_init();

    while (1) 
    {
        kal_retrieve_eg_events(e_compass_sensor_data.event,1,KAL_OR_CONSUME,&event_group,KAL_SUSPEND);
        e_compass_main_hdr();
    }

    /* Do component task's processing here */
}
Beispiel #8
0
/*****************************************************************************
 * FUNCTION
 *  jpim_evtdb_upddateEntry
 * DESCRIPTION
 *  This function updates an entry in the event database.
 *  The index (physical storage index) must refer to a valid entry
 *  in the database, otherwise an "invalid index" error is returned.
 *  If the sort index changes after the update, a new sort index is assigned
 * PARAMETERS
 *  entry           [IN/OUT]
 * RETURNS
 *  jpim_error_code_enum
 *****************************************************************************/
kal_int32 jpim_evtdb_upddateEntry_ext(mmi_evtdb_java_entry_struct *entry, kal_uint8 db_type, kal_int32 vm_id)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/

    kal_uint32 event_group;

    mmi_evtdb_java_set_entry_req_struct *p =
        (mmi_evtdb_java_set_entry_req_struct*) construct_local_para(
                                                sizeof(mmi_evtdb_java_set_entry_req_struct),
                                                TD_CTRL | TD_RESET);

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    JPIM_DEBUG(TRACE_GROUP_2, JPIM_EVTDB_UPDDATEENTRY);

    jpim_evtdb_adjustEntry(entry, db_type);

#ifdef JSR_75_PIM_EXTRA_ALARM_TIME_USER_DEFINE
	  jpim_evtdb_adjustAlarmTime(entry, db_type, KAL_TRUE);
#endif

    p->entry_ptr = entry;
    p->index = entry->handle;
    p->sort_type = MMI_EVTDB_SORT_BY_TIME;
    p->db_index = jpim_evtdb_transfer_tdl_db(db_type);

    jpim_evtdb_result = MMI_EVTDB_JAVA_ERROR;
    jpim_evtdb_state = JPIM_EVTDB_STATE_UPDATE_ENTRY;
    jpim_evtdb_index = 0xffff;
    jpim_evtdb_handle = 0xffff;

	if (jpim_check_vm_state(1, vm_id))
    {
        jpim_send_ilm(p, MSG_ID_MMI_EVTDB_JAVA_SET_ENTRY_REQ);
        kal_retrieve_eg_events(g_java_event_group_1, JAVA_EG_PIM_EVTDB_UPDATE_ENTRY, KAL_OR_CONSUME, &event_group, KAL_SUSPEND);
        entry->index = jpim_evtdb_index;
        entry->handle = jpim_evtdb_handle;
    }
    else
    {
        free_local_para((local_para_struct*) p);
    }
    return jpim_transfer_error_code(JPIM_EVENTDB, jpim_evtdb_result);
}
Beispiel #9
0
/*****************************************************************************
 * FUNCTION
 *  jpim_evtdb_getCount
 * DESCRIPTION
 *  The function retrieves the total count of event database entries.
 * PARAMETERS
 *  void
 * RETURNS
 *  0~n, -1 means database error
 *****************************************************************************/
kal_int32 jpim_evtdb_getCount(kal_uint8 db_type, kal_int32 vm_id)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
    kal_uint32 event_group;
    mmi_evtdb_java_get_entry_req_struct *p =
        (mmi_evtdb_java_get_entry_req_struct*) construct_local_para(
                                                sizeof(mmi_evtdb_java_get_entry_req_struct),
                                                TD_CTRL | TD_RESET);

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    JPIM_DEBUG(TRACE_GROUP_2, JPIM_EVTDB_GETCOUNT);

    p->count = 0;
    p->entry_ptr = NULL;
    p->index = 1;
    p->sort_type = MMI_EVTDB_SORT_BY_TIME;
	p->db_index = jpim_evtdb_transfer_tdl_db(db_type);

    /* set cmccphk_state before send message!! */
    jpim_evtdb_state = JPIM_EVTDB_STATE_GET_COUNT;
    jpim_evtdb_result = MMI_EVTDB_JAVA_ERROR;
    jpim_evtdb_count = -1;

	if (jpim_check_vm_state(0, vm_id))
    {
        jpim_send_ilm(p, MSG_ID_MMI_EVTDB_JAVA_GET_ENTRY_REQ);
        kal_retrieve_eg_events(g_java_event_group_1, JAVA_EG_PIM_EVTDB_GETCOUNT, KAL_OR_CONSUME, &event_group, KAL_SUSPEND);
    }
	  else
    {
        free_local_para((local_para_struct*) p);
    }

    if (jpim_evtdb_result != MMI_EVTDB_JAVA_SUCCESS)
    {
        return -1;
    }
    else
    {
        return jpim_evtdb_count;
    }
}
Beispiel #10
0
void IspWaitNVsync(ISP_VSYNC_TIME_OUT_UNIT TimeOut, kal_int32 Num)
{
    kal_uint32 EventGroup;
    if(TimeOut ==0 || TimeOut > IspVsyncTimeOut500MS)
        TimeOut = IspVsyncTimeOut500MS;

    if(Num == 0)
        return;

    while(Num>0)
    {
        _IspVsyncTimeOutReportStart(TimeOut);
        kal_set_eg_events(IspEventId,0,KAL_AND);
        kal_retrieve_eg_events(IspEventId,CAMERA_ISP_VD_READY_EVENT,KAL_OR_CONSUME,&EventGroup,KAL_SUSPEND);
        _IspVsyncTimeOutReportRelease();		
        Num--;
    }
}
Beispiel #11
0
/*****************************************************************************
 * FUNCTION
 *  jpim_evtdb_deleteEntry
 * DESCRIPTION
 *  This function deletes an entry from the event database.
 * PARAMETERS
 *  handle           [IN]
 * RETURNS
 *  jpim_error_code_enum
 *****************************************************************************/
kal_int32 jpim_evtdb_deleteEntry(kal_uint16 handle, kal_uint8 db_type, kal_int32 vm_id)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/

    kal_uint32 event_group;

    mmi_evtdb_java_set_entry_req_struct *p =
        (mmi_evtdb_java_set_entry_req_struct*) construct_local_para(
                                                sizeof(mmi_evtdb_java_set_entry_req_struct),
                                                TD_CTRL | TD_RESET);

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    JPIM_DEBUG(TRACE_GROUP_2, JPIM_EVTDB_DELETEENTRY);

    p->entry_ptr = NULL;
    p->index = handle;
    p->sort_type = MMI_EVTDB_SORT_BY_TIME;
    p->db_index = jpim_evtdb_transfer_tdl_db(db_type);

    jpim_evtdb_result = MMI_EVTDB_JAVA_ERROR;
    jpim_evtdb_state = JPIM_EVTDB_STATE_DELETE_ENTRY;

	if (jpim_check_vm_state(1, vm_id))
    {
        jpim_send_ilm(p, MSG_ID_MMI_EVTDB_JAVA_SET_ENTRY_REQ);
        kal_retrieve_eg_events(g_java_event_group_1, JAVA_EG_PIM_EVTDB_DELETE_ENTRY, KAL_OR_CONSUME, &event_group, KAL_SUSPEND);
    }
    else
    {
        free_local_para((local_para_struct*) p);
    }
    return jpim_transfer_error_code(JPIM_EVENTDB, jpim_evtdb_result);
}
Beispiel #12
0
/*************************************************************************
* FUNCTION
*  ccci_ipc_send_msg
*
* DESCRIPTION
*  This function is the internal api to send message
*
* PARAMETERS
*  ipc_task_id     -  
*  buffer_ptr      -
*  msg_size        -
*  wait_mode       -
*  message_to_head -
*
* RETURNS
*  status - success/fail
*
*************************************************************************/
kal_bool ccci_ipc_send_msg(kal_uint32 ipc_task_id, void *buffer_ptr, kal_uint16 msg_size,	kal_wait_mode wait_mode, kal_bool message_to_head)
{
    kal_uint32 i, j ;
    kal_uint32 retrieved_events = 0, orig_local_addr = 0 , orig_peer_addr = 0, update_buff_addr=0;
    kal_int32 result = CCCI_SUCCESS;
    ipc_ilm_t	*temp_ipc_ilm = (ipc_ilm_t *)buffer_ptr;
    ccci_io_request_t ior = {0};
	CCCI_BUFF_T *p_ccci_buff;
    kal_uint32 len = 0;
	
		
	ccci_ipc_trace(CCCI_IPC_TRACE, CCCI_IPC_MOD_DATA, CCCI_SEND_MSG_FUNC_TRA);	
    ccci_ipc_trace(CCCI_IPC_TRACE, CCCI_IPC_MOD_DATA, CCCI_SEND_MSG_TRA_ILM,
                temp_ipc_ilm, temp_ipc_ilm->src_mod_id, temp_ipc_ilm->dest_mod_id,
                temp_ipc_ilm->sap_id, temp_ipc_ilm->msg_id,
                temp_ipc_ilm->local_para_ptr, temp_ipc_ilm->peer_buff_ptr);
		
    /* get ext queue id from mapping table of task id - destnation*/
    for (i = 0; i < MAX_CCCI_IPC_TASKS; i++) 
    {
        if ( ccci_ipc_maptbl[i].task_id == ipc_task_id )
        	{
                    break;
        	}
    }
	
    /* get ext queue id from mapping table of task id - source*/
    for (j = 0; j < MAX_CCCI_IPC_TASKS; j++) 
    {
        if ( ccci_ipc_maptbl[j].task_id == temp_ipc_ilm->src_mod_id )
        	{
                    break;
        	}
    }
  
    /* check src mod id, if it's not defined in CCCI IPC, don't set used bit */
    if(j >= MAX_CCCI_IPC_TASKS)
    {
        ccci_ipc_trace(CCCI_IPC_ERR, CCCI_IPC_MOD_DATA, CCCI_SEND_MSG_FUNC_TASKID_ERROR, ipc_task_id, temp_ipc_ilm->src_mod_id);
        return KAL_FALSE;
    }
 
    /* check if the extquque id can not be found */
    if (i >= MAX_CCCI_IPC_TASKS) 
    {
	    ccci_ipc_trace(CCCI_IPC_ERR, CCCI_IPC_MOD_DATA, CCCI_SEND_MSG_FUNC_TASKID_ERROR, ipc_task_id, temp_ipc_ilm->src_mod_id);
        ((CCCI_IPC_ILM_T*)buffer_ptr)->used = 0;  
        return KAL_FALSE;
    }
  
        /* check if the extquque id is to AP */
    if ((ccci_ipc_maptbl[i].extq_id & AP_UINFY_ID_FLAG) == 0)
    {
        ccci_ipc_trace(CCCI_IPC_ERR, CCCI_IPC_MOD_DATA, CCCI_SEND_MSG_FUNC_DESTID_ERROR, ipc_task_id);
        ((CCCI_IPC_ILM_T*)buffer_ptr)->used = 0;   
	    return KAL_FALSE;
    }

    /* check if the ilm buffer is from ipc_msgsvc_allocate_ilm or not */
    if (buffer_ptr != &ccci_ipc_ilm_arr[j].ipc_ilm){
        ccci_ipc_trace(CCCI_IPC_ERR, CCCI_IPC_MOD_DATA, CCCI_SEND_MSG_FUNC_ILM_ERROR);
        return KAL_FALSE;
    }
		    
	len = sizeof(CCCI_BUFF_T) + sizeof(ipc_ilm_t);
    if (temp_ipc_ilm->local_para_ptr != NULL){          
        len+= temp_ipc_ilm->local_para_ptr->msg_len ;
    }
    if( temp_ipc_ilm->peer_buff_ptr != NULL){
        len+= sizeof(peer_buff_struct) 
            + temp_ipc_ilm->peer_buff_ptr->pdu_len 
            + temp_ipc_ilm->peer_buff_ptr->free_header_space 
            + temp_ipc_ilm->peer_buff_ptr->free_tail_space;
    }
	//assert if ilm size > CCCI_IPC_GPD size
	EXT_ASSERT(len < CCCI_IPC_GPD_SIZE, len, CCCI_IPC_GPD_SIZE, 0);

    /* Use critical section to protect ENTER */
    CCCI_IPC_ENTER_CRITICAL_SECTION
    if (KAL_TRUE == kal_query_systemInit()){ // polling mode
        ior.first_gpd = ccci_ipc_ch.p_polling_gpd;
        ior.last_gpd  = ccci_ipc_ch.p_polling_gpd;
    }
    else{
#ifdef __SDIOC_PULL_Q_ENH_DL__
        ior.num_gpd = 
#endif 
        qbmt_alloc_q_no_tail( 
                            CCCI_IPC_GPD_TYPE,            /* type */
                            1,                            /* buff_num */
                            (void **)(&ior.first_gpd),    /* pp_head */
                            (void **)(&ior.last_gpd));    /* pp_tail */
        if(ior.first_gpd == NULL){
            ccci_ipc_trace(CCCI_IPC_ERR, CCCI_IPC_MOD_DATA, CCCI_SEND_MSG_FUNC_ALLOC_GPD_ERROR);
            return KAL_FALSE;
        }
    }
    
	//initialize GPD CCCI_Header content
	p_ccci_buff = CCCIDEV_GET_QBM_DATAPTR(ior.first_gpd);
	p_ccci_buff->data[1] = (kal_uint32)len;
	p_ccci_buff->channel = (kal_uint32)ccci_ipc_ch.send_channel;
	p_ccci_buff->reserved = (kal_uint32)ccci_ipc_maptbl[i].extq_id;
    ccci_debug_add_seq(p_ccci_buff, CCCI_DEBUG_ASSERT_BIT); // add ccci seq
    QBM_DES_SET_DATALEN(ior.first_gpd, p_ccci_buff->data[1]);
    QBM_DES_SET_DATALEN(ior.first_gpd->p_data_tbd,  p_ccci_buff->data[1]);
    qbm_cal_set_checksum((kal_uint8 *)ior.first_gpd);
    qbm_cal_set_checksum((kal_uint8 *)ior.first_gpd->p_data_tbd);
    QBM_CACHE_FLUSH(ior.first_gpd, sizeof(qbm_gpd));
    QBM_CACHE_FLUSH(ior.first_gpd->p_data_tbd, sizeof(qbm_gpd));
    
    
    //copy ilm to GPD
    temp_ipc_ilm->src_mod_id =	ccci_ipc_maptbl[j].extq_id; 
    update_buff_addr = (kal_uint32)p_ccci_buff;
	update_buff_addr += sizeof(CCCI_BUFF_T);	
    CCCI_KAL_MSG_TO_AP_MSG(temp_ipc_ilm->msg_id, temp_ipc_ilm->msg_id);
	kal_mem_cpy((kal_uint8 *)update_buff_addr ,(kal_uint8 *)temp_ipc_ilm, sizeof(ipc_ilm_t));
    
	if (temp_ipc_ilm->local_para_ptr != NULL){			
			//copy loca_para_struct to GPD
			update_buff_addr += sizeof(ipc_ilm_t); //24 bytes
			orig_local_addr = update_buff_addr;
			kal_mem_cpy((kal_uint8 *)update_buff_addr,(kal_uint8 *)temp_ipc_ilm->local_para_ptr, temp_ipc_ilm->local_para_ptr->msg_len);
    }
    
    if( temp_ipc_ilm->peer_buff_ptr != NULL){
			//copy peer buff_struct to GPD
			if (temp_ipc_ilm->local_para_ptr != NULL){	 
			    update_buff_addr += temp_ipc_ilm->local_para_ptr->msg_len;//should be 4 bytes alignment?? 
			}
            else{
                update_buff_addr += sizeof(ipc_ilm_t); //24 bytes
            }
			orig_peer_addr = update_buff_addr;
			kal_mem_cpy((kal_uint8 *)update_buff_addr,(kal_uint8 *)temp_ipc_ilm->peer_buff_ptr, 
                          sizeof(peer_buff_struct) 
                          + temp_ipc_ilm->peer_buff_ptr->pdu_len 
                          + temp_ipc_ilm->peer_buff_ptr->free_header_space 
                          + temp_ipc_ilm->peer_buff_ptr->free_tail_space);
    }

    free_local_para(temp_ipc_ilm->local_para_ptr);
	temp_ipc_ilm->local_para_ptr = (local_para_struct *)orig_local_addr;//assign not NULL ptr to indicate there have content 
			
	free_peer_buff(temp_ipc_ilm->peer_buff_ptr);
	temp_ipc_ilm->peer_buff_ptr = (peer_buff_struct *)orig_peer_addr;//assign not NULL ptr to indicate there have content			

    QBM_CACHE_FLUSH(p_ccci_buff, len);
    
    if (KAL_TRUE == kal_query_systemInit()){ // polling mode
        result = ccci_polling_io(ccci_ipc_ch.send_channel, ccci_ipc_ch.p_polling_gpd, KAL_TRUE);
        CCCIDEV_RST_CCCI_COMM_GPD_LIST(ccci_ipc_ch.p_polling_gpd,ccci_ipc_ch.p_polling_gpd);
    }
    else{		
        result = ccci_ipc_ch.ccci_write_gpd(ccci_ipc_ch.send_channel, &ior, NULL);	
    	
        if (KAL_INFINITE_WAIT == wait_mode && CCCI_SUCCESS == result){		
    	    /* Wait for feedabck by retrieve event */
    	    kal_retrieve_eg_events(ccci_ipc_ch.event, 1 << i, KAL_AND_CONSUME,  &retrieved_events, KAL_SUSPEND);
        }
    }				
	/* Exit critical section */ 
	CCCI_IPC_EXIT_CRITICAL_SECTION
    ((CCCI_IPC_ILM_T*)buffer_ptr)->used = 0;  

    ccci_ipc_trace(CCCI_IPC_TRACE, CCCI_IPC_MOD_DATA, CCCI_SEND_MSG_TRA_CCCI,
                p_ccci_buff->data[0], p_ccci_buff->data[1], p_ccci_buff->channel, p_ccci_buff->reserved);
    ccci_ipc_trace(CCCI_IPC_TRACE, CCCI_IPC_MOD_DATA, CCCI_SEND_MSG_FUNC_PASS_TRA);	
		
	/* Finish */	
    if (result == CCCI_SUCCESS){
    	return KAL_TRUE;
    }
    else{
        return KAL_FALSE;
    }
        
}
Beispiel #13
0
/*****************************************************************************
 * FUNCTION
 *  media_player_do_recover
 * DESCRIPTION
 *  The function is to do recover
 * PARAMETERS
 *  void
 * RETURNS
 *  void
 *****************************************************************************/
media_error_t media_player_do_recover(media_player_t* mp, media_time_t key_frame_time)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
    media_player_cntx_struct* self = SELF(mp, media_player_cntx_struct, itf);
    VIDEO_DECODER_QUERY_I_FRM_T query;
    VIDEO_ERROR_TYPE_T error;
    kal_bool found;
    kal_uint64 decode_time, diff;
    media_data_t *node = NULL, *head = NULL, *found_node = NULL;
    VIDEO_COMPONENT_TYPE_T *dec_handle = self->decoder_handle;
    kal_uint32 event_group, format_index;
    media_codec_type_t codec_type;
    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    kal_trace(TRACE_FUNC, VID_TRC_MEDIA_PLAYER_JUMP_TO_I_FRAME, self->state, (kal_uint32)key_frame_time);

    if (self->state == MPLY_STATE_CLOSED ||
            self->state == MPLY_STATE_OPENED ||
            self->state == MPLY_STATE_PREPARED ||
            self->state == MPLY_STATE_SEEKING ||
            self->state == MPLY_STATE_SEEK_DONE)
    {
        return MED_E_WRONG_STATE;
    }

    ASSERT(self->vid_stream_index != MEDIA_PLAYER_INVALID_INDEX);
    kal_take_mutex(media_player_mutex);
    /**************************************************
     ** Jump to I frame in file
     **************************************************/
    if (key_frame_time > 0)
    {
        /* Flush frame */
        error = dec_handle->pfnSetParameter(VIDEO_PARAM_FLUSH_FRM, NULL);
        ASSERT(error == VIDEO_ERROR_NONE ||
               error == VIDEO_ERROR_NO_FRAME_TO_FLUSH);

        /* Wait until flush frame is done */
        if (error == VIDEO_ERROR_NONE)
        {
            /* release mutex for decoder to release frame */
            kal_give_mutex(media_player_mutex);
            MPLY_SET_FLAG(MPLY_FLAG_WAIT_FLUSH_FRAME);
            kal_retrieve_eg_events(media_player_comp_eg, MEDIA_PLAYER_EG_DECODER_FLUSH_FRAME_DONE, KAL_OR_CONSUME, &event_group, KAL_SUSPEND);
            MPLY_UNSET_FLAG(MPLY_FLAG_WAIT_FLUSH_FRAME);
            kal_take_mutex(media_player_mutex);
        }

        /* Flush frame in queue */
        media_player_reset_queue(mp, MPLY_QUEUE_VIDEO_WRITTEN);
        media_player_reset_queue(mp, MPLY_QUEUE_VIDEO);
        self->vid_life_cycle_id ++;
        self->vid_queue_num = 0;
        MPLY_UNSET_FLAG(MPLY_FLAG_VID_BUFF_FULL);

        /* Enable skip non-I frame */
        MPLY_SET_FLAG(MPLY_FLAG_SKIP_NON_I_FRAME);
        self->key_frame_time = key_frame_time;
        goto finish;
    }

    /**************************************************
     ** Jump to I frame in queue
     **************************************************/
    codec_type = self->vid_stream.dec_config.codec;
    format_index = mpl_get_vid_custom_format_index(codec_type);

    diff = mply_custom_get_cust(format_index, 2);
    ASSERT(diff > 0);
    error = self->decoder_handle->pfnGetParameter(VIDEO_PARAM_QUERY_DECODE_TIME, &decode_time);
    decode_time = MEDIA_PLAYER_COMPTIME_TO_TIME(decode_time);
    found = KAL_FALSE;

    /* Search I frame with max T from queue's head */
    if (self->video_queue)
    {
        node = head = self->video_queue->next;
        do
        {
            if ((node->flags & MEDIA_DATA_FLAG_KEY_FRAME) &&
                    (node->display_time <= decode_time + diff))
            {
                found = KAL_TRUE;
                found_node = node;
            }
            node = node->next;
        }
        while (node != head);
    }

    kal_trace(TRACE_FUNC, VID_TRC_MEDIA_PLAYER_JUMP_INFO,
              found, (kal_uint32)decode_time, (kal_uint32)diff);

    /* If I frame is found, drop P, B frame */
    if (found && found_node != NULL)
    {
        /* Flush all the frame in decoder */
        error = dec_handle->pfnSetParameter(VIDEO_PARAM_FLUSH_FRM, NULL);
        ASSERT(error == VIDEO_ERROR_NONE ||
               error == VIDEO_ERROR_NO_FRAME_TO_FLUSH);

        /* Wait until flush frame is done */
        if (error == VIDEO_ERROR_NONE)
        {
            kal_give_mutex(media_player_mutex);
            MPLY_SET_FLAG(MPLY_FLAG_WAIT_FLUSH_FRAME);
            kal_retrieve_eg_events(media_player_comp_eg, MEDIA_PLAYER_EG_DECODER_FLUSH_FRAME_DONE, KAL_OR_CONSUME, &event_group, KAL_SUSPEND);
            MPLY_UNSET_FLAG(MPLY_FLAG_WAIT_FLUSH_FRAME);
            kal_take_mutex(media_player_mutex);
        }

        /* Flush frame in queue */
        media_player_reset_queue(mp, MPLY_QUEUE_VIDEO_WRITTEN);
        self->vid_life_cycle_id ++;
        self->vid_queue_num = 0;
        MPLY_UNSET_FLAG(MPLY_FLAG_VID_BUFF_FULL);

        /* Flush P, B frame in queue */
        head = self->video_queue->next;
        while(head != found_node)
        {
            media_player_remove_from_queue(&self->video_queue, head);
            head->release(head);
            self->vid_queue_num --;

            head = self->video_queue->next;
        }
        goto finish;
    }

    /**************************************************
     ** Jump to I frame in decoder
     **************************************************/

    /* Check if decoder input queue has I frame */
    query.u8TimeDifference = MEDIA_PLAYER_TIME_TO_COMPTIME(diff);
    query.fgRet = KAL_FALSE;

    error = self->decoder_handle->pfnGetParameter(VIDEO_PARAM_IS_I_FRM_IN_QUEUE, &query);
    ASSERT(error == VIDEO_ERROR_NONE);

    if (query.fgRet)
    {
        error = self->decoder_handle->pfnSetParameter(VIDEO_PARAM_FLUSH_FRM_BEFORE_I, NULL);
        goto finish;
    }

finish:
    mpl_start_timer(
        MPL_PLAYER_RECOVER_TIMER, MPLY_RESET_RECOVER_ELAPSE,
        media_player_reset_recover, self);

    kal_give_mutex(media_player_mutex);
    return MED_S_OK;
}
Beispiel #14
0
uint32 L1Audio_GetEventGroup( void )
{
   uint32 retrieved_events;
   kal_retrieve_eg_events( l1audio.aud_events, 0xFFFF, KAL_OR_CONSUME, &retrieved_events, KAL_SUSPEND );
   return retrieved_events;
}
Beispiel #15
0
/* ------------------------------------------------------------------------------ */
void L1Audio_Task(unsigned argc, void *argv)
{
   uint32 retrieved_events;
   uint32 I;
   uint16 tempID;

   l1audio.aud_events = kal_create_event_group("L1Audio");
   l1audio.hisr = kal_init_hisr(L1AUDIO_HISR);
   
   GET_SLEEP_HANDLE();
   
#if ( defined( __CENTRALIZED_SLEEP_MANAGER__ ) && defined(MTK_SLEEP_ENABLE) && !defined(__AUDIO_POWERON_RESET_DSP__) )
   l1audio.md2g_pdn_handle = L1D_MD2G_PWD_GetHandle();
   l1audio.l1sm_handle = L1SM_IntGetHandle();
#endif

   l1audio.runningState        = 0;
   l1audio.disallowSleepState  = 0;
   l1audio.dsp_slow_idle_counter = 0;
   l1audio.event_flag   = 0;
   l1audio.id_flag      = 0;
   l1audio.media_flag   = 0;
   l1audio.postHisrHandler = (L1Audio_EventHandler)0;
   l1audio.sema = kal_create_sem( "Aud_Sema", 1 );  

   l1audio.hisrMagicFlag = 0;
   for( I = 0; I < MAX_HISR_HANDLER; I++ )
      l1audio.hisrMagicNo[I] = 0;

   tempID = L1Audio_GetAudioID();
   L1Audio_SetFlag(tempID);

   DSP_DynamicDownload_Init();

#ifndef  L1D_TEST
   /// Dynamic download for A/V sync
#if defined( DSP_WT_SYN ) && !defined(__AUDIO_COMPONENT_SUPPORT__)
   DSP_DynamicDownload( DDID_WAVETABLE );
#endif
#endif
   AM_Init();

#if APM_SUPPORT
   APM_Init();
#endif

   /// AFE_Init will invoke L1Audio_GetAudioID
   /// and expect to get the id 0 to make sure
   /// it has the highest priority in the event group
   AFE_Init();

#if !defined(__SMART_PHONE_MODEM__) && !defined(__L1_STANDALONE__) && !defined( MED_MODEM )   
   AVsync_Init();
#endif   
   
#if defined(__AUDIO_POWERON_RESET_DSP__)
   {
      uint32 _savedMask;
      _savedMask = SaveAndSetIRQMask();
      AFE_Init_status(KAL_TRUE);
      AFE_RegisterBackup();
      RestoreIRQMask(_savedMask);
   }
#endif

   L1SP_Init();

   ktInit( L1Audio_GetAudioID() );
   toneInit( L1Audio_GetAudioID() );
   mediaInit( L1Audio_GetAudioID() );
#if defined(VR_CYBERON)
   vrsdInit();
#elif defined(VRSI_CYBERON)
   vrsiInit();
#endif

   toneLoopbackRecInit();

#if ( defined(__BT_A2DP_PROFILE__) || defined(SBC_UNIT_TEST) ) //&& !(APM_SUPPORT)
   SBC_Init();
#endif

#if defined(__BES_TS_SUPPORT__)
   AudioPP_TS_Init();
#endif

#ifdef __CTM_SUPPORT__
   l1ctm_init();
#endif

#ifdef __TWOMICNR_SUPPORT__
   Two_Mic_NR_chip_Init();	
#endif


#if VMI_SUPPORT || defined(VORTP_UNIT_TEST)
   VMI_Init();
#endif

#if VORTP_SUPPORT || defined(VORTP_UNIT_TEST)
   VoRTP_Init();
#endif

#if defined(CYBERON_DIC_TTS) || defined(IFLY_TTS) || defined(SINOVOICE_TTS)
   ttsInit();
#endif
#if defined( DSP_WT_SYN ) && !defined(__AUDIO_COMPONENT_SUPPORT__)
   DSPSYN_HW_Init();
#endif

#if defined( __I2S_INPUT_MODE_SUPPORT__ )
   I2S_init();
#endif

#if defined(__VOICE_CHANGER_SUPPORT__)
   VCHG_Initialize();
#endif

#if defined(__AUDIO_COMPONENT_SUPPORT__) && !defined(__L1_STANDALONE__) && !defined(MED_MODEM)
   // KH : for audio component
   ACU_Init();
#endif

#if defined(__CVSD_CODEC_SUPPORT__) 
    {
        extern void BT_SCO_Init(void);
        BT_SCO_Init();
    }
#endif

   memset( &(l1audio.debug_info), 0, sizeof(l1audio.debug_info) );
   AFE_TurnOnFIR( L1SP_SPEECH );
   AFE_TurnOnFIR( L1SP_VOICE );

   L1Audio_ClearFlag(tempID);
   L1Audio_FreeAudioID(tempID);

   l1audio.isInitiated = KAL_TRUE;

   while( 1 ) {
#if VERIFY_DATA_TO_DSP
      VERIFY_DATA_TO_DSP_SAVE_DATA();
#endif
      kal_retrieve_eg_events(l1audio.aud_events,0xFFFF,KAL_OR_CONSUME,&retrieved_events,KAL_SUSPEND);
      l1audio.retrieved_events = retrieved_events;
      l1audio.events_l1FN = L1I_GetTimeStamp();
      for( I = 0; I < MAX_AUDIO_FUNCTIONS; I++ ) {
         if ( l1audio.retrieved_events & (1<<I) ) {
            l1audio.evHandler[I]( l1audio.evData[I] );
         }
      }
      //if( (l1audio.runningState & l1audio.disallowSleepState) == 0 )
      if( l1audio.runningState == 0 )
         SLEEP_UNLOCK();
   }
}
Beispiel #16
0
/*************************************************************************
* FUNCTION
*  mdci_read
*
* DESCRIPTION
*  This function reads data through either mailbox channel or stream
*  channel.
*
* PARAMETERS
*  channel    -    logical channel
*  buff       -    pointer to channel buffer
*
* RETURNS
*  MDIF error code.
*
*************************************************************************/
kal_int32 mdci_read(MDCI_CHANNEL_T channel, MDCI_BUFF_T *buff)
{
    kal_uint32 owner, mask, ret, event;
    kal_char event_name[20];


#ifdef __IVP__
    dbg_print("Error.... can not use mdci_read in IVP\n\r");
    while(1);
#endif

    /* check if a LISR is running */
    if (kal_if_lisr())
        return MDCI_IN_LISR;

    /* check parameters */
    if (channel >= MDCI_MAX_CHANNEL)
        return MDCI_INVALID_PARAM;
    if (buff == NULL)
        return MDCI_INVALID_PARAM;

    /* get the current task */
    owner = (kal_uint32)kal_get_current_thread_ID();

    /* check owner */
    if (mdci_ctrl_pool[channel].owner != owner && mdci_is_chanel_need_check_owner(channel)) {
        return MDCI_NOT_OWNER;
    }

    /* create an event for the first use */ 
    if (mdci_ctrl_pool[channel].event == NULL) {
        sprintf(event_name, "MDIF%d event", channel);
        mdci_ctrl_pool[channel].event = kal_create_event_group(event_name);
        if (mdci_ctrl_pool[channel].event == NULL)
            ASSERT(0);
    }

    /* check state */
    ret = MDCI_SUCCESS;
    mask = SaveAndSetIRQMask();
    if (mdci_ctrl_pool[channel].state != MDCI_IDLE) {
        ret = MDCI_IN_USE;
    } else {
        /* set ACTIVE_WRITE */
        mdci_ctrl_pool[channel].state = MDCI_ACTIVE_READ;
    }
    RestoreIRQMask(mask);
    if (ret != MDCI_SUCCESS)
        return ret;

#ifndef __IVP__
    /* wait for the event */
    kal_retrieve_eg_events(mdci_ctrl_pool[channel].event, 1, KAL_OR_CONSUME, &event, KAL_SUSPEND);
#endif    
    if (event != 1) {
        ASSERT(0);
    }

    /* read channel buffer */
    memcpy(buff, &(mdci_ctrl_pool[channel].buff), sizeof(MDCI_BUFF_T));

    /* set ACTIVE_IDLE */
    mdci_ctrl_pool[channel].state = MDCI_IDLE;

    return MDCI_SUCCESS;
}
Beispiel #17
0
/*****************************************************************************
 * FUNCTION
 *  jpim_evtdb_fetchByIndex
 * DESCRIPTION
 *  This function retrieves an entry from the event database. The data is filled into "entry" parameter.
 * PARAMETERS
 *  entry           [OUT]
 *  index           [IN]        0~n-1
 *  sort_type       [IN]        jpim_evtdb_sort_enum
 *  db_type         [IN]        jpim_evtdb_db_enum
 * RETURNS
 *  jpim_error_code_enum
 *****************************************************************************/
kal_int32 jpim_evtdb_fetchByIndex(mmi_evtdb_java_entry_struct *entry,
									   kal_uint16 index,
									   kal_uint8 sort_type,
									   kal_uint8 db_type,
									   kal_int32 vm_id)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
    kal_uint32 event_group;

    mmi_evtdb_java_get_entry_req_struct *p =
        (mmi_evtdb_java_get_entry_req_struct*) construct_local_para(
                                                sizeof(mmi_evtdb_java_get_entry_req_struct),
                                                TD_CTRL | TD_RESET);

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/

    p->entry_ptr = entry;
    p->index = index;
    p->sort_type = MMI_EVTDB_SORT_BY_TIME;
    p->db_index = jpim_evtdb_transfer_tdl_db(db_type);
    p->count = 1;

    jpim_evtdb_result = MMI_EVTDB_JAVA_ERROR;
    jpim_evtdb_state = JPIM_EVTDB_STATE_GET_ENTRY;

	if (jpim_check_vm_state(0, vm_id))
    {
        jpim_send_ilm(p, MSG_ID_MMI_EVTDB_JAVA_GET_ENTRY_REQ);
        kal_retrieve_eg_events(g_java_event_group_1, JAVA_EG_PIM_EVTDB_FETCH_INDEX, KAL_OR_CONSUME, &event_group, KAL_SUSPEND);
        JPIM_DEBUG(TRACE_GROUP_2, JPIM_EVTDB_FETCHBYINDEX, entry->handle, entry->index);
    }
    else
    {
        free_local_para((local_para_struct*) p);
    }


    if(jpim_transfer_error_code(JPIM_EVENTDB, jpim_evtdb_result) == JPIM_SUCCESS)
    {
#ifdef JSR_75_PIM_EXTRA_ALARM_TIME_USER_DEFINE
        jpim_evtdb_adjustAlarmTime(entry, db_type, KAL_FALSE);
#endif
#ifndef __COSMOS_MMI_PACKAGE__
        if (db_type == JPIM_EVTDB_REMINDER || db_type == JPIM_EVTDB_MEETING || db_type == JPIM_EVTDB_COURSE ||
		    db_type == JPIM_EVTDB_DATE || db_type == JPIM_EVTDB_CALL|| db_type == JPIM_EVTDB_ANNIVERSARY || 
		    db_type == JPIM_EVTDB_ALL)
#else
        if (db_type == JPIM_EVTDB_PERSONAL || db_type == JPIM_EVTDB_MEETING || db_type == JPIM_EVTDB_SPECIALDAY ||
		    db_type == JPIM_EVTDB_BIRTHDAY || db_type == JPIM_EVTDB_OTHERS || db_type == JPIM_EVTDB_ALL)
#endif
        {
            if (applib_dt_compare_time(&(entry->endTime), &(entry->startTime), NULL) == DT_TIME_LESS)
            {
                memcpy(&(entry->endTime), &(entry->startTime), sizeof(applib_time_struct));
            }
        }
        if (db_type == JPIM_EVTDB_TASK)
        {
#ifdef JSR_75_PIM_EXTRA_TODO
		    if (entry->status == SRV_TDL_STATUS_UNDONE)
		    {
                entry->complete_time.nYear = 0;
                entry->complete_time.nMonth = 0;
                entry->complete_time.nDay = 0;
    }
#endif
		}
		
    }

    return jpim_transfer_error_code(JPIM_EVENTDB, jpim_evtdb_result);
}
Beispiel #18
0
HIF_RESULT hif_dma_read_internal(HIF_HANDLE handle, HIF_TYPE type, kal_uint32 addr, kal_uint32 size, HIF_CALLBACK fCB)
{
    HIF_RESULT result = HIF_RESULT_OK;
    HIF_INTERNAL_HANDLE_T* pHandle = (HIF_INTERNAL_HANDLE_T*) handle;
    kal_uint32 retrieved_events;
    // Enable HIF interrupt.
    ENABLE_HIF_INTR(pHandle->engine_id);
    pHandle->DMA_BUSY = KAL_TRUE;
    #ifdef MTK_SLEEP_ENABLE
    L1SM_SleepDisable(hif_sleepMode_handle[pHandle->engine_id]);//unlock MD sleep mode
    #endif
    
    if (fCB == NULL)
    {
      if(!(kal_if_lisr()||kal_if_hisr()))
        {
          //Clear the evnet for pHandle->engine_id HIF for task level
          kal_set_eg_events(hif_events, ~(1 << pHandle->engine_id), KAL_AND);
        }
      else 
      ASSERT(0); //HIF DMA blocking mode is not allowed in LISR or HISR
    }
    // Setup HIF.
    //SET_HIF_BUS_WIDTH(pHandle->engine_id, pHandle->config.hif_bus_width);
    SET_HIF_READ(pHandle->engine_id);
    if(type == HIF_TYPE_A0H_DMA)
    {
      SET_HIF_A0_HIGH(pHandle->engine_id);
    }
    else if(type == HIF_TYPE_A0L_DMA)
    {	
      SET_HIF_A0_LOW(pHandle->engine_id);
    }
    SET_HIF_DAMOUNT(pHandle->engine_id, size);
/*              // Set DMA address.
    PDMA_SET_BUF_ADDR(pHandle->engine_id, addr);
    PDMA_SET_RW_DIRECTION(pHandle->engine_id, 1); // 1:read; 0: write
    PDMA_SET_BUF_LEN(pHandle->engine_id, size);
    PDMA_SET_BURST_LEN(pHandle->engine_id, 7);

    PDMA_START(pHandle->engine_id); //Start DMA
*/
    //dma config
    SLA_CustomLogging("HDM",1);//set for debug
    #if (defined(MT6752) && !defined(__ANDROID_MODEM__))
    hif_dma_menu[pHandle->engine_id].addr = addr + 0x80000000;
    #else
    hif_dma_menu[pHandle->engine_id].addr = addr;
    #endif
    hif_dma_input[pHandle->engine_id].count  = (pHandle->config.hif_bus_width == 16) ? (size >> 1) : size;
    hif_dma_input[pHandle->engine_id].type = DMA_HWRX;
    hif_dma_input[pHandle->engine_id].size = (pHandle->config.hif_bus_width == 16) ? DMA_SHORT : DMA_BYTE;
    hif_dma_input[pHandle->engine_id].callback = NULL;
    hif_dma_input[pHandle->engine_id].menu = (void*) &hif_dma_menu[pHandle->engine_id];
    DMA_Config(hif_sysdma_id[pHandle->engine_id], &hif_dma_input[pHandle->engine_id], KAL_TRUE);

    // Set fCB as HIF interrupt callback.
    hif_cb[pHandle->engine_id] = fCB;

    // Start HIF
    START_HIF(pHandle->engine_id);
    if (fCB == NULL)
    {
      if(!(kal_if_lisr()||kal_if_hisr()))
      {
        kal_retrieve_eg_events(hif_events, (1<<pHandle->engine_id), KAL_OR_CONSUME, &retrieved_events, KAL_SUSPEND);
            	      pHandle->DMA_BUSY = KAL_FALSE;
      }
      else 
        ASSERT(0); //HIF DMA blocking mode is not allowed in LISR or HISR
    }	
   return result;
}