From patchwork Sun Dec 31 13:58:41 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: 10138169 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 721B86020A for ; Sun, 31 Dec 2017 14:00:17 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6073D28859 for ; Sun, 31 Dec 2017 14:00:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5E46B28866; Sun, 31 Dec 2017 14:00:17 +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 D61CE28859 for ; Sun, 31 Dec 2017 14:00:16 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 0016289CA1; Sun, 31 Dec 2017 13:59:41 +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 A7DB689C33; Sun, 31 Dec 2017 13:59:26 +0000 (UTC) Received: from 211.81-166-168.customer.lyse.net ([81.166.168.211]:48182 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 1eVe96-0003Z0-MH; Sun, 31 Dec 2017 14:59:24 +0100 From: =?UTF-8?q?Noralf=20Tr=C3=B8nnes?= To: dri-devel@lists.freedesktop.org Date: Sun, 31 Dec 2017 14:58:41 +0100 Message-Id: <20171231135843.10760-6-noralf@tronnes.org> X-Mailer: git-send-email 2.14.2 In-Reply-To: <20171231135843.10760-1-noralf@tronnes.org> References: <20171231135843.10760-1-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] [RFC 5/7] drm: Handle fbdev emulation in core 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 Prepare for generic fbdev emulation by letting DRM core work directly with the fbdev compatibility layer. This is done by adding new fbdev helper vtable callbacks for restore, hotplug_event, unregister and release. Signed-off-by: Noralf Trønnes --- drivers/gpu/drm/drm_file.c | 12 +++++++++++- drivers/gpu/drm/drm_mode_config.c | 10 ++++++++++ drivers/gpu/drm/drm_probe_helper.c | 4 ++++ include/drm/drm_fb_helper.h | 33 +++++++++++++++++++++++++++++++++ 4 files changed, 58 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/drm_file.c b/drivers/gpu/drm/drm_file.c index d208faade27e..67f0309e22ff 100644 --- a/drivers/gpu/drm/drm_file.c +++ b/drivers/gpu/drm/drm_file.c @@ -35,6 +35,7 @@ #include #include +#include #include #include @@ -439,10 +440,19 @@ static void drm_legacy_dev_reinit(struct drm_device *dev) void drm_lastclose(struct drm_device * dev) { + struct drm_fb_helper *fb_helper = dev->fb_helper; + int ret; + DRM_DEBUG("\n"); - if (dev->driver->lastclose) + if (dev->driver->lastclose) { dev->driver->lastclose(dev); + } else if (fb_helper && fb_helper->funcs && fb_helper->funcs->restore) { + ret = fb_helper->funcs->restore(fb_helper); + if (ret) + DRM_ERROR("Failed to restore fbdev: %d\n", ret); + } + DRM_DEBUG("driver lastclose completed\n"); if (drm_core_check_feature(dev, DRIVER_LEGACY)) diff --git a/drivers/gpu/drm/drm_mode_config.c b/drivers/gpu/drm/drm_mode_config.c index bc5c46306b3d..260eb1730244 100644 --- a/drivers/gpu/drm/drm_mode_config.c +++ b/drivers/gpu/drm/drm_mode_config.c @@ -21,6 +21,7 @@ */ #include +#include #include #include @@ -61,6 +62,11 @@ int drm_modeset_register_all(struct drm_device *dev) void drm_modeset_unregister_all(struct drm_device *dev) { + struct drm_fb_helper *fb_helper = dev->fb_helper; + + if (fb_helper && fb_helper->funcs && fb_helper->funcs->unregister) + fb_helper->funcs->unregister(fb_helper); + drm_connector_unregister_all(dev); drm_encoder_unregister_all(dev); drm_crtc_unregister_all(dev); @@ -408,6 +414,7 @@ EXPORT_SYMBOL(drm_mode_config_init); */ void drm_mode_config_cleanup(struct drm_device *dev) { + struct drm_fb_helper *fb_helper = dev->fb_helper; struct drm_connector *connector; struct drm_connector_list_iter conn_iter; struct drm_crtc *crtc, *ct; @@ -417,6 +424,9 @@ void drm_mode_config_cleanup(struct drm_device *dev) struct drm_property_blob *blob, *bt; struct drm_plane *plane, *plt; + if (fb_helper && fb_helper->funcs && fb_helper->funcs->release) + fb_helper->funcs->release(fb_helper); + list_for_each_entry_safe(encoder, enct, &dev->mode_config.encoder_list, head) { encoder->funcs->destroy(encoder); diff --git a/drivers/gpu/drm/drm_probe_helper.c b/drivers/gpu/drm/drm_probe_helper.c index 555fbe54d6e2..9d8b0ba54173 100644 --- a/drivers/gpu/drm/drm_probe_helper.c +++ b/drivers/gpu/drm/drm_probe_helper.c @@ -559,10 +559,14 @@ EXPORT_SYMBOL(drm_helper_probe_single_connector_modes); */ void drm_kms_helper_hotplug_event(struct drm_device *dev) { + struct drm_fb_helper *fb_helper = dev->fb_helper; + /* send a uevent + call fbdev */ drm_sysfs_hotplug_event(dev); if (dev->mode_config.funcs->output_poll_changed) dev->mode_config.funcs->output_poll_changed(dev); + else if (fb_helper && fb_helper->funcs && fb_helper->funcs->hotplug_event) + fb_helper->funcs->hotplug_event(fb_helper); } EXPORT_SYMBOL(drm_kms_helper_hotplug_event); diff --git a/include/drm/drm_fb_helper.h b/include/drm/drm_fb_helper.h index 5d4ccc3f28aa..f5ea79bbb831 100644 --- a/include/drm/drm_fb_helper.h +++ b/include/drm/drm_fb_helper.h @@ -125,6 +125,39 @@ struct drm_fb_helper_funcs { struct drm_display_mode **modes, struct drm_fb_offset *offsets, bool *enabled, int width, int height); + + /** + * @restore: + * + * Optional callback for restoring fbdev emulation. + * Called by drm_lastclose() if &drm_driver->lastclose is not set. + */ + int (*restore)(struct drm_fb_helper *fb_helper); + + /** + * @hotplug_event: + * + * Optional callback for hotplug events. + * Called by drm_kms_helper_hotplug_event() if + * &drm_mode_config_funcs->output_poll_changed is not set. + */ + int (*hotplug_event)(struct drm_fb_helper *fb_helper); + + /** + * @unregister: + * + * Optional callback for unregistrering fbdev emulation. + * Called by drm_dev_unregister(). + */ + void (*unregister)(struct drm_fb_helper *fb_helper); + + /** + * @release: + * + * Optional callback for releasing fbdev emulation resources. + * Called by drm_mode_config_cleanup(). + */ + void (*release)(struct drm_fb_helper *fb_helper); }; struct drm_fb_helper_connector {