drm_hwcomposer: Changes to support HiKey/HiKey960
v2 cover drm_hwcomposer: Changes to support HiKey/HiKey960
Here is a second revision of the early RFC patch set I wanted to send out to get some review and feedback on.
I've been working to enable the drm_hwcomposer for HiKey and HiKey960 boards in AOSP, and this patchset contains the required changes to the drm_hwcomposer code to get things working.
I'm really quite naive when it comes to graphics, and I'm sure I don't fully understand the drm_hwcomposer code, so forgive me if I've done anything terribly stupid here.
The first two patches are, I think, mostly straightforward, the first being a bug fix, and the second adding an importer for the ARM gralloc implementations.
The next two patches, while largely reworked from v1, are still a bit iffy, and I'd appreciate guidance on how to improve them. The third forcing client composition if there is only one layer and the fourth providing a glFinish() fallback which fixes on-screen tearing when the gl compositior fails to initalize.
I also have two additional patches, which I've not included here - as they still need work, which get the glcompositor to properly function on HiKey960. But the curious can find them here:
https://github.com/johnstultz-work/drm_hwcomposer/commits/drm_hwc
If anyone wants to try the code out on either a HiKey or HiKey960, you will need just the 4 patches here on top of the freedesktop/master branch of drm_hwcomposer. You'll also need the freedesktop/master branch of libdrm. You'll need the following patches to the device/linaro/hikey project:
https://github.com/johnstultz-work/android_device_linaro_hikey/commits/drm_hwc
And you'll need to replace the kernel Image-dtb with one built from the following tree:
https://git.linaro.org/people/john.stultz/android-dev.git/log/?h=dev/hikey-hwcomposer-deps
Any thoughts or feedback will be very much appreciated!
Many thanks to Rob Herring and Matt Szczesiak for help to get this working so far! And Sean Paul for his recent help working out the crtc activiation bug.
Thanks so much for your time!
-john
John Stultz (4):
drm_hwcomposer: Make sure we set the active state when doing modesets
drm_hwcomposer: Add platformhisi buffer importer for hikey and
hikey960
drm_hwcomposer: Use client compositing if there is only one plane
drm_hwcomposer: Try to fallback if GLCompisition fails
Android.mk | 15 +++- drmdisplaycompositor.cpp | 11 +++ drmhwctwo.cpp | 7 ++ platformhisi.cpp | 200 +++++++++++++++++++++++++++++++++++++++++++++++ platformhisi.h | 50 ++++++++++++ 5 files changed, 282 insertions(+), 1 deletion(-) create mode 100644 platformhisi.cpp create mode 100644 platformhisi.h
Signature · 6 lines
2.7.4 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
RFC PATCH v2 1/4 drm_hwcomposer: Make sure we set the active state when doing modesets
In trying to use drm_hwcomposer with HiKey/HiKey960 boards, I found that the crtc wouldn't intitalize and the atomic commit calls were failing.
I initially chased this down to following check in the kernel drm_atomic_crtc_check() function failing:
if (state->event && !state->active && !crtc->state->active) {
DRM_DEBUG_ATOMIC("[CRTC:%d:%s] requesting event but off\n",
crtc->base.id, crtc->name);
return -EINVAL;}
Where because a fence was submitted state->event was set, but the crtc state was not active. This results in the atomic commit to fail and no mode to be set.
After hacking around this in the kernel, Sean Paul helped me understand that it was the kernel complaining about the crtc state being provided in the atomic commit which did not have the active flag set.
Thus, the proper fix is to make sure when we do the modesetting that we also set the crtc state active flag in property set.
With this change, the kernel no longer rejects the atomic commit and the crtc initializes properly.
--- drmdisplaycompositor.cpp | 7 +++++++ 1 file changed, 7 insertions(+)
drmdisplaycompositor.cpp +7 -0
@@ -520,6 +520,13 @@ int DrmDisplayCompositor::CommitFrame(DrmDisplayComposition *display_comp, } if (mode_.needs_modeset) { + ret = drmModeAtomicAddProperty(pset, crtc->id(), crtc->active_property().id(), 1); + if (ret < 0) { + ALOGE("Failed to add crtc active to pset\n"); + drmModeAtomicFree(pset); + return ret; + } + ret = drmModeAtomicAddProperty(pset, crtc->id(), crtc->mode_property().id(), mode_.blob_id) < 0 || drmModeAtomicAddProperty(pset, connector->id(),
Signature · 6 lines
2.7.4 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Sean Paul
AppliedRe: [RFC][PATCH 1/4 v2] drm_hwcomposer: Make sure we set the active state when doing modesets
Quoted 28 lines · John Stultz
In trying to use
drm_hwcomposerwith HiKey/HiKey960 boards, I found that the crtc wouldn't intitalize and the atomic commit calls were failing.I initially chased this down to following check in the kernel
drm_atomic_crtc_check()function failing:if (state->event && !state->active && !crtc->state->active) { DRM_DEBUG_ATOMIC("[CRTC:%d:%s] requesting event but off\n", crtc->base.id, crtc->name); return -EINVAL;}
Where because a fence was submitted
state->eventwas set, but the crtc state was not active. This results in the atomic commit to fail and no mode to be set.After hacking around this in the kernel, Sean Paul helped me understand that it was the kernel complaining about the crtc state being provided in the atomic commit which did not have the active flag set.
Thus, the proper fix is to make sure when we do the modesetting that we also set the crtc state active flag in property set.
With this change, the kernel no longer rejects the atomic commit and the crtc initializes properly.
Quoted 9 lines
Cc Marissa Wall <[email protected]>Cc Sean Paul <[email protected]>Cc Dmitry Shmidt <[email protected]>Cc Robert Foss <[email protected]>Cc Matt Szczesiak <[email protected]>Cc Liviu Dudau <[email protected]>Cc David Hanna <[email protected]>Cc Rob Herring <[email protected]>Signed-off-by John Stultz <[email protected]>
Applied.
Thanks for the patch!
Sean
Quoted 25 lines
--- drmdisplaycompositor.cpp | 7 +++++++ 1 file changed, 7 insertions(+)drmdisplaycompositor.cpp +7
-0@@ -520,6 +520,13 @@ int DrmDisplayCompositor::CommitFrame(DrmDisplayComposition *display_comp, } if (mode_.needs_modeset) { + ret = drmModeAtomicAddProperty(pset, crtc->id(), crtc->active_property().id(), 1); + if (ret < 0) { + ALOGE("Failed to add crtc active to pset\n"); + drmModeAtomicFree(pset); + return ret; + } + ret = drmModeAtomicAddProperty(pset, crtc->id(), crtc->mode_property().id(), mode_.blob_id) < 0 || drmModeAtomicAddProperty(pset, connector->id(),Signature · 1 line
2.7.4
Signature · 5 lines
Sean Paul, Software Engineer, Google / Chromium OS _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
RFC PATCH v2 2/4 drm_hwcomposer: Add platformhisi buffer importer for hikey and hikey960
In reply to John StultzThis allows for importing buffers allocated from the hikey and hikey960 gralloc implelementations.
---
v2:
* Make platformhisi and the generic importer exclusive in the build
* Fixup vendor check
--- Android.mk | 15 ++++- platformhisi.cpp | 200 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ platformhisi.h | 50 ++++++++++++++ 3 files changed, 264 insertions(+), 1 deletion(-) create mode 100644 platformhisi.cpp create mode 100644 platformhisi.h
Android.mk +14 -1
@@ -66,7 +66,6 @@ LOCAL_SRC_FILES := \ glworker.cpp \ hwcutils.cpp \ platform.cpp \ - platformdrmgeneric.cpp \ separate_rects.cpp \ virtualcompositorworker.cpp \ vsyncworker.cpp
@@ -75,7 +74,21 @@ LOCAL_CPPFLAGS += \ -DHWC2_USE_CPP11 \ -DHWC2_INCLUDE_STRINGIFICATION + +ifeq ($(TARGET_PRODUCT),hikey960) +LOCAL_CPPFLAGS += -DUSE_HISI_IMPORTER +LOCAL_C_INCLUDES += device/linaro/hikey/gralloc960/ +LOCAL_SRC_FILES += platformhisi.cpp +else +ifeq ($(TARGET_PRODUCT),hikey) +LOCAL_CPPFLAGS += -DUSE_HISI_IMPORTER -DHIKEY +LOCAL_C_INCLUDES += device/linaro/hikey/gralloc/ +LOCAL_SRC_FILES += platformhisi.cpp +else LOCAL_CPPFLAGS += -DUSE_DRM_GENERIC_IMPORTER +LOCAL_SRC_FILES += platformdrmgeneric.cpp +endif +endif LOCAL_MODULE := hwcomposer.drm LOCAL_MODULE_TAGS := optional
platformhisi.cpp new file +200 -0
200 lines not on this page · raw message
platformhisi.h new file +50 -0
50 lines not on this page · raw message
Signature · 6 lines
2.7.4 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [RFC][PATCH 2/4 v2] drm_hwcomposer: Add platformhisi buffer importer for hikey and hikey960
Quoted 12 lines · John Stultz
This allows for importing buffers allocated from the hikey and hikey960 gralloc implelementations.
Cc Marissa Wall <[email protected]>Cc Sean Paul <[email protected]>Cc Dmitry Shmidt <[email protected]>Cc Robert Foss <[email protected]>Cc Matt Szczesiak <[email protected]>Cc Liviu Dudau <[email protected]>Cc David Hanna <[email protected]>Cc Rob Herring <[email protected]>Signed-off-by John Stultz <[email protected]>
Quoted 3 lines
---
v2:
* Make platformhisi and the generic importer exclusive in the build
I actually prefer the opposite. If everything is always compiled, we reduce the chance of breaking boards when the base class is updated. I'm sure there is a good reason for this, but perhaps there's another way?
Sean
Quoted 308 lines
* Fixup vendor check
--- Android.mk | 15 ++++- platformhisi.cpp | 200 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ platformhisi.h | 50 ++++++++++++++ 3 files changed, 264 insertions(+), 1 deletion(-) create mode 100644 platformhisi.cpp create mode 100644 platformhisi.hAndroid.mk +14
-1@@ -66,7 +66,6 @@ LOCAL_SRC_FILES := \ glworker.cpp \ hwcutils.cpp \ platform.cpp \ - platformdrmgeneric.cpp \ separate_rects.cpp \ virtualcompositorworker.cpp \ vsyncworker.cpp@@ -75,7 +74,21 @@ LOCAL_CPPFLAGS += \ -DHWC2_USE_CPP11 \ -DHWC2_INCLUDE_STRINGIFICATION + +ifeq ($(TARGET_PRODUCT),hikey960) +LOCAL_CPPFLAGS += -DUSE_HISI_IMPORTER +LOCAL_C_INCLUDES += device/linaro/hikey/gralloc960/ +LOCAL_SRC_FILES += platformhisi.cpp +else +ifeq ($(TARGET_PRODUCT),hikey) +LOCAL_CPPFLAGS += -DUSE_HISI_IMPORTER -DHIKEY +LOCAL_C_INCLUDES += device/linaro/hikey/gralloc/ +LOCAL_SRC_FILES += platformhisi.cpp +else LOCAL_CPPFLAGS += -DUSE_DRM_GENERIC_IMPORTER +LOCAL_SRC_FILES += platformdrmgeneric.cpp +endif +endif LOCAL_MODULE := hwcomposer.drm LOCAL_MODULE_TAGS := optionalplatformhisi.cpp new file +200
-0@@ -0,0 +1,200 @@ +/* + * Copyright (C) 2015 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-hisi" + +#include "drmresources.h" +#include "platform.h" +#include "platformhisi.h" + + +#include <drm/drm_fourcc.h> +#include <cinttypes> +#include <stdatomic.h> +#include <xf86drm.h> +#include <xf86drmMode.h> + +#include <cutils/log.h> +#include <hardware/gralloc.h> +#include "gralloc_priv.h" + + +namespace android { + +#ifdef USE_HISI_IMPORTER +// static +Importer *Importer::CreateInstance(DrmResources *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; +} +#endif + +HisiImporter::HisiImporter(DrmResources *drm) : drm_(drm) { +} + +HisiImporter::~HisiImporter() { +} + +int HisiImporter::Init() { + int ret = hw_get_module(GRALLOC_HARDWARE_MODULE_ID, + (const hw_module_t **)&gralloc_); + if (ret) { + ALOGE("Failed to open gralloc module %d", ret); + return ret; + } + + if (strcasecmp(gralloc_->common.author, "ARM Ltd.")) + ALOGW("Using non-ARM gralloc module: %s/%s\n", gralloc_->common.name, + gralloc_->common.author); + + return 0; +} + +#ifdef HIKEY +uint32_t HisiImporter::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 -EINVAL; + } +} +#else /* HIKEY960 case*/ +uint32_t HisiImporter::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_XBGR8888; + case HAL_PIXEL_FORMAT_RGBX_8888: + return DRM_FORMAT_XBGR8888; + case HAL_PIXEL_FORMAT_RGBA_8888: + return DRM_FORMAT_XBGR8888; + 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 -EINVAL; + } +} +#endif /* HIKEY */ + +EGLImageKHR HisiImporter::ImportImage(EGLDisplay egl_display, buffer_handle_t handle) { + private_handle_t const *hnd = reinterpret_cast < private_handle_t const *>(handle); + if (!hnd) + return NULL; + EGLint attr[] = { + EGL_WIDTH, hnd->width, + EGL_HEIGHT, hnd->height, + EGL_LINUX_DRM_FOURCC_EXT, (EGLint)ConvertHalFormatToDrm(hnd->req_format), + EGL_DMA_BUF_PLANE0_FD_EXT, hnd->share_fd, + EGL_DMA_BUF_PLANE0_OFFSET_EXT, 0, + EGL_DMA_BUF_PLANE0_PITCH_EXT, hnd->byte_stride, + EGL_NONE, + }; + return eglCreateImageKHR(egl_display, EGL_NO_CONTEXT, EGL_LINUX_DMA_BUF_EXT, NULL, attr); +} + +int HisiImporter::ImportBuffer(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 gem_handle; + int ret = drmPrimeFDToHandle(drm_->fd(), hnd->share_fd, &gem_handle); + if (ret) { + ALOGE("failed to import prime fd %d ret=%d", hnd->share_fd, ret); + return ret; + } + + memset(bo, 0, sizeof(hwc_drm_bo_t)); + bo->width = hnd->width; + bo->height = hnd->height; + bo->format = ConvertHalFormatToDrm(hnd->req_format); + bo->usage = hnd->usage; +#ifdef HIKEY + bo->pitches[0] = hnd->width * 4; +#else + bo->pitches[0] = hnd->byte_stride; +#endif + bo->gem_handles[0] = gem_handle; + bo->offsets[0] = 0; + + ret = drmModeAddFB2(drm_->fd(), bo->width, bo->height, bo->format, + bo->gem_handles, bo->pitches, bo->offsets, &bo->fb_id, 0); + if (ret) { + ALOGE("could not create drm fb %d", ret); + return ret; + } + + return ret; +} + +int HisiImporter::ReleaseBuffer(hwc_drm_bo_t *bo) { + if (bo->fb_id) + if (drmModeRmFB(drm_->fd(), bo->fb_id)) + ALOGE("Failed to rm fb"); + + struct drm_gem_close gem_close; + memset(&gem_close, 0, sizeof(gem_close)); + int num_gem_handles = sizeof(bo->gem_handles) / sizeof(bo->gem_handles[0]); + for (int i = 0; i < num_gem_handles; i++) { + if (!bo->gem_handles[i]) + continue; + + gem_close.handle = bo->gem_handles[i]; + int ret = drmIoctl(drm_->fd(), DRM_IOCTL_GEM_CLOSE, &gem_close); + if (ret) + ALOGE("Failed to close gem handle %d %d", i, ret); + else + bo->gem_handles[i] = 0; + } + return 0; +} + +#ifdef USE_HISI_IMPORTER +std::unique_ptr<Planner> Planner::CreateInstance(DrmResources *) { + std::unique_ptr<Planner> planner(new Planner); + planner->AddStage<PlanStageGreedy>(); + return planner; +} +#endif + +} + +platformhisi.h new file +50
-0@@ -0,0 +1,50 @@ +/* +* Copyright (C) 2015 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_HISI_H_ +#define ANDROID_PLATFORM_HISI_H_ + +#include "drmresources.h" +#include "platform.h" +#include "platformdrmgeneric.h" + +#include <stdatomic.h> + +#include <hardware/gralloc.h> + +namespace android { + +class HisiImporter : public Importer { + public: +HisiImporter (DrmResources *drm); + ~HisiImporter() override; + +int Init (); + + EGLImageKHR ImportImage(EGLDisplay egl_display, buffer_handle_t handle) override; + int ImportBuffer(buffer_handle_t handle, hwc_drm_bo_t *bo) override; + int ReleaseBuffer(hwc_drm_bo_t *bo) override; + + private: +uint32_t ConvertHalFormatToDrm (uint32_t hal_format); + +DrmResources *drm_; + +const gralloc_module_t *gralloc_; +}; +} + +#endif Signature · 1 line
2.7.4
Signature · 5 lines
Sean Paul, Software Engineer, Google / Chromium OS _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [RFC][PATCH 2/4 v2] drm_hwcomposer: Add platformhisi buffer importer for hikey and hikey960
Quoted 17 lines · Sean Paul
Quoted 12 lines · John Stultz
This allows for importing buffers allocated from the hikey and hikey960 gralloc implelementations.
Cc Marissa Wall <[email protected]>Cc Sean Paul <[email protected]>Cc Dmitry Shmidt <[email protected]>Cc Robert Foss <[email protected]>Cc Matt Szczesiak <[email protected]>Cc Liviu Dudau <[email protected]>Cc David Hanna <[email protected]>Cc Rob Herring <[email protected]>Signed-off-by John Stultz <[email protected]>Quoted 3 lines
---
v2:
* Make platformhisi and the generic importer exclusive in the build
Quoted 3 lines
I actually prefer the opposite. If everything is always compiled, we reduce the chance of breaking boards when the base class is updated. I'm sure there is a good reason for this, but perhaps there's another way?
The main reason for this was avoiding the build breaking when "gralloc_priv.h" isn't supplied or present.
Similarly the current freedesktop/master code won't build in the Android environment as the platformdrmgeneric.cpp file depends on the gralloc_drm_handle.h, which doesn't exist.
Earlier to avoid this I had included Rob's "provide a common gralloc handle definition" patch, but build-conditionalizing the importers seemed like a sane solution.
I'm of course open to alternatives, but I'm not sure how to add the hisi importer and the drmgeneric one and keep things building without also adding copies of the various gralloc headers to the project as well.
thanks
-john
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [RFC][PATCH 2/4 v2] drm_hwcomposer: Add platformhisi buffer importer for hikey and hikey960
Quoted 22 lines · John Stultz
Quoted 17 lines · Sean Paul
Quoted 12 lines · John Stultz
This allows for importing buffers allocated from the hikey and hikey960 gralloc implelementations.
Cc Marissa Wall <[email protected]>Cc Sean Paul <[email protected]>Cc Dmitry Shmidt <[email protected]>Cc Robert Foss <[email protected]>Cc Matt Szczesiak <[email protected]>Cc Liviu Dudau <[email protected]>Cc David Hanna <[email protected]>Cc Rob Herring <[email protected]>Signed-off-by John Stultz <[email protected]>Quoted 3 lines
---
v2:
* Make platformhisi and the generic importer exclusive in the buildQuoted 3 lines
I actually prefer the opposite. If everything is always compiled, we reduce the chance of breaking boards when the base class is updated. I'm sure there is a good reason for this, but perhaps there's another way?
Quoted 6 lines
The main reason for this was avoiding the build breaking when "
gralloc_priv.h" isn't supplied or present.Similarly the current freedesktop/master code won't build in the Android environment as the platformdrmgeneric.cpp file depends on the
gralloc_drm_handle.h, which doesn't exist.
That will be fixed soon. We're moving the handle definition to libdrm.
The idea was to provide an accessor API to return all the data needed and then custom gralloc handle implementations can provide different accessor functions. This may be enough to get rid of different importers, but you still need some magic to pull in different implementations whether header inlines or library functions.
The intent was to not be runtime selected because there's only ever one handle implementation and we want to encourage converging on one handle implementation.
Quoted 8 lines
Earlier to avoid this I had included Rob's "provide a common gralloc handle definition" patch, but build-conditionalizing the importers seemed like a sane solution.
I'm of course open to alternatives, but I'm not sure how to add the hisi importer and the drmgeneric one and keep things building without also adding copies of the various gralloc headers to the project as well.
Sometimes just copying the headers is the easiest, but whomever maintains the original needs to know that to avoid breaking people. And you don't have control of that since this comes from ARM.
Rob
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [RFC][PATCH 2/4 v2] drm_hwcomposer: Add platformhisi buffer importer for hikey and hikey960
Quoted 23 lines · Rob Herring
Quoted 22 lines · John Stultz
Quoted 20 lines · Sean Paul
Quoted 12 lines · John Stultz
This allows for importing buffers allocated from the hikey and hikey960 gralloc implelementations.
Cc Marissa Wall <[email protected]>Cc Sean Paul <[email protected]>Cc Dmitry Shmidt <[email protected]>Cc Robert Foss <[email protected]>Cc Matt Szczesiak <[email protected]>Cc Liviu Dudau <[email protected]>Cc David Hanna <[email protected]>Cc Rob Herring <[email protected]>Signed-off-by John Stultz <[email protected]>Quoted 3 lines
---
v2:
* Make platformhisi and the generic importer exclusive in the buildI actually prefer the opposite. If everything is always compiled, we reduce the chance of breaking boards when the base class is updated. I'm sure there is a good reason for this, but perhaps there's another way?
Quoted 8 lines
Quoted 6 lines
The main reason for this was avoiding the build breaking when "
gralloc_priv.h" isn't supplied or present.Similarly the current freedesktop/master code won't build in the Android environment as the platformdrmgeneric.cpp file depends on the
gralloc_drm_handle.h, which doesn't exist.That will be fixed soon. We're moving the handle definition to libdrm.
How soon is that eta? Do you have a current patch for libdrm I should work against?
thanks
-john
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [RFC][PATCH 2/4 v2] drm_hwcomposer: Add platformhisi buffer importer for hikey and hikey960
Hey John,
Quoted 27 lines · John Stultz
Quoted 26 lines · Rob Herring
Quoted 25 lines · John Stultz
Quoted 17 lines · Sean Paul
Quoted 12 lines · John Stultz
This allows for importing buffers allocated from the hikey and hikey960 gralloc implelementations.
Cc Marissa Wall <[email protected]>Cc Sean Paul <[email protected]>Cc Dmitry Shmidt <[email protected]>Cc Robert Foss <[email protected]>Cc Matt Szczesiak <[email protected]>Cc Liviu Dudau <[email protected]>Cc David Hanna <[email protected]>Cc Rob Herring <[email protected]>Signed-off-by John Stultz <[email protected]>Quoted 3 lines
---
v2:
* Make platformhisi and the generic importer exclusive in the buildQuoted 3 lines
I actually prefer the opposite. If everything is always compiled, we reduce the chance of breaking boards when the base class is updated. I'm sure there is a good reason for this, but perhaps there's another way?
The main reason for this was avoiding the build breaking when "
gralloc_priv.h" isn't supplied or present.
Quoted 8 lines
Quoted 5 lines
Quoted 3 lines
Similarly the current freedesktop/master code won't build in the Android environment as the platformdrmgeneric.cpp file depends on the
gralloc_drm_handle.h, which doesn't exist.That will be fixed soon. We're moving the handle definition to libdrm.
How soon is that eta? Do you have a current patch for libdrm I should work against?
Currently it is a bit more up in the air than I was hoping for. I'll make another stab at it today :)
Rob.
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [RFC][PATCH 2/4 v2] drm_hwcomposer: Add platformhisi buffer importer for hikey and hikey960
In reply to John StultzQuoted 12 lines · John Stultz
This allows for importing buffers allocated from the hikey and hikey960 gralloc implelementations.
Cc Marissa Wall <[email protected]>Cc Sean Paul <[email protected]>Cc Dmitry Shmidt <[email protected]>Cc Robert Foss <[email protected]>Cc Matt Szczesiak <[email protected]>Cc Liviu Dudau <[email protected]>Cc David Hanna <[email protected]>Cc Rob Herring <[email protected]>Signed-off-by John Stultz <[email protected]>
Quoted 4 lines
---
v2:
* Make platformhisi and the generic importer exclusive in the build
* Fixup vendor check
Hi John,
Thanks for your patches, I have a few more comments on the code aside from the Makefile nit.
Quoted 131 lines
--- Android.mk | 15 ++++- platformhisi.cpp | 200 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ platformhisi.h | 50 ++++++++++++++ 3 files changed, 264 insertions(+), 1 deletion(-) create mode 100644 platformhisi.cpp create mode 100644 platformhisi.hAndroid.mk +14
-1@@ -66,7 +66,6 @@ LOCAL_SRC_FILES := \ glworker.cpp \ hwcutils.cpp \ platform.cpp \ - platformdrmgeneric.cpp \ separate_rects.cpp \ virtualcompositorworker.cpp \ vsyncworker.cpp@@ -75,7 +74,21 @@ LOCAL_CPPFLAGS += \ -DHWC2_USE_CPP11 \ -DHWC2_INCLUDE_STRINGIFICATION + +ifeq ($(TARGET_PRODUCT),hikey960) +LOCAL_CPPFLAGS += -DUSE_HISI_IMPORTER +LOCAL_C_INCLUDES += device/linaro/hikey/gralloc960/ +LOCAL_SRC_FILES += platformhisi.cpp +else +ifeq ($(TARGET_PRODUCT),hikey) +LOCAL_CPPFLAGS += -DUSE_HISI_IMPORTER -DHIKEY +LOCAL_C_INCLUDES += device/linaro/hikey/gralloc/ +LOCAL_SRC_FILES += platformhisi.cpp +else LOCAL_CPPFLAGS += -DUSE_DRM_GENERIC_IMPORTER +LOCAL_SRC_FILES += platformdrmgeneric.cpp +endif +endif LOCAL_MODULE := hwcomposer.drm LOCAL_MODULE_TAGS := optionalplatformhisi.cpp new file +83
-0@@ -0,0 +1,200 @@ +/* + * Copyright (C) 2015 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-hisi" + +#include "drmresources.h" +#include "platform.h" +#include "platformhisi.h" + + +#include <drm/drm_fourcc.h> +#include <cinttypes> +#include <stdatomic.h> +#include <xf86drm.h> +#include <xf86drmMode.h> + +#include <cutils/log.h> +#include <hardware/gralloc.h> +#include "gralloc_priv.h" + + +namespace android { + +#ifdef USE_HISI_IMPORTER +// static +Importer *Importer::CreateInstance(DrmResources *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; +} +#endif + +HisiImporter::HisiImporter(DrmResources *drm) : drm_(drm) { +} + +HisiImporter::~HisiImporter() { +} + +int HisiImporter::Init() { + int ret = hw_get_module(GRALLOC_HARDWARE_MODULE_ID, + (const hw_module_t **)&gralloc_); + if (ret) { + ALOGE("Failed to open gralloc module %d", ret); + return ret; + } + + if (strcasecmp(gralloc_->common.author, "ARM Ltd.")) + ALOGW("Using non-ARM gralloc module: %s/%s\n", gralloc_->common.name, + gralloc_->common.author); + + return 0; +} + +#ifdef HIKEY +uint32_t HisiImporter::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;
platformhisi.cpp line 93
Quoted 10 lines
platformhisi.cpp new file +10
-0+ 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 -EINVAL; + }
This is the same as the generic case, and below is a little confusing to me.
Quoted 10 lines
platformhisi.cpp new file +10
-0+} +#else /* HIKEY960 case*/ +uint32_t HisiImporter::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_XBGR8888; + case HAL_PIXEL_FORMAT_RGBX_8888: + return DRM_FORMAT_XBGR8888;
platformhisi.cpp line 113
Quoted 10 lines
platformhisi.cpp new file +10
-0+ case HAL_PIXEL_FORMAT_RGBA_8888: + return DRM_FORMAT_XBGR8888; + 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 -EINVAL; + }
So it seems like we're smashing a whole bunch of formats into XBGR8888 here, and I'm not sure how it'll work. If you look above, the primary difference between the HAL and drm formats is that the subpixels are reversed (ie: RGBA becomes ABGR). In this snippet, you've got BGRA->XBGR, does this actually work?
Furthermore, when I look at the kirin driver (I think that's what you use on hikey?), I see full support for all the above formats. So 2 questions:
1- Does this work as expected
2- Is there an opportunity to share code between platforms instead of copy-pasting this function over and over again? Perhaps each platform provides the formats they support and we have the base class do a mapping based on what is present?
Quoted 28 lines
platformhisi.cpp new file +28
-0+} +#endif /* HIKEY */ + +EGLImageKHR HisiImporter::ImportImage(EGLDisplay egl_display, buffer_handle_t handle) { + private_handle_t const *hnd = reinterpret_cast < private_handle_t const *>(handle); + if (!hnd) + return NULL; + EGLint attr[] = { + EGL_WIDTH, hnd->width, + EGL_HEIGHT, hnd->height, + EGL_LINUX_DRM_FOURCC_EXT, (EGLint)ConvertHalFormatToDrm(hnd->req_format), + EGL_DMA_BUF_PLANE0_FD_EXT, hnd->share_fd, + EGL_DMA_BUF_PLANE0_OFFSET_EXT, 0, + EGL_DMA_BUF_PLANE0_PITCH_EXT, hnd->byte_stride, + EGL_NONE, + }; + return eglCreateImageKHR(egl_display, EGL_NO_CONTEXT, EGL_LINUX_DMA_BUF_EXT, NULL, attr); +} + +int HisiImporter::ImportBuffer(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 gem_handle; + int ret = drmPrimeFDToHandle(drm_->fd(), hnd->share_fd, &gem_handle); + if (ret) { + ALOGE("failed to import prime fd %d ret=%d", hnd->share_fd, ret);
platformhisi.cpp line 151
Quoted 10 lines
platformhisi.cpp new file +10
-0+ return ret; + } + + memset(bo, 0, sizeof(hwc_drm_bo_t)); + bo->width = hnd->width; + bo->height = hnd->height; + bo->format = ConvertHalFormatToDrm(hnd->req_format); + bo->usage = hnd->usage; +#ifdef HIKEY + bo->pitches[0] = hnd->width * 4;
Does this work for formats that are not 32-bit?
Quoted 27 lines
platformhisi.cpp new file +27
-0+#else + bo->pitches[0] = hnd->byte_stride; +#endif + bo->gem_handles[0] = gem_handle; + bo->offsets[0] = 0; + + ret = drmModeAddFB2(drm_->fd(), bo->width, bo->height, bo->format, + bo->gem_handles, bo->pitches, bo->offsets, &bo->fb_id, 0); + if (ret) { + ALOGE("could not create drm fb %d", ret); + return ret; + } + + return ret; +} + +int HisiImporter::ReleaseBuffer(hwc_drm_bo_t *bo) { + if (bo->fb_id) + if (drmModeRmFB(drm_->fd(), bo->fb_id)) + ALOGE("Failed to rm fb"); + + struct drm_gem_close gem_close; + memset(&gem_close, 0, sizeof(gem_close)); + int num_gem_handles = sizeof(bo->gem_handles) / sizeof(bo->gem_handles[0]); + for (int i = 0; i < num_gem_handles; i++) { + if (!bo->gem_handles[i]) + continue;
platformhisi.cpp line 188
Quoted 10 lines
platformhisi.cpp new file +10
-0+ + gem_close.handle = bo->gem_handles[i]; + int ret = drmIoctl(drm_->fd(), DRM_IOCTL_GEM_CLOSE, &gem_close); + if (ret) + ALOGE("Failed to close gem handle %d %d", i, ret); + else + bo->gem_handles[i] = 0; + } + return 0; +}
This function is a straight copy-paste from generic, right? Let's try to do better than that. Perhaps you should be subclassing the drm generic platform instead?
Quoted 71 lines
platformhisi.cpp new file +12
-0+ +#ifdef USE_HISI_IMPORTER +std::unique_ptr<Planner> Planner::CreateInstance(DrmResources *) { + std::unique_ptr<Planner> planner(new Planner); + planner->AddStage<PlanStageGreedy>(); + return planner; +} +#endif + +} + +platformhisi.h new file +50
-0@@ -0,0 +1,50 @@ +/* +* Copyright (C) 2015 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_HISI_H_ +#define ANDROID_PLATFORM_HISI_H_ + +#include "drmresources.h" +#include "platform.h" +#include "platformdrmgeneric.h" + +#include <stdatomic.h> + +#include <hardware/gralloc.h> + +namespace android { + +class HisiImporter : public Importer { + public: +HisiImporter (DrmResources *drm); + ~HisiImporter() override; + +int Init (); + + EGLImageKHR ImportImage(EGLDisplay egl_display, buffer_handle_t handle) override; + int ImportBuffer(buffer_handle_t handle, hwc_drm_bo_t *bo) override; + int ReleaseBuffer(hwc_drm_bo_t *bo) override; + + private: +uint32_t ConvertHalFormatToDrm (uint32_t hal_format); + +DrmResources *drm_; + +const gralloc_module_t *gralloc_; +}; +} + +#endif Signature · 1 line
2.7.4
Signature · 5 lines
Sean Paul, Software Engineer, Google / Chromium OS _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [RFC][PATCH 2/4 v2] drm_hwcomposer: Add platformhisi buffer importer for hikey and hikey960
Quoted 14 lines · Sean Paul
Quoted 13 lines · John Stultz
platformhisi.cpp new file +13
-0+#ifdef HIKEY +uint32_t HisiImporter::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;
Quoted 8 lines
platformhisi.cpp line 93
Quoted 6 lines
platformhisi.cpp new file +6
-0+ case HAL_PIXEL_FORMAT_YV12: + return DRM_FORMAT_YVU420; + default: + ALOGE("Cannot convert hal format to drm format %u", hal_format); + return -EINVAL; + }This is the same as the generic case, and below is a little confusing to me.
Yes. HiKey is the same as the generic case.
Quoted 17 lines
Quoted 17 lines
platformhisi.cpp new file +17
-0+} +#else /* HIKEY960 case*/ +uint32_t HisiImporter::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_XBGR8888; + case HAL_PIXEL_FORMAT_RGBX_8888: + return DRM_FORMAT_XBGR8888; + case HAL_PIXEL_FORMAT_RGBA_8888: + return DRM_FORMAT_XBGR8888; + case HAL_PIXEL_FORMAT_RGB_565: + return DRM_FORMAT_BGR565; + case HAL_PIXEL_FORMAT_YV12: + return DRM_FORMAT_YVU420; + default:
Quoted 8 lines
platformhisi.cpp line 93
Quoted 3 lines
platformhisi.cpp new file +3
-0+ ALOGE("Cannot convert hal format to drm format %u", hal_format); + return -EINVAL; + }So it seems like we're smashing a whole bunch of formats into XBGR8888 here, and I'm not sure how it'll work. If you look above, the primary difference between the HAL and drm formats is that the subpixels are reversed (ie: RGBA becomes ABGR). In this snippet, you've got
BGRA->XBGR, does this actually work?
Honestly the above is some sort of dyslexia nightmare for me, so I may have gotten it slightly wrong. :)
So my understanding is that for the HiKey960/bifrost the As need to be Xs (and I've verified that we don't get anything if we try to leave the X's), and we have to switch the R/Bs to get the colors right. It may be the R/B switching is due to other quirks in gralloc and the drm driver, I'm not sure.
Quoted 2 lines
Furthermore, when I look at the kirin driver (I think that's what you use on hikey?), I see full support for all the above formats. So 2 questions:
So, on HiKey960 we have the out-of-tree kirin960 drm driver, which is one of those vendor code drops that is similar but different enough that its a pain to whittle down if extending the kirin driver can be done to support it, I've not been involved in the upstreaming effort for that driver, so I'm not sure what the plan is yet.
Quoted 1 line
1- Does this work as expected
So yes, the code here does work. But we're only exercising the BGRA_8888 path, so the rest could very well be wrong.
Quoted 4 lines
2- Is there an opportunity to share code between platforms instead of copy-pasting this function over and over again? Perhaps each platform provides the formats they support and we have the base class do a mapping based on what is present?
My C++ is ~20 years stale, but I'll take a look to see what I can do there.
Quoted 4 lines
platformhisi.cpp line 151
Quoted 2 lines
platformhisi.cpp new file +2
-0+#ifdef HIKEY + bo->pitches[0] = hnd->width * 4;Does this work for formats that are not 32-bit?
Probably not. I'll try to sort that out in a better way too.
Quoted 17 lines
Quoted 17 lines
platformhisi.cpp new file +17
-0+int HisiImporter::ReleaseBuffer(hwc_drm_bo_t *bo) { + if (bo->fb_id) + if (drmModeRmFB(drm_->fd(), bo->fb_id)) + ALOGE("Failed to rm fb"); + + struct drm_gem_close gem_close; + memset(&gem_close, 0, sizeof(gem_close)); + int num_gem_handles = sizeof(bo->gem_handles) / sizeof(bo->gem_handles[0]); + for (int i = 0; i < num_gem_handles; i++) { + if (!bo->gem_handles[i]) + continue; + + gem_close.handle = bo->gem_handles[i]; + int ret = drmIoctl(drm_->fd(), DRM_IOCTL_GEM_CLOSE, &gem_close); + if (ret) + ALOGE("Failed to close gem handle %d %d", i, ret); + else
Quoted 8 lines
platformhisi.cpp line 188
Quoted 4 lines
platformhisi.cpp new file +4
-0+ bo->gem_handles[i] = 0; + } + return 0; +}This function is a straight copy-paste from generic, right? Let's try to do better than that. Perhaps you should be subclassing the drm generic platform instead?
Apologies, my sense of taste here is terrible. Do you recommend I try to subclass the drmgenericplatform or create a common base that both use (along with the format bits)?
thanks
-john
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [RFC][PATCH 2/4 v2] drm_hwcomposer: Add platformhisi buffer importer for hikey and hikey960
Quoted 52 lines · John Stultz
Quoted 14 lines · Sean Paul
Quoted 13 lines · John Stultz
platformhisi.cpp new file +13
-0+#ifdef HIKEY +uint32_t HisiImporter::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;Quoted 8 lines
platformhisi.cpp line 93
Quoted 6 lines
platformhisi.cpp new file +6
-0+ case HAL_PIXEL_FORMAT_YV12: + return DRM_FORMAT_YVU420; + default: + ALOGE("Cannot convert hal format to drm format %u", hal_format); + return -EINVAL; + }This is the same as the generic case, and below is a little confusing to me.
Yes. HiKey is the same as the generic case.
Quoted 17 lines
Quoted 17 lines
platformhisi.cpp new file +17
-0+} +#else /* HIKEY960 case*/ +uint32_t HisiImporter::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_XBGR8888; + case HAL_PIXEL_FORMAT_RGBX_8888: + return DRM_FORMAT_XBGR8888; + case HAL_PIXEL_FORMAT_RGBA_8888: + return DRM_FORMAT_XBGR8888; + case HAL_PIXEL_FORMAT_RGB_565: + return DRM_FORMAT_BGR565; + case HAL_PIXEL_FORMAT_YV12: + return DRM_FORMAT_YVU420; + default:Quoted 8 lines
platformhisi.cpp line 93
Quoted 3 lines
platformhisi.cpp new file +3
-0+ ALOGE("Cannot convert hal format to drm format %u", hal_format); + return -EINVAL; + }So it seems like we're smashing a whole bunch of formats into XBGR8888 here, and I'm not sure how it'll work. If you look above, the primary difference between the HAL and drm formats is that the subpixels are reversed (ie: RGBA becomes ABGR). In this snippet, you've got
BGRA->XBGR, does this actually work?
Quoted 3 lines
Honestly the above is some sort of dyslexia nightmare for me, so I may have gotten it slightly wrong. :)
I can certainly sympathize with this. It took me longer than I'd like to admit to write the above. This seems like a good reason to change things up!
Quoted 5 lines
So my understanding is that for the HiKey960/bifrost the As need to be Xs (and I've verified that we don't get anything if we try to leave the X's), and we have to switch the R/Bs to get the colors right. It may be the R/B switching is due to other quirks in gralloc and the drm driver, I'm not sure.
It'd be nice to figure out. I suspect there's a bug somewhere that's re- reversing things.
Quoted 57 lines
Quoted 3 lines
Furthermore, when I look at the kirin driver (I think that's what you use on hikey?), I see full support for all the above formats. So 2 questions:
So, on HiKey960 we have the out-of-tree kirin960 drm driver, which is one of those vendor code drops that is similar but different enough that its a pain to whittle down if extending the kirin driver can be done to support it, I've not been involved in the upstreaming effort for that driver, so I'm not sure what the plan is yet.
Quoted 1 line
1- Does this work as expected
So yes, the code here does work. But we're only exercising the
BGRA_8888path, so the rest could very well be wrong.Quoted 4 lines
2- Is there an opportunity to share code between platforms instead of copy-pasting this function over and over again? Perhaps each platform provides the formats they support and we have the base class do a mapping based on what is present?
My C++ is ~20 years stale, but I'll take a look to see what I can do there.
Quoted 4 lines
platformhisi.cpp line 151
Quoted 2 lines
platformhisi.cpp new file +2
-0+#ifdef HIKEY + bo->pitches[0] = hnd->width * 4;Does this work for formats that are not 32-bit?
Probably not. I'll try to sort that out in a better way too.
Quoted 17 lines
Quoted 17 lines
platformhisi.cpp new file +17
-0+int HisiImporter::ReleaseBuffer(hwc_drm_bo_t *bo) { + if (bo->fb_id) + if (drmModeRmFB(drm_->fd(), bo->fb_id)) + ALOGE("Failed to rm fb"); + + struct drm_gem_close gem_close; + memset(&gem_close, 0, sizeof(gem_close)); + int num_gem_handles = sizeof(bo->gem_handles) / sizeof(bo->gem_handles[0]); + for (int i = 0; i < num_gem_handles; i++) { + if (!bo->gem_handles[i]) + continue; + + gem_close.handle = bo->gem_handles[i]; + int ret = drmIoctl(drm_->fd(), DRM_IOCTL_GEM_CLOSE, &gem_close); + if (ret) + ALOGE("Failed to close gem handle %d %d", i, ret); + elseQuoted 8 lines
platformhisi.cpp line 188
Quoted 4 lines
platformhisi.cpp new file +4
-0+ bo->gem_handles[i] = 0; + } + return 0; +}This function is a straight copy-paste from generic, right? Let's try to do better than that. Perhaps you should be subclassing the drm generic platform instead?
Quoted 3 lines
Apologies, my sense of taste here is terrible. Do you recommend I try to subclass the drmgenericplatform or create a common base that both use (along with the format bits)?
I think it makes sense to subclass DrmGenericPlatform, since there are minimal differences. Ideally we wouldn't need any subclass, but tbh I haven't dug into the differences enough to have a strong opinion on that.
For the format conversion function, given that the only difference is s/A/X/, we can probably keep everything in drmgeneric (assuming you fix the format issue mentioned above).
I'm thinking you add a member to DrmGenericPlatform called _has_alpha. If the platform has alpha, this is set to true when the object is initialized. If _has_alpha is true in CovertFormat you use the 'A' variants. If not, use 'X'.
I haven't put the Import functions side-by-side, but perhaps you can share some code between them similar to above?
Sean
Quoted 3 lines
thanks
-john
Signature · 5 lines
Sean Paul, Software Engineer, Google / Chromium OS _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [RFC][PATCH 2/4 v2] drm_hwcomposer: Add platformhisi buffer importer for hikey and hikey960
Quoted 37 lines · Sean Paul
Quoted 28 lines · John Stultz
Quoted 18 lines · Sean Paul
Quoted 17 lines · John Stultz
platformhisi.cpp new file +17
-0+} +#else /* HIKEY960 case*/ +uint32_t HisiImporter::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_XBGR8888; + case HAL_PIXEL_FORMAT_RGBX_8888: + return DRM_FORMAT_XBGR8888; + case HAL_PIXEL_FORMAT_RGBA_8888: + return DRM_FORMAT_XBGR8888; + case HAL_PIXEL_FORMAT_RGB_565: + return DRM_FORMAT_BGR565; + case HAL_PIXEL_FORMAT_YV12: + return DRM_FORMAT_YVU420; + default:Quoted 8 lines
platformhisi.cpp line 93
Quoted 3 lines
platformhisi.cpp new file +3
-0+ ALOGE("Cannot convert hal format to drm format %u", hal_format); + return -EINVAL; + }So it seems like we're smashing a whole bunch of formats into XBGR8888 here, and I'm not sure how it'll work. If you look above, the primary difference between the HAL and drm formats is that the subpixels are reversed (ie: RGBA becomes ABGR). In this snippet, you've got
BGRA->XBGR, does this actually work?Quoted 3 lines
Honestly the above is some sort of dyslexia nightmare for me, so I may have gotten it slightly wrong. :)
I can certainly sympathize with this. It took me longer than I'd like to admit to write the above. This seems like a good reason to change things up!
Quoted 8 lines
Quoted 5 lines
So my understanding is that for the HiKey960/bifrost the As need to be Xs (and I've verified that we don't get anything if we try to leave the X's), and we have to switch the R/Bs to get the colors right. It may be the R/B switching is due to other quirks in gralloc and the drm driver, I'm not sure.
It'd be nice to figure out. I suspect there's a bug somewhere that's re- reversing things.
Yea, I've been digging in and it looks like we can get rid of the special case conversion by adding DRM_FORMAT_ARGB8888 entries to the kirin960 drm driver.
So that part seems to be easy to simplify out. I'll continue trying to sort out the rest of your feedback.
thanks
-john
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
RFC PATCH v2 3/4 drm_hwcomposer: Use client compositing if there is only one plane
In reply to John StultzOriginally based on work by Rob Herring, this patch changes ValidateDisplay() so that if there is only one plane, we modify Device composited layers to be Client composited.
Without this, on devices with just one plane, nothing gets displayed on the screen.
Suggestions for alternative solutions here would be greatly appreciated!
---
v2:
* Rework Rob's change to check planes
--- drmhwctwo.cpp | 7 +++++++ 1 file changed, 7 insertions(+)
drmhwctwo.cpp +7 -0
@@ -695,6 +695,13 @@ HWC2::Error DrmHwcTwo::HwcDisplay::ValidateDisplay(uint32_t *num_types, layer.set_validated_type(HWC2::Composition::Client); ++*num_types; break; + case HWC2::Composition::Device: + /* If we only have one plane, always do Client composition */ + if (primary_planes_.size() + overlay_planes_.size() == 1) { + layer.set_validated_type(HWC2::Composition::Client); + ++*num_types; + break; + } default: layer.set_validated_type(layer.sf_type()); break;
Signature · 6 lines
2.7.4 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [RFC][PATCH 3/4 v2] drm_hwcomposer: Use client compositing if there is only one plane
Quoted 31 lines · John Stultz
Originally based on work by Rob Herring, this patch changes
ValidateDisplay()so that if there is only one plane, we modify Device composited layers to be Client composited.Without this, on devices with just one plane, nothing gets displayed on the screen.
Suggestions for alternative solutions here would be greatly appreciated!
Cc Marissa Wall <[email protected]>Cc Sean Paul <[email protected]>Cc Dmitry Shmidt <[email protected]>Cc Robert Foss <[email protected]>Cc Matt Szczesiak <[email protected]>Cc Liviu Dudau <[email protected]>Cc David Hanna <[email protected]>Cc Rob Herring <[email protected]>Signed-off-by John Stultz <[email protected]>---
v2:
* Rework Rob's change to check planes--- drmhwctwo.cpp | 7 +++++++ 1 file changed, 7 insertions(+)drmhwctwo.cpp +0
-0
drmhwctwo.cpp HWC2::Error DrmHwcTwo::HwcDisplay::ValidateDisplay(uint32_t *num_types, · line 704
Quoted 10 lines
drmhwctwo.cpp +7
-0@@ -695,6 +695,13 @@ HWC2::Error DrmHwcTwo::HwcDisplay::ValidateDisplay(uint32_t *num_types, layer.set_validated_type(HWC2::Composition::Client); ++*num_types; break; + case HWC2::Composition::Device: + /* If we only have one plane, always do Client composition */ + if (primary_planes_.size() + overlay_planes_.size() == 1) { + layer.set_validated_type(HWC2::Composition::Client); + ++*num_types; + break; + }
This needs to be conditional on GL compositing being disabled (either thru init failure or a property flag). Also, this can be generalized to use as many planes as we have. Something like the following patch.
BTW, "gl_enabled" doesn't exist. I left that for you to figure out how to set and propagate.
drmhwctwo.cpp +0 -0
@@ -684,6 +684,8 @@ HWC2::Error
DrmHwcTwo::HwcDisplay::SetVsyncEnabled(int32_t enabled) {
HWC2::Error DrmHwcTwo::HwcDisplay::ValidateDisplay(uint32_t *num_types,
uint32_t *num_requests) { supported(__func__);
+ int planes = primary_planes_.size() + overlay_planes_.size(); +
*num_types = 0;
*num_requests = 0;
for (std::pair<const hwc2_layer_t, DrmHwcTwo::HwcLayer> &l : layers_) {
@@ -696,7 +698,12 @@ HWC2::Error DrmHwcTwo::HwcDisplay::ValidateDisplay(uint32_t *num_types,
++*num_types;
break;
default:- layer.set_validated_type(layer.sf_type());
+ if (--planes > 0 || gl_enabled) {
+ layer.set_validated_type(layer.sf_type());
+ } else {
+ layer.set_validated_type(HWC2::Composition::Client);
+ ++*num_types;
+ }
break;
} }
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
RFC PATCH v2 4/4 drm_hwcomposer: Try to fallback if GLCompisition fails
In reply to John StultzWhen using drm_hwcomposer with the hikey board, the resulting display shows lots of tearing.
This seems to be due to EGLcomposition not initializing properly, potentially due to I'm guessing limitations of what the utgard mali driver can do. I've noted that with the HiKey960 board, this patch is *not* necessary.
Hacking around a bit, I found that since the glworker code isn't running properly, we never call glFinish(), which is required to fix the tearing.
Ideas for a better way to implement this would be greatly appreciated!
---
v2:
* Simplified, focusing on the key glFinsh() call
--- drmdisplaycompositor.cpp | 4 ++++ 1 file changed, 4 insertions(+)
drmdisplaycompositor.cpp +4 -0
@@ -439,6 +439,10 @@ int DrmDisplayCompositor::PrepareFrame(DrmDisplayComposition *display_comp) { fb.set_release_fence_fd(ret); ret = 0; + } else { + /*If we're not doing anything, block to avoid tearing */ + glFinish(); + return 0; } }
Signature · 6 lines
2.7.4 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [RFC][PATCH 4/4 v2] drm_hwcomposer: Try to fallback if GLCompisition fails
Quoted 8 lines · John Stultz
When using
drm_hwcomposerwith the hikey board, the resulting display shows lots of tearing.This seems to be due to EGLcomposition not initializing properly, potentially due to I'm guessing limitations of what the utgard mali driver can do. I've noted that with the HiKey960 board, this patch is *not* necessary.
Quoted 6 lines
Hacking around a bit, I found that since the glworker code isn't running properly, we never call
glFinish(), which is required to fix the tearing.Ideas for a better way to implement this would be greatly appreciated!
Sounds like you'll have to dig into the gl compositor to fix this. I think chances are quite good there's a better way than below.
Good luck!
Quoted 35 lines
Cc Marissa Wall <[email protected]>Cc Sean Paul <[email protected]>Cc Dmitry Shmidt <[email protected]>Cc Robert Foss <[email protected]>Cc Matt Szczesiak <[email protected]>Cc Liviu Dudau <[email protected]>Cc David Hanna <[email protected]>Cc Rob Herring <[email protected]>Signed-off-by John Stultz <[email protected]>---
v2:
* Simplified, focusing on the keyglFinsh()call--- drmdisplaycompositor.cpp | 4 ++++ 1 file changed, 4 insertions(+)drmdisplaycompositor.cpp +4
-0@@ -439,6 +439,10 @@ int DrmDisplayCompositor::PrepareFrame(DrmDisplayComposition *display_comp) { fb.set_release_fence_fd(ret); ret = 0; + } else { + /*If we're not doing anything, block to avoid tearing */ + glFinish(); + return 0; } }Signature · 1 line
2.7.4
Signature · 5 lines
Sean Paul, Software Engineer, Google / Chromium OS _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [RFC][PATCH 4/4 v2] drm_hwcomposer: Try to fallback if GLCompisition fails
Quoted 13 lines · Sean Paul
Quoted 12 lines · John Stultz
When using
drm_hwcomposerwith the hikey board, the resulting display shows lots of tearing.This seems to be due to EGLcomposition not initializing properly, potentially due to I'm guessing limitations of what the utgard mali driver can do. I've noted that with the HiKey960 board, this patch is *not* necessary.
Hacking around a bit, I found that since the glworker code isn't running properly, we never call
glFinish(), which is required to fix the tearing.
Quoted 5 lines
Quoted 2 lines
Ideas for a better way to implement this would be greatly appreciated!
Sounds like you'll have to dig into the gl compositor to fix this. I think chances are quite good there's a better way than below.
Yes, I did spent a little bit of time earlier trying to rewrite the gl shader to try to build for the utgard level hardware, but wasn't very successful. At a deeper level I guess I'm not sure the glcompositor is useful in this case, since we're doing single plane client side compositing (as short of the glFinish bit, not running it doesn't seem to keep things from working). But I'll look into that again.
Again forgive as I really a bit in the dark on most graphics details, but the other more basic question I'm a bit unsure of is, does this patch even make any functional sense? If we're not using the glcompositor and are using the atomic commit in ApplyFrame(), why the need for glFinish to avoid tearing? Is it that the we commit the frame atomically to the display, but if we don't block w/ glFinish() the gpu is still drawing into it? It seems we'd want a buffer specific fence to wait on rather then waiting for all gl calls to complete (if I'm understanding how glFinish() works).
Thanks again for your review feedback!
thanks
-john
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [RFC][PATCH 4/4 v2] drm_hwcomposer: Try to fallback if GLCompisition fails
Quoted 27 lines · John Stultz
Quoted 13 lines · Sean Paul
Quoted 12 lines · John Stultz
When using
drm_hwcomposerwith the hikey board, the resulting display shows lots of tearing.This seems to be due to EGLcomposition not initializing properly, potentially due to I'm guessing limitations of what the utgard mali driver can do. I've noted that with the HiKey960 board, this patch is *not* necessary.
Hacking around a bit, I found that since the glworker code isn't running properly, we never call
glFinish(), which is required to fix the tearing.Quoted 5 lines
Quoted 2 lines
Ideas for a better way to implement this would be greatly appreciated!
Sounds like you'll have to dig into the gl compositor to fix this. I think chances are quite good there's a better way than below.
Yes, I did spent a little bit of time earlier trying to rewrite the gl shader to try to build for the utgard level hardware, but wasn't very successful. At a deeper level I guess I'm not sure the glcompositor is useful in this case, since we're doing single plane client side compositing (as short of the glFinish bit, not running it doesn't seem to keep things from working). But I'll look into that again.
Quoted 3 lines
Again forgive as I really a bit in the dark on most graphics details, but the other more basic question I'm a bit unsure of is, does this patch even make any functional sense?
I'd think not. The only thing that makes me question that is I've seen glFinish calls in gralloc (framebuffer) cases. But those cases were prior to explicit fence support.
Quoted 7 lines
If we're not using the
glcompositor and are using the atomic commit inApplyFrame(), why the need for glFinish to avoid tearing? Is it that the we commit the frame atomically to the display, but if we don't block w/glFinish()the gpu is still drawing into it? It seems we'd want a buffer specific fence to wait on rather then waiting for all gl calls to complete (if I'm understanding howglFinish()works).
That seems like the right approach. Are we failing to pass fences associated with input layers to DRM?
Rob
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [RFC][PATCH 4/4 v2] drm_hwcomposer: Try to fallback if GLCompisition fails
Hi John,
I took your patches for a spin on Hikey960. Some findings:
Even with this patch I'm getting some tearing on Hikey960, not a lot as you reported on Hikey, still there are some small black squares, less than 10 of aproximetly 20x20.
So I investigated a little bit through drm_hwcomposer and found some issues, maybe they could help you somehow, see bellow:
Quoted 46 lines · Rob Herring
Quoted 29 lines · John Stultz
Quoted 15 lines · Sean Paul
Quoted 14 lines · John Stultz
When using
drm_hwcomposerwith the hikey board, the resulting display shows lots of tearing.This seems to be due to EGLcomposition not initializing properly, potentially due to I'm guessing limitations of what the utgard mali driver can do. I've noted that with the HiKey960 board, this patch is *not* necessary.
Hacking around a bit, I found that since the glworker code isn't running properly, we never call
glFinish(), which is required to fix the tearing.Quoted 5 lines
Quoted 2 lines
Ideas for a better way to implement this would be greatly appreciated!
Sounds like you'll have to dig into the gl compositor to fix this. I think chances are quite good there's a better way than below.
Yes, I did spent a little bit of time earlier trying to rewrite the gl shader to try to build for the utgard level hardware, but wasn't very successful. At a deeper level I guess I'm not sure the glcompositor is useful in this case, since we're doing single plane client side compositing (as short of the glFinish bit, not running it doesn't seem to keep things from working). But I'll look into that again.
Quoted 3 lines
Again forgive as I really a bit in the dark on most graphics details, but the other more basic question I'm a bit unsure of is, does this patch even make any functional sense?
I'd think not. The only thing that makes me question that is I've seen glFinish calls in gralloc (framebuffer) cases. But those cases were prior to explicit fence support.
Quoted 7 lines
If we're not using the
glcompositor and are using the atomic commit inApplyFrame(), why the need for glFinish to avoid tearing? Is it that the we commit the frame atomically to the display, but if we don't block w/glFinish()the gpu is still drawing into it? It seems we'd want a buffer specific fence to wait on rather then waiting for all gl calls to complete (if I'm understanding howglFinish()works).
Quoted 5 lines
That seems like the right approach. Are we failing to pass fences associated with input layers to DRM?
Rob
_______________________________________________
It seems that we don't pass any explicit fences to the kernel for IN_FENCE_FD property. This particular line seems wrong.
@@ -593,14 +594,17 @@ int DrmDisplayCompositor::CommitFrame(DrmDisplayComposition *display_comp,
else
rotation |= DRM_MODE_ROTATE_0;- if (fence_fd < 0) {
+ if (fence_fd >= 0) {
Also, if you track the value of the OUT_FENCE_PTR property, it seems that it gets lost. As far I was able to track it down it seem that it should have been used by AddFenceToRetireFence, and then be passed to SurfaceFlinger through retire_fence parameter of PresentDisplay. But, that doesn't happen because AddFenceToRetireFence get's called each time on a new DrmDisplayComposition object, before calling ApplyComposition.
Both of this findings should have explained the tearing, however I hacked something today and it didn't fix it for Hikey960, maybe you have more luck.
Thank you,
Alex Gheorghe
Quoted 3 lines
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
IMPORTANT NOTICE: The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium. Thank you.
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [RFC][PATCH 4/4 v2] drm_hwcomposer: Try to fallback if GLCompisition fails
Quoted 6 lines · Alexandru-Cosmin Gheorghe
Hi John,
I took your patches for a spin on Hikey960. Some findings:
Even with this patch I'm getting some tearing on Hikey960, not a lot as you reported on Hikey, still there are some small black squares, less than 10 of aproximetly 20x20.
Sweet! I'm glad you were able to get it up and running! I think the black squares are a separate thing, more on that below.
Quoted 2 lines
So I investigated a little bit through
drm_hwcomposerand found some issues, maybe they could help you somehow, see bellow:
Very much appreciate the extra review and eyes on the code!
Quoted 30 lines
Quoted 23 lines
Quoted 10 lines
Yes, I did spent a little bit of time earlier trying to rewrite the gl shader to try to build for the utgard level hardware, but wasn't very successful. At a deeper level I guess I'm not sure the glcompositor is useful in this case, since we're doing single plane client side compositing (as short of the glFinish bit, not running it doesn't seem to keep things from working). But I'll look into that again.
Again forgive as I really a bit in the dark on most graphics details, but the other more basic question I'm a bit unsure of is, does this patch even make any functional sense?
I'd think not. The only thing that makes me question that is I've seen glFinish calls in gralloc (framebuffer) cases. But those cases were prior to explicit fence support.
Quoted 7 lines
If we're not using the
glcompositor and are using the atomic commit inApplyFrame(), why the need for glFinish to avoid tearing? Is it that the we commit the frame atomically to the display, but if we don't block w/glFinish()the gpu is still drawing into it? It seems we'd want a buffer specific fence to wait on rather then waiting for all gl calls to complete (if I'm understanding howglFinish()works).Quoted 3 lines
That seems like the right approach. Are we failing to pass fences associated with input layers to DRM?
_______________________________________________It seems that we don't pass any explicit fences to the kernel for
IN_FENCE_FDproperty. This particular line seems wrong.
Review int · line 598
Quoted 6 lines
(quoted diff) +1
-1@@ -593,14 +594,17 @@ int DrmDisplayCompositor::CommitFrame(DrmDisplayComposition *display_comp, else rotation |= DRM_MODE_ROTATE_0; - if (fence_fd < 0) { + if (fence_fd >= 0) {
I'll give that a whirl.
Quoted 7 lines
Also, if you track the value of the
OUT_FENCE_PTRproperty, it seems that it gets lost. As far I was able to track it down it seem that it should have been used by AddFenceToRetireFence, and then be passed to SurfaceFlinger throughretire_fenceparameter of PresentDisplay. But, that doesn't happen because AddFenceToRetireFence get's called each time on a new DrmDisplayComposition object, before calling ApplyComposition.
I'll look into this some more as well. I've not yet gotten into the details of the fence handling in drm_hwcomposer yet, so I'll have to check that out.
Quoted 3 lines
Both of this findings should have explained the tearing, however I hacked something today and it didn't fix it for Hikey960, maybe you have more luck.
The issue with the black/grey blocks is a separate problem with the 4.9 based kernels that I'm still chasing down, we see it (though less often) w/o the hwcomposer, and I think it has to do with something off in the CMA allocations. We don't see it with the 4.4 or the 4.14 based tree i'm also prepping.
Thanks again for the feedback! I'm really happy to have your input here, so if you do generate any further changes, let me know and I'll try to integrate them into the patch set!
thanks
-john
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [RFC][PATCH 4/4 v2] drm_hwcomposer: Try to fallback if GLCompisition fails
Quoted 10 lines · John Stultz
Quoted 8 lines · Alexandru-Cosmin Gheorghe
It seems that we don't pass any explicit fences to the kernel for
IN_FENCE_FDproperty. This particular line seems wrong.(quoted diff) +0
-0@@ -593,14 +594,17 @@ int DrmDisplayCompositor::CommitFrame(DrmDisplayComposition *display_comp, else rotation |= DRM_MODE_ROTATE_0;
Quoted 4 lines
Review int · line 598
Quoted 2 lines
(quoted diff) +1
-1- if (fence_fd < 0) { + if (fence_fd >= 0) {I'll give that a whirl.
So I did give that a whirl after you suggested it, but it ended up causing nothing to be displayed, and I unfortunately didn't have time right then to dig much further.
Rob however re-found this issue today, and I've been digging a bit more. At least with the HiKey board, it seem the trouble is when the IN_FENCE_FD is added to the pset, the atomic commit calls start to fail. I dug in and it seems we're catching in the kernel on the if (file->f_op != &sync_file_fops) check in sync_file_fdget().
I'm now trying to trace back to where the in fence was provided from to see what might be going wrong there.
Curious if this is anything you ran across in your attempts?
thanks
-john
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [RFC][PATCH 4/4 v2] drm_hwcomposer: Try to fallback if GLCompisition fails
Quoted 20 lines · John Stultz
Quoted 10 lines · John Stultz
Quoted 8 lines · Alexandru-Cosmin Gheorghe
It seems that we don't pass any explicit fences to the kernel for
IN_FENCE_FDproperty. This particular line seems wrong.(quoted diff) +0
-0@@ -593,14 +594,17 @@ int DrmDisplayCompositor::CommitFrame(DrmDisplayComposition *display_comp, else rotation |= DRM_MODE_ROTATE_0;Quoted 4 lines
Review int · line 598
Quoted 2 lines
(quoted diff) +1
-1- if (fence_fd < 0) { + if (fence_fd >= 0) {I'll give that a whirl.
So I did give that a whirl after you suggested it, but it ended up causing nothing to be displayed, and I unfortunately didn't have time right then to dig much further.
Quoted 8 lines
Rob however re-found this issue today, and I've been digging a bit more. At least with the HiKey board, it seem the trouble is when the
IN_FENCE_FDis added to the pset, the atomic commit calls start to fail. I dug in and it seems we're catching in the kernel on the if (file->f_op!=&sync_file_fops) check insync_file_fdget().I'm now trying to trace back to where the in fence was provided from to see what might be going wrong there.
I would be surprised if this fence is not created by the GPU driver. But, the whole Android stack is new to me, so I might be wrong.
Quoted 2 lines
Curious if this is anything you ran across in your attempts?
Sorry, on Hikey960, I don't have this problem. Are you using the same 4.9 kernel from your branch(hikey-hwcomposer-deps)?
Quoted 3 lines
thanks
-john
Regards,
Alex Gheorghe
IMPORTANT NOTICE: The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium. Thank you.
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [RFC][PATCH 4/4 v2] drm_hwcomposer: Try to fallback if GLCompisition fails
Quoted 27 lines · Alexandru-Cosmin Gheorghe
Quoted 26 lines · John Stultz
Quoted 10 lines · John Stultz
Quoted 8 lines · Alexandru-Cosmin Gheorghe
It seems that we don't pass any explicit fences to the kernel for
IN_FENCE_FDproperty. This particular line seems wrong.(quoted diff) +0
-0@@ -593,14 +594,17 @@ int DrmDisplayCompositor::CommitFrame(DrmDisplayComposition *display_comp, else rotation |= DRM_MODE_ROTATE_0;Quoted 4 lines
Review int · line 598
Quoted 2 lines
(quoted diff) +1
-1- if (fence_fd < 0) { + if (fence_fd >= 0) {I'll give that a whirl.
So I did give that a whirl after you suggested it, but it ended up causing nothing to be displayed, and I unfortunately didn't have time right then to dig much further.
Rob however re-found this issue today, and I've been digging a bit more. At least with the HiKey board, it seem the trouble is when the
IN_FENCE_FDis added to the pset, the atomic commit calls start to fail. I dug in and it seems we're catching in the kernel on the if (file->f_op!=&sync_file_fops) check insync_file_fdget().
Quoted 4 lines
Quoted 2 lines
I'm now trying to trace back to where the in fence was provided from to see what might be going wrong there.
I would be surprised if this fence is not created by the GPU driver. But, the whole Android stack is new to me, so I might be wrong.
Yes, I went digging on this last night and it ends up the utgard driver we use (r7p0) isn't giving us a dmabuf fence, instead we're getting a mali_sync_fence.
There's a newer kernel driver release (r8p1), which seems to correct this, but it also is version tied to the binary blob, which I don't have a matching update for. I spent a bit of time trying to hack out just the dmabuf fence bits, but it rarely boots all the way and frequently locks the board up, so I'm probably mucking the library driver interface in some way.
Its a well known sad song.
Quoted 3 lines
Quoted 1 line
Curious if this is anything you ran across in your attempts?
Sorry, on Hikey960, I don't have this problem. Are you using the same 4.9 kernel from your branch(hikey-hwcomposer-deps)?
Thanks for confirming! I'll be double checking on the hikey960 soon. I suspect the bifrost driver is giving back the right structure if it was working for you.
thanks
-john
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [RFC][PATCH 4/4 v2] drm_hwcomposer: Try to fallback if GLCompisition fails
Quoted 38 lines · John Stultz
Quoted 27 lines · Alexandru-Cosmin Gheorghe
Quoted 26 lines · John Stultz
Quoted 10 lines · John Stultz
Quoted 8 lines · Alexandru-Cosmin Gheorghe
It seems that we don't pass any explicit fences to the kernel for
IN_FENCE_FDproperty. This particular line seems wrong.(quoted diff) +0
-0@@ -593,14 +594,17 @@ int DrmDisplayCompositor::CommitFrame(DrmDisplayComposition *display_comp, else rotation |= DRM_MODE_ROTATE_0;Quoted 4 lines
Review int · line 598
Quoted 2 lines
(quoted diff) +1
-1- if (fence_fd < 0) { + if (fence_fd >= 0) {I'll give that a whirl.
So I did give that a whirl after you suggested it, but it ended up causing nothing to be displayed, and I unfortunately didn't have time right then to dig much further.
Rob however re-found this issue today, and I've been digging a bit more. At least with the HiKey board, it seem the trouble is when the
IN_FENCE_FDis added to the pset, the atomic commit calls start to fail. I dug in and it seems we're catching in the kernel on the if (file->f_op!=&sync_file_fops) check insync_file_fdget().Quoted 4 lines
Quoted 2 lines
I'm now trying to trace back to where the in fence was provided from to see what might be going wrong there.
I would be surprised if this fence is not created by the GPU driver. But, the whole Android stack is new to me, so I might be wrong.
Yes, I went digging on this last night and it ends up the utgard driver we use (r7p0) isn't giving us a dmabuf fence, instead we're getting a
mali_sync_fence.
Quoted 8 lines
There's a newer kernel driver release (r8p1), which seems to correct this, but it also is version tied to the binary blob, which I don't have a matching update for. I spent a bit of time trying to hack out just the dmabuf fence bits, but it rarely boots all the way and frequently locks the board up, so I'm probably mucking the library driver interface in some way.
Its a well known sad song.
So, I took another stab at this tonight and actually got the dmabuf fence handling transplanted into the older r7p0 driver we're using. So with that and the recent fence_fd bug that has been fixed in master, things are working *much* better. No gl_finsh() hacks needed to avoid tearing and performance is improved nicely.
thanks
-john
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel