@@ -137,47 +137,53 @@ static enum task_state dmic_work(void *data)
137137static int dmic_get_hw_params (struct dai * dai ,
138138 struct sof_ipc_stream_params * params , int dir )
139139{
140+ #if CONFIG_INTEL_DMIC_TPLG_PARAMS
140141 return dmic_get_hw_params_computed (dai , params , dir );
142+
143+ #elif CONFIG_INTEL_DMIC_NHLT
144+ return dmic_get_hw_params_nhlt (dai , params , dir );
145+
146+ #else
147+ return - EINVAL ;
148+ #endif
141149}
142150
143- static int dmic_set_config (struct dai * dai , struct ipc_config_dai * common_config ,
144- void * spec_config )
151+ static int dmic_set_config (struct dai * dai , struct ipc_config_dai * common_config , void * spec_config )
145152{
146153 struct dmic_pdata * dmic = dai_get_drvdata (dai );
147- struct sof_ipc_dai_config * config = spec_config ;
148154 int32_t unmute_ramp_time_ms ;
149155 int32_t step_db ;
150- int i ;
151- int j ;
152156 int ret = 0 ;
153157 int di = dai -> index ;
158+ #if CONFIG_INTEL_DMIC_TPLG_PARAMS
159+ struct sof_ipc_dai_config * config = spec_config ;
160+ int i ;
161+ int j ;
162+ #endif
154163
155164 dai_info (dai , "dmic_set_config()" );
156165
157- if (config -> dmic .driver_ipc_version != DMIC_IPC_VERSION ) {
158- dai_err (dai , "dmic_set_config(): wrong ipc version" );
166+ if (di >= DMIC_HW_FIFOS ) {
167+ dai_err (dai , "dmic_set_config(): DAI index exceeds number of FIFOs" );
168+ return - EINVAL ;
169+ }
170+
171+ if (!spec_config ) {
172+ dai_err (dai , "dmic_set_config(): NULL config" );
159173 return - EINVAL ;
160174 }
161175
176+ assert (dmic );
162177 spin_lock (& dai -> lock );
163178
164- /* Compute unmute ramp gain update coefficient. Use the value from
165- * topology if it is non-zero, otherwise use default length.
179+ #if CONFIG_INTEL_DMIC_TPLG_PARAMS
180+ /*
181+ * "config" might contain pdm controller params for only
182+ * the active controllers
183+ * "prm" is initialized with default params for all HW controllers
166184 */
167- if (config -> dmic .unmute_ramp_time )
168- unmute_ramp_time_ms = config -> dmic .unmute_ramp_time ;
169- else
170- unmute_ramp_time_ms = dmic_get_unmute_ramp_from_samplerate (config -> dmic .fifo_fs );
171-
172- if (unmute_ramp_time_ms < LOGRAMP_TIME_MIN_MS ||
173- unmute_ramp_time_ms > LOGRAMP_TIME_MAX_MS ) {
174- dai_err (dai , "dmic_set_config(): Illegal ramp time = %d" , unmute_ramp_time_ms );
175- ret = - EINVAL ;
176- goto out ;
177- }
178-
179- if (di >= DMIC_HW_FIFOS ) {
180- dai_err (dai , "dmic_set_config(): dai->index exceeds number of FIFOs" );
185+ if (config -> dmic .driver_ipc_version != DMIC_IPC_VERSION ) {
186+ dai_err (dai , "dmic_set_config(): wrong ipc version" );
181187 ret = - EINVAL ;
182188 goto out ;
183189 }
@@ -188,17 +194,20 @@ static int dmic_set_config(struct dai *dai, struct ipc_config_dai *common_config
188194 goto out ;
189195 }
190196
191- step_db = LOGRAMP_CONST_TERM / unmute_ramp_time_ms ;
192- dmic -> gain_coef = db2lin_fixed (step_db );
193- dai_info (dai , "dmic_set_config(): unmute_ramp_time_ms = %d" ,
194- unmute_ramp_time_ms );
195-
196- /*
197- * "config" might contain pdm controller params for only
198- * the active controllers
199- * "prm" is initialized with default params for all HW controllers
197+ /* Get unmute gain ramp duration. Use the value from topology
198+ * if it is non-zero, otherwise use default length.
200199 */
201- assert (dmic );
200+ if (config -> dmic .unmute_ramp_time )
201+ unmute_ramp_time_ms = config -> dmic .unmute_ramp_time ;
202+ else
203+ unmute_ramp_time_ms = dmic_get_unmute_ramp_from_samplerate (config -> dmic .fifo_fs );
204+
205+ if (unmute_ramp_time_ms < LOGRAMP_TIME_MIN_MS ||
206+ unmute_ramp_time_ms > LOGRAMP_TIME_MAX_MS ) {
207+ dai_err (dai , "dmic_set_config(): Illegal ramp time = %d" , unmute_ramp_time_ms );
208+ ret = - EINVAL ;
209+ goto out ;
210+ }
202211
203212 /* Copy the new DMIC params header (all but not pdm[]) to persistent.
204213 * The last arrived request determines the parameters.
@@ -223,6 +232,26 @@ static int dmic_set_config(struct dai *dai, struct ipc_config_dai *common_config
223232 }
224233
225234 ret = dmic_set_config_computed (dai );
235+
236+ #elif CONFIG_INTEL_DMIC_NHLT
237+ ret = dmic_set_config_nhlt (dai , spec_config );
238+
239+ /* There's no unmute ramp duration in blob, so the default rate dependent is used. */
240+ unmute_ramp_time_ms = dmic_get_unmute_ramp_from_samplerate (dmic -> dai_rate );
241+ #else
242+ ret = - EINVAL ;
243+ #endif
244+
245+ if (ret < 0 ) {
246+ dai_err (dai , "dmic_set_config(): Failed to set the requested configuration." );
247+ goto out ;
248+ }
249+
250+ /* Compute unmute ramp gain update coefficient. */
251+ step_db = LOGRAMP_CONST_TERM / unmute_ramp_time_ms ;
252+ dmic -> gain_coef = db2lin_fixed (step_db );
253+ dai_info (dai , "dmic_set_config(): unmute_ramp_time_ms = %d" , unmute_ramp_time_ms );
254+
226255 dmic -> state = COMP_STATE_PREPARE ;
227256
228257out :
0 commit comments