Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions app/boards/acp_7_x_adsp.conf
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ CONFIG_INTC_AMD_ACP=y
CONFIG_DMA_AMD_ACP_HOST=y
CONFIG_DMA_AMD_ACP_SDW=y
CONFIG_DMA_AMD_ACP_SDW_CHANNEL_COUNT=64
CONFIG_DMA_AMD_ACP_TDM=y
CONFIG_DAI_AMD_SDW=y
CONFIG_DAI_AMD_TDM=y
CONFIG_AMS=n
CONFIG_WRAP_ACTUAL_POSITION=y
CONFIG_TRACE=n
Expand Down
4 changes: 4 additions & 0 deletions src/audio/dai-zephyr.c
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,10 @@ __cold int dai_set_config(struct dai *dai, struct ipc_config_dai *common_config,
cfg.type = DAI_AMD_SDW;
cfg_params = &sof_cfg->acpsdw;
break;
case SOF_DAI_AMD_TDM:
cfg.type = DAI_AMD_TDM;
cfg_params = &sof_cfg->acptdm;
break;
case SOF_DAI_INTEL_UAOL:
cfg.type = DAI_INTEL_UAOL;
cfg.channels = common_config->gtw_fmt->channels_count;
Expand Down
1 change: 1 addition & 0 deletions src/include/ipc/dai-amd.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ struct sof_ipc_dai_acp_params {
uint32_t reserved0;
uint32_t fsync_rate;
uint32_t tdm_slots;
uint32_t format;
} __attribute__((packed, aligned(4)));

/* ACP Configuration Request - SOF_IPC_DAI_AMD_SDW_CONFIG */
Expand Down
2 changes: 2 additions & 0 deletions src/include/ipc/dai.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ enum sof_ipc_dai_type {
SOF_DAI_IMX_MICFIL, /**< i.MX MICFIL */
SOF_DAI_AMD_SDW, /**< Amd SDW */
SOF_DAI_INTEL_UAOL, /**< Intel UAOL */
SOF_DAI_AMD_TDM /**< Amd TDM */
};

#define SOF_DAI_CONFIG_HW_SPEC_OFFSET offsetof(struct sof_ipc_dai_config, ssp)
Expand Down Expand Up @@ -130,6 +131,7 @@ struct sof_ipc_dai_config {
struct sof_ipc_dai_afe_params afe;
struct sof_ipc_dai_micfil_params micfil;
struct sof_ipc_dai_acp_sdw_params acpsdw;
struct sof_ipc_dai_acp_params acptdm;
};
} __attribute__((packed, aligned(4)));

Expand Down
35 changes: 35 additions & 0 deletions src/ipc/ipc3/dai.c
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ int dai_config_dma_channel(struct dai_data *dd, struct comp_dev *dev, const void
break;
case SOF_DAI_AMD_HS:
case SOF_DAI_AMD_HS_VIRTUAL:
case SOF_DAI_AMD_TDM:
case SOF_DAI_AMD_SDW: {
struct dai_config *params = (struct dai_config *)dd->dai->dev->config;

Expand Down Expand Up @@ -197,6 +198,40 @@ int ipc_dai_data_config(struct dai_data *dd, struct comp_dev *dev)
audio_stream_set_frm_fmt(&dd->dma_buffer->stream,
dev->ipc_config.frame_fmt);
break;
case SOF_DAI_AMD_TDM:
#if defined(CONFIG_AMD) && defined(CONFIG_SOC_ACP_7_X)
{
struct acp_dma_dev_data *tdm_dev_data = dd->dma->z_dev->data;
struct tdm_context *tdm_ctx;

/* AMD TDM HW needs 24-bit data MSB-aligned in 32-bit word */
if (dev->ipc_config.frame_fmt == SOF_IPC_FRAME_S24_4LE)
dev->ipc_config.frame_fmt = SOF_IPC_FRAME_S24_4LE_MSB;
if (dd->dma_buffer)
audio_stream_set_frm_fmt(&dd->dma_buffer->stream,
dev->ipc_config.frame_fmt);

/* Free the old ptr if set from a previous DAI type */
if (!tdm_dev_data->dai_index_ptr) {
tdm_ctx = rzalloc(SOF_MEM_FLAG_USER | SOF_MEM_FLAG_COHERENT,
sizeof(*tdm_ctx));
tdm_dev_data->dai_index_ptr = tdm_ctx;
} else {
tdm_ctx = tdm_dev_data->dai_index_ptr;
}
tdm_ctx->index = dd->dai->index;
tdm_ctx->pin_dir = dai->direction;
#ifdef CONFIG_ZEPHYR_NATIVE_DRIVERS
tdm_ctx->dma_channel = dd->chan_index >= 0 ?
(uint32_t)dd->chan_index : ACP_TDM_INVALID_32;
#else
tdm_ctx->dma_channel = dd->chan ?
dd->chan->index : ACP_TDM_INVALID_32;
#endif
tdm_ctx->frame_fmt = dev->ipc_config.frame_fmt;
}
#endif /* CONFIG_AMD && CONFIG_SOC_ACP_7_X */
break;
case SOF_DAI_AMD_HS:
case SOF_DAI_AMD_HS_VIRTUAL:
case SOF_DAI_AMD_SDW:
Expand Down
9 changes: 9 additions & 0 deletions src/lib/dai.c
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,9 @@ const struct device *zephyr_dev[] = {
#if CONFIG_DAI_AMD_SDW
DT_FOREACH_STATUS_OKAY(amd_acp_sdw_dai, GET_DEVICE_LIST)
#endif
#if CONFIG_DAI_AMD_TDM
DT_FOREACH_STATUS_OKAY(amd_tdm_dai, GET_DEVICE_LIST)
#endif
#if CONFIG_DAI_INTEL_UAOL
DT_FOREACH_STATUS_OKAY(intel_uaol_dai, GET_DEVICE_LIST)
#endif
Expand Down Expand Up @@ -238,6 +241,8 @@ static int sof_dai_type_to_zephyr(uint32_t type)
case SOF_DAI_AMD_HS_VIRTUAL:
case SOF_DAI_AMD_SDW:
return DAI_AMD_SDW;
case SOF_DAI_AMD_TDM:
return DAI_AMD_TDM;
default:
return -EINVAL;
}
Expand Down Expand Up @@ -308,6 +313,10 @@ static void dai_set_device_params(struct dai *d)
case SOF_DAI_MEDIATEK_AFE:
d->dma_dev = SOF_DMA_DEV_AFE_MEMIF;
break;
case SOF_DAI_AMD_TDM:
d->dma_dev = SOF_DMA_DEV_TDM;
d->dma_caps = SOF_DMA_CAP_TDM;
break;
default:
break;
}
Expand Down
3 changes: 3 additions & 0 deletions src/platform/amd/acp_7_0/include/platform/platform_misc.h
Original file line number Diff line number Diff line change
Expand Up @@ -421,6 +421,9 @@ struct sdw_pin_data {
uint32_t instance;
};

#define ACP_TDM_INVALID_32 0xFFFFFFFFU
#define ACP_TDM_INVALID_16 0xFFFFU

struct tdm_context {
uint32_t tdm_instance;
uint32_t pin_dir;
Expand Down
3 changes: 3 additions & 0 deletions src/platform/amd/acp_7_x/include/platform/platform_misc.h
Original file line number Diff line number Diff line change
Expand Up @@ -548,6 +548,9 @@ struct sdw_pin_data {
uint32_t instance1;
};

#define ACP_TDM_INVALID_32 0xFFFFFFFFU
#define ACP_TDM_INVALID_16 0xFFFFU

struct tdm_context {
uint64_t prev_pos;
uint32_t buff_size;
Expand Down
2 changes: 2 additions & 0 deletions tools/topology/topology1/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,8 @@ set(TPLGS
"sof-acp_7_0\;sof-acp_7_0"
"sof-acp_7_0_sdw\;sof-acp_7_0-rt722-l0"
"sof-acp_7_x_sdw\;sof-acp7x-rt721-l0"
"sof-acp_7_x_i2s\;sof-acp7x"
"sof-acp_7_x_i2s_24bit\;sof-acp7x-24bit"
)

# This empty 'production/' source subdirectory exists only to create the
Expand Down
2 changes: 1 addition & 1 deletion tools/topology/topology1/m4/dai.m4
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ define(`DO_DAI_CONFIG',
`'
` id "'$3`"'
`'
` ifelse($1, `SSP', $5, $1, `HDA', $5, $1, `ALH', $5, $1, `ESAI', $5, $1, `SAI', $5, $1, `MICFIL', $5, $1, `AFE', $5, $1, `ACP', $5, $1, `ACPSP', $5, $1,`ACPSP_VIRTUAL', $5, $1, `ACPHS', $5, $1, `ACPHS_VIRTUAL', $5, $1, `ACP_SDW', $5, $1, `ACPDMIC', $5, `}')'
` ifelse($1, `SSP', $5, $1, `HDA', $5, $1, `ALH', $5, $1, `ESAI', $5, $1, `SAI', $5, $1, `MICFIL', $5, $1, `AFE', $5, $1, `ACP', $5, $1, `ACPSP', $5, $1,`ACPSP_VIRTUAL', $5, $1, `ACPHS', $5, $1, `ACPHS_VIRTUAL', $5, $1, `ACP_SDW', $5, $1, `ACPDMIC', $5, $1, `ACPTDM', $5, `}')'
`ifelse($1, `DMIC', $5, `')'
`SectionVendorTuples."'N_DAI_CONFIG($1$2)`_tuples_common" {'
` tokens "sof_dai_tokens"'
Expand Down
74 changes: 74 additions & 0 deletions tools/topology/topology1/platform/common/acp-tdm.m4
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
divert(-1)

dnl ACPTDM related macros

dnl ACP_CLOCK(clock, freq, codec_provider, polarity)
dnl polarity is optional
define(`ACP_CLOCK',
$1 STR($3)
$1_freq STR($2))
`ifelse($4, `inverted', `$1_invert "true"',`')')

dnl ACP_TDM(slots, width, tx_mask, rx_mask)
define(`ACP_TDM',
` tdm_slots 'STR($1)
` tdm_slot_width 'STR($2)
` tx_slots 'STR($3)
` rx_slots 'STR($4)
)

dnl ACP_CONFIG(format, mclk, bclk, fsync, tdm, esai_config_data)
define(`ACPTDM_CONFIG',
` format "'$1`"'
` '$2
` '$3
` '$4
` '$5
`}'
$6
)

dnl ACPTDM_VIRTUAL_CONFIG(format, mclk, bclk, fsync, tdm, esai_config_data)
define(`ACPTDM_VIRTUAL_CONFIG',
` format "'$1`"'
` '$2
` '$3
` '$4
` '$5
`}'
$6
)

dnl ACPTDM_CONFIG_DATA(type, idx, rate, channel,i2s_tdm_mode)
#i2s_tdm_mode 1-> tdm mode, 0->i2s mode
define(`ACPTDM_CONFIG_DATA',
`SectionVendorTuples."'N_DAI_CONFIG($1$2)`_tuples" {'
` tokens "sof_acp_tokens"'
` tuples."word" {'
` SOF_TKN_AMD_ACP_RATE' STR($3)
` SOF_TKN_AMD_ACP_CH' STR($4)
` SOF_TKN_AMD_ACP_I2S_TDM_MODE' STR($5)
` SOF_TKN_AMD_ACP_I2S_BITDEPTH' STR($6)
` }'
`}'
`SectionData."'N_DAI_CONFIG($1$2)`_data" {'
` tuples "'N_DAI_CONFIG($1$2)`_tuples"'
`}'
)

dnl ACPTDM_VIRTUAL_CONFIG_DATA(type, idx, rate, channel,i2s_tdm_mode)
#i2s_tdm_mode 1-> tdm mode, 0->i2s mode
define(`ACPTDM_VIRTUAL_CONFIG_DATA',
`SectionVendorTuples."'N_DAI_CONFIG($1$2)`_tuples" {'
` tokens "sof_acp_tokens"'
` tuples."word" {'
` SOF_TKN_AMD_ACP_RATE' STR($3)
` SOF_TKN_AMD_ACP_CH' STR($4)
` SOF_TKN_AMD_ACP_I2S_TDM_MODE' STR($5)
` }'
`}'
`SectionData."'N_DAI_CONFIG($1$2)`_data" {'
` tuples "'N_DAI_CONFIG($1$2)`_tuples"'
`}'
)
divert(0)dnl
Loading
Loading