From: "Thasleem, Mohammed" <mohammed.thasleem@intel.com>
To: Santhosh Reddy Guddati <santhosh.reddy.guddati@intel.com>,
<igt-dev@lists.freedesktop.org>
Cc: <bhanuprakash.modem@intel.com>, <suraj.kandpal@intel.com>,
<pranay.samala@intel.com>
Subject: Re: [PATCH i-g-t v4 2/3] tests/intel/kms_pm_backlight: Refactor and use functions from lib
Date: Thu, 24 Oct 2024 12:06:20 +0530 [thread overview]
Message-ID: <38ae6773-8717-4250-8883-c3f99ff3ecc3@intel.com> (raw)
In-Reply-To: <20241024045212.1697869-3-santhosh.reddy.guddati@intel.com>
On 10/24/2024 10:22 AM, Santhosh Reddy Guddati wrote:
> Refactor to use igt_backlight_read and igt_backlight_write
> update struct names to maintain consistency.
> move struct context to library.
> -->Start new line with capital.
>
> V2: update backlight_dir_path with BACKLIGHT_PATH.
> v3: rename intel_backlight_context_t to igt_backlight_context_t (Suraj)
>
> Signed-off-by: Santhosh Reddy Guddati <santhosh.reddy.guddati@intel.com>
> Reviewed-by: Suraj Kandpal <suraj.kandpal@intel.com>
> ---
> tests/intel/kms_pm_backlight.c | 108 +++++++++------------------------
> 1 file changed, 28 insertions(+), 80 deletions(-)
>
> diff --git a/tests/intel/kms_pm_backlight.c b/tests/intel/kms_pm_backlight.c
> index 196b5af03..8b59725ac 100644
> --- a/tests/intel/kms_pm_backlight.c
> +++ b/tests/intel/kms_pm_backlight.c
> @@ -72,13 +72,6 @@
> * Functionality: backlight, dpms
> */
>
> -struct context {
> - int max;
> - int old;
> - igt_output_t *output;
> - char path[PATH_MAX];
> -};
> -
> enum {
> TEST_NONE = 0,
> TEST_DPMS,
> @@ -96,65 +89,17 @@ enum {
>
> IGT_TEST_DESCRIPTION("Basic backlight sysfs test");
>
> -static int backlight_read(int *result, const char *fname, struct context *context)
> -{
> - int fd;
> - char full[PATH_MAX];
> - char dst[64];
> - int r, e;
> -
> - igt_assert(snprintf(full, PATH_MAX, "%s/%s/%s", BACKLIGHT_PATH, context->path, fname)
> - < PATH_MAX);
> - fd = open(full, O_RDONLY);
> - if (fd == -1)
> - return -errno;
> -
> - r = read(fd, dst, sizeof(dst));
> - e = errno;
> - close(fd);
> -
> - if (r < 0)
> - return -e;
> -
> - errno = 0;
> - *result = strtol(dst, NULL, 10);
> - return errno;
> -}
> -
> -static int backlight_write(int value, const char *fname, struct context *context)
> -{
> - int fd;
> - char full[PATH_MAX];
> - char src[64];
> - int len;
> -
> - igt_assert(snprintf(full, PATH_MAX, "%s/%s/%s", BACKLIGHT_PATH, context->path, fname)
> - < PATH_MAX);
> - fd = open(full, O_WRONLY);
> - if (fd == -1)
> - return -errno;
> -
> - len = snprintf(src, sizeof(src), "%i", value);
> - len = write(fd, src, len);
> - close(fd);
> -
> - if (len < 0)
> - return len;
> -
> - return 0;
> -}
> -
> -static void test_and_verify(struct context *context, int val)
> +static void test_and_verify(igt_backlight_context_t *context, int val)
> {
> const int tolerance = val * TOLERANCE / 100;
> int result;
>
> - igt_assert_eq(backlight_write(val, "brightness", context), 0);
> - igt_assert_eq(backlight_read(&result, "brightness", context), 0);
> + igt_assert_eq(igt_backlight_write(val, "brightness", context), 0);
> + igt_assert_eq(igt_backlight_read(&result, "brightness", context), 0);
> /* Check that the exact value sticks */
> igt_assert_eq(result, val);
>
> - igt_assert_eq(backlight_read(&result, "actual_brightness", context), 0);
> + igt_assert_eq(igt_backlight_read(&result, "actual_brightness", context), 0);
> /* Some rounding may happen depending on hw */
> igt_assert_f(result >= max(0, val - tolerance) &&
> result <= min(context->max, val + tolerance),
> @@ -162,31 +107,31 @@ static void test_and_verify(struct context *context, int val)
> result, val, tolerance);
> }
>
> -static void test_brightness(struct context *context)
> +static void test_brightness(igt_backlight_context_t *context)
> {
> test_and_verify(context, 0);
> test_and_verify(context, context->max);
> test_and_verify(context, context->max / 2);
> }
>
> -static void test_bad_brightness(struct context *context)
> +static void test_bad_brightness(igt_backlight_context_t *context)
> {
> int val;
> /* First write some sane value */
> - backlight_write(context->max / 2, "brightness", context);
> + igt_backlight_write(context->max / 2, "brightness", context);
> /* Writing invalid values should fail and not change the value */
> - igt_assert_lt(backlight_write(-1, "brightness", context), 0);
> - backlight_read(&val, "brightness", context);
> + igt_assert_lt(igt_backlight_write(-1, "brightness", context), 0);
> + igt_backlight_read(&val, "brightness", context);
> igt_assert_eq(val, context->max / 2);
> - igt_assert_lt(backlight_write(context->max + 1, "brightness", context), 0);
> - backlight_read(&val, "brightness", context);
> + igt_assert_lt(igt_backlight_write(context->max + 1, "brightness", context), 0);
> + igt_backlight_read(&val, "brightness", context);
> igt_assert_eq(val, context->max / 2);
> - igt_assert_lt(backlight_write(INT_MAX, "brightness", context), 0);
> - backlight_read(&val, "brightness", context);
> + igt_assert_lt(igt_backlight_write(INT_MAX, "brightness", context), 0);
> + igt_backlight_read(&val, "brightness", context);
> igt_assert_eq(val, context->max / 2);
> }
>
> -static void test_fade(struct context *context)
> +static void test_fade(igt_backlight_context_t *context)
> {
> int i;
> static const struct timespec ts = { .tv_sec = 0, .tv_nsec = FADESPEED*1000000 };
> @@ -218,19 +163,19 @@ check_dpms(igt_output_t *output)
> igt_assert(igt_wait_for_pm_status(IGT_RUNTIME_PM_STATUS_ACTIVE));
> }
>
> -static void check_dpms_cycle(struct context *context)
> +static void check_dpms_cycle(igt_backlight_context_t *context)
> {
> int max, val_1, val_2;
>
> - backlight_read(&max, "max_brightness", context);
> + igt_backlight_read(&max, "max_brightness", context);
> igt_assert(max);
>
> - backlight_write(max / 2, "brightness", context);
> - backlight_read(&val_1, "actual_brightness", context);
> + igt_backlight_write(max / 2, "brightness", context);
> + igt_backlight_read(&val_1, "actual_brightness", context);
>
> check_dpms(context->output);
>
> - backlight_read(&val_2, "actual_brightness", context);
> + igt_backlight_read(&val_2, "actual_brightness", context);
> igt_assert_eq(val_1, val_2);
> }
>
> @@ -286,11 +231,11 @@ igt_main
> igt_output_t *output;
> char file_path_n[PATH_MAX] = "";
> bool dual_edp = false;
> - struct context contexts[NUM_EDP_OUTPUTS];
> + igt_backlight_context_t contexts[NUM_EDP_OUTPUTS];
> struct {
> const char *name;
> const char *desc;
> - void (*test_t) (struct context *);
> + void (*test_t)(igt_backlight_context_t *context);
> int flags;
> } tests[] = {
> { "basic-brightness", "test the basic brightness.", test_brightness, TEST_NONE },
> @@ -339,14 +284,17 @@ igt_main
>
> close(fd);
>
> + snprintf(contexts[i].backlight_dir_path, PATH_MAX, "%s", BACKLIGHT_PATH);
> +
> /* should be ../../cardX-$output */
> snprintf(file_path_n, PATH_MAX, "%s/%s/device", BACKLIGHT_PATH,
> contexts[i].path);
> igt_assert_lt(16, readlink(file_path_n, full_name, sizeof(full_name) - 1));
> name = basename(full_name);
> - igt_assert(backlight_read(&contexts[i].max,
> - "max_brightness", &contexts[i]) > -1);
> - igt_skip_on(backlight_read(&contexts[i].old, "brightness", &contexts[i]));
> + igt_assert(igt_backlight_read(&contexts[i].max,
> + "max_brightness", &contexts[i]) > -1);
> + igt_skip_on(igt_backlight_read(&contexts[i].old,
> + "brightness", &contexts[i]));
>
> if (!strcmp(name + 6, output->name)) {
> contexts[i++].output = output;
> @@ -383,7 +331,7 @@ igt_main
> igt_fixture {
> /* Restore old brightness */
> for (i = 0; i < (dual_edp ? 2 : 1); i++)
> - backlight_write(contexts[i].old, "brightness", &contexts[i]);
> + igt_backlight_write(contexts[i].old, "brightness", &contexts[i]);
>
> igt_display_fini(&display);
> igt_pm_restore_sata_link_power_management();
next prev parent reply other threads:[~2024-10-24 6:36 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-24 4:52 [PATCH i-g-t v4 0/3] Move backlight read, write to lib Santhosh Reddy Guddati
2024-10-24 4:52 ` [PATCH i-g-t v4 1/3] lib/igt_kms: Move backlight read and " Santhosh Reddy Guddati
2024-10-24 6:35 ` Thasleem, Mohammed
2024-10-24 6:53 ` Reddy Guddati, Santhosh
2024-10-24 4:52 ` [PATCH i-g-t v4 2/3] tests/intel/kms_pm_backlight: Refactor and use functions from lib Santhosh Reddy Guddati
2024-10-24 6:36 ` Thasleem, Mohammed [this message]
2024-10-24 4:52 ` [PATCH i-g-t v4 3/3] tests/kms_hdr: Test brightness manipulation in HDR mode Santhosh Reddy Guddati
2024-10-24 4:59 ` Kandpal, Suraj
2024-10-24 6:37 ` Thasleem, Mohammed
2024-10-24 9:40 ` ✓ Fi.CI.BAT: success for Move backlight read, write to lib (rev4) Patchwork
2024-10-24 10:21 ` ✓ CI.xeBAT: " Patchwork
2024-10-24 12:09 ` ✗ Fi.CI.IGT: failure " Patchwork
2024-10-24 22:47 ` ✓ CI.xeFULL: success " Patchwork
2024-10-25 15:11 ` ✓ Fi.CI.IGT: " Patchwork
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=38ae6773-8717-4250-8883-c3f99ff3ecc3@intel.com \
--to=mohammed.thasleem@intel.com \
--cc=bhanuprakash.modem@intel.com \
--cc=igt-dev@lists.freedesktop.org \
--cc=pranay.samala@intel.com \
--cc=santhosh.reddy.guddati@intel.com \
--cc=suraj.kandpal@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