--- /dev/null
+/*
+ * PASS (Power Aware System Service) - Display Resource Driver
+ *
+ * Copyright (c) 2022 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.
+ */
+
+/**
+ * @file resource-display.c
+ * @brief TBD
+ * @ingroup TBD
+ */
+
+#include <glib.h>
+
+#include <hal/hal-power.h>
+
+#include <util/common.h>
+#include <util/log.h>
+#include <util/resource.h>
+#include <util/gdbus-util.h>
+
+#include <tmonitor/tmonitor.h>
+
+#define DBUS_ENLIGHTENMENT_NAME "org.enlightenment.wm"
+#define DBUS_ENLIGHTENMENT_PATH "/org/enlightenment/wm"
+#define DBUS_ENLIGHTENMENT_INTERFACE "org.enlightenment.wm.info"
+#define DBUS_ENLIGHTENMENT_FPS_FUNC "get_fps_info"
+
+struct display_fps_data {
+ unsigned int type;
+ char output[128];
+ int zpos;
+ unsigned int window;
+ double fps;
+};
+
+static int display_get_fps(const struct resource *res,
+ const struct resource_attribute *attr,
+ void **data, void *user_data)
+{
+ GDBusConnection *conn;
+ GDBusMessage *msg, *reply;
+ GVariant *result, *value;
+ GError *err = NULL;
+ struct display_fps_data fps_data;
+ int ret = 0;
+
+ if (!res || !attr || !data)
+ return -EINVAL;
+
+ /* Connect dbus interface and receive message */
+ conn = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &err);
+ if (err) {
+ g_clear_error(&err);
+ return -EINVAL;
+ }
+
+ msg = g_dbus_message_new_method_call(DBUS_ENLIGHTENMENT_NAME,
+ DBUS_ENLIGHTENMENT_PATH,
+ DBUS_ENLIGHTENMENT_INTERFACE,
+ DBUS_ENLIGHTENMENT_FPS_FUNC);
+ if (!msg) {
+ ret = -EINVAL;
+ goto err_conn;
+ }
+
+ reply = g_dbus_connection_send_message_with_reply_sync(conn, msg,
+ G_DBUS_SEND_MESSAGE_FLAGS_NONE,
+ G_MAXINT, NULL, NULL, &err);
+ if (err) {
+ g_clear_error(&err);
+ ret = -EINVAL;
+ goto err_msg;
+ }
+
+ if (g_dbus_message_get_message_type(reply) == G_DBUS_MESSAGE_TYPE_ERROR) {
+ ret = -EINVAL;
+ goto err_reply;
+ }
+
+ /* Parse the received data */
+ result = g_variant_get_child_value(g_dbus_message_get_body(reply), 0);
+ if (g_variant_n_children(result) <= res->index) {
+ ret = -EINVAL;
+ goto err_reply;
+ }
+
+ /* Get the fps information according to the index of resource_device */
+ value = g_variant_get_child_value(result, res->index);
+ g_variant_get(value, "(usiud)",
+ &fps_data.type, fps_data.output, &fps_data.zpos,
+ &fps_data.window, &fps_data.fps);
+
+ *data = (void *)(intptr_t)fps_data.fps;
+
+err_reply:
+ g_object_unref(reply);
+err_msg:
+ g_object_unref(msg);
+err_conn:
+ g_dbus_connection_flush(conn, NULL, NULL, NULL);
+
+ return ret;
+}
+
+static const struct resource_attribute display_attrs[] = {
+ {
+ .name = "DISPLAY_FPS",
+ .id = DISPLAY_FPS,
+ .type = DATA_TYPE_DOUBLE,
+ .ops = {
+ .get = display_get_fps,
+ },
+ },
+};
+
+static const struct resource_driver display_resource_driver = {
+ .name = "DISPLAY",
+ .type = RESOURCE_TYPE_DISPLAY,
+ .attrs = display_attrs,
+ .num_attrs = ARRAY_SIZE(display_attrs),
+};
+RESOURCE_DRIVER_REGISTER(&display_resource_driver)