From d30ea0663adab7452bd44404fb1d6700a96a8d3f Mon Sep 17 00:00:00 2001 From: Jeevaka Prabu Badrappan Date: Tue, 18 Mar 2025 19:13:43 +0000 Subject: [PATCH 1/3] intel_defines: Add ADL-N PCI ids Ref: https://patchwork.freedesktop.org/patch/578271/?series=129901&rev=1 Ref: bspec 68397 BUG=b:403278247 TEST=CI Change-Id: I4588469defa166e58e733ae45af3247e2222c654 Signed-off-by: Jeevaka Prabu Badrappan Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/6394316 Reviewed-by: Ryan Neph Tested-by: Ryan Neph Commit-Queue: Ryan Neph Reviewed-by: Lina Versace --- intel_defines.h | 1 + 1 file changed, 1 insertion(+) diff --git a/intel_defines.h b/intel_defines.h index bb00100..9cd9924 100644 --- a/intel_defines.h +++ b/intel_defines.h @@ -54,6 +54,7 @@ const uint16_t adlp_ids[] = { 0x46A0, 0x46A1, 0x46A2, 0x46A3, 0x46A6, 0x46A8, 0x46AA, 0x462A, 0x4626, 0x4628, 0x46B0, 0x46B1, 0x46B2, 0x46B3, 0x46C0, 0x46C1, 0x46C2, 0x46C3, 0x46D0, 0x46D1, 0x46D2, + 0x46D3, 0x46D4, }; const uint16_t rplp_ids[] = { 0xA720, 0xA721, 0xA7A0, 0xA7A1, 0xA7A8, 0xA7A9, }; From 9acaaad9a03417fcce9923328068e5284f008ffe Mon Sep 17 00:00:00 2001 From: Yiwei Zhang Date: Wed, 26 Mar 2025 05:39:21 +0000 Subject: [PATCH 2/3] minigbm: expand owners for desktop development To ease the desktop development, it's better to expand the existing owners of minigbm. Unlike CrOS side, I'd like to keep the list minimal so only introduce per-file for the hw backends under our control. Bug: N/A Test: build Change-Id: I1f05842af9e35c669c28b9e45c443ff30c87d56e --- OWNERS.android | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/OWNERS.android b/OWNERS.android index 54e65dc..b842031 100644 --- a/OWNERS.android +++ b/OWNERS.android @@ -1,3 +1,15 @@ adelva@google.com natsu@google.com +prahladk@google.com include platform/system/core:main:/janitors/OWNERS + +# Intel +per-file external/i915_drm.h = msturner@google.com, ryanneph@google.com +per-file external/xe_drm.h = msturner@google.com, ryanneph@google.com +per-file intel_defines.h = msturner@google.com, ryanneph@google.com +per-file i915.c = msturner@google.com, ryanneph@google.com +per-file xe.c = msturner@google.com, ryanneph@google.com + +# Mediatek +per-file external/mediatek_drm.h = dbehr@google.com, zzyiwei@google.com +per-file mediatek.c = dbehr@google.com, zzyiwei@google.com From a1e715acd8e690069786b17a44e0c9c509ddaa42 Mon Sep 17 00:00:00 2001 From: Dominik Behr Date: Thu, 20 Mar 2025 17:03:12 -0700 Subject: [PATCH 3/3] cros_gralloc: add support for mt8186 Add build changes for mt8186. Add ARM metadata types: compression, plane fds and data type. Add mediatek_drm.h which is not available. Bug: 388092228 Test: boot corsola with minigbm gralloc/mapper Change-Id: I1f1e8a57f37e26694320c3ddee01fbad453f854b --- Android.bp | 14 +++ cros_gralloc/cros_gralloc_arm.h | 69 +++++++++++++++ cros_gralloc/cros_gralloc_buffer.cc | 8 ++ cros_gralloc/cros_gralloc_buffer.h | 1 + cros_gralloc/gralloc4/Android.bp | 16 ++++ cros_gralloc/gralloc4/CrosGralloc4Mapper.cc | 46 +++++++++- ....allocator@4.0-service.minigbm_mediatek.rc | 24 +++++ cros_gralloc/mapper_stablec/Mapper.cpp | 87 ++++++++++++++++++- external/mediatek_drm.h | 62 +++++++++++++ mediatek.c | 2 +- 10 files changed, 322 insertions(+), 7 deletions(-) create mode 100644 cros_gralloc/cros_gralloc_arm.h create mode 100644 cros_gralloc/gralloc4/android.hardware.graphics.allocator@4.0-service.minigbm_mediatek.rc create mode 100644 external/mediatek_drm.h diff --git a/Android.bp b/Android.bp index d044e7d..1ca0d26 100644 --- a/Android.bp +++ b/Android.bp @@ -82,6 +82,10 @@ msm_cflags = [ ] arcvm_cflags = ["-DVIRTIO_GPU_NEXT"] +mediatek_cflags = [ + "-DDRV_MEDIATEK", +] + cc_defaults { name: "minigbm_defaults", @@ -100,6 +104,9 @@ cc_defaults { "meson": meson_cflags, "msm": msm_cflags, "arcvm": arcvm_cflags, + "mt8186": mediatek_cflags + ["-DMTK_MT8186"], + "mt8188": mediatek_cflags + ["-DMTK_MT8188G"], + "mt8196": mediatek_cflags + ["-DMTK_MT8196"], default: [], }), @@ -323,3 +330,10 @@ cc_library_shared { defaults: ["minigbm_cros_gralloc0_defaults"], shared_libs: ["libminigbm_gralloc_arcvm"], } + +// mediatek +cc_library_shared { + name: "libminigbm_gralloc_mediatek", + defaults: ["minigbm_cros_gralloc_library_defaults"], + cflags: mediatek_cflags, +} diff --git a/cros_gralloc/cros_gralloc_arm.h b/cros_gralloc/cros_gralloc_arm.h new file mode 100644 index 0000000..6389714 --- /dev/null +++ b/cros_gralloc/cros_gralloc_arm.h @@ -0,0 +1,69 @@ +#ifndef CROS_GRALLOC_ARM_H +#define CROS_GRALLOC_ARM_H + +#include "../drv.h" +#include "aidl/android/hardware/graphics/common/ExtendableType.h" + +using aidl::android::hardware::graphics::common::ExtendableType; + +/* from AIDL interface */ +typedef enum { + INVALID = 0, + PLANE_FDS = 1, + FORMAT_DATA_TYPE = 2, +} ArmMetadataType; + +typedef enum { + UNORM = 0, + SNORM = 1, + UINT = 2, + SINT = 3, + SFLOAT = 4, + UNKNOWN = 0xFF, +} ArmDataType; + +typedef enum { + AFBC = 0, + AFRC = 1, +} ArmCompression; + +#define GRALLOC_ARM_COMPRESSION_TYPE_NAME "arm.graphics.Compression" +const static ExtendableType Compression_AFBC{ GRALLOC_ARM_COMPRESSION_TYPE_NAME, + static_cast(ArmCompression::AFBC) }; + +const static ExtendableType Compression_AFRC{ GRALLOC_ARM_COMPRESSION_TYPE_NAME, + static_cast(ArmCompression::AFRC) }; + +#define GRALLOC_ARM_METADATA_TYPE_NAME "arm.graphics.ArmMetadataType" + +#define GRALLOC_ARM_FORMAT_DATA_TYPE_NAME "arm.graphics.DataType" + +static ArmDataType DataTypeFromDrmPixelFormat(uint32_t pf) +{ + switch (pf) { + case DRM_FORMAT_R8: + case DRM_FORMAT_GR88: + case DRM_FORMAT_RGB565: + case DRM_FORMAT_XRGB8888: + case DRM_FORMAT_ARGB8888: + case DRM_FORMAT_XBGR8888: + case DRM_FORMAT_ABGR8888: + case DRM_FORMAT_XRGB2101010: + case DRM_FORMAT_XBGR2101010: + case DRM_FORMAT_ARGB2101010: + case DRM_FORMAT_ABGR2101010: + case DRM_FORMAT_NV12: + case DRM_FORMAT_NV21: + case DRM_FORMAT_YUYV: + case DRM_FORMAT_YVU420: + case DRM_FORMAT_YVU420_ANDROID: + case DRM_FORMAT_P010: + return ArmDataType::UNORM; + case DRM_FORMAT_ABGR16161616F: + return ArmDataType::SFLOAT; + default: + return ArmDataType::UNKNOWN; + } +} + +#endif // CROS_GRALLOC_ARM_H diff --git a/cros_gralloc/cros_gralloc_buffer.cc b/cros_gralloc/cros_gralloc_buffer.cc index b2c4dc8..5af8c46 100644 --- a/cros_gralloc/cros_gralloc_buffer.cc +++ b/cros_gralloc/cros_gralloc_buffer.cc @@ -142,6 +142,14 @@ uint32_t cros_gralloc_buffer::get_plane_size(uint32_t plane) const return hnd_->sizes[plane]; } +int64_t cros_gralloc_buffer::get_plane_fd(uint32_t plane) const +{ + if (plane >= hnd_->num_planes) { + return -1; + } + return hnd_->fds[plane]; +} + int32_t cros_gralloc_buffer::get_android_format() const { return hnd_->droid_format; diff --git a/cros_gralloc/cros_gralloc_buffer.h b/cros_gralloc/cros_gralloc_buffer.h index e246602..9707aca 100644 --- a/cros_gralloc/cros_gralloc_buffer.h +++ b/cros_gralloc/cros_gralloc_buffer.h @@ -38,6 +38,7 @@ class cros_gralloc_buffer uint32_t get_plane_offset(uint32_t plane) const; uint32_t get_plane_stride(uint32_t plane) const; uint32_t get_plane_size(uint32_t plane) const; + int64_t get_plane_fd(uint32_t plane) const; int32_t get_android_format() const; int64_t get_android_usage() const; diff --git a/cros_gralloc/gralloc4/Android.bp b/cros_gralloc/gralloc4/Android.bp index 73588f7..432a89d 100644 --- a/cros_gralloc/gralloc4/Android.bp +++ b/cros_gralloc/gralloc4/Android.bp @@ -126,6 +126,14 @@ cc_binary { }, } +cc_binary { + name: "android.hardware.graphics.allocator@4.0-service.minigbm_mediatek", + defaults: ["minigbm_gralloc4_allocator_defaults"], + shared_libs: ["libminigbm_gralloc_mediatek"], + vintf_fragment_modules: ["android.hardware.graphics.allocator@4.0.xml"], + init_rc: ["android.hardware.graphics.allocator@4.0-service.minigbm_mediatek.rc"], +} + vintf_fragment { name: "android.hardware.graphics.mapper@4.0.xml", src: "android.hardware.graphics.mapper@4.0.xml", @@ -172,3 +180,11 @@ cc_library_shared { }, }, } + +cc_library_shared { + name: "android.hardware.graphics.mapper@4.0-impl.minigbm_mediatek", + defaults: ["minigbm_gralloc4_common_defaults"], + shared_libs: ["libminigbm_gralloc_mediatek"], + vintf_fragment_modules: ["android.hardware.graphics.mapper@4.0.xml"], + srcs: [":minigbm_gralloc4_mapper_files"], +} diff --git a/cros_gralloc/gralloc4/CrosGralloc4Mapper.cc b/cros_gralloc/gralloc4/CrosGralloc4Mapper.cc index f9f75b6..7219a3f 100644 --- a/cros_gralloc/gralloc4/CrosGralloc4Mapper.cc +++ b/cros_gralloc/gralloc4/CrosGralloc4Mapper.cc @@ -16,6 +16,7 @@ #include #include +#include "cros_gralloc/cros_gralloc_arm.h" #include "cros_gralloc/cros_gralloc_helpers.h" #include "cros_gralloc/gralloc4/CrosGralloc4Utils.h" @@ -34,6 +35,11 @@ using android::hardware::graphics::common::V1_2::PixelFormat; using android::hardware::graphics::mapper::V4_0::Error; using android::hardware::graphics::mapper::V4_0::IMapper; +const static IMapper::MetadataType kArmMetadataTypePlaneFds{ + GRALLOC_ARM_METADATA_TYPE_NAME, static_cast(ArmMetadataType::PLANE_FDS)}; +const static IMapper::MetadataType kArmMetadataTypeFormatDataType{ + GRALLOC_ARM_METADATA_TYPE_NAME, static_cast(ArmMetadataType::FORMAT_DATA_TYPE)}; + Return CrosGralloc4Mapper::createDescriptor(const BufferDescriptorInfo& description, createDescriptor_cb hidlCb) { hidl_vec descriptor; @@ -480,8 +486,18 @@ Return CrosGralloc4Mapper::get(const cros_gralloc_buffer* crosBuffer, crosBuffer->get_android_usage() & BufferUsage::PROTECTED ? 1 : 0; status = android::gralloc4::encodeProtectedContent(hasProtectedContent, &encodedMetadata); } else if (metadataType == android::gralloc4::MetadataType_Compression) { - status = android::gralloc4::encodeCompression(android::gralloc4::Compression_None, - &encodedMetadata); + ExtendableType compression = android::gralloc4::Compression_None; + uint64_t modifier = crosBuffer->get_format_modifier(); + + if (fourcc_mod_is_vendor(modifier, ARM)) { + if (((modifier >> 52) & 0xF) == DRM_FORMAT_MOD_ARM_TYPE_AFBC) { + compression = Compression_AFBC; + } else if (((modifier >> 52) & 0xF) == DRM_FORMAT_MOD_ARM_TYPE_AFRC) { + compression = Compression_AFRC; + } + } + + status = android::gralloc4::encodeCompression(compression, &encodedMetadata); } else if (metadataType == android::gralloc4::MetadataType_Interlaced) { status = android::gralloc4::encodeInterlaced(android::gralloc4::Interlaced_None, &encodedMetadata); @@ -557,6 +573,20 @@ Return CrosGralloc4Mapper::get(const cros_gralloc_buffer* crosBuffer, } } else if (metadataType == android::gralloc4::MetadataType_Smpte2094_40) { status = android::gralloc4::encodeSmpte2094_40(std::nullopt, &encodedMetadata); + } else if (metadataType == kArmMetadataTypePlaneFds) { + uint32_t num_planes = crosBuffer->get_num_planes(); + int64_t plane_fds[5]; + plane_fds[0] = num_planes; + for (auto plane = 0; plane < num_planes; plane++) { + plane_fds[1 + plane] = crosBuffer->get_plane_fd(plane); + } + encodedMetadata.resize(sizeof(uint64_t) * (1 + num_planes)); + memcpy(encodedMetadata.data(), plane_fds, encodedMetadata.size()); + } else if (metadataType == kArmMetadataTypeFormatDataType) { + uint32_t pf = crosBuffer->get_format(); + int64_t fdt = static_cast(DataTypeFromDrmPixelFormat(pf)); + encodedMetadata.resize(sizeof(fdt)); + memcpy(encodedMetadata.data(), &fdt, encodedMetadata.size()); } else { hidlCb(Error::UNSUPPORTED, encodedMetadata); return Void(); @@ -940,6 +970,18 @@ Return CrosGralloc4Mapper::listSupportedMetadataTypes(listSupportedMetadat /*isGettable=*/true, /*isSettable=*/false, }, + { + kArmMetadataTypePlaneFds, + "Vector of file descriptors of each plane", + /*isGettable=*/true, + /*isSettable=*/false, + }, + { + kArmMetadataTypeFormatDataType, + "Format data type", + /*isGettable=*/true, + /*isSettable=*/false, + }, }); hidlCb(Error::NONE, supported); diff --git a/cros_gralloc/gralloc4/android.hardware.graphics.allocator@4.0-service.minigbm_mediatek.rc b/cros_gralloc/gralloc4/android.hardware.graphics.allocator@4.0-service.minigbm_mediatek.rc new file mode 100644 index 0000000..d8d87fd --- /dev/null +++ b/cros_gralloc/gralloc4/android.hardware.graphics.allocator@4.0-service.minigbm_mediatek.rc @@ -0,0 +1,24 @@ +# +# Copyright 2025 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. +# + +service vendor.graphics.allocator-4-0 /vendor/bin/hw/android.hardware.graphics.allocator@4.0-service.minigbm_mediatek + interface android.hardware.graphics.allocator@4.0::IAllocator default + class hal animation + user system + group graphics drmrpc + capabilities SYS_NICE + onrestart restart surfaceflinger + task_profiles ServiceCapacityLow diff --git a/cros_gralloc/mapper_stablec/Mapper.cpp b/cros_gralloc/mapper_stablec/Mapper.cpp index 866f0dd..68b3680 100644 --- a/cros_gralloc/mapper_stablec/Mapper.cpp +++ b/cros_gralloc/mapper_stablec/Mapper.cpp @@ -17,6 +17,7 @@ #include +#include "cros_gralloc/cros_gralloc_arm.h" #include "cros_gralloc/cros_gralloc_driver.h" #include "cros_gralloc/cros_gralloc_handle.h" #include "cros_gralloc/gralloc4/CrosGralloc4Utils.h" @@ -49,10 +50,19 @@ static_assert(CROS_GRALLOC_BUFFER_METADATA_MAX_NAME_SIZE >= constexpr const char* STANDARD_METADATA_NAME = "android.hardware.graphics.common.StandardMetadataType"; +constexpr const AIMapper_MetadataType kArmMetadataTypePlaneFds{ + GRALLOC_ARM_METADATA_TYPE_NAME, static_cast(ArmMetadataType::PLANE_FDS)}; +constexpr const AIMapper_MetadataType kArmMetadataTypeFormatDataType{ + GRALLOC_ARM_METADATA_TYPE_NAME, static_cast(ArmMetadataType::FORMAT_DATA_TYPE)}; + static bool isStandardMetadata(AIMapper_MetadataType metadataType) { return strcmp(STANDARD_METADATA_NAME, metadataType.name) == 0; } +static bool isArmMetadata(AIMapper_MetadataType metadataType) { + return strcmp(GRALLOC_ARM_METADATA_TYPE_NAME, metadataType.name) == 0; +} + class CrosGrallocMapperV5 final : public vendor::mapper::IMapperV5Impl { private: std::shared_ptr mDriver = cros_gralloc_driver::get_instance(); @@ -119,6 +129,9 @@ class CrosGrallocMapperV5 final : public vendor::mapper::IMapperV5Impl { void dumpBuffer( const cros_gralloc_buffer* crosBuffer, std::function&)> callback); + + int32_t getArmMetadata(buffer_handle_t _Nonnull buffer, int64_t armMetadataType, + void* _Nonnull outData, size_t outDataSize); }; AIMapper_Error CrosGrallocMapperV5::importBuffer( @@ -268,14 +281,67 @@ AIMapper_Error CrosGrallocMapperV5::rereadLockedBuffer(buffer_handle_t _Nonnull int32_t CrosGrallocMapperV5::getMetadata(buffer_handle_t _Nonnull buffer, AIMapper_MetadataType metadataType, void* _Nonnull outData, size_t outDataSize) { - // We don't have any vendor-specific metadata, so divert to getStandardMetadata after validating - // that this is a standard metadata request if (isStandardMetadata(metadataType)) { return getStandardMetadata(buffer, metadataType.value, outData, outDataSize); } + + if (isArmMetadata(metadataType)) { + return getArmMetadata(buffer, metadataType.value, outData, outDataSize); + } return -AIMAPPER_ERROR_UNSUPPORTED; } +int32_t CrosGrallocMapperV5::getArmMetadata(buffer_handle_t _Nonnull buffer, + int64_t armMetadataType, void* _Nonnull outData, + size_t outDataSize) { + cros_gralloc_handle_t crosHandle = cros_gralloc_convert_handle(buffer); + if (!crosHandle) { + ALOGE("Failed to get. Invalid handle."); + return -AIMAPPER_ERROR_BAD_BUFFER; + } + int32_t retValue = -AIMAPPER_ERROR_UNSUPPORTED; + switch (armMetadataType) { + case ArmMetadataType::PLANE_FDS: { + mDriver->with_buffer(crosHandle, [&](cros_gralloc_buffer* crosBuffer) { + uint32_t num_planes = crosBuffer->get_num_planes(); + + if (outDataSize < sizeof(int64_t) * (1 + num_planes)) { + retValue = sizeof(int64_t) * (1 + num_planes); + } else { + int64_t plane_fds[DRV_MAX_PLANES + 1]; + + plane_fds[0] = num_planes; + for (auto plane = 0; plane < num_planes; plane++) { + plane_fds[1 + plane] = crosBuffer->get_plane_fd(plane); + } + + memcpy(outData, plane_fds, sizeof(uint64_t) * (1 + num_planes)); + + retValue = -AIMAPPER_ERROR_NONE; + } + }); + break; + } + case ArmMetadataType::FORMAT_DATA_TYPE: { + mDriver->with_buffer(crosHandle, [&](cros_gralloc_buffer* crosBuffer) { + uint32_t pf = crosBuffer->get_format(); + int64_t fdt = static_cast(DataTypeFromDrmPixelFormat(pf)); + + if (outDataSize < sizeof(fdt)) { + retValue = sizeof(fdt); + } else { + memcpy(outData, &fdt, sizeof(fdt)); + retValue = -AIMAPPER_ERROR_NONE; + } + }); + break; + } + default: + return -AIMAPPER_ERROR_UNSUPPORTED; + } + return retValue; +} + int32_t CrosGrallocMapperV5::getStandardMetadata(buffer_handle_t _Nonnull bufferHandle, int64_t standardType, void* _Nonnull outData, size_t outDataSize) { @@ -355,7 +421,18 @@ int32_t CrosGrallocMapperV5::getStandardMetadata(const cros_gralloc_buffer* cros return provide(hasProtectedContent); } if constexpr (metadataType == StandardMetadataType::COMPRESSION) { - return provide(android::gralloc4::Compression_None); + ExtendableType compression = android::gralloc4::Compression_None; + uint64_t modifier = crosBuffer->get_format_modifier(); + + if (fourcc_mod_is_vendor(modifier, ARM)) { + if (((modifier >> 52) & 0xF) == DRM_FORMAT_MOD_ARM_TYPE_AFBC) { + compression = Compression_AFBC; + } else if (((modifier >> 52) & 0xF) == DRM_FORMAT_MOD_ARM_TYPE_AFRC) { + compression = Compression_AFRC; + } + } + + return provide(compression); } if constexpr (metadataType == StandardMetadataType::INTERLACED) { return provide(android::gralloc4::Interlaced_None); @@ -528,7 +605,7 @@ constexpr AIMapper_MetadataTypeDescription describeStandard(StandardMetadataType AIMapper_Error CrosGrallocMapperV5::listSupportedMetadataTypes( const AIMapper_MetadataTypeDescription* _Nullable* _Nonnull outDescriptionList, size_t* _Nonnull outNumberOfDescriptions) { - static constexpr std::array sSupportedMetadaTypes{ + static constexpr std::array sSupportedMetadaTypes{ describeStandard(StandardMetadataType::BUFFER_ID, true, false), describeStandard(StandardMetadataType::NAME, true, false), describeStandard(StandardMetadataType::WIDTH, true, false), @@ -551,6 +628,8 @@ AIMapper_Error CrosGrallocMapperV5::listSupportedMetadataTypes( describeStandard(StandardMetadataType::SMPTE2086, true, true), describeStandard(StandardMetadataType::CTA861_3, true, true), describeStandard(StandardMetadataType::STRIDE, true, false), + {kArmMetadataTypePlaneFds, "Vector of file descriptors of each plane", true, false, {0}}, + {kArmMetadataTypeFormatDataType, "Format data type", true, false, {0}}, }; *outDescriptionList = sSupportedMetadaTypes.data(); *outNumberOfDescriptions = sSupportedMetadaTypes.size(); diff --git a/external/mediatek_drm.h b/external/mediatek_drm.h new file mode 100644 index 0000000..51c5dc1 --- /dev/null +++ b/external/mediatek_drm.h @@ -0,0 +1,62 @@ +/* + * Copyright (c) 2015 MediaTek Inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ + + +#ifndef _UAPI_MEDIATEK_DRM_H +#define _UAPI_MEDIATEK_DRM_H + +#include "drm.h" + +/** + * User-desired buffer creation information structure. + * + * @size: user-desired memory allocation size. + * - this size value would be page-aligned internally. + * @flags: user request for setting memory type or cache attributes. + * @handle: returned a handle to created gem object. + * - this handle will be set by gem module of kernel side. + */ +struct drm_mtk_gem_create { + uint64_t size; + uint32_t flags; + uint32_t handle; +}; + +/** + * A structure for getting buffer offset. + * + * @handle: a pointer to gem object created. + * @pad: just padding to be 64-bit aligned. + * @offset: relatived offset value of the memory region allocated. + * - this value should be set by user. + */ +struct drm_mtk_gem_map_off { + uint32_t handle; + uint32_t pad; + uint64_t offset; +}; + +#define DRM_MTK_GEM_CREATE 0x00 +#define DRM_MTK_GEM_MAP_OFFSET 0x01 + +#define DRM_MTK_GEM_CREATE_FLAG_RESTRICTED (1 << 0) +#define DRM_MTK_GEM_CREATE_FLAG_ALLOC_SINGLE_PAGES (1 << 1) + +#define DRM_IOCTL_MTK_GEM_CREATE DRM_IOWR(DRM_COMMAND_BASE + \ + DRM_MTK_GEM_CREATE, struct drm_mtk_gem_create) + +#define DRM_IOCTL_MTK_GEM_MAP_OFFSET DRM_IOWR(DRM_COMMAND_BASE + \ + DRM_MTK_GEM_MAP_OFFSET, struct drm_mtk_gem_map_off) + + +#endif /* _UAPI_MEDIATEK_DRM_H */ diff --git a/mediatek.c b/mediatek.c index e34f672..2310e88 100644 --- a/mediatek.c +++ b/mediatek.c @@ -20,7 +20,7 @@ #include #include #include -#include +#include "external/mediatek_drm.h" // clang-format on #include "drv_helpers.h"