Esempio n. 1
0
void L1Audio_SetFlag_MD2G( uint16 audio_id )
{
   uint32 savedMask;
   if (!kal_if_hisr() && !kal_if_lisr())
      kal_trace( TRACE_GROUP_AUD_MD2GCTRL, L1AUDIO_SETFLAG_MD2G_A,audio_id,l1audio.runningState);
   else
      kal_dev_trace( TRACE_GROUP_AUD_MD2GCTRL, L1AUDIO_SETFLAG_MD2G_A,audio_id,l1audio.runningState);

   kal_take_sem( l1audio.sema, KAL_INFINITE_WAIT );
   ASSERT( l1audio.id_flag & (1 << audio_id) );
   ASSERT( (l1audio.disallowSleepState & (1 << audio_id)) == 0 );

   if( (l1audio.runningState == 0) && (l1audio.disallowSleepState == 0) ) {
#if defined( __CENTRALIZED_SLEEP_MANAGER__ )
      Audio_Wake_DSP(audio_id,KAL_TRUE);
#endif
   }

   savedMask = SaveAndSetIRQMask();
   l1audio.disallowSleepState |= (1 << audio_id);
   RestoreIRQMask( savedMask );
   kal_give_sem( l1audio.sema ); 
}
Esempio n. 2
0
/////////////////////////////////////////////////////////////////////////////
//power on/off/suspend
/////////////////////////////////////////////////////////////////////////////
kal_bool fm_powerup(struct fm_tune_parm *parm){
	kal_bool return_value;
	
	mATV_task_init();
	kal_prompt_trace(MOD_MATV, "[FM] fm_powerup In");
	if (NULL != matv_sem_id)
			kal_take_sem(matv_sem_id, KAL_INFINITE_WAIT);
	
	return_value=fmdrv_init();

	if (NULL != matv_sem_id)
			kal_give_sem(matv_sem_id);
	
	if(return_value)
	{
		return_value = fm_tune(parm);
	}
			

	kal_prompt_trace(MOD_MATV, "[FM] fm_powerup Out");
	
	return return_value;
}
Esempio n. 3
0
/******************************************************************************
* Function:
*	GPSAppDataBackupLoad
* 
* Usage:
*	Load data from backup files.
*
* Parameters:
*	pBuff - pointer to caller's data buffer, which is used to store loading data.
*	pLength - (Input) the buffer size (in byte)
*			 (Output) data length loaded from the backup file (in byte)
*
*	NOTE: If just want to check whether backup files existing, the caller is allowed to assign a
*			NULL pointer to pBuff; the other parameter pLength is used to return the number
*			of these backup files, so it should not be NULL.
*
* Return:
*	Error code
******************************************************************************/
GPSAppDataBackupError_t GPSAppDataBackupLoad(
	kal_uint8* pBuff,
	kal_uint16* pLength
	)
{
	GPSAppDataBackupError_t ErrCode = GPSAPP_DATABACKUP_ERROR_NONE;
	kal_int32 FileID;
	kal_uint16 FileName[GPSAPP_DATABACKUP_FULLPATHNAME_LEN_MAX];
	FS_HANDLE file_handle;
	int result;
	unsigned int len;

	if (pBuff == NULL && pLength == NULL)
	{
		return GPSAPP_DATABACKUP_ERROR_INVALID_PARAM;
	}
	//take the semaphore
	kal_take_sem(gGPSAppDataBackupSem, KAL_INFINITE_WAIT);

	gGPSAppDataBackupCurrLoadingFileID = -1;
	
	if (pBuff == NULL)
	{
		//just inquery file amount
		*pLength = GPSAppDataBackupGetFileAmount();
		ErrCode = GPSAPP_DATABACKUP_ERROR_NONE;
		goto _RelSem_Return_;
	}

	//apply file name
	if ((FileID = GPSAppDataBackupApplyCell(FileName, CELLATTR_OCCUPIED)) < 0)
	{
		ErrCode = GPSAPP_DATABACKUP_ERROR_STORAGE_EMPTY;
		goto _RelSem_Return_;
	}
	//save file ID
	gGPSAppDataBackupCurrLoadingFileID = FileID;
	//create file
	file_handle = FS_Open(FileName, FS_READ_ONLY);
	if (file_handle < FS_NO_ERROR)
	{
		//fail to open
		ErrCode = GPSAPP_DATABACKUP_ERROR_OPEN_FAIL;
		goto _RelSem_Return_;
	}
	//read
	result = FS_Read(file_handle, pBuff, *pLength, &len);
	FS_Close(file_handle);
	if (result != FS_NO_ERROR)
	{
		//read fail
		ErrCode = GPSAPP_DATABACKUP_ERROR_READ_FAIL;
		goto _RelSem_Return_;
	}
	*pLength = len;

#if 0
	{
	GPS_GPRMC_Packed_Struct_t *pPack = (GPS_GPRMC_Packed_Struct_t *)pBuff;
	int tmpLen = len / sizeof(GPS_GPRMC_Packed_Struct_t);
	char tmpStr[128];
	int i;
	Result_t result = RESULT_ERROR;
	for (i = 0; i < tmpLen; i++)
		{
		memset(tmpStr, 0, sizeof(tmpStr));
		result = GPS_APP_GPRMC_Packed2Str(tmpStr, pPack);
		pPack++;
		trace_printf("XXX: %s", tmpStr);
		}
	}
#endif

_RelSem_Return_:
	//release semaphore
	kal_give_sem(gGPSAppDataBackupSem);
	return ErrCode;
}
Esempio n. 4
0
/*****************************************************************************
 * FUNCTION
 *  jbt_cmd_queue_nonconcurrent_processing
 * DESCRIPTION
 *  
 * PARAMETERS
 *  void
 * RETURNS
 *  void
 *****************************************************************************/
void jbt_cmd_queue_nonconcurrent_processing(void)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
    JBT_cmd_node *node;

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    kal_take_sem(jbt_cmd_process_sem, KAL_INFINITE_WAIT);

    kal_trace(TRACE_JBT_GROUP, JBT_JBT_CMD_QUEUE_NONCONCURRENT_PROCESSING);

    if (jbt_cmd_queue_context.cmd_run_no < JBT_MAX_COMMAND_NO)
    {
        kal_trace(TRACE_JBT_GROUP, JBT_JBT_CMD_LIST_REMOVE_HEAD);
        node = jbt_cmd_list_remove_head(&jbt_cmd_queue_context.cmd_list);
        jbt_cmd_queue_context.cmd_run_no++;
        kal_trace(TRACE_JBT_GROUP, JBT_JBT_CMD_QUEUE_CONTEXTCMD_RUN_NOxD, jbt_cmd_queue_context.cmd_run_no);
        kal_trace(TRACE_JBT_GROUP, JBT_NODECMD_CODExD, node->cmd_code);
        switch (node->cmd_code)
        {
            case JBT_CMDCODE_DEVICE_RESTORE_COD:
                jbt_set_local_cod_cmd_body(node->parms, BTBM_WRITE_COD_RESTORE);
                break;
            case JBT_CMDCODE_DEVICE_RESTORE_MMI:
                break;
            case JBT_CMDCODE_SET_LOCAL_COD:
                jbt_set_local_cod_cmd_body(node->parms, BTBM_WRITE_COD_MASK);
                break;
            case JBT_CMDCODE_GET_REMOTE_NAME:
                jbt_get_remote_name_cmd_body(node->parms);
                break;
            case JBT_CMDCODE_DEVICE_DISCOVERY_CMD:
                jbt_device_discovery_cmd_body(node->parms);
                break;
                /* Add 2007-1119 */
            case JBT_CMDCODE_SET_ACL_SECURITY_INFO:
                jbt_set_acl_security_cmd_body(node->parms);
                break;
            default:
                ASSERT(0);
                break;
        }
        if (node->parms != 0)
        {
            jbt_free_record(node->parms);
#ifndef JBT_SUPPORT_ADM_MEM
            jvm_free(node->parms);
#else
            kal_adm_free(jbt_get_mem_pool_id(),node->parms);
#endif
        }
        node->parms = 0;
        node->cmd_code = 0;
        kal_trace(TRACE_JBT_GROUP, JBT_JBT_CMD_LIST_INIT);
        jbt_cmd_list_init(node);
        kal_trace(TRACE_JBT_GROUP, JBT_JBT_CMD_LIST_INSERT_TAIL);
        jbt_cmd_list_insert_tail(&jbt_cmd_queue_context.empty_list, node);

    }
    kal_give_sem(jbt_cmd_process_sem);
    kal_trace(TRACE_JBT_GROUP, JBT_JBT_CMD_QUEUE_NONCONCURRENT_PROCESSING_END);

}
Esempio n. 5
0
void matv_kal_take_sem(void)
{
	if (NULL != matv_sem_id)
			kal_take_sem(matv_sem_id, KAL_INFINITE_WAIT);
}
Esempio n. 6
0
kal_bool
idp_close(
    kal_uint32 const key,
    idp_close_hook_t const hook)
{
    kal_bool result;
    idp_owner_t *owner = NULL;

    result = idp_find(key, &owner);
    if (KAL_FALSE == result)
    {
        //ASSERT(0);
        return KAL_FALSE;
    }

    result = hook(owner);

    owner->key = 0;

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

    if (kal_if_lisr())
    {
        //ASSERT(0);
        return KAL_FALSE;
    }

#if ((!defined(DRV_IDP_6252_SERIES)) && (!defined(DRV_IDP_6253_SERIES)))
    // To see if there is no one use IDP.
    {
        kal_uint32 i;
        kal_bool can_poweroff = KAL_TRUE;

        // lock all possible data paths.
        kal_take_sem(idp_owners_sem, KAL_INFINITE_WAIT);

        for (i = 0; i < MAX_CONCURRENT_DP; ++i)
        {
            if (owners[i].key != 0)
            {
                // There at least one uses IDP now, so I can not
                // power off IDP.
                can_poweroff = KAL_FALSE;
            }
        }

        if (KAL_TRUE == can_poweroff)
        {
#if defined(IDP_DRVPDN_SUPPORT)
            turn_off_idp_power();
#endif
        }

        // unlock all possible data paths.
        kal_give_sem(idp_owners_sem);
    }
#endif // ((!defined(DRV_IDP_6252_SERIES))...

    return KAL_TRUE;
}
Esempio n. 7
0
kal_bool
idp_find_empty_and_register(
    kal_uint32 * const key,
    idp_owner_t ** const owner)
{
    kal_uint32 i;
    kal_bool result = KAL_FALSE;

    if (NULL == owner)
    {
        //ASSERT(0);
        return KAL_FALSE;
    }

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

    kal_take_sem(idp_owners_sem, KAL_INFINITE_WAIT);

    for (i = 0; i < MAX_CONCURRENT_DP; ++i)
    {
        //kal_bool find_one = KAL_FALSE;

        if (0 == owners[i].key)
        {
            kal_uint32 local_key;

            while (1)
            {
                kal_bool cal_again = KAL_FALSE;

                local_key = 0;

                while (0 == local_key)
                {
                    local_key = rand();
                }

                {
                    int j;

                    for (j = 0; j < MAX_CONCURRENT_DP; ++j)
                    {
                        if (j != i)
                        {
                            if (owners[j].key == local_key)
                            {
                                cal_again = KAL_TRUE;
                            }

                            if (KAL_TRUE == cal_again)
                            {
                                break;
                            }
                        }
                    }
                }

                if (KAL_FALSE == cal_again)
                {
                    break;
                }
            }

            owners[i].key = local_key;
            (*key) = local_key;

            owners[i].task = kal_get_current_thread_ID();

            (*owner) = &(owners[i]);

            result = KAL_TRUE;

            //find_one = KAL_TRUE;
            break;
        }

        //if (KAL_TRUE == find_one)
        //{
        //  break;
        //}
    }

    kal_give_sem(idp_owners_sem);

    return result;
}