[igt-dev] [v2] tests/kms_scaling_filters: New IGT to validate scaling filters

Subsystems: library code, the rest

4 messages, 3 authors, 2022-06-14 · open the first message on its own page

[igt-dev] [v2] tests/kms_scaling_filters: New IGT to validate scaling filters

From: Swati Sharma <hidden>
Date: 2022-06-08 17:12:52

SCALING_FILTER can be used either as plane scaler property
or CRTC scaler property.
The value of this property can be one of the following:
    Default:
             Driver's default scaling filter
    Nearest Neighbor:
             Nearest Neighbor scaling filter
If NN is used for scaling, sharpness is preserved
whereas if we use default scaling we can see blurriness
at edges.

Four subtests are written upscale/downscale with NN and default
scaling filters.

v2: no need to set pipe scaler filter property

Signed-off-by: Swati Sharma <redacted>
---
 lib/igt_kms.c               |  16 ++++
 lib/igt_kms.h               |   1 +
 tests/kms_scaling_filters.c | 180 ++++++++++++++++++++++++++++++++++++
 tests/meson.build           |   1 +
 4 files changed, 198 insertions(+)
 create mode 100644 tests/kms_scaling_filters.c
diff --git a/lib/igt_kms.c b/lib/igt_kms.c
index b70d336e..e939ed41 100644
--- a/lib/igt_kms.c
+++ b/lib/igt_kms.c
@@ -912,6 +912,22 @@ const char *kmstest_connector_status_str(int status)
 	return find_type_name(connector_status_names, status);
 }
 
+enum drm_scaling_filter {
+	DRM_SCALING_FILTER_DEFAULT,
+	DRM_SCALING_FILTER_NEAREST_NEIGHBOR,
+};
+
+static const struct type_name drm_scaling_filter[] = {
+	{ DRM_SCALING_FILTER_DEFAULT, "Default" },
+	{ DRM_SCALING_FILTER_NEAREST_NEIGHBOR, "Nearest Neighbor" },
+	{}
+};
+
+const char *kmstest_scaling_filter_str(int filter)
+{
+	return find_type_name(drm_scaling_filter, filter);
+}
+
 static const struct type_name connector_type_names[] = {
 	{ DRM_MODE_CONNECTOR_Unknown, "Unknown" },
 	{ DRM_MODE_CONNECTOR_VGA, "VGA" },
diff --git a/lib/igt_kms.h b/lib/igt_kms.h
index a334e0cf..2abb3353 100644
--- a/lib/igt_kms.h
+++ b/lib/igt_kms.h
@@ -107,6 +107,7 @@ enum igt_custom_edid_type {
 const char *kmstest_encoder_type_str(int type);
 const char *kmstest_connector_status_str(int status);
 const char *kmstest_connector_type_str(int type);
+const char *kmstest_scaling_filter_str(int filter);
 
 void kmstest_dump_mode(drmModeModeInfo *mode);
 
diff --git a/tests/kms_scaling_filters.c b/tests/kms_scaling_filters.c
new file mode 100644
index 00000000..3928fafb
--- /dev/null
+++ b/tests/kms_scaling_filters.c
@@ -0,0 +1,180 @@
+/*
+ * Copyright © 2022 Intel Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Author:
+ *     Swati Sharma <swati2.sharma@intel.com>
+ */
+
+#include "igt.h"
+#include "igt_kms.h"
+
+IGT_TEST_DESCRIPTION("Test display scaling filters");
+
+enum {
+	DRM_SCALING_FILTER_DEFAULT,
+	DRM_SCALING_FILTER_NEAREST_NEIGHBOR,
+};
+
+typedef struct data {
+	igt_display_t display;
+	int drm_fd;
+} data_t;
+
+typedef struct {
+	float r;
+	float g;
+	float b;
+} rgb_color_t;
+
+static void set_color(rgb_color_t *color, float r, float g, float b)
+{
+	color->r = r;
+	color->g = g;
+	color->b = b;
+}
+
+#define RGB_COLOR(color) \
+	color.r, color.g, color.b
+
+static void
+paint_squares(data_t *data, struct igt_fb *fb, float o)
+{
+	cairo_t *cr;
+	unsigned int w = fb->width;
+	unsigned int h = fb->height;
+	rgb_color_t tl, tr, bl, br;
+
+	cr = igt_get_cairo_ctx(data->drm_fd, fb);
+
+	set_color(&tl, o, 0.0f, 0.0f);
+	set_color(&tr, 0.0f, o, 0.0f);
+	set_color(&br, o, o, o);
+	set_color(&bl, 0.0f, 0.0f, o);
+
+	igt_paint_color(cr, 0, 0, w / 2, h / 2, RGB_COLOR(tl));
+	igt_paint_color(cr, w / 2, 0, w / 2, h / 2, RGB_COLOR(tr));
+	igt_paint_color(cr, 0, h / 2, w / 2, h / 2, RGB_COLOR(bl));
+	igt_paint_color(cr, w / 2, h / 2, w / 2, h / 2, RGB_COLOR(br));
+
+	igt_put_cairo_ctx(cr);
+}
+
+#define IS_FACTOR 2
+static void test_scaling_filter_on_output(data_t *data, const enum pipe pipe,
+					  igt_output_t *output, igt_plane_t *plane, int flags,
+					  bool is_upscale)
+{
+	igt_display_t *display = &data->display;
+	const float flip_opacity = 1;
+	drmModeModeInfo *mode;
+	struct igt_fb fb;
+	int w, h, ret;
+
+	igt_output_set_pipe(output, pipe);
+	mode = igt_output_get_mode(output);
+
+	if (is_upscale) {
+		w = mode->hdisplay / IS_FACTOR;
+		h = mode->vdisplay / IS_FACTOR;
+	} else {
+		w = mode->hdisplay;
+		h = mode->vdisplay;
+	}
+
+	igt_create_fb(display->drm_fd, w, h,
+		      DRM_FORMAT_XRGB8888, DRM_FORMAT_MOD_NONE, &fb);
+	paint_squares(data, &fb, flip_opacity);
+
+	igt_plane_set_prop_enum(plane, IGT_PLANE_SCALING_FILTER, kmstest_scaling_filter_str(flags));
+
+	igt_plane_set_fb(plane, &fb);
+	igt_plane_set_position(plane, 0, 0);
+
+	if (is_upscale)
+		igt_plane_set_size(plane, mode->hdisplay, mode->vdisplay);
+	else
+		igt_plane_set_size(plane, mode->hdisplay * 0.75, mode->vdisplay * 0.75);
+
+	ret = igt_display_try_commit2(display, COMMIT_ATOMIC);
+
+	igt_plane_set_fb(plane, NULL);
+	igt_plane_set_position(plane, 0, 0);
+	igt_remove_fb(display->drm_fd, &fb);
+
+	igt_skip_on_f(ret == -ERANGE || ret == -EINVAL,
+		      "Unsupported scaling factor with fb size %dx%d\n", w, h);
+	igt_assert_eq(ret, 0);
+}
+
+static void test_scaling_filter(data_t *data, int flags, bool is_upscale)
+{
+	igt_display_t *display = &data->display;
+	igt_output_t *output;
+	igt_plane_t *plane;
+	enum pipe pipe;
+
+	for_each_pipe_with_valid_output(display, pipe, output) {
+		for_each_plane_on_pipe(display, pipe, plane) {
+			if (!igt_plane_has_prop(plane, IGT_PLANE_SCALING_FILTER))
+				continue;
+
+			igt_dynamic_f("pipe-%s-%s-plane-%u", kmstest_pipe_name(pipe), output->name, plane->index)
+				test_scaling_filter_on_output(data, pipe, output, plane, flags, is_upscale);
+
+			igt_display_reset(display);
+		}
+	}
+}
+
+igt_main
+{
+	data_t data = {};
+
+	igt_fixture {
+		data.drm_fd = drm_open_driver_master(DRIVER_ANY);
+		igt_require(data.drm_fd >= 0);
+
+		kmstest_set_vt_graphics_mode();
+
+		igt_display_require(&data.display, data.drm_fd);
+		igt_require(data.display.is_atomic);
+
+		igt_display_require_output(&data.display);
+	}
+
+	igt_describe("Tests default scaling filter, upscale");
+	igt_subtest_with_dynamic("scaling-filter-default-upscale")
+		test_scaling_filter(&data, DRM_SCALING_FILTER_DEFAULT, true);
+	igt_describe("Tests default scaling filter, downscale");
+	igt_subtest_with_dynamic("scaling-filter-default-downscale")
+		test_scaling_filter(&data, DRM_SCALING_FILTER_DEFAULT, false);
+	igt_describe("Tests nearest neighbor scaling filter, upscale");
+	igt_subtest_with_dynamic("scaling-filter-nn-upscale")
+		test_scaling_filter(&data, DRM_SCALING_FILTER_NEAREST_NEIGHBOR, true);
+	igt_describe("Tests nearest neighbor scaling filter, downscale");
+	igt_subtest_with_dynamic("scaling-filter-nn-downscale")
+		test_scaling_filter(&data, DRM_SCALING_FILTER_NEAREST_NEIGHBOR, false);
+
+
+	igt_fixture
+		igt_display_fini(&data.display);
+}
diff --git a/tests/meson.build b/tests/meson.build
index fb0f1e37..dd83c068 100644
--- a/tests/meson.build
+++ b/tests/meson.build
@@ -52,6 +52,7 @@ test_progs = [
 	'kms_properties',
 	'kms_rmfb',
 	'kms_rotation_crc',
+	'kms_scaling_filters',
 	'kms_scaling_modes',
 	'kms_selftest',
 	'kms_sequence',
-- 
2.25.1

[igt-dev] ✗ Fi.CI.BUILD: failure for tests/kms_scaling_filters: New IGT to validate scaling filters

From: Patchwork <hidden>
Date: 2022-06-08 17:16:15

== Series Details ==

Series: tests/kms_scaling_filters: New IGT to validate scaling filters
URL   : https://patchwork.freedesktop.org/series/104905/
State : failure

== Summary ==

IGT patchset build failed on latest successful build
2aff41793e5f7f23206547ff615187708e728b92 tests/i915/kms_big_fb: Move cleanup code to fixture

[207/939] Linking target tests/feature_discovery
[208/939] Linking target tests/kms_atomic_interruptible
[209/939] Linking target tests/kms_3d
[210/939] Linking target tests/kms_addfb_basic
[211/939] Linking target tests/kms_async_flips
[212/939] Linking target tests/kms_cursor_crc
[213/939] Linking target tests/kms_atomic
[214/939] Linking target tests/kms_atomic_transition
[215/939] Linking target tests/kms_bw
[216/939] Linking target tests/kms_concurrent
[217/939] Linking target tests/kms_content_protection
[218/939] Linking target tests/kms_cursor_edge_walk
[219/939] Linking target tests/kms_cursor_legacy
[220/939] Linking target tests/kms_dither
[221/939] Linking target tests/kms_display_modes
[222/939] Linking target tests/kms_dp_aux_dev
[223/939] Linking target tests/kms_dp_tiled_display
[224/939] Linking target tests/kms_getfb
[225/939] Linking target tests/kms_flip
[226/939] Linking target tests/kms_flip_event_leak
[227/939] Linking target tests/kms_force_connector_basic
[228/939] Linking target tests/kms_multipipe_modeset
[229/939] Linking target tests/kms_hdmi_inject
[230/939] Linking target tests/kms_hdr
[231/939] Linking target tests/kms_invalid_mode
[232/939] Linking target tests/kms_plane
[233/939] Linking target tests/kms_lease
[234/939] Linking target tests/kms_panel_fitting
[235/939] Linking target tests/kms_plane_alpha_blend
[236/939] Linking target tests/kms_plane_cursor
[237/939] Linking target tests/kms_plane_lowres
[238/939] Linking target tests/kms_plane_multiple
[239/939] Linking target tests/kms_plane_scaling
[240/939] Linking target tests/kms_prime
[241/939] Linking target tests/kms_prop_blob
[242/939] Compiling C object tests/kms_scaling_filters.p/kms_scaling_filters.c.o
FAILED: tests/kms_scaling_filters.p/kms_scaling_filters.c.o 
ccache cc -Itests/kms_scaling_filters.p -Itests -I../tests -I../include/drm-uapi -I../include/linux-uapi -Ilib -I../lib -I../lib/stubs/syscalls -I. -I.. -I/usr/include/cairo -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/libpng16 -I/usr/include/libpng12 -I/usr/include/libdrm -I/usr/include/libdrm/nouveau -I/usr/include/x86_64-linux-gnu -I/usr/include/alsa -I/usr/include -I/home/cidrm/kernel_headers/include -fdiagnostics-color=always -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -Wextra -std=gnu11 -O2 -g -D_GNU_SOURCE -include config.h -D_FORTIFY_SOURCE=2 -Wbad-function-cast -Wdeclaration-after-statement -Wformat=2 -Wimplicit-fallthrough=0 -Wlogical-op -Wmissing-declarations -Wmissing-format-attribute -Wmissing-noreturn -Wmissing-prototypes -Wnested-externs -Wold-style-definition -Wpointer-arith -Wredundant-decls -Wshadow -Wstrict-prototypes -Wuninitialized -Wunused -Wno-clobbered -Wno-maybe-uninitialized -Wno-missing-field-initializers -Wno-pointer-arith -Wno-sign-compare -Wno-type-limits -Wno-unused-parameter -Wno-unused-result -Werror=address -Werror=array-bounds -Werror=implicit -Werror=init-self -Werror=int-to-pointer-cast -Werror=main -Werror=missing-braces -Werror=nonnull -Werror=pointer-to-int-cast -Werror=return-type -Werror=sequence-point -Werror=trigraphs -Werror=write-strings -fno-builtin-malloc -fno-builtin-calloc -fcommon -pthread -MD -MQ tests/kms_scaling_filters.p/kms_scaling_filters.c.o -MF tests/kms_scaling_filters.p/kms_scaling_filters.c.o.d -o tests/kms_scaling_filters.p/kms_scaling_filters.c.o -c ../tests/kms_scaling_filters.c
../tests/kms_scaling_filters.c: In function ‘test_scaling_filter_on_output’:
../tests/kms_scaling_filters.c:107:33: error: ‘IGT_PLANE_SCALING_FILTER’ undeclared (first use in this function); did you mean ‘IGT_PLANE_COLOR_RANGE’?
  igt_plane_set_prop_enum(plane, IGT_PLANE_SCALING_FILTER, kmstest_scaling_filter_str(flags));
                                 ^~~~~~~~~~~~~~~~~~~~~~~~
                                 IGT_PLANE_COLOR_RANGE
../tests/kms_scaling_filters.c:107:33: note: each undeclared identifier is reported only once for each function it appears in
../tests/kms_scaling_filters.c: In function ‘test_scaling_filter’:
../tests/kms_scaling_filters.c:137:35: error: ‘IGT_PLANE_SCALING_FILTER’ undeclared (first use in this function); did you mean ‘IGT_PLANE_COLOR_RANGE’?
    if (!igt_plane_has_prop(plane, IGT_PLANE_SCALING_FILTER))
                                   ^~~~~~~~~~~~~~~~~~~~~~~~
                                   IGT_PLANE_COLOR_RANGE
ninja: build stopped: subcommand failed.

Re: [igt-dev] [v2] tests/kms_scaling_filters: New IGT to validate scaling filters

From: Kamil Konieczny <hidden>
Date: 2022-06-09 07:46:36

Hi Swati,

few small nits below.

On 2022-06-08 at 22:43:04 +0530, Swati Sharma wrote:
quoted hunk
SCALING_FILTER can be used either as plane scaler property
or CRTC scaler property.
The value of this property can be one of the following:
    Default:
             Driver's default scaling filter
    Nearest Neighbor:
             Nearest Neighbor scaling filter
If NN is used for scaling, sharpness is preserved
whereas if we use default scaling we can see blurriness
at edges.

Four subtests are written upscale/downscale with NN and default
scaling filters.

v2: no need to set pipe scaler filter property

Signed-off-by: Swati Sharma <redacted>
---
 lib/igt_kms.c               |  16 ++++
 lib/igt_kms.h               |   1 +
 tests/kms_scaling_filters.c | 180 ++++++++++++++++++++++++++++++++++++
 tests/meson.build           |   1 +
 4 files changed, 198 insertions(+)
 create mode 100644 tests/kms_scaling_filters.c
diff --git a/lib/igt_kms.c b/lib/igt_kms.c
index b70d336e..e939ed41 100644
--- a/lib/igt_kms.c
+++ b/lib/igt_kms.c
@@ -912,6 +912,22 @@ const char *kmstest_connector_status_str(int status)
 	return find_type_name(connector_status_names, status);
 }
 
+enum drm_scaling_filter {
+	DRM_SCALING_FILTER_DEFAULT,
+	DRM_SCALING_FILTER_NEAREST_NEIGHBOR,
+};
+
+static const struct type_name drm_scaling_filter[] = {
+	{ DRM_SCALING_FILTER_DEFAULT, "Default" },
+	{ DRM_SCALING_FILTER_NEAREST_NEIGHBOR, "Nearest Neighbor" },
+	{}
+};
+
+const char *kmstest_scaling_filter_str(int filter)
+{
+	return find_type_name(drm_scaling_filter, filter);
+}
+
 static const struct type_name connector_type_names[] = {
 	{ DRM_MODE_CONNECTOR_Unknown, "Unknown" },
 	{ DRM_MODE_CONNECTOR_VGA, "VGA" },
diff --git a/lib/igt_kms.h b/lib/igt_kms.h
index a334e0cf..2abb3353 100644
--- a/lib/igt_kms.h
+++ b/lib/igt_kms.h
@@ -107,6 +107,7 @@ enum igt_custom_edid_type {
 const char *kmstest_encoder_type_str(int type);
 const char *kmstest_connector_status_str(int status);
 const char *kmstest_connector_type_str(int type);
+const char *kmstest_scaling_filter_str(int filter);
 
 void kmstest_dump_mode(drmModeModeInfo *mode);
 
diff --git a/tests/kms_scaling_filters.c b/tests/kms_scaling_filters.c
new file mode 100644
index 00000000..3928fafb
--- /dev/null
+++ b/tests/kms_scaling_filters.c
@@ -0,0 +1,180 @@
+/*
+ * Copyright © 2022 Intel Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
Please use SPDX licence placeholder.
quoted hunk
+ *
+ * Author:
+ *     Swati Sharma <swati2.sharma@intel.com>
+ */
+
+#include "igt.h"
+#include "igt_kms.h"
+
+IGT_TEST_DESCRIPTION("Test display scaling filters");
+
+enum {
+	DRM_SCALING_FILTER_DEFAULT,
+	DRM_SCALING_FILTER_NEAREST_NEIGHBOR,
+};
+
+typedef struct data {
+	igt_display_t display;
+	int drm_fd;
+} data_t;
+
+typedef struct {
+	float r;
+	float g;
+	float b;
+} rgb_color_t;
+
+static void set_color(rgb_color_t *color, float r, float g, float b)
+{
+	color->r = r;
+	color->g = g;
+	color->b = b;
+}
+
+#define RGB_COLOR(color) \
+	color.r, color.g, color.b
+
+static void
+paint_squares(data_t *data, struct igt_fb *fb, float o)
+{
+	cairo_t *cr;
+	unsigned int w = fb->width;
+	unsigned int h = fb->height;
+	rgb_color_t tl, tr, bl, br;
+
+	cr = igt_get_cairo_ctx(data->drm_fd, fb);
+
+	set_color(&tl, o, 0.0f, 0.0f);
+	set_color(&tr, 0.0f, o, 0.0f);
+	set_color(&br, o, o, o);
+	set_color(&bl, 0.0f, 0.0f, o);
+
+	igt_paint_color(cr, 0, 0, w / 2, h / 2, RGB_COLOR(tl));
+	igt_paint_color(cr, w / 2, 0, w / 2, h / 2, RGB_COLOR(tr));
+	igt_paint_color(cr, 0, h / 2, w / 2, h / 2, RGB_COLOR(bl));
+	igt_paint_color(cr, w / 2, h / 2, w / 2, h / 2, RGB_COLOR(br));
+
+	igt_put_cairo_ctx(cr);
+}
+
+#define IS_FACTOR 2
+static void test_scaling_filter_on_output(data_t *data, const enum pipe pipe,
+					  igt_output_t *output, igt_plane_t *plane, int flags,
+					  bool is_upscale)
+{
+	igt_display_t *display = &data->display;
+	const float flip_opacity = 1;
+	drmModeModeInfo *mode;
+	struct igt_fb fb;
+	int w, h, ret;
+
+	igt_output_set_pipe(output, pipe);
+	mode = igt_output_get_mode(output);
+
+	if (is_upscale) {
+		w = mode->hdisplay / IS_FACTOR;
+		h = mode->vdisplay / IS_FACTOR;
+	} else {
+		w = mode->hdisplay;
+		h = mode->vdisplay;
+	}
+
+	igt_create_fb(display->drm_fd, w, h,
+		      DRM_FORMAT_XRGB8888, DRM_FORMAT_MOD_NONE, &fb);
+	paint_squares(data, &fb, flip_opacity);
+
+	igt_plane_set_prop_enum(plane, IGT_PLANE_SCALING_FILTER, kmstest_scaling_filter_str(flags));
+
+	igt_plane_set_fb(plane, &fb);
+	igt_plane_set_position(plane, 0, 0);
+
+	if (is_upscale)
+		igt_plane_set_size(plane, mode->hdisplay, mode->vdisplay);
+	else
+		igt_plane_set_size(plane, mode->hdisplay * 0.75, mode->vdisplay * 0.75);
+
+	ret = igt_display_try_commit2(display, COMMIT_ATOMIC);
+
+	igt_plane_set_fb(plane, NULL);
+	igt_plane_set_position(plane, 0, 0);
+	igt_remove_fb(display->drm_fd, &fb);
+
+	igt_skip_on_f(ret == -ERANGE || ret == -EINVAL,
+		      "Unsupported scaling factor with fb size %dx%d\n", w, h);
+	igt_assert_eq(ret, 0);
+}
+
+static void test_scaling_filter(data_t *data, int flags, bool is_upscale)
+{
+	igt_display_t *display = &data->display;
+	igt_output_t *output;
+	igt_plane_t *plane;
+	enum pipe pipe;
+
+	for_each_pipe_with_valid_output(display, pipe, output) {
+		for_each_plane_on_pipe(display, pipe, plane) {
+			if (!igt_plane_has_prop(plane, IGT_PLANE_SCALING_FILTER))
+				continue;
+
+			igt_dynamic_f("pipe-%s-%s-plane-%u", kmstest_pipe_name(pipe), output->name, plane->index)
+				test_scaling_filter_on_output(data, pipe, output, plane, flags, is_upscale);
+
+			igt_display_reset(display);
+		}
+	}
+}
+
+igt_main
+{
+	data_t data = {};
+
+	igt_fixture {
+		data.drm_fd = drm_open_driver_master(DRIVER_ANY);
+		igt_require(data.drm_fd >= 0);
+
+		kmstest_set_vt_graphics_mode();
+
+		igt_display_require(&data.display, data.drm_fd);
+		igt_require(data.display.is_atomic);
+
+		igt_display_require_output(&data.display);
+	}
+
+	igt_describe("Tests default scaling filter, upscale");
+	igt_subtest_with_dynamic("scaling-filter-default-upscale")
+		test_scaling_filter(&data, DRM_SCALING_FILTER_DEFAULT, true);
imho here should be added one empty line to imrove readability.
quoted hunk
+	igt_describe("Tests default scaling filter, downscale");
+	igt_subtest_with_dynamic("scaling-filter-default-downscale")
+		test_scaling_filter(&data, DRM_SCALING_FILTER_DEFAULT, false);
Same here.
quoted hunk
+	igt_describe("Tests nearest neighbor scaling filter, upscale");
+	igt_subtest_with_dynamic("scaling-filter-nn-upscale")
+		test_scaling_filter(&data, DRM_SCALING_FILTER_NEAREST_NEIGHBOR, true);
Same here.
quoted hunk
+	igt_describe("Tests nearest neighbor scaling filter, downscale");
+	igt_subtest_with_dynamic("scaling-filter-nn-downscale")
+		test_scaling_filter(&data, DRM_SCALING_FILTER_NEAREST_NEIGHBOR, false);
+
+
Remove one empty line.
+	igt_fixture
+		igt_display_fini(&data.display);
hmmm, what about closing data.drm_fd here ?

Regards,
Kamil
quoted hunk
+}
diff --git a/tests/meson.build b/tests/meson.build
index fb0f1e37..dd83c068 100644
--- a/tests/meson.build
+++ b/tests/meson.build
@@ -52,6 +52,7 @@ test_progs = [
 	'kms_properties',
 	'kms_rmfb',
 	'kms_rotation_crc',
+	'kms_scaling_filters',
 	'kms_scaling_modes',
 	'kms_selftest',
 	'kms_sequence',
-- 
2.25.1

Re: [igt-dev] [v2] tests/kms_scaling_filters: New IGT to validate scaling filters

From: Sharma, Swati2 <hidden>
Date: 2022-06-14 09:20:46

Hi Kamil,

Thanks for the review comments.
I have addressed in v3.

On 09-Jun-22 1:16 PM, Kamil Konieczny wrote:
Hi Swati,

few small nits below.

On 2022-06-08 at 22:43:04 +0530, Swati Sharma wrote:
quoted
SCALING_FILTER can be used either as plane scaler property
or CRTC scaler property.
The value of this property can be one of the following:
     Default:
              Driver's default scaling filter
     Nearest Neighbor:
              Nearest Neighbor scaling filter
If NN is used for scaling, sharpness is preserved
whereas if we use default scaling we can see blurriness
at edges.

Four subtests are written upscale/downscale with NN and default
scaling filters.

v2: no need to set pipe scaler filter property

Signed-off-by: Swati Sharma <redacted>
---
  lib/igt_kms.c               |  16 ++++
  lib/igt_kms.h               |   1 +
  tests/kms_scaling_filters.c | 180 ++++++++++++++++++++++++++++++++++++
  tests/meson.build           |   1 +
  4 files changed, 198 insertions(+)
  create mode 100644 tests/kms_scaling_filters.c
diff --git a/lib/igt_kms.c b/lib/igt_kms.c
index b70d336e..e939ed41 100644
--- a/lib/igt_kms.c
+++ b/lib/igt_kms.c
@@ -912,6 +912,22 @@ const char *kmstest_connector_status_str(int status)
  	return find_type_name(connector_status_names, status);
  }
  
+enum drm_scaling_filter {
+	DRM_SCALING_FILTER_DEFAULT,
+	DRM_SCALING_FILTER_NEAREST_NEIGHBOR,
+};
+
+static const struct type_name drm_scaling_filter[] = {
+	{ DRM_SCALING_FILTER_DEFAULT, "Default" },
+	{ DRM_SCALING_FILTER_NEAREST_NEIGHBOR, "Nearest Neighbor" },
+	{}
+};
+
+const char *kmstest_scaling_filter_str(int filter)
+{
+	return find_type_name(drm_scaling_filter, filter);
+}
+
  static const struct type_name connector_type_names[] = {
  	{ DRM_MODE_CONNECTOR_Unknown, "Unknown" },
  	{ DRM_MODE_CONNECTOR_VGA, "VGA" },
diff --git a/lib/igt_kms.h b/lib/igt_kms.h
index a334e0cf..2abb3353 100644
--- a/lib/igt_kms.h
+++ b/lib/igt_kms.h
@@ -107,6 +107,7 @@ enum igt_custom_edid_type {
  const char *kmstest_encoder_type_str(int type);
  const char *kmstest_connector_status_str(int status);
  const char *kmstest_connector_type_str(int type);
+const char *kmstest_scaling_filter_str(int filter);
  
  void kmstest_dump_mode(drmModeModeInfo *mode);
  
diff --git a/tests/kms_scaling_filters.c b/tests/kms_scaling_filters.c
new file mode 100644
index 00000000..3928fafb
--- /dev/null
+++ b/tests/kms_scaling_filters.c
@@ -0,0 +1,180 @@
+/*
+ * Copyright © 2022 Intel Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
Please use SPDX licence placeholder.
quoted
+ *
+ * Author:
+ *     Swati Sharma <swati2.sharma@intel.com>
+ */
+
+#include "igt.h"
+#include "igt_kms.h"
+
+IGT_TEST_DESCRIPTION("Test display scaling filters");
+
+enum {
+	DRM_SCALING_FILTER_DEFAULT,
+	DRM_SCALING_FILTER_NEAREST_NEIGHBOR,
+};
+
+typedef struct data {
+	igt_display_t display;
+	int drm_fd;
+} data_t;
+
+typedef struct {
+	float r;
+	float g;
+	float b;
+} rgb_color_t;
+
+static void set_color(rgb_color_t *color, float r, float g, float b)
+{
+	color->r = r;
+	color->g = g;
+	color->b = b;
+}
+
+#define RGB_COLOR(color) \
+	color.r, color.g, color.b
+
+static void
+paint_squares(data_t *data, struct igt_fb *fb, float o)
+{
+	cairo_t *cr;
+	unsigned int w = fb->width;
+	unsigned int h = fb->height;
+	rgb_color_t tl, tr, bl, br;
+
+	cr = igt_get_cairo_ctx(data->drm_fd, fb);
+
+	set_color(&tl, o, 0.0f, 0.0f);
+	set_color(&tr, 0.0f, o, 0.0f);
+	set_color(&br, o, o, o);
+	set_color(&bl, 0.0f, 0.0f, o);
+
+	igt_paint_color(cr, 0, 0, w / 2, h / 2, RGB_COLOR(tl));
+	igt_paint_color(cr, w / 2, 0, w / 2, h / 2, RGB_COLOR(tr));
+	igt_paint_color(cr, 0, h / 2, w / 2, h / 2, RGB_COLOR(bl));
+	igt_paint_color(cr, w / 2, h / 2, w / 2, h / 2, RGB_COLOR(br));
+
+	igt_put_cairo_ctx(cr);
+}
+
+#define IS_FACTOR 2
+static void test_scaling_filter_on_output(data_t *data, const enum pipe pipe,
+					  igt_output_t *output, igt_plane_t *plane, int flags,
+					  bool is_upscale)
+{
+	igt_display_t *display = &data->display;
+	const float flip_opacity = 1;
+	drmModeModeInfo *mode;
+	struct igt_fb fb;
+	int w, h, ret;
+
+	igt_output_set_pipe(output, pipe);
+	mode = igt_output_get_mode(output);
+
+	if (is_upscale) {
+		w = mode->hdisplay / IS_FACTOR;
+		h = mode->vdisplay / IS_FACTOR;
+	} else {
+		w = mode->hdisplay;
+		h = mode->vdisplay;
+	}
+
+	igt_create_fb(display->drm_fd, w, h,
+		      DRM_FORMAT_XRGB8888, DRM_FORMAT_MOD_NONE, &fb);
+	paint_squares(data, &fb, flip_opacity);
+
+	igt_plane_set_prop_enum(plane, IGT_PLANE_SCALING_FILTER, kmstest_scaling_filter_str(flags));
+
+	igt_plane_set_fb(plane, &fb);
+	igt_plane_set_position(plane, 0, 0);
+
+	if (is_upscale)
+		igt_plane_set_size(plane, mode->hdisplay, mode->vdisplay);
+	else
+		igt_plane_set_size(plane, mode->hdisplay * 0.75, mode->vdisplay * 0.75);
+
+	ret = igt_display_try_commit2(display, COMMIT_ATOMIC);
+
+	igt_plane_set_fb(plane, NULL);
+	igt_plane_set_position(plane, 0, 0);
+	igt_remove_fb(display->drm_fd, &fb);
+
+	igt_skip_on_f(ret == -ERANGE || ret == -EINVAL,
+		      "Unsupported scaling factor with fb size %dx%d\n", w, h);
+	igt_assert_eq(ret, 0);
+}
+
+static void test_scaling_filter(data_t *data, int flags, bool is_upscale)
+{
+	igt_display_t *display = &data->display;
+	igt_output_t *output;
+	igt_plane_t *plane;
+	enum pipe pipe;
+
+	for_each_pipe_with_valid_output(display, pipe, output) {
+		for_each_plane_on_pipe(display, pipe, plane) {
+			if (!igt_plane_has_prop(plane, IGT_PLANE_SCALING_FILTER))
+				continue;
+
+			igt_dynamic_f("pipe-%s-%s-plane-%u", kmstest_pipe_name(pipe), output->name, plane->index)
+				test_scaling_filter_on_output(data, pipe, output, plane, flags, is_upscale);
+
+			igt_display_reset(display);
+		}
+	}
+}
+
+igt_main
+{
+	data_t data = {};
+
+	igt_fixture {
+		data.drm_fd = drm_open_driver_master(DRIVER_ANY);
+		igt_require(data.drm_fd >= 0);
+
+		kmstest_set_vt_graphics_mode();
+
+		igt_display_require(&data.display, data.drm_fd);
+		igt_require(data.display.is_atomic);
+
+		igt_display_require_output(&data.display);
+	}
+
+	igt_describe("Tests default scaling filter, upscale");
+	igt_subtest_with_dynamic("scaling-filter-default-upscale")
+		test_scaling_filter(&data, DRM_SCALING_FILTER_DEFAULT, true);
imho here should be added one empty line to imrove readability.
quoted
+	igt_describe("Tests default scaling filter, downscale");
+	igt_subtest_with_dynamic("scaling-filter-default-downscale")
+		test_scaling_filter(&data, DRM_SCALING_FILTER_DEFAULT, false);
Same here.
quoted
+	igt_describe("Tests nearest neighbor scaling filter, upscale");
+	igt_subtest_with_dynamic("scaling-filter-nn-upscale")
+		test_scaling_filter(&data, DRM_SCALING_FILTER_NEAREST_NEIGHBOR, true);
Same here.
quoted
+	igt_describe("Tests nearest neighbor scaling filter, downscale");
+	igt_subtest_with_dynamic("scaling-filter-nn-downscale")
+		test_scaling_filter(&data, DRM_SCALING_FILTER_NEAREST_NEIGHBOR, false);
+
+
Remove one empty line.
quoted
+	igt_fixture
+		igt_display_fini(&data.display);
hmmm, what about closing data.drm_fd here ?

Regards,
Kamil
quoted
+}
diff --git a/tests/meson.build b/tests/meson.build
index fb0f1e37..dd83c068 100644
--- a/tests/meson.build
+++ b/tests/meson.build
@@ -52,6 +52,7 @@ test_progs = [
  	'kms_properties',
  	'kms_rmfb',
  	'kms_rotation_crc',
+	'kms_scaling_filters',
  	'kms_scaling_modes',
  	'kms_selftest',
  	'kms_sequence',
-- 
2.25.1
-- 
~Swati Sharma
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help