modetest: Add support for setting mode having floating vertical refresh rate
authorDevarsh Thakkar <devarsh.thakkar@xilinx.com>
Fri, 15 Nov 2019 14:31:00 +0000 (06:31 -0800)
committerVille Syrjälä <ville.syrjala@linux.intel.com>
Mon, 25 Nov 2019 14:13:43 +0000 (16:13 +0200)
commita2d588fe12dd55b222bcd31d683bd17a41326df7
tree2ce2be03c7e053ed671f69f0ead3e4c4c8839205
parent9d48895425a2d51287455e2c63517cdacd879953
modetest: Add support for setting mode having floating vertical refresh rate

For the scenario where user may require to modeset with a mode
supporting a fractional value for vertical refresh-rate,
appropriate mode can be selected by searching for mode
having matching fractional vertical refresh rate using
below equation.

vrefresh = (1000 * pixel clock) / (htotal * vtotal) Hz.

We do this way since driver doesn't return float value of vrefresh
as it use int for vrefresh in struct drm_mode_info, but we can derive
the actual value using pixel clock, horizontal total size and
vertical total size values.

So for e.g. if user want to select mode having 59.94 Hz as refresh rate
then with this patch it be can done as shown in below command,
given there is an appropriate mode is available :

modetest -M xlnx -s 39:1920x1080-59.94@BG24 -v

NOTE: Above command was tested on xilinx DRM driver with DP
monitor which was supporting mode having 59.94 Hz refresh rate.

V2: Update commit message
V3: Update with below changes as per review comments :
  1) Use epsilon for vrefresh comparison
  2) Use implicit type-casting wherever possible
V4: Keep patch version history on main commit message

Signed-off-by: Devarsh Thakkar <devarsh.thakkar@xilinx.com>
Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
tests/modetest/modetest.c