From patchwork Mon Jul 31 18:29:13 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joe Kniss X-Patchwork-Id: 9872955 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 A99286037D for ; Mon, 31 Jul 2017 18:30:07 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 84CC4285CF for ; Mon, 31 Jul 2017 18:30:07 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 792D2285D3; Mon, 31 Jul 2017 18:30:07 +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=-1.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 6B8E2285CF for ; Mon, 31 Jul 2017 18:30:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=myzqgPdnTnoa1h3n+aVak/U7yhC2RobqgyoGe6eSiIo=; b=SZ6rZwtbls1s2hPZX8e550KDHS Qyu0GC7HTkQUiNFkQ6AGs+jVJEwgTONdT6tj9eiH9trSzYw74406x2MnA8ZM0Q0bipgWYi4WQxnMP wIl5ErfqPeY/80lwaUlYPyLAIS2E0NO6lkPLEsaK6sgR3Rf1/E2j2SMToqf2qwXoDaB955iPmFwtC O+FWzsc/66+xJPJ/V1ZeOHPmf1hRN7ihNnOJo791+/SgOyUnrDIDrgGq/FwBvCwgw5NeUTRGbOPS6 4z8WQq07d/EMy7McsSRuZZx3/VC2hTWsWrip46TqmFk5qhTsSWAEOsA9TQU4HF8MWedtyn4xqoeWT zFfCFBUA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1dcFS9-0001jw-L8; Mon, 31 Jul 2017 18:30:05 +0000 Received: from mail-pg0-x236.google.com ([2607:f8b0:400e:c05::236]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1dcFRk-0001G4-82 for linux-mediatek@lists.infradead.org; Mon, 31 Jul 2017 18:29:44 +0000 Received: by mail-pg0-x236.google.com with SMTP id u185so35708222pgb.1 for ; Mon, 31 Jul 2017 11:29:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=bQ1qpo8Xs2W8aTeVFOp999wDiL9WZmLpj5WAfksqbPs=; b=WYNAjNrlpL/JOKXPndTkzdDQiP92xnawQ9AXns71RglIe+w8n3ASDtS9wEhmSHRWjl bzcdIr1GIQrToIefn9hFD+/8XzqAz7P/7GSdLWAqv7Wy+hrxWGXQRIwMb7JW7xPTXKdB Q2C1cBcmp5K85gNyfgZpjsxoLAXNFwwMq7gxY= 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:in-reply-to :references; bh=bQ1qpo8Xs2W8aTeVFOp999wDiL9WZmLpj5WAfksqbPs=; b=fd6/lcB3VjVu6TDHZMEKC3ZV1ivjwgLIePdJU2g1jpVePWiu5T184RGIF3MRtEDITB WknpPCzd4Xq9bI5jDMtScBQwTlhtvb7Mvm82z3RX29nND9Ib9mCjWvc+dPqjLBQkC3pn 3LQSOQhI40y1Kkc+oWwiR1MlUvD3IEDzEBHhyS+fA8FGvD3sG7gLVCMbnGcyblpMXpWS SGPfRQW7nROoJJJhq7ubwdsuutl1kOIPLs98jCdtihTQFxbi7+971aBbsW+JlQ3eH13R O/SFeGUMg7EsHXj384JUQ9JpTp+qoHhof0Fz8rMxhUaDwiAB5luKGwiWLj4cEQIAd7Xq nn7g== X-Gm-Message-State: AIVw110SH4lCqx9n7ki3dZBLelpA+3swihZgF62XL8lJosrkCxX6fcM8 CUeL8VG9tlkcq4kD X-Received: by 10.84.232.13 with SMTP id h13mr18836163plk.168.1501525758041; Mon, 31 Jul 2017 11:29:18 -0700 (PDT) Received: from djmk.mtv.corp.google.com ([172.22.114.233]) by smtp.gmail.com with ESMTPSA id s73sm38122021pgc.73.2017.07.31.11.29.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 31 Jul 2017 11:29:16 -0700 (PDT) From: Joe Kniss X-Google-Original-From: Joe Kniss To: dri-devel@lists.freedesktop.org Subject: [PATCH] Add drm ioctl DRM_IOCTL_MODE_GETFB2 & associated helpers. Date: Mon, 31 Jul 2017 11:29:13 -0700 Message-Id: <20170731182913.136758-1-djmk@google.com> X-Mailer: git-send-email 2.14.0.rc0.400.g1c36432dff-goog In-Reply-To: References: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170731_112940_428248_358D29DF X-CRM114-Status: GOOD ( 19.21 ) X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: amd-gfx@lists.freedesktop.org, heiko@sntech.de, seanpaul@google.com, michel.daenzer@amd.com, chris@chris-wilson.co.uk, linux-tegra@vger.kernel.org, thierry.reding@gmail.com, patrik.r.jakobsson@gmail.com, djmk@google.com, gnurou@gmail.com, linux-samsung-soc@vger.kernel.org, jy0922.shim@samsung.com, linux-rockchip@lists.infradead.org, kyungmin.park@samsung.com, krzk@kernel.org, javier@osg.samsung.com, tomi.valkeinen@ti.com, bskeggs@redhat.com, nouveau@lists.freedesktop.org, ck.hu@mediatek.com, Andrey.Grodzovsky@amd.com, swarren@wwwdotorg.org, linux-arm-msm@vger.kernel.org, intel-gfx@lists.freedesktop.org, linux-mediatek@lists.infradead.org, matthias.bgg@gmail.com, linux-arm-kernel@lists.infradead.org, mark.yao@rock-chips.com, marcheu@google.com, nils.wallmenius@gmail.com, freedreno@lists.freedesktop.org, sw0312.kim@samsung.com, linux-kernel@vger.kernel.org, robdclark@gmail.com, kgene@kernel.org, p.zabel@pengutronix.de, alexander.deucher@amd.com, funfunctor@folklore1984.net, laurent.pinchart@ideasonboard.com MIME-Version: 1.0 Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+patchwork-linux-mediatek=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP New getfb2 functionality uses drm_mode_fb_cmd2 struct to be symmetric with addfb2. Also modifies *_fb_create_handle() calls to accept a format_plane_index so that handles for each plane can be generated. Previously, many *_fb_create_handle() calls simply defaulted to plane 0 only. Signed-off-by: Joe Kniss --- drivers/gpu/drm/amd/amdgpu/amdgpu_display.c | 5 +- drivers/gpu/drm/armada/armada_fb.c | 1 + drivers/gpu/drm/drm_crtc_internal.h | 2 + drivers/gpu/drm/drm_fb_cma_helper.c | 11 ++-- drivers/gpu/drm/drm_framebuffer.c | 79 ++++++++++++++++++++++++++++- drivers/gpu/drm/drm_ioctl.c | 1 + drivers/gpu/drm/exynos/exynos_drm_fb.c | 7 ++- drivers/gpu/drm/gma500/framebuffer.c | 2 + drivers/gpu/drm/i915/intel_display.c | 1 + drivers/gpu/drm/mediatek/mtk_drm_fb.c | 1 + drivers/gpu/drm/msm/msm_fb.c | 5 +- drivers/gpu/drm/nouveau/nouveau_display.c | 1 + drivers/gpu/drm/omapdrm/omap_fb.c | 5 +- drivers/gpu/drm/radeon/radeon_display.c | 5 +- drivers/gpu/drm/rockchip/rockchip_drm_fb.c | 6 ++- drivers/gpu/drm/tegra/fb.c | 9 +++- include/drm/drm_framebuffer.h | 1 + include/uapi/drm/drm.h | 2 + 18 files changed, 127 insertions(+), 17 deletions(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c index 39fc388f222a..c77c1cd265a0 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c @@ -566,8 +566,9 @@ static void amdgpu_user_framebuffer_destroy(struct drm_framebuffer *fb) } static int amdgpu_user_framebuffer_create_handle(struct drm_framebuffer *fb, - struct drm_file *file_priv, - unsigned int *handle) + unsigned int plane_index, + struct drm_file *file_priv, + unsigned int *handle) { struct amdgpu_framebuffer *amdgpu_fb = to_amdgpu_framebuffer(fb); diff --git a/drivers/gpu/drm/armada/armada_fb.c b/drivers/gpu/drm/armada/armada_fb.c index 2a7eb6817c36..9f237544f6c5 100644 --- a/drivers/gpu/drm/armada/armada_fb.c +++ b/drivers/gpu/drm/armada/armada_fb.c @@ -23,6 +23,7 @@ static void armada_fb_destroy(struct drm_framebuffer *fb) } static int armada_fb_create_handle(struct drm_framebuffer *fb, + unsigned int format_plane_index, struct drm_file *dfile, unsigned int *handle) { struct armada_framebuffer *dfb = drm_fb_to_armada_fb(fb); diff --git a/drivers/gpu/drm/drm_crtc_internal.h b/drivers/gpu/drm/drm_crtc_internal.h index 955c5690bf64..ec8d913240fe 100644 --- a/drivers/gpu/drm/drm_crtc_internal.h +++ b/drivers/gpu/drm/drm_crtc_internal.h @@ -170,6 +170,8 @@ int drm_mode_rmfb(struct drm_device *dev, void *data, struct drm_file *file_priv); int drm_mode_getfb(struct drm_device *dev, void *data, struct drm_file *file_priv); +int drm_mode_getfb2(struct drm_device *dev, + void *data, struct drm_file *file_priv); int drm_mode_dirtyfb_ioctl(struct drm_device *dev, void *data, struct drm_file *file_priv); diff --git a/drivers/gpu/drm/drm_fb_cma_helper.c b/drivers/gpu/drm/drm_fb_cma_helper.c index 596fabf18c3e..5fd7bcc2c6d1 100644 --- a/drivers/gpu/drm/drm_fb_cma_helper.c +++ b/drivers/gpu/drm/drm_fb_cma_helper.c @@ -110,13 +110,16 @@ void drm_fb_cma_destroy(struct drm_framebuffer *fb) } EXPORT_SYMBOL(drm_fb_cma_destroy); -int drm_fb_cma_create_handle(struct drm_framebuffer *fb, - struct drm_file *file_priv, unsigned int *handle) +static int drm_fb_cma_create_handle(struct drm_framebuffer *fb, + unsigned int format_plane_index, + struct drm_file *file_priv, + unsigned int *handle) { struct drm_fb_cma *fb_cma = to_fb_cma(fb); - + if (format_plane_index >= 4 || !fb_dma->obj[format_plane_index]) + return -ENOENT; return drm_gem_handle_create(file_priv, - &fb_cma->obj[0]->base, handle); + &fb_cma->obj[format_plane_index]->base, handle); } EXPORT_SYMBOL(drm_fb_cma_create_handle); diff --git a/drivers/gpu/drm/drm_framebuffer.c b/drivers/gpu/drm/drm_framebuffer.c index 28a0108a1ab8..67b3be1bedbc 100644 --- a/drivers/gpu/drm/drm_framebuffer.c +++ b/drivers/gpu/drm/drm_framebuffer.c @@ -24,6 +24,7 @@ #include #include #include +#include #include "drm_crtc_internal.h" @@ -438,7 +439,7 @@ int drm_mode_getfb(struct drm_device *dev, if (fb->funcs->create_handle) { if (drm_is_current_master(file_priv) || capable(CAP_SYS_ADMIN) || drm_is_control_client(file_priv)) { - ret = fb->funcs->create_handle(fb, file_priv, + ret = fb->funcs->create_handle(fb, 0, file_priv, &r->handle); } else { /* GET_FB() is an unprivileged ioctl so we must not @@ -458,6 +459,82 @@ int drm_mode_getfb(struct drm_device *dev, return ret; } +/** + * drm_mode_getfb2 - get FB info + * @dev: drm device for the ioctl + * @data: data pointer for the ioctl + * @file_priv: drm file for the ioctl call + * + * Lookup the FB given its ID and return info about it. + * + * Called by the user via ioctl. + * + * Returns: + * Zero on success, negative errno on failure. + */ +int drm_mode_getfb2(struct drm_device *dev, + void *data, struct drm_file *file_priv) +{ + struct drm_mode_fb_cmd2 *r = data; + struct drm_framebuffer *fb; + int ret, i; + + if (!drm_core_check_feature(dev, DRIVER_MODESET)) + return -EINVAL; + + fb = drm_framebuffer_lookup(dev, r->fb_id); + if (!fb) + return -ENOENT; + + r->height = fb->height; + r->width = fb->width; + r->pixel_format = fb->format->format; + for (i = 0; i < 4; ++i) { + r->pitches[i] = fb->pitches[i]; + r->offsets[i] = fb->offsets[i]; + r->modifier[i] = fb->modifier; + r->handles[i] = 0; + } + + for (i = 0; i < fb->format->num_planes; ++i) { + if (fb->funcs->create_handle) { + if (drm_is_current_master(file_priv) || + capable(CAP_SYS_ADMIN) || + drm_is_control_client(file_priv)) { + ret = fb->funcs->create_handle(fb, i, file_priv, + &r->handles[i]); + if (ret) + break; + } else { + /* GET_FB() is an unprivileged ioctl so we must + * not return a buffer-handle to non-master + * processes! For backwards-compatibility + * reasons, we cannot make GET_FB() privileged, + * so just return an invalid handle for + * non-masters. */ + r->handles[i] = 0; + ret = 0; + } + } else { + ret = -ENODEV; + break; + } + } + + /* If handle creation failed, delete/dereference any that were made. */ + if (ret) { + for (i = 0; i < 4; ++i) { + if (r->handles[i]) + drm_gem_handle_delete(file_priv, r->handles[i]); + r->handles[i] = 0; + } + } + + drm_framebuffer_unreference(fb); + + return ret; +} + /** * drm_mode_dirtyfb_ioctl - flush frontbuffer rendering on an FB * @dev: drm device for the ioctl diff --git a/drivers/gpu/drm/drm_ioctl.c b/drivers/gpu/drm/drm_ioctl.c index a7c61c23685a..a9b578dc5d17 100644 --- a/drivers/gpu/drm/drm_ioctl.c +++ b/drivers/gpu/drm/drm_ioctl.c @@ -627,6 +627,7 @@ static const struct drm_ioctl_desc drm_ioctls[] = { DRM_IOCTL_DEF(DRM_IOCTL_MODE_SETPROPERTY, drm_mode_connector_property_set_ioctl, DRM_MASTER|DRM_CONTROL_ALLOW|DRM_UNLOCKED), DRM_IOCTL_DEF(DRM_IOCTL_MODE_GETPROPBLOB, drm_mode_getblob_ioctl, DRM_CONTROL_ALLOW|DRM_UNLOCKED), DRM_IOCTL_DEF(DRM_IOCTL_MODE_GETFB, drm_mode_getfb, DRM_CONTROL_ALLOW|DRM_UNLOCKED), + DRM_IOCTL_DEF(DRM_IOCTL_MODE_GETFB2, drm_mode_getfb2, DRM_CONTROL_ALLOW|DRM_UNLOCKED), DRM_IOCTL_DEF(DRM_IOCTL_MODE_ADDFB, drm_mode_addfb, DRM_CONTROL_ALLOW|DRM_UNLOCKED), DRM_IOCTL_DEF(DRM_IOCTL_MODE_ADDFB2, drm_mode_addfb2, DRM_CONTROL_ALLOW|DRM_UNLOCKED), DRM_IOCTL_DEF(DRM_IOCTL_MODE_RMFB, drm_mode_rmfb, DRM_CONTROL_ALLOW|DRM_UNLOCKED), diff --git a/drivers/gpu/drm/exynos/exynos_drm_fb.c b/drivers/gpu/drm/exynos/exynos_drm_fb.c index c77a5aced81a..5e8b774dc1af 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_fb.c +++ b/drivers/gpu/drm/exynos/exynos_drm_fb.c @@ -88,13 +88,16 @@ static void exynos_drm_fb_destroy(struct drm_framebuffer *fb) } static int exynos_drm_fb_create_handle(struct drm_framebuffer *fb, + unsigned int format_plane_index, struct drm_file *file_priv, unsigned int *handle) { struct exynos_drm_fb *exynos_fb = to_exynos_fb(fb); - + if (format_plane_index >= MAX_FB_BUFFER || + !exynos_fb->exynos_gem[format_plane_index]) + return -ENOENT; return drm_gem_handle_create(file_priv, - &exynos_fb->exynos_gem[0]->base, handle); + &exynos_fb->exynos_gem[format_plane_index]->base, handle); } static const struct drm_framebuffer_funcs exynos_drm_fb_funcs = { diff --git a/drivers/gpu/drm/gma500/framebuffer.c b/drivers/gpu/drm/gma500/framebuffer.c index ffe6b4ffa1a8..c221544b4c6a 100644 --- a/drivers/gpu/drm/gma500/framebuffer.c +++ b/drivers/gpu/drm/gma500/framebuffer.c @@ -42,6 +42,7 @@ static void psb_user_framebuffer_destroy(struct drm_framebuffer *fb); static int psb_user_framebuffer_create_handle(struct drm_framebuffer *fb, + unsigned int format_plane_index, struct drm_file *file_priv, unsigned int *handle); @@ -619,6 +620,7 @@ static void psbfb_output_poll_changed(struct drm_device *dev) * the work for us */ static int psb_user_framebuffer_create_handle(struct drm_framebuffer *fb, + unsigned int plane_index, struct drm_file *file_priv, unsigned int *handle) { diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c index 3282b0f4b134..54fdd30b0598 100644 --- a/drivers/gpu/drm/i915/intel_display.c +++ b/drivers/gpu/drm/i915/intel_display.c @@ -15853,6 +15853,7 @@ static void intel_user_framebuffer_destroy(struct drm_framebuffer *fb) } static int intel_user_framebuffer_create_handle(struct drm_framebuffer *fb, + unsigned int format_plane_index, struct drm_file *file, unsigned int *handle) { diff --git a/drivers/gpu/drm/mediatek/mtk_drm_fb.c b/drivers/gpu/drm/mediatek/mtk_drm_fb.c index d4246c9dceae..8343144ba1cd 100644 --- a/drivers/gpu/drm/mediatek/mtk_drm_fb.c +++ b/drivers/gpu/drm/mediatek/mtk_drm_fb.c @@ -44,6 +44,7 @@ struct drm_gem_object *mtk_fb_get_gem_obj(struct drm_framebuffer *fb) } static int mtk_drm_fb_create_handle(struct drm_framebuffer *fb, + unsigned int format_plane_index, struct drm_file *file_priv, unsigned int *handle) { diff --git a/drivers/gpu/drm/msm/msm_fb.c b/drivers/gpu/drm/msm/msm_fb.c index 5cf165c9c3a9..de92fc8a7a1c 100644 --- a/drivers/gpu/drm/msm/msm_fb.c +++ b/drivers/gpu/drm/msm/msm_fb.c @@ -30,12 +30,15 @@ struct msm_framebuffer { static int msm_framebuffer_create_handle(struct drm_framebuffer *fb, + unsigned int format_plane_index, struct drm_file *file_priv, unsigned int *handle) { struct msm_framebuffer *msm_fb = to_msm_framebuffer(fb); + if (format_plane_index >= MAX_PLANE) + return -ENOENT; return drm_gem_handle_create(file_priv, - msm_fb->planes[0], handle); + msm_fb->planes[format_plane_index], handle); } static void msm_framebuffer_destroy(struct drm_framebuffer *fb) diff --git a/drivers/gpu/drm/nouveau/nouveau_display.c b/drivers/gpu/drm/nouveau/nouveau_display.c index 72fdba1a1c5d..bc30c0d3d9cd 100644 --- a/drivers/gpu/drm/nouveau/nouveau_display.c +++ b/drivers/gpu/drm/nouveau/nouveau_display.c @@ -237,6 +237,7 @@ nouveau_user_framebuffer_destroy(struct drm_framebuffer *drm_fb) static int nouveau_user_framebuffer_create_handle(struct drm_framebuffer *drm_fb, + unsigned int format_plane_index, struct drm_file *file_priv, unsigned int *handle) { diff --git a/drivers/gpu/drm/omapdrm/omap_fb.c b/drivers/gpu/drm/omapdrm/omap_fb.c index 29dc677dd4d3..a982c72a773e 100644 --- a/drivers/gpu/drm/omapdrm/omap_fb.c +++ b/drivers/gpu/drm/omapdrm/omap_fb.c @@ -90,12 +90,15 @@ struct omap_framebuffer { }; static int omap_framebuffer_create_handle(struct drm_framebuffer *fb, + unsigned int format_plane_index, struct drm_file *file_priv, unsigned int *handle) { struct omap_framebuffer *omap_fb = to_omap_framebuffer(fb); + if (format_plane_index >= 4 || !omap_fb->planes[format_plane_index]) + return -ENOENT; return drm_gem_handle_create(file_priv, - omap_fb->planes[0].bo, handle); + omap_fb->planes[format_plane_index].bo, handle); } static void omap_framebuffer_destroy(struct drm_framebuffer *fb) diff --git a/drivers/gpu/drm/radeon/radeon_display.c b/drivers/gpu/drm/radeon/radeon_display.c index aea8b62835a4..2188e6341cd9 100644 --- a/drivers/gpu/drm/radeon/radeon_display.c +++ b/drivers/gpu/drm/radeon/radeon_display.c @@ -1306,8 +1306,9 @@ static void radeon_user_framebuffer_destroy(struct drm_framebuffer *fb) } static int radeon_user_framebuffer_create_handle(struct drm_framebuffer *fb, - struct drm_file *file_priv, - unsigned int *handle) + unsigned int plane_index, + struct drm_file *file_priv, + unsigned int *handle) { struct radeon_framebuffer *radeon_fb = to_radeon_framebuffer(fb); diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_fb.c b/drivers/gpu/drm/rockchip/rockchip_drm_fb.c index c9ccdf8f44bb..206d93249519 100644 --- a/drivers/gpu/drm/rockchip/rockchip_drm_fb.c +++ b/drivers/gpu/drm/rockchip/rockchip_drm_fb.c @@ -55,13 +55,15 @@ static void rockchip_drm_fb_destroy(struct drm_framebuffer *fb) } static int rockchip_drm_fb_create_handle(struct drm_framebuffer *fb, + unsigned int format_plane_index, struct drm_file *file_priv, unsigned int *handle) { struct rockchip_drm_fb *rockchip_fb = to_rockchip_fb(fb); - + if (format_plane_index >= ROCKCHIP_MAX_FB_BUFFER) + return -ENOENT; return drm_gem_handle_create(file_priv, - rockchip_fb->obj[0], handle); + rockchip_fb->obj[format_plane_index], handle); } static int rockchip_drm_fb_dirty(struct drm_framebuffer *fb, diff --git a/drivers/gpu/drm/tegra/fb.c b/drivers/gpu/drm/tegra/fb.c index f142f6a4db25..ff206b143503 100644 --- a/drivers/gpu/drm/tegra/fb.c +++ b/drivers/gpu/drm/tegra/fb.c @@ -81,11 +81,16 @@ static void tegra_fb_destroy(struct drm_framebuffer *framebuffer) } static int tegra_fb_create_handle(struct drm_framebuffer *framebuffer, + unsigned int format_plane_index, struct drm_file *file, unsigned int *handle) { struct tegra_fb *fb = to_tegra_fb(framebuffer); - - return drm_gem_handle_create(file, &fb->planes[0]->gem, handle); + if (format_plane_index >= fb->num_planes || + !fb->planes[format_plane_index]) + return -ENOENT; + return drm_gem_handle_create(file, + &fb->planes[format_plane_index]->gem, + handle); } static const struct drm_framebuffer_funcs tegra_fb_funcs = { diff --git a/include/drm/drm_framebuffer.h b/include/drm/drm_framebuffer.h index dd1e3e99dcff..2fb398cb4646 100644 --- a/include/drm/drm_framebuffer.h +++ b/include/drm/drm_framebuffer.h @@ -66,6 +66,7 @@ struct drm_framebuffer_funcs { * 0 on success or a negative error code on failure. */ int (*create_handle)(struct drm_framebuffer *fb, + unsigned int plane_index, struct drm_file *file_priv, unsigned int *handle); /** diff --git a/include/uapi/drm/drm.h b/include/uapi/drm/drm.h index b2c52843bc70..c81c75335cca 100644 --- a/include/uapi/drm/drm.h +++ b/include/uapi/drm/drm.h @@ -814,6 +814,8 @@ extern "C" { #define DRM_IOCTL_MODE_CREATEPROPBLOB DRM_IOWR(0xBD, struct drm_mode_create_blob) #define DRM_IOCTL_MODE_DESTROYPROPBLOB DRM_IOWR(0xBE, struct drm_mode_destroy_blob) +#define DRM_IOCTL_MODE_GETFB2 DRM_IOWR(0xC4, struct drm_mode_fb_cmd2) + /** * Device specific ioctls should only be in their respective headers * The device specific ioctl range is from 0x40 to 0x9f.