mirror of https://github.com/thesofproject/sof.git
component: make copy type extendable
Changes component's copy attribute from bool to enum, which makes it extendable. Now we can add additional copy types and implement each component's functionality based on selected type. Signed-off-by: Tomasz Lauda <tomasz.lauda@linux.intel.com>
This commit is contained in:
parent
12a563fce0
commit
912158e1f4
|
@ -62,7 +62,7 @@ struct host_data {
|
||||||
uint32_t local_pos; /**< Local position in host buffer */
|
uint32_t local_pos; /**< Local position in host buffer */
|
||||||
|
|
||||||
/* host component attributes */
|
/* host component attributes */
|
||||||
uint32_t copy_blocking; /**< True for copy in blocking mode */
|
enum comp_copy_type copy_type; /**< Current host copy type */
|
||||||
|
|
||||||
/* local and host DMA buffer info */
|
/* local and host DMA buffer info */
|
||||||
struct hc_buf host;
|
struct hc_buf host;
|
||||||
|
@ -373,7 +373,7 @@ static struct comp_dev *host_new(struct sof_ipc_comp *comp)
|
||||||
dma_sg_init(&hd->local.elem_array);
|
dma_sg_init(&hd->local.elem_array);
|
||||||
|
|
||||||
hd->chan = DMA_CHAN_INVALID;
|
hd->chan = DMA_CHAN_INVALID;
|
||||||
hd->copy_blocking = 0;
|
hd->copy_type = COMP_COPY_NORMAL;
|
||||||
hd->posn.comp_id = comp->id;
|
hd->posn.comp_id = comp->id;
|
||||||
dev->state = COMP_STATE_READY;
|
dev->state = COMP_STATE_READY;
|
||||||
dev->is_dma_connected = 1;
|
dev->is_dma_connected = 1;
|
||||||
|
@ -458,7 +458,7 @@ static void host_buffer_cb(void *data, uint32_t bytes)
|
||||||
|
|
||||||
tracev_host("host_buffer_cb(), copy_bytes = 0x%x", copy_bytes);
|
tracev_host("host_buffer_cb(), copy_bytes = 0x%x", copy_bytes);
|
||||||
|
|
||||||
if (hd->copy_blocking)
|
if (hd->copy_type == COMP_COPY_BLOCKING)
|
||||||
flags |= DMA_COPY_BLOCKING;
|
flags |= DMA_COPY_BLOCKING;
|
||||||
|
|
||||||
if (!hd->config.cyclic)
|
if (!hd->config.cyclic)
|
||||||
|
@ -665,7 +665,7 @@ static int host_reset(struct comp_dev *dev)
|
||||||
hd->chan = DMA_CHAN_INVALID;
|
hd->chan = DMA_CHAN_INVALID;
|
||||||
|
|
||||||
host_pointer_reset(dev);
|
host_pointer_reset(dev);
|
||||||
hd->copy_blocking = 0;
|
hd->copy_type = COMP_COPY_NORMAL;
|
||||||
hd->source = NULL;
|
hd->source = NULL;
|
||||||
hd->sink = NULL;
|
hd->sink = NULL;
|
||||||
dev->state = COMP_STATE_READY;
|
dev->state = COMP_STATE_READY;
|
||||||
|
@ -749,8 +749,8 @@ static int host_set_attribute(struct comp_dev *dev, uint32_t type,
|
||||||
struct host_data *hd = comp_get_drvdata(dev);
|
struct host_data *hd = comp_get_drvdata(dev);
|
||||||
|
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case COMP_ATTR_COPY_BLOCKING:
|
case COMP_ATTR_COPY_TYPE:
|
||||||
hd->copy_blocking = *(uint32_t *)value;
|
hd->copy_type = *(enum comp_copy_type *)value;
|
||||||
break;
|
break;
|
||||||
case COMP_ATTR_HOST_BUFFER:
|
case COMP_ATTR_HOST_BUFFER:
|
||||||
hd->host.elem_array = *(struct dma_sg_elem_array *)value;
|
hd->host.elem_array = *(struct dma_sg_elem_array *)value;
|
||||||
|
|
|
@ -684,7 +684,7 @@ static void kpb_init_draining(struct comp_data *kpb, struct kpb_client *cli)
|
||||||
struct hb *first_buff = buff;
|
struct hb *first_buff = buff;
|
||||||
size_t buffered = 0;
|
size_t buffered = 0;
|
||||||
size_t local_buffered = 0;
|
size_t local_buffered = 0;
|
||||||
uint32_t attr = 1;
|
enum comp_copy_type copy_type = COMP_COPY_BLOCKING;
|
||||||
|
|
||||||
trace_kpb("kpb_init_draining()");
|
trace_kpb("kpb_init_draining()");
|
||||||
|
|
||||||
|
@ -767,8 +767,8 @@ static void kpb_init_draining(struct comp_data *kpb, struct kpb_client *cli)
|
||||||
kpb->state = KPB_STATE_DRAINING;
|
kpb->state = KPB_STATE_DRAINING;
|
||||||
|
|
||||||
/* Set host-sink copy mode to blocking */
|
/* Set host-sink copy mode to blocking */
|
||||||
comp_set_attribute(kpb->host_sink->sink,
|
comp_set_attribute(kpb->host_sink->sink, COMP_ATTR_COPY_TYPE,
|
||||||
COMP_ATTR_COPY_BLOCKING, &attr);
|
©_type);
|
||||||
|
|
||||||
/* Schedule draining task */
|
/* Schedule draining task */
|
||||||
schedule_task(&kpb->draining_task, 0, 0,
|
schedule_task(&kpb->draining_task, 0, 0,
|
||||||
|
@ -796,7 +796,7 @@ static uint64_t kpb_draining_task(void *arg)
|
||||||
bool move_buffer = false;
|
bool move_buffer = false;
|
||||||
uint32_t drained = 0;
|
uint32_t drained = 0;
|
||||||
uint64_t time;
|
uint64_t time;
|
||||||
uint32_t attr = 0;
|
enum comp_copy_type copy_type = COMP_COPY_NORMAL;
|
||||||
|
|
||||||
trace_kpb("kpb_draining_task(), start.");
|
trace_kpb("kpb_draining_task(), start.");
|
||||||
|
|
||||||
|
@ -843,7 +843,7 @@ static uint64_t kpb_draining_task(void *arg)
|
||||||
*draining_data->state = KPB_STATE_HOST_COPY;
|
*draining_data->state = KPB_STATE_HOST_COPY;
|
||||||
|
|
||||||
/* Reset host-sink copy mode back to unblocking */
|
/* Reset host-sink copy mode back to unblocking */
|
||||||
comp_set_attribute(sink->sink, COMP_ATTR_COPY_BLOCKING, &attr);
|
comp_set_attribute(sink->sink, COMP_ATTR_COPY_TYPE, ©_type);
|
||||||
|
|
||||||
trace_kpb("kpb_draining_task(), done. %u drained in %d ms.",
|
trace_kpb("kpb_draining_task(), done. %u drained in %d ms.",
|
||||||
drained,
|
drained,
|
||||||
|
|
|
@ -130,7 +130,7 @@
|
||||||
/** \name Component attribute types
|
/** \name Component attribute types
|
||||||
* @{
|
* @{
|
||||||
*/
|
*/
|
||||||
#define COMP_ATTR_COPY_BLOCKING 0 /**< Comp blocking copy attribute */
|
#define COMP_ATTR_COPY_TYPE 0 /**< Comp copy type attribute */
|
||||||
#define COMP_ATTR_HOST_BUFFER 1 /**< Comp host buffer attribute */
|
#define COMP_ATTR_HOST_BUFFER 1 /**< Comp host buffer attribute */
|
||||||
/** @}*/
|
/** @}*/
|
||||||
|
|
||||||
|
@ -152,6 +152,12 @@ enum comp_endpoint_type {
|
||||||
COMP_ENDPOINT_NODE
|
COMP_ENDPOINT_NODE
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/* \brief Type of component copy, which can be changed on runtime */
|
||||||
|
enum comp_copy_type {
|
||||||
|
COMP_COPY_NORMAL = 0,
|
||||||
|
COMP_COPY_BLOCKING,
|
||||||
|
};
|
||||||
|
|
||||||
struct comp_dev;
|
struct comp_dev;
|
||||||
struct comp_buffer;
|
struct comp_buffer;
|
||||||
struct dai_config;
|
struct dai_config;
|
||||||
|
|
Loading…
Reference in New Issue