예제 #1
0
/**
 * @brief@  main sleep work handling function which update the flags
 * and activate and deactivate UART ,check FIFO.
 */
static void bluesleep_sleep_work(struct work_struct *work)
{
	if (bluesleep_can_sleep()) {
		/* already asleep, this is an error case */
		if (test_bit(BT_ASLEEP, &flags)) {
			BT_INFO("already asleep");
			return;
		}

		if (msm_hs_tx_empty(bsi->uport)) {
			BT_INFO("going to sleep...");
			set_bit(BT_ASLEEP, &flags);
			/*Deactivating UART */
			hsuart_power(0);
			/* UART clk is not turned off immediately. Release
			 * wakelock after 500 ms.
			 */
#ifdef USE_WAKELOCK
			wake_lock_timeout(&bsi->wake_lock, HZ / 2);
#endif
		} else {
			mod_timer(&tx_timer, jiffies + (TX_TIMER_INTERVAL * HZ));
			return;
		}
	} else {
		bluesleep_sleep_wakeup();
	}
}
예제 #2
0
/**
 * @brief@  main sleep work handling function which update the flags
 * and activate and deactivate UART ,check FIFO.
 */
static void bluesleep_sleep_work(struct work_struct *work)
{
	if (mutex_is_locked(&bluesleep_mutex))
		BT_DBG("Wait for mutex unlock in bluesleep_sleep_work");

	mutex_lock(&bluesleep_mutex);

	if (bluesleep_can_sleep()) {
		/* already asleep, this is an error case */
		if (test_bit(BT_ASLEEP, &flags)) {
			BT_DBG("already asleep");
			mutex_unlock(&bluesleep_mutex);
			return;
		}

		if (msm_hs_tx_empty(bsi->uport)) {
			if (test_bit(BT_TXDATA, &flags)) {
				BT_DBG("TXDATA remained. Wait until timer expires.");

				mod_timer(&tx_timer, jiffies + TX_TIMER_INTERVAL * HZ);
				mutex_unlock(&bluesleep_mutex);
				return;
			}

			BT_DBG("going to sleep...");

			set_bit(BT_ASLEEP, &flags);
			/*Deactivating UART */
			hsuart_power(0);

			/*Deactivating UART */
			/* UART clk is not turned off immediately. Release
			* wakelock after 500 ms.
			*/
			wake_lock_timeout(&bsi->wake_lock, HZ / 2);
			} else {
			BT_DBG("host can enter sleep but some tx remained.");

			mod_timer(&tx_timer, jiffies + TX_TIMER_INTERVAL * HZ);
			mutex_unlock(&bluesleep_mutex);
			return;
		}
	} else if (!test_bit(BT_EXT_WAKE, &flags)
			&& !test_bit(BT_ASLEEP, &flags)) {
		BT_DBG("host_wake high and BT_EXT_WAKE & BT_ASLEEP is freed.");
		mod_timer(&tx_timer, jiffies + (TX_TIMER_INTERVAL * HZ));
		if (bsi->has_ext_wake == 1) {
			gpio_set_value(bsi->ext_wake, 1);
		}
		set_bit(BT_EXT_WAKE, &flags);
	} else {
		bluesleep_sleep_wakeup();
	}
	mutex_unlock(&bluesleep_mutex);
}
/**
 * @brief@	main sleep work	handling function which	update the flags
 * and activate	and	deactivate UART	,check FIFO.
 */
static void	bluesleep_sleep_work(struct	work_struct	*work)
{
	if (bluesleep_can_sleep()) {
	    pr_info("bluesleep_can_sleep\n");
		if (test_bit(BT_ASLEEP,	&g_bs_data->flags)) {
			pr_info("already asleep");
			return;
		}
		pr_info("bt going to sleep...\n");
		set_bit(BT_ASLEEP, &g_bs_data->flags);
		wake_lock_timeout(&g_bs_data->wake_lock, HZ/2);
	} else {
	    pr_info("bluesleep_sleep_wakeup\n");
		bluesleep_sleep_wakeup();
	}
}
/**
 * @brief@  main sleep work handling function which update the flags
 * and activate and deactivate UART ,check FIFO.
 */
static void bluesleep_sleep_work(struct work_struct *work)
{
	if (bluesleep_can_sleep()) {
		/* already asleep, this is an error case */
		if (test_bit(BT_ASLEEP, &flags)) {
			if (debug_mask & DEBUG_SUSPEND)
				pr_info("already asleep\n");
			return;
		}

		if (msm_hs_tx_empty(bsi->uport)) {
			if (debug_mask & DEBUG_SUSPEND)
				pr_info("going to sleep...\n");

			set_bit(BT_ASLEEP, &flags);

			/*Deactivating UART */
			hsuart_power(0);

			/* UART clk is not turned off immediately. Release
			 * wakelock after 125 ms.
			 */
			wake_lock_timeout(&bsi->wake_lock, HZ / 8);
		} else {
			mod_timer(&tx_timer, jiffies + (TX_TIMER_INTERVAL * HZ));
			return;
		}
	} else if (test_bit(BT_EXT_WAKE, &flags)
		   && !test_bit(BT_ASLEEP, &flags)) {
		mod_timer(&tx_timer, jiffies + (TX_TIMER_INTERVAL * HZ));

		if (debug_mask & DEBUG_BTWAKE)
			pr_info("BT WAKE: set to wake\n");

		if (bsi->has_ext_wake == 1)
			gpio_set_value(bsi->ext_wake, 0);

		clear_bit(BT_EXT_WAKE, &flags);
	} else {
		bluesleep_sleep_wakeup();
	}
}
예제 #5
0
파일: bluesleep.c 프로젝트: Pafcholini/drop
/**
 * @brief@  main sleep work handling function which update the flags
 * and activate and deactivate UART ,check FIFO.
 */
static void bluesleep_sleep_work(struct work_struct *work)
{
#if 0 //For debug : defined(CONFIG_SEC_MIF_UART_SWITCH)
	int uart_sel = 0;
#endif
	if (mutex_is_locked(&bluesleep_mutex))
		BT_DBG("Wait for mutex unlock in bluesleep_sleep_work");

	if (bsi->uport == NULL) {
		BT_DBG("bluesleep_sleep_work - uport is null");
		return;
	}

	if (bsi->uport->state == NULL) {
		BT_DBG("bluesleep_sleep_work - bsi->uport->state is null");
		return;
	}

	if (bsi->uport->state->port.tty == NULL) {
		BT_DBG("bluesleep_sleep_work - bsi->uport->state->port.tty is null");
		return;
	}

	mutex_lock(&bluesleep_mutex);

	if (bluesleep_can_sleep()) {
		/* already asleep, this is an error case */
		if (test_bit(BT_ASLEEP, &flags)) {
			BT_DBG("already asleep");
			mutex_unlock(&bluesleep_mutex);
			return;
		}

		if (msm_hs_tx_empty(bsi->uport)) {
			if (test_bit(BT_TXDATA, &flags)) {
				BT_DBG("TXDATA remained. Wait until timer expires.");

				mod_timer(&tx_timer, jiffies + TX_TIMER_INTERVAL * HZ);
				mutex_unlock(&bluesleep_mutex);
				return;
			}

#if 0 //For debug : defined(CONFIG_SEC_MIF_UART_SWITCH)
			if(system_rev <= 6 /*board rev 06*/) {
				uart_sel = gpio_get_value(GPIO_UART_SEL);
			}
			else{
				uart_sel = gpio_get_value(GPIO_UART_SEL_REV07);
			}

			if (uart_sel ==1) {
				BT_DBG("bluesleep_sleep_work GPIO_UART_SEL (%d)", uart_sel);
				return;
			}
#endif
			BT_DBG("going to sleep...");

			set_bit(BT_ASLEEP, &flags);
			/*Deactivating UART */
			hsuart_power(0);

			/* Moved from Timer expired */
			if (bsi->has_ext_wake == 1)
				gpio_set_value(bsi->ext_wake, 0);
			clear_bit(BT_EXT_WAKE, &flags);

			/*Deactivating UART */
			/* UART clk is not turned off immediately. Release
			* wakelock after 500 ms.
			*/
			wake_lock_timeout(&bsi->wake_lock, HZ / 2);
			} else {
			BT_DBG("host can enter sleep but some tx remained.");

			mod_timer(&tx_timer, jiffies + TX_TIMER_INTERVAL * HZ);
			mutex_unlock(&bluesleep_mutex);
			return;
		}
	} else if (!test_bit(BT_EXT_WAKE, &flags)
			&& !test_bit(BT_ASLEEP, &flags)) {
		BT_DBG("host_wake high and BT_EXT_WAKE & BT_ASLEEP already freed.");
		mod_timer(&tx_timer, jiffies + (TX_TIMER_INTERVAL * HZ));
		if (bsi->has_ext_wake == 1) {
			gpio_set_value(bsi->ext_wake, 1);
		}
		set_bit(BT_EXT_WAKE, &flags);
	} else {
		bluesleep_sleep_wakeup();
	}
	mutex_unlock(&bluesleep_mutex);
}