Mir

Merge lp:~peat-new/mir/load-fb-hal-before-hwc into lp:mir

Proposed by Ratchanan Srirattanamet
Status: Work in progress
Proposed branch: lp:~peat-new/mir/load-fb-hal-before-hwc
Merge into: lp:mir
Diff against target: 141 lines (+55/-14)
2 files modified
src/platforms/android/server/hal_component_factory.cpp (+28/-3)
tests/unit-tests/graphics/android/test_output_builder.cpp (+27/-11)
To merge this branch: bzr merge lp:~peat-new/mir/load-fb-hal-before-hwc
Reviewer Review Type Date Requested Status
Kevin DuBois (community) Abstain
Daniel van Vugt Needs Resubmitting
Mir CI Bot Pending
Review via email: mp+302881@code.launchpad.net

Commit message

android: open FB HAL before HWComposer.

Some devices (for example Samsung Galaxy Tab 2 7.0) may insist that the
FB HAL be opened before HWC. This revision make HalComponentFactory to
comply to this requirement.

Description of the change

I'm porting Ubuntu Touch to Samsung Galaxy Tab 2 7.0. While porting, I found that this device's HWComposer (OMAP's, and has version 1.0 of API) have to be opened after FB HAL. Looking at Android's SurfaceFlinger code, I found that it does open FB HAL before HWComposer, but then close FB HAL if HWComposer is successfully opened and has version 1.1 of API or later.

This branch changes HalComponentFactory to do essentially the same thing as Android. With this fix, I can confirm that HWComposer is opened successfully on Samsung Galaxy Tab 2 7.0. Although graphic doesn't work yet. (Actually, using FB HAL alone, graphic does work but isn't complete.)

To post a comment you must log in.
Revision history for this message
Daniel van Vugt (vanvugt) wrote :

Just running automated tests first. Unfortunately the only way I know to make that happen is to resubmit the code from a mir-team member:
https://code.launchpad.net/~mir-team/mir/load-fb-hal-before-hwc/+merge/302909

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

This has the problem that we have to load the fb hal, even when its not needed. It also seems to be a problem on older devices only, so it causes a bit more work for the bulk of supported devices. So, if we want to support the older devices (like the omap hwc 1.0), this is the only way to do it... so alright by me.

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

Obviously there are other problems with drivers that require a particular build order.. but since we can't move that source code (due to old age, and closed-source nature), we probably have to just work around it.

Revision history for this message
Ratchanan Srirattanamet (peat-new) wrote :

Actually, we have HWC's code here (highlighting the line that requires FB HAL to be opened first): https://github.com/CyanogenMod/android_hardware_ti_omap4/blob/cm-13.0/hwc/hwc.c#L2529

I have another problem with this HWC, which I'll file a bug because I can't figure out how to fix that properly (I have a hack but it's obviously not a proper fix).

Revision history for this message
Daniel van Vugt (vanvugt) wrote :
review: Needs Information
Revision history for this message
Daniel van Vugt (vanvugt) wrote :

CI is mostly happy with the branch (only failing for unrelated reasons today).

So I'm happy with it.

review: Approve
Revision history for this message
Daniel van Vugt (vanvugt) wrote :

This change got reverted yesterday due to a regression: bug 1615703

Please fix and resubmit under a new branch name (Launchpad won't accept the old name after it already landed once).

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

yeah, a quirk that detects on the device name is probably the easiest way to go, although adding hwc-vendor detection would probably be a bit more robust. The device that had problems was the MX4, we can test the resubmission against the device.

review: Abstain
Revision history for this message
Cemil Azizoglu (cemil-azizoglu) wrote :

I'll set this to WiP as it's not ready for review. Thanks.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/platforms/android/server/hal_component_factory.cpp'
2--- src/platforms/android/server/hal_component_factory.cpp 2016-06-02 05:33:50 +0000
3+++ src/platforms/android/server/hal_component_factory.cpp 2016-08-14 10:11:51 +0000
4@@ -50,6 +50,16 @@
5 working_egl_sync(quirks->working_egl_sync()),
6 hwc_version{mga::HwcVersion::unknown}
7 {
8+ bool fb_native_failed_to_load = false;
9+
10+ try
11+ {
12+ fb_native = res_factory->create_fb_native_device();
13+ } catch (...)
14+ {
15+ fb_native_failed_to_load = true;
16+ }
17+
18 try
19 {
20 std::tie(hwc_wrapper, hwc_version) = res_factory->create_hwc_wrapper(hwc_report);
21@@ -61,9 +71,24 @@
22
23 if (force_backup_display || hwc_version == mga::HwcVersion::hwc10)
24 {
25- fb_native = res_factory->create_fb_native_device();
26- //guarantee always 2 fb's allocated
27- num_framebuffers = std::max(2u, static_cast<unsigned int>(fb_native->numFramebuffers));
28+ //We're using FB HAL
29+ if (fb_native_failed_to_load)
30+ {
31+ BOOST_THROW_EXCEPTION(std::runtime_error("fb display is mandory but failed to create one"));
32+ }
33+ else
34+ {
35+ //get framebuffers amount from FB HAL but guarantee always 2 fb's allocated
36+ num_framebuffers = std::max(2u, static_cast<unsigned int>(fb_native->numFramebuffers));
37+ }
38+ }
39+ else
40+ {
41+ if (!fb_native_failed_to_load)
42+ {
43+ //Close FB HAL as we don't need it.
44+ fb_native.reset(); //This will close the FB HAL via destructor
45+ }
46 }
47
48 command_stream_sync_factory = create_command_stream_sync_factory();
49
50=== modified file 'tests/unit-tests/graphics/android/test_output_builder.cpp'
51--- tests/unit-tests/graphics/android/test_output_builder.cpp 2016-06-02 05:33:50 +0000
52+++ tests/unit-tests/graphics/android/test_output_builder.cpp 2016-08-14 10:11:51 +0000
53@@ -94,9 +94,12 @@
54 TEST_F(HalComponentFactory, builds_hwc_version_10)
55 {
56 using namespace testing;
57+ Sequence seq;
58+ EXPECT_CALL(*mock_resource_factory, create_fb_native_device())
59+ .InSequence(seq);
60 EXPECT_CALL(*mock_resource_factory, create_hwc_wrapper(_))
61+ .InSequence(seq)
62 .WillOnce(Return(std::make_tuple(mock_wrapper, mga::HwcVersion::hwc10)));
63- EXPECT_CALL(*mock_resource_factory, create_fb_native_device());
64 EXPECT_CALL(*mock_hwc_report, report_hwc_version(mga::HwcVersion::hwc10));
65
66 mga::HalComponentFactory factory(
67@@ -109,7 +112,11 @@
68 TEST_F(HalComponentFactory, builds_hwc_version_11_and_later)
69 {
70 using namespace testing;
71+ Sequence seq;
72+ EXPECT_CALL(*mock_resource_factory, create_fb_native_device())
73+ .InSequence(seq);
74 EXPECT_CALL(*mock_resource_factory, create_hwc_wrapper(_))
75+ .InSequence(seq)
76 .WillOnce(Return(std::make_tuple(mock_wrapper, mga::HwcVersion::hwc11)));
77 EXPECT_CALL(*mock_hwc_report, report_hwc_version(mga::HwcVersion::hwc11));
78
79@@ -137,9 +144,12 @@
80 TEST_F(HalComponentFactory, hwc_failure_falls_back_to_fb)
81 {
82 using namespace testing;
83+ Sequence seq;
84+ EXPECT_CALL(*mock_resource_factory, create_fb_native_device())
85+ .InSequence(seq);
86 EXPECT_CALL(*mock_resource_factory, create_hwc_wrapper(_))
87+ .InSequence(seq)
88 .WillOnce(Throw(std::runtime_error("")));
89- EXPECT_CALL(*mock_resource_factory, create_fb_native_device());
90 EXPECT_CALL(*mock_hwc_report, report_legacy_fb_module());
91
92 mga::HalComponentFactory factory(
93@@ -152,9 +162,12 @@
94 TEST_F(HalComponentFactory, hwc_and_fb_failure_fatal)
95 {
96 using namespace testing;
97+ Sequence seq;
98+ EXPECT_CALL(*mock_resource_factory, create_fb_native_device())
99+ .InSequence(seq)
100+ .WillOnce(Throw(std::runtime_error("")));
101 EXPECT_CALL(*mock_resource_factory, create_hwc_wrapper(_))
102- .WillOnce(Throw(std::runtime_error("")));
103- EXPECT_CALL(*mock_resource_factory, create_fb_native_device())
104+ .InSequence(seq)
105 .WillOnce(Throw(std::runtime_error("")));
106
107 EXPECT_THROW({
108@@ -169,11 +182,14 @@
109 TEST_F(HalComponentFactory, determine_fbnum_always_reports_2_minimum)
110 {
111 using namespace testing;
112- EXPECT_CALL(*mock_resource_factory, create_hwc_wrapper(_))
113- .WillOnce(Throw(std::runtime_error("")));
114+ Sequence seq;
115 EXPECT_CALL(*mock_resource_factory, create_fb_native_device())
116+ .InSequence(seq)
117 .WillOnce(Return(std::make_shared<mtd::MockFBHalDevice>(
118 0, 0, mir_pixel_format_abgr_8888, 0, 0.0, 0.0)));
119+ EXPECT_CALL(*mock_resource_factory, create_hwc_wrapper(_))
120+ .InSequence(seq)
121+ .WillOnce(Throw(std::runtime_error("")));
122
123 mga::HalComponentFactory factory(
124 mock_resource_factory,
125@@ -192,11 +208,11 @@
126 {
127 using namespace testing;
128 auto supported_versions = {
129- mga::HwcVersion::hwc10,
130- mga::HwcVersion::hwc11,
131- mga::HwcVersion::hwc12,
132- mga::HwcVersion::hwc13,
133- mga::HwcVersion::hwc14,
134+ mga::HwcVersion::hwc10,
135+ mga::HwcVersion::hwc11,
136+ mga::HwcVersion::hwc12,
137+ mga::HwcVersion::hwc13,
138+ mga::HwcVersion::hwc14,
139 mga::HwcVersion::hwc15 };
140 for (auto supported_version : supported_versions)
141 {

Subscribers

People subscribed via source and target branches