1212#include "sof-utils.h"
1313#include "ops.h"
1414
15- static void sof_set_transferred_bytes (struct sof_compr_stream * sstream ,
16- u64 host_pos , u64 buffer_size )
17- {
18- u64 prev_pos ;
19- unsigned int copied ;
20-
21- div64_u64_rem (sstream -> copied_total , buffer_size , & prev_pos );
22-
23- if (host_pos < prev_pos )
24- copied = (buffer_size - prev_pos ) + host_pos ;
25- else
26- copied = host_pos - prev_pos ;
27-
28- sstream -> copied_total += copied ;
29- }
30-
31- static void snd_sof_compr_fragment_elapsed_work (struct work_struct * work )
32- {
33- struct snd_sof_pcm_stream * sps =
34- container_of (work , struct snd_sof_pcm_stream ,
35- period_elapsed_work );
36-
37- snd_compr_fragment_elapsed (sps -> cstream );
38- }
39-
40- void snd_sof_compr_init_elapsed_work (struct work_struct * work )
41- {
42- INIT_WORK (work , snd_sof_compr_fragment_elapsed_work );
43- }
44-
45- /*
46- * sof compr fragment elapse, this could be called in irq thread context
47- */
48- void snd_sof_compr_fragment_elapsed (struct snd_compr_stream * cstream )
49- {
50- struct snd_soc_pcm_runtime * rtd ;
51- struct snd_compr_runtime * crtd ;
52- struct snd_soc_component * component ;
53- struct sof_compr_stream * sstream ;
54- struct snd_sof_pcm * spcm ;
55-
56- if (!cstream )
57- return ;
58-
59- rtd = cstream -> private_data ;
60- crtd = cstream -> runtime ;
61- sstream = crtd -> private_data ;
62- component = snd_soc_rtdcom_lookup (rtd , SOF_AUDIO_PCM_DRV_NAME );
63-
64- spcm = snd_sof_find_spcm_dai (component , rtd );
65- if (!spcm ) {
66- dev_err (component -> dev ,
67- "fragment elapsed called for unknown stream!\n" );
68- return ;
69- }
70-
71- sof_set_transferred_bytes (sstream , spcm -> stream [cstream -> direction ].posn .host_posn ,
72- crtd -> buffer_size );
73-
74- /* use the same workqueue-based solution as for PCM, cf. snd_sof_pcm_elapsed */
75- schedule_work (& spcm -> stream [cstream -> direction ].period_elapsed_work );
76- }
77-
78- static int create_page_table (struct snd_soc_component * component ,
79- struct snd_compr_stream * cstream ,
80- unsigned char * dma_area , size_t size )
81- {
82- struct snd_dma_buffer * dmab = cstream -> runtime -> dma_buffer_p ;
83- struct snd_soc_pcm_runtime * rtd = cstream -> private_data ;
84- int dir = cstream -> direction ;
85- struct snd_sof_pcm * spcm ;
86-
87- spcm = snd_sof_find_spcm_dai (component , rtd );
88- if (!spcm )
89- return - EINVAL ;
90-
91- return snd_sof_create_page_table (component -> dev , dmab ,
92- spcm -> stream [dir ].page_table .area , size );
93- }
94-
95- static int sof_compr_open (struct snd_soc_component * component ,
96- struct snd_compr_stream * cstream )
15+ static int sof_ipc3_compr_open (struct snd_soc_component * component ,
16+ struct snd_compr_stream * cstream )
9717{
9818 struct snd_soc_pcm_runtime * rtd = cstream -> private_data ;
9919 struct snd_compr_runtime * crtd = cstream -> runtime ;
@@ -128,8 +48,8 @@ static int sof_compr_open(struct snd_soc_component *component,
12848 return 0 ;
12949}
13050
131- static int sof_compr_free (struct snd_soc_component * component ,
132- struct snd_compr_stream * cstream )
51+ static int sof_ipc3_compr_free (struct snd_soc_component * component ,
52+ struct snd_compr_stream * cstream )
13353{
13454 struct snd_sof_dev * sdev = snd_soc_component_get_drvdata (component );
13555 struct sof_compr_stream * sstream = cstream -> runtime -> private_data ;
@@ -159,8 +79,9 @@ static int sof_compr_free(struct snd_soc_component *component,
15979 return ret ;
16080}
16181
162- static int sof_compr_set_params (struct snd_soc_component * component ,
163- struct snd_compr_stream * cstream , struct snd_compr_params * params )
82+ static int sof_ipc3_compr_set_params (struct snd_soc_component * component ,
83+ struct snd_compr_stream * cstream ,
84+ struct snd_compr_params * params )
16485{
16586 struct snd_sof_dev * sdev = snd_soc_component_get_drvdata (component );
16687 struct snd_soc_pcm_runtime * rtd = cstream -> private_data ;
@@ -213,7 +134,7 @@ static int sof_compr_set_params(struct snd_soc_component *component,
213134 if (ret < 0 )
214135 goto out ;
215136
216- ret = create_page_table (component , cstream , crtd -> dma_area , crtd -> dma_bytes );
137+ ret = snd_sof_compr_create_page_table (component , cstream , crtd -> dma_area , crtd -> dma_bytes );
217138 if (ret < 0 )
218139 goto out ;
219140
@@ -264,17 +185,18 @@ static int sof_compr_set_params(struct snd_soc_component *component,
264185 return ret ;
265186}
266187
267- static int sof_compr_get_params (struct snd_soc_component * component ,
268- struct snd_compr_stream * cstream , struct snd_codec * params )
188+ static int sof_ipc3_compr_get_params (struct snd_soc_component * component ,
189+ struct snd_compr_stream * cstream ,
190+ struct snd_codec * params )
269191{
270192 /* TODO: we don't query the supported codecs for now, if the
271193 * application asks for an unsupported codec the set_params() will fail.
272194 */
273195 return 0 ;
274196}
275197
276- static int sof_compr_trigger (struct snd_soc_component * component ,
277- struct snd_compr_stream * cstream , int cmd )
198+ static int sof_ipc3_compr_trigger (struct snd_soc_component * component ,
199+ struct snd_compr_stream * cstream , int cmd )
278200{
279201 struct snd_sof_dev * sdev = snd_soc_component_get_drvdata (component );
280202 struct snd_soc_pcm_runtime * rtd = cstream -> private_data ;
@@ -310,8 +232,8 @@ static int sof_compr_trigger(struct snd_soc_component *component,
310232 return sof_ipc_tx_message_no_reply (sdev -> ipc , & stream , sizeof (stream ));
311233}
312234
313- static int sof_compr_copy_playback (struct snd_compr_runtime * rtd ,
314- char __user * buf , size_t count )
235+ static int sof_ipc3_compr_copy_playback (struct snd_compr_runtime * rtd ,
236+ char __user * buf , size_t count )
315237{
316238 void * ptr ;
317239 unsigned int offset , n ;
@@ -331,8 +253,8 @@ static int sof_compr_copy_playback(struct snd_compr_runtime *rtd,
331253 return count - ret ;
332254}
333255
334- static int sof_compr_copy_capture (struct snd_compr_runtime * rtd ,
335- char __user * buf , size_t count )
256+ static int sof_ipc3_compr_copy_capture (struct snd_compr_runtime * rtd ,
257+ char __user * buf , size_t count )
336258{
337259 void * ptr ;
338260 unsigned int offset , n ;
@@ -352,24 +274,24 @@ static int sof_compr_copy_capture(struct snd_compr_runtime *rtd,
352274 return count - ret ;
353275}
354276
355- static int sof_compr_copy (struct snd_soc_component * component ,
356- struct snd_compr_stream * cstream ,
357- char __user * buf , size_t count )
277+ static int sof_ipc3_compr_copy (struct snd_soc_component * component ,
278+ struct snd_compr_stream * cstream ,
279+ char __user * buf , size_t count )
358280{
359281 struct snd_compr_runtime * rtd = cstream -> runtime ;
360282
361283 if (count > rtd -> buffer_size )
362284 count = rtd -> buffer_size ;
363285
364286 if (cstream -> direction == SND_COMPRESS_PLAYBACK )
365- return sof_compr_copy_playback (rtd , buf , count );
287+ return sof_ipc3_compr_copy_playback (rtd , buf , count );
366288 else
367- return sof_compr_copy_capture (rtd , buf , count );
289+ return sof_ipc3_compr_copy_capture (rtd , buf , count );
368290}
369291
370- static int sof_compr_pointer (struct snd_soc_component * component ,
371- struct snd_compr_stream * cstream ,
372- struct snd_compr_tstamp64 * tstamp )
292+ static int sof_ipc3_compr_pointer (struct snd_soc_component * component ,
293+ struct snd_compr_stream * cstream ,
294+ struct snd_compr_tstamp64 * tstamp )
373295{
374296 struct snd_sof_pcm * spcm ;
375297 struct snd_soc_pcm_runtime * rtd = cstream -> private_data ;
@@ -387,13 +309,12 @@ static int sof_compr_pointer(struct snd_soc_component *component,
387309 return 0 ;
388310}
389311
390- struct snd_compress_ops sof_compressed_ops = {
391- .open = sof_compr_open ,
392- .free = sof_compr_free ,
393- .set_params = sof_compr_set_params ,
394- .get_params = sof_compr_get_params ,
395- .trigger = sof_compr_trigger ,
396- .pointer = sof_compr_pointer ,
397- .copy = sof_compr_copy ,
312+ const struct snd_compress_ops sof_ipc3_compressed_ops = {
313+ .open = sof_ipc3_compr_open ,
314+ .free = sof_ipc3_compr_free ,
315+ .set_params = sof_ipc3_compr_set_params ,
316+ .get_params = sof_ipc3_compr_get_params ,
317+ .trigger = sof_ipc3_compr_trigger ,
318+ .pointer = sof_ipc3_compr_pointer ,
319+ .copy = sof_ipc3_compr_copy ,
398320};
399- EXPORT_SYMBOL (sof_compressed_ops );
0 commit comments