From patchwork Mon Nov 15 09:47:46 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Modem, Bhanuprakash" X-Patchwork-Id: 12619183 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B04E6C4332F for ; Mon, 15 Nov 2021 09:50:25 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 779A6615E1 for ; Mon, 15 Nov 2021 09:50:25 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 779A6615E1 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=intel.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 24BB26EC05; Mon, 15 Nov 2021 09:50:24 +0000 (UTC) Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by gabe.freedesktop.org (Postfix) with ESMTPS id 8DF666EC13; Mon, 15 Nov 2021 09:50:23 +0000 (UTC) X-IronPort-AV: E=McAfee;i="6200,9189,10168"; a="232133761" X-IronPort-AV: E=Sophos;i="5.87,236,1631602800"; d="scan'208";a="232133761" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Nov 2021 01:50:23 -0800 X-IronPort-AV: E=Sophos;i="5.87,236,1631602800"; d="scan'208";a="535446936" Received: from bhanu-nuclab.iind.intel.com ([10.145.162.173]) by orsmga001-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Nov 2021 01:50:21 -0800 From: Bhanuprakash Modem To: igt-dev@lists.freedesktop.org, dri-devel@lists.freedesktop.org Subject: [i-g-t 01/14] HAX: Get uapi headers to compile the IGT Date: Mon, 15 Nov 2021 15:17:46 +0530 Message-Id: <20211115094759.520955-2-bhanuprakash.modem@intel.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20211115094759.520955-1-bhanuprakash.modem@intel.com> References: <20211115094759.520955-1-bhanuprakash.modem@intel.com> MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Bhanuprakash Modem Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Signed-off-by: Bhanuprakash Modem --- include/drm-uapi/drm.h | 10 ++++++++++ include/drm-uapi/drm_mode.h | 28 ++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+) diff --git a/include/drm-uapi/drm.h b/include/drm-uapi/drm.h index 5e54c3aa4c..9ca3dbe8e5 100644 --- a/include/drm-uapi/drm.h +++ b/include/drm-uapi/drm.h @@ -830,6 +830,16 @@ struct drm_get_cap { */ #define DRM_CLIENT_CAP_WRITEBACK_CONNECTORS 5 +/** + * DRM_CLIENT_CAP_ADVANCE_GAMMA_MODES + * + * Add support for advance gamma mode UAPI + * If set to 1, DRM will enable advance gamma mode + * UAPI to process the gamma mode based on extended + * range and segments. + */ +#define DRM_CLIENT_CAP_ADVANCE_GAMMA_MODES 6 + /* DRM_IOCTL_SET_CLIENT_CAP ioctl argument type */ struct drm_set_client_cap { __u64 capability; diff --git a/include/drm-uapi/drm_mode.h b/include/drm-uapi/drm_mode.h index e4a2570a60..97198609a5 100644 --- a/include/drm-uapi/drm_mode.h +++ b/include/drm-uapi/drm_mode.h @@ -817,6 +817,34 @@ struct drm_color_lut { __u16 reserved; }; +/* + * Creating 64 bit palette entries for better data + * precision. This will be required for HDR and + * similar color processing usecases. + */ +struct drm_color_lut_ext { + /* + * Data is U32.32 fixed point format. + */ + __u64 red; + __u64 green; + __u64 blue; + __u64 reserved; +}; + +struct drm_color_lut_range { + /* DRM_MODE_LUT_* */ + __u32 flags; + /* number of points on the curve */ + __u16 count; + /* input/output bits per component */ + __u8 input_bpc, output_bpc; + /* input start/end values */ + __s32 start, end; + /* output min/max values */ + __s32 min, max; +}; + /** * struct hdr_metadata_infoframe - HDR Metadata Infoframe Data. * From patchwork Mon Nov 15 09:47:47 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Modem, Bhanuprakash" X-Patchwork-Id: 12619187 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 12FB8C433FE for ; Mon, 15 Nov 2021 09:50:33 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id B67B4615E1 for ; Mon, 15 Nov 2021 09:50:32 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org B67B4615E1 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=intel.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 7719F6EC61; Mon, 15 Nov 2021 09:50:30 +0000 (UTC) Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by gabe.freedesktop.org (Postfix) with ESMTPS id 9A5AC6EC61; Mon, 15 Nov 2021 09:50:26 +0000 (UTC) X-IronPort-AV: E=McAfee;i="6200,9189,10168"; a="232133767" X-IronPort-AV: E=Sophos;i="5.87,236,1631602800"; d="scan'208";a="232133767" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Nov 2021 01:50:26 -0800 X-IronPort-AV: E=Sophos;i="5.87,236,1631602800"; d="scan'208";a="535446974" Received: from bhanu-nuclab.iind.intel.com ([10.145.162.173]) by orsmga001-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Nov 2021 01:50:23 -0800 From: Bhanuprakash Modem To: igt-dev@lists.freedesktop.org, dri-devel@lists.freedesktop.org Subject: [i-g-t 02/14] lib/igt_kms: Add plane color mgmt properties Date: Mon, 15 Nov 2021 15:17:47 +0530 Message-Id: <20211115094759.520955-3-bhanuprakash.modem@intel.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20211115094759.520955-1-bhanuprakash.modem@intel.com> References: <20211115094759.520955-1-bhanuprakash.modem@intel.com> MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Juha-Pekka Heikkila , Uma Shankar , Bhanuprakash Modem Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Add support for Plane color management properties. Cc: Harry Wentland Cc: Ville Syrjälä Cc: Juha-Pekka Heikkila Cc: Uma Shankar Signed-off-by: Bhanuprakash Modem --- lib/igt_kms.c | 5 +++++ lib/igt_kms.h | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/lib/igt_kms.c b/lib/igt_kms.c index 34a2aa00ea..fdb83e0f91 100644 --- a/lib/igt_kms.c +++ b/lib/igt_kms.c @@ -581,6 +581,11 @@ const char * const igt_plane_prop_names[IGT_NUM_PLANE_PROPS] = { [IGT_PLANE_ALPHA] = "alpha", [IGT_PLANE_ZPOS] = "zpos", [IGT_PLANE_FB_DAMAGE_CLIPS] = "FB_DAMAGE_CLIPS", + [IGT_PLANE_CTM] = "PLANE_CTM", + [IGT_PLANE_GAMMA_MODE] = "PLANE_GAMMA_MODE", + [IGT_PLANE_GAMMA_LUT] = "PLANE_GAMMA_LUT", + [IGT_PLANE_DEGAMMA_MODE] = "PLANE_DEGAMMA_MODE", + [IGT_PLANE_DEGAMMA_LUT] = "PLANE_DEGAMMA_LUT", }; const char * const igt_crtc_prop_names[IGT_NUM_CRTC_PROPS] = { diff --git a/lib/igt_kms.h b/lib/igt_kms.h index e9ecd21e98..3a1f7243ad 100644 --- a/lib/igt_kms.h +++ b/lib/igt_kms.h @@ -301,6 +301,11 @@ enum igt_atomic_plane_properties { IGT_PLANE_ALPHA, IGT_PLANE_ZPOS, IGT_PLANE_FB_DAMAGE_CLIPS, + IGT_PLANE_CTM, + IGT_PLANE_GAMMA_MODE, + IGT_PLANE_GAMMA_LUT, + IGT_PLANE_DEGAMMA_MODE, + IGT_PLANE_DEGAMMA_LUT, IGT_NUM_PLANE_PROPS }; From patchwork Mon Nov 15 09:47:48 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Modem, Bhanuprakash" X-Patchwork-Id: 12619191 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3BF89C433EF for ; Mon, 15 Nov 2021 09:50:40 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 0412661BA9 for ; Mon, 15 Nov 2021 09:50:39 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 0412661BA9 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=intel.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id B62576EC7F; Mon, 15 Nov 2021 09:50:35 +0000 (UTC) Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by gabe.freedesktop.org (Postfix) with ESMTPS id 336BB6EC52; Mon, 15 Nov 2021 09:50:33 +0000 (UTC) X-IronPort-AV: E=McAfee;i="6200,9189,10168"; a="232133774" X-IronPort-AV: E=Sophos;i="5.87,236,1631602800"; d="scan'208";a="232133774" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Nov 2021 01:50:29 -0800 X-IronPort-AV: E=Sophos;i="5.87,236,1631602800"; d="scan'208";a="535447006" Received: from bhanu-nuclab.iind.intel.com ([10.145.162.173]) by orsmga001-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Nov 2021 01:50:26 -0800 From: Bhanuprakash Modem To: igt-dev@lists.freedesktop.org, dri-devel@lists.freedesktop.org Subject: [i-g-t 03/14] kms_color_helper: Add helper functions for plane color mgmt Date: Mon, 15 Nov 2021 15:17:48 +0530 Message-Id: <20211115094759.520955-4-bhanuprakash.modem@intel.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20211115094759.520955-1-bhanuprakash.modem@intel.com> References: <20211115094759.520955-1-bhanuprakash.modem@intel.com> MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Juha-Pekka Heikkila , Uma Shankar , Bhanuprakash Modem Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Add helper functions to support Plane color management properties. Cc: Harry Wentland Cc: Ville Syrjälä Cc: Juha-Pekka Heikkila Cc: Uma Shankar Signed-off-by: Bhanuprakash Modem --- tests/kms_color_helper.c | 173 +++++++++++++++++++++++++++++++++++++++ tests/kms_color_helper.h | 29 +++++++ 2 files changed, 202 insertions(+) diff --git a/tests/kms_color_helper.c b/tests/kms_color_helper.c index d71e7bb2e6..c65b7a0f50 100644 --- a/tests/kms_color_helper.c +++ b/tests/kms_color_helper.c @@ -241,6 +241,150 @@ void disable_prop(igt_pipe_t *pipe, enum igt_atomic_crtc_properties prop) igt_pipe_obj_replace_prop_blob(pipe, prop, NULL, 0); } +drmModePropertyPtr get_plane_gamma_degamma_mode(igt_plane_t *plane, + enum igt_atomic_plane_properties prop) +{ + igt_display_t *display = plane->pipe->display; + uint32_t prop_id = plane->props[prop]; + drmModePropertyPtr drmProp; + + igt_assert(prop_id); + + drmProp = drmModeGetProperty(display->drm_fd, prop_id); + + igt_assert(drmProp); + igt_assert(drmProp->count_enums); + + return drmProp; +} + +struct drm_color_lut_ext *create_linear_lut(segment_data_t *info) +{ + uint32_t val, segment, entry, index = 0; + uint32_t max_val = 0xffffffff; + struct drm_color_lut_ext *lut = malloc(sizeof(struct drm_color_lut_ext) * info->entries_count); + igt_assert(lut); + + for (segment = 0; segment < info->segment_count; segment++) { + uint32_t entry_count = info->segment_data[segment].count; + uint32_t start = info->segment_data[segment].start; + uint32_t end = info->segment_data[segment].end; + + for (entry = 1; entry <= entry_count; entry++) { + val = (index == 0) ? /* First entry is Zero. */ + 0 : start + entry * ((end - start) * 1.0 / entry_count); + + lut[index].red = lut[index].green = lut[index].blue = MIN(val, max_val); + + index++; + } + } + + return lut; +} + +struct drm_color_lut_ext *create_max_lut(segment_data_t *info) +{ + int i; + struct drm_color_lut_ext *lut; + uint32_t max_val = 0xffffffff; + + lut = malloc(sizeof(struct drm_color_lut_ext) * info->entries_count); + igt_assert(lut); + + lut[0].red = lut[0].green = lut[0].blue = 0; /* First entry is Zero. */ + + for (i = 1; i < info->entries_count; i++) + lut[i].red = lut[i].green = lut[i].blue = max_val; + + return lut; +} + +void clear_segment_data(segment_data_t *info) +{ + if (!info) + return; + + free(info->segment_data); + free(info); +} + +segment_data_t *get_segment_data(data_t *data, + uint64_t blob_id, char *mode) +{ + drmModePropertyBlobPtr blob; + struct drm_color_lut_range *lut_range = NULL; + segment_data_t *info = NULL; + uint32_t i; + + blob = drmModeGetPropertyBlob(data->drm_fd, blob_id); + igt_assert(blob); + igt_assert(blob->length); + + info = malloc(sizeof(segment_data_t)); + igt_assert(info); + + lut_range = (struct drm_color_lut_range *) blob->data; + info->segment_count = blob->length / sizeof(lut_range[0]); + igt_assert(info->segment_count); + + info->segment_data = malloc(sizeof(struct drm_color_lut_range) * info->segment_count); + igt_assert(info->segment_data); + + for (i = 0; i < info->segment_count; i++) { + info->entries_count += lut_range[i].count; + info->segment_data[i] = lut_range[i]; + } + + drmModeFreePropertyBlob(blob); + + return info; +} + +void set_plane_gamma(igt_plane_t *plane, + char *mode, + struct drm_color_lut_ext *lut, + uint32_t size) +{ + igt_plane_set_prop_enum(plane, IGT_PLANE_GAMMA_MODE, mode); + igt_plane_replace_prop_blob(plane, IGT_PLANE_GAMMA_LUT, lut, size); +} + +void set_plane_degamma(igt_plane_t *plane, + char *mode, + struct drm_color_lut_ext *lut, + uint32_t size) +{ + igt_plane_set_prop_enum(plane, IGT_PLANE_DEGAMMA_MODE, mode); + igt_plane_replace_prop_blob(plane, IGT_PLANE_DEGAMMA_LUT, lut, size); +} + +void set_plane_ctm(igt_plane_t *plane, const double *coefficients) +{ + struct drm_color_ctm ctm; + int i; + + for (i = 0; i < ARRAY_SIZE(ctm.matrix); i++) { + if (coefficients[i] < 0) { + ctm.matrix[i] = + (int64_t) (-coefficients[i] * + ((int64_t) 1L << 32)); + ctm.matrix[i] |= 1ULL << 63; + } else + ctm.matrix[i] = + (int64_t) (coefficients[i] * + ((int64_t) 1L << 32)); + } + + igt_plane_replace_prop_blob(plane, IGT_PLANE_CTM, &ctm, sizeof(ctm)); +} + +void disable_plane_prop(igt_plane_t *plane, enum igt_atomic_plane_properties prop) +{ + if (igt_plane_has_prop(plane, prop)) + igt_plane_replace_prop_blob(plane, prop, NULL, 0); +} + drmModePropertyBlobPtr get_blob(data_t *data, igt_pipe_t *pipe, enum igt_atomic_crtc_properties prop) { @@ -274,6 +418,19 @@ pipe_set_property_blob_id(igt_pipe_t *pipe, return ret; } +static int +plane_set_property_blob(igt_display_t *display, + igt_plane_t *plane, + enum igt_atomic_plane_properties prop, + void *ptr, size_t length) +{ + igt_plane_replace_prop_blob(plane, prop, ptr, length); + + return igt_display_try_commit2(display, + display->is_atomic ? + COMMIT_ATOMIC : COMMIT_LEGACY); +} + int pipe_set_property_blob(igt_pipe_t *pipe, enum igt_atomic_crtc_properties prop, @@ -319,6 +476,22 @@ invalid_lut_sizes(data_t *data, enum pipe p, free(lut); } +void +invalid_plane_lut_sizes(igt_display_t *display, + igt_plane_t *plane, + enum igt_atomic_plane_properties prop, + size_t lut_size) +{ + void *lut = malloc(lut_size * 2); + igt_assert(lut); + + igt_assert_eq(plane_set_property_blob(display, plane, prop, lut, 1), -EINVAL); + igt_assert_eq(plane_set_property_blob(display, plane, prop, lut, lut_size + 1), -EINVAL); + igt_assert_eq(plane_set_property_blob(display, plane, prop, lut, lut_size - 1), -EINVAL); + + free(lut); +} + void invalid_gamma_lut_sizes(data_t *data, enum pipe p) { diff --git a/tests/kms_color_helper.h b/tests/kms_color_helper.h index bb6f0054f3..5a35dcaac1 100644 --- a/tests/kms_color_helper.h +++ b/tests/kms_color_helper.h @@ -64,6 +64,14 @@ typedef struct { color_t coeffs[]; } gamma_lut_t; +typedef struct { + uint32_t segment_count; + struct drm_color_lut_range *segment_data; + uint32_t entries_count; +} segment_data_t; + +#define MIN(a, b) ((a) < (b) ? (a) : (b)) + void paint_gradient_rectangles(data_t *data, drmModeModeInfo *mode, color_t *colors, @@ -90,10 +98,31 @@ void set_gamma(data_t *data, void set_ctm(igt_pipe_t *pipe, const double *coefficients); void disable_prop(igt_pipe_t *pipe, enum igt_atomic_crtc_properties prop); +drmModePropertyPtr get_plane_gamma_degamma_mode(igt_plane_t *plane, + enum igt_atomic_plane_properties prop); +void clear_segment_data(segment_data_t *info); +struct drm_color_lut_ext *create_linear_lut(segment_data_t *info); +struct drm_color_lut_ext *create_max_lut(segment_data_t *info); +segment_data_t *get_segment_data(data_t *data, uint64_t blob_id, char *mode); +void set_plane_gamma(igt_plane_t *plane, + char *mode, struct drm_color_lut_ext *lut, uint32_t size); +void set_plane_degamma(igt_plane_t *plane, + char *mode, struct drm_color_lut_ext *lut, uint32_t size); +void set_plane_ctm(igt_plane_t *plane, const double *coefficients); +void disable_plane_prop(igt_plane_t *plane, enum igt_atomic_plane_properties prop); +void invalid_plane_lut_sizes(igt_display_t *display, + igt_plane_t *plane, + enum igt_atomic_plane_properties prop, + size_t lut_size); + #define disable_degamma(pipe) disable_prop(pipe, IGT_CRTC_DEGAMMA_LUT) #define disable_gamma(pipe) disable_prop(pipe, IGT_CRTC_GAMMA_LUT) #define disable_ctm(pipe) disable_prop(pipe, IGT_CRTC_CTM) +#define disable_plane_degamma(plane) disable_plane_prop(plane, IGT_PLANE_DEGAMMA_LUT) +#define disable_plane_gamma(plane) disable_plane_prop(plane, IGT_PLANE_GAMMA_LUT) +#define disable_plane_ctm(plane) disable_plane_prop(plane, IGT_PLANE_CTM) + drmModePropertyBlobPtr get_blob(data_t *data, igt_pipe_t *pipe, enum igt_atomic_crtc_properties prop); bool crc_equal(igt_crc_t *a, igt_crc_t *b); From patchwork Mon Nov 15 09:47:49 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Modem, Bhanuprakash" X-Patchwork-Id: 12619189 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D36ABC433FE for ; Mon, 15 Nov 2021 09:50:37 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 9F2BE615E1 for ; Mon, 15 Nov 2021 09:50:37 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 9F2BE615E1 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=intel.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 0FCC56EC53; Mon, 15 Nov 2021 09:50:35 +0000 (UTC) Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by gabe.freedesktop.org (Postfix) with ESMTPS id 92CB86EC53; Mon, 15 Nov 2021 09:50:33 +0000 (UTC) X-IronPort-AV: E=McAfee;i="6200,9189,10168"; a="232133778" X-IronPort-AV: E=Sophos;i="5.87,236,1631602800"; d="scan'208";a="232133778" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Nov 2021 01:50:31 -0800 X-IronPort-AV: E=Sophos;i="5.87,236,1631602800"; d="scan'208";a="535447027" Received: from bhanu-nuclab.iind.intel.com ([10.145.162.173]) by orsmga001-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Nov 2021 01:50:29 -0800 From: Bhanuprakash Modem To: igt-dev@lists.freedesktop.org, dri-devel@lists.freedesktop.org Subject: [i-g-t 04/14] tests/kms_color: New subtests for Plane gamma Date: Mon, 15 Nov 2021 15:17:49 +0530 Message-Id: <20211115094759.520955-5-bhanuprakash.modem@intel.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20211115094759.520955-1-bhanuprakash.modem@intel.com> References: <20211115094759.520955-1-bhanuprakash.modem@intel.com> MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Juha-Pekka Heikkila , Uma Shankar , Bhanuprakash Modem Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" To verify Plane gamma, draw 3 gradient rectangles in red, green and blue, with a maxed out gamma LUT and verify we have the same CRC as drawing solid color rectangles. Cc: Harry Wentland Cc: Ville Syrjälä Cc: Juha-Pekka Heikkila Cc: Uma Shankar Signed-off-by: Bhanuprakash Modem --- tests/kms_color.c | 179 +++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 178 insertions(+), 1 deletion(-) diff --git a/tests/kms_color.c b/tests/kms_color.c index 775f35964f..b45d66762f 100644 --- a/tests/kms_color.c +++ b/tests/kms_color.c @@ -24,7 +24,34 @@ #include "kms_color_helper.h" -IGT_TEST_DESCRIPTION("Test Color Features at Pipe level"); +IGT_TEST_DESCRIPTION("Test Color Features at Pipe & Plane level"); + +#define MAX_SUPPORTED_PLANES 7 +#define SDR_PLANE_BASE 3 + +typedef bool (*test_t)(data_t*, igt_plane_t*); + +static bool is_hdr_plane(const igt_plane_t *plane) +{ + return plane->index >= 0 && plane->index < SDR_PLANE_BASE; +} + +static bool is_valid_plane(igt_plane_t *plane) +{ + int index = plane->index; + + if (plane->type != DRM_PLANE_TYPE_PRIMARY) + return false; + + /* + * Test 1 HDR plane, 1 SDR plane. + * + * 0,1,2 HDR planes + * 3,4,5,6 SDR planes + * + */ + return index >= 0 && index < MAX_SUPPORTED_PLANES; +} static void test_pipe_degamma(data_t *data, igt_plane_t *primary) @@ -638,6 +665,122 @@ static void test_pipe_limited_range_ctm(data_t *data, } #endif +static bool plane_gamma_test(data_t *data, igt_plane_t *plane) +{ + igt_output_t *output; + igt_display_t *display = &data->display; + drmModeModeInfo *mode; + struct igt_fb fb; + drmModePropertyPtr gamma_mode = NULL; + uint32_t i; + bool ret = true; + igt_pipe_crc_t *pipe_crc = NULL; + color_t red_green_blue[] = { + { 1.0, 0.0, 0.0 }, + { 0.0, 1.0, 0.0 }, + { 0.0, 0.0, 1.0 } + }; + + igt_info("Plane gamma test is running on pipe-%s plane-%s(%s)\n", + kmstest_pipe_name(plane->pipe->pipe), + kmstest_plane_type_name(plane->type), + is_hdr_plane(plane) ? "hdr":"sdr"); + + igt_require(igt_plane_has_prop(plane, IGT_PLANE_GAMMA_MODE)); + igt_require(igt_plane_has_prop(plane, IGT_PLANE_GAMMA_LUT)); + + pipe_crc = igt_pipe_crc_new(data->drm_fd, + plane->pipe->pipe, + INTEL_PIPE_CRC_SOURCE_AUTO); + + output = igt_get_single_output_for_pipe(display, plane->pipe->pipe); + igt_assert(output); + + igt_output_set_pipe(output, plane->pipe->pipe); + mode = igt_output_get_mode(output); + + /* Create a framebuffer at the size of the output. */ + igt_assert(igt_create_fb(data->drm_fd, + mode->hdisplay, + mode->vdisplay, + DRM_FORMAT_XRGB8888, + DRM_FORMAT_MOD_LINEAR, + &fb)); + igt_plane_set_fb(plane, &fb); + + /* Disable Pipe color props. */ + disable_ctm(plane->pipe); + disable_degamma(plane->pipe); + disable_gamma(plane->pipe); + + disable_plane_ctm(plane); + disable_plane_degamma(plane); + igt_display_commit2(display, display->is_atomic ? + COMMIT_ATOMIC : COMMIT_LEGACY); + + gamma_mode = get_plane_gamma_degamma_mode(plane, IGT_PLANE_GAMMA_MODE); + + /* Iterate all supported gamma modes. */ + for (i = 0; i < gamma_mode->count_enums; i++) { + igt_crc_t crc_gamma, crc_fullcolors; + segment_data_t *segment_info = NULL; + struct drm_color_lut_ext *lut = NULL; + uint32_t lut_size = 0; + + /* Ignore 'no gamma' from enum list. */ + if (!strcmp(gamma_mode->enums[i].name, "no gamma")) + continue; + + igt_info("Trying to use gamma mode: \'%s\'\n", gamma_mode->enums[i].name); + + /* Draw solid colors with no gamma transformation. */ + disable_plane_gamma(plane); + paint_rectangles(data, mode, red_green_blue, &fb); + igt_plane_set_fb(plane, &fb); + igt_display_commit2(display, display->is_atomic ? + COMMIT_ATOMIC : COMMIT_LEGACY); + igt_wait_for_vblank(data->drm_fd, + display->pipes[plane->pipe->pipe].crtc_offset); + igt_pipe_crc_collect_crc(pipe_crc, &crc_fullcolors); + + /* Draw gradient colors with gamma LUT to remap all + * values to max red/green/blue. + */ + segment_info = get_segment_data(data, gamma_mode->enums[i].value, + gamma_mode->enums[i].name); + lut_size = sizeof(struct drm_color_lut_ext) * segment_info->entries_count; + lut = create_max_lut(segment_info); + set_plane_gamma(plane, gamma_mode->enums[i].name, lut, lut_size); + + paint_gradient_rectangles(data, mode, red_green_blue, &fb); + igt_plane_set_fb(plane, &fb); + igt_display_commit2(display, display->is_atomic ? + COMMIT_ATOMIC : COMMIT_LEGACY); + igt_wait_for_vblank(data->drm_fd, + display->pipes[plane->pipe->pipe].crtc_offset); + igt_pipe_crc_collect_crc(pipe_crc, &crc_gamma); + + /* Verify that the CRC of the software computed output is + * equal to the CRC of the gamma LUT transformation output. + */ + ret &= igt_check_crc_equal(&crc_gamma, &crc_fullcolors); + + free(lut); + clear_segment_data(segment_info); + } + + disable_plane_gamma(plane); + igt_plane_set_fb(plane, NULL); + igt_output_set_pipe(output, PIPE_NONE); + igt_display_commit2(display, display->is_atomic ? + COMMIT_ATOMIC : COMMIT_LEGACY); + + igt_pipe_crc_free(pipe_crc); + drmModeFreeProperty(gamma_mode); + + return ret; +} + static void prep_pipe(data_t *data, enum pipe p) { @@ -890,6 +1033,37 @@ run_invalid_tests_for_pipe(data_t *data, enum pipe p) invalid_ctm_matrix_sizes(data, p); } +static void run_plane_color_test(data_t *data, enum pipe pipe, test_t test) +{ + igt_plane_t *plane; + int count = 0; + + for_each_plane_on_pipe(&data->display, pipe, plane) { + if (!is_valid_plane(plane)) + continue; + + igt_assert(test(data, plane)); + + count++; + } + + igt_require_f(count, "No valid planes found.\n"); +} + +static void run_tests_for_plane(data_t *data, enum pipe pipe) +{ + igt_fixture { + igt_require_pipe(&data->display, pipe); + igt_require_pipe_crc(data->drm_fd); + igt_require(data->display.pipes[pipe].n_planes > 0); + igt_display_require_output_on_pipe(&data->display, pipe); + } + + igt_describe("Compare maxed out plane gamma LUT and solid color linear LUT"); + igt_subtest_f("pipe-%s-plane-gamma", kmstest_pipe_name(pipe)) + run_plane_color_test(data, pipe, plane_gamma_test); +} + igt_main { data_t data = {}; @@ -910,6 +1084,9 @@ igt_main igt_subtest_group run_invalid_tests_for_pipe(&data, pipe); + + igt_subtest_group + run_tests_for_plane(&data, pipe); } igt_fixture { From patchwork Mon Nov 15 09:47:50 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Modem, Bhanuprakash" X-Patchwork-Id: 12619193 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 30537C433FE for ; Mon, 15 Nov 2021 09:50:43 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id E49A161BA9 for ; Mon, 15 Nov 2021 09:50:42 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org E49A161BA9 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=intel.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 0F2076EC84; Mon, 15 Nov 2021 09:50:40 +0000 (UTC) Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by gabe.freedesktop.org (Postfix) with ESMTPS id 8D8566EC78; Mon, 15 Nov 2021 09:50:35 +0000 (UTC) X-IronPort-AV: E=McAfee;i="6200,9189,10168"; a="232133785" X-IronPort-AV: E=Sophos;i="5.87,236,1631602800"; d="scan'208";a="232133785" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Nov 2021 01:50:34 -0800 X-IronPort-AV: E=Sophos;i="5.87,236,1631602800"; d="scan'208";a="535447060" Received: from bhanu-nuclab.iind.intel.com ([10.145.162.173]) by orsmga001-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Nov 2021 01:50:32 -0800 From: Bhanuprakash Modem To: igt-dev@lists.freedesktop.org, dri-devel@lists.freedesktop.org Subject: [i-g-t 05/14] tests/kms_color: New subtests for Plane degamma Date: Mon, 15 Nov 2021 15:17:50 +0530 Message-Id: <20211115094759.520955-6-bhanuprakash.modem@intel.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20211115094759.520955-1-bhanuprakash.modem@intel.com> References: <20211115094759.520955-1-bhanuprakash.modem@intel.com> MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Juha-Pekka Heikkila , Uma Shankar , Bhanuprakash Modem Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" To verify Plane degamma, draw 3 gradient rectangles in red, green and blue, with a maxed out degamma LUT and verify we have the same CRC as drawing solid color rectangles without degamma. Cc: Harry Wentland Cc: Ville Syrjälä Cc: Juha-Pekka Heikkila Cc: Uma Shankar Signed-off-by: Bhanuprakash Modem --- tests/kms_color.c | 124 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 124 insertions(+) diff --git a/tests/kms_color.c b/tests/kms_color.c index b45d66762f..920a5eaadd 100644 --- a/tests/kms_color.c +++ b/tests/kms_color.c @@ -781,6 +781,125 @@ static bool plane_gamma_test(data_t *data, igt_plane_t *plane) return ret; } +static bool plane_degamma_test(data_t *data, igt_plane_t *plane) +{ + igt_output_t *output; + igt_display_t *display = &data->display; + drmModeModeInfo *mode; + drmModePropertyPtr degamma_mode; + struct igt_fb fb; + uint32_t i; + bool ret = true; + igt_pipe_crc_t *pipe_crc = NULL; + color_t red_green_blue[] = { + { 1.0, 0.0, 0.0 }, + { 0.0, 1.0, 0.0 }, + { 0.0, 0.0, 1.0 } + }; + + igt_info("Plane degamma test is running on pipe-%s plane-%s(%s)\n", + kmstest_pipe_name(plane->pipe->pipe), + kmstest_plane_type_name(plane->type), + is_hdr_plane(plane) ? "hdr":"sdr"); + + igt_require(igt_plane_has_prop(plane, IGT_PLANE_DEGAMMA_MODE)); + igt_require(igt_plane_has_prop(plane, IGT_PLANE_DEGAMMA_LUT)); + + pipe_crc = igt_pipe_crc_new(data->drm_fd, + plane->pipe->pipe, + INTEL_PIPE_CRC_SOURCE_AUTO); + + output = igt_get_single_output_for_pipe(display, plane->pipe->pipe); + igt_assert(output); + + igt_output_set_pipe(output, plane->pipe->pipe); + mode = igt_output_get_mode(output); + + /* Create a framebuffer at the size of the output. */ + igt_assert(igt_create_fb(data->drm_fd, + mode->hdisplay, + mode->vdisplay, + DRM_FORMAT_XRGB8888, + DRM_FORMAT_MOD_LINEAR, + &fb)); + + igt_plane_set_fb(plane, &fb); + + /* Disable Pipe color props. */ + disable_ctm(plane->pipe); + disable_degamma(plane->pipe); + disable_gamma(plane->pipe); + + disable_plane_ctm(plane); + disable_plane_gamma(plane); + igt_display_commit2(display, display->is_atomic ? + COMMIT_ATOMIC : COMMIT_LEGACY); + + degamma_mode = get_plane_gamma_degamma_mode(plane, IGT_PLANE_DEGAMMA_MODE); + + /* Iterate all supported degamma modes. */ + for (i = 0; i < degamma_mode->count_enums; i++) { + igt_crc_t crc_degamma, crc_fullcolors; + segment_data_t *degamma_segment_info = NULL; + struct drm_color_lut_ext *degamma_lut = NULL; + uint32_t degamma_lut_size = 0; + + /* Ignore 'no degamma' from enum list. */ + if (!strcmp(degamma_mode->enums[i].name, "no degamma")) + continue; + + degamma_segment_info = get_segment_data(data, degamma_mode->enums[i].value, + degamma_mode->enums[i].name); + degamma_lut_size = sizeof(struct drm_color_lut_ext) * degamma_segment_info->entries_count; + degamma_lut = create_max_lut(degamma_segment_info); + + igt_info("Trying to use degamma mode: \'%s\'\n", degamma_mode->enums[i].name); + + /* Draw solid colors with no degamma. */ + disable_plane_degamma(plane); + paint_rectangles(data, mode, red_green_blue, &fb); + igt_plane_set_fb(plane, &fb); + igt_display_commit2(display, display->is_atomic ? + COMMIT_ATOMIC : COMMIT_LEGACY); + igt_wait_for_vblank(data->drm_fd, + display->pipes[plane->pipe->pipe].crtc_offset); + igt_pipe_crc_collect_crc(pipe_crc, &crc_fullcolors); + + /* Draw gradient colors with degamma LUT to remap all + * values to max red/green/blue. + */ + paint_gradient_rectangles(data, mode, red_green_blue, &fb); + igt_plane_set_fb(plane, &fb); + set_plane_degamma(plane, degamma_mode->enums[i].name, + degamma_lut, degamma_lut_size); + igt_display_commit2(display, display->is_atomic ? + COMMIT_ATOMIC : COMMIT_LEGACY); + igt_wait_for_vblank(data->drm_fd, + display->pipes[plane->pipe->pipe].crtc_offset); + igt_pipe_crc_collect_crc(pipe_crc, &crc_degamma); + + /* Verify that the CRC of the software computed output + * is equal to the CRC of the degamma LUT transformation + * output. + */ + ret &= igt_check_crc_equal(&crc_degamma, &crc_fullcolors); + + free(degamma_lut); + clear_segment_data(degamma_segment_info); + } + + disable_plane_degamma(plane); + igt_plane_set_fb(plane, NULL); + igt_output_set_pipe(output, PIPE_NONE); + igt_display_commit2(display, display->is_atomic ? + COMMIT_ATOMIC : COMMIT_LEGACY); + + igt_pipe_crc_free(pipe_crc); + drmModeFreeProperty(degamma_mode); + + return ret; +} + static void prep_pipe(data_t *data, enum pipe p) { @@ -1062,6 +1181,11 @@ static void run_tests_for_plane(data_t *data, enum pipe pipe) igt_describe("Compare maxed out plane gamma LUT and solid color linear LUT"); igt_subtest_f("pipe-%s-plane-gamma", kmstest_pipe_name(pipe)) run_plane_color_test(data, pipe, plane_gamma_test); + + igt_describe("Compare maxed out plane degamma LUT and solid color linear LUT"); + igt_subtest_f("pipe-%s-plane-degamma", + kmstest_pipe_name(pipe)) + run_plane_color_test(data, pipe, plane_degamma_test); } igt_main From patchwork Mon Nov 15 09:47:51 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Modem, Bhanuprakash" X-Patchwork-Id: 12619197 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1CB94C4332F for ; Mon, 15 Nov 2021 09:50:49 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id CFBCD61BA9 for ; Mon, 15 Nov 2021 09:50:48 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org CFBCD61BA9 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=intel.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 5886A6EC98; Mon, 15 Nov 2021 09:50:44 +0000 (UTC) Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by gabe.freedesktop.org (Postfix) with ESMTPS id C53BD6EC84; Mon, 15 Nov 2021 09:50:38 +0000 (UTC) X-IronPort-AV: E=McAfee;i="6200,9189,10168"; a="232133788" X-IronPort-AV: E=Sophos;i="5.87,236,1631602800"; d="scan'208";a="232133788" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Nov 2021 01:50:38 -0800 X-IronPort-AV: E=Sophos;i="5.87,236,1631602800"; d="scan'208";a="535447113" Received: from bhanu-nuclab.iind.intel.com ([10.145.162.173]) by orsmga001-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Nov 2021 01:50:34 -0800 From: Bhanuprakash Modem To: igt-dev@lists.freedesktop.org, dri-devel@lists.freedesktop.org Subject: [i-g-t 06/14] tests/kms_color: New subtests for Plane CTM Date: Mon, 15 Nov 2021 15:17:51 +0530 Message-Id: <20211115094759.520955-7-bhanuprakash.modem@intel.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20211115094759.520955-1-bhanuprakash.modem@intel.com> References: <20211115094759.520955-1-bhanuprakash.modem@intel.com> MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Juha-Pekka Heikkila , Uma Shankar , Bhanuprakash Modem Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" To verify plane CTM, draw 3 rectangles using before colors with the ctm matrix applied and verify the CRC is equal to using after colors with an identify ctm matrix. Cc: Harry Wentland Cc: Ville Syrjälä Cc: Juha-Pekka Heikkila Cc: Uma Shankar Signed-off-by: Bhanuprakash Modem --- tests/kms_color.c | 225 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 225 insertions(+) diff --git a/tests/kms_color.c b/tests/kms_color.c index 920a5eaadd..e14b37cb6f 100644 --- a/tests/kms_color.c +++ b/tests/kms_color.c @@ -53,6 +53,77 @@ static bool is_valid_plane(igt_plane_t *plane) return index >= 0 && index < MAX_SUPPORTED_PLANES; } +struct { + const char *test_name; + int iter; + color_t expected_colors[3]; + double ctm[9]; +} ctm_tests[] = { + {"plane-ctm-red-to-blue", 0, + {{ 0.0, 0.0, 1.0 }, + { 0.0, 1.0, 0.0 }, + { 0.0, 0.0, 1.0 }}, + { 0.0, 0.0, 0.0, + 0.0, 1.0, 0.0, + 1.0, 0.0, 1.0 }, + }, + {"plane-ctm-green-to-red", 0, + {{ 1.0, 0.0, 0.0 }, + { 1.0, 0.0, 0.0 }, + { 0.0, 0.0, 1.0 }}, + { 1.0, 1.0, 0.0, + 0.0, 0.0, 0.0, + 0.0, 0.0, 1.0 }, + }, + {"plane-ctm-blue-to-red", 0, + {{ 1.0, 0.0, 0.0 }, + { 0.0, 1.0, 0.0 }, + { 1.0, 0.0, 0.0 }}, + { 1.0, 0.0, 1.0, + 0.0, 1.0, 0.0, + 0.0, 0.0, 0.0 }, + }, + {"plane-ctm-max", 0, + {{ 1.0, 0.0, 0.0 }, + { 0.0, 1.0, 0.0 }, + { 0.0, 0.0, 1.0 }}, + { 100.0, 0.0, 0.0, + 0.0, 100.0, 0.0, + 0.0, 0.0, 100.0 }, + }, + {"plane-ctm-negative", 0, + {{ 0.0, 0.0, 0.0 }, + { 0.0, 0.0, 0.0 }, + { 0.0, 0.0, 0.0 }}, + { -1.0, 0.0, 0.0, + 0.0, -1.0, 0.0, + 0.0, 0.0, -1.0 }, + }, + /* We tests a few values around the expected result because + * it depends on the hardware we're dealing with, we can + * either get clamped or rounded values and we also need to + * account for odd number of items in the LUTs. + */ + {"plane-ctm-0-25", 5, + {{ 0.0, }, { 0.0, }, { 0.0, }}, + { 0.25, 0.0, 0.0, + 0.0, 0.25, 0.0, + 0.0, 0.0, 0.25 }, + }, + {"plane-ctm-0-50", 5, + {{ 0.0, }, { 0.0, }, { 0.0, }}, + { 0.5, 0.0, 0.0, + 0.0, 0.5, 0.0, + 0.0, 0.0, 0.5 }, + }, + {"plane-ctm-0-75", 7, + {{ 0.0, }, { 0.0, }, { 0.0, }}, + { 0.75, 0.0, 0.0, + 0.0, 0.75, 0.0, + 0.0, 0.0, 0.75 }, + }, +}; + static void test_pipe_degamma(data_t *data, igt_plane_t *primary) { @@ -900,6 +971,99 @@ static bool plane_degamma_test(data_t *data, igt_plane_t *plane) return ret; } +static bool test_plane_ctm(data_t *data, + igt_plane_t *plane, + color_t *before, + color_t *after, + double *ctm_matrix) +{ + const double ctm_identity[] = { + 1.0, 0.0, 0.0, + 0.0, 1.0, 0.0, + 0.0, 0.0, 1.0 + }; + igt_output_t *output; + igt_display_t *display = &data->display; + drmModeModeInfo *mode; + struct igt_fb fb; + igt_crc_t crc_software, crc_hardware; + igt_pipe_crc_t *pipe_crc = NULL; + bool ret = true; + + igt_info("Plane CTM test is running on pipe-%s plane-%s(%s)\n", + kmstest_pipe_name(plane->pipe->pipe), + kmstest_plane_type_name(plane->type), + is_hdr_plane(plane) ? "hdr":"sdr"); + + igt_require(igt_plane_has_prop(plane, IGT_PLANE_CTM)); + + pipe_crc = igt_pipe_crc_new(data->drm_fd, + plane->pipe->pipe, + INTEL_PIPE_CRC_SOURCE_AUTO); + + output = igt_get_single_output_for_pipe(display, plane->pipe->pipe); + igt_assert(output); + + igt_output_set_pipe(output, plane->pipe->pipe); + mode = igt_output_get_mode(output); + + /* Create a framebuffer at the size of the output. */ + igt_assert(igt_create_fb(data->drm_fd, + mode->hdisplay, + mode->vdisplay, + DRM_FORMAT_XRGB8888, + DRM_FORMAT_MOD_LINEAR, + &fb)); + + igt_plane_set_fb(plane, &fb); + + /* Disable Pipe color props. */ + disable_degamma(plane->pipe); + disable_gamma(plane->pipe); + disable_ctm(plane->pipe); + + disable_plane_gamma(plane); + disable_plane_degamma(plane); + igt_display_commit2(display, display->is_atomic ? + COMMIT_ATOMIC : COMMIT_LEGACY); + + /* Without CTM transformation. */ + paint_rectangles(data, mode, after, &fb); + igt_plane_set_fb(plane, &fb); + set_plane_ctm(plane, ctm_identity); + igt_display_commit2(display, display->is_atomic ? + COMMIT_ATOMIC : COMMIT_LEGACY); + igt_wait_for_vblank(data->drm_fd, + display->pipes[plane->pipe->pipe].crtc_offset); + igt_pipe_crc_collect_crc(pipe_crc, &crc_software); + + /* With CTM transformation. */ + paint_rectangles(data, mode, before, &fb); + igt_plane_set_fb(plane, &fb); + set_plane_ctm(plane, ctm_matrix); + igt_display_commit2(display, display->is_atomic ? + COMMIT_ATOMIC : COMMIT_LEGACY); + igt_wait_for_vblank(data->drm_fd, + display->pipes[plane->pipe->pipe].crtc_offset); + igt_pipe_crc_collect_crc(pipe_crc, &crc_hardware); + + /* Verify that the CRC of the software computed ouutput + * is equal to the CRC of the CTM matrix transformation + * output. + */ + ret = igt_check_crc_equal(&crc_software, &crc_hardware); + + disable_plane_ctm(plane); + igt_plane_set_fb(plane, NULL); + igt_output_set_pipe(output, PIPE_NONE); + igt_display_commit2(display, display->is_atomic ? + COMMIT_ATOMIC : COMMIT_LEGACY); + + igt_pipe_crc_free(pipe_crc); + + return ret; +} + static void prep_pipe(data_t *data, enum pipe p) { @@ -1169,8 +1333,57 @@ static void run_plane_color_test(data_t *data, enum pipe pipe, test_t test) igt_require_f(count, "No valid planes found.\n"); } +static void run_plane_ctm_test(data_t *data, + enum pipe pipe, + color_t *expected, + double *ctm, + int iter) +{ + igt_plane_t *plane; + bool result; + int i, count = 0; + double delta = 1.0 / (1 << 8); + color_t red_green_blue[] = { + { 1.0, 0.0, 0.0 }, + { 0.0, 1.0, 0.0 }, + { 0.0, 0.0, 1.0 } + }; + + for_each_plane_on_pipe(&data->display, pipe, plane) { + if (!is_valid_plane(plane)) + continue; + + result = false; + + if (!iter) + result |= test_plane_ctm(data, plane, + red_green_blue, expected, + ctm); + + for (i = 0; i < iter; i++) { + expected[0].r = + expected[1].g = + expected[2].b = + ctm[0] + delta * (i - (iter/2)); + + result |= test_plane_ctm(data, plane, + red_green_blue, expected, + ctm); + if (result) + break; + } + + igt_assert(result); + count++; + } + + igt_require_f(count, "No valid planes found.\n"); +} + static void run_tests_for_plane(data_t *data, enum pipe pipe) { + int i; + igt_fixture { igt_require_pipe(&data->display, pipe); igt_require_pipe_crc(data->drm_fd); @@ -1186,6 +1399,18 @@ static void run_tests_for_plane(data_t *data, enum pipe pipe) igt_subtest_f("pipe-%s-plane-degamma", kmstest_pipe_name(pipe)) run_plane_color_test(data, pipe, plane_degamma_test); + + for (i = 0; i < ARRAY_SIZE(ctm_tests); i++) { + igt_describe("Compare after applying ctm matrix & identity matrix"); + igt_subtest_f("pipe-%s-%s", + kmstest_pipe_name(pipe), + ctm_tests[i].test_name) { + run_plane_ctm_test(data, pipe, + ctm_tests[i].expected_colors, + ctm_tests[i].ctm, + ctm_tests[i].iter); + } + } } igt_main From patchwork Mon Nov 15 09:47:52 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Modem, Bhanuprakash" X-Patchwork-Id: 12619195 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D1F49C433F5 for ; Mon, 15 Nov 2021 09:50:46 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 9D1D561BA9 for ; Mon, 15 Nov 2021 09:50:46 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 9D1D561BA9 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=intel.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id B190A6EC94; Mon, 15 Nov 2021 09:50:43 +0000 (UTC) Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by gabe.freedesktop.org (Postfix) with ESMTPS id 230176EC8D; Mon, 15 Nov 2021 09:50:41 +0000 (UTC) X-IronPort-AV: E=McAfee;i="6200,9189,10168"; a="232133794" X-IronPort-AV: E=Sophos;i="5.87,236,1631602800"; d="scan'208";a="232133794" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Nov 2021 01:50:40 -0800 X-IronPort-AV: E=Sophos;i="5.87,236,1631602800"; d="scan'208";a="535447157" Received: from bhanu-nuclab.iind.intel.com ([10.145.162.173]) by orsmga001-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Nov 2021 01:50:37 -0800 From: Bhanuprakash Modem To: igt-dev@lists.freedesktop.org, dri-devel@lists.freedesktop.org Subject: [i-g-t 07/14] tests/kms_color: New negative tests for plane level color mgmt Date: Mon, 15 Nov 2021 15:17:52 +0530 Message-Id: <20211115094759.520955-8-bhanuprakash.modem@intel.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20211115094759.520955-1-bhanuprakash.modem@intel.com> References: <20211115094759.520955-1-bhanuprakash.modem@intel.com> MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Juha-Pekka Heikkila , Uma Shankar , Bhanuprakash Modem Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Negative check for: * plane gamma lut sizes * plane degamma lut sizes * plane ctm matrix sizes Cc: Harry Wentland Cc: Ville Syrjälä Cc: Juha-Pekka Heikkila Cc: Uma Shankar Signed-off-by: Bhanuprakash Modem --- tests/kms_color.c | 127 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 127 insertions(+) diff --git a/tests/kms_color.c b/tests/kms_color.c index e14b37cb6f..d9fe417ba9 100644 --- a/tests/kms_color.c +++ b/tests/kms_color.c @@ -736,6 +736,118 @@ static void test_pipe_limited_range_ctm(data_t *data, } #endif +static bool invalid_plane_gamma_test(data_t *data, igt_plane_t *plane) +{ + igt_display_t *display = &data->display; + drmModePropertyPtr gamma_mode = NULL; + uint32_t i; + + igt_info("Plane invalid gamma test is running on pipe-%s plane-%s(%s)\n", + kmstest_pipe_name(plane->pipe->pipe), + kmstest_plane_type_name(plane->type), + is_hdr_plane(plane) ? "hdr":"sdr"); + + igt_require(igt_plane_has_prop(plane, IGT_PLANE_GAMMA_MODE)); + igt_require(igt_plane_has_prop(plane, IGT_PLANE_GAMMA_LUT)); + + gamma_mode = get_plane_gamma_degamma_mode(plane, IGT_PLANE_GAMMA_MODE); + + /* Iterate all supported gamma modes. */ + for (i = 0; i < gamma_mode->count_enums; i++) { + segment_data_t *segment_info = NULL; + size_t lut_size = 0; + + /* Ignore 'no gamma' from enum list. */ + if (!strcmp(gamma_mode->enums[i].name, "no gamma")) + continue; + + igt_info("Trying to use gamma mode: \'%s\'\n", gamma_mode->enums[i].name); + + segment_info = get_segment_data(data, gamma_mode->enums[i].value, + gamma_mode->enums[i].name); + lut_size = sizeof(struct drm_color_lut_ext) * segment_info->entries_count; + + igt_plane_set_prop_enum(plane, IGT_PLANE_GAMMA_MODE, gamma_mode->enums[i].name); + invalid_plane_lut_sizes(display, plane, + IGT_PLANE_GAMMA_LUT, + lut_size); + + clear_segment_data(segment_info); + + /* One enum is enough. */ + break; + } + + drmModeFreeProperty(gamma_mode); + + return true; +} + +static bool invalid_plane_degamma_test(data_t *data, igt_plane_t *plane) +{ + igt_display_t *display = &data->display; + drmModePropertyPtr degamma_mode = NULL; + uint32_t i; + + igt_info("Plane invalid degamma test is running on pipe-%s plane-%s(%s)\n", + kmstest_pipe_name(plane->pipe->pipe), + kmstest_plane_type_name(plane->type), + is_hdr_plane(plane) ? "hdr":"sdr"); + + igt_require(igt_plane_has_prop(plane, IGT_PLANE_DEGAMMA_MODE)); + igt_require(igt_plane_has_prop(plane, IGT_PLANE_DEGAMMA_LUT)); + + degamma_mode = get_plane_gamma_degamma_mode(plane, IGT_PLANE_DEGAMMA_MODE); + + /* Iterate all supported degamma modes. */ + for (i = 0; i < degamma_mode->count_enums; i++) { + segment_data_t *segment_info = NULL; + size_t lut_size = 0; + + /* Ignore 'no degamma' from enum list. */ + if (!strcmp(degamma_mode->enums[i].name, "no degamma")) + continue; + + igt_info("Trying to use degamma mode: \'%s\'\n", degamma_mode->enums[i].name); + + segment_info = get_segment_data(data, + degamma_mode->enums[i].value, + degamma_mode->enums[i].name); + lut_size = sizeof(struct drm_color_lut_ext) * segment_info->entries_count * 2; + + igt_plane_set_prop_enum(plane, + IGT_PLANE_DEGAMMA_MODE, + degamma_mode->enums[i].name); + invalid_plane_lut_sizes(display, plane, + IGT_PLANE_DEGAMMA_LUT, + lut_size); + + clear_segment_data(segment_info); + + /* One enum is enough. */ + break; + } + + drmModeFreeProperty(degamma_mode); + + return true; +} + +static bool invalid_plane_ctm_test(data_t *data, igt_plane_t *plane) +{ + igt_info("Plane invalid CTM test is running on pipe-%s plane-%s(%s)\n", + kmstest_pipe_name(plane->pipe->pipe), + kmstest_plane_type_name(plane->type), + is_hdr_plane(plane) ? "hdr":"sdr"); + + igt_require(igt_plane_has_prop(plane, IGT_PLANE_CTM)); + invalid_plane_lut_sizes(&data->display, plane, + IGT_PLANE_CTM, + sizeof(struct drm_color_ctm)); + + return true; +} + static bool plane_gamma_test(data_t *data, igt_plane_t *plane) { igt_output_t *output; @@ -1411,6 +1523,21 @@ static void run_tests_for_plane(data_t *data, enum pipe pipe) ctm_tests[i].iter); } } + + igt_describe("Negative check for invalid plane gamma lut sizes"); + igt_subtest_f("pipe-%s-invalid-plane-gamma-lut-sizes", + kmstest_pipe_name(pipe)) + run_plane_color_test(data, pipe, invalid_plane_gamma_test); + + igt_describe("Negative check for invalid plane degamma lut sizes"); + igt_subtest_f("pipe-%s-invalid-plane-degamma-lut-sizes", + kmstest_pipe_name(pipe)) + run_plane_color_test(data, pipe, invalid_plane_degamma_test); + + igt_describe("Negative check for invalid plane ctm matrix sizes"); + igt_subtest_f("pipe-%s-invalid-plane-ctm-matrix-sizes", + kmstest_pipe_name(pipe)) + run_plane_color_test(data, pipe, invalid_plane_ctm_test); } igt_main From patchwork Mon Nov 15 09:47:53 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Modem, Bhanuprakash" X-Patchwork-Id: 12619199 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0EA49C433EF for ; Mon, 15 Nov 2021 09:50:52 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id CABB461BA9 for ; Mon, 15 Nov 2021 09:50:51 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org CABB461BA9 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=intel.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id E97C36EC97; Mon, 15 Nov 2021 09:50:47 +0000 (UTC) Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by gabe.freedesktop.org (Postfix) with ESMTPS id D5E946EC96; Mon, 15 Nov 2021 09:50:43 +0000 (UTC) X-IronPort-AV: E=McAfee;i="6200,9189,10168"; a="232133799" X-IronPort-AV: E=Sophos;i="5.87,236,1631602800"; d="scan'208";a="232133799" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Nov 2021 01:50:43 -0800 X-IronPort-AV: E=Sophos;i="5.87,236,1631602800"; d="scan'208";a="535447171" Received: from bhanu-nuclab.iind.intel.com ([10.145.162.173]) by orsmga001-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Nov 2021 01:50:40 -0800 From: Bhanuprakash Modem To: igt-dev@lists.freedesktop.org, dri-devel@lists.freedesktop.org Subject: [i-g-t 08/14] tests/kms_color_chamelium: New subtests for Plane gamma Date: Mon, 15 Nov 2021 15:17:53 +0530 Message-Id: <20211115094759.520955-9-bhanuprakash.modem@intel.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20211115094759.520955-1-bhanuprakash.modem@intel.com> References: <20211115094759.520955-1-bhanuprakash.modem@intel.com> MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kunal Joshi , Juha-Pekka Heikkila , Uma Shankar , Bhanuprakash Modem Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" To verify Plane gamma, draw 3 gradient rectangles in red, green and blue, with a maxed out gamma LUT and verify we have the same frame dump as drawing solid color rectangles. Cc: Harry Wentland Cc: Ville Syrjälä Cc: Juha-Pekka Heikkila Cc: Uma Shankar Cc: Kunal Joshi Signed-off-by: Bhanuprakash Modem --- tests/kms_color_chamelium.c | 188 +++++++++++++++++++++++++++++++++++- 1 file changed, 187 insertions(+), 1 deletion(-) diff --git a/tests/kms_color_chamelium.c b/tests/kms_color_chamelium.c index 76f82d6d35..b506109271 100644 --- a/tests/kms_color_chamelium.c +++ b/tests/kms_color_chamelium.c @@ -24,7 +24,34 @@ #include "kms_color_helper.h" -IGT_TEST_DESCRIPTION("Test Color Features at Pipe level using Chamelium to verify instead of CRC"); +IGT_TEST_DESCRIPTION("Test Color Features at Pipe & Plane level using Chamelium to verify instead of CRC"); + +#define MAX_SUPPORTED_PLANES 7 +#define SDR_PLANE_BASE 3 + +typedef bool (*test_t)(data_t*, igt_plane_t*); + +static bool is_hdr_plane(const igt_plane_t *plane) +{ + return plane->index >= 0 && plane->index < SDR_PLANE_BASE; +} + +static bool is_valid_plane(igt_plane_t *plane) +{ + int index = plane->index; + + if (plane->type != DRM_PLANE_TYPE_PRIMARY) + return false; + + /* + * Test 1 HDR plane, 1 SDR plane. + * + * 0,1,2 HDR planes + * 3,4,5,6 SDR planes + * + */ + return index >= 0 && index < MAX_SUPPORTED_PLANES; +} /* * Draw 3 gradient rectangles in red, green and blue, with a maxed out @@ -723,6 +750,161 @@ run_tests_for_pipe(data_t *data, enum pipe p) } } +static bool plane_gamma_test(data_t *data, igt_plane_t *plane) +{ + igt_output_t *output; + igt_display_t *display = &data->display; + drmModeModeInfo *mode; + struct igt_fb fb, fbref; + drmModePropertyPtr gamma_mode = NULL; + uint32_t i; + bool ret = true; + struct chamelium_port *port = NULL; + color_t red_green_blue[] = { + { 1.0, 0.0, 0.0 }, + { 0.0, 1.0, 0.0 }, + { 0.0, 0.0, 1.0 } + }; + + igt_info("Plane gamma test is running on pipe-%s plane-%s(%s)\n", + kmstest_pipe_name(plane->pipe->pipe), + kmstest_plane_type_name(plane->type), + is_hdr_plane(plane) ? "hdr":"sdr"); + + igt_require(igt_plane_has_prop(plane, IGT_PLANE_GAMMA_MODE)); + igt_require(igt_plane_has_prop(plane, IGT_PLANE_GAMMA_LUT)); + + for_each_valid_output_on_pipe(display, plane->pipe->pipe, output) { + for (i = 0; i < data->port_count; i++) + if (strcmp(output->name, chamelium_port_get_name(data->ports[i])) == 0) { + port = data->ports[i]; + break; + } + + if (port) + break; + } + igt_require(port); + igt_assert(output); + + igt_output_set_pipe(output, plane->pipe->pipe); + mode = igt_output_get_mode(output); + + /* Create a framebuffer at the size of the output. */ + igt_assert(igt_create_fb(data->drm_fd, + mode->hdisplay, + mode->vdisplay, + DRM_FORMAT_XRGB8888, + DRM_FORMAT_MOD_LINEAR, + &fb)); + + igt_assert(igt_create_fb(data->drm_fd, + mode->hdisplay, + mode->vdisplay, + DRM_FORMAT_XRGB8888, + DRM_FORMAT_MOD_LINEAR, + &fbref)); + + disable_degamma(plane->pipe); + disable_ctm(plane->pipe); + disable_gamma(plane->pipe); + + disable_plane_degamma(plane); + disable_plane_ctm(plane); + disable_plane_gamma(plane); + + igt_plane_set_fb(plane, &fbref); + igt_display_commit2(display, display->is_atomic ? + COMMIT_ATOMIC : COMMIT_LEGACY); + + /* Draw solid colors with no gamma transformation. */ + paint_rectangles(data, mode, red_green_blue, &fbref); + + gamma_mode = get_plane_gamma_degamma_mode(plane, IGT_PLANE_GAMMA_MODE); + /* Iterate all supported gamma modes. */ + for (i = 0; i < gamma_mode->count_enums; i++) { + struct chamelium_frame_dump *frame_fullcolors; + segment_data_t *segment_info = NULL; + struct drm_color_lut_ext *lut = NULL; + uint32_t lut_size = 0; + + /* Ignore 'no gamma' from enum list. */ + if (!strcmp(gamma_mode->enums[i].name, "no gamma")) + continue; + + igt_info("Trying to use gamma mode: \'%s\'\n", gamma_mode->enums[i].name); + + segment_info = get_segment_data(data, gamma_mode->enums[i].value, + gamma_mode->enums[i].name); + lut_size = sizeof(struct drm_color_lut_ext) * segment_info->entries_count; + lut = create_max_lut(segment_info); + set_plane_gamma(plane, gamma_mode->enums[i].name, lut, lut_size); + + /* Draw a gradient with gamma LUT to remap all + * values to max red/green/blue. + */ + paint_gradient_rectangles(data, mode, red_green_blue, &fb); + igt_plane_set_fb(plane, &fb); + igt_display_commit2(display, display->is_atomic ? + COMMIT_ATOMIC : COMMIT_LEGACY); + + chamelium_capture(data->chamelium, port, 0, 0, 0, 0, 1); + frame_fullcolors = + chamelium_read_captured_frame(data->chamelium, 0); + + /* Verify that the framebuffer reference of the software computed + * output is equal to the frame dump of the gamma LUT + * transformation output. + */ + ret &= chamelium_frame_match_or_dump(data->chamelium, port, + frame_fullcolors, &fbref, + CHAMELIUM_CHECK_ANALOG); + free(lut); + clear_segment_data(segment_info); + } + + disable_plane_gamma(plane); + igt_plane_set_fb(plane, NULL); + igt_output_set_pipe(output, PIPE_NONE); + igt_display_commit2(display, display->is_atomic ? + COMMIT_ATOMIC : COMMIT_LEGACY); + + drmModeFreeProperty(gamma_mode); + + return ret; +} + +static void run_plane_color_test(data_t *data, enum pipe pipe, test_t test) +{ + igt_plane_t *plane; + int count = 0; + + for_each_plane_on_pipe(&data->display, pipe, plane) { + if (!is_valid_plane(plane)) + continue; + + igt_assert(test(data, plane)); + + count++; + } + + igt_require_f(count, "No valid planes found.\n"); +} + +static void run_tests_for_plane(data_t *data, enum pipe pipe) +{ + igt_fixture { + igt_require_pipe(&data->display, pipe); + igt_require(data->display.pipes[pipe].n_planes > 0); + igt_display_require_output_on_pipe(&data->display, pipe); + } + + igt_describe("Compare maxed out plane gamma LUT and solid color linear LUT"); + igt_subtest_f("pipe-%s-plane-gamma", + kmstest_pipe_name(pipe)) + run_plane_color_test(data, pipe, plane_gamma_test); +} + igt_main { data_t data = {}; @@ -755,6 +937,10 @@ igt_main igt_subtest_group run_tests_for_pipe(&data, pipe); + for_each_pipe_static(pipe) + igt_subtest_group + run_tests_for_plane(&data, pipe); + igt_fixture { igt_display_fini(&data.display); } From patchwork Mon Nov 15 09:47:54 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Modem, Bhanuprakash" X-Patchwork-Id: 12619201 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id EB232C433F5 for ; Mon, 15 Nov 2021 09:50:55 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id AF43D615E1 for ; Mon, 15 Nov 2021 09:50:55 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org AF43D615E1 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=intel.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 719CC6EB88; Mon, 15 Nov 2021 09:50:51 +0000 (UTC) Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by gabe.freedesktop.org (Postfix) with ESMTPS id DC4C76EC93; Mon, 15 Nov 2021 09:50:46 +0000 (UTC) X-IronPort-AV: E=McAfee;i="6200,9189,10168"; a="232133802" X-IronPort-AV: E=Sophos;i="5.87,236,1631602800"; d="scan'208";a="232133802" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Nov 2021 01:50:46 -0800 X-IronPort-AV: E=Sophos;i="5.87,236,1631602800"; d="scan'208";a="535447199" Received: from bhanu-nuclab.iind.intel.com ([10.145.162.173]) by orsmga001-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Nov 2021 01:50:43 -0800 From: Bhanuprakash Modem To: igt-dev@lists.freedesktop.org, dri-devel@lists.freedesktop.org Subject: [i-g-t 09/14] tests/kms_color_chamelium: New subtests for Plane degamma Date: Mon, 15 Nov 2021 15:17:54 +0530 Message-Id: <20211115094759.520955-10-bhanuprakash.modem@intel.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20211115094759.520955-1-bhanuprakash.modem@intel.com> References: <20211115094759.520955-1-bhanuprakash.modem@intel.com> MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kunal Joshi , Juha-Pekka Heikkila , Uma Shankar , Bhanuprakash Modem Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" To verify Plane degamma, draw 3 gradient rectangles in red, green and blue, with a maxed out degamma LUT and verify we have the same frame dump as drawing solid color rectangles with linear gamma LUT. Cc: Harry Wentland Cc: Ville Syrjälä Cc: Juha-Pekka Heikkila Cc: Uma Shankar Cc: Kunal Joshi Signed-off-by: Bhanuprakash Modem --- tests/kms_color_chamelium.c | 131 ++++++++++++++++++++++++++++++++++++ 1 file changed, 131 insertions(+) diff --git a/tests/kms_color_chamelium.c b/tests/kms_color_chamelium.c index b506109271..3bcb3ac043 100644 --- a/tests/kms_color_chamelium.c +++ b/tests/kms_color_chamelium.c @@ -874,6 +874,132 @@ static bool plane_gamma_test(data_t *data, igt_plane_t *plane) return ret; } +static bool plane_degamma_test(data_t *data, igt_plane_t *plane) +{ + igt_output_t *output; + igt_display_t *display = &data->display; + drmModeModeInfo *mode; + drmModePropertyPtr degamma_mode; + struct igt_fb fb, fbref; + struct chamelium_port *port; + uint32_t i; + bool ret = true; + color_t red_green_blue[] = { + { 1.0, 0.0, 0.0 }, + { 0.0, 1.0, 0.0 }, + { 0.0, 0.0, 1.0 } + }; + + igt_info("Plane degamma test is running on pipe-%s plane-%s(%s)\n", + kmstest_pipe_name(plane->pipe->pipe), + kmstest_plane_type_name(plane->type), + is_hdr_plane(plane) ? "hdr":"sdr"); + + igt_require(igt_plane_has_prop(plane, IGT_PLANE_DEGAMMA_MODE)); + igt_require(igt_plane_has_prop(plane, IGT_PLANE_DEGAMMA_LUT)); + + for_each_valid_output_on_pipe(display, plane->pipe->pipe, output) { + for (i = 0; i < data->port_count; i++) + if (strcmp(output->name, chamelium_port_get_name(data->ports[i])) == 0) { + port = data->ports[i]; + break; + } + + if (port) + break; + } + igt_require(port); + igt_assert(output); + + igt_output_set_pipe(output, plane->pipe->pipe); + mode = igt_output_get_mode(output); + + /* Create a framebuffer at the size of the output. */ + igt_assert(igt_create_fb(data->drm_fd, + mode->hdisplay, + mode->vdisplay, + DRM_FORMAT_XRGB8888, + DRM_FORMAT_MOD_LINEAR, + &fb)); + + igt_assert(igt_create_fb(data->drm_fd, + mode->hdisplay, + mode->vdisplay, + DRM_FORMAT_XRGB8888, + DRM_FORMAT_MOD_LINEAR, + &fbref)); + + disable_degamma(plane->pipe); + disable_ctm(plane->pipe); + disable_gamma(plane->pipe); + + disable_plane_degamma(plane); + disable_plane_ctm(plane); + disable_plane_gamma(plane); + + igt_plane_set_fb(plane, &fbref); + igt_display_commit2(display, display->is_atomic ? + COMMIT_ATOMIC : COMMIT_LEGACY); + + /* Draw solid colors with no degamma. */ + paint_rectangles(data, mode, red_green_blue, &fbref); + + degamma_mode = get_plane_gamma_degamma_mode(plane, IGT_PLANE_DEGAMMA_MODE); + /* Iterate all supported degamma modes. */ + for (i = 0; i < degamma_mode->count_enums; i++) { + struct chamelium_frame_dump *frame_fullcolors; + segment_data_t *degamma_segment_info = NULL; + struct drm_color_lut_ext *degamma_lut = NULL; + uint32_t degamma_lut_size = 0; + + /* Ignore 'no degamma' from enum list. */ + if (!strcmp(degamma_mode->enums[i].name, "no degamma")) + continue; + + degamma_segment_info = get_segment_data(data, degamma_mode->enums[i].value, + degamma_mode->enums[i].name); + degamma_lut_size = sizeof(struct drm_color_lut_ext) * degamma_segment_info->entries_count; + degamma_lut = create_max_lut(degamma_segment_info); + + igt_info("Trying to use degamma mode: \'%s\'\n", degamma_mode->enums[i].name); + + /* Draw a gradient with degamma LUT to remap all + * values to max red/green/blue. + */ + paint_gradient_rectangles(data, mode, red_green_blue, &fb); + igt_plane_set_fb(plane, &fb); + set_plane_degamma(plane, degamma_mode->enums[i].name, + degamma_lut, degamma_lut_size); + igt_display_commit2(display, display->is_atomic ? + COMMIT_ATOMIC : COMMIT_LEGACY); + + chamelium_capture(data->chamelium, port, 0, 0, 0, 0, 1); + frame_fullcolors = + chamelium_read_captured_frame(data->chamelium, 0); + + /* Verify that the framebuffer reference of the software computed + * output is equal to the frame dump of the gamma LUT + * transformation output. + */ + ret &= chamelium_frame_match_or_dump(data->chamelium, port, + frame_fullcolors, &fbref, + CHAMELIUM_CHECK_ANALOG); + + free(degamma_lut); + clear_segment_data(degamma_segment_info); + } + + disable_plane_degamma(plane); + igt_plane_set_fb(plane, NULL); + igt_output_set_pipe(output, PIPE_NONE); + igt_display_commit2(display, display->is_atomic ? + COMMIT_ATOMIC : COMMIT_LEGACY); + + drmModeFreeProperty(degamma_mode); + + return ret; +} + static void run_plane_color_test(data_t *data, enum pipe pipe, test_t test) { igt_plane_t *plane; @@ -903,6 +1029,11 @@ static void run_tests_for_plane(data_t *data, enum pipe pipe) igt_subtest_f("pipe-%s-plane-gamma", kmstest_pipe_name(pipe)) run_plane_color_test(data, pipe, plane_gamma_test); + + igt_describe("Compare maxed out plane degamma LUT and solid color linear LUT"); + igt_subtest_f("pipe-%s-plane-degamma", + kmstest_pipe_name(pipe)) + run_plane_color_test(data, pipe, plane_degamma_test); } igt_main From patchwork Mon Nov 15 09:47:55 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Modem, Bhanuprakash" X-Patchwork-Id: 12619203 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A0A85C433EF for ; Mon, 15 Nov 2021 09:50:57 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 6A338615E1 for ; Mon, 15 Nov 2021 09:50:57 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 6A338615E1 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=intel.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id B9AF16EC59; Mon, 15 Nov 2021 09:50:51 +0000 (UTC) Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by gabe.freedesktop.org (Postfix) with ESMTPS id E803D6EC59; Mon, 15 Nov 2021 09:50:49 +0000 (UTC) X-IronPort-AV: E=McAfee;i="6200,9189,10168"; a="232133805" X-IronPort-AV: E=Sophos;i="5.87,236,1631602800"; d="scan'208";a="232133805" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Nov 2021 01:50:49 -0800 X-IronPort-AV: E=Sophos;i="5.87,236,1631602800"; d="scan'208";a="535447248" Received: from bhanu-nuclab.iind.intel.com ([10.145.162.173]) by orsmga001-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Nov 2021 01:50:46 -0800 From: Bhanuprakash Modem To: igt-dev@lists.freedesktop.org, dri-devel@lists.freedesktop.org Subject: [i-g-t 10/14] tests/kms_color_chamelium: New subtests for Plane CTM Date: Mon, 15 Nov 2021 15:17:55 +0530 Message-Id: <20211115094759.520955-11-bhanuprakash.modem@intel.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20211115094759.520955-1-bhanuprakash.modem@intel.com> References: <20211115094759.520955-1-bhanuprakash.modem@intel.com> MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kunal Joshi , Juha-Pekka Heikkila , Uma Shankar , Bhanuprakash Modem Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" To verify plane CTM, draw 3 rectangles using before colors with the ctm matrix applied and verify the frame dump is equal to using after colors with an identify ctm matrix. Cc: Harry Wentland Cc: Ville Syrjälä Cc: Juha-Pekka Heikkila Cc: Uma Shankar Cc: Kunal Joshi Signed-off-by: Bhanuprakash Modem --- tests/kms_color_chamelium.c | 229 ++++++++++++++++++++++++++++++++++++ 1 file changed, 229 insertions(+) diff --git a/tests/kms_color_chamelium.c b/tests/kms_color_chamelium.c index 3bcb3ac043..af820565d3 100644 --- a/tests/kms_color_chamelium.c +++ b/tests/kms_color_chamelium.c @@ -53,6 +53,77 @@ static bool is_valid_plane(igt_plane_t *plane) return index >= 0 && index < MAX_SUPPORTED_PLANES; } +struct { + const char *test_name; + int iter; + color_t expected_colors[3]; + double ctm[9]; +} ctm_tests[] = { + {"plane-ctm-red-to-blue", 0, + {{ 0.0, 0.0, 1.0 }, + { 0.0, 1.0, 0.0 }, + { 0.0, 0.0, 1.0 }}, + { 0.0, 0.0, 0.0, + 0.0, 1.0, 0.0, + 1.0, 0.0, 1.0 }, + }, + {"plane-ctm-green-to-red", 0, + {{ 1.0, 0.0, 0.0 }, + { 1.0, 0.0, 0.0 }, + { 0.0, 0.0, 1.0 }}, + { 1.0, 1.0, 0.0, + 0.0, 0.0, 0.0, + 0.0, 0.0, 1.0 }, + }, + {"plane-ctm-blue-to-red", 0, + {{ 1.0, 0.0, 0.0 }, + { 0.0, 1.0, 0.0 }, + { 1.0, 0.0, 0.0 }}, + { 1.0, 0.0, 1.0, + 0.0, 1.0, 0.0, + 0.0, 0.0, 0.0 }, + }, + {"plane-ctm-max", 0, + {{ 1.0, 0.0, 0.0 }, + { 0.0, 1.0, 0.0 }, + { 0.0, 0.0, 1.0 }}, + { 100.0, 0.0, 0.0, + 0.0, 100.0, 0.0, + 0.0, 0.0, 100.0 }, + }, + {"plane-ctm-negative", 0, + {{ 0.0, 0.0, 0.0 }, + { 0.0, 0.0, 0.0 }, + { 0.0, 0.0, 0.0 }}, + { -1.0, 0.0, 0.0, + 0.0, -1.0, 0.0, + 0.0, 0.0, -1.0 }, + }, + /* We tests a few values around the expected result because + * it depends on the hardware we're dealing with, we can + * either get clamped or rounded values and we also need to + * account for odd number of items in the LUTs. + */ + {"plane-ctm-0-25", 5, + {{ 0.0, }, { 0.0, }, { 0.0, }}, + { 0.25, 0.0, 0.0, + 0.0, 0.25, 0.0, + 0.0, 0.0, 0.25 }, + }, + {"plane-ctm-0-50", 5, + {{ 0.0, }, { 0.0, }, { 0.0, }}, + { 0.5, 0.0, 0.0, + 0.0, 0.5, 0.0, + 0.0, 0.0, 0.5 }, + }, + {"plane-ctm-0-75", 7, + {{ 0.0, }, { 0.0, }, { 0.0, }}, + { 0.75, 0.0, 0.0, + 0.0, 0.75, 0.0, + 0.0, 0.0, 0.75 }, + }, +}; + /* * Draw 3 gradient rectangles in red, green and blue, with a maxed out * degamma LUT and verify we have the same frame dump as drawing solid color @@ -1000,6 +1071,103 @@ static bool plane_degamma_test(data_t *data, igt_plane_t *plane) return ret; } +static bool test_plane_ctm(data_t *data, + igt_plane_t *plane, + color_t *before, + color_t *after, + double *ctm_matrix) +{ + igt_output_t *output; + igt_display_t *display = &data->display; + drmModeModeInfo *mode; + struct igt_fb fb, fbref; + struct chamelium_port *port; + struct chamelium_frame_dump *frame_hardware; + uint32_t i; + bool ret = true; + + igt_info("Plane CTM test is running on pipe-%s plane-%s(%s)\n", + kmstest_pipe_name(plane->pipe->pipe), + kmstest_plane_type_name(plane->type), + is_hdr_plane(plane) ? "hdr":"sdr"); + + igt_require(igt_plane_has_prop(plane, IGT_PLANE_CTM)); + + for_each_valid_output_on_pipe(display, plane->pipe->pipe, output) { + for (i = 0; i < data->port_count; i++) + if (strcmp(output->name, chamelium_port_get_name(data->ports[i])) == 0) { + port = data->ports[i]; + break; + } + + if (port) + break; + } + igt_require(port); + igt_assert(output); + + igt_output_set_pipe(output, plane->pipe->pipe); + mode = igt_output_get_mode(output); + + /* Create a framebuffer at the size of the output. */ + igt_assert(igt_create_fb(data->drm_fd, + mode->hdisplay, + mode->vdisplay, + DRM_FORMAT_XRGB8888, + DRM_FORMAT_MOD_LINEAR, + &fb)); + + igt_assert(igt_create_fb(data->drm_fd, + mode->hdisplay, + mode->vdisplay, + DRM_FORMAT_XRGB8888, + DRM_FORMAT_MOD_LINEAR, + &fbref)); + + disable_degamma(plane->pipe); + disable_ctm(plane->pipe); + disable_gamma(plane->pipe); + + disable_plane_degamma(plane); + disable_plane_ctm(plane); + disable_plane_gamma(plane); + + igt_plane_set_fb(plane, &fbref); + igt_display_commit2(display, display->is_atomic ? + COMMIT_ATOMIC : COMMIT_LEGACY); + + /* Without CTM transformation. */ + paint_rectangles(data, mode, after, &fbref); + + /* With CTM transformation. */ + paint_rectangles(data, mode, before, &fb); + igt_plane_set_fb(plane, &fb); + set_plane_ctm(plane, ctm_matrix); + igt_display_commit2(display, display->is_atomic ? + COMMIT_ATOMIC : COMMIT_LEGACY); + + chamelium_capture(data->chamelium, port, 0, 0, 0, 0, 1); + frame_hardware = + chamelium_read_captured_frame(data->chamelium, 0); + + /* Verify that the framebuffer reference of the software + * computed output is equal to the frame dump of the CTM + * matrix transformation output. + */ + ret = chamelium_frame_match_or_dump(data->chamelium, port, + frame_hardware, + &fbref, + CHAMELIUM_CHECK_ANALOG); + + disable_plane_ctm(plane); + igt_plane_set_fb(plane, NULL); + igt_output_set_pipe(output, PIPE_NONE); + igt_display_commit2(display, display->is_atomic ? + COMMIT_ATOMIC : COMMIT_LEGACY); + + return ret; +} + static void run_plane_color_test(data_t *data, enum pipe pipe, test_t test) { igt_plane_t *plane; @@ -1017,8 +1185,57 @@ static void run_plane_color_test(data_t *data, enum pipe pipe, test_t test) igt_require_f(count, "No valid planes found.\n"); } +static void run_plane_ctm_test(data_t *data, + enum pipe pipe, + color_t *expected, + double *ctm, + int iter) +{ + igt_plane_t *plane; + bool result; + int i, count = 0; + double delta = 1.0 / (1 << 8); + color_t red_green_blue[] = { + { 1.0, 0.0, 0.0 }, + { 0.0, 1.0, 0.0 }, + { 0.0, 0.0, 1.0 } + }; + + for_each_plane_on_pipe(&data->display, pipe, plane) { + if (!is_valid_plane(plane)) + continue; + + result = false; + + if (!iter) + result |= test_plane_ctm(data, plane, + red_green_blue, expected, + ctm); + + for (i = 0; i < iter; i++) { + expected[0].r = + expected[1].g = + expected[2].b = + ctm[0] + delta * (i - (iter/2)); + + result |= test_plane_ctm(data, plane, + red_green_blue, expected, + ctm); + if (result) + break; + } + + igt_assert(result); + count++; + } + + igt_require_f(count, "No valid planes found.\n"); +} + static void run_tests_for_plane(data_t *data, enum pipe pipe) { + int i; + igt_fixture { igt_require_pipe(&data->display, pipe); igt_require(data->display.pipes[pipe].n_planes > 0); @@ -1034,6 +1251,18 @@ static void run_tests_for_plane(data_t *data, enum pipe pipe) igt_subtest_f("pipe-%s-plane-degamma", kmstest_pipe_name(pipe)) run_plane_color_test(data, pipe, plane_degamma_test); + + for (i = 0; i < ARRAY_SIZE(ctm_tests); i++) { + igt_describe("Compare after applying ctm matrix & identity matrix"); + igt_subtest_f("pipe-%s-%s", + kmstest_pipe_name(pipe), + ctm_tests[i].test_name) { + run_plane_ctm_test(data, pipe, + ctm_tests[i].expected_colors, + ctm_tests[i].ctm, + ctm_tests[i].iter); + } + } } igt_main From patchwork Mon Nov 15 09:47:56 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Modem, Bhanuprakash" X-Patchwork-Id: 12619207 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 661D4C433EF for ; Mon, 15 Nov 2021 09:51:03 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 29E1761BA9 for ; Mon, 15 Nov 2021 09:51:03 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 29E1761BA9 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=intel.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 16BCD6EC99; Mon, 15 Nov 2021 09:50:58 +0000 (UTC) Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by gabe.freedesktop.org (Postfix) with ESMTPS id B9B256EBAA; Mon, 15 Nov 2021 09:50:53 +0000 (UTC) X-IronPort-AV: E=McAfee;i="6200,9189,10168"; a="232133807" X-IronPort-AV: E=Sophos;i="5.87,236,1631602800"; d="scan'208";a="232133807" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Nov 2021 01:50:53 -0800 X-IronPort-AV: E=Sophos;i="5.87,236,1631602800"; d="scan'208";a="535447291" Received: from bhanu-nuclab.iind.intel.com ([10.145.162.173]) by orsmga001-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Nov 2021 01:50:49 -0800 From: Bhanuprakash Modem To: igt-dev@lists.freedesktop.org, dri-devel@lists.freedesktop.org Subject: [i-g-t 11/14] lib/igt_kms: Add pipe color mgmt properties Date: Mon, 15 Nov 2021 15:17:56 +0530 Message-Id: <20211115094759.520955-12-bhanuprakash.modem@intel.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20211115094759.520955-1-bhanuprakash.modem@intel.com> References: <20211115094759.520955-1-bhanuprakash.modem@intel.com> MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mukunda Pramodh Kumar , Juha-Pekka Heikkila , Uma Shankar , Bhanuprakash Modem Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Mukunda Pramodh Kumar Add support for Pipe color management properties. Cc: Harry Wentland Cc: Ville Syrjälä Cc: Juha-Pekka Heikkila Cc: Uma Shankar Signed-off-by: Mukunda Pramodh Kumar Signed-off-by: Bhanuprakash Modem --- lib/igt_kms.c | 1 + lib/igt_kms.h | 1 + 2 files changed, 2 insertions(+) diff --git a/lib/igt_kms.c b/lib/igt_kms.c index fdb83e0f91..677d26fedb 100644 --- a/lib/igt_kms.c +++ b/lib/igt_kms.c @@ -592,6 +592,7 @@ const char * const igt_crtc_prop_names[IGT_NUM_CRTC_PROPS] = { [IGT_CRTC_CTM] = "CTM", [IGT_CRTC_GAMMA_LUT] = "GAMMA_LUT", [IGT_CRTC_GAMMA_LUT_SIZE] = "GAMMA_LUT_SIZE", + [IGT_CRTC_GAMMA_MODE] = "GAMMA_MODE", [IGT_CRTC_DEGAMMA_LUT] = "DEGAMMA_LUT", [IGT_CRTC_DEGAMMA_LUT_SIZE] = "DEGAMMA_LUT_SIZE", [IGT_CRTC_MODE_ID] = "MODE_ID", diff --git a/lib/igt_kms.h b/lib/igt_kms.h index 3a1f7243ad..5fac651fa3 100644 --- a/lib/igt_kms.h +++ b/lib/igt_kms.h @@ -119,6 +119,7 @@ enum igt_atomic_crtc_properties { IGT_CRTC_CTM = 0, IGT_CRTC_GAMMA_LUT, IGT_CRTC_GAMMA_LUT_SIZE, + IGT_CRTC_GAMMA_MODE, IGT_CRTC_DEGAMMA_LUT, IGT_CRTC_DEGAMMA_LUT_SIZE, IGT_CRTC_MODE_ID, From patchwork Mon Nov 15 09:47:57 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Modem, Bhanuprakash" X-Patchwork-Id: 12619205 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 712CBC433FE for ; Mon, 15 Nov 2021 09:51:01 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 3B9E1615E1 for ; Mon, 15 Nov 2021 09:51:01 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 3B9E1615E1 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=intel.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 27C9F6EC9A; Mon, 15 Nov 2021 09:50:58 +0000 (UTC) Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by gabe.freedesktop.org (Postfix) with ESMTPS id 681E86EBAA; Mon, 15 Nov 2021 09:50:56 +0000 (UTC) X-IronPort-AV: E=McAfee;i="6200,9189,10168"; a="232133815" X-IronPort-AV: E=Sophos;i="5.87,236,1631602800"; d="scan'208";a="232133815" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Nov 2021 01:50:55 -0800 X-IronPort-AV: E=Sophos;i="5.87,236,1631602800"; d="scan'208";a="535447311" Received: from bhanu-nuclab.iind.intel.com ([10.145.162.173]) by orsmga001-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Nov 2021 01:50:52 -0800 From: Bhanuprakash Modem To: igt-dev@lists.freedesktop.org, dri-devel@lists.freedesktop.org Subject: [i-g-t 12/14] kms_color_helper: Add helper functions to support logarithmic gamma mode Date: Mon, 15 Nov 2021 15:17:57 +0530 Message-Id: <20211115094759.520955-13-bhanuprakash.modem@intel.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20211115094759.520955-1-bhanuprakash.modem@intel.com> References: <20211115094759.520955-1-bhanuprakash.modem@intel.com> MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mukunda Pramodh Kumar , Juha-Pekka Heikkila , Uma Shankar , Bhanuprakash Modem Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Mukunda Pramodh Kumar Add helper functions to support logarithmic gamma mode Cc: Harry Wentland Cc: Ville Syrjälä Cc: Juha-Pekka Heikkila Cc: Uma Shankar Signed-off-by: Mukunda Pramodh Kumar Signed-off-by: Bhanuprakash Modem --- tests/kms_color_helper.c | 127 +++++++++++++++++++++++++++++++++++++++ tests/kms_color_helper.h | 16 +++++ 2 files changed, 143 insertions(+) diff --git a/tests/kms_color_helper.c b/tests/kms_color_helper.c index c65b7a0f50..7ea8282df3 100644 --- a/tests/kms_color_helper.c +++ b/tests/kms_color_helper.c @@ -190,6 +190,33 @@ struct drm_color_lut *coeffs_to_lut(data_t *data, return lut; } +struct drm_color_lut *coeffs_to_logarithmic_lut(data_t *data, + const gamma_lut_t *gamma, + uint32_t color_depth, + int off) +{ + struct drm_color_lut *lut; + int i, lut_size = gamma->size; + /* This is the maximum value due to 16 bit precision in hardware. */ + uint32_t max_hw_value = (1 << 16) - 1; + unsigned int max_segment_value = 1 << 24; + + lut = malloc(sizeof(struct drm_color_lut) * lut_size); + + for (i = 0; i < lut_size; i++) { + double scaling_factor = (double)max_hw_value / (double)max_segment_value; + uint32_t r = MIN((gamma->coeffs[i].r * scaling_factor), max_hw_value); + uint32_t g = MIN((gamma->coeffs[i].g * scaling_factor), max_hw_value); + uint32_t b = MIN((gamma->coeffs[i].b * scaling_factor), max_hw_value); + + lut[i].red = r; + lut[i].green = g; + lut[i].blue = b; + } + + return lut; +} + void set_degamma(data_t *data, igt_pipe_t *pipe, const gamma_lut_t *gamma) @@ -203,6 +230,15 @@ void set_degamma(data_t *data, free(lut); } +void set_pipe_gamma(igt_pipe_t *pipe, + uint64_t value, + struct drm_color_lut *lut, + uint32_t size) +{ + igt_pipe_obj_set_prop_value(pipe, IGT_CRTC_GAMMA_MODE, value); + igt_pipe_obj_replace_prop_blob(pipe, IGT_CRTC_GAMMA_LUT, lut, size); +} + void set_gamma(data_t *data, igt_pipe_t *pipe, const gamma_lut_t *gamma) { @@ -241,6 +277,51 @@ void disable_prop(igt_pipe_t *pipe, enum igt_atomic_crtc_properties prop) igt_pipe_obj_replace_prop_blob(pipe, prop, NULL, 0); } +drmModePropertyPtr get_pipe_gamma_degamma_mode(igt_pipe_t *pipe, + enum igt_atomic_crtc_properties prop) +{ + igt_display_t *display = pipe->display; + uint32_t prop_id = pipe->props[prop]; + drmModePropertyPtr drmProp; + + igt_assert(prop_id); + + drmProp = drmModeGetProperty(display->drm_fd, prop_id); + + igt_assert(drmProp); + igt_assert(drmProp->count_enums); + + return drmProp; +} + +gamma_lut_t *pipe_create_linear_lut(segment_data_t *info) +{ + uint32_t segment, entry, index = 0; + double val; + int i = 0; + gamma_lut_t *gamma = alloc_lut(info->entries_count); + + igt_assert(gamma); + + gamma->size = info->entries_count; + for (segment = 0; segment < info->segment_count; segment++) { + uint32_t entry_count = info->segment_data[segment].count; + uint32_t start = (segment == 0) ? 0 : (1 << (segment - 1)); + uint32_t end = 1 << segment; + + for (entry = 0; entry < entry_count; entry++) { + val = (index == 0) ? /* First entry is Zero. */ + 0 : start + entry * + ((end - start) * 1.0 / entry_count); + + set_rgb(&gamma->coeffs[i++], val); + index++; + } + } + + return gamma; +} + drmModePropertyPtr get_plane_gamma_degamma_mode(igt_plane_t *plane, enum igt_atomic_plane_properties prop) { @@ -331,6 +412,7 @@ segment_data_t *get_segment_data(data_t *data, info->segment_data = malloc(sizeof(struct drm_color_lut_range) * info->segment_count); igt_assert(info->segment_data); + info->entries_count = 0; for (i = 0; i < info->segment_count; i++) { info->entries_count += lut_range[i].count; info->segment_data[i] = lut_range[i]; @@ -341,6 +423,51 @@ segment_data_t *get_segment_data(data_t *data, return info; } +void set_advance_gamma(data_t *data, igt_pipe_t *pipe, enum gamma_type type) +{ + igt_display_t *display = &data->display; + gamma_lut_t *gamma_log; + drmModePropertyPtr gamma_mode = NULL; + segment_data_t *segment_info = NULL; + struct drm_color_lut *lut = NULL; + int lut_size = 0; + + drmSetClientCap(data->drm_fd, DRM_CLIENT_CAP_ADVANCE_GAMMA_MODES, 1); + gamma_mode = get_pipe_gamma_degamma_mode(pipe, IGT_CRTC_GAMMA_MODE); + + for (int i = 0; i < gamma_mode->count_enums; i++) { + if (!strcmp(gamma_mode->enums[i].name, "logarithmic gamma")) { + segment_info = get_segment_data(data, + gamma_mode->enums[i].value, + gamma_mode->enums[i].name); + lut_size = sizeof(struct drm_color_lut) * + segment_info->entries_count; + if (type == LINEAR_GAMMA) { + gamma_log = pipe_create_linear_lut(segment_info); + lut = coeffs_to_logarithmic_lut(data, + gamma_log, + data->color_depth, + 0); + } else if (type == MAX_GAMMA) { + gamma_log = generate_table_max(segment_info->entries_count); + gamma_log->size = segment_info->entries_count; + lut = coeffs_to_lut(data, gamma_log, + data->color_depth, 0); + } + set_pipe_gamma(pipe, gamma_mode->enums[i].value, + lut, lut_size); + igt_display_commit2(display, display->is_atomic + ? COMMIT_ATOMIC : COMMIT_LEGACY); + break; + } + } + drmSetClientCap(data->drm_fd, DRM_CLIENT_CAP_ADVANCE_GAMMA_MODES, 0); + free(gamma_log); + free(lut); + clear_segment_data(segment_info); + drmModeFreeProperty(gamma_mode); +} + void set_plane_gamma(igt_plane_t *plane, char *mode, struct drm_color_lut_ext *lut, diff --git a/tests/kms_color_helper.h b/tests/kms_color_helper.h index 5a35dcaac1..c863874f0c 100644 --- a/tests/kms_color_helper.h +++ b/tests/kms_color_helper.h @@ -70,6 +70,11 @@ typedef struct { uint32_t entries_count; } segment_data_t; +enum gamma_type { + LINEAR_GAMMA, + MAX_GAMMA +}; + #define MIN(a, b) ((a) < (b) ? (a) : (b)) void paint_gradient_rectangles(data_t *data, @@ -89,6 +94,10 @@ struct drm_color_lut *coeffs_to_lut(data_t *data, const gamma_lut_t *gamma, uint32_t color_depth, int off); +struct drm_color_lut *coeffs_to_logarithmic_lut(data_t *data, + const gamma_lut_t *gamma, + uint32_t color_depth, + int off); void set_degamma(data_t *data, igt_pipe_t *pipe, const gamma_lut_t *gamma); @@ -98,12 +107,19 @@ void set_gamma(data_t *data, void set_ctm(igt_pipe_t *pipe, const double *coefficients); void disable_prop(igt_pipe_t *pipe, enum igt_atomic_crtc_properties prop); +drmModePropertyPtr get_pipe_gamma_degamma_mode(igt_pipe_t *pipe, + enum igt_atomic_crtc_properties + prop); drmModePropertyPtr get_plane_gamma_degamma_mode(igt_plane_t *plane, enum igt_atomic_plane_properties prop); void clear_segment_data(segment_data_t *info); +gamma_lut_t *pipe_create_linear_lut(segment_data_t *info); struct drm_color_lut_ext *create_linear_lut(segment_data_t *info); struct drm_color_lut_ext *create_max_lut(segment_data_t *info); segment_data_t *get_segment_data(data_t *data, uint64_t blob_id, char *mode); +void set_pipe_gamma(igt_pipe_t *pipe, uint64_t value, + struct drm_color_lut *lut, uint32_t size); +void set_advance_gamma(data_t *data, igt_pipe_t *pipe, enum gamma_type type); void set_plane_gamma(igt_plane_t *plane, char *mode, struct drm_color_lut_ext *lut, uint32_t size); void set_plane_degamma(igt_plane_t *plane, From patchwork Mon Nov 15 09:47:58 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Modem, Bhanuprakash" X-Patchwork-Id: 12619211 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id CA328C433EF for ; Mon, 15 Nov 2021 09:51:08 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 8902A615E1 for ; Mon, 15 Nov 2021 09:51:08 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 8902A615E1 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=intel.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 67BB46EC9F; Mon, 15 Nov 2021 09:51:06 +0000 (UTC) Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by gabe.freedesktop.org (Postfix) with ESMTPS id 1A4366EC2B; Mon, 15 Nov 2021 09:51:04 +0000 (UTC) X-IronPort-AV: E=McAfee;i="6200,9189,10168"; a="232133819" X-IronPort-AV: E=Sophos;i="5.87,236,1631602800"; d="scan'208";a="232133819" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Nov 2021 01:50:59 -0800 X-IronPort-AV: E=Sophos;i="5.87,236,1631602800"; d="scan'208";a="535447334" Received: from bhanu-nuclab.iind.intel.com ([10.145.162.173]) by orsmga001-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Nov 2021 01:50:56 -0800 From: Bhanuprakash Modem To: igt-dev@lists.freedesktop.org, dri-devel@lists.freedesktop.org Subject: [i-g-t 13/14] tests/kms_color: Extended IGT tests to support logarithmic gamma mode Date: Mon, 15 Nov 2021 15:17:58 +0530 Message-Id: <20211115094759.520955-14-bhanuprakash.modem@intel.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20211115094759.520955-1-bhanuprakash.modem@intel.com> References: <20211115094759.520955-1-bhanuprakash.modem@intel.com> MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mukunda Pramodh Kumar , Juha-Pekka Heikkila , Uma Shankar , Bhanuprakash Modem Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Mukunda Pramodh Kumar Extended IGT tests to support logarithmic gamma mode on pipe Cc: Harry Wentland Cc: Ville Syrjälä Cc: Juha-Pekka Heikkila Cc: Uma Shankar Signed-off-by: Mukunda Pramodh Kumar Signed-off-by: Bhanuprakash Modem --- tests/kms_color.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/tests/kms_color.c b/tests/kms_color.c index d9fe417ba9..00742afaaf 100644 --- a/tests/kms_color.c +++ b/tests/kms_color.c @@ -232,8 +232,6 @@ static void test_pipe_gamma(data_t *data, igt_require(igt_pipe_obj_has_prop(primary->pipe, IGT_CRTC_GAMMA_LUT)); - gamma_full = generate_table_max(data->gamma_lut_size); - output = igt_get_single_output_for_pipe(&data->display, primary->pipe->pipe); igt_require(output); @@ -258,10 +256,13 @@ static void test_pipe_gamma(data_t *data, igt_assert(fb_modeset_id); igt_plane_set_fb(primary, &fb_modeset); + /* Reset Color properties */ disable_ctm(primary->pipe); disable_degamma(primary->pipe); - set_gamma(data, primary->pipe, gamma_full); + disable_gamma(primary->pipe); igt_display_commit(&data->display); + igt_wait_for_vblank(data->drm_fd, + display->pipes[primary->pipe->pipe].crtc_offset); /* Draw solid colors with no gamma transformation. */ paint_rectangles(data, mode, red_green_blue, &fb); @@ -274,6 +275,13 @@ static void test_pipe_gamma(data_t *data, /* Draw a gradient with gamma LUT to remap all values * to max red/green/blue. */ + if (igt_pipe_obj_has_prop(primary->pipe, IGT_CRTC_GAMMA_MODE)) { + set_advance_gamma(data, primary->pipe, MAX_GAMMA); + } else { + gamma_full = generate_table_max(data->gamma_lut_size); + set_gamma(data, primary->pipe, gamma_full); + igt_display_commit(&data->display); + } paint_gradient_rectangles(data, mode, red_green_blue, &fb); igt_plane_set_fb(primary, &fb); igt_display_commit(&data->display); @@ -581,7 +589,10 @@ static bool test_pipe_ctm(data_t *data, */ if (memcmp(before, after, sizeof(color_t))) { set_degamma(data, primary->pipe, degamma_linear); - set_gamma(data, primary->pipe, gamma_linear); + if (igt_pipe_obj_has_prop(primary->pipe, IGT_CRTC_GAMMA_MODE)) + disable_gamma(primary->pipe); + else + set_gamma(data, primary->pipe, gamma_linear); } else { /* Disable Degamma and Gamma for ctm max test */ disable_degamma(primary->pipe); From patchwork Mon Nov 15 09:47:59 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Modem, Bhanuprakash" X-Patchwork-Id: 12619209 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4C946C433FE for ; Mon, 15 Nov 2021 09:51:07 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 1C034615E1 for ; Mon, 15 Nov 2021 09:51:07 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 1C034615E1 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=intel.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 28F3A6EC9B; Mon, 15 Nov 2021 09:51:06 +0000 (UTC) Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by gabe.freedesktop.org (Postfix) with ESMTPS id DD03D6ECA3; Mon, 15 Nov 2021 09:51:04 +0000 (UTC) X-IronPort-AV: E=McAfee;i="6200,9189,10168"; a="232133824" X-IronPort-AV: E=Sophos;i="5.87,236,1631602800"; d="scan'208";a="232133824" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Nov 2021 01:51:03 -0800 X-IronPort-AV: E=Sophos;i="5.87,236,1631602800"; d="scan'208";a="535447391" Received: from bhanu-nuclab.iind.intel.com ([10.145.162.173]) by orsmga001-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Nov 2021 01:50:59 -0800 From: Bhanuprakash Modem To: igt-dev@lists.freedesktop.org, dri-devel@lists.freedesktop.org Subject: [i-g-t 14/14] tests/kms_color_chamelium: Extended IGT tests to support logarithmic gamma mode Date: Mon, 15 Nov 2021 15:17:59 +0530 Message-Id: <20211115094759.520955-15-bhanuprakash.modem@intel.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20211115094759.520955-1-bhanuprakash.modem@intel.com> References: <20211115094759.520955-1-bhanuprakash.modem@intel.com> MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kunal Joshi , Mukunda Pramodh Kumar , Juha-Pekka Heikkila , Uma Shankar , Bhanuprakash Modem Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Extended IGT tests to support logarithmic gamma mode on pipe Cc: Harry Wentland Cc: Ville Syrjälä Cc: Juha-Pekka Heikkila Cc: Kunal Joshi Cc: Uma Shankar Signed-off-by: Mukunda Pramodh Kumar Signed-off-by: Bhanuprakash Modem --- tests/kms_color_chamelium.c | 40 ++++++++++++++++++++++++++++++++++--- 1 file changed, 37 insertions(+), 3 deletions(-) diff --git a/tests/kms_color_chamelium.c b/tests/kms_color_chamelium.c index af820565d3..26e940f4c1 100644 --- a/tests/kms_color_chamelium.c +++ b/tests/kms_color_chamelium.c @@ -317,10 +317,21 @@ static void test_pipe_gamma(data_t *data, igt_assert(fbref_id); igt_plane_set_fb(primary, &fb_modeset); + + /* Reset the color properties */ disable_ctm(primary->pipe); disable_degamma(primary->pipe); - set_gamma(data, primary->pipe, gamma_full); + disable_gamma(primary->pipe); igt_display_commit(&data->display); + igt_wait_for_vblank(data->drm_fd, + data->display.pipes[primary->pipe->pipe].crtc_offset); + + if (igt_pipe_obj_has_prop(primary->pipe, IGT_CRTC_GAMMA_MODE)) { + set_advance_gamma(data, primary->pipe, MAX_GAMMA); + } else { + set_gamma(data, primary->pipe, gamma_full); + igt_display_commit(&data->display); + } /* Draw solid colors with no gamma transformation. */ paint_rectangles(data, mode, red_green_blue, &fbref); @@ -343,6 +354,7 @@ static void test_pipe_gamma(data_t *data, frame_fullcolors, &fbref, CHAMELIUM_CHECK_ANALOG); + /* Cleanup */ disable_gamma(primary->pipe); igt_plane_set_fb(primary, NULL); igt_output_set_pipe(output, PIPE_NONE); @@ -431,7 +443,10 @@ static bool test_pipe_ctm(data_t *data, if (memcmp(before, after, sizeof(color_t))) { set_degamma(data, primary->pipe, degamma_linear); - set_gamma(data, primary->pipe, gamma_linear); + if (igt_pipe_obj_has_prop(primary->pipe, IGT_CRTC_GAMMA_MODE)) + disable_gamma(primary->pipe); + else + set_gamma(data, primary->pipe, gamma_linear); } else { /* Disable Degamma and Gamma for ctm max test */ disable_degamma(primary->pipe); @@ -465,6 +480,12 @@ static bool test_pipe_ctm(data_t *data, igt_output_set_pipe(output, PIPE_NONE); } + /* Cleanup */ + disable_gamma(primary->pipe); + disable_degamma(primary->pipe); + disable_ctm(primary->pipe); + igt_display_commit(&data->display); + free_lut(degamma_linear); free_lut(gamma_linear); @@ -561,7 +582,14 @@ static void test_pipe_limited_range_ctm(data_t *data, igt_plane_set_fb(primary, &fb_modeset); set_degamma(data, primary->pipe, degamma_linear); - set_gamma(data, primary->pipe, gamma_linear); + /* + * No need of linear gamma for limited range ctm test + * Not extending for new API interface. + */ + if (igt_pipe_obj_has_prop(primary->pipe, IGT_CRTC_GAMMA_MODE)) + disable_gamma(primary->pipe); + else + set_gamma(data, primary->pipe, gamma_linear); set_ctm(primary->pipe, ctm); igt_output_set_prop_value(output, @@ -598,6 +626,12 @@ static void test_pipe_limited_range_ctm(data_t *data, } + /* Cleanup */ + disable_gamma(primary->pipe); + disable_degamma(primary->pipe); + disable_ctm(primary->pipe); + igt_display_commit(&data->display); + free_lut(gamma_linear); free_lut(degamma_linear);