Igt-dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: "Nautiyal, Ankit K" <ankit.k.nautiyal@intel.com>
To: Swati Sharma <swati2.sharma@intel.com>, <igt-dev@lists.freedesktop.org>
Subject: Re: [PATCH i-g-t, v2 9/9] tests/chamelium/kms_chamelium_sharpness_filter: Add basic test
Date: Tue, 17 Dec 2024 16:02:52 +0530	[thread overview]
Message-ID: <9a90fe38-8a7a-4102-9830-7867029cc7ee@intel.com> (raw)
In-Reply-To: <20241209114623.1843033-10-swati2.sharma@intel.com>


On 12/9/2024 5:16 PM, Swati Sharma wrote:
> Add new chamelium based sharpness test. Basic test is added where
> we have tried comparing frame dump of unsharped and sharped image.
> After, sharpness filter is applied its expected both frame dumps
> will be different.
>
> v2: -removed MIN/MAX_FILTER_STRENGTH (Ankit)
>      -fixed alignment (Ankit)
>      -removed commit with fb_ref (Ankit)
>      -set data->pipe_id (Ankit)
>      -removed disable_filter_strength_on_pipe()
>      -fixed CRASH
>      -fixed assert condition
>
> Signed-off-by: Swati Sharma <swati2.sharma@intel.com>
> ---
>   .../kms_chamelium_sharpness_filter.c          | 240 ++++++++++++++++++
>   tests/meson.build                             |   2 +
>   2 files changed, 242 insertions(+)
>   create mode 100644 tests/chamelium/kms_chamelium_sharpness_filter.c
>
> diff --git a/tests/chamelium/kms_chamelium_sharpness_filter.c b/tests/chamelium/kms_chamelium_sharpness_filter.c
> new file mode 100644
> index 000000000..d7316723a
> --- /dev/null
> +++ b/tests/chamelium/kms_chamelium_sharpness_filter.c
> @@ -0,0 +1,240 @@
> +// SPDX-License-Identifier: MIT
> +/*
> + * Copyright © 2024 Intel Corporation
> + */
> +
> +/**
> + * TEST: kms chamelium sharpness filter
> + * Category: Display
> + * Description: Test to validate content adaptive sharpness filter using Chamelium
> + * Driver requirement: xe
> + * Functionality: chamelium, casf
> + * Mega feature: General Display Features
> + * Test category: functionality test
> + */
> +
> +#include "igt.h"
> +#include "igt_kms.h"
> +
> +/**
> + * SUBTEST: filter-basic
> + * Description: Verify basic content adaptive sharpness filter.
> + */
> +
> +IGT_TEST_DESCRIPTION("Test to validate content adaptive sharpness filter using Chamelium");
> +
> +#define MID_FILTER_STRENGTH		128
> +
> +typedef struct {
> +	int drm_fd;
> +	enum pipe pipe_id;
> +	struct igt_fb fb, fb_ref;
> +	igt_display_t display;
> +	igt_output_t *output;
> +	igt_plane_t *primary;
> +	drmModeModeInfo *mode;
> +	int filter_strength;
> +	struct chamelium *chamelium;
> +	struct chamelium_port **ports;
> +	int port_count;
> +} data_t;
> +
> +static bool pipe_output_combo_valid(data_t *data, enum pipe pipe)
> +{
> +	bool ret = true;
> +
> +	igt_output_set_pipe(data->output, pipe);
> +	if (!intel_pipe_output_combo_valid(&data->display))
> +		ret = false;
> +	igt_output_set_pipe(data->output, PIPE_NONE);
> +
> +	return ret;
> +}
> +
> +static void set_filter_strength_on_pipe(data_t *data)
> +{
> +	igt_pipe_set_prop_value(&data->display, data->pipe_id,
> +				IGT_CRTC_SHARPNESS_STRENGTH,
> +				data->filter_strength);
> +}
> +
> +static void paint_image(igt_fb_t *fb)
> +{
> +	cairo_t *cr = igt_get_cairo_ctx(fb->fd, fb);
> +	int img_x, img_y, img_w, img_h;
> +	const char *file = "1080p-left.png";
> +
> +	img_x = img_y = 0;
> +	img_w = fb->width;
> +	img_h = fb->height;
> +
> +	igt_paint_image(cr, file, img_x, img_y, img_w, img_h);
> +
> +	igt_put_cairo_ctx(cr);
> +}
> +
> +static void setup_fb(int fd, int width, int height, uint32_t format,
> +		     uint64_t modifier, struct igt_fb *fb)
> +{
> +	int fb_id;
> +
> +	fb_id = igt_create_fb(fd, width, height, format, modifier, fb);
> +	igt_assert(fb_id);
> +
> +	paint_image(fb);
> +}
> +
> +static void cleanup(data_t *data)
> +{
> +	igt_remove_fb(data->drm_fd, &data->fb);
> +	igt_remove_fb(data->drm_fd, &data->fb_ref);
> +	igt_output_set_pipe(data->output, PIPE_NONE);
> +	igt_output_override_mode(data->output, NULL);
> +	igt_display_commit2(&data->display, COMMIT_ATOMIC);
> +}
> +
> +
> +static bool test_t(data_t *data, igt_plane_t *primary,
> +		   struct chamelium_port *port)
> +{
> +	struct chamelium_frame_dump *dump;
> +	drmModeModeInfo *mode;
> +	int height, width;
> +	bool ret = false;
> +
> +	igt_output_set_pipe(data->output, data->pipe_id);
> +
> +	mode = igt_output_get_mode(data->output);
> +	height = mode->hdisplay;
> +	width = mode->vdisplay;
> +
> +	setup_fb(data->drm_fd, height, width, DRM_FORMAT_XRGB8888, DRM_FORMAT_MOD_LINEAR, &data->fb_ref);
> +	setup_fb(data->drm_fd, height, width, DRM_FORMAT_XRGB8888, DRM_FORMAT_MOD_LINEAR, &data->fb);
> +
> +	igt_plane_set_fb(data->primary, &data->fb);
> +	set_filter_strength_on_pipe(data);
> +	igt_display_commit2(&data->display, COMMIT_ATOMIC);
> +
> +	igt_debug("Reading frame dumps from Chamelium...\n");
> +	chamelium_capture(data->chamelium, port, 0, 0, 0, 0, 1);
> +	dump = chamelium_read_captured_frame(data->chamelium, 0);
> +
> +	ret = chamelium_frame_match_or_dump(data->chamelium, port,
> +					    dump, &data->fb_ref,
> +					    CHAMELIUM_CHECK_ANALOG);

Currently we are comparing the frame captured after sharpening 
(converted to cairo surface) with the cairo surface generated from the 
reference fb.

I am wondering if we can capture frame (chamelium_capture) before 
setting the sharpness property and one after the property and compare that.

Regards,

Ankit


> +	chamelium_destroy_frame_dump(dump);
> +	cleanup(data);
> +
> +	return ret;
> +}
> +
> +static int test_setup(data_t *data, enum pipe p)
> +{
> +	igt_pipe_t *pipe;
> +	int i = 0;
> +
> +	igt_display_reset(&data->display);
> +	igt_modeset_disable_all_outputs(&data->display);
> +	chamelium_reset_state(&data->display, data->chamelium, NULL,
> +			      data->ports, data->port_count);
> +
> +	pipe = &data->display.pipes[p];
> +	igt_require(pipe->n_planes >= 0);
> +
> +	data->primary = igt_pipe_get_plane_type(pipe, DRM_PLANE_TYPE_PRIMARY);
> +	igt_assert(data->primary);
> +
> +	/*
> +	 * Prefer to run this test on HDMI connector if its connected, since on DP we
> +	 * sometimes face DP FSM issue
> +	 */
> +        for_each_valid_output_on_pipe(&data->display, p, data->output) {
> +		data->pipe_id = p;
> +                for (i = 0; i < data->port_count; i++) {
> +                        if ((data->output->config.connector->connector_type == DRM_MODE_CONNECTOR_HDMIA ||
> +			    data->output->config.connector->connector_type == DRM_MODE_CONNECTOR_HDMIB) &&
> +			    strcmp(data->output->name, chamelium_port_get_name(data->ports[i])) == 0)
> +                                return i;
> +                }
> +        }
> +
> +	for_each_valid_output_on_pipe(&data->display, p, data->output) {
> +		data->pipe_id = p;
> +		for (i = 0; i < data->port_count; i++) {
> +			if (strcmp(data->output->name,
> +				   chamelium_port_get_name(data->ports[i])) == 0)
> +				return i;
> +		}
> +	}
> +
> +	return -1;
> +}
> +
> +static void test_sharpness_filter(data_t *data,  enum pipe p)
> +{
> +	int port_idx = test_setup(data, p);
> +
> +	igt_require(port_idx >= 0);
> +	igt_require(igt_pipe_obj_has_prop(&data->display.pipes[p], IGT_CRTC_SHARPNESS_STRENGTH));
> +
> +	if (!pipe_output_combo_valid(data, p))
> +		return;
> +
> +	igt_dynamic_f("pipe-%s-%s", kmstest_pipe_name(p), data->output->name)
> +		igt_assert_f(!(test_t(data, data->primary, data->ports[port_idx]) == 1), "No sharpness observed.\n");
> +}
> +
> +static void
> +run_sharpness_filter_test(data_t *data)
> +{
> +	igt_display_t *display = &data->display;
> +	enum pipe pipe;
> +
> +	igt_describe("Verify basic content adaptive sharpness filter.");
> +	igt_subtest_with_dynamic("filter-basic") {
> +		for_each_pipe(display, pipe) {
> +			data->filter_strength = MID_FILTER_STRENGTH;
> +			test_sharpness_filter(data, pipe);
> +		}
> +	}
> +}
> +
> +igt_main
> +{
> +	data_t data = {};
> +
> +	igt_fixture {
> +		data.drm_fd = drm_open_driver_master(DRIVER_ANY);
> +
> +		igt_display_require(&data.display, data.drm_fd);
> +		igt_require(data.display.is_atomic);
> +
> +		igt_chamelium_allow_fsm_handling = false;
> +
> +		/* we need to initalize chamelium after igt_display_require */
> +		data.chamelium = chamelium_init(data.drm_fd, &data.display);
> +		igt_require(data.chamelium);
> +
> +		data.ports = chamelium_get_ports(data.chamelium,
> +						 &data.port_count);
> +
> +		if (!data.port_count)
> +			igt_skip("No ports connected\n");
> +		/*
> +		 * We don't cause any harm by plugging
> +		 * discovered ports, just incase they are not plugged
> +		 * we currently skip in test_setup
> +		 */
> +		for(int i = 0; i < data.port_count; i++)
> +			chamelium_plug(data.chamelium, data.ports[i]);
> +
> +		kmstest_set_vt_graphics_mode();
> +	}
> +
> +	run_sharpness_filter_test(&data);
> +
> +	igt_fixture {
> +		igt_display_fini(&data.display);
> +		drm_close_driver(data.drm_fd);
> +	}
> +}
> diff --git a/tests/meson.build b/tests/meson.build
> index 84d8bed4b..0a336c2c1 100644
> --- a/tests/meson.build
> +++ b/tests/meson.build
> @@ -340,6 +340,7 @@ chamelium_progs = [
>   	'kms_chamelium_edid',
>   	'kms_chamelium_frames',
>   	'kms_chamelium_hpd',
> +	'kms_chamelium_sharpness_filter',
>   ]
>   
>   test_deps = [ igt_deps ]
> @@ -365,6 +366,7 @@ extra_sources = {
>   	'kms_chamelium_edid': [ join_paths ('chamelium', 'kms_chamelium_helper.c') ],
>   	'kms_chamelium_frames': [ join_paths ('chamelium', 'kms_chamelium_helper.c') ],
>   	'kms_chamelium_hpd': [ join_paths ('chamelium', 'kms_chamelium_helper.c') ],
> +	'kms_chamelium_sharpness_filter': [ join_paths ('chamelium', 'kms_chamelium_helper.c') ],
>   	'kms_dsc': [ join_paths ('intel', 'kms_dsc_helper.c') ],
>   	'kms_psr2_sf':  [ join_paths ('intel', 'kms_dsc_helper.c') ],
>   }

  reply	other threads:[~2024-12-17 10:33 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-12-09 11:46 [PATCH i-g-t 0/9] Add new test to validate adaptive sharpness filter Swati Sharma
2024-12-09 11:46 ` [PATCH i-g-t, v3 1/9] lib/igt_kms: Add "sharpness strength" as crtc property Swati Sharma
2024-12-09 11:46 ` [PATCH i-g-t, v2 2/9] lib/igt_kms: Add func() to return scaling mode name string Swati Sharma
2024-12-09 11:46 ` [PATCH i-g-t, v9 3/9] tests/kms_sharpness_filter: Add adaptive sharpness basic filter tests Swati Sharma
2024-12-11  4:25   ` Nautiyal, Ankit K
2024-12-09 11:46 ` [PATCH i-g-t 4/9] tests/kms_sharpness_filter: Add toggle subtest Swati Sharma
2024-12-11  7:57   ` Nautiyal, Ankit K
2024-12-09 11:46 ` [PATCH i-g-t 5/9] tests/kms_sharpness_filter: Add filter-tap subtest Swati Sharma
2024-12-11  8:36   ` Nautiyal, Ankit K
2024-12-09 11:46 ` [PATCH i-g-t 6/9] tests/kms_sharpness_filter: Add dpms/suspend subtests Swati Sharma
2024-12-11 10:59   ` Nautiyal, Ankit K
2024-12-09 11:46 ` [PATCH i-g-t 7/9] tests/kms_sharpness_filter: Add scaler subtests Swati Sharma
2024-12-11  8:47   ` Nautiyal, Ankit K
2024-12-09 11:46 ` [PATCH i-g-t 8/9] tests/kms_sharpness_filter: Add invalid subtests Swati Sharma
2024-12-11 10:55   ` Nautiyal, Ankit K
2024-12-09 11:46 ` [PATCH i-g-t, v2 9/9] tests/chamelium/kms_chamelium_sharpness_filter: Add basic test Swati Sharma
2024-12-17 10:32   ` Nautiyal, Ankit K [this message]
2024-12-09 21:18 ` ✓ Xe.CI.BAT: success for Add new test to validate adaptive sharpness filter (rev10) Patchwork
2024-12-09 21:28 ` ✓ i915.CI.BAT: " Patchwork
2024-12-09 22:33 ` ✗ Xe.CI.Full: failure " Patchwork
2024-12-09 23:50 ` ✗ i915.CI.Full: " Patchwork
  -- strict thread matches above, loose matches on Subject: below --
2024-12-31 13:02 [PATCH i-g-t 0/9] Add new test to validate adaptive sharpness filter Swati Sharma
2024-12-31 13:02 ` [PATCH i-g-t, v2 9/9] tests/chamelium/kms_chamelium_sharpness_filter: Add basic test Swati Sharma

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=9a90fe38-8a7a-4102-9830-7867029cc7ee@intel.com \
    --to=ankit.k.nautiyal@intel.com \
    --cc=igt-dev@lists.freedesktop.org \
    --cc=swati2.sharma@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