Liam Girdwood | c0dfb4e | 2016-09-21 15:57:22 +0100 | [diff] [blame] | 1 | /* |
| 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 Bossart | 81708a5 | 2018-04-04 18:46:50 -0500 | [diff] [blame] | 33 | #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 Lauda | 7e430f2 | 2018-07-03 15:21:18 +0200 | [diff] [blame] | 40 | #include <platform/idc.h> |
Liam Girdwood | c0dfb4e | 2016-09-21 15:57:22 +0100 | [diff] [blame] | 41 | #include <platform/interrupt.h> |
| 42 | #include <platform/shim.h> |
Pierre-Louis Bossart | 81708a5 | 2018-04-04 18:46:50 -0500 | [diff] [blame] | 43 | #include <sof/audio/pipeline.h> |
| 44 | #include <sof/work.h> |
| 45 | #include <sof/debug.h> |
| 46 | #include <sof/trace.h> |
Liam Girdwood | c0dfb4e | 2016-09-21 15:57:22 +0100 | [diff] [blame] | 47 | #include <stdint.h> |
| 48 | #include <stdlib.h> |
| 49 | #include <errno.h> |
| 50 | |
| 51 | struct audio_data { |
| 52 | struct pipeline *p; |
| 53 | }; |
| 54 | |
Tomasz Lauda | 7e430f2 | 2018-07-03 15:21:18 +0200 | [diff] [blame] | 55 | int do_task_master_core(struct sof *sof) |
Liam Girdwood | c0dfb4e | 2016-09-21 15:57:22 +0100 | [diff] [blame] | 56 | { |
Liam Girdwood | 425aa5e | 2017-06-06 20:34:10 +0100 | [diff] [blame] | 57 | #ifdef STATIC_PIPE |
Liam Girdwood | c0dfb4e | 2016-09-21 15:57:22 +0100 | [diff] [blame] | 58 | struct audio_data pdata; |
Liam Girdwood | 425aa5e | 2017-06-06 20:34:10 +0100 | [diff] [blame] | 59 | #endif |
Liam Girdwood | c0dfb4e | 2016-09-21 15:57:22 +0100 | [diff] [blame] | 60 | /* 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 Lauda | 7e430f2 | 2018-07-03 15:21:18 +0200 | [diff] [blame] | 68 | sys_comp_src_init(); |
| 69 | sys_comp_tone_init(); |
| 70 | sys_comp_eq_iir_init(); |
| 71 | sys_comp_eq_fir_init(); |
Liam Girdwood | c0dfb4e | 2016-09-21 15:57:22 +0100 | [diff] [blame] | 72 | |
Liam Girdwood | 425aa5e | 2017-06-06 20:34:10 +0100 | [diff] [blame] | 73 | #if STATIC_PIPE |
Liam Girdwood | c0dfb4e | 2016-09-21 15:57:22 +0100 | [diff] [blame] | 74 | /* init static pipeline */ |
| 75 | pdata.p = init_static_pipeline(); |
| 76 | if (pdata.p == NULL) |
Liam Girdwood | e52ce68 | 2018-02-21 15:36:25 +0000 | [diff] [blame] | 77 | panic(SOF_IPC_PANIC_TASK); |
Liam Girdwood | 425aa5e | 2017-06-06 20:34:10 +0100 | [diff] [blame] | 78 | #endif |
Liam Girdwood | c0dfb4e | 2016-09-21 15:57:22 +0100 | [diff] [blame] | 79 | /* let host know DSP boot is complete */ |
| 80 | platform_boot_complete(0); |
| 81 | |
| 82 | /* main audio IPC processing loop */ |
| 83 | while (1) { |
Liam Girdwood | c0dfb4e | 2016-09-21 15:57:22 +0100 | [diff] [blame] | 84 | /* sleep until next IPC or DMA */ |
Pierre-Louis Bossart | 81708a5 | 2018-04-04 18:46:50 -0500 | [diff] [blame] | 85 | sa_enter_idle(sof); |
Liam Girdwood | c0dfb4e | 2016-09-21 15:57:22 +0100 | [diff] [blame] | 86 | wait_for_interrupt(0); |
| 87 | |
| 88 | /* now process any IPC messages from host */ |
| 89 | ipc_process_msg_queue(); |
Liam Girdwood | d1e88b2 | 2017-11-16 20:09:39 +0000 | [diff] [blame] | 90 | |
Liam Girdwood | cf3221b | 2017-12-21 17:16:53 +0000 | [diff] [blame] | 91 | /* schedule any idle tasks */ |
Liam Girdwood | d1e88b2 | 2017-11-16 20:09:39 +0000 | [diff] [blame] | 92 | schedule(); |
Liam Girdwood | c0dfb4e | 2016-09-21 15:57:22 +0100 | [diff] [blame] | 93 | } |
| 94 | |
| 95 | /* something bad happened */ |
| 96 | return -EIO; |
| 97 | } |
Tomasz Lauda | 7e430f2 | 2018-07-03 15:21:18 +0200 | [diff] [blame] | 98 | |
| 99 | int 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 | } |