From patchwork Thu Jan 2 21:28:19 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Russell King X-Patchwork-Id: 3431701 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 11E5E9F2E9 for ; Fri, 3 Jan 2014 15:22:55 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id A10F72010C for ; Fri, 3 Jan 2014 15:22:53 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id A1EFA20108 for ; Fri, 3 Jan 2014 15:22:52 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id ED36DFAAB3; Fri, 3 Jan 2014 07:22:17 -0800 (PST) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from pandora.arm.linux.org.uk (gw-1.arm.linux.org.uk [78.32.30.217]) by gabe.freedesktop.org (Postfix) with ESMTP id D1760FB8EC for ; Thu, 2 Jan 2014 13:31:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=arm.linux.org.uk; s=pandora; h=Date:Sender:Message-Id:Subject:Cc:To:From:References:In-Reply-To; bh=SZDSso/x6M56tFpReZQ8Wwh0iXCjMq9vofGbyH//WdE=; b=d3QhgWyg2znURRG/h0RAYKukBJxibbpkk+biUktR1ZRJNbwpDuDawzgyKrctj5wFnsXL9elzH+rNFm0rcbaY74+DSTrsfgWnr7qyvkl/mSeaj8zW5E0tiu9j3JZmF7OXHHYw7qj7yzla6wKyZr71TSJ851DMrFzwn1O56kT1pLY=; Received: from [2001:4d48:ad52:3201:222:68ff:fe15:37dd] (port=58613 helo=rmk-PC.arm.linux.org.uk) by pandora.arm.linux.org.uk with esmtpsa (TLSv1:AES256-SHA:256) (Exim 4.76) (envelope-from ) id 1VypoR-0004B6-LY; Thu, 02 Jan 2014 21:28:19 +0000 Received: from rmk by rmk-PC.arm.linux.org.uk with local (Exim 4.76) (envelope-from ) id 1VypoR-0007FW-4q; Thu, 02 Jan 2014 21:28:19 +0000 In-Reply-To: <20140102212528.GD7383@n2100.arm.linux.org.uk> References: <20140102212528.GD7383@n2100.arm.linux.org.uk> From: Russell King To: David Airlie , Greg Kroah-Hartman , Sascha Hauer , Shawn Guo Subject: [PATCH RFC 30/46] imx-drm: remove separate imx-fbdev Message-Id: Date: Thu, 02 Jan 2014 21:28:19 +0000 X-Mailman-Approved-At: Fri, 03 Jan 2014 07:21:54 -0800 Cc: devel@driverdev.osuosl.org, dri-devel@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: dri-devel-bounces@lists.freedesktop.org Errors-To: dri-devel-bounces@lists.freedesktop.org X-Spam-Status: No, score=-4.6 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Now that we know when the components of the imx-drm subsystem will be initialised, we can move the fbdev helper initialisation and teardown into imx-drm-core. This gives us the required ordering that DRM wants in both driver load and unload methods. We can also stop exporting the imx_drm_device_get() and imx_drm_device_put() methods; nothing but the fbdev helper was making use of these. Signed-off-by: Russell King --- drivers/staging/imx-drm/Makefile | 1 - drivers/staging/imx-drm/imx-drm-core.c | 43 +++++++++++++----- drivers/staging/imx-drm/imx-drm.h | 3 - drivers/staging/imx-drm/imx-fbdev.c | 74 -------------------------------- 4 files changed, 31 insertions(+), 90 deletions(-) delete mode 100644 drivers/staging/imx-drm/imx-fbdev.c diff --git a/drivers/staging/imx-drm/Makefile b/drivers/staging/imx-drm/Makefile index 4677585b5ad5..5239f908ceec 100644 --- a/drivers/staging/imx-drm/Makefile +++ b/drivers/staging/imx-drm/Makefile @@ -6,7 +6,6 @@ obj-$(CONFIG_DRM_IMX) += imxdrm.o obj-$(CONFIG_DRM_IMX_PARALLEL_DISPLAY) += parallel-display.o obj-$(CONFIG_DRM_IMX_TVE) += imx-tve.o obj-$(CONFIG_DRM_IMX_LDB) += imx-ldb.o -obj-$(CONFIG_DRM_IMX_FB_HELPER) += imx-fbdev.o obj-$(CONFIG_DRM_IMX_IPUV3_CORE) += ipu-v3/ imx-ipuv3-crtc-objs := ipuv3-crtc.o ipuv3-plane.o diff --git a/drivers/staging/imx-drm/imx-drm-core.c b/drivers/staging/imx-drm/imx-drm-core.c index d5bf4a4646a3..31bc8d9c49be 100644 --- a/drivers/staging/imx-drm/imx-drm-core.c +++ b/drivers/staging/imx-drm/imx-drm-core.c @@ -70,6 +70,10 @@ struct imx_drm_connector { struct module *owner; }; +static int legacyfb_depth = 16; +module_param(legacyfb_depth, int, 0444); + +static void imx_drm_device_put(void); static struct imx_drm_device *__imx_drm_device(void); int imx_drm_crtc_id(struct imx_drm_crtc *crtc) @@ -82,14 +86,21 @@ static void imx_drm_driver_lastclose(struct drm_device *drm) { struct imx_drm_device *imxdrm = drm->dev_private; +#if IS_ENABLED(CONFIG_DRM_IMX_FB_HELPER) if (imxdrm->fbhelper) drm_fbdev_cma_restore_mode(imxdrm->fbhelper); +#endif } static int imx_drm_driver_unload(struct drm_device *drm) { struct imx_drm_device *imxdrm = drm->dev_private; +#if IS_ENABLED(CONFIG_DRM_IMX_FB_HELPER) + if (imxdrm->fbhelper) + drm_fbdev_cma_fini(imxdrm->fbhelper); +#endif + component_unbind_all(drm->dev, drm); imx_drm_device_put(); @@ -225,7 +236,7 @@ static struct imx_drm_device *__imx_drm_device(void) return imx_drm_device; } -struct drm_device *imx_drm_device_get(void) +static struct drm_device *imx_drm_device_get(void) { struct imx_drm_device *imxdrm = __imx_drm_device(); struct imx_drm_encoder *enc; @@ -273,9 +284,8 @@ struct drm_device *imx_drm_device_get(void) return NULL; } -EXPORT_SYMBOL_GPL(imx_drm_device_get); -void imx_drm_device_put(void) +static void imx_drm_device_put(void) { struct imx_drm_device *imxdrm = __imx_drm_device(); struct imx_drm_encoder *enc; @@ -295,7 +305,6 @@ void imx_drm_device_put(void) mutex_unlock(&imxdrm->mutex); } -EXPORT_SYMBOL_GPL(imx_drm_device_put); static int drm_mode_group_reinit(struct drm_device *dev) { @@ -449,6 +458,24 @@ static int imx_drm_driver_load(struct drm_device *drm, unsigned long flags) } } + /* + * All components are now initialised, so setup the fb helper. + * The fb helper takes copies of key hardware information, so the + * crtcs/connectors/encoders must not change after this point. + */ +#if IS_ENABLED(CONFIG_DRM_IMX_FB_HELPER) + if (legacyfb_depth != 16 && legacyfb_depth != 32) { + dev_warn(drm->dev, "Invalid legacyfb_depth. Defaulting to 16bpp\n"); + legacyfb_depth = 16; + } + imxdrm->fbhelper = drm_fbdev_cma_init(drm, legacyfb_depth, + drm->mode_config.num_crtc, 4); + if (IS_ERR(imxdrm->fbhelper)) { + ret = PTR_ERR(imxdrm->fbhelper); + imxdrm->fbhelper = NULL; + goto err_unbind; + } +#endif return 0; err_unbind: @@ -766,14 +793,6 @@ int imx_drm_add_connector(struct drm_connector *connector, } EXPORT_SYMBOL_GPL(imx_drm_add_connector); -void imx_drm_fb_helper_set(struct drm_fbdev_cma *fbdev_helper) -{ - struct imx_drm_device *imxdrm = __imx_drm_device(); - - imxdrm->fbhelper = fbdev_helper; -} -EXPORT_SYMBOL_GPL(imx_drm_fb_helper_set); - /* * imx_drm_remove_connector - remove a connector */ diff --git a/drivers/staging/imx-drm/imx-drm.h b/drivers/staging/imx-drm/imx-drm.h index e3ca0c6b6a39..d1fb1146240e 100644 --- a/drivers/staging/imx-drm/imx-drm.h +++ b/drivers/staging/imx-drm/imx-drm.h @@ -54,13 +54,10 @@ void imx_drm_mode_config_init(struct drm_device *drm); struct drm_gem_cma_object *imx_drm_fb_get_obj(struct drm_framebuffer *fb); -struct drm_device *imx_drm_device_get(void); -void imx_drm_device_put(void); int imx_drm_panel_format_pins(struct drm_encoder *encoder, u32 interface_pix_fmt, int hsync_pin, int vsync_pin); int imx_drm_panel_format(struct drm_encoder *encoder, u32 interface_pix_fmt); -void imx_drm_fb_helper_set(struct drm_fbdev_cma *fbdev_helper); struct device_node; diff --git a/drivers/staging/imx-drm/imx-fbdev.c b/drivers/staging/imx-drm/imx-fbdev.c deleted file mode 100644 index 8331739c3d08..000000000000 --- a/drivers/staging/imx-drm/imx-fbdev.c +++ /dev/null @@ -1,74 +0,0 @@ -/* - * i.MX drm driver - * - * Copyright (C) 2012 Sascha Hauer, Pengutronix - * - * Based on Samsung Exynos code - * - * Copyright (c) 2011 Samsung Electronics Co., Ltd. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - */ -#include -#include -#include -#include -#include - -#include "imx-drm.h" - -#define MAX_CONNECTOR 4 -#define PREFERRED_BPP 16 - -static struct drm_fbdev_cma *fbdev_cma; - -static int legacyfb_depth = 16; - -module_param(legacyfb_depth, int, 0444); - -static int __init imx_fb_helper_init(void) -{ - struct drm_device *drm = imx_drm_device_get(); - - if (!drm) - return -EINVAL; - - if (legacyfb_depth != 16 && legacyfb_depth != 32) { - pr_warn("i.MX legacyfb: invalid legacyfb_depth setting. defaulting to 16bpp\n"); - legacyfb_depth = 16; - } - - fbdev_cma = drm_fbdev_cma_init(drm, legacyfb_depth, - drm->mode_config.num_crtc, MAX_CONNECTOR); - - if (IS_ERR(fbdev_cma)) { - imx_drm_device_put(); - return PTR_ERR(fbdev_cma); - } - - imx_drm_fb_helper_set(fbdev_cma); - - return 0; -} - -static void __exit imx_fb_helper_exit(void) -{ - imx_drm_fb_helper_set(NULL); - drm_fbdev_cma_fini(fbdev_cma); - imx_drm_device_put(); -} - -late_initcall(imx_fb_helper_init); -module_exit(imx_fb_helper_exit); - -MODULE_DESCRIPTION("Freescale i.MX legacy fb driver"); -MODULE_AUTHOR("Sascha Hauer, Pengutronix"); -MODULE_LICENSE("GPL");