summaryrefslogtreecommitdiff
path: root/Kernel/API
diff options
context:
space:
mode:
authorLiav A <liavalb@gmail.com>2022-07-16 08:33:17 +0300
committerLinus Groh <mail@linusgroh.de>2022-07-19 11:02:37 +0100
commitecf015e6ee3e1557f256bf02637ead2734e56191 (patch)
treeea634fa9208710eb4bc3bb54b55571d22d5ad1c1 /Kernel/API
parent3af70cb0fcaddbf1d9888608496a474ab0f36c1b (diff)
downloadserenity-ecf015e6ee3e1557f256bf02637ead2734e56191.zip
Userland: Make graphics_connector_get_head_edid to read EDID from SysFS
The EDID blob is now exposed in the SysFS for each DisplayConnector, so we don't need to use the ioctl interface anymore to read the EDID.
Diffstat (limited to 'Kernel/API')
-rw-r--r--Kernel/API/FB.h29
1 files changed, 28 insertions, 1 deletions
diff --git a/Kernel/API/FB.h b/Kernel/API/FB.h
index bb89042548..36948e3e61 100644
--- a/Kernel/API/FB.h
+++ b/Kernel/API/FB.h
@@ -7,9 +7,16 @@
#pragma once
#include <AK/Platform.h>
+#include <AK/ScopeGuard.h>
+#include <AK/String.h>
+#include <fcntl.h>
#include <stddef.h>
+#include <stdio.h>
#include <sys/cdefs.h>
#include <sys/ioctl.h>
+#include <sys/stat.h>
+#include <sys/sysmacros.h>
+#include <unistd.h>
__BEGIN_DECLS
@@ -20,7 +27,27 @@ ALWAYS_INLINE int graphics_connector_get_properties(int fd, GraphicsConnectorPro
ALWAYS_INLINE int graphics_connector_get_head_edid(int fd, GraphicsHeadEDID* info)
{
- return ioctl(fd, GRAPHICS_IOCTL_GET_HEAD_EDID, info);
+ // FIXME: Optimize this function to get a minor number instead of a file descriptor.
+ struct stat display_connector_stat;
+ if (auto rc = fstat(fd, &display_connector_stat); rc < 0) {
+ return rc;
+ }
+ auto minor_number = minor(display_connector_stat.st_rdev);
+
+ auto edid_fd = open(String::formatted("/sys/devices/graphics/connectors/{}/edid", minor_number).characters(), O_RDONLY);
+ if (edid_fd < 0) {
+ return edid_fd;
+ }
+
+ ScopeGuard close_on_return([&]() {
+ close(edid_fd);
+ });
+
+ if (auto rc = read(edid_fd, info->bytes, info->bytes_size); rc < 0) {
+ return rc;
+ }
+
+ return 0;
}
ALWAYS_INLINE int fb_get_head_vertical_offset_buffer(int fd, GraphicsHeadVerticalOffset* vertical_offset)