@@ -185,8 +185,12 @@ static int tasdevice_get_profile_id(struct snd_kcontrol *kcontrol,
185
185
{
186
186
struct tasdevice_priv * tas_priv = snd_kcontrol_chip (kcontrol );
187
187
188
+ mutex_lock (& tas_priv -> codec_lock );
189
+
188
190
ucontrol -> value .integer .value [0 ] = tas_priv -> rcabin .profile_cfg_id ;
189
191
192
+ mutex_unlock (& tas_priv -> codec_lock );
193
+
190
194
return 0 ;
191
195
}
192
196
@@ -200,11 +204,15 @@ static int tasdevice_set_profile_id(struct snd_kcontrol *kcontrol,
200
204
201
205
val = clamp (nr_profile , 0 , max );
202
206
207
+ mutex_lock (& tas_priv -> codec_lock );
208
+
203
209
if (tas_priv -> rcabin .profile_cfg_id != val ) {
204
210
tas_priv -> rcabin .profile_cfg_id = val ;
205
211
ret = 1 ;
206
212
}
207
213
214
+ mutex_unlock (& tas_priv -> codec_lock );
215
+
208
216
return ret ;
209
217
}
210
218
@@ -241,8 +249,12 @@ static int tasdevice_program_get(struct snd_kcontrol *kcontrol,
241
249
{
242
250
struct tasdevice_priv * tas_priv = snd_kcontrol_chip (kcontrol );
243
251
252
+ mutex_lock (& tas_priv -> codec_lock );
253
+
244
254
ucontrol -> value .integer .value [0 ] = tas_priv -> cur_prog ;
245
255
256
+ mutex_unlock (& tas_priv -> codec_lock );
257
+
246
258
return 0 ;
247
259
}
248
260
@@ -257,11 +269,15 @@ static int tasdevice_program_put(struct snd_kcontrol *kcontrol,
257
269
258
270
val = clamp (nr_program , 0 , max );
259
271
272
+ mutex_lock (& tas_priv -> codec_lock );
273
+
260
274
if (tas_priv -> cur_prog != val ) {
261
275
tas_priv -> cur_prog = val ;
262
276
ret = 1 ;
263
277
}
264
278
279
+ mutex_unlock (& tas_priv -> codec_lock );
280
+
265
281
return ret ;
266
282
}
267
283
@@ -270,8 +286,12 @@ static int tasdevice_config_get(struct snd_kcontrol *kcontrol,
270
286
{
271
287
struct tasdevice_priv * tas_priv = snd_kcontrol_chip (kcontrol );
272
288
289
+ mutex_lock (& tas_priv -> codec_lock );
290
+
273
291
ucontrol -> value .integer .value [0 ] = tas_priv -> cur_conf ;
274
292
293
+ mutex_unlock (& tas_priv -> codec_lock );
294
+
275
295
return 0 ;
276
296
}
277
297
@@ -286,11 +306,15 @@ static int tasdevice_config_put(struct snd_kcontrol *kcontrol,
286
306
287
307
val = clamp (nr_config , 0 , max );
288
308
309
+ mutex_lock (& tas_priv -> codec_lock );
310
+
289
311
if (tas_priv -> cur_conf != val ) {
290
312
tas_priv -> cur_conf = val ;
291
313
ret = 1 ;
292
314
}
293
315
316
+ mutex_unlock (& tas_priv -> codec_lock );
317
+
294
318
return ret ;
295
319
}
296
320
@@ -300,8 +324,15 @@ static int tas2781_amp_getvol(struct snd_kcontrol *kcontrol,
300
324
struct tasdevice_priv * tas_priv = snd_kcontrol_chip (kcontrol );
301
325
struct soc_mixer_control * mc =
302
326
(struct soc_mixer_control * )kcontrol -> private_value ;
327
+ int ret ;
328
+
329
+ mutex_lock (& tas_priv -> codec_lock );
330
+
331
+ ret = tasdevice_amp_getvol (tas_priv , ucontrol , mc );
332
+
333
+ mutex_unlock (& tas_priv -> codec_lock );
303
334
304
- return tasdevice_amp_getvol ( tas_priv , ucontrol , mc ) ;
335
+ return ret ;
305
336
}
306
337
307
338
static int tas2781_amp_putvol (struct snd_kcontrol * kcontrol ,
@@ -310,20 +341,31 @@ static int tas2781_amp_putvol(struct snd_kcontrol *kcontrol,
310
341
struct tasdevice_priv * tas_priv = snd_kcontrol_chip (kcontrol );
311
342
struct soc_mixer_control * mc =
312
343
(struct soc_mixer_control * )kcontrol -> private_value ;
344
+ int ret ;
345
+
346
+ mutex_lock (& tas_priv -> codec_lock );
313
347
314
348
/* The check of the given value is in tasdevice_amp_putvol. */
315
- return tasdevice_amp_putvol (tas_priv , ucontrol , mc );
349
+ ret = tasdevice_amp_putvol (tas_priv , ucontrol , mc );
350
+
351
+ mutex_unlock (& tas_priv -> codec_lock );
352
+
353
+ return ret ;
316
354
}
317
355
318
356
static int tas2781_force_fwload_get (struct snd_kcontrol * kcontrol ,
319
357
struct snd_ctl_elem_value * ucontrol )
320
358
{
321
359
struct tasdevice_priv * tas_priv = snd_kcontrol_chip (kcontrol );
322
360
361
+ mutex_lock (& tas_priv -> codec_lock );
362
+
323
363
ucontrol -> value .integer .value [0 ] = (int )tas_priv -> force_fwload_status ;
324
364
dev_dbg (tas_priv -> dev , "%s : Force FWload %s\n" , __func__ ,
325
365
tas_priv -> force_fwload_status ? "ON" : "OFF" );
326
366
367
+ mutex_unlock (& tas_priv -> codec_lock );
368
+
327
369
return 0 ;
328
370
}
329
371
@@ -333,6 +375,8 @@ static int tas2781_force_fwload_put(struct snd_kcontrol *kcontrol,
333
375
struct tasdevice_priv * tas_priv = snd_kcontrol_chip (kcontrol );
334
376
bool change , val = (bool )ucontrol -> value .integer .value [0 ];
335
377
378
+ mutex_lock (& tas_priv -> codec_lock );
379
+
336
380
if (tas_priv -> force_fwload_status == val )
337
381
change = false;
338
382
else {
@@ -342,6 +386,8 @@ static int tas2781_force_fwload_put(struct snd_kcontrol *kcontrol,
342
386
dev_dbg (tas_priv -> dev , "%s : Force FWload %s\n" , __func__ ,
343
387
tas_priv -> force_fwload_status ? "ON" : "OFF" );
344
388
389
+ mutex_unlock (& tas_priv -> codec_lock );
390
+
345
391
return change ;
346
392
}
347
393
0 commit comments