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
@@ -265,8 +186,9 @@ static int sof_compr_set_params(struct snd_soc_component *component,
265186 return ret ;
266187}
267188
268- static int sof_compr_get_params (struct snd_soc_component * component ,
269- struct snd_compr_stream * cstream , struct snd_codec * params )
189+ static int sof_ipc3_compr_get_params (struct snd_soc_component * component ,
190+ struct snd_compr_stream * cstream ,
191+ struct snd_codec * params )
270192{
271193 struct sof_compr_stream * sstream = cstream -> runtime -> private_data ;
272194
@@ -275,8 +197,8 @@ static int sof_compr_get_params(struct snd_soc_component *component,
275197 return 0 ;
276198}
277199
278- static int sof_compr_trigger (struct snd_soc_component * component ,
279- struct snd_compr_stream * cstream , int cmd )
200+ static int sof_ipc3_compr_trigger (struct snd_soc_component * component ,
201+ struct snd_compr_stream * cstream , int cmd )
280202{
281203 struct snd_sof_dev * sdev = snd_soc_component_get_drvdata (component );
282204 struct snd_soc_pcm_runtime * rtd = cstream -> private_data ;
@@ -312,8 +234,8 @@ static int sof_compr_trigger(struct snd_soc_component *component,
312234 return sof_ipc_tx_message_no_reply (sdev -> ipc , & stream , sizeof (stream ));
313235}
314236
315- static int sof_compr_copy_playback (struct snd_compr_runtime * rtd ,
316- char __user * buf , size_t count )
237+ static int sof_ipc3_compr_copy_playback (struct snd_compr_runtime * rtd ,
238+ char __user * buf , size_t count )
317239{
318240 void * ptr ;
319241 unsigned int offset , n ;
@@ -333,8 +255,8 @@ static int sof_compr_copy_playback(struct snd_compr_runtime *rtd,
333255 return count - ret ;
334256}
335257
336- static int sof_compr_copy_capture (struct snd_compr_runtime * rtd ,
337- char __user * buf , size_t count )
258+ static int sof_ipc3_compr_copy_capture (struct snd_compr_runtime * rtd ,
259+ char __user * buf , size_t count )
338260{
339261 void * ptr ;
340262 unsigned int offset , n ;
@@ -354,24 +276,24 @@ static int sof_compr_copy_capture(struct snd_compr_runtime *rtd,
354276 return count - ret ;
355277}
356278
357- static int sof_compr_copy (struct snd_soc_component * component ,
358- struct snd_compr_stream * cstream ,
359- char __user * buf , size_t count )
279+ static int sof_ipc3_compr_copy (struct snd_soc_component * component ,
280+ struct snd_compr_stream * cstream ,
281+ char __user * buf , size_t count )
360282{
361283 struct snd_compr_runtime * rtd = cstream -> runtime ;
362284
363285 if (count > rtd -> buffer_size )
364286 count = rtd -> buffer_size ;
365287
366288 if (cstream -> direction == SND_COMPRESS_PLAYBACK )
367- return sof_compr_copy_playback (rtd , buf , count );
289+ return sof_ipc3_compr_copy_playback (rtd , buf , count );
368290 else
369- return sof_compr_copy_capture (rtd , buf , count );
291+ return sof_ipc3_compr_copy_capture (rtd , buf , count );
370292}
371293
372- static int sof_compr_pointer (struct snd_soc_component * component ,
373- struct snd_compr_stream * cstream ,
374- struct snd_compr_tstamp64 * tstamp )
294+ static int sof_ipc3_compr_pointer (struct snd_soc_component * component ,
295+ struct snd_compr_stream * cstream ,
296+ struct snd_compr_tstamp64 * tstamp )
375297{
376298 struct snd_sof_pcm * spcm ;
377299 struct snd_soc_pcm_runtime * rtd = cstream -> private_data ;
@@ -392,13 +314,12 @@ static int sof_compr_pointer(struct snd_soc_component *component,
392314 return 0 ;
393315}
394316
395- struct snd_compress_ops sof_compressed_ops = {
396- .open = sof_compr_open ,
397- .free = sof_compr_free ,
398- .set_params = sof_compr_set_params ,
399- .get_params = sof_compr_get_params ,
400- .trigger = sof_compr_trigger ,
401- .pointer = sof_compr_pointer ,
402- .copy = sof_compr_copy ,
317+ const struct snd_compress_ops sof_ipc3_compressed_ops = {
318+ .open = sof_ipc3_compr_open ,
319+ .free = sof_ipc3_compr_free ,
320+ .set_params = sof_ipc3_compr_set_params ,
321+ .get_params = sof_ipc3_compr_get_params ,
322+ .trigger = sof_ipc3_compr_trigger ,
323+ .pointer = sof_ipc3_compr_pointer ,
324+ .copy = sof_ipc3_compr_copy ,
403325};
404- EXPORT_SYMBOL (sof_compressed_ops );
0 commit comments