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: 130834 Delivered-To: patches@linaro.org Received: by 10.46.66.2 with SMTP id p2csp4518788lja; Tue, 6 Mar 2018 15:19:23 -0800 (PST) X-Received: by 2002:a17:902:724b:: with SMTP id c11-v6mr18283826pll.352.1520378363418; Tue, 06 Mar 2018 15:19:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520378363; cv=none; d=google.com; s=arc-20160816; b=Y7iDvwfADTU+387hjGB+vWELp6+zk1TcdCdMIEakE9Y4JS/tppxsYX9zZYze7UeT8e 7qA2zX6ZoZmblwYJ2JRJg8cnYwfj4ajQtSdFvN9ln1Jp2Lkr9bJXUCUHT2HGMSexMHC4 uwUdmeqMR1rqysrdypZBdsf3qLIrBgY3P8ErSjK2khtc1xghwzaMjvPq11IfRfJMxB95 RhxBo18gVD0SDJjY20WNYnVb4Yew3kA/uy5Ar5Z5MIhmiUk9oYeo0G9FmAU28zK2z/sc oLSuGAYtgZ/4xzLNukGwgtUDQ2HhfqEN6hIe7dOEp4VPLmMh33aPuVc0x8gm7CIQKers TPrg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=message-id:date:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=I554ZL9nCS+8m0+oNk99HF8zP0qiQ3pmDXt+nup4it4=; b=hR6MEdBjH+F9ycrMB6pQZy/XZ07LvHrZFTkrqKdmFmEs8UBVsSQJnC9OC/0RjZlrxs 7AJpTnZihAJX94m4oedS/+xvqDuYPGEBqeU7DmQllevuFoqIskPD63mTnBqONWYVyNIh fxUsCsouursrbsbLzmTEUA8VQgvDHr0KD/DTpdDF3aVKoXzSHxuCkiCa2y6SXIBtt3c4 PSAMUYfRtLJ4SKCbv0nJuAq4ntme1KpUxDEst6Jd27ceDuMiWQbgf2h9WgCozLeYFmYM i9ZbJPKctJoWX5Kzzfg+6bwAIcqbxkuCWZwhmzSQ8dVXt7IMfz8STCCx+LnCcXQAn+FN JCPg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Ie59jY4k; spf=pass (google.com: domain of john.stultz@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=john.stultz@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id l4sor3553717pgr.230.2018.03.06.15.19.23 for (Google Transport Security); Tue, 06 Mar 2018 15:19:23 -0800 (PST) Received-SPF: pass (google.com: domain of john.stultz@linaro.org designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Ie59jY4k; spf=pass (google.com: domain of john.stultz@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=john.stultz@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org 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=JE3ir4kdfZxtabZQWnSLXmp8EMOLbikKKok7Lna0+YzJU5X5f+Cl81L37O5gdjT/2H A29RfTch3tc2nvMtzBh+eWdWc/mtZBqdRi2xIKPPHPQ7lJ71mVWn4Qgvc8eNMckpeqDZ VKbF7Zh/XXxVe255QG/ZAnO/kkGQcy3ycsWzvPvlciMtKh06Xs/9Zdd5VNRkLNiczAJy QzhzINh9ktD5KzqRAU8S6VjEG6BqkNPd4TWvAdMF14+1SULxstXqAck91eoOtVznZXt5 p0VziMnkTlUOu6eBFLOkuvVlirUiZLZ5b/14/s7IjIUcdDR0xZud2IDiAoHLxzci0r9O G5RQ== X-Gm-Message-State: APf1xPAezoW09BODt9Yus8udBazttZUT34z/RNQg/cylYYthc1tC2/Cd dprbwLSrQQ9kvCH0EUxh6lRBp7cj 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) Return-Path: 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 Cc: John Stultz , Marissa Wall , Sean Paul , Dmitry Shmidt , Robert Foss , Matt Szczesiak , Liviu Dudau , David Hanna , Rob Herring , Alexandru-Cosmin Gheorghe 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 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(-) -- 2.7.4 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;