@@ -82,29 +82,6 @@ void snd_sof_pcm_period_elapsed(struct snd_pcm_substream *substream)
8282}
8383EXPORT_SYMBOL (snd_sof_pcm_period_elapsed );
8484
85- int sof_pcm_dsp_pcm_free (struct snd_pcm_substream * substream , struct snd_sof_dev * sdev ,
86- struct snd_sof_pcm * spcm )
87- {
88- struct sof_ipc_stream stream ;
89- struct sof_ipc_reply reply ;
90- int ret ;
91-
92- if (!spcm -> prepared [substream -> stream ])
93- return 0 ;
94-
95- stream .hdr .size = sizeof (stream );
96- stream .hdr .cmd = SOF_IPC_GLB_STREAM_MSG | SOF_IPC_STREAM_PCM_FREE ;
97- stream .comp_id = spcm -> stream [substream -> stream ].comp_id ;
98-
99- /* send IPC to the DSP */
100- ret = sof_ipc_tx_message (sdev -> ipc , stream .hdr .cmd , & stream ,
101- sizeof (stream ), & reply , sizeof (reply ));
102- if (!ret )
103- spcm -> prepared [substream -> stream ] = false;
104-
105- return ret ;
106- }
107-
10885int sof_pcm_setup_connected_widgets (struct snd_sof_dev * sdev , struct snd_soc_pcm_runtime * rtd ,
10986 struct snd_sof_pcm * spcm , int dir )
11087{
@@ -145,6 +122,7 @@ static int sof_pcm_hw_params(struct snd_soc_component *component,
145122 struct snd_soc_pcm_runtime * rtd = asoc_substream_to_rtd (substream );
146123 struct snd_pcm_runtime * runtime = substream -> runtime ;
147124 struct snd_sof_dev * sdev = snd_soc_component_get_drvdata (component );
125+ const struct sof_ipc_pcm_ops * pcm_ops = sdev -> ipc -> ops -> pcm ;
148126 struct snd_sof_platform_stream_params platform_params = { 0 };
149127 struct sof_ipc_fw_version * v = & sdev -> fw_ready .version ;
150128 struct snd_sof_pcm * spcm ;
@@ -164,9 +142,13 @@ static int sof_pcm_hw_params(struct snd_soc_component *component,
164142 * Handle repeated calls to hw_params() without free_pcm() in
165143 * between. At least ALSA OSS emulation depends on this.
166144 */
167- ret = sof_pcm_dsp_pcm_free (substream , sdev , spcm );
168- if (ret < 0 )
169- return ret ;
145+ if (pcm_ops -> hw_free && spcm -> prepared [substream -> stream ]) {
146+ ret = pcm_ops -> hw_free (component , substream );
147+ if (ret < 0 )
148+ return ret ;
149+
150+ spcm -> prepared [substream -> stream ] = false;
151+ }
170152
171153 dev_dbg (component -> dev , "pcm: hw params stream %d dir %d\n" ,
172154 spcm -> pcm .pcm_id , substream -> stream );
@@ -289,6 +271,7 @@ static int sof_pcm_hw_free(struct snd_soc_component *component,
289271{
290272 struct snd_soc_pcm_runtime * rtd = asoc_substream_to_rtd (substream );
291273 struct snd_sof_dev * sdev = snd_soc_component_get_drvdata (component );
274+ const struct sof_ipc_pcm_ops * pcm_ops = sdev -> ipc -> ops -> pcm ;
292275 struct snd_sof_pcm * spcm ;
293276 int ret , err = 0 ;
294277
@@ -304,10 +287,13 @@ static int sof_pcm_hw_free(struct snd_soc_component *component,
304287 spcm -> pcm .pcm_id , substream -> stream );
305288
306289 /* free PCM in the DSP */
307- ret = sof_pcm_dsp_pcm_free (substream , sdev , spcm );
308- if (ret < 0 )
309- err = ret ;
290+ if (pcm_ops -> hw_free && spcm -> prepared [substream -> stream ]) {
291+ ret = pcm_ops -> hw_free (component , substream );
292+ if (ret < 0 )
293+ err = ret ;
310294
295+ spcm -> prepared [substream -> stream ] = false;
296+ }
311297
312298 /* stop DMA */
313299 ret = snd_sof_pcm_platform_hw_free (sdev , substream );
0 commit comments