From 5429b2d97b262b6ed8c2a1d72b126dc734a0b195 Mon Sep 17 00:00:00 2001 From: Keyon Jie Date: Tue, 14 May 2019 18:30:29 +0800 Subject: [PATCH 1/6] topology: kwd: update detector configure blob to align with default settings We should load_mips to be 0, align values with default settings, that is: load_mips = 0, load_memory_size = 0, keyphrase_length = 0x780, activation_shift = 0x3, activation_threshold = 0x3fff. Signed-off-by: Keyon Jie --- tools/topology/m4/detect_test_coef.m4 | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tools/topology/m4/detect_test_coef.m4 b/tools/topology/m4/detect_test_coef.m4 index 77f027c664b2..6358be7ad8ec 100644 --- a/tools/topology/m4/detect_test_coef.m4 +++ b/tools/topology/m4/detect_test_coef.m4 @@ -4,8 +4,8 @@ CONTROLBYTES_PRIV(DETECTOR_priv, ` 0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x03,' ` 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,' ` 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,' -` 0x20,0x00,0x00,0x00,0x05,0x00,0x00,0x00,' -` 0x00,0x00,0x00,0x00,0x80,0x02,0x00,0x00,' -` 0x03,0x00,0x00,0x80,0x00,0x00,0x00,0x00,' +` 0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,' +` 0x00,0x00,0x00,0x00,0x80,0x07,0x00,0x00,' +` 0x03,0x00,0xff,0x3f,0x00,0x00,0x00,0x00,' ` 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00"' ) From 3b941c4380f3caf9a416b576e6acc15b30ba585a Mon Sep 17 00:00:00 2001 From: Tomasz Lauda Date: Tue, 14 May 2019 14:15:07 +0200 Subject: [PATCH 2/6] topology: fix sof-glk-da7219-kwd topology This patch fixes two things: - Configures HDA pipelines to be timer driven. - Moves definition of pipe-kfbm-capture to avoid overwrite of deadline and frames for other pipelines. Signed-off-by: Tomasz Lauda --- tools/topology/sof-glk-da7219-kwd.m4 | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/tools/topology/sof-glk-da7219-kwd.m4 b/tools/topology/sof-glk-da7219-kwd.m4 index 7ee3a21dd5da..10d14096778d 100644 --- a/tools/topology/sof-glk-da7219-kwd.m4 +++ b/tools/topology/sof-glk-da7219-kwd.m4 @@ -77,14 +77,6 @@ PIPELINE_PCM_ADD(sof/pipe-volume-playback.m4, 7, 7, 2, s32le, 48, 1000, 0, 0) -# Passthrough capture pipeline 8 on PCM 8 using max 2 channels. -# Schedule 320 frames per 1000us deadline on core 0 with priority 0 -PIPELINE_PCM_ADD(sof/pipe-kfbm-capture.m4, - 8, 8, 2, s16le, - KWD_PERIOD_FRAMES, - KWD_PIPE_SCH_DEADLINE_US, - 0, 0) - # # DAIs configuration # @@ -122,24 +114,36 @@ DAI_ADD(sof/pipe-dai-capture.m4, DAI_ADD(sof/pipe-dai-playback.m4, 5, HDA, 3, iDisp1, PIPELINE_SOURCE_5, 2, s32le, - 48, 1000, 0, 0) + 48, 1000, 0, 0, SCHEDULE_TIME_DOMAIN_TIMER) # playback DAI is iDisp2 using 2 periods # Buffers use s32le format, with 48 frame per 1000us on core 0 with priority 0 DAI_ADD(sof/pipe-dai-playback.m4, 6, HDA, 4, iDisp2, PIPELINE_SOURCE_6, 2, s32le, - 48, 1000, 0, 0) + 48, 1000, 0, 0, SCHEDULE_TIME_DOMAIN_TIMER) # playback DAI is iDisp3 using 2 periods # Buffers use s32le format, with 48 frame per 1000us on core 0 with priority 0 DAI_ADD(sof/pipe-dai-playback.m4, 7, HDA, 5, iDisp3, PIPELINE_SOURCE_7, 2, s32le, - 48, 1000, 0, 0) + 48, 1000, 0, 0, SCHEDULE_TIME_DOMAIN_TIMER) + +# +# KWD configuration +# + +# Passthrough capture pipeline 8 on PCM 8 using max 2 channels. +# Schedule 320 frames per 20000us deadline on core 0 with priority 0 +PIPELINE_PCM_ADD(sof/pipe-kfbm-capture.m4, + 8, 8, 2, s16le, + KWD_PERIOD_FRAMES, + KWD_PIPE_SCH_DEADLINE_US, + 0, 0) # capture DAI is DMIC 1 using 2 periods -# Buffers use s16le format, with 320 frame per 1000us on core 0 with priority 0 +# Buffers use s16le format, with 320 frame per 20000us on core 0 with priority 0 DAI_ADD(sof/pipe-dai-capture.m4, 8, DMIC, 1, dmic16k, PIPELINE_SINK_8, 2, s16le, From 90bc89cae057a0e4f4501fc3a560a39d9a28d0c8 Mon Sep 17 00:00:00 2001 From: Keyon Jie Date: Tue, 14 May 2019 18:53:28 +0800 Subject: [PATCH 3/6] kpb: stop pipeline copy at draining Add a state KPB_STATE_REALTIME for the realtime copy, and stop propagate copying while at draining. Signed-off-by: Keyon Jie --- src/audio/kpb.c | 24 +++++++++--------------- src/include/sof/audio/kpb.h | 1 + 2 files changed, 10 insertions(+), 15 deletions(-) diff --git a/src/audio/kpb.c b/src/audio/kpb.c index 8a912a307a65..9c29c10b96de 100644 --- a/src/audio/kpb.c +++ b/src/audio/kpb.c @@ -350,7 +350,6 @@ static int kpb_prepare(struct comp_dev *dev) /* Init private data */ cd->kpb_no_of_clients = 0; cd->buffered_data = 0; - cd->state = KPB_STATE_BUFFERING; /* Init history buffer */ kpb_clear_history_buffer(cd->history_buffer); @@ -437,16 +436,12 @@ static int kpb_reset(struct comp_dev *dev) /* Reset history buffer */ kpb->is_internal_buffer_full = false; kpb_clear_history_buffer(kpb->history_buffer); - /* Reset amount of buffered data */ kpb->buffered_data = 0; /* Unregister KPB for async notification */ notifier_unregister(&kpb->kpb_events); - /* Reset KPB state to initial buffering state */ - kpb->state = KPB_STATE_BUFFERING; - return comp_set_state(dev, COMP_TRIGGER_RESET); } @@ -474,17 +469,15 @@ static int kpb_copy(struct comp_dev *dev) /* Get source and sink buffers */ source = list_first_item(&dev->bsource_list, struct comp_buffer, sink_list); - sink = (kpb->state == KPB_STATE_BUFFERING) ? kpb->rt_sink - : kpb->cli_sink; - /* Pause selector copy during draining and/or draining on demand. - * We keep selector in this "paused" state as long as draining - * is going and later during direct copy to client's/host sink, - * in so called "draining on demand" state. In order to rearm - * detection algorithm kpb_reset is needed. - */ - if (kpb->state != KPB_STATE_BUFFERING) + /* Stop copying downstream if in draining */ + if (kpb->state == KPB_STATE_DRAINING_ON_DEMAND) { + comp_update_buffer_consume(source, source->avail); return PPL_STATUS_PATH_STOP; + } + + sink = (kpb->state == KPB_STATE_BUFFERING) ? kpb->rt_sink + : kpb->cli_sink; /* Process source data */ /* Check if there are valid pointers */ @@ -795,6 +788,7 @@ static void kpb_init_draining(struct comp_data *kpb, struct kpb_client *cli) comp_set_attribute(kpb->cli_sink->sink, COMP_ATTR_COPY_BLOCKING, 1); + kpb->state = KPB_STATE_DRAINING_ON_DEMAND; /* Schedule draining task */ schedule_task(&kpb->draining_task, 0, 0, SOF_SCHEDULE_FLAG_IDLE); @@ -855,7 +849,7 @@ static uint64_t kpb_draining_task(void *arg) /* Draining is done. Now switch KPB to copy real time stream * to client's sink */ - *draining_data->state = KPB_STATE_DRAINING_ON_DEMAND; + *draining_data->state = KPB_STATE_REALTIME; /* Reset host-sink copy mode back to unblocking */ comp_set_attribute(sink->sink, COMP_ATTR_COPY_BLOCKING, 0); diff --git a/src/include/sof/audio/kpb.h b/src/include/sof/audio/kpb.h index 382a1ed919b6..938b2a354d79 100644 --- a/src/include/sof/audio/kpb.h +++ b/src/include/sof/audio/kpb.h @@ -60,6 +60,7 @@ enum kpb_state { KPB_STATE_BUFFERING = 0, KPB_STATE_DRAINING_ON_DEMAND, + KPB_STATE_REALTIME, }; enum kpb_event { From 51d1bed61ef8c3b864550f6c7f38acb0952459b2 Mon Sep 17 00:00:00 2001 From: Tomasz Lauda Date: Mon, 13 May 2019 11:25:45 +0200 Subject: [PATCH 4/6] hda-dma: add safe check to waiting functions Adds safe check to waiting functions in case we've got preempted after read, but before deadline check. Signed-off-by: Tomasz Lauda --- src/drivers/intel/cavs/hda-dma.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/drivers/intel/cavs/hda-dma.c b/src/drivers/intel/cavs/hda-dma.c index 24e435a678c7..d075799471f0 100644 --- a/src/drivers/intel/cavs/hda-dma.c +++ b/src/drivers/intel/cavs/hda-dma.c @@ -275,6 +275,11 @@ static int hda_dma_wait_for_buffer_full(struct dma *dma, while (!(host_dma_reg_read(dma, chan->index, DGCS) & DGCS_BF)) { if (deadline < platform_timer_get(platform_timer)) { + /* safe check in case we've got preempted after read */ + if (host_dma_reg_read(dma, chan->index, DGCS) & + DGCS_BF) + return 0; + trace_hddma_error("hda-dmac: %d wait for buffer full " "timeout", dma->plat_data.id); return -ETIME; @@ -293,6 +298,11 @@ static int hda_dma_wait_for_buffer_empty(struct dma *dma, while (host_dma_reg_read(dma, chan->index, DGCS) & DGCS_BNE) { if (deadline < platform_timer_get(platform_timer)) { + /* safe check in case we've got preempted after read */ + if (!(host_dma_reg_read(dma, chan->index, DGCS) & + DGCS_BNE)) + return 0; + trace_hddma_error("hda-dmac: %d wait for buffer empty " "timeout", dma->plat_data.id); return -ETIME; From f72d96cae1839f15164fe16ae4cfd64be0875bad Mon Sep 17 00:00:00 2001 From: Keyon Jie Date: Sun, 5 May 2019 18:22:14 +0800 Subject: [PATCH 5/6] [RFC]selector: need treat selector as endpoint for command handling For hw_params(), prepare(), trigger(), reset() commands, we should treat seletor as endpoint(don't propagate them upstream anymore), otherwise, those upstream components(e.g. kpb and dai) will complain about double handling and status might be wrong, errors like "source component buffer has not enough data available" will happen. This is only RFC to raise attention of this issue, it is not good fix, please help comment. Signed-off-by: Keyon Jie --- src/audio/selector.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/audio/selector.c b/src/audio/selector.c index 19d02344acb8..de6d61260478 100644 --- a/src/audio/selector.c +++ b/src/audio/selector.c @@ -183,7 +183,7 @@ static int selector_params(struct comp_dev *dev) else dev->params.channels = cd->config.in_channels_count; - return 0; + return PPL_STATUS_PATH_STOP; } @@ -303,9 +303,11 @@ static int selector_cmd(struct comp_dev *dev, int cmd, void *data, */ static int selector_trigger(struct comp_dev *dev, int cmd) { + int ret; trace_selector("selector_trigger()"); - return comp_set_state(dev, cmd); + ret = comp_set_state(dev, cmd); + return ret == 0 ? PPL_STATUS_PATH_STOP : ret; } @@ -454,7 +456,7 @@ static int selector_prepare(struct comp_dev *dev) goto err; } - return 0; + return PPL_STATUS_PATH_STOP; err: comp_set_state(dev, COMP_TRIGGER_RESET); @@ -468,9 +470,11 @@ static int selector_prepare(struct comp_dev *dev) */ static int selector_reset(struct comp_dev *dev) { + int ret; trace_selector("selector_reset()"); - return comp_set_state(dev, COMP_TRIGGER_RESET); + ret = comp_set_state(dev, COMP_TRIGGER_RESET); + return ret == 0 ? PPL_STATUS_PATH_STOP : ret; } /** From 0e429b45d2246725391e18973301de76b694f6bb Mon Sep 17 00:00:00 2001 From: Bartosz Kokoszko Date: Mon, 13 May 2019 15:54:34 +0200 Subject: [PATCH 6/6] platform: apl: increase l1 exit time Signed-off-by: Bartosz Kokoszko --- src/platform/apollolake/include/platform/platform.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/platform/apollolake/include/platform/platform.h b/src/platform/apollolake/include/platform/platform.h index 64fa0ed2c34c..1b6fcf21266e 100644 --- a/src/platform/apollolake/include/platform/platform.h +++ b/src/platform/apollolake/include/platform/platform.h @@ -155,7 +155,7 @@ struct sof; #define PLATFORM_DEFAULT_DELAY 12 /* minimal L1 exit time in cycles */ -#define PLATFORM_FORCE_L1_EXIT_TIME 585 +#define PLATFORM_FORCE_L1_EXIT_TIME 800 /* the SSP port fifo depth */ #define SSP_FIFO_DEPTH 16