skip to Main Content

drmModeModeInfo structure from DRM contains uint32_t vrefresh; field, and the values are actually good there i.e. I’m getting 24-75Hz for different video modes. But refresh rates aren’t integers, they’re rational numbers, right now for my display the value is 59997/1000.

Is it possible to get the precise numbers on Linux? Or at least a floating point value?

2

Answers


  1. Chosen as BEST ANSWER

    The numerator is drmModeModeInfo::clock * 1000, the clock field is in kilohertz and we need Hz for the formula.

    The denominator is the product of drmModeModeInfo::htotal and drmModeModeInfo::vtotal fields.

    For better result, I simplify the rational by dividing both numerator and denominator by their greatest common divisor. For this part, I have used an algorithm from Wikipedia.

    I’m not sure if current displays support signal frequencies above 2^32 Hz = 4.29 GHz, but even if they do not, future ones may do so, i.e. you better use 64-bit integer math there.


  2. I simply use this:

    drmModeModeInfoPtr mode = 0;
    .
    .
    double freq = mode->clock * 1000.0f / (mode->htotal * mode->vtotal);
    freq = round(freq * 1000.0f) / 1000.0f;
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search