kal_bool USB_Ms_Read_Write(USB_MS_DIRECTION direct, kal_uint8 LUN, void *data, kal_uint32 LBA, kal_uint16 sec_len)
{
	kal_bool ret;
	kal_uint32 time;
	kal_uint32 performance;
	
	USB_Ms_Check_CURRENT_DRV(LUN);	

	if (USBMS_DISKDRV_LBA_INFO[LUN].LastBA == 0)
	{
		USBMS_DISKDRV_API[CURRENT_DRV][LUN]->usbms_read_capacity(
					&USBMS_DISKDRV_LBA_INFO[LUN].LastBA, 
					&USBMS_DISKDRV_LBA_INFO[LUN].BlkLen);
	}
	
	if ( (LBA+sec_len-1) > USBMS_DISKDRV_LBA_INFO[LUN].LastBA)
		return KAL_FALSE;
		
	time = drv_get_current_time();
	if (direct == USB_MS_WRITE)
		ret = USBMS_DISKDRV_API[CURRENT_DRV][LUN]->usbms_write(data, LBA, sec_len);
	else
		ret = USBMS_DISKDRV_API[CURRENT_DRV][LUN]->usbms_read(data, LBA, sec_len);
	time = drv_get_current_time()-time;
	if(time > 0)
	{
		performance = sec_len*32*1024/2/time;
		if (direct == USB_MS_WRITE)
			drv_trace1(TRACE_FUNC, (kal_uint32)USBMS_WRITE_PERFORMANCE, performance);
		else
			drv_trace1(TRACE_FUNC, (kal_uint32)USBMS_READ_PERFORMANCE, performance);
	}
	return ret;
}
Esempio n. 2
0
/* clear tx buffer */
static void USB2UART_ClrTxBuffer(UART_PORT port, module_type ownerid)
{
    kal_uint32 savedMask;


#ifndef  __PRODUCTION_RELEASE__
    if(ownerid != USB2UARTPort.ownerid)
    {
        EXT_ASSERT( 0, (kal_uint32) ownerid, USB2UARTPort.ownerid, 0);
    }
#endif

    drv_trace0(TRACE_FUNC, USBACM_CLEAR_TX_BUF);
//	kal_prompt_trace(MOD_USB, "clrTx\n");

    /* stop dma channel if current status is CDC ACM*/
    if ( (gUsbDevice.device_type == USB_CDC_ACM) && (USB2UARTPort.initialized == KAL_TRUE)
            &&(gUsbDevice.nDevState==DEVSTATE_CONFIG))
    {
        USB_Stop_DMA_Channel(g_UsbACM.txpipe->byEP, USB_TX_EP_TYPE);
    }

    savedMask = SaveAndSetIRQMask();
    USB2UARTPort.Tx_Buffer.Write = 0;
    USB2UARTPort.Tx_Buffer.Read = 0;
    g_UsbACM.send_Txilm = KAL_TRUE;
    RestoreIRQMask(savedMask);

    drv_trace1(TRACE_FUNC, USBACM_CLEAR_TX_BUF_READY_TO_READ_FLAG, ownerid);
//	kal_prompt_trace(MOD_USB, "clr RDY W %d", ownerid);

}
VSD_CODEC_API_T* GetVsdCodecApi(VSD_CODEC_T eVsdCodec)
{
    VSD_CODEC_API_T *prApi = NULL;

    drv_trace1(TRACE_GROUP_10, VSD_CODEC_TYPE, eVsdCodec);

    switch (eVsdCodec)
    {
    case VSD_CODEC_UTF8:
    case VSD_CODEC_SSA_ASS:
        prApi = GetVsdSsaCodecApi(eVsdCodec);
        break;

#if 0
/* under construction !*/
/* under construction !*/
/* under construction !*/
#endif  // 0  // Not supported for now.

    default:
        ASSERT(0);
        break;
    }

    return prApi;
}
Esempio n. 4
0
kal_bool bmt_PhyCheck_VCharger(BATPHYStruct *BATPHYS)
{
	static kal_uint8 over_charger_count = 0;
	static kal_uint8 low_charger_count = 0;
	
#if defined(DRV_BMT_HIGH_VCHG_ADAPTIVE_CHARGE_CURRENT_SUPPORT)
	if ( (BATPHYS->VCHARGER > bmt_charging_para.HIGH_VCHG_TABLE[VCHG_VOL_LEVEL - 1][0]) )
#else
	if ( (BATPHYS->VCHARGER > bmt_charging_para.VCHARGER_HIGH) )
#endif // End of #if defined(DRV_BMT_HIGH_VCHG_ADAPTIVE_CHARGE_CURRENT_SUPPORT)   
	{
		over_charger_count ++;
		drv_trace1(TRACE_ERROR, BMT_PHY_CHECK_OVER_CHARGER_COUNT_TRC, over_charger_count);	
	}
	else
	{
		over_charger_count = 0;
	}
	
	if ( (BATPHYS->VCHARGER < bmt_charging_para.VCHARGER_LOW) )
	{
		low_charger_count++;
	}
	else
	{			
		low_charger_count = 0;
	}
	
	if ( (low_charger_count > VCHARGER_LOW_CHECK_COUNT) || (over_charger_count > VCHARGER_OVER_CHECK_COUNT) )
	{
		low_charger_count = 0;
		return KAL_FALSE;
	}
	return KAL_TRUE;
}
Esempio n. 5
0
kal_bool bmt_PhyCheck_LowCurrent(BATPHYStruct *BATPHYS)
{
	static kal_uint8 low_current_count=0;
	if (BMT.pmictrl_state != PMIC_CHARGEOFF)
	{
		if ( (BMT.bat_state == CHR_FAST)) 
		{
			if(BATPHYS->ICHARGE < bmt_charging_para.ICHARGE_ON_LOW)
			{
				low_current_count++;
				drv_trace1(TRACE_GROUP_6, BMT_PHY_CHECK_LOW_CURRENT_COUNT_TRC, low_current_count);	
			}
			else
			{				
				low_current_count = 0;
			}
			
			if (low_current_count > LOW_CURRENT_CHECK_COUNT)
			{
				low_current_count = 0;
				return KAL_FALSE;
			}
		}
		else
		{
			low_current_count = 0;
		}
	}
	return KAL_TRUE;
}
Esempio n. 6
0
// Return the calculated temp value of battery temperature ==> 23000 means 23C
static void get_bat_temp(BATPHYStruct *BATPHYS)
{
	if (bmt_charging_para.bmt_check_temp)
	{
		BATPHYS->BATTMP = bmt_change_VBatTmp_To_BatTmp(BMT_VOL_RESULT[BMT_ADC_VBATTMP]);
		drv_trace1(TRACE_INFO, BMT_BATTMP_TRC, BATPHYS->BATTMP);
	}
}
void MPEG4EncCallbackYUVDone(kal_uint8* pu1Ptr)
{
    ASSERT(rMPEG4HWEncCtrl.pfYUVDone);

    drv_trace1(TRACE_GROUP_10, MPEG4HW_CALLBACK_YUV_DONE, (kal_uint32)(pu1Ptr));

    rMPEG4HWEncCtrl.pfYUVDone(pu1Ptr);
}
void MPEG4EncCallbackEncPause(kal_uint8* pu1Ptr)
{
    ASSERT(rMPEG4HWEncCtrl.pfEncPause);

    drv_trace1(TRACE_GROUP_10, MPEG4HW_CALLBACK_ENC_PAUSE, (kal_uint32)(pu1Ptr));

    rMPEG4HWEncCtrl.pfEncPause(pu1Ptr);
}
static void VideoH264DecReturnBitstream(H264SwDecReturnBs *pBs)
{
    if (rH264SwCtrl.pfnReturnBitstream)
    {
        drv_trace1(TRACE_GROUP_10,OPEN_API_RETURNBSBUFFER, (kal_uint32)pBs->pBsAddr);
        rH264SwCtrl.pfnReturnBitstream((kal_uint32)pBs->pBsAddr);
    }
    return;
}
Esempio n. 10
0
void bmt_stop_timer(bmt_timer_enum timer_id)
{
   evshed_cancel_event(bmt_event_scheduler_ptr, &bmt_event_scheduler_id[timer_id]);
   #if !defined(BMT_CHARGING_DISABLE)
   if(BMT_CHARGE_TIMEOUT_TIMER == timer_id)
   {
	   drv_trace1(TRACE_GROUP_10, BMT_SAFETY_TIMER_STOP_TRC, bmt_total_charge_time);
   }
   #endif
}
Esempio n. 11
0
// The return unit is mA ==> 1000 means 1A
static void get_isense(BATPHYStruct *BATPHYS)
{
#ifndef __BMT_NO_ISENSE_RESISTOR__
	DCL_UINT32 TransformVolt;

	if(BMT.pmictrl_state == PMIC_CHARGEOFF)
	{	
		ISense_Offset = BMT_VOL_RESULT[BMT_ADC_VISENSE] - BMT_VOL_RESULT[BMT_ADC_VBAT];
	}

	BATPHYS->ISense_Offset = ISense_Offset;

	TransformVolt = BMT_VOL_RESULT[BMT_ADC_VISENSE] - BMT_VOL_RESULT[BMT_ADC_VBAT]-BATPHYS->ISense_Offset;
	BATPHYS->ICHARGE = bmt_change_Voltage_To_ISense(TransformVolt);	
	
	drv_trace1(TRACE_INFO, BMT_VSENSE_TRC,BMT_VOL_RESULT[BMT_ADC_VISENSE]);
	drv_trace1(TRACE_INFO, BMT_ICHARGE_TRC, BATPHYS->ICHARGE);
	drv_trace1(TRACE_INFO, BMT_VSENSE_VBAT_OFFSET_TRC, BATPHYS->ISense_Offset);
#endif	
}
Esempio n. 12
0
static void bmt_high_vchg_first_time_set(void)
{
	BATPHYStruct BATPHYS;

	bmt_ObtainBMTPhystate(&BATPHYS);
	
    bmt_vchg_compare_and_set_current(BATPHYS.VCHARGER, KAL_TRUE);
    Pre_VCharge_AVG = BATPHYS.VCHARGER;
    drv_trace1(TRACE_GROUP_9, BMT_HIGH_VCHG_FIRST_TIME_VCHG_TRC, Pre_VCharge_AVG);

} 
static void *VideoH264DecMallocDPB(void)
{
    kal_uint32 u4Buffer;
    kal_bool fgCurFrmBufferCacheable;

    if (!rH264SwCtrl.pfnGetYUVBuffer)
    {
        ASSERT(0);
        return (void *)NULL;
    }

    u4Buffer = rH264SwCtrl.pfnGetYUVBuffer();
    drv_trace1(TRACE_GROUP_10, OPEN_API_GETYUVBUFFER, u4Buffer);
    //must be 32 alignment
    if (u4Buffer & 0x1F)
    {
        drv_trace1(TRACE_GROUP_8, H264DEC_ALIGN_ERROR, u4Buffer);
        ASSERT(0);
        return (void *)NULL;
    }

    fgCurFrmBufferCacheable = OpenAPIIsExtBufferCacheable(u4Buffer, rH264SwCtrl.u4BufferSize);

    if (fgCurFrmBufferCacheable)
    {
        ASSERT(0);
    }

    if ((rH264SwCtrl.fgFrmBufferCacheable == KAL_TRUE) && (fgCurFrmBufferCacheable == KAL_FALSE))
    {
        rH264SwCtrl.fgFrmBufferSwitch = KAL_TRUE;
        u4Buffer = OpenAPIExtBufferCacheableSwitch(u4Buffer, rH264SwCtrl.u4BufferSize, OPEN_API_CACHEABLE);
    }
    else if ((rH264SwCtrl.fgFrmBufferCacheable == KAL_FALSE) && (fgCurFrmBufferCacheable == KAL_TRUE))
    {
        rH264SwCtrl.fgFrmBufferSwitch = KAL_TRUE;
        u4Buffer = OpenAPIExtBufferCacheableSwitch(u4Buffer, rH264SwCtrl.u4BufferSize, OPEN_API_NON_CACHEABLE);
    }

    return (void *)u4Buffer;
}
Esempio n. 14
0
void bmt_find_and_set_the_nearest_current(PMU_CHR_CURRENT_ENUM SetCurrent)
{
	
	PMU_CTRL_CHR_GET_CHR_CURRENT_LIST get_chr_current_list;
	PMU_CTRL_CHR_SET_CHR_CURRENT set_chr_current;
	DCL_STATUS  status;
	
	status=DclPMU_Control(bmt_PmuHandler, CHR_GET_CHR_CURRENT_LIST, (DCL_CTRL_DATA_T *)&get_chr_current_list);

	if(status==STATUS_UNSUPPORTED)
	{
		drv_trace1(TRACE_GROUP_10, BMT_PMU_DO_NOT_SUPPORT_TRC, 1);
		return;
	}

	set_chr_current.current=(PMU_CHR_CURRENT_ENUM)bmt_find_closest_level(get_chr_current_list.pCurrentList
		,get_chr_current_list.number,(DCL_UINT32)SetCurrent);

	drv_trace1(TRACE_GROUP_10, BMT_FIND_AND_SET_THE_NEAREST_CURRENT_TRC, set_chr_current.current);
	DclPMU_Control(bmt_PmuHandler, CHR_SET_CHR_CURRENT, (DCL_CTRL_DATA_T *)&set_chr_current);
}
/* Check whether dpb list is full or not
 * @param p_DPB: the dpb goning to be released
 * @param force_release: free the dpb regardless of it's mmco status
 * @return full or not
 */
void open_api_h264_free_dpb(H264_DPB_entry* p_DPB)
{
	H264_dpb_frame_entry *p_free_entry;
    drv_trace1(TRACE_GROUP_10,OPEN_API_UNREFERENCEFRAME,(kal_uint32)p_DPB->mem_addr);
    g_open_api_h264_dec_info_ptr->pfnSetFrameUnReferenceCallback((kal_uint32)p_DPB->mem_addr); 

	p_DPB->b_used = KAL_FALSE;
	p_DPB->status_marked = -1;
	p_DPB->b_dec_done = KAL_FALSE;
	p_DPB->is_corrupted=KAL_FALSE;
	p_DPB->top_POC = 0;
	p_DPB->bottom_POC = 0;
	p_DPB->POC = 0;
	p_DPB->isOutputed = -1;
	p_DPB->pic_num = -1;

	p_free_entry = &g_open_api_h264_dpb_frame_info.frame_list[p_DPB->index_to_list];
	// remove the display one from list 
	if (p_free_entry == g_open_api_h264_dpb_frame_info.p_start)
	{
		g_open_api_h264_dpb_frame_info.p_start = p_free_entry->p_next_dpb;
	}
	else
    {
        if (p_free_entry->p_prev_dpb != NULL)
        {   
            p_free_entry->p_prev_dpb->p_next_dpb = p_free_entry->p_next_dpb;
        }
        if (p_free_entry->p_next_dpb != NULL)
        {
        		p_free_entry->p_next_dpb->p_prev_dpb = p_free_entry->p_prev_dpb;
        	}
        }

        if (p_free_entry == g_open_api_h264_dpb_frame_info.p_end)
        {
        	g_open_api_h264_dpb_frame_info.p_end = p_free_entry->p_prev_dpb;
        }
        else
        {
            if (p_free_entry->p_next_dpb != NULL)
        	{
        	    p_free_entry->p_next_dpb->p_prev_dpb = p_free_entry->p_prev_dpb;
            }
        	if (p_free_entry->p_prev_dpb != NULL)
        	{
        		p_free_entry->p_prev_dpb->p_next_dpb = p_free_entry->p_next_dpb;
        	}
        }
        p_free_entry->b_used = KAL_FALSE;

}
/*------------------------------------------------------------------------------

    Function name:  H264SwDecFree

    Purpose:
        Example implementation of H264SwDecFree function. Prototype of this
        function is given in H264SwDecApi.h. This implementation uses
        library function free for freeing of memory.

------------------------------------------------------------------------------*/
static void VideoH264DecFree(void *ptr)
{
    drv_trace1(TRACE_GROUP_10,OPEN_API_SW_FREEMEMORY,(kal_uint32)ptr);
    if (rH264SwCtrl.pAdmId == NULL)
    {
        ASSERT(0);
    }

    if (ptr != NULL)
    {
        kal_adm_free(rH264SwCtrl.pAdmId, (kal_uint8*)ptr);
    }
}
void MPEG4HWHwResourceFree(VIDEO_MPEG4HW_USER_T eMPEG4HWUser)
{
    kal_uint32 savedMask;

    video_dbg_trace(VIDEO_DBG_OWNER_ENCODER, VIDEO_DBG_MPEG4HW_RESOURCE_FREE, video_get_current_time());
    video_dbg_trace(VIDEO_DBG_OWNER_ENCODER, VIDEO_DBG_MPEG4HW_RESOURCE_FREE, _eMPEG4HWUser);
    drv_trace1(TRACE_GROUP_10, MPEG4HW_RESOURCE_FREE, eMPEG4HWUser);

    ASSERT(_eMPEG4HWUser == eMPEG4HWUser);

    savedMask = SaveAndSetIRQMask();
    _eMPEG4HWUser = VIDEO_MPEG4HW_NONE;
    RestoreIRQMask(savedMask);
}
Esempio n. 18
0
static void bmt_charging_timeout_timer_callback(void* msg_ptr)
{
	  kal_bool charging_algo_enable;

	  drv_trace1(TRACE_GROUP_10, BMT_SAFETY_TIMER_EXPIRE_TRC, bmt_total_charge_time);

	  bmt_event_scheduler_id[BMT_CHARGE_TIMEOUT_TIMER] = 0;	

      //When BMT has guard time, it won't need safty time
      bmt_sendMes2UEM(BMT_CHARGE_TIMEOUT);
      charging_algo_enable = KAL_FALSE;
	  chr_algorithm_control_handler(BMT_CHARGING_ALGO_CMD_ENABLE, &charging_algo_enable);

	  bmt_enable_sleepmode(KAL_TRUE);
}
Esempio n. 19
0
kal_bool bmt_PhyCheck_OverCurrent(BATPHYStruct *BATPHYS)
{
	static kal_uint8 over_current_count=0;
	
	if (BMT.pmictrl_state == PMIC_CHARGEOFF)
	{
		if(BATPHYS->ICHARGE > bmt_charging_para.ICHARGE_OFF_HIGH || BATPHYS->ISense_Offset > (bmt_charging_para.ICHARGE_OFF_HIGH / 5))	// x0.2 Ohm resistor
		{
			over_current_count++;
			drv_trace1(TRACE_ERROR, BMT_PHY_CHECK_OVER_CURRENT_COUNT_TRC, over_current_count);	
		}
		else
		{				
			over_current_count = 0;	
		}
	}
	else
	{
		if(BATPHYS->ICHARGE > bmt_charging_para.ICHARGE_ON_HIGH)
		{
			over_current_count++;
			drv_trace1(TRACE_ERROR, BMT_PHY_CHECK_OVER_CURRENT_COUNT_TRC, over_current_count);	
		}
		else
		{				
			over_current_count = 0;	  
		}	
	}
	if (over_current_count > OVER_CURRENT_CHECK_COUNT)
	{
		over_current_count = 0;
		return KAL_FALSE;
		
	}
	return KAL_TRUE;
}
Esempio n. 20
0
/*
* FUNCTION
*	   bmt_charge_end
*
* DESCRIPTION                                                           
*   	This function is to stop charging when charger is plugged out 
*     or serious error in charging stage.
*
* CALLS  
*
* PARAMETERS
*	   None
*	
* RETURNS
*	   None
*
* GLOBALS AFFECTED
*     None
*/
void bmt_charge_end(void)
{
#if defined(__EVB__) && defined(__MTK_INTERNAL__)
/* under construction !*/
#elif defined(__DRV_BMT_NO_CHARGING__)
   return;
#else//#if defined(__EVB__)
    DCL_STATUS adc_status;
//#ifdef __DRV_BMT_SW_POLLING_CHARGER_OV__
//	kal_cancel_timer(bmt_sw_polling_timerId);
//#endif //#ifdef __DRV_BMT_SW_POLLING_CHARGER_OV__

#if defined(__DRV_BMT_ULTRA_LOW_COST_CHARGER__)
	bmt_chr_force_enable(KAL_FALSE);
#endif
	BMT.pmictrl_state = PMIC_CHARGEOFF;
   	BMT.VBAT_UEM= VBAT_UEM_CHR_OUT_FIRST;
	BMT_Charge(KAL_FALSE);
		adc_status = DclSADC_Control(bmt_adc_handle, ADC_CMD_STOP_MEASURE, NULL);
		if(adc_status != STATUS_OK)
		{
			ASSERT(0);
		}

	bmt_stop_stoptimer();
	stack_stop_timer(&ChargeTimeout_timer);
#ifdef __BMT_CHARGE_GUARD_TIME__
	bmt_stop_guardtimer();
#endif
#if defined(__DRV_BMT_ESTIMATIVE_TIMER_ON_TOPOFF__)
	bmt_stop_estimativetimer();
#endif //#if defined(__DRV_BMT_ESTIMATIVE_TIMER_ON_TOPOFF__)
	drv_trace1(TRACE_GROUP_10, BMT_SAFETY_TIMER_STOP_TRC, BMT_TOTAL_CHARGE_TIME);
   SaftyTimer_Flag = BMT_SAFETY_TIMER_OFF; 
//   #ifdef MTK_SLEEP_ENABLE
//   L1SM_SleepEnable(bmt_sm_handle);
//   #endif

	bmt_enable_sleepmode(KAL_TRUE);
   
   #if defined(PMIC_CHARGE_WDT)  // Defined in pmic_features.h
   bmt_charge_enable_wdt(KAL_FALSE);
   #endif // #if defined(PMIC_CHARGE_WDT)
   
   drv_trace0(TRACE_GROUP_10, BMT_CHARGING_END_TRC);
 //  DclSADC_Close(adc_handle);
#endif//#if defined(__EVB__)
}
Esempio n. 21
0
/* close  USB2UART port */
static void USB2UART_close(UART_PORT port, module_type ownerid)
{
#ifndef __USB_ENABLE__
    ASSERT(0);
#endif

#ifndef  __PRODUCTION_RELEASE__
    if(ownerid != USB2UARTPort.ownerid)
    {
        EXT_ASSERT( 0, (kal_uint32) ownerid, USB2UARTPort.ownerid, 0);
    }
#endif

    if(INT_Exception_Enter != 0)
    {
        drv_trace1(TRACE_FUNC, USBACM_CLOSE, ownerid);
//	kal_prompt_trace(MOD_USB, "USB Close %d", ownerid);
    }

    g_UsbACM.send_Txilm = KAL_FALSE;
    g_UsbACM.config_send_Txilm = KAL_FALSE;
    USB2UARTPort.initialized = KAL_FALSE;
    USB2UARTPort.ownerid = MOD_DRV_HISR;
    g_UsbACM.threshold_enable = KAL_FALSE;

    if ((gUsbDevice.device_type == USB_CDC_ACM)&&(gUsbDevice.nDevState==DEVSTATE_CONFIG))
    {
        /* disable endpoint interrupt */
        USB_TxEPDis(g_UsbACM.txpipe->byEP, KAL_TRUE);
        USB_RxEPDis(g_UsbACM.rxpipe->byEP, KAL_FALSE);
    }

    Buf_init(&(USB2UARTPort.Rx_Buffer),(kal_uint8 *)(USB2UARTPort.RingBuffers.rx_buffer),
             g_UsbACM.acm_param->rx_ringbuff_size);
    Buf_init(&(USB2UARTPort.Tx_Buffer),(kal_uint8 *)(USB2UARTPort.RingBuffers.tx_buffer),
             g_UsbACM.acm_param->tx_ringbuff_size);
    Buf_init(&(USB2UARTPort.Tx_Buffer_ISR),(kal_uint8 *)(USB2UARTPort.RingBuffers.txISR_buffer),
             g_UsbACM.acm_param->txisr_ringbuff_size);

    if(g_UsbACM.ring_buffer_timer_counting == KAL_TRUE)
    {
        GPTI_StopItem(g_UsbACM.ring_buffer_handle);
        g_UsbACM.ring_buffer_timer_counting = KAL_FALSE;
    }

    USB2UART_ConfigEscape(port, 0xff, 0, MOD_DRV_HISR);
}
Esempio n. 22
0
/*
* FUNCTION
*		bmt_CtrlCharge
*
* DESCRIPTION																			  
*		This function is called to control the SW of charge
*
* CALLS  
*
* PARAMETERS
*		ON: 1, charge on	  0, charge off
*	  VBAT: the measured voltage of battery.
*	
* RETURNS
*		None
*
* GLOBALS AFFECTED
*	  None
*/
void bmt_CtrlCharge(kal_uint8 ON)
{
	kal_bool chr_enable;
	kal_bool ChrCtrl;

    drv_trace1(TRACE_GROUP_1, BMT_CTRL_CHARGE_TRC, ON);

	// If bat_state is HOLD, we do NOT enable chr_en
	if ( (BMT.bat_state == CHR_HOLD) || (BMT.bat_state == CHR_ERROR) )
	{
		BMT.pmictrl_state = PMIC_CHARGEOFF;

		chr_enable = KAL_FALSE;
		bmt_charging_control_handler(BMT_CHARGING_CMD_CHARGING_ENABLE, &chr_enable);

		return;
	}

	if ((kal_bool)ON == KAL_TRUE)
	{
		if (BMT.pmictrl_state == PMIC_CHARGEOFF)
		{      
			BMT.pmictrl_state = PMIC_CHARGEON;

			// Fast plug in/out may cause HW disable current level, but SW do not receive interrupt.
			// Under such scenario the current level will incorrect.
			// Enforce set correct current level every time charge ON.
     		bmt_set_chr_current();
     
			ChrCtrl = KAL_TRUE;
			bmt_charging_control_handler(BMT_CHARGING_CMD_CHARGING_ENABLE, &ChrCtrl);
		}
		else
		{
			bmt_charging_control_handler(BMT_CHARGING_CMD_WDT_CLEAR,NULL);
   	 		drv_trace0(TRACE_GROUP_6, BMT_CHARGING_ALREADY_ON_TRC);
      	}
	}
	else
	{
		BMT.pmictrl_state = PMIC_CHARGEOFF;
		ChrCtrl = KAL_FALSE;

		bmt_charging_control_handler(BMT_CHARGING_CMD_CHARGING_ENABLE, &ChrCtrl);
	}
}
kal_bool ctp_cypress_cy8ctma340_get_data(TouchPanelMultipleEventStruct *tpes)
{
	kal_bool i2c_ret;
	kal_uint8 reg[2];
	kal_uint32 model = 0;

	ASSERT(tpes);
		
	tpes->time_stamp = (kal_uint16)L1I_GetTimeStamp();
	tpes->padding = CTP_PATTERN;
	
	i2c_ret = CTP_I2C_read(TT_MODE_ADDR, reg, 2);
	if(i2c_ret == KAL_FALSE)
	{
		ctp_cypress_cy8ctma340_toggle();
		return KAL_FALSE;
	}	
	if(reg[0] & TT_MODE_BUFFER_INVALID)
	{
		drv_trace0(TRACE_GROUP_10, CTP_CAPACITIVE_GET_DATA_INVALID);
		ctp_cypress_cy8ctma340_toggle();
		return KAL_FALSE;
	}

	model = (kal_uint32)(reg[1] & TT_STAT_NUMBER_TOUCH);
		
	drv_trace1(TRACE_GROUP_10, CTP_CAPACITIVE_MODEL, model);
	if(model > 4) //cypress only support 4 fingers
	{
		ctp_cypress_cy8ctma340_toggle();
		return KAL_FALSE;
	}

	tpes->model = (kal_uint16)model;  //read out all touch points coordinates.
	if(model == 0)
	{
		ctp_cypress_cy8ctma340_toggle();
		return KAL_FALSE;
	}

	ctp_read_all_point(tpes, model);
	ctp_cypress_cy8ctma340_toggle();
	return KAL_TRUE;
}
static void VideoH264DecOutputPic(kal_uint32 u4FlushBuffer)
{
    H264SwDecPicture rDecPic;
    kal_uint32 u4OutAddr;

    if (!rH264SwCtrl.pfnOutputOneFrame)
    {
        ASSERT(0);
        return;
    }

    while (H264SwDecNextPicture(rH264SwCtrl.prH264DecInst, &rDecPic,
                                                u4FlushBuffer) == H264SWDEC_PIC_RDY)
    {
   	kal_bool fgError = KAL_FALSE;
        drv_trace1(TRACE_GROUP_8, H264DEC_OUTPUT_IDR, rDecPic.isIdrPicture);
        if (rDecPic.isEOF) break;
        if (rH264SwCtrl.fgFrmBufferSwitch == KAL_TRUE)
        {
            if (rH264SwCtrl.fgFrmBufferCacheable == KAL_TRUE)
            {
                u4OutAddr = OpenAPIExtBufferCacheableSwitch((kal_uint32)rDecPic.pOutputPicture,
                                                                rH264SwCtrl.u4BufferSize, OPEN_API_NON_CACHEABLE);
            }
            else
            {
                u4OutAddr = OpenAPIExtBufferCacheableSwitch((kal_uint32)rDecPic.pOutputPicture,
                                                                rH264SwCtrl.u4BufferSize, OPEN_API_CACHEABLE);
            }
        }
        else
        {
            u4OutAddr = (kal_uint32)rDecPic.pOutputPicture;
        }
        if (rDecPic.nbrOfErrMBs > 0)
        {
            fgError = KAL_TRUE;
        }
        drv_trace4(TRACE_GROUP_8, H264DEC_DISPLAY_INFO, u4OutAddr, rDecPic.displayWidth, 
                            rDecPic.displayHeight, u4FlushBuffer);
        drv_trace2(TRACE_GROUP_10,OPEN_API_OUTPUTFRAME, u4OutAddr,0);
        rH264SwCtrl.pfnOutputOneFrame(u4OutAddr, fgError);
    }
}
/* USB task run */
static void USB_Host_Ms_Error_Handler(kal_uint8 ms_index)
{
	OTG_DRV_CTRL_GET_PLUG_TYPE_T  dcl_data;
	OTG_PLUG_TYPE plug_type;


	//DclSGPT_Control((DCL_HANDLE)(g_UsbHostMs[ms_index].gpt_handle), SGPT_CMD_STOP, 0);	
	USB_GPTI_StopItem(g_UsbHostMs[ms_index].gpt_handle);
	//DclSGPT_Control((DCL_HANDLE)(g_UsbHostMs[ms_index].sleep_timer_handle), SGPT_CMD_STOP, 0);	
	USB_GPTI_StopItem(g_UsbHostMs[ms_index].sleep_timer_handle);

	DclOTG_DRV_Control(g_OTG_Dcl_Handle, OTG_DRV_CMD_GET_PLUG_TYPE, (DCL_CTRL_DATA_T  *)&dcl_data);
	plug_type = (OTG_PLUG_TYPE)dcl_data.type;

	USB_Dbg_Trace(USB_HOST_MS_ERROR_HLDR, (kal_uint32)plug_type, (kal_uint32)g_UsbHostMs[ms_index].dev_attatch);

	if(g_UsbHostMs[ms_index].dev_attatch == KAL_TRUE)
	{
		/* If cable is plugged out then error, do not turn off Vbus */
		/* Stop OTG action */
//		if(OTG_Get_Plug_Type() == OTG_PLUG_A)
		if(plug_type == OTG_PLUG_A)
		{
			DclOTG_DRV_Control(g_OTG_Dcl_Handle, OTG_DRV_CMD_A_STOP_HOST, NULL);
//			OTG_A_Stop_Host();
		}
		else
		{
			DclOTG_DRV_Control(g_OTG_Dcl_Handle, OTG_DRV_CMD_B_STOP_HOST, NULL);
//			OTG_B_Stop_Host();
		}

		OTG_Display_Message(OTG_DISPLAY_MSG_UN_SUPPORT);

		drv_trace1(TRACE_FUNC, (kal_uint32)USB_HOST_MS_CHECK_MEDIA_STATE, g_UsbHostMs[ms_index].media_state_change);
		USB_Dbg_Trace(USB_HOST_MS_REPORT_MEDIA_STATE,  g_UsbHostMs[ms_index].media_state_change, (kal_uint32)g_UsbHostMs[ms_index].b_sending_change_ilm);

		if((g_UsbHostMs[ms_index].media_state_change != 0) && (g_UsbHostMs[ms_index].b_sending_change_ilm == KAL_FALSE))
		{
			USB_Host_Ms_Check_Media_State(ms_index);
		}
	}
}
static kal_uint8 gt818_reset( void )
{
    kal_uint8 ret = 1;
    kal_uint8 retry_count = 0;

    outbuf[0] = 1;
    outbuf[1] = 1;

    DclGPIO_Control(rst_handle, GPIO_CMD_WRITE_HIGH, NULL);
    kal_sleep_task(5);
    DclGPIO_Control(rst_handle, GPIO_CMD_WRITE_LOW, NULL);
    kal_sleep_task(5);
    DclGPIO_Control(rst_handle, GPIO_CMD_WRITE_HIGH, NULL);
    kal_sleep_task(120);

search_i2c:
    //gt818_i2c_write( guitar_i2c_address, 0x00FF, outbuf, 1 );

    //kal_sleep_task( 12 );

    gt818_i2c_read( guitar_i2c_address, 0x00FF, inbuf, 1 );

    if ( inbuf[0] != 0x55 )
    {
        drv_trace2( TRACE_GROUP_7, CTP_GOODIX_DWN_REGISTER_TRACE, 0x00FF, inbuf[0] );
        kal_sleep_task(10);
        
        if ( retry_count < 10 )
        {
            retry_count++;
            goto search_i2c;
        }
        else
        {
            ASSERT(0);
        }
    }

    drv_trace1( TRACE_GROUP_7, CTP_GOODIX_DWN_DETECT_ADDR_TRACE, guitar_i2c_address );
    kal_sleep_task(120);
    return ret;	
}
kal_bool MPEG4HWHwResourceFreeIfOccupy(VIDEO_MPEG4HW_USER_T eMPEG4HWUser)
{
    kal_bool fgResult = KAL_FALSE;
    kal_uint32 savedMask;

    if(_eMPEG4HWUser != eMPEG4HWUser)
        return fgResult;

    video_dbg_trace(VIDEO_DBG_OWNER_ENCODER, VIDEO_DBG_MPEG4HW_RESOURCE_FREE, video_get_current_time());
    video_dbg_trace(VIDEO_DBG_OWNER_ENCODER, VIDEO_DBG_MPEG4HW_RESOURCE_FREE, _eMPEG4HWUser);
    drv_trace1(TRACE_GROUP_10, MPEG4HW_RESOURCE_FREE, eMPEG4HWUser);

    ASSERT(_eMPEG4HWUser == eMPEG4HWUser);

    savedMask = SaveAndSetIRQMask();
    _eMPEG4HWUser = VIDEO_MPEG4HW_NONE;
    RestoreIRQMask(savedMask);
    fgResult = KAL_TRUE;
    return fgResult;
}
static void VideoH264DecFreeDPB(void *ptr)
{
    kal_uint32 u4Buffer = (kal_uint32)ptr;

    if (!rH264SwCtrl.pfnSetFrameUnReference)
    {
        ASSERT(0);
        return;
    }

    if (u4Buffer)
    {
        if (rH264SwCtrl.fgFrmBufferSwitch == KAL_TRUE)
        {
            u4Buffer = query_opposite_switchable_cacheaddr_ram(u4Buffer);
        }
        drv_trace1(TRACE_GROUP_10,OPEN_API_UNREFERENCEFRAME,u4Buffer);
        rH264SwCtrl.pfnSetFrameUnReference(u4Buffer);
    }
}
Esempio n. 29
0
void bmt_find_and_set_the_nearest_charger_high_voltage(DCL_UINT32 voltage)
{
	PMU_CTRL_CHR_GET_HV_DETECTION_VOLTAGE_LIST hv_voltage_list;
	PMU_CTRL_CHR_SET_HV_DETECTION_VOLTAGE hv_voltage;
	DCL_STATUS  status;
	
	status=DclPMU_Control(bmt_PmuHandler, CHR_GET_HV_DETECTION_VOLTAGE_LIST, (DCL_CTRL_DATA_T *)&hv_voltage_list);

	if(status==STATUS_UNSUPPORTED)
	{
		drv_trace1(TRACE_GROUP_10, BMT_PMU_DO_NOT_SUPPORT_TRC, 0);
		return;
	}

	hv_voltage.voltage=(PMU_VOLTAGE_ENUM)bmt_find_closest_level(hv_voltage_list.pVoltageList
		,hv_voltage_list.number,(DCL_UINT32)voltage);
	
	DclPMU_Control(bmt_PmuHandler, CHR_SET_HV_DETECTION_VOLTAGE, (DCL_CTRL_DATA_T *)&hv_voltage);

}
Esempio n. 30
0
kal_bool bmt_PhyCheck_LowBatTemp(BATPHYStruct *BATPHYS)
{
	static kal_uint8 low_temper_count = 0;
	
	if (BATPHYS->BATTMP <CHR_BATTMP_LOW_TEMP && BATPHYS->BATTMP > CHR_BATTMP_BAD_CONTACT)  /*battery temperature < 0C*/
	{
		low_temper_count ++;
		drv_trace1(TRACE_ERROR, BMT_PHY_CHECK_LOW_TRMPER_COUNT_TRC, low_temper_count);	
	}
	else
	{
		low_temper_count = 0;
	}
	
	if (low_temper_count > LOW_BATTEMP_CHECK_COUNT)
	{
		return KAL_FALSE;
	}
	
	return KAL_TRUE;
}