diff options
author | Saurabh Shah <saurshah@codeaurora.org> | 2018-01-05 11:05:35 -0800 |
---|---|---|
committer | Saurabh Shah <saurshah@codeaurora.org> | 2018-01-08 15:52:46 -0800 |
commit | 00a40ba6e2f032f2054c4b024a6b0fbf04d38051 (patch) | |
tree | 3ec0652f10966e2398f05383b65d807f3422cc6f /sdm/libs/core | |
parent | ca16bf276799867fa1a0d39764a9807f797f7df1 (diff) | |
download | display-00a40ba6e2f032f2054c4b024a6b0fbf04d38051.tar.gz |
sdm: Fix multiple VBlank registration
Currently VBlank registration happens even if polling thread wakes up
for other events. This causes multiple wake-ups on actual VBlank.
This change registers for VBlank in VBlank handler and on VBlank
enable, if it's not already registered.
Change-Id: I4aada5a5bd28382d60c68865c20eaabda5325ccf
CRs-fixed: 2167257
Diffstat (limited to 'sdm/libs/core')
-rw-r--r-- | sdm/libs/core/drm/hw_events_drm.cpp | 30 | ||||
-rw-r--r-- | sdm/libs/core/drm/hw_events_drm.h | 5 |
2 files changed, 23 insertions, 12 deletions
diff --git a/sdm/libs/core/drm/hw_events_drm.cpp b/sdm/libs/core/drm/hw_events_drm.cpp index 7a3d3851..86a3f544 100644 --- a/sdm/libs/core/drm/hw_events_drm.cpp +++ b/sdm/libs/core/drm/hw_events_drm.cpp @@ -1,5 +1,5 @@ /* -* Copyright (c) 2017, The Linux Foundation. All rights reserved. +* Copyright (c) 2017-2018, The Linux Foundation. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are @@ -182,7 +182,6 @@ DisplayError HWEventsDRM::Init(int display_type, HWEventHandler *event_handler, static_cast<const HWDeviceDRM *>(hw_intf)->GetDRMDisplayToken(&token_); is_primary_ = static_cast<const HWDeviceDRM *>(hw_intf)->IsPrimaryDisplay(); - vsync_enabled_ = is_primary_; DLOGI("Setup event handler for display %d, CRTC %d, Connector %d", display_type, token_.crtc_id, token_.conn_id); @@ -198,6 +197,11 @@ DisplayError HWEventsDRM::Init(int display_type, HWEventHandler *event_handler, return kErrorResources; } + if (is_primary_) { + RegisterVSync(); + vsync_registered_ = true; + } + RegisterPanelDead(true); RegisterIdleNotify(true); RegisterIdlePowerCollapse(true); @@ -220,15 +224,17 @@ DisplayError HWEventsDRM::Deinit() { DisplayError HWEventsDRM::SetEventState(HWEvent event, bool enable, void *arg) { switch (event) { - case HWEvent::VSYNC: + case HWEvent::VSYNC: { + std::lock_guard<std::mutex> lock(vsync_mutex_); if (!is_primary_) { break; } vsync_enabled_ = enable; - if (enable) { - WakeUpEventThread(); + if (vsync_enabled_ && !vsync_registered_) { + RegisterVSync(); + vsync_registered_ = true; } - break; + } break; default: DLOGE("Event not supported"); return kErrorNotSupported; @@ -295,11 +301,6 @@ void *HWEventsDRM::DisplayEventHandler() { setpriority(PRIO_PROCESS, 0, kThreadPriorityUrgent); while (!exit_threads_) { - if (vsync_enabled_ && RegisterVSync() != kErrorNone) { - pthread_exit(0); - return nullptr; - } - int error = Sys::poll_(poll_fds_.data(), UINT32(poll_fds_.size()), -1); if (error <= 0) { DLOGW("poll failed. error = %s", strerror(errno)); @@ -469,6 +470,13 @@ void HWEventsDRM::HandleVSync(char *data) { if (error != 0) { DLOGE("drmHandleEvent failed: %i", error); } + + std::lock_guard<std::mutex> lock(vsync_mutex_); + vsync_registered_ = false; + if (vsync_enabled_) { + RegisterVSync(); + vsync_registered_ = true; + } } void HWEventsDRM::HandlePanelDead(char *data) { diff --git a/sdm/libs/core/drm/hw_events_drm.h b/sdm/libs/core/drm/hw_events_drm.h index c54ac6fb..fafe606b 100644 --- a/sdm/libs/core/drm/hw_events_drm.h +++ b/sdm/libs/core/drm/hw_events_drm.h @@ -1,5 +1,5 @@ /* -* Copyright (c) 2017, The Linux Foundation. All rights reserved. +* Copyright (c) 2017-2018, The Linux Foundation. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are @@ -33,6 +33,7 @@ #include <drm_interface.h> #include <sys/poll.h> #include <map> +#include <mutex> #include <string> #include <utility> #include <vector> @@ -94,6 +95,8 @@ class HWEventsDRM : public HWEventsInterface { bool exit_threads_ = false; uint32_t vsync_index_ = 0; bool vsync_enabled_ = false; + bool vsync_registered_ = false; + std::mutex vsync_mutex_; // To protect vsync_enabled_ and vsync_registered_ uint32_t idle_notify_index_ = 0; sde_drm::DRMDisplayToken token_ = {}; bool is_primary_ = false; |