diff options
author | Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> | 2018-01-28 22:53:51 -0500 |
---|---|---|
committer | Mark Brown <broonie@kernel.org> | 2018-02-12 04:46:46 -0500 |
commit | aebbf9cc42d6001dcf8872600e55df6e5bd3d406 (patch) | |
tree | 30ce477aa0672078579c636355e4631c41b12b7f | |
parent | 7928b2cbe55b2a410a0f5c1f154610059c57b1b2 (diff) |
ASoC: cs4265: 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/cs4265.c | 98 |
1 files changed, 46 insertions, 52 deletions
diff --git a/sound/soc/codecs/cs4265.c b/sound/soc/codecs/cs4265.c index fd966bb851cb..275677de669f 100644 --- a/sound/soc/codecs/cs4265.c +++ b/sound/soc/codecs/cs4265.c | |||
@@ -322,12 +322,12 @@ static int cs4265_get_clk_index(int mclk, int rate) | |||
322 | static int cs4265_set_sysclk(struct snd_soc_dai *codec_dai, int clk_id, | 322 | static int cs4265_set_sysclk(struct snd_soc_dai *codec_dai, int clk_id, |
323 | unsigned int freq, int dir) | 323 | unsigned int freq, int dir) |
324 | { | 324 | { |
325 | struct snd_soc_codec *codec = codec_dai->codec; | 325 | struct snd_soc_component *component = codec_dai->component; |
326 | struct cs4265_private *cs4265 = snd_soc_codec_get_drvdata(codec); | 326 | struct cs4265_private *cs4265 = snd_soc_component_get_drvdata(component); |
327 | int i; | 327 | int i; |
328 | 328 | ||
329 | if (clk_id != 0) { | 329 | if (clk_id != 0) { |
330 | dev_err(codec->dev, "Invalid clk_id %d\n", clk_id); | 330 | dev_err(component->dev, "Invalid clk_id %d\n", clk_id); |
331 | return -EINVAL; | 331 | return -EINVAL; |
332 | } | 332 | } |
333 | for (i = 0; i < ARRAY_SIZE(clk_map_table); i++) { | 333 | for (i = 0; i < ARRAY_SIZE(clk_map_table); i++) { |
@@ -337,24 +337,24 @@ static int cs4265_set_sysclk(struct snd_soc_dai *codec_dai, int clk_id, | |||
337 | } | 337 | } |
338 | } | 338 | } |
339 | cs4265->sysclk = 0; | 339 | cs4265->sysclk = 0; |
340 | dev_err(codec->dev, "Invalid freq parameter %d\n", freq); | 340 | dev_err(component->dev, "Invalid freq parameter %d\n", freq); |
341 | return -EINVAL; | 341 | return -EINVAL; |
342 | } | 342 | } |
343 | 343 | ||
344 | static int cs4265_set_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt) | 344 | static int cs4265_set_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt) |
345 | { | 345 | { |
346 | struct snd_soc_codec *codec = codec_dai->codec; | 346 | struct snd_soc_component *component = codec_dai->component; |
347 | struct cs4265_private *cs4265 = snd_soc_codec_get_drvdata(codec); | 347 | struct cs4265_private *cs4265 = snd_soc_component_get_drvdata(component); |
348 | u8 iface = 0; | 348 | u8 iface = 0; |
349 | 349 | ||
350 | switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { | 350 | switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { |
351 | case SND_SOC_DAIFMT_CBM_CFM: | 351 | case SND_SOC_DAIFMT_CBM_CFM: |
352 | snd_soc_update_bits(codec, CS4265_ADC_CTL, | 352 | snd_soc_component_update_bits(component, CS4265_ADC_CTL, |
353 | CS4265_ADC_MASTER, | 353 | CS4265_ADC_MASTER, |
354 | CS4265_ADC_MASTER); | 354 | CS4265_ADC_MASTER); |
355 | break; | 355 | break; |
356 | case SND_SOC_DAIFMT_CBS_CFS: | 356 | case SND_SOC_DAIFMT_CBS_CFS: |
357 | snd_soc_update_bits(codec, CS4265_ADC_CTL, | 357 | snd_soc_component_update_bits(component, CS4265_ADC_CTL, |
358 | CS4265_ADC_MASTER, | 358 | CS4265_ADC_MASTER, |
359 | 0); | 359 | 0); |
360 | break; | 360 | break; |
@@ -383,20 +383,20 @@ static int cs4265_set_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt) | |||
383 | 383 | ||
384 | static int cs4265_digital_mute(struct snd_soc_dai *dai, int mute) | 384 | static int cs4265_digital_mute(struct snd_soc_dai *dai, int mute) |
385 | { | 385 | { |
386 | struct snd_soc_codec *codec = dai->codec; | 386 | struct snd_soc_component *component = dai->component; |
387 | 387 | ||
388 | if (mute) { | 388 | if (mute) { |
389 | snd_soc_update_bits(codec, CS4265_DAC_CTL, | 389 | snd_soc_component_update_bits(component, CS4265_DAC_CTL, |
390 | CS4265_DAC_CTL_MUTE, | 390 | CS4265_DAC_CTL_MUTE, |
391 | CS4265_DAC_CTL_MUTE); | 391 | CS4265_DAC_CTL_MUTE); |
392 | snd_soc_update_bits(codec, CS4265_SPDIF_CTL2, | 392 | snd_soc_component_update_bits(component, CS4265_SPDIF_CTL2, |
393 | CS4265_SPDIF_CTL2_MUTE, | 393 | CS4265_SPDIF_CTL2_MUTE, |
394 | CS4265_SPDIF_CTL2_MUTE); | 394 | CS4265_SPDIF_CTL2_MUTE); |
395 | } else { | 395 | } else { |
396 | snd_soc_update_bits(codec, CS4265_DAC_CTL, | 396 | snd_soc_component_update_bits(component, CS4265_DAC_CTL, |
397 | CS4265_DAC_CTL_MUTE, | 397 | CS4265_DAC_CTL_MUTE, |
398 | 0); | 398 | 0); |
399 | snd_soc_update_bits(codec, CS4265_SPDIF_CTL2, | 399 | snd_soc_component_update_bits(component, CS4265_SPDIF_CTL2, |
400 | CS4265_SPDIF_CTL2_MUTE, | 400 | CS4265_SPDIF_CTL2_MUTE, |
401 | 0); | 401 | 0); |
402 | } | 402 | } |
@@ -407,8 +407,8 @@ static int cs4265_pcm_hw_params(struct snd_pcm_substream *substream, | |||
407 | struct snd_pcm_hw_params *params, | 407 | struct snd_pcm_hw_params *params, |
408 | struct snd_soc_dai *dai) | 408 | struct snd_soc_dai *dai) |
409 | { | 409 | { |
410 | struct snd_soc_codec *codec = dai->codec; | 410 | struct snd_soc_component *component = dai->component; |
411 | struct cs4265_private *cs4265 = snd_soc_codec_get_drvdata(codec); | 411 | struct cs4265_private *cs4265 = snd_soc_component_get_drvdata(component); |
412 | int index; | 412 | int index; |
413 | 413 | ||
414 | if (substream->stream == SNDRV_PCM_STREAM_CAPTURE && | 414 | if (substream->stream == SNDRV_PCM_STREAM_CAPTURE && |
@@ -418,45 +418,45 @@ static int cs4265_pcm_hw_params(struct snd_pcm_substream *substream, | |||
418 | 418 | ||
419 | index = cs4265_get_clk_index(cs4265->sysclk, params_rate(params)); | 419 | index = cs4265_get_clk_index(cs4265->sysclk, params_rate(params)); |
420 | if (index >= 0) { | 420 | if (index >= 0) { |
421 | snd_soc_update_bits(codec, CS4265_ADC_CTL, | 421 | snd_soc_component_update_bits(component, CS4265_ADC_CTL, |
422 | CS4265_ADC_FM, clk_map_table[index].fm_mode << 6); | 422 | CS4265_ADC_FM, clk_map_table[index].fm_mode << 6); |
423 | snd_soc_update_bits(codec, CS4265_MCLK_FREQ, | 423 | snd_soc_component_update_bits(component, CS4265_MCLK_FREQ, |
424 | CS4265_MCLK_FREQ_MASK, | 424 | CS4265_MCLK_FREQ_MASK, |
425 | clk_map_table[index].mclkdiv << 4); | 425 | clk_map_table[index].mclkdiv << 4); |
426 | 426 | ||
427 | } else { | 427 | } else { |
428 | dev_err(codec->dev, "can't get correct mclk\n"); | 428 | dev_err(component->dev, "can't get correct mclk\n"); |
429 | return -EINVAL; | 429 | return -EINVAL; |
430 | } | 430 | } |
431 | 431 | ||
432 | switch (cs4265->format & SND_SOC_DAIFMT_FORMAT_MASK) { | 432 | switch (cs4265->format & SND_SOC_DAIFMT_FORMAT_MASK) { |
433 | case SND_SOC_DAIFMT_I2S: | 433 | case SND_SOC_DAIFMT_I2S: |
434 | snd_soc_update_bits(codec, CS4265_DAC_CTL, | 434 | snd_soc_component_update_bits(component, CS4265_DAC_CTL, |
435 | CS4265_DAC_CTL_DIF, (1 << 4)); | 435 | CS4265_DAC_CTL_DIF, (1 << 4)); |
436 | snd_soc_update_bits(codec, CS4265_ADC_CTL, | 436 | snd_soc_component_update_bits(component, CS4265_ADC_CTL, |
437 | CS4265_ADC_DIF, (1 << 4)); | 437 | CS4265_ADC_DIF, (1 << 4)); |
438 | snd_soc_update_bits(codec, CS4265_SPDIF_CTL2, | 438 | snd_soc_component_update_bits(component, CS4265_SPDIF_CTL2, |
439 | CS4265_SPDIF_CTL2_DIF, (1 << 6)); | 439 | CS4265_SPDIF_CTL2_DIF, (1 << 6)); |
440 | break; | 440 | break; |
441 | case SND_SOC_DAIFMT_RIGHT_J: | 441 | case SND_SOC_DAIFMT_RIGHT_J: |
442 | if (params_width(params) == 16) { | 442 | if (params_width(params) == 16) { |
443 | snd_soc_update_bits(codec, CS4265_DAC_CTL, | 443 | snd_soc_component_update_bits(component, CS4265_DAC_CTL, |
444 | CS4265_DAC_CTL_DIF, (2 << 4)); | 444 | CS4265_DAC_CTL_DIF, (2 << 4)); |
445 | snd_soc_update_bits(codec, CS4265_SPDIF_CTL2, | 445 | snd_soc_component_update_bits(component, CS4265_SPDIF_CTL2, |
446 | CS4265_SPDIF_CTL2_DIF, (2 << 6)); | 446 | CS4265_SPDIF_CTL2_DIF, (2 << 6)); |
447 | } else { | 447 | } else { |
448 | snd_soc_update_bits(codec, CS4265_DAC_CTL, | 448 | snd_soc_component_update_bits(component, CS4265_DAC_CTL, |
449 | CS4265_DAC_CTL_DIF, (3 << 4)); | 449 | CS4265_DAC_CTL_DIF, (3 << 4)); |
450 | snd_soc_update_bits(codec, CS4265_SPDIF_CTL2, | 450 | snd_soc_component_update_bits(component, CS4265_SPDIF_CTL2, |
451 | CS4265_SPDIF_CTL2_DIF, (3 << 6)); | 451 | CS4265_SPDIF_CTL2_DIF, (3 << 6)); |
452 | } | 452 | } |
453 | break; | 453 | break; |
454 | case SND_SOC_DAIFMT_LEFT_J: | 454 | case SND_SOC_DAIFMT_LEFT_J: |
455 | snd_soc_update_bits(codec, CS4265_DAC_CTL, | 455 | snd_soc_component_update_bits(component, CS4265_DAC_CTL, |
456 | CS4265_DAC_CTL_DIF, 0); | 456 | CS4265_DAC_CTL_DIF, 0); |
457 | snd_soc_update_bits(codec, CS4265_ADC_CTL, | 457 | snd_soc_component_update_bits(component, CS4265_ADC_CTL, |
458 | CS4265_ADC_DIF, 0); | 458 | CS4265_ADC_DIF, 0); |
459 | snd_soc_update_bits(codec, CS4265_SPDIF_CTL2, | 459 | snd_soc_component_update_bits(component, CS4265_SPDIF_CTL2, |
460 | CS4265_SPDIF_CTL2_DIF, 0); | 460 | CS4265_SPDIF_CTL2_DIF, 0); |
461 | 461 | ||
462 | break; | 462 | break; |
@@ -466,23 +466,23 @@ static int cs4265_pcm_hw_params(struct snd_pcm_substream *substream, | |||
466 | return 0; | 466 | return 0; |
467 | } | 467 | } |
468 | 468 | ||
469 | static int cs4265_set_bias_level(struct snd_soc_codec *codec, | 469 | static int cs4265_set_bias_level(struct snd_soc_component *component, |
470 | enum snd_soc_bias_level level) | 470 | enum snd_soc_bias_level level) |
471 | { | 471 | { |
472 | switch (level) { | 472 | switch (level) { |
473 | case SND_SOC_BIAS_ON: | 473 | case SND_SOC_BIAS_ON: |
474 | break; | 474 | break; |
475 | case SND_SOC_BIAS_PREPARE: | 475 | case SND_SOC_BIAS_PREPARE: |
476 | snd_soc_update_bits(codec, CS4265_PWRCTL, | 476 | snd_soc_component_update_bits(component, CS4265_PWRCTL, |
477 | CS4265_PWRCTL_PDN, 0); | 477 | CS4265_PWRCTL_PDN, 0); |
478 | break; | 478 | break; |
479 | case SND_SOC_BIAS_STANDBY: | 479 | case SND_SOC_BIAS_STANDBY: |
480 | snd_soc_update_bits(codec, CS4265_PWRCTL, | 480 | snd_soc_component_update_bits(component, CS4265_PWRCTL, |
481 | CS4265_PWRCTL_PDN, | 481 | CS4265_PWRCTL_PDN, |
482 | CS4265_PWRCTL_PDN); | 482 | CS4265_PWRCTL_PDN); |
483 | break; | 483 | break; |
484 | case SND_SOC_BIAS_OFF: | 484 | case SND_SOC_BIAS_OFF: |
485 | snd_soc_update_bits(codec, CS4265_PWRCTL, | 485 | snd_soc_component_update_bits(component, CS4265_PWRCTL, |
486 | CS4265_PWRCTL_PDN, | 486 | CS4265_PWRCTL_PDN, |
487 | CS4265_PWRCTL_PDN); | 487 | CS4265_PWRCTL_PDN); |
488 | break; | 488 | break; |
@@ -544,17 +544,18 @@ static struct snd_soc_dai_driver cs4265_dai[] = { | |||
544 | }, | 544 | }, |
545 | }; | 545 | }; |
546 | 546 | ||
547 | static const struct snd_soc_codec_driver soc_codec_cs4265 = { | 547 | static const struct snd_soc_component_driver soc_component_cs4265 = { |
548 | .set_bias_level = cs4265_set_bias_level, | 548 | .set_bias_level = cs4265_set_bias_level, |
549 | 549 | .controls = cs4265_snd_controls, | |
550 | .component_driver = { | 550 | .num_controls = ARRAY_SIZE(cs4265_snd_controls), |
551 | .controls = cs4265_snd_controls, | 551 | .dapm_widgets = cs4265_dapm_widgets, |
552 | .num_controls = ARRAY_SIZE(cs4265_snd_controls), | 552 | .num_dapm_widgets = ARRAY_SIZE(cs4265_dapm_widgets), |
553 | .dapm_widgets = cs4265_dapm_widgets, | 553 | .dapm_routes = cs4265_audio_map, |
554 | .num_dapm_widgets = ARRAY_SIZE(cs4265_dapm_widgets), | 554 | .num_dapm_routes = ARRAY_SIZE(cs4265_audio_map), |
555 | .dapm_routes = cs4265_audio_map, | 555 | .idle_bias_on = 1, |
556 | .num_dapm_routes = ARRAY_SIZE(cs4265_audio_map), | 556 | .use_pmdown_time = 1, |
557 | }, | 557 | .endianness = 1, |
558 | .non_legacy_dai_naming = 1, | ||
558 | }; | 559 | }; |
559 | 560 | ||
560 | static const struct regmap_config cs4265_regmap = { | 561 | static const struct regmap_config cs4265_regmap = { |
@@ -616,18 +617,12 @@ static int cs4265_i2c_probe(struct i2c_client *i2c_client, | |||
616 | 617 | ||
617 | regmap_write(cs4265->regmap, CS4265_PWRCTL, 0x0F); | 618 | regmap_write(cs4265->regmap, CS4265_PWRCTL, 0x0F); |
618 | 619 | ||
619 | ret = snd_soc_register_codec(&i2c_client->dev, | 620 | ret = devm_snd_soc_register_component(&i2c_client->dev, |
620 | &soc_codec_cs4265, cs4265_dai, | 621 | &soc_component_cs4265, cs4265_dai, |
621 | ARRAY_SIZE(cs4265_dai)); | 622 | ARRAY_SIZE(cs4265_dai)); |
622 | return ret; | 623 | return ret; |
623 | } | 624 | } |
624 | 625 | ||
625 | static int cs4265_i2c_remove(struct i2c_client *client) | ||
626 | { | ||
627 | snd_soc_unregister_codec(&client->dev); | ||
628 | return 0; | ||
629 | } | ||
630 | |||
631 | static const struct of_device_id cs4265_of_match[] = { | 626 | static const struct of_device_id cs4265_of_match[] = { |
632 | { .compatible = "cirrus,cs4265", }, | 627 | { .compatible = "cirrus,cs4265", }, |
633 | { } | 628 | { } |
@@ -647,7 +642,6 @@ static struct i2c_driver cs4265_i2c_driver = { | |||
647 | }, | 642 | }, |
648 | .id_table = cs4265_id, | 643 | .id_table = cs4265_id, |
649 | .probe = cs4265_i2c_probe, | 644 | .probe = cs4265_i2c_probe, |
650 | .remove = cs4265_i2c_remove, | ||
651 | }; | 645 | }; |
652 | 646 | ||
653 | module_i2c_driver(cs4265_i2c_driver); | 647 | module_i2c_driver(cs4265_i2c_driver); |