Skip to contentSkip to conversation

New sharpness tool

PATCH In review Swati Sharma 2 participants 7 messages Sep 23, 2024 – Oct 14, 2024

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

cover New sharpness tool

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
Signature · 1 line
2.25.1
#1 lore raw

PATCH 1/6 data: create new data directory

From: "Naladala, Ramanaidu" <[email protected]>

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.

---
 {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%)
data/1080p-left.png renamed from tests/1080p-left.png +0 -0
similarity index 100%
rename from tests/1080p-left.png
rename to data/1080p-left.png
data/1080p-right.png renamed from tests/1080p-right.png +0 -0
similarity index 100%
rename from tests/1080p-right.png
rename to data/1080p-right.png
data/meson.build new file +9 -0
new file mode 100644
index 000000000..415cf9b6b
@@ -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
data/pass.png renamed from tests/pass.png +0 -0
similarity index 100%
rename from tests/pass.png
rename to data/pass.png
lib/meson.build +1 -0
index c3556a921..544c8caaf 100644
@@ -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
meson.build +2 -0
index 0d06721b4..472c38c51 100644
@@ -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('=============')
tests/meson.build +0 -6
index e5d8852f3..7f8c755c6 100644
@@ -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')
Signature · 1 line
2.25.1
#2 lore raw

PATCH 2/6 lib: update fopen() to accomodate imgdir

In reply to Swati Sharma

From: "Naladala, Ramanaidu" <[email protected]>

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

---
 lib/igt_core.c | 10 ++++++++--
 lib/igt_core.h |  4 ++--
 2 files changed, 10 insertions(+), 4 deletions(-)
lib/igt_core.c +8 -2
index 407f7b551..1a7798d92 100644
@@ -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");
 	}
 
lib/igt_core.h +2 -2
index 90f57402f..5b058a8d0 100644
@@ -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);
Signature · 1 line
2.25.1
#3 lore raw

Re: [PATCH i-g-t 2/6] lib: update fopen() to accomodate imgdir

Hi Swati,

Quoted 2 lines · Swati Sharma

From: "Naladala, Ramanaidu" <[email protected]>

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

Quoted 1 line

Update fopen() to accomodate imgage directory path. Tests like kms_3d

s/imgage/image/

Quoted 27 lines

use this function while creating fb from png image.

---
 lib/igt_core.c | 10 ++++++++--
 lib/igt_core.h |  4 ++--
 2 files changed, 10 insertions(+), 4 deletions(-)
lib/igt_core.c +2 -1
index 407f7b551..1a7798d92 100644
@@ -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");
 	}
+

lib/igt_core.c FILE *__igt_fopen_data(const char* igt_srcdir, const char* igt_datadir, · line 3329

Quoted 10 lines
lib/igt_core.c +6 -1
+	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

Quoted 26 lines
lib/igt_core.h +2 -2
index 90f57402f..5b058a8d0 100644
@@ -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);
Signature · 1 line
2.25.1
#4 lore raw

PATCH 3/6 lib/igt_kms: Added "sharpness strength" as crtc property

In reply to Swati Sharma

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)

---
 lib/igt_kms.c | 4 ++++
 lib/igt_kms.h | 1 +
 2 files changed, 5 insertions(+)
lib/igt_kms.c +4 -0
index b40470c02..73b024e0b 100644
@@ -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;
 }
 
lib/igt_kms.h +1 -0
index 25ba50916..9bba0924d 100644
@@ -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
 };
 
Signature · 1 line
2.25.1
#5 lore raw

PATCH 4/6 tools: Add new sharpness tool

In reply to 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
---
 tools/intel_sharpness_tool.c | 342 +++++++++++++++++++++++++++++++++++
 1 file changed, 342 insertions(+)
 create mode 100644 tools/intel_sharpness_tool.c
tools/intel_sharpness_tool.c new file +342 -0
new file mode 100644
index 000000000..3040bb802
@@ -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;
+}
Signature · 1 line
2.25.1
#6 lore raw

PATCH 6/6 meson: Add sharpness tool

In reply to Swati Sharma

From: Naladala Ramanaidu <[email protected]>

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

---
 tools/meson.build | 11 +++++++++++
 1 file changed, 11 insertions(+)
tools/meson.build +11 -0
index df26c4b95..2128c605f 100644
@@ -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,
Signature · 1 line
2.25.1