ASoC: Intel: sof_nau8825: use common module for sof_card_private initialization

Use intel_board module to initialize sof_card_private structure.

Reviewed-by: Bard Liao <yung-chuan.liao@linux.intel.com>
Signed-off-by: Brent Lu <brent.lu@intel.com>
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Link: https://msgid.link/r/20240325221059.206042-10-pierre-louis.bossart@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
This commit is contained in:
Brent Lu 2024-03-25 17:10:47 -05:00 committed by Mark Brown
parent 96258c3348
commit bfa8c0088f
No known key found for this signature in database
GPG Key ID: 24D68B725D5487D0

View File

@ -24,27 +24,8 @@
#include "sof_realtek_common.h"
#include "sof_maxim_common.h"
#include "sof_nuvoton_common.h"
#include "sof_ssp_common.h"
#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 unsigned long sof_nau8825_quirk = SOF_SSP_PORT_CODEC(0);
static struct snd_soc_jack_pin jack_pins[] = {
{
@ -264,41 +245,19 @@ static int sof_audio_probe(struct platform_device *pdev)
struct sof_card_private *ctx;
int ret;
ctx = devm_kzalloc(&pdev->dev, sizeof(*ctx), GFP_KERNEL);
if (!ctx)
return -ENOMEM;
if (pdev->id_entry && 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);
/* default number of DMIC DAI's */
ctx->dmic_be_num = 2;
ctx->hdmi_num = (sof_nau8825_quirk & SOF_NAU8825_NUM_HDMIDEV_MASK) >>
SOF_NAU8825_NUM_HDMIDEV_SHIFT;
/* default number of HDMI DAI's */
if (!ctx->hdmi_num)
ctx->hdmi_num = 3;
/* initialize ctx with board quirk */
ctx = sof_intel_board_get_ctx(&pdev->dev, sof_nau8825_quirk);
if (!ctx)
return -ENOMEM;
if (mach->mach_params.codec_mask & IDISP_CODEC_MASK)
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 */
ret = sof_card_dai_links_create(&pdev->dev, &sof_audio_card_nau8825, ctx);
if (ret)
@ -340,33 +299,33 @@ static int sof_audio_probe(struct platform_device *pdev)
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),
.driver_data = (kernel_ulong_t)(SOF_SSP_PORT_CODEC(0) |
SOF_NUM_IDISP_HDMI(4) |
SOF_SSP_PORT_BT_OFFLOAD(2) |
SOF_BT_OFFLOAD_PRESENT),
},
{
.name = "adl_rt1019p_8825",
.driver_data = (kernel_ulong_t)(SOF_NAU8825_SSP_CODEC(0) |
SOF_NAU8825_SSP_AMP(2) |
SOF_NAU8825_NUM_HDMIDEV(4)),
.driver_data = (kernel_ulong_t)(SOF_SSP_PORT_CODEC(0) |
SOF_SSP_PORT_AMP(2) |
SOF_NUM_IDISP_HDMI(4)),
},
{
.name = "adl_nau8825_def",
.driver_data = (kernel_ulong_t)(SOF_NAU8825_SSP_CODEC(0) |
SOF_NAU8825_SSP_AMP(1) |
SOF_NAU8825_NUM_HDMIDEV(4) |
SOF_BT_OFFLOAD_SSP(2) |
SOF_SSP_BT_OFFLOAD_PRESENT),
.driver_data = (kernel_ulong_t)(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 = "rpl_nau8825_def",
.driver_data = (kernel_ulong_t)(SOF_NAU8825_SSP_CODEC(0) |
SOF_NAU8825_SSP_AMP(1) |
SOF_NAU8825_NUM_HDMIDEV(4) |
SOF_BT_OFFLOAD_SSP(2) |
SOF_SSP_BT_OFFLOAD_PRESENT),
.driver_data = (kernel_ulong_t)(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),
},
{ }
};
@ -392,4 +351,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_NUVOTON_COMMON);
MODULE_IMPORT_NS(SND_SOC_INTEL_SOF_REALTEK_COMMON);
MODULE_IMPORT_NS(SND_SOC_INTEL_SOF_SSP_COMMON);