From 2c9d32146a064fe84a6fc44f9992ee32ea445ae5 Mon Sep 17 00:00:00 2001 From: Seppo Ingalsuo Date: Fri, 20 Mar 2020 16:20:22 +0200 Subject: [PATCH 1/3] DMIC: Change IPC in dmic_set_config() to use a fixed length struct This patch was created due to kernel driver code enhancement. The DMIC was the only DAI type that used variable length arrays for configuration IPC. It complicated the driver topology parsing more than necessary. Since the header files for IPC are common also the firmware side needs similar changes. The flexible array member pdm[] is changed into a fixed array of four that is the max. number of stereo PDM controllers in the current Intel platforms. The DMIC driver code needs minor changes to correctly handle the changed IPC struct size. The IPC logic remains as before: The IPC PDM entries do not correspond to hardware PDM controllers. They are applied per provided index in each entry. Depending on number of PDM controllers there is now zeros data after the last defined controller that will be omitted. Signed-off-by: Seppo Ingalsuo --- src/drivers/intel/cavs/dmic.c | 10 ++++------ src/include/ipc/dai-intel.h | 11 ++++++++--- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/src/drivers/intel/cavs/dmic.c b/src/drivers/intel/cavs/dmic.c index 05074921806d..7b2352126012 100644 --- a/src/drivers/intel/cavs/dmic.c +++ b/src/drivers/intel/cavs/dmic.c @@ -1147,9 +1147,7 @@ static int dmic_set_config(struct dai *dai, struct sof_ipc_dai_config *config) * "prm" is initialized with default params for all HW controllers */ if (!dmic_prm[0]) { - size = sizeof(struct sof_ipc_dai_dmic_params) - + DMIC_HW_CONTROLLERS - * sizeof(struct sof_ipc_dai_dmic_pdm_ctrl); + size = sizeof(struct sof_ipc_dai_dmic_params); dmic_prm[0] = rzalloc(SOF_MEM_ZONE_SYS_RUNTIME, 0, SOF_MEM_CAPS_RAM, DMIC_HW_FIFOS * size); @@ -1162,11 +1160,11 @@ static int dmic_set_config(struct dai *dai, struct sof_ipc_dai_config *config) ((uint8_t *)dmic_prm[i - 1] + size); } - /* Copy the new DMIC params to persistent. The last request - * determines the parameters. + /* Copy the new DMIC params header (all but not pdm[]) to persistent. + * The last arrived request determines the parameters. */ ret = memcpy_s(dmic_prm[di], sizeof(*dmic_prm[di]), &config->dmic, - sizeof(struct sof_ipc_dai_dmic_params)); + offsetof(struct sof_ipc_dai_dmic_params, pdm)); assert(!ret); /* copy the pdm controller params from ipc */ diff --git a/src/include/ipc/dai-intel.h b/src/include/ipc/dai-intel.h index e57afd09d1c6..033a997d891a 100644 --- a/src/include/ipc/dai-intel.h +++ b/src/include/ipc/dai-intel.h @@ -57,6 +57,9 @@ /* bclk idle */ #define SOF_DAI_INTEL_SSP_CLKCTRL_BCLK_IDLE_HIGH BIT(5) +/* DMIC max. four controllers for eight microphone channels */ +#define SOF_DAI_INTEL_DMIC_NUM_CTRL 4 + /* SSP Configuration Request - SOF_IPC_DAI_SSP_CONFIG */ struct sof_ipc_dai_ssp_params { uint32_t reserved0; @@ -168,6 +171,7 @@ struct sof_ipc_dai_dmic_pdm_ctrl { * met. The unit for both is microseconds (us). Exceed of 100 ms will be * treated as an error. */ + struct sof_ipc_dai_dmic_params { uint32_t reserved0; uint32_t driver_ipc_version; /**< Version (1..N) */ @@ -183,7 +187,8 @@ struct sof_ipc_dai_dmic_params { uint16_t duty_min; /**< Min. mic clock duty cycle in % (20..80) */ uint16_t duty_max; /**< Max. mic clock duty cycle in % (min..80) */ - uint32_t num_pdm_active; /**< Number of active pdm controllers */ + uint32_t num_pdm_active; /**< Number of active pdm controllers. */ + /**< Range is 1..SOF_DAI_INTEL_DMIC_NUM_CTRL */ uint32_t wake_up_time; /**< Time from clock start to data (us) */ uint32_t min_clock_on_time; /**< Min. time that clk is kept on (us) */ @@ -192,8 +197,8 @@ struct sof_ipc_dai_dmic_params { /* reserved for future use */ uint32_t reserved[5]; - /**< variable number of pdm controller config */ - struct sof_ipc_dai_dmic_pdm_ctrl pdm[0]; + /**< PDM controllers configuration */ + struct sof_ipc_dai_dmic_pdm_ctrl pdm[SOF_DAI_INTEL_DMIC_NUM_CTRL]; } __attribute__((packed)); #endif /* __IPC_DAI_INTEL_H__ */ From 34cccc36ce3cacd3f2f29fb7149a8ac0c7850f3f Mon Sep 17 00:00:00 2001 From: Seppo Ingalsuo Date: Fri, 20 Mar 2020 17:23:32 +0200 Subject: [PATCH 2/3] DMIC: Fix a typo in header file comment text This patch fixes the topo in word "microphone". Signed-off-by: Seppo Ingalsuo --- src/include/ipc/dai-intel.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/include/ipc/dai-intel.h b/src/include/ipc/dai-intel.h index 033a997d891a..a1993aa59a64 100644 --- a/src/include/ipc/dai-intel.h +++ b/src/include/ipc/dai-intel.h @@ -146,7 +146,7 @@ struct sof_ipc_dai_dmic_pdm_ctrl { * version number used in configuration data is checked vs. version used by * device driver src/drivers/dmic.c need to match. It is incremented from * initial value 1 if updates done for the to driver would alter the operation - * of the microhone. + * of the microphone. * * Note: The microphone clock (pdmclk_min, pdmclk_max, duty_min, duty_max) * parameters need to be set as defined in microphone data sheet. E.g. clock From f948977d458ea95daf2407d4ad3967134d520247 Mon Sep 17 00:00:00 2001 From: Seppo Ingalsuo Date: Wed, 25 Mar 2020 18:24:42 +0200 Subject: [PATCH 3/3] DMIC: Rename DMIC IPC struct field reserved_2 Since the SOF kernel and firmware headers need to be the same the rename is also done on firmware side. The fifo_bits_b parameter was deprecated in firmware ABI version 3.0.1 and the value has been ignored. Since the kernel sets this in case of ABI version 3.0.0 or earlier the name reserved_2 is not appropriate. Signed-off-by: Seppo Ingalsuo --- src/include/ipc/dai-intel.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/include/ipc/dai-intel.h b/src/include/ipc/dai-intel.h index a1993aa59a64..a9628b820071 100644 --- a/src/include/ipc/dai-intel.h +++ b/src/include/ipc/dai-intel.h @@ -182,7 +182,7 @@ struct sof_ipc_dai_dmic_params { uint32_t fifo_fs; /**< FIFO sample rate in Hz (8000..96000) */ uint32_t reserved_1; /**< Reserved */ uint16_t fifo_bits; /**< FIFO word length (16 or 32) */ - uint16_t reserved_2; /**< Reserved */ + uint16_t fifo_bits_b; /**< Deprecated since firmware ABI 3.0.1 */ uint16_t duty_min; /**< Min. mic clock duty cycle in % (20..80) */ uint16_t duty_max; /**< Max. mic clock duty cycle in % (min..80) */