From patchwork Tue Mar 6 23:19:11 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 10263097 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 483876055D for ; Tue, 6 Mar 2018 23:19:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3D9042921B for ; Tue, 6 Mar 2018 23:19:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 31B472921D; Tue, 6 Mar 2018 23:19:27 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id B1A982921B for ; Tue, 6 Mar 2018 23:19:26 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 4D7676E37D; Tue, 6 Mar 2018 23:19:24 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-pg0-x243.google.com (mail-pg0-x243.google.com [IPv6:2607:f8b0:400e:c05::243]) by gabe.freedesktop.org (Postfix) with ESMTPS id AAD876E37D for ; Tue, 6 Mar 2018 23:19:23 +0000 (UTC) Received: by mail-pg0-x243.google.com with SMTP id i133so143696pgc.12 for ; Tue, 06 Mar 2018 15:19:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=I554ZL9nCS+8m0+oNk99HF8zP0qiQ3pmDXt+nup4it4=; b=Ie59jY4kvKET/hgDtoyg6cSW4bDYs+jDYFc8KLECgyvMEh31nJAQI+0RWuBF6wE8V8 b29+Fth6xwcrBdfwFlzcPlYTZ2LRy87LmiiM7N0yOramto20A+r0HX2w0A0pggDv2hmX fS0toj/h9bkFoZDMw4r7eNl51GtiR0ZTeXHRA= 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=I554ZL9nCS+8m0+oNk99HF8zP0qiQ3pmDXt+nup4it4=; b=MB7pCt5BjKl/FQEgF5nTc+8Dypf9BXB2d85oEzwjI/10qfDGei9NFdCeF1uU96JjEF YHS4Pc1oiGUaKWjbV4it5KbQCMIDaSZjjBXD7wdBQqPbR8ojx8GifDDD2ZKCNnRH48v1 KpMN9JWoG8OnYeclcud/kS56t9XFgo3sfNTOxys347+4wiBOxJ2DWNmSvwYhrvGInWO7 mxEkIbWoi4w7caBXHO8SjCw9Hr3zKhF5mlVwY3ieokVuRLVo2gJAU84CX5XWUzvJPdAd FdlsOoqwUFA088Pxvrdhu0uAn7Lfk6dTKKnJF0Jx1wLqDChVLbt2j7enn1GdMEdZbLKU tcuQ== X-Gm-Message-State: APf1xPBjvwyyaehJYfLq9LoBAAcXyaYGo49uYClQOqiVhkxmPRsLYc7e 9t1RUUX40A9gx6JWkETssWeAB03lDrc= X-Google-Smtp-Source: AG47ELtqTZSuhZq5QsT8baX7s17Pf5EY20yboYj/q0oL6l9b/ckrGZQH0Hif1zIcACzVzPeTOiKhcg== X-Received: by 10.99.47.132 with SMTP id v126mr16654173pgv.42.1520378362704; Tue, 06 Mar 2018 15:19:22 -0800 (PST) Received: from localhost.localdomain ([2601:1c2:600:5100:4e72:b9ff:fe99:466a]) by smtp.gmail.com with ESMTPSA id b4sm30854413pfa.3.2018.03.06.15.19.21 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 06 Mar 2018 15:19:21 -0800 (PST) From: John Stultz To: dri-devel Subject: [RFC][PATCH 1/2] drm_hwcomposer: Error out on YUV layer as it would fail for single planes Date: Tue, 6 Mar 2018 15:19:11 -0800 Message-Id: <1520378352-31260-1-git-send-email-john.stultz@linaro.org> X-Mailer: git-send-email 2.7.4 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Rob Herring , Matt Szczesiak , Dmitry Shmidt , Sean Paul , Robert Foss , Alexandru-Cosmin Gheorghe , Liviu Dudau , Marissa Wall , David Hanna MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP As suggested by Alexandru-Cosmin Gheorghe: ConvertHALFormatToDrm logic would work only for 1 plane formats, and probably gets rejected by drmModeAddFb2, but to save debugging time maybe it worth removing DRM_FORMAT_YVU420 from ConvertHALFormatToDrm and checking it's return code. So this patch tries to do this. Cc: Marissa Wall Cc: Sean Paul Cc: Dmitry Shmidt Cc: Robert Foss Cc: Matt Szczesiak Cc: Liviu Dudau Cc: David Hanna Cc: Rob Herring Cc: Alexandru-Cosmin Gheorghe Signed-off-by: John Stultz --- platformdrmgeneric.cpp | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/platformdrmgeneric.cpp b/platformdrmgeneric.cpp index 741d42b..33f1ea0 100644 --- a/platformdrmgeneric.cpp +++ b/platformdrmgeneric.cpp @@ -76,8 +76,6 @@ uint32_t DrmGenericImporter::ConvertHalFormatToDrm(uint32_t hal_format) { 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; @@ -88,10 +86,15 @@ EGLImageKHR DrmGenericImporter::ImportImage(EGLDisplay egl_display, buffer_handl gralloc_drm_handle_t *gr_handle = gralloc_drm_handle(handle); if (!gr_handle) return NULL; + + EGLint fmt = ConvertHalFormatToDrm(gr_handle->format); + if (fmt < 0) + return NULL; + EGLint attr[] = { EGL_WIDTH, gr_handle->width, EGL_HEIGHT, gr_handle->height, - EGL_LINUX_DRM_FOURCC_EXT, (EGLint)ConvertHalFormatToDrm(gr_handle->format), + EGL_LINUX_DRM_FOURCC_EXT, fmt, EGL_DMA_BUF_PLANE0_FD_EXT, gr_handle->prime_fd, EGL_DMA_BUF_PLANE0_OFFSET_EXT, 0, EGL_DMA_BUF_PLANE0_PITCH_EXT, gr_handle->stride, @@ -112,10 +115,14 @@ int DrmGenericImporter::ImportBuffer(buffer_handle_t handle, hwc_drm_bo_t *bo) { return ret; } + uint32_t fmt = ConvertHalFormatToDrm(gr_handle->format); + if (fmt < 0) + return fmt; + memset(bo, 0, sizeof(hwc_drm_bo_t)); bo->width = gr_handle->width; bo->height = gr_handle->height; - bo->format = ConvertHalFormatToDrm(gr_handle->format); + bo->format = fmt; bo->usage = gr_handle->usage; bo->pitches[0] = gr_handle->stride; bo->gem_handles[0] = gem_handle;