@@ -151,6 +151,61 @@ 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+ /* Use correct format based on the used codec */
171+ switch (params -> codec .id ) {
172+ case SND_AUDIOCODEC_PCM :
173+ bps = snd_pcm_format_physical_width (params -> codec .format );
174+ break ;
175+ case SND_AUDIOCODEC_VORBIS :
176+ bps = snd_pcm_format_physical_width (SNDRV_PCM_FORMAT_S16_LE );
177+ break ;
178+ default :
179+ bps = snd_pcm_format_physical_width (SNDRV_PCM_FORMAT_S32_LE );
180+ }
181+
182+ if (bps < 0 )
183+ return bps ;
184+ bits = hda_dsp_get_bits (sdev , bps );
185+ rate = hda_dsp_get_mult_div (sdev , params -> codec .sample_rate );
186+
187+ hstream -> format_val = rate | bits | (params -> codec .ch_out - 1 );
188+ hstream -> bufsize = cstream -> runtime -> buffer_size ;
189+ hstream -> period_bytes = cstream -> runtime -> fragment_size ;
190+ hstream -> no_period_wakeup = false;
191+
192+ /* params is not used so pass NULL */
193+ dmab = cstream -> runtime -> dma_buffer_p ;
194+ ret = hda_dsp_stream_hw_params (sdev , hext_stream , dmab , NULL );
195+ if (ret < 0 ) {
196+ dev_err (sdev -> dev , "%s: hdac prepare failed: %d\n" , __func__ , ret );
197+ return ret ;
198+ }
199+
200+ if (hda )
201+ platform_params -> no_ipc_position = hda -> no_ipc_position ;
202+
203+ platform_params -> stream_tag = hstream -> stream_tag ;
204+
205+ return 0 ;
206+ }
207+ EXPORT_SYMBOL_NS (hda_dsp_compr_hw_params , "SND_SOC_SOF_INTEL_HDA_COMMON" );
208+
154209/* update SPIB register with appl position */
155210int hda_dsp_pcm_ack (struct snd_sof_dev * sdev , struct snd_pcm_substream * substream )
156211{
@@ -184,6 +239,16 @@ int hda_dsp_pcm_trigger(struct snd_sof_dev *sdev,
184239}
185240EXPORT_SYMBOL_NS (hda_dsp_pcm_trigger , "SND_SOC_SOF_INTEL_HDA_COMMON" );
186241
242+ int hda_dsp_compr_trigger (struct snd_sof_dev * sdev ,
243+ struct snd_compr_stream * cstream , int cmd )
244+ {
245+ struct hdac_stream * hstream = cstream -> runtime -> private_data ;
246+ struct hdac_ext_stream * hext_stream = stream_to_hdac_ext_stream (hstream );
247+
248+ return hda_dsp_stream_trigger (sdev , hext_stream , cmd );
249+ }
250+ EXPORT_SYMBOL_NS (hda_dsp_compr_trigger , "SND_SOC_SOF_INTEL_HDA_COMMON" );
251+
187252snd_pcm_uframes_t hda_dsp_pcm_pointer (struct snd_sof_dev * sdev ,
188253 struct snd_pcm_substream * substream )
189254{
@@ -216,6 +281,20 @@ snd_pcm_uframes_t hda_dsp_pcm_pointer(struct snd_sof_dev *sdev,
216281}
217282EXPORT_SYMBOL_NS (hda_dsp_pcm_pointer , "SND_SOC_SOF_INTEL_HDA_COMMON" );
218283
284+ int hda_dsp_compr_pointer (struct snd_sof_dev * sdev , struct snd_compr_stream * cstream ,
285+ struct snd_compr_tstamp64 * tstamp )
286+ {
287+ struct hdac_stream * hstream = cstream -> runtime -> private_data ;
288+
289+ /* hstream->curr_pos is updated when we receive the ioc */
290+ tstamp -> copied_total += hstream -> curr_pos ;
291+
292+ tstamp -> byte_offset = hda_dsp_stream_get_position (hstream , cstream -> direction , true);
293+
294+ return 0 ;
295+ }
296+ EXPORT_SYMBOL_NS (hda_dsp_compr_pointer , "SND_SOC_SOF_INTEL_HDA_COMMON" );
297+
219298int hda_dsp_pcm_open (struct snd_sof_dev * sdev ,
220299 struct snd_pcm_substream * substream )
221300{
@@ -332,6 +411,41 @@ int hda_dsp_pcm_open(struct snd_sof_dev *sdev,
332411}
333412EXPORT_SYMBOL_NS (hda_dsp_pcm_open , "SND_SOC_SOF_INTEL_HDA_COMMON" );
334413
414+ int hda_dsp_compr_open (struct snd_sof_dev * sdev , struct snd_compr_stream * cstream )
415+ {
416+ struct snd_soc_pcm_runtime * rtd = cstream -> private_data ;
417+ struct snd_soc_component * scomp = sdev -> component ;
418+ struct hdac_ext_stream * dsp_stream ;
419+ struct snd_sof_pcm * spcm ;
420+ int direction = cstream -> direction ;
421+
422+ spcm = snd_sof_find_spcm_dai (scomp , rtd );
423+ if (!spcm ) {
424+ dev_err (sdev -> dev , "%s: can't find PCM with DAI ID %d\n" ,
425+ __func__ , rtd -> dai_link -> id );
426+ return - EINVAL ;
427+ }
428+
429+ dsp_stream = hda_dsp_stream_get (sdev , direction , 0 );
430+ if (!dsp_stream ) {
431+ dev_err (sdev -> dev , "%s: no stream available\n" , __func__ );
432+ return - ENODEV ;
433+ }
434+
435+ /* binding compr stream to hda stream */
436+ cstream -> runtime -> private_data = & dsp_stream -> hstream ;
437+
438+ /*
439+ * Reset the llp cache values (they are used for LLP compensation in
440+ * case the counter is not reset)
441+ */
442+ dsp_stream -> pplcllpl = 0 ;
443+ dsp_stream -> pplcllpu = 0 ;
444+
445+ return 0 ;
446+ }
447+ EXPORT_SYMBOL_NS (hda_dsp_compr_open , "SND_SOC_SOF_INTEL_HDA_COMMON" );
448+
335449int hda_dsp_pcm_close (struct snd_sof_dev * sdev ,
336450 struct snd_pcm_substream * substream )
337451{
@@ -351,3 +465,20 @@ int hda_dsp_pcm_close(struct snd_sof_dev *sdev,
351465 return 0 ;
352466}
353467EXPORT_SYMBOL_NS (hda_dsp_pcm_close , "SND_SOC_SOF_INTEL_HDA_COMMON" );
468+
469+ int hda_dsp_compr_close (struct snd_sof_dev * sdev , struct snd_compr_stream * cstream )
470+ {
471+ struct hdac_stream * hstream = cstream -> runtime -> private_data ;
472+ int direction = cstream -> direction ;
473+ int ret ;
474+
475+ ret = hda_dsp_stream_put (sdev , direction , hstream -> stream_tag );
476+ if (ret )
477+ return - ENODEV ;
478+
479+ /* unbinding compress stream to hda stream */
480+ hstream -> cstream = NULL ;
481+ cstream -> runtime -> private_data = NULL ;
482+ return 0 ;
483+ }
484+ EXPORT_SYMBOL_NS (hda_dsp_compr_close , "SND_SOC_SOF_INTEL_HDA_COMMON" );
0 commit comments