summaryrefslogtreecommitdiff
path: root/drivers/media
diff options
context:
space:
mode:
authorpeter mikolajczyk <pmikolajczyk@nvidia.com>2011-11-09 14:19:06 -0800
committerDan Willemsen <dwillemsen@nvidia.com>2011-11-30 21:49:59 -0800
commitc3510d18d039e966bf8f115cc317b525abb615bf (patch)
treebe1568916d3e141916d14a8d5a5cd29f9be13398 /drivers/media
parenta524f1b30b495babf871d8010ba7292e700610cb (diff)
media: video: tegra: Prevent sleep when cam open
Adding a check for camera open in order to prevent driver from allowing the system to go to sleep. Application layers must release camera before suspend is called bug 870768 Reviewed-on: http://git-master/r/#change,60307 (cherry picked from commit I5df86a22e46af724fd2cf4d8a0440350cbd4aba2) Change-Id: I36e8d7c3b8b8002fc195e8f6bb0e0a228a397c2d Reviewed-on: http://git-master/r/63384 Reviewed-by: Lokesh Pathak <lpathak@nvidia.com> Tested-by: Lokesh Pathak <lpathak@nvidia.com> Rebase-Id: R35ad971920f255e1427dbb87e8c76375971a9c9a
Diffstat (limited to 'drivers/media')
-rw-r--r--drivers/media/video/tegra/tegra_camera.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/drivers/media/video/tegra/tegra_camera.c b/drivers/media/video/tegra/tegra_camera.c
index 95d477ee8cca..a21051690f84 100644
--- a/drivers/media/video/tegra/tegra_camera.c
+++ b/drivers/media/video/tegra/tegra_camera.c
@@ -111,6 +111,18 @@ struct tegra_camera_block tegra_camera_block[] = {
#define TEGRA_CAMERA_PD2VI_CLK_SEL_VI_SENSOR_CLK (1<<25)
#define TEGRA_CAMERA_PD2VI_CLK_SEL_PD2VI_CLK 0
+static bool tegra_camera_enabled()
+{
+ bool ret = false;
+
+ mutex_lock(&tegra_camera_lock);
+ ret = tegra_camera_block[TEGRA_CAMERA_MODULE_ISP].is_enabled == true ||
+ tegra_camera_block[TEGRA_CAMERA_MODULE_VI].is_enabled == true ||
+ tegra_camera_block[TEGRA_CAMERA_MODULE_CSI].is_enabled == true;
+ mutex_unlock(&tegra_camera_lock);
+ return ret;
+}
+
static int tegra_camera_clk_set_rate(struct tegra_camera_clk_info *info)
{
u32 offset;
@@ -355,9 +367,28 @@ static int tegra_camera_remove(struct platform_device *pdev)
return 0;
}
+static int tegra_camera_suspend(struct platform_device *pdev, pm_message_t state)
+{
+ int ret = 0;
+
+ if (tegra_camera_enabled()) {
+ ret = -EBUSY;
+ pr_info("tegra_camera cannot suspend, application is holding on to camera. \n");
+ }
+
+ return ret;
+}
+
+static int tegra_camera_resume(struct platform_device *pdev)
+{
+ return 0;
+}
+
static struct platform_driver tegra_camera_driver = {
.probe = tegra_camera_probe,
.remove = tegra_camera_remove,
+ .suspend = tegra_camera_suspend,
+ .resume = tegra_camera_resume,
.driver = { .name = TEGRA_CAMERA_NAME }
};