From patchwork Thu Feb 22 20:06:49 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Noralf_Tr=C3=B8nnes?= X-Patchwork-Id: 10236315 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 EE03660349 for ; Thu, 22 Feb 2018 20:15:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E4E1728BFE for ; Thu, 22 Feb 2018 20:15:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D916728DAC; Thu, 22 Feb 2018 20:15:54 +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.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=unavailable 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 9D95328BFE for ; Thu, 22 Feb 2018 20:15:54 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 162366EBE8; Thu, 22 Feb 2018 20:15:50 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from smtp.domeneshop.no (smtp.domeneshop.no [IPv6:2a01:5b40:0:3005::1]) by gabe.freedesktop.org (Postfix) with ESMTPS id 1CBB46ED7C for ; Thu, 22 Feb 2018 20:15:47 +0000 (UTC) Received: from 211.81-166-168.customer.lyse.net ([81.166.168.211]:34576 helo=localhost.localdomain) by smtp.domeneshop.no with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_CBC_SHA256:128) (Exim 4.84_2) (envelope-from ) id 1eox93-0004nQ-2v; Thu, 22 Feb 2018 21:07:09 +0100 From: =?UTF-8?q?Noralf=20Tr=C3=B8nnes?= To: dri-devel@lists.freedesktop.org Date: Thu, 22 Feb 2018 21:06:49 +0100 Message-Id: <20180222200653.19453-9-noralf@tronnes.org> X-Mailer: git-send-email 2.15.1 In-Reply-To: <20180222200653.19453-1-noralf@tronnes.org> References: <20180222200653.19453-1-noralf@tronnes.org> MIME-Version: 1.0 Subject: [Intel-gfx] [RFC v3 08/12] drm/framebuffer: Add drm_mode_can_dirtyfb() X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: daniel.vetter@ffwll.ch, intel-gfx@lists.freedesktop.org, =?UTF-8?q?Noralf=20Tr=C3=B8nnes?= , laurent.pinchart@ideasonboard.com, dh.herrmann@gmail.com Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Virus-Scanned: ClamAV using ClamSMTP Add a function so the generic fbdev client can check if the framebuffer does flushing. This is needed to set up deferred I/O. Signed-off-by: Noralf Trønnes --- drivers/gpu/drm/drm_framebuffer.c | 31 +++++++++++++++++++++++++++++++ include/drm/drm_framebuffer.h | 2 ++ 2 files changed, 33 insertions(+) diff --git a/drivers/gpu/drm/drm_framebuffer.c b/drivers/gpu/drm/drm_framebuffer.c index ad8f7d308656..a659cff45844 100644 --- a/drivers/gpu/drm/drm_framebuffer.c +++ b/drivers/gpu/drm/drm_framebuffer.c @@ -600,6 +600,37 @@ int drm_mode_dirtyfb_ioctl(struct drm_device *dev, return drm_mode_dirtyfb(dev, data, file_priv, true); } +/** + * drm_mode_can_dirtyfb - check if the FB does flushing + * @dev: drm device + * @fb_id: Framebuffer id + * @file_priv: drm file + * + * Returns: + * True if the framebuffer does flushing, false otherwise. + */ +bool drm_mode_can_dirtyfb(struct drm_device *dev, u32 fb_id, + struct drm_file *file_priv) +{ + struct drm_framebuffer *fb; + bool ret = false; + + if (!drm_core_check_feature(dev, DRIVER_MODESET)) + return false; + + fb = drm_framebuffer_lookup(dev, file_priv, fb_id); + if (!fb) + return false; + + if (fb->funcs->dirty) + ret = true; + + drm_framebuffer_put(fb); + + return ret; +} +EXPORT_SYMBOL(drm_mode_can_dirtyfb); + /** * drm_fb_release - remove and free the FBs on this file * @priv: drm file for the ioctl diff --git a/include/drm/drm_framebuffer.h b/include/drm/drm_framebuffer.h index c50502c656e5..05d170f4e215 100644 --- a/include/drm/drm_framebuffer.h +++ b/include/drm/drm_framebuffer.h @@ -216,6 +216,8 @@ struct drm_framebuffer *drm_framebuffer_lookup(struct drm_device *dev, void drm_framebuffer_remove(struct drm_framebuffer *fb); void drm_framebuffer_cleanup(struct drm_framebuffer *fb); void drm_framebuffer_unregister_private(struct drm_framebuffer *fb); +bool drm_mode_can_dirtyfb(struct drm_device *dev, u32 fb_id, + struct drm_file *file_priv); /** * drm_framebuffer_get - acquire a framebuffer reference