sdm: Add HIDL implementation for CWB APIs.
Change-Id: Id4220b4d517f4fdd23265d8394e8b2c8afd46fce
CRs-Fixed: 2476553
diff --git a/composer/hwc_display_builtin.cpp b/composer/hwc_display_builtin.cpp
index e1892da..e37f5ba 100644
--- a/composer/hwc_display_builtin.cpp
+++ b/composer/hwc_display_builtin.cpp
@@ -351,8 +351,13 @@
}
HWC2::Error HWCDisplayBuiltIn::SetReadbackBuffer(const native_handle_t *buffer,
- int32_t acquire_fence,
- bool post_processed_output) {
+ int32_t acquire_fence, bool post_processed_output,
+ CWBClient client) {
+ if (cwb_client_ != client && cwb_client_ != kCWBClientNone) {
+ DLOGE("CWB is in use with client = %d", cwb_client_);
+ return HWC2::Error::NoResources;
+ }
+
const private_handle_t *handle = reinterpret_cast<const private_handle_t *>(buffer);
if (!handle || (handle->fd < 0)) {
return HWC2::Error::BadParameter;
@@ -374,6 +379,7 @@
readback_buffer_queued_ = true;
readback_configured_ = false;
validated_ = false;
+ cwb_client_ = client;
return HWC2::Error::None;
}
@@ -392,6 +398,7 @@
readback_buffer_queued_ = false;
readback_configured_ = false;
output_buffer_ = {};
+ cwb_client_ = kCWBClientNone;
return status;
}
@@ -657,6 +664,7 @@
post_processed_output_ = false;
readback_configured_ = false;
output_buffer_ = {};
+ cwb_client_ = kCWBClientNone;
}
void HWCDisplayBuiltIn::HandleFrameDump() {
@@ -693,6 +701,7 @@
output_buffer_ = {};
output_buffer_info_ = {};
output_buffer_base_ = nullptr;
+ cwb_client_ = kCWBClientNone;
}
}
}
@@ -703,6 +712,14 @@
dump_output_to_file_ = bit_mask_layer_type & (1 << OUTPUT_LAYER_DUMP);
DLOGI("output_layer_dump_enable %d", dump_output_to_file_);
+ if (dump_output_to_file_) {
+ if (cwb_client_ != kCWBClientNone) {
+ DLOGE("CWB is in use with client = %d", cwb_client_);
+ dump_output_to_file_ = false;
+ return HWC2::Error::NoResources;
+ }
+ }
+
if (!count || !dump_output_to_file_ || (output_buffer_info_.alloc_buffer_info.fd >= 0)) {
return HWC2::Error::None;
}
@@ -738,13 +755,18 @@
output_buffer_base_ = buffer;
const native_handle_t *handle = static_cast<native_handle_t *>(output_buffer_info_.private_data);
- SetReadbackBuffer(handle, -1, post_processed);
+ SetReadbackBuffer(handle, -1, post_processed, kCWBClientFrameDump);
return HWC2::Error::None;
}
int HWCDisplayBuiltIn::FrameCaptureAsync(const BufferInfo &output_buffer_info,
bool post_processed_output) {
+ if (cwb_client_ != kCWBClientNone) {
+ DLOGE("CWB is in use with client = %d", cwb_client_);
+ return -1;
+ }
+
// Note: This function is called in context of a binder thread and a lock is already held
if (output_buffer_info.alloc_buffer_info.fd < 0) {
DLOGE("Invalid fd %d", output_buffer_info.alloc_buffer_info.fd);
@@ -770,7 +792,7 @@
}
const native_handle_t *buffer = static_cast<native_handle_t *>(output_buffer_info.private_data);
- SetReadbackBuffer(buffer, -1, post_processed_output);
+ SetReadbackBuffer(buffer, -1, post_processed_output, kCWBClientColor);
frame_capture_buffer_queued_ = true;
frame_capture_status_ = -EAGAIN;