diff options
author | Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> | 2018-01-28 23:13:13 -0500 |
---|---|---|
committer | Mark Brown <broonie@kernel.org> | 2018-02-12 04:52:06 -0500 |
commit | 1514613a7a4480e40f40a2d41527292fece8b362 (patch) | |
tree | 437d9d71e4172b4e2dfcf0e45890fcf99bedc221 | |
parent | 7928b2cbe55b2a410a0f5c1f154610059c57b1b2 (diff) |
ASoC: tlv320aic26: 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/tlv320aic26.c | 83 |
1 files changed, 39 insertions, 44 deletions
diff --git a/sound/soc/codecs/tlv320aic26.c b/sound/soc/codecs/tlv320aic26.c index 89421caaeb70..b91b8d5f1ba3 100644 --- a/sound/soc/codecs/tlv320aic26.c +++ b/sound/soc/codecs/tlv320aic26.c | |||
@@ -30,7 +30,7 @@ MODULE_LICENSE("GPL"); | |||
30 | struct aic26 { | 30 | struct aic26 { |
31 | struct spi_device *spi; | 31 | struct spi_device *spi; |
32 | struct regmap *regmap; | 32 | struct regmap *regmap; |
33 | struct snd_soc_codec *codec; | 33 | struct snd_soc_component *component; |
34 | int master; | 34 | int master; |
35 | int datfm; | 35 | int datfm; |
36 | int mclk; | 36 | int mclk; |
@@ -64,8 +64,8 @@ static int aic26_hw_params(struct snd_pcm_substream *substream, | |||
64 | struct snd_pcm_hw_params *params, | 64 | struct snd_pcm_hw_params *params, |
65 | struct snd_soc_dai *dai) | 65 | struct snd_soc_dai *dai) |
66 | { | 66 | { |
67 | struct snd_soc_codec *codec = dai->codec; | 67 | struct snd_soc_component *component = dai->component; |
68 | struct aic26 *aic26 = snd_soc_codec_get_drvdata(codec); | 68 | struct aic26 *aic26 = snd_soc_component_get_drvdata(component); |
69 | int fsref, divisor, wlen, pval, jval, dval, qval; | 69 | int fsref, divisor, wlen, pval, jval, dval, qval; |
70 | u16 reg; | 70 | u16 reg; |
71 | 71 | ||
@@ -112,20 +112,20 @@ static int aic26_hw_params(struct snd_pcm_substream *substream, | |||
112 | dev_dbg(&aic26->spi->dev, "Setting PLLM to %d.%04d\n", jval, dval); | 112 | dev_dbg(&aic26->spi->dev, "Setting PLLM to %d.%04d\n", jval, dval); |
113 | qval = 0; | 113 | qval = 0; |
114 | reg = 0x8000 | qval << 11 | pval << 8 | jval << 2; | 114 | reg = 0x8000 | qval << 11 | pval << 8 | jval << 2; |
115 | snd_soc_write(codec, AIC26_REG_PLL_PROG1, reg); | 115 | snd_soc_component_write(component, AIC26_REG_PLL_PROG1, reg); |
116 | reg = dval << 2; | 116 | reg = dval << 2; |
117 | snd_soc_write(codec, AIC26_REG_PLL_PROG2, reg); | 117 | snd_soc_component_write(component, AIC26_REG_PLL_PROG2, reg); |
118 | 118 | ||
119 | /* Audio Control 3 (master mode, fsref rate) */ | 119 | /* Audio Control 3 (master mode, fsref rate) */ |
120 | if (aic26->master) | 120 | if (aic26->master) |
121 | reg = 0x0800; | 121 | reg = 0x0800; |
122 | if (fsref == 48000) | 122 | if (fsref == 48000) |
123 | reg = 0x2000; | 123 | reg = 0x2000; |
124 | snd_soc_update_bits(codec, AIC26_REG_AUDIO_CTRL3, 0xf800, reg); | 124 | snd_soc_component_update_bits(component, AIC26_REG_AUDIO_CTRL3, 0xf800, reg); |
125 | 125 | ||
126 | /* Audio Control 1 (FSref divisor) */ | 126 | /* Audio Control 1 (FSref divisor) */ |
127 | reg = wlen | aic26->datfm | (divisor << 3) | divisor; | 127 | reg = wlen | aic26->datfm | (divisor << 3) | divisor; |
128 | snd_soc_update_bits(codec, AIC26_REG_AUDIO_CTRL1, 0xfff, reg); | 128 | snd_soc_component_update_bits(component, AIC26_REG_AUDIO_CTRL1, 0xfff, reg); |
129 | 129 | ||
130 | return 0; | 130 | return 0; |
131 | } | 131 | } |
@@ -135,8 +135,8 @@ static int aic26_hw_params(struct snd_pcm_substream *substream, | |||
135 | */ | 135 | */ |
136 | static int aic26_mute(struct snd_soc_dai *dai, int mute) | 136 | static int aic26_mute(struct snd_soc_dai *dai, int mute) |
137 | { | 137 | { |
138 | struct snd_soc_codec *codec = dai->codec; | 138 | struct snd_soc_component *component = dai->component; |
139 | struct aic26 *aic26 = snd_soc_codec_get_drvdata(codec); | 139 | struct aic26 *aic26 = snd_soc_component_get_drvdata(component); |
140 | u16 reg; | 140 | u16 reg; |
141 | 141 | ||
142 | dev_dbg(&aic26->spi->dev, "aic26_mute(dai=%p, mute=%i)\n", | 142 | dev_dbg(&aic26->spi->dev, "aic26_mute(dai=%p, mute=%i)\n", |
@@ -146,7 +146,7 @@ static int aic26_mute(struct snd_soc_dai *dai, int mute) | |||
146 | reg = 0x8080; | 146 | reg = 0x8080; |
147 | else | 147 | else |
148 | reg = 0; | 148 | reg = 0; |
149 | snd_soc_update_bits(codec, AIC26_REG_DAC_GAIN, 0x8000, reg); | 149 | snd_soc_component_update_bits(component, AIC26_REG_DAC_GAIN, 0x8000, reg); |
150 | 150 | ||
151 | return 0; | 151 | return 0; |
152 | } | 152 | } |
@@ -154,8 +154,8 @@ static int aic26_mute(struct snd_soc_dai *dai, int mute) | |||
154 | static int aic26_set_sysclk(struct snd_soc_dai *codec_dai, | 154 | static int aic26_set_sysclk(struct snd_soc_dai *codec_dai, |
155 | int clk_id, unsigned int freq, int dir) | 155 | int clk_id, unsigned int freq, int dir) |
156 | { | 156 | { |
157 | struct snd_soc_codec *codec = codec_dai->codec; | 157 | struct snd_soc_component *component = codec_dai->component; |
158 | struct aic26 *aic26 = snd_soc_codec_get_drvdata(codec); | 158 | struct aic26 *aic26 = snd_soc_component_get_drvdata(component); |
159 | 159 | ||
160 | dev_dbg(&aic26->spi->dev, "aic26_set_sysclk(dai=%p, clk_id==%i," | 160 | dev_dbg(&aic26->spi->dev, "aic26_set_sysclk(dai=%p, clk_id==%i," |
161 | " freq=%i, dir=%i)\n", | 161 | " freq=%i, dir=%i)\n", |
@@ -171,8 +171,8 @@ static int aic26_set_sysclk(struct snd_soc_dai *codec_dai, | |||
171 | 171 | ||
172 | static int aic26_set_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt) | 172 | static int aic26_set_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt) |
173 | { | 173 | { |
174 | struct snd_soc_codec *codec = codec_dai->codec; | 174 | struct snd_soc_component *component = codec_dai->component; |
175 | struct aic26 *aic26 = snd_soc_codec_get_drvdata(codec); | 175 | struct aic26 *aic26 = snd_soc_component_get_drvdata(component); |
176 | 176 | ||
177 | dev_dbg(&aic26->spi->dev, "aic26_set_fmt(dai=%p, fmt==%i)\n", | 177 | dev_dbg(&aic26->spi->dev, "aic26_set_fmt(dai=%p, fmt==%i)\n", |
178 | codec_dai, fmt); | 178 | codec_dai, fmt); |
@@ -265,7 +265,7 @@ static ssize_t aic26_keyclick_show(struct device *dev, | |||
265 | struct aic26 *aic26 = dev_get_drvdata(dev); | 265 | struct aic26 *aic26 = dev_get_drvdata(dev); |
266 | int val, amp, freq, len; | 266 | int val, amp, freq, len; |
267 | 267 | ||
268 | val = snd_soc_read(aic26->codec, AIC26_REG_AUDIO_CTRL2); | 268 | val = snd_soc_component_read32(aic26->component, AIC26_REG_AUDIO_CTRL2); |
269 | amp = (val >> 12) & 0x7; | 269 | amp = (val >> 12) & 0x7; |
270 | freq = (125 << ((val >> 8) & 0x7)) >> 1; | 270 | freq = (125 << ((val >> 8) & 0x7)) >> 1; |
271 | len = 2 * (1 + ((val >> 4) & 0xf)); | 271 | len = 2 * (1 + ((val >> 4) & 0xf)); |
@@ -280,7 +280,7 @@ static ssize_t aic26_keyclick_set(struct device *dev, | |||
280 | { | 280 | { |
281 | struct aic26 *aic26 = dev_get_drvdata(dev); | 281 | struct aic26 *aic26 = dev_get_drvdata(dev); |
282 | 282 | ||
283 | snd_soc_update_bits(aic26->codec, AIC26_REG_AUDIO_CTRL2, | 283 | snd_soc_component_update_bits(aic26->component, AIC26_REG_AUDIO_CTRL2, |
284 | 0x8000, 0x800); | 284 | 0x8000, 0x800); |
285 | 285 | ||
286 | return count; | 286 | return count; |
@@ -291,44 +291,46 @@ static DEVICE_ATTR(keyclick, 0644, aic26_keyclick_show, aic26_keyclick_set); | |||
291 | /* --------------------------------------------------------------------- | 291 | /* --------------------------------------------------------------------- |
292 | * SoC CODEC portion of driver: probe and release routines | 292 | * SoC CODEC portion of driver: probe and release routines |
293 | */ | 293 | */ |
294 | static int aic26_probe(struct snd_soc_codec *codec) | 294 | static int aic26_probe(struct snd_soc_component *component) |
295 | { | 295 | { |
296 | struct aic26 *aic26 = dev_get_drvdata(codec->dev); | 296 | struct aic26 *aic26 = dev_get_drvdata(component->dev); |
297 | int ret, reg; | 297 | int ret, reg; |
298 | 298 | ||
299 | aic26->codec = codec; | 299 | aic26->component = component; |
300 | 300 | ||
301 | /* Reset the codec to power on defaults */ | 301 | /* Reset the codec to power on defaults */ |
302 | snd_soc_write(codec, AIC26_REG_RESET, 0xBB00); | 302 | snd_soc_component_write(component, AIC26_REG_RESET, 0xBB00); |
303 | 303 | ||
304 | /* Power up CODEC */ | 304 | /* Power up CODEC */ |
305 | snd_soc_write(codec, AIC26_REG_POWER_CTRL, 0); | 305 | snd_soc_component_write(component, AIC26_REG_POWER_CTRL, 0); |
306 | 306 | ||
307 | /* Audio Control 3 (master mode, fsref rate) */ | 307 | /* Audio Control 3 (master mode, fsref rate) */ |
308 | reg = snd_soc_read(codec, AIC26_REG_AUDIO_CTRL3); | 308 | reg = snd_soc_component_read32(component, AIC26_REG_AUDIO_CTRL3); |
309 | reg &= ~0xf800; | 309 | reg &= ~0xf800; |
310 | reg |= 0x0800; /* set master mode */ | 310 | reg |= 0x0800; /* set master mode */ |
311 | snd_soc_write(codec, AIC26_REG_AUDIO_CTRL3, reg); | 311 | snd_soc_component_write(component, AIC26_REG_AUDIO_CTRL3, reg); |
312 | 312 | ||
313 | /* Register the sysfs files for debugging */ | 313 | /* Register the sysfs files for debugging */ |
314 | /* Create SysFS files */ | 314 | /* Create SysFS files */ |
315 | ret = device_create_file(codec->dev, &dev_attr_keyclick); | 315 | ret = device_create_file(component->dev, &dev_attr_keyclick); |
316 | if (ret) | 316 | if (ret) |
317 | dev_info(codec->dev, "error creating sysfs files\n"); | 317 | dev_info(component->dev, "error creating sysfs files\n"); |
318 | 318 | ||
319 | return 0; | 319 | return 0; |
320 | } | 320 | } |
321 | 321 | ||
322 | static const struct snd_soc_codec_driver aic26_soc_codec_dev = { | 322 | static const struct snd_soc_component_driver aic26_soc_component_dev = { |
323 | .probe = aic26_probe, | 323 | .probe = aic26_probe, |
324 | .component_driver = { | 324 | .controls = aic26_snd_controls, |
325 | .controls = aic26_snd_controls, | 325 | .num_controls = ARRAY_SIZE(aic26_snd_controls), |
326 | .num_controls = ARRAY_SIZE(aic26_snd_controls), | 326 | .dapm_widgets = tlv320aic26_dapm_widgets, |
327 | .dapm_widgets = tlv320aic26_dapm_widgets, | 327 | .num_dapm_widgets = ARRAY_SIZE(tlv320aic26_dapm_widgets), |
328 | .num_dapm_widgets = ARRAY_SIZE(tlv320aic26_dapm_widgets), | 328 | .dapm_routes = tlv320aic26_dapm_routes, |
329 | .dapm_routes = tlv320aic26_dapm_routes, | 329 | .num_dapm_routes = ARRAY_SIZE(tlv320aic26_dapm_routes), |
330 | .num_dapm_routes = ARRAY_SIZE(tlv320aic26_dapm_routes), | 330 | .idle_bias_on = 1, |
331 | }, | 331 | .use_pmdown_time = 1, |
332 | .endianness = 1, | ||
333 | .non_legacy_dai_naming = 1, | ||
332 | }; | 334 | }; |
333 | 335 | ||
334 | static const struct regmap_config aic26_regmap = { | 336 | static const struct regmap_config aic26_regmap = { |
@@ -361,23 +363,16 @@ static int aic26_spi_probe(struct spi_device *spi) | |||
361 | dev_set_drvdata(&spi->dev, aic26); | 363 | dev_set_drvdata(&spi->dev, aic26); |
362 | aic26->master = 1; | 364 | aic26->master = 1; |
363 | 365 | ||
364 | ret = snd_soc_register_codec(&spi->dev, | 366 | ret = devm_snd_soc_register_component(&spi->dev, |
365 | &aic26_soc_codec_dev, &aic26_dai, 1); | 367 | &aic26_soc_component_dev, &aic26_dai, 1); |
366 | return ret; | 368 | return ret; |
367 | } | 369 | } |
368 | 370 | ||
369 | static int aic26_spi_remove(struct spi_device *spi) | ||
370 | { | ||
371 | snd_soc_unregister_codec(&spi->dev); | ||
372 | return 0; | ||
373 | } | ||
374 | |||
375 | static struct spi_driver aic26_spi = { | 371 | static struct spi_driver aic26_spi = { |
376 | .driver = { | 372 | .driver = { |
377 | .name = "tlv320aic26-codec", | 373 | .name = "tlv320aic26-codec", |
378 | }, | 374 | }, |
379 | .probe = aic26_spi_probe, | 375 | .probe = aic26_spi_probe, |
380 | .remove = aic26_spi_remove, | ||
381 | }; | 376 | }; |
382 | 377 | ||
383 | module_spi_driver(aic26_spi); | 378 | module_spi_driver(aic26_spi); |