summaryrefslogtreecommitdiff
path: root/sdm/libs/core
diff options
context:
space:
mode:
authorRamkumar Radhakrishnan <ramkumar@codeaurora.org>2018-01-17 11:39:33 -0800
committerRamkumar Radhakrishnan <ramkumar@codeaurora.org>2018-02-06 14:29:46 -0800
commit00698decef667ee7700b663091e1f6c4fbefbf71 (patch)
tree7a6469cb987745447c67872d910d0c60e8f561f8 /sdm/libs/core
parentf5464da30116baa43cc1e4e9e5a6af980dca11ac (diff)
downloaddisplay-00698decef667ee7700b663091e1f6c4fbefbf71.tar.gz
sdm: Merge release fence after set power mode
On SetPowerMode() with retain pipes, DRM driver triggers the kick off that enables MDP to read the previously queued buffer, Since the fence created during SetPowerMode() is not merged with the previously queued buffer, it may result in tearing. Hence get the release fence from driver on SetPowerMode and propagate it to hwcomposer to merge it with the previous release fence of all layer buffers to avoid tearing. Change-Id: I81c078a1b05dd3fb34f10b9b70e25cfbcfabd117 CRs-Fixed: 2184515
Diffstat (limited to 'sdm/libs/core')
-rw-r--r--sdm/libs/core/display_base.cpp10
-rw-r--r--sdm/libs/core/display_base.h4
-rw-r--r--sdm/libs/core/display_primary.cpp17
-rw-r--r--sdm/libs/core/display_primary.h4
-rw-r--r--sdm/libs/core/drm/hw_device_drm.cpp13
-rw-r--r--sdm/libs/core/drm/hw_device_drm.h8
-rw-r--r--sdm/libs/core/drm/hw_tv_drm.cpp6
-rw-r--r--sdm/libs/core/drm/hw_tv_drm.h6
-rw-r--r--sdm/libs/core/fb/hw_device.cpp8
-rw-r--r--sdm/libs/core/fb/hw_device.h8
-rw-r--r--sdm/libs/core/fb/hw_primary.cpp6
-rw-r--r--sdm/libs/core/fb/hw_primary.h6
-rw-r--r--sdm/libs/core/hw_interface.h8
13 files changed, 58 insertions, 46 deletions
diff --git a/sdm/libs/core/display_base.cpp b/sdm/libs/core/display_base.cpp
index 383bdba7..b1617b9c 100644
--- a/sdm/libs/core/display_base.cpp
+++ b/sdm/libs/core/display_base.cpp
@@ -1,5 +1,5 @@
/*
-* Copyright (c) 2014 - 2017, The Linux Foundation. All rights reserved.
+* Copyright (c) 2014 - 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 met:
@@ -430,7 +430,7 @@ DisplayState DisplayBase::GetLastPowerMode() {
return last_power_mode_;
}
-DisplayError DisplayBase::SetDisplayState(DisplayState state) {
+DisplayError DisplayBase::SetDisplayState(DisplayState state, int *release_fence) {
lock_guard<recursive_mutex> obj(recursive_mutex_);
DisplayError error = kErrorNone;
bool active = false;
@@ -452,7 +452,7 @@ DisplayError DisplayBase::SetDisplayState(DisplayState state) {
break;
case kStateOn:
- error = hw_intf_->PowerOn();
+ error = hw_intf_->PowerOn(release_fence);
if (error != kErrorNone) {
return error;
}
@@ -468,13 +468,13 @@ DisplayError DisplayBase::SetDisplayState(DisplayState state) {
break;
case kStateDoze:
- error = hw_intf_->Doze();
+ error = hw_intf_->Doze(release_fence);
active = true;
last_power_mode_ = kStateDoze;
break;
case kStateDozeSuspend:
- error = hw_intf_->DozeSuspend();
+ error = hw_intf_->DozeSuspend(release_fence);
if (display_type_ != kPrimary) {
active = true;
}
diff --git a/sdm/libs/core/display_base.h b/sdm/libs/core/display_base.h
index 014ea112..bd597c9c 100644
--- a/sdm/libs/core/display_base.h
+++ b/sdm/libs/core/display_base.h
@@ -1,5 +1,5 @@
/*
-* Copyright (c) 2014-2017, The Linux Foundation. All rights reserved.
+* Copyright (c) 2014-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 met:
@@ -62,7 +62,7 @@ class DisplayBase : public DisplayInterface {
virtual DisplayError GetConfig(DisplayConfigFixedInfo *variable_info);
virtual DisplayError GetActiveConfig(uint32_t *index);
virtual DisplayError GetVSyncState(bool *enabled);
- virtual DisplayError SetDisplayState(DisplayState state);
+ virtual DisplayError SetDisplayState(DisplayState state, int *release_fence);
virtual DisplayError SetActiveConfig(uint32_t index);
virtual DisplayError SetActiveConfig(DisplayConfigVariableInfo *variable_info) {
return kErrorNotSupported;
diff --git a/sdm/libs/core/display_primary.cpp b/sdm/libs/core/display_primary.cpp
index 8466f8bf..d9fef336 100644
--- a/sdm/libs/core/display_primary.cpp
+++ b/sdm/libs/core/display_primary.cpp
@@ -1,5 +1,5 @@
/*
-* Copyright (c) 2014 - 2017, The Linux Foundation. All rights reserved.
+* Copyright (c) 2014 - 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 met:
@@ -166,10 +166,10 @@ DisplayError DisplayPrimary::Commit(LayerStack *layer_stack) {
return error;
}
-DisplayError DisplayPrimary::SetDisplayState(DisplayState state) {
+DisplayError DisplayPrimary::SetDisplayState(DisplayState state, int *release_fence) {
lock_guard<recursive_mutex> obj(recursive_mutex_);
DisplayError error = kErrorNone;
- error = DisplayBase::SetDisplayState(state);
+ error = DisplayBase::SetDisplayState(state, release_fence);
if (error != kErrorNone) {
return error;
}
@@ -391,19 +391,26 @@ bool DisplayPrimary::NeedsAVREnable() {
void DisplayPrimary::ResetPanel() {
DisplayError status = kErrorNone;
+ int release_fence = -1;
DLOGI("Powering off primary");
- status = SetDisplayState(kStateOff);
+ status = SetDisplayState(kStateOff, &release_fence);
if (status != kErrorNone) {
DLOGE("power-off on primary failed with error = %d", status);
}
+ if (release_fence >= 0) {
+ ::close(release_fence);
+ }
DLOGI("Restoring power mode on primary");
DisplayState mode = GetLastPowerMode();
- status = SetDisplayState(mode);
+ status = SetDisplayState(mode, &release_fence);
if (status != kErrorNone) {
DLOGE("Setting power mode = %d on primary failed with error = %d", mode, status);
}
+ if (release_fence >= 0) {
+ ::close(release_fence);
+ }
DLOGI("Enabling HWVsync");
status = SetVSyncState(true);
diff --git a/sdm/libs/core/display_primary.h b/sdm/libs/core/display_primary.h
index a4dd4b84..e14c6d77 100644
--- a/sdm/libs/core/display_primary.h
+++ b/sdm/libs/core/display_primary.h
@@ -1,5 +1,5 @@
/*
-* Copyright (c) 2014 - 2017, The Linux Foundation. All rights reserved.
+* Copyright (c) 2014 - 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 met:
@@ -44,7 +44,7 @@ class DisplayPrimary : public DisplayBase, HWEventHandler {
virtual DisplayError Commit(LayerStack *layer_stack);
virtual DisplayError ControlPartialUpdate(bool enable, uint32_t *pending);
virtual DisplayError DisablePartialUpdateOneFrame();
- virtual DisplayError SetDisplayState(DisplayState state);
+ virtual DisplayError SetDisplayState(DisplayState state, int *release_fence);
virtual void SetIdleTimeoutMs(uint32_t active_ms);
virtual DisplayError SetDisplayMode(uint32_t mode);
virtual DisplayError GetRefreshRateRange(uint32_t *min_refresh_rate, uint32_t *max_refresh_rate);
diff --git a/sdm/libs/core/drm/hw_device_drm.cpp b/sdm/libs/core/drm/hw_device_drm.cpp
index c734f4cd..c01fa5c3 100644
--- a/sdm/libs/core/drm/hw_device_drm.cpp
+++ b/sdm/libs/core/drm/hw_device_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
@@ -708,7 +708,7 @@ DisplayError HWDeviceDRM::GetConfigIndex(char *mode, uint32_t *index) {
return kErrorNone;
}
-DisplayError HWDeviceDRM::PowerOn() {
+DisplayError HWDeviceDRM::PowerOn(int *release_fence) {
DTRACE_SCOPED();
if (!drm_atomic_intf_) {
DLOGE("DRM Atomic Interface is null!");
@@ -726,6 +726,7 @@ DisplayError HWDeviceDRM::PowerOn() {
DLOGE("Failed with error: %d", ret);
return kErrorHardware;
}
+ drm_atomic_intf_->Perform(DRMOps::CRTC_GET_RELEASE_FENCE, token_.crtc_id, release_fence);
return kErrorNone;
}
@@ -748,7 +749,7 @@ DisplayError HWDeviceDRM::PowerOff() {
return kErrorNone;
}
-DisplayError HWDeviceDRM::Doze() {
+DisplayError HWDeviceDRM::Doze(int *release_fence) {
DTRACE_SCOPED();
drm_atomic_intf_->Perform(DRMOps::CRTC_SET_ACTIVE, token_.crtc_id, 1);
drm_atomic_intf_->Perform(DRMOps::CONNECTOR_SET_POWER_MODE, token_.conn_id, DRMPowerMode::DOZE);
@@ -758,10 +759,12 @@ DisplayError HWDeviceDRM::Doze() {
return kErrorHardware;
}
+ drm_atomic_intf_->Perform(DRMOps::CRTC_GET_RELEASE_FENCE, token_.crtc_id, release_fence);
+
return kErrorNone;
}
-DisplayError HWDeviceDRM::DozeSuspend() {
+DisplayError HWDeviceDRM::DozeSuspend(int *release_fence) {
DTRACE_SCOPED();
drm_atomic_intf_->Perform(DRMOps::CRTC_SET_ACTIVE, token_.crtc_id, 1);
drm_atomic_intf_->Perform(DRMOps::CONNECTOR_SET_POWER_MODE, token_.conn_id,
@@ -772,6 +775,8 @@ DisplayError HWDeviceDRM::DozeSuspend() {
return kErrorHardware;
}
+ drm_atomic_intf_->Perform(DRMOps::CRTC_GET_RELEASE_FENCE, token_.crtc_id, release_fence);
+
return kErrorNone;
}
diff --git a/sdm/libs/core/drm/hw_device_drm.h b/sdm/libs/core/drm/hw_device_drm.h
index b08c0e66..3ecc9a08 100644
--- a/sdm/libs/core/drm/hw_device_drm.h
+++ b/sdm/libs/core/drm/hw_device_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
@@ -67,10 +67,10 @@ class HWDeviceDRM : public HWInterface {
virtual DisplayError SetDisplayAttributes(uint32_t index);
virtual DisplayError SetDisplayAttributes(const HWDisplayAttributes &display_attributes);
virtual DisplayError GetConfigIndex(char *mode, uint32_t *index);
- virtual DisplayError PowerOn();
+ virtual DisplayError PowerOn(int *release_fence);
virtual DisplayError PowerOff();
- virtual DisplayError Doze();
- virtual DisplayError DozeSuspend();
+ virtual DisplayError Doze(int *release_fence);
+ virtual DisplayError DozeSuspend(int *release_fence);
virtual DisplayError Standby();
virtual DisplayError Validate(HWLayers *hw_layers);
virtual DisplayError Commit(HWLayers *hw_layers);
diff --git a/sdm/libs/core/drm/hw_tv_drm.cpp b/sdm/libs/core/drm/hw_tv_drm.cpp
index f1d0d80b..a43ac2cc 100644
--- a/sdm/libs/core/drm/hw_tv_drm.cpp
+++ b/sdm/libs/core/drm/hw_tv_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
@@ -164,11 +164,11 @@ DisplayError HWTVDRM::PowerOff() {
return kErrorNone;
}
-DisplayError HWTVDRM::Doze() {
+DisplayError HWTVDRM::Doze(int *release_fence) {
return kErrorNone;
}
-DisplayError HWTVDRM::DozeSuspend() {
+DisplayError HWTVDRM::DozeSuspend(int *release_fence) {
return kErrorNone;
}
diff --git a/sdm/libs/core/drm/hw_tv_drm.h b/sdm/libs/core/drm/hw_tv_drm.h
index 5661bc27..a87f33d9 100644
--- a/sdm/libs/core/drm/hw_tv_drm.h
+++ b/sdm/libs/core/drm/hw_tv_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 met:
@@ -43,8 +43,8 @@ class HWTVDRM : public HWDeviceDRM {
virtual DisplayError SetDisplayAttributes(uint32_t index);
virtual DisplayError GetConfigIndex(char *mode, uint32_t *index);
virtual DisplayError PowerOff();
- virtual DisplayError Doze();
- virtual DisplayError DozeSuspend();
+ virtual DisplayError Doze(int *release_fence);
+ virtual DisplayError DozeSuspend(int *release_fence);
virtual DisplayError Standby();
virtual DisplayError Commit(HWLayers *hw_layers);
virtual void PopulateHWPanelInfo();
diff --git a/sdm/libs/core/fb/hw_device.cpp b/sdm/libs/core/fb/hw_device.cpp
index 2c529ae0..1f733a04 100644
--- a/sdm/libs/core/fb/hw_device.cpp
+++ b/sdm/libs/core/fb/hw_device.cpp
@@ -1,5 +1,5 @@
/*
-* Copyright (c) 2014 - 2017, The Linux Foundation. All rights reserved.
+* Copyright (c) 2014 - 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
@@ -155,7 +155,7 @@ DisplayError HWDevice::GetConfigIndex(char *mode, uint32_t *index) {
return kErrorNone;
}
-DisplayError HWDevice::PowerOn() {
+DisplayError HWDevice::PowerOn(int *release_fence) {
DTRACE_SCOPED();
if (Sys::ioctl_(device_fd_, FBIOBLANK, FB_BLANK_UNBLANK) < 0) {
@@ -174,11 +174,11 @@ DisplayError HWDevice::PowerOff() {
return kErrorNone;
}
-DisplayError HWDevice::Doze() {
+DisplayError HWDevice::Doze(int *release_fence) {
return kErrorNone;
}
-DisplayError HWDevice::DozeSuspend() {
+DisplayError HWDevice::DozeSuspend(int *release_fence) {
return kErrorNone;
}
diff --git a/sdm/libs/core/fb/hw_device.h b/sdm/libs/core/fb/hw_device.h
index f32c5bda..353cce5b 100644
--- a/sdm/libs/core/fb/hw_device.h
+++ b/sdm/libs/core/fb/hw_device.h
@@ -1,5 +1,5 @@
/*
-* Copyright (c) 2014 - 2017, The Linux Foundation. All rights reserved.
+* Copyright (c) 2014 - 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 met:
@@ -70,10 +70,10 @@ class HWDevice : public HWInterface {
virtual DisplayError SetDisplayAttributes(uint32_t index);
virtual DisplayError SetDisplayAttributes(const HWDisplayAttributes &display_attributes);
virtual DisplayError GetConfigIndex(char *mode, uint32_t *index);
- virtual DisplayError PowerOn();
+ virtual DisplayError PowerOn(int *release_fence);
virtual DisplayError PowerOff();
- virtual DisplayError Doze();
- virtual DisplayError DozeSuspend();
+ virtual DisplayError Doze(int *release_fence);
+ virtual DisplayError DozeSuspend(int *release_fence);
virtual DisplayError Standby();
virtual DisplayError Validate(HWLayers *hw_layers);
virtual DisplayError Commit(HWLayers *hw_layers);
diff --git a/sdm/libs/core/fb/hw_primary.cpp b/sdm/libs/core/fb/hw_primary.cpp
index 5ee81219..3f3c28e2 100644
--- a/sdm/libs/core/fb/hw_primary.cpp
+++ b/sdm/libs/core/fb/hw_primary.cpp
@@ -1,5 +1,5 @@
/*
-* Copyright (c) 2015 - 2017, The Linux Foundation. All rights reserved.
+* Copyright (c) 2015 - 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
@@ -344,7 +344,7 @@ DisplayError HWPrimary::PowerOff() {
return kErrorNone;
}
-DisplayError HWPrimary::Doze() {
+DisplayError HWPrimary::Doze(int *release_fence) {
if (Sys::ioctl_(device_fd_, FBIOBLANK, FB_BLANK_NORMAL) < 0) {
IOCTL_LOGE(FB_BLANK_NORMAL, device_type_);
return kErrorHardware;
@@ -353,7 +353,7 @@ DisplayError HWPrimary::Doze() {
return kErrorNone;
}
-DisplayError HWPrimary::DozeSuspend() {
+DisplayError HWPrimary::DozeSuspend(int *release_fence) {
if (Sys::ioctl_(device_fd_, FBIOBLANK, FB_BLANK_VSYNC_SUSPEND) < 0) {
IOCTL_LOGE(FB_BLANK_VSYNC_SUSPEND, device_type_);
return kErrorHardware;
diff --git a/sdm/libs/core/fb/hw_primary.h b/sdm/libs/core/fb/hw_primary.h
index 69b54452..c6ca5a98 100644
--- a/sdm/libs/core/fb/hw_primary.h
+++ b/sdm/libs/core/fb/hw_primary.h
@@ -1,5 +1,5 @@
/*
-* Copyright (c) 2015-2016, The Linux Foundation. All rights reserved.
+* Copyright (c) 2015-2016, 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 met:
@@ -46,8 +46,8 @@ class HWPrimary : public HWDevice {
virtual DisplayError SetDisplayAttributes(uint32_t index);
virtual DisplayError GetConfigIndex(char *mode, uint32_t *index);
virtual DisplayError PowerOff();
- virtual DisplayError Doze();
- virtual DisplayError DozeSuspend();
+ virtual DisplayError Doze(int *release_fence);
+ virtual DisplayError DozeSuspend(int *release_fence);
virtual DisplayError Validate(HWLayers *hw_layers);
virtual DisplayError Commit(HWLayers *hw_layers);
virtual void SetIdleTimeoutMs(uint32_t timeout_ms);
diff --git a/sdm/libs/core/hw_interface.h b/sdm/libs/core/hw_interface.h
index 9bb825e8..483a4df4 100644
--- a/sdm/libs/core/hw_interface.h
+++ b/sdm/libs/core/hw_interface.h
@@ -1,5 +1,5 @@
/*
-* Copyright (c) 2014 - 2017, The Linux Foundation. All rights reserved.
+* Copyright (c) 2014 - 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 met:
@@ -85,10 +85,10 @@ class HWInterface {
virtual DisplayError SetDisplayAttributes(uint32_t index) = 0;
virtual DisplayError SetDisplayAttributes(const HWDisplayAttributes &display_attributes) = 0;
virtual DisplayError GetConfigIndex(char *mode, uint32_t *index) = 0;
- virtual DisplayError PowerOn() = 0;
+ virtual DisplayError PowerOn(int *release_fence) = 0;
virtual DisplayError PowerOff() = 0;
- virtual DisplayError Doze() = 0;
- virtual DisplayError DozeSuspend() = 0;
+ virtual DisplayError Doze(int *release_fence) = 0;
+ virtual DisplayError DozeSuspend(int *release_fence) = 0;
virtual DisplayError Standby() = 0;
virtual DisplayError Validate(HWLayers *hw_layers) = 0;
virtual DisplayError Commit(HWLayers *hw_layers) = 0;