aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMattijs Korpershoek <mkorpershoek@baylibre.com>2020-09-21 11:03:35 +0000
committerMattijs Korpershoek <mkorpershoek@baylibre.com>2020-09-23 10:22:23 +0200
commit5284c7e970a25dd6f80991672e51047c79811075 (patch)
tree9d8aa7675992721af1705f7b95e94b3ffd20d6ed
parent42c7f0c1b52fdda20ca142c8d3ef911b10783313 (diff)
downloaddrm_hwcomposer-5284c7e970a25dd6f80991672e51047c79811075.tar.gz
drm_hwcomposer: Add MediaTek platform support
This platform handler is dedicated for the i500 MediaTek SoC [1]. i500 has a Mali-G72 MP3 GPU. OpenGL/Mali integration is based on ARM Gralloc module, version BX304L01B-SW-99005-r20p0-01rel0, without additional patches. This platformmediatek is based on platformmeson, without the additional usage flag in the private_handle_t. AFBC support has also been removed as it's unsupported. External Android.bp file should be created in order to build this module: ``` cc_library_shared { name: "hwcomposer.drm_mediatek", defaults: ["hwcomposer.drm_defaults"], srcs: [":drm_hwcomposer_platformmediatek"], whole_static_libs: ["drm_hwcomposer"], } ``` [1] https://www.mediatek.com/products/AIoT/i500 Change-Id: I3ea7a980d76ba5c5ff583b5d4f21e1989875bafb Signed-off-by: Mattijs Korpershoek <mkorpershoek@baylibre.com>
-rw-r--r--Android.bp9
-rw-r--r--platform/platformmediatek.cpp71
-rw-r--r--platform/platformmediatek.h36
3 files changed, 116 insertions, 0 deletions
diff --git a/Android.bp b/Android.bp
index 4bd4586..fef3ed6 100644
--- a/Android.bp
+++ b/Android.bp
@@ -153,3 +153,12 @@ filegroup {
"platform/platformmeson.cpp",
],
}
+
+// Used by hwcomposer.drm_mediatek
+filegroup {
+ name: "drm_hwcomposer_platformmediatek",
+ srcs: [
+ "platform/platformdrmgeneric.cpp",
+ "platform/platformmediatek.cpp",
+ ],
+}
diff --git a/platform/platformmediatek.cpp b/platform/platformmediatek.cpp
new file mode 100644
index 0000000..bbf76ea
--- /dev/null
+++ b/platform/platformmediatek.cpp
@@ -0,0 +1,71 @@
+/*
+ * 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-platform-mediatek"
+
+#include "platformmediatek.h"
+
+#include <hardware/gralloc.h>
+#include <log/log.h>
+#include <stdatomic.h>
+#include <xf86drm.h>
+#include <xf86drmMode.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;
+
+ 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) {
+ private_handle_t const *hnd = reinterpret_cast<private_handle_t const *>(
+ handle);
+ if (!hnd)
+ return -EINVAL;
+
+ 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->pixel_stride = hnd->stride;
+ bo->prime_fds[0] = hnd->share_fd;
+ bo->pitches[0] = hnd->byte_stride;
+ bo->offsets[0] = 0;
+
+ return 0;
+}
+
+} // namespace android
diff --git a/platform/platformmediatek.h b/platform/platformmediatek.h
new file mode 100644
index 0000000..61fcf47
--- /dev/null
+++ b/platform/platformmediatek.h
@@ -0,0 +1,36 @@
+/*
+ * 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_PLATFORM_MTK_H_
+#define ANDROID_PLATFORM_MTK_H_
+
+#include <hardware/gralloc.h>
+#include <stdatomic.h>
+
+#include "platform.h"
+#include "platformdrmgeneric.h"
+
+namespace android {
+
+class MediatekImporter : public DrmGenericImporter {
+ public:
+ using DrmGenericImporter::DrmGenericImporter;
+
+ int ConvertBoInfo(buffer_handle_t handle, hwc_drm_bo_t *bo) override;
+};
+} // namespace android
+
+#endif