[PATCH 20/48] drm: omapdrm: Merge the omapdrm and omapdss drivers

Sebastian Reichel sre at kernel.org
Sat Oct 14 13:12:37 UTC 2017


Hi,

On Fri, Oct 13, 2017 at 05:59:16PM +0300, Laurent Pinchart wrote:
> The split between the omapdss and omapdrm driver is historic and was due
> to other userspace APIs (FBDEV and V4L2) being supported in addition to
> DRM/KMS. Now that the drivers only supports the DRM/KMS API, there is no
> need to keep them separate anymore.
> 
> Merge the two drivers and remove the now unneeded omapdrm virtual
> platform device.
> 
> Signed-off-by: Laurent Pinchart <laurent.pinchart at ideasonboard.com>
> ---
>  drivers/gpu/drm/omapdrm/Kconfig          |  5 +-
>  drivers/gpu/drm/omapdrm/Makefile         | 25 ++++++++++
>  drivers/gpu/drm/omapdrm/dss/Kconfig      | 12 -----
>  drivers/gpu/drm/omapdrm/dss/Makefile     | 25 ----------
>  drivers/gpu/drm/omapdrm/dss/base.c       | 13 -----
>  drivers/gpu/drm/omapdrm/dss/core.c       | 14 ++----
>  drivers/gpu/drm/omapdrm/dss/dss.c        | 23 ++++++++-
>  drivers/gpu/drm/omapdrm/dss/omapdss.h    |  4 --
>  drivers/gpu/drm/omapdrm/omap_dmm_tiler.c | 12 ++++-
>  drivers/gpu/drm/omapdrm/omap_dmm_tiler.h |  3 +-
>  drivers/gpu/drm/omapdrm/omap_drv.c       | 82 ++------------------------------
>  drivers/gpu/drm/omapdrm/omap_drv.h       |  4 ++
>  12 files changed, 74 insertions(+), 148 deletions(-)
> 
> diff --git a/drivers/gpu/drm/omapdrm/Kconfig b/drivers/gpu/drm/omapdrm/Kconfig
> index b3d08c5f41d4..7e5080e45b16 100644
> --- a/drivers/gpu/drm/omapdrm/Kconfig
> +++ b/drivers/gpu/drm/omapdrm/Kconfig
> @@ -2,8 +2,11 @@ config DRM_OMAP
>  	tristate "OMAP DRM"
>  	depends on DRM
>  	depends on ARCH_OMAP2PLUS || ARCH_MULTIPLATFORM
> -	select OMAP2_DSS
>  	select DRM_KMS_HELPER
> +	select HDMI
> +	select OMAP2_DSS

As far as I can see "CONFIG_OMAP2_DSS" no longer exists after the merge,
so this can be dropped.

Otherwise:

Reviewed-by: Sebastian Reichel <sebastian.reichel at collabora.co.uk>

-- Sebastian

> +	select OMAP2_DSS_INIT
> +	select VIDEOMODE_HELPERS
>  	default n
>  	help
>  	  DRM display driver for OMAP2/3/4 based boards.
> diff --git a/drivers/gpu/drm/omapdrm/Makefile b/drivers/gpu/drm/omapdrm/Makefile
> index b391be7ecb6c..1dafa51ca00e 100644
> --- a/drivers/gpu/drm/omapdrm/Makefile
> +++ b/drivers/gpu/drm/omapdrm/Makefile
> @@ -21,4 +21,29 @@ omapdrm-y := omap_drv.o \
>  
>  omapdrm-$(CONFIG_DRM_FBDEV_EMULATION) += omap_fbdev.o
>  
> +# Core DSS files
> +omapdrm-y += \
> +	dss/base.o \
> +	dss/core.o \
> +	dss/dispc.o \
> +	dss/dispc_coefs.o \
> +	dss/display.o \
> +	dss/dss.o \
> +	dss/dss-of.o \
> +	dss/output.o \
> +	dss/pll.o \
> +	dss/video-pll.o
> +
> +omapdrm-$(CONFIG_OMAP2_DSS_DPI) += dss/dpi.o
> +omapdrm-$(CONFIG_OMAP2_DSS_VENC) += dss/venc.o
> +omapdrm-$(CONFIG_OMAP2_DSS_SDI) += dss/sdi.o
> +omapdrm-$(CONFIG_OMAP2_DSS_DSI) += dss/dsi.o
> +omapdrm-$(CONFIG_OMAP2_DSS_HDMI_COMMON) += dss/hdmi_common.o dss/hdmi_wp.o \
> +	dss/hdmi_pll.o dss/hdmi_phy.o
> +omapdrm-$(CONFIG_OMAP4_DSS_HDMI) += dss/hdmi4.o dss/hdmi4_core.o
> +omapdrm-$(CONFIG_OMAP4_DSS_HDMI_CEC) += dss/hdmi4_cec.o
> +omapdrm-$(CONFIG_OMAP5_DSS_HDMI) += dss/hdmi5.o dss/hdmi5_core.o
> +
> +ccflags-$(CONFIG_OMAP2_DSS_DEBUG) += -DDEBUG
> +
>  obj-$(CONFIG_DRM_OMAP)	+= omapdrm.o
> diff --git a/drivers/gpu/drm/omapdrm/dss/Kconfig b/drivers/gpu/drm/omapdrm/dss/Kconfig
> index 39a30a64448a..157c5601e4be 100644
> --- a/drivers/gpu/drm/omapdrm/dss/Kconfig
> +++ b/drivers/gpu/drm/omapdrm/dss/Kconfig
> @@ -1,16 +1,6 @@
>  config OMAP2_DSS_INIT
>  	bool
>  
> -menuconfig OMAP2_DSS
> -        tristate "OMAP2+ Display Subsystem support"
> -	select VIDEOMODE_HELPERS
> -	select OMAP2_DSS_INIT
> -	select HDMI
> -        help
> -	  OMAP2+ Display Subsystem support.
> -
> -if OMAP2_DSS
> -
>  config OMAP2_DSS_DEBUG
>  	bool "Debug support"
>  	default n
> @@ -126,5 +116,3 @@ config OMAP2_DSS_SLEEP_AFTER_VENC_RESET
>  
>  	  This option enables the sleep, and is enabled by default. You can
>  	  disable the sleep if it doesn't cause problems on your platform.
> -
> -endif
> diff --git a/drivers/gpu/drm/omapdrm/dss/Makefile b/drivers/gpu/drm/omapdrm/dss/Makefile
> index 531b4d8075e5..3db4bf31aeaf 100644
> --- a/drivers/gpu/drm/omapdrm/dss/Makefile
> +++ b/drivers/gpu/drm/omapdrm/dss/Makefile
> @@ -1,26 +1 @@
>  obj-$(CONFIG_OMAP2_DSS_INIT) += omapdss-boot-init.o
> -obj-$(CONFIG_OMAP2_DSS) += omapdss.o
> -
> -# Core DSS files
> -omapdss-y := \
> -	base.o \
> -	display.o \
> -	dss-of.o \
> -	output.o \
> -	core.o \
> -	dss.o \
> -	dispc.o \
> -	dispc_coefs.o \
> -	pll.o \
> -	video-pll.o
> -
> -omapdss-$(CONFIG_OMAP2_DSS_DPI) += dpi.o
> -omapdss-$(CONFIG_OMAP2_DSS_VENC) += venc.o
> -omapdss-$(CONFIG_OMAP2_DSS_SDI) += sdi.o
> -omapdss-$(CONFIG_OMAP2_DSS_DSI) += dsi.o
> -omapdss-$(CONFIG_OMAP2_DSS_HDMI_COMMON) += hdmi_common.o hdmi_wp.o hdmi_pll.o \
> -	hdmi_phy.o
> -omapdss-$(CONFIG_OMAP4_DSS_HDMI) += hdmi4.o hdmi4_core.o
> -omapdss-$(CONFIG_OMAP4_DSS_HDMI_CEC) += hdmi4_cec.o
> -omapdss-$(CONFIG_OMAP5_DSS_HDMI) += hdmi5.o hdmi5_core.o
> -ccflags-$(CONFIG_OMAP2_DSS_DEBUG) += -DDEBUG
> diff --git a/drivers/gpu/drm/omapdrm/dss/base.c b/drivers/gpu/drm/omapdrm/dss/base.c
> index eff427dd3297..5729f8244bf9 100644
> --- a/drivers/gpu/drm/omapdrm/dss/base.c
> +++ b/drivers/gpu/drm/omapdrm/dss/base.c
> @@ -5,7 +5,6 @@
>  #include <linux/list.h>
>  #include "omapdss.h"
>  
> -static bool dss_initialized;
>  static const struct dispc_ops *ops;
>  
>  static struct list_head omapdss_comp_list;
> @@ -16,17 +15,6 @@ struct omapdss_comp_node {
>  	bool dss_core_component;
>  };
>  
> -void omapdss_set_is_initialized(bool set)
> -{
> -	dss_initialized = set;
> -}
> -
> -bool omapdss_is_initialized(void)
> -{
> -	return dss_initialized;
> -}
> -EXPORT_SYMBOL(omapdss_is_initialized);
> -
>  void dispc_set_ops(const struct dispc_ops *o)
>  {
>  	ops = o;
> @@ -130,4 +118,3 @@ bool omapdss_stack_is_ready(void)
>  
>  	return true;
>  }
> -EXPORT_SYMBOL(omapdss_stack_is_ready);
> diff --git a/drivers/gpu/drm/omapdrm/dss/core.c b/drivers/gpu/drm/omapdrm/dss/core.c
> index 197ddbc1512b..776f43601288 100644
> --- a/drivers/gpu/drm/omapdrm/dss/core.c
> +++ b/drivers/gpu/drm/omapdrm/dss/core.c
> @@ -24,13 +24,14 @@
>  
>  #include <linux/kernel.h>
>  #include <linux/module.h>
> -#include <linux/platform_device.h>
>  
>  #include "omapdss.h"
>  #include "dss.h"
> +#include "../omap_dmm_tiler.h"
>  
>  /* INIT */
>  static int (*dss_output_drv_reg_funcs[])(void) __initdata = {
> +	dmm_init_platform_driver,
>  	dss_init_platform_driver,
>  	dispc_init_platform_driver,
>  #ifdef CONFIG_OMAP2_DSS_DSI
> @@ -62,10 +63,9 @@ static void (*dss_output_drv_unreg_funcs[])(void) = {
>  #endif
>  	dispc_uninit_platform_driver,
>  	dss_uninit_platform_driver,
> +	dmm_uninit_platform_driver,
>  };
>  
> -static struct platform_device *omap_drm_device;
> -
>  static int __init omap_dss_init(void)
>  {
>  	int r;
> @@ -77,12 +77,6 @@ static int __init omap_dss_init(void)
>  			goto err_reg;
>  	}
>  
> -	omap_drm_device = platform_device_register_simple("omapdrm", 0, NULL, 0);
> -	if (IS_ERR(omap_drm_device)) {
> -		r = PTR_ERR(omap_drm_device);
> -		goto err_reg;
> -	}
> -
>  	return 0;
>  
>  err_reg:
> @@ -98,8 +92,6 @@ static void __exit omap_dss_exit(void)
>  {
>  	int i;
>  
> -	platform_device_unregister(omap_drm_device);
> -
>  	for (i = 0; i < ARRAY_SIZE(dss_output_drv_unreg_funcs); ++i)
>  		dss_output_drv_unreg_funcs[i]();
>  }
> diff --git a/drivers/gpu/drm/omapdrm/dss/dss.c b/drivers/gpu/drm/omapdrm/dss/dss.c
> index a27edc56a509..5721f3d64bdd 100644
> --- a/drivers/gpu/drm/omapdrm/dss/dss.c
> +++ b/drivers/gpu/drm/omapdrm/dss/dss.c
> @@ -49,6 +49,7 @@
>  
>  #include "omapdss.h"
>  #include "dss.h"
> +#include "../omap_drv.h"
>  
>  #define DSS_SZ_REGS			SZ_512
>  
> @@ -94,6 +95,8 @@ struct dss_features {
>  
>  static struct {
>  	struct platform_device *pdev;
> +	struct omap_drm_private drm;
> +
>  	void __iomem    *base;
>  	struct regmap	*syscon_pll_ctrl;
>  	u32		syscon_pll_ctrl_offset;
> @@ -1366,10 +1369,15 @@ static int dss_bind(struct device *dev)
>  	pm_set_vt_switch(0);
>  
>  	omapdss_gather_components(dev);
> -	omapdss_set_is_initialized(true);
> +
> +	r = omapdrm_init(&dss.drm, dev);
> +	if (r)
> +		goto err_drm_init;
>  
>  	return 0;
>  
> +err_drm_init:
> +	component_unbind_all(&pdev->dev, NULL);
>  err_component:
>  err_runtime_get:
>  	pm_runtime_disable(&pdev->dev);
> @@ -1390,7 +1398,7 @@ static void dss_unbind(struct device *dev)
>  {
>  	struct platform_device *pdev = to_platform_device(dev);
>  
> -	omapdss_set_is_initialized(false);
> +	omapdrm_cleanup(&dss.drm);
>  
>  	component_unbind_all(&pdev->dev, NULL);
>  
> @@ -1531,7 +1539,18 @@ static int dss_runtime_resume(struct device *dev)
>  	return 0;
>  }
>  
> +static int dss_suspend(struct device *dev)
> +{
> +	return omap_drm_suspend(&dss.drm);
> +}
> +
> +static int dss_resume(struct device *dev)
> +{
> +	return omap_drm_resume(&dss.drm);
> +}
> +
>  static const struct dev_pm_ops dss_pm_ops = {
> +	SET_SYSTEM_SLEEP_PM_OPS(dss_suspend, dss_resume)
>  	.runtime_suspend = dss_runtime_suspend,
>  	.runtime_resume = dss_runtime_resume,
>  };
> diff --git a/drivers/gpu/drm/omapdrm/dss/omapdss.h b/drivers/gpu/drm/omapdrm/dss/omapdss.h
> index 3a6b33ff2990..6f9b9b2d8af2 100644
> --- a/drivers/gpu/drm/omapdrm/dss/omapdss.h
> +++ b/drivers/gpu/drm/omapdrm/dss/omapdss.h
> @@ -583,8 +583,6 @@ struct omap_dss_driver {
>  		const struct hdmi_avi_infoframe *avi);
>  };
>  
> -bool omapdss_is_initialized(void);
> -
>  int omap_dss_register_driver(struct omap_dss_driver *);
>  void omap_dss_unregister_driver(struct omap_dss_driver *);
>  
> @@ -633,8 +631,6 @@ static inline bool omapdss_device_is_enabled(struct omap_dss_device *dssdev)
>  struct omap_dss_device *
>  omapdss_of_find_source_for_first_ep(struct device_node *node);
>  
> -void omapdss_set_is_initialized(bool set);
> -
>  struct device_node *dss_of_port_get_parent_device(struct device_node *port);
>  u32 dss_of_port_get_port_number(struct device_node *port);
>  
> diff --git a/drivers/gpu/drm/omapdrm/omap_dmm_tiler.c b/drivers/gpu/drm/omapdrm/omap_dmm_tiler.c
> index b341ebc136fe..dfbf361ac1e4 100644
> --- a/drivers/gpu/drm/omapdrm/omap_dmm_tiler.c
> +++ b/drivers/gpu/drm/omapdrm/omap_dmm_tiler.c
> @@ -1042,7 +1042,7 @@ static const struct of_device_id dmm_of_match[] = {
>  };
>  #endif
>  
> -struct platform_driver omap_dmm_driver = {
> +static struct platform_driver omap_dmm_driver = {
>  	.probe = omap_dmm_probe,
>  	.remove = omap_dmm_remove,
>  	.driver = {
> @@ -1053,6 +1053,16 @@ struct platform_driver omap_dmm_driver = {
>  	},
>  };
>  
> +int __init dmm_init_platform_driver(void)
> +{
> +	return platform_driver_register(&omap_dmm_driver);
> +}
> +
> +void dmm_uninit_platform_driver(void)
> +{
> +	platform_driver_unregister(&omap_dmm_driver);
> +}
> +
>  MODULE_LICENSE("GPL v2");
>  MODULE_AUTHOR("Andy Gross <andy.gross at ti.com>");
>  MODULE_DESCRIPTION("OMAP DMM/Tiler Driver");
> diff --git a/drivers/gpu/drm/omapdrm/omap_dmm_tiler.h b/drivers/gpu/drm/omapdrm/omap_dmm_tiler.h
> index 09816adfd422..842254d65548 100644
> --- a/drivers/gpu/drm/omapdrm/omap_dmm_tiler.h
> +++ b/drivers/gpu/drm/omapdrm/omap_dmm_tiler.h
> @@ -109,7 +109,8 @@ void tiler_align(enum tiler_fmt fmt, u16 *w, u16 *h);
>  u32 tiler_get_cpu_cache_flags(void);
>  bool dmm_is_available(void);
>  
> -extern struct platform_driver omap_dmm_driver;
> +int dmm_init_platform_driver(void) __init;
> +void dmm_uninit_platform_driver(void);
>  
>  /* GEM bo flags -> tiler fmt */
>  static inline enum tiler_fmt gem2fmt(u32 flags)
> diff --git a/drivers/gpu/drm/omapdrm/omap_drv.c b/drivers/gpu/drm/omapdrm/omap_drv.c
> index cbca70f80d8e..baf8e32b899b 100644
> --- a/drivers/gpu/drm/omapdrm/omap_drv.c
> +++ b/drivers/gpu/drm/omapdrm/omap_drv.c
> @@ -542,7 +542,7 @@ static const struct soc_device_attribute omapdrm_soc_devices[] = {
>  	{ /* sentinel */ }
>  };
>  
> -static int omapdrm_init(struct omap_drm_private *priv, struct device *dev)
> +int omapdrm_init(struct omap_drm_private *priv, struct device *dev)
>  {
>  	const struct soc_device_attribute *soc;
>  	struct drm_device *ddev;
> @@ -630,7 +630,7 @@ static int omapdrm_init(struct omap_drm_private *priv, struct device *dev)
>  	return ret;
>  }
>  
> -static void omapdrm_cleanup(struct omap_drm_private *priv)
> +void omapdrm_cleanup(struct omap_drm_private *priv)
>  {
>  	struct drm_device *ddev = priv->ddev;
>  
> @@ -659,44 +659,6 @@ static void omapdrm_cleanup(struct omap_drm_private *priv)
>  	omap_crtc_pre_uninit();
>  }
>  
> -static int pdev_probe(struct platform_device *pdev)
> -{
> -	struct omap_drm_private *priv;
> -	int ret;
> -
> -	if (omapdss_is_initialized() == false)
> -		return -EPROBE_DEFER;
> -
> -	ret = dma_set_coherent_mask(&pdev->dev, DMA_BIT_MASK(32));
> -	if (ret) {
> -		dev_err(&pdev->dev, "Failed to set the DMA mask\n");
> -		return ret;
> -	}
> -
> -	/* Allocate and initialize the driver private structure. */
> -	priv = kzalloc(sizeof(*priv), GFP_KERNEL);
> -	if (!priv)
> -		return -ENOMEM;
> -
> -	platform_set_drvdata(pdev, priv);
> -
> -	ret = omapdrm_init(priv, &pdev->dev);
> -	if (ret < 0)
> -		kfree(priv);
> -
> -	return ret;
> -}
> -
> -static int pdev_remove(struct platform_device *pdev)
> -{
> -	struct omap_drm_private *priv = platform_get_drvdata(pdev);
> -
> -	omapdrm_cleanup(priv);
> -	kfree(priv);
> -
> -	return 0;
> -}
> -
>  #ifdef CONFIG_PM_SLEEP
>  static int omap_drm_suspend_all_displays(void)
>  {
> @@ -734,9 +696,8 @@ static int omap_drm_resume_all_displays(void)
>  	return 0;
>  }
>  
> -static int omap_drm_suspend(struct device *dev)
> +int omap_drm_suspend(struct omap_drm_private *priv)
>  {
> -	struct omap_drm_private *priv = dev_get_drvdata(dev);
>  	struct drm_device *drm_dev = priv->ddev;
>  
>  	drm_kms_helper_poll_disable(drm_dev);
> @@ -748,9 +709,8 @@ static int omap_drm_suspend(struct device *dev)
>  	return 0;
>  }
>  
> -static int omap_drm_resume(struct device *dev)
> +int omap_drm_resume(struct omap_drm_private *priv)
>  {
> -	struct omap_drm_private *priv = dev_get_drvdata(dev);
>  	struct drm_device *drm_dev = priv->ddev;
>  
>  	drm_modeset_lock_all(drm_dev);
> @@ -763,40 +723,6 @@ static int omap_drm_resume(struct device *dev)
>  }
>  #endif
>  
> -static SIMPLE_DEV_PM_OPS(omapdrm_pm_ops, omap_drm_suspend, omap_drm_resume);
> -
> -static struct platform_driver pdev = {
> -	.driver = {
> -		.name = "omapdrm",
> -		.pm = &omapdrm_pm_ops,
> -	},
> -	.probe = pdev_probe,
> -	.remove = pdev_remove,
> -};
> -
> -static struct platform_driver * const drivers[] = {
> -	&omap_dmm_driver,
> -	&pdev,
> -};
> -
> -static int __init omap_drm_init(void)
> -{
> -	DBG("init");
> -
> -	return platform_register_drivers(drivers, ARRAY_SIZE(drivers));
> -}
> -
> -static void __exit omap_drm_fini(void)
> -{
> -	DBG("fini");
> -
> -	platform_unregister_drivers(drivers, ARRAY_SIZE(drivers));
> -}
> -
> -/* need late_initcall() so we load after dss_driver's are loaded */
> -late_initcall(omap_drm_init);
> -module_exit(omap_drm_fini);
> -
>  MODULE_AUTHOR("Rob Clark <rob at ti.com>");
>  MODULE_DESCRIPTION("OMAP DRM Display Driver");
>  MODULE_ALIAS("platform:" DRIVER_NAME);
> diff --git a/drivers/gpu/drm/omapdrm/omap_drv.h b/drivers/gpu/drm/omapdrm/omap_drv.h
> index 2c06533a2d0a..e10b9105379a 100644
> --- a/drivers/gpu/drm/omapdrm/omap_drv.h
> +++ b/drivers/gpu/drm/omapdrm/omap_drv.h
> @@ -88,6 +88,10 @@ struct omap_drm_private {
>  	u32 irq_mask;			/* enabled irqs in addition to wait_list */
>  };
>  
> +int omapdrm_init(struct omap_drm_private *priv, struct device *dev);
> +void omapdrm_cleanup(struct omap_drm_private *priv);
> +int omap_drm_suspend(struct omap_drm_private *priv);
> +int omap_drm_resume(struct omap_drm_private *priv);
>  
>  int omap_debugfs_init(struct drm_minor *minor);
>  
> -- 
> Regards,
> 
> Laurent Pinchart
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <https://lists.freedesktop.org/archives/dri-devel/attachments/20171014/2b16bee8/attachment.sig>


More information about the dri-devel mailing list