-
Notifications
You must be signed in to change notification settings - Fork 349
[Temporarily Inactive] zephyr: alh: add ALH zephyr driver #5727
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
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| # SPDX-License-Identifier: BSD-3-Clause | ||
|
|
||
| add_local_sources(sof alh.c) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,156 @@ | ||
| // SPDX-License-Identifier: BSD-3-Clause | ||
| // | ||
| // Copyright(c) 2022 Intel Corporation. All rights reserved. | ||
| // | ||
| // Author: Adrian Bonislawski <adrian.bonislawski@intel.com> | ||
|
|
||
| #include <sof/audio/component.h> | ||
| #include <sof/lib/dai.h> | ||
| #include <sof/lib/dma.h> | ||
| #include <sof/lib/memory.h> | ||
| #include <sof/lib/uuid.h> | ||
| #include <sof/trace/trace.h> | ||
| #include <sof/common.h> | ||
| #include <ipc/dai.h> | ||
| #include <ipc/stream.h> | ||
| #include <ipc/topology.h> | ||
| #include <user/trace.h> | ||
| #include <stdint.h> | ||
| #include <ipc4/alh.h> | ||
|
|
||
| /* zephyr dai driver */ | ||
| #include <drivers/dai.h> | ||
|
|
||
| /* a8e4218c-e863-4c93-84e7-5c27d2504501 */ | ||
| DECLARE_SOF_UUID("alh-dai", alh_uuid, 0xa8e4218c, 0xe863, 0x4c93, | ||
| 0x84, 0xe7, 0x5c, 0x27, 0xd2, 0x50, 0x45, 0x01); | ||
|
|
||
| DECLARE_TR_CTX(alh_tr, SOF_UUID(alh_uuid), LOG_LEVEL_INFO); | ||
|
|
||
| static int alh_trigger_zephyr(struct dai *dai, int cmd, int direction) | ||
| { | ||
| enum dai_trigger_cmd cmd_z; | ||
|
|
||
| switch(cmd) { | ||
| case COMP_TRIGGER_STOP: | ||
| cmd_z = DAI_TRIGGER_STOP; | ||
| break; | ||
| case COMP_TRIGGER_START: | ||
| case COMP_TRIGGER_RELEASE: | ||
| cmd_z = DAI_TRIGGER_START; | ||
| break; | ||
| case COMP_TRIGGER_PAUSE: | ||
| cmd_z = DAI_TRIGGER_PAUSE; | ||
| break; | ||
| case COMP_TRIGGER_PRE_START: | ||
| case COMP_TRIGGER_PRE_RELEASE: | ||
| cmd_z = DAI_TRIGGER_PRE_START; | ||
| break; | ||
| default: | ||
| return -EINVAL; | ||
| } | ||
|
|
||
| return dai_trigger(dai->z_drv, direction, cmd_z); | ||
| } | ||
|
|
||
| static int alh_set_config_zephyr(struct dai *dai, struct ipc_config_dai *common_config, | ||
| void *spec_config) | ||
| { | ||
| struct sof_ipc_dai_config *sof_cfg; | ||
| struct dai_config cfg; | ||
|
|
||
| sof_cfg = (struct sof_ipc_dai_config *)spec_config; | ||
| cfg.dai_index = common_config->dai_index; | ||
| cfg.format = sof_cfg->format; | ||
| cfg.options = sof_cfg->flags; | ||
|
|
||
| if(common_config->is_config_blob) { | ||
| cfg.type = DAI_INTEL_ALH_NHLT; | ||
| return dai_config_set(dai->z_drv, &cfg, spec_config); | ||
| } else { | ||
| cfg.type = DAI_INTEL_ALH; | ||
| return dai_config_set(dai->z_drv, &cfg, &sof_cfg->alh); | ||
| } | ||
| } | ||
|
|
||
| static int alh_get_hw_params_zephyr(struct dai *dai, struct sof_ipc_stream_params *params, int dir) | ||
| { | ||
| const struct dai_config *cfg; | ||
|
|
||
| cfg = dai_config_get(dai->z_drv, dir); | ||
|
|
||
| params->rate = cfg->rate; | ||
| params->buffer_fmt = 0; | ||
| params->channels = cfg->channels; | ||
|
|
||
| switch (cfg->word_size) { | ||
| case 16: | ||
| params->frame_fmt = SOF_IPC_FRAME_S16_LE; | ||
| break; | ||
| case 24: | ||
| params->frame_fmt = SOF_IPC_FRAME_S24_4LE; | ||
| break; | ||
| case 32: | ||
| params->frame_fmt = SOF_IPC_FRAME_S32_LE; | ||
| break; | ||
| default: | ||
| dai_warn(dai,"%d not supported format", cfg->word_size); | ||
| } | ||
|
|
||
| return 0; | ||
| } | ||
|
|
||
| static int alh_get_handshake_zephyr(struct dai *dai, int direction, int stream_id) | ||
| { | ||
| const struct dai_properties *props; | ||
|
|
||
| props = dai_get_properties(dai->z_drv, direction, stream_id); | ||
|
|
||
| return props->dma_hs_id; | ||
| } | ||
|
|
||
| static int alh_get_fifo_zephyr(struct dai *dai, int direction, int stream_id) | ||
| { | ||
| const struct dai_properties *props; | ||
|
|
||
| props = dai_get_properties(dai->z_drv, direction, stream_id); | ||
|
|
||
| return props->fifo_address; | ||
| } | ||
|
|
||
| static int alh_get_stream_id_zephyr(struct dai *dai, int direction) | ||
| { | ||
| const struct dai_properties *props; | ||
|
|
||
| props = dai_get_properties(dai->z_drv, direction, 0); | ||
|
|
||
| return props->stream_id; | ||
| } | ||
|
|
||
| static int alh_probe_zephyr(struct dai *dai) | ||
| { | ||
| return dai_probe(dai->z_drv); | ||
| } | ||
|
|
||
| static int alh_remove_zephyr(struct dai *dai) | ||
| { | ||
| return dai_remove(dai->z_drv); | ||
| } | ||
|
|
||
| const struct dai_driver alh_driver = { | ||
| .type = SOF_DAI_INTEL_ALH, | ||
| .uid = SOF_UUID(alh_uuid), | ||
| .tctx = &alh_tr, | ||
| .dma_caps = DMA_CAP_GP_LP | DMA_CAP_GP_HP, | ||
| .dma_dev = DMA_DEV_ALH, | ||
| .ops = { | ||
| .trigger = alh_trigger_zephyr, | ||
| .set_config = alh_set_config_zephyr, | ||
| .get_hw_params = alh_get_hw_params_zephyr, | ||
| .get_handshake = alh_get_handshake_zephyr, | ||
| .get_fifo = alh_get_fifo_zephyr, | ||
| .get_stream_id = alh_get_stream_id_zephyr, | ||
| .probe = alh_probe_zephyr, | ||
| .remove = alh_remove_zephyr, | ||
| }, | ||
| }; | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -68,7 +68,6 @@ int ipc_dai_data_config(struct comp_dev *dev) | |
| struct ipc_config_dai *dai = &dd->ipc_config; | ||
| struct ipc4_copier_module_cfg *copier_cfg; | ||
| struct dai *dai_p = dd->dai; | ||
| struct alh_pdata *alh; | ||
|
|
||
| if (!dai) { | ||
| comp_err(dev, "dai_data_config(): no dai!\n"); | ||
|
|
@@ -100,20 +99,18 @@ int ipc_dai_data_config(struct comp_dev *dev) | |
| case SOF_DAI_INTEL_HDA: | ||
| break; | ||
| case SOF_DAI_INTEL_ALH: | ||
| alh = dai_get_drvdata(dai_p); | ||
| /* SDW HW FIFO always requires 32bit MSB aligned sample data for | ||
| * all formats, such as 8/16/24/32 bits. | ||
| */ | ||
| dev->ipc_config.frame_fmt = SOF_IPC_FRAME_S32_LE; | ||
| dd->dma_buffer->stream.frame_fmt = dev->ipc_config.frame_fmt; | ||
|
|
||
| dd->config.burst_elems = | ||
| dd->dai->plat_data.fifo[dai->direction].depth; | ||
| dd->config.burst_elems = ALH_GPDMA_BURST_LENGTH; | ||
|
|
||
| /* As with HDA, the DMA channel is assigned in runtime, | ||
| * not during topology parsing. | ||
| */ | ||
| dd->stream_id = alh->params.stream_id; | ||
| dd->stream_id = dai_get_stream_id(dai_p, 0);//alh->params.stream_id; | ||
|
Member
Author
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. Temporarily added dai_get_stream_id, not sure if this is the correct approach (feel free to comment) but we need to address this as alh private data was used here |
||
|
|
||
| comp_dbg(dev, "dai_data_config() SOF_DAI_INTEL_ALH dd->dma_buffer->stream.frame_fmt %#x stream_id %d", | ||
| dd->dma_buffer->stream.frame_fmt, dd->stream_id); | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
indentation - like in SSP