diff --git a/src/audio/copier/copier.c b/src/audio/copier/copier.c index 65dc8f25f5ab..cd997595352c 100644 --- a/src/audio/copier/copier.c +++ b/src/audio/copier/copier.c @@ -38,6 +38,7 @@ #include #include #include +#include #if CONFIG_ZEPHYR_NATIVE_DRIVERS #include @@ -54,49 +55,44 @@ DECLARE_SOF_RT_UUID("copier", copier_comp_uuid, 0x9ba00c83, 0xca12, 0x4a83, DECLARE_TR_CTX(copier_comp_tr, SOF_UUID(copier_comp_uuid), LOG_LEVEL_INFO); -static struct comp_dev *copier_new(const struct comp_driver *drv, - const struct comp_ipc_config *config, - const void *spec) +static int copier_init(struct processing_module *mod) { - const struct ipc4_copier_module_cfg *copier = spec; union ipc4_connector_node_id node_id; struct ipc_comp_dev *ipc_pipe; struct ipc *ipc = ipc_get(); struct copier_data *cd; - struct comp_dev *dev; - int i; - - comp_cl_dbg(&comp_copier, "copier_new()"); - - dev = comp_alloc(drv, sizeof(*dev)); - if (!dev) - return NULL; - - dev->ipc_config = *config; + struct comp_dev *dev = mod->dev; + struct module_data *md = &mod->priv; + struct ipc4_copier_module_cfg *copier = (struct ipc4_copier_module_cfg *)md->cfg.init_data; + struct comp_ipc_config *config = &dev->ipc_config; + int i, ret = 0; cd = rzalloc(SOF_MEM_ZONE_RUNTIME, 0, SOF_MEM_CAPS_RAM, sizeof(*cd)); if (!cd) - goto error; + return -ENOMEM; + md->private = cd; /* * Don't copy the config_data[] variable size array, we don't need to * store it, it's only used during IPC processing, besides we haven't * allocated space for it, so don't "fix" this! */ - if (memcpy_s(&cd->config, sizeof(cd->config), copier, sizeof(*copier)) < 0) - goto error_cd; + if (memcpy_s(&cd->config, sizeof(cd->config), copier, sizeof(*copier)) < 0) { + ret = -EINVAL; + goto error; + } for (i = 0; i < IPC4_COPIER_MODULE_OUTPUT_PINS_COUNT; i++) cd->out_fmt[i] = cd->config.out_fmt; - comp_set_drvdata(dev, cd); list_init(&dev->bsource_list); list_init(&dev->bsink_list); ipc_pipe = ipc_get_comp_by_ppl_id(ipc, COMP_TYPE_PIPELINE, config->pipeline_id); if (!ipc_pipe) { - comp_cl_err(&comp_copier, "pipeline %d is not existed", config->pipeline_id); - goto error_cd; + comp_err(dev, "pipeline %d is not existed", config->pipeline_id); + ret = -EPIPE; + goto error; } dev->pipeline = ipc_pipe->pipeline; @@ -109,10 +105,11 @@ static struct comp_dev *copier_new(const struct comp_driver *drv, switch (node_id.f.dma_type) { case ipc4_hda_host_output_class: case ipc4_hda_host_input_class: - if (copier_host_create(dev, cd, &dev->ipc_config, - copier, cd->direction, ipc_pipe->pipeline)) { - comp_cl_err(&comp_copier, "unable to create host"); - goto error_cd; + ret = copier_host_create(dev, cd, &dev->ipc_config, + copier, cd->direction, ipc_pipe->pipeline); + if (ret < 0) { + comp_err(dev, "unable to create host"); + goto error; } break; case ipc4_hda_link_output_class: @@ -122,27 +119,28 @@ static struct comp_dev *copier_new(const struct comp_driver *drv, case ipc4_i2s_link_input_class: case ipc4_alh_link_output_class: case ipc4_alh_link_input_class: - if (copier_dai_create(dev, cd, &dev->ipc_config, - copier, ipc_pipe->pipeline)) { - comp_cl_err(&comp_copier, "unable to create dai"); - goto error_cd; + ret = copier_dai_create(dev, cd, &dev->ipc_config, + copier, ipc_pipe->pipeline); + if (ret < 0) { + comp_err(dev, "unable to create dai"); + goto error; } break; #if CONFIG_IPC4_GATEWAY case ipc4_ipc_output_class: case ipc4_ipc_input_class: - if (copier_ipcgtw_create(dev, cd, &dev->ipc_config, - copier, ipc_pipe->pipeline)) { - comp_cl_err(&comp_copier, "unable to create IPC gateway"); - goto error_cd; + ret = copier_ipcgtw_create(dev, cd, &dev->ipc_config, + copier, ipc_pipe->pipeline); + if (ret < 0) { + comp_err(dev, "unable to create IPC gateway"); + goto error; } - break; #endif default: - comp_cl_err(&comp_copier, "unsupported dma type %x", - (uint32_t)node_id.f.dma_type); - goto error_cd; + comp_err(dev, "unsupported dma type %x", (uint32_t)node_id.f.dma_type); + ret = -EINVAL; + goto error; }; dev->direction_set = true; @@ -150,18 +148,52 @@ static struct comp_dev *copier_new(const struct comp_driver *drv, dev->direction = cd->direction; dev->state = COMP_STATE_READY; - return dev; - -error_cd: - rfree(cd); + return 0; error: + rfree(cd); + return ret; +} + +static struct comp_dev *copier_new(const struct comp_driver *drv, + const struct comp_ipc_config *config, + const void *spec) +{ + struct comp_dev *dev; + struct processing_module *mod; + struct module_data *md; + int ret; + + comp_cl_dbg(&comp_copier, "copier_new()"); + + mod = rzalloc(SOF_MEM_ZONE_RUNTIME, 0, SOF_MEM_CAPS_RAM, sizeof(*mod)); + if (!mod) + return NULL; + + dev = comp_alloc(drv, sizeof(*dev)); + if (!dev) + goto error_dev; + + dev->ipc_config = *config; + + comp_set_drvdata(dev, mod); + md = &mod->priv; + mod->dev = dev; + md->cfg.init_data = spec; + + ret = copier_init(mod); + if (!ret) + return dev; + rfree(dev); +error_dev: + rfree(mod); return NULL; } -static void copier_free(struct comp_dev *dev) +static void copier_mod_free(struct processing_module *mod) { - struct copier_data *cd = comp_get_drvdata(dev); + struct copier_data *cd = module_get_private_data(mod); + struct comp_dev *dev = mod->dev; switch (dev->ipc_config.type) { case SOF_COMP_HOST: @@ -179,28 +211,27 @@ static void copier_free(struct comp_dev *dev) } rfree(cd); - rfree(dev); } -static int copier_prepare(struct comp_dev *dev) +static void copier_free(struct comp_dev *dev) { - struct copier_data *cd = comp_get_drvdata(dev); - int ret; + struct processing_module *mod = comp_get_drvdata(dev); - comp_dbg(dev, "copier_prepare()"); + copier_mod_free(mod); - /* cannot configure DAI while active */ - if (dev->state == COMP_STATE_ACTIVE) { - comp_info(dev, "copier_config_prepare(): Component is in active state."); - return 0; - } + rfree(mod); + rfree(dev); +} - ret = comp_set_state(dev, COMP_TRIGGER_PREPARE); - if (ret < 0) - return ret; +static int copier_mod_prepare(struct processing_module *mod, + struct sof_source __sparse_cache **sources, int num_of_sources, + struct sof_sink __sparse_cache **sinks, int num_of_sinks) +{ + struct copier_data *cd = module_get_private_data(mod); + struct comp_dev *dev = mod->dev; + int ret; - if (ret == COMP_STATUS_STATE_ALREADY_SET) - return PPL_STATUS_PATH_STOP; + comp_dbg(dev, "copier_prepare()"); switch (dev->ipc_config.type) { case SOF_COMP_HOST: @@ -236,10 +267,32 @@ static int copier_prepare(struct comp_dev *dev) return 0; } -static int copier_reset(struct comp_dev *dev) +static int copier_prepare(struct comp_dev *dev) +{ + struct processing_module *mod = comp_get_drvdata(dev); + int ret; + + /* cannot configure DAI while active */ + if (dev->state == COMP_STATE_ACTIVE) { + comp_info(dev, "copier_config_prepare(): Component is in active state."); + return 0; + } + + ret = comp_set_state(dev, COMP_TRIGGER_PREPARE); + if (ret < 0) + return ret; + + if (ret == COMP_STATUS_STATE_ALREADY_SET) + return PPL_STATUS_PATH_STOP; + + return copier_mod_prepare(mod, NULL, 0, NULL, 0); +} + +static int copier_mod_reset(struct processing_module *mod) { - struct copier_data *cd = comp_get_drvdata(dev); + struct copier_data *cd = module_get_private_data(mod); struct ipc4_pipeline_registers pipe_reg; + struct comp_dev *dev = mod->dev; comp_dbg(dev, "copier_reset()"); @@ -266,14 +319,25 @@ static int copier_reset(struct comp_dev *dev) mailbox_sw_regs_write(cd->pipeline_reg_offset, &pipe_reg, sizeof(pipe_reg)); } + return 0; +} + +static int copier_reset(struct comp_dev *dev) +{ + struct processing_module *mod = comp_get_drvdata(dev); + int ret; + + ret = copier_mod_reset(mod); + comp_set_state(dev, COMP_TRIGGER_RESET); - return 0; + return ret; } static int copier_comp_trigger(struct comp_dev *dev, int cmd) { - struct copier_data *cd = comp_get_drvdata(dev); + struct processing_module *mod = comp_get_drvdata(dev); + struct copier_data *cd = module_get_private_data(mod); struct sof_ipc_stream_posn posn; struct comp_dev *dai_copier; struct comp_buffer *buffer; @@ -405,33 +469,6 @@ static int copier_comp_trigger(struct comp_dev *dev, int cmd) return ret; } -static inline struct comp_buffer *get_endpoint_buffer(struct copier_data *cd) -{ - return cd->multi_endpoint_buffer ? cd->multi_endpoint_buffer : - cd->endpoint_buffer[IPC4_COPIER_GATEWAY_PIN]; -} - -static int do_endpoint_copy(struct comp_dev *dev) -{ - struct copier_data *cd = comp_get_drvdata(dev); - - switch (dev->ipc_config.type) { - case SOF_COMP_HOST: - if (!cd->ipc_gtw) - return host_common_copy(cd->hd, dev, copier_host_dma_cb); - break; - case SOF_COMP_DAI: - if (cd->endpoint_num == 1) - return dai_common_copy(cd->dd[0], dev, cd->converter); - - return dai_zephyr_multi_endpoint_copy(cd->dd, dev, cd->multi_endpoint_buffer, - cd->endpoint_num); - default: - break; - } - return 0; -} - static int do_conversion_copy(struct comp_dev *dev, struct copier_data *cd, struct comp_buffer __sparse_cache *src, @@ -460,63 +497,26 @@ static int do_conversion_copy(struct comp_dev *dev, return 0; } -static int do_multi_endpoint_module_copy(struct copier_data *cd, struct comp_dev *dev) +static int copier_copy_to_sinks(struct copier_data *cd, struct comp_dev *dev, + struct comp_buffer __sparse_cache *src_c, + struct comp_copy_limits *processed_data) { - struct comp_buffer *src, *sink; - struct comp_buffer __sparse_cache *src_c, *sink_c; - struct comp_copy_limits processed_data; + struct comp_buffer __sparse_cache *sink_c; struct list_item *sink_list; - int ret = 0; - - processed_data.source_bytes = 0; - - if (cd->endpoint_num && !cd->bsource_buffer) { - /* gateway(s) as input */ - ret = do_endpoint_copy(dev); - if (ret < 0) - return ret; - - src_c = buffer_acquire(get_endpoint_buffer(cd)); - } else { - /* component as input */ - if (list_is_empty(&dev->bsource_list)) { - comp_err(dev, "No source buffer bound"); - return -EINVAL; - } - - src = list_first_item(&dev->bsource_list, struct comp_buffer, sink_list); - src_c = buffer_acquire(src); - - if (cd->endpoint_num) { - /* gateway(s) on output */ - sink_c = buffer_acquire(get_endpoint_buffer(cd)); - ret = do_conversion_copy(dev, cd, src_c, sink_c, &processed_data); - buffer_release(sink_c); - - if (ret < 0) { - buffer_release(src_c); - return ret; - } - - ret = do_endpoint_copy(dev); - if (ret < 0) { - buffer_release(src_c); - return ret; - } - } - } + struct comp_buffer *sink; + int ret = 0; - /* zero or more components on outputs, module copy case */ + /* module copy, one source to multiple sink buffers */ list_for_item(sink_list, &dev->bsink_list) { struct comp_dev *sink_dev; sink = container_of(sink_list, struct comp_buffer, source_list); sink_c = buffer_acquire(sink); sink_dev = sink_c->sink; - processed_data.sink_bytes = 0; + processed_data->sink_bytes = 0; if (sink_dev->state == COMP_STATE_ACTIVE) { - ret = do_conversion_copy(dev, cd, src_c, sink_c, &processed_data); - cd->output_total_data_processed += processed_data.sink_bytes; + ret = do_conversion_copy(dev, cd, src_c, sink_c, processed_data); + cd->output_total_data_processed += processed_data->sink_bytes; } buffer_release(sink_c); if (ret < 0) { @@ -527,11 +527,75 @@ static int do_multi_endpoint_module_copy(struct copier_data *cd, struct comp_dev } if (!ret) { - comp_update_buffer_consume(src_c, processed_data.source_bytes); + comp_update_buffer_consume(src_c, processed_data->source_bytes); + /* module copy case with endpoint_num == 0 or src_c as source buffer */ if (!cd->endpoint_num || cd->bsource_buffer) - cd->input_total_data_processed += processed_data.source_bytes; + cd->input_total_data_processed += processed_data->source_bytes; + } + + return ret; +} + +static int copier_module_copy(struct copier_data *cd, struct comp_dev *dev) +{ + struct comp_buffer __sparse_cache *src_c; + struct comp_copy_limits processed_data; + struct comp_buffer *src; + int ret; + + src = list_first_item(&dev->bsource_list, struct comp_buffer, sink_list); + src_c = buffer_acquire(src); + + ret = copier_copy_to_sinks(cd, dev, src_c, &processed_data); + + buffer_release(src_c); + + return ret; +} + +static int copier_multi_endpoint_dai_copy(struct copier_data *cd, struct comp_dev *dev) +{ + struct comp_buffer __sparse_cache *src_c, *sink_c; + struct comp_copy_limits processed_data; + struct comp_buffer *src; + int ret; + + processed_data.source_bytes = 0; + + if (!cd->bsource_buffer) { + /* gateway(s) as input */ + ret = dai_zephyr_multi_endpoint_copy(cd->dd, dev, cd->multi_endpoint_buffer, + cd->endpoint_num); + if (ret < 0) + return ret; + + src_c = buffer_acquire(cd->multi_endpoint_buffer); + ret = copier_copy_to_sinks(cd, dev, src_c, &processed_data); + buffer_release(src_c); + + return ret; + } + + /* component as input */ + if (list_is_empty(&dev->bsource_list)) { + comp_err(dev, "No source buffer bound"); + return -EINVAL; } + src = list_first_item(&dev->bsource_list, struct comp_buffer, sink_list); + src_c = buffer_acquire(src); + + /* gateway(s) on output */ + sink_c = buffer_acquire(cd->multi_endpoint_buffer); + ret = do_conversion_copy(dev, cd, src_c, sink_c, &processed_data); + buffer_release(sink_c); + + if (ret < 0) + goto err; + + ret = dai_zephyr_multi_endpoint_copy(cd->dd, dev, cd->multi_endpoint_buffer, + cd->endpoint_num); +err: buffer_release(src_c); return ret; @@ -550,30 +614,36 @@ static int do_multi_endpoint_module_copy(struct copier_data *cd, struct comp_dev */ static int copier_copy(struct comp_dev *dev) { - struct copier_data *cd = comp_get_drvdata(dev); + struct processing_module *mod = comp_get_drvdata(dev); + struct copier_data *cd = module_get_private_data(mod); comp_dbg(dev, "copier_copy()"); switch (dev->ipc_config.type) { case SOF_COMP_HOST: if (!cd->ipc_gtw) - return do_endpoint_copy(dev); - break; + return host_common_copy(cd->hd, dev, copier_host_dma_cb); + + /* do nothing in the gateway copier case */ + return 0; case SOF_COMP_DAI: if (cd->endpoint_num == 1) return dai_common_copy(cd->dd[0], dev, cd->converter); - break; + + return copier_multi_endpoint_dai_copy(cd, dev); default: break; } - /* handle multi-endpoint and module copy */ - return do_multi_endpoint_module_copy(cd, dev); + + /* module copier case */ + return copier_module_copy(cd, dev); } -/* configure the DMA params */ -static int copier_params(struct comp_dev *dev, struct sof_ipc_stream_params *params) +static int copier_mod_params(struct processing_module *mod) { - struct copier_data *cd = comp_get_drvdata(dev); + struct sof_ipc_stream_params *params = mod->stream_params; + struct copier_data *cd = module_get_private_data(mod); + struct comp_dev *dev = mod->dev; int i, ret = 0; comp_dbg(dev, "copier_params()"); @@ -603,11 +673,23 @@ static int copier_params(struct comp_dev *dev, struct sof_ipc_stream_params *par return ret; } +/* configure the DMA params */ +static int copier_params(struct comp_dev *dev, struct sof_ipc_stream_params *params) +{ + struct processing_module *mod = comp_get_drvdata(dev); + + /* will remove once fully convert to module interface in last patch */ + mod->stream_params = params; + + return copier_mod_params(mod); +} + static int copier_set_sink_fmt(struct comp_dev *dev, const void *data, int max_data_size) { const struct ipc4_copier_config_set_sink_format *sink_fmt = data; - struct copier_data *cd = comp_get_drvdata(dev); + struct processing_module *mod = comp_get_drvdata(dev); + struct copier_data *cd = module_get_private_data(mod); struct comp_buffer __sparse_cache *sink_c; struct list_item *sink_list; struct comp_buffer *sink; @@ -662,7 +744,8 @@ static int copier_set_sink_fmt(struct comp_dev *dev, const void *data, static int set_attenuation(struct comp_dev *dev, uint32_t data_offset, const char *data) { - struct copier_data *cd = comp_get_drvdata(dev); + struct processing_module *mod = comp_get_drvdata(dev); + struct copier_data *cd = module_get_private_data(mod); uint32_t attenuation; enum sof_ipc_frame valid_fmt, frame_fmt; @@ -694,22 +777,40 @@ static int set_attenuation(struct comp_dev *dev, uint32_t data_offset, const cha return 0; } +static int copier_set_configuration(struct processing_module *mod, + uint32_t config_id, + enum module_cfg_fragment_position pos, + uint32_t data_offset_size, + const uint8_t *fragment, size_t fragment_size, + uint8_t *response, + size_t response_size) +{ + struct comp_dev *dev = mod->dev; + + comp_dbg(dev, "copier_set_config()"); + + switch (config_id) { + case IPC4_COPIER_MODULE_CFG_PARAM_SET_SINK_FORMAT: + return copier_set_sink_fmt(dev, fragment, fragment_size); + case IPC4_COPIER_MODULE_CFG_ATTENUATION: + return set_attenuation(dev, fragment_size, fragment); + default: + return -EINVAL; + } +} + static int copier_set_large_config(struct comp_dev *dev, uint32_t param_id, bool first_block, bool last_block, uint32_t data_offset, const char *data) { + struct processing_module *mod = comp_get_drvdata(dev); + comp_dbg(dev, "copier_set_large_config()"); - switch (param_id) { - case IPC4_COPIER_MODULE_CFG_PARAM_SET_SINK_FORMAT: - return copier_set_sink_fmt(dev, data, data_offset); - case IPC4_COPIER_MODULE_CFG_ATTENUATION: - return set_attenuation(dev, data_offset, data); - default: - return -EINVAL; - } + return copier_set_configuration(mod, param_id, MODULE_CFG_FRAGMENT_SINGLE, + data_offset, data, data_offset, NULL, 0); } static inline void convert_u64_to_u32s(uint64_t val, uint32_t *val_l, uint32_t *val_h) @@ -718,21 +819,20 @@ static inline void convert_u64_to_u32s(uint64_t val, uint32_t *val_l, uint32_t * *val_h = (uint32_t)((val >> 32) & 0xffffffff); } -static int copier_get_large_config(struct comp_dev *dev, uint32_t param_id, - bool first_block, - bool last_block, - uint32_t *data_offset, - char *data) +static int copier_get_configuration(struct processing_module *mod, + uint32_t config_id, uint32_t *data_offset_size, + uint8_t *fragment, size_t fragment_size) { - struct copier_data *cd = comp_get_drvdata(dev); - struct sof_ipc_stream_posn posn; + struct copier_data *cd = module_get_private_data(mod); struct ipc4_llp_reading_extended llp_ext; + struct comp_dev *dev = mod->dev; + struct sof_ipc_stream_posn posn; struct ipc4_llp_reading llp; if (cd->ipc_gtw) return 0; - switch (param_id) { + switch (config_id) { case IPC4_COPIER_MODULE_CFG_PARAM_LLP_READING: if (!cd->endpoint_num || comp_get_endpoint_type(dev) != @@ -741,16 +841,16 @@ static int copier_get_large_config(struct comp_dev *dev, uint32_t param_id, return -EINVAL; } - if (*data_offset < sizeof(struct ipc4_llp_reading)) { - comp_err(dev, "Config size %d is inadequate", *data_offset); + if (*data_offset_size < sizeof(struct ipc4_llp_reading)) { + comp_err(dev, "Config size %d is inadequate", *data_offset_size); return -EINVAL; } - *data_offset = sizeof(struct ipc4_llp_reading); + *data_offset_size = sizeof(struct ipc4_llp_reading); memset(&llp, 0, sizeof(llp)); if (dev->state != COMP_STATE_ACTIVE) { - memcpy_s(data, sizeof(llp), &llp, sizeof(llp)); + memcpy_s(fragment, sizeof(llp), &llp, sizeof(llp)); return 0; } @@ -759,7 +859,7 @@ static int copier_get_large_config(struct comp_dev *dev, uint32_t param_id, convert_u64_to_u32s(posn.comp_posn, &llp.llp_l, &llp.llp_u); convert_u64_to_u32s(posn.wallclock, &llp.wclk_l, &llp.wclk_u); - memcpy_s(data, sizeof(llp), &llp, sizeof(llp)); + memcpy_s(fragment, sizeof(llp), &llp, sizeof(llp)); return 0; @@ -771,16 +871,16 @@ static int copier_get_large_config(struct comp_dev *dev, uint32_t param_id, return -EINVAL; } - if (*data_offset < sizeof(struct ipc4_llp_reading_extended)) { - comp_err(dev, "Config size %d is inadequate", *data_offset); + if (*data_offset_size < sizeof(struct ipc4_llp_reading_extended)) { + comp_err(dev, "Config size %d is inadequate", *data_offset_size); return -EINVAL; } - *data_offset = sizeof(struct ipc4_llp_reading_extended); + *data_offset_size = sizeof(struct ipc4_llp_reading_extended); memset(&llp_ext, 0, sizeof(llp_ext)); if (dev->state != COMP_STATE_ACTIVE) { - memcpy_s(data, sizeof(llp_ext), &llp_ext, sizeof(llp_ext)); + memcpy_s(fragment, sizeof(llp_ext), &llp_ext, sizeof(llp_ext)); return 0; } @@ -793,21 +893,33 @@ static int copier_get_large_config(struct comp_dev *dev, uint32_t param_id, &llp_ext.llp_reading.wclk_u); convert_u64_to_u32s(posn.dai_posn, &llp_ext.tpd_low, &llp_ext.tpd_high); - memcpy_s(data, sizeof(llp_ext), &llp_ext, sizeof(llp_ext)); + memcpy_s(fragment, sizeof(llp_ext), &llp_ext, sizeof(llp_ext)); return 0; default: - comp_err(dev, "unsupported param %d", param_id); + comp_err(dev, "unsupported param %d", config_id); break; } return -EINVAL; } +static int copier_get_large_config(struct comp_dev *dev, uint32_t param_id, + bool first_block, + bool last_block, + uint32_t *data_offset, + char *data) +{ + struct processing_module *mod = comp_get_drvdata(dev); + + return copier_get_configuration(mod, param_id, data_offset, data, 0); +} + static uint64_t copier_get_processed_data(struct comp_dev *dev, uint32_t stream_no, bool input) { - struct copier_data *cd = comp_get_drvdata(dev); + struct processing_module *mod = comp_get_drvdata(dev); + struct copier_data *cd = module_get_private_data(mod); uint64_t ret = 0; bool source; @@ -851,7 +963,8 @@ static uint64_t copier_get_processed_data(struct comp_dev *dev, uint32_t stream_ static int copier_get_attribute(struct comp_dev *dev, uint32_t type, void *value) { - struct copier_data *cd = comp_get_drvdata(dev); + struct processing_module *mod = comp_get_drvdata(dev); + struct copier_data *cd = module_get_private_data(mod); switch (type) { case COMP_ATTR_BASE_CONFIG: @@ -866,7 +979,8 @@ static int copier_get_attribute(struct comp_dev *dev, uint32_t type, void *value static int copier_position(struct comp_dev *dev, struct sof_ipc_stream_posn *posn) { - struct copier_data *cd = comp_get_drvdata(dev); + struct processing_module *mod = comp_get_drvdata(dev); + struct copier_data *cd = module_get_private_data(mod); int ret = 0; /* Exit if no endpoints */ @@ -893,7 +1007,8 @@ static int copier_position(struct comp_dev *dev, struct sof_ipc_stream_posn *pos static int copier_dai_ts_config_op(struct comp_dev *dev) { - struct copier_data *cd = comp_get_drvdata(dev); + struct processing_module *mod = comp_get_drvdata(dev); + struct copier_data *cd = module_get_private_data(mod); struct dai_data *dd = cd->dd[0]; return dai_common_ts_config_op(dd, dev); @@ -901,7 +1016,8 @@ static int copier_dai_ts_config_op(struct comp_dev *dev) static int copier_dai_ts_start_op(struct comp_dev *dev) { - struct copier_data *cd = comp_get_drvdata(dev); + struct processing_module *mod = comp_get_drvdata(dev); + struct copier_data *cd = module_get_private_data(mod); struct dai_data *dd = cd->dd[0]; comp_dbg(dev, "dai_ts_start()"); @@ -911,7 +1027,8 @@ static int copier_dai_ts_start_op(struct comp_dev *dev) static int copier_dai_ts_get_op(struct comp_dev *dev, struct timestamp_data *tsd) { - struct copier_data *cd = comp_get_drvdata(dev); + struct processing_module *mod = comp_get_drvdata(dev); + struct copier_data *cd = module_get_private_data(mod); struct dai_data *dd = cd->dd[0]; comp_dbg(dev, "dai_ts_get()"); @@ -921,7 +1038,8 @@ static int copier_dai_ts_get_op(struct comp_dev *dev, struct timestamp_data *tsd static int copier_dai_ts_stop_op(struct comp_dev *dev) { - struct copier_data *cd = comp_get_drvdata(dev); + struct processing_module *mod = comp_get_drvdata(dev); + struct copier_data *cd = module_get_private_data(mod); struct dai_data *dd = cd->dd[0]; comp_dbg(dev, "dai_ts_stop()"); @@ -932,7 +1050,8 @@ static int copier_dai_ts_stop_op(struct comp_dev *dev) static int copier_get_hw_params(struct comp_dev *dev, struct sof_ipc_stream_params *params, int dir) { - struct copier_data *cd = comp_get_drvdata(dev); + struct processing_module *mod = comp_get_drvdata(dev); + struct copier_data *cd = module_get_private_data(mod); struct dai_data *dd = cd->dd[0]; if (dev->ipc_config.type != SOF_COMP_DAI) @@ -941,9 +1060,10 @@ static int copier_get_hw_params(struct comp_dev *dev, struct sof_ipc_stream_para return dai_common_get_hw_params(dd, dev, params, dir); } -static int copier_unbind(struct comp_dev *dev, void *data) +static int copier_mod_unbind(struct processing_module *mod, void *data) { - struct copier_data *cd = comp_get_drvdata(dev); + struct copier_data *cd = module_get_private_data(mod); + struct comp_dev *dev = mod->dev; struct dai_data *dd = cd->dd[0]; if (dev->ipc_config.type == SOF_COMP_DAI) @@ -952,6 +1072,13 @@ static int copier_unbind(struct comp_dev *dev, void *data) return 0; } +static int copier_unbind(struct comp_dev *dev, void *data) +{ + struct processing_module *mod = comp_get_drvdata(dev); + + return copier_mod_unbind(mod, data); +} + static const struct comp_driver comp_copier = { .uid = SOF_RT_UUID(copier_comp_uuid), .tctx = &copier_comp_tr, diff --git a/src/audio/copier/copier_dai.c b/src/audio/copier/copier_dai.c index d7e1f49a34d5..8f8810e8d758 100644 --- a/src/audio/copier/copier_dai.c +++ b/src/audio/copier/copier_dai.c @@ -9,6 +9,7 @@ #include #include #include +#include LOG_MODULE_DECLARE(copier, CONFIG_SOF_LOG_LEVEL); @@ -34,7 +35,8 @@ static int copier_set_alh_multi_gtw_channel_map(struct comp_dev *parent_dev, const struct ipc4_copier_module_cfg *copier_cfg, int index) { - struct copier_data *cd = comp_get_drvdata(parent_dev); + struct processing_module *mod = comp_get_drvdata(parent_dev); + struct copier_data *cd = module_get_private_data(mod); const struct sof_alh_configuration_blob *alh_blob; uint8_t chan_bitmask; int channels; @@ -71,7 +73,8 @@ static int copier_dai_init(struct comp_dev *parent_dev, enum ipc4_gateway_type type, int index, int dai_count) { - struct copier_data *cd = comp_get_drvdata(parent_dev); + struct processing_module *mod = comp_get_drvdata(parent_dev); + struct copier_data *cd = module_get_private_data(mod); struct dai_data *dd; int ret; diff --git a/src/audio/copier/copier_host.c b/src/audio/copier/copier_host.c index 4b448045126d..78dbad237494 100644 --- a/src/audio/copier/copier_host.c +++ b/src/audio/copier/copier_host.c @@ -8,13 +8,15 @@ #include #include #include +#include LOG_MODULE_DECLARE(copier, CONFIG_SOF_LOG_LEVEL); /* Playback only */ static int init_pipeline_reg(struct comp_dev *dev) { - struct copier_data *cd = comp_get_drvdata(dev); + struct processing_module *mod = comp_get_drvdata(dev); + struct copier_data *cd = module_get_private_data(mod); struct ipc4_pipeline_registers pipe_reg; uint32_t gateway_id; @@ -125,7 +127,8 @@ void copier_host_free(struct copier_data *cd) */ void copier_host_dma_cb(struct comp_dev *dev, size_t bytes) { - struct copier_data *cd = comp_get_drvdata(dev); + struct processing_module *mod = comp_get_drvdata(dev); + struct copier_data *cd = module_get_private_data(mod); struct comp_buffer __sparse_cache *sink, *source; int ret, frames; diff --git a/src/audio/pipeline/pipeline-stream.c b/src/audio/pipeline/pipeline-stream.c index 3bb7bab2dc3a..6fe795cf54f5 100644 --- a/src/audio/pipeline/pipeline-stream.c +++ b/src/audio/pipeline/pipeline-stream.c @@ -23,6 +23,7 @@ #include #include #include +#include LOG_MODULE_DECLARE(pipe, CONFIG_SOF_LOG_LEVEL); @@ -330,7 +331,8 @@ static int pipeline_comp_trigger(struct comp_dev *current, #if CONFIG_IPC_MAJOR_3 dd = comp_get_drvdata(current); #elif CONFIG_IPC_MAJOR_4 - struct copier_data *cd = comp_get_drvdata(current); + struct processing_module *mod = comp_get_drvdata(current); + struct copier_data *cd = module_get_private_data(mod); dd = cd->dd[0]; #else