From patchwork Thu Mar 10 12:47:05 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lionel Landwerlin X-Patchwork-Id: 8557031 Return-Path: X-Original-To: patchwork-intel-gfx@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 1B5679F46A for ; Thu, 10 Mar 2016 12:47:31 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 1FAD220272 for ; Thu, 10 Mar 2016 12:47:30 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id B27A02026D for ; Thu, 10 Mar 2016 12:47:28 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 367226E239; Thu, 10 Mar 2016 12:47:25 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by gabe.freedesktop.org (Postfix) with ESMTP id 454F589916 for ; Thu, 10 Mar 2016 12:47:16 +0000 (UTC) Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga103.fm.intel.com with ESMTP; 10 Mar 2016 04:47:16 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.24,315,1455004800"; d="scan'208";a="761612161" Received: from tcohen10-mobl3.ger.corp.intel.com (HELO ivy.ger.corp.intel.com) ([10.252.47.123]) by orsmga003.jf.intel.com with ESMTP; 10 Mar 2016 04:47:14 -0800 From: Lionel Landwerlin To: intel-gfx@lists.freedesktop.org Date: Thu, 10 Mar 2016 12:47:05 +0000 Message-Id: <1457614025-22910-7-git-send-email-lionel.g.landwerlin@intel.com> X-Mailer: git-send-email 2.7.0 In-Reply-To: <1457614025-22910-1-git-send-email-lionel.g.landwerlin@intel.com> References: <1457614025-22910-1-git-send-email-lionel.g.landwerlin@intel.com> Subject: [Intel-gfx] [PATCH i-g-t 6/6] test/kms_pipe_color: add test to verify legacy ioctl resets GAMMA_LUT 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: , MIME-Version: 1.0 Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The GAMMA_LUT property must be updated when the legacy ioctl is triggered to ensure the new property does not impact older userspace code. Signed-off-by: Lionel Landwerlin Cc: Matt Roper Reviewed-by: Matt Roper --- tests/kms_pipe_color.c | 101 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 101 insertions(+) diff --git a/tests/kms_pipe_color.c b/tests/kms_pipe_color.c index 0241cf2..d17bf7f 100644 --- a/tests/kms_pipe_color.c +++ b/tests/kms_pipe_color.c @@ -516,6 +516,104 @@ static void test_pipe_legacy_gamma(data_t *data, free(blue_lut); } +static drmModePropertyBlobPtr +get_gamma_lut_blob(data_t *data, igt_pipe_t *pipe) +{ + uint64_t prop_value; + drmModePropertyPtr prop; + drmModePropertyBlobPtr blob; + + igt_assert(igt_pipe_get_property(pipe, "GAMMA_LUT", + NULL, &prop_value, &prop)); + igt_assert(prop->flags & DRM_MODE_PROP_BLOB); + + blob = drmModeGetPropertyBlob(data->drm_fd, prop_value); + + drmModeFreeProperty(prop); + + return blob; +} + +/* + * Verify that setting the legacy gamma LUT resets the gamma LUT set + * through the GAMMA_LUT property. + */ +static void test_pipe_legacy_gamma_reset(data_t *data, + igt_plane_t *primary) +{ + drmModeCrtc *kms_crtc; + double *gamma_zero; + uint32_t i, legacy_lut_size; + uint16_t *red_lut, *green_lut, *blue_lut; + struct _drm_color_lut *lut; + drmModePropertyBlobPtr blob; + igt_output_t *output; + + gamma_zero = malloc(sizeof(double) * data->gamma_lut_size); + for (i = 0; i < data->gamma_lut_size; i++) + gamma_zero[i] = 0.0; + + for_each_connected_output(&data->display, output) { + igt_output_set_pipe(output, primary->pipe->pipe); + + /* Set a gamma LUT using the property and verify the + * content of the property. */ + set_gamma(data, primary->pipe, gamma_zero); + igt_display_commit(&data->display); + + blob = get_gamma_lut_blob(data, primary->pipe); + igt_assert(blob && + blob->length == (sizeof(struct _drm_color_lut) * + data->gamma_lut_size)); + + lut = (struct _drm_color_lut *) blob->data; + for (i = 0; i < data->gamma_lut_size; i++) + igt_assert(lut[i].red == 0 && + lut[i].green == 0 && + lut[i].blue == 0); + + drmModeFreePropertyBlob(blob); + + /* Set a gamma LUT using the legacy ioctl and verify + * the content of the GAMMA_LUT property is + * changed. */ + kms_crtc = drmModeGetCrtc(data->drm_fd, primary->pipe->crtc_id); + legacy_lut_size = kms_crtc->gamma_size; + drmModeFreeCrtc(kms_crtc); + + red_lut = malloc(sizeof(uint16_t) * legacy_lut_size); + green_lut = malloc(sizeof(uint16_t) * legacy_lut_size); + blue_lut = malloc(sizeof(uint16_t) * legacy_lut_size); + + for (i = 0; i < legacy_lut_size; i++) + red_lut[i] = green_lut[i] = blue_lut[i] = 0xffff; + + igt_assert_eq(drmModeCrtcSetGamma(data->drm_fd, + primary->pipe->crtc_id, + legacy_lut_size, + red_lut, green_lut, blue_lut), + 0); + igt_display_commit(&data->display); + + blob = get_gamma_lut_blob(data, primary->pipe); + igt_assert(blob && + blob->length == (sizeof(struct _drm_color_lut) * + legacy_lut_size)); + + lut = (struct _drm_color_lut *) blob->data; + for (i = 0; i < legacy_lut_size; i++) + igt_assert(lut[i].red == 0xffff && + lut[i].green == 0xffff && + lut[i].blue == 0xffff); + + drmModeFreePropertyBlob(blob); + + igt_output_set_pipe(output, PIPE_ANY); + } + + free(gamma_zero); +} + /* * Draw 3 rectangles using before colors with the ctm matrix apply and verify * the CRC is equal to using after colors with an identify ctm matrix. @@ -894,6 +992,9 @@ run_tests_for_pipe(data_t *data, enum pipe p) igt_subtest_f("legacy-gamma-pipe%d", p) test_pipe_legacy_gamma(data, primary); + igt_subtest_f("legacy-gamma-reset-pipe%d", p) + test_pipe_legacy_gamma_reset(data, primary); + igt_fixture { for_each_connected_output(&data->display, output) output_set_property_enum(output, "Broadcast RGB", "Full");