software/drivers/sd8887/src/bluetooth/bt/bt_main.c
/**
 *  @brief This function enables host sleep
 *
 *  @param priv    A pointer to bt_private structure
 *  @param is_shutdown  indicate shutdown mode
 *  @return    BT_STATUS_SUCCESS or BT_STATUS_FAILURE
 */
@brief This function enables host sleep
@param priv    A pointer to bt_private structure
@param is_shutdown  indicate shutdown mode
@return    BT_STATUS_SUCCESS or BT_STATUS_FAILURE
@brief This function enables host sleep @param priv A pointer to bt_private structure @param is_shutdown indicate shutdown mode @return BT_STATUS_SUCCESS or BT_STATUS_FAILURE
int
bt_enable_hs(bt_private *priv, bool is_shutdown)
{
	struct sk_buff *skb = NULL;
	int ret = BT_STATUS_SUCCESS;
	BT_CMD *pcmd;
	ENTER();
	skb = bt_skb_alloc(sizeof(BT_CMD), GFP_ATOMIC);
	if (skb == NULL) {
		PRINTM(WARN, "No free skb\n");
		ret = BT_STATUS_FAILURE;
		goto exit;
	}
	priv->adapter->suspend_fail = FALSE;
	pcmd = (BT_CMD *)skb->data;
	pcmd->ocf_ogf =
		__cpu_to_le16((VENDOR_OGF << 10) | BT_CMD_HOST_SLEEP_ENABLE);
	pcmd->length = 0;
	bt_cb(skb)->pkt_type = MRVL_VENDOR_PKT;
	skb_put(skb, BT_CMD_HEADER_SIZE + pcmd->length);
	skb->dev = (void *)(&(priv->bt_dev.m_dev[BT_SEQ]));
	skb_queue_head(&priv->adapter->tx_queue, skb);
	priv->bt_dev.sendcmdflag = TRUE;
	priv->adapter->wait_event_timeout = is_shutdown;
	priv->bt_dev.send_cmd_opcode = __le16_to_cpu(pcmd->ocf_ogf);
	PRINTM(CMD, "Queue hs enable Command(0x%x)\n",
	       __le16_to_cpu(pcmd->ocf_ogf));
	wake_up_interruptible(&priv->MainThread.waitQ);
	if (is_shutdown) {
		if (!os_wait_timeout
		    (priv->adapter->cmd_wait_q, priv->adapter->hs_state,
		     WAIT_UNTIL_HS_STATE_CHANGED)) {
			PRINTM(MSG, "BT: Enable host sleep timeout:\n");
			priv->adapter->wait_event_timeout = FALSE;
			bt_cmd_timeout_func(priv, BT_CMD_HOST_SLEEP_ENABLE);
		}
	} else {
		if (!os_wait_interruptible_timeout
		    (priv->adapter->cmd_wait_q, priv->adapter->hs_state,
		     WAIT_UNTIL_HS_STATE_CHANGED)) {
			PRINTM(MSG, "BT: Enable host sleep timeout:\n");
			bt_cmd_timeout_func(priv, BT_CMD_HOST_SLEEP_ENABLE);
		}
	}
	OS_INT_DISABLE;
	if ((priv->adapter->hs_state == HS_ACTIVATED) ||
	    (priv->adapter->is_suspended == TRUE)) {
		OS_INT_RESTORE;
		PRINTM(MSG, "BT: suspend success! skip=%d\n",
		       priv->adapter->hs_skip);
	} else {
		priv->adapter->suspend_fail = TRUE;
		OS_INT_RESTORE;
		priv->adapter->hs_skip++;
		ret = BT_STATUS_FAILURE;
		PRINTM(MSG,
		       "BT: suspend skipped! "
		       "state=%d skip=%d ps_state= %d WakeupTries=%d\n",
		       priv->adapter->hs_state, priv->adapter->hs_skip,
		       priv->adapter->ps_state, priv->adapter->WakeupTries);
	}
exit:
	LEAVE();
	return ret;
}
int bt_enable_hs ( bt_private * priv , bool is_shutdown ) { struct sk_buff * skb = NULL ; int ret = BT_STATUS_SUCCESS ; BT_CMD * pcmd ; ENTER ( ) ; skb = bt_skb_alloc ( sizeof ( BT_CMD ) , GFP_ATOMIC ) ; if ( skb == NULL ) { PRINTM ( WARN , " \n " ) ; ret = BT_STATUS_FAILURE ; goto exit ; } priv -> adapter -> suspend_fail = FALSE ; pcmd = ( BT_CMD * ) skb -> data ; pcmd -> ocf_ogf = __cpu_to_le16 ( ( VENDOR_OGF << 10 ) | BT_CMD_HOST_SLEEP_ENABLE ) ; pcmd -> length = 0 ; bt_cb ( skb ) -> pkt_type = MRVL_VENDOR_PKT ; skb_put ( skb , BT_CMD_HEADER_SIZE + pcmd -> length ) ; skb -> dev = ( void * ) ( & ( priv -> bt_dev . m_dev [ BT_SEQ ] ) ) ; skb_queue_head ( & priv -> adapter -> tx_queue , skb ) ; priv -> bt_dev . sendcmdflag = TRUE ; priv -> adapter -> wait_event_timeout = is_shutdown ; priv -> bt_dev . send_cmd_opcode = __le16_to_cpu ( pcmd -> ocf_ogf ) ; PRINTM ( CMD , " \n " , __le16_to_cpu ( pcmd -> ocf_ogf ) ) ; wake_up_interruptible ( & priv -> MainThread . waitQ ) ; if ( is_shutdown ) { if ( ! os_wait_timeout ( priv -> adapter -> cmd_wait_q , priv -> adapter -> hs_state , WAIT_UNTIL_HS_STATE_CHANGED ) ) { PRINTM ( MSG , " \n " ) ; priv -> adapter -> wait_event_timeout = FALSE ; bt_cmd_timeout_func ( priv , BT_CMD_HOST_SLEEP_ENABLE ) ; } } else { if ( ! os_wait_interruptible_timeout ( priv -> adapter -> cmd_wait_q , priv -> adapter -> hs_state , WAIT_UNTIL_HS_STATE_CHANGED ) ) { PRINTM ( MSG , " \n " ) ; bt_cmd_timeout_func ( priv , BT_CMD_HOST_SLEEP_ENABLE ) ; } } OS_INT_DISABLE ; if ( ( priv -> adapter -> hs_state == HS_ACTIVATED ) || ( priv -> adapter -> is_suspended == TRUE ) ) { OS_INT_RESTORE ; PRINTM ( MSG , " \n " , priv -> adapter -> hs_skip ) ; } else { priv -> adapter -> suspend_fail = TRUE ; OS_INT_RESTORE ; priv -> adapter -> hs_skip ++ ; ret = BT_STATUS_FAILURE ; PRINTM ( MSG , " " " \n " , priv -> adapter -> hs_state , priv -> adapter -> hs_skip , priv -> adapter -> ps_state , priv -> adapter -> WakeupTries ) ; } exit : LEAVE ( ) ; return ret ; }
@brief This function enables host sleep
  @param priv    A pointer to bt_private structure
  @param is_shutdown  indicate shutdown mode
  @return    BT_STATUS_SUCCESS or BT_STATUS_FAILURE
@brief This function enables host sleep @param priv A pointer to bt_private structure @param is_shutdown indicate shutdown mode @return BT_STATUS_SUCCESS or BT_STATUS_FAILURE