Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
c12183c
notifier: add new NOTIFIER_ID_DMA_DOMAIN_CHANGE
tlauda Sep 17, 2019
e76e30b
dma: add period to dma_chan_data
tlauda Sep 19, 2019
dd7dc53
ll_schedule: clear domain earlier
tlauda Oct 4, 2019
11f4f98
schedule: implement dma_single_chan_domain
tlauda Sep 17, 2019
3b25b0d
platform: cavs: switch to DMA single channel domain
tlauda Sep 18, 2019
531163c
pipeline: don't copy not active component
tlauda Oct 3, 2019
fa90f94
pipeline: trigger pipeline in non-atomic context
tlauda Oct 3, 2019
a92ab47
memory: adjust memory sizes for heaps
dabekjakub Sep 10, 2019
4e6631e
host: Fix memory function definitions
dabekjakub Aug 8, 2019
b0c4406
memory: Add alignment option for allocation
dabekjakub Aug 8, 2019
b797595
pipeline: fix tasks initialization
tlauda Oct 11, 2019
1471eda
dai: fix rare case of xrun on release
tlauda Oct 15, 2019
bebe161
ipc: return an error on dai not found
tlauda Oct 16, 2019
c5ef7fb
pipeline: check task init result
jajanusz Oct 16, 2019
8c64222
ipc: rename ipc_get_comp function
tlauda Oct 17, 2019
0d5fb79
ipc: check whether pipeline id is already taken
tlauda Oct 17, 2019
e2d3969
memory: removed hp buffer heap
dabekjakub Jun 21, 2019
c558026
buffer: Add alignment setting for DMA buffers.
dabekjakub Oct 14, 2019
3c6b0d1
memory: Fix DEBUG_HEAP build
dabekjakub Oct 21, 2019
2881b50
buffer: add and init id, pipeline_id and caps fields
tlauda Oct 17, 2019
8c927ec
buffer: extract allocation part to separate function
tlauda Oct 17, 2019
510245f
dma: add new attribute DMA_ATTR_BUFFER_PERIOD_COUNT
tlauda Oct 17, 2019
5a546a6
buffer: implement buffer copy functions
tlauda Oct 18, 2019
603aa9b
dma: implement dma buffer copy functions
tlauda Oct 18, 2019
e22d397
dw-dma: fix buffer and copy alignments
tlauda Oct 18, 2019
4018334
dma: alloc separate buffers for DMAs
tlauda Oct 18, 2019
75b8d62
buffer: remove buffer cache operations
tlauda Oct 21, 2019
4b10402
component: do not set buffer sizes
tlauda Oct 21, 2019
17a70bb
component: remove unused is_dma_connected field
tlauda Oct 21, 2019
13f153d
pipeline: remove code related to preload
tlauda Oct 21, 2019
455c9a6
dma: remove unused DMA_COPY_PRELOAD flags
tlauda Oct 21, 2019
7b9bedc
dai: call dma_copy even if there is no data
tlauda Oct 21, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions scripts/qemu-check.sh
Original file line number Diff line number Diff line change
Expand Up @@ -59,23 +59,23 @@ do
then
READY_IPC="00 00 00 f0"
SHM_IPC_REG=qemu-bridge-ipc-io
OUTBOX_OFFSET="11000"
OUTBOX_OFFSET="7000"
SHM_MBOX=qemu-bridge-hp-sram-mem
ROM="-r ../sof.git/build_${j}_gcc/src/arch/xtensa/rom-$j.bin"
fi
if [ $j == "skl" ]
then
READY_IPC="00 00 00 f0"
SHM_IPC_REG=qemu-bridge-ipc-io
OUTBOX_OFFSET="11000"
OUTBOX_OFFSET="7000"
SHM_MBOX=qemu-bridge-hp-sram-mem
ROM="-r ../sof.git/build_${j}_gcc/src/arch/xtensa/rom-$j.bin"
fi
if [ $j == "kbl" ]
then
READY_IPC="00 00 00 f0"
SHM_IPC_REG=qemu-bridge-ipc-io
OUTBOX_OFFSET="11000"
OUTBOX_OFFSET="7000"
SHM_MBOX=qemu-bridge-hp-sram-mem
ROM="-r ../sof.git/build_${j}_gcc/src/arch/xtensa/rom-$j.bin"
fi
Expand Down
2 changes: 2 additions & 0 deletions src/arch/host/include/arch/lib/cache.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@

#include <stddef.h>

#define PLATFORM_DCACHE_ALIGN sizeof(void *)

static inline void dcache_writeback_region(void *addr, size_t size) {}
static inline void dcache_invalidate_region(void *addr, size_t size) {}
static inline void icache_invalidate_region(void *addr, size_t size) {}
Expand Down
108 changes: 40 additions & 68 deletions src/audio/buffer.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,94 +7,99 @@

#include <sof/audio/buffer.h>
#include <sof/audio/component.h>
#include <sof/debug/panic.h>
#include <sof/drivers/interrupt.h>
#include <sof/lib/alloc.h>
#include <sof/lib/cache.h>
#include <sof/lib/memory.h>
#include <sof/list.h>
#include <sof/string.h>
#include <ipc/topology.h>
#include <errno.h>
#include <stddef.h>
#include <stdint.h>

/* create a new component in the pipeline */
struct comp_buffer *buffer_new(struct sof_ipc_buffer *desc)
struct comp_buffer *buffer_alloc(uint32_t size, uint32_t caps, uint32_t align)
{
struct comp_buffer *buffer;

trace_buffer("buffer_new()");
trace_buffer("buffer_alloc()");

/* validate request */
if (desc->size == 0 || desc->size > HEAP_BUFFER_SIZE) {
trace_buffer_error("buffer_new() error: "
"new size = %u is invalid", desc->size);
if (size == 0 || size > HEAP_BUFFER_SIZE) {
trace_buffer_error("buffer_alloc() error: "
"new size = %u is invalid", size);
return NULL;
}

/* allocate new buffer */
buffer = rzalloc(RZONE_RUNTIME, SOF_MEM_CAPS_RAM, sizeof(*buffer));
if (!buffer) {
trace_buffer_error("buffer_new() error: "
trace_buffer_error("buffer_alloc() error: "
"could not alloc structure");
return NULL;
}

buffer->addr = rballoc(RZONE_BUFFER, desc->caps, desc->size);
buffer->addr = rballoc_align(RZONE_BUFFER, caps, size, align);
if (!buffer->addr) {
rfree(buffer);
trace_buffer_error("buffer_new() error: "
trace_buffer_error("buffer_alloc() error: "
"could not alloc size = %u "
"bytes of type = %u",
desc->size, desc->caps);
size, caps);
return NULL;
}

assert(!memcpy_s(&buffer->ipc_buffer, sizeof(buffer->ipc_buffer),
desc, sizeof(*desc)));
buffer_init(buffer, size, caps);

buffer_init(buffer, desc->size);
list_init(&buffer->source_list);
list_init(&buffer->sink_list);

return buffer;
}

/* create a new component in the pipeline */
struct comp_buffer *buffer_new(struct sof_ipc_buffer *desc)
{
struct comp_buffer *buffer;

trace_buffer("buffer_new()");

/* allocate buffer */
buffer = buffer_alloc(desc->size, desc->caps, PLATFORM_DCACHE_ALIGN);
if (buffer) {
buffer->id = desc->comp.id;
buffer->pipeline_id = desc->comp.pipeline_id;
}

return buffer;
}

int buffer_set_size(struct comp_buffer *buffer, uint32_t size)
{
void *new_ptr = NULL;
struct sof_ipc_buffer *desc = NULL;

/* validate request */
if (size == 0 || size > HEAP_BUFFER_SIZE) {
trace_buffer_error("resize error: size = %u is invalid", size);
return -EINVAL;
}

desc = &buffer->ipc_buffer;
if (!desc) {
trace_buffer_error("resize error: invalid buffer desc");
return -EINVAL;
}

if (size == desc->size)
if (size == buffer->size)
return 0;

new_ptr = rbrealloc(buffer->addr, RZONE_BUFFER, desc->caps, size);
new_ptr = rbrealloc(buffer->addr, RZONE_BUFFER, buffer->caps, size);

/* we couldn't allocate bigger chunk */
if (!new_ptr && size > desc->size) {
if (!new_ptr && size > buffer->size) {
trace_buffer_error("resize error: can't alloc %u bytes type %u",
desc->size, desc->caps);
buffer->size, buffer->caps);
return -ENOMEM;
}

/* use bigger chunk, else just use the old chunk but set smaller */
if (new_ptr)
buffer->addr = new_ptr;

desc->size = size;

buffer_init(buffer, desc->size);
buffer_init(buffer, size, buffer->caps);

return 0;
}
Expand All @@ -113,8 +118,6 @@ void buffer_free(struct comp_buffer *buffer)
void comp_update_buffer_produce(struct comp_buffer *buffer, uint32_t bytes)
{
uint32_t flags;
uint32_t head = bytes;
uint32_t tail = 0;

/* return if no bytes */
if (!bytes) {
Expand All @@ -129,33 +132,6 @@ void comp_update_buffer_produce(struct comp_buffer *buffer, uint32_t bytes)

irq_local_disable(flags);

/* calculate head and tail size for dcache circular wrap ops */
if (buffer->w_ptr + bytes > buffer->end_addr) {
head = buffer->end_addr - buffer->w_ptr;
tail = bytes - head;
}

/*
* new data produce, handle consistency for buffer and cache:
* 1. source(DMA) --> buffer --> sink(non-DMA): invalidate cache.
* 2. source(non-DMA) --> buffer --> sink(DMA): write back to memory.
* 3. source(DMA) --> buffer --> sink(DMA): do nothing.
* 4. source(non-DMA) --> buffer --> sink(non-DMA): do nothing.
*/
if (buffer->source->is_dma_connected &&
!buffer->sink->is_dma_connected) {
/* need invalidate cache for sink component to use */
dcache_invalidate_region(buffer->w_ptr, head);
if (tail)
dcache_invalidate_region(buffer->addr, tail);
} else if (!buffer->source->is_dma_connected &&
buffer->sink->is_dma_connected) {
/* need write back to memory for sink component to use */
dcache_writeback_region(buffer->w_ptr, head);
if (tail)
dcache_writeback_region(buffer->addr, tail);
}

buffer->w_ptr += bytes;

/* check for pointer wrap */
Expand Down Expand Up @@ -184,10 +160,10 @@ void comp_update_buffer_produce(struct comp_buffer *buffer, uint32_t bytes)
irq_local_enable(flags);

tracev_buffer("comp_update_buffer_produce(), ((buffer->avail << 16) | "
"buffer->free) = %08x, ((buffer->ipc_buffer.comp.id << "
"16) | buffer->size) = %08x",
"buffer->free) = %08x, ((buffer->id << 16) | "
"buffer->size) = %08x",
(buffer->avail << 16) | buffer->free,
(buffer->ipc_buffer.comp.id << 16) | buffer->size);
(buffer->id << 16) | buffer->size);
tracev_buffer("comp_update_buffer_produce(), ((buffer->r_ptr - buffer"
"->addr) << 16 | (buffer->w_ptr - buffer->addr)) = %08x",
(buffer->r_ptr - buffer->addr) << 16 |
Expand Down Expand Up @@ -229,22 +205,18 @@ void comp_update_buffer_consume(struct comp_buffer *buffer, uint32_t bytes)
/* calculate free bytes */
buffer->free = buffer->size - buffer->avail;

if (buffer->sink->is_dma_connected &&
!buffer->source->is_dma_connected)
dcache_writeback_region(buffer->r_ptr, bytes);

if (buffer->cb && buffer->cb_type & BUFF_CB_TYPE_CONSUME)
buffer->cb(buffer->cb_data, bytes);

irq_local_enable(flags);

tracev_buffer("comp_update_buffer_consume(), "
"(buffer->avail << 16) | buffer->free = %08x, "
"(buffer->ipc_buffer.comp.id << 16) | buffer->size = "
" %08x, (buffer->r_ptr - buffer->addr) << 16 | "
"(buffer->id << 16) | buffer->size = %08x, "
"(buffer->r_ptr - buffer->addr) << 16 | "
"(buffer->w_ptr - buffer->addr)) = %08x",
(buffer->avail << 16) | buffer->free,
(buffer->ipc_buffer.comp.id << 16) | buffer->size,
(buffer->id << 16) | buffer->size,
(buffer->r_ptr - buffer->addr) << 16 |
(buffer->w_ptr - buffer->addr));
}
27 changes: 0 additions & 27 deletions src/audio/component.c
Original file line number Diff line number Diff line change
Expand Up @@ -98,33 +98,6 @@ void comp_unregister(struct comp_driver *drv)
irq_local_enable(flags);
}

int comp_set_sink_buffer(struct comp_dev *dev, uint32_t period_bytes,
uint32_t periods)
{
struct comp_buffer *sinkb;
int ret = 0;

sinkb = list_first_item(&dev->bsink_list, struct comp_buffer,
source_list);

/* components connected to dma configure buffer independently */
if (!sinkb->sink->is_dma_connected) {
ret = buffer_set_size(sinkb, period_bytes * periods);
if (ret < 0) {
trace_comp_error("comp_set_sink_buffer() error: "
"buffer_set_size() failed");
return ret;
}
} else if (sinkb->size < period_bytes * periods) {
trace_comp_error("comp_set_sink_buffer() error: "
"sink buffer size is not sufficient");
ret = -EINVAL;
return ret;
}

return ret;
}

int comp_set_state(struct comp_dev *dev, int cmd)
{
int requested_state = comp_get_requested_state(cmd);
Expand Down
Loading