aboutsummaryrefslogtreecommitdiff
path: root/bufferinfo
diff options
context:
space:
mode:
authorRoman Stratiienko <roman.o.stratiienko@globallogic.com>2021-10-22 12:34:36 +0300
committerRoman Stratiienko <roman.o.stratiienko@globallogic.com>2021-10-22 23:05:06 +0300
commit875f39793ff12f95cf8bd5c66addfa14b3cf01fb (patch)
treea7d107d04320d889e25acd6fe50a22a39b838c52 /bufferinfo
parent11ef8c5f6792a128d8419a037ff00b3987d565f1 (diff)
downloaddrm_hwcomposer-875f39793ff12f95cf8bd5c66addfa14b3cf01fb.tar.gz
drm_hwcomposer: Improve Mapper@4 metadata API fds index guessing logic
Unfortunately Mapper@4.0 metadata API doesn't allow to query fd index or getting fd another way for every layout plane, therefore users have to provide their custom additional metadata API. We are doing all our best to minimize custom per-platform logic in drm_hwcomposer. So it was decided to implement primitive guessing logic, allowing users to extend it with out-of-tree code if necessary. As was reported by John Stultz in [1] our primitive logic has some flaws. New guessing logic are using inputs from layout data (offsets, sizes), and should be more precise. [1]: https://gitlab.freedesktop.org/drm-hwcomposer/drm-hwcomposer/-/merge_requests/159 Signed-off-by: Roman Stratiienko <roman.o.stratiienko@globallogic.com>
Diffstat (limited to 'bufferinfo')
-rw-r--r--bufferinfo/BufferInfoMapperMetadata.cpp47
1 files changed, 30 insertions, 17 deletions
diff --git a/bufferinfo/BufferInfoMapperMetadata.cpp b/bufferinfo/BufferInfoMapperMetadata.cpp
index 23a9072..a8e95e7 100644
--- a/bufferinfo/BufferInfoMapperMetadata.cpp
+++ b/bufferinfo/BufferInfoMapperMetadata.cpp
@@ -47,30 +47,42 @@ BufferInfoGetter *BufferInfoMapperMetadata::CreateInstance() {
*/
int __attribute__((weak))
BufferInfoMapperMetadata::GetFds(buffer_handle_t handle, hwc_drm_bo_t *bo) {
- int num_fds = handle->numFds;
+ int fd_index = 0;
- if (num_fds >= 1 && num_fds <= 2) {
- if (IsDrmFormatRgb(bo->format)) {
- bo->prime_fds[0] = handle->data[0];
- } else {
- bo->prime_fds[0] = bo->prime_fds[1] = bo->prime_fds[2] = handle->data[0];
- }
- if (bo->prime_fds[0] <= 0) {
- ALOGE("Encountered invalid fd %d", bo->prime_fds[0]);
- return android::BAD_VALUE;
+ if (handle->numFds <= 0) {
+ ALOGE("Handle has no fds");
+ return android::BAD_VALUE;
+ }
+
+ for (int i = 0; i < HWC_DRM_BO_MAX_PLANES; i++) {
+ /* If no size, we're out of usable planes */
+ if (bo->sizes[i] <= 0) {
+ if (i == 0) {
+ ALOGE("Bad handle metadata");
+ return android::BAD_VALUE;
+ }
+ break;
}
- } else if (num_fds >= 3) {
- bo->prime_fds[0] = handle->data[0];
- bo->prime_fds[1] = handle->data[1];
- bo->prime_fds[2] = handle->data[2];
- for (int i = 0; i < 3; i++) {
- if (bo->prime_fds[i] <= 0) {
- ALOGE("Encountered invalid fd %d", bo->prime_fds[i]);
+ /*
+ * If the offset is zero, its multi-buffer
+ * so move to the next fd
+ */
+ if (i != 0 && bo->offsets[i] == 0) {
+ fd_index++;
+ if (fd_index >= handle->numFds) {
+ ALOGE("Handle has no more fds");
return android::BAD_VALUE;
}
}
+
+ bo->prime_fds[i] = handle->data[fd_index];
+ if (bo->prime_fds[i] <= 0) {
+ ALOGE("Invalid prime fd");
+ return android::BAD_VALUE;
+ }
}
+
return 0;
}
@@ -135,6 +147,7 @@ int BufferInfoMapperMetadata::ConvertBoInfo(buffer_handle_t handle,
bo->modifiers[i] = bo->modifiers[0];
bo->pitches[i] = layouts[i].strideInBytes;
bo->offsets[i] = layouts[i].offsetInBytes;
+ bo->sizes[i] = layouts[i].totalSizeInBytes;
}
return GetFds(handle, bo);