sdm: hwc2: Fix Concurrent Writeback issues

1. Clear Output buffer fb_id cache on Concurrent Writeback teardown.
2. Set the Handle Id of Output buffer for Concurrent Writeback.
3. In HWC binder thread for Output layer dump, do not allocate the
   new Output buffer, if the buffer already exists.

CRs-Fixed: 2315986
Change-Id: Ica37cc580f7aab0d13bcb80f5f81a8e1c9678ce1
diff --git a/sdm/libs/hwc2/hwc_display_builtin.cpp b/sdm/libs/hwc2/hwc_display_builtin.cpp
index ceda6d1..343dbcd 100644
--- a/sdm/libs/hwc2/hwc_display_builtin.cpp
+++ b/sdm/libs/hwc2/hwc_display_builtin.cpp
@@ -359,6 +359,7 @@
   output_buffer_.planes[0].stride = UINT32(handle->width);
   output_buffer_.acquire_fence_fd = dup(acquire_fence);
   output_buffer_.release_fence_fd = -1;
+  output_buffer_.handle_id = handle->id;
 
   post_processed_output_ = post_processed_output;
   readback_buffer_queued_ = true;
@@ -582,13 +583,11 @@
   dump_output_to_file_ = bit_mask_layer_type & (1 << OUTPUT_LAYER_DUMP);
   DLOGI("output_layer_dump_enable %d", dump_output_to_file_);
 
-  if (!count || !dump_output_to_file_) {
+  if (!count || !dump_output_to_file_ || (output_buffer_info_.alloc_buffer_info.fd >= 0)) {
     return HWC2::Error::None;
   }
 
   // Allocate and map output buffer
-  output_buffer_info_ = {};
-
   if (post_processed) {
     // To dump post-processed (DSPP) output, use Panel resolution.
     GetPanelResolution(&output_buffer_info_.buffer_config.width,