<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)">
<!--[if !mso]><style>v\:* {behavior:url(#default#VML);}
o\:* {behavior:url(#default#VML);}
w\:* {behavior:url(#default#VML);}
.shape {behavior:url(#default#VML);}
</style><![endif]--><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:0in;
        font-size:12.0pt;
        font-family:"Aptos",sans-serif;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
p.xmsonormal, li.xmsonormal, div.xmsonormal
        {mso-style-name:x_msonormal;
        margin:0in;
        font-size:12.0pt;
        font-family:"Aptos",sans-serif;}
span.EmailStyle23
        {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:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
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-US" link="blue" vlink="purple" style="word-wrap:break-word">
<div class="WordSection1">
<p class="MsoNormal"><span style="font-size:11.0pt"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt"><o:p> </o:p></span></p>
<div style="border:none;border-left:solid blue 1.5pt;padding:0in 0in 0in 4.0pt">
<div>
<div style="border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0in 0in 0in">
<p class="MsoNormal"><b><span style="font-size:11.0pt;font-family:"Calibri",sans-serif">From:</span></b><span style="font-size:11.0pt;font-family:"Calibri",sans-serif"> Reddy Guddati, Santhosh <santhosh.reddy.guddati@intel.com>
<br>
<b>Sent:</b> Wednesday, October 9, 2024 10:02 AM<br>
<b>To:</b> Kandpal, Suraj <suraj.kandpal@intel.com>; igt-dev@lists.freedesktop.org; Modem, Bhanuprakash <bhanuprakash.modem@intel.com><br>
<b>Cc:</b> Samala, Pranay <pranay.samala@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"><span style="color:black">++ Bhanu<br>
<br>
Hi Suraj,<br>
<br>
Thank you for your suggestion regarding code sharing via header file. I have tried to share across the test files unfortunately in the current igt  setup, we cannot re use with importing the header files.<br>
<br>
<a id="OWAAM179493" href="mailto:bhanuprakash.modem@intel.com"><span style="font-family:"Aptos",sans-serif;text-decoration:none">@Modem, Bhanuprakash</span></a>,<br>
<br>
Could you please help if these functions can be moved to lib/igt_sysfs or lib/igt_kms ?</span><o:p></o:p></p>
<p class="MsoNormal"><span style="font-size:11.0pt"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt">Or have a separate file in /lib<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt">Igt_brightness <o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:black"><br>
<br>
Thanks,<br>
Santhosh<o:p></o:p></span></p>
</div>
<div class="MsoNormal" align="center" style="text-align:center">
<hr size="2" width="98%" align="center">
</div>
<div id="divRplyFwdMsg">
<p class="MsoNormal"><b><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:black">From:</span></b><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:black"> Kandpal, Suraj <<a href="mailto:suraj.kandpal@intel.com">suraj.kandpal@intel.com</a>><br>
<b>Sent:</b> Friday, October 4, 2024 11:14 AM<br>
<b>To:</b> Reddy Guddati, Santhosh <<a href="mailto:santhosh.reddy.guddati@intel.com">santhosh.reddy.guddati@intel.com</a>>;
<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>
<b>Cc:</b> Samala, Pranay <<a href="mailto:pranay.samala@intel.com">pranay.samala@intel.com</a>><br>
<b>Subject:</b> Re: [PATCH i-g-t v3 1/1] tests/kms_hdr: Test brightness manipulation in HDR mode</span>
<o:p></o:p></p>
<div>
<p class="MsoNormal"> <o:p></o:p></p>
</div>
</div>
<div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div id="x_mail-editor-reference-message-container">
<p class="MsoNormal"><o:p> </o:p></p>
<div class="MsoNormal" align="center" style="text-align:center">
<hr size="2" width="98%" align="center">
</div>
<div id="x_divRplyFwdMsg">
<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>><br>
<strong><span style="font-family:"Aptos",sans-serif">Sent:</span></strong> Friday, October 4, 2024 11:02:42 am<br>
<strong><span style="font-family:"Aptos",sans-serif">To:</span></strong> Kandpal, Suraj <<a href="mailto:suraj.kandpal@intel.com">suraj.kandpal@intel.com</a>>;
<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>><br>
<strong><span style="font-family:"Aptos",sans-serif">Subject:</span></strong> RE: [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"><o:p> </o:p></p>
<div>
<p class="xmsonormal">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></p>
<p class="xmsonormal"> <o:p></o:p></p>
<p class="xmsonormal">Please provide your thoughts on this approach.<o:p></o:p></p>
<p class="xmsonormal">_____________<o:p></o:p></p>
<p class="xmsonormal"><o:p> </o:p></p>
<p class="xmsonormal">Why not just some simple code sharing via a header file rather than the whole lib/igt_sysfs complexity.<o:p></o:p></p>
<p class="xmsonormal"><o:p> </o:p></p>
<p class="xmsonormal">Regards,<br>
Suraj<br>
____________<br>
Regards,<br>
Santhosh<o:p></o:p></p>
<p class="xmsonormal"> <o:p></o:p></p>
<div>
<div style="border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0in 0in 0in">
<p class="xmsonormal"><b><span style="font-size:11.0pt;font-family:"Calibri",sans-serif">From:</span></b><span style="font-size:11.0pt;font-family:"Calibri",sans-serif"> Kandpal, Suraj <<a href="mailto:suraj.kandpal@intel.com">suraj.kandpal@intel.com</a>>
<br>
<b>Sent:</b> Friday, October 4, 2024 10:50 AM<br>
<b>To:</b> Reddy Guddati, Santhosh <<a href="mailto:santhosh.reddy.guddati@intel.com">santhosh.reddy.guddati@intel.com</a>>;
<a href="mailto:igt-dev@lists.freedesktop.org">igt-dev@lists.freedesktop.org</a><br>
<b>Cc:</b> Samala, Pranay <<a href="mailto:pranay.samala@intel.com">pranay.samala@intel.com</a>>; Reddy Guddati, Santhosh <<a href="mailto:santhosh.reddy.guddati@intel.com">santhosh.reddy.guddati@intel.com</a>><br>
<b>Subject:</b> Re: [PATCH i-g-t v3 1/1] tests/kms_hdr: Test brightness manipulation in HDR mode</span><o:p></o:p></p>
</div>
</div>
<p class="xmsonormal"> <o:p></o:p></p>
<div>
<p class="xmsonormal"><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"><span style="color:#467886">santhosh.reddy.guddati@intel.com</span></a>></span><o:p></o:p></p>
</div>
<div id="x_mail-editor-reference-message-container">
<div id="x_divRplyFwdMsg">
<p class="xmsonormal"><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">
<span style="color:#467886">igt-dev@lists.freedesktop.org</span></a> <<a href="mailto:igt-dev@lists.freedesktop.org"><span style="color:#467886">igt-dev@lists.freedesktop.org</span></a>><br>
<strong><span style="font-family:"Aptos",sans-serif">Cc:</span></strong> Samala, Pranay <<a href="mailto:pranay.samala@intel.com"><span style="color:#467886">pranay.samala@intel.com</span></a>>; Kandpal, Suraj <<a href="mailto:suraj.kandpal@intel.com"><span style="color:#467886">suraj.kandpal@intel.com</span></a>>;
 Reddy Guddati, Santhosh <<a href="mailto:santhosh.reddy.guddati@intel.com"><span style="color:#467886">santhosh.reddy.guddati@intel.com</span></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</span><o:p></o:p></p>
</div>
<p class="xmsonormal" style="margin-bottom:12.0pt"><o:p> </o:p></p>
<div>
<p class="xmsonormal"><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"><span style="color:#467886">santhosh.reddy.guddati@intel.com</span></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)</span><o:p></o:p></p>
</div>
<div>
<p class="xmsonormal"><span style="font-size:11.0pt"> </span><o:p></o:p></p>
</div>
<div>
<p class="xmsonormal"><span style="font-size:11.0pt">-----------------</span><o:p></o:p></p>
</div>
<div>
<p class="xmsonormal"><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</span><o:p></o:p></p>
</div>
<div>
<p class="xmsonormal"><span style="font-size:11.0pt"> </span><o:p></o:p></p>
</div>
<div>
<p class="xmsonormal"><span style="font-size:11.0pt">Regards,</span><o:p></o:p></p>
</div>
<div>
<p class="xmsonormal"><span style="font-size:11.0pt">Suraj Kandpal</span><o:p></o:p></p>
</div>
<div>
<p class="xmsonormal"><span style="font-size:11.0pt"> </span><o:p></o:p></p>
</div>
<div>
<p class="xmsonormal" 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</span><o:p></o:p></p>
</div>
<p class="xmsonormal"> <o:p></o:p></p>
</div>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
</div>
</div>
</div>
</body>
</html>