sdm: color-manager: Frame capture interface.
Interface implementation between color manager and composer
to complete the frame capture feature.
Change-Id: Ib221c845242996f79e4aa18a0fcb290c63493107
CRs-Fixed: 1049801
diff --git a/sdm/include/private/color_params.h b/sdm/include/private/color_params.h
index 8608c16..462d293 100644
--- a/sdm/include/private/color_params.h
+++ b/sdm/include/private/color_params.h
@@ -144,16 +144,16 @@
return ret;
}
- DisplayError CreatePayloadBytes(uint8_t *output, uint32_t size_in_bytes) {
+ DisplayError CreatePayloadBytes(uint32_t size_in_bytes, uint8_t **output) {
DisplayError ret = kErrorNone;
payload = new uint8_t[size_in_bytes]();
if (!payload) {
ret = kErrorMemory;
- output = NULL;
+ *output = NULL;
} else {
this->size = size_in_bytes;
- output = payload;
+ *output = payload;
own_payload = true;
}
return ret;
diff --git a/sdm/libs/hwc/hwc_color_manager.cpp b/sdm/libs/hwc/hwc_color_manager.cpp
index 8e11fce..64603ea 100644
--- a/sdm/libs/hwc/hwc_color_manager.cpp
+++ b/sdm/libs/hwc/hwc_color_manager.cpp
@@ -343,14 +343,12 @@
if (enable) {
std::memset(&buffer_info, 0x00, sizeof(buffer_info));
- hwc_display->GetFrameBufferResolution(&buffer_info.buffer_config.width,
- &buffer_info.buffer_config.height);
+ hwc_display->GetPanelResolution(&buffer_info.buffer_config.width,
+ &buffer_info.buffer_config.height);
if (frame_capture_data->input_params.out_pix_format == PP_PIXEL_FORMAT_RGB_888) {
buffer_info.buffer_config.format = kFormatRGB888;
} else if (frame_capture_data->input_params.out_pix_format == PP_PIXEL_FORMAT_RGB_2101010) {
- // TODO(user): Complete the implementation
- DLOGE("RGB 10-bit format NOT supported");
- return -EFAULT;
+ buffer_info.buffer_config.format = kFormatRGBA1010102;
} else {
DLOGE("Pixel-format: %d NOT support.", frame_capture_data->input_params.out_pix_format);
return -EFAULT;
@@ -370,7 +368,7 @@
ret = buffer_allocator_->AllocateBuffer(&buffer_info);
if (ret != 0) {
DLOGE("Buffer allocation failed. ret: %d", ret);
- delete[] buffer_allocator_;
+ delete buffer_allocator_;
buffer_allocator_ = NULL;
return -ENOMEM;
} else {
@@ -382,7 +380,7 @@
DLOGE("mmap failed. err = %d", errno);
frame_capture_data->buffer = NULL;
ret = buffer_allocator_->FreeBuffer(&buffer_info);
- delete[] buffer_allocator_;
+ delete buffer_allocator_;
buffer_allocator_ = NULL;
return -EFAULT;
} else {
@@ -390,22 +388,30 @@
frame_capture_data->buffer_stride = buffer_info.alloc_buffer_info.stride;
frame_capture_data->buffer_size = buffer_info.alloc_buffer_info.size;
}
- // TODO(user): Call HWC interface to provide the buffer and rectangle information
+ ret = hwc_display->FrameCaptureAsync(buffer_info, 1);
+ if (ret < 0) {
+ DLOGE("FrameCaptureAsync failed. ret = %d", ret);
+ }
}
} else {
- if (frame_capture_data->buffer != NULL) {
- if (munmap(frame_capture_data->buffer, buffer_info.alloc_buffer_info.size) != 0) {
- DLOGE("munmap failed. err = %d", errno);
+ ret = hwc_display->GetFrameCaptureStatus();
+ if (!ret) {
+ if (frame_capture_data->buffer != NULL) {
+ if (munmap(frame_capture_data->buffer, buffer_info.alloc_buffer_info.size) != 0) {
+ DLOGE("munmap failed. err = %d", errno);
+ }
}
- }
- if (buffer_allocator_ != NULL) {
- std::memset(frame_capture_data, 0x00, sizeof(PPFrameCaptureData));
- ret = buffer_allocator_->FreeBuffer(&buffer_info);
- if (ret != 0) {
- DLOGE("FreeBuffer failed. ret = %d", ret);
+ if (buffer_allocator_ != NULL) {
+ std::memset(frame_capture_data, 0x00, sizeof(PPFrameCaptureData));
+ ret = buffer_allocator_->FreeBuffer(&buffer_info);
+ if (ret != 0) {
+ DLOGE("FreeBuffer failed. ret = %d", ret);
+ }
+ delete buffer_allocator_;
+ buffer_allocator_ = NULL;
}
- delete[] buffer_allocator_;
- buffer_allocator_ = NULL;
+ } else {
+ DLOGE("GetFrameCaptureStatus failed. ret = %d", ret);
}
}
return ret;
diff --git a/sdm/libs/hwc2/hwc_color_manager.cpp b/sdm/libs/hwc2/hwc_color_manager.cpp
index c40ec4b..a39516c 100644
--- a/sdm/libs/hwc2/hwc_color_manager.cpp
+++ b/sdm/libs/hwc2/hwc_color_manager.cpp
@@ -200,14 +200,12 @@
if (enable) {
std::memset(&buffer_info, 0x00, sizeof(buffer_info));
- hwc_display->GetFrameBufferResolution(&buffer_info.buffer_config.width,
- &buffer_info.buffer_config.height);
+ hwc_display->GetPanelResolution(&buffer_info.buffer_config.width,
+ &buffer_info.buffer_config.height);
if (frame_capture_data->input_params.out_pix_format == PP_PIXEL_FORMAT_RGB_888) {
buffer_info.buffer_config.format = kFormatRGB888;
} else if (frame_capture_data->input_params.out_pix_format == PP_PIXEL_FORMAT_RGB_2101010) {
- // TODO(user): Complete the implementation
- DLOGE("RGB 10-bit format NOT supported");
- return -EFAULT;
+ buffer_info.buffer_config.format = kFormatRGBA1010102;
} else {
DLOGE("Pixel-format: %d NOT support.", frame_capture_data->input_params.out_pix_format);
return -EFAULT;
@@ -227,7 +225,7 @@
ret = buffer_allocator_->AllocateBuffer(&buffer_info);
if (ret != 0) {
DLOGE("Buffer allocation failed. ret: %d", ret);
- delete[] buffer_allocator_;
+ delete buffer_allocator_;
buffer_allocator_ = NULL;
return -ENOMEM;
} else {
@@ -238,7 +236,7 @@
DLOGE("mmap failed. err = %d", errno);
frame_capture_data->buffer = NULL;
ret = buffer_allocator_->FreeBuffer(&buffer_info);
- delete[] buffer_allocator_;
+ delete buffer_allocator_;
buffer_allocator_ = NULL;
return -EFAULT;
} else {
@@ -246,22 +244,30 @@
frame_capture_data->buffer_stride = buffer_info.alloc_buffer_info.stride;
frame_capture_data->buffer_size = buffer_info.alloc_buffer_info.size;
}
- // TODO(user): Call HWC interface to provide the buffer and rectangle information
+ ret = hwc_display->FrameCaptureAsync(buffer_info, 1);
+ if (ret < 0) {
+ DLOGE("FrameCaptureAsync failed. ret = %d", ret);
+ }
}
} else {
- if (frame_capture_data->buffer != NULL) {
- if (munmap(frame_capture_data->buffer, buffer_info.alloc_buffer_info.size) != 0) {
- DLOGE("munmap failed. err = %d", errno);
+ ret = hwc_display->GetFrameCaptureStatus();
+ if (!ret) {
+ if (frame_capture_data->buffer != NULL) {
+ if (munmap(frame_capture_data->buffer, buffer_info.alloc_buffer_info.size) != 0) {
+ DLOGE("munmap failed. err = %d", errno);
+ }
}
- }
- if (buffer_allocator_ != NULL) {
- std::memset(frame_capture_data, 0x00, sizeof(PPFrameCaptureData));
- ret = buffer_allocator_->FreeBuffer(&buffer_info);
- if (ret != 0) {
- DLOGE("FreeBuffer failed. ret = %d", ret);
+ if (buffer_allocator_ != NULL) {
+ std::memset(frame_capture_data, 0x00, sizeof(PPFrameCaptureData));
+ ret = buffer_allocator_->FreeBuffer(&buffer_info);
+ if (ret != 0) {
+ DLOGE("FreeBuffer failed. ret = %d", ret);
+ }
+ delete buffer_allocator_;
+ buffer_allocator_ = NULL;
}
- delete[] buffer_allocator_;
- buffer_allocator_ = NULL;
+ } else {
+ DLOGE("GetFrameCaptureStatus failed. ret = %d", ret);
}
}
return ret;