diff mbox

[2/2] drm: add plane properties

Message ID 1337158738-31685-3-git-send-email-rob.clark@linaro.org
State New
Headers show

Commit Message

Rob Clark May 16, 2012, 8:58 a.m. UTC
From: Rob Clark <rob@ti.com>

The omapdrm driver uses this for setting per-overlay rotation.  It
is likely also useful for setting YUV->RGB colorspace conversion
matrix, etc.

Signed-off-by: Rob Clark <rob@ti.com>
---
 drivers/gpu/drm/drm_crtc.c |   19 +++++++++++++++++++
 include/drm/drm_crtc.h     |    5 +++++
 2 files changed, 24 insertions(+)

Comments

Paulo Zanoni May 16, 2012, 5:55 p.m. UTC | #1
2012/5/16 Rob Clark <rob.clark@linaro.org>:
> From: Rob Clark <rob@ti.com>
>
> The omapdrm driver uses this for setting per-overlay rotation.  It
> is likely also useful for setting YUV->RGB colorspace conversion
> matrix, etc.
>
> Signed-off-by: Rob Clark <rob@ti.com>

Please add comments inside include/drm/drm_crtc.h documenting the new
added fields of drm_plane_funcs and drm_funcs (we already have
descriptions of all the other fields).

With that:
Reviewed-by: Paulo Zanoni <paulo.r.zanoni@intel.com>

> ---
>  drivers/gpu/drm/drm_crtc.c |   19 +++++++++++++++++++
>  include/drm/drm_crtc.h     |    5 +++++
>  2 files changed, 24 insertions(+)
>
> diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c
> index 022873e..a9b2b497 100644
> --- a/drivers/gpu/drm/drm_crtc.c
> +++ b/drivers/gpu/drm/drm_crtc.c
> @@ -606,6 +606,7 @@ int drm_plane_init(struct drm_device *dev, struct drm_plane *plane,
>        if (ret)
>                goto out;
>
> +       plane->base.properties = &plane->properties;
>        plane->dev = dev;
>        plane->funcs = funcs;
>        plane->format_types = kmalloc(sizeof(uint32_t) * format_count,
> @@ -3155,6 +3156,21 @@ static int drm_mode_crtc_set_obj_prop(struct drm_mode_object *obj,
>        return ret;
>  }
>
> +static int drm_mode_plane_set_obj_prop(struct drm_mode_object *obj,
> +                                     struct drm_property *property,
> +                                     uint64_t value)
> +{
> +       int ret = -EINVAL;
> +       struct drm_plane *plane = obj_to_plane(obj);
> +
> +       if (plane->funcs->set_property)
> +               ret = plane->funcs->set_property(plane, property, value);
> +       if (!ret)
> +               drm_object_property_set_value(obj, property, value);
> +
> +       return ret;
> +}
> +
>  int drm_mode_obj_get_properties_ioctl(struct drm_device *dev, void *data,
>                                      struct drm_file *file_priv)
>  {
> @@ -3256,6 +3272,9 @@ int drm_mode_obj_set_property_ioctl(struct drm_device *dev, void *data,
>        case DRM_MODE_OBJECT_CRTC:
>                ret = drm_mode_crtc_set_obj_prop(arg_obj, property, arg->value);
>                break;
> +       case DRM_MODE_OBJECT_PLANE:
> +               ret = drm_mode_plane_set_obj_prop(arg_obj, property, arg->value);
> +               break;
>        }
>
>  out:
> diff --git a/include/drm/drm_crtc.h b/include/drm/drm_crtc.h
> index 39e3e1c..c23789c 100644
> --- a/include/drm/drm_crtc.h
> +++ b/include/drm/drm_crtc.h
> @@ -618,6 +618,9 @@ struct drm_plane_funcs {
>                            uint32_t src_w, uint32_t src_h);
>        int (*disable_plane)(struct drm_plane *plane);
>        void (*destroy)(struct drm_plane *plane);
> +
> +       int (*set_property)(struct drm_plane *plane,
> +                           struct drm_property *property, uint64_t val);
>  };
>
>  /**
> @@ -657,6 +660,8 @@ struct drm_plane {
>
>        const struct drm_plane_funcs *funcs;
>        void *helper_private;
> +
> +       struct drm_object_properties properties;
>  };
>
>  /**
> --
> 1.7.9.5
>
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/dri-devel
diff mbox

Patch

diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c
index 022873e..a9b2b497 100644
--- a/drivers/gpu/drm/drm_crtc.c
+++ b/drivers/gpu/drm/drm_crtc.c
@@ -606,6 +606,7 @@  int drm_plane_init(struct drm_device *dev, struct drm_plane *plane,
 	if (ret)
 		goto out;
 
+	plane->base.properties = &plane->properties;
 	plane->dev = dev;
 	plane->funcs = funcs;
 	plane->format_types = kmalloc(sizeof(uint32_t) * format_count,
@@ -3155,6 +3156,21 @@  static int drm_mode_crtc_set_obj_prop(struct drm_mode_object *obj,
 	return ret;
 }
 
+static int drm_mode_plane_set_obj_prop(struct drm_mode_object *obj,
+				      struct drm_property *property,
+				      uint64_t value)
+{
+	int ret = -EINVAL;
+	struct drm_plane *plane = obj_to_plane(obj);
+
+	if (plane->funcs->set_property)
+		ret = plane->funcs->set_property(plane, property, value);
+	if (!ret)
+		drm_object_property_set_value(obj, property, value);
+
+	return ret;
+}
+
 int drm_mode_obj_get_properties_ioctl(struct drm_device *dev, void *data,
 				      struct drm_file *file_priv)
 {
@@ -3256,6 +3272,9 @@  int drm_mode_obj_set_property_ioctl(struct drm_device *dev, void *data,
 	case DRM_MODE_OBJECT_CRTC:
 		ret = drm_mode_crtc_set_obj_prop(arg_obj, property, arg->value);
 		break;
+	case DRM_MODE_OBJECT_PLANE:
+		ret = drm_mode_plane_set_obj_prop(arg_obj, property, arg->value);
+		break;
 	}
 
 out:
diff --git a/include/drm/drm_crtc.h b/include/drm/drm_crtc.h
index 39e3e1c..c23789c 100644
--- a/include/drm/drm_crtc.h
+++ b/include/drm/drm_crtc.h
@@ -618,6 +618,9 @@  struct drm_plane_funcs {
 			    uint32_t src_w, uint32_t src_h);
 	int (*disable_plane)(struct drm_plane *plane);
 	void (*destroy)(struct drm_plane *plane);
+
+	int (*set_property)(struct drm_plane *plane,
+			    struct drm_property *property, uint64_t val);
 };
 
 /**
@@ -657,6 +660,8 @@  struct drm_plane {
 
 	const struct drm_plane_funcs *funcs;
 	void *helper_private;
+
+	struct drm_object_properties properties;
 };
 
 /**