All of lore.kernel.org
 help / color / mirror / Atom feed
From: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
To: linux-sound@vger.kernel.org
Cc: alsa-devel@alsa-project.org, tiwai@suse.de, broonie@kernel.org,
	Brent Lu <brent.lu@intel.com>,
	Bard Liao <yung-chuan.liao@linux.intel.com>,
	Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Subject: [PATCH 07/21] ASoC: Intel: board_helpers: support sof_card_private initialization
Date: Mon, 25 Mar 2024 17:10:45 -0500	[thread overview]
Message-ID: <20240325221059.206042-8-pierre-louis.bossart@linux.intel.com> (raw)
In-Reply-To: <20240325221059.206042-1-pierre-louis.bossart@linux.intel.com>

From: Brent Lu <brent.lu@intel.com>

Add a helper function for machine drivers to initialize common part of
sof_card_private structure. Also unify the macros of board quirks for
the initialization.

Reviewed-by: Bard Liao <yung-chuan.liao@linux.intel.com>
Signed-off-by: Brent Lu <brent.lu@intel.com>
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
---
 sound/soc/intel/boards/sof_board_helpers.c | 43 ++++++++++++++++++++++
 sound/soc/intel/boards/sof_board_helpers.h | 40 ++++++++++++++++++++
 2 files changed, 83 insertions(+)

diff --git a/sound/soc/intel/boards/sof_board_helpers.c b/sound/soc/intel/boards/sof_board_helpers.c
index feba1a522527..a5135be94f32 100644
--- a/sound/soc/intel/boards/sof_board_helpers.c
+++ b/sound/soc/intel/boards/sof_board_helpers.c
@@ -587,6 +587,49 @@ int sof_intel_board_set_dai_link(struct device *dev, struct snd_soc_card *card,
 }
 EXPORT_SYMBOL_NS(sof_intel_board_set_dai_link, SND_SOC_INTEL_SOF_BOARD_HELPERS);
 
+struct sof_card_private *
+sof_intel_board_get_ctx(struct device *dev, unsigned long board_quirk)
+{
+	struct sof_card_private *ctx;
+
+	dev_dbg(dev, "create ctx, board_quirk 0x%lx\n", board_quirk);
+
+	ctx = devm_kzalloc(dev, sizeof(struct sof_card_private), GFP_KERNEL);
+	if (!ctx)
+		return NULL;
+
+	ctx->codec_type = sof_ssp_detect_codec_type(dev);
+	ctx->amp_type = sof_ssp_detect_amp_type(dev);
+
+	ctx->dmic_be_num = 2;
+	ctx->hdmi_num = (board_quirk & SOF_NUM_IDISP_HDMI_MASK) >>
+			SOF_NUM_IDISP_HDMI_SHIFT;
+	/* default number of HDMI DAI's */
+	if (!ctx->hdmi_num)
+		ctx->hdmi_num = 3;
+
+	/* port number/mask of peripherals attached to ssp interface */
+	if (ctx->codec_type != CODEC_NONE)
+		ctx->ssp_codec = (board_quirk & SOF_SSP_PORT_CODEC_MASK) >>
+				SOF_SSP_PORT_CODEC_SHIFT;
+
+	if (ctx->amp_type != CODEC_NONE)
+		ctx->ssp_amp = (board_quirk & SOF_SSP_PORT_AMP_MASK) >>
+				SOF_SSP_PORT_AMP_SHIFT;
+
+	if (board_quirk & SOF_BT_OFFLOAD_PRESENT) {
+		ctx->bt_offload_present = true;
+		ctx->ssp_bt = (board_quirk & SOF_SSP_PORT_BT_OFFLOAD_MASK) >>
+				SOF_SSP_PORT_BT_OFFLOAD_SHIFT;
+	}
+
+	ctx->ssp_mask_hdmi_in = (board_quirk & SOF_SSP_MASK_HDMI_CAPTURE_MASK) >>
+				SOF_SSP_MASK_HDMI_CAPTURE_SHIFT;
+
+	return ctx;
+}
+EXPORT_SYMBOL_NS(sof_intel_board_get_ctx, SND_SOC_INTEL_SOF_BOARD_HELPERS);
+
 struct snd_soc_dai *get_codec_dai_by_name(struct snd_soc_pcm_runtime *rtd,
 					  const char * const dai_name[], int num_dais)
 {
diff --git a/sound/soc/intel/boards/sof_board_helpers.h b/sound/soc/intel/boards/sof_board_helpers.h
index 38e459e6af9b..0d0a8d97843b 100644
--- a/sound/soc/intel/boards/sof_board_helpers.h
+++ b/sound/soc/intel/boards/sof_board_helpers.h
@@ -10,6 +10,44 @@
 #include "sof_hdmi_common.h"
 #include "sof_ssp_common.h"
 
+/*
+ * Common board quirks: from bit 8 to 31, LSB 8 bits reserved for machine
+ *                      drivers
+ */
+
+/* SSP port number for headphone codec: 3 bits */
+#define SOF_SSP_PORT_CODEC_SHIFT		8
+#define SOF_SSP_PORT_CODEC_MASK			(GENMASK(10, 8))
+#define SOF_SSP_PORT_CODEC(quirk)		\
+	(((quirk) << SOF_SSP_PORT_CODEC_SHIFT) & SOF_SSP_PORT_CODEC_MASK)
+
+/* SSP port number for speaker amplifier: 3 bits */
+#define SOF_SSP_PORT_AMP_SHIFT			11
+#define SOF_SSP_PORT_AMP_MASK			(GENMASK(13, 11))
+#define SOF_SSP_PORT_AMP(quirk)			\
+	(((quirk) << SOF_SSP_PORT_AMP_SHIFT) & SOF_SSP_PORT_AMP_MASK)
+
+/* SSP port number for BT audio offload: 3 bits */
+#define SOF_SSP_PORT_BT_OFFLOAD_SHIFT		14
+#define SOF_SSP_PORT_BT_OFFLOAD_MASK		(GENMASK(16, 14))
+#define SOF_SSP_PORT_BT_OFFLOAD(quirk)		\
+	(((quirk) << SOF_SSP_PORT_BT_OFFLOAD_SHIFT) & SOF_SSP_PORT_BT_OFFLOAD_MASK)
+
+/* SSP port mask for HDMI capture: 6 bits */
+#define SOF_SSP_MASK_HDMI_CAPTURE_SHIFT		17
+#define SOF_SSP_MASK_HDMI_CAPTURE_MASK		(GENMASK(22, 17))
+#define SOF_SSP_MASK_HDMI_CAPTURE(quirk)	\
+	(((quirk) << SOF_SSP_MASK_HDMI_CAPTURE_SHIFT) & SOF_SSP_MASK_HDMI_CAPTURE_MASK)
+
+/* Number of idisp HDMI BE link: 3 bits */
+#define SOF_NUM_IDISP_HDMI_SHIFT		23
+#define SOF_NUM_IDISP_HDMI_MASK			(GENMASK(25, 23))
+#define SOF_NUM_IDISP_HDMI(quirk)		\
+	(((quirk) << SOF_NUM_IDISP_HDMI_SHIFT) & SOF_NUM_IDISP_HDMI_MASK)
+
+/* Board uses BT audio offload */
+#define SOF_BT_OFFLOAD_PRESENT			BIT(26)
+
 enum {
 	SOF_LINK_NONE = 0,
 	SOF_LINK_CODEC,
@@ -111,6 +149,8 @@ struct sof_card_private {
 int sof_intel_board_card_late_probe(struct snd_soc_card *card);
 int sof_intel_board_set_dai_link(struct device *dev, struct snd_soc_card *card,
 				 struct sof_card_private *ctx);
+struct sof_card_private *
+sof_intel_board_get_ctx(struct device *dev, unsigned long board_quirk);
 
 struct snd_soc_dai *get_codec_dai_by_name(struct snd_soc_pcm_runtime *rtd,
 					  const char * const dai_name[], int num_dais);
-- 
2.40.1


  parent reply	other threads:[~2024-03-25 22:11 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-25 22:10 [PATCH 00/21] ASoC: Intel: boards: updates for 6.10 - part1 Pierre-Louis Bossart
2024-03-25 22:10 ` [PATCH 01/21] ASoC: Intel: board_helpers: support DAI link ID customization Pierre-Louis Bossart
2024-03-25 22:10 ` [PATCH 02/21] ASoC: Intel: sof_ssp_amp: use common module for DAI link generation Pierre-Louis Bossart
2024-03-25 22:10 ` [PATCH 03/21] ASoC: Intel: board_helpers: change dai link helpers to static function Pierre-Louis Bossart
2024-03-25 22:10 ` [PATCH 04/21] ASoC: Intel: sof_da7219: add rpl_mx98360_da7219 board config Pierre-Louis Bossart
2024-03-25 22:10 ` [PATCH 05/21] ASoC: Intel: sof_rt5682: support ALC5650 on RPL boards Pierre-Louis Bossart
2024-03-25 22:10 ` [PATCH 06/21] ASoC: Intel: sof_cs42l42: rename BT offload quirk Pierre-Louis Bossart
2024-03-25 22:10 ` Pierre-Louis Bossart [this message]
2024-03-25 22:10 ` [PATCH 08/21] ASoC: Intel: sof_cs42l42: use common module for sof_card_private initialization Pierre-Louis Bossart
2024-03-25 22:10 ` [PATCH 09/21] ASoC: Intel: sof_nau8825: " Pierre-Louis Bossart
2024-03-25 22:10 ` [PATCH 10/21] ASoC: Intel: sof_rt5682: " Pierre-Louis Bossart
2024-03-25 22:10 ` [PATCH 11/21] ASoC: Intel: sof_ssp_amp: " Pierre-Louis Bossart
2024-03-25 22:10 ` [PATCH 12/21] ASoC: Intel: sof_da7219: use common module for DAI link generation Pierre-Louis Bossart
2024-03-25 22:10 ` [PATCH 13/21] ASoC: Intel: sof_da7219: add codec exit function Pierre-Louis Bossart
2024-03-25 22:10 ` [PATCH 14/21] ASoC: Intel: sof_da7219: add SOF_DA7219_MCLK_EN quirk Pierre-Louis Bossart
2024-03-25 22:10 ` [PATCH 15/21] ASoC: Intel: sof_da7219: board id cleanup for jsl boards Pierre-Louis Bossart
2024-03-25 22:10 ` [PATCH 16/21] ASoC: Intel: sof_da7219: board id cleanup for adl boards Pierre-Louis Bossart
2024-03-25 22:10 ` [PATCH 17/21] ASoC: Intel: sof_da7219: board id cleanup for rpl boards Pierre-Louis Bossart
2024-03-25 22:10 ` [PATCH 18/21] ASoC: Intel: sof_rt5682: remove unnecessary idisp HDMI quirk Pierre-Louis Bossart
2024-03-25 22:10 ` [PATCH 19/21] ASoC: Intel: sof_ssp_amp: " Pierre-Louis Bossart
2024-03-25 22:10 ` [PATCH 20/21] ASoC: Intel: sof_nau8825: remove sof_nau8825 board id Pierre-Louis Bossart
2024-03-25 22:10 ` [PATCH 21/21] ASoC: Intel: sof_rt5682: board id cleanup for cml boards Pierre-Louis Bossart
2024-03-26 15:28 ` [PATCH 00/21] ASoC: Intel: boards: updates for 6.10 - part1 Mark Brown

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240325221059.206042-8-pierre-louis.bossart@linux.intel.com \
    --to=pierre-louis.bossart@linux.intel.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=brent.lu@intel.com \
    --cc=broonie@kernel.org \
    --cc=linux-sound@vger.kernel.org \
    --cc=tiwai@suse.de \
    --cc=yung-chuan.liao@linux.intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.