From patchwork Thu Dec 7 00:17:37 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Sean Paul X-Patchwork-Id: 10097479 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id E453460327 for ; Thu, 7 Dec 2017 00:17:44 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D5C1229B65 for ; Thu, 7 Dec 2017 00:17:44 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CA35A29F7C; Thu, 7 Dec 2017 00:17:44 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id C459729B65 for ; Thu, 7 Dec 2017 00:17:43 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 4113D898C4; Thu, 7 Dec 2017 00:17:43 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mail-yb0-x244.google.com (mail-yb0-x244.google.com [IPv6:2607:f8b0:4002:c09::244]) by gabe.freedesktop.org (Postfix) with ESMTPS id 6E7BF89873 for ; Thu, 7 Dec 2017 00:17:40 +0000 (UTC) Received: by mail-yb0-x244.google.com with SMTP id z62so2306196yba.11 for ; Wed, 06 Dec 2017 16:17:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=WGeqD4dimx3Zuh+0IxJOCgEPEdetSqHsZQ/5Bj+f6Ho=; b=SWxxslb8tDzOxhs+7CLzgfBRbmW/2MP4+kMBOilLP4XJwgXmK4+1AYZzYfeFrA4lPw Itd4cU26HKfUL7c0bz3AZvQRUmMzC02a4ucGw2VYOc62X8/LuJXdNzvknOc26d8C3jHv ABEGQSjxMaZpjGeezPEjzGAFgK2R4Ktf0Nj54= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=WGeqD4dimx3Zuh+0IxJOCgEPEdetSqHsZQ/5Bj+f6Ho=; b=Bd8qb7CTeuII1mX7PHtoTsec4B7dTwUtB7MNBQ+WJFvk7Hfo9I+5cQI546Ry4a+6tN rFc9uXcVNrqiIBX1ibEZTWFqicoY0S+4EjTWkZBEjk0U2urVSame/2I8RJcHKTux7Q6U ZO3YYlHBNLg4MdbcS5epSMVr6xy0/ymCMtsH7/Fz4+Y2Tkks76a8Fw1/CqypUOgOXKsu hqU8PiARnoVL4O+j/ieHDM8iyhNFqahR8xKa0oaZyb6np4c/zXDcZ/gcFqHafOY3HIKm sAWJQV4bGMQWj+BIwE05sHnDphDiW+v0E7NQTUhBnkVWsMtH0NlAcCj8gxX1JUm5Kznk KtLw== X-Gm-Message-State: AJaThX51Ujz9hawm7jTeYaqp9AzTesusTu72vXpQp75Ixa/0Fbw+0tKP vs/osIr4dmTfzYuAACgkNdSY7ogK2F4= X-Google-Smtp-Source: AGs4zMZtVIKcJVvpheJ9GLAmEtrJvdDIS5SEPQuNFoz9YHtrqDY/25bVMcCKAo4s2DlqhwdMkSicjA== X-Received: by 10.37.116.130 with SMTP id p124mr16601356ybc.286.1512605859528; Wed, 06 Dec 2017 16:17:39 -0800 (PST) Received: from rosewood.cam.corp.google.com ([2620:0:1013:11:d3af:69ac:1964:28e8]) by smtp.gmail.com with ESMTPSA id t206sm1874296ywa.74.2017.12.06.16.17.38 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 06 Dec 2017 16:17:38 -0800 (PST) From: Sean Paul To: intel-gfx@lists.freedesktop.org Date: Wed, 6 Dec 2017 19:17:37 -0500 Message-Id: <20171207001737.48696-2-seanpaul@chromium.org> X-Mailer: git-send-email 2.15.1.424.g9478a66081-goog In-Reply-To: <20171207001737.48696-1-seanpaul@chromium.org> References: <20171207001737.48696-1-seanpaul@chromium.org> MIME-Version: 1.0 Cc: seanpaul@google.com Subject: [Intel-gfx] [PATCH v2 2/2] kms_content_protection: Add Content Protection test X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Virus-Scanned: ClamAV using ClamSMTP Pretty simple test: - initializes the output - clears the content protection property - verifies that it clears - sets the content protection property to desired - verifies that it transitions to enabled Does this for both legacy and atomic. Changes in v2: - Don't check for i915 gen - Skip test if Content Protection property is absent Signed-off-by: Sean Paul --- lib/igt_kms.c | 3 +- lib/igt_kms.h | 1 + tests/Makefile.sources | 1 + tests/kms_content_protection.c | 129 +++++++++++++++++++++++++++++++++++++++++ tests/meson.build | 1 + 5 files changed, 134 insertions(+), 1 deletion(-) create mode 100644 tests/kms_content_protection.c diff --git a/lib/igt_kms.c b/lib/igt_kms.c index 125ecb19..907db694 100644 --- a/lib/igt_kms.c +++ b/lib/igt_kms.c @@ -190,7 +190,8 @@ const char *igt_connector_prop_names[IGT_NUM_CONNECTOR_PROPS] = { "scaling mode", "CRTC_ID", "DPMS", - "Broadcast RGB" + "Broadcast RGB", + "Content Protection" }; /* diff --git a/lib/igt_kms.h b/lib/igt_kms.h index 2a480bf3..93e59dc7 100644 --- a/lib/igt_kms.h +++ b/lib/igt_kms.h @@ -118,6 +118,7 @@ enum igt_atomic_connector_properties { IGT_CONNECTOR_CRTC_ID, IGT_CONNECTOR_DPMS, IGT_CONNECTOR_BROADCAST_RGB, + IGT_CONNECTOR_CONTENT_PROTECTION, IGT_NUM_CONNECTOR_PROPS }; diff --git a/tests/Makefile.sources b/tests/Makefile.sources index 34ca71a0..e0466411 100644 --- a/tests/Makefile.sources +++ b/tests/Makefile.sources @@ -179,6 +179,7 @@ TESTS_progs = \ kms_chv_cursor_fail \ kms_color \ kms_concurrent \ + kms_content_protection\ kms_crtc_background_color \ kms_cursor_crc \ kms_cursor_legacy \ diff --git a/tests/kms_content_protection.c b/tests/kms_content_protection.c new file mode 100644 index 00000000..5d61b257 --- /dev/null +++ b/tests/kms_content_protection.c @@ -0,0 +1,129 @@ +/* + * Copyright © 2017 Google, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS + * IN THE SOFTWARE. + * + */ + +#include "igt.h" + +IGT_TEST_DESCRIPTION("Test content protection (HDCP)"); + +typedef struct { + int drm_fd; + igt_display_t display; +} data_t; + +static bool +wait_for_prop_value(igt_output_t *output, uint64_t expected) +{ + uint64_t val; + int i; + + for (i = 0; i < 2000; i++) { + val = igt_output_get_prop(output, + IGT_CONNECTOR_CONTENT_PROTECTION); + if (val == expected) + return true; + usleep(1000); + } + igt_info("prop_value mismatch %ld != %ld\n", val, expected); + return false; +} + +static void +test_pipe_output(igt_display_t *display, const enum pipe pipe, + igt_output_t *output, enum igt_commit_style s) +{ + drmModeModeInfo mode; + igt_plane_t *primary; + struct igt_fb red; + bool ret; + + igt_assert(kmstest_get_connector_default_mode( + display->drm_fd, output->config.connector, &mode)); + + igt_output_override_mode(output, &mode); + igt_output_set_pipe(output, pipe); + + igt_create_color_fb(display->drm_fd, mode.hdisplay, mode.vdisplay, + DRM_FORMAT_XRGB8888, LOCAL_DRM_FORMAT_MOD_NONE, + 1.f, 0.f, 0.f, &red); + primary = igt_output_get_plane_type(output, DRM_PLANE_TYPE_PRIMARY); + igt_plane_set_fb(primary, &red); + igt_display_commit2(display, s); + + igt_output_set_prop_value(output, IGT_CONNECTOR_CONTENT_PROTECTION, 0); + igt_display_commit2(display, s); + + ret = wait_for_prop_value(output, 0); + igt_require_f(ret, "Content Protection not cleared\n"); + + igt_output_set_prop_value(output, IGT_CONNECTOR_CONTENT_PROTECTION, 1); + igt_display_commit2(display, s); + + ret = wait_for_prop_value(output, 2); + igt_require_f(ret, "Content Protection not enabled\n"); + + igt_plane_set_fb(primary, NULL); + igt_output_set_pipe(output, PIPE_NONE); +} + +static void +test_content_protection(igt_display_t *display, enum igt_commit_style s) +{ + igt_output_t *output; + enum pipe pipe; + int valid_tests = 0; + + for_each_pipe_with_valid_output(display, pipe, output) { + if (!output->props[IGT_CONNECTOR_CONTENT_PROTECTION]) + continue; + + test_pipe_output(display, pipe, output, s); + valid_tests++; + } + igt_require_f(valid_tests, "no support for content proteciton found\n"); +} + +igt_main +{ + data_t data = {}; + + igt_fixture { + igt_skip_on_simulation(); + + data.drm_fd = drm_open_driver(DRIVER_ANY); + + igt_display_init(&data.display, data.drm_fd); + } + + + igt_subtest("legacy") + test_content_protection(&data.display, COMMIT_LEGACY); + + igt_subtest("atomic") { + igt_require(data.display.is_atomic); + test_content_protection(&data.display, COMMIT_ATOMIC); + } + + igt_fixture + igt_display_fini(&data.display); +} diff --git a/tests/meson.build b/tests/meson.build index 59ccd9a6..b12c35c0 100644 --- a/tests/meson.build +++ b/tests/meson.build @@ -157,6 +157,7 @@ test_progs = [ 'kms_chv_cursor_fail', 'kms_color', 'kms_concurrent', + 'kms_content_protection', 'kms_crtc_background_color', 'kms_cursor_crc', 'kms_cursor_legacy',