22
22
#include <sound/sof/xtensa.h>
23
23
#include "../../ops.h"
24
24
#include "../../sof-of-dev.h"
25
- #include "../../sof-audio.h"
26
25
#include "../adsp_helper.h"
27
26
#include "../mtk-adsp-common.h"
28
27
#include "mt8186.h"
@@ -38,53 +37,9 @@ static int mt8186_get_window_offset(struct snd_sof_dev *sdev, u32 id)
38
37
return MBOX_OFFSET ;
39
38
}
40
39
41
- static int mt8186_send_msg (struct snd_sof_dev * sdev ,
42
- struct snd_sof_ipc_msg * msg )
43
- {
44
- struct adsp_priv * priv = sdev -> pdata -> hw_pdata ;
45
-
46
- sof_mailbox_write (sdev , sdev -> host_box .offset , msg -> msg_data ,
47
- msg -> msg_size );
48
-
49
- return mtk_adsp_ipc_send (priv -> dsp_ipc , MTK_ADSP_IPC_REQ , MTK_ADSP_IPC_OP_REQ );
50
- }
51
-
52
- static void mt8186_dsp_handle_reply (struct mtk_adsp_ipc * ipc )
53
- {
54
- struct adsp_priv * priv = mtk_adsp_ipc_get_data (ipc );
55
- unsigned long flags ;
56
-
57
- spin_lock_irqsave (& priv -> sdev -> ipc_lock , flags );
58
- snd_sof_ipc_process_reply (priv -> sdev , 0 );
59
- spin_unlock_irqrestore (& priv -> sdev -> ipc_lock , flags );
60
- }
61
-
62
- static void mt8186_dsp_handle_request (struct mtk_adsp_ipc * ipc )
63
- {
64
- struct adsp_priv * priv = mtk_adsp_ipc_get_data (ipc );
65
- u32 p ; /* panic code */
66
- int ret ;
67
-
68
- /* Read the message from the debug box. */
69
- sof_mailbox_read (priv -> sdev , priv -> sdev -> debug_box .offset + 4 ,
70
- & p , sizeof (p ));
71
-
72
- /* Check to see if the message is a panic code 0x0dead*** */
73
- if ((p & SOF_IPC_PANIC_MAGIC_MASK ) == SOF_IPC_PANIC_MAGIC ) {
74
- snd_sof_dsp_panic (priv -> sdev , p , true);
75
- } else {
76
- snd_sof_ipc_msgs_rx (priv -> sdev );
77
-
78
- /* tell DSP cmd is done */
79
- ret = mtk_adsp_ipc_send (priv -> dsp_ipc , MTK_ADSP_IPC_RSP , MTK_ADSP_IPC_OP_RSP );
80
- if (ret )
81
- dev_err (priv -> dev , "request send ipc failed" );
82
- }
83
- }
84
-
85
40
static const struct mtk_adsp_ipc_ops dsp_ops = {
86
- .handle_reply = mt8186_dsp_handle_reply ,
87
- .handle_request = mt8186_dsp_handle_request ,
41
+ .handle_reply = mtk_adsp_handle_reply ,
42
+ .handle_request = mtk_adsp_handle_request ,
88
43
};
89
44
90
45
static int platform_parse_resource (struct platform_device * pdev , void * data )
@@ -381,54 +336,6 @@ static int mt8186_dsp_resume(struct snd_sof_dev *sdev)
381
336
return ret ;
382
337
}
383
338
384
- /* on mt8186 there is 1 to 1 match between type and BAR idx */
385
- static int mt8186_get_bar_index (struct snd_sof_dev * sdev , u32 type )
386
- {
387
- return type ;
388
- }
389
-
390
- static int mt8186_pcm_hw_params (struct snd_sof_dev * sdev ,
391
- struct snd_pcm_substream * substream ,
392
- struct snd_pcm_hw_params * params ,
393
- struct snd_sof_platform_stream_params * platform_params )
394
- {
395
- platform_params -> cont_update_posn = 1 ;
396
-
397
- return 0 ;
398
- }
399
-
400
- static snd_pcm_uframes_t mt8186_pcm_pointer (struct snd_sof_dev * sdev ,
401
- struct snd_pcm_substream * substream )
402
- {
403
- int ret ;
404
- snd_pcm_uframes_t pos ;
405
- struct snd_sof_pcm * spcm ;
406
- struct sof_ipc_stream_posn posn ;
407
- struct snd_sof_pcm_stream * stream ;
408
- struct snd_soc_component * scomp = sdev -> component ;
409
- struct snd_soc_pcm_runtime * rtd = snd_soc_substream_to_rtd (substream );
410
-
411
- spcm = snd_sof_find_spcm_dai (scomp , rtd );
412
- if (!spcm ) {
413
- dev_warn_ratelimited (sdev -> dev , "warn: can't find PCM with DAI ID %d\n" ,
414
- rtd -> dai_link -> id );
415
- return 0 ;
416
- }
417
-
418
- stream = & spcm -> stream [substream -> stream ];
419
- ret = snd_sof_ipc_msg_data (sdev , stream , & posn , sizeof (posn ));
420
- if (ret < 0 ) {
421
- dev_warn (sdev -> dev , "failed to read stream position: %d\n" , ret );
422
- return 0 ;
423
- }
424
-
425
- memcpy (& stream -> posn , & posn , sizeof (posn ));
426
- pos = spcm -> stream [substream -> stream ].posn .host_posn ;
427
- pos = bytes_to_frames (substream -> runtime , pos );
428
-
429
- return pos ;
430
- }
431
-
432
339
static void mt8186_adsp_dump (struct snd_sof_dev * sdev , u32 flags )
433
340
{
434
341
u32 dbg_pc , dbg_data , dbg_inst , dbg_ls0stat , dbg_status , faultinfo ;
@@ -505,19 +412,19 @@ static const struct snd_sof_dsp_ops sof_mt8186_ops = {
505
412
.read64 = sof_io_read64 ,
506
413
507
414
/* ipc */
508
- .send_msg = mt8186_send_msg ,
415
+ .send_msg = mtk_adsp_send_msg ,
509
416
.get_mailbox_offset = mt8186_get_mailbox_offset ,
510
417
.get_window_offset = mt8186_get_window_offset ,
511
418
.ipc_msg_data = sof_ipc_msg_data ,
512
419
.set_stream_data_offset = sof_set_stream_data_offset ,
513
420
514
421
/* misc */
515
- .get_bar_index = mt8186_get_bar_index ,
422
+ .get_bar_index = mtk_adsp_get_bar_index ,
516
423
517
424
/* stream callbacks */
518
425
.pcm_open = sof_stream_pcm_open ,
519
- .pcm_hw_params = mt8186_pcm_hw_params ,
520
- .pcm_pointer = mt8186_pcm_pointer ,
426
+ .pcm_hw_params = mtk_adsp_stream_pcm_hw_params ,
427
+ .pcm_pointer = mtk_adsp_stream_pcm_pointer ,
521
428
.pcm_close = sof_stream_pcm_close ,
522
429
523
430
/* firmware loading */
0 commit comments