aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKuninori Morimoto <kuninori.morimoto.gx@renesas.com>2018-01-28 22:04:37 -0500
committerMark Brown <broonie@kernel.org>2018-02-12 04:38:10 -0500
commitcf73dce9bc4947a777cc07b7fb7b9ff11f1e3b68 (patch)
tree7c12d5e9de4f0fb47e985e0c4d93e58055b600c6
parent7928b2cbe55b2a410a0f5c1f154610059c57b1b2 (diff)
ASoC: wm8804: 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 = 1 -> .idle_bias_on = 0 .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/wm8804.c100
1 files changed, 49 insertions, 51 deletions
diff --git a/sound/soc/codecs/wm8804.c b/sound/soc/codecs/wm8804.c
index fc69b87443d8..89f13249966e 100644
--- a/sound/soc/codecs/wm8804.c
+++ b/sound/soc/codecs/wm8804.c
@@ -137,21 +137,21 @@ static const struct snd_soc_dapm_route wm8804_dapm_routes[] = {
137static int wm8804_aif_event(struct snd_soc_dapm_widget *w, 137static int wm8804_aif_event(struct snd_soc_dapm_widget *w,
138 struct snd_kcontrol *kcontrol, int event) 138 struct snd_kcontrol *kcontrol, int event)
139{ 139{
140 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); 140 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm);
141 struct wm8804_priv *wm8804 = snd_soc_codec_get_drvdata(codec); 141 struct wm8804_priv *wm8804 = snd_soc_component_get_drvdata(component);
142 142
143 switch (event) { 143 switch (event) {
144 case SND_SOC_DAPM_POST_PMU: 144 case SND_SOC_DAPM_POST_PMU:
145 /* power up the aif */ 145 /* power up the aif */
146 if (!wm8804->aif_pwr) 146 if (!wm8804->aif_pwr)
147 snd_soc_update_bits(codec, WM8804_PWRDN, 0x10, 0x0); 147 snd_soc_component_update_bits(component, WM8804_PWRDN, 0x10, 0x0);
148 wm8804->aif_pwr++; 148 wm8804->aif_pwr++;
149 break; 149 break;
150 case SND_SOC_DAPM_POST_PMD: 150 case SND_SOC_DAPM_POST_PMD:
151 /* power down only both paths are disabled */ 151 /* power down only both paths are disabled */
152 wm8804->aif_pwr--; 152 wm8804->aif_pwr--;
153 if (!wm8804->aif_pwr) 153 if (!wm8804->aif_pwr)
154 snd_soc_update_bits(codec, WM8804_PWRDN, 0x10, 0x10); 154 snd_soc_component_update_bits(component, WM8804_PWRDN, 0x10, 0x10);
155 break; 155 break;
156 } 156 }
157 157
@@ -161,8 +161,8 @@ static int wm8804_aif_event(struct snd_soc_dapm_widget *w,
161static int txsrc_put(struct snd_kcontrol *kcontrol, 161static int txsrc_put(struct snd_kcontrol *kcontrol,
162 struct snd_ctl_elem_value *ucontrol) 162 struct snd_ctl_elem_value *ucontrol)
163{ 163{
164 struct snd_soc_codec *codec = snd_soc_dapm_kcontrol_codec(kcontrol); 164 struct snd_soc_component *component = snd_soc_dapm_kcontrol_component(kcontrol);
165 struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec); 165 struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component);
166 struct soc_enum *e = (struct soc_enum *)kcontrol->private_value; 166 struct soc_enum *e = (struct soc_enum *)kcontrol->private_value;
167 unsigned int val = ucontrol->value.enumerated.item[0] << e->shift_l; 167 unsigned int val = ucontrol->value.enumerated.item[0] << e->shift_l;
168 unsigned int mask = 1 << e->shift_l; 168 unsigned int mask = 1 << e->shift_l;
@@ -173,18 +173,18 @@ static int txsrc_put(struct snd_kcontrol *kcontrol,
173 173
174 snd_soc_dapm_mutex_lock(dapm); 174 snd_soc_dapm_mutex_lock(dapm);
175 175
176 if (snd_soc_test_bits(codec, e->reg, mask, val)) { 176 if (snd_soc_component_test_bits(component, e->reg, mask, val)) {
177 /* save the current power state of the transmitter */ 177 /* save the current power state of the transmitter */
178 txpwr = snd_soc_read(codec, WM8804_PWRDN) & 0x4; 178 txpwr = snd_soc_component_read32(component, WM8804_PWRDN) & 0x4;
179 179
180 /* power down the transmitter */ 180 /* power down the transmitter */
181 snd_soc_update_bits(codec, WM8804_PWRDN, 0x4, 0x4); 181 snd_soc_component_update_bits(component, WM8804_PWRDN, 0x4, 0x4);
182 182
183 /* set the tx source */ 183 /* set the tx source */
184 snd_soc_update_bits(codec, e->reg, mask, val); 184 snd_soc_component_update_bits(component, e->reg, mask, val);
185 185
186 /* restore the transmitter's configuration */ 186 /* restore the transmitter's configuration */
187 snd_soc_update_bits(codec, WM8804_PWRDN, 0x4, txpwr); 187 snd_soc_component_update_bits(component, WM8804_PWRDN, 0x4, txpwr);
188 } 188 }
189 189
190 snd_soc_dapm_mutex_unlock(dapm); 190 snd_soc_dapm_mutex_unlock(dapm);
@@ -218,10 +218,10 @@ static int wm8804_soft_reset(struct wm8804_priv *wm8804)
218 218
219static int wm8804_set_fmt(struct snd_soc_dai *dai, unsigned int fmt) 219static int wm8804_set_fmt(struct snd_soc_dai *dai, unsigned int fmt)
220{ 220{
221 struct snd_soc_codec *codec; 221 struct snd_soc_component *component;
222 u16 format, master, bcp, lrp; 222 u16 format, master, bcp, lrp;
223 223
224 codec = dai->codec; 224 component = dai->component;
225 225
226 switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) { 226 switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) {
227 case SND_SOC_DAIFMT_I2S: 227 case SND_SOC_DAIFMT_I2S:
@@ -243,8 +243,8 @@ static int wm8804_set_fmt(struct snd_soc_dai *dai, unsigned int fmt)
243 } 243 }
244 244
245 /* set data format */ 245 /* set data format */
246 snd_soc_update_bits(codec, WM8804_AIFTX, 0x3, format); 246 snd_soc_component_update_bits(component, WM8804_AIFTX, 0x3, format);
247 snd_soc_update_bits(codec, WM8804_AIFRX, 0x3, format); 247 snd_soc_component_update_bits(component, WM8804_AIFRX, 0x3, format);
248 248
249 switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { 249 switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) {
250 case SND_SOC_DAIFMT_CBM_CFM: 250 case SND_SOC_DAIFMT_CBM_CFM:
@@ -259,7 +259,7 @@ static int wm8804_set_fmt(struct snd_soc_dai *dai, unsigned int fmt)
259 } 259 }
260 260
261 /* set master/slave mode */ 261 /* set master/slave mode */
262 snd_soc_update_bits(codec, WM8804_AIFRX, 0x40, master << 6); 262 snd_soc_component_update_bits(component, WM8804_AIFRX, 0x40, master << 6);
263 263
264 bcp = lrp = 0; 264 bcp = lrp = 0;
265 switch (fmt & SND_SOC_DAIFMT_INV_MASK) { 265 switch (fmt & SND_SOC_DAIFMT_INV_MASK) {
@@ -280,9 +280,9 @@ static int wm8804_set_fmt(struct snd_soc_dai *dai, unsigned int fmt)
280 } 280 }
281 281
282 /* set frame inversion */ 282 /* set frame inversion */
283 snd_soc_update_bits(codec, WM8804_AIFTX, 0x10 | 0x20, 283 snd_soc_component_update_bits(component, WM8804_AIFTX, 0x10 | 0x20,
284 (bcp << 4) | (lrp << 5)); 284 (bcp << 4) | (lrp << 5));
285 snd_soc_update_bits(codec, WM8804_AIFRX, 0x10 | 0x20, 285 snd_soc_component_update_bits(component, WM8804_AIFRX, 0x10 | 0x20,
286 (bcp << 4) | (lrp << 5)); 286 (bcp << 4) | (lrp << 5));
287 return 0; 287 return 0;
288} 288}
@@ -291,10 +291,10 @@ static int wm8804_hw_params(struct snd_pcm_substream *substream,
291 struct snd_pcm_hw_params *params, 291 struct snd_pcm_hw_params *params,
292 struct snd_soc_dai *dai) 292 struct snd_soc_dai *dai)
293{ 293{
294 struct snd_soc_codec *codec; 294 struct snd_soc_component *component;
295 u16 blen; 295 u16 blen;
296 296
297 codec = dai->codec; 297 component = dai->component;
298 298
299 switch (params_width(params)) { 299 switch (params_width(params)) {
300 case 16: 300 case 16:
@@ -313,8 +313,8 @@ static int wm8804_hw_params(struct snd_pcm_substream *substream,
313 } 313 }
314 314
315 /* set word length */ 315 /* set word length */
316 snd_soc_update_bits(codec, WM8804_AIFTX, 0xc, blen << 2); 316 snd_soc_component_update_bits(component, WM8804_AIFTX, 0xc, blen << 2);
317 snd_soc_update_bits(codec, WM8804_AIFRX, 0xc, blen << 2); 317 snd_soc_component_update_bits(component, WM8804_AIFRX, 0xc, blen << 2);
318 318
319 return 0; 319 return 0;
320} 320}
@@ -405,8 +405,8 @@ static int wm8804_set_pll(struct snd_soc_dai *dai, int pll_id,
405 int source, unsigned int freq_in, 405 int source, unsigned int freq_in,
406 unsigned int freq_out) 406 unsigned int freq_out)
407{ 407{
408 struct snd_soc_codec *codec = dai->codec; 408 struct snd_soc_component *component = dai->component;
409 struct wm8804_priv *wm8804 = snd_soc_codec_get_drvdata(codec); 409 struct wm8804_priv *wm8804 = snd_soc_component_get_drvdata(component);
410 bool change; 410 bool change;
411 411
412 if (!freq_in || !freq_out) { 412 if (!freq_in || !freq_out) {
@@ -431,18 +431,18 @@ static int wm8804_set_pll(struct snd_soc_dai *dai, int pll_id,
431 pm_runtime_get_sync(wm8804->dev); 431 pm_runtime_get_sync(wm8804->dev);
432 432
433 /* set PLLN and PRESCALE */ 433 /* set PLLN and PRESCALE */
434 snd_soc_update_bits(codec, WM8804_PLL4, 0xf | 0x10, 434 snd_soc_component_update_bits(component, WM8804_PLL4, 0xf | 0x10,
435 pll_div.n | (pll_div.prescale << 4)); 435 pll_div.n | (pll_div.prescale << 4));
436 /* set mclkdiv and freqmode */ 436 /* set mclkdiv and freqmode */
437 snd_soc_update_bits(codec, WM8804_PLL5, 0x3 | 0x8, 437 snd_soc_component_update_bits(component, WM8804_PLL5, 0x3 | 0x8,
438 pll_div.freqmode | (pll_div.mclkdiv << 3)); 438 pll_div.freqmode | (pll_div.mclkdiv << 3));
439 /* set PLLK */ 439 /* set PLLK */
440 snd_soc_write(codec, WM8804_PLL1, pll_div.k & 0xff); 440 snd_soc_component_write(component, WM8804_PLL1, pll_div.k & 0xff);
441 snd_soc_write(codec, WM8804_PLL2, (pll_div.k >> 8) & 0xff); 441 snd_soc_component_write(component, WM8804_PLL2, (pll_div.k >> 8) & 0xff);
442 snd_soc_write(codec, WM8804_PLL3, pll_div.k >> 16); 442 snd_soc_component_write(component, WM8804_PLL3, pll_div.k >> 16);
443 443
444 /* power up the PLL */ 444 /* power up the PLL */
445 snd_soc_update_bits(codec, WM8804_PWRDN, 0x1, 0); 445 snd_soc_component_update_bits(component, WM8804_PWRDN, 0x1, 0);
446 } 446 }
447 447
448 return 0; 448 return 0;
@@ -451,15 +451,15 @@ static int wm8804_set_pll(struct snd_soc_dai *dai, int pll_id,
451static int wm8804_set_sysclk(struct snd_soc_dai *dai, 451static int wm8804_set_sysclk(struct snd_soc_dai *dai,
452 int clk_id, unsigned int freq, int dir) 452 int clk_id, unsigned int freq, int dir)
453{ 453{
454 struct snd_soc_codec *codec; 454 struct snd_soc_component *component;
455 455
456 codec = dai->codec; 456 component = dai->component;
457 457
458 switch (clk_id) { 458 switch (clk_id) {
459 case WM8804_TX_CLKSRC_MCLK: 459 case WM8804_TX_CLKSRC_MCLK:
460 if ((freq >= 10000000 && freq <= 14400000) 460 if ((freq >= 10000000 && freq <= 14400000)
461 || (freq >= 16280000 && freq <= 27000000)) 461 || (freq >= 16280000 && freq <= 27000000))
462 snd_soc_update_bits(codec, WM8804_PLL6, 0x80, 0x80); 462 snd_soc_component_update_bits(component, WM8804_PLL6, 0x80, 0x80);
463 else { 463 else {
464 dev_err(dai->dev, "OSCCLOCK is not within the " 464 dev_err(dai->dev, "OSCCLOCK is not within the "
465 "recommended range: %uHz\n", freq); 465 "recommended range: %uHz\n", freq);
@@ -467,13 +467,13 @@ static int wm8804_set_sysclk(struct snd_soc_dai *dai,
467 } 467 }
468 break; 468 break;
469 case WM8804_TX_CLKSRC_PLL: 469 case WM8804_TX_CLKSRC_PLL:
470 snd_soc_update_bits(codec, WM8804_PLL6, 0x80, 0); 470 snd_soc_component_update_bits(component, WM8804_PLL6, 0x80, 0);
471 break; 471 break;
472 case WM8804_CLKOUT_SRC_CLK1: 472 case WM8804_CLKOUT_SRC_CLK1:
473 snd_soc_update_bits(codec, WM8804_PLL6, 0x8, 0); 473 snd_soc_component_update_bits(component, WM8804_PLL6, 0x8, 0);
474 break; 474 break;
475 case WM8804_CLKOUT_SRC_OSCCLK: 475 case WM8804_CLKOUT_SRC_OSCCLK:
476 snd_soc_update_bits(codec, WM8804_PLL6, 0x8, 0x8); 476 snd_soc_component_update_bits(component, WM8804_PLL6, 0x8, 0x8);
477 break; 477 break;
478 default: 478 default:
479 dev_err(dai->dev, "Unknown clock source: %d\n", clk_id); 479 dev_err(dai->dev, "Unknown clock source: %d\n", clk_id);
@@ -486,17 +486,17 @@ static int wm8804_set_sysclk(struct snd_soc_dai *dai,
486static int wm8804_set_clkdiv(struct snd_soc_dai *dai, 486static int wm8804_set_clkdiv(struct snd_soc_dai *dai,
487 int div_id, int div) 487 int div_id, int div)
488{ 488{
489 struct snd_soc_codec *codec; 489 struct snd_soc_component *component;
490 struct wm8804_priv *wm8804; 490 struct wm8804_priv *wm8804;
491 491
492 codec = dai->codec; 492 component = dai->component;
493 switch (div_id) { 493 switch (div_id) {
494 case WM8804_CLKOUT_DIV: 494 case WM8804_CLKOUT_DIV:
495 snd_soc_update_bits(codec, WM8804_PLL5, 0x30, 495 snd_soc_component_update_bits(component, WM8804_PLL5, 0x30,
496 (div & 0x3) << 4); 496 (div & 0x3) << 4);
497 break; 497 break;
498 case WM8804_MCLK_DIV: 498 case WM8804_MCLK_DIV:
499 wm8804 = snd_soc_codec_get_drvdata(codec); 499 wm8804 = snd_soc_component_get_drvdata(component);
500 wm8804->mclk_div = div; 500 wm8804->mclk_div = div;
501 break; 501 break;
502 default: 502 default:
@@ -542,15 +542,14 @@ static struct snd_soc_dai_driver wm8804_dai = {
542 .symmetric_rates = 1 542 .symmetric_rates = 1
543}; 543};
544 544
545static const struct snd_soc_codec_driver soc_codec_dev_wm8804 = { 545static const struct snd_soc_component_driver soc_component_dev_wm8804 = {
546 .idle_bias_off = true, 546 .dapm_widgets = wm8804_dapm_widgets,
547 547 .num_dapm_widgets = ARRAY_SIZE(wm8804_dapm_widgets),
548 .component_driver = { 548 .dapm_routes = wm8804_dapm_routes,
549 .dapm_widgets = wm8804_dapm_widgets, 549 .num_dapm_routes = ARRAY_SIZE(wm8804_dapm_routes),
550 .num_dapm_widgets = ARRAY_SIZE(wm8804_dapm_widgets), 550 .use_pmdown_time = 1,
551 .dapm_routes = wm8804_dapm_routes, 551 .endianness = 1,
552 .num_dapm_routes = ARRAY_SIZE(wm8804_dapm_routes), 552 .non_legacy_dai_naming = 1,
553 },
554}; 553};
555 554
556const struct regmap_config wm8804_regmap_config = { 555const struct regmap_config wm8804_regmap_config = {
@@ -661,7 +660,7 @@ int wm8804_probe(struct device *dev, struct regmap *regmap)
661 } 660 }
662 } 661 }
663 662
664 ret = snd_soc_register_codec(dev, &soc_codec_dev_wm8804, 663 ret = devm_snd_soc_register_component(dev, &soc_component_dev_wm8804,
665 &wm8804_dai, 1); 664 &wm8804_dai, 1);
666 if (ret < 0) { 665 if (ret < 0) {
667 dev_err(dev, "Failed to register CODEC: %d\n", ret); 666 dev_err(dev, "Failed to register CODEC: %d\n", ret);
@@ -683,7 +682,6 @@ EXPORT_SYMBOL_GPL(wm8804_probe);
683void wm8804_remove(struct device *dev) 682void wm8804_remove(struct device *dev)
684{ 683{
685 pm_runtime_disable(dev); 684 pm_runtime_disable(dev);
686 snd_soc_unregister_codec(dev);
687} 685}
688EXPORT_SYMBOL_GPL(wm8804_remove); 686EXPORT_SYMBOL_GPL(wm8804_remove);
689 687