static int hci_sock_bind(struct socket *sock, struct sockaddr *addr, int addr_len)
{
	struct sockaddr_hci *haddr = (struct sockaddr_hci *) addr;
	struct sock *sk = sock->sk;
	struct hci_dev *hdev = NULL;
	int err = 0;

	BT_DBG("sock %p sk %p", sock, sk);

	if (!haddr || haddr->hci_family != AF_BLUETOOTH)
		return -EINVAL;

	lock_sock(sk);

	if (hci_pi(sk)->hdev) {
		err = -EALREADY;
		goto done;
	}

	if (haddr->hci_dev != HCI_DEV_NONE) {
		if (!(hdev = hci_dev_get(haddr->hci_dev))) {
			err = -ENODEV;
			goto done;
		}

		atomic_inc(&hdev->promisc);
	}

	hci_pi(sk)->hdev = hdev;
	sk->state = BT_BOUND;

done:
	release_sock(sk);
	return err;
}
irqreturn_t mt_bt_eirq_handler(int i, void *arg)
{
    struct hci_dev *hdev = NULL;

    //printk(KERN_ALERT "mt_bt_eirq_handler\n");
    mt_bt_disable_irq();

if(eint_handle_method == 0) {
//#ifdef CONFIG_BT_HCIUART
    /* BlueZ stack, hci_uart driver */
    hdev = hci_dev_get(0);
    if(hdev == NULL){
        /* Avoid the early interrupt before hci0 registered */
        //BT_HWCTL_ALERT("hdev is NULL\n");
    }else{
        //BT_HWCTL_ALERT("EINT arrives! notify host wakeup\n");
        printk("Send host wakeup command\n");
        hci_send_cmd(hdev, 0xFCC1, 0, NULL);
        /* enable irq after receiving host wakeup command's event */
    }
	mt_bt_enable_irq();
} else {
//#else
    /* Maybe handle the interrupt in user space? */
    eint_gen = 1;
    wake_up_interruptible(&eint_wait);
    /* Send host wakeup command in user space, enable irq then */
//#endif
}

    return IRQ_HANDLED;
}
Example #3
0
static int hci_sock_bind(struct socket *sock, struct sockaddr *addr, int addr_len)
{
	struct sockaddr_hci *haddr = (struct sockaddr_hci *) addr;
	struct sock *sk = sock->sk;
	struct hci_dev *hdev = NULL;

	DBG("sock %p sk %p", sock, sk);

	if (!haddr || haddr->hci_family != AF_BLUETOOTH)
		return -EINVAL;

	if (hci_pi(sk)->hdev) {
		/* Already bound */
		return 0;
	}

	if (haddr->hci_dev != HCI_DEV_NONE) {
		if (!(hdev = hci_dev_get(haddr->hci_dev)))
			return -ENODEV;

		hdev->flags |= HCI_SOCK;
	}

	hci_pi(sk)->hdev = hdev;
	sk->state = BT_BOUND;

	return 0;
}
Example #4
0
static void bt_reset_workqueue(struct work_struct *work)
{
    struct hci_dev *hdev;
    printk("bt reset\n");
    if( hdev = hci_dev_get(0)) {
        hci_resume_dev(hdev);
    }
}
static void mtk_wcn_bt_work_fun(struct work_struct *work)
{
    struct hci_dev *hdev = NULL;

    /* BlueZ stack, hci_uart driver */
    hdev = hci_dev_get(0);
    if(hdev == NULL){
        /* Avoid the early interrupt before hci0 registered */
        //printk(KERN_ALERT "hdev is NULL\n ");
    }else{
        //printk(KERN_ALERT "Send host wakeup command\n");
        hci_send_cmd(hdev, 0xFCC1, 0, NULL);
    }
    
    mt_bt_enable_irq();
}
Example #6
0
static int bt_earlysuspend(struct platform_device *pdev, pm_message_t state)
{
#if 0
    struct hci_dev *hdev;

    pr_info("BCM_BT: going early suspend\n");

    if( hdev = hci_dev_get(0)) {

        if (NULL != bt_dev.bt_dev_suspend) {
            bt_dev.bt_dev_suspend();
        }

    }
#endif
    return 0;
}
Example #7
0
static int bt_suspend(struct platform_device *pdev, pm_message_t state)
{
#if 0
    struct hci_dev *hdev;

    pr_info("BCM_BT: going suspend\n");

    if( hdev = hci_dev_get(0)) {
        if (NULL != bt_dev.bt_dev_off) {
            bt_dev.bt_dev_off();
        }
        /* if we do not power off bt , we should restore uart baud */
        //bt_baud = get_baud(1);
    }
#endif
    return 0;
}
Example #8
0
static int bt_lateresume(struct platform_device *pdev)
{
#if 0
    struct hci_dev *hdev;

    pr_info("BCM_BT: going later resume\n");

    if( hdev = hci_dev_get(0)) {

        if (NULL != bt_dev.bt_dev_resume) {
            bt_dev.bt_dev_resume();
        }
        /* when call the hci_dev_open after hci_dev_close, the bt will be restart */
        //hci_dev_open(0);
    }
#endif
    return 0;
}
Example #9
0
static int bt_resume(struct platform_device *pdev)
{
#if 0
    struct hci_dev *hdev;

    pr_info("BCM_BT: going resume\n");

    if( hdev = hci_dev_get(0)) {
        if (NULL != bt_dev.bt_dev_on) {
            bt_dev.bt_dev_on();
        }
        //set_baud(1, bt_baud);
        //hci_dev_close(0);
        schedule_delayed_work(&btwork, 100);
    }
#endif
    return 0;
}