Mir

Merge lp:~phablet-team/mir/track-plug-state into lp:mir

Proposed by Alfonso Sanchez-Beato
Status: Merged
Merged at revision: 3312
Proposed branch: lp:~phablet-team/mir/track-plug-state
Merge into: lp:mir
Diff against target: 54 lines (+12/-0)
2 files modified
src/platforms/android/server/real_hwc_wrapper.cpp (+10/-0)
src/platforms/android/server/real_hwc_wrapper.h (+2/-0)
To merge this branch: bzr merge lp:~phablet-team/mir/track-plug-state
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Needs Fixing
Kevin DuBois (community) Approve
Andreas Pokorny (community) Approve
Alan Griffiths Approve
Review via email: mp+285854@code.launchpad.net

Commit message

Track the displays plugged state to avoid reporting configurations in case they are unplugged (LP #1531503).

Description of the change

Track the displays plugged state to avoid reporting configurations in case they are unplugged (LP #1531503).

To post a comment you must log in.
Revision history for this message
Andreas Pokorny (andreas-pokorny) wrote :

Needs fixing: Instead of a map use an array std::atomic<bool> of size HWC_NUM_DISPLAY_TYPES.
Needs information: What about the other scenario .. the display was just plugged in but there is no display information available yet? Or do we only experience unplug + still display conf readable problems?

review: Needs Information
Revision history for this message
Alan Griffiths (alan-griffiths) wrote :

I'm not very familiar with this code, so I may be missing something?

It seems excessive to have both inclusion in a map and a bool to represent the "plugged" state. And there are at most three elements!

Surely either a set (membership in the set implying the "plugged" state) or a three element array would be adequate.

E.g.

bool is_plugged_map[3] = { false, false, false };

...

if (!is_plugged_map[display_name]) return {};

(It would be nice to eliminate the "magic number" 3 by adding a DisplayName::max_names)

review: Needs Information
Revision history for this message
Andreas Pokorny (andreas-pokorny) wrote :

yes androdi hw_composer_defs.h or so devices a max number of displays, and we could put that into the DiplayNme enum ..

Revision history for this message
Alfonso Sanchez-Beato (alfonsosanchezbeato) wrote :

Branch refreshed addressing comments.

Re: plugged in but no display information yet, I have not seen that. The only issue has been when unplugging the tablet.

Revision history for this message
Alan Griffiths (alan-griffiths) wrote :

+ if (is_plugged[mga::as_hwc_display(display_name)].load() == false)

Can be written

  if (!is_plugged[mga::as_hwc_display(display_name)])

~~~~

+ is_plugged[HWC_DISPLAY_PRIMARY].store(true);
+ is_plugged[HWC_DISPLAY_EXTERNAL].store(false);
+ is_plugged[HWC_DISPLAY_VIRTUAL].store(true);

Constructors should use initialization, not assignment

review: Needs Fixing
Revision history for this message
Alfonso Sanchez-Beato (alfonsosanchezbeato) wrote :

On Fri, Feb 12, 2016 at 3:01 PM, Alan Griffiths <email address hidden> wrote:

> Review: Needs Fixing
>
> + if (is_plugged[mga::as_hwc_display(display_name)].load() == false)
>
> Can be written
>
> if (!is_plugged[mga::as_hwc_display(display_name)])
>
> ~~~~
>
> + is_plugged[HWC_DISPLAY_PRIMARY].store(true);
> + is_plugged[HWC_DISPLAY_EXTERNAL].store(false);
> + is_plugged[HWC_DISPLAY_VIRTUAL].store(true);
>
> Constructors should use initialization, not assignment
>

The copy constructor is =deleted for atomic types apparently, so I could
not initialize directly.

> --
> https://code.launchpad.net/~phablet-team/mir/track-plug-state/+merge/285854
> Your team Ubuntu Phablet Team is subscribed to branch
> lp:~phablet-team/mir/track-plug-state.
>

Revision history for this message
Alan Griffiths (alan-griffiths) wrote :

OK.

I don't think the extra verbage of explicit store()/load() adds anything, but I won't block.

review: Approve
Revision history for this message
Andreas Pokorny (andreas-pokorny) wrote :

oh there are really only three diplays possible HWC. builtin external and virtual. So this could just be an int. Instead of an array.

I guess we should integrate that to 0.20?

Revision history for this message
Andreas Pokorny (andreas-pokorny) wrote :

I am ok with that version. But pinged kdub on whether this should be a runtime switchable quirk or not.

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

in my reading of hwc spec, we're specifically guaranteed that checking the display config of a device is allowed (<groan>)
https://android.googlesource.com/platform/hardware/libhardware/+/master/include/hardware/hwcomposer.h#492

If it is a problem on this device though, this doesn't look bad, although I might follow up to solve the problem at a higher level and to add tests (this class is just supposed to be a wrapper)

review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Alan Griffiths (alan-griffiths) wrote :

Flaky infrastructure - landing by hand

Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/softwareproperties/ppa.py", line 101, in _get_https_content_py3
    lp_page = urllib.request.urlopen(request, cafile=LAUNCHPAD_PPA_CERT)
  File "/usr/lib/python3.4/urllib/request.py", line 161, in urlopen
    return opener.open(url, data, timeout)
  File "/usr/lib/python3.4/urllib/request.py", line 463, in open
    response = self._open(req, data)
  File "/usr/lib/python3.4/urllib/request.py", line 481, in _open
    '_open', req)
  File "/usr/lib/python3.4/urllib/request.py", line 441, in _call_chain
    result = func(*args)
  File "/usr/lib/python3.4/urllib/request.py", line 1225, in https_open
    context=self._context, check_hostname=self._check_hostname)
  File "/usr/lib/python3.4/urllib/request.py", line 1184, in do_open
    raise URLError(err)
urllib.error.URLError: <urlopen error [Errno -3] Temporary failure in name resolution>

During handling of the above exception, another exception occurred:

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/platforms/android/server/real_hwc_wrapper.cpp'
2--- src/platforms/android/server/real_hwc_wrapper.cpp 2016-01-29 08:18:22 +0000
3+++ src/platforms/android/server/real_hwc_wrapper.cpp 2016-02-12 14:23:01 +0000
4@@ -89,6 +89,9 @@
5 std::unique_lock<std::mutex> lk(callback_lock);
6 hwc_callbacks.self = this;
7 hwc_device->registerProcs(hwc_device.get(), reinterpret_cast<hwc_procs_t*>(&hwc_callbacks));
8+ is_plugged[HWC_DISPLAY_PRIMARY].store(true);
9+ is_plugged[HWC_DISPLAY_EXTERNAL].store(false);
10+ is_plugged[HWC_DISPLAY_VIRTUAL].store(true);
11 }
12
13 mga::RealHwcWrapper::~RealHwcWrapper()
14@@ -215,6 +218,8 @@
15
16 void mga::RealHwcWrapper::hotplug(DisplayName name, bool connected) noexcept
17 {
18+ is_plugged[mga::as_hwc_display(name)].store(connected);
19+
20 std::unique_lock<std::mutex> lk(callback_map_lock);
21 for(auto const& callbacks : callback_map)
22 {
23@@ -245,6 +250,11 @@
24
25 std::vector<mga::ConfigId> mga::RealHwcWrapper::display_configs(DisplayName display_name) const
26 {
27+ //Check first if display is unplugged, as some hw composers incorrectly report display configurations
28+ //when they have already triggered an unplug event.
29+ if (!is_plugged[mga::as_hwc_display(display_name)].load())
30+ return {};
31+
32 //No way to get the number of display configs. SF uses 128 possible spots, but that seems excessive.
33 static size_t const max_configs = 16;
34 size_t num_configs = max_configs;
35
36=== modified file 'src/platforms/android/server/real_hwc_wrapper.h'
37--- src/platforms/android/server/real_hwc_wrapper.h 2016-01-29 08:18:22 +0000
38+++ src/platforms/android/server/real_hwc_wrapper.h 2016-02-12 14:23:01 +0000
39@@ -25,6 +25,7 @@
40
41 #include <mutex>
42 #include <unordered_map>
43+#include <atomic>
44
45 namespace mir
46 {
47@@ -86,6 +87,7 @@
48 std::function<void()> invalidate;
49 };
50 std::unordered_map<void const*, Callbacks> callback_map;
51+ std::atomic<bool> is_plugged[HWC_NUM_DISPLAY_TYPES];
52 };
53
54 }

Subscribers

People subscribed via source and target branches