88#include <ipc4/base-config.h>
99#include <sof/audio/component_ext.h>
1010#include <module/module/base.h>
11+ #include <sof/tlv.h>
12+ #include <ipc4/dmic.h>
1113#include "copier.h"
1214#include "copier_gain.h"
1315
@@ -27,6 +29,31 @@ int copier_gain_set_params(struct comp_dev *dev, struct dai_data *dd)
2729 /* Set basic gain parameters */
2830 copier_gain_set_basic_params (dev , dd , ipc4_cfg );
2931
32+ switch (dd -> dai -> type ) {
33+ case SOF_DAI_INTEL_DMIC :
34+ {
35+ struct dmic_config_data * dmic_cfg = cd -> gtw_cfg ;
36+ union dmic_global_cfg * dmic_glb_cfg = & dmic_cfg -> dmic_blob .global_cfg ;
37+
38+ if (!dmic_glb_cfg ) {
39+ comp_err (dev , "No dmic global config found" );
40+ return - EINVAL ;
41+ }
42+
43+ fade_period = dmic_glb_cfg -> ext_global_cfg .fade_in_period ;
44+ /* Convert and assign silence and fade length values received
45+ * in DMIC blob.
46+ */
47+ gain_params -> silence_sg_length =
48+ frames * dmic_glb_cfg -> ext_global_cfg .silence_period ;
49+ gain_params -> fade_sg_length = frames * fade_period ;
50+ }
51+ break ;
52+ default :
53+ comp_info (dev , "Apply default fade period for dai type %d" , dd -> dai -> type );
54+ break ;
55+ }
56+
3057 /* Set fade parameters */
3158 ret = copier_gain_set_fade_params (dev , dd , ipc4_cfg , fade_period , frames );
3259 if (ret )
@@ -78,15 +105,16 @@ int copier_gain_dma_control(uint32_t node_id, const uint32_t *config_data,
78105 size_t config_size , enum sof_ipc_dai_type dai_type )
79106{
80107 union ipc4_connector_node_id node = (union ipc4_connector_node_id )node_id ;
108+ struct sof_tlv * tlv = (struct sof_tlv * )config_data ;
81109 struct ipc * ipc = ipc_get ();
82110 struct ipc_comp_dev * icd ;
83111 struct comp_dev * dev ;
84112 struct list_item * clist ;
85-
86113 int ret ;
87114
88115 list_for_item (clist , & ipc -> comp_list ) {
89116 struct gain_dma_control_data * gain_data = NULL ;
117+ void * tlv_val = NULL ;
90118
91119 icd = container_of (clist , struct ipc_comp_dev , list );
92120
@@ -101,6 +129,29 @@ int copier_gain_dma_control(uint32_t node_id, const uint32_t *config_data,
101129 struct processing_module * mod = comp_mod (dev );
102130 struct copier_data * cd = module_get_private_data (mod );
103131
132+ switch (dai_type ) {
133+ case SOF_DAI_INTEL_DMIC :
134+ if (cd -> dd [0 ]-> dai -> index != node .f .v_index )
135+ continue ;
136+
137+ if (!config_size ) {
138+ comp_err (dev , "Config length for DMIC couldn't be zero" );
139+ return - EINVAL ;
140+ }
141+
142+ /* Gain coefficients for DMIC */
143+ tlv_val = tlv_value_ptr_get (tlv , DMIC_SET_GAIN_COEFFICIENTS );
144+ if (!tlv_val ) {
145+ comp_err (dev , "No gain coefficients in DMA_CONTROL ipc" );
146+ return - EINVAL ;
147+ }
148+ gain_data = tlv_val ;
149+ break ;
150+ default :
151+ comp_warn (dev , "Gain DMA control: no dai type=%d found" , dai_type );
152+ break ;
153+ }
154+
104155 ret = copier_set_gain (dev , cd -> dd [0 ], gain_data );
105156 if (ret )
106157 comp_err (dev , "Gain DMA control: failed to set gain" );
0 commit comments