dri-devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
To: Maxime Ripard <maxime@cerno.tech>
Cc: Dom Cobley <dom@raspberrypi.com>,
	Tim Gover <tim.gover@raspberrypi.com>,
	Dave Stevenson <dave.stevenson@raspberrypi.com>,
	David Airlie <airlied@linux.ie>,
	dri-devel@lists.freedesktop.org,
	Thomas Zimmermann <tzimmermann@suse.de>,
	Daniel Vetter <daniel.vetter@intel.com>,
	Phil Elwell <phil@raspberrypi.com>
Subject: Re: [PATCH 06/23] drm/object: Add drm_object_property_get_default_value() function
Date: Tue, 8 Feb 2022 00:04:02 +0200	[thread overview]
Message-ID: <YgGXUr/jAx5WJpXN@pendragon.ideasonboard.com> (raw)
In-Reply-To: <20220207163515.1038648-7-maxime@cerno.tech>

Hi Maxime and Dave,

Thank you for the patch.

On Mon, Feb 07, 2022 at 05:34:58PM +0100, Maxime Ripard wrote:
> From: Dave Stevenson <dave.stevenson@raspberrypi.com>
> 
> Some functions to create properties (drm_plane_create_zpos_property or
> drm_plane_create_color_properties for example) will ask for a range of
> acceptable value and an initial one.
> 
> This initial value is then stored in the values array for that property.
> 
> Let's provide an helper to access this property.
> 
> Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
> Signed-off-by: Maxime Ripard <maxime@cerno.tech>

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

> ---
>  drivers/gpu/drm/drm_mode_object.c | 53 +++++++++++++++++++++++++------
>  include/drm/drm_mode_object.h     |  7 ++++
>  2 files changed, 50 insertions(+), 10 deletions(-)
> 
> diff --git a/drivers/gpu/drm/drm_mode_object.c b/drivers/gpu/drm/drm_mode_object.c
> index 86d9e907c0b2..ba1608effc0f 100644
> --- a/drivers/gpu/drm/drm_mode_object.c
> +++ b/drivers/gpu/drm/drm_mode_object.c
> @@ -297,11 +297,26 @@ int drm_object_property_set_value(struct drm_mode_object *obj,
>  }
>  EXPORT_SYMBOL(drm_object_property_set_value);
>  
> +static int __drm_object_property_get_prop_value(struct drm_mode_object *obj,
> +						struct drm_property *property,
> +						uint64_t *val)
> +{
> +	int i;
> +
> +	for (i = 0; i < obj->properties->count; i++) {
> +		if (obj->properties->properties[i] == property) {
> +			*val = obj->properties->values[i];
> +			return 0;
> +		}
> +	}
> +
> +	return -EINVAL;
> +}
> +
>  static int __drm_object_property_get_value(struct drm_mode_object *obj,
>  					   struct drm_property *property,
>  					   uint64_t *val)
>  {
> -	int i;
>  
>  	/* read-only properties bypass atomic mechanism and still store
>  	 * their value in obj->properties->values[].. mostly to avoid
> @@ -311,15 +326,7 @@ static int __drm_object_property_get_value(struct drm_mode_object *obj,
>  			!(property->flags & DRM_MODE_PROP_IMMUTABLE))
>  		return drm_atomic_get_property(obj, property, val);
>  
> -	for (i = 0; i < obj->properties->count; i++) {
> -		if (obj->properties->properties[i] == property) {
> -			*val = obj->properties->values[i];
> -			return 0;
> -		}
> -
> -	}
> -
> -	return -EINVAL;
> +	return __drm_object_property_get_prop_value(obj, property, val);
>  }
>  
>  /**
> @@ -348,6 +355,32 @@ int drm_object_property_get_value(struct drm_mode_object *obj,
>  }
>  EXPORT_SYMBOL(drm_object_property_get_value);
>  
> +/**
> + * drm_object_property_get_default_value - retrieve the default value of a
> + * property when in atomic mode.
> + * @obj: drm mode object to get property value from
> + * @property: property to retrieve
> + * @val: storage for the property value
> + *
> + * This function retrieves the default state of the given property as passed in
> + * to drm_object_attach_property
> + *
> + * Only atomic drivers should call this function directly, as for non-atomic
> + * drivers it will return the current value.
> + *
> + * Returns:
> + * Zero on success, error code on failure.
> + */
> +int drm_object_property_get_default_value(struct drm_mode_object *obj,
> +					  struct drm_property *property,
> +					  uint64_t *val)
> +{
> +	WARN_ON(!drm_drv_uses_atomic_modeset(property->dev));
> +
> +	return __drm_object_property_get_prop_value(obj, property, val);
> +}
> +EXPORT_SYMBOL(drm_object_property_get_default_value);
> +
>  /* helper for getconnector and getproperties ioctls */
>  int drm_mode_object_get_properties(struct drm_mode_object *obj, bool atomic,
>  				   uint32_t __user *prop_ptr,
> diff --git a/include/drm/drm_mode_object.h b/include/drm/drm_mode_object.h
> index c34a3e8030e1..912f1e415685 100644
> --- a/include/drm/drm_mode_object.h
> +++ b/include/drm/drm_mode_object.h
> @@ -98,6 +98,10 @@ struct drm_object_properties {
>  	 * Hence atomic drivers should not use drm_object_property_set_value()
>  	 * and drm_object_property_get_value() on mutable objects, i.e. those
>  	 * without the DRM_MODE_PROP_IMMUTABLE flag set.
> +	 *
> +	 * For atomic drivers the default value of properties is stored in this
> +	 * array, so drm_object_property_get_default_value can be used to
> +	 * retrieve it.
>  	 */
>  	uint64_t values[DRM_OBJECT_MAX_PROPERTY];
>  };
> @@ -126,6 +130,9 @@ int drm_object_property_set_value(struct drm_mode_object *obj,
>  int drm_object_property_get_value(struct drm_mode_object *obj,
>  				  struct drm_property *property,
>  				  uint64_t *value);
> +int drm_object_property_get_default_value(struct drm_mode_object *obj,
> +					  struct drm_property *property,
> +					  uint64_t *val);
>  
>  void drm_object_attach_property(struct drm_mode_object *obj,
>  				struct drm_property *property,
> -- 
> 2.34.1
> 

-- 
Regards,

Laurent Pinchart

  reply	other threads:[~2022-02-07 22:04 UTC|newest]

Thread overview: 43+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-07 16:34 [PATCH 00/23] drm: Fill in default values for plane properties Maxime Ripard
2022-02-07 16:34 ` [PATCH 01/23] drm/komeda: plane: switch to plane reset helper Maxime Ripard
2022-02-07 16:34 ` [PATCH 02/23] drm/tegra: " Maxime Ripard
2022-02-07 16:34 ` [PATCH 03/23] drm/tegra: hub: Fix zpos initial value mismatch Maxime Ripard
2022-02-07 16:34 ` [PATCH 04/23] drm/msm/mdp5: " Maxime Ripard
2022-02-07 19:27   ` Dmitry Baryshkov
2022-02-10  8:43     ` Maxime Ripard
2022-02-07 16:34 ` [PATCH 05/23] drm/amd/display: Fix color encoding mismatch Maxime Ripard
2022-02-07 18:57   ` Harry Wentland
2022-02-07 18:59     ` Harry Wentland
2022-02-10  8:42       ` Maxime Ripard
2022-02-10 14:38         ` Harry Wentland
2022-02-17 16:14           ` Maxime Ripard
2022-02-07 16:34 ` [PATCH 06/23] drm/object: Add drm_object_property_get_default_value() function Maxime Ripard
2022-02-07 22:04   ` Laurent Pinchart [this message]
2022-02-07 16:34 ` [PATCH 07/23] drm/object: Add default zpos value at reset Maxime Ripard
2022-02-07 19:24   ` Harry Wentland
2022-02-07 22:05   ` Laurent Pinchart
2022-02-07 16:35 ` [PATCH 08/23] drm/tegra: plane: Remove redundant zpos initialisation Maxime Ripard
2022-02-07 16:35 ` [PATCH 09/23] drm/komeda: " Maxime Ripard
2022-02-07 16:35 ` [PATCH 10/23] drm/exynos: " Maxime Ripard
2022-02-07 16:35 ` [PATCH 11/23] drm/imx: ipuv3-plane: " Maxime Ripard
2022-02-07 16:35 ` [PATCH 12/23] drm/msm/mdp5: " Maxime Ripard
2022-02-07 16:35 ` [PATCH 13/23] drm/nouveau/kms: " Maxime Ripard
2022-02-07 16:35 ` [PATCH 14/23] drm/omap: plane: Fix zpos initial value mismatch Maxime Ripard
2022-02-09  7:33   ` Tomi Valkeinen
2022-02-07 16:35 ` [PATCH 15/23] drm/omap: plane: Remove redundant zpos initialisation Maxime Ripard
2022-02-09  7:33   ` Tomi Valkeinen
2022-02-07 16:35 ` [PATCH 16/23] drm/rcar: " Maxime Ripard
2022-02-07 22:06   ` Laurent Pinchart
2022-02-08 12:16   ` Kieran Bingham
2022-02-07 16:35 ` [PATCH 17/23] drm/sti: " Maxime Ripard
2022-02-10  9:34   ` Alain Volmat
2022-02-10 11:00   ` Philippe CORNU
2022-02-07 16:35 ` [PATCH 18/23] drm/sun4i: layer: " Maxime Ripard
2022-02-08 13:56   ` Jernej Škrabec
2022-02-07 16:35 ` [PATCH 19/23] drm/object: Add default color encoding and range value at reset Maxime Ripard
2022-02-07 19:25   ` Harry Wentland
2022-02-07 16:35 ` [PATCH 20/23] drm/komeda: plane: Remove redundant color encoding and range initialisation Maxime Ripard
2022-02-07 16:35 ` [PATCH 21/23] drm/armada: overlay: " Maxime Ripard
2022-02-07 16:35 ` [PATCH 22/23] drm/imx: ipuv3-plane: " Maxime Ripard
2022-02-07 16:35 ` [PATCH 23/23] drm/omap: plane: " Maxime Ripard
2022-02-09  7:33   ` Tomi Valkeinen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=YgGXUr/jAx5WJpXN@pendragon.ideasonboard.com \
    --to=laurent.pinchart@ideasonboard.com \
    --cc=airlied@linux.ie \
    --cc=daniel.vetter@intel.com \
    --cc=dave.stevenson@raspberrypi.com \
    --cc=dom@raspberrypi.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=maxime@cerno.tech \
    --cc=phil@raspberrypi.com \
    --cc=tim.gover@raspberrypi.com \
    --cc=tzimmermann@suse.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox