Igt-dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH i-g-t 0/6] New sharpness tool
@ 2024-09-23  7:10 Swati Sharma
  2024-09-23  7:10 ` [PATCH i-g-t 1/6] data: create new data directory Swati Sharma
                   ` (4 more replies)
  0 siblings, 5 replies; 7+ messages in thread
From: Swati Sharma @ 2024-09-23  7:10 UTC (permalink / raw)
  To: igt-dev; +Cc: Swati Sharma

New sharpness tool is introduced to validate basic functionality
of content adaptive sharpness filter supported with intel LNL platform.

Tool has following 2 main functions:
1. input user defined strength value (1-255)
2. input incr/decr factor for setting strength and use up/down
   arrow keys to increase/decrease strength during run time

To experiment with sharpness, 3 images are used (HD, FHD, 4K).
All the images are stocked images.

Tool has following options:
-h value:   incr/decr factor for setting strength for hd res
-f value:   incr/decr factor for setting strength for fhd res
-k value:   incr/decr factor for setting strength for 4k res
-H value:   user defined strength (1-255) for hd res
-F value:   user defined strength (1-255) for fhd res
-K value:   user defined strength (1-255) for 4k res
-p:         prints this message

Naladala Ramanaidu (1):
  meson: Add sharpness tool

Naladala, Ramanaidu (2):
  data: create new data directory
  lib: update fopen() to accomodate imgdir

Swati Sharma (3):
  [HAX] lib/igt_kms: Added "sharpness strength" as crtc property
  tools: Add new sharpness tool
  data: Add hd, fhd and 4k images

 {tests => data}/1080p-left.png  | Bin
 {tests => data}/1080p-right.png | Bin
 data/1920x1080.png              | Bin 0 -> 3347107 bytes
 data/3840x2160.png              | Bin 0 -> 13426944 bytes
 data/640x480.png                | Bin 0 -> 657520 bytes
 data/meson.build                |  12 ++
 {tests => data}/pass.png        | Bin
 lib/igt_core.c                  |  10 +-
 lib/igt_core.h                  |   4 +-
 lib/igt_kms.c                   |   4 +
 lib/igt_kms.h                   |   1 +
 lib/meson.build                 |   1 +
 meson.build                     |   2 +
 tests/meson.build               |   6 -
 tools/intel_sharpness_tool.c    | 342 ++++++++++++++++++++++++++++++++
 tools/meson.build               |  11 +
 16 files changed, 383 insertions(+), 10 deletions(-)
 rename {tests => data}/1080p-left.png (100%)
 rename {tests => data}/1080p-right.png (100%)
 create mode 100644 data/1920x1080.png
 create mode 100644 data/3840x2160.png
 create mode 100644 data/640x480.png
 create mode 100644 data/meson.build
 rename {tests => data}/pass.png (100%)
 create mode 100644 tools/intel_sharpness_tool.c

-- 
2.25.1


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH i-g-t 1/6] data: create new data directory
  2024-09-23  7:10 [PATCH i-g-t 0/6] New sharpness tool Swati Sharma
@ 2024-09-23  7:10 ` Swati Sharma
  2024-09-23  7:10 ` [PATCH i-g-t 2/6] lib: update fopen() to accomodate imgdir Swati Sharma
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 7+ messages in thread
From: Swati Sharma @ 2024-09-23  7:10 UTC (permalink / raw)
  To: igt-dev; +Cc: Naladala, Ramanaidu, Swati Sharma

From: "Naladala, Ramanaidu" <ramanaidu.naladala@intel.com>

Placing png images inside "tests/" directory seems wrong, as these
are not source files. These images should ideally be in a directory
with other non-exec files, so creating a new "data/" directory to
store such non-exec files.

Signed-off-by: Ramanaidu Naladala <ramanaidu.naladala@intel.com>
Signed-off-by: Swati Sharma <swati2.sharma@intel.com>
---
 {tests => data}/1080p-left.png  | Bin
 {tests => data}/1080p-right.png | Bin
 data/meson.build                |   9 +++++++++
 {tests => data}/pass.png        | Bin
 lib/meson.build                 |   1 +
 meson.build                     |   2 ++
 tests/meson.build               |   6 ------
 7 files changed, 12 insertions(+), 6 deletions(-)
 rename {tests => data}/1080p-left.png (100%)
 rename {tests => data}/1080p-right.png (100%)
 create mode 100644 data/meson.build
 rename {tests => data}/pass.png (100%)

diff --git a/tests/1080p-left.png b/data/1080p-left.png
similarity index 100%
rename from tests/1080p-left.png
rename to data/1080p-left.png
diff --git a/tests/1080p-right.png b/data/1080p-right.png
similarity index 100%
rename from tests/1080p-right.png
rename to data/1080p-right.png
diff --git a/data/meson.build b/data/meson.build
new file mode 100644
index 000000000..415cf9b6b
--- /dev/null
+++ b/data/meson.build
@@ -0,0 +1,9 @@
+image_files = [
+  '1080p-left.png',
+  '1080p-right.png',
+  'pass.png',
+]
+
+foreach img : image_files
+      configure_file(output:img, input:img, copy:true)
+endforeach
diff --git a/tests/pass.png b/data/pass.png
similarity index 100%
rename from tests/pass.png
rename to data/pass.png
diff --git a/lib/meson.build b/lib/meson.build
index c3556a921..544c8caaf 100644
--- a/lib/meson.build
+++ b/lib/meson.build
@@ -236,6 +236,7 @@ foreach f: lib_sources
 	    '-DIGT_DATADIR="@0@"'.format(join_paths(prefix, datadir)),
 	    '-DIGT_SRCDIR="@0@"'.format(srcdir),
 	    '-DIGT_LOG_DOMAIN="@0@"'.format(f.split('.')[0]),
+	    '-DIGT_IMGDIR="@0@"'.format(imgdir),
 	])
 
     lib_intermediates += lib
diff --git a/meson.build b/meson.build
index 0d06721b4..472c38c51 100644
--- a/meson.build
+++ b/meson.build
@@ -286,6 +286,7 @@ vmwgfxdir = join_paths(libexecdir, 'vmwgfx')
 mandir = get_option('mandir')
 pkgconfigdir = join_paths(libdir, 'pkgconfig')
 python3 = find_program('python3', required : true)
+imgdir = join_paths(build_root, 'data')
 
 if get_option('use_rpath')
 	# Set up runpath for the test executables towards libigt.so.
@@ -381,6 +382,7 @@ endif
 subdir('overlay')
 subdir('man')
 subdir('docs')
+subdir('data')
 
 message('Build options')
 message('=============')
diff --git a/tests/meson.build b/tests/meson.build
index e5d8852f3..7f8c755c6 100644
--- a/tests/meson.build
+++ b/tests/meson.build
@@ -503,11 +503,5 @@ if not meson.is_cross_build()
 			output : 'gem_stress.testlist')
 endif
 
-image_files = [
-  '1080p-left.png',
-  '1080p-right.png',
-  'pass.png',
-]
-install_data(sources : image_files, install_dir : datadir)
 
 subdir('intel-ci')
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH i-g-t 2/6] lib: update fopen() to accomodate imgdir
  2024-09-23  7:10 [PATCH i-g-t 0/6] New sharpness tool Swati Sharma
  2024-09-23  7:10 ` [PATCH i-g-t 1/6] data: create new data directory Swati Sharma
@ 2024-09-23  7:10 ` Swati Sharma
  2024-10-14 14:26   ` Kamil Konieczny
  2024-09-23  7:10 ` [PATCH i-g-t 3/6] [HAX] lib/igt_kms: Added "sharpness strength" as crtc property Swati Sharma
                   ` (2 subsequent siblings)
  4 siblings, 1 reply; 7+ messages in thread
From: Swati Sharma @ 2024-09-23  7:10 UTC (permalink / raw)
  To: igt-dev; +Cc: Naladala, Ramanaidu, Swati Sharma

From: "Naladala, Ramanaidu" <ramanaidu.naladala@intel.com>

Update fopen() to accomodate imgage directory path. Tests like kms_3d
use this function while creating fb from png image.

Signed-off-by: Ramanaidu Naladala <ramanaidu.naladala@intel.com>
Signed-off-by: Swati Sharma <swati2.sharma@intel.com>
---
 lib/igt_core.c | 10 ++++++++--
 lib/igt_core.h |  4 ++--
 2 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/lib/igt_core.c b/lib/igt_core.c
index 407f7b551..1a7798d92 100644
--- a/lib/igt_core.c
+++ b/lib/igt_core.c
@@ -3306,7 +3306,7 @@ void igt_reset_timeout(void)
 }
 
 FILE *__igt_fopen_data(const char* igt_srcdir, const char* igt_datadir,
-		       const char* filename)
+		       const char* igt_imgdir, const char* filename)
 {
 	char path[PATH_MAX];
 	FILE *fp;
@@ -3317,8 +3317,14 @@ FILE *__igt_fopen_data(const char* igt_srcdir, const char* igt_datadir,
 		snprintf(path, sizeof(path), "%s/%s", igt_srcdir, filename);
 		fp = fopen(path, "r");
 	}
+
+	if (!fp) {
+		snprintf(path, sizeof(path), "%s/%s", igt_imgdir, filename);
+		fp = fopen(path, "r");
+        }
+
 	if (!fp) {
-		snprintf(path, sizeof(path), "./%s", filename);
+		snprintf(path, sizeof(path), "./data/%s", filename);
 		fp = fopen(path, "r");
 	}
 
diff --git a/lib/igt_core.h b/lib/igt_core.h
index 90f57402f..5b058a8d0 100644
--- a/lib/igt_core.h
+++ b/lib/igt_core.h
@@ -1457,7 +1457,7 @@ static inline uint32_t igt_seconds_elapsed(struct timespec *start)
 void igt_reset_timeout(void);
 
 FILE *__igt_fopen_data(const char* igt_srcdir, const char* igt_datadir,
-		       const char* filename);
+		       const char* igt_imgdir, const char* filename);
 /**
  * igt_fopen_data:
  * @filename: filename to open.
@@ -1466,7 +1466,7 @@ FILE *__igt_fopen_data(const char* igt_srcdir, const char* igt_datadir,
  * then from build directory, and finally from current directory.
  */
 #define igt_fopen_data(filename) \
-	__igt_fopen_data(IGT_SRCDIR, IGT_DATADIR, filename)
+	__igt_fopen_data(IGT_SRCDIR, IGT_DATADIR, IGT_IMGDIR, filename)
 
 int igt_system(const char *command);
 int igt_system_quiet(const char *command);
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH i-g-t 3/6] [HAX] lib/igt_kms: Added "sharpness strength" as crtc property
  2024-09-23  7:10 [PATCH i-g-t 0/6] New sharpness tool Swati Sharma
  2024-09-23  7:10 ` [PATCH i-g-t 1/6] data: create new data directory Swati Sharma
  2024-09-23  7:10 ` [PATCH i-g-t 2/6] lib: update fopen() to accomodate imgdir Swati Sharma
@ 2024-09-23  7:10 ` Swati Sharma
  2024-09-23  7:10 ` [PATCH i-g-t 4/6] tools: Add new sharpness tool Swati Sharma
  2024-09-23  7:10 ` [PATCH i-g-t 6/6] meson: Add " Swati Sharma
  4 siblings, 0 replies; 7+ messages in thread
From: Swati Sharma @ 2024-09-23  7:10 UTC (permalink / raw)
  To: igt-dev; +Cc: Swati Sharma, Mohammed Thasleem

Added "sharpness strength" as crtc property.

This patch is already part of other PW
https://patchwork.freedesktop.org/series/130218/

v2: Replace SHARPENESS_STRENGTH with SHARPNESS_STRENGTH. (Nemesa)

Signed-off-by: Swati Sharma <swati2.sharma@intel.com>
Signed-off-by: Mohammed Thasleem <mohammed.thasleem@intel.com>
---
 lib/igt_kms.c | 4 ++++
 lib/igt_kms.h | 1 +
 2 files changed, 5 insertions(+)

diff --git a/lib/igt_kms.c b/lib/igt_kms.c
index b40470c02..73b024e0b 100644
--- a/lib/igt_kms.c
+++ b/lib/igt_kms.c
@@ -700,6 +700,7 @@ const char * const igt_crtc_prop_names[IGT_NUM_CRTC_PROPS] = {
 	[IGT_CRTC_OUT_FENCE_PTR] = "OUT_FENCE_PTR",
 	[IGT_CRTC_VRR_ENABLED] = "VRR_ENABLED",
 	[IGT_CRTC_SCALING_FILTER] = "SCALING_FILTER",
+	[IGT_CRTC_SHARPNESS_STRENGTH] = "SHARPNESS_STRENGTH",
 };
 
 const char * const igt_connector_prop_names[IGT_NUM_CONNECTOR_PROPS] = {
@@ -2562,6 +2563,9 @@ static void igt_pipe_reset(igt_pipe_t *pipe)
 	if (igt_pipe_obj_has_prop(pipe, IGT_CRTC_SCALING_FILTER))
 		igt_pipe_obj_set_prop_enum(pipe, IGT_CRTC_SCALING_FILTER, "Default");
 
+	if (igt_pipe_obj_has_prop(pipe, IGT_CRTC_SHARPNESS_STRENGTH))
+		igt_pipe_obj_set_prop_value(pipe, IGT_CRTC_SHARPNESS_STRENGTH, 0);
+
 	pipe->out_fence_fd = -1;
 }
 
diff --git a/lib/igt_kms.h b/lib/igt_kms.h
index 25ba50916..9bba0924d 100644
--- a/lib/igt_kms.h
+++ b/lib/igt_kms.h
@@ -163,6 +163,7 @@ enum igt_atomic_crtc_properties {
        IGT_CRTC_OUT_FENCE_PTR,
        IGT_CRTC_VRR_ENABLED,
        IGT_CRTC_SCALING_FILTER,
+       IGT_CRTC_SHARPNESS_STRENGTH,
        IGT_NUM_CRTC_PROPS
 };
 
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH i-g-t 4/6] tools: Add new sharpness tool
  2024-09-23  7:10 [PATCH i-g-t 0/6] New sharpness tool Swati Sharma
                   ` (2 preceding siblings ...)
  2024-09-23  7:10 ` [PATCH i-g-t 3/6] [HAX] lib/igt_kms: Added "sharpness strength" as crtc property Swati Sharma
@ 2024-09-23  7:10 ` Swati Sharma
  2024-09-23  7:10 ` [PATCH i-g-t 6/6] meson: Add " Swati Sharma
  4 siblings, 0 replies; 7+ messages in thread
From: Swati Sharma @ 2024-09-23  7:10 UTC (permalink / raw)
  To: igt-dev; +Cc: Swati Sharma, Mohammed Thasleem, Nemesa Garg

New sharpness tool is introduced to validate basic functionality
of content adaptive sharpness filter supported with intel LNL platform.

Tool has following 2 main functions:
1. input user defined strength value (1-255)
2. input incr/decr factor for setting strength and use up/down
   arrow keys to increase/decrease strength during run time

To experiment with sharpness, 3 images are used (HD, FHD, 4K).
All the images are stocked images.

Tool has following options:
-h value:   incr/decr factor for setting strength for hd res
-f value:   incr/decr factor for setting strength for fhd res
-k value:   incr/decr factor for setting strength for 4k res
-H value:   user defined strength (1-255) for hd res
-F value:   user defined strength (1-255) for fhd res
-K value:   user defined strength (1-255) for 4k res
-p:         prints this message

Signed-off-by: Swati Sharma <swati2.sharma@intel.com>
Signed-off-by: Mohammed Thasleem <mohammed.thasleem@intel.com>
Signed-off-by: Nemesa Garg <nemesa.garg@intel.com>
---
 tools/intel_sharpness_tool.c | 342 +++++++++++++++++++++++++++++++++++
 1 file changed, 342 insertions(+)
 create mode 100644 tools/intel_sharpness_tool.c

diff --git a/tools/intel_sharpness_tool.c b/tools/intel_sharpness_tool.c
new file mode 100644
index 000000000..3040bb802
--- /dev/null
+++ b/tools/intel_sharpness_tool.c
@@ -0,0 +1,342 @@
+/* SPDX-License-Identifier: MIT */
+/*
+ * Copyright © 2024 Intel Corporation
+ */
+
+#include "igt.h"
+#include "igt_kms.h"
+
+#define DISABLE_FILTER			0
+#define MIN_VALUE			1
+#define MAX_VALUE			255
+#define UP_ARROW			65
+#define DOWN_ARROW			66
+
+#define MAX(a,b) ((a) > (b) ? (a) : (b))
+#define MIN(a,b) ((a) < (b) ? (a) : (b))
+
+typedef struct {
+	int drm_fd;
+	enum pipe pipe_id;
+	struct igt_fb fb;
+	igt_pipe_t *pipe;
+	igt_display_t display;
+	igt_output_t *output;
+	igt_plane_t *plane;
+	drmModeModeInfo *mode;
+	int filter_strength;
+	uint64_t modifier;
+	uint32_t format;
+	const char *png;
+	int incr_value;
+	int width;
+	int height;
+} data_t;
+
+typedef enum {
+	NONE_SELECTED,
+	SHARP_INCR_SELECTED,
+	SHARP_USR_SELECTED,
+	USAGE_SELECTED
+} option;
+
+/* Sets the sharpness filter strength on the display pipe. */
+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(data_t *data)
+{
+	cairo_t *cr = igt_get_cairo_ctx(data->drm_fd, &data->fb);
+	int img_x, img_y, img_w, img_h;
+
+	img_x = img_y = 0;
+	img_w = data->fb.width;
+	img_h = data->fb.height;
+
+	igt_paint_image(cr, data->png, img_x, img_y, img_w, img_h);
+
+	igt_put_cairo_ctx(cr);
+}
+
+static void setup_fb(data_t *data)
+{
+	int fb_id;
+
+	fb_id = igt_create_fb(data->drm_fd, data->width, data->height, data->format, data->modifier, &data->fb);
+	igt_assert(fb_id);
+
+	paint_image(data);
+}
+
+static void cleanup(data_t *data)
+{
+	igt_remove_fb(data->drm_fd, &data->fb);
+
+	igt_output_set_pipe(data->output, PIPE_NONE);
+	igt_display_commit2(&data->display, COMMIT_ATOMIC);
+}
+
+/* Tests the sharpness filter by applying the filter strength and committing the changes. */
+static void test_sharpness_filter(data_t *data)
+{
+	igt_output_t *output = data->output;
+	drmModeModeInfo *mode = data->mode;
+	int ret;
+
+	igt_display_reset(&data->display);
+	igt_output_set_pipe(output, data->pipe_id);
+
+	data->plane = igt_pipe_get_plane_type(data->pipe, DRM_PLANE_TYPE_PRIMARY);
+	igt_skip_on_f(!igt_plane_has_format_mod(data->plane, data->format, data->modifier),
+		      "No requested format/modifier on pipe %s\n", kmstest_pipe_name(data->pipe_id));
+
+	setup_fb(data);
+	igt_plane_set_fb(data->plane, &data->fb);
+	igt_plane_set_size(data->plane, mode->hdisplay, mode->vdisplay);
+
+	/* Set filter strength property */
+	set_filter_strength_on_pipe(data);
+	igt_debug("Sharpened image should be observed for filter strength > 0\n");
+
+	ret = igt_display_try_commit2(&data->display, COMMIT_ATOMIC);
+	igt_assert_eq(ret, 0);
+}
+
+/* Checks if the sharpness filter property is available on a given pipe. */
+static bool has_sharpness_filter(igt_pipe_t *pipe)
+{
+	return igt_pipe_obj_has_prop(pipe, IGT_CRTC_SHARPNESS_STRENGTH);
+}
+
+static void set_output(data_t *data)
+{
+	igt_display_t *display = &data->display;
+	igt_output_t *output;
+	enum pipe pipe;
+
+	for_each_pipe_with_valid_output(display, pipe, output) {
+		/* Restricting to pipe A */
+		if (pipe != PIPE_A)
+			continue;
+
+		data->output = output;
+		data->pipe_id = pipe;
+		data->pipe = &display->pipes[data->pipe_id];
+		data->mode = igt_output_get_mode(data->output);
+
+		if (!has_sharpness_filter(data->pipe))
+			continue;
+
+		igt_output_set_pipe(output, pipe);
+
+		if (!intel_pipe_output_combo_valid(display)) {
+			igt_output_set_pipe(output, PIPE_NONE);
+			continue;
+		}
+	}
+}
+
+/* Handles incrementing or decrementing the sharpness filter strength based on arrow key inputs. */
+static void do_sharpness_incr(data_t *data)
+{
+	char arrow;
+
+	data->modifier = DRM_FORMAT_MOD_LINEAR;
+	data->format = DRM_FORMAT_XRGB8888;
+
+	/* Run with sharpness filter disable */
+	set_output(data);
+	test_sharpness_filter(data);
+
+	/*
+	 * Press up-arrow to increase & down-arrow to decrease strength value
+	 * and 'q' to escape. Strength value is incremented/decremented by
+	 * incr/decr value provide by user if its within range (0-255).
+	 */
+
+	/* Read the arrow key input */
+	while ((arrow = getchar()) != 'q') {
+		if (arrow != UP_ARROW && arrow != DOWN_ARROW)
+			continue;
+
+		if (arrow == UP_ARROW) {
+			data->filter_strength = MIN(MAX_VALUE, data->filter_strength + data->incr_value);
+		} else if (arrow == DOWN_ARROW) {
+			data->filter_strength = MAX(MIN_VALUE, data->filter_strength - data->incr_value);
+		}
+
+		igt_info("pipe-%s-%s-strength-%d \n", kmstest_pipe_name(data->pipe_id), data->output->name, data->filter_strength);
+		test_sharpness_filter(data);
+	}
+
+	/* Clear the input buffer */
+	while (getchar() != '\n');
+	cleanup(data);
+}
+
+/* Allows the user to specify a sharpness filter strength value directly. */
+static void do_sharpness_usr(data_t *data)
+{
+	data->modifier = DRM_FORMAT_MOD_LINEAR;
+	data->format = DRM_FORMAT_XRGB8888;
+
+	/* Run with sharpness filter disable */
+	set_output(data);
+	test_sharpness_filter(data);
+
+	igt_info("pipe-%s-%s-strength-%d \n", kmstest_pipe_name(data->pipe_id), data->output->name, data->filter_strength);
+	test_sharpness_filter(data);
+
+	cleanup(data);
+}
+
+static void print_usage(void)
+{
+	printf("Options:\n"
+"  -h value:   incr/decr factor for setting strength value for hd resolution. use up/down \n"
+"              arrow keys to increase/decrease strength by this factor and q to quit.\n"
+"  -f value:   incr/decr factor for setting strength value for fhd resolution. use up/down \n"
+"              arrow keys to increase/decrease strength by this factor and q to quit.\n"
+"  -k value:   incr/decr factor for setting strength value for 4k resolution. use up/down \n"
+"              arrow keys to increase/decrease strength by this factor and q to quit.\n"
+"  -H value:   user defined strength value (1-255) for hd resolution.\n"
+"  -F value:   user defined strength value (1-255) for fhd resolution.\n"
+"  -K value:   user defined strength value (1-255) for 4k resolution.\n"
+"  -p:         prints this message\n");
+}
+
+int main(int argc, char *argv[])
+{
+	int opt;
+	data_t data = {0};
+	int ret = EXIT_SUCCESS;
+	FILE *file = NULL;
+	const char *files[] = {"640x480.png", "1920x1080.png", "3840x2160.png"};
+
+	option selected_option = NONE_SELECTED;
+
+	if (argc <= 1) {
+		print_usage();
+		return EXIT_SUCCESS;
+	}
+
+	data.drm_fd = drm_open_driver_master(DRIVER_XE);
+	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);
+
+	while ((opt = getopt(argc, argv, "h:f:k:H:F:K:p")) != -1) {
+		switch (opt) {
+		case 'h':
+		case 'f':
+		case 'k':
+			if (selected_option != NONE_SELECTED) {
+				igt_warn("Error: Only one option can be selected.\n");
+				ret = EXIT_FAILURE;
+				goto exit;
+			}
+			data.incr_value = atoi(optarg);
+			if (data.incr_value < 1 || data.incr_value > 255) {
+				igt_warn("Invalid input for -%c option. Value should be between 1 and 255.\n", opt);
+				ret = EXIT_FAILURE;
+				goto exit;
+			}
+			selected_option = SHARP_INCR_SELECTED;
+
+			data.png = (opt == 'h') ? files[0] : ((opt == 'f') ? files[1] : files[2]);
+			data.width = (opt == 'h') ? 640 : ((opt == 'f') ? 1920 : 3840);
+			data.height = (opt == 'h') ? 480 : ((opt == 'f') ? 1080 : 2160);
+
+			// Check if the file exists and can be opened
+			file = igt_fopen_data(data.png);
+			if (file == NULL) {
+				igt_warn("Error: Unable to open file '%s'\n", data.png);
+				ret = EXIT_FAILURE;
+				goto exit;
+			}
+
+			fclose(file);
+			break;
+		case 'H':
+		case 'F':
+		case 'K':
+			if (selected_option != NONE_SELECTED) {
+				igt_warn("Error: Only one option can be selected.\n");
+				ret = EXIT_FAILURE;
+				goto exit;
+			}
+			data.filter_strength = atoi(optarg);
+			if (data.filter_strength < 1 || data.filter_strength > 255) {
+				igt_warn("Invalid input for -%c option. Value should be between 1 and 255.\n", opt);
+				ret = EXIT_FAILURE;
+				goto exit;
+			}
+			selected_option = SHARP_USR_SELECTED;
+
+			data.png = (opt == 'H') ? files[0] : ((opt == 'F') ? files[1] : files[2]);
+			data.width = (opt == 'H') ? 640 : ((opt == 'F') ? 1920 : 3840);
+			data.height = (opt == 'H') ? 480 : ((opt == 'F') ? 1080 : 2160);
+
+			// Check if the file exists and can be opened
+			file = igt_fopen_data(data.png);
+			if (file == NULL) {
+				igt_warn("Error: Unable to open file '%s'\n", data.png);
+				ret = EXIT_FAILURE;
+				goto exit;
+			}
+
+			fclose(file);
+			break;
+		case 'p':
+			if (selected_option != NONE_SELECTED) {
+				igt_warn("Error: Only one option can be selected.\n");
+				print_usage();
+				ret = EXIT_FAILURE;
+				goto exit;
+			}
+			selected_option = USAGE_SELECTED;
+			break;
+		default:
+			igt_warn("Error: Unknown option -%c.\n", opt);
+			print_usage();
+			ret = EXIT_FAILURE;
+			goto exit;
+		}
+	}
+
+	// Check if the selected_option that requires a file was selected
+	if ((selected_option == SHARP_INCR_SELECTED ||  selected_option == SHARP_USR_SELECTED) && data.png == NULL) {
+		igt_warn("Error: No file specified for sharpness adjustment.\n");
+	    	ret = EXIT_FAILURE;
+		goto exit;
+	  }
+
+	// Handle the case where no valid option was processed
+	if (selected_option == NONE_SELECTED) {
+		igt_warn("Error: No valid option selected.\n");
+		ret = EXIT_FAILURE;
+		goto exit;
+	}
+
+	// Perform actions based on the selected option
+	if (selected_option == SHARP_INCR_SELECTED) {
+		do_sharpness_incr(&data);
+	} else if (selected_option == SHARP_USR_SELECTED) {
+		do_sharpness_usr(&data);
+	} else if (selected_option == USAGE_SELECTED) {
+		print_usage();
+	}
+exit:
+	igt_display_fini(&data.display);
+	close(data.drm_fd);
+
+	return ret;
+}
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH i-g-t 6/6] meson: Add sharpness tool
  2024-09-23  7:10 [PATCH i-g-t 0/6] New sharpness tool Swati Sharma
                   ` (3 preceding siblings ...)
  2024-09-23  7:10 ` [PATCH i-g-t 4/6] tools: Add new sharpness tool Swati Sharma
@ 2024-09-23  7:10 ` Swati Sharma
  4 siblings, 0 replies; 7+ messages in thread
From: Swati Sharma @ 2024-09-23  7:10 UTC (permalink / raw)
  To: igt-dev; +Cc: Naladala Ramanaidu, Swati Sharma

From: Naladala Ramanaidu <ramanaidu.naladala@intel.com>

Make changes in tools/meson.build to build sharpness tool.

Signed-off-by: Swati Sharma <swati2.sharma@intel.com>
---
 tools/meson.build | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/tools/meson.build b/tools/meson.build
index df26c4b95..2128c605f 100644
--- a/tools/meson.build
+++ b/tools/meson.build
@@ -66,6 +66,17 @@ if libudev.found()
 		   install : true)
 endif
 
+executable('intel_sharpness_tool', 'intel_sharpness_tool.c',
+           dependencies : tool_deps,
+           c_args : [
+	      '-DIGT_DATADIR="@0@"'.format(join_paths(prefix, datadir)),
+	      '-DIGT_SRCDIR="@0@"'.format(srcdir),
+	      '-DIGT_IMGDIR="@0@"'.format(imgdir),
+	      '-DIGT_LOG_DOMAIN="@0@"'.format(f.split('.')[0])
+            ],
+          install_rpath : bindir_rpathdir,
+          install : true)
+
 executable('gputop', 'gputop.c',
            install : true,
            install_rpath : bindir_rpathdir,
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH i-g-t 2/6] lib: update fopen() to accomodate imgdir
  2024-09-23  7:10 ` [PATCH i-g-t 2/6] lib: update fopen() to accomodate imgdir Swati Sharma
@ 2024-10-14 14:26   ` Kamil Konieczny
  0 siblings, 0 replies; 7+ messages in thread
From: Kamil Konieczny @ 2024-10-14 14:26 UTC (permalink / raw)
  To: igt-dev; +Cc: Swati Sharma, Ramanaidu Naladala

Hi Swati,
On 2024-09-23 at 12:40:19 +0530, Swati Sharma wrote:
> From: "Naladala, Ramanaidu" <ramanaidu.naladala@intel.com>
> 

Please correct e-mail above, it should be same as s-o-b below.

> Update fopen() to accomodate imgage directory path. Tests like kms_3d
s/imgage/image/

> use this function while creating fb from png image.
> 
> Signed-off-by: Ramanaidu Naladala <ramanaidu.naladala@intel.com>
> Signed-off-by: Swati Sharma <swati2.sharma@intel.com>
> ---
>  lib/igt_core.c | 10 ++++++++--
>  lib/igt_core.h |  4 ++--
>  2 files changed, 10 insertions(+), 4 deletions(-)
> 
> diff --git a/lib/igt_core.c b/lib/igt_core.c
> index 407f7b551..1a7798d92 100644
> --- a/lib/igt_core.c
> +++ b/lib/igt_core.c
> @@ -3306,7 +3306,7 @@ void igt_reset_timeout(void)
>  }
>  
>  FILE *__igt_fopen_data(const char* igt_srcdir, const char* igt_datadir,
> -		       const char* filename)
> +		       const char* igt_imgdir, const char* filename)
>  {
>  	char path[PATH_MAX];
>  	FILE *fp;
> @@ -3317,8 +3317,14 @@ FILE *__igt_fopen_data(const char* igt_srcdir, const char* igt_datadir,
>  		snprintf(path, sizeof(path), "%s/%s", igt_srcdir, filename);
>  		fp = fopen(path, "r");
>  	}
> +
> +	if (!fp) {
> +		snprintf(path, sizeof(path), "%s/%s", igt_imgdir, filename);
> +		fp = fopen(path, "r");
> +        }
> +
>  	if (!fp) {
> -		snprintf(path, sizeof(path), "./%s", filename);
> +		snprintf(path, sizeof(path), "./data/%s", filename);
>  		fp = fopen(path, "r");
>  	}

Can we have a fallback here for "./%s" ?

Regards,
Kamil

>  
> diff --git a/lib/igt_core.h b/lib/igt_core.h
> index 90f57402f..5b058a8d0 100644
> --- a/lib/igt_core.h
> +++ b/lib/igt_core.h
> @@ -1457,7 +1457,7 @@ static inline uint32_t igt_seconds_elapsed(struct timespec *start)
>  void igt_reset_timeout(void);
>  
>  FILE *__igt_fopen_data(const char* igt_srcdir, const char* igt_datadir,
> -		       const char* filename);
> +		       const char* igt_imgdir, const char* filename);
>  /**
>   * igt_fopen_data:
>   * @filename: filename to open.
> @@ -1466,7 +1466,7 @@ FILE *__igt_fopen_data(const char* igt_srcdir, const char* igt_datadir,
>   * then from build directory, and finally from current directory.
>   */
>  #define igt_fopen_data(filename) \
> -	__igt_fopen_data(IGT_SRCDIR, IGT_DATADIR, filename)
> +	__igt_fopen_data(IGT_SRCDIR, IGT_DATADIR, IGT_IMGDIR, filename)
>  
>  int igt_system(const char *command);
>  int igt_system_quiet(const char *command);
> -- 
> 2.25.1
> 

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2024-10-14 14:26 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-09-23  7:10 [PATCH i-g-t 0/6] New sharpness tool Swati Sharma
2024-09-23  7:10 ` [PATCH i-g-t 1/6] data: create new data directory Swati Sharma
2024-09-23  7:10 ` [PATCH i-g-t 2/6] lib: update fopen() to accomodate imgdir Swati Sharma
2024-10-14 14:26   ` Kamil Konieczny
2024-09-23  7:10 ` [PATCH i-g-t 3/6] [HAX] lib/igt_kms: Added "sharpness strength" as crtc property Swati Sharma
2024-09-23  7:10 ` [PATCH i-g-t 4/6] tools: Add new sharpness tool Swati Sharma
2024-09-23  7:10 ` [PATCH i-g-t 6/6] meson: Add " Swati Sharma

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox