Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 367
hw hda chain managment#6624
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Uh oh!
There was an error while loading. Please reload this page.
hw hda chain managment #6624
Changes from all commits
d725d3bfb631084fd043d07148729fbcce1c24359a071f46c3216d4579289e0File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -6,4 +6,5 @@ add_local_sources(sof | ||
| pipeline-params.c | ||
| pipeline-xrun.c | ||
| pipeline-schedule.c | ||
| chain_dma.c | ||
| ) | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,80 @@ | ||
| #include <sof/audio/chain_dma.h> | ||
| #include <ipc4/error_status.h> | ||
| #include <ipc4/module.h> | ||
| /* 6a0a274f-27cc-4afb-a3e7-3444723f432e */ | ||
| DECLARE_SOF_RT_UUID("chain_dma", chain_dma_uuid, 0x6a0a274f, 0x27cc, 0x4afb, | ||
| 0xa3, 0xe7, 0x34, 0x44, 0x72, 0x3f, 0x43, 0x2e); | ||
| DECLARE_TR_CTX(chain_dma_tr, SOF_UUID(chain_dma_uuid), LOG_LEVEL_INFO); | ||
| int chain_dma_start(struct comp_dev *dev, uint8_t host_dma_id) | ||
| { | ||
| return IPC4_SUCCESS; | ||
| } | ||
| int chain_dma_pause(struct comp_dev *dev, uint8_t host_dma_id) | ||
| { | ||
| return IPC4_SUCCESS; | ||
| } | ||
| int chain_dma_trigger(struct comp_dev *dev, int cmd) | ||
| { | ||
| switch (cmd) { | ||
| case COMP_TRIGGER_START: | ||
| chain_dma_start(dev, cmd); | ||
| break; | ||
| case COMP_TRIGGER_PAUSE: | ||
| chain_dma_pause(dev, cmd); | ||
| break; | ||
| default: | ||
| return 0; | ||
| } | ||
| return IPC4_SUCCESS; | ||
| } | ||
| int chain_dma_remove(struct comp_dev *dev, uint8_t host_dma_id) | ||
| { | ||
| return IPC4_SUCCESS; | ||
| } | ||
| int chain_dma_create(const struct comp_driver *drv, uint8_t host_dma_id, uint8_t link_dma_id, uint32_t fifo_size, bool scs) | ||
| { | ||
| struct comp_dev *dev; | ||
| dev = comp_alloc(drv, sizeof(*dev)); | ||
| if (!dev) | ||
| return IPC4_INVALID_REQUEST; | ||
| int comp_id = IPC4_COMP_ID(host_dma_id + IPC4_MAX_MODULE_COUNT, | ||
| link_dma_id); | ||
| struct chain_dma_data *cd = comp_get_drvdata(dev); | ||
| size_t size = sizeof(*cd); | ||
| cd = rzalloc(SOF_MEM_ZONE_RUNTIME, 0, SOF_MEM_CAPS_RAM, size); | ||
| return IPC4_SUCCESS; | ||
| } | ||
| static const struct comp_driver comp_chain_dma = { | ||
| .type = SOF_COMP_CHAIN_DMA, | ||
| .uid = SOF_RT_UUID(chain_dma_uuid), | ||
| .tctx = &chain_dma_tr, | ||
| .ops = { | ||
| .chain_dma_create = chain_dma_create, | ||
| .trigger = chain_dma_trigger, | ||
| .free = chain_dma_remove, | ||
| }, | ||
| }; | ||
| static SHARED_DATA struct comp_driver_info comp_chain_dma_info = { | ||
| .drv = &comp_chain_dma, | ||
| }; | ||
| static void sys_comp_chain_dma_init(void) | ||
| { | ||
| comp_register(platform_shared_get(&comp_chain_dma_info, | ||
| sizeof(comp_chain_dma_info))); | ||
| } | ||
| DECLARE_MODULE(sys_comp_chain_dma_init); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| #include <sof/audio/buffer.h> | ||
| #include <sof/audio/component.h> | ||
| #include <sof/audio/component_ext.h> | ||
| #include <sof/audio/pipeline.h> | ||
| #include <sof/common.h> | ||
| #include <sof/ipc/topology.h> | ||
| #include <sof/ipc/common.h> | ||
| #include <ipc/dai.h> | ||
| static const uint32_t MAX_CHAIN_NUMBER = DAI_NUM_HDA_OUT + DAI_NUM_HDA_IN; | ||
| /* chain dma component private data */ | ||
| struct chain_dma_data { | ||
| bool first_data_received_; | ||
| //! Node id of host HD/A DMA | ||
| uint32_t output_node_id_; | ||
| //! Node id of link HD/A DMA | ||
| uint32_t input_node_id_; | ||
| uint32_t* hw_buffer_; | ||
| bool under_over_run_notification_sent_; | ||
| }; | ||
| int chain_dma_create(const struct comp_driver *drv, uint8_t host_dma_id, uint8_t link_dma_id, uint32_t fifo_size, bool scs); | ||
| int chain_dma_start(struct comp_dev *dev, uint8_t host_dma_id); | ||
| int chain_dma_pause(struct comp_dev *dev, uint8_t host_dma_id); | ||
| int chain_dma_remove(struct comp_dev *dev, uint8_t host_dma_id); | ||
| int chain_dma_trigger(struct comp_dev *dev, int cmd); | ||
| void SetReadPointer(uint32_t read_pointer); | ||
| void SetWritePointer(uint32_t write_pointer); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -14,6 +14,7 @@ | ||
| #include <sof/audio/buffer.h> | ||
| #include <sof/audio/component_ext.h> | ||
| #include <sof/audio/pipeline.h> | ||
| #include <sof/audio/chain_dma.h> | ||
| #include <sof/common.h> | ||
| #include <sof/ipc/topology.h> | ||
| #include <sof/ipc/common.h> | ||
| @@ -458,36 +459,101 @@ static int ipc4_load_library(struct ipc4_message_request *ipc4) | ||
| } | ||
| #endif | ||
| #include "sof/mem_win_debug.h" | ||
| static int ipc4_process_chain_dma(struct ipc4_message_request *ipc4) | ||
| { | ||
| struct sof_uuid uuid = {0x6a0a274f, 0x27cc, 0x4afb, {0xa3, 0xe7, 0x34, | ||
| 0x44, 0x72, 0x3f, 0x43, 0x2e}}; | ||
| struct ipc4_chain_dma cdma; | ||
| struct ipc *ipc = ipc_get(); | ||
| int ret; | ||
| int ret = IPC4_INVALID_REQUEST; | ||
| memcpy_s(&cdma, sizeof(cdma), ipc4, sizeof(cdma)); | ||
| if (cdma.primary.r.allocate && cdma.extension.r.fifo_size) { | ||
| ret = ipc4_create_chain_dma(ipc, &cdma); | ||
| if (ret) { | ||
| tr_err(&ipc_tr, "failed to create chain dma %d", ret); | ||
| return ret; | ||
| } | ||
| /* if enable is not set, chain dma pipeline is not going to be triggered */ | ||
| if (!cdma.primary.r.enable) | ||
| return ret; | ||
| } | ||
| atomic_set(&msg_data.delayed_reply, 1); | ||
| ret = ipc4_trigger_chain_dma(ipc, &cdma); | ||
| /* it is not scheduled in another thread */ | ||
| if (ret != PPL_STATUS_SCHEDULED) { | ||
| atomic_set(&msg_data.delayed_reply, 0); | ||
| msg_data.delayed_error = 0; | ||
| } else { | ||
| ret = 0; | ||
| } | ||
| const uint8_t link_dma_id = cdma.primary.r.link_dma_id; | ||
| const uint8_t host_dma_id = cdma.primary.r.host_dma_id; | ||
| const uint32_t fifo_size = cdma.extension.r.fifo_size; | ||
| const bool allocate = cdma.primary.r.allocate; | ||
| const bool enable = cdma.primary.r.enable; | ||
| const bool scs = cdma.primary.r.scs; | ||
| MEM_WIN_DEBUG0(0xaaa0,0,0,0); | ||
| int comp_id = IPC4_COMP_ID(host_dma_id + IPC4_MAX_MODULE_COUNT, | ||
| link_dma_id); | ||
| if (allocate) | ||
| { | ||
makarukp marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| ret = ipc4_create_io_driver_for_chain(&cdma); | ||
| struct ipc_comp_dev* cdma_comp = ipc_get_comp_by_id(ipc, comp_id); | ||
| MEM_WIN_DEBUG0(0xaab0,cdma_comp,0,0); | ||
makarukp marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| assert(cdma_comp != NULL); | ||
makarukp marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| if(ret == IPC4_SUCCESS || ret == IPC4_INVALID_CHAIN_STATE_TRANSITION) | ||
| { | ||
| // valid ret code. | ||
| } | ||
| else | ||
| { | ||
| return IPC4_INVALID_REQUEST; | ||
| } | ||
| const struct comp_driver *drv; | ||
| drv = ipc4_get_drv((uint8_t *)&uuid); | ||
| MEM_WIN_DEBUG0(0xaab1,drv,0,0); | ||
| assert(drv != NULL); | ||
| if (enable) | ||
| { | ||
| drv->ops.trigger(cdma_comp->cd, COMP_TRIGGER_START); | ||
| } | ||
| else | ||
| { | ||
| drv->ops.trigger(cdma_comp->cd, COMP_TRIGGER_PAUSE); | ||
| } | ||
| MEM_WIN_DEBUG0(0xaab2,drv,0,0); | ||
| } | ||
| else | ||
| { | ||
| const struct comp_driver *drv; | ||
| drv = ipc4_get_drv((uint8_t *)&uuid); | ||
| struct ipc_comp_dev* cdma_comp = ipc_get_comp_by_id(ipc, comp_id); | ||
| if (enable) | ||
| { | ||
| return IPC4_INVALID_REQUEST; | ||
makarukp marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| } | ||
| else | ||
| { | ||
| //ret = chain_dma_mgr->PauseChain(host_dma_id); | ||
| drv->ops.trigger(cdma_comp->cd, COMP_TRIGGER_PAUSE); | ||
| } | ||
| if (ret == IPC4_SUCCESS) | ||
| { | ||
| //ret = chain_dma_mgr->RemoveChain(host_dma_id); | ||
| drv->ops.free(cdma_comp->cd); | ||
| } | ||
| } | ||
| //PREVIOUS IMPLEMENTATION | ||
makarukp marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| // if (cdma.primary.r.allocate && cdma.extension.r.fifo_size) { | ||
| // ret = ipc4_create_chain_dma(ipc, &cdma); | ||
| // if (ret) { | ||
| // tr_err(&ipc_tr, "failed to create chain dma %d", ret); | ||
| // return ret; | ||
| // } | ||
| // /* if enable is not set, chain dma pipeline is not going to be triggered */ | ||
| // if (!cdma.primary.r.enable) | ||
| // return ret; | ||
| // } | ||
| // atomic_set(&msg_data.delayed_reply, 1); | ||
| // ret = ipc4_trigger_chain_dma(ipc, &cdma); | ||
| // /* it is not scheduled in another thread */ | ||
| // if (ret != PPL_STATUS_SCHEDULED) { | ||
| // atomic_set(&msg_data.delayed_reply, 0); | ||
| // msg_data.delayed_error = 0; | ||
| // } else { | ||
| // ret = 0; | ||
| // } | ||
| MEM_WIN_DEBUG0(0xaaa1,0,0,0); | ||
| return ret; | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.