Igt-dev Archive on 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
Subject: Re: [igt-dev] [PATCH i-g-t 03/12] lib/igt_fb: Add igt_fb_supported_format()
Date: Thu, 08 Feb 2018 10:08:46 +0200	[thread overview]
Message-ID: <1518077326.14464.7.camel@intel.com> (raw)
In-Reply-To: <20180206101417.59979-3-maarten.lankhorst@linux.intel.com>

On Tue, 2018-02-06 at 11:14 +0100, Maarten Lankhorst wrote:
> This makes it possible to iterate whether a format is supported or
> not,
> without each driver having to open code it.
> 
> Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
> ---
>  lib/igt_fb.c              | 18 ++++++++++++++++++
>  lib/igt_fb.h              |  1 +
>  tests/kms_atomic.c        | 13 +++----------
>  tests/kms_plane.c         | 16 +---------------
>  tests/kms_plane_scaling.c | 22 ++++------------------
>  5 files changed, 27 insertions(+), 43 deletions(-)
> 
> diff --git a/lib/igt_fb.c b/lib/igt_fb.c
> index 35a928b9281d..0389b1c1b159 100644
> --- a/lib/igt_fb.c
> +++ b/lib/igt_fb.c
> @@ -1719,3 +1719,21 @@ void igt_get_all_cairo_formats(const uint32_t
> **formats, int *format_count)
>  	*formats = drm_formats;
>  	*format_count = n_formats;
>  }
> +
> +/**
> + * igt_fb_supported_format:
> + * @drm_format: drm fourcc to test.
> + *
> + * This functions returns whether @drm_format can be succesfully
> created by
> + * igt_create_fb() and drawn to by igt_get_cairo_ctx().
> + */
> +bool igt_fb_supported_format(uint32_t drm_format)
> +{
> +	struct format_desc_struct *f;
> +
> +	for_each_format(f)
> +		if (f->drm_id == drm_format)
> +			return f->cairo_id != CAIRO_FORMAT_INVALID;
> +
Maybe we could utilize the existing lookup_drm_format() function but
even so we wouldn't save no more than couple of lines. I'm ok with this
approach.

Reviewed-by: Mika Kahola <mika.kahola@intel.com>
 
> +	return false;
> +}
> diff --git a/lib/igt_fb.h b/lib/igt_fb.h
> index 77fd88bb7aca..a6ce07898784 100644
> --- a/lib/igt_fb.h
> +++ b/lib/igt_fb.h
> @@ -163,6 +163,7 @@ uint32_t igt_bpp_depth_to_drm_format(int bpp, int
> depth);
>  uint32_t igt_drm_format_to_bpp(uint32_t drm_format);
>  const char *igt_format_str(uint32_t drm_format);
>  void igt_get_all_cairo_formats(const uint32_t **formats, int
> *format_count);
> +bool igt_fb_supported_format(uint32_t drm_format);
>  
>  #endif /* __IGT_FB_H__ */
>  
> diff --git a/tests/kms_atomic.c b/tests/kms_atomic.c
> index 2e21b53b8c87..ac02baf0170b 100644
> --- a/tests/kms_atomic.c
> +++ b/tests/kms_atomic.c
> @@ -264,20 +264,13 @@ static void
> crtc_commit_atomic_flags_err(igt_pipe_t *pipe, igt_plane_t *plane,
>  static uint32_t plane_get_igt_format(igt_plane_t *plane)
>  {
>  	drmModePlanePtr plane_kms;
> -	const uint32_t *igt_formats;
> -	int num_igt_formats;
>  	int i;
>  
>  	plane_kms = plane->drm_plane;
>  
> -	igt_get_all_cairo_formats(&igt_formats, &num_igt_formats);
> -	for (i = 0; i < num_igt_formats; i++) {
> -		int j;
> -
> -		for (j = 0; j < plane_kms->count_formats; j++) {
> -			if (plane_kms->formats[j] == igt_formats[i])
> -				return plane_kms->formats[j];
> -		}
> +	for (i = 0; i < plane_kms->count_formats; i++) {
> +		if (igt_fb_supported_format(plane_kms->formats[i]))
> +			return plane_kms->formats[i];
>  	}
>  
>  	return 0;
> diff --git a/tests/kms_plane.c b/tests/kms_plane.c
> index 54bcffc16f4f..23173b966eab 100644
> --- a/tests/kms_plane.c
> +++ b/tests/kms_plane.c
> @@ -366,20 +366,6 @@ test_plane_panning(data_t *data, enum pipe pipe,
> unsigned int flags)
>  	igt_skip_on(connected_outs == 0);
>  }
>  
> -static bool can_draw(uint32_t drm_format)
> -{
> -	const uint32_t *drm_formats;
> -	int format_count, i;
> -
> -	igt_get_all_cairo_formats(&drm_formats, &format_count);
> -
> -	for (i = 0; i < format_count; i++)
> -		if (drm_formats[i] == drm_format)
> -			return true;
> -
> -	return false;
> -}
> -
>  static void test_format_plane(data_t *data, enum pipe pipe,
>  			      igt_output_t *output, igt_plane_t
> *plane)
>  {
> @@ -420,7 +406,7 @@ static void test_format_plane(data_t *data, enum
> pipe pipe,
>  	for (i = 0; i < plane->drm_plane->count_formats; i++) {
>  		format = plane->drm_plane->formats[i];
>  
> -		if (!can_draw(format))
> +		if (!igt_fb_supported_format(format))
>  			continue;
>  
>  		igt_debug("Testing format 0x%x on %s.%u\n",
> diff --git a/tests/kms_plane_scaling.c b/tests/kms_plane_scaling.c
> index 3171331c96b8..7a5470106cd5 100644
> --- a/tests/kms_plane_scaling.c
> +++ b/tests/kms_plane_scaling.c
> @@ -173,20 +173,6 @@ static bool can_rotate(unsigned format)
>  	return true;
>  }
>  
> -static bool can_draw(uint32_t drm_format)
> -{
> -	const uint32_t *drm_formats;
> -	int format_count, i;
> -
> -	igt_get_all_cairo_formats(&drm_formats, &format_count);
> -
> -	for (i = 0; i < format_count; i++)
> -		if (drm_formats[i] == drm_format)
> -			return true;
> -
> -	return false;
> -}
> -
>  static void test_scaler_with_rotation_pipe(data_t *d, enum pipe
> pipe,
>  					   igt_output_t *output)
>  {
> @@ -202,7 +188,7 @@ static void test_scaler_with_rotation_pipe(data_t
> *d, enum pipe pipe,
>  			igt_rotation_t rot = rotations[i];
>  			for (int j = 0; j < plane->drm_plane-
> >count_formats; j++) {
>  				unsigned format = plane->drm_plane-
> >formats[j];
> -				if (can_draw(format) &&
> can_rotate(format))
> +				if (igt_fb_supported_format(format)
> && can_rotate(format))
>  					check_scaling_pipe_plane_rot
> (d, plane, format,
>  								    
>  LOCAL_I915_FORMAT_MOD_Y_TILED,
>  								    
>  pipe, output, rot);
> @@ -235,7 +221,7 @@ static void
> test_scaler_with_pixel_format_pipe(data_t *d, enum pipe pipe, igt_ou
>  			for (int j = 0; j < plane->drm_plane-
> >count_formats; j++) {
>  				uint32_t format = plane->drm_plane-
> >formats[j];
>  
> -				if (can_draw(format))
> +				if (igt_fb_supported_format(format))
>  					check_scaling_pipe_plane_rot
> (d, plane,
>  								    
>  format, tiling,
>  								    
>  pipe, output, IGT_ROTATION_0);
> @@ -446,13 +432,13 @@
> test_scaler_with_clipping_clamping_scenario(data_t *d, enum pipe
> pipe, igt_outpu
>  
>  	for (int i = 0; i < d->plane1->drm_plane->count_formats;
> i++) {
>  		unsigned f1 = d->plane1->drm_plane->formats[i];
> -		if (!can_draw(f1))
> +		if (!igt_fb_supported_format(f1))
>  			continue;
>  
>  		for (int j = 0; j < d->plane2->drm_plane-
> >count_formats; j++) {
>  			unsigned f2 = d->plane2->drm_plane-
> >formats[j];
>  
> -			if (!can_draw(f2))
> +			if (!igt_fb_supported_format(f2))
>  				continue;
>  
>  			__test_scaler_with_clipping_clamping_scenari
> o(d, mode, f1, f2);
-- 
Mika Kahola - Intel OTC

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

  reply	other threads:[~2018-02-08  8:08 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-02-06 10:14 [igt-dev] [PATCH i-g-t 01/12] lib/igt_fb: Make igt_remove_fb more robust Maarten Lankhorst
2018-02-06 10:14 ` [igt-dev] [PATCH i-g-t 02/12] tests: Always call igt_remove_fb without checking Maarten Lankhorst
2018-02-07 13:42   ` Mika Kahola
2018-02-06 10:14 ` [igt-dev] [PATCH i-g-t 03/12] lib/igt_fb: Add igt_fb_supported_format() Maarten Lankhorst
2018-02-08  8:08   ` Mika Kahola [this message]
2018-02-06 10:14 ` [igt-dev] [PATCH i-g-t 04/12] lib/igt_fb: Remove igt_get_all_cairo_formats() Maarten Lankhorst
2018-02-08  8:15   ` Mika Kahola
2018-02-06 10:14 ` [igt-dev] [PATCH i-g-t 05/12] lib/igt_debugfs: Add igt_pipe_crc_get_single and igt_pipe_crc_drain Maarten Lankhorst
2018-02-06 16:11   ` Ville Syrjälä
2018-02-06 16:30     ` Maarten Lankhorst
2018-02-07 11:47     ` [igt-dev] [PATCH i-g-t] lib/igt_debugfs: Add igt_pipe_crc_get_single and igt_pipe_crc_drain, v2 Maarten Lankhorst
2018-02-08 11:15       ` Mika Kahola
2018-02-06 10:14 ` [igt-dev] [PATCH i-g-t 06/12] tests/kms_rotation_crc: Fix bad-tiling testcase Maarten Lankhorst
2018-02-08 12:08   ` Mika Kahola
2018-02-08 12:12     ` Maarten Lankhorst
2018-02-08 12:19   ` Mika Kahola
2018-02-06 10:14 ` [igt-dev] [PATCH i-g-t 07/12] tests/kms_rotation_crc: Move bad_format parameter to test_plane_rotation Maarten Lankhorst
2018-02-08 13:07   ` Mika Kahola
2018-02-06 10:14 ` [igt-dev] [PATCH i-g-t 08/12] tests/kms_rotation_crc: Always run the flip tests when available Maarten Lankhorst
2018-02-06 10:14 ` [igt-dev] [PATCH i-g-t 09/12] tests/kms_rotation_crc: Remove primary-rotation-90-Y-tiled Maarten Lankhorst
2018-02-09  8:25   ` Kahola, Mika
2018-02-06 10:14 ` [igt-dev] [PATCH i-g-t 10/12] tests/kms_rotation_crc: Perform lazy cleanup and require atomic Maarten Lankhorst
2018-02-09  9:39   ` Kahola, Mika
2018-02-06 10:14 ` [igt-dev] [PATCH i-g-t 11/12] tests/kms_rotation_crc: Clean up exhaust-fences subtest Maarten Lankhorst
2018-02-12 11:20   ` Mika Kahola
2018-02-06 10:14 ` [igt-dev] [PATCH i-g-t 12/12] tests/kms_rotation_crc: Test all pixel formats on all planes Maarten Lankhorst
2018-02-08  3:33   ` Srinivas, Vidya
2018-02-12 13:09   ` Mika Kahola
2018-02-12 14:20     ` Maarten Lankhorst
2018-02-06 11:25 ` [igt-dev] ✗ Fi.CI.BAT: warning for series starting with [i-g-t,01/12] lib/igt_fb: Make igt_remove_fb more robust Patchwork
2018-02-07 13:30 ` [igt-dev] ✓ Fi.CI.BAT: success for series starting with [i-g-t,01/12] lib/igt_fb: Make igt_remove_fb more robust (rev2) Patchwork
2018-02-07 13:39 ` [igt-dev] [PATCH i-g-t 01/12] lib/igt_fb: Make igt_remove_fb more robust Mika Kahola
2018-02-07 16:36 ` [igt-dev] ✗ Fi.CI.IGT: failure for series starting with [i-g-t,01/12] lib/igt_fb: Make igt_remove_fb more robust (rev2) Patchwork
2018-02-09 16:33 ` [igt-dev] ✓ Fi.CI.BAT: success for series starting with [i-g-t,01/12] lib/igt_fb: Make igt_remove_fb more robust (rev3) Patchwork
2018-02-09 18:21 ` [igt-dev] ✗ Fi.CI.IGT: failure " Patchwork

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=1518077326.14464.7.camel@intel.com \
    --to=mika.kahola@intel.com \
    --cc=igt-dev@lists.freedesktop.org \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox