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
@@ -26,6 +28,31 @@ int copier_gain_set_params(struct comp_dev *dev, struct dai_data *dd)
2628 /* Set basic gain parameters */
2729 copier_gain_set_basic_params (dev , dd , ipc4_cfg );
2830
31+ switch (dd -> dai -> type ) {
32+ case SOF_DAI_INTEL_DMIC :
33+ {
34+ struct dmic_config_data * dmic_cfg = cd -> gtw_cfg ;
35+
36+ if (!dmic_cfg ) {
37+ comp_err (dev , "No dmic config found" );
38+ return - EINVAL ;
39+ }
40+
41+ union dmic_global_cfg * dmic_glb_cfg = & dmic_cfg -> dmic_blob .global_cfg ;
42+
43+ /* Get fade period from DMIC blob */
44+ fade_period = dmic_glb_cfg -> ext_global_cfg .fade_in_period ;
45+ /* Convert and assign silence and fade length values */
46+ dd -> gain_data -> silence_sg_length =
47+ frames * dmic_glb_cfg -> ext_global_cfg .silence_period ;
48+ dd -> gain_data -> fade_sg_length = frames * fade_period ;
49+ }
50+ break ;
51+ default :
52+ comp_info (dev , "Apply default fade period for dai type %d" , dd -> dai -> type );
53+ break ;
54+ }
55+
2956 /* Set fade parameters */
3057 ret = copier_gain_set_fade_params (dev , dd , ipc4_cfg , fade_period , frames );
3158 if (ret )
@@ -73,18 +100,19 @@ enum copier_gain_state copier_gain_eval_state(struct copier_gain_params *gain_pa
73100 return state ;
74101}
75102
76- int copier_gain_dma_control (uint32_t node_id , const uint32_t * config_data ,
103+ int copier_gain_dma_control (union ipc4_connector_node_id node , const char * config_data ,
77104 size_t config_size , enum sof_ipc_dai_type dai_type )
78105{
106+ struct sof_tlv * tlv = (struct sof_tlv * )config_data ;
79107 struct ipc * ipc = ipc_get ();
80108 struct ipc_comp_dev * icd ;
81109 struct comp_dev * dev ;
82110 struct list_item * clist ;
83-
84111 int ret ;
85112
86113 list_for_item (clist , & ipc -> comp_list ) {
87114 struct gain_dma_control_data * gain_data = NULL ;
115+ void * tlv_val = NULL ;
88116
89117 icd = container_of (clist , struct ipc_comp_dev , list );
90118
@@ -99,6 +127,29 @@ int copier_gain_dma_control(uint32_t node_id, const uint32_t *config_data,
99127 struct processing_module * mod = comp_mod (dev );
100128 struct copier_data * cd = module_get_private_data (mod );
101129
130+ switch (dai_type ) {
131+ case SOF_DAI_INTEL_DMIC :
132+ if (cd -> dd [0 ]-> dai -> index != node .f .v_index )
133+ continue ;
134+
135+ if (!config_size ) {
136+ comp_err (dev , "Config length for DMIC couldn't be zero" );
137+ return - EINVAL ;
138+ }
139+
140+ /* Gain coefficients for DMIC */
141+ tlv_val = tlv_value_ptr_get (tlv , DMIC_SET_GAIN_COEFFICIENTS );
142+ if (!tlv_val ) {
143+ comp_err (dev , "No gain coefficients in DMA_CONTROL ipc" );
144+ return - EINVAL ;
145+ }
146+ gain_data = tlv_val ;
147+ break ;
148+ default :
149+ comp_warn (dev , "Gain DMA control: no dai type=%d found" , dai_type );
150+ break ;
151+ }
152+
102153 ret = copier_set_gain (dev , cd -> dd [0 ], gain_data );
103154 if (ret )
104155 comp_err (dev , "Gain DMA control: failed to set gain" );
0 commit comments