Skip to content

Commit 38a72a9

Browse files
committed
Merge remote-tracking branches 'asoc/topic/wm9090', 'asoc/topic/wm9712', 'asoc/topic/wm9713' and 'asoc/topic/wm_adsp' into asoc-next
5 parents a1c83f6 + 2822e66 + 60edb20 + 91cd000 + 61fc060 commit 38a72a9

File tree

5 files changed

+87
-75
lines changed

5 files changed

+87
-75
lines changed

sound/soc/codecs/wm9090.c

Lines changed: 53 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -143,23 +143,23 @@ static bool wm9090_readable(struct device *dev, unsigned int reg)
143143
}
144144
}
145145

146-
static void wait_for_dc_servo(struct snd_soc_codec *codec)
146+
static void wait_for_dc_servo(struct snd_soc_component *component)
147147
{
148148
unsigned int reg;
149149
int count = 0;
150150

151-
dev_dbg(codec->dev, "Waiting for DC servo...\n");
151+
dev_dbg(component->dev, "Waiting for DC servo...\n");
152152
do {
153153
count++;
154154
msleep(1);
155-
reg = snd_soc_read(codec, WM9090_DC_SERVO_READBACK_0);
156-
dev_dbg(codec->dev, "DC servo status: %x\n", reg);
155+
reg = snd_soc_component_read32(component, WM9090_DC_SERVO_READBACK_0);
156+
dev_dbg(component->dev, "DC servo status: %x\n", reg);
157157
} while ((reg & WM9090_DCS_CAL_COMPLETE_MASK)
158158
!= WM9090_DCS_CAL_COMPLETE_MASK && count < 1000);
159159

160160
if ((reg & WM9090_DCS_CAL_COMPLETE_MASK)
161161
!= WM9090_DCS_CAL_COMPLETE_MASK)
162-
dev_err(codec->dev, "Timed out waiting for DC Servo\n");
162+
dev_err(component->dev, "Timed out waiting for DC Servo\n");
163163
}
164164

165165
static const DECLARE_TLV_DB_RANGE(in_tlv,
@@ -251,39 +251,39 @@ SOC_SINGLE_TLV("MIXOUTR IN2B Volume", WM9090_OUTPUT_MIXER4, 0, 3, 1,
251251
static int hp_ev(struct snd_soc_dapm_widget *w,
252252
struct snd_kcontrol *kcontrol, int event)
253253
{
254-
struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
255-
unsigned int reg = snd_soc_read(codec, WM9090_ANALOGUE_HP_0);
254+
struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm);
255+
unsigned int reg = snd_soc_component_read32(component, WM9090_ANALOGUE_HP_0);
256256

257257
switch (event) {
258258
case SND_SOC_DAPM_POST_PMU:
259-
snd_soc_update_bits(codec, WM9090_CHARGE_PUMP_1,
259+
snd_soc_component_update_bits(component, WM9090_CHARGE_PUMP_1,
260260
WM9090_CP_ENA, WM9090_CP_ENA);
261261

262262
msleep(5);
263263

264-
snd_soc_update_bits(codec, WM9090_POWER_MANAGEMENT_1,
264+
snd_soc_component_update_bits(component, WM9090_POWER_MANAGEMENT_1,
265265
WM9090_HPOUT1L_ENA | WM9090_HPOUT1R_ENA,
266266
WM9090_HPOUT1L_ENA | WM9090_HPOUT1R_ENA);
267267

268268
reg |= WM9090_HPOUT1L_DLY | WM9090_HPOUT1R_DLY;
269-
snd_soc_write(codec, WM9090_ANALOGUE_HP_0, reg);
269+
snd_soc_component_write(component, WM9090_ANALOGUE_HP_0, reg);
270270

271271
/* Start the DC servo. We don't currently use the
272272
* ability to save the state since we don't have full
273273
* control of the analogue paths and they can change
274274
* DC offsets; see the WM8904 driver for an example of
275275
* doing so.
276276
*/
277-
snd_soc_write(codec, WM9090_DC_SERVO_0,
277+
snd_soc_component_write(component, WM9090_DC_SERVO_0,
278278
WM9090_DCS_ENA_CHAN_0 |
279279
WM9090_DCS_ENA_CHAN_1 |
280280
WM9090_DCS_TRIG_STARTUP_1 |
281281
WM9090_DCS_TRIG_STARTUP_0);
282-
wait_for_dc_servo(codec);
282+
wait_for_dc_servo(component);
283283

284284
reg |= WM9090_HPOUT1R_OUTP | WM9090_HPOUT1R_RMV_SHORT |
285285
WM9090_HPOUT1L_OUTP | WM9090_HPOUT1L_RMV_SHORT;
286-
snd_soc_write(codec, WM9090_ANALOGUE_HP_0, reg);
286+
snd_soc_component_write(component, WM9090_ANALOGUE_HP_0, reg);
287287
break;
288288

289289
case SND_SOC_DAPM_PRE_PMD:
@@ -294,15 +294,15 @@ static int hp_ev(struct snd_soc_dapm_widget *w,
294294
WM9090_HPOUT1R_DLY |
295295
WM9090_HPOUT1R_OUTP);
296296

297-
snd_soc_write(codec, WM9090_ANALOGUE_HP_0, reg);
297+
snd_soc_component_write(component, WM9090_ANALOGUE_HP_0, reg);
298298

299-
snd_soc_write(codec, WM9090_DC_SERVO_0, 0);
299+
snd_soc_component_write(component, WM9090_DC_SERVO_0, 0);
300300

301-
snd_soc_update_bits(codec, WM9090_POWER_MANAGEMENT_1,
301+
snd_soc_component_update_bits(component, WM9090_POWER_MANAGEMENT_1,
302302
WM9090_HPOUT1L_ENA | WM9090_HPOUT1R_ENA,
303303
0);
304304

305-
snd_soc_update_bits(codec, WM9090_CHARGE_PUMP_1,
305+
snd_soc_component_update_bits(component, WM9090_CHARGE_PUMP_1,
306306
WM9090_CP_ENA, 0);
307307
break;
308308
}
@@ -419,18 +419,18 @@ static const struct snd_soc_dapm_route audio_map_in2_diff[] = {
419419
{ "IN2A PGA", NULL, "IN2-" },
420420
};
421421

422-
static int wm9090_add_controls(struct snd_soc_codec *codec)
422+
static int wm9090_add_controls(struct snd_soc_component *component)
423423
{
424-
struct wm9090_priv *wm9090 = snd_soc_codec_get_drvdata(codec);
425-
struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec);
424+
struct wm9090_priv *wm9090 = snd_soc_component_get_drvdata(component);
425+
struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component);
426426
int i;
427427

428428
snd_soc_dapm_new_controls(dapm, wm9090_dapm_widgets,
429429
ARRAY_SIZE(wm9090_dapm_widgets));
430430

431431
snd_soc_dapm_add_routes(dapm, audio_map, ARRAY_SIZE(audio_map));
432432

433-
snd_soc_add_codec_controls(codec, wm9090_controls,
433+
snd_soc_add_component_controls(component, wm9090_controls,
434434
ARRAY_SIZE(wm9090_controls));
435435

436436
if (wm9090->pdata.lin1_diff) {
@@ -439,7 +439,7 @@ static int wm9090_add_controls(struct snd_soc_codec *codec)
439439
} else {
440440
snd_soc_dapm_add_routes(dapm, audio_map_in1_se,
441441
ARRAY_SIZE(audio_map_in1_se));
442-
snd_soc_add_codec_controls(codec, wm9090_in1_se_controls,
442+
snd_soc_add_component_controls(component, wm9090_in1_se_controls,
443443
ARRAY_SIZE(wm9090_in1_se_controls));
444444
}
445445

@@ -449,18 +449,18 @@ static int wm9090_add_controls(struct snd_soc_codec *codec)
449449
} else {
450450
snd_soc_dapm_add_routes(dapm, audio_map_in2_se,
451451
ARRAY_SIZE(audio_map_in2_se));
452-
snd_soc_add_codec_controls(codec, wm9090_in2_se_controls,
452+
snd_soc_add_component_controls(component, wm9090_in2_se_controls,
453453
ARRAY_SIZE(wm9090_in2_se_controls));
454454
}
455455

456456
if (wm9090->pdata.agc_ena) {
457457
for (i = 0; i < ARRAY_SIZE(wm9090->pdata.agc); i++)
458-
snd_soc_write(codec, WM9090_AGC_CONTROL_0 + i,
458+
snd_soc_component_write(component, WM9090_AGC_CONTROL_0 + i,
459459
wm9090->pdata.agc[i]);
460-
snd_soc_update_bits(codec, WM9090_POWER_MANAGEMENT_3,
460+
snd_soc_component_update_bits(component, WM9090_POWER_MANAGEMENT_3,
461461
WM9090_AGC_ENA, WM9090_AGC_ENA);
462462
} else {
463-
snd_soc_update_bits(codec, WM9090_POWER_MANAGEMENT_3,
463+
snd_soc_component_update_bits(component, WM9090_POWER_MANAGEMENT_3,
464464
WM9090_AGC_ENA, 0);
465465
}
466466

@@ -472,19 +472,19 @@ static int wm9090_add_controls(struct snd_soc_codec *codec)
472472
* The machine driver should call this from their set_bias_level; if there
473473
* isn't one then this can just be set as the set_bias_level function.
474474
*/
475-
static int wm9090_set_bias_level(struct snd_soc_codec *codec,
475+
static int wm9090_set_bias_level(struct snd_soc_component *component,
476476
enum snd_soc_bias_level level)
477477
{
478-
struct wm9090_priv *wm9090 = snd_soc_codec_get_drvdata(codec);
478+
struct wm9090_priv *wm9090 = snd_soc_component_get_drvdata(component);
479479

480480
switch (level) {
481481
case SND_SOC_BIAS_ON:
482482
break;
483483

484484
case SND_SOC_BIAS_PREPARE:
485-
snd_soc_update_bits(codec, WM9090_ANTIPOP2, WM9090_VMID_ENA,
485+
snd_soc_component_update_bits(component, WM9090_ANTIPOP2, WM9090_VMID_ENA,
486486
WM9090_VMID_ENA);
487-
snd_soc_update_bits(codec, WM9090_POWER_MANAGEMENT_1,
487+
snd_soc_component_update_bits(component, WM9090_POWER_MANAGEMENT_1,
488488
WM9090_BIAS_ENA |
489489
WM9090_VMID_RES_MASK,
490490
WM9090_BIAS_ENA |
@@ -493,7 +493,7 @@ static int wm9090_set_bias_level(struct snd_soc_codec *codec,
493493
break;
494494

495495
case SND_SOC_BIAS_STANDBY:
496-
if (snd_soc_codec_get_bias_level(codec) == SND_SOC_BIAS_OFF) {
496+
if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_OFF) {
497497
/* Restore the register cache */
498498
regcache_sync(wm9090->regmap);
499499
}
@@ -502,9 +502,9 @@ static int wm9090_set_bias_level(struct snd_soc_codec *codec,
502502
* ground referenced outputs and class D speaker mean that
503503
* latency is not an issue.
504504
*/
505-
snd_soc_update_bits(codec, WM9090_POWER_MANAGEMENT_1,
505+
snd_soc_component_update_bits(component, WM9090_POWER_MANAGEMENT_1,
506506
WM9090_BIAS_ENA | WM9090_VMID_RES_MASK, 0);
507-
snd_soc_update_bits(codec, WM9090_ANTIPOP2,
507+
snd_soc_component_update_bits(component, WM9090_ANTIPOP2,
508508
WM9090_VMID_ENA, 0);
509509
break;
510510

@@ -515,45 +515,49 @@ static int wm9090_set_bias_level(struct snd_soc_codec *codec,
515515
return 0;
516516
}
517517

518-
static int wm9090_probe(struct snd_soc_codec *codec)
518+
static int wm9090_probe(struct snd_soc_component *component)
519519
{
520520
/* Configure some defaults; they will be written out when we
521521
* bring the bias up.
522522
*/
523-
snd_soc_update_bits(codec, WM9090_IN1_LINE_INPUT_A_VOLUME,
523+
snd_soc_component_update_bits(component, WM9090_IN1_LINE_INPUT_A_VOLUME,
524524
WM9090_IN1_VU | WM9090_IN1A_ZC,
525525
WM9090_IN1_VU | WM9090_IN1A_ZC);
526-
snd_soc_update_bits(codec, WM9090_IN1_LINE_INPUT_B_VOLUME,
526+
snd_soc_component_update_bits(component, WM9090_IN1_LINE_INPUT_B_VOLUME,
527527
WM9090_IN1_VU | WM9090_IN1B_ZC,
528528
WM9090_IN1_VU | WM9090_IN1B_ZC);
529-
snd_soc_update_bits(codec, WM9090_IN2_LINE_INPUT_A_VOLUME,
529+
snd_soc_component_update_bits(component, WM9090_IN2_LINE_INPUT_A_VOLUME,
530530
WM9090_IN2_VU | WM9090_IN2A_ZC,
531531
WM9090_IN2_VU | WM9090_IN2A_ZC);
532-
snd_soc_update_bits(codec, WM9090_IN2_LINE_INPUT_B_VOLUME,
532+
snd_soc_component_update_bits(component, WM9090_IN2_LINE_INPUT_B_VOLUME,
533533
WM9090_IN2_VU | WM9090_IN2B_ZC,
534534
WM9090_IN2_VU | WM9090_IN2B_ZC);
535-
snd_soc_update_bits(codec, WM9090_SPEAKER_VOLUME_LEFT,
535+
snd_soc_component_update_bits(component, WM9090_SPEAKER_VOLUME_LEFT,
536536
WM9090_SPKOUT_VU | WM9090_SPKOUTL_ZC,
537537
WM9090_SPKOUT_VU | WM9090_SPKOUTL_ZC);
538-
snd_soc_update_bits(codec, WM9090_LEFT_OUTPUT_VOLUME,
538+
snd_soc_component_update_bits(component, WM9090_LEFT_OUTPUT_VOLUME,
539539
WM9090_HPOUT1_VU | WM9090_HPOUT1L_ZC,
540540
WM9090_HPOUT1_VU | WM9090_HPOUT1L_ZC);
541-
snd_soc_update_bits(codec, WM9090_RIGHT_OUTPUT_VOLUME,
541+
snd_soc_component_update_bits(component, WM9090_RIGHT_OUTPUT_VOLUME,
542542
WM9090_HPOUT1_VU | WM9090_HPOUT1R_ZC,
543543
WM9090_HPOUT1_VU | WM9090_HPOUT1R_ZC);
544544

545-
snd_soc_update_bits(codec, WM9090_CLOCKING_1,
545+
snd_soc_component_update_bits(component, WM9090_CLOCKING_1,
546546
WM9090_TOCLK_ENA, WM9090_TOCLK_ENA);
547547

548-
wm9090_add_controls(codec);
548+
wm9090_add_controls(component);
549549

550550
return 0;
551551
}
552552

553-
static const struct snd_soc_codec_driver soc_codec_dev_wm9090 = {
554-
.probe = wm9090_probe,
555-
.set_bias_level = wm9090_set_bias_level,
556-
.suspend_bias_off = true,
553+
static const struct snd_soc_component_driver soc_component_dev_wm9090 = {
554+
.probe = wm9090_probe,
555+
.set_bias_level = wm9090_set_bias_level,
556+
.suspend_bias_off = 1,
557+
.idle_bias_on = 1,
558+
.use_pmdown_time = 1,
559+
.endianness = 1,
560+
.non_legacy_dai_naming = 1,
557561
};
558562

559563
static const struct regmap_config wm9090_regmap = {
@@ -607,8 +611,8 @@ static int wm9090_i2c_probe(struct i2c_client *i2c,
607611

608612
i2c_set_clientdata(i2c, wm9090);
609613

610-
ret = snd_soc_register_codec(&i2c->dev,
611-
&soc_codec_dev_wm9090, NULL, 0);
614+
ret = devm_snd_soc_register_component(&i2c->dev,
615+
&soc_component_dev_wm9090, NULL, 0);
612616
if (ret != 0) {
613617
dev_err(&i2c->dev, "Failed to register CODEC: %d\n", ret);
614618
return ret;
@@ -617,12 +621,6 @@ static int wm9090_i2c_probe(struct i2c_client *i2c,
617621
return 0;
618622
}
619623

620-
static int wm9090_i2c_remove(struct i2c_client *i2c)
621-
{
622-
snd_soc_unregister_codec(&i2c->dev);
623-
return 0;
624-
}
625-
626624
static const struct i2c_device_id wm9090_id[] = {
627625
{ "wm9090", 0 },
628626
{ "wm9093", 0 },
@@ -635,7 +633,6 @@ static struct i2c_driver wm9090_i2c_driver = {
635633
.name = "wm9090",
636634
},
637635
.probe = wm9090_i2c_probe,
638-
.remove = wm9090_i2c_remove,
639636
.id_table = wm9090_id,
640637
};
641638

sound/soc/codecs/wm9712.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ static int wm9712_hp_mixer_put(struct snd_kcontrol *kcontrol,
226226
struct soc_mixer_control *mc =
227227
(struct soc_mixer_control *)kcontrol->private_value;
228228
unsigned int mixer, mask, shift, old;
229-
struct snd_soc_dapm_update update = { 0 };
229+
struct snd_soc_dapm_update update = {};
230230
bool change;
231231

232232
mixer = mc->shift >> 8;

sound/soc/codecs/wm9713.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ static int wm9713_hp_mixer_put(struct snd_kcontrol *kcontrol,
235235
struct soc_mixer_control *mc =
236236
(struct soc_mixer_control *)kcontrol->private_value;
237237
unsigned int mixer, mask, shift, old;
238-
struct snd_soc_dapm_update update = { 0 };
238+
struct snd_soc_dapm_update update = {};
239239
bool change;
240240

241241
mixer = mc->shift >> 8;

sound/soc/codecs/wm_adsp.c

Lines changed: 28 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1239,9 +1239,16 @@ static int wm_coeff_init_control_caches(struct wm_adsp *dsp)
12391239
if (ctl->flags & WMFW_CTL_FLAG_VOLATILE)
12401240
continue;
12411241

1242-
ret = wm_coeff_read_control(ctl, ctl->cache, ctl->len);
1243-
if (ret < 0)
1244-
return ret;
1242+
/*
1243+
* For readable controls populate the cache from the DSP memory.
1244+
* For non-readable controls the cache was zero-filled when
1245+
* created so we don't need to do anything.
1246+
*/
1247+
if (!ctl->flags || (ctl->flags & WMFW_CTL_FLAG_READABLE)) {
1248+
ret = wm_coeff_read_control(ctl, ctl->cache, ctl->len);
1249+
if (ret < 0)
1250+
return ret;
1251+
}
12451252
}
12461253

12471254
return 0;
@@ -3253,6 +3260,13 @@ static int wm_adsp_buffer_populate(struct wm_adsp_compr_buf *buf)
32533260
return 0;
32543261
}
32553262

3263+
static void wm_adsp_buffer_clear(struct wm_adsp_compr_buf *buf)
3264+
{
3265+
buf->irq_count = 0xFFFFFFFF;
3266+
buf->read_index = -1;
3267+
buf->avail = 0;
3268+
}
3269+
32563270
static int wm_adsp_buffer_init(struct wm_adsp *dsp)
32573271
{
32583272
struct wm_adsp_compr_buf *buf;
@@ -3263,8 +3277,8 @@ static int wm_adsp_buffer_init(struct wm_adsp *dsp)
32633277
return -ENOMEM;
32643278

32653279
buf->dsp = dsp;
3266-
buf->read_index = -1;
3267-
buf->irq_count = 0xFFFFFFFF;
3280+
3281+
wm_adsp_buffer_clear(buf);
32683282

32693283
ret = wm_adsp_buffer_locate(buf);
32703284
if (ret < 0) {
@@ -3322,16 +3336,17 @@ int wm_adsp_compr_trigger(struct snd_compr_stream *stream, int cmd)
33223336

33233337
switch (cmd) {
33243338
case SNDRV_PCM_TRIGGER_START:
3325-
if (wm_adsp_compr_attached(compr))
3326-
break;
3327-
3328-
ret = wm_adsp_compr_attach(compr);
3329-
if (ret < 0) {
3330-
adsp_err(dsp, "Failed to link buffer and stream: %d\n",
3331-
ret);
3332-
break;
3339+
if (!wm_adsp_compr_attached(compr)) {
3340+
ret = wm_adsp_compr_attach(compr);
3341+
if (ret < 0) {
3342+
adsp_err(dsp, "Failed to link buffer and stream: %d\n",
3343+
ret);
3344+
break;
3345+
}
33333346
}
33343347

3348+
wm_adsp_buffer_clear(compr->buf);
3349+
33353350
/* Trigger the IRQ at one fragment of data */
33363351
ret = wm_adsp_buffer_write(compr->buf,
33373352
HOST_BUFFER_FIELD(high_water_mark),

sound/soc/codecs/wm_adsp.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,10 @@ struct wm_adsp {
6464
struct regmap *regmap;
6565
struct snd_soc_component *component;
6666

67-
int base;
68-
int sysclk_reg;
69-
int sysclk_mask;
70-
int sysclk_shift;
67+
unsigned int base;
68+
unsigned int sysclk_reg;
69+
unsigned int sysclk_mask;
70+
unsigned int sysclk_shift;
7171

7272
struct list_head alg_regions;
7373

0 commit comments

Comments
 (0)