diff mbox

[5/6] drm/tile: expose the tile property to userspace

Message ID 1413787036-19114-6-git-send-email-airlied@gmail.com (mailing list archive)
State New, archived
Headers show

Commit Message

Dave Airlie Oct. 20, 2014, 6:37 a.m. UTC
From: Dave Airlie <airlied@redhat.com>

This takes the tiling info from the connector and
exposes it to userspace, as a blob object in a
connector property.

The contents of the blob is ABI.

Signed-off-by: Dave Airlie <airlied@redhat.com>
---
 drivers/gpu/drm/drm_crtc.c          | 36 ++++++++++++++++++++++++++++++++++++
 drivers/gpu/drm/i915/intel_dp_mst.c |  2 ++
 include/drm/drm_crtc.h              |  4 ++++
 3 files changed, 42 insertions(+)

Comments

David Herrmann Oct. 20, 2014, 9:15 a.m. UTC | #1
Hi

On Mon, Oct 20, 2014 at 8:37 AM, Dave Airlie <airlied@gmail.com> wrote:
> From: Dave Airlie <airlied@redhat.com>
>
> This takes the tiling info from the connector and
> exposes it to userspace, as a blob object in a
> connector property.
>
> The contents of the blob is ABI.
>
> Signed-off-by: Dave Airlie <airlied@redhat.com>
> ---
>  drivers/gpu/drm/drm_crtc.c          | 36 ++++++++++++++++++++++++++++++++++++
>  drivers/gpu/drm/i915/intel_dp_mst.c |  2 ++
>  include/drm/drm_crtc.h              |  4 ++++
>  3 files changed, 42 insertions(+)
>
> diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c
> index 93135d4..81e867a 100644
> --- a/drivers/gpu/drm/drm_crtc.c
> +++ b/drivers/gpu/drm/drm_crtc.c
> @@ -1319,6 +1319,11 @@ static int drm_mode_create_standard_connector_properties(struct drm_device *dev)
>                                        "PATH", 0);
>         dev->mode_config.path_property = dev_path;
>
> +       dev->mode_config.tile_property = drm_property_create(dev,
> +                                                            DRM_MODE_PROP_BLOB |
> +                                                            DRM_MODE_PROP_IMMUTABLE,
> +                                                            "TILE", 0);
> +
>         return 0;
>  }
>
> @@ -4004,6 +4009,37 @@ int drm_mode_connector_set_path_property(struct drm_connector *connector,
>  }
>  EXPORT_SYMBOL(drm_mode_connector_set_path_property);
>
> +int drm_mode_connector_set_tile_property(struct drm_connector *connector)
> +{
> +       struct drm_device *dev = connector->dev;
> +       int ret, size;
> +       char tile[256];
> +
> +       if (connector->tile_blob_ptr)
> +               drm_property_destroy_blob(dev, connector->tile_blob_ptr);
> +
> +       if (!connector->has_tile) {
> +               connector->tile_blob_ptr = NULL;
> +               ret = drm_object_property_set_value(&connector->base,
> +                                                   dev->mode_config.tile_property, 0);
> +               return ret;
> +       }
> +
> +       snprintf(tile, 256, "%d:%d:%d:%d:%d:%d:%d:%d", connector->tile_group->id, connector->tile_is_single_monitor, connector->num_h_tile, connector->num_v_tile, connector->tile_h_loc, connector->tile_v_loc, connector->tile_h_size, connector->tile_v_size);
> +       size = strlen(tile) + 1;
> +
> +       connector->tile_blob_ptr = drm_property_create_blob(connector->dev,
> +                                                           size, tile);
> +       if (!connector->tile_blob_ptr)
> +               return -EINVAL;
> +
> +       ret = drm_object_property_set_value(&connector->base,
> +                                           dev->mode_config.tile_property,
> +                                           connector->tile_blob_ptr->base.id);

I recently looked at property hotplugging and I think it needs the
same fix you pushed for connectors (drm_mode_object_get_reg() and
friends). I wanted to look at the same thing for brightness
properties, but didn't have time for that so far.
The race is mostly theoretical, but I think we should still try to fix it.

Thanks
David

> +       return ret;
> +}
> +EXPORT_SYMBOL(drm_mode_connector_set_tile_property);
> +
>  /**
>   * drm_mode_connector_update_edid_property - update the edid property of a connector
>   * @connector: drm connector
> diff --git a/drivers/gpu/drm/i915/intel_dp_mst.c b/drivers/gpu/drm/i915/intel_dp_mst.c
> index c66e73a..c5529ff 100644
> --- a/drivers/gpu/drm/i915/intel_dp_mst.c
> +++ b/drivers/gpu/drm/i915/intel_dp_mst.c
> @@ -422,6 +422,8 @@ static struct drm_connector *intel_dp_add_mst_connector(struct drm_dp_mst_topolo
>         intel_dp_add_properties(intel_dp, connector);
>
>         drm_object_attach_property(&connector->base, dev->mode_config.path_property, 0);
> +       drm_object_attach_property(&connector->base, dev->mode_config.tile_property, 0);
> +
>         drm_mode_connector_set_path_property(connector, pathprop);
>         drm_reinit_primary_mode_group(dev);
>         mutex_lock(&dev->mode_config.mutex);
> diff --git a/include/drm/drm_crtc.h b/include/drm/drm_crtc.h
> index d71b6d7..39d744b 100644
> --- a/include/drm/drm_crtc.h
> +++ b/include/drm/drm_crtc.h
> @@ -548,6 +548,8 @@ struct drm_connector {
>
>         struct drm_property_blob *path_blob_ptr;
>
> +       struct drm_property_blob *tile_blob_ptr;
> +
>         uint8_t polled; /* DRM_CONNECTOR_POLL_* */
>
>         /* requested DPMS state */
> @@ -838,6 +840,7 @@ struct drm_mode_config {
>         struct drm_property *edid_property;
>         struct drm_property *dpms_property;
>         struct drm_property *path_property;
> +       struct drm_property *tile_property;
>         struct drm_property *plane_type_property;
>
>         /* DVI-I properties */
> @@ -990,6 +993,7 @@ extern void drm_mode_config_cleanup(struct drm_device *dev);
>
>  extern int drm_mode_connector_set_path_property(struct drm_connector *connector,
>                                                 char *path);
> +int drm_mode_connector_set_tile_property(struct drm_connector *connector);
>  extern int drm_mode_connector_update_edid_property(struct drm_connector *connector,
>                                                 struct edid *edid);
>
> --
> 2.1.0
>
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/dri-devel
Daniel Vetter Oct. 20, 2014, 3:31 p.m. UTC | #2
On Mon, Oct 20, 2014 at 04:37:15PM +1000, Dave Airlie wrote:
> From: Dave Airlie <airlied@redhat.com>
> 
> This takes the tiling info from the connector and
> exposes it to userspace, as a blob object in a
> connector property.
> 
> The contents of the blob is ABI.
> 
> Signed-off-by: Dave Airlie <airlied@redhat.com>
> ---
>  drivers/gpu/drm/drm_crtc.c          | 36 ++++++++++++++++++++++++++++++++++++
>  drivers/gpu/drm/i915/intel_dp_mst.c |  2 ++
>  include/drm/drm_crtc.h              |  4 ++++
>  3 files changed, 42 insertions(+)
> 
> diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c
> index 93135d4..81e867a 100644
> --- a/drivers/gpu/drm/drm_crtc.c
> +++ b/drivers/gpu/drm/drm_crtc.c
> @@ -1319,6 +1319,11 @@ static int drm_mode_create_standard_connector_properties(struct drm_device *dev)
>  				       "PATH", 0);
>  	dev->mode_config.path_property = dev_path;
>  
> +	dev->mode_config.tile_property = drm_property_create(dev,
> +							     DRM_MODE_PROP_BLOB |
> +							     DRM_MODE_PROP_IMMUTABLE,
> +							     "TILE", 0);
> +
>  	return 0;
>  }
>  
> @@ -4004,6 +4009,37 @@ int drm_mode_connector_set_path_property(struct drm_connector *connector,
>  }
>  EXPORT_SYMBOL(drm_mode_connector_set_path_property);
>  
> +int drm_mode_connector_set_tile_property(struct drm_connector *connector)

Same again, please add some kerneldoc for this function here.
-Daniel

> +{
> +	struct drm_device *dev = connector->dev;
> +	int ret, size;
> +	char tile[256];
> +
> +	if (connector->tile_blob_ptr)
> +		drm_property_destroy_blob(dev, connector->tile_blob_ptr);
> +
> +	if (!connector->has_tile) {
> +		connector->tile_blob_ptr = NULL;
> +		ret = drm_object_property_set_value(&connector->base,
> +						    dev->mode_config.tile_property, 0);
> +		return ret;
> +	}
> +
> +	snprintf(tile, 256, "%d:%d:%d:%d:%d:%d:%d:%d", connector->tile_group->id, connector->tile_is_single_monitor, connector->num_h_tile, connector->num_v_tile, connector->tile_h_loc, connector->tile_v_loc, connector->tile_h_size, connector->tile_v_size);
> +	size = strlen(tile) + 1;
> +
> +	connector->tile_blob_ptr = drm_property_create_blob(connector->dev,
> +							    size, tile);
> +	if (!connector->tile_blob_ptr)
> +		return -EINVAL;
> +
> +	ret = drm_object_property_set_value(&connector->base,
> +					    dev->mode_config.tile_property,
> +					    connector->tile_blob_ptr->base.id);
> +	return ret;
> +}
> +EXPORT_SYMBOL(drm_mode_connector_set_tile_property);
> +
>  /**
>   * drm_mode_connector_update_edid_property - update the edid property of a connector
>   * @connector: drm connector
> diff --git a/drivers/gpu/drm/i915/intel_dp_mst.c b/drivers/gpu/drm/i915/intel_dp_mst.c
> index c66e73a..c5529ff 100644
> --- a/drivers/gpu/drm/i915/intel_dp_mst.c
> +++ b/drivers/gpu/drm/i915/intel_dp_mst.c
> @@ -422,6 +422,8 @@ static struct drm_connector *intel_dp_add_mst_connector(struct drm_dp_mst_topolo
>  	intel_dp_add_properties(intel_dp, connector);
>  
>  	drm_object_attach_property(&connector->base, dev->mode_config.path_property, 0);
> +	drm_object_attach_property(&connector->base, dev->mode_config.tile_property, 0);
> +
>  	drm_mode_connector_set_path_property(connector, pathprop);
>  	drm_reinit_primary_mode_group(dev);
>  	mutex_lock(&dev->mode_config.mutex);
> diff --git a/include/drm/drm_crtc.h b/include/drm/drm_crtc.h
> index d71b6d7..39d744b 100644
> --- a/include/drm/drm_crtc.h
> +++ b/include/drm/drm_crtc.h
> @@ -548,6 +548,8 @@ struct drm_connector {
>  
>  	struct drm_property_blob *path_blob_ptr;
>  
> +	struct drm_property_blob *tile_blob_ptr;
> +
>  	uint8_t polled; /* DRM_CONNECTOR_POLL_* */
>  
>  	/* requested DPMS state */
> @@ -838,6 +840,7 @@ struct drm_mode_config {
>  	struct drm_property *edid_property;
>  	struct drm_property *dpms_property;
>  	struct drm_property *path_property;
> +	struct drm_property *tile_property;
>  	struct drm_property *plane_type_property;
>  
>  	/* DVI-I properties */
> @@ -990,6 +993,7 @@ extern void drm_mode_config_cleanup(struct drm_device *dev);
>  
>  extern int drm_mode_connector_set_path_property(struct drm_connector *connector,
>  						char *path);
> +int drm_mode_connector_set_tile_property(struct drm_connector *connector);
>  extern int drm_mode_connector_update_edid_property(struct drm_connector *connector,
>  						struct edid *edid);
>  
> -- 
> 2.1.0
> 
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Daniel Vetter Oct. 20, 2014, 3:34 p.m. UTC | #3
On Mon, Oct 20, 2014 at 05:31:51PM +0200, Daniel Vetter wrote:
> On Mon, Oct 20, 2014 at 04:37:15PM +1000, Dave Airlie wrote:
> > From: Dave Airlie <airlied@redhat.com>
> > 
> > This takes the tiling info from the connector and
> > exposes it to userspace, as a blob object in a
> > connector property.
> > 
> > The contents of the blob is ABI.
> > 
> > Signed-off-by: Dave Airlie <airlied@redhat.com>
> > ---
> >  drivers/gpu/drm/drm_crtc.c          | 36 ++++++++++++++++++++++++++++++++++++
> >  drivers/gpu/drm/i915/intel_dp_mst.c |  2 ++
> >  include/drm/drm_crtc.h              |  4 ++++
> >  3 files changed, 42 insertions(+)
> > 
> > diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c
> > index 93135d4..81e867a 100644
> > --- a/drivers/gpu/drm/drm_crtc.c
> > +++ b/drivers/gpu/drm/drm_crtc.c
> > @@ -1319,6 +1319,11 @@ static int drm_mode_create_standard_connector_properties(struct drm_device *dev)
> >  				       "PATH", 0);
> >  	dev->mode_config.path_property = dev_path;
> >  
> > +	dev->mode_config.tile_property = drm_property_create(dev,
> > +							     DRM_MODE_PROP_BLOB |
> > +							     DRM_MODE_PROP_IMMUTABLE,
> > +							     "TILE", 0);
> > +
> >  	return 0;
> >  }
> >  
> > @@ -4004,6 +4009,37 @@ int drm_mode_connector_set_path_property(struct drm_connector *connector,
> >  }
> >  EXPORT_SYMBOL(drm_mode_connector_set_path_property);
> >  
> > +int drm_mode_connector_set_tile_property(struct drm_connector *connector)
> 
> Same again, please add some kerneldoc for this function here.

While at it, please also add the missing kerneldoc for the functions
you've already added for dp mst support.

Thanks, Daniel
Daniel Vetter Oct. 20, 2014, 3:35 p.m. UTC | #4
On Mon, Oct 20, 2014 at 05:34:11PM +0200, Daniel Vetter wrote:
> On Mon, Oct 20, 2014 at 05:31:51PM +0200, Daniel Vetter wrote:
> > On Mon, Oct 20, 2014 at 04:37:15PM +1000, Dave Airlie wrote:
> > > From: Dave Airlie <airlied@redhat.com>
> > > 
> > > This takes the tiling info from the connector and
> > > exposes it to userspace, as a blob object in a
> > > connector property.
> > > 
> > > The contents of the blob is ABI.
> > > 
> > > Signed-off-by: Dave Airlie <airlied@redhat.com>
> > > ---
> > >  drivers/gpu/drm/drm_crtc.c          | 36 ++++++++++++++++++++++++++++++++++++
> > >  drivers/gpu/drm/i915/intel_dp_mst.c |  2 ++
> > >  include/drm/drm_crtc.h              |  4 ++++
> > >  3 files changed, 42 insertions(+)
> > > 
> > > diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c
> > > index 93135d4..81e867a 100644
> > > --- a/drivers/gpu/drm/drm_crtc.c
> > > +++ b/drivers/gpu/drm/drm_crtc.c
> > > @@ -1319,6 +1319,11 @@ static int drm_mode_create_standard_connector_properties(struct drm_device *dev)
> > >  				       "PATH", 0);
> > >  	dev->mode_config.path_property = dev_path;
> > >  
> > > +	dev->mode_config.tile_property = drm_property_create(dev,
> > > +							     DRM_MODE_PROP_BLOB |
> > > +							     DRM_MODE_PROP_IMMUTABLE,
> > > +							     "TILE", 0);
> > > +
> > >  	return 0;
> > >  }
> > >  
> > > @@ -4004,6 +4009,37 @@ int drm_mode_connector_set_path_property(struct drm_connector *connector,
> > >  }
> > >  EXPORT_SYMBOL(drm_mode_connector_set_path_property);
> > >  
> > > +int drm_mode_connector_set_tile_property(struct drm_connector *connector)
> > 
> > Same again, please add some kerneldoc for this function here.
> 
> While at it, please also add the missing kerneldoc for the functions
> you've already added for dp mst support.

And the docbook xml table with all the properties we have should also be
updated for both of them.
-Daniel
diff mbox

Patch

diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c
index 93135d4..81e867a 100644
--- a/drivers/gpu/drm/drm_crtc.c
+++ b/drivers/gpu/drm/drm_crtc.c
@@ -1319,6 +1319,11 @@  static int drm_mode_create_standard_connector_properties(struct drm_device *dev)
 				       "PATH", 0);
 	dev->mode_config.path_property = dev_path;
 
+	dev->mode_config.tile_property = drm_property_create(dev,
+							     DRM_MODE_PROP_BLOB |
+							     DRM_MODE_PROP_IMMUTABLE,
+							     "TILE", 0);
+
 	return 0;
 }
 
@@ -4004,6 +4009,37 @@  int drm_mode_connector_set_path_property(struct drm_connector *connector,
 }
 EXPORT_SYMBOL(drm_mode_connector_set_path_property);
 
+int drm_mode_connector_set_tile_property(struct drm_connector *connector)
+{
+	struct drm_device *dev = connector->dev;
+	int ret, size;
+	char tile[256];
+
+	if (connector->tile_blob_ptr)
+		drm_property_destroy_blob(dev, connector->tile_blob_ptr);
+
+	if (!connector->has_tile) {
+		connector->tile_blob_ptr = NULL;
+		ret = drm_object_property_set_value(&connector->base,
+						    dev->mode_config.tile_property, 0);
+		return ret;
+	}
+
+	snprintf(tile, 256, "%d:%d:%d:%d:%d:%d:%d:%d", connector->tile_group->id, connector->tile_is_single_monitor, connector->num_h_tile, connector->num_v_tile, connector->tile_h_loc, connector->tile_v_loc, connector->tile_h_size, connector->tile_v_size);
+	size = strlen(tile) + 1;
+
+	connector->tile_blob_ptr = drm_property_create_blob(connector->dev,
+							    size, tile);
+	if (!connector->tile_blob_ptr)
+		return -EINVAL;
+
+	ret = drm_object_property_set_value(&connector->base,
+					    dev->mode_config.tile_property,
+					    connector->tile_blob_ptr->base.id);
+	return ret;
+}
+EXPORT_SYMBOL(drm_mode_connector_set_tile_property);
+
 /**
  * drm_mode_connector_update_edid_property - update the edid property of a connector
  * @connector: drm connector
diff --git a/drivers/gpu/drm/i915/intel_dp_mst.c b/drivers/gpu/drm/i915/intel_dp_mst.c
index c66e73a..c5529ff 100644
--- a/drivers/gpu/drm/i915/intel_dp_mst.c
+++ b/drivers/gpu/drm/i915/intel_dp_mst.c
@@ -422,6 +422,8 @@  static struct drm_connector *intel_dp_add_mst_connector(struct drm_dp_mst_topolo
 	intel_dp_add_properties(intel_dp, connector);
 
 	drm_object_attach_property(&connector->base, dev->mode_config.path_property, 0);
+	drm_object_attach_property(&connector->base, dev->mode_config.tile_property, 0);
+
 	drm_mode_connector_set_path_property(connector, pathprop);
 	drm_reinit_primary_mode_group(dev);
 	mutex_lock(&dev->mode_config.mutex);
diff --git a/include/drm/drm_crtc.h b/include/drm/drm_crtc.h
index d71b6d7..39d744b 100644
--- a/include/drm/drm_crtc.h
+++ b/include/drm/drm_crtc.h
@@ -548,6 +548,8 @@  struct drm_connector {
 
 	struct drm_property_blob *path_blob_ptr;
 
+	struct drm_property_blob *tile_blob_ptr;
+
 	uint8_t polled; /* DRM_CONNECTOR_POLL_* */
 
 	/* requested DPMS state */
@@ -838,6 +840,7 @@  struct drm_mode_config {
 	struct drm_property *edid_property;
 	struct drm_property *dpms_property;
 	struct drm_property *path_property;
+	struct drm_property *tile_property;
 	struct drm_property *plane_type_property;
 
 	/* DVI-I properties */
@@ -990,6 +993,7 @@  extern void drm_mode_config_cleanup(struct drm_device *dev);
 
 extern int drm_mode_connector_set_path_property(struct drm_connector *connector,
 						char *path);
+int drm_mode_connector_set_tile_property(struct drm_connector *connector);
 extern int drm_mode_connector_update_edid_property(struct drm_connector *connector,
 						struct edid *edid);