blob: b872793f56af17880586f4ef861f3050c7ba9386 [file] [log] [blame]
Liam Girdwoodc0dfb4e2016-09-21 15:57:22 +01001/*
2 * Copyright (c) 2016, Intel Corporation
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the Intel Corporation nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
20 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26 * POSSIBILITY OF SUCH DAMAGE.
27 *
28 * Author: Liam Girdwood <liam.r.girdwood@linux.intel.com>
29 *
30 * Generic audio task.
31 */
32
Pierre-Louis Bossart81708a52018-04-04 18:46:50 -050033#include <sof/task.h>
34#include <sof/wait.h>
35#include <sof/debug.h>
36#include <sof/timer.h>
37#include <sof/interrupt.h>
38#include <sof/ipc.h>
39#include <sof/agent.h>
Tomasz Lauda7e430f22018-07-03 15:21:18 +020040#include <platform/idc.h>
Liam Girdwoodc0dfb4e2016-09-21 15:57:22 +010041#include <platform/interrupt.h>
42#include <platform/shim.h>
Pierre-Louis Bossart81708a52018-04-04 18:46:50 -050043#include <sof/audio/pipeline.h>
44#include <sof/work.h>
45#include <sof/debug.h>
46#include <sof/trace.h>
Liam Girdwoodc0dfb4e2016-09-21 15:57:22 +010047#include <stdint.h>
48#include <stdlib.h>
49#include <errno.h>
50
51struct audio_data {
52 struct pipeline *p;
53};
54
Tomasz Lauda7e430f22018-07-03 15:21:18 +020055int do_task_master_core(struct sof *sof)
Liam Girdwoodc0dfb4e2016-09-21 15:57:22 +010056{
Liam Girdwood425aa5e2017-06-06 20:34:10 +010057#ifdef STATIC_PIPE
Liam Girdwoodc0dfb4e2016-09-21 15:57:22 +010058 struct audio_data pdata;
Liam Girdwood425aa5e2017-06-06 20:34:10 +010059#endif
Liam Girdwoodc0dfb4e2016-09-21 15:57:22 +010060 /* init default audio components */
61 sys_comp_init();
62 sys_comp_dai_init();
63 sys_comp_host_init();
64 sys_comp_mixer_init();
65 sys_comp_mux_init();
66 sys_comp_switch_init();
67 sys_comp_volume_init();
Tomasz Lauda7e430f22018-07-03 15:21:18 +020068 sys_comp_src_init();
69 sys_comp_tone_init();
70 sys_comp_eq_iir_init();
71 sys_comp_eq_fir_init();
Liam Girdwoodc0dfb4e2016-09-21 15:57:22 +010072
Liam Girdwood425aa5e2017-06-06 20:34:10 +010073#if STATIC_PIPE
Liam Girdwoodc0dfb4e2016-09-21 15:57:22 +010074 /* init static pipeline */
75 pdata.p = init_static_pipeline();
76 if (pdata.p == NULL)
Liam Girdwoode52ce682018-02-21 15:36:25 +000077 panic(SOF_IPC_PANIC_TASK);
Liam Girdwood425aa5e2017-06-06 20:34:10 +010078#endif
Liam Girdwoodc0dfb4e2016-09-21 15:57:22 +010079 /* let host know DSP boot is complete */
80 platform_boot_complete(0);
81
82 /* main audio IPC processing loop */
83 while (1) {
Liam Girdwoodc0dfb4e2016-09-21 15:57:22 +010084 /* sleep until next IPC or DMA */
Pierre-Louis Bossart81708a52018-04-04 18:46:50 -050085 sa_enter_idle(sof);
Liam Girdwoodc0dfb4e2016-09-21 15:57:22 +010086 wait_for_interrupt(0);
87
88 /* now process any IPC messages from host */
89 ipc_process_msg_queue();
Liam Girdwoodd1e88b22017-11-16 20:09:39 +000090
Liam Girdwoodcf3221b2017-12-21 17:16:53 +000091 /* schedule any idle tasks */
Liam Girdwoodd1e88b22017-11-16 20:09:39 +000092 schedule();
Liam Girdwoodc0dfb4e2016-09-21 15:57:22 +010093 }
94
95 /* something bad happened */
96 return -EIO;
97}
Tomasz Lauda7e430f22018-07-03 15:21:18 +020098
99int do_task_slave_core(struct sof *sof)
100{
101 /* main audio IDC processing loop */
102 while (1) {
103 /* sleep until next IDC */
104 wait_for_interrupt(0);
105
106 /* now process any IDC messages from master core */
107 idc_process_msg_queue();
108
109 /* schedule any idle tasks */
110 schedule();
111 }
112
113 /* something bad happened */
114 return -EIO;
115}