4 * Copyright (c) 2022 Samsung Electronics Co., Ltd.
6 * Licensed under the Apache License, Version 2.0 (the License);
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
19 #include <shared/common.h>
20 #include <shared/devices.h>
21 #include <hal/device/hal-display.h>
22 #include <libsyscommon/libgdbus.h>
24 static GVariant *dbus_lockstate(GDBusConnection *conn,
25 const gchar *sender, const gchar *path, const gchar *iface, const gchar *name,
26 GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data)
28 return g_variant_new("(i)", 0);
31 static GVariant *dbus_unlockstate(GDBusConnection *conn,
32 const gchar *sender, const gchar *path, const gchar *iface, const gchar *name,
33 GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data)
35 return g_variant_new("(i)", 0);
38 static GVariant *dbus_getrotationangle(GDBusConnection *conn,
39 const gchar *sender, const gchar *path, const gchar *iface, const gchar *name,
40 GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data)
44 enum hal_device_display_rotation_angle angle;
46 g_variant_get(param, "(i)", &display_index);
47 ret = hal_device_display_get_rotation_angle(display_index, &angle);
49 angle = HAL_DEVICE_DISPLAY_ROTATION_ANGLE_UNKNOWN;
51 return g_variant_new("(ii)", ret, angle);
54 static GVariant *dbus_setrotationangle(GDBusConnection *conn,
55 const gchar *sender, const gchar *path, const gchar *iface, const gchar *name,
56 GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data)
60 enum hal_device_display_rotation_angle angle;
61 enum hal_device_display_rotation_direction direction;
63 g_variant_get(param, "(iii)", &display_index, &angle, &direction);
64 ret = hal_device_display_set_rotation_angle(display_index, angle, direction);
66 return g_variant_new("(i)", ret);
69 static const dbus_method_s dbus_methods[] = {
70 { "lockstate", "sssi", "i", dbus_lockstate },
71 { "unlockstate", "ss", "i", dbus_unlockstate },
72 { "GetRotationAngle", "i", "ii", dbus_getrotationangle },
73 { "SetRotationAngle", "iii", "i", dbus_setrotationangle }
76 static const dbus_interface_u dbus_interface = {
78 .name = DEVICED_INTERFACE_DISPLAY,
79 .methods = dbus_methods,
80 .nr_methods = ARRAY_SIZE(dbus_methods),
83 static void display_init(void *data)
85 gdbus_add_object(NULL, DEVICED_PATH_DISPLAY, &dbus_interface);
88 static const struct device_ops display_device_ops = {
89 .priority = DEVICE_PRIORITY_HIGH,
90 DECLARE_NAME_LEN("display"),
94 DEVICE_OPS_REGISTER(&display_device_ops)