From d916b9f291cdc66bbe894fece5d91167cadaa563 Mon Sep 17 00:00:00 2001 From: JP Abgrall Date: Fri, 30 Mar 2012 19:13:52 -0700 Subject: S5PC11X: FIMC: Handle off mode in suspend()/resume() Avoid clock gating in suspend()/resume() when ctrl->status is set to FIMC_OFF_SLEEP because the fimc doesn't support it. Prevent the fimc from turning on during resume when it is not used. This patch fixes issue 5400100, which says mp3 playback power usage increased by 33%. Also, don't allow capture modue op during output mode, and vice-versa. Change-Id: I705523a674f1102a77195ee2ee170935bcf4d41e Signed-off-by: jung-min.oh --- drivers/media/video/samsung/fimc/fimc_capture.c | 6 ++++++ drivers/media/video/samsung/fimc/fimc_dev.c | 6 ++---- drivers/media/video/samsung/fimc/fimc_output.c | 6 ++++++ 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/drivers/media/video/samsung/fimc/fimc_capture.c b/drivers/media/video/samsung/fimc/fimc_capture.c index 2367bf6..2028bf9 100644 --- a/drivers/media/video/samsung/fimc/fimc_capture.c +++ b/drivers/media/video/samsung/fimc/fimc_capture.c @@ -690,6 +690,12 @@ int fimc_enum_fmt_vid_capture(struct file *file, void *fh, fimc_dbg("%s\n", __func__); + if (ctrl->out) { + fimc_err("%s: fimc is already used for output mode\n", + __func__); + return -EINVAL; + } + if (!ctrl->cam || !ctrl->cam->sd) { fimc_err("%s: No capture device.\n", __func__); return -ENODEV; diff --git a/drivers/media/video/samsung/fimc/fimc_dev.c b/drivers/media/video/samsung/fimc/fimc_dev.c index 1441367..e9f088a 100644 --- a/drivers/media/video/samsung/fimc/fimc_dev.c +++ b/drivers/media/video/samsung/fimc/fimc_dev.c @@ -1503,13 +1503,12 @@ int fimc_suspend(struct platform_device *pdev, pm_message_t state) if (ctrl->out) fimc_suspend_out(ctrl); - else if (ctrl->cap) fimc_suspend_cap(ctrl); else ctrl->status = FIMC_OFF_SLEEP; - if (atomic_read(&ctrl->in_use)) + if (atomic_read(&ctrl->in_use) && ctrl->status != FIMC_OFF_SLEEP) fimc_clk_en(ctrl, false); return 0; @@ -1624,12 +1623,11 @@ int fimc_resume(struct platform_device *pdev) ctrl = get_fimc_ctrl(id); pdata = to_fimc_plat(ctrl->dev); - if (atomic_read(&ctrl->in_use)) + if (atomic_read(&ctrl->in_use) && ctrl->status != FIMC_OFF_SLEEP) fimc_clk_en(ctrl, true); if (ctrl->out) fimc_resume_out(ctrl); - else if (ctrl->cap) fimc_resume_cap(ctrl); else diff --git a/drivers/media/video/samsung/fimc/fimc_output.c b/drivers/media/video/samsung/fimc/fimc_output.c index c66f995..6bf839d 100644 --- a/drivers/media/video/samsung/fimc/fimc_output.c +++ b/drivers/media/video/samsung/fimc/fimc_output.c @@ -2158,6 +2158,12 @@ int fimc_g_fmt_vid_out(struct file *filp, void *fh, struct v4l2_format *f) fimc_info1("%s: called\n", __func__); + if (ctrl->cap) { + fimc_err("%s: fimc is already used for capture mode\n", + __func__); + return -EINVAL; + } + if (!out) { out = kzalloc(sizeof(*out), GFP_KERNEL); if (!out) { -- cgit v1.1