/*
** Function: eng_controller_bqb_start
**
** Description:
**	  open the ttys0 and create a thread, download bt controller code
**
** Arguments:
**	 void
**
** Returns:
**	  0
**    -1 failed
*/
int eng_controller_bqb_start(void)
{
    pthread_t thread;
    int ret = -1;

    ENG_LOG(" bqb test test eng_controller_bqb_start");

    bt_hci_init_transport(&bt_fd);
    sprd_config_init(bt_fd, NULL,NULL);

    ret = pthread_create(&thread, NULL, (void *)eng_receive_data_thread, NULL);   /*create thread*/
    if(ret== -1)  {
        ENG_LOG("bqb test create thread failed");
    }

    return ret;
}
Ejemplo n.º 2
0
/** Requested operations */
static int op(bt_vendor_opcode_t opcode, void *param)
{
    int retval = 0;
    int nCnt = 0;
    int nState = -1;

    ALOGV("bt-vendor : op for %d", opcode);

    switch(opcode)
    {
        case BT_VND_OP_POWER_CTRL:
            {
                nState = *(int *) param;
                retval = hw_config(nState);
                if(nState == BT_VND_PWR_ON
                   && retval == 0
                   && is_hw_ready() == TRUE){
                    retval = 0;
                }
                else {
                    retval = -1;
                }
            }
            break;

        case BT_VND_OP_FW_CFG:
            {
                // call hciattach to initalize the stack
                if(bt_vendor_cbacks){
                   ALOGI("Bluetooth Firmware and smd is initialized");
                   bt_vendor_cbacks->fwcfg_cb(BT_VND_OP_RESULT_SUCCESS);
                }
                else{
                   ALOGE("Error : hci, smd initialization Error");
                   bt_vendor_cbacks->fwcfg_cb(BT_VND_OP_RESULT_FAIL);
                }
            }
            break;

        case BT_VND_OP_SCO_CFG:
            {
                bt_vendor_cbacks->scocfg_cb(BT_VND_OP_RESULT_SUCCESS); //dummy
            }
            break;

        case BT_VND_OP_USERIAL_OPEN:
            {
                if(bt_hci_init_transport(pFd) != -1){
                    int (*fd_array)[] = (int (*) []) param;

                        (*fd_array)[CH_CMD] = pFd[0];
                        (*fd_array)[CH_EVT] = pFd[0];
                        (*fd_array)[CH_ACL_OUT] = pFd[1];
                        (*fd_array)[CH_ACL_IN] = pFd[1];
                }
                else {
                    retval = -1;
                    break;
                }
                retval = 2;
            }
            break;

        case BT_VND_OP_USERIAL_CLOSE:
            {
                 bt_hci_deinit_transport(pFd);
            }
            break;

        case BT_VND_OP_GET_LPM_IDLE_TIMEOUT:
            break;

        case BT_VND_OP_LPM_SET_MODE:
            {
                bt_vendor_cbacks->lpm_cb(BT_VND_OP_RESULT_SUCCESS); //dummy
            }
            break;

        case BT_VND_OP_LPM_WAKE_SET_STATE:
            break;
        case BT_VND_OP_EPILOG:
            {
#if (HW_NEED_END_WITH_HCI_RESET == FALSE)
                if (bt_vendor_cbacks)
                {
                    bt_vendor_cbacks->epilog_cb(BT_VND_OP_RESULT_SUCCESS);
                }
#else
                hw_epilog_process();
#endif
            }
            break;
    }

    return retval;
}