Repository navigation
notifier: Extend capabilities of notifier to serve as event hub for all callback types #1950
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
4dacae4
2c8473d
a2d0373
3a63e0d
f297953
5cd860a
dee855b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| # SPDX-License-Identifier: BSD-3-Clause | ||
|
|
||
| add_local_sources(sof notifier.c) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| // SPDX-License-Identifier: BSD-3-Clause | ||
| // | ||
| // Copyright(c) 2019 Intel Corporation. All rights reserved. | ||
| // | ||
| // Author: Artur Kloniecki <arturx.kloniecki@linux.intel.com> | ||
|
|
||
| /** | ||
| * \file arch/host/lib/notifier.c | ||
| * \brief Host notifier implementation file | ||
| * \authors Artur Kloniecki <arturx.kloniecki@linux.intel.com> | ||
| */ | ||
|
|
||
| #include <ipc/topology.h> | ||
| #include <sof/lib/alloc.h> | ||
| #include <sof/lib/notifier.h> | ||
|
|
||
| static struct notify *host_notify; | ||
|
|
||
| struct notify **arch_notify_get(void) | ||
| { | ||
| if (!host_notify) | ||
| host_notify = rzalloc(RZONE_SYS, SOF_MEM_CAPS_RAM, | ||
| sizeof(*host_notify)); | ||
| return &host_notify; | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -19,6 +19,7 @@ | |
| #include <sof/lib/cache.h> | ||
| #include <sof/lib/dai.h> | ||
| #include <sof/lib/dma.h> | ||
| #include <sof/lib/notifier.h> | ||
| #include <sof/list.h> | ||
| #include <sof/string.h> | ||
| #include <sof/trace/trace.h> | ||
|
|
@@ -76,9 +77,10 @@ struct dai_data { | |
| }; | ||
|
|
||
| /* this is called by DMA driver every time descriptor has completed */ | ||
| static void dai_dma_cb(void *data, uint32_t type, struct dma_cb_data *next) | ||
| static void dai_dma_cb(void *arg, enum notify_id type, void *data) | ||
| { | ||
| struct comp_dev *dev = (struct comp_dev *)data; | ||
| struct dma_cb_data *next = data; | ||
| struct comp_dev *dev = arg; | ||
| struct dai_data *dd = comp_get_drvdata(dev); | ||
| uint32_t bytes = next->elem.size; | ||
| uint32_t samples = bytes / sample_bytes(dd->frame_fmt); | ||
|
|
@@ -540,6 +542,11 @@ static int dai_comp_trigger(struct comp_dev *dev, int cmd) | |
| if (ret == COMP_STATUS_STATE_ALREADY_SET) | ||
| return PPL_STATUS_PATH_STOP; | ||
|
|
||
| /* setup callback */ | ||
| notifier_unregister(dev, dd->chan, NOTIFIER_ID_DMA_COPY); | ||
| notifier_register(dev, dd->chan, NOTIFIER_ID_DMA_COPY, | ||
| dai_dma_cb); | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is this because there's no suitable initialisation location, where a notifier can be registered once?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. True. Previously these callbacks were registered in config/params, but in multicore scenario, trigger is the first call done on target core, so to register to appropriate notifier (there is 1 per core), I've moved it here. |
||
|
|
||
| switch (cmd) { | ||
| case COMP_TRIGGER_START: | ||
| trace_dai_with_ids(dev, "dai_comp_trigger(), START"); | ||
|
|
@@ -786,9 +793,6 @@ static int dai_config(struct comp_dev *dev, struct sof_ipc_dai_config *config) | |
| dd->chan = NULL; | ||
| return -EIO; | ||
| } | ||
|
|
||
| /* set up callback */ | ||
| dma_set_cb(dd->chan, DMA_CB_TYPE_COPY, dai_dma_cb, dev); | ||
| } | ||
|
|
||
| return 0; | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this just make it work without including too much?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@paulstelian97 This only includes 'lib' subdirectory in current tree = 'src/arch/host/lib', which only contains notifier.c and CMakeLists.txt, the notifier implementation for host. I've added these in this PR, but during all the rebasing this slipped somewhere.
It only adds what is really needed.