From patchwork Fri Aug 5 15:44:43 2016 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: 9265511 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 6539A6048B for ; Fri, 5 Aug 2016 15:45:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5658728454 for ; Fri, 5 Aug 2016 15:45:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4B01028456; Fri, 5 Aug 2016 15:45:14 +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 D738928454 for ; Fri, 5 Aug 2016 15:45:13 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id E4E126EBCD; Fri, 5 Aug 2016 15:45:11 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@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 E74326EBCE for ; Fri, 5 Aug 2016 15:45:10 +0000 (UTC) Received: from 211.81-166-168.customer.lyse.net ([81.166.168.211]:51025 helo=localhost.localdomain) by smtp.domeneshop.no with esmtpsa (TLS1.1:DHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.80) (envelope-from ) id 1bVhJ7-0003oM-D0; Fri, 05 Aug 2016 17:45:09 +0200 From: =?UTF-8?q?Noralf=20Tr=C3=B8nnes?= To: dri-devel@lists.freedesktop.org Subject: [PATCH v2 3/3] drm: simpledrm: honour remove_conflicting_framebuffers() Date: Fri, 5 Aug 2016 17:44:43 +0200 Message-Id: <1470411883-3534-4-git-send-email-noralf@tronnes.org> X-Mailer: git-send-email 2.8.2 In-Reply-To: <1470411883-3534-1-git-send-email-noralf@tronnes.org> References: <1470411883-3534-1-git-send-email-noralf@tronnes.org> MIME-Version: 1.0 Cc: linux-kernel@vger.kernel.org X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP There is currently no non-fbdev mechanism in place to kick out simpledrm when the real hw-driver is probed. As a stop gap until that is in place, honour remove_conflicting_framebuffers() and delete the simple-framebuffer platform device when it's called. Signed-off-by: Noralf Trønnes --- drivers/gpu/drm/simpledrm/Kconfig | 5 ++++ drivers/gpu/drm/simpledrm/Makefile | 2 +- drivers/gpu/drm/simpledrm/simpledrm.h | 9 +++++++ drivers/gpu/drm/simpledrm/simpledrm_drv.c | 3 +++ drivers/gpu/drm/simpledrm/simpledrm_fbdev.c | 40 +++++++++++++++++++++++++++++ 5 files changed, 58 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/simpledrm/Kconfig b/drivers/gpu/drm/simpledrm/Kconfig index 9454536..6205b17 100644 --- a/drivers/gpu/drm/simpledrm/Kconfig +++ b/drivers/gpu/drm/simpledrm/Kconfig @@ -16,6 +16,11 @@ config DRM_SIMPLEDRM If fbdev support is enabled, this driver will also provide an fbdev compatibility layer. + WARNING + fbdev must be enabled for simpledrm to disable itself when a real + hw-driver is probed. It relies on remove_conflicting_framebuffers() + to be called by the hw-driver. + If unsure, say Y. To compile this driver as a module, choose M here: the diff --git a/drivers/gpu/drm/simpledrm/Makefile b/drivers/gpu/drm/simpledrm/Makefile index 7087245..4b4bcdd 100644 --- a/drivers/gpu/drm/simpledrm/Makefile +++ b/drivers/gpu/drm/simpledrm/Makefile @@ -1,5 +1,5 @@ simpledrm-y := simpledrm_drv.o simpledrm_kms.o simpledrm_gem.o \ simpledrm_damage.o -simpledrm-$(CONFIG_DRM_FBDEV_EMULATION) += simpledrm_fbdev.o +simpledrm-$(CONFIG_FB) += simpledrm_fbdev.o obj-$(CONFIG_DRM_SIMPLEDRM) := simpledrm.o diff --git a/drivers/gpu/drm/simpledrm/simpledrm.h b/drivers/gpu/drm/simpledrm/simpledrm.h index eb18d59..16f7e03 100644 --- a/drivers/gpu/drm/simpledrm/simpledrm.h +++ b/drivers/gpu/drm/simpledrm/simpledrm.h @@ -100,6 +100,8 @@ struct sdrm_framebuffer { void sdrm_fbdev_init(struct sdrm_device *sdrm); void sdrm_fbdev_cleanup(struct sdrm_device *sdrm); void sdrm_fbdev_set_suspend(struct sdrm_device *sdrm, int state); +void sdrm_fbdev_kickout_init(void); +void sdrm_fbdev_kickout_exit(void); #else @@ -115,6 +117,13 @@ static inline void sdrm_fbdev_set_suspend(struct sdrm_device *sdrm, int state) { } +static inline void sdrm_fbdev_kickout_init(void) +{ +} + +static inline void sdrm_fbdev_kickout_exit(void) +{ +} #endif #endif /* SDRM_DRV_H */ diff --git a/drivers/gpu/drm/simpledrm/simpledrm_drv.c b/drivers/gpu/drm/simpledrm/simpledrm_drv.c index 88ad717c..a329e4c 100644 --- a/drivers/gpu/drm/simpledrm/simpledrm_drv.c +++ b/drivers/gpu/drm/simpledrm/simpledrm_drv.c @@ -526,12 +526,15 @@ static int __init sdrm_init(void) } } + sdrm_fbdev_kickout_init(); + return 0; } module_init(sdrm_init); static void __exit sdrm_exit(void) { + sdrm_fbdev_kickout_exit(); platform_driver_unregister(&sdrm_simplefb_driver); } module_exit(sdrm_exit); diff --git a/drivers/gpu/drm/simpledrm/simpledrm_fbdev.c b/drivers/gpu/drm/simpledrm/simpledrm_fbdev.c index b83646b..0d64352 100644 --- a/drivers/gpu/drm/simpledrm/simpledrm_fbdev.c +++ b/drivers/gpu/drm/simpledrm/simpledrm_fbdev.c @@ -24,6 +24,7 @@ #include "simpledrm.h" struct sdrm_fbdev { + struct sdrm_device *sdrm; u32 palette[16]; }; @@ -76,7 +77,16 @@ void sdrm_fbdev_init(struct sdrm_device *sdrm) if (!info) goto err_out; + info->apertures = alloc_apertures(1); + if (!info->apertures) + goto err_free; + + info->apertures->ranges[0].base = sdrm->fb_base; + info->apertures->ranges[0].size = sdrm->fb_size; + fb = info->par; + fb->sdrm = sdrm; + info->flags = FBINFO_DEFAULT | FBINFO_MISC_FIRMWARE | FBINFO_CAN_FORCE_OUTPUT; info->pseudo_palette = fb->palette; @@ -158,3 +168,33 @@ void sdrm_fbdev_set_suspend(struct sdrm_device *sdrm, int state) fb_set_suspend(sdrm->fbdev, state); console_unlock(); } + +static int sdrm_fbdev_event_notify(struct notifier_block *self, + unsigned long action, void *data) +{ + struct fb_event *event = data; + struct fb_info *info = event->info; + struct sdrm_fbdev *sfb = info->par; + + if (sfb && sfb->sdrm && sfb->sdrm->fbdev == info && + action == FB_EVENT_FB_UNREGISTERED) { + sfb->sdrm->fbdev = NULL; /* don't run sdrm_fbdev_cleanup() */ + platform_device_del(sfb->sdrm->ddev->platformdev); + } + + return NOTIFY_DONE; +} + +static struct notifier_block sdrm_fbdev_event_notifier = { + .notifier_call = sdrm_fbdev_event_notify, +}; + +void sdrm_fbdev_kickout_init(void) +{ + fb_register_client(&sdrm_fbdev_event_notifier); +} + +void sdrm_fbdev_kickout_exit(void) +{ + fb_unregister_client(&sdrm_fbdev_event_notifier); +}