Example #1
0
static void *bt_eint_monitor(void *ptr)
{
    int ret = 0;
    struct pollfd fds[1];
    int bt_fd;

    LOG_TRC();

    bt_fd = (int)ptr;
    eint_fd = open(BTWLANEM_DEVNAME, O_RDWR | O_NOCTTY);
    if (eint_fd < 0){
        LOG_ERR("Can't get %s fd to handle EINT\n", BTWLANEM_DEVNAME);
        return 0;
    }
    
    unmaskEint();
    
    fds[0].fd = eint_fd;
    fds[0].events = POLLIN;

    while(1) {
        ret = poll(fds, 1, -1);
        if(ret > 0){
            if(fds[0].revents & POLLIN){
                LOG_DBG("EINT arrives! Notify host wake up\n");
                sleep_mode = 0;
                if(bt_host_wake_up(bt_fd) < 0){
                    LOG_ERR("Send host wake up command fails\n");
                }
                unmaskEint();
            }
            else if(fds[0].revents & POLLERR){
                LOG_DBG("EINT monitor needs to exit\n");
                goto exit;
            }
        }
        else if ((ret == -1) && (errno == EINTR)){
            LOG_ERR("poll error EINTR\n");
        }
        else{
            LOG_ERR("poll error %s(%d)!\n", strerror(errno), errno);
            goto exit;
        }
    }
exit:
    close(eint_fd);
    eint_fd = -1;
    return 0;
}
Example #2
0
/* Handle things after controller is waked up 
(command complete of FCC1 is received) */
void Radio_hostWakedup(void)
{
    unmaskEint();
}
Example #3
0
static BtStatus GORM_Init(void)
{
#if !defined(__ANDROID_EMULATOR__)
    BtStatus status = BT_STATUS_FAILED;
    void *lib_handle;
    SET_UART_SETUP SetUartSetup = NULL;
    INIT mtk = NULL;

    bt_android_log("[BT] + GORM_Init");
    
    /* load BT driver */
    lib_handle = getDriverHandle();    
    if (!lib_handle) 
    {
        bt_prompt_trace(MOD_BT, "[UART][ERR] dlopen failed : %s\n", dlerror());
        return BT_STATUS_FAILED;
    }    

    mtk = dlsym(lib_handle, "mtk");
#ifdef __MTK_STP_SUPPORTED__
    if (!mtk) 
#else
    SetUartSetup = dlsym(lib_handle, "SetUartSetup");
    if ((!mtk) || (!SetUartSetup)) 
#endif
    {
        bt_prompt_trace(MOD_BT, "[UART][ERR] Can not find functions %s\n", dlerror());
        bt_android_log("[BT][ERR] GORM_Init : Can not find functions %s", dlerror());
        dlclose(lib_handle);
        return BT_STATUS_FAILED;
    }
#ifdef __MTK_STP_SUPPORTED__
    bt_android_log("[BT] + call mtk");
    if(!mtk(commPort, NULL, NULL))
    {
        bt_prompt_trace(MOD_BT, "[UART] mtk call return success\n");
        status = BT_STATUS_SUCCESS;
    }
    else
    {
        bt_prompt_trace(MOD_BT, "[UART][ERR] mtk call return failed\n");
        bt_android_log("[BT][ERR] mtk call return failed");
        status = BT_STATUS_FAILED;
    }
    bt_android_log("[BT] - call mtk : status=%d", status);
#else
    /* Start init  */
    SetUartSetup(setup_uart_param);
    if(commPort >= 0)
    {
        struct uart_t u;
        struct termios ti;
        memset(&u, 0, sizeof(u));
        u.flags &= ~FLOW_CTL_MASK;
        u.flags |=  FLOW_CTL_SW;
        u.speed = 3250000;
        //u.speed = 115200;
        
        if (tcgetattr(commPort, &ti) < 0) 
        {
            bt_prompt_trace(MOD_BT, "[UART][ERR] Can't get port settings");
        }
        else
        {
            bt_prompt_trace(MOD_BT, "[UART] Call mtk function\n");
            bt_android_log("[BT] + call mtk");
            if(!mtk(commPort, &u, &ti))
            {
                int val;
                bt_prompt_trace(MOD_BT, "[UART] mtk call return success\n");
                /* uart handle is opened as blocking, change it to non-blocking */
                if ( setUartBlockMode(commPort, 0) < 0 ) {
                    bt_android_log("[BT][ERR] setUartBlockMode return failed");
                    status = BT_STATUS_FAILED;
                }else {
                    status = BT_STATUS_SUCCESS;
                    unmaskEint();
                }
            }
            else
            {
                bt_prompt_trace(MOD_BT, "[UART][ERR] mtk call return failed\n");
                bt_android_log("[BT][ERR] mtk call return failed");
                status = BT_STATUS_FAILED;
            }
            bt_android_log("[BT] - call mtk : status=%d", status);
        }                
    }
    else
    {
        bt_prompt_trace(MOD_BT, "[UART][ERR] commPort is not opened yet\n");
    }
#endif
    /* Close lib_handler */
    dlclose(lib_handle);
    bt_android_log("[BT] - GORM_Init : ret=%d", status);
    return status;
#else /* !defined(__ANDROID_EMULATOR__) */
    return BT_STATUS_SUCCESS;
#endif
}