Discussion:
XrandR Verify Active Rate
re.mcclue
2021-03-27 11:35:56 UTC
Permalink
A XRRScreenResources contains multiple XRRModeInfo and RROutput (which with XRRGetOutputInfo() effectively means XRROutputInfo). Therefore, a screen can have many outputs which in turn, can have many modes. I can restrict myself to only (XRROutputInfo *)->connection == RR_Connected outputs, however this still leaves many possible modes. The, rate is a property of the mode. Because of this many-to-many relationship, how can I determine what the active rate is?
In other words:

XRRScreenResources *res = XRRGetScreenResources(display, default_root_window);
for (int i = 0; i < res->nmode; ++i) {
XRRModeInfo *mode_info = &res->modes[i];
// How do you verify this is the active rate?
double rate = (double)mode_info->dotClock / ((double)mode_info->hTotal * (double)mode_info->vTotal));
}

Sent with [ProtonMail](https://protonmail.com) Secure Email.

Sent with [ProtonMail](https://protonmail.com) Secure Email.
Aaron Plattner
2021-03-30 05:20:43 UTC
Permalink
A |XRRScreenResources| contains multiple |XRRModeInfo| and |RROutput|
(which with |XRRGetOutputInfo()| effectively means |XRROutputInfo|).
Therefore, a screen can have many outputs which in turn, can have many
modes. I can restrict myself to only |(XRROutputInfo *)->connection ==
RR_Connected| outputs, however this still leaves many possible
modes. The, rate is a property of the mode. Because of this
many-to-many relationship, how can I determine what the active rate is?
|XRRScreenResources *res = XRRGetScreenResources(display,
default_root_window); for (int i = 0; i < res->nmode; ++i) {
XRRModeInfo *mode_info = &res->modes[i]; // How do you verify this is
the active rate? double rate = (double)mode_info->dotClock /
((double)mode_info->hTotal * (double)mode_info->vTotal)); } |
An Output is active if there is a CRTC driving it. The active mode for a
CRTC is returned in the RRGetCrtcInfo reply
<https://gitlab.freedesktop.org/xorg/proto/xorgproto/blob/master/randrproto.txt#L1062>.
This reply also tells you which outputs are currently being driven by
that CRTC.

Note that even if an Output is connected (i.e. |(XRROutputInfo
*)->connection == RR_Connected|) it's not necessarily actually turned
on. Conversely, it's possible for a CRTC to be driving an Output with a
mode even if no monitor is actually connected to that Output. So if you
just want to figure out which display heads (CRTCs) are active and what
their refresh rates are, I would recommend ignoring the |connection|
state completely and only look at the states of the CRTCs.

-- Aaron

Loading...