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);
...@@ -15,35 +15,25 @@ ...@@ -15,35 +15,25 @@
#include <sound/soc-acpi.h> #include <sound/soc-acpi.h>
#include <sound/sof.h> #include <sound/sof.h>
#include "../../codecs/da7219.h" #include "../../codecs/da7219.h"
#include "hda_dsp_common.h" #include "sof_board_helpers.h"
#include "sof_hdmi_common.h"
#include "sof_maxim_common.h" #include "sof_maxim_common.h"
#include "sof_ssp_common.h"
/* Board Quirks */ /* Driver-specific board quirks: from bit 0 to 7 */
#define SOF_DA7219_JSL_BOARD BIT(2) #define SOF_DA7219_JSL_BOARD BIT(0)
#define SOF_DA7219_MCLK_EN BIT(1)
#define DIALOG_CODEC_DAI "da7219-hifi" #define DIALOG_CODEC_DAI "da7219-hifi"
struct card_private {
struct snd_soc_jack headset_jack;
struct sof_hdmi_private hdmi;
enum sof_ssp_codec codec_type;
enum sof_ssp_codec amp_type;
unsigned int pll_bypass:1;
};
static int platform_clock_control(struct snd_soc_dapm_widget *w, static int platform_clock_control(struct snd_soc_dapm_widget *w,
struct snd_kcontrol *k, int event) struct snd_kcontrol *k, int event)
{ {
struct snd_soc_dapm_context *dapm = w->dapm; struct snd_soc_dapm_context *dapm = w->dapm;
struct snd_soc_card *card = dapm->card; struct snd_soc_card *card = dapm->card;
struct card_private *ctx = snd_soc_card_get_drvdata(card); struct sof_card_private *ctx = snd_soc_card_get_drvdata(card);
struct snd_soc_dai *codec_dai; struct snd_soc_dai *codec_dai;
int ret = 0; int ret = 0;
if (ctx->pll_bypass) if (ctx->da7219.pll_bypass)
return ret; return ret;
/* PLL SRM mode */ /* PLL SRM mode */
...@@ -74,8 +64,6 @@ static const struct snd_kcontrol_new controls[] = { ...@@ -74,8 +64,6 @@ static const struct snd_kcontrol_new controls[] = {
SOC_DAPM_PIN_SWITCH("Headphone Jack"), SOC_DAPM_PIN_SWITCH("Headphone Jack"),
SOC_DAPM_PIN_SWITCH("Headset Mic"), SOC_DAPM_PIN_SWITCH("Headset Mic"),
SOC_DAPM_PIN_SWITCH("Line Out"), SOC_DAPM_PIN_SWITCH("Line Out"),
SOC_DAPM_PIN_SWITCH("Left Spk"),
SOC_DAPM_PIN_SWITCH("Right Spk"),
}; };
static const struct snd_soc_dapm_widget widgets[] = { static const struct snd_soc_dapm_widget widgets[] = {
...@@ -83,14 +71,9 @@ static const struct snd_soc_dapm_widget widgets[] = { ...@@ -83,14 +71,9 @@ static const struct snd_soc_dapm_widget widgets[] = {
SND_SOC_DAPM_MIC("Headset Mic", NULL), SND_SOC_DAPM_MIC("Headset Mic", NULL),
SND_SOC_DAPM_LINE("Line Out", NULL), SND_SOC_DAPM_LINE("Line Out", NULL),
SND_SOC_DAPM_SPK("Left Spk", NULL),
SND_SOC_DAPM_SPK("Right Spk", NULL),
SND_SOC_DAPM_SUPPLY("Platform Clock", SND_SOC_NOPM, 0, 0, SND_SOC_DAPM_SUPPLY("Platform Clock", SND_SOC_NOPM, 0, 0,
platform_clock_control, SND_SOC_DAPM_POST_PMD | platform_clock_control, SND_SOC_DAPM_POST_PMD |
SND_SOC_DAPM_PRE_PMU), SND_SOC_DAPM_PRE_PMU),
SND_SOC_DAPM_MIC("SoC DMIC", NULL),
}; };
static const struct snd_soc_dapm_route audio_map[] = { static const struct snd_soc_dapm_route audio_map[] = {
...@@ -102,9 +85,6 @@ static const struct snd_soc_dapm_route audio_map[] = { ...@@ -102,9 +85,6 @@ static const struct snd_soc_dapm_route audio_map[] = {
{ "Headphone Jack", NULL, "Platform Clock" }, { "Headphone Jack", NULL, "Platform Clock" },
{ "Headset Mic", NULL, "Platform Clock" }, { "Headset Mic", NULL, "Platform Clock" },
{ "Line Out", NULL, "Platform Clock" }, { "Line Out", NULL, "Platform Clock" },
/* digital mics */
{"DMic", NULL, "SoC DMIC"},
}; };
static struct snd_soc_jack_pin jack_pins[] = { static struct snd_soc_jack_pin jack_pins[] = {
...@@ -124,7 +104,7 @@ static struct snd_soc_jack_pin jack_pins[] = { ...@@ -124,7 +104,7 @@ static struct snd_soc_jack_pin jack_pins[] = {
static int da7219_codec_init(struct snd_soc_pcm_runtime *rtd) static int da7219_codec_init(struct snd_soc_pcm_runtime *rtd)
{ {
struct card_private *ctx = snd_soc_card_get_drvdata(rtd->card); struct sof_card_private *ctx = snd_soc_card_get_drvdata(rtd->card);
struct snd_soc_dai *codec_dai = snd_soc_rtd_to_codec(rtd, 0); struct snd_soc_dai *codec_dai = snd_soc_rtd_to_codec(rtd, 0);
struct snd_soc_component *component = codec_dai->component; struct snd_soc_component *component = codec_dai->component;
struct snd_soc_jack *jack = &ctx->headset_jack; struct snd_soc_jack *jack = &ctx->headset_jack;
...@@ -147,7 +127,8 @@ static int da7219_codec_init(struct snd_soc_pcm_runtime *rtd) ...@@ -147,7 +127,8 @@ static int da7219_codec_init(struct snd_soc_pcm_runtime *rtd)
* Use PLL bypass mode if MCLK is available, be sure to set the * Use PLL bypass mode if MCLK is available, be sure to set the
* frequency of MCLK to 12.288 or 24.576MHz on topology side. * frequency of MCLK to 12.288 or 24.576MHz on topology side.
*/ */
if (mclk_rate == 12288000 || mclk_rate == 24576000) { if (ctx->da7219.mclk_en &&
(mclk_rate == 12288000 || mclk_rate == 24576000)) {
/* PLL bypass mode */ /* PLL bypass mode */
dev_dbg(rtd->dev, "pll bypass mode, mclk rate %d\n", mclk_rate); dev_dbg(rtd->dev, "pll bypass mode, mclk rate %d\n", mclk_rate);
...@@ -157,7 +138,7 @@ static int da7219_codec_init(struct snd_soc_pcm_runtime *rtd) ...@@ -157,7 +138,7 @@ static int da7219_codec_init(struct snd_soc_pcm_runtime *rtd)
return ret; return ret;
} }
ctx->pll_bypass = 1; ctx->da7219.pll_bypass = true;
} }
/* /*
...@@ -188,6 +169,13 @@ static int da7219_codec_init(struct snd_soc_pcm_runtime *rtd) ...@@ -188,6 +169,13 @@ static int da7219_codec_init(struct snd_soc_pcm_runtime *rtd)
return ret; return ret;
} }
static void da7219_codec_exit(struct snd_soc_pcm_runtime *rtd)
{
struct snd_soc_component *component = snd_soc_rtd_to_codec(rtd, 0)->component;
snd_soc_component_set_jack(component, NULL, NULL);
}
static int max98373_hw_params(struct snd_pcm_substream *substream, static int max98373_hw_params(struct snd_pcm_substream *substream,
struct snd_pcm_hw_params *params) struct snd_pcm_hw_params *params)
{ {
...@@ -222,215 +210,11 @@ static const struct snd_soc_ops max98373_ops = { ...@@ -222,215 +210,11 @@ static const struct snd_soc_ops max98373_ops = {
.hw_params = max98373_hw_params, .hw_params = max98373_hw_params,
}; };
static int hdmi_init(struct snd_soc_pcm_runtime *rtd)
{
struct card_private *ctx = snd_soc_card_get_drvdata(rtd->card);
struct snd_soc_dai *dai = snd_soc_rtd_to_codec(rtd, 0);
ctx->hdmi.hdmi_comp = dai->component;
return 0;
}
static int card_late_probe(struct snd_soc_card *card) static int card_late_probe(struct snd_soc_card *card)
{ {
struct card_private *ctx = snd_soc_card_get_drvdata(card); return sof_intel_board_card_late_probe(card);
if (!ctx->hdmi.idisp_codec)
return 0;
if (!ctx->hdmi.hdmi_comp)
return -EINVAL;
return hda_dsp_hdmi_build_controls(card, ctx->hdmi.hdmi_comp);
} }
SND_SOC_DAILINK_DEF(ssp0_pin,
DAILINK_COMP_ARRAY(COMP_CPU("SSP0 Pin")));
SND_SOC_DAILINK_DEF(ssp0_codec,
DAILINK_COMP_ARRAY(COMP_CODEC("i2c-DLGS7219:00", DIALOG_CODEC_DAI)));
SND_SOC_DAILINK_DEF(ssp1_pin,
DAILINK_COMP_ARRAY(COMP_CPU("SSP1 Pin")));
SND_SOC_DAILINK_DEF(ssp2_pin,
DAILINK_COMP_ARRAY(COMP_CPU("SSP2 Pin")));
SND_SOC_DAILINK_DEF(dummy_codec,
DAILINK_COMP_ARRAY(COMP_CODEC("snd-soc-dummy", "snd-soc-dummy-dai")));
SND_SOC_DAILINK_DEF(dmic_pin,
DAILINK_COMP_ARRAY(COMP_CPU("DMIC01 Pin")));
SND_SOC_DAILINK_DEF(dmic_codec,
DAILINK_COMP_ARRAY(COMP_CODEC("dmic-codec", "dmic-hifi")));
SND_SOC_DAILINK_DEF(dmic16k_pin,
DAILINK_COMP_ARRAY(COMP_CPU("DMIC16k Pin")));
SND_SOC_DAILINK_DEF(idisp1_pin,
DAILINK_COMP_ARRAY(COMP_CPU("iDisp1 Pin")));
SND_SOC_DAILINK_DEF(idisp1_codec,
DAILINK_COMP_ARRAY(COMP_CODEC("ehdaudio0D2", "intel-hdmi-hifi1")));
SND_SOC_DAILINK_DEF(idisp2_pin,
DAILINK_COMP_ARRAY(COMP_CPU("iDisp2 Pin")));
SND_SOC_DAILINK_DEF(idisp2_codec,
DAILINK_COMP_ARRAY(COMP_CODEC("ehdaudio0D2", "intel-hdmi-hifi2")));
SND_SOC_DAILINK_DEF(idisp3_pin,
DAILINK_COMP_ARRAY(COMP_CPU("iDisp3 Pin")));
SND_SOC_DAILINK_DEF(idisp3_codec,
DAILINK_COMP_ARRAY(COMP_CODEC("ehdaudio0D2", "intel-hdmi-hifi3")));
SND_SOC_DAILINK_DEF(idisp4_pin,
DAILINK_COMP_ARRAY(COMP_CPU("iDisp4 Pin")));
SND_SOC_DAILINK_DEF(idisp4_codec,
DAILINK_COMP_ARRAY(COMP_CODEC("ehdaudio0D2", "intel-hdmi-hifi4")));
SND_SOC_DAILINK_DEF(platform, /* subject to be overridden during probe */
DAILINK_COMP_ARRAY(COMP_PLATFORM("0000:00:1f.3")));
static struct snd_soc_dai_link jsl_dais[] = {
/* Back End DAI links */
{
.name = "SSP1-Codec",
.id = 0,
.ignore_pmdown_time = 1,
.no_pcm = 1,
.dpcm_playback = 1,
.dpcm_capture = 1, /* IV feedback */
SND_SOC_DAILINK_REG(ssp1_pin, max_98373_components, platform),
},
{
.name = "SSP0-Codec",
.id = 1,
.no_pcm = 1,
.init = da7219_codec_init,
.ignore_pmdown_time = 1,
.dpcm_playback = 1,
.dpcm_capture = 1,
SND_SOC_DAILINK_REG(ssp0_pin, ssp0_codec, platform),
},
{
.name = "dmic01",
.id = 2,
.ignore_suspend = 1,
.dpcm_capture = 1,
.no_pcm = 1,
SND_SOC_DAILINK_REG(dmic_pin, dmic_codec, platform),
},
{
.name = "iDisp1",
.id = 3,
.init = hdmi_init,
.dpcm_playback = 1,
.no_pcm = 1,
SND_SOC_DAILINK_REG(idisp1_pin, idisp1_codec, platform),
},
{
.name = "iDisp2",
.id = 4,
.init = hdmi_init,
.dpcm_playback = 1,
.no_pcm = 1,
SND_SOC_DAILINK_REG(idisp2_pin, idisp2_codec, platform),
},
{
.name = "iDisp3",
.id = 5,
.init = hdmi_init,
.dpcm_playback = 1,
.no_pcm = 1,
SND_SOC_DAILINK_REG(idisp3_pin, idisp3_codec, platform),
},
{
.name = "dmic16k",
.id = 6,
.ignore_suspend = 1,
.dpcm_capture = 1,
.no_pcm = 1,
SND_SOC_DAILINK_REG(dmic16k_pin, dmic_codec, platform),
}
};
static struct snd_soc_dai_link adl_dais[] = {
/* Back End DAI links */
{
.name = "SSP0-Codec",
.id = 0,
.no_pcm = 1,
.init = da7219_codec_init,
.ignore_pmdown_time = 1,
.dpcm_playback = 1,
.dpcm_capture = 1,
SND_SOC_DAILINK_REG(ssp0_pin, ssp0_codec, platform),
},
{
.name = "dmic01",
.id = 1,
.ignore_suspend = 1,
.dpcm_capture = 1,
.no_pcm = 1,
SND_SOC_DAILINK_REG(dmic_pin, dmic_codec, platform),
},
{
.name = "dmic16k",
.id = 2,
.ignore_suspend = 1,
.dpcm_capture = 1,
.no_pcm = 1,
SND_SOC_DAILINK_REG(dmic16k_pin, dmic_codec, platform),
},
{
.name = "iDisp1",
.id = 3,
.init = hdmi_init,
.dpcm_playback = 1,
.no_pcm = 1,
SND_SOC_DAILINK_REG(idisp1_pin, idisp1_codec, platform),
},
{
.name = "iDisp2",
.id = 4,
.init = hdmi_init,
.dpcm_playback = 1,
.no_pcm = 1,
SND_SOC_DAILINK_REG(idisp2_pin, idisp2_codec, platform),
},
{
.name = "iDisp3",
.id = 5,
.init = hdmi_init,
.dpcm_playback = 1,
.no_pcm = 1,
SND_SOC_DAILINK_REG(idisp3_pin, idisp3_codec, platform),
},
{
.name = "iDisp4",
.id = 6,
.init = hdmi_init,
.dpcm_playback = 1,
.no_pcm = 1,
SND_SOC_DAILINK_REG(idisp4_pin, idisp4_codec, platform),
},
{
.name = "SSP1-Codec",
.id = 7,
.no_pcm = 1,
.dpcm_playback = 1,
/* feedback stream or firmware-generated echo reference */
.dpcm_capture = 1,
SND_SOC_DAILINK_REG(ssp1_pin, max_98373_components, platform),
},
{
.name = "SSP2-BT",
.id = 8,
.no_pcm = 1,
.dpcm_playback = 1,
.dpcm_capture = 1,
SND_SOC_DAILINK_REG(ssp2_pin, dummy_codec, platform),
},
};
static struct snd_soc_card card_da7219 = { static struct snd_soc_card card_da7219 = {
.name = "da7219", /* the sof- prefix is added by the core */ .name = "da7219", /* the sof- prefix is added by the core */
.owner = THIS_MODULE, .owner = THIS_MODULE,
...@@ -444,28 +228,101 @@ static struct snd_soc_card card_da7219 = { ...@@ -444,28 +228,101 @@ static struct snd_soc_card card_da7219 = {
.late_probe = card_late_probe, .late_probe = card_late_probe,
}; };
static struct snd_soc_dai_link_component da7219_component[] = {
{
.name = "i2c-DLGS7219:00",
.dai_name = DIALOG_CODEC_DAI,
}
};
static int
sof_card_dai_links_create(struct device *dev, struct snd_soc_card *card,
struct sof_card_private *ctx)
{
int ret;
ret = sof_intel_board_set_dai_link(dev, card, ctx);
if (ret)
return ret;
if (!ctx->codec_link) {
dev_err(dev, "codec link not available");
return -EINVAL;
}
/* codec-specific fields for headphone codec */
ctx->codec_link->codecs = da7219_component;
ctx->codec_link->num_codecs = ARRAY_SIZE(da7219_component);
ctx->codec_link->init = da7219_codec_init;
ctx->codec_link->exit = da7219_codec_exit;
if (ctx->amp_type == CODEC_NONE)
return 0;
if (!ctx->amp_link) {
dev_err(dev, "amp link not available");
return -EINVAL;
}
/* codec-specific fields for speaker amplifier */
switch (ctx->amp_type) {
case CODEC_MAX98360A:
max_98360a_dai_link(ctx->amp_link);
break;
case CODEC_MAX98373:
ctx->amp_link->codecs = max_98373_components;
ctx->amp_link->num_codecs = ARRAY_SIZE(max_98373_components);
ctx->amp_link->init = max_98373_spk_codec_init;
if (ctx->da7219.is_jsl_board) {
ctx->amp_link->ops = &max98373_ops; /* use local ops */
} else {
/* TBD: implement the amp for later platform */
dev_err(dev, "max98373 not support yet\n");
return -EINVAL;
}
break;
default:
dev_err(dev, "invalid amp type %d\n", ctx->amp_type);
return -EINVAL;
}
return 0;
}
#define JSL_LINK_ORDER SOF_LINK_ORDER(SOF_LINK_AMP, \
SOF_LINK_CODEC, \
SOF_LINK_DMIC01, \
SOF_LINK_IDISP_HDMI, \
SOF_LINK_DMIC16K, \
SOF_LINK_NONE, \
SOF_LINK_NONE)
static int audio_probe(struct platform_device *pdev) static int audio_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 card_private *ctx;
unsigned long board_quirk = 0; unsigned long board_quirk = 0;
int ret, amp_idx; 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)
board_quirk = (unsigned long)pdev->id_entry->driver_data; board_quirk = (unsigned long)pdev->id_entry->driver_data;
ctx->codec_type = sof_ssp_detect_codec_type(&pdev->dev); dev_dbg(&pdev->dev, "board_quirk = %lx\n", board_quirk);
ctx->amp_type = sof_ssp_detect_amp_type(&pdev->dev);
/* initialize ctx with board quirk */
ctx = sof_intel_board_get_ctx(&pdev->dev, board_quirk);
if (!ctx)
return -ENOMEM;
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;
if (board_quirk & SOF_DA7219_JSL_BOARD) { if (board_quirk & SOF_DA7219_JSL_BOARD) {
ctx->da7219.is_jsl_board = true;
/* overwrite the DAI link order for JSL boards */
ctx->link_order_overwrite = JSL_LINK_ORDER;
/* backward-compatible with existing devices */ /* backward-compatible with existing devices */
switch (ctx->amp_type) { switch (ctx->amp_type) {
case CODEC_MAX98360A: case CODEC_MAX98360A:
...@@ -480,46 +337,30 @@ static int audio_probe(struct platform_device *pdev) ...@@ -480,46 +337,30 @@ static int audio_probe(struct platform_device *pdev)
default: default:
break; break;
} }
dai_links = jsl_dais;
amp_idx = 0;
card_da7219.num_links = ARRAY_SIZE(jsl_dais);
} else {
dai_links = adl_dais;
amp_idx = 7;
card_da7219.num_links = ARRAY_SIZE(adl_dais);
} }
dev_dbg(&pdev->dev, "board_quirk = %lx\n", board_quirk); if (board_quirk & SOF_DA7219_MCLK_EN)
ctx->da7219.mclk_en = true;
/* update dai_link */
ret = sof_card_dai_links_create(&pdev->dev, &card_da7219, ctx);
if (ret)
return ret;
/* speaker amp */ /* update codec_conf */
switch (ctx->amp_type) { switch (ctx->amp_type) {
case CODEC_MAX98360A:
max_98360a_dai_link(&dai_links[amp_idx]);
break;
case CODEC_MAX98373: case CODEC_MAX98373:
dai_links[amp_idx].codecs = max_98373_components;
dai_links[amp_idx].num_codecs = ARRAY_SIZE(max_98373_components);
dai_links[amp_idx].init = max_98373_spk_codec_init;
if (board_quirk & SOF_DA7219_JSL_BOARD) {
dai_links[amp_idx].ops = &max98373_ops; /* use local ops */
} else {
/* TBD: implement the amp for later platform */
dev_err(&pdev->dev, "max98373 not support yet\n");
return -EINVAL;
}
max_98373_set_codec_conf(&card_da7219); max_98373_set_codec_conf(&card_da7219);
break; break;
case CODEC_MAX98360A:
case CODEC_NONE:
/* no codec conf required */
break;
default: default:
dev_err(&pdev->dev, "invalid amp type %d\n", ctx->amp_type); dev_err(&pdev->dev, "invalid amp type %d\n", ctx->amp_type);
return -EINVAL; return -EINVAL;
} }
card_da7219.dai_link = dai_links;
card_da7219.dev = &pdev->dev; card_da7219.dev = &pdev->dev;
ret = snd_soc_fixup_dai_links_platform_name(&card_da7219, ret = snd_soc_fixup_dai_links_platform_name(&card_da7219,
...@@ -534,16 +375,28 @@ static int audio_probe(struct platform_device *pdev) ...@@ -534,16 +375,28 @@ static int audio_probe(struct platform_device *pdev)
static const struct platform_device_id board_ids[] = { static const struct platform_device_id board_ids[] = {
{ {
.name = "jsl_mx98373_da7219", .name = "jsl_da7219_def",
.driver_data = (kernel_ulong_t)(SOF_DA7219_JSL_BOARD), .driver_data = (kernel_ulong_t)(SOF_DA7219_JSL_BOARD |
SOF_SSP_PORT_CODEC(0) |
SOF_SSP_PORT_AMP(1)),
}, },
{ {
.name = "jsl_mx98360_da7219", .name = "adl_da7219_def",
.driver_data = (kernel_ulong_t)(SOF_DA7219_JSL_BOARD), .driver_data = (kernel_ulong_t)(SOF_DA7219_MCLK_EN |
SOF_SSP_PORT_CODEC(0) |
SOF_SSP_PORT_AMP(1) |
SOF_NUM_IDISP_HDMI(4) |
SOF_SSP_PORT_BT_OFFLOAD(2) |
SOF_BT_OFFLOAD_PRESENT),
}, },
{ {
.name = "adl_mx98360_da7219", .name = "rpl_da7219_def",
/* no quirk needed for this board */ .driver_data = (kernel_ulong_t)(SOF_DA7219_MCLK_EN |
SOF_SSP_PORT_CODEC(0) |
SOF_SSP_PORT_AMP(1) |
SOF_NUM_IDISP_HDMI(4) |
SOF_SSP_PORT_BT_OFFLOAD(2) |
SOF_BT_OFFLOAD_PRESENT),
}, },
{ } { }
}; };
...@@ -564,6 +417,5 @@ MODULE_DESCRIPTION("ASoC Intel(R) SOF Machine driver for Dialog codec"); ...@@ -564,6 +417,5 @@ MODULE_DESCRIPTION("ASoC Intel(R) SOF Machine driver for Dialog codec");
MODULE_AUTHOR("Yong Zhi <yong.zhi@intel.com>"); MODULE_AUTHOR("Yong Zhi <yong.zhi@intel.com>");
MODULE_AUTHOR("Brent Lu <brent.lu@intel.com>"); MODULE_AUTHOR("Brent Lu <brent.lu@intel.com>");
MODULE_LICENSE("GPL v2"); MODULE_LICENSE("GPL v2");
MODULE_IMPORT_NS(SND_SOC_INTEL_HDA_DSP_COMMON); 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);
...@@ -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);
...@@ -27,37 +27,14 @@ ...@@ -27,37 +27,14 @@
#include "sof_board_helpers.h" #include "sof_board_helpers.h"
#include "sof_maxim_common.h" #include "sof_maxim_common.h"
#include "sof_realtek_common.h" #include "sof_realtek_common.h"
#include "sof_ssp_common.h"
/* Driver-specific board quirks: from bit 0 to 7 */
#define SOF_RT5682_SSP_CODEC(quirk) ((quirk) & GENMASK(2, 0)) #define SOF_RT5682_MCLK_EN BIT(0)
#define SOF_RT5682_SSP_CODEC_MASK (GENMASK(2, 0)) #define SOF_RT5682_MCLK_BYTCHT_EN BIT(1)
#define SOF_RT5682_MCLK_EN BIT(3)
#define SOF_RT5682_SSP_AMP_SHIFT 6
#define SOF_RT5682_SSP_AMP_MASK (GENMASK(8, 6))
#define SOF_RT5682_SSP_AMP(quirk) \
(((quirk) << SOF_RT5682_SSP_AMP_SHIFT) & SOF_RT5682_SSP_AMP_MASK)
#define SOF_RT5682_MCLK_BYTCHT_EN BIT(9)
#define SOF_RT5682_NUM_HDMIDEV_SHIFT 10
#define SOF_RT5682_NUM_HDMIDEV_MASK (GENMASK(12, 10))
#define SOF_RT5682_NUM_HDMIDEV(quirk) \
((quirk << SOF_RT5682_NUM_HDMIDEV_SHIFT) & SOF_RT5682_NUM_HDMIDEV_MASK)
/* BT audio offload: reserve 3 bits for future */
#define SOF_BT_OFFLOAD_SSP_SHIFT 19
#define SOF_BT_OFFLOAD_SSP_MASK (GENMASK(21, 19))
#define SOF_BT_OFFLOAD_SSP(quirk) \
(((quirk) << SOF_BT_OFFLOAD_SSP_SHIFT) & SOF_BT_OFFLOAD_SSP_MASK)
#define SOF_SSP_BT_OFFLOAD_PRESENT BIT(22)
/* HDMI capture*/
#define SOF_NO_OF_HDMI_CAPTURE_SSP_SHIFT 27
#define SOF_SSP_HDMI_CAPTURE_PRESENT_MASK (GENMASK(30, 27))
#define SOF_HDMI_CAPTURE_SSP_MASK(quirk) \
(((quirk) << SOF_NO_OF_HDMI_CAPTURE_SSP_SHIFT) & SOF_SSP_HDMI_CAPTURE_PRESENT_MASK)
/* Default: MCLK on, MCLK 19.2M, SSP0 */ /* Default: MCLK on, MCLK 19.2M, SSP0 */
static unsigned long sof_rt5682_quirk = SOF_RT5682_MCLK_EN | static unsigned long sof_rt5682_quirk = SOF_RT5682_MCLK_EN |
SOF_RT5682_SSP_CODEC(0); SOF_SSP_PORT_CODEC(0);
static int sof_rt5682_quirk_cb(const struct dmi_system_id *id) static int sof_rt5682_quirk_cb(const struct dmi_system_id *id)
{ {
...@@ -72,7 +49,7 @@ static const struct dmi_system_id sof_rt5682_quirk_table[] = { ...@@ -72,7 +49,7 @@ static const struct dmi_system_id sof_rt5682_quirk_table[] = {
DMI_MATCH(DMI_SYS_VENDOR, "Circuitco"), DMI_MATCH(DMI_SYS_VENDOR, "Circuitco"),
DMI_MATCH(DMI_PRODUCT_NAME, "Minnowboard Max"), DMI_MATCH(DMI_PRODUCT_NAME, "Minnowboard Max"),
}, },
.driver_data = (void *)(SOF_RT5682_SSP_CODEC(2)), .driver_data = (void *)(SOF_SSP_PORT_CODEC(2)),
}, },
{ {
.callback = sof_rt5682_quirk_cb, .callback = sof_rt5682_quirk_cb,
...@@ -80,7 +57,7 @@ static const struct dmi_system_id sof_rt5682_quirk_table[] = { ...@@ -80,7 +57,7 @@ static const struct dmi_system_id sof_rt5682_quirk_table[] = {
DMI_MATCH(DMI_SYS_VENDOR, "AAEON"), DMI_MATCH(DMI_SYS_VENDOR, "AAEON"),
DMI_MATCH(DMI_PRODUCT_NAME, "UP-CHT01"), DMI_MATCH(DMI_PRODUCT_NAME, "UP-CHT01"),
}, },
.driver_data = (void *)(SOF_RT5682_SSP_CODEC(2)), .driver_data = (void *)(SOF_SSP_PORT_CODEC(2)),
}, },
{ {
.callback = sof_rt5682_quirk_cb, .callback = sof_rt5682_quirk_cb,
...@@ -89,7 +66,7 @@ static const struct dmi_system_id sof_rt5682_quirk_table[] = { ...@@ -89,7 +66,7 @@ static const struct dmi_system_id sof_rt5682_quirk_table[] = {
DMI_MATCH(DMI_PRODUCT_NAME, "WhiskeyLake Client"), DMI_MATCH(DMI_PRODUCT_NAME, "WhiskeyLake Client"),
}, },
.driver_data = (void *)(SOF_RT5682_MCLK_EN | .driver_data = (void *)(SOF_RT5682_MCLK_EN |
SOF_RT5682_SSP_CODEC(1)), SOF_SSP_PORT_CODEC(1)),
}, },
{ {
.callback = sof_rt5682_quirk_cb, .callback = sof_rt5682_quirk_cb,
...@@ -97,8 +74,8 @@ static const struct dmi_system_id sof_rt5682_quirk_table[] = { ...@@ -97,8 +74,8 @@ static const struct dmi_system_id sof_rt5682_quirk_table[] = {
DMI_MATCH(DMI_PRODUCT_FAMILY, "Google_Hatch"), DMI_MATCH(DMI_PRODUCT_FAMILY, "Google_Hatch"),
}, },
.driver_data = (void *)(SOF_RT5682_MCLK_EN | .driver_data = (void *)(SOF_RT5682_MCLK_EN |
SOF_RT5682_SSP_CODEC(0) | SOF_SSP_PORT_CODEC(0) |
SOF_RT5682_SSP_AMP(1)), SOF_SSP_PORT_AMP(1)),
}, },
{ {
.callback = sof_rt5682_quirk_cb, .callback = sof_rt5682_quirk_cb,
...@@ -107,7 +84,7 @@ static const struct dmi_system_id sof_rt5682_quirk_table[] = { ...@@ -107,7 +84,7 @@ static const struct dmi_system_id sof_rt5682_quirk_table[] = {
DMI_MATCH(DMI_PRODUCT_NAME, "Ice Lake Client"), DMI_MATCH(DMI_PRODUCT_NAME, "Ice Lake Client"),
}, },
.driver_data = (void *)(SOF_RT5682_MCLK_EN | .driver_data = (void *)(SOF_RT5682_MCLK_EN |
SOF_RT5682_SSP_CODEC(0)), SOF_SSP_PORT_CODEC(0)),
}, },
{ {
.callback = sof_rt5682_quirk_cb, .callback = sof_rt5682_quirk_cb,
...@@ -116,9 +93,9 @@ static const struct dmi_system_id sof_rt5682_quirk_table[] = { ...@@ -116,9 +93,9 @@ static const struct dmi_system_id sof_rt5682_quirk_table[] = {
DMI_MATCH(DMI_OEM_STRING, "AUDIO-MAX98373_ALC5682I_I2S_UP4"), DMI_MATCH(DMI_OEM_STRING, "AUDIO-MAX98373_ALC5682I_I2S_UP4"),
}, },
.driver_data = (void *)(SOF_RT5682_MCLK_EN | .driver_data = (void *)(SOF_RT5682_MCLK_EN |
SOF_RT5682_SSP_CODEC(0) | SOF_SSP_PORT_CODEC(0) |
SOF_RT5682_SSP_AMP(2) | SOF_SSP_PORT_AMP(2) |
SOF_RT5682_NUM_HDMIDEV(4)), SOF_NUM_IDISP_HDMI(4)),
}, },
{ {
.callback = sof_rt5682_quirk_cb, .callback = sof_rt5682_quirk_cb,
...@@ -128,9 +105,9 @@ static const struct dmi_system_id sof_rt5682_quirk_table[] = { ...@@ -128,9 +105,9 @@ static const struct dmi_system_id sof_rt5682_quirk_table[] = {
DMI_MATCH(DMI_OEM_STRING, "AUDIO-ADL_MAX98373_ALC5682I_I2S"), DMI_MATCH(DMI_OEM_STRING, "AUDIO-ADL_MAX98373_ALC5682I_I2S"),
}, },
.driver_data = (void *)(SOF_RT5682_MCLK_EN | .driver_data = (void *)(SOF_RT5682_MCLK_EN |
SOF_RT5682_SSP_CODEC(0) | SOF_SSP_PORT_CODEC(0) |
SOF_RT5682_SSP_AMP(2) | SOF_SSP_PORT_AMP(2) |
SOF_RT5682_NUM_HDMIDEV(4)), SOF_NUM_IDISP_HDMI(4)),
}, },
{ {
.callback = sof_rt5682_quirk_cb, .callback = sof_rt5682_quirk_cb,
...@@ -139,9 +116,9 @@ static const struct dmi_system_id sof_rt5682_quirk_table[] = { ...@@ -139,9 +116,9 @@ static const struct dmi_system_id sof_rt5682_quirk_table[] = {
DMI_MATCH(DMI_OEM_STRING, "AUDIO-MAX98390_ALC5682I_I2S"), DMI_MATCH(DMI_OEM_STRING, "AUDIO-MAX98390_ALC5682I_I2S"),
}, },
.driver_data = (void *)(SOF_RT5682_MCLK_EN | .driver_data = (void *)(SOF_RT5682_MCLK_EN |
SOF_RT5682_SSP_CODEC(0) | SOF_SSP_PORT_CODEC(0) |
SOF_RT5682_SSP_AMP(2) | SOF_SSP_PORT_AMP(2) |
SOF_RT5682_NUM_HDMIDEV(4)), SOF_NUM_IDISP_HDMI(4)),
}, },
{ {
.callback = sof_rt5682_quirk_cb, .callback = sof_rt5682_quirk_cb,
...@@ -150,9 +127,9 @@ static const struct dmi_system_id sof_rt5682_quirk_table[] = { ...@@ -150,9 +127,9 @@ static const struct dmi_system_id sof_rt5682_quirk_table[] = {
DMI_MATCH(DMI_OEM_STRING, "AUDIO-MAX98360_ALC5682I_I2S_AMP_SSP2"), DMI_MATCH(DMI_OEM_STRING, "AUDIO-MAX98360_ALC5682I_I2S_AMP_SSP2"),
}, },
.driver_data = (void *)(SOF_RT5682_MCLK_EN | .driver_data = (void *)(SOF_RT5682_MCLK_EN |
SOF_RT5682_SSP_CODEC(0) | SOF_SSP_PORT_CODEC(0) |
SOF_RT5682_SSP_AMP(2) | SOF_SSP_PORT_AMP(2) |
SOF_RT5682_NUM_HDMIDEV(4)), SOF_NUM_IDISP_HDMI(4)),
}, },
{ {
.callback = sof_rt5682_quirk_cb, .callback = sof_rt5682_quirk_cb,
...@@ -160,11 +137,10 @@ static const struct dmi_system_id sof_rt5682_quirk_table[] = { ...@@ -160,11 +137,10 @@ static const struct dmi_system_id sof_rt5682_quirk_table[] = {
DMI_MATCH(DMI_PRODUCT_FAMILY, "Google_Rex"), DMI_MATCH(DMI_PRODUCT_FAMILY, "Google_Rex"),
}, },
.driver_data = (void *)(SOF_RT5682_MCLK_EN | .driver_data = (void *)(SOF_RT5682_MCLK_EN |
SOF_RT5682_SSP_CODEC(2) | SOF_SSP_PORT_CODEC(2) |
SOF_RT5682_SSP_AMP(0) | SOF_SSP_PORT_AMP(0) |
SOF_RT5682_NUM_HDMIDEV(3) | SOF_SSP_PORT_BT_OFFLOAD(1) |
SOF_BT_OFFLOAD_SSP(1) | SOF_BT_OFFLOAD_PRESENT
SOF_SSP_BT_OFFLOAD_PRESENT
), ),
}, },
{} {}
...@@ -630,19 +606,29 @@ static int sof_audio_probe(struct platform_device *pdev) ...@@ -630,19 +606,29 @@ static int sof_audio_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 sof_card_private *ctx; struct sof_card_private *ctx;
bool is_legacy_cpu;
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_rt5682_quirk = (unsigned long)pdev->id_entry->driver_data; sof_rt5682_quirk = (unsigned long)pdev->id_entry->driver_data;
dmi_check_system(sof_rt5682_quirk_table); dmi_check_system(sof_rt5682_quirk_table);
ctx->codec_type = sof_ssp_detect_codec_type(&pdev->dev); if (soc_intel_is_byt() || soc_intel_is_cht()) {
ctx->amp_type = sof_ssp_detect_amp_type(&pdev->dev); is_legacy_cpu = true;
/* default quirk for legacy cpu */
sof_rt5682_quirk = SOF_RT5682_MCLK_EN |
SOF_RT5682_MCLK_BYTCHT_EN |
SOF_SSP_PORT_CODEC(2);
}
dev_dbg(&pdev->dev, "sof_rt5682_quirk = %lx\n", sof_rt5682_quirk);
/* initialize ctx with board quirk */
ctx = sof_intel_board_get_ctx(&pdev->dev, sof_rt5682_quirk);
if (!ctx)
return -ENOMEM;
if (ctx->codec_type == CODEC_RT5650) { if (ctx->codec_type == CODEC_RT5650) {
sof_audio_card_rt5682.name = devm_kstrdup(&pdev->dev, "rt5650", sof_audio_card_rt5682.name = devm_kstrdup(&pdev->dev, "rt5650",
...@@ -653,23 +639,12 @@ static int sof_audio_probe(struct platform_device *pdev) ...@@ -653,23 +639,12 @@ static int sof_audio_probe(struct platform_device *pdev)
ctx->amp_type = CODEC_RT5650; ctx->amp_type = CODEC_RT5650;
} }
if (soc_intel_is_byt() || soc_intel_is_cht()) { if (is_legacy_cpu) {
ctx->rt5682.is_legacy_cpu = true; ctx->rt5682.is_legacy_cpu = true;
ctx->dmic_be_num = 0; ctx->dmic_be_num = 0;
/* HDMI is not supported by SOF on Baytrail/CherryTrail */ /* HDMI is not supported by SOF on Baytrail/CherryTrail */
ctx->hdmi_num = 0; ctx->hdmi_num = 0;
/* default quirk for legacy cpu */
sof_rt5682_quirk = SOF_RT5682_MCLK_EN |
SOF_RT5682_MCLK_BYTCHT_EN |
SOF_RT5682_SSP_CODEC(2);
} else { } else {
ctx->dmic_be_num = 2;
ctx->hdmi_num = (sof_rt5682_quirk & SOF_RT5682_NUM_HDMIDEV_MASK) >>
SOF_RT5682_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;
} }
...@@ -694,23 +669,6 @@ static int sof_audio_probe(struct platform_device *pdev) ...@@ -694,23 +669,6 @@ static int sof_audio_probe(struct platform_device *pdev)
} }
} }
dev_dbg(&pdev->dev, "sof_rt5682_quirk = %lx\n", sof_rt5682_quirk);
/* port number/mask of peripherals attached to ssp interface */
ctx->ssp_mask_hdmi_in = (sof_rt5682_quirk & SOF_SSP_HDMI_CAPTURE_PRESENT_MASK) >>
SOF_NO_OF_HDMI_CAPTURE_SSP_SHIFT;
ctx->ssp_bt = (sof_rt5682_quirk & SOF_BT_OFFLOAD_SSP_MASK) >>
SOF_BT_OFFLOAD_SSP_SHIFT;
ctx->ssp_amp = (sof_rt5682_quirk & SOF_RT5682_SSP_AMP_MASK) >>
SOF_RT5682_SSP_AMP_SHIFT;
ctx->ssp_codec = sof_rt5682_quirk & SOF_RT5682_SSP_CODEC_MASK;
if (sof_rt5682_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_rt5682, ctx); ret = sof_card_dai_links_create(&pdev->dev, &sof_audio_card_rt5682, ctx);
if (ret) if (ret)
...@@ -733,11 +691,11 @@ static int sof_audio_probe(struct platform_device *pdev) ...@@ -733,11 +691,11 @@ static int sof_audio_probe(struct platform_device *pdev)
case CODEC_RT1015P: case CODEC_RT1015P:
sof_rt1015p_codec_conf(&sof_audio_card_rt5682); sof_rt1015p_codec_conf(&sof_audio_card_rt5682);
break; break;
case CODEC_NONE:
case CODEC_MAX98357A: case CODEC_MAX98357A:
case CODEC_MAX98360A: case CODEC_MAX98360A:
case CODEC_RT1019P: case CODEC_RT1019P:
case CODEC_RT5650: case CODEC_RT5650:
case CODEC_NONE:
/* no codec conf required */ /* no codec conf required */
break; break;
default: default:
...@@ -764,98 +722,93 @@ static const struct platform_device_id board_ids[] = { ...@@ -764,98 +722,93 @@ static const struct platform_device_id board_ids[] = {
.name = "sof_rt5682", .name = "sof_rt5682",
}, },
{ {
.name = "cml_rt1015_rt5682", .name = "cml_rt5682_def",
.driver_data = (kernel_ulong_t)(SOF_RT5682_MCLK_EN | .driver_data = (kernel_ulong_t)(SOF_RT5682_MCLK_EN |
SOF_RT5682_SSP_CODEC(0) | SOF_SSP_PORT_CODEC(0) |
SOF_RT5682_SSP_AMP(1)), SOF_SSP_PORT_AMP(1)),
}, },
{ {
.name = "jsl_rt5682_def", .name = "jsl_rt5682_def",
.driver_data = (kernel_ulong_t)(SOF_RT5682_MCLK_EN | .driver_data = (kernel_ulong_t)(SOF_RT5682_MCLK_EN |
SOF_RT5682_SSP_CODEC(0) | SOF_SSP_PORT_CODEC(0) |
SOF_RT5682_SSP_AMP(1)), SOF_SSP_PORT_AMP(1)),
}, },
{ {
.name = "tgl_rt5682_def", .name = "tgl_rt5682_def",
.driver_data = (kernel_ulong_t)(SOF_RT5682_MCLK_EN | .driver_data = (kernel_ulong_t)(SOF_RT5682_MCLK_EN |
SOF_RT5682_SSP_CODEC(0) | SOF_SSP_PORT_CODEC(0) |
SOF_RT5682_SSP_AMP(1) | SOF_SSP_PORT_AMP(1) |
SOF_RT5682_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 = "adl_rt5682_def", .name = "adl_rt5682_def",
.driver_data = (kernel_ulong_t)(SOF_RT5682_MCLK_EN | .driver_data = (kernel_ulong_t)(SOF_RT5682_MCLK_EN |
SOF_RT5682_SSP_CODEC(0) | SOF_SSP_PORT_CODEC(0) |
SOF_RT5682_SSP_AMP(1) | SOF_SSP_PORT_AMP(1) |
SOF_RT5682_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 = "adl_mx98357_rt5682", .name = "adl_mx98357_rt5682",
.driver_data = (kernel_ulong_t)(SOF_RT5682_MCLK_EN | .driver_data = (kernel_ulong_t)(SOF_RT5682_MCLK_EN |
SOF_RT5682_SSP_CODEC(0) | SOF_SSP_PORT_CODEC(0) |
SOF_RT5682_SSP_AMP(2) | SOF_SSP_PORT_AMP(2) |
SOF_RT5682_NUM_HDMIDEV(4)), SOF_NUM_IDISP_HDMI(4)),
}, },
{ {
.name = "adl_rt5682_c1_h02", .name = "adl_rt5682_c1_h02",
.driver_data = (kernel_ulong_t)(SOF_RT5682_MCLK_EN | .driver_data = (kernel_ulong_t)(SOF_RT5682_MCLK_EN |
SOF_RT5682_SSP_CODEC(1) | SOF_SSP_PORT_CODEC(1) |
SOF_RT5682_NUM_HDMIDEV(3) |
/* SSP 0 and SSP 2 are used for HDMI IN */ /* SSP 0 and SSP 2 are used for HDMI IN */
SOF_HDMI_CAPTURE_SSP_MASK(0x5)), SOF_SSP_MASK_HDMI_CAPTURE(0x5)),
}, },
{ {
.name = "rpl_mx98357_rt5682", .name = "rpl_mx98357_rt5682",
.driver_data = (kernel_ulong_t)(SOF_RT5682_MCLK_EN | .driver_data = (kernel_ulong_t)(SOF_RT5682_MCLK_EN |
SOF_RT5682_SSP_CODEC(0) | SOF_SSP_PORT_CODEC(0) |
SOF_RT5682_SSP_AMP(2) | SOF_SSP_PORT_AMP(2) |
SOF_RT5682_NUM_HDMIDEV(4)), SOF_NUM_IDISP_HDMI(4)),
}, },
{ {
.name = "rpl_rt5682_def", .name = "rpl_rt5682_def",
.driver_data = (kernel_ulong_t)(SOF_RT5682_MCLK_EN | .driver_data = (kernel_ulong_t)(SOF_RT5682_MCLK_EN |
SOF_RT5682_SSP_CODEC(0) | SOF_SSP_PORT_CODEC(0) |
SOF_RT5682_SSP_AMP(1) | SOF_SSP_PORT_AMP(1) |
SOF_RT5682_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_rt5682_c1_h02", .name = "rpl_rt5682_c1_h02",
.driver_data = (kernel_ulong_t)(SOF_RT5682_MCLK_EN | .driver_data = (kernel_ulong_t)(SOF_RT5682_MCLK_EN |
SOF_RT5682_SSP_CODEC(1) | SOF_SSP_PORT_CODEC(1) |
SOF_RT5682_NUM_HDMIDEV(3) |
/* SSP 0 and SSP 2 are used for HDMI IN */ /* SSP 0 and SSP 2 are used for HDMI IN */
SOF_HDMI_CAPTURE_SSP_MASK(0x5)), SOF_SSP_MASK_HDMI_CAPTURE(0x5)),
}, },
{ {
.name = "mtl_mx98357_rt5682", .name = "mtl_mx98357_rt5682",
.driver_data = (kernel_ulong_t)(SOF_RT5682_MCLK_EN | .driver_data = (kernel_ulong_t)(SOF_RT5682_MCLK_EN |
SOF_RT5682_SSP_CODEC(0) | SOF_SSP_PORT_CODEC(0) |
SOF_RT5682_SSP_AMP(1) | SOF_SSP_PORT_AMP(1) |
SOF_RT5682_NUM_HDMIDEV(3) | SOF_SSP_PORT_BT_OFFLOAD(2) |
SOF_BT_OFFLOAD_SSP(2) | SOF_BT_OFFLOAD_PRESENT),
SOF_SSP_BT_OFFLOAD_PRESENT),
}, },
{ {
.name = "mtl_mx98360_rt5682", .name = "mtl_mx98360_rt5682",
.driver_data = (kernel_ulong_t)(SOF_RT5682_MCLK_EN | .driver_data = (kernel_ulong_t)(SOF_RT5682_MCLK_EN |
SOF_RT5682_SSP_CODEC(0) | SOF_SSP_PORT_CODEC(0) |
SOF_RT5682_SSP_AMP(1) | SOF_SSP_PORT_AMP(1)),
SOF_RT5682_NUM_HDMIDEV(3)),
}, },
{ {
.name = "mtl_rt5682_def", .name = "mtl_rt5682_def",
.driver_data = (kernel_ulong_t)(SOF_RT5682_MCLK_EN | .driver_data = (kernel_ulong_t)(SOF_RT5682_MCLK_EN |
SOF_RT5682_SSP_CODEC(2) | SOF_SSP_PORT_CODEC(2) |
SOF_RT5682_SSP_AMP(0) | SOF_SSP_PORT_AMP(0) |
SOF_RT5682_NUM_HDMIDEV(3) | SOF_SSP_PORT_BT_OFFLOAD(1) |
SOF_BT_OFFLOAD_SSP(1) | SOF_BT_OFFLOAD_PRESENT),
SOF_SSP_BT_OFFLOAD_PRESENT),
}, },
{ } { }
}; };
...@@ -881,4 +834,3 @@ MODULE_LICENSE("GPL v2"); ...@@ -881,4 +834,3 @@ MODULE_LICENSE("GPL v2");
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_REALTEK_COMMON); MODULE_IMPORT_NS(SND_SOC_INTEL_SOF_REALTEK_COMMON);
MODULE_IMPORT_NS(SND_SOC_INTEL_SOF_SSP_COMMON);
...@@ -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