Igt-dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
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 1/3] lib/igt_kms: Move backlight read and write to lib
Date: Thu, 24 Oct 2024 12:05:12 +0530	[thread overview]
Message-ID: <bbc2c90d-814d-44c9-937c-c9125fc25c4c@intel.com> (raw)
In-Reply-To: <20241024045212.1697869-2-santhosh.reddy.guddati@intel.com>


On 10/24/2024 10:22 AM, Santhosh Reddy Guddati wrote:
> move backlight_read and backlight_write functions from
> kms_pm_backlight to library to reuse in other tests.
>
> move and rename struct context to intel_backlight_context_t.
> -->Please format discription correctly and start new line with capital.
> 	
> v2: Rename backlight_read to igt_backlight_read and backlight_write to
> backlight_write (Suraj).
> Add a new member to intel_backlight_context_t to cache vendor specific
> backlight path.
> 	-->please allin above line with v2
>
>
> Signed-off-by: Santhosh Reddy Guddati <santhosh.reddy.guddati@intel.com>
> Reviewed-by: Suraj Kandpal <suraj.kandpal@intel.com>
> ---
>   lib/igt_kms.c | 66 +++++++++++++++++++++++++++++++++++++++++++++++++++
>   lib/igt_kms.h | 12 ++++++++++
>   2 files changed, 78 insertions(+)
>
> diff --git a/lib/igt_kms.c b/lib/igt_kms.c
> index bb35d4b82..5d8096a17 100644
> --- a/lib/igt_kms.c
> +++ b/lib/igt_kms.c
> @@ -7119,3 +7119,69 @@ void igt_reset_link_params(int drm_fd, igt_output_t *output)
>   	temp = drmModeGetConnector(drm_fd, output->config.connector->connector_id);
>   	drmModeFreeConnector(temp);
>   }
> +
> +/**
> + * igt_backlight_read:
> + * @result:	Pointer to store the result
> + * @fname:	Name of the file to read
> + * @context:	Pointer to the context structure
> + */
> +int igt_backlight_read(int *result, const char *fname, igt_backlight_context_t *context)
> +{
> +	int fd;
> +	char full[PATH_MAX];
> +	char dst[64];
> +	int r, e;
> +
> +	igt_assert(snprintf(full, PATH_MAX, "%s/%s/%s",
> +			    context->backlight_dir_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;
> +}
> +
> +/**
> + * igt_backlight_write:
> + * @value:		Value to write
> + * @fname:		Name of the file to write
> + * @context:	Pointer to the context structure
> + */
> +int igt_backlight_write(int value, const char *fname, igt_backlight_context_t *context)
> +{
> +	int fd;
> +	char full[PATH_MAX];
> +	char src[64];
> +	int len;
> +
> +	igt_assert(snprintf(full, PATH_MAX, "%s/%s/%s",
> +			    context->backlight_dir_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;
> +}
> diff --git a/lib/igt_kms.h b/lib/igt_kms.h
> index 2b26d2bbf..bd154d1c1 100644
> --- a/lib/igt_kms.h
> +++ b/lib/igt_kms.h
> @@ -33,6 +33,7 @@
>   #include <stdint.h>
>   #include <stddef.h>
>   #include <assert.h>
> +#include <limits.h>
>   
>   #include <xf86drmMode.h>
>   
> @@ -513,6 +514,15 @@ typedef struct {
>   	uint16_t tile_h_size, tile_v_size;
>   } igt_tile_info_t;
>   
> +/* Backlight context*/
> +typedef struct {
> +	int max;
> +	int old;
> +	igt_output_t *output;
> +	char path[PATH_MAX];
> +	char backlight_dir_path[PATH_MAX];
> +} igt_backlight_context_t;
> +
>   void igt_display_reset_outputs(igt_display_t *display);
>   void igt_display_require(igt_display_t *display, int drm_fd);
>   void igt_display_fini(igt_display_t *display);
> @@ -1253,5 +1263,7 @@ bool igt_has_force_link_training_failure_debugfs(int drmfd, igt_output_t *output
>   int igt_get_dp_pending_lt_failures(int drm_fd, igt_output_t *output);
>   int igt_get_dp_pending_retrain(int drm_fd, igt_output_t *output);
>   void igt_reset_link_params(int drm_fd, igt_output_t *output);
> +int igt_backlight_read(int *result, const char *fname, igt_backlight_context_t *context);
> +int igt_backlight_write(int value, const char *fname, igt_backlight_context_t *context);
>   
>   #endif /* __IGT_KMS_H__ */

  reply	other threads:[~2024-10-24  6:35 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 [this message]
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
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=bbc2c90d-814d-44c9-937c-c9125fc25c4c@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