@@ -151,6 +151,51 @@ int hda_dsp_pcm_hw_params(struct snd_sof_dev *sdev,
151151}
152152EXPORT_SYMBOL_NS (hda_dsp_pcm_hw_params , "SND_SOC_SOF_INTEL_HDA_COMMON" );
153153
154+ int hda_dsp_compr_hw_params (struct snd_sof_dev * sdev ,
155+ struct snd_compr_stream * cstream ,
156+ struct snd_compr_params * params ,
157+ struct snd_sof_platform_stream_params * platform_params )
158+ {
159+ struct hdac_stream * hstream = cstream -> runtime -> private_data ;
160+ struct hdac_ext_stream * hext_stream = stream_to_hdac_ext_stream (hstream );
161+ struct sof_intel_hda_dev * hda = sdev -> pdata -> hw_pdata ;
162+ struct snd_dma_buffer * dmab ;
163+ u32 bits , rate ;
164+ int bps ;
165+ int ret ;
166+
167+ hstream -> cstream = cstream ;
168+ dmab = cstream -> runtime -> dma_buffer_p ;
169+
170+ /* compr params do not store bit depth, default to S32_LE */
171+ bps = snd_pcm_format_physical_width (params -> codec .format );
172+ if (bps < 0 )
173+ return bps ;
174+ bits = hda_dsp_get_bits (sdev , bps );
175+ rate = hda_dsp_get_mult_div (sdev , params -> codec .sample_rate );
176+
177+ hstream -> format_val = rate | bits | (params -> codec .ch_out - 1 );
178+ hstream -> bufsize = cstream -> runtime -> buffer_size ;
179+ hstream -> period_bytes = cstream -> runtime -> fragment_size ;
180+ hstream -> no_period_wakeup = false;
181+
182+ /* params is not used so pass NULL */
183+ dmab = cstream -> runtime -> dma_buffer_p ;
184+ ret = hda_dsp_stream_hw_params (sdev , hext_stream , dmab , NULL );
185+ if (ret < 0 ) {
186+ dev_err (sdev -> dev , "%s: hdac prepare failed: %d\n" , __func__ , ret );
187+ return ret ;
188+ }
189+
190+ if (hda )
191+ platform_params -> no_ipc_position = hda -> no_ipc_position ;
192+
193+ platform_params -> stream_tag = hstream -> stream_tag ;
194+
195+ return 0 ;
196+ }
197+ EXPORT_SYMBOL_NS (hda_dsp_compr_hw_params , "SND_SOC_SOF_INTEL_HDA_COMMON" );
198+
154199/* update SPIB register with appl position */
155200int hda_dsp_pcm_ack (struct snd_sof_dev * sdev , struct snd_pcm_substream * substream )
156201{
@@ -184,6 +229,16 @@ int hda_dsp_pcm_trigger(struct snd_sof_dev *sdev,
184229}
185230EXPORT_SYMBOL_NS (hda_dsp_pcm_trigger , "SND_SOC_SOF_INTEL_HDA_COMMON" );
186231
232+ int hda_dsp_compr_trigger (struct snd_sof_dev * sdev ,
233+ struct snd_compr_stream * cstream , int cmd )
234+ {
235+ struct hdac_stream * hstream = cstream -> runtime -> private_data ;
236+ struct hdac_ext_stream * hext_stream = stream_to_hdac_ext_stream (hstream );
237+
238+ return hda_dsp_stream_trigger (sdev , hext_stream , cmd );
239+ }
240+ EXPORT_SYMBOL_NS (hda_dsp_compr_trigger , "SND_SOC_SOF_INTEL_HDA_COMMON" );
241+
187242snd_pcm_uframes_t hda_dsp_pcm_pointer (struct snd_sof_dev * sdev ,
188243 struct snd_pcm_substream * substream )
189244{
@@ -216,6 +271,18 @@ snd_pcm_uframes_t hda_dsp_pcm_pointer(struct snd_sof_dev *sdev,
216271}
217272EXPORT_SYMBOL_NS (hda_dsp_pcm_pointer , "SND_SOC_SOF_INTEL_HDA_COMMON" );
218273
274+ int hda_dsp_compr_pointer (struct snd_sof_dev * sdev , struct snd_compr_stream * cstream ,
275+ struct snd_compr_tstamp64 * tstamp )
276+ {
277+ struct hdac_stream * hstream = cstream -> runtime -> private_data ;
278+
279+ /* hstream->curr_pos is updated when we receive the ioc */
280+ tstamp -> copied_total += hstream -> curr_pos ;
281+
282+ return 0 ;
283+ }
284+ EXPORT_SYMBOL_NS (hda_dsp_compr_pointer , "SND_SOC_SOF_INTEL_HDA_COMMON" );
285+
219286int hda_dsp_pcm_open (struct snd_sof_dev * sdev ,
220287 struct snd_pcm_substream * substream )
221288{
@@ -332,6 +399,41 @@ int hda_dsp_pcm_open(struct snd_sof_dev *sdev,
332399}
333400EXPORT_SYMBOL_NS (hda_dsp_pcm_open , "SND_SOC_SOF_INTEL_HDA_COMMON" );
334401
402+ int hda_dsp_compr_open (struct snd_sof_dev * sdev , struct snd_compr_stream * cstream )
403+ {
404+ struct snd_soc_pcm_runtime * rtd = cstream -> private_data ;
405+ struct snd_soc_component * scomp = sdev -> component ;
406+ struct hdac_ext_stream * dsp_stream ;
407+ struct snd_sof_pcm * spcm ;
408+ int direction = cstream -> direction ;
409+
410+ spcm = snd_sof_find_spcm_dai (scomp , rtd );
411+ if (!spcm ) {
412+ dev_err (sdev -> dev , "%s: can't find PCM with DAI ID %d\n" ,
413+ __func__ , rtd -> dai_link -> id );
414+ return - EINVAL ;
415+ }
416+
417+ dsp_stream = hda_dsp_stream_get (sdev , direction , 0 );
418+ if (!dsp_stream ) {
419+ dev_err (sdev -> dev , "%s: no stream available\n" , __func__ );
420+ return - ENODEV ;
421+ }
422+
423+ /* binding compr stream to hda stream */
424+ cstream -> runtime -> private_data = & dsp_stream -> hstream ;
425+
426+ /*
427+ * Reset the llp cache values (they are used for LLP compensation in
428+ * case the counter is not reset)
429+ */
430+ dsp_stream -> pplcllpl = 0 ;
431+ dsp_stream -> pplcllpu = 0 ;
432+
433+ return 0 ;
434+ }
435+ EXPORT_SYMBOL_NS (hda_dsp_compr_open , "SND_SOC_SOF_INTEL_HDA_COMMON" );
436+
335437int hda_dsp_pcm_close (struct snd_sof_dev * sdev ,
336438 struct snd_pcm_substream * substream )
337439{
@@ -351,3 +453,20 @@ int hda_dsp_pcm_close(struct snd_sof_dev *sdev,
351453 return 0 ;
352454}
353455EXPORT_SYMBOL_NS (hda_dsp_pcm_close , "SND_SOC_SOF_INTEL_HDA_COMMON" );
456+
457+ int hda_dsp_compr_close (struct snd_sof_dev * sdev , struct snd_compr_stream * cstream )
458+ {
459+ struct hdac_stream * hstream = cstream -> runtime -> private_data ;
460+ int direction = cstream -> direction ;
461+ int ret ;
462+
463+ ret = hda_dsp_stream_put (sdev , direction , hstream -> stream_tag );
464+ if (ret )
465+ return - ENODEV ;
466+
467+ /* unbinding compress stream to hda stream */
468+ hstream -> cstream = NULL ;
469+ cstream -> runtime -> private_data = NULL ;
470+ return 0 ;
471+ }
472+ EXPORT_SYMBOL_NS (hda_dsp_compr_close , "SND_SOC_SOF_INTEL_HDA_COMMON" );
0 commit comments