From: Daniel Vetter <daniel@ffwll.ch>
To: Ramalingam C <ramalingam.c@intel.com>
Cc: igt-dev@lists.freedesktop.org, daniel.vetter@intel.com
Subject: Re: [igt-dev] [PATCH i-g-t v5 4/6] kms_content_protection: uevent for HDCP status change
Date: Mon, 29 Apr 2019 17:17:18 +0200 [thread overview]
Message-ID: <20190429151718.GP3271@phenom.ffwll.local> (raw)
In-Reply-To: <20190418084842.5422-5-ramalingam.c@intel.com>
On Thu, Apr 18, 2019 at 02:18:40PM +0530, Ramalingam C wrote:
> To detect the HDCP status change we are reading the uevent sent with the
> corresponding connector id and property id.
>
> This avoids the polling of the property every mSec.
>
> Signed-off-by: Ramalingam C <ramalingam.c@intel.com>
We have a lot of kernels without the uevent. Given that I think we need a
new subtest for this, so that existing tests keep working on existing
kernels. So another test flag to control this.
Otherwise looks good, you already have the retry loop for udev events
(which is somehow needed, because netlink sometimes takes forever to
deliver an event).
-Daniel
> ---
> tests/kms_content_protection.c | 152 +++++++++++++++++++++++++++++++--
> 1 file changed, 144 insertions(+), 8 deletions(-)
>
> diff --git a/tests/kms_content_protection.c b/tests/kms_content_protection.c
> index 754ce996640d..48f89571dcff 100644
> --- a/tests/kms_content_protection.c
> +++ b/tests/kms_content_protection.c
> @@ -24,6 +24,9 @@
>
> #include <poll.h>
> #include <fcntl.h>
> +#include <sys/epoll.h>
> +#include <sys/stat.h>
> +#include <libudev.h>
> #include "igt.h"
> #include "igt_sysfs.h"
> #include "igt_kms.h"
> @@ -95,20 +98,153 @@ static int wait_flip_event(void)
> return rc;
> }
>
> +static bool hdcp_event(struct udev_monitor *uevent_monitor,
> + struct udev *udev, uint32_t conn_id, uint32_t prop_id)
> +{
> + struct udev_device *dev;
> + dev_t udev_devnum;
> + struct stat s;
> + const char *hotplug, *connector, *property;
> + bool ret = false;
> +
> + dev = udev_monitor_receive_device(uevent_monitor);
> + if (!dev)
> + goto out;
> +
> + udev_devnum = udev_device_get_devnum(dev);
> + fstat(data.display.drm_fd, &s);
> +
> + hotplug = udev_device_get_property_value(dev, "HOTPLUG");
> + if (!(memcmp(&s.st_rdev, &udev_devnum, sizeof(dev_t)) == 0 &&
> + hotplug && atoi(hotplug) == 1)) {
> + igt_debug("Not a Hotplug event\n");
> + goto out_dev;
> + }
> +
> + connector = udev_device_get_property_value(dev, "CONNECTOR");
> + if (!(memcmp(&s.st_rdev, &udev_devnum, sizeof(dev_t)) == 0 &&
> + connector && atoi(connector) == conn_id)) {
> + igt_debug("Not for connector id: %u\n", conn_id);
> + goto out_dev;
> + }
> +
> + property = udev_device_get_property_value(dev, "PROPERTY");
> + if (!(memcmp(&s.st_rdev, &udev_devnum, sizeof(dev_t)) == 0 &&
> + property && atoi(property) == prop_id)) {
> + igt_debug("Not for property id: %u\n", prop_id);
> + goto out_dev;
> + }
> + ret = true;
> +
> +out_dev:
> + udev_device_unref(dev);
> +out:
> + return ret;
> +}
> +
> +static void hdcp_udev_fini(struct udev_monitor *uevent_monitor,
> + struct udev *udev)
> +{
> + if (uevent_monitor)
> + udev_monitor_unref(uevent_monitor);
> + if (udev)
> + udev_unref(udev);
> +}
> +
> +static int hdcp_udev_init(struct udev_monitor *uevent_monitor,
> + struct udev *udev)
> +{
> + int ret = -EINVAL;
> +
> + udev = udev_new();
> + if (!udev) {
> + igt_info("failed to create udev object\n");
> + goto out;
> + }
> +
> + uevent_monitor = udev_monitor_new_from_netlink(udev, "udev");
> + if (!uevent_monitor) {
> + igt_info("failed to create udev event monitor\n");
> + goto out;
> + }
> +
> + ret = udev_monitor_filter_add_match_subsystem_devtype(uevent_monitor,
> + "drm",
> + "drm_minor");
> + if (ret < 0) {
> + igt_info("failed to filter for drm events\n");
> + goto out;
> + }
> +
> + ret = udev_monitor_enable_receiving(uevent_monitor);
> + if (ret < 0) {
> + igt_info("failed to enable udev event reception\n");
> + goto out;
> + }
> +
> + return udev_monitor_get_fd(uevent_monitor);
> +
> +out:
> + hdcp_udev_fini(uevent_monitor, udev);
> + return ret;
> +}
> +
> +#define MAX_EVENTS 10
> +static bool wait_for_hdcp_event(uint32_t conn_id, uint32_t prop_id,
> + uint32_t timeout_mSec)
> +{
> +
> + struct udev_monitor *uevent_monitor = NULL;
> + struct udev *udev = NULL;
> + int udev_fd, epoll_fd;
> + struct epoll_event event, events[MAX_EVENTS];
> + bool ret = false;
> +
> + udev_fd = hdcp_udev_init(uevent_monitor, udev);
> + if (udev_fd < 0)
> + return false;
> +
> + epoll_fd = epoll_create1(0);
> + if (epoll_fd == -1) {
> + igt_info("Failed to create epoll fd. %d\n", epoll_fd);
> + goto out_ep_create;
> + }
> +
> + event.events = EPOLLIN | EPOLLERR;
> + event.data.fd = 0;
> +
> + if (epoll_ctl(epoll_fd, EPOLL_CTL_ADD, udev_fd, &event))
> + {
> + igt_info("failed to fd into epoll\n");
> + goto out_ep_ctl;
> + }
> +
> + if (epoll_wait(epoll_fd, events, MAX_EVENTS, timeout_mSec))
> + ret = hdcp_event(uevent_monitor, udev, conn_id, prop_id);
> +
> +out_ep_ctl:
> + if (close(epoll_fd))
> + igt_info("failed to close the epoll fd\n");
> +out_ep_create:
> + hdcp_udev_fini(uevent_monitor, udev);
> + return ret;
> +}
> +
> static bool
> wait_for_prop_value(igt_output_t *output, uint64_t expected,
> uint32_t timeout_mSec)
> {
> uint64_t val;
> - int i;
>
> - for (i = 0; i < timeout_mSec; i++) {
> - val = igt_output_get_prop(output,
> - IGT_CONNECTOR_CONTENT_PROTECTION);
> - if (val == expected)
> - return true;
> - usleep(1000);
> - }
> + if (wait_for_hdcp_event(output->id,
> + output->props[IGT_CONNECTOR_CONTENT_PROTECTION],
> + timeout_mSec))
> + igt_debug("hdcp event received\n");
> +
> + val = igt_output_get_prop(output, IGT_CONNECTOR_CONTENT_PROTECTION);
> + if (val == expected)
> + return true;
> +
> igt_info("prop_value mismatch %" PRId64 " != %" PRId64 "\n",
> val, expected);
>
> --
> 2.19.1
>
> _______________________________________________
> igt-dev mailing list
> igt-dev@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/igt-dev
--
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev
next prev parent reply other threads:[~2019-04-29 15:17 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-04-18 8:48 [igt-dev] [PATCH i-g-t v5 0/6] HDCP2.2 Tests Ramalingam C
2019-04-18 8:48 ` [igt-dev] [PATCH i-g-t v5 1/6] kms_content_protection: Content type support Ramalingam C
2019-04-18 8:48 ` [igt-dev] [PATCH i-g-t v5 2/6] kms_content_protection: test teardown and rebuild of I915-mei I/F Ramalingam C
2019-04-18 8:48 ` [igt-dev] [PATCH i-g-t v5 3/6] kms_content_protection: test content type change Ramalingam C
2019-04-29 14:40 ` Daniel Vetter
2019-04-30 12:41 ` Ramalingam C
2019-04-18 8:48 ` [igt-dev] [PATCH i-g-t v5 4/6] kms_content_protection: uevent for HDCP status change Ramalingam C
2019-04-29 15:17 ` Daniel Vetter [this message]
2019-04-18 8:48 ` [igt-dev] [PATCH i-g-t v5 5/6] kms_content_protection: srm and topology_info test Ramalingam C
2019-04-29 15:24 ` Daniel Vetter
2019-04-30 12:33 ` Ramalingam C
2019-04-18 8:48 ` [igt-dev] [PATCH i-g-t v5 6/6] DO NOT MERGE: CP in fast feedback list Ramalingam C
2019-04-18 9:54 ` [igt-dev] ✓ Fi.CI.BAT: success for HDCP2.2 Tests (rev5) Patchwork
2019-04-18 11:38 ` [igt-dev] ✓ Fi.CI.IGT: " Patchwork
2019-04-29 15:24 ` [igt-dev] [PATCH i-g-t v5 0/6] HDCP2.2 Tests Daniel Vetter
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=20190429151718.GP3271@phenom.ffwll.local \
--to=daniel@ffwll.ch \
--cc=daniel.vetter@intel.com \
--cc=igt-dev@lists.freedesktop.org \
--cc=ramalingam.c@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