diff options
Diffstat (limited to 'bufferinfo/legacy')
-rw-r--r-- | bufferinfo/legacy/BufferInfoImagination.cpp | 30 | ||||
-rw-r--r-- | bufferinfo/legacy/BufferInfoImagination.h | 2 | ||||
-rw-r--r-- | bufferinfo/legacy/BufferInfoLibdrm.cpp | 45 | ||||
-rw-r--r-- | bufferinfo/legacy/BufferInfoLibdrm.h | 5 | ||||
-rw-r--r-- | bufferinfo/legacy/BufferInfoMaliHisi.cpp | 46 | ||||
-rw-r--r-- | bufferinfo/legacy/BufferInfoMaliHisi.h | 2 | ||||
-rw-r--r-- | bufferinfo/legacy/BufferInfoMaliMediatek.cpp | 30 | ||||
-rw-r--r-- | bufferinfo/legacy/BufferInfoMaliMediatek.h | 2 | ||||
-rw-r--r-- | bufferinfo/legacy/BufferInfoMaliMeson.cpp | 30 | ||||
-rw-r--r-- | bufferinfo/legacy/BufferInfoMaliMeson.h | 2 | ||||
-rw-r--r-- | bufferinfo/legacy/BufferInfoMinigbm.cpp | 34 | ||||
-rw-r--r-- | bufferinfo/legacy/BufferInfoMinigbm.h | 2 |
12 files changed, 116 insertions, 114 deletions
diff --git a/bufferinfo/legacy/BufferInfoImagination.cpp b/bufferinfo/legacy/BufferInfoImagination.cpp index 691dd14..6d917c2 100644 --- a/bufferinfo/legacy/BufferInfoImagination.cpp +++ b/bufferinfo/legacy/BufferInfoImagination.cpp @@ -29,40 +29,40 @@ namespace android { LEGACY_BUFFER_INFO_GETTER(BufferInfoImagination); -int BufferInfoImagination::ConvertBoInfo(buffer_handle_t handle, - hwc_drm_bo_t *bo) { +auto BufferInfoImagination::GetBoInfo(buffer_handle_t handle) + -> std::optional<BufferInfo> { auto *hnd = (IMG_native_handle_t *)handle; if (!hnd) - return -EINVAL; + return {}; /* Extra bits are responsible for buffer compression and memory layout */ if (hnd->iFormat & ~0x10f) { ALOGV("Special buffer formats are not supported"); - return -EINVAL; + return {}; } - bo->width = hnd->iWidth; - bo->height = hnd->iHeight; - bo->usage = hnd->usage; - bo->prime_fds[0] = hnd->fd[0]; - bo->pitches[0] = ALIGN(hnd->iWidth, HW_ALIGN) * hnd->uiBpp >> 3; - bo->hal_format = hnd->iFormat; + BufferInfo bi{}; + + bi.width = hnd->iWidth; + bi.height = hnd->iHeight; + bi.prime_fds[0] = hnd->fd[0]; + bi.pitches[0] = ALIGN(hnd->iWidth, HW_ALIGN) * hnd->uiBpp >> 3; switch (hnd->iFormat) { #ifdef HAL_PIXEL_FORMAT_BGRX_8888 case HAL_PIXEL_FORMAT_BGRX_8888: - bo->format = DRM_FORMAT_XRGB8888; + bi.format = DRM_FORMAT_XRGB8888; break; #endif default: - bo->format = ConvertHalFormatToDrm(hnd->iFormat & 0xf); - if (bo->format == DRM_FORMAT_INVALID) { + bi.format = ConvertHalFormatToDrm(hnd->iFormat & 0xf); + if (bi.format == DRM_FORMAT_INVALID) { ALOGV("Cannot convert hal format to drm format %u", hnd->iFormat); - return -EINVAL; + return {}; } } - return 0; + return bi; } } // namespace android diff --git a/bufferinfo/legacy/BufferInfoImagination.h b/bufferinfo/legacy/BufferInfoImagination.h index 765b279..635e3b5 100644 --- a/bufferinfo/legacy/BufferInfoImagination.h +++ b/bufferinfo/legacy/BufferInfoImagination.h @@ -27,7 +27,7 @@ class BufferInfoImagination : public LegacyBufferInfoGetter { public: using LegacyBufferInfoGetter::LegacyBufferInfoGetter; - int ConvertBoInfo(buffer_handle_t handle, hwc_drm_bo_t *bo) override; + auto GetBoInfo(buffer_handle_t handle) -> std::optional<BufferInfo> override; }; } // namespace android diff --git a/bufferinfo/legacy/BufferInfoLibdrm.cpp b/bufferinfo/legacy/BufferInfoLibdrm.cpp index 6baf6bb..ac71ec0 100644 --- a/bufferinfo/legacy/BufferInfoLibdrm.cpp +++ b/bufferinfo/legacy/BufferInfoLibdrm.cpp @@ -91,8 +91,8 @@ static bool is_yuv(uint32_t native) { return false; } -bool BufferInfoLibdrm::GetYuvPlaneInfo(int num_fds, buffer_handle_t handle, - hwc_drm_bo_t *bo) { +bool BufferInfoLibdrm::GetYuvPlaneInfo(uint32_t hal_format, int num_fds, + buffer_handle_t handle, BufferInfo *bo) { struct android_ycbcr ycbcr {}; enum chroma_order chroma_order {}; int ret = 0; @@ -136,12 +136,12 @@ bool BufferInfoLibdrm::GetYuvPlaneInfo(int num_fds, buffer_handle_t handle, /* .chroma_step is the byte distance between the same chroma channel * values of subsequent pixels, assumed to be the same for Cb and Cr. */ - bo->format = get_fourcc_yuv(bo->hal_format, chroma_order, ycbcr.chroma_step); + bo->format = get_fourcc_yuv(hal_format, chroma_order, ycbcr.chroma_step); if (bo->format == UINT32_MAX) { ALOGW( "unsupported YUV format, native = %x, chroma_order = %s, chroma_step = " "%d", - bo->hal_format, chroma_order == kYCbCr ? "YCbCr" : "YCrCb", + hal_format, chroma_order == kYCbCr ? "YCbCr" : "YCrCb", (int)ycbcr.chroma_step); return false; } @@ -162,14 +162,16 @@ bool BufferInfoLibdrm::GetYuvPlaneInfo(int num_fds, buffer_handle_t handle, return true; } -int BufferInfoLibdrm::ConvertBoInfo(buffer_handle_t handle, hwc_drm_bo_t *bo) { +auto BufferInfoLibdrm::GetBoInfo(buffer_handle_t handle) + -> std::optional<BufferInfo> { gralloc_handle_t *gr_handle = gralloc_handle(handle); if (!gr_handle) - return -EINVAL; + return {}; + + BufferInfo bi{}; - bo->width = gr_handle->width; - bo->height = gr_handle->height; - bo->hal_format = gr_handle->format; + bi.width = gr_handle->width; + bi.height = gr_handle->height; #if GRALLOC_HANDLE_VERSION < 4 static std::once_flag once; @@ -179,35 +181,34 @@ int BufferInfoLibdrm::ConvertBoInfo(buffer_handle_t handle, hwc_drm_bo_t *bo) { }); #endif #if GRALLOC_HANDLE_VERSION == 4 - bo->modifiers[0] = gr_handle->modifier; + bi.modifiers[0] = gr_handle->modifier; #endif - bo->usage = gr_handle->usage; - bo->prime_fds[0] = gr_handle->prime_fd; + bi.prime_fds[0] = gr_handle->prime_fd; if (is_yuv(gr_handle->format)) { - if (!GetYuvPlaneInfo(handle->numFds, handle, bo)) - return -EINVAL; + if (!GetYuvPlaneInfo(gr_handle->format, handle->numFds, handle, &bi)) + return {}; } else { - bo->pitches[0] = gr_handle->stride; - bo->offsets[0] = 0; + bi.pitches[0] = gr_handle->stride; + bi.offsets[0] = 0; /* FOSS graphic components (gbm_gralloc, mesa3d) are translating * HAL_PIXEL_FORMAT_RGB_565 to DRM_FORMAT_RGB565 without swapping * the R and B components. Same must be done here. */ - switch (bo->hal_format) { + switch (gr_handle->format) { case HAL_PIXEL_FORMAT_RGB_565: - bo->format = DRM_FORMAT_RGB565; + bi.format = DRM_FORMAT_RGB565; break; default: - bo->format = ConvertHalFormatToDrm(gr_handle->format); + bi.format = ConvertHalFormatToDrm(gr_handle->format); } - if (bo->format == DRM_FORMAT_INVALID) - return -EINVAL; + if (bi.format == DRM_FORMAT_INVALID) + return {}; } - return 0; + return bi; } constexpr char gbm_gralloc_module_name[] = "GBM Memory Allocator"; diff --git a/bufferinfo/legacy/BufferInfoLibdrm.h b/bufferinfo/legacy/BufferInfoLibdrm.h index cad8add..7f5b08c 100644 --- a/bufferinfo/legacy/BufferInfoLibdrm.h +++ b/bufferinfo/legacy/BufferInfoLibdrm.h @@ -26,11 +26,12 @@ namespace android { class BufferInfoLibdrm : public LegacyBufferInfoGetter { public: using LegacyBufferInfoGetter::LegacyBufferInfoGetter; - int ConvertBoInfo(buffer_handle_t handle, hwc_drm_bo_t *bo) override; + auto GetBoInfo(buffer_handle_t handle) -> std::optional<BufferInfo> override; int ValidateGralloc() override; private: - bool GetYuvPlaneInfo(int num_fds, buffer_handle_t handle, hwc_drm_bo_t *bo); + bool GetYuvPlaneInfo(uint32_t hal_format, int num_fds, buffer_handle_t handle, + BufferInfo *bo); }; } // namespace android diff --git a/bufferinfo/legacy/BufferInfoMaliHisi.cpp b/bufferinfo/legacy/BufferInfoMaliHisi.cpp index 5fc413a..1c7f4d0 100644 --- a/bufferinfo/legacy/BufferInfoMaliHisi.cpp +++ b/bufferinfo/legacy/BufferInfoMaliHisi.cpp @@ -66,33 +66,33 @@ uint64_t BufferInfoMaliHisi::ConvertGrallocFormatToDrmModifiers( } #endif -int BufferInfoMaliHisi::ConvertBoInfo(buffer_handle_t handle, - hwc_drm_bo_t *bo) { +auto BufferInfoMaliHisi::GetBoInfo(buffer_handle_t handle) + -> std::optional<BufferInfo> { bool is_rgb = false; const auto *hnd = (private_handle_t const *)handle; if (!hnd) - return -EINVAL; + return {}; if (!(hnd->usage & GRALLOC_USAGE_HW_FB)) - return -EINVAL; + return {}; uint32_t fmt = ConvertHalFormatToDrm(hnd->req_format); if (fmt == DRM_FORMAT_INVALID) - return -EINVAL; + return {}; + + BufferInfo bi{}; is_rgb = IsDrmFormatRgb(fmt); - bo->modifiers[0] = ConvertGrallocFormatToDrmModifiers(hnd->internal_format, - is_rgb); - - bo->width = hnd->width; - bo->height = hnd->height; - bo->hal_format = hnd->req_format; - bo->format = fmt; - bo->usage = hnd->usage; - bo->pitches[0] = hnd->byte_stride; - bo->prime_fds[0] = hnd->share_fd; - bo->offsets[0] = 0; + bi.modifiers[0] = ConvertGrallocFormatToDrmModifiers(hnd->internal_format, + is_rgb); + + bi.width = hnd->width; + bi.height = hnd->height; + bi.format = fmt; + bi.pitches[0] = hnd->byte_stride; + bi.prime_fds[0] = hnd->share_fd; + bi.offsets[0] = 0; switch (fmt) { case DRM_FORMAT_YVU420: { @@ -106,20 +106,20 @@ int BufferInfoMaliHisi::ConvertBoInfo(buffer_handle_t handle, int v_size = vu_stride * (adjusted_height / 2); /* V plane*/ - bo->prime_fds[1] = hnd->share_fd; - bo->pitches[1] = vu_stride; - bo->offsets[1] = y_size; + bi.prime_fds[1] = hnd->share_fd; + bi.pitches[1] = vu_stride; + bi.offsets[1] = y_size; /* U plane */ - bo->prime_fds[2] = hnd->share_fd; - bo->pitches[2] = vu_stride; - bo->offsets[2] = y_size + v_size; + bi.prime_fds[2] = hnd->share_fd; + bi.pitches[2] = vu_stride; + bi.offsets[2] = y_size + v_size; break; } default: break; } - return 0; + return bi; } } // namespace android diff --git a/bufferinfo/legacy/BufferInfoMaliHisi.h b/bufferinfo/legacy/BufferInfoMaliHisi.h index 698a0d3..cc37491 100644 --- a/bufferinfo/legacy/BufferInfoMaliHisi.h +++ b/bufferinfo/legacy/BufferInfoMaliHisi.h @@ -27,7 +27,7 @@ class BufferInfoMaliHisi : public LegacyBufferInfoGetter { public: using LegacyBufferInfoGetter::LegacyBufferInfoGetter; - int ConvertBoInfo(buffer_handle_t handle, hwc_drm_bo_t *bo) override; + auto GetBoInfo(buffer_handle_t handle) -> std::optional<BufferInfo> override; private: uint64_t ConvertGrallocFormatToDrmModifiers(uint64_t flags, bool is_rgb); diff --git a/bufferinfo/legacy/BufferInfoMaliMediatek.cpp b/bufferinfo/legacy/BufferInfoMaliMediatek.cpp index 7e6f3a8..2e10460 100644 --- a/bufferinfo/legacy/BufferInfoMaliMediatek.cpp +++ b/bufferinfo/legacy/BufferInfoMaliMediatek.cpp @@ -32,26 +32,26 @@ namespace android { LEGACY_BUFFER_INFO_GETTER(BufferInfoMaliMediatek); -int BufferInfoMaliMediatek::ConvertBoInfo(buffer_handle_t handle, - hwc_drm_bo_t *bo) { +auto BufferInfoMaliMediatek::GetBoInfo(buffer_handle_t handle) + -> std::optional<BufferInfo> { const auto *hnd = (private_handle_t const *)handle; if (!hnd) - return -EINVAL; + return {}; uint32_t fmt = ConvertHalFormatToDrm(hnd->req_format); if (fmt == DRM_FORMAT_INVALID) - return -EINVAL; - - bo->width = hnd->width; - bo->height = hnd->height; - bo->hal_format = hnd->req_format; - bo->format = fmt; - bo->usage = hnd->consumer_usage | hnd->producer_usage; - bo->prime_fds[0] = hnd->share_fd; - bo->pitches[0] = hnd->byte_stride; - bo->offsets[0] = 0; - - return 0; + return {}; + + BufferInfo bi{}; + + bi.width = hnd->width; + bi.height = hnd->height; + bi.format = fmt; + bi.prime_fds[0] = hnd->share_fd; + bi.pitches[0] = hnd->byte_stride; + bi.offsets[0] = 0; + + return bi; } } // namespace android diff --git a/bufferinfo/legacy/BufferInfoMaliMediatek.h b/bufferinfo/legacy/BufferInfoMaliMediatek.h index 1204818..43d987a 100644 --- a/bufferinfo/legacy/BufferInfoMaliMediatek.h +++ b/bufferinfo/legacy/BufferInfoMaliMediatek.h @@ -27,7 +27,7 @@ class BufferInfoMaliMediatek : public LegacyBufferInfoGetter { public: using LegacyBufferInfoGetter::LegacyBufferInfoGetter; - int ConvertBoInfo(buffer_handle_t handle, hwc_drm_bo_t *bo) override; + auto GetBoInfo(buffer_handle_t handle) -> std::optional<BufferInfo> override; }; } // namespace android diff --git a/bufferinfo/legacy/BufferInfoMaliMeson.cpp b/bufferinfo/legacy/BufferInfoMaliMeson.cpp index 9daf542..8160296 100644 --- a/bufferinfo/legacy/BufferInfoMaliMeson.cpp +++ b/bufferinfo/legacy/BufferInfoMaliMeson.cpp @@ -61,32 +61,32 @@ uint64_t BufferInfoMaliMeson::ConvertGrallocFormatToDrmModifiers( } #endif -int BufferInfoMaliMeson::ConvertBoInfo(buffer_handle_t handle, - hwc_drm_bo_t *bo) { +auto BufferInfoMaliMeson::GetBoInfo(buffer_handle_t handle) + -> std::optional<BufferInfo> { const auto *hnd = (private_handle_t const *)handle; if (!hnd) - return -EINVAL; + return {}; if (!(hnd->usage & GRALLOC_USAGE_HW_FB)) - return -EINVAL; + return {}; uint32_t fmt = ConvertHalFormatToDrm(hnd->req_format); if (fmt == DRM_FORMAT_INVALID) - return -EINVAL; + return {}; - bo->modifiers[0] = BufferInfoMaliMeson::ConvertGrallocFormatToDrmModifiers( + BufferInfo bi{}; + + bi.modifiers[0] = BufferInfoMaliMeson::ConvertGrallocFormatToDrmModifiers( hnd->internal_format); - bo->width = hnd->width; - bo->height = hnd->height; - bo->hal_format = hnd->req_format; - bo->format = fmt; - bo->usage = hnd->usage; - bo->prime_fds[0] = hnd->share_fd; - bo->pitches[0] = hnd->byte_stride; - bo->offsets[0] = 0; + bi.width = hnd->width; + bi.height = hnd->height; + bi.format = fmt; + bi.prime_fds[0] = hnd->share_fd; + bi.pitches[0] = hnd->byte_stride; + bi.offsets[0] = 0; - return 0; + return bi; } } // namespace android diff --git a/bufferinfo/legacy/BufferInfoMaliMeson.h b/bufferinfo/legacy/BufferInfoMaliMeson.h index ce5d3f9..3b6fab0 100644 --- a/bufferinfo/legacy/BufferInfoMaliMeson.h +++ b/bufferinfo/legacy/BufferInfoMaliMeson.h @@ -26,7 +26,7 @@ namespace android { class BufferInfoMaliMeson : public LegacyBufferInfoGetter { public: using LegacyBufferInfoGetter::LegacyBufferInfoGetter; - int ConvertBoInfo(buffer_handle_t handle, hwc_drm_bo_t *bo) override; + auto GetBoInfo(buffer_handle_t handle) -> std::optional<BufferInfo> override; private: uint64_t ConvertGrallocFormatToDrmModifiers(uint64_t flags); diff --git a/bufferinfo/legacy/BufferInfoMinigbm.cpp b/bufferinfo/legacy/BufferInfoMinigbm.cpp index 777c2b7..c5a9e98 100644 --- a/bufferinfo/legacy/BufferInfoMinigbm.cpp +++ b/bufferinfo/legacy/BufferInfoMinigbm.cpp @@ -43,11 +43,14 @@ struct cros_gralloc0_buffer_info { int stride[4]; }; -int BufferInfoMinigbm::ConvertBoInfo(buffer_handle_t handle, hwc_drm_bo_t *bo) { +auto BufferInfoMinigbm::GetBoInfo(buffer_handle_t handle) + -> std::optional<BufferInfo> { if (handle == nullptr) { - return -EINVAL; + return {}; } + BufferInfo bi{}; + uint32_t width{}; uint32_t height{}; if (gralloc_->perform(gralloc_, CROS_GRALLOC_DRM_GET_DIMENSIONS, handle, @@ -55,7 +58,7 @@ int BufferInfoMinigbm::ConvertBoInfo(buffer_handle_t handle, hwc_drm_bo_t *bo) { ALOGE( "CROS_GRALLOC_DRM_GET_DIMENSIONS operation has failed. " "Please ensure you are using the latest minigbm."); - return -EINVAL; + return {}; } int32_t droid_format{}; @@ -64,7 +67,7 @@ int BufferInfoMinigbm::ConvertBoInfo(buffer_handle_t handle, hwc_drm_bo_t *bo) { ALOGE( "CROS_GRALLOC_DRM_GET_FORMAT operation has failed. " "Please ensure you are using the latest minigbm."); - return -EINVAL; + return {}; } uint32_t usage{}; @@ -73,7 +76,7 @@ int BufferInfoMinigbm::ConvertBoInfo(buffer_handle_t handle, hwc_drm_bo_t *bo) { ALOGE( "CROS_GRALLOC_DRM_GET_USAGE operation has failed. " "Please ensure you are using the latest minigbm."); - return -EINVAL; + return {}; } struct cros_gralloc0_buffer_info info {}; @@ -82,25 +85,22 @@ int BufferInfoMinigbm::ConvertBoInfo(buffer_handle_t handle, hwc_drm_bo_t *bo) { ALOGE( "CROS_GRALLOC_DRM_GET_BUFFER_INFO operation has failed. " "Please ensure you are using the latest minigbm."); - return -EINVAL; + return {}; } - bo->width = width; - bo->height = height; + bi.width = width; + bi.height = height; - bo->hal_format = droid_format; - - bo->format = info.drm_fourcc; - bo->usage = usage; + bi.format = info.drm_fourcc; for (int i = 0; i < info.num_fds; i++) { - bo->modifiers[i] = info.modifier; - bo->prime_fds[i] = info.fds[i]; - bo->pitches[i] = info.stride[i]; - bo->offsets[i] = info.offset[i]; + bi.modifiers[i] = info.modifier; + bi.prime_fds[i] = info.fds[i]; + bi.pitches[i] = info.stride[i]; + bi.offsets[i] = info.offset[i]; } - return 0; + return bi; } constexpr char cros_gralloc_module_name[] = "CrOS Gralloc"; diff --git a/bufferinfo/legacy/BufferInfoMinigbm.h b/bufferinfo/legacy/BufferInfoMinigbm.h index 04cc2ae..40d9926 100644 --- a/bufferinfo/legacy/BufferInfoMinigbm.h +++ b/bufferinfo/legacy/BufferInfoMinigbm.h @@ -26,7 +26,7 @@ namespace android { class BufferInfoMinigbm : public LegacyBufferInfoGetter { public: using LegacyBufferInfoGetter::LegacyBufferInfoGetter; - int ConvertBoInfo(buffer_handle_t handle, hwc_drm_bo_t *bo) override; + auto GetBoInfo(buffer_handle_t handle) -> std::optional<BufferInfo> override; int ValidateGralloc() override; }; |