component: add comp drivers list to sof context

Adds component drivers list to sof context, so it can be
accessed globally. Also adds global getter.

Signed-off-by: Tomasz Lauda <tomasz.lauda@linux.intel.com>
This commit is contained in:
Tomasz Lauda 2020-01-17 11:26:40 +01:00 committed by Liam Girdwood
parent 47917c1f3d
commit 5eea994a3a
4 changed files with 24 additions and 4 deletions

View File

@ -21,6 +21,7 @@ static struct comp_driver_list cd;
static struct comp_driver *get_drv(uint32_t type)
{
struct comp_driver_list *drivers = comp_drivers_get();
struct list_item *clist;
struct comp_driver *drv = NULL;
uint32_t flags;
@ -28,7 +29,7 @@ static struct comp_driver *get_drv(uint32_t type)
irq_local_disable(flags);
/* search driver list for driver type */
list_for_item(clist, &cd.list) {
list_for_item(clist, &drivers->list) {
drv = container_of(clist, struct comp_driver, list);
if (drv->type == type)
@ -79,10 +80,11 @@ struct comp_dev *comp_new(struct sof_ipc_comp *comp)
int comp_register(struct comp_driver *drv)
{
struct comp_driver_list *drivers = comp_drivers_get();
uint32_t flags;
irq_local_disable(flags);
list_item_prepend(&drv->list, &cd.list);
list_item_prepend(&drv->list, &drivers->list);
irq_local_enable(flags);
return 0;
@ -191,7 +193,9 @@ int comp_set_state(struct comp_dev *dev, int cmd)
void sys_comp_init(struct sof *sof)
{
list_init(&cd.list);
sof->comp_drivers = &cd;
list_init(&sof->comp_drivers->list);
}
int comp_get_copy_limits(struct comp_dev *dev, struct comp_copy_limits *cl)

View File

@ -22,6 +22,7 @@
#include <sof/debug/panic.h>
#include <sof/list.h>
#include <sof/math/numbers.h>
#include <sof/sof.h>
#include <sof/trace/trace.h>
#include <ipc/control.h>
#include <ipc/stream.h>
@ -35,7 +36,6 @@
#include <stdint.h>
struct comp_dev;
struct sof;
struct sof_ipc_dai_config;
struct sof_ipc_stream_posn;
struct dai_hw_params;
@ -718,6 +718,11 @@ static inline bool comp_is_scheduling_source(struct comp_dev *dev)
*/
int comp_get_copy_limits(struct comp_dev *dev, struct comp_copy_limits *cl);
static inline struct comp_driver_list *comp_drivers_get(void)
{
return sof_get()->comp_drivers;
}
/** @}*/
/** @}*/

View File

@ -14,6 +14,7 @@
struct cascade_root;
struct clock_info;
struct comp_driver_list;
struct dai_info;
struct dma_info;
struct dma_trace_data;
@ -83,6 +84,9 @@ struct sof {
/* cascading interrupt controller root */
struct cascade_root *cascade_root;
/* list of registered component drivers */
struct comp_driver_list *comp_drivers;
__aligned(PLATFORM_DCACHE_ALIGN) int alignment[0];
} __aligned(PLATFORM_DCACHE_ALIGN);

View File

@ -15,6 +15,8 @@
TRACE_IMPL()
static struct sof sof;
#if !CONFIG_LIBRARY
void *_zalloc(enum mem_zone zone, uint32_t flags, uint32_t caps, size_t bytes)
@ -45,4 +47,9 @@ void __panic(uint32_t p, char *filename, uint32_t linenum)
(void)linenum;
}
struct sof *sof_get(void)
{
return &sof;
}
#endif