15 changes: 15 additions & 0 deletions plugins/linux-display/fu-linux-display-plugin.h
@@ -0,0 +1,15 @@
/*
* Copyright (C) 2023 Richard Hughes <richard@hughsie.com>
*
* SPDX-License-Identifier: LGPL-2.1+
*/

#pragma once

#include <fwupdplugin.h>

G_DECLARE_FINAL_TYPE(FuLinuxDisplayPlugin,
fu_linux_display_plugin,
FU,
LINUX_DISPLAY_PLUGIN,
FuPlugin)
13 changes: 13 additions & 0 deletions plugins/linux-display/meson.build
@@ -0,0 +1,13 @@
if host_machine.system() == 'linux'
cargs = ['-DG_LOG_DOMAIN="FuPluginLinuxDisplay"']

plugin_builtins += static_library('fu_plugin_linux_display',
sources: [
'fu-linux-display-plugin.c',
],
include_directories: plugin_incdirs,
link_with: plugin_libs,
c_args: cargs,
dependencies: plugin_deps,
)
endif
1 change: 1 addition & 0 deletions plugins/meson.build
Expand Up @@ -65,6 +65,7 @@ plugins = [
'jabra',
'jabra-gnp',
'lenovo-thinklmi',
'linux-display',
'linux-lockdown',
'linux-sleep',
'linux-swap',
Expand Down
4 changes: 4 additions & 0 deletions plugins/uefi-capsule/fu-uefi-capsule-plugin.c
Expand Up @@ -773,6 +773,10 @@ fu_uefi_capsule_plugin_coldplug_device(FuPlugin *plugin, FuUefiDevice *dev, GErr
fu_device_add_private_flag(FU_DEVICE(dev), FU_UEFI_DEVICE_FLAG_NO_UX_CAPSULE);
if (fu_context_has_hwid_flag(ctx, "no-lid-closed"))
fu_device_add_internal_flag(FU_DEVICE(dev), FU_DEVICE_INTERNAL_FLAG_NO_LID_CLOSED);
if (fu_context_has_hwid_flag(ctx, "display-required")) {
fu_device_add_internal_flag(FU_DEVICE(dev),
FU_DEVICE_INTERNAL_FLAG_DISPLAY_REQUIRED);
}

/* detected InsydeH2O */
if (self->acpi_uefi != NULL &&
Expand Down
21 changes: 21 additions & 0 deletions src/fu-engine.c
Expand Up @@ -483,6 +483,17 @@ fu_engine_ensure_device_lid_inhibit(FuEngine *self, FuDevice *device)
fu_device_remove_problem(device, FWUPD_DEVICE_PROBLEM_LID_IS_CLOSED);
}

static void
fu_engine_ensure_device_display_required_inhibit(FuEngine *self, FuDevice *device)
{
if (fu_device_has_internal_flag(device, FU_DEVICE_INTERNAL_FLAG_DISPLAY_REQUIRED) &&
fu_context_get_display_state(self->ctx) == FU_DISPLAY_STATE_DISCONNECTED) {
fu_device_add_problem(device, FWUPD_DEVICE_PROBLEM_DISPLAY_REQUIRED);
return;
}
fu_device_remove_problem(device, FWUPD_DEVICE_PROBLEM_DISPLAY_REQUIRED);
}

static void
fu_engine_ensure_device_system_inhibit(FuEngine *self, FuDevice *device)
{
Expand Down Expand Up @@ -531,6 +542,7 @@ fu_engine_device_added_cb(FuDeviceList *device_list, FuDevice *device, FuEngine
fu_engine_watch_device(self, device);
fu_engine_ensure_device_power_inhibit(self, device);
fu_engine_ensure_device_lid_inhibit(self, device);
fu_engine_ensure_device_display_required_inhibit(self, device);
fu_engine_ensure_device_system_inhibit(self, device);
fu_engine_acquiesce_reset(self);
g_signal_emit(self, signals[SIGNAL_DEVICE_ADDED], 0, device);
Expand Down Expand Up @@ -2376,6 +2388,10 @@ fu_engine_get_report_metadata(FuEngine *self, GError **error)
hash,
g_strdup("PowerState"),
g_strdup(fu_power_state_to_string(fu_context_get_power_state(self->ctx))));
g_hash_table_insert(
hash,
g_strdup("DisplayState"),
g_strdup(fu_display_state_to_string(fu_context_get_display_state(self->ctx))));
g_hash_table_insert(hash,
g_strdup("LidState"),
g_strdup(fu_lid_state_to_string(fu_context_get_lid_state(self->ctx))));
Expand Down Expand Up @@ -8691,6 +8707,7 @@ fu_engine_context_power_changed_cb(FuContext *ctx, GParamSpec *pspec, FuEngine *
FuDevice *device = g_ptr_array_index(devices, i);
fu_engine_ensure_device_power_inhibit(self, device);
fu_engine_ensure_device_lid_inhibit(self, device);
fu_engine_ensure_device_display_required_inhibit(self, device);
fu_engine_ensure_device_system_inhibit(self, device);
}
}
Expand Down Expand Up @@ -8752,6 +8769,10 @@ fu_engine_init(FuEngine *self)
"notify::lid-state",
G_CALLBACK(fu_engine_context_power_changed_cb),
self);
g_signal_connect(FU_CONTEXT(self->ctx),
"notify::display-state",
G_CALLBACK(fu_engine_context_power_changed_cb),
self);
g_signal_connect(FU_CONTEXT(self->ctx),
"notify::battery-level",
G_CALLBACK(fu_engine_context_power_changed_cb),
Expand Down
4 changes: 4 additions & 0 deletions src/fu-util-common.c
Expand Up @@ -1328,6 +1328,10 @@ fu_util_device_problem_to_string(FwupdClient *client, FwupdDevice *dev, FwupdDev
/* TRANSLATORS: device cannot be interrupted, for instance taking a phone call */
return g_strdup(_("Device is in use"));
}
if (problem == FWUPD_DEVICE_PROBLEM_DISPLAY_REQUIRED) {
/* TRANSLATORS: device does not have a display connected */
return g_strdup(_("Device requires a display to be plugged in"));
}
return NULL;
}

Expand Down