2 * TP suspend Control Abstraction
4 * Copyright (C) RK Company
7 #ifndef _RK_TP_SUSPEND_H
8 #define _RK_TP_SUSPEND_H
9 #include <linux/module.h>
10 #include <linux/init.h>
11 #include <linux/device.h>
12 #include <linux/err.h>
14 #include <linux/notifier.h>
17 struct notifier_block fb_notif;
18 int(*tp_suspend)(struct tp_device*);
19 int(*tp_resume)(struct tp_device*);
20 struct mutex ops_lock;
23 static inline int fb_notifier_callback(struct notifier_block *self,
24 unsigned long action, void *data)
27 struct fb_event *event = data;
28 int blank_mode = *((int *)event->data);
31 tp = container_of(self, struct tp_device, fb_notif);
33 //printk("%s.....lin=%d tp->status=%x,blank_mode=%x\n",__func__,__LINE__,tp->status,blank_mode);
35 mutex_lock(&tp->ops_lock);
37 if (action == FB_EARLY_EVENT_BLANK) {
39 case FB_BLANK_UNBLANK:
42 ret = tp->tp_suspend(tp);
46 else if (action == FB_EVENT_BLANK) {
48 case FB_BLANK_UNBLANK:
55 mutex_unlock(&tp->ops_lock);
59 printk("TP_notifier_callback error action=%x,blank_mode=%x\n",(int)action,blank_mode);
66 static inline int tp_register_fb(struct tp_device *tp)
68 memset(&tp->fb_notif, 0, sizeof(tp->fb_notif));
69 tp->fb_notif.notifier_call = fb_notifier_callback;
70 mutex_init(&tp->ops_lock);
72 return fb_register_client(&tp->fb_notif);
75 static inline void tp_unregister_fb(struct tp_device *tp)
77 fb_unregister_client(&tp->fb_notif);