void GetEDID(QMap<QPair<int, QString>, QByteArray> &EDIDMap, WId Window, int Screen) { if (!UIXRandr.m_valid) return; const char *displaystring = NULL; Display* display = XOpenDisplay(displaystring); if (!display) return; int screen = DefaultScreen(display); XRRScreenResources* screenresources = NULL; if (UIXRandr.m_getScreenResourcesCurrent) screenresources = UIXRandr.m_getScreenResourcesCurrent(display, RootWindow(display, screen)); else screenresources = UIXRandr.m_getScreenResources(display, RootWindow(display, screen)); if (screenresources) { Atom atoms[] = { XInternAtom(display, "EDID", False), XInternAtom(display, "EDID_DATA", False), XInternAtom(display, "XFree86_DDC_EDID1_RAWDATA", False), 0 }; for (int i = 0; i < screenresources->ncrtc; ++i) { XRRCrtcInfo* crtcinfo = UIXRandr.m_getCRTCInfo(display, screenresources, screenresources->crtcs[i]); if (!crtcinfo) continue; LOG(VB_GENERAL, LOG_INFO, QString("CRTC #%1 has %2 outputs").arg(i).arg(crtcinfo->noutput)); if (crtcinfo->noutput >= 1) { unsigned char* data = NULL; int actualformat = 0; unsigned long numberofitems = 0; unsigned long bytesafter = 0; Atom actualtype = 0; for (int j = 0; j < 3; ++j) { if (UIXRandr.m_getOutputProperty(display, crtcinfo->outputs[0], atoms[j], 0, 100, False, False, AnyPropertyType, &actualtype, &actualformat, &numberofitems, &bytesafter, &data) == Success) { if (actualtype == XA_INTEGER && actualformat == 8 && numberofitems > 0 && (numberofitems % 128 == 0)) { QByteArray edid((const char*)data, numberofitems); EDIDMap.insert(qMakePair(50, QString("Xrandr")), edid); break; } } } } UIXRandr.m_freeCRTCInfo(crtcinfo); } UIXRandr.m_freeScreenResources(screenresources); } XCloseDisplay(display); }
void GetEDID(QMap<QPair<int, QString>, QByteArray> &EDIDMap, WId Window, int Screen) { (void)Screen; NVApiLibrary* lib = NVApiLibrary::Create(); if (!lib) return; MONITORINFOEX monitor; memset(&monitor, 0, sizeof(MONITORINFOEX)); monitor.cbSize = sizeof(MONITORINFOEX); HMONITOR monitorid = MonitorFromWindow(Window, MONITOR_DEFAULTTONEAREST); GetMonitorInfo(monitorid, &monitor); NvDisplayHandle handle; if (lib->m_nvapiGetAssociatedDisplayHandle(monitor.szDevice, &handle) != NVAPI_OK) return; NvPhysicalGpuHandle gpus[NVAPI_MAX_PHYSICAL_GPUS] = {0}; NvU32 numbergpus = 0; if (lib->m_nvapiGetPhysicalGPUsFromDisplay(handle, gpus, &numbergpus) == NVAPI_OK && numbergpus > 0) { NvU32 displayid; if (lib->m_nvapiGetAssociatedDisplayID(handle, &displayid) != NVAPI_OK) return; NV_EDID nvedid = {0}; nvedid.version = NV_EDID_VER2; if (lib->m_nvapiGPUGetEDID(gpus[0], displayid, &nvedid) != NVAPI_OK) return; QByteArray edid((const char*)nvedid.EDID_Data, NV_EDID_DATA_SIZE); if (nvedid.sizeofEDID > NV_EDID_DATA_SIZE) { NV_EDID nvedid2 = {0}; nvedid2.version = NV_EDID_VER2; nvedid2.offset = NV_EDID_DATA_SIZE; // NB this probably won't work as 'offset' is only strictly available in NV_EDID_V3 if (lib->m_nvapiGPUGetEDID(gpus[0], displayid, &nvedid2) == NVAPI_OK) { QByteArray edid2((const char*)nvedid2.EDID_Data, NV_EDID_DATA_SIZE); edid.append(edid2); } } EDIDMap.insert(qMakePair(90, QString("Nvidia API")), UIEDID::TrimEDID(edid)); return; } }
static void dps_connected_edid(struct dce4 *dce) { unsigned i; for (i = 0; i < dce->ddev.crtcs_n; ++i) { if ((dce->dps_used & BIT(i)) == 0) continue; if (!dce->dps[i].connected) continue; /* it's not fatal to fail to get the edid */ edid(dce, i); } }