mirror of
https://github.com/hyprwm/aquamarine.git
synced 2024-11-16 22:05:58 +01:00
drm: implement edid parsing
This commit is contained in:
parent
7e4ae2e226
commit
20a99be9f4
4 changed files with 57 additions and 2 deletions
|
@ -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)
|
||||
|
||||
|
|
8
data/hwdata.hpp.in
Normal file
8
data/hwdata.hpp.in
Normal file
|
@ -0,0 +1,8 @@
|
|||
#include <unordered_map>
|
||||
#include <string>
|
||||
|
||||
#define __AQ_PNP_PROP(pnp, manu) {pnp, manu}
|
||||
inline std::unordered_map<std::string, std::string> PNPIDS = {
|
||||
@HWDATA_PNP_IDS@
|
||||
};
|
||||
#undef __AQ_PNP_PROP
|
8
data/hwdata.sh
Executable file
8
data/hwdata.sh
Executable file
|
@ -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
|
||||
|
|
@ -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;
|
||||
|
@ -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) {
|
||||
|
|
Loading…
Reference in a new issue