From 1985b78991d1fe925b827ded4fdae58d1b4e1d7a Mon Sep 17 00:00:00 2001 From: Youngjae Cho Date: Tue, 20 Sep 2022 15:45:26 +0900 Subject: [PATCH] display: add dummy display for iot-headless For who want cpulock directly via dbus API, not device API on headless target, add dummy dbus object that receives those request not to emit error. Such a weird call, request for display function on headless profile, is basically because display module provides state locking including sleep state(cpulock), which should have been handled by power module. Therefore in the future, moving cpulock from display to power module should be followed by removing this dummy. Change-Id: If8f0b449f65832ddf705b9e7ad4e461c20f6a102 Signed-off-by: Youngjae Cho --- CMakeLists.txt | 1 + packaging/deviced.spec | 2 + plugins/iot-headless/display/CMakeLists.txt | 21 ++++++++++ plugins/iot-headless/display/core.c | 60 +++++++++++++++++++++++++++++ 4 files changed, 84 insertions(+) create mode 100644 plugins/iot-headless/display/CMakeLists.txt create mode 100644 plugins/iot-headless/display/core.c diff --git a/CMakeLists.txt b/CMakeLists.txt index ba0c0c8..8aca3d1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -337,6 +337,7 @@ ADD_SUBDIRECTORY(plugins/tv/display) ADD_SUBDIRECTORY(plugins/iot-headed/display) ADD_SUBDIRECTORY(plugins/iot-headless/input) ADD_SUBDIRECTORY(plugins/iot-headless/battery) +ADD_SUBDIRECTORY(plugins/iot-headless/display) IF(BATTERY_MODULE STREQUAL on) ADD_SUBDIRECTORY(plugins/mobile/battery) ADD_SUBDIRECTORY(plugins/wearable/battery) diff --git a/packaging/deviced.spec b/packaging/deviced.spec index caa06af..a963293 100644 --- a/packaging/deviced.spec +++ b/packaging/deviced.spec @@ -258,6 +258,7 @@ mv %{_sysconfdir}/deviced/power-profile-iot-headless.conf %{_sysconfdir}/deviced mkdir -p %{_libdir}/deviced mv %{_libdir}/iot-headless-input-handler.so %{_libdir}/deviced/input-handler.so mv %{_libdir}/iot-headless-battery.so %{_libdir}/deviced/battery.so +mv %{_libdir}/iot-headless-display.so %{_libdir}/deviced/display.so %files %manifest %{name}.manifest @@ -393,5 +394,6 @@ mv %{_libdir}/iot-headless-battery.so %{_libdir}/deviced/battery.so %config %{_sysconfdir}/deviced/power-profile-iot-headless.conf %{_libdir}/iot-headless-input-handler.so %{_libdir}/iot-headless-battery.so +%{_libdir}/iot-headless-display.so %{_unitdir}/rndis.service %{_bindir}/rndis.sh diff --git a/plugins/iot-headless/display/CMakeLists.txt b/plugins/iot-headless/display/CMakeLists.txt new file mode 100644 index 0000000..3d0a186 --- /dev/null +++ b/plugins/iot-headless/display/CMakeLists.txt @@ -0,0 +1,21 @@ +CMAKE_MINIMUM_REQUIRED(VERSION 2.6) +PROJECT(iot-headless-display C) + +FILE(GLOB SRCS "*.c") + +INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/src) + +INCLUDE(FindPkgConfig) +pkg_check_modules(libpkgs REQUIRED + libsyscommon) + +FOREACH(flag ${libpkgs_CFLAGS}) + SET(EXTRA_LIB_CFLAGS "${EXTRA_LIB_CFLAGS} ${flag}") +ENDFOREACH(flag) +SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_LIB_CFLAGS}") + +ADD_LIBRARY(${PROJECT_NAME} SHARED ${SRCS}) +TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${libpkgs_LDFLAGS} deviced-common-private) +SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES PREFIX "") +SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES OUTPUT_NAME iot-headless-display) +INSTALL(TARGETS ${PROJECT_NAME} DESTINATION ${LIB_INSTALL_DIR} COMPONENT RuntimeLibraries) diff --git a/plugins/iot-headless/display/core.c b/plugins/iot-headless/display/core.c new file mode 100644 index 0000000..fc642eb --- /dev/null +++ b/plugins/iot-headless/display/core.c @@ -0,0 +1,60 @@ +/* + * deviced + * + * 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. + */ + +#include +#include +#include + +static GVariant *dbus_lockstate(GDBusConnection *conn, + const gchar *sender, const gchar *path, const gchar *iface, const gchar *name, + GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data) +{ + return g_variant_new("(i)", 0); +} + +static GVariant *dbus_unlockstate(GDBusConnection *conn, + const gchar *sender, const gchar *path, const gchar *iface, const gchar *name, + GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data) +{ + return g_variant_new("(i)", 0); +} + +static const dbus_method_s dbus_methods[] = { + { "lockstate", "sssi", "i", dbus_lockstate }, + { "unlockstate", "ss", "i", dbus_unlockstate }, +}; + +static const dbus_interface_u dbus_interface = { + .oh = NULL, + .name = DEVICED_INTERFACE_DISPLAY, + .methods = dbus_methods, + .nr_methods = ARRAY_SIZE(dbus_methods), +}; + +static void display_init(void *data) +{ + gdbus_add_object(NULL, DEVICED_PATH_DISPLAY, &dbus_interface); +} + +static const struct device_ops display_device_ops = { + .priority = DEVICE_PRIORITY_HIGH, + DECLARE_NAME_LEN("display"), + .init = display_init, +}; + +DEVICE_OPS_REGISTER(&display_device_ops) -- 2.7.4