Skip to content

Commit

Permalink
drm: implement edid parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
vaxerski committed Jul 2, 2024
1 parent 7e4ae2e commit ef93a10
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 2 deletions.
18 changes: 17 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down Expand Up @@ -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)

Expand Down
25 changes: 24 additions & 1 deletion src/backend/drm/DRM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,14 @@ extern "C" {
#include <xf86drm.h>
#include <xf86drmMode.h>
#include <libdisplay-info/cvt.h>
#include <libdisplay-info/info.h>
#include <libdisplay-info/edid.h>
}

#include "Props.hpp"
#include "FormatUtils.hpp"
#include "Shared.hpp"
#include "hwdata.hpp"

using namespace Aquamarine;
using namespace Hyprutils::Memory;
Expand Down Expand Up @@ -840,7 +843,27 @@ drmModeModeInfo* Aquamarine::SDRMConnector::getCurrentMode() {
}

void Aquamarine::SDRMConnector::parseEDID(std::vector<uint8_t> 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) {
Expand Down

0 comments on commit ef93a10

Please sign in to comment.