From patchwork Fri Aug 26 21:34:51 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?VmlsbGUgU3lyasOkbMOk?= X-Patchwork-Id: 12956617 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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id D8122ECAAD8 for ; Fri, 26 Aug 2022 21:35:29 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id D810F10E67B; Fri, 26 Aug 2022 21:35:11 +0000 (UTC) Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by gabe.freedesktop.org (Postfix) with ESMTPS id 5A6BB10E58D; Fri, 26 Aug 2022 21:35:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1661549708; x=1693085708; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Zeah7v6GaWnNvFKIevAHE4ahpJl4lFSOFUV+cp0a/cM=; b=V+vzUGEHdujtfeQdGFrjTuVz7xgdq3Nvc/aRGeQl80V+3QeG/ckory2p 3F136gVzdC6jaAa4L6FZ4tSb9HYu0AAKauTaT/DSg6YTTuCmKv2osji7z yp1eyL4P3iPL6WhThrZujTX2LfxwAqVSI4c+YFU/10OmNfct/fOSYbz09 SuCcNxOvriYapFO9LfQ62jrpchKYN7dOFWwdSMU/1pjpR5KR3bc7N5L+z mY+jan4Slq06wapz8aqfUdt4M1m7v7xAuZF70yJ4gUffhirEIeEogjuJT 30tU1Q/VWt6hmNt3Me69Ep2L+Xeg5LiAlWoNB0LOtpGctFuD/TfKuc1PV w==; X-IronPort-AV: E=McAfee;i="6500,9779,10451"; a="380902785" X-IronPort-AV: E=Sophos;i="5.93,266,1654585200"; d="scan'208";a="380902785" Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Aug 2022 14:35:07 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.93,266,1654585200"; d="scan'208";a="613657785" Received: from stinkpipe.fi.intel.com (HELO stinkbox) ([10.237.72.191]) by fmsmga007.fm.intel.com with SMTP; 26 Aug 2022 14:35:05 -0700 Received: by stinkbox (sSMTP sendmail emulation); Sat, 27 Aug 2022 00:35:04 +0300 From: Ville Syrjala To: dri-devel@lists.freedesktop.org Subject: [PATCH 01/11] drm/edid: Handle EDID 1.4 range descriptor h/vfreq offsets Date: Sat, 27 Aug 2022 00:34:51 +0300 Message-Id: <20220826213501.31490-2-ville.syrjala@linux.intel.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220826213501.31490-1-ville.syrjala@linux.intel.com> References: <20220826213501.31490-1-ville.syrjala@linux.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: Jani Nikula , intel-gfx@lists.freedesktop.org, stable@vger.kernel.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Ville Syrjälä EDID 1.4 introduced some extra flags in the range descriptor to support min/max h/vfreq >= 255. Consult them to correctly parse the vfreq limits. Note that some combinations of the flags are documented as "reserved" (as are some other values in the descriptor) but explicitly checking for those doesn't seem particularly worthwile since we end up with bogus results whether we decode them or not. v2: Increase the storage to u16 to make it work (Jani) Note the "reserved" values situation (Jani) v3: Document the EDID version number in the defines Drop some bogus (u8) casts Cc: stable@vger.kernel.org Closes: https://gitlab.freedesktop.org/drm/intel/-/issues/6519 Reviewed-by: Jani Nikula Signed-off-by: Ville Syrjälä Reviewed-by: Manasi Navare --- drivers/gpu/drm/drm_debugfs.c | 4 ++-- drivers/gpu/drm/drm_edid.c | 24 ++++++++++++++++++------ include/drm/drm_connector.h | 4 ++-- include/drm/drm_edid.h | 5 +++++ 4 files changed, 27 insertions(+), 10 deletions(-) diff --git a/drivers/gpu/drm/drm_debugfs.c b/drivers/gpu/drm/drm_debugfs.c index 493922069c90..01ee3febb813 100644 --- a/drivers/gpu/drm/drm_debugfs.c +++ b/drivers/gpu/drm/drm_debugfs.c @@ -377,8 +377,8 @@ static int vrr_range_show(struct seq_file *m, void *data) if (connector->status != connector_status_connected) return -ENODEV; - seq_printf(m, "Min: %u\n", (u8)connector->display_info.monitor_range.min_vfreq); - seq_printf(m, "Max: %u\n", (u8)connector->display_info.monitor_range.max_vfreq); + seq_printf(m, "Min: %u\n", connector->display_info.monitor_range.min_vfreq); + seq_printf(m, "Max: %u\n", connector->display_info.monitor_range.max_vfreq); return 0; } diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c index 90a5e26eafa8..4005dab6147d 100644 --- a/drivers/gpu/drm/drm_edid.c +++ b/drivers/gpu/drm/drm_edid.c @@ -6020,12 +6020,14 @@ static void drm_parse_cea_ext(struct drm_connector *connector, } static -void get_monitor_range(const struct detailed_timing *timing, - void *info_monitor_range) +void get_monitor_range(const struct detailed_timing *timing, void *c) { - struct drm_monitor_range_info *monitor_range = info_monitor_range; + struct detailed_mode_closure *closure = c; + struct drm_display_info *info = &closure->connector->display_info; + struct drm_monitor_range_info *monitor_range = &info->monitor_range; const struct detailed_non_pixel *data = &timing->data.other_data; const struct detailed_data_monitor_range *range = &data->data.range; + const struct edid *edid = closure->drm_edid->edid; if (!is_display_descriptor(timing, EDID_DETAIL_MONITOR_RANGE)) return; @@ -6041,18 +6043,28 @@ void get_monitor_range(const struct detailed_timing *timing, monitor_range->min_vfreq = range->min_vfreq; monitor_range->max_vfreq = range->max_vfreq; + + if (edid->revision >= 4) { + if (data->pad2 & DRM_EDID_RANGE_OFFSET_MIN_VFREQ) + monitor_range->min_vfreq += 255; + if (data->pad2 & DRM_EDID_RANGE_OFFSET_MAX_VFREQ) + monitor_range->max_vfreq += 255; + } } static void drm_get_monitor_range(struct drm_connector *connector, const struct drm_edid *drm_edid) { - struct drm_display_info *info = &connector->display_info; + const struct drm_display_info *info = &connector->display_info; + struct detailed_mode_closure closure = { + .connector = connector, + .drm_edid = drm_edid, + }; if (!version_greater(drm_edid, 1, 1)) return; - drm_for_each_detailed_block(drm_edid, get_monitor_range, - &info->monitor_range); + drm_for_each_detailed_block(drm_edid, get_monitor_range, &closure); DRM_DEBUG_KMS("Supported Monitor Refresh rate range is %d Hz - %d Hz\n", info->monitor_range.min_vfreq, diff --git a/include/drm/drm_connector.h b/include/drm/drm_connector.h index 248206bbd975..56aee949c6fa 100644 --- a/include/drm/drm_connector.h +++ b/include/drm/drm_connector.h @@ -319,8 +319,8 @@ enum drm_panel_orientation { * EDID's detailed monitor range */ struct drm_monitor_range_info { - u8 min_vfreq; - u8 max_vfreq; + u16 min_vfreq; + u16 max_vfreq; }; /** diff --git a/include/drm/drm_edid.h b/include/drm/drm_edid.h index 2181977ae683..1ed61e2b30a4 100644 --- a/include/drm/drm_edid.h +++ b/include/drm/drm_edid.h @@ -92,6 +92,11 @@ struct detailed_data_string { u8 str[13]; } __attribute__((packed)); +#define DRM_EDID_RANGE_OFFSET_MIN_VFREQ (1 << 0) /* 1.4 */ +#define DRM_EDID_RANGE_OFFSET_MAX_VFREQ (1 << 1) /* 1.4 */ +#define DRM_EDID_RANGE_OFFSET_MIN_HFREQ (1 << 2) /* 1.4 */ +#define DRM_EDID_RANGE_OFFSET_MAX_HFREQ (1 << 3) /* 1.4 */ + #define DRM_EDID_DEFAULT_GTF_SUPPORT_FLAG 0x00 #define DRM_EDID_RANGE_LIMITS_ONLY_FLAG 0x01 #define DRM_EDID_SECONDARY_GTF_SUPPORT_FLAG 0x02 From patchwork Fri Aug 26 21:34:52 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?VmlsbGUgU3lyasOkbMOk?= X-Patchwork-Id: 12956619 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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 2B861ECAAD8 for ; Fri, 26 Aug 2022 21:35:57 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id E5DA010E6BF; Fri, 26 Aug 2022 21:35:28 +0000 (UTC) Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by gabe.freedesktop.org (Postfix) with ESMTPS id E127E10E67A; Fri, 26 Aug 2022 21:35:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1661549712; x=1693085712; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=vzjV6RnMuk1xiiGIvqKRgHvcl9T/Jk16mhcYH7c3r5Y=; b=lkt7dh/vqHV+f5Kxct1ZMZ9sb53lUEgGijY2Jb5N7zEjoQ/OIPmoO8ma JusoiZ7RJQzynuFOIJ+QCBBoY7rrd3ZVVWXRnVEhG12p4ywCwneXyhVvM qyMOLuaWRgapGz5i6ittyNZT0zNDxA/nLa2m8mPh2HvEe3ZqvAFXhpB1K nx3PBgjDblbMdEqayll4yZ7Q97/nldgS5+iIEe3+SxiYG9EOtXLigxxIi x5OmXxfLz3ics87rIk5NU57vTzlMqsSUhf/fF9xj5h7IdNmS5QHwLt+Rm 5FuaJxAV8Gu8cKZ0uBlk+q4z4VECg2EM+Ot1Gm0qJ7lbV2igNlZASTchU Q==; X-IronPort-AV: E=McAfee;i="6500,9779,10451"; a="274350256" X-IronPort-AV: E=Sophos;i="5.93,266,1654585200"; d="scan'208";a="274350256" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Aug 2022 14:35:12 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.93,266,1654585200"; d="scan'208";a="606892807" Received: from stinkpipe.fi.intel.com (HELO stinkbox) ([10.237.72.191]) by orsmga007.jf.intel.com with SMTP; 26 Aug 2022 14:35:08 -0700 Received: by stinkbox (sSMTP sendmail emulation); Sat, 27 Aug 2022 00:35:07 +0300 From: Ville Syrjala To: dri-devel@lists.freedesktop.org Subject: [PATCH 02/11] drm/edid: Clarify why we only accept the "range limits only" descriptor Date: Sat, 27 Aug 2022 00:34:52 +0300 Message-Id: <20220826213501.31490-3-ville.syrjala@linux.intel.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220826213501.31490-1-ville.syrjala@linux.intel.com> References: <20220826213501.31490-1-ville.syrjala@linux.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: Leo Li , intel-gfx@lists.freedesktop.org, Rodrigo Siqueira , amd-gfx@lists.freedesktop.org, Manasi Navare , Nicholas Kazlauskas Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Ville Syrjälä The current comment fails to clarify why we only accept the "range limits only" variant of the range descriptor. Reword it to make some actual sense. Cc: Manasi Navare Cc: Nicholas Kazlauskas Cc: Harry Wentland Cc: Leo Li Cc: Rodrigo Siqueira Cc: amd-gfx@lists.freedesktop.org Signed-off-by: Ville Syrjälä Reviewed-by: Manasi Navare --- drivers/gpu/drm/drm_edid.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c index 4005dab6147d..ac662495635c 100644 --- a/drivers/gpu/drm/drm_edid.c +++ b/drivers/gpu/drm/drm_edid.c @@ -6033,10 +6033,13 @@ void get_monitor_range(const struct detailed_timing *timing, void *c) return; /* - * Check for flag range limits only. If flag == 1 then - * no additional timing information provided. - * Default GTF, GTF Secondary curve and CVT are not - * supported + * These limits are used to determine the VRR refresh + * rate range. Only the "range limits only" variant + * of the range descriptor seems to guarantee that + * any and all timings are accepted by the sink, as + * opposed to just timings conforming to the indicated + * formula (GTF/GTF2/CVT). Thus other variants of the + * range descriptor are not accepted here. */ if (range->flags != DRM_EDID_RANGE_LIMITS_ONLY_FLAG) return; From patchwork Fri Aug 26 21:34:53 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?VmlsbGUgU3lyasOkbMOk?= X-Patchwork-Id: 12956618 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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 058CAECAAD8 for ; Fri, 26 Aug 2022 21:35:51 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id D747610E6D7; Fri, 26 Aug 2022 21:35:26 +0000 (UTC) Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by gabe.freedesktop.org (Postfix) with ESMTPS id A2F1910E68E; Fri, 26 Aug 2022 21:35:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1661549717; x=1693085717; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=h5GLVAWn6TeUAI6z0ZQVoyQ3+H0lY8ShRy+X/nma/Pk=; b=GwoviN0EfcywR/GeEdoT/3wdPivukLFKGVTJZLZrzn20DrRCQPcJsCsi RI5gkSiSl2U6YxiCU/JzVgQKTd/lWvpNyoMJCiLcLwUL8L1OMG+8C5oQg 9+giJ2slDJL9O3zcG4ADAKlEYEf4CDpJPEdZWTIqJNifpgRz0O69eaybP F+JUUFgnw49okGFvPCYsvOTainpTIz8FAMOrVEGgsa+aRLLwz/4plGhEy ghYS5l+VfIakRJZZD4ugEexKYTYMy2R/O611CjJVhhZUTLq4z011N9OyF z7S/5DNTOYpfgQn6HLBlhPtTIyh8o//qiu1BPvwIvaJCq50VGYtSTHz13 Q==; X-IronPort-AV: E=McAfee;i="6500,9779,10451"; a="275002355" X-IronPort-AV: E=Sophos;i="5.93,266,1654585200"; d="scan'208";a="275002355" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Aug 2022 14:35:16 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.93,266,1654585200"; d="scan'208";a="671624275" Received: from stinkpipe.fi.intel.com (HELO stinkbox) ([10.237.72.191]) by fmsmga008.fm.intel.com with SMTP; 26 Aug 2022 14:35:12 -0700 Received: by stinkbox (sSMTP sendmail emulation); Sat, 27 Aug 2022 00:35:12 +0300 From: Ville Syrjala To: dri-devel@lists.freedesktop.org Subject: [PATCH 03/11] drm/edid: s/monitor_rage/vrr_range/ Date: Sat, 27 Aug 2022 00:34:53 +0300 Message-Id: <20220826213501.31490-4-ville.syrjala@linux.intel.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220826213501.31490-1-ville.syrjala@linux.intel.com> References: <20220826213501.31490-1-ville.syrjala@linux.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: Leo Li , intel-gfx@lists.freedesktop.org, Rodrigo Siqueira , amd-gfx@lists.freedesktop.org, Manasi Navare , Nicholas Kazlauskas Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Ville Syrjälä Rename info->monitor_range to info->vrr_range to actually reflect its usage. Cc: Manasi Navare Cc: Nicholas Kazlauskas Cc: Harry Wentland Cc: Leo Li Cc: Rodrigo Siqueira Cc: amd-gfx@lists.freedesktop.org Signed-off-by: Ville Syrjälä Reviewed-by: Manasi Navare Acked-by: Jani Nikula --- .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 12 ++++----- drivers/gpu/drm/drm_debugfs.c | 4 +-- drivers/gpu/drm/drm_edid.c | 26 +++++++++---------- drivers/gpu/drm/i915/display/intel_vrr.c | 6 ++--- include/drm/drm_connector.h | 4 +-- 5 files changed, 26 insertions(+), 26 deletions(-) diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c index e702f0d72d53..928b5b6541db 100644 --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c @@ -9921,8 +9921,8 @@ void amdgpu_dm_update_freesync_caps(struct drm_connector *connector, amdgpu_dm_connector->min_vfreq = 0; amdgpu_dm_connector->max_vfreq = 0; amdgpu_dm_connector->pixel_clock_mhz = 0; - connector->display_info.monitor_range.min_vfreq = 0; - connector->display_info.monitor_range.max_vfreq = 0; + connector->display_info.vrr_range.min_vfreq = 0; + connector->display_info.vrr_range.max_vfreq = 0; freesync_capable = false; goto update; @@ -9970,8 +9970,8 @@ void amdgpu_dm_update_freesync_caps(struct drm_connector *connector, amdgpu_dm_connector->pixel_clock_mhz = range->pixel_clock_mhz * 10; - connector->display_info.monitor_range.min_vfreq = range->min_vfreq; - connector->display_info.monitor_range.max_vfreq = range->max_vfreq; + connector->display_info.vrr_range.min_vfreq = range->min_vfreq; + connector->display_info.vrr_range.max_vfreq = range->max_vfreq; break; } @@ -9993,8 +9993,8 @@ void amdgpu_dm_update_freesync_caps(struct drm_connector *connector, if (amdgpu_dm_connector->max_vfreq - amdgpu_dm_connector->min_vfreq > 10) freesync_capable = true; - connector->display_info.monitor_range.min_vfreq = vsdb_info.min_refresh_rate_hz; - connector->display_info.monitor_range.max_vfreq = vsdb_info.max_refresh_rate_hz; + connector->display_info.vrr_range.min_vfreq = vsdb_info.min_refresh_rate_hz; + connector->display_info.vrr_range.max_vfreq = vsdb_info.max_refresh_rate_hz; } } diff --git a/drivers/gpu/drm/drm_debugfs.c b/drivers/gpu/drm/drm_debugfs.c index 01ee3febb813..1437c798b122 100644 --- a/drivers/gpu/drm/drm_debugfs.c +++ b/drivers/gpu/drm/drm_debugfs.c @@ -377,8 +377,8 @@ static int vrr_range_show(struct seq_file *m, void *data) if (connector->status != connector_status_connected) return -ENODEV; - seq_printf(m, "Min: %u\n", connector->display_info.monitor_range.min_vfreq); - seq_printf(m, "Max: %u\n", connector->display_info.monitor_range.max_vfreq); + seq_printf(m, "Min: %u\n", connector->display_info.vrr_range.min_vfreq); + seq_printf(m, "Max: %u\n", connector->display_info.vrr_range.max_vfreq); return 0; } diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c index ac662495635c..4355d73632c3 100644 --- a/drivers/gpu/drm/drm_edid.c +++ b/drivers/gpu/drm/drm_edid.c @@ -6020,11 +6020,11 @@ static void drm_parse_cea_ext(struct drm_connector *connector, } static -void get_monitor_range(const struct detailed_timing *timing, void *c) +void get_vrr_range(const struct detailed_timing *timing, void *c) { struct detailed_mode_closure *closure = c; struct drm_display_info *info = &closure->connector->display_info; - struct drm_monitor_range_info *monitor_range = &info->monitor_range; + struct drm_monitor_range_info *vrr_range = &info->vrr_range; const struct detailed_non_pixel *data = &timing->data.other_data; const struct detailed_data_monitor_range *range = &data->data.range; const struct edid *edid = closure->drm_edid->edid; @@ -6044,19 +6044,19 @@ void get_monitor_range(const struct detailed_timing *timing, void *c) if (range->flags != DRM_EDID_RANGE_LIMITS_ONLY_FLAG) return; - monitor_range->min_vfreq = range->min_vfreq; - monitor_range->max_vfreq = range->max_vfreq; + vrr_range->min_vfreq = range->min_vfreq; + vrr_range->max_vfreq = range->max_vfreq; if (edid->revision >= 4) { if (data->pad2 & DRM_EDID_RANGE_OFFSET_MIN_VFREQ) - monitor_range->min_vfreq += 255; + vrr_range->min_vfreq += 255; if (data->pad2 & DRM_EDID_RANGE_OFFSET_MAX_VFREQ) - monitor_range->max_vfreq += 255; + vrr_range->max_vfreq += 255; } } -static void drm_get_monitor_range(struct drm_connector *connector, - const struct drm_edid *drm_edid) +static void drm_get_vrr_range(struct drm_connector *connector, + const struct drm_edid *drm_edid) { const struct drm_display_info *info = &connector->display_info; struct detailed_mode_closure closure = { @@ -6067,11 +6067,11 @@ static void drm_get_monitor_range(struct drm_connector *connector, if (!version_greater(drm_edid, 1, 1)) return; - drm_for_each_detailed_block(drm_edid, get_monitor_range, &closure); + drm_for_each_detailed_block(drm_edid, get_vrr_range, &closure); DRM_DEBUG_KMS("Supported Monitor Refresh rate range is %d Hz - %d Hz\n", - info->monitor_range.min_vfreq, - info->monitor_range.max_vfreq); + info->vrr_range.min_vfreq, + info->vrr_range.max_vfreq); } static void drm_parse_vesa_mso_data(struct drm_connector *connector, @@ -6164,7 +6164,7 @@ static void drm_reset_display_info(struct drm_connector *connector) info->edid_hdmi_ycbcr444_dc_modes = 0; info->non_desktop = 0; - memset(&info->monitor_range, 0, sizeof(info->monitor_range)); + memset(&info->vrr_range, 0, sizeof(info->vrr_range)); memset(&info->luminance_range, 0, sizeof(info->luminance_range)); info->mso_stream_count = 0; @@ -6184,7 +6184,7 @@ static u32 update_display_info(struct drm_connector *connector, info->width_mm = edid->width_cm * 10; info->height_mm = edid->height_cm * 10; - drm_get_monitor_range(connector, drm_edid); + drm_get_vrr_range(connector, drm_edid); if (edid->revision < 3) goto out; diff --git a/drivers/gpu/drm/i915/display/intel_vrr.c b/drivers/gpu/drm/i915/display/intel_vrr.c index 04250a0fec3c..15bc9b9f2b27 100644 --- a/drivers/gpu/drm/i915/display/intel_vrr.c +++ b/drivers/gpu/drm/i915/display/intel_vrr.c @@ -38,7 +38,7 @@ bool intel_vrr_is_capable(struct intel_connector *connector) } return HAS_VRR(i915) && - info->monitor_range.max_vfreq - info->monitor_range.min_vfreq > 10; + info->vrr_range.max_vfreq - info->vrr_range.min_vfreq > 10; } void @@ -117,9 +117,9 @@ intel_vrr_compute_config(struct intel_crtc_state *crtc_state, return; vmin = DIV_ROUND_UP(adjusted_mode->crtc_clock * 1000, - adjusted_mode->crtc_htotal * info->monitor_range.max_vfreq); + adjusted_mode->crtc_htotal * info->vrr_range.max_vfreq); vmax = adjusted_mode->crtc_clock * 1000 / - (adjusted_mode->crtc_htotal * info->monitor_range.min_vfreq); + (adjusted_mode->crtc_htotal * info->vrr_range.min_vfreq); vmin = max_t(int, vmin, adjusted_mode->crtc_vtotal); vmax = max_t(int, vmax, adjusted_mode->crtc_vtotal); diff --git a/include/drm/drm_connector.h b/include/drm/drm_connector.h index 56aee949c6fa..7ae23d691cd6 100644 --- a/include/drm/drm_connector.h +++ b/include/drm/drm_connector.h @@ -636,9 +636,9 @@ struct drm_display_info { bool non_desktop; /** - * @monitor_range: Frequency range supported by monitor range descriptor + * @vrr_range: Refresh rate range supported by monitor for VRR */ - struct drm_monitor_range_info monitor_range; + struct drm_monitor_range_info vrr_range; /** * @luminance_range: Luminance range supported by panel From patchwork Fri Aug 26 21:34:54 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?VmlsbGUgU3lyasOkbMOk?= X-Patchwork-Id: 12956620 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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id A0BA7ECAAD8 for ; Fri, 26 Aug 2022 21:36:00 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 265B510E6FC; Fri, 26 Aug 2022 21:35:30 +0000 (UTC) Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by gabe.freedesktop.org (Postfix) with ESMTPS id ADC0310E6A0; Fri, 26 Aug 2022 21:35:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1661549719; x=1693085719; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=TXDMWEAcAjk8n+euJh0r9fOVldCET2/TNmI3zs48AwI=; b=VeFMj+mFdgWQQAO7MVHi2V8e4fxdRjF2KwSzT1wfZx+1QanzPIK3iPJU inbJFHnv09O9rXnZQfm7DNQNWCDofjskKQKHLIXFf1E8NaDjkBzTm0wsh RKViezNk96d+CvBrbt1m56SSQ68W8wMwhvcUTSlWdq1dwrd8QGjJGijo3 ydmtRITGBi8kB+04LyuLhguNQCBbGw4vbVXm9M31hDm6D1Fo2Ibiw4hNe k788p3u09bBMnqWQ0RqdOM/eT96XtZ43TJBW5veEP8bPHQMmE7clEJsbD CTnV4XKTLbpS4qKeysr/FDaQRk4kinTgpzYz7ozX57cCaW1bB63PYc9Fh A==; X-IronPort-AV: E=McAfee;i="6500,9779,10451"; a="295870971" X-IronPort-AV: E=Sophos;i="5.93,266,1654585200"; d="scan'208";a="295870971" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Aug 2022 14:35:19 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.93,266,1654585200"; d="scan'208";a="640215062" Received: from stinkpipe.fi.intel.com (HELO stinkbox) ([10.237.72.191]) by orsmga008.jf.intel.com with SMTP; 26 Aug 2022 14:35:16 -0700 Received: by stinkbox (sSMTP sendmail emulation); Sat, 27 Aug 2022 00:35:16 +0300 From: Ville Syrjala To: dri-devel@lists.freedesktop.org Subject: [PATCH 04/11] drm/edid: Define more flags Date: Sat, 27 Aug 2022 00:34:54 +0300 Message-Id: <20220826213501.31490-5-ville.syrjala@linux.intel.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220826213501.31490-1-ville.syrjala@linux.intel.com> References: <20220826213501.31490-1-ville.syrjala@linux.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: intel-gfx@lists.freedesktop.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Ville Syrjälä Replace a bunch of hex constants with proper definitions. Signed-off-by: Ville Syrjälä Reviewed-by: Jani Nikula --- drivers/gpu/drm/drm_edid.c | 18 +++++++++--------- include/drm/drm_edid.h | 14 +++++++++----- 2 files changed, 18 insertions(+), 14 deletions(-) diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c index 4355d73632c3..856d304a1354 100644 --- a/drivers/gpu/drm/drm_edid.c +++ b/drivers/gpu/drm/drm_edid.c @@ -2984,7 +2984,7 @@ is_rb(const struct detailed_timing *descriptor, void *data) BUILD_BUG_ON(offsetof(typeof(*descriptor), data.other_data.data.range.formula.cvt.flags) != 15); if (descriptor->data.other_data.data.range.flags == DRM_EDID_CVT_SUPPORT_FLAG && - descriptor->data.other_data.data.range.formula.cvt.flags & 0x10) + descriptor->data.other_data.data.range.formula.cvt.flags & DRM_EDID_CVT_FLAGS_REDUCED_BLANKING) *res = true; } @@ -3012,7 +3012,7 @@ find_gtf2(const struct detailed_timing *descriptor, void *data) BUILD_BUG_ON(offsetof(typeof(*descriptor), data.other_data.data.range.flags) != 10); - if (descriptor->data.other_data.data.range.flags == 0x02) + if (descriptor->data.other_data.data.range.flags == DRM_EDID_SECONDARY_GTF_SUPPORT_FLAG) *res = descriptor; } @@ -3415,7 +3415,7 @@ range_pixel_clock(const struct edid *edid, const u8 *t) return 0; /* 1.4 with CVT support gives us real precision, yay */ - if (edid->revision >= 4 && t[10] == 0x04) + if (edid->revision >= 4 && t[10] == DRM_EDID_CVT_SUPPORT_FLAG) return (t[9] * 10000) - ((t[12] >> 2) * 250); /* 1.3 is pathetic, so fuzz up a bit */ @@ -3441,7 +3441,7 @@ static bool mode_in_range(const struct drm_display_mode *mode, return false; /* 1.4 max horizontal check */ - if (edid->revision >= 4 && t[10] == 0x04) + if (edid->revision >= 4 && t[10] == DRM_EDID_CVT_SUPPORT_FLAG) if (t[13] && mode->hdisplay > 8 * (t[13] + (256 * (t[12]&0x3)))) return false; @@ -3581,13 +3581,13 @@ do_inferred_modes(const struct detailed_timing *timing, void *c) return; /* GTF not defined yet */ switch (range->flags) { - case 0x02: /* secondary gtf, XXX could do more */ - case 0x00: /* default gtf */ + case DRM_EDID_SECONDARY_GTF_SUPPORT_FLAG: /* XXX could do more */ + case DRM_EDID_DEFAULT_GTF_SUPPORT_FLAG: closure->modes += drm_gtf_modes_for_range(closure->connector, closure->drm_edid, timing); break; - case 0x04: /* cvt, only in 1.4+ */ + case DRM_EDID_CVT_SUPPORT_FLAG: if (!version_greater(closure->drm_edid, 1, 3)) break; @@ -3595,7 +3595,7 @@ do_inferred_modes(const struct detailed_timing *timing, void *c) closure->drm_edid, timing); break; - case 0x01: /* just the ranges, no formula */ + case DRM_EDID_RANGE_LIMITS_ONLY_FLAG: default: break; } @@ -6393,7 +6393,7 @@ static int _drm_edid_connector_update(struct drm_connector *connector, num_modes += add_cea_modes(connector, drm_edid); num_modes += add_alternate_cea_modes(connector, drm_edid); num_modes += add_displayid_detailed_modes(connector, drm_edid); - if (drm_edid->edid->features & DRM_EDID_FEATURE_DEFAULT_GTF) + if (drm_edid->edid->features & DRM_EDID_FEATURE_CONTINUOUS_FREQ) num_modes += add_inferred_modes(connector, drm_edid); if (quirks & (EDID_QUIRK_PREFER_LARGE_60 | EDID_QUIRK_PREFER_LARGE_75)) diff --git a/include/drm/drm_edid.h b/include/drm/drm_edid.h index 1ed61e2b30a4..429735b91f63 100644 --- a/include/drm/drm_edid.h +++ b/include/drm/drm_edid.h @@ -97,10 +97,13 @@ struct detailed_data_string { #define DRM_EDID_RANGE_OFFSET_MIN_HFREQ (1 << 2) /* 1.4 */ #define DRM_EDID_RANGE_OFFSET_MAX_HFREQ (1 << 3) /* 1.4 */ -#define DRM_EDID_DEFAULT_GTF_SUPPORT_FLAG 0x00 -#define DRM_EDID_RANGE_LIMITS_ONLY_FLAG 0x01 -#define DRM_EDID_SECONDARY_GTF_SUPPORT_FLAG 0x02 -#define DRM_EDID_CVT_SUPPORT_FLAG 0x04 +#define DRM_EDID_DEFAULT_GTF_SUPPORT_FLAG 0x00 /* 1.3 */ +#define DRM_EDID_RANGE_LIMITS_ONLY_FLAG 0x01 /* 1.4 */ +#define DRM_EDID_SECONDARY_GTF_SUPPORT_FLAG 0x02 /* 1.3 */ +#define DRM_EDID_CVT_SUPPORT_FLAG 0x04 /* 1.4 */ + +#define DRM_EDID_CVT_FLAGS_STANDARD_BLANKING (1 << 3) +#define DRM_EDID_CVT_FLAGS_REDUCED_BLANKING (1 << 4) struct detailed_data_monitor_range { u8 min_vfreq; @@ -206,7 +209,8 @@ struct detailed_timing { #define DRM_EDID_DIGITAL_TYPE_DP (5 << 0) /* 1.4 */ #define DRM_EDID_DIGITAL_DFP_1_X (1 << 0) /* 1.3 */ -#define DRM_EDID_FEATURE_DEFAULT_GTF (1 << 0) +#define DRM_EDID_FEATURE_DEFAULT_GTF (1 << 0) /* 1.2 */ +#define DRM_EDID_FEATURE_CONTINUOUS_FREQ (1 << 0) /* 1.4 */ #define DRM_EDID_FEATURE_PREFERRED_TIMING (1 << 1) #define DRM_EDID_FEATURE_STANDARD_COLOR (1 << 2) /* If analog */ From patchwork Fri Aug 26 21:34:55 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?VmlsbGUgU3lyasOkbMOk?= X-Patchwork-Id: 12956621 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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 72D02ECAAD8 for ; Fri, 26 Aug 2022 21:36:06 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id E859510E6FB; Fri, 26 Aug 2022 21:35:29 +0000 (UTC) Received: from mga06.intel.com (mga06b.intel.com [134.134.136.31]) by gabe.freedesktop.org (Postfix) with ESMTPS id 1D65810E6D7; Fri, 26 Aug 2022 21:35:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1661549724; x=1693085724; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Z1pbq0Unb+uKrKT2+NJlh/dxpG6pjO0aRXlnYSq7W5M=; b=cFmGnL0ifAMGAlhDzDqWju+HCsOPLg7aLHZYSnasvlXChOyOW703+8/5 wrlUgxFiwsPENa/MioFSFQpXnt4HGdijBaQGiOJU1cPqYQdK2sXE4RR9J tjQdVnEFv3FMW3IFfmTZhBxGv9AEwAmNU8Eept6ZSFmuHdwYox55/gWXE X2MLR7SuWFHb71+jfMvx9tispPEYQiIaH1LN8D7NEbsDU5tZkRjdu1elA pQM9zUgMobxx7BG4RFF9wDn3roIL69bdbmPBEYsTsGQdJOF2D84hu9ddT yHVa7V42ep4ZBBhVWwmTnxSTTVBdSL2hxDSD7soXj/fxfZvY33iZkOABl g==; X-IronPort-AV: E=McAfee;i="6500,9779,10451"; a="356315592" X-IronPort-AV: E=Sophos;i="5.93,266,1654585200"; d="scan'208";a="356315592" Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Aug 2022 14:35:23 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.93,266,1654585200"; d="scan'208";a="587444582" Received: from stinkpipe.fi.intel.com (HELO stinkbox) ([10.237.72.191]) by orsmga006.jf.intel.com with SMTP; 26 Aug 2022 14:35:20 -0700 Received: by stinkbox (sSMTP sendmail emulation); Sat, 27 Aug 2022 00:35:19 +0300 From: Ville Syrjala To: dri-devel@lists.freedesktop.org Subject: [PATCH 05/11] drm/edid: Only parse VRR range for continuous frequency displays Date: Sat, 27 Aug 2022 00:34:55 +0300 Message-Id: <20220826213501.31490-6-ville.syrjala@linux.intel.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220826213501.31490-1-ville.syrjala@linux.intel.com> References: <20220826213501.31490-1-ville.syrjala@linux.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: Leo Li , intel-gfx@lists.freedesktop.org, Rodrigo Siqueira , amd-gfx@lists.freedesktop.org, Manasi Navare , Nicholas Kazlauskas Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Ville Syrjälä Since we only use the parsed vrefresh range to determine if VRR should be supported we should only accept continuous frequency displays here. Cc: Manasi Navare Cc: Nicholas Kazlauskas Cc: Harry Wentland Cc: Leo Li Cc: Rodrigo Siqueira Cc: amd-gfx@lists.freedesktop.org Signed-off-by: Ville Syrjälä Reviewed-by: Jani Nikula --- drivers/gpu/drm/drm_edid.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c index 856d304a1354..b459fdf12b58 100644 --- a/drivers/gpu/drm/drm_edid.c +++ b/drivers/gpu/drm/drm_edid.c @@ -6064,7 +6064,10 @@ static void drm_get_vrr_range(struct drm_connector *connector, .drm_edid = drm_edid, }; - if (!version_greater(drm_edid, 1, 1)) + if (!version_greater(drm_edid, 1, 3)) + return; + + if (!(drm_edid->edid->features & DRM_EDID_FEATURE_CONTINUOUS_FREQ)) return; drm_for_each_detailed_block(drm_edid, get_vrr_range, &closure); From patchwork Fri Aug 26 21:34:56 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?VmlsbGUgU3lyasOkbMOk?= X-Patchwork-Id: 12956626 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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 0EC13C0502E for ; Fri, 26 Aug 2022 21:36:26 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id B4A3710E803; Fri, 26 Aug 2022 21:35:53 +0000 (UTC) Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by gabe.freedesktop.org (Postfix) with ESMTPS id 8116C10E6D8; Fri, 26 Aug 2022 21:35:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1661549727; x=1693085727; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=wa3cllefe8tNwRjOMj8usyvDkEmC5ANY8uff3LM9IwM=; b=F2umXytoNGYkdkiuk6+H+3oVeKsuaxuWakHcblUE3Iut+0S26LDkFFTb zNVlJgcO632vUwj4aleGwRKLayt5qWynE9uYnRCFniEMShz02TJMFjHmz L3kI7zAuKkSrcfz1op506QF1XVzrWj5vh8FL8Vvd2ApNKJq9jJJBsY5KM tF8rHJeSn+XjGcsr1pkxcbwyn1JvftdVHWfNT1GuZ3WMusn/qCGWVoHAa fJP1+q9xQ11cDR9SNQjjxLZRQ3iBD/QRYcK4VP4FSkNYOZpmWcN0cW7xg aOOBqrgpcjenSSunCWhCLldhkMLjxSuiKeryw06Ng7vTr71dFQt7XmBx5 w==; X-IronPort-AV: E=McAfee;i="6500,9779,10451"; a="380902815" X-IronPort-AV: E=Sophos;i="5.93,266,1654585200"; d="scan'208";a="380902815" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Aug 2022 14:35:26 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.93,266,1654585200"; d="scan'208";a="643805802" Received: from stinkpipe.fi.intel.com (HELO stinkbox) ([10.237.72.191]) by orsmga001.jf.intel.com with SMTP; 26 Aug 2022 14:35:24 -0700 Received: by stinkbox (sSMTP sendmail emulation); Sat, 27 Aug 2022 00:35:23 +0300 From: Ville Syrjala To: dri-devel@lists.freedesktop.org Subject: [PATCH 06/11] drm/edid: Extract drm_gtf2_mode() Date: Sat, 27 Aug 2022 00:34:56 +0300 Message-Id: <20220826213501.31490-7-ville.syrjala@linux.intel.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220826213501.31490-1-ville.syrjala@linux.intel.com> References: <20220826213501.31490-1-ville.syrjala@linux.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: intel-gfx@lists.freedesktop.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Ville Syrjälä Extract the GTF vs. GTF2 logic into a separate function. We'll have a second user soon. Signed-off-by: Ville Syrjälä Reviewed-by: Jani Nikula --- drivers/gpu/drm/drm_edid.c | 47 ++++++++++++++++++++++++-------------- 1 file changed, 30 insertions(+), 17 deletions(-) diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c index b459fdf12b58..0c7cbe9b44f5 100644 --- a/drivers/gpu/drm/drm_edid.c +++ b/drivers/gpu/drm/drm_edid.c @@ -3113,6 +3113,35 @@ static int drm_mode_hsync(const struct drm_display_mode *mode) return DIV_ROUND_CLOSEST(mode->clock, mode->htotal); } +static struct drm_display_mode * +drm_gtf2_mode(struct drm_device *dev, + const struct drm_edid *drm_edid, + int hsize, int vsize, int vrefresh_rate) +{ + struct drm_display_mode *mode; + + /* + * This is potentially wrong if there's ever a monitor with + * more than one ranges section, each claiming a different + * secondary GTF curve. Please don't do that. + */ + mode = drm_gtf_mode(dev, hsize, vsize, vrefresh_rate, 0, 0); + if (!mode) + return NULL; + + if (drm_mode_hsync(mode) > drm_gtf2_hbreak(drm_edid)) { + drm_mode_destroy(dev, mode); + mode = drm_gtf_mode_complex(dev, hsize, vsize, + vrefresh_rate, 0, 0, + drm_gtf2_m(drm_edid), + drm_gtf2_2c(drm_edid), + drm_gtf2_k(drm_edid), + drm_gtf2_2j(drm_edid)); + } + + return mode; +} + /* * Take the standard timing params (in this case width, aspect, and refresh) * and convert them into a real mode using CVT/GTF/DMT. @@ -3201,23 +3230,7 @@ static struct drm_display_mode *drm_mode_std(struct drm_connector *connector, mode = drm_gtf_mode(dev, hsize, vsize, vrefresh_rate, 0, 0); break; case LEVEL_GTF2: - /* - * This is potentially wrong if there's ever a monitor with - * more than one ranges section, each claiming a different - * secondary GTF curve. Please don't do that. - */ - mode = drm_gtf_mode(dev, hsize, vsize, vrefresh_rate, 0, 0); - if (!mode) - return NULL; - if (drm_mode_hsync(mode) > drm_gtf2_hbreak(drm_edid)) { - drm_mode_destroy(dev, mode); - mode = drm_gtf_mode_complex(dev, hsize, vsize, - vrefresh_rate, 0, 0, - drm_gtf2_m(drm_edid), - drm_gtf2_2c(drm_edid), - drm_gtf2_k(drm_edid), - drm_gtf2_2j(drm_edid)); - } + mode = drm_gtf2_mode(dev, drm_edid, hsize, vsize, vrefresh_rate); break; case LEVEL_CVT: mode = drm_cvt_mode(dev, hsize, vsize, vrefresh_rate, 0, 0, From patchwork Fri Aug 26 21:34:57 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?VmlsbGUgU3lyasOkbMOk?= X-Patchwork-Id: 12956625 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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 0FB33ECAAD8 for ; Fri, 26 Aug 2022 21:36:21 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 8597810E8B0; Fri, 26 Aug 2022 21:35:46 +0000 (UTC) Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by gabe.freedesktop.org (Postfix) with ESMTPS id B136E10E721; Fri, 26 Aug 2022 21:35:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1661549730; x=1693085730; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=8m7IY/xdcl+XJ7Wk54Y2ANol4C3mdBs2nDMyaOr7POw=; b=d2GGzf4ojACUsu6vPPAt4xhLvOQQ9tj+oyDgeK+Eg+5pLFA1ixpu/wIR 1OAAflZCym/WUcexQXi77oMYaAe6uRZiA/3cEoPcjHXVNaB/8O5/JkPSR BA305xzbUkpU4RUdHfSMhHITwklvfsrYixabHBE0VwrPmig2VCFN1oqgW rqXtsol0Q0fwbcft8DMrtONwonI2I5WIl3eURRIxMjHPNglpyRclbW6c+ d+3oim2d55cZheldFVb/NsHf6siYSwb7RUabU4znnMzZwlKk7wrxwIlM8 LuSph1g8WS44a3Ao/k0nfwiLzYf4HUlA1Lkf1A6/wzftT1dM5G5mLZg8w g==; X-IronPort-AV: E=McAfee;i="6500,9779,10451"; a="295375979" X-IronPort-AV: E=Sophos;i="5.93,266,1654585200"; d="scan'208";a="295375979" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Aug 2022 14:35:29 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.93,266,1654585200"; d="scan'208";a="753006820" Received: from stinkpipe.fi.intel.com (HELO stinkbox) ([10.237.72.191]) by fmsmga001.fm.intel.com with SMTP; 26 Aug 2022 14:35:27 -0700 Received: by stinkbox (sSMTP sendmail emulation); Sat, 27 Aug 2022 00:35:26 +0300 From: Ville Syrjala To: dri-devel@lists.freedesktop.org Subject: [PATCH 07/11] drm/edid: Use GTF2 for inferred modes Date: Sat, 27 Aug 2022 00:34:57 +0300 Message-Id: <20220826213501.31490-8-ville.syrjala@linux.intel.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220826213501.31490-1-ville.syrjala@linux.intel.com> References: <20220826213501.31490-1-ville.syrjala@linux.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: intel-gfx@lists.freedesktop.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Ville Syrjälä For some resaon we only use the secondary GTF curve for the standard timings. Use it for inferred modes as well. Signed-off-by: Ville Syrjälä Reviewed-by: Jani Nikula --- drivers/gpu/drm/drm_edid.c | 35 ++++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c index 0c7cbe9b44f5..fed2bdd55c09 100644 --- a/drivers/gpu/drm/drm_edid.c +++ b/drivers/gpu/drm/drm_edid.c @@ -3546,6 +3546,35 @@ static int drm_gtf_modes_for_range(struct drm_connector *connector, return modes; } +static int drm_gtf2_modes_for_range(struct drm_connector *connector, + const struct drm_edid *drm_edid, + const struct detailed_timing *timing) +{ + int i, modes = 0; + struct drm_display_mode *newmode; + struct drm_device *dev = connector->dev; + + for (i = 0; i < ARRAY_SIZE(extra_modes); i++) { + const struct minimode *m = &extra_modes[i]; + + newmode = drm_gtf2_mode(dev, drm_edid, m->w, m->h, m->r); + if (!newmode) + return modes; + + drm_mode_fixup_1366x768(newmode); + if (!mode_in_range(newmode, drm_edid, timing) || + !valid_inferred_mode(connector, newmode)) { + drm_mode_destroy(dev, newmode); + continue; + } + + drm_mode_probed_add(connector, newmode); + modes++; + } + + return modes; +} + static int drm_cvt_modes_for_range(struct drm_connector *connector, const struct drm_edid *drm_edid, const struct detailed_timing *timing) @@ -3594,7 +3623,11 @@ do_inferred_modes(const struct detailed_timing *timing, void *c) return; /* GTF not defined yet */ switch (range->flags) { - case DRM_EDID_SECONDARY_GTF_SUPPORT_FLAG: /* XXX could do more */ + case DRM_EDID_SECONDARY_GTF_SUPPORT_FLAG: + closure->modes += drm_gtf2_modes_for_range(closure->connector, + closure->drm_edid, + timing); + break; case DRM_EDID_DEFAULT_GTF_SUPPORT_FLAG: closure->modes += drm_gtf_modes_for_range(closure->connector, closure->drm_edid, From patchwork Fri Aug 26 21:34:58 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?VmlsbGUgU3lyasOkbMOk?= X-Patchwork-Id: 12956623 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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id DFDA9C0502A for ; Fri, 26 Aug 2022 21:36:15 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 4086210E77B; Fri, 26 Aug 2022 21:35:44 +0000 (UTC) Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by gabe.freedesktop.org (Postfix) with ESMTPS id 53C1F10E779; Fri, 26 Aug 2022 21:35:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1661549733; x=1693085733; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=ixMKHjHRc8NMDgtENPNmcnCt5JhqC1JOiOHEiREF7tY=; b=IX0qpRTk8cHlZc6j48lkqOLESPx87ZfGCnZHWTnXg++yKJhrJP3+Lcn2 Dcmj0I+Pj3u9e4QAZJICYVTeZcs1/ZL02B/1rGur1SQSIlU53RLk6ew0Q FEjtBCA4OvyaG81i/g+hn21yZaEskqjHCvJ0JRTpBx8b2hzVfw5Hyk9Kg aNY0y9uxcyKXOgg0XS/NFWxQQ25yfVOXW56FIAN9Cefudb0yZE7GBrMEd wDlOfsYikL2FJyW6l+gbLmZs3MUBfYy6D0Qk3wRlise5FFddNKSywkO2R dLImr0LXr6GFV3g0SZYJtubt6zgCwyWiAq7PrCH69V/NzACf/bsn6sB/N g==; X-IronPort-AV: E=McAfee;i="6500,9779,10451"; a="295870991" X-IronPort-AV: E=Sophos;i="5.93,266,1654585200"; d="scan'208";a="295870991" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Aug 2022 14:35:32 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.93,266,1654585200"; d="scan'208";a="699982811" Received: from stinkpipe.fi.intel.com (HELO stinkbox) ([10.237.72.191]) by FMSMGA003.fm.intel.com with SMTP; 26 Aug 2022 14:35:30 -0700 Received: by stinkbox (sSMTP sendmail emulation); Sat, 27 Aug 2022 00:35:29 +0300 From: Ville Syrjala To: dri-devel@lists.freedesktop.org Subject: [PATCH 08/11] drm/edid: Use the correct formula for standard timings Date: Sat, 27 Aug 2022 00:34:58 +0300 Message-Id: <20220826213501.31490-9-ville.syrjala@linux.intel.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220826213501.31490-1-ville.syrjala@linux.intel.com> References: <20220826213501.31490-1-ville.syrjala@linux.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: intel-gfx@lists.freedesktop.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Ville Syrjälä Prefer the timing formula indicated by the range descriptor for generating the non-DMT standard timings. Previously we just used CVT for all EDID 1.4 continuous frequency displays without even checking if the range descriptor indicates otherwise. Now we check the range descriptor first, and fall back to CVT if nothing else was indicated. EDID 1.4 more or less deprecates GTF/GTF2 but there are still a lot of 1.4 EDIDs out there that don't advertise CVT support, so seems safer to use the formula the EDID actually reports as supported. For EDID 1.3 we use GTF2 if indicated (as before), and for EDID 1.2+ we now just use GTF without even checking the feature flag. There seem to be quite a few EDIDs out there that don't set the GTF feature flag but still include a GTF range descriptor and non-DMT standard timings. This to me seems to be roughly what appendix B of EDID 1.4 suggests should be done. Signed-off-by: Ville Syrjälä Reviewed-by: Jani Nikula --- drivers/gpu/drm/drm_edid.c | 49 +++++++++++++++++++++++++++++++------- 1 file changed, 41 insertions(+), 8 deletions(-) diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c index fed2bdd55c09..c1c85b9e1208 100644 --- a/drivers/gpu/drm/drm_edid.c +++ b/drivers/gpu/drm/drm_edid.c @@ -3077,20 +3077,53 @@ drm_gtf2_2j(const struct drm_edid *drm_edid) return descriptor ? descriptor->data.other_data.data.range.formula.gtf2.j : 0; } +static void +get_timing_level(const struct detailed_timing *descriptor, void *data) +{ + int *res = data; + + if (!is_display_descriptor(descriptor, EDID_DETAIL_MONITOR_RANGE)) + return; + + BUILD_BUG_ON(offsetof(typeof(*descriptor), data.other_data.data.range.flags) != 10); + + switch (descriptor->data.other_data.data.range.flags) { + case DRM_EDID_DEFAULT_GTF_SUPPORT_FLAG: + *res = LEVEL_GTF; + break; + case DRM_EDID_SECONDARY_GTF_SUPPORT_FLAG: + *res = LEVEL_GTF2; + break; + case DRM_EDID_CVT_SUPPORT_FLAG: + *res = LEVEL_CVT; + break; + default: + break; + } +} + /* Get standard timing level (CVT/GTF/DMT). */ static int standard_timing_level(const struct drm_edid *drm_edid) { const struct edid *edid = drm_edid->edid; - if (edid->revision >= 2) { - if (edid->revision >= 4 && (edid->features & DRM_EDID_FEATURE_DEFAULT_GTF)) - return LEVEL_CVT; - if (drm_gtf2_hbreak(drm_edid)) - return LEVEL_GTF2; - if (edid->features & DRM_EDID_FEATURE_DEFAULT_GTF) - return LEVEL_GTF; + if (edid->revision >= 4) { + /* + * If the range descriptor doesn't + * indicate otherwise default to CVT + */ + int ret = LEVEL_CVT; + + drm_for_each_detailed_block(drm_edid, get_timing_level, &ret); + + return ret; + } else if (edid->revision >= 3 && drm_gtf2_hbreak(drm_edid)) { + return LEVEL_GTF2; + } else if (edid->revision >= 2) { + return LEVEL_GTF; + } else { + return LEVEL_DMT; } - return LEVEL_DMT; } /* From patchwork Fri Aug 26 21:34:59 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?VmlsbGUgU3lyasOkbMOk?= X-Patchwork-Id: 12956622 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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 18E1BC0502A for ; Fri, 26 Aug 2022 21:36:13 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 70C8110E721; Fri, 26 Aug 2022 21:35:43 +0000 (UTC) Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by gabe.freedesktop.org (Postfix) with ESMTPS id 7B75010E721; Fri, 26 Aug 2022 21:35:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1661549736; x=1693085736; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=DB5pZschjig9iQHOe43WS8LbqM/GAk+L6tjbnGUnMyE=; b=UbFJM2cZehPFaWOnVB8F5kG2gQRpnHIaHty15jnZf7tEnRYC79htodAY g6rI5Mxp88F0+rmLKCRTg3uPSlxMC0M9F4m97y7U3aufeKptGMD778unA jIPaq2o7m874XoKzXMi61Jtgz0v2c232i+JbgbGMwxrKo2XJ9XbtLaZfQ NrjbUQd6MJg0OIyLCHYEFndeqAL03G79/3ZhEjy36uYYl6Viot9LqtUEA s3ZYO12FWgGTw4PCMoGK36Tvv75b8I1wlGPwFT5VS04MyU/VwHEDsV2lP llZZcQzxD3FPLUvUz0fGrUesi0BInaa84bkaje8xLfvrQ2j3sD5k5ooQD g==; X-IronPort-AV: E=McAfee;i="6500,9779,10451"; a="275002386" X-IronPort-AV: E=Sophos;i="5.93,266,1654585200"; d="scan'208";a="275002386" Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Aug 2022 14:35:36 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.93,266,1654585200"; d="scan'208";a="610696225" Received: from stinkpipe.fi.intel.com (HELO stinkbox) ([10.237.72.191]) by orsmga002.jf.intel.com with SMTP; 26 Aug 2022 14:35:33 -0700 Received: by stinkbox (sSMTP sendmail emulation); Sat, 27 Aug 2022 00:35:32 +0300 From: Ville Syrjala To: dri-devel@lists.freedesktop.org Subject: [PATCH 09/11] drm/edid: Unconfuse preferred timing stuff a bit Date: Sat, 27 Aug 2022 00:34:59 +0300 Message-Id: <20220826213501.31490-10-ville.syrjala@linux.intel.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220826213501.31490-1-ville.syrjala@linux.intel.com> References: <20220826213501.31490-1-ville.syrjala@linux.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: intel-gfx@lists.freedesktop.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Ville Syrjälä For EDID 1.4 the first detailed timing is always preferred, for older EDIDs there was a feature flag to indicate the same. While correct, the code setting that up is rather confusing. Restate it in a slightly more straightforward manner. Signed-off-by: Ville Syrjälä Reviewed-by: Jani Nikula --- drivers/gpu/drm/drm_edid.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c index c1c85b9e1208..0fe06e5fd6e0 100644 --- a/drivers/gpu/drm/drm_edid.c +++ b/drivers/gpu/drm/drm_edid.c @@ -3952,13 +3952,14 @@ static int add_detailed_modes(struct drm_connector *connector, struct detailed_mode_closure closure = { .connector = connector, .drm_edid = drm_edid, - .preferred = true, .quirks = quirks, }; - if (closure.preferred && !version_greater(drm_edid, 1, 3)) + if (version_greater(drm_edid, 1, 3)) + closure.preferred = true; /* first detailed timing is always preferred */ + else closure.preferred = - (drm_edid->edid->features & DRM_EDID_FEATURE_PREFERRED_TIMING); + drm_edid->edid->features & DRM_EDID_FEATURE_PREFERRED_TIMING; drm_for_each_detailed_block(drm_edid, do_detailed_mode, &closure); From patchwork Fri Aug 26 21:35:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?VmlsbGUgU3lyasOkbMOk?= X-Patchwork-Id: 12956624 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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 75A6DC0502E for ; Fri, 26 Aug 2022 21:36:18 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id B4B4110E78B; Fri, 26 Aug 2022 21:35:44 +0000 (UTC) Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by gabe.freedesktop.org (Postfix) with ESMTPS id E467110E721; Fri, 26 Aug 2022 21:35:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1661549740; x=1693085740; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=rB93n2Ea1l4UxNRRSWAKvyQF1xIZBsxiWS36+TpFFVM=; b=L87GtEPCFs/oybjSw9wekjy9MBDYgeCB3mYtsDQHYJT9dvPT/3xjvjvk Ua3zUlq9h6/uWa2D41m3k0Nnz7DJlnFR6XQzZemQk0f7SjygTNxyNTGux 9d89X9aqz5fAn8knb0DtSVAFJFwabzCb3eTs1xn0eljykgpfxEO5xB1p5 OaY+xiVMppUER72ys0Sw1UjiDJrlpWHJxITS3cBgn3D6NTsSQN03L3VgD atfxBR+l+0C7oUlniXiYpBPO2N/TVPALKFozI5gc/KtTnu+vnjZJZiowL 5SrmCKS9D46VPvBM3qUbNN0k/14XdxmCgwOiLqNHcGAcEhAQveIH2aAUZ w==; X-IronPort-AV: E=McAfee;i="6500,9779,10451"; a="295375999" X-IronPort-AV: E=Sophos;i="5.93,266,1654585200"; d="scan'208";a="295375999" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Aug 2022 14:35:39 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.93,266,1654585200"; d="scan'208";a="714115536" Received: from stinkpipe.fi.intel.com (HELO stinkbox) ([10.237.72.191]) by fmsmga002.fm.intel.com with SMTP; 26 Aug 2022 14:35:36 -0700 Received: by stinkbox (sSMTP sendmail emulation); Sat, 27 Aug 2022 00:35:36 +0300 From: Ville Syrjala To: dri-devel@lists.freedesktop.org Subject: [PATCH 10/11] drm/edid: Make version checks less convoluted Date: Sat, 27 Aug 2022 00:35:00 +0300 Message-Id: <20220826213501.31490-11-ville.syrjala@linux.intel.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220826213501.31490-1-ville.syrjala@linux.intel.com> References: <20220826213501.31490-1-ville.syrjala@linux.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: intel-gfx@lists.freedesktop.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Ville Syrjälä Get rid of the confusing version_greater() stuff and simply compare edid->revision directly everwhere. Half the places already did it this way, and since we actually reject any EDID with edid->version!=1 it's a perfectly sane thing to do. Signed-off-by: Ville Syrjälä Reviewed-by: Jani Nikula --- drivers/gpu/drm/drm_edid.c | 25 ++++++++----------------- 1 file changed, 8 insertions(+), 17 deletions(-) diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c index 0fe06e5fd6e0..e7f46260dfe7 100644 --- a/drivers/gpu/drm/drm_edid.c +++ b/drivers/gpu/drm/drm_edid.c @@ -1572,15 +1572,6 @@ struct drm_edid { const struct edid *edid; }; -static bool version_greater(const struct drm_edid *drm_edid, - u8 version, u8 revision) -{ - const struct edid *edid = drm_edid->edid; - - return edid->version > version || - (edid->version == version && edid->revision > revision); -} - static int edid_hfeeodb_extension_block_count(const struct edid *edid); static int edid_hfeeodb_block_count(const struct edid *edid) @@ -3652,7 +3643,7 @@ do_inferred_modes(const struct detailed_timing *timing, void *c) closure->drm_edid, timing); - if (!version_greater(closure->drm_edid, 1, 1)) + if (closure->drm_edid->edid->revision < 2) return; /* GTF not defined yet */ switch (range->flags) { @@ -3667,7 +3658,7 @@ do_inferred_modes(const struct detailed_timing *timing, void *c) timing); break; case DRM_EDID_CVT_SUPPORT_FLAG: - if (!version_greater(closure->drm_edid, 1, 3)) + if (closure->drm_edid->edid->revision < 4) break; closure->modes += drm_cvt_modes_for_range(closure->connector, @@ -3688,7 +3679,7 @@ static int add_inferred_modes(struct drm_connector *connector, .drm_edid = drm_edid, }; - if (version_greater(drm_edid, 1, 0)) + if (drm_edid->edid->revision >= 1) drm_for_each_detailed_block(drm_edid, do_inferred_modes, &closure); return closure.modes; @@ -3765,7 +3756,7 @@ static int add_established_modes(struct drm_connector *connector, } } - if (version_greater(drm_edid, 1, 0)) + if (edid->revision >= 1) drm_for_each_detailed_block(drm_edid, do_established_modes, &closure); @@ -3820,7 +3811,7 @@ static int add_standard_modes(struct drm_connector *connector, } } - if (version_greater(drm_edid, 1, 0)) + if (drm_edid->edid->revision >= 1) drm_for_each_detailed_block(drm_edid, do_standard_modes, &closure); @@ -3900,7 +3891,7 @@ add_cvt_modes(struct drm_connector *connector, const struct drm_edid *drm_edid) .drm_edid = drm_edid, }; - if (version_greater(drm_edid, 1, 2)) + if (drm_edid->edid->revision >= 3) drm_for_each_detailed_block(drm_edid, do_cvt_mode, &closure); /* XXX should also look for CVT codes in VTB blocks */ @@ -3955,7 +3946,7 @@ static int add_detailed_modes(struct drm_connector *connector, .quirks = quirks, }; - if (version_greater(drm_edid, 1, 3)) + if (drm_edid->edid->revision >= 4) closure.preferred = true; /* first detailed timing is always preferred */ else closure.preferred = @@ -6144,7 +6135,7 @@ static void drm_get_vrr_range(struct drm_connector *connector, .drm_edid = drm_edid, }; - if (!version_greater(drm_edid, 1, 3)) + if (drm_edid->edid->revision < 4) return; if (!(drm_edid->edid->features & DRM_EDID_FEATURE_CONTINUOUS_FREQ)) From patchwork Fri Aug 26 21:35:01 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?VmlsbGUgU3lyasOkbMOk?= X-Patchwork-Id: 12956627 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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id C10BEC0502C for ; Fri, 26 Aug 2022 21:36:29 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 37BF210E9ED; Fri, 26 Aug 2022 21:35:55 +0000 (UTC) Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by gabe.freedesktop.org (Postfix) with ESMTPS id 42F9D10E721; Fri, 26 Aug 2022 21:35:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1661549742; x=1693085742; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=IVm5RoE2xRo26A3dFvEORqC6SKj0KFr9veRbhuMOuiw=; b=RXguaAvECFe0hCBYqQEEIJzn0Zgo72Bam9B2f12IoTJ9M89fAkMQSBNN W/uxQBLB5xu2CmVM6gtCEEVaM/QnVLet9CHqsmmvgl3DYRbFTG3+XpZBc +Y6UjVaKTKydfLD0c7mdYsK8xzY6SpHbq1bknrSty8G4Qon3YxP8RXdF8 xg5kpJAOB5BMCmZFAAnhiIGTQyzKmLd68o0Vsgqq/oUYZqXMySD4gQFTl qhozdKu1h9hIxFN5P3LWXeFlEiFR/BZQev8Iw9Vh5wbcvvw1mtNJH0/AW fPswQyMWWloXlXxfG1oCXpSRRm2LmfDsYkC+XnkhDJhZ8BZLQOIOurpLW A==; X-IronPort-AV: E=McAfee;i="6500,9779,10451"; a="295376011" X-IronPort-AV: E=Sophos;i="5.93,266,1654585200"; d="scan'208";a="295376011" Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Aug 2022 14:35:42 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.93,266,1654585200"; d="scan'208";a="613657894" Received: from stinkpipe.fi.intel.com (HELO stinkbox) ([10.237.72.191]) by fmsmga007.fm.intel.com with SMTP; 26 Aug 2022 14:35:39 -0700 Received: by stinkbox (sSMTP sendmail emulation); Sat, 27 Aug 2022 00:35:39 +0300 From: Ville Syrjala To: dri-devel@lists.freedesktop.org Subject: [PATCH 11/11] drm/i915: Infer vrefresh range for eDP if the EDID omits it Date: Sat, 27 Aug 2022 00:35:01 +0300 Message-Id: <20220826213501.31490-12-ville.syrjala@linux.intel.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220826213501.31490-1-ville.syrjala@linux.intel.com> References: <20220826213501.31490-1-ville.syrjala@linux.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: intel-gfx@lists.freedesktop.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Ville Syrjälä A bunch of machines seem to have eDP panels where the EDID indicates continuous frequency support but fails to actually include the range descirptor. This violates the EDID 1.4 spec, but looks like the Windows driver just hacks around this by just assuming that the panel supports a continuous refresh rate range that covers all EDID reported modes. Do the same so that we get VRR support on these machines. Closes: https://gitlab.freedesktop.org/drm/intel/-/issues/6323 Signed-off-by: Ville Syrjälä Reviewed-by: Jani Nikula --- drivers/gpu/drm/i915/display/intel_dp.c | 45 +++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/drivers/gpu/drm/i915/display/intel_dp.c b/drivers/gpu/drm/i915/display/intel_dp.c index 8d1559323412..1f3e4824d316 100644 --- a/drivers/gpu/drm/i915/display/intel_dp.c +++ b/drivers/gpu/drm/i915/display/intel_dp.c @@ -5207,6 +5207,49 @@ intel_edp_add_properties(struct intel_dp *intel_dp) fixed_mode->vdisplay); } +/* + * Some VRR eDP panels violate the EDID spec and neglect + * to include the monitor range descriptor in the EDID. + * Cook up the VRR refresh rate limits based on the modes + * reported by the panel. + */ +static void +intel_edp_infer_vrr_range(struct intel_connector *connector) +{ + struct drm_i915_private *i915 = to_i915(connector->base.dev); + struct drm_display_info *info = &connector->base.display_info; + const struct edid *edid = connector->edid; + const struct drm_display_mode *mode; + + if (!HAS_VRR(i915)) + return; + + if (!edid || edid->revision < 4 || + !(edid->features & DRM_EDID_FEATURE_CONTINUOUS_FREQ) || + info->vrr_range.min_vfreq || info->vrr_range.max_vfreq) + return; + + if (list_empty(&connector->base.probed_modes)) + return; + + info->vrr_range.min_vfreq = ~0; + info->vrr_range.max_vfreq = 0; + + list_for_each_entry(mode, &connector->base.probed_modes, head) { + int vrefresh = drm_mode_vrefresh(mode); + + info->vrr_range.min_vfreq = min_t(int, vrefresh, + info->vrr_range.min_vfreq); + info->vrr_range.max_vfreq = max_t(int, vrefresh, + info->vrr_range.max_vfreq); + } + + drm_dbg_kms(&i915->drm, + "[CONNECTOR:%d:%s] does not report refresh rate range, assuming: %d Hz - %d Hz\n", + connector->base.base.id, connector->base.name, + info->vrr_range.min_vfreq, info->vrr_range.max_vfreq); +} + static bool intel_edp_init_connector(struct intel_dp *intel_dp, struct intel_connector *intel_connector) { @@ -5271,6 +5314,8 @@ static bool intel_edp_init_connector(struct intel_dp *intel_dp, } intel_connector->edid = edid; + intel_edp_infer_vrr_range(intel_connector); + intel_bios_init_panel(dev_priv, &intel_connector->panel, encoder->devdata, IS_ERR(edid) ? NULL : edid);