diff --git a/CMakeLists.txt b/CMakeLists.txt index 9adf819..79a908c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -36,7 +36,7 @@ file(GLOB_RECURSE PUBLIC_HEADERS CONFIGURE_DEPENDS "include/*.hpp") add_library(aquamarine SHARED ${SRCFILES}) target_include_directories( aquamarine PUBLIC "./include" - PRIVATE "./src" "./src/include" "./protocols" + PRIVATE "./src" "./src/include" "./protocols" "./build" ) set_target_properties(aquamarine PROPERTIES VERSION ${AQUAMARINE_VERSION} @@ -79,6 +79,22 @@ protocolWayland() protocolNew("stable/xdg-shell" "xdg-shell" false) protocolNew("stable/linux-dmabuf" "linux-dmabuf-v1" false) +# Generate hwdata info +pkg_get_variable(HWDATA_DIR hwdata pkgdatadir) +message(STATUS "Running ${CMAKE_SOURCE_DIR}/data/hwdata.sh < ${HWDATA_DIR}/pnp.ids") +execute_process( + COMMAND /bin/sh -c "${CMAKE_SOURCE_DIR}/data/hwdata.sh < ${HWDATA_DIR}/pnp.ids" + RESULT_VARIABLE HWDATA_PNP_RESULT + OUTPUT_VARIABLE HWDATA_PNP_IDS + ENCODING UTF8 +) + +if (NOT HWDATA_PNP_RESULT MATCHES 0) + message(WARNING "hwdata gathering pnps failed") +endif() + +configure_file(data/hwdata.hpp.in hwdata.hpp @ONLY) + # tests add_custom_target(tests) diff --git a/data/hwdata.hpp.in b/data/hwdata.hpp.in new file mode 100644 index 0000000..99ef6a2 --- /dev/null +++ b/data/hwdata.hpp.in @@ -0,0 +1,8 @@ +#include +#include + +#define __AQ_PNP_PROP(pnp, manu) {pnp, manu} +inline std::unordered_map PNPIDS = { +@HWDATA_PNP_IDS@ +}; +#undef __AQ_PNP_PROP diff --git a/data/hwdata.sh b/data/hwdata.sh new file mode 100755 index 0000000..751553a --- /dev/null +++ b/data/hwdata.sh @@ -0,0 +1,8 @@ +#!/bin/sh + +while read -r id vendor; do + [ "${#id}" = 3 ] || exit 1 + + printf "\t__AQ_PNP_PROP(\"%s\", \"%s\"),\n" "$id" "$vendor" +done + diff --git a/src/backend/drm/DRM.cpp b/src/backend/drm/DRM.cpp index 7c49bef..4bba0d4 100644 --- a/src/backend/drm/DRM.cpp +++ b/src/backend/drm/DRM.cpp @@ -14,11 +14,14 @@ extern "C" { #include #include #include +#include +#include } #include "Props.hpp" #include "FormatUtils.hpp" #include "Shared.hpp" +#include "hwdata.hpp" using namespace Aquamarine; using namespace Hyprutils::Memory; @@ -840,7 +843,27 @@ drmModeModeInfo* Aquamarine::SDRMConnector::getCurrentMode() { } void Aquamarine::SDRMConnector::parseEDID(std::vector data) { - // TODO: libdisplay-info prolly + auto info = di_info_parse_edid(data.data(), data.size()); + if (!info) { + backend->backend->log(AQ_LOG_ERROR, "drm: failed to parse edid"); + return; + } + + auto edid = di_info_get_edid(info); + auto venProduct = di_edid_get_vendor_product(edid); + auto pnpID = std::string{venProduct->manufacturer, 3}; + if (PNPIDS.contains(pnpID)) + make = PNPIDS.at(pnpID); + else + make = pnpID; + + auto mod = di_info_get_model(info); + auto ser = di_info_get_serial(info); + + model = mod ? mod : ""; + serial = ser ? ser : ""; + + di_info_destroy(info); } void Aquamarine::SDRMConnector::connect(drmModeConnector* connector) {