diff mbox

[1/3] drm: Add an "expose 3d modes" property

Message ID 1348771268-3436-2-git-send-email-damien.lespiau@gmail.com (mailing list archive)
State New, archived
Headers show

Commit Message

Damien Lespiau Sept. 27, 2012, 6:41 p.m. UTC
From: Damien Lespiau <damien.lespiau@intel.com>

The "expose 3D modes" property can be attached to connectors to allow
user space to indicate it can deal with 3D modes and that the drm driver
should expose those 3D modes.

Signed-off-by: Damien Lespiau <damien.lespiau@intel.com>
---
 drivers/gpu/drm/drm_crtc.c | 35 ++++++++++++++++++++++++++++++++++-
 include/drm/drm_crtc.h     |  6 ++++++
 include/drm/drm_mode.h     |  4 ++++
 3 files changed, 44 insertions(+), 1 deletion(-)

Comments

Rodrigo Vivi Sept. 29, 2012, 12:45 a.m. UTC | #1
Reviewed-by: Rodrigo Vivi <rodrigo.vivi@gmail.com>
Tested-by: Rodrigo Vivi <rodrigo.vivi@gmail.com>

On Thu, Sep 27, 2012 at 3:41 PM, Damien Lespiau
<damien.lespiau@gmail.com> wrote:
> From: Damien Lespiau <damien.lespiau@intel.com>
>
> The "expose 3D modes" property can be attached to connectors to allow
> user space to indicate it can deal with 3D modes and that the drm driver
> should expose those 3D modes.
>
> Signed-off-by: Damien Lespiau <damien.lespiau@intel.com>
> ---
>  drivers/gpu/drm/drm_crtc.c | 35 ++++++++++++++++++++++++++++++++++-
>  include/drm/drm_crtc.h     |  6 ++++++
>  include/drm/drm_mode.h     |  4 ++++
>  3 files changed, 44 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c
> index 6fbfc24..10a289c 100644
> --- a/drivers/gpu/drm/drm_crtc.c
> +++ b/drivers/gpu/drm/drm_crtc.c
> @@ -841,6 +841,35 @@ int drm_mode_create_tv_properties(struct drm_device *dev, int num_modes,
>  }
>  EXPORT_SYMBOL(drm_mode_create_tv_properties);
>
> +static const struct drm_prop_enum_list expose_3d_modes_list[] =
> +{
> +       { DRM_MODE_EXPOSE_3D_MODES_OFF, "Off" },
> +       { DRM_MODE_EXPOSE_3D_MODES_ON, "On" }
> +};
> +
> +/**
> + * drm_mode_create_s3d_properties - create stereo 3D properties
> + * @dev: DRM device
> + *
> + * This functions create properties that are used by the stereo 3D code. Those
> + * properties must be attached to the desired connectors afterwards.
> + */
> +int drm_mode_create_s3d_properties(struct drm_device *dev)
> +{
> +       struct drm_property *prop;
> +
> +       if (dev->mode_config.s3d_expose_modes_property)
> +               return 0;
> +
> +       prop = drm_property_create_enum(dev, 0, "expose 3D modes",
> +                                       expose_3d_modes_list,
> +                                       ARRAY_SIZE(expose_3d_modes_list));
> +       dev->mode_config.s3d_expose_modes_property = prop;
> +
> +       return 0;
> +}
> +EXPORT_SYMBOL(drm_mode_create_s3d_properties);
> +
>  /**
>   * drm_mode_create_scaling_mode_property - create scaling mode property
>   * @dev: DRM device
> @@ -3170,12 +3199,16 @@ static int drm_mode_connector_set_obj_prop(struct drm_mode_object *obj,
>  {
>         int ret = -EINVAL;
>         struct drm_connector *connector = obj_to_connector(obj);
> +       struct drm_device *dev = connector->dev;
>
>         /* Do DPMS ourselves */
> -       if (property == connector->dev->mode_config.dpms_property) {
> +       if (property == dev->mode_config.dpms_property) {
>                 if (connector->funcs->dpms)
>                         (*connector->funcs->dpms)(connector, (int)value);
>                 ret = 0;
> +       } else if (property == dev->mode_config.s3d_expose_modes_property) {
> +               connector->expose_3d_modes = value;
> +               ret = 0;
>         } else if (connector->funcs->set_property)
>                 ret = connector->funcs->set_property(connector, property, value);
>
> diff --git a/include/drm/drm_crtc.h b/include/drm/drm_crtc.h
> index bfacf0d..34372cb 100644
> --- a/include/drm/drm_crtc.h
> +++ b/include/drm/drm_crtc.h
> @@ -578,6 +578,8 @@ struct drm_connector {
>         /* requested DPMS state */
>         int dpms;
>
> +       int expose_3d_modes;
> +
>         void *helper_private;
>
>         /* forced on connector */
> @@ -802,6 +804,9 @@ struct drm_mode_config {
>         struct drm_property *tv_saturation_property;
>         struct drm_property *tv_hue_property;
>
> +       /* Stereo 3D properties */
> +       struct drm_property *s3d_expose_modes_property;
> +
>         /* Optional properties */
>         struct drm_property *scaling_mode_property;
>         struct drm_property *dithering_mode_property;
> @@ -950,6 +955,7 @@ extern int drm_property_add_enum(struct drm_property *property, int index,
>  extern int drm_mode_create_dvi_i_properties(struct drm_device *dev);
>  extern int drm_mode_create_tv_properties(struct drm_device *dev, int num_formats,
>                                      char *formats[]);
> +extern int drm_mode_create_s3d_properties(struct drm_device *dev);
>  extern int drm_mode_create_scaling_mode_property(struct drm_device *dev);
>  extern int drm_mode_create_dithering_property(struct drm_device *dev);
>  extern int drm_mode_create_dirty_info_property(struct drm_device *dev);
> diff --git a/include/drm/drm_mode.h b/include/drm/drm_mode.h
> index 3d6301b..45b19c6 100644
> --- a/include/drm/drm_mode.h
> +++ b/include/drm/drm_mode.h
> @@ -83,6 +83,10 @@
>  #define DRM_MODE_DIRTY_ON       1
>  #define DRM_MODE_DIRTY_ANNOTATE 2
>
> +/* Expose 3D modes */
> +#define DRM_MODE_EXPOSE_3D_MODES_OFF   0
> +#define DRM_MODE_EXPOSE_3D_MODES_ON    1
> +
>  struct drm_mode_modeinfo {
>         __u32 clock;
>         __u16 hdisplay, hsync_start, hsync_end, htotal, hskew;
> --
> 1.7.11.4
>
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Chris Wilson Sept. 29, 2012, 9:01 a.m. UTC | #2
On Thu, 27 Sep 2012 19:41:06 +0100, Damien Lespiau <damien.lespiau@gmail.com> wrote:
> From: Damien Lespiau <damien.lespiau@intel.com>
> 
> The "expose 3D modes" property can be attached to connectors to allow
> user space to indicate it can deal with 3D modes and that the drm driver
> should expose those 3D modes.
> 
> Signed-off-by: Damien Lespiau <damien.lespiau@intel.com>
> ---
> diff --git a/include/drm/drm_crtc.h b/include/drm/drm_crtc.h
> index bfacf0d..34372cb 100644
> --- a/include/drm/drm_crtc.h
> +++ b/include/drm/drm_crtc.h
> @@ -578,6 +578,8 @@ struct drm_connector {
>  	/* requested DPMS state */
>  	int dpms;
>  
> +	int expose_3d_modes;

Looking at the surrounding code, this should be moved up and called
  bool stereo_allowed;
-Chris
Daniel Vetter Oct. 4, 2012, 1:35 p.m. UTC | #3
On Thu, Sep 27, 2012 at 07:41:06PM +0100, Damien Lespiau wrote:
> From: Damien Lespiau <damien.lespiau@intel.com>
> 
> The "expose 3D modes" property can be attached to connectors to allow
> user space to indicate it can deal with 3D modes and that the drm driver
> should expose those 3D modes.
> 
> Signed-off-by: Damien Lespiau <damien.lespiau@intel.com>

I've thought a bit more about this and I don't like the connector prop so
much any more:
- connector properties stick around, so if you mix up your userspace
  things could go wrong (e.g. i-g-t tests and ddx).
- connector properties are exposed to users by default.
- it makes little sense for userspace to not enable this on all
  connectors.

So I think a per-file_priv option to not filter out 3d modes would be
better suited.

We don't yet have any driver-agnostic ioctl yet for such things, so would
require a bit more work ...
-Daniel


> ---
>  drivers/gpu/drm/drm_crtc.c | 35 ++++++++++++++++++++++++++++++++++-
>  include/drm/drm_crtc.h     |  6 ++++++
>  include/drm/drm_mode.h     |  4 ++++
>  3 files changed, 44 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c
> index 6fbfc24..10a289c 100644
> --- a/drivers/gpu/drm/drm_crtc.c
> +++ b/drivers/gpu/drm/drm_crtc.c
> @@ -841,6 +841,35 @@ int drm_mode_create_tv_properties(struct drm_device *dev, int num_modes,
>  }
>  EXPORT_SYMBOL(drm_mode_create_tv_properties);
>  
> +static const struct drm_prop_enum_list expose_3d_modes_list[] =
> +{
> +	{ DRM_MODE_EXPOSE_3D_MODES_OFF, "Off" },
> +	{ DRM_MODE_EXPOSE_3D_MODES_ON, "On" }
> +};
> +
> +/**
> + * drm_mode_create_s3d_properties - create stereo 3D properties
> + * @dev: DRM device
> + *
> + * This functions create properties that are used by the stereo 3D code. Those
> + * properties must be attached to the desired connectors afterwards.
> + */
> +int drm_mode_create_s3d_properties(struct drm_device *dev)
> +{
> +	struct drm_property *prop;
> +
> +	if (dev->mode_config.s3d_expose_modes_property)
> +		return 0;
> +
> +	prop = drm_property_create_enum(dev, 0, "expose 3D modes",
> +					expose_3d_modes_list,
> +					ARRAY_SIZE(expose_3d_modes_list));
> +	dev->mode_config.s3d_expose_modes_property = prop;
> +
> +	return 0;
> +}
> +EXPORT_SYMBOL(drm_mode_create_s3d_properties);
> +
>  /**
>   * drm_mode_create_scaling_mode_property - create scaling mode property
>   * @dev: DRM device
> @@ -3170,12 +3199,16 @@ static int drm_mode_connector_set_obj_prop(struct drm_mode_object *obj,
>  {
>  	int ret = -EINVAL;
>  	struct drm_connector *connector = obj_to_connector(obj);
> +	struct drm_device *dev = connector->dev;
>  
>  	/* Do DPMS ourselves */
> -	if (property == connector->dev->mode_config.dpms_property) {
> +	if (property == dev->mode_config.dpms_property) {
>  		if (connector->funcs->dpms)
>  			(*connector->funcs->dpms)(connector, (int)value);
>  		ret = 0;
> +	} else if (property == dev->mode_config.s3d_expose_modes_property) {
> +		connector->expose_3d_modes = value;
> +		ret = 0;
>  	} else if (connector->funcs->set_property)
>  		ret = connector->funcs->set_property(connector, property, value);
>  
> diff --git a/include/drm/drm_crtc.h b/include/drm/drm_crtc.h
> index bfacf0d..34372cb 100644
> --- a/include/drm/drm_crtc.h
> +++ b/include/drm/drm_crtc.h
> @@ -578,6 +578,8 @@ struct drm_connector {
>  	/* requested DPMS state */
>  	int dpms;
>  
> +	int expose_3d_modes;
> +
>  	void *helper_private;
>  
>  	/* forced on connector */
> @@ -802,6 +804,9 @@ struct drm_mode_config {
>  	struct drm_property *tv_saturation_property;
>  	struct drm_property *tv_hue_property;
>  
> +	/* Stereo 3D properties */
> +	struct drm_property *s3d_expose_modes_property;
> +
>  	/* Optional properties */
>  	struct drm_property *scaling_mode_property;
>  	struct drm_property *dithering_mode_property;
> @@ -950,6 +955,7 @@ extern int drm_property_add_enum(struct drm_property *property, int index,
>  extern int drm_mode_create_dvi_i_properties(struct drm_device *dev);
>  extern int drm_mode_create_tv_properties(struct drm_device *dev, int num_formats,
>  				     char *formats[]);
> +extern int drm_mode_create_s3d_properties(struct drm_device *dev);
>  extern int drm_mode_create_scaling_mode_property(struct drm_device *dev);
>  extern int drm_mode_create_dithering_property(struct drm_device *dev);
>  extern int drm_mode_create_dirty_info_property(struct drm_device *dev);
> diff --git a/include/drm/drm_mode.h b/include/drm/drm_mode.h
> index 3d6301b..45b19c6 100644
> --- a/include/drm/drm_mode.h
> +++ b/include/drm/drm_mode.h
> @@ -83,6 +83,10 @@
>  #define DRM_MODE_DIRTY_ON       1
>  #define DRM_MODE_DIRTY_ANNOTATE 2
>  
> +/* Expose 3D modes */
> +#define DRM_MODE_EXPOSE_3D_MODES_OFF	0
> +#define DRM_MODE_EXPOSE_3D_MODES_ON	1
> +
>  struct drm_mode_modeinfo {
>  	__u32 clock;
>  	__u16 hdisplay, hsync_start, hsync_end, htotal, hskew;
> -- 
> 1.7.11.4
> 
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Imre Deak Oct. 4, 2012, 1:56 p.m. UTC | #4
On Thu, 2012-10-04 at 15:35 +0200, Daniel Vetter wrote:
> On Thu, Sep 27, 2012 at 07:41:06PM +0100, Damien Lespiau wrote:
> > From: Damien Lespiau <damien.lespiau@intel.com>
> > 
> > The "expose 3D modes" property can be attached to connectors to allow
> > user space to indicate it can deal with 3D modes and that the drm driver
> > should expose those 3D modes.
> > 
> > Signed-off-by: Damien Lespiau <damien.lespiau@intel.com>
> 
> I've thought a bit more about this and I don't like the connector prop so
> much any more:
> - connector properties stick around, so if you mix up your userspace
>   things could go wrong (e.g. i-g-t tests and ddx).
> - connector properties are exposed to users by default.
> - it makes little sense for userspace to not enable this on all
>   connectors.
> 
> So I think a per-file_priv option to not filter out 3d modes would be
> better suited.
> 
> We don't yet have any driver-agnostic ioctl yet for such things, so would
> require a bit more work ...

This would be useful for the monotonic time stamp support too. At the
moment the client would have to set a flag whether it wants real or raw
timestamp for each wait-for-vblank and page-flip ioctl, though what it
really needs is a one time setting.

--Imre
diff mbox

Patch

diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c
index 6fbfc24..10a289c 100644
--- a/drivers/gpu/drm/drm_crtc.c
+++ b/drivers/gpu/drm/drm_crtc.c
@@ -841,6 +841,35 @@  int drm_mode_create_tv_properties(struct drm_device *dev, int num_modes,
 }
 EXPORT_SYMBOL(drm_mode_create_tv_properties);
 
+static const struct drm_prop_enum_list expose_3d_modes_list[] =
+{
+	{ DRM_MODE_EXPOSE_3D_MODES_OFF, "Off" },
+	{ DRM_MODE_EXPOSE_3D_MODES_ON, "On" }
+};
+
+/**
+ * drm_mode_create_s3d_properties - create stereo 3D properties
+ * @dev: DRM device
+ *
+ * This functions create properties that are used by the stereo 3D code. Those
+ * properties must be attached to the desired connectors afterwards.
+ */
+int drm_mode_create_s3d_properties(struct drm_device *dev)
+{
+	struct drm_property *prop;
+
+	if (dev->mode_config.s3d_expose_modes_property)
+		return 0;
+
+	prop = drm_property_create_enum(dev, 0, "expose 3D modes",
+					expose_3d_modes_list,
+					ARRAY_SIZE(expose_3d_modes_list));
+	dev->mode_config.s3d_expose_modes_property = prop;
+
+	return 0;
+}
+EXPORT_SYMBOL(drm_mode_create_s3d_properties);
+
 /**
  * drm_mode_create_scaling_mode_property - create scaling mode property
  * @dev: DRM device
@@ -3170,12 +3199,16 @@  static int drm_mode_connector_set_obj_prop(struct drm_mode_object *obj,
 {
 	int ret = -EINVAL;
 	struct drm_connector *connector = obj_to_connector(obj);
+	struct drm_device *dev = connector->dev;
 
 	/* Do DPMS ourselves */
-	if (property == connector->dev->mode_config.dpms_property) {
+	if (property == dev->mode_config.dpms_property) {
 		if (connector->funcs->dpms)
 			(*connector->funcs->dpms)(connector, (int)value);
 		ret = 0;
+	} else if (property == dev->mode_config.s3d_expose_modes_property) {
+		connector->expose_3d_modes = value;
+		ret = 0;
 	} else if (connector->funcs->set_property)
 		ret = connector->funcs->set_property(connector, property, value);
 
diff --git a/include/drm/drm_crtc.h b/include/drm/drm_crtc.h
index bfacf0d..34372cb 100644
--- a/include/drm/drm_crtc.h
+++ b/include/drm/drm_crtc.h
@@ -578,6 +578,8 @@  struct drm_connector {
 	/* requested DPMS state */
 	int dpms;
 
+	int expose_3d_modes;
+
 	void *helper_private;
 
 	/* forced on connector */
@@ -802,6 +804,9 @@  struct drm_mode_config {
 	struct drm_property *tv_saturation_property;
 	struct drm_property *tv_hue_property;
 
+	/* Stereo 3D properties */
+	struct drm_property *s3d_expose_modes_property;
+
 	/* Optional properties */
 	struct drm_property *scaling_mode_property;
 	struct drm_property *dithering_mode_property;
@@ -950,6 +955,7 @@  extern int drm_property_add_enum(struct drm_property *property, int index,
 extern int drm_mode_create_dvi_i_properties(struct drm_device *dev);
 extern int drm_mode_create_tv_properties(struct drm_device *dev, int num_formats,
 				     char *formats[]);
+extern int drm_mode_create_s3d_properties(struct drm_device *dev);
 extern int drm_mode_create_scaling_mode_property(struct drm_device *dev);
 extern int drm_mode_create_dithering_property(struct drm_device *dev);
 extern int drm_mode_create_dirty_info_property(struct drm_device *dev);
diff --git a/include/drm/drm_mode.h b/include/drm/drm_mode.h
index 3d6301b..45b19c6 100644
--- a/include/drm/drm_mode.h
+++ b/include/drm/drm_mode.h
@@ -83,6 +83,10 @@ 
 #define DRM_MODE_DIRTY_ON       1
 #define DRM_MODE_DIRTY_ANNOTATE 2
 
+/* Expose 3D modes */
+#define DRM_MODE_EXPOSE_3D_MODES_OFF	0
+#define DRM_MODE_EXPOSE_3D_MODES_ON	1
+
 struct drm_mode_modeinfo {
 	__u32 clock;
 	__u16 hdisplay, hsync_start, hsync_end, htotal, hskew;