Exemple #1
0
/*****************************************************************************
 * FUNCTION
 *  jbt_cmd_queue_init
 * DESCRIPTION
 *  
 * PARAMETERS
 *  void
 * RETURNS
 *  void
 *****************************************************************************/
void jbt_cmd_queue_init(void)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
    kal_uint8 i = 0;

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    jbt_cmd_sem = kal_create_sem("jbt_cmd_sem", 1);
    jbt_cmd_process_sem = kal_create_sem("jbt_cmd_process_sem", 1);
    jbt_cmd_kick_sem = kal_create_sem("jbt_cmd_kick_sem", 1);

    kal_mem_set((kal_uint8*) & jbt_cmd_queue_context, 0, sizeof(jbt_cmd_queue_context));
    jbt_cmd_list_init(&jbt_cmd_queue_context.empty_list);
    jbt_cmd_list_init(&jbt_cmd_queue_context.cmd_list);
    jbt_cmd_queue_context.queue_kick_off = 0;

    for (i = 0; i < JBT_MAX_COMMAND_QUEUE; i++)
    {
        jbt_cmd_list_init(&jbt_cmd_queue_context.cmd_node[i]);
        jbt_cmd_list_insert_tail(&jbt_cmd_queue_context.empty_list, &jbt_cmd_queue_context.cmd_node[i]);
    }
}
Exemple #2
0
DCL_STATUS DclSIM_Initialize(void)
{
    kal_uint32	maskedValue;
    kal_uint32	loopIndex;

    maskedValue = SaveAndSetIRQMask();
    if(KAL_FALSE == fgSIMInit) {
        fgSIMInit = KAL_FALSE;
        RestoreIRQMask(maskedValue);
        kal_mem_set(simResource, 0, sizeof(DCL_SIM_RESOURCE) * DCL_SIM_MAX_INTERFACE);
        dclSimArb = kal_create_sem("SIM_DCL", 1);
        for(loopIndex = 0; DCL_SIM_MAX_INTERFACE > loopIndex; loopIndex ++) {
            simResource[loopIndex].guardHead = SIM_RESOURCE_HEAD;
            simResource[loopIndex].guardTail = SIM_RESOURCE_TAIL;
            simResource[loopIndex].driverHandle = SIM_RSC_HANDLE_UDEF;
        }
        sim_init_all_cb();
#ifdef MEUT_ON_FPGA
        MT6302_test();
#endif
    }
    else {
        RestoreIRQMask(maskedValue);
    }

    return STATUS_OK;
}
kal_bool
idp_imgdma_rotdma0_init(void)
{
    memset(&owner, 0, sizeof(owner));
    owner.sem = kal_create_sem("IDP", 1);

    return KAL_TRUE;
}
Exemple #4
0
RTFAPI RTFSYSAllocMutex(const char * Name)
{
    if (NextMutex >= MAX_MUTEX)
    {
        fs_err_internal_fatal(FS_ERR_MUTEX_01, (void*)MAX_MUTEX);
    }

    M[NextMutex].rtf_lock_count = 0;
    M[NextMutex].rtf_sem_owner = KAL_NILTASK_ID;
    M[NextMutex].DeviceNum_1 = 0;
    M[NextMutex].DeviceNum_2 = 0;
    M[NextMutex++].rtf_sem = kal_create_sem((kal_char*)Name, INI_SEM);

    return &M[NextMutex-1];
}
Exemple #5
0
void ccci_ipc_init(void)
{
    kal_uint32 p_cache_aligned; 
    
    //Send message does not need callback
    ccci_ipc_ch.ccci_init_gpdior(ccci_ipc_ch.send_channel ,  ccci_ipc_send_msg_cb);
    //send mesage ack need to implement callback
//	    ccci_ipc_ch.ccci_init_gpdior(ccci_ipc_ch.send_ack_channel , ccci_ipc_error_cb);
    //Receive mesage need to implement callback
    ccci_ipc_ch.ccci_init_gpdior(ccci_ipc_ch.receive_channel , ccci_ipc_receive_msg_cb);
    //Receive mesage ack does not need to implement callback
//	    ccci_ipc_ch.ccci_init_gpdior(ccci_ipc_ch.receive_ack_channel , ccci_ipc_error_cb);

    //Initialize the event for usage
    if (ccci_ipc_ch.event == 0){
        ccci_ipc_ch.event = kal_create_event_group("CCCI_IPC");
    }
    //Initialize the semaphore for critical section 
    if (ccci_ipc_ch.semaphore == 0){
        ccci_ipc_ch.semaphore = kal_create_sem("CCCI_IPC",1); 
    }

    /* initialize polling mode GPD */
    ASSERT(CCCI_IPC_POLLING_MODE_BUF_SZ >= 2*CPU_CACHE_LINE_SIZE);
    /*make p_gpd aligned to CPU_CACHE_LINE_SIZE_MASK*/
    p_cache_aligned = (kal_uint32)g_ccci_ipc_polling_buf;
    if(p_cache_aligned&CPU_CACHE_LINE_SIZE_MASK) { 
        p_cache_aligned = ((kal_uint32)(g_ccci_ipc_polling_buf)&~CPU_CACHE_LINE_SIZE_MASK);
        p_cache_aligned += CPU_CACHE_LINE_SIZE;
    }

    // The reason + QBM_HEAD_SIZE is for ROME E1, cldma needs to record this buff whether is cacheable or non-cacheable
	ccci_ipc_ch.p_polling_gpd = (qbm_gpd *)(p_cache_aligned + QBM_HEAD_SIZE);
    
    // register ccci debug get status cb funp
    ccci_debug_get_status_register(CCCI_DEBUG_GET_STATUS_MODULE_CCCIIPC, ccci_ipc_get_debug_status);    
    
    CCCIDEV_RST_CCCI_COMM_GPD_LIST(ccci_ipc_ch.p_polling_gpd,ccci_ipc_ch.p_polling_gpd);

#ifdef CCCI_IT_MODE_CONTROL_CCCI_IPC
    ccci_ipc_it_create();
#endif
}
Exemple #6
0
void
idp_init(void)
{
    kal_uint32 i;

    /* All operations based on this buffer will assume that the size of the buffer
     * is power of 2. This is to say that I have to ensure that the binary form of
     * buffer_size must contain only one one.
     */
    //ASSERT(1 == count_one_bit_number(IDP_TRACED_BUFFER_SIZE));

    /* Because I need to call semaphore API, I have to ensure
     * this function will not be called from HISR & LISR.
     */
    if (kal_if_hisr() || kal_if_lisr())
    {
        ASSERT(0);
    }

    idp_owners_sem = kal_create_sem("IDP", 1);

    for (i = 0; i < MAX_CONCURRENT_DP; ++i)
    {
        memset(&(owners[i]), 0, sizeof(owners[i]));
    }

    idp_hw_init();

#if defined(IDP_HISR_SUPPORT)
    idp_hisr_init();
#endif

#if defined(DRV_IDP_6238_SERIES) || defined(DRV_IDP_MT6236_SERIES)
    // For MT6268 VT video frame rotation
    //idp_sw_yuv_rotator_init(); // for MT6268 VT
#endif  // #if defined(DRV_IDP_6238_SERIES) || defined(DRV_IDP_MT6236_SERIES)
}
/******************************************************************************
* Function:
*	GPSLocateNvramInitDataFile
*
* Usage:
*	Initialize data file
*	If the file doesn't exist, create it and write the default data to the file. Otherwise, load the
*	content of the file to the cache.
*
* Parameters:
*	None
*
* Return:
*	KAL_TRUE - successfully
*	KAL_FALSE - failed
******************************************************************************/
kal_bool GPSLocateNvramInitDataFile(void)
{
	FS_HANDLE file_handle;
	int result;
	kal_uint16 folderName[GPSLOCATE_NVRAMDATA_FULLPATHNAME_LEN_MAX];
	char tmpBuffer[GPSLOCATE_NVRAMDATA_FULLPATHNAME_LEN_MAX];
	kal_bool bRet = KAL_TRUE, bNeedCreate = KAL_FALSE;
	unsigned int Size;
	unsigned char Ver;

	if (gGPSLocateNvramSem != NULL)
	{
		//has been initialized
		//do nothing, return error directly
		return KAL_FALSE;
	}
	//create semaphore
	gGPSLocateNvramSem = kal_create_sem("GPSNVRAM SEM", 1);
	ASSERT((gGPSLocateNvramSem!=NULL));
	/*
	* Taking the semaphore here will make the handset not able to power up.
	* Maybe, semaphore is not ready now.
	*/
	//take the semaphore
	//kal_take_sem(gGPSLocateNvramSem, KAL_INFINITE_WAIT);

	//initialize global data
	gGPSLocateNvramFullPathFileName[0] = 0x0000;
	gGPSLocateNvramDataCache.Valid = KAL_FALSE;
	
	//construct folder name
	sprintf(tmpBuffer, "%c:\\%s", GPSLOCATE_NVRAMDATA_DRV, GPSLOCATE_NVRAMDATA_FOLDER_NAME);
	app_ansii_to_unicodestring((kal_int8*)folderName, (kal_int8*)tmpBuffer);
	//check the folder exists or not
	file_handle = FS_Open(folderName, FS_OPEN_DIR | FS_READ_ONLY );
	if (file_handle < FS_NO_ERROR) 
	{
		//the folder doesn't exist, create it.
		result = FS_CreateDir(folderName);
		if (result < FS_NO_ERROR)
		{
			//fail to create
			bRet = KAL_FALSE;
			//return KAL_FALSE;
			goto _RelSem_Return_;
		}
	}
	else
	{
		FS_Close(file_handle);
	}

	/*
	1. construct full path file name
	2. check file exist or not
	3. check file valid or not (by file size)
	4. if file doesn't exist or it is invalid, re-create and restore default data for it
	*/

	//construct full path file name
	sprintf(tmpBuffer, "%c:\\%s%s", 
					GPSLOCATE_NVRAMDATA_DRV, 
					GPSLOCATE_NVRAMDATA_FOLDER_NAME,
					GPSLOCATE_NVRAMDATA_FILE_NAME);
	app_ansii_to_unicodestring((kal_int8*)gGPSLocateNvramFullPathFileName, (kal_int8*)tmpBuffer);
	//check files exist or not
	file_handle = FS_Open(gGPSLocateNvramFullPathFileName, FS_READ_ONLY);
	if (file_handle < FS_NO_ERROR)
	{
		//this file doesn't exist, need create it
		bNeedCreate = KAL_TRUE;
	}
	else 
	{
		if (FS_GetFileSize(file_handle, &Size) < FS_NO_ERROR)
		{
			//fail to get file size, consider the file invalid, need create it
			bNeedCreate = KAL_TRUE;
		}
		else if (Size != sizeof(GPSLocateNvramDataStruct_t))
		{
			//invalid size, need re-create it
			bNeedCreate = KAL_TRUE;
		}
		else
		{
			//check version number
			result = FS_Read(file_handle, &Ver, sizeof(unsigned char), &Size);
			if (result == FS_NO_ERROR && Size == sizeof(unsigned char))
			{
				//Got version number
				if (Ver != GPSLOCATE_NVRAM_VER_NO)
				{
					//old version, should be re-created
					bNeedCreate = KAL_TRUE;
				}
			}
		}
		//close the file
		FS_Close(file_handle);
		if (bNeedCreate == KAL_TRUE)
		{
			//delete the bad file
			FS_Delete(gGPSLocateNvramFullPathFileName);
		}
	}
	if (bNeedCreate == KAL_FALSE)
	{
#if 0//defined(M100)
		if (gGPSLocateRestoreFlag == 1 && BMT.PWRon == PWRKEYPWRON)
		{
			//should restore the default value
			file_handle = FS_Open(gGPSLocateNvramFullPathFileName, FS_READ_WRITE);
			if (file_handle < FS_NO_ERROR)
			{
				//fail to open
				bRet = KAL_FALSE;
				goto _RelSem_Return_;
			}
			else
			{
				//load default
				bRet = GPSLocateNvramLoadDefault(file_handle, KAL_FALSE);
				FS_Close(file_handle);
				goto _RelSem_Return_;
			}
		}
		else
#endif //	M100	
		{
			//valid file, load the content to the cache
			bRet = GPSLocateNvramLoadData();
			goto _RelSem_Return_;
		}
	}
	else
	{
		//create the file
		if (GPSLocateNvramCreateDataFile() != KAL_TRUE)
		{
			//fail to create, set the full path name empty
			gGPSLocateNvramFullPathFileName[0] = 0x0000;
			bRet = KAL_FALSE;
			//return KAL_FALSE;
			goto _RelSem_Return_;
		}
	}
_RelSem_Return_:
	//release the semaphore
	//kal_give_sem(gGPSLocateNvramSem);
	return bRet;
}
/******************************************************************************
* Function:
*	GPSAppDataBackupInit
*
* Usage:
*	Initialize data backup
*
* Parameters:
*	None
*
* Return:
*	void
******************************************************************************/
void GPSAppDataBackupInit(void)
{
	FS_HANDLE file_handle;
	int result;
	kal_uint16 folderName[GPSAPP_DATABACKUP_FULLPATHNAME_LEN_MAX];
	kal_int8 tmpBuffer[GPSAPP_DATABACKUP_FULLPATHNAME_LEN_MAX];
	unsigned int Size;
	GPSAppDataBackupError_t ErrCode;
	kal_int32 ErrExt1=0, ErrExt2=0, ErrExt3=0;

	if (gGPSAppDataBackupSem != NULL)
	{
		//has been initialized
		//do nothing, return error directly
		return;
	}
	//create semaphore
	gGPSAppDataBackupSem = kal_create_sem("Backup SEM", 1);
	ASSERT((gGPSAppDataBackupSem!=NULL));

	//initialize global data
	gGPSAppDataBackupFolderName[0] = 0x00;
	gGPSAppDataBackupAttrFileName[0] = 0x0000;
	memset(&gGPSAppDataBackAttrCache, 0x00, sizeof(gGPSAppDataBackAttrCache));

	//construct attr file name
	sprintf(tmpBuffer, "%c:\\%s", GPSAPP_DATABACKUP_DRV, GPSAPP_DATABACKUP_ATTRIBUTE_FILE_NAME);
	app_ansii_to_unicodestring((kal_int8*)gGPSAppDataBackupAttrFileName, (kal_int8*)tmpBuffer);
	//check the file exists or not
	file_handle = FS_Open(gGPSAppDataBackupAttrFileName, FS_READ_ONLY);
	if (file_handle < FS_NO_ERROR) 
	{
		//the attr file doesn't exist, create it.
		ErrCode = GPSAppDataBackupWriteAttrFile(KAL_TRUE);
		if (ErrCode != GPSAPP_DATABACKUP_ERROR_NONE)
		{
			ErrExt1 = 1;
			ErrExt2 = ErrCode;
			goto _INIT_FAIL_;
		}
	}
	else
	{
		//the attr file exists, read it
		result = FS_Read(file_handle, gGPSAppDataBackAttrCache, sizeof(gGPSAppDataBackAttrCache), &Size);
		FS_Close(file_handle);
		if (result != FS_NO_ERROR || Size != sizeof(gGPSAppDataBackAttrCache))
		{
			ErrExt1 = 2;
			ErrExt2 = result;
			ErrExt3 = Size;
			goto _INIT_FAIL_;
		}
	}
	
	//construct folder name
	sprintf(gGPSAppDataBackupFolderName, "%c:\\%s", GPSAPP_DATABACKUP_DRV, GPSAPP_DATABACKUP_FOLDER_NAME);
	app_ansii_to_unicodestring((kal_int8*)folderName, (kal_int8*)gGPSAppDataBackupFolderName);
	//check the folder exists or not
	file_handle = FS_Open(folderName, FS_OPEN_DIR | FS_READ_ONLY );
	if (file_handle < FS_NO_ERROR) 
	{
		//the folder doesn't exist, create it.
		result = FS_CreateDir(folderName);
		if (result < FS_NO_ERROR)
		{
			//fail to create
			ErrExt1 = 3;
			ErrExt2 = result;
			goto _INIT_FAIL_;
		}
	}
	else
	{
		FS_Close(file_handle);
		/*
		//sync attr file and backup files
		ErrCode = GPSAppDataBackupSyncAttr();
		if (ErrCode != GPSAPP_DATABACKUP_ERROR_NONE)
		{
			ErrExt1 = 4;
			ErrExt2 = ErrCode;
			goto _INIT_FAIL_;
		}
		*/
	}

	return;

_INIT_FAIL_:
	EXT_ASSERT(0, ErrExt1, ErrExt2, ErrExt3);
	return;
}
/* ------------------------------------------------------------------------------ */
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();
   }
}