XrandR Verify Active Rate

Aaron Plattner aplattner at nvidia.com
Tue Mar 30 05:20:43 UTC 2021


On 3/27/21 4:35 AM, re.mcclue wrote:
> 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)); } |
>
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

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.x.org/archives/xorg/attachments/20210329/14f5d638/attachment.htm>


More information about the xorg mailing list