diff mbox

[RFCv2,05/10] drm: Add plane type property

Message ID 1394237002-18041-6-git-send-email-matthew.d.roper@intel.com (mailing list archive)
State New, archived
Headers show

Commit Message

Matt Roper March 8, 2014, 12:03 a.m. UTC
Add a plane type property to allow userspace to distinguish plane types.
The type of the plane will now be established at drm_plane_init() time
(replacing the 'priv' parameter previously used).

Signed-off-by: Matt Roper <matthew.d.roper@intel.com>
---
 drivers/gpu/drm/armada/armada_overlay.c    |  3 +-
 drivers/gpu/drm/drm_crtc.c                 | 65 ++++++++++++++++++++----------
 drivers/gpu/drm/exynos/exynos_drm_plane.c  |  4 +-
 drivers/gpu/drm/i915/intel_sprite.c        |  2 +-
 drivers/gpu/drm/msm/mdp/mdp4/mdp4_plane.c  |  4 +-
 drivers/gpu/drm/msm/mdp/mdp5/mdp5_plane.c  |  3 +-
 drivers/gpu/drm/nouveau/dispnv04/overlay.c |  4 +-
 drivers/gpu/drm/omapdrm/omap_plane.c       |  4 +-
 drivers/gpu/drm/rcar-du/rcar_du_plane.c    |  3 +-
 drivers/gpu/drm/shmobile/shmob_drm_plane.c |  2 +-
 drivers/gpu/drm/tegra/dc.c                 |  3 +-
 drivers/staging/imx-drm/ipuv3-plane.c      |  4 +-
 include/drm/drm_crtc.h                     |  3 +-
 13 files changed, 69 insertions(+), 35 deletions(-)

Comments

Paauwe, Bob J March 11, 2014, 11:45 p.m. UTC | #1
On Fri, 7 Mar 2014 16:03:17 -0800
Matt Roper <matthew.d.roper@intel.com> wrote:

> Add a plane type property to allow userspace to distinguish plane types.
> The type of the plane will now be established at drm_plane_init() time
> (replacing the 'priv' parameter previously used).
> 
> Signed-off-by: Matt Roper <matthew.d.roper@intel.com>
> ---
>  drivers/gpu/drm/armada/armada_overlay.c    |  3 +-
>  drivers/gpu/drm/drm_crtc.c                 | 65 ++++++++++++++++++++----------
>  drivers/gpu/drm/exynos/exynos_drm_plane.c  |  4 +-
>  drivers/gpu/drm/i915/intel_sprite.c        |  2 +-
>  drivers/gpu/drm/msm/mdp/mdp4/mdp4_plane.c  |  4 +-
>  drivers/gpu/drm/msm/mdp/mdp5/mdp5_plane.c  |  3 +-
>  drivers/gpu/drm/nouveau/dispnv04/overlay.c |  4 +-
>  drivers/gpu/drm/omapdrm/omap_plane.c       |  4 +-
>  drivers/gpu/drm/rcar-du/rcar_du_plane.c    |  3 +-
>  drivers/gpu/drm/shmobile/shmob_drm_plane.c |  2 +-
>  drivers/gpu/drm/tegra/dc.c                 |  3 +-
>  drivers/staging/imx-drm/ipuv3-plane.c      |  4 +-
>  include/drm/drm_crtc.h                     |  3 +-
>  13 files changed, 69 insertions(+), 35 deletions(-)
> 
> diff --git a/drivers/gpu/drm/armada/armada_overlay.c b/drivers/gpu/drm/armada/armada_overlay.c
> index c5b06fd..ef68c42 100644
> --- a/drivers/gpu/drm/armada/armada_overlay.c
> +++ b/drivers/gpu/drm/armada/armada_overlay.c
> @@ -444,7 +444,8 @@ int armada_overlay_plane_create(struct drm_device *dev, unsigned long crtcs)
>  				  dplane);
>  
>  	drm_plane_init(dev, &dplane->base, crtcs, &armada_plane_funcs,
> -		       armada_formats, ARRAY_SIZE(armada_formats), false);
> +		       armada_formats, ARRAY_SIZE(armada_formats),
> +		       DRM_PLANE_TYPE_OVERLAY);
>  
>  	dplane->prop.colorkey_yr = 0xfefefe00;
>  	dplane->prop.colorkey_ug = 0x01010100;
> diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c
> index 93fc2dd..5b9b512 100644
> --- a/drivers/gpu/drm/drm_crtc.c
> +++ b/drivers/gpu/drm/drm_crtc.c
> @@ -114,6 +114,15 @@ static const struct drm_prop_enum_list drm_dpms_enum_list[] =
>  
>  DRM_ENUM_NAME_FN(drm_get_dpms_name, drm_dpms_enum_list)
>  
> +static const struct drm_prop_enum_list drm_plane_type_enum_list[] =
> +{
> +	{ DRM_PLANE_TYPE_OVERLAY, "Overlay" },
> +	{ DRM_PLANE_TYPE_PRIMARY, "Primary" },
> +	{ DRM_PLANE_TYPE_CURSOR, "Cursor" },
> +};
> +
> +DRM_ENUM_NAME_FN(drm_get_plane_type, drm_plane_type_enum_list)
> +
>  /*
>   * Optional properties
>   */
> @@ -928,7 +937,7 @@ EXPORT_SYMBOL(drm_encoder_cleanup);
>   * @funcs: callbacks for the new plane
>   * @formats: array of supported formats (%DRM_FORMAT_*)
>   * @format_count: number of elements in @formats
> - * @priv: plane is private (hidden from userspace)?
> + * @type: type of plane (overlay, primary, cursor)
>   *
>   * Inits a new object created as base part of a driver plane object.
>   *
> @@ -939,7 +948,7 @@ int drm_plane_init(struct drm_device *dev, struct drm_plane *plane,
>  		   unsigned long possible_crtcs,
>  		   const struct drm_plane_funcs *funcs,
>  		   const uint32_t *formats, uint32_t format_count,
> -		   bool priv)
> +		   enum drm_plane_type type)
>  {
>  	int ret;
>  
> @@ -964,20 +973,16 @@ int drm_plane_init(struct drm_device *dev, struct drm_plane *plane,
>  	memcpy(plane->format_types, formats, format_count * sizeof(uint32_t));
>  	plane->format_count = format_count;
>  	plane->possible_crtcs = possible_crtcs;
> -	plane->type = DRM_PLANE_TYPE_OVERLAY;
> +	plane->type = type;
>  
> -	/* private planes are not exposed to userspace, but depending on
> -	 * display hardware, might be convenient to allow sharing programming
> -	 * for the scanout engine with the crtc implementation.
> -	 */
> -	if (!priv) {
> -		list_add_tail(&plane->head, &dev->mode_config.plane_list);
> -		dev->mode_config.num_total_plane++;
> -		if (plane->type == DRM_PLANE_TYPE_OVERLAY)
> -			dev->mode_config.num_overlay_plane++;
> -	} else {
> -		INIT_LIST_HEAD(&plane->head);
> -	}
> +	list_add_tail(&plane->head, &dev->mode_config.plane_list);
> +	dev->mode_config.num_total_plane++;
> +	if (plane->type == DRM_PLANE_TYPE_OVERLAY)
> +		dev->mode_config.num_overlay_plane++;
> +
> +	drm_object_attach_property(&plane->base,
> +				   dev->mode_config.plane_type_property,
> +				   plane->type);
>  
>   out:
>  	drm_modeset_unlock_all(dev);
> @@ -1001,13 +1006,13 @@ void drm_plane_cleanup(struct drm_plane *plane)
>  	drm_modeset_lock_all(dev);
>  	kfree(plane->format_types);
>  	drm_mode_object_put(dev, &plane->base);
> -	/* if not added to a list, it must be a private plane */
> -	if (!list_empty(&plane->head)) {
> -		list_del(&plane->head);
> -	        dev->mode_config.num_total_plane--;
> -		if (plane->type == DRM_PLANE_TYPE_OVERLAY)
> -			dev->mode_config.num_overlay_plane--;
> -	}
> +
> +	BUG_ON(list_empty(&plane->head));
> +
> +	list_del(&plane->head);
> +	dev->mode_config.num_total_plane--;
> +	if (plane->type == DRM_PLANE_TYPE_OVERLAY)
> +		dev->mode_config.num_overlay_plane--;
>  	drm_modeset_unlock_all(dev);
>  }
>  EXPORT_SYMBOL(drm_plane_cleanup);
> @@ -1357,6 +1362,21 @@ static int drm_mode_create_standard_connector_properties(struct drm_device *dev)
>  	return 0;
>  }
>  
> +static int drm_mode_create_standard_plane_properties(struct drm_device *dev)
> +{
> +	struct drm_property *type;
> +
> +	/*
> +	 * Standard properties (apply to all planes)
> +	 */
> +	type = drm_property_create_enum(dev, 0,
> +					"TYPE", drm_plane_type_enum_list,
> +					ARRAY_SIZE(drm_plane_type_enum_list));

Should this property be created with DRM_MODE_PROP_IMMUTABLE set?  What
happens if user space tries to change this property to a different type?


> +	dev->mode_config.plane_type_property = type;
> +
> +	return 0;
> +}
> +
>  /**
>   * drm_mode_create_dvi_i_properties - create DVI-I specific connector properties
>   * @dev: DRM device
> @@ -4277,6 +4297,7 @@ void drm_mode_config_init(struct drm_device *dev)
>  
>  	drm_modeset_lock_all(dev);
>  	drm_mode_create_standard_connector_properties(dev);
> +	drm_mode_create_standard_plane_properties(dev);
>  	drm_modeset_unlock_all(dev);
>  
>  	/* Just to be sure */
> diff --git a/drivers/gpu/drm/exynos/exynos_drm_plane.c b/drivers/gpu/drm/exynos/exynos_drm_plane.c
> index fcb0652..7943dd3 100644
> --- a/drivers/gpu/drm/exynos/exynos_drm_plane.c
> +++ b/drivers/gpu/drm/exynos/exynos_drm_plane.c
> @@ -263,14 +263,16 @@ struct drm_plane *exynos_plane_init(struct drm_device *dev,
>  {
>  	struct exynos_plane *exynos_plane;
>  	int err;
> +	enum drm_plane_type type;
>  
>  	exynos_plane = kzalloc(sizeof(struct exynos_plane), GFP_KERNEL);
>  	if (!exynos_plane)
>  		return NULL;
>  
> +	type = priv ? DRM_PLANE_TYPE_PRIMARY : DRM_PLANE_TYPE_OVERLAY;
>  	err = drm_plane_init(dev, &exynos_plane->base, possible_crtcs,
>  			      &exynos_plane_funcs, formats, ARRAY_SIZE(formats),
> -			      priv);
> +			      type);
>  	if (err) {
>  		DRM_ERROR("failed to initialize plane\n");
>  		kfree(exynos_plane);
> diff --git a/drivers/gpu/drm/i915/intel_sprite.c b/drivers/gpu/drm/i915/intel_sprite.c
> index 336ae6c..630485c 100644
> --- a/drivers/gpu/drm/i915/intel_sprite.c
> +++ b/drivers/gpu/drm/i915/intel_sprite.c
> @@ -1145,7 +1145,7 @@ intel_plane_init(struct drm_device *dev, enum pipe pipe, int plane)
>  	ret = drm_plane_init(dev, &intel_plane->base, possible_crtcs,
>  			     &intel_plane_funcs,
>  			     plane_formats, num_plane_formats,
> -			     false);
> +			     DRM_PLANE_TYPE_OVERLAY);
>  	if (ret)
>  		kfree(intel_plane);
>  
> diff --git a/drivers/gpu/drm/msm/mdp/mdp4/mdp4_plane.c b/drivers/gpu/drm/msm/mdp/mdp4/mdp4_plane.c
> index 1e893dd..afa9c67 100644
> --- a/drivers/gpu/drm/msm/mdp/mdp4/mdp4_plane.c
> +++ b/drivers/gpu/drm/msm/mdp/mdp4/mdp4_plane.c
> @@ -222,6 +222,7 @@ struct drm_plane *mdp4_plane_init(struct drm_device *dev,
>  	struct drm_plane *plane = NULL;
>  	struct mdp4_plane *mdp4_plane;
>  	int ret;
> +	enum drm_plane_type type;
>  
>  	mdp4_plane = kzalloc(sizeof(*mdp4_plane), GFP_KERNEL);
>  	if (!mdp4_plane) {
> @@ -237,9 +238,10 @@ struct drm_plane *mdp4_plane_init(struct drm_device *dev,
>  	mdp4_plane->nformats = mdp4_get_formats(pipe_id, mdp4_plane->formats,
>  			ARRAY_SIZE(mdp4_plane->formats));
>  
> +	type = private_plane ? DRM_PLANE_TYPE_PRIMARY : DRM_PLANE_TYPE_OVERLAY;
>  	drm_plane_init(dev, plane, 0xff, &mdp4_plane_funcs,
>  			mdp4_plane->formats, mdp4_plane->nformats,
> -			private_plane);
> +			type);
>  
>  	mdp4_plane_install_properties(plane, &plane->base);
>  
> diff --git a/drivers/gpu/drm/msm/mdp/mdp5/mdp5_plane.c b/drivers/gpu/drm/msm/mdp/mdp5/mdp5_plane.c
> index 0ac8bb5..faf179c 100644
> --- a/drivers/gpu/drm/msm/mdp/mdp5/mdp5_plane.c
> +++ b/drivers/gpu/drm/msm/mdp/mdp5/mdp5_plane.c
> @@ -373,9 +373,10 @@ struct drm_plane *mdp5_plane_init(struct drm_device *dev,
>  	mdp5_plane->nformats = mdp5_get_formats(pipe, mdp5_plane->formats,
>  			ARRAY_SIZE(mdp5_plane->formats));
>  
> +	type = private_plane ? DRM_PLANE_TYPE_PRIMARY : DRM_PLANE_TYPE_OVERLAY;
>  	drm_plane_init(dev, plane, 0xff, &mdp5_plane_funcs,
>  			mdp5_plane->formats, mdp5_plane->nformats,
> -			private_plane);
> +			type);
>  
>  	mdp5_plane_install_properties(plane, &plane->base);
>  
> diff --git a/drivers/gpu/drm/nouveau/dispnv04/overlay.c b/drivers/gpu/drm/nouveau/dispnv04/overlay.c
> index ab03f77..0b4f35d 100644
> --- a/drivers/gpu/drm/nouveau/dispnv04/overlay.c
> +++ b/drivers/gpu/drm/nouveau/dispnv04/overlay.c
> @@ -276,7 +276,7 @@ nv10_overlay_init(struct drm_device *device)
>  
>  	ret = drm_plane_init(device, &plane->base, 3 /* both crtc's */,
>  			     &nv10_plane_funcs,
> -			     formats, num_formats, false);
> +			     formats, num_formats, DRM_PLANE_TYPE_OVERLAY);
>  	if (ret)
>  		goto err;
>  
> @@ -456,7 +456,7 @@ nv04_overlay_init(struct drm_device *device)
>  
>  	ret = drm_plane_init(device, &plane->base, 1 /* single crtc */,
>  			     &nv04_plane_funcs,
> -			     formats, 2, false);
> +			     formats, 2, DRM_PLANE_TYPE_OVERLAY);
>  	if (ret)
>  		goto err;
>  
> diff --git a/drivers/gpu/drm/omapdrm/omap_plane.c b/drivers/gpu/drm/omapdrm/omap_plane.c
> index 046d5e6..d4179b2 100644
> --- a/drivers/gpu/drm/omapdrm/omap_plane.c
> +++ b/drivers/gpu/drm/omapdrm/omap_plane.c
> @@ -384,6 +384,7 @@ struct drm_plane *omap_plane_init(struct drm_device *dev,
>  	struct omap_plane *omap_plane;
>  	struct omap_overlay_info *info;
>  	int ret;
> +	enum drm_plane_type type;
>  
>  	DBG("%s: priv=%d", plane_names[id], private_plane);
>  
> @@ -413,8 +414,9 @@ struct drm_plane *omap_plane_init(struct drm_device *dev,
>  	omap_plane->error_irq.irq = omap_plane_error_irq;
>  	omap_irq_register(dev, &omap_plane->error_irq);
>  
> +	type = private_plane ? DRM_PLANE_TYPE_PRIMARY : DRM_PLANE_TYPE_OVERLAY;
>  	drm_plane_init(dev, plane, (1 << priv->num_crtcs) - 1, &omap_plane_funcs,
> -			omap_plane->formats, omap_plane->nformats, private_plane);
> +			omap_plane->formats, omap_plane->nformats, type);
>  
>  	omap_plane_install_properties(plane, &plane->base);
>  
> diff --git a/drivers/gpu/drm/rcar-du/rcar_du_plane.c b/drivers/gpu/drm/rcar-du/rcar_du_plane.c
> index 3fb69d9..27f1531 100644
> --- a/drivers/gpu/drm/rcar-du/rcar_du_plane.c
> +++ b/drivers/gpu/drm/rcar-du/rcar_du_plane.c
> @@ -499,7 +499,8 @@ int rcar_du_planes_register(struct rcar_du_group *rgrp)
>  
>  		ret = drm_plane_init(rcdu->ddev, &plane->plane, crtcs,
>  				     &rcar_du_plane_funcs, formats,
> -				     ARRAY_SIZE(formats), false);
> +				     ARRAY_SIZE(formats),
> +				     DRM_PLANE_TYPE_OVERLAY);
>  		if (ret < 0)
>  			return ret;
>  
> diff --git a/drivers/gpu/drm/shmobile/shmob_drm_plane.c b/drivers/gpu/drm/shmobile/shmob_drm_plane.c
> index 060ae03..2b03fff 100644
> --- a/drivers/gpu/drm/shmobile/shmob_drm_plane.c
> +++ b/drivers/gpu/drm/shmobile/shmob_drm_plane.c
> @@ -257,7 +257,7 @@ int shmob_drm_plane_create(struct shmob_drm_device *sdev, unsigned int index)
>  
>  	ret = drm_plane_init(sdev->ddev, &splane->plane, 1,
>  			     &shmob_drm_plane_funcs, formats,
> -			     ARRAY_SIZE(formats), false);
> +			     ARRAY_SIZE(formats), DRM_PLANE_TYPE_OVERLAY);
>  
>  	return ret;
>  }
> diff --git a/drivers/gpu/drm/tegra/dc.c b/drivers/gpu/drm/tegra/dc.c
> index 9336006..76e5b22 100644
> --- a/drivers/gpu/drm/tegra/dc.c
> +++ b/drivers/gpu/drm/tegra/dc.c
> @@ -137,7 +137,8 @@ static int tegra_dc_add_planes(struct drm_device *drm, struct tegra_dc *dc)
>  
>  		err = drm_plane_init(drm, &plane->base, 1 << dc->pipe,
>  				     &tegra_plane_funcs, plane_formats,
> -				     ARRAY_SIZE(plane_formats), false);
> +				     ARRAY_SIZE(plane_formats),
> +				     DRM_PLANE_TYPE_OVERLAY);
>  		if (err < 0) {
>  			kfree(plane);
>  			return err;
> diff --git a/drivers/staging/imx-drm/ipuv3-plane.c b/drivers/staging/imx-drm/ipuv3-plane.c
> index 34b642a..7975369 100644
> --- a/drivers/staging/imx-drm/ipuv3-plane.c
> +++ b/drivers/staging/imx-drm/ipuv3-plane.c
> @@ -355,6 +355,7 @@ struct ipu_plane *ipu_plane_init(struct drm_device *dev, struct ipu_soc *ipu,
>  {
>  	struct ipu_plane *ipu_plane;
>  	int ret;
> +	enum drm_plane_type type;
>  
>  	DRM_DEBUG_KMS("channel %d, dp flow %d, possible_crtcs=0x%x\n",
>  		      dma, dp, possible_crtcs);
> @@ -369,10 +370,11 @@ struct ipu_plane *ipu_plane_init(struct drm_device *dev, struct ipu_soc *ipu,
>  	ipu_plane->dma = dma;
>  	ipu_plane->dp_flow = dp;
>  
> +	type = priv ? DRM_PLANE_TYPE_PRIMARY : DRM_PLANE_TYPE_OVERLAY;
>  	ret = drm_plane_init(dev, &ipu_plane->base, possible_crtcs,
>  			     &ipu_plane_funcs, ipu_plane_formats,
>  			     ARRAY_SIZE(ipu_plane_formats),
> -			     priv);
> +			     type);
>  	if (ret) {
>  		DRM_ERROR("failed to initialize plane\n");
>  		kfree(ipu_plane);
> diff --git a/include/drm/drm_crtc.h b/include/drm/drm_crtc.h
> index 6ecfc9d..d8a1dc8 100644
> --- a/include/drm/drm_crtc.h
> +++ b/include/drm/drm_crtc.h
> @@ -976,6 +976,7 @@ struct drm_mode_config {
>  	struct list_head property_blob_list;
>  	struct drm_property *edid_property;
>  	struct drm_property *dpms_property;
> +	struct drm_property *plane_type_property;
>  
>  	/* DVI-I properties */
>  	struct drm_property *dvi_i_subconnector_property;
> @@ -1084,7 +1085,7 @@ extern int drm_plane_init(struct drm_device *dev,
>  			  unsigned long possible_crtcs,
>  			  const struct drm_plane_funcs *funcs,
>  			  const uint32_t *formats, uint32_t format_count,
> -			  bool priv);
> +			  enum drm_plane_type type);
>  extern void drm_plane_cleanup(struct drm_plane *plane);
>  extern void drm_plane_force_disable(struct drm_plane *plane);
>
Matt Roper March 12, 2014, 4:43 p.m. UTC | #2
On Tue, Mar 11, 2014 at 04:45:00PM -0700, Bob Paauwe wrote:
> On Fri, 7 Mar 2014 16:03:17 -0800
> Matt Roper <matthew.d.roper@intel.com> wrote:
...
> > +static int drm_mode_create_standard_plane_properties(struct drm_device *dev)
> > +{
> > +	struct drm_property *type;
> > +
> > +	/*
> > +	 * Standard properties (apply to all planes)
> > +	 */
> > +	type = drm_property_create_enum(dev, 0,
> > +					"TYPE", drm_plane_type_enum_list,
> > +					ARRAY_SIZE(drm_plane_type_enum_list));
> 
> Should this property be created with DRM_MODE_PROP_IMMUTABLE set?  What
> happens if user space tries to change this property to a different type?
> 

Yep, good point.  I'll add that flag in my next revision of the
patchset.

Thanks!


Matt
diff mbox

Patch

diff --git a/drivers/gpu/drm/armada/armada_overlay.c b/drivers/gpu/drm/armada/armada_overlay.c
index c5b06fd..ef68c42 100644
--- a/drivers/gpu/drm/armada/armada_overlay.c
+++ b/drivers/gpu/drm/armada/armada_overlay.c
@@ -444,7 +444,8 @@  int armada_overlay_plane_create(struct drm_device *dev, unsigned long crtcs)
 				  dplane);
 
 	drm_plane_init(dev, &dplane->base, crtcs, &armada_plane_funcs,
-		       armada_formats, ARRAY_SIZE(armada_formats), false);
+		       armada_formats, ARRAY_SIZE(armada_formats),
+		       DRM_PLANE_TYPE_OVERLAY);
 
 	dplane->prop.colorkey_yr = 0xfefefe00;
 	dplane->prop.colorkey_ug = 0x01010100;
diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c
index 93fc2dd..5b9b512 100644
--- a/drivers/gpu/drm/drm_crtc.c
+++ b/drivers/gpu/drm/drm_crtc.c
@@ -114,6 +114,15 @@  static const struct drm_prop_enum_list drm_dpms_enum_list[] =
 
 DRM_ENUM_NAME_FN(drm_get_dpms_name, drm_dpms_enum_list)
 
+static const struct drm_prop_enum_list drm_plane_type_enum_list[] =
+{
+	{ DRM_PLANE_TYPE_OVERLAY, "Overlay" },
+	{ DRM_PLANE_TYPE_PRIMARY, "Primary" },
+	{ DRM_PLANE_TYPE_CURSOR, "Cursor" },
+};
+
+DRM_ENUM_NAME_FN(drm_get_plane_type, drm_plane_type_enum_list)
+
 /*
  * Optional properties
  */
@@ -928,7 +937,7 @@  EXPORT_SYMBOL(drm_encoder_cleanup);
  * @funcs: callbacks for the new plane
  * @formats: array of supported formats (%DRM_FORMAT_*)
  * @format_count: number of elements in @formats
- * @priv: plane is private (hidden from userspace)?
+ * @type: type of plane (overlay, primary, cursor)
  *
  * Inits a new object created as base part of a driver plane object.
  *
@@ -939,7 +948,7 @@  int drm_plane_init(struct drm_device *dev, struct drm_plane *plane,
 		   unsigned long possible_crtcs,
 		   const struct drm_plane_funcs *funcs,
 		   const uint32_t *formats, uint32_t format_count,
-		   bool priv)
+		   enum drm_plane_type type)
 {
 	int ret;
 
@@ -964,20 +973,16 @@  int drm_plane_init(struct drm_device *dev, struct drm_plane *plane,
 	memcpy(plane->format_types, formats, format_count * sizeof(uint32_t));
 	plane->format_count = format_count;
 	plane->possible_crtcs = possible_crtcs;
-	plane->type = DRM_PLANE_TYPE_OVERLAY;
+	plane->type = type;
 
-	/* private planes are not exposed to userspace, but depending on
-	 * display hardware, might be convenient to allow sharing programming
-	 * for the scanout engine with the crtc implementation.
-	 */
-	if (!priv) {
-		list_add_tail(&plane->head, &dev->mode_config.plane_list);
-		dev->mode_config.num_total_plane++;
-		if (plane->type == DRM_PLANE_TYPE_OVERLAY)
-			dev->mode_config.num_overlay_plane++;
-	} else {
-		INIT_LIST_HEAD(&plane->head);
-	}
+	list_add_tail(&plane->head, &dev->mode_config.plane_list);
+	dev->mode_config.num_total_plane++;
+	if (plane->type == DRM_PLANE_TYPE_OVERLAY)
+		dev->mode_config.num_overlay_plane++;
+
+	drm_object_attach_property(&plane->base,
+				   dev->mode_config.plane_type_property,
+				   plane->type);
 
  out:
 	drm_modeset_unlock_all(dev);
@@ -1001,13 +1006,13 @@  void drm_plane_cleanup(struct drm_plane *plane)
 	drm_modeset_lock_all(dev);
 	kfree(plane->format_types);
 	drm_mode_object_put(dev, &plane->base);
-	/* if not added to a list, it must be a private plane */
-	if (!list_empty(&plane->head)) {
-		list_del(&plane->head);
-	        dev->mode_config.num_total_plane--;
-		if (plane->type == DRM_PLANE_TYPE_OVERLAY)
-			dev->mode_config.num_overlay_plane--;
-	}
+
+	BUG_ON(list_empty(&plane->head));
+
+	list_del(&plane->head);
+	dev->mode_config.num_total_plane--;
+	if (plane->type == DRM_PLANE_TYPE_OVERLAY)
+		dev->mode_config.num_overlay_plane--;
 	drm_modeset_unlock_all(dev);
 }
 EXPORT_SYMBOL(drm_plane_cleanup);
@@ -1357,6 +1362,21 @@  static int drm_mode_create_standard_connector_properties(struct drm_device *dev)
 	return 0;
 }
 
+static int drm_mode_create_standard_plane_properties(struct drm_device *dev)
+{
+	struct drm_property *type;
+
+	/*
+	 * Standard properties (apply to all planes)
+	 */
+	type = drm_property_create_enum(dev, 0,
+					"TYPE", drm_plane_type_enum_list,
+					ARRAY_SIZE(drm_plane_type_enum_list));
+	dev->mode_config.plane_type_property = type;
+
+	return 0;
+}
+
 /**
  * drm_mode_create_dvi_i_properties - create DVI-I specific connector properties
  * @dev: DRM device
@@ -4277,6 +4297,7 @@  void drm_mode_config_init(struct drm_device *dev)
 
 	drm_modeset_lock_all(dev);
 	drm_mode_create_standard_connector_properties(dev);
+	drm_mode_create_standard_plane_properties(dev);
 	drm_modeset_unlock_all(dev);
 
 	/* Just to be sure */
diff --git a/drivers/gpu/drm/exynos/exynos_drm_plane.c b/drivers/gpu/drm/exynos/exynos_drm_plane.c
index fcb0652..7943dd3 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_plane.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_plane.c
@@ -263,14 +263,16 @@  struct drm_plane *exynos_plane_init(struct drm_device *dev,
 {
 	struct exynos_plane *exynos_plane;
 	int err;
+	enum drm_plane_type type;
 
 	exynos_plane = kzalloc(sizeof(struct exynos_plane), GFP_KERNEL);
 	if (!exynos_plane)
 		return NULL;
 
+	type = priv ? DRM_PLANE_TYPE_PRIMARY : DRM_PLANE_TYPE_OVERLAY;
 	err = drm_plane_init(dev, &exynos_plane->base, possible_crtcs,
 			      &exynos_plane_funcs, formats, ARRAY_SIZE(formats),
-			      priv);
+			      type);
 	if (err) {
 		DRM_ERROR("failed to initialize plane\n");
 		kfree(exynos_plane);
diff --git a/drivers/gpu/drm/i915/intel_sprite.c b/drivers/gpu/drm/i915/intel_sprite.c
index 336ae6c..630485c 100644
--- a/drivers/gpu/drm/i915/intel_sprite.c
+++ b/drivers/gpu/drm/i915/intel_sprite.c
@@ -1145,7 +1145,7 @@  intel_plane_init(struct drm_device *dev, enum pipe pipe, int plane)
 	ret = drm_plane_init(dev, &intel_plane->base, possible_crtcs,
 			     &intel_plane_funcs,
 			     plane_formats, num_plane_formats,
-			     false);
+			     DRM_PLANE_TYPE_OVERLAY);
 	if (ret)
 		kfree(intel_plane);
 
diff --git a/drivers/gpu/drm/msm/mdp/mdp4/mdp4_plane.c b/drivers/gpu/drm/msm/mdp/mdp4/mdp4_plane.c
index 1e893dd..afa9c67 100644
--- a/drivers/gpu/drm/msm/mdp/mdp4/mdp4_plane.c
+++ b/drivers/gpu/drm/msm/mdp/mdp4/mdp4_plane.c
@@ -222,6 +222,7 @@  struct drm_plane *mdp4_plane_init(struct drm_device *dev,
 	struct drm_plane *plane = NULL;
 	struct mdp4_plane *mdp4_plane;
 	int ret;
+	enum drm_plane_type type;
 
 	mdp4_plane = kzalloc(sizeof(*mdp4_plane), GFP_KERNEL);
 	if (!mdp4_plane) {
@@ -237,9 +238,10 @@  struct drm_plane *mdp4_plane_init(struct drm_device *dev,
 	mdp4_plane->nformats = mdp4_get_formats(pipe_id, mdp4_plane->formats,
 			ARRAY_SIZE(mdp4_plane->formats));
 
+	type = private_plane ? DRM_PLANE_TYPE_PRIMARY : DRM_PLANE_TYPE_OVERLAY;
 	drm_plane_init(dev, plane, 0xff, &mdp4_plane_funcs,
 			mdp4_plane->formats, mdp4_plane->nformats,
-			private_plane);
+			type);
 
 	mdp4_plane_install_properties(plane, &plane->base);
 
diff --git a/drivers/gpu/drm/msm/mdp/mdp5/mdp5_plane.c b/drivers/gpu/drm/msm/mdp/mdp5/mdp5_plane.c
index 0ac8bb5..faf179c 100644
--- a/drivers/gpu/drm/msm/mdp/mdp5/mdp5_plane.c
+++ b/drivers/gpu/drm/msm/mdp/mdp5/mdp5_plane.c
@@ -373,9 +373,10 @@  struct drm_plane *mdp5_plane_init(struct drm_device *dev,
 	mdp5_plane->nformats = mdp5_get_formats(pipe, mdp5_plane->formats,
 			ARRAY_SIZE(mdp5_plane->formats));
 
+	type = private_plane ? DRM_PLANE_TYPE_PRIMARY : DRM_PLANE_TYPE_OVERLAY;
 	drm_plane_init(dev, plane, 0xff, &mdp5_plane_funcs,
 			mdp5_plane->formats, mdp5_plane->nformats,
-			private_plane);
+			type);
 
 	mdp5_plane_install_properties(plane, &plane->base);
 
diff --git a/drivers/gpu/drm/nouveau/dispnv04/overlay.c b/drivers/gpu/drm/nouveau/dispnv04/overlay.c
index ab03f77..0b4f35d 100644
--- a/drivers/gpu/drm/nouveau/dispnv04/overlay.c
+++ b/drivers/gpu/drm/nouveau/dispnv04/overlay.c
@@ -276,7 +276,7 @@  nv10_overlay_init(struct drm_device *device)
 
 	ret = drm_plane_init(device, &plane->base, 3 /* both crtc's */,
 			     &nv10_plane_funcs,
-			     formats, num_formats, false);
+			     formats, num_formats, DRM_PLANE_TYPE_OVERLAY);
 	if (ret)
 		goto err;
 
@@ -456,7 +456,7 @@  nv04_overlay_init(struct drm_device *device)
 
 	ret = drm_plane_init(device, &plane->base, 1 /* single crtc */,
 			     &nv04_plane_funcs,
-			     formats, 2, false);
+			     formats, 2, DRM_PLANE_TYPE_OVERLAY);
 	if (ret)
 		goto err;
 
diff --git a/drivers/gpu/drm/omapdrm/omap_plane.c b/drivers/gpu/drm/omapdrm/omap_plane.c
index 046d5e6..d4179b2 100644
--- a/drivers/gpu/drm/omapdrm/omap_plane.c
+++ b/drivers/gpu/drm/omapdrm/omap_plane.c
@@ -384,6 +384,7 @@  struct drm_plane *omap_plane_init(struct drm_device *dev,
 	struct omap_plane *omap_plane;
 	struct omap_overlay_info *info;
 	int ret;
+	enum drm_plane_type type;
 
 	DBG("%s: priv=%d", plane_names[id], private_plane);
 
@@ -413,8 +414,9 @@  struct drm_plane *omap_plane_init(struct drm_device *dev,
 	omap_plane->error_irq.irq = omap_plane_error_irq;
 	omap_irq_register(dev, &omap_plane->error_irq);
 
+	type = private_plane ? DRM_PLANE_TYPE_PRIMARY : DRM_PLANE_TYPE_OVERLAY;
 	drm_plane_init(dev, plane, (1 << priv->num_crtcs) - 1, &omap_plane_funcs,
-			omap_plane->formats, omap_plane->nformats, private_plane);
+			omap_plane->formats, omap_plane->nformats, type);
 
 	omap_plane_install_properties(plane, &plane->base);
 
diff --git a/drivers/gpu/drm/rcar-du/rcar_du_plane.c b/drivers/gpu/drm/rcar-du/rcar_du_plane.c
index 3fb69d9..27f1531 100644
--- a/drivers/gpu/drm/rcar-du/rcar_du_plane.c
+++ b/drivers/gpu/drm/rcar-du/rcar_du_plane.c
@@ -499,7 +499,8 @@  int rcar_du_planes_register(struct rcar_du_group *rgrp)
 
 		ret = drm_plane_init(rcdu->ddev, &plane->plane, crtcs,
 				     &rcar_du_plane_funcs, formats,
-				     ARRAY_SIZE(formats), false);
+				     ARRAY_SIZE(formats),
+				     DRM_PLANE_TYPE_OVERLAY);
 		if (ret < 0)
 			return ret;
 
diff --git a/drivers/gpu/drm/shmobile/shmob_drm_plane.c b/drivers/gpu/drm/shmobile/shmob_drm_plane.c
index 060ae03..2b03fff 100644
--- a/drivers/gpu/drm/shmobile/shmob_drm_plane.c
+++ b/drivers/gpu/drm/shmobile/shmob_drm_plane.c
@@ -257,7 +257,7 @@  int shmob_drm_plane_create(struct shmob_drm_device *sdev, unsigned int index)
 
 	ret = drm_plane_init(sdev->ddev, &splane->plane, 1,
 			     &shmob_drm_plane_funcs, formats,
-			     ARRAY_SIZE(formats), false);
+			     ARRAY_SIZE(formats), DRM_PLANE_TYPE_OVERLAY);
 
 	return ret;
 }
diff --git a/drivers/gpu/drm/tegra/dc.c b/drivers/gpu/drm/tegra/dc.c
index 9336006..76e5b22 100644
--- a/drivers/gpu/drm/tegra/dc.c
+++ b/drivers/gpu/drm/tegra/dc.c
@@ -137,7 +137,8 @@  static int tegra_dc_add_planes(struct drm_device *drm, struct tegra_dc *dc)
 
 		err = drm_plane_init(drm, &plane->base, 1 << dc->pipe,
 				     &tegra_plane_funcs, plane_formats,
-				     ARRAY_SIZE(plane_formats), false);
+				     ARRAY_SIZE(plane_formats),
+				     DRM_PLANE_TYPE_OVERLAY);
 		if (err < 0) {
 			kfree(plane);
 			return err;
diff --git a/drivers/staging/imx-drm/ipuv3-plane.c b/drivers/staging/imx-drm/ipuv3-plane.c
index 34b642a..7975369 100644
--- a/drivers/staging/imx-drm/ipuv3-plane.c
+++ b/drivers/staging/imx-drm/ipuv3-plane.c
@@ -355,6 +355,7 @@  struct ipu_plane *ipu_plane_init(struct drm_device *dev, struct ipu_soc *ipu,
 {
 	struct ipu_plane *ipu_plane;
 	int ret;
+	enum drm_plane_type type;
 
 	DRM_DEBUG_KMS("channel %d, dp flow %d, possible_crtcs=0x%x\n",
 		      dma, dp, possible_crtcs);
@@ -369,10 +370,11 @@  struct ipu_plane *ipu_plane_init(struct drm_device *dev, struct ipu_soc *ipu,
 	ipu_plane->dma = dma;
 	ipu_plane->dp_flow = dp;
 
+	type = priv ? DRM_PLANE_TYPE_PRIMARY : DRM_PLANE_TYPE_OVERLAY;
 	ret = drm_plane_init(dev, &ipu_plane->base, possible_crtcs,
 			     &ipu_plane_funcs, ipu_plane_formats,
 			     ARRAY_SIZE(ipu_plane_formats),
-			     priv);
+			     type);
 	if (ret) {
 		DRM_ERROR("failed to initialize plane\n");
 		kfree(ipu_plane);
diff --git a/include/drm/drm_crtc.h b/include/drm/drm_crtc.h
index 6ecfc9d..d8a1dc8 100644
--- a/include/drm/drm_crtc.h
+++ b/include/drm/drm_crtc.h
@@ -976,6 +976,7 @@  struct drm_mode_config {
 	struct list_head property_blob_list;
 	struct drm_property *edid_property;
 	struct drm_property *dpms_property;
+	struct drm_property *plane_type_property;
 
 	/* DVI-I properties */
 	struct drm_property *dvi_i_subconnector_property;
@@ -1084,7 +1085,7 @@  extern int drm_plane_init(struct drm_device *dev,
 			  unsigned long possible_crtcs,
 			  const struct drm_plane_funcs *funcs,
 			  const uint32_t *formats, uint32_t format_count,
-			  bool priv);
+			  enum drm_plane_type type);
 extern void drm_plane_cleanup(struct drm_plane *plane);
 extern void drm_plane_force_disable(struct drm_plane *plane);