<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:Aptos;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        font-size:12.0pt;
        font-family:"Aptos",sans-serif;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:#467886;
        text-decoration:underline;}
span.EmailStyle20
        {mso-style-type:personal-reply;
        font-family:"Aptos",sans-serif;
        color:windowtext;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-size:10.0pt;
        mso-ligatures:none;}
@page WordSection1
        {size:612.0pt 792.0pt;
        margin:72.0pt 72.0pt 72.0pt 72.0pt;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="EN-IN" link="#467886" vlink="#96607D" style="word-wrap:break-word">
<div class="WordSection1">
<p class="MsoNormal"><span style="mso-fareast-language:EN-US">Hi Suraj,<br>
<br>
Agreed, we do have similar functionality in kms_brightness, but it requires some adjustments .<br>
I plan to move these functions “backlight_read” , “backlight_write” to lib/igt_sysfs and make the necessary modifications at a later stage.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="mso-fareast-language:EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="mso-fareast-language:EN-US">Please provide your thoughts on this approach.<br>
<br>
Regards,<br>
Santhosh<o:p></o:p></span></p>
<p class="MsoNormal"><span style="mso-fareast-language:EN-US"><o:p> </o:p></span></p>
<div>
<div style="border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0cm 0cm 0cm">
<p class="MsoNormal"><b><span lang="EN-US" style="font-size:11.0pt;font-family:"Calibri",sans-serif">From:</span></b><span lang="EN-US" style="font-size:11.0pt;font-family:"Calibri",sans-serif"> Kandpal, Suraj <suraj.kandpal@intel.com>
<br>
<b>Sent:</b> Friday, October 4, 2024 10:50 AM<br>
<b>To:</b> Reddy Guddati, Santhosh <santhosh.reddy.guddati@intel.com>; igt-dev@lists.freedesktop.org<br>
<b>Cc:</b> Samala, Pranay <pranay.samala@intel.com>; Reddy Guddati, Santhosh <santhosh.reddy.guddati@intel.com><br>
<b>Subject:</b> Re: [PATCH i-g-t v3 1/1] tests/kms_hdr: Test brightness manipulation in HDR mode<o:p></o:p></span></p>
</div>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<p class="MsoNormal"><strong><span style="font-size:11.0pt;font-family:"Aptos",sans-serif">From:</span></strong><span style="font-size:11.0pt"> Reddy Guddati, Santhosh <<a href="mailto:santhosh.reddy.guddati@intel.com">santhosh.reddy.guddati@intel.com</a>></span><o:p></o:p></p>
</div>
<div id="mail-editor-reference-message-container">
<div id="divRplyFwdMsg">
<p class="MsoNormal"><strong><span style="font-size:11.0pt;font-family:"Aptos",sans-serif">Sent:</span></strong><span style="font-size:11.0pt"> Wednesday, October 2, 2024 8:26:33 pm<br>
<strong><span style="font-family:"Aptos",sans-serif">To:</span></strong> <a href="mailto:igt-dev@lists.freedesktop.org">
igt-dev@lists.freedesktop.org</a> <<a href="mailto:igt-dev@lists.freedesktop.org">igt-dev@lists.freedesktop.org</a>><br>
<strong><span style="font-family:"Aptos",sans-serif">Cc:</span></strong> Samala, Pranay <<a href="mailto:pranay.samala@intel.com">pranay.samala@intel.com</a>>; Kandpal, Suraj <<a href="mailto:suraj.kandpal@intel.com">suraj.kandpal@intel.com</a>>; Reddy Guddati,
 Santhosh <<a href="mailto:santhosh.reddy.guddati@intel.com">santhosh.reddy.guddati@intel.com</a>><br>
<strong><span style="font-family:"Aptos",sans-serif">Subject:</span></strong> [PATCH i-g-t v3 1/1] tests/kms_hdr: Test brightness manipulation in HDR mode<o:p></o:p></span></p>
</div>
<p class="MsoNormal"><br>
<br>
<span style="font-size:11.0pt"><o:p></o:p></span></p>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt">Add subtest for backlight control on hdr enabled edp panels<br>
by changing brightness via sysfs.<br>
<br>
v2: adjust brightness range, refactor and restore brightness (Pranay)<br>
<br>
v3: reuse functions, add flags to avoid duplicate code (Suraj)<br>
<br>
Signed-off-by: Santhosh Reddy Guddati <<a href="mailto:santhosh.reddy.guddati@intel.com">santhosh.reddy.guddati@intel.com</a>><br>
---<br>
 tests/kms_hdr.c | 83 ++++++++++++++++++++++++++++++++++++++++++++++++-<br>
 1 file changed, 82 insertions(+), 1 deletion(-)<br>
<br>
diff --git a/tests/kms_hdr.c b/tests/kms_hdr.c<br>
index f123c6b36..0f07e770b 100644<br>
--- a/tests/kms_hdr.c<br>
+++ b/tests/kms_hdr.c<br>
@@ -64,6 +64,10 @@<br>
  * Description: Tests static toggle with suspend<br>
  * Functionality: colorspace, static_hdr, suspend<br>
  *<br>
+ * SUBTEST: brightness-with-hdr<br>
+ * Description: Tests brightness with HDR<br>
+ * Functionality: colorspace, static_hdr<br>
+ *<br>
  * SUBTEST: static-%s<br>
  * Description: Tests %arg[1].<br>
  * Functionality: colorspace, static_hdr<br>
@@ -81,6 +85,8 @@ IGT_TEST_DESCRIPTION("Test HDR metadata interfaces and bpc switch");<br>
 #define HDR_STATIC_METADATA_BLOCK       0x06<br>
 #define USE_EXTENDED_TAG                0x07<br>
 <br>
+#define INTEL_BACKLIGHT_PATH "/sys/class/backlight/intel_backlight"<br>
+<br>
 /* DRM HDR definitions. Not in the UAPI header, unfortunately. */<br>
 enum hdmi_metadata_type {<br>
         HDMI_STATIC_METADATA_TYPE1 = 0,<br>
@@ -100,6 +106,7 @@ enum {<br>
         TEST_SWAP = 1 << 3,<br>
         TEST_INVALID_METADATA_SIZES = 1 << 4,<br>
         TEST_INVALID_HDR = 1 << 5,<br>
+       TEST_BRIGHTNESS = 1 << 6,<br>
 };<br>
 <br>
 /* BPC connector state. */<br>
@@ -448,6 +455,72 @@ static void fill_hdr_output_metadata_st2048(struct hdr_output_metadata *meta)<br>
         meta->hdmi_metadata_type1.max_cll = 500;   /* 500 nits */<br>
 }<br>
 <br>
+/* TODO: Move adjust_brightness to lib/igt_sysfs to reuse in other tests. */<br>
+static void adjust_brightness(data_t *data, uint32_t flags)<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt"><o:p> </o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt">-----------------<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt"> Do we not have a function in kms_brightness to manipulate brightness let's reuse that rather than writing the whole function here<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt"><o:p> </o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt">Regards,<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt">Suraj Kandpal<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt"><o:p> </o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="margin-bottom:12.0pt"><span style="font-size:11.0pt">----------------------<br>
+{<br>
+       char brightness_path[1024];<br>
+       int brightness_fd;<br>
+       char brightness_value[64];<br>
+       int current_brightness;<br>
+       int max_brightness;<br>
+       int read_brightness;<br>
+       int fd, i;<br>
+<br>
+       /* Get max brightness */<br>
+       snprintf(brightness_path, sizeof(brightness_path),<br>
+                "%s/%s", INTEL_BACKLIGHT_PATH, "max_brightness");<br>
+       fd = open(brightness_path, O_RDONLY);<br>
+       igt_assert_f(fd >= 0, "Failed to open %s\n", brightness_path);<br>
+<br>
+       igt_assert(read(fd, brightness_value, sizeof(brightness_value)) > 0);<br>
+<br>
+       max_brightness = atoi(brightness_value);<br>
+<br>
+       close(fd);<br>
+<br>
+       /* Get current brightness */<br>
+       snprintf(brightness_path, sizeof(brightness_path),<br>
+                "%s/%s", INTEL_BACKLIGHT_PATH, "brightness");<br>
+       fd = open(brightness_path, O_RDONLY);<br>
+       igt_assert_f(fd >= 0, "Failed to open %s\n", brightness_path);<br>
+<br>
+       igt_assert(read(fd, brightness_value, sizeof(brightness_value)) > 0);<br>
+<br>
+       current_brightness = atoi(brightness_value);<br>
+<br>
+       close(fd);<br>
+<br>
+       for (i = 0; i <= max_brightness; i += 50) {<br>
+               fd = open(brightness_path, O_WRONLY);<br>
+               igt_assert_f(fd >= 0, "Failed to open %s\n", brightness_path);<br>
+<br>
+               snprintf(brightness_value, sizeof(brightness_value), "%d", i);<br>
+               igt_assert(write(fd, brightness_value, strlen(brightness_value)) > 0);<br>
+<br>
+               close(fd);<br>
+<br>
+               /* Verify brightness adjustment */<br>
+               fd = open(brightness_path, O_RDONLY);<br>
+               igt_assert(fd >= 0);<br>
+<br>
+               igt_assert(read(fd, brightness_value, sizeof(brightness_value)) > 0);<br>
+<br>
+               read_brightness = atoi(brightness_value);<br>
+<br>
+               igt_assert_eq(read_brightness, i);<br>
+<br>
+               close(fd);<br>
+       }<br>
+<br>
+       fd = open(brightness_path, O_WRONLY);<br>
+       igt_assert_f(fd >= 0, "Failed to open %s\n", brightness_path);<br>
+<br>
+       snprintf(brightness_value, sizeof(brightness_value), "%d", current_brightness);<br>
+       igt_assert(write(brightness_fd, brightness_value, strlen(brightness_value)) > 0);<br>
+<br>
+       close(fd);<br>
+}<br>
+<br>
 static void test_static_toggle(data_t *data, enum pipe pipe,<br>
                                igt_output_t *output,<br>
                                uint32_t flags)<br>
@@ -483,6 +556,9 @@ static void test_static_toggle(data_t *data, enum pipe pipe,<br>
                 igt_assert_eq(system("dmesg|tail -n 1000|grep -E \"Unknown EOTF [0-9]+\""), 0);<br>
                 goto cleanup;<br>
         }<br>
+       if (flags & TEST_BRIGHTNESS)<br>
+               adjust_brightness(data, flags);<br>
+<br>
         igt_assert_output_bpc_equal(data->fd, pipe, output->name, 10);<br>
 <br>
         /* Verify that the CRC are equal after DPMS or suspend. */<br>
@@ -685,7 +761,8 @@ static void test_hdr(data_t *data, uint32_t flags)<br>
 <br>
                         igt_dynamic_f("pipe-%s-%s",<br>
                                       kmstest_pipe_name(pipe), output->name) {<br>
-                               if (flags & (TEST_NONE | TEST_DPMS | TEST_SUSPEND | TEST_INVALID_HDR))<br>
+                               if (flags & (TEST_NONE | TEST_DPMS | TEST_SUSPEND |<br>
+                                            TEST_INVALID_HDR | TEST_BRIGHTNESS))<br>
                                         test_static_toggle(data, pipe, output, flags);<br>
                                 if (flags & TEST_SWAP)<br>
                                         test_static_swap(data, pipe, output);<br>
@@ -734,6 +811,10 @@ igt_main<br>
         igt_subtest_with_dynamic("static-toggle-suspend")<br>
                 test_hdr(&data, TEST_SUSPEND);<br>
 <br>
+       igt_describe("Tests brightness while entering and exiting HDR mode");<br>
+       igt_subtest_with_dynamic("brightness-with-hdr")<br>
+               test_hdr(&data, TEST_BRIGHTNESS);<br>
+<br>
         igt_describe("Tests swapping static HDR metadata");<br>
         igt_subtest_with_dynamic("static-swap")<br>
                 test_hdr(&data, TEST_SWAP);<br>
-- <br>
2.34.1<o:p></o:p></span></p>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
</div>
</body>
</html>