diff --git a/src/audio/host.c b/src/audio/host.c index 2a64c40a6..5ef6152f0 100644 --- a/src/audio/host.c +++ b/src/audio/host.c @@ -62,7 +62,7 @@ struct host_data { uint32_t local_pos; /**< Local position in host buffer */ /* 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 */ 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); hd->chan = DMA_CHAN_INVALID; - hd->copy_blocking = 0; + hd->copy_type = COMP_COPY_NORMAL; hd->posn.comp_id = comp->id; dev->state = COMP_STATE_READY; 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); - if (hd->copy_blocking) + if (hd->copy_type == COMP_COPY_BLOCKING) flags |= DMA_COPY_BLOCKING; if (!hd->config.cyclic) @@ -665,7 +665,7 @@ static int host_reset(struct comp_dev *dev) hd->chan = DMA_CHAN_INVALID; host_pointer_reset(dev); - hd->copy_blocking = 0; + hd->copy_type = COMP_COPY_NORMAL; hd->source = NULL; hd->sink = NULL; 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); switch (type) { - case COMP_ATTR_COPY_BLOCKING: - hd->copy_blocking = *(uint32_t *)value; + case COMP_ATTR_COPY_TYPE: + hd->copy_type = *(enum comp_copy_type *)value; break; case COMP_ATTR_HOST_BUFFER: hd->host.elem_array = *(struct dma_sg_elem_array *)value; diff --git a/src/audio/kpb.c b/src/audio/kpb.c index 72014f4a1..3bdc1b350 100644 --- a/src/audio/kpb.c +++ b/src/audio/kpb.c @@ -684,7 +684,7 @@ static void kpb_init_draining(struct comp_data *kpb, struct kpb_client *cli) struct hb *first_buff = buff; size_t 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()"); @@ -767,8 +767,8 @@ static void kpb_init_draining(struct comp_data *kpb, struct kpb_client *cli) kpb->state = KPB_STATE_DRAINING; /* Set host-sink copy mode to blocking */ - comp_set_attribute(kpb->host_sink->sink, - COMP_ATTR_COPY_BLOCKING, &attr); + comp_set_attribute(kpb->host_sink->sink, COMP_ATTR_COPY_TYPE, + ©_type); /* Schedule draining task */ schedule_task(&kpb->draining_task, 0, 0, @@ -796,7 +796,7 @@ static uint64_t kpb_draining_task(void *arg) bool move_buffer = false; uint32_t drained = 0; uint64_t time; - uint32_t attr = 0; + enum comp_copy_type copy_type = COMP_COPY_NORMAL; 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; /* 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.", drained, diff --git a/src/include/sof/audio/component.h b/src/include/sof/audio/component.h index e1370a873..42ee35f52 100644 --- a/src/include/sof/audio/component.h +++ b/src/include/sof/audio/component.h @@ -130,7 +130,7 @@ /** \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 */ /** @}*/ @@ -152,6 +152,12 @@ enum comp_endpoint_type { 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_buffer; struct dai_config;