From c52e8dbba265ded56dd6eaed77023151b5712648 Mon Sep 17 00:00:00 2001 From: Rander Wang Date: Mon, 19 Jul 2021 13:34:43 +0800 Subject: [PATCH] ipc4: alh: add alh support for ipc4 Stream id is included in ipc4 config and fw constructs hw_params for alh based on this information. Signed-off-by: Bard Liao Reviewed-by: Rander Wang --- src/drivers/intel/alh.c | 35 +++++++++++++++++++++++++---- src/include/ipc4/alh.h | 50 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 81 insertions(+), 4 deletions(-) create mode 100644 src/include/ipc4/alh.h diff --git a/src/drivers/intel/alh.c b/src/drivers/intel/alh.c index e462f2b9a..2e241eed8 100644 --- a/src/drivers/intel/alh.c +++ b/src/drivers/intel/alh.c @@ -16,6 +16,7 @@ #include #include #include +#include /* a8e4218c-e863-4c93-84e7-5c27d2504501 */ DECLARE_SOF_UUID("alh-dai", alh_uuid, 0xa8e4218c, 0xe863, 0x4c93, @@ -30,18 +31,19 @@ static int alh_trigger(struct dai *dai, int cmd, int direction) return 0; } -static int alh_set_config(struct dai *dai, struct ipc_config_dai *common_config, - void *spec_config) +static int alh_set_config_tplg(struct dai *dai, struct ipc_config_dai *common_config, + void *spec_config) { struct alh_pdata *alh = dai_get_drvdata(dai); struct sof_ipc_dai_config *config = spec_config; - dai_info(dai, "alh_set_config() config->format = 0x%4x", - config->format); + dai_info(dai, "alh_set_config_tplg() config->format = 0x%4x", config->format); if (config->alh.channels || config->alh.rate) { alh->params.channels = config->alh.channels; alh->params.rate = config->alh.rate; + dai_info(dai, "alh_set_config() channels %d rate %d", + config->alh.channels, config->alh.rate); } alh->params.stream_id = config->alh.stream_id; @@ -49,6 +51,31 @@ static int alh_set_config(struct dai *dai, struct ipc_config_dai *common_config, return 0; } +static int alh_set_config_blob(struct dai *dai, struct ipc_config_dai *common_config, + void *spec_config) +{ + struct alh_pdata *alh = dai_get_drvdata(dai); + struct sof_alh_configuration_blob *blob = spec_config; + struct ipc4_alh_multi_gtw_cfg *alh_cfg = &blob->alh_cfg; + + dai_info(dai, "alh_set_config_blob()"); + + alh->params.channels = 2; + alh->params.rate = 48000; + alh->params.stream_id = alh_cfg->mapping[0].alh_id & 0xf; + + return 0; +} + +static int alh_set_config(struct dai *dai, struct ipc_config_dai *common_config, + void *spec_config) +{ + if (!common_config->is_config_blob) + return alh_set_config_tplg(dai, common_config, spec_config); + else + return alh_set_config_blob(dai, common_config, spec_config); +} + /* get ALH hw params */ static int alh_get_hw_params(struct dai *dai, struct sof_ipc_stream_params *params, int dir) diff --git a/src/include/ipc4/alh.h b/src/include/ipc4/alh.h new file mode 100644 index 000000000..e6275009a --- /dev/null +++ b/src/include/ipc4/alh.h @@ -0,0 +1,50 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * + * Copyright(c) 2021 Intel Corporation. All rights reserved. + */ + +/* + * This file contains structures that are exact copies of an existing ABI used + * by IOT middleware. They are Intel specific and will be used by one middleware. + * + * Some of the structures may contain programming implementations that makes them + * unsuitable for generic use and general usage. + * + * This code is mostly copied "as-is" from existing C++ interface files hence the use of + * different style in places. The intention is to keep the interface as close as possible to + * original so it's easier to track changes with IPC host code. + */ + +/** + * \file include/ipc4/alh.h + * \brief IPC4 global definitions. + * NOTE: This ABI uses bit fields and is non portable. + */ + +#ifndef __SOF_IPC4_ALH_H__ +#define __SOF_IPC4_ALH_H__ + +#include +#include + +#define IPC4_ALH_MAX_NUMBER_OF_GTW 16 +#define IPC4_ALH_DAI_INDEX_OFFSET 7 + +struct ipc4_alh_multi_gtw_cfg { + /* Number of single channels (valid items in mapping array). */ + uint32_t count; + /* Single to multi aggregation mapping item. */ + struct { + /* Vindex of a single ALH channel aggregated. */ + uint32_t alh_id; + /* Channel mask */ + uint32_t channel_mask; + } mapping[IPC4_ALH_MAX_NUMBER_OF_GTW]; /* < Mapping items */ +} __attribute__((packed, aligned(4))); + +struct sof_alh_configuration_blob { + union ipc4_gateway_attributes gtw_attributes; + struct ipc4_alh_multi_gtw_cfg alh_cfg; +} __attribute__((packed, aligned(4))); + +#endif