diff --git a/sound/soc/sof/intel/hda-dai-ops.c b/sound/soc/sof/intel/hda-dai-ops.c index 437e46bc3f7d..0ac9b4323032 100644 --- a/sound/soc/sof/intel/hda-dai-ops.c +++ b/sound/soc/sof/intel/hda-dai-ops.c @@ -242,14 +242,14 @@ static unsigned int generic_calc_stream_format(struct snd_sof_dev *sdev, unsigned int format_val; u32 ch_mask = 0; int num_channels; - int j; + int codec_dai_id; /* * if the multiple dais are handled by the same dailink, we may need to update the * stream channel count - the params are modified in soc-pcm based on the codec_ch_maps info */ - for_each_rtd_codec_dais(rtd, j, codec_dai) - ch_mask |= rtd->dai_link->codec_ch_maps[j].ch_mask; + for_each_rtd_codec_dais(rtd, codec_dai_id, codec_dai) + ch_mask |= rtd->dai_link->codec_ch_maps[codec_dai_id].ch_mask; num_channels = hweight_long(ch_mask); if (num_channels != params_channels(params)) diff --git a/sound/soc/sof/intel/hda-dai.c b/sound/soc/sof/intel/hda-dai.c index 06df8a8166b2..e0e19cce1d37 100644 --- a/sound/soc/sof/intel/hda-dai.c +++ b/sound/soc/sof/intel/hda-dai.c @@ -440,9 +440,9 @@ int sdw_hda_dai_hw_params(struct snd_pcm_substream *substream, struct snd_soc_dai *codec_dai; struct snd_soc_dai *dai; struct snd_sof_dev *sdev; + int cpu_dai_id; int ch_mask; int ret; - int i; int j; ret = non_hda_dai_hw_params(substream, params, cpu_dai); @@ -463,14 +463,14 @@ int sdw_hda_dai_hw_params(struct snd_pcm_substream *substream, * of aggregated devices, we need to define the channel mask for each sublink * by reconstructing the split done in soc-pcm.c */ - for_each_rtd_cpu_dais(rtd, i, dai) { + for_each_rtd_cpu_dais(rtd, cpu_dai_id, dai) { if (dai == cpu_dai) break; } ch_mask = 0; for_each_rtd_codec_dais(rtd, j, codec_dai) { - if (rtd->dai_link->codec_ch_maps[j].connected_cpu_id == i) + if (rtd->dai_link->codec_ch_maps[j].connected_cpu_id == cpu_dai_id) ch_mask |= rtd->dai_link->codec_ch_maps[j].ch_mask; } diff --git a/sound/soc/sof/intel/hda.c b/sound/soc/sof/intel/hda.c index 924ebbf3c9cc..7ac7cf5e2efa 100644 --- a/sound/soc/sof/intel/hda.c +++ b/sound/soc/sof/intel/hda.c @@ -54,26 +54,33 @@ static void hda_get_interfaces(struct snd_sof_dev *sdev, u32 *interface_mask) case SOF_INTEL_TANGIER: case SOF_INTEL_BAYTRAIL: case SOF_INTEL_BROADWELL: - interface_mask[0] = BIT(SOF_DAI_INTEL_SSP); + interface_mask[SOF_DAI_FEATURE_DSP_ONLY] = BIT(SOF_DAI_INTEL_SSP); break; case SOF_INTEL_CAVS_1_5: case SOF_INTEL_CAVS_1_5_PLUS: - interface_mask[0] = BIT(SOF_DAI_INTEL_SSP) | BIT(SOF_DAI_INTEL_DMIC) | - BIT(SOF_DAI_INTEL_HDA); - interface_mask[1] = BIT(SOF_DAI_INTEL_HDA); + interface_mask[SOF_DAI_FEATURE_DSP_ONLY] = + BIT(SOF_DAI_INTEL_SSP) | BIT(SOF_DAI_INTEL_DMIC) | BIT(SOF_DAI_INTEL_HDA); + interface_mask[SOF_DAI_FEATURE_DSPLESS] = BIT(SOF_DAI_INTEL_HDA); break; case SOF_INTEL_CAVS_1_8: case SOF_INTEL_CAVS_2_0: case SOF_INTEL_CAVS_2_5: case SOF_INTEL_ACE_1_0: - interface_mask[0] = BIT(SOF_DAI_INTEL_SSP) | BIT(SOF_DAI_INTEL_DMIC) | - BIT(SOF_DAI_INTEL_HDA) | BIT(SOF_DAI_INTEL_ALH); - interface_mask[1] = BIT(SOF_DAI_INTEL_HDA); + interface_mask[SOF_DAI_FEATURE_DSP_ONLY] = + BIT(SOF_DAI_INTEL_SSP) | BIT(SOF_DAI_INTEL_DMIC) | + BIT(SOF_DAI_INTEL_HDA) | BIT(SOF_DAI_INTEL_ALH); + interface_mask[SOF_DAI_FEATURE_DSPLESS] = BIT(SOF_DAI_INTEL_HDA); break; case SOF_INTEL_ACE_2_0: - interface_mask[0] = BIT(SOF_DAI_INTEL_SSP) | BIT(SOF_DAI_INTEL_DMIC) | - BIT(SOF_DAI_INTEL_HDA) | BIT(SOF_DAI_INTEL_ALH); - interface_mask[1] = interface_mask[0]; /* all interfaces accessible without DSP */ + interface_mask[SOF_DAI_FEATURE_DSP_ONLY] = + BIT(SOF_DAI_INTEL_SSP) | BIT(SOF_DAI_INTEL_DMIC) | + BIT(SOF_DAI_INTEL_HDA) | BIT(SOF_DAI_INTEL_ALH); + /* all interfaces accessible without DSP */ + interface_mask[SOF_DAI_FEATURE_DSPLESS] = + interface_mask[SOF_DAI_FEATURE_DSP_ONLY]; + /* all interfaces accessible with CHAIN_DMA */ + interface_mask[SOF_DAI_FEATURE_CHAIN_DMA] = + interface_mask[SOF_DAI_FEATURE_DSP_ONLY]; break; default: break; @@ -82,20 +89,20 @@ static void hda_get_interfaces(struct snd_sof_dev *sdev, u32 *interface_mask) static u32 hda_get_interface_mask(struct snd_sof_dev *sdev) { - u32 interface_mask[2] = { 0 }; + u32 interface_mask[SOF_DAI_FEATURE_NUM] = { 0 }; hda_get_interfaces(sdev, interface_mask); return interface_mask[sdev->dspless_mode_selected]; } -bool hda_is_dai_supported(struct snd_sof_dev *sdev, u32 dai_type, bool dspless_mode) +bool hda_is_dai_supported(struct snd_sof_dev *sdev, u32 dai_type, u8 feature) { - u32 interface_mask[2] = { 0 }; + u32 interface_mask[SOF_DAI_FEATURE_NUM] = { 0 }; hda_get_interfaces(sdev, interface_mask); - return interface_mask[dspless_mode] & BIT(dai_type); + return interface_mask[feature] & BIT(dai_type); } #if IS_ENABLED(CONFIG_SND_SOC_SOF_INTEL_SOUNDWIRE) diff --git a/sound/soc/sof/intel/hda.h b/sound/soc/sof/intel/hda.h index bfc085153bdc..95b2b5f4c952 100644 --- a/sound/soc/sof/intel/hda.h +++ b/sound/soc/sof/intel/hda.h @@ -576,7 +576,7 @@ struct sof_intel_hda_stream { /* * DAI support */ -bool hda_is_dai_supported(struct snd_sof_dev *sdev, u32 dai_type, bool dspless_mode); +bool hda_is_dai_supported(struct snd_sof_dev *sdev, u32 dai_type, u8 feature); /* * DSP Core services. diff --git a/sound/soc/sof/ipc4-topology.c b/sound/soc/sof/ipc4-topology.c index 123c8468ed42..bf8ac0f62699 100644 --- a/sound/soc/sof/ipc4-topology.c +++ b/sound/soc/sof/ipc4-topology.c @@ -532,9 +532,8 @@ static int sof_ipc4_widget_setup_comp_dai(struct snd_sof_widget *swidget) pipe_widget = swidget->spipe->pipe_widget; pipeline = pipe_widget->private; - /* chain_dma is available for all DAIs on dspless platforms */ if (pipeline->use_chain_dma && - !snd_sof_is_dai_supported(sdev, ipc4_copier->dai_type, true)) { + !snd_sof_is_dai_supported(sdev, ipc4_copier->dai_type, SOF_DAI_FEATURE_CHAIN_DMA)) { dev_err(scomp->dev, "Bad DAI type '%d', Chain DMA is not supported\n", ipc4_copier->dai_type); ret = -ENODEV; diff --git a/sound/soc/sof/ops.h b/sound/soc/sof/ops.h index fa6c0b9a9df5..ad2f4066c3a6 100644 --- a/sound/soc/sof/ops.h +++ b/sound/soc/sof/ops.h @@ -556,10 +556,11 @@ snd_sof_set_mach_params(struct snd_soc_acpi_mach *mach, } static inline bool -snd_sof_is_dai_supported(struct snd_sof_dev *sdev, u32 dai_type, bool dspless_mode) +snd_sof_is_dai_supported(struct snd_sof_dev *sdev, u32 dai_type, u8 feature) { if (sof_ops(sdev) && sof_ops(sdev)->is_dai_supported) - return sof_ops(sdev)->is_dai_supported(sdev, dai_type, dspless_mode); + return sof_ops(sdev)->is_dai_supported(sdev, dai_type, feature); + return false; } diff --git a/sound/soc/sof/sof-priv.h b/sound/soc/sof/sof-priv.h index 9b7cd2fd0377..1e76ac23c075 100644 --- a/sound/soc/sof/sof-priv.h +++ b/sound/soc/sof/sof-priv.h @@ -157,6 +157,14 @@ struct sof_firmware { u32 payload_offset; }; +enum sof_dai_feature { + SOF_DAI_FEATURE_DSP_ONLY, /* access from DSP only */ + SOF_DAI_FEATURE_DSPLESS, /* access from host only */ + SOF_DAI_FEATURE_CHAIN_DMA,/* access from DSP with CHAIN_DMA mode */ + + SOF_DAI_FEATURE_NUM +}; + /* * SOF DSP HW abstraction operations. * Used to abstract DSP HW architecture and any IO busses between host CPU @@ -337,7 +345,7 @@ struct snd_sof_dsp_ops { int num_drv; bool (*is_dai_supported)(struct snd_sof_dev *sdev, u32 dai_type, - bool dspless_mode); /* optional */ + u8 feature); /* optional */ /* ALSA HW info flags, will be stored in snd_pcm_runtime.hw.info */ u32 hw_info;