From nobody Sun Nov 24 05:28:17 2024 Received: from mail-lf1-f42.google.com (mail-lf1-f42.google.com [209.85.167.42]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8A8D61917C2 for ; Fri, 8 Nov 2024 00:22:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.42 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731025331; cv=none; b=mAQana2Q5AvoPaG7jleYwzIXLELAdPUF75YvpgVJlzHiaMEwVwhzRyWTKuGeaEnDx94k36klPfwZzD7uQl8w2oea44ulBln1WH0bnHFUFvPEYgdU8CuQWzdB9Hnf0NEh+7PD6/DPLLMSD8xp2JOvxWgxBJDLn5iwxBw5DO7Q9p4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731025331; c=relaxed/simple; bh=CJNeGuR1/hi3WdAk96FubFXJd9V4K8sajDyAH3cIEjU=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Kg9NkNVL6PCPCOCFFj44AeAdHsJS1mZD27xY7n85hYAD27jeCqN03Q0kM5Tc2WIxJTUjxXgs0thiZQ1G6YxwmAI9VoLO7kYyBxWdMsYEBtTFQcKEy8m+/8GWeLuKq3Q8O5t1PR9GClFXDVjFFokNWLsRH3QM+t0SlEkPIpmc7dg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=CE9XZVos; arc=none smtp.client-ip=209.85.167.42 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="CE9XZVos" Received: by mail-lf1-f42.google.com with SMTP id 2adb3069b0e04-539e8607c2aso1586049e87.3 for ; Thu, 07 Nov 2024 16:22:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1731025328; x=1731630128; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=Z5kQ4AmnSGpR1tsagb+JUR8SjjRR8sZ+27U7rHc8thc=; b=CE9XZVosmWwACZpR29jw761vnc6rxt5x4Th1LShiAsB3qe9+6y5OrHIcDzuRZJeVXP SxbbhFt1tjAXRlk/wMTCyoxYCdcjMQ62vN8sOhI2TJ4/txxxwOJIuCfy9DCuc+MS96Bg bSUQRuhyMCZBt/5UGvJGiRKEBJRQLvirjY7Q4tAYJtErZz725kYCVVLTDlEGy9oGjWKc lWp/9E4aOakGFmaoDw6ASbJ5mnkkGe3hoWuLtma00hZReRqev9edGGEcoQvxeT0mCyY3 tz7rTyTgn/NUfgv7XtPVWVD3lIN4OTqSp2LRVYq81ZhEgZX5P+n7uzzFZCrdWzmojwCJ h+1g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731025328; x=1731630128; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Z5kQ4AmnSGpR1tsagb+JUR8SjjRR8sZ+27U7rHc8thc=; b=WFAggTxv7fjD9OCAHaYvU+x0+/G74RrNthDWzADwmHhE77uLWdXxbZarxinlvOketa qATYnQE7ftZNsS0103c9Tf0PXHiQbi8Ue21wWMjaX502x2EKTHlI3P6bxoI0KOZ/Wf+Q xHCwk8hxzspCpTkmQIUSk0VvWAOSzzZrWuIZYe66g6NJoH2fHJ7bAE54jMQll6eS7CCv VL6NG3Yh89n5xWlH/P0qg4N20TTz716wIHhFmh4BQ3ZYb5ZkHTt8V2RQroF3QQNOs1sn Bh4gn9OHeBUBkuAaUiUxePuYMLM86ZDzujjvxEUMZ8dZ5lyGAxVqolQO4XBcxDWB15Nc ef7Q== X-Forwarded-Encrypted: i=1; AJvYcCVd2wPx9oFYLBI2oLANj/6+vfPru+G3ng8PDOlLQBiArNemHSrSxp9CTskjOsJZQezX6AT+Gfj91CWuKyc=@vger.kernel.org X-Gm-Message-State: AOJu0Yz3EpGoyRB6BxTxDye8BEDXjznLnmi4XVnH01AOvaBB9f2Fw/x2 CXtZJNmXWHO8ZRwUj9xhM+doTm1wU8HcGgLuR7u9X6rYUkjBOi6XQxSAsuJPMlo= X-Google-Smtp-Source: AGHT+IFtPSNKeO7vF9wCM86fTjU3dsWl3RKTsfudcRZdzKmu76nAD+5RkIhDSRgF9xUxHt70BZ39RA== X-Received: by 2002:a05:651c:150c:b0:2fb:5d8a:4cd3 with SMTP id 38308e7fff4ca-2ff2006084fmr4840981fa.0.1731025327552; Thu, 07 Nov 2024 16:22:07 -0800 (PST) Received: from umbar.lan ([192.130.178.90]) by smtp.gmail.com with ESMTPSA id 38308e7fff4ca-2ff17900a63sm4195191fa.47.2024.11.07.16.22.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Nov 2024 16:22:06 -0800 (PST) From: Dmitry Baryshkov Date: Fri, 08 Nov 2024 02:21:42 +0200 Subject: [PATCH 11/14] drm/msm/dp: move/inline audio related functions Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20241108-fd-dp-audio-fixup-v1-11-40c8eeb60cf5@linaro.org> References: <20241108-fd-dp-audio-fixup-v1-0-40c8eeb60cf5@linaro.org> In-Reply-To: <20241108-fd-dp-audio-fixup-v1-0-40c8eeb60cf5@linaro.org> To: Rob Clark , Abhinav Kumar , Sean Paul , Marijn Suijten , David Airlie , Simona Vetter , Paloma Arellano Cc: Douglas Anderson , Stephen Boyd , linux-arm-msm@vger.kernel.org, dri-devel@lists.freedesktop.org, freedreno@lists.freedesktop.org, linux-kernel@vger.kernel.org, Dmitry Baryshkov X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=8606; i=dmitry.baryshkov@linaro.org; h=from:subject:message-id; bh=CJNeGuR1/hi3WdAk96FubFXJd9V4K8sajDyAH3cIEjU=; b=owEBbQGS/pANAwAKAYs8ij4CKSjVAcsmYgBnLVmQeBbtYi7rdedJFb/81mfZJGHDrLlk9stC7 4/2bOapZWKJATMEAAEKAB0WIQRMcISVXLJjVvC4lX+LPIo+Aiko1QUCZy1ZkAAKCRCLPIo+Aiko 1QYkB/9rDbCubMBn3heGWbrNxPet0AQvpG5JDcMUCKY+A2fLmhT50dnyI5FG7aaiKlly/VMv2ng tTYFVEtg4t/ESTsAcIuc6LOrxxyU4MffokBo7j8shuZd+uwTzNdU1KKAlb3UJDDMDHgFDi4BPln L3t86jimpIlb7CAxHDQOOzoI4cFdxd1ecJwyCtV11y/6xEzSpRV/cQm9KBPDs+8HmsTe8KXxLwz fera0F7J53nL3vEA5D0KbtMWA2sTH98BK64VSXHiXhyf/ScF8VeYzDypgipj1UnUogvgVf6PXu0 SDw51FWsiiTgeKL1ljjUC0aXWdu29osm5Esgd1ZooR1GWr70 X-Developer-Key: i=dmitry.baryshkov@linaro.org; a=openpgp; fpr=8F88381DD5C873E4AE487DA5199BF1243632046A Move audio-related functions to dp_audio.c, following up the cleanup done by the rest of the submodules. Inline functions with simple register access patterns. Signed-off-by: Dmitry Baryshkov --- drivers/gpu/drm/msm/dp/dp_audio.c | 72 +++++++++++++++++++++---- drivers/gpu/drm/msm/dp/dp_catalog.c | 105 --------------------------------= ---- drivers/gpu/drm/msm/dp/dp_catalog.h | 6 --- 3 files changed, 63 insertions(+), 120 deletions(-) diff --git a/drivers/gpu/drm/msm/dp/dp_audio.c b/drivers/gpu/drm/msm/dp/dp_= audio.c index 63bdd57948401451426364796e608643c1ebfebe..63c4cd88edef07c54b2eb54d5b6= ee494ee94723d 100644 --- a/drivers/gpu/drm/msm/dp/dp_audio.c +++ b/drivers/gpu/drm/msm/dp/dp_audio.c @@ -119,9 +119,41 @@ static void msm_dp_audio_isrc_sdp(struct msm_dp_audio_= private *audio) msm_dp_write_link(catalog, MMSS_DP_AUDIO_ISRC_1, header[1]); } =20 +static void msm_dp_audio_config_sdp(struct msm_dp_audio_private *audio) +{ + struct msm_dp_catalog *msm_dp_catalog =3D audio->catalog; + u32 sdp_cfg, sdp_cfg2; + + sdp_cfg =3D msm_dp_read_link(msm_dp_catalog, MMSS_DP_SDP_CFG); + /* AUDIO_TIMESTAMP_SDP_EN */ + sdp_cfg |=3D BIT(1); + /* AUDIO_STREAM_SDP_EN */ + sdp_cfg |=3D BIT(2); + /* AUDIO_COPY_MANAGEMENT_SDP_EN */ + sdp_cfg |=3D BIT(5); + /* AUDIO_ISRC_SDP_EN */ + sdp_cfg |=3D BIT(6); + /* AUDIO_INFOFRAME_SDP_EN */ + sdp_cfg |=3D BIT(20); + + drm_dbg_dp(audio->drm_dev, "sdp_cfg =3D 0x%x\n", sdp_cfg); + + msm_dp_write_link(msm_dp_catalog, MMSS_DP_SDP_CFG, sdp_cfg); + + sdp_cfg2 =3D msm_dp_read_link(msm_dp_catalog, MMSS_DP_SDP_CFG2); + /* IFRM_REGSRC -> Do not use reg values */ + sdp_cfg2 &=3D ~BIT(0); + /* AUDIO_STREAM_HB3_REGSRC-> Do not use reg values */ + sdp_cfg2 &=3D ~BIT(1); + + drm_dbg_dp(audio->drm_dev, "sdp_cfg2 =3D 0x%x\n", sdp_cfg2); + + msm_dp_write_link(msm_dp_catalog, MMSS_DP_SDP_CFG2, sdp_cfg2); +} + static void msm_dp_audio_setup_sdp(struct msm_dp_audio_private *audio) { - msm_dp_catalog_audio_config_sdp(audio->catalog); + msm_dp_audio_config_sdp(audio); =20 msm_dp_audio_stream_sdp(audio); msm_dp_audio_timestamp_sdp(audio); @@ -132,8 +164,7 @@ static void msm_dp_audio_setup_sdp(struct msm_dp_audio_= private *audio) =20 static void msm_dp_audio_setup_acr(struct msm_dp_audio_private *audio) { - u32 select =3D 0; - struct msm_dp_catalog *catalog =3D audio->catalog; + u32 select, acr_ctrl; =20 switch (audio->msm_dp_audio.bw_code) { case DP_LINK_BW_1_62: @@ -154,13 +185,17 @@ static void msm_dp_audio_setup_acr(struct msm_dp_audi= o_private *audio) break; } =20 - msm_dp_catalog_audio_config_acr(catalog, select); + acr_ctrl =3D select << 4 | BIT(31) | BIT(8) | BIT(14); + + drm_dbg_dp(audio->drm_dev, "select: %#x, acr_ctrl: %#x\n", + select, acr_ctrl); + + msm_dp_write_link(audio->catalog, MMSS_DP_AUDIO_ACR_CTRL, acr_ctrl); } =20 static void msm_dp_audio_safe_to_exit_level(struct msm_dp_audio_private *a= udio) { - struct msm_dp_catalog *catalog =3D audio->catalog; - u32 safe_to_exit_level =3D 0; + u32 safe_to_exit_level, mainlink_levels; =20 switch (audio->msm_dp_audio.lane_count) { case 1: @@ -180,14 +215,33 @@ static void msm_dp_audio_safe_to_exit_level(struct ms= m_dp_audio_private *audio) break; } =20 - msm_dp_catalog_audio_sfe_level(catalog, safe_to_exit_level); + mainlink_levels =3D msm_dp_read_link(audio->catalog, REG_DP_MAINLINK_LEVE= LS); + mainlink_levels &=3D 0xFE0; + mainlink_levels |=3D safe_to_exit_level; + + drm_dbg_dp(audio->drm_dev, + "mainlink_level =3D 0x%x, safe_to_exit_level =3D 0x%x\n", + mainlink_levels, safe_to_exit_level); + + msm_dp_write_link(audio->catalog, REG_DP_MAINLINK_LEVELS, mainlink_levels= ); } =20 static void msm_dp_audio_enable(struct msm_dp_audio_private *audio, bool e= nable) { - struct msm_dp_catalog *catalog =3D audio->catalog; + u32 audio_ctrl; + + audio_ctrl =3D msm_dp_read_link(audio->catalog, MMSS_DP_AUDIO_CFG); + + if (enable) + audio_ctrl |=3D BIT(0); + else + audio_ctrl &=3D ~BIT(0); + + drm_dbg_dp(audio->drm_dev, "dp_audio_cfg =3D 0x%x\n", audio_ctrl); =20 - msm_dp_catalog_audio_enable(catalog, enable); + msm_dp_write_link(audio->catalog, MMSS_DP_AUDIO_CFG, audio_ctrl); + /* make sure audio engine is disabled */ + wmb(); } =20 static struct msm_dp_audio_private *msm_dp_audio_get_data(struct platform_= device *pdev) diff --git a/drivers/gpu/drm/msm/dp/dp_catalog.c b/drivers/gpu/drm/msm/dp/d= p_catalog.c index 5071c86fd219cb1c933b32104a396982c5cc8ace..60ba6e0a204f536fd050591e891= add17d286fb2d 100644 --- a/drivers/gpu/drm/msm/dp/dp_catalog.c +++ b/drivers/gpu/drm/msm/dp/dp_catalog.c @@ -298,108 +298,3 @@ struct msm_dp_catalog *msm_dp_catalog_get(struct devi= ce *dev) =20 return &catalog->msm_dp_catalog; } - -void msm_dp_catalog_audio_config_acr(struct msm_dp_catalog *msm_dp_catalog= , u32 select) -{ - struct msm_dp_catalog_private *catalog; - u32 acr_ctrl; - - if (!msm_dp_catalog) - return; - - catalog =3D container_of(msm_dp_catalog, - struct msm_dp_catalog_private, msm_dp_catalog); - - acr_ctrl =3D select << 4 | BIT(31) | BIT(8) | BIT(14); - - drm_dbg_dp(catalog->drm_dev, "select: %#x, acr_ctrl: %#x\n", - select, acr_ctrl); - - msm_dp_write_link(msm_dp_catalog, MMSS_DP_AUDIO_ACR_CTRL, acr_ctrl); -} - -void msm_dp_catalog_audio_enable(struct msm_dp_catalog *msm_dp_catalog, bo= ol enable) -{ - struct msm_dp_catalog_private *catalog; - u32 audio_ctrl; - - if (!msm_dp_catalog) - return; - - catalog =3D container_of(msm_dp_catalog, - struct msm_dp_catalog_private, msm_dp_catalog); - - audio_ctrl =3D msm_dp_read_link(msm_dp_catalog, MMSS_DP_AUDIO_CFG); - - if (enable) - audio_ctrl |=3D BIT(0); - else - audio_ctrl &=3D ~BIT(0); - - drm_dbg_dp(catalog->drm_dev, "dp_audio_cfg =3D 0x%x\n", audio_ctrl); - - msm_dp_write_link(msm_dp_catalog, MMSS_DP_AUDIO_CFG, audio_ctrl); - /* make sure audio engine is disabled */ - wmb(); -} - -void msm_dp_catalog_audio_config_sdp(struct msm_dp_catalog *msm_dp_catalog) -{ - struct msm_dp_catalog_private *catalog; - u32 sdp_cfg =3D 0; - u32 sdp_cfg2 =3D 0; - - if (!msm_dp_catalog) - return; - - catalog =3D container_of(msm_dp_catalog, - struct msm_dp_catalog_private, msm_dp_catalog); - - sdp_cfg =3D msm_dp_read_link(msm_dp_catalog, MMSS_DP_SDP_CFG); - /* AUDIO_TIMESTAMP_SDP_EN */ - sdp_cfg |=3D BIT(1); - /* AUDIO_STREAM_SDP_EN */ - sdp_cfg |=3D BIT(2); - /* AUDIO_COPY_MANAGEMENT_SDP_EN */ - sdp_cfg |=3D BIT(5); - /* AUDIO_ISRC_SDP_EN */ - sdp_cfg |=3D BIT(6); - /* AUDIO_INFOFRAME_SDP_EN */ - sdp_cfg |=3D BIT(20); - - drm_dbg_dp(catalog->drm_dev, "sdp_cfg =3D 0x%x\n", sdp_cfg); - - msm_dp_write_link(msm_dp_catalog, MMSS_DP_SDP_CFG, sdp_cfg); - - sdp_cfg2 =3D msm_dp_read_link(msm_dp_catalog, MMSS_DP_SDP_CFG2); - /* IFRM_REGSRC -> Do not use reg values */ - sdp_cfg2 &=3D ~BIT(0); - /* AUDIO_STREAM_HB3_REGSRC-> Do not use reg values */ - sdp_cfg2 &=3D ~BIT(1); - - drm_dbg_dp(catalog->drm_dev, "sdp_cfg2 =3D 0x%x\n", sdp_cfg2); - - msm_dp_write_link(msm_dp_catalog, MMSS_DP_SDP_CFG2, sdp_cfg2); -} - -void msm_dp_catalog_audio_sfe_level(struct msm_dp_catalog *msm_dp_catalog,= u32 safe_to_exit_level) -{ - struct msm_dp_catalog_private *catalog; - u32 mainlink_levels; - - if (!msm_dp_catalog) - return; - - catalog =3D container_of(msm_dp_catalog, - struct msm_dp_catalog_private, msm_dp_catalog); - - mainlink_levels =3D msm_dp_read_link(msm_dp_catalog, REG_DP_MAINLINK_LEVE= LS); - mainlink_levels &=3D 0xFE0; - mainlink_levels |=3D safe_to_exit_level; - - drm_dbg_dp(catalog->drm_dev, - "mainlink_level =3D 0x%x, safe_to_exit_level =3D 0x%x\n", - mainlink_levels, safe_to_exit_level); - - msm_dp_write_link(msm_dp_catalog, REG_DP_MAINLINK_LEVELS, mainlink_levels= ); -} diff --git a/drivers/gpu/drm/msm/dp/dp_catalog.h b/drivers/gpu/drm/msm/dp/d= p_catalog.h index 24f1cf4ed5150c4e0e80880588641a01bb6a1596..e2fdccc332f874458709593c68a= 1d1a46b6cc406 100644 --- a/drivers/gpu/drm/msm/dp/dp_catalog.h +++ b/drivers/gpu/drm/msm/dp/dp_catalog.h @@ -134,10 +134,4 @@ u32 msm_dp_catalog_ctrl_read_psr_interrupt_status(stru= ct msm_dp_catalog *msm_dp_ =20 struct msm_dp_catalog *msm_dp_catalog_get(struct device *dev); =20 -/* DP Audio APIs */ -void msm_dp_catalog_audio_config_acr(struct msm_dp_catalog *catalog, u32 s= elect); -void msm_dp_catalog_audio_enable(struct msm_dp_catalog *catalog, bool enab= le); -void msm_dp_catalog_audio_config_sdp(struct msm_dp_catalog *catalog); -void msm_dp_catalog_audio_sfe_level(struct msm_dp_catalog *catalog, u32 sa= fe_to_exit_level); - #endif /* _DP_CATALOG_H_ */ --=20 2.39.5