display: remove codes related with vconf keys which are not used
[platform/core/system/libdevice-node.git] / devices / display.c
1 /*
2  * device-node
3  * Copyright (c) 2012 Samsung Electronics Co., Ltd.
4  *
5  * Licensed under the Apache License, Version 2.0 (the License);
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  *     http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17
18
19 #include <stdio.h>
20 #include <vconf.h>
21 #include "device-internal.h"
22
23 #define PROPERTY_MASK                   0x0F
24 #define PROPERTY_PROP(val)              ((val) & PROPERTY_MASK)
25 #define PROPERTY_INDEX(val)             ((val) >> 4)
26
27 static int display_get_prop(int __prop, int *val)
28 {
29         int prop = PROPERTY_PROP(__prop);
30         int index = PROPERTY_INDEX(__prop);
31         int lux = index;
32         int ps_disp_stat = 0;
33         int disp_cnt;
34         int r;
35
36         r = PLUGIN_GET(display_count, &disp_cnt);
37         if (r < 0) {
38                 _E("Get display count failed");
39                 return -1;
40         }
41
42         if (prop != PROP_DISPLAY_BRIGHTNESS_BY_LUX) {
43                 if (index >= disp_cnt) {
44                         _E("Invalid Argument: index(%d) > max(%d)", index, disp_cnt);
45                         return -1;
46                 }
47         }
48
49         switch (prop) {
50         case PROP_DISPLAY_DISPLAY_COUNT:
51                 *val = disp_cnt;
52                 return 0;
53         case PROP_DISPLAY_MAX_BRIGHTNESS:
54                 return PLUGIN_GET(backlight_max_brightness, index, val);
55         case PROP_DISPLAY_BRIGHTNESS:
56                 return PLUGIN_GET(backlight_brightness, index, val, ps_disp_stat);
57         case PROP_DISPLAY_ACL_CONTROL:
58                 return PLUGIN_GET(backlight_acl_control, index, val);
59         case PROP_DISPLAY_ONOFF:
60                 return PLUGIN_GET(lcd_power, index, val);
61         case PROP_DISPLAY_BRIGHTNESS_BY_LUX:
62                 return PLUGIN_GET(backlight_brightness_by_lux, lux, val);
63         case PROP_DISPLAY_IMAGE_ENHANCE_MODE:
64                 return PLUGIN_GET(image_enhance_mode, val);
65         case PROP_DISPLAY_IMAGE_ENHANCE_SCENARIO:
66                 return PLUGIN_GET(image_enhance_scenario, val);
67         case PROP_DISPLAY_IMAGE_ENHANCE_TONE:
68                 return PLUGIN_GET(image_enhance_tone, val);
69         case PROP_DISPLAY_IMAGE_ENHANCE_OUTDOOR:
70                 return PLUGIN_GET(image_enhance_outdoor, val);
71         case PROP_DISPLAY_IMAGE_ENHANCE_INFO:
72                 return PLUGIN_SYS(image_enhance_info, val);
73         }
74
75         return -1;
76 }
77
78 static int display_set_prop(int __prop, int val)
79 {
80         int prop = PROPERTY_PROP(__prop);
81         int index = PROPERTY_INDEX(__prop);
82         int ps_disp_stat = 0;
83         int disp_cnt;
84         int r;
85
86         r = PLUGIN_GET(display_count, &disp_cnt);
87         if (r < 0) {
88                 _E("Get display count failed");
89                 return -1;
90         }
91
92         if (index >= disp_cnt) {
93                 _E("Invalid Argument: index(%d) > max(%d)", index, disp_cnt);
94                 return -1;
95         }
96
97         switch (prop) {
98         case PROP_DISPLAY_BRIGHTNESS:
99                 return PLUGIN_SET(backlight_brightness, index, val, ps_disp_stat);
100         case PROP_DISPLAY_ACL_CONTROL:
101                 return PLUGIN_SET(backlight_acl_control, index, val);
102         case PROP_DISPLAY_ONOFF:
103                 return PLUGIN_SET(lcd_power, index, val);
104         case PROP_DISPLAY_FRAME_RATE:
105                 return PLUGIN_SET(display_frame_rate, val);
106         case PROP_DISPLAY_IMAGE_ENHANCE_MODE:
107                 return PLUGIN_SET(image_enhance_mode, val);
108         case PROP_DISPLAY_IMAGE_ENHANCE_SCENARIO:
109                 return PLUGIN_SET(image_enhance_scenario, val);
110         case PROP_DISPLAY_IMAGE_ENHANCE_TONE:
111                 return PLUGIN_SET(image_enhance_tone, val);
112         case PROP_DISPLAY_IMAGE_ENHANCE_OUTDOOR:
113                 return PLUGIN_SET(image_enhance_outdoor, val);
114         }
115
116         return -1;
117 }
118
119 static const struct device display = {
120         .name     = "display",
121         .set_prop = display_set_prop,
122         .get_prop = display_get_prop,
123         .type     = DEVICE_TYPE_DISPLAY,
124 };
125
126 static void __CONSTRUCTOR__ module_init(void)
127 {
128         add_device(&(display.type));
129 }
130
131 static void __DESTRUCTOR__ module_fini(void)
132 {
133         remove_device(&(display.type));
134 }