• Kuninori Morimoto's avatar
    ASoC: soc-pcm: fixup snd_pcm_limit_hw_rates() timing · dd5abc78
    Kuninori Morimoto authored
    soc-pcm has snd_pcm_limit_hw_rates() which determine rate_min/rate_max.
    It updates runtime->hw.rate_min/max (A) based on hw->rates (B).
    
    	int snd_pcm_limit_hw_rates(...)
    	{
    		int i;
    		for (...) {
    (B)			if (runtime->hw.rates & (1 << i)) {
    (A)				runtime->hw.rate_min = ...
    				break;
    			}
    		}
    		for (...) {
    (B)			if (runtime->hw.rates & (1 << i)) {
    (A)				runtime->hw.rate_max = ...
    				break;
    			}
    		}
    		return 0;
    	}
    
    This means, setup order is
    
    	1) set hw->rates
    	2) call snd_pcm_limit_hw_rates()
    	3) update hw->rate_min/max
    
    soc_pcm_init_runtime_hw() is calling it in good order
    
    	static void soc_pcm_init_runtime_hw(xxx)
    	{
    		...
    1)		hw->rates = snd_pcm_rate_mask_intersect(...);
    
    2)		snd_pcm_limit_hw_rates(...);
    
    3)		hw->rate_min = max(...);
    		hw->rate_min = max(...);
    		hw->rate_max = min_not_zero(...);
    		hw->rate_max = min_not_zero(...);
    	}
    
    But, dpcm_fe_dai_startup() is not.
    
    	static int dpcm_fe_dai_startup(xxx)
    	{
    		...
    1) 3)		dpcm_set_fe_runtime(...);
    2)		snd_pcm_limit_hw_rates(...);
    		...
    	}
    
    More detail of dpcm_set_fe_runtime() is
    
    	static void dpcm_set_fe_runtime()
    	{
    		...
    		for_each_rtd_cpu_dais(rtd, i, cpu_dai) {
    			...
    
    3) 1)			dpcm_init_runtime_hw(...);
    		}
    		...
    3) 1)		dpcm_runtime_merge_rate(...);
    	}
    
    This patch fixup these into
    
    	static void dpcm_set_fe_runtime()
    	{
    		...
    		for_each_rtd_cpu_dais(rtd, i, cpu_dai) {
    			...
    
    1) 2) 3)		dpcm_init_runtime_hw(...);
    		}
    		...
    1) 2) 3)	dpcm_runtime_merge_rate(...);
    	}
    
    	static int dpcm_fe_dai_startup(xxx)
    	{
    		...
    		dpcm_set_fe_runtime(...);
    -		snd_pcm_limit_hw_rates(...);
    		...
    	}
    
    Link: https://lore.kernel.org/r/87k15l7ewd.wl-kuninori.morimoto.gx@renesas.comSigned-off-by: default avatarKuninori Morimoto <kuninori.morimoto.gx@renesas.com>
    Link: https://lore.kernel.org/r/8735ytaig8.wl-kuninori.morimoto.gx@renesas.comSigned-off-by: default avatarMark Brown <broonie@kernel.org>
    dd5abc78
soc-pcm.c 78.2 KB