2.0 alpha
[platform/core/system/devman.git] / devices / haptic.c
1 /*
2  *  devman
3  *
4  * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
5  *
6  * Contact: DongGi Jang <dg0402.jang@samsung.com>
7  * 
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  * http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  *
20 */ 
21
22 #include "device_engine.h"
23 #include "device_haptic.h"
24 #include "device_plugin.h"
25
26 static int get_haptic(int prop, int *val)
27 {
28         switch (prop) {
29         case HAPTIC_PROP_LEVEL:
30                 return plugin_intf->OEM_sys_get_haptic_vibetones_level(val);
31         case HAPTIC_PROP_LEVEL_MAX:
32                 return plugin_intf->OEM_sys_get_haptic_vibetones_level_max(val);
33         }
34
35         return -1;
36 }
37
38 static int set_haptic(int prop, int val)
39 {
40         switch (prop) {
41         case HAPTIC_PROP_ENABLE:
42                 return plugin_intf->OEM_sys_set_haptic_vibetones_enable(val);
43         case HAPTIC_PROP_LEVEL:
44                 return plugin_intf->OEM_sys_set_haptic_vibetones_level(val);
45         case HAPTIC_PROP_ONESHOT:
46                 return plugin_intf->OEM_sys_set_haptic_vibetones_oneshot(val);
47         }
48
49         return -1;
50 }
51
52 static struct device haptic = {
53         .devname = "haptic",
54         .set_int = set_haptic,
55         .get_int = get_haptic,
56         .devtype = DEVTYPE_HAPTIC
57 };
58
59 static void __attribute__ ((constructor)) module_init()
60 {
61         add_dev(&haptic);
62 }