aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKuninori Morimoto <kuninori.morimoto.gx@renesas.com>2018-01-28 22:01:09 -0500
committerMark Brown <broonie@kernel.org>2018-02-12 04:40:29 -0500
commit4bf8ae8356c982847ef5bd5f613b87311f9024ec (patch)
treede94977a3d1a202457ff1791707681ba6c7e7ee7
parent7928b2cbe55b2a410a0f5c1f154610059c57b1b2 (diff)
ASoC: wm8523: 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/wm8523.c98
1 files changed, 46 insertions, 52 deletions
diff --git a/sound/soc/codecs/wm8523.c b/sound/soc/codecs/wm8523.c
index c7c33e98fbcb..f4a9e25fb334 100644
--- a/sound/soc/codecs/wm8523.c
+++ b/sound/soc/codecs/wm8523.c
@@ -125,14 +125,14 @@ static const struct {
125static int wm8523_startup(struct snd_pcm_substream *substream, 125static int wm8523_startup(struct snd_pcm_substream *substream,
126 struct snd_soc_dai *dai) 126 struct snd_soc_dai *dai)
127{ 127{
128 struct snd_soc_codec *codec = dai->codec; 128 struct snd_soc_component *component = dai->component;
129 struct wm8523_priv *wm8523 = snd_soc_codec_get_drvdata(codec); 129 struct wm8523_priv *wm8523 = snd_soc_component_get_drvdata(component);
130 130
131 /* The set of sample rates that can be supported depends on the 131 /* The set of sample rates that can be supported depends on the
132 * MCLK supplied to the CODEC - enforce this. 132 * MCLK supplied to the CODEC - enforce this.
133 */ 133 */
134 if (!wm8523->sysclk) { 134 if (!wm8523->sysclk) {
135 dev_err(codec->dev, 135 dev_err(component->dev,
136 "No MCLK configured, call set_sysclk() on init\n"); 136 "No MCLK configured, call set_sysclk() on init\n");
137 return -EINVAL; 137 return -EINVAL;
138 } 138 }
@@ -148,11 +148,11 @@ static int wm8523_hw_params(struct snd_pcm_substream *substream,
148 struct snd_pcm_hw_params *params, 148 struct snd_pcm_hw_params *params,
149 struct snd_soc_dai *dai) 149 struct snd_soc_dai *dai)
150{ 150{
151 struct snd_soc_codec *codec = dai->codec; 151 struct snd_soc_component *component = dai->component;
152 struct wm8523_priv *wm8523 = snd_soc_codec_get_drvdata(codec); 152 struct wm8523_priv *wm8523 = snd_soc_component_get_drvdata(component);
153 int i; 153 int i;
154 u16 aifctrl1 = snd_soc_read(codec, WM8523_AIF_CTRL1); 154 u16 aifctrl1 = snd_soc_component_read32(component, WM8523_AIF_CTRL1);
155 u16 aifctrl2 = snd_soc_read(codec, WM8523_AIF_CTRL2); 155 u16 aifctrl2 = snd_soc_component_read32(component, WM8523_AIF_CTRL2);
156 156
157 /* Find a supported LRCLK ratio */ 157 /* Find a supported LRCLK ratio */
158 for (i = 0; i < ARRAY_SIZE(lrclk_ratios); i++) { 158 for (i = 0; i < ARRAY_SIZE(lrclk_ratios); i++) {
@@ -163,7 +163,7 @@ static int wm8523_hw_params(struct snd_pcm_substream *substream,
163 163
164 /* Should never happen, should be handled by constraints */ 164 /* Should never happen, should be handled by constraints */
165 if (i == ARRAY_SIZE(lrclk_ratios)) { 165 if (i == ARRAY_SIZE(lrclk_ratios)) {
166 dev_err(codec->dev, "MCLK/fs ratio %d unsupported\n", 166 dev_err(component->dev, "MCLK/fs ratio %d unsupported\n",
167 wm8523->sysclk / params_rate(params)); 167 wm8523->sysclk / params_rate(params));
168 return -EINVAL; 168 return -EINVAL;
169 } 169 }
@@ -178,7 +178,7 @@ static int wm8523_hw_params(struct snd_pcm_substream *substream,
178 break; 178 break;
179 179
180 if (i == ARRAY_SIZE(bclk_ratios)) { 180 if (i == ARRAY_SIZE(bclk_ratios)) {
181 dev_err(codec->dev, 181 dev_err(component->dev,
182 "No matching BCLK/fs ratio for word length %d\n", 182 "No matching BCLK/fs ratio for word length %d\n",
183 params_width(params)); 183 params_width(params));
184 return -EINVAL; 184 return -EINVAL;
@@ -203,8 +203,8 @@ static int wm8523_hw_params(struct snd_pcm_substream *substream,
203 break; 203 break;
204 } 204 }
205 205
206 snd_soc_write(codec, WM8523_AIF_CTRL1, aifctrl1); 206 snd_soc_component_write(component, WM8523_AIF_CTRL1, aifctrl1);
207 snd_soc_write(codec, WM8523_AIF_CTRL2, aifctrl2); 207 snd_soc_component_write(component, WM8523_AIF_CTRL2, aifctrl2);
208 208
209 return 0; 209 return 0;
210} 210}
@@ -212,8 +212,8 @@ static int wm8523_hw_params(struct snd_pcm_substream *substream,
212static int wm8523_set_dai_sysclk(struct snd_soc_dai *codec_dai, 212static int wm8523_set_dai_sysclk(struct snd_soc_dai *codec_dai,
213 int clk_id, unsigned int freq, int dir) 213 int clk_id, unsigned int freq, int dir)
214{ 214{
215 struct snd_soc_codec *codec = codec_dai->codec; 215 struct snd_soc_component *component = codec_dai->component;
216 struct wm8523_priv *wm8523 = snd_soc_codec_get_drvdata(codec); 216 struct wm8523_priv *wm8523 = snd_soc_component_get_drvdata(component);
217 unsigned int val; 217 unsigned int val;
218 int i; 218 int i;
219 219
@@ -239,13 +239,13 @@ static int wm8523_set_dai_sysclk(struct snd_soc_dai *codec_dai,
239 case 96000: 239 case 96000:
240 case 176400: 240 case 176400:
241 case 192000: 241 case 192000:
242 dev_dbg(codec->dev, "Supported sample rate: %dHz\n", 242 dev_dbg(component->dev, "Supported sample rate: %dHz\n",
243 val); 243 val);
244 wm8523->rate_constraint_list[i] = val; 244 wm8523->rate_constraint_list[i] = val;
245 wm8523->rate_constraint.count++; 245 wm8523->rate_constraint.count++;
246 break; 246 break;
247 default: 247 default:
248 dev_dbg(codec->dev, "Skipping sample rate: %dHz\n", 248 dev_dbg(component->dev, "Skipping sample rate: %dHz\n",
249 val); 249 val);
250 } 250 }
251 } 251 }
@@ -261,8 +261,8 @@ static int wm8523_set_dai_sysclk(struct snd_soc_dai *codec_dai,
261static int wm8523_set_dai_fmt(struct snd_soc_dai *codec_dai, 261static int wm8523_set_dai_fmt(struct snd_soc_dai *codec_dai,
262 unsigned int fmt) 262 unsigned int fmt)
263{ 263{
264 struct snd_soc_codec *codec = codec_dai->codec; 264 struct snd_soc_component *component = codec_dai->component;
265 u16 aifctrl1 = snd_soc_read(codec, WM8523_AIF_CTRL1); 265 u16 aifctrl1 = snd_soc_component_read32(component, WM8523_AIF_CTRL1);
266 266
267 aifctrl1 &= ~(WM8523_BCLK_INV_MASK | WM8523_LRCLK_INV_MASK | 267 aifctrl1 &= ~(WM8523_BCLK_INV_MASK | WM8523_LRCLK_INV_MASK |
268 WM8523_FMT_MASK | WM8523_AIF_MSTR_MASK); 268 WM8523_FMT_MASK | WM8523_AIF_MSTR_MASK);
@@ -312,15 +312,15 @@ static int wm8523_set_dai_fmt(struct snd_soc_dai *codec_dai,
312 return -EINVAL; 312 return -EINVAL;
313 } 313 }
314 314
315 snd_soc_write(codec, WM8523_AIF_CTRL1, aifctrl1); 315 snd_soc_component_write(component, WM8523_AIF_CTRL1, aifctrl1);
316 316
317 return 0; 317 return 0;
318} 318}
319 319
320static int wm8523_set_bias_level(struct snd_soc_codec *codec, 320static int wm8523_set_bias_level(struct snd_soc_component *component,
321 enum snd_soc_bias_level level) 321 enum snd_soc_bias_level level)
322{ 322{
323 struct wm8523_priv *wm8523 = snd_soc_codec_get_drvdata(codec); 323 struct wm8523_priv *wm8523 = snd_soc_component_get_drvdata(component);
324 int ret; 324 int ret;
325 325
326 switch (level) { 326 switch (level) {
@@ -329,16 +329,16 @@ static int wm8523_set_bias_level(struct snd_soc_codec *codec,
329 329
330 case SND_SOC_BIAS_PREPARE: 330 case SND_SOC_BIAS_PREPARE:
331 /* Full power on */ 331 /* Full power on */
332 snd_soc_update_bits(codec, WM8523_PSCTRL1, 332 snd_soc_component_update_bits(component, WM8523_PSCTRL1,
333 WM8523_SYS_ENA_MASK, 3); 333 WM8523_SYS_ENA_MASK, 3);
334 break; 334 break;
335 335
336 case SND_SOC_BIAS_STANDBY: 336 case SND_SOC_BIAS_STANDBY:
337 if (snd_soc_codec_get_bias_level(codec) == SND_SOC_BIAS_OFF) { 337 if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_OFF) {
338 ret = regulator_bulk_enable(ARRAY_SIZE(wm8523->supplies), 338 ret = regulator_bulk_enable(ARRAY_SIZE(wm8523->supplies),
339 wm8523->supplies); 339 wm8523->supplies);
340 if (ret != 0) { 340 if (ret != 0) {
341 dev_err(codec->dev, 341 dev_err(component->dev,
342 "Failed to enable supplies: %d\n", 342 "Failed to enable supplies: %d\n",
343 ret); 343 ret);
344 return ret; 344 return ret;
@@ -348,21 +348,21 @@ static int wm8523_set_bias_level(struct snd_soc_codec *codec,
348 regcache_sync(wm8523->regmap); 348 regcache_sync(wm8523->regmap);
349 349
350 /* Initial power up */ 350 /* Initial power up */
351 snd_soc_update_bits(codec, WM8523_PSCTRL1, 351 snd_soc_component_update_bits(component, WM8523_PSCTRL1,
352 WM8523_SYS_ENA_MASK, 1); 352 WM8523_SYS_ENA_MASK, 1);
353 353
354 msleep(100); 354 msleep(100);
355 } 355 }
356 356
357 /* Power up to mute */ 357 /* Power up to mute */
358 snd_soc_update_bits(codec, WM8523_PSCTRL1, 358 snd_soc_component_update_bits(component, WM8523_PSCTRL1,
359 WM8523_SYS_ENA_MASK, 2); 359 WM8523_SYS_ENA_MASK, 2);
360 360
361 break; 361 break;
362 362
363 case SND_SOC_BIAS_OFF: 363 case SND_SOC_BIAS_OFF:
364 /* The chip runs through the power down sequence for us. */ 364 /* The chip runs through the power down sequence for us. */
365 snd_soc_update_bits(codec, WM8523_PSCTRL1, 365 snd_soc_component_update_bits(component, WM8523_PSCTRL1,
366 WM8523_SYS_ENA_MASK, 0); 366 WM8523_SYS_ENA_MASK, 0);
367 msleep(100); 367 msleep(100);
368 368
@@ -397,35 +397,36 @@ static struct snd_soc_dai_driver wm8523_dai = {
397 .ops = &wm8523_dai_ops, 397 .ops = &wm8523_dai_ops,
398}; 398};
399 399
400static int wm8523_probe(struct snd_soc_codec *codec) 400static int wm8523_probe(struct snd_soc_component *component)
401{ 401{
402 struct wm8523_priv *wm8523 = snd_soc_codec_get_drvdata(codec); 402 struct wm8523_priv *wm8523 = snd_soc_component_get_drvdata(component);
403 403
404 wm8523->rate_constraint.list = &wm8523->rate_constraint_list[0]; 404 wm8523->rate_constraint.list = &wm8523->rate_constraint_list[0];
405 wm8523->rate_constraint.count = 405 wm8523->rate_constraint.count =
406 ARRAY_SIZE(wm8523->rate_constraint_list); 406 ARRAY_SIZE(wm8523->rate_constraint_list);
407 407
408 /* Change some default settings - latch VU and enable ZC */ 408 /* Change some default settings - latch VU and enable ZC */
409 snd_soc_update_bits(codec, WM8523_DAC_GAINR, 409 snd_soc_component_update_bits(component, WM8523_DAC_GAINR,
410 WM8523_DACR_VU, WM8523_DACR_VU); 410 WM8523_DACR_VU, WM8523_DACR_VU);
411 snd_soc_update_bits(codec, WM8523_DAC_CTRL3, WM8523_ZC, WM8523_ZC); 411 snd_soc_component_update_bits(component, WM8523_DAC_CTRL3, WM8523_ZC, WM8523_ZC);
412 412
413 return 0; 413 return 0;
414} 414}
415 415
416static const struct snd_soc_codec_driver soc_codec_dev_wm8523 = { 416static const struct snd_soc_component_driver soc_component_dev_wm8523 = {
417 .probe = wm8523_probe, 417 .probe = wm8523_probe,
418 .set_bias_level = wm8523_set_bias_level, 418 .set_bias_level = wm8523_set_bias_level,
419 .suspend_bias_off = true, 419 .controls = wm8523_controls,
420 420 .num_controls = ARRAY_SIZE(wm8523_controls),
421 .component_driver = { 421 .dapm_widgets = wm8523_dapm_widgets,
422 .controls = wm8523_controls, 422 .num_dapm_widgets = ARRAY_SIZE(wm8523_dapm_widgets),
423 .num_controls = ARRAY_SIZE(wm8523_controls), 423 .dapm_routes = wm8523_dapm_routes,
424 .dapm_widgets = wm8523_dapm_widgets, 424 .num_dapm_routes = ARRAY_SIZE(wm8523_dapm_routes),
425 .num_dapm_widgets = ARRAY_SIZE(wm8523_dapm_widgets), 425 .suspend_bias_off = 1,
426 .dapm_routes = wm8523_dapm_routes, 426 .idle_bias_on = 1,
427 .num_dapm_routes = ARRAY_SIZE(wm8523_dapm_routes), 427 .use_pmdown_time = 1,
428 }, 428 .endianness = 1,
429 .non_legacy_dai_naming = 1,
429}; 430};
430 431
431static const struct of_device_id wm8523_of_match[] = { 432static const struct of_device_id wm8523_of_match[] = {
@@ -511,8 +512,8 @@ static int wm8523_i2c_probe(struct i2c_client *i2c,
511 512
512 i2c_set_clientdata(i2c, wm8523); 513 i2c_set_clientdata(i2c, wm8523);
513 514
514 ret = snd_soc_register_codec(&i2c->dev, 515 ret = devm_snd_soc_register_component(&i2c->dev,
515 &soc_codec_dev_wm8523, &wm8523_dai, 1); 516 &soc_component_dev_wm8523, &wm8523_dai, 1);
516 517
517 return ret; 518 return ret;
518 519
@@ -521,12 +522,6 @@ err_enable:
521 return ret; 522 return ret;
522} 523}
523 524
524static int wm8523_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 wm8523_i2c_id[] = { 525static const struct i2c_device_id wm8523_i2c_id[] = {
531 { "wm8523", 0 }, 526 { "wm8523", 0 },
532 { } 527 { }
@@ -539,7 +534,6 @@ static struct i2c_driver wm8523_i2c_driver = {
539 .of_match_table = wm8523_of_match, 534 .of_match_table = wm8523_of_match,
540 }, 535 },
541 .probe = wm8523_i2c_probe, 536 .probe = wm8523_i2c_probe,
542 .remove = wm8523_i2c_remove,
543 .id_table = wm8523_i2c_id, 537 .id_table = wm8523_i2c_id,
544}; 538};
545 539