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
=== modified file 'src/platforms/android/server/real_hwc_wrapper.cpp'
--- src/platforms/android/server/real_hwc_wrapper.cpp 2016-01-29 08:18:22 +0000
+++ src/platforms/android/server/real_hwc_wrapper.cpp 2016-02-12 14:23:01 +0000
@@ -89,6 +89,9 @@
89 std::unique_lock<std::mutex> lk(callback_lock);89 std::unique_lock<std::mutex> lk(callback_lock);
90 hwc_callbacks.self = this;90 hwc_callbacks.self = this;
91 hwc_device->registerProcs(hwc_device.get(), reinterpret_cast<hwc_procs_t*>(&hwc_callbacks));91 hwc_device->registerProcs(hwc_device.get(), reinterpret_cast<hwc_procs_t*>(&hwc_callbacks));
92 is_plugged[HWC_DISPLAY_PRIMARY].store(true);
93 is_plugged[HWC_DISPLAY_EXTERNAL].store(false);
94 is_plugged[HWC_DISPLAY_VIRTUAL].store(true);
92}95}
9396
94mga::RealHwcWrapper::~RealHwcWrapper()97mga::RealHwcWrapper::~RealHwcWrapper()
@@ -215,6 +218,8 @@
215218
216void mga::RealHwcWrapper::hotplug(DisplayName name, bool connected) noexcept219void mga::RealHwcWrapper::hotplug(DisplayName name, bool connected) noexcept
217{220{
221 is_plugged[mga::as_hwc_display(name)].store(connected);
222
218 std::unique_lock<std::mutex> lk(callback_map_lock);223 std::unique_lock<std::mutex> lk(callback_map_lock);
219 for(auto const& callbacks : callback_map)224 for(auto const& callbacks : callback_map)
220 {225 {
@@ -245,6 +250,11 @@
245250
246std::vector<mga::ConfigId> mga::RealHwcWrapper::display_configs(DisplayName display_name) const251std::vector<mga::ConfigId> mga::RealHwcWrapper::display_configs(DisplayName display_name) const
247{252{
253 //Check first if display is unplugged, as some hw composers incorrectly report display configurations
254 //when they have already triggered an unplug event.
255 if (!is_plugged[mga::as_hwc_display(display_name)].load())
256 return {};
257
248 //No way to get the number of display configs. SF uses 128 possible spots, but that seems excessive.258 //No way to get the number of display configs. SF uses 128 possible spots, but that seems excessive.
249 static size_t const max_configs = 16;259 static size_t const max_configs = 16;
250 size_t num_configs = max_configs;260 size_t num_configs = max_configs;
251261
=== modified file 'src/platforms/android/server/real_hwc_wrapper.h'
--- src/platforms/android/server/real_hwc_wrapper.h 2016-01-29 08:18:22 +0000
+++ src/platforms/android/server/real_hwc_wrapper.h 2016-02-12 14:23:01 +0000
@@ -25,6 +25,7 @@
2525
26#include <mutex>26#include <mutex>
27#include <unordered_map>27#include <unordered_map>
28#include <atomic>
2829
29namespace mir30namespace mir
30{31{
@@ -86,6 +87,7 @@
86 std::function<void()> invalidate;87 std::function<void()> invalidate;
87 };88 };
88 std::unordered_map<void const*, Callbacks> callback_map;89 std::unordered_map<void const*, Callbacks> callback_map;
90 std::atomic<bool> is_plugged[HWC_NUM_DISPLAY_TYPES];
89};91};
9092
91}93}

Subscribers

People subscribed via source and target branches