diff options
author | Valerie Hau <vhau@google.com> | 2019-04-09 14:37:00 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2019-04-09 14:37:00 +0000 |
commit | abc5bd873e54d74d396dc280205d608f72b000dc (patch) | |
tree | 9613cd4a2d7d6593662774374e20af98f48c1d6e | |
parent | 1c3903b59f159857f017866c0173e04dc238b149 (diff) | |
parent | f8c3fdc74c5b807bb0db6c0881d620c96d352e5f (diff) | |
download | display-abc5bd873e54d74d396dc280205d608f72b000dc.tar.gz |
Merge changes from topic "readbackfix-qcom" into qt-dev
* changes:
hwc2: Teardown CWB in Create Virtual Display
Revert "sdm: Fix Concurrent Writeback fence handling"
-rw-r--r-- | sdm/include/core/display_interface.h | 5 | ||||
-rw-r--r-- | sdm/libs/core/display_hdmi.h | 1 | ||||
-rw-r--r-- | sdm/libs/core/display_primary.cpp | 6 | ||||
-rw-r--r-- | sdm/libs/core/display_primary.h | 1 | ||||
-rw-r--r-- | sdm/libs/core/display_virtual.h | 1 | ||||
-rw-r--r-- | sdm/libs/core/drm/hw_device_drm.h | 1 | ||||
-rw-r--r-- | sdm/libs/core/drm/hw_peripheral_drm.cpp | 27 | ||||
-rw-r--r-- | sdm/libs/core/drm/hw_peripheral_drm.h | 1 | ||||
-rw-r--r-- | sdm/libs/core/fb/hw_device.h | 1 | ||||
-rw-r--r-- | sdm/libs/core/hw_interface.h | 1 | ||||
-rw-r--r-- | sdm/libs/hwc2/display_null.h | 1 | ||||
-rw-r--r-- | sdm/libs/hwc2/hwc_display.h | 3 | ||||
-rw-r--r-- | sdm/libs/hwc2/hwc_display_primary.cpp | 22 | ||||
-rw-r--r-- | sdm/libs/hwc2/hwc_display_primary.h | 1 | ||||
-rw-r--r-- | sdm/libs/hwc2/hwc_session.cpp | 7 |
15 files changed, 69 insertions, 10 deletions
diff --git a/sdm/include/core/display_interface.h b/sdm/include/core/display_interface.h index 8b724da1..cb073d20 100644 --- a/sdm/include/core/display_interface.h +++ b/sdm/include/core/display_interface.h @@ -694,6 +694,11 @@ class DisplayInterface { */ virtual DisplayError ControlIdlePowerCollapse(bool enable, bool synchronous) = 0; +/*! @brief Method to free concurrent writeback resoures for primary display. + @return \link DisplayError \endlink + */ + virtual DisplayError TeardownConcurrentWriteback(void) = 0; + /* * Returns a string consisting of a dump of SDM's display and layer related state * as programmed to driver diff --git a/sdm/libs/core/display_hdmi.h b/sdm/libs/core/display_hdmi.h index 64aa6c7c..cf480bff 100644 --- a/sdm/libs/core/display_hdmi.h +++ b/sdm/libs/core/display_hdmi.h @@ -46,6 +46,7 @@ class DisplayHDMI : public DisplayBase, HWEventHandler { virtual DisplayError SetRefreshRate(uint32_t refresh_rate, bool final_rate); virtual bool IsUnderscanSupported(); virtual DisplayError OnMinHdcpEncryptionLevelChange(uint32_t min_enc_level); + virtual DisplayError TeardownConcurrentWriteback(void) { return kErrorNotSupported; } // Implement the HWEventHandlers virtual DisplayError VSync(int64_t timestamp); diff --git a/sdm/libs/core/display_primary.cpp b/sdm/libs/core/display_primary.cpp index 4326d8ea..14d2e89b 100644 --- a/sdm/libs/core/display_primary.cpp +++ b/sdm/libs/core/display_primary.cpp @@ -255,6 +255,12 @@ DisplayError DisplayPrimary::GetRefreshRateRange(uint32_t *min_refresh_rate, return error; } +DisplayError DisplayPrimary::TeardownConcurrentWriteback(void) { + lock_guard<recursive_mutex> obj(recursive_mutex_); + + return hw_intf_->TeardownConcurrentWriteback(); +} + DisplayError DisplayPrimary::SetRefreshRate(uint32_t refresh_rate, bool final_rate) { lock_guard<recursive_mutex> obj(recursive_mutex_); diff --git a/sdm/libs/core/display_primary.h b/sdm/libs/core/display_primary.h index 60dee5c7..df31daae 100644 --- a/sdm/libs/core/display_primary.h +++ b/sdm/libs/core/display_primary.h @@ -62,6 +62,7 @@ class DisplayPrimary : public DisplayBase, HWEventHandler { virtual void IdlePowerCollapse(); virtual void PingPongTimeout(); virtual void PanelDead(); + virtual DisplayError TeardownConcurrentWriteback(void); private: bool NeedsAVREnable(); diff --git a/sdm/libs/core/display_virtual.h b/sdm/libs/core/display_virtual.h index ca154c44..c06e90db 100644 --- a/sdm/libs/core/display_virtual.h +++ b/sdm/libs/core/display_virtual.h @@ -64,6 +64,7 @@ class DisplayVirtual : public DisplayBase { return kErrorNone; } virtual DisplayError GetColorModeCount(uint32_t *mode_count); + virtual DisplayError TeardownConcurrentWriteback(void) { return kErrorNotSupported; } }; } // namespace sdm diff --git a/sdm/libs/core/drm/hw_device_drm.h b/sdm/libs/core/drm/hw_device_drm.h index c4f06c35..aaa46949 100644 --- a/sdm/libs/core/drm/hw_device_drm.h +++ b/sdm/libs/core/drm/hw_device_drm.h @@ -98,6 +98,7 @@ class HWDeviceDRM : public HWInterface { virtual DisplayError SetScaleLutConfig(HWScaleLutInfo *lut_info); virtual DisplayError SetMixerAttributes(const HWMixerAttributes &mixer_attributes); virtual DisplayError GetMixerAttributes(HWMixerAttributes *mixer_attributes); + virtual DisplayError TeardownConcurrentWriteback(void) { return kErrorNotSupported; } virtual void InitializeConfigs(); virtual DisplayError DumpDebugData() { return kErrorNone; } virtual void PopulateHWPanelInfo(); diff --git a/sdm/libs/core/drm/hw_peripheral_drm.cpp b/sdm/libs/core/drm/hw_peripheral_drm.cpp index 71437d48..01b0474d 100644 --- a/sdm/libs/core/drm/hw_peripheral_drm.cpp +++ b/sdm/libs/core/drm/hw_peripheral_drm.cpp @@ -165,13 +165,6 @@ void HWPeripheralDRM::SetupConcurrentWriteback(const HWLayersInfo &hw_layer_info if (enable) { // Set DRM properties for Concurrent Writeback. ConfigureConcurrentWriteback(hw_layer_info.stack); - - if (!validate) { - // Set GET_RETIRE_FENCE property to get Concurrent Writeback fence. - int *fence = &hw_layer_info.stack->output_buffer->release_fence_fd; - drm_atomic_intf_->Perform(DRMOps::CONNECTOR_GET_RETIRE_FENCE, - cwb_config_.token.conn_id, fence); - } } else { // Tear down the Concurrent Writeback topology. drm_atomic_intf_->Perform(DRMOps::CONNECTOR_SET_CRTC, cwb_config_.token.conn_id, 0); @@ -179,6 +172,16 @@ void HWPeripheralDRM::SetupConcurrentWriteback(const HWLayersInfo &hw_layer_info } } +DisplayError HWPeripheralDRM::TeardownConcurrentWriteback(void) { + if (cwb_config_.enabled) { + drm_mgr_intf_->UnregisterDisplay(cwb_config_.token); + cwb_config_.enabled = false; + registry_.Clear(); + } + + return kErrorNone; +} + DisplayError HWPeripheralDRM::SetupConcurrentWritebackModes() { // To setup Concurrent Writeback topology, get the Connector ID of Virtual display if (drm_mgr_intf_->RegisterDisplay(DRMDisplayType::VIRTUAL, &cwb_config_.token)) { @@ -246,9 +249,13 @@ void HWPeripheralDRM::ConfigureConcurrentWriteback(LayerStack *layer_stack) { void HWPeripheralDRM::PostCommitConcurrentWriteback(LayerBuffer *output_buffer) { bool enabled = hw_resource_.has_concurrent_writeback && output_buffer; - if (!enabled) { - drm_mgr_intf_->UnregisterDisplay(cwb_config_.token); - cwb_config_.enabled = false; + if (enabled) { + // Get Concurrent Writeback fence + int *fence = &output_buffer->release_fence_fd; + drm_atomic_intf_->Perform(DRMOps::CONNECTOR_GET_RETIRE_FENCE, cwb_config_.token.conn_id, fence); + } + else { + TeardownConcurrentWriteback(); } } diff --git a/sdm/libs/core/drm/hw_peripheral_drm.h b/sdm/libs/core/drm/hw_peripheral_drm.h index 365da42c..9523bd95 100644 --- a/sdm/libs/core/drm/hw_peripheral_drm.h +++ b/sdm/libs/core/drm/hw_peripheral_drm.h @@ -54,6 +54,7 @@ class HWPeripheralDRM : public HWDeviceDRM { virtual DisplayError Flush(); virtual DisplayError ControlIdlePowerCollapse(bool enable, bool synchronous); virtual DisplayError PowerOn(int *release_fence); + virtual DisplayError TeardownConcurrentWriteback(void); private: void SetDestScalarData(HWLayersInfo hw_layer_info); diff --git a/sdm/libs/core/fb/hw_device.h b/sdm/libs/core/fb/hw_device.h index 636baa5b..fce6e18b 100644 --- a/sdm/libs/core/fb/hw_device.h +++ b/sdm/libs/core/fb/hw_device.h @@ -100,6 +100,7 @@ class HWDevice : public HWInterface { virtual DisplayError ControlIdlePowerCollapse(bool enable, bool synchronous) { return kErrorNotSupported; } + virtual DisplayError TeardownConcurrentWriteback(void) { return kErrorNotSupported; } enum { kHWEventVSync, diff --git a/sdm/libs/core/hw_interface.h b/sdm/libs/core/hw_interface.h index 143391c2..91eb66e7 100644 --- a/sdm/libs/core/hw_interface.h +++ b/sdm/libs/core/hw_interface.h @@ -113,6 +113,7 @@ class HWInterface { virtual DisplayError GetMixerAttributes(HWMixerAttributes *mixer_attributes) = 0; virtual DisplayError DumpDebugData() = 0; virtual DisplayError ControlIdlePowerCollapse(bool enable, bool synchronous) = 0; + virtual DisplayError TeardownConcurrentWriteback(void) = 0; protected: virtual ~HWInterface() { } diff --git a/sdm/libs/hwc2/display_null.h b/sdm/libs/hwc2/display_null.h index dbfc7199..a7e69594 100644 --- a/sdm/libs/hwc2/display_null.h +++ b/sdm/libs/hwc2/display_null.h @@ -65,6 +65,7 @@ class DisplayNull : public DisplayInterface { MAKE_NO_OP(GetConfig(uint32_t, DisplayConfigVariableInfo *)) MAKE_NO_OP(GetConfig(DisplayConfigFixedInfo *)) MAKE_NO_OP(GetActiveConfig(uint32_t *)) + MAKE_NO_OP(TeardownConcurrentWriteback(void)) MAKE_NO_OP(GetVSyncState(bool *)) MAKE_NO_OP(SetActiveConfig(uint32_t)) MAKE_NO_OP(SetActiveConfig(DisplayConfigVariableInfo *)) diff --git a/sdm/libs/hwc2/hwc_display.h b/sdm/libs/hwc2/hwc_display.h index 0d3520a8..1ff55046 100644 --- a/sdm/libs/hwc2/hwc_display.h +++ b/sdm/libs/hwc2/hwc_display.h @@ -250,6 +250,9 @@ class HWCDisplay : public DisplayEventHandler { virtual DisplayError GetMixerResolution(uint32_t *width, uint32_t *height); virtual void GetPanelResolution(uint32_t *width, uint32_t *height); virtual std::string Dump(); + virtual DisplayError TeardownConcurrentWriteback(void) { + return kErrorNotSupported; + } // Captures frame output in the buffer specified by output_buffer_info. The API is // non-blocking and the client is expected to check operation status later on. diff --git a/sdm/libs/hwc2/hwc_display_primary.cpp b/sdm/libs/hwc2/hwc_display_primary.cpp index ac8d12a4..7b015636 100644 --- a/sdm/libs/hwc2/hwc_display_primary.cpp +++ b/sdm/libs/hwc2/hwc_display_primary.cpp @@ -509,6 +509,28 @@ HWC2::Error HWCDisplayPrimary::PostCommitLayerStack(int32_t *out_retire_fence) { return HWC2::Error::None; } +DisplayError HWCDisplayPrimary::TeardownConcurrentWriteback(void) { + DisplayError error = kErrorNotSupported; + + if (output_buffer_.release_fence_fd >= 0) { + int32_t release_fence_fd = dup(output_buffer_.release_fence_fd); + int ret = sync_wait(output_buffer_.release_fence_fd, 1000); + if (ret < 0) { + DLOGE("sync_wait error errno = %d, desc = %s", errno, strerror(errno)); + } + + ::close(release_fence_fd); + if (ret) + return kErrorResources; + } + + if (display_intf_) { + error = display_intf_->TeardownConcurrentWriteback(); + } + + return error; +} + int HWCDisplayPrimary::Perform(uint32_t operation, ...) { va_list args; va_start(args, operation); diff --git a/sdm/libs/hwc2/hwc_display_primary.h b/sdm/libs/hwc2/hwc_display_primary.h index 69a8522c..b0e54f90 100644 --- a/sdm/libs/hwc2/hwc_display_primary.h +++ b/sdm/libs/hwc2/hwc_display_primary.h @@ -93,6 +93,7 @@ class HWCDisplayPrimary : public HWCDisplay { int32_t samples_size[NUM_HISTOGRAM_COLOR_COMPONENTS], uint64_t* samples[NUM_HISTOGRAM_COLOR_COMPONENTS]) override; std::string Dump() override; + virtual DisplayError TeardownConcurrentWriteback(void); private: HWCDisplayPrimary(CoreInterface *core_intf, BufferAllocator *buffer_allocator, diff --git a/sdm/libs/hwc2/hwc_session.cpp b/sdm/libs/hwc2/hwc_session.cpp index 911df97d..5784a1dd 100644 --- a/sdm/libs/hwc2/hwc_session.cpp +++ b/sdm/libs/hwc2/hwc_session.cpp @@ -1163,6 +1163,13 @@ HWC2::Error HWCSession::CreateVirtualDisplayObject(uint32_t width, uint32_t heig return HWC2::Error::NoResources; } + if (hwc_display_[HWC_DISPLAY_PRIMARY]) { + auto error = hwc_display_[HWC_DISPLAY_PRIMARY]->TeardownConcurrentWriteback(); + if (error) { + return HWC2::Error::NoResources; + } + } + auto status = HWCDisplayVirtual::Create(core_intf_, &buffer_allocator_, &callbacks_, width, height, format, &hwc_display_[HWC_DISPLAY_VIRTUAL]); // TODO(user): validate width and height support |