<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css" style="display:none;"> P {margin-top:0;margin-bottom:0;} </style>
</head>
<body dir="ltr">
<div class="elementToProof" style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Hi Kamil,</div>
<div id="appendonsend"></div>
<div style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<hr style="display: inline-block; width: 98%;">
<div id="divRplyFwdMsg" dir="ltr"><span style="font-family: Calibri, sans-serif; font-size: 11pt; color: rgb(0, 0, 0);"><b>From:</b> Kamil Konieczny <kamil.konieczny@linux.intel.com><br>
<b>Sent:</b> Friday, December 6, 2024 10:48 PM<br>
<b>To:</b> Reddy Guddati, Santhosh <santhosh.reddy.guddati@intel.com><br>
<b>Cc:</b> igt-dev@lists.freedesktop.org <igt-dev@lists.freedesktop.org>; Kandpal, Suraj <suraj.kandpal@intel.com>; Nautiyal, Ankit K <ankit.k.nautiyal@intel.com>; Thasleem, Mohammed <mohammed.thasleem@intel.com><br>
<b>Subject:</b> Re: [PATCH i-g-t v1] tools/intel_hdcp: Introduce intel_hdcp tool</span>
<div> </div>
</div>
<div class="elementToProof" style="font-size: 11pt;">Hi Santhosh,<br>
On 2024-12-04 at 15:26:54 +0530, Santhosh Reddy Guddati wrote:<br>
> Add a new HDCP tool for self-testing and easy deployment<br>
> to client machines. This tool helps diagnose issues,<br>
> determining whether the problem lies in the driver or user space.<br>
><br>
> The current changes include tool skeleton and get hdcp info<br>
> on the connected outputs.<br>
><br>
> Signed-off-by: Santhosh Reddy Guddati <santhosh.reddy.guddati@intel.com><br>
> ---<br>
>  tools/intel_hdcp.c | 203 +++++++++++++++++++++++++++++++++++++++++++++<br>
>  tools/meson.build  |   1 +<br>
>  2 files changed, 204 insertions(+)<br>
>  create mode 100644 tools/intel_hdcp.c<br>
><br>
> diff --git a/tools/intel_hdcp.c b/tools/intel_hdcp.c<br>
> new file mode 100644<br>
> index 000000000..8c0258092<br>
> --- /dev/null<br>
> +++ b/tools/intel_hdcp.c<br>
> @@ -0,0 +1,203 @@<br>
> +/*<br>
> + * Copyright © 2024 Intel Corporation<br>
> + *<br>
> + * Permission is hereby granted, free of charge, to any person obtaining a<br>
<br>
Use SPDX, see other recent C files.<br>
<br>
> + * copy of this software and associated documentation files (the "Software"),<br>
> + * to deal in the Software without restriction, including without limitation<br>
> + * the rights to use, copy, modify, merge, publish, distribute, sublicense,<br>
> + * and/or sell copies of the Software, and to permit persons to whom the<br>
> + * Software is furnished to do so, subject to the following conditions:<br>
> + *<br>
> + * The above copyright notice and this permission notice (including the next<br>
> + * paragraph) shall be included in all copies or substantial portions of the<br>
> + * Software.<br>
> + *<br>
> + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR<br>
> + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,<br>
> + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL<br>
> + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER<br>
> + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING<br>
> + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER<br>
> + * DEALINGS IN THE SOFTWARE.<br>
> + *<br>
> + * This tool designed to mimic an HDCP video player, capable of performing<br>
> + * self-tests and easily deployable to client machines. This tool helps identify<br>
> + * whether issues are rooted in the driver or user space.<br>
> + *<br>
> + */<br>
> +<br>
> +#include <stdio.h><br>
> +#include "igt.h"<br>
> +#include <fcntl.h><br>
<br>
Sort alphabetically, first system headers, then igt so:<br>
<br>
#include <fcntl.h><br>
#include <stdio.h><br>
<br>
#include "igt.h"<br>
<br>
Btw are you sure to include igt.h here?</div>
<div class="elementToProof" style="font-size: 11pt;"><br>
</div>
<div class="elementToProof" style="font-size: 11pt;">We need this to use the igt defintions here to stay consistent with the other tools in the igt_gpu_<span style="color: rgb(0, 0, 0);">tools repository, We are using the igt_* functions in the existing tools
 like </span></div>
<div class="elementToProof" style="font-size: 11pt;">Igt_dp_compliance, igt_reg etc. <br>
<br>
Please let me know your thoughts or if my understanding is incorrect.<br>
> +<br>
> +#define MAX_HDCP_BUF_LEN     5000<br>
> +<br>
> +typedef struct data {<br>
> +     int fd;<br>
> +     igt_display_t display;<br>
> +     struct igt_fb red, green;<br>
> +     int height, width;<br>
> +} data_t;<br>
> +<br>
> +<br>
> +/* TODO: Implement the actual HDCP enabling logic here<br>
> + * Steps:<br>
> + * 1. Open the appropriate debugfs file for the connector.<br>
> + * 2. Enable HDCP on the output using connector properties<br>
> + *    IGT_CONNECTOR_CONTENT_PROTECTION and IGT_CONNECTOR_HDCP_CONTENT_TYPE.<br>
> + * 3. Check the status to ensure HDCP is enabled.<br>
> + */<br>
> +static void enable_hdcp(void)<br>
> +{<br>
> +     igt_debug("TODO: Enable HDCP\n");<br>
<br>
Tools is not a test, so maybe just fprintf(stderr, ...)<br>
<br>
> +}<br>
> +<br>
> +/* TODO: Implement the actual HDCP disabling logic here */<br>
> +static void disable_hdcp(void)<br>
> +{<br>
> +     igt_debug("TODO: Disable HDCP\n");<br>
<br>
Same here.<br>
<br>
> +}<br>
> +<br>
> +static bool sink_hdcp2_capable(data_t *data, igt_output_t *output)<br>
> +{<br>
> +     char buf[MAX_HDCP_BUF_LEN];<br>
> +     int fd;<br>
> +<br>
> +     fd = igt_debugfs_connector_dir(data->fd, output->name, O_RDONLY);<br>
<br>
You are using igt lib function here, make sure it will not assert.<br>
<br>
> +     if (fd < 0)<br>
> +             return false;<br>
> +<br>
> +     if (is_intel_device(data->fd))<br>
> +             igt_debugfs_simple_read(fd, "i915_hdcp_sink_capability", buf, sizeof(buf));<br>
<br>
Same here, using igt lib function intended for tests<br>
can bring an assert, it is no expected in a tool.</div>
<div class="elementToProof" style="font-size: 11pt;"><br>
</div>
<div class="elementToProof" style="font-size: 11pt;"><br>
<br>
> +     else<br>
> +             igt_debugfs_simple_read(fd, "hdcp_sink_capability", buf, sizeof(buf));<br>
<br>
Same here.<br>
<br>
> +<br>
> +     close(fd);<br>
> +<br>
> +     igt_debug("Sink capability: %s\n", buf);<br>
> +     return strstr(buf, "HDCP2.2");<br>
> +}<br>
> +<br>
> +static bool sink_hdcp_capable(data_t *data, igt_output_t *output)<br>
> +{<br>
> +     char buf[MAX_HDCP_BUF_LEN];<br>
> +     int fd;<br>
> +<br>
> +     fd = igt_debugfs_connector_dir(data->fd, output->name, O_RDONLY);<br>
<br>
Same here.<br>
<br>
> +     if (fd < 0)<br>
> +             return false;<br>
> +<br>
> +     if (is_intel_device(data->fd))<br>
> +             igt_debugfs_simple_read(fd, "i915_hdcp_sink_capability", buf, sizeof(buf));<br>
<br>
Same here.<br>
<br>
> +     else<br>
> +             igt_debugfs_simple_read(fd, "hdcp_sink_capability", buf, sizeof(buf));<br>
<br>
Same here.<br>
<br>
> +<br>
> +     close(fd);<br>
> +<br>
> +     igt_debug("Sink capability: %s\n", buf);<br>
> +     return strstr(buf, "HDCP1.4");<br>
> +}<br>
> +<br>
> +static const char *get_hdcp_version(igt_output_t *output, data_t *data)<br>
> +{<br>
> +     if (sink_hdcp2_capable(data, output))<br>
> +             return "HDCP 2.2";<br>
> +     else if (sink_hdcp_capable(data, output))<br>
> +             return "HDCP 1.4";<br>
> +     else<br>
> +             return "No HDCP support";<br>
> +}<br>
> +<br>
> +static void get_hdcp_info(data_t *data)<br>
> +{<br>
> +     igt_output_t *output;<br>
> +     igt_display_t *display = &data->display;<br>
> +<br>
> +     igt_info("\nHDCP Sink Information\n");<br>
> +     for_each_connected_output(display, output) {<br>
> +             igt_info("Output: %s\tHDCP Supported Version: %s\n",<br>
> +                       igt_output_name(output), get_hdcp_version(output, data));<br>
> +     }<br>
> +}<br>
> +<br>
> +static void print_usage(void)<br>
> +{<br>
> +     igt_info("Usage: intel_hdcp [OPTIONS]\n");<br>
<br>
Same here, imho better just printf() here.<br>
> +     igt_info("Options:\n");<br>
> +     igt_info("-i,   --info          Get HDCP Information\n");<br>
> +     igt_info("-e,   --enable        Enable HDCP on the output\n");<br>
> +     igt_info("-d,   --disable       Disable HDCP on the specific output\n");<br>
> +     igt_info("-h,   --help          Display this help message\n");<br>
> +}<br>
> +<br>
> +static void create_frame_buffers(int fd, data_t *data)<br>
> +{<br>
> +     igt_output_t *output;<br>
> +     drmModeModeInfo *mode;<br>
> +     uint16_t width, height;<br>
> +     igt_display_t *display = &data->display;<br>
> +<br>
> +     for_each_connected_output(display, output) {<br>
> +             mode = igt_output_get_mode(output);<br>
> +             igt_assert(mode);<br>
> +<br>
> +             width = mode->hdisplay;<br>
> +             height = mode->vdisplay;<br>
> +     }<br>
> +<br>
> +     data->width = width;<br>
> +     data->height = height;<br>
> +<br>
> +     igt_create_color_fb(data->fd, width, height,<br>
> +                         DRM_FORMAT_XRGB8888, DRM_FORMAT_MOD_LINEAR,<br>
> +                         1.f, 0.f, 0.f, &data->red);<br>
> +     igt_create_color_fb(data->fd, width, height,<br>
> +                         DRM_FORMAT_XRGB8888, DRM_FORMAT_MOD_LINEAR,<br>
> +                         0.f, 1.f, 0.f, &data->green);<br>
> +}<br>
> +<br>
> +static void hdcp_init(data_t *data)<br>
> +{<br>
> +     data->fd = drm_open_driver_master(DRIVER_ANY);<br>
<br>
Imho you should do an open yourself.<br>
<br>
> +     if (data->fd < 0) {<br>
> +             fprintf(stderr, "Failed to open DRM driver\n");<br>
> +             exit(EXIT_FAILURE);<br>
> +     }<br>
> +     igt_display_require(&data->display, data->fd);<br>
<br>
You are not in test, you cannot 'require' a display in a tool,<br>
imho you should inform user that no displays were found and<br>
just exit, no igt SKIPs.</div>
<div class="elementToProof" style="font-size: 11pt;"><br>
</div>
<div class="elementToProof" style="text-align: left; text-indent: 0px; margin: 0px; font-family: "Segoe UI Web (West European)", "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, "Helvetica Neue", sans-serif; font-size: 11pt; color: rgb(0, 0, 0);">
We need this to use the igt defintions here to stay consistent with the other tools in the igt_gpu_tools repository, We are using the igt_* functions in the existing tools like </div>
<div style="text-align: left; text-indent: 0px; margin: 0px; font-family: "Segoe UI Web (West European)", "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, "Helvetica Neue", sans-serif; font-size: 11pt; color: rgb(0, 0, 0);">
Igt_dp_compliance, igt_reg etc. </div>
<div class="elementToProof" style="font-size: 11pt;"><br>
</div>
<div class="elementToProof" style="font-size: 11pt;"><br>
Regards,<br>
Kamil<br>
<br>
> +     igt_display_require_output(&data->display);<br>
> +     create_frame_buffers(data->fd, data);<br>
> +}<br>
> +<br>
> +int main(int argc, char **argv)<br>
> +{<br>
> +     data_t data;<br>
> +     int option;<br>
> +     static const char optstr[] = "hied";<br>
> +     struct option long_opts[] = {<br>
> +             {"help",        no_argument,    NULL, 'h'},<br>
> +             {"info",        no_argument,    NULL, 'i'},<br>
> +             {"enable",      no_argument,    NULL, 'e'},<br>
> +             {"disable",     no_argument,    NULL, 'd'},<br>
> +             {NULL,          0,              NULL,  0 }<br>
> +     };<br>
> +<br>
> +     hdcp_init(&data);<br>
> +<br>
> +     while ((option = getopt_long(argc, argv, optstr, long_opts, NULL)) != -1) {<br>
> +             switch (option) {<br>
> +             case 'i':<br>
> +                     get_hdcp_info(&data);<br>
> +                     break;<br>
> +             case 'e':<br>
> +                     enable_hdcp();<br>
> +                     break;<br>
> +             case 'd':<br>
> +                     disable_hdcp();<br>
> +                     break;<br>
> +             case 'h':<br>
> +             default:<br>
> +                     print_usage();<br>
> +                     break;<br>
> +             }<br>
> +     }<br>
> +}<br>
> diff --git a/tools/meson.build b/tools/meson.build<br>
> index 48c9a4b50..8e24005eb 100644<br>
> --- a/tools/meson.build<br>
> +++ b/tools/meson.build<br>
> @@ -27,6 +27,7 @@ tools_progs = [<br>
>        'intel_gpu_time',<br>
>        'intel_gtt',<br>
>        'intel_guc_logger',<br>
> +     'intel_hdcp',<br>
>        'intel_infoframes',<br>
>        'intel_lid',<br>
>        'intel_opregion_decode',<br>
> --<br>
> 2.34.1<br>
></div>
</body>
</html>