From patchwork Fri Oct 6 22:02:03 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Rob Herring \(Arm\)" X-Patchwork-Id: 115139 Delivered-To: patch@linaro.org Received: by 10.140.22.163 with SMTP id 32csp23207qgn; Fri, 6 Oct 2017 15:02:11 -0700 (PDT) X-Received: by 10.99.123.4 with SMTP id w4mr3069111pgc.438.1507327331227; Fri, 06 Oct 2017 15:02:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1507327331; cv=none; d=google.com; s=arc-20160816; b=ha2a7VNa7fEC3wDU71NW453lDaLF2jNyEDDSmod73U02vyqJbD2T1u5N7r5+s//BIW JNNsU7lfRoiQchDNhCa5vuBtTGLKAxuWJAVyOh7/U24B5d1gRiZE/rp/saM5wr0UG4AF coaexpbRCqDUBLy38/InaunrqIGUATHU+Rppg1Hp7pG0omsj8nUIVfG51atqSyYdwI1w nJDOnnPI9nScXO11Fhe88fpwf5gUpFkthqp+jx9pzOMfagelIiAM8werrOWw2m2SJmHA MLKn4gxf4j1Cm8dIBOKs6XADzzkB3ofNkNw+pq/GIUcYRb39vdo+AKsj3OQ+c0MBE1iO rPqw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:cc:message-id:date:subject:to:from:delivered-to :arc-authentication-results; bh=tUTrcoVtRm1KM8W72pSm6UUf02ZNEHLJtfdKSD9bEBg=; b=rhkanB2N6716g21rOWueBtA4+oxHegR+7Gczpa/6WOBsklesb7YLoTez9Bz5sTaZbz M/qR/l9lLXZenOld7Oxamz51LnykiCE9wmj+ESbINQSLfSwvOFs4+MID+jU7IVcyr95a sLRIYid308xNHFOE5f01IZ7eMeYtVtFE5XvyOvk4FJCmmQLlReba8PJ+UThYtRqTwVmi LrohbdlMbN0bbXi9h7G/0uuBUNMWiNjJI+jTDLV97qRd1hNcMJlVQGV8oExdCUbTanWX r5a1Rebh3NaeMjj6AZFJn7UeHj0beGUaM/qHJLjmcCXVB2F5vuIyxwmlWJ38OzFldJF7 gHmg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 131.252.210.177 as permitted sender) smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Return-Path: Received: from gabe.freedesktop.org (gabe.freedesktop.org. [131.252.210.177]) by mx.google.com with ESMTPS id v6si1851132pgt.38.2017.10.06.15.02.10 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 06 Oct 2017 15:02:11 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 131.252.210.177 as permitted sender) client-ip=131.252.210.177; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 131.252.210.177 as permitted sender) smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 0E8256E9EC; Fri, 6 Oct 2017 22:02:09 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-oi0-f48.google.com (mail-oi0-f48.google.com [209.85.218.48]) by gabe.freedesktop.org (Postfix) with ESMTPS id 607006E9E5 for ; Fri, 6 Oct 2017 22:02:07 +0000 (UTC) Received: by mail-oi0-f48.google.com with SMTP id g125so14244466oib.12 for ; Fri, 06 Oct 2017 15:02:07 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=BKNZUxNPQ2sNbID7b7/6ycncv7iS2GRrIMpaEXgtsWs=; b=D4codvzX7B6LVt/5U4h2aZv0x2P7SUq6IbGUEGoscNHKnF0q0u5p5nezgmxmh5K5ek AB9lHSkAWohI9vCL7RbJh9wcxQwL05UUuu2S8rfzyZcCTBKKtVieXRdXw9g0cYioWewK /CCu99uF3qqnnHnnT0UgPtPinbIgw2cfGhj7SDIJYRTyhs+pkgo7dI6KxCKBrAVEq/fm WRTVqB0vBFreOJtENZfRQMbKySORMuuoSezVfHlu0DNBOQVibV3FyVR6Eqc6IjvN0HFo IrEZWOB3MIuCuZklfIqoULgDbyo8hwpzukWjWFI+ynTKGeS6lmFuADBSl6pIikFrJkp9 1scg== X-Gm-Message-State: AMCzsaWsr9g4DA3XZZc55emww5L6t6D/VLDUoYKieYQYgmUUlAuly3nP q7Tu8D0qUtTO0EqIVYS3iIAEo3c= X-Google-Smtp-Source: AOwi7QAOaBPfpl1y/PhV1PgbgzqdnYVpjHAYEzQreLoDoHk2/gIVs+JRVxW4Aa2KPgB6AhhsrilKoA== X-Received: by 10.157.87.75 with SMTP id x11mr2252099oti.112.1507327326228; Fri, 06 Oct 2017 15:02:06 -0700 (PDT) Received: from localhost.localdomain (216-188-254-6.dyn.grandenetworks.net. [216.188.254.6]) by smtp.googlemail.com with ESMTPSA id c201sm1220358oih.47.2017.10.06.15.02.05 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 06 Oct 2017 15:02:05 -0700 (PDT) From: Rob Herring To: dri-devel@lists.freedesktop.org Subject: [PATCH hwc] drm_hwcomposer: remove NVIDIA importer Date: Fri, 6 Oct 2017 17:02:03 -0500 Message-Id: <20171006220203.16196-1-robh@kernel.org> X-Mailer: git-send-email 2.11.0 Cc: Robert Foss X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" There's no opensource implementation for the NVIDIA gralloc implementation, so remove it as it is not testable. As all of the gralloc perform() operations are specific to it, they can be removed, too. Signed-off-by: Rob Herring Acked-by: Thierry Reding --- Android.mk | 5 - drmhwcgralloc.h | 33 ----- platformnv.cpp | 374 -------------------------------------------------------- 3 files changed, 412 deletions(-) delete mode 100644 platformnv.cpp diff --git a/Android.mk b/Android.mk index 99bbcac3e984..d7dc6782e1e0 100644 --- a/Android.mk +++ b/Android.mk @@ -71,7 +71,6 @@ LOCAL_SRC_FILES := \ hwcutils.cpp \ platform.cpp \ platformdrmgeneric.cpp \ - platformnv.cpp \ separate_rects.cpp \ virtualcompositorworker.cpp \ vsyncworker.cpp @@ -80,11 +79,7 @@ LOCAL_CPPFLAGS += \ -DHWC2_USE_CPP11 \ -DHWC2_INCLUDE_STRINGIFICATION -ifeq ($(strip $(BOARD_DRM_HWCOMPOSER_BUFFER_IMPORTER)),nvidia-gralloc) -LOCAL_CPPFLAGS += -DUSE_NVIDIA_IMPORTER -else LOCAL_CPPFLAGS += -DUSE_DRM_GENERIC_IMPORTER -endif LOCAL_MODULE := hwcomposer.drm LOCAL_MODULE_TAGS := optional diff --git a/drmhwcgralloc.h b/drmhwcgralloc.h index c4a42eaf1c54..759746a67949 100644 --- a/drmhwcgralloc.h +++ b/drmhwcgralloc.h @@ -19,39 +19,6 @@ #include -enum { - /* perform(const struct gralloc_module_t *mod, - * int op, - * int drm_fd, - * buffer_handle_t buffer, - * struct hwc_drm_bo *bo); - */ - GRALLOC_MODULE_PERFORM_DRM_IMPORT = 0xffeeff00, - - /* perform(const struct gralloc_module_t *mod, - * int op, - * buffer_handle_t buffer, - * void (*free_callback)(void *), - * void *priv); - */ - GRALLOC_MODULE_PERFORM_SET_IMPORTER_PRIVATE = 0xffeeff01, - - /* perform(const struct gralloc_module_t *mod, - * int op, - * buffer_handle_t buffer, - * void (*free_callback)(void *), - * void **priv); - */ - GRALLOC_MODULE_PERFORM_GET_IMPORTER_PRIVATE = 0xffeeff02, - - /* perform(const struct gralloc_module_t *mod, - * int op, - * buffer_handle_t buffer, - * int *usage); - */ - GRALLOC_MODULE_PERFORM_GET_USAGE = 0xffeeff03, -}; - typedef struct hwc_drm_bo { uint32_t width; uint32_t height; diff --git a/platformnv.cpp b/platformnv.cpp deleted file mode 100644 index e7b6be3430a8..000000000000 --- a/platformnv.cpp +++ /dev/null @@ -1,374 +0,0 @@ -/* - * 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-nv" - -#include "drmresources.h" -#include "platform.h" -#include "platformnv.h" - -#include -#include -#include -#include -#include - -#include -#include - -#ifndef EGL_NATIVE_HANDLE_ANDROID_NVX -#define EGL_NATIVE_HANDLE_ANDROID_NVX 0x322A -#endif - -namespace android { - -#ifdef USE_NVIDIA_IMPORTER -// static -Importer *Importer::CreateInstance(DrmResources *drm) { - NvImporter *importer = new NvImporter(drm); - if (!importer) - return NULL; - - int ret = importer->Init(); - if (ret) { - ALOGE("Failed to initialize the nv importer %d", ret); - delete importer; - return NULL; - } - return importer; -} -#endif - -NvImporter::NvImporter(DrmResources *drm) : drm_(drm) { -} - -NvImporter::~NvImporter() { -} - -int NvImporter::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, "NVIDIA")) - ALOGW("Using non-NVIDIA gralloc module: %s/%s\n", gralloc_->common.name, - gralloc_->common.author); - - return 0; -} - - -EGLImageKHR NvImporter::ImportImage(EGLDisplay egl_display, buffer_handle_t handle) { - return eglCreateImageKHR( - egl_display, EGL_NO_CONTEXT, EGL_NATIVE_HANDLE_ANDROID_NVX, - (EGLClientBuffer)handle, NULL /* no attribs */); -} - -int NvImporter::ImportBuffer(buffer_handle_t handle, hwc_drm_bo_t *bo) { - memset(bo, 0, sizeof(hwc_drm_bo_t)); - NvBuffer_t *buf = GrallocGetNvBuffer(handle); - if (buf) { - atomic_fetch_add(&buf->ref, 1); - *bo = buf->bo; - return 0; - } - - buf = new NvBuffer_t(); - if (!buf) { - ALOGE("Failed to allocate new NvBuffer_t"); - return -ENOMEM; - } - buf->bo.priv = buf; - buf->importer = this; - - // We initialize the reference count to 2 since NvGralloc is still using this - // buffer (will be cleared in the NvGrallocRelease), and the other - // reference is for HWC (this ImportBuffer call). - atomic_init(&buf->ref, 2); - - int ret = gralloc_->perform(gralloc_, GRALLOC_MODULE_PERFORM_DRM_IMPORT, - drm_->fd(), handle, &buf->bo); - if (ret) { - ALOGE("GRALLOC_MODULE_PERFORM_DRM_IMPORT failed %d", ret); - delete buf; - return ret; - } - - ret = drmModeAddFB2(drm_->fd(), buf->bo.width, buf->bo.height, buf->bo.format, - buf->bo.gem_handles, buf->bo.pitches, buf->bo.offsets, - &buf->bo.fb_id, 0); - if (ret) { - ALOGE("Failed to add fb %d", ret); - ReleaseBufferImpl(&buf->bo); - delete buf; - return ret; - } - - ret = GrallocSetNvBuffer(handle, buf); - if (ret) { - /* This will happen is persist.tegra.gpu_mapping_cache is 0/off, - * or if NV gralloc runs out of "priv slots" (currently 3 per buffer, - * only one of which should be used by drm_hwcomposer). */ - ALOGE("Failed to register free callback for imported buffer %d", ret); - ReleaseBufferImpl(&buf->bo); - delete buf; - return ret; - } - *bo = buf->bo; - return 0; -} - -int NvImporter::ReleaseBuffer(hwc_drm_bo_t *bo) { - NvBuffer_t *buf = (NvBuffer_t *)bo->priv; - if (!buf) { - ALOGE("Freeing bo %" PRIu32 ", buf is NULL!", bo->fb_id); - return 0; - } - if (atomic_fetch_sub(&buf->ref, 1) > 1) - return 0; - - ReleaseBufferImpl(bo); - delete buf; - return 0; -} - -// static -void NvImporter::NvGrallocRelease(void *nv_buffer) { - NvBuffer_t *buf = (NvBuffer *)nv_buffer; - buf->importer->ReleaseBuffer(&buf->bo); -} - -void NvImporter::ReleaseBufferImpl(hwc_drm_bo_t *bo) { - if (bo->fb_id) { - int ret = drmModeRmFB(drm_->fd(), bo->fb_id); - if (ret) - ALOGE("Failed to rm fb %d", ret); - } - - 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 { - /* Clear any duplicate gem handle as well but don't close again */ - for (int j = i + 1; j < num_gem_handles; j++) - if (bo->gem_handles[j] == bo->gem_handles[i]) - bo->gem_handles[j] = 0; - bo->gem_handles[i] = 0; - } - } -} - -NvImporter::NvBuffer_t *NvImporter::GrallocGetNvBuffer(buffer_handle_t handle) { - void *priv = NULL; - int ret = - gralloc_->perform(gralloc_, GRALLOC_MODULE_PERFORM_GET_IMPORTER_PRIVATE, - handle, NvGrallocRelease, &priv); - return ret ? NULL : (NvBuffer_t *)priv; -} - -int NvImporter::GrallocSetNvBuffer(buffer_handle_t handle, NvBuffer_t *buf) { - return gralloc_->perform(gralloc_, - GRALLOC_MODULE_PERFORM_SET_IMPORTER_PRIVATE, handle, - NvGrallocRelease, buf); -} - -#ifdef USE_NVIDIA_IMPORTER -// static -std::unique_ptr Planner::CreateInstance(DrmResources *) { - std::unique_ptr planner(new Planner); - planner->AddStage(); - planner->AddStage(); - planner->AddStage(); - planner->AddStage(); - planner->AddStage(); - return planner; -} -#endif - -static DrmPlane *GetCrtcPrimaryPlane(DrmCrtc *crtc, - std::vector *planes) { - for (auto i = planes->begin(); i != planes->end(); ++i) { - if ((*i)->GetCrtcSupported(*crtc)) { - DrmPlane *plane = *i; - planes->erase(i); - return plane; - } - } - return NULL; -} - -int PlanStageProtectedRotated::ProvisionPlanes( - std::vector *composition, - std::map &layers, DrmCrtc *crtc, - std::vector *planes) { - int ret; - int protected_zorder = -1; - for (auto i = layers.begin(); i != layers.end();) { - if (!i->second->protected_usage() || !i->second->transform) { - ++i; - continue; - } - - auto primary_iter = planes->begin(); - for (; primary_iter != planes->end(); ++primary_iter) { - if ((*primary_iter)->type() == DRM_PLANE_TYPE_PRIMARY) - break; - } - - // We cheat a little here. Since there can only be one primary plane per - // crtc, we know we'll only hit this case once. So we blindly insert the - // protected content at the beginning of the composition, knowing this path - // won't be taken a second time during the loop. - if (primary_iter != planes->end()) { - composition->emplace(composition->begin(), - DrmCompositionPlane::Type::kLayer, *primary_iter, - crtc, i->first); - planes->erase(primary_iter); - protected_zorder = i->first; - } else { - ALOGE("Could not provision primary plane for protected/rotated layer"); - } - i = layers.erase(i); - } - - if (protected_zorder == -1) - return 0; - - // Add any layers below the protected content to the precomposition since we - // need to punch a hole through them. - for (auto i = layers.begin(); i != layers.end();) { - // Skip layers above the z-order of the protected content - if (i->first > static_cast(protected_zorder)) { - ++i; - continue; - } - - // If there's no precomp layer already queued, queue one now. - DrmCompositionPlane *precomp = GetPrecomp(composition); - if (precomp) { - precomp->source_layers().emplace_back(i->first); - } else { - if (planes->size()) { - DrmPlane *precomp_plane = planes->back(); - planes->pop_back(); - composition->emplace_back(DrmCompositionPlane::Type::kPrecomp, - precomp_plane, crtc, i->first); - } else { - ALOGE("Not enough planes to reserve for precomp fb"); - } - } - i = layers.erase(i); - } - return 0; -} - -bool PlanStageNvLimits::CheckLayer(size_t zorder, DrmHwcLayer *layer) { - auto src_w = layer->source_crop.width(); - auto src_h = layer->source_crop.height(); - auto dst_w = layer->display_frame.width(); - auto dst_h = layer->display_frame.height(); - int h_limit = 4; - int v_limit; - - switch (layer->buffer->format) { - case DRM_FORMAT_ARGB8888: - case DRM_FORMAT_ABGR8888: - case DRM_FORMAT_XBGR8888: - case DRM_FORMAT_XRGB8888: - // tegra driver assumes any layer with alpha channel has premult - // blending, avoid handling it this is not the case. This is not an - // issue for bottom-most layer since there's nothing to blend with - if (zorder > 0 && layer->blending != DrmHwcBlending::kPreMult) - return false; - - v_limit = 2; - break; - case DRM_FORMAT_YVU420: - case DRM_FORMAT_YUV420: - case DRM_FORMAT_YUV422: - case DRM_FORMAT_UYVY: - case DRM_FORMAT_YUYV: - case DRM_FORMAT_NV12: - case DRM_FORMAT_NV21: - case DRM_FORMAT_RGB565: - case DRM_FORMAT_BGR565: - v_limit = 4; - break; - default: - v_limit = 2; - break; - } - - if (layer->transform & - (DrmHwcTransform::kRotate90 | DrmHwcTransform::kRotate270)) - std::swap(dst_w, dst_h); - - // check for max supported down scaling - if (((src_w / dst_w) > h_limit) || ((src_h / dst_h) > v_limit)) - return false; - - return true; -} - -int PlanStageNvLimits::ProvisionPlanes( - std::vector *composition, - std::map &layers, DrmCrtc *crtc, - std::vector *planes) { - int ret; - - for (auto i = layers.begin(); i != layers.end();) { - // Skip layer if supported - if (CheckLayer(i->first, i->second)) { - i++; - continue; - } - - if (i->second->protected_usage()) { - // Drop the layer if unsupported and protected, this will just display - // black in the area of this layer but it's better than failing miserably - i = layers.erase(i); - continue; - } - - // If there's no precomp layer already queued, queue one now. - DrmCompositionPlane *precomp = GetPrecomp(composition); - if (precomp) { - precomp->source_layers().emplace_back(i->first); - } else if (!planes->empty()) { - DrmPlane *precomp_plane = planes->back(); - planes->pop_back(); - composition->emplace_back(DrmCompositionPlane::Type::kPrecomp, - precomp_plane, crtc, i->first); - } else { - ALOGE("Not enough planes to reserve for precomp fb"); - } - i = layers.erase(i); - } - - return 0; -} -}