@@ -89,7 +89,7 @@ struct tas2781_hda {
8989 struct snd_kcontrol * dsp_prog_ctl ;
9090 struct snd_kcontrol * dsp_conf_ctl ;
9191 struct snd_kcontrol * prof_ctl ;
92- struct snd_kcontrol * snd_ctls [3 ];
92+ struct snd_kcontrol * snd_ctls [2 ];
9393};
9494
9595static int tas2781_get_i2c_res (struct acpi_resource * ares , void * data )
@@ -161,8 +161,6 @@ static void tas2781_hda_playback_hook(struct device *dev, int action)
161161 pm_runtime_put_autosuspend (dev );
162162 break ;
163163 default :
164- dev_dbg (tas_hda -> dev , "Playback action not supported: %d\n" ,
165- action );
166164 break ;
167165 }
168166}
@@ -185,8 +183,15 @@ static int tasdevice_get_profile_id(struct snd_kcontrol *kcontrol,
185183{
186184 struct tasdevice_priv * tas_priv = snd_kcontrol_chip (kcontrol );
187185
186+ mutex_lock (& tas_priv -> codec_lock );
187+
188188 ucontrol -> value .integer .value [0 ] = tas_priv -> rcabin .profile_cfg_id ;
189189
190+ dev_dbg (tas_priv -> dev , "%s: kcontrol %s: %d\n" ,
191+ __func__ , kcontrol -> id .name , tas_priv -> rcabin .profile_cfg_id );
192+
193+ mutex_unlock (& tas_priv -> codec_lock );
194+
190195 return 0 ;
191196}
192197
@@ -200,11 +205,19 @@ static int tasdevice_set_profile_id(struct snd_kcontrol *kcontrol,
200205
201206 val = clamp (nr_profile , 0 , max );
202207
208+ mutex_lock (& tas_priv -> codec_lock );
209+
210+ dev_dbg (tas_priv -> dev , "%s: kcontrol %s: %d -> %d\n" ,
211+ __func__ , kcontrol -> id .name ,
212+ tas_priv -> rcabin .profile_cfg_id , val );
213+
203214 if (tas_priv -> rcabin .profile_cfg_id != val ) {
204215 tas_priv -> rcabin .profile_cfg_id = val ;
205216 ret = 1 ;
206217 }
207218
219+ mutex_unlock (& tas_priv -> codec_lock );
220+
208221 return ret ;
209222}
210223
@@ -241,8 +254,15 @@ static int tasdevice_program_get(struct snd_kcontrol *kcontrol,
241254{
242255 struct tasdevice_priv * tas_priv = snd_kcontrol_chip (kcontrol );
243256
257+ mutex_lock (& tas_priv -> codec_lock );
258+
244259 ucontrol -> value .integer .value [0 ] = tas_priv -> cur_prog ;
245260
261+ dev_dbg (tas_priv -> dev , "%s: kcontrol %s: %d\n" ,
262+ __func__ , kcontrol -> id .name , tas_priv -> cur_prog );
263+
264+ mutex_unlock (& tas_priv -> codec_lock );
265+
246266 return 0 ;
247267}
248268
@@ -257,11 +277,18 @@ static int tasdevice_program_put(struct snd_kcontrol *kcontrol,
257277
258278 val = clamp (nr_program , 0 , max );
259279
280+ mutex_lock (& tas_priv -> codec_lock );
281+
282+ dev_dbg (tas_priv -> dev , "%s: kcontrol %s: %d -> %d\n" ,
283+ __func__ , kcontrol -> id .name , tas_priv -> cur_prog , val );
284+
260285 if (tas_priv -> cur_prog != val ) {
261286 tas_priv -> cur_prog = val ;
262287 ret = 1 ;
263288 }
264289
290+ mutex_unlock (& tas_priv -> codec_lock );
291+
265292 return ret ;
266293}
267294
@@ -270,8 +297,15 @@ static int tasdevice_config_get(struct snd_kcontrol *kcontrol,
270297{
271298 struct tasdevice_priv * tas_priv = snd_kcontrol_chip (kcontrol );
272299
300+ mutex_lock (& tas_priv -> codec_lock );
301+
273302 ucontrol -> value .integer .value [0 ] = tas_priv -> cur_conf ;
274303
304+ dev_dbg (tas_priv -> dev , "%s: kcontrol %s: %d\n" ,
305+ __func__ , kcontrol -> id .name , tas_priv -> cur_conf );
306+
307+ mutex_unlock (& tas_priv -> codec_lock );
308+
275309 return 0 ;
276310}
277311
@@ -286,54 +320,39 @@ static int tasdevice_config_put(struct snd_kcontrol *kcontrol,
286320
287321 val = clamp (nr_config , 0 , max );
288322
323+ mutex_lock (& tas_priv -> codec_lock );
324+
325+ dev_dbg (tas_priv -> dev , "%s: kcontrol %s: %d -> %d\n" ,
326+ __func__ , kcontrol -> id .name , tas_priv -> cur_conf , val );
327+
289328 if (tas_priv -> cur_conf != val ) {
290329 tas_priv -> cur_conf = val ;
291330 ret = 1 ;
292331 }
293332
333+ mutex_unlock (& tas_priv -> codec_lock );
334+
294335 return ret ;
295336}
296337
297- /*
298- * tas2781_digital_getvol - get the volum control
299- * @kcontrol: control pointer
300- * @ucontrol: User data
301- * Customer Kcontrol for tas2781 is primarily for regmap booking, paging
302- * depends on internal regmap mechanism.
303- * tas2781 contains book and page two-level register map, especially
304- * book switching will set the register BXXP00R7F, after switching to the
305- * correct book, then leverage the mechanism for paging to access the
306- * register.
307- */
308- static int tas2781_digital_getvol (struct snd_kcontrol * kcontrol ,
338+ static int tas2781_amp_getvol (struct snd_kcontrol * kcontrol ,
309339 struct snd_ctl_elem_value * ucontrol )
310340{
311341 struct tasdevice_priv * tas_priv = snd_kcontrol_chip (kcontrol );
312342 struct soc_mixer_control * mc =
313343 (struct soc_mixer_control * )kcontrol -> private_value ;
344+ int ret ;
314345
315- return tasdevice_digital_getvol (tas_priv , ucontrol , mc );
316- }
346+ mutex_lock (& tas_priv -> codec_lock );
317347
318- static int tas2781_amp_getvol (struct snd_kcontrol * kcontrol ,
319- struct snd_ctl_elem_value * ucontrol )
320- {
321- struct tasdevice_priv * tas_priv = snd_kcontrol_chip (kcontrol );
322- struct soc_mixer_control * mc =
323- (struct soc_mixer_control * )kcontrol -> private_value ;
348+ ret = tasdevice_amp_getvol (tas_priv , ucontrol , mc );
324349
325- return tasdevice_amp_getvol (tas_priv , ucontrol , mc );
326- }
350+ dev_dbg (tas_priv -> dev , "%s: kcontrol %s: %ld\n" ,
351+ __func__ , kcontrol -> id . name , ucontrol -> value . integer . value [ 0 ]);
327352
328- static int tas2781_digital_putvol (struct snd_kcontrol * kcontrol ,
329- struct snd_ctl_elem_value * ucontrol )
330- {
331- struct tasdevice_priv * tas_priv = snd_kcontrol_chip (kcontrol );
332- struct soc_mixer_control * mc =
333- (struct soc_mixer_control * )kcontrol -> private_value ;
353+ mutex_unlock (& tas_priv -> codec_lock );
334354
335- /* The check of the given value is in tasdevice_digital_putvol. */
336- return tasdevice_digital_putvol (tas_priv , ucontrol , mc );
355+ return ret ;
337356}
338357
339358static int tas2781_amp_putvol (struct snd_kcontrol * kcontrol ,
@@ -342,19 +361,33 @@ static int tas2781_amp_putvol(struct snd_kcontrol *kcontrol,
342361 struct tasdevice_priv * tas_priv = snd_kcontrol_chip (kcontrol );
343362 struct soc_mixer_control * mc =
344363 (struct soc_mixer_control * )kcontrol -> private_value ;
364+ int ret ;
365+
366+ mutex_lock (& tas_priv -> codec_lock );
367+
368+ dev_dbg (tas_priv -> dev , "%s: kcontrol %s: -> %ld\n" ,
369+ __func__ , kcontrol -> id .name , ucontrol -> value .integer .value [0 ]);
345370
346371 /* The check of the given value is in tasdevice_amp_putvol. */
347- return tasdevice_amp_putvol (tas_priv , ucontrol , mc );
372+ ret = tasdevice_amp_putvol (tas_priv , ucontrol , mc );
373+
374+ mutex_unlock (& tas_priv -> codec_lock );
375+
376+ return ret ;
348377}
349378
350379static int tas2781_force_fwload_get (struct snd_kcontrol * kcontrol ,
351380 struct snd_ctl_elem_value * ucontrol )
352381{
353382 struct tasdevice_priv * tas_priv = snd_kcontrol_chip (kcontrol );
354383
384+ mutex_lock (& tas_priv -> codec_lock );
385+
355386 ucontrol -> value .integer .value [0 ] = (int )tas_priv -> force_fwload_status ;
356- dev_dbg (tas_priv -> dev , "%s : Force FWload %s\n" , __func__ ,
357- tas_priv -> force_fwload_status ? "ON" : "OFF" );
387+ dev_dbg (tas_priv -> dev , "%s: kcontrol %s: %d\n" ,
388+ __func__ , kcontrol -> id .name , tas_priv -> force_fwload_status );
389+
390+ mutex_unlock (& tas_priv -> codec_lock );
358391
359392 return 0 ;
360393}
@@ -365,14 +398,20 @@ static int tas2781_force_fwload_put(struct snd_kcontrol *kcontrol,
365398 struct tasdevice_priv * tas_priv = snd_kcontrol_chip (kcontrol );
366399 bool change , val = (bool )ucontrol -> value .integer .value [0 ];
367400
401+ mutex_lock (& tas_priv -> codec_lock );
402+
403+ dev_dbg (tas_priv -> dev , "%s: kcontrol %s: %d -> %d\n" ,
404+ __func__ , kcontrol -> id .name ,
405+ tas_priv -> force_fwload_status , val );
406+
368407 if (tas_priv -> force_fwload_status == val )
369408 change = false;
370409 else {
371410 change = true;
372411 tas_priv -> force_fwload_status = val ;
373412 }
374- dev_dbg ( tas_priv -> dev , "%s : Force FWload %s\n" , __func__ ,
375- tas_priv -> force_fwload_status ? "ON" : "OFF" );
413+
414+ mutex_unlock ( & tas_priv -> codec_lock );
376415
377416 return change ;
378417}
@@ -381,9 +420,6 @@ static const struct snd_kcontrol_new tas2781_snd_controls[] = {
381420 ACARD_SINGLE_RANGE_EXT_TLV ("Speaker Analog Gain" , TAS2781_AMP_LEVEL ,
382421 1 , 0 , 20 , 0 , tas2781_amp_getvol ,
383422 tas2781_amp_putvol , amp_vol_tlv ),
384- ACARD_SINGLE_RANGE_EXT_TLV ("Speaker Digital Gain" , TAS2781_DVC_LVL ,
385- 0 , 0 , 200 , 1 , tas2781_digital_getvol ,
386- tas2781_digital_putvol , dvc_tlv ),
387423 ACARD_SINGLE_BOOL_EXT ("Speaker Force Firmware Load" , 0 ,
388424 tas2781_force_fwload_get , tas2781_force_fwload_put ),
389425};
0 commit comments