__device_flags_to_string() is used for getting string name according to device_flags.
These functions have same logic, thus it is relocated to display-util.
This function is added to display-util.
- int display_util_get_device_flags_name(enum device_flags flags, const char **flag_name);
-> It replaces __device_flags_to_string().
Change-Id: Ia84ae6d7ff71419e22b700c12a7bca4e76413293
Signed-off-by: Yunhee Seo <yuni.seo@samsung.com>
return &states[state];
}
-static const char* __device_flags_to_string(enum device_flags flags)
-{
- if (flags & LCD_ON_BY_GESTURE)
- return GESTURE_STR;
- else if (flags & (LCD_ON_BY_POWER_KEY | LCD_OFF_BY_POWER_KEY))
- return POWER_KEY_STR;
- else if (flags & (LCD_ON_BY_EVENT | LCD_OFF_BY_EVENT))
- return EVENT_STR;
- else if (flags & LCD_ON_BY_TOUCH)
- return TOUCH_STR;
- else if (flags & LCD_OFF_BY_TIMEOUT)
- return TIMEOUT_STR;
- else
- return UNKNOWN_STR;
-}
-
static void init_lcd_operation(void)
{
const struct device_ops *ops = NULL;
/* display_plugin instance initialization */
init_pm_internal(data);
- disp_plgn->device_flags_to_string = __device_flags_to_string;
return 0;
}
return &states[state];
}
-static const char* __device_flags_to_string(enum device_flags flags)
-{
-
- if (flags & (LCD_ON_BY_GESTURE | LCD_OFF_BY_GESTURE))
- return GESTURE_STR;
- else if (flags & (LCD_ON_BY_POWER_KEY | LCD_OFF_BY_POWER_KEY))
- return POWER_KEY_STR;
- else if (flags & (LCD_ON_BY_EVENT | LCD_OFF_BY_EVENT))
- return EVENT_STR;
- else if (flags & LCD_ON_BY_TOUCH)
- return TOUCH_STR;
- else if (flags & LCD_OFF_BY_TIMEOUT)
- return TIMEOUT_STR;
- else if (flags & LCD_OFF_BY_PROXIMITY)
- return PROXI_STR;
- else if (flags & LCD_OFF_BY_PALM)
- return PALM_STR;
- else
- return UNKNOWN_STR;
-}
-
static int default_proc_change_state(unsigned int cond, pid_t pid)
{
enum state_t next;
/* display_plugin instance initialization */
init_pm_internal(data);
- disp_plgn->device_flags_to_string = __device_flags_to_string;
return 0;
}
return &states[state];
}
-static const char* __device_flags_to_string(enum device_flags flags)
-{
- if (flags & LCD_ON_BY_GESTURE)
- return GESTURE_STR;
- else if (flags & (LCD_ON_BY_POWER_KEY | LCD_OFF_BY_POWER_KEY))
- return POWER_KEY_STR;
- else if (flags & (LCD_ON_BY_EVENT | LCD_OFF_BY_EVENT))
- return EVENT_STR;
- else if (flags & LCD_ON_BY_TOUCH)
- return TOUCH_STR;
- else if (flags & LCD_OFF_BY_TIMEOUT)
- return TIMEOUT_STR;
- else
- return UNKNOWN_STR;
-}
-
static void init_lcd_operation(void)
{
const struct device_ops *ops = NULL;
/* display_plugin instance initialization */
init_pm_internal(data);
- disp_plgn->device_flags_to_string = __device_flags_to_string;
return 0;
}
return 0;
}
-static const char* __device_flags_to_string(enum device_flags flags)
-{
- if (flags & (LCD_ON_BY_GESTURE | LCD_OFF_BY_GESTURE))
- return GESTURE_STR;
- else if (flags & (LCD_ON_BY_POWER_KEY | LCD_OFF_BY_POWER_KEY))
- return POWER_KEY_STR;
- else if (flags & (LCD_ON_BY_EVENT | LCD_OFF_BY_EVENT))
- return EVENT_STR;
- else if (flags & LCD_ON_BY_BACK_KEY)
- return BACK_KEY_STR;
- else if (flags & LCD_ON_BY_TOUCH)
- return TOUCH_STR;
- else if (flags & LCD_ON_BY_BEZEL)
- return BEZEL_STR;
- else if (flags & LCD_OFF_BY_TIMEOUT)
- return TIMEOUT_STR;
- else if (flags & LCD_OFF_BY_PROXIMITY)
- return PROXI_STR;
- else if (flags & LCD_OFF_BY_PALM)
- return PALM_STR;
- else if (flags & LCD_OFF_BY_DISPLAY_DETACH)
- return DISPLAY_DETACH_STR;
- else
- return UNKNOWN_STR;
-}
-
static int get_device_flags(unsigned long *device_flags)
{
if (!device_flags)
/* display_plugin instance initialization */
init_pm_internal(data);
- disp_plgn->device_flags_to_string = __device_flags_to_string;
return 0;
}
return 0;
}
-const char* display_plugin_device_flags_to_string(enum device_flags flags)
-{
- if (g_display_plugin.device_flags_to_string)
- return g_display_plugin.device_flags_to_string(flags);
-
- return NULL;
-}
-
int display_plugin_auto_brightness_control(enum brightness_request_e request, int set_brightness)
{
if (g_display_plugin.auto_brightness_control)
int (*update_pm_setting) (int key_idx, int val);
int (*get_lock_screen_state) (void);
bool system_wakeup_flag;
- const char* (*device_flags_to_string) (enum device_flags flags);
int (*auto_brightness_control) (enum brightness_request_e request, int set_brightness);
/* FIXME: function names will be redefined */
void (*set_dim_state) (bool on);
int display_plugin_get_lock_screen_state(void);
int display_plugin_get_system_wakeup_flag(bool *flag);
int display_plugin_set_system_wakeup_flag(bool flag);
-const char* display_plugin_device_flags_to_string(enum device_flags flags);
int display_plugin_auto_brightness_control(enum brightness_request_e request, int set_brightness);
int display_plugin_set_dim_state(bool on);
int display_plugin_get_device_flags(unsigned long *device_flags);
*/
#include "display-signal.h"
+#include "display-util.h"
#include "poll.h"
#include "shared/plugin.h"
#include "shared/time.h"
if (type == SIGNAL_PRE && displayoff_time != 0)
diff = clock_gettime_to_long() - displayoff_time;
- if (!disp_plgn->device_flags_to_string) {
- _E("Cannot convert device_flags to string.");
- return;
- }
-
- str = disp_plgn->device_flags_to_string(flags);
+ display_util_get_device_flags_name(flags, &str);
signal = lcdon_sig_lookup[type];
_I("lcdstep : Broadcast signal(%s:%s).", signal, str);
signal = lcdoff_sig_lookup[type];
- if (!disp_plgn->device_flags_to_string) {
- _E("Cannot convert device_flags to string.");
- return;
- }
-
- str = disp_plgn->device_flags_to_string(flags);
+ display_util_get_device_flags_name(flags, &str);
_I("lcdstep : Broadcast signal(%s).", signal);
ret = gdbus_signal_emit_sync(NULL,
--- /dev/null
+/*
+ * deviced
+ *
+ * Copyright (c) 2023 Samsung Electronics Co., Ltd.
+ *
+ * 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 "display-util.h"
+
+int display_util_get_device_flags_name(enum device_flags flags, const char **flag_name)
+{
+ if (!flag_name)
+ return -EINVAL;
+
+ if (flags & (LCD_ON_BY_GESTURE | LCD_OFF_BY_GESTURE))
+ *flag_name = GESTURE_STR;
+ else if (flags & (LCD_ON_BY_POWER_KEY | LCD_OFF_BY_POWER_KEY))
+ *flag_name = POWER_KEY_STR;
+ else if (flags & (LCD_ON_BY_EVENT | LCD_OFF_BY_EVENT))
+ *flag_name = EVENT_STR;
+ else if (flags & LCD_ON_BY_BACK_KEY)
+ *flag_name = BACK_KEY_STR;
+ else if (flags & LCD_ON_BY_TOUCH)
+ *flag_name = TOUCH_STR;
+ else if (flags & LCD_ON_BY_BEZEL)
+ *flag_name = BEZEL_STR;
+ else if (flags & LCD_OFF_BY_TIMEOUT)
+ *flag_name = TIMEOUT_STR;
+ else if (flags & LCD_OFF_BY_PROXIMITY)
+ *flag_name = PROXI_STR;
+ else if (flags & LCD_OFF_BY_PALM)
+ *flag_name = PALM_STR;
+ else if (flags & LCD_OFF_BY_DISPLAY_DETACH)
+ *flag_name = DISPLAY_DETACH_STR;
+ else
+ *flag_name = UNKNOWN_STR;
+
+ return 0;
+}
\ No newline at end of file
--- /dev/null
+/*
+ * deviced
+ *
+ * Copyright (c) 2023 Samsung Electronics Co., Ltd.
+ *
+ * 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_UTIL_H__
+#define __DISPLAY_UTIL_H__
+
+#include "shared/devices.h"
+
+int display_util_get_device_flags_name(enum device_flags flags, const char **flag_name);
+
+#endif /* __DISPLAY_UTIL_H__ */
\ No newline at end of file