Mir

Merge lp:~vanvugt/mir/fix-1407558 into lp:mir

Proposed by Daniel van Vugt
Status: Merged
Approved by: Alan Griffiths
Approved revision: no longer in the source branch.
Merged at revision: 2193
Proposed branch: lp:~vanvugt/mir/fix-1407558
Merge into: lp:mir
Prerequisite: lp:~vanvugt/mir/wrap-the-rest
Diff against target: 48 lines (+9/-6)
3 files modified
src/platforms/mesa/real_kms_display_configuration.cpp (+6/-3)
src/utils/out.c (+1/-1)
tests/unit-tests/graphics/mesa/test_display_configuration.cpp (+2/-2)
To merge this branch: bzr merge lp:~vanvugt/mir/fix-1407558
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Approve
Alan Griffiths Approve
Review via email: mp+245557@code.launchpad.net

Commit message

Report vertical refresh rates to two decimal places so that one can tell
the difference between common frequencies such as 59.94 vs 60.00Hz.
(LP: #1407558)

I'm kind of undecided about this. Although slightly on the side of
preferring two decimal places because that's the precision most commonly
used in the industry. If people do round then they tend to round to the
nearest whole number. Never one decimal place.

To post a comment you must log in.
Revision history for this message
Alan Griffiths (alan-griffiths) wrote :

Ok

review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/platforms/mesa/real_kms_display_configuration.cpp'
2--- src/platforms/mesa/real_kms_display_configuration.cpp 2014-12-18 18:30:27 +0000
3+++ src/platforms/mesa/real_kms_display_configuration.cpp 2015-01-05 10:46:45 +0000
4@@ -54,10 +54,13 @@
5 return 0.0;
6
7 /* mode.clock is in KHz */
8- double vrefresh_hz = mode.clock * 1000.0 / (mode.htotal * mode.vtotal);
9+ double hz = (mode.clock * 100000LL /
10+ ((long)mode.htotal * (long)mode.vtotal)
11+ ) / 100.0;
12
13- /* Round to first decimal */
14- return round(vrefresh_hz * 10.0) / 10.0;
15+ // Actually we don't need floating point at all for this...
16+ // TODO: Consider converting our structs to fixed-point ints
17+ return hz;
18 }
19
20 mg::DisplayConfigurationOutputType
21
22=== modified file 'src/utils/out.c'
23--- src/utils/out.c 2014-03-06 06:05:17 +0000
24+++ src/utils/out.c 2015-01-05 10:46:45 +0000
25@@ -177,7 +177,7 @@
26 mode->vertical_resolution);
27 }
28
29- printf("%6.1f%c%c",
30+ printf("%6.2f%c%c",
31 mode->refresh_rate,
32 (m == out->current_mode) ? '*' : ' ',
33 (m == out->preferred_mode) ? '+' : ' ');
34
35=== modified file 'tests/unit-tests/graphics/mesa/test_display_configuration.cpp'
36--- tests/unit-tests/graphics/mesa/test_display_configuration.cpp 2014-12-19 02:31:34 +0000
37+++ tests/unit-tests/graphics/mesa/test_display_configuration.cpp 2015-01-05 10:46:45 +0000
38@@ -56,8 +56,8 @@
39 /* Calculate vertical refresh rate from DRM mode information */
40 if (mode.htotal != 0.0 && mode.vtotal != 0.0)
41 {
42- vrefresh_hz = mode.clock * 1000.0 / (mode.htotal * mode.vtotal);
43- vrefresh_hz = round(vrefresh_hz * 10.0) / 10.0;
44+ vrefresh_hz = (mode.clock * 100000LL /
45+ ((long)mode.htotal * (long)mode.vtotal)) / 100.0;
46 }
47
48 return mg::DisplayConfigurationMode{size, vrefresh_hz};

Subscribers

People subscribed via source and target branches