summaryrefslogtreecommitdiff
path: root/Kernel/Graphics
diff options
context:
space:
mode:
authorLiav A <liavalb@gmail.com>2022-07-16 08:08:53 +0300
committerLinus Groh <mail@linusgroh.de>2022-07-19 11:02:37 +0100
commitda8d18b2633522ca8fdfa6d4bc80d49ceb1b22a5 (patch)
treedfeccf327656e9b275a9c8f3ebf11c94e1df04b0 /Kernel/Graphics
parentcb900006b930498ee22b94693d84d538dec5d714 (diff)
downloadserenity-da8d18b2633522ca8fdfa6d4bc80d49ceb1b22a5.zip
Kernel/SysFS: Add exposing interface for DisplayConnectors
Under normal conditions (when mounting SysFS in /sys), there will be a new directory in the /sys/devices directory called "graphics". For now, under that directory there will be only a sub-directory called "connectors" which will contain all DisplayConnectors' details, each in its own sub-directory too, distinguished in naming with its minor number. Therefore, /sys/devices/graphics/connectors/MINOR_NUMBER/ will contain: - General device attributes such as mutable_mode_setting_capable, double_buffering_capable, flush_support, partial_flush_support and refresh_rate_support. These values are exposed in the ioctl interface of the DisplayConnector class too, but these can be useful later on for command line utilities that want/need to expose these basic settings. - The EDID blob, simply named "edid". This will help userspace to fetch the edid without the need of using the ioctl interface later on.
Diffstat (limited to 'Kernel/Graphics')
-rw-r--r--Kernel/Graphics/DisplayConnector.cpp26
1 files changed, 24 insertions, 2 deletions
diff --git a/Kernel/Graphics/DisplayConnector.cpp b/Kernel/Graphics/DisplayConnector.cpp
index e6462e33d1..9cf8f327b8 100644
--- a/Kernel/Graphics/DisplayConnector.cpp
+++ b/Kernel/Graphics/DisplayConnector.cpp
@@ -4,6 +4,9 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
+#include <Kernel/FileSystem/SysFS/Subsystems/DeviceIdentifiers/CharacterDevicesDirectory.h>
+#include <Kernel/FileSystem/SysFS/Subsystems/Devices/Graphics/DisplayConnector/DeviceDirectory.h>
+#include <Kernel/FileSystem/SysFS/Subsystems/Devices/Graphics/DisplayConnector/Directory.h>
#include <Kernel/Graphics/DisplayConnector.h>
#include <Kernel/Graphics/GraphicsManagement.h>
#include <Kernel/Memory/MemoryManager.h>
@@ -57,12 +60,31 @@ ErrorOr<size_t> DisplayConnector::write(OpenFileDescription&, u64, UserOrKernelB
void DisplayConnector::will_be_destroyed()
{
GraphicsManagement::the().detach_display_connector({}, *this);
- Device::will_be_destroyed();
+
+ VERIFY(m_symlink_sysfs_component);
+ VERIFY(!is_block_device());
+ SysFSCharacterDevicesDirectory::the().m_child_components.with([&](auto& list) -> void {
+ list.remove(*m_symlink_sysfs_component);
+ });
+ m_symlink_sysfs_component.clear();
+ SysFSDisplayConnectorsDirectory::the().unplug({}, *m_sysfs_device_directory);
+ before_will_be_destroyed_remove_from_device_management();
}
void DisplayConnector::after_inserting()
{
- Device::after_inserting();
+ after_inserting_add_to_device_management();
+ auto sysfs_display_connector_device_directory = DisplayConnectorSysFSDirectory::create(SysFSDisplayConnectorsDirectory::the(), *this);
+ m_sysfs_device_directory = sysfs_display_connector_device_directory;
+ SysFSDisplayConnectorsDirectory::the().plug({}, *sysfs_display_connector_device_directory);
+ VERIFY(!m_symlink_sysfs_component);
+ auto sys_fs_component = MUST(SysFSSymbolicLinkDeviceComponent::try_create(SysFSDeviceIdentifiersDirectory::the(), *this, *m_sysfs_device_directory));
+ m_symlink_sysfs_component = sys_fs_component;
+ VERIFY(!is_block_device());
+ SysFSCharacterDevicesDirectory::the().m_child_components.with([&](auto& list) -> void {
+ list.append(*m_symlink_sysfs_component);
+ });
+
auto rounded_size = MUST(Memory::page_round_up(m_framebuffer_resource_size));
if (!m_framebuffer_at_arbitrary_physical_range) {