@@ -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,22 @@ 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+ snd_pcm_uframes_t pos ;
279+
280+ /* hstream->curr_pos is updated when we receive the ioc */
281+ tstamp -> copied_total += hstream -> curr_pos ;
282+
283+ pos = hda_dsp_stream_get_position (hstream , cstream -> direction , true);
284+ tstamp -> byte_offset = do_div (pos , cstream -> runtime -> buffer_size );
285+
286+ return 0 ;
287+ }
288+ EXPORT_SYMBOL_NS (hda_dsp_compr_pointer , "SND_SOC_SOF_INTEL_HDA_COMMON" );
289+
219290int hda_dsp_pcm_open (struct snd_sof_dev * sdev ,
220291 struct snd_pcm_substream * substream )
221292{
@@ -332,6 +403,41 @@ int hda_dsp_pcm_open(struct snd_sof_dev *sdev,
332403}
333404EXPORT_SYMBOL_NS (hda_dsp_pcm_open , "SND_SOC_SOF_INTEL_HDA_COMMON" );
334405
406+ int hda_dsp_compr_open (struct snd_sof_dev * sdev , struct snd_compr_stream * cstream )
407+ {
408+ struct snd_soc_pcm_runtime * rtd = cstream -> private_data ;
409+ struct snd_soc_component * scomp = sdev -> component ;
410+ struct hdac_ext_stream * dsp_stream ;
411+ struct snd_sof_pcm * spcm ;
412+ int direction = cstream -> direction ;
413+
414+ spcm = snd_sof_find_spcm_dai (scomp , rtd );
415+ if (!spcm ) {
416+ dev_err (sdev -> dev , "%s: can't find PCM with DAI ID %d\n" ,
417+ __func__ , rtd -> dai_link -> id );
418+ return - EINVAL ;
419+ }
420+
421+ dsp_stream = hda_dsp_stream_get (sdev , direction , 0 );
422+ if (!dsp_stream ) {
423+ dev_err (sdev -> dev , "%s: no stream available\n" , __func__ );
424+ return - ENODEV ;
425+ }
426+
427+ /* binding compr stream to hda stream */
428+ cstream -> runtime -> private_data = & dsp_stream -> hstream ;
429+
430+ /*
431+ * Reset the llp cache values (they are used for LLP compensation in
432+ * case the counter is not reset)
433+ */
434+ dsp_stream -> pplcllpl = 0 ;
435+ dsp_stream -> pplcllpu = 0 ;
436+
437+ return 0 ;
438+ }
439+ EXPORT_SYMBOL_NS (hda_dsp_compr_open , "SND_SOC_SOF_INTEL_HDA_COMMON" );
440+
335441int hda_dsp_pcm_close (struct snd_sof_dev * sdev ,
336442 struct snd_pcm_substream * substream )
337443{
@@ -351,3 +457,20 @@ int hda_dsp_pcm_close(struct snd_sof_dev *sdev,
351457 return 0 ;
352458}
353459EXPORT_SYMBOL_NS (hda_dsp_pcm_close , "SND_SOC_SOF_INTEL_HDA_COMMON" );
460+
461+ int hda_dsp_compr_close (struct snd_sof_dev * sdev , struct snd_compr_stream * cstream )
462+ {
463+ struct hdac_stream * hstream = cstream -> runtime -> private_data ;
464+ int direction = cstream -> direction ;
465+ int ret ;
466+
467+ ret = hda_dsp_stream_put (sdev , direction , hstream -> stream_tag );
468+ if (ret )
469+ return - ENODEV ;
470+
471+ /* unbinding compress stream to hda stream */
472+ hstream -> cstream = NULL ;
473+ cstream -> runtime -> private_data = NULL ;
474+ return 0 ;
475+ }
476+ EXPORT_SYMBOL_NS (hda_dsp_compr_close , "SND_SOC_SOF_INTEL_HDA_COMMON" );
0 commit comments