display: Move plugin config-parser to core 32/290232/6
authorYoungjae Cho <y0.cho@samsung.com>
Tue, 21 Mar 2023 03:59:47 +0000 (12:59 +0900)
committerYoungjae Cho <y0.cho@samsung.com>
Mon, 27 Mar 2023 04:51:06 +0000 (13:51 +0900)
The display_load_config() has been relocated:
 - display/plugin-common/display.c => display/display-config.c

Change-Id: I82f495090f6814342ce3081b9477c72bd7cf863b
Signed-off-by: Youngjae Cho <y0.cho@samsung.com>
18 files changed:
plugins/iot-headed/display/core.c
plugins/iot-headed/display/key-filter.c
plugins/mobile/display/core.c
plugins/mobile/display/key-filter.c
plugins/tv/display/core.c
plugins/tv/display/key-filter.c
plugins/wearable/display/auto-brightness-sensorhub.c
plugins/wearable/display/core.c
plugins/wearable/display/device-interface.c
plugins/wearable/display/key-filter.c
plugins/wearable/display/lbm.c
src/display/display-config.c [new file with mode: 0644]
src/display/display-config.h [new file with mode: 0644]
src/display/plugin-common/core.h
src/display/plugin-common/display-backlight.c
src/display/plugin-common/display-lock.c
src/display/plugin-common/display.c
src/display/plugin-common/display.h

index e3528f2..57dbfbe 100644 (file)
 #include "display-lock.h"
 #include "display-backlight.h"
 #include "display-panel.h"
+#include "display-config.h"
 #include "shared/plugin.h"
 
-#define DISPLAY_CONF_FILE    "/etc/deviced/display.conf"
-
 /**
  * @addtogroup POWER_MANAGER
  * @{
@@ -2051,7 +2050,7 @@ static void display_init(void *data)
        power_saving_func = default_saving_mode;
 
        /* load configutation */
-       ret = config_parse(DISPLAY_CONF_FILE, display_load_config, &display_conf);
+       ret = display_load_config(&display_conf);
        if (ret < 0)
                _W("Failed to load '%s', use default value: %d",
                    DISPLAY_CONF_FILE, ret);
index 6990473..e054c2f 100644 (file)
@@ -34,6 +34,7 @@
 #include "display-actor.h"
 #include "display-backlight.h"
 #include "display-ops.h"
+#include "display-config.h"
 #include "shared/common.h"
 #include "shared/devices.h"
 #include "shared/device-notifier.h"
index e8d4930..87bb9ac 100644 (file)
 #include "display-lock.h"
 #include "display-backlight.h"
 #include "display-panel.h"
+#include "display-config.h"
 #include "shared/plugin.h"
 
-#define DISPLAY_CONF_FILE    "/etc/deviced/display.conf"
-
 /**
  * @addtogroup POWER_MANAGER
  * @{
@@ -2057,7 +2056,7 @@ static void display_init(void *data)
        power_saving_func = default_saving_mode;
 
        /* load configutation */
-       ret = config_parse(DISPLAY_CONF_FILE, display_load_config, &display_conf);
+       ret = display_load_config(&display_conf);
        if (ret < 0)
                _W("Failed to load '%s', use default value: %d",
                    DISPLAY_CONF_FILE, ret);
index df380ce..6fdc5c5 100644 (file)
@@ -34,6 +34,7 @@
 #include "display-actor.h"
 #include "display-backlight.h"
 #include "display-ops.h"
+#include "display-config.h"
 #include "shared/common.h"
 #include "shared/devices.h"
 #include "shared/device-notifier.h"
index 30a8579..956cc53 100644 (file)
 #include "display-lock.h"
 #include "display-backlight.h"
 #include "display-panel.h"
+#include "display-config.h"
 #include "shared/plugin.h"
 
-#define DISPLAY_CONF_FILE    "/etc/deviced/display.conf"
-
 /**
  * @addtogroup POWER_MANAGER
  * @{
@@ -2048,7 +2047,7 @@ static void display_init(void *data)
        power_saving_func = default_saving_mode;
 
        /* load configutation */
-       ret = config_parse(DISPLAY_CONF_FILE, display_load_config, &display_conf);
+       ret = display_load_config(&display_conf);
        if (ret < 0)
                _W("Failed to load '%s', use default value: %d",
                    DISPLAY_CONF_FILE, ret);
index d992c7c..dcbced5 100644 (file)
@@ -34,6 +34,7 @@
 #include "display-actor.h"
 #include "display-backlight.h"
 #include "display-ops.h"
+#include "display-config.h"
 #include "shared/common.h"
 #include "shared/devices.h"
 #include "shared/device-notifier.h"
index 806d01f..1815253 100644 (file)
@@ -31,6 +31,7 @@
 #include "core.h"
 #include "display-ops.h"
 #include "display-backlight.h"
+#include "display-config.h"
 #include "shared/device-notifier.h"
 #include "battery/power-supply.h"
 #include "shared/plugin.h"
index ca9cfc2..904ca95 100644 (file)
@@ -67,9 +67,9 @@
 #include "display-lock.h"
 #include "display-backlight.h"
 #include "display-panel.h"
+#include "display-config.h"
 #include "shared/plugin.h"
 
-#define DISPLAY_CONF_FILE    "/etc/deviced/display.conf"
 #define POWERLOCK_CONF_FILE  "/etc/deviced/powerlock.conf"
 
 #ifndef VCONFKEY_HOMESCREEN_TUTORIAL_OOBE_ENABLED
@@ -2366,7 +2366,7 @@ static void display_init(void *data)
        power_saving_func = default_saving_mode;
 
        /* load configutation */
-       ret = config_parse(DISPLAY_CONF_FILE, display_load_config, &display_conf);
+       ret = display_load_config(&display_conf);
        if (ret < 0)
                _W("Failed to load '%s', use default value: %d",
                    DISPLAY_CONF_FILE, ret);
index b2a1709..3f57023 100644 (file)
@@ -46,6 +46,7 @@
 #include "display-lock.h"
 #include "display-backlight.h"
 #include "display-panel.h"
+#include "display-config.h"
 #include "battery-monitor.h"
 #include "battery/power-supply.h"
 #include "power/power-suspend.h"
index c7d3c4a..574466b 100644 (file)
@@ -34,6 +34,7 @@
 #include "display-actor.h"
 #include "display-ops.h"
 #include "display-backlight.h"
+#include "display-config.h"
 #include "shared/common.h"
 #include "shared/devices.h"
 #include "shared/device-notifier.h"
index 75403c7..dbf3838 100644 (file)
@@ -31,8 +31,6 @@
 #include "shared/common.h"
 #include "shared/device-notifier.h"
 
-#define DISPLAY_CONF_FILE      "/etc/deviced/display.conf"
-
 #define SIGNAL_LBM_ON  "LBMOn"
 #define SIGNAL_LBM_OFF "LBMOff"
 
diff --git a/src/display/display-config.c b/src/display/display-config.c
new file mode 100644 (file)
index 0000000..2dac564
--- /dev/null
@@ -0,0 +1,112 @@
+/*
+ * deviced
+ *
+ * Copyright (c) 2011 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <stdbool.h>
+#include <libsyscommon/ini-parser.h>
+
+#include "display-dpms.h"
+#include "display.h"
+#include "deviced/dd-display.h"
+
+#include <shared/log.h>
+#include "display-config.h"
+
+static int display_config_parse(struct parse_result *result, void *user_data)
+{
+       struct display_config *c = user_data;
+
+       _D("display_load_config: section=%s name=%s value=%s", result->section, result->name, result->value);
+
+       if (!c)
+               return -EINVAL;
+
+       if (!MATCH(result->section, "Display"))
+               return 0;
+
+       if (MATCH(result->name, "LockScreenWaitingTime")) {
+               SET_CONF(c->lock_wait_time, atof(result->value));
+               _D("lock wait time is %.3f", c->lock_wait_time);
+       } else if (MATCH(result->name, "LongPressInterval")) {
+               SET_CONF(c->longpress_interval, atof(result->value));
+               _D("long press interval is %.3f", c->longpress_interval);
+       } else if (MATCH(result->name, "LightSensorSamplingInterval")) {
+               SET_CONF(c->lightsensor_interval, atof(result->value));
+               _D("lightsensor interval is %.3f", c->lightsensor_interval);
+       } else if (MATCH(result->name, "LCDOffTimeout")) {
+               SET_CONF(c->lcdoff_timeout, atoi(result->value));
+               _D("lcdoff timeout is %d ms", c->lcdoff_timeout);
+       } else if (MATCH(result->name, "BrightnessChangeStep")) {
+               SET_CONF(c->brightness_change_step, atoi(result->value));
+               _D("brightness change step is %d", c->brightness_change_step);
+       } else if (MATCH(result->name, "LCDAlwaysOn")) {
+               c->lcd_always_on = (MATCH(result->value, "yes") ? 1 : 0);
+               _D("LCD always on is %d", c->lcd_always_on);
+       } else if (MATCH(result->name, "Dimming")) {
+               c->dimming = (MATCH(result->value, "yes") ? 1 : 0);
+                _D("Dimming is %d", c->dimming);
+       } else if (MATCH(result->name, "ChangedFrameRateAllowed")) {
+               if (strstr(result->value, "setting")) {
+                       c->framerate_app[REFRESH_SETTING] = 1;
+                       _D("framerate app is Setting");
+               }
+               if (strstr(result->value, "all")) {
+                       memset(c->framerate_app, 1, sizeof(c->framerate_app));
+                       _D("framerate app is All");
+               }
+       } else if (MATCH(result->name, "ControlDisplay")) {
+               c->control_display = (MATCH(result->value, "yes") ? 1 : 0);
+               _D("ControlDisplay is %d", c->control_display);
+       } else if (MATCH(result->name, "PowerKeyDoublePressSupport")) {
+               c->powerkey_doublepress = (MATCH(result->value, "yes") ? 1 : 0);
+               _D("PowerKeyDoublePressSupport is %d", c->powerkey_doublepress);
+       } else if (MATCH(result->name, "AccelSensorOn")) {
+               c->accel_sensor_on = (MATCH(result->value, "yes") ? 1 : 0);
+               _D("AccelSensorOn is %d", c->accel_sensor_on);
+       } else if (MATCH(result->name, "ContinuousSampling")) {
+               c->continuous_sampling = (MATCH(result->value, "yes") ? 1 : 0);
+               _D("ContinuousSampling is %d", c->continuous_sampling);
+       } else if (MATCH(result->name, "TimeoutEnable")) {
+               c->timeout_enable = (MATCH(result->value, "yes") ? true : false);
+               _D("Timeout is %s", c->timeout_enable ? "enalbed" : "disabled");
+       } else if (MATCH(result->name, "InputSupport")) {
+               c->input_support = (MATCH(result->value, "yes") ? true : false);
+               _D("Input is %s", c->input_support ? "supported" : "NOT supported");
+       } else if (MATCH(result->name, "LockCheckTimeout")) {
+               SET_CONF(c->lockcheck_timeout, atoi(result->value));
+               _D("LockCheckTimeout is %d", c->lockcheck_timeout);
+       } else if (MATCH(result->name, "AODTSP")) {
+               c->aod_tsp = (MATCH(result->value, "yes") ? true : false);
+               _D("TSP control at is %d at aod", c->aod_tsp);
+       } else if (MATCH(result->name, "DisplayOnUsbConnChanged")) {
+               c->display_on_usb_conn_changed = (MATCH(result->value, "yes") ? true : false);
+       } else if (MATCH(result->name, "DisplayInitDirection")) {
+               c->display_init_direction = (MATCH(result->value, "vertical") ? \
+               DISPLAY_INIT_DIRECTION_VERTICAL : DISPLAY_INIT_DIRECTION_HORIZONTAL);
+       } else if (MATCH(result->name, "DisplayDPMSType")) {
+               c->display_dpms_type = (MATCH(result->value, "none") ? \
+               DISPLAY_DPMS_TYPE_NONE : DISPLAY_DPMS_TYPE_WINDOW_MANAGER);
+       }
+
+       return 0;
+}
+
+int display_load_config(struct display_config *config)
+{
+       return config_parse(DISPLAY_CONF_FILE, display_config_parse, config);
+}
+
diff --git a/src/display/display-config.h b/src/display/display-config.h
new file mode 100644 (file)
index 0000000..1d2cdfe
--- /dev/null
@@ -0,0 +1,63 @@
+/*
+ * deviced
+ *
+ * Copyright (c) 2011 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __DISPLAY_CONFIG_H__
+#define __DISPLAY_CONFIG_H__
+
+#define DISPLAY_CONF_FILE      "/etc/deviced/display.conf"
+/*
+ * @brief Configuration structure
+ */
+struct display_config {
+       double lock_wait_time;
+       double longpress_interval;
+       double lightsensor_interval;
+       int lcdoff_timeout;
+       const int pm_default_brightness;
+       int brightness_change_step;
+       int lcd_always_on;
+       int dimming;
+       int framerate_app[4];
+       int control_display;
+       int powerkey_doublepress;
+       int alpm_on;
+       int accel_sensor_on;
+       int continuous_sampling;
+       int lockcheck_timeout;
+       int display_init_direction;
+
+       /* Define pmlock checker.
+        * Return id of the lock checker.
+        *
+        * Returning 0 will use default lock checker */
+       int (*pmlock_check) (void *data);
+
+       int aod_enter_level;
+       bool aod_tsp;
+       bool timeout_enable;
+       bool input_support;
+       bool touch_wakeup;
+       bool display_on_usb_conn_changed;
+
+       /* FIXME: After extrancting display-dpms from plugin, restore its type to enum display_dpms_type */
+       int display_dpms_type;
+};
+
+int display_load_config(struct display_config *config);
+
+#endif //__DISPLAY_CONFIG_H__
index 3e28126..fce9961 100644 (file)
@@ -28,6 +28,7 @@
 #include "device-interface.h"
 #include "setting.h"
 #include "display-dpms.h"
+#include "display-config.h"
 
 #define WITHOUT_STARTNOTI      0x1
 #define MASK_BIT    0x7                /* 111 */
@@ -90,42 +91,6 @@ struct state {
 struct state *state_st(enum state_t state);
 
 /*
- * @brief Configuration structure
- */
-struct display_config {
-       double lock_wait_time;
-       double longpress_interval;
-       double lightsensor_interval;
-       int lcdoff_timeout;
-       const int pm_default_brightness;
-       int brightness_change_step;
-       int lcd_always_on;
-       int dimming;
-       int framerate_app[4];
-       int control_display;
-       int powerkey_doublepress;
-       int alpm_on;
-       int accel_sensor_on;
-       int continuous_sampling;
-       int lockcheck_timeout;
-       int display_init_direction;
-
-       /* Define pmlock checker.
-        * Return id of the lock checker.
-        *
-        * Returning 0 will use default lock checker */
-       int (*pmlock_check) (void *data);
-
-       int aod_enter_level;
-       bool aod_tsp;
-       bool timeout_enable;
-       bool input_support;
-       bool touch_wakeup;
-       bool display_on_usb_conn_changed;
-       enum display_dpms_type display_dpms_type;
-};
-
-/*
  * Global variables
  *   display_conf : configuration of display
  */
index a32a13c..c65e2bb 100644 (file)
@@ -498,4 +498,4 @@ static void __CONSTRUCTOR__ initialize(void)
        if (!backlight_ops)
                _W("Failed to get backlight operator variable.");
 
-}
\ No newline at end of file
+}
index 3bd8590..4223b2f 100644 (file)
@@ -28,6 +28,7 @@
 #include "display-signal.h"
 #include "lock-detector.h"
 #include "display-lock.h"
+#include "display-config.h"
 #include "shared/log-macro.h"
 #include "shared/apps.h"
 
index 36b1320..977252a 100644 (file)
@@ -99,85 +99,6 @@ void lcd_direct_control(enum dpms_state state, int flags)
        }
 }
 
-int display_load_config(struct parse_result *result, void *user_data)
-{
-       struct display_config *c = user_data;
-
-       _D("display_load_config: section=%s name=%s value=%s", result->section, result->name, result->value);
-
-       if (!c)
-               return -EINVAL;
-
-       if (!MATCH(result->section, "Display"))
-               return 0;
-
-       if (MATCH(result->name, "LockScreenWaitingTime")) {
-               SET_CONF(c->lock_wait_time, atof(result->value));
-               _D("lock wait time is %.3f", c->lock_wait_time);
-       } else if (MATCH(result->name, "LongPressInterval")) {
-               SET_CONF(c->longpress_interval, atof(result->value));
-               _D("long press interval is %.3f", c->longpress_interval);
-       } else if (MATCH(result->name, "LightSensorSamplingInterval")) {
-               SET_CONF(c->lightsensor_interval, atof(result->value));
-               _D("lightsensor interval is %.3f", c->lightsensor_interval);
-       } else if (MATCH(result->name, "LCDOffTimeout")) {
-               SET_CONF(c->lcdoff_timeout, atoi(result->value));
-               _D("lcdoff timeout is %d ms", c->lcdoff_timeout);
-       } else if (MATCH(result->name, "BrightnessChangeStep")) {
-               SET_CONF(c->brightness_change_step, atoi(result->value));
-               _D("brightness change step is %d", c->brightness_change_step);
-       } else if (MATCH(result->name, "LCDAlwaysOn")) {
-               c->lcd_always_on = (MATCH(result->value, "yes") ? 1 : 0);
-               _D("LCD always on is %d", c->lcd_always_on);
-       } else if (MATCH(result->name, "Dimming")) {
-               c->dimming = (MATCH(result->value, "yes") ? 1 : 0);
-                _D("Dimming is %d", c->dimming);
-       } else if (MATCH(result->name, "ChangedFrameRateAllowed")) {
-               if (strstr(result->value, "setting")) {
-                       c->framerate_app[REFRESH_SETTING] = 1;
-                       _D("framerate app is Setting");
-               }
-               if (strstr(result->value, "all")) {
-                       memset(c->framerate_app, 1, sizeof(c->framerate_app));
-                       _D("framerate app is All");
-               }
-       } else if (MATCH(result->name, "ControlDisplay")) {
-               c->control_display = (MATCH(result->value, "yes") ? 1 : 0);
-               _D("ControlDisplay is %d", c->control_display);
-       } else if (MATCH(result->name, "PowerKeyDoublePressSupport")) {
-               c->powerkey_doublepress = (MATCH(result->value, "yes") ? 1 : 0);
-               _D("PowerKeyDoublePressSupport is %d", c->powerkey_doublepress);
-       } else if (MATCH(result->name, "AccelSensorOn")) {
-               c->accel_sensor_on = (MATCH(result->value, "yes") ? 1 : 0);
-               _D("AccelSensorOn is %d", c->accel_sensor_on);
-       } else if (MATCH(result->name, "ContinuousSampling")) {
-               c->continuous_sampling = (MATCH(result->value, "yes") ? 1 : 0);
-               _D("ContinuousSampling is %d", c->continuous_sampling);
-       } else if (MATCH(result->name, "TimeoutEnable")) {
-               c->timeout_enable = (MATCH(result->value, "yes") ? true : false);
-               _D("Timeout is %s", c->timeout_enable ? "enalbed" : "disabled");
-       } else if (MATCH(result->name, "InputSupport")) {
-               c->input_support = (MATCH(result->value, "yes") ? true : false);
-               _D("Input is %s", c->input_support ? "supported" : "NOT supported");
-       } else if (MATCH(result->name, "LockCheckTimeout")) {
-               SET_CONF(c->lockcheck_timeout, atoi(result->value));
-               _D("LockCheckTimeout is %d", c->lockcheck_timeout);
-       } else if (MATCH(result->name, "AODTSP")) {
-               c->aod_tsp = (MATCH(result->value, "yes") ? true : false);
-               _D("TSP control at is %d at aod", c->aod_tsp);
-       } else if (MATCH(result->name, "DisplayOnUsbConnChanged")) {
-               c->display_on_usb_conn_changed = (MATCH(result->value, "yes") ? true : false);
-       } else if (MATCH(result->name, "DisplayInitDirection")) {
-               c->display_init_direction = (MATCH(result->value, "vertical") ? \
-               DISPLAY_INIT_DIRECTION_VERTICAL : DISPLAY_INIT_DIRECTION_HORIZONTAL);
-       } else if (MATCH(result->name, "DisplayDPMSType")) {
-               c->display_dpms_type = (MATCH(result->value, "none") ? \
-               DISPLAY_DPMS_TYPE_NONE : DISPLAY_DPMS_TYPE_WINDOW_MANAGER);
-       }
-
-       return 0;
-}
-
 /* FIXME: This function is for temporary use, should be fixed after plugin refactoring */
 void display_set_hal_backend_available(bool display_hal_backend_available)
 {
@@ -188,4 +109,4 @@ void display_set_hal_backend_available(bool display_hal_backend_available)
 bool display_is_hal_backend_available(void)
 {
        return g_display_hal_backend_available;
-}
\ No newline at end of file
+}
index 289b0d0..90c4764 100644 (file)
@@ -33,7 +33,6 @@ void set_pm_status_flag(unsigned int status_flag);
 void clear_pm_status_flag(unsigned int status_flag);
 enum display_init_direction_e get_display_init_direction(void);
 void set_display_init_direction(enum display_init_direction_e display_init_direction);
-int display_load_config(struct parse_result *result, void *user_data);
 void display_set_hal_backend_available(bool display_hal_backend_available);
 bool display_is_hal_backend_available(void);