From patchwork Fri Jun 9 08:45:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Golani, Mitulkumar Ajitkumar" X-Patchwork-Id: 13273491 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 C2E3EC7EE37 for ; Fri, 9 Jun 2023 08:44:10 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 2C2E110E228; Fri, 9 Jun 2023 08:44:10 +0000 (UTC) Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by gabe.freedesktop.org (Postfix) with ESMTPS id 20BD9892F6 for ; Fri, 9 Jun 2023 08:44:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1686300246; x=1717836246; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=nqJPTRznm6sflusXEJSjLf+fciWQ+0KYP3JkS0mFOgs=; b=KvdqSu7xCzw66Vjqa3UpXQNCBVgf5xv6ONaEYFtSscpi4TQ8NxxCaKxM JuopRJr6Lfwl4zFeWhi0POO56SPwHUhL2WIQId1iPS+bQ6gDE+osrqhp9 FIQHrUe9Xg+zBvJ3RsCoD6SOFYGGKLi4oHevI37xBi5Noysty0G+brM/C A5+4zRTYzRI1o/Ris0Thm7J+HzuZnKZJH6Xh3Quzj+f6e7du/ibNPZd7M eopyKx7SXV49QjlNap3jegOedIEWTaP4DH2gt5ZDMOaMC8/OnfFmyvxps +DoNrbAdRVeC/F2TdAuJrF0wKyHIXxYuHriq4R3Y4YpOZq8D2YY+4/Dpq A==; X-IronPort-AV: E=McAfee;i="6600,9927,10735"; a="357553420" X-IronPort-AV: E=Sophos;i="6.00,228,1681196400"; d="scan'208";a="357553420" Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Jun 2023 01:44:05 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10735"; a="884501526" X-IronPort-AV: E=Sophos;i="6.00,228,1681196400"; d="scan'208";a="884501526" Received: from mgolanimitul-x299-ud4-pro.iind.intel.com ([10.190.239.114]) by orsmga005.jf.intel.com with ESMTP; 09 Jun 2023 01:44:04 -0700 From: Mitul Golani To: intel-gfx@lists.freedesktop.org Date: Fri, 9 Jun 2023 14:15:01 +0530 Message-Id: <20230609084504.1929424-2-mitulkumar.ajitkumar.golani@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230609084504.1929424-1-mitulkumar.ajitkumar.golani@intel.com> References: <20230609084504.1929424-1-mitulkumar.ajitkumar.golani@intel.com> MIME-Version: 1.0 Subject: [Intel-gfx] [RFC 1/4] drm/i915/hdmi: Add audio config related params in crtc_state 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: , Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" Add source audio-related config params in crtc_state. These params can be supported frequency, supported channel, and audio support, which can be further computed based on source capabilities. Signed-off-by: Mitul Golani --- drivers/gpu/drm/i915/display/intel_display_types.h | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/i915/display/intel_display_types.h b/drivers/gpu/drm/i915/display/intel_display_types.h index 731f2ec04d5c..873a60f3f870 100644 --- a/drivers/gpu/drm/i915/display/intel_display_types.h +++ b/drivers/gpu/drm/i915/display/intel_display_types.h @@ -1129,9 +1129,15 @@ struct intel_crtc_state { /* Whether we should send NULL infoframes. Required for audio. */ bool has_hdmi_sink; - /* Audio enabled on this pipe. Only valid if either has_hdmi_sink or - * has_dp_encoder is set. */ - bool has_audio; + struct { + bool has_audio; + + /* Audio rate in Hz */ + unsigned int max_frequency; + + /* Number of audio channels */ + unsigned int max_channel; + } audio_config; /* * Enable dithering, used when the selected pipe bpp doesn't match the From patchwork Fri Jun 9 08:45:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Golani, Mitulkumar Ajitkumar" X-Patchwork-Id: 13273493 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 B011EC7EE37 for ; Fri, 9 Jun 2023 08:44:26 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id B5FB210E662; Fri, 9 Jun 2023 08:44:25 +0000 (UTC) Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by gabe.freedesktop.org (Postfix) with ESMTPS id 1F1EE10E65A for ; Fri, 9 Jun 2023 08:44: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=1686300263; x=1717836263; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=NAy+gWVMWldsLw3dAquI+NyuDCFCEcAtHxfp02sBOOk=; b=UlS96i63vxFfWKrRRCxm095Q7ZfwQWzZh8kicRjG4KqS77lgFvxVElun c9Q18x2uh8KA4ZDQ95ZWL+NACLqLQ3Hf0I4fs3OJOw9BpZ3x9x1sbomjY 4Mgy4puS0Kuu6jCbz3aAyerOZORchw//9sfcs7PGvzc349m0Y02op2iHv pcBtXqxhmD/0CB8NcmraQeEJuK+yArZ3AFjf0VgXl/hNMAToHFSvwRDuN uUC52H+53/Tc/UWMRhEGvvykWyjttOv0mbLBDfjmMIWHTahH28RCiLIYp uEorKyuuxVOWo/t+rs/jjW3d939+CeUhdU7apSK5UIWuIKmoVd5pWjf7N A==; X-IronPort-AV: E=McAfee;i="6600,9927,10735"; a="357553428" X-IronPort-AV: E=Sophos;i="6.00,228,1681196400"; d="scan'208";a="357553428" Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Jun 2023 01:44:08 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10735"; a="884501545" X-IronPort-AV: E=Sophos;i="6.00,228,1681196400"; d="scan'208";a="884501545" Received: from mgolanimitul-x299-ud4-pro.iind.intel.com ([10.190.239.114]) by orsmga005.jf.intel.com with ESMTP; 09 Jun 2023 01:44:06 -0700 From: Mitul Golani To: intel-gfx@lists.freedesktop.org Date: Fri, 9 Jun 2023 14:15:02 +0530 Message-Id: <20230609084504.1929424-3-mitulkumar.ajitkumar.golani@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230609084504.1929424-1-mitulkumar.ajitkumar.golani@intel.com> References: <20230609084504.1929424-1-mitulkumar.ajitkumar.golani@intel.com> MIME-Version: 1.0 Subject: [Intel-gfx] [RFC 2/4] drm/i915/display: Update access of has_audio param 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: , Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" Update access of has_audio param from crtc_state pointer as it is wrapped under audio_config. Signed-off-by: Mitul Golani --- drivers/gpu/drm/i915/display/g4x_dp.c | 4 ++-- drivers/gpu/drm/i915/display/g4x_hdmi.c | 16 ++++++++-------- drivers/gpu/drm/i915/display/intel_audio.c | 6 +++--- drivers/gpu/drm/i915/display/intel_cdclk.c | 6 +++--- .../gpu/drm/i915/display/intel_crtc_state_dump.c | 4 ++-- drivers/gpu/drm/i915/display/intel_ddi.c | 2 +- drivers/gpu/drm/i915/display/intel_display.c | 4 ++-- drivers/gpu/drm/i915/display/intel_dp.c | 2 +- drivers/gpu/drm/i915/display/intel_dp_mst.c | 2 +- drivers/gpu/drm/i915/display/intel_hdmi.c | 2 +- drivers/gpu/drm/i915/display/intel_sdvo.c | 10 +++++----- 11 files changed, 29 insertions(+), 29 deletions(-) diff --git a/drivers/gpu/drm/i915/display/g4x_dp.c b/drivers/gpu/drm/i915/display/g4x_dp.c index 112d91d81fdc..741896db0b38 100644 --- a/drivers/gpu/drm/i915/display/g4x_dp.c +++ b/drivers/gpu/drm/i915/display/g4x_dp.c @@ -345,7 +345,7 @@ static void intel_dp_get_config(struct intel_encoder *encoder, tmp = intel_de_read(dev_priv, intel_dp->output_reg); - pipe_config->has_audio = tmp & DP_AUDIO_OUTPUT_ENABLE && port != PORT_A; + pipe_config->audio_config.has_audio = tmp & DP_AUDIO_OUTPUT_ENABLE && port != PORT_A; if (HAS_PCH_CPT(dev_priv) && port != PORT_A) { u32 trans_dp = intel_de_read(dev_priv, @@ -625,7 +625,7 @@ static void intel_dp_enable_port(struct intel_dp *intel_dp, * fail when the power sequencer is freshly used for this port. */ intel_dp->DP |= DP_PORT_EN; - if (crtc_state->has_audio) + if (crtc_state->audio_config.has_audio) intel_dp->DP |= DP_AUDIO_OUTPUT_ENABLE; intel_de_write(dev_priv, intel_dp->output_reg, intel_dp->DP); diff --git a/drivers/gpu/drm/i915/display/g4x_hdmi.c b/drivers/gpu/drm/i915/display/g4x_hdmi.c index 5c187e6e0472..5607e750f576 100644 --- a/drivers/gpu/drm/i915/display/g4x_hdmi.c +++ b/drivers/gpu/drm/i915/display/g4x_hdmi.c @@ -178,7 +178,7 @@ static void intel_hdmi_get_config(struct intel_encoder *encoder, pipe_config->has_infoframe = true; if (tmp & HDMI_AUDIO_ENABLE) - pipe_config->has_audio = true; + pipe_config->audio_config.has_audio = true; if (!HAS_PCH_SPLIT(dev_priv) && tmp & HDMI_COLOR_RANGE_16_235) @@ -224,7 +224,7 @@ static void g4x_hdmi_enable_port(struct intel_encoder *encoder, temp = intel_de_read(dev_priv, intel_hdmi->hdmi_reg); temp |= SDVO_ENABLE; - if (pipe_config->has_audio) + if (pipe_config->audio_config.has_audio) temp |= HDMI_AUDIO_ENABLE; intel_de_write(dev_priv, intel_hdmi->hdmi_reg, temp); @@ -240,7 +240,7 @@ static void g4x_enable_hdmi(struct intel_atomic_state *state, g4x_hdmi_enable_port(encoder, pipe_config); - drm_WARN_ON(&dev_priv->drm, pipe_config->has_audio && + drm_WARN_ON(&dev_priv->drm, pipe_config->audio_config.has_audio && !pipe_config->has_hdmi_sink); intel_audio_codec_enable(encoder, pipe_config, conn_state); } @@ -258,7 +258,7 @@ static void ibx_enable_hdmi(struct intel_atomic_state *state, temp = intel_de_read(dev_priv, intel_hdmi->hdmi_reg); temp |= SDVO_ENABLE; - if (pipe_config->has_audio) + if (pipe_config->audio_config.has_audio) temp |= HDMI_AUDIO_ENABLE; /* @@ -293,7 +293,7 @@ static void ibx_enable_hdmi(struct intel_atomic_state *state, intel_de_posting_read(dev_priv, intel_hdmi->hdmi_reg); } - drm_WARN_ON(&dev_priv->drm, pipe_config->has_audio && + drm_WARN_ON(&dev_priv->drm, pipe_config->audio_config.has_audio && !pipe_config->has_hdmi_sink); intel_audio_codec_enable(encoder, pipe_config, conn_state); } @@ -313,7 +313,7 @@ static void cpt_enable_hdmi(struct intel_atomic_state *state, temp = intel_de_read(dev_priv, intel_hdmi->hdmi_reg); temp |= SDVO_ENABLE; - if (pipe_config->has_audio) + if (pipe_config->audio_config.has_audio) temp |= HDMI_AUDIO_ENABLE; /* @@ -348,7 +348,7 @@ static void cpt_enable_hdmi(struct intel_atomic_state *state, TRANS_CHICKEN1_HDMIUNIT_GC_DISABLE, 0); } - drm_WARN_ON(&dev_priv->drm, pipe_config->has_audio && + drm_WARN_ON(&dev_priv->drm, pipe_config->audio_config.has_audio && !pipe_config->has_hdmi_sink); intel_audio_codec_enable(encoder, pipe_config, conn_state); } @@ -360,7 +360,7 @@ static void vlv_enable_hdmi(struct intel_atomic_state *state, { struct drm_i915_private *dev_priv = to_i915(encoder->base.dev); - drm_WARN_ON(&dev_priv->drm, pipe_config->has_audio && + drm_WARN_ON(&dev_priv->drm, pipe_config->audio_config.has_audio && !pipe_config->has_hdmi_sink); intel_audio_codec_enable(encoder, pipe_config, conn_state); } diff --git a/drivers/gpu/drm/i915/display/intel_audio.c b/drivers/gpu/drm/i915/display/intel_audio.c index 3d9c9b4f27f8..b4a0dae65cbf 100644 --- a/drivers/gpu/drm/i915/display/intel_audio.c +++ b/drivers/gpu/drm/i915/display/intel_audio.c @@ -815,7 +815,7 @@ void intel_audio_codec_enable(struct intel_encoder *encoder, struct intel_audio_state *audio_state; enum port port = encoder->port; - if (!crtc_state->has_audio) + if (!crtc_state->audio_config.has_audio) return; drm_dbg_kms(&i915->drm, "[CONNECTOR:%d:%s][ENCODER:%d:%s] Enable audio codec on [CRTC:%d:%s], %u bytes ELD\n", @@ -874,7 +874,7 @@ void intel_audio_codec_disable(struct intel_encoder *encoder, struct intel_audio_state *audio_state; enum port port = encoder->port; - if (!old_crtc_state->has_audio) + if (!old_crtc_state->audio_config.has_audio) return; drm_dbg_kms(&i915->drm, "[CONNECTOR:%d:%s][ENCODER:%d:%s] Disable audio codec on [CRTC:%d:%s]\n", @@ -930,7 +930,7 @@ void intel_audio_codec_get_config(struct intel_encoder *encoder, { struct drm_i915_private *i915 = to_i915(encoder->base.dev); - if (!crtc_state->has_audio) + if (!crtc_state->audio_config.has_audio) return; if (i915->display.funcs.audio) diff --git a/drivers/gpu/drm/i915/display/intel_cdclk.c b/drivers/gpu/drm/i915/display/intel_cdclk.c index 4207863b7b2a..48ecd2cb5a9e 100644 --- a/drivers/gpu/drm/i915/display/intel_cdclk.c +++ b/drivers/gpu/drm/i915/display/intel_cdclk.c @@ -2553,7 +2553,7 @@ int intel_crtc_compute_min_cdclk(const struct intel_crtc_state *crtc_state) * restriction for GLK is 316.8 MHz. */ if (intel_crtc_has_dp_encoder(crtc_state) && - crtc_state->has_audio && + crtc_state->audio_config.has_audio && crtc_state->port_clock >= 540000 && crtc_state->lane_count == 4) { if (DISPLAY_VER(dev_priv) == 10) { @@ -2569,7 +2569,7 @@ int intel_crtc_compute_min_cdclk(const struct intel_crtc_state *crtc_state) * According to BSpec, "The CD clock frequency must be at least twice * the frequency of the Azalia BCLK." and BCLK is 96 MHz by default. */ - if (crtc_state->has_audio && DISPLAY_VER(dev_priv) >= 9) + if (crtc_state->audio_config.has_audio && DISPLAY_VER(dev_priv) >= 9) min_cdclk = max(2 * 96000, min_cdclk); /* @@ -2580,7 +2580,7 @@ int intel_crtc_compute_min_cdclk(const struct intel_crtc_state *crtc_state) * 162 | 200 or higher" */ if ((IS_VALLEYVIEW(dev_priv) || IS_CHERRYVIEW(dev_priv)) && - intel_crtc_has_dp_encoder(crtc_state) && crtc_state->has_audio) + intel_crtc_has_dp_encoder(crtc_state) && crtc_state->audio_config.has_audio) min_cdclk = max(crtc_state->port_clock, min_cdclk); /* diff --git a/drivers/gpu/drm/i915/display/intel_crtc_state_dump.c b/drivers/gpu/drm/i915/display/intel_crtc_state_dump.c index 8d4640d0fd34..ea1b706e637e 100644 --- a/drivers/gpu/drm/i915/display/intel_crtc_state_dump.c +++ b/drivers/gpu/drm/i915/display/intel_crtc_state_dump.c @@ -265,7 +265,7 @@ void intel_crtc_state_dump(const struct intel_crtc_state *pipe_config, drm_dbg_kms(&i915->drm, "audio: %i, infoframes: %i, infoframes enabled: 0x%x\n", - pipe_config->has_audio, pipe_config->has_infoframe, + pipe_config->audio_config.has_audio, pipe_config->has_infoframe, pipe_config->infoframes.enable); if (pipe_config->infoframes.enable & @@ -291,7 +291,7 @@ void intel_crtc_state_dump(const struct intel_crtc_state *pipe_config, intel_hdmi_infoframe_enable(DP_SDP_VSC)) intel_dump_dp_vsc_sdp(i915, &pipe_config->infoframes.vsc); - if (pipe_config->has_audio) + if (pipe_config->audio_config.has_audio) intel_dump_buffer(i915, "ELD: ", pipe_config->eld, drm_eld_size(pipe_config->eld)); diff --git a/drivers/gpu/drm/i915/display/intel_ddi.c b/drivers/gpu/drm/i915/display/intel_ddi.c index 090f242e610c..396fe3d16609 100644 --- a/drivers/gpu/drm/i915/display/intel_ddi.c +++ b/drivers/gpu/drm/i915/display/intel_ddi.c @@ -3782,7 +3782,7 @@ static void intel_ddi_get_config(struct intel_encoder *encoder, intel_ddi_mso_get_config(encoder, pipe_config); - pipe_config->has_audio = + pipe_config->audio_config.has_audio = intel_ddi_is_audio_enabled(dev_priv, cpu_transcoder); if (encoder->type == INTEL_OUTPUT_EDP) diff --git a/drivers/gpu/drm/i915/display/intel_display.c b/drivers/gpu/drm/i915/display/intel_display.c index 5c7fdc82ac22..6eaa537ee961 100644 --- a/drivers/gpu/drm/i915/display/intel_display.c +++ b/drivers/gpu/drm/i915/display/intel_display.c @@ -1857,7 +1857,7 @@ static void get_crtc_power_domains(struct intel_crtc_state *crtc_state, set_bit(intel_encoder->power_domain, mask->bits); } - if (HAS_DDI(dev_priv) && crtc_state->has_audio) + if (HAS_DDI(dev_priv) && crtc_state->audio_config.has_audio) set_bit(POWER_DOMAIN_AUDIO_MMIO, mask->bits); if (crtc_state->shared_dpll) @@ -5254,7 +5254,7 @@ intel_pipe_config_compare(const struct intel_crtc_state *current_config, PIPE_CONF_CHECK_BOOL(has_infoframe); PIPE_CONF_CHECK_BOOL(fec_enable); - PIPE_CONF_CHECK_BOOL_INCOMPLETE(has_audio); + PIPE_CONF_CHECK_BOOL_INCOMPLETE(audio_config.has_audio); PIPE_CONF_CHECK_BUFFER(eld, MAX_ELD_BYTES); PIPE_CONF_CHECK_X(gmch_pfit.control); diff --git a/drivers/gpu/drm/i915/display/intel_dp.c b/drivers/gpu/drm/i915/display/intel_dp.c index f4192fda1a76..028317d40dc9 100644 --- a/drivers/gpu/drm/i915/display/intel_dp.c +++ b/drivers/gpu/drm/i915/display/intel_dp.c @@ -2255,7 +2255,7 @@ intel_dp_compute_config(struct intel_encoder *encoder, if (HAS_PCH_SPLIT(dev_priv) && !HAS_DDI(dev_priv) && encoder->port != PORT_A) pipe_config->has_pch_encoder = true; - pipe_config->has_audio = + pipe_config->audio_config.has_audio = intel_dp_has_audio(encoder, conn_state) && intel_audio_compute_config(encoder, pipe_config, conn_state); diff --git a/drivers/gpu/drm/i915/display/intel_dp_mst.c b/drivers/gpu/drm/i915/display/intel_dp_mst.c index e3f176a093d2..4ca39373c448 100644 --- a/drivers/gpu/drm/i915/display/intel_dp_mst.c +++ b/drivers/gpu/drm/i915/display/intel_dp_mst.c @@ -322,7 +322,7 @@ static int intel_dp_mst_compute_config(struct intel_encoder *encoder, pipe_config->output_format = INTEL_OUTPUT_FORMAT_RGB; pipe_config->has_pch_encoder = false; - pipe_config->has_audio = + pipe_config->audio_config.has_audio = intel_dp_mst_has_audio(conn_state) && intel_audio_compute_config(encoder, pipe_config, conn_state); diff --git a/drivers/gpu/drm/i915/display/intel_hdmi.c b/drivers/gpu/drm/i915/display/intel_hdmi.c index 7ac5e6c5e00d..aa822ee5fbda 100644 --- a/drivers/gpu/drm/i915/display/intel_hdmi.c +++ b/drivers/gpu/drm/i915/display/intel_hdmi.c @@ -2302,7 +2302,7 @@ int intel_hdmi_compute_config(struct intel_encoder *encoder, if (adjusted_mode->flags & DRM_MODE_FLAG_DBLCLK) pipe_config->pixel_multiplier = 2; - pipe_config->has_audio = + pipe_config->audio_config.has_audio = intel_hdmi_has_audio(encoder, pipe_config, conn_state) && intel_audio_compute_config(encoder, pipe_config, conn_state); diff --git a/drivers/gpu/drm/i915/display/intel_sdvo.c b/drivers/gpu/drm/i915/display/intel_sdvo.c index 21f92123c844..f6ff42841784 100644 --- a/drivers/gpu/drm/i915/display/intel_sdvo.c +++ b/drivers/gpu/drm/i915/display/intel_sdvo.c @@ -1191,7 +1191,7 @@ static void intel_sdvo_get_eld(struct intel_sdvo *intel_sdvo, ssize_t len; u8 val; - if (!crtc_state->has_audio) + if (!crtc_state->audio_config.has_audio) return; if (!intel_sdvo_get_value(intel_sdvo, SDVO_CMD_GET_AUDIO_STAT, &val, 1)) @@ -1406,7 +1406,7 @@ static int intel_sdvo_compute_config(struct intel_encoder *encoder, pipe_config->has_hdmi_sink = intel_has_hdmi_sink(intel_sdvo_connector, conn_state); - pipe_config->has_audio = + pipe_config->audio_config.has_audio = intel_sdvo_has_audio(encoder, pipe_config, conn_state) && intel_audio_compute_config(encoder, pipe_config, conn_state); @@ -1760,7 +1760,7 @@ static void intel_sdvo_get_config(struct intel_encoder *encoder, if (intel_sdvo_get_value(intel_sdvo, SDVO_CMD_GET_AUDIO_STAT, &val, 1)) { if (val & SDVO_AUDIO_PRESENCE_DETECT) - pipe_config->has_audio = true; + pipe_config->audio_config.has_audio = true; } if (intel_sdvo_get_value(intel_sdvo, SDVO_CMD_GET_ENCODE, @@ -1805,7 +1805,7 @@ static void intel_disable_sdvo(struct intel_atomic_state *state, struct intel_crtc *crtc = to_intel_crtc(old_crtc_state->uapi.crtc); u32 temp; - if (old_crtc_state->has_audio) + if (old_crtc_state->audio_config.has_audio) intel_sdvo_disable_audio(intel_sdvo); intel_sdvo_set_active_outputs(intel_sdvo, 0); @@ -1898,7 +1898,7 @@ static void intel_enable_sdvo(struct intel_atomic_state *state, DRM_MODE_DPMS_ON); intel_sdvo_set_active_outputs(intel_sdvo, intel_sdvo->attached_output); - if (pipe_config->has_audio) + if (pipe_config->audio_config.has_audio) intel_sdvo_enable_audio(intel_sdvo, pipe_config, conn_state); } From patchwork Fri Jun 9 08:45:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Golani, Mitulkumar Ajitkumar" X-Patchwork-Id: 13273492 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 B5A7AC7EE2E for ; Fri, 9 Jun 2023 08:44:25 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 595A210E65A; Fri, 9 Jun 2023 08:44:25 +0000 (UTC) Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by gabe.freedesktop.org (Postfix) with ESMTPS id 8ED1410E65A for ; Fri, 9 Jun 2023 08:44: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=1686300263; x=1717836263; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=LZuRg8Xbqa5dOwJlYHhE34q4sZ540xP4ZI5bN9nGbGI=; b=kKoVNDD/yS7h4p2j4SbOO8uKzBfQ/n8hRCyAM+9b7Wxv18eivLBGXaRI Lemz1/oJesqWRb9sU8J+FTAZ4TMQMxF7p9Bh/krPWpk5lm9xGt4Kd+01I MAsYknhewzZ05Zps6QygE4zaQwk+bDzZjLSPaOgL82gQzA1vMHdxrmOjF 3d2MOWxZIaRM6LtatdfTdsYyXBbfLU1K3kwtMwaqof1nOMqUx91aS78wI f+9hfPyXjzG7gBIiyNV7Nf0KHRliRkmVOrXz/XpvdEwC5zuMFzSzyr0Vp RotABaNgroOKU/IZQd6gt5bCAO+Uf+cGHecoA4SF2O49ng8KcQTKCRY/V A==; X-IronPort-AV: E=McAfee;i="6600,9927,10735"; a="357553436" X-IronPort-AV: E=Sophos;i="6.00,228,1681196400"; d="scan'208";a="357553436" Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Jun 2023 01:44:10 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10735"; a="884501564" X-IronPort-AV: E=Sophos;i="6.00,228,1681196400"; d="scan'208";a="884501564" Received: from mgolanimitul-x299-ud4-pro.iind.intel.com ([10.190.239.114]) by orsmga005.jf.intel.com with ESMTP; 09 Jun 2023 01:44:08 -0700 From: Mitul Golani To: intel-gfx@lists.freedesktop.org Date: Fri, 9 Jun 2023 14:15:03 +0530 Message-Id: <20230609084504.1929424-4-mitulkumar.ajitkumar.golani@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230609084504.1929424-1-mitulkumar.ajitkumar.golani@intel.com> References: <20230609084504.1929424-1-mitulkumar.ajitkumar.golani@intel.com> MIME-Version: 1.0 Subject: [Intel-gfx] [RFC 3/4] drm/i915/display: Add wrapper to Compute SAD 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: , Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" Compute SADs that takes into account the supported rate and channel based on the capabilities of the audio source. This wrapper function should encapsulate the logic for determining the supported rate and channel and should return a set of SADs that are compatible with the source. Signed-off-by: Mitul Golani --- drivers/gpu/drm/i915/display/intel_audio.c | 66 ++++++++++++++++++++++ drivers/gpu/drm/i915/display/intel_audio.h | 1 + 2 files changed, 67 insertions(+) diff --git a/drivers/gpu/drm/i915/display/intel_audio.c b/drivers/gpu/drm/i915/display/intel_audio.c index b4a0dae65cbf..e612aad9a053 100644 --- a/drivers/gpu/drm/i915/display/intel_audio.c +++ b/drivers/gpu/drm/i915/display/intel_audio.c @@ -794,6 +794,72 @@ bool intel_audio_compute_config(struct intel_encoder *encoder, return true; } +static unsigned int drm_sad_to_channels(const u8 *sad) +{ + return 1 + (sad[0] & 0x7); +} + +static inline u8 *parse_sad(u8 *eld) +{ + unsigned int ver, mnl; + + ver = (eld[DRM_ELD_VER] & DRM_ELD_VER_MASK) >> DRM_ELD_VER_SHIFT; + if (ver != 2 && ver != 31) + return NULL; + + mnl = drm_eld_mnl(eld); + if (mnl > 16) + return NULL; + + return eld + DRM_ELD_CEA_SAD(mnl, 0); +} + +static u8 get_supported_freq_mask(struct intel_crtc_state *crtc_state) +{ + int audio_freq_hz[] = {32000, 44100, 48000, 88000, 96000, 176000, 192000, 0}; + u8 mask = 0; + + for (u8 index = 0; index < ARRAY_SIZE(audio_freq_hz); index++) { + mask |= 1 << index; + if (crtc_state->audio_config.max_frequency != audio_freq_hz[index]) + continue; + else + break; + } + + return mask; +} + +void intel_audio_compute_eld(struct intel_crtc_state *crtc_state) +{ + struct drm_i915_private *i915 = to_i915(crtc_state->uapi.crtc->dev); + u8 *eld, *sad, index, mask = 0; + + eld = crtc_state->eld; + if (!eld) { + drm_err(&i915->drm, "failed to locate eld\n"); + return; + } + + sad = (u8 *)parse_sad(eld); + if (sad) { + mask = get_supported_freq_mask(crtc_state); + + for (index = 0; index < drm_eld_sad_count(eld); index++, sad += 3) { + /* + * Respect to source restrictions. If source limit is greater than sink + * capabilities then follow to sink's highest supported rate. + */ + if (drm_sad_to_channels(sad) >= crtc_state->audio_config.max_channel) { + sad[0] &= ~0x7; + sad[0] |= crtc_state->audio_config.max_channel - 1; + } + + sad[1] &= mask; + } + } +} + /** * intel_audio_codec_enable - Enable the audio codec for HD audio * @encoder: encoder on which to enable audio diff --git a/drivers/gpu/drm/i915/display/intel_audio.h b/drivers/gpu/drm/i915/display/intel_audio.h index 07d034a981e9..2ec7fafd9711 100644 --- a/drivers/gpu/drm/i915/display/intel_audio.h +++ b/drivers/gpu/drm/i915/display/intel_audio.h @@ -14,6 +14,7 @@ struct intel_crtc_state; struct intel_encoder; void intel_audio_hooks_init(struct drm_i915_private *dev_priv); +void intel_audio_compute_eld(struct intel_crtc_state *crtc_state); bool intel_audio_compute_config(struct intel_encoder *encoder, struct intel_crtc_state *crtc_state, struct drm_connector_state *conn_state); From patchwork Fri Jun 9 08:45:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Golani, Mitulkumar Ajitkumar" X-Patchwork-Id: 13273494 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 DA9ADC7EE29 for ; Fri, 9 Jun 2023 08:44:29 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 7611810E667; Fri, 9 Jun 2023 08:44:29 +0000 (UTC) Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by gabe.freedesktop.org (Postfix) with ESMTPS id 7DF0510E65A for ; Fri, 9 Jun 2023 08:44:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1686300264; x=1717836264; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=iqEH6KTC1mnAxkEIgrcpkCPVl2/qXmgXLvtLk8yby5M=; b=D1DLW5qIcJNHpdvvrKYn+EPE3P9DVuirXqyldUeVaDlDeGNk9MZzrBK7 evJh89/BXKV+qpLJZNyTFcSbWJhiIWua5Li7xQMIyQ5LQLzs94cN5esYe jQsmYxlHJveLyqJf/LmeDZtICRU758q+a+3nqKDKSH2gEdrQfSaRtl4Xm zY7nbInr2M5eM5ZWJ+ruqCLi0lf+TJj+8FSpmkaOfWqdLOzs96Nb3Hyxs uu2xPXXXsr1J3bsH5BgeYc9QXLLoVHlrrGMmjQ49adWPsjrrN7jGaJ7Q5 XWyJTPQ1SiU9WAMg4OTTs0z0U0GOAiaq7mkgiuGFV8WOujkJ1i1+0Q0Gb A==; X-IronPort-AV: E=McAfee;i="6600,9927,10735"; a="357553443" X-IronPort-AV: E=Sophos;i="6.00,228,1681196400"; d="scan'208";a="357553443" Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Jun 2023 01:44:12 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10735"; a="884501575" X-IronPort-AV: E=Sophos;i="6.00,228,1681196400"; d="scan'208";a="884501575" Received: from mgolanimitul-x299-ud4-pro.iind.intel.com ([10.190.239.114]) by orsmga005.jf.intel.com with ESMTP; 09 Jun 2023 01:44:10 -0700 From: Mitul Golani To: intel-gfx@lists.freedesktop.org Date: Fri, 9 Jun 2023 14:15:04 +0530 Message-Id: <20230609084504.1929424-5-mitulkumar.ajitkumar.golani@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230609084504.1929424-1-mitulkumar.ajitkumar.golani@intel.com> References: <20230609084504.1929424-1-mitulkumar.ajitkumar.golani@intel.com> MIME-Version: 1.0 Subject: [Intel-gfx] [RFC 4/4] drm/i915/display: Initialize and compute HDMI Audio source cap 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: , Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" Initialize the audio capabilities for HDMI by setting them to their maximum supported values and then call a function to compute these capabilities into SADs. The audio capabilities for HDMI include parameters such as supported frequency and channel configurations. By computing these capabilities into SADs, we can determine which audio formats are supported. Signed-off-by: Mitul Golani --- drivers/gpu/drm/i915/display/intel_hdmi.c | 37 +++++++++++++++++++++++ drivers/gpu/drm/i915/display/intel_hdmi.h | 1 + 2 files changed, 38 insertions(+) diff --git a/drivers/gpu/drm/i915/display/intel_hdmi.c b/drivers/gpu/drm/i915/display/intel_hdmi.c index aa822ee5fbda..c71110a1a44a 100644 --- a/drivers/gpu/drm/i915/display/intel_hdmi.c +++ b/drivers/gpu/drm/i915/display/intel_hdmi.c @@ -2277,6 +2277,40 @@ bool intel_hdmi_compute_has_hdmi_sink(struct intel_encoder *encoder, !intel_hdmi_is_cloned(crtc_state); } +static unsigned int calc_audio_bw(int channel, int frequency) +{ + int bits_per_sample = 32; + unsigned int bandwidth = channel * frequency * bits_per_sample; + return bandwidth; +} + +void +intel_hdmi_audio_compute_config(struct intel_crtc_state *pipe_config) +{ + struct drm_display_mode *adjusted_mode = &pipe_config->hw.adjusted_mode; + int num_of_channel, aud_rates[7] = {192000, 176000, 96000, 88000, 48000, 44100, 32000}; + unsigned int audio_req_bandwidth, available_blank_bandwidth, vblank, hblank; + + hblank = adjusted_mode->htotal - adjusted_mode->hdisplay; + vblank = adjusted_mode->vtotal - adjusted_mode->vdisplay; + available_blank_bandwidth = hblank * vblank * + drm_mode_vrefresh(adjusted_mode) * pipe_config->pipe_bpp; + for (num_of_channel = 8; num_of_channel > 0; num_of_channel--) { + for (int index = 0; index < 7; index++) { + audio_req_bandwidth = calc_audio_bw(num_of_channel, + aud_rates[index]); + if (audio_req_bandwidth < available_blank_bandwidth) { + pipe_config->audio_config.max_frequency = aud_rates[index]; + pipe_config->audio_config.max_channel = num_of_channel; + return; + } + } + } + + pipe_config->audio_config.max_frequency = 0; + pipe_config->audio_config.max_channel = 0; +} + int intel_hdmi_compute_config(struct intel_encoder *encoder, struct intel_crtc_state *pipe_config, struct drm_connector_state *conn_state) @@ -2344,6 +2378,7 @@ int intel_hdmi_compute_config(struct intel_encoder *encoder, pipe_config->hdmi_high_tmds_clock_ratio = true; } } + intel_hdmi_audio_compute_config(pipe_config); intel_hdmi_compute_gcp_infoframe(encoder, pipe_config, conn_state); @@ -2368,6 +2403,8 @@ int intel_hdmi_compute_config(struct intel_encoder *encoder, return -EINVAL; } + intel_audio_compute_eld(pipe_config); + return 0; } diff --git a/drivers/gpu/drm/i915/display/intel_hdmi.h b/drivers/gpu/drm/i915/display/intel_hdmi.h index 6b39df38d57a..6df303daf348 100644 --- a/drivers/gpu/drm/i915/display/intel_hdmi.h +++ b/drivers/gpu/drm/i915/display/intel_hdmi.h @@ -27,6 +27,7 @@ void intel_hdmi_init_connector(struct intel_digital_port *dig_port, bool intel_hdmi_compute_has_hdmi_sink(struct intel_encoder *encoder, const struct intel_crtc_state *crtc_state, const struct drm_connector_state *conn_state); +void intel_hdmi_audio_compute_config(struct intel_crtc_state *pipe_config); int intel_hdmi_compute_config(struct intel_encoder *encoder, struct intel_crtc_state *pipe_config, struct drm_connector_state *conn_state);