gpu: add delay early_suspend for Camera App
author杜坤明 <dkm@rockchip.com>
Wed, 20 Apr 2011 04:12:37 +0000 (12:12 +0800)
committer杜坤明 <dkm@rockchip.com>
Wed, 20 Apr 2011 04:12:37 +0000 (12:12 +0800)
drivers/staging/rk29/vivante/hal/inc/gc_hal_options.h
drivers/staging/rk29/vivante/hal/os/linux/kernel/gc_hal_kernel_driver.c

index 6e480912cd9cb951c41ef2515f70564ac3292ec3..f4158b80905ca7860f988facc7e80925eaac96b5 100755 (executable)
 */
 #define gcdENABLE_MEM_CACHE                 2
 
+/*
+    gcdENABLE_DELAY_EARLY_SUSPEND
+
+    ÔÚgpu_early_suspendÖÐʹÓÃÑÓʱ¹¤×÷¶ÓÁÐÀ´Ö´ÐÐsuspend,
+    ±ÜÃâgpu_early_suspend¹ýÔçÖ´Ðе¼ÖÂÓû§Ï̵߳ÄÊÂÇ黹´¦Àí¸É¾»
+*/
+#define gcdENABLE_DELAY_EARLY_SUSPEND       0
+
 #endif /* __gc_hal_options_h_ */
 
index 986346bd9af9506b6a0d8065159b6b31e0dbae16..a3d37bc22cfc45ab4ebf6c903e0ef2c94e61986e 100755 (executable)
@@ -26,6 +26,7 @@
 #include <linux/slab.h>
 #include <linux/earlysuspend.h>
 #include <linux/delay.h>
+#include <linux/workqueue.h>
 
 #include "gc_hal_kernel_linux.h"
 #include "gc_hal_driver.h"
@@ -150,6 +151,22 @@ void gputimer_callback(unsigned long arg)
 }
 #endif
 
+#if gcdENABLE_DELAY_EARLY_SUSPEND
+struct delayed_work suspend_work;
+void real_suspend(struct work_struct *work)
+{
+    gceSTATUS status;
+
+    status = gckHARDWARE_SetPowerManagementState(galDevice->kernel->hardware, gcvPOWER_OFF);
+
+    if (gcmIS_ERROR(status))
+    {
+        printk("%s fail!\n", __func__);
+        return;
+    }
+}
+#endif
+
 int drv_open(struct inode *inode, struct file* filp)
 {
     gcsHAL_PRIVATE_DATA_PTR    private;
@@ -753,6 +770,9 @@ module_exit(drv_exit);
 #if CONFIG_HAS_EARLYSUSPEND
 static void gpu_early_suspend(struct early_suspend *h)
 {
+#if gcdENABLE_DELAY_EARLY_SUSPEND
+    schedule_delayed_work(&suspend_work, 5*HZ);
+#else
        gceSTATUS status;
 
        status = gckHARDWARE_SetPowerManagementState(galDevice->kernel->hardware, gcvPOWER_OFF);
@@ -762,12 +782,16 @@ static void gpu_early_suspend(struct early_suspend *h)
            printk("%s fail!\n", __func__);
                return;
        }
+#endif
 }
 
 static void gpu_early_resume(struct early_suspend *h)
 {
        gceSTATUS status;
-    
+
+#if gcdENABLE_DELAY_EARLY_SUSPEND
+    cancel_delayed_work_sync(&suspend_work);
+#endif
        status = gckHARDWARE_SetPowerManagementState(galDevice->kernel->hardware, gcvPOWER_ON);
 
        if (gcmIS_ERROR(status))
@@ -822,6 +846,10 @@ static int __devinit gpu_probe(struct platform_device *pdev)
     register_early_suspend(&gpu_early_suspend_info);
 #endif
 
+#if gcdENABLE_DELAY_EARLY_SUSPEND
+    INIT_DELAYED_WORK(&suspend_work, real_suspend);
+#endif
+
        ret = drv_init();
        if(!ret) {
                platform_set_drvdata(pdev,galDevice);
@@ -835,8 +863,10 @@ gpu_probe_fail:
 
 static int __devinit gpu_remove(struct platform_device *pdev)
 {
+#if gcdENABLE_DELAY_EARLY_SUSPEND
+    cancel_delayed_work_sync(&suspend_work);
+#endif
        drv_exit();
-
        return 0;
 }
 
@@ -844,7 +874,10 @@ static int __devinit gpu_suspend(struct platform_device *dev, pm_message_t state
 {
        gceSTATUS status;
        gckGALDEVICE device;
-
+    
+#if gcdENABLE_DELAY_EARLY_SUSPEND
+    cancel_delayed_work_sync(&suspend_work);
+#endif
        device = platform_get_drvdata(dev);
 
        status = gckHARDWARE_SetPowerManagementState(device->kernel->hardware, gcvPOWER_OFF);
@@ -878,6 +911,9 @@ static int __devinit gpu_resume(struct platform_device *dev)
 
 static void __devinit gpu_shutdown(struct platform_device *dev)
 {
+#if gcdENABLE_DELAY_EARLY_SUSPEND
+    cancel_delayed_work_sync(&suspend_work);
+#endif
     drv_exit();
 }