aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKuninori Morimoto <kuninori.morimoto.gx@renesas.com>2018-01-28 22:04:06 -0500
committerMark Brown <broonie@kernel.org>2018-02-12 04:41:25 -0500
commit9b6a00f753ddb6fbc7e7b105bf4b9ddfef92b75c (patch)
tree9a1da3c57456c7fc252dbbd066d62e0622beec14
parent7928b2cbe55b2a410a0f5c1f154610059c57b1b2 (diff)
ASoC: wm8741: 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/wm8741.c133
1 files changed, 59 insertions, 74 deletions
diff --git a/sound/soc/codecs/wm8741.c b/sound/soc/codecs/wm8741.c
index a394dbee77aa..1fedf74da705 100644
--- a/sound/soc/codecs/wm8741.c
+++ b/sound/soc/codecs/wm8741.c
@@ -59,9 +59,9 @@ static const struct reg_default wm8741_reg_defaults[] = {
59 { 32, 0x0002 }, /* R32 - ADDITONAL_CONTROL_1 */ 59 { 32, 0x0002 }, /* R32 - ADDITONAL_CONTROL_1 */
60}; 60};
61 61
62static int wm8741_reset(struct snd_soc_codec *codec) 62static int wm8741_reset(struct snd_soc_component *component)
63{ 63{
64 return snd_soc_write(codec, WM8741_RESET, 0); 64 return snd_soc_component_write(component, WM8741_RESET, 0);
65} 65}
66 66
67static const DECLARE_TLV_DB_SCALE(dac_tlv_fine, -12700, 13, 0); 67static const DECLARE_TLV_DB_SCALE(dac_tlv_fine, -12700, 13, 0);
@@ -179,8 +179,8 @@ static const struct snd_pcm_hw_constraint_list constraints_36864 = {
179static int wm8741_startup(struct snd_pcm_substream *substream, 179static int wm8741_startup(struct snd_pcm_substream *substream,
180 struct snd_soc_dai *dai) 180 struct snd_soc_dai *dai)
181{ 181{
182 struct snd_soc_codec *codec = dai->codec; 182 struct snd_soc_component *component = dai->component;
183 struct wm8741_priv *wm8741 = snd_soc_codec_get_drvdata(codec); 183 struct wm8741_priv *wm8741 = snd_soc_component_get_drvdata(component);
184 184
185 if (wm8741->sysclk) 185 if (wm8741->sysclk)
186 snd_pcm_hw_constraint_list(substream->runtime, 0, 186 snd_pcm_hw_constraint_list(substream->runtime, 0,
@@ -194,8 +194,8 @@ static int wm8741_hw_params(struct snd_pcm_substream *substream,
194 struct snd_pcm_hw_params *params, 194 struct snd_pcm_hw_params *params,
195 struct snd_soc_dai *dai) 195 struct snd_soc_dai *dai)
196{ 196{
197 struct snd_soc_codec *codec = dai->codec; 197 struct snd_soc_component *component = dai->component;
198 struct wm8741_priv *wm8741 = snd_soc_codec_get_drvdata(codec); 198 struct wm8741_priv *wm8741 = snd_soc_component_get_drvdata(component);
199 unsigned int iface; 199 unsigned int iface;
200 int i; 200 int i;
201 201
@@ -203,7 +203,7 @@ static int wm8741_hw_params(struct snd_pcm_substream *substream,
203 * MCLK supplied to the CODEC - enforce this. 203 * MCLK supplied to the CODEC - enforce this.
204 */ 204 */
205 if (!wm8741->sysclk) { 205 if (!wm8741->sysclk) {
206 dev_err(codec->dev, 206 dev_err(component->dev,
207 "No MCLK configured, call set_sysclk() on init or in hw_params\n"); 207 "No MCLK configured, call set_sysclk() on init or in hw_params\n");
208 return -EINVAL; 208 return -EINVAL;
209 } 209 }
@@ -215,7 +215,7 @@ static int wm8741_hw_params(struct snd_pcm_substream *substream,
215 } 215 }
216 216
217 if (i == wm8741->sysclk_constraints->count) { 217 if (i == wm8741->sysclk_constraints->count) {
218 dev_err(codec->dev, "LRCLK %d unsupported with MCLK %d\n", 218 dev_err(component->dev, "LRCLK %d unsupported with MCLK %d\n",
219 params_rate(params), wm8741->sysclk); 219 params_rate(params), wm8741->sysclk);
220 return -EINVAL; 220 return -EINVAL;
221 } 221 }
@@ -235,15 +235,15 @@ static int wm8741_hw_params(struct snd_pcm_substream *substream,
235 iface = 0x3; 235 iface = 0x3;
236 break; 236 break;
237 default: 237 default:
238 dev_dbg(codec->dev, "wm8741_hw_params: Unsupported bit size param = %d", 238 dev_dbg(component->dev, "wm8741_hw_params: Unsupported bit size param = %d",
239 params_width(params)); 239 params_width(params));
240 return -EINVAL; 240 return -EINVAL;
241 } 241 }
242 242
243 dev_dbg(codec->dev, "wm8741_hw_params: bit size param = %d, rate param = %d", 243 dev_dbg(component->dev, "wm8741_hw_params: bit size param = %d, rate param = %d",
244 params_width(params), params_rate(params)); 244 params_width(params), params_rate(params));
245 245
246 snd_soc_update_bits(codec, WM8741_FORMAT_CONTROL, WM8741_IWL_MASK, 246 snd_soc_component_update_bits(component, WM8741_FORMAT_CONTROL, WM8741_IWL_MASK,
247 iface); 247 iface);
248 248
249 return 0; 249 return 0;
@@ -252,10 +252,10 @@ static int wm8741_hw_params(struct snd_pcm_substream *substream,
252static int wm8741_set_dai_sysclk(struct snd_soc_dai *codec_dai, 252static int wm8741_set_dai_sysclk(struct snd_soc_dai *codec_dai,
253 int clk_id, unsigned int freq, int dir) 253 int clk_id, unsigned int freq, int dir)
254{ 254{
255 struct snd_soc_codec *codec = codec_dai->codec; 255 struct snd_soc_component *component = codec_dai->component;
256 struct wm8741_priv *wm8741 = snd_soc_codec_get_drvdata(codec); 256 struct wm8741_priv *wm8741 = snd_soc_component_get_drvdata(component);
257 257
258 dev_dbg(codec->dev, "wm8741_set_dai_sysclk info: freq=%dHz\n", freq); 258 dev_dbg(component->dev, "wm8741_set_dai_sysclk info: freq=%dHz\n", freq);
259 259
260 switch (freq) { 260 switch (freq) {
261 case 0: 261 case 0:
@@ -297,7 +297,7 @@ static int wm8741_set_dai_sysclk(struct snd_soc_dai *codec_dai,
297static int wm8741_set_dai_fmt(struct snd_soc_dai *codec_dai, 297static int wm8741_set_dai_fmt(struct snd_soc_dai *codec_dai,
298 unsigned int fmt) 298 unsigned int fmt)
299{ 299{
300 struct snd_soc_codec *codec = codec_dai->codec; 300 struct snd_soc_component *component = codec_dai->component;
301 unsigned int iface; 301 unsigned int iface;
302 302
303 /* check master/slave audio interface */ 303 /* check master/slave audio interface */
@@ -347,11 +347,11 @@ static int wm8741_set_dai_fmt(struct snd_soc_dai *codec_dai,
347 } 347 }
348 348
349 349
350 dev_dbg(codec->dev, "wm8741_set_dai_fmt: Format=%x, Clock Inv=%x\n", 350 dev_dbg(component->dev, "wm8741_set_dai_fmt: Format=%x, Clock Inv=%x\n",
351 fmt & SND_SOC_DAIFMT_FORMAT_MASK, 351 fmt & SND_SOC_DAIFMT_FORMAT_MASK,
352 ((fmt & SND_SOC_DAIFMT_INV_MASK))); 352 ((fmt & SND_SOC_DAIFMT_INV_MASK)));
353 353
354 snd_soc_update_bits(codec, WM8741_FORMAT_CONTROL, 354 snd_soc_component_update_bits(component, WM8741_FORMAT_CONTROL,
355 WM8741_BCP_MASK | WM8741_LRP_MASK | WM8741_FMT_MASK, 355 WM8741_BCP_MASK | WM8741_LRP_MASK | WM8741_FMT_MASK,
356 iface); 356 iface);
357 357
@@ -386,18 +386,18 @@ static struct snd_soc_dai_driver wm8741_dai = {
386}; 386};
387 387
388#ifdef CONFIG_PM 388#ifdef CONFIG_PM
389static int wm8741_resume(struct snd_soc_codec *codec) 389static int wm8741_resume(struct snd_soc_component *component)
390{ 390{
391 snd_soc_cache_sync(codec); 391 snd_soc_component_cache_sync(component);
392 return 0; 392 return 0;
393} 393}
394#else 394#else
395#define wm8741_resume NULL 395#define wm8741_resume NULL
396#endif 396#endif
397 397
398static int wm8741_configure(struct snd_soc_codec *codec) 398static int wm8741_configure(struct snd_soc_component *component)
399{ 399{
400 struct wm8741_priv *wm8741 = snd_soc_codec_get_drvdata(codec); 400 struct wm8741_priv *wm8741 = snd_soc_component_get_drvdata(component);
401 401
402 /* Configure differential mode */ 402 /* Configure differential mode */
403 switch (wm8741->pdata.diff_mode) { 403 switch (wm8741->pdata.diff_mode) {
@@ -405,7 +405,7 @@ static int wm8741_configure(struct snd_soc_codec *codec)
405 case WM8741_DIFF_MODE_STEREO_REVERSED: 405 case WM8741_DIFF_MODE_STEREO_REVERSED:
406 case WM8741_DIFF_MODE_MONO_LEFT: 406 case WM8741_DIFF_MODE_MONO_LEFT:
407 case WM8741_DIFF_MODE_MONO_RIGHT: 407 case WM8741_DIFF_MODE_MONO_RIGHT:
408 snd_soc_update_bits(codec, WM8741_MODE_CONTROL_2, 408 snd_soc_component_update_bits(component, WM8741_MODE_CONTROL_2,
409 WM8741_DIFF_MASK, 409 WM8741_DIFF_MASK,
410 wm8741->pdata.diff_mode << WM8741_DIFF_SHIFT); 410 wm8741->pdata.diff_mode << WM8741_DIFF_SHIFT);
411 break; 411 break;
@@ -414,36 +414,36 @@ static int wm8741_configure(struct snd_soc_codec *codec)
414 } 414 }
415 415
416 /* Change some default settings - latch VU */ 416 /* Change some default settings - latch VU */
417 snd_soc_update_bits(codec, WM8741_DACLLSB_ATTENUATION, 417 snd_soc_component_update_bits(component, WM8741_DACLLSB_ATTENUATION,
418 WM8741_UPDATELL, WM8741_UPDATELL); 418 WM8741_UPDATELL, WM8741_UPDATELL);
419 snd_soc_update_bits(codec, WM8741_DACLMSB_ATTENUATION, 419 snd_soc_component_update_bits(component, WM8741_DACLMSB_ATTENUATION,
420 WM8741_UPDATELM, WM8741_UPDATELM); 420 WM8741_UPDATELM, WM8741_UPDATELM);
421 snd_soc_update_bits(codec, WM8741_DACRLSB_ATTENUATION, 421 snd_soc_component_update_bits(component, WM8741_DACRLSB_ATTENUATION,
422 WM8741_UPDATERL, WM8741_UPDATERL); 422 WM8741_UPDATERL, WM8741_UPDATERL);
423 snd_soc_update_bits(codec, WM8741_DACRMSB_ATTENUATION, 423 snd_soc_component_update_bits(component, WM8741_DACRMSB_ATTENUATION,
424 WM8741_UPDATERM, WM8741_UPDATERM); 424 WM8741_UPDATERM, WM8741_UPDATERM);
425 425
426 return 0; 426 return 0;
427} 427}
428 428
429static int wm8741_add_controls(struct snd_soc_codec *codec) 429static int wm8741_add_controls(struct snd_soc_component *component)
430{ 430{
431 struct wm8741_priv *wm8741 = snd_soc_codec_get_drvdata(codec); 431 struct wm8741_priv *wm8741 = snd_soc_component_get_drvdata(component);
432 432
433 switch (wm8741->pdata.diff_mode) { 433 switch (wm8741->pdata.diff_mode) {
434 case WM8741_DIFF_MODE_STEREO: 434 case WM8741_DIFF_MODE_STEREO:
435 case WM8741_DIFF_MODE_STEREO_REVERSED: 435 case WM8741_DIFF_MODE_STEREO_REVERSED:
436 snd_soc_add_codec_controls(codec, 436 snd_soc_add_component_controls(component,
437 wm8741_snd_controls_stereo, 437 wm8741_snd_controls_stereo,
438 ARRAY_SIZE(wm8741_snd_controls_stereo)); 438 ARRAY_SIZE(wm8741_snd_controls_stereo));
439 break; 439 break;
440 case WM8741_DIFF_MODE_MONO_LEFT: 440 case WM8741_DIFF_MODE_MONO_LEFT:
441 snd_soc_add_codec_controls(codec, 441 snd_soc_add_component_controls(component,
442 wm8741_snd_controls_mono_left, 442 wm8741_snd_controls_mono_left,
443 ARRAY_SIZE(wm8741_snd_controls_mono_left)); 443 ARRAY_SIZE(wm8741_snd_controls_mono_left));
444 break; 444 break;
445 case WM8741_DIFF_MODE_MONO_RIGHT: 445 case WM8741_DIFF_MODE_MONO_RIGHT:
446 snd_soc_add_codec_controls(codec, 446 snd_soc_add_component_controls(component,
447 wm8741_snd_controls_mono_right, 447 wm8741_snd_controls_mono_right,
448 ARRAY_SIZE(wm8741_snd_controls_mono_right)); 448 ARRAY_SIZE(wm8741_snd_controls_mono_right));
449 break; 449 break;
@@ -454,37 +454,37 @@ static int wm8741_add_controls(struct snd_soc_codec *codec)
454 return 0; 454 return 0;
455} 455}
456 456
457static int wm8741_probe(struct snd_soc_codec *codec) 457static int wm8741_probe(struct snd_soc_component *component)
458{ 458{
459 struct wm8741_priv *wm8741 = snd_soc_codec_get_drvdata(codec); 459 struct wm8741_priv *wm8741 = snd_soc_component_get_drvdata(component);
460 int ret = 0; 460 int ret = 0;
461 461
462 ret = regulator_bulk_enable(ARRAY_SIZE(wm8741->supplies), 462 ret = regulator_bulk_enable(ARRAY_SIZE(wm8741->supplies),
463 wm8741->supplies); 463 wm8741->supplies);
464 if (ret != 0) { 464 if (ret != 0) {
465 dev_err(codec->dev, "Failed to enable supplies: %d\n", ret); 465 dev_err(component->dev, "Failed to enable supplies: %d\n", ret);
466 goto err_get; 466 goto err_get;
467 } 467 }
468 468
469 ret = wm8741_reset(codec); 469 ret = wm8741_reset(component);
470 if (ret < 0) { 470 if (ret < 0) {
471 dev_err(codec->dev, "Failed to issue reset\n"); 471 dev_err(component->dev, "Failed to issue reset\n");
472 goto err_enable; 472 goto err_enable;
473 } 473 }
474 474
475 ret = wm8741_configure(codec); 475 ret = wm8741_configure(component);
476 if (ret < 0) { 476 if (ret < 0) {
477 dev_err(codec->dev, "Failed to change default settings\n"); 477 dev_err(component->dev, "Failed to change default settings\n");
478 goto err_enable; 478 goto err_enable;
479 } 479 }
480 480
481 ret = wm8741_add_controls(codec); 481 ret = wm8741_add_controls(component);
482 if (ret < 0) { 482 if (ret < 0) {
483 dev_err(codec->dev, "Failed to add controls\n"); 483 dev_err(component->dev, "Failed to add controls\n");
484 goto err_enable; 484 goto err_enable;
485 } 485 }
486 486
487 dev_dbg(codec->dev, "Successful registration\n"); 487 dev_dbg(component->dev, "Successful registration\n");
488 return ret; 488 return ret;
489 489
490err_enable: 490err_enable:
@@ -493,26 +493,25 @@ err_get:
493 return ret; 493 return ret;
494} 494}
495 495
496static int wm8741_remove(struct snd_soc_codec *codec) 496static void wm8741_remove(struct snd_soc_component *component)
497{ 497{
498 struct wm8741_priv *wm8741 = snd_soc_codec_get_drvdata(codec); 498 struct wm8741_priv *wm8741 = snd_soc_component_get_drvdata(component);
499 499
500 regulator_bulk_disable(ARRAY_SIZE(wm8741->supplies), wm8741->supplies); 500 regulator_bulk_disable(ARRAY_SIZE(wm8741->supplies), wm8741->supplies);
501
502 return 0;
503} 501}
504 502
505static const struct snd_soc_codec_driver soc_codec_dev_wm8741 = { 503static const struct snd_soc_component_driver soc_component_dev_wm8741 = {
506 .probe = wm8741_probe, 504 .probe = wm8741_probe,
507 .remove = wm8741_remove, 505 .remove = wm8741_remove,
508 .resume = wm8741_resume, 506 .resume = wm8741_resume,
509 507 .dapm_widgets = wm8741_dapm_widgets,
510 .component_driver = { 508 .num_dapm_widgets = ARRAY_SIZE(wm8741_dapm_widgets),
511 .dapm_widgets = wm8741_dapm_widgets, 509 .dapm_routes = wm8741_dapm_routes,
512 .num_dapm_widgets = ARRAY_SIZE(wm8741_dapm_widgets), 510 .num_dapm_routes = ARRAY_SIZE(wm8741_dapm_routes),
513 .dapm_routes = wm8741_dapm_routes, 511 .idle_bias_on = 1,
514 .num_dapm_routes = ARRAY_SIZE(wm8741_dapm_routes), 512 .use_pmdown_time = 1,
515 }, 513 .endianness = 1,
514 .non_legacy_dai_naming = 1,
516}; 515};
517 516
518static const struct of_device_id wm8741_of_match[] = { 517static const struct of_device_id wm8741_of_match[] = {
@@ -585,18 +584,12 @@ static int wm8741_i2c_probe(struct i2c_client *i2c,
585 584
586 i2c_set_clientdata(i2c, wm8741); 585 i2c_set_clientdata(i2c, wm8741);
587 586
588 ret = snd_soc_register_codec(&i2c->dev, 587 ret = devm_snd_soc_register_component(&i2c->dev,
589 &soc_codec_dev_wm8741, &wm8741_dai, 1); 588 &soc_component_dev_wm8741, &wm8741_dai, 1);
590 589
591 return ret; 590 return ret;
592} 591}
593 592
594static int wm8741_i2c_remove(struct i2c_client *client)
595{
596 snd_soc_unregister_codec(&client->dev);
597 return 0;
598}
599
600static const struct i2c_device_id wm8741_i2c_id[] = { 593static const struct i2c_device_id wm8741_i2c_id[] = {
601 { "wm8741", 0 }, 594 { "wm8741", 0 },
602 { } 595 { }
@@ -609,7 +602,6 @@ static struct i2c_driver wm8741_i2c_driver = {
609 .of_match_table = wm8741_of_match, 602 .of_match_table = wm8741_of_match,
610 }, 603 },
611 .probe = wm8741_i2c_probe, 604 .probe = wm8741_i2c_probe,
612 .remove = wm8741_i2c_remove,
613 .id_table = wm8741_i2c_id, 605 .id_table = wm8741_i2c_id,
614}; 606};
615#endif 607#endif
@@ -650,24 +642,17 @@ static int wm8741_spi_probe(struct spi_device *spi)
650 642
651 spi_set_drvdata(spi, wm8741); 643 spi_set_drvdata(spi, wm8741);
652 644
653 ret = snd_soc_register_codec(&spi->dev, 645 ret = devm_snd_soc_register_component(&spi->dev,
654 &soc_codec_dev_wm8741, &wm8741_dai, 1); 646 &soc_component_dev_wm8741, &wm8741_dai, 1);
655 return ret; 647 return ret;
656} 648}
657 649
658static int wm8741_spi_remove(struct spi_device *spi)
659{
660 snd_soc_unregister_codec(&spi->dev);
661 return 0;
662}
663
664static struct spi_driver wm8741_spi_driver = { 650static struct spi_driver wm8741_spi_driver = {
665 .driver = { 651 .driver = {
666 .name = "wm8741", 652 .name = "wm8741",
667 .of_match_table = wm8741_of_match, 653 .of_match_table = wm8741_of_match,
668 }, 654 },
669 .probe = wm8741_spi_probe, 655 .probe = wm8741_spi_probe,
670 .remove = wm8741_spi_remove,
671}; 656};
672#endif /* CONFIG_SPI_MASTER */ 657#endif /* CONFIG_SPI_MASTER */
673 658