From 6ff8573ea4b58f707cb0c776609841a41032b739 Mon Sep 17 00:00:00 2001 From: Slawomir Blauciak Date: Tue, 14 Apr 2020 14:45:12 +0200 Subject: [PATCH 1/2] hda: retrieve hda hardware params from ipc This is an analogous change to what's been done for ALH DAIs. Similarly, HDA is set up on the host side. As a result, the firmware normally has no knowledge of the hardware configuration, which leads to failures in components, that may modify stream parameters, such as (de)mux or asrc. Signed-off-by: Slawomir Blauciak --- src/drivers/intel/cavs/hda.c | 49 ++++++++++++++++++++++++++++++++--- src/include/ipc/dai-intel.h | 2 ++ src/include/kernel/abi.h | 2 +- src/include/sof/drivers/hda.h | 5 ++++ 4 files changed, 53 insertions(+), 5 deletions(-) diff --git a/src/drivers/intel/cavs/hda.c b/src/drivers/intel/cavs/hda.c index 3b9229f94ff4..2367d0027a21 100644 --- a/src/drivers/intel/cavs/hda.c +++ b/src/drivers/intel/cavs/hda.c @@ -12,6 +12,7 @@ #include #include #include +#include /* bc9ebe20-4577-41bb-9eed-d0cb236328da */ DECLARE_SOF_UUID("hda-dai", hda_uuid, 0xbc9ebe20, 0x4577, 0x41bb, @@ -25,6 +26,13 @@ static int hda_trigger(struct dai *dai, int cmd, int direction) static int hda_set_config(struct dai *dai, struct sof_ipc_dai_config *config) { + struct hda_pdata *hda = dai_get_drvdata(dai); + + if (config->hda.channels || config->hda.rate) { + hda->params.channels = config->hda.channels; + hda->params.rate = config->hda.rate; + } + return 0; } @@ -32,15 +40,48 @@ static int hda_set_config(struct dai *dai, static int hda_get_hw_params(struct dai *dai, struct sof_ipc_stream_params *params, int dir) { + struct hda_pdata *hda = dai_get_drvdata(dai); + + params->rate = hda->params.rate; + params->channels = hda->params.channels; + /* 0 means variable */ - params->rate = 0; - params->channels = 0; params->buffer_fmt = 0; params->frame_fmt = 0; return 0; } +static int hda_probe(struct dai *dai) +{ + struct hda_pdata *hda; + + dai_info(dai, "hda_probe()"); + + if (dai_get_drvdata(dai)) + return -EEXIST; + + hda = rzalloc(SOF_MEM_ZONE_SYS_RUNTIME, 0, SOF_MEM_CAPS_RAM, + sizeof(*hda)); + if (!hda) { + dai_err(dai, "hda_probe() error: alloc failed"); + return -ENOMEM; + } + dai_set_drvdata(dai, hda); + + return 0; +} + +static int hda_remove(struct dai *dai) +{ + dai_info(dai, "hda_remove()"); + + rfree(dai_get_drvdata(dai)); + dai_set_drvdata(dai, NULL); + + return 0; +} + static int hda_dummy(struct dai *dai) { return 0; @@ -170,8 +211,8 @@ const struct dai_driver hda_driver = { .get_hw_params = hda_get_hw_params, .get_handshake = hda_get_handshake, .get_fifo = hda_get_fifo, - .probe = hda_dummy, - .remove = hda_dummy, + .probe = hda_probe, + .remove = hda_remove, }, .ts_ops = { .ts_config = hda_ts_config, diff --git a/src/include/ipc/dai-intel.h b/src/include/ipc/dai-intel.h index 4c6d1b3a81b9..9e5c395a4928 100644 --- a/src/include/ipc/dai-intel.h +++ b/src/include/ipc/dai-intel.h @@ -96,6 +96,8 @@ struct sof_ipc_dai_ssp_params { struct sof_ipc_dai_hda_params { uint32_t reserved0; uint32_t link_dma_ch; + uint32_t rate; + uint32_t channels; } __attribute__((packed)); /* ALH Configuration Request - SOF_IPC_DAI_ALH_CONFIG */ diff --git a/src/include/kernel/abi.h b/src/include/kernel/abi.h index 0e3dc57762c2..792d253fe397 100644 --- a/src/include/kernel/abi.h +++ b/src/include/kernel/abi.h @@ -29,7 +29,7 @@ /** \brief SOF ABI version major, minor and patch numbers */ #define SOF_ABI_MAJOR 3 -#define SOF_ABI_MINOR 15 +#define SOF_ABI_MINOR 16 #define SOF_ABI_PATCH 0 /** \brief SOF ABI version number. Format within 32bit word is MMmmmppp */ diff --git a/src/include/sof/drivers/hda.h b/src/include/sof/drivers/hda.h index fa8c5637efbc..a78bac3b624d 100644 --- a/src/include/sof/drivers/hda.h +++ b/src/include/sof/drivers/hda.h @@ -8,8 +8,13 @@ #ifndef __SOF_DRIVERS_HDA_H__ #define __SOF_DRIVERS_HDA_H__ +#include #include +struct hda_pdata { + struct sof_ipc_dai_hda_params params; +}; + extern const struct dai_driver hda_driver; #endif /* __SOF_DRIVERS_HDA_H__ */ From af9401c74bde3496695382244dc1a54c366a15ad Mon Sep 17 00:00:00 2001 From: Slawomir Blauciak Date: Tue, 14 Apr 2020 14:49:01 +0200 Subject: [PATCH 2/2] alh: fix incorrect trace message The old trace message contained an SSP-specific string, which is not correct for ALH. Signed-off-by: Slawomir Blauciak --- src/drivers/intel/cavs/alh.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/drivers/intel/cavs/alh.c b/src/drivers/intel/cavs/alh.c index 880b243e5f49..f5ac21e215e0 100644 --- a/src/drivers/intel/cavs/alh.c +++ b/src/drivers/intel/cavs/alh.c @@ -89,7 +89,7 @@ static int alh_probe(struct dai *dai) alh = rzalloc(SOF_MEM_ZONE_SYS_RUNTIME, 0, SOF_MEM_CAPS_RAM, sizeof(*alh)); if (!alh) { - dai_err(dai, "ssp_probe() error: alloc failed"); + dai_err(dai, "alh_probe() error: alloc failed"); return -ENOMEM; } dai_set_drvdata(dai, alh);