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,32 @@ 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 );
2931
32+ switch (dd -> dai -> type ) {
33+ case SOF_DAI_INTEL_DMIC :
34+ {
35+ struct dmic_config_data * dmic_gtw_cfg = cd -> gtw_cfg ;
36+ struct dmic_ext_global_cfg * dmic_ext_glb_cfg =
37+ & dmic_gtw_cfg -> dmic_blob .global_cfg .ext_cfg ;
38+
39+ if (!dmic_ext_glb_cfg ) {
40+ comp_err (dev , "No dmic global config found" );
41+ return - EINVAL ;
42+ }
43+
44+ fade_period = dmic_ext_glb_cfg -> fade_in_period ;
45+ /* Convert and assign silence and fade length values received
46+ * in DMIC blob.
47+ */
48+ gain_params -> silence_sg_length =
49+ frames * dmic_ext_glb_cfg -> silence_period ;
50+ gain_params -> fade_sg_length = frames * fade_period ;
51+ }
52+ break ;
53+ default :
54+ comp_info (dev , "Apply default fade period for dai type %d" , dd -> dai -> type );
55+ break ;
56+ }
57+
3058 /* Set fade parameters */
3159 ret = copier_gain_set_fade_params (dev , dd , fade_period , frames );
3260 if (ret )
@@ -78,13 +106,15 @@ int copier_gain_dma_control(uint32_t node_id, const uint32_t *config_data,
78106 size_t config_size , enum sof_ipc_dai_type dai_type )
79107{
80108 union ipc4_connector_node_id node = (union ipc4_connector_node_id )node_id ;
109+ struct sof_tlv * tlv = (struct sof_tlv * )config_data ;
81110 struct gain_dma_control_data * gain_data = NULL ;
82111 struct ipc_comp_dev * icd = NULL ;
83112 struct processing_module * mod = NULL ;
84113 struct copier_data * cd = NULL ;
85114 struct ipc * ipc = ipc_get ();
86115 struct list_item * clist ;
87116 struct comp_dev * dev ;
117+ void * tlv_val ;
88118 int ret ;
89119
90120 list_for_item (clist , & ipc -> comp_list ) {
@@ -101,6 +131,29 @@ int copier_gain_dma_control(uint32_t node_id, const uint32_t *config_data,
101131 mod = comp_mod (dev );
102132 cd = module_get_private_data (mod );
103133
134+ switch (dai_type ) {
135+ case SOF_DAI_INTEL_DMIC :
136+ if (cd -> dd [0 ]-> dai -> index != node .f .v_index )
137+ continue ;
138+
139+ if (!config_size ) {
140+ comp_err (dev , "Config length for DMIC couldn't be zero" );
141+ return - EINVAL ;
142+ }
143+
144+ /* Gain coefficients for DMIC */
145+ tlv_val = tlv_value_ptr_get (tlv , DMIC_SET_GAIN_COEFFICIENTS );
146+ if (!tlv_val ) {
147+ comp_err (dev , "No gain coefficients in DMA_CONTROL ipc" );
148+ return - EINVAL ;
149+ }
150+ gain_data = tlv_val ;
151+ break ;
152+ default :
153+ comp_warn (dev , "Gain DMA control: no dai type=%d found" , dai_type );
154+ break ;
155+ }
156+
104157 ret = copier_set_gain (dev , cd -> dd [0 ], gain_data );
105158 if (ret )
106159 comp_err (dev , "Gain DMA control: failed to set gain" );
0 commit comments