-
Notifications
You must be signed in to change notification settings - Fork 350
dai: uaol: add support for Intel UAOL (includes west.yml Zephyr update) #10567
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -24,6 +24,10 @@ | |
| #include <sof/lib/memory.h> | ||
| #include <sof/lib_manager.h> | ||
|
|
||
| #if CONFIG_UAOL_INTEL_ADSP | ||
| #include <zephyr/drivers/uaol.h> | ||
| #endif | ||
|
|
||
| #include <ipc4/base_fw.h> | ||
| #include <ipc4/alh.h> | ||
| #include <rimage/sof/user/manifest.h> | ||
|
|
@@ -41,6 +45,23 @@ struct ipc4_modules_info { | |
| /* Sanity check because a subtraction of those sizes is performed later on */ | ||
| STATIC_ASSERT(sizeof(struct ipc4_modules_info) < SOF_IPC_MSG_MAX_SIZE, | ||
| invalid_modules_info_struct_size); | ||
|
|
||
| #if CONFIG_UAOL_INTEL_ADSP | ||
| struct ipc4_uaol_link_capabilities { | ||
| uint32_t input_streams_supported : 4; | ||
| uint32_t output_streams_supported : 4; | ||
| uint32_t bidirectional_streams_supported : 5; | ||
| uint32_t rsvd : 19; | ||
| uint32_t max_tx_fifo_size; | ||
| uint32_t max_rx_fifo_size; | ||
| } __packed __aligned(4); | ||
|
|
||
| struct ipc4_uaol_capabilities { | ||
| uint32_t link_count; | ||
| struct ipc4_uaol_link_capabilities link_caps[]; | ||
| } __packed __aligned(4); | ||
| #endif /* CONFIG_UAOL_INTEL_ADSP */ | ||
|
|
||
| /* | ||
| * TODO: default to value of ACE1.x platforms. This is defined | ||
| * in multiple places in Zephyr, mm_drv_intel_adsp.h and | ||
|
|
@@ -71,7 +92,7 @@ __cold int basefw_vendor_fw_config(uint32_t *data_offset, char *data) | |
| tlv_value_uint32_set(tuple, IPC4_SLOW_CLOCK_FREQ_HZ_FW_CFG, IPC4_ALH_CAVS_1_8); | ||
|
|
||
| tuple = tlv_next(tuple); | ||
| tlv_value_uint32_set(tuple, IPC4_UAOL_SUPPORT, 0); | ||
| tlv_value_uint32_set(tuple, IPC4_UAOL_SUPPORT, IS_ENABLED(CONFIG_UAOL_INTEL_ADSP)); | ||
|
|
||
| tuple = tlv_next(tuple); | ||
| tlv_value_uint32_set(tuple, IPC4_ALH_SUPPORT_LEVEL_FW_CFG, IPC4_ALH_CAVS_1_8); | ||
|
|
@@ -82,6 +103,55 @@ __cold int basefw_vendor_fw_config(uint32_t *data_offset, char *data) | |
| return 0; | ||
| } | ||
|
|
||
| #if CONFIG_UAOL_INTEL_ADSP | ||
| #define DEV_AND_COMMA(node) DEVICE_DT_GET(node), | ||
| static const struct device *uaol_devs[] = { | ||
| DT_FOREACH_STATUS_OKAY(intel_adsp_uaol, DEV_AND_COMMA) | ||
| }; | ||
|
|
||
| static void tlv_value_set_uaol_caps(struct sof_tlv *tuple, uint32_t type) | ||
| { | ||
| const size_t dev_count = ARRAY_SIZE(uaol_devs); | ||
| struct uaol_capabilities dev_cap; | ||
| struct ipc4_uaol_capabilities *caps = (struct ipc4_uaol_capabilities *)tuple->value; | ||
| size_t caps_size = offsetof(struct ipc4_uaol_capabilities, link_caps[dev_count]); | ||
| size_t i; | ||
| int ret; | ||
|
|
||
| memset(caps, 0, caps_size); | ||
|
|
||
| caps->link_count = dev_count; | ||
| for (i = 0; i < dev_count; i++) { | ||
| ret = uaol_get_capabilities(uaol_devs[i], &dev_cap); | ||
| if (ret) | ||
| continue; | ||
|
|
||
| caps->link_caps[i].input_streams_supported = dev_cap.input_streams; | ||
| caps->link_caps[i].output_streams_supported = dev_cap.output_streams; | ||
| caps->link_caps[i].bidirectional_streams_supported = dev_cap.bidirectional_streams; | ||
| caps->link_caps[i].max_tx_fifo_size = dev_cap.max_tx_fifo_size; | ||
| caps->link_caps[i].max_rx_fifo_size = dev_cap.max_rx_fifo_size; | ||
| } | ||
|
|
||
| tlv_value_set(tuple, type, caps_size, caps); | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not related to this PR, but reminds me we'd to add better protections against overrunning the IPC mailbox size. The overall length of the TLV is not known in these functions now, and it will be difficult to debug if we excedeed the space. Most of these are by definition ok as the structure is fixed and defined in FW. |
||
| } | ||
|
|
||
| static int uaol_stream_id_to_hda_link_stream_id(int uaol_stream_id) | ||
| { | ||
| size_t dev_count = ARRAY_SIZE(uaol_devs); | ||
| size_t i; | ||
|
|
||
| for (i = 0; i < dev_count; i++) { | ||
| int hda_link_stream_id = uaol_get_mapped_hda_link_stream_id(uaol_devs[i], | ||
| uaol_stream_id); | ||
| if (hda_link_stream_id >= 0) | ||
| return hda_link_stream_id; | ||
| } | ||
|
|
||
| return -1; | ||
| } | ||
| #endif /* CONFIG_UAOL_INTEL_ADSP */ | ||
|
|
||
| __cold int basefw_vendor_hw_config(uint32_t *data_offset, char *data) | ||
| { | ||
| struct sof_tlv *tuple = (struct sof_tlv *)data; | ||
|
|
@@ -124,6 +194,11 @@ __cold int basefw_vendor_hw_config(uint32_t *data_offset, char *data) | |
| tlv_value_set(tuple, IPC4_INTEL_MIC_PRIVACY_CAPS_HW_CFG, sizeof(priv_caps), &priv_caps); | ||
| #endif | ||
|
|
||
| #if CONFIG_UAOL_INTEL_ADSP | ||
| tuple = tlv_next(tuple); | ||
| tlv_value_set_uaol_caps(tuple, IPC4_UAOL_CAPS_HW_CFG); | ||
| #endif | ||
|
|
||
| tuple = tlv_next(tuple); | ||
| *data_offset = (int)((char *)tuple - data); | ||
|
|
||
|
|
@@ -454,6 +529,7 @@ __cold int basefw_vendor_set_large_config(struct comp_dev *dev, uint32_t param_i | |
| __cold int basefw_vendor_dma_control(uint32_t node_id, const char *config_data, size_t data_size) | ||
| { | ||
| union ipc4_connector_node_id node = (union ipc4_connector_node_id)node_id; | ||
| int dai_index = node.f.v_index; | ||
| int ret, result; | ||
| enum sof_ipc_dai_type type; | ||
|
|
||
|
|
@@ -477,11 +553,25 @@ __cold int basefw_vendor_dma_control(uint32_t node_id, const char *config_data, | |
| case ipc4_i2s_link_input_class: | ||
| type = SOF_DAI_INTEL_SSP; | ||
| break; | ||
|
|
||
| #if CONFIG_UAOL_INTEL_ADSP | ||
| case ipc4_alh_uaol_stream_link_output_class: | ||
| case ipc4_alh_uaol_stream_link_input_class: | ||
| type = SOF_DAI_INTEL_UAOL; | ||
| dai_index = uaol_stream_id_to_hda_link_stream_id(node.f.v_index); | ||
| if (dai_index < 0) { | ||
| tr_err(&basefw_comp_tr, | ||
| "HDA link stream not found! UAOL node ID: 0x%x", node_id); | ||
| return IPC4_INVALID_RESOURCE_ID; | ||
| } | ||
| break; | ||
| #endif | ||
|
|
||
| default: | ||
| return IPC4_INVALID_RESOURCE_ID; | ||
| } | ||
|
|
||
| const struct device *dev = dai_get_device(type, node.f.v_index); | ||
| const struct device *dev = dai_get_device(type, dai_index); | ||
|
|
||
| if (!dev) { | ||
| tr_err(&basefw_comp_tr, | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -60,6 +60,12 @@ void dai_set_link_hda_config(uint16_t *link_config, | |
| } | ||
| link_cfg.part.stream = common_config->host_dma_config[0]->stream_id; | ||
| break; | ||
| case SOF_DAI_INTEL_UAOL: | ||
| link_cfg.full = 0; | ||
| link_cfg.part.hchan = gtw_fmt->channels_count - 1; | ||
| link_cfg.part.dir = common_config->direction; | ||
| link_cfg.part.stream = common_config->host_dma_config[0]->stream_id; | ||
| break; | ||
|
Comment on lines
+63
to
+68
|
||
| default: | ||
| /* other types of DAIs not need link_config */ | ||
| return; | ||
|
|
@@ -112,6 +118,13 @@ int dai_config_dma_channel(struct dai_data *dd, struct comp_dev *dev, const void | |
| */ | ||
| channel = 0; | ||
| break; | ||
| #if ACE_VERSION > ACE_VERSION_1_5 | ||
| case SOF_DAI_INTEL_UAOL: | ||
| channel = 0; | ||
| if (dai->host_dma_config[0]->pre_allocated_by_host) | ||
| channel = dai->host_dma_config[0]->dma_channel_id; | ||
| break; | ||
| #endif | ||
| default: | ||
| /* other types of DAIs not handled for now */ | ||
| comp_err(dev, "Unknown dai type %d", dai->type); | ||
|
|
@@ -173,6 +186,8 @@ int ipc_dai_data_config(struct dai_data *dd, struct comp_dev *dev) | |
| comp_dbg(dev, "dai_data_config() SOF_DAI_INTEL_ALH dev->ipc_config.frame_fmt: %d, stream_id: %d", | ||
| dev->ipc_config.frame_fmt, dd->stream_id); | ||
|
|
||
| break; | ||
| case SOF_DAI_INTEL_UAOL: | ||
| break; | ||
| default: | ||
| /* other types of DAIs not handled for now */ | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -43,7 +43,7 @@ manifest: | |
|
|
||
| - name: zephyr | ||
| repo-path: zephyr | ||
| revision: 653ebccc49ad1f79cae2729f4c6fabd5ff54d397 | ||
| revision: c8b9adaec98778767d00a41bbb395eabe9f4985e | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. could you please update to latest Zephyr version? |
||
| remote: zephyrproject | ||
|
|
||
| # Import some projects listed in zephyr/west.yml@revision | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
offsetof(struct ..., link_caps[dev_count])uses a non-constant array index; this is not valid with standardoffsetof/__builtin_offsetofand can fail to compile. Compute the size assizeof(*caps) + dev_count * sizeof(caps->link_caps[0])(or the equivalent using the element type) instead.