[COMMON] fimc-is2: add preventing logic regarding to pattern generator on/off
authorWooki Min <wooki.min@samsung.com>
Tue, 29 May 2018 11:16:58 +0000 (20:16 +0900)
committerWooyeon Kim <wooy88.kim@samsung.com>
Fri, 6 Jul 2018 01:43:23 +0000 (10:43 +0900)
The pattern generator should be enabled while camera is not running.
So, a checking state is added if pattern generator can be enable or not.

Change-Id: I0664949d7c31c69d52cfcc68bfbfc7d8928201b4
Signed-off-by: Wooki Min <wooki.min@samsung.com>
drivers/media/platform/exynos/fimc-is2/fimc-is-core.c

index ab738eff97d12520979201ea7d65fde7279a6c12..8d6d58976edf147c33791009faa913fc559a32dc 100644 (file)
@@ -603,6 +603,8 @@ static ssize_t store_pattern_en(struct device *dev,
 {
        int ret = 0;
        unsigned long cmd;
+       struct fimc_is_core *core =
+               (struct fimc_is_core *)platform_get_drvdata(to_platform_device(dev));
 
        ret = kstrtoul(buf, 0, &cmd);
        if (ret)
@@ -611,7 +613,10 @@ static ssize_t store_pattern_en(struct device *dev,
        switch (cmd) {
        case 0:
        case 1:
-               sysfs_debug.pattern_en = cmd;
+               if (atomic_read(&core->rsccount))
+                       pr_warn("%s: patter generator cannot be enabled while camera is running.\n", __func__);
+               else
+                       sysfs_debug.pattern_en = cmd;
                break;
        default:
                pr_warn("%s: invalid paramter (%lu)\n", __func__, cmd);