From c3659da65a403b4eefb41d5e7dca069f130d82e2 Mon Sep 17 00:00:00 2001 From: Adrian Bonislawski Date: Fri, 2 Sep 2022 16:18:36 +0200 Subject: [PATCH] drivers: dai: alh: set rate and channels from config blob This will use config blob to set rate and channels params Signed-off-by: Adrian Bonislawski --- drivers/dai/intel/alh/alh.c | 21 +++++++++++++++------ drivers/dai/intel/alh/alh.h | 6 ++++++ 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/drivers/dai/intel/alh/alh.c b/drivers/dai/intel/alh/alh.c index 59f1d1a4be..cda36bc0f5 100644 --- a/drivers/dai/intel/alh/alh.c +++ b/drivers/dai/intel/alh/alh.c @@ -35,16 +35,25 @@ static int dai_alh_set_config_tplg(struct dai_intel_alh *dp, const void *spec_co return 0; } -static int dai_alh_set_config_blob(struct dai_intel_alh *dp, const void *spec_config) +static int dai_alh_set_config_blob(struct dai_intel_alh *dp, const struct dai_config *cfg, + const void *spec_config) { struct dai_intel_alh_pdata *alh = dai_get_drvdata(dp); const struct dai_intel_ipc4_alh_configuration_blob *blob = spec_config; const struct ipc4_alh_multi_gtw_cfg *alh_cfg = &blob->alh_cfg; - alh->params.channels = ALH_CHANNELS_DEFAULT; - alh->params.rate = ALH_RATE_DEFAULT; - /* the LSB 8bits are for stream id */ - alh->params.stream_id = alh_cfg->mapping[0].alh_id & 0xff; + alh->params.rate = cfg->rate; + + for (int i = 0; i < alh_cfg->count; i++) { + /* the LSB 8bits are for stream id */ + int alh_id = alh_cfg->mapping[i].alh_id & 0xff; + + if (IPC4_ALH_DAI_INDEX(alh_id) == dp->index) { + alh->params.stream_id = alh_id; + alh->params.channels = popcount(alh_cfg->mapping[i].channel_mask); + break; + } + } return 0; } @@ -103,7 +112,7 @@ static int dai_alh_config_set(const struct device *dev, const struct dai_config if (cfg->type == DAI_INTEL_ALH) { return dai_alh_set_config_tplg(dp, bespoke_cfg); } else { - return dai_alh_set_config_blob(dp, bespoke_cfg); + return dai_alh_set_config_blob(dp, cfg, bespoke_cfg); } } diff --git a/drivers/dai/intel/alh/alh.h b/drivers/dai/intel/alh/alh.h index 85e432e801..bff8a408ab 100644 --- a/drivers/dai/intel/alh/alh.h +++ b/drivers/dai/intel/alh/alh.h @@ -19,6 +19,12 @@ #define IPC4_ALH_MAX_NUMBER_OF_GTW 16 #define IPC4_ALH_DAI_INDEX_OFFSET 7 +/* copier id = (group id << 4) + codec id + IPC4_ALH_DAI_INDEX_OFFSET + * dai_index = (group id << 8) + codec id; + */ +#define IPC4_ALH_DAI_INDEX(x) ((((x) & 0xF0) << DAI_NUM_ALH_BI_DIR_LINKS_GROUP) + \ + (((x) & 0xF) - IPC4_ALH_DAI_INDEX_OFFSET)) + #define ALH_GPDMA_BURST_LENGTH 4 #define ALH_SET_BITS(b_hi, b_lo, x) \