Commit 9fadbf3f authored by Brent Lu's avatar Brent Lu Committed by Mark Brown

ASoC: Intel: sof_ssp_amp: simplify HDMI-In quirks

Use bit mask to handle SSP port number of HDMI-In devices to simplify
the code. No functional change in this patch.
Signed-off-by: default avatarBrent Lu <brent.lu@intel.com>
Reviewed-by: default avatarPierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Reviewed-by: default avatarBard Liao <yung-chuan.liao@linux.intel.com>
Reviewed-by: default avatarBalamurugan C <balamurugan.c@intel.com>
Signed-off-by: default avatarPeter Ujfalusi <peter.ujfalusi@linux.intel.com>
Link: https://lore.kernel.org/r/20231127152654.28204-22-peter.ujfalusi@linux.intel.comSigned-off-by: default avatarMark Brown <broonie@kernel.org>
parent dc3d7dcb
...@@ -27,21 +27,10 @@ ...@@ -27,21 +27,10 @@
#define SOF_AMPLIFIER_SSP_MASK (GENMASK(3, 0)) #define SOF_AMPLIFIER_SSP_MASK (GENMASK(3, 0))
/* HDMI capture*/ /* HDMI capture*/
#define SOF_SSP_HDMI_CAPTURE_PRESENT BIT(4) #define SOF_HDMI_CAPTURE_SSP_MASK_SHIFT 4
#define SOF_NO_OF_HDMI_CAPTURE_SSP_SHIFT 5 #define SOF_HDMI_CAPTURE_SSP_MASK_MASK (GENMASK(9, 4))
#define SOF_NO_OF_HDMI_CAPTURE_SSP_MASK (GENMASK(6, 5)) #define SOF_HDMI_CAPTURE_SSP_MASK(quirk) \
#define SOF_NO_OF_HDMI_CAPTURE_SSP(quirk) \ (((quirk) << SOF_HDMI_CAPTURE_SSP_MASK_SHIFT) & SOF_HDMI_CAPTURE_SSP_MASK_MASK)
(((quirk) << SOF_NO_OF_HDMI_CAPTURE_SSP_SHIFT) & SOF_NO_OF_HDMI_CAPTURE_SSP_MASK)
#define SOF_HDMI_CAPTURE_1_SSP_SHIFT 7
#define SOF_HDMI_CAPTURE_1_SSP_MASK (GENMASK(9, 7))
#define SOF_HDMI_CAPTURE_1_SSP(quirk) \
(((quirk) << SOF_HDMI_CAPTURE_1_SSP_SHIFT) & SOF_HDMI_CAPTURE_1_SSP_MASK)
#define SOF_HDMI_CAPTURE_2_SSP_SHIFT 10
#define SOF_HDMI_CAPTURE_2_SSP_MASK (GENMASK(12, 10))
#define SOF_HDMI_CAPTURE_2_SSP(quirk) \
(((quirk) << SOF_HDMI_CAPTURE_2_SSP_SHIFT) & SOF_HDMI_CAPTURE_2_SSP_MASK)
/* HDMI playback */ /* HDMI playback */
#define SOF_HDMI_PLAYBACK_PRESENT BIT(13) #define SOF_HDMI_PLAYBACK_PRESENT BIT(13)
...@@ -108,6 +97,7 @@ sof_card_dai_links_create(struct device *dev, enum sof_ssp_codec amp_type, ...@@ -108,6 +97,7 @@ sof_card_dai_links_create(struct device *dev, enum sof_ssp_codec amp_type,
int ret; int ret;
bool fixed_be = false; bool fixed_be = false;
int be_id; int be_id;
unsigned long ssp_mask_hdmi_in;
links = devm_kcalloc(dev, sof_ssp_amp_card.num_links, links = devm_kcalloc(dev, sof_ssp_amp_card.num_links,
sizeof(struct snd_soc_dai_link), GFP_KERNEL); sizeof(struct snd_soc_dai_link), GFP_KERNEL);
...@@ -117,20 +107,17 @@ sof_card_dai_links_create(struct device *dev, enum sof_ssp_codec amp_type, ...@@ -117,20 +107,17 @@ sof_card_dai_links_create(struct device *dev, enum sof_ssp_codec amp_type,
return NULL; return NULL;
/* HDMI-In SSP */ /* HDMI-In SSP */
if (sof_ssp_amp_quirk & SOF_SSP_HDMI_CAPTURE_PRESENT) { ssp_mask_hdmi_in = (sof_ssp_amp_quirk & SOF_HDMI_CAPTURE_SSP_MASK_MASK) >>
int num_of_hdmi_ssp = (sof_ssp_amp_quirk & SOF_NO_OF_HDMI_CAPTURE_SSP_MASK) >> SOF_HDMI_CAPTURE_SSP_MASK_SHIFT;
SOF_NO_OF_HDMI_CAPTURE_SSP_SHIFT;
if (ssp_mask_hdmi_in) {
int port = 0;
/* the topology supports HDMI-IN uses fixed BE ID for DAI links */ /* the topology supports HDMI-IN uses fixed BE ID for DAI links */
fixed_be = true; fixed_be = true;
be_id = HDMI_IN_BE_ID; be_id = HDMI_IN_BE_ID;
for (i = 1; i <= num_of_hdmi_ssp; i++) { for_each_set_bit(port, &ssp_mask_hdmi_in, 32) {
int port = (i == 1 ? (sof_ssp_amp_quirk & SOF_HDMI_CAPTURE_1_SSP_MASK) >>
SOF_HDMI_CAPTURE_1_SSP_SHIFT :
(sof_ssp_amp_quirk & SOF_HDMI_CAPTURE_2_SSP_MASK) >>
SOF_HDMI_CAPTURE_2_SSP_SHIFT);
links[id].cpus = &cpus[id]; links[id].cpus = &cpus[id];
links[id].cpus->dai_name = devm_kasprintf(dev, GFP_KERNEL, links[id].cpus->dai_name = devm_kasprintf(dev, GFP_KERNEL,
"SSP%d Pin", port); "SSP%d Pin", port);
...@@ -231,6 +218,7 @@ static int sof_ssp_amp_probe(struct platform_device *pdev) ...@@ -231,6 +218,7 @@ static int sof_ssp_amp_probe(struct platform_device *pdev)
struct snd_soc_dai_link *dai_links; struct snd_soc_dai_link *dai_links;
struct sof_card_private *ctx; struct sof_card_private *ctx;
int ret; int ret;
unsigned long ssp_mask_hdmi_in;
ctx = devm_kzalloc(&pdev->dev, sizeof(*ctx), GFP_KERNEL); ctx = devm_kzalloc(&pdev->dev, sizeof(*ctx), GFP_KERNEL);
if (!ctx) if (!ctx)
...@@ -246,7 +234,10 @@ static int sof_ssp_amp_probe(struct platform_device *pdev) ...@@ -246,7 +234,10 @@ static int sof_ssp_amp_probe(struct platform_device *pdev)
else else
ctx->dmic_be_num = 0; ctx->dmic_be_num = 0;
/* port number of peripherals attached to ssp interface */ /* port number/mask of peripherals attached to ssp interface */
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) >> ctx->ssp_bt = (sof_ssp_amp_quirk & SOF_BT_OFFLOAD_SSP_MASK) >>
SOF_BT_OFFLOAD_SSP_SHIFT; SOF_BT_OFFLOAD_SSP_SHIFT;
...@@ -258,9 +249,8 @@ static int sof_ssp_amp_probe(struct platform_device *pdev) ...@@ -258,9 +249,8 @@ static int sof_ssp_amp_probe(struct platform_device *pdev)
if (ctx->amp_type != CODEC_NONE) if (ctx->amp_type != CODEC_NONE)
sof_ssp_amp_card.num_links++; sof_ssp_amp_card.num_links++;
if (sof_ssp_amp_quirk & SOF_SSP_HDMI_CAPTURE_PRESENT) if (ssp_mask_hdmi_in)
sof_ssp_amp_card.num_links += (sof_ssp_amp_quirk & SOF_NO_OF_HDMI_CAPTURE_SSP_MASK) >> sof_ssp_amp_card.num_links += hweight32(ssp_mask_hdmi_in);
SOF_NO_OF_HDMI_CAPTURE_SSP_SHIFT;
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) >> ctx->hdmi_num = (sof_ssp_amp_quirk & SOF_NO_OF_HDMI_PLAYBACK_MASK) >>
...@@ -325,10 +315,8 @@ static const struct platform_device_id board_ids[] = { ...@@ -325,10 +315,8 @@ 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_AMPLIFIER_SSP(2) |
SOF_NO_OF_HDMI_CAPTURE_SSP(2) | SOF_HDMI_CAPTURE_SSP_MASK(0x22)),
SOF_HDMI_CAPTURE_1_SSP(1) | /* SSP 1 and SSP 5 are used for HDMI IN */
SOF_HDMI_CAPTURE_2_SSP(5) |
SOF_SSP_HDMI_CAPTURE_PRESENT),
}, },
{ {
.name = "adl_cs35l41", .name = "adl_cs35l41",
...@@ -340,28 +328,22 @@ static const struct platform_device_id board_ids[] = { ...@@ -340,28 +328,22 @@ static const struct platform_device_id board_ids[] = {
}, },
{ {
.name = "adl_lt6911_hdmi_ssp", .name = "adl_lt6911_hdmi_ssp",
.driver_data = (kernel_ulong_t)(SOF_NO_OF_HDMI_CAPTURE_SSP(2) | .driver_data = (kernel_ulong_t)(SOF_HDMI_CAPTURE_SSP_MASK(0x5) |
SOF_HDMI_CAPTURE_1_SSP(0) | /* SSP 0 and SSP 2 are used for HDMI IN */
SOF_HDMI_CAPTURE_2_SSP(2) |
SOF_SSP_HDMI_CAPTURE_PRESENT |
SOF_NO_OF_HDMI_PLAYBACK(3) | 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_NO_OF_HDMI_CAPTURE_SSP(2) | .driver_data = (kernel_ulong_t)(SOF_HDMI_CAPTURE_SSP_MASK(0x5) |
SOF_HDMI_CAPTURE_1_SSP(0) | /* SSP 0 and SSP 2 are used for HDMI IN */
SOF_HDMI_CAPTURE_2_SSP(2) |
SOF_SSP_HDMI_CAPTURE_PRESENT |
SOF_NO_OF_HDMI_PLAYBACK(3) | 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_NO_OF_HDMI_CAPTURE_SSP(2) | .driver_data = (kernel_ulong_t)(SOF_HDMI_CAPTURE_SSP_MASK(0x5) |
SOF_HDMI_CAPTURE_1_SSP(0) | /* SSP 0 and SSP 2 are used for HDMI IN */
SOF_HDMI_CAPTURE_2_SSP(2) |
SOF_SSP_HDMI_CAPTURE_PRESENT |
SOF_NO_OF_HDMI_PLAYBACK(3) | SOF_NO_OF_HDMI_PLAYBACK(3) |
SOF_HDMI_PLAYBACK_PRESENT), SOF_HDMI_PLAYBACK_PRESENT),
}, },
......
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