From patchwork Wed Sep 11 21:35:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 13801133 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 B644AEE57D7 for ; Wed, 11 Sep 2024 21:36:00 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 8D70D10E12D; Wed, 11 Sep 2024 21:35:55 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.b="nTaRusiQ"; dkim-atps=neutral Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by gabe.freedesktop.org (Postfix) with ESMTPS id 9FA9710E0D1; Wed, 11 Sep 2024 21:35:54 +0000 (UTC) Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 29CB15C0689; Wed, 11 Sep 2024 21:35:50 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5A966C4CECC; Wed, 11 Sep 2024 21:35:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1726090553; bh=W8fg2VsXYj0JvfXf/QEq0bCScHiPBxLzCbahu6u8/eY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nTaRusiQmxanOsg/9IwPdqyfc9dZ/EAYkjIv6J1XDt2J0uFYahGdmlIeHzDSOonNv b/WWDgRbs30EwOZQcpcOTES6noc4UOZrDyuuz5T66ds97ncDeXnu2asooT8lKWTmUw pMVl19eN7td1Ri827J2nsilEvBvCsCcb9bTzFzYWfmmaXAEurPfr+/QcMv/1u83TtW xA4KPmtejppHTrUnCouEWVclNuKlSRf8HLXLEdW1RRu3y6gYvtlQFfvQXV7m0W2wap 32XyIXQKgI920u6K2EbTDCeiIhDDUTad6V9WtO5VK7/Ez2Vlwet+AkJlBdHrwokHng sfrRLFejlBqIg== From: Mario Limonciello To: Alex Hung , Alexander Deucher , Melissa Wen Cc: kernel-dev@igalia.com, Mario Limonciello , amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, harry.wentland@amd.com, sunpeng.li@amd.com, Mark Pearson Subject: [PATCH v6 01/10] drm/amd/display: switch amdgpu_dm_connector to use struct drm_edid Date: Wed, 11 Sep 2024 16:35:27 -0500 Message-ID: <20240911213537.2338164-2-superm1@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240911213537.2338164-1-superm1@kernel.org> References: <20240911213537.2338164-1-superm1@kernel.org> 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: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Melissa Wen Replace raw edid handling (struct edid) with the opaque EDID type (struct drm_edid) on amdgpu_dm_connector for consistency. It may also prevent mismatch of approaches in different parts of the driver code. Signed-off-by: Melissa Wen Co-developed-by: Mario Limonciello Signed-off-by: Mario Limonciello --- v6: Move changelog to cutlist Update text of commit message Add missing newline (checkpatch.pl) Split long line in dm_dp_mst_get_modes() v5: remove deprecated comments (Alex H) use edid from dc_sink instead of call drm_edid_raw for now (Alex H) remove unnecessary cast (Alex H) v4: rename edid to drm_edid in amdgpu_connector (Jani) call drm_edid_connector_update to clear edid in case of NULL (Jani) keep setting NULL instead of free drm_edid (Jani) check drm_edid not NULL, instead of valid (Jani) v3: fix general protection fault on mst v2: use const to fix warnings (Alex Hung) --- .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 121 ++++++++---------- .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h | 4 +- .../amd/display/amdgpu_dm/amdgpu_dm_helpers.c | 13 +- .../display/amdgpu_dm/amdgpu_dm_mst_types.c | 34 ++--- 4 files changed, 83 insertions(+), 89 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 5942fc4e1c86..4927fdd45073 100644 --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c @@ -3436,7 +3436,7 @@ void amdgpu_dm_update_connector_after_detect( aconnector->dc_sink = sink; dc_sink_retain(aconnector->dc_sink); amdgpu_dm_update_freesync_caps(connector, - aconnector->edid); + aconnector->drm_edid); } else { amdgpu_dm_update_freesync_caps(connector, NULL); if (!aconnector->dc_sink) { @@ -3495,18 +3495,19 @@ void amdgpu_dm_update_connector_after_detect( aconnector->dc_sink = sink; dc_sink_retain(aconnector->dc_sink); if (sink->dc_edid.length == 0) { - aconnector->edid = NULL; + aconnector->drm_edid = NULL; if (aconnector->dc_link->aux_mode) { drm_dp_cec_unset_edid( &aconnector->dm_dp_aux.aux); } } else { - aconnector->edid = - (struct edid *)sink->dc_edid.raw_edid; + const struct edid *edid = (const struct edid *)sink->dc_edid.raw_edid; + + aconnector->drm_edid = drm_edid_alloc(edid, sink->dc_edid.length); + drm_edid_connector_update(connector, aconnector->drm_edid); if (aconnector->dc_link->aux_mode) - drm_dp_cec_set_edid(&aconnector->dm_dp_aux.aux, - aconnector->edid); + drm_dp_cec_set_edid(&aconnector->dm_dp_aux.aux, edid); } if (!aconnector->timing_requested) { @@ -3517,17 +3518,18 @@ void amdgpu_dm_update_connector_after_detect( "failed to create aconnector->requested_timing\n"); } - drm_connector_update_edid_property(connector, aconnector->edid); - amdgpu_dm_update_freesync_caps(connector, aconnector->edid); + drm_edid_connector_update(connector, aconnector->drm_edid); + amdgpu_dm_update_freesync_caps(connector, aconnector->drm_edid); update_connector_ext_caps(aconnector); } else { drm_dp_cec_unset_edid(&aconnector->dm_dp_aux.aux); amdgpu_dm_update_freesync_caps(connector, NULL); - drm_connector_update_edid_property(connector, NULL); + drm_edid_connector_update(connector, NULL); aconnector->num_modes = 0; dc_sink_release(aconnector->dc_sink); aconnector->dc_sink = NULL; - aconnector->edid = NULL; + drm_edid_free(aconnector->drm_edid); + aconnector->drm_edid = NULL; kfree(aconnector->timing_requested); aconnector->timing_requested = NULL; /* Set CP to DESIRED if it was ENABLED, so we can re-enable it again on hotplug */ @@ -7041,32 +7043,24 @@ static void amdgpu_dm_connector_funcs_force(struct drm_connector *connector) struct amdgpu_dm_connector *aconnector = to_amdgpu_dm_connector(connector); struct dc_link *dc_link = aconnector->dc_link; struct dc_sink *dc_em_sink = aconnector->dc_em_sink; - struct edid *edid; - struct i2c_adapter *ddc; - - if (dc_link && dc_link->aux_mode) - ddc = &aconnector->dm_dp_aux.aux.ddc; - else - ddc = &aconnector->i2c->base; + const struct drm_edid *drm_edid; - /* - * Note: drm_get_edid gets edid in the following order: - * 1) override EDID if set via edid_override debugfs, - * 2) firmware EDID if set via edid_firmware module parameter - * 3) regular DDC read. - */ - edid = drm_get_edid(connector, ddc); - if (!edid) { + drm_edid = drm_edid_read(connector); + drm_edid_connector_update(connector, drm_edid); + if (!drm_edid) { DRM_ERROR("No EDID found on connector: %s.\n", connector->name); return; } - aconnector->edid = edid; - + aconnector->drm_edid = drm_edid; /* Update emulated (virtual) sink's EDID */ if (dc_em_sink && dc_link) { + // FIXME: Get rid of drm_edid_raw() + const struct edid *edid = drm_edid_raw(drm_edid); + memset(&dc_em_sink->edid_caps, 0, sizeof(struct dc_edid_caps)); - memmove(dc_em_sink->dc_edid.raw_edid, edid, (edid->extensions + 1) * EDID_LENGTH); + memmove(dc_em_sink->dc_edid.raw_edid, edid, + (edid->extensions + 1) * EDID_LENGTH); dm_helpers_parse_edid_caps( dc_link, &dc_em_sink->dc_edid, @@ -7096,36 +7090,26 @@ static int get_modes(struct drm_connector *connector) static void create_eml_sink(struct amdgpu_dm_connector *aconnector) { struct drm_connector *connector = &aconnector->base; - struct dc_link *dc_link = aconnector->dc_link; struct dc_sink_init_data init_params = { .link = aconnector->dc_link, .sink_signal = SIGNAL_TYPE_VIRTUAL }; - struct edid *edid; - struct i2c_adapter *ddc; - - if (dc_link->aux_mode) - ddc = &aconnector->dm_dp_aux.aux.ddc; - else - ddc = &aconnector->i2c->base; + const struct drm_edid *drm_edid; + const struct edid *edid; - /* - * Note: drm_get_edid gets edid in the following order: - * 1) override EDID if set via edid_override debugfs, - * 2) firmware EDID if set via edid_firmware module parameter - * 3) regular DDC read. - */ - edid = drm_get_edid(connector, ddc); - if (!edid) { + drm_edid = drm_edid_read(connector); + drm_edid_connector_update(connector, drm_edid); + if (!drm_edid) { DRM_ERROR("No EDID found on connector: %s.\n", connector->name); return; } - if (drm_detect_hdmi_monitor(edid)) + if (connector->display_info.is_hdmi) init_params.sink_signal = SIGNAL_TYPE_HDMI_TYPE_A; - aconnector->edid = edid; + aconnector->drm_edid = drm_edid; + edid = drm_edid_raw(drm_edid); // FIXME: Get rid of drm_edid_raw() aconnector->dc_em_sink = dc_link_add_remote_sink( aconnector->dc_link, (uint8_t *)edid, @@ -7809,16 +7793,16 @@ static void amdgpu_set_panel_orientation(struct drm_connector *connector) } static void amdgpu_dm_connector_ddc_get_modes(struct drm_connector *connector, - struct edid *edid) + const struct drm_edid *drm_edid) { struct amdgpu_dm_connector *amdgpu_dm_connector = to_amdgpu_dm_connector(connector); - if (edid) { + if (drm_edid) { /* empty probed_modes */ INIT_LIST_HEAD(&connector->probed_modes); amdgpu_dm_connector->num_modes = - drm_add_edid_modes(connector, edid); + drm_edid_connector_add_modes(connector); /* sorting the probed modes before calling function * amdgpu_dm_get_native_mode() since EDID can have @@ -7832,10 +7816,10 @@ static void amdgpu_dm_connector_ddc_get_modes(struct drm_connector *connector, amdgpu_dm_get_native_mode(connector); /* Freesync capabilities are reset by calling - * drm_add_edid_modes() and need to be + * drm_edid_connector_add_modes() and need to be * restored here. */ - amdgpu_dm_update_freesync_caps(connector, edid); + amdgpu_dm_update_freesync_caps(connector, drm_edid); } else { amdgpu_dm_connector->num_modes = 0; } @@ -7931,12 +7915,12 @@ static uint add_fs_modes(struct amdgpu_dm_connector *aconnector) } static void amdgpu_dm_connector_add_freesync_modes(struct drm_connector *connector, - struct edid *edid) + const struct drm_edid *drm_edid) { struct amdgpu_dm_connector *amdgpu_dm_connector = to_amdgpu_dm_connector(connector); - if (!(amdgpu_freesync_vid_mode && edid)) + if (!(amdgpu_freesync_vid_mode && drm_edid)) return; if (amdgpu_dm_connector->max_vfreq - amdgpu_dm_connector->min_vfreq > 10) @@ -7949,24 +7933,24 @@ static int amdgpu_dm_connector_get_modes(struct drm_connector *connector) struct amdgpu_dm_connector *amdgpu_dm_connector = to_amdgpu_dm_connector(connector); struct drm_encoder *encoder; - struct edid *edid = amdgpu_dm_connector->edid; + const struct drm_edid *drm_edid = amdgpu_dm_connector->drm_edid; struct dc_link_settings *verified_link_cap = &amdgpu_dm_connector->dc_link->verified_link_cap; const struct dc *dc = amdgpu_dm_connector->dc_link->dc; encoder = amdgpu_dm_connector_to_encoder(connector); - if (!drm_edid_is_valid(edid)) { + if (!drm_edid) { amdgpu_dm_connector->num_modes = drm_add_modes_noedid(connector, 640, 480); if (dc->link_srv->dp_get_encoding_format(verified_link_cap) == DP_128b_132b_ENCODING) amdgpu_dm_connector->num_modes += drm_add_modes_noedid(connector, 1920, 1080); } else { - amdgpu_dm_connector_ddc_get_modes(connector, edid); + amdgpu_dm_connector_ddc_get_modes(connector, drm_edid); if (encoder) amdgpu_dm_connector_add_common_modes(encoder, connector); - amdgpu_dm_connector_add_freesync_modes(connector, edid); + amdgpu_dm_connector_add_freesync_modes(connector, drm_edid); } amdgpu_dm_fbc_init(connector); @@ -11905,7 +11889,7 @@ static bool parse_edid_cea(struct amdgpu_dm_connector *aconnector, } static void parse_edid_displayid_vrr(struct drm_connector *connector, - struct edid *edid) + const struct edid *edid) { u8 *edid_ext = NULL; int i; @@ -11948,7 +11932,7 @@ static void parse_edid_displayid_vrr(struct drm_connector *connector, } static int parse_amd_vsdb(struct amdgpu_dm_connector *aconnector, - struct edid *edid, struct amdgpu_hdmi_vsdb_info *vsdb_info) + const struct edid *edid, struct amdgpu_hdmi_vsdb_info *vsdb_info) { u8 *edid_ext = NULL; int i; @@ -11983,7 +11967,8 @@ static int parse_amd_vsdb(struct amdgpu_dm_connector *aconnector, } static int parse_hdmi_amd_vsdb(struct amdgpu_dm_connector *aconnector, - struct edid *edid, struct amdgpu_hdmi_vsdb_info *vsdb_info) + const struct edid *edid, + struct amdgpu_hdmi_vsdb_info *vsdb_info) { u8 *edid_ext = NULL; int i; @@ -12025,19 +12010,19 @@ static int parse_hdmi_amd_vsdb(struct amdgpu_dm_connector *aconnector, * FreeSync parameters. */ void amdgpu_dm_update_freesync_caps(struct drm_connector *connector, - struct edid *edid) + const struct drm_edid *drm_edid) { int i = 0; - struct detailed_timing *timing; - struct detailed_non_pixel *data; - struct detailed_data_monitor_range *range; + const struct detailed_timing *timing; + const struct detailed_non_pixel *data; + const struct detailed_data_monitor_range *range; struct amdgpu_dm_connector *amdgpu_dm_connector = to_amdgpu_dm_connector(connector); struct dm_connector_state *dm_con_state = NULL; struct dc_sink *sink; - struct amdgpu_device *adev = drm_to_adev(connector->dev); struct amdgpu_hdmi_vsdb_info vsdb_info = {0}; + const struct edid *edid; bool freesync_capable = false; enum adaptive_sync_type as_type = ADAPTIVE_SYNC_TYPE_NONE; @@ -12050,7 +12035,7 @@ void amdgpu_dm_update_freesync_caps(struct drm_connector *connector, amdgpu_dm_connector->dc_sink : amdgpu_dm_connector->dc_em_sink; - if (!edid || !sink) { + if (!drm_edid || !sink) { dm_con_state = to_dm_connector_state(connector->state); amdgpu_dm_connector->min_vfreq = 0; @@ -12067,6 +12052,8 @@ void amdgpu_dm_update_freesync_caps(struct drm_connector *connector, if (!adev->dm.freesync_module) goto update; + edid = drm_edid_raw(drm_edid); // FIXME: Get rid of drm_edid_raw() + /* Some eDP panels only have the refresh rate range info in DisplayID */ if ((connector->display_info.monitor_range.min_vfreq == 0 || connector->display_info.monitor_range.max_vfreq == 0)) @@ -12143,7 +12130,7 @@ void amdgpu_dm_update_freesync_caps(struct drm_connector *connector, amdgpu_dm_connector->as_type = ADAPTIVE_SYNC_TYPE_EDP; } - } else if (edid && sink->sink_signal == SIGNAL_TYPE_HDMI_TYPE_A) { + } else if (drm_edid && sink->sink_signal == SIGNAL_TYPE_HDMI_TYPE_A) { i = parse_hdmi_amd_vsdb(amdgpu_dm_connector, edid, &vsdb_info); if (i >= 0 && vsdb_info.freesync_supported) { timing = &edid->detailed_timings[i]; diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h index 2d7755e2b6c3..c231d3058db8 100644 --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h @@ -673,7 +673,7 @@ struct amdgpu_dm_connector { /* we need to mind the EDID between detect and get modes due to analog/digital/tvencoder */ - struct edid *edid; + const struct drm_edid *drm_edid; /* shared with amdgpu */ struct amdgpu_hpd hpd; @@ -951,7 +951,7 @@ void dm_restore_drm_connector_state(struct drm_device *dev, struct drm_connector *connector); void amdgpu_dm_update_freesync_caps(struct drm_connector *connector, - struct edid *edid); + const struct drm_edid *drm_edid); void amdgpu_dm_trigger_timing_sync(struct drm_device *dev); diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c index b490ae67b6be..be72f14f5429 100644 --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c @@ -897,7 +897,8 @@ enum dc_edid_status dm_helpers_read_local_edid( struct i2c_adapter *ddc; int retry = 3; enum dc_edid_status edid_status; - struct edid *edid; + const struct drm_edid *drm_edid; + const struct edid *edid; if (link->aux_mode) ddc = &aconnector->dm_dp_aux.aux.ddc; @@ -909,25 +910,27 @@ enum dc_edid_status dm_helpers_read_local_edid( */ do { - edid = drm_get_edid(&aconnector->base, ddc); + drm_edid = drm_edid_read_ddc(connector, ddc); + drm_edid_connector_update(connector, drm_edid); /* DP Compliance Test 4.2.2.6 */ if (link->aux_mode && connector->edid_corrupt) drm_dp_send_real_edid_checksum(&aconnector->dm_dp_aux.aux, connector->real_edid_checksum); - if (!edid && connector->edid_corrupt) { + if (!drm_edid && connector->edid_corrupt) { connector->edid_corrupt = false; return EDID_BAD_CHECKSUM; } - if (!edid) + if (!drm_edid) return EDID_NO_RESPONSE; + edid = drm_edid_raw(drm_edid); // FIXME: Get rid of drm_edid_raw() sink->dc_edid.length = EDID_LENGTH * (edid->extensions + 1); memmove(sink->dc_edid.raw_edid, (uint8_t *)edid, sink->dc_edid.length); /* We don't need the original edid anymore */ - kfree(edid); + drm_edid_free(drm_edid); edid_status = dm_helpers_parse_edid_caps( link, diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_mst_types.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_mst_types.c index 2e9f6da1acdc..90a80e799d8b 100644 --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_mst_types.c +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_mst_types.c @@ -129,7 +129,7 @@ dm_dp_mst_connector_destroy(struct drm_connector *connector) dc_sink_release(aconnector->dc_sink); } - kfree(aconnector->edid); + drm_edid_free(aconnector->drm_edid); drm_connector_cleanup(connector); drm_dp_mst_put_port_malloc(aconnector->mst_output_port); @@ -182,7 +182,7 @@ amdgpu_dm_mst_connector_early_unregister(struct drm_connector *connector) dc_sink_release(dc_sink); aconnector->dc_sink = NULL; - aconnector->edid = NULL; + aconnector->drm_edid = NULL; aconnector->dsc_aux = NULL; port->passthrough_aux = NULL; } @@ -302,16 +302,18 @@ static int dm_dp_mst_get_modes(struct drm_connector *connector) if (!aconnector) return drm_add_edid_modes(connector, NULL); - if (!aconnector->edid) { - struct edid *edid; + if (!aconnector->drm_edid) { + const struct drm_edid *drm_edid; - edid = drm_dp_mst_get_edid(connector, &aconnector->mst_root->mst_mgr, aconnector->mst_output_port); + drm_edid = drm_dp_mst_edid_read(connector, + &aconnector->mst_root->mst_mgr, + aconnector->mst_output_port); - if (!edid) { + if (!drm_edid) { amdgpu_dm_set_mst_status(&aconnector->mst_status, MST_REMOTE_EDID, false); - drm_connector_update_edid_property( + drm_edid_connector_update( &aconnector->base, NULL); @@ -345,7 +347,7 @@ static int dm_dp_mst_get_modes(struct drm_connector *connector) return ret; } - aconnector->edid = edid; + aconnector->drm_edid = drm_edid; amdgpu_dm_set_mst_status(&aconnector->mst_status, MST_REMOTE_EDID, true); } @@ -360,10 +362,13 @@ static int dm_dp_mst_get_modes(struct drm_connector *connector) struct dc_sink_init_data init_params = { .link = aconnector->dc_link, .sink_signal = SIGNAL_TYPE_DISPLAY_PORT_MST }; + const struct edid *edid; + + edid = drm_edid_raw(aconnector->drm_edid); // FIXME: Get rid of drm_edid_raw() dc_sink = dc_link_add_remote_sink( aconnector->dc_link, - (uint8_t *)aconnector->edid, - (aconnector->edid->extensions + 1) * EDID_LENGTH, + (uint8_t *)edid, + (edid->extensions + 1) * EDID_LENGTH, &init_params); if (!dc_sink) { @@ -405,7 +410,7 @@ static int dm_dp_mst_get_modes(struct drm_connector *connector) if (aconnector->dc_sink) { amdgpu_dm_update_freesync_caps( - connector, aconnector->edid); + connector, aconnector->drm_edid); #if defined(CONFIG_DRM_AMD_DC_FP) if (!validate_dsc_caps_on_connector(aconnector)) @@ -419,10 +424,9 @@ static int dm_dp_mst_get_modes(struct drm_connector *connector) } } - drm_connector_update_edid_property( - &aconnector->base, aconnector->edid); + drm_edid_connector_update(&aconnector->base, aconnector->drm_edid); - ret = drm_add_edid_modes(connector, aconnector->edid); + ret = drm_edid_connector_add_modes(connector); return ret; } @@ -500,7 +504,7 @@ dm_dp_mst_detect(struct drm_connector *connector, dc_sink_release(aconnector->dc_sink); aconnector->dc_sink = NULL; - aconnector->edid = NULL; + aconnector->drm_edid = NULL; aconnector->dsc_aux = NULL; port->passthrough_aux = NULL; From patchwork Wed Sep 11 21:35:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 13801134 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 E1949EE57D7 for ; Wed, 11 Sep 2024 21:36:04 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id F1D3210EAB3; Wed, 11 Sep 2024 21:35:58 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.b="Vs7D9C6/"; dkim-atps=neutral Received: from nyc.source.kernel.org (nyc.source.kernel.org [147.75.193.91]) by gabe.freedesktop.org (Postfix) with ESMTPS id B576210E922; Wed, 11 Sep 2024 21:35:55 +0000 (UTC) Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by nyc.source.kernel.org (Postfix) with ESMTP id 5541AA44650; Wed, 11 Sep 2024 21:35:47 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 991D2C4CEC6; Wed, 11 Sep 2024 21:35:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1726090554; bh=NQx4mqHS+mLTR+0LBNOQU6bmZLzqnc1wEp+jawVSYhU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Vs7D9C6/I8IRRJqOXIny4a0DdiQp3jmg6KoPVHNFPYTmeOND4Fx+zPuV5AjSxlCbm fRcyVQSpQScLyEPJWHMJ0u6fXpwYfgXyR0y2s/ySViAPY0qjzTuATG8jorSz72G0fk PBkL72KMGC66yrN9UWEkTM0C62FFrAjFxkq5elS39TUG9kJTIC4C52rEAubXoqFmgc tPiMUpj+NrNhUIRnqJX7WgY0r7be09RKAolUiH2USZqDf2uOGrjUNpK0JPtyVPD4gl 8JMxvExW3D1ak24NkAqU/FP5HBkU9sFZTY08zSN1ryE0S0WPcMspdvyzeSQmP6yACE uehKoKMhCl6WA== From: Mario Limonciello To: Alex Hung , Alexander Deucher , Melissa Wen Cc: kernel-dev@igalia.com, Mario Limonciello , amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, harry.wentland@amd.com, sunpeng.li@amd.com, Mark Pearson Subject: [PATCH v6 02/10] drm/amd/display: switch to setting physical address directly Date: Wed, 11 Sep 2024 16:35:28 -0500 Message-ID: <20240911213537.2338164-3-superm1@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240911213537.2338164-1-superm1@kernel.org> References: <20240911213537.2338164-1-superm1@kernel.org> 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: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Melissa Wen Connectors have source physical address available in display info. Use drm_dp_cec_attach() to use it instead of parsing the EDID again. Signed-off-by: Melissa Wen Signed-off-by: Mario Limonciello --- drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 6 +++--- 1 file changed, 3 insertions(+), 3 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 4927fdd45073..f19afa117f15 100644 --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c @@ -3497,8 +3497,7 @@ void amdgpu_dm_update_connector_after_detect( if (sink->dc_edid.length == 0) { aconnector->drm_edid = NULL; if (aconnector->dc_link->aux_mode) { - drm_dp_cec_unset_edid( - &aconnector->dm_dp_aux.aux); + drm_dp_cec_unset_edid(&aconnector->dm_dp_aux.aux); } } else { const struct edid *edid = (const struct edid *)sink->dc_edid.raw_edid; @@ -3507,7 +3506,8 @@ void amdgpu_dm_update_connector_after_detect( drm_edid_connector_update(connector, aconnector->drm_edid); if (aconnector->dc_link->aux_mode) - drm_dp_cec_set_edid(&aconnector->dm_dp_aux.aux, edid); + drm_dp_cec_attach(&aconnector->dm_dp_aux.aux, + connector->display_info.source_physical_address); } if (!aconnector->timing_requested) { From patchwork Wed Sep 11 21:35:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 13801135 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 24326EE57DF for ; Wed, 11 Sep 2024 21:36:07 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 50C5610EAB4; Wed, 11 Sep 2024 21:36:01 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.b="U7CMxVdK"; dkim-atps=neutral Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by gabe.freedesktop.org (Postfix) with ESMTPS id ACFC710EAAF; Wed, 11 Sep 2024 21:35:56 +0000 (UTC) Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 86D6A5C076D; Wed, 11 Sep 2024 21:35:52 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D3B16C4CEC0; Wed, 11 Sep 2024 21:35:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1726090555; bh=+tZD3EFKWPbEt+BMNijyH1Snu6pbvTsLPs6a9dgrmao=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=U7CMxVdKKBodqygR0tVlqmXDREa457YWath38ULg1ITRvOdpqH7iXJGbs+himXfdk I2XyMdXwO43qul2vuybyHR1rVk5n3v79dm9fqODcIlDcVAKfWkt3i/GTZQ4q9QdC4m Au41e0HTTEDtQtvvYZvlU874ocyqmyWgtGcwudrHNxywkTJbL4CaulyE1+rMxtJpqL RLm70eOZViefrwq6ooCYmGoJzkj4gAgOgOJ4Oy38BUgsdb9CupMF0MZhzIkDiXnEpd /rTPU4C5AIZCyYINUyRvIpNbM64qAG6pHRUyCR8FIHEG0msBFAHxql84AypDHcMwZd T1XuZr63L9Rpw== From: Mario Limonciello To: Alex Hung , Alexander Deucher , Melissa Wen Cc: kernel-dev@igalia.com, Mario Limonciello , amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, harry.wentland@amd.com, sunpeng.li@amd.com, Mark Pearson Subject: [PATCH v6 03/10] drm/amd/display: always call connector_update when parsing freesync_caps Date: Wed, 11 Sep 2024 16:35:29 -0500 Message-ID: <20240911213537.2338164-4-superm1@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240911213537.2338164-1-superm1@kernel.org> References: <20240911213537.2338164-1-superm1@kernel.org> 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: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Melissa Wen Update connector caps with drm_edid data before parsing info for freesync. Signed-off-by: Melissa Wen Signed-off-by: Mario Limonciello --- drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 4 ++-- 1 file changed, 2 insertions(+), 2 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 f19afa117f15..49a71c575e45 100644 --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c @@ -3518,13 +3518,11 @@ void amdgpu_dm_update_connector_after_detect( "failed to create aconnector->requested_timing\n"); } - drm_edid_connector_update(connector, aconnector->drm_edid); amdgpu_dm_update_freesync_caps(connector, aconnector->drm_edid); update_connector_ext_caps(aconnector); } else { drm_dp_cec_unset_edid(&aconnector->dm_dp_aux.aux); amdgpu_dm_update_freesync_caps(connector, NULL); - drm_edid_connector_update(connector, NULL); aconnector->num_modes = 0; dc_sink_release(aconnector->dc_sink); aconnector->dc_sink = NULL; @@ -12035,6 +12033,8 @@ void amdgpu_dm_update_freesync_caps(struct drm_connector *connector, amdgpu_dm_connector->dc_sink : amdgpu_dm_connector->dc_em_sink; + drm_edid_connector_update(connector, drm_edid); + if (!drm_edid || !sink) { dm_con_state = to_dm_connector_state(connector->state); From patchwork Wed Sep 11 21:35:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 13801138 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 92A8EEE57DB for ; Wed, 11 Sep 2024 21:36:10 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 8954610EAB7; Wed, 11 Sep 2024 21:36:01 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.b="ZnORJTGT"; dkim-atps=neutral Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by gabe.freedesktop.org (Postfix) with ESMTPS id D7DC810EAB0; Wed, 11 Sep 2024 21:35:57 +0000 (UTC) Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id BE2DE5C06C3; Wed, 11 Sep 2024 21:35:53 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 162CBC4CECD; Wed, 11 Sep 2024 21:35:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1726090557; bh=/Ef7j4rt9d+Ji5cVpbcxQG2CmYBLbLlRXfGhXP3wVaE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZnORJTGTpe94oFaPT1AXxrzXiUxJYYOK3KC9BPCDJYU5Z+TPojgFRksvWZpDpEk8/ O4+R9aQEwwnPNqvbBpJAaXL7yDeJ6eykhYgq3atw8AAcbTIR/y5v8PFcIvPKEhQe9m lYrzx+FhOejlgQUcRY37gnXTlit7IspWqM4/+JrHW8JTfx0YM3sXmKBf0Buk11tfzi NFZlRze7E/mIW9t90PbUPM0lb+EFT6VaaLnPoq2yExKGok/cCmzQi0JBn8Ti/UzpBL P09uQ7Fp07qaJX5Z5BRb54kzwPJ8q5Gni97qbVl1s/H9G9WKyysd0zice714daUgj0 Vy3RIRR8dnF+w== From: Mario Limonciello To: Alex Hung , Alexander Deucher , Melissa Wen Cc: kernel-dev@igalia.com, Mario Limonciello , amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, harry.wentland@amd.com, sunpeng.li@amd.com, Mark Pearson Subject: [PATCH v6 04/10] drm/amd/display: remove redundant freesync parser for DP Date: Wed, 11 Sep 2024 16:35:30 -0500 Message-ID: <20240911213537.2338164-5-superm1@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240911213537.2338164-1-superm1@kernel.org> References: <20240911213537.2338164-1-superm1@kernel.org> 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: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Melissa Wen When updating connector under drm_edid infrastructure, many calculations and validations are already done and become redundant inside AMD driver. Remove those driver-specific code in favor of the DRM common code. Signed-off-by: Melissa Wen Co-developed-by: Mario Limonciello Signed-off-by: Mario Limonciello --- v6: * Drop unneeded is_dp_capable_without_timing_msa() * Rebase on v6.11-rc7 * Add Co-developed-by tag --- .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 91 +------------------ 1 file changed, 4 insertions(+), 87 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 49a71c575e45..a1379ac0e628 100644 --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c @@ -11737,25 +11737,6 @@ static int amdgpu_dm_atomic_check(struct drm_device *dev, return ret; } -static bool is_dp_capable_without_timing_msa(struct dc *dc, - struct amdgpu_dm_connector *amdgpu_dm_connector) -{ - u8 dpcd_data; - bool capable = false; - - if (amdgpu_dm_connector->dc_link && - dm_helpers_dp_read_dpcd( - NULL, - amdgpu_dm_connector->dc_link, - DP_DOWN_STREAM_PORT_COUNT, - &dpcd_data, - sizeof(dpcd_data))) { - capable = (dpcd_data & DP_MSA_TIMING_PAR_IGNORED) ? true:false; - } - - return capable; -} - static bool dm_edid_parser_send_cea(struct amdgpu_display_manager *dm, unsigned int offset, unsigned int total_length, @@ -12011,9 +11992,6 @@ void amdgpu_dm_update_freesync_caps(struct drm_connector *connector, const struct drm_edid *drm_edid) { int i = 0; - const struct detailed_timing *timing; - const struct detailed_non_pixel *data; - const struct detailed_data_monitor_range *range; struct amdgpu_dm_connector *amdgpu_dm_connector = to_amdgpu_dm_connector(connector); struct dm_connector_state *dm_con_state = NULL; @@ -12040,8 +12018,6 @@ void amdgpu_dm_update_freesync_caps(struct drm_connector *connector, amdgpu_dm_connector->min_vfreq = 0; amdgpu_dm_connector->max_vfreq = 0; - connector->display_info.monitor_range.min_vfreq = 0; - connector->display_info.monitor_range.max_vfreq = 0; freesync_capable = false; goto update; @@ -12061,67 +12037,12 @@ void amdgpu_dm_update_freesync_caps(struct drm_connector *connector, if (edid && (sink->sink_signal == SIGNAL_TYPE_DISPLAY_PORT || sink->sink_signal == SIGNAL_TYPE_EDP)) { - bool edid_check_required = false; - - if (is_dp_capable_without_timing_msa(adev->dm.dc, - amdgpu_dm_connector)) { - if (edid->features & DRM_EDID_FEATURE_CONTINUOUS_FREQ) { - amdgpu_dm_connector->min_vfreq = connector->display_info.monitor_range.min_vfreq; - amdgpu_dm_connector->max_vfreq = connector->display_info.monitor_range.max_vfreq; - if (amdgpu_dm_connector->max_vfreq - - amdgpu_dm_connector->min_vfreq > 10) - freesync_capable = true; - } else { - edid_check_required = edid->version > 1 || - (edid->version == 1 && - edid->revision > 1); - } - } - if (edid_check_required) { - for (i = 0; i < 4; i++) { - - timing = &edid->detailed_timings[i]; - data = &timing->data.other_data; - range = &data->data.range; - /* - * Check if monitor has continuous frequency mode - */ - if (data->type != EDID_DETAIL_MONITOR_RANGE) - continue; - /* - * 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 - */ - if (range->flags != 1) - continue; + amdgpu_dm_connector->min_vfreq = connector->display_info.monitor_range.min_vfreq; + amdgpu_dm_connector->max_vfreq = connector->display_info.monitor_range.max_vfreq; + if (amdgpu_dm_connector->max_vfreq - amdgpu_dm_connector->min_vfreq > 10) + freesync_capable = true; - connector->display_info.monitor_range.min_vfreq = range->min_vfreq; - connector->display_info.monitor_range.max_vfreq = range->max_vfreq; - - if (edid->revision >= 4) { - if (data->pad2 & DRM_EDID_RANGE_OFFSET_MIN_VFREQ) - connector->display_info.monitor_range.min_vfreq += 255; - if (data->pad2 & DRM_EDID_RANGE_OFFSET_MAX_VFREQ) - connector->display_info.monitor_range.max_vfreq += 255; - } - - amdgpu_dm_connector->min_vfreq = - connector->display_info.monitor_range.min_vfreq; - amdgpu_dm_connector->max_vfreq = - connector->display_info.monitor_range.max_vfreq; - - break; - } - - if (amdgpu_dm_connector->max_vfreq - - amdgpu_dm_connector->min_vfreq > 10) { - - freesync_capable = true; - } - } parse_amd_vsdb(amdgpu_dm_connector, edid, &vsdb_info); if (vsdb_info.replay_mode) { @@ -12129,13 +12050,9 @@ void amdgpu_dm_update_freesync_caps(struct drm_connector *connector, amdgpu_dm_connector->vsdb_info.amd_vsdb_version = vsdb_info.amd_vsdb_version; amdgpu_dm_connector->as_type = ADAPTIVE_SYNC_TYPE_EDP; } - } else if (drm_edid && sink->sink_signal == SIGNAL_TYPE_HDMI_TYPE_A) { 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; - amdgpu_dm_connector->min_vfreq = vsdb_info.min_refresh_rate_hz; amdgpu_dm_connector->max_vfreq = vsdb_info.max_refresh_rate_hz; if (amdgpu_dm_connector->max_vfreq - amdgpu_dm_connector->min_vfreq > 10) From patchwork Wed Sep 11 21:35:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 13801137 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 4E5F3EE57DD for ; Wed, 11 Sep 2024 21:36:09 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 0A2DC10EAB9; Wed, 11 Sep 2024 21:36:02 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.b="eSPsclrp"; dkim-atps=neutral Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by gabe.freedesktop.org (Postfix) with ESMTPS id 2392810EAB4; Wed, 11 Sep 2024 21:35:59 +0000 (UTC) Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 064DA5C076E; Wed, 11 Sep 2024 21:35:55 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 49768C4CEC0; Wed, 11 Sep 2024 21:35:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1726090558; bh=nhODxcM1QURNsOFuZKCavh92pNBFM1nsGs7Cefqy1/Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=eSPsclrptwcnpw8wpV/n39GS7QGL3OUhYpyz6qddocfV7DExgj+L1ryxJtiESjMBi I9V2htSKHVuV5zTJRuVz/o7fYUZOeeGJ/18dFmfAd/+W1CQ8jYJNxXcxZq3fTZhNU3 RgAVeY4GcsZiR/NO5AhxdgMksnOTWAvaaD86O3s+fVQhfM7x4pn7oiPC3fIJjed02I Yrapy9BP4NxEnoxsFIxoM4U3YsEDWgvXsLasPQBKOIc5EmRPimqCnsYYtnFfu/RDEh cUNWKI6yoDflPsFTX+5Clbal7ujM5TIVJk5tgdEh/c3Ov1xqE6V4drmp8G/jf5YY4z Dwa78idN8/xCg== From: Mario Limonciello To: Alex Hung , Alexander Deucher , Melissa Wen Cc: kernel-dev@igalia.com, Mario Limonciello , amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, harry.wentland@amd.com, sunpeng.li@amd.com, Mark Pearson Subject: [PATCH v6 05/10] drm/amd/display: use drm_edid_product_id for parsing EDID product info Date: Wed, 11 Sep 2024 16:35:31 -0500 Message-ID: <20240911213537.2338164-6-superm1@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240911213537.2338164-1-superm1@kernel.org> References: <20240911213537.2338164-1-superm1@kernel.org> 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: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Melissa Wen Since [1], we can use drm_edid_product_id to get debug info from drm_edid instead of directly parsing EDID. Link: https://lore.kernel.org/dri-devel/cover.1712655867.git.jani.nikula@intel.com/ [1] Signed-off-by: Melissa Wen Co-developed-by: Mario Limonciello Signed-off-by: Mario Limonciello --- v6: Split apply_edid_quirks() to two lines --- .../amd/display/amdgpu_dm/amdgpu_dm_helpers.c | 38 ++++++++++--------- 1 file changed, 20 insertions(+), 18 deletions(-) diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c index be72f14f5429..3f280bc36e87 100644 --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c @@ -45,16 +45,16 @@ #include "dm_helpers.h" #include "ddc_service_types.h" -static u32 edid_extract_panel_id(struct edid *edid) +static u32 edid_extract_panel_id(struct drm_edid_product_id *product_id) { - return (u32)edid->mfg_id[0] << 24 | - (u32)edid->mfg_id[1] << 16 | - (u32)EDID_PRODUCT_ID(edid); + return (u32)be16_to_cpu(product_id->manufacturer_name) << 16 | + (u32)le16_to_cpu(product_id->product_code); } -static void apply_edid_quirks(struct edid *edid, struct dc_edid_caps *edid_caps) +static void apply_edid_quirks(struct drm_edid_product_id *product_id, + struct dc_edid_caps *edid_caps) { - uint32_t panel_id = edid_extract_panel_id(edid); + uint32_t panel_id = edid_extract_panel_id(product_id); switch (panel_id) { /* Workaround for some monitors which does not work well with FAMS */ @@ -94,6 +94,8 @@ enum dc_edid_status dm_helpers_parse_edid_caps( { struct amdgpu_dm_connector *aconnector = link->priv; struct drm_connector *connector = &aconnector->base; + const struct drm_edid *drm_edid = aconnector->drm_edid; + struct drm_edid_product_id product_id; struct edid *edid_buf = edid ? (struct edid *) edid->raw_edid : NULL; struct cea_sad *sads; int sad_count = -1; @@ -109,13 +111,13 @@ enum dc_edid_status dm_helpers_parse_edid_caps( if (!drm_edid_is_valid(edid_buf)) result = EDID_BAD_CHECKSUM; - edid_caps->manufacturer_id = (uint16_t) edid_buf->mfg_id[0] | - ((uint16_t) edid_buf->mfg_id[1])<<8; - edid_caps->product_id = (uint16_t) edid_buf->prod_code[0] | - ((uint16_t) edid_buf->prod_code[1])<<8; - edid_caps->serial_number = edid_buf->serial; - edid_caps->manufacture_week = edid_buf->mfg_week; - edid_caps->manufacture_year = edid_buf->mfg_year; + drm_edid_get_product_id(drm_edid, &product_id); + + edid_caps->manufacturer_id = le16_to_cpu(product_id.manufacturer_name); + edid_caps->product_id = le16_to_cpu(product_id.product_code); + edid_caps->serial_number = le32_to_cpu(product_id.serial_number); + edid_caps->manufacture_week = product_id.week_of_manufacture; + edid_caps->manufacture_year = product_id.year_of_manufacture; drm_edid_get_monitor_name(edid_buf, edid_caps->display_name, @@ -123,7 +125,7 @@ enum dc_edid_status dm_helpers_parse_edid_caps( edid_caps->edid_hdmi = connector->display_info.is_hdmi; - apply_edid_quirks(edid_buf, edid_caps); + apply_edid_quirks(&product_id, edid_caps); sad_count = drm_edid_to_sad((struct edid *) edid->raw_edid, &sads); if (sad_count <= 0) @@ -909,9 +911,9 @@ enum dc_edid_status dm_helpers_read_local_edid( * do check sum and retry to make sure read correct edid. */ do { - drm_edid = drm_edid_read_ddc(connector, ddc); drm_edid_connector_update(connector, drm_edid); + aconnector->drm_edid = drm_edid; /* DP Compliance Test 4.2.2.6 */ if (link->aux_mode && connector->edid_corrupt) @@ -929,14 +931,14 @@ enum dc_edid_status dm_helpers_read_local_edid( sink->dc_edid.length = EDID_LENGTH * (edid->extensions + 1); memmove(sink->dc_edid.raw_edid, (uint8_t *)edid, sink->dc_edid.length); - /* We don't need the original edid anymore */ - drm_edid_free(drm_edid); - edid_status = dm_helpers_parse_edid_caps( link, &sink->dc_edid, &sink->edid_caps); + /* We don't need the original edid anymore */ + drm_edid_free(drm_edid); + } while (edid_status == EDID_BAD_CHECKSUM && --retry > 0); if (edid_status != EDID_OK) From patchwork Wed Sep 11 21:35:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 13801136 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 2C52EEE57D7 for ; Wed, 11 Sep 2024 21:36:08 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id C52A510EAB8; Wed, 11 Sep 2024 21:36:01 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.b="KrWUuA1A"; dkim-atps=neutral Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by gabe.freedesktop.org (Postfix) with ESMTPS id 7A95010EAB4; Wed, 11 Sep 2024 21:36:00 +0000 (UTC) Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 4AFE85C076F; Wed, 11 Sep 2024 21:35:56 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 87C53C4CEC6; Wed, 11 Sep 2024 21:35:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1726090559; bh=FjRNeQDZZiwkhk2/jrLegD2MpmolnCu9JNkjbMBh35c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KrWUuA1ABMoYx+dvhjtBdqeipJveYRDLsgGwgneTJffMtypRcaoc1cfPISYTHkgTw O5JF87rQJfRHb97uvk9IFmQNkrARWl1h/eow3NDwmFG3jf2asmF2hPsE4zpsYtADOK Lnb44G4oiuwOFo9GylvJ/hFEqxbHAy3XNRE/Z6A8qR2MhzqZUHvdBqA4Yy7SZEgBIq dNKr9qy8wQlVozvKsf0+2fVY3Aq02Mt4kNvu2QZj8es5YpISQt9OV+HvlmrbxxvJGT UEhIaj8kodxARmRckTdNIGY+zLyFafJ4Ffm8EBCbeSJCpdS02ScmHCR4kbk1tr85Z6 Myn2yrymJ0S1A== From: Mario Limonciello To: Alex Hung , Alexander Deucher , Melissa Wen Cc: kernel-dev@igalia.com, Mario Limonciello , amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, harry.wentland@amd.com, sunpeng.li@amd.com, Mark Pearson Subject: [PATCH v6 06/10] drm/amd/display: parse display name from drm_eld Date: Wed, 11 Sep 2024 16:35:32 -0500 Message-ID: <20240911213537.2338164-7-superm1@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240911213537.2338164-1-superm1@kernel.org> References: <20240911213537.2338164-1-superm1@kernel.org> 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: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Melissa Wen We don't need to parse dc_edid to get the display name since it's already set in drm_eld which in turn had it values updated when updating connector with the opaque drm_edid. Signed-off-by: Melissa Wen Signed-off-by: Mario Limonciello --- .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c index 3f280bc36e87..b42821a02c9a 100644 --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c @@ -32,7 +32,7 @@ #include #include #include - +#include #include "dm_services.h" #include "amdgpu.h" #include "dc.h" @@ -78,6 +78,7 @@ static void apply_edid_quirks(struct drm_edid_product_id *product_id, } } +#define AMDGPU_ELD_DISPLAY_NAME_SIZE_IN_CHARS 13 /** * dm_helpers_parse_edid_caps() - Parse edid caps * @@ -119,9 +120,10 @@ enum dc_edid_status dm_helpers_parse_edid_caps( edid_caps->manufacture_week = product_id.week_of_manufacture; edid_caps->manufacture_year = product_id.year_of_manufacture; - drm_edid_get_monitor_name(edid_buf, - edid_caps->display_name, - AUDIO_INFO_DISPLAY_NAME_SIZE_IN_CHARS); + memset(edid_caps->display_name, 0, AUDIO_INFO_DISPLAY_NAME_SIZE_IN_CHARS); + memcpy(edid_caps->display_name, + &connector->eld[DRM_ELD_MONITOR_NAME_STRING], + AMDGPU_ELD_DISPLAY_NAME_SIZE_IN_CHARS); edid_caps->edid_hdmi = connector->display_info.is_hdmi; From patchwork Wed Sep 11 21:35:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 13801139 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 0B04EEE57E0 for ; Wed, 11 Sep 2024 21:36:13 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 1180210EAB0; Wed, 11 Sep 2024 21:36:08 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.b="SWJ4133H"; dkim-atps=neutral Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by gabe.freedesktop.org (Postfix) with ESMTPS id 79DFC10EABA; Wed, 11 Sep 2024 21:36:02 +0000 (UTC) Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 541555C0771; Wed, 11 Sep 2024 21:35:58 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C7A75C4CECC; Wed, 11 Sep 2024 21:35:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1726090560; bh=5RZEc9IWush3FT994Fg0fT/HhN9cssZBF4xAbD/bZNI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SWJ4133HPcQ+Wh5RxvrIkCa3uhSMLEHkfE6pus2lGodqDVNoPrEzoDOPkF6rfsLa/ jK+dG4b8G5E2FtoaC6Q/k5dauPk4yTs05SH9SRQ1UHu8myj6SHFC0xVexKhcvWPT1S kFixE1mzH2APvFmW2aT/d96GMdaGx5MLlW4rab6g7bepuIa1GePBbAE9CrE+CHH0gi EYJqa1PJAphMA/hHVs64y9TvIWNx4n7p3s+63HS6yWn7JPJgSgQ0/0JQnno0/f0igz bvSdHW/AuKSqoE5+UIzyek2bkdTeN12FXyGdHWIxaVVZ/GCxGRrOmX2A/3mqL2PaF+ cx9+B8Ur+waVw== From: Mario Limonciello To: Alex Hung , Alexander Deucher , Melissa Wen Cc: kernel-dev@igalia.com, Mario Limonciello , amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, harry.wentland@amd.com, sunpeng.li@amd.com, Mark Pearson Subject: [PATCH v6 07/10] drm/amd/display: get SAD from drm_eld when parsing EDID caps Date: Wed, 11 Sep 2024 16:35:33 -0500 Message-ID: <20240911213537.2338164-8-superm1@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240911213537.2338164-1-superm1@kernel.org> References: <20240911213537.2338164-1-superm1@kernel.org> 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: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Melissa Wen drm_edid_connector_update() updates display info, filling ELD with audio info from Short-Audio Descriptors in the last step of update_dislay_info(). Our goal is stopping using raw edid, so we can extract SAD from drm_eld instead of access raw edid to get audio caps. Signed-off-by: Melissa Wen Signed-off-by: Mario Limonciello --- v6: - Move changelog to below cutlist v5: - squash with `don't give initial values for sad/b_count` (Alex H) - add more informative commit description (Alex H) --- .../amd/display/amdgpu_dm/amdgpu_dm_helpers.c | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c index b42821a02c9a..1bc9c12ab120 100644 --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c @@ -98,9 +98,7 @@ enum dc_edid_status dm_helpers_parse_edid_caps( const struct drm_edid *drm_edid = aconnector->drm_edid; struct drm_edid_product_id product_id; struct edid *edid_buf = edid ? (struct edid *) edid->raw_edid : NULL; - struct cea_sad *sads; - int sad_count = -1; - int sadb_count = -1; + int sad_count, sadb_count; int i = 0; uint8_t *sadb = NULL; @@ -129,18 +127,21 @@ enum dc_edid_status dm_helpers_parse_edid_caps( apply_edid_quirks(&product_id, edid_caps); - sad_count = drm_edid_to_sad((struct edid *) edid->raw_edid, &sads); + sad_count = drm_eld_sad_count(connector->eld); if (sad_count <= 0) return result; edid_caps->audio_mode_count = min(sad_count, DC_MAX_AUDIO_DESC_COUNT); for (i = 0; i < edid_caps->audio_mode_count; ++i) { - struct cea_sad *sad = &sads[i]; + struct cea_sad sad; - edid_caps->audio_modes[i].format_code = sad->format; - edid_caps->audio_modes[i].channel_count = sad->channels + 1; - edid_caps->audio_modes[i].sample_rate = sad->freq; - edid_caps->audio_modes[i].sample_size = sad->byte2; + if (drm_eld_sad_get(connector->eld, i, &sad) < 0) + continue; + + edid_caps->audio_modes[i].format_code = sad.format; + edid_caps->audio_modes[i].channel_count = sad.channels + 1; + edid_caps->audio_modes[i].sample_rate = sad.freq; + edid_caps->audio_modes[i].sample_size = sad.byte2; } sadb_count = drm_edid_to_speaker_allocation((struct edid *) edid->raw_edid, &sadb); @@ -155,7 +156,6 @@ enum dc_edid_status dm_helpers_parse_edid_caps( else edid_caps->speaker_flags = DEFAULT_SPEAKER_LOCATION; - kfree(sads); kfree(sadb); return result; From patchwork Wed Sep 11 21:35:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 13801140 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 C943EEE57E1 for ; Wed, 11 Sep 2024 21:36:13 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 4E8D410EABF; Wed, 11 Sep 2024 21:36:08 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.b="BAnHwzo6"; dkim-atps=neutral Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by gabe.freedesktop.org (Postfix) with ESMTPS id D04C310EABC; Wed, 11 Sep 2024 21:36:02 +0000 (UTC) Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id A83655C0774; Wed, 11 Sep 2024 21:35:58 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0C723C4CEC6; Wed, 11 Sep 2024 21:36:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1726090562; bh=1T51Tb6/BNcKzoFLfJU76j99M3iPitxo8d33dkbNssY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BAnHwzo6smNkSBNq412Nc2CMyZIpbi8OGfbMyZ3SJfw0IolgvlxwkXRoE3fXdrORT RjBhk919f6Ie8kFGqM0/PvIJwm1tj7yh7t9IugLI18P64ekGJtTrLqdQPIHulh3QBp n0UvuLxuRpkUVs7Os59q6X8VDO9+g455Ko3IGI99lqVYx/DFBrhALhFNSAOWhHEuZa ZoBQszGVrYPyQUatSON0X/KoKRIntPaVkEYlqBchzsSaKxenLvEysxYii59bONKujo Je5GgPhXDrlULIVoFoZBWYzeWfLv1mwJM7MazSCwM6bOrSxx+04g8sckYn77DmmUXy qTeiKmqXLV0mA== From: Mario Limonciello To: Alex Hung , Alexander Deucher , Melissa Wen Cc: kernel-dev@igalia.com, Mario Limonciello , amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, harry.wentland@amd.com, sunpeng.li@amd.com, Mark Pearson Subject: [PATCH v6 08/10] drm/amd/display: get SADB from drm_eld when parsing EDID caps Date: Wed, 11 Sep 2024 16:35:34 -0500 Message-ID: <20240911213537.2338164-9-superm1@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240911213537.2338164-1-superm1@kernel.org> References: <20240911213537.2338164-1-superm1@kernel.org> 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: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Melissa Wen drm_edid_connector_update() updates display info, filling ELD with speaker allocation data in the last step of update_dislay_info(). Our goal is stopping using raw edid, so we can extract SADB from drm_eld instead of access raw edid to get audio caps. Signed-off-by: Melissa Wen Signed-off-by: Mario Limonciello --- v6: Move changelog below cutlist v5: add more informative commit description (Alex H) --- .../drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c index 1bc9c12ab120..72ea78ff2c5b 100644 --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c @@ -98,9 +98,8 @@ enum dc_edid_status dm_helpers_parse_edid_caps( const struct drm_edid *drm_edid = aconnector->drm_edid; struct drm_edid_product_id product_id; struct edid *edid_buf = edid ? (struct edid *) edid->raw_edid : NULL; - int sad_count, sadb_count; + int sad_count; int i = 0; - uint8_t *sadb = NULL; enum dc_edid_status result = EDID_OK; @@ -144,20 +143,12 @@ enum dc_edid_status dm_helpers_parse_edid_caps( edid_caps->audio_modes[i].sample_size = sad.byte2; } - sadb_count = drm_edid_to_speaker_allocation((struct edid *) edid->raw_edid, &sadb); - if (sadb_count < 0) { - DRM_ERROR("Couldn't read Speaker Allocation Data Block: %d\n", sadb_count); - sadb_count = 0; - } - - if (sadb_count) - edid_caps->speaker_flags = sadb[0]; + if (connector->eld[DRM_ELD_SPEAKER]) + edid_caps->speaker_flags = connector->eld[DRM_ELD_SPEAKER]; else edid_caps->speaker_flags = DEFAULT_SPEAKER_LOCATION; - kfree(sadb); - return result; } From patchwork Wed Sep 11 21:35:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 13801148 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 5C80CEE57DE for ; Wed, 11 Sep 2024 21:36:16 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 3338510EAC6; Wed, 11 Sep 2024 21:36:10 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.b="eKRCVwUI"; dkim-atps=neutral Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by gabe.freedesktop.org (Postfix) with ESMTPS id 4D1CF10EAB2; Wed, 11 Sep 2024 21:36:04 +0000 (UTC) Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 18CBA5C0775; Wed, 11 Sep 2024 21:36:00 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4CE16C4CECD; Wed, 11 Sep 2024 21:36:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1726090563; bh=7tShgrqf0WYpeU7vGOpHUCbGacprP/Qcboukklbpohw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=eKRCVwUIfwtoOfBhc/JEUp2eYgBy578OXGNCiT2SGX9DVqUtrpnY4zYsugcBcxVu4 AjgQmY5T0izylPsimNqTqmcwBqHf4igg6Y+afu/FwLJ8N0rZ2pOWrizLJWdZb2GInR 2HoDU88BbtUyHNujAt2/a7KZhiwrkThxo+RJfqdM9sp2k1rZrvtHaBhcEk7U3UgGou OFQL1kgRAabz8L4u3MT75hJqX19hMLsc0VoZXAmcuVpDFMIrVxZnQnjhzo40cpltZb aGZBkw1HRMnxJqON2HnerQmXuwKneED7knWeVnyHabXkE5zgfd5CLyJ5eUoddkXITU DG6dw3BPV3fKA== From: Mario Limonciello To: Alex Hung , Alexander Deucher , Melissa Wen Cc: kernel-dev@igalia.com, Mario Limonciello , amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, harry.wentland@amd.com, sunpeng.li@amd.com, Mark Pearson Subject: [PATCH v6 09/10] drm/amd/display: remove dc_edid handler from dm_helpers_parse_edid_caps Date: Wed, 11 Sep 2024 16:35:35 -0500 Message-ID: <20240911213537.2338164-10-superm1@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240911213537.2338164-1-superm1@kernel.org> References: <20240911213537.2338164-1-superm1@kernel.org> 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: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Melissa Wen We can parse edid caps from drm_edid and drm_eld and any calls of dm_helpers_parse_edid_caps is made in a state that we have drm_edid set to amdgpu connector. Signed-off-by: Melissa Wen Co-developed-by: Mario Limonciello Signed-off-by: Mario Limonciello --- v6: - Move changelog below cutlist - Rebase on v6.11-rc7 v5: also remove the parameter from kernel-doc (kernel test bot) --- .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 5 +--- .../amd/display/amdgpu_dm/amdgpu_dm_helpers.c | 30 ++++++++----------- drivers/gpu/drm/amd/display/dc/dm_helpers.h | 1 - .../drm/amd/display/dc/link/link_detection.c | 6 ++-- 4 files changed, 16 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 a1379ac0e628..d3074a020ba1 100644 --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c @@ -7059,10 +7059,7 @@ static void amdgpu_dm_connector_funcs_force(struct drm_connector *connector) memset(&dc_em_sink->edid_caps, 0, sizeof(struct dc_edid_caps)); memmove(dc_em_sink->dc_edid.raw_edid, edid, (edid->extensions + 1) * EDID_LENGTH); - dm_helpers_parse_edid_caps( - dc_link, - &dc_em_sink->dc_edid, - &dc_em_sink->edid_caps); + dm_helpers_parse_edid_caps(dc_link, &dc_em_sink->edid_caps); } } diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c index 72ea78ff2c5b..1118986bb3e2 100644 --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c @@ -83,32 +83,24 @@ static void apply_edid_quirks(struct drm_edid_product_id *product_id, * dm_helpers_parse_edid_caps() - Parse edid caps * * @link: current detected link - * @edid: [in] pointer to edid * @edid_caps: [in] pointer to edid caps * * Return: void */ -enum dc_edid_status dm_helpers_parse_edid_caps( - struct dc_link *link, - const struct dc_edid *edid, - struct dc_edid_caps *edid_caps) +enum dc_edid_status dm_helpers_parse_edid_caps(struct dc_link *link, + struct dc_edid_caps *edid_caps) { struct amdgpu_dm_connector *aconnector = link->priv; struct drm_connector *connector = &aconnector->base; const struct drm_edid *drm_edid = aconnector->drm_edid; struct drm_edid_product_id product_id; - struct edid *edid_buf = edid ? (struct edid *) edid->raw_edid : NULL; int sad_count; int i = 0; - enum dc_edid_status result = EDID_OK; - if (!edid_caps || !edid) + if (!edid_caps || !drm_edid) return EDID_BAD_INPUT; - if (!drm_edid_is_valid(edid_buf)) - result = EDID_BAD_CHECKSUM; - drm_edid_get_product_id(drm_edid, &product_id); edid_caps->manufacturer_id = le16_to_cpu(product_id.manufacturer_name); @@ -920,19 +912,23 @@ enum dc_edid_status dm_helpers_read_local_edid( if (!drm_edid) return EDID_NO_RESPONSE; - edid = drm_edid_raw(drm_edid); // FIXME: Get rid of drm_edid_raw() + /* FIXME: Get rid of drm_edid_raw() + * Raw edid is still needed for dm_helpers_dp_write_dpcd() + */ + edid = drm_edid_raw(drm_edid); sink->dc_edid.length = EDID_LENGTH * (edid->extensions + 1); memmove(sink->dc_edid.raw_edid, (uint8_t *)edid, sink->dc_edid.length); edid_status = dm_helpers_parse_edid_caps( link, - &sink->dc_edid, &sink->edid_caps); - /* We don't need the original edid anymore */ - drm_edid_free(drm_edid); - - } while (edid_status == EDID_BAD_CHECKSUM && --retry > 0); + if (edid_status != EDID_OK) { + /* We can discard the drm_edid and retry */ + drm_edid_free(drm_edid); + drm_edid_connector_update(connector, drm_edid); + } + } while (edid_status != EDID_OK && --retry > 0); if (edid_status != EDID_OK) DRM_ERROR("EDID err: %d, on connector: %s", diff --git a/drivers/gpu/drm/amd/display/dc/dm_helpers.h b/drivers/gpu/drm/amd/display/dc/dm_helpers.h index 34adae7ab6e8..bcdfc46c844e 100644 --- a/drivers/gpu/drm/amd/display/dc/dm_helpers.h +++ b/drivers/gpu/drm/amd/display/dc/dm_helpers.h @@ -61,7 +61,6 @@ void dm_helpers_free_gpu_mem( enum dc_edid_status dm_helpers_parse_edid_caps( struct dc_link *link, - const struct dc_edid *edid, struct dc_edid_caps *edid_caps); diff --git a/drivers/gpu/drm/amd/display/dc/link/link_detection.c b/drivers/gpu/drm/amd/display/dc/link/link_detection.c index bba644024780..c7bb146636b2 100644 --- a/drivers/gpu/drm/amd/display/dc/link/link_detection.c +++ b/drivers/gpu/drm/amd/display/dc/link/link_detection.c @@ -1417,10 +1417,8 @@ struct dc_sink *link_add_remote_sink( dc_sink)) goto fail_add_sink; - edid_status = dm_helpers_parse_edid_caps( - link, - &dc_sink->dc_edid, - &dc_sink->edid_caps); + edid_status = dm_helpers_parse_edid_caps(link, + &dc_sink->edid_caps); /* * Treat device as no EDID device if EDID From patchwork Wed Sep 11 21:35:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 13801141 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 8ED63EE57DB for ; Wed, 11 Sep 2024 21:36:14 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 71A7C10EAC0; Wed, 11 Sep 2024 21:36:08 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.b="lWOsx+xk"; dkim-atps=neutral Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by gabe.freedesktop.org (Postfix) with ESMTPS id 3843E10EABC; Wed, 11 Sep 2024 21:36:06 +0000 (UTC) Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 145B85C0780; Wed, 11 Sep 2024 21:36:02 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8DB9CC4CEC6; Wed, 11 Sep 2024 21:36:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1726090564; bh=vPifgjQo5kfkxp7/usZZ/zXq5MkQ4YXB2TR4R9P+6to=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lWOsx+xkn4GMYUaPZerv91xbG1y9De2q8/atCT2XKvISoc/7ILzCNL73IRBXUJTn/ aSFjLbovI61QItNJh78824cXKSc5KO5U/7qzWWRxXrdYC0hbRsq5v4XoZ308+ftfOp 17SJHXGkybpqxAltdiSNQ2BdON54W28fnXWTjwPysMOVu52u9yIqy3fhVu+6UReiUn 8+naKVGMfP6SYU5RXDEx2sCkrxC59ybPhT7XceRJcoO8938F+nBYvKy3kLTOn2sWcX 7QnnrDQB/HYr6cNXUVjWw7BQybtTLnkjeRuZ/p0+dAPs0pl6eQeccKO9s4BwTRSXfa vSeG69t0WKXUA== From: Mario Limonciello To: Alex Hung , Alexander Deucher , Melissa Wen Cc: kernel-dev@igalia.com, Mario Limonciello , amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, harry.wentland@amd.com, sunpeng.li@amd.com, Mark Pearson Subject: [PATCH v6 10/10] drm/amd/display: Fetch the EDID from _DDC if available for eDP Date: Wed, 11 Sep 2024 16:35:36 -0500 Message-ID: <20240911213537.2338164-11-superm1@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240911213537.2338164-1-superm1@kernel.org> References: <20240911213537.2338164-1-superm1@kernel.org> 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: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Mario Limonciello Some manufacturers have intentionally put an EDID that differs from the EDID on the internal panel on laptops. Attempt to fetch this EDID if it exists and prefer it over the EDID that is provided by the panel. If a user prefers to use the EDID from the panel, offer a DC debugging parameter that would disable this. Signed-off-by: Mario Limonciello --- .../amd/display/amdgpu_dm/amdgpu_dm_helpers.c | 63 ++++++++++++++++++- drivers/gpu/drm/amd/include/amd_shared.h | 1 + 2 files changed, 63 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c index 1118986bb3e2..26d5fff6e185 100644 --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c @@ -23,6 +23,8 @@ * */ +#include + #include #include #include @@ -874,6 +876,61 @@ bool dm_helpers_is_dp_sink_present(struct dc_link *link) return dp_sink_present; } +static int +dm_helpers_probe_acpi_edid(void *data, u8 *buf, unsigned int block, size_t len) +{ + struct drm_connector *connector = data; + struct drm_device *ddev = connector->dev; + struct acpi_device *acpidev = ACPI_COMPANION(ddev->dev); + unsigned char start = block * EDID_LENGTH; + void *edid; + int r; + + if (!acpidev) + return -ENODEV; + + /* fetch the entire edid from BIOS */ + r = acpi_video_get_edid(acpidev, ACPI_VIDEO_DISPLAY_LCD, -1, &edid); + if (r < 0) { + DRM_DEBUG_KMS("Failed to get EDID from ACPI: %d\n", r); + return r; + } + if (len > r || start > r || start + len > r) { + r = -EINVAL; + goto cleanup; + } + + memcpy(buf, edid + start, len); + r = 0; + +cleanup: + kfree(edid); + + return r; +} + +static const struct drm_edid * +dm_helpers_read_acpi_edid(struct amdgpu_dm_connector *aconnector) +{ + struct drm_connector *connector = &aconnector->base; + + if (amdgpu_dc_debug_mask & DC_DISABLE_ACPI_EDID) + return NULL; + + switch (connector->connector_type) { + case DRM_MODE_CONNECTOR_LVDS: + case DRM_MODE_CONNECTOR_eDP: + break; + default: + return NULL; + } + + if (connector->force == DRM_FORCE_OFF) + return NULL; + + return drm_edid_read_custom(connector, dm_helpers_probe_acpi_edid, connector); +} + enum dc_edid_status dm_helpers_read_local_edid( struct dc_context *ctx, struct dc_link *link, @@ -896,7 +953,11 @@ enum dc_edid_status dm_helpers_read_local_edid( * do check sum and retry to make sure read correct edid. */ do { - drm_edid = drm_edid_read_ddc(connector, ddc); + drm_edid = dm_helpers_read_acpi_edid(aconnector); + if (drm_edid) + DRM_DEBUG_KMS("Using ACPI provided EDID for %s\n", connector->name); + else + drm_edid = drm_edid_read_ddc(connector, ddc); drm_edid_connector_update(connector, drm_edid); aconnector->drm_edid = drm_edid; diff --git a/drivers/gpu/drm/amd/include/amd_shared.h b/drivers/gpu/drm/amd/include/amd_shared.h index f5b725f10a7c..9702eba767f9 100644 --- a/drivers/gpu/drm/amd/include/amd_shared.h +++ b/drivers/gpu/drm/amd/include/amd_shared.h @@ -264,6 +264,7 @@ enum DC_DEBUG_MASK { DC_DISABLE_PSR_SU = 0x200, DC_DISABLE_REPLAY = 0x400, DC_DISABLE_IPS = 0x800, + DC_DISABLE_ACPI_EDID = 0x1000, }; enum amd_dpm_forced_level;