From patchwork Mon Mar 28 09:17:15 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Jani Nikula X-Patchwork-Id: 12793319 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 7A7DEC433F5 for ; Mon, 28 Mar 2022 09:17:43 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id F1C2B10EA4B; Mon, 28 Mar 2022 09:17:42 +0000 (UTC) Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by gabe.freedesktop.org (Postfix) with ESMTPS id C508B10EAD7; Mon, 28 Mar 2022 09:17:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1648459061; x=1679995061; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=35R2Vq1xT3Kgqzlcgy1x5Zhl6wBdMkBU4RTO1exJPo8=; b=kD3faceuwvfgLtiPPBFuBO7wjVOyLFesqckW4J6O4NKjlgM89UzTC9km dBzyOenm4T0jPMEkZamcebiKAvnJHhyq+/UZUnFthUGVRWhTQNQiyDC3D Sxap/Z+lUB8KHJ30bqri+kOxhEuxxdx8ltpn0+7uSsh/mLEbZ8GW5HSTe H+Q+8hFigniK9eETS6oF6exfoadJJYwkCch42vX5EyKIE1fXw5i3jctf3 xXivKMaWo+/W57L6gj3svBhLCNh5z2uWFNzMJ0H7DohcWeE97HZ+0EScz 6FVxhPPEl9peHGFd928Ko1MUTJyKAfX1PbUzm87X5aX9Vkta2MOwM7Nf9 g==; X-IronPort-AV: E=McAfee;i="6200,9189,10299"; a="241106648" X-IronPort-AV: E=Sophos;i="5.90,217,1643702400"; d="scan'208";a="241106648" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Mar 2022 02:17:41 -0700 X-IronPort-AV: E=Sophos;i="5.90,217,1643702400"; d="scan'208";a="651863799" Received: from aysivtso-mobl.ccr.corp.intel.com (HELO localhost) ([10.252.62.56]) by orsmga004-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Mar 2022 02:17:39 -0700 From: Jani Nikula To: dri-devel@lists.freedesktop.org Date: Mon, 28 Mar 2022 12:17:15 +0300 Message-Id: <8dcb5d66d7c0095e51a469dbd5ee0a219de18ab3.1648458971.git.jani.nikula@intel.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: References: MIME-Version: 1.0 Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo Subject: [Intel-gfx] [PATCH v2 01/11] drm/edid: don't modify EDID while parsing X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: jani.nikula@intel.com, intel-gfx@lists.freedesktop.org Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" We'll want to keep the EDID immutable while parsing. Stop modifying the EDID because of the quirks. In theory, this does have userspace implications, but the userspace is supposed to use the modes exposed via KMS API, not by parsing the EDID directly. Cc: Ville Syrjälä Signed-off-by: Jani Nikula Reviewed-by: Ville Syrjälä --- drivers/gpu/drm/drm_edid.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c index cc7bd58369df..1b552fe54f38 100644 --- a/drivers/gpu/drm/drm_edid.c +++ b/drivers/gpu/drm/drm_edid.c @@ -2740,9 +2740,9 @@ static struct drm_display_mode *drm_mode_detailed(struct drm_device *dev, return NULL; if (quirks & EDID_QUIRK_135_CLOCK_TOO_HIGH) - timing->pixel_clock = cpu_to_le16(1088); - - mode->clock = le16_to_cpu(timing->pixel_clock) * 10; + mode->clock = 1088 * 10; + else + mode->clock = le16_to_cpu(timing->pixel_clock) * 10; mode->hdisplay = hactive; mode->hsync_start = mode->hdisplay + hsync_offset; @@ -2763,14 +2763,14 @@ static struct drm_display_mode *drm_mode_detailed(struct drm_device *dev, drm_mode_do_interlace_quirk(mode, pt); if (quirks & EDID_QUIRK_DETAILED_SYNC_PP) { - pt->misc |= DRM_EDID_PT_HSYNC_POSITIVE | DRM_EDID_PT_VSYNC_POSITIVE; + mode->flags |= DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC; + } else { + mode->flags |= (pt->misc & DRM_EDID_PT_HSYNC_POSITIVE) ? + DRM_MODE_FLAG_PHSYNC : DRM_MODE_FLAG_NHSYNC; + mode->flags |= (pt->misc & DRM_EDID_PT_VSYNC_POSITIVE) ? + DRM_MODE_FLAG_PVSYNC : DRM_MODE_FLAG_NVSYNC; } - mode->flags |= (pt->misc & DRM_EDID_PT_HSYNC_POSITIVE) ? - DRM_MODE_FLAG_PHSYNC : DRM_MODE_FLAG_NHSYNC; - mode->flags |= (pt->misc & DRM_EDID_PT_VSYNC_POSITIVE) ? - DRM_MODE_FLAG_PVSYNC : DRM_MODE_FLAG_NVSYNC; - set_size: mode->width_mm = pt->width_mm_lo | (pt->width_height_mm_hi & 0xf0) << 4; mode->height_mm = pt->height_mm_lo | (pt->width_height_mm_hi & 0xf) << 8; From patchwork Mon Mar 28 09:17:16 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Jani Nikula X-Patchwork-Id: 12793320 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 E9F0EC433EF for ; Mon, 28 Mar 2022 09:17:51 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 8FE7A10EAD7; Mon, 28 Mar 2022 09:17:51 +0000 (UTC) Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) by gabe.freedesktop.org (Postfix) with ESMTPS id 4629610EA5B; Mon, 28 Mar 2022 09:17:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1648459066; x=1679995066; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=34wm7PMDXhmWzJ1ooXIZN30UnR2cVvWB6aIqcj4XevI=; b=lbae414RYJNDt1FO+wJvSktDAKESe+pHXmBINqTeAL2yYT9QtaGx9jYd sIzAps3DwFv0q4ke/uAFbBmZnMRyk/Hac3AZZ5vVEhxOx6J9hTEv/RNZE EKFqgih8xBWb8e22OD+CwgRNv9KJ10Zc2VjjIhJqLC2FV9jGxos2SO0Vc ruSC2UlKwZUhMt3miqAIUqIKZy/f9D+CI7YsF86OSdnNw5j0Cttly0Z7C v6CyoSwO8V8tt+wDAO9i3mQG8xzBsC2l9hEYtYg0PKpqfyRYYmWELiIr4 IZFwpzjIzSxt6RkyyzVmiDPflqsIlMFriICh2/uv9B4JMNDKY4T5C+9q+ g==; X-IronPort-AV: E=McAfee;i="6200,9189,10299"; a="319655745" X-IronPort-AV: E=Sophos;i="5.90,217,1643702400"; d="scan'208";a="319655745" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Mar 2022 02:17:45 -0700 X-IronPort-AV: E=Sophos;i="5.90,217,1643702400"; d="scan'208";a="502447399" Received: from aysivtso-mobl.ccr.corp.intel.com (HELO localhost) ([10.252.62.56]) by orsmga003-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Mar 2022 02:17:43 -0700 From: Jani Nikula To: dri-devel@lists.freedesktop.org Date: Mon, 28 Mar 2022 12:17:16 +0300 Message-Id: <8bb6a4997680685e1a6b8978ac34befd955578f4.1648458971.git.jani.nikula@intel.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: References: MIME-Version: 1.0 Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo Subject: [Intel-gfx] [PATCH v2 02/11] drm/edid: fix reduced blanking support check X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: jani.nikula@intel.com, intel-gfx@lists.freedesktop.org Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" The reduced blanking bit is valid only for CVT, indicated by display range limits flags 0x04. Signed-off-by: Jani Nikula Reviewed-by: Ville Syrjälä --- drivers/gpu/drm/drm_edid.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c index 1b552fe54f38..13d05062d68c 100644 --- a/drivers/gpu/drm/drm_edid.c +++ b/drivers/gpu/drm/drm_edid.c @@ -2408,7 +2408,7 @@ is_rb(struct detailed_timing *t, void *data) if (!is_display_descriptor(r, EDID_DETAIL_MONITOR_RANGE)) return; - if (r[15] & 0x10) + if (r[10] == DRM_EDID_CVT_SUPPORT_FLAG && r[15] & 0x10) *(bool *)data = true; } From patchwork Mon Mar 28 09:17:17 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Jani Nikula X-Patchwork-Id: 12793321 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 E2F1EC433EF for ; Mon, 28 Mar 2022 09:17:53 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 21EDC10EAEA; Mon, 28 Mar 2022 09:17:53 +0000 (UTC) Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by gabe.freedesktop.org (Postfix) with ESMTPS id F056310EAD7; Mon, 28 Mar 2022 09:17:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1648459071; x=1679995071; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=FH09TiMnMimO+UYp1HS9yZX42SvCC57EQLh9OARm9RM=; b=Dye+cCDxXyIcsL86qc49xGfQM/m3+Yq0PmCXp0mCXftwHJb1rCq3goxP SY9O0OuJmgtTXKg7uUnayL/g7j0ZqsrpJXDnwA/c/LX2pROeXA2/T8Wb7 hjdalrNUPNljidvVwTz6gY3srJWq+s0pBnd07dpBvR0ARGxLlXKG66uAp g2UtuCCJzdGWB1pE6u7K1UBYTA3sCtK8LNV6IIFalPJXIye7CmrpsXFda L3pJGCV50M9jhWhbG+PMCoJ/tBkeiJusjxsQKiM1Mxlr4PfiCN/cA6iji /SSM76fKZYo8Ct4TiQetuMP43Hb1/NYM/qjIcf+WWgLQC4fpR/fOiYT+X g==; X-IronPort-AV: E=McAfee;i="6200,9189,10299"; a="257783810" X-IronPort-AV: E=Sophos;i="5.90,217,1643702400"; d="scan'208";a="257783810" Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Mar 2022 02:17:50 -0700 X-IronPort-AV: E=Sophos;i="5.90,217,1643702400"; d="scan'208";a="517949979" Received: from aysivtso-mobl.ccr.corp.intel.com (HELO localhost) ([10.252.62.56]) by orsmga002-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Mar 2022 02:17:48 -0700 From: Jani Nikula To: dri-devel@lists.freedesktop.org Date: Mon, 28 Mar 2022 12:17:17 +0300 Message-Id: <04c8140a780dc02155a16d8acc64dbce756739bb.1648458971.git.jani.nikula@intel.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: References: MIME-Version: 1.0 Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo Subject: [Intel-gfx] [PATCH v2 03/11] drm/edid: slightly restructure timing and non-timing descriptor structs X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: jani.nikula@intel.com, intel-gfx@lists.freedesktop.org Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" The pixel clock is conceptually part of the detailed timings, while it's just zero padding for display descriptors. Modify the structures to reflect this. Rename struct detailed_non_pixel to edid_display_descriptor to better reflect spec while at it. (Further struct renames are left for follow-up work.) Suggested-by: Ville Syrjälä Signed-off-by: Jani Nikula Reported-by: kernel test robot Reported-by: kernel test robot Reported-by: kernel test robot --- drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 6 +++--- drivers/gpu/drm/drm_edid.c | 12 ++++++------ include/drm/drm_edid.h | 9 +++++---- 3 files changed, 14 insertions(+), 13 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 b30656959fd8..e477f4b42b6b 100644 --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c @@ -11537,7 +11537,7 @@ void amdgpu_dm_update_freesync_caps(struct drm_connector *connector, { int i = 0; struct detailed_timing *timing; - struct detailed_non_pixel *data; + struct edid_display_descriptor *data; struct detailed_data_monitor_range *range; struct amdgpu_dm_connector *amdgpu_dm_connector = to_amdgpu_dm_connector(connector); @@ -11592,7 +11592,7 @@ void amdgpu_dm_update_freesync_caps(struct drm_connector *connector, for (i = 0; i < 4; i++) { timing = &edid->detailed_timings[i]; - data = &timing->data.other_data; + data = &timing->data.descriptor; range = &data->data.range; /* * Check if monitor has continuous frequency mode @@ -11629,7 +11629,7 @@ void amdgpu_dm_update_freesync_caps(struct drm_connector *connector, i = parse_hdmi_amd_vsdb(amdgpu_dm_connector, edid, &vsdb_info); if (i >= 0 && vsdb_info.freesync_supported) { timing = &edid->detailed_timings[i]; - data = &timing->data.other_data; + data = &timing->data.descriptor; amdgpu_dm_connector->min_vfreq = vsdb_info.min_refresh_rate_hz; amdgpu_dm_connector->max_vfreq = vsdb_info.max_refresh_rate_hz; diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c index 13d05062d68c..ac80681d64f6 100644 --- a/drivers/gpu/drm/drm_edid.c +++ b/drivers/gpu/drm/drm_edid.c @@ -2742,7 +2742,7 @@ static struct drm_display_mode *drm_mode_detailed(struct drm_device *dev, if (quirks & EDID_QUIRK_135_CLOCK_TOO_HIGH) mode->clock = 1088 * 10; else - mode->clock = le16_to_cpu(timing->pixel_clock) * 10; + mode->clock = le16_to_cpu(pt->pixel_clock) * 10; mode->hdisplay = hactive; mode->hsync_start = mode->hdisplay + hsync_offset; @@ -2984,7 +2984,7 @@ static void do_inferred_modes(struct detailed_timing *timing, void *c) { struct detailed_mode_closure *closure = c; - struct detailed_non_pixel *data = &timing->data.other_data; + struct edid_display_descriptor *data = &timing->data.descriptor; struct detailed_data_monitor_range *range = &data->data.range; if (!is_display_descriptor((const u8 *)timing, EDID_DETAIL_MONITOR_RANGE)) @@ -3117,7 +3117,7 @@ static void do_standard_modes(struct detailed_timing *timing, void *c) { struct detailed_mode_closure *closure = c; - struct detailed_non_pixel *data = &timing->data.other_data; + struct edid_display_descriptor *data = &timing->data.descriptor; struct drm_connector *connector = closure->connector; struct edid *edid = closure->edid; int i; @@ -3187,7 +3187,7 @@ static int drm_cvt_modes(struct drm_connector *connector, for (i = 0; i < 4; i++) { int width, height; - cvt = &(timing->data.other_data.data.cvt[i]); + cvt = &(timing->data.descriptor.data.cvt[i]); if (!memcmp(cvt->code, empty, 3)) continue; @@ -4494,7 +4494,7 @@ monitor_name(struct detailed_timing *t, void *data) if (!is_display_descriptor((const u8 *)t, EDID_DETAIL_MONITOR_NAME)) return; - *(u8 **)data = t->data.other_data.data.str.str; + *(u8 **)data = t->data.descriptor.data.str.str; } static int get_monitor_name(struct edid *edid, char name[13]) @@ -5223,7 +5223,7 @@ void get_monitor_range(struct detailed_timing *timing, void *info_monitor_range) { struct drm_monitor_range_info *monitor_range = info_monitor_range; - const struct detailed_non_pixel *data = &timing->data.other_data; + const struct edid_display_descriptor *data = &timing->data.descriptor; const struct detailed_data_monitor_range *range = &data->data.range; if (!is_display_descriptor((const u8 *)timing, EDID_DETAIL_MONITOR_RANGE)) diff --git a/include/drm/drm_edid.h b/include/drm/drm_edid.h index 144c495b99c4..8e322ef173a8 100644 --- a/include/drm/drm_edid.h +++ b/include/drm/drm_edid.h @@ -68,6 +68,7 @@ struct std_timing { /* If detailed data is pixel timing */ struct detailed_pixel_timing { + __le16 pixel_clock; /* non-zero, need to multiply by 10 KHz */ u8 hactive_lo; u8 hblank_lo; u8 hactive_hblank_hi; @@ -142,8 +143,9 @@ struct cvt_timing { u8 code[3]; } __attribute__((packed)); -struct detailed_non_pixel { - u8 pad1; +struct edid_display_descriptor { + u16 pad0; /* 0 for Display Descriptor */ + u8 pad1; /* 0 for Display Descriptor */ u8 type; /* ff=serial, fe=string, fd=monitor range, fc=monitor name fb=color point data, fa=standard timing data, f9=undefined, f8=mfg. reserved */ @@ -168,10 +170,9 @@ struct detailed_non_pixel { #define EDID_DETAIL_MONITOR_SERIAL 0xff struct detailed_timing { - __le16 pixel_clock; /* need to multiply by 10 KHz */ union { struct detailed_pixel_timing pixel_data; - struct detailed_non_pixel other_data; + struct edid_display_descriptor descriptor; } data; } __attribute__((packed)); From patchwork Mon Mar 28 09:17:18 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Jani Nikula X-Patchwork-Id: 12793322 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 5C039C433F5 for ; Mon, 28 Mar 2022 09:18:04 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id B532810E64C; Mon, 28 Mar 2022 09:18:03 +0000 (UTC) Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by gabe.freedesktop.org (Postfix) with ESMTPS id 8722510EB11; Mon, 28 Mar 2022 09:17:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1648459075; x=1679995075; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=N6l01Kyco4r2aWrwUAvFqb8gjScec7KUeRUlXv/3j2c=; b=QOHG0XAFUUCwNULeE4KtxldVChhF26sJ3O13A1kow++zrY/pU+A7MzZ/ Mx/hRwrFgQDvJVbqacZZVK8wWh3alUl94Sz6Nhp06veYOD0J4J34/FAoI pMIY9MrGmXsZ1vkJZvt2/zyj4NHRrqge6gZa5+Pbhdp9zaA5spTDfQdnb XnyAJK7BtegOTL0CLQQVdksHBBaw67il86LA4qE3LbE0CLNAxqjT/p1kb iQHSI50tlN/H1B2CF8epuehNxdbefkbZcJ98ndO2K2OjDs/OcE9LYh8Ou x7E7dNWyfK5WriXmeU25+/NlnFdg3YRvYn6xA+NLniXm2CKF/ioqOI+HG Q==; X-IronPort-AV: E=McAfee;i="6200,9189,10299"; a="259140263" X-IronPort-AV: E=Sophos;i="5.90,217,1643702400"; d="scan'208";a="259140263" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Mar 2022 02:17:55 -0700 X-IronPort-AV: E=Sophos;i="5.90,217,1643702400"; d="scan'208";a="585128981" Received: from aysivtso-mobl.ccr.corp.intel.com (HELO localhost) ([10.252.62.56]) by orsmga001-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Mar 2022 02:17:53 -0700 From: Jani Nikula To: dri-devel@lists.freedesktop.org Date: Mon, 28 Mar 2022 12:17:18 +0300 Message-Id: X-Mailer: git-send-email 2.30.2 In-Reply-To: References: MIME-Version: 1.0 Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo Subject: [Intel-gfx] [PATCH v2 04/11] drm/edid: pass a timing pointer to is_display_descriptor() X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: jani.nikula@intel.com, intel-gfx@lists.freedesktop.org Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" Use struct member access instead of direct offsets to avoid lots of casts all over the place. Use BUILD_BUG_ON() for sanity check. Cc: Ville Syrjälä Signed-off-by: Jani Nikula --- drivers/gpu/drm/drm_edid.c | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c index ac80681d64f6..586b0ed3b3dc 100644 --- a/drivers/gpu/drm/drm_edid.c +++ b/drivers/gpu/drm/drm_edid.c @@ -2331,10 +2331,15 @@ struct drm_display_mode *drm_mode_find_dmt(struct drm_device *dev, } EXPORT_SYMBOL(drm_mode_find_dmt); -static bool is_display_descriptor(const u8 d[18], u8 tag) +static bool is_display_descriptor(const struct detailed_timing *descriptor, u8 tag) { - return d[0] == 0x00 && d[1] == 0x00 && - d[2] == 0x00 && d[3] == tag; + BUILD_BUG_ON(offsetof(typeof(*descriptor), data.descriptor.pad0) != 0); + BUILD_BUG_ON(offsetof(typeof(*descriptor), data.descriptor.pad1) != 2); + BUILD_BUG_ON(offsetof(typeof(*descriptor), data.descriptor.type) != 3); + + return descriptor->data.descriptor.pad0 == 0 && + descriptor->data.descriptor.pad1 == 0 && + descriptor->data.descriptor.type == tag; } static bool is_detailed_timing_descriptor(const u8 d[18]) @@ -2405,7 +2410,7 @@ is_rb(struct detailed_timing *t, void *data) { u8 *r = (u8 *)t; - if (!is_display_descriptor(r, EDID_DETAIL_MONITOR_RANGE)) + if (!is_display_descriptor(t, EDID_DETAIL_MONITOR_RANGE)) return; if (r[10] == DRM_EDID_CVT_SUPPORT_FLAG && r[15] & 0x10) @@ -2431,7 +2436,7 @@ find_gtf2(struct detailed_timing *t, void *data) { u8 *r = (u8 *)t; - if (!is_display_descriptor(r, EDID_DETAIL_MONITOR_RANGE)) + if (!is_display_descriptor(t, EDID_DETAIL_MONITOR_RANGE)) return; if (r[10] == 0x02) @@ -2987,7 +2992,7 @@ do_inferred_modes(struct detailed_timing *timing, void *c) struct edid_display_descriptor *data = &timing->data.descriptor; struct detailed_data_monitor_range *range = &data->data.range; - if (!is_display_descriptor((const u8 *)timing, EDID_DETAIL_MONITOR_RANGE)) + if (!is_display_descriptor(timing, EDID_DETAIL_MONITOR_RANGE)) return; closure->modes += drm_dmt_modes_for_range(closure->connector, @@ -3067,7 +3072,7 @@ do_established_modes(struct detailed_timing *timing, void *c) { struct detailed_mode_closure *closure = c; - if (!is_display_descriptor((const u8 *)timing, EDID_DETAIL_EST_TIMINGS)) + if (!is_display_descriptor(timing, EDID_DETAIL_EST_TIMINGS)) return; closure->modes += drm_est3_modes(closure->connector, timing); @@ -3122,7 +3127,7 @@ do_standard_modes(struct detailed_timing *timing, void *c) struct edid *edid = closure->edid; int i; - if (!is_display_descriptor((const u8 *)timing, EDID_DETAIL_STD_MODES)) + if (!is_display_descriptor(timing, EDID_DETAIL_STD_MODES)) return; for (i = 0; i < 6; i++) { @@ -3231,7 +3236,7 @@ do_cvt_mode(struct detailed_timing *timing, void *c) { struct detailed_mode_closure *closure = c; - if (!is_display_descriptor((const u8 *)timing, EDID_DETAIL_CVT_3BYTE)) + if (!is_display_descriptor(timing, EDID_DETAIL_CVT_3BYTE)) return; closure->modes += drm_cvt_modes(closure->connector, timing); @@ -4491,7 +4496,7 @@ drm_parse_hdmi_vsdb_audio(struct drm_connector *connector, const u8 *db) static void monitor_name(struct detailed_timing *t, void *data) { - if (!is_display_descriptor((const u8 *)t, EDID_DETAIL_MONITOR_NAME)) + if (!is_display_descriptor(t, EDID_DETAIL_MONITOR_NAME)) return; *(u8 **)data = t->data.descriptor.data.str.str; @@ -5226,7 +5231,7 @@ void get_monitor_range(struct detailed_timing *timing, const struct edid_display_descriptor *data = &timing->data.descriptor; const struct detailed_data_monitor_range *range = &data->data.range; - if (!is_display_descriptor((const u8 *)timing, EDID_DETAIL_MONITOR_RANGE)) + if (!is_display_descriptor(timing, EDID_DETAIL_MONITOR_RANGE)) return; /* From patchwork Mon Mar 28 09:17:19 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Jani Nikula X-Patchwork-Id: 12793330 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 060A5C433F5 for ; Mon, 28 Mar 2022 09:18:22 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id B070410EB24; Mon, 28 Mar 2022 09:18:20 +0000 (UTC) Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) by gabe.freedesktop.org (Postfix) with ESMTPS id 6C79E10EB21; Mon, 28 Mar 2022 09:18:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1648459098; x=1679995098; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=2zJZJqG0N7GQHilr3yQN0NDn/DXYmpQNBFZxXSeiiHo=; b=G9O46mewAl4LMHSJeIUmQTLnx0WCJ/y3dnj9KBehuYtZWAUTPG6ryf/y Zy/8+M2OZEGAiKwRXhhbakxUaah/SN0odkh3VlV22Y4gQGNfEmo/I5zAu vikTNrNUj3uxkmchb7bKoX5rMNpzZP6rlZeULB/dE4EfXuGnHMa2CmLEw wRgBT+ImnwixnzAIm5T717gtwfj2/EhB9P6ffhfyuKaMAKHqjUVaJWdcF XAVeTxGHqVUDaCsYZRWJaPUGFuVYiCTTpPd3NweBKaXL8aIBUHF/zrZsD cQw1LInznRNH2GC7Qa8FmbrfAyRQT3b9m7Up7j30XS9PJ8DDKcnMGinhp g==; X-IronPort-AV: E=McAfee;i="6200,9189,10299"; a="319655777" X-IronPort-AV: E=Sophos;i="5.90,217,1643702400"; d="scan'208";a="319655777" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Mar 2022 02:17:59 -0700 X-IronPort-AV: E=Sophos;i="5.90,217,1643702400"; d="scan'208";a="638893109" Received: from aysivtso-mobl.ccr.corp.intel.com (HELO localhost) ([10.252.62.56]) by fmsmga003-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Mar 2022 02:17:57 -0700 From: Jani Nikula To: dri-devel@lists.freedesktop.org Date: Mon, 28 Mar 2022 12:17:19 +0300 Message-Id: X-Mailer: git-send-email 2.30.2 In-Reply-To: References: MIME-Version: 1.0 Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo Subject: [Intel-gfx] [PATCH v2 05/11] drm/edid: use struct detailed_timing member access in is_rb() X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: jani.nikula@intel.com, intel-gfx@lists.freedesktop.org Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" Use struct detailed_timing member access instead of direct offsets to avoid casting. Use BUILD_BUG_ON() for sanity check. Cc: Ville Syrjälä Signed-off-by: Jani Nikula --- Note: Why can we use range.formula.cvt.flags directly in is_rb() while gtf2 functions check for range.flags == 0x02 first to ensure it's gtf2? --- drivers/gpu/drm/drm_edid.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c index 586b0ed3b3dc..242f074f60d9 100644 --- a/drivers/gpu/drm/drm_edid.c +++ b/drivers/gpu/drm/drm_edid.c @@ -2406,15 +2406,21 @@ drm_for_each_detailed_block(u8 *raw_edid, detailed_cb *cb, void *closure) } static void -is_rb(struct detailed_timing *t, void *data) +is_rb(struct detailed_timing *descriptor, void *data) { - u8 *r = (u8 *)t; + bool *res = data; - if (!is_display_descriptor(t, EDID_DETAIL_MONITOR_RANGE)) + if (!is_display_descriptor(descriptor, EDID_DETAIL_MONITOR_RANGE)) return; - if (r[10] == DRM_EDID_CVT_SUPPORT_FLAG && r[15] & 0x10) - *(bool *)data = true; + BUILD_BUG_ON(offsetof(typeof(*descriptor), + data.descriptor.data.range.flags) != 10); + BUILD_BUG_ON(offsetof(typeof(*descriptor), + data.descriptor.data.range.formula.cvt.flags) != 15); + + if (descriptor->data.descriptor.data.range.flags == DRM_EDID_CVT_SUPPORT_FLAG && + descriptor->data.descriptor.data.range.formula.cvt.flags & 0x10) + *res = true; } /* EDID 1.4 defines this explicitly. For EDID 1.3, we guess, badly. */ From patchwork Mon Mar 28 09:17:20 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Jani Nikula X-Patchwork-Id: 12793329 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 C1889C433F5 for ; Mon, 28 Mar 2022 09:18:06 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 3076B10EB11; Mon, 28 Mar 2022 09:18:06 +0000 (UTC) Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by gabe.freedesktop.org (Postfix) with ESMTPS id 8CFB510EB11; Mon, 28 Mar 2022 09:18:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1648459084; x=1679995084; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=n3JsYZScArEq08WopnENbKxcwn3bsFE//XKDBq8vwS4=; b=WZ4VKJp64DJE2TtlqnfVa7G5BlwvDIntRdBTakGAnbqv5mlBMtILB1GR Y39XL5T8wWSKQxusj//r95xVzjnfrX0Eb76d7Zh1ir+e0BfCo6oFe8GsB 3H4H9hG7neEo/FpCwqssdfCIXd5HofgZ744MhCKvw3gHyExO01sReiGdT 2yoCbNlVJ6qf86JPIQ+R9R5EILDluUUJoITREi0NpZb2C47d1PpGSyFDQ TMrUsjY9CPYzx+4V5+kw4H4KToCWdhcIMCpRmFE3Q1xbDYGLLqLpbZUsw g1wsGsrbU/T/yIoyIjQRWxQ/84SJGtlhAh9AmCiFWPsuRtRuMQcmYZho+ w==; X-IronPort-AV: E=McAfee;i="6200,9189,10299"; a="258924209" X-IronPort-AV: E=Sophos;i="5.90,217,1643702400"; d="scan'208";a="258924209" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Mar 2022 02:18:03 -0700 X-IronPort-AV: E=Sophos;i="5.90,217,1643702400"; d="scan'208";a="648992641" Received: from aysivtso-mobl.ccr.corp.intel.com (HELO localhost) ([10.252.62.56]) by fmsmga002-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Mar 2022 02:18:01 -0700 From: Jani Nikula To: dri-devel@lists.freedesktop.org Date: Mon, 28 Mar 2022 12:17:20 +0300 Message-Id: X-Mailer: git-send-email 2.30.2 In-Reply-To: References: MIME-Version: 1.0 Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo Subject: [Intel-gfx] [PATCH v2 06/11] drm/edid: use struct detailed_data_monitor_range member access in gtf2 functions X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: jani.nikula@intel.com, intel-gfx@lists.freedesktop.org Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" Use struct struct detailed_data_monitor_range member access instead of direct offsets to avoid casting. Use BUILD_BUG_ON() for sanity check. v2: - Rename timing to descriptor (Ville) - Return and use struct detailed_data_monitor_range Cc: Ville Syrjälä Signed-off-by: Jani Nikula --- drivers/gpu/drm/drm_edid.c | 63 ++++++++++++++++++++++++++------------ 1 file changed, 43 insertions(+), 20 deletions(-) diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c index 242f074f60d9..4d63f3412672 100644 --- a/drivers/gpu/drm/drm_edid.c +++ b/drivers/gpu/drm/drm_edid.c @@ -2438,61 +2438,84 @@ drm_monitor_supports_rb(struct edid *edid) } static void -find_gtf2(struct detailed_timing *t, void *data) +find_gtf2(struct detailed_timing *descriptor, void *data) { - u8 *r = (u8 *)t; + struct detailed_data_monitor_range **res = data; - if (!is_display_descriptor(t, EDID_DETAIL_MONITOR_RANGE)) + if (!is_display_descriptor(descriptor, EDID_DETAIL_MONITOR_RANGE)) return; - if (r[10] == 0x02) - *(u8 **)data = r; + BUILD_BUG_ON(offsetof(typeof(*descriptor), data.descriptor.data.range.flags) != 10); + + if (descriptor->data.descriptor.data.range.flags == + DRM_EDID_SECONDARY_GTF_SUPPORT_FLAG) + *res = &descriptor->data.descriptor.data.range; } /* Secondary GTF curve kicks in above some break frequency */ static int drm_gtf2_hbreak(struct edid *edid) { - u8 *r = NULL; + struct detailed_data_monitor_range *range = NULL; + + drm_for_each_detailed_block((u8 *)edid, find_gtf2, &range); - drm_for_each_detailed_block((u8 *)edid, find_gtf2, &r); - return r ? (r[12] * 2) : 0; + BUILD_BUG_ON(offsetof(struct detailed_timing, data.descriptor.data.range) + + offsetof(typeof(*range), formula.gtf2.hfreq_start_khz) != 12); + + return range ? range->formula.gtf2.hfreq_start_khz * 2 : 0; } static int drm_gtf2_2c(struct edid *edid) { - u8 *r = NULL; + struct detailed_data_monitor_range *range = NULL; + + drm_for_each_detailed_block((u8 *)edid, find_gtf2, &range); + + BUILD_BUG_ON(offsetof(struct detailed_timing, data.descriptor.data.range) + + offsetof(typeof(*range), formula.gtf2.c) != 13); - drm_for_each_detailed_block((u8 *)edid, find_gtf2, &r); - return r ? r[13] : 0; + return range ? range->formula.gtf2.c : 0; } static int drm_gtf2_m(struct edid *edid) { - u8 *r = NULL; + struct detailed_data_monitor_range *range = NULL; - drm_for_each_detailed_block((u8 *)edid, find_gtf2, &r); - return r ? (r[15] << 8) + r[14] : 0; + drm_for_each_detailed_block((u8 *)edid, find_gtf2, &range); + + BUILD_BUG_ON(offsetof(struct detailed_timing, data.descriptor.data.range) + + offsetof(typeof(*range), formula.gtf2.m) != 14); + + return range ? le16_to_cpu(range->formula.gtf2.m) : 0; } static int drm_gtf2_k(struct edid *edid) { - u8 *r = NULL; + struct detailed_data_monitor_range *range = NULL; + + drm_for_each_detailed_block((u8 *)edid, find_gtf2, &range); - drm_for_each_detailed_block((u8 *)edid, find_gtf2, &r); - return r ? r[16] : 0; + BUILD_BUG_ON(offsetof(struct detailed_timing, data.descriptor.data.range) + + offsetof(typeof(*range), formula.gtf2.k) != 16); + + return range ? range->formula.gtf2.k : 0; } static int drm_gtf2_2j(struct edid *edid) { - u8 *r = NULL; + struct detailed_data_monitor_range *range = NULL; + + drm_for_each_detailed_block((u8 *)edid, find_gtf2, &range); + + BUILD_BUG_ON(offsetof(struct detailed_timing, data.descriptor.data.range) + + offsetof(typeof(*range), formula.gtf2.j) != 17); - drm_for_each_detailed_block((u8 *)edid, find_gtf2, &r); - return r ? r[17] : 0; + return range ? range->formula.gtf2.j : 0; } /** From patchwork Mon Mar 28 09:17:21 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Jani Nikula X-Patchwork-Id: 12793335 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 74B67C433FE for ; Mon, 28 Mar 2022 09:18:39 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id CF33510EC28; Mon, 28 Mar 2022 09:18:34 +0000 (UTC) Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by gabe.freedesktop.org (Postfix) with ESMTPS id 4395B10EBEB; Mon, 28 Mar 2022 09:18:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1648459106; x=1679995106; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=RiJIIxEYo5DrI+6dT0nLvCLL+B3So7UixYzpfdMv534=; b=OUfWLhVq0s6JH3w0wzGssogdB+ZBLUu3nZi+QfGDkLNCkXAL8sEvuy0+ 99UWmk8iDCDUIp/egoLplatwcU2t8vcD/QQ8XHChAfWLrIIm9AHKHbxe4 v/iwUEqq77PFPOazEuFHGKILhzyp5k6NhNQd6bU4SF6tajHzuqqkWp2Vr LzWoAEKaWG2vQTlXt+v+ROPFzeMGc6+oXTZQm/koC6MdMIWbcusNiJV+Y RL4HFNrPsx4DpJM3eEBwh5K8O4XUEQJITMzaaNmVVYRIBMAtoADK/KKLM VhOjgBhHPupPQvSXhHW+pvOezH7O0Q4LqGyCaxSJi/lRpzR6As0xNS5Jr g==; X-IronPort-AV: E=McAfee;i="6200,9189,10299"; a="283841884" X-IronPort-AV: E=Sophos;i="5.90,217,1643702400"; d="scan'208";a="283841884" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Mar 2022 02:18:08 -0700 X-IronPort-AV: E=Sophos;i="5.90,217,1643702400"; d="scan'208";a="603962424" Received: from aysivtso-mobl.ccr.corp.intel.com (HELO localhost) ([10.252.62.56]) by fmsmga008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Mar 2022 02:18:06 -0700 From: Jani Nikula To: dri-devel@lists.freedesktop.org Date: Mon, 28 Mar 2022 12:17:21 +0300 Message-Id: <5db2906c3767ea80392cf91b9aa5745763349c4f.1648458971.git.jani.nikula@intel.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: References: MIME-Version: 1.0 Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo Subject: [Intel-gfx] [PATCH v2 07/11] drm/edid: constify struct detailed_timing in lower level parsing X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: jani.nikula@intel.com, intel-gfx@lists.freedesktop.org Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" Start constifying the struct detailed_timing pointers being passed around from bottom up. Cc: Ville Syrjälä Signed-off-by: Jani Nikula --- drivers/gpu/drm/drm_edid.c | 40 +++++++++++++++++++------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c index 4d63f3412672..60eee683be3f 100644 --- a/drivers/gpu/drm/drm_edid.c +++ b/drivers/gpu/drm/drm_edid.c @@ -2566,7 +2566,7 @@ static int drm_mode_hsync(const struct drm_display_mode *mode) */ static struct drm_display_mode * drm_mode_std(struct drm_connector *connector, struct edid *edid, - struct std_timing *t) + const struct std_timing *t) { struct drm_device *dev = connector->dev; struct drm_display_mode *m, *mode = NULL; @@ -2684,7 +2684,7 @@ drm_mode_std(struct drm_connector *connector, struct edid *edid, */ static void drm_mode_do_interlace_quirk(struct drm_display_mode *mode, - struct detailed_pixel_timing *pt) + const struct detailed_pixel_timing *pt) { int i; static const struct { @@ -2728,11 +2728,11 @@ drm_mode_do_interlace_quirk(struct drm_display_mode *mode, */ static struct drm_display_mode *drm_mode_detailed(struct drm_device *dev, struct edid *edid, - struct detailed_timing *timing, + const struct detailed_timing *timing, u32 quirks) { struct drm_display_mode *mode; - struct detailed_pixel_timing *pt = &timing->data.pixel_data; + const struct detailed_pixel_timing *pt = &timing->data.pixel_data; unsigned hactive = (pt->hactive_hblank_hi & 0xf0) << 4 | pt->hactive_lo; unsigned vactive = (pt->vactive_vblank_hi & 0xf0) << 4 | pt->vactive_lo; unsigned hblank = (pt->hactive_hblank_hi & 0xf) << 8 | pt->hblank_lo; @@ -2827,7 +2827,7 @@ static struct drm_display_mode *drm_mode_detailed(struct drm_device *dev, static bool mode_in_hsync_range(const struct drm_display_mode *mode, - struct edid *edid, u8 *t) + struct edid *edid, const u8 *t) { int hsync, hmin, hmax; @@ -2844,7 +2844,7 @@ mode_in_hsync_range(const struct drm_display_mode *mode, static bool mode_in_vsync_range(const struct drm_display_mode *mode, - struct edid *edid, u8 *t) + struct edid *edid, const u8 *t) { int vsync, vmin, vmax; @@ -2860,7 +2860,7 @@ mode_in_vsync_range(const struct drm_display_mode *mode, } static u32 -range_pixel_clock(struct edid *edid, u8 *t) +range_pixel_clock(struct edid *edid, const u8 *t) { /* unspecified */ if (t[9] == 0 || t[9] == 255) @@ -2876,10 +2876,10 @@ range_pixel_clock(struct edid *edid, u8 *t) static bool mode_in_range(const struct drm_display_mode *mode, struct edid *edid, - struct detailed_timing *timing) + const struct detailed_timing *timing) { u32 max_clock; - u8 *t = (u8 *)timing; + const u8 *t = (const u8 *)timing; if (!mode_in_hsync_range(mode, edid, t)) return false; @@ -2922,7 +2922,7 @@ static bool valid_inferred_mode(const struct drm_connector *connector, static int drm_dmt_modes_for_range(struct drm_connector *connector, struct edid *edid, - struct detailed_timing *timing) + const struct detailed_timing *timing) { int i, modes = 0; struct drm_display_mode *newmode; @@ -2957,7 +2957,7 @@ void drm_mode_fixup_1366x768(struct drm_display_mode *mode) static int drm_gtf_modes_for_range(struct drm_connector *connector, struct edid *edid, - struct detailed_timing *timing) + const struct detailed_timing *timing) { int i, modes = 0; struct drm_display_mode *newmode; @@ -2986,7 +2986,7 @@ drm_gtf_modes_for_range(struct drm_connector *connector, struct edid *edid, static int drm_cvt_modes_for_range(struct drm_connector *connector, struct edid *edid, - struct detailed_timing *timing) + const struct detailed_timing *timing) { int i, modes = 0; struct drm_display_mode *newmode; @@ -3018,8 +3018,8 @@ static void do_inferred_modes(struct detailed_timing *timing, void *c) { struct detailed_mode_closure *closure = c; - struct edid_display_descriptor *data = &timing->data.descriptor; - struct detailed_data_monitor_range *range = &data->data.range; + const struct edid_display_descriptor *data = &timing->data.descriptor; + const struct detailed_data_monitor_range *range = &data->data.range; if (!is_display_descriptor(timing, EDID_DETAIL_MONITOR_RANGE)) return; @@ -3068,11 +3068,11 @@ add_inferred_modes(struct drm_connector *connector, struct edid *edid) } static int -drm_est3_modes(struct drm_connector *connector, struct detailed_timing *timing) +drm_est3_modes(struct drm_connector *connector, const struct detailed_timing *timing) { int i, j, m, modes = 0; struct drm_display_mode *mode; - u8 *est = ((u8 *)timing) + 6; + const u8 *est = ((const u8 *)timing) + 6; for (i = 0; i < 6; i++) { for (j = 7; j >= 0; j--) { @@ -3151,7 +3151,7 @@ static void do_standard_modes(struct detailed_timing *timing, void *c) { struct detailed_mode_closure *closure = c; - struct edid_display_descriptor *data = &timing->data.descriptor; + const struct edid_display_descriptor *data = &timing->data.descriptor; struct drm_connector *connector = closure->connector; struct edid *edid = closure->edid; int i; @@ -3160,7 +3160,7 @@ do_standard_modes(struct detailed_timing *timing, void *c) return; for (i = 0; i < 6; i++) { - struct std_timing *std = &data->data.timings[i]; + const struct std_timing *std = &data->data.timings[i]; struct drm_display_mode *newmode; newmode = drm_mode_std(connector, edid, std); @@ -3209,12 +3209,12 @@ add_standard_modes(struct drm_connector *connector, struct edid *edid) } static int drm_cvt_modes(struct drm_connector *connector, - struct detailed_timing *timing) + const struct detailed_timing *timing) { int i, j, modes = 0; struct drm_display_mode *newmode; struct drm_device *dev = connector->dev; - struct cvt_timing *cvt; + const struct cvt_timing *cvt; const int rates[] = { 60, 85, 75, 60, 50 }; const u8 empty[3] = { 0, 0, 0 }; From patchwork Mon Mar 28 09:17:22 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Jani Nikula X-Patchwork-Id: 12793332 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 93491C433EF for ; Mon, 28 Mar 2022 09:18:25 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id C387A10EB6B; Mon, 28 Mar 2022 09:18:24 +0000 (UTC) Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by gabe.freedesktop.org (Postfix) with ESMTPS id CB9CF10EB6A; Mon, 28 Mar 2022 09:18:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1648459103; x=1679995103; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=h+Vo5fEkzCJCcefRIUBhmjKVq9YwkUOl7FZWj0f9QAw=; b=Kr0yUmW9Ms2Pc7EHfABDE8YtmuyfxmxHpf4hJ4NbfdBqnQsKSwVvg0Na 1/ISFQ3sgC4YCTSW9ZQOJEURyt/Lq4cWopoR9hSJDg6y1Nc0wrCiqmHCS Xs7YkN+NHyY3+ULQY4oBbTypzEoqupxbI3z6hI6znJKAqe2mLtZiVV2Py djgnvotuZUdFxPYc2WrTv8HsQclxq4X4ad1OVzSC0nVSf4XenU84iouwW 7nfoUETLDu27hkcjLYmNyiDli2CWNMVsOd7EwomRAAfdTlt7pPi0emcdC GhdNiXiN85wsmJSQj40tTtEpUh6tPQQIO3MzQwXVT6EvrYxQJjY2fTDZh g==; X-IronPort-AV: E=McAfee;i="6200,9189,10299"; a="258670031" X-IronPort-AV: E=Sophos;i="5.90,217,1643702400"; d="scan'208";a="258670031" Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Mar 2022 02:18:12 -0700 X-IronPort-AV: E=Sophos;i="5.90,217,1643702400"; d="scan'208";a="553851121" Received: from aysivtso-mobl.ccr.corp.intel.com (HELO localhost) ([10.252.62.56]) by fmsmga007-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Mar 2022 02:18:10 -0700 From: Jani Nikula To: dri-devel@lists.freedesktop.org Date: Mon, 28 Mar 2022 12:17:22 +0300 Message-Id: X-Mailer: git-send-email 2.30.2 In-Reply-To: References: MIME-Version: 1.0 Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo Subject: [Intel-gfx] [PATCH v2 08/11] drm/edid: constify struct detailed_timing in parsing callbacks X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: jani.nikula@intel.com, intel-gfx@lists.freedesktop.org Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" Moving one level higher, constify struct detailed_timing pointers in callbacks. Cc: Ville Syrjälä Signed-off-by: Jani Nikula --- drivers/gpu/drm/drm_edid.c | 40 ++++++++++++++++++++------------------ 1 file changed, 21 insertions(+), 19 deletions(-) diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c index 60eee683be3f..95c48485794c 100644 --- a/drivers/gpu/drm/drm_edid.c +++ b/drivers/gpu/drm/drm_edid.c @@ -2347,7 +2347,7 @@ static bool is_detailed_timing_descriptor(const u8 d[18]) return d[0] != 0x00 || d[1] != 0x00; } -typedef void detailed_cb(struct detailed_timing *timing, void *closure); +typedef void detailed_cb(const struct detailed_timing *timing, void *closure); static void cea_for_each_detailed_block(u8 *ext, detailed_cb *cb, void *closure) @@ -2406,7 +2406,7 @@ drm_for_each_detailed_block(u8 *raw_edid, detailed_cb *cb, void *closure) } static void -is_rb(struct detailed_timing *descriptor, void *data) +is_rb(const struct detailed_timing *descriptor, void *data) { bool *res = data; @@ -2438,9 +2438,9 @@ drm_monitor_supports_rb(struct edid *edid) } static void -find_gtf2(struct detailed_timing *descriptor, void *data) +find_gtf2(const struct detailed_timing *descriptor, void *data) { - struct detailed_data_monitor_range **res = data; + const struct detailed_data_monitor_range **res = data; if (!is_display_descriptor(descriptor, EDID_DETAIL_MONITOR_RANGE)) return; @@ -2456,7 +2456,7 @@ find_gtf2(struct detailed_timing *descriptor, void *data) static int drm_gtf2_hbreak(struct edid *edid) { - struct detailed_data_monitor_range *range = NULL; + const struct detailed_data_monitor_range *range = NULL; drm_for_each_detailed_block((u8 *)edid, find_gtf2, &range); @@ -2469,7 +2469,7 @@ drm_gtf2_hbreak(struct edid *edid) static int drm_gtf2_2c(struct edid *edid) { - struct detailed_data_monitor_range *range = NULL; + const struct detailed_data_monitor_range *range = NULL; drm_for_each_detailed_block((u8 *)edid, find_gtf2, &range); @@ -2482,7 +2482,7 @@ drm_gtf2_2c(struct edid *edid) static int drm_gtf2_m(struct edid *edid) { - struct detailed_data_monitor_range *range = NULL; + const struct detailed_data_monitor_range *range = NULL; drm_for_each_detailed_block((u8 *)edid, find_gtf2, &range); @@ -2495,7 +2495,7 @@ drm_gtf2_m(struct edid *edid) static int drm_gtf2_k(struct edid *edid) { - struct detailed_data_monitor_range *range = NULL; + const struct detailed_data_monitor_range *range = NULL; drm_for_each_detailed_block((u8 *)edid, find_gtf2, &range); @@ -2508,7 +2508,7 @@ drm_gtf2_k(struct edid *edid) static int drm_gtf2_2j(struct edid *edid) { - struct detailed_data_monitor_range *range = NULL; + const struct detailed_data_monitor_range *range = NULL; drm_for_each_detailed_block((u8 *)edid, find_gtf2, &range); @@ -3015,7 +3015,7 @@ drm_cvt_modes_for_range(struct drm_connector *connector, struct edid *edid, } static void -do_inferred_modes(struct detailed_timing *timing, void *c) +do_inferred_modes(const struct detailed_timing *timing, void *c) { struct detailed_mode_closure *closure = c; const struct edid_display_descriptor *data = &timing->data.descriptor; @@ -3097,7 +3097,7 @@ drm_est3_modes(struct drm_connector *connector, const struct detailed_timing *ti } static void -do_established_modes(struct detailed_timing *timing, void *c) +do_established_modes(const struct detailed_timing *timing, void *c) { struct detailed_mode_closure *closure = c; @@ -3148,7 +3148,7 @@ add_established_modes(struct drm_connector *connector, struct edid *edid) } static void -do_standard_modes(struct detailed_timing *timing, void *c) +do_standard_modes(const struct detailed_timing *timing, void *c) { struct detailed_mode_closure *closure = c; const struct edid_display_descriptor *data = &timing->data.descriptor; @@ -3261,7 +3261,7 @@ static int drm_cvt_modes(struct drm_connector *connector, } static void -do_cvt_mode(struct detailed_timing *timing, void *c) +do_cvt_mode(const struct detailed_timing *timing, void *c) { struct detailed_mode_closure *closure = c; @@ -3290,7 +3290,7 @@ add_cvt_modes(struct drm_connector *connector, struct edid *edid) static void fixup_detailed_cea_mode_clock(struct drm_display_mode *mode); static void -do_detailed_mode(struct detailed_timing *timing, void *c) +do_detailed_mode(const struct detailed_timing *timing, void *c) { struct detailed_mode_closure *closure = c; struct drm_display_mode *newmode; @@ -4523,17 +4523,19 @@ drm_parse_hdmi_vsdb_audio(struct drm_connector *connector, const u8 *db) } static void -monitor_name(struct detailed_timing *t, void *data) +monitor_name(const struct detailed_timing *timing, void *data) { - if (!is_display_descriptor(t, EDID_DETAIL_MONITOR_NAME)) + const char **res = data; + + if (!is_display_descriptor(timing, EDID_DETAIL_MONITOR_NAME)) return; - *(u8 **)data = t->data.descriptor.data.str.str; + *res = timing->data.descriptor.data.str.str; } static int get_monitor_name(struct edid *edid, char name[13]) { - char *edid_name = NULL; + const char *edid_name = NULL; int mnl; if (!edid || !name) @@ -5253,7 +5255,7 @@ static void drm_parse_cea_ext(struct drm_connector *connector, } static -void get_monitor_range(struct detailed_timing *timing, +void get_monitor_range(const struct detailed_timing *timing, void *info_monitor_range) { struct drm_monitor_range_info *monitor_range = info_monitor_range; From patchwork Mon Mar 28 09:17:23 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Jani Nikula X-Patchwork-Id: 12793333 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 C1FFAC433F5 for ; Mon, 28 Mar 2022 09:18:37 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 5CABA10EC26; Mon, 28 Mar 2022 09:18:34 +0000 (UTC) Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by gabe.freedesktop.org (Postfix) with ESMTPS id 4A59C10EBEB; Mon, 28 Mar 2022 09:18: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=1648459107; x=1679995107; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=rWzE46us+0Sqt9zh+iCw3SGY70qDmGFryOqAWqhkMqM=; b=eJX+jHvEM8UbnntckioJJEYD/c5jSibplV1Cz9pNLtCJj+a/DeMOdf8O KJ9XaKf+KQEioF2xHyiDRqd8LE9opFKTOkI7Df1tp+U6EpEnwwkwkT4CG rEdrDkDm16qi1mhEYB5WG7POhgT9itwPj/jeaNNly7bsTwnbchTQTgn34 2JYrrmUpAqH6gvOQD5U62wA4DC8BXm9UV+NzEFuFlXBbk8F0SbOBMD5ZY eG58ELIh8pzREMOA3ZGDNrHpW6bbWs5F4hU7MHD4v83Anv+QlEKOe2VfZ zwgRBzRWDQongZKg/mCLsb3x3doouEVYzEg8WrYmbEgdWLD1t+/lFVvAD Q==; X-IronPort-AV: E=McAfee;i="6200,9189,10299"; a="322140187" X-IronPort-AV: E=Sophos;i="5.90,217,1643702400"; d="scan'208";a="322140187" Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Mar 2022 02:18:16 -0700 X-IronPort-AV: E=Sophos;i="5.90,217,1643702400"; d="scan'208";a="787162951" Received: from aysivtso-mobl.ccr.corp.intel.com (HELO localhost) ([10.252.62.56]) by fmsmga006-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Mar 2022 02:18:15 -0700 From: Jani Nikula To: dri-devel@lists.freedesktop.org Date: Mon, 28 Mar 2022 12:17:23 +0300 Message-Id: <477792b768fd810109912dc2c9a5fd45c21a3e57.1648458971.git.jani.nikula@intel.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: References: MIME-Version: 1.0 Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo Subject: [Intel-gfx] [PATCH v2 09/11] drm/edid: constify struct edid passed to detailed blocks X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: jani.nikula@intel.com, intel-gfx@lists.freedesktop.org Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" Constify the first level of struct edid in detailed timing parsing. Also switch to struct edid instead of u8. Cc: Ville Syrjälä Signed-off-by: Jani Nikula --- drivers/gpu/drm/drm_edid.c | 48 ++++++++++++++++++-------------------- 1 file changed, 23 insertions(+), 25 deletions(-) diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c index 95c48485794c..4542f8b8c8f0 100644 --- a/drivers/gpu/drm/drm_edid.c +++ b/drivers/gpu/drm/drm_edid.c @@ -2350,38 +2350,37 @@ static bool is_detailed_timing_descriptor(const u8 d[18]) typedef void detailed_cb(const struct detailed_timing *timing, void *closure); static void -cea_for_each_detailed_block(u8 *ext, detailed_cb *cb, void *closure) +cea_for_each_detailed_block(const u8 *ext, detailed_cb *cb, void *closure) { int i, n; u8 d = ext[0x02]; - u8 *det_base = ext + d; + const u8 *det_base = ext + d; if (d < 4 || d > 127) return; n = (127 - d) / 18; for (i = 0; i < n; i++) - cb((struct detailed_timing *)(det_base + 18 * i), closure); + cb((const struct detailed_timing *)(det_base + 18 * i), closure); } static void -vtb_for_each_detailed_block(u8 *ext, detailed_cb *cb, void *closure) +vtb_for_each_detailed_block(const u8 *ext, detailed_cb *cb, void *closure) { unsigned int i, n = min((int)ext[0x02], 6); - u8 *det_base = ext + 5; + const u8 *det_base = ext + 5; if (ext[0x01] != 1) return; /* unknown version */ for (i = 0; i < n; i++) - cb((struct detailed_timing *)(det_base + 18 * i), closure); + cb((const struct detailed_timing *)(det_base + 18 * i), closure); } static void -drm_for_each_detailed_block(u8 *raw_edid, detailed_cb *cb, void *closure) +drm_for_each_detailed_block(const struct edid *edid, detailed_cb *cb, void *closure) { int i; - struct edid *edid = (struct edid *)raw_edid; if (edid == NULL) return; @@ -2389,8 +2388,8 @@ drm_for_each_detailed_block(u8 *raw_edid, detailed_cb *cb, void *closure) for (i = 0; i < EDID_DETAILED_TIMINGS; i++) cb(&(edid->detailed_timings[i]), closure); - for (i = 1; i <= raw_edid[0x7e]; i++) { - u8 *ext = raw_edid + (i * EDID_LENGTH); + for (i = 1; i <= edid->extensions; i++) { + const u8 *ext = (const u8 *)edid + (i * EDID_LENGTH); switch (*ext) { case CEA_EXT: @@ -2430,7 +2429,7 @@ drm_monitor_supports_rb(struct edid *edid) if (edid->revision >= 4) { bool ret = false; - drm_for_each_detailed_block((u8 *)edid, is_rb, &ret); + drm_for_each_detailed_block(edid, is_rb, &ret); return ret; } @@ -2458,7 +2457,7 @@ drm_gtf2_hbreak(struct edid *edid) { const struct detailed_data_monitor_range *range = NULL; - drm_for_each_detailed_block((u8 *)edid, find_gtf2, &range); + drm_for_each_detailed_block(edid, find_gtf2, &range); BUILD_BUG_ON(offsetof(struct detailed_timing, data.descriptor.data.range) + offsetof(typeof(*range), formula.gtf2.hfreq_start_khz) != 12); @@ -2471,7 +2470,7 @@ drm_gtf2_2c(struct edid *edid) { const struct detailed_data_monitor_range *range = NULL; - drm_for_each_detailed_block((u8 *)edid, find_gtf2, &range); + drm_for_each_detailed_block(edid, find_gtf2, &range); BUILD_BUG_ON(offsetof(struct detailed_timing, data.descriptor.data.range) + offsetof(typeof(*range), formula.gtf2.c) != 13); @@ -2484,7 +2483,7 @@ drm_gtf2_m(struct edid *edid) { const struct detailed_data_monitor_range *range = NULL; - drm_for_each_detailed_block((u8 *)edid, find_gtf2, &range); + drm_for_each_detailed_block(edid, find_gtf2, &range); BUILD_BUG_ON(offsetof(struct detailed_timing, data.descriptor.data.range) + offsetof(typeof(*range), formula.gtf2.m) != 14); @@ -2497,7 +2496,7 @@ drm_gtf2_k(struct edid *edid) { const struct detailed_data_monitor_range *range = NULL; - drm_for_each_detailed_block((u8 *)edid, find_gtf2, &range); + drm_for_each_detailed_block(edid, find_gtf2, &range); BUILD_BUG_ON(offsetof(struct detailed_timing, data.descriptor.data.range) + offsetof(typeof(*range), formula.gtf2.k) != 16); @@ -2510,7 +2509,7 @@ drm_gtf2_2j(struct edid *edid) { const struct detailed_data_monitor_range *range = NULL; - drm_for_each_detailed_block((u8 *)edid, find_gtf2, &range); + drm_for_each_detailed_block(edid, find_gtf2, &range); BUILD_BUG_ON(offsetof(struct detailed_timing, data.descriptor.data.range) + offsetof(typeof(*range), formula.gtf2.j) != 17); @@ -3061,8 +3060,7 @@ add_inferred_modes(struct drm_connector *connector, struct edid *edid) }; if (version_greater(edid, 1, 0)) - drm_for_each_detailed_block((u8 *)edid, do_inferred_modes, - &closure); + drm_for_each_detailed_block(edid, do_inferred_modes, &closure); return closure.modes; } @@ -3141,8 +3139,8 @@ add_established_modes(struct drm_connector *connector, struct edid *edid) } if (version_greater(edid, 1, 0)) - drm_for_each_detailed_block((u8 *)edid, - do_established_modes, &closure); + drm_for_each_detailed_block(edid, do_established_modes, + &closure); return modes + closure.modes; } @@ -3200,7 +3198,7 @@ add_standard_modes(struct drm_connector *connector, struct edid *edid) } if (version_greater(edid, 1, 0)) - drm_for_each_detailed_block((u8 *)edid, do_standard_modes, + drm_for_each_detailed_block(edid, do_standard_modes, &closure); /* XXX should also look for standard codes in VTB blocks */ @@ -3280,7 +3278,7 @@ add_cvt_modes(struct drm_connector *connector, struct edid *edid) }; if (version_greater(edid, 1, 2)) - drm_for_each_detailed_block((u8 *)edid, do_cvt_mode, &closure); + drm_for_each_detailed_block(edid, do_cvt_mode, &closure); /* XXX should also look for CVT codes in VTB blocks */ @@ -3340,7 +3338,7 @@ add_detailed_modes(struct drm_connector *connector, struct edid *edid, closure.preferred = (edid->features & DRM_EDID_FEATURE_PREFERRED_TIMING); - drm_for_each_detailed_block((u8 *)edid, do_detailed_mode, &closure); + drm_for_each_detailed_block(edid, do_detailed_mode, &closure); return closure.modes; } @@ -4541,7 +4539,7 @@ static int get_monitor_name(struct edid *edid, char name[13]) if (!edid || !name) return 0; - drm_for_each_detailed_block((u8 *)edid, monitor_name, &edid_name); + drm_for_each_detailed_block(edid, monitor_name, &edid_name); for (mnl = 0; edid_name && mnl < 13; mnl++) { if (edid_name[mnl] == 0x0a) break; @@ -5287,7 +5285,7 @@ void drm_get_monitor_range(struct drm_connector *connector, if (!version_greater(edid, 1, 1)) return; - drm_for_each_detailed_block((u8 *)edid, get_monitor_range, + drm_for_each_detailed_block(edid, get_monitor_range, &info->monitor_range); DRM_DEBUG_KMS("Supported Monitor Refresh rate range is %d Hz - %d Hz\n", From patchwork Mon Mar 28 09:17:24 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Jani Nikula X-Patchwork-Id: 12793331 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 1F887C433F5 for ; Mon, 28 Mar 2022 09:18:25 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 80DF710EB6A; Mon, 28 Mar 2022 09:18:24 +0000 (UTC) Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by gabe.freedesktop.org (Postfix) with ESMTPS id 1E64C10EB6A; Mon, 28 Mar 2022 09:18:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1648459102; x=1679995102; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=IjvPNHMd0YKRpG54o8/pJGaow228lq34iEERd84wFxk=; b=SEaVc382ldsWkkTuvKT6mGvAaU/5pZCgFH3ggi1W0SIpFFxD0h2serIZ J1orY8FK1g3Kyl/e9UE5ygp8FM98yRyoGrB9fEprSAEyn82LIJ9qM2+vL qhKl7FG3AjLWrp6VN6EvWXCTd1qGNufASkSGqN8USRBuWTK3qCgYSqEfk eJ8A6LnFscii/eYyUwqeyLZkvXcgxgjb5YX/yDyDztHdwyrXL2bCQaY7E GfQFsvwu568KoyBNEAH7c0cFlf68ipiih1IDm6wYgH6e/BPm/P2cAOGBv dbvdn7MyFa4tWQXZaI3aUBfFJtPIB58bXPJo5fkYrQs3PM3KL1NK/vz3u A==; X-IronPort-AV: E=McAfee;i="6200,9189,10299"; a="241106730" X-IronPort-AV: E=Sophos;i="5.90,217,1643702400"; d="scan'208";a="241106730" Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Mar 2022 02:18:21 -0700 X-IronPort-AV: E=Sophos;i="5.90,217,1643702400"; d="scan'208";a="830508170" Received: from aysivtso-mobl.ccr.corp.intel.com (HELO localhost) ([10.252.62.56]) by fmsmga005-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Mar 2022 02:18:19 -0700 From: Jani Nikula To: dri-devel@lists.freedesktop.org Date: Mon, 28 Mar 2022 12:17:24 +0300 Message-Id: <8d153fc52f2c45c3bc9030e175fa4e13095a50d5.1648458971.git.jani.nikula@intel.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: References: MIME-Version: 1.0 Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo Subject: [Intel-gfx] [PATCH v2 10/11] drm/edid: constify struct edid passed around in callbacks and closure X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: jani.nikula@intel.com, intel-gfx@lists.freedesktop.org Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" Finalize detailed timing parsing constness by making struct edid also const in callbacks and closure. Cc: Ville Syrjälä Signed-off-by: Jani Nikula --- drivers/gpu/drm/drm_edid.c | 48 +++++++++++++++++++------------------- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c index 4542f8b8c8f0..0c4b95fb6bd9 100644 --- a/drivers/gpu/drm/drm_edid.c +++ b/drivers/gpu/drm/drm_edid.c @@ -97,7 +97,7 @@ static int oui(u8 first, u8 second, u8 third) struct detailed_mode_closure { struct drm_connector *connector; - struct edid *edid; + const struct edid *edid; bool preferred; u32 quirks; int modes; @@ -2424,7 +2424,7 @@ is_rb(const struct detailed_timing *descriptor, void *data) /* EDID 1.4 defines this explicitly. For EDID 1.3, we guess, badly. */ static bool -drm_monitor_supports_rb(struct edid *edid) +drm_monitor_supports_rb(const struct edid *edid) { if (edid->revision >= 4) { bool ret = false; @@ -2453,7 +2453,7 @@ find_gtf2(const struct detailed_timing *descriptor, void *data) /* Secondary GTF curve kicks in above some break frequency */ static int -drm_gtf2_hbreak(struct edid *edid) +drm_gtf2_hbreak(const struct edid *edid) { const struct detailed_data_monitor_range *range = NULL; @@ -2466,7 +2466,7 @@ drm_gtf2_hbreak(struct edid *edid) } static int -drm_gtf2_2c(struct edid *edid) +drm_gtf2_2c(const struct edid *edid) { const struct detailed_data_monitor_range *range = NULL; @@ -2479,7 +2479,7 @@ drm_gtf2_2c(struct edid *edid) } static int -drm_gtf2_m(struct edid *edid) +drm_gtf2_m(const struct edid *edid) { const struct detailed_data_monitor_range *range = NULL; @@ -2492,7 +2492,7 @@ drm_gtf2_m(struct edid *edid) } static int -drm_gtf2_k(struct edid *edid) +drm_gtf2_k(const struct edid *edid) { const struct detailed_data_monitor_range *range = NULL; @@ -2505,7 +2505,7 @@ drm_gtf2_k(struct edid *edid) } static int -drm_gtf2_2j(struct edid *edid) +drm_gtf2_2j(const struct edid *edid) { const struct detailed_data_monitor_range *range = NULL; @@ -2521,7 +2521,7 @@ drm_gtf2_2j(struct edid *edid) * standard_timing_level - get std. timing level(CVT/GTF/DMT) * @edid: EDID block to scan */ -static int standard_timing_level(struct edid *edid) +static int standard_timing_level(const struct edid *edid) { if (edid->revision >= 2) { if (edid->revision >= 4 && (edid->features & DRM_EDID_FEATURE_DEFAULT_GTF)) @@ -2564,7 +2564,7 @@ static int drm_mode_hsync(const struct drm_display_mode *mode) * and convert them into a real mode using CVT/GTF/DMT. */ static struct drm_display_mode * -drm_mode_std(struct drm_connector *connector, struct edid *edid, +drm_mode_std(struct drm_connector *connector, const struct edid *edid, const struct std_timing *t) { struct drm_device *dev = connector->dev; @@ -2726,7 +2726,7 @@ drm_mode_do_interlace_quirk(struct drm_display_mode *mode, * return a new struct drm_display_mode. */ static struct drm_display_mode *drm_mode_detailed(struct drm_device *dev, - struct edid *edid, + const struct edid *edid, const struct detailed_timing *timing, u32 quirks) { @@ -2826,7 +2826,7 @@ static struct drm_display_mode *drm_mode_detailed(struct drm_device *dev, static bool mode_in_hsync_range(const struct drm_display_mode *mode, - struct edid *edid, const u8 *t) + const struct edid *edid, const u8 *t) { int hsync, hmin, hmax; @@ -2843,7 +2843,7 @@ mode_in_hsync_range(const struct drm_display_mode *mode, static bool mode_in_vsync_range(const struct drm_display_mode *mode, - struct edid *edid, const u8 *t) + const struct edid *edid, const u8 *t) { int vsync, vmin, vmax; @@ -2859,7 +2859,7 @@ mode_in_vsync_range(const struct drm_display_mode *mode, } static u32 -range_pixel_clock(struct edid *edid, const u8 *t) +range_pixel_clock(const struct edid *edid, const u8 *t) { /* unspecified */ if (t[9] == 0 || t[9] == 255) @@ -2874,7 +2874,7 @@ range_pixel_clock(struct edid *edid, const u8 *t) } static bool -mode_in_range(const struct drm_display_mode *mode, struct edid *edid, +mode_in_range(const struct drm_display_mode *mode, const struct edid *edid, const struct detailed_timing *timing) { u32 max_clock; @@ -2920,7 +2920,7 @@ static bool valid_inferred_mode(const struct drm_connector *connector, } static int -drm_dmt_modes_for_range(struct drm_connector *connector, struct edid *edid, +drm_dmt_modes_for_range(struct drm_connector *connector, const struct edid *edid, const struct detailed_timing *timing) { int i, modes = 0; @@ -2955,7 +2955,7 @@ void drm_mode_fixup_1366x768(struct drm_display_mode *mode) } static int -drm_gtf_modes_for_range(struct drm_connector *connector, struct edid *edid, +drm_gtf_modes_for_range(struct drm_connector *connector, const struct edid *edid, const struct detailed_timing *timing) { int i, modes = 0; @@ -2984,7 +2984,7 @@ drm_gtf_modes_for_range(struct drm_connector *connector, struct edid *edid, } static int -drm_cvt_modes_for_range(struct drm_connector *connector, struct edid *edid, +drm_cvt_modes_for_range(struct drm_connector *connector, const struct edid *edid, const struct detailed_timing *timing) { int i, modes = 0; @@ -3052,7 +3052,7 @@ do_inferred_modes(const struct detailed_timing *timing, void *c) } static int -add_inferred_modes(struct drm_connector *connector, struct edid *edid) +add_inferred_modes(struct drm_connector *connector, const struct edid *edid) { struct detailed_mode_closure closure = { .connector = connector, @@ -3114,7 +3114,7 @@ do_established_modes(const struct detailed_timing *timing, void *c) * (defined above). Tease them out and add them to the global modes list. */ static int -add_established_modes(struct drm_connector *connector, struct edid *edid) +add_established_modes(struct drm_connector *connector, const struct edid *edid) { struct drm_device *dev = connector->dev; unsigned long est_bits = edid->established_timings.t1 | @@ -3151,7 +3151,7 @@ do_standard_modes(const struct detailed_timing *timing, void *c) struct detailed_mode_closure *closure = c; const struct edid_display_descriptor *data = &timing->data.descriptor; struct drm_connector *connector = closure->connector; - struct edid *edid = closure->edid; + const struct edid *edid = closure->edid; int i; if (!is_display_descriptor(timing, EDID_DETAIL_STD_MODES)) @@ -3178,7 +3178,7 @@ do_standard_modes(const struct detailed_timing *timing, void *c) * GTF or CVT. Grab them from @edid and add them to the list. */ static int -add_standard_modes(struct drm_connector *connector, struct edid *edid) +add_standard_modes(struct drm_connector *connector, const struct edid *edid) { int i, modes = 0; struct detailed_mode_closure closure = { @@ -3270,7 +3270,7 @@ do_cvt_mode(const struct detailed_timing *timing, void *c) } static int -add_cvt_modes(struct drm_connector *connector, struct edid *edid) +add_cvt_modes(struct drm_connector *connector, const struct edid *edid) { struct detailed_mode_closure closure = { .connector = connector, @@ -3324,7 +3324,7 @@ do_detailed_mode(const struct detailed_timing *timing, void *c) * @quirks: quirks to apply */ static int -add_detailed_modes(struct drm_connector *connector, struct edid *edid, +add_detailed_modes(struct drm_connector *connector, const struct edid *edid, u32 quirks) { struct detailed_mode_closure closure = { @@ -4531,7 +4531,7 @@ monitor_name(const struct detailed_timing *timing, void *data) *res = timing->data.descriptor.data.str.str; } -static int get_monitor_name(struct edid *edid, char name[13]) +static int get_monitor_name(const struct edid *edid, char name[13]) { const char *edid_name = NULL; int mnl; From patchwork Mon Mar 28 09:17:25 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Jani Nikula X-Patchwork-Id: 12793334 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 AEFF5C433EF for ; Mon, 28 Mar 2022 09:18:38 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 646B510EC27; Mon, 28 Mar 2022 09:18:34 +0000 (UTC) Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) by gabe.freedesktop.org (Postfix) with ESMTPS id E1BFE10EBB6; Mon, 28 Mar 2022 09:18:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1648459106; x=1679995106; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=U5eI4u1D+0DhKWd1tvpzwvpi060icjZPwKJUqtmC3n8=; b=dSUh/W2Q9hoWkvD4wqqcizhuRRTd7v/vgHbPhxHI5scxIq9TO4R7OQBD UyoOkThf71SoU0Qdqmr8ZQyNTvpDF0dlyKp2M2soNJPVnU1wRiLBbAzQL OUFX4whx5EBl+6bD6OxJ/hyTneZymXb8CxNo/LXFqjED1F2xiYfnpaXv9 io6Y+pU9ITYe+EV4io4BMKCn8sL7iGFlFkUb9bWAWurl6cV0uWiy1ppCv 3Aw3wkvomqxIl44SC0lh3G2sRZUke2d+rdnO+Fvekbrzx4UzugxBO/SUK RimM2GBYUzx5quy/VPAb0wcn8T9+dFBIHHmT2a4OU5RY8u4CKh9a9lza1 g==; X-IronPort-AV: E=McAfee;i="6200,9189,10299"; a="319655844" X-IronPort-AV: E=Sophos;i="5.90,217,1643702400"; d="scan'208";a="319655844" Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Mar 2022 02:18:25 -0700 X-IronPort-AV: E=Sophos;i="5.90,217,1643702400"; d="scan'208";a="617721951" Received: from aysivtso-mobl.ccr.corp.intel.com (HELO localhost) ([10.252.62.56]) by fmsmga004-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Mar 2022 02:18:23 -0700 From: Jani Nikula To: dri-devel@lists.freedesktop.org Date: Mon, 28 Mar 2022 12:17:25 +0300 Message-Id: X-Mailer: git-send-email 2.30.2 In-Reply-To: References: MIME-Version: 1.0 Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo Subject: [Intel-gfx] [PATCH v2 11/11] drm/edid: add more general struct edid constness in the interfaces X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: jani.nikula@intel.com, intel-gfx@lists.freedesktop.org Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" With this, the remaining non-const parts are the ones that actually modify the EDID, for example to fix corrupt EDID. Cc: Ville Syrjälä Signed-off-by: Jani Nikula --- drivers/gpu/drm/drm_edid.c | 21 +++++++++++---------- include/drm/drm_edid.h | 10 +++++----- 2 files changed, 16 insertions(+), 15 deletions(-) diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c index 0c4b95fb6bd9..114ccc712c71 100644 --- a/drivers/gpu/drm/drm_edid.c +++ b/drivers/gpu/drm/drm_edid.c @@ -2150,7 +2150,7 @@ static u32 edid_extract_panel_id(const struct edid *edid) u32 drm_edid_get_panel_id(struct i2c_adapter *adapter) { - struct edid *edid; + const struct edid *edid; u32 panel_id; edid = drm_do_get_edid_base_block(NULL, drm_do_probe_ddc_edid, adapter); @@ -3670,7 +3670,7 @@ static bool drm_valid_hdmi_vic(u8 vic) } static int -add_alternate_cea_modes(struct drm_connector *connector, struct edid *edid) +add_alternate_cea_modes(struct drm_connector *connector, const struct edid *edid) { struct drm_device *dev = connector->dev; struct drm_display_mode *mode, *tmp; @@ -4351,7 +4351,7 @@ static void drm_parse_y420cmdb_bitmap(struct drm_connector *connector, } static int -add_cea_modes(struct drm_connector *connector, struct edid *edid) +add_cea_modes(struct drm_connector *connector, const struct edid *edid) { const u8 *cea = drm_find_cea_extension(edid); const u8 *db, *hdmi = NULL, *video = NULL; @@ -4557,7 +4557,7 @@ static int get_monitor_name(const struct edid *edid, char name[13]) * @bufsize: The size of the name buffer (should be at least 14 chars.) * */ -void drm_edid_get_monitor_name(struct edid *edid, char *name, int bufsize) +void drm_edid_get_monitor_name(const struct edid *edid, char *name, int bufsize) { int name_length; char buf[13]; @@ -4591,7 +4591,8 @@ static void clear_eld(struct drm_connector *connector) * Fill the ELD (EDID-Like Data) buffer for passing to the audio driver. The * HDCP and Port_ID ELD fields are left for the graphics driver to fill in. */ -static void drm_edid_to_eld(struct drm_connector *connector, struct edid *edid) +static void drm_edid_to_eld(struct drm_connector *connector, + const struct edid *edid) { uint8_t *eld = connector->eld; const u8 *cea; @@ -4687,7 +4688,7 @@ static void drm_edid_to_eld(struct drm_connector *connector, struct edid *edid) * * Return: The number of found SADs or negative number on error. */ -int drm_edid_to_sad(struct edid *edid, struct cea_sad **sads) +int drm_edid_to_sad(const struct edid *edid, struct cea_sad **sads) { int count = 0; int i, start, end, dbl; @@ -4749,7 +4750,7 @@ EXPORT_SYMBOL(drm_edid_to_sad); * Return: The number of found Speaker Allocation Blocks or negative number on * error. */ -int drm_edid_to_speaker_allocation(struct edid *edid, u8 **sadb) +int drm_edid_to_speaker_allocation(const struct edid *edid, u8 **sadb) { int count = 0; int i, start, end, dbl; @@ -4844,7 +4845,7 @@ EXPORT_SYMBOL(drm_av_sync_delay); * * Return: True if the monitor is HDMI, false if not or unknown. */ -bool drm_detect_hdmi_monitor(struct edid *edid) +bool drm_detect_hdmi_monitor(const struct edid *edid) { const u8 *edid_ext; int i; @@ -4882,7 +4883,7 @@ EXPORT_SYMBOL(drm_detect_hdmi_monitor); * * Return: True if the monitor supports audio, false otherwise. */ -bool drm_detect_monitor_audio(struct edid *edid) +bool drm_detect_monitor_audio(const struct edid *edid) { const u8 *edid_ext; int i, j; @@ -5549,7 +5550,7 @@ static int add_displayid_detailed_1_modes(struct drm_connector *connector, } static int add_displayid_detailed_modes(struct drm_connector *connector, - struct edid *edid) + const struct edid *edid) { const struct displayid_block *block; struct displayid_iter iter; diff --git a/include/drm/drm_edid.h b/include/drm/drm_edid.h index 8e322ef173a8..5fe6e302a81f 100644 --- a/include/drm/drm_edid.h +++ b/include/drm/drm_edid.h @@ -373,8 +373,8 @@ struct drm_connector; struct drm_connector_state; struct drm_display_mode; -int drm_edid_to_sad(struct edid *edid, struct cea_sad **sads); -int drm_edid_to_speaker_allocation(struct edid *edid, u8 **sadb); +int drm_edid_to_sad(const struct edid *edid, struct cea_sad **sads); +int drm_edid_to_speaker_allocation(const struct edid *edid, u8 **sadb); int drm_av_sync_delay(struct drm_connector *connector, const struct drm_display_mode *mode); @@ -570,8 +570,8 @@ int drm_add_edid_modes(struct drm_connector *connector, struct edid *edid); int drm_add_override_edid_modes(struct drm_connector *connector); u8 drm_match_cea_mode(const struct drm_display_mode *to_match); -bool drm_detect_hdmi_monitor(struct edid *edid); -bool drm_detect_monitor_audio(struct edid *edid); +bool drm_detect_hdmi_monitor(const struct edid *edid); +bool drm_detect_monitor_audio(const struct edid *edid); enum hdmi_quantization_range drm_default_rgb_quant_range(const struct drm_display_mode *mode); int drm_add_modes_noedid(struct drm_connector *connector, @@ -583,7 +583,7 @@ int drm_edid_header_is_valid(const u8 *raw_edid); bool drm_edid_block_valid(u8 *raw_edid, int block, bool print_bad_edid, bool *edid_corrupt); bool drm_edid_is_valid(struct edid *edid); -void drm_edid_get_monitor_name(struct edid *edid, char *name, +void drm_edid_get_monitor_name(const struct edid *edid, char *name, int buflen); struct drm_display_mode *drm_mode_find_dmt(struct drm_device *dev, int hsize, int vsize, int fresh,