srcs: [
"DrmHwcTwo.cpp",
+ "bufferinfo/BufferInfoGetter.cpp",
+ "bufferinfo/BufferInfoMapperMetadata.cpp",
+
"compositor/DrmDisplayComposition.cpp",
"compositor/DrmDisplayCompositor.cpp",
+ "compositor/Planner.cpp",
"drm/DrmConnector.cpp",
"drm/DrmCrtc.cpp",
"drm/DrmDevice.cpp",
"drm/DrmEncoder.cpp",
"drm/DrmEventListener.cpp",
+ "drm/DrmGenericImporter.cpp",
"drm/DrmMode.cpp",
"drm/DrmPlane.cpp",
"drm/DrmProperty.cpp",
"drm/ResourceManager.cpp",
"drm/VSyncWorker.cpp",
- "platform/platform.cpp",
-
"utils/autolock.cpp",
"utils/hwcutils.cpp",
name: "hwcomposer.drm",
defaults: ["hwcomposer.drm_defaults"],
whole_static_libs: ["drm_hwcomposer"],
- srcs: ["platform/platformdrmgeneric.cpp",
- "platform/platformlibdrm.cpp"],
+ srcs: ["bufferinfo/legacy/BufferInfoLibdrm.cpp"],
}
cc_library_shared {
name: "hwcomposer.drm_minigbm",
defaults: ["hwcomposer.drm_defaults"],
whole_static_libs: ["drm_hwcomposer"],
- srcs: [
- "platform/platformdrmgeneric.cpp",
- "platform/platformminigbm.cpp",
- ],
+ srcs: ["bufferinfo/legacy/BufferInfoMinigbm.cpp"],
include_dirs: ["external/minigbm/cros_gralloc"],
}
// Used by hwcomposer.drm_imagination
filegroup {
name: "drm_hwcomposer_platformimagination",
- srcs: [
- "platform/platformdrmgeneric.cpp",
- "platform/platformimagination.cpp",
- ],
+ srcs: ["bufferinfo/legacy/BufferInfoImagination.cpp"],
}
// Used by hwcomposer.drm_hikey and hwcomposer.drm_hikey960
filegroup {
name: "drm_hwcomposer_platformhisi",
- srcs: [
- "platform/platformdrmgeneric.cpp",
- "platform/platformhisi.cpp",
- ],
+ srcs: ["bufferinfo/legacy/BufferInfoMaliHisi.cpp"],
}
// Used by hwcomposer.drm_meson
filegroup {
name: "drm_hwcomposer_platformmeson",
- srcs: [
- "platform/platformdrmgeneric.cpp",
- "platform/platformmeson.cpp",
- ],
+ srcs: ["bufferinfo/legacy/BufferInfoMaliMeson.cpp"],
}
// Used by hwcomposer.drm_mediatek
filegroup {
name: "drm_hwcomposer_platformmediatek",
- srcs: [
- "platform/platformdrmgeneric.cpp",
- "platform/platformmediatek.cpp",
- ],
+ srcs: ["bufferinfo/legacy/BufferInfoMaliMediatek.cpp"],
}
#include <map>
#include "compositor/DrmDisplayCompositor.h"
+#include "compositor/Planner.h"
+#include "drm/DrmGenericImporter.h"
#include "drm/ResourceManager.h"
#include "drm/VSyncWorker.h"
#include "drmhwcomposer.h"
-#include "platform/platform.h"
namespace android {
#include "Backend.h"
#include "BackendManager.h"
+#include "bufferinfo/BufferInfoGetter.h"
namespace android {
bool Backend::IsClientLayer(DrmHwcTwo::HwcDisplay *display,
DrmHwcTwo::HwcLayer *layer) {
return !display->HardwareSupportsLayerType(layer->sf_type()) ||
- !display->importer()->CanImportBuffer(layer->buffer()) ||
+ !BufferInfoGetter::GetInstance()->IsHandleUsable(layer->buffer()) ||
display->color_transform_hint() != HAL_COLOR_TRANSFORM_IDENTITY ||
(layer->RequireScalingOrPhasing() &&
display->resource_manager()->ForcedScalingWithGpu());
#include "BackendRCarDu.h"
#include "BackendManager.h"
+#include "bufferinfo/BufferInfoGetter.h"
#include "drm_fourcc.h"
namespace android {
DrmHwcTwo::HwcLayer *layer) {
hwc_drm_bo_t bo;
- int ret = display->importer()->ConvertBoInfo(layer->buffer(), &bo);
+ int ret = BufferInfoGetter::GetInstance()->ConvertBoInfo(layer->buffer(),
+ &bo);
if (ret)
return true;
--- /dev/null
+/*
+ * Copyright (C) 2020 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#define LOG_TAG "hwc-buffer-info-getter"
+
+#include "BufferInfoGetter.h"
+
+#if PLATFORM_SDK_VERSION >= 30
+#include "BufferInfoMapperMetadata.h"
+#endif
+
+#include <cutils/properties.h>
+#include <gralloc_handle.h>
+#include <hardware/gralloc.h>
+#include <log/log.h>
+#include <xf86drm.h>
+#include <xf86drmMode.h>
+
+namespace android {
+
+BufferInfoGetter *BufferInfoGetter::GetInstance() {
+ static std::unique_ptr<BufferInfoGetter> inst;
+ if (inst == nullptr) {
+#if PLATFORM_SDK_VERSION >= 30
+ inst.reset(BufferInfoMapperMetadata::CreateInstance());
+ if (inst == nullptr) {
+ ALOGW(
+ "Generic buffer getter is not available. Falling back to legacy...");
+#endif
+ inst.reset(LegacyBufferInfoGetter::CreateInstance());
+#if PLATFORM_SDK_VERSION >= 30
+ }
+#endif
+ }
+
+ return inst.get();
+}
+
+bool BufferInfoGetter::IsHandleUsable(buffer_handle_t handle) {
+ hwc_drm_bo_t bo;
+ memset(&bo, 0, sizeof(hwc_drm_bo_t));
+
+ if (ConvertBoInfo(handle, &bo) != 0)
+ return false;
+
+ if (bo.prime_fds[0] == 0)
+ return false;
+
+ return true;
+}
+
+int LegacyBufferInfoGetter::Init() {
+ int ret = hw_get_module(GRALLOC_HARDWARE_MODULE_ID,
+ (const hw_module_t **)&gralloc_);
+ if (ret) {
+ ALOGE("Failed to open gralloc module");
+ return ret;
+ }
+
+ ALOGI("Using %s gralloc module: %s\n", gralloc_->common.name,
+ gralloc_->common.author);
+
+ return 0;
+}
+
+uint32_t LegacyBufferInfoGetter::ConvertHalFormatToDrm(uint32_t hal_format) {
+ switch (hal_format) {
+ case HAL_PIXEL_FORMAT_RGB_888:
+ return DRM_FORMAT_BGR888;
+ case HAL_PIXEL_FORMAT_BGRA_8888:
+ return DRM_FORMAT_ARGB8888;
+ case HAL_PIXEL_FORMAT_RGBX_8888:
+ return DRM_FORMAT_XBGR8888;
+ case HAL_PIXEL_FORMAT_RGBA_8888:
+ return DRM_FORMAT_ABGR8888;
+ case HAL_PIXEL_FORMAT_RGB_565:
+ return DRM_FORMAT_BGR565;
+ case HAL_PIXEL_FORMAT_YV12:
+ return DRM_FORMAT_YVU420;
+ default:
+ ALOGE("Cannot convert hal format to drm format %u", hal_format);
+ return DRM_FORMAT_INVALID;
+ }
+}
+
+uint32_t BufferInfoGetter::DrmFormatToBitsPerPixel(uint32_t drm_format) {
+ switch (drm_format) {
+ case DRM_FORMAT_ARGB8888:
+ case DRM_FORMAT_XBGR8888:
+ case DRM_FORMAT_ABGR8888:
+ return 32;
+ case DRM_FORMAT_BGR888:
+ return 24;
+ case DRM_FORMAT_BGR565:
+ return 16;
+ case DRM_FORMAT_YVU420:
+ return 12;
+ default:
+ ALOGE("Cannot convert hal format %u to bpp (returning 32)", drm_format);
+ return 32;
+ }
+}
+
+bool BufferInfoGetter::IsDrmFormatRgb(uint32_t drm_format) {
+ switch (drm_format) {
+ case DRM_FORMAT_ARGB8888:
+ case DRM_FORMAT_XBGR8888:
+ case DRM_FORMAT_ABGR8888:
+ case DRM_FORMAT_BGR888:
+ case DRM_FORMAT_BGR565:
+ return true;
+ default:
+ return false;
+ }
+}
+
+__attribute__((weak)) LegacyBufferInfoGetter *
+LegacyBufferInfoGetter::CreateInstance() {
+ ALOGE("No legacy buffer info getters available");
+ return nullptr;
+}
+
+} // namespace android
--- /dev/null
+/*
+ * Copyright (C) 2020 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef ANDROID_BUFFERINFOGETTER_H_
+#define ANDROID_BUFFERINFOGETTER_H_
+
+#include <drm/drm_fourcc.h>
+#include <hardware/gralloc.h>
+
+#include "drm/DrmDevice.h"
+#include "drmhwcgralloc.h"
+
+#ifndef DRM_FORMAT_INVALID
+#define DRM_FORMAT_INVALID 0
+#endif
+
+namespace android {
+
+class BufferInfoGetter {
+ public:
+ virtual ~BufferInfoGetter() {
+ }
+
+ virtual int ConvertBoInfo(buffer_handle_t handle, hwc_drm_bo_t *bo) = 0;
+
+ bool IsHandleUsable(buffer_handle_t handle);
+
+ static BufferInfoGetter *GetInstance();
+
+ static uint32_t DrmFormatToBitsPerPixel(uint32_t drm_format);
+ static bool IsDrmFormatRgb(uint32_t drm_format);
+};
+
+class LegacyBufferInfoGetter : public BufferInfoGetter {
+ public:
+ using BufferInfoGetter::BufferInfoGetter;
+
+ int Init();
+
+ int ConvertBoInfo(buffer_handle_t handle, hwc_drm_bo_t *bo) override = 0;
+
+ static LegacyBufferInfoGetter *CreateInstance();
+
+ static uint32_t ConvertHalFormatToDrm(uint32_t hal_format);
+ const gralloc_module_t *gralloc_;
+};
+
+#define LEGACY_BUFFER_INFO_GETTER(getter_) \
+ LegacyBufferInfoGetter *LegacyBufferInfoGetter::CreateInstance() { \
+ auto *instance = new getter_(); \
+ if (!instance) \
+ return NULL; \
+ \
+ int ret = instance->Init(); \
+ if (ret) { \
+ ALOGE("Failed to initialize the " #getter_ " getter %d", ret); \
+ delete instance; \
+ return NULL; \
+ } \
+ return instance; \
+ }
+
+} // namespace android
+#endif
--- /dev/null
+/*
+ * Copyright (C) 2020 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#if PLATFORM_SDK_VERSION >= 30
+
+#define LOG_TAG "hwc-bufferinfo-mappermetadata"
+
+#include "BufferInfoMapperMetadata.h"
+
+#include <drm/drm_fourcc.h>
+#include <inttypes.h>
+#include <log/log.h>
+#include <ui/GraphicBufferMapper.h>
+#include <xf86drm.h>
+#include <xf86drmMode.h>
+
+using android::hardware::graphics::common::V1_1::BufferUsage;
+
+namespace android {
+
+BufferInfoGetter *BufferInfoMapperMetadata::CreateInstance() {
+ if (GraphicBufferMapper::getInstance().getMapperVersion() <
+ GraphicBufferMapper::GRALLOC_4)
+ return nullptr;
+
+ return new BufferInfoMapperMetadata();
+}
+
+int BufferInfoMapperMetadata::ConvertBoInfo(buffer_handle_t /*handle*/,
+ hwc_drm_bo_t * /*bo*/) {
+ return -EINVAL;
+}
+
+} // namespace android
+
+#endif
--- /dev/null
+/*
+ * Copyright (C) 2020 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef PLATFORMIMAGINATION_H
+#define PLATFORMIMAGINATION_H
+
+#include "bufferinfo/BufferInfoGetter.h"
+
+namespace android {
+
+class BufferInfoMapperMetadata : public BufferInfoGetter {
+ public:
+ using BufferInfoGetter::BufferInfoGetter;
+
+ int ConvertBoInfo(buffer_handle_t handle, hwc_drm_bo_t *bo) override;
+
+ static BufferInfoGetter *CreateInstance();
+};
+} // namespace android
+
+#endif // PLATFORMIMAGINATION_H
-#define LOG_TAG "hwc-platform-imagination"
+/*
+ * Copyright (C) 2020 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
-#include "platformimagination.h"
+#define LOG_TAG "hwc-bufferinfo-imagination"
+
+#include "BufferInfoImagination.h"
#include <log/log.h>
#include <xf86drm.h>
namespace android {
-Importer *Importer::CreateInstance(DrmDevice *drm) {
- ImaginationImporter *importer = new ImaginationImporter(drm);
- if (!importer)
- return NULL;
-
- int ret = importer->Init();
- if (ret) {
- ALOGE("Failed to initialize the Imagination importer %d", ret);
- delete importer;
- return NULL;
- }
- return importer;
-}
+LEGACY_BUFFER_INFO_GETTER(BufferInfoImagination);
-int ImaginationImporter::ConvertBoInfo(buffer_handle_t handle,
- hwc_drm_bo_t *bo) {
+int BufferInfoImagination::ConvertBoInfo(buffer_handle_t handle,
+ hwc_drm_bo_t *bo) {
IMG_native_handle_t *hnd = (IMG_native_handle_t *)handle;
if (!hnd)
return -EINVAL;
--- /dev/null
+/*
+ * Copyright (C) 2020 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef BUFFERINFOIMAGINATION_H
+#define BUFFERINFOIMAGINATION_H
+
+#include <hardware/gralloc.h>
+
+#include "bufferinfo/BufferInfoGetter.h"
+
+namespace android {
+
+class BufferInfoImagination : public LegacyBufferInfoGetter {
+ public:
+ using LegacyBufferInfoGetter::LegacyBufferInfoGetter;
+
+ int ConvertBoInfo(buffer_handle_t handle, hwc_drm_bo_t *bo) override;
+};
+} // namespace android
+
+#endif // PLATFORMIMAGINATION_H
/*
- * Copyright (C) 2015 The Android Open Source Project
+ * Copyright (C) 2020 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* limitations under the License.
*/
-#define LOG_TAG "hwc-platform-libdrm"
+#define LOG_TAG "hwc-bufferinfo-libdrm"
-#include "platformlibdrm.h"
+#include "BufferInfoLibdrm.h"
#include <cutils/properties.h>
#include <gralloc_handle.h>
namespace android {
-Importer *Importer::CreateInstance(DrmDevice *drm) {
- DrmGenericImporter *importer = new LibdrmImporter(drm);
- if (!importer)
- return NULL;
-
- int ret = importer->Init();
- if (ret) {
- ALOGE("Failed to initialize the libdrm importer %d", ret);
- delete importer;
- return NULL;
- }
- return importer;
-}
+LEGACY_BUFFER_INFO_GETTER(BufferInfoLibdrm);
enum chroma_order {
YCbCr,
return false;
}
-bool LibdrmImporter::GetYuvPlaneInfo(int num_fds, buffer_handle_t handle,
- hwc_drm_bo_t *bo) {
+bool BufferInfoLibdrm::GetYuvPlaneInfo(int num_fds, buffer_handle_t handle,
+ hwc_drm_bo_t *bo) {
struct android_ycbcr ycbcr;
enum chroma_order chroma_order;
int ret;
return true;
}
-int LibdrmImporter::ConvertBoInfo(buffer_handle_t handle, hwc_drm_bo_t *bo) {
+int BufferInfoLibdrm::ConvertBoInfo(buffer_handle_t handle, hwc_drm_bo_t *bo) {
gralloc_handle_t *gr_handle = gralloc_handle(handle);
if (!gr_handle)
return -EINVAL;
/*
- * Copyright (C) 2018 The Android Open Source Project
+ * Copyright (C) 2020 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* limitations under the License.
*/
-#ifndef ANDROID_PLATFORM_LIBDRM_H_
-#define ANDROID_PLATFORM_LIBDRM_H_
+#ifndef BUFFERINFOLIBDRM_H_
+#define BUFFERINFOLIBDRM_H_
#include <hardware/gralloc.h>
-#include "platform.h"
-#include "platformdrmgeneric.h"
+#include "bufferinfo/BufferInfoGetter.h"
namespace android {
-class LibdrmImporter : public DrmGenericImporter {
+class BufferInfoLibdrm : public LegacyBufferInfoGetter {
public:
- using DrmGenericImporter::DrmGenericImporter;
+ using LegacyBufferInfoGetter::LegacyBufferInfoGetter;
int ConvertBoInfo(buffer_handle_t handle, hwc_drm_bo_t *bo) override;
private:
/*
- * Copyright (C) 2015 The Android Open Source Project
+ * Copyright (C) 2020 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* limitations under the License.
*/
-#define LOG_TAG "hwc-platform-hisi"
+#define LOG_TAG "hwc-bufferinfo-mali-hisi"
-#include "platformhisi.h"
+#include "BufferInfoMaliHisi.h"
+#include <log/log.h>
#include <xf86drm.h>
#include <xf86drmMode.h>
+
#include <cinttypes>
-#include <log/log.h>
#include "gralloc_priv.h"
#define MALI_ALIGN(value, base) (((value) + ((base)-1)) & ~((base)-1))
namespace android {
-Importer *Importer::CreateInstance(DrmDevice *drm) {
- HisiImporter *importer = new HisiImporter(drm);
- if (!importer)
- return NULL;
-
- int ret = importer->Init();
- if (ret) {
- ALOGE("Failed to initialize the hisi importer %d", ret);
- delete importer;
- return NULL;
- }
- return importer;
-}
+LEGACY_BUFFER_INFO_GETTER(BufferInfoMaliHisi);
#if defined(MALI_GRALLOC_INTFMT_AFBC_BASIC) && \
defined(AFBC_FORMAT_MOD_BLOCK_SIZE_16x16)
-uint64_t HisiImporter::ConvertGrallocFormatToDrmModifiers(uint64_t flags,
- bool is_rgb) {
+uint64_t BufferInfoMaliHisi::ConvertGrallocFormatToDrmModifiers(uint64_t flags,
+ bool is_rgb) {
uint64_t features = 0UL;
if (flags & MALI_GRALLOC_INTFMT_AFBC_BASIC)
return 0;
}
#else
-uint64_t HisiImporter::ConvertGrallocFormatToDrmModifiers(uint64_t /* flags */,
- bool /* is_rgb */) {
+uint64_t BufferInfoMaliHisi::ConvertGrallocFormatToDrmModifiers(
+ uint64_t /* flags */, bool /* is_rgb */) {
return 0;
}
#endif
-bool HisiImporter::IsDrmFormatRgb(uint32_t drm_format) {
- switch (drm_format) {
- case DRM_FORMAT_ARGB8888:
- case DRM_FORMAT_XBGR8888:
- case DRM_FORMAT_ABGR8888:
- case DRM_FORMAT_BGR888:
- case DRM_FORMAT_BGR565:
- return true;
- case DRM_FORMAT_YVU420:
- return false;
- default:
- ALOGV("Unsupported format %u assuming rgb?", drm_format);
- return true;
- }
-}
-
-int HisiImporter::ConvertBoInfo(buffer_handle_t handle, hwc_drm_bo_t *bo) {
+int BufferInfoMaliHisi::ConvertBoInfo(buffer_handle_t handle,
+ hwc_drm_bo_t *bo) {
bool is_rgb;
private_handle_t const *hnd = reinterpret_cast<private_handle_t const *>(
if (fmt == DRM_FORMAT_INVALID)
return -EINVAL;
- is_rgb = HisiImporter::IsDrmFormatRgb(fmt);
- bo->modifiers[0] = HisiImporter::
- ConvertGrallocFormatToDrmModifiers(hnd->internal_format, is_rgb);
+ is_rgb = IsDrmFormatRgb(fmt);
+ bo->modifiers[0] = ConvertGrallocFormatToDrmModifiers(hnd->internal_format,
+ is_rgb);
bo->width = hnd->width;
bo->height = hnd->height;
/*
- * Copyright (C) 2015 The Android Open Source Project
+ * Copyright (C) 2020 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* limitations under the License.
*/
-#ifndef ANDROID_PLATFORM_HISI_H_
-#define ANDROID_PLATFORM_HISI_H_
-
-#include "platform.h"
-#include "platformdrmgeneric.h"
-
-#include <stdatomic.h>
+#ifndef BUFFERINFOMALIHISI_H_
+#define BUFFERINFOMALIHISI_H_
#include <hardware/gralloc.h>
+#include "bufferinfo/BufferInfoGetter.h"
+
namespace android {
-class HisiImporter : public DrmGenericImporter {
+class BufferInfoMaliHisi : public LegacyBufferInfoGetter {
public:
- using DrmGenericImporter::DrmGenericImporter;
+ using LegacyBufferInfoGetter::LegacyBufferInfoGetter;
int ConvertBoInfo(buffer_handle_t handle, hwc_drm_bo_t *bo) override;
private:
uint64_t ConvertGrallocFormatToDrmModifiers(uint64_t flags, bool is_rgb);
-
- bool IsDrmFormatRgb(uint32_t drm_format);
};
} // namespace android
* limitations under the License.
*/
-#define LOG_TAG "hwc-platform-mediatek"
+#define LOG_TAG "hwc-bufferinfo-mali-mediatek"
-#include "platformmediatek.h"
+#include "BufferInfoMaliMediatek.h"
#include <hardware/gralloc.h>
#include <log/log.h>
#include <cinttypes>
#include "gralloc_priv.h"
-#include "platform.h"
namespace android {
-Importer *Importer::CreateInstance(DrmDevice *drm) {
- MediatekImporter *importer = new MediatekImporter(drm);
- if (!importer)
- return NULL;
+LEGACY_BUFFER_INFO_GETTER(BufferInfoMaliMediatek);
- int ret = importer->Init();
- if (ret) {
- ALOGE("Failed to initialize the mediatek importer %d", ret);
- delete importer;
- return NULL;
- }
- return importer;
-}
-
-int MediatekImporter::ConvertBoInfo(buffer_handle_t handle, hwc_drm_bo_t *bo) {
+int BufferInfoMaliMediatek::ConvertBoInfo(buffer_handle_t handle,
+ hwc_drm_bo_t *bo) {
private_handle_t const *hnd = reinterpret_cast<private_handle_t const *>(
handle);
if (!hnd)
* limitations under the License.
*/
-#ifndef ANDROID_PLATFORM_MTK_H_
-#define ANDROID_PLATFORM_MTK_H_
+#ifndef BUFFERINFOMALIMTK_H_
+#define BUFFERINFOMALIMTK_H_
#include <hardware/gralloc.h>
-#include <stdatomic.h>
-#include "platform.h"
-#include "platformdrmgeneric.h"
+#include "bufferinfo/BufferInfoGetter.h"
namespace android {
-class MediatekImporter : public DrmGenericImporter {
+class BufferInfoMaliMediatek : public LegacyBufferInfoGetter {
public:
- using DrmGenericImporter::DrmGenericImporter;
+ using LegacyBufferInfoGetter::LegacyBufferInfoGetter;
int ConvertBoInfo(buffer_handle_t handle, hwc_drm_bo_t *bo) override;
};
* limitations under the License.
*/
-#define LOG_TAG "hwc-platform-meson"
+#define LOG_TAG "hwc-bufferinfo-mali-meson"
-#include "platformmeson.h"
+#include "BufferInfoMaliMeson.h"
+#include <log/log.h>
#include <xf86drm.h>
#include <xf86drmMode.h>
+
#include <cinttypes>
-#include <log/log.h>
#include "gralloc_priv.h"
namespace android {
-Importer *Importer::CreateInstance(DrmDevice *drm) {
- MesonImporter *importer = new MesonImporter(drm);
- if (!importer)
- return NULL;
-
- int ret = importer->Init();
- if (ret) {
- ALOGE("Failed to initialize the meson importer %d", ret);
- delete importer;
- return NULL;
- }
- return importer;
-}
+LEGACY_BUFFER_INFO_GETTER(BufferInfoMaliMeson);
#if defined(MALI_GRALLOC_INTFMT_AFBC_BASIC) && \
defined(AFBC_FORMAT_MOD_BLOCK_SIZE_16x16)
-uint64_t MesonImporter::ConvertGrallocFormatToDrmModifiers(uint64_t flags) {
+uint64_t BufferInfoMaliMeson::ConvertGrallocFormatToDrmModifiers(
+ uint64_t flags) {
uint64_t features = 0UL;
if (flags & MALI_GRALLOC_INTFMT_AFBC_BASIC) {
return 0;
}
#else
-uint64_t MesonImporter::ConvertGrallocFormatToDrmModifiers(
+uint64_t BufferInfoMaliMeson::ConvertGrallocFormatToDrmModifiers(
uint64_t /* flags */) {
return 0;
}
#endif
-int MesonImporter::ConvertBoInfo(buffer_handle_t handle, hwc_drm_bo_t *bo) {
+int BufferInfoMaliMeson::ConvertBoInfo(buffer_handle_t handle,
+ hwc_drm_bo_t *bo) {
private_handle_t const *hnd = reinterpret_cast<private_handle_t const *>(
handle);
if (!hnd)
if (fmt == DRM_FORMAT_INVALID)
return -EINVAL;
- bo->modifiers[0] = MesonImporter::ConvertGrallocFormatToDrmModifiers(
+ bo->modifiers[0] = BufferInfoMaliMeson::ConvertGrallocFormatToDrmModifiers(
hnd->internal_format);
bo->width = hnd->width;
* limitations under the License.
*/
-#ifndef ANDROID_PLATFORM_HISI_H_
-#define ANDROID_PLATFORM_HISI_H_
-
-#include "platform.h"
-#include "platformdrmgeneric.h"
-
-#include <stdatomic.h>
+#ifndef BUFFERINFOMALIHISI_H_
+#define BUFFERINFOMALIHISI_H_
#include <hardware/gralloc.h>
+#include "bufferinfo/BufferInfoGetter.h"
+
namespace android {
-class MesonImporter : public DrmGenericImporter {
+class BufferInfoMaliMeson : public LegacyBufferInfoGetter {
public:
- using DrmGenericImporter::DrmGenericImporter;
-
+ using LegacyBufferInfoGetter::LegacyBufferInfoGetter;
int ConvertBoInfo(buffer_handle_t handle, hwc_drm_bo_t *bo) override;
private:
* limitations under the License.
*/
-#define LOG_TAG "hwc-platform-drm-minigbm"
+#define LOG_TAG "hwc-bufferinfo-minigbm"
-#include "platformminigbm.h"
+#include "BufferInfoMinigbm.h"
+#include <log/log.h>
#include <xf86drm.h>
#include <xf86drmMode.h>
-#include <log/log.h>
-
#include "cros_gralloc_handle.h"
namespace android {
-Importer *Importer::CreateInstance(DrmDevice *drm) {
- DrmMinigbmImporter *importer = new DrmMinigbmImporter(drm);
- if (!importer)
- return NULL;
-
- int ret = importer->Init();
- if (ret) {
- ALOGE("Failed to initialize the minigbm importer %d", ret);
- delete importer;
- return NULL;
- }
- return importer;
-}
+LEGACY_BUFFER_INFO_GETTER(BufferInfoMinigbm);
-int DrmMinigbmImporter::ConvertBoInfo(buffer_handle_t handle,
- hwc_drm_bo_t *bo) {
+int BufferInfoMinigbm::ConvertBoInfo(buffer_handle_t handle, hwc_drm_bo_t *bo) {
cros_gralloc_handle *gr_handle = (cros_gralloc_handle *)handle;
if (!gr_handle)
return -EINVAL;
* limitations under the License.
*/
-#ifndef ANDROID_PLATFORM_DRM_MINIGBM_H_
-#define ANDROID_PLATFORM_DRM_MINIGBM_H_
-
-#include "platform.h"
-#include "platformdrmgeneric.h"
+#ifndef BUFFERINFOMINIGBM_H_
+#define BUFFERINFOMINIGBM_H_
#include <hardware/gralloc.h>
+#include "bufferinfo/BufferInfoGetter.h"
+
namespace android {
-class DrmMinigbmImporter : public DrmGenericImporter {
+class BufferInfoMinigbm : public LegacyBufferInfoGetter {
public:
- using DrmGenericImporter::DrmGenericImporter;
+ using LegacyBufferInfoGetter::LegacyBufferInfoGetter;
int ConvertBoInfo(buffer_handle_t handle, hwc_drm_bo_t *bo) override;
};
#include <unordered_set>
#include "DrmDisplayCompositor.h"
+#include "Planner.h"
#include "drm/DrmDevice.h"
-#include "platform/platform.h"
namespace android {
#include "DrmDisplayComposition.h"
#include "DrmFramebuffer.h"
+#include "Planner.h"
#include "drm/ResourceManager.h"
#include "drm/VSyncWorker.h"
#include "drmhwcomposer.h"
#define LOG_TAG "hwc-platform"
-#include "platform.h"
+#include "Planner.h"
#include <log/log.h>
namespace android {
+std::unique_ptr<Planner> Planner::CreateInstance(DrmDevice *) {
+ std::unique_ptr<Planner> planner(new Planner);
+ planner->AddStage<PlanStageGreedy>();
+ return planner;
+}
+
std::vector<DrmPlane *> Planner::GetUsablePlanes(
DrmCrtc *crtc, std::vector<DrmPlane *> *primary_planes,
std::vector<DrmPlane *> *overlay_planes) {
class DrmDevice;
-class Importer {
- public:
- virtual ~Importer() {
- }
-
- // Creates a platform-specific importer instance
- static Importer *CreateInstance(DrmDevice *drm);
-
- // Imports the buffer referred to by handle into bo.
- //
- // Note: This can be called from a different thread than ReleaseBuffer. The
- // implementation is responsible for ensuring thread safety.
- virtual int ImportBuffer(buffer_handle_t handle, hwc_drm_bo_t *bo) = 0;
-
- // Releases the buffer object (ie: does the inverse of ImportBuffer)
- //
- // Note: This can be called from a different thread than ImportBuffer. The
- // implementation is responsible for ensuring thread safety.
- virtual int ReleaseBuffer(hwc_drm_bo_t *bo) = 0;
-
- // Checks if importer can import the buffer.
- virtual bool CanImportBuffer(buffer_handle_t handle) = 0;
-
- // Convert platform-dependent buffer format to drm_hwc internal format.
- virtual int ConvertBoInfo(buffer_handle_t handle, hwc_drm_bo_t *bo) = 0;
-};
-
class Planner {
public:
class PlanStage {
#include <algorithm>
#include <array>
#include <cinttypes>
+#include <sstream>
#include <string>
static void trim_left(std::string &str) {
#include <stdint.h>
+#include <map>
#include <tuple>
#include "DrmConnector.h"
#include "DrmEncoder.h"
#include "DrmEventListener.h"
#include "DrmPlane.h"
-#include "platform/platform.h"
namespace android {
/*
- * Copyright (C) 2015 The Android Open Source Project
+ * Copyright (C) 2020 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
#define LOG_TAG "hwc-platform-drm-generic"
-#include "platformdrmgeneric.h"
-
-#include <xf86drm.h>
-#include <xf86drmMode.h>
+#include "DrmGenericImporter.h"
#include <cutils/properties.h>
#include <gralloc_handle.h>
#include <hardware/gralloc.h>
#include <log/log.h>
+#include <xf86drm.h>
+#include <xf86drmMode.h>
namespace android {
DrmGenericImporter::~DrmGenericImporter() {
}
-int DrmGenericImporter::Init() {
- int ret = hw_get_module(GRALLOC_HARDWARE_MODULE_ID,
- (const hw_module_t **)&gralloc_);
- if (ret) {
- ALOGE("Failed to open gralloc module");
- return ret;
- }
-
- ALOGI("Using %s gralloc module: %s\n", gralloc_->common.name,
- gralloc_->common.author);
-
- return 0;
-}
-
-uint32_t DrmGenericImporter::ConvertHalFormatToDrm(uint32_t hal_format) {
- switch (hal_format) {
- case HAL_PIXEL_FORMAT_RGB_888:
- return DRM_FORMAT_BGR888;
- case HAL_PIXEL_FORMAT_BGRA_8888:
- return DRM_FORMAT_ARGB8888;
- case HAL_PIXEL_FORMAT_RGBX_8888:
- return DRM_FORMAT_XBGR8888;
- case HAL_PIXEL_FORMAT_RGBA_8888:
- return DRM_FORMAT_ABGR8888;
- case HAL_PIXEL_FORMAT_RGB_565:
- return DRM_FORMAT_BGR565;
- case HAL_PIXEL_FORMAT_YV12:
- return DRM_FORMAT_YVU420;
- default:
- ALOGE("Cannot convert hal format to drm format %u", hal_format);
- return DRM_FORMAT_INVALID;
- }
-}
-
-uint32_t DrmGenericImporter::DrmFormatToBitsPerPixel(uint32_t drm_format) {
- switch (drm_format) {
- case DRM_FORMAT_ARGB8888:
- case DRM_FORMAT_XBGR8888:
- case DRM_FORMAT_ABGR8888:
- return 32;
- case DRM_FORMAT_BGR888:
- return 24;
- case DRM_FORMAT_BGR565:
- return 16;
- case DRM_FORMAT_YVU420:
- return 12;
- default:
- ALOGE("Cannot convert hal format %u to bpp (returning 32)", drm_format);
- return 32;
- }
-}
-
-int DrmGenericImporter::ImportBuffer(buffer_handle_t handle, hwc_drm_bo_t *bo) {
- memset(bo, 0, sizeof(hwc_drm_bo_t));
-
- int ret = ConvertBoInfo(handle, bo);
- if (ret)
- return ret;
-
- ret = drmPrimeFDToHandle(drm_->fd(), bo->prime_fds[0], &bo->gem_handles[0]);
+int DrmGenericImporter::ImportBuffer(hwc_drm_bo_t *bo) {
+ int ret = drmPrimeFDToHandle(drm_->fd(), bo->prime_fds[0],
+ &bo->gem_handles[0]);
if (ret) {
ALOGE("failed to import prime fd %d ret=%d", bo->prime_fds[0], ret);
return ret;
return 0;
}
-bool DrmGenericImporter::CanImportBuffer(buffer_handle_t handle) {
- hwc_drm_bo_t bo;
-
- int ret = ConvertBoInfo(handle, &bo);
- if (ret)
- return false;
-
- if (bo.prime_fds[0] == 0)
- return false;
-
- return true;
-}
-
-std::unique_ptr<Planner> Planner::CreateInstance(DrmDevice *) {
- std::unique_ptr<Planner> planner(new Planner);
- planner->AddStage<PlanStageGreedy>();
- return planner;
-}
-
int DrmGenericImporter::ImportHandle(uint32_t gem_handle) {
gem_refcount_[gem_handle]++;
return ret;
}
-}
+} // namespace android
/*
- * Copyright (C) 2015 The Android Open Source Project
+ * Copyright (C) 2020 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
#include <map>
#include "drm/DrmDevice.h"
-#include "platform.h"
+#include "drmhwcgralloc.h"
#ifndef DRM_FORMAT_INVALID
#define DRM_FORMAT_INVALID 0
namespace android {
+class Importer {
+ public:
+ virtual ~Importer() {
+ }
+
+ // Imports the buffer referred to by handle into bo.
+ //
+ // Note: This can be called from a different thread than ReleaseBuffer. The
+ // implementation is responsible for ensuring thread safety.
+ virtual int ImportBuffer(hwc_drm_bo_t *bo) = 0;
+
+ // Releases the buffer object (ie: does the inverse of ImportBuffer)
+ //
+ // Note: This can be called from a different thread than ImportBuffer. The
+ // implementation is responsible for ensuring thread safety.
+ virtual int ReleaseBuffer(hwc_drm_bo_t *bo) = 0;
+};
+
class DrmGenericImporter : public Importer {
public:
DrmGenericImporter(DrmDevice *drm);
~DrmGenericImporter() override;
- int Init();
-
- int ImportBuffer(buffer_handle_t handle, hwc_drm_bo_t *bo) override;
+ int ImportBuffer(hwc_drm_bo_t *bo) override;
int ReleaseBuffer(hwc_drm_bo_t *bo) override;
- bool CanImportBuffer(buffer_handle_t handle) override;
int ImportHandle(uint32_t gem_handle);
int ReleaseHandle(uint32_t gem_handle);
- int ConvertBoInfo(buffer_handle_t handle, hwc_drm_bo_t *bo) override = 0;
-
- uint32_t ConvertHalFormatToDrm(uint32_t hal_format);
- uint32_t DrmFormatToBitsPerPixel(uint32_t drm_format);
-
protected:
DrmDevice *drm_;
- const gralloc_module_t *gralloc_;
private:
-
int CloseHandle(uint32_t gem_handle);
std::map<uint32_t, int> gem_refcount_;
};
+
} // namespace android
#endif
#include <sstream>
+#include "bufferinfo/BufferInfoGetter.h"
+
namespace android {
ResourceManager::ResourceManager() : num_displays_(0), gralloc_(NULL) {
property_get("vendor.hwc.drm.scale_with_gpu", scale_with_gpu, "0");
scale_with_gpu_ = bool(strncmp(scale_with_gpu, "0", 1));
+ if (!BufferInfoGetter::GetInstance()) {
+ ALOGE("Failed to initialize BufferInfoGetter");
+ return -EINVAL;
+ }
+
return hw_get_module(GRALLOC_HARDWARE_MODULE_ID,
(const hw_module_t **)&gralloc_);
}
if (ret)
return ret;
std::shared_ptr<Importer> importer;
- importer.reset(Importer::CreateInstance(drm.get()));
+ importer.reset(new DrmGenericImporter(drm.get()));
if (!importer) {
ALOGE("Failed to create importer instance");
return -ENODEV;
#include <string.h>
#include "DrmDevice.h"
-#include "platform/platform.h"
+#include "DrmGenericImporter.h"
namespace android {
+++ /dev/null
-#ifndef PLATFORMIMAGINATION_H
-#define PLATFORMIMAGINATION_H
-
-#include "platform.h"
-#include "platformdrmgeneric.h"
-
-#include <stdatomic.h>
-
-#include <hardware/gralloc.h>
-
-namespace android {
-
-class ImaginationImporter : public DrmGenericImporter {
- public:
- using DrmGenericImporter::DrmGenericImporter;
-
- int ConvertBoInfo(buffer_handle_t handle, hwc_drm_bo_t *bo) override;
-};
-} // namespace android
-
-#endif // PLATFORMIMAGINATION_H
#include <log/log.h>
#include <ui/GraphicBufferMapper.h>
+#include "bufferinfo/BufferInfoGetter.h"
+#include "drm/DrmGenericImporter.h"
#include "drmhwcomposer.h"
-#include "platform/platform.h"
#define UNUSED(x) (void)(x)
}
int DrmHwcBuffer::ImportBuffer(buffer_handle_t handle, Importer *importer) {
- hwc_drm_bo tmp_bo;
+ hwc_drm_bo tmp_bo{};
- int ret = importer->ImportBuffer(handle, &tmp_bo);
+ BufferInfoGetter::GetInstance()->ConvertBoInfo(handle, &tmp_bo);
+
+ int ret = importer->ImportBuffer(&tmp_bo);
if (ret)
return ret;