aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKuninori Morimoto <kuninori.morimoto.gx@renesas.com>2018-01-28 22:02:13 -0500
committerMark Brown <broonie@kernel.org>2018-02-12 04:40:56 -0500
commit51e42c952e872ebcdbbb2418f652e9c678612072 (patch)
tree9709396377b303fa976b92718ff01c82347c0f31
parent7928b2cbe55b2a410a0f5c1f154610059c57b1b2 (diff)
ASoC: wm8776: replace codec to component
Now we can replace Codec to Component. Let's do it. Note: xxx_codec_xxx() -> xxx_component_xxx() .idle_bias_off = 0 -> .idle_bias_on = 1 .ignore_pmdown_time = 0 -> .use_pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1 Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> Signed-off-by: Mark Brown <broonie@kernel.org>
-rw-r--r--sound/soc/codecs/wm8776.c105
1 files changed, 46 insertions, 59 deletions
diff --git a/sound/soc/codecs/wm8776.c b/sound/soc/codecs/wm8776.c
index ae30480b3976..fb357e23f221 100644
--- a/sound/soc/codecs/wm8776.c
+++ b/sound/soc/codecs/wm8776.c
@@ -78,9 +78,9 @@ static bool wm8776_volatile(struct device *dev, unsigned int reg)
78 } 78 }
79} 79}
80 80
81static int wm8776_reset(struct snd_soc_codec *codec) 81static int wm8776_reset(struct snd_soc_component *component)
82{ 82{
83 return snd_soc_write(codec, WM8776_RESET, 0); 83 return snd_soc_component_write(component, WM8776_RESET, 0);
84} 84}
85 85
86static const DECLARE_TLV_DB_SCALE(hp_tlv, -12100, 100, 1); 86static const DECLARE_TLV_DB_SCALE(hp_tlv, -12100, 100, 1);
@@ -166,7 +166,7 @@ static const struct snd_soc_dapm_route routes[] = {
166 166
167static int wm8776_set_fmt(struct snd_soc_dai *dai, unsigned int fmt) 167static int wm8776_set_fmt(struct snd_soc_dai *dai, unsigned int fmt)
168{ 168{
169 struct snd_soc_codec *codec = dai->codec; 169 struct snd_soc_component *component = dai->component;
170 int reg, iface, master; 170 int reg, iface, master;
171 171
172 switch (dai->driver->id) { 172 switch (dai->driver->id) {
@@ -224,8 +224,8 @@ static int wm8776_set_fmt(struct snd_soc_dai *dai, unsigned int fmt)
224 } 224 }
225 225
226 /* Finally, write out the values */ 226 /* Finally, write out the values */
227 snd_soc_update_bits(codec, reg, 0xf, iface); 227 snd_soc_component_update_bits(component, reg, 0xf, iface);
228 snd_soc_update_bits(codec, WM8776_MSTRCTRL, 0x180, master); 228 snd_soc_component_update_bits(component, WM8776_MSTRCTRL, 0x180, master);
229 229
230 return 0; 230 return 0;
231} 231}
@@ -243,8 +243,8 @@ static int wm8776_hw_params(struct snd_pcm_substream *substream,
243 struct snd_pcm_hw_params *params, 243 struct snd_pcm_hw_params *params,
244 struct snd_soc_dai *dai) 244 struct snd_soc_dai *dai)
245{ 245{
246 struct snd_soc_codec *codec = dai->codec; 246 struct snd_soc_component *component = dai->component;
247 struct wm8776_priv *wm8776 = snd_soc_codec_get_drvdata(codec); 247 struct wm8776_priv *wm8776 = snd_soc_component_get_drvdata(component);
248 int iface_reg, iface; 248 int iface_reg, iface;
249 int ratio_shift, master; 249 int ratio_shift, master;
250 int i; 250 int i;
@@ -279,13 +279,13 @@ static int wm8776_hw_params(struct snd_pcm_substream *substream,
279 iface = 0x30; 279 iface = 0x30;
280 break; 280 break;
281 default: 281 default:
282 dev_err(codec->dev, "Unsupported sample size: %i\n", 282 dev_err(component->dev, "Unsupported sample size: %i\n",
283 params_width(params)); 283 params_width(params));
284 return -EINVAL; 284 return -EINVAL;
285 } 285 }
286 286
287 /* Only need to set MCLK/LRCLK ratio if we're master */ 287 /* Only need to set MCLK/LRCLK ratio if we're master */
288 if (snd_soc_read(codec, WM8776_MSTRCTRL) & master) { 288 if (snd_soc_component_read32(component, WM8776_MSTRCTRL) & master) {
289 for (i = 0; i < ARRAY_SIZE(mclk_ratios); i++) { 289 for (i = 0; i < ARRAY_SIZE(mclk_ratios); i++) {
290 if (wm8776->sysclk[dai->driver->id] / params_rate(params) 290 if (wm8776->sysclk[dai->driver->id] / params_rate(params)
291 == mclk_ratios[i]) 291 == mclk_ratios[i])
@@ -293,37 +293,37 @@ static int wm8776_hw_params(struct snd_pcm_substream *substream,
293 } 293 }
294 294
295 if (i == ARRAY_SIZE(mclk_ratios)) { 295 if (i == ARRAY_SIZE(mclk_ratios)) {
296 dev_err(codec->dev, 296 dev_err(component->dev,
297 "Unable to configure MCLK ratio %d/%d\n", 297 "Unable to configure MCLK ratio %d/%d\n",
298 wm8776->sysclk[dai->driver->id], params_rate(params)); 298 wm8776->sysclk[dai->driver->id], params_rate(params));
299 return -EINVAL; 299 return -EINVAL;
300 } 300 }
301 301
302 dev_dbg(codec->dev, "MCLK is %dfs\n", mclk_ratios[i]); 302 dev_dbg(component->dev, "MCLK is %dfs\n", mclk_ratios[i]);
303 303
304 snd_soc_update_bits(codec, WM8776_MSTRCTRL, 304 snd_soc_component_update_bits(component, WM8776_MSTRCTRL,
305 0x7 << ratio_shift, i << ratio_shift); 305 0x7 << ratio_shift, i << ratio_shift);
306 } else { 306 } else {
307 dev_dbg(codec->dev, "DAI in slave mode\n"); 307 dev_dbg(component->dev, "DAI in slave mode\n");
308 } 308 }
309 309
310 snd_soc_update_bits(codec, iface_reg, 0x30, iface); 310 snd_soc_component_update_bits(component, iface_reg, 0x30, iface);
311 311
312 return 0; 312 return 0;
313} 313}
314 314
315static int wm8776_mute(struct snd_soc_dai *dai, int mute) 315static int wm8776_mute(struct snd_soc_dai *dai, int mute)
316{ 316{
317 struct snd_soc_codec *codec = dai->codec; 317 struct snd_soc_component *component = dai->component;
318 318
319 return snd_soc_write(codec, WM8776_DACMUTE, !!mute); 319 return snd_soc_component_write(component, WM8776_DACMUTE, !!mute);
320} 320}
321 321
322static int wm8776_set_sysclk(struct snd_soc_dai *dai, 322static int wm8776_set_sysclk(struct snd_soc_dai *dai,
323 int clk_id, unsigned int freq, int dir) 323 int clk_id, unsigned int freq, int dir)
324{ 324{
325 struct snd_soc_codec *codec = dai->codec; 325 struct snd_soc_component *component = dai->component;
326 struct wm8776_priv *wm8776 = snd_soc_codec_get_drvdata(codec); 326 struct wm8776_priv *wm8776 = snd_soc_component_get_drvdata(component);
327 327
328 if (WARN_ON(dai->driver->id >= ARRAY_SIZE(wm8776->sysclk))) 328 if (WARN_ON(dai->driver->id >= ARRAY_SIZE(wm8776->sysclk)))
329 return -EINVAL; 329 return -EINVAL;
@@ -333,10 +333,10 @@ static int wm8776_set_sysclk(struct snd_soc_dai *dai,
333 return 0; 333 return 0;
334} 334}
335 335
336static int wm8776_set_bias_level(struct snd_soc_codec *codec, 336static int wm8776_set_bias_level(struct snd_soc_component *component,
337 enum snd_soc_bias_level level) 337 enum snd_soc_bias_level level)
338{ 338{
339 struct wm8776_priv *wm8776 = snd_soc_codec_get_drvdata(codec); 339 struct wm8776_priv *wm8776 = snd_soc_component_get_drvdata(component);
340 340
341 switch (level) { 341 switch (level) {
342 case SND_SOC_BIAS_ON: 342 case SND_SOC_BIAS_ON:
@@ -344,16 +344,16 @@ static int wm8776_set_bias_level(struct snd_soc_codec *codec,
344 case SND_SOC_BIAS_PREPARE: 344 case SND_SOC_BIAS_PREPARE:
345 break; 345 break;
346 case SND_SOC_BIAS_STANDBY: 346 case SND_SOC_BIAS_STANDBY:
347 if (snd_soc_codec_get_bias_level(codec) == SND_SOC_BIAS_OFF) { 347 if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_OFF) {
348 regcache_sync(wm8776->regmap); 348 regcache_sync(wm8776->regmap);
349 349
350 /* Disable the global powerdown; DAPM does the rest */ 350 /* Disable the global powerdown; DAPM does the rest */
351 snd_soc_update_bits(codec, WM8776_PWRDOWN, 1, 0); 351 snd_soc_component_update_bits(component, WM8776_PWRDOWN, 1, 0);
352 } 352 }
353 353
354 break; 354 break;
355 case SND_SOC_BIAS_OFF: 355 case SND_SOC_BIAS_OFF:
356 snd_soc_update_bits(codec, WM8776_PWRDOWN, 1, 1); 356 snd_soc_component_update_bits(component, WM8776_PWRDOWN, 1, 1);
357 break; 357 break;
358 } 358 }
359 359
@@ -407,37 +407,38 @@ static struct snd_soc_dai_driver wm8776_dai[] = {
407 }, 407 },
408}; 408};
409 409
410static int wm8776_probe(struct snd_soc_codec *codec) 410static int wm8776_probe(struct snd_soc_component *component)
411{ 411{
412 int ret = 0; 412 int ret = 0;
413 413
414 ret = wm8776_reset(codec); 414 ret = wm8776_reset(component);
415 if (ret < 0) { 415 if (ret < 0) {
416 dev_err(codec->dev, "Failed to issue reset: %d\n", ret); 416 dev_err(component->dev, "Failed to issue reset: %d\n", ret);
417 return ret; 417 return ret;
418 } 418 }
419 419
420 /* Latch the update bits; right channel only since we always 420 /* Latch the update bits; right channel only since we always
421 * update both. */ 421 * update both. */
422 snd_soc_update_bits(codec, WM8776_HPRVOL, 0x100, 0x100); 422 snd_soc_component_update_bits(component, WM8776_HPRVOL, 0x100, 0x100);
423 snd_soc_update_bits(codec, WM8776_DACRVOL, 0x100, 0x100); 423 snd_soc_component_update_bits(component, WM8776_DACRVOL, 0x100, 0x100);
424 424
425 return ret; 425 return ret;
426} 426}
427 427
428static const struct snd_soc_codec_driver soc_codec_dev_wm8776 = { 428static const struct snd_soc_component_driver soc_component_dev_wm8776 = {
429 .probe = wm8776_probe, 429 .probe = wm8776_probe,
430 .set_bias_level = wm8776_set_bias_level, 430 .set_bias_level = wm8776_set_bias_level,
431 .suspend_bias_off = true, 431 .controls = wm8776_snd_controls,
432 432 .num_controls = ARRAY_SIZE(wm8776_snd_controls),
433 .component_driver = { 433 .dapm_widgets = wm8776_dapm_widgets,
434 .controls = wm8776_snd_controls, 434 .num_dapm_widgets = ARRAY_SIZE(wm8776_dapm_widgets),
435 .num_controls = ARRAY_SIZE(wm8776_snd_controls), 435 .dapm_routes = routes,
436 .dapm_widgets = wm8776_dapm_widgets, 436 .num_dapm_routes = ARRAY_SIZE(routes),
437 .num_dapm_widgets = ARRAY_SIZE(wm8776_dapm_widgets), 437 .suspend_bias_off = 1,
438 .dapm_routes = routes, 438 .idle_bias_on = 1,
439 .num_dapm_routes = ARRAY_SIZE(routes), 439 .use_pmdown_time = 1,
440 }, 440 .endianness = 1,
441 .non_legacy_dai_naming = 1,
441}; 442};
442 443
443static const struct of_device_id wm8776_of_match[] = { 444static const struct of_device_id wm8776_of_match[] = {
@@ -475,25 +476,18 @@ static int wm8776_spi_probe(struct spi_device *spi)
475 476
476 spi_set_drvdata(spi, wm8776); 477 spi_set_drvdata(spi, wm8776);
477 478
478 ret = snd_soc_register_codec(&spi->dev, 479 ret = devm_snd_soc_register_component(&spi->dev,
479 &soc_codec_dev_wm8776, wm8776_dai, ARRAY_SIZE(wm8776_dai)); 480 &soc_component_dev_wm8776, wm8776_dai, ARRAY_SIZE(wm8776_dai));
480 481
481 return ret; 482 return ret;
482} 483}
483 484
484static int wm8776_spi_remove(struct spi_device *spi)
485{
486 snd_soc_unregister_codec(&spi->dev);
487 return 0;
488}
489
490static struct spi_driver wm8776_spi_driver = { 485static struct spi_driver wm8776_spi_driver = {
491 .driver = { 486 .driver = {
492 .name = "wm8776", 487 .name = "wm8776",
493 .of_match_table = wm8776_of_match, 488 .of_match_table = wm8776_of_match,
494 }, 489 },
495 .probe = wm8776_spi_probe, 490 .probe = wm8776_spi_probe,
496 .remove = wm8776_spi_remove,
497}; 491};
498#endif /* CONFIG_SPI_MASTER */ 492#endif /* CONFIG_SPI_MASTER */
499 493
@@ -515,18 +509,12 @@ static int wm8776_i2c_probe(struct i2c_client *i2c,
515 509
516 i2c_set_clientdata(i2c, wm8776); 510 i2c_set_clientdata(i2c, wm8776);
517 511
518 ret = snd_soc_register_codec(&i2c->dev, 512 ret = devm_snd_soc_register_component(&i2c->dev,
519 &soc_codec_dev_wm8776, wm8776_dai, ARRAY_SIZE(wm8776_dai)); 513 &soc_component_dev_wm8776, wm8776_dai, ARRAY_SIZE(wm8776_dai));
520 514
521 return ret; 515 return ret;
522} 516}
523 517
524static int wm8776_i2c_remove(struct i2c_client *client)
525{
526 snd_soc_unregister_codec(&client->dev);
527 return 0;
528}
529
530static const struct i2c_device_id wm8776_i2c_id[] = { 518static const struct i2c_device_id wm8776_i2c_id[] = {
531 { "wm8775", WM8775 }, 519 { "wm8775", WM8775 },
532 { "wm8776", WM8776 }, 520 { "wm8776", WM8776 },
@@ -540,7 +528,6 @@ static struct i2c_driver wm8776_i2c_driver = {
540 .of_match_table = wm8776_of_match, 528 .of_match_table = wm8776_of_match,
541 }, 529 },
542 .probe = wm8776_i2c_probe, 530 .probe = wm8776_i2c_probe,
543 .remove = wm8776_i2c_remove,
544 .id_table = wm8776_i2c_id, 531 .id_table = wm8776_i2c_id,
545}; 532};
546#endif 533#endif