Skip to content

Commit

Permalink
msm: msm_fb: wait for VSYNC instead of DMA_P for LCDC
Browse files Browse the repository at this point in the history
This is a follow up to previous changes:-
"Replace wait for DMA_P with VSYNC in Pan_display Path" and
"wait for VSYNC instead of DMA_P for commit completion" extending
for LCDC/LVDS display.

Change-Id: I1613f6196bf115b396bb9536283d9e95615c4a28
Signed-off-by: Justin Philip <jphili@codeaurora.org>
  • Loading branch information
Justin Philip authored and arco committed May 27, 2015
1 parent 0ba67ca commit 7ac69dd
Showing 1 changed file with 21 additions and 10 deletions.
31 changes: 21 additions & 10 deletions drivers/video/msm/mdp4_overlay_lcdc.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright (c) 2009-2013, The Linux Foundation. All rights reserved.
/* Copyright (c) 2009-2015, The Linux Foundation. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 and
Expand Down Expand Up @@ -69,6 +69,7 @@ static struct vsycn_ctrl {
struct vsync_update vlist[2];
int vsync_irq_enabled;
ktime_t vsync_time;
wait_queue_head_t wait_queue_internal;
wait_queue_head_t wait_queue;
} vsync_ctrl_db[MAX_CONTROLLER];

Expand Down Expand Up @@ -291,10 +292,6 @@ int mdp4_lcdc_pipe_commit(int cndx, int wait)
/* kickoff overlay engine */
mdp4_stat.kickoff_ov0++;
outpdw(MDP_BASE + 0x0004, 0);
} else {
/* schedule second phase update at dmap */
INIT_COMPLETION(vctrl->dmap_comp);
vsync_irq_enable(INTR_DMA_P_DONE, MDP_DMAP_TERM);
}
spin_unlock_irqrestore(&vctrl->spin_lock, flags);

Expand All @@ -304,7 +301,7 @@ int mdp4_lcdc_pipe_commit(int cndx, int wait)
if (pipe->ov_blt_addr)
mdp4_lcdc_wait4ov(0);
else
mdp4_lcdc_wait4dmap(0);
mdp4_lcdc_wait4vsync(0);
}

return cnt;
Expand Down Expand Up @@ -356,22 +353,27 @@ void mdp4_lcdc_vsync_ctrl(struct fb_info *info, int enable)
void mdp4_lcdc_wait4vsync(int cndx)
{
struct vsycn_ctrl *vctrl;
struct mdp4_overlay_pipe *pipe;
ktime_t timestamp;
unsigned long flags;

if (cndx >= MAX_CONTROLLER) {
pr_err("%s: out or range: cndx=%d\n", __func__, cndx);
return;
}

vctrl = &vsync_ctrl_db[cndx];
pipe = vctrl->base_pipe;

if (atomic_read(&vctrl->suspend) > 0)
return;

spin_lock_irqsave(&vctrl->spin_lock, flags);
timestamp = vctrl->vsync_time;
spin_unlock_irqrestore(&vctrl->spin_lock, flags);

mdp4_lcdc_vsync_irq_ctrl(cndx, 1);

wait_event_interruptible_timeout(vctrl->wait_queue, 1,
wait_event_timeout(vctrl->wait_queue_internal,
!ktime_equal(timestamp, vctrl->vsync_time),
msecs_to_jiffies(VSYNC_PERIOD * 8));

mdp4_lcdc_vsync_irq_ctrl(cndx, 0);
Expand Down Expand Up @@ -420,18 +422,25 @@ ssize_t mdp4_lcdc_show_event(struct device *dev,
ssize_t ret = 0;
u64 vsync_tick;
ktime_t timestamp;
unsigned long flags;

cndx = 0;
vctrl = &vsync_ctrl_db[0];

spin_lock_irqsave(&vctrl->spin_lock, flags);
timestamp = vctrl->vsync_time;
spin_unlock_irqrestore(&vctrl->spin_lock, flags);

ret = wait_event_interruptible(vctrl->wait_queue,
!ktime_equal(timestamp, vctrl->vsync_time) &&
vctrl->vsync_irq_enabled);
if (ret == -ERESTARTSYS)
return ret;

spin_lock_irqsave(&vctrl->spin_lock, flags);
vsync_tick = ktime_to_ns(vctrl->vsync_time);
spin_unlock_irqrestore(&vctrl->spin_lock, flags);

ret = scnprintf(buf, PAGE_SIZE, "VSYNC=%llu", vsync_tick);
buf[strlen(buf) + 1] = '\0';
return ret;
Expand Down Expand Up @@ -459,6 +468,7 @@ void mdp4_lcdc_vsync_init(int cndx)
init_completion(&vctrl->ov_comp);
atomic_set(&vctrl->suspend, 1);
spin_lock_init(&vctrl->spin_lock);
init_waitqueue_head(&vctrl->wait_queue_internal);
init_waitqueue_head(&vctrl->wait_queue);
}

Expand Down Expand Up @@ -887,6 +897,7 @@ void mdp4_primary_vsync_lcdc(void)

spin_lock(&vctrl->spin_lock);
vctrl->vsync_time = ktime_get();
wake_up_all(&vctrl->wait_queue_internal);
wake_up_interruptible_all(&vctrl->wait_queue);
spin_unlock(&vctrl->spin_lock);
}
Expand Down Expand Up @@ -1077,7 +1088,7 @@ void mdp4_lcdc_overlay(struct msm_fb_data_type *mfd)
if (pipe->ov_blt_addr)
mdp4_lcdc_wait4ov(cndx);
else
mdp4_lcdc_wait4dmap(cndx);
mdp4_lcdc_wait4vsync(cndx);
}

mdp4_overlay_mdp_perf_upd(mfd, 0);
Expand Down

0 comments on commit 7ac69dd

Please sign in to comment.