[igt-dev] [PATCH i-g-t 2/2] kms_atomic: Add subtest for testing zpos plane property

Philipp Zabel p.zabel at pengutronix.de
Fri Mar 8 13:30:04 UTC 2019


On Sat, 2019-02-16 at 20:29 +0200, Marius Vlad wrote:
> From: Tomeu Vizoso <tomeu.vizoso at collabora.com>
> 
> We use a 16-bit pixel buffer format for the overlay plane, as some older
> HW might not be capable of driving a 32-bit pixel format.
> 
> Signed-off-by: Tomeu Vizoso <tomeu.vizoso at collabora.com>
> Signed-off-by: Marius Vlad <marius.vlad at collabora.com>
> ---
>  tests/kms_atomic.c | 84 ++++++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 84 insertions(+)
> 
> diff --git a/tests/kms_atomic.c b/tests/kms_atomic.c
> index 3aad2d9a..a9bc7f16 100644
> --- a/tests/kms_atomic.c
> +++ b/tests/kms_atomic.c
> @@ -276,6 +276,78 @@ static uint32_t plane_get_igt_format(igt_plane_t *plane)
>  	return 0;
>  }
>  
> +static void
> +plane_primary_overlay_zpos(igt_pipe_t *pipe, igt_output_t *output,
> +			   igt_plane_t *primary, igt_plane_t *overlay)
> +{
> +	struct igt_fb fb_primary, fb_overlay;
> +	drmModeModeInfo *mode = igt_output_get_mode(output);
> +	cairo_t *cr;
> +
> +	/* for primary */
> +	uint32_t w = mode->hdisplay;
> +	uint32_t h = mode->vdisplay;
> +
> +	/* for overlay */
> +	uint32_t w_overlay = mode->hdisplay / 2;
> +	uint32_t h_overlay = mode->vdisplay / 2;
> +
> +	igt_create_color_pattern_fb(pipe->display->drm_fd,
> +				    w, h, DRM_FORMAT_ARGB8888, I915_TILING_NONE,
> +				    0.2, 0.2, 0.2, &fb_primary);
> +
> +	igt_create_color_pattern_fb(pipe->display->drm_fd,
> +				    w_overlay, h_overlay,
> +				    DRM_FORMAT_RGB565, I915_TILING_NONE,
> +				    0.2, 0.2, 0.2, &fb_overlay);
> +
> +	/* Draw a hole in the overlay */
> +	cr = igt_get_cairo_ctx(pipe->display->drm_fd, &fb_overlay);
> +	cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE);
> +	igt_paint_color_alpha(cr, w_overlay / 4, h_overlay / 4,
> +			      w_overlay / 2, h_overlay / 2,
> +			      0.0, 0.0, 0.0, 0.5);

How can this draw a hole when the overlay plane has DRM_FORMAT_RGB565? I
would assume the alpha value is ignored in this case.

> +	cairo_set_operator(cr, CAIRO_OPERATOR_OVER);
> +	igt_put_cairo_ctx(pipe->display->drm_fd, &fb_overlay, cr);
> +
> +	igt_plane_set_fb(primary, &fb_primary);
> +	igt_plane_set_fb(overlay, &fb_overlay);
> +
> +	igt_plane_set_position(overlay, w_overlay / 2, h_overlay / 2);
> +
> +	igt_plane_set_prop_value(primary, IGT_PLANE_ZPOS, 0);
> +	igt_plane_set_prop_value(overlay, IGT_PLANE_ZPOS, 1);
> +
> +	igt_info("Commiting with overlay on top, it has a hole "\
> +		  "through which the primary should be seen\n");
> +	plane_commit(primary, COMMIT_ATOMIC, ATOMIC_RELAX_NONE);
> +
> +	igt_assert_eq_u64(igt_plane_get_prop(primary, IGT_PLANE_ZPOS), 0);
> +	igt_assert_eq_u64(igt_plane_get_prop(overlay, IGT_PLANE_ZPOS), 1);
> +
> +	igt_plane_set_prop_value(primary, IGT_PLANE_ZPOS, 1);
> +	igt_plane_set_prop_value(overlay, IGT_PLANE_ZPOS, 0);
> +
> +	igt_info("Commiting with primary on top, only the primary should be visible\n");

Committing

> +	plane_commit(primary, COMMIT_ATOMIC, ATOMIC_RELAX_NONE);
> +
> +	igt_assert_eq_u64(igt_plane_get_prop(primary, IGT_PLANE_ZPOS), 1);
> +	igt_assert_eq_u64(igt_plane_get_prop(overlay, IGT_PLANE_ZPOS), 0);
> +
> +	/* Draw a hole in the primary exactly on top of the overlay plane */
> +	cr = igt_get_cairo_ctx(pipe->display->drm_fd, &fb_primary);
> +	cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE);
> +	igt_paint_color_alpha(cr, w_overlay / 2, h_overlay / 2,
> +			      w_overlay, h_overlay,
> +			      0.0, 0.0, 0.0, 0.5);
> +	cairo_set_operator(cr, CAIRO_OPERATOR_OVER);
> +	igt_put_cairo_ctx(pipe->display->drm_fd, &fb_primary, cr);
> +
> +	igt_info("Commiting with a hole in the primary through "\
> +		  "which the underlay should be seen\n");
> +	plane_commit(primary, COMMIT_ATOMIC, ATOMIC_RELAX_NONE);
> +}
> +
>  static void plane_overlay(igt_pipe_t *pipe, igt_output_t *output, igt_plane_t *plane)
>  {
>  	drmModeModeInfo *mode = igt_output_get_mode(output);
> @@ -905,6 +977,18 @@ igt_main
>  		plane_primary(pipe_obj, primary, &fb);
>  	}
>  
> +	igt_subtest("plane_primary_overlay_zpos") {
> +		igt_plane_t *overlay =
> +			igt_pipe_get_plane_type(pipe_obj, DRM_PLANE_TYPE_OVERLAY);
> +
> +		igt_require(overlay);
> +		igt_require(igt_plane_has_prop(primary, IGT_PLANE_ZPOS));
> +		igt_require(igt_plane_has_prop(overlay, IGT_PLANE_ZPOS));

Maybe also check igt_plane_has_format_mod for the formats the test wants
to set.

> +
> +		igt_output_set_pipe(output, pipe);
> +		plane_primary_overlay_zpos(pipe_obj, output, primary, overlay);
> +	}
> +
>  	igt_subtest("test_only") {
>  		atomic_clear(&display, pipe, primary, output);
>  

regards
Philipp


More information about the igt-dev mailing list