summaryrefslogtreecommitdiff
path: root/Userland/Libraries
diff options
context:
space:
mode:
authorTom <tomut@yahoo.com>2022-01-17 16:53:17 -0700
committerLinus Groh <mail@linusgroh.de>2022-01-23 22:45:21 +0000
commit869c20b05dba6230d96166f2a5b74e823653274a (patch)
treec2b4404f0f14591c229ca77439893eaeea601961 /Userland/Libraries
parentab1075e2961107a9f9d411d4afc0f4fe144dec36 (diff)
downloadserenity-869c20b05dba6230d96166f2a5b74e823653274a.zip
Meta+LibEDID: Download and generate the PNP ID database
This downloads the UEFI's published PNP ID database and generates a lookup table for use in LibEDID. The lookup table isn't optimized at all, but this can be easily done at a later point if needed.
Diffstat (limited to 'Userland/Libraries')
-rw-r--r--Userland/Libraries/LibEDID/CMakeLists.txt4
-rw-r--r--Userland/Libraries/LibEDID/EDID.cpp16
-rw-r--r--Userland/Libraries/LibEDID/EDID.h4
3 files changed, 24 insertions, 0 deletions
diff --git a/Userland/Libraries/LibEDID/CMakeLists.txt b/Userland/Libraries/LibEDID/CMakeLists.txt
index a3f981385f..e50d8022d1 100644
--- a/Userland/Libraries/LibEDID/CMakeLists.txt
+++ b/Userland/Libraries/LibEDID/CMakeLists.txt
@@ -1,8 +1,12 @@
+include(${SerenityOS_SOURCE_DIR}/Meta/CMake/pnp_ids.cmake)
+
set(SOURCES
DMT.cpp
EDID.cpp
VIC.cpp
+ ${PNP_IDS_SOURCES}
)
serenity_lib(LibEDID edid)
target_link_libraries(LibEDID LibC)
+target_compile_definitions(LibEDID PRIVATE ENABLE_PNP_IDS_DATA=$<BOOL:${ENABLE_PNP_IDS_DOWNLOAD}>)
diff --git a/Userland/Libraries/LibEDID/EDID.cpp b/Userland/Libraries/LibEDID/EDID.cpp
index ecf333fbed..c8ee308481 100644
--- a/Userland/Libraries/LibEDID/EDID.cpp
+++ b/Userland/Libraries/LibEDID/EDID.cpp
@@ -13,6 +13,10 @@
# include <Kernel/API/FB.h>
# include <fcntl.h>
# include <unistd.h>
+
+# ifdef ENABLE_PNP_IDS_DATA
+# include <LibEDID/LibEDID/PnpIDs.h>
+# endif
#endif
namespace EDID {
@@ -552,6 +556,18 @@ String Parser::legacy_manufacturer_id() const
return id;
}
+#ifndef KERNEL
+String Parser::manufacturer_name() const
+{
+ auto manufacturer_id = legacy_manufacturer_id();
+# ifdef ENABLE_PNP_IDS_DATA
+ if (auto pnp_id_data = PnpIDs::find_by_manufacturer_id(manufacturer_id); pnp_id_data.has_value())
+ return pnp_id_data.value().manufacturer_name;
+# endif
+ return manufacturer_id;
+}
+#endif
+
u16 Parser::product_code() const
{
return read_le(&raw_edid().vendor.product_code);
diff --git a/Userland/Libraries/LibEDID/EDID.h b/Userland/Libraries/LibEDID/EDID.h
index da966708cd..5cb1317164 100644
--- a/Userland/Libraries/LibEDID/EDID.h
+++ b/Userland/Libraries/LibEDID/EDID.h
@@ -83,6 +83,10 @@ public:
#endif
String legacy_manufacturer_id() const;
+#ifndef KERNEL
+ String manufacturer_name() const;
+#endif
+
u16 product_code() const;
u32 serial_number() const;