101 memcpy(m_raw.data(), data, size);
103 const uint8_t *bytes =
static_cast<const uint8_t *
>(data);
105 auto info = di_info_parse_edid(data, size);
107 qCWarning(KWIN_CORE,
"parsing edid failed");
110 const di_edid *edid = di_info_get_edid(info);
111 const di_edid_vendor_product *productInfo = di_edid_get_vendor_product(edid);
112 const di_edid_screen_size *screenSize = di_edid_get_screen_size(edid);
115 m_physicalSize = QSize(screenSize->width_cm, screenSize->height_cm) * 10;
116 m_eisaId = parseEisaId(bytes);
119 m_serialNumber = QByteArray::number(productInfo->serial);
120 m_vendor = parseVendor(bytes);
121 QCryptographicHash
hash(QCryptographicHash::Md5);
123 m_hash = QString::fromLatin1(
hash.result().toHex());
125 m_identifier = QByteArray(productInfo->manufacturer, 3) +
" " + QByteArray::number(productInfo->product) +
" " + QByteArray::number(productInfo->serial) +
" "
126 + QByteArray::number(productInfo->manufacture_week) +
" " + QByteArray::number(productInfo->manufacture_year) +
" " + QByteArray::number(productInfo->model_year);
129 const auto chromaticity = di_edid_get_chromaticity_coords(edid);
132 QVector2D{chromaticity->red_x, chromaticity->red_y},
133 QVector2D{chromaticity->green_x, chromaticity->green_y},
134 QVector2D{chromaticity->blue_x, chromaticity->blue_y},
135 QVector2D{chromaticity->white_x, chromaticity->white_y},
138 m_colorimetry.reset();
141 const di_edid_cta *cta =
nullptr;
142 const di_edid_ext *
const *exts = di_edid_get_extensions(edid);
143 const di_cta_hdr_static_metadata_block *hdr_static_metadata =
nullptr;
144 const di_cta_colorimetry_block *
colorimetry =
nullptr;
145 for (; *exts !=
nullptr; exts++) {
146 if ((cta = di_edid_ext_get_cta(*exts))) {
151 const di_cta_data_block *
const *blocks = di_edid_cta_get_data_blocks(cta);
152 for (; *blocks !=
nullptr; blocks++) {
153 if (!hdr_static_metadata && (hdr_static_metadata = di_cta_data_block_get_hdr_static_metadata(*blocks))) {
160 if (hdr_static_metadata) {
161 m_hdrMetadata = HDRMetadata{
162 .desiredContentMinLuminance = hdr_static_metadata->desired_content_min_luminance,
163 .desiredContentMaxLuminance = hdr_static_metadata->desired_content_max_luminance > 0 ? std::make_optional(hdr_static_metadata->desired_content_max_luminance) : std::nullopt,
164 .desiredMaxFrameAverageLuminance = hdr_static_metadata->desired_content_max_frame_avg_luminance > 0 ? std::make_optional(hdr_static_metadata->desired_content_max_frame_avg_luminance) : std::nullopt,
165 .supportsPQ = hdr_static_metadata->eotfs->pq,
172 di_info_destroy(info);
223 if (!m_monitorName.isEmpty()) {
224 QString m = QString::fromLatin1(m_monitorName);
225 if (!m_serialNumber.isEmpty()) {
227 m.append(QString::fromLatin1(m_serialNumber));
230 }
else if (!m_serialNumber.isEmpty()) {
231 return QString::fromLatin1(m_serialNumber);
233 return i18n(
"unknown");