⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 aud_bt_hfp.c

📁 最新MTK手机软件源码
💻 C
📖 第 1 页 / 共 2 页
字号:
/*****************************************************************************
*  Copyright Statement:
*  --------------------
*  This software is protected by Copyright and the information contained
*  herein is confidential. The software may not be copied and the information
*  contained herein may not be used or disclosed except with the written
*  permission of MediaTek Inc. (C) 2005
*
*  BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
*  THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
*  RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
*  AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
*  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
*  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
*  NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
*  SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
*  SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
*  THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
*  NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
*  SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
*
*  BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
*  LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
*  AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
*  OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
*  MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE. 
*
*  THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
*  WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
*  LAWS PRINCIPLES.  ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
*  RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
*  THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
*
*****************************************************************************/

/*******************************************************************************
 * Filename:
 * ---------
 * aud_bt_hfp.c
 *
 * Project:
 * --------
 *   Maui
 *
 * Description:
 * ------------
 *   This file includes BT HFP service functions
 *
 * Author:
 * -------
 * -------
 *
 *==============================================================================
 *             HISTORY
 * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!! 
 *------------------------------------------------------------------------------
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 * removed!
 *------------------------------------------------------------------------------
 * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!! 
 *==============================================================================
 *******************************************************************************/

#ifndef MED_NOT_PRESENT

/*==== INCLUDES =========*/
#include "kal_release.h"
#include "kal_trace.h"
#include "stack_common.h"
#include "stack_msgs.h"
#include "app_ltlcom.h" /* Task message communiction */
#include "syscomp_config.h"
#include "task_config.h"        /* Task creation */
#include "stacklib.h"   /* Basic type for dll, evshed, stacktimer */
#include "event_shed.h" /* Event scheduler */
#include "stack_timer.h"        /* Stack timer */

/* global includes */
#include "l1audio.h"
#include "device.h"
#include "resource_audio.h"
#include "fat_fs.h"
#include "nvram_enums.h"
#include "nvram_struct.h"
#include "nvram_user_defs.h"
#include "nvram_data_items.h"
#include "custom_nvram_editor_data_item.h"
#include "custom_equipment.h"

/* local includes */
#include "med_global.h"
#include "aud_defs.h"
#include "med_struct.h"
#include "med_api.h"
#include "med_context.h"
#include "med_main.h"
#include "aud_main.h"
#include "med_utility.h"

#ifdef __AUD_TRACE_ON__
#include "med_trc.h"
#endif 

#ifdef __MED_BT_HFP_MOD__
#include "bt_dm_struct.h"
#include "bt_hfg_struct.h"
#include "bt_hfg.h"

extern kal_bool aud_bt_hfp_sco_connect_req(void);
extern kal_bool aud_bt_hfp_sco_disconnect_req(void);

typedef struct
{
    module_type src_mod_id;
    kal_uint16 connect_id;
    kal_bool disabled;
    kal_bool audio_path_on;
    kal_uint8 state;
    kal_uint8 next_cmd;
} aud_bt_hfp_context_struct;

aud_bt_hfp_context_struct aud_bt_hfp_ctx;


/*****************************************************************************
 * FUNCTION
 *  aud_bt_hfp_reset_state
 * DESCRIPTION
 *  
 * PARAMETERS
 *  void
 * RETURNS
 *  void
 *****************************************************************************/
void aud_bt_hfp_reset_state(void)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    AUD_BT_HFP_FUNC_ENTRY(AUD_BT_HFP_RESET_STATE)
    
    aud_bt_hfp_ctx.src_mod_id = MOD_MMI;  /* set MMI as the default receiver */
    
    AUD_BT_HFP_ENTER_STATE(AUD_BT_HFP_STATE_IDLE);
    aud_bt_hfp_ctx.audio_path_on = KAL_FALSE;
    aud_bt_hfp_ctx.next_cmd = AUD_BT_HFP_CMD_NONE;
    aud_bt_hfp_ctx.disabled = KAL_FALSE;
}


/*****************************************************************************
 * FUNCTION
 *  aud_bt_hfp_init
 * DESCRIPTION
 *  
 * PARAMETERS
 *  void
 * RETURNS
 *  void
 *****************************************************************************/
void aud_bt_hfp_init(void)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    aud_bt_hfp_reset_state();
}


/*****************************************************************************
 * FUNCTION
 *  aud_bt_hfp_close_req_hdlr
 * DESCRIPTION
 *  
 * PARAMETERS
 *  ilm_ptr     [?]     
 * RETURNS
 *  void
 *****************************************************************************/
void aud_bt_hfp_close_req_hdlr(ilm_struct *ilm_ptr)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    /* media_bt_audio_close_req_struct* msg_p = (media_bt_audio_close_req_struct*)ilm_ptr->local_para_ptr; */

    AUD_BT_HFP_FUNC_ENTRY2(AUD_BT_HFP_CLOSE_REQ_HDLR, aud_bt_hfp_ctx.state, aud_bt_hfp_ctx.audio_path_on)
    aud_bt_hfp_set_audio_path(KAL_FALSE);

    if (!aud_bt_hfp_sco_disconnect_req())
    {
        aud_send_bt_audio_close_cnf(aud_bt_hfp_ctx.src_mod_id, BT_HFP, MED_RES_OK);
    }
}


/*****************************************************************************
 * FUNCTION
 *  aud_bt_hfp_open_req_hdlr
 * DESCRIPTION
 *  
 * PARAMETERS
 *  ilm_ptr     [?]     
 * RETURNS
 *  void
 *****************************************************************************/
void aud_bt_hfp_open_req_hdlr(ilm_struct *ilm_ptr)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
    media_bt_audio_open_req_struct *msg_p = (media_bt_audio_open_req_struct*) ilm_ptr->local_para_ptr;

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    AUD_BT_HFP_FUNC_ENTRY2(AUD_BT_HFP_OPEN_REQ_HDLR, aud_bt_hfp_ctx.state, aud_bt_hfp_ctx.audio_path_on)
    
    aud_bt_hfp_ctx.src_mod_id = ilm_ptr->src_mod_id;
    aud_bt_hfp_ctx.connect_id = msg_p->connect_id;

    if( aud_bt_hfp_ctx.state == AUD_BT_HFP_STATE_IDLE )
    {
        ASSERT(aud_bt_hfp_ctx.next_cmd == AUD_BT_HFP_CMD_NONE);

        aud_bt_hfp_sco_connect_req();
    }
    else
    {
        aud_send_bt_audio_open_cnf(aud_bt_hfp_ctx.src_mod_id, BT_HFP, MED_RES_BUSY);
    }
}


/*****************************************************************************
 * FUNCTION
 *  aud_bt_hfp_turn_on_req_hdlr
 * DESCRIPTION
 *  
 * PARAMETERS
 *  ilm_ptr     [?]     
 * RETURNS
 *  void
 *****************************************************************************/
void aud_bt_hfp_turn_on_req_hdlr(ilm_struct *ilm_ptr)
{
    /* don't use this function until we need it */
    ASSERT(0);
}


/*****************************************************************************
 * FUNCTION
 *  aud_bt_hfp_turn_off_req_hdlr
 * DESCRIPTION
 *  
 * PARAMETERS
 *  ilm_ptr     [?]     
 * RETURNS
 *  void
 *****************************************************************************/
void aud_bt_hfp_turn_off_req_hdlr(ilm_struct *ilm_ptr)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    AUD_BT_HFP_FUNC_ENTRY2( AUD_BT_HFP_TURN_OFF_REQ_HDLR, aud_bt_hfp_ctx.state, aud_bt_hfp_ctx.disabled );

    if (!aud_bt_hfp_ctx.disabled)
    {
        aud_bt_hfp_set_audio_path( KAL_FALSE );
        aud_bt_hfp_sco_disconnect_req();
        aud_bt_hfp_ctx.disabled = KAL_TRUE;
    }
}


/*****************************************************************************
 * FUNCTION
 *  aud_bt_hfp_sco_connect_req
 * DESCRIPTION
 *  
 * PARAMETERS
 *  void
 * RETURNS
 *  
 *****************************************************************************/
kal_bool aud_bt_hfp_sco_connect_req(void)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
    kal_bool processed = KAL_TRUE;

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

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -