4 * Copyright (c) 2012 - 2013 Samsung Electronics Co., Ltd.
6 * Licensed under the Apache License, Version 2.0 (the License);
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
26 enum device_priority {
27 DEVICE_PRIORITY_NORMAL = 0,
32 NORMAL_MODE = 0x00000001,
33 AMBIENT_MODE = 0x00000002,
34 CORE_LOGIC_MODE = 0x00010000,
35 TOUCH_SCREEN_OFF_MODE = 0x00020000,
36 LCD_PANEL_OFF_MODE = 0x00040000,
37 LCD_PHASED_TRANSIT_MODE = 0x00080000,
38 LCD_ON_BY_GESTURE = 0x00100000,
39 LCD_ON_BY_POWER_KEY = 0x00200000,
40 LCD_ON_BY_EVENT = 0x00400000,
41 LCD_ON_BY_TOUCH = 0x00800000,
45 enum device_priority priority;
47 void (*init) (void *data);
48 void (*exit) (void *data);
49 int (*start) (enum device_flags flags);
50 int (*stop) (enum device_flags flags);
52 int (*execute) (void *data);
55 enum device_ops_status {
56 DEVICE_OPS_STATUS_UNINIT,
57 DEVICE_OPS_STATUS_START,
58 DEVICE_OPS_STATUS_STOP,
59 DEVICE_OPS_STATUS_MAX,
62 void devices_init(void *data);
63 void devices_exit(void *data);
65 static inline int device_start(const struct device_ops *dev)
67 if (dev && dev->start)
68 return dev->start(NORMAL_MODE);
73 static inline int device_stop(const struct device_ops *dev)
76 return dev->stop(NORMAL_MODE);
81 static inline int device_exit(const struct device_ops *dev, void *data)
83 if (dev && dev->exit) {
91 static inline int device_execute(const struct device_ops *dev, void *data)
93 if (dev && dev->execute)
94 return dev->execute(data);
99 static inline int device_get_status(const struct device_ops *dev)
101 if (dev && dev->status)
102 return dev->status();
107 #define DEVICE_OPS_REGISTER(dev) \
108 static void __CONSTRUCTOR__ module_init(void) \
112 static void __DESTRUCTOR__ module_exit(void) \
114 remove_device(dev); \
117 void add_device(const struct device_ops *dev);
118 void remove_device(const struct device_ops *dev);
120 const struct device_ops *find_device(const char *name);
121 int check_default(const struct device_ops *dev);
123 #define NOT_SUPPORT_OPS(dev) \
124 ((check_default(dev))? 1 : 0)
126 #define FIND_DEVICE_INT(dev, name) do { \
127 if (!dev) dev = find_device(name); if(check_default(dev)) return -ENODEV; \
130 #define FIND_DEVICE_VOID(dev, name) do { \
131 if (!dev) dev = find_device(name); if(check_default(dev)) return; \