From patchwork Mon Sep 11 14:31:58 2017 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: 9947473 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 D2F62603F4 for ; Mon, 11 Sep 2017 14:33:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C257028505 for ; Mon, 11 Sep 2017 14:33:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C0C352887A; Mon, 11 Sep 2017 14:33:11 +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=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 D5E5628505 for ; Mon, 11 Sep 2017 14:32:48 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 7D1496E3FE; Mon, 11 Sep 2017 14:32:21 +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 805CD6E3DF; Mon, 11 Sep 2017 14:32:15 +0000 (UTC) Received: from 211.81-166-168.customer.lyse.net ([81.166.168.211]:41326 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 1drPkz-0000vg-Od; Mon, 11 Sep 2017 16:32:13 +0200 From: =?UTF-8?q?Noralf=20Tr=C3=B8nnes?= To: dri-devel@lists.freedesktop.org Date: Mon, 11 Sep 2017 16:31:58 +0200 Message-Id: <1505140322-17416-5-git-send-email-noralf@tronnes.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1505140322-17416-1-git-send-email-noralf@tronnes.org> References: <1505140322-17416-1-git-send-email-noralf@tronnes.org> MIME-Version: 1.0 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 Subject: [Intel-gfx] [PATCH 4/8] drm/fb-helper: Allocate a drm_file X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Virus-Scanned: ClamAV using ClamSMTP Allocate a drm_file so drivers can use drm_framebuffer_create_dumb() to create a buffer. The framebuffer is reaped automtically in drm_fb_helper_fini(). Signed-off-by: Noralf Trønnes --- drivers/gpu/drm/drm_fb_helper.c | 22 ++++++++++++++++++++-- include/drm/drm_fb_helper.h | 9 +++++++++ 2 files changed, 29 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c index 6a31d13..a04bdf9 100644 --- a/drivers/gpu/drm/drm_fb_helper.c +++ b/drivers/gpu/drm/drm_fb_helper.c @@ -35,6 +35,7 @@ #include #include #include +#include #include #include #include @@ -902,6 +903,7 @@ EXPORT_SYMBOL(drm_fb_helper_unregister_fbi); * * This cleans up all remaining resources associated with @fb_helper. Must be * called after drm_fb_helper_unlink_fbi() was called. + * drm_framebuffer_create_dumb() created framebuffers will be destroyed. */ void drm_fb_helper_fini(struct drm_fb_helper *fb_helper) { @@ -932,6 +934,7 @@ void drm_fb_helper_fini(struct drm_fb_helper *fb_helper) mutex_destroy(&fb_helper->lock); drm_fb_helper_crtc_free(fb_helper); + drm_file_free(fb_helper->file); } EXPORT_SYMBOL(drm_fb_helper_fini); @@ -2465,6 +2468,16 @@ __drm_fb_helper_initial_config_and_unlock(struct drm_fb_helper *fb_helper, unsigned int width, height; int ret; + fb_helper->file = drm_file_alloc(dev->primary); + if (IS_ERR(fb_helper->file)) { + ret = PTR_ERR(fb_helper->file); + fb_helper->file = NULL; + mutex_unlock(&fb_helper->lock); + return ret; + } + + drm_dropmaster_ioctl(dev, NULL, fb_helper->file); + width = dev->mode_config.max_width; height = dev->mode_config.max_height; @@ -2478,7 +2491,7 @@ __drm_fb_helper_initial_config_and_unlock(struct drm_fb_helper *fb_helper, } mutex_unlock(&fb_helper->lock); - return ret; + goto err_free_file; } drm_setup_crtcs_fb(fb_helper); @@ -2494,7 +2507,7 @@ __drm_fb_helper_initial_config_and_unlock(struct drm_fb_helper *fb_helper, ret = register_framebuffer(info); if (ret < 0) - return ret; + goto err_free_file; dev_info(dev->dev, "fb%d: %s frame buffer device\n", info->node, info->fix.id); @@ -2507,6 +2520,11 @@ __drm_fb_helper_initial_config_and_unlock(struct drm_fb_helper *fb_helper, mutex_unlock(&kernel_fb_helper_lock); return 0; + +err_free_file: + drm_file_free(fb_helper->file); + + return ret; } /** diff --git a/include/drm/drm_fb_helper.h b/include/drm/drm_fb_helper.h index 33fe959..89757ff 100644 --- a/include/drm/drm_fb_helper.h +++ b/include/drm/drm_fb_helper.h @@ -154,6 +154,15 @@ struct drm_fb_helper_connector { struct drm_fb_helper { struct drm_framebuffer *fb; struct drm_device *dev; + + /** + * @file: + * + * DRM file that can be used with drm_framebuffer_create_dumb() to + * create a framebuffer to back fbdev. + */ + struct drm_file *file; + int crtc_count; struct drm_fb_helper_crtc *crtc_info; int connector_count;