Mir

Merge lp:~alan-griffiths/mir/fix-1463873 into lp:mir

Proposed by Alan Griffiths on 2015-11-16
Status: Merged
Merged at revision: 3119
Proposed branch: lp:~alan-griffiths/mir/fix-1463873
Merge into: lp:mir
Diff against target: 199 lines (+28/-18)
7 files modified
src/platforms/android/server/display.cpp (+1/-1)
src/platforms/android/server/display_configuration.cpp (+1/-1)
src/platforms/android/server/display_name.h (+11/-1)
src/platforms/android/server/fb_device.cpp (+1/-1)
src/platforms/android/server/hwc_blanking_control.cpp (+1/-1)
src/platforms/android/server/real_hwc_wrapper.cpp (+12/-12)
tests/include/mir/test/doubles/stub_display_builder.h (+1/-1)
To merge this branch: bzr merge lp:~alan-griffiths/mir/fix-1463873
Reviewer Review Type Date Requested Status
PS Jenkins bot continuous-integration Needs Fixing on 2015-11-20
Kevin DuBois (community) 2015-11-16 Approve on 2015-11-16
Alexandros Frantzis (community) Approve on 2015-11-16
Alberto Aguirre (community) 2015-11-16 Approve on 2015-11-16
Review via email: mp+277552@code.launchpad.net

Commit message

platforms/android: Don't conflate the display numbering in HWC with the output numbering in Mir (as one is zero based and the other one based).

Description of the change

platforms/android: Don't conflate the display numbering in HWC with the output numbering in Mir (as one is zero based and the other one based).

This enables nested servers to specify the outputs on which to create fullscreen surfaces.

To post a comment you must log in.
Alberto Aguirre (albaguirre) wrote :

LGTM

review: Approve
Alexandros Frantzis (afrantzis) wrote :

Looks good. I would also like for Kevin to take a look before we merge.

review: Approve
Kevin DuBois (kdub) wrote :

looks good to me.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/platforms/android/server/display.cpp'
2--- src/platforms/android/server/display.cpp 2015-10-07 15:32:10 +0000
3+++ src/platforms/android/server/display.cpp 2015-11-19 10:44:11 +0000
4@@ -287,7 +287,7 @@
5
6 void mga::Display::on_vsync(DisplayName name) const
7 {
8- display_report->report_vsync(name);
9+ display_report->report_vsync(as_output_id(name).as_value());
10 }
11
12 void mga::Display::register_configuration_change_handler(
13
14=== modified file 'src/platforms/android/server/display_configuration.cpp'
15--- src/platforms/android/server/display_configuration.cpp 2015-10-30 11:07:02 +0000
16+++ src/platforms/android/server/display_configuration.cpp 2015-11-19 10:44:11 +0000
17@@ -100,7 +100,7 @@
18
19 mg::DisplayConfigurationOutput& mga::DisplayConfiguration::operator[](mg::DisplayConfigurationOutputId const& disp_id)
20 {
21- auto id = disp_id.as_value();
22+ auto id = disp_id.as_value() - 1;
23 if (id != primary_id && id != external_id)
24 BOOST_THROW_EXCEPTION(std::invalid_argument("invalid display id"));
25 return configurations[id];
26
27=== modified file 'src/platforms/android/server/display_name.h'
28--- src/platforms/android/server/display_name.h 2015-01-22 09:00:14 +0000
29+++ src/platforms/android/server/display_name.h 2015-11-19 10:44:11 +0000
30@@ -19,6 +19,7 @@
31 #ifndef MIR_GRAPHICS_ANDROID_DISPLAY_NAME_H_
32 #define MIR_GRAPHICS_ANDROID_DISPLAY_NAME_H_
33
34+#include "mir/graphics/display_configuration.h"
35 #include <hardware/hwcomposer.h>
36
37 namespace mir
38@@ -28,13 +29,22 @@
39 namespace android
40 {
41
42-enum DisplayName
43+enum class DisplayName
44 {
45 primary = HWC_DISPLAY_PRIMARY,
46 external = HWC_DISPLAY_EXTERNAL,
47 virt = HWC_DISPLAY_VIRTUAL
48 };
49
50+inline auto as_output_id(DisplayName name) -> DisplayConfigurationOutputId
51+{
52+ return DisplayConfigurationOutputId{1 + static_cast<int>(name)};
53+}
54+
55+inline auto as_hwc_display(DisplayName name) -> int
56+{
57+ return static_cast<int>(name);
58+}
59 }
60 }
61 }
62
63=== modified file 'src/platforms/android/server/fb_device.cpp'
64--- src/platforms/android/server/fb_device.cpp 2015-10-07 12:07:00 +0000
65+++ src/platforms/android/server/fb_device.cpp 2015-11-19 10:44:11 +0000
66@@ -58,7 +58,7 @@
67 auto const connected = (display_name == DisplayName::primary);
68
69 return {
70- static_cast<mg::DisplayConfigurationOutputId>(display_name),
71+ as_output_id(display_name),
72 mg::DisplayConfigurationCardId{0},
73 mg::DisplayConfigurationOutputType::lvds,
74 std::vector<MirPixelFormat>{mga::to_mir_format(fb_device->format)},
75
76=== modified file 'src/platforms/android/server/hwc_blanking_control.cpp'
77--- src/platforms/android/server/hwc_blanking_control.cpp 2015-10-02 04:27:34 +0000
78+++ src/platforms/android/server/hwc_blanking_control.cpp 2015-11-19 10:44:11 +0000
79@@ -139,7 +139,7 @@
80 }
81
82 return {
83- static_cast<mg::DisplayConfigurationOutputId>(name),
84+ as_output_id(name),
85 mg::DisplayConfigurationCardId{0},
86 type,
87 {display_format},
88
89=== modified file 'src/platforms/android/server/real_hwc_wrapper.cpp'
90--- src/platforms/android/server/real_hwc_wrapper.cpp 2015-10-07 02:34:05 +0000
91+++ src/platforms/android/server/real_hwc_wrapper.cpp 2015-11-19 10:44:11 +0000
92@@ -138,7 +138,7 @@
93
94 void mga::RealHwcWrapper::vsync_signal_on(DisplayName display_name) const
95 {
96- if (auto rc = hwc_device->eventControl(hwc_device.get(), display_name, HWC_EVENT_VSYNC, 1))
97+ if (auto rc = hwc_device->eventControl(hwc_device.get(), as_hwc_display(display_name), HWC_EVENT_VSYNC, 1))
98 {
99 std::stringstream ss;
100 ss << "error turning vsync signal on. rc = " << std::hex << rc;
101@@ -149,7 +149,7 @@
102
103 void mga::RealHwcWrapper::vsync_signal_off(DisplayName display_name) const
104 {
105- if (auto rc = hwc_device->eventControl(hwc_device.get(), display_name, HWC_EVENT_VSYNC, 0))
106+ if (auto rc = hwc_device->eventControl(hwc_device.get(), as_hwc_display(display_name), HWC_EVENT_VSYNC, 0))
107 {
108 std::stringstream ss;
109 ss << "error turning vsync signal off. rc = " << std::hex << rc;
110@@ -160,7 +160,7 @@
111
112 void mga::RealHwcWrapper::display_on(DisplayName display_name) const
113 {
114- if (auto rc = hwc_device->blank(hwc_device.get(), display_name, 0))
115+ if (auto rc = hwc_device->blank(hwc_device.get(), as_hwc_display(display_name), 0))
116 {
117 std::stringstream ss;
118 ss << "error turning display on. rc = " << std::hex << rc;
119@@ -171,7 +171,7 @@
120
121 void mga::RealHwcWrapper::display_off(DisplayName display_name) const
122 {
123- if (auto rc = hwc_device->blank(hwc_device.get(), display_name, 1))
124+ if (auto rc = hwc_device->blank(hwc_device.get(), as_hwc_display(display_name), 1))
125 {
126 std::stringstream ss;
127 ss << "error turning display off. rc = " << std::hex << rc;
128@@ -249,7 +249,7 @@
129 static size_t const max_configs = 16;
130 size_t num_configs = max_configs;
131 static uint32_t display_config[max_configs] = {};
132- if (hwc_device->getDisplayConfigs(hwc_device.get(), display_name, display_config, &num_configs))
133+ if (hwc_device->getDisplayConfigs(hwc_device.get(), as_hwc_display(display_name), display_config, &num_configs))
134 return {};
135
136 auto i = 0u;
137@@ -263,12 +263,12 @@
138 DisplayName display_name, ConfigId config, uint32_t const* attributes, int32_t* values) const
139 {
140 return hwc_device->getDisplayAttributes(
141- hwc_device.get(), display_name, config.as_value(), attributes, values);
142+ hwc_device.get(), as_hwc_display(display_name), config.as_value(), attributes, values);
143 }
144
145 void mga::RealHwcWrapper::power_mode(DisplayName display_name, PowerMode mode) const
146 {
147- if (auto rc = hwc_device->setPowerMode(hwc_device.get(), display_name, static_cast<int>(mode)))
148+ if (auto rc = hwc_device->setPowerMode(hwc_device.get(), as_hwc_display(display_name), static_cast<int>(mode)))
149 {
150 std::stringstream ss;
151 ss << "error setting power mode. rc = " << std::hex << rc;
152@@ -280,16 +280,16 @@
153 bool mga::RealHwcWrapper::has_active_config(DisplayName display_name) const
154 {
155 int const no_active_config = -1;
156- return hwc_device->getActiveConfig(hwc_device.get(), display_name) != no_active_config;
157+ return hwc_device->getActiveConfig(hwc_device.get(), as_hwc_display(display_name)) != no_active_config;
158 }
159
160 mga::ConfigId mga::RealHwcWrapper::active_config_for(DisplayName display_name) const
161 {
162- int id = hwc_device->getActiveConfig(hwc_device.get(), display_name);
163+ int id = hwc_device->getActiveConfig(hwc_device.get(), as_hwc_display(display_name));
164 if (id == -1)
165 {
166 std::stringstream ss;
167- ss << "No active configuration for display: " << display_name;
168+ ss << "No active configuration for display: " << as_hwc_display(display_name);
169 BOOST_THROW_EXCEPTION(std::runtime_error(ss.str()));
170 }
171 return mga::ConfigId{static_cast<uint32_t>(id)};
172@@ -297,7 +297,7 @@
173
174 void mga::RealHwcWrapper::set_active_config(DisplayName display_name, ConfigId id) const
175 {
176- int rc = hwc_device->setActiveConfig(hwc_device.get(), display_name, id.as_value());
177+ int rc = hwc_device->setActiveConfig(hwc_device.get(), as_hwc_display(display_name), id.as_value());
178 if (rc < 0)
179 BOOST_THROW_EXCEPTION(std::system_error(rc, std::system_category(), "unable to set active display config"));
180 }
181@@ -305,5 +305,5 @@
182 bool mga::RealHwcWrapper::display_connected(DisplayName display_name) const
183 {
184 size_t num_configs = 0;
185- return hwc_device->getDisplayConfigs(hwc_device.get(), display_name, nullptr, &num_configs) == 0;
186+ return hwc_device->getDisplayConfigs(hwc_device.get(), as_hwc_display(display_name), nullptr, &num_configs) == 0;
187 }
188
189=== modified file 'tests/include/mir/test/doubles/stub_display_builder.h'
190--- tests/include/mir/test/doubles/stub_display_builder.h 2015-07-27 07:24:50 +0000
191+++ tests/include/mir/test/doubles/stub_display_builder.h 2015-11-19 10:44:11 +0000
192@@ -70,7 +70,7 @@
193 {
194 bool connected{name == graphics::android::DisplayName::primary};
195 auto config = StubDisplayConfig({{connected, connected}}).outputs[0];
196- config.id = static_cast<graphics::DisplayConfigurationOutputId>(name);
197+ config.id = as_output_id(name);
198 return config;
199 }
200

Subscribers

People subscribed via source and target branches