@@ -556,33 +556,6 @@ static int sof_pcm_new(struct snd_soc_component *component,
556556 return 0 ;
557557}
558558
559- static void ssp_dai_config_pcm_params_match (struct snd_sof_dev * sdev , const char * link_name ,
560- struct snd_pcm_hw_params * params )
561- {
562- struct sof_ipc_dai_config * config ;
563- struct snd_sof_dai * dai ;
564- int i ;
565-
566- /*
567- * Search for all matching DAIs as we can have both playback and capture DAI
568- * associated with the same link.
569- */
570- list_for_each_entry (dai , & sdev -> dai_list , list ) {
571- if (!dai -> name || strcmp (link_name , dai -> name ))
572- continue ;
573- for (i = 0 ; i < dai -> number_configs ; i ++ ) {
574- struct sof_dai_private_data * private = dai -> private ;
575-
576- config = & private -> dai_config [i ];
577- if (config -> ssp .fsync_rate == params_rate (params )) {
578- dev_dbg (sdev -> dev , "DAI config %d matches pcm hw params\n" , i );
579- dai -> current_config = i ;
580- break ;
581- }
582- }
583- }
584- }
585-
586559/* fixup the BE DAI link to match any values from topology */
587560int sof_pcm_dai_link_fixup (struct snd_soc_pcm_runtime * rtd , struct snd_pcm_hw_params * params )
588561{
@@ -596,8 +569,7 @@ int sof_pcm_dai_link_fixup(struct snd_soc_pcm_runtime *rtd, struct snd_pcm_hw_pa
596569 struct snd_sof_dai * dai =
597570 snd_sof_find_dai (component , (char * )rtd -> dai_link -> name );
598571 struct snd_sof_dev * sdev = snd_soc_component_get_drvdata (component );
599- struct sof_dai_private_data * private = dai -> private ;
600- struct snd_soc_dpcm * dpcm ;
572+ const struct sof_ipc_pcm_ops * pcm_ops = sdev -> ipc -> ops -> pcm ;
601573
602574 /* no topology exists for this BE, try a common configuration */
603575 if (!dai ) {
@@ -618,148 +590,8 @@ int sof_pcm_dai_link_fixup(struct snd_soc_pcm_runtime *rtd, struct snd_pcm_hw_pa
618590 return 0 ;
619591 }
620592
621- /* read format from topology */
622- snd_mask_none (fmt );
623-
624- switch (private -> comp_dai -> config .frame_fmt ) {
625- case SOF_IPC_FRAME_S16_LE :
626- snd_mask_set_format (fmt , SNDRV_PCM_FORMAT_S16_LE );
627- break ;
628- case SOF_IPC_FRAME_S24_4LE :
629- snd_mask_set_format (fmt , SNDRV_PCM_FORMAT_S24_LE );
630- break ;
631- case SOF_IPC_FRAME_S32_LE :
632- snd_mask_set_format (fmt , SNDRV_PCM_FORMAT_S32_LE );
633- break ;
634- default :
635- dev_err (component -> dev , "error: No available DAI format!\n" );
636- return - EINVAL ;
637- }
638-
639- /* read rate and channels from topology */
640- switch (private -> dai_config -> type ) {
641- case SOF_DAI_INTEL_SSP :
642- /* search for config to pcm params match, if not found use default */
643- ssp_dai_config_pcm_params_match (sdev , (char * )rtd -> dai_link -> name , params );
644-
645- rate -> min = private -> dai_config [dai -> current_config ].ssp .fsync_rate ;
646- rate -> max = private -> dai_config [dai -> current_config ].ssp .fsync_rate ;
647- channels -> min = private -> dai_config [dai -> current_config ].ssp .tdm_slots ;
648- channels -> max = private -> dai_config [dai -> current_config ].ssp .tdm_slots ;
649-
650- dev_dbg (component -> dev ,
651- "rate_min: %d rate_max: %d\n" , rate -> min , rate -> max );
652- dev_dbg (component -> dev ,
653- "channels_min: %d channels_max: %d\n" ,
654- channels -> min , channels -> max );
655-
656- break ;
657- case SOF_DAI_INTEL_DMIC :
658- /* DMIC only supports 16 or 32 bit formats */
659- if (private -> comp_dai -> config .frame_fmt == SOF_IPC_FRAME_S24_4LE ) {
660- dev_err (component -> dev ,
661- "error: invalid fmt %d for DAI type %d\n" ,
662- private -> comp_dai -> config .frame_fmt ,
663- private -> dai_config -> type );
664- }
665- break ;
666- case SOF_DAI_INTEL_HDA :
667- /*
668- * HDAudio does not follow the default trigger
669- * sequence due to firmware implementation
670- */
671- for_each_dpcm_fe (rtd , SNDRV_PCM_STREAM_PLAYBACK , dpcm ) {
672- struct snd_soc_pcm_runtime * fe = dpcm -> fe ;
673-
674- fe -> dai_link -> trigger [SNDRV_PCM_STREAM_PLAYBACK ] =
675- SND_SOC_DPCM_TRIGGER_POST ;
676- }
677- break ;
678- case SOF_DAI_INTEL_ALH :
679- /*
680- * Dai could run with different channel count compared with
681- * front end, so get dai channel count from topology
682- */
683- channels -> min = private -> dai_config -> alh .channels ;
684- channels -> max = private -> dai_config -> alh .channels ;
685- break ;
686- case SOF_DAI_IMX_ESAI :
687- rate -> min = private -> dai_config -> esai .fsync_rate ;
688- rate -> max = private -> dai_config -> esai .fsync_rate ;
689- channels -> min = private -> dai_config -> esai .tdm_slots ;
690- channels -> max = private -> dai_config -> esai .tdm_slots ;
691-
692- dev_dbg (component -> dev ,
693- "rate_min: %d rate_max: %d\n" , rate -> min , rate -> max );
694- dev_dbg (component -> dev ,
695- "channels_min: %d channels_max: %d\n" ,
696- channels -> min , channels -> max );
697- break ;
698- case SOF_DAI_MEDIATEK_AFE :
699- rate -> min = private -> dai_config -> afe .rate ;
700- rate -> max = private -> dai_config -> afe .rate ;
701- channels -> min = private -> dai_config -> afe .channels ;
702- channels -> max = private -> dai_config -> afe .channels ;
703-
704- dev_dbg (component -> dev ,
705- "rate_min: %d rate_max: %d\n" , rate -> min , rate -> max );
706- dev_dbg (component -> dev ,
707- "channels_min: %d channels_max: %d\n" ,
708- channels -> min , channels -> max );
709- break ;
710- case SOF_DAI_IMX_SAI :
711- rate -> min = private -> dai_config -> sai .fsync_rate ;
712- rate -> max = private -> dai_config -> sai .fsync_rate ;
713- channels -> min = private -> dai_config -> sai .tdm_slots ;
714- channels -> max = private -> dai_config -> sai .tdm_slots ;
715-
716- dev_dbg (component -> dev ,
717- "rate_min: %d rate_max: %d\n" , rate -> min , rate -> max );
718- dev_dbg (component -> dev ,
719- "channels_min: %d channels_max: %d\n" ,
720- channels -> min , channels -> max );
721- break ;
722- case SOF_DAI_AMD_BT :
723- rate -> min = private -> dai_config -> acpbt .fsync_rate ;
724- rate -> max = private -> dai_config -> acpbt .fsync_rate ;
725- channels -> min = private -> dai_config -> acpbt .tdm_slots ;
726- channels -> max = private -> dai_config -> acpbt .tdm_slots ;
727-
728- dev_dbg (component -> dev ,
729- "AMD_BT rate_min: %d rate_max: %d\n" , rate -> min , rate -> max );
730- dev_dbg (component -> dev ,
731- "AMD_BT channels_min: %d channels_max: %d\n" ,
732- channels -> min , channels -> max );
733- break ;
734- case SOF_DAI_AMD_SP :
735- rate -> min = private -> dai_config -> acpsp .fsync_rate ;
736- rate -> max = private -> dai_config -> acpsp .fsync_rate ;
737- channels -> min = private -> dai_config -> acpsp .tdm_slots ;
738- channels -> max = private -> dai_config -> acpsp .tdm_slots ;
739-
740- dev_dbg (component -> dev ,
741- "AMD_SP rate_min: %d rate_max: %d\n" , rate -> min , rate -> max );
742- dev_dbg (component -> dev ,
743- "AMD_SP channels_min: %d channels_max: %d\n" ,
744- channels -> min , channels -> max );
745- break ;
746- case SOF_DAI_AMD_DMIC :
747- rate -> min = private -> dai_config -> acpdmic .fsync_rate ;
748- rate -> max = private -> dai_config -> acpdmic .fsync_rate ;
749- channels -> min = private -> dai_config -> acpdmic .tdm_slots ;
750- channels -> max = private -> dai_config -> acpdmic .tdm_slots ;
751-
752- dev_dbg (component -> dev ,
753- "AMD_DMIC rate_min: %d rate_max: %d\n" , rate -> min , rate -> max );
754- dev_dbg (component -> dev ,
755- "AMD_DMIC channels_min: %d channels_max: %d\n" ,
756- channels -> min , channels -> max );
757- break ;
758- default :
759- dev_err (component -> dev , "error: invalid DAI type %d\n" ,
760- private -> dai_config -> type );
761- break ;
762- }
593+ if (pcm_ops -> dai_link_fixup )
594+ return pcm_ops -> dai_link_fixup (rtd , params );
763595
764596 return 0 ;
765597}
0 commit comments