static int mdss_mdp_rotator_busy_wait(struct mdss_mdp_rotator_session *rot)
{

	mutex_lock(&rot->lock);
	if (!rot->pipe || !rot->pipe->mixer || !rot->pipe->mixer->ctl) {
		mutex_unlock(&rot->lock);
		return -ENODEV;
	}

	if (rot->busy) {
		struct mdss_mdp_ctl *ctl = rot->pipe->mixer->ctl;
		mdss_mdp_display_wait4comp(ctl);
		rot->busy = false;
		if (ctl->shared_lock)
			mutex_unlock(ctl->shared_lock);
	}
	mdss_mdp_smp_release(rot->pipe);
	mutex_unlock(&rot->lock);

	return 0;
}
static int mdss_mdp_rotator_busy_wait(struct mdss_mdp_rotator_session *rot)
{
	struct mdss_mdp_pipe *rot_pipe = NULL;
	struct mdss_mdp_ctl *ctl = NULL;

	rot_pipe = rot->pipe;
	if (!rot_pipe)
		return -ENODEV;

	ctl = rot_pipe->mixer->ctl;
	mutex_lock(&rot->lock);
	if (rot->busy) {
		pr_debug("waiting for rot=%d to complete\n", rot->pipe->num);
		mdss_mdp_display_wait4comp(ctl);
		rot->busy = false;
		mdss_mdp_smp_release(rot->pipe);
	}
	mutex_unlock(&rot->lock);

	return 0;
}
static int mdss_mdp_rotator_pipe_dequeue(struct mdss_mdp_rotator_session *rot)
{
	int rc;
	if (rot->pipe) {
		pr_debug("reusing existing session=%d\n", rot->pipe->num);
		mdss_mdp_rotator_busy_wait(rot);
		list_move_tail(&rot->head, &rotator_queue);
	} else {
		struct mdss_mdp_rotator_session *tmp;

		rot->params_changed++;
		rot->pipe = mdss_mdp_rotator_pipe_alloc();
		if (rot->pipe) {
			pr_debug("use new rotator pipe=%d\n", rot->pipe->num);

			list_add_tail(&rot->head, &rotator_queue);
		} else if (!list_empty(&rotator_queue)) {
			tmp = list_first_entry(&rotator_queue,
					       struct mdss_mdp_rotator_session,
					       head);

			rc = mdss_mdp_rotator_busy_wait(tmp);
			mdss_mdp_smp_release(tmp->pipe);
			list_del(&tmp->head);
			if (rc) {
				pr_err("no pipe attached to session=%d\n",
					tmp->session_id);
				return rc;
			} else {
				pr_debug("waited for rotator pipe=%d\n",
					  tmp->pipe->num);
			}
			rot->pipe = tmp->pipe;
			tmp->pipe = NULL;

			list_add_tail(&rot->head, &rotator_queue);
		} else {