Mir

Merge lp:~raof/mir/subpixel-info-for-mesa-kms into lp:mir

Proposed by Chris Halse Rogers
Status: Merged
Approved by: Kevin DuBois
Approved revision: 3641
Merged at revision: 3646
Proposed branch: lp:~raof/mir/subpixel-info-for-mesa-kms
Merge into: lp:mir
Prerequisite: lp:~raof/mir/plumb-subpixel-info
Diff against target: 244 lines (+177/-3)
4 files modified
src/platforms/mesa/server/kms/real_kms_display_configuration.cpp (+23/-1)
tests/include/mir/test/doubles/mock_drm.h (+2/-1)
tests/mir_test_doubles/mock_drm.cpp (+3/-1)
tests/unit-tests/graphics/mesa/kms/test_display_configuration.cpp (+149/-0)
To merge this branch: bzr merge lp:~raof/mir/subpixel-info-for-mesa-kms
Reviewer Review Type Date Requested Status
Mir CI Bot continuous-integration Approve
Kevin DuBois (community) Approve
Cemil Azizoglu (community) Approve
Review via email: mp+302496@code.launchpad.net

Commit message

Provide subpixel arrangement info from the mesa-kms platform.

To post a comment you must log in.
Revision history for this message
Mir CI Bot (mir-ci-bot) wrote :

FAILED: Continuous integration, rev:3641
https://mir-jenkins.ubuntu.com/job/mir-ci/1421/
Executed test runs:
    FAILURE: https://mir-jenkins.ubuntu.com/job/build-mir/1734/console
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-0-fetch/1787
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=vivid+overlay/1778
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=xenial+overlay/1778
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=yakkety/1778
    FAILURE: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=clang,platform=mesa,release=vivid+overlay/1758/console
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=xenial+overlay/1758
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=xenial+overlay/1758/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=yakkety/1758
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=yakkety/1758/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=cross-armhf,compiler=gcc,platform=android,release=vivid+overlay/1758
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=cross-armhf,compiler=gcc,platform=android,release=vivid+overlay/1758/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=android,release=vivid+overlay/1758
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=android,release=vivid+overlay/1758/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=mesa,release=xenial+overlay/1758
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=mesa,release=xenial+overlay/1758/artifact/output/*zip*/output.zip

Click here to trigger a rebuild:
https://mir-jenkins.ubuntu.com/job/mir-ci/1421/rebuild

review: Needs Fixing (continuous-integration)
Revision history for this message
Cemil Azizoglu (cemil-azizoglu) wrote :

LGTM

review: Approve
Revision history for this message
Chris Halse Rogers (raof) wrote :

11: [ FAILED ] DisplayConfiguration/DisplaySubpixelSetting.can_get_all_subpixel_arrangements/1, where GetParam() = 1 (695 ms)

Hm. Have I added a racy test?

Revision history for this message
Kevin DuBois (kdub) wrote :

minor, default argument:
+ drmModeSubPixel subpixel_arrangement = DRM_MODE_SUBPIXEL_UNKNOWN);

+1 otherwise

review: Approve
Revision history for this message
Mir CI Bot (mir-ci-bot) wrote :

PASSED: Continuous integration, rev:3641
https://mir-jenkins.ubuntu.com/job/mir-ci/1434/
Executed test runs:
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-mir/1763
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-0-fetch/1817
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=vivid+overlay/1808
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=xenial+overlay/1808
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=yakkety/1808
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=clang,platform=mesa,release=yakkety/1787
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=clang,platform=mesa,release=yakkety/1787/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=xenial+overlay/1787
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=xenial+overlay/1787/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=yakkety/1787
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=yakkety/1787/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=cross-armhf,compiler=gcc,platform=android,release=vivid+overlay/1787
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=cross-armhf,compiler=gcc,platform=android,release=vivid+overlay/1787/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=android,release=vivid+overlay/1787
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=android,release=vivid+overlay/1787/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=mesa,release=xenial+overlay/1787
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=mesa,release=xenial+overlay/1787/artifact/output/*zip*/output.zip

Click here to trigger a rebuild:
https://mir-jenkins.ubuntu.com/job/mir-ci/1434/rebuild

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/server/kms/real_kms_display_configuration.cpp'
2--- src/platforms/mesa/server/kms/real_kms_display_configuration.cpp 2016-08-10 00:54:06 +0000
3+++ src/platforms/mesa/server/kms/real_kms_display_configuration.cpp 2016-08-10 00:54:06 +0000
4@@ -69,6 +69,27 @@
5 return static_cast<mg::DisplayConfigurationOutputType>(connector_type);
6 }
7
8+MirSubpixelArrangement kms_subpixel_to_mir_subpixel(uint32_t subpixel)
9+{
10+ switch (subpixel)
11+ {
12+ case DRM_MODE_SUBPIXEL_UNKNOWN:
13+ return mir_subpixel_arrangement_unknown;
14+ case DRM_MODE_SUBPIXEL_HORIZONTAL_RGB:
15+ return mir_subpixel_arrangement_horizontal_rgb;
16+ case DRM_MODE_SUBPIXEL_HORIZONTAL_BGR:
17+ return mir_subpixel_arrangement_horizontal_bgr;
18+ case DRM_MODE_SUBPIXEL_VERTICAL_RGB:
19+ return mir_subpixel_arrangement_vertical_rgb;
20+ case DRM_MODE_SUBPIXEL_VERTICAL_BGR:
21+ return mir_subpixel_arrangement_vertical_bgr;
22+ case DRM_MODE_SUBPIXEL_NONE:
23+ return mir_subpixel_arrangement_none;
24+ default:
25+ return mir_subpixel_arrangement_unknown;
26+ }
27+}
28+
29 }
30
31 mgm::RealKMSDisplayConfiguration::RealKMSDisplayConfiguration(int drm_fd)
32@@ -220,7 +241,7 @@
33 physical_size, connected, false, geom::Point(),
34 current_mode_index, mir_pixel_format_xrgb_8888,
35 mir_power_mode_on, mir_orientation_normal,
36- 1.0f, mir_form_factor_monitor, mir_subpixel_arrangement_unknown});
37+ 1.0f, mir_form_factor_monitor, kms_subpixel_to_mir_subpixel(connector.subpixel)});
38 }
39 else
40 {
41@@ -247,6 +268,7 @@
42 output.physical_size_mm = physical_size;
43 output.connected = connected;
44 output.current_format = mir_pixel_format_xrgb_8888;
45+ output.subpixel_arrangement = kms_subpixel_to_mir_subpixel(connector.subpixel);
46 }
47 }
48
49
50=== modified file 'tests/include/mir/test/doubles/mock_drm.h'
51--- tests/include/mir/test/doubles/mock_drm.h 2016-05-16 06:26:33 +0000
52+++ tests/include/mir/test/doubles/mock_drm.h 2016-08-10 00:54:06 +0000
53@@ -51,7 +51,8 @@
54 void add_connector(uint32_t connector_id, uint32_t type, drmModeConnection connection,
55 uint32_t encoder_id, std::vector<drmModeModeInfo>& modes,
56 std::vector<uint32_t>& possible_encoder_ids,
57- geometry::Size const& physical_size);
58+ geometry::Size const& physical_size,
59+ drmModeSubPixel subpixel_arrangement = DRM_MODE_SUBPIXEL_UNKNOWN);
60
61 void prepare();
62 void reset();
63
64=== modified file 'tests/mir_test_doubles/mock_drm.cpp'
65--- tests/mir_test_doubles/mock_drm.cpp 2016-05-20 02:40:59 +0000
66+++ tests/mir_test_doubles/mock_drm.cpp 2016-08-10 00:54:06 +0000
67@@ -155,7 +155,8 @@
68 uint32_t encoder_id,
69 std::vector<drmModeModeInfo>& modes,
70 std::vector<uint32_t>& possible_encoder_ids,
71- geom::Size const& physical_size)
72+ geom::Size const& physical_size,
73+ drmModeSubPixel subpixel_arrangement)
74 {
75 drmModeConnector connector = drmModeConnector();
76
77@@ -169,6 +170,7 @@
78 connector.count_encoders = possible_encoder_ids.size();
79 connector.mmWidth = physical_size.width.as_uint32_t();
80 connector.mmHeight = physical_size.height.as_uint32_t();
81+ connector.subpixel = subpixel_arrangement;
82
83 connectors.push_back(connector);
84 }
85
86=== modified file 'tests/unit-tests/graphics/mesa/kms/test_display_configuration.cpp'
87--- tests/unit-tests/graphics/mesa/kms/test_display_configuration.cpp 2016-08-10 00:54:06 +0000
88+++ tests/unit-tests/graphics/mesa/kms/test_display_configuration.cpp 2016-08-10 00:54:06 +0000
89@@ -303,6 +303,155 @@
90 EXPECT_EQ(expected_outputs.size(), output_count);
91 }
92
93+TEST_F(MesaDisplayConfigurationTest, reads_subpixel_information_correctly)
94+{
95+ using namespace ::testing;
96+
97+ /* Set up DRM resources */
98+ uint32_t const crtc0_id{10};
99+ uint32_t const encoder0_id{20};
100+ uint32_t const connector0_id{30};
101+ geom::Size const connector0_physical_size_mm{480, 270};
102+ std::vector<uint32_t> possible_encoder_ids_empty;
103+ uint32_t const possible_crtcs_mask_empty{0};
104+
105+ mtd::FakeDRMResources& resources(mock_drm.fake_drm);
106+
107+ struct TestData
108+ {
109+ drmModeSubPixel drm_subpixel;
110+ MirSubpixelArrangement mir_subpixel;
111+ };
112+ std::vector<TestData> const test_data = {
113+ { DRM_MODE_SUBPIXEL_UNKNOWN, mir_subpixel_arrangement_unknown },
114+ { DRM_MODE_SUBPIXEL_HORIZONTAL_RGB, mir_subpixel_arrangement_horizontal_rgb },
115+ { DRM_MODE_SUBPIXEL_HORIZONTAL_BGR, mir_subpixel_arrangement_horizontal_bgr },
116+ { DRM_MODE_SUBPIXEL_VERTICAL_RGB, mir_subpixel_arrangement_vertical_rgb },
117+ { DRM_MODE_SUBPIXEL_VERTICAL_BGR, mir_subpixel_arrangement_vertical_bgr },
118+ { DRM_MODE_SUBPIXEL_NONE, mir_subpixel_arrangement_none }
119+ };
120+
121+ for (auto& data : test_data)
122+ {
123+
124+ resources.reset();
125+
126+ resources.add_crtc(crtc0_id, modes0[1]);
127+
128+ resources.add_encoder(encoder0_id, crtc0_id, possible_crtcs_mask_empty);
129+
130+ resources.add_connector(connector0_id, DRM_MODE_CONNECTOR_HDMIA,
131+ DRM_MODE_CONNECTED, encoder0_id,
132+ modes0, possible_encoder_ids_empty,
133+ connector0_physical_size_mm,
134+ data.drm_subpixel);
135+
136+ resources.prepare();
137+
138+ /* Test body */
139+ auto display = create_display(create_platform());
140+
141+ auto conf = display->configuration();
142+
143+
144+ size_t output_count{0};
145+
146+ conf->for_each_output([&](mg::DisplayConfigurationOutput const& output)
147+ {
148+ EXPECT_THAT(output.subpixel_arrangement, Eq(data.mir_subpixel));
149+ ++output_count;
150+ });
151+
152+ EXPECT_THAT(output_count, Ge(1));
153+ }
154+}
155+
156+TEST_F(MesaDisplayConfigurationTest, reads_updated_subpixel_information)
157+{
158+ using namespace ::testing;
159+ using namespace std::chrono_literals;
160+
161+ /* Set up DRM resources */
162+ uint32_t const crtc0_id{10};
163+ uint32_t const encoder0_id{20};
164+ uint32_t const connector0_id{30};
165+ geom::Size const connector0_physical_size_mm{480, 270};
166+ std::vector<uint32_t> possible_encoder_ids_empty;
167+ uint32_t const possible_crtcs_mask_empty{0};
168+
169+ mtd::FakeDRMResources& resources(mock_drm.fake_drm);
170+
171+ resources.reset();
172+
173+ resources.add_crtc(crtc0_id, modes0[1]);
174+
175+ resources.add_encoder(encoder0_id, crtc0_id, possible_crtcs_mask_empty);
176+
177+ resources.add_connector(connector0_id, DRM_MODE_CONNECTOR_HDMIA,
178+ DRM_MODE_CONNECTED, encoder0_id,
179+ modes0, possible_encoder_ids_empty,
180+ connector0_physical_size_mm,
181+ DRM_MODE_SUBPIXEL_NONE);
182+
183+ resources.prepare();
184+
185+ struct TestData
186+ {
187+ drmModeSubPixel drm_subpixel;
188+ MirSubpixelArrangement mir_subpixel;
189+ };
190+ std::vector<TestData> const test_data = {
191+ { DRM_MODE_SUBPIXEL_UNKNOWN, mir_subpixel_arrangement_unknown },
192+ { DRM_MODE_SUBPIXEL_HORIZONTAL_RGB, mir_subpixel_arrangement_horizontal_rgb },
193+ { DRM_MODE_SUBPIXEL_HORIZONTAL_BGR, mir_subpixel_arrangement_horizontal_bgr },
194+ { DRM_MODE_SUBPIXEL_VERTICAL_RGB, mir_subpixel_arrangement_vertical_rgb },
195+ { DRM_MODE_SUBPIXEL_VERTICAL_BGR, mir_subpixel_arrangement_vertical_bgr },
196+ { DRM_MODE_SUBPIXEL_NONE, mir_subpixel_arrangement_none }
197+ };
198+
199+ auto display = create_display(create_platform());
200+ auto const syspath = fake_devices.add_device("drm", "card2", NULL, {}, {"DEVTYPE", "drm_minor"});
201+
202+ for (auto& data : test_data)
203+ {
204+
205+ resources.reset();
206+
207+ resources.add_crtc(crtc0_id, modes0[1]);
208+
209+ resources.add_encoder(encoder0_id, crtc0_id, possible_crtcs_mask_empty);
210+
211+ resources.add_connector(connector0_id, DRM_MODE_CONNECTOR_HDMIA,
212+ DRM_MODE_CONNECTED, encoder0_id,
213+ modes0, possible_encoder_ids_empty,
214+ connector0_physical_size_mm,
215+ data.drm_subpixel);
216+
217+ resources.prepare();
218+
219+ MainLoop ml;
220+ mt::Signal handler_signal;
221+ display->register_configuration_change_handler(ml.ml, [&handler_signal]{handler_signal.raise();});
222+ fake_devices.emit_device_changed(syspath);
223+ ASSERT_TRUE(handler_signal.wait_for(10s));
224+
225+
226+ /* Test body */
227+ auto conf = display->configuration();
228+
229+
230+ size_t output_count{0};
231+
232+ conf->for_each_output([&](mg::DisplayConfigurationOutput const& output)
233+ {
234+ EXPECT_THAT(output.subpixel_arrangement, Eq(data.mir_subpixel));
235+ ++output_count;
236+ });
237+
238+ EXPECT_THAT(output_count, Ge(1));
239+ }
240+}
241+
242 TEST_F(MesaDisplayConfigurationTest, get_kms_connector_id_returns_correct_id)
243 {
244 uint32_t const crtc0_id{10};

Subscribers

People subscribed via source and target branches