All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mika Kahola <mika.kahola@intel.com>
To: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>,
	igt-dev@lists.freedesktop.org
Cc: Lowry Li <lowry.li@arm.com>, Liviu Dudau <liviu.dudau@arm.com>,
	dri-devel@lists.freedesktop.org
Subject: Re: [igt-dev] [PATCH v2 2/3] lib/kms: Remove special enum handling and replace with call to igt_plane_set_prop_enum, v2.
Date: Tue, 28 Aug 2018 13:42:16 +0300	[thread overview]
Message-ID: <1535452936.20284.3.camel@intel.com> (raw)
In-Reply-To: <20180815100851.22219-2-maarten.lankhorst@linux.intel.com>

On Wed, 2018-08-15 at 12:08 +0200, Maarten Lankhorst wrote:
> We now have infrastructure for generic enum handling. This will make
> it easier
> to write new tests without defining all enum constants beforehand.
> 
> Changes since v1:
> - Fix compile error, sent old version by accident.
> 
Reviewed-by: Mika Kahola <mika.kahola@intel.com>

> Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
> ---
>  lib/igt_color_encoding.c | 20 +++++++++++
>  lib/igt_color_encoding.h |  3 ++
>  lib/igt_kms.c            | 77 +++++---------------------------------
> --
>  3 files changed, 32 insertions(+), 68 deletions(-)
> 
> diff --git a/lib/igt_color_encoding.c b/lib/igt_color_encoding.c
> index f445dbbc0250..03e16e0c9658 100644
> --- a/lib/igt_color_encoding.c
> +++ b/lib/igt_color_encoding.c
> @@ -23,6 +23,7 @@
>  
>  #include "igt_color_encoding.h"
>  #include "igt_matrix.h"
> +#include "igt_core.h"
>  
>  struct color_encoding {
>  	float kr, kb;
> @@ -141,3 +142,22 @@ struct igt_mat4 igt_rgb_to_ycbcr_matrix(enum
> igt_color_encoding color_encoding,
>  
>  	return igt_matrix_multiply(&r, &c);
>  }
> +
> +const char *igt_color_encoding_to_str(enum igt_color_encoding
> encoding)
> +{
> +	switch (encoding) {
> +	case IGT_COLOR_YCBCR_BT601: return "ITU-R BT.601 YCbCr";
> +	case IGT_COLOR_YCBCR_BT709: return "ITU-R BT.709 YCbCr";
> +	case IGT_COLOR_YCBCR_BT2020: return "ITU-R BT.2020 YCbCr";
> +	default: igt_assert(0); return NULL;
> +	}
> +}
> +
> +const char *igt_color_range_to_str(enum igt_color_range range)
> +{
> +	switch (range) {
> +	case IGT_COLOR_YCBCR_LIMITED_RANGE: return "YCbCr limited
> range";
> +	case IGT_COLOR_YCBCR_FULL_RANGE: return "YCbCr full range";
> +	default: igt_assert(0); return NULL;
> +	}
> +}
> diff --git a/lib/igt_color_encoding.h b/lib/igt_color_encoding.h
> index 0d8c819322af..3884e4939f4c 100644
> --- a/lib/igt_color_encoding.h
> +++ b/lib/igt_color_encoding.h
> @@ -41,6 +41,9 @@ enum igt_color_range {
>  	IGT_NUM_COLOR_RANGES,
>  };
>  
> +const char *igt_color_encoding_to_str(enum igt_color_encoding
> encoding);
> +const char *igt_color_range_to_str(enum igt_color_range range);
> +
>  struct igt_mat4 igt_ycbcr_to_rgb_matrix(enum igt_color_encoding
> color_encoding,
>  					enum igt_color_range
> color_range);
>  struct igt_mat4 igt_rgb_to_ycbcr_matrix(enum igt_color_encoding
> color_encoding,
> diff --git a/lib/igt_kms.c b/lib/igt_kms.c
> index e5272103e243..62d8468415c6 100644
> --- a/lib/igt_kms.c
> +++ b/lib/igt_kms.c
> @@ -196,61 +196,6 @@ const char * const
> igt_connector_prop_names[IGT_NUM_CONNECTOR_PROPS] = {
>  	[IGT_CONNECTOR_BROADCAST_RGB] = "Broadcast RGB",
>  };
>  
> -static const char * const
> igt_color_encoding_names[IGT_NUM_COLOR_ENCODINGS] = {
> -	[IGT_COLOR_YCBCR_BT601] = "ITU-R BT.601 YCbCr",
> -	[IGT_COLOR_YCBCR_BT709] = "ITU-R BT.709 YCbCr",
> -	[IGT_COLOR_YCBCR_BT2020] = "ITU-R BT.2020 YCbCr",
> -};
> -
> -static const char * const
> igt_color_range_names[IGT_NUM_COLOR_RANGES] = {
> -	[IGT_COLOR_YCBCR_FULL_RANGE] = "YCbCr full range",
> -	[IGT_COLOR_YCBCR_LIMITED_RANGE] = "YCbCr limited range",
> -};
> -
> -static void parse_enum_prop(drmModePropertyPtr prop,
> -			    int num_enums,
> -			    uint64_t values[],
> -			    const char * const enum_names[])
> -{
> -	igt_assert((prop->flags & ~(DRM_MODE_PROP_IMMUTABLE |
> -				    DRM_MODE_PROP_ATOMIC)) ==
> DRM_MODE_PROP_ENUM);
> -	igt_assert(prop->count_enums == prop->count_values);
> -	igt_assert(prop->count_enums >= 1);
> -	igt_assert(!!(prop->flags & DRM_MODE_PROP_IMMUTABLE) ==
> (prop->count_enums == 1));
> -
> -	for (int i = 0; i < prop->count_enums; i++) {
> -		for (int j = 0; j < num_enums; j++) {
> -			if (strcmp(prop->enums[i].name,
> enum_names[j]))
> -				continue;
> -
> -			values[j] = prop->enums[i].value;
> -		}
> -	}
> -}
> -
> -static void
> -parse_color_encoding_prop(igt_plane_t *plane, drmModePropertyPtr
> prop)
> -{
> -	parse_enum_prop(prop, ARRAY_SIZE(igt_color_encoding_names),
> -			plane->color_encoding.values,
> -			igt_color_encoding_names);
> -}
> -
> -static void
> -parse_color_range_prop(igt_plane_t *plane, drmModePropertyPtr prop)
> -{
> -	parse_enum_prop(prop, ARRAY_SIZE(igt_color_range_names),
> -			plane->color_range.values,
> -			igt_color_range_names);
> -}
> -
> -typedef void (*parse_plane_prop_t)(igt_plane_t *plane,
> drmModePropertyPtr prop);
> -
> -static const parse_plane_prop_t
> igt_parse_plane_prop[IGT_NUM_PLANE_PROPS] = {
> -	[IGT_PLANE_COLOR_ENCODING] = parse_color_encoding_prop,
> -	[IGT_PLANE_COLOR_RANGE] = parse_color_range_prop,
> -};
> -
>  /*
>   * Retrieve all the properies specified in props_name and store them
> into
>   * plane->props.
> @@ -275,9 +220,6 @@ igt_fill_plane_props(igt_display_t *display,
> igt_plane_t *plane,
>  			if (strcmp(prop->name, prop_names[j]) != 0)
>  				continue;
>  
> -			if (igt_parse_plane_prop[j])
> -				igt_parse_plane_prop[j](plane,
> prop);
> -
>  			plane->props[j] = props->props[i];
>  			break;
>  		}
> @@ -1799,11 +1741,12 @@ static void igt_plane_reset(igt_plane_t
> *plane)
>  	igt_plane_set_prop_value(plane, IGT_PLANE_CRTC_ID, 0);
>  
>  	if (igt_plane_has_prop(plane, IGT_PLANE_COLOR_ENCODING))
> -		igt_plane_set_prop_value(plane,
> IGT_PLANE_COLOR_ENCODING,
> -					 plane-
> >color_encoding.values[IGT_COLOR_YCBCR_BT601]);
> +		igt_plane_set_prop_enum(plane,
> IGT_PLANE_COLOR_ENCODING,
> +			igt_color_encoding_to_str(IGT_COLOR_YCBCR_BT
> 601));
> +
>  	if (igt_plane_has_prop(plane, IGT_PLANE_COLOR_RANGE))
> -		igt_plane_set_prop_value(plane,
> IGT_PLANE_COLOR_RANGE,
> -					 plane-
> >color_range.values[IGT_COLOR_YCBCR_LIMITED_RANGE]);
> +		igt_plane_set_prop_enum(plane,
> IGT_PLANE_COLOR_RANGE,
> +			igt_color_range_to_str(IGT_COLOR_YCBCR_LIMIT
> ED_RANGE));
>  
>  	/* Use default rotation */
>  	if (igt_plane_has_prop(plane, IGT_PLANE_ROTATION))
> @@ -3722,13 +3665,11 @@ void igt_plane_set_fb(igt_plane_t *plane,
> struct igt_fb *fb)
>  		igt_fb_set_size(fb, plane, fb->width, fb->height);
>  
>  		if (igt_plane_has_prop(plane,
> IGT_PLANE_COLOR_ENCODING))
> -			igt_plane_set_prop_value(plane,
> -						 IGT_PLANE_COLOR_ENC
> ODING,
> -						 plane-
> >color_encoding.values[fb->color_encoding]);
> +			igt_plane_set_prop_enum(plane,
> IGT_PLANE_COLOR_ENCODING,
> +				igt_color_encoding_to_str(fb-
> >color_encoding));
>  		if (igt_plane_has_prop(plane,
> IGT_PLANE_COLOR_RANGE))
> -			igt_plane_set_prop_value(plane,
> -						 IGT_PLANE_COLOR_RAN
> GE,
> -						 plane-
> >color_range.values[fb->color_range]);
> +			igt_plane_set_prop_enum(plane,
> IGT_PLANE_COLOR_RANGE,
> +				igt_color_range_to_str(fb-
> >color_range));
>  	} else {
>  		igt_plane_set_size(plane, 0, 0);
>  
-- 
Mika Kahola - Intel OTC

_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev

WARNING: multiple messages have this Message-ID (diff)
From: Mika Kahola <mika.kahola@intel.com>
To: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>,
	igt-dev@lists.freedesktop.org
Cc: Lowry Li <lowry.li@arm.com>, Liviu Dudau <liviu.dudau@arm.com>,
	dri-devel@lists.freedesktop.org
Subject: Re: [igt-dev] [PATCH v2 2/3] lib/kms: Remove special enum handling and replace with call to igt_plane_set_prop_enum, v2.
Date: Tue, 28 Aug 2018 13:42:16 +0300	[thread overview]
Message-ID: <1535452936.20284.3.camel@intel.com> (raw)
In-Reply-To: <20180815100851.22219-2-maarten.lankhorst@linux.intel.com>

On Wed, 2018-08-15 at 12:08 +0200, Maarten Lankhorst wrote:
> We now have infrastructure for generic enum handling. This will make
> it easier
> to write new tests without defining all enum constants beforehand.
> 
> Changes since v1:
> - Fix compile error, sent old version by accident.
> 
Reviewed-by: Mika Kahola <mika.kahola@intel.com>

> Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
> ---
>  lib/igt_color_encoding.c | 20 +++++++++++
>  lib/igt_color_encoding.h |  3 ++
>  lib/igt_kms.c            | 77 +++++---------------------------------
> --
>  3 files changed, 32 insertions(+), 68 deletions(-)
> 
> diff --git a/lib/igt_color_encoding.c b/lib/igt_color_encoding.c
> index f445dbbc0250..03e16e0c9658 100644
> --- a/lib/igt_color_encoding.c
> +++ b/lib/igt_color_encoding.c
> @@ -23,6 +23,7 @@
>  
>  #include "igt_color_encoding.h"
>  #include "igt_matrix.h"
> +#include "igt_core.h"
>  
>  struct color_encoding {
>  	float kr, kb;
> @@ -141,3 +142,22 @@ struct igt_mat4 igt_rgb_to_ycbcr_matrix(enum
> igt_color_encoding color_encoding,
>  
>  	return igt_matrix_multiply(&r, &c);
>  }
> +
> +const char *igt_color_encoding_to_str(enum igt_color_encoding
> encoding)
> +{
> +	switch (encoding) {
> +	case IGT_COLOR_YCBCR_BT601: return "ITU-R BT.601 YCbCr";
> +	case IGT_COLOR_YCBCR_BT709: return "ITU-R BT.709 YCbCr";
> +	case IGT_COLOR_YCBCR_BT2020: return "ITU-R BT.2020 YCbCr";
> +	default: igt_assert(0); return NULL;
> +	}
> +}
> +
> +const char *igt_color_range_to_str(enum igt_color_range range)
> +{
> +	switch (range) {
> +	case IGT_COLOR_YCBCR_LIMITED_RANGE: return "YCbCr limited
> range";
> +	case IGT_COLOR_YCBCR_FULL_RANGE: return "YCbCr full range";
> +	default: igt_assert(0); return NULL;
> +	}
> +}
> diff --git a/lib/igt_color_encoding.h b/lib/igt_color_encoding.h
> index 0d8c819322af..3884e4939f4c 100644
> --- a/lib/igt_color_encoding.h
> +++ b/lib/igt_color_encoding.h
> @@ -41,6 +41,9 @@ enum igt_color_range {
>  	IGT_NUM_COLOR_RANGES,
>  };
>  
> +const char *igt_color_encoding_to_str(enum igt_color_encoding
> encoding);
> +const char *igt_color_range_to_str(enum igt_color_range range);
> +
>  struct igt_mat4 igt_ycbcr_to_rgb_matrix(enum igt_color_encoding
> color_encoding,
>  					enum igt_color_range
> color_range);
>  struct igt_mat4 igt_rgb_to_ycbcr_matrix(enum igt_color_encoding
> color_encoding,
> diff --git a/lib/igt_kms.c b/lib/igt_kms.c
> index e5272103e243..62d8468415c6 100644
> --- a/lib/igt_kms.c
> +++ b/lib/igt_kms.c
> @@ -196,61 +196,6 @@ const char * const
> igt_connector_prop_names[IGT_NUM_CONNECTOR_PROPS] = {
>  	[IGT_CONNECTOR_BROADCAST_RGB] = "Broadcast RGB",
>  };
>  
> -static const char * const
> igt_color_encoding_names[IGT_NUM_COLOR_ENCODINGS] = {
> -	[IGT_COLOR_YCBCR_BT601] = "ITU-R BT.601 YCbCr",
> -	[IGT_COLOR_YCBCR_BT709] = "ITU-R BT.709 YCbCr",
> -	[IGT_COLOR_YCBCR_BT2020] = "ITU-R BT.2020 YCbCr",
> -};
> -
> -static const char * const
> igt_color_range_names[IGT_NUM_COLOR_RANGES] = {
> -	[IGT_COLOR_YCBCR_FULL_RANGE] = "YCbCr full range",
> -	[IGT_COLOR_YCBCR_LIMITED_RANGE] = "YCbCr limited range",
> -};
> -
> -static void parse_enum_prop(drmModePropertyPtr prop,
> -			    int num_enums,
> -			    uint64_t values[],
> -			    const char * const enum_names[])
> -{
> -	igt_assert((prop->flags & ~(DRM_MODE_PROP_IMMUTABLE |
> -				    DRM_MODE_PROP_ATOMIC)) ==
> DRM_MODE_PROP_ENUM);
> -	igt_assert(prop->count_enums == prop->count_values);
> -	igt_assert(prop->count_enums >= 1);
> -	igt_assert(!!(prop->flags & DRM_MODE_PROP_IMMUTABLE) ==
> (prop->count_enums == 1));
> -
> -	for (int i = 0; i < prop->count_enums; i++) {
> -		for (int j = 0; j < num_enums; j++) {
> -			if (strcmp(prop->enums[i].name,
> enum_names[j]))
> -				continue;
> -
> -			values[j] = prop->enums[i].value;
> -		}
> -	}
> -}
> -
> -static void
> -parse_color_encoding_prop(igt_plane_t *plane, drmModePropertyPtr
> prop)
> -{
> -	parse_enum_prop(prop, ARRAY_SIZE(igt_color_encoding_names),
> -			plane->color_encoding.values,
> -			igt_color_encoding_names);
> -}
> -
> -static void
> -parse_color_range_prop(igt_plane_t *plane, drmModePropertyPtr prop)
> -{
> -	parse_enum_prop(prop, ARRAY_SIZE(igt_color_range_names),
> -			plane->color_range.values,
> -			igt_color_range_names);
> -}
> -
> -typedef void (*parse_plane_prop_t)(igt_plane_t *plane,
> drmModePropertyPtr prop);
> -
> -static const parse_plane_prop_t
> igt_parse_plane_prop[IGT_NUM_PLANE_PROPS] = {
> -	[IGT_PLANE_COLOR_ENCODING] = parse_color_encoding_prop,
> -	[IGT_PLANE_COLOR_RANGE] = parse_color_range_prop,
> -};
> -
>  /*
>   * Retrieve all the properies specified in props_name and store them
> into
>   * plane->props.
> @@ -275,9 +220,6 @@ igt_fill_plane_props(igt_display_t *display,
> igt_plane_t *plane,
>  			if (strcmp(prop->name, prop_names[j]) != 0)
>  				continue;
>  
> -			if (igt_parse_plane_prop[j])
> -				igt_parse_plane_prop[j](plane,
> prop);
> -
>  			plane->props[j] = props->props[i];
>  			break;
>  		}
> @@ -1799,11 +1741,12 @@ static void igt_plane_reset(igt_plane_t
> *plane)
>  	igt_plane_set_prop_value(plane, IGT_PLANE_CRTC_ID, 0);
>  
>  	if (igt_plane_has_prop(plane, IGT_PLANE_COLOR_ENCODING))
> -		igt_plane_set_prop_value(plane,
> IGT_PLANE_COLOR_ENCODING,
> -					 plane-
> >color_encoding.values[IGT_COLOR_YCBCR_BT601]);
> +		igt_plane_set_prop_enum(plane,
> IGT_PLANE_COLOR_ENCODING,
> +			igt_color_encoding_to_str(IGT_COLOR_YCBCR_BT
> 601));
> +
>  	if (igt_plane_has_prop(plane, IGT_PLANE_COLOR_RANGE))
> -		igt_plane_set_prop_value(plane,
> IGT_PLANE_COLOR_RANGE,
> -					 plane-
> >color_range.values[IGT_COLOR_YCBCR_LIMITED_RANGE]);
> +		igt_plane_set_prop_enum(plane,
> IGT_PLANE_COLOR_RANGE,
> +			igt_color_range_to_str(IGT_COLOR_YCBCR_LIMIT
> ED_RANGE));
>  
>  	/* Use default rotation */
>  	if (igt_plane_has_prop(plane, IGT_PLANE_ROTATION))
> @@ -3722,13 +3665,11 @@ void igt_plane_set_fb(igt_plane_t *plane,
> struct igt_fb *fb)
>  		igt_fb_set_size(fb, plane, fb->width, fb->height);
>  
>  		if (igt_plane_has_prop(plane,
> IGT_PLANE_COLOR_ENCODING))
> -			igt_plane_set_prop_value(plane,
> -						 IGT_PLANE_COLOR_ENC
> ODING,
> -						 plane-
> >color_encoding.values[fb->color_encoding]);
> +			igt_plane_set_prop_enum(plane,
> IGT_PLANE_COLOR_ENCODING,
> +				igt_color_encoding_to_str(fb-
> >color_encoding));
>  		if (igt_plane_has_prop(plane,
> IGT_PLANE_COLOR_RANGE))
> -			igt_plane_set_prop_value(plane,
> -						 IGT_PLANE_COLOR_RAN
> GE,
> -						 plane-
> >color_range.values[fb->color_range]);
> +			igt_plane_set_prop_enum(plane,
> IGT_PLANE_COLOR_RANGE,
> +				igt_color_range_to_str(fb-
> >color_range));
>  	} else {
>  		igt_plane_set_size(plane, 0, 0);
>  
-- 
Mika Kahola - Intel OTC

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

  reply	other threads:[~2018-08-28 10:42 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-08-15 10:08 [igt-dev] [PATCH v2 1/3] lib/igt_kms: Add try_prop_enum and set_prop_enum for mode objects, v2 Maarten Lankhorst
2018-08-15 10:08 ` Maarten Lankhorst
2018-08-15 10:08 ` [igt-dev] [PATCH v2 2/3] lib/kms: Remove special enum handling and replace with call to igt_plane_set_prop_enum, v2 Maarten Lankhorst
2018-08-15 10:08   ` Maarten Lankhorst
2018-08-28 10:42   ` Mika Kahola [this message]
2018-08-28 10:42     ` [igt-dev] " Mika Kahola
2018-08-30  9:12     ` Maarten Lankhorst
2018-08-30  9:12       ` Maarten Lankhorst
2018-08-15 10:08 ` [igt-dev] [PATCH v2 3/3] tests: Add kms plane alpha blending test, v2 Maarten Lankhorst
2018-08-15 10:08   ` Maarten Lankhorst
2018-08-15 15:54 ` [igt-dev] ✓ Fi.CI.BAT: success for series starting with [v2,1/3] lib/igt_kms: Add try_prop_enum and set_prop_enum for mode objects, v2 Patchwork
2018-08-15 20:11 ` [igt-dev] ✗ Fi.CI.IGT: failure " Patchwork
2018-08-24  7:29 ` [igt-dev] [PATCH v2 1/3] " Mika Kahola
2018-08-24  7:29   ` Mika Kahola

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=1535452936.20284.3.camel@intel.com \
    --to=mika.kahola@intel.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=igt-dev@lists.freedesktop.org \
    --cc=liviu.dudau@arm.com \
    --cc=lowry.li@arm.com \
    --cc=maarten.lankhorst@linux.intel.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.