Commit 22247e40 authored by Mark Brown's avatar Mark Brown

ASoC: Intel: boards: updates for 6.10 - part1

Merge series from Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>:

This series from Brent Lu adds common helpers and board configurations
to reduce the number of quirks.
parents 6c26dac5 61cafaea
...@@ -624,6 +624,7 @@ config SND_SOC_INTEL_SOF_DA7219_MACH ...@@ -624,6 +624,7 @@ config SND_SOC_INTEL_SOF_DA7219_MACH
select SND_SOC_MAX98357A select SND_SOC_MAX98357A
select SND_SOC_MAX98373_I2C select SND_SOC_MAX98373_I2C
select SND_SOC_DMIC select SND_SOC_DMIC
select SND_SOC_INTEL_SOF_BOARD_HELPERS
select SND_SOC_INTEL_SOF_MAXIM_COMMON select SND_SOC_INTEL_SOF_MAXIM_COMMON
select SND_SOC_INTEL_SOF_SSP_COMMON select SND_SOC_INTEL_SOF_SSP_COMMON
help help
......
...@@ -74,6 +74,11 @@ static int dmic_init(struct snd_soc_pcm_runtime *rtd) ...@@ -74,6 +74,11 @@ static int dmic_init(struct snd_soc_pcm_runtime *rtd)
* DAI Link Helpers * DAI Link Helpers
*/ */
enum sof_dmic_be_type {
SOF_DMIC_01,
SOF_DMIC_16K,
};
/* DEFAULT_LINK_ORDER: the order used in sof_rt5682 */ /* DEFAULT_LINK_ORDER: the order used in sof_rt5682 */
#define DEFAULT_LINK_ORDER SOF_LINK_ORDER(SOF_LINK_CODEC, \ #define DEFAULT_LINK_ORDER SOF_LINK_ORDER(SOF_LINK_CODEC, \
SOF_LINK_DMIC01, \ SOF_LINK_DMIC01, \
...@@ -97,13 +102,13 @@ static struct snd_soc_dai_link_component platform_component[] = { ...@@ -97,13 +102,13 @@ static struct snd_soc_dai_link_component platform_component[] = {
} }
}; };
int sof_intel_board_set_codec_link(struct device *dev, static int set_ssp_codec_link(struct device *dev, struct snd_soc_dai_link *link,
struct snd_soc_dai_link *link, int be_id, int be_id, enum sof_ssp_codec codec_type,
enum sof_ssp_codec codec_type, int ssp_codec) int ssp_codec)
{ {
struct snd_soc_dai_link_component *cpus; struct snd_soc_dai_link_component *cpus;
dev_dbg(dev, "link %d: codec %s, ssp %d\n", be_id, dev_dbg(dev, "link %d: ssp codec %s, ssp %d\n", be_id,
sof_ssp_get_codec_name(codec_type), ssp_codec); sof_ssp_get_codec_name(codec_type), ssp_codec);
/* link name */ /* link name */
...@@ -144,11 +149,9 @@ int sof_intel_board_set_codec_link(struct device *dev, ...@@ -144,11 +149,9 @@ int sof_intel_board_set_codec_link(struct device *dev,
return 0; return 0;
} }
EXPORT_SYMBOL_NS(sof_intel_board_set_codec_link, SND_SOC_INTEL_SOF_BOARD_HELPERS);
int sof_intel_board_set_dmic_link(struct device *dev, static int set_dmic_link(struct device *dev, struct snd_soc_dai_link *link,
struct snd_soc_dai_link *link, int be_id, int be_id, enum sof_dmic_be_type be_type)
enum sof_dmic_be_type be_type)
{ {
struct snd_soc_dai_link_component *cpus; struct snd_soc_dai_link_component *cpus;
...@@ -196,16 +199,14 @@ int sof_intel_board_set_dmic_link(struct device *dev, ...@@ -196,16 +199,14 @@ int sof_intel_board_set_dmic_link(struct device *dev,
return 0; return 0;
} }
EXPORT_SYMBOL_NS(sof_intel_board_set_dmic_link, SND_SOC_INTEL_SOF_BOARD_HELPERS);
int sof_intel_board_set_intel_hdmi_link(struct device *dev, static int set_idisp_hdmi_link(struct device *dev, struct snd_soc_dai_link *link,
struct snd_soc_dai_link *link, int be_id, int be_id, int hdmi_id, bool idisp_codec)
int hdmi_id, bool idisp_codec)
{ {
struct snd_soc_dai_link_component *cpus, *codecs; struct snd_soc_dai_link_component *cpus, *codecs;
dev_dbg(dev, "link %d: intel hdmi, hdmi id %d, idisp codec %d\n", dev_dbg(dev, "link %d: idisp hdmi %d, idisp codec %d\n", be_id, hdmi_id,
be_id, hdmi_id, idisp_codec); idisp_codec);
/* link name */ /* link name */
link->name = devm_kasprintf(dev, GFP_KERNEL, "iDisp%d", hdmi_id); link->name = devm_kasprintf(dev, GFP_KERNEL, "iDisp%d", hdmi_id);
...@@ -256,11 +257,9 @@ int sof_intel_board_set_intel_hdmi_link(struct device *dev, ...@@ -256,11 +257,9 @@ int sof_intel_board_set_intel_hdmi_link(struct device *dev,
return 0; return 0;
} }
EXPORT_SYMBOL_NS(sof_intel_board_set_intel_hdmi_link, SND_SOC_INTEL_SOF_BOARD_HELPERS);
int sof_intel_board_set_ssp_amp_link(struct device *dev, static int set_ssp_amp_link(struct device *dev, struct snd_soc_dai_link *link,
struct snd_soc_dai_link *link, int be_id, int be_id, enum sof_ssp_codec amp_type, int ssp_amp)
enum sof_ssp_codec amp_type, int ssp_amp)
{ {
struct snd_soc_dai_link_component *cpus; struct snd_soc_dai_link_component *cpus;
...@@ -298,11 +297,9 @@ int sof_intel_board_set_ssp_amp_link(struct device *dev, ...@@ -298,11 +297,9 @@ int sof_intel_board_set_ssp_amp_link(struct device *dev,
return 0; return 0;
} }
EXPORT_SYMBOL_NS(sof_intel_board_set_ssp_amp_link, SND_SOC_INTEL_SOF_BOARD_HELPERS);
int sof_intel_board_set_bt_link(struct device *dev, static int set_bt_offload_link(struct device *dev, struct snd_soc_dai_link *link,
struct snd_soc_dai_link *link, int be_id, int be_id, int ssp_bt)
int ssp_bt)
{ {
struct snd_soc_dai_link_component *cpus; struct snd_soc_dai_link_component *cpus;
...@@ -341,11 +338,9 @@ int sof_intel_board_set_bt_link(struct device *dev, ...@@ -341,11 +338,9 @@ int sof_intel_board_set_bt_link(struct device *dev,
return 0; return 0;
} }
EXPORT_SYMBOL_NS(sof_intel_board_set_bt_link, SND_SOC_INTEL_SOF_BOARD_HELPERS);
int sof_intel_board_set_hdmi_in_link(struct device *dev, static int set_hdmi_in_link(struct device *dev, struct snd_soc_dai_link *link,
struct snd_soc_dai_link *link, int be_id, int be_id, int ssp_hdmi)
int ssp_hdmi)
{ {
struct snd_soc_dai_link_component *cpus; struct snd_soc_dai_link_component *cpus;
...@@ -383,7 +378,6 @@ int sof_intel_board_set_hdmi_in_link(struct device *dev, ...@@ -383,7 +378,6 @@ int sof_intel_board_set_hdmi_in_link(struct device *dev,
return 0; return 0;
} }
EXPORT_SYMBOL_NS(sof_intel_board_set_hdmi_in_link, SND_SOC_INTEL_SOF_BOARD_HELPERS);
static int calculate_num_links(struct sof_card_private *ctx) static int calculate_num_links(struct sof_card_private *ctx)
{ {
...@@ -427,6 +421,7 @@ int sof_intel_board_set_dai_link(struct device *dev, struct snd_soc_card *card, ...@@ -427,6 +421,7 @@ int sof_intel_board_set_dai_link(struct device *dev, struct snd_soc_card *card,
int ret; int ret;
int ssp_hdmi_in = 0; int ssp_hdmi_in = 0;
unsigned long link_order, link; unsigned long link_order, link;
unsigned long link_ids, be_id;
num_links = calculate_num_links(ctx); num_links = calculate_num_links(ctx);
...@@ -440,22 +435,34 @@ int sof_intel_board_set_dai_link(struct device *dev, struct snd_soc_card *card, ...@@ -440,22 +435,34 @@ int sof_intel_board_set_dai_link(struct device *dev, struct snd_soc_card *card,
else else
link_order = DEFAULT_LINK_ORDER; link_order = DEFAULT_LINK_ORDER;
dev_dbg(dev, "create dai links, link_order 0x%lx\n", link_order); if (ctx->link_id_overwrite)
link_ids = ctx->link_id_overwrite;
else
link_ids = 0;
dev_dbg(dev, "create dai links, link_order 0x%lx, id_overwrite 0x%lx\n",
link_order, link_ids);
while (link_order) { while (link_order) {
link = link_order & SOF_LINK_ORDER_MASK; link = link_order & SOF_LINK_ORDER_MASK;
link_order >>= SOF_LINK_ORDER_SHIFT; link_order >>= SOF_LINK_ORDER_SHIFT;
if (ctx->link_id_overwrite) {
be_id = link_ids & SOF_LINK_IDS_MASK;
link_ids >>= SOF_LINK_IDS_SHIFT;
} else {
/* use array index as link id */
be_id = idx;
}
switch (link) { switch (link) {
case SOF_LINK_CODEC: case SOF_LINK_CODEC:
/* headphone codec */ /* headphone codec */
if (ctx->codec_type == CODEC_NONE) if (ctx->codec_type == CODEC_NONE)
continue; continue;
ret = sof_intel_board_set_codec_link(dev, &links[idx], ret = set_ssp_codec_link(dev, &links[idx], be_id,
idx, ctx->codec_type, ctx->ssp_codec);
ctx->codec_type,
ctx->ssp_codec);
if (ret) { if (ret) {
dev_err(dev, "fail to set codec link, ret %d\n", dev_err(dev, "fail to set codec link, ret %d\n",
ret); ret);
...@@ -471,8 +478,7 @@ int sof_intel_board_set_dai_link(struct device *dev, struct snd_soc_card *card, ...@@ -471,8 +478,7 @@ int sof_intel_board_set_dai_link(struct device *dev, struct snd_soc_card *card,
continue; continue;
/* at least we have dmic01 */ /* at least we have dmic01 */
ret = sof_intel_board_set_dmic_link(dev, &links[idx], ret = set_dmic_link(dev, &links[idx], be_id, SOF_DMIC_01);
idx, SOF_DMIC_01);
if (ret) { if (ret) {
dev_err(dev, "fail to set dmic01 link, ret %d\n", dev_err(dev, "fail to set dmic01 link, ret %d\n",
ret); ret);
...@@ -487,8 +493,8 @@ int sof_intel_board_set_dai_link(struct device *dev, struct snd_soc_card *card, ...@@ -487,8 +493,8 @@ int sof_intel_board_set_dai_link(struct device *dev, struct snd_soc_card *card,
continue; continue;
/* set up 2 BE links at most */ /* set up 2 BE links at most */
ret = sof_intel_board_set_dmic_link(dev, &links[idx], ret = set_dmic_link(dev, &links[idx], be_id,
idx, SOF_DMIC_16K); SOF_DMIC_16K);
if (ret) { if (ret) {
dev_err(dev, "fail to set dmic16k link, ret %d\n", dev_err(dev, "fail to set dmic16k link, ret %d\n",
ret); ret);
...@@ -500,9 +506,8 @@ int sof_intel_board_set_dai_link(struct device *dev, struct snd_soc_card *card, ...@@ -500,9 +506,8 @@ int sof_intel_board_set_dai_link(struct device *dev, struct snd_soc_card *card,
case SOF_LINK_IDISP_HDMI: case SOF_LINK_IDISP_HDMI:
/* idisp HDMI */ /* idisp HDMI */
for (i = 1; i <= ctx->hdmi_num; i++) { for (i = 1; i <= ctx->hdmi_num; i++) {
ret = sof_intel_board_set_intel_hdmi_link(dev, ret = set_idisp_hdmi_link(dev, &links[idx],
&links[idx], be_id, i,
idx, i,
ctx->hdmi.idisp_codec); ctx->hdmi.idisp_codec);
if (ret) { if (ret) {
dev_err(dev, "fail to set hdmi link, ret %d\n", dev_err(dev, "fail to set hdmi link, ret %d\n",
...@@ -511,6 +516,7 @@ int sof_intel_board_set_dai_link(struct device *dev, struct snd_soc_card *card, ...@@ -511,6 +516,7 @@ int sof_intel_board_set_dai_link(struct device *dev, struct snd_soc_card *card,
} }
idx++; idx++;
be_id++;
} }
break; break;
case SOF_LINK_AMP: case SOF_LINK_AMP:
...@@ -518,10 +524,8 @@ int sof_intel_board_set_dai_link(struct device *dev, struct snd_soc_card *card, ...@@ -518,10 +524,8 @@ int sof_intel_board_set_dai_link(struct device *dev, struct snd_soc_card *card,
if (ctx->amp_type == CODEC_NONE) if (ctx->amp_type == CODEC_NONE)
continue; continue;
ret = sof_intel_board_set_ssp_amp_link(dev, &links[idx], ret = set_ssp_amp_link(dev, &links[idx], be_id,
idx, ctx->amp_type, ctx->ssp_amp);
ctx->amp_type,
ctx->ssp_amp);
if (ret) { if (ret) {
dev_err(dev, "fail to set amp link, ret %d\n", dev_err(dev, "fail to set amp link, ret %d\n",
ret); ret);
...@@ -536,7 +540,7 @@ int sof_intel_board_set_dai_link(struct device *dev, struct snd_soc_card *card, ...@@ -536,7 +540,7 @@ int sof_intel_board_set_dai_link(struct device *dev, struct snd_soc_card *card,
if (!ctx->bt_offload_present) if (!ctx->bt_offload_present)
continue; continue;
ret = sof_intel_board_set_bt_link(dev, &links[idx], idx, ret = set_bt_offload_link(dev, &links[idx], be_id,
ctx->ssp_bt); ctx->ssp_bt);
if (ret) { if (ret) {
dev_err(dev, "fail to set bt link, ret %d\n", dev_err(dev, "fail to set bt link, ret %d\n",
...@@ -549,9 +553,7 @@ int sof_intel_board_set_dai_link(struct device *dev, struct snd_soc_card *card, ...@@ -549,9 +553,7 @@ int sof_intel_board_set_dai_link(struct device *dev, struct snd_soc_card *card,
case SOF_LINK_HDMI_IN: case SOF_LINK_HDMI_IN:
/* HDMI-In */ /* HDMI-In */
for_each_set_bit(ssp_hdmi_in, &ctx->ssp_mask_hdmi_in, 32) { for_each_set_bit(ssp_hdmi_in, &ctx->ssp_mask_hdmi_in, 32) {
ret = sof_intel_board_set_hdmi_in_link(dev, ret = set_hdmi_in_link(dev, &links[idx], be_id,
&links[idx],
idx,
ssp_hdmi_in); ssp_hdmi_in);
if (ret) { if (ret) {
dev_err(dev, "fail to set hdmi-in link, ret %d\n", dev_err(dev, "fail to set hdmi-in link, ret %d\n",
...@@ -560,6 +562,7 @@ int sof_intel_board_set_dai_link(struct device *dev, struct snd_soc_card *card, ...@@ -560,6 +562,7 @@ int sof_intel_board_set_dai_link(struct device *dev, struct snd_soc_card *card,
} }
idx++; idx++;
be_id++;
} }
break; break;
case SOF_LINK_NONE: case SOF_LINK_NONE:
...@@ -584,6 +587,49 @@ int sof_intel_board_set_dai_link(struct device *dev, struct snd_soc_card *card, ...@@ -584,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); 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, struct snd_soc_dai *get_codec_dai_by_name(struct snd_soc_pcm_runtime *rtd,
const char * const dai_name[], int num_dais) const char * const dai_name[], int num_dais)
{ {
......
...@@ -10,6 +10,44 @@ ...@@ -10,6 +10,44 @@
#include "sof_hdmi_common.h" #include "sof_hdmi_common.h"
#include "sof_ssp_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 { enum {
SOF_LINK_NONE = 0, SOF_LINK_NONE = 0,
SOF_LINK_CODEC, SOF_LINK_CODEC,
...@@ -33,6 +71,31 @@ enum { ...@@ -33,6 +71,31 @@ enum {
(((k6) & SOF_LINK_ORDER_MASK) << (SOF_LINK_ORDER_SHIFT * 5)) | \ (((k6) & SOF_LINK_ORDER_MASK) << (SOF_LINK_ORDER_SHIFT * 5)) | \
(((k7) & SOF_LINK_ORDER_MASK) << (SOF_LINK_ORDER_SHIFT * 6))) (((k7) & SOF_LINK_ORDER_MASK) << (SOF_LINK_ORDER_SHIFT * 6)))
#define SOF_LINK_IDS_MASK (0xF)
#define SOF_LINK_IDS_SHIFT (4)
#define SOF_LINK_IDS(k1, k2, k3, k4, k5, k6, k7) \
((((k1) & SOF_LINK_IDS_MASK) << (SOF_LINK_IDS_SHIFT * 0)) | \
(((k2) & SOF_LINK_IDS_MASK) << (SOF_LINK_IDS_SHIFT * 1)) | \
(((k3) & SOF_LINK_IDS_MASK) << (SOF_LINK_IDS_SHIFT * 2)) | \
(((k4) & SOF_LINK_IDS_MASK) << (SOF_LINK_IDS_SHIFT * 3)) | \
(((k5) & SOF_LINK_IDS_MASK) << (SOF_LINK_IDS_SHIFT * 4)) | \
(((k6) & SOF_LINK_IDS_MASK) << (SOF_LINK_IDS_SHIFT * 5)) | \
(((k7) & SOF_LINK_IDS_MASK) << (SOF_LINK_IDS_SHIFT * 6)))
/*
* sof_da7219_private: private data for da7219 machine driver
*
* @is_jsl_board: true for JSL boards
* @mclk_en: true for mclk pin is connected
* @pll_bypass: true for PLL bypass mode
*/
struct sof_da7219_private {
bool is_jsl_board;
bool mclk_en;
bool pll_bypass;
};
/* /*
* sof_rt5682_private: private data for rt5682 machine driver * sof_rt5682_private: private data for rt5682 machine driver
* *
...@@ -61,6 +124,8 @@ struct sof_rt5682_private { ...@@ -61,6 +124,8 @@ struct sof_rt5682_private {
* @codec_link: pointer to headset codec dai link * @codec_link: pointer to headset codec dai link
* @amp_link: pointer to speaker amplifier dai link * @amp_link: pointer to speaker amplifier dai link
* @link_order_overwrite: custom DAI link order * @link_order_overwrite: custom DAI link order
* @link_id_overwrite: custom DAI link ID
* @da7219: private data for da7219 machine driver
* @rt5682: private data for rt5682 machine driver * @rt5682: private data for rt5682 machine driver
*/ */
struct sof_card_private { struct sof_card_private {
...@@ -84,39 +149,23 @@ struct sof_card_private { ...@@ -84,39 +149,23 @@ struct sof_card_private {
struct snd_soc_dai_link *amp_link; struct snd_soc_dai_link *amp_link;
unsigned long link_order_overwrite; unsigned long link_order_overwrite;
/*
* A variable stores id for all BE DAI links, use SOF_LINK_IDS macro to
* build the value; use DAI link array index as id if zero.
*/
unsigned long link_id_overwrite;
union { union {
struct sof_da7219_private da7219;
struct sof_rt5682_private rt5682; struct sof_rt5682_private rt5682;
}; };
}; };
enum sof_dmic_be_type {
SOF_DMIC_01,
SOF_DMIC_16K,
};
int sof_intel_board_card_late_probe(struct snd_soc_card *card); 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, int sof_intel_board_set_dai_link(struct device *dev, struct snd_soc_card *card,
struct sof_card_private *ctx); struct sof_card_private *ctx);
struct sof_card_private *
int sof_intel_board_set_codec_link(struct device *dev, sof_intel_board_get_ctx(struct device *dev, unsigned long board_quirk);
struct snd_soc_dai_link *link, int be_id,
enum sof_ssp_codec codec_type, int ssp_codec);
int sof_intel_board_set_dmic_link(struct device *dev,
struct snd_soc_dai_link *link, int be_id,
enum sof_dmic_be_type be_type);
int sof_intel_board_set_intel_hdmi_link(struct device *dev,
struct snd_soc_dai_link *link, int be_id,
int hdmi_id, bool idisp_codec);
int sof_intel_board_set_ssp_amp_link(struct device *dev,
struct snd_soc_dai_link *link, int be_id,
enum sof_ssp_codec amp_type, int ssp_amp);
int sof_intel_board_set_bt_link(struct device *dev,
struct snd_soc_dai_link *link, int be_id,
int ssp_bt);
int sof_intel_board_set_hdmi_in_link(struct device *dev,
struct snd_soc_dai_link *link, int be_id,
int ssp_hdmi);
struct snd_soc_dai *get_codec_dai_by_name(struct snd_soc_pcm_runtime *rtd, struct snd_soc_dai *get_codec_dai_by_name(struct snd_soc_pcm_runtime *rtd,
const char * const dai_name[], int num_dais); const char * const dai_name[], int num_dais);
......
...@@ -22,23 +22,6 @@ ...@@ -22,23 +22,6 @@
#include "../common/soc-intel-quirks.h" #include "../common/soc-intel-quirks.h"
#include "sof_board_helpers.h" #include "sof_board_helpers.h"
#include "sof_maxim_common.h" #include "sof_maxim_common.h"
#include "sof_ssp_common.h"
#define SOF_CS42L42_SSP_CODEC(quirk) ((quirk) & GENMASK(2, 0))
#define SOF_CS42L42_SSP_CODEC_MASK (GENMASK(2, 0))
#define SOF_CS42L42_SSP_AMP_SHIFT 4
#define SOF_CS42L42_SSP_AMP_MASK (GENMASK(6, 4))
#define SOF_CS42L42_SSP_AMP(quirk) \
(((quirk) << SOF_CS42L42_SSP_AMP_SHIFT) & SOF_CS42L42_SSP_AMP_MASK)
#define SOF_CS42L42_NUM_HDMIDEV_SHIFT 7
#define SOF_CS42L42_NUM_HDMIDEV_MASK (GENMASK(9, 7))
#define SOF_CS42L42_NUM_HDMIDEV(quirk) \
(((quirk) << SOF_CS42L42_NUM_HDMIDEV_SHIFT) & SOF_CS42L42_NUM_HDMIDEV_MASK)
#define SOF_BT_OFFLOAD_PRESENT BIT(25)
#define SOF_CS42L42_SSP_BT_SHIFT 26
#define SOF_CS42L42_SSP_BT_MASK (GENMASK(28, 26))
#define SOF_CS42L42_SSP_BT(quirk) \
(((quirk) << SOF_CS42L42_SSP_BT_SHIFT) & SOF_CS42L42_SSP_BT_MASK)
static struct snd_soc_jack_pin jack_pins[] = { static struct snd_soc_jack_pin jack_pins[] = {
{ {
...@@ -52,7 +35,7 @@ static struct snd_soc_jack_pin jack_pins[] = { ...@@ -52,7 +35,7 @@ static struct snd_soc_jack_pin jack_pins[] = {
}; };
/* Default: SSP2 */ /* Default: SSP2 */
static unsigned long sof_cs42l42_quirk = SOF_CS42L42_SSP_CODEC(2); static unsigned long sof_cs42l42_quirk = SOF_SSP_PORT_CODEC(2);
static int sof_cs42l42_init(struct snd_soc_pcm_runtime *rtd) static int sof_cs42l42_init(struct snd_soc_pcm_runtime *rtd)
{ {
...@@ -229,48 +212,26 @@ static int sof_audio_probe(struct platform_device *pdev) ...@@ -229,48 +212,26 @@ static int sof_audio_probe(struct platform_device *pdev)
struct sof_card_private *ctx; struct sof_card_private *ctx;
int ret; int ret;
ctx = devm_kzalloc(&pdev->dev, sizeof(*ctx), GFP_KERNEL);
if (!ctx)
return -ENOMEM;
if (pdev->id_entry && pdev->id_entry->driver_data) if (pdev->id_entry && pdev->id_entry->driver_data)
sof_cs42l42_quirk = (unsigned long)pdev->id_entry->driver_data; sof_cs42l42_quirk = (unsigned long)pdev->id_entry->driver_data;
ctx->codec_type = sof_ssp_detect_codec_type(&pdev->dev); dev_dbg(&pdev->dev, "sof_cs42l42_quirk = %lx\n", sof_cs42l42_quirk);
ctx->amp_type = sof_ssp_detect_amp_type(&pdev->dev);
/* initialize ctx with board quirk */
ctx = sof_intel_board_get_ctx(&pdev->dev, sof_cs42l42_quirk);
if (!ctx)
return -ENOMEM;
if (soc_intel_is_glk()) { if (soc_intel_is_glk()) {
ctx->dmic_be_num = 1; ctx->dmic_be_num = 1;
ctx->hdmi_num = 3;
/* overwrite the DAI link order for GLK boards */ /* overwrite the DAI link order for GLK boards */
ctx->link_order_overwrite = GLK_LINK_ORDER; ctx->link_order_overwrite = GLK_LINK_ORDER;
} else {
ctx->dmic_be_num = 2;
ctx->hdmi_num = (sof_cs42l42_quirk & SOF_CS42L42_NUM_HDMIDEV_MASK) >>
SOF_CS42L42_NUM_HDMIDEV_SHIFT;
/* default number of HDMI DAI's */
if (!ctx->hdmi_num)
ctx->hdmi_num = 3;
} }
if (mach->mach_params.codec_mask & IDISP_CODEC_MASK) if (mach->mach_params.codec_mask & IDISP_CODEC_MASK)
ctx->hdmi.idisp_codec = true; ctx->hdmi.idisp_codec = true;
dev_dbg(&pdev->dev, "sof_cs42l42_quirk = %lx\n", sof_cs42l42_quirk);
/* port number of peripherals attached to ssp interface */
ctx->ssp_bt = (sof_cs42l42_quirk & SOF_CS42L42_SSP_BT_MASK) >>
SOF_CS42L42_SSP_BT_SHIFT;
ctx->ssp_amp = (sof_cs42l42_quirk & SOF_CS42L42_SSP_AMP_MASK) >>
SOF_CS42L42_SSP_AMP_SHIFT;
ctx->ssp_codec = sof_cs42l42_quirk & SOF_CS42L42_SSP_CODEC_MASK;
if (sof_cs42l42_quirk & SOF_BT_OFFLOAD_PRESENT)
ctx->bt_offload_present = true;
/* update dai_link */ /* update dai_link */
ret = sof_card_dai_links_create(&pdev->dev, &sof_audio_card_cs42l42, ctx); ret = sof_card_dai_links_create(&pdev->dev, &sof_audio_card_cs42l42, ctx);
if (ret) if (ret)
...@@ -293,21 +254,21 @@ static int sof_audio_probe(struct platform_device *pdev) ...@@ -293,21 +254,21 @@ static int sof_audio_probe(struct platform_device *pdev)
static const struct platform_device_id board_ids[] = { static const struct platform_device_id board_ids[] = {
{ {
.name = "glk_cs4242_mx98357a", .name = "glk_cs4242_mx98357a",
.driver_data = (kernel_ulong_t)(SOF_CS42L42_SSP_CODEC(2) | .driver_data = (kernel_ulong_t)(SOF_SSP_PORT_CODEC(2) |
SOF_CS42L42_SSP_AMP(1)), SOF_SSP_PORT_AMP(1)),
}, },
{ {
.name = "jsl_cs4242_mx98360a", .name = "jsl_cs4242_mx98360a",
.driver_data = (kernel_ulong_t)(SOF_CS42L42_SSP_CODEC(0) | .driver_data = (kernel_ulong_t)(SOF_SSP_PORT_CODEC(0) |
SOF_CS42L42_SSP_AMP(1)), SOF_SSP_PORT_AMP(1)),
}, },
{ {
.name = "adl_mx98360a_cs4242", .name = "adl_mx98360a_cs4242",
.driver_data = (kernel_ulong_t)(SOF_CS42L42_SSP_CODEC(0) | .driver_data = (kernel_ulong_t)(SOF_SSP_PORT_CODEC(0) |
SOF_CS42L42_SSP_AMP(1) | SOF_SSP_PORT_AMP(1) |
SOF_CS42L42_NUM_HDMIDEV(4) | SOF_NUM_IDISP_HDMI(4) |
SOF_BT_OFFLOAD_PRESENT | SOF_BT_OFFLOAD_PRESENT |
SOF_CS42L42_SSP_BT(2)), SOF_SSP_PORT_BT_OFFLOAD(2)),
}, },
{ } { }
}; };
...@@ -329,4 +290,3 @@ MODULE_AUTHOR("Brent Lu <brent.lu@intel.com>"); ...@@ -329,4 +290,3 @@ MODULE_AUTHOR("Brent Lu <brent.lu@intel.com>");
MODULE_LICENSE("GPL"); MODULE_LICENSE("GPL");
MODULE_IMPORT_NS(SND_SOC_INTEL_SOF_BOARD_HELPERS); MODULE_IMPORT_NS(SND_SOC_INTEL_SOF_BOARD_HELPERS);
MODULE_IMPORT_NS(SND_SOC_INTEL_SOF_MAXIM_COMMON); MODULE_IMPORT_NS(SND_SOC_INTEL_SOF_MAXIM_COMMON);
MODULE_IMPORT_NS(SND_SOC_INTEL_SOF_SSP_COMMON);
This diff is collapsed.
...@@ -24,27 +24,8 @@ ...@@ -24,27 +24,8 @@
#include "sof_realtek_common.h" #include "sof_realtek_common.h"
#include "sof_maxim_common.h" #include "sof_maxim_common.h"
#include "sof_nuvoton_common.h" #include "sof_nuvoton_common.h"
#include "sof_ssp_common.h"
static unsigned long sof_nau8825_quirk = SOF_SSP_PORT_CODEC(0);
#define SOF_NAU8825_SSP_CODEC(quirk) ((quirk) & GENMASK(2, 0))
#define SOF_NAU8825_SSP_CODEC_MASK (GENMASK(2, 0))
#define SOF_NAU8825_SSP_AMP_SHIFT 4
#define SOF_NAU8825_SSP_AMP_MASK (GENMASK(6, 4))
#define SOF_NAU8825_SSP_AMP(quirk) \
(((quirk) << SOF_NAU8825_SSP_AMP_SHIFT) & SOF_NAU8825_SSP_AMP_MASK)
#define SOF_NAU8825_NUM_HDMIDEV_SHIFT 7
#define SOF_NAU8825_NUM_HDMIDEV_MASK (GENMASK(9, 7))
#define SOF_NAU8825_NUM_HDMIDEV(quirk) \
(((quirk) << SOF_NAU8825_NUM_HDMIDEV_SHIFT) & SOF_NAU8825_NUM_HDMIDEV_MASK)
/* BT audio offload: reserve 3 bits for future */
#define SOF_BT_OFFLOAD_SSP_SHIFT 10
#define SOF_BT_OFFLOAD_SSP_MASK (GENMASK(12, 10))
#define SOF_BT_OFFLOAD_SSP(quirk) \
(((quirk) << SOF_BT_OFFLOAD_SSP_SHIFT) & SOF_BT_OFFLOAD_SSP_MASK)
#define SOF_SSP_BT_OFFLOAD_PRESENT BIT(13)
static unsigned long sof_nau8825_quirk = SOF_NAU8825_SSP_CODEC(0);
static struct snd_soc_jack_pin jack_pins[] = { static struct snd_soc_jack_pin jack_pins[] = {
{ {
...@@ -264,41 +245,19 @@ static int sof_audio_probe(struct platform_device *pdev) ...@@ -264,41 +245,19 @@ static int sof_audio_probe(struct platform_device *pdev)
struct sof_card_private *ctx; struct sof_card_private *ctx;
int ret; int ret;
ctx = devm_kzalloc(&pdev->dev, sizeof(*ctx), GFP_KERNEL);
if (!ctx)
return -ENOMEM;
if (pdev->id_entry && pdev->id_entry->driver_data) if (pdev->id_entry && pdev->id_entry->driver_data)
sof_nau8825_quirk = (unsigned long)pdev->id_entry->driver_data; sof_nau8825_quirk = (unsigned long)pdev->id_entry->driver_data;
ctx->codec_type = sof_ssp_detect_codec_type(&pdev->dev);
ctx->amp_type = sof_ssp_detect_amp_type(&pdev->dev);
dev_dbg(&pdev->dev, "sof_nau8825_quirk = %lx\n", sof_nau8825_quirk); dev_dbg(&pdev->dev, "sof_nau8825_quirk = %lx\n", sof_nau8825_quirk);
/* default number of DMIC DAI's */ /* initialize ctx with board quirk */
ctx->dmic_be_num = 2; ctx = sof_intel_board_get_ctx(&pdev->dev, sof_nau8825_quirk);
ctx->hdmi_num = (sof_nau8825_quirk & SOF_NAU8825_NUM_HDMIDEV_MASK) >> if (!ctx)
SOF_NAU8825_NUM_HDMIDEV_SHIFT; return -ENOMEM;
/* default number of HDMI DAI's */
if (!ctx->hdmi_num)
ctx->hdmi_num = 3;
if (mach->mach_params.codec_mask & IDISP_CODEC_MASK) if (mach->mach_params.codec_mask & IDISP_CODEC_MASK)
ctx->hdmi.idisp_codec = true; ctx->hdmi.idisp_codec = true;
/* port number of peripherals attached to ssp interface */
ctx->ssp_bt = (sof_nau8825_quirk & SOF_BT_OFFLOAD_SSP_MASK) >>
SOF_BT_OFFLOAD_SSP_SHIFT;
ctx->ssp_amp = (sof_nau8825_quirk & SOF_NAU8825_SSP_AMP_MASK) >>
SOF_NAU8825_SSP_AMP_SHIFT;
ctx->ssp_codec = sof_nau8825_quirk & SOF_NAU8825_SSP_CODEC_MASK;
if (sof_nau8825_quirk & SOF_SSP_BT_OFFLOAD_PRESENT)
ctx->bt_offload_present = true;
/* update dai_link */ /* update dai_link */
ret = sof_card_dai_links_create(&pdev->dev, &sof_audio_card_nau8825, ctx); ret = sof_card_dai_links_create(&pdev->dev, &sof_audio_card_nau8825, ctx);
if (ret) if (ret)
...@@ -312,10 +271,10 @@ static int sof_audio_probe(struct platform_device *pdev) ...@@ -312,10 +271,10 @@ static int sof_audio_probe(struct platform_device *pdev)
case CODEC_RT1015P: case CODEC_RT1015P:
sof_rt1015p_codec_conf(&sof_audio_card_nau8825); sof_rt1015p_codec_conf(&sof_audio_card_nau8825);
break; break;
case CODEC_NONE:
case CODEC_MAX98360A: case CODEC_MAX98360A:
case CODEC_NAU8318: case CODEC_NAU8318:
case CODEC_RT1019P: case CODEC_RT1019P:
case CODEC_NONE:
/* no codec conf required */ /* no codec conf required */
break; break;
default: default:
...@@ -338,35 +297,27 @@ static int sof_audio_probe(struct platform_device *pdev) ...@@ -338,35 +297,27 @@ static int sof_audio_probe(struct platform_device *pdev)
} }
static const struct platform_device_id board_ids[] = { static const struct platform_device_id board_ids[] = {
{
.name = "sof_nau8825",
.driver_data = (kernel_ulong_t)(SOF_NAU8825_SSP_CODEC(0) |
SOF_NAU8825_NUM_HDMIDEV(4) |
SOF_BT_OFFLOAD_SSP(2) |
SOF_SSP_BT_OFFLOAD_PRESENT),
},
{ {
.name = "adl_rt1019p_8825", .name = "adl_rt1019p_8825",
.driver_data = (kernel_ulong_t)(SOF_NAU8825_SSP_CODEC(0) | .driver_data = (kernel_ulong_t)(SOF_SSP_PORT_CODEC(0) |
SOF_NAU8825_SSP_AMP(2) | SOF_SSP_PORT_AMP(2) |
SOF_NAU8825_NUM_HDMIDEV(4)), SOF_NUM_IDISP_HDMI(4)),
}, },
{ {
.name = "adl_nau8825_def", .name = "adl_nau8825_def",
.driver_data = (kernel_ulong_t)(SOF_NAU8825_SSP_CODEC(0) | .driver_data = (kernel_ulong_t)(SOF_SSP_PORT_CODEC(0) |
SOF_NAU8825_SSP_AMP(1) | SOF_SSP_PORT_AMP(1) |
SOF_NAU8825_NUM_HDMIDEV(4) | SOF_NUM_IDISP_HDMI(4) |
SOF_BT_OFFLOAD_SSP(2) | SOF_SSP_PORT_BT_OFFLOAD(2) |
SOF_SSP_BT_OFFLOAD_PRESENT), SOF_BT_OFFLOAD_PRESENT),
}, },
{ {
.name = "rpl_nau8825_def", .name = "rpl_nau8825_def",
.driver_data = (kernel_ulong_t)(SOF_NAU8825_SSP_CODEC(0) | .driver_data = (kernel_ulong_t)(SOF_SSP_PORT_CODEC(0) |
SOF_NAU8825_SSP_AMP(1) | SOF_SSP_PORT_AMP(1) |
SOF_NAU8825_NUM_HDMIDEV(4) | SOF_NUM_IDISP_HDMI(4) |
SOF_BT_OFFLOAD_SSP(2) | SOF_SSP_PORT_BT_OFFLOAD(2) |
SOF_SSP_BT_OFFLOAD_PRESENT), SOF_BT_OFFLOAD_PRESENT),
}, },
{ } { }
}; };
...@@ -392,4 +343,3 @@ MODULE_IMPORT_NS(SND_SOC_INTEL_SOF_BOARD_HELPERS); ...@@ -392,4 +343,3 @@ MODULE_IMPORT_NS(SND_SOC_INTEL_SOF_BOARD_HELPERS);
MODULE_IMPORT_NS(SND_SOC_INTEL_SOF_MAXIM_COMMON); MODULE_IMPORT_NS(SND_SOC_INTEL_SOF_MAXIM_COMMON);
MODULE_IMPORT_NS(SND_SOC_INTEL_SOF_NUVOTON_COMMON); MODULE_IMPORT_NS(SND_SOC_INTEL_SOF_NUVOTON_COMMON);
MODULE_IMPORT_NS(SND_SOC_INTEL_SOF_REALTEK_COMMON); MODULE_IMPORT_NS(SND_SOC_INTEL_SOF_REALTEK_COMMON);
MODULE_IMPORT_NS(SND_SOC_INTEL_SOF_SSP_COMMON);
This diff is collapsed.
...@@ -20,34 +20,12 @@ ...@@ -20,34 +20,12 @@
#include "sof_board_helpers.h" #include "sof_board_helpers.h"
#include "sof_realtek_common.h" #include "sof_realtek_common.h"
#include "sof_cirrus_common.h" #include "sof_cirrus_common.h"
#include "sof_ssp_common.h"
/* Driver-specific board quirks: from bit 0 to 7 */
/* SSP port ID for speaker amplifier */ #define SOF_HDMI_PLAYBACK_PRESENT BIT(0)
#define SOF_AMPLIFIER_SSP(quirk) ((quirk) & GENMASK(3, 0))
#define SOF_AMPLIFIER_SSP_MASK (GENMASK(3, 0))
/* HDMI capture*/
#define SOF_HDMI_CAPTURE_SSP_MASK_SHIFT 4
#define SOF_HDMI_CAPTURE_SSP_MASK_MASK (GENMASK(9, 4))
#define SOF_HDMI_CAPTURE_SSP_MASK(quirk) \
(((quirk) << SOF_HDMI_CAPTURE_SSP_MASK_SHIFT) & SOF_HDMI_CAPTURE_SSP_MASK_MASK)
/* HDMI playback */
#define SOF_HDMI_PLAYBACK_PRESENT BIT(13)
#define SOF_NO_OF_HDMI_PLAYBACK_SHIFT 14
#define SOF_NO_OF_HDMI_PLAYBACK_MASK (GENMASK(16, 14))
#define SOF_NO_OF_HDMI_PLAYBACK(quirk) \
(((quirk) << SOF_NO_OF_HDMI_PLAYBACK_SHIFT) & SOF_NO_OF_HDMI_PLAYBACK_MASK)
/* BT audio offload */
#define SOF_SSP_BT_OFFLOAD_PRESENT BIT(17)
#define SOF_BT_OFFLOAD_SSP_SHIFT 18
#define SOF_BT_OFFLOAD_SSP_MASK (GENMASK(20, 18))
#define SOF_BT_OFFLOAD_SSP(quirk) \
(((quirk) << SOF_BT_OFFLOAD_SSP_SHIFT) & SOF_BT_OFFLOAD_SSP_MASK)
/* Default: SSP2 */ /* Default: SSP2 */
static unsigned long sof_ssp_amp_quirk = SOF_AMPLIFIER_SSP(2); static unsigned long sof_ssp_amp_quirk = SOF_SSP_PORT_AMP(2);
static const struct dmi_system_id chromebook_platforms[] = { static const struct dmi_system_id chromebook_platforms[] = {
{ {
...@@ -75,197 +53,107 @@ static struct snd_soc_card sof_ssp_amp_card = { ...@@ -75,197 +53,107 @@ static struct snd_soc_card sof_ssp_amp_card = {
#define HDMI_IN_BE_ID 0 #define HDMI_IN_BE_ID 0
#define SPK_BE_ID 2 #define SPK_BE_ID 2
#define DMIC01_BE_ID 3 #define DMIC01_BE_ID 3
#define DMIC16K_BE_ID 4
#define INTEL_HDMI_BE_ID 5 #define INTEL_HDMI_BE_ID 5
/* extra BE links to support no-hdmi-in boards */
static struct snd_soc_dai_link * #define DMIC16K_BE_ID 4
sof_card_dai_links_create(struct device *dev, enum sof_ssp_codec amp_type, #define BT_OFFLOAD_BE_ID 8
int ssp_amp, int dmic_be_num, int hdmi_num,
bool idisp_codec) #define SSP_AMP_LINK_ORDER SOF_LINK_ORDER(SOF_LINK_HDMI_IN, \
SOF_LINK_AMP, \
SOF_LINK_DMIC01, \
SOF_LINK_DMIC16K, \
SOF_LINK_IDISP_HDMI, \
SOF_LINK_BT_OFFLOAD, \
SOF_LINK_NONE)
#define SSP_AMP_LINK_IDS SOF_LINK_ORDER(HDMI_IN_BE_ID, \
SPK_BE_ID, \
DMIC01_BE_ID, \
DMIC16K_BE_ID, \
INTEL_HDMI_BE_ID, \
BT_OFFLOAD_BE_ID, \
0)
static int
sof_card_dai_links_create(struct device *dev, struct snd_soc_card *card,
struct sof_card_private *ctx)
{ {
struct snd_soc_dai_link *links;
int i;
int id = 0;
int ret; int ret;
bool fixed_be = false;
int be_id;
unsigned long ssp_mask_hdmi_in;
links = devm_kcalloc(dev, sof_ssp_amp_card.num_links, ret = sof_intel_board_set_dai_link(dev, card, ctx);
sizeof(struct snd_soc_dai_link), GFP_KERNEL);
if (!links)
return NULL;
/* HDMI-In SSP */
ssp_mask_hdmi_in = (sof_ssp_amp_quirk & SOF_HDMI_CAPTURE_SSP_MASK_MASK) >>
SOF_HDMI_CAPTURE_SSP_MASK_SHIFT;
if (ssp_mask_hdmi_in) {
int port = 0;
/* the topology supports HDMI-IN uses fixed BE ID for DAI links */
fixed_be = true;
be_id = HDMI_IN_BE_ID;
for_each_set_bit(port, &ssp_mask_hdmi_in, 32) {
ret = sof_intel_board_set_hdmi_in_link(dev, &links[id],
be_id, port);
if (ret) if (ret)
return NULL; return ret;
id++; if (ctx->amp_type == CODEC_NONE)
be_id++; return 0;
}
}
/* codec SSP */ if (!ctx->amp_link) {
if (amp_type != CODEC_NONE) { dev_err(dev, "amp link not available");
be_id = fixed_be ? SPK_BE_ID : id; return -EINVAL;
ret = sof_intel_board_set_ssp_amp_link(dev, &links[id], be_id, }
amp_type, ssp_amp);
if (ret)
return NULL;
/* codec-specific fields */ /* codec-specific fields for speaker amplifier */
switch (amp_type) { switch (ctx->amp_type) {
case CODEC_CS35L41: case CODEC_CS35L41:
cs35l41_set_dai_link(&links[id]); cs35l41_set_dai_link(ctx->amp_link);
break; break;
case CODEC_RT1308: case CODEC_RT1308:
sof_rt1308_dai_link(&links[id]); sof_rt1308_dai_link(ctx->amp_link);
break; break;
default: default:
dev_err(dev, "invalid amp type %d\n", amp_type); dev_err(dev, "invalid amp type %d\n", ctx->amp_type);
return NULL; return -EINVAL;
}
id++;
}
/* dmic */
if (dmic_be_num > 0) {
/* at least we have dmic01 */
be_id = fixed_be ? DMIC01_BE_ID : id;
ret = sof_intel_board_set_dmic_link(dev, &links[id], be_id,
SOF_DMIC_01);
if (ret)
return NULL;
id++;
}
if (dmic_be_num > 1) {
/* set up 2 BE links at most */
be_id = fixed_be ? DMIC16K_BE_ID : id;
ret = sof_intel_board_set_dmic_link(dev, &links[id], be_id,
SOF_DMIC_16K);
if (ret)
return NULL;
id++;
}
/* HDMI playback */
for (i = 1; i <= hdmi_num; i++) {
be_id = fixed_be ? (INTEL_HDMI_BE_ID + i - 1) : id;
ret = sof_intel_board_set_intel_hdmi_link(dev, &links[id], be_id,
i, idisp_codec);
if (ret)
return NULL;
id++;
}
/* BT audio offload */
if (sof_ssp_amp_quirk & SOF_SSP_BT_OFFLOAD_PRESENT) {
int port = (sof_ssp_amp_quirk & SOF_BT_OFFLOAD_SSP_MASK) >>
SOF_BT_OFFLOAD_SSP_SHIFT;
ret = sof_intel_board_set_bt_link(dev, &links[id], id, port);
if (ret)
return NULL;
id++;
} }
return links; return 0;
} }
static int sof_ssp_amp_probe(struct platform_device *pdev) static int sof_ssp_amp_probe(struct platform_device *pdev)
{ {
struct snd_soc_acpi_mach *mach = pdev->dev.platform_data; struct snd_soc_acpi_mach *mach = pdev->dev.platform_data;
struct snd_soc_dai_link *dai_links;
struct sof_card_private *ctx; struct sof_card_private *ctx;
int ret; int ret;
ctx = devm_kzalloc(&pdev->dev, sizeof(*ctx), GFP_KERNEL);
if (!ctx)
return -ENOMEM;
if (pdev->id_entry && pdev->id_entry->driver_data) if (pdev->id_entry && pdev->id_entry->driver_data)
sof_ssp_amp_quirk = (unsigned long)pdev->id_entry->driver_data; sof_ssp_amp_quirk = (unsigned long)pdev->id_entry->driver_data;
ctx->amp_type = sof_ssp_detect_amp_type(&pdev->dev); dev_dbg(&pdev->dev, "sof_ssp_amp_quirk = %lx\n", sof_ssp_amp_quirk);
if (dmi_check_system(chromebook_platforms) || mach->mach_params.dmic_num > 0)
ctx->dmic_be_num = 2;
else
ctx->dmic_be_num = 0;
/* port number/mask of peripherals attached to ssp interface */
ctx->ssp_mask_hdmi_in = (sof_ssp_amp_quirk & SOF_HDMI_CAPTURE_SSP_MASK_MASK) >>
SOF_HDMI_CAPTURE_SSP_MASK_SHIFT;
ctx->ssp_bt = (sof_ssp_amp_quirk & SOF_BT_OFFLOAD_SSP_MASK) >>
SOF_BT_OFFLOAD_SSP_SHIFT;
ctx->ssp_amp = sof_ssp_amp_quirk & SOF_AMPLIFIER_SSP_MASK;
/* set number of dai links */ /* initialize ctx with board quirk */
sof_ssp_amp_card.num_links = ctx->dmic_be_num; ctx = sof_intel_board_get_ctx(&pdev->dev, sof_ssp_amp_quirk);
if (!ctx)
if (ctx->amp_type != CODEC_NONE) return -ENOMEM;
sof_ssp_amp_card.num_links++;
if (ctx->ssp_mask_hdmi_in) if (!dmi_check_system(chromebook_platforms) &&
sof_ssp_amp_card.num_links += hweight32(ctx->ssp_mask_hdmi_in); (mach->mach_params.dmic_num == 0))
ctx->dmic_be_num = 0;
if (sof_ssp_amp_quirk & SOF_HDMI_PLAYBACK_PRESENT) { if (sof_ssp_amp_quirk & SOF_HDMI_PLAYBACK_PRESENT) {
ctx->hdmi_num = (sof_ssp_amp_quirk & SOF_NO_OF_HDMI_PLAYBACK_MASK) >>
SOF_NO_OF_HDMI_PLAYBACK_SHIFT;
/* default number of HDMI DAI's */
if (!ctx->hdmi_num)
ctx->hdmi_num = 3;
if (mach->mach_params.codec_mask & IDISP_CODEC_MASK) if (mach->mach_params.codec_mask & IDISP_CODEC_MASK)
ctx->hdmi.idisp_codec = true; ctx->hdmi.idisp_codec = true;
sof_ssp_amp_card.num_links += ctx->hdmi_num;
} else { } else {
ctx->hdmi_num = 0; ctx->hdmi_num = 0;
} }
if (sof_ssp_amp_quirk & SOF_SSP_BT_OFFLOAD_PRESENT) { ctx->link_order_overwrite = SSP_AMP_LINK_ORDER;
ctx->bt_offload_present = true;
sof_ssp_amp_card.num_links++;
}
dai_links = sof_card_dai_links_create(&pdev->dev, ctx->amp_type, if (ctx->ssp_mask_hdmi_in) {
ctx->ssp_amp, ctx->dmic_be_num, /* the topology supports HDMI-IN uses fixed BE ID for DAI links */
ctx->hdmi_num, ctx->link_id_overwrite = SSP_AMP_LINK_IDS;
ctx->hdmi.idisp_codec); }
if (!dai_links)
return -ENOMEM;
sof_ssp_amp_card.dai_link = dai_links; /* update dai_link */
ret = sof_card_dai_links_create(&pdev->dev, &sof_ssp_amp_card, ctx);
if (ret)
return ret;
/* update codec_conf */ /* update codec_conf */
switch (ctx->amp_type) { switch (ctx->amp_type) {
case CODEC_CS35L41: case CODEC_CS35L41:
cs35l41_set_codec_conf(&sof_ssp_amp_card); cs35l41_set_codec_conf(&sof_ssp_amp_card);
break; break;
case CODEC_NONE:
case CODEC_RT1308: case CODEC_RT1308:
case CODEC_NONE:
/* no codec conf required */ /* no codec conf required */
break; break;
default: default:
...@@ -292,37 +180,34 @@ static const struct platform_device_id board_ids[] = { ...@@ -292,37 +180,34 @@ static const struct platform_device_id board_ids[] = {
}, },
{ {
.name = "tgl_rt1308_hdmi_ssp", .name = "tgl_rt1308_hdmi_ssp",
.driver_data = (kernel_ulong_t)(SOF_AMPLIFIER_SSP(2) | .driver_data = (kernel_ulong_t)(SOF_SSP_PORT_AMP(2) |
SOF_HDMI_CAPTURE_SSP_MASK(0x22)), SOF_SSP_MASK_HDMI_CAPTURE(0x22)),
/* SSP 1 and SSP 5 are used for HDMI IN */ /* SSP 1 and SSP 5 are used for HDMI IN */
}, },
{ {
.name = "adl_cs35l41", .name = "adl_cs35l41",
.driver_data = (kernel_ulong_t)(SOF_AMPLIFIER_SSP(1) | .driver_data = (kernel_ulong_t)(SOF_SSP_PORT_AMP(1) |
SOF_NO_OF_HDMI_PLAYBACK(4) | SOF_NUM_IDISP_HDMI(4) |
SOF_HDMI_PLAYBACK_PRESENT | SOF_HDMI_PLAYBACK_PRESENT |
SOF_BT_OFFLOAD_SSP(2) | SOF_SSP_PORT_BT_OFFLOAD(2) |
SOF_SSP_BT_OFFLOAD_PRESENT), SOF_BT_OFFLOAD_PRESENT),
}, },
{ {
.name = "adl_lt6911_hdmi_ssp", .name = "adl_lt6911_hdmi_ssp",
.driver_data = (kernel_ulong_t)(SOF_HDMI_CAPTURE_SSP_MASK(0x5) | .driver_data = (kernel_ulong_t)(SOF_SSP_MASK_HDMI_CAPTURE(0x5) |
/* SSP 0 and SSP 2 are used for HDMI IN */ /* SSP 0 and SSP 2 are used for HDMI IN */
SOF_NO_OF_HDMI_PLAYBACK(3) |
SOF_HDMI_PLAYBACK_PRESENT), SOF_HDMI_PLAYBACK_PRESENT),
}, },
{ {
.name = "rpl_lt6911_hdmi_ssp", .name = "rpl_lt6911_hdmi_ssp",
.driver_data = (kernel_ulong_t)(SOF_HDMI_CAPTURE_SSP_MASK(0x5) | .driver_data = (kernel_ulong_t)(SOF_SSP_MASK_HDMI_CAPTURE(0x5) |
/* SSP 0 and SSP 2 are used for HDMI IN */ /* SSP 0 and SSP 2 are used for HDMI IN */
SOF_NO_OF_HDMI_PLAYBACK(3) |
SOF_HDMI_PLAYBACK_PRESENT), SOF_HDMI_PLAYBACK_PRESENT),
}, },
{ {
.name = "mtl_lt6911_hdmi_ssp", .name = "mtl_lt6911_hdmi_ssp",
.driver_data = (kernel_ulong_t)(SOF_HDMI_CAPTURE_SSP_MASK(0x5) | .driver_data = (kernel_ulong_t)(SOF_SSP_MASK_HDMI_CAPTURE(0x5) |
/* SSP 0 and SSP 2 are used for HDMI IN */ /* SSP 0 and SSP 2 are used for HDMI IN */
SOF_NO_OF_HDMI_PLAYBACK(3) |
SOF_HDMI_PLAYBACK_PRESENT), SOF_HDMI_PLAYBACK_PRESENT),
}, },
{ } { }
...@@ -346,4 +231,3 @@ MODULE_LICENSE("GPL"); ...@@ -346,4 +231,3 @@ MODULE_LICENSE("GPL");
MODULE_IMPORT_NS(SND_SOC_INTEL_SOF_BOARD_HELPERS); MODULE_IMPORT_NS(SND_SOC_INTEL_SOF_BOARD_HELPERS);
MODULE_IMPORT_NS(SND_SOC_INTEL_SOF_REALTEK_COMMON); MODULE_IMPORT_NS(SND_SOC_INTEL_SOF_REALTEK_COMMON);
MODULE_IMPORT_NS(SND_SOC_INTEL_SOF_CIRRUS_COMMON); MODULE_IMPORT_NS(SND_SOC_INTEL_SOF_CIRRUS_COMMON);
MODULE_IMPORT_NS(SND_SOC_INTEL_SOF_SSP_COMMON);
...@@ -563,7 +563,7 @@ struct snd_soc_acpi_mach snd_soc_acpi_intel_adl_machines[] = { ...@@ -563,7 +563,7 @@ struct snd_soc_acpi_mach snd_soc_acpi_intel_adl_machines[] = {
}, },
{ {
.id = "10508825", .id = "10508825",
.drv_name = "sof_nau8825", .drv_name = "adl_nau8825_def",
.sof_tplg_filename = "sof-adl-nau8825.tplg", .sof_tplg_filename = "sof-adl-nau8825.tplg",
}, },
{ {
...@@ -616,7 +616,7 @@ struct snd_soc_acpi_mach snd_soc_acpi_intel_adl_machines[] = { ...@@ -616,7 +616,7 @@ struct snd_soc_acpi_mach snd_soc_acpi_intel_adl_machines[] = {
}, },
{ {
.id = "DLGS7219", .id = "DLGS7219",
.drv_name = "adl_mx98360_da7219", .drv_name = "adl_da7219_def",
.machine_quirk = snd_soc_acpi_codec_list, .machine_quirk = snd_soc_acpi_codec_list,
.quirk_data = &adl_max98360a_amp, .quirk_data = &adl_max98360a_amp,
.sof_tplg_filename = "sof-adl-max98360a-da7219.tplg", .sof_tplg_filename = "sof-adl-max98360a-da7219.tplg",
......
...@@ -49,21 +49,21 @@ struct snd_soc_acpi_mach snd_soc_acpi_intel_cml_machines[] = { ...@@ -49,21 +49,21 @@ struct snd_soc_acpi_mach snd_soc_acpi_intel_cml_machines[] = {
}, },
{ {
.id = "10EC5682", .id = "10EC5682",
.drv_name = "cml_rt1015_rt5682", .drv_name = "cml_rt5682_def",
.machine_quirk = snd_soc_acpi_codec_list, .machine_quirk = snd_soc_acpi_codec_list,
.quirk_data = &rt1015_spk_codecs, .quirk_data = &rt1015_spk_codecs,
.sof_tplg_filename = "sof-cml-rt1011-rt5682.tplg", .sof_tplg_filename = "sof-cml-rt1011-rt5682.tplg",
}, },
{ {
.id = "10EC5682", .id = "10EC5682",
.drv_name = "sof_rt5682", .drv_name = "cml_rt5682_def",
.machine_quirk = snd_soc_acpi_codec_list, .machine_quirk = snd_soc_acpi_codec_list,
.quirk_data = &max98357a_spk_codecs, .quirk_data = &max98357a_spk_codecs,
.sof_tplg_filename = "sof-cml-rt5682-max98357a.tplg", .sof_tplg_filename = "sof-cml-rt5682-max98357a.tplg",
}, },
{ {
.id = "10EC5682", .id = "10EC5682",
.drv_name = "sof_rt5682", .drv_name = "cml_rt5682_def",
.sof_tplg_filename = "sof-cml-rt5682.tplg", .sof_tplg_filename = "sof-cml-rt5682.tplg",
}, },
{ {
......
...@@ -52,14 +52,14 @@ static const struct snd_soc_acpi_codecs rt5682_rt5682s_hp = { ...@@ -52,14 +52,14 @@ static const struct snd_soc_acpi_codecs rt5682_rt5682s_hp = {
struct snd_soc_acpi_mach snd_soc_acpi_intel_jsl_machines[] = { struct snd_soc_acpi_mach snd_soc_acpi_intel_jsl_machines[] = {
{ {
.id = "DLGS7219", .id = "DLGS7219",
.drv_name = "jsl_mx98373_da7219", .drv_name = "jsl_da7219_def",
.machine_quirk = snd_soc_acpi_codec_list, .machine_quirk = snd_soc_acpi_codec_list,
.quirk_data = &mx98373_spk, .quirk_data = &mx98373_spk,
.sof_tplg_filename = "sof-jsl-da7219.tplg", .sof_tplg_filename = "sof-jsl-da7219.tplg",
}, },
{ {
.id = "DLGS7219", .id = "DLGS7219",
.drv_name = "jsl_mx98360_da7219", .drv_name = "jsl_da7219_def",
.machine_quirk = snd_soc_acpi_codec_list, .machine_quirk = snd_soc_acpi_codec_list,
.quirk_data = &mx98360a_spk, .quirk_data = &mx98360a_spk,
.sof_tplg_filename = "sof-jsl-da7219-mx98360a.tplg", .sof_tplg_filename = "sof-jsl-da7219-mx98360a.tplg",
......
...@@ -455,6 +455,18 @@ struct snd_soc_acpi_mach snd_soc_acpi_intel_rpl_machines[] = { ...@@ -455,6 +455,18 @@ struct snd_soc_acpi_mach snd_soc_acpi_intel_rpl_machines[] = {
.drv_name = "rpl_lt6911_hdmi_ssp", .drv_name = "rpl_lt6911_hdmi_ssp",
.sof_tplg_filename = "sof-rpl-nocodec-hdmi-ssp02.tplg" .sof_tplg_filename = "sof-rpl-nocodec-hdmi-ssp02.tplg"
}, },
{
.id = "DLGS7219",
.drv_name = "rpl_da7219_def",
.machine_quirk = snd_soc_acpi_codec_list,
.quirk_data = &rpl_max98360a_amp,
.sof_tplg_filename = "sof-rpl-max98360a-da7219.tplg",
},
{
.id = "10EC5650",
.drv_name = "rpl_rt5682_def",
.sof_tplg_filename = "sof-rpl-rt5650.tplg",
},
{}, {},
}; };
EXPORT_SYMBOL_GPL(snd_soc_acpi_intel_rpl_machines); EXPORT_SYMBOL_GPL(snd_soc_acpi_intel_rpl_machines);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment