[alsa-devel] [PATCH 000/187] ASoC: replace codec to component
Hi Mark
codec/platform can be replaced to component now. These patches do it for codec. These are based on "asoc-v4.16" tag
Current existing "codec" related codes will be no longer needed by these patches. I can post it, but I don't know when is good timing
Kuninori Morimoto (187): ASoC: soc-utils: replace codec to component ASoC: ac97: replace codec to component ASoC: wm0010: replace codec to component ASoC: wm2000: replace codec to component ASoC: wm2200: replace codec to component ASoC: wm5100: replace codec to component ASoC: wm8350: replace codec to component ASoC: wm8400: replace codec to component ASoC: wm8580: replace codec to component ASoC: wm8524: replace codec to component ASoC: wm8510: replace codec to component ASoC: wm8523: replace codec to component ASoC: wm8711: replace codec to component ASoC: wm8750: replace codec to component ASoC: wm8737: replace codec to component ASoC: wm8776: replace codec to component ASoC: wm8770: replace codec to component ASoC: wm8727: replace codec to component ASoC: wm8731: replace codec to component ASoC: wm8782: replace codec to component ASoC: wm8728: replace codec to component ASoC: wm8741: replace codec to component ASoC: wm8753: replace codec to component ASoC: wm8804: replace codec to component ASoC: wm8900: replace codec to component ASoC: wm8903: replace codec to component ASoC: wm8955: replace codec to component ASoC: wm8960: replace codec to component ASoC: wm8985: replace codec to component ASoC: wm8971: replace codec to component ASoC: wm8978: replace codec to component ASoC: wm8974: replace codec to component ASoC: wm8990: replace codec to component ASoC: wm8988: replace codec to component ASoC: wm8983: replace codec to component ASoC: wm8962: replace codec to component ASoC: wm8996: replace codec to component ASoC: wm8991: replace codec to component ASoC: wm8995: replace codec to component ASoC: wm8961: replace codec to component ASoC: wm8940: replace codec to component ASoC: wm8904: replace codec to component ASoC: wm9081: replace codec to component ASoC: wm9090: replace codec to component ASoC: wm9705: replace codec to component ASoC: wm9712: replace codec to component ASoC: wm9713: replace codec to component ASoC: wm9867: replace codec to component ASoC: wm1250-ev1: replace codec to component ASoC: wm8993/wm8994/wm8958: replace codec to component ASoC: ak4613: replace codec to component ASoC: ak4642: replace codec to component ASoC: ak5386: replace codec to component ASoC: ak4671: replace codec to component ASoC: ak4104: replace codec to component ASoC: ak4535: replace codec to component ASoC: ak4641: replace codec to component ASoC: ak4554: replace codec to component ASoC: rt274: replace codec to component ASoC: rt5616: replace codec to component ASoC: rt5640: replace codec to component ASoC: rt5651: replace codec to component ASoC: rt5514: replace codec to component ASoC: rt5659: replace codec to component ASoC: rt5670: replace codec to component ASoC: rt5660: replace codec to component ASoC: rt5631: replace codec to component ASoC: rt5665: replace codec to component ASoC: rt5645/rt5677: replace codec to component ASoC: cs4271: replace codec to component ASoC: cs4270: replace codec to component ASoC: cs4349: replace codec to component ASoC: cs4265: replace codec to component ASoC: cs35l32: replace codec to component ASoC: cs35l33: replace codec to component ASoC: cs35l35: replace codec to component ASoC: cs35l34: replace codec to component ASoC: cs42xx8: replace codec to component ASoC: cs42l73: replace codec to component ASoC: cs42l52: replace codec to component ASoC: cs42l56: replace codec to component ASoC: cs42l51: replace codec to component ASoC: cs42l42: replace codec to component ASoC: cs43130: replace codec to component ASoC: cs53l30: replace codec to component ASoC: da732x: replace codec to component ASoC: da7210: replace codec to component ASoC: da7218: replace codec to component ASoC: da7213: replace codec to component ASoC: da9055: replace codec to component ASoC: max9860: replace codec to component ASoC: max9850: replace codec to component ASoC: max98371: replace codec to component ASoC: max98095: replace codec to component ASoC: max98090: replace codec to component ASoC: max98926: replace codec to component ASoC: max98088: replace codec to component ASoC: max98925: replace codec to component ASoC: max98927: replace codec to component ASoC: max98357a: replace codec to component ASoC: max98373: replace codec to component ASoC: adav80x: replace codec to component ASoC: adau1373: replace codec to component ASoC: adau7002: replace codec to component ASoC: adau1977: replace codec to component ASoC: adau1701: replace codec to component ASoC: adau17x1/adau1761/adau1781: replace codec to component ASoC: tlv320aic23: replace codec to component ASoC: tlv320aic26: replace codec to component ASoC: tlv320aic3x: replace codec to component ASoC: tlv320dac33: replace codec to component ASoC: tlv320aic32x4: replace codec to component ASoC: tlv320aic31xx: replace codec to component ASoC: tscs42xx: replace codec to component ASoC: pcm179x: replace codec to component ASoC: pcm3008: replace codec to component ASoC: pcm1681: replace codec to component ASoC: pcm512x: replace codec to component ASoC: pcm5102a: replace codec to component ASoC: pcm3168a: replace codec to component ASoC: twl6040: replace codec to component ASoC: twl4030: replace codec to component ASoC: msm8916-wcd-analog: replace codec to component ASoC: msm8916-wcd-digital: replace codec to component ASoC: spdif_transmitter: replace codec to component ASoC: spdif_receiver: replace codec to component ASoC: tas5720: replace codec to component ASoC: tas2552: replace codec to component ASoC: sun4i: replace codec to component ASoC: sun8i: replace codec to component ASoC: ads117x: replace codec to component ASoC: ab8500: replace codec to component ASoC: ad193x: replace codec to component ASoC: ad1836: replace codec to component ASoC: ad1980: replace codec to component ASoC: ad73311: replace codec to component ASoC: atmel-pdmic: replace codec to component ASoC: atmel-classd: replace codec to component ASoC: ssm4567: replace codec to component ASoC: ssm2602: replace codec to component ASoC: ssm2518: replace codec to component ASoC: sta350: replace codec to component ASoC: sta32x: replace codec to component ASoC: sta529: replace codec to component ASoC: tas5086: replace codec to component ASoC: tas571x: replace codec to component ASoC: nau8824: replace codec to component ASoC: nau8810: replace codec to component ASoC: nau8540: replace codec to component ASoC: es8316: replace codec to component ASoC: es7134: replace codec to component ASoC: es8328: replace codec to component ASoC: alc5632: replace codec to component ASoC: alc5623: replace codec to component ASoC: hdmi-codec: replace codec to component ASoC: bt-sco: replace codec to component ASoC: vc4_hdmi: replace codec to component ASoC: zx_aud96p22: replace codec to component ASoC: wl1273: replace codec to component ASoC: hdac_hdmi/nau8825/rt286/rt298/rt5663/da7219: replace codec to component ASoC: arizona/cs47l24/wm5102/wm5110/wm8997/wm8998/wm_adsp: replace codec to component ASoC: mc13783: replace codec to component ASoC: sgtl5000: replace codec to component ASoC: stac9766: replace codec to component ASoC: sn95031: replace codec to component ASoC: cx20442: replace codec to component ASoC: sirf-audio: replace codec to component ASoC: inno_rk3036: replace codec to component ASoC: isabelle: replace codec to component ASoC: tfa9879: replace codec to component ASoC: dmic: replace codec to component ASoC: sti-sas: replace codec to component ASoC: gtm601: replace codec to component ASoC: 88pm860x: replace codec to component ASoC: pistachio: replace codec to component ASoC: lm49453: replace codec to component ASoC: cq93vc: replace codec to component ASoC: jz4740: replace codec to component ASoC: uda1380: replace codec to component ASoC: ml26124: replace codec to component ASoC: si476x: replace codec to component ASoC: uda134x: replace codec to component ASoC: ics43432: replace codec to component ASoC: pxa/mioa701_wm9713: replace codec to component ASoC: uniphier: evea: replace codec to component ASoC: pcm186x: replace codec to component ASoC: tas6424: replace codec to component
drivers/gpu/drm/vc4/vc4_hdmi.c | 47 +- include/sound/soc.h | 13 +- sound/soc/amd/acp-rt5645.c | 4 +- sound/soc/atmel/atmel-classd.c | 54 +- sound/soc/atmel/atmel-pdmic.c | 56 +- sound/soc/codecs/88pm860x-codec.c | 166 ++--- sound/soc/codecs/88pm860x-codec.h | 4 +- sound/soc/codecs/ab8500-codec.c | 295 ++++---- sound/soc/codecs/ac97.c | 46 +- sound/soc/codecs/ad1836.c | 68 +- sound/soc/codecs/ad193x-i2c.c | 7 - sound/soc/codecs/ad193x-spi.c | 7 - sound/soc/codecs/ad193x.c | 46 +- sound/soc/codecs/ad1980.c | 87 +-- sound/soc/codecs/ad73311.c | 27 +- sound/soc/codecs/adau1373.c | 84 +-- sound/soc/codecs/adau1701.c | 101 ++- sound/soc/codecs/adau1761.c | 88 +-- sound/soc/codecs/adau1781.c | 51 +- sound/soc/codecs/adau17x1.c | 67 +- sound/soc/codecs/adau17x1.h | 8 +- sound/soc/codecs/adau1977-i2c.c | 7 - sound/soc/codecs/adau1977-spi.c | 7 - sound/soc/codecs/adau1977.c | 59 +- sound/soc/codecs/adau7002.c | 20 +- sound/soc/codecs/adav801.c | 7 - sound/soc/codecs/adav803.c | 7 - sound/soc/codecs/adav80x.c | 130 ++-- sound/soc/codecs/ads117x.c | 27 +- sound/soc/codecs/ak4104.c | 68 +- sound/soc/codecs/ak4535.c | 78 +- sound/soc/codecs/ak4554.c | 27 +- sound/soc/codecs/ak4613.c | 67 +- sound/soc/codecs/ak4641.c | 91 +-- sound/soc/codecs/ak4642.c | 105 ++- sound/soc/codecs/ak4671.c | 67 +- sound/soc/codecs/ak5386.c | 62 +- sound/soc/codecs/alc5623.c | 147 ++-- sound/soc/codecs/alc5632.c | 138 ++-- sound/soc/codecs/arizona.c | 208 +++--- sound/soc/codecs/arizona.h | 24 +- sound/soc/codecs/bt-sco.c | 21 +- sound/soc/codecs/cq93vc.c | 33 +- sound/soc/codecs/cs35l32.c | 45 +- sound/soc/codecs/cs35l33.c | 186 +++-- sound/soc/codecs/cs35l34.c | 127 ++-- sound/soc/codecs/cs35l35.c | 104 ++- sound/soc/codecs/cs4265.c | 98 ++- sound/soc/codecs/cs4270.c | 124 ++-- sound/soc/codecs/cs4271-i2c.c | 7 - sound/soc/codecs/cs4271-spi.c | 7 - sound/soc/codecs/cs4271.c | 105 ++- sound/soc/codecs/cs42l42.c | 154 ++-- sound/soc/codecs/cs42l42.h | 2 +- sound/soc/codecs/cs42l51-i2c.c | 8 - sound/soc/codecs/cs42l51.c | 81 ++- sound/soc/codecs/cs42l52.c | 146 ++-- sound/soc/codecs/cs42l56.c | 158 ++-- sound/soc/codecs/cs42l73.c | 122 ++-- sound/soc/codecs/cs42xx8-i2c.c | 1 - sound/soc/codecs/cs42xx8.c | 57 +- sound/soc/codecs/cs43130.c | 243 ++++--- sound/soc/codecs/cs43130.h | 2 +- sound/soc/codecs/cs4349.c | 39 +- sound/soc/codecs/cs47l24.c | 86 +-- sound/soc/codecs/cs53l30.c | 57 +- sound/soc/codecs/cx20442.c | 85 +-- sound/soc/codecs/da7210.c | 181 +++-- sound/soc/codecs/da7213.c | 328 ++++----- sound/soc/codecs/da7218.c | 498 +++++++------ sound/soc/codecs/da7218.h | 2 +- sound/soc/codecs/da7219-aad.c | 236 +++--- sound/soc/codecs/da7219-aad.h | 12 +- sound/soc/codecs/da7219.c | 307 ++++---- sound/soc/codecs/da7219.h | 2 +- sound/soc/codecs/da732x.c | 241 +++--- sound/soc/codecs/da9055.c | 186 +++-- sound/soc/codecs/dmic.c | 33 +- sound/soc/codecs/es7134.c | 27 +- sound/soc/codecs/es8316.c | 80 +- sound/soc/codecs/es8328-i2c.c | 7 - sound/soc/codecs/es8328-spi.c | 7 - sound/soc/codecs/es8328.c | 147 ++-- sound/soc/codecs/gtm601.c | 28 +- sound/soc/codecs/hdac_hdmi.c | 47 +- sound/soc/codecs/hdac_hdmi.h | 2 +- sound/soc/codecs/hdmi-codec.c | 23 +- sound/soc/codecs/ics43432.c | 16 +- sound/soc/codecs/inno_rk3036.c | 70 +- sound/soc/codecs/isabelle.c | 57 +- sound/soc/codecs/jz4740.c | 50 +- sound/soc/codecs/lm49453.c | 65 +- sound/soc/codecs/max98088.c | 314 ++++---- sound/soc/codecs/max98090.c | 319 ++++---- sound/soc/codecs/max98090.h | 4 +- sound/soc/codecs/max98095.c | 448 ++++++------ sound/soc/codecs/max98095.h | 2 +- sound/soc/codecs/max98357a.c | 29 +- sound/soc/codecs/max98371.c | 43 +- sound/soc/codecs/max98371.h | 1 - sound/soc/codecs/max98373.c | 75 +- sound/soc/codecs/max9850.c | 80 +- sound/soc/codecs/max9860.c | 70 +- sound/soc/codecs/max9867.c | 65 +- sound/soc/codecs/max9867.h | 2 +- sound/soc/codecs/max98925.c | 72 +- sound/soc/codecs/max98925.h | 2 +- sound/soc/codecs/max98926.c | 56 +- sound/soc/codecs/max98926.h | 2 +- sound/soc/codecs/max98927.c | 82 +-- sound/soc/codecs/max98927.h | 2 +- sound/soc/codecs/mc13783.c | 68 +- sound/soc/codecs/ml26124.c | 103 ++- sound/soc/codecs/msm8916-wcd-analog.c | 207 +++--- sound/soc/codecs/msm8916-wcd-digital.c | 115 +-- sound/soc/codecs/nau8540.c | 79 +- sound/soc/codecs/nau8810.c | 73 +- sound/soc/codecs/nau8824.c | 113 ++- sound/soc/codecs/nau8824.h | 2 +- sound/soc/codecs/nau8825.c | 107 ++- sound/soc/codecs/nau8825.h | 2 +- sound/soc/codecs/pcm1681.c | 62 +- sound/soc/codecs/pcm179x-i2c.c | 6 - sound/soc/codecs/pcm179x-spi.c | 6 - sound/soc/codecs/pcm179x.c | 45 +- sound/soc/codecs/pcm179x.h | 1 - sound/soc/codecs/pcm186x-i2c.c | 8 - sound/soc/codecs/pcm186x-spi.c | 8 - sound/soc/codecs/pcm186x.c | 143 ++-- sound/soc/codecs/pcm186x.h | 1 - sound/soc/codecs/pcm3008.c | 36 +- sound/soc/codecs/pcm3168a.c | 51 +- sound/soc/codecs/pcm5102a.c | 16 +- sound/soc/codecs/pcm512x.c | 162 ++--- sound/soc/codecs/rt274.c | 206 +++--- sound/soc/codecs/rt286.c | 198 +++-- sound/soc/codecs/rt286.h | 2 +- sound/soc/codecs/rt298.c | 210 +++--- sound/soc/codecs/rt298.h | 2 +- sound/soc/codecs/rt5514-spi.c | 4 +- sound/soc/codecs/rt5514.c | 124 ++-- sound/soc/codecs/rt5514.h | 2 +- sound/soc/codecs/rt5616.c | 219 +++--- sound/soc/codecs/rt5631.c | 324 +++++---- sound/soc/codecs/rt5640.c | 260 ++++--- sound/soc/codecs/rt5640.h | 6 +- sound/soc/codecs/rt5645.c | 370 +++++----- sound/soc/codecs/rt5645.h | 4 +- sound/soc/codecs/rt5651.c | 220 +++--- sound/soc/codecs/rt5651.h | 4 +- sound/soc/codecs/rt5659.c | 307 ++++---- sound/soc/codecs/rt5659.h | 4 +- sound/soc/codecs/rt5660.c | 145 ++-- sound/soc/codecs/rt5660.h | 2 +- sound/soc/codecs/rt5663.c | 600 ++++++++------- sound/soc/codecs/rt5663.h | 4 +- sound/soc/codecs/rt5665.c | 345 +++++---- sound/soc/codecs/rt5665.h | 2 +- sound/soc/codecs/rt5670.c | 295 ++++---- sound/soc/codecs/rt5670.h | 10 +- sound/soc/codecs/rt5677.c | 205 +++--- sound/soc/codecs/rt5677.h | 4 +- sound/soc/codecs/sgtl5000.c | 173 +++-- sound/soc/codecs/si476x.c | 42 +- sound/soc/codecs/sirf-audio-codec.c | 58 +- sound/soc/codecs/sn95031.c | 219 +++--- sound/soc/codecs/sn95031.h | 2 +- sound/soc/codecs/spdif_receiver.c | 26 +- sound/soc/codecs/spdif_transmitter.c | 26 +- sound/soc/codecs/ssm2518.c | 57 +- sound/soc/codecs/ssm2602-i2c.c | 7 - sound/soc/codecs/ssm2602-spi.c | 7 - sound/soc/codecs/ssm2602.c | 77 +- sound/soc/codecs/ssm4567.c | 44 +- sound/soc/codecs/sta32x.c | 134 ++-- sound/soc/codecs/sta350.c | 117 ++- sound/soc/codecs/sta529.c | 69 +- sound/soc/codecs/stac9766.c | 77 +- sound/soc/codecs/sti-sas.c | 84 +-- sound/soc/codecs/tas2552.c | 178 +++-- sound/soc/codecs/tas5086.c | 94 +-- sound/soc/codecs/tas571x.c | 55 +- sound/soc/codecs/tas5720.c | 151 ++-- sound/soc/codecs/tas6424.c | 99 ++- sound/soc/codecs/tfa9879.c | 50 +- sound/soc/codecs/tlv320aic23-i2c.c | 7 - sound/soc/codecs/tlv320aic23-spi.c | 7 - sound/soc/codecs/tlv320aic23.c | 120 +-- sound/soc/codecs/tlv320aic26.c | 83 +-- sound/soc/codecs/tlv320aic31xx.c | 240 +++--- sound/soc/codecs/tlv320aic32x4.c | 207 +++--- sound/soc/codecs/tlv320aic3x.c | 293 ++++---- sound/soc/codecs/tlv320dac33.c | 392 +++++----- sound/soc/codecs/tscs42xx.c | 222 +++--- sound/soc/codecs/twl4030.c | 379 +++++----- sound/soc/codecs/twl6040.c | 265 ++++--- sound/soc/codecs/twl6040.h | 10 +- sound/soc/codecs/uda134x.c | 78 +- sound/soc/codecs/uda1380.c | 156 ++-- sound/soc/codecs/wl1273.c | 93 ++- sound/soc/codecs/wl1273.h | 2 +- sound/soc/codecs/wm0010.c | 181 +++-- sound/soc/codecs/wm1250-ev1.c | 27 +- sound/soc/codecs/wm2000.c | 78 +- sound/soc/codecs/wm2200.c | 157 ++-- sound/soc/codecs/wm5100.c | 260 ++++--- sound/soc/codecs/wm5100.h | 2 +- sound/soc/codecs/wm5102.c | 106 ++- sound/soc/codecs/wm5110.c | 140 ++-- sound/soc/codecs/wm8350.c | 183 +++-- sound/soc/codecs/wm8350.h | 4 +- sound/soc/codecs/wm8400.c | 211 +++--- sound/soc/codecs/wm8510.c | 149 ++-- sound/soc/codecs/wm8523.c | 98 ++- sound/soc/codecs/wm8524.c | 56 +- sound/soc/codecs/wm8580.c | 150 ++-- sound/soc/codecs/wm8711.c | 116 ++- sound/soc/codecs/wm8727.c | 29 +- sound/soc/codecs/wm8728.c | 82 +-- sound/soc/codecs/wm8731.c | 101 ++- sound/soc/codecs/wm8737.c | 109 ++- sound/soc/codecs/wm8741.c | 133 ++-- sound/soc/codecs/wm8750.c | 115 ++- sound/soc/codecs/wm8753.c | 289 ++++---- sound/soc/codecs/wm8770.c | 131 ++-- sound/soc/codecs/wm8776.c | 105 ++- sound/soc/codecs/wm8782.c | 27 +- sound/soc/codecs/wm8804.c | 100 ++- sound/soc/codecs/wm8900.c | 251 ++++--- sound/soc/codecs/wm8903.c | 211 +++--- sound/soc/codecs/wm8903.h | 2 +- sound/soc/codecs/wm8904.c | 355 +++++---- sound/soc/codecs/wm8940.c | 159 ++-- sound/soc/codecs/wm8955.c | 189 +++-- sound/soc/codecs/wm8958-dsp2.c | 278 +++---- sound/soc/codecs/wm8960.c | 249 +++---- sound/soc/codecs/wm8961.c | 241 +++--- sound/soc/codecs/wm8962.c | 397 +++++----- sound/soc/codecs/wm8962.h | 2 +- sound/soc/codecs/wm8971.c | 108 ++- sound/soc/codecs/wm8974.c | 143 ++-- sound/soc/codecs/wm8978.c | 185 +++-- sound/soc/codecs/wm8983.c | 170 ++--- sound/soc/codecs/wm8985.c | 201 +++-- sound/soc/codecs/wm8988.c | 127 ++-- sound/soc/codecs/wm8990.c | 179 +++-- sound/soc/codecs/wm8991.c | 167 ++--- sound/soc/codecs/wm8993.c | 237 +++--- sound/soc/codecs/wm8994.c | 810 +++++++++++---------- sound/soc/codecs/wm8994.h | 8 +- sound/soc/codecs/wm8995.c | 286 ++++---- sound/soc/codecs/wm8996.c | 401 +++++----- sound/soc/codecs/wm8996.h | 4 +- sound/soc/codecs/wm8997.c | 62 +- sound/soc/codecs/wm8998.c | 88 ++- sound/soc/codecs/wm9081.c | 228 +++--- sound/soc/codecs/wm9090.c | 109 ++- sound/soc/codecs/wm9705.c | 83 +-- sound/soc/codecs/wm9712.c | 109 ++- sound/soc/codecs/wm9713.c | 201 +++-- sound/soc/codecs/wm_adsp.c | 58 +- sound/soc/codecs/wm_adsp.h | 6 +- sound/soc/codecs/wm_hubs.c | 254 +++---- sound/soc/codecs/wm_hubs.h | 18 +- sound/soc/codecs/zx_aud96p22.c | 35 +- sound/soc/fsl/wm1133-ev1.c | 6 +- sound/soc/img/pistachio-internal-dac.c | 34 +- sound/soc/intel/boards/bdw-rt5677.c | 38 +- sound/soc/intel/boards/broadwell.c | 14 +- sound/soc/intel/boards/bxt_da7219_max98357a.c | 12 +- sound/soc/intel/boards/bxt_rt298.c | 12 +- sound/soc/intel/boards/byt-rt5640.c | 4 +- sound/soc/intel/boards/bytcr_rt5640.c | 8 +- sound/soc/intel/boards/bytcr_rt5651.c | 2 +- sound/soc/intel/boards/cht_bsw_rt5645.c | 8 +- sound/soc/intel/boards/cht_bsw_rt5672.c | 18 +- sound/soc/intel/boards/kbl_rt5663_max98927.c | 14 +- .../soc/intel/boards/kbl_rt5663_rt5514_max98927.c | 14 +- sound/soc/intel/boards/mfld_machine.c | 12 +- sound/soc/intel/boards/skl_nau88l25_max98357a.c | 12 +- sound/soc/intel/boards/skl_nau88l25_ssm4567.c | 12 +- sound/soc/intel/boards/skl_rt286.c | 12 +- sound/soc/mediatek/mt8173/mt8173-max98090.c | 4 +- sound/soc/mediatek/mt8173/mt8173-rt5650-rt5514.c | 6 +- sound/soc/mediatek/mt8173/mt8173-rt5650-rt5676.c | 12 +- sound/soc/mediatek/mt8173/mt8173-rt5650.c | 12 +- sound/soc/omap/ams-delta.c | 20 +- sound/soc/omap/omap-abe-twl6040.c | 8 +- sound/soc/pxa/mioa701_wm9713.c | 30 +- sound/soc/pxa/ttc-dkb.c | 6 +- sound/soc/rockchip/rk3399_gru_sound.c | 4 +- sound/soc/rockchip/rockchip_rt5645.c | 8 +- sound/soc/samsung/littlemill.c | 8 +- sound/soc/samsung/lowland.c | 12 +- sound/soc/samsung/speyside.c | 12 +- sound/soc/samsung/tm2_wm5110.c | 54 +- sound/soc/samsung/tobermory.c | 6 +- sound/soc/soc-ac97.c | 84 ++- sound/soc/soc-utils.c | 22 +- sound/soc/sunxi/sun4i-codec.c | 71 +- sound/soc/sunxi/sun8i-codec.c | 23 +- sound/soc/tegra/tegra_wm8903.c | 8 +- sound/soc/uniphier/evea.c | 67 +- 303 files changed, 14204 insertions(+), 15237 deletions(-)
From: Kuninori Morimoto kuninori.morimoto.gx@renesas.com
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 -> .pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com --- sound/soc/soc-utils.c | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-)
diff --git a/sound/soc/soc-utils.c b/sound/soc/soc-utils.c index e237858..1e0f802 100644 --- a/sound/soc/soc-utils.c +++ b/sound/soc/soc-utils.c @@ -288,7 +288,12 @@ static int dummy_dma_open(struct snd_pcm_substream *substream) .ops = &dummy_dma_ops, };
-static const struct snd_soc_codec_driver dummy_codec; +static const struct snd_soc_component_driver dummy_codec = { + .idle_bias_on = 1, + .pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, +};
#define STUB_RATES SNDRV_PCM_RATE_8000_192000 #define STUB_FORMATS (SNDRV_PCM_FMTBIT_S8 | \ @@ -338,33 +343,22 @@ static int snd_soc_dummy_probe(struct platform_device *pdev) { int ret;
- ret = snd_soc_register_codec(&pdev->dev, &dummy_codec, &dummy_dai, 1); + ret = devm_snd_soc_register_component(&pdev->dev, + &dummy_codec, &dummy_dai, 1); if (ret < 0) return ret;
ret = devm_snd_soc_register_component(&pdev->dev, &dummy_platform, NULL, 0); - if (ret < 0) { - snd_soc_unregister_codec(&pdev->dev); - return ret; - }
return ret; }
-static int snd_soc_dummy_remove(struct platform_device *pdev) -{ - snd_soc_unregister_codec(&pdev->dev); - - return 0; -} - static struct platform_driver soc_dummy_driver = { .driver = { .name = "snd-soc-dummy", }, .probe = snd_soc_dummy_probe, - .remove = snd_soc_dummy_remove, };
static struct platform_device *soc_dummy_dev;
From: Kuninori Morimoto kuninori.morimoto.gx@renesas.com
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 -> .pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1
To keep compatibilty, this patch adds snd_soc_xxx_ac97_codec() macro. These will be removed when all codec code was removed.
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com --- include/sound/soc.h | 13 ++++++-- sound/soc/codecs/ac97.c | 46 +++++++++++++-------------- sound/soc/soc-ac97.c | 84 ++++++++++++++++++++++++++----------------------- 3 files changed, 77 insertions(+), 66 deletions(-)
diff --git a/include/sound/soc.h b/include/sound/soc.h index a34aa20..29e5379 100644 --- a/include/sound/soc.h +++ b/include/sound/soc.h @@ -586,10 +586,17 @@ int snd_soc_test_bits(struct snd_soc_codec *codec, unsigned int reg, unsigned int mask, unsigned int value);
#ifdef CONFIG_SND_SOC_AC97_BUS -struct snd_ac97 *snd_soc_alloc_ac97_codec(struct snd_soc_codec *codec); -struct snd_ac97 *snd_soc_new_ac97_codec(struct snd_soc_codec *codec, +#define snd_soc_alloc_ac97_codec(codec) \ + snd_soc_alloc_ac97_component(&codec->component) +#define snd_soc_new_ac97_codec(codec, id, id_mask) \ + snd_soc_new_ac97_component(&codec->component, id, id_mask) +#define snd_soc_free_ac97_codec(ac97) \ + snd_soc_free_ac97_component(ac97) + +struct snd_ac97 *snd_soc_alloc_ac97_component(struct snd_soc_component *component); +struct snd_ac97 *snd_soc_new_ac97_component(struct snd_soc_component *component, unsigned int id, unsigned int id_mask); -void snd_soc_free_ac97_codec(struct snd_ac97 *ac97); +void snd_soc_free_ac97_component(struct snd_ac97 *ac97);
int snd_soc_set_ac97_ops(struct snd_ac97_bus_ops *ops); int snd_soc_set_ac97_ops_of_reset(struct snd_ac97_bus_ops *ops, diff --git a/sound/soc/codecs/ac97.c b/sound/soc/codecs/ac97.c index 440b4ce..432206b 100644 --- a/sound/soc/codecs/ac97.c +++ b/sound/soc/codecs/ac97.c @@ -36,8 +36,8 @@ static int ac97_prepare(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; - struct snd_ac97 *ac97 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct snd_ac97 *ac97 = snd_soc_component_get_drvdata(component);
int reg = (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) ? AC97_PCM_FRONT_DAC_RATE : AC97_PCM_LR_ADC_RATE; @@ -65,7 +65,7 @@ static int ac97_prepare(struct snd_pcm_substream *substream, .ops = &ac97_dai_ops, };
-static int ac97_soc_probe(struct snd_soc_codec *codec) +static int ac97_soc_probe(struct snd_soc_component *component) { struct snd_ac97 *ac97; struct snd_ac97_bus *ac97_bus; @@ -73,7 +73,7 @@ static int ac97_soc_probe(struct snd_soc_codec *codec) int ret;
/* add codec as bus device for standard ac97 */ - ret = snd_ac97_bus(codec->component.card->snd_card, 0, soc_ac97_ops, + ret = snd_ac97_bus(component->card->snd_card, 0, soc_ac97_ops, NULL, &ac97_bus); if (ret < 0) return ret; @@ -83,25 +83,25 @@ static int ac97_soc_probe(struct snd_soc_codec *codec) if (ret < 0) return ret;
- snd_soc_codec_set_drvdata(codec, ac97); + snd_soc_component_set_drvdata(component, ac97);
return 0; }
#ifdef CONFIG_PM -static int ac97_soc_suspend(struct snd_soc_codec *codec) +static int ac97_soc_suspend(struct snd_soc_component *component) { - struct snd_ac97 *ac97 = snd_soc_codec_get_drvdata(codec); + struct snd_ac97 *ac97 = snd_soc_component_get_drvdata(component);
snd_ac97_suspend(ac97);
return 0; }
-static int ac97_soc_resume(struct snd_soc_codec *codec) +static int ac97_soc_resume(struct snd_soc_component *component) {
- struct snd_ac97 *ac97 = snd_soc_codec_get_drvdata(codec); + struct snd_ac97 *ac97 = snd_soc_component_get_drvdata(component);
snd_ac97_resume(ac97);
@@ -112,28 +112,28 @@ static int ac97_soc_resume(struct snd_soc_codec *codec) #define ac97_soc_resume NULL #endif
-static const struct snd_soc_codec_driver soc_codec_dev_ac97 = { - .probe = ac97_soc_probe, - .suspend = ac97_soc_suspend, - .resume = ac97_soc_resume, - - .component_driver = { - .dapm_widgets = ac97_widgets, - .num_dapm_widgets = ARRAY_SIZE(ac97_widgets), - .dapm_routes = ac97_routes, - .num_dapm_routes = ARRAY_SIZE(ac97_routes), - }, +static const struct snd_soc_component_driver soc_component_dev_ac97 = { + .probe = ac97_soc_probe, + .suspend = ac97_soc_suspend, + .resume = ac97_soc_resume, + .dapm_widgets = ac97_widgets, + .num_dapm_widgets = ARRAY_SIZE(ac97_widgets), + .dapm_routes = ac97_routes, + .num_dapm_routes = ARRAY_SIZE(ac97_routes), + .idle_bias_on = 1, + .pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, };
static int ac97_probe(struct platform_device *pdev) { - return snd_soc_register_codec(&pdev->dev, - &soc_codec_dev_ac97, &ac97_dai, 1); + return devm_snd_soc_register_component(&pdev->dev, + &soc_component_dev_ac97, &ac97_dai, 1); }
static int ac97_remove(struct platform_device *pdev) { - snd_soc_unregister_codec(&pdev->dev); return 0; }
diff --git a/sound/soc/soc-ac97.c b/sound/soc/soc-ac97.c index 36dae41..3f424f2 100644 --- a/sound/soc/soc-ac97.c +++ b/sound/soc/soc-ac97.c @@ -44,7 +44,7 @@ struct snd_ac97_gpio_priv { struct gpio_chip gpio_chip; #endif unsigned int gpios_set; - struct snd_soc_codec *codec; + struct snd_soc_component *component; };
static struct snd_ac97_bus soc_ac97_bus = { @@ -57,11 +57,11 @@ static void soc_ac97_device_release(struct device *dev) }
#ifdef CONFIG_GPIOLIB -static inline struct snd_soc_codec *gpio_to_codec(struct gpio_chip *chip) +static inline struct snd_soc_component *gpio_to_component(struct gpio_chip *chip) { struct snd_ac97_gpio_priv *gpio_priv = gpiochip_get_data(chip);
- return gpio_priv->codec; + return gpio_priv->component; }
static int snd_soc_ac97_gpio_request(struct gpio_chip *chip, unsigned offset) @@ -75,20 +75,22 @@ static int snd_soc_ac97_gpio_request(struct gpio_chip *chip, unsigned offset) static int snd_soc_ac97_gpio_direction_in(struct gpio_chip *chip, unsigned offset) { - struct snd_soc_codec *codec = gpio_to_codec(chip); + struct snd_soc_component *component = gpio_to_component(chip);
- dev_dbg(codec->dev, "set gpio %d to output\n", offset); - return snd_soc_update_bits(codec, AC97_GPIO_CFG, + dev_dbg(component->dev, "set gpio %d to output\n", offset); + return snd_soc_component_update_bits(component, AC97_GPIO_CFG, 1 << offset, 1 << offset); }
static int snd_soc_ac97_gpio_get(struct gpio_chip *chip, unsigned offset) { - struct snd_soc_codec *codec = gpio_to_codec(chip); + struct snd_soc_component *component = gpio_to_component(chip); int ret;
- ret = snd_soc_read(codec, AC97_GPIO_STATUS); - dev_dbg(codec->dev, "get gpio %d : %d\n", offset, + if (snd_soc_component_read(component, AC97_GPIO_STATUS, &ret) < 0) + ret = -1; + + dev_dbg(component->dev, "get gpio %d : %d\n", offset, ret < 0 ? ret : ret & (1 << offset));
return ret < 0 ? ret : !!(ret & (1 << offset)); @@ -98,22 +100,24 @@ static void snd_soc_ac97_gpio_set(struct gpio_chip *chip, unsigned offset, int value) { struct snd_ac97_gpio_priv *gpio_priv = gpiochip_get_data(chip); - struct snd_soc_codec *codec = gpio_to_codec(chip); + struct snd_soc_component *component = gpio_to_component(chip);
gpio_priv->gpios_set &= ~(1 << offset); gpio_priv->gpios_set |= (!!value) << offset; - snd_soc_write(codec, AC97_GPIO_STATUS, gpio_priv->gpios_set); - dev_dbg(codec->dev, "set gpio %d to %d\n", offset, !!value); + snd_soc_component_write(component, AC97_GPIO_STATUS, + gpio_priv->gpios_set); + dev_dbg(component->dev, "set gpio %d to %d\n", offset, !!value); }
static int snd_soc_ac97_gpio_direction_out(struct gpio_chip *chip, unsigned offset, int value) { - struct snd_soc_codec *codec = gpio_to_codec(chip); + struct snd_soc_component *component = gpio_to_component(chip);
- dev_dbg(codec->dev, "set gpio %d to output\n", offset); + dev_dbg(component->dev, "set gpio %d to output\n", offset); snd_soc_ac97_gpio_set(chip, offset, value); - return snd_soc_update_bits(codec, AC97_GPIO_CFG, 1 << offset, 0); + return snd_soc_component_update_bits(component, AC97_GPIO_CFG, + 1 << offset, 0); }
static const struct gpio_chip snd_soc_ac97_gpio_chip = { @@ -128,24 +132,24 @@ static int snd_soc_ac97_gpio_direction_out(struct gpio_chip *chip, };
static int snd_soc_ac97_init_gpio(struct snd_ac97 *ac97, - struct snd_soc_codec *codec) + struct snd_soc_component *component) { struct snd_ac97_gpio_priv *gpio_priv; int ret;
- gpio_priv = devm_kzalloc(codec->dev, sizeof(*gpio_priv), GFP_KERNEL); + gpio_priv = devm_kzalloc(component->dev, sizeof(*gpio_priv), GFP_KERNEL); if (!gpio_priv) return -ENOMEM; ac97->gpio_priv = gpio_priv; - gpio_priv->codec = codec; + gpio_priv->component = component; gpio_priv->gpio_chip = snd_soc_ac97_gpio_chip; gpio_priv->gpio_chip.ngpio = AC97_NUM_GPIOS; - gpio_priv->gpio_chip.parent = codec->dev; + gpio_priv->gpio_chip.parent = component->dev; gpio_priv->gpio_chip.base = -1;
ret = gpiochip_add_data(&gpio_priv->gpio_chip, gpio_priv); if (ret != 0) - dev_err(codec->dev, "Failed to add GPIOs: %d\n", ret); + dev_err(component->dev, "Failed to add GPIOs: %d\n", ret); return ret; }
@@ -155,7 +159,7 @@ static void snd_soc_ac97_free_gpio(struct snd_ac97 *ac97) } #else static int snd_soc_ac97_init_gpio(struct snd_ac97 *ac97, - struct snd_soc_codec *codec) + struct snd_soc_component *component) { return 0; } @@ -166,8 +170,8 @@ static void snd_soc_ac97_free_gpio(struct snd_ac97 *ac97) #endif
/** - * snd_soc_alloc_ac97_codec() - Allocate new a AC'97 device - * @codec: The CODEC for which to create the AC'97 device + * snd_soc_alloc_ac97_component() - Allocate new a AC'97 device + * @component: The COMPONENT for which to create the AC'97 device * * Allocated a new snd_ac97 device and intializes it, but does not yet register * it. The caller is responsible to either call device_add(&ac97->dev) to @@ -175,7 +179,7 @@ static void snd_soc_ac97_free_gpio(struct snd_ac97 *ac97) * * Returns: A snd_ac97 device or a PTR_ERR in case of an error. */ -struct snd_ac97 *snd_soc_alloc_ac97_codec(struct snd_soc_codec *codec) +struct snd_ac97 *snd_soc_alloc_ac97_component(struct snd_soc_component *component) { struct snd_ac97 *ac97;
@@ -187,26 +191,26 @@ struct snd_ac97 *snd_soc_alloc_ac97_codec(struct snd_soc_codec *codec) ac97->num = 0;
ac97->dev.bus = &ac97_bus_type; - ac97->dev.parent = codec->component.card->dev; + ac97->dev.parent = component->card->dev; ac97->dev.release = soc_ac97_device_release;
dev_set_name(&ac97->dev, "%d-%d:%s", - codec->component.card->snd_card->number, 0, - codec->component.name); + component->card->snd_card->number, 0, + component->name);
device_initialize(&ac97->dev);
return ac97; } -EXPORT_SYMBOL(snd_soc_alloc_ac97_codec); +EXPORT_SYMBOL(snd_soc_alloc_ac97_component);
/** - * snd_soc_new_ac97_codec - initailise AC97 device - * @codec: audio codec + * snd_soc_new_ac97_component - initailise AC97 device + * @component: audio component * @id: The expected device ID * @id_mask: Mask that is applied to the device ID before comparing with @id * - * Initialises AC97 codec resources for use by ad-hoc devices only. + * Initialises AC97 component resources for use by ad-hoc devices only. * * If @id is not 0 this function will reset the device, then read the ID from * the device and check if it matches the expected ID. If it doesn't match an @@ -214,20 +218,20 @@ struct snd_ac97 *snd_soc_alloc_ac97_codec(struct snd_soc_codec *codec) * * Returns: A PTR_ERR() on failure or a valid snd_ac97 struct on success. */ -struct snd_ac97 *snd_soc_new_ac97_codec(struct snd_soc_codec *codec, +struct snd_ac97 *snd_soc_new_ac97_component(struct snd_soc_component *component, unsigned int id, unsigned int id_mask) { struct snd_ac97 *ac97; int ret;
- ac97 = snd_soc_alloc_ac97_codec(codec); + ac97 = snd_soc_alloc_ac97_component(component); if (IS_ERR(ac97)) return ac97;
if (id) { ret = snd_ac97_reset(ac97, false, id, id_mask); if (ret < 0) { - dev_err(codec->dev, "Failed to reset AC97 device: %d\n", + dev_err(component->dev, "Failed to reset AC97 device: %d\n", ret); goto err_put_device; } @@ -237,7 +241,7 @@ struct snd_ac97 *snd_soc_new_ac97_codec(struct snd_soc_codec *codec, if (ret) goto err_put_device;
- ret = snd_soc_ac97_init_gpio(ac97, codec); + ret = snd_soc_ac97_init_gpio(ac97, component); if (ret) goto err_put_device;
@@ -247,22 +251,22 @@ struct snd_ac97 *snd_soc_new_ac97_codec(struct snd_soc_codec *codec, put_device(&ac97->dev); return ERR_PTR(ret); } -EXPORT_SYMBOL_GPL(snd_soc_new_ac97_codec); +EXPORT_SYMBOL_GPL(snd_soc_new_ac97_component);
/** - * snd_soc_free_ac97_codec - free AC97 codec device + * snd_soc_free_ac97_component - free AC97 component device * @ac97: snd_ac97 device to be freed * - * Frees AC97 codec device resources. + * Frees AC97 component device resources. */ -void snd_soc_free_ac97_codec(struct snd_ac97 *ac97) +void snd_soc_free_ac97_component(struct snd_ac97 *ac97) { snd_soc_ac97_free_gpio(ac97); device_del(&ac97->dev); ac97->bus = NULL; put_device(&ac97->dev); } -EXPORT_SYMBOL_GPL(snd_soc_free_ac97_codec); +EXPORT_SYMBOL_GPL(snd_soc_free_ac97_component);
static struct snd_ac97_reset_cfg snd_ac97_rst_cfg;
From: Kuninori Morimoto kuninori.morimoto.gx@renesas.com
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 -> .pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com --- sound/soc/codecs/wm0010.c | 181 +++++++++++++++++++++++----------------------- 1 file changed, 89 insertions(+), 92 deletions(-)
diff --git a/sound/soc/codecs/wm0010.c b/sound/soc/codecs/wm0010.c index 0147d2f..ab1ad33 100644 --- a/sound/soc/codecs/wm0010.c +++ b/sound/soc/codecs/wm0010.c @@ -90,7 +90,7 @@ enum wm0010_state { };
struct wm0010_priv { - struct snd_soc_codec *codec; + struct snd_soc_component *component;
struct mutex lock; struct device *dev; @@ -157,9 +157,9 @@ static const char *wm0010_state_to_str(enum wm0010_state state) }
/* Called with wm0010->lock held */ -static void wm0010_halt(struct snd_soc_codec *codec) +static void wm0010_halt(struct snd_soc_component *component) { - struct wm0010_priv *wm0010 = snd_soc_codec_get_drvdata(codec); + struct wm0010_priv *wm0010 = snd_soc_component_get_drvdata(component); unsigned long flags; enum wm0010_state state;
@@ -193,7 +193,7 @@ static void wm0010_halt(struct snd_soc_codec *codec)
struct wm0010_boot_xfer { struct list_head list; - struct snd_soc_codec *codec; + struct snd_soc_component *component; struct completion *done; struct spi_message m; struct spi_transfer t; @@ -218,13 +218,13 @@ static void wm0010_mark_boot_failure(struct wm0010_priv *wm0010) static void wm0010_boot_xfer_complete(void *data) { struct wm0010_boot_xfer *xfer = data; - struct snd_soc_codec *codec = xfer->codec; - struct wm0010_priv *wm0010 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = xfer->component; + struct wm0010_priv *wm0010 = snd_soc_component_get_drvdata(component); u32 *out32 = xfer->t.rx_buf; int i;
if (xfer->m.status != 0) { - dev_err(codec->dev, "SPI transfer failed: %d\n", + dev_err(component->dev, "SPI transfer failed: %d\n", xfer->m.status); wm0010_mark_boot_failure(wm0010); if (xfer->done) @@ -233,11 +233,11 @@ static void wm0010_boot_xfer_complete(void *data) }
for (i = 0; i < xfer->t.len / 4; i++) { - dev_dbg(codec->dev, "%d: %04x\n", i, out32[i]); + dev_dbg(component->dev, "%d: %04x\n", i, out32[i]);
switch (be32_to_cpu(out32[i])) { case 0xe0e0e0e0: - dev_err(codec->dev, + dev_err(component->dev, "%d: ROM error reported in stage 2\n", i); wm0010_mark_boot_failure(wm0010); break; @@ -245,82 +245,82 @@ static void wm0010_boot_xfer_complete(void *data) case 0x55555555: if (wm0010->state < WM0010_STAGE2) break; - dev_err(codec->dev, + dev_err(component->dev, "%d: ROM bootloader running in stage 2\n", i); wm0010_mark_boot_failure(wm0010); break;
case 0x0fed0000: - dev_dbg(codec->dev, "Stage2 loader running\n"); + dev_dbg(component->dev, "Stage2 loader running\n"); break;
case 0x0fed0007: - dev_dbg(codec->dev, "CODE_HDR packet received\n"); + dev_dbg(component->dev, "CODE_HDR packet received\n"); break;
case 0x0fed0008: - dev_dbg(codec->dev, "CODE_DATA packet received\n"); + dev_dbg(component->dev, "CODE_DATA packet received\n"); break;
case 0x0fed0009: - dev_dbg(codec->dev, "Download complete\n"); + dev_dbg(component->dev, "Download complete\n"); break;
case 0x0fed000c: - dev_dbg(codec->dev, "Application start\n"); + dev_dbg(component->dev, "Application start\n"); break;
case 0x0fed000e: - dev_dbg(codec->dev, "PLL packet received\n"); + dev_dbg(component->dev, "PLL packet received\n"); wm0010->pll_running = true; break;
case 0x0fed0025: - dev_err(codec->dev, "Device reports image too long\n"); + dev_err(component->dev, "Device reports image too long\n"); wm0010_mark_boot_failure(wm0010); break;
case 0x0fed002c: - dev_err(codec->dev, "Device reports bad SPI packet\n"); + dev_err(component->dev, "Device reports bad SPI packet\n"); wm0010_mark_boot_failure(wm0010); break;
case 0x0fed0031: - dev_err(codec->dev, "Device reports SPI read overflow\n"); + dev_err(component->dev, "Device reports SPI read overflow\n"); wm0010_mark_boot_failure(wm0010); break;
case 0x0fed0032: - dev_err(codec->dev, "Device reports SPI underclock\n"); + dev_err(component->dev, "Device reports SPI underclock\n"); wm0010_mark_boot_failure(wm0010); break;
case 0x0fed0033: - dev_err(codec->dev, "Device reports bad header packet\n"); + dev_err(component->dev, "Device reports bad header packet\n"); wm0010_mark_boot_failure(wm0010); break;
case 0x0fed0034: - dev_err(codec->dev, "Device reports invalid packet type\n"); + dev_err(component->dev, "Device reports invalid packet type\n"); wm0010_mark_boot_failure(wm0010); break;
case 0x0fed0035: - dev_err(codec->dev, "Device reports data before header error\n"); + dev_err(component->dev, "Device reports data before header error\n"); wm0010_mark_boot_failure(wm0010); break;
case 0x0fed0038: - dev_err(codec->dev, "Device reports invalid PLL packet\n"); + dev_err(component->dev, "Device reports invalid PLL packet\n"); break;
case 0x0fed003a: - dev_err(codec->dev, "Device reports packet alignment error\n"); + dev_err(component->dev, "Device reports packet alignment error\n"); wm0010_mark_boot_failure(wm0010); break;
default: - dev_err(codec->dev, "Unrecognised return 0x%x\n", + dev_err(component->dev, "Unrecognised return 0x%x\n", be32_to_cpu(out32[i])); wm0010_mark_boot_failure(wm0010); break; @@ -342,10 +342,10 @@ static void byte_swap_64(u64 *data_in, u64 *data_out, u32 len) data_out[i] = cpu_to_be64(le64_to_cpu(data_in[i])); }
-static int wm0010_firmware_load(const char *name, struct snd_soc_codec *codec) +static int wm0010_firmware_load(const char *name, struct snd_soc_component *component) { - struct spi_device *spi = to_spi_device(codec->dev); - struct wm0010_priv *wm0010 = snd_soc_codec_get_drvdata(codec); + struct spi_device *spi = to_spi_device(component->dev); + struct wm0010_priv *wm0010 = snd_soc_component_get_drvdata(component); struct list_head xfer_list; struct wm0010_boot_xfer *xfer; int ret; @@ -359,9 +359,9 @@ static int wm0010_firmware_load(const char *name, struct snd_soc_codec *codec)
INIT_LIST_HEAD(&xfer_list);
- ret = request_firmware(&fw, name, codec->dev); + ret = request_firmware(&fw, name, component->dev); if (ret != 0) { - dev_err(codec->dev, "Failed to request application(%s): %d\n", + dev_err(component->dev, "Failed to request application(%s): %d\n", name, ret); return ret; } @@ -377,25 +377,25 @@ static int wm0010_firmware_load(const char *name, struct snd_soc_codec *codec)
/* First record should be INFO */ if (rec->command != DFW_CMD_INFO) { - dev_err(codec->dev, "First record not INFO\r\n"); + dev_err(component->dev, "First record not INFO\r\n"); ret = -EINVAL; goto abort; }
if (inforec->info_version != INFO_VERSION) { - dev_err(codec->dev, + dev_err(component->dev, "Unsupported version (%02d) of INFO record\r\n", inforec->info_version); ret = -EINVAL; goto abort; }
- dev_dbg(codec->dev, "Version v%02d INFO record found\r\n", + dev_dbg(component->dev, "Version v%02d INFO record found\r\n", inforec->info_version);
/* Check it's a DSP file */ if (dsp != DEVICE_ID_WM0010) { - dev_err(codec->dev, "Not a WM0010 firmware file.\r\n"); + dev_err(component->dev, "Not a WM0010 firmware file.\r\n"); ret = -EINVAL; goto abort; } @@ -405,7 +405,7 @@ static int wm0010_firmware_load(const char *name, struct snd_soc_codec *codec) rec = (void *)&rec->data[rec->length];
while (offset < fw->size) { - dev_dbg(codec->dev, + dev_dbg(component->dev, "Packet: command %d, data length = 0x%x\r\n", rec->command, rec->length); len = rec->length + 8; @@ -416,7 +416,7 @@ static int wm0010_firmware_load(const char *name, struct snd_soc_codec *codec) goto abort; }
- xfer->codec = codec; + xfer->component = component; list_add_tail(&xfer->list, &xfer_list);
out = kzalloc(len, GFP_KERNEL | GFP_DMA); @@ -460,18 +460,18 @@ static int wm0010_firmware_load(const char *name, struct snd_soc_codec *codec) rec = (void *)&rec->data[rec->length];
if (offset >= fw->size) { - dev_dbg(codec->dev, "All transfers scheduled\n"); + dev_dbg(component->dev, "All transfers scheduled\n"); xfer->done = &done; }
ret = spi_async(spi, &xfer->m); if (ret != 0) { - dev_err(codec->dev, "Write failed: %d\n", ret); + dev_err(component->dev, "Write failed: %d\n", ret); goto abort1; }
if (wm0010->boot_failed) { - dev_dbg(codec->dev, "Boot fail!\n"); + dev_dbg(component->dev, "Boot fail!\n"); ret = -EINVAL; goto abort1; } @@ -496,10 +496,10 @@ static int wm0010_firmware_load(const char *name, struct snd_soc_codec *codec) return ret; }
-static int wm0010_stage2_load(struct snd_soc_codec *codec) +static int wm0010_stage2_load(struct snd_soc_component *component) { - struct spi_device *spi = to_spi_device(codec->dev); - struct wm0010_priv *wm0010 = snd_soc_codec_get_drvdata(codec); + struct spi_device *spi = to_spi_device(component->dev); + struct wm0010_priv *wm0010 = snd_soc_component_get_drvdata(component); const struct firmware *fw; struct spi_message m; struct spi_transfer t; @@ -508,14 +508,14 @@ static int wm0010_stage2_load(struct snd_soc_codec *codec) int i; int ret = 0;
- ret = request_firmware(&fw, "wm0010_stage2.bin", codec->dev); + ret = request_firmware(&fw, "wm0010_stage2.bin", component->dev); if (ret != 0) { - dev_err(codec->dev, "Failed to request stage2 loader: %d\n", + dev_err(component->dev, "Failed to request stage2 loader: %d\n", ret); return ret; }
- dev_dbg(codec->dev, "Downloading %zu byte stage 2 loader\n", fw->size); + dev_dbg(component->dev, "Downloading %zu byte stage 2 loader\n", fw->size);
/* Copy to local buffer first as vmalloc causes problems for dma */ img = kzalloc(fw->size, GFP_KERNEL | GFP_DMA); @@ -541,19 +541,19 @@ static int wm0010_stage2_load(struct snd_soc_codec *codec) t.speed_hz = wm0010->sysclk / 10; spi_message_add_tail(&t, &m);
- dev_dbg(codec->dev, "Starting initial download at %dHz\n", + dev_dbg(component->dev, "Starting initial download at %dHz\n", t.speed_hz);
ret = spi_sync(spi, &m); if (ret != 0) { - dev_err(codec->dev, "Initial download failed: %d\n", ret); + dev_err(component->dev, "Initial download failed: %d\n", ret); goto abort; }
/* Look for errors from the boot ROM */ for (i = 0; i < fw->size; i++) { if (out[i] != 0x55) { - dev_err(codec->dev, "Boot ROM error: %x in %d\n", + dev_err(component->dev, "Boot ROM error: %x in %d\n", out[i], i); wm0010_mark_boot_failure(wm0010); ret = -EBUSY; @@ -570,10 +570,10 @@ static int wm0010_stage2_load(struct snd_soc_codec *codec) return ret; }
-static int wm0010_boot(struct snd_soc_codec *codec) +static int wm0010_boot(struct snd_soc_component *component) { - struct spi_device *spi = to_spi_device(codec->dev); - struct wm0010_priv *wm0010 = snd_soc_codec_get_drvdata(codec); + struct spi_device *spi = to_spi_device(component->dev); + struct wm0010_priv *wm0010 = snd_soc_component_get_drvdata(component); unsigned long flags; int ret; struct spi_message m; @@ -590,7 +590,7 @@ static int wm0010_boot(struct snd_soc_codec *codec) spin_unlock_irqrestore(&wm0010->irq_lock, flags);
if (wm0010->sysclk > 26000000) { - dev_err(codec->dev, "Max DSP clock frequency is 26MHz\n"); + dev_err(component->dev, "Max DSP clock frequency is 26MHz\n"); ret = -ECANCELED; goto err; } @@ -598,7 +598,7 @@ static int wm0010_boot(struct snd_soc_codec *codec) mutex_lock(&wm0010->lock); wm0010->pll_running = false;
- dev_dbg(codec->dev, "max_spi_freq: %d\n", wm0010->max_spi_freq); + dev_dbg(component->dev, "max_spi_freq: %d\n", wm0010->max_spi_freq);
ret = regulator_bulk_enable(ARRAY_SIZE(wm0010->core_supplies), wm0010->core_supplies); @@ -623,19 +623,19 @@ static int wm0010_boot(struct snd_soc_codec *codec)
if (!wait_for_completion_timeout(&wm0010->boot_completion, msecs_to_jiffies(20))) - dev_err(codec->dev, "Failed to get interrupt from DSP\n"); + dev_err(component->dev, "Failed to get interrupt from DSP\n");
spin_lock_irqsave(&wm0010->irq_lock, flags); wm0010->state = WM0010_BOOTROM; spin_unlock_irqrestore(&wm0010->irq_lock, flags);
- ret = wm0010_stage2_load(codec); + ret = wm0010_stage2_load(component); if (ret) goto abort;
if (!wait_for_completion_timeout(&wm0010->boot_completion, msecs_to_jiffies(20))) - dev_err(codec->dev, "Failed to get interrupt from DSP loader.\n"); + dev_err(component->dev, "Failed to get interrupt from DSP loader.\n");
spin_lock_irqsave(&wm0010->irq_lock, flags); wm0010->state = WM0010_STAGE2; @@ -676,14 +676,14 @@ static int wm0010_boot(struct snd_soc_codec *codec)
ret = spi_sync(spi, &m); if (ret) { - dev_err(codec->dev, "First PLL write failed: %d\n", ret); + dev_err(component->dev, "First PLL write failed: %d\n", ret); goto abort_swap; }
/* Use a second send of the message to get the return status */ ret = spi_sync(spi, &m); if (ret) { - dev_err(codec->dev, "Second PLL write failed: %d\n", ret); + dev_err(component->dev, "Second PLL write failed: %d\n", ret); goto abort_swap; }
@@ -692,7 +692,7 @@ static int wm0010_boot(struct snd_soc_codec *codec) /* Look for PLL active code from the DSP */ for (i = 0; i < len / 4; i++) { if (*p == 0x0e00ed0f) { - dev_dbg(codec->dev, "PLL packet received\n"); + dev_dbg(component->dev, "PLL packet received\n"); wm0010->pll_running = true; break; } @@ -702,9 +702,9 @@ static int wm0010_boot(struct snd_soc_codec *codec) kfree(img_swap); kfree(out); } else - dev_dbg(codec->dev, "Not enabling DSP PLL."); + dev_dbg(component->dev, "Not enabling DSP PLL.");
- ret = wm0010_firmware_load("wm0010.dfw", codec); + ret = wm0010_firmware_load("wm0010.dfw", component);
if (ret != 0) goto abort; @@ -723,7 +723,7 @@ static int wm0010_boot(struct snd_soc_codec *codec) kfree(out); abort: /* Put the chip back into reset */ - wm0010_halt(codec); + wm0010_halt(component); mutex_unlock(&wm0010->lock); return ret;
@@ -735,22 +735,22 @@ static int wm0010_boot(struct snd_soc_codec *codec) return ret; }
-static int wm0010_set_bias_level(struct snd_soc_codec *codec, +static int wm0010_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { - struct wm0010_priv *wm0010 = snd_soc_codec_get_drvdata(codec); + struct wm0010_priv *wm0010 = snd_soc_component_get_drvdata(component);
switch (level) { case SND_SOC_BIAS_ON: - if (snd_soc_codec_get_bias_level(codec) == SND_SOC_BIAS_PREPARE) - wm0010_boot(codec); + if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_PREPARE) + wm0010_boot(component); break; case SND_SOC_BIAS_PREPARE: break; case SND_SOC_BIAS_STANDBY: - if (snd_soc_codec_get_bias_level(codec) == SND_SOC_BIAS_PREPARE) { + if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_PREPARE) { mutex_lock(&wm0010->lock); - wm0010_halt(codec); + wm0010_halt(component); mutex_unlock(&wm0010->lock); } break; @@ -761,10 +761,10 @@ static int wm0010_set_bias_level(struct snd_soc_codec *codec, return 0; }
-static int wm0010_set_sysclk(struct snd_soc_codec *codec, int source, +static int wm0010_set_sysclk(struct snd_soc_component *component, int source, int clk_id, unsigned int freq, int dir) { - struct wm0010_priv *wm0010 = snd_soc_codec_get_drvdata(codec); + struct wm0010_priv *wm0010 = snd_soc_component_get_drvdata(component); unsigned int i;
wm0010->sysclk = freq; @@ -783,20 +783,19 @@ static int wm0010_set_sysclk(struct snd_soc_codec *codec, int source, return 0; }
-static int wm0010_probe(struct snd_soc_codec *codec); - -static const struct snd_soc_codec_driver soc_codec_dev_wm0010 = { - .probe = wm0010_probe, - .set_bias_level = wm0010_set_bias_level, - .set_sysclk = wm0010_set_sysclk, - .idle_bias_off = true, - - .component_driver = { - .dapm_widgets = wm0010_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(wm0010_dapm_widgets), - .dapm_routes = wm0010_dapm_routes, - .num_dapm_routes = ARRAY_SIZE(wm0010_dapm_routes), - }, +static int wm0010_probe(struct snd_soc_component *component); + +static const struct snd_soc_component_driver soc_component_dev_wm0010 = { + .probe = wm0010_probe, + .set_bias_level = wm0010_set_bias_level, + .set_sysclk = wm0010_set_sysclk, + .dapm_widgets = wm0010_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(wm0010_dapm_widgets), + .dapm_routes = wm0010_dapm_routes, + .num_dapm_routes = ARRAY_SIZE(wm0010_dapm_routes), + .pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, };
#define WM0010_RATES (SNDRV_PCM_RATE_44100 | SNDRV_PCM_RATE_48000) @@ -860,11 +859,11 @@ static irqreturn_t wm0010_irq(int irq, void *data) return IRQ_NONE; }
-static int wm0010_probe(struct snd_soc_codec *codec) +static int wm0010_probe(struct snd_soc_component *component) { - struct wm0010_priv *wm0010 = snd_soc_codec_get_drvdata(codec); + struct wm0010_priv *wm0010 = snd_soc_component_get_drvdata(component);
- wm0010->codec = codec; + wm0010->component = component;
return 0; } @@ -967,8 +966,8 @@ static int wm0010_spi_probe(struct spi_device *spi) else wm0010->board_max_spi_speed = 0;
- ret = snd_soc_register_codec(&spi->dev, - &soc_codec_dev_wm0010, wm0010_dai, + ret = devm_snd_soc_register_component(&spi->dev, + &soc_component_dev_wm0010, wm0010_dai, ARRAY_SIZE(wm0010_dai)); if (ret < 0) return ret; @@ -980,8 +979,6 @@ static int wm0010_spi_remove(struct spi_device *spi) { struct wm0010_priv *wm0010 = spi_get_drvdata(spi);
- snd_soc_unregister_codec(&spi->dev); - gpio_set_value_cansleep(wm0010->gpio_reset, wm0010->gpio_reset_value);
On Fri, Jan 12, 2018 at 01:08:19AM +0000, Kuninori Morimoto wrote:
From: Kuninori Morimoto kuninori.morimoto.gx@renesas.com
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 -> .pmdown_time = 1
-> .endianness = 1
-> .non_legacy_dai_naming = 1
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com
Acked-by: Charles Keepax ckeepax@opensource.cirrus.com
Thanks, Charles
From: Kuninori Morimoto kuninori.morimoto.gx@renesas.com
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 -> .pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com --- sound/soc/codecs/wm2000.c | 78 ++++++++++++++++++++++------------------------- 1 file changed, 36 insertions(+), 42 deletions(-)
diff --git a/sound/soc/codecs/wm2000.c b/sound/soc/codecs/wm2000.c index abfa052..1a8f137 100644 --- a/sound/soc/codecs/wm2000.c +++ b/sound/soc/codecs/wm2000.c @@ -607,8 +607,8 @@ static int wm2000_anc_set_mode(struct wm2000_priv *wm2000) static int wm2000_anc_mode_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct wm2000_priv *wm2000 = dev_get_drvdata(codec->dev); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct wm2000_priv *wm2000 = dev_get_drvdata(component->dev);
ucontrol->value.integer.value[0] = wm2000->anc_active;
@@ -618,8 +618,8 @@ static int wm2000_anc_mode_get(struct snd_kcontrol *kcontrol, static int wm2000_anc_mode_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct wm2000_priv *wm2000 = dev_get_drvdata(codec->dev); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct wm2000_priv *wm2000 = dev_get_drvdata(component->dev); unsigned int anc_active = ucontrol->value.integer.value[0]; int ret;
@@ -640,8 +640,8 @@ static int wm2000_anc_mode_put(struct snd_kcontrol *kcontrol, static int wm2000_speaker_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct wm2000_priv *wm2000 = dev_get_drvdata(codec->dev); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct wm2000_priv *wm2000 = dev_get_drvdata(component->dev);
ucontrol->value.integer.value[0] = wm2000->spk_ena;
@@ -651,8 +651,8 @@ static int wm2000_speaker_get(struct snd_kcontrol *kcontrol, static int wm2000_speaker_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct wm2000_priv *wm2000 = dev_get_drvdata(codec->dev); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct wm2000_priv *wm2000 = dev_get_drvdata(component->dev); unsigned int val = ucontrol->value.integer.value[0]; int ret;
@@ -683,8 +683,8 @@ static int wm2000_speaker_put(struct snd_kcontrol *kcontrol, static int wm2000_anc_power_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); - struct wm2000_priv *wm2000 = dev_get_drvdata(codec->dev); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); + struct wm2000_priv *wm2000 = dev_get_drvdata(component->dev); int ret;
mutex_lock(&wm2000->lock); @@ -724,16 +724,16 @@ static int wm2000_anc_power_event(struct snd_soc_dapm_widget *w, };
#ifdef CONFIG_PM -static int wm2000_suspend(struct snd_soc_codec *codec) +static int wm2000_suspend(struct snd_soc_component *component) { - struct wm2000_priv *wm2000 = dev_get_drvdata(codec->dev); + struct wm2000_priv *wm2000 = dev_get_drvdata(component->dev);
return wm2000_anc_transition(wm2000, ANC_OFF); }
-static int wm2000_resume(struct snd_soc_codec *codec) +static int wm2000_resume(struct snd_soc_component *component) { - struct wm2000_priv *wm2000 = dev_get_drvdata(codec->dev); + struct wm2000_priv *wm2000 = dev_get_drvdata(component->dev);
return wm2000_anc_set_mode(wm2000); } @@ -782,9 +782,9 @@ static bool wm2000_readable_reg(struct device *dev, unsigned int reg) .readable_reg = wm2000_readable_reg, };
-static int wm2000_probe(struct snd_soc_codec *codec) +static int wm2000_probe(struct snd_soc_component *component) { - struct wm2000_priv *wm2000 = dev_get_drvdata(codec->dev); + struct wm2000_priv *wm2000 = dev_get_drvdata(component->dev);
/* This will trigger a transition to standby mode by default */ wm2000_anc_set_mode(wm2000); @@ -792,27 +792,28 @@ static int wm2000_probe(struct snd_soc_codec *codec) return 0; }
-static int wm2000_remove(struct snd_soc_codec *codec) +static void wm2000_remove(struct snd_soc_component *component) { - struct wm2000_priv *wm2000 = dev_get_drvdata(codec->dev); + struct wm2000_priv *wm2000 = dev_get_drvdata(component->dev);
- return wm2000_anc_transition(wm2000, ANC_OFF); + wm2000_anc_transition(wm2000, ANC_OFF); }
-static const struct snd_soc_codec_driver soc_codec_dev_wm2000 = { - .probe = wm2000_probe, - .remove = wm2000_remove, - .suspend = wm2000_suspend, - .resume = wm2000_resume, - - .component_driver = { - .controls = wm2000_controls, - .num_controls = ARRAY_SIZE(wm2000_controls), - .dapm_widgets = wm2000_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(wm2000_dapm_widgets), - .dapm_routes = wm2000_audio_map, - .num_dapm_routes = ARRAY_SIZE(wm2000_audio_map), - }, +static const struct snd_soc_component_driver soc_component_dev_wm2000 = { + .probe = wm2000_probe, + .remove = wm2000_remove, + .suspend = wm2000_suspend, + .resume = wm2000_resume, + .controls = wm2000_controls, + .num_controls = ARRAY_SIZE(wm2000_controls), + .dapm_widgets = wm2000_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(wm2000_dapm_widgets), + .dapm_routes = wm2000_audio_map, + .num_dapm_routes = ARRAY_SIZE(wm2000_audio_map), + .idle_bias_on = 1, + .pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, };
static int wm2000_i2c_probe(struct i2c_client *i2c, @@ -916,7 +917,8 @@ static int wm2000_i2c_probe(struct i2c_client *i2c,
wm2000_reset(wm2000);
- ret = snd_soc_register_codec(&i2c->dev, &soc_codec_dev_wm2000, NULL, 0); + ret = devm_snd_soc_register_component(&i2c->dev, + &soc_component_dev_wm2000, NULL, 0);
err_supplies: regulator_bulk_disable(WM2000_NUM_SUPPLIES, wm2000->supplies); @@ -926,13 +928,6 @@ static int wm2000_i2c_probe(struct i2c_client *i2c, return ret; }
-static int wm2000_i2c_remove(struct i2c_client *i2c) -{ - snd_soc_unregister_codec(&i2c->dev); - - return 0; -} - static const struct i2c_device_id wm2000_i2c_id[] = { { "wm2000", 0 }, { } @@ -944,7 +939,6 @@ static int wm2000_i2c_remove(struct i2c_client *i2c) .name = "wm2000", }, .probe = wm2000_i2c_probe, - .remove = wm2000_i2c_remove, .id_table = wm2000_i2c_id, };
On Fri, Jan 12, 2018 at 01:08:42AM +0000, Kuninori Morimoto wrote:
From: Kuninori Morimoto kuninori.morimoto.gx@renesas.com
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 -> .pmdown_time = 1
-> .endianness = 1
-> .non_legacy_dai_naming = 1
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com
Acked-by: Charles Keepax ckeepax@opensource.cirrus.com
Thanks, Charles
From: Kuninori Morimoto kuninori.morimoto.gx@renesas.com
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 = 1 -> .pmdown_time = 0 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com --- sound/soc/codecs/wm2200.c | 157 ++++++++++++++++++++++------------------------ 1 file changed, 76 insertions(+), 81 deletions(-)
diff --git a/sound/soc/codecs/wm2200.c b/sound/soc/codecs/wm2200.c index 5c2f572..d5f4bbf 100644 --- a/sound/soc/codecs/wm2200.c +++ b/sound/soc/codecs/wm2200.c @@ -87,7 +87,7 @@ struct wm2200_priv { struct wm_adsp dsp[2]; struct regmap *regmap; struct device *dev; - struct snd_soc_codec *codec; + struct snd_soc_component *component; struct wm2200_pdata pdata; struct regulator_bulk_data core_supplies[WM2200_NUM_CORE_SUPPLIES];
@@ -1550,14 +1550,14 @@ static SOC_ENUM_SINGLE_DECL(wm2200_aec_loopback, WM2200_MIXER_ROUTES("LHPF2", "LHPF2"), };
-static int wm2200_probe(struct snd_soc_codec *codec) +static int wm2200_probe(struct snd_soc_component *component) { - struct wm2200_priv *wm2200 = snd_soc_codec_get_drvdata(codec); + struct wm2200_priv *wm2200 = snd_soc_component_get_drvdata(component); int ret;
- wm2200->codec = codec; + wm2200->component = component;
- ret = snd_soc_add_codec_controls(codec, wm_adsp_fw_controls, 2); + ret = snd_soc_add_component_controls(component, wm_adsp_fw_controls, 2); if (ret != 0) return ret;
@@ -1566,7 +1566,7 @@ static int wm2200_probe(struct snd_soc_codec *codec)
static int wm2200_set_fmt(struct snd_soc_dai *dai, unsigned int fmt) { - struct snd_soc_codec *codec = dai->codec; + struct snd_soc_component *component = dai->component; int lrclk, bclk, fmt_val;
lrclk = 0; @@ -1580,7 +1580,7 @@ static int wm2200_set_fmt(struct snd_soc_dai *dai, unsigned int fmt) fmt_val = 2; break; default: - dev_err(codec->dev, "Unsupported DAI format %d\n", + dev_err(component->dev, "Unsupported DAI format %d\n", fmt & SND_SOC_DAIFMT_FORMAT_MASK); return -EINVAL; } @@ -1599,7 +1599,7 @@ static int wm2200_set_fmt(struct snd_soc_dai *dai, unsigned int fmt) bclk |= WM2200_AIF1_BCLK_MSTR; break; default: - dev_err(codec->dev, "Unsupported master mode %d\n", + dev_err(component->dev, "Unsupported master mode %d\n", fmt & SND_SOC_DAIFMT_MASTER_MASK); return -EINVAL; } @@ -1621,15 +1621,15 @@ static int wm2200_set_fmt(struct snd_soc_dai *dai, unsigned int fmt) return -EINVAL; }
- snd_soc_update_bits(codec, WM2200_AUDIO_IF_1_1, WM2200_AIF1_BCLK_MSTR | + snd_soc_component_update_bits(component, WM2200_AUDIO_IF_1_1, WM2200_AIF1_BCLK_MSTR | WM2200_AIF1_BCLK_INV, bclk); - snd_soc_update_bits(codec, WM2200_AUDIO_IF_1_2, + snd_soc_component_update_bits(component, WM2200_AUDIO_IF_1_2, WM2200_AIF1TX_LRCLK_MSTR | WM2200_AIF1TX_LRCLK_INV, lrclk); - snd_soc_update_bits(codec, WM2200_AUDIO_IF_1_3, + snd_soc_component_update_bits(component, WM2200_AUDIO_IF_1_3, WM2200_AIF1TX_LRCLK_MSTR | WM2200_AIF1TX_LRCLK_INV, lrclk); - snd_soc_update_bits(codec, WM2200_AUDIO_IF_1_5, + snd_soc_component_update_bits(component, WM2200_AUDIO_IF_1_5, WM2200_AIF1_FMT_MASK, fmt_val);
return 0; @@ -1698,8 +1698,8 @@ static int wm2200_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; - struct wm2200_priv *wm2200 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct wm2200_priv *wm2200 = snd_soc_component_get_drvdata(component); int i, bclk, lrclk, wl, fl, sr_code; int *bclk_rates;
@@ -1711,7 +1711,7 @@ static int wm2200_hw_params(struct snd_pcm_substream *substream, if (fl < 0) return fl;
- dev_dbg(codec->dev, "Word length %d bits, frame length %d bits\n", + dev_dbg(component->dev, "Word length %d bits, frame length %d bits\n", wl, fl);
/* Target BCLK rate */ @@ -1720,7 +1720,7 @@ static int wm2200_hw_params(struct snd_pcm_substream *substream, return bclk;
if (!wm2200->sysclk) { - dev_err(codec->dev, "SYSCLK has no rate set\n"); + dev_err(component->dev, "SYSCLK has no rate set\n"); return -EINVAL; }
@@ -1728,13 +1728,13 @@ static int wm2200_hw_params(struct snd_pcm_substream *substream, if (wm2200_sr_code[i] == params_rate(params)) break; if (i == ARRAY_SIZE(wm2200_sr_code)) { - dev_err(codec->dev, "Unsupported sample rate: %dHz\n", + dev_err(component->dev, "Unsupported sample rate: %dHz\n", params_rate(params)); return -EINVAL; } sr_code = i;
- dev_dbg(codec->dev, "Target BCLK is %dHz, using %dHz SYSCLK\n", + dev_dbg(component->dev, "Target BCLK is %dHz, using %dHz SYSCLK\n", bclk, wm2200->sysclk);
if (wm2200->sysclk % 4000) @@ -1746,38 +1746,38 @@ static int wm2200_hw_params(struct snd_pcm_substream *substream, if (bclk_rates[i] >= bclk && (bclk_rates[i] % bclk == 0)) break; if (i == WM2200_NUM_BCLK_RATES) { - dev_err(codec->dev, + dev_err(component->dev, "No valid BCLK for %dHz found from %dHz SYSCLK\n", bclk, wm2200->sysclk); return -EINVAL; }
bclk = i; - dev_dbg(codec->dev, "Setting %dHz BCLK\n", bclk_rates[bclk]); - snd_soc_update_bits(codec, WM2200_AUDIO_IF_1_1, + dev_dbg(component->dev, "Setting %dHz BCLK\n", bclk_rates[bclk]); + snd_soc_component_update_bits(component, WM2200_AUDIO_IF_1_1, WM2200_AIF1_BCLK_DIV_MASK, bclk);
lrclk = bclk_rates[bclk] / params_rate(params); - dev_dbg(codec->dev, "Setting %dHz LRCLK\n", bclk_rates[bclk] / lrclk); + dev_dbg(component->dev, "Setting %dHz LRCLK\n", bclk_rates[bclk] / lrclk); if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK || wm2200->symmetric_rates) - snd_soc_update_bits(codec, WM2200_AUDIO_IF_1_7, + snd_soc_component_update_bits(component, WM2200_AUDIO_IF_1_7, WM2200_AIF1RX_BCPF_MASK, lrclk); else - snd_soc_update_bits(codec, WM2200_AUDIO_IF_1_6, + snd_soc_component_update_bits(component, WM2200_AUDIO_IF_1_6, WM2200_AIF1TX_BCPF_MASK, lrclk);
i = (wl << WM2200_AIF1TX_WL_SHIFT) | wl; if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) - snd_soc_update_bits(codec, WM2200_AUDIO_IF_1_9, + snd_soc_component_update_bits(component, WM2200_AUDIO_IF_1_9, WM2200_AIF1RX_WL_MASK | WM2200_AIF1RX_SLOT_LEN_MASK, i); else - snd_soc_update_bits(codec, WM2200_AUDIO_IF_1_8, + snd_soc_component_update_bits(component, WM2200_AUDIO_IF_1_8, WM2200_AIF1TX_WL_MASK | WM2200_AIF1TX_SLOT_LEN_MASK, i);
- snd_soc_update_bits(codec, WM2200_CLOCKING_4, + snd_soc_component_update_bits(component, WM2200_CLOCKING_4, WM2200_SAMPLE_RATE_1_MASK, sr_code);
return 0; @@ -1788,10 +1788,10 @@ static int wm2200_hw_params(struct snd_pcm_substream *substream, .hw_params = wm2200_hw_params, };
-static int wm2200_set_sysclk(struct snd_soc_codec *codec, int clk_id, +static int wm2200_set_sysclk(struct snd_soc_component *component, int clk_id, int source, unsigned int freq, int dir) { - struct wm2200_priv *wm2200 = snd_soc_codec_get_drvdata(codec); + struct wm2200_priv *wm2200 = snd_soc_component_get_drvdata(component); int fval;
switch (clk_id) { @@ -1799,7 +1799,7 @@ static int wm2200_set_sysclk(struct snd_soc_codec *codec, int clk_id, break;
default: - dev_err(codec->dev, "Unknown clock %d\n", clk_id); + dev_err(component->dev, "Unknown clock %d\n", clk_id); return -EINVAL; }
@@ -1810,7 +1810,7 @@ static int wm2200_set_sysclk(struct snd_soc_codec *codec, int clk_id, case WM2200_CLKSRC_BCLK1: break; default: - dev_err(codec->dev, "Invalid source %d\n", source); + dev_err(component->dev, "Invalid source %d\n", source); return -EINVAL; }
@@ -1820,7 +1820,7 @@ static int wm2200_set_sysclk(struct snd_soc_codec *codec, int clk_id, fval = 2; break; default: - dev_err(codec->dev, "Invalid clock rate: %d\n", freq); + dev_err(component->dev, "Invalid clock rate: %d\n", freq); return -EINVAL; }
@@ -1828,7 +1828,7 @@ static int wm2200_set_sysclk(struct snd_soc_codec *codec, int clk_id, * match. */
- snd_soc_update_bits(codec, WM2200_CLOCKING_3, WM2200_SYSCLK_FREQ_MASK | + snd_soc_component_update_bits(component, WM2200_CLOCKING_3, WM2200_SYSCLK_FREQ_MASK | WM2200_SYSCLK_SRC_MASK, fval << WM2200_SYSCLK_FREQ_SHIFT | source);
@@ -1936,23 +1936,23 @@ static int fll_factors(struct _fll_div *fll_div, unsigned int Fref, return 0; }
-static int wm2200_set_fll(struct snd_soc_codec *codec, int fll_id, int source, +static int wm2200_set_fll(struct snd_soc_component *component, int fll_id, int source, unsigned int Fref, unsigned int Fout) { - struct i2c_client *i2c = to_i2c_client(codec->dev); - struct wm2200_priv *wm2200 = snd_soc_codec_get_drvdata(codec); + struct i2c_client *i2c = to_i2c_client(component->dev); + struct wm2200_priv *wm2200 = snd_soc_component_get_drvdata(component); struct _fll_div factors; int ret, i, timeout; unsigned long time_left;
if (!Fout) { - dev_dbg(codec->dev, "FLL disabled"); + dev_dbg(component->dev, "FLL disabled");
if (wm2200->fll_fout) - pm_runtime_put(codec->dev); + pm_runtime_put(component->dev);
wm2200->fll_fout = 0; - snd_soc_update_bits(codec, WM2200_FLL_CONTROL_1, + snd_soc_component_update_bits(component, WM2200_FLL_CONTROL_1, WM2200_FLL_ENA, 0); return 0; } @@ -1963,7 +1963,7 @@ static int wm2200_set_fll(struct snd_soc_codec *codec, int fll_id, int source, case WM2200_FLL_SRC_BCLK: break; default: - dev_err(codec->dev, "Invalid FLL source %d\n", source); + dev_err(component->dev, "Invalid FLL source %d\n", source); return -EINVAL; }
@@ -1972,44 +1972,44 @@ static int wm2200_set_fll(struct snd_soc_codec *codec, int fll_id, int source, return ret;
/* Disable the FLL while we reconfigure */ - snd_soc_update_bits(codec, WM2200_FLL_CONTROL_1, WM2200_FLL_ENA, 0); + snd_soc_component_update_bits(component, WM2200_FLL_CONTROL_1, WM2200_FLL_ENA, 0);
- snd_soc_update_bits(codec, WM2200_FLL_CONTROL_2, + snd_soc_component_update_bits(component, WM2200_FLL_CONTROL_2, WM2200_FLL_OUTDIV_MASK | WM2200_FLL_FRATIO_MASK, (factors.fll_outdiv << WM2200_FLL_OUTDIV_SHIFT) | factors.fll_fratio); if (factors.theta) { - snd_soc_update_bits(codec, WM2200_FLL_CONTROL_3, + snd_soc_component_update_bits(component, WM2200_FLL_CONTROL_3, WM2200_FLL_FRACN_ENA, WM2200_FLL_FRACN_ENA); - snd_soc_update_bits(codec, WM2200_FLL_EFS_2, + snd_soc_component_update_bits(component, WM2200_FLL_EFS_2, WM2200_FLL_EFS_ENA, WM2200_FLL_EFS_ENA); } else { - snd_soc_update_bits(codec, WM2200_FLL_CONTROL_3, + snd_soc_component_update_bits(component, WM2200_FLL_CONTROL_3, WM2200_FLL_FRACN_ENA, 0); - snd_soc_update_bits(codec, WM2200_FLL_EFS_2, + snd_soc_component_update_bits(component, WM2200_FLL_EFS_2, WM2200_FLL_EFS_ENA, 0); }
- snd_soc_update_bits(codec, WM2200_FLL_CONTROL_4, WM2200_FLL_THETA_MASK, + snd_soc_component_update_bits(component, WM2200_FLL_CONTROL_4, WM2200_FLL_THETA_MASK, factors.theta); - snd_soc_update_bits(codec, WM2200_FLL_CONTROL_6, WM2200_FLL_N_MASK, + snd_soc_component_update_bits(component, WM2200_FLL_CONTROL_6, WM2200_FLL_N_MASK, factors.n); - snd_soc_update_bits(codec, WM2200_FLL_CONTROL_7, + snd_soc_component_update_bits(component, WM2200_FLL_CONTROL_7, WM2200_FLL_CLK_REF_DIV_MASK | WM2200_FLL_CLK_REF_SRC_MASK, (factors.fll_refclk_div << WM2200_FLL_CLK_REF_DIV_SHIFT) | source); - snd_soc_update_bits(codec, WM2200_FLL_EFS_1, + snd_soc_component_update_bits(component, WM2200_FLL_EFS_1, WM2200_FLL_LAMBDA_MASK, factors.lambda);
/* Clear any pending completions */ try_wait_for_completion(&wm2200->fll_lock);
- pm_runtime_get_sync(codec->dev); + pm_runtime_get_sync(component->dev);
- snd_soc_update_bits(codec, WM2200_FLL_CONTROL_1, + snd_soc_component_update_bits(component, WM2200_FLL_CONTROL_1, WM2200_FLL_ENA, WM2200_FLL_ENA);
if (i2c->irq) @@ -2017,7 +2017,7 @@ static int wm2200_set_fll(struct snd_soc_codec *codec, int fll_id, int source, else timeout = 50;
- snd_soc_update_bits(codec, WM2200_CLOCKING_3, WM2200_SYSCLK_ENA, + snd_soc_component_update_bits(component, WM2200_CLOCKING_3, WM2200_SYSCLK_ENA, WM2200_SYSCLK_ENA);
/* Poll for the lock; will use the interrupt to exit quickly */ @@ -2032,10 +2032,10 @@ static int wm2200_set_fll(struct snd_soc_codec *codec, int fll_id, int source, msleep(1); }
- ret = snd_soc_read(codec, + ret = snd_soc_component_read32(component, WM2200_INTERRUPT_RAW_STATUS_2); if (ret < 0) { - dev_err(codec->dev, + dev_err(component->dev, "Failed to read FLL status: %d\n", ret); continue; @@ -2044,8 +2044,8 @@ static int wm2200_set_fll(struct snd_soc_codec *codec, int fll_id, int source, break; } if (i == timeout) { - dev_err(codec->dev, "FLL lock timed out\n"); - pm_runtime_put(codec->dev); + dev_err(component->dev, "FLL lock timed out\n"); + pm_runtime_put(component->dev); return -ETIMEDOUT; }
@@ -2053,29 +2053,29 @@ static int wm2200_set_fll(struct snd_soc_codec *codec, int fll_id, int source, wm2200->fll_fref = Fref; wm2200->fll_fout = Fout;
- dev_dbg(codec->dev, "FLL running %dHz->%dHz\n", Fref, Fout); + dev_dbg(component->dev, "FLL running %dHz->%dHz\n", Fref, Fout);
return 0; }
static int wm2200_dai_probe(struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; - struct wm2200_priv *wm2200 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct wm2200_priv *wm2200 = snd_soc_component_get_drvdata(component); unsigned int val = 0; int ret;
- ret = snd_soc_read(codec, WM2200_GPIO_CTRL_1); + ret = snd_soc_component_read32(component, WM2200_GPIO_CTRL_1); if (ret >= 0) { if ((ret & WM2200_GP1_FN_MASK) != 0) { wm2200->symmetric_rates = true; val = WM2200_AIF1TX_LRCLK_SRC; } } else { - dev_err(codec->dev, "Failed to read GPIO 1 config: %d\n", ret); + dev_err(component->dev, "Failed to read GPIO 1 config: %d\n", ret); }
- snd_soc_update_bits(codec, WM2200_AUDIO_IF_1_2, + snd_soc_component_update_bits(component, WM2200_AUDIO_IF_1_2, WM2200_AIF1TX_LRCLK_SRC, val);
return 0; @@ -2106,22 +2106,18 @@ static int wm2200_dai_probe(struct snd_soc_dai *dai) .ops = &wm2200_dai_ops, };
-static const struct snd_soc_codec_driver soc_codec_wm2200 = { - .probe = wm2200_probe, - - .idle_bias_off = true, - .ignore_pmdown_time = true, - .set_sysclk = wm2200_set_sysclk, - .set_pll = wm2200_set_fll, - - .component_driver = { - .controls = wm2200_snd_controls, - .num_controls = ARRAY_SIZE(wm2200_snd_controls), - .dapm_widgets = wm2200_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(wm2200_dapm_widgets), - .dapm_routes = wm2200_dapm_routes, - .num_dapm_routes = ARRAY_SIZE(wm2200_dapm_routes), - }, +static const struct snd_soc_component_driver soc_component_wm2200 = { + .probe = wm2200_probe, + .set_sysclk = wm2200_set_sysclk, + .set_pll = wm2200_set_fll, + .controls = wm2200_snd_controls, + .num_controls = ARRAY_SIZE(wm2200_snd_controls), + .dapm_widgets = wm2200_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(wm2200_dapm_widgets), + .dapm_routes = wm2200_dapm_routes, + .num_dapm_routes = ARRAY_SIZE(wm2200_dapm_routes), + .endianness = 1, + .non_legacy_dai_naming = 1, };
static irqreturn_t wm2200_irq(int irq, void *data) @@ -2408,7 +2404,7 @@ static int wm2200_i2c_probe(struct i2c_client *i2c, pm_runtime_enable(&i2c->dev); pm_request_idle(&i2c->dev);
- ret = snd_soc_register_codec(&i2c->dev, &soc_codec_wm2200, + ret = devm_snd_soc_register_component(&i2c->dev, &soc_component_wm2200, &wm2200_dai, 1); if (ret != 0) { dev_err(&i2c->dev, "Failed to register CODEC: %d\n", ret); @@ -2435,7 +2431,6 @@ static int wm2200_i2c_remove(struct i2c_client *i2c) { struct wm2200_priv *wm2200 = i2c_get_clientdata(i2c);
- snd_soc_unregister_codec(&i2c->dev); if (i2c->irq) free_irq(i2c->irq, wm2200); if (wm2200->pdata.reset)
The patch
ASoC: wm2200: replace codec to component
has been applied to the asoc tree at
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git
All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying to this mail.
Thanks, Mark
From 908b530863d4ae570e8005056f408ecae4862494 Mon Sep 17 00:00:00 2001
From: Kuninori Morimoto kuninori.morimoto.gx@renesas.com Date: Mon, 29 Jan 2018 02:59:19 +0000 Subject: [PATCH] ASoC: wm2200: 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 = 1 -> .use_pmdown_time = 0 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com Acked-by: Charles Keepax ckeepax@opensource.cirrus.com Signed-off-by: Mark Brown broonie@kernel.org --- sound/soc/codecs/wm2200.c | 157 ++++++++++++++++++++++------------------------ 1 file changed, 76 insertions(+), 81 deletions(-)
diff --git a/sound/soc/codecs/wm2200.c b/sound/soc/codecs/wm2200.c index 5c2f5727244d..d5f4bbf27182 100644 --- a/sound/soc/codecs/wm2200.c +++ b/sound/soc/codecs/wm2200.c @@ -87,7 +87,7 @@ struct wm2200_priv { struct wm_adsp dsp[2]; struct regmap *regmap; struct device *dev; - struct snd_soc_codec *codec; + struct snd_soc_component *component; struct wm2200_pdata pdata; struct regulator_bulk_data core_supplies[WM2200_NUM_CORE_SUPPLIES];
@@ -1550,14 +1550,14 @@ static const struct snd_soc_dapm_route wm2200_dapm_routes[] = { WM2200_MIXER_ROUTES("LHPF2", "LHPF2"), };
-static int wm2200_probe(struct snd_soc_codec *codec) +static int wm2200_probe(struct snd_soc_component *component) { - struct wm2200_priv *wm2200 = snd_soc_codec_get_drvdata(codec); + struct wm2200_priv *wm2200 = snd_soc_component_get_drvdata(component); int ret;
- wm2200->codec = codec; + wm2200->component = component;
- ret = snd_soc_add_codec_controls(codec, wm_adsp_fw_controls, 2); + ret = snd_soc_add_component_controls(component, wm_adsp_fw_controls, 2); if (ret != 0) return ret;
@@ -1566,7 +1566,7 @@ static int wm2200_probe(struct snd_soc_codec *codec)
static int wm2200_set_fmt(struct snd_soc_dai *dai, unsigned int fmt) { - struct snd_soc_codec *codec = dai->codec; + struct snd_soc_component *component = dai->component; int lrclk, bclk, fmt_val;
lrclk = 0; @@ -1580,7 +1580,7 @@ static int wm2200_set_fmt(struct snd_soc_dai *dai, unsigned int fmt) fmt_val = 2; break; default: - dev_err(codec->dev, "Unsupported DAI format %d\n", + dev_err(component->dev, "Unsupported DAI format %d\n", fmt & SND_SOC_DAIFMT_FORMAT_MASK); return -EINVAL; } @@ -1599,7 +1599,7 @@ static int wm2200_set_fmt(struct snd_soc_dai *dai, unsigned int fmt) bclk |= WM2200_AIF1_BCLK_MSTR; break; default: - dev_err(codec->dev, "Unsupported master mode %d\n", + dev_err(component->dev, "Unsupported master mode %d\n", fmt & SND_SOC_DAIFMT_MASTER_MASK); return -EINVAL; } @@ -1621,15 +1621,15 @@ static int wm2200_set_fmt(struct snd_soc_dai *dai, unsigned int fmt) return -EINVAL; }
- snd_soc_update_bits(codec, WM2200_AUDIO_IF_1_1, WM2200_AIF1_BCLK_MSTR | + snd_soc_component_update_bits(component, WM2200_AUDIO_IF_1_1, WM2200_AIF1_BCLK_MSTR | WM2200_AIF1_BCLK_INV, bclk); - snd_soc_update_bits(codec, WM2200_AUDIO_IF_1_2, + snd_soc_component_update_bits(component, WM2200_AUDIO_IF_1_2, WM2200_AIF1TX_LRCLK_MSTR | WM2200_AIF1TX_LRCLK_INV, lrclk); - snd_soc_update_bits(codec, WM2200_AUDIO_IF_1_3, + snd_soc_component_update_bits(component, WM2200_AUDIO_IF_1_3, WM2200_AIF1TX_LRCLK_MSTR | WM2200_AIF1TX_LRCLK_INV, lrclk); - snd_soc_update_bits(codec, WM2200_AUDIO_IF_1_5, + snd_soc_component_update_bits(component, WM2200_AUDIO_IF_1_5, WM2200_AIF1_FMT_MASK, fmt_val);
return 0; @@ -1698,8 +1698,8 @@ static int wm2200_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; - struct wm2200_priv *wm2200 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct wm2200_priv *wm2200 = snd_soc_component_get_drvdata(component); int i, bclk, lrclk, wl, fl, sr_code; int *bclk_rates;
@@ -1711,7 +1711,7 @@ static int wm2200_hw_params(struct snd_pcm_substream *substream, if (fl < 0) return fl;
- dev_dbg(codec->dev, "Word length %d bits, frame length %d bits\n", + dev_dbg(component->dev, "Word length %d bits, frame length %d bits\n", wl, fl);
/* Target BCLK rate */ @@ -1720,7 +1720,7 @@ static int wm2200_hw_params(struct snd_pcm_substream *substream, return bclk;
if (!wm2200->sysclk) { - dev_err(codec->dev, "SYSCLK has no rate set\n"); + dev_err(component->dev, "SYSCLK has no rate set\n"); return -EINVAL; }
@@ -1728,13 +1728,13 @@ static int wm2200_hw_params(struct snd_pcm_substream *substream, if (wm2200_sr_code[i] == params_rate(params)) break; if (i == ARRAY_SIZE(wm2200_sr_code)) { - dev_err(codec->dev, "Unsupported sample rate: %dHz\n", + dev_err(component->dev, "Unsupported sample rate: %dHz\n", params_rate(params)); return -EINVAL; } sr_code = i;
- dev_dbg(codec->dev, "Target BCLK is %dHz, using %dHz SYSCLK\n", + dev_dbg(component->dev, "Target BCLK is %dHz, using %dHz SYSCLK\n", bclk, wm2200->sysclk);
if (wm2200->sysclk % 4000) @@ -1746,38 +1746,38 @@ static int wm2200_hw_params(struct snd_pcm_substream *substream, if (bclk_rates[i] >= bclk && (bclk_rates[i] % bclk == 0)) break; if (i == WM2200_NUM_BCLK_RATES) { - dev_err(codec->dev, + dev_err(component->dev, "No valid BCLK for %dHz found from %dHz SYSCLK\n", bclk, wm2200->sysclk); return -EINVAL; }
bclk = i; - dev_dbg(codec->dev, "Setting %dHz BCLK\n", bclk_rates[bclk]); - snd_soc_update_bits(codec, WM2200_AUDIO_IF_1_1, + dev_dbg(component->dev, "Setting %dHz BCLK\n", bclk_rates[bclk]); + snd_soc_component_update_bits(component, WM2200_AUDIO_IF_1_1, WM2200_AIF1_BCLK_DIV_MASK, bclk);
lrclk = bclk_rates[bclk] / params_rate(params); - dev_dbg(codec->dev, "Setting %dHz LRCLK\n", bclk_rates[bclk] / lrclk); + dev_dbg(component->dev, "Setting %dHz LRCLK\n", bclk_rates[bclk] / lrclk); if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK || wm2200->symmetric_rates) - snd_soc_update_bits(codec, WM2200_AUDIO_IF_1_7, + snd_soc_component_update_bits(component, WM2200_AUDIO_IF_1_7, WM2200_AIF1RX_BCPF_MASK, lrclk); else - snd_soc_update_bits(codec, WM2200_AUDIO_IF_1_6, + snd_soc_component_update_bits(component, WM2200_AUDIO_IF_1_6, WM2200_AIF1TX_BCPF_MASK, lrclk);
i = (wl << WM2200_AIF1TX_WL_SHIFT) | wl; if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) - snd_soc_update_bits(codec, WM2200_AUDIO_IF_1_9, + snd_soc_component_update_bits(component, WM2200_AUDIO_IF_1_9, WM2200_AIF1RX_WL_MASK | WM2200_AIF1RX_SLOT_LEN_MASK, i); else - snd_soc_update_bits(codec, WM2200_AUDIO_IF_1_8, + snd_soc_component_update_bits(component, WM2200_AUDIO_IF_1_8, WM2200_AIF1TX_WL_MASK | WM2200_AIF1TX_SLOT_LEN_MASK, i);
- snd_soc_update_bits(codec, WM2200_CLOCKING_4, + snd_soc_component_update_bits(component, WM2200_CLOCKING_4, WM2200_SAMPLE_RATE_1_MASK, sr_code);
return 0; @@ -1788,10 +1788,10 @@ static const struct snd_soc_dai_ops wm2200_dai_ops = { .hw_params = wm2200_hw_params, };
-static int wm2200_set_sysclk(struct snd_soc_codec *codec, int clk_id, +static int wm2200_set_sysclk(struct snd_soc_component *component, int clk_id, int source, unsigned int freq, int dir) { - struct wm2200_priv *wm2200 = snd_soc_codec_get_drvdata(codec); + struct wm2200_priv *wm2200 = snd_soc_component_get_drvdata(component); int fval;
switch (clk_id) { @@ -1799,7 +1799,7 @@ static int wm2200_set_sysclk(struct snd_soc_codec *codec, int clk_id, break;
default: - dev_err(codec->dev, "Unknown clock %d\n", clk_id); + dev_err(component->dev, "Unknown clock %d\n", clk_id); return -EINVAL; }
@@ -1810,7 +1810,7 @@ static int wm2200_set_sysclk(struct snd_soc_codec *codec, int clk_id, case WM2200_CLKSRC_BCLK1: break; default: - dev_err(codec->dev, "Invalid source %d\n", source); + dev_err(component->dev, "Invalid source %d\n", source); return -EINVAL; }
@@ -1820,7 +1820,7 @@ static int wm2200_set_sysclk(struct snd_soc_codec *codec, int clk_id, fval = 2; break; default: - dev_err(codec->dev, "Invalid clock rate: %d\n", freq); + dev_err(component->dev, "Invalid clock rate: %d\n", freq); return -EINVAL; }
@@ -1828,7 +1828,7 @@ static int wm2200_set_sysclk(struct snd_soc_codec *codec, int clk_id, * match. */
- snd_soc_update_bits(codec, WM2200_CLOCKING_3, WM2200_SYSCLK_FREQ_MASK | + snd_soc_component_update_bits(component, WM2200_CLOCKING_3, WM2200_SYSCLK_FREQ_MASK | WM2200_SYSCLK_SRC_MASK, fval << WM2200_SYSCLK_FREQ_SHIFT | source);
@@ -1936,23 +1936,23 @@ static int fll_factors(struct _fll_div *fll_div, unsigned int Fref, return 0; }
-static int wm2200_set_fll(struct snd_soc_codec *codec, int fll_id, int source, +static int wm2200_set_fll(struct snd_soc_component *component, int fll_id, int source, unsigned int Fref, unsigned int Fout) { - struct i2c_client *i2c = to_i2c_client(codec->dev); - struct wm2200_priv *wm2200 = snd_soc_codec_get_drvdata(codec); + struct i2c_client *i2c = to_i2c_client(component->dev); + struct wm2200_priv *wm2200 = snd_soc_component_get_drvdata(component); struct _fll_div factors; int ret, i, timeout; unsigned long time_left;
if (!Fout) { - dev_dbg(codec->dev, "FLL disabled"); + dev_dbg(component->dev, "FLL disabled");
if (wm2200->fll_fout) - pm_runtime_put(codec->dev); + pm_runtime_put(component->dev);
wm2200->fll_fout = 0; - snd_soc_update_bits(codec, WM2200_FLL_CONTROL_1, + snd_soc_component_update_bits(component, WM2200_FLL_CONTROL_1, WM2200_FLL_ENA, 0); return 0; } @@ -1963,7 +1963,7 @@ static int wm2200_set_fll(struct snd_soc_codec *codec, int fll_id, int source, case WM2200_FLL_SRC_BCLK: break; default: - dev_err(codec->dev, "Invalid FLL source %d\n", source); + dev_err(component->dev, "Invalid FLL source %d\n", source); return -EINVAL; }
@@ -1972,44 +1972,44 @@ static int wm2200_set_fll(struct snd_soc_codec *codec, int fll_id, int source, return ret;
/* Disable the FLL while we reconfigure */ - snd_soc_update_bits(codec, WM2200_FLL_CONTROL_1, WM2200_FLL_ENA, 0); + snd_soc_component_update_bits(component, WM2200_FLL_CONTROL_1, WM2200_FLL_ENA, 0);
- snd_soc_update_bits(codec, WM2200_FLL_CONTROL_2, + snd_soc_component_update_bits(component, WM2200_FLL_CONTROL_2, WM2200_FLL_OUTDIV_MASK | WM2200_FLL_FRATIO_MASK, (factors.fll_outdiv << WM2200_FLL_OUTDIV_SHIFT) | factors.fll_fratio); if (factors.theta) { - snd_soc_update_bits(codec, WM2200_FLL_CONTROL_3, + snd_soc_component_update_bits(component, WM2200_FLL_CONTROL_3, WM2200_FLL_FRACN_ENA, WM2200_FLL_FRACN_ENA); - snd_soc_update_bits(codec, WM2200_FLL_EFS_2, + snd_soc_component_update_bits(component, WM2200_FLL_EFS_2, WM2200_FLL_EFS_ENA, WM2200_FLL_EFS_ENA); } else { - snd_soc_update_bits(codec, WM2200_FLL_CONTROL_3, + snd_soc_component_update_bits(component, WM2200_FLL_CONTROL_3, WM2200_FLL_FRACN_ENA, 0); - snd_soc_update_bits(codec, WM2200_FLL_EFS_2, + snd_soc_component_update_bits(component, WM2200_FLL_EFS_2, WM2200_FLL_EFS_ENA, 0); }
- snd_soc_update_bits(codec, WM2200_FLL_CONTROL_4, WM2200_FLL_THETA_MASK, + snd_soc_component_update_bits(component, WM2200_FLL_CONTROL_4, WM2200_FLL_THETA_MASK, factors.theta); - snd_soc_update_bits(codec, WM2200_FLL_CONTROL_6, WM2200_FLL_N_MASK, + snd_soc_component_update_bits(component, WM2200_FLL_CONTROL_6, WM2200_FLL_N_MASK, factors.n); - snd_soc_update_bits(codec, WM2200_FLL_CONTROL_7, + snd_soc_component_update_bits(component, WM2200_FLL_CONTROL_7, WM2200_FLL_CLK_REF_DIV_MASK | WM2200_FLL_CLK_REF_SRC_MASK, (factors.fll_refclk_div << WM2200_FLL_CLK_REF_DIV_SHIFT) | source); - snd_soc_update_bits(codec, WM2200_FLL_EFS_1, + snd_soc_component_update_bits(component, WM2200_FLL_EFS_1, WM2200_FLL_LAMBDA_MASK, factors.lambda);
/* Clear any pending completions */ try_wait_for_completion(&wm2200->fll_lock);
- pm_runtime_get_sync(codec->dev); + pm_runtime_get_sync(component->dev);
- snd_soc_update_bits(codec, WM2200_FLL_CONTROL_1, + snd_soc_component_update_bits(component, WM2200_FLL_CONTROL_1, WM2200_FLL_ENA, WM2200_FLL_ENA);
if (i2c->irq) @@ -2017,7 +2017,7 @@ static int wm2200_set_fll(struct snd_soc_codec *codec, int fll_id, int source, else timeout = 50;
- snd_soc_update_bits(codec, WM2200_CLOCKING_3, WM2200_SYSCLK_ENA, + snd_soc_component_update_bits(component, WM2200_CLOCKING_3, WM2200_SYSCLK_ENA, WM2200_SYSCLK_ENA);
/* Poll for the lock; will use the interrupt to exit quickly */ @@ -2032,10 +2032,10 @@ static int wm2200_set_fll(struct snd_soc_codec *codec, int fll_id, int source, msleep(1); }
- ret = snd_soc_read(codec, + ret = snd_soc_component_read32(component, WM2200_INTERRUPT_RAW_STATUS_2); if (ret < 0) { - dev_err(codec->dev, + dev_err(component->dev, "Failed to read FLL status: %d\n", ret); continue; @@ -2044,8 +2044,8 @@ static int wm2200_set_fll(struct snd_soc_codec *codec, int fll_id, int source, break; } if (i == timeout) { - dev_err(codec->dev, "FLL lock timed out\n"); - pm_runtime_put(codec->dev); + dev_err(component->dev, "FLL lock timed out\n"); + pm_runtime_put(component->dev); return -ETIMEDOUT; }
@@ -2053,29 +2053,29 @@ static int wm2200_set_fll(struct snd_soc_codec *codec, int fll_id, int source, wm2200->fll_fref = Fref; wm2200->fll_fout = Fout;
- dev_dbg(codec->dev, "FLL running %dHz->%dHz\n", Fref, Fout); + dev_dbg(component->dev, "FLL running %dHz->%dHz\n", Fref, Fout);
return 0; }
static int wm2200_dai_probe(struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; - struct wm2200_priv *wm2200 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct wm2200_priv *wm2200 = snd_soc_component_get_drvdata(component); unsigned int val = 0; int ret;
- ret = snd_soc_read(codec, WM2200_GPIO_CTRL_1); + ret = snd_soc_component_read32(component, WM2200_GPIO_CTRL_1); if (ret >= 0) { if ((ret & WM2200_GP1_FN_MASK) != 0) { wm2200->symmetric_rates = true; val = WM2200_AIF1TX_LRCLK_SRC; } } else { - dev_err(codec->dev, "Failed to read GPIO 1 config: %d\n", ret); + dev_err(component->dev, "Failed to read GPIO 1 config: %d\n", ret); }
- snd_soc_update_bits(codec, WM2200_AUDIO_IF_1_2, + snd_soc_component_update_bits(component, WM2200_AUDIO_IF_1_2, WM2200_AIF1TX_LRCLK_SRC, val);
return 0; @@ -2106,22 +2106,18 @@ static struct snd_soc_dai_driver wm2200_dai = { .ops = &wm2200_dai_ops, };
-static const struct snd_soc_codec_driver soc_codec_wm2200 = { - .probe = wm2200_probe, - - .idle_bias_off = true, - .ignore_pmdown_time = true, - .set_sysclk = wm2200_set_sysclk, - .set_pll = wm2200_set_fll, - - .component_driver = { - .controls = wm2200_snd_controls, - .num_controls = ARRAY_SIZE(wm2200_snd_controls), - .dapm_widgets = wm2200_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(wm2200_dapm_widgets), - .dapm_routes = wm2200_dapm_routes, - .num_dapm_routes = ARRAY_SIZE(wm2200_dapm_routes), - }, +static const struct snd_soc_component_driver soc_component_wm2200 = { + .probe = wm2200_probe, + .set_sysclk = wm2200_set_sysclk, + .set_pll = wm2200_set_fll, + .controls = wm2200_snd_controls, + .num_controls = ARRAY_SIZE(wm2200_snd_controls), + .dapm_widgets = wm2200_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(wm2200_dapm_widgets), + .dapm_routes = wm2200_dapm_routes, + .num_dapm_routes = ARRAY_SIZE(wm2200_dapm_routes), + .endianness = 1, + .non_legacy_dai_naming = 1, };
static irqreturn_t wm2200_irq(int irq, void *data) @@ -2408,7 +2404,7 @@ static int wm2200_i2c_probe(struct i2c_client *i2c, pm_runtime_enable(&i2c->dev); pm_request_idle(&i2c->dev);
- ret = snd_soc_register_codec(&i2c->dev, &soc_codec_wm2200, + ret = devm_snd_soc_register_component(&i2c->dev, &soc_component_wm2200, &wm2200_dai, 1); if (ret != 0) { dev_err(&i2c->dev, "Failed to register CODEC: %d\n", ret); @@ -2435,7 +2431,6 @@ static int wm2200_i2c_remove(struct i2c_client *i2c) { struct wm2200_priv *wm2200 = i2c_get_clientdata(i2c);
- snd_soc_unregister_codec(&i2c->dev); if (i2c->irq) free_irq(i2c->irq, wm2200); if (wm2200->pdata.reset)
From: Kuninori Morimoto kuninori.morimoto.gx@renesas.com
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 -> .pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com --- sound/soc/codecs/wm5100.c | 260 ++++++++++++++++++++++---------------------- sound/soc/codecs/wm5100.h | 2 +- sound/soc/samsung/lowland.c | 12 +- 3 files changed, 134 insertions(+), 140 deletions(-)
diff --git a/sound/soc/codecs/wm5100.c b/sound/soc/codecs/wm5100.c index 138a84e..14f0cab 100644 --- a/sound/soc/codecs/wm5100.c +++ b/sound/soc/codecs/wm5100.c @@ -55,7 +55,7 @@ struct wm5100_fll { struct wm5100_priv { struct device *dev; struct regmap *regmap; - struct snd_soc_codec *codec; + struct snd_soc_component *component;
struct regulator_bulk_data core_supplies[WM5100_NUM_CORE_SUPPLIES];
@@ -118,16 +118,16 @@ struct wm5100_priv { WM5100_CLOCKING_6, };
-static int wm5100_alloc_sr(struct snd_soc_codec *codec, int rate) +static int wm5100_alloc_sr(struct snd_soc_component *component, int rate) { - struct wm5100_priv *wm5100 = snd_soc_codec_get_drvdata(codec); + struct wm5100_priv *wm5100 = snd_soc_component_get_drvdata(component); int sr_code, sr_free, i;
for (i = 0; i < ARRAY_SIZE(wm5100_sr_code); i++) if (wm5100_sr_code[i] == rate) break; if (i == ARRAY_SIZE(wm5100_sr_code)) { - dev_err(codec->dev, "Unsupported sample rate: %dHz\n", rate); + dev_err(component->dev, "Unsupported sample rate: %dHz\n", rate); return -EINVAL; } sr_code = i; @@ -140,50 +140,50 @@ static int wm5100_alloc_sr(struct snd_soc_codec *codec, int rate) sr_free = i; continue; } - if ((snd_soc_read(codec, wm5100_sr_regs[i]) & + if ((snd_soc_component_read32(component, wm5100_sr_regs[i]) & WM5100_SAMPLE_RATE_1_MASK) == sr_code) break; }
if (i < ARRAY_SIZE(wm5100_sr_regs)) { wm5100->sr_ref[i]++; - dev_dbg(codec->dev, "SR %dHz, slot %d, ref %d\n", + dev_dbg(component->dev, "SR %dHz, slot %d, ref %d\n", rate, i, wm5100->sr_ref[i]); return i; }
if (sr_free == -1) { - dev_err(codec->dev, "All SR slots already in use\n"); + dev_err(component->dev, "All SR slots already in use\n"); return -EBUSY; }
- dev_dbg(codec->dev, "Allocating SR slot %d for %dHz\n", + dev_dbg(component->dev, "Allocating SR slot %d for %dHz\n", sr_free, rate); wm5100->sr_ref[sr_free]++; - snd_soc_update_bits(codec, wm5100_sr_regs[sr_free], + snd_soc_component_update_bits(component, wm5100_sr_regs[sr_free], WM5100_SAMPLE_RATE_1_MASK, sr_code);
return sr_free;
} else { - dev_err(codec->dev, + dev_err(component->dev, "SR %dHz incompatible with %dHz SYSCLK and %dHz ASYNCCLK\n", rate, wm5100->sysclk, wm5100->asyncclk); return -EINVAL; } }
-static void wm5100_free_sr(struct snd_soc_codec *codec, int rate) +static void wm5100_free_sr(struct snd_soc_component *component, int rate) { - struct wm5100_priv *wm5100 = snd_soc_codec_get_drvdata(codec); + struct wm5100_priv *wm5100 = snd_soc_component_get_drvdata(component); int i, sr_code;
for (i = 0; i < ARRAY_SIZE(wm5100_sr_code); i++) if (wm5100_sr_code[i] == rate) break; if (i == ARRAY_SIZE(wm5100_sr_code)) { - dev_err(codec->dev, "Unsupported sample rate: %dHz\n", rate); + dev_err(component->dev, "Unsupported sample rate: %dHz\n", rate); return; } sr_code = wm5100_sr_code[i]; @@ -192,16 +192,16 @@ static void wm5100_free_sr(struct snd_soc_codec *codec, int rate) if (!wm5100->sr_ref[i]) continue;
- if ((snd_soc_read(codec, wm5100_sr_regs[i]) & + if ((snd_soc_component_read32(component, wm5100_sr_regs[i]) & WM5100_SAMPLE_RATE_1_MASK) == sr_code) break; } if (i < ARRAY_SIZE(wm5100_sr_regs)) { wm5100->sr_ref[i]--; - dev_dbg(codec->dev, "Dereference SR %dHz, count now %d\n", + dev_dbg(component->dev, "Dereference SR %dHz, count now %d\n", rate, wm5100->sr_ref[i]); } else { - dev_warn(codec->dev, "Freeing unreferenced sample rate %dHz\n", + dev_warn(component->dev, "Freeing unreferenced sample rate %dHz\n", rate); } } @@ -733,40 +733,39 @@ static SOC_ENUM_SINGLE_DECL(wm5100_lhpf4_mode, WM5100_MIXER_CONTROLS("LHPF4", WM5100_HPLP4MIX_INPUT_1_SOURCE), };
-static void wm5100_seq_notifier(struct snd_soc_dapm_context *dapm, +static void wm5100_seq_notifier(struct snd_soc_component *component, enum snd_soc_dapm_type event, int subseq) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(dapm); - struct wm5100_priv *wm5100 = snd_soc_codec_get_drvdata(codec); + struct wm5100_priv *wm5100 = snd_soc_component_get_drvdata(component); u16 val, expect, i;
/* Wait for the outputs to flag themselves as enabled */ if (wm5100->out_ena[0]) { - expect = snd_soc_read(codec, WM5100_CHANNEL_ENABLES_1); + expect = snd_soc_component_read32(component, WM5100_CHANNEL_ENABLES_1); for (i = 0; i < 200; i++) { - val = snd_soc_read(codec, WM5100_OUTPUT_STATUS_1); + val = snd_soc_component_read32(component, WM5100_OUTPUT_STATUS_1); if (val == expect) { wm5100->out_ena[0] = false; break; } } if (i == 200) { - dev_err(codec->dev, "Timeout waiting for OUTPUT1 %x\n", + dev_err(component->dev, "Timeout waiting for OUTPUT1 %x\n", expect); } }
if (wm5100->out_ena[1]) { - expect = snd_soc_read(codec, WM5100_OUTPUT_ENABLES_2); + expect = snd_soc_component_read32(component, WM5100_OUTPUT_ENABLES_2); for (i = 0; i < 200; i++) { - val = snd_soc_read(codec, WM5100_OUTPUT_STATUS_2); + val = snd_soc_component_read32(component, WM5100_OUTPUT_STATUS_2); if (val == expect) { wm5100->out_ena[1] = false; break; } } if (i == 200) { - dev_err(codec->dev, "Timeout waiting for OUTPUT2 %x\n", + dev_err(component->dev, "Timeout waiting for OUTPUT2 %x\n", expect); } } @@ -776,8 +775,8 @@ static int wm5100_out_ev(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); - struct wm5100_priv *wm5100 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); + struct wm5100_priv *wm5100 = snd_soc_component_get_drvdata(component);
switch (w->reg) { case WM5100_CHANNEL_ENABLES_1: @@ -841,17 +840,17 @@ static int wm5100_post_ev(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); - struct wm5100_priv *wm5100 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); + struct wm5100_priv *wm5100 = snd_soc_component_get_drvdata(component); int ret;
- ret = snd_soc_read(codec, WM5100_INTERRUPT_RAW_STATUS_3); + ret = snd_soc_component_read32(component, WM5100_INTERRUPT_RAW_STATUS_3); ret &= WM5100_SPK_SHUTDOWN_WARN_STS | WM5100_SPK_SHUTDOWN_STS | WM5100_CLKGEN_ERR_STS | WM5100_CLKGEN_ERR_ASYNC_STS; wm5100_log_status3(wm5100, ret);
- ret = snd_soc_read(codec, WM5100_INTERRUPT_RAW_STATUS_4); + ret = snd_soc_component_read32(component, WM5100_INTERRUPT_RAW_STATUS_4); wm5100_log_status4(wm5100, ret);
return 0; @@ -1282,7 +1281,7 @@ static int wm5100_post_ev(struct snd_soc_dapm_widget *w,
static int wm5100_set_fmt(struct snd_soc_dai *dai, unsigned int fmt) { - struct snd_soc_codec *codec = dai->codec; + struct snd_soc_component *component = dai->component; int lrclk, bclk, mask, base;
base = dai->driver->base; @@ -1298,7 +1297,7 @@ static int wm5100_set_fmt(struct snd_soc_dai *dai, unsigned int fmt) mask = 2; break; default: - dev_err(codec->dev, "Unsupported DAI format %d\n", + dev_err(component->dev, "Unsupported DAI format %d\n", fmt & SND_SOC_DAIFMT_FORMAT_MASK); return -EINVAL; } @@ -1317,7 +1316,7 @@ static int wm5100_set_fmt(struct snd_soc_dai *dai, unsigned int fmt) bclk |= WM5100_AIF1_BCLK_MSTR; break; default: - dev_err(codec->dev, "Unsupported master mode %d\n", + dev_err(component->dev, "Unsupported master mode %d\n", fmt & SND_SOC_DAIFMT_MASTER_MASK); return -EINVAL; } @@ -1339,13 +1338,13 @@ static int wm5100_set_fmt(struct snd_soc_dai *dai, unsigned int fmt) return -EINVAL; }
- snd_soc_update_bits(codec, base + 1, WM5100_AIF1_BCLK_MSTR | + snd_soc_component_update_bits(component, base + 1, WM5100_AIF1_BCLK_MSTR | WM5100_AIF1_BCLK_INV, bclk); - snd_soc_update_bits(codec, base + 2, WM5100_AIF1TX_LRCLK_MSTR | + snd_soc_component_update_bits(component, base + 2, WM5100_AIF1TX_LRCLK_MSTR | WM5100_AIF1TX_LRCLK_INV, lrclk); - snd_soc_update_bits(codec, base + 3, WM5100_AIF1TX_LRCLK_MSTR | + snd_soc_component_update_bits(component, base + 3, WM5100_AIF1TX_LRCLK_MSTR | WM5100_AIF1TX_LRCLK_INV, lrclk); - snd_soc_update_bits(codec, base + 5, WM5100_AIF1_FMT_MASK, mask); + snd_soc_component_update_bits(component, base + 5, WM5100_AIF1_FMT_MASK, mask);
return 0; } @@ -1400,8 +1399,8 @@ static int wm5100_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; - struct wm5100_priv *wm5100 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct wm5100_priv *wm5100 = snd_soc_component_get_drvdata(component); bool async = wm5100->aif_async[dai->id]; int i, base, bclk, aif_rate, lrclk, wl, fl, sr; int *bclk_rates; @@ -1416,7 +1415,7 @@ static int wm5100_hw_params(struct snd_pcm_substream *substream, if (fl < 0) return fl;
- dev_dbg(codec->dev, "Word length %d bits, frame length %d bits\n", + dev_dbg(component->dev, "Word length %d bits, frame length %d bits\n", wl, fl);
/* Target BCLK rate */ @@ -1427,7 +1426,7 @@ static int wm5100_hw_params(struct snd_pcm_substream *substream, /* Root for BCLK depends on SYS/ASYNCCLK */ if (!async) { aif_rate = wm5100->sysclk; - sr = wm5100_alloc_sr(codec, params_rate(params)); + sr = wm5100_alloc_sr(component, params_rate(params)); if (sr < 0) return sr; } else { @@ -1439,23 +1438,23 @@ static int wm5100_hw_params(struct snd_pcm_substream *substream, if (params_rate(params) == wm5100_sr_code[i]) break; if (i == ARRAY_SIZE(wm5100_sr_code)) { - dev_err(codec->dev, "Invalid rate %dHzn", + dev_err(component->dev, "Invalid rate %dHzn", params_rate(params)); return -EINVAL; }
/* TODO: We should really check for symmetry */ - snd_soc_update_bits(codec, WM5100_CLOCKING_8, + snd_soc_component_update_bits(component, WM5100_CLOCKING_8, WM5100_ASYNC_SAMPLE_RATE_MASK, i); }
if (!aif_rate) { - dev_err(codec->dev, "%s has no rate set\n", + dev_err(component->dev, "%s has no rate set\n", async ? "ASYNCCLK" : "SYSCLK"); return -EINVAL; }
- dev_dbg(codec->dev, "Target BCLK is %dHz, using %dHz %s\n", + dev_dbg(component->dev, "Target BCLK is %dHz, using %dHz %s\n", bclk, aif_rate, async ? "ASYNCCLK" : "SYSCLK");
if (aif_rate % 4000) @@ -1467,37 +1466,37 @@ static int wm5100_hw_params(struct snd_pcm_substream *substream, if (bclk_rates[i] >= bclk && (bclk_rates[i] % bclk == 0)) break; if (i == WM5100_NUM_BCLK_RATES) { - dev_err(codec->dev, + dev_err(component->dev, "No valid BCLK for %dHz found from %dHz %s\n", bclk, aif_rate, async ? "ASYNCCLK" : "SYSCLK"); return -EINVAL; }
bclk = i; - dev_dbg(codec->dev, "Setting %dHz BCLK\n", bclk_rates[bclk]); - snd_soc_update_bits(codec, base + 1, WM5100_AIF1_BCLK_FREQ_MASK, bclk); + dev_dbg(component->dev, "Setting %dHz BCLK\n", bclk_rates[bclk]); + snd_soc_component_update_bits(component, base + 1, WM5100_AIF1_BCLK_FREQ_MASK, bclk);
lrclk = bclk_rates[bclk] / params_rate(params); - dev_dbg(codec->dev, "Setting %dHz LRCLK\n", bclk_rates[bclk] / lrclk); + dev_dbg(component->dev, "Setting %dHz LRCLK\n", bclk_rates[bclk] / lrclk); if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK || wm5100->aif_symmetric[dai->id]) - snd_soc_update_bits(codec, base + 7, + snd_soc_component_update_bits(component, base + 7, WM5100_AIF1RX_BCPF_MASK, lrclk); else - snd_soc_update_bits(codec, base + 6, + snd_soc_component_update_bits(component, base + 6, WM5100_AIF1TX_BCPF_MASK, lrclk);
i = (wl << WM5100_AIF1TX_WL_SHIFT) | fl; if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) - snd_soc_update_bits(codec, base + 9, + snd_soc_component_update_bits(component, base + 9, WM5100_AIF1RX_WL_MASK | WM5100_AIF1RX_SLOT_LEN_MASK, i); else - snd_soc_update_bits(codec, base + 8, + snd_soc_component_update_bits(component, base + 8, WM5100_AIF1TX_WL_MASK | WM5100_AIF1TX_SLOT_LEN_MASK, i);
- snd_soc_update_bits(codec, base + 4, WM5100_AIF1_RATE_MASK, sr); + snd_soc_component_update_bits(component, base + 4, WM5100_AIF1_RATE_MASK, sr);
return 0; } @@ -1507,10 +1506,10 @@ static int wm5100_hw_params(struct snd_pcm_substream *substream, .hw_params = wm5100_hw_params, };
-static int wm5100_set_sysclk(struct snd_soc_codec *codec, int clk_id, +static int wm5100_set_sysclk(struct snd_soc_component *component, int clk_id, int source, unsigned int freq, int dir) { - struct wm5100_priv *wm5100 = snd_soc_codec_get_drvdata(codec); + struct wm5100_priv *wm5100 = snd_soc_component_get_drvdata(component); int *rate_store; int fval, audio_rate, ret, reg;
@@ -1529,7 +1528,7 @@ static int wm5100_set_sysclk(struct snd_soc_codec *codec, int clk_id, case WM5100_CLKSRC_MCLK1: case WM5100_CLKSRC_MCLK2: case WM5100_CLKSRC_SYSCLK: - snd_soc_update_bits(codec, WM5100_CLOCKING_1, + snd_soc_component_update_bits(component, WM5100_CLOCKING_1, WM5100_CLK_32K_SRC_MASK, source); break; @@ -1550,7 +1549,7 @@ static int wm5100_set_sysclk(struct snd_soc_codec *codec, int clk_id, wm5100->aif_async[clk_id - 1] = true; break; default: - dev_err(codec->dev, "Invalid source %d\n", source); + dev_err(component->dev, "Invalid source %d\n", source); return -EINVAL; } return 0; @@ -1559,35 +1558,35 @@ static int wm5100_set_sysclk(struct snd_soc_codec *codec, int clk_id, switch (freq) { case 5644800: case 6144000: - snd_soc_update_bits(codec, WM5100_MISC_GPIO_1, + snd_soc_component_update_bits(component, WM5100_MISC_GPIO_1, WM5100_OPCLK_SEL_MASK, 0); break; case 11289600: case 12288000: - snd_soc_update_bits(codec, WM5100_MISC_GPIO_1, + snd_soc_component_update_bits(component, WM5100_MISC_GPIO_1, WM5100_OPCLK_SEL_MASK, 0); break; case 22579200: case 24576000: - snd_soc_update_bits(codec, WM5100_MISC_GPIO_1, + snd_soc_component_update_bits(component, WM5100_MISC_GPIO_1, WM5100_OPCLK_SEL_MASK, 0); break; default: - dev_err(codec->dev, "Unsupported OPCLK %dHz\n", + dev_err(component->dev, "Unsupported OPCLK %dHz\n", freq); return -EINVAL; } return 0;
default: - dev_err(codec->dev, "Unknown clock %d\n", clk_id); + dev_err(component->dev, "Unknown clock %d\n", clk_id); return -EINVAL; }
switch (source) { case WM5100_CLKSRC_SYSCLK: case WM5100_CLKSRC_ASYNCCLK: - dev_err(codec->dev, "Invalid source %d\n", source); + dev_err(component->dev, "Invalid source %d\n", source); return -EINVAL; }
@@ -1605,7 +1604,7 @@ static int wm5100_set_sysclk(struct snd_soc_codec *codec, int clk_id, fval = 2; break; default: - dev_err(codec->dev, "Invalid clock rate: %d\n", freq); + dev_err(component->dev, "Invalid clock rate: %d\n", freq); return -EINVAL; }
@@ -1632,7 +1631,7 @@ static int wm5100_set_sysclk(struct snd_soc_codec *codec, int clk_id, * match. */
- snd_soc_update_bits(codec, reg, WM5100_SYSCLK_FREQ_MASK | + snd_soc_component_update_bits(component, reg, WM5100_SYSCLK_FREQ_MASK | WM5100_SYSCLK_SRC_MASK, fval << WM5100_SYSCLK_FREQ_SHIFT | source);
@@ -1641,13 +1640,13 @@ static int wm5100_set_sysclk(struct snd_soc_codec *codec, int clk_id, * this clock rate. */ if (clk_id == WM5100_CLK_SYSCLK) { - dev_dbg(codec->dev, "Setting primary audio rate to %dHz", + dev_dbg(component->dev, "Setting primary audio rate to %dHz", audio_rate); if (0 && *rate_store) - wm5100_free_sr(codec, audio_rate); - ret = wm5100_alloc_sr(codec, audio_rate); + wm5100_free_sr(component, audio_rate); + ret = wm5100_alloc_sr(component, audio_rate); if (ret != 0) - dev_warn(codec->dev, "Primary audio slot is %d\n", + dev_warn(component->dev, "Primary audio slot is %d\n", ret); }
@@ -1755,11 +1754,11 @@ static int fll_factors(struct _fll_div *fll_div, unsigned int Fref, return 0; }
-static int wm5100_set_fll(struct snd_soc_codec *codec, int fll_id, int source, +static int wm5100_set_fll(struct snd_soc_component *component, int fll_id, int source, unsigned int Fref, unsigned int Fout) { - struct i2c_client *i2c = to_i2c_client(codec->dev); - struct wm5100_priv *wm5100 = snd_soc_codec_get_drvdata(codec); + struct i2c_client *i2c = to_i2c_client(component->dev); + struct wm5100_priv *wm5100 = snd_soc_component_get_drvdata(component); struct _fll_div factors; struct wm5100_fll *fll; int ret, base, lock, i, timeout; @@ -1777,16 +1776,16 @@ static int wm5100_set_fll(struct snd_soc_codec *codec, int fll_id, int source, lock = WM5100_FLL2_LOCK_STS; break; default: - dev_err(codec->dev, "Unknown FLL %d\n",fll_id); + dev_err(component->dev, "Unknown FLL %d\n",fll_id); return -EINVAL; }
if (!Fout) { - dev_dbg(codec->dev, "FLL%d disabled", fll_id); + dev_dbg(component->dev, "FLL%d disabled", fll_id); if (fll->fout) - pm_runtime_put(codec->dev); + pm_runtime_put(component->dev); fll->fout = 0; - snd_soc_update_bits(codec, base + 1, WM5100_FLL1_ENA, 0); + snd_soc_component_update_bits(component, base + 1, WM5100_FLL1_ENA, 0); return 0; }
@@ -1800,7 +1799,7 @@ static int wm5100_set_fll(struct snd_soc_codec *codec, int fll_id, int source, case WM5100_FLL_SRC_AIF3BCLK: break; default: - dev_err(codec->dev, "Invalid FLL source %d\n", source); + dev_err(component->dev, "Invalid FLL source %d\n", source); return -EINVAL; }
@@ -1809,36 +1808,36 @@ static int wm5100_set_fll(struct snd_soc_codec *codec, int fll_id, int source, return ret;
/* Disable the FLL while we reconfigure */ - snd_soc_update_bits(codec, base + 1, WM5100_FLL1_ENA, 0); + snd_soc_component_update_bits(component, base + 1, WM5100_FLL1_ENA, 0);
- snd_soc_update_bits(codec, base + 2, + snd_soc_component_update_bits(component, base + 2, WM5100_FLL1_OUTDIV_MASK | WM5100_FLL1_FRATIO_MASK, (factors.fll_outdiv << WM5100_FLL1_OUTDIV_SHIFT) | factors.fll_fratio); - snd_soc_update_bits(codec, base + 3, WM5100_FLL1_THETA_MASK, + snd_soc_component_update_bits(component, base + 3, WM5100_FLL1_THETA_MASK, factors.theta); - snd_soc_update_bits(codec, base + 5, WM5100_FLL1_N_MASK, factors.n); - snd_soc_update_bits(codec, base + 6, + snd_soc_component_update_bits(component, base + 5, WM5100_FLL1_N_MASK, factors.n); + snd_soc_component_update_bits(component, base + 6, WM5100_FLL1_REFCLK_DIV_MASK | WM5100_FLL1_REFCLK_SRC_MASK, (factors.fll_refclk_div << WM5100_FLL1_REFCLK_DIV_SHIFT) | source); - snd_soc_update_bits(codec, base + 7, WM5100_FLL1_LAMBDA_MASK, + snd_soc_component_update_bits(component, base + 7, WM5100_FLL1_LAMBDA_MASK, factors.lambda);
/* Clear any pending completions */ try_wait_for_completion(&fll->lock);
- pm_runtime_get_sync(codec->dev); + pm_runtime_get_sync(component->dev);
- snd_soc_update_bits(codec, base + 1, WM5100_FLL1_ENA, WM5100_FLL1_ENA); + snd_soc_component_update_bits(component, base + 1, WM5100_FLL1_ENA, WM5100_FLL1_ENA);
if (i2c->irq) timeout = 2; else timeout = 50;
- snd_soc_update_bits(codec, WM5100_CLOCKING_3, WM5100_SYSCLK_ENA, + snd_soc_component_update_bits(component, WM5100_CLOCKING_3, WM5100_SYSCLK_ENA, WM5100_SYSCLK_ENA);
/* Poll for the lock; will use interrupt when we can test */ @@ -1852,10 +1851,10 @@ static int wm5100_set_fll(struct snd_soc_codec *codec, int fll_id, int source, msleep(1); }
- ret = snd_soc_read(codec, + ret = snd_soc_component_read32(component, WM5100_INTERRUPT_RAW_STATUS_3); if (ret < 0) { - dev_err(codec->dev, + dev_err(component->dev, "Failed to read FLL status: %d\n", ret); continue; @@ -1864,8 +1863,8 @@ static int wm5100_set_fll(struct snd_soc_codec *codec, int fll_id, int source, break; } if (i == timeout) { - dev_err(codec->dev, "FLL%d lock timed out\n", fll_id); - pm_runtime_put(codec->dev); + dev_err(component->dev, "FLL%d lock timed out\n", fll_id); + pm_runtime_put(component->dev); return -ETIMEDOUT; }
@@ -1873,7 +1872,7 @@ static int wm5100_set_fll(struct snd_soc_codec *codec, int fll_id, int source, fll->fref = Fref; fll->fout = Fout;
- dev_dbg(codec->dev, "FLL%d running %dHz->%dHz\n", fll_id, + dev_dbg(component->dev, "FLL%d running %dHz->%dHz\n", fll_id, Fref, Fout);
return 0; @@ -2099,10 +2098,10 @@ static void wm5100_micd_irq(struct wm5100_priv *wm5100) } }
-int wm5100_detect(struct snd_soc_codec *codec, struct snd_soc_jack *jack) +int wm5100_detect(struct snd_soc_component *component, struct snd_soc_jack *jack) { - struct wm5100_priv *wm5100 = snd_soc_codec_get_drvdata(codec); - struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec); + struct wm5100_priv *wm5100 = snd_soc_component_get_drvdata(component); + struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component);
if (jack) { wm5100->jack = jack; @@ -2113,7 +2112,7 @@ int wm5100_detect(struct snd_soc_codec *codec, struct snd_soc_jack *jack)
/* Slowest detection rate, gives debounce for initial * detection */ - snd_soc_update_bits(codec, WM5100_MIC_DETECT_1, + snd_soc_component_update_bits(component, WM5100_MIC_DETECT_1, WM5100_ACCDET_BIAS_STARTTIME_MASK | WM5100_ACCDET_RATE_MASK, (7 << WM5100_ACCDET_BIAS_STARTTIME_SHIFT) | @@ -2132,18 +2131,18 @@ int wm5100_detect(struct snd_soc_codec *codec, struct snd_soc_jack *jack) /* We start off just enabling microphone detection - even a * plain headphone will trigger detection. */ - snd_soc_update_bits(codec, WM5100_MIC_DETECT_1, + snd_soc_component_update_bits(component, WM5100_MIC_DETECT_1, WM5100_ACCDET_ENA, WM5100_ACCDET_ENA);
- snd_soc_update_bits(codec, WM5100_INTERRUPT_STATUS_3_MASK, + snd_soc_component_update_bits(component, WM5100_INTERRUPT_STATUS_3_MASK, WM5100_IM_ACCDET_EINT, 0); } else { - snd_soc_update_bits(codec, WM5100_INTERRUPT_STATUS_3_MASK, + snd_soc_component_update_bits(component, WM5100_INTERRUPT_STATUS_3_MASK, WM5100_IM_HPDET_EINT | WM5100_IM_ACCDET_EINT, WM5100_IM_HPDET_EINT | WM5100_IM_ACCDET_EINT); - snd_soc_update_bits(codec, WM5100_MIC_DETECT_1, + snd_soc_component_update_bits(component, WM5100_MIC_DETECT_1, WM5100_ACCDET_ENA, 0); wm5100->jack = NULL; } @@ -2330,22 +2329,22 @@ static void wm5100_free_gpio(struct i2c_client *i2c) } #endif
-static int wm5100_probe(struct snd_soc_codec *codec) +static int wm5100_probe(struct snd_soc_component *component) { - struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec); - struct i2c_client *i2c = to_i2c_client(codec->dev); - struct wm5100_priv *wm5100 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); + struct i2c_client *i2c = to_i2c_client(component->dev); + struct wm5100_priv *wm5100 = snd_soc_component_get_drvdata(component); int ret, i;
- wm5100->codec = codec; + wm5100->component = component;
for (i = 0; i < ARRAY_SIZE(wm5100_dig_vu); i++) - snd_soc_update_bits(codec, wm5100_dig_vu[i], WM5100_OUT_VU, + snd_soc_component_update_bits(component, wm5100_dig_vu[i], WM5100_OUT_VU, WM5100_OUT_VU);
/* Don't debounce interrupts to support use of SYSCLK only */ - snd_soc_write(codec, WM5100_IRQ_DEBOUNCE_1, 0); - snd_soc_write(codec, WM5100_IRQ_DEBOUNCE_2, 0); + snd_soc_component_write(component, WM5100_IRQ_DEBOUNCE_1, 0); + snd_soc_component_write(component, WM5100_IRQ_DEBOUNCE_2, 0);
/* TODO: check if we're symmetric */
@@ -2370,34 +2369,30 @@ static int wm5100_probe(struct snd_soc_codec *codec) return ret; }
-static int wm5100_remove(struct snd_soc_codec *codec) +static void wm5100_remove(struct snd_soc_component *component) { - struct wm5100_priv *wm5100 = snd_soc_codec_get_drvdata(codec); + struct wm5100_priv *wm5100 = snd_soc_component_get_drvdata(component);
if (wm5100->pdata.hp_pol) { gpio_free(wm5100->pdata.hp_pol); } - - return 0; }
-static const struct snd_soc_codec_driver soc_codec_dev_wm5100 = { - .probe = wm5100_probe, - .remove = wm5100_remove, - - .set_sysclk = wm5100_set_sysclk, - .set_pll = wm5100_set_fll, - .idle_bias_off = 1, - - .seq_notifier = wm5100_seq_notifier, - .component_driver = { - .controls = wm5100_snd_controls, - .num_controls = ARRAY_SIZE(wm5100_snd_controls), - .dapm_widgets = wm5100_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(wm5100_dapm_widgets), - .dapm_routes = wm5100_dapm_routes, - .num_dapm_routes = ARRAY_SIZE(wm5100_dapm_routes), - }, +static const struct snd_soc_component_driver soc_component_dev_wm5100 = { + .probe = wm5100_probe, + .remove = wm5100_remove, + .set_sysclk = wm5100_set_sysclk, + .set_pll = wm5100_set_fll, + .seq_notifier = wm5100_seq_notifier, + .controls = wm5100_snd_controls, + .num_controls = ARRAY_SIZE(wm5100_snd_controls), + .dapm_widgets = wm5100_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(wm5100_dapm_widgets), + .dapm_routes = wm5100_dapm_routes, + .num_dapm_routes = ARRAY_SIZE(wm5100_dapm_routes), + .pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, };
static const struct regmap_config wm5100_regmap = { @@ -2614,8 +2609,8 @@ static int wm5100_i2c_probe(struct i2c_client *i2c, pm_runtime_enable(&i2c->dev); pm_request_idle(&i2c->dev);
- ret = snd_soc_register_codec(&i2c->dev, - &soc_codec_dev_wm5100, wm5100_dai, + ret = devm_snd_soc_register_component(&i2c->dev, + &soc_component_dev_wm5100, wm5100_dai, ARRAY_SIZE(wm5100_dai)); if (ret < 0) { dev_err(&i2c->dev, "Failed to register WM5100: %d\n", ret); @@ -2648,7 +2643,6 @@ static int wm5100_i2c_remove(struct i2c_client *i2c) { struct wm5100_priv *wm5100 = i2c_get_clientdata(i2c);
- snd_soc_unregister_codec(&i2c->dev); if (i2c->irq) free_irq(i2c->irq, wm5100); wm5100_free_gpio(i2c); diff --git a/sound/soc/codecs/wm5100.h b/sound/soc/codecs/wm5100.h index 935a9b7..6076493 100644 --- a/sound/soc/codecs/wm5100.h +++ b/sound/soc/codecs/wm5100.h @@ -17,7 +17,7 @@ #include <sound/soc.h> #include <linux/regmap.h>
-int wm5100_detect(struct snd_soc_codec *codec, struct snd_soc_jack *jack); +int wm5100_detect(struct snd_soc_component *component, struct snd_soc_jack *jack);
#define WM5100_CLK_AIF1 1 #define WM5100_CLK_AIF2 2 diff --git a/sound/soc/samsung/lowland.c b/sound/soc/samsung/lowland.c index 0d0f582..c9081f4 100644 --- a/sound/soc/samsung/lowland.c +++ b/sound/soc/samsung/lowland.c @@ -37,10 +37,10 @@
static int lowland_wm5100_init(struct snd_soc_pcm_runtime *rtd) { - struct snd_soc_codec *codec = rtd->codec; + struct snd_soc_component *component = rtd->codec_dai->component; int ret;
- ret = snd_soc_codec_set_sysclk(codec, WM5100_CLK_SYSCLK, + ret = snd_soc_component_set_sysclk(component, WM5100_CLK_SYSCLK, WM5100_CLKSRC_MCLK1, MCLK1_RATE, SND_SOC_CLOCK_IN); if (ret < 0) { @@ -49,7 +49,7 @@ static int lowland_wm5100_init(struct snd_soc_pcm_runtime *rtd) }
/* Clock OPCLK, used by the other audio components. */ - ret = snd_soc_codec_set_sysclk(codec, WM5100_CLK_OPCLK, 0, + ret = snd_soc_component_set_sysclk(component, WM5100_CLK_OPCLK, 0, CLKOUT_RATE, 0); if (ret < 0) { pr_err("Failed to set OPCLK rate: %d\n", ret); @@ -63,19 +63,19 @@ static int lowland_wm5100_init(struct snd_soc_pcm_runtime *rtd) if (ret) return ret;
- wm5100_detect(codec, &lowland_headset); + wm5100_detect(component, &lowland_headset);
return 0; }
static int lowland_wm9081_init(struct snd_soc_pcm_runtime *rtd) { - struct snd_soc_codec *codec = rtd->codec; + struct snd_soc_component *component = rtd->codec_dai->component;
snd_soc_dapm_nc_pin(&rtd->card->dapm, "LINEOUT");
/* At any time the WM9081 is active it will have this clock */ - return snd_soc_codec_set_sysclk(codec, WM9081_SYSCLK_MCLK, 0, + return snd_soc_component_set_sysclk(component, WM9081_SYSCLK_MCLK, 0, CLKOUT_RATE, 0); }
From: Kuninori Morimoto kuninori.morimoto.gx@renesas.com
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 -> .pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com --- sound/soc/codecs/wm8350.c | 183 ++++++++++++++++++++++----------------------- sound/soc/codecs/wm8350.h | 4 +- sound/soc/fsl/wm1133-ev1.c | 6 +- 3 files changed, 93 insertions(+), 100 deletions(-)
diff --git a/sound/soc/codecs/wm8350.c b/sound/soc/codecs/wm8350.c index fc79c67..6b3b768 100644 --- a/sound/soc/codecs/wm8350.c +++ b/sound/soc/codecs/wm8350.c @@ -256,8 +256,8 @@ static void wm8350_pga_work(struct work_struct *work) static int pga_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); - struct wm8350_data *wm8350_data = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); + struct wm8350_data *wm8350_data = snd_soc_component_get_drvdata(component); struct wm8350_output *out;
switch (w->shift) { @@ -299,8 +299,8 @@ static int pga_event(struct snd_soc_dapm_widget *w, static int wm8350_put_volsw_2r_vu(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct wm8350_data *wm8350_priv = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct wm8350_data *wm8350_priv = snd_soc_component_get_drvdata(component); struct wm8350_output *out = NULL; struct soc_mixer_control *mc = (struct soc_mixer_control *)kcontrol->private_value; @@ -334,16 +334,16 @@ static int wm8350_put_volsw_2r_vu(struct snd_kcontrol *kcontrol, return ret;
/* now hit the volume update bits (always bit 8) */ - val = snd_soc_read(codec, reg); - snd_soc_write(codec, reg, val | WM8350_OUT1_VU); + val = snd_soc_component_read32(component, reg); + snd_soc_component_write(component, reg, val | WM8350_OUT1_VU); return 1; }
static int wm8350_get_volsw_2r(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct wm8350_data *wm8350_priv = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct wm8350_data *wm8350_priv = snd_soc_component_get_drvdata(component); struct wm8350_output *out1 = &wm8350_priv->out1; struct wm8350_output *out2 = &wm8350_priv->out2; struct soc_mixer_control *mc = @@ -753,8 +753,8 @@ static const DECLARE_TLV_DB_RANGE(capture_sd_tlv, static int wm8350_set_dai_sysclk(struct snd_soc_dai *codec_dai, int clk_id, unsigned int freq, int dir) { - struct snd_soc_codec *codec = codec_dai->codec; - struct wm8350_data *wm8350_data = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = codec_dai->component; + struct wm8350_data *wm8350_data = snd_soc_component_get_drvdata(component); struct wm8350 *wm8350 = wm8350_data->wm8350; u16 fll_4;
@@ -769,9 +769,9 @@ static int wm8350_set_dai_sysclk(struct snd_soc_dai *codec_dai, case WM8350_MCLK_SEL_PLL_32K: wm8350_set_bits(wm8350, WM8350_CLOCK_CONTROL_1, WM8350_MCLK_SEL); - fll_4 = snd_soc_read(codec, WM8350_FLL_CONTROL_4) & + fll_4 = snd_soc_component_read32(component, WM8350_FLL_CONTROL_4) & ~WM8350_FLL_CLK_SRC_MASK; - snd_soc_write(codec, WM8350_FLL_CONTROL_4, fll_4 | clk_id); + snd_soc_component_write(component, WM8350_FLL_CONTROL_4, fll_4 | clk_id); break; }
@@ -788,44 +788,44 @@ static int wm8350_set_dai_sysclk(struct snd_soc_dai *codec_dai,
static int wm8350_set_clkdiv(struct snd_soc_dai *codec_dai, int div_id, int div) { - struct snd_soc_codec *codec = codec_dai->codec; + struct snd_soc_component *component = codec_dai->component; u16 val;
switch (div_id) { case WM8350_ADC_CLKDIV: - val = snd_soc_read(codec, WM8350_ADC_DIVIDER) & + val = snd_soc_component_read32(component, WM8350_ADC_DIVIDER) & ~WM8350_ADC_CLKDIV_MASK; - snd_soc_write(codec, WM8350_ADC_DIVIDER, val | div); + snd_soc_component_write(component, WM8350_ADC_DIVIDER, val | div); break; case WM8350_DAC_CLKDIV: - val = snd_soc_read(codec, WM8350_DAC_CLOCK_CONTROL) & + val = snd_soc_component_read32(component, WM8350_DAC_CLOCK_CONTROL) & ~WM8350_DAC_CLKDIV_MASK; - snd_soc_write(codec, WM8350_DAC_CLOCK_CONTROL, val | div); + snd_soc_component_write(component, WM8350_DAC_CLOCK_CONTROL, val | div); break; case WM8350_BCLK_CLKDIV: - val = snd_soc_read(codec, WM8350_CLOCK_CONTROL_1) & + val = snd_soc_component_read32(component, WM8350_CLOCK_CONTROL_1) & ~WM8350_BCLK_DIV_MASK; - snd_soc_write(codec, WM8350_CLOCK_CONTROL_1, val | div); + snd_soc_component_write(component, WM8350_CLOCK_CONTROL_1, val | div); break; case WM8350_OPCLK_CLKDIV: - val = snd_soc_read(codec, WM8350_CLOCK_CONTROL_1) & + val = snd_soc_component_read32(component, WM8350_CLOCK_CONTROL_1) & ~WM8350_OPCLK_DIV_MASK; - snd_soc_write(codec, WM8350_CLOCK_CONTROL_1, val | div); + snd_soc_component_write(component, WM8350_CLOCK_CONTROL_1, val | div); break; case WM8350_SYS_CLKDIV: - val = snd_soc_read(codec, WM8350_CLOCK_CONTROL_1) & + val = snd_soc_component_read32(component, WM8350_CLOCK_CONTROL_1) & ~WM8350_MCLK_DIV_MASK; - snd_soc_write(codec, WM8350_CLOCK_CONTROL_1, val | div); + snd_soc_component_write(component, WM8350_CLOCK_CONTROL_1, val | div); break; case WM8350_DACLR_CLKDIV: - val = snd_soc_read(codec, WM8350_DAC_LR_RATE) & + val = snd_soc_component_read32(component, WM8350_DAC_LR_RATE) & ~WM8350_DACLRC_RATE_MASK; - snd_soc_write(codec, WM8350_DAC_LR_RATE, val | div); + snd_soc_component_write(component, WM8350_DAC_LR_RATE, val | div); break; case WM8350_ADCLR_CLKDIV: - val = snd_soc_read(codec, WM8350_ADC_LR_RATE) & + val = snd_soc_component_read32(component, WM8350_ADC_LR_RATE) & ~WM8350_ADCLRC_RATE_MASK; - snd_soc_write(codec, WM8350_ADC_LR_RATE, val | div); + snd_soc_component_write(component, WM8350_ADC_LR_RATE, val | div); break; default: return -EINVAL; @@ -836,14 +836,14 @@ static int wm8350_set_clkdiv(struct snd_soc_dai *codec_dai, int div_id, int div)
static int wm8350_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt) { - struct snd_soc_codec *codec = codec_dai->codec; - u16 iface = snd_soc_read(codec, WM8350_AI_FORMATING) & + struct snd_soc_component *component = codec_dai->component; + u16 iface = snd_soc_component_read32(component, WM8350_AI_FORMATING) & ~(WM8350_AIF_BCLK_INV | WM8350_AIF_LRCLK_INV | WM8350_AIF_FMT_MASK); - u16 master = snd_soc_read(codec, WM8350_AI_DAC_CONTROL) & + u16 master = snd_soc_component_read32(component, WM8350_AI_DAC_CONTROL) & ~WM8350_BCLK_MSTR; - u16 dac_lrc = snd_soc_read(codec, WM8350_DAC_LR_RATE) & + u16 dac_lrc = snd_soc_component_read32(component, WM8350_DAC_LR_RATE) & ~WM8350_DACLRC_ENA; - u16 adc_lrc = snd_soc_read(codec, WM8350_ADC_LR_RATE) & + u16 adc_lrc = snd_soc_component_read32(component, WM8350_ADC_LR_RATE) & ~WM8350_ADCLRC_ENA;
/* set master/slave audio interface */ @@ -896,10 +896,10 @@ static int wm8350_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt) return -EINVAL; }
- snd_soc_write(codec, WM8350_AI_FORMATING, iface); - snd_soc_write(codec, WM8350_AI_DAC_CONTROL, master); - snd_soc_write(codec, WM8350_DAC_LR_RATE, dac_lrc); - snd_soc_write(codec, WM8350_ADC_LR_RATE, adc_lrc); + snd_soc_component_write(component, WM8350_AI_FORMATING, iface); + snd_soc_component_write(component, WM8350_AI_DAC_CONTROL, master); + snd_soc_component_write(component, WM8350_DAC_LR_RATE, dac_lrc); + snd_soc_component_write(component, WM8350_ADC_LR_RATE, adc_lrc); return 0; }
@@ -907,10 +907,10 @@ static int wm8350_pcm_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *codec_dai) { - struct snd_soc_codec *codec = codec_dai->codec; - struct wm8350_data *wm8350_data = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = codec_dai->component; + struct wm8350_data *wm8350_data = snd_soc_component_get_drvdata(component); struct wm8350 *wm8350 = wm8350_data->wm8350; - u16 iface = snd_soc_read(codec, WM8350_AI_FORMATING) & + u16 iface = snd_soc_component_read32(component, WM8350_AI_FORMATING) & ~WM8350_AIF_WL_MASK;
/* bit size */ @@ -928,7 +928,7 @@ static int wm8350_pcm_hw_params(struct snd_pcm_substream *substream, break; }
- snd_soc_write(codec, WM8350_AI_FORMATING, iface); + snd_soc_component_write(component, WM8350_AI_FORMATING, iface);
/* The sloping stopband filter is recommended for use with * lower sample rates to improve performance. @@ -947,7 +947,7 @@ static int wm8350_pcm_hw_params(struct snd_pcm_substream *substream,
static int wm8350_mute(struct snd_soc_dai *dai, int mute) { - struct snd_soc_codec *codec = dai->codec; + struct snd_soc_component *component = dai->component; unsigned int val;
if (mute) @@ -955,7 +955,7 @@ static int wm8350_mute(struct snd_soc_dai *dai, int mute) else val = 0;
- snd_soc_update_bits(codec, WM8350_DAC_MUTE, WM8350_DAC_MUTE_ENA, val); + snd_soc_component_update_bits(component, WM8350_DAC_MUTE, WM8350_DAC_MUTE_ENA, val);
return 0; } @@ -1024,8 +1024,8 @@ static int wm8350_set_fll(struct snd_soc_dai *codec_dai, int pll_id, int source, unsigned int freq_in, unsigned int freq_out) { - struct snd_soc_codec *codec = codec_dai->codec; - struct wm8350_data *priv = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = codec_dai->component; + struct wm8350_data *priv = snd_soc_component_get_drvdata(component); struct wm8350 *wm8350 = priv->wm8350; struct _fll_div fll_div; int ret = 0; @@ -1050,17 +1050,17 @@ static int wm8350_set_fll(struct snd_soc_dai *codec_dai, fll_div.ratio);
/* set up N.K & dividers */ - fll_1 = snd_soc_read(codec, WM8350_FLL_CONTROL_1) & + fll_1 = snd_soc_component_read32(component, WM8350_FLL_CONTROL_1) & ~(WM8350_FLL_OUTDIV_MASK | WM8350_FLL_RSP_RATE_MASK | 0xc000); - snd_soc_write(codec, WM8350_FLL_CONTROL_1, + snd_soc_component_write(component, WM8350_FLL_CONTROL_1, fll_1 | (fll_div.div << 8) | 0x50); - snd_soc_write(codec, WM8350_FLL_CONTROL_2, + snd_soc_component_write(component, WM8350_FLL_CONTROL_2, (fll_div.ratio << 11) | (fll_div. n & WM8350_FLL_N_MASK)); - snd_soc_write(codec, WM8350_FLL_CONTROL_3, fll_div.k); - fll_4 = snd_soc_read(codec, WM8350_FLL_CONTROL_4) & + snd_soc_component_write(component, WM8350_FLL_CONTROL_3, fll_div.k); + fll_4 = snd_soc_component_read32(component, WM8350_FLL_CONTROL_4) & ~(WM8350_FLL_FRAC | WM8350_FLL_SLOW_LOCK_REF); - snd_soc_write(codec, WM8350_FLL_CONTROL_4, + snd_soc_component_write(component, WM8350_FLL_CONTROL_4, fll_4 | (fll_div.k ? WM8350_FLL_FRAC : 0) | (fll_div.ratio == 8 ? WM8350_FLL_SLOW_LOCK_REF : 0));
@@ -1074,10 +1074,10 @@ static int wm8350_set_fll(struct snd_soc_dai *codec_dai, return 0; }
-static int wm8350_set_bias_level(struct snd_soc_codec *codec, +static int wm8350_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { - struct wm8350_data *priv = snd_soc_codec_get_drvdata(codec); + struct wm8350_data *priv = snd_soc_component_get_drvdata(component); struct wm8350 *wm8350 = priv->wm8350; struct wm8350_audio_platform_data *platform = wm8350->codec.platform_data; @@ -1101,7 +1101,7 @@ static int wm8350_set_bias_level(struct snd_soc_codec *codec, break;
case SND_SOC_BIAS_STANDBY: - if (snd_soc_codec_get_bias_level(codec) == SND_SOC_BIAS_OFF) { + if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_OFF) { ret = regulator_bulk_enable(ARRAY_SIZE(priv->supplies), priv->supplies); if (ret != 0) @@ -1310,7 +1310,7 @@ static irqreturn_t wm8350_hpr_jack_handler(int irq, void *data) /** * wm8350_hp_jack_detect - Enable headphone jack detection. * - * @codec: WM8350 codec + * @component: WM8350 component * @which: left or right jack detect signal * @jack: jack to report detection events on * @report: value to report @@ -1318,10 +1318,10 @@ static irqreturn_t wm8350_hpr_jack_handler(int irq, void *data) * Enables the headphone jack detection of the WM8350. If no report * is specified then detection is disabled. */ -int wm8350_hp_jack_detect(struct snd_soc_codec *codec, enum wm8350_jack which, +int wm8350_hp_jack_detect(struct snd_soc_component *component, enum wm8350_jack which, struct snd_soc_jack *jack, int report) { - struct wm8350_data *priv = snd_soc_codec_get_drvdata(codec); + struct wm8350_data *priv = snd_soc_component_get_drvdata(component); struct wm8350 *wm8350 = priv->wm8350; int ena;
@@ -1389,7 +1389,7 @@ static irqreturn_t wm8350_mic_handler(int irq, void *data) /** * wm8350_mic_jack_detect - Enable microphone jack detection. * - * @codec: WM8350 codec + * @component: WM8350 component * @jack: jack to report detection events on * @detect_report: value to report when presence detected * @short_report: value to report when microphone short detected @@ -1397,11 +1397,11 @@ static irqreturn_t wm8350_mic_handler(int irq, void *data) * Enables the microphone jack detection of the WM8350. If both reports * are specified as zero then detection is disabled. */ -int wm8350_mic_jack_detect(struct snd_soc_codec *codec, +int wm8350_mic_jack_detect(struct snd_soc_component *component, struct snd_soc_jack *jack, int detect_report, int short_report) { - struct wm8350_data *priv = snd_soc_codec_get_drvdata(codec); + struct wm8350_data *priv = snd_soc_component_get_drvdata(component); struct wm8350 *wm8350 = priv->wm8350;
priv->mic.jack = jack; @@ -1455,26 +1455,26 @@ int wm8350_mic_jack_detect(struct snd_soc_codec *codec, .ops = &wm8350_dai_ops, };
-static int wm8350_codec_probe(struct snd_soc_codec *codec) +static int wm8350_component_probe(struct snd_soc_component *component) { - struct wm8350 *wm8350 = dev_get_platdata(codec->dev); + struct wm8350 *wm8350 = dev_get_platdata(component->dev); struct wm8350_data *priv; struct wm8350_output *out1; struct wm8350_output *out2; int ret, i;
if (wm8350->codec.platform_data == NULL) { - dev_err(codec->dev, "No audio platform data supplied\n"); + dev_err(component->dev, "No audio platform data supplied\n"); return -EINVAL; }
- priv = devm_kzalloc(codec->dev, sizeof(struct wm8350_data), + priv = devm_kzalloc(component->dev, sizeof(struct wm8350_data), GFP_KERNEL); if (priv == NULL) return -ENOMEM;
- snd_soc_codec_init_regmap(codec, wm8350->regmap); - snd_soc_codec_set_drvdata(codec, priv); + snd_soc_component_init_regmap(component, wm8350->regmap); + snd_soc_component_set_drvdata(component, priv);
priv->wm8350 = wm8350;
@@ -1497,9 +1497,9 @@ static int wm8350_codec_probe(struct snd_soc_codec *codec) wm8350_set_bits(wm8350, WM8350_POWER_MGMT_5, WM8350_CODEC_ENA);
/* Enable robust clocking mode in ADC */ - snd_soc_write(codec, WM8350_SECURITY, 0xa7); - snd_soc_write(codec, 0xde, 0x13); - snd_soc_write(codec, WM8350_SECURITY, 0); + snd_soc_component_write(component, WM8350_SECURITY, 0xa7); + snd_soc_component_write(component, 0xde, 0x13); + snd_soc_component_write(component, WM8350_SECURITY, 0);
/* read OUT1 & OUT2 volumes */ out1 = &priv->out1; @@ -1552,10 +1552,10 @@ static int wm8350_codec_probe(struct snd_soc_codec *codec) return 0; }
-static int wm8350_codec_remove(struct snd_soc_codec *codec) +static void wm8350_component_remove(struct snd_soc_component *component) { - struct wm8350_data *priv = snd_soc_codec_get_drvdata(codec); - struct wm8350 *wm8350 = dev_get_platdata(codec->dev); + struct wm8350_data *priv = snd_soc_component_get_drvdata(component); + struct wm8350 *wm8350 = dev_get_platdata(component->dev);
wm8350_clear_bits(wm8350, WM8350_JACK_DETECT, WM8350_JDL_ENA | WM8350_JDR_ENA); @@ -1578,44 +1578,37 @@ static int wm8350_codec_remove(struct snd_soc_codec *codec) flush_delayed_work(&priv->pga_work);
wm8350_clear_bits(wm8350, WM8350_POWER_MGMT_5, WM8350_CODEC_ENA); - - return 0; }
-static const struct snd_soc_codec_driver soc_codec_dev_wm8350 = { - .probe = wm8350_codec_probe, - .remove = wm8350_codec_remove, - .set_bias_level = wm8350_set_bias_level, - .suspend_bias_off = true, - - .component_driver = { - .controls = wm8350_snd_controls, - .num_controls = ARRAY_SIZE(wm8350_snd_controls), - .dapm_widgets = wm8350_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(wm8350_dapm_widgets), - .dapm_routes = wm8350_dapm_routes, - .num_dapm_routes = ARRAY_SIZE(wm8350_dapm_routes), - }, +static const struct snd_soc_component_driver soc_component_dev_wm8350 = { + .probe = wm8350_component_probe, + .remove = wm8350_component_remove, + .set_bias_level = wm8350_set_bias_level, + .controls = wm8350_snd_controls, + .num_controls = ARRAY_SIZE(wm8350_snd_controls), + .dapm_widgets = wm8350_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(wm8350_dapm_widgets), + .dapm_routes = wm8350_dapm_routes, + .num_dapm_routes = ARRAY_SIZE(wm8350_dapm_routes), + .suspend_bias_off = 1, + .idle_bias_on = 1, + .pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, };
static int wm8350_probe(struct platform_device *pdev) { - return snd_soc_register_codec(&pdev->dev, &soc_codec_dev_wm8350, + return devm_snd_soc_register_component(&pdev->dev, + &soc_component_dev_wm8350, &wm8350_dai, 1); }
-static int wm8350_remove(struct platform_device *pdev) -{ - snd_soc_unregister_codec(&pdev->dev); - return 0; -} - static struct platform_driver wm8350_codec_driver = { .driver = { .name = "wm8350-codec", }, .probe = wm8350_probe, - .remove = wm8350_remove, };
module_platform_driver(wm8350_codec_driver); diff --git a/sound/soc/codecs/wm8350.h b/sound/soc/codecs/wm8350.h index 74108eb..1191326 100644 --- a/sound/soc/codecs/wm8350.h +++ b/sound/soc/codecs/wm8350.h @@ -20,9 +20,9 @@ enum wm8350_jack { WM8350_JDR = 2, };
-int wm8350_hp_jack_detect(struct snd_soc_codec *codec, enum wm8350_jack which, +int wm8350_hp_jack_detect(struct snd_soc_component *component, enum wm8350_jack which, struct snd_soc_jack *jack, int report); -int wm8350_mic_jack_detect(struct snd_soc_codec *codec, +int wm8350_mic_jack_detect(struct snd_soc_component *component, struct snd_soc_jack *jack, int detect_report, int short_report);
diff --git a/sound/soc/fsl/wm1133-ev1.c b/sound/soc/fsl/wm1133-ev1.c index cdaf163..2f80b21 100644 --- a/sound/soc/fsl/wm1133-ev1.c +++ b/sound/soc/fsl/wm1133-ev1.c @@ -201,18 +201,18 @@ static int wm1133_ev1_hw_params(struct snd_pcm_substream *substream,
static int wm1133_ev1_init(struct snd_soc_pcm_runtime *rtd) { - struct snd_soc_codec *codec = rtd->codec; + struct snd_soc_component *component = rtd->codec_dai->component;
/* Headphone jack detection */ snd_soc_card_jack_new(rtd->card, "Headphone", SND_JACK_HEADPHONE, &hp_jack, hp_jack_pins, ARRAY_SIZE(hp_jack_pins)); - wm8350_hp_jack_detect(codec, WM8350_JDR, &hp_jack, SND_JACK_HEADPHONE); + wm8350_hp_jack_detect(component, WM8350_JDR, &hp_jack, SND_JACK_HEADPHONE);
/* Microphone jack detection */ snd_soc_card_jack_new(rtd->card, "Microphone", SND_JACK_MICROPHONE | SND_JACK_BTN_0, &mic_jack, mic_jack_pins, ARRAY_SIZE(mic_jack_pins)); - wm8350_mic_jack_detect(codec, &mic_jack, SND_JACK_MICROPHONE, + wm8350_mic_jack_detect(component, &mic_jack, SND_JACK_MICROPHONE, SND_JACK_BTN_0);
snd_soc_dapm_force_enable_pin(&rtd->card->dapm, "Mic Bias");
From: Kuninori Morimoto kuninori.morimoto.gx@renesas.com
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 -> .pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com --- sound/soc/codecs/wm8400.c | 211 ++++++++++++++++++++++------------------------ 1 file changed, 102 insertions(+), 109 deletions(-)
diff --git a/sound/soc/codecs/wm8400.c b/sound/soc/codecs/wm8400.c index a36adf8..7b542a0 100644 --- a/sound/soc/codecs/wm8400.c +++ b/sound/soc/codecs/wm8400.c @@ -65,9 +65,9 @@ struct wm8400_priv { int fll_in, fll_out; };
-static void wm8400_codec_reset(struct snd_soc_codec *codec) +static void wm8400_component_reset(struct snd_soc_component *component) { - struct wm8400_priv *wm8400 = snd_soc_codec_get_drvdata(codec); + struct wm8400_priv *wm8400 = snd_soc_component_get_drvdata(component);
wm8400_reset_codec_reg_cache(wm8400->wm8400); } @@ -91,7 +91,7 @@ static void wm8400_codec_reset(struct snd_soc_codec *codec) static int wm8400_outpga_put_volsw_vu(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); struct soc_mixer_control *mc = (struct soc_mixer_control *)kcontrol->private_value; int reg = mc->reg; @@ -103,8 +103,8 @@ static int wm8400_outpga_put_volsw_vu(struct snd_kcontrol *kcontrol, return ret;
/* now hit the volume update bits (always bit 8) */ - val = snd_soc_read(codec, reg); - return snd_soc_write(codec, reg, val | 0x0100); + val = snd_soc_component_read32(component, reg); + return snd_soc_component_write(component, reg, val | 0x0100); }
#define WM8400_OUTPGA_SINGLE_R_TLV(xname, reg, shift, max, invert, tlv_array) \ @@ -324,7 +324,7 @@ static SOC_ENUM_SINGLE_DECL(wm8400_right_adcmode_enum, static int outmixer_event (struct snd_soc_dapm_widget *w, struct snd_kcontrol * kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); struct soc_mixer_control *mc = (struct soc_mixer_control *)kcontrol->private_value; u32 reg_shift = mc->shift; @@ -333,7 +333,7 @@ static int outmixer_event (struct snd_soc_dapm_widget *w,
switch (reg_shift) { case WM8400_SPEAKER_MIXER | (WM8400_LDSPK << 8) : - reg = snd_soc_read(codec, WM8400_OUTPUT_MIXER1); + reg = snd_soc_component_read32(component, WM8400_OUTPUT_MIXER1); if (reg & WM8400_LDLO) { printk(KERN_WARNING "Cannot set as Output Mixer 1 LDLO Set\n"); @@ -341,7 +341,7 @@ static int outmixer_event (struct snd_soc_dapm_widget *w, } break; case WM8400_SPEAKER_MIXER | (WM8400_RDSPK << 8): - reg = snd_soc_read(codec, WM8400_OUTPUT_MIXER2); + reg = snd_soc_component_read32(component, WM8400_OUTPUT_MIXER2); if (reg & WM8400_RDRO) { printk(KERN_WARNING "Cannot set as Output Mixer 2 RDRO Set\n"); @@ -349,7 +349,7 @@ static int outmixer_event (struct snd_soc_dapm_widget *w, } break; case WM8400_OUTPUT_MIXER1 | (WM8400_LDLO << 8): - reg = snd_soc_read(codec, WM8400_SPEAKER_MIXER); + reg = snd_soc_component_read32(component, WM8400_SPEAKER_MIXER); if (reg & WM8400_LDSPK) { printk(KERN_WARNING "Cannot set as Speaker Mixer LDSPK Set\n"); @@ -357,7 +357,7 @@ static int outmixer_event (struct snd_soc_dapm_widget *w, } break; case WM8400_OUTPUT_MIXER2 | (WM8400_RDRO << 8): - reg = snd_soc_read(codec, WM8400_SPEAKER_MIXER); + reg = snd_soc_component_read32(component, WM8400_SPEAKER_MIXER); if (reg & WM8400_RDSPK) { printk(KERN_WARNING "Cannot set as Speaker Mixer RDSPK Set\n"); @@ -849,8 +849,8 @@ static SOC_ENUM_SINGLE_DECL(wm8400_ainrmux_enum, static int wm8400_set_dai_sysclk(struct snd_soc_dai *codec_dai, int clk_id, unsigned int freq, int dir) { - struct snd_soc_codec *codec = codec_dai->codec; - struct wm8400_priv *wm8400 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = codec_dai->component; + struct wm8400_priv *wm8400 = snd_soc_component_get_drvdata(component);
wm8400->sysclk = freq; return 0; @@ -938,8 +938,8 @@ static int wm8400_set_dai_pll(struct snd_soc_dai *codec_dai, int pll_id, int source, unsigned int freq_in, unsigned int freq_out) { - struct snd_soc_codec *codec = codec_dai->codec; - struct wm8400_priv *wm8400 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = codec_dai->component; + struct wm8400_priv *wm8400 = snd_soc_component_get_drvdata(component); struct fll_factors factors; int ret; u16 reg; @@ -962,13 +962,13 @@ static int wm8400_set_dai_pll(struct snd_soc_dai *codec_dai, int pll_id, wm8400->fll_in = freq_in;
/* We *must* disable the FLL before any changes */ - reg = snd_soc_read(codec, WM8400_POWER_MANAGEMENT_2); + reg = snd_soc_component_read32(component, WM8400_POWER_MANAGEMENT_2); reg &= ~WM8400_FLL_ENA; - snd_soc_write(codec, WM8400_POWER_MANAGEMENT_2, reg); + snd_soc_component_write(component, WM8400_POWER_MANAGEMENT_2, reg);
- reg = snd_soc_read(codec, WM8400_FLL_CONTROL_1); + reg = snd_soc_component_read32(component, WM8400_FLL_CONTROL_1); reg &= ~WM8400_FLL_OSC_ENA; - snd_soc_write(codec, WM8400_FLL_CONTROL_1, reg); + snd_soc_component_write(component, WM8400_FLL_CONTROL_1, reg);
if (!freq_out) return 0; @@ -976,15 +976,15 @@ static int wm8400_set_dai_pll(struct snd_soc_dai *codec_dai, int pll_id, reg &= ~(WM8400_FLL_REF_FREQ | WM8400_FLL_FRATIO_MASK); reg |= WM8400_FLL_FRAC | factors.fratio; reg |= factors.freq_ref << WM8400_FLL_REF_FREQ_SHIFT; - snd_soc_write(codec, WM8400_FLL_CONTROL_1, reg); + snd_soc_component_write(component, WM8400_FLL_CONTROL_1, reg);
- snd_soc_write(codec, WM8400_FLL_CONTROL_2, factors.k); - snd_soc_write(codec, WM8400_FLL_CONTROL_3, factors.n); + snd_soc_component_write(component, WM8400_FLL_CONTROL_2, factors.k); + snd_soc_component_write(component, WM8400_FLL_CONTROL_3, factors.n);
- reg = snd_soc_read(codec, WM8400_FLL_CONTROL_4); + reg = snd_soc_component_read32(component, WM8400_FLL_CONTROL_4); reg &= ~WM8400_FLL_OUTDIV_MASK; reg |= factors.outdiv; - snd_soc_write(codec, WM8400_FLL_CONTROL_4, reg); + snd_soc_component_write(component, WM8400_FLL_CONTROL_4, reg);
return 0; } @@ -995,11 +995,11 @@ static int wm8400_set_dai_pll(struct snd_soc_dai *codec_dai, int pll_id, static int wm8400_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt) { - struct snd_soc_codec *codec = codec_dai->codec; + struct snd_soc_component *component = codec_dai->component; u16 audio1, audio3;
- audio1 = snd_soc_read(codec, WM8400_AUDIO_INTERFACE_1); - audio3 = snd_soc_read(codec, WM8400_AUDIO_INTERFACE_3); + audio1 = snd_soc_component_read32(component, WM8400_AUDIO_INTERFACE_1); + audio3 = snd_soc_component_read32(component, WM8400_AUDIO_INTERFACE_3);
/* set master/slave audio interface */ switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { @@ -1040,37 +1040,37 @@ static int wm8400_set_dai_fmt(struct snd_soc_dai *codec_dai, return -EINVAL; }
- snd_soc_write(codec, WM8400_AUDIO_INTERFACE_1, audio1); - snd_soc_write(codec, WM8400_AUDIO_INTERFACE_3, audio3); + snd_soc_component_write(component, WM8400_AUDIO_INTERFACE_1, audio1); + snd_soc_component_write(component, WM8400_AUDIO_INTERFACE_3, audio3); return 0; }
static int wm8400_set_dai_clkdiv(struct snd_soc_dai *codec_dai, int div_id, int div) { - struct snd_soc_codec *codec = codec_dai->codec; + struct snd_soc_component *component = codec_dai->component; u16 reg;
switch (div_id) { case WM8400_MCLK_DIV: - reg = snd_soc_read(codec, WM8400_CLOCKING_2) & + reg = snd_soc_component_read32(component, WM8400_CLOCKING_2) & ~WM8400_MCLK_DIV_MASK; - snd_soc_write(codec, WM8400_CLOCKING_2, reg | div); + snd_soc_component_write(component, WM8400_CLOCKING_2, reg | div); break; case WM8400_DACCLK_DIV: - reg = snd_soc_read(codec, WM8400_CLOCKING_2) & + reg = snd_soc_component_read32(component, WM8400_CLOCKING_2) & ~WM8400_DAC_CLKDIV_MASK; - snd_soc_write(codec, WM8400_CLOCKING_2, reg | div); + snd_soc_component_write(component, WM8400_CLOCKING_2, reg | div); break; case WM8400_ADCCLK_DIV: - reg = snd_soc_read(codec, WM8400_CLOCKING_2) & + reg = snd_soc_component_read32(component, WM8400_CLOCKING_2) & ~WM8400_ADC_CLKDIV_MASK; - snd_soc_write(codec, WM8400_CLOCKING_2, reg | div); + snd_soc_component_write(component, WM8400_CLOCKING_2, reg | div); break; case WM8400_BCLK_DIV: - reg = snd_soc_read(codec, WM8400_CLOCKING_1) & + reg = snd_soc_component_read32(component, WM8400_CLOCKING_1) & ~WM8400_BCLK_DIV_MASK; - snd_soc_write(codec, WM8400_CLOCKING_1, reg | div); + snd_soc_component_write(component, WM8400_CLOCKING_1, reg | div); break; default: return -EINVAL; @@ -1086,8 +1086,8 @@ static int wm8400_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; - u16 audio1 = snd_soc_read(codec, WM8400_AUDIO_INTERFACE_1); + struct snd_soc_component *component = dai->component; + u16 audio1 = snd_soc_component_read32(component, WM8400_AUDIO_INTERFACE_1);
audio1 &= ~WM8400_AIF_WL_MASK; /* bit size */ @@ -1105,28 +1105,28 @@ static int wm8400_hw_params(struct snd_pcm_substream *substream, break; }
- snd_soc_write(codec, WM8400_AUDIO_INTERFACE_1, audio1); + snd_soc_component_write(component, WM8400_AUDIO_INTERFACE_1, audio1); return 0; }
static int wm8400_mute(struct snd_soc_dai *dai, int mute) { - struct snd_soc_codec *codec = dai->codec; - u16 val = snd_soc_read(codec, WM8400_DAC_CTRL) & ~WM8400_DAC_MUTE; + struct snd_soc_component *component = dai->component; + u16 val = snd_soc_component_read32(component, WM8400_DAC_CTRL) & ~WM8400_DAC_MUTE;
if (mute) - snd_soc_write(codec, WM8400_DAC_CTRL, val | WM8400_DAC_MUTE); + snd_soc_component_write(component, WM8400_DAC_CTRL, val | WM8400_DAC_MUTE); else - snd_soc_write(codec, WM8400_DAC_CTRL, val); + snd_soc_component_write(component, WM8400_DAC_CTRL, val);
return 0; }
/* TODO: set bias for best performance at standby */ -static int wm8400_set_bias_level(struct snd_soc_codec *codec, +static int wm8400_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { - struct wm8400_priv *wm8400 = snd_soc_codec_get_drvdata(codec); + struct wm8400_priv *wm8400 = snd_soc_component_get_drvdata(component); u16 val; int ret;
@@ -1136,13 +1136,13 @@ static int wm8400_set_bias_level(struct snd_soc_codec *codec,
case SND_SOC_BIAS_PREPARE: /* VMID=2*50k */ - val = snd_soc_read(codec, WM8400_POWER_MANAGEMENT_1) & + val = snd_soc_component_read32(component, WM8400_POWER_MANAGEMENT_1) & ~WM8400_VMID_MODE_MASK; - snd_soc_write(codec, WM8400_POWER_MANAGEMENT_1, val | 0x2); + snd_soc_component_write(component, WM8400_POWER_MANAGEMENT_1, val | 0x2); break;
case SND_SOC_BIAS_STANDBY: - if (snd_soc_codec_get_bias_level(codec) == SND_SOC_BIAS_OFF) { + if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_OFF) { ret = regulator_bulk_enable(ARRAY_SIZE(power), &power[0]); if (ret != 0) { @@ -1152,74 +1152,74 @@ static int wm8400_set_bias_level(struct snd_soc_codec *codec, return ret; }
- snd_soc_write(codec, WM8400_POWER_MANAGEMENT_1, + snd_soc_component_write(component, WM8400_POWER_MANAGEMENT_1, WM8400_CODEC_ENA | WM8400_SYSCLK_ENA);
/* Enable POBCTRL, SOFT_ST, VMIDTOG and BUFDCOPEN */ - snd_soc_write(codec, WM8400_ANTIPOP2, WM8400_SOFTST | + snd_soc_component_write(component, WM8400_ANTIPOP2, WM8400_SOFTST | WM8400_BUFDCOPEN | WM8400_POBCTRL);
msleep(50);
/* Enable VREF & VMID at 2x50k */ - val = snd_soc_read(codec, WM8400_POWER_MANAGEMENT_1); + val = snd_soc_component_read32(component, WM8400_POWER_MANAGEMENT_1); val |= 0x2 | WM8400_VREF_ENA; - snd_soc_write(codec, WM8400_POWER_MANAGEMENT_1, val); + snd_soc_component_write(component, WM8400_POWER_MANAGEMENT_1, val);
/* Enable BUFIOEN */ - snd_soc_write(codec, WM8400_ANTIPOP2, WM8400_SOFTST | + snd_soc_component_write(component, WM8400_ANTIPOP2, WM8400_SOFTST | WM8400_BUFDCOPEN | WM8400_POBCTRL | WM8400_BUFIOEN);
/* disable POBCTRL, SOFT_ST and BUFDCOPEN */ - snd_soc_write(codec, WM8400_ANTIPOP2, WM8400_BUFIOEN); + snd_soc_component_write(component, WM8400_ANTIPOP2, WM8400_BUFIOEN); }
/* VMID=2*300k */ - val = snd_soc_read(codec, WM8400_POWER_MANAGEMENT_1) & + val = snd_soc_component_read32(component, WM8400_POWER_MANAGEMENT_1) & ~WM8400_VMID_MODE_MASK; - snd_soc_write(codec, WM8400_POWER_MANAGEMENT_1, val | 0x4); + snd_soc_component_write(component, WM8400_POWER_MANAGEMENT_1, val | 0x4); break;
case SND_SOC_BIAS_OFF: /* Enable POBCTRL and SOFT_ST */ - snd_soc_write(codec, WM8400_ANTIPOP2, WM8400_SOFTST | + snd_soc_component_write(component, WM8400_ANTIPOP2, WM8400_SOFTST | WM8400_POBCTRL | WM8400_BUFIOEN);
/* Enable POBCTRL, SOFT_ST and BUFDCOPEN */ - snd_soc_write(codec, WM8400_ANTIPOP2, WM8400_SOFTST | + snd_soc_component_write(component, WM8400_ANTIPOP2, WM8400_SOFTST | WM8400_BUFDCOPEN | WM8400_POBCTRL | WM8400_BUFIOEN);
/* mute DAC */ - val = snd_soc_read(codec, WM8400_DAC_CTRL); - snd_soc_write(codec, WM8400_DAC_CTRL, val | WM8400_DAC_MUTE); + val = snd_soc_component_read32(component, WM8400_DAC_CTRL); + snd_soc_component_write(component, WM8400_DAC_CTRL, val | WM8400_DAC_MUTE);
/* Enable any disabled outputs */ - val = snd_soc_read(codec, WM8400_POWER_MANAGEMENT_1); + val = snd_soc_component_read32(component, WM8400_POWER_MANAGEMENT_1); val |= WM8400_SPK_ENA | WM8400_OUT3_ENA | WM8400_OUT4_ENA | WM8400_LOUT_ENA | WM8400_ROUT_ENA; - snd_soc_write(codec, WM8400_POWER_MANAGEMENT_1, val); + snd_soc_component_write(component, WM8400_POWER_MANAGEMENT_1, val);
/* Disable VMID */ val &= ~WM8400_VMID_MODE_MASK; - snd_soc_write(codec, WM8400_POWER_MANAGEMENT_1, val); + snd_soc_component_write(component, WM8400_POWER_MANAGEMENT_1, val);
msleep(300);
/* Enable all output discharge bits */ - snd_soc_write(codec, WM8400_ANTIPOP1, WM8400_DIS_LLINE | + snd_soc_component_write(component, WM8400_ANTIPOP1, WM8400_DIS_LLINE | WM8400_DIS_RLINE | WM8400_DIS_OUT3 | WM8400_DIS_OUT4 | WM8400_DIS_LOUT | WM8400_DIS_ROUT);
/* Disable VREF */ val &= ~WM8400_VREF_ENA; - snd_soc_write(codec, WM8400_POWER_MANAGEMENT_1, val); + snd_soc_component_write(component, WM8400_POWER_MANAGEMENT_1, val);
/* disable POBCTRL, SOFT_ST and BUFDCOPEN */ - snd_soc_write(codec, WM8400_ANTIPOP2, 0x0); + snd_soc_component_write(component, WM8400_ANTIPOP2, 0x0);
ret = regulator_bulk_disable(ARRAY_SIZE(power), &power[0]); @@ -1273,93 +1273,86 @@ static int wm8400_set_bias_level(struct snd_soc_codec *codec, .ops = &wm8400_dai_ops, };
-static int wm8400_codec_probe(struct snd_soc_codec *codec) +static int wm8400_component_probe(struct snd_soc_component *component) { - struct wm8400 *wm8400 = dev_get_platdata(codec->dev); + struct wm8400 *wm8400 = dev_get_platdata(component->dev); struct wm8400_priv *priv; int ret; u16 reg;
- priv = devm_kzalloc(codec->dev, sizeof(struct wm8400_priv), + priv = devm_kzalloc(component->dev, sizeof(struct wm8400_priv), GFP_KERNEL); if (priv == NULL) return -ENOMEM;
- snd_soc_codec_init_regmap(codec, wm8400->regmap); - snd_soc_codec_set_drvdata(codec, priv); + snd_soc_component_init_regmap(component, wm8400->regmap); + snd_soc_component_set_drvdata(component, priv); priv->wm8400 = wm8400;
ret = devm_regulator_bulk_get(wm8400->dev, ARRAY_SIZE(power), &power[0]); if (ret != 0) { - dev_err(codec->dev, "Failed to get regulators: %d\n", ret); + dev_err(component->dev, "Failed to get regulators: %d\n", ret); return ret; }
- wm8400_codec_reset(codec); + wm8400_component_reset(component);
- reg = snd_soc_read(codec, WM8400_POWER_MANAGEMENT_1); - snd_soc_write(codec, WM8400_POWER_MANAGEMENT_1, reg | WM8400_CODEC_ENA); + reg = snd_soc_component_read32(component, WM8400_POWER_MANAGEMENT_1); + snd_soc_component_write(component, WM8400_POWER_MANAGEMENT_1, reg | WM8400_CODEC_ENA);
/* Latch volume update bits */ - reg = snd_soc_read(codec, WM8400_LEFT_LINE_INPUT_1_2_VOLUME); - snd_soc_write(codec, WM8400_LEFT_LINE_INPUT_1_2_VOLUME, + reg = snd_soc_component_read32(component, WM8400_LEFT_LINE_INPUT_1_2_VOLUME); + snd_soc_component_write(component, WM8400_LEFT_LINE_INPUT_1_2_VOLUME, reg & WM8400_IPVU); - reg = snd_soc_read(codec, WM8400_RIGHT_LINE_INPUT_1_2_VOLUME); - snd_soc_write(codec, WM8400_RIGHT_LINE_INPUT_1_2_VOLUME, + reg = snd_soc_component_read32(component, WM8400_RIGHT_LINE_INPUT_1_2_VOLUME); + snd_soc_component_write(component, WM8400_RIGHT_LINE_INPUT_1_2_VOLUME, reg & WM8400_IPVU);
- snd_soc_write(codec, WM8400_LEFT_OUTPUT_VOLUME, 0x50 | (1<<8)); - snd_soc_write(codec, WM8400_RIGHT_OUTPUT_VOLUME, 0x50 | (1<<8)); + snd_soc_component_write(component, WM8400_LEFT_OUTPUT_VOLUME, 0x50 | (1<<8)); + snd_soc_component_write(component, WM8400_RIGHT_OUTPUT_VOLUME, 0x50 | (1<<8));
return 0; }
-static int wm8400_codec_remove(struct snd_soc_codec *codec) +static void wm8400_component_remove(struct snd_soc_component *component) { u16 reg;
- reg = snd_soc_read(codec, WM8400_POWER_MANAGEMENT_1); - snd_soc_write(codec, WM8400_POWER_MANAGEMENT_1, + reg = snd_soc_component_read32(component, WM8400_POWER_MANAGEMENT_1); + snd_soc_component_write(component, WM8400_POWER_MANAGEMENT_1, reg & (~WM8400_CODEC_ENA)); - - return 0; }
-static const struct snd_soc_codec_driver soc_codec_dev_wm8400 = { - .probe = wm8400_codec_probe, - .remove = wm8400_codec_remove, - .set_bias_level = wm8400_set_bias_level, - .suspend_bias_off = true, - - .component_driver = { - .controls = wm8400_snd_controls, - .num_controls = ARRAY_SIZE(wm8400_snd_controls), - .dapm_widgets = wm8400_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(wm8400_dapm_widgets), - .dapm_routes = wm8400_dapm_routes, - .num_dapm_routes = ARRAY_SIZE(wm8400_dapm_routes), - }, +static const struct snd_soc_component_driver soc_component_dev_wm8400 = { + .probe = wm8400_component_probe, + .remove = wm8400_component_remove, + .set_bias_level = wm8400_set_bias_level, + .controls = wm8400_snd_controls, + .num_controls = ARRAY_SIZE(wm8400_snd_controls), + .dapm_widgets = wm8400_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(wm8400_dapm_widgets), + .dapm_routes = wm8400_dapm_routes, + .num_dapm_routes = ARRAY_SIZE(wm8400_dapm_routes), + .suspend_bias_off = 1, + .idle_bias_on = 1, + .pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, };
static int wm8400_probe(struct platform_device *pdev) { - return snd_soc_register_codec(&pdev->dev, &soc_codec_dev_wm8400, + return snd_soc_register_component(&pdev->dev, + &soc_component_dev_wm8400, &wm8400_dai, 1); }
-static int wm8400_remove(struct platform_device *pdev) -{ - snd_soc_unregister_codec(&pdev->dev); - return 0; -} - static struct platform_driver wm8400_codec_driver = { .driver = { .name = "wm8400-codec", }, .probe = wm8400_probe, - .remove = wm8400_remove, };
module_platform_driver(wm8400_codec_driver);
From: Kuninori Morimoto kuninori.morimoto.gx@renesas.com
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 -> .pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com --- sound/soc/codecs/wm8580.c | 150 ++++++++++++++++++++++------------------------ 1 file changed, 71 insertions(+), 79 deletions(-)
diff --git a/sound/soc/codecs/wm8580.c b/sound/soc/codecs/wm8580.c index 910801d..37b141e 100644 --- a/sound/soc/codecs/wm8580.c +++ b/sound/soc/codecs/wm8580.c @@ -262,8 +262,8 @@ static int wm8580_out_vu(struct snd_kcontrol *kcontrol, { struct soc_mixer_control *mc = (struct soc_mixer_control *)kcontrol->private_value; - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct wm8580_priv *wm8580 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct wm8580_priv *wm8580 = snd_soc_component_get_drvdata(component); unsigned int reg = mc->reg; unsigned int reg2 = mc->rreg; int ret; @@ -279,8 +279,8 @@ static int wm8580_out_vu(struct snd_kcontrol *kcontrol, return ret;
/* Now write again with the volume update bit set */ - snd_soc_update_bits(codec, reg, 0x100, 0x100); - snd_soc_update_bits(codec, reg2, 0x100, 0x100); + snd_soc_component_update_bits(component, reg, 0x100, 0x100); + snd_soc_component_update_bits(component, reg2, 0x100, 0x100);
return 0; } @@ -465,8 +465,8 @@ static int wm8580_set_dai_pll(struct snd_soc_dai *codec_dai, int pll_id, int source, unsigned int freq_in, unsigned int freq_out) { int offset; - struct snd_soc_codec *codec = codec_dai->codec; - struct wm8580_priv *wm8580 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = codec_dai->component; + struct wm8580_priv *wm8580 = snd_soc_component_get_drvdata(component); struct pll_state *state; struct _pll_div pll_div; unsigned int reg; @@ -505,25 +505,25 @@ static int wm8580_set_dai_pll(struct snd_soc_dai *codec_dai, int pll_id, /* Always disable the PLL - it is not safe to leave it running * while reprogramming it. */ - snd_soc_update_bits(codec, WM8580_PWRDN2, pwr_mask, pwr_mask); + snd_soc_component_update_bits(component, WM8580_PWRDN2, pwr_mask, pwr_mask);
if (!freq_in || !freq_out) return 0;
- snd_soc_write(codec, WM8580_PLLA1 + offset, pll_div.k & 0x1ff); - snd_soc_write(codec, WM8580_PLLA2 + offset, (pll_div.k >> 9) & 0x1ff); - snd_soc_write(codec, WM8580_PLLA3 + offset, + snd_soc_component_write(component, WM8580_PLLA1 + offset, pll_div.k & 0x1ff); + snd_soc_component_write(component, WM8580_PLLA2 + offset, (pll_div.k >> 9) & 0x1ff); + snd_soc_component_write(component, WM8580_PLLA3 + offset, (pll_div.k >> 18 & 0xf) | (pll_div.n << 4));
- reg = snd_soc_read(codec, WM8580_PLLA4 + offset); + reg = snd_soc_component_read32(component, WM8580_PLLA4 + offset); reg &= ~0x1b; reg |= pll_div.prescale | pll_div.postscale << 1 | pll_div.freqmode << 3;
- snd_soc_write(codec, WM8580_PLLA4 + offset, reg); + snd_soc_component_write(component, WM8580_PLLA4 + offset, reg);
/* All done, turn it on */ - snd_soc_update_bits(codec, WM8580_PWRDN2, pwr_mask, 0); + snd_soc_component_update_bits(component, WM8580_PWRDN2, pwr_mask, 0);
return 0; } @@ -539,8 +539,8 @@ static int wm8580_paif_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; - struct wm8580_priv *wm8580 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct wm8580_priv *wm8580 = snd_soc_component_get_drvdata(component); u16 paifa = 0; u16 paifb = 0; int i, ratio, osr; @@ -572,12 +572,12 @@ static int wm8580_paif_hw_params(struct snd_pcm_substream *substream, if (ratio == wm8580_sysclk_ratios[i]) break; if (i == ARRAY_SIZE(wm8580_sysclk_ratios)) { - dev_err(codec->dev, "Invalid clock ratio %d/%d\n", + dev_err(component->dev, "Invalid clock ratio %d/%d\n", wm8580->sysclk[dai->driver->id], params_rate(params)); return -EINVAL; } paifa |= i; - dev_dbg(codec->dev, "Running at %dfs with %dHz clock\n", + dev_dbg(component->dev, "Running at %dfs with %dHz clock\n", wm8580_sysclk_ratios[i], wm8580->sysclk[dai->driver->id]);
if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { @@ -585,21 +585,21 @@ static int wm8580_paif_hw_params(struct snd_pcm_substream *substream, case 128: case 192: osr = WM8580_DACOSR; - dev_dbg(codec->dev, "Selecting 64x OSR\n"); + dev_dbg(component->dev, "Selecting 64x OSR\n"); break; default: osr = 0; - dev_dbg(codec->dev, "Selecting 128x OSR\n"); + dev_dbg(component->dev, "Selecting 128x OSR\n"); break; }
- snd_soc_update_bits(codec, WM8580_PAIF3, WM8580_DACOSR, osr); + snd_soc_component_update_bits(component, WM8580_PAIF3, WM8580_DACOSR, osr); }
- snd_soc_update_bits(codec, WM8580_PAIF1 + dai->driver->id, + snd_soc_component_update_bits(component, WM8580_PAIF1 + dai->driver->id, WM8580_AIF_RATE_MASK | WM8580_AIF_BCLKSEL_MASK, paifa); - snd_soc_update_bits(codec, WM8580_PAIF3 + dai->driver->id, + snd_soc_component_update_bits(component, WM8580_PAIF3 + dai->driver->id, WM8580_AIF_LENGTH_MASK, paifb); return 0; } @@ -607,13 +607,13 @@ static int wm8580_paif_hw_params(struct snd_pcm_substream *substream, static int wm8580_set_paif_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt) { - struct snd_soc_codec *codec = codec_dai->codec; + struct snd_soc_component *component = codec_dai->component; unsigned int aifa; unsigned int aifb; int can_invert_lrclk;
- aifa = snd_soc_read(codec, WM8580_PAIF1 + codec_dai->driver->id); - aifb = snd_soc_read(codec, WM8580_PAIF3 + codec_dai->driver->id); + aifa = snd_soc_component_read32(component, WM8580_PAIF1 + codec_dai->driver->id); + aifb = snd_soc_component_read32(component, WM8580_PAIF3 + codec_dai->driver->id);
aifb &= ~(WM8580_AIF_FMT_MASK | WM8580_AIF_LRP | WM8580_AIF_BCP);
@@ -679,8 +679,8 @@ static int wm8580_set_paif_dai_fmt(struct snd_soc_dai *codec_dai, return -EINVAL; }
- snd_soc_write(codec, WM8580_PAIF1 + codec_dai->driver->id, aifa); - snd_soc_write(codec, WM8580_PAIF3 + codec_dai->driver->id, aifb); + snd_soc_component_write(component, WM8580_PAIF1 + codec_dai->driver->id, aifa); + snd_soc_component_write(component, WM8580_PAIF3 + codec_dai->driver->id, aifb);
return 0; } @@ -688,12 +688,12 @@ static int wm8580_set_paif_dai_fmt(struct snd_soc_dai *codec_dai, static int wm8580_set_dai_clkdiv(struct snd_soc_dai *codec_dai, int div_id, int div) { - struct snd_soc_codec *codec = codec_dai->codec; + struct snd_soc_component *component = codec_dai->component; unsigned int reg;
switch (div_id) { case WM8580_MCLK: - reg = snd_soc_read(codec, WM8580_PLLB4); + reg = snd_soc_component_read32(component, WM8580_PLLB4); reg &= ~WM8580_PLLB4_MCLKOUTSRC_MASK;
switch (div) { @@ -715,11 +715,11 @@ static int wm8580_set_dai_clkdiv(struct snd_soc_dai *codec_dai, default: return -EINVAL; } - snd_soc_write(codec, WM8580_PLLB4, reg); + snd_soc_component_write(component, WM8580_PLLB4, reg); break;
case WM8580_CLKOUTSRC: - reg = snd_soc_read(codec, WM8580_PLLB4); + reg = snd_soc_component_read32(component, WM8580_PLLB4); reg &= ~WM8580_PLLB4_CLKOUTSRC_MASK;
switch (div) { @@ -741,7 +741,7 @@ static int wm8580_set_dai_clkdiv(struct snd_soc_dai *codec_dai, default: return -EINVAL; } - snd_soc_write(codec, WM8580_PLLB4, reg); + snd_soc_component_write(component, WM8580_PLLB4, reg); break;
default: @@ -754,8 +754,8 @@ static int wm8580_set_dai_clkdiv(struct snd_soc_dai *codec_dai, static int wm8580_set_sysclk(struct snd_soc_dai *dai, int clk_id, unsigned int freq, int dir) { - struct snd_soc_codec *codec = dai->codec; - struct wm8580_priv *wm8580 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct wm8580_priv *wm8580 = snd_soc_component_get_drvdata(component); int ret, sel, sel_mask, sel_shift;
switch (dai->driver->id) { @@ -790,14 +790,14 @@ static int wm8580_set_sysclk(struct snd_soc_dai *dai, int clk_id, sel = 3 << sel_shift; break; default: - dev_err(codec->dev, "Unknown clock %d\n", clk_id); + dev_err(component->dev, "Unknown clock %d\n", clk_id); return -EINVAL; }
/* We really should validate PLL settings but not yet */ wm8580->sysclk[dai->driver->id] = freq;
- ret = snd_soc_update_bits(codec, WM8580_CLKSEL, sel_mask, sel); + ret = snd_soc_component_update_bits(component, WM8580_CLKSEL, sel_mask, sel); if (ret < 0) return ret;
@@ -806,22 +806,22 @@ static int wm8580_set_sysclk(struct snd_soc_dai *dai, int clk_id,
static int wm8580_digital_mute(struct snd_soc_dai *codec_dai, int mute) { - struct snd_soc_codec *codec = codec_dai->codec; + struct snd_soc_component *component = codec_dai->component; unsigned int reg;
- reg = snd_soc_read(codec, WM8580_DAC_CONTROL5); + reg = snd_soc_component_read32(component, WM8580_DAC_CONTROL5);
if (mute) reg |= WM8580_DAC_CONTROL5_MUTEALL; else reg &= ~WM8580_DAC_CONTROL5_MUTEALL;
- snd_soc_write(codec, WM8580_DAC_CONTROL5, reg); + snd_soc_component_write(component, WM8580_DAC_CONTROL5, reg);
return 0; }
-static int wm8580_set_bias_level(struct snd_soc_codec *codec, +static int wm8580_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { switch (level) { @@ -830,20 +830,20 @@ static int wm8580_set_bias_level(struct snd_soc_codec *codec, break;
case SND_SOC_BIAS_STANDBY: - if (snd_soc_codec_get_bias_level(codec) == SND_SOC_BIAS_OFF) { + if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_OFF) { /* Power up and get individual control of the DACs */ - snd_soc_update_bits(codec, WM8580_PWRDN1, + snd_soc_component_update_bits(component, WM8580_PWRDN1, WM8580_PWRDN1_PWDN | WM8580_PWRDN1_ALLDACPD, 0);
/* Make VMID high impedance */ - snd_soc_update_bits(codec, WM8580_ADC_CONTROL1, + snd_soc_component_update_bits(component, WM8580_ADC_CONTROL1, 0x100, 0); } break;
case SND_SOC_BIAS_OFF: - snd_soc_update_bits(codec, WM8580_PWRDN1, + snd_soc_component_update_bits(component, WM8580_PWRDN1, WM8580_PWRDN1_PWDN, WM8580_PWRDN1_PWDN); break; } @@ -853,8 +853,8 @@ static int wm8580_set_bias_level(struct snd_soc_codec *codec, static int wm8580_playback_startup(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; - struct wm8580_priv *wm8580 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct wm8580_priv *wm8580 = snd_soc_component_get_drvdata(component);
return snd_pcm_hw_constraint_minmax(substream->runtime, SNDRV_PCM_HW_PARAM_CHANNELS, 1, wm8580->drvdata->num_dacs * 2); @@ -907,15 +907,15 @@ static int wm8580_playback_startup(struct snd_pcm_substream *substream, }, };
-static int wm8580_probe(struct snd_soc_codec *codec) +static int wm8580_probe(struct snd_soc_component *component) { - struct wm8580_priv *wm8580 = snd_soc_codec_get_drvdata(codec); - struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec); + struct wm8580_priv *wm8580 = snd_soc_component_get_drvdata(component); + struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); int ret = 0;
switch (wm8580->drvdata->num_dacs) { case 4: - snd_soc_add_codec_controls(codec, wm8581_snd_controls, + snd_soc_add_component_controls(component, wm8581_snd_controls, ARRAY_SIZE(wm8581_snd_controls)); snd_soc_dapm_new_controls(dapm, wm8581_dapm_widgets, ARRAY_SIZE(wm8581_dapm_widgets)); @@ -929,14 +929,14 @@ static int wm8580_probe(struct snd_soc_codec *codec) ret = regulator_bulk_enable(ARRAY_SIZE(wm8580->supplies), wm8580->supplies); if (ret != 0) { - dev_err(codec->dev, "Failed to enable supplies: %d\n", ret); + dev_err(component->dev, "Failed to enable supplies: %d\n", ret); goto err_regulator_get; }
/* Get the codec into a known state */ - ret = snd_soc_write(codec, WM8580_RESET, 0); + ret = snd_soc_component_write(component, WM8580_RESET, 0); if (ret != 0) { - dev_err(codec->dev, "Failed to reset codec: %d\n", ret); + dev_err(component->dev, "Failed to reset component: %d\n", ret); goto err_regulator_enable; }
@@ -949,28 +949,27 @@ static int wm8580_probe(struct snd_soc_codec *codec) }
/* power down chip */ -static int wm8580_remove(struct snd_soc_codec *codec) +static void wm8580_remove(struct snd_soc_component *component) { - struct wm8580_priv *wm8580 = snd_soc_codec_get_drvdata(codec); + struct wm8580_priv *wm8580 = snd_soc_component_get_drvdata(component);
regulator_bulk_disable(ARRAY_SIZE(wm8580->supplies), wm8580->supplies); - - return 0; }
-static const struct snd_soc_codec_driver soc_codec_dev_wm8580 = { - .probe = wm8580_probe, - .remove = wm8580_remove, - .set_bias_level = wm8580_set_bias_level, - - .component_driver = { - .controls = wm8580_snd_controls, - .num_controls = ARRAY_SIZE(wm8580_snd_controls), - .dapm_widgets = wm8580_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(wm8580_dapm_widgets), - .dapm_routes = wm8580_dapm_routes, - .num_dapm_routes = ARRAY_SIZE(wm8580_dapm_routes), - }, +static const struct snd_soc_component_driver soc_component_dev_wm8580 = { + .probe = wm8580_probe, + .remove = wm8580_remove, + .set_bias_level = wm8580_set_bias_level, + .controls = wm8580_snd_controls, + .num_controls = ARRAY_SIZE(wm8580_snd_controls), + .dapm_widgets = wm8580_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(wm8580_dapm_widgets), + .dapm_routes = wm8580_dapm_routes, + .num_dapm_routes = ARRAY_SIZE(wm8580_dapm_routes), + .idle_bias_on = 1, + .pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, };
static const struct regmap_config wm8580_regmap = { @@ -1037,18 +1036,12 @@ static int wm8580_i2c_probe(struct i2c_client *i2c, return -EINVAL; }
- ret = snd_soc_register_codec(&i2c->dev, - &soc_codec_dev_wm8580, wm8580_dai, ARRAY_SIZE(wm8580_dai)); + ret = devm_snd_soc_register_component(&i2c->dev, + &soc_component_dev_wm8580, wm8580_dai, ARRAY_SIZE(wm8580_dai));
return ret; }
-static int wm8580_i2c_remove(struct i2c_client *client) -{ - snd_soc_unregister_codec(&client->dev); - return 0; -} - static const struct i2c_device_id wm8580_i2c_id[] = { { "wm8580", (kernel_ulong_t)&wm8580_data }, { "wm8581", (kernel_ulong_t)&wm8581_data }, @@ -1062,7 +1055,6 @@ static int wm8580_i2c_remove(struct i2c_client *client) .of_match_table = wm8580_of_match, }, .probe = wm8580_i2c_probe, - .remove = wm8580_i2c_remove, .id_table = wm8580_i2c_id, };
From: Kuninori Morimoto kuninori.morimoto.gx@renesas.com
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 -> .pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com --- sound/soc/codecs/wm8524.c | 56 +++++++++++++++++++++-------------------------- 1 file changed, 25 insertions(+), 31 deletions(-)
diff --git a/sound/soc/codecs/wm8524.c b/sound/soc/codecs/wm8524.c index 856a695..1a90235 100644 --- a/sound/soc/codecs/wm8524.c +++ b/sound/soc/codecs/wm8524.c @@ -62,14 +62,14 @@ struct wm8524_priv { static int wm8524_startup(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; - struct wm8524_priv *wm8524 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct wm8524_priv *wm8524 = snd_soc_component_get_drvdata(component);
/* The set of sample rates that can be supported depends on the * MCLK supplied to the CODEC - enforce this. */ if (!wm8524->sysclk) { - dev_err(codec->dev, + dev_err(component->dev, "No MCLK configured, call set_sysclk() on init\n"); return -EINVAL; } @@ -86,8 +86,8 @@ static int wm8524_startup(struct snd_pcm_substream *substream, static void wm8524_shutdown(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; - struct wm8524_priv *wm8524 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct wm8524_priv *wm8524 = snd_soc_component_get_drvdata(component);
gpiod_set_value_cansleep(wm8524->mute, 0); } @@ -95,8 +95,8 @@ static void wm8524_shutdown(struct snd_pcm_substream *substream, static int wm8524_set_dai_sysclk(struct snd_soc_dai *codec_dai, int clk_id, unsigned int freq, int dir) { - struct snd_soc_codec *codec = codec_dai->codec; - struct wm8524_priv *wm8524 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = codec_dai->component; + struct wm8524_priv *wm8524 = snd_soc_component_get_drvdata(component); unsigned int val; int i, j = 0;
@@ -118,13 +118,13 @@ static int wm8524_set_dai_sysclk(struct snd_soc_dai *codec_dai, case 96000: case 176400: case 192000: - dev_dbg(codec->dev, "Supported sample rate: %dHz\n", + dev_dbg(component->dev, "Supported sample rate: %dHz\n", val); wm8524->rate_constraint_list[j++] = val; wm8524->rate_constraint.count++; break; default: - dev_dbg(codec->dev, "Skipping sample rate: %dHz\n", + dev_dbg(component->dev, "Skipping sample rate: %dHz\n", val); } } @@ -152,7 +152,7 @@ static int wm8524_set_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt)
static int wm8524_mute_stream(struct snd_soc_dai *dai, int mute, int stream) { - struct wm8524_priv *wm8524 = snd_soc_codec_get_drvdata(dai->codec); + struct wm8524_priv *wm8524 = snd_soc_component_get_drvdata(dai->component);
if (wm8524->mute) gpiod_set_value_cansleep(wm8524->mute, mute); @@ -184,9 +184,9 @@ static int wm8524_mute_stream(struct snd_soc_dai *dai, int mute, int stream) .ops = &wm8524_dai_ops, };
-static int wm8524_probe(struct snd_soc_codec *codec) +static int wm8524_probe(struct snd_soc_component *component) { - struct wm8524_priv *wm8524 = snd_soc_codec_get_drvdata(codec); + struct wm8524_priv *wm8524 = snd_soc_component_get_drvdata(component);
wm8524->rate_constraint.list = &wm8524->rate_constraint_list[0]; wm8524->rate_constraint.count = @@ -195,15 +195,16 @@ static int wm8524_probe(struct snd_soc_codec *codec) return 0; }
-static const struct snd_soc_codec_driver soc_codec_dev_wm8524 = { - .probe = wm8524_probe, - - .component_driver = { - .dapm_widgets = wm8524_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(wm8524_dapm_widgets), - .dapm_routes = wm8524_dapm_routes, - .num_dapm_routes = ARRAY_SIZE(wm8524_dapm_routes), - }, +static const struct snd_soc_component_driver soc_component_dev_wm8524 = { + .probe = wm8524_probe, + .dapm_widgets = wm8524_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(wm8524_dapm_widgets), + .dapm_routes = wm8524_dapm_routes, + .num_dapm_routes = ARRAY_SIZE(wm8524_dapm_routes), + .idle_bias_on = 1, + .pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, };
static const struct of_device_id wm8524_of_match[] = { @@ -231,23 +232,16 @@ static int wm8524_codec_probe(struct platform_device *pdev) return ret; }
- ret = snd_soc_register_codec(&pdev->dev, - &soc_codec_dev_wm8524, &wm8524_dai, 1); + ret = devm_snd_soc_register_component(&pdev->dev, + &soc_component_dev_wm8524, &wm8524_dai, 1); if (ret < 0) - dev_err(&pdev->dev, "Failed to register codec: %d\n", ret); + dev_err(&pdev->dev, "Failed to register component: %d\n", ret);
return ret; }
-static int wm8524_codec_remove(struct platform_device *pdev) -{ - snd_soc_unregister_codec(&pdev->dev); - return 0; -} - static struct platform_driver wm8524_codec_driver = { .probe = wm8524_codec_probe, - .remove = wm8524_codec_remove, .driver = { .name = "wm8524-codec", .of_match_table = wm8524_of_match,
On Fri, Jan 12, 2018 at 01:10:38AM +0000, Kuninori Morimoto wrote:
From: Kuninori Morimoto kuninori.morimoto.gx@renesas.com
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 -> .pmdown_time = 1
-> .endianness = 1
-> .non_legacy_dai_naming = 1
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com
Acked-by: Charles Keepax ckeepax@opensource.cirrus.com
Thanks, Charles
From: Kuninori Morimoto kuninori.morimoto.gx@renesas.com
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 -> .pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com --- sound/soc/codecs/wm8510.c | 149 +++++++++++++++++++++------------------------- 1 file changed, 68 insertions(+), 81 deletions(-)
diff --git a/sound/soc/codecs/wm8510.c b/sound/soc/codecs/wm8510.c index 119ceac..1675599 100644 --- a/sound/soc/codecs/wm8510.c +++ b/sound/soc/codecs/wm8510.c @@ -106,7 +106,7 @@ static bool wm8510_volatile(struct device *dev, unsigned int reg) #define WM8510_POWER1_BIASEN 0x08 #define WM8510_POWER1_BUFIOEN 0x10
-#define wm8510_reset(c) snd_soc_write(c, WM8510_RESET, 0) +#define wm8510_reset(c) snd_soc_component_write(c, WM8510_RESET, 0)
/* codec private data */ struct wm8510_priv { @@ -316,32 +316,32 @@ static void pll_factors(unsigned int target, unsigned int source) static int wm8510_set_dai_pll(struct snd_soc_dai *codec_dai, int pll_id, int source, unsigned int freq_in, unsigned int freq_out) { - struct snd_soc_codec *codec = codec_dai->codec; + struct snd_soc_component *component = codec_dai->component; u16 reg;
if (freq_in == 0 || freq_out == 0) { /* Clock CODEC directly from MCLK */ - reg = snd_soc_read(codec, WM8510_CLOCK); - snd_soc_write(codec, WM8510_CLOCK, reg & 0x0ff); + reg = snd_soc_component_read32(component, WM8510_CLOCK); + snd_soc_component_write(component, WM8510_CLOCK, reg & 0x0ff);
/* Turn off PLL */ - reg = snd_soc_read(codec, WM8510_POWER1); - snd_soc_write(codec, WM8510_POWER1, reg & 0x1df); + reg = snd_soc_component_read32(component, WM8510_POWER1); + snd_soc_component_write(component, WM8510_POWER1, reg & 0x1df); return 0; }
pll_factors(freq_out*4, freq_in);
- snd_soc_write(codec, WM8510_PLLN, (pll_div.pre_div << 4) | pll_div.n); - snd_soc_write(codec, WM8510_PLLK1, pll_div.k >> 18); - snd_soc_write(codec, WM8510_PLLK2, (pll_div.k >> 9) & 0x1ff); - snd_soc_write(codec, WM8510_PLLK3, pll_div.k & 0x1ff); - reg = snd_soc_read(codec, WM8510_POWER1); - snd_soc_write(codec, WM8510_POWER1, reg | 0x020); + snd_soc_component_write(component, WM8510_PLLN, (pll_div.pre_div << 4) | pll_div.n); + snd_soc_component_write(component, WM8510_PLLK1, pll_div.k >> 18); + snd_soc_component_write(component, WM8510_PLLK2, (pll_div.k >> 9) & 0x1ff); + snd_soc_component_write(component, WM8510_PLLK3, pll_div.k & 0x1ff); + reg = snd_soc_component_read32(component, WM8510_POWER1); + snd_soc_component_write(component, WM8510_POWER1, reg | 0x020);
/* Run CODEC from PLL instead of MCLK */ - reg = snd_soc_read(codec, WM8510_CLOCK); - snd_soc_write(codec, WM8510_CLOCK, reg | 0x100); + reg = snd_soc_component_read32(component, WM8510_CLOCK); + snd_soc_component_write(component, WM8510_CLOCK, reg | 0x100);
return 0; } @@ -352,29 +352,29 @@ static int wm8510_set_dai_pll(struct snd_soc_dai *codec_dai, int pll_id, static int wm8510_set_dai_clkdiv(struct snd_soc_dai *codec_dai, int div_id, int div) { - struct snd_soc_codec *codec = codec_dai->codec; + struct snd_soc_component *component = codec_dai->component; u16 reg;
switch (div_id) { case WM8510_OPCLKDIV: - reg = snd_soc_read(codec, WM8510_GPIO) & 0x1cf; - snd_soc_write(codec, WM8510_GPIO, reg | div); + reg = snd_soc_component_read32(component, WM8510_GPIO) & 0x1cf; + snd_soc_component_write(component, WM8510_GPIO, reg | div); break; case WM8510_MCLKDIV: - reg = snd_soc_read(codec, WM8510_CLOCK) & 0x11f; - snd_soc_write(codec, WM8510_CLOCK, reg | div); + reg = snd_soc_component_read32(component, WM8510_CLOCK) & 0x11f; + snd_soc_component_write(component, WM8510_CLOCK, reg | div); break; case WM8510_ADCCLK: - reg = snd_soc_read(codec, WM8510_ADC) & 0x1f7; - snd_soc_write(codec, WM8510_ADC, reg | div); + reg = snd_soc_component_read32(component, WM8510_ADC) & 0x1f7; + snd_soc_component_write(component, WM8510_ADC, reg | div); break; case WM8510_DACCLK: - reg = snd_soc_read(codec, WM8510_DAC) & 0x1f7; - snd_soc_write(codec, WM8510_DAC, reg | div); + reg = snd_soc_component_read32(component, WM8510_DAC) & 0x1f7; + snd_soc_component_write(component, WM8510_DAC, reg | div); break; case WM8510_BCLKDIV: - reg = snd_soc_read(codec, WM8510_CLOCK) & 0x1e3; - snd_soc_write(codec, WM8510_CLOCK, reg | div); + reg = snd_soc_component_read32(component, WM8510_CLOCK) & 0x1e3; + snd_soc_component_write(component, WM8510_CLOCK, reg | div); break; default: return -EINVAL; @@ -386,9 +386,9 @@ static int wm8510_set_dai_clkdiv(struct snd_soc_dai *codec_dai, static int wm8510_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt) { - struct snd_soc_codec *codec = codec_dai->codec; + struct snd_soc_component *component = codec_dai->component; u16 iface = 0; - u16 clk = snd_soc_read(codec, WM8510_CLOCK) & 0x1fe; + u16 clk = snd_soc_component_read32(component, WM8510_CLOCK) & 0x1fe;
/* set master/slave audio interface */ switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { @@ -435,8 +435,8 @@ static int wm8510_set_dai_fmt(struct snd_soc_dai *codec_dai, return -EINVAL; }
- snd_soc_write(codec, WM8510_IFACE, iface); - snd_soc_write(codec, WM8510_CLOCK, clk); + snd_soc_component_write(component, WM8510_IFACE, iface); + snd_soc_component_write(component, WM8510_CLOCK, clk); return 0; }
@@ -444,9 +444,9 @@ static int wm8510_pcm_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; - u16 iface = snd_soc_read(codec, WM8510_IFACE) & 0x19f; - u16 adn = snd_soc_read(codec, WM8510_ADD) & 0x1f1; + struct snd_soc_component *component = dai->component; + u16 iface = snd_soc_component_read32(component, WM8510_IFACE) & 0x19f; + u16 adn = snd_soc_component_read32(component, WM8510_ADD) & 0x1f1;
/* bit size */ switch (params_width(params)) { @@ -485,56 +485,56 @@ static int wm8510_pcm_hw_params(struct snd_pcm_substream *substream, break; }
- snd_soc_write(codec, WM8510_IFACE, iface); - snd_soc_write(codec, WM8510_ADD, adn); + snd_soc_component_write(component, WM8510_IFACE, iface); + snd_soc_component_write(component, WM8510_ADD, adn); return 0; }
static int wm8510_mute(struct snd_soc_dai *dai, int mute) { - struct snd_soc_codec *codec = dai->codec; - u16 mute_reg = snd_soc_read(codec, WM8510_DAC) & 0xffbf; + struct snd_soc_component *component = dai->component; + u16 mute_reg = snd_soc_component_read32(component, WM8510_DAC) & 0xffbf;
if (mute) - snd_soc_write(codec, WM8510_DAC, mute_reg | 0x40); + snd_soc_component_write(component, WM8510_DAC, mute_reg | 0x40); else - snd_soc_write(codec, WM8510_DAC, mute_reg); + snd_soc_component_write(component, WM8510_DAC, mute_reg); return 0; }
/* liam need to make this lower power with dapm */ -static int wm8510_set_bias_level(struct snd_soc_codec *codec, +static int wm8510_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { - struct wm8510_priv *wm8510 = snd_soc_codec_get_drvdata(codec); - u16 power1 = snd_soc_read(codec, WM8510_POWER1) & ~0x3; + struct wm8510_priv *wm8510 = snd_soc_component_get_drvdata(component); + u16 power1 = snd_soc_component_read32(component, WM8510_POWER1) & ~0x3;
switch (level) { case SND_SOC_BIAS_ON: case SND_SOC_BIAS_PREPARE: power1 |= 0x1; /* VMID 50k */ - snd_soc_write(codec, WM8510_POWER1, power1); + snd_soc_component_write(component, WM8510_POWER1, power1); break;
case SND_SOC_BIAS_STANDBY: power1 |= WM8510_POWER1_BIASEN | WM8510_POWER1_BUFIOEN;
- if (snd_soc_codec_get_bias_level(codec) == SND_SOC_BIAS_OFF) { + if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_OFF) { regcache_sync(wm8510->regmap);
/* Initial cap charge at VMID 5k */ - snd_soc_write(codec, WM8510_POWER1, power1 | 0x3); + snd_soc_component_write(component, WM8510_POWER1, power1 | 0x3); mdelay(100); }
power1 |= 0x2; /* VMID 500k */ - snd_soc_write(codec, WM8510_POWER1, power1); + snd_soc_component_write(component, WM8510_POWER1, power1); break;
case SND_SOC_BIAS_OFF: - snd_soc_write(codec, WM8510_POWER1, 0); - snd_soc_write(codec, WM8510_POWER2, 0); - snd_soc_write(codec, WM8510_POWER3, 0); + snd_soc_component_write(component, WM8510_POWER1, 0); + snd_soc_component_write(component, WM8510_POWER2, 0); + snd_soc_component_write(component, WM8510_POWER3, 0); break; }
@@ -574,26 +574,27 @@ static int wm8510_set_bias_level(struct snd_soc_codec *codec, .symmetric_rates = 1, };
-static int wm8510_probe(struct snd_soc_codec *codec) +static int wm8510_probe(struct snd_soc_component *component) { - wm8510_reset(codec); + wm8510_reset(component);
return 0; }
-static const struct snd_soc_codec_driver soc_codec_dev_wm8510 = { - .probe = wm8510_probe, - .set_bias_level = wm8510_set_bias_level, - .suspend_bias_off = true, - - .component_driver = { - .controls = wm8510_snd_controls, - .num_controls = ARRAY_SIZE(wm8510_snd_controls), - .dapm_widgets = wm8510_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(wm8510_dapm_widgets), - .dapm_routes = wm8510_dapm_routes, - .num_dapm_routes = ARRAY_SIZE(wm8510_dapm_routes), - }, +static const struct snd_soc_component_driver soc_component_dev_wm8510 = { + .probe = wm8510_probe, + .set_bias_level = wm8510_set_bias_level, + .controls = wm8510_snd_controls, + .num_controls = ARRAY_SIZE(wm8510_snd_controls), + .dapm_widgets = wm8510_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(wm8510_dapm_widgets), + .dapm_routes = wm8510_dapm_routes, + .num_dapm_routes = ARRAY_SIZE(wm8510_dapm_routes), + .suspend_bias_off = 1, + .idle_bias_on = 1, + .pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, };
static const struct of_device_id wm8510_of_match[] = { @@ -631,25 +632,18 @@ static int wm8510_spi_probe(struct spi_device *spi)
spi_set_drvdata(spi, wm8510);
- ret = snd_soc_register_codec(&spi->dev, - &soc_codec_dev_wm8510, &wm8510_dai, 1); + ret = devm_snd_soc_register_component(&spi->dev, + &soc_component_dev_wm8510, &wm8510_dai, 1);
return ret; }
-static int wm8510_spi_remove(struct spi_device *spi) -{ - snd_soc_unregister_codec(&spi->dev); - return 0; -} - static struct spi_driver wm8510_spi_driver = { .driver = { .name = "wm8510", .of_match_table = wm8510_of_match, }, .probe = wm8510_spi_probe, - .remove = wm8510_spi_remove, }; #endif /* CONFIG_SPI_MASTER */
@@ -671,18 +665,12 @@ static int wm8510_i2c_probe(struct i2c_client *i2c,
i2c_set_clientdata(i2c, wm8510);
- ret = snd_soc_register_codec(&i2c->dev, - &soc_codec_dev_wm8510, &wm8510_dai, 1); + ret = devm_snd_soc_register_component(&i2c->dev, + &soc_component_dev_wm8510, &wm8510_dai, 1);
return ret; }
-static int wm8510_i2c_remove(struct i2c_client *client) -{ - snd_soc_unregister_codec(&client->dev); - return 0; -} - static const struct i2c_device_id wm8510_i2c_id[] = { { "wm8510", 0 }, { } @@ -695,7 +683,6 @@ static int wm8510_i2c_remove(struct i2c_client *client) .of_match_table = wm8510_of_match, }, .probe = wm8510_i2c_probe, - .remove = wm8510_i2c_remove, .id_table = wm8510_i2c_id, }; #endif
From: Kuninori Morimoto kuninori.morimoto.gx@renesas.com
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 -> .pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com --- sound/soc/codecs/wm8523.c | 98 ++++++++++++++++++++++------------------------- 1 file changed, 46 insertions(+), 52 deletions(-)
diff --git a/sound/soc/codecs/wm8523.c b/sound/soc/codecs/wm8523.c index c7c33e9..bf60f95 100644 --- a/sound/soc/codecs/wm8523.c +++ b/sound/soc/codecs/wm8523.c @@ -125,14 +125,14 @@ static SOC_ENUM_SINGLE_DECL(wm8523_zc_count, WM8523_ZERO_DETECT, 0, static int wm8523_startup(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; - struct wm8523_priv *wm8523 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct wm8523_priv *wm8523 = snd_soc_component_get_drvdata(component);
/* The set of sample rates that can be supported depends on the * MCLK supplied to the CODEC - enforce this. */ if (!wm8523->sysclk) { - dev_err(codec->dev, + dev_err(component->dev, "No MCLK configured, call set_sysclk() on init\n"); return -EINVAL; } @@ -148,11 +148,11 @@ static int wm8523_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; - struct wm8523_priv *wm8523 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct wm8523_priv *wm8523 = snd_soc_component_get_drvdata(component); int i; - u16 aifctrl1 = snd_soc_read(codec, WM8523_AIF_CTRL1); - u16 aifctrl2 = snd_soc_read(codec, WM8523_AIF_CTRL2); + u16 aifctrl1 = snd_soc_component_read32(component, WM8523_AIF_CTRL1); + u16 aifctrl2 = snd_soc_component_read32(component, WM8523_AIF_CTRL2);
/* Find a supported LRCLK ratio */ for (i = 0; i < ARRAY_SIZE(lrclk_ratios); i++) { @@ -163,7 +163,7 @@ static int wm8523_hw_params(struct snd_pcm_substream *substream,
/* Should never happen, should be handled by constraints */ if (i == ARRAY_SIZE(lrclk_ratios)) { - dev_err(codec->dev, "MCLK/fs ratio %d unsupported\n", + dev_err(component->dev, "MCLK/fs ratio %d unsupported\n", wm8523->sysclk / params_rate(params)); return -EINVAL; } @@ -178,7 +178,7 @@ static int wm8523_hw_params(struct snd_pcm_substream *substream, break;
if (i == ARRAY_SIZE(bclk_ratios)) { - dev_err(codec->dev, + dev_err(component->dev, "No matching BCLK/fs ratio for word length %d\n", params_width(params)); return -EINVAL; @@ -203,8 +203,8 @@ static int wm8523_hw_params(struct snd_pcm_substream *substream, break; }
- snd_soc_write(codec, WM8523_AIF_CTRL1, aifctrl1); - snd_soc_write(codec, WM8523_AIF_CTRL2, aifctrl2); + snd_soc_component_write(component, WM8523_AIF_CTRL1, aifctrl1); + snd_soc_component_write(component, WM8523_AIF_CTRL2, aifctrl2);
return 0; } @@ -212,8 +212,8 @@ static int wm8523_hw_params(struct snd_pcm_substream *substream, static int wm8523_set_dai_sysclk(struct snd_soc_dai *codec_dai, int clk_id, unsigned int freq, int dir) { - struct snd_soc_codec *codec = codec_dai->codec; - struct wm8523_priv *wm8523 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = codec_dai->component; + struct wm8523_priv *wm8523 = snd_soc_component_get_drvdata(component); unsigned int val; int i;
@@ -239,13 +239,13 @@ static int wm8523_set_dai_sysclk(struct snd_soc_dai *codec_dai, case 96000: case 176400: case 192000: - dev_dbg(codec->dev, "Supported sample rate: %dHz\n", + dev_dbg(component->dev, "Supported sample rate: %dHz\n", val); wm8523->rate_constraint_list[i] = val; wm8523->rate_constraint.count++; break; default: - dev_dbg(codec->dev, "Skipping sample rate: %dHz\n", + dev_dbg(component->dev, "Skipping sample rate: %dHz\n", val); } } @@ -261,8 +261,8 @@ static int wm8523_set_dai_sysclk(struct snd_soc_dai *codec_dai, static int wm8523_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt) { - struct snd_soc_codec *codec = codec_dai->codec; - u16 aifctrl1 = snd_soc_read(codec, WM8523_AIF_CTRL1); + struct snd_soc_component *component = codec_dai->component; + u16 aifctrl1 = snd_soc_component_read32(component, WM8523_AIF_CTRL1);
aifctrl1 &= ~(WM8523_BCLK_INV_MASK | WM8523_LRCLK_INV_MASK | WM8523_FMT_MASK | WM8523_AIF_MSTR_MASK); @@ -312,15 +312,15 @@ static int wm8523_set_dai_fmt(struct snd_soc_dai *codec_dai, return -EINVAL; }
- snd_soc_write(codec, WM8523_AIF_CTRL1, aifctrl1); + snd_soc_component_write(component, WM8523_AIF_CTRL1, aifctrl1);
return 0; }
-static int wm8523_set_bias_level(struct snd_soc_codec *codec, +static int wm8523_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { - struct wm8523_priv *wm8523 = snd_soc_codec_get_drvdata(codec); + struct wm8523_priv *wm8523 = snd_soc_component_get_drvdata(component); int ret;
switch (level) { @@ -329,16 +329,16 @@ static int wm8523_set_bias_level(struct snd_soc_codec *codec,
case SND_SOC_BIAS_PREPARE: /* Full power on */ - snd_soc_update_bits(codec, WM8523_PSCTRL1, + snd_soc_component_update_bits(component, WM8523_PSCTRL1, WM8523_SYS_ENA_MASK, 3); break;
case SND_SOC_BIAS_STANDBY: - if (snd_soc_codec_get_bias_level(codec) == SND_SOC_BIAS_OFF) { + if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_OFF) { ret = regulator_bulk_enable(ARRAY_SIZE(wm8523->supplies), wm8523->supplies); if (ret != 0) { - dev_err(codec->dev, + dev_err(component->dev, "Failed to enable supplies: %d\n", ret); return ret; @@ -348,21 +348,21 @@ static int wm8523_set_bias_level(struct snd_soc_codec *codec, regcache_sync(wm8523->regmap);
/* Initial power up */ - snd_soc_update_bits(codec, WM8523_PSCTRL1, + snd_soc_component_update_bits(component, WM8523_PSCTRL1, WM8523_SYS_ENA_MASK, 1);
msleep(100); }
/* Power up to mute */ - snd_soc_update_bits(codec, WM8523_PSCTRL1, + snd_soc_component_update_bits(component, WM8523_PSCTRL1, WM8523_SYS_ENA_MASK, 2);
break;
case SND_SOC_BIAS_OFF: /* The chip runs through the power down sequence for us. */ - snd_soc_update_bits(codec, WM8523_PSCTRL1, + snd_soc_component_update_bits(component, WM8523_PSCTRL1, WM8523_SYS_ENA_MASK, 0); msleep(100);
@@ -397,35 +397,36 @@ static int wm8523_set_bias_level(struct snd_soc_codec *codec, .ops = &wm8523_dai_ops, };
-static int wm8523_probe(struct snd_soc_codec *codec) +static int wm8523_probe(struct snd_soc_component *component) { - struct wm8523_priv *wm8523 = snd_soc_codec_get_drvdata(codec); + struct wm8523_priv *wm8523 = snd_soc_component_get_drvdata(component);
wm8523->rate_constraint.list = &wm8523->rate_constraint_list[0]; wm8523->rate_constraint.count = ARRAY_SIZE(wm8523->rate_constraint_list);
/* Change some default settings - latch VU and enable ZC */ - snd_soc_update_bits(codec, WM8523_DAC_GAINR, + snd_soc_component_update_bits(component, WM8523_DAC_GAINR, WM8523_DACR_VU, WM8523_DACR_VU); - snd_soc_update_bits(codec, WM8523_DAC_CTRL3, WM8523_ZC, WM8523_ZC); + snd_soc_component_update_bits(component, WM8523_DAC_CTRL3, WM8523_ZC, WM8523_ZC);
return 0; }
-static const struct snd_soc_codec_driver soc_codec_dev_wm8523 = { - .probe = wm8523_probe, - .set_bias_level = wm8523_set_bias_level, - .suspend_bias_off = true, - - .component_driver = { - .controls = wm8523_controls, - .num_controls = ARRAY_SIZE(wm8523_controls), - .dapm_widgets = wm8523_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(wm8523_dapm_widgets), - .dapm_routes = wm8523_dapm_routes, - .num_dapm_routes = ARRAY_SIZE(wm8523_dapm_routes), - }, +static const struct snd_soc_component_driver soc_component_dev_wm8523 = { + .probe = wm8523_probe, + .set_bias_level = wm8523_set_bias_level, + .controls = wm8523_controls, + .num_controls = ARRAY_SIZE(wm8523_controls), + .dapm_widgets = wm8523_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(wm8523_dapm_widgets), + .dapm_routes = wm8523_dapm_routes, + .num_dapm_routes = ARRAY_SIZE(wm8523_dapm_routes), + .suspend_bias_off = 1, + .idle_bias_on = 1, + .pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, };
static const struct of_device_id wm8523_of_match[] = { @@ -511,8 +512,8 @@ static int wm8523_i2c_probe(struct i2c_client *i2c,
i2c_set_clientdata(i2c, wm8523);
- ret = snd_soc_register_codec(&i2c->dev, - &soc_codec_dev_wm8523, &wm8523_dai, 1); + ret = devm_snd_soc_register_component(&i2c->dev, + &soc_component_dev_wm8523, &wm8523_dai, 1);
return ret;
@@ -521,12 +522,6 @@ static int wm8523_i2c_probe(struct i2c_client *i2c, return ret; }
-static int wm8523_i2c_remove(struct i2c_client *client) -{ - snd_soc_unregister_codec(&client->dev); - return 0; -} - static const struct i2c_device_id wm8523_i2c_id[] = { { "wm8523", 0 }, { } @@ -539,7 +534,6 @@ static int wm8523_i2c_remove(struct i2c_client *client) .of_match_table = wm8523_of_match, }, .probe = wm8523_i2c_probe, - .remove = wm8523_i2c_remove, .id_table = wm8523_i2c_id, };
From: Kuninori Morimoto kuninori.morimoto.gx@renesas.com
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 -> .pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com --- sound/soc/codecs/wm8711.c | 116 ++++++++++++++++++++-------------------------- 1 file changed, 51 insertions(+), 65 deletions(-)
diff --git a/sound/soc/codecs/wm8711.c b/sound/soc/codecs/wm8711.c index 2b376c9..fe7a40a 100644 --- a/sound/soc/codecs/wm8711.c +++ b/sound/soc/codecs/wm8711.c @@ -58,7 +58,7 @@ static bool wm8711_volatile(struct device *dev, unsigned int reg) } }
-#define wm8711_reset(c) snd_soc_write(c, WM8711_RESET, 0) +#define wm8711_reset(c) snd_soc_component_write(c, WM8711_RESET, 0)
static const DECLARE_TLV_DB_SCALE(out_tlv, -12100, 100, 1);
@@ -159,14 +159,14 @@ static int wm8711_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; - struct wm8711_priv *wm8711 = snd_soc_codec_get_drvdata(codec); - u16 iface = snd_soc_read(codec, WM8711_IFACE) & 0xfff3; + struct snd_soc_component *component = dai->component; + struct wm8711_priv *wm8711 = snd_soc_component_get_drvdata(component); + u16 iface = snd_soc_component_read32(component, WM8711_IFACE) & 0xfff3; int i = get_coeff(wm8711->sysclk, params_rate(params)); u16 srate = (coeff_div[i].sr << 2) | (coeff_div[i].bosr << 1) | coeff_div[i].usb;
- snd_soc_write(codec, WM8711_SRATE, srate); + snd_soc_component_write(component, WM8711_SRATE, srate);
/* bit size */ switch (params_width(params)) { @@ -180,17 +180,17 @@ static int wm8711_hw_params(struct snd_pcm_substream *substream, break; }
- snd_soc_write(codec, WM8711_IFACE, iface); + snd_soc_component_write(component, WM8711_IFACE, iface); return 0; }
static int wm8711_pcm_prepare(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; + struct snd_soc_component *component = dai->component;
/* set active */ - snd_soc_write(codec, WM8711_ACTIVE, 0x0001); + snd_soc_component_write(component, WM8711_ACTIVE, 0x0001);
return 0; } @@ -198,24 +198,24 @@ static int wm8711_pcm_prepare(struct snd_pcm_substream *substream, static void wm8711_shutdown(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; + struct snd_soc_component *component = dai->component;
/* deactivate */ - if (!snd_soc_codec_is_active(codec)) { + if (!snd_soc_component_is_active(component)) { udelay(50); - snd_soc_write(codec, WM8711_ACTIVE, 0x0); + snd_soc_component_write(component, WM8711_ACTIVE, 0x0); } }
static int wm8711_mute(struct snd_soc_dai *dai, int mute) { - struct snd_soc_codec *codec = dai->codec; - u16 mute_reg = snd_soc_read(codec, WM8711_APDIGI) & 0xfff7; + struct snd_soc_component *component = dai->component; + u16 mute_reg = snd_soc_component_read32(component, WM8711_APDIGI) & 0xfff7;
if (mute) - snd_soc_write(codec, WM8711_APDIGI, mute_reg | 0x8); + snd_soc_component_write(component, WM8711_APDIGI, mute_reg | 0x8); else - snd_soc_write(codec, WM8711_APDIGI, mute_reg); + snd_soc_component_write(component, WM8711_APDIGI, mute_reg);
return 0; } @@ -223,8 +223,8 @@ static int wm8711_mute(struct snd_soc_dai *dai, int mute) static int wm8711_set_dai_sysclk(struct snd_soc_dai *codec_dai, int clk_id, unsigned int freq, int dir) { - struct snd_soc_codec *codec = codec_dai->codec; - struct wm8711_priv *wm8711 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = codec_dai->component; + struct wm8711_priv *wm8711 = snd_soc_component_get_drvdata(component);
switch (freq) { case 11289600: @@ -241,8 +241,8 @@ static int wm8711_set_dai_sysclk(struct snd_soc_dai *codec_dai, static int wm8711_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt) { - struct snd_soc_codec *codec = codec_dai->codec; - u16 iface = snd_soc_read(codec, WM8711_IFACE) & 0x000c; + struct snd_soc_component *component = codec_dai->component; + u16 iface = snd_soc_component_read32(component, WM8711_IFACE) & 0x000c;
/* set master/slave audio interface */ switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { @@ -293,31 +293,31 @@ static int wm8711_set_dai_fmt(struct snd_soc_dai *codec_dai, }
/* set iface */ - snd_soc_write(codec, WM8711_IFACE, iface); + snd_soc_component_write(component, WM8711_IFACE, iface); return 0; }
-static int wm8711_set_bias_level(struct snd_soc_codec *codec, +static int wm8711_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { - struct wm8711_priv *wm8711 = snd_soc_codec_get_drvdata(codec); - u16 reg = snd_soc_read(codec, WM8711_PWR) & 0xff7f; + struct wm8711_priv *wm8711 = snd_soc_component_get_drvdata(component); + u16 reg = snd_soc_component_read32(component, WM8711_PWR) & 0xff7f;
switch (level) { case SND_SOC_BIAS_ON: - snd_soc_write(codec, WM8711_PWR, reg); + snd_soc_component_write(component, WM8711_PWR, reg); break; case SND_SOC_BIAS_PREPARE: break; case SND_SOC_BIAS_STANDBY: - if (snd_soc_codec_get_bias_level(codec) == SND_SOC_BIAS_OFF) + if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_OFF) regcache_sync(wm8711->regmap);
- snd_soc_write(codec, WM8711_PWR, reg | 0x0040); + snd_soc_component_write(component, WM8711_PWR, reg | 0x0040); break; case SND_SOC_BIAS_OFF: - snd_soc_write(codec, WM8711_ACTIVE, 0x0); - snd_soc_write(codec, WM8711_PWR, 0xffff); + snd_soc_component_write(component, WM8711_ACTIVE, 0x0); + snd_soc_component_write(component, WM8711_PWR, 0xffff); break; } return 0; @@ -349,37 +349,38 @@ static int wm8711_set_bias_level(struct snd_soc_codec *codec, .ops = &wm8711_ops, };
-static int wm8711_probe(struct snd_soc_codec *codec) +static int wm8711_probe(struct snd_soc_component *component) { int ret;
- ret = wm8711_reset(codec); + ret = wm8711_reset(component); if (ret < 0) { - dev_err(codec->dev, "Failed to issue reset\n"); + dev_err(component->dev, "Failed to issue reset\n"); return ret; }
/* Latch the update bits */ - snd_soc_update_bits(codec, WM8711_LOUT1V, 0x0100, 0x0100); - snd_soc_update_bits(codec, WM8711_ROUT1V, 0x0100, 0x0100); + snd_soc_component_update_bits(component, WM8711_LOUT1V, 0x0100, 0x0100); + snd_soc_component_update_bits(component, WM8711_ROUT1V, 0x0100, 0x0100);
return ret;
}
-static const struct snd_soc_codec_driver soc_codec_dev_wm8711 = { - .probe = wm8711_probe, - .set_bias_level = wm8711_set_bias_level, - .suspend_bias_off = true, - - .component_driver = { - .controls = wm8711_snd_controls, - .num_controls = ARRAY_SIZE(wm8711_snd_controls), - .dapm_widgets = wm8711_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(wm8711_dapm_widgets), - .dapm_routes = wm8711_intercon, - .num_dapm_routes = ARRAY_SIZE(wm8711_intercon), - }, +static const struct snd_soc_component_driver soc_component_dev_wm8711 = { + .probe = wm8711_probe, + .set_bias_level = wm8711_set_bias_level, + .controls = wm8711_snd_controls, + .num_controls = ARRAY_SIZE(wm8711_snd_controls), + .dapm_widgets = wm8711_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(wm8711_dapm_widgets), + .dapm_routes = wm8711_intercon, + .num_dapm_routes = ARRAY_SIZE(wm8711_intercon), + .suspend_bias_off = 1, + .idle_bias_on = 1, + .pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, };
static const struct of_device_id wm8711_of_match[] = { @@ -417,26 +418,18 @@ static int wm8711_spi_probe(struct spi_device *spi)
spi_set_drvdata(spi, wm8711);
- ret = snd_soc_register_codec(&spi->dev, - &soc_codec_dev_wm8711, &wm8711_dai, 1); + ret = devm_snd_soc_register_component(&spi->dev, + &soc_component_dev_wm8711, &wm8711_dai, 1);
return ret; }
-static int wm8711_spi_remove(struct spi_device *spi) -{ - snd_soc_unregister_codec(&spi->dev); - - return 0; -} - static struct spi_driver wm8711_spi_driver = { .driver = { .name = "wm8711", .of_match_table = wm8711_of_match, }, .probe = wm8711_spi_probe, - .remove = wm8711_spi_remove, }; #endif /* CONFIG_SPI_MASTER */
@@ -458,18 +451,12 @@ static int wm8711_i2c_probe(struct i2c_client *client,
i2c_set_clientdata(client, wm8711);
- ret = snd_soc_register_codec(&client->dev, - &soc_codec_dev_wm8711, &wm8711_dai, 1); + ret = devm_snd_soc_register_component(&client->dev, + &soc_component_dev_wm8711, &wm8711_dai, 1);
return ret; }
-static int wm8711_i2c_remove(struct i2c_client *client) -{ - snd_soc_unregister_codec(&client->dev); - return 0; -} - static const struct i2c_device_id wm8711_i2c_id[] = { { "wm8711", 0 }, { } @@ -482,7 +469,6 @@ static int wm8711_i2c_remove(struct i2c_client *client) .of_match_table = wm8711_of_match, }, .probe = wm8711_i2c_probe, - .remove = wm8711_i2c_remove, .id_table = wm8711_i2c_id, }; #endif
From: Kuninori Morimoto kuninori.morimoto.gx@renesas.com
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 -> .pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com --- sound/soc/codecs/wm8750.c | 115 ++++++++++++++++++++-------------------------- 1 file changed, 51 insertions(+), 64 deletions(-)
diff --git a/sound/soc/codecs/wm8750.c b/sound/soc/codecs/wm8750.c index 0da2bba..4418527 100644 --- a/sound/soc/codecs/wm8750.c +++ b/sound/soc/codecs/wm8750.c @@ -86,7 +86,7 @@ struct wm8750_priv { unsigned int sysclk; };
-#define wm8750_reset(c) snd_soc_write(c, WM8750_RESET, 0) +#define wm8750_reset(c) snd_soc_component_write(c, WM8750_RESET, 0)
/* * WM8750 Controls @@ -502,8 +502,8 @@ static inline int get_coeff(int mclk, int rate) static int wm8750_set_dai_sysclk(struct snd_soc_dai *codec_dai, int clk_id, unsigned int freq, int dir) { - struct snd_soc_codec *codec = codec_dai->codec; - struct wm8750_priv *wm8750 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = codec_dai->component; + struct wm8750_priv *wm8750 = snd_soc_component_get_drvdata(component);
switch (freq) { case 11289600: @@ -520,7 +520,7 @@ static int wm8750_set_dai_sysclk(struct snd_soc_dai *codec_dai, static int wm8750_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt) { - struct snd_soc_codec *codec = codec_dai->codec; + struct snd_soc_component *component = codec_dai->component; u16 iface = 0;
/* set master/slave audio interface */ @@ -571,7 +571,7 @@ static int wm8750_set_dai_fmt(struct snd_soc_dai *codec_dai, return -EINVAL; }
- snd_soc_write(codec, WM8750_IFACE, iface); + snd_soc_component_write(component, WM8750_IFACE, iface); return 0; }
@@ -579,10 +579,10 @@ static int wm8750_pcm_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; - struct wm8750_priv *wm8750 = snd_soc_codec_get_drvdata(codec); - u16 iface = snd_soc_read(codec, WM8750_IFACE) & 0x1f3; - u16 srate = snd_soc_read(codec, WM8750_SRATE) & 0x1c0; + struct snd_soc_component *component = dai->component; + struct wm8750_priv *wm8750 = snd_soc_component_get_drvdata(component); + u16 iface = snd_soc_component_read32(component, WM8750_IFACE) & 0x1f3; + u16 srate = snd_soc_component_read32(component, WM8750_SRATE) & 0x1c0; int coeff = get_coeff(wm8750->sysclk, params_rate(params));
/* bit size */ @@ -601,9 +601,9 @@ static int wm8750_pcm_hw_params(struct snd_pcm_substream *substream, }
/* set iface & srate */ - snd_soc_write(codec, WM8750_IFACE, iface); + snd_soc_component_write(component, WM8750_IFACE, iface); if (coeff >= 0) - snd_soc_write(codec, WM8750_SRATE, srate | + snd_soc_component_write(component, WM8750_SRATE, srate | (coeff_div[coeff].sr << 1) | coeff_div[coeff].usb);
return 0; @@ -611,44 +611,44 @@ static int wm8750_pcm_hw_params(struct snd_pcm_substream *substream,
static int wm8750_mute(struct snd_soc_dai *dai, int mute) { - struct snd_soc_codec *codec = dai->codec; - u16 mute_reg = snd_soc_read(codec, WM8750_ADCDAC) & 0xfff7; + struct snd_soc_component *component = dai->component; + u16 mute_reg = snd_soc_component_read32(component, WM8750_ADCDAC) & 0xfff7;
if (mute) - snd_soc_write(codec, WM8750_ADCDAC, mute_reg | 0x8); + snd_soc_component_write(component, WM8750_ADCDAC, mute_reg | 0x8); else - snd_soc_write(codec, WM8750_ADCDAC, mute_reg); + snd_soc_component_write(component, WM8750_ADCDAC, mute_reg); return 0; }
-static int wm8750_set_bias_level(struct snd_soc_codec *codec, +static int wm8750_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { - u16 pwr_reg = snd_soc_read(codec, WM8750_PWR1) & 0xfe3e; + u16 pwr_reg = snd_soc_component_read32(component, WM8750_PWR1) & 0xfe3e;
switch (level) { case SND_SOC_BIAS_ON: /* set vmid to 50k and unmute dac */ - snd_soc_write(codec, WM8750_PWR1, pwr_reg | 0x00c0); + snd_soc_component_write(component, WM8750_PWR1, pwr_reg | 0x00c0); break; case SND_SOC_BIAS_PREPARE: break; case SND_SOC_BIAS_STANDBY: - if (snd_soc_codec_get_bias_level(codec) == SND_SOC_BIAS_OFF) { - snd_soc_cache_sync(codec); + if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_OFF) { + snd_soc_component_cache_sync(component);
/* Set VMID to 5k */ - snd_soc_write(codec, WM8750_PWR1, pwr_reg | 0x01c1); + snd_soc_component_write(component, WM8750_PWR1, pwr_reg | 0x01c1);
/* ...and ramp */ msleep(1000); }
/* mute dac and set vmid to 500k, enable VREF */ - snd_soc_write(codec, WM8750_PWR1, pwr_reg | 0x0141); + snd_soc_component_write(component, WM8750_PWR1, pwr_reg | 0x0141); break; case SND_SOC_BIAS_OFF: - snd_soc_write(codec, WM8750_PWR1, 0x0001); + snd_soc_component_write(component, WM8750_PWR1, 0x0001); break; } return 0; @@ -685,42 +685,43 @@ static int wm8750_set_bias_level(struct snd_soc_codec *codec, .ops = &wm8750_dai_ops, };
-static int wm8750_probe(struct snd_soc_codec *codec) +static int wm8750_probe(struct snd_soc_component *component) { int ret;
- ret = wm8750_reset(codec); + ret = wm8750_reset(component); if (ret < 0) { printk(KERN_ERR "wm8750: failed to reset: %d\n", ret); return ret; }
/* set the update bits */ - snd_soc_update_bits(codec, WM8750_LDAC, 0x0100, 0x0100); - snd_soc_update_bits(codec, WM8750_RDAC, 0x0100, 0x0100); - snd_soc_update_bits(codec, WM8750_LOUT1V, 0x0100, 0x0100); - snd_soc_update_bits(codec, WM8750_ROUT1V, 0x0100, 0x0100); - snd_soc_update_bits(codec, WM8750_LOUT2V, 0x0100, 0x0100); - snd_soc_update_bits(codec, WM8750_ROUT2V, 0x0100, 0x0100); - snd_soc_update_bits(codec, WM8750_LINVOL, 0x0100, 0x0100); - snd_soc_update_bits(codec, WM8750_RINVOL, 0x0100, 0x0100); + snd_soc_component_update_bits(component, WM8750_LDAC, 0x0100, 0x0100); + snd_soc_component_update_bits(component, WM8750_RDAC, 0x0100, 0x0100); + snd_soc_component_update_bits(component, WM8750_LOUT1V, 0x0100, 0x0100); + snd_soc_component_update_bits(component, WM8750_ROUT1V, 0x0100, 0x0100); + snd_soc_component_update_bits(component, WM8750_LOUT2V, 0x0100, 0x0100); + snd_soc_component_update_bits(component, WM8750_ROUT2V, 0x0100, 0x0100); + snd_soc_component_update_bits(component, WM8750_LINVOL, 0x0100, 0x0100); + snd_soc_component_update_bits(component, WM8750_RINVOL, 0x0100, 0x0100);
return ret; }
-static const struct snd_soc_codec_driver soc_codec_dev_wm8750 = { - .probe = wm8750_probe, - .set_bias_level = wm8750_set_bias_level, - .suspend_bias_off = true, - - .component_driver = { - .controls = wm8750_snd_controls, - .num_controls = ARRAY_SIZE(wm8750_snd_controls), - .dapm_widgets = wm8750_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(wm8750_dapm_widgets), - .dapm_routes = wm8750_dapm_routes, - .num_dapm_routes = ARRAY_SIZE(wm8750_dapm_routes), - }, +static const struct snd_soc_component_driver soc_component_dev_wm8750 = { + .probe = wm8750_probe, + .set_bias_level = wm8750_set_bias_level, + .controls = wm8750_snd_controls, + .num_controls = ARRAY_SIZE(wm8750_snd_controls), + .dapm_widgets = wm8750_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(wm8750_dapm_widgets), + .dapm_routes = wm8750_dapm_routes, + .num_dapm_routes = ARRAY_SIZE(wm8750_dapm_routes), + .suspend_bias_off = 1, + .idle_bias_on = 1, + .pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, };
static const struct of_device_id wm8750_of_match[] = { @@ -758,17 +759,11 @@ static int wm8750_spi_probe(struct spi_device *spi)
spi_set_drvdata(spi, wm8750);
- ret = snd_soc_register_codec(&spi->dev, - &soc_codec_dev_wm8750, &wm8750_dai, 1); + ret = devm_snd_soc_register_component(&spi->dev, + &soc_component_dev_wm8750, &wm8750_dai, 1); return ret; }
-static int wm8750_spi_remove(struct spi_device *spi) -{ - snd_soc_unregister_codec(&spi->dev); - return 0; -} - static const struct spi_device_id wm8750_spi_ids[] = { { "wm8750", 0 }, { "wm8987", 0 }, @@ -783,7 +778,6 @@ static int wm8750_spi_remove(struct spi_device *spi) }, .id_table = wm8750_spi_ids, .probe = wm8750_spi_probe, - .remove = wm8750_spi_remove, }; #endif /* CONFIG_SPI_MASTER */
@@ -806,17 +800,11 @@ static int wm8750_i2c_probe(struct i2c_client *i2c, if (IS_ERR(regmap)) return PTR_ERR(regmap);
- ret = snd_soc_register_codec(&i2c->dev, - &soc_codec_dev_wm8750, &wm8750_dai, 1); + ret = devm_snd_soc_register_component(&i2c->dev, + &soc_component_dev_wm8750, &wm8750_dai, 1); return ret; }
-static int wm8750_i2c_remove(struct i2c_client *client) -{ - snd_soc_unregister_codec(&client->dev); - return 0; -} - static const struct i2c_device_id wm8750_i2c_id[] = { { "wm8750", 0 }, { "wm8987", 0 }, @@ -830,7 +818,6 @@ static int wm8750_i2c_remove(struct i2c_client *client) .of_match_table = wm8750_of_match, }, .probe = wm8750_i2c_probe, - .remove = wm8750_i2c_remove, .id_table = wm8750_i2c_id, }; #endif
From: Kuninori Morimoto kuninori.morimoto.gx@renesas.com
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 -> .pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com --- sound/soc/codecs/wm8737.c | 109 ++++++++++++++++++++-------------------------- 1 file changed, 47 insertions(+), 62 deletions(-)
diff --git a/sound/soc/codecs/wm8737.c b/sound/soc/codecs/wm8737.c index f0cb1c4..5c277e7 100644 --- a/sound/soc/codecs/wm8737.c +++ b/sound/soc/codecs/wm8737.c @@ -74,9 +74,9 @@ static bool wm8737_volatile(struct device *dev, unsigned int reg) } }
-static int wm8737_reset(struct snd_soc_codec *codec) +static int wm8737_reset(struct snd_soc_component *component) { - return snd_soc_write(codec, WM8737_RESET, 0); + return snd_soc_component_write(component, WM8737_RESET, 0); }
static const DECLARE_TLV_DB_RANGE(micboost_tlv, @@ -328,8 +328,8 @@ static int wm8737_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; - struct wm8737_priv *wm8737 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct wm8737_priv *wm8737 = snd_soc_component_get_drvdata(component); int i; u16 clocking = 0; u16 af = 0; @@ -348,7 +348,7 @@ static int wm8737_hw_params(struct snd_pcm_substream *substream, }
if (i == ARRAY_SIZE(coeff_div)) { - dev_err(codec->dev, "%dHz MCLK can't support %dHz\n", + dev_err(component->dev, "%dHz MCLK can't support %dHz\n", wm8737->mclk, params_rate(params)); return -EINVAL; } @@ -371,8 +371,8 @@ static int wm8737_hw_params(struct snd_pcm_substream *substream, return -EINVAL; }
- snd_soc_update_bits(codec, WM8737_AUDIO_FORMAT, WM8737_WL_MASK, af); - snd_soc_update_bits(codec, WM8737_CLOCKING, + snd_soc_component_update_bits(component, WM8737_AUDIO_FORMAT, WM8737_WL_MASK, af); + snd_soc_component_update_bits(component, WM8737_CLOCKING, WM8737_USB_MODE | WM8737_CLKDIV2 | WM8737_SR_MASK, clocking);
@@ -382,8 +382,8 @@ static int wm8737_hw_params(struct snd_pcm_substream *substream, static int wm8737_set_dai_sysclk(struct snd_soc_dai *codec_dai, int clk_id, unsigned int freq, int dir) { - struct snd_soc_codec *codec = codec_dai->codec; - struct wm8737_priv *wm8737 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = codec_dai->component; + struct wm8737_priv *wm8737 = snd_soc_component_get_drvdata(component); int i;
for (i = 0; i < ARRAY_SIZE(coeff_div); i++) { @@ -394,7 +394,7 @@ static int wm8737_set_dai_sysclk(struct snd_soc_dai *codec_dai, } }
- dev_err(codec->dev, "MCLK rate %dHz not supported\n", freq); + dev_err(component->dev, "MCLK rate %dHz not supported\n", freq);
return -EINVAL; } @@ -403,7 +403,7 @@ static int wm8737_set_dai_sysclk(struct snd_soc_dai *codec_dai, static int wm8737_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt) { - struct snd_soc_codec *codec = codec_dai->codec; + struct snd_soc_component *component = codec_dai->component; u16 af = 0;
switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { @@ -445,16 +445,16 @@ static int wm8737_set_dai_fmt(struct snd_soc_dai *codec_dai, return -EINVAL; }
- snd_soc_update_bits(codec, WM8737_AUDIO_FORMAT, + snd_soc_component_update_bits(component, WM8737_AUDIO_FORMAT, WM8737_FORMAT_MASK | WM8737_LRP | WM8737_MS, af);
return 0; }
-static int wm8737_set_bias_level(struct snd_soc_codec *codec, +static int wm8737_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { - struct wm8737_priv *wm8737 = snd_soc_codec_get_drvdata(codec); + struct wm8737_priv *wm8737 = snd_soc_component_get_drvdata(component); int ret;
switch (level) { @@ -463,16 +463,16 @@ static int wm8737_set_bias_level(struct snd_soc_codec *codec,
case SND_SOC_BIAS_PREPARE: /* VMID at 2*75k */ - snd_soc_update_bits(codec, WM8737_MISC_BIAS_CONTROL, + snd_soc_component_update_bits(component, WM8737_MISC_BIAS_CONTROL, WM8737_VMIDSEL_MASK, 0); break;
case SND_SOC_BIAS_STANDBY: - if (snd_soc_codec_get_bias_level(codec) == SND_SOC_BIAS_OFF) { + if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_OFF) { ret = regulator_bulk_enable(ARRAY_SIZE(wm8737->supplies), wm8737->supplies); if (ret != 0) { - dev_err(codec->dev, + dev_err(component->dev, "Failed to enable supplies: %d\n", ret); return ret; @@ -481,12 +481,12 @@ static int wm8737_set_bias_level(struct snd_soc_codec *codec, regcache_sync(wm8737->regmap);
/* Fast VMID ramp at 2*2.5k */ - snd_soc_update_bits(codec, WM8737_MISC_BIAS_CONTROL, + snd_soc_component_update_bits(component, WM8737_MISC_BIAS_CONTROL, WM8737_VMIDSEL_MASK, 2 << WM8737_VMIDSEL_SHIFT);
/* Bring VMID up */ - snd_soc_update_bits(codec, WM8737_POWER_MANAGEMENT, + snd_soc_component_update_bits(component, WM8737_POWER_MANAGEMENT, WM8737_VMID_MASK | WM8737_VREF_MASK, WM8737_VMID_MASK | @@ -496,14 +496,14 @@ static int wm8737_set_bias_level(struct snd_soc_codec *codec, }
/* VMID at 2*300k */ - snd_soc_update_bits(codec, WM8737_MISC_BIAS_CONTROL, + snd_soc_component_update_bits(component, WM8737_MISC_BIAS_CONTROL, WM8737_VMIDSEL_MASK, 1 << WM8737_VMIDSEL_SHIFT);
break;
case SND_SOC_BIAS_OFF: - snd_soc_update_bits(codec, WM8737_POWER_MANAGEMENT, + snd_soc_component_update_bits(component, WM8737_POWER_MANAGEMENT, WM8737_VMID_MASK | WM8737_VREF_MASK, 0);
regulator_bulk_disable(ARRAY_SIZE(wm8737->supplies), @@ -537,30 +537,30 @@ static int wm8737_set_bias_level(struct snd_soc_codec *codec, .ops = &wm8737_dai_ops, };
-static int wm8737_probe(struct snd_soc_codec *codec) +static int wm8737_probe(struct snd_soc_component *component) { - struct wm8737_priv *wm8737 = snd_soc_codec_get_drvdata(codec); + struct wm8737_priv *wm8737 = snd_soc_component_get_drvdata(component); int ret;
ret = regulator_bulk_enable(ARRAY_SIZE(wm8737->supplies), wm8737->supplies); if (ret != 0) { - dev_err(codec->dev, "Failed to enable supplies: %d\n", ret); + dev_err(component->dev, "Failed to enable supplies: %d\n", ret); goto err_get; }
- ret = wm8737_reset(codec); + ret = wm8737_reset(component); if (ret < 0) { - dev_err(codec->dev, "Failed to issue reset\n"); + dev_err(component->dev, "Failed to issue reset\n"); goto err_enable; }
- snd_soc_update_bits(codec, WM8737_LEFT_PGA_VOLUME, WM8737_LVU, + snd_soc_component_update_bits(component, WM8737_LEFT_PGA_VOLUME, WM8737_LVU, WM8737_LVU); - snd_soc_update_bits(codec, WM8737_RIGHT_PGA_VOLUME, WM8737_RVU, + snd_soc_component_update_bits(component, WM8737_RIGHT_PGA_VOLUME, WM8737_RVU, WM8737_RVU);
- snd_soc_codec_force_bias_level(codec, SND_SOC_BIAS_STANDBY); + snd_soc_component_force_bias_level(component, SND_SOC_BIAS_STANDBY);
/* Bias level configuration will have done an extra enable */ regulator_bulk_disable(ARRAY_SIZE(wm8737->supplies), wm8737->supplies); @@ -573,19 +573,20 @@ static int wm8737_probe(struct snd_soc_codec *codec) return ret; }
-static const struct snd_soc_codec_driver soc_codec_dev_wm8737 = { - .probe = wm8737_probe, - .set_bias_level = wm8737_set_bias_level, - .suspend_bias_off = true, - - .component_driver = { - .controls = wm8737_snd_controls, - .num_controls = ARRAY_SIZE(wm8737_snd_controls), - .dapm_widgets = wm8737_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(wm8737_dapm_widgets), - .dapm_routes = intercon, - .num_dapm_routes = ARRAY_SIZE(intercon), - }, +static const struct snd_soc_component_driver soc_component_dev_wm8737 = { + .probe = wm8737_probe, + .set_bias_level = wm8737_set_bias_level, + .controls = wm8737_snd_controls, + .num_controls = ARRAY_SIZE(wm8737_snd_controls), + .dapm_widgets = wm8737_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(wm8737_dapm_widgets), + .dapm_routes = intercon, + .num_dapm_routes = ARRAY_SIZE(intercon), + .suspend_bias_off = 1, + .idle_bias_on = 1, + .pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, };
static const struct of_device_id wm8737_of_match[] = { @@ -635,20 +636,13 @@ static int wm8737_i2c_probe(struct i2c_client *i2c,
i2c_set_clientdata(i2c, wm8737);
- ret = snd_soc_register_codec(&i2c->dev, - &soc_codec_dev_wm8737, &wm8737_dai, 1); + ret = devm_snd_soc_register_component(&i2c->dev, + &soc_component_dev_wm8737, &wm8737_dai, 1);
return ret;
}
-static int wm8737_i2c_remove(struct i2c_client *client) -{ - snd_soc_unregister_codec(&client->dev); - - return 0; -} - static const struct i2c_device_id wm8737_i2c_id[] = { { "wm8737", 0 }, { } @@ -661,7 +655,6 @@ static int wm8737_i2c_remove(struct i2c_client *client) .of_match_table = wm8737_of_match, }, .probe = wm8737_i2c_probe, - .remove = wm8737_i2c_remove, .id_table = wm8737_i2c_id, }; #endif @@ -693,26 +686,18 @@ static int wm8737_spi_probe(struct spi_device *spi)
spi_set_drvdata(spi, wm8737);
- ret = snd_soc_register_codec(&spi->dev, - &soc_codec_dev_wm8737, &wm8737_dai, 1); + ret = devm_snd_soc_register_component(&spi->dev, + &soc_component_dev_wm8737, &wm8737_dai, 1);
return ret; }
-static int wm8737_spi_remove(struct spi_device *spi) -{ - snd_soc_unregister_codec(&spi->dev); - - return 0; -} - static struct spi_driver wm8737_spi_driver = { .driver = { .name = "wm8737", .of_match_table = wm8737_of_match, }, .probe = wm8737_spi_probe, - .remove = wm8737_spi_remove, }; #endif /* CONFIG_SPI_MASTER */
From: Kuninori Morimoto kuninori.morimoto.gx@renesas.com
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 -> .pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com --- sound/soc/codecs/wm8776.c | 105 ++++++++++++++++++++-------------------------- 1 file changed, 46 insertions(+), 59 deletions(-)
diff --git a/sound/soc/codecs/wm8776.c b/sound/soc/codecs/wm8776.c index ae30480..02f8164 100644 --- a/sound/soc/codecs/wm8776.c +++ b/sound/soc/codecs/wm8776.c @@ -78,9 +78,9 @@ static bool wm8776_volatile(struct device *dev, unsigned int reg) } }
-static int wm8776_reset(struct snd_soc_codec *codec) +static int wm8776_reset(struct snd_soc_component *component) { - return snd_soc_write(codec, WM8776_RESET, 0); + return snd_soc_component_write(component, WM8776_RESET, 0); }
static const DECLARE_TLV_DB_SCALE(hp_tlv, -12100, 100, 1); @@ -166,7 +166,7 @@ static int wm8776_reset(struct snd_soc_codec *codec)
static int wm8776_set_fmt(struct snd_soc_dai *dai, unsigned int fmt) { - struct snd_soc_codec *codec = dai->codec; + struct snd_soc_component *component = dai->component; int reg, iface, master;
switch (dai->driver->id) { @@ -224,8 +224,8 @@ static int wm8776_set_fmt(struct snd_soc_dai *dai, unsigned int fmt) }
/* Finally, write out the values */ - snd_soc_update_bits(codec, reg, 0xf, iface); - snd_soc_update_bits(codec, WM8776_MSTRCTRL, 0x180, master); + snd_soc_component_update_bits(component, reg, 0xf, iface); + snd_soc_component_update_bits(component, WM8776_MSTRCTRL, 0x180, master);
return 0; } @@ -243,8 +243,8 @@ static int wm8776_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; - struct wm8776_priv *wm8776 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct wm8776_priv *wm8776 = snd_soc_component_get_drvdata(component); int iface_reg, iface; int ratio_shift, master; int i; @@ -279,13 +279,13 @@ static int wm8776_hw_params(struct snd_pcm_substream *substream, iface = 0x30; break; default: - dev_err(codec->dev, "Unsupported sample size: %i\n", + dev_err(component->dev, "Unsupported sample size: %i\n", params_width(params)); return -EINVAL; }
/* Only need to set MCLK/LRCLK ratio if we're master */ - if (snd_soc_read(codec, WM8776_MSTRCTRL) & master) { + if (snd_soc_component_read32(component, WM8776_MSTRCTRL) & master) { for (i = 0; i < ARRAY_SIZE(mclk_ratios); i++) { if (wm8776->sysclk[dai->driver->id] / params_rate(params) == mclk_ratios[i]) @@ -293,37 +293,37 @@ static int wm8776_hw_params(struct snd_pcm_substream *substream, }
if (i == ARRAY_SIZE(mclk_ratios)) { - dev_err(codec->dev, + dev_err(component->dev, "Unable to configure MCLK ratio %d/%d\n", wm8776->sysclk[dai->driver->id], params_rate(params)); return -EINVAL; }
- dev_dbg(codec->dev, "MCLK is %dfs\n", mclk_ratios[i]); + dev_dbg(component->dev, "MCLK is %dfs\n", mclk_ratios[i]);
- snd_soc_update_bits(codec, WM8776_MSTRCTRL, + snd_soc_component_update_bits(component, WM8776_MSTRCTRL, 0x7 << ratio_shift, i << ratio_shift); } else { - dev_dbg(codec->dev, "DAI in slave mode\n"); + dev_dbg(component->dev, "DAI in slave mode\n"); }
- snd_soc_update_bits(codec, iface_reg, 0x30, iface); + snd_soc_component_update_bits(component, iface_reg, 0x30, iface);
return 0; }
static int wm8776_mute(struct snd_soc_dai *dai, int mute) { - struct snd_soc_codec *codec = dai->codec; + struct snd_soc_component *component = dai->component;
- return snd_soc_write(codec, WM8776_DACMUTE, !!mute); + return snd_soc_component_write(component, WM8776_DACMUTE, !!mute); }
static int wm8776_set_sysclk(struct snd_soc_dai *dai, int clk_id, unsigned int freq, int dir) { - struct snd_soc_codec *codec = dai->codec; - struct wm8776_priv *wm8776 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct wm8776_priv *wm8776 = snd_soc_component_get_drvdata(component);
if (WARN_ON(dai->driver->id >= ARRAY_SIZE(wm8776->sysclk))) return -EINVAL; @@ -333,10 +333,10 @@ static int wm8776_set_sysclk(struct snd_soc_dai *dai, return 0; }
-static int wm8776_set_bias_level(struct snd_soc_codec *codec, +static int wm8776_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { - struct wm8776_priv *wm8776 = snd_soc_codec_get_drvdata(codec); + struct wm8776_priv *wm8776 = snd_soc_component_get_drvdata(component);
switch (level) { case SND_SOC_BIAS_ON: @@ -344,16 +344,16 @@ static int wm8776_set_bias_level(struct snd_soc_codec *codec, case SND_SOC_BIAS_PREPARE: break; case SND_SOC_BIAS_STANDBY: - if (snd_soc_codec_get_bias_level(codec) == SND_SOC_BIAS_OFF) { + if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_OFF) { regcache_sync(wm8776->regmap);
/* Disable the global powerdown; DAPM does the rest */ - snd_soc_update_bits(codec, WM8776_PWRDOWN, 1, 0); + snd_soc_component_update_bits(component, WM8776_PWRDOWN, 1, 0); }
break; case SND_SOC_BIAS_OFF: - snd_soc_update_bits(codec, WM8776_PWRDOWN, 1, 1); + snd_soc_component_update_bits(component, WM8776_PWRDOWN, 1, 1); break; }
@@ -407,37 +407,38 @@ static int wm8776_set_bias_level(struct snd_soc_codec *codec, }, };
-static int wm8776_probe(struct snd_soc_codec *codec) +static int wm8776_probe(struct snd_soc_component *component) { int ret = 0;
- ret = wm8776_reset(codec); + ret = wm8776_reset(component); if (ret < 0) { - dev_err(codec->dev, "Failed to issue reset: %d\n", ret); + dev_err(component->dev, "Failed to issue reset: %d\n", ret); return ret; }
/* Latch the update bits; right channel only since we always * update both. */ - snd_soc_update_bits(codec, WM8776_HPRVOL, 0x100, 0x100); - snd_soc_update_bits(codec, WM8776_DACRVOL, 0x100, 0x100); + snd_soc_component_update_bits(component, WM8776_HPRVOL, 0x100, 0x100); + snd_soc_component_update_bits(component, WM8776_DACRVOL, 0x100, 0x100);
return ret; }
-static const struct snd_soc_codec_driver soc_codec_dev_wm8776 = { - .probe = wm8776_probe, - .set_bias_level = wm8776_set_bias_level, - .suspend_bias_off = true, - - .component_driver = { - .controls = wm8776_snd_controls, - .num_controls = ARRAY_SIZE(wm8776_snd_controls), - .dapm_widgets = wm8776_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(wm8776_dapm_widgets), - .dapm_routes = routes, - .num_dapm_routes = ARRAY_SIZE(routes), - }, +static const struct snd_soc_component_driver soc_component_dev_wm8776 = { + .probe = wm8776_probe, + .set_bias_level = wm8776_set_bias_level, + .controls = wm8776_snd_controls, + .num_controls = ARRAY_SIZE(wm8776_snd_controls), + .dapm_widgets = wm8776_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(wm8776_dapm_widgets), + .dapm_routes = routes, + .num_dapm_routes = ARRAY_SIZE(routes), + .suspend_bias_off = 1, + .idle_bias_on = 1, + .pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, };
static const struct of_device_id wm8776_of_match[] = { @@ -475,25 +476,18 @@ static int wm8776_spi_probe(struct spi_device *spi)
spi_set_drvdata(spi, wm8776);
- ret = snd_soc_register_codec(&spi->dev, - &soc_codec_dev_wm8776, wm8776_dai, ARRAY_SIZE(wm8776_dai)); + ret = devm_snd_soc_register_component(&spi->dev, + &soc_component_dev_wm8776, wm8776_dai, ARRAY_SIZE(wm8776_dai));
return ret; }
-static int wm8776_spi_remove(struct spi_device *spi) -{ - snd_soc_unregister_codec(&spi->dev); - return 0; -} - static struct spi_driver wm8776_spi_driver = { .driver = { .name = "wm8776", .of_match_table = wm8776_of_match, }, .probe = wm8776_spi_probe, - .remove = wm8776_spi_remove, }; #endif /* CONFIG_SPI_MASTER */
@@ -515,18 +509,12 @@ static int wm8776_i2c_probe(struct i2c_client *i2c,
i2c_set_clientdata(i2c, wm8776);
- ret = snd_soc_register_codec(&i2c->dev, - &soc_codec_dev_wm8776, wm8776_dai, ARRAY_SIZE(wm8776_dai)); + ret = devm_snd_soc_register_component(&i2c->dev, + &soc_component_dev_wm8776, wm8776_dai, ARRAY_SIZE(wm8776_dai));
return ret; }
-static int wm8776_i2c_remove(struct i2c_client *client) -{ - snd_soc_unregister_codec(&client->dev); - return 0; -} - static const struct i2c_device_id wm8776_i2c_id[] = { { "wm8775", WM8775 }, { "wm8776", WM8776 }, @@ -540,7 +528,6 @@ static int wm8776_i2c_remove(struct i2c_client *client) .of_match_table = wm8776_of_match, }, .probe = wm8776_i2c_probe, - .remove = wm8776_i2c_remove, .id_table = wm8776_i2c_id, }; #endif
From: Kuninori Morimoto kuninori.morimoto.gx@renesas.com
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 -> .pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com --- sound/soc/codecs/wm8770.c | 131 ++++++++++++++++++++++------------------------ 1 file changed, 64 insertions(+), 67 deletions(-)
diff --git a/sound/soc/codecs/wm8770.c b/sound/soc/codecs/wm8770.c index d6edcbb..9bd2098 100644 --- a/sound/soc/codecs/wm8770.c +++ b/sound/soc/codecs/wm8770.c @@ -84,7 +84,7 @@ struct wm8770_priv { struct regmap *regmap; struct regulator_bulk_data supplies[WM8770_NUM_SUPPLIES]; struct notifier_block disable_nb[WM8770_NUM_SUPPLIES]; - struct snd_soc_codec *codec; + struct snd_soc_component *component; int sysclk; };
@@ -308,14 +308,14 @@ static SOC_ENUM_DOUBLE_DECL(ain_enum, static int vout12supply_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm);
switch (event) { case SND_SOC_DAPM_PRE_PMU: - snd_soc_update_bits(codec, WM8770_OUTMUX1, 0x180, 0); + snd_soc_component_update_bits(component, WM8770_OUTMUX1, 0x180, 0); break; case SND_SOC_DAPM_POST_PMD: - snd_soc_update_bits(codec, WM8770_OUTMUX1, 0x180, 0x180); + snd_soc_component_update_bits(component, WM8770_OUTMUX1, 0x180, 0x180); break; }
@@ -325,31 +325,31 @@ static int vout12supply_event(struct snd_soc_dapm_widget *w, static int vout34supply_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm);
switch (event) { case SND_SOC_DAPM_PRE_PMU: - snd_soc_update_bits(codec, WM8770_OUTMUX2, 0x180, 0); + snd_soc_component_update_bits(component, WM8770_OUTMUX2, 0x180, 0); break; case SND_SOC_DAPM_POST_PMD: - snd_soc_update_bits(codec, WM8770_OUTMUX2, 0x180, 0x180); + snd_soc_component_update_bits(component, WM8770_OUTMUX2, 0x180, 0x180); break; }
return 0; }
-static int wm8770_reset(struct snd_soc_codec *codec) +static int wm8770_reset(struct snd_soc_component *component) { - return snd_soc_write(codec, WM8770_RESET, 0); + return snd_soc_component_write(component, WM8770_RESET, 0); }
static int wm8770_set_fmt(struct snd_soc_dai *dai, unsigned int fmt) { - struct snd_soc_codec *codec; + struct snd_soc_component *component; int iface, master;
- codec = dai->codec; + component = dai->component;
switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { case SND_SOC_DAIFMT_CBM_CFM: @@ -392,8 +392,8 @@ static int wm8770_set_fmt(struct snd_soc_dai *dai, unsigned int fmt) return -EINVAL; }
- snd_soc_update_bits(codec, WM8770_IFACECTRL, 0xf, iface); - snd_soc_update_bits(codec, WM8770_MSTRCTRL, 0x100, master); + snd_soc_component_update_bits(component, WM8770_IFACECTRL, 0xf, iface); + snd_soc_component_update_bits(component, WM8770_MSTRCTRL, 0x100, master);
return 0; } @@ -411,15 +411,15 @@ static int wm8770_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec; + struct snd_soc_component *component; struct wm8770_priv *wm8770; int i; int iface; int shift; int ratio;
- codec = dai->codec; - wm8770 = snd_soc_codec_get_drvdata(codec); + component = dai->component; + wm8770 = snd_soc_component_get_drvdata(component);
iface = 0; switch (params_width(params)) { @@ -450,7 +450,7 @@ static int wm8770_hw_params(struct snd_pcm_substream *substream, }
/* Only need to set MCLK/LRCLK ratio if we're master */ - if (snd_soc_read(codec, WM8770_MSTRCTRL) & 0x100) { + if (snd_soc_component_read32(component, WM8770_MSTRCTRL) & 0x100) { for (; i < ARRAY_SIZE(mclk_ratios); ++i) { ratio = wm8770->sysclk / params_rate(params); if (ratio == mclk_ratios[i]) @@ -458,51 +458,51 @@ static int wm8770_hw_params(struct snd_pcm_substream *substream, }
if (i == ARRAY_SIZE(mclk_ratios)) { - dev_err(codec->dev, + dev_err(component->dev, "Unable to configure MCLK ratio %d/%d\n", wm8770->sysclk, params_rate(params)); return -EINVAL; }
- dev_dbg(codec->dev, "MCLK is %dfs\n", mclk_ratios[i]); + dev_dbg(component->dev, "MCLK is %dfs\n", mclk_ratios[i]);
- snd_soc_update_bits(codec, WM8770_MSTRCTRL, 0x7 << shift, + snd_soc_component_update_bits(component, WM8770_MSTRCTRL, 0x7 << shift, i << shift); }
- snd_soc_update_bits(codec, WM8770_IFACECTRL, 0x30, iface); + snd_soc_component_update_bits(component, WM8770_IFACECTRL, 0x30, iface);
return 0; }
static int wm8770_mute(struct snd_soc_dai *dai, int mute) { - struct snd_soc_codec *codec; + struct snd_soc_component *component;
- codec = dai->codec; - return snd_soc_update_bits(codec, WM8770_DACMUTE, 0x10, + component = dai->component; + return snd_soc_component_update_bits(component, WM8770_DACMUTE, 0x10, !!mute << 4); }
static int wm8770_set_sysclk(struct snd_soc_dai *dai, int clk_id, unsigned int freq, int dir) { - struct snd_soc_codec *codec; + struct snd_soc_component *component; struct wm8770_priv *wm8770;
- codec = dai->codec; - wm8770 = snd_soc_codec_get_drvdata(codec); + component = dai->component; + wm8770 = snd_soc_component_get_drvdata(component); wm8770->sysclk = freq; return 0; }
-static int wm8770_set_bias_level(struct snd_soc_codec *codec, +static int wm8770_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { int ret; struct wm8770_priv *wm8770;
- wm8770 = snd_soc_codec_get_drvdata(codec); + wm8770 = snd_soc_component_get_drvdata(component);
switch (level) { case SND_SOC_BIAS_ON: @@ -510,11 +510,11 @@ static int wm8770_set_bias_level(struct snd_soc_codec *codec, case SND_SOC_BIAS_PREPARE: break; case SND_SOC_BIAS_STANDBY: - if (snd_soc_codec_get_bias_level(codec) == SND_SOC_BIAS_OFF) { + if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_OFF) { ret = regulator_bulk_enable(ARRAY_SIZE(wm8770->supplies), wm8770->supplies); if (ret) { - dev_err(codec->dev, + dev_err(component->dev, "Failed to enable supplies: %d\n", ret); return ret; @@ -523,12 +523,12 @@ static int wm8770_set_bias_level(struct snd_soc_codec *codec, regcache_sync(wm8770->regmap);
/* global powerup */ - snd_soc_write(codec, WM8770_PWDNCTRL, 0); + snd_soc_component_write(component, WM8770_PWDNCTRL, 0); } break; case SND_SOC_BIAS_OFF: /* global powerdown */ - snd_soc_write(codec, WM8770_PWDNCTRL, 1); + snd_soc_component_write(component, WM8770_PWDNCTRL, 1); regulator_bulk_disable(ARRAY_SIZE(wm8770->supplies), wm8770->supplies); break; @@ -567,60 +567,59 @@ static int wm8770_set_bias_level(struct snd_soc_codec *codec, .symmetric_rates = 1 };
-static int wm8770_probe(struct snd_soc_codec *codec) +static int wm8770_probe(struct snd_soc_component *component) { struct wm8770_priv *wm8770; int ret;
- wm8770 = snd_soc_codec_get_drvdata(codec); - wm8770->codec = codec; + wm8770 = snd_soc_component_get_drvdata(component); + wm8770->component = component;
ret = regulator_bulk_enable(ARRAY_SIZE(wm8770->supplies), wm8770->supplies); if (ret) { - dev_err(codec->dev, "Failed to enable supplies: %d\n", ret); + dev_err(component->dev, "Failed to enable supplies: %d\n", ret); return ret; }
- ret = wm8770_reset(codec); + ret = wm8770_reset(component); if (ret < 0) { - dev_err(codec->dev, "Failed to issue reset: %d\n", ret); + dev_err(component->dev, "Failed to issue reset: %d\n", ret); goto err_reg_enable; }
/* latch the volume update bits */ - snd_soc_update_bits(codec, WM8770_MSDIGVOL, 0x100, 0x100); - snd_soc_update_bits(codec, WM8770_MSALGVOL, 0x100, 0x100); - snd_soc_update_bits(codec, WM8770_VOUT1RVOL, 0x100, 0x100); - snd_soc_update_bits(codec, WM8770_VOUT2RVOL, 0x100, 0x100); - snd_soc_update_bits(codec, WM8770_VOUT3RVOL, 0x100, 0x100); - snd_soc_update_bits(codec, WM8770_VOUT4RVOL, 0x100, 0x100); - snd_soc_update_bits(codec, WM8770_DAC1RVOL, 0x100, 0x100); - snd_soc_update_bits(codec, WM8770_DAC2RVOL, 0x100, 0x100); - snd_soc_update_bits(codec, WM8770_DAC3RVOL, 0x100, 0x100); - snd_soc_update_bits(codec, WM8770_DAC4RVOL, 0x100, 0x100); + snd_soc_component_update_bits(component, WM8770_MSDIGVOL, 0x100, 0x100); + snd_soc_component_update_bits(component, WM8770_MSALGVOL, 0x100, 0x100); + snd_soc_component_update_bits(component, WM8770_VOUT1RVOL, 0x100, 0x100); + snd_soc_component_update_bits(component, WM8770_VOUT2RVOL, 0x100, 0x100); + snd_soc_component_update_bits(component, WM8770_VOUT3RVOL, 0x100, 0x100); + snd_soc_component_update_bits(component, WM8770_VOUT4RVOL, 0x100, 0x100); + snd_soc_component_update_bits(component, WM8770_DAC1RVOL, 0x100, 0x100); + snd_soc_component_update_bits(component, WM8770_DAC2RVOL, 0x100, 0x100); + snd_soc_component_update_bits(component, WM8770_DAC3RVOL, 0x100, 0x100); + snd_soc_component_update_bits(component, WM8770_DAC4RVOL, 0x100, 0x100);
/* mute all DACs */ - snd_soc_update_bits(codec, WM8770_DACMUTE, 0x10, 0x10); + snd_soc_component_update_bits(component, WM8770_DACMUTE, 0x10, 0x10);
err_reg_enable: regulator_bulk_disable(ARRAY_SIZE(wm8770->supplies), wm8770->supplies); return ret; }
-static const struct snd_soc_codec_driver soc_codec_dev_wm8770 = { - .probe = wm8770_probe, - .set_bias_level = wm8770_set_bias_level, - .idle_bias_off = true, - - .component_driver = { - .controls = wm8770_snd_controls, - .num_controls = ARRAY_SIZE(wm8770_snd_controls), - .dapm_widgets = wm8770_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(wm8770_dapm_widgets), - .dapm_routes = wm8770_intercon, - .num_dapm_routes = ARRAY_SIZE(wm8770_intercon), - }, +static const struct snd_soc_component_driver soc_component_dev_wm8770 = { + .probe = wm8770_probe, + .set_bias_level = wm8770_set_bias_level, + .controls = wm8770_snd_controls, + .num_controls = ARRAY_SIZE(wm8770_snd_controls), + .dapm_widgets = wm8770_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(wm8770_dapm_widgets), + .dapm_routes = wm8770_intercon, + .num_dapm_routes = ARRAY_SIZE(wm8770_intercon), + .pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, };
static const struct of_device_id wm8770_of_match[] = { @@ -682,8 +681,8 @@ static int wm8770_spi_probe(struct spi_device *spi)
spi_set_drvdata(spi, wm8770);
- ret = snd_soc_register_codec(&spi->dev, - &soc_codec_dev_wm8770, &wm8770_dai, 1); + ret = devm_snd_soc_register_component(&spi->dev, + &soc_component_dev_wm8770, &wm8770_dai, 1);
return ret; } @@ -697,8 +696,6 @@ static int wm8770_spi_remove(struct spi_device *spi) regulator_unregister_notifier(wm8770->supplies[i].consumer, &wm8770->disable_nb[i]);
- snd_soc_unregister_codec(&spi->dev); - return 0; }
From: Kuninori Morimoto kuninori.morimoto.gx@renesas.com
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 -> .pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com --- sound/soc/codecs/wm8727.c | 29 +++++++++++------------------ 1 file changed, 11 insertions(+), 18 deletions(-)
diff --git a/sound/soc/codecs/wm8727.c b/sound/soc/codecs/wm8727.c index 7fde077..8cd0ec9 100644 --- a/sound/soc/codecs/wm8727.c +++ b/sound/soc/codecs/wm8727.c @@ -19,7 +19,6 @@ #include <linux/device.h> #include <sound/core.h> #include <sound/pcm.h> -#include <sound/ac97_codec.h> #include <sound/initval.h> #include <sound/soc.h>
@@ -41,7 +40,6 @@ SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_96000 |\ SNDRV_PCM_RATE_192000)
- static struct snd_soc_dai_driver wm8727_dai = { .name = "wm8727-hifi", .playback = { @@ -53,25 +51,21 @@ }, };
-static const struct snd_soc_codec_driver soc_codec_dev_wm8727 = { - .component_driver = { - .dapm_widgets = wm8727_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(wm8727_dapm_widgets), - .dapm_routes = wm8727_dapm_routes, - .num_dapm_routes = ARRAY_SIZE(wm8727_dapm_routes), - }, +static const struct snd_soc_component_driver soc_component_dev_wm8727 = { + .dapm_widgets = wm8727_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(wm8727_dapm_widgets), + .dapm_routes = wm8727_dapm_routes, + .num_dapm_routes = ARRAY_SIZE(wm8727_dapm_routes), + .idle_bias_on = 1, + .pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, };
static int wm8727_probe(struct platform_device *pdev) { - return snd_soc_register_codec(&pdev->dev, - &soc_codec_dev_wm8727, &wm8727_dai, 1); -} - -static int wm8727_remove(struct platform_device *pdev) -{ - snd_soc_unregister_codec(&pdev->dev); - return 0; + return devm_snd_soc_register_component(&pdev->dev, + &soc_component_dev_wm8727, &wm8727_dai, 1); }
static struct platform_driver wm8727_codec_driver = { @@ -80,7 +74,6 @@ static int wm8727_remove(struct platform_device *pdev) },
.probe = wm8727_probe, - .remove = wm8727_remove, };
module_platform_driver(wm8727_codec_driver);
From: Kuninori Morimoto kuninori.morimoto.gx@renesas.com
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 -> .pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com --- sound/soc/codecs/wm8731.c | 101 +++++++++++++++++++++++----------------------- 1 file changed, 50 insertions(+), 51 deletions(-)
diff --git a/sound/soc/codecs/wm8731.c b/sound/soc/codecs/wm8731.c index 4f9a1eb..4e67b07 100644 --- a/sound/soc/codecs/wm8731.c +++ b/sound/soc/codecs/wm8731.c @@ -88,9 +88,9 @@ static SOC_ENUM_SINGLE_DECL(wm8731_insel_enum,
static int wm8731_deemph[] = { 0, 32000, 44100, 48000 };
-static int wm8731_set_deemph(struct snd_soc_codec *codec) +static int wm8731_set_deemph(struct snd_soc_component *component) { - struct wm8731_priv *wm8731 = snd_soc_codec_get_drvdata(codec); + struct wm8731_priv *wm8731 = snd_soc_component_get_drvdata(component); int val, i, best;
/* If we're using deemphasis select the nearest available sample @@ -110,17 +110,17 @@ static int wm8731_set_deemph(struct snd_soc_codec *codec) val = 0; }
- dev_dbg(codec->dev, "Set deemphasis %d (%dHz)\n", + dev_dbg(component->dev, "Set deemphasis %d (%dHz)\n", best, wm8731_deemph[best]);
- return snd_soc_update_bits(codec, WM8731_APDIGI, 0x6, val); + return snd_soc_component_update_bits(component, WM8731_APDIGI, 0x6, val); }
static int wm8731_get_deemph(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct wm8731_priv *wm8731 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct wm8731_priv *wm8731 = snd_soc_component_get_drvdata(component);
ucontrol->value.integer.value[0] = wm8731->deemph;
@@ -130,8 +130,8 @@ static int wm8731_get_deemph(struct snd_kcontrol *kcontrol, static int wm8731_put_deemph(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct wm8731_priv *wm8731 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct wm8731_priv *wm8731 = snd_soc_component_get_drvdata(component); unsigned int deemph = ucontrol->value.integer.value[0]; int ret = 0;
@@ -142,7 +142,7 @@ static int wm8731_put_deemph(struct snd_kcontrol *kcontrol, if (wm8731->deemph != deemph) { wm8731->deemph = deemph;
- wm8731_set_deemph(codec); + wm8731_set_deemph(component);
ret = 1; } @@ -214,8 +214,8 @@ static int wm8731_put_deemph(struct snd_kcontrol *kcontrol, static int wm8731_check_osc(struct snd_soc_dapm_widget *source, struct snd_soc_dapm_widget *sink) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(source->dapm); - struct wm8731_priv *wm8731 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_dapm_to_component(source->dapm); + struct wm8731_priv *wm8731 = snd_soc_component_get_drvdata(component);
return wm8731->sysclk_type == WM8731_SYSCLK_XTAL; } @@ -337,16 +337,16 @@ static int wm8731_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; - struct wm8731_priv *wm8731 = snd_soc_codec_get_drvdata(codec); - u16 iface = snd_soc_read(codec, WM8731_IFACE) & 0xfff3; + struct snd_soc_component *component = dai->component; + struct wm8731_priv *wm8731 = snd_soc_component_get_drvdata(component); + u16 iface = snd_soc_component_read32(component, WM8731_IFACE) & 0xfff3; int i = get_coeff(wm8731->sysclk, params_rate(params)); u16 srate = (coeff_div[i].sr << 2) | (coeff_div[i].bosr << 1) | coeff_div[i].usb;
wm8731->playback_fs = params_rate(params);
- snd_soc_write(codec, WM8731_SRATE, srate); + snd_soc_component_write(component, WM8731_SRATE, srate);
/* bit size */ switch (params_width(params)) { @@ -363,30 +363,30 @@ static int wm8731_hw_params(struct snd_pcm_substream *substream, break; }
- wm8731_set_deemph(codec); + wm8731_set_deemph(component);
- snd_soc_write(codec, WM8731_IFACE, iface); + snd_soc_component_write(component, WM8731_IFACE, iface); return 0; }
static int wm8731_mute(struct snd_soc_dai *dai, int mute) { - struct snd_soc_codec *codec = dai->codec; - u16 mute_reg = snd_soc_read(codec, WM8731_APDIGI) & 0xfff7; + struct snd_soc_component *component = dai->component; + u16 mute_reg = snd_soc_component_read32(component, WM8731_APDIGI) & 0xfff7;
if (mute) - snd_soc_write(codec, WM8731_APDIGI, mute_reg | 0x8); + snd_soc_component_write(component, WM8731_APDIGI, mute_reg | 0x8); else - snd_soc_write(codec, WM8731_APDIGI, mute_reg); + snd_soc_component_write(component, WM8731_APDIGI, mute_reg); return 0; }
static int wm8731_set_dai_sysclk(struct snd_soc_dai *codec_dai, int clk_id, unsigned int freq, int dir) { - struct snd_soc_codec *codec = codec_dai->codec; - struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec); - struct wm8731_priv *wm8731 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = codec_dai->component; + struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); + struct wm8731_priv *wm8731 = snd_soc_component_get_drvdata(component);
switch (clk_id) { case WM8731_SYSCLK_XTAL: @@ -429,7 +429,7 @@ static int wm8731_set_dai_sysclk(struct snd_soc_dai *codec_dai, static int wm8731_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt) { - struct snd_soc_codec *codec = codec_dai->codec; + struct snd_soc_component *component = codec_dai->component; u16 iface = 0;
/* set master/slave audio interface */ @@ -481,14 +481,14 @@ static int wm8731_set_dai_fmt(struct snd_soc_dai *codec_dai, }
/* set iface */ - snd_soc_write(codec, WM8731_IFACE, iface); + snd_soc_component_write(component, WM8731_IFACE, iface); return 0; }
-static int wm8731_set_bias_level(struct snd_soc_codec *codec, +static int wm8731_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { - struct wm8731_priv *wm8731 = snd_soc_codec_get_drvdata(codec); + struct wm8731_priv *wm8731 = snd_soc_component_get_drvdata(component); int ret; u16 reg;
@@ -503,7 +503,7 @@ static int wm8731_set_bias_level(struct snd_soc_codec *codec, case SND_SOC_BIAS_PREPARE: break; case SND_SOC_BIAS_STANDBY: - if (snd_soc_codec_get_bias_level(codec) == SND_SOC_BIAS_OFF) { + if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_OFF) { ret = regulator_bulk_enable(ARRAY_SIZE(wm8731->supplies), wm8731->supplies); if (ret != 0) @@ -513,13 +513,13 @@ static int wm8731_set_bias_level(struct snd_soc_codec *codec, }
/* Clear PWROFF, gate CLKOUT, everything else as-is */ - reg = snd_soc_read(codec, WM8731_PWR) & 0xff7f; - snd_soc_write(codec, WM8731_PWR, reg | 0x0040); + reg = snd_soc_component_read32(component, WM8731_PWR) & 0xff7f; + snd_soc_component_write(component, WM8731_PWR, reg | 0x0040); break; case SND_SOC_BIAS_OFF: if (wm8731->mclk) clk_disable_unprepare(wm8731->mclk); - snd_soc_write(codec, WM8731_PWR, 0xffff); + snd_soc_component_write(component, WM8731_PWR, 0xffff); regulator_bulk_disable(ARRAY_SIZE(wm8731->supplies), wm8731->supplies); regcache_mark_dirty(wm8731->regmap); @@ -531,7 +531,7 @@ static int wm8731_set_bias_level(struct snd_soc_codec *codec, static int wm8731_startup(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) { - struct wm8731_priv *wm8731 = snd_soc_codec_get_drvdata(dai->codec); + struct wm8731_priv *wm8731 = snd_soc_component_get_drvdata(dai->component);
if (wm8731->constraints) snd_pcm_hw_constraint_list(substream->runtime, 0, @@ -628,18 +628,19 @@ static int wm8731_hw_init(struct device *dev, struct wm8731_priv *wm8731) return ret; }
-static const struct snd_soc_codec_driver soc_codec_dev_wm8731 = { - .set_bias_level = wm8731_set_bias_level, - .suspend_bias_off = true, - - .component_driver = { - .controls = wm8731_snd_controls, - .num_controls = ARRAY_SIZE(wm8731_snd_controls), - .dapm_widgets = wm8731_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(wm8731_dapm_widgets), - .dapm_routes = wm8731_intercon, - .num_dapm_routes = ARRAY_SIZE(wm8731_intercon), - }, +static const struct snd_soc_component_driver soc_component_dev_wm8731 = { + .set_bias_level = wm8731_set_bias_level, + .controls = wm8731_snd_controls, + .num_controls = ARRAY_SIZE(wm8731_snd_controls), + .dapm_widgets = wm8731_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(wm8731_dapm_widgets), + .dapm_routes = wm8731_intercon, + .num_dapm_routes = ARRAY_SIZE(wm8731_intercon), + .suspend_bias_off = 1, + .idle_bias_on = 1, + .pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, };
static const struct of_device_id wm8731_of_match[] = { @@ -704,8 +705,8 @@ static int wm8731_spi_probe(struct spi_device *spi) if (ret != 0) return ret;
- ret = snd_soc_register_codec(&spi->dev, - &soc_codec_dev_wm8731, &wm8731_dai, 1); + ret = devm_snd_soc_register_component(&spi->dev, + &soc_component_dev_wm8731, &wm8731_dai, 1); if (ret != 0) { dev_err(&spi->dev, "Failed to register CODEC: %d\n", ret); return ret; @@ -716,7 +717,6 @@ static int wm8731_spi_probe(struct spi_device *spi)
static int wm8731_spi_remove(struct spi_device *spi) { - snd_soc_unregister_codec(&spi->dev); return 0; }
@@ -775,8 +775,8 @@ static int wm8731_i2c_probe(struct i2c_client *i2c, if (ret != 0) return ret;
- ret = snd_soc_register_codec(&i2c->dev, - &soc_codec_dev_wm8731, &wm8731_dai, 1); + ret = devm_snd_soc_register_component(&i2c->dev, + &soc_component_dev_wm8731, &wm8731_dai, 1); if (ret != 0) { dev_err(&i2c->dev, "Failed to register CODEC: %d\n", ret); return ret; @@ -787,7 +787,6 @@ static int wm8731_i2c_probe(struct i2c_client *i2c,
static int wm8731_i2c_remove(struct i2c_client *client) { - snd_soc_unregister_codec(&client->dev); return 0; }
From: Kuninori Morimoto kuninori.morimoto.gx@renesas.com
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 -> .pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com --- sound/soc/codecs/wm8782.c | 27 +++++++++++---------------- 1 file changed, 11 insertions(+), 16 deletions(-)
diff --git a/sound/soc/codecs/wm8782.c b/sound/soc/codecs/wm8782.c index bcda210..8870dda 100644 --- a/sound/soc/codecs/wm8782.c +++ b/sound/soc/codecs/wm8782.c @@ -50,25 +50,21 @@ }, };
-static const struct snd_soc_codec_driver soc_codec_dev_wm8782 = { - .component_driver = { - .dapm_widgets = wm8782_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(wm8782_dapm_widgets), - .dapm_routes = wm8782_dapm_routes, - .num_dapm_routes = ARRAY_SIZE(wm8782_dapm_routes), - }, +static const struct snd_soc_component_driver soc_component_dev_wm8782 = { + .dapm_widgets = wm8782_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(wm8782_dapm_widgets), + .dapm_routes = wm8782_dapm_routes, + .num_dapm_routes = ARRAY_SIZE(wm8782_dapm_routes), + .idle_bias_on = 1, + .pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, };
static int wm8782_probe(struct platform_device *pdev) { - return snd_soc_register_codec(&pdev->dev, - &soc_codec_dev_wm8782, &wm8782_dai, 1); -} - -static int wm8782_remove(struct platform_device *pdev) -{ - snd_soc_unregister_codec(&pdev->dev); - return 0; + return devm_snd_soc_register_component(&pdev->dev, + &soc_component_dev_wm8782, &wm8782_dai, 1); }
static struct platform_driver wm8782_codec_driver = { @@ -76,7 +72,6 @@ static int wm8782_remove(struct platform_device *pdev) .name = "wm8782", }, .probe = wm8782_probe, - .remove = wm8782_remove, };
module_platform_driver(wm8782_codec_driver);
From: Kuninori Morimoto kuninori.morimoto.gx@renesas.com
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 -> .pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com --- sound/soc/codecs/wm8728.c | 82 ++++++++++++++++++++--------------------------- 1 file changed, 34 insertions(+), 48 deletions(-)
diff --git a/sound/soc/codecs/wm8728.c b/sound/soc/codecs/wm8728.c index 797cc6e..b6f4cf0 100644 --- a/sound/soc/codecs/wm8728.c +++ b/sound/soc/codecs/wm8728.c @@ -74,13 +74,13 @@ struct wm8728_priv {
static int wm8728_mute(struct snd_soc_dai *dai, int mute) { - struct snd_soc_codec *codec = dai->codec; - u16 mute_reg = snd_soc_read(codec, WM8728_DACCTL); + struct snd_soc_component *component = dai->component; + u16 mute_reg = snd_soc_component_read32(component, WM8728_DACCTL);
if (mute) - snd_soc_write(codec, WM8728_DACCTL, mute_reg | 1); + snd_soc_component_write(component, WM8728_DACCTL, mute_reg | 1); else - snd_soc_write(codec, WM8728_DACCTL, mute_reg & ~1); + snd_soc_component_write(component, WM8728_DACCTL, mute_reg & ~1);
return 0; } @@ -89,8 +89,8 @@ static int wm8728_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; - u16 dac = snd_soc_read(codec, WM8728_DACCTL); + struct snd_soc_component *component = dai->component; + u16 dac = snd_soc_component_read32(component, WM8728_DACCTL);
dac &= ~0x18;
@@ -107,7 +107,7 @@ static int wm8728_hw_params(struct snd_pcm_substream *substream, return -EINVAL; }
- snd_soc_write(codec, WM8728_DACCTL, dac); + snd_soc_component_write(component, WM8728_DACCTL, dac);
return 0; } @@ -115,8 +115,8 @@ static int wm8728_hw_params(struct snd_pcm_substream *substream, static int wm8728_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt) { - struct snd_soc_codec *codec = codec_dai->codec; - u16 iface = snd_soc_read(codec, WM8728_IFCTL); + struct snd_soc_component *component = codec_dai->component; + u16 iface = snd_soc_component_read32(component, WM8728_IFCTL);
/* Currently only I2S is supported by the driver, though the * hardware is more flexible. @@ -156,24 +156,24 @@ static int wm8728_set_dai_fmt(struct snd_soc_dai *codec_dai, return -EINVAL; }
- snd_soc_write(codec, WM8728_IFCTL, iface); + snd_soc_component_write(component, WM8728_IFCTL, iface); return 0; }
-static int wm8728_set_bias_level(struct snd_soc_codec *codec, +static int wm8728_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { - struct wm8728_priv *wm8728 = snd_soc_codec_get_drvdata(codec); + struct wm8728_priv *wm8728 = snd_soc_component_get_drvdata(component); u16 reg;
switch (level) { case SND_SOC_BIAS_ON: case SND_SOC_BIAS_PREPARE: case SND_SOC_BIAS_STANDBY: - if (snd_soc_codec_get_bias_level(codec) == SND_SOC_BIAS_OFF) { + if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_OFF) { /* Power everything up... */ - reg = snd_soc_read(codec, WM8728_DACCTL); - snd_soc_write(codec, WM8728_DACCTL, reg & ~0x4); + reg = snd_soc_component_read32(component, WM8728_DACCTL); + snd_soc_component_write(component, WM8728_DACCTL, reg & ~0x4);
/* ..then sync in the register cache. */ regcache_sync(wm8728->regmap); @@ -181,8 +181,8 @@ static int wm8728_set_bias_level(struct snd_soc_codec *codec, break;
case SND_SOC_BIAS_OFF: - reg = snd_soc_read(codec, WM8728_DACCTL); - snd_soc_write(codec, WM8728_DACCTL, reg | 0x4); + reg = snd_soc_component_read32(component, WM8728_DACCTL); + snd_soc_component_write(component, WM8728_DACCTL, reg | 0x4); break; } return 0; @@ -211,18 +211,19 @@ static int wm8728_set_bias_level(struct snd_soc_codec *codec, .ops = &wm8728_dai_ops, };
-static const struct snd_soc_codec_driver soc_codec_dev_wm8728 = { - .set_bias_level = wm8728_set_bias_level, - .suspend_bias_off = true, - - .component_driver = { - .controls = wm8728_snd_controls, - .num_controls = ARRAY_SIZE(wm8728_snd_controls), - .dapm_widgets = wm8728_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(wm8728_dapm_widgets), - .dapm_routes = wm8728_intercon, - .num_dapm_routes = ARRAY_SIZE(wm8728_intercon), - }, +static const struct snd_soc_component_driver soc_component_dev_wm8728 = { + .set_bias_level = wm8728_set_bias_level, + .controls = wm8728_snd_controls, + .num_controls = ARRAY_SIZE(wm8728_snd_controls), + .dapm_widgets = wm8728_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(wm8728_dapm_widgets), + .dapm_routes = wm8728_intercon, + .num_dapm_routes = ARRAY_SIZE(wm8728_intercon), + .suspend_bias_off = 1, + .idle_bias_on = 1, + .pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, };
static const struct of_device_id wm8728_of_match[] = { @@ -258,26 +259,18 @@ static int wm8728_spi_probe(struct spi_device *spi)
spi_set_drvdata(spi, wm8728);
- ret = snd_soc_register_codec(&spi->dev, - &soc_codec_dev_wm8728, &wm8728_dai, 1); + ret = devm_snd_soc_register_component(&spi->dev, + &soc_component_dev_wm8728, &wm8728_dai, 1);
return ret; }
-static int wm8728_spi_remove(struct spi_device *spi) -{ - snd_soc_unregister_codec(&spi->dev); - - return 0; -} - static struct spi_driver wm8728_spi_driver = { .driver = { .name = "wm8728", .of_match_table = wm8728_of_match, }, .probe = wm8728_spi_probe, - .remove = wm8728_spi_remove, }; #endif /* CONFIG_SPI_MASTER */
@@ -299,18 +292,12 @@ static int wm8728_i2c_probe(struct i2c_client *i2c,
i2c_set_clientdata(i2c, wm8728);
- ret = snd_soc_register_codec(&i2c->dev, - &soc_codec_dev_wm8728, &wm8728_dai, 1); + ret = devm_snd_soc_register_component(&i2c->dev, + &soc_component_dev_wm8728, &wm8728_dai, 1);
return ret; }
-static int wm8728_i2c_remove(struct i2c_client *client) -{ - snd_soc_unregister_codec(&client->dev); - return 0; -} - static const struct i2c_device_id wm8728_i2c_id[] = { { "wm8728", 0 }, { } @@ -323,7 +310,6 @@ static int wm8728_i2c_remove(struct i2c_client *client) .of_match_table = wm8728_of_match, }, .probe = wm8728_i2c_probe, - .remove = wm8728_i2c_remove, .id_table = wm8728_i2c_id, }; #endif
From: Kuninori Morimoto kuninori.morimoto.gx@renesas.com
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 -> .pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com --- sound/soc/codecs/wm8741.c | 133 ++++++++++++++++++++-------------------------- 1 file changed, 59 insertions(+), 74 deletions(-)
diff --git a/sound/soc/codecs/wm8741.c b/sound/soc/codecs/wm8741.c index a394dbe..ddca550 100644 --- a/sound/soc/codecs/wm8741.c +++ b/sound/soc/codecs/wm8741.c @@ -59,9 +59,9 @@ struct wm8741_priv { { 32, 0x0002 }, /* R32 - ADDITONAL_CONTROL_1 */ };
-static int wm8741_reset(struct snd_soc_codec *codec) +static int wm8741_reset(struct snd_soc_component *component) { - return snd_soc_write(codec, WM8741_RESET, 0); + return snd_soc_component_write(component, WM8741_RESET, 0); }
static const DECLARE_TLV_DB_SCALE(dac_tlv_fine, -12700, 13, 0); @@ -179,8 +179,8 @@ static int wm8741_reset(struct snd_soc_codec *codec) static int wm8741_startup(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; - struct wm8741_priv *wm8741 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct wm8741_priv *wm8741 = snd_soc_component_get_drvdata(component);
if (wm8741->sysclk) snd_pcm_hw_constraint_list(substream->runtime, 0, @@ -194,8 +194,8 @@ static int wm8741_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; - struct wm8741_priv *wm8741 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct wm8741_priv *wm8741 = snd_soc_component_get_drvdata(component); unsigned int iface; int i;
@@ -203,7 +203,7 @@ static int wm8741_hw_params(struct snd_pcm_substream *substream, * MCLK supplied to the CODEC - enforce this. */ if (!wm8741->sysclk) { - dev_err(codec->dev, + dev_err(component->dev, "No MCLK configured, call set_sysclk() on init or in hw_params\n"); return -EINVAL; } @@ -215,7 +215,7 @@ static int wm8741_hw_params(struct snd_pcm_substream *substream, }
if (i == wm8741->sysclk_constraints->count) { - dev_err(codec->dev, "LRCLK %d unsupported with MCLK %d\n", + dev_err(component->dev, "LRCLK %d unsupported with MCLK %d\n", params_rate(params), wm8741->sysclk); return -EINVAL; } @@ -235,15 +235,15 @@ static int wm8741_hw_params(struct snd_pcm_substream *substream, iface = 0x3; break; default: - dev_dbg(codec->dev, "wm8741_hw_params: Unsupported bit size param = %d", + dev_dbg(component->dev, "wm8741_hw_params: Unsupported bit size param = %d", params_width(params)); return -EINVAL; }
- dev_dbg(codec->dev, "wm8741_hw_params: bit size param = %d, rate param = %d", + dev_dbg(component->dev, "wm8741_hw_params: bit size param = %d, rate param = %d", params_width(params), params_rate(params));
- snd_soc_update_bits(codec, WM8741_FORMAT_CONTROL, WM8741_IWL_MASK, + snd_soc_component_update_bits(component, WM8741_FORMAT_CONTROL, WM8741_IWL_MASK, iface);
return 0; @@ -252,10 +252,10 @@ static int wm8741_hw_params(struct snd_pcm_substream *substream, static int wm8741_set_dai_sysclk(struct snd_soc_dai *codec_dai, int clk_id, unsigned int freq, int dir) { - struct snd_soc_codec *codec = codec_dai->codec; - struct wm8741_priv *wm8741 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = codec_dai->component; + struct wm8741_priv *wm8741 = snd_soc_component_get_drvdata(component);
- dev_dbg(codec->dev, "wm8741_set_dai_sysclk info: freq=%dHz\n", freq); + dev_dbg(component->dev, "wm8741_set_dai_sysclk info: freq=%dHz\n", freq);
switch (freq) { case 0: @@ -297,7 +297,7 @@ static int wm8741_set_dai_sysclk(struct snd_soc_dai *codec_dai, static int wm8741_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt) { - struct snd_soc_codec *codec = codec_dai->codec; + struct snd_soc_component *component = codec_dai->component; unsigned int iface;
/* check master/slave audio interface */ @@ -347,11 +347,11 @@ static int wm8741_set_dai_fmt(struct snd_soc_dai *codec_dai, }
- dev_dbg(codec->dev, "wm8741_set_dai_fmt: Format=%x, Clock Inv=%x\n", + dev_dbg(component->dev, "wm8741_set_dai_fmt: Format=%x, Clock Inv=%x\n", fmt & SND_SOC_DAIFMT_FORMAT_MASK, ((fmt & SND_SOC_DAIFMT_INV_MASK)));
- snd_soc_update_bits(codec, WM8741_FORMAT_CONTROL, + snd_soc_component_update_bits(component, WM8741_FORMAT_CONTROL, WM8741_BCP_MASK | WM8741_LRP_MASK | WM8741_FMT_MASK, iface);
@@ -386,18 +386,18 @@ static int wm8741_set_dai_fmt(struct snd_soc_dai *codec_dai, };
#ifdef CONFIG_PM -static int wm8741_resume(struct snd_soc_codec *codec) +static int wm8741_resume(struct snd_soc_component *component) { - snd_soc_cache_sync(codec); + snd_soc_component_cache_sync(component); return 0; } #else #define wm8741_resume NULL #endif
-static int wm8741_configure(struct snd_soc_codec *codec) +static int wm8741_configure(struct snd_soc_component *component) { - struct wm8741_priv *wm8741 = snd_soc_codec_get_drvdata(codec); + struct wm8741_priv *wm8741 = snd_soc_component_get_drvdata(component);
/* Configure differential mode */ switch (wm8741->pdata.diff_mode) { @@ -405,7 +405,7 @@ static int wm8741_configure(struct snd_soc_codec *codec) case WM8741_DIFF_MODE_STEREO_REVERSED: case WM8741_DIFF_MODE_MONO_LEFT: case WM8741_DIFF_MODE_MONO_RIGHT: - snd_soc_update_bits(codec, WM8741_MODE_CONTROL_2, + snd_soc_component_update_bits(component, WM8741_MODE_CONTROL_2, WM8741_DIFF_MASK, wm8741->pdata.diff_mode << WM8741_DIFF_SHIFT); break; @@ -414,36 +414,36 @@ static int wm8741_configure(struct snd_soc_codec *codec) }
/* Change some default settings - latch VU */ - snd_soc_update_bits(codec, WM8741_DACLLSB_ATTENUATION, + snd_soc_component_update_bits(component, WM8741_DACLLSB_ATTENUATION, WM8741_UPDATELL, WM8741_UPDATELL); - snd_soc_update_bits(codec, WM8741_DACLMSB_ATTENUATION, + snd_soc_component_update_bits(component, WM8741_DACLMSB_ATTENUATION, WM8741_UPDATELM, WM8741_UPDATELM); - snd_soc_update_bits(codec, WM8741_DACRLSB_ATTENUATION, + snd_soc_component_update_bits(component, WM8741_DACRLSB_ATTENUATION, WM8741_UPDATERL, WM8741_UPDATERL); - snd_soc_update_bits(codec, WM8741_DACRMSB_ATTENUATION, + snd_soc_component_update_bits(component, WM8741_DACRMSB_ATTENUATION, WM8741_UPDATERM, WM8741_UPDATERM);
return 0; }
-static int wm8741_add_controls(struct snd_soc_codec *codec) +static int wm8741_add_controls(struct snd_soc_component *component) { - struct wm8741_priv *wm8741 = snd_soc_codec_get_drvdata(codec); + struct wm8741_priv *wm8741 = snd_soc_component_get_drvdata(component);
switch (wm8741->pdata.diff_mode) { case WM8741_DIFF_MODE_STEREO: case WM8741_DIFF_MODE_STEREO_REVERSED: - snd_soc_add_codec_controls(codec, + snd_soc_add_component_controls(component, wm8741_snd_controls_stereo, ARRAY_SIZE(wm8741_snd_controls_stereo)); break; case WM8741_DIFF_MODE_MONO_LEFT: - snd_soc_add_codec_controls(codec, + snd_soc_add_component_controls(component, wm8741_snd_controls_mono_left, ARRAY_SIZE(wm8741_snd_controls_mono_left)); break; case WM8741_DIFF_MODE_MONO_RIGHT: - snd_soc_add_codec_controls(codec, + snd_soc_add_component_controls(component, wm8741_snd_controls_mono_right, ARRAY_SIZE(wm8741_snd_controls_mono_right)); break; @@ -454,37 +454,37 @@ static int wm8741_add_controls(struct snd_soc_codec *codec) return 0; }
-static int wm8741_probe(struct snd_soc_codec *codec) +static int wm8741_probe(struct snd_soc_component *component) { - struct wm8741_priv *wm8741 = snd_soc_codec_get_drvdata(codec); + struct wm8741_priv *wm8741 = snd_soc_component_get_drvdata(component); int ret = 0;
ret = regulator_bulk_enable(ARRAY_SIZE(wm8741->supplies), wm8741->supplies); if (ret != 0) { - dev_err(codec->dev, "Failed to enable supplies: %d\n", ret); + dev_err(component->dev, "Failed to enable supplies: %d\n", ret); goto err_get; }
- ret = wm8741_reset(codec); + ret = wm8741_reset(component); if (ret < 0) { - dev_err(codec->dev, "Failed to issue reset\n"); + dev_err(component->dev, "Failed to issue reset\n"); goto err_enable; }
- ret = wm8741_configure(codec); + ret = wm8741_configure(component); if (ret < 0) { - dev_err(codec->dev, "Failed to change default settings\n"); + dev_err(component->dev, "Failed to change default settings\n"); goto err_enable; }
- ret = wm8741_add_controls(codec); + ret = wm8741_add_controls(component); if (ret < 0) { - dev_err(codec->dev, "Failed to add controls\n"); + dev_err(component->dev, "Failed to add controls\n"); goto err_enable; }
- dev_dbg(codec->dev, "Successful registration\n"); + dev_dbg(component->dev, "Successful registration\n"); return ret;
err_enable: @@ -493,26 +493,25 @@ static int wm8741_probe(struct snd_soc_codec *codec) return ret; }
-static int wm8741_remove(struct snd_soc_codec *codec) +static void wm8741_remove(struct snd_soc_component *component) { - struct wm8741_priv *wm8741 = snd_soc_codec_get_drvdata(codec); + struct wm8741_priv *wm8741 = snd_soc_component_get_drvdata(component);
regulator_bulk_disable(ARRAY_SIZE(wm8741->supplies), wm8741->supplies); - - return 0; }
-static const struct snd_soc_codec_driver soc_codec_dev_wm8741 = { - .probe = wm8741_probe, - .remove = wm8741_remove, - .resume = wm8741_resume, - - .component_driver = { - .dapm_widgets = wm8741_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(wm8741_dapm_widgets), - .dapm_routes = wm8741_dapm_routes, - .num_dapm_routes = ARRAY_SIZE(wm8741_dapm_routes), - }, +static const struct snd_soc_component_driver soc_component_dev_wm8741 = { + .probe = wm8741_probe, + .remove = wm8741_remove, + .resume = wm8741_resume, + .dapm_widgets = wm8741_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(wm8741_dapm_widgets), + .dapm_routes = wm8741_dapm_routes, + .num_dapm_routes = ARRAY_SIZE(wm8741_dapm_routes), + .idle_bias_on = 1, + .pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, };
static const struct of_device_id wm8741_of_match[] = { @@ -585,18 +584,12 @@ static int wm8741_i2c_probe(struct i2c_client *i2c,
i2c_set_clientdata(i2c, wm8741);
- ret = snd_soc_register_codec(&i2c->dev, - &soc_codec_dev_wm8741, &wm8741_dai, 1); + ret = devm_snd_soc_register_component(&i2c->dev, + &soc_component_dev_wm8741, &wm8741_dai, 1);
return ret; }
-static int wm8741_i2c_remove(struct i2c_client *client) -{ - snd_soc_unregister_codec(&client->dev); - return 0; -} - static const struct i2c_device_id wm8741_i2c_id[] = { { "wm8741", 0 }, { } @@ -609,7 +602,6 @@ static int wm8741_i2c_remove(struct i2c_client *client) .of_match_table = wm8741_of_match, }, .probe = wm8741_i2c_probe, - .remove = wm8741_i2c_remove, .id_table = wm8741_i2c_id, }; #endif @@ -650,24 +642,17 @@ static int wm8741_spi_probe(struct spi_device *spi)
spi_set_drvdata(spi, wm8741);
- ret = snd_soc_register_codec(&spi->dev, - &soc_codec_dev_wm8741, &wm8741_dai, 1); + ret = devm_snd_soc_register_component(&spi->dev, + &soc_component_dev_wm8741, &wm8741_dai, 1); return ret; }
-static int wm8741_spi_remove(struct spi_device *spi) -{ - snd_soc_unregister_codec(&spi->dev); - return 0; -} - static struct spi_driver wm8741_spi_driver = { .driver = { .name = "wm8741", .of_match_table = wm8741_of_match, }, .probe = wm8741_spi_probe, - .remove = wm8741_spi_remove, }; #endif /* CONFIG_SPI_MASTER */
From: Kuninori Morimoto kuninori.morimoto.gx@renesas.com
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 -> .pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com --- sound/soc/codecs/wm8753.c | 289 ++++++++++++++++++++++------------------------ 1 file changed, 138 insertions(+), 151 deletions(-)
diff --git a/sound/soc/codecs/wm8753.c b/sound/soc/codecs/wm8753.c index 0271a52..cbcd998 100644 --- a/sound/soc/codecs/wm8753.c +++ b/sound/soc/codecs/wm8753.c @@ -55,9 +55,9 @@ module_param(caps_charge, int, 0); MODULE_PARM_DESC(caps_charge, "WM8753 cap charge time (msecs)");
-static int wm8753_hifi_write_dai_fmt(struct snd_soc_codec *codec, +static int wm8753_hifi_write_dai_fmt(struct snd_soc_component *component, unsigned int fmt); -static int wm8753_voice_write_dai_fmt(struct snd_soc_codec *codec, +static int wm8753_voice_write_dai_fmt(struct snd_soc_component *component, unsigned int fmt);
/* @@ -150,7 +150,7 @@ struct wm8753_priv { struct delayed_work charge_work; };
-#define wm8753_reset(c) snd_soc_write(c, WM8753_RESET, 0) +#define wm8753_reset(c) snd_soc_component_write(c, WM8753_RESET, 0)
/* * WM8753 Controls @@ -229,8 +229,8 @@ struct wm8753_priv { static int wm8753_get_dai(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct wm8753_priv *wm8753 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct wm8753_priv *wm8753 = snd_soc_component_get_drvdata(component);
ucontrol->value.enumerated.item[0] = wm8753->dai_func; return 0; @@ -239,17 +239,17 @@ static int wm8753_get_dai(struct snd_kcontrol *kcontrol, static int wm8753_set_dai(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct wm8753_priv *wm8753 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct wm8753_priv *wm8753 = snd_soc_component_get_drvdata(component); u16 ioctl;
if (wm8753->dai_func == ucontrol->value.enumerated.item[0]) return 0;
- if (snd_soc_codec_is_active(codec)) + if (snd_soc_component_is_active(component)) return -EBUSY;
- ioctl = snd_soc_read(codec, WM8753_IOCTL); + ioctl = snd_soc_component_read32(component, WM8753_IOCTL);
wm8753->dai_func = ucontrol->value.enumerated.item[0];
@@ -257,11 +257,11 @@ static int wm8753_set_dai(struct snd_kcontrol *kcontrol, return 1;
ioctl = (ioctl & 0x1f3) | (wm8753->dai_func << 2); - snd_soc_write(codec, WM8753_IOCTL, ioctl); + snd_soc_component_write(component, WM8753_IOCTL, ioctl);
- wm8753_hifi_write_dai_fmt(codec, wm8753->hifi_fmt); - wm8753_voice_write_dai_fmt(codec, wm8753->voice_fmt); + wm8753_hifi_write_dai_fmt(component, wm8753->hifi_fmt); + wm8753_voice_write_dai_fmt(component, wm8753->voice_fmt);
return 1; } @@ -745,7 +745,7 @@ static int wm8753_set_dai_pll(struct snd_soc_dai *codec_dai, int pll_id, { u16 reg, enable; int offset; - struct snd_soc_codec *codec = codec_dai->codec; + struct snd_soc_component *component = codec_dai->component;
if (pll_id < WM8753_PLL1 || pll_id > WM8753_PLL2) return -ENODEV; @@ -753,17 +753,17 @@ static int wm8753_set_dai_pll(struct snd_soc_dai *codec_dai, int pll_id, if (pll_id == WM8753_PLL1) { offset = 0; enable = 0x10; - reg = snd_soc_read(codec, WM8753_CLOCK) & 0xffef; + reg = snd_soc_component_read32(component, WM8753_CLOCK) & 0xffef; } else { offset = 4; enable = 0x8; - reg = snd_soc_read(codec, WM8753_CLOCK) & 0xfff7; + reg = snd_soc_component_read32(component, WM8753_CLOCK) & 0xfff7; }
if (!freq_in || !freq_out) { /* disable PLL */ - snd_soc_write(codec, WM8753_PLL1CTL1 + offset, 0x0026); - snd_soc_write(codec, WM8753_CLOCK, reg); + snd_soc_component_write(component, WM8753_PLL1CTL1 + offset, 0x0026); + snd_soc_component_write(component, WM8753_CLOCK, reg); return 0; } else { u16 value = 0; @@ -774,20 +774,20 @@ static int wm8753_set_dai_pll(struct snd_soc_dai *codec_dai, int pll_id, /* set up N and K PLL divisor ratios */ /* bits 8:5 = PLL_N, bits 3:0 = PLL_K[21:18] */ value = (pll_div.n << 5) + ((pll_div.k & 0x3c0000) >> 18); - snd_soc_write(codec, WM8753_PLL1CTL2 + offset, value); + snd_soc_component_write(component, WM8753_PLL1CTL2 + offset, value);
/* bits 8:0 = PLL_K[17:9] */ value = (pll_div.k & 0x03fe00) >> 9; - snd_soc_write(codec, WM8753_PLL1CTL3 + offset, value); + snd_soc_component_write(component, WM8753_PLL1CTL3 + offset, value);
/* bits 8:0 = PLL_K[8:0] */ value = pll_div.k & 0x0001ff; - snd_soc_write(codec, WM8753_PLL1CTL4 + offset, value); + snd_soc_component_write(component, WM8753_PLL1CTL4 + offset, value);
/* set PLL as input and enable */ - snd_soc_write(codec, WM8753_PLL1CTL1 + offset, 0x0027 | + snd_soc_component_write(component, WM8753_PLL1CTL1 + offset, 0x0027 | (pll_div.div2 << 3)); - snd_soc_write(codec, WM8753_CLOCK, reg | enable); + snd_soc_component_write(component, WM8753_CLOCK, reg | enable); } return 0; } @@ -866,8 +866,8 @@ static int get_coeff(int mclk, int rate) static int wm8753_set_dai_sysclk(struct snd_soc_dai *codec_dai, int clk_id, unsigned int freq, int dir) { - struct snd_soc_codec *codec = codec_dai->codec; - struct wm8753_priv *wm8753 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = codec_dai->component; + struct wm8753_priv *wm8753 = snd_soc_component_get_drvdata(component);
switch (freq) { case 11289600: @@ -890,10 +890,10 @@ static int wm8753_set_dai_sysclk(struct snd_soc_dai *codec_dai, /* * Set's ADC and Voice DAC format. */ -static int wm8753_vdac_adc_set_dai_fmt(struct snd_soc_codec *codec, +static int wm8753_vdac_adc_set_dai_fmt(struct snd_soc_component *component, unsigned int fmt) { - u16 voice = snd_soc_read(codec, WM8753_PCM) & 0x01ec; + u16 voice = snd_soc_component_read32(component, WM8753_PCM) & 0x01ec;
/* interface format */ switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) { @@ -915,7 +915,7 @@ static int wm8753_vdac_adc_set_dai_fmt(struct snd_soc_codec *codec, return -EINVAL; }
- snd_soc_write(codec, WM8753_PCM, voice); + snd_soc_component_write(component, WM8753_PCM, voice); return 0; }
@@ -926,10 +926,10 @@ static int wm8753_pcm_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; - struct wm8753_priv *wm8753 = snd_soc_codec_get_drvdata(codec); - u16 voice = snd_soc_read(codec, WM8753_PCM) & 0x01f3; - u16 srate = snd_soc_read(codec, WM8753_SRATE1) & 0x017f; + struct snd_soc_component *component = dai->component; + struct wm8753_priv *wm8753 = snd_soc_component_get_drvdata(component); + u16 voice = snd_soc_component_read32(component, WM8753_PCM) & 0x01f3; + u16 srate = snd_soc_component_read32(component, WM8753_SRATE1) & 0x017f;
/* bit size */ switch (params_width(params)) { @@ -949,22 +949,22 @@ static int wm8753_pcm_hw_params(struct snd_pcm_substream *substream, /* sample rate */ if (params_rate(params) * 384 == wm8753->pcmclk) srate |= 0x80; - snd_soc_write(codec, WM8753_SRATE1, srate); + snd_soc_component_write(component, WM8753_SRATE1, srate);
- snd_soc_write(codec, WM8753_PCM, voice); + snd_soc_component_write(component, WM8753_PCM, voice); return 0; }
/* * Set's PCM dai fmt and BCLK. */ -static int wm8753_pcm_set_dai_fmt(struct snd_soc_codec *codec, +static int wm8753_pcm_set_dai_fmt(struct snd_soc_component *component, unsigned int fmt) { u16 voice, ioctl;
- voice = snd_soc_read(codec, WM8753_PCM) & 0x011f; - ioctl = snd_soc_read(codec, WM8753_IOCTL) & 0x015d; + voice = snd_soc_component_read32(component, WM8753_PCM) & 0x011f; + ioctl = snd_soc_component_read32(component, WM8753_IOCTL) & 0x015d;
/* set master/slave audio interface */ switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { @@ -1018,29 +1018,29 @@ static int wm8753_pcm_set_dai_fmt(struct snd_soc_codec *codec, return -EINVAL; }
- snd_soc_write(codec, WM8753_PCM, voice); - snd_soc_write(codec, WM8753_IOCTL, ioctl); + snd_soc_component_write(component, WM8753_PCM, voice); + snd_soc_component_write(component, WM8753_IOCTL, ioctl); return 0; }
static int wm8753_set_dai_clkdiv(struct snd_soc_dai *codec_dai, int div_id, int div) { - struct snd_soc_codec *codec = codec_dai->codec; + struct snd_soc_component *component = codec_dai->component; u16 reg;
switch (div_id) { case WM8753_PCMDIV: - reg = snd_soc_read(codec, WM8753_CLOCK) & 0x003f; - snd_soc_write(codec, WM8753_CLOCK, reg | div); + reg = snd_soc_component_read32(component, WM8753_CLOCK) & 0x003f; + snd_soc_component_write(component, WM8753_CLOCK, reg | div); break; case WM8753_BCLKDIV: - reg = snd_soc_read(codec, WM8753_SRATE2) & 0x01c7; - snd_soc_write(codec, WM8753_SRATE2, reg | div); + reg = snd_soc_component_read32(component, WM8753_SRATE2) & 0x01c7; + snd_soc_component_write(component, WM8753_SRATE2, reg | div); break; case WM8753_VXCLKDIV: - reg = snd_soc_read(codec, WM8753_SRATE2) & 0x003f; - snd_soc_write(codec, WM8753_SRATE2, reg | div); + reg = snd_soc_component_read32(component, WM8753_SRATE2) & 0x003f; + snd_soc_component_write(component, WM8753_SRATE2, reg | div); break; default: return -EINVAL; @@ -1051,10 +1051,10 @@ static int wm8753_set_dai_clkdiv(struct snd_soc_dai *codec_dai, /* * Set's HiFi DAC format. */ -static int wm8753_hdac_set_dai_fmt(struct snd_soc_codec *codec, +static int wm8753_hdac_set_dai_fmt(struct snd_soc_component *component, unsigned int fmt) { - u16 hifi = snd_soc_read(codec, WM8753_HIFI) & 0x01e0; + u16 hifi = snd_soc_component_read32(component, WM8753_HIFI) & 0x01e0;
/* interface format */ switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) { @@ -1076,20 +1076,20 @@ static int wm8753_hdac_set_dai_fmt(struct snd_soc_codec *codec, return -EINVAL; }
- snd_soc_write(codec, WM8753_HIFI, hifi); + snd_soc_component_write(component, WM8753_HIFI, hifi); return 0; }
/* * Set's I2S DAI format. */ -static int wm8753_i2s_set_dai_fmt(struct snd_soc_codec *codec, +static int wm8753_i2s_set_dai_fmt(struct snd_soc_component *component, unsigned int fmt) { u16 ioctl, hifi;
- hifi = snd_soc_read(codec, WM8753_HIFI) & 0x013f; - ioctl = snd_soc_read(codec, WM8753_IOCTL) & 0x00ae; + hifi = snd_soc_component_read32(component, WM8753_HIFI) & 0x013f; + ioctl = snd_soc_component_read32(component, WM8753_IOCTL) & 0x00ae;
/* set master/slave audio interface */ switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { @@ -1143,8 +1143,8 @@ static int wm8753_i2s_set_dai_fmt(struct snd_soc_codec *codec, return -EINVAL; }
- snd_soc_write(codec, WM8753_HIFI, hifi); - snd_soc_write(codec, WM8753_IOCTL, ioctl); + snd_soc_component_write(component, WM8753_HIFI, hifi); + snd_soc_component_write(component, WM8753_IOCTL, ioctl); return 0; }
@@ -1155,10 +1155,10 @@ static int wm8753_i2s_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; - struct wm8753_priv *wm8753 = snd_soc_codec_get_drvdata(codec); - u16 srate = snd_soc_read(codec, WM8753_SRATE1) & 0x01c0; - u16 hifi = snd_soc_read(codec, WM8753_HIFI) & 0x01f3; + struct snd_soc_component *component = dai->component; + struct wm8753_priv *wm8753 = snd_soc_component_get_drvdata(component); + u16 srate = snd_soc_component_read32(component, WM8753_SRATE1) & 0x01c0; + u16 hifi = snd_soc_component_read32(component, WM8753_HIFI) & 0x01f3; int coeff;
/* is digital filter coefficient valid ? */ @@ -1167,7 +1167,7 @@ static int wm8753_i2s_hw_params(struct snd_pcm_substream *substream, printk(KERN_ERR "wm8753 invalid MCLK or rate\n"); return coeff; } - snd_soc_write(codec, WM8753_SRATE1, srate | (coeff_div[coeff].sr << 1) | + snd_soc_component_write(component, WM8753_SRATE1, srate | (coeff_div[coeff].sr << 1) | coeff_div[coeff].usb);
/* bit size */ @@ -1185,70 +1185,70 @@ static int wm8753_i2s_hw_params(struct snd_pcm_substream *substream, break; }
- snd_soc_write(codec, WM8753_HIFI, hifi); + snd_soc_component_write(component, WM8753_HIFI, hifi); return 0; }
-static int wm8753_mode1v_set_dai_fmt(struct snd_soc_codec *codec, +static int wm8753_mode1v_set_dai_fmt(struct snd_soc_component *component, unsigned int fmt) { u16 clock;
/* set clk source as pcmclk */ - clock = snd_soc_read(codec, WM8753_CLOCK) & 0xfffb; - snd_soc_write(codec, WM8753_CLOCK, clock); + clock = snd_soc_component_read32(component, WM8753_CLOCK) & 0xfffb; + snd_soc_component_write(component, WM8753_CLOCK, clock);
- return wm8753_vdac_adc_set_dai_fmt(codec, fmt); + return wm8753_vdac_adc_set_dai_fmt(component, fmt); }
-static int wm8753_mode1h_set_dai_fmt(struct snd_soc_codec *codec, +static int wm8753_mode1h_set_dai_fmt(struct snd_soc_component *component, unsigned int fmt) { - return wm8753_hdac_set_dai_fmt(codec, fmt); + return wm8753_hdac_set_dai_fmt(component, fmt); }
-static int wm8753_mode2_set_dai_fmt(struct snd_soc_codec *codec, +static int wm8753_mode2_set_dai_fmt(struct snd_soc_component *component, unsigned int fmt) { u16 clock;
/* set clk source as pcmclk */ - clock = snd_soc_read(codec, WM8753_CLOCK) & 0xfffb; - snd_soc_write(codec, WM8753_CLOCK, clock); + clock = snd_soc_component_read32(component, WM8753_CLOCK) & 0xfffb; + snd_soc_component_write(component, WM8753_CLOCK, clock);
- return wm8753_vdac_adc_set_dai_fmt(codec, fmt); + return wm8753_vdac_adc_set_dai_fmt(component, fmt); }
-static int wm8753_mode3_4_set_dai_fmt(struct snd_soc_codec *codec, +static int wm8753_mode3_4_set_dai_fmt(struct snd_soc_component *component, unsigned int fmt) { u16 clock;
/* set clk source as mclk */ - clock = snd_soc_read(codec, WM8753_CLOCK) & 0xfffb; - snd_soc_write(codec, WM8753_CLOCK, clock | 0x4); + clock = snd_soc_component_read32(component, WM8753_CLOCK) & 0xfffb; + snd_soc_component_write(component, WM8753_CLOCK, clock | 0x4);
- if (wm8753_hdac_set_dai_fmt(codec, fmt) < 0) + if (wm8753_hdac_set_dai_fmt(component, fmt) < 0) return -EINVAL; - return wm8753_vdac_adc_set_dai_fmt(codec, fmt); + return wm8753_vdac_adc_set_dai_fmt(component, fmt); }
-static int wm8753_hifi_write_dai_fmt(struct snd_soc_codec *codec, +static int wm8753_hifi_write_dai_fmt(struct snd_soc_component *component, unsigned int fmt) { - struct wm8753_priv *wm8753 = snd_soc_codec_get_drvdata(codec); + struct wm8753_priv *wm8753 = snd_soc_component_get_drvdata(component); int ret = 0;
switch (wm8753->dai_func) { case 0: - ret = wm8753_mode1h_set_dai_fmt(codec, fmt); + ret = wm8753_mode1h_set_dai_fmt(component, fmt); break; case 1: - ret = wm8753_mode2_set_dai_fmt(codec, fmt); + ret = wm8753_mode2_set_dai_fmt(component, fmt); break; case 2: case 3: - ret = wm8753_mode3_4_set_dai_fmt(codec, fmt); + ret = wm8753_mode3_4_set_dai_fmt(component, fmt); break; default: break; @@ -1256,33 +1256,33 @@ static int wm8753_hifi_write_dai_fmt(struct snd_soc_codec *codec, if (ret) return ret;
- return wm8753_i2s_set_dai_fmt(codec, fmt); + return wm8753_i2s_set_dai_fmt(component, fmt); }
static int wm8753_hifi_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt) { - struct snd_soc_codec *codec = codec_dai->codec; - struct wm8753_priv *wm8753 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = codec_dai->component; + struct wm8753_priv *wm8753 = snd_soc_component_get_drvdata(component);
wm8753->hifi_fmt = fmt;
- return wm8753_hifi_write_dai_fmt(codec, fmt); + return wm8753_hifi_write_dai_fmt(component, fmt); };
-static int wm8753_voice_write_dai_fmt(struct snd_soc_codec *codec, +static int wm8753_voice_write_dai_fmt(struct snd_soc_component *component, unsigned int fmt) { - struct wm8753_priv *wm8753 = snd_soc_codec_get_drvdata(codec); + struct wm8753_priv *wm8753 = snd_soc_component_get_drvdata(component); int ret = 0;
if (wm8753->dai_func != 0) return 0;
- ret = wm8753_mode1v_set_dai_fmt(codec, fmt); + ret = wm8753_mode1v_set_dai_fmt(component, fmt); if (ret) return ret; - ret = wm8753_pcm_set_dai_fmt(codec, fmt); + ret = wm8753_pcm_set_dai_fmt(component, fmt); if (ret) return ret;
@@ -1292,30 +1292,30 @@ static int wm8753_voice_write_dai_fmt(struct snd_soc_codec *codec, static int wm8753_voice_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt) { - struct snd_soc_codec *codec = codec_dai->codec; - struct wm8753_priv *wm8753 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = codec_dai->component; + struct wm8753_priv *wm8753 = snd_soc_component_get_drvdata(component);
wm8753->voice_fmt = fmt;
- return wm8753_voice_write_dai_fmt(codec, fmt); + return wm8753_voice_write_dai_fmt(component, fmt); };
static int wm8753_mute(struct snd_soc_dai *dai, int mute) { - struct snd_soc_codec *codec = dai->codec; - u16 mute_reg = snd_soc_read(codec, WM8753_DAC) & 0xfff7; - struct wm8753_priv *wm8753 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + u16 mute_reg = snd_soc_component_read32(component, WM8753_DAC) & 0xfff7; + struct wm8753_priv *wm8753 = snd_soc_component_get_drvdata(component);
/* the digital mute covers the HiFi and Voice DAC's on the WM8753. * make sure we check if they are not both active when we mute */ if (mute && wm8753->dai_func == 1) { - if (!snd_soc_codec_is_active(codec)) - snd_soc_write(codec, WM8753_DAC, mute_reg | 0x8); + if (!snd_soc_component_is_active(component)) + snd_soc_component_write(component, WM8753_DAC, mute_reg | 0x8); } else { if (mute) - snd_soc_write(codec, WM8753_DAC, mute_reg | 0x8); + snd_soc_component_write(component, WM8753_DAC, mute_reg | 0x8); else - snd_soc_write(codec, WM8753_DAC, mute_reg); + snd_soc_component_write(component, WM8753_DAC, mute_reg); }
return 0; @@ -1330,35 +1330,35 @@ static void wm8753_charge_work(struct work_struct *work) regmap_update_bits(wm8753->regmap, WM8753_PWR1, 0x0180, 0x0100); }
-static int wm8753_set_bias_level(struct snd_soc_codec *codec, +static int wm8753_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { - struct wm8753_priv *wm8753 = snd_soc_codec_get_drvdata(codec); - u16 pwr_reg = snd_soc_read(codec, WM8753_PWR1) & 0xfe3e; + struct wm8753_priv *wm8753 = snd_soc_component_get_drvdata(component); + u16 pwr_reg = snd_soc_component_read32(component, WM8753_PWR1) & 0xfe3e;
switch (level) { case SND_SOC_BIAS_ON: /* set vmid to 50k and unmute dac */ - snd_soc_write(codec, WM8753_PWR1, pwr_reg | 0x00c0); + snd_soc_component_write(component, WM8753_PWR1, pwr_reg | 0x00c0); break; case SND_SOC_BIAS_PREPARE: /* Wait until fully charged */ flush_delayed_work(&wm8753->charge_work); break; case SND_SOC_BIAS_STANDBY: - if (snd_soc_codec_get_bias_level(codec) == SND_SOC_BIAS_OFF) { + if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_OFF) { /* set vmid to 5k for quick power up */ - snd_soc_write(codec, WM8753_PWR1, pwr_reg | 0x01c1); + snd_soc_component_write(component, WM8753_PWR1, pwr_reg | 0x01c1); schedule_delayed_work(&wm8753->charge_work, msecs_to_jiffies(caps_charge)); } else { /* mute dac and set vmid to 500k, enable VREF */ - snd_soc_write(codec, WM8753_PWR1, pwr_reg | 0x0141); + snd_soc_component_write(component, WM8753_PWR1, pwr_reg | 0x0141); } break; case SND_SOC_BIAS_OFF: cancel_delayed_work_sync(&wm8753->charge_work); - snd_soc_write(codec, WM8753_PWR1, 0x0001); + snd_soc_component_write(component, WM8753_PWR1, 0x0001); break; } return 0; @@ -1440,59 +1440,60 @@ static int wm8753_set_bias_level(struct snd_soc_codec *codec, }, };
-static int wm8753_resume(struct snd_soc_codec *codec) +static int wm8753_resume(struct snd_soc_component *component) { - struct wm8753_priv *wm8753 = snd_soc_codec_get_drvdata(codec); + struct wm8753_priv *wm8753 = snd_soc_component_get_drvdata(component);
regcache_sync(wm8753->regmap);
return 0; }
-static int wm8753_probe(struct snd_soc_codec *codec) +static int wm8753_probe(struct snd_soc_component *component) { - struct wm8753_priv *wm8753 = snd_soc_codec_get_drvdata(codec); + struct wm8753_priv *wm8753 = snd_soc_component_get_drvdata(component); int ret;
INIT_DELAYED_WORK(&wm8753->charge_work, wm8753_charge_work);
- ret = wm8753_reset(codec); + ret = wm8753_reset(component); if (ret < 0) { - dev_err(codec->dev, "Failed to issue reset: %d\n", ret); + dev_err(component->dev, "Failed to issue reset: %d\n", ret); return ret; }
wm8753->dai_func = 0;
/* set the update bits */ - snd_soc_update_bits(codec, WM8753_LDAC, 0x0100, 0x0100); - snd_soc_update_bits(codec, WM8753_RDAC, 0x0100, 0x0100); - snd_soc_update_bits(codec, WM8753_LADC, 0x0100, 0x0100); - snd_soc_update_bits(codec, WM8753_RADC, 0x0100, 0x0100); - snd_soc_update_bits(codec, WM8753_LOUT1V, 0x0100, 0x0100); - snd_soc_update_bits(codec, WM8753_ROUT1V, 0x0100, 0x0100); - snd_soc_update_bits(codec, WM8753_LOUT2V, 0x0100, 0x0100); - snd_soc_update_bits(codec, WM8753_ROUT2V, 0x0100, 0x0100); - snd_soc_update_bits(codec, WM8753_LINVOL, 0x0100, 0x0100); - snd_soc_update_bits(codec, WM8753_RINVOL, 0x0100, 0x0100); + snd_soc_component_update_bits(component, WM8753_LDAC, 0x0100, 0x0100); + snd_soc_component_update_bits(component, WM8753_RDAC, 0x0100, 0x0100); + snd_soc_component_update_bits(component, WM8753_LADC, 0x0100, 0x0100); + snd_soc_component_update_bits(component, WM8753_RADC, 0x0100, 0x0100); + snd_soc_component_update_bits(component, WM8753_LOUT1V, 0x0100, 0x0100); + snd_soc_component_update_bits(component, WM8753_ROUT1V, 0x0100, 0x0100); + snd_soc_component_update_bits(component, WM8753_LOUT2V, 0x0100, 0x0100); + snd_soc_component_update_bits(component, WM8753_ROUT2V, 0x0100, 0x0100); + snd_soc_component_update_bits(component, WM8753_LINVOL, 0x0100, 0x0100); + snd_soc_component_update_bits(component, WM8753_RINVOL, 0x0100, 0x0100);
return 0; }
-static const struct snd_soc_codec_driver soc_codec_dev_wm8753 = { - .probe = wm8753_probe, - .resume = wm8753_resume, - .set_bias_level = wm8753_set_bias_level, - .suspend_bias_off = true, - - .component_driver = { - .controls = wm8753_snd_controls, - .num_controls = ARRAY_SIZE(wm8753_snd_controls), - .dapm_widgets = wm8753_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(wm8753_dapm_widgets), - .dapm_routes = wm8753_dapm_routes, - .num_dapm_routes = ARRAY_SIZE(wm8753_dapm_routes), - }, +static const struct snd_soc_component_driver soc_component_dev_wm8753 = { + .probe = wm8753_probe, + .resume = wm8753_resume, + .set_bias_level = wm8753_set_bias_level, + .controls = wm8753_snd_controls, + .num_controls = ARRAY_SIZE(wm8753_snd_controls), + .dapm_widgets = wm8753_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(wm8753_dapm_widgets), + .dapm_routes = wm8753_dapm_routes, + .num_dapm_routes = ARRAY_SIZE(wm8753_dapm_routes), + .suspend_bias_off = 1, + .idle_bias_on = 1, + .pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, };
static const struct of_device_id wm8753_of_match[] = { @@ -1534,7 +1535,7 @@ static int wm8753_spi_probe(struct spi_device *spi) return ret; }
- ret = snd_soc_register_codec(&spi->dev, &soc_codec_dev_wm8753, + ret = devm_snd_soc_register_component(&spi->dev, &soc_component_dev_wm8753, wm8753_dai, ARRAY_SIZE(wm8753_dai)); if (ret != 0) dev_err(&spi->dev, "Failed to register CODEC: %d\n", ret); @@ -1542,19 +1543,12 @@ static int wm8753_spi_probe(struct spi_device *spi) return ret; }
-static int wm8753_spi_remove(struct spi_device *spi) -{ - snd_soc_unregister_codec(&spi->dev); - return 0; -} - static struct spi_driver wm8753_spi_driver = { .driver = { .name = "wm8753", .of_match_table = wm8753_of_match, }, .probe = wm8753_spi_probe, - .remove = wm8753_spi_remove, }; #endif /* CONFIG_SPI_MASTER */
@@ -1580,7 +1574,7 @@ static int wm8753_i2c_probe(struct i2c_client *i2c, return ret; }
- ret = snd_soc_register_codec(&i2c->dev, &soc_codec_dev_wm8753, + ret = devm_snd_soc_register_component(&i2c->dev, &soc_component_dev_wm8753, wm8753_dai, ARRAY_SIZE(wm8753_dai)); if (ret != 0) dev_err(&i2c->dev, "Failed to register CODEC: %d\n", ret); @@ -1588,12 +1582,6 @@ static int wm8753_i2c_probe(struct i2c_client *i2c, return ret; }
-static int wm8753_i2c_remove(struct i2c_client *client) -{ - snd_soc_unregister_codec(&client->dev); - return 0; -} - static const struct i2c_device_id wm8753_i2c_id[] = { { "wm8753", 0 }, { } @@ -1606,7 +1594,6 @@ static int wm8753_i2c_remove(struct i2c_client *client) .of_match_table = wm8753_of_match, }, .probe = wm8753_i2c_probe, - .remove = wm8753_i2c_remove, .id_table = wm8753_i2c_id, }; #endif
From: Kuninori Morimoto kuninori.morimoto.gx@renesas.com
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 -> .pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com --- sound/soc/codecs/wm8804.c | 100 +++++++++++++++++++++++----------------------- 1 file changed, 49 insertions(+), 51 deletions(-)
diff --git a/sound/soc/codecs/wm8804.c b/sound/soc/codecs/wm8804.c index fc69b87..a037701 100644 --- a/sound/soc/codecs/wm8804.c +++ b/sound/soc/codecs/wm8804.c @@ -137,21 +137,21 @@ static int wm8804_aif_event(struct snd_soc_dapm_widget *w, static int wm8804_aif_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); - struct wm8804_priv *wm8804 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); + struct wm8804_priv *wm8804 = snd_soc_component_get_drvdata(component);
switch (event) { case SND_SOC_DAPM_POST_PMU: /* power up the aif */ if (!wm8804->aif_pwr) - snd_soc_update_bits(codec, WM8804_PWRDN, 0x10, 0x0); + snd_soc_component_update_bits(component, WM8804_PWRDN, 0x10, 0x0); wm8804->aif_pwr++; break; case SND_SOC_DAPM_POST_PMD: /* power down only both paths are disabled */ wm8804->aif_pwr--; if (!wm8804->aif_pwr) - snd_soc_update_bits(codec, WM8804_PWRDN, 0x10, 0x10); + snd_soc_component_update_bits(component, WM8804_PWRDN, 0x10, 0x10); break; }
@@ -161,8 +161,8 @@ static int wm8804_aif_event(struct snd_soc_dapm_widget *w, static int txsrc_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_dapm_kcontrol_codec(kcontrol); - struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec); + struct snd_soc_component *component = snd_soc_dapm_kcontrol_component(kcontrol); + struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); struct soc_enum *e = (struct soc_enum *)kcontrol->private_value; unsigned int val = ucontrol->value.enumerated.item[0] << e->shift_l; unsigned int mask = 1 << e->shift_l; @@ -173,18 +173,18 @@ static int txsrc_put(struct snd_kcontrol *kcontrol,
snd_soc_dapm_mutex_lock(dapm);
- if (snd_soc_test_bits(codec, e->reg, mask, val)) { + if (snd_soc_component_test_bits(component, e->reg, mask, val)) { /* save the current power state of the transmitter */ - txpwr = snd_soc_read(codec, WM8804_PWRDN) & 0x4; + txpwr = snd_soc_component_read32(component, WM8804_PWRDN) & 0x4;
/* power down the transmitter */ - snd_soc_update_bits(codec, WM8804_PWRDN, 0x4, 0x4); + snd_soc_component_update_bits(component, WM8804_PWRDN, 0x4, 0x4);
/* set the tx source */ - snd_soc_update_bits(codec, e->reg, mask, val); + snd_soc_component_update_bits(component, e->reg, mask, val);
/* restore the transmitter's configuration */ - snd_soc_update_bits(codec, WM8804_PWRDN, 0x4, txpwr); + snd_soc_component_update_bits(component, WM8804_PWRDN, 0x4, txpwr); }
snd_soc_dapm_mutex_unlock(dapm); @@ -218,10 +218,10 @@ static int wm8804_soft_reset(struct wm8804_priv *wm8804)
static int wm8804_set_fmt(struct snd_soc_dai *dai, unsigned int fmt) { - struct snd_soc_codec *codec; + struct snd_soc_component *component; u16 format, master, bcp, lrp;
- codec = dai->codec; + component = dai->component;
switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) { case SND_SOC_DAIFMT_I2S: @@ -243,8 +243,8 @@ static int wm8804_set_fmt(struct snd_soc_dai *dai, unsigned int fmt) }
/* set data format */ - snd_soc_update_bits(codec, WM8804_AIFTX, 0x3, format); - snd_soc_update_bits(codec, WM8804_AIFRX, 0x3, format); + snd_soc_component_update_bits(component, WM8804_AIFTX, 0x3, format); + snd_soc_component_update_bits(component, WM8804_AIFRX, 0x3, format);
switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { case SND_SOC_DAIFMT_CBM_CFM: @@ -259,7 +259,7 @@ static int wm8804_set_fmt(struct snd_soc_dai *dai, unsigned int fmt) }
/* set master/slave mode */ - snd_soc_update_bits(codec, WM8804_AIFRX, 0x40, master << 6); + snd_soc_component_update_bits(component, WM8804_AIFRX, 0x40, master << 6);
bcp = lrp = 0; switch (fmt & SND_SOC_DAIFMT_INV_MASK) { @@ -280,9 +280,9 @@ static int wm8804_set_fmt(struct snd_soc_dai *dai, unsigned int fmt) }
/* set frame inversion */ - snd_soc_update_bits(codec, WM8804_AIFTX, 0x10 | 0x20, + snd_soc_component_update_bits(component, WM8804_AIFTX, 0x10 | 0x20, (bcp << 4) | (lrp << 5)); - snd_soc_update_bits(codec, WM8804_AIFRX, 0x10 | 0x20, + snd_soc_component_update_bits(component, WM8804_AIFRX, 0x10 | 0x20, (bcp << 4) | (lrp << 5)); return 0; } @@ -291,10 +291,10 @@ static int wm8804_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec; + struct snd_soc_component *component; u16 blen;
- codec = dai->codec; + component = dai->component;
switch (params_width(params)) { case 16: @@ -313,8 +313,8 @@ static int wm8804_hw_params(struct snd_pcm_substream *substream, }
/* set word length */ - snd_soc_update_bits(codec, WM8804_AIFTX, 0xc, blen << 2); - snd_soc_update_bits(codec, WM8804_AIFRX, 0xc, blen << 2); + snd_soc_component_update_bits(component, WM8804_AIFTX, 0xc, blen << 2); + snd_soc_component_update_bits(component, WM8804_AIFRX, 0xc, blen << 2);
return 0; } @@ -405,8 +405,8 @@ static int wm8804_set_pll(struct snd_soc_dai *dai, int pll_id, int source, unsigned int freq_in, unsigned int freq_out) { - struct snd_soc_codec *codec = dai->codec; - struct wm8804_priv *wm8804 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct wm8804_priv *wm8804 = snd_soc_component_get_drvdata(component); bool change;
if (!freq_in || !freq_out) { @@ -431,18 +431,18 @@ static int wm8804_set_pll(struct snd_soc_dai *dai, int pll_id, pm_runtime_get_sync(wm8804->dev);
/* set PLLN and PRESCALE */ - snd_soc_update_bits(codec, WM8804_PLL4, 0xf | 0x10, + snd_soc_component_update_bits(component, WM8804_PLL4, 0xf | 0x10, pll_div.n | (pll_div.prescale << 4)); /* set mclkdiv and freqmode */ - snd_soc_update_bits(codec, WM8804_PLL5, 0x3 | 0x8, + snd_soc_component_update_bits(component, WM8804_PLL5, 0x3 | 0x8, pll_div.freqmode | (pll_div.mclkdiv << 3)); /* set PLLK */ - snd_soc_write(codec, WM8804_PLL1, pll_div.k & 0xff); - snd_soc_write(codec, WM8804_PLL2, (pll_div.k >> 8) & 0xff); - snd_soc_write(codec, WM8804_PLL3, pll_div.k >> 16); + snd_soc_component_write(component, WM8804_PLL1, pll_div.k & 0xff); + snd_soc_component_write(component, WM8804_PLL2, (pll_div.k >> 8) & 0xff); + snd_soc_component_write(component, WM8804_PLL3, pll_div.k >> 16);
/* power up the PLL */ - snd_soc_update_bits(codec, WM8804_PWRDN, 0x1, 0); + snd_soc_component_update_bits(component, WM8804_PWRDN, 0x1, 0); }
return 0; @@ -451,15 +451,15 @@ static int wm8804_set_pll(struct snd_soc_dai *dai, int pll_id, static int wm8804_set_sysclk(struct snd_soc_dai *dai, int clk_id, unsigned int freq, int dir) { - struct snd_soc_codec *codec; + struct snd_soc_component *component;
- codec = dai->codec; + component = dai->component;
switch (clk_id) { case WM8804_TX_CLKSRC_MCLK: if ((freq >= 10000000 && freq <= 14400000) || (freq >= 16280000 && freq <= 27000000)) - snd_soc_update_bits(codec, WM8804_PLL6, 0x80, 0x80); + snd_soc_component_update_bits(component, WM8804_PLL6, 0x80, 0x80); else { dev_err(dai->dev, "OSCCLOCK is not within the " "recommended range: %uHz\n", freq); @@ -467,13 +467,13 @@ static int wm8804_set_sysclk(struct snd_soc_dai *dai, } break; case WM8804_TX_CLKSRC_PLL: - snd_soc_update_bits(codec, WM8804_PLL6, 0x80, 0); + snd_soc_component_update_bits(component, WM8804_PLL6, 0x80, 0); break; case WM8804_CLKOUT_SRC_CLK1: - snd_soc_update_bits(codec, WM8804_PLL6, 0x8, 0); + snd_soc_component_update_bits(component, WM8804_PLL6, 0x8, 0); break; case WM8804_CLKOUT_SRC_OSCCLK: - snd_soc_update_bits(codec, WM8804_PLL6, 0x8, 0x8); + snd_soc_component_update_bits(component, WM8804_PLL6, 0x8, 0x8); break; default: 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, static int wm8804_set_clkdiv(struct snd_soc_dai *dai, int div_id, int div) { - struct snd_soc_codec *codec; + struct snd_soc_component *component; struct wm8804_priv *wm8804;
- codec = dai->codec; + component = dai->component; switch (div_id) { case WM8804_CLKOUT_DIV: - snd_soc_update_bits(codec, WM8804_PLL5, 0x30, + snd_soc_component_update_bits(component, WM8804_PLL5, 0x30, (div & 0x3) << 4); break; case WM8804_MCLK_DIV: - wm8804 = snd_soc_codec_get_drvdata(codec); + wm8804 = snd_soc_component_get_drvdata(component); wm8804->mclk_div = div; break; default: @@ -542,15 +542,14 @@ static int wm8804_set_clkdiv(struct snd_soc_dai *dai, .symmetric_rates = 1 };
-static const struct snd_soc_codec_driver soc_codec_dev_wm8804 = { - .idle_bias_off = true, - - .component_driver = { - .dapm_widgets = wm8804_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(wm8804_dapm_widgets), - .dapm_routes = wm8804_dapm_routes, - .num_dapm_routes = ARRAY_SIZE(wm8804_dapm_routes), - }, +static const struct snd_soc_component_driver soc_component_dev_wm8804 = { + .dapm_widgets = wm8804_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(wm8804_dapm_widgets), + .dapm_routes = wm8804_dapm_routes, + .num_dapm_routes = ARRAY_SIZE(wm8804_dapm_routes), + .pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, };
const struct regmap_config wm8804_regmap_config = { @@ -661,7 +660,7 @@ int wm8804_probe(struct device *dev, struct regmap *regmap) } }
- ret = snd_soc_register_codec(dev, &soc_codec_dev_wm8804, + ret = devm_snd_soc_register_component(dev, &soc_component_dev_wm8804, &wm8804_dai, 1); if (ret < 0) { dev_err(dev, "Failed to register CODEC: %d\n", ret); @@ -683,7 +682,6 @@ int wm8804_probe(struct device *dev, struct regmap *regmap) void wm8804_remove(struct device *dev) { pm_runtime_disable(dev); - snd_soc_unregister_codec(dev); } EXPORT_SYMBOL_GPL(wm8804_remove);
From: Kuninori Morimoto kuninori.morimoto.gx@renesas.com
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 -> .pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com --- sound/soc/codecs/wm8900.c | 251 +++++++++++++++++++++++----------------------- 1 file changed, 125 insertions(+), 126 deletions(-)
diff --git a/sound/soc/codecs/wm8900.c b/sound/soc/codecs/wm8900.c index c77b49a..74a7d0c 100644 --- a/sound/soc/codecs/wm8900.c +++ b/sound/soc/codecs/wm8900.c @@ -216,23 +216,23 @@ static bool wm8900_volatile_register(struct device *dev, unsigned int reg) } }
-static void wm8900_reset(struct snd_soc_codec *codec) +static void wm8900_reset(struct snd_soc_component *component) { - snd_soc_write(codec, WM8900_REG_RESET, 0); + snd_soc_component_write(component, WM8900_REG_RESET, 0); }
static int wm8900_hp_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); - u16 hpctl1 = snd_soc_read(codec, WM8900_REG_HPCTL1); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); + u16 hpctl1 = snd_soc_component_read32(component, WM8900_REG_HPCTL1);
switch (event) { case SND_SOC_DAPM_PRE_PMU: /* Clamp headphone outputs */ hpctl1 = WM8900_REG_HPCTL1_HP_CLAMP_IP | WM8900_REG_HPCTL1_HP_CLAMP_OP; - snd_soc_write(codec, WM8900_REG_HPCTL1, hpctl1); + snd_soc_component_write(component, WM8900_REG_HPCTL1, hpctl1); break;
case SND_SOC_DAPM_POST_PMU: @@ -241,41 +241,41 @@ static int wm8900_hp_event(struct snd_soc_dapm_widget *w, hpctl1 |= WM8900_REG_HPCTL1_HP_SHORT | WM8900_REG_HPCTL1_HP_SHORT2 | WM8900_REG_HPCTL1_HP_IPSTAGE_ENA; - snd_soc_write(codec, WM8900_REG_HPCTL1, hpctl1); + snd_soc_component_write(component, WM8900_REG_HPCTL1, hpctl1);
msleep(400);
/* Enable the output stage */ hpctl1 &= ~WM8900_REG_HPCTL1_HP_CLAMP_OP; hpctl1 |= WM8900_REG_HPCTL1_HP_OPSTAGE_ENA; - snd_soc_write(codec, WM8900_REG_HPCTL1, hpctl1); + snd_soc_component_write(component, WM8900_REG_HPCTL1, hpctl1);
/* Remove the shorts */ hpctl1 &= ~WM8900_REG_HPCTL1_HP_SHORT2; - snd_soc_write(codec, WM8900_REG_HPCTL1, hpctl1); + snd_soc_component_write(component, WM8900_REG_HPCTL1, hpctl1); hpctl1 &= ~WM8900_REG_HPCTL1_HP_SHORT; - snd_soc_write(codec, WM8900_REG_HPCTL1, hpctl1); + snd_soc_component_write(component, WM8900_REG_HPCTL1, hpctl1); break;
case SND_SOC_DAPM_PRE_PMD: /* Short the output */ hpctl1 |= WM8900_REG_HPCTL1_HP_SHORT; - snd_soc_write(codec, WM8900_REG_HPCTL1, hpctl1); + snd_soc_component_write(component, WM8900_REG_HPCTL1, hpctl1);
/* Disable the output stage */ hpctl1 &= ~WM8900_REG_HPCTL1_HP_OPSTAGE_ENA; - snd_soc_write(codec, WM8900_REG_HPCTL1, hpctl1); + snd_soc_component_write(component, WM8900_REG_HPCTL1, hpctl1);
/* Clamp the outputs and power down input */ hpctl1 |= WM8900_REG_HPCTL1_HP_CLAMP_IP | WM8900_REG_HPCTL1_HP_CLAMP_OP; hpctl1 &= ~WM8900_REG_HPCTL1_HP_IPSTAGE_ENA; - snd_soc_write(codec, WM8900_REG_HPCTL1, hpctl1); + snd_soc_component_write(component, WM8900_REG_HPCTL1, hpctl1); break;
case SND_SOC_DAPM_POST_PMD: /* Disable everything */ - snd_soc_write(codec, WM8900_REG_HPCTL1, 0); + snd_soc_component_write(component, WM8900_REG_HPCTL1, 0); break;
default: @@ -635,10 +635,10 @@ static int wm8900_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; + struct snd_soc_component *component = dai->component; u16 reg;
- reg = snd_soc_read(codec, WM8900_REG_AUDIO1) & ~0x60; + reg = snd_soc_component_read32(component, WM8900_REG_AUDIO1) & ~0x60;
switch (params_width(params)) { case 16: @@ -656,17 +656,17 @@ static int wm8900_hw_params(struct snd_pcm_substream *substream, return -EINVAL; }
- snd_soc_write(codec, WM8900_REG_AUDIO1, reg); + snd_soc_component_write(component, WM8900_REG_AUDIO1, reg);
if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { - reg = snd_soc_read(codec, WM8900_REG_DACCTRL); + reg = snd_soc_component_read32(component, WM8900_REG_DACCTRL);
if (params_rate(params) <= 24000) reg |= WM8900_REG_DACCTRL_DAC_SB_FILT; else reg &= ~WM8900_REG_DACCTRL_DAC_SB_FILT;
- snd_soc_write(codec, WM8900_REG_DACCTRL, reg); + snd_soc_component_write(component, WM8900_REG_DACCTRL, reg); }
return 0; @@ -751,24 +751,24 @@ static int fll_factors(struct _fll_div *fll_div, unsigned int Fref, return 0; }
-static int wm8900_set_fll(struct snd_soc_codec *codec, +static int wm8900_set_fll(struct snd_soc_component *component, int fll_id, unsigned int freq_in, unsigned int freq_out) { - struct wm8900_priv *wm8900 = snd_soc_codec_get_drvdata(codec); + struct wm8900_priv *wm8900 = snd_soc_component_get_drvdata(component); struct _fll_div fll_div;
if (wm8900->fll_in == freq_in && wm8900->fll_out == freq_out) return 0;
/* The digital side should be disabled during any change. */ - snd_soc_update_bits(codec, WM8900_REG_POWER1, + snd_soc_component_update_bits(component, WM8900_REG_POWER1, WM8900_REG_POWER1_FLL_ENA, 0);
/* Disable the FLL? */ if (!freq_in || !freq_out) { - snd_soc_update_bits(codec, WM8900_REG_CLOCKING1, + snd_soc_component_update_bits(component, WM8900_REG_CLOCKING1, WM8900_REG_CLOCKING1_MCLK_SRC, 0); - snd_soc_update_bits(codec, WM8900_REG_FLLCTL1, + snd_soc_component_update_bits(component, WM8900_REG_FLLCTL1, WM8900_REG_FLLCTL1_OSC_ENA, 0); wm8900->fll_in = freq_in; wm8900->fll_out = freq_out; @@ -784,32 +784,32 @@ static int wm8900_set_fll(struct snd_soc_codec *codec,
/* The osclilator *MUST* be enabled before we enable the * digital circuit. */ - snd_soc_write(codec, WM8900_REG_FLLCTL1, + snd_soc_component_write(component, WM8900_REG_FLLCTL1, fll_div.fll_ratio | WM8900_REG_FLLCTL1_OSC_ENA);
- snd_soc_write(codec, WM8900_REG_FLLCTL4, fll_div.n >> 5); - snd_soc_write(codec, WM8900_REG_FLLCTL5, + snd_soc_component_write(component, WM8900_REG_FLLCTL4, fll_div.n >> 5); + snd_soc_component_write(component, WM8900_REG_FLLCTL5, (fll_div.fllclk_div << 6) | (fll_div.n & 0x1f));
if (fll_div.k) { - snd_soc_write(codec, WM8900_REG_FLLCTL2, + snd_soc_component_write(component, WM8900_REG_FLLCTL2, (fll_div.k >> 8) | 0x100); - snd_soc_write(codec, WM8900_REG_FLLCTL3, fll_div.k & 0xff); + snd_soc_component_write(component, WM8900_REG_FLLCTL3, fll_div.k & 0xff); } else - snd_soc_write(codec, WM8900_REG_FLLCTL2, 0); + snd_soc_component_write(component, WM8900_REG_FLLCTL2, 0);
if (fll_div.fll_slow_lock_ref) - snd_soc_write(codec, WM8900_REG_FLLCTL6, + snd_soc_component_write(component, WM8900_REG_FLLCTL6, WM8900_REG_FLLCTL6_FLL_SLOW_LOCK_REF); else - snd_soc_write(codec, WM8900_REG_FLLCTL6, 0); + snd_soc_component_write(component, WM8900_REG_FLLCTL6, 0);
- snd_soc_update_bits(codec, WM8900_REG_POWER1, + snd_soc_component_update_bits(component, WM8900_REG_POWER1, WM8900_REG_POWER1_FLL_ENA, WM8900_REG_POWER1_FLL_ENA);
reenable: - snd_soc_update_bits(codec, WM8900_REG_CLOCKING1, + snd_soc_component_update_bits(component, WM8900_REG_CLOCKING1, WM8900_REG_CLOCKING1_MCLK_SRC, WM8900_REG_CLOCKING1_MCLK_SRC); return 0; @@ -818,41 +818,41 @@ static int wm8900_set_fll(struct snd_soc_codec *codec, static int wm8900_set_dai_pll(struct snd_soc_dai *codec_dai, int pll_id, int source, unsigned int freq_in, unsigned int freq_out) { - return wm8900_set_fll(codec_dai->codec, pll_id, freq_in, freq_out); + return wm8900_set_fll(codec_dai->component, pll_id, freq_in, freq_out); }
static int wm8900_set_dai_clkdiv(struct snd_soc_dai *codec_dai, int div_id, int div) { - struct snd_soc_codec *codec = codec_dai->codec; + struct snd_soc_component *component = codec_dai->component;
switch (div_id) { case WM8900_BCLK_DIV: - snd_soc_update_bits(codec, WM8900_REG_CLOCKING1, + snd_soc_component_update_bits(component, WM8900_REG_CLOCKING1, WM8900_REG_CLOCKING1_BCLK_MASK, div); break; case WM8900_OPCLK_DIV: - snd_soc_update_bits(codec, WM8900_REG_CLOCKING1, + snd_soc_component_update_bits(component, WM8900_REG_CLOCKING1, WM8900_REG_CLOCKING1_OPCLK_MASK, div); break; case WM8900_DAC_LRCLK: - snd_soc_update_bits(codec, WM8900_REG_AUDIO4, + snd_soc_component_update_bits(component, WM8900_REG_AUDIO4, WM8900_LRC_MASK, div); break; case WM8900_ADC_LRCLK: - snd_soc_update_bits(codec, WM8900_REG_AUDIO3, + snd_soc_component_update_bits(component, WM8900_REG_AUDIO3, WM8900_LRC_MASK, div); break; case WM8900_DAC_CLKDIV: - snd_soc_update_bits(codec, WM8900_REG_CLOCKING2, + snd_soc_component_update_bits(component, WM8900_REG_CLOCKING2, WM8900_REG_CLOCKING2_DAC_CLKDIV, div); break; case WM8900_ADC_CLKDIV: - snd_soc_update_bits(codec, WM8900_REG_CLOCKING2, + snd_soc_component_update_bits(component, WM8900_REG_CLOCKING2, WM8900_REG_CLOCKING2_ADC_CLKDIV, div); break; case WM8900_LRCLK_MODE: - snd_soc_update_bits(codec, WM8900_REG_DACCTRL, + snd_soc_component_update_bits(component, WM8900_REG_DACCTRL, WM8900_REG_DACCTRL_AIF_LRCLKRATE, div); break; default: @@ -866,13 +866,13 @@ static int wm8900_set_dai_clkdiv(struct snd_soc_dai *codec_dai, static int wm8900_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt) { - struct snd_soc_codec *codec = codec_dai->codec; + struct snd_soc_component *component = codec_dai->component; unsigned int clocking1, aif1, aif3, aif4;
- clocking1 = snd_soc_read(codec, WM8900_REG_CLOCKING1); - aif1 = snd_soc_read(codec, WM8900_REG_AUDIO1); - aif3 = snd_soc_read(codec, WM8900_REG_AUDIO3); - aif4 = snd_soc_read(codec, WM8900_REG_AUDIO4); + clocking1 = snd_soc_component_read32(component, WM8900_REG_CLOCKING1); + aif1 = snd_soc_component_read32(component, WM8900_REG_AUDIO1); + aif3 = snd_soc_component_read32(component, WM8900_REG_AUDIO3); + aif4 = snd_soc_component_read32(component, WM8900_REG_AUDIO4);
/* set master/slave audio interface */ switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { @@ -968,27 +968,27 @@ static int wm8900_set_dai_fmt(struct snd_soc_dai *codec_dai, return -EINVAL; }
- snd_soc_write(codec, WM8900_REG_CLOCKING1, clocking1); - snd_soc_write(codec, WM8900_REG_AUDIO1, aif1); - snd_soc_write(codec, WM8900_REG_AUDIO3, aif3); - snd_soc_write(codec, WM8900_REG_AUDIO4, aif4); + snd_soc_component_write(component, WM8900_REG_CLOCKING1, clocking1); + snd_soc_component_write(component, WM8900_REG_AUDIO1, aif1); + snd_soc_component_write(component, WM8900_REG_AUDIO3, aif3); + snd_soc_component_write(component, WM8900_REG_AUDIO4, aif4);
return 0; }
static int wm8900_digital_mute(struct snd_soc_dai *codec_dai, int mute) { - struct snd_soc_codec *codec = codec_dai->codec; + struct snd_soc_component *component = codec_dai->component; u16 reg;
- reg = snd_soc_read(codec, WM8900_REG_DACCTRL); + reg = snd_soc_component_read32(component, WM8900_REG_DACCTRL);
if (mute) reg |= WM8900_REG_DACCTRL_MUTE; else reg &= ~WM8900_REG_DACCTRL_MUTE;
- snd_soc_write(codec, WM8900_REG_DACCTRL, reg); + snd_soc_component_write(component, WM8900_REG_DACCTRL, reg);
return 0; } @@ -1028,7 +1028,7 @@ static int wm8900_digital_mute(struct snd_soc_dai *codec_dai, int mute) .ops = &wm8900_dai_ops, };
-static int wm8900_set_bias_level(struct snd_soc_codec *codec, +static int wm8900_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { u16 reg; @@ -1036,10 +1036,10 @@ static int wm8900_set_bias_level(struct snd_soc_codec *codec, switch (level) { case SND_SOC_BIAS_ON: /* Enable thermal shutdown */ - snd_soc_update_bits(codec, WM8900_REG_GPIO, + snd_soc_component_update_bits(component, WM8900_REG_GPIO, WM8900_REG_GPIO_TEMP_ENA, WM8900_REG_GPIO_TEMP_ENA); - snd_soc_update_bits(codec, WM8900_REG_ADDCTL, + snd_soc_component_update_bits(component, WM8900_REG_ADDCTL, WM8900_REG_ADDCTL_TEMP_SD, WM8900_REG_ADDCTL_TEMP_SD); break; @@ -1049,113 +1049,113 @@ static int wm8900_set_bias_level(struct snd_soc_codec *codec,
case SND_SOC_BIAS_STANDBY: /* Charge capacitors if initial power up */ - if (snd_soc_codec_get_bias_level(codec) == SND_SOC_BIAS_OFF) { + if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_OFF) { /* STARTUP_BIAS_ENA on */ - snd_soc_write(codec, WM8900_REG_POWER1, + snd_soc_component_write(component, WM8900_REG_POWER1, WM8900_REG_POWER1_STARTUP_BIAS_ENA);
/* Startup bias mode */ - snd_soc_write(codec, WM8900_REG_ADDCTL, + snd_soc_component_write(component, WM8900_REG_ADDCTL, WM8900_REG_ADDCTL_BIAS_SRC | WM8900_REG_ADDCTL_VMID_SOFTST);
/* VMID 2x50k */ - snd_soc_write(codec, WM8900_REG_POWER1, + snd_soc_component_write(component, WM8900_REG_POWER1, WM8900_REG_POWER1_STARTUP_BIAS_ENA | 0x1);
/* Allow capacitors to charge */ schedule_timeout_interruptible(msecs_to_jiffies(400));
/* Enable bias */ - snd_soc_write(codec, WM8900_REG_POWER1, + snd_soc_component_write(component, WM8900_REG_POWER1, WM8900_REG_POWER1_STARTUP_BIAS_ENA | WM8900_REG_POWER1_BIAS_ENA | 0x1);
- snd_soc_write(codec, WM8900_REG_ADDCTL, 0); + snd_soc_component_write(component, WM8900_REG_ADDCTL, 0);
- snd_soc_write(codec, WM8900_REG_POWER1, + snd_soc_component_write(component, WM8900_REG_POWER1, WM8900_REG_POWER1_BIAS_ENA | 0x1); }
- reg = snd_soc_read(codec, WM8900_REG_POWER1); - snd_soc_write(codec, WM8900_REG_POWER1, + reg = snd_soc_component_read32(component, WM8900_REG_POWER1); + snd_soc_component_write(component, WM8900_REG_POWER1, (reg & WM8900_REG_POWER1_FLL_ENA) | WM8900_REG_POWER1_BIAS_ENA | 0x1); - snd_soc_write(codec, WM8900_REG_POWER2, + snd_soc_component_write(component, WM8900_REG_POWER2, WM8900_REG_POWER2_SYSCLK_ENA); - snd_soc_write(codec, WM8900_REG_POWER3, 0); + snd_soc_component_write(component, WM8900_REG_POWER3, 0); break;
case SND_SOC_BIAS_OFF: /* Startup bias enable */ - reg = snd_soc_read(codec, WM8900_REG_POWER1); - snd_soc_write(codec, WM8900_REG_POWER1, + reg = snd_soc_component_read32(component, WM8900_REG_POWER1); + snd_soc_component_write(component, WM8900_REG_POWER1, reg & WM8900_REG_POWER1_STARTUP_BIAS_ENA); - snd_soc_write(codec, WM8900_REG_ADDCTL, + snd_soc_component_write(component, WM8900_REG_ADDCTL, WM8900_REG_ADDCTL_BIAS_SRC | WM8900_REG_ADDCTL_VMID_SOFTST);
/* Discharge caps */ - snd_soc_write(codec, WM8900_REG_POWER1, + snd_soc_component_write(component, WM8900_REG_POWER1, WM8900_REG_POWER1_STARTUP_BIAS_ENA); schedule_timeout_interruptible(msecs_to_jiffies(500));
/* Remove clamp */ - snd_soc_write(codec, WM8900_REG_HPCTL1, 0); + snd_soc_component_write(component, WM8900_REG_HPCTL1, 0);
/* Power down */ - snd_soc_write(codec, WM8900_REG_ADDCTL, 0); - snd_soc_write(codec, WM8900_REG_POWER1, 0); - snd_soc_write(codec, WM8900_REG_POWER2, 0); - snd_soc_write(codec, WM8900_REG_POWER3, 0); + snd_soc_component_write(component, WM8900_REG_ADDCTL, 0); + snd_soc_component_write(component, WM8900_REG_POWER1, 0); + snd_soc_component_write(component, WM8900_REG_POWER2, 0); + snd_soc_component_write(component, WM8900_REG_POWER3, 0);
/* Need to let things settle before stopping the clock * to ensure that restart works, see "Stopping the * master clock" in the datasheet. */ schedule_timeout_interruptible(msecs_to_jiffies(1)); - snd_soc_write(codec, WM8900_REG_POWER2, + snd_soc_component_write(component, WM8900_REG_POWER2, WM8900_REG_POWER2_SYSCLK_ENA); break; } return 0; }
-static int wm8900_suspend(struct snd_soc_codec *codec) +static int wm8900_suspend(struct snd_soc_component *component) { - struct wm8900_priv *wm8900 = snd_soc_codec_get_drvdata(codec); + struct wm8900_priv *wm8900 = snd_soc_component_get_drvdata(component); int fll_out = wm8900->fll_out; int fll_in = wm8900->fll_in; int ret;
/* Stop the FLL in an orderly fashion */ - ret = wm8900_set_fll(codec, 0, 0, 0); + ret = wm8900_set_fll(component, 0, 0, 0); if (ret != 0) { - dev_err(codec->dev, "Failed to stop FLL\n"); + dev_err(component->dev, "Failed to stop FLL\n"); return ret; }
wm8900->fll_out = fll_out; wm8900->fll_in = fll_in;
- snd_soc_codec_force_bias_level(codec, SND_SOC_BIAS_OFF); + snd_soc_component_force_bias_level(component, SND_SOC_BIAS_OFF);
return 0; }
-static int wm8900_resume(struct snd_soc_codec *codec) +static int wm8900_resume(struct snd_soc_component *component) { - struct wm8900_priv *wm8900 = snd_soc_codec_get_drvdata(codec); + struct wm8900_priv *wm8900 = snd_soc_component_get_drvdata(component); int ret;
- wm8900_reset(codec); + wm8900_reset(component);
ret = regcache_sync(wm8900->regmap); if (ret != 0) { - dev_err(codec->dev, "Failed to restore cache: %d\n", ret); + dev_err(component->dev, "Failed to restore cache: %d\n", ret); return ret; }
- snd_soc_codec_force_bias_level(codec, SND_SOC_BIAS_STANDBY); + snd_soc_component_force_bias_level(component, SND_SOC_BIAS_STANDBY);
/* Restart the FLL? */ if (wm8900->fll_out) { @@ -1165,9 +1165,9 @@ static int wm8900_resume(struct snd_soc_codec *codec) wm8900->fll_in = 0; wm8900->fll_out = 0;
- ret = wm8900_set_fll(codec, 0, fll_in, fll_out); + ret = wm8900_set_fll(component, 0, fll_in, fll_out); if (ret != 0) { - dev_err(codec->dev, "Failed to restart FLL\n"); + dev_err(component->dev, "Failed to restart FLL\n"); return ret; } } @@ -1175,53 +1175,54 @@ static int wm8900_resume(struct snd_soc_codec *codec) return 0; }
-static int wm8900_probe(struct snd_soc_codec *codec) +static int wm8900_probe(struct snd_soc_component *component) { int reg;
- reg = snd_soc_read(codec, WM8900_REG_ID); + reg = snd_soc_component_read32(component, WM8900_REG_ID); if (reg != 0x8900) { - dev_err(codec->dev, "Device is not a WM8900 - ID %x\n", reg); + dev_err(component->dev, "Device is not a WM8900 - ID %x\n", reg); return -ENODEV; }
- wm8900_reset(codec); + wm8900_reset(component);
/* Turn the chip on */ - snd_soc_codec_force_bias_level(codec, SND_SOC_BIAS_STANDBY); + snd_soc_component_force_bias_level(component, SND_SOC_BIAS_STANDBY);
/* Latch the volume update bits */ - snd_soc_update_bits(codec, WM8900_REG_LINVOL, 0x100, 0x100); - snd_soc_update_bits(codec, WM8900_REG_RINVOL, 0x100, 0x100); - snd_soc_update_bits(codec, WM8900_REG_LOUT1CTL, 0x100, 0x100); - snd_soc_update_bits(codec, WM8900_REG_ROUT1CTL, 0x100, 0x100); - snd_soc_update_bits(codec, WM8900_REG_LOUT2CTL, 0x100, 0x100); - snd_soc_update_bits(codec, WM8900_REG_ROUT2CTL, 0x100, 0x100); - snd_soc_update_bits(codec, WM8900_REG_LDAC_DV, 0x100, 0x100); - snd_soc_update_bits(codec, WM8900_REG_RDAC_DV, 0x100, 0x100); - snd_soc_update_bits(codec, WM8900_REG_LADC_DV, 0x100, 0x100); - snd_soc_update_bits(codec, WM8900_REG_RADC_DV, 0x100, 0x100); + snd_soc_component_update_bits(component, WM8900_REG_LINVOL, 0x100, 0x100); + snd_soc_component_update_bits(component, WM8900_REG_RINVOL, 0x100, 0x100); + snd_soc_component_update_bits(component, WM8900_REG_LOUT1CTL, 0x100, 0x100); + snd_soc_component_update_bits(component, WM8900_REG_ROUT1CTL, 0x100, 0x100); + snd_soc_component_update_bits(component, WM8900_REG_LOUT2CTL, 0x100, 0x100); + snd_soc_component_update_bits(component, WM8900_REG_ROUT2CTL, 0x100, 0x100); + snd_soc_component_update_bits(component, WM8900_REG_LDAC_DV, 0x100, 0x100); + snd_soc_component_update_bits(component, WM8900_REG_RDAC_DV, 0x100, 0x100); + snd_soc_component_update_bits(component, WM8900_REG_LADC_DV, 0x100, 0x100); + snd_soc_component_update_bits(component, WM8900_REG_RADC_DV, 0x100, 0x100);
/* Set the DAC and mixer output bias */ - snd_soc_write(codec, WM8900_REG_OUTBIASCTL, 0x81); + snd_soc_component_write(component, WM8900_REG_OUTBIASCTL, 0x81);
return 0; }
-static const struct snd_soc_codec_driver soc_codec_dev_wm8900 = { - .probe = wm8900_probe, - .suspend = wm8900_suspend, - .resume = wm8900_resume, - .set_bias_level = wm8900_set_bias_level, - - .component_driver = { - .controls = wm8900_snd_controls, - .num_controls = ARRAY_SIZE(wm8900_snd_controls), - .dapm_widgets = wm8900_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(wm8900_dapm_widgets), - .dapm_routes = wm8900_dapm_routes, - .num_dapm_routes = ARRAY_SIZE(wm8900_dapm_routes), - }, +static const struct snd_soc_component_driver soc_component_dev_wm8900 = { + .probe = wm8900_probe, + .suspend = wm8900_suspend, + .resume = wm8900_resume, + .set_bias_level = wm8900_set_bias_level, + .controls = wm8900_snd_controls, + .num_controls = ARRAY_SIZE(wm8900_snd_controls), + .dapm_widgets = wm8900_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(wm8900_dapm_widgets), + .dapm_routes = wm8900_dapm_routes, + .num_dapm_routes = ARRAY_SIZE(wm8900_dapm_routes), + .idle_bias_on = 1, + .pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, };
static const struct regmap_config wm8900_regmap = { @@ -1253,15 +1254,14 @@ static int wm8900_spi_probe(struct spi_device *spi)
spi_set_drvdata(spi, wm8900);
- ret = snd_soc_register_codec(&spi->dev, - &soc_codec_dev_wm8900, &wm8900_dai, 1); + ret = devm_snd_soc_register_component(&spi->dev, + &soc_component_dev_wm8900, &wm8900_dai, 1);
return ret; }
static int wm8900_spi_remove(struct spi_device *spi) { - snd_soc_unregister_codec(&spi->dev); return 0; }
@@ -1292,15 +1292,14 @@ static int wm8900_i2c_probe(struct i2c_client *i2c,
i2c_set_clientdata(i2c, wm8900);
- ret = snd_soc_register_codec(&i2c->dev, - &soc_codec_dev_wm8900, &wm8900_dai, 1); + ret = devm_snd_soc_register_component(&i2c->dev, + &soc_component_dev_wm8900, &wm8900_dai, 1);
return ret; }
static int wm8900_i2c_remove(struct i2c_client *client) { - snd_soc_unregister_codec(&client->dev); return 0; }
From: Kuninori Morimoto kuninori.morimoto.gx@renesas.com
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 -> .pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com --- sound/soc/codecs/wm8903.c | 211 ++++++++++++++++++++--------------------- sound/soc/codecs/wm8903.h | 2 +- sound/soc/tegra/tegra_wm8903.c | 8 +- 3 files changed, 110 insertions(+), 111 deletions(-)
diff --git a/sound/soc/codecs/wm8903.c b/sound/soc/codecs/wm8903.c index cba90f2..34056fc 100644 --- a/sound/soc/codecs/wm8903.c +++ b/sound/soc/codecs/wm8903.c @@ -270,15 +270,15 @@ static int wm8903_cp_event(struct snd_soc_dapm_widget *w, static int wm8903_dcs_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); - struct wm8903_priv *wm8903 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); + struct wm8903_priv *wm8903 = snd_soc_component_get_drvdata(component);
switch (event) { case SND_SOC_DAPM_POST_PMU: wm8903->dcs_pending |= 1 << w->shift; break; case SND_SOC_DAPM_PRE_PMD: - snd_soc_update_bits(codec, WM8903_DC_SERVO_0, + snd_soc_component_update_bits(component, WM8903_DC_SERVO_0, 1 << w->shift, 0); break; } @@ -289,17 +289,16 @@ static int wm8903_dcs_event(struct snd_soc_dapm_widget *w, #define WM8903_DCS_MODE_WRITE_STOP 0 #define WM8903_DCS_MODE_START_STOP 2
-static void wm8903_seq_notifier(struct snd_soc_dapm_context *dapm, +static void wm8903_seq_notifier(struct snd_soc_component *component, enum snd_soc_dapm_type event, int subseq) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(dapm); - struct wm8903_priv *wm8903 = snd_soc_codec_get_drvdata(codec); + struct wm8903_priv *wm8903 = snd_soc_component_get_drvdata(component); int dcs_mode = WM8903_DCS_MODE_WRITE_STOP; int i, val;
/* Complete any pending DC servo starts */ if (wm8903->dcs_pending) { - dev_dbg(codec->dev, "Starting DC servo for %x\n", + dev_dbg(component->dev, "Starting DC servo for %x\n", wm8903->dcs_pending);
/* If we've no cached values then we need to do startup */ @@ -308,14 +307,14 @@ static void wm8903_seq_notifier(struct snd_soc_dapm_context *dapm, continue;
if (wm8903->dcs_cache[i]) { - dev_dbg(codec->dev, + dev_dbg(component->dev, "Restore DC servo %d value %x\n", 3 - i, wm8903->dcs_cache[i]);
- snd_soc_write(codec, WM8903_DC_SERVO_4 + i, + snd_soc_component_write(component, WM8903_DC_SERVO_4 + i, wm8903->dcs_cache[i] & 0xff); } else { - dev_dbg(codec->dev, + dev_dbg(component->dev, "Calibrate DC servo %d\n", 3 - i); dcs_mode = WM8903_DCS_MODE_START_STOP; } @@ -325,10 +324,10 @@ static void wm8903_seq_notifier(struct snd_soc_dapm_context *dapm, if (wm8903->class_w_users) dcs_mode = WM8903_DCS_MODE_START_STOP;
- snd_soc_update_bits(codec, WM8903_DC_SERVO_2, + snd_soc_component_update_bits(component, WM8903_DC_SERVO_2, WM8903_DCS_MODE_MASK, dcs_mode);
- snd_soc_update_bits(codec, WM8903_DC_SERVO_0, + snd_soc_component_update_bits(component, WM8903_DC_SERVO_0, WM8903_DCS_ENA_MASK, wm8903->dcs_pending);
switch (dcs_mode) { @@ -346,9 +345,9 @@ static void wm8903_seq_notifier(struct snd_soc_dapm_context *dapm, if (!(wm8903->dcs_pending & (1 << i))) continue;
- val = snd_soc_read(codec, + val = snd_soc_component_read32(component, WM8903_DC_SERVO_READBACK_1 + i); - dev_dbg(codec->dev, "DC servo %d: %x\n", + dev_dbg(component->dev, "DC servo %d: %x\n", 3 - i, val); wm8903->dcs_cache[i] = val; } @@ -374,18 +373,18 @@ static void wm8903_seq_notifier(struct snd_soc_dapm_context *dapm, static int wm8903_class_w_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_dapm_kcontrol_codec(kcontrol); - struct wm8903_priv *wm8903 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_dapm_kcontrol_component(kcontrol); + struct wm8903_priv *wm8903 = snd_soc_component_get_drvdata(component); u16 reg; int ret;
- reg = snd_soc_read(codec, WM8903_CLASS_W_0); + reg = snd_soc_component_read32(component, WM8903_CLASS_W_0);
/* Turn it off if we're about to enable bypass */ if (ucontrol->value.integer.value[0]) { if (wm8903->class_w_users == 0) { - dev_dbg(codec->dev, "Disabling Class W\n"); - snd_soc_write(codec, WM8903_CLASS_W_0, reg & + dev_dbg(component->dev, "Disabling Class W\n"); + snd_soc_component_write(component, WM8903_CLASS_W_0, reg & ~(WM8903_CP_DYN_FREQ | WM8903_CP_DYN_V)); } wm8903->class_w_users++; @@ -397,14 +396,14 @@ static int wm8903_class_w_put(struct snd_kcontrol *kcontrol, /* If we've just disabled the last bypass path turn Class W on */ if (!ucontrol->value.integer.value[0]) { if (wm8903->class_w_users == 1) { - dev_dbg(codec->dev, "Enabling Class W\n"); - snd_soc_write(codec, WM8903_CLASS_W_0, reg | + dev_dbg(component->dev, "Enabling Class W\n"); + snd_soc_component_write(component, WM8903_CLASS_W_0, reg | WM8903_CP_DYN_FREQ | WM8903_CP_DYN_V); } wm8903->class_w_users--; }
- dev_dbg(codec->dev, "Bypass use count now %d\n", + dev_dbg(component->dev, "Bypass use count now %d\n", wm8903->class_w_users);
return ret; @@ -417,9 +416,9 @@ static int wm8903_class_w_put(struct snd_kcontrol *kcontrol,
static int wm8903_deemph[] = { 0, 32000, 44100, 48000 };
-static int wm8903_set_deemph(struct snd_soc_codec *codec) +static int wm8903_set_deemph(struct snd_soc_component *component) { - struct wm8903_priv *wm8903 = snd_soc_codec_get_drvdata(codec); + struct wm8903_priv *wm8903 = snd_soc_component_get_drvdata(component); int val, i, best;
/* If we're using deemphasis select the nearest available sample @@ -439,18 +438,18 @@ static int wm8903_set_deemph(struct snd_soc_codec *codec) val = 0; }
- dev_dbg(codec->dev, "Set deemphasis %d (%dHz)\n", + dev_dbg(component->dev, "Set deemphasis %d (%dHz)\n", best, wm8903_deemph[best]);
- return snd_soc_update_bits(codec, WM8903_DAC_DIGITAL_1, + return snd_soc_component_update_bits(component, WM8903_DAC_DIGITAL_1, WM8903_DEEMPH_MASK, val); }
static int wm8903_get_deemph(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct wm8903_priv *wm8903 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct wm8903_priv *wm8903 = snd_soc_component_get_drvdata(component);
ucontrol->value.integer.value[0] = wm8903->deemph;
@@ -460,8 +459,8 @@ static int wm8903_get_deemph(struct snd_kcontrol *kcontrol, static int wm8903_put_deemph(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct wm8903_priv *wm8903 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct wm8903_priv *wm8903 = snd_soc_component_get_drvdata(component); unsigned int deemph = ucontrol->value.integer.value[0]; int ret = 0;
@@ -472,7 +471,7 @@ static int wm8903_put_deemph(struct snd_kcontrol *kcontrol, if (wm8903->deemph != deemph) { wm8903->deemph = deemph;
- wm8903_set_deemph(codec); + wm8903_set_deemph(component);
ret = 1; } @@ -1101,7 +1100,7 @@ static SOC_ENUM_SINGLE_DECL(rplay_enum, { "Right Line Output PGA", NULL, "Charge Pump" }, };
-static int wm8903_set_bias_level(struct snd_soc_codec *codec, +static int wm8903_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { switch (level) { @@ -1109,14 +1108,14 @@ static int wm8903_set_bias_level(struct snd_soc_codec *codec, break;
case SND_SOC_BIAS_PREPARE: - snd_soc_update_bits(codec, WM8903_VMID_CONTROL_0, + snd_soc_component_update_bits(component, WM8903_VMID_CONTROL_0, WM8903_VMID_RES_MASK, WM8903_VMID_RES_50K); break;
case SND_SOC_BIAS_STANDBY: - if (snd_soc_codec_get_bias_level(codec) == SND_SOC_BIAS_OFF) { - snd_soc_update_bits(codec, WM8903_BIAS_CONTROL_0, + if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_OFF) { + snd_soc_component_update_bits(component, WM8903_BIAS_CONTROL_0, WM8903_POBCTRL | WM8903_ISEL_MASK | WM8903_STARTUP_BIAS_ENA | WM8903_BIAS_ENA, @@ -1124,22 +1123,22 @@ static int wm8903_set_bias_level(struct snd_soc_codec *codec, (2 << WM8903_ISEL_SHIFT) | WM8903_STARTUP_BIAS_ENA);
- snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, WM8903_ANALOGUE_SPK_OUTPUT_CONTROL_0, WM8903_SPK_DISCHARGE, WM8903_SPK_DISCHARGE);
msleep(33);
- snd_soc_update_bits(codec, WM8903_POWER_MANAGEMENT_5, + snd_soc_component_update_bits(component, WM8903_POWER_MANAGEMENT_5, WM8903_SPKL_ENA | WM8903_SPKR_ENA, WM8903_SPKL_ENA | WM8903_SPKR_ENA);
- snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, WM8903_ANALOGUE_SPK_OUTPUT_CONTROL_0, WM8903_SPK_DISCHARGE, 0);
- snd_soc_update_bits(codec, WM8903_VMID_CONTROL_0, + snd_soc_component_update_bits(component, WM8903_VMID_CONTROL_0, WM8903_VMID_TIE_ENA | WM8903_BUFIO_ENA | WM8903_VMID_IO_ENA | @@ -1155,57 +1154,57 @@ static int wm8903_set_bias_level(struct snd_soc_codec *codec,
msleep(129);
- snd_soc_update_bits(codec, WM8903_POWER_MANAGEMENT_5, + snd_soc_component_update_bits(component, WM8903_POWER_MANAGEMENT_5, WM8903_SPKL_ENA | WM8903_SPKR_ENA, 0);
- snd_soc_update_bits(codec, WM8903_VMID_CONTROL_0, + snd_soc_component_update_bits(component, WM8903_VMID_CONTROL_0, WM8903_VMID_SOFT_MASK, 0);
- snd_soc_update_bits(codec, WM8903_VMID_CONTROL_0, + snd_soc_component_update_bits(component, WM8903_VMID_CONTROL_0, WM8903_VMID_RES_MASK, WM8903_VMID_RES_50K);
- snd_soc_update_bits(codec, WM8903_BIAS_CONTROL_0, + snd_soc_component_update_bits(component, WM8903_BIAS_CONTROL_0, WM8903_BIAS_ENA | WM8903_POBCTRL, WM8903_BIAS_ENA);
/* By default no bypass paths are enabled so * enable Class W support. */ - dev_dbg(codec->dev, "Enabling Class W\n"); - snd_soc_update_bits(codec, WM8903_CLASS_W_0, + dev_dbg(component->dev, "Enabling Class W\n"); + snd_soc_component_update_bits(component, WM8903_CLASS_W_0, WM8903_CP_DYN_FREQ | WM8903_CP_DYN_V, WM8903_CP_DYN_FREQ | WM8903_CP_DYN_V); }
- snd_soc_update_bits(codec, WM8903_VMID_CONTROL_0, + snd_soc_component_update_bits(component, WM8903_VMID_CONTROL_0, WM8903_VMID_RES_MASK, WM8903_VMID_RES_250K); break;
case SND_SOC_BIAS_OFF: - snd_soc_update_bits(codec, WM8903_BIAS_CONTROL_0, + snd_soc_component_update_bits(component, WM8903_BIAS_CONTROL_0, WM8903_BIAS_ENA, 0);
- snd_soc_update_bits(codec, WM8903_VMID_CONTROL_0, + snd_soc_component_update_bits(component, WM8903_VMID_CONTROL_0, WM8903_VMID_SOFT_MASK, 2 << WM8903_VMID_SOFT_SHIFT);
- snd_soc_update_bits(codec, WM8903_VMID_CONTROL_0, + snd_soc_component_update_bits(component, WM8903_VMID_CONTROL_0, WM8903_VMID_BUF_ENA, 0);
msleep(290);
- snd_soc_update_bits(codec, WM8903_VMID_CONTROL_0, + snd_soc_component_update_bits(component, WM8903_VMID_CONTROL_0, WM8903_VMID_TIE_ENA | WM8903_BUFIO_ENA | WM8903_VMID_IO_ENA | WM8903_VMID_RES_MASK | WM8903_VMID_SOFT_MASK | WM8903_VMID_BUF_ENA, 0);
- snd_soc_update_bits(codec, WM8903_BIAS_CONTROL_0, + snd_soc_component_update_bits(component, WM8903_BIAS_CONTROL_0, WM8903_STARTUP_BIAS_ENA, 0); break; } @@ -1216,8 +1215,8 @@ static int wm8903_set_bias_level(struct snd_soc_codec *codec, static int wm8903_set_dai_sysclk(struct snd_soc_dai *codec_dai, int clk_id, unsigned int freq, int dir) { - struct snd_soc_codec *codec = codec_dai->codec; - struct wm8903_priv *wm8903 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = codec_dai->component; + struct wm8903_priv *wm8903 = snd_soc_component_get_drvdata(component);
wm8903->sysclk = freq;
@@ -1227,8 +1226,8 @@ static int wm8903_set_dai_sysclk(struct snd_soc_dai *codec_dai, static int wm8903_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt) { - struct snd_soc_codec *codec = codec_dai->codec; - u16 aif1 = snd_soc_read(codec, WM8903_AUDIO_INTERFACE_1); + struct snd_soc_component *component = codec_dai->component; + u16 aif1 = snd_soc_component_read32(component, WM8903_AUDIO_INTERFACE_1);
aif1 &= ~(WM8903_LRCLK_DIR | WM8903_BCLK_DIR | WM8903_AIF_FMT_MASK | WM8903_AIF_LRCLK_INV | WM8903_AIF_BCLK_INV); @@ -1306,24 +1305,24 @@ static int wm8903_set_dai_fmt(struct snd_soc_dai *codec_dai, return -EINVAL; }
- snd_soc_write(codec, WM8903_AUDIO_INTERFACE_1, aif1); + snd_soc_component_write(component, WM8903_AUDIO_INTERFACE_1, aif1);
return 0; }
static int wm8903_digital_mute(struct snd_soc_dai *codec_dai, int mute) { - struct snd_soc_codec *codec = codec_dai->codec; + struct snd_soc_component *component = codec_dai->component; u16 reg;
- reg = snd_soc_read(codec, WM8903_DAC_DIGITAL_1); + reg = snd_soc_component_read32(component, WM8903_DAC_DIGITAL_1);
if (mute) reg |= WM8903_DAC_MUTE; else reg &= ~WM8903_DAC_MUTE;
- snd_soc_write(codec, WM8903_DAC_DIGITAL_1, reg); + snd_soc_component_write(component, WM8903_DAC_DIGITAL_1, reg);
return 0; } @@ -1443,8 +1442,8 @@ static int wm8903_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; - struct wm8903_priv *wm8903 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct wm8903_priv *wm8903 = snd_soc_component_get_drvdata(component); int fs = params_rate(params); int bclk; int bclk_div; @@ -1455,12 +1454,12 @@ static int wm8903_hw_params(struct snd_pcm_substream *substream, int cur_val; int clk_sys;
- u16 aif1 = snd_soc_read(codec, WM8903_AUDIO_INTERFACE_1); - u16 aif2 = snd_soc_read(codec, WM8903_AUDIO_INTERFACE_2); - u16 aif3 = snd_soc_read(codec, WM8903_AUDIO_INTERFACE_3); - u16 clock0 = snd_soc_read(codec, WM8903_CLOCK_RATES_0); - u16 clock1 = snd_soc_read(codec, WM8903_CLOCK_RATES_1); - u16 dac_digital1 = snd_soc_read(codec, WM8903_DAC_DIGITAL_1); + u16 aif1 = snd_soc_component_read32(component, WM8903_AUDIO_INTERFACE_1); + u16 aif2 = snd_soc_component_read32(component, WM8903_AUDIO_INTERFACE_2); + u16 aif3 = snd_soc_component_read32(component, WM8903_AUDIO_INTERFACE_3); + u16 clock0 = snd_soc_component_read32(component, WM8903_CLOCK_RATES_0); + u16 clock1 = snd_soc_component_read32(component, WM8903_CLOCK_RATES_1); + u16 dac_digital1 = snd_soc_component_read32(component, WM8903_DAC_DIGITAL_1);
/* Enable sloping stopband filter for low sample rates */ if (fs <= 24000) @@ -1479,7 +1478,7 @@ static int wm8903_hw_params(struct snd_pcm_substream *substream, } }
- dev_dbg(codec->dev, "DSP fs = %dHz\n", sample_rates[dsp_config].rate); + dev_dbg(component->dev, "DSP fs = %dHz\n", sample_rates[dsp_config].rate); clock1 &= ~WM8903_SAMPLE_RATE_MASK; clock1 |= sample_rates[dsp_config].value;
@@ -1505,7 +1504,7 @@ static int wm8903_hw_params(struct snd_pcm_substream *substream, return -EINVAL; }
- dev_dbg(codec->dev, "MCLK = %dHz, target sample rate = %dHz\n", + dev_dbg(component->dev, "MCLK = %dHz, target sample rate = %dHz\n", wm8903->sysclk, fs);
/* We may not have an MCLK which allows us to generate exactly @@ -1540,12 +1539,12 @@ static int wm8903_hw_params(struct snd_pcm_substream *substream, clock1 |= clk_sys_ratios[clk_config].rate << WM8903_CLK_SYS_RATE_SHIFT; clock1 |= clk_sys_ratios[clk_config].mode << WM8903_CLK_SYS_MODE_SHIFT;
- dev_dbg(codec->dev, "CLK_SYS_RATE=%x, CLK_SYS_MODE=%x div=%d\n", + dev_dbg(component->dev, "CLK_SYS_RATE=%x, CLK_SYS_MODE=%x div=%d\n", clk_sys_ratios[clk_config].rate, clk_sys_ratios[clk_config].mode, clk_sys_ratios[clk_config].div);
- dev_dbg(codec->dev, "Actual CLK_SYS = %dHz\n", clk_sys); + dev_dbg(component->dev, "Actual CLK_SYS = %dHz\n", clk_sys);
/* We may not get quite the right frequency if using * approximate clocks so look for the closest match that is @@ -1567,7 +1566,7 @@ static int wm8903_hw_params(struct snd_pcm_substream *substream, aif2 &= ~WM8903_BCLK_DIV_MASK; aif3 &= ~WM8903_LRCLK_RATE_MASK;
- dev_dbg(codec->dev, "BCLK ratio %d for %dHz - actual BCLK = %dHz\n", + dev_dbg(component->dev, "BCLK ratio %d for %dHz - actual BCLK = %dHz\n", bclk_divs[bclk_div].ratio / 10, bclk, (clk_sys * 10) / bclk_divs[bclk_div].ratio);
@@ -1575,14 +1574,14 @@ static int wm8903_hw_params(struct snd_pcm_substream *substream, aif3 |= bclk / fs;
wm8903->fs = params_rate(params); - wm8903_set_deemph(codec); + wm8903_set_deemph(component);
- snd_soc_write(codec, WM8903_CLOCK_RATES_0, clock0); - snd_soc_write(codec, WM8903_CLOCK_RATES_1, clock1); - snd_soc_write(codec, WM8903_AUDIO_INTERFACE_1, aif1); - snd_soc_write(codec, WM8903_AUDIO_INTERFACE_2, aif2); - snd_soc_write(codec, WM8903_AUDIO_INTERFACE_3, aif3); - snd_soc_write(codec, WM8903_DAC_DIGITAL_1, dac_digital1); + snd_soc_component_write(component, WM8903_CLOCK_RATES_0, clock0); + snd_soc_component_write(component, WM8903_CLOCK_RATES_1, clock1); + snd_soc_component_write(component, WM8903_AUDIO_INTERFACE_1, aif1); + snd_soc_component_write(component, WM8903_AUDIO_INTERFACE_2, aif2); + snd_soc_component_write(component, WM8903_AUDIO_INTERFACE_3, aif3); + snd_soc_component_write(component, WM8903_DAC_DIGITAL_1, dac_digital1);
return 0; } @@ -1590,7 +1589,7 @@ static int wm8903_hw_params(struct snd_pcm_substream *substream, /** * wm8903_mic_detect - Enable microphone detection via the WM8903 IRQ * - * @codec: WM8903 codec + * @component: WM8903 component * @jack: jack to report detection events on * @det: value to report for presence detection * @shrt: value to report for short detection @@ -1604,13 +1603,13 @@ static int wm8903_hw_params(struct snd_pcm_substream *substream, * micdet_cfg in the platform data. Using this function will force on * the microphone bias for the device. */ -int wm8903_mic_detect(struct snd_soc_codec *codec, struct snd_soc_jack *jack, +int wm8903_mic_detect(struct snd_soc_component *component, struct snd_soc_jack *jack, int det, int shrt) { - struct wm8903_priv *wm8903 = snd_soc_codec_get_drvdata(codec); + struct wm8903_priv *wm8903 = snd_soc_component_get_drvdata(component); int irq_mask = WM8903_MICDET_EINT | WM8903_MICSHRT_EINT;
- dev_dbg(codec->dev, "Enabling microphone detection: %x %x\n", + dev_dbg(component->dev, "Enabling microphone detection: %x %x\n", det, shrt);
/* Store the configuration */ @@ -1624,19 +1623,19 @@ int wm8903_mic_detect(struct snd_soc_codec *codec, struct snd_soc_jack *jack, if (shrt) irq_mask &= ~WM8903_MICSHRT_EINT;
- snd_soc_update_bits(codec, WM8903_INTERRUPT_STATUS_1_MASK, + snd_soc_component_update_bits(component, WM8903_INTERRUPT_STATUS_1_MASK, WM8903_MICDET_EINT | WM8903_MICSHRT_EINT, irq_mask);
if (det || shrt) { /* Enable mic detection, this may not have been set through * platform data (eg, if the defaults are OK). */ - snd_soc_update_bits(codec, WM8903_WRITE_SEQUENCER_0, + snd_soc_component_update_bits(component, WM8903_WRITE_SEQUENCER_0, WM8903_WSEQ_ENA, WM8903_WSEQ_ENA); - snd_soc_update_bits(codec, WM8903_MIC_BIAS_CONTROL_0, + snd_soc_component_update_bits(component, WM8903_MIC_BIAS_CONTROL_0, WM8903_MICDET_ENA, WM8903_MICDET_ENA); } else { - snd_soc_update_bits(codec, WM8903_MIC_BIAS_CONTROL_0, + snd_soc_component_update_bits(component, WM8903_MIC_BIAS_CONTROL_0, WM8903_MICDET_ENA, 0); }
@@ -1766,9 +1765,9 @@ static irqreturn_t wm8903_irq(int irq, void *data) .symmetric_rates = 1, };
-static int wm8903_resume(struct snd_soc_codec *codec) +static int wm8903_resume(struct snd_soc_component *component) { - struct wm8903_priv *wm8903 = snd_soc_codec_get_drvdata(codec); + struct wm8903_priv *wm8903 = snd_soc_component_get_drvdata(component);
regcache_sync(wm8903->regmap);
@@ -1884,20 +1883,21 @@ static void wm8903_free_gpio(struct wm8903_priv *wm8903) } #endif
-static const struct snd_soc_codec_driver soc_codec_dev_wm8903 = { - .resume = wm8903_resume, - .set_bias_level = wm8903_set_bias_level, - .seq_notifier = wm8903_seq_notifier, - .suspend_bias_off = true, - - .component_driver = { - .controls = wm8903_snd_controls, - .num_controls = ARRAY_SIZE(wm8903_snd_controls), - .dapm_widgets = wm8903_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(wm8903_dapm_widgets), - .dapm_routes = wm8903_intercon, - .num_dapm_routes = ARRAY_SIZE(wm8903_intercon), - }, +static const struct snd_soc_component_driver soc_component_dev_wm8903 = { + .resume = wm8903_resume, + .set_bias_level = wm8903_set_bias_level, + .seq_notifier = wm8903_seq_notifier, + .controls = wm8903_snd_controls, + .num_controls = ARRAY_SIZE(wm8903_snd_controls), + .dapm_widgets = wm8903_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(wm8903_dapm_widgets), + .dapm_routes = wm8903_intercon, + .num_dapm_routes = ARRAY_SIZE(wm8903_intercon), + .suspend_bias_off = 1, + .idle_bias_on = 1, + .pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, };
static const struct regmap_config wm8903_regmap = { @@ -2176,8 +2176,8 @@ static int wm8903_i2c_probe(struct i2c_client *i2c, WM8903_DAC_MUTEMODE | WM8903_DAC_MUTE, WM8903_DAC_MUTEMODE | WM8903_DAC_MUTE);
- ret = snd_soc_register_codec(&i2c->dev, - &soc_codec_dev_wm8903, &wm8903_dai, 1); + ret = devm_snd_soc_register_component(&i2c->dev, + &soc_component_dev_wm8903, &wm8903_dai, 1); if (ret != 0) goto err;
@@ -2197,7 +2197,6 @@ static int wm8903_i2c_remove(struct i2c_client *client) if (client->irq) free_irq(client->irq, wm8903); wm8903_free_gpio(wm8903); - snd_soc_unregister_codec(&client->dev);
return 0; } diff --git a/sound/soc/codecs/wm8903.h b/sound/soc/codecs/wm8903.h index 0bb4a64..1301aa9 100644 --- a/sound/soc/codecs/wm8903.h +++ b/sound/soc/codecs/wm8903.h @@ -15,7 +15,7 @@
#include <linux/i2c.h>
-extern int wm8903_mic_detect(struct snd_soc_codec *codec, +extern int wm8903_mic_detect(struct snd_soc_component *component, struct snd_soc_jack *jack, int det, int shrt);
diff --git a/sound/soc/tegra/tegra_wm8903.c b/sound/soc/tegra/tegra_wm8903.c index 18bdae5..69bc946 100644 --- a/sound/soc/tegra/tegra_wm8903.c +++ b/sound/soc/tegra/tegra_wm8903.c @@ -170,7 +170,7 @@ static int tegra_wm8903_event_hp(struct snd_soc_dapm_widget *w, static int tegra_wm8903_init(struct snd_soc_pcm_runtime *rtd) { struct snd_soc_dai *codec_dai = rtd->codec_dai; - struct snd_soc_codec *codec = codec_dai->codec; + struct snd_soc_component *component = codec_dai->component; struct snd_soc_card *card = rtd->card; struct tegra_wm8903 *machine = snd_soc_card_get_drvdata(card);
@@ -189,7 +189,7 @@ static int tegra_wm8903_init(struct snd_soc_pcm_runtime *rtd) &tegra_wm8903_mic_jack, tegra_wm8903_mic_jack_pins, ARRAY_SIZE(tegra_wm8903_mic_jack_pins)); - wm8903_mic_detect(codec, &tegra_wm8903_mic_jack, SND_JACK_MICROPHONE, + wm8903_mic_detect(component, &tegra_wm8903_mic_jack, SND_JACK_MICROPHONE, 0);
snd_soc_dapm_force_enable_pin(&card->dapm, "MICBIAS"); @@ -202,9 +202,9 @@ static int tegra_wm8903_remove(struct snd_soc_card *card) struct snd_soc_pcm_runtime *rtd = snd_soc_get_pcm_runtime(card, card->dai_link[0].name); struct snd_soc_dai *codec_dai = rtd->codec_dai; - struct snd_soc_codec *codec = codec_dai->codec; + struct snd_soc_component *component = codec_dai->component;
- wm8903_mic_detect(codec, NULL, 0, 0); + wm8903_mic_detect(component, NULL, 0, 0);
return 0; }
From: Kuninori Morimoto kuninori.morimoto.gx@renesas.com
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 -> .pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com --- sound/soc/codecs/wm8955.c | 189 ++++++++++++++++++++++------------------------ 1 file changed, 91 insertions(+), 98 deletions(-)
diff --git a/sound/soc/codecs/wm8955.c b/sound/soc/codecs/wm8955.c index 1edc7b1..d1d5292 100644 --- a/sound/soc/codecs/wm8955.c +++ b/sound/soc/codecs/wm8955.c @@ -128,9 +128,9 @@ static bool wm8955_volatile(struct device *dev, unsigned int reg) } }
-static int wm8955_reset(struct snd_soc_codec *codec) +static int wm8955_reset(struct snd_soc_component *component) { - return snd_soc_write(codec, WM8955_RESET, 0); + return snd_soc_component_write(component, WM8955_RESET, 0); }
struct pll_factors { @@ -242,9 +242,9 @@ static int wm8995_pll_factors(struct device *dev, { 11289600, 88200, 0, 31, }, };
-static int wm8955_configure_clocking(struct snd_soc_codec *codec) +static int wm8955_configure_clocking(struct snd_soc_component *component) { - struct wm8955_priv *wm8955 = snd_soc_codec_get_drvdata(codec); + struct wm8955_priv *wm8955 = snd_soc_component_get_drvdata(component); int i, ret, val; int clocking = 0; int srate = 0; @@ -267,7 +267,7 @@ static int wm8955_configure_clocking(struct snd_soc_codec *codec)
/* We should never get here with an unsupported sample rate */ if (sr == -1) { - dev_err(codec->dev, "Sample rate %dHz unsupported\n", + dev_err(component->dev, "Sample rate %dHz unsupported\n", wm8955->fs); WARN_ON(sr == -1); return -EINVAL; @@ -282,30 +282,30 @@ static int wm8955_configure_clocking(struct snd_soc_codec *codec)
/* Use the last divider configuration we saw for the * sample rate. */ - ret = wm8995_pll_factors(codec->dev, wm8955->mclk_rate, + ret = wm8995_pll_factors(component->dev, wm8955->mclk_rate, clock_cfgs[sr].mclk, &pll); if (ret != 0) { - dev_err(codec->dev, + dev_err(component->dev, "Unable to generate %dHz from %dHz MCLK\n", wm8955->fs, wm8955->mclk_rate); return -EINVAL; }
- snd_soc_update_bits(codec, WM8955_PLL_CONTROL_1, + snd_soc_component_update_bits(component, WM8955_PLL_CONTROL_1, WM8955_N_MASK | WM8955_K_21_18_MASK, (pll.n << WM8955_N_SHIFT) | pll.k >> 18); - snd_soc_update_bits(codec, WM8955_PLL_CONTROL_2, + snd_soc_component_update_bits(component, WM8955_PLL_CONTROL_2, WM8955_K_17_9_MASK, (pll.k >> 9) & WM8955_K_17_9_MASK); - snd_soc_update_bits(codec, WM8955_PLL_CONTROL_3, + snd_soc_component_update_bits(component, WM8955_PLL_CONTROL_3, WM8955_K_8_0_MASK, pll.k & WM8955_K_8_0_MASK); if (pll.k) - snd_soc_update_bits(codec, WM8955_PLL_CONTROL_4, + snd_soc_component_update_bits(component, WM8955_PLL_CONTROL_4, WM8955_KEN, WM8955_KEN); else - snd_soc_update_bits(codec, WM8955_PLL_CONTROL_4, + snd_soc_component_update_bits(component, WM8955_PLL_CONTROL_4, WM8955_KEN, 0);
if (pll.outdiv) @@ -314,17 +314,17 @@ static int wm8955_configure_clocking(struct snd_soc_codec *codec) val = WM8955_PLL_RB;
/* Now start the PLL running */ - snd_soc_update_bits(codec, WM8955_CLOCKING_PLL, + snd_soc_component_update_bits(component, WM8955_CLOCKING_PLL, WM8955_PLL_RB | WM8955_PLLOUTDIV2, val); - snd_soc_update_bits(codec, WM8955_CLOCKING_PLL, + snd_soc_component_update_bits(component, WM8955_CLOCKING_PLL, WM8955_PLLEN, WM8955_PLLEN); }
srate = clock_cfgs[sr].usb | (clock_cfgs[sr].sr << WM8955_SR_SHIFT);
- snd_soc_update_bits(codec, WM8955_SAMPLE_RATE, + snd_soc_component_update_bits(component, WM8955_SAMPLE_RATE, WM8955_USB | WM8955_SR_MASK, srate); - snd_soc_update_bits(codec, WM8955_CLOCKING_PLL, + snd_soc_component_update_bits(component, WM8955_CLOCKING_PLL, WM8955_MCLKSEL, clocking);
return 0; @@ -333,22 +333,22 @@ static int wm8955_configure_clocking(struct snd_soc_codec *codec) static int wm8955_sysclk(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); int ret = 0;
/* Always disable the clocks - if we're doing reconfiguration this * avoids misclocking. */ - snd_soc_update_bits(codec, WM8955_POWER_MANAGEMENT_1, + snd_soc_component_update_bits(component, WM8955_POWER_MANAGEMENT_1, WM8955_DIGENB, 0); - snd_soc_update_bits(codec, WM8955_CLOCKING_PLL, + snd_soc_component_update_bits(component, WM8955_CLOCKING_PLL, WM8955_PLL_RB | WM8955_PLLEN, 0);
switch (event) { case SND_SOC_DAPM_POST_PMD: break; case SND_SOC_DAPM_PRE_PMU: - ret = wm8955_configure_clocking(codec); + ret = wm8955_configure_clocking(component); break; default: ret = -EINVAL; @@ -360,9 +360,9 @@ static int wm8955_sysclk(struct snd_soc_dapm_widget *w,
static int deemph_settings[] = { 0, 32000, 44100, 48000 };
-static int wm8955_set_deemph(struct snd_soc_codec *codec) +static int wm8955_set_deemph(struct snd_soc_component *component) { - struct wm8955_priv *wm8955 = snd_soc_codec_get_drvdata(codec); + struct wm8955_priv *wm8955 = snd_soc_component_get_drvdata(component); int val, i, best;
/* If we're using deemphasis select the nearest available sample @@ -381,17 +381,17 @@ static int wm8955_set_deemph(struct snd_soc_codec *codec) val = 0; }
- dev_dbg(codec->dev, "Set deemphasis %d\n", val); + dev_dbg(component->dev, "Set deemphasis %d\n", val);
- return snd_soc_update_bits(codec, WM8955_DAC_CONTROL, + return snd_soc_component_update_bits(component, WM8955_DAC_CONTROL, WM8955_DEEMPH_MASK, val); }
static int wm8955_get_deemph(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct wm8955_priv *wm8955 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct wm8955_priv *wm8955 = snd_soc_component_get_drvdata(component);
ucontrol->value.integer.value[0] = wm8955->deemph; return 0; @@ -400,8 +400,8 @@ static int wm8955_get_deemph(struct snd_kcontrol *kcontrol, static int wm8955_put_deemph(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct wm8955_priv *wm8955 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct wm8955_priv *wm8955 = snd_soc_component_get_drvdata(component); unsigned int deemph = ucontrol->value.integer.value[0];
if (deemph > 1) @@ -409,7 +409,7 @@ static int wm8955_put_deemph(struct snd_kcontrol *kcontrol,
wm8955->deemph = deemph;
- return wm8955_set_deemph(codec); + return wm8955_set_deemph(component); }
static const char *bass_mode_text[] = { @@ -592,8 +592,8 @@ static int wm8955_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; - struct wm8955_priv *wm8955 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct wm8955_priv *wm8955 = snd_soc_component_get_drvdata(component); int ret; int wl;
@@ -613,25 +613,25 @@ static int wm8955_hw_params(struct snd_pcm_substream *substream, default: return -EINVAL; } - snd_soc_update_bits(codec, WM8955_AUDIO_INTERFACE, + snd_soc_component_update_bits(component, WM8955_AUDIO_INTERFACE, WM8955_WL_MASK, wl);
wm8955->fs = params_rate(params); - wm8955_set_deemph(codec); + wm8955_set_deemph(component);
/* If the chip is clocked then disable the clocks and force a * reconfiguration, otherwise DAPM will power up the * clocks for us later. */ - ret = snd_soc_read(codec, WM8955_POWER_MANAGEMENT_1); + ret = snd_soc_component_read32(component, WM8955_POWER_MANAGEMENT_1); if (ret < 0) return ret; if (ret & WM8955_DIGENB) { - snd_soc_update_bits(codec, WM8955_POWER_MANAGEMENT_1, + snd_soc_component_update_bits(component, WM8955_POWER_MANAGEMENT_1, WM8955_DIGENB, 0); - snd_soc_update_bits(codec, WM8955_CLOCKING_PLL, + snd_soc_component_update_bits(component, WM8955_CLOCKING_PLL, WM8955_PLL_RB | WM8955_PLLEN, 0);
- wm8955_configure_clocking(codec); + wm8955_configure_clocking(component); }
return 0; @@ -641,8 +641,8 @@ static int wm8955_hw_params(struct snd_pcm_substream *substream, static int wm8955_set_sysclk(struct snd_soc_dai *dai, int clk_id, unsigned int freq, int dir) { - struct snd_soc_codec *codec = dai->codec; - struct wm8955_priv *priv = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct wm8955_priv *priv = snd_soc_component_get_drvdata(component); int div;
switch (clk_id) { @@ -655,7 +655,7 @@ static int wm8955_set_sysclk(struct snd_soc_dai *dai, int clk_id, div = 0; }
- snd_soc_update_bits(codec, WM8955_SAMPLE_RATE, + snd_soc_component_update_bits(component, WM8955_SAMPLE_RATE, WM8955_MCLKDIV2, div); break;
@@ -670,7 +670,7 @@ static int wm8955_set_sysclk(struct snd_soc_dai *dai, int clk_id,
static int wm8955_set_fmt(struct snd_soc_dai *dai, unsigned int fmt) { - struct snd_soc_codec *codec = dai->codec; + struct snd_soc_component *component = dai->component; u16 aif = 0;
switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { @@ -739,7 +739,7 @@ static int wm8955_set_fmt(struct snd_soc_dai *dai, unsigned int fmt) return -EINVAL; }
- snd_soc_update_bits(codec, WM8955_AUDIO_INTERFACE, + snd_soc_component_update_bits(component, WM8955_AUDIO_INTERFACE, WM8955_MS | WM8955_FORMAT_MASK | WM8955_BCLKINV | WM8955_LRP, aif);
@@ -749,7 +749,7 @@ static int wm8955_set_fmt(struct snd_soc_dai *dai, unsigned int fmt)
static int wm8955_digital_mute(struct snd_soc_dai *codec_dai, int mute) { - struct snd_soc_codec *codec = codec_dai->codec; + struct snd_soc_component *component = codec_dai->component; int val;
if (mute) @@ -757,15 +757,15 @@ static int wm8955_digital_mute(struct snd_soc_dai *codec_dai, int mute) else val = 0;
- snd_soc_update_bits(codec, WM8955_DAC_CONTROL, WM8955_DACMU, val); + snd_soc_component_update_bits(component, WM8955_DAC_CONTROL, WM8955_DACMU, val);
return 0; }
-static int wm8955_set_bias_level(struct snd_soc_codec *codec, +static int wm8955_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { - struct wm8955_priv *wm8955 = snd_soc_codec_get_drvdata(codec); + struct wm8955_priv *wm8955 = snd_soc_component_get_drvdata(component); int ret;
switch (level) { @@ -774,22 +774,22 @@ static int wm8955_set_bias_level(struct snd_soc_codec *codec,
case SND_SOC_BIAS_PREPARE: /* VMID resistance 2*50k */ - snd_soc_update_bits(codec, WM8955_POWER_MANAGEMENT_1, + snd_soc_component_update_bits(component, WM8955_POWER_MANAGEMENT_1, WM8955_VMIDSEL_MASK, 0x1 << WM8955_VMIDSEL_SHIFT);
/* Default bias current */ - snd_soc_update_bits(codec, WM8955_ADDITIONAL_CONTROL_1, + snd_soc_component_update_bits(component, WM8955_ADDITIONAL_CONTROL_1, WM8955_VSEL_MASK, 0x2 << WM8955_VSEL_SHIFT); break;
case SND_SOC_BIAS_STANDBY: - if (snd_soc_codec_get_bias_level(codec) == SND_SOC_BIAS_OFF) { + if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_OFF) { ret = regulator_bulk_enable(ARRAY_SIZE(wm8955->supplies), wm8955->supplies); if (ret != 0) { - dev_err(codec->dev, + dev_err(component->dev, "Failed to enable supplies: %d\n", ret); return ret; @@ -798,7 +798,7 @@ static int wm8955_set_bias_level(struct snd_soc_codec *codec, regcache_sync(wm8955->regmap);
/* Enable VREF and VMID */ - snd_soc_update_bits(codec, WM8955_POWER_MANAGEMENT_1, + snd_soc_component_update_bits(component, WM8955_POWER_MANAGEMENT_1, WM8955_VREF | WM8955_VMIDSEL_MASK, WM8955_VREF | @@ -808,29 +808,29 @@ static int wm8955_set_bias_level(struct snd_soc_codec *codec, msleep(500);
/* High resistance VROI to maintain outputs */ - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, WM8955_ADDITIONAL_CONTROL_3, WM8955_VROI, WM8955_VROI); }
/* Maintain VMID with 2*250k */ - snd_soc_update_bits(codec, WM8955_POWER_MANAGEMENT_1, + snd_soc_component_update_bits(component, WM8955_POWER_MANAGEMENT_1, WM8955_VMIDSEL_MASK, 0x2 << WM8955_VMIDSEL_SHIFT);
/* Minimum bias current */ - snd_soc_update_bits(codec, WM8955_ADDITIONAL_CONTROL_1, + snd_soc_component_update_bits(component, WM8955_ADDITIONAL_CONTROL_1, WM8955_VSEL_MASK, 0); break;
case SND_SOC_BIAS_OFF: /* Low resistance VROI to help discharge */ - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, WM8955_ADDITIONAL_CONTROL_3, WM8955_VROI, 0);
/* Turn off VMID and VREF */ - snd_soc_update_bits(codec, WM8955_POWER_MANAGEMENT_1, + snd_soc_component_update_bits(component, WM8955_POWER_MANAGEMENT_1, WM8955_VREF | WM8955_VMIDSEL_MASK, 0);
@@ -865,70 +865,70 @@ static int wm8955_set_bias_level(struct snd_soc_codec *codec, .ops = &wm8955_dai_ops, };
-static int wm8955_probe(struct snd_soc_codec *codec) +static int wm8955_probe(struct snd_soc_component *component) { - struct wm8955_priv *wm8955 = snd_soc_codec_get_drvdata(codec); - struct wm8955_pdata *pdata = dev_get_platdata(codec->dev); + struct wm8955_priv *wm8955 = snd_soc_component_get_drvdata(component); + struct wm8955_pdata *pdata = dev_get_platdata(component->dev); int ret, i;
for (i = 0; i < ARRAY_SIZE(wm8955->supplies); i++) wm8955->supplies[i].supply = wm8955_supply_names[i];
- ret = devm_regulator_bulk_get(codec->dev, ARRAY_SIZE(wm8955->supplies), + ret = devm_regulator_bulk_get(component->dev, ARRAY_SIZE(wm8955->supplies), wm8955->supplies); if (ret != 0) { - dev_err(codec->dev, "Failed to request supplies: %d\n", ret); + dev_err(component->dev, "Failed to request supplies: %d\n", ret); return ret; }
ret = regulator_bulk_enable(ARRAY_SIZE(wm8955->supplies), wm8955->supplies); if (ret != 0) { - dev_err(codec->dev, "Failed to enable supplies: %d\n", ret); + dev_err(component->dev, "Failed to enable supplies: %d\n", ret); return ret; }
- ret = wm8955_reset(codec); + ret = wm8955_reset(component); if (ret < 0) { - dev_err(codec->dev, "Failed to issue reset: %d\n", ret); + dev_err(component->dev, "Failed to issue reset: %d\n", ret); goto err_enable; }
/* Change some default settings - latch VU and enable ZC */ - snd_soc_update_bits(codec, WM8955_LEFT_DAC_VOLUME, + snd_soc_component_update_bits(component, WM8955_LEFT_DAC_VOLUME, WM8955_LDVU, WM8955_LDVU); - snd_soc_update_bits(codec, WM8955_RIGHT_DAC_VOLUME, + snd_soc_component_update_bits(component, WM8955_RIGHT_DAC_VOLUME, WM8955_RDVU, WM8955_RDVU); - snd_soc_update_bits(codec, WM8955_LOUT1_VOLUME, + snd_soc_component_update_bits(component, WM8955_LOUT1_VOLUME, WM8955_LO1VU | WM8955_LO1ZC, WM8955_LO1VU | WM8955_LO1ZC); - snd_soc_update_bits(codec, WM8955_ROUT1_VOLUME, + snd_soc_component_update_bits(component, WM8955_ROUT1_VOLUME, WM8955_RO1VU | WM8955_RO1ZC, WM8955_RO1VU | WM8955_RO1ZC); - snd_soc_update_bits(codec, WM8955_LOUT2_VOLUME, + snd_soc_component_update_bits(component, WM8955_LOUT2_VOLUME, WM8955_LO2VU | WM8955_LO2ZC, WM8955_LO2VU | WM8955_LO2ZC); - snd_soc_update_bits(codec, WM8955_ROUT2_VOLUME, + snd_soc_component_update_bits(component, WM8955_ROUT2_VOLUME, WM8955_RO2VU | WM8955_RO2ZC, WM8955_RO2VU | WM8955_RO2ZC); - snd_soc_update_bits(codec, WM8955_MONOOUT_VOLUME, + snd_soc_component_update_bits(component, WM8955_MONOOUT_VOLUME, WM8955_MOZC, WM8955_MOZC);
/* Also enable adaptive bass boost by default */ - snd_soc_update_bits(codec, WM8955_BASS_CONTROL, WM8955_BB, WM8955_BB); + snd_soc_component_update_bits(component, WM8955_BASS_CONTROL, WM8955_BB, WM8955_BB);
/* Set platform data values */ if (pdata) { if (pdata->out2_speaker) - snd_soc_update_bits(codec, WM8955_ADDITIONAL_CONTROL_2, + snd_soc_component_update_bits(component, WM8955_ADDITIONAL_CONTROL_2, WM8955_ROUT2INV, WM8955_ROUT2INV);
if (pdata->monoin_diff) - snd_soc_update_bits(codec, WM8955_MONO_OUT_MIX_1, + snd_soc_component_update_bits(component, WM8955_MONO_OUT_MIX_1, WM8955_DMEN, WM8955_DMEN); }
- snd_soc_codec_force_bias_level(codec, SND_SOC_BIAS_STANDBY); + snd_soc_component_force_bias_level(component, SND_SOC_BIAS_STANDBY);
/* Bias level configuration will have done an extra enable */ regulator_bulk_disable(ARRAY_SIZE(wm8955->supplies), wm8955->supplies); @@ -940,19 +940,20 @@ static int wm8955_probe(struct snd_soc_codec *codec) return ret; }
-static const struct snd_soc_codec_driver soc_codec_dev_wm8955 = { - .probe = wm8955_probe, - .set_bias_level = wm8955_set_bias_level, - .suspend_bias_off = true, - - .component_driver = { - .controls = wm8955_snd_controls, - .num_controls = ARRAY_SIZE(wm8955_snd_controls), - .dapm_widgets = wm8955_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(wm8955_dapm_widgets), - .dapm_routes = wm8955_dapm_routes, - .num_dapm_routes = ARRAY_SIZE(wm8955_dapm_routes), - }, +static const struct snd_soc_component_driver soc_component_dev_wm8955 = { + .probe = wm8955_probe, + .set_bias_level = wm8955_set_bias_level, + .controls = wm8955_snd_controls, + .num_controls = ARRAY_SIZE(wm8955_snd_controls), + .dapm_widgets = wm8955_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(wm8955_dapm_widgets), + .dapm_routes = wm8955_dapm_routes, + .num_dapm_routes = ARRAY_SIZE(wm8955_dapm_routes), + .suspend_bias_off = 1, + .idle_bias_on = 1, + .pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, };
static const struct regmap_config wm8955_regmap = { @@ -989,19 +990,12 @@ static int wm8955_i2c_probe(struct i2c_client *i2c,
i2c_set_clientdata(i2c, wm8955);
- ret = snd_soc_register_codec(&i2c->dev, - &soc_codec_dev_wm8955, &wm8955_dai, 1); + ret = devm_snd_soc_register_component(&i2c->dev, + &soc_component_dev_wm8955, &wm8955_dai, 1);
return ret; }
-static int wm8955_i2c_remove(struct i2c_client *client) -{ - snd_soc_unregister_codec(&client->dev); - - return 0; -} - static const struct i2c_device_id wm8955_i2c_id[] = { { "wm8955", 0 }, { } @@ -1013,7 +1007,6 @@ static int wm8955_i2c_remove(struct i2c_client *client) .name = "wm8955", }, .probe = wm8955_i2c_probe, - .remove = wm8955_i2c_remove, .id_table = wm8955_i2c_id, };
From: Kuninori Morimoto kuninori.morimoto.gx@renesas.com
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 -> .pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com --- sound/soc/codecs/wm8985.c | 201 ++++++++++++++++++++++------------------------ 1 file changed, 94 insertions(+), 107 deletions(-)
diff --git a/sound/soc/codecs/wm8985.c b/sound/soc/codecs/wm8985.c index 05344f9..c32c2c9 100644 --- a/sound/soc/codecs/wm8985.c +++ b/sound/soc/codecs/wm8985.c @@ -564,10 +564,10 @@ static SOC_ENUM_SINGLE_DECL(eq5_cutoff, WM8985_EQ5_HIGH_SHELF, 5, { "Left Boost Mixer", "AUXL Volume", "AUXL" }, };
-static int wm8985_add_widgets(struct snd_soc_codec *codec) +static int wm8985_add_widgets(struct snd_soc_component *component) { - struct wm8985_priv *wm8985 = snd_soc_codec_get_drvdata(codec); - struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec); + struct wm8985_priv *wm8985 = snd_soc_component_get_drvdata(component); + struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component);
switch (wm8985->dev_type) { case WM8758: @@ -576,7 +576,7 @@ static int wm8985_add_widgets(struct snd_soc_codec *codec) break;
case WM8985: - snd_soc_add_codec_controls(codec, wm8985_specific_snd_controls, + snd_soc_add_component_controls(component, wm8985_specific_snd_controls, ARRAY_SIZE(wm8985_specific_snd_controls));
snd_soc_dapm_new_controls(dapm, wm8985_dapm_widgets, @@ -592,10 +592,10 @@ static int wm8985_add_widgets(struct snd_soc_codec *codec) static int eqmode_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); unsigned int reg;
- reg = snd_soc_read(codec, WM8985_EQ1_LOW_SHELF); + reg = snd_soc_component_read32(component, WM8985_EQ1_LOW_SHELF); if (reg & WM8985_EQ3DMODE) ucontrol->value.enumerated.item[0] = 1; else @@ -607,7 +607,7 @@ static int eqmode_get(struct snd_kcontrol *kcontrol, static int eqmode_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); unsigned int regpwr2, regpwr3; unsigned int reg_eq;
@@ -615,7 +615,7 @@ static int eqmode_put(struct snd_kcontrol *kcontrol, && ucontrol->value.enumerated.item[0] != 1) return -EINVAL;
- reg_eq = snd_soc_read(codec, WM8985_EQ1_LOW_SHELF); + reg_eq = snd_soc_component_read32(component, WM8985_EQ1_LOW_SHELF); switch ((reg_eq & WM8985_EQ3DMODE) >> WM8985_EQ3DMODE_SHIFT) { case 0: if (!ucontrol->value.enumerated.item[0]) @@ -627,46 +627,46 @@ static int eqmode_put(struct snd_kcontrol *kcontrol, break; }
- regpwr2 = snd_soc_read(codec, WM8985_POWER_MANAGEMENT_2); - regpwr3 = snd_soc_read(codec, WM8985_POWER_MANAGEMENT_3); + regpwr2 = snd_soc_component_read32(component, WM8985_POWER_MANAGEMENT_2); + regpwr3 = snd_soc_component_read32(component, WM8985_POWER_MANAGEMENT_3); /* disable the DACs and ADCs */ - snd_soc_update_bits(codec, WM8985_POWER_MANAGEMENT_2, + snd_soc_component_update_bits(component, WM8985_POWER_MANAGEMENT_2, WM8985_ADCENR_MASK | WM8985_ADCENL_MASK, 0); - snd_soc_update_bits(codec, WM8985_POWER_MANAGEMENT_3, + snd_soc_component_update_bits(component, WM8985_POWER_MANAGEMENT_3, WM8985_DACENR_MASK | WM8985_DACENL_MASK, 0); - snd_soc_update_bits(codec, WM8985_ADDITIONAL_CONTROL, + snd_soc_component_update_bits(component, WM8985_ADDITIONAL_CONTROL, WM8985_M128ENB_MASK, WM8985_M128ENB); /* set the desired eqmode */ - snd_soc_update_bits(codec, WM8985_EQ1_LOW_SHELF, + snd_soc_component_update_bits(component, WM8985_EQ1_LOW_SHELF, WM8985_EQ3DMODE_MASK, ucontrol->value.enumerated.item[0] << WM8985_EQ3DMODE_SHIFT); /* restore DAC/ADC configuration */ - snd_soc_write(codec, WM8985_POWER_MANAGEMENT_2, regpwr2); - snd_soc_write(codec, WM8985_POWER_MANAGEMENT_3, regpwr3); + snd_soc_component_write(component, WM8985_POWER_MANAGEMENT_2, regpwr2); + snd_soc_component_write(component, WM8985_POWER_MANAGEMENT_3, regpwr3); return 0; }
-static int wm8985_reset(struct snd_soc_codec *codec) +static int wm8985_reset(struct snd_soc_component *component) { - return snd_soc_write(codec, WM8985_SOFTWARE_RESET, 0x0); + return snd_soc_component_write(component, WM8985_SOFTWARE_RESET, 0x0); }
static int wm8985_dac_mute(struct snd_soc_dai *dai, int mute) { - struct snd_soc_codec *codec = dai->codec; + struct snd_soc_component *component = dai->component;
- return snd_soc_update_bits(codec, WM8985_DAC_CONTROL, + return snd_soc_component_update_bits(component, WM8985_DAC_CONTROL, WM8985_SOFTMUTE_MASK, !!mute << WM8985_SOFTMUTE_SHIFT); }
static int wm8985_set_fmt(struct snd_soc_dai *dai, unsigned int fmt) { - struct snd_soc_codec *codec; + struct snd_soc_component *component; u16 format, master, bcp, lrp;
- codec = dai->codec; + component = dai->component;
switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) { case SND_SOC_DAIFMT_I2S: @@ -687,7 +687,7 @@ static int wm8985_set_fmt(struct snd_soc_dai *dai, unsigned int fmt) return -EINVAL; }
- snd_soc_update_bits(codec, WM8985_AUDIO_INTERFACE, + snd_soc_component_update_bits(component, WM8985_AUDIO_INTERFACE, WM8985_FMT_MASK, format << WM8985_FMT_SHIFT);
switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { @@ -702,7 +702,7 @@ static int wm8985_set_fmt(struct snd_soc_dai *dai, unsigned int fmt) return -EINVAL; }
- snd_soc_update_bits(codec, WM8985_CLOCK_GEN_CONTROL, + snd_soc_component_update_bits(component, WM8985_CLOCK_GEN_CONTROL, WM8985_MS_MASK, master << WM8985_MS_SHIFT);
/* frame inversion is not valid for dsp modes */ @@ -739,9 +739,9 @@ static int wm8985_set_fmt(struct snd_soc_dai *dai, unsigned int fmt) return -EINVAL; }
- snd_soc_update_bits(codec, WM8985_AUDIO_INTERFACE, + snd_soc_component_update_bits(component, WM8985_AUDIO_INTERFACE, WM8985_LRP_MASK, lrp << WM8985_LRP_SHIFT); - snd_soc_update_bits(codec, WM8985_AUDIO_INTERFACE, + snd_soc_component_update_bits(component, WM8985_AUDIO_INTERFACE, WM8985_BCP_MASK, bcp << WM8985_BCP_SHIFT); return 0; } @@ -751,14 +751,14 @@ static int wm8985_hw_params(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) { int i; - struct snd_soc_codec *codec; + struct snd_soc_component *component; struct wm8985_priv *wm8985; u16 blen, srate_idx; unsigned int tmp; int srate_best;
- codec = dai->codec; - wm8985 = snd_soc_codec_get_drvdata(codec); + component = dai->component; + wm8985 = snd_soc_component_get_drvdata(component);
wm8985->bclk = snd_soc_params_to_bclk(params); if ((int)wm8985->bclk < 0) @@ -783,7 +783,7 @@ static int wm8985_hw_params(struct snd_pcm_substream *substream, return -EINVAL; }
- snd_soc_update_bits(codec, WM8985_AUDIO_INTERFACE, + snd_soc_component_update_bits(component, WM8985_AUDIO_INTERFACE, WM8985_WL_MASK, blen << WM8985_WL_SHIFT);
/* @@ -800,7 +800,7 @@ static int wm8985_hw_params(struct snd_pcm_substream *substream, }
dev_dbg(dai->dev, "Selected SRATE = %d\n", srates[srate_idx]); - snd_soc_update_bits(codec, WM8985_ADDITIONAL_CONTROL, + snd_soc_component_update_bits(component, WM8985_ADDITIONAL_CONTROL, WM8985_SR_MASK, srate_idx << WM8985_SR_SHIFT);
dev_dbg(dai->dev, "Target BCLK = %uHz\n", wm8985->bclk); @@ -819,7 +819,7 @@ static int wm8985_hw_params(struct snd_pcm_substream *substream, }
dev_dbg(dai->dev, "MCLK ratio = %dfs\n", fs_ratios[i].ratio); - snd_soc_update_bits(codec, WM8985_CLOCK_GEN_CONTROL, + snd_soc_component_update_bits(component, WM8985_CLOCK_GEN_CONTROL, WM8985_MCLKDIV_MASK, i << WM8985_MCLKDIV_SHIFT);
/* select the appropriate bclk divider */ @@ -835,7 +835,7 @@ static int wm8985_hw_params(struct snd_pcm_substream *substream, }
dev_dbg(dai->dev, "BCLK div = %d\n", i); - snd_soc_update_bits(codec, WM8985_CLOCK_GEN_CONTROL, + snd_soc_component_update_bits(component, WM8985_CLOCK_GEN_CONTROL, WM8985_BCLKDIV_MASK, i << WM8985_BCLKDIV_SHIFT); return 0; } @@ -887,13 +887,13 @@ static int wm8985_set_pll(struct snd_soc_dai *dai, int pll_id, unsigned int freq_out) { int ret; - struct snd_soc_codec *codec; + struct snd_soc_component *component; struct pll_div pll_div;
- codec = dai->codec; + component = dai->component; if (!freq_in || !freq_out) { /* disable the PLL */ - snd_soc_update_bits(codec, WM8985_POWER_MANAGEMENT_1, + snd_soc_component_update_bits(component, WM8985_POWER_MANAGEMENT_1, WM8985_PLLEN_MASK, 0); } else { ret = pll_factors(&pll_div, freq_out * 4 * 2, freq_in); @@ -901,18 +901,18 @@ static int wm8985_set_pll(struct snd_soc_dai *dai, int pll_id, return ret;
/* set PLLN and PRESCALE */ - snd_soc_write(codec, WM8985_PLL_N, + snd_soc_component_write(component, WM8985_PLL_N, (pll_div.div2 << WM8985_PLL_PRESCALE_SHIFT) | pll_div.n); /* set PLLK */ - snd_soc_write(codec, WM8985_PLL_K_3, pll_div.k & 0x1ff); - snd_soc_write(codec, WM8985_PLL_K_2, (pll_div.k >> 9) & 0x1ff); - snd_soc_write(codec, WM8985_PLL_K_1, (pll_div.k >> 18)); + snd_soc_component_write(component, WM8985_PLL_K_3, pll_div.k & 0x1ff); + snd_soc_component_write(component, WM8985_PLL_K_2, (pll_div.k >> 9) & 0x1ff); + snd_soc_component_write(component, WM8985_PLL_K_1, (pll_div.k >> 18)); /* set the source of the clock to be the PLL */ - snd_soc_update_bits(codec, WM8985_CLOCK_GEN_CONTROL, + snd_soc_component_update_bits(component, WM8985_CLOCK_GEN_CONTROL, WM8985_CLKSEL_MASK, WM8985_CLKSEL); /* enable the PLL */ - snd_soc_update_bits(codec, WM8985_POWER_MANAGEMENT_1, + snd_soc_component_update_bits(component, WM8985_POWER_MANAGEMENT_1, WM8985_PLLEN_MASK, WM8985_PLLEN); } return 0; @@ -921,21 +921,21 @@ static int wm8985_set_pll(struct snd_soc_dai *dai, int pll_id, static int wm8985_set_sysclk(struct snd_soc_dai *dai, int clk_id, unsigned int freq, int dir) { - struct snd_soc_codec *codec; + struct snd_soc_component *component; struct wm8985_priv *wm8985;
- codec = dai->codec; - wm8985 = snd_soc_codec_get_drvdata(codec); + component = dai->component; + wm8985 = snd_soc_component_get_drvdata(component);
switch (clk_id) { case WM8985_CLKSRC_MCLK: - snd_soc_update_bits(codec, WM8985_CLOCK_GEN_CONTROL, + snd_soc_component_update_bits(component, WM8985_CLOCK_GEN_CONTROL, WM8985_CLKSEL_MASK, 0); - snd_soc_update_bits(codec, WM8985_POWER_MANAGEMENT_1, + snd_soc_component_update_bits(component, WM8985_POWER_MANAGEMENT_1, WM8985_PLLEN_MASK, 0); break; case WM8985_CLKSRC_PLL: - snd_soc_update_bits(codec, WM8985_CLOCK_GEN_CONTROL, + snd_soc_component_update_bits(component, WM8985_CLOCK_GEN_CONTROL, WM8985_CLKSEL_MASK, WM8985_CLKSEL); break; default: @@ -947,27 +947,27 @@ static int wm8985_set_sysclk(struct snd_soc_dai *dai, return 0; }
-static int wm8985_set_bias_level(struct snd_soc_codec *codec, +static int wm8985_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { int ret; struct wm8985_priv *wm8985;
- wm8985 = snd_soc_codec_get_drvdata(codec); + wm8985 = snd_soc_component_get_drvdata(component); switch (level) { case SND_SOC_BIAS_ON: case SND_SOC_BIAS_PREPARE: /* VMID at 75k */ - snd_soc_update_bits(codec, WM8985_POWER_MANAGEMENT_1, + snd_soc_component_update_bits(component, WM8985_POWER_MANAGEMENT_1, WM8985_VMIDSEL_MASK, 1 << WM8985_VMIDSEL_SHIFT); break; case SND_SOC_BIAS_STANDBY: - if (snd_soc_codec_get_bias_level(codec) == SND_SOC_BIAS_OFF) { + if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_OFF) { ret = regulator_bulk_enable(ARRAY_SIZE(wm8985->supplies), wm8985->supplies); if (ret) { - dev_err(codec->dev, + dev_err(component->dev, "Failed to enable supplies: %d\n", ret); return ret; @@ -976,45 +976,45 @@ static int wm8985_set_bias_level(struct snd_soc_codec *codec, regcache_sync(wm8985->regmap);
/* enable anti-pop features */ - snd_soc_update_bits(codec, WM8985_OUT4_TO_ADC, + snd_soc_component_update_bits(component, WM8985_OUT4_TO_ADC, WM8985_POBCTRL_MASK, WM8985_POBCTRL); /* enable thermal shutdown */ - snd_soc_update_bits(codec, WM8985_OUTPUT_CTRL0, + snd_soc_component_update_bits(component, WM8985_OUTPUT_CTRL0, WM8985_TSDEN_MASK, WM8985_TSDEN); - snd_soc_update_bits(codec, WM8985_OUTPUT_CTRL0, + snd_soc_component_update_bits(component, WM8985_OUTPUT_CTRL0, WM8985_TSOPCTRL_MASK, WM8985_TSOPCTRL); /* enable BIASEN */ - snd_soc_update_bits(codec, WM8985_POWER_MANAGEMENT_1, + snd_soc_component_update_bits(component, WM8985_POWER_MANAGEMENT_1, WM8985_BIASEN_MASK, WM8985_BIASEN); /* VMID at 75k */ - snd_soc_update_bits(codec, WM8985_POWER_MANAGEMENT_1, + snd_soc_component_update_bits(component, WM8985_POWER_MANAGEMENT_1, WM8985_VMIDSEL_MASK, 1 << WM8985_VMIDSEL_SHIFT); msleep(500); /* disable anti-pop features */ - snd_soc_update_bits(codec, WM8985_OUT4_TO_ADC, + snd_soc_component_update_bits(component, WM8985_OUT4_TO_ADC, WM8985_POBCTRL_MASK, 0); } /* VMID at 300k */ - snd_soc_update_bits(codec, WM8985_POWER_MANAGEMENT_1, + snd_soc_component_update_bits(component, WM8985_POWER_MANAGEMENT_1, WM8985_VMIDSEL_MASK, 2 << WM8985_VMIDSEL_SHIFT); break; case SND_SOC_BIAS_OFF: /* disable thermal shutdown */ - snd_soc_update_bits(codec, WM8985_OUTPUT_CTRL0, + snd_soc_component_update_bits(component, WM8985_OUTPUT_CTRL0, WM8985_TSOPCTRL_MASK, 0); - snd_soc_update_bits(codec, WM8985_OUTPUT_CTRL0, + snd_soc_component_update_bits(component, WM8985_OUTPUT_CTRL0, WM8985_TSDEN_MASK, 0); /* disable VMIDSEL and BIASEN */ - snd_soc_update_bits(codec, WM8985_POWER_MANAGEMENT_1, + snd_soc_component_update_bits(component, WM8985_POWER_MANAGEMENT_1, WM8985_VMIDSEL_MASK | WM8985_BIASEN_MASK, 0); - snd_soc_write(codec, WM8985_POWER_MANAGEMENT_1, 0); - snd_soc_write(codec, WM8985_POWER_MANAGEMENT_2, 0); - snd_soc_write(codec, WM8985_POWER_MANAGEMENT_3, 0); + snd_soc_component_write(component, WM8985_POWER_MANAGEMENT_1, 0); + snd_soc_component_write(component, WM8985_POWER_MANAGEMENT_2, 0); + snd_soc_component_write(component, WM8985_POWER_MANAGEMENT_3, 0);
regcache_mark_dirty(wm8985->regmap);
@@ -1026,46 +1026,46 @@ static int wm8985_set_bias_level(struct snd_soc_codec *codec, return 0; }
-static int wm8985_probe(struct snd_soc_codec *codec) +static int wm8985_probe(struct snd_soc_component *component) { size_t i; struct wm8985_priv *wm8985; int ret;
- wm8985 = snd_soc_codec_get_drvdata(codec); + wm8985 = snd_soc_component_get_drvdata(component);
for (i = 0; i < ARRAY_SIZE(wm8985->supplies); i++) wm8985->supplies[i].supply = wm8985_supply_names[i];
- ret = devm_regulator_bulk_get(codec->dev, ARRAY_SIZE(wm8985->supplies), + ret = devm_regulator_bulk_get(component->dev, ARRAY_SIZE(wm8985->supplies), wm8985->supplies); if (ret) { - dev_err(codec->dev, "Failed to request supplies: %d\n", ret); + dev_err(component->dev, "Failed to request supplies: %d\n", ret); return ret; }
ret = regulator_bulk_enable(ARRAY_SIZE(wm8985->supplies), wm8985->supplies); if (ret) { - dev_err(codec->dev, "Failed to enable supplies: %d\n", ret); + dev_err(component->dev, "Failed to enable supplies: %d\n", ret); return ret; }
- ret = wm8985_reset(codec); + ret = wm8985_reset(component); if (ret < 0) { - dev_err(codec->dev, "Failed to issue reset: %d\n", ret); + dev_err(component->dev, "Failed to issue reset: %d\n", ret); goto err_reg_enable; }
/* latch volume update bits */ for (i = 0; i < ARRAY_SIZE(volume_update_regs); ++i) - snd_soc_update_bits(codec, volume_update_regs[i], + snd_soc_component_update_bits(component, volume_update_regs[i], 0x100, 0x100); /* enable BIASCUT */ - snd_soc_update_bits(codec, WM8985_BIAS_CTRL, WM8985_BIASCUT, + snd_soc_component_update_bits(component, WM8985_BIAS_CTRL, WM8985_BIASCUT, WM8985_BIASCUT);
- wm8985_add_widgets(codec); + wm8985_add_widgets(component);
return 0;
@@ -1105,19 +1105,20 @@ static int wm8985_probe(struct snd_soc_codec *codec) .symmetric_rates = 1 };
-static const struct snd_soc_codec_driver soc_codec_dev_wm8985 = { - .probe = wm8985_probe, - .set_bias_level = wm8985_set_bias_level, - .suspend_bias_off = true, - - .component_driver = { - .controls = wm8985_common_snd_controls, - .num_controls = ARRAY_SIZE(wm8985_common_snd_controls), - .dapm_widgets = wm8985_common_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(wm8985_common_dapm_widgets), - .dapm_routes = wm8985_common_dapm_routes, - .num_dapm_routes = ARRAY_SIZE(wm8985_common_dapm_routes), - }, +static const struct snd_soc_component_driver soc_component_dev_wm8985 = { + .probe = wm8985_probe, + .set_bias_level = wm8985_set_bias_level, + .controls = wm8985_common_snd_controls, + .num_controls = ARRAY_SIZE(wm8985_common_snd_controls), + .dapm_widgets = wm8985_common_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(wm8985_common_dapm_widgets), + .dapm_routes = wm8985_common_dapm_routes, + .num_dapm_routes = ARRAY_SIZE(wm8985_common_dapm_routes), + .suspend_bias_off = 1, + .idle_bias_on = 1, + .pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, };
static const struct regmap_config wm8985_regmap = { @@ -1154,23 +1155,16 @@ static int wm8985_spi_probe(struct spi_device *spi) return ret; }
- ret = snd_soc_register_codec(&spi->dev, - &soc_codec_dev_wm8985, &wm8985_dai, 1); + ret = devm_snd_soc_register_component(&spi->dev, + &soc_component_dev_wm8985, &wm8985_dai, 1); return ret; }
-static int wm8985_spi_remove(struct spi_device *spi) -{ - snd_soc_unregister_codec(&spi->dev); - return 0; -} - static struct spi_driver wm8985_spi_driver = { .driver = { .name = "wm8985", }, .probe = wm8985_spi_probe, - .remove = wm8985_spi_remove }; #endif
@@ -1197,17 +1191,11 @@ static int wm8985_i2c_probe(struct i2c_client *i2c, return ret; }
- ret = snd_soc_register_codec(&i2c->dev, - &soc_codec_dev_wm8985, &wm8985_dai, 1); + ret = devm_snd_soc_register_component(&i2c->dev, + &soc_component_dev_wm8985, &wm8985_dai, 1); return ret; }
-static int wm8985_i2c_remove(struct i2c_client *i2c) -{ - snd_soc_unregister_codec(&i2c->dev); - return 0; -} - static const struct i2c_device_id wm8985_i2c_id[] = { { "wm8985", WM8985 }, { "wm8758", WM8758 }, @@ -1220,7 +1208,6 @@ static int wm8985_i2c_remove(struct i2c_client *i2c) .name = "wm8985", }, .probe = wm8985_i2c_probe, - .remove = wm8985_i2c_remove, .id_table = wm8985_i2c_id }; #endif
From: Kuninori Morimoto kuninori.morimoto.gx@renesas.com
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 -> .pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com --- sound/soc/codecs/wm8971.c | 108 ++++++++++++++++++++++------------------------ 1 file changed, 51 insertions(+), 57 deletions(-)
diff --git a/sound/soc/codecs/wm8971.c b/sound/soc/codecs/wm8971.c index 887d31c..4b02561 100644 --- a/sound/soc/codecs/wm8971.c +++ b/sound/soc/codecs/wm8971.c @@ -89,7 +89,7 @@ struct wm8971_priv { { 42, 0x0079 }, };
-#define wm8971_reset(c) snd_soc_write(c, WM8971_RESET, 0) +#define wm8971_reset(c) snd_soc_component_write(c, WM8971_RESET, 0)
/* WM8971 Controls */ static const char *wm8971_bass[] = { "Linear Control", "Adaptive Boost" }; @@ -433,8 +433,8 @@ static int get_coeff(int mclk, int rate) static int wm8971_set_dai_sysclk(struct snd_soc_dai *codec_dai, int clk_id, unsigned int freq, int dir) { - struct snd_soc_codec *codec = codec_dai->codec; - struct wm8971_priv *wm8971 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = codec_dai->component; + struct wm8971_priv *wm8971 = snd_soc_component_get_drvdata(component);
switch (freq) { case 11289600: @@ -451,7 +451,7 @@ static int wm8971_set_dai_sysclk(struct snd_soc_dai *codec_dai, static int wm8971_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt) { - struct snd_soc_codec *codec = codec_dai->codec; + struct snd_soc_component *component = codec_dai->component; u16 iface = 0;
/* set master/slave audio interface */ @@ -502,7 +502,7 @@ static int wm8971_set_dai_fmt(struct snd_soc_dai *codec_dai, return -EINVAL; }
- snd_soc_write(codec, WM8971_IFACE, iface); + snd_soc_component_write(component, WM8971_IFACE, iface); return 0; }
@@ -510,10 +510,10 @@ static int wm8971_pcm_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; - struct wm8971_priv *wm8971 = snd_soc_codec_get_drvdata(codec); - u16 iface = snd_soc_read(codec, WM8971_IFACE) & 0x1f3; - u16 srate = snd_soc_read(codec, WM8971_SRATE) & 0x1c0; + struct snd_soc_component *component = dai->component; + struct wm8971_priv *wm8971 = snd_soc_component_get_drvdata(component); + u16 iface = snd_soc_component_read32(component, WM8971_IFACE) & 0x1f3; + u16 srate = snd_soc_component_read32(component, WM8971_SRATE) & 0x1c0; int coeff = get_coeff(wm8971->sysclk, params_rate(params));
/* bit size */ @@ -532,9 +532,9 @@ static int wm8971_pcm_hw_params(struct snd_pcm_substream *substream, }
/* set iface & srate */ - snd_soc_write(codec, WM8971_IFACE, iface); + snd_soc_component_write(component, WM8971_IFACE, iface); if (coeff >= 0) - snd_soc_write(codec, WM8971_SRATE, srate | + snd_soc_component_write(component, WM8971_SRATE, srate | (coeff_div[coeff].sr << 1) | coeff_div[coeff].usb);
return 0; @@ -542,13 +542,13 @@ static int wm8971_pcm_hw_params(struct snd_pcm_substream *substream,
static int wm8971_mute(struct snd_soc_dai *dai, int mute) { - struct snd_soc_codec *codec = dai->codec; - u16 mute_reg = snd_soc_read(codec, WM8971_ADCDAC) & 0xfff7; + struct snd_soc_component *component = dai->component; + u16 mute_reg = snd_soc_component_read32(component, WM8971_ADCDAC) & 0xfff7;
if (mute) - snd_soc_write(codec, WM8971_ADCDAC, mute_reg | 0x8); + snd_soc_component_write(component, WM8971_ADCDAC, mute_reg | 0x8); else - snd_soc_write(codec, WM8971_ADCDAC, mute_reg); + snd_soc_component_write(component, WM8971_ADCDAC, mute_reg); return 0; }
@@ -561,37 +561,37 @@ static void wm8971_charge_work(struct work_struct *work) regmap_update_bits(wm8971->regmap, WM8971_PWR1, 0x0180, 0x0100); }
-static int wm8971_set_bias_level(struct snd_soc_codec *codec, +static int wm8971_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { - struct wm8971_priv *wm8971 = snd_soc_codec_get_drvdata(codec); - u16 pwr_reg = snd_soc_read(codec, WM8971_PWR1) & 0xfe3e; + struct wm8971_priv *wm8971 = snd_soc_component_get_drvdata(component); + u16 pwr_reg = snd_soc_component_read32(component, WM8971_PWR1) & 0xfe3e;
switch (level) { case SND_SOC_BIAS_ON: /* set vmid to 50k and unmute dac */ - snd_soc_write(codec, WM8971_PWR1, pwr_reg | 0x00c1); + snd_soc_component_write(component, WM8971_PWR1, pwr_reg | 0x00c1); break; case SND_SOC_BIAS_PREPARE: /* Wait until fully charged */ flush_delayed_work(&wm8971->charge_work); break; case SND_SOC_BIAS_STANDBY: - if (snd_soc_codec_get_bias_level(codec) == SND_SOC_BIAS_OFF) { - snd_soc_cache_sync(codec); + if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_OFF) { + snd_soc_component_cache_sync(component); /* charge output caps - set vmid to 5k for quick power up */ - snd_soc_write(codec, WM8971_PWR1, pwr_reg | 0x01c0); + snd_soc_component_write(component, WM8971_PWR1, pwr_reg | 0x01c0); queue_delayed_work(system_power_efficient_wq, &wm8971->charge_work, msecs_to_jiffies(1000)); } else { /* mute dac and set vmid to 500k, enable VREF */ - snd_soc_write(codec, WM8971_PWR1, pwr_reg | 0x0140); + snd_soc_component_write(component, WM8971_PWR1, pwr_reg | 0x0140); }
break; case SND_SOC_BIAS_OFF: cancel_delayed_work_sync(&wm8971->charge_work); - snd_soc_write(codec, WM8971_PWR1, 0x0001); + snd_soc_component_write(component, WM8971_PWR1, 0x0001); break; } return 0; @@ -628,40 +628,41 @@ static int wm8971_set_bias_level(struct snd_soc_codec *codec, .ops = &wm8971_dai_ops, };
-static int wm8971_probe(struct snd_soc_codec *codec) +static int wm8971_probe(struct snd_soc_component *component) { - struct wm8971_priv *wm8971 = snd_soc_codec_get_drvdata(codec); + struct wm8971_priv *wm8971 = snd_soc_component_get_drvdata(component);
INIT_DELAYED_WORK(&wm8971->charge_work, wm8971_charge_work);
- wm8971_reset(codec); + wm8971_reset(component);
/* set the update bits */ - snd_soc_update_bits(codec, WM8971_LDAC, 0x0100, 0x0100); - snd_soc_update_bits(codec, WM8971_RDAC, 0x0100, 0x0100); - snd_soc_update_bits(codec, WM8971_LOUT1V, 0x0100, 0x0100); - snd_soc_update_bits(codec, WM8971_ROUT1V, 0x0100, 0x0100); - snd_soc_update_bits(codec, WM8971_LOUT2V, 0x0100, 0x0100); - snd_soc_update_bits(codec, WM8971_ROUT2V, 0x0100, 0x0100); - snd_soc_update_bits(codec, WM8971_LINVOL, 0x0100, 0x0100); - snd_soc_update_bits(codec, WM8971_RINVOL, 0x0100, 0x0100); + snd_soc_component_update_bits(component, WM8971_LDAC, 0x0100, 0x0100); + snd_soc_component_update_bits(component, WM8971_RDAC, 0x0100, 0x0100); + snd_soc_component_update_bits(component, WM8971_LOUT1V, 0x0100, 0x0100); + snd_soc_component_update_bits(component, WM8971_ROUT1V, 0x0100, 0x0100); + snd_soc_component_update_bits(component, WM8971_LOUT2V, 0x0100, 0x0100); + snd_soc_component_update_bits(component, WM8971_ROUT2V, 0x0100, 0x0100); + snd_soc_component_update_bits(component, WM8971_LINVOL, 0x0100, 0x0100); + snd_soc_component_update_bits(component, WM8971_RINVOL, 0x0100, 0x0100);
return 0; }
-static const struct snd_soc_codec_driver soc_codec_dev_wm8971 = { - .probe = wm8971_probe, - .set_bias_level = wm8971_set_bias_level, - .suspend_bias_off = true, - - .component_driver = { - .controls = wm8971_snd_controls, - .num_controls = ARRAY_SIZE(wm8971_snd_controls), - .dapm_widgets = wm8971_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(wm8971_dapm_widgets), - .dapm_routes = wm8971_dapm_routes, - .num_dapm_routes = ARRAY_SIZE(wm8971_dapm_routes), - }, +static const struct snd_soc_component_driver soc_component_dev_wm8971 = { + .probe = wm8971_probe, + .set_bias_level = wm8971_set_bias_level, + .controls = wm8971_snd_controls, + .num_controls = ARRAY_SIZE(wm8971_snd_controls), + .dapm_widgets = wm8971_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(wm8971_dapm_widgets), + .dapm_routes = wm8971_dapm_routes, + .num_dapm_routes = ARRAY_SIZE(wm8971_dapm_routes), + .suspend_bias_off = 1, + .idle_bias_on = 1, + .pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, };
static const struct regmap_config wm8971_regmap = { @@ -691,18 +692,12 @@ static int wm8971_i2c_probe(struct i2c_client *i2c,
i2c_set_clientdata(i2c, wm8971);
- ret = snd_soc_register_codec(&i2c->dev, - &soc_codec_dev_wm8971, &wm8971_dai, 1); + ret = devm_snd_soc_register_component(&i2c->dev, + &soc_component_dev_wm8971, &wm8971_dai, 1);
return ret; }
-static int wm8971_i2c_remove(struct i2c_client *client) -{ - snd_soc_unregister_codec(&client->dev); - return 0; -} - static const struct i2c_device_id wm8971_i2c_id[] = { { "wm8971", 0 }, { } @@ -714,7 +709,6 @@ static int wm8971_i2c_remove(struct i2c_client *client) .name = "wm8971", }, .probe = wm8971_i2c_probe, - .remove = wm8971_i2c_remove, .id_table = wm8971_i2c_id, };
From: Kuninori Morimoto kuninori.morimoto.gx@renesas.com
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 -> .pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com --- sound/soc/codecs/wm8978.c | 185 ++++++++++++++++++++++------------------------ 1 file changed, 89 insertions(+), 96 deletions(-)
diff --git a/sound/soc/codecs/wm8978.c b/sound/soc/codecs/wm8978.c index cf761e2..50801b3 100644 --- a/sound/soc/codecs/wm8978.c +++ b/sound/soc/codecs/wm8978.c @@ -408,7 +408,7 @@ struct wm8978_pll_div {
#define FIXED_PLL_SIZE (1 << 24)
-static void pll_factors(struct snd_soc_codec *codec, +static void pll_factors(struct snd_soc_component *component, struct wm8978_pll_div *pll_div, unsigned int target, unsigned int source) { u64 k_part; @@ -424,7 +424,7 @@ static void pll_factors(struct snd_soc_codec *codec, }
if (n_div < 6 || n_div > 12) - dev_warn(codec->dev, + dev_warn(component->dev, "WM8978 N value exceeds recommended range! N = %u\n", n_div);
@@ -471,9 +471,9 @@ static int wm8978_enum_mclk(unsigned int f_out, unsigned int f_mclk, * Calculate internal frequencies and dividers, according to Figure 40 * "PLL and Clock Select Circuit" in WM8978 datasheet Rev. 2.6 */ -static int wm8978_configure_pll(struct snd_soc_codec *codec) +static int wm8978_configure_pll(struct snd_soc_component *component) { - struct wm8978_priv *wm8978 = snd_soc_codec_get_drvdata(codec); + struct wm8978_priv *wm8978 = snd_soc_component_get_drvdata(component); struct wm8978_pll_div pll_div; unsigned int f_opclk = wm8978->f_opclk, f_mclk = wm8978->f_mclk, f_256fs = wm8978->f_256fs; @@ -505,9 +505,9 @@ static int wm8978_configure_pll(struct snd_soc_codec *codec) else opclk_div = 1;
- dev_dbg(codec->dev, "%s: OPCLKDIV=%d\n", __func__, opclk_div); + dev_dbg(component->dev, "%s: OPCLKDIV=%d\n", __func__, opclk_div);
- snd_soc_update_bits(codec, WM8978_GPIO_CONTROL, 0x30, + snd_soc_component_update_bits(component, WM8978_GPIO_CONTROL, 0x30, (opclk_div - 1) << 4);
wm8978->f_pllout = f_opclk * opclk_div; @@ -533,28 +533,28 @@ static int wm8978_configure_pll(struct snd_soc_codec *codec)
f2 = wm8978->f_pllout * 4;
- dev_dbg(codec->dev, "%s: f_MCLK=%uHz, f_PLLOUT=%uHz\n", __func__, + dev_dbg(component->dev, "%s: f_MCLK=%uHz, f_PLLOUT=%uHz\n", __func__, wm8978->f_mclk, wm8978->f_pllout);
- pll_factors(codec, &pll_div, f2, wm8978->f_mclk); + pll_factors(component, &pll_div, f2, wm8978->f_mclk);
- dev_dbg(codec->dev, "%s: calculated PLL N=0x%x, K=0x%x, div2=%d\n", + dev_dbg(component->dev, "%s: calculated PLL N=0x%x, K=0x%x, div2=%d\n", __func__, pll_div.n, pll_div.k, pll_div.div2);
/* Turn PLL off for configuration... */ - snd_soc_update_bits(codec, WM8978_POWER_MANAGEMENT_1, 0x20, 0); + snd_soc_component_update_bits(component, WM8978_POWER_MANAGEMENT_1, 0x20, 0);
- snd_soc_write(codec, WM8978_PLL_N, (pll_div.div2 << 4) | pll_div.n); - snd_soc_write(codec, WM8978_PLL_K1, pll_div.k >> 18); - snd_soc_write(codec, WM8978_PLL_K2, (pll_div.k >> 9) & 0x1ff); - snd_soc_write(codec, WM8978_PLL_K3, pll_div.k & 0x1ff); + snd_soc_component_write(component, WM8978_PLL_N, (pll_div.div2 << 4) | pll_div.n); + snd_soc_component_write(component, WM8978_PLL_K1, pll_div.k >> 18); + snd_soc_component_write(component, WM8978_PLL_K2, (pll_div.k >> 9) & 0x1ff); + snd_soc_component_write(component, WM8978_PLL_K3, pll_div.k & 0x1ff);
/* ...and on again */ - snd_soc_update_bits(codec, WM8978_POWER_MANAGEMENT_1, 0x20, 0x20); + snd_soc_component_update_bits(component, WM8978_POWER_MANAGEMENT_1, 0x20, 0x20);
if (f_opclk) /* Output PLL (OPCLK) to GPIO1 */ - snd_soc_update_bits(codec, WM8978_GPIO_CONTROL, 7, 4); + snd_soc_component_update_bits(component, WM8978_GPIO_CONTROL, 7, 4);
return 0; } @@ -565,8 +565,8 @@ static int wm8978_configure_pll(struct snd_soc_codec *codec) static int wm8978_set_dai_clkdiv(struct snd_soc_dai *codec_dai, int div_id, int div) { - struct snd_soc_codec *codec = codec_dai->codec; - struct wm8978_priv *wm8978 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = codec_dai->component; + struct wm8978_priv *wm8978 = snd_soc_component_get_drvdata(component); int ret = 0;
switch (div_id) { @@ -588,18 +588,18 @@ static int wm8978_set_dai_clkdiv(struct snd_soc_dai *codec_dai, * find an exact MCLK divider configuration - it will * be equal to or double the OPCLK divisor. */ - ret = wm8978_configure_pll(codec); + ret = wm8978_configure_pll(component); break; case WM8978_BCLKDIV: if (div & ~0x1c) return -EINVAL; - snd_soc_update_bits(codec, WM8978_CLOCKING, 0x1c, div); + snd_soc_component_update_bits(component, WM8978_CLOCKING, 0x1c, div); break; default: return -EINVAL; }
- dev_dbg(codec->dev, "%s: ID %d, value %u\n", __func__, div_id, div); + dev_dbg(component->dev, "%s: ID %d, value %u\n", __func__, div_id, div);
return ret; } @@ -610,18 +610,18 @@ static int wm8978_set_dai_clkdiv(struct snd_soc_dai *codec_dai, static int wm8978_set_dai_sysclk(struct snd_soc_dai *codec_dai, int clk_id, unsigned int freq, int dir) { - struct snd_soc_codec *codec = codec_dai->codec; - struct wm8978_priv *wm8978 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = codec_dai->component; + struct wm8978_priv *wm8978 = snd_soc_component_get_drvdata(component); int ret = 0;
- dev_dbg(codec->dev, "%s: ID %d, freq %u\n", __func__, clk_id, freq); + dev_dbg(component->dev, "%s: ID %d, freq %u\n", __func__, clk_id, freq);
if (freq) { wm8978->f_mclk = freq;
/* Even if MCLK is used for system clock, might have to drive OPCLK */ if (wm8978->f_opclk) - ret = wm8978_configure_pll(codec); + ret = wm8978_configure_pll(component);
/* Our sysclk is fixed to 256 * fs, will configure in .hw_params() */
@@ -631,13 +631,13 @@ static int wm8978_set_dai_sysclk(struct snd_soc_dai *codec_dai, int clk_id,
if (wm8978->sysclk == WM8978_PLL && (!freq || clk_id == WM8978_MCLK)) { /* Clock CODEC directly from MCLK */ - snd_soc_update_bits(codec, WM8978_CLOCKING, 0x100, 0); + snd_soc_component_update_bits(component, WM8978_CLOCKING, 0x100, 0);
/* GPIO1 into default mode as input - before configuring PLL */ - snd_soc_update_bits(codec, WM8978_GPIO_CONTROL, 7, 0); + snd_soc_component_update_bits(component, WM8978_GPIO_CONTROL, 7, 0);
/* Turn off PLL */ - snd_soc_update_bits(codec, WM8978_POWER_MANAGEMENT_1, 0x20, 0); + snd_soc_component_update_bits(component, WM8978_POWER_MANAGEMENT_1, 0x20, 0); wm8978->sysclk = WM8978_MCLK; wm8978->f_pllout = 0; wm8978->f_opclk = 0; @@ -651,15 +651,15 @@ static int wm8978_set_dai_sysclk(struct snd_soc_dai *codec_dai, int clk_id, */ static int wm8978_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt) { - struct snd_soc_codec *codec = codec_dai->codec; + struct snd_soc_component *component = codec_dai->component; /* * BCLK polarity mask = 0x100, LRC clock polarity mask = 0x80, * Data Format mask = 0x18: all will be calculated anew */ - u16 iface = snd_soc_read(codec, WM8978_AUDIO_INTERFACE) & ~0x198; - u16 clk = snd_soc_read(codec, WM8978_CLOCKING); + u16 iface = snd_soc_component_read32(component, WM8978_AUDIO_INTERFACE) & ~0x198; + u16 clk = snd_soc_component_read32(component, WM8978_CLOCKING);
- dev_dbg(codec->dev, "%s\n", __func__); + dev_dbg(component->dev, "%s\n", __func__);
/* set master/slave audio interface */ switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { @@ -707,8 +707,8 @@ static int wm8978_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt) return -EINVAL; }
- snd_soc_write(codec, WM8978_AUDIO_INTERFACE, iface); - snd_soc_write(codec, WM8978_CLOCKING, clk); + snd_soc_component_write(component, WM8978_AUDIO_INTERFACE, iface); + snd_soc_component_write(component, WM8978_CLOCKING, clk);
return 0; } @@ -720,13 +720,13 @@ static int wm8978_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; - struct wm8978_priv *wm8978 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct wm8978_priv *wm8978 = snd_soc_component_get_drvdata(component); /* Word length mask = 0x60 */ - u16 iface_ctl = snd_soc_read(codec, WM8978_AUDIO_INTERFACE) & ~0x60; + u16 iface_ctl = snd_soc_component_read32(component, WM8978_AUDIO_INTERFACE) & ~0x60; /* Sampling rate mask = 0xe (for filters) */ - u16 add_ctl = snd_soc_read(codec, WM8978_ADDITIONAL_CONTROL) & ~0xe; - u16 clking = snd_soc_read(codec, WM8978_CLOCKING); + u16 add_ctl = snd_soc_component_read32(component, WM8978_ADDITIONAL_CONTROL) & ~0xe; + u16 clking = snd_soc_component_read32(component, WM8978_CLOCKING); enum wm8978_sysclk_src current_clk_id = clking & 0x100 ? WM8978_PLL : WM8978_MCLK; unsigned int f_sel, diff, diff_best = INT_MAX; @@ -781,7 +781,7 @@ static int wm8978_hw_params(struct snd_pcm_substream *substream, } else { if (!wm8978->f_opclk) { /* We only enter here, if OPCLK is not used */ - int ret = wm8978_configure_pll(codec); + int ret = wm8978_configure_pll(component); if (ret < 0) return ret; } @@ -812,28 +812,28 @@ static int wm8978_hw_params(struct snd_pcm_substream *substream, }
if (diff) - dev_warn(codec->dev, "Imprecise sampling rate: %uHz%s\n", + dev_warn(component->dev, "Imprecise sampling rate: %uHz%s\n", f_sel * mclk_denominator[best] / mclk_numerator[best] / 256, wm8978->sysclk == WM8978_MCLK ? ", consider using PLL" : "");
- dev_dbg(codec->dev, "%s: width %d, rate %u, MCLK divisor #%d\n", __func__, + dev_dbg(component->dev, "%s: width %d, rate %u, MCLK divisor #%d\n", __func__, params_width(params), params_rate(params), best);
/* MCLK divisor mask = 0xe0 */ - snd_soc_update_bits(codec, WM8978_CLOCKING, 0xe0, best << 5); + snd_soc_component_update_bits(component, WM8978_CLOCKING, 0xe0, best << 5);
- snd_soc_write(codec, WM8978_AUDIO_INTERFACE, iface_ctl); - snd_soc_write(codec, WM8978_ADDITIONAL_CONTROL, add_ctl); + snd_soc_component_write(component, WM8978_AUDIO_INTERFACE, iface_ctl); + snd_soc_component_write(component, WM8978_ADDITIONAL_CONTROL, add_ctl);
if (wm8978->sysclk != current_clk_id) { if (wm8978->sysclk == WM8978_PLL) /* Run CODEC from PLL instead of MCLK */ - snd_soc_update_bits(codec, WM8978_CLOCKING, + snd_soc_component_update_bits(component, WM8978_CLOCKING, 0x100, 0x100); else /* Clock CODEC directly from MCLK */ - snd_soc_update_bits(codec, WM8978_CLOCKING, 0x100, 0); + snd_soc_component_update_bits(component, WM8978_CLOCKING, 0x100, 0); }
return 0; @@ -841,52 +841,52 @@ static int wm8978_hw_params(struct snd_pcm_substream *substream,
static int wm8978_mute(struct snd_soc_dai *dai, int mute) { - struct snd_soc_codec *codec = dai->codec; + struct snd_soc_component *component = dai->component;
- dev_dbg(codec->dev, "%s: %d\n", __func__, mute); + dev_dbg(component->dev, "%s: %d\n", __func__, mute);
if (mute) - snd_soc_update_bits(codec, WM8978_DAC_CONTROL, 0x40, 0x40); + snd_soc_component_update_bits(component, WM8978_DAC_CONTROL, 0x40, 0x40); else - snd_soc_update_bits(codec, WM8978_DAC_CONTROL, 0x40, 0); + snd_soc_component_update_bits(component, WM8978_DAC_CONTROL, 0x40, 0);
return 0; }
-static int wm8978_set_bias_level(struct snd_soc_codec *codec, +static int wm8978_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { - u16 power1 = snd_soc_read(codec, WM8978_POWER_MANAGEMENT_1) & ~3; + u16 power1 = snd_soc_component_read32(component, WM8978_POWER_MANAGEMENT_1) & ~3;
switch (level) { case SND_SOC_BIAS_ON: case SND_SOC_BIAS_PREPARE: power1 |= 1; /* VMID 75k */ - snd_soc_write(codec, WM8978_POWER_MANAGEMENT_1, power1); + snd_soc_component_write(component, WM8978_POWER_MANAGEMENT_1, power1); break; case SND_SOC_BIAS_STANDBY: /* bit 3: enable bias, bit 2: enable I/O tie off buffer */ power1 |= 0xc;
- if (snd_soc_codec_get_bias_level(codec) == SND_SOC_BIAS_OFF) { + if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_OFF) { /* Initial cap charge at VMID 5k */ - snd_soc_write(codec, WM8978_POWER_MANAGEMENT_1, + snd_soc_component_write(component, WM8978_POWER_MANAGEMENT_1, power1 | 0x3); mdelay(100); }
power1 |= 0x2; /* VMID 500k */ - snd_soc_write(codec, WM8978_POWER_MANAGEMENT_1, power1); + snd_soc_component_write(component, WM8978_POWER_MANAGEMENT_1, power1); break; case SND_SOC_BIAS_OFF: /* Preserve PLL - OPCLK may be used by someone */ - snd_soc_update_bits(codec, WM8978_POWER_MANAGEMENT_1, ~0x20, 0); - snd_soc_write(codec, WM8978_POWER_MANAGEMENT_2, 0); - snd_soc_write(codec, WM8978_POWER_MANAGEMENT_3, 0); + snd_soc_component_update_bits(component, WM8978_POWER_MANAGEMENT_1, ~0x20, 0); + snd_soc_component_write(component, WM8978_POWER_MANAGEMENT_2, 0); + snd_soc_component_write(component, WM8978_POWER_MANAGEMENT_3, 0); break; }
- dev_dbg(codec->dev, "%s: %d, %x\n", __func__, level, power1); + dev_dbg(component->dev, "%s: %d, %x\n", __func__, level, power1);
return 0; } @@ -923,31 +923,31 @@ static int wm8978_set_bias_level(struct snd_soc_codec *codec, .symmetric_rates = 1, };
-static int wm8978_suspend(struct snd_soc_codec *codec) +static int wm8978_suspend(struct snd_soc_component *component) { - struct wm8978_priv *wm8978 = snd_soc_codec_get_drvdata(codec); + struct wm8978_priv *wm8978 = snd_soc_component_get_drvdata(component);
- snd_soc_codec_force_bias_level(codec, SND_SOC_BIAS_OFF); + snd_soc_component_force_bias_level(component, SND_SOC_BIAS_OFF); /* Also switch PLL off */ - snd_soc_write(codec, WM8978_POWER_MANAGEMENT_1, 0); + snd_soc_component_write(component, WM8978_POWER_MANAGEMENT_1, 0);
regcache_mark_dirty(wm8978->regmap);
return 0; }
-static int wm8978_resume(struct snd_soc_codec *codec) +static int wm8978_resume(struct snd_soc_component *component) { - struct wm8978_priv *wm8978 = snd_soc_codec_get_drvdata(codec); + struct wm8978_priv *wm8978 = snd_soc_component_get_drvdata(component);
/* Sync reg_cache with the hardware */ regcache_sync(wm8978->regmap);
- snd_soc_codec_force_bias_level(codec, SND_SOC_BIAS_STANDBY); + snd_soc_component_force_bias_level(component, SND_SOC_BIAS_STANDBY);
if (wm8978->f_pllout) /* Switch PLL on */ - snd_soc_update_bits(codec, WM8978_POWER_MANAGEMENT_1, 0x20, 0x20); + snd_soc_component_update_bits(component, WM8978_POWER_MANAGEMENT_1, 0x20, 0x20);
return 0; } @@ -971,9 +971,9 @@ static int wm8978_resume(struct snd_soc_codec *codec) WM8978_ROUT2_SPK_CONTROL, };
-static int wm8978_probe(struct snd_soc_codec *codec) +static int wm8978_probe(struct snd_soc_component *component) { - struct wm8978_priv *wm8978 = snd_soc_codec_get_drvdata(codec); + struct wm8978_priv *wm8978 = snd_soc_component_get_drvdata(component); int i;
/* @@ -988,25 +988,26 @@ static int wm8978_probe(struct snd_soc_codec *codec) * written. */ for (i = 0; i < ARRAY_SIZE(update_reg); i++) - snd_soc_update_bits(codec, update_reg[i], 0x100, 0x100); + snd_soc_component_update_bits(component, update_reg[i], 0x100, 0x100);
return 0; }
-static const struct snd_soc_codec_driver soc_codec_dev_wm8978 = { - .probe = wm8978_probe, - .suspend = wm8978_suspend, - .resume = wm8978_resume, - .set_bias_level = wm8978_set_bias_level, - - .component_driver = { - .controls = wm8978_snd_controls, - .num_controls = ARRAY_SIZE(wm8978_snd_controls), - .dapm_widgets = wm8978_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(wm8978_dapm_widgets), - .dapm_routes = wm8978_dapm_routes, - .num_dapm_routes = ARRAY_SIZE(wm8978_dapm_routes), - }, +static const struct snd_soc_component_driver soc_component_dev_wm8978 = { + .probe = wm8978_probe, + .suspend = wm8978_suspend, + .resume = wm8978_resume, + .set_bias_level = wm8978_set_bias_level, + .controls = wm8978_snd_controls, + .num_controls = ARRAY_SIZE(wm8978_snd_controls), + .dapm_widgets = wm8978_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(wm8978_dapm_widgets), + .dapm_routes = wm8978_dapm_routes, + .num_dapm_routes = ARRAY_SIZE(wm8978_dapm_routes), + .idle_bias_on = 1, + .pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, };
static const struct regmap_config wm8978_regmap_config = { @@ -1048,8 +1049,8 @@ static int wm8978_i2c_probe(struct i2c_client *i2c, return ret; }
- ret = snd_soc_register_codec(&i2c->dev, - &soc_codec_dev_wm8978, &wm8978_dai, 1); + ret = devm_snd_soc_register_component(&i2c->dev, + &soc_component_dev_wm8978, &wm8978_dai, 1); if (ret != 0) { dev_err(&i2c->dev, "Failed to register CODEC: %d\n", ret); return ret; @@ -1058,13 +1059,6 @@ static int wm8978_i2c_probe(struct i2c_client *i2c, return 0; }
-static int wm8978_i2c_remove(struct i2c_client *client) -{ - snd_soc_unregister_codec(&client->dev); - - return 0; -} - static const struct i2c_device_id wm8978_i2c_id[] = { { "wm8978", 0 }, { } @@ -1083,7 +1077,6 @@ static int wm8978_i2c_remove(struct i2c_client *client) .of_match_table = wm8978_of_match, }, .probe = wm8978_i2c_probe, - .remove = wm8978_i2c_remove, .id_table = wm8978_i2c_id, };
From: Kuninori Morimoto kuninori.morimoto.gx@renesas.com
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 -> .pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com --- sound/soc/codecs/wm8974.c | 143 ++++++++++++++++++++++------------------------ 1 file changed, 68 insertions(+), 75 deletions(-)
diff --git a/sound/soc/codecs/wm8974.c b/sound/soc/codecs/wm8974.c index d414ddd..baf3fee 100644 --- a/sound/soc/codecs/wm8974.c +++ b/sound/soc/codecs/wm8974.c @@ -54,7 +54,7 @@ struct wm8974_priv { #define WM8974_POWER1_BIASEN 0x08 #define WM8974_POWER1_BUFIOEN 0x04
-#define wm8974_reset(c) snd_soc_write(c, WM8974_RESET, 0) +#define wm8974_reset(c) snd_soc_component_write(c, WM8974_RESET, 0)
static const char *wm8974_companding[] = {"Off", "NC", "u-law", "A-law" }; static const char *wm8974_deemp[] = {"None", "32kHz", "44.1kHz", "48kHz" }; @@ -324,33 +324,33 @@ static void pll_factors(struct pll_ *pll_div, static int wm8974_set_dai_pll(struct snd_soc_dai *codec_dai, int pll_id, int source, unsigned int freq_in, unsigned int freq_out) { - struct snd_soc_codec *codec = codec_dai->codec; + struct snd_soc_component *component = codec_dai->component; struct pll_ pll_div; u16 reg;
if (freq_in == 0 || freq_out == 0) { /* Clock CODEC directly from MCLK */ - reg = snd_soc_read(codec, WM8974_CLOCK); - snd_soc_write(codec, WM8974_CLOCK, reg & 0x0ff); + reg = snd_soc_component_read32(component, WM8974_CLOCK); + snd_soc_component_write(component, WM8974_CLOCK, reg & 0x0ff);
/* Turn off PLL */ - reg = snd_soc_read(codec, WM8974_POWER1); - snd_soc_write(codec, WM8974_POWER1, reg & 0x1df); + reg = snd_soc_component_read32(component, WM8974_POWER1); + snd_soc_component_write(component, WM8974_POWER1, reg & 0x1df); return 0; }
pll_factors(&pll_div, freq_out, freq_in);
- snd_soc_write(codec, WM8974_PLLN, (pll_div.pre_div << 4) | pll_div.n); - snd_soc_write(codec, WM8974_PLLK1, pll_div.k >> 18); - snd_soc_write(codec, WM8974_PLLK2, (pll_div.k >> 9) & 0x1ff); - snd_soc_write(codec, WM8974_PLLK3, pll_div.k & 0x1ff); - reg = snd_soc_read(codec, WM8974_POWER1); - snd_soc_write(codec, WM8974_POWER1, reg | 0x020); + snd_soc_component_write(component, WM8974_PLLN, (pll_div.pre_div << 4) | pll_div.n); + snd_soc_component_write(component, WM8974_PLLK1, pll_div.k >> 18); + snd_soc_component_write(component, WM8974_PLLK2, (pll_div.k >> 9) & 0x1ff); + snd_soc_component_write(component, WM8974_PLLK3, pll_div.k & 0x1ff); + reg = snd_soc_component_read32(component, WM8974_POWER1); + snd_soc_component_write(component, WM8974_POWER1, reg | 0x020);
/* Run CODEC from PLL instead of MCLK */ - reg = snd_soc_read(codec, WM8974_CLOCK); - snd_soc_write(codec, WM8974_CLOCK, reg | 0x100); + reg = snd_soc_component_read32(component, WM8974_CLOCK); + snd_soc_component_write(component, WM8974_CLOCK, reg | 0x100);
return 0; } @@ -361,21 +361,21 @@ static int wm8974_set_dai_pll(struct snd_soc_dai *codec_dai, int pll_id, static int wm8974_set_dai_clkdiv(struct snd_soc_dai *codec_dai, int div_id, int div) { - struct snd_soc_codec *codec = codec_dai->codec; + struct snd_soc_component *component = codec_dai->component; u16 reg;
switch (div_id) { case WM8974_OPCLKDIV: - reg = snd_soc_read(codec, WM8974_GPIO) & 0x1cf; - snd_soc_write(codec, WM8974_GPIO, reg | div); + reg = snd_soc_component_read32(component, WM8974_GPIO) & 0x1cf; + snd_soc_component_write(component, WM8974_GPIO, reg | div); break; case WM8974_MCLKDIV: - reg = snd_soc_read(codec, WM8974_CLOCK) & 0x11f; - snd_soc_write(codec, WM8974_CLOCK, reg | div); + reg = snd_soc_component_read32(component, WM8974_CLOCK) & 0x11f; + snd_soc_component_write(component, WM8974_CLOCK, reg | div); break; case WM8974_BCLKDIV: - reg = snd_soc_read(codec, WM8974_CLOCK) & 0x1e3; - snd_soc_write(codec, WM8974_CLOCK, reg | div); + reg = snd_soc_component_read32(component, WM8974_CLOCK) & 0x1e3; + snd_soc_component_write(component, WM8974_CLOCK, reg | div); break; default: return -EINVAL; @@ -418,8 +418,8 @@ static unsigned int wm8974_get_mclkdiv(unsigned int f_in, unsigned int f_out,
static int wm8974_update_clocks(struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; - struct wm8974_priv *priv = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct wm8974_priv *priv = snd_soc_component_get_drvdata(component); unsigned int fs256; unsigned int fpll = 0; unsigned int f; @@ -446,8 +446,8 @@ static int wm8974_update_clocks(struct snd_soc_dai *dai) static int wm8974_set_dai_sysclk(struct snd_soc_dai *dai, int clk_id, unsigned int freq, int dir) { - struct snd_soc_codec *codec = dai->codec; - struct wm8974_priv *priv = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct wm8974_priv *priv = snd_soc_component_get_drvdata(component);
if (dir != SND_SOC_CLOCK_IN) return -EINVAL; @@ -460,9 +460,9 @@ static int wm8974_set_dai_sysclk(struct snd_soc_dai *dai, int clk_id, static int wm8974_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt) { - struct snd_soc_codec *codec = codec_dai->codec; + struct snd_soc_component *component = codec_dai->component; u16 iface = 0; - u16 clk = snd_soc_read(codec, WM8974_CLOCK) & 0x1fe; + u16 clk = snd_soc_component_read32(component, WM8974_CLOCK) & 0x1fe;
/* set master/slave audio interface */ switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { @@ -509,8 +509,8 @@ static int wm8974_set_dai_fmt(struct snd_soc_dai *codec_dai, return -EINVAL; }
- snd_soc_write(codec, WM8974_IFACE, iface); - snd_soc_write(codec, WM8974_CLOCK, clk); + snd_soc_component_write(component, WM8974_IFACE, iface); + snd_soc_component_write(component, WM8974_CLOCK, clk); return 0; }
@@ -518,10 +518,10 @@ static int wm8974_pcm_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; - struct wm8974_priv *priv = snd_soc_codec_get_drvdata(codec); - u16 iface = snd_soc_read(codec, WM8974_IFACE) & 0x19f; - u16 adn = snd_soc_read(codec, WM8974_ADD) & 0x1f1; + struct snd_soc_component *component = dai->component; + struct wm8974_priv *priv = snd_soc_component_get_drvdata(component); + u16 iface = snd_soc_component_read32(component, WM8974_IFACE) & 0x19f; + u16 adn = snd_soc_component_read32(component, WM8974_ADD) & 0x1f1; int err;
priv->fs = params_rate(params); @@ -566,55 +566,55 @@ static int wm8974_pcm_hw_params(struct snd_pcm_substream *substream, break; }
- snd_soc_write(codec, WM8974_IFACE, iface); - snd_soc_write(codec, WM8974_ADD, adn); + snd_soc_component_write(component, WM8974_IFACE, iface); + snd_soc_component_write(component, WM8974_ADD, adn); return 0; }
static int wm8974_mute(struct snd_soc_dai *dai, int mute) { - struct snd_soc_codec *codec = dai->codec; - u16 mute_reg = snd_soc_read(codec, WM8974_DAC) & 0xffbf; + struct snd_soc_component *component = dai->component; + u16 mute_reg = snd_soc_component_read32(component, WM8974_DAC) & 0xffbf;
if (mute) - snd_soc_write(codec, WM8974_DAC, mute_reg | 0x40); + snd_soc_component_write(component, WM8974_DAC, mute_reg | 0x40); else - snd_soc_write(codec, WM8974_DAC, mute_reg); + snd_soc_component_write(component, WM8974_DAC, mute_reg); return 0; }
/* liam need to make this lower power with dapm */ -static int wm8974_set_bias_level(struct snd_soc_codec *codec, +static int wm8974_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { - u16 power1 = snd_soc_read(codec, WM8974_POWER1) & ~0x3; + u16 power1 = snd_soc_component_read32(component, WM8974_POWER1) & ~0x3;
switch (level) { case SND_SOC_BIAS_ON: case SND_SOC_BIAS_PREPARE: power1 |= 0x1; /* VMID 50k */ - snd_soc_write(codec, WM8974_POWER1, power1); + snd_soc_component_write(component, WM8974_POWER1, power1); break;
case SND_SOC_BIAS_STANDBY: power1 |= WM8974_POWER1_BIASEN | WM8974_POWER1_BUFIOEN;
- if (snd_soc_codec_get_bias_level(codec) == SND_SOC_BIAS_OFF) { - regcache_sync(dev_get_regmap(codec->dev, NULL)); + if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_OFF) { + regcache_sync(dev_get_regmap(component->dev, NULL));
/* Initial cap charge at VMID 5k */ - snd_soc_write(codec, WM8974_POWER1, power1 | 0x3); + snd_soc_component_write(component, WM8974_POWER1, power1 | 0x3); mdelay(100); }
power1 |= 0x2; /* VMID 500k */ - snd_soc_write(codec, WM8974_POWER1, power1); + snd_soc_component_write(component, WM8974_POWER1, power1); break;
case SND_SOC_BIAS_OFF: - snd_soc_write(codec, WM8974_POWER1, 0); - snd_soc_write(codec, WM8974_POWER2, 0); - snd_soc_write(codec, WM8974_POWER3, 0); + snd_soc_component_write(component, WM8974_POWER1, 0); + snd_soc_component_write(component, WM8974_POWER2, 0); + snd_soc_component_write(component, WM8974_POWER3, 0); break; }
@@ -663,32 +663,33 @@ static int wm8974_set_bias_level(struct snd_soc_codec *codec, .cache_type = REGCACHE_FLAT, };
-static int wm8974_probe(struct snd_soc_codec *codec) +static int wm8974_probe(struct snd_soc_component *component) { int ret = 0;
- ret = wm8974_reset(codec); + ret = wm8974_reset(component); if (ret < 0) { - dev_err(codec->dev, "Failed to issue reset\n"); + dev_err(component->dev, "Failed to issue reset\n"); return ret; }
return 0; }
-static const struct snd_soc_codec_driver soc_codec_dev_wm8974 = { - .probe = wm8974_probe, - .set_bias_level = wm8974_set_bias_level, - .suspend_bias_off = true, - - .component_driver = { - .controls = wm8974_snd_controls, - .num_controls = ARRAY_SIZE(wm8974_snd_controls), - .dapm_widgets = wm8974_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(wm8974_dapm_widgets), - .dapm_routes = wm8974_dapm_routes, - .num_dapm_routes = ARRAY_SIZE(wm8974_dapm_routes), - }, +static const struct snd_soc_component_driver soc_component_dev_wm8974 = { + .probe = wm8974_probe, + .set_bias_level = wm8974_set_bias_level, + .controls = wm8974_snd_controls, + .num_controls = ARRAY_SIZE(wm8974_snd_controls), + .dapm_widgets = wm8974_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(wm8974_dapm_widgets), + .dapm_routes = wm8974_dapm_routes, + .num_dapm_routes = ARRAY_SIZE(wm8974_dapm_routes), + .suspend_bias_off = 1, + .idle_bias_on = 1, + .pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, };
static int wm8974_i2c_probe(struct i2c_client *i2c, @@ -708,19 +709,12 @@ static int wm8974_i2c_probe(struct i2c_client *i2c, if (IS_ERR(regmap)) return PTR_ERR(regmap);
- ret = snd_soc_register_codec(&i2c->dev, - &soc_codec_dev_wm8974, &wm8974_dai, 1); + ret = devm_snd_soc_register_component(&i2c->dev, + &soc_component_dev_wm8974, &wm8974_dai, 1);
return ret; }
-static int wm8974_i2c_remove(struct i2c_client *client) -{ - snd_soc_unregister_codec(&client->dev); - - return 0; -} - static const struct i2c_device_id wm8974_i2c_id[] = { { "wm8974", 0 }, { } @@ -739,7 +733,6 @@ static int wm8974_i2c_remove(struct i2c_client *client) .of_match_table = wm8974_of_match, }, .probe = wm8974_i2c_probe, - .remove = wm8974_i2c_remove, .id_table = wm8974_i2c_id, };
From: Kuninori Morimoto kuninori.morimoto.gx@renesas.com
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 -> .pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com --- sound/soc/codecs/wm8990.c | 179 ++++++++++++++++++++++------------------------ 1 file changed, 86 insertions(+), 93 deletions(-)
diff --git a/sound/soc/codecs/wm8990.c b/sound/soc/codecs/wm8990.c index a894500..283ec82 100644 --- a/sound/soc/codecs/wm8990.c +++ b/sound/soc/codecs/wm8990.c @@ -111,7 +111,7 @@ static bool wm8990_volatile_register(struct device *dev, unsigned int reg) { 62, 0x0026 }, /* R62 - PLL3 */ };
-#define wm8990_reset(c) snd_soc_write(c, WM8990_RESET, 0) +#define wm8990_reset(c) snd_soc_component_write(c, WM8990_RESET, 0)
static const DECLARE_TLV_DB_SCALE(rec_mix_tlv, -1500, 600, 0);
@@ -132,7 +132,7 @@ static bool wm8990_volatile_register(struct device *dev, unsigned int reg) static int wm899x_outpga_put_volsw_vu(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); struct soc_mixer_control *mc = (struct soc_mixer_control *)kcontrol->private_value; int reg = mc->reg; @@ -144,8 +144,8 @@ static int wm899x_outpga_put_volsw_vu(struct snd_kcontrol *kcontrol, return ret;
/* now hit the volume update bits (always bit 8) */ - val = snd_soc_read(codec, reg); - return snd_soc_write(codec, reg, val | 0x0100); + val = snd_soc_component_read32(component, reg); + return snd_soc_component_write(component, reg, val | 0x0100); }
#define SOC_WM899X_OUTPGA_SINGLE_R_TLV(xname, reg, shift, max, invert,\ @@ -374,14 +374,14 @@ static SOC_ENUM_SINGLE_DECL(wm8990_right_adcmode_enum, static int outmixer_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); u32 reg_shift = kcontrol->private_value & 0xfff; int ret = 0; u16 reg;
switch (reg_shift) { case WM8990_SPEAKER_MIXER | (WM8990_LDSPK_BIT << 8) : - reg = snd_soc_read(codec, WM8990_OUTPUT_MIXER1); + reg = snd_soc_component_read32(component, WM8990_OUTPUT_MIXER1); if (reg & WM8990_LDLO) { printk(KERN_WARNING "Cannot set as Output Mixer 1 LDLO Set\n"); @@ -389,7 +389,7 @@ static int outmixer_event(struct snd_soc_dapm_widget *w, } break; case WM8990_SPEAKER_MIXER | (WM8990_RDSPK_BIT << 8): - reg = snd_soc_read(codec, WM8990_OUTPUT_MIXER2); + reg = snd_soc_component_read32(component, WM8990_OUTPUT_MIXER2); if (reg & WM8990_RDRO) { printk(KERN_WARNING "Cannot set as Output Mixer 2 RDRO Set\n"); @@ -397,7 +397,7 @@ static int outmixer_event(struct snd_soc_dapm_widget *w, } break; case WM8990_OUTPUT_MIXER1 | (WM8990_LDLO_BIT << 8): - reg = snd_soc_read(codec, WM8990_SPEAKER_MIXER); + reg = snd_soc_component_read32(component, WM8990_SPEAKER_MIXER); if (reg & WM8990_LDSPK) { printk(KERN_WARNING "Cannot set as Speaker Mixer LDSPK Set\n"); @@ -405,7 +405,7 @@ static int outmixer_event(struct snd_soc_dapm_widget *w, } break; case WM8990_OUTPUT_MIXER2 | (WM8990_RDRO_BIT << 8): - reg = snd_soc_read(codec, WM8990_SPEAKER_MIXER); + reg = snd_soc_component_read32(component, WM8990_SPEAKER_MIXER); if (reg & WM8990_RDSPK) { printk(KERN_WARNING "Cannot set as Speaker Mixer RDSPK Set\n"); @@ -934,28 +934,28 @@ static void pll_factors(struct _pll_div *pll_div, unsigned int target, static int wm8990_set_dai_pll(struct snd_soc_dai *codec_dai, int pll_id, int source, unsigned int freq_in, unsigned int freq_out) { - struct snd_soc_codec *codec = codec_dai->codec; + struct snd_soc_component *component = codec_dai->component; struct _pll_div pll_div;
if (freq_in && freq_out) { pll_factors(&pll_div, freq_out * 4, freq_in);
/* Turn on PLL */ - snd_soc_update_bits(codec, WM8990_POWER_MANAGEMENT_2, + snd_soc_component_update_bits(component, WM8990_POWER_MANAGEMENT_2, WM8990_PLL_ENA, WM8990_PLL_ENA);
/* sysclk comes from PLL */ - snd_soc_update_bits(codec, WM8990_CLOCKING_2, + snd_soc_component_update_bits(component, WM8990_CLOCKING_2, WM8990_SYSCLK_SRC, WM8990_SYSCLK_SRC);
/* set up N , fractional mode and pre-divisor if necessary */ - snd_soc_write(codec, WM8990_PLL1, pll_div.n | WM8990_SDM | + snd_soc_component_write(component, WM8990_PLL1, pll_div.n | WM8990_SDM | (pll_div.div2?WM8990_PRESCALE:0)); - snd_soc_write(codec, WM8990_PLL2, (u8)(pll_div.k>>8)); - snd_soc_write(codec, WM8990_PLL3, (u8)(pll_div.k & 0xFF)); + snd_soc_component_write(component, WM8990_PLL2, (u8)(pll_div.k>>8)); + snd_soc_component_write(component, WM8990_PLL3, (u8)(pll_div.k & 0xFF)); } else { /* Turn off PLL */ - snd_soc_update_bits(codec, WM8990_POWER_MANAGEMENT_2, + snd_soc_component_update_bits(component, WM8990_POWER_MANAGEMENT_2, WM8990_PLL_ENA, 0); } return 0; @@ -967,8 +967,8 @@ static int wm8990_set_dai_pll(struct snd_soc_dai *codec_dai, int pll_id, static int wm8990_set_dai_sysclk(struct snd_soc_dai *codec_dai, int clk_id, unsigned int freq, int dir) { - struct snd_soc_codec *codec = codec_dai->codec; - struct wm8990_priv *wm8990 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = codec_dai->component; + struct wm8990_priv *wm8990 = snd_soc_component_get_drvdata(component);
wm8990->sysclk = freq; return 0; @@ -980,11 +980,11 @@ static int wm8990_set_dai_sysclk(struct snd_soc_dai *codec_dai, static int wm8990_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt) { - struct snd_soc_codec *codec = codec_dai->codec; + struct snd_soc_component *component = codec_dai->component; u16 audio1, audio3;
- audio1 = snd_soc_read(codec, WM8990_AUDIO_INTERFACE_1); - audio3 = snd_soc_read(codec, WM8990_AUDIO_INTERFACE_3); + audio1 = snd_soc_component_read32(component, WM8990_AUDIO_INTERFACE_1); + audio3 = snd_soc_component_read32(component, WM8990_AUDIO_INTERFACE_3);
/* set master/slave audio interface */ switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { @@ -1025,31 +1025,31 @@ static int wm8990_set_dai_fmt(struct snd_soc_dai *codec_dai, return -EINVAL; }
- snd_soc_write(codec, WM8990_AUDIO_INTERFACE_1, audio1); - snd_soc_write(codec, WM8990_AUDIO_INTERFACE_3, audio3); + snd_soc_component_write(component, WM8990_AUDIO_INTERFACE_1, audio1); + snd_soc_component_write(component, WM8990_AUDIO_INTERFACE_3, audio3); return 0; }
static int wm8990_set_dai_clkdiv(struct snd_soc_dai *codec_dai, int div_id, int div) { - struct snd_soc_codec *codec = codec_dai->codec; + struct snd_soc_component *component = codec_dai->component;
switch (div_id) { case WM8990_MCLK_DIV: - snd_soc_update_bits(codec, WM8990_CLOCKING_2, + snd_soc_component_update_bits(component, WM8990_CLOCKING_2, WM8990_MCLK_DIV_MASK, div); break; case WM8990_DACCLK_DIV: - snd_soc_update_bits(codec, WM8990_CLOCKING_2, + snd_soc_component_update_bits(component, WM8990_CLOCKING_2, WM8990_DAC_CLKDIV_MASK, div); break; case WM8990_ADCCLK_DIV: - snd_soc_update_bits(codec, WM8990_CLOCKING_2, + snd_soc_component_update_bits(component, WM8990_CLOCKING_2, WM8990_ADC_CLKDIV_MASK, div); break; case WM8990_BCLK_DIV: - snd_soc_update_bits(codec, WM8990_CLOCKING_1, + snd_soc_component_update_bits(component, WM8990_CLOCKING_1, WM8990_BCLK_DIV_MASK, div); break; default: @@ -1066,8 +1066,8 @@ static int wm8990_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; - u16 audio1 = snd_soc_read(codec, WM8990_AUDIO_INTERFACE_1); + struct snd_soc_component *component = dai->component; + u16 audio1 = snd_soc_component_read32(component, WM8990_AUDIO_INTERFACE_1);
audio1 &= ~WM8990_AIF_WL_MASK; /* bit size */ @@ -1085,29 +1085,29 @@ static int wm8990_hw_params(struct snd_pcm_substream *substream, break; }
- snd_soc_write(codec, WM8990_AUDIO_INTERFACE_1, audio1); + snd_soc_component_write(component, WM8990_AUDIO_INTERFACE_1, audio1); return 0; }
static int wm8990_mute(struct snd_soc_dai *dai, int mute) { - struct snd_soc_codec *codec = dai->codec; + struct snd_soc_component *component = dai->component; u16 val;
- val = snd_soc_read(codec, WM8990_DAC_CTRL) & ~WM8990_DAC_MUTE; + val = snd_soc_component_read32(component, WM8990_DAC_CTRL) & ~WM8990_DAC_MUTE;
if (mute) - snd_soc_write(codec, WM8990_DAC_CTRL, val | WM8990_DAC_MUTE); + snd_soc_component_write(component, WM8990_DAC_CTRL, val | WM8990_DAC_MUTE); else - snd_soc_write(codec, WM8990_DAC_CTRL, val); + snd_soc_component_write(component, WM8990_DAC_CTRL, val);
return 0; }
-static int wm8990_set_bias_level(struct snd_soc_codec *codec, +static int wm8990_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { - struct wm8990_priv *wm8990 = snd_soc_codec_get_drvdata(codec); + struct wm8990_priv *wm8990 = snd_soc_component_get_drvdata(component); int ret;
switch (level) { @@ -1116,26 +1116,26 @@ static int wm8990_set_bias_level(struct snd_soc_codec *codec,
case SND_SOC_BIAS_PREPARE: /* VMID=2*50k */ - snd_soc_update_bits(codec, WM8990_POWER_MANAGEMENT_1, + snd_soc_component_update_bits(component, WM8990_POWER_MANAGEMENT_1, WM8990_VMID_MODE_MASK, 0x2); break;
case SND_SOC_BIAS_STANDBY: - if (snd_soc_codec_get_bias_level(codec) == SND_SOC_BIAS_OFF) { + if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_OFF) { ret = regcache_sync(wm8990->regmap); if (ret < 0) { - dev_err(codec->dev, "Failed to sync cache: %d\n", ret); + dev_err(component->dev, "Failed to sync cache: %d\n", ret); return ret; }
/* Enable all output discharge bits */ - snd_soc_write(codec, WM8990_ANTIPOP1, WM8990_DIS_LLINE | + snd_soc_component_write(component, WM8990_ANTIPOP1, WM8990_DIS_LLINE | WM8990_DIS_RLINE | WM8990_DIS_OUT3 | WM8990_DIS_OUT4 | WM8990_DIS_LOUT | WM8990_DIS_ROUT);
/* Enable POBCTRL, SOFT_ST, VMIDTOG and BUFDCOPEN */ - snd_soc_write(codec, WM8990_ANTIPOP2, WM8990_SOFTST | + snd_soc_component_write(component, WM8990_ANTIPOP2, WM8990_SOFTST | WM8990_BUFDCOPEN | WM8990_POBCTRL | WM8990_VMIDTOG);
@@ -1143,82 +1143,82 @@ static int wm8990_set_bias_level(struct snd_soc_codec *codec, msleep(300);
/* Disable VMIDTOG */ - snd_soc_write(codec, WM8990_ANTIPOP2, WM8990_SOFTST | + snd_soc_component_write(component, WM8990_ANTIPOP2, WM8990_SOFTST | WM8990_BUFDCOPEN | WM8990_POBCTRL);
/* disable all output discharge bits */ - snd_soc_write(codec, WM8990_ANTIPOP1, 0); + snd_soc_component_write(component, WM8990_ANTIPOP1, 0);
/* Enable outputs */ - snd_soc_write(codec, WM8990_POWER_MANAGEMENT_1, 0x1b00); + snd_soc_component_write(component, WM8990_POWER_MANAGEMENT_1, 0x1b00);
msleep(50);
/* Enable VMID at 2x50k */ - snd_soc_write(codec, WM8990_POWER_MANAGEMENT_1, 0x1f02); + snd_soc_component_write(component, WM8990_POWER_MANAGEMENT_1, 0x1f02);
msleep(100);
/* Enable VREF */ - snd_soc_write(codec, WM8990_POWER_MANAGEMENT_1, 0x1f03); + snd_soc_component_write(component, WM8990_POWER_MANAGEMENT_1, 0x1f03);
msleep(600);
/* Enable BUFIOEN */ - snd_soc_write(codec, WM8990_ANTIPOP2, WM8990_SOFTST | + snd_soc_component_write(component, WM8990_ANTIPOP2, WM8990_SOFTST | WM8990_BUFDCOPEN | WM8990_POBCTRL | WM8990_BUFIOEN);
/* Disable outputs */ - snd_soc_write(codec, WM8990_POWER_MANAGEMENT_1, 0x3); + snd_soc_component_write(component, WM8990_POWER_MANAGEMENT_1, 0x3);
/* disable POBCTRL, SOFT_ST and BUFDCOPEN */ - snd_soc_write(codec, WM8990_ANTIPOP2, WM8990_BUFIOEN); + snd_soc_component_write(component, WM8990_ANTIPOP2, WM8990_BUFIOEN);
/* Enable workaround for ADC clocking issue. */ - snd_soc_write(codec, WM8990_EXT_ACCESS_ENA, 0x2); - snd_soc_write(codec, WM8990_EXT_CTL1, 0xa003); - snd_soc_write(codec, WM8990_EXT_ACCESS_ENA, 0); + snd_soc_component_write(component, WM8990_EXT_ACCESS_ENA, 0x2); + snd_soc_component_write(component, WM8990_EXT_CTL1, 0xa003); + snd_soc_component_write(component, WM8990_EXT_ACCESS_ENA, 0); }
/* VMID=2*250k */ - snd_soc_update_bits(codec, WM8990_POWER_MANAGEMENT_1, + snd_soc_component_update_bits(component, WM8990_POWER_MANAGEMENT_1, WM8990_VMID_MODE_MASK, 0x4); break;
case SND_SOC_BIAS_OFF: /* Enable POBCTRL and SOFT_ST */ - snd_soc_write(codec, WM8990_ANTIPOP2, WM8990_SOFTST | + snd_soc_component_write(component, WM8990_ANTIPOP2, WM8990_SOFTST | WM8990_POBCTRL | WM8990_BUFIOEN);
/* Enable POBCTRL, SOFT_ST and BUFDCOPEN */ - snd_soc_write(codec, WM8990_ANTIPOP2, WM8990_SOFTST | + snd_soc_component_write(component, WM8990_ANTIPOP2, WM8990_SOFTST | WM8990_BUFDCOPEN | WM8990_POBCTRL | WM8990_BUFIOEN);
/* mute DAC */ - snd_soc_update_bits(codec, WM8990_DAC_CTRL, + snd_soc_component_update_bits(component, WM8990_DAC_CTRL, WM8990_DAC_MUTE, WM8990_DAC_MUTE);
/* Enable any disabled outputs */ - snd_soc_write(codec, WM8990_POWER_MANAGEMENT_1, 0x1f03); + snd_soc_component_write(component, WM8990_POWER_MANAGEMENT_1, 0x1f03);
/* Disable VMID */ - snd_soc_write(codec, WM8990_POWER_MANAGEMENT_1, 0x1f01); + snd_soc_component_write(component, WM8990_POWER_MANAGEMENT_1, 0x1f01);
msleep(300);
/* Enable all output discharge bits */ - snd_soc_write(codec, WM8990_ANTIPOP1, WM8990_DIS_LLINE | + snd_soc_component_write(component, WM8990_ANTIPOP1, WM8990_DIS_LLINE | WM8990_DIS_RLINE | WM8990_DIS_OUT3 | WM8990_DIS_OUT4 | WM8990_DIS_LOUT | WM8990_DIS_ROUT);
/* Disable VREF */ - snd_soc_write(codec, WM8990_POWER_MANAGEMENT_1, 0x0); + snd_soc_component_write(component, WM8990_POWER_MANAGEMENT_1, 0x0);
/* disable POBCTRL, SOFT_ST and BUFDCOPEN */ - snd_soc_write(codec, WM8990_ANTIPOP2, 0x0); + snd_soc_component_write(component, WM8990_ANTIPOP2, 0x0);
regcache_mark_dirty(wm8990->regmap); break; @@ -1272,41 +1272,42 @@ static int wm8990_set_bias_level(struct snd_soc_codec *codec, * initialise the WM8990 driver * register the mixer and dsp interfaces with the kernel */ -static int wm8990_probe(struct snd_soc_codec *codec) +static int wm8990_probe(struct snd_soc_component *component) { - wm8990_reset(codec); + wm8990_reset(component);
/* charge output caps */ - snd_soc_codec_force_bias_level(codec, SND_SOC_BIAS_STANDBY); + snd_soc_component_force_bias_level(component, SND_SOC_BIAS_STANDBY);
- snd_soc_update_bits(codec, WM8990_AUDIO_INTERFACE_4, + snd_soc_component_update_bits(component, WM8990_AUDIO_INTERFACE_4, WM8990_ALRCGPIO1, WM8990_ALRCGPIO1);
- snd_soc_update_bits(codec, WM8990_GPIO1_GPIO2, + snd_soc_component_update_bits(component, WM8990_GPIO1_GPIO2, WM8990_GPIO1_SEL_MASK, 1);
- snd_soc_update_bits(codec, WM8990_POWER_MANAGEMENT_2, + snd_soc_component_update_bits(component, WM8990_POWER_MANAGEMENT_2, WM8990_OPCLK_ENA, WM8990_OPCLK_ENA);
- snd_soc_write(codec, WM8990_LEFT_OUTPUT_VOLUME, 0x50 | (1<<8)); - snd_soc_write(codec, WM8990_RIGHT_OUTPUT_VOLUME, 0x50 | (1<<8)); + snd_soc_component_write(component, WM8990_LEFT_OUTPUT_VOLUME, 0x50 | (1<<8)); + snd_soc_component_write(component, WM8990_RIGHT_OUTPUT_VOLUME, 0x50 | (1<<8));
return 0; }
-static const struct snd_soc_codec_driver soc_codec_dev_wm8990 = { - .probe = wm8990_probe, - .set_bias_level = wm8990_set_bias_level, - .suspend_bias_off = true, - - .component_driver = { - .controls = wm8990_snd_controls, - .num_controls = ARRAY_SIZE(wm8990_snd_controls), - .dapm_widgets = wm8990_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(wm8990_dapm_widgets), - .dapm_routes = wm8990_dapm_routes, - .num_dapm_routes = ARRAY_SIZE(wm8990_dapm_routes), - }, +static const struct snd_soc_component_driver soc_component_dev_wm8990 = { + .probe = wm8990_probe, + .set_bias_level = wm8990_set_bias_level, + .controls = wm8990_snd_controls, + .num_controls = ARRAY_SIZE(wm8990_snd_controls), + .dapm_widgets = wm8990_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(wm8990_dapm_widgets), + .dapm_routes = wm8990_dapm_routes, + .num_dapm_routes = ARRAY_SIZE(wm8990_dapm_routes), + .suspend_bias_off = 1, + .idle_bias_on = 1, + .pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, };
static const struct regmap_config wm8990_regmap = { @@ -1333,19 +1334,12 @@ static int wm8990_i2c_probe(struct i2c_client *i2c,
i2c_set_clientdata(i2c, wm8990);
- ret = snd_soc_register_codec(&i2c->dev, - &soc_codec_dev_wm8990, &wm8990_dai, 1); + ret = devm_snd_soc_register_component(&i2c->dev, + &soc_component_dev_wm8990, &wm8990_dai, 1);
return ret; }
-static int wm8990_i2c_remove(struct i2c_client *client) -{ - snd_soc_unregister_codec(&client->dev); - - return 0; -} - static const struct i2c_device_id wm8990_i2c_id[] = { { "wm8990", 0 }, { } @@ -1357,7 +1351,6 @@ static int wm8990_i2c_remove(struct i2c_client *client) .name = "wm8990", }, .probe = wm8990_i2c_probe, - .remove = wm8990_i2c_remove, .id_table = wm8990_i2c_id, };
From: Kuninori Morimoto kuninori.morimoto.gx@renesas.com
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 -> .pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com --- sound/soc/codecs/wm8988.c | 127 +++++++++++++++++++++------------------------- 1 file changed, 57 insertions(+), 70 deletions(-)
diff --git a/sound/soc/codecs/wm8988.c b/sound/soc/codecs/wm8988.c index b0d0219..65f602d 100644 --- a/sound/soc/codecs/wm8988.c +++ b/sound/soc/codecs/wm8988.c @@ -119,7 +119,7 @@ struct wm8988_priv { const struct snd_pcm_hw_constraint_list *sysclk_constraints; };
-#define wm8988_reset(c) snd_soc_write(c, WM8988_RESET, 0) +#define wm8988_reset(c) snd_soc_component_write(c, WM8988_RESET, 0)
/* * WM8988 Controls @@ -244,16 +244,16 @@ static SOC_ENUM_SINGLE_DECL(adcpol, static int wm8988_lrc_control(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); - u16 adctl2 = snd_soc_read(codec, WM8988_ADCTL2); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); + u16 adctl2 = snd_soc_component_read32(component, WM8988_ADCTL2);
/* Use the DAC to gate LRC if active, otherwise use ADC */ - if (snd_soc_read(codec, WM8988_PWR2) & 0x180) + if (snd_soc_component_read32(component, WM8988_PWR2) & 0x180) adctl2 &= ~0x4; else adctl2 |= 0x4;
- return snd_soc_write(codec, WM8988_ADCTL2, adctl2); + return snd_soc_component_write(component, WM8988_ADCTL2, adctl2); }
static const char *wm8988_line_texts[] = { @@ -555,8 +555,8 @@ static inline int get_coeff(int mclk, int rate) static int wm8988_set_dai_sysclk(struct snd_soc_dai *codec_dai, int clk_id, unsigned int freq, int dir) { - struct snd_soc_codec *codec = codec_dai->codec; - struct wm8988_priv *wm8988 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = codec_dai->component; + struct wm8988_priv *wm8988 = snd_soc_component_get_drvdata(component);
switch (freq) { case 11289600: @@ -587,7 +587,7 @@ static int wm8988_set_dai_sysclk(struct snd_soc_dai *codec_dai, static int wm8988_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt) { - struct snd_soc_codec *codec = codec_dai->codec; + struct snd_soc_component *component = codec_dai->component; u16 iface = 0;
/* set master/slave audio interface */ @@ -638,21 +638,21 @@ static int wm8988_set_dai_fmt(struct snd_soc_dai *codec_dai, return -EINVAL; }
- snd_soc_write(codec, WM8988_IFACE, iface); + snd_soc_component_write(component, WM8988_IFACE, iface); return 0; }
static int wm8988_pcm_startup(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; - struct wm8988_priv *wm8988 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct wm8988_priv *wm8988 = snd_soc_component_get_drvdata(component);
/* The set of sample rates that can be supported depends on the * MCLK supplied to the CODEC - enforce this. */ if (!wm8988->sysclk) { - dev_err(codec->dev, + dev_err(component->dev, "No MCLK configured, call set_sysclk() on init\n"); return -EINVAL; } @@ -668,10 +668,10 @@ static int wm8988_pcm_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; - struct wm8988_priv *wm8988 = snd_soc_codec_get_drvdata(codec); - u16 iface = snd_soc_read(codec, WM8988_IFACE) & 0x1f3; - u16 srate = snd_soc_read(codec, WM8988_SRATE) & 0x180; + struct snd_soc_component *component = dai->component; + struct wm8988_priv *wm8988 = snd_soc_component_get_drvdata(component); + u16 iface = snd_soc_component_read32(component, WM8988_IFACE) & 0x1f3; + u16 srate = snd_soc_component_read32(component, WM8988_SRATE) & 0x180; int coeff;
coeff = get_coeff(wm8988->sysclk, params_rate(params)); @@ -680,7 +680,7 @@ static int wm8988_pcm_hw_params(struct snd_pcm_substream *substream, srate |= 0x40; } if (coeff < 0) { - dev_err(codec->dev, + dev_err(component->dev, "Unable to configure sample rate %dHz with %dHz MCLK\n", params_rate(params), wm8988->sysclk); return coeff; @@ -702,9 +702,9 @@ static int wm8988_pcm_hw_params(struct snd_pcm_substream *substream, }
/* set iface & srate */ - snd_soc_write(codec, WM8988_IFACE, iface); + snd_soc_component_write(component, WM8988_IFACE, iface); if (coeff >= 0) - snd_soc_write(codec, WM8988_SRATE, srate | + snd_soc_component_write(component, WM8988_SRATE, srate | (coeff_div[coeff].sr << 1) | coeff_div[coeff].usb);
return 0; @@ -712,21 +712,21 @@ static int wm8988_pcm_hw_params(struct snd_pcm_substream *substream,
static int wm8988_mute(struct snd_soc_dai *dai, int mute) { - struct snd_soc_codec *codec = dai->codec; - u16 mute_reg = snd_soc_read(codec, WM8988_ADCDAC) & 0xfff7; + struct snd_soc_component *component = dai->component; + u16 mute_reg = snd_soc_component_read32(component, WM8988_ADCDAC) & 0xfff7;
if (mute) - snd_soc_write(codec, WM8988_ADCDAC, mute_reg | 0x8); + snd_soc_component_write(component, WM8988_ADCDAC, mute_reg | 0x8); else - snd_soc_write(codec, WM8988_ADCDAC, mute_reg); + snd_soc_component_write(component, WM8988_ADCDAC, mute_reg); return 0; }
-static int wm8988_set_bias_level(struct snd_soc_codec *codec, +static int wm8988_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { - struct wm8988_priv *wm8988 = snd_soc_codec_get_drvdata(codec); - u16 pwr_reg = snd_soc_read(codec, WM8988_PWR1) & ~0x1c1; + struct wm8988_priv *wm8988 = snd_soc_component_get_drvdata(component); + u16 pwr_reg = snd_soc_component_read32(component, WM8988_PWR1) & ~0x1c1;
switch (level) { case SND_SOC_BIAS_ON: @@ -734,26 +734,26 @@ static int wm8988_set_bias_level(struct snd_soc_codec *codec,
case SND_SOC_BIAS_PREPARE: /* VREF, VMID=2x50k, digital enabled */ - snd_soc_write(codec, WM8988_PWR1, pwr_reg | 0x00c0); + snd_soc_component_write(component, WM8988_PWR1, pwr_reg | 0x00c0); break;
case SND_SOC_BIAS_STANDBY: - if (snd_soc_codec_get_bias_level(codec) == SND_SOC_BIAS_OFF) { + if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_OFF) { regcache_sync(wm8988->regmap);
/* VREF, VMID=2x5k */ - snd_soc_write(codec, WM8988_PWR1, pwr_reg | 0x1c1); + snd_soc_component_write(component, WM8988_PWR1, pwr_reg | 0x1c1);
/* Charge caps */ msleep(100); }
/* VREF, VMID=2*500k, digital stopped */ - snd_soc_write(codec, WM8988_PWR1, pwr_reg | 0x0141); + snd_soc_component_write(component, WM8988_PWR1, pwr_reg | 0x0141); break;
case SND_SOC_BIAS_OFF: - snd_soc_write(codec, WM8988_PWR1, 0x0000); + snd_soc_component_write(component, WM8988_PWR1, 0x0000); break; } return 0; @@ -792,39 +792,40 @@ static int wm8988_set_bias_level(struct snd_soc_codec *codec, .symmetric_rates = 1, };
-static int wm8988_probe(struct snd_soc_codec *codec) +static int wm8988_probe(struct snd_soc_component *component) { int ret = 0;
- ret = wm8988_reset(codec); + ret = wm8988_reset(component); if (ret < 0) { - dev_err(codec->dev, "Failed to issue reset\n"); + dev_err(component->dev, "Failed to issue reset\n"); return ret; }
/* set the update bits (we always update left then right) */ - snd_soc_update_bits(codec, WM8988_RADC, 0x0100, 0x0100); - snd_soc_update_bits(codec, WM8988_RDAC, 0x0100, 0x0100); - snd_soc_update_bits(codec, WM8988_ROUT1V, 0x0100, 0x0100); - snd_soc_update_bits(codec, WM8988_ROUT2V, 0x0100, 0x0100); - snd_soc_update_bits(codec, WM8988_RINVOL, 0x0100, 0x0100); + snd_soc_component_update_bits(component, WM8988_RADC, 0x0100, 0x0100); + snd_soc_component_update_bits(component, WM8988_RDAC, 0x0100, 0x0100); + snd_soc_component_update_bits(component, WM8988_ROUT1V, 0x0100, 0x0100); + snd_soc_component_update_bits(component, WM8988_ROUT2V, 0x0100, 0x0100); + snd_soc_component_update_bits(component, WM8988_RINVOL, 0x0100, 0x0100);
return 0; }
-static const struct snd_soc_codec_driver soc_codec_dev_wm8988 = { - .probe = wm8988_probe, - .set_bias_level = wm8988_set_bias_level, - .suspend_bias_off = true, - - .component_driver = { - .controls = wm8988_snd_controls, - .num_controls = ARRAY_SIZE(wm8988_snd_controls), - .dapm_widgets = wm8988_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(wm8988_dapm_widgets), - .dapm_routes = wm8988_dapm_routes, - .num_dapm_routes = ARRAY_SIZE(wm8988_dapm_routes), - }, +static const struct snd_soc_component_driver soc_component_dev_wm8988 = { + .probe = wm8988_probe, + .set_bias_level = wm8988_set_bias_level, + .controls = wm8988_snd_controls, + .num_controls = ARRAY_SIZE(wm8988_snd_controls), + .dapm_widgets = wm8988_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(wm8988_dapm_widgets), + .dapm_routes = wm8988_dapm_routes, + .num_dapm_routes = ARRAY_SIZE(wm8988_dapm_routes), + .suspend_bias_off = 1, + .idle_bias_on = 1, + .pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, };
static const struct regmap_config wm8988_regmap = { @@ -859,23 +860,16 @@ static int wm8988_spi_probe(struct spi_device *spi)
spi_set_drvdata(spi, wm8988);
- ret = snd_soc_register_codec(&spi->dev, - &soc_codec_dev_wm8988, &wm8988_dai, 1); + ret = devm_snd_soc_register_component(&spi->dev, + &soc_component_dev_wm8988, &wm8988_dai, 1); return ret; }
-static int wm8988_spi_remove(struct spi_device *spi) -{ - snd_soc_unregister_codec(&spi->dev); - return 0; -} - static struct spi_driver wm8988_spi_driver = { .driver = { .name = "wm8988", }, .probe = wm8988_spi_probe, - .remove = wm8988_spi_remove, }; #endif /* CONFIG_SPI_MASTER */
@@ -900,17 +894,11 @@ static int wm8988_i2c_probe(struct i2c_client *i2c, return ret; }
- ret = snd_soc_register_codec(&i2c->dev, - &soc_codec_dev_wm8988, &wm8988_dai, 1); + ret = devm_snd_soc_register_component(&i2c->dev, + &soc_component_dev_wm8988, &wm8988_dai, 1); return ret; }
-static int wm8988_i2c_remove(struct i2c_client *client) -{ - snd_soc_unregister_codec(&client->dev); - return 0; -} - static const struct i2c_device_id wm8988_i2c_id[] = { { "wm8988", 0 }, { } @@ -922,7 +910,6 @@ static int wm8988_i2c_remove(struct i2c_client *client) .name = "wm8988", }, .probe = wm8988_i2c_probe, - .remove = wm8988_i2c_remove, .id_table = wm8988_i2c_id, }; #endif
From: Kuninori Morimoto kuninori.morimoto.gx@renesas.com
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 -> .pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com --- sound/soc/codecs/wm8983.c | 170 +++++++++++++++++++++------------------------- 1 file changed, 79 insertions(+), 91 deletions(-)
diff --git a/sound/soc/codecs/wm8983.c b/sound/soc/codecs/wm8983.c index bfdbe72..5d62de6 100644 --- a/sound/soc/codecs/wm8983.c +++ b/sound/soc/codecs/wm8983.c @@ -492,10 +492,10 @@ static SOC_ENUM_SINGLE_DECL(depth_3d, WM8983_3D_CONTROL, 0, static int eqmode_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); unsigned int reg;
- reg = snd_soc_read(codec, WM8983_EQ1_LOW_SHELF); + reg = snd_soc_component_read32(component, WM8983_EQ1_LOW_SHELF); if (reg & WM8983_EQ3DMODE) ucontrol->value.enumerated.item[0] = 1; else @@ -507,7 +507,7 @@ static int eqmode_get(struct snd_kcontrol *kcontrol, static int eqmode_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); unsigned int regpwr2, regpwr3; unsigned int reg_eq;
@@ -515,7 +515,7 @@ static int eqmode_put(struct snd_kcontrol *kcontrol, && ucontrol->value.enumerated.item[0] != 1) return -EINVAL;
- reg_eq = snd_soc_read(codec, WM8983_EQ1_LOW_SHELF); + reg_eq = snd_soc_component_read32(component, WM8983_EQ1_LOW_SHELF); switch ((reg_eq & WM8983_EQ3DMODE) >> WM8983_EQ3DMODE_SHIFT) { case 0: if (!ucontrol->value.enumerated.item[0]) @@ -527,21 +527,21 @@ static int eqmode_put(struct snd_kcontrol *kcontrol, break; }
- regpwr2 = snd_soc_read(codec, WM8983_POWER_MANAGEMENT_2); - regpwr3 = snd_soc_read(codec, WM8983_POWER_MANAGEMENT_3); + regpwr2 = snd_soc_component_read32(component, WM8983_POWER_MANAGEMENT_2); + regpwr3 = snd_soc_component_read32(component, WM8983_POWER_MANAGEMENT_3); /* disable the DACs and ADCs */ - snd_soc_update_bits(codec, WM8983_POWER_MANAGEMENT_2, + snd_soc_component_update_bits(component, WM8983_POWER_MANAGEMENT_2, WM8983_ADCENR_MASK | WM8983_ADCENL_MASK, 0); - snd_soc_update_bits(codec, WM8983_POWER_MANAGEMENT_3, + snd_soc_component_update_bits(component, WM8983_POWER_MANAGEMENT_3, WM8983_DACENR_MASK | WM8983_DACENL_MASK, 0); /* set the desired eqmode */ - snd_soc_update_bits(codec, WM8983_EQ1_LOW_SHELF, + snd_soc_component_update_bits(component, WM8983_EQ1_LOW_SHELF, WM8983_EQ3DMODE_MASK, ucontrol->value.enumerated.item[0] << WM8983_EQ3DMODE_SHIFT); /* restore DAC/ADC configuration */ - snd_soc_write(codec, WM8983_POWER_MANAGEMENT_2, regpwr2); - snd_soc_write(codec, WM8983_POWER_MANAGEMENT_3, regpwr3); + snd_soc_component_write(component, WM8983_POWER_MANAGEMENT_2, regpwr2); + snd_soc_component_write(component, WM8983_POWER_MANAGEMENT_3, regpwr3); return 0; }
@@ -562,16 +562,16 @@ static bool wm8983_writeable(struct device *dev, unsigned int reg)
static int wm8983_dac_mute(struct snd_soc_dai *dai, int mute) { - struct snd_soc_codec *codec = dai->codec; + struct snd_soc_component *component = dai->component;
- return snd_soc_update_bits(codec, WM8983_DAC_CONTROL, + return snd_soc_component_update_bits(component, WM8983_DAC_CONTROL, WM8983_SOFTMUTE_MASK, !!mute << WM8983_SOFTMUTE_SHIFT); }
static int wm8983_set_fmt(struct snd_soc_dai *dai, unsigned int fmt) { - struct snd_soc_codec *codec = dai->codec; + struct snd_soc_component *component = dai->component; u16 format, master, bcp, lrp;
switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) { @@ -593,7 +593,7 @@ static int wm8983_set_fmt(struct snd_soc_dai *dai, unsigned int fmt) return -EINVAL; }
- snd_soc_update_bits(codec, WM8983_AUDIO_INTERFACE, + snd_soc_component_update_bits(component, WM8983_AUDIO_INTERFACE, WM8983_FMT_MASK, format << WM8983_FMT_SHIFT);
switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { @@ -608,7 +608,7 @@ static int wm8983_set_fmt(struct snd_soc_dai *dai, unsigned int fmt) return -EINVAL; }
- snd_soc_update_bits(codec, WM8983_CLOCK_GEN_CONTROL, + snd_soc_component_update_bits(component, WM8983_CLOCK_GEN_CONTROL, WM8983_MS_MASK, master << WM8983_MS_SHIFT);
/* FIXME: We don't currently support DSP A/B modes */ @@ -639,9 +639,9 @@ static int wm8983_set_fmt(struct snd_soc_dai *dai, unsigned int fmt) return -EINVAL; }
- snd_soc_update_bits(codec, WM8983_AUDIO_INTERFACE, + snd_soc_component_update_bits(component, WM8983_AUDIO_INTERFACE, WM8983_LRCP_MASK, lrp << WM8983_LRCP_SHIFT); - snd_soc_update_bits(codec, WM8983_AUDIO_INTERFACE, + snd_soc_component_update_bits(component, WM8983_AUDIO_INTERFACE, WM8983_BCP_MASK, bcp << WM8983_BCP_SHIFT); return 0; } @@ -651,8 +651,8 @@ static int wm8983_hw_params(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) { int i; - struct snd_soc_codec *codec = dai->codec; - struct wm8983_priv *wm8983 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct wm8983_priv *wm8983 = snd_soc_component_get_drvdata(component); u16 blen, srate_idx; u32 tmp; int srate_best; @@ -660,7 +660,7 @@ static int wm8983_hw_params(struct snd_pcm_substream *substream,
ret = snd_soc_params_to_bclk(params); if (ret < 0) { - dev_err(codec->dev, "Failed to convert params to bclk: %d\n", ret); + dev_err(component->dev, "Failed to convert params to bclk: %d\n", ret); return ret; }
@@ -685,7 +685,7 @@ static int wm8983_hw_params(struct snd_pcm_substream *substream, return -EINVAL; }
- snd_soc_update_bits(codec, WM8983_AUDIO_INTERFACE, + snd_soc_component_update_bits(component, WM8983_AUDIO_INTERFACE, WM8983_WL_MASK, blen << WM8983_WL_SHIFT);
/* @@ -702,7 +702,7 @@ static int wm8983_hw_params(struct snd_pcm_substream *substream, }
dev_dbg(dai->dev, "Selected SRATE = %d\n", srates[srate_idx]); - snd_soc_update_bits(codec, WM8983_ADDITIONAL_CONTROL, + snd_soc_component_update_bits(component, WM8983_ADDITIONAL_CONTROL, WM8983_SR_MASK, srate_idx << WM8983_SR_SHIFT);
dev_dbg(dai->dev, "Target BCLK = %uHz\n", wm8983->bclk); @@ -721,7 +721,7 @@ static int wm8983_hw_params(struct snd_pcm_substream *substream, }
dev_dbg(dai->dev, "MCLK ratio = %dfs\n", fs_ratios[i].ratio); - snd_soc_update_bits(codec, WM8983_CLOCK_GEN_CONTROL, + snd_soc_component_update_bits(component, WM8983_CLOCK_GEN_CONTROL, WM8983_MCLKDIV_MASK, i << WM8983_MCLKDIV_SHIFT);
/* select the appropriate bclk divider */ @@ -737,7 +737,7 @@ static int wm8983_hw_params(struct snd_pcm_substream *substream, }
dev_dbg(dai->dev, "BCLK div = %d\n", i); - snd_soc_update_bits(codec, WM8983_CLOCK_GEN_CONTROL, + snd_soc_component_update_bits(component, WM8983_CLOCK_GEN_CONTROL, WM8983_BCLKDIV_MASK, i << WM8983_BCLKDIV_SHIFT);
return 0; @@ -789,13 +789,13 @@ static int wm8983_set_pll(struct snd_soc_dai *dai, int pll_id, unsigned int freq_out) { int ret; - struct snd_soc_codec *codec; + struct snd_soc_component *component; struct pll_div pll_div;
- codec = dai->codec; + component = dai->component; if (!freq_in || !freq_out) { /* disable the PLL */ - snd_soc_update_bits(codec, WM8983_POWER_MANAGEMENT_1, + snd_soc_component_update_bits(component, WM8983_POWER_MANAGEMENT_1, WM8983_PLLEN_MASK, 0); return 0; } else { @@ -804,19 +804,19 @@ static int wm8983_set_pll(struct snd_soc_dai *dai, int pll_id, return ret;
/* disable the PLL before re-programming it */ - snd_soc_update_bits(codec, WM8983_POWER_MANAGEMENT_1, + snd_soc_component_update_bits(component, WM8983_POWER_MANAGEMENT_1, WM8983_PLLEN_MASK, 0);
/* set PLLN and PRESCALE */ - snd_soc_write(codec, WM8983_PLL_N, + snd_soc_component_write(component, WM8983_PLL_N, (pll_div.div2 << WM8983_PLL_PRESCALE_SHIFT) | pll_div.n); /* set PLLK */ - snd_soc_write(codec, WM8983_PLL_K_3, pll_div.k & 0x1ff); - snd_soc_write(codec, WM8983_PLL_K_2, (pll_div.k >> 9) & 0x1ff); - snd_soc_write(codec, WM8983_PLL_K_1, (pll_div.k >> 18)); + snd_soc_component_write(component, WM8983_PLL_K_3, pll_div.k & 0x1ff); + snd_soc_component_write(component, WM8983_PLL_K_2, (pll_div.k >> 9) & 0x1ff); + snd_soc_component_write(component, WM8983_PLL_K_1, (pll_div.k >> 18)); /* enable the PLL */ - snd_soc_update_bits(codec, WM8983_POWER_MANAGEMENT_1, + snd_soc_component_update_bits(component, WM8983_POWER_MANAGEMENT_1, WM8983_PLLEN_MASK, WM8983_PLLEN); }
@@ -826,16 +826,16 @@ static int wm8983_set_pll(struct snd_soc_dai *dai, int pll_id, static int wm8983_set_sysclk(struct snd_soc_dai *dai, int clk_id, unsigned int freq, int dir) { - struct snd_soc_codec *codec = dai->codec; - struct wm8983_priv *wm8983 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct wm8983_priv *wm8983 = snd_soc_component_get_drvdata(component);
switch (clk_id) { case WM8983_CLKSRC_MCLK: - snd_soc_update_bits(codec, WM8983_CLOCK_GEN_CONTROL, + snd_soc_component_update_bits(component, WM8983_CLOCK_GEN_CONTROL, WM8983_CLKSEL_MASK, 0); break; case WM8983_CLKSRC_PLL: - snd_soc_update_bits(codec, WM8983_CLOCK_GEN_CONTROL, + snd_soc_component_update_bits(component, WM8983_CLOCK_GEN_CONTROL, WM8983_CLKSEL_MASK, WM8983_CLKSEL); break; default: @@ -847,100 +847,100 @@ static int wm8983_set_sysclk(struct snd_soc_dai *dai, return 0; }
-static int wm8983_set_bias_level(struct snd_soc_codec *codec, +static int wm8983_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { - struct wm8983_priv *wm8983 = snd_soc_codec_get_drvdata(codec); + struct wm8983_priv *wm8983 = snd_soc_component_get_drvdata(component); int ret;
switch (level) { case SND_SOC_BIAS_ON: case SND_SOC_BIAS_PREPARE: /* VMID at 100k */ - snd_soc_update_bits(codec, WM8983_POWER_MANAGEMENT_1, + snd_soc_component_update_bits(component, WM8983_POWER_MANAGEMENT_1, WM8983_VMIDSEL_MASK, 1 << WM8983_VMIDSEL_SHIFT); break; case SND_SOC_BIAS_STANDBY: - if (snd_soc_codec_get_bias_level(codec) == SND_SOC_BIAS_OFF) { + if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_OFF) { ret = regcache_sync(wm8983->regmap); if (ret < 0) { - dev_err(codec->dev, "Failed to sync cache: %d\n", ret); + dev_err(component->dev, "Failed to sync cache: %d\n", ret); return ret; } /* enable anti-pop features */ - snd_soc_update_bits(codec, WM8983_OUT4_TO_ADC, + snd_soc_component_update_bits(component, WM8983_OUT4_TO_ADC, WM8983_POBCTRL_MASK | WM8983_DELEN_MASK, WM8983_POBCTRL | WM8983_DELEN); /* enable thermal shutdown */ - snd_soc_update_bits(codec, WM8983_OUTPUT_CTRL, + snd_soc_component_update_bits(component, WM8983_OUTPUT_CTRL, WM8983_TSDEN_MASK, WM8983_TSDEN); /* enable BIASEN */ - snd_soc_update_bits(codec, WM8983_POWER_MANAGEMENT_1, + snd_soc_component_update_bits(component, WM8983_POWER_MANAGEMENT_1, WM8983_BIASEN_MASK, WM8983_BIASEN); /* VMID at 100k */ - snd_soc_update_bits(codec, WM8983_POWER_MANAGEMENT_1, + snd_soc_component_update_bits(component, WM8983_POWER_MANAGEMENT_1, WM8983_VMIDSEL_MASK, 1 << WM8983_VMIDSEL_SHIFT); msleep(250); /* disable anti-pop features */ - snd_soc_update_bits(codec, WM8983_OUT4_TO_ADC, + snd_soc_component_update_bits(component, WM8983_OUT4_TO_ADC, WM8983_POBCTRL_MASK | WM8983_DELEN_MASK, 0); }
/* VMID at 500k */ - snd_soc_update_bits(codec, WM8983_POWER_MANAGEMENT_1, + snd_soc_component_update_bits(component, WM8983_POWER_MANAGEMENT_1, WM8983_VMIDSEL_MASK, 2 << WM8983_VMIDSEL_SHIFT); break; case SND_SOC_BIAS_OFF: /* disable thermal shutdown */ - snd_soc_update_bits(codec, WM8983_OUTPUT_CTRL, + snd_soc_component_update_bits(component, WM8983_OUTPUT_CTRL, WM8983_TSDEN_MASK, 0); /* disable VMIDSEL and BIASEN */ - snd_soc_update_bits(codec, WM8983_POWER_MANAGEMENT_1, + snd_soc_component_update_bits(component, WM8983_POWER_MANAGEMENT_1, WM8983_VMIDSEL_MASK | WM8983_BIASEN_MASK, 0); /* wait for VMID to discharge */ msleep(100); - snd_soc_write(codec, WM8983_POWER_MANAGEMENT_1, 0); - snd_soc_write(codec, WM8983_POWER_MANAGEMENT_2, 0); - snd_soc_write(codec, WM8983_POWER_MANAGEMENT_3, 0); + snd_soc_component_write(component, WM8983_POWER_MANAGEMENT_1, 0); + snd_soc_component_write(component, WM8983_POWER_MANAGEMENT_2, 0); + snd_soc_component_write(component, WM8983_POWER_MANAGEMENT_3, 0); break; }
return 0; }
-static int wm8983_probe(struct snd_soc_codec *codec) +static int wm8983_probe(struct snd_soc_component *component) { int ret; int i;
- ret = snd_soc_write(codec, WM8983_SOFTWARE_RESET, 0); + ret = snd_soc_component_write(component, WM8983_SOFTWARE_RESET, 0); if (ret < 0) { - dev_err(codec->dev, "Failed to issue reset: %d\n", ret); + dev_err(component->dev, "Failed to issue reset: %d\n", ret); return ret; }
/* set the vol/gain update bits */ for (i = 0; i < ARRAY_SIZE(vol_update_regs); ++i) - snd_soc_update_bits(codec, vol_update_regs[i], + snd_soc_component_update_bits(component, vol_update_regs[i], 0x100, 0x100);
/* mute all outputs and set PGAs to minimum gain */ for (i = WM8983_LOUT1_HP_VOLUME_CTRL; i <= WM8983_OUT4_MONO_MIX_CTRL; ++i) - snd_soc_update_bits(codec, i, 0x40, 0x40); + snd_soc_component_update_bits(component, i, 0x40, 0x40);
/* enable soft mute */ - snd_soc_update_bits(codec, WM8983_DAC_CONTROL, + snd_soc_component_update_bits(component, WM8983_DAC_CONTROL, WM8983_SOFTMUTE_MASK, WM8983_SOFTMUTE);
/* enable BIASCUT */ - snd_soc_update_bits(codec, WM8983_BIAS_CTRL, + snd_soc_component_update_bits(component, WM8983_BIAS_CTRL, WM8983_BIASCUT, WM8983_BIASCUT); return 0; } @@ -976,18 +976,20 @@ static int wm8983_probe(struct snd_soc_codec *codec) .symmetric_rates = 1 };
-static const struct snd_soc_codec_driver soc_codec_dev_wm8983 = { - .probe = wm8983_probe, - .set_bias_level = wm8983_set_bias_level, - .suspend_bias_off = true, - .component_driver = { - .controls = wm8983_snd_controls, - .num_controls = ARRAY_SIZE(wm8983_snd_controls), - .dapm_widgets = wm8983_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(wm8983_dapm_widgets), - .dapm_routes = wm8983_audio_map, - .num_dapm_routes = ARRAY_SIZE(wm8983_audio_map), - }, +static const struct snd_soc_component_driver soc_component_dev_wm8983 = { + .probe = wm8983_probe, + .set_bias_level = wm8983_set_bias_level, + .controls = wm8983_snd_controls, + .num_controls = ARRAY_SIZE(wm8983_snd_controls), + .dapm_widgets = wm8983_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(wm8983_dapm_widgets), + .dapm_routes = wm8983_audio_map, + .num_dapm_routes = ARRAY_SIZE(wm8983_audio_map), + .suspend_bias_off = 1, + .idle_bias_on = 1, + .pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, };
static const struct regmap_config wm8983_regmap = { @@ -1021,23 +1023,16 @@ static int wm8983_spi_probe(struct spi_device *spi)
spi_set_drvdata(spi, wm8983);
- ret = snd_soc_register_codec(&spi->dev, - &soc_codec_dev_wm8983, &wm8983_dai, 1); + ret = devm_snd_soc_register_component(&spi->dev, + &soc_component_dev_wm8983, &wm8983_dai, 1); return ret; }
-static int wm8983_spi_remove(struct spi_device *spi) -{ - snd_soc_unregister_codec(&spi->dev); - return 0; -} - static struct spi_driver wm8983_spi_driver = { .driver = { .name = "wm8983", }, .probe = wm8983_spi_probe, - .remove = wm8983_spi_remove }; #endif
@@ -1061,18 +1056,12 @@ static int wm8983_i2c_probe(struct i2c_client *i2c,
i2c_set_clientdata(i2c, wm8983);
- ret = snd_soc_register_codec(&i2c->dev, - &soc_codec_dev_wm8983, &wm8983_dai, 1); + ret = devm_snd_soc_register_component(&i2c->dev, + &soc_component_dev_wm8983, &wm8983_dai, 1);
return ret; }
-static int wm8983_i2c_remove(struct i2c_client *client) -{ - snd_soc_unregister_codec(&client->dev); - return 0; -} - static const struct i2c_device_id wm8983_i2c_id[] = { { "wm8983", 0 }, { } @@ -1084,7 +1073,6 @@ static int wm8983_i2c_remove(struct i2c_client *client) .name = "wm8983", }, .probe = wm8983_i2c_probe, - .remove = wm8983_i2c_remove, .id_table = wm8983_i2c_id }; #endif
From: Kuninori Morimoto kuninori.morimoto.gx@renesas.com
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 -> .pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com --- sound/soc/codecs/wm8962.c | 397 +++++++++++++++++++++--------------------- sound/soc/codecs/wm8962.h | 2 +- sound/soc/samsung/tobermory.c | 6 +- 3 files changed, 202 insertions(+), 203 deletions(-)
diff --git a/sound/soc/codecs/wm8962.c b/sound/soc/codecs/wm8962.c index fd2731d..05b0fc2 100644 --- a/sound/soc/codecs/wm8962.c +++ b/sound/soc/codecs/wm8962.c @@ -55,7 +55,7 @@ struct wm8962_priv { struct wm8962_pdata pdata; struct regmap *regmap; - struct snd_soc_codec *codec; + struct snd_soc_component *component;
int sysclk; int sysclk_rate; @@ -1475,55 +1475,55 @@ static const DECLARE_TLV_DB_RANGE(classd_tlv, ); static const DECLARE_TLV_DB_SCALE(eq_tlv, -1200, 100, 0);
-static int wm8962_dsp2_write_config(struct snd_soc_codec *codec) +static int wm8962_dsp2_write_config(struct snd_soc_component *component) { - struct wm8962_priv *wm8962 = snd_soc_codec_get_drvdata(codec); + struct wm8962_priv *wm8962 = snd_soc_component_get_drvdata(component);
return regcache_sync_region(wm8962->regmap, WM8962_HDBASS_AI_1, WM8962_MAX_REGISTER); }
-static int wm8962_dsp2_set_enable(struct snd_soc_codec *codec, u16 val) +static int wm8962_dsp2_set_enable(struct snd_soc_component *component, u16 val) { - u16 adcl = snd_soc_read(codec, WM8962_LEFT_ADC_VOLUME); - u16 adcr = snd_soc_read(codec, WM8962_RIGHT_ADC_VOLUME); - u16 dac = snd_soc_read(codec, WM8962_ADC_DAC_CONTROL_1); + u16 adcl = snd_soc_component_read32(component, WM8962_LEFT_ADC_VOLUME); + u16 adcr = snd_soc_component_read32(component, WM8962_RIGHT_ADC_VOLUME); + u16 dac = snd_soc_component_read32(component, WM8962_ADC_DAC_CONTROL_1);
/* Mute the ADCs and DACs */ - snd_soc_write(codec, WM8962_LEFT_ADC_VOLUME, 0); - snd_soc_write(codec, WM8962_RIGHT_ADC_VOLUME, WM8962_ADC_VU); - snd_soc_update_bits(codec, WM8962_ADC_DAC_CONTROL_1, + snd_soc_component_write(component, WM8962_LEFT_ADC_VOLUME, 0); + snd_soc_component_write(component, WM8962_RIGHT_ADC_VOLUME, WM8962_ADC_VU); + snd_soc_component_update_bits(component, WM8962_ADC_DAC_CONTROL_1, WM8962_DAC_MUTE, WM8962_DAC_MUTE);
- snd_soc_write(codec, WM8962_SOUNDSTAGE_ENABLES_0, val); + snd_soc_component_write(component, WM8962_SOUNDSTAGE_ENABLES_0, val);
/* Restore the ADCs and DACs */ - snd_soc_write(codec, WM8962_LEFT_ADC_VOLUME, adcl); - snd_soc_write(codec, WM8962_RIGHT_ADC_VOLUME, adcr); - snd_soc_update_bits(codec, WM8962_ADC_DAC_CONTROL_1, + snd_soc_component_write(component, WM8962_LEFT_ADC_VOLUME, adcl); + snd_soc_component_write(component, WM8962_RIGHT_ADC_VOLUME, adcr); + snd_soc_component_update_bits(component, WM8962_ADC_DAC_CONTROL_1, WM8962_DAC_MUTE, dac);
return 0; }
-static int wm8962_dsp2_start(struct snd_soc_codec *codec) +static int wm8962_dsp2_start(struct snd_soc_component *component) { - struct wm8962_priv *wm8962 = snd_soc_codec_get_drvdata(codec); + struct wm8962_priv *wm8962 = snd_soc_component_get_drvdata(component);
- wm8962_dsp2_write_config(codec); + wm8962_dsp2_write_config(component);
- snd_soc_write(codec, WM8962_DSP2_EXECCONTROL, WM8962_DSP2_RUNR); + snd_soc_component_write(component, WM8962_DSP2_EXECCONTROL, WM8962_DSP2_RUNR);
- wm8962_dsp2_set_enable(codec, wm8962->dsp2_ena); + wm8962_dsp2_set_enable(component, wm8962->dsp2_ena);
return 0; }
-static int wm8962_dsp2_stop(struct snd_soc_codec *codec) +static int wm8962_dsp2_stop(struct snd_soc_component *component) { - wm8962_dsp2_set_enable(codec, 0); + wm8962_dsp2_set_enable(component, 0);
- snd_soc_write(codec, WM8962_DSP2_EXECCONTROL, WM8962_DSP2_STOP); + snd_soc_component_write(component, WM8962_DSP2_EXECCONTROL, WM8962_DSP2_STOP);
return 0; } @@ -1550,8 +1550,8 @@ static int wm8962_dsp2_ena_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { int shift = kcontrol->private_value; - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct wm8962_priv *wm8962 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct wm8962_priv *wm8962 = snd_soc_component_get_drvdata(component);
ucontrol->value.integer.value[0] = !!(wm8962->dsp2_ena & 1 << shift);
@@ -1562,11 +1562,11 @@ static int wm8962_dsp2_ena_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { int shift = kcontrol->private_value; - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct wm8962_priv *wm8962 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct wm8962_priv *wm8962 = snd_soc_component_get_drvdata(component); int old = wm8962->dsp2_ena; int ret = 0; - int dsp2_running = snd_soc_read(codec, WM8962_DSP2_POWER_MANAGEMENT) & + int dsp2_running = snd_soc_component_read32(component, WM8962_DSP2_POWER_MANAGEMENT) & WM8962_DSP2_ENA;
mutex_lock(&wm8962->dsp2_ena_lock); @@ -1583,9 +1583,9 @@ static int wm8962_dsp2_ena_put(struct snd_kcontrol *kcontrol,
if (dsp2_running) { if (wm8962->dsp2_ena) - wm8962_dsp2_set_enable(codec, wm8962->dsp2_ena); + wm8962_dsp2_set_enable(component, wm8962->dsp2_ena); else - wm8962_dsp2_stop(codec); + wm8962_dsp2_stop(component); }
out: @@ -1600,7 +1600,7 @@ static int wm8962_dsp2_ena_put(struct snd_kcontrol *kcontrol, static int wm8962_put_hp_sw(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); int ret;
/* Apply the update (if any) */ @@ -1609,17 +1609,17 @@ static int wm8962_put_hp_sw(struct snd_kcontrol *kcontrol, return 0;
/* If the left PGA is enabled hit that VU bit... */ - ret = snd_soc_read(codec, WM8962_PWR_MGMT_2); + ret = snd_soc_component_read32(component, WM8962_PWR_MGMT_2); if (ret & WM8962_HPOUTL_PGA_ENA) { - snd_soc_write(codec, WM8962_HPOUTL_VOLUME, - snd_soc_read(codec, WM8962_HPOUTL_VOLUME)); + snd_soc_component_write(component, WM8962_HPOUTL_VOLUME, + snd_soc_component_read32(component, WM8962_HPOUTL_VOLUME)); return 1; }
/* ...otherwise the right. The VU is stereo. */ if (ret & WM8962_HPOUTR_PGA_ENA) - snd_soc_write(codec, WM8962_HPOUTR_VOLUME, - snd_soc_read(codec, WM8962_HPOUTR_VOLUME)); + snd_soc_component_write(component, WM8962_HPOUTR_VOLUME, + snd_soc_component_read32(component, WM8962_HPOUTR_VOLUME));
return 1; } @@ -1630,7 +1630,7 @@ static int wm8962_put_hp_sw(struct snd_kcontrol *kcontrol, static int wm8962_put_spk_sw(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); int ret;
/* Apply the update (if any) */ @@ -1639,17 +1639,17 @@ static int wm8962_put_spk_sw(struct snd_kcontrol *kcontrol, return 0;
/* If the left PGA is enabled hit that VU bit... */ - ret = snd_soc_read(codec, WM8962_PWR_MGMT_2); + ret = snd_soc_component_read32(component, WM8962_PWR_MGMT_2); if (ret & WM8962_SPKOUTL_PGA_ENA) { - snd_soc_write(codec, WM8962_SPKOUTL_VOLUME, - snd_soc_read(codec, WM8962_SPKOUTL_VOLUME)); + snd_soc_component_write(component, WM8962_SPKOUTL_VOLUME, + snd_soc_component_read32(component, WM8962_SPKOUTL_VOLUME)); return 1; }
/* ...otherwise the right. The VU is stereo. */ if (ret & WM8962_SPKOUTR_PGA_ENA) - snd_soc_write(codec, WM8962_SPKOUTR_VOLUME, - snd_soc_read(codec, WM8962_SPKOUTR_VOLUME)); + snd_soc_component_write(component, WM8962_SPKOUTR_VOLUME, + snd_soc_component_read32(component, WM8962_SPKOUTR_VOLUME));
return 1; } @@ -1863,7 +1863,7 @@ static int cp_event(struct snd_soc_dapm_widget *w, static int hp_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); int timeout; int reg; int expected = (WM8962_DCS_STARTUP_DONE_HP1L | @@ -1871,17 +1871,17 @@ static int hp_event(struct snd_soc_dapm_widget *w,
switch (event) { case SND_SOC_DAPM_POST_PMU: - snd_soc_update_bits(codec, WM8962_ANALOGUE_HP_0, + snd_soc_component_update_bits(component, WM8962_ANALOGUE_HP_0, WM8962_HP1L_ENA | WM8962_HP1R_ENA, WM8962_HP1L_ENA | WM8962_HP1R_ENA); udelay(20);
- snd_soc_update_bits(codec, WM8962_ANALOGUE_HP_0, + snd_soc_component_update_bits(component, WM8962_ANALOGUE_HP_0, WM8962_HP1L_ENA_DLY | WM8962_HP1R_ENA_DLY, WM8962_HP1L_ENA_DLY | WM8962_HP1R_ENA_DLY);
/* Start the DC servo */ - snd_soc_update_bits(codec, WM8962_DC_SERVO_1, + snd_soc_component_update_bits(component, WM8962_DC_SERVO_1, WM8962_HP1L_DCS_ENA | WM8962_HP1R_DCS_ENA | WM8962_HP1L_DCS_STARTUP | WM8962_HP1R_DCS_STARTUP, @@ -1893,30 +1893,30 @@ static int hp_event(struct snd_soc_dapm_widget *w, timeout = 0; do { msleep(1); - reg = snd_soc_read(codec, WM8962_DC_SERVO_6); + reg = snd_soc_component_read32(component, WM8962_DC_SERVO_6); if (reg < 0) { - dev_err(codec->dev, + dev_err(component->dev, "Failed to read DCS status: %d\n", reg); continue; } - dev_dbg(codec->dev, "DCS status: %x\n", reg); + dev_dbg(component->dev, "DCS status: %x\n", reg); } while (++timeout < 200 && (reg & expected) != expected);
if ((reg & expected) != expected) - dev_err(codec->dev, "DC servo timed out\n"); + dev_err(component->dev, "DC servo timed out\n"); else - dev_dbg(codec->dev, "DC servo complete after %dms\n", + dev_dbg(component->dev, "DC servo complete after %dms\n", timeout);
- snd_soc_update_bits(codec, WM8962_ANALOGUE_HP_0, + snd_soc_component_update_bits(component, WM8962_ANALOGUE_HP_0, WM8962_HP1L_ENA_OUTP | WM8962_HP1R_ENA_OUTP, WM8962_HP1L_ENA_OUTP | WM8962_HP1R_ENA_OUTP); udelay(20);
- snd_soc_update_bits(codec, WM8962_ANALOGUE_HP_0, + snd_soc_component_update_bits(component, WM8962_ANALOGUE_HP_0, WM8962_HP1L_RMV_SHORT | WM8962_HP1R_RMV_SHORT, WM8962_HP1L_RMV_SHORT | @@ -1924,19 +1924,19 @@ static int hp_event(struct snd_soc_dapm_widget *w, break;
case SND_SOC_DAPM_PRE_PMD: - snd_soc_update_bits(codec, WM8962_ANALOGUE_HP_0, + snd_soc_component_update_bits(component, WM8962_ANALOGUE_HP_0, WM8962_HP1L_RMV_SHORT | WM8962_HP1R_RMV_SHORT, 0);
udelay(20);
- snd_soc_update_bits(codec, WM8962_DC_SERVO_1, + snd_soc_component_update_bits(component, WM8962_DC_SERVO_1, WM8962_HP1L_DCS_ENA | WM8962_HP1R_DCS_ENA | WM8962_HP1L_DCS_STARTUP | WM8962_HP1R_DCS_STARTUP, 0);
- snd_soc_update_bits(codec, WM8962_ANALOGUE_HP_0, + snd_soc_component_update_bits(component, WM8962_ANALOGUE_HP_0, WM8962_HP1L_ENA | WM8962_HP1R_ENA | WM8962_HP1L_ENA_DLY | WM8962_HP1R_ENA_DLY | WM8962_HP1L_ENA_OUTP | @@ -1957,7 +1957,7 @@ static int hp_event(struct snd_soc_dapm_widget *w, static int out_pga_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); int reg;
switch (w->shift) { @@ -1980,7 +1980,7 @@ static int out_pga_event(struct snd_soc_dapm_widget *w,
switch (event) { case SND_SOC_DAPM_POST_PMU: - return snd_soc_write(codec, reg, snd_soc_read(codec, reg)); + return snd_soc_component_write(component, reg, snd_soc_component_read32(component, reg)); default: WARN(1, "Invalid event %d\n", event); return -EINVAL; @@ -1990,18 +1990,18 @@ static int out_pga_event(struct snd_soc_dapm_widget *w, static int dsp2_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); - struct wm8962_priv *wm8962 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); + struct wm8962_priv *wm8962 = snd_soc_component_get_drvdata(component);
switch (event) { case SND_SOC_DAPM_POST_PMU: if (wm8962->dsp2_ena) - wm8962_dsp2_start(codec); + wm8962_dsp2_start(component); break;
case SND_SOC_DAPM_PRE_PMD: if (wm8962->dsp2_ena) - wm8962_dsp2_stop(codec); + wm8962_dsp2_stop(component); break;
default: @@ -2354,19 +2354,19 @@ static SOC_ENUM_SINGLE_DECL(hpoutl_enum, { "SPKOUTR", NULL, "SPKOUTR Output" }, };
-static int wm8962_add_widgets(struct snd_soc_codec *codec) +static int wm8962_add_widgets(struct snd_soc_component *component) { - struct wm8962_priv *wm8962 = snd_soc_codec_get_drvdata(codec); + struct wm8962_priv *wm8962 = snd_soc_component_get_drvdata(component); struct wm8962_pdata *pdata = &wm8962->pdata; - struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec); + struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component);
- snd_soc_add_codec_controls(codec, wm8962_snd_controls, + snd_soc_add_component_controls(component, wm8962_snd_controls, ARRAY_SIZE(wm8962_snd_controls)); if (pdata->spk_mono) - snd_soc_add_codec_controls(codec, wm8962_spk_mono_controls, + snd_soc_add_component_controls(component, wm8962_spk_mono_controls, ARRAY_SIZE(wm8962_spk_mono_controls)); else - snd_soc_add_codec_controls(codec, wm8962_spk_stereo_controls, + snd_soc_add_component_controls(component, wm8962_spk_stereo_controls, ARRAY_SIZE(wm8962_spk_stereo_controls));
@@ -2403,21 +2403,21 @@ static int wm8962_add_widgets(struct snd_soc_codec *codec) 64, 128, 192, 256, 384, 512, 768, 1024, 1408, 1536, 3072, 6144 };
-static void wm8962_configure_bclk(struct snd_soc_codec *codec) +static void wm8962_configure_bclk(struct snd_soc_component *component) { - struct wm8962_priv *wm8962 = snd_soc_codec_get_drvdata(codec); + struct wm8962_priv *wm8962 = snd_soc_component_get_drvdata(component); int dspclk, i; int clocking2 = 0; int clocking4 = 0; int aif2 = 0;
if (!wm8962->sysclk_rate) { - dev_dbg(codec->dev, "No SYSCLK configured\n"); + dev_dbg(component->dev, "No SYSCLK configured\n"); return; }
if (!wm8962->bclk || !wm8962->lrclk) { - dev_dbg(codec->dev, "No audio clocks configured\n"); + dev_dbg(component->dev, "No audio clocks configured\n"); return; }
@@ -2429,32 +2429,32 @@ static void wm8962_configure_bclk(struct snd_soc_codec *codec) }
if (i == ARRAY_SIZE(sysclk_rates)) { - dev_err(codec->dev, "Unsupported sysclk ratio %d\n", + dev_err(component->dev, "Unsupported sysclk ratio %d\n", wm8962->sysclk_rate / wm8962->lrclk); return; }
- dev_dbg(codec->dev, "Selected sysclk ratio %d\n", sysclk_rates[i]); + dev_dbg(component->dev, "Selected sysclk ratio %d\n", sysclk_rates[i]);
- snd_soc_update_bits(codec, WM8962_CLOCKING_4, + snd_soc_component_update_bits(component, WM8962_CLOCKING_4, WM8962_SYSCLK_RATE_MASK, clocking4);
/* DSPCLK_DIV can be only generated correctly after enabling SYSCLK. * So we here provisionally enable it and then disable it afterward * if current bias_level hasn't reached SND_SOC_BIAS_ON. */ - if (snd_soc_codec_get_bias_level(codec) != SND_SOC_BIAS_ON) - snd_soc_update_bits(codec, WM8962_CLOCKING2, + if (snd_soc_component_get_bias_level(component) != SND_SOC_BIAS_ON) + snd_soc_component_update_bits(component, WM8962_CLOCKING2, WM8962_SYSCLK_ENA_MASK, WM8962_SYSCLK_ENA);
- dspclk = snd_soc_read(codec, WM8962_CLOCKING1); + dspclk = snd_soc_component_read32(component, WM8962_CLOCKING1);
- if (snd_soc_codec_get_bias_level(codec) != SND_SOC_BIAS_ON) - snd_soc_update_bits(codec, WM8962_CLOCKING2, + if (snd_soc_component_get_bias_level(component) != SND_SOC_BIAS_ON) + snd_soc_component_update_bits(component, WM8962_CLOCKING2, WM8962_SYSCLK_ENA_MASK, 0);
if (dspclk < 0) { - dev_err(codec->dev, "Failed to read DSPCLK: %d\n", dspclk); + dev_err(component->dev, "Failed to read DSPCLK: %d\n", dspclk); return; }
@@ -2470,11 +2470,11 @@ static void wm8962_configure_bclk(struct snd_soc_codec *codec) dspclk = wm8962->sysclk_rate / 4; break; default: - dev_warn(codec->dev, "Unknown DSPCLK divisor read back\n"); + dev_warn(component->dev, "Unknown DSPCLK divisor read back\n"); dspclk = wm8962->sysclk_rate; }
- dev_dbg(codec->dev, "DSPCLK is %dHz, BCLK %d\n", dspclk, wm8962->bclk); + dev_dbg(component->dev, "DSPCLK is %dHz, BCLK %d\n", dspclk, wm8962->bclk);
/* We're expecting an exact match */ for (i = 0; i < ARRAY_SIZE(bclk_divs); i++) { @@ -2482,29 +2482,29 @@ static void wm8962_configure_bclk(struct snd_soc_codec *codec) continue;
if (dspclk / bclk_divs[i] == wm8962->bclk) { - dev_dbg(codec->dev, "Selected BCLK_DIV %d for %dHz\n", + dev_dbg(component->dev, "Selected BCLK_DIV %d for %dHz\n", bclk_divs[i], wm8962->bclk); clocking2 |= i; break; } } if (i == ARRAY_SIZE(bclk_divs)) { - dev_err(codec->dev, "Unsupported BCLK ratio %d\n", + dev_err(component->dev, "Unsupported BCLK ratio %d\n", dspclk / wm8962->bclk); return; }
aif2 |= wm8962->bclk / wm8962->lrclk; - dev_dbg(codec->dev, "Selected LRCLK divisor %d for %dHz\n", + dev_dbg(component->dev, "Selected LRCLK divisor %d for %dHz\n", wm8962->bclk / wm8962->lrclk, wm8962->lrclk);
- snd_soc_update_bits(codec, WM8962_CLOCKING2, + snd_soc_component_update_bits(component, WM8962_CLOCKING2, WM8962_BCLK_DIV_MASK, clocking2); - snd_soc_update_bits(codec, WM8962_AUDIO_INTERFACE_2, + snd_soc_component_update_bits(component, WM8962_AUDIO_INTERFACE_2, WM8962_AIF_RATE_MASK, aif2); }
-static int wm8962_set_bias_level(struct snd_soc_codec *codec, +static int wm8962_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { switch (level) { @@ -2513,18 +2513,18 @@ static int wm8962_set_bias_level(struct snd_soc_codec *codec,
case SND_SOC_BIAS_PREPARE: /* VMID 2*50k */ - snd_soc_update_bits(codec, WM8962_PWR_MGMT_1, + snd_soc_component_update_bits(component, WM8962_PWR_MGMT_1, WM8962_VMID_SEL_MASK, 0x80);
- wm8962_configure_bclk(codec); + wm8962_configure_bclk(component); break;
case SND_SOC_BIAS_STANDBY: /* VMID 2*250k */ - snd_soc_update_bits(codec, WM8962_PWR_MGMT_1, + snd_soc_component_update_bits(component, WM8962_PWR_MGMT_1, WM8962_VMID_SEL_MASK, 0x100);
- if (snd_soc_codec_get_bias_level(codec) == SND_SOC_BIAS_OFF) + if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_OFF) msleep(100); break;
@@ -2556,8 +2556,8 @@ static int wm8962_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; - struct wm8962_priv *wm8962 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct wm8962_priv *wm8962 = snd_soc_component_get_drvdata(component); int i; int aif0 = 0; int adctl3 = 0; @@ -2575,7 +2575,7 @@ static int wm8962_hw_params(struct snd_pcm_substream *substream, } } if (i == ARRAY_SIZE(sr_vals)) { - dev_err(codec->dev, "Unsupported rate %dHz\n", wm8962->lrclk); + dev_err(component->dev, "Unsupported rate %dHz\n", wm8962->lrclk); return -EINVAL; }
@@ -2598,17 +2598,17 @@ static int wm8962_hw_params(struct snd_pcm_substream *substream, return -EINVAL; }
- snd_soc_update_bits(codec, WM8962_AUDIO_INTERFACE_0, + snd_soc_component_update_bits(component, WM8962_AUDIO_INTERFACE_0, WM8962_WL_MASK, aif0); - snd_soc_update_bits(codec, WM8962_ADDITIONAL_CONTROL_3, + snd_soc_component_update_bits(component, WM8962_ADDITIONAL_CONTROL_3, WM8962_SAMPLE_RATE_INT_MODE | WM8962_SAMPLE_RATE_MASK, adctl3);
- dev_dbg(codec->dev, "hw_params set BCLK %dHz LRCLK %dHz\n", + dev_dbg(component->dev, "hw_params set BCLK %dHz LRCLK %dHz\n", wm8962->bclk, wm8962->lrclk);
- if (snd_soc_codec_get_bias_level(codec) == SND_SOC_BIAS_ON) - wm8962_configure_bclk(codec); + if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_ON) + wm8962_configure_bclk(component);
return 0; } @@ -2616,8 +2616,8 @@ static int wm8962_hw_params(struct snd_pcm_substream *substream, static int wm8962_set_dai_sysclk(struct snd_soc_dai *dai, int clk_id, unsigned int freq, int dir) { - struct snd_soc_codec *codec = dai->codec; - struct wm8962_priv *wm8962 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct wm8962_priv *wm8962 = snd_soc_component_get_drvdata(component); int src;
switch (clk_id) { @@ -2633,7 +2633,7 @@ static int wm8962_set_dai_sysclk(struct snd_soc_dai *dai, int clk_id, return -EINVAL; }
- snd_soc_update_bits(codec, WM8962_CLOCKING2, WM8962_SYSCLK_SRC_MASK, + snd_soc_component_update_bits(component, WM8962_CLOCKING2, WM8962_SYSCLK_SRC_MASK, src);
wm8962->sysclk_rate = freq; @@ -2643,7 +2643,7 @@ static int wm8962_set_dai_sysclk(struct snd_soc_dai *dai, int clk_id,
static int wm8962_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt) { - struct snd_soc_codec *codec = dai->codec; + struct snd_soc_component *component = dai->component; int aif0 = 0;
switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) { @@ -2699,7 +2699,7 @@ static int wm8962_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt) return -EINVAL; }
- snd_soc_update_bits(codec, WM8962_AUDIO_INTERFACE_0, + snd_soc_component_update_bits(component, WM8962_AUDIO_INTERFACE_0, WM8962_FMT_MASK | WM8962_BCLK_INV | WM8962_MSTR | WM8962_LRCLK_INV, aif0);
@@ -2809,10 +2809,10 @@ static int fll_factors(struct _fll_div *fll_div, unsigned int Fref, return 0; }
-static int wm8962_set_fll(struct snd_soc_codec *codec, int fll_id, int source, +static int wm8962_set_fll(struct snd_soc_component *component, int fll_id, int source, unsigned int Fref, unsigned int Fout) { - struct wm8962_priv *wm8962 = snd_soc_codec_get_drvdata(codec); + struct wm8962_priv *wm8962 = snd_soc_component_get_drvdata(component); struct _fll_div fll_div; unsigned long timeout; int ret; @@ -2824,15 +2824,15 @@ static int wm8962_set_fll(struct snd_soc_codec *codec, int fll_id, int source, return 0;
if (Fout == 0) { - dev_dbg(codec->dev, "FLL disabled\n"); + dev_dbg(component->dev, "FLL disabled\n");
wm8962->fll_fref = 0; wm8962->fll_fout = 0;
- snd_soc_update_bits(codec, WM8962_FLL_CONTROL_1, + snd_soc_component_update_bits(component, WM8962_FLL_CONTROL_1, WM8962_FLL_ENA, 0);
- pm_runtime_put(codec->dev); + pm_runtime_put(component->dev);
return 0; } @@ -2842,7 +2842,7 @@ static int wm8962_set_fll(struct snd_soc_codec *codec, int fll_id, int source, return ret;
/* Parameters good, disable so we can reprogram */ - snd_soc_update_bits(codec, WM8962_FLL_CONTROL_1, WM8962_FLL_ENA, 0); + snd_soc_component_update_bits(component, WM8962_FLL_CONTROL_1, WM8962_FLL_ENA, 0);
switch (fll_id) { case WM8962_FLL_MCLK: @@ -2851,13 +2851,13 @@ static int wm8962_set_fll(struct snd_soc_codec *codec, int fll_id, int source, fll1 |= (fll_id - 1) << WM8962_FLL_REFCLK_SRC_SHIFT; break; case WM8962_FLL_INT: - snd_soc_update_bits(codec, WM8962_FLL_CONTROL_1, + snd_soc_component_update_bits(component, WM8962_FLL_CONTROL_1, WM8962_FLL_OSC_ENA, WM8962_FLL_OSC_ENA); - snd_soc_update_bits(codec, WM8962_FLL_CONTROL_5, + snd_soc_component_update_bits(component, WM8962_FLL_CONTROL_5, WM8962_FLL_FRC_NCO, WM8962_FLL_FRC_NCO); break; default: - dev_err(codec->dev, "Unknown FLL source %d\n", ret); + dev_err(component->dev, "Unknown FLL source %d\n", ret); return -EINVAL; }
@@ -2865,34 +2865,34 @@ static int wm8962_set_fll(struct snd_soc_codec *codec, int fll_id, int source, fll1 |= WM8962_FLL_FRAC;
/* Stop the FLL while we reconfigure */ - snd_soc_update_bits(codec, WM8962_FLL_CONTROL_1, WM8962_FLL_ENA, 0); + snd_soc_component_update_bits(component, WM8962_FLL_CONTROL_1, WM8962_FLL_ENA, 0);
- snd_soc_update_bits(codec, WM8962_FLL_CONTROL_2, + snd_soc_component_update_bits(component, WM8962_FLL_CONTROL_2, WM8962_FLL_OUTDIV_MASK | WM8962_FLL_REFCLK_DIV_MASK, (fll_div.fll_outdiv << WM8962_FLL_OUTDIV_SHIFT) | (fll_div.fll_refclk_div));
- snd_soc_update_bits(codec, WM8962_FLL_CONTROL_3, + snd_soc_component_update_bits(component, WM8962_FLL_CONTROL_3, WM8962_FLL_FRATIO_MASK, fll_div.fll_fratio);
- snd_soc_write(codec, WM8962_FLL_CONTROL_6, fll_div.theta); - snd_soc_write(codec, WM8962_FLL_CONTROL_7, fll_div.lambda); - snd_soc_write(codec, WM8962_FLL_CONTROL_8, fll_div.n); + snd_soc_component_write(component, WM8962_FLL_CONTROL_6, fll_div.theta); + snd_soc_component_write(component, WM8962_FLL_CONTROL_7, fll_div.lambda); + snd_soc_component_write(component, WM8962_FLL_CONTROL_8, fll_div.n);
reinit_completion(&wm8962->fll_lock);
- ret = pm_runtime_get_sync(codec->dev); + ret = pm_runtime_get_sync(component->dev); if (ret < 0) { - dev_err(codec->dev, "Failed to resume device: %d\n", ret); + dev_err(component->dev, "Failed to resume device: %d\n", ret); return ret; }
- snd_soc_update_bits(codec, WM8962_FLL_CONTROL_1, + snd_soc_component_update_bits(component, WM8962_FLL_CONTROL_1, WM8962_FLL_FRAC | WM8962_FLL_REFCLK_SRC_MASK | WM8962_FLL_ENA, fll1 | WM8962_FLL_ENA);
- dev_dbg(codec->dev, "FLL configured for %dHz->%dHz\n", Fref, Fout); + dev_dbg(component->dev, "FLL configured for %dHz->%dHz\n", Fref, Fout);
/* This should be a massive overestimate but go even * higher if we'll error out @@ -2906,10 +2906,10 @@ static int wm8962_set_fll(struct snd_soc_codec *codec, int fll_id, int source, timeout);
if (timeout == 0 && wm8962->irq) { - dev_err(codec->dev, "FLL lock timed out"); - snd_soc_update_bits(codec, WM8962_FLL_CONTROL_1, + dev_err(component->dev, "FLL lock timed out"); + snd_soc_component_update_bits(component, WM8962_FLL_CONTROL_1, WM8962_FLL_ENA, 0); - pm_runtime_put(codec->dev); + pm_runtime_put(component->dev); return -ETIMEDOUT; }
@@ -2922,7 +2922,7 @@ static int wm8962_set_fll(struct snd_soc_codec *codec, int fll_id, int source,
static int wm8962_mute(struct snd_soc_dai *dai, int mute) { - struct snd_soc_codec *codec = dai->codec; + struct snd_soc_component *component = dai->component; int val, ret;
if (mute) @@ -2934,12 +2934,12 @@ static int wm8962_mute(struct snd_soc_dai *dai, int mute) * The DAC mute bit is mirrored in two registers, update both to keep * the register cache consistent. */ - ret = snd_soc_update_bits(codec, WM8962_CLASS_D_CONTROL_1, + ret = snd_soc_component_update_bits(component, WM8962_CLASS_D_CONTROL_1, WM8962_DAC_MUTE_ALT, val); if (ret < 0) return ret;
- return snd_soc_update_bits(codec, WM8962_ADC_DAC_CONTROL_1, + return snd_soc_component_update_bits(component, WM8962_ADC_DAC_CONTROL_1, WM8962_DAC_MUTE, val); }
@@ -2981,12 +2981,12 @@ static void wm8962_mic_work(struct work_struct *work) struct wm8962_priv *wm8962 = container_of(work, struct wm8962_priv, mic_work.work); - struct snd_soc_codec *codec = wm8962->codec; + struct snd_soc_component *component = wm8962->component; int status = 0; int irq_pol = 0; int reg;
- reg = snd_soc_read(codec, WM8962_ADDITIONAL_CONTROL_4); + reg = snd_soc_component_read32(component, WM8962_ADDITIONAL_CONTROL_4);
if (reg & WM8962_MICDET_STS) { status |= SND_JACK_MICROPHONE; @@ -3001,7 +3001,7 @@ static void wm8962_mic_work(struct work_struct *work) snd_soc_jack_report(wm8962->jack, status, SND_JACK_MICROPHONE | SND_JACK_BTN_0);
- snd_soc_update_bits(codec, WM8962_MICINT_SOURCE_POL, + snd_soc_component_update_bits(component, WM8962_MICINT_SOURCE_POL, WM8962_MICSCD_IRQ_POL | WM8962_MICD_IRQ_POL, irq_pol); } @@ -3099,7 +3099,7 @@ static irqreturn_t wm8962_irq(int irq, void *data) /** * wm8962_mic_detect - Enable microphone detection via the WM8962 IRQ * - * @codec: WM8962 codec + * @component: WM8962 component * @jack: jack to report detection events on * * Enable microphone detection via IRQ on the WM8962. If GPIOs are @@ -3109,10 +3109,10 @@ static irqreturn_t wm8962_irq(int irq, void *data) * * If no jack is supplied detection will be disabled. */ -int wm8962_mic_detect(struct snd_soc_codec *codec, struct snd_soc_jack *jack) +int wm8962_mic_detect(struct snd_soc_component *component, struct snd_soc_jack *jack) { - struct wm8962_priv *wm8962 = snd_soc_codec_get_drvdata(codec); - struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec); + struct wm8962_priv *wm8962 = snd_soc_component_get_drvdata(component); + struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); int irq_mask, enable;
wm8962->jack = jack; @@ -3124,9 +3124,9 @@ int wm8962_mic_detect(struct snd_soc_codec *codec, struct snd_soc_jack *jack) enable = 0; }
- snd_soc_update_bits(codec, WM8962_INTERRUPT_STATUS_2_MASK, + snd_soc_component_update_bits(component, WM8962_INTERRUPT_STATUS_2_MASK, WM8962_MICD_EINT | WM8962_MICSCD_EINT, irq_mask); - snd_soc_update_bits(codec, WM8962_ADDITIONAL_CONTROL_4, + snd_soc_component_update_bits(component, WM8962_ADDITIONAL_CONTROL_4, WM8962_MICDET_ENA, enable);
/* Send an initial empty report */ @@ -3157,8 +3157,8 @@ static void wm8962_beep_work(struct work_struct *work) { struct wm8962_priv *wm8962 = container_of(work, struct wm8962_priv, beep_work); - struct snd_soc_codec *codec = wm8962->codec; - struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec); + struct snd_soc_component *component = wm8962->component; + struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); int i; int reg = 0; int best = 0; @@ -3170,18 +3170,18 @@ static void wm8962_beep_work(struct work_struct *work) best = i; }
- dev_dbg(codec->dev, "Set beep rate %dHz for requested %dHz\n", + dev_dbg(component->dev, "Set beep rate %dHz for requested %dHz\n", beep_rates[best], wm8962->beep_rate);
reg = WM8962_BEEP_ENA | (best << WM8962_BEEP_RATE_SHIFT);
snd_soc_dapm_enable_pin(dapm, "Beep"); } else { - dev_dbg(codec->dev, "Disabling beep\n"); + dev_dbg(component->dev, "Disabling beep\n"); snd_soc_dapm_disable_pin(dapm, "Beep"); }
- snd_soc_update_bits(codec, WM8962_BEEP_GENERATOR_1, + snd_soc_component_update_bits(component, WM8962_BEEP_GENERATOR_1, WM8962_BEEP_ENA | WM8962_BEEP_RATE_MASK, reg);
snd_soc_dapm_sync(dapm); @@ -3193,10 +3193,10 @@ static void wm8962_beep_work(struct work_struct *work) static int wm8962_beep_event(struct input_dev *dev, unsigned int type, unsigned int code, int hz) { - struct snd_soc_codec *codec = input_get_drvdata(dev); - struct wm8962_priv *wm8962 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = input_get_drvdata(dev); + struct wm8962_priv *wm8962 = snd_soc_component_get_drvdata(component);
- dev_dbg(codec->dev, "Beep event %x %x\n", code, hz); + dev_dbg(component->dev, "Beep event %x %x\n", code, hz);
switch (code) { case SND_BELL: @@ -3233,14 +3233,14 @@ static ssize_t wm8962_beep_set(struct device *dev,
static DEVICE_ATTR(beep, 0200, NULL, wm8962_beep_set);
-static void wm8962_init_beep(struct snd_soc_codec *codec) +static void wm8962_init_beep(struct snd_soc_component *component) { - struct wm8962_priv *wm8962 = snd_soc_codec_get_drvdata(codec); + struct wm8962_priv *wm8962 = snd_soc_component_get_drvdata(component); int ret;
- wm8962->beep = devm_input_allocate_device(codec->dev); + wm8962->beep = devm_input_allocate_device(component->dev); if (!wm8962->beep) { - dev_err(codec->dev, "Failed to allocate beep device\n"); + dev_err(component->dev, "Failed to allocate beep device\n"); return; }
@@ -3248,37 +3248,37 @@ static void wm8962_init_beep(struct snd_soc_codec *codec) wm8962->beep_rate = 0;
wm8962->beep->name = "WM8962 Beep Generator"; - wm8962->beep->phys = dev_name(codec->dev); + wm8962->beep->phys = dev_name(component->dev); wm8962->beep->id.bustype = BUS_I2C;
wm8962->beep->evbit[0] = BIT_MASK(EV_SND); wm8962->beep->sndbit[0] = BIT_MASK(SND_BELL) | BIT_MASK(SND_TONE); wm8962->beep->event = wm8962_beep_event; - wm8962->beep->dev.parent = codec->dev; - input_set_drvdata(wm8962->beep, codec); + wm8962->beep->dev.parent = component->dev; + input_set_drvdata(wm8962->beep, component);
ret = input_register_device(wm8962->beep); if (ret != 0) { wm8962->beep = NULL; - dev_err(codec->dev, "Failed to register beep device\n"); + dev_err(component->dev, "Failed to register beep device\n"); }
- ret = device_create_file(codec->dev, &dev_attr_beep); + ret = device_create_file(component->dev, &dev_attr_beep); if (ret != 0) { - dev_err(codec->dev, "Failed to create keyclick file: %d\n", + dev_err(component->dev, "Failed to create keyclick file: %d\n", ret); } }
-static void wm8962_free_beep(struct snd_soc_codec *codec) +static void wm8962_free_beep(struct snd_soc_component *component) { - struct wm8962_priv *wm8962 = snd_soc_codec_get_drvdata(codec); + struct wm8962_priv *wm8962 = snd_soc_component_get_drvdata(component);
- device_remove_file(codec->dev, &dev_attr_beep); + device_remove_file(component->dev, &dev_attr_beep); cancel_work_sync(&wm8962->beep_work); wm8962->beep = NULL;
- snd_soc_update_bits(codec, WM8962_BEEP_GENERATOR_1, WM8962_BEEP_ENA,0); + snd_soc_component_update_bits(component, WM8962_BEEP_GENERATOR_1, WM8962_BEEP_ENA,0); }
static void wm8962_set_gpio_mode(struct wm8962_priv *wm8962, int gpio) @@ -3333,9 +3333,9 @@ static int wm8962_gpio_request(struct gpio_chip *chip, unsigned offset) static void wm8962_gpio_set(struct gpio_chip *chip, unsigned offset, int value) { struct wm8962_priv *wm8962 = gpiochip_get_data(chip); - struct snd_soc_codec *codec = wm8962->codec; + struct snd_soc_component *component = wm8962->component;
- snd_soc_update_bits(codec, WM8962_GPIO_BASE + offset, + snd_soc_component_update_bits(component, WM8962_GPIO_BASE + offset, WM8962_GP2_LVL, !!value << WM8962_GP2_LVL_SHIFT); }
@@ -3343,13 +3343,13 @@ static int wm8962_gpio_direction_out(struct gpio_chip *chip, unsigned offset, int value) { struct wm8962_priv *wm8962 = gpiochip_get_data(chip); - struct snd_soc_codec *codec = wm8962->codec; + struct snd_soc_component *component = wm8962->component; int ret, val;
/* Force function 1 (logic output) */ val = (1 << WM8962_GP2_FN_SHIFT) | (value << WM8962_GP2_LVL_SHIFT);
- ret = snd_soc_update_bits(codec, WM8962_GPIO_BASE + offset, + ret = snd_soc_component_update_bits(component, WM8962_GPIO_BASE + offset, WM8962_GP2_FN_MASK | WM8962_GP2_LVL, val); if (ret < 0) return ret; @@ -3366,15 +3366,15 @@ static int wm8962_gpio_direction_out(struct gpio_chip *chip, .can_sleep = 1, };
-static void wm8962_init_gpio(struct snd_soc_codec *codec) +static void wm8962_init_gpio(struct snd_soc_component *component) { - struct wm8962_priv *wm8962 = snd_soc_codec_get_drvdata(codec); + struct wm8962_priv *wm8962 = snd_soc_component_get_drvdata(component); struct wm8962_pdata *pdata = &wm8962->pdata; int ret;
wm8962->gpio_chip = wm8962_template_chip; wm8962->gpio_chip.ngpio = WM8962_MAX_GPIO; - wm8962->gpio_chip.parent = codec->dev; + wm8962->gpio_chip.parent = component->dev;
if (pdata->gpio_base) wm8962->gpio_chip.base = pdata->gpio_base; @@ -3383,34 +3383,34 @@ static void wm8962_init_gpio(struct snd_soc_codec *codec)
ret = gpiochip_add_data(&wm8962->gpio_chip, wm8962); if (ret != 0) - dev_err(codec->dev, "Failed to add GPIOs: %d\n", ret); + dev_err(component->dev, "Failed to add GPIOs: %d\n", ret); }
-static void wm8962_free_gpio(struct snd_soc_codec *codec) +static void wm8962_free_gpio(struct snd_soc_component *component) { - struct wm8962_priv *wm8962 = snd_soc_codec_get_drvdata(codec); + struct wm8962_priv *wm8962 = snd_soc_component_get_drvdata(component);
gpiochip_remove(&wm8962->gpio_chip); } #else -static void wm8962_init_gpio(struct snd_soc_codec *codec) +static void wm8962_init_gpio(struct snd_soc_component *component) { }
-static void wm8962_free_gpio(struct snd_soc_codec *codec) +static void wm8962_free_gpio(struct snd_soc_component *component) { } #endif
-static int wm8962_probe(struct snd_soc_codec *codec) +static int wm8962_probe(struct snd_soc_component *component) { - struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec); + struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); int ret; - struct wm8962_priv *wm8962 = snd_soc_codec_get_drvdata(codec); + struct wm8962_priv *wm8962 = snd_soc_component_get_drvdata(component); int i; bool dmicclk, dmicdat;
- wm8962->codec = codec; + wm8962->component = component;
wm8962->disable_nb[0].notifier_call = wm8962_regulator_event_0; wm8962->disable_nb[1].notifier_call = wm8962_regulator_event_1; @@ -3426,19 +3426,19 @@ static int wm8962_probe(struct snd_soc_codec *codec) ret = regulator_register_notifier(wm8962->supplies[i].consumer, &wm8962->disable_nb[i]); if (ret != 0) { - dev_err(codec->dev, + dev_err(component->dev, "Failed to register regulator notifier: %d\n", ret); } }
- wm8962_add_widgets(codec); + wm8962_add_widgets(component);
/* Save boards having to disable DMIC when not in use */ dmicclk = false; dmicdat = false; for (i = 0; i < WM8962_MAX_GPIO; i++) { - switch (snd_soc_read(codec, WM8962_GPIO_BASE + i) + switch (snd_soc_component_read32(component, WM8962_GPIO_BASE + i) & WM8962_GP2_FN_MASK) { case WM8962_GPIO_FN_DMICCLK: dmicclk = true; @@ -3451,40 +3451,40 @@ static int wm8962_probe(struct snd_soc_codec *codec) } } if (!dmicclk || !dmicdat) { - dev_dbg(codec->dev, "DMIC not in use, disabling\n"); + dev_dbg(component->dev, "DMIC not in use, disabling\n"); snd_soc_dapm_nc_pin(dapm, "DMICDAT"); } if (dmicclk != dmicdat) - dev_warn(codec->dev, "DMIC GPIOs partially configured\n"); + dev_warn(component->dev, "DMIC GPIOs partially configured\n");
- wm8962_init_beep(codec); - wm8962_init_gpio(codec); + wm8962_init_beep(component); + wm8962_init_gpio(component);
return 0; }
-static int wm8962_remove(struct snd_soc_codec *codec) +static void wm8962_remove(struct snd_soc_component *component) { - struct wm8962_priv *wm8962 = snd_soc_codec_get_drvdata(codec); + struct wm8962_priv *wm8962 = snd_soc_component_get_drvdata(component); int i;
cancel_delayed_work_sync(&wm8962->mic_work);
- wm8962_free_gpio(codec); - wm8962_free_beep(codec); + wm8962_free_gpio(component); + wm8962_free_beep(component); for (i = 0; i < ARRAY_SIZE(wm8962->supplies); i++) regulator_unregister_notifier(wm8962->supplies[i].consumer, &wm8962->disable_nb[i]); - - return 0; }
-static const struct snd_soc_codec_driver soc_codec_dev_wm8962 = { - .probe = wm8962_probe, - .remove = wm8962_remove, - .set_bias_level = wm8962_set_bias_level, - .set_pll = wm8962_set_fll, - .idle_bias_off = true, +static const struct snd_soc_component_driver soc_component_dev_wm8962 = { + .probe = wm8962_probe, + .remove = wm8962_remove, + .set_bias_level = wm8962_set_bias_level, + .set_pll = wm8962_set_fll, + .pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, };
/* Improve power consumption for IN4 DC measurement mode */ @@ -3751,8 +3751,8 @@ static int wm8962_i2c_probe(struct i2c_client *i2c, pm_runtime_enable(&i2c->dev); pm_request_idle(&i2c->dev);
- ret = snd_soc_register_codec(&i2c->dev, - &soc_codec_dev_wm8962, &wm8962_dai, 1); + ret = devm_snd_soc_register_component(&i2c->dev, + &soc_component_dev_wm8962, &wm8962_dai, 1); if (ret < 0) goto err_pm_runtime;
@@ -3773,7 +3773,6 @@ static int wm8962_i2c_probe(struct i2c_client *i2c,
static int wm8962_i2c_remove(struct i2c_client *client) { - snd_soc_unregister_codec(&client->dev); pm_runtime_disable(&client->dev); return 0; } diff --git a/sound/soc/codecs/wm8962.h b/sound/soc/codecs/wm8962.h index e63a318..a4a42d2 100644 --- a/sound/soc/codecs/wm8962.h +++ b/sound/soc/codecs/wm8962.h @@ -3779,6 +3779,6 @@ #define WM8962_VSS_ENA_SHIFT 0 /* VSS_ENA */ #define WM8962_VSS_ENA_WIDTH 1 /* VSS_ENA */
-int wm8962_mic_detect(struct snd_soc_codec *codec, struct snd_soc_jack *jack); +int wm8962_mic_detect(struct snd_soc_component *component, struct snd_soc_jack *jack);
#endif diff --git a/sound/soc/samsung/tobermory.c b/sound/soc/samsung/tobermory.c index 3310eda..998727c 100644 --- a/sound/soc/samsung/tobermory.c +++ b/sound/soc/samsung/tobermory.c @@ -179,12 +179,12 @@ static int tobermory_hw_params(struct snd_pcm_substream *substream, static int tobermory_late_probe(struct snd_soc_card *card) { struct snd_soc_pcm_runtime *rtd; - struct snd_soc_codec *codec; + struct snd_soc_component *component; struct snd_soc_dai *codec_dai; int ret;
rtd = snd_soc_get_pcm_runtime(card, card->dai_link[0].name); - codec = rtd->codec; + component = rtd->codec_dai->component; codec_dai = rtd->codec_dai;
ret = snd_soc_dai_set_sysclk(codec_dai, WM8962_SYSCLK_MCLK, @@ -199,7 +199,7 @@ static int tobermory_late_probe(struct snd_soc_card *card) if (ret) return ret;
- wm8962_mic_detect(codec, &tobermory_headset); + wm8962_mic_detect(component, &tobermory_headset);
return 0; }
From: Kuninori Morimoto kuninori.morimoto.gx@renesas.com
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 -> .pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com --- sound/soc/codecs/wm8996.c | 401 +++++++++++++++++++++---------------------- sound/soc/codecs/wm8996.h | 4 +- sound/soc/samsung/speyside.c | 12 +- 3 files changed, 206 insertions(+), 211 deletions(-)
diff --git a/sound/soc/codecs/wm8996.c b/sound/soc/codecs/wm8996.c index 8affa49..f42e8e6 100644 --- a/sound/soc/codecs/wm8996.c +++ b/sound/soc/codecs/wm8996.c @@ -53,7 +53,7 @@ struct wm8996_priv { struct device *dev; struct regmap *regmap; - struct snd_soc_codec *codec; + struct snd_soc_component *component;
int ldo1ena;
@@ -335,9 +335,9 @@ static SOC_ENUM_SINGLE_DECL(dsp1tx_hpf_cutoff, static SOC_ENUM_SINGLE_DECL(dsp2tx_hpf_cutoff, WM8996_DSP2_TX_FILTERS, 0, hpf_cutoff_text);
-static void wm8996_set_retune_mobile(struct snd_soc_codec *codec, int block) +static void wm8996_set_retune_mobile(struct snd_soc_component *component, int block) { - struct wm8996_priv *wm8996 = snd_soc_codec_get_drvdata(codec); + struct wm8996_priv *wm8996 = snd_soc_component_get_drvdata(component); struct wm8996_pdata *pdata = &wm8996->pdata; int base, best, best_val, save, i, cfg, iface;
@@ -347,7 +347,7 @@ static void wm8996_set_retune_mobile(struct snd_soc_codec *codec, int block) switch (block) { case 0: base = WM8996_DSP1_RX_EQ_GAINS_1; - if (snd_soc_read(codec, WM8996_POWER_MANAGEMENT_8) & + if (snd_soc_component_read32(component, WM8996_POWER_MANAGEMENT_8) & WM8996_DSP1RX_SRC) iface = 1; else @@ -355,7 +355,7 @@ static void wm8996_set_retune_mobile(struct snd_soc_codec *codec, int block) break; case 1: base = WM8996_DSP1_RX_EQ_GAINS_2; - if (snd_soc_read(codec, WM8996_POWER_MANAGEMENT_8) & + if (snd_soc_component_read32(component, WM8996_POWER_MANAGEMENT_8) & WM8996_DSP2RX_SRC) iface = 1; else @@ -381,7 +381,7 @@ static void wm8996_set_retune_mobile(struct snd_soc_codec *codec, int block) } }
- dev_dbg(codec->dev, "ReTune Mobile %d %s/%dHz for %dHz sample rate\n", + dev_dbg(component->dev, "ReTune Mobile %d %s/%dHz for %dHz sample rate\n", block, pdata->retune_mobile_cfgs[best].name, pdata->retune_mobile_cfgs[best].rate, @@ -390,14 +390,14 @@ static void wm8996_set_retune_mobile(struct snd_soc_codec *codec, int block) /* The EQ will be disabled while reconfiguring it, remember the * current configuration. */ - save = snd_soc_read(codec, base); + save = snd_soc_component_read32(component, base); save &= WM8996_DSP1RX_EQ_ENA;
for (i = 0; i < ARRAY_SIZE(pdata->retune_mobile_cfgs[best].regs); i++) - snd_soc_update_bits(codec, base + i, 0xffff, + snd_soc_component_update_bits(component, base + i, 0xffff, pdata->retune_mobile_cfgs[best].regs[i]);
- snd_soc_update_bits(codec, base, WM8996_DSP1RX_EQ_ENA, save); + snd_soc_component_update_bits(component, base, WM8996_DSP1RX_EQ_ENA, save); }
/* Icky as hell but saves code duplication */ @@ -413,8 +413,8 @@ static int wm8996_get_retune_mobile_block(const char *name) static int wm8996_put_retune_mobile_enum(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct wm8996_priv *wm8996 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct wm8996_priv *wm8996 = snd_soc_component_get_drvdata(component); struct wm8996_pdata *pdata = &wm8996->pdata; int block = wm8996_get_retune_mobile_block(kcontrol->id.name); int value = ucontrol->value.enumerated.item[0]; @@ -427,7 +427,7 @@ static int wm8996_put_retune_mobile_enum(struct snd_kcontrol *kcontrol,
wm8996->retune_mobile_cfg[block] = value;
- wm8996_set_retune_mobile(codec, block); + wm8996_set_retune_mobile(component, block);
return 0; } @@ -435,8 +435,8 @@ static int wm8996_put_retune_mobile_enum(struct snd_kcontrol *kcontrol, static int wm8996_get_retune_mobile_enum(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct wm8996_priv *wm8996 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct wm8996_priv *wm8996 = snd_soc_component_get_drvdata(component); int block = wm8996_get_retune_mobile_block(kcontrol->id.name);
if (block < 0) @@ -575,40 +575,40 @@ static int wm8996_get_retune_mobile_enum(struct snd_kcontrol *kcontrol, eq_tlv), };
-static void wm8996_bg_enable(struct snd_soc_codec *codec) +static void wm8996_bg_enable(struct snd_soc_component *component) { - struct wm8996_priv *wm8996 = snd_soc_codec_get_drvdata(codec); + struct wm8996_priv *wm8996 = snd_soc_component_get_drvdata(component);
wm8996->bg_ena++; if (wm8996->bg_ena == 1) { - snd_soc_update_bits(codec, WM8996_POWER_MANAGEMENT_1, + snd_soc_component_update_bits(component, WM8996_POWER_MANAGEMENT_1, WM8996_BG_ENA, WM8996_BG_ENA); msleep(2); } }
-static void wm8996_bg_disable(struct snd_soc_codec *codec) +static void wm8996_bg_disable(struct snd_soc_component *component) { - struct wm8996_priv *wm8996 = snd_soc_codec_get_drvdata(codec); + struct wm8996_priv *wm8996 = snd_soc_component_get_drvdata(component);
wm8996->bg_ena--; if (!wm8996->bg_ena) - snd_soc_update_bits(codec, WM8996_POWER_MANAGEMENT_1, + snd_soc_component_update_bits(component, WM8996_POWER_MANAGEMENT_1, WM8996_BG_ENA, 0); }
static int bg_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); int ret = 0;
switch (event) { case SND_SOC_DAPM_PRE_PMU: - wm8996_bg_enable(codec); + wm8996_bg_enable(component); break; case SND_SOC_DAPM_POST_PMD: - wm8996_bg_disable(codec); + wm8996_bg_disable(component); break; default: WARN(1, "Invalid event %d\n", event); @@ -635,8 +635,8 @@ static int cp_event(struct snd_soc_dapm_widget *w, static int rmv_short_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); - struct wm8996_priv *wm8996 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); + struct wm8996_priv *wm8996 = snd_soc_component_get_drvdata(component);
/* Record which outputs we enabled */ switch (event) { @@ -654,14 +654,14 @@ static int rmv_short_event(struct snd_soc_dapm_widget *w, return 0; }
-static void wait_for_dc_servo(struct snd_soc_codec *codec, u16 mask) +static void wait_for_dc_servo(struct snd_soc_component *component, u16 mask) { - struct i2c_client *i2c = to_i2c_client(codec->dev); - struct wm8996_priv *wm8996 = snd_soc_codec_get_drvdata(codec); + struct i2c_client *i2c = to_i2c_client(component->dev); + struct wm8996_priv *wm8996 = snd_soc_component_get_drvdata(component); int ret; unsigned long timeout = 200;
- snd_soc_write(codec, WM8996_DC_SERVO_2, mask); + snd_soc_component_write(component, WM8996_DC_SERVO_2, mask);
/* Use the interrupt if possible */ do { @@ -669,44 +669,43 @@ static void wait_for_dc_servo(struct snd_soc_codec *codec, u16 mask) timeout = wait_for_completion_timeout(&wm8996->dcs_done, msecs_to_jiffies(200)); if (timeout == 0) - dev_err(codec->dev, "DC servo timed out\n"); + dev_err(component->dev, "DC servo timed out\n");
} else { msleep(1); timeout--; }
- ret = snd_soc_read(codec, WM8996_DC_SERVO_2); - dev_dbg(codec->dev, "DC servo state: %x\n", ret); + ret = snd_soc_component_read32(component, WM8996_DC_SERVO_2); + dev_dbg(component->dev, "DC servo state: %x\n", ret); } while (timeout && ret & mask);
if (timeout == 0) - dev_err(codec->dev, "DC servo timed out for %x\n", mask); + dev_err(component->dev, "DC servo timed out for %x\n", mask); else - dev_dbg(codec->dev, "DC servo complete for %x\n", mask); + dev_dbg(component->dev, "DC servo complete for %x\n", mask); }
-static void wm8996_seq_notifier(struct snd_soc_dapm_context *dapm, +static void wm8996_seq_notifier(struct snd_soc_component *component, enum snd_soc_dapm_type event, int subseq) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(dapm); - struct wm8996_priv *wm8996 = snd_soc_codec_get_drvdata(codec); + struct wm8996_priv *wm8996 = snd_soc_component_get_drvdata(component); u16 val, mask;
/* Complete any pending DC servo starts */ if (wm8996->dcs_pending) { - dev_dbg(codec->dev, "Starting DC servo for %x\n", + dev_dbg(component->dev, "Starting DC servo for %x\n", wm8996->dcs_pending);
/* Trigger a startup sequence */ - wait_for_dc_servo(codec, wm8996->dcs_pending + wait_for_dc_servo(component, wm8996->dcs_pending << WM8996_DCS_TRIG_STARTUP_0_SHIFT);
wm8996->dcs_pending = 0; }
if (wm8996->hpout_pending != wm8996->hpout_ena) { - dev_dbg(codec->dev, "Applying RMV_SHORTs %x->%x\n", + dev_dbg(component->dev, "Applying RMV_SHORTs %x->%x\n", wm8996->hpout_ena, wm8996->hpout_pending);
val = 0; @@ -729,7 +728,7 @@ static void wm8996_seq_notifier(struct snd_soc_dapm_context *dapm, WM8996_HPOUT1R_DLY; }
- snd_soc_update_bits(codec, WM8996_ANALOGUE_HP_1, mask, val); + snd_soc_component_update_bits(component, WM8996_ANALOGUE_HP_1, mask, val);
val = 0; mask = 0; @@ -751,7 +750,7 @@ static void wm8996_seq_notifier(struct snd_soc_dapm_context *dapm, WM8996_HPOUT2R_DLY; }
- snd_soc_update_bits(codec, WM8996_ANALOGUE_HP_2, mask, val); + snd_soc_component_update_bits(component, WM8996_ANALOGUE_HP_2, mask, val);
wm8996->hpout_ena = wm8996->hpout_pending; } @@ -760,8 +759,8 @@ static void wm8996_seq_notifier(struct snd_soc_dapm_context *dapm, static int dcs_start(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); - struct wm8996_priv *wm8996 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); + struct wm8996_priv *wm8996 = snd_soc_component_get_drvdata(component);
switch (event) { case SND_SOC_DAPM_POST_PMU: @@ -1533,9 +1532,9 @@ static bool wm8996_volatile_register(struct device *dev, unsigned int reg) 1, 2, 3, 4, 6, 8, 12, 16, 24, 32, 48, 64, 96 };
-static void wm8996_update_bclk(struct snd_soc_codec *codec) +static void wm8996_update_bclk(struct snd_soc_component *component) { - struct wm8996_priv *wm8996 = snd_soc_codec_get_drvdata(codec); + struct wm8996_priv *wm8996 = snd_soc_component_get_drvdata(component); int aif, best, cur_val, bclk_rate, bclk_reg, i;
/* Don't bother if we're in a low frequency idle mode that @@ -1565,18 +1564,18 @@ static void wm8996_update_bclk(struct snd_soc_codec *codec) best = i; } bclk_rate = wm8996->sysclk / bclk_divs[best]; - dev_dbg(codec->dev, "Using BCLK_DIV %d for actual BCLK %dHz\n", + dev_dbg(component->dev, "Using BCLK_DIV %d for actual BCLK %dHz\n", bclk_divs[best], bclk_rate);
- snd_soc_update_bits(codec, bclk_reg, + snd_soc_component_update_bits(component, bclk_reg, WM8996_AIF1_BCLK_DIV_MASK, best); } }
-static int wm8996_set_bias_level(struct snd_soc_codec *codec, +static int wm8996_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { - struct wm8996_priv *wm8996 = snd_soc_codec_get_drvdata(codec); + struct wm8996_priv *wm8996 = snd_soc_component_get_drvdata(component); int ret;
switch (level) { @@ -1584,18 +1583,18 @@ static int wm8996_set_bias_level(struct snd_soc_codec *codec, break; case SND_SOC_BIAS_PREPARE: /* Put the MICBIASes into regulating mode */ - snd_soc_update_bits(codec, WM8996_MICBIAS_1, + snd_soc_component_update_bits(component, WM8996_MICBIAS_1, WM8996_MICB1_MODE, 0); - snd_soc_update_bits(codec, WM8996_MICBIAS_2, + snd_soc_component_update_bits(component, WM8996_MICBIAS_2, WM8996_MICB2_MODE, 0); break;
case SND_SOC_BIAS_STANDBY: - if (snd_soc_codec_get_bias_level(codec) == SND_SOC_BIAS_OFF) { + if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_OFF) { ret = regulator_bulk_enable(ARRAY_SIZE(wm8996->supplies), wm8996->supplies); if (ret != 0) { - dev_err(codec->dev, + dev_err(component->dev, "Failed to enable supplies: %d\n", ret); return ret; @@ -1612,9 +1611,9 @@ static int wm8996_set_bias_level(struct snd_soc_codec *codec, }
/* Bypass the MICBIASes for lowest power */ - snd_soc_update_bits(codec, WM8996_MICBIAS_1, + snd_soc_component_update_bits(component, WM8996_MICBIAS_1, WM8996_MICB1_MODE, WM8996_MICB1_MODE); - snd_soc_update_bits(codec, WM8996_MICBIAS_2, + snd_soc_component_update_bits(component, WM8996_MICBIAS_2, WM8996_MICB2_MODE, WM8996_MICB2_MODE); break;
@@ -1634,7 +1633,7 @@ static int wm8996_set_bias_level(struct snd_soc_codec *codec,
static int wm8996_set_fmt(struct snd_soc_dai *dai, unsigned int fmt) { - struct snd_soc_codec *codec = dai->codec; + struct snd_soc_component *component = dai->component; int aifctrl = 0; int bclk = 0; int lrclk_tx = 0; @@ -1711,15 +1710,15 @@ static int wm8996_set_fmt(struct snd_soc_dai *dai, unsigned int fmt) return -EINVAL; }
- snd_soc_update_bits(codec, aifctrl_reg, WM8996_AIF1_FMT_MASK, aifctrl); - snd_soc_update_bits(codec, bclk_reg, + snd_soc_component_update_bits(component, aifctrl_reg, WM8996_AIF1_FMT_MASK, aifctrl); + snd_soc_component_update_bits(component, bclk_reg, WM8996_AIF1_BCLK_INV | WM8996_AIF1_BCLK_MSTR, bclk); - snd_soc_update_bits(codec, lrclk_tx_reg, + snd_soc_component_update_bits(component, lrclk_tx_reg, WM8996_AIF1TX_LRCLK_INV | WM8996_AIF1TX_LRCLK_MSTR, lrclk_tx); - snd_soc_update_bits(codec, lrclk_rx_reg, + snd_soc_component_update_bits(component, lrclk_rx_reg, WM8996_AIF1RX_LRCLK_INV | WM8996_AIF1RX_LRCLK_MSTR, lrclk_rx); @@ -1735,8 +1734,8 @@ static int wm8996_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; - struct wm8996_priv *wm8996 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct wm8996_priv *wm8996 = snd_soc_component_get_drvdata(component); int bits, i, bclk_rate, best; int aifdata = 0; int lrclk = 0; @@ -1746,7 +1745,7 @@ static int wm8996_hw_params(struct snd_pcm_substream *substream, switch (dai->id) { case 0: if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK || - (snd_soc_read(codec, WM8996_GPIO_1)) & WM8996_GP1_FN_MASK) { + (snd_soc_component_read32(component, WM8996_GPIO_1)) & WM8996_GP1_FN_MASK) { aifdata_reg = WM8996_AIF1RX_DATA_CONFIGURATION; lrclk_reg = WM8996_AIF1_RX_LRCLK_1; } else { @@ -1757,7 +1756,7 @@ static int wm8996_hw_params(struct snd_pcm_substream *substream, break; case 1: if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK || - (snd_soc_read(codec, WM8996_GPIO_2)) & WM8996_GP2_FN_MASK) { + (snd_soc_component_read32(component, WM8996_GPIO_2)) & WM8996_GP2_FN_MASK) { aifdata_reg = WM8996_AIF2RX_DATA_CONFIGURATION; lrclk_reg = WM8996_AIF2_RX_LRCLK_1; } else { @@ -1773,7 +1772,7 @@ static int wm8996_hw_params(struct snd_pcm_substream *substream,
bclk_rate = snd_soc_params_to_bclk(params); if (bclk_rate < 0) { - dev_err(codec->dev, "Unsupported BCLK rate: %d\n", bclk_rate); + dev_err(component->dev, "Unsupported BCLK rate: %d\n", bclk_rate); return bclk_rate; }
@@ -1794,19 +1793,19 @@ static int wm8996_hw_params(struct snd_pcm_substream *substream, } dsp |= i << dsp_shift;
- wm8996_update_bclk(codec); + wm8996_update_bclk(component);
lrclk = bclk_rate / params_rate(params); dev_dbg(dai->dev, "Using LRCLK rate %d for actual LRCLK %dHz\n", lrclk, bclk_rate / lrclk);
- snd_soc_update_bits(codec, aifdata_reg, + snd_soc_component_update_bits(component, aifdata_reg, WM8996_AIF1TX_WL_MASK | WM8996_AIF1TX_SLOT_LEN_MASK, aifdata); - snd_soc_update_bits(codec, lrclk_reg, WM8996_AIF1RX_RATE_MASK, + snd_soc_component_update_bits(component, lrclk_reg, WM8996_AIF1RX_RATE_MASK, lrclk); - snd_soc_update_bits(codec, WM8996_AIF_CLOCKING_2, + snd_soc_component_update_bits(component, WM8996_AIF_CLOCKING_2, WM8996_DSP1_DIV_MASK << dsp_shift, dsp);
return 0; @@ -1815,8 +1814,8 @@ static int wm8996_hw_params(struct snd_pcm_substream *substream, static int wm8996_set_sysclk(struct snd_soc_dai *dai, int clk_id, unsigned int freq, int dir) { - struct snd_soc_codec *codec = dai->codec; - struct wm8996_priv *wm8996 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct wm8996_priv *wm8996 = snd_soc_component_get_drvdata(component); int lfclk = 0; int ratediv = 0; int sync = WM8996_REG_SYNC; @@ -1827,8 +1826,8 @@ static int wm8996_set_sysclk(struct snd_soc_dai *dai, return 0;
/* Disable SYSCLK while we reconfigure */ - old = snd_soc_read(codec, WM8996_AIF_CLOCKING_1) & WM8996_SYSCLK_ENA; - snd_soc_update_bits(codec, WM8996_AIF_CLOCKING_1, + old = snd_soc_component_read32(component, WM8996_AIF_CLOCKING_1) & WM8996_SYSCLK_ENA; + snd_soc_component_update_bits(component, WM8996_AIF_CLOCKING_1, WM8996_SYSCLK_ENA, 0);
switch (clk_id) { @@ -1845,14 +1844,14 @@ static int wm8996_set_sysclk(struct snd_soc_dai *dai, src = 2; break; default: - dev_err(codec->dev, "Unsupported clock source %d\n", clk_id); + dev_err(component->dev, "Unsupported clock source %d\n", clk_id); return -EINVAL; }
switch (wm8996->sysclk) { case 5644800: case 6144000: - snd_soc_update_bits(codec, WM8996_AIF_RATE, + snd_soc_component_update_bits(component, WM8996_AIF_RATE, WM8996_SYSCLK_RATE, 0); break; case 22579200: @@ -1861,7 +1860,7 @@ static int wm8996_set_sysclk(struct snd_soc_dai *dai, wm8996->sysclk /= 2; case 11289600: case 12288000: - snd_soc_update_bits(codec, WM8996_AIF_RATE, + snd_soc_component_update_bits(component, WM8996_AIF_RATE, WM8996_SYSCLK_RATE, WM8996_SYSCLK_RATE); break; case 32000: @@ -1870,20 +1869,20 @@ static int wm8996_set_sysclk(struct snd_soc_dai *dai, sync = 0; break; default: - dev_warn(codec->dev, "Unsupported clock rate %dHz\n", + dev_warn(component->dev, "Unsupported clock rate %dHz\n", wm8996->sysclk); return -EINVAL; }
- wm8996_update_bclk(codec); + wm8996_update_bclk(component);
- snd_soc_update_bits(codec, WM8996_AIF_CLOCKING_1, + snd_soc_component_update_bits(component, WM8996_AIF_CLOCKING_1, WM8996_SYSCLK_SRC_MASK | WM8996_SYSCLK_DIV_MASK, src << WM8996_SYSCLK_SRC_SHIFT | ratediv); - snd_soc_update_bits(codec, WM8996_CLOCKING_1, WM8996_LFCLK_ENA, lfclk); - snd_soc_update_bits(codec, WM8996_CONTROL_INTERFACE_1, + snd_soc_component_update_bits(component, WM8996_CLOCKING_1, WM8996_LFCLK_ENA, lfclk); + snd_soc_component_update_bits(component, WM8996_CONTROL_INTERFACE_1, WM8996_REG_SYNC, sync); - snd_soc_update_bits(codec, WM8996_AIF_CLOCKING_1, + snd_soc_component_update_bits(component, WM8996_AIF_CLOCKING_1, WM8996_SYSCLK_ENA, old);
wm8996->sysclk_src = clk_id; @@ -2002,11 +2001,11 @@ static int fll_factors(struct _fll_div *fll_div, unsigned int Fref, return 0; }
-static int wm8996_set_fll(struct snd_soc_codec *codec, int fll_id, int source, +static int wm8996_set_fll(struct snd_soc_component *component, int fll_id, int source, unsigned int Fref, unsigned int Fout) { - struct wm8996_priv *wm8996 = snd_soc_codec_get_drvdata(codec); - struct i2c_client *i2c = to_i2c_client(codec->dev); + struct wm8996_priv *wm8996 = snd_soc_component_get_drvdata(component); + struct i2c_client *i2c = to_i2c_client(component->dev); struct _fll_div fll_div; unsigned long timeout, time_left; int ret, reg, retry; @@ -2017,15 +2016,15 @@ static int wm8996_set_fll(struct snd_soc_codec *codec, int fll_id, int source, return 0;
if (Fout == 0) { - dev_dbg(codec->dev, "FLL disabled\n"); + dev_dbg(component->dev, "FLL disabled\n");
wm8996->fll_fref = 0; wm8996->fll_fout = 0;
- snd_soc_update_bits(codec, WM8996_FLL_CONTROL_1, + snd_soc_component_update_bits(component, WM8996_FLL_CONTROL_1, WM8996_FLL_ENA, 0);
- wm8996_bg_disable(codec); + wm8996_bg_disable(component);
return 0; } @@ -2048,14 +2047,14 @@ static int wm8996_set_fll(struct snd_soc_codec *codec, int fll_id, int source, reg = 3; break; default: - dev_err(codec->dev, "Unknown FLL source %d\n", ret); + dev_err(component->dev, "Unknown FLL source %d\n", ret); return -EINVAL; }
reg |= fll_div.fll_refclk_div << WM8996_FLL_REFCLK_DIV_SHIFT; reg |= fll_div.fll_ref_freq << WM8996_FLL_REF_FREQ_SHIFT;
- snd_soc_update_bits(codec, WM8996_FLL_CONTROL_5, + snd_soc_component_update_bits(component, WM8996_FLL_CONTROL_5, WM8996_FLL_REFCLK_DIV_MASK | WM8996_FLL_REF_FREQ | WM8996_FLL_REFCLK_SRC_MASK, reg);
@@ -2064,38 +2063,38 @@ static int wm8996_set_fll(struct snd_soc_codec *codec, int fll_id, int source, reg |= WM8996_FLL_EFS_ENA | (3 << WM8996_FLL_LFSR_SEL_SHIFT); else reg |= 1 << WM8996_FLL_LFSR_SEL_SHIFT; - snd_soc_write(codec, WM8996_FLL_EFS_2, reg); + snd_soc_component_write(component, WM8996_FLL_EFS_2, reg);
- snd_soc_update_bits(codec, WM8996_FLL_CONTROL_2, + snd_soc_component_update_bits(component, WM8996_FLL_CONTROL_2, WM8996_FLL_OUTDIV_MASK | WM8996_FLL_FRATIO_MASK, (fll_div.fll_outdiv << WM8996_FLL_OUTDIV_SHIFT) | (fll_div.fll_fratio));
- snd_soc_write(codec, WM8996_FLL_CONTROL_3, fll_div.theta); + snd_soc_component_write(component, WM8996_FLL_CONTROL_3, fll_div.theta);
- snd_soc_update_bits(codec, WM8996_FLL_CONTROL_4, + snd_soc_component_update_bits(component, WM8996_FLL_CONTROL_4, WM8996_FLL_N_MASK | WM8996_FLL_LOOP_GAIN_MASK, (fll_div.n << WM8996_FLL_N_SHIFT) | fll_div.fll_loop_gain);
- snd_soc_write(codec, WM8996_FLL_EFS_1, fll_div.lambda); + snd_soc_component_write(component, WM8996_FLL_EFS_1, fll_div.lambda);
/* Enable the bandgap if it's not already enabled */ - ret = snd_soc_read(codec, WM8996_FLL_CONTROL_1); + ret = snd_soc_component_read32(component, WM8996_FLL_CONTROL_1); if (!(ret & WM8996_FLL_ENA)) - wm8996_bg_enable(codec); + wm8996_bg_enable(component);
/* Clear any pending completions (eg, from failed startups) */ try_wait_for_completion(&wm8996->fll_lock);
- snd_soc_update_bits(codec, WM8996_FLL_CONTROL_1, + snd_soc_component_update_bits(component, WM8996_FLL_CONTROL_1, WM8996_FLL_ENA, WM8996_FLL_ENA);
/* The FLL supports live reconfiguration - kick that in case we were * already enabled. */ - snd_soc_write(codec, WM8996_FLL_CONTROL_6, WM8996_FLL_SWITCH_CLK); + snd_soc_component_write(component, WM8996_FLL_CONTROL_6, WM8996_FLL_SWITCH_CLK);
/* Wait for the FLL to lock, using the interrupt if possible */ if (Fref > 1000000) @@ -2121,16 +2120,16 @@ static int wm8996_set_fll(struct snd_soc_codec *codec, int fll_id, int source, break; }
- ret = snd_soc_read(codec, WM8996_INTERRUPT_RAW_STATUS_2); + ret = snd_soc_component_read32(component, WM8996_INTERRUPT_RAW_STATUS_2); if (ret & WM8996_FLL_LOCK_STS) break; } if (retry == 10) { - dev_err(codec->dev, "Timed out waiting for FLL\n"); + dev_err(component->dev, "Timed out waiting for FLL\n"); ret = -ETIMEDOUT; }
- dev_dbg(codec->dev, "FLL configured for %dHz->%dHz\n", Fref, Fout); + dev_dbg(component->dev, "FLL configured for %dHz->%dHz\n", Fref, Fout);
wm8996->fll_fref = Fref; wm8996->fll_fout = Fout; @@ -2237,11 +2236,11 @@ static void wm8996_free_gpio(struct wm8996_priv *wm8996) * will also detect inverted microphone ground connections and update * the polarity of the connections. */ -int wm8996_detect(struct snd_soc_codec *codec, struct snd_soc_jack *jack, +int wm8996_detect(struct snd_soc_component *component, struct snd_soc_jack *jack, wm8996_polarity_fn polarity_cb) { - struct wm8996_priv *wm8996 = snd_soc_codec_get_drvdata(codec); - struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec); + struct wm8996_priv *wm8996 = snd_soc_component_get_drvdata(component); + struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component);
wm8996->jack = jack; wm8996->detecting = true; @@ -2249,12 +2248,12 @@ int wm8996_detect(struct snd_soc_codec *codec, struct snd_soc_jack *jack, wm8996->jack_flips = 0;
if (wm8996->polarity_cb) - wm8996->polarity_cb(codec, 0); + wm8996->polarity_cb(component, 0);
/* Clear discarge to avoid noise during detection */ - snd_soc_update_bits(codec, WM8996_MICBIAS_1, + snd_soc_component_update_bits(component, WM8996_MICBIAS_1, WM8996_MICB1_DISCH, 0); - snd_soc_update_bits(codec, WM8996_MICBIAS_2, + snd_soc_component_update_bits(component, WM8996_MICBIAS_2, WM8996_MICB2_DISCH, 0);
/* LDO2 powers the microphones, SYSCLK clocks detection */ @@ -2268,26 +2267,26 @@ int wm8996_detect(struct snd_soc_codec *codec, struct snd_soc_jack *jack, /* We start off just enabling microphone detection - even a * plain headphone will trigger detection. */ - snd_soc_update_bits(codec, WM8996_MIC_DETECT_1, + snd_soc_component_update_bits(component, WM8996_MIC_DETECT_1, WM8996_MICD_ENA, WM8996_MICD_ENA);
/* Slowest detection rate, gives debounce for initial detection */ - snd_soc_update_bits(codec, WM8996_MIC_DETECT_1, + snd_soc_component_update_bits(component, WM8996_MIC_DETECT_1, WM8996_MICD_RATE_MASK, WM8996_MICD_RATE_MASK);
/* Enable interrupts and we're off */ - snd_soc_update_bits(codec, WM8996_INTERRUPT_STATUS_2_MASK, + snd_soc_component_update_bits(component, WM8996_INTERRUPT_STATUS_2_MASK, WM8996_IM_MICD_EINT | WM8996_HP_DONE_EINT, 0);
return 0; } EXPORT_SYMBOL_GPL(wm8996_detect);
-static void wm8996_hpdet_irq(struct snd_soc_codec *codec) +static void wm8996_hpdet_irq(struct snd_soc_component *component) { - struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec); - struct wm8996_priv *wm8996 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); + struct wm8996_priv *wm8996 = snd_soc_component_get_drvdata(component); int val, reg, report;
/* Assume headphone in error conditions; we need to report @@ -2295,20 +2294,20 @@ static void wm8996_hpdet_irq(struct snd_soc_codec *codec) */ report = SND_JACK_HEADPHONE;
- reg = snd_soc_read(codec, WM8996_HEADPHONE_DETECT_2); + reg = snd_soc_component_read32(component, WM8996_HEADPHONE_DETECT_2); if (reg < 0) { - dev_err(codec->dev, "Failed to read HPDET status\n"); + dev_err(component->dev, "Failed to read HPDET status\n"); goto out; }
if (!(reg & WM8996_HP_DONE)) { - dev_err(codec->dev, "Got HPDET IRQ but HPDET is busy\n"); + dev_err(component->dev, "Got HPDET IRQ but HPDET is busy\n"); goto out; }
val = reg & WM8996_HP_LVL_MASK;
- dev_dbg(codec->dev, "HPDET measured %d ohms\n", val); + dev_dbg(component->dev, "HPDET measured %d ohms\n", val);
/* If we've got high enough impedence then report as line, * otherwise assume headphone. @@ -2328,28 +2327,28 @@ static void wm8996_hpdet_irq(struct snd_soc_codec *codec) wm8996->detecting = false;
/* If the output isn't running re-clamp it */ - if (!(snd_soc_read(codec, WM8996_POWER_MANAGEMENT_1) & + if (!(snd_soc_component_read32(component, WM8996_POWER_MANAGEMENT_1) & (WM8996_HPOUT1L_ENA | WM8996_HPOUT1R_RMV_SHORT))) - snd_soc_update_bits(codec, WM8996_ANALOGUE_HP_1, + snd_soc_component_update_bits(component, WM8996_ANALOGUE_HP_1, WM8996_HPOUT1L_RMV_SHORT | WM8996_HPOUT1R_RMV_SHORT, 0);
/* Go back to looking at the microphone */ - snd_soc_update_bits(codec, WM8996_ACCESSORY_DETECT_MODE_1, + snd_soc_component_update_bits(component, WM8996_ACCESSORY_DETECT_MODE_1, WM8996_JD_MODE_MASK, 0); - snd_soc_update_bits(codec, WM8996_MIC_DETECT_1, WM8996_MICD_ENA, + snd_soc_component_update_bits(component, WM8996_MIC_DETECT_1, WM8996_MICD_ENA, WM8996_MICD_ENA);
snd_soc_dapm_disable_pin(dapm, "Bandgap"); snd_soc_dapm_sync(dapm); }
-static void wm8996_hpdet_start(struct snd_soc_codec *codec) +static void wm8996_hpdet_start(struct snd_soc_component *component) { - struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec); + struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component);
/* Unclamp the output, we can't measure while we're shorting it */ - snd_soc_update_bits(codec, WM8996_ANALOGUE_HP_1, + snd_soc_component_update_bits(component, WM8996_ANALOGUE_HP_1, WM8996_HPOUT1L_RMV_SHORT | WM8996_HPOUT1R_RMV_SHORT, WM8996_HPOUT1L_RMV_SHORT | @@ -2360,45 +2359,45 @@ static void wm8996_hpdet_start(struct snd_soc_codec *codec) snd_soc_dapm_sync(dapm);
/* Go into headphone detect left mode */ - snd_soc_update_bits(codec, WM8996_MIC_DETECT_1, WM8996_MICD_ENA, 0); - snd_soc_update_bits(codec, WM8996_ACCESSORY_DETECT_MODE_1, + snd_soc_component_update_bits(component, WM8996_MIC_DETECT_1, WM8996_MICD_ENA, 0); + snd_soc_component_update_bits(component, WM8996_ACCESSORY_DETECT_MODE_1, WM8996_JD_MODE_MASK, 1);
/* Trigger a measurement */ - snd_soc_update_bits(codec, WM8996_HEADPHONE_DETECT_1, + snd_soc_component_update_bits(component, WM8996_HEADPHONE_DETECT_1, WM8996_HP_POLL, WM8996_HP_POLL); }
-static void wm8996_report_headphone(struct snd_soc_codec *codec) +static void wm8996_report_headphone(struct snd_soc_component *component) { - dev_dbg(codec->dev, "Headphone detected\n"); - wm8996_hpdet_start(codec); + dev_dbg(component->dev, "Headphone detected\n"); + wm8996_hpdet_start(component);
/* Increase the detection rate a bit for responsiveness. */ - snd_soc_update_bits(codec, WM8996_MIC_DETECT_1, + snd_soc_component_update_bits(component, WM8996_MIC_DETECT_1, WM8996_MICD_RATE_MASK | WM8996_MICD_BIAS_STARTTIME_MASK, 7 << WM8996_MICD_RATE_SHIFT | 7 << WM8996_MICD_BIAS_STARTTIME_SHIFT); }
-static void wm8996_micd(struct snd_soc_codec *codec) +static void wm8996_micd(struct snd_soc_component *component) { - struct wm8996_priv *wm8996 = snd_soc_codec_get_drvdata(codec); + struct wm8996_priv *wm8996 = snd_soc_component_get_drvdata(component); int val, reg;
- val = snd_soc_read(codec, WM8996_MIC_DETECT_3); + val = snd_soc_component_read32(component, WM8996_MIC_DETECT_3);
- dev_dbg(codec->dev, "Microphone event: %x\n", val); + dev_dbg(component->dev, "Microphone event: %x\n", val);
if (!(val & WM8996_MICD_VALID)) { - dev_warn(codec->dev, "Microphone detection state invalid\n"); + dev_warn(component->dev, "Microphone detection state invalid\n"); return; }
/* No accessory, reset everything and report removal */ if (!(val & WM8996_MICD_STS)) { - dev_dbg(codec->dev, "Jack removal detected\n"); + dev_dbg(component->dev, "Jack removal detected\n"); wm8996->jack_mic = false; wm8996->detecting = true; wm8996->jack_flips = 0; @@ -2406,7 +2405,7 @@ static void wm8996_micd(struct snd_soc_codec *codec) SND_JACK_LINEOUT | SND_JACK_HEADSET | SND_JACK_BTN_0);
- snd_soc_update_bits(codec, WM8996_MIC_DETECT_1, + snd_soc_component_update_bits(component, WM8996_MIC_DETECT_1, WM8996_MICD_RATE_MASK | WM8996_MICD_BIAS_STARTTIME_MASK, WM8996_MICD_RATE_MASK | @@ -2420,19 +2419,19 @@ static void wm8996_micd(struct snd_soc_codec *codec) */ if (val & 0x400) { if (wm8996->detecting) { - dev_dbg(codec->dev, "Microphone detected\n"); + dev_dbg(component->dev, "Microphone detected\n"); wm8996->jack_mic = true; - wm8996_hpdet_start(codec); + wm8996_hpdet_start(component);
/* Increase poll rate to give better responsiveness * for buttons */ - snd_soc_update_bits(codec, WM8996_MIC_DETECT_1, + snd_soc_component_update_bits(component, WM8996_MIC_DETECT_1, WM8996_MICD_RATE_MASK | WM8996_MICD_BIAS_STARTTIME_MASK, 5 << WM8996_MICD_RATE_SHIFT | 7 << WM8996_MICD_BIAS_STARTTIME_SHIFT); } else { - dev_dbg(codec->dev, "Mic button up\n"); + dev_dbg(component->dev, "Mic button up\n"); snd_soc_jack_report(wm8996->jack, 0, SND_JACK_BTN_0); }
@@ -2449,22 +2448,22 @@ static void wm8996_micd(struct snd_soc_codec *codec) wm8996->jack_flips++;
if (wm8996->jack_flips > 1) { - wm8996_report_headphone(codec); + wm8996_report_headphone(component); return; }
- reg = snd_soc_read(codec, WM8996_ACCESSORY_DETECT_MODE_2); + reg = snd_soc_component_read32(component, WM8996_ACCESSORY_DETECT_MODE_2); reg ^= WM8996_HPOUT1FB_SRC | WM8996_MICD_SRC | WM8996_MICD_BIAS_SRC; - snd_soc_update_bits(codec, WM8996_ACCESSORY_DETECT_MODE_2, + snd_soc_component_update_bits(component, WM8996_ACCESSORY_DETECT_MODE_2, WM8996_HPOUT1FB_SRC | WM8996_MICD_SRC | WM8996_MICD_BIAS_SRC, reg);
if (wm8996->polarity_cb) - wm8996->polarity_cb(codec, + wm8996->polarity_cb(component, (reg & WM8996_MICD_SRC) != 0);
- dev_dbg(codec->dev, "Set microphone polarity to %d\n", + dev_dbg(component->dev, "Set microphone polarity to %d\n", (reg & WM8996_MICD_SRC) != 0);
return; @@ -2475,52 +2474,52 @@ static void wm8996_micd(struct snd_soc_codec *codec) */ if (val & 0x3fc) { if (wm8996->jack_mic) { - dev_dbg(codec->dev, "Mic button detected\n"); + dev_dbg(component->dev, "Mic button detected\n"); snd_soc_jack_report(wm8996->jack, SND_JACK_BTN_0, SND_JACK_BTN_0); } else if (wm8996->detecting) { - wm8996_report_headphone(codec); + wm8996_report_headphone(component); } } }
static irqreturn_t wm8996_irq(int irq, void *data) { - struct snd_soc_codec *codec = data; - struct wm8996_priv *wm8996 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = data; + struct wm8996_priv *wm8996 = snd_soc_component_get_drvdata(component); int irq_val;
- irq_val = snd_soc_read(codec, WM8996_INTERRUPT_STATUS_2); + irq_val = snd_soc_component_read32(component, WM8996_INTERRUPT_STATUS_2); if (irq_val < 0) { - dev_err(codec->dev, "Failed to read IRQ status: %d\n", + dev_err(component->dev, "Failed to read IRQ status: %d\n", irq_val); return IRQ_NONE; } - irq_val &= ~snd_soc_read(codec, WM8996_INTERRUPT_STATUS_2_MASK); + irq_val &= ~snd_soc_component_read32(component, WM8996_INTERRUPT_STATUS_2_MASK);
if (!irq_val) return IRQ_NONE;
- snd_soc_write(codec, WM8996_INTERRUPT_STATUS_2, irq_val); + snd_soc_component_write(component, WM8996_INTERRUPT_STATUS_2, irq_val);
if (irq_val & (WM8996_DCS_DONE_01_EINT | WM8996_DCS_DONE_23_EINT)) { - dev_dbg(codec->dev, "DC servo IRQ\n"); + dev_dbg(component->dev, "DC servo IRQ\n"); complete(&wm8996->dcs_done); }
if (irq_val & WM8996_FIFOS_ERR_EINT) - dev_err(codec->dev, "Digital core FIFO error\n"); + dev_err(component->dev, "Digital core FIFO error\n");
if (irq_val & WM8996_FLL_LOCK_EINT) { - dev_dbg(codec->dev, "FLL locked\n"); + dev_dbg(component->dev, "FLL locked\n"); complete(&wm8996->fll_lock); }
if (irq_val & WM8996_MICD_EINT) - wm8996_micd(codec); + wm8996_micd(component);
if (irq_val & WM8996_HP_DONE_EINT) - wm8996_hpdet_irq(codec); + wm8996_hpdet_irq(component);
return IRQ_HANDLED; } @@ -2539,9 +2538,9 @@ static irqreturn_t wm8996_edge_irq(int irq, void *data) return ret; }
-static void wm8996_retune_mobile_pdata(struct snd_soc_codec *codec) +static void wm8996_retune_mobile_pdata(struct snd_soc_component *component) { - struct wm8996_priv *wm8996 = snd_soc_codec_get_drvdata(codec); + struct wm8996_priv *wm8996 = snd_soc_component_get_drvdata(component); struct wm8996_pdata *pdata = &wm8996->pdata;
struct snd_kcontrol_new controls[] = { @@ -2590,15 +2589,15 @@ static void wm8996_retune_mobile_pdata(struct snd_soc_codec *codec) wm8996->retune_mobile_texts = t; }
- dev_dbg(codec->dev, "Allocated %d unique ReTune Mobile names\n", + dev_dbg(component->dev, "Allocated %d unique ReTune Mobile names\n", wm8996->num_retune_mobile_texts);
wm8996->retune_mobile_enum.items = wm8996->num_retune_mobile_texts; wm8996->retune_mobile_enum.texts = wm8996->retune_mobile_texts;
- ret = snd_soc_add_codec_controls(codec, controls, ARRAY_SIZE(controls)); + ret = snd_soc_add_component_controls(component, controls, ARRAY_SIZE(controls)); if (ret != 0) - dev_err(codec->dev, + dev_err(component->dev, "Failed to add ReTune Mobile controls: %d\n", ret); }
@@ -2614,22 +2613,22 @@ static void wm8996_retune_mobile_pdata(struct snd_soc_codec *codec) .cache_type = REGCACHE_RBTREE, };
-static int wm8996_probe(struct snd_soc_codec *codec) +static int wm8996_probe(struct snd_soc_component *component) { int ret; - struct wm8996_priv *wm8996 = snd_soc_codec_get_drvdata(codec); - struct i2c_client *i2c = to_i2c_client(codec->dev); + struct wm8996_priv *wm8996 = snd_soc_component_get_drvdata(component); + struct i2c_client *i2c = to_i2c_client(component->dev); int irq_flags;
- wm8996->codec = codec; + wm8996->component = component;
init_completion(&wm8996->dcs_done); init_completion(&wm8996->fll_lock);
if (wm8996->pdata.num_retune_mobile_cfgs) - wm8996_retune_mobile_pdata(codec); + wm8996_retune_mobile_pdata(component); else - snd_soc_add_codec_controls(codec, wm8996_eq_controls, + snd_soc_add_component_controls(component, wm8996_eq_controls, ARRAY_SIZE(wm8996_eq_controls));
if (i2c->irq) { @@ -2643,18 +2642,18 @@ static int wm8996_probe(struct snd_soc_codec *codec) if (irq_flags & (IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING)) ret = request_threaded_irq(i2c->irq, NULL, wm8996_edge_irq, - irq_flags, "wm8996", codec); + irq_flags, "wm8996", component); else ret = request_threaded_irq(i2c->irq, NULL, wm8996_irq, - irq_flags, "wm8996", codec); + irq_flags, "wm8996", component);
if (ret == 0) { /* Unmask the interrupt */ - snd_soc_update_bits(codec, WM8996_INTERRUPT_CONTROL, + snd_soc_component_update_bits(component, WM8996_INTERRUPT_CONTROL, WM8996_IM_IRQ, 0);
/* Enable error reporting and DC servo status */ - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, WM8996_INTERRUPT_STATUS_2_MASK, WM8996_IM_DCS_DONE_23_EINT | WM8996_IM_DCS_DONE_01_EINT | @@ -2662,7 +2661,7 @@ static int wm8996_probe(struct snd_soc_codec *codec) WM8996_IM_FIFOS_ERR_EINT, 0); } else { - dev_err(codec->dev, "Failed to request IRQ: %d\n", + dev_err(component->dev, "Failed to request IRQ: %d\n", ret); return ret; } @@ -2671,34 +2670,33 @@ static int wm8996_probe(struct snd_soc_codec *codec) return 0; }
-static int wm8996_remove(struct snd_soc_codec *codec) +static void wm8996_remove(struct snd_soc_component *component) { - struct i2c_client *i2c = to_i2c_client(codec->dev); + struct i2c_client *i2c = to_i2c_client(component->dev);
- snd_soc_update_bits(codec, WM8996_INTERRUPT_CONTROL, + snd_soc_component_update_bits(component, WM8996_INTERRUPT_CONTROL, WM8996_IM_IRQ, WM8996_IM_IRQ);
if (i2c->irq) - free_irq(i2c->irq, codec); - - return 0; + free_irq(i2c->irq, component); }
-static const struct snd_soc_codec_driver soc_codec_dev_wm8996 = { - .probe = wm8996_probe, - .remove = wm8996_remove, - .set_bias_level = wm8996_set_bias_level, - .idle_bias_off = true, - .seq_notifier = wm8996_seq_notifier, - .component_driver = { - .controls = wm8996_snd_controls, - .num_controls = ARRAY_SIZE(wm8996_snd_controls), - .dapm_widgets = wm8996_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(wm8996_dapm_widgets), - .dapm_routes = wm8996_dapm_routes, - .num_dapm_routes = ARRAY_SIZE(wm8996_dapm_routes), - }, - .set_pll = wm8996_set_fll, +static const struct snd_soc_component_driver soc_component_dev_wm8996 = { + .probe = wm8996_probe, + .remove = wm8996_remove, + .set_bias_level = wm8996_set_bias_level, + .seq_notifier = wm8996_seq_notifier, + .controls = wm8996_snd_controls, + .num_controls = ARRAY_SIZE(wm8996_snd_controls), + .dapm_widgets = wm8996_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(wm8996_dapm_widgets), + .dapm_routes = wm8996_dapm_routes, + .num_dapm_routes = ARRAY_SIZE(wm8996_dapm_routes), + .set_pll = wm8996_set_fll, + .pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, + };
#define WM8996_RATES (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |\ @@ -3046,8 +3044,8 @@ static int wm8996_i2c_probe(struct i2c_client *i2c,
wm8996_init_gpio(wm8996);
- ret = snd_soc_register_codec(&i2c->dev, - &soc_codec_dev_wm8996, wm8996_dai, + ret = devm_snd_soc_register_component(&i2c->dev, + &soc_component_dev_wm8996, wm8996_dai, ARRAY_SIZE(wm8996_dai)); if (ret < 0) goto err_gpiolib; @@ -3074,7 +3072,6 @@ static int wm8996_i2c_remove(struct i2c_client *client) struct wm8996_priv *wm8996 = i2c_get_clientdata(client); int i;
- snd_soc_unregister_codec(&client->dev); wm8996_free_gpio(wm8996); if (wm8996->pdata.ldo_ena > 0) { gpio_set_value_cansleep(wm8996->pdata.ldo_ena, 0); diff --git a/sound/soc/codecs/wm8996.h b/sound/soc/codecs/wm8996.h index de9ac3e..b387699 100644 --- a/sound/soc/codecs/wm8996.h +++ b/sound/soc/codecs/wm8996.h @@ -22,9 +22,9 @@ #define WM8996_FLL_DACLRCLK1 3 #define WM8996_FLL_BCLK1 4
-typedef void (*wm8996_polarity_fn)(struct snd_soc_codec *codec, int polarity); +typedef void (*wm8996_polarity_fn)(struct snd_soc_component *component, int polarity);
-int wm8996_detect(struct snd_soc_codec *codec, struct snd_soc_jack *jack, +int wm8996_detect(struct snd_soc_component *component, struct snd_soc_jack *jack, wm8996_polarity_fn polarity_cb);
/* diff --git a/sound/soc/samsung/speyside.c b/sound/soc/samsung/speyside.c index 083ef5e..4b4147d 100644 --- a/sound/soc/samsung/speyside.c +++ b/sound/soc/samsung/speyside.c @@ -124,14 +124,14 @@ static int speyside_get_micbias(struct snd_soc_dapm_widget *source, return 0; }
-static void speyside_set_polarity(struct snd_soc_codec *codec, +static void speyside_set_polarity(struct snd_soc_component *component, int polarity) { speyside_jack_polarity = !polarity; gpio_direction_output(WM8996_HPSEL_GPIO, speyside_jack_polarity);
/* Re-run DAPM to make sure we're using the correct mic bias */ - snd_soc_dapm_sync(snd_soc_codec_get_dapm(codec)); + snd_soc_dapm_sync(snd_soc_component_get_dapm(component)); }
static int speyside_wm0010_init(struct snd_soc_pcm_runtime *rtd) @@ -149,7 +149,7 @@ static int speyside_wm0010_init(struct snd_soc_pcm_runtime *rtd) static int speyside_wm8996_init(struct snd_soc_pcm_runtime *rtd) { struct snd_soc_dai *dai = rtd->codec_dai; - struct snd_soc_codec *codec = rtd->codec; + struct snd_soc_component *component = dai->component; int ret;
ret = snd_soc_dai_set_sysclk(dai, WM8996_SYSCLK_MCLK2, 32768, 0); @@ -168,7 +168,7 @@ static int speyside_wm8996_init(struct snd_soc_pcm_runtime *rtd) if (ret) return ret;
- wm8996_detect(codec, &speyside_headset, speyside_set_polarity); + wm8996_detect(component, &speyside_headset, speyside_set_polarity);
return 0; } @@ -232,10 +232,8 @@ static int speyside_late_probe(struct snd_soc_card *card)
static int speyside_wm9081_init(struct snd_soc_component *component) { - struct snd_soc_codec *codec = snd_soc_component_to_codec(component); - /* At any time the WM9081 is active it will have this clock */ - return snd_soc_codec_set_sysclk(codec, WM9081_SYSCLK_MCLK, 0, + return snd_soc_component_set_sysclk(component, WM9081_SYSCLK_MCLK, 0, MCLK_AUDIO_RATE, 0); }
From: Kuninori Morimoto kuninori.morimoto.gx@renesas.com
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 -> .pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com --- sound/soc/codecs/wm8991.c | 167 ++++++++++++++++++++++------------------------ 1 file changed, 80 insertions(+), 87 deletions(-)
diff --git a/sound/soc/codecs/wm8991.c b/sound/soc/codecs/wm8991.c index 802c0694..99c397b 100644 --- a/sound/soc/codecs/wm8991.c +++ b/sound/soc/codecs/wm8991.c @@ -133,7 +133,7 @@ static const SNDRV_CTL_TLVD_DECLARE_DB_RANGE(out_sidetone_tlv, static int wm899x_outpga_put_volsw_vu(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); int reg = kcontrol->private_value & 0xff; int ret; u16 val; @@ -143,8 +143,8 @@ static int wm899x_outpga_put_volsw_vu(struct snd_kcontrol *kcontrol, return ret;
/* now hit the volume update bits (always bit 8) */ - val = snd_soc_read(codec, reg); - return snd_soc_write(codec, reg, val | 0x0100); + val = snd_soc_component_read32(component, reg); + return snd_soc_component_write(component, reg, val | 0x0100); }
static const char *wm8991_digital_sidetone[] = @@ -361,14 +361,14 @@ static SOC_ENUM_SINGLE_DECL(wm8991_right_adcmode_enum, static int outmixer_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); u32 reg_shift = kcontrol->private_value & 0xfff; int ret = 0; u16 reg;
switch (reg_shift) { case WM8991_SPEAKER_MIXER | (WM8991_LDSPK_BIT << 8): - reg = snd_soc_read(codec, WM8991_OUTPUT_MIXER1); + reg = snd_soc_component_read32(component, WM8991_OUTPUT_MIXER1); if (reg & WM8991_LDLO) { printk(KERN_WARNING "Cannot set as Output Mixer 1 LDLO Set\n"); @@ -377,7 +377,7 @@ static int outmixer_event(struct snd_soc_dapm_widget *w, break;
case WM8991_SPEAKER_MIXER | (WM8991_RDSPK_BIT << 8): - reg = snd_soc_read(codec, WM8991_OUTPUT_MIXER2); + reg = snd_soc_component_read32(component, WM8991_OUTPUT_MIXER2); if (reg & WM8991_RDRO) { printk(KERN_WARNING "Cannot set as Output Mixer 2 RDRO Set\n"); @@ -386,7 +386,7 @@ static int outmixer_event(struct snd_soc_dapm_widget *w, break;
case WM8991_OUTPUT_MIXER1 | (WM8991_LDLO_BIT << 8): - reg = snd_soc_read(codec, WM8991_SPEAKER_MIXER); + reg = snd_soc_component_read32(component, WM8991_SPEAKER_MIXER); if (reg & WM8991_LDSPK) { printk(KERN_WARNING "Cannot set as Speaker Mixer LDSPK Set\n"); @@ -395,7 +395,7 @@ static int outmixer_event(struct snd_soc_dapm_widget *w, break;
case WM8991_OUTPUT_MIXER2 | (WM8991_RDRO_BIT << 8): - reg = snd_soc_read(codec, WM8991_SPEAKER_MIXER); + reg = snd_soc_component_read32(component, WM8991_SPEAKER_MIXER); if (reg & WM8991_RDSPK) { printk(KERN_WARNING "Cannot set as Speaker Mixer RDSPK Set\n"); @@ -927,31 +927,31 @@ static int wm8991_set_dai_pll(struct snd_soc_dai *codec_dai, int pll_id, int src, unsigned int freq_in, unsigned int freq_out) { u16 reg; - struct snd_soc_codec *codec = codec_dai->codec; + struct snd_soc_component *component = codec_dai->component; struct _pll_div pll_div;
if (freq_in && freq_out) { pll_factors(&pll_div, freq_out * 4, freq_in);
/* Turn on PLL */ - reg = snd_soc_read(codec, WM8991_POWER_MANAGEMENT_2); + reg = snd_soc_component_read32(component, WM8991_POWER_MANAGEMENT_2); reg |= WM8991_PLL_ENA; - snd_soc_write(codec, WM8991_POWER_MANAGEMENT_2, reg); + snd_soc_component_write(component, WM8991_POWER_MANAGEMENT_2, reg);
/* sysclk comes from PLL */ - reg = snd_soc_read(codec, WM8991_CLOCKING_2); - snd_soc_write(codec, WM8991_CLOCKING_2, reg | WM8991_SYSCLK_SRC); + reg = snd_soc_component_read32(component, WM8991_CLOCKING_2); + snd_soc_component_write(component, WM8991_CLOCKING_2, reg | WM8991_SYSCLK_SRC);
/* set up N , fractional mode and pre-divisor if necessary */ - snd_soc_write(codec, WM8991_PLL1, pll_div.n | WM8991_SDM | + snd_soc_component_write(component, WM8991_PLL1, pll_div.n | WM8991_SDM | (pll_div.div2 ? WM8991_PRESCALE : 0)); - snd_soc_write(codec, WM8991_PLL2, (u8)(pll_div.k>>8)); - snd_soc_write(codec, WM8991_PLL3, (u8)(pll_div.k & 0xFF)); + snd_soc_component_write(component, WM8991_PLL2, (u8)(pll_div.k>>8)); + snd_soc_component_write(component, WM8991_PLL3, (u8)(pll_div.k & 0xFF)); } else { /* Turn on PLL */ - reg = snd_soc_read(codec, WM8991_POWER_MANAGEMENT_2); + reg = snd_soc_component_read32(component, WM8991_POWER_MANAGEMENT_2); reg &= ~WM8991_PLL_ENA; - snd_soc_write(codec, WM8991_POWER_MANAGEMENT_2, reg); + snd_soc_component_write(component, WM8991_POWER_MANAGEMENT_2, reg); } return 0; } @@ -962,11 +962,11 @@ static int wm8991_set_dai_pll(struct snd_soc_dai *codec_dai, static int wm8991_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt) { - struct snd_soc_codec *codec = codec_dai->codec; + struct snd_soc_component *component = codec_dai->component; u16 audio1, audio3;
- audio1 = snd_soc_read(codec, WM8991_AUDIO_INTERFACE_1); - audio3 = snd_soc_read(codec, WM8991_AUDIO_INTERFACE_3); + audio1 = snd_soc_component_read32(component, WM8991_AUDIO_INTERFACE_1); + audio3 = snd_soc_component_read32(component, WM8991_AUDIO_INTERFACE_3);
/* set master/slave audio interface */ switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { @@ -1007,37 +1007,37 @@ static int wm8991_set_dai_fmt(struct snd_soc_dai *codec_dai, return -EINVAL; }
- snd_soc_write(codec, WM8991_AUDIO_INTERFACE_1, audio1); - snd_soc_write(codec, WM8991_AUDIO_INTERFACE_3, audio3); + snd_soc_component_write(component, WM8991_AUDIO_INTERFACE_1, audio1); + snd_soc_component_write(component, WM8991_AUDIO_INTERFACE_3, audio3); return 0; }
static int wm8991_set_dai_clkdiv(struct snd_soc_dai *codec_dai, int div_id, int div) { - struct snd_soc_codec *codec = codec_dai->codec; + struct snd_soc_component *component = codec_dai->component; u16 reg;
switch (div_id) { case WM8991_MCLK_DIV: - reg = snd_soc_read(codec, WM8991_CLOCKING_2) & + reg = snd_soc_component_read32(component, WM8991_CLOCKING_2) & ~WM8991_MCLK_DIV_MASK; - snd_soc_write(codec, WM8991_CLOCKING_2, reg | div); + snd_soc_component_write(component, WM8991_CLOCKING_2, reg | div); break; case WM8991_DACCLK_DIV: - reg = snd_soc_read(codec, WM8991_CLOCKING_2) & + reg = snd_soc_component_read32(component, WM8991_CLOCKING_2) & ~WM8991_DAC_CLKDIV_MASK; - snd_soc_write(codec, WM8991_CLOCKING_2, reg | div); + snd_soc_component_write(component, WM8991_CLOCKING_2, reg | div); break; case WM8991_ADCCLK_DIV: - reg = snd_soc_read(codec, WM8991_CLOCKING_2) & + reg = snd_soc_component_read32(component, WM8991_CLOCKING_2) & ~WM8991_ADC_CLKDIV_MASK; - snd_soc_write(codec, WM8991_CLOCKING_2, reg | div); + snd_soc_component_write(component, WM8991_CLOCKING_2, reg | div); break; case WM8991_BCLK_DIV: - reg = snd_soc_read(codec, WM8991_CLOCKING_1) & + reg = snd_soc_component_read32(component, WM8991_CLOCKING_1) & ~WM8991_BCLK_DIV_MASK; - snd_soc_write(codec, WM8991_CLOCKING_1, reg | div); + snd_soc_component_write(component, WM8991_CLOCKING_1, reg | div); break; default: return -EINVAL; @@ -1053,8 +1053,8 @@ static int wm8991_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; - u16 audio1 = snd_soc_read(codec, WM8991_AUDIO_INTERFACE_1); + struct snd_soc_component *component = dai->component; + u16 audio1 = snd_soc_component_read32(component, WM8991_AUDIO_INTERFACE_1);
audio1 &= ~WM8991_AIF_WL_MASK; /* bit size */ @@ -1072,27 +1072,27 @@ static int wm8991_hw_params(struct snd_pcm_substream *substream, break; }
- snd_soc_write(codec, WM8991_AUDIO_INTERFACE_1, audio1); + snd_soc_component_write(component, WM8991_AUDIO_INTERFACE_1, audio1); return 0; }
static int wm8991_mute(struct snd_soc_dai *dai, int mute) { - struct snd_soc_codec *codec = dai->codec; + struct snd_soc_component *component = dai->component; u16 val;
- val = snd_soc_read(codec, WM8991_DAC_CTRL) & ~WM8991_DAC_MUTE; + val = snd_soc_component_read32(component, WM8991_DAC_CTRL) & ~WM8991_DAC_MUTE; if (mute) - snd_soc_write(codec, WM8991_DAC_CTRL, val | WM8991_DAC_MUTE); + snd_soc_component_write(component, WM8991_DAC_CTRL, val | WM8991_DAC_MUTE); else - snd_soc_write(codec, WM8991_DAC_CTRL, val); + snd_soc_component_write(component, WM8991_DAC_CTRL, val); return 0; }
-static int wm8991_set_bias_level(struct snd_soc_codec *codec, +static int wm8991_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { - struct wm8991_priv *wm8991 = snd_soc_codec_get_drvdata(codec); + struct wm8991_priv *wm8991 = snd_soc_component_get_drvdata(component); u16 val;
switch (level) { @@ -1101,22 +1101,22 @@ static int wm8991_set_bias_level(struct snd_soc_codec *codec,
case SND_SOC_BIAS_PREPARE: /* VMID=2*50k */ - val = snd_soc_read(codec, WM8991_POWER_MANAGEMENT_1) & + val = snd_soc_component_read32(component, WM8991_POWER_MANAGEMENT_1) & ~WM8991_VMID_MODE_MASK; - snd_soc_write(codec, WM8991_POWER_MANAGEMENT_1, val | 0x2); + snd_soc_component_write(component, WM8991_POWER_MANAGEMENT_1, val | 0x2); break;
case SND_SOC_BIAS_STANDBY: - if (snd_soc_codec_get_bias_level(codec) == SND_SOC_BIAS_OFF) { + if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_OFF) { regcache_sync(wm8991->regmap); /* Enable all output discharge bits */ - snd_soc_write(codec, WM8991_ANTIPOP1, WM8991_DIS_LLINE | + snd_soc_component_write(component, WM8991_ANTIPOP1, WM8991_DIS_LLINE | WM8991_DIS_RLINE | WM8991_DIS_OUT3 | WM8991_DIS_OUT4 | WM8991_DIS_LOUT | WM8991_DIS_ROUT);
/* Enable POBCTRL, SOFT_ST, VMIDTOG and BUFDCOPEN */ - snd_soc_write(codec, WM8991_ANTIPOP2, WM8991_SOFTST | + snd_soc_component_write(component, WM8991_ANTIPOP2, WM8991_SOFTST | WM8991_BUFDCOPEN | WM8991_POBCTRL | WM8991_VMIDTOG);
@@ -1124,78 +1124,78 @@ static int wm8991_set_bias_level(struct snd_soc_codec *codec, msleep(300);
/* Disable VMIDTOG */ - snd_soc_write(codec, WM8991_ANTIPOP2, WM8991_SOFTST | + snd_soc_component_write(component, WM8991_ANTIPOP2, WM8991_SOFTST | WM8991_BUFDCOPEN | WM8991_POBCTRL);
/* disable all output discharge bits */ - snd_soc_write(codec, WM8991_ANTIPOP1, 0); + snd_soc_component_write(component, WM8991_ANTIPOP1, 0);
/* Enable outputs */ - snd_soc_write(codec, WM8991_POWER_MANAGEMENT_1, 0x1b00); + snd_soc_component_write(component, WM8991_POWER_MANAGEMENT_1, 0x1b00);
msleep(50);
/* Enable VMID at 2x50k */ - snd_soc_write(codec, WM8991_POWER_MANAGEMENT_1, 0x1f02); + snd_soc_component_write(component, WM8991_POWER_MANAGEMENT_1, 0x1f02);
msleep(100);
/* Enable VREF */ - snd_soc_write(codec, WM8991_POWER_MANAGEMENT_1, 0x1f03); + snd_soc_component_write(component, WM8991_POWER_MANAGEMENT_1, 0x1f03);
msleep(600);
/* Enable BUFIOEN */ - snd_soc_write(codec, WM8991_ANTIPOP2, WM8991_SOFTST | + snd_soc_component_write(component, WM8991_ANTIPOP2, WM8991_SOFTST | WM8991_BUFDCOPEN | WM8991_POBCTRL | WM8991_BUFIOEN);
/* Disable outputs */ - snd_soc_write(codec, WM8991_POWER_MANAGEMENT_1, 0x3); + snd_soc_component_write(component, WM8991_POWER_MANAGEMENT_1, 0x3);
/* disable POBCTRL, SOFT_ST and BUFDCOPEN */ - snd_soc_write(codec, WM8991_ANTIPOP2, WM8991_BUFIOEN); + snd_soc_component_write(component, WM8991_ANTIPOP2, WM8991_BUFIOEN); }
/* VMID=2*250k */ - val = snd_soc_read(codec, WM8991_POWER_MANAGEMENT_1) & + val = snd_soc_component_read32(component, WM8991_POWER_MANAGEMENT_1) & ~WM8991_VMID_MODE_MASK; - snd_soc_write(codec, WM8991_POWER_MANAGEMENT_1, val | 0x4); + snd_soc_component_write(component, WM8991_POWER_MANAGEMENT_1, val | 0x4); break;
case SND_SOC_BIAS_OFF: /* Enable POBCTRL and SOFT_ST */ - snd_soc_write(codec, WM8991_ANTIPOP2, WM8991_SOFTST | + snd_soc_component_write(component, WM8991_ANTIPOP2, WM8991_SOFTST | WM8991_POBCTRL | WM8991_BUFIOEN);
/* Enable POBCTRL, SOFT_ST and BUFDCOPEN */ - snd_soc_write(codec, WM8991_ANTIPOP2, WM8991_SOFTST | + snd_soc_component_write(component, WM8991_ANTIPOP2, WM8991_SOFTST | WM8991_BUFDCOPEN | WM8991_POBCTRL | WM8991_BUFIOEN);
/* mute DAC */ - val = snd_soc_read(codec, WM8991_DAC_CTRL); - snd_soc_write(codec, WM8991_DAC_CTRL, val | WM8991_DAC_MUTE); + val = snd_soc_component_read32(component, WM8991_DAC_CTRL); + snd_soc_component_write(component, WM8991_DAC_CTRL, val | WM8991_DAC_MUTE);
/* Enable any disabled outputs */ - snd_soc_write(codec, WM8991_POWER_MANAGEMENT_1, 0x1f03); + snd_soc_component_write(component, WM8991_POWER_MANAGEMENT_1, 0x1f03);
/* Disable VMID */ - snd_soc_write(codec, WM8991_POWER_MANAGEMENT_1, 0x1f01); + snd_soc_component_write(component, WM8991_POWER_MANAGEMENT_1, 0x1f01);
msleep(300);
/* Enable all output discharge bits */ - snd_soc_write(codec, WM8991_ANTIPOP1, WM8991_DIS_LLINE | + snd_soc_component_write(component, WM8991_ANTIPOP1, WM8991_DIS_LLINE | WM8991_DIS_RLINE | WM8991_DIS_OUT3 | WM8991_DIS_OUT4 | WM8991_DIS_LOUT | WM8991_DIS_ROUT);
/* Disable VREF */ - snd_soc_write(codec, WM8991_POWER_MANAGEMENT_1, 0x0); + snd_soc_component_write(component, WM8991_POWER_MANAGEMENT_1, 0x0);
/* disable POBCTRL, SOFT_ST and BUFDCOPEN */ - snd_soc_write(codec, WM8991_ANTIPOP2, 0x0); + snd_soc_component_write(component, WM8991_ANTIPOP2, 0x0); regcache_mark_dirty(wm8991->regmap); break; } @@ -1242,18 +1242,19 @@ static int wm8991_set_bias_level(struct snd_soc_codec *codec, .ops = &wm8991_ops };
-static const struct snd_soc_codec_driver soc_codec_dev_wm8991 = { - .set_bias_level = wm8991_set_bias_level, - .suspend_bias_off = true, - - .component_driver = { - .controls = wm8991_snd_controls, - .num_controls = ARRAY_SIZE(wm8991_snd_controls), - .dapm_widgets = wm8991_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(wm8991_dapm_widgets), - .dapm_routes = wm8991_dapm_routes, - .num_dapm_routes = ARRAY_SIZE(wm8991_dapm_routes), - }, +static const struct snd_soc_component_driver soc_component_dev_wm8991 = { + .set_bias_level = wm8991_set_bias_level, + .controls = wm8991_snd_controls, + .num_controls = ARRAY_SIZE(wm8991_snd_controls), + .dapm_widgets = wm8991_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(wm8991_dapm_widgets), + .dapm_routes = wm8991_dapm_routes, + .num_dapm_routes = ARRAY_SIZE(wm8991_dapm_routes), + .suspend_bias_off = 1, + .idle_bias_on = 1, + .pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, };
static const struct regmap_config wm8991_regmap = { @@ -1319,19 +1320,12 @@ static int wm8991_i2c_probe(struct i2c_client *i2c, regmap_write(wm8991->regmap, WM8991_RIGHT_OUTPUT_VOLUME, 0x50 | (1<<8));
- ret = snd_soc_register_codec(&i2c->dev, - &soc_codec_dev_wm8991, &wm8991_dai, 1); + ret = devm_snd_soc_register_component(&i2c->dev, + &soc_component_dev_wm8991, &wm8991_dai, 1);
return ret; }
-static int wm8991_i2c_remove(struct i2c_client *client) -{ - snd_soc_unregister_codec(&client->dev); - - return 0; -} - static const struct i2c_device_id wm8991_i2c_id[] = { { "wm8991", 0 }, { } @@ -1343,7 +1337,6 @@ static int wm8991_i2c_remove(struct i2c_client *client) .name = "wm8991", }, .probe = wm8991_i2c_probe, - .remove = wm8991_i2c_remove, .id_table = wm8991_i2c_id, };
From: Kuninori Morimoto kuninori.morimoto.gx@renesas.com
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 -> .pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com --- sound/soc/codecs/wm8995.c | 286 ++++++++++++++++++++++------------------------ 1 file changed, 135 insertions(+), 151 deletions(-)
diff --git a/sound/soc/codecs/wm8995.c b/sound/soc/codecs/wm8995.c index 19b08a5..4c435757 100644 --- a/sound/soc/codecs/wm8995.c +++ b/sound/soc/codecs/wm8995.c @@ -385,7 +385,7 @@ struct wm8995_priv { struct fll_config fll[2], fll_suspend[2]; struct regulator_bulk_data supplies[WM8995_NUM_SUPPLIES]; struct notifier_block disable_nb[WM8995_NUM_SUPPLIES]; - struct snd_soc_codec *codec; + struct snd_soc_component *component; };
/* @@ -485,48 +485,48 @@ static SOC_ENUM_SINGLE_DECL(dmic_src2_enum, WM8995_POWER_MANAGEMENT_5, WM8995_AIF2_ADC_RIGHT_VOLUME, 0, 96, 0, digital_tlv) };
-static void wm8995_update_class_w(struct snd_soc_codec *codec) +static void wm8995_update_class_w(struct snd_soc_component *component) { int enable = 1; int source = 0; /* GCC flow analysis can't track enable */ int reg, reg_r;
/* We also need the same setting for L/R and only one path */ - reg = snd_soc_read(codec, WM8995_DAC1_LEFT_MIXER_ROUTING); + reg = snd_soc_component_read32(component, WM8995_DAC1_LEFT_MIXER_ROUTING); switch (reg) { case WM8995_AIF2DACL_TO_DAC1L: - dev_dbg(codec->dev, "Class W source AIF2DAC\n"); + dev_dbg(component->dev, "Class W source AIF2DAC\n"); source = 2 << WM8995_CP_DYN_SRC_SEL_SHIFT; break; case WM8995_AIF1DAC2L_TO_DAC1L: - dev_dbg(codec->dev, "Class W source AIF1DAC2\n"); + dev_dbg(component->dev, "Class W source AIF1DAC2\n"); source = 1 << WM8995_CP_DYN_SRC_SEL_SHIFT; break; case WM8995_AIF1DAC1L_TO_DAC1L: - dev_dbg(codec->dev, "Class W source AIF1DAC1\n"); + dev_dbg(component->dev, "Class W source AIF1DAC1\n"); source = 0 << WM8995_CP_DYN_SRC_SEL_SHIFT; break; default: - dev_dbg(codec->dev, "DAC mixer setting: %x\n", reg); + dev_dbg(component->dev, "DAC mixer setting: %x\n", reg); enable = 0; break; }
- reg_r = snd_soc_read(codec, WM8995_DAC1_RIGHT_MIXER_ROUTING); + reg_r = snd_soc_component_read32(component, WM8995_DAC1_RIGHT_MIXER_ROUTING); if (reg_r != reg) { - dev_dbg(codec->dev, "Left and right DAC mixers different\n"); + dev_dbg(component->dev, "Left and right DAC mixers different\n"); enable = 0; }
if (enable) { - dev_dbg(codec->dev, "Class W enabled\n"); - snd_soc_update_bits(codec, WM8995_CLASS_W_1, + dev_dbg(component->dev, "Class W enabled\n"); + snd_soc_component_update_bits(component, WM8995_CLASS_W_1, WM8995_CP_DYN_PWR_MASK | WM8995_CP_DYN_SRC_SEL_MASK, source | WM8995_CP_DYN_PWR); } else { - dev_dbg(codec->dev, "Class W disabled\n"); - snd_soc_update_bits(codec, WM8995_CLASS_W_1, + dev_dbg(component->dev, "Class W disabled\n"); + snd_soc_component_update_bits(component, WM8995_CLASS_W_1, WM8995_CP_DYN_PWR_MASK, 0); } } @@ -534,11 +534,11 @@ static void wm8995_update_class_w(struct snd_soc_codec *codec) static int check_clk_sys(struct snd_soc_dapm_widget *source, struct snd_soc_dapm_widget *sink) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(source->dapm); + struct snd_soc_component *component = snd_soc_dapm_to_component(source->dapm); unsigned int reg; const char *clk;
- reg = snd_soc_read(codec, WM8995_CLOCKING_1); + reg = snd_soc_component_read32(component, WM8995_CLOCKING_1); /* Check what we're currently using for CLK_SYS */ if (reg & WM8995_SYSCLK_SRC) clk = "AIF2CLK"; @@ -550,37 +550,37 @@ static int check_clk_sys(struct snd_soc_dapm_widget *source, static int wm8995_put_class_w(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_dapm_kcontrol_codec(kcontrol); + struct snd_soc_component *component = snd_soc_dapm_kcontrol_component(kcontrol); int ret;
ret = snd_soc_dapm_put_volsw(kcontrol, ucontrol); - wm8995_update_class_w(codec); + wm8995_update_class_w(component); return ret; }
static int hp_supply_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm);
switch (event) { case SND_SOC_DAPM_PRE_PMU: /* Enable the headphone amp */ - snd_soc_update_bits(codec, WM8995_POWER_MANAGEMENT_1, + snd_soc_component_update_bits(component, WM8995_POWER_MANAGEMENT_1, WM8995_HPOUT1L_ENA_MASK | WM8995_HPOUT1R_ENA_MASK, WM8995_HPOUT1L_ENA | WM8995_HPOUT1R_ENA);
/* Enable the second stage */ - snd_soc_update_bits(codec, WM8995_ANALOGUE_HP_1, + snd_soc_component_update_bits(component, WM8995_ANALOGUE_HP_1, WM8995_HPOUT1L_DLY_MASK | WM8995_HPOUT1R_DLY_MASK, WM8995_HPOUT1L_DLY | WM8995_HPOUT1R_DLY); break; case SND_SOC_DAPM_PRE_PMD: - snd_soc_update_bits(codec, WM8995_CHARGE_PUMP_1, + snd_soc_component_update_bits(component, WM8995_CHARGE_PUMP_1, WM8995_CP_ENA_MASK, 0); break; } @@ -588,41 +588,41 @@ static int hp_supply_event(struct snd_soc_dapm_widget *w, return 0; }
-static void dc_servo_cmd(struct snd_soc_codec *codec, +static void dc_servo_cmd(struct snd_soc_component *component, unsigned int reg, unsigned int val, unsigned int mask) { int timeout = 10;
- dev_dbg(codec->dev, "%s: reg = %#x, val = %#x, mask = %#x\n", + dev_dbg(component->dev, "%s: reg = %#x, val = %#x, mask = %#x\n", __func__, reg, val, mask);
- snd_soc_write(codec, reg, val); + snd_soc_component_write(component, reg, val); while (timeout--) { msleep(10); - val = snd_soc_read(codec, WM8995_DC_SERVO_READBACK_0); + val = snd_soc_component_read32(component, WM8995_DC_SERVO_READBACK_0); if ((val & mask) == mask) return; }
- dev_err(codec->dev, "Timed out waiting for DC Servo\n"); + dev_err(component->dev, "Timed out waiting for DC Servo\n"); }
static int hp_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); unsigned int reg;
- reg = snd_soc_read(codec, WM8995_ANALOGUE_HP_1); + reg = snd_soc_component_read32(component, WM8995_ANALOGUE_HP_1);
switch (event) { case SND_SOC_DAPM_POST_PMU: - snd_soc_update_bits(codec, WM8995_CHARGE_PUMP_1, + snd_soc_component_update_bits(component, WM8995_CHARGE_PUMP_1, WM8995_CP_ENA_MASK, WM8995_CP_ENA);
msleep(5);
- snd_soc_update_bits(codec, WM8995_POWER_MANAGEMENT_1, + snd_soc_component_update_bits(component, WM8995_POWER_MANAGEMENT_1, WM8995_HPOUT1L_ENA_MASK | WM8995_HPOUT1R_ENA_MASK, WM8995_HPOUT1L_ENA | WM8995_HPOUT1R_ENA); @@ -630,12 +630,12 @@ static int hp_event(struct snd_soc_dapm_widget *w, udelay(20);
reg |= WM8995_HPOUT1L_DLY | WM8995_HPOUT1R_DLY; - snd_soc_write(codec, WM8995_ANALOGUE_HP_1, reg); + snd_soc_component_write(component, WM8995_ANALOGUE_HP_1, reg);
- snd_soc_write(codec, WM8995_DC_SERVO_1, WM8995_DCS_ENA_CHAN_0 | + snd_soc_component_write(component, WM8995_DC_SERVO_1, WM8995_DCS_ENA_CHAN_0 | WM8995_DCS_ENA_CHAN_1);
- dc_servo_cmd(codec, WM8995_DC_SERVO_2, + dc_servo_cmd(component, WM8995_DC_SERVO_2, WM8995_DCS_TRIG_STARTUP_0 | WM8995_DCS_TRIG_STARTUP_1, WM8995_DCS_TRIG_DAC_WR_0 | @@ -643,23 +643,23 @@ static int hp_event(struct snd_soc_dapm_widget *w,
reg |= WM8995_HPOUT1R_OUTP | WM8995_HPOUT1R_RMV_SHORT | WM8995_HPOUT1L_OUTP | WM8995_HPOUT1L_RMV_SHORT; - snd_soc_write(codec, WM8995_ANALOGUE_HP_1, reg); + snd_soc_component_write(component, WM8995_ANALOGUE_HP_1, reg);
break; case SND_SOC_DAPM_PRE_PMD: - snd_soc_update_bits(codec, WM8995_ANALOGUE_HP_1, + snd_soc_component_update_bits(component, WM8995_ANALOGUE_HP_1, WM8995_HPOUT1L_OUTP_MASK | WM8995_HPOUT1R_OUTP_MASK | WM8995_HPOUT1L_RMV_SHORT_MASK | WM8995_HPOUT1R_RMV_SHORT_MASK, 0);
- snd_soc_update_bits(codec, WM8995_ANALOGUE_HP_1, + snd_soc_component_update_bits(component, WM8995_ANALOGUE_HP_1, WM8995_HPOUT1L_DLY_MASK | WM8995_HPOUT1R_DLY_MASK, 0);
- snd_soc_write(codec, WM8995_DC_SERVO_1, 0); + snd_soc_component_write(component, WM8995_DC_SERVO_1, 0);
- snd_soc_update_bits(codec, WM8995_POWER_MANAGEMENT_1, + snd_soc_component_update_bits(component, WM8995_POWER_MANAGEMENT_1, WM8995_HPOUT1L_ENA_MASK | WM8995_HPOUT1R_ENA_MASK, 0); @@ -669,14 +669,14 @@ static int hp_event(struct snd_soc_dapm_widget *w, return 0; }
-static int configure_aif_clock(struct snd_soc_codec *codec, int aif) +static int configure_aif_clock(struct snd_soc_component *component, int aif) { struct wm8995_priv *wm8995; int rate; int reg1 = 0; int offset;
- wm8995 = snd_soc_codec_get_drvdata(codec); + wm8995 = snd_soc_component_get_drvdata(component);
if (aif) offset = 4; @@ -707,29 +707,29 @@ static int configure_aif_clock(struct snd_soc_codec *codec, int aif) rate /= 2; reg1 |= WM8995_AIF1CLK_DIV;
- dev_dbg(codec->dev, "Dividing AIF%d clock to %dHz\n", + dev_dbg(component->dev, "Dividing AIF%d clock to %dHz\n", aif + 1, rate); }
wm8995->aifclk[aif] = rate;
- snd_soc_update_bits(codec, WM8995_AIF1_CLOCKING_1 + offset, + snd_soc_component_update_bits(component, WM8995_AIF1_CLOCKING_1 + offset, WM8995_AIF1CLK_SRC_MASK | WM8995_AIF1CLK_DIV_MASK, reg1); return 0; }
-static int configure_clock(struct snd_soc_codec *codec) +static int configure_clock(struct snd_soc_component *component) { - struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec); + struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); struct wm8995_priv *wm8995; int change, new;
- wm8995 = snd_soc_codec_get_drvdata(codec); + wm8995 = snd_soc_component_get_drvdata(component);
/* Bring up the AIF clocks first */ - configure_aif_clock(codec, 0); - configure_aif_clock(codec, 1); + configure_aif_clock(component, 0); + configure_aif_clock(component, 1);
/* * Then switch CLK_SYS over to the higher of them; a change @@ -747,7 +747,7 @@ static int configure_clock(struct snd_soc_codec *codec) else new = 0;
- change = snd_soc_update_bits(codec, WM8995_CLOCKING_1, + change = snd_soc_component_update_bits(component, WM8995_CLOCKING_1, WM8995_SYSCLK_SRC_MASK, new); if (!change) return 0; @@ -760,14 +760,14 @@ static int configure_clock(struct snd_soc_codec *codec) static int clk_sys_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm);
switch (event) { case SND_SOC_DAPM_PRE_PMU: - return configure_clock(codec); + return configure_clock(component);
case SND_SOC_DAPM_POST_PMD: - configure_clock(codec); + configure_clock(component); break; }
@@ -1422,7 +1422,7 @@ static bool wm8995_volatile(struct device *dev, unsigned int reg)
static int wm8995_aif_mute(struct snd_soc_dai *dai, int mute) { - struct snd_soc_codec *codec = dai->codec; + struct snd_soc_component *component = dai->component; int mute_reg;
switch (dai->id) { @@ -1436,18 +1436,18 @@ static int wm8995_aif_mute(struct snd_soc_dai *dai, int mute) return -EINVAL; }
- snd_soc_update_bits(codec, mute_reg, WM8995_AIF1DAC1_MUTE_MASK, + snd_soc_component_update_bits(component, mute_reg, WM8995_AIF1DAC1_MUTE_MASK, !!mute << WM8995_AIF1DAC1_MUTE_SHIFT); return 0; }
static int wm8995_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt) { - struct snd_soc_codec *codec; + struct snd_soc_component *component; int master; int aif;
- codec = dai->codec; + component = dai->component;
master = 0; switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { @@ -1519,11 +1519,11 @@ static int wm8995_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt) return -EINVAL; }
- snd_soc_update_bits(codec, WM8995_AIF1_CONTROL_1, + snd_soc_component_update_bits(component, WM8995_AIF1_CONTROL_1, WM8995_AIF1_BCLK_INV_MASK | WM8995_AIF1_LRCLK_INV_MASK | WM8995_AIF1_FMT_MASK, aif); - snd_soc_update_bits(codec, WM8995_AIF1_MASTER_SLAVE, + snd_soc_component_update_bits(component, WM8995_AIF1_MASTER_SLAVE, WM8995_AIF1_MSTR_MASK, master); return 0; } @@ -1546,7 +1546,7 @@ static int wm8995_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec; + struct snd_soc_component *component; struct wm8995_priv *wm8995; int aif1_reg; int bclk_reg; @@ -1557,8 +1557,8 @@ static int wm8995_hw_params(struct snd_pcm_substream *substream, int lrclk, bclk; int i, rate_val, best, best_val, cur_val;
- codec = dai->codec; - wm8995 = snd_soc_codec_get_drvdata(codec); + component = dai->component; + wm8995 = snd_soc_component_get_drvdata(component);
switch (dai->id) { case 0: @@ -1570,7 +1570,7 @@ static int wm8995_hw_params(struct snd_pcm_substream *substream, lrclk_reg = WM8995_AIF1DAC_LRCLK; } else { lrclk_reg = WM8995_AIF1ADC_LRCLK; - dev_dbg(codec->dev, "AIF1 using split LRCLK\n"); + dev_dbg(component->dev, "AIF1 using split LRCLK\n"); } break; case 1: @@ -1582,7 +1582,7 @@ static int wm8995_hw_params(struct snd_pcm_substream *substream, lrclk_reg = WM8995_AIF2DAC_LRCLK; } else { lrclk_reg = WM8995_AIF2ADC_LRCLK; - dev_dbg(codec->dev, "AIF2 using split LRCLK\n"); + dev_dbg(component->dev, "AIF2 using split LRCLK\n"); } break; default: @@ -1668,13 +1668,13 @@ static int wm8995_hw_params(struct snd_pcm_substream *substream, dev_dbg(dai->dev, "Using LRCLK rate %d for actual LRCLK %dHz\n", lrclk, bclk_rate / lrclk);
- snd_soc_update_bits(codec, aif1_reg, + snd_soc_component_update_bits(component, aif1_reg, WM8995_AIF1_WL_MASK, aif1); - snd_soc_update_bits(codec, bclk_reg, + snd_soc_component_update_bits(component, bclk_reg, WM8995_AIF1_BCLK_DIV_MASK, bclk); - snd_soc_update_bits(codec, lrclk_reg, + snd_soc_component_update_bits(component, lrclk_reg, WM8995_AIF1DAC_RATE_MASK, lrclk); - snd_soc_update_bits(codec, rate_reg, + snd_soc_component_update_bits(component, rate_reg, WM8995_AIF1_SR_MASK | WM8995_AIF1CLK_RATE_MASK, rate_val); return 0; @@ -1682,7 +1682,7 @@ static int wm8995_hw_params(struct snd_pcm_substream *substream,
static int wm8995_set_tristate(struct snd_soc_dai *codec_dai, int tristate) { - struct snd_soc_codec *codec = codec_dai->codec; + struct snd_soc_component *component = codec_dai->component; int reg, val, mask;
switch (codec_dai->id) { @@ -1707,7 +1707,7 @@ static int wm8995_set_tristate(struct snd_soc_dai *codec_dai, int tristate) else val = 0;
- return snd_soc_update_bits(codec, reg, mask, val); + return snd_soc_component_update_bits(component, reg, mask, val); }
/* The size in bits of the FLL divide multiplied by 10 @@ -1797,19 +1797,19 @@ static int wm8995_set_fll(struct snd_soc_dai *dai, int id, int src, unsigned int freq_in, unsigned int freq_out) { - struct snd_soc_codec *codec; + struct snd_soc_component *component; struct wm8995_priv *wm8995; int reg_offset, ret; struct fll_div fll; u16 reg, aif1, aif2;
- codec = dai->codec; - wm8995 = snd_soc_codec_get_drvdata(codec); + component = dai->component; + wm8995 = snd_soc_component_get_drvdata(component);
- aif1 = snd_soc_read(codec, WM8995_AIF1_CLOCKING_1) + aif1 = snd_soc_component_read32(component, WM8995_AIF1_CLOCKING_1) & WM8995_AIF1CLK_ENA;
- aif2 = snd_soc_read(codec, WM8995_AIF2_CLOCKING_1) + aif2 = snd_soc_component_read32(component, WM8995_AIF2_CLOCKING_1) & WM8995_AIF2CLK_ENA;
switch (id) { @@ -1858,35 +1858,35 @@ static int wm8995_set_fll(struct snd_soc_dai *dai, int id, return ret;
/* Gate the AIF clocks while we reclock */ - snd_soc_update_bits(codec, WM8995_AIF1_CLOCKING_1, + snd_soc_component_update_bits(component, WM8995_AIF1_CLOCKING_1, WM8995_AIF1CLK_ENA_MASK, 0); - snd_soc_update_bits(codec, WM8995_AIF2_CLOCKING_1, + snd_soc_component_update_bits(component, WM8995_AIF2_CLOCKING_1, WM8995_AIF2CLK_ENA_MASK, 0);
/* We always need to disable the FLL while reconfiguring */ - snd_soc_update_bits(codec, WM8995_FLL1_CONTROL_1 + reg_offset, + snd_soc_component_update_bits(component, WM8995_FLL1_CONTROL_1 + reg_offset, WM8995_FLL1_ENA_MASK, 0);
reg = (fll.outdiv << WM8995_FLL1_OUTDIV_SHIFT) | (fll.fll_fratio << WM8995_FLL1_FRATIO_SHIFT); - snd_soc_update_bits(codec, WM8995_FLL1_CONTROL_2 + reg_offset, + snd_soc_component_update_bits(component, WM8995_FLL1_CONTROL_2 + reg_offset, WM8995_FLL1_OUTDIV_MASK | WM8995_FLL1_FRATIO_MASK, reg);
- snd_soc_write(codec, WM8995_FLL1_CONTROL_3 + reg_offset, fll.k); + snd_soc_component_write(component, WM8995_FLL1_CONTROL_3 + reg_offset, fll.k);
- snd_soc_update_bits(codec, WM8995_FLL1_CONTROL_4 + reg_offset, + snd_soc_component_update_bits(component, WM8995_FLL1_CONTROL_4 + reg_offset, WM8995_FLL1_N_MASK, fll.n << WM8995_FLL1_N_SHIFT);
- snd_soc_update_bits(codec, WM8995_FLL1_CONTROL_5 + reg_offset, + snd_soc_component_update_bits(component, WM8995_FLL1_CONTROL_5 + reg_offset, WM8995_FLL1_REFCLK_DIV_MASK | WM8995_FLL1_REFCLK_SRC_MASK, (fll.clk_ref_div << WM8995_FLL1_REFCLK_DIV_SHIFT) | (src - 1));
if (freq_out) - snd_soc_update_bits(codec, WM8995_FLL1_CONTROL_1 + reg_offset, + snd_soc_component_update_bits(component, WM8995_FLL1_CONTROL_1 + reg_offset, WM8995_FLL1_ENA_MASK, WM8995_FLL1_ENA);
wm8995->fll[id].in = freq_in; @@ -1894,12 +1894,12 @@ static int wm8995_set_fll(struct snd_soc_dai *dai, int id, wm8995->fll[id].src = src;
/* Enable any gated AIF clocks */ - snd_soc_update_bits(codec, WM8995_AIF1_CLOCKING_1, + snd_soc_component_update_bits(component, WM8995_AIF1_CLOCKING_1, WM8995_AIF1CLK_ENA_MASK, aif1); - snd_soc_update_bits(codec, WM8995_AIF2_CLOCKING_1, + snd_soc_component_update_bits(component, WM8995_AIF2_CLOCKING_1, WM8995_AIF2CLK_ENA_MASK, aif2);
- configure_clock(codec); + configure_clock(component);
return 0; } @@ -1907,11 +1907,11 @@ static int wm8995_set_fll(struct snd_soc_dai *dai, int id, static int wm8995_set_dai_sysclk(struct snd_soc_dai *dai, int clk_id, unsigned int freq, int dir) { - struct snd_soc_codec *codec; + struct snd_soc_component *component; struct wm8995_priv *wm8995;
- codec = dai->codec; - wm8995 = snd_soc_codec_get_drvdata(codec); + component = dai->component; + wm8995 = snd_soc_component_get_drvdata(component);
switch (dai->id) { case 0: @@ -1949,24 +1949,24 @@ static int wm8995_set_dai_sysclk(struct snd_soc_dai *dai, return -EINVAL; }
- configure_clock(codec); + configure_clock(component);
return 0; }
-static int wm8995_set_bias_level(struct snd_soc_codec *codec, +static int wm8995_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { struct wm8995_priv *wm8995; int ret;
- wm8995 = snd_soc_codec_get_drvdata(codec); + wm8995 = snd_soc_component_get_drvdata(component); switch (level) { case SND_SOC_BIAS_ON: case SND_SOC_BIAS_PREPARE: break; case SND_SOC_BIAS_STANDBY: - if (snd_soc_codec_get_bias_level(codec) == SND_SOC_BIAS_OFF) { + if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_OFF) { ret = regulator_bulk_enable(ARRAY_SIZE(wm8995->supplies), wm8995->supplies); if (ret) @@ -1974,17 +1974,17 @@ static int wm8995_set_bias_level(struct snd_soc_codec *codec,
ret = regcache_sync(wm8995->regmap); if (ret) { - dev_err(codec->dev, + dev_err(component->dev, "Failed to sync cache: %d\n", ret); return ret; }
- snd_soc_update_bits(codec, WM8995_POWER_MANAGEMENT_1, + snd_soc_component_update_bits(component, WM8995_POWER_MANAGEMENT_1, WM8995_BG_ENA_MASK, WM8995_BG_ENA); } break; case SND_SOC_BIAS_OFF: - snd_soc_update_bits(codec, WM8995_POWER_MANAGEMENT_1, + snd_soc_component_update_bits(component, WM8995_POWER_MANAGEMENT_1, WM8995_BG_ENA_MASK, 0); regulator_bulk_disable(ARRAY_SIZE(wm8995->supplies), wm8995->supplies); @@ -1994,37 +1994,36 @@ static int wm8995_set_bias_level(struct snd_soc_codec *codec, return 0; }
-static int wm8995_remove(struct snd_soc_codec *codec) +static void wm8995_remove(struct snd_soc_component *component) { struct wm8995_priv *wm8995; int i;
- wm8995 = snd_soc_codec_get_drvdata(codec); + wm8995 = snd_soc_component_get_drvdata(component);
for (i = 0; i < ARRAY_SIZE(wm8995->supplies); ++i) regulator_unregister_notifier(wm8995->supplies[i].consumer, &wm8995->disable_nb[i]);
regulator_bulk_free(ARRAY_SIZE(wm8995->supplies), wm8995->supplies); - return 0; }
-static int wm8995_probe(struct snd_soc_codec *codec) +static int wm8995_probe(struct snd_soc_component *component) { struct wm8995_priv *wm8995; int i; int ret;
- wm8995 = snd_soc_codec_get_drvdata(codec); - wm8995->codec = codec; + wm8995 = snd_soc_component_get_drvdata(component); + wm8995->component = component;
for (i = 0; i < ARRAY_SIZE(wm8995->supplies); i++) wm8995->supplies[i].supply = wm8995_supply_names[i];
- ret = regulator_bulk_get(codec->dev, ARRAY_SIZE(wm8995->supplies), + ret = regulator_bulk_get(component->dev, ARRAY_SIZE(wm8995->supplies), wm8995->supplies); if (ret) { - dev_err(codec->dev, "Failed to request supplies: %d\n", ret); + dev_err(component->dev, "Failed to request supplies: %d\n", ret); return ret; }
@@ -2042,7 +2041,7 @@ static int wm8995_probe(struct snd_soc_codec *codec) ret = regulator_register_notifier(wm8995->supplies[i].consumer, &wm8995->disable_nb[i]); if (ret) { - dev_err(codec->dev, + dev_err(component->dev, "Failed to register regulator notifier: %d\n", ret); } @@ -2051,49 +2050,49 @@ static int wm8995_probe(struct snd_soc_codec *codec) ret = regulator_bulk_enable(ARRAY_SIZE(wm8995->supplies), wm8995->supplies); if (ret) { - dev_err(codec->dev, "Failed to enable supplies: %d\n", ret); + dev_err(component->dev, "Failed to enable supplies: %d\n", ret); goto err_reg_get; }
- ret = snd_soc_read(codec, WM8995_SOFTWARE_RESET); + ret = snd_soc_component_read32(component, WM8995_SOFTWARE_RESET); if (ret < 0) { - dev_err(codec->dev, "Failed to read device ID: %d\n", ret); + dev_err(component->dev, "Failed to read device ID: %d\n", ret); goto err_reg_enable; }
if (ret != 0x8995) { - dev_err(codec->dev, "Invalid device ID: %#x\n", ret); + dev_err(component->dev, "Invalid device ID: %#x\n", ret); ret = -EINVAL; goto err_reg_enable; }
- ret = snd_soc_write(codec, WM8995_SOFTWARE_RESET, 0); + ret = snd_soc_component_write(component, WM8995_SOFTWARE_RESET, 0); if (ret < 0) { - dev_err(codec->dev, "Failed to issue reset: %d\n", ret); + dev_err(component->dev, "Failed to issue reset: %d\n", ret); goto err_reg_enable; }
/* Latch volume updates (right only; we always do left then right). */ - snd_soc_update_bits(codec, WM8995_AIF1_DAC1_RIGHT_VOLUME, + snd_soc_component_update_bits(component, WM8995_AIF1_DAC1_RIGHT_VOLUME, WM8995_AIF1DAC1_VU_MASK, WM8995_AIF1DAC1_VU); - snd_soc_update_bits(codec, WM8995_AIF1_DAC2_RIGHT_VOLUME, + snd_soc_component_update_bits(component, WM8995_AIF1_DAC2_RIGHT_VOLUME, WM8995_AIF1DAC2_VU_MASK, WM8995_AIF1DAC2_VU); - snd_soc_update_bits(codec, WM8995_AIF2_DAC_RIGHT_VOLUME, + snd_soc_component_update_bits(component, WM8995_AIF2_DAC_RIGHT_VOLUME, WM8995_AIF2DAC_VU_MASK, WM8995_AIF2DAC_VU); - snd_soc_update_bits(codec, WM8995_AIF1_ADC1_RIGHT_VOLUME, + snd_soc_component_update_bits(component, WM8995_AIF1_ADC1_RIGHT_VOLUME, WM8995_AIF1ADC1_VU_MASK, WM8995_AIF1ADC1_VU); - snd_soc_update_bits(codec, WM8995_AIF1_ADC2_RIGHT_VOLUME, + snd_soc_component_update_bits(component, WM8995_AIF1_ADC2_RIGHT_VOLUME, WM8995_AIF1ADC2_VU_MASK, WM8995_AIF1ADC2_VU); - snd_soc_update_bits(codec, WM8995_AIF2_ADC_RIGHT_VOLUME, + snd_soc_component_update_bits(component, WM8995_AIF2_ADC_RIGHT_VOLUME, WM8995_AIF2ADC_VU_MASK, WM8995_AIF1ADC2_VU); - snd_soc_update_bits(codec, WM8995_DAC1_RIGHT_VOLUME, + snd_soc_component_update_bits(component, WM8995_DAC1_RIGHT_VOLUME, WM8995_DAC1_VU_MASK, WM8995_DAC1_VU); - snd_soc_update_bits(codec, WM8995_DAC2_RIGHT_VOLUME, + snd_soc_component_update_bits(component, WM8995_DAC2_RIGHT_VOLUME, WM8995_DAC2_VU_MASK, WM8995_DAC2_VU); - snd_soc_update_bits(codec, WM8995_RIGHT_LINE_INPUT_1_VOLUME, + snd_soc_component_update_bits(component, WM8995_RIGHT_LINE_INPUT_1_VOLUME, WM8995_IN1_VU_MASK, WM8995_IN1_VU);
- wm8995_update_class_w(codec); + wm8995_update_class_w(component);
return 0;
@@ -2186,20 +2185,19 @@ static int wm8995_probe(struct snd_soc_codec *codec) } };
-static const struct snd_soc_codec_driver soc_codec_dev_wm8995 = { - .probe = wm8995_probe, - .remove = wm8995_remove, - .set_bias_level = wm8995_set_bias_level, - .idle_bias_off = true, - - .component_driver = { - .controls = wm8995_snd_controls, - .num_controls = ARRAY_SIZE(wm8995_snd_controls), - .dapm_widgets = wm8995_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(wm8995_dapm_widgets), - .dapm_routes = wm8995_intercon, - .num_dapm_routes = ARRAY_SIZE(wm8995_intercon), - }, +static const struct snd_soc_component_driver soc_component_dev_wm8995 = { + .probe = wm8995_probe, + .remove = wm8995_remove, + .set_bias_level = wm8995_set_bias_level, + .controls = wm8995_snd_controls, + .num_controls = ARRAY_SIZE(wm8995_snd_controls), + .dapm_widgets = wm8995_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(wm8995_dapm_widgets), + .dapm_routes = wm8995_intercon, + .num_dapm_routes = ARRAY_SIZE(wm8995_intercon), + .pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, };
static const struct regmap_config wm8995_regmap = { @@ -2233,24 +2231,17 @@ static int wm8995_spi_probe(struct spi_device *spi) return ret; }
- ret = snd_soc_register_codec(&spi->dev, - &soc_codec_dev_wm8995, wm8995_dai, + ret = devm_snd_soc_register_component(&spi->dev, + &soc_component_dev_wm8995, wm8995_dai, ARRAY_SIZE(wm8995_dai)); return ret; }
-static int wm8995_spi_remove(struct spi_device *spi) -{ - snd_soc_unregister_codec(&spi->dev); - return 0; -} - static struct spi_driver wm8995_spi_driver = { .driver = { .name = "wm8995", }, .probe = wm8995_spi_probe, - .remove = wm8995_spi_remove }; #endif
@@ -2274,8 +2265,8 @@ static int wm8995_i2c_probe(struct i2c_client *i2c, return ret; }
- ret = snd_soc_register_codec(&i2c->dev, - &soc_codec_dev_wm8995, wm8995_dai, + ret = devm_snd_soc_register_component(&i2c->dev, + &soc_component_dev_wm8995, wm8995_dai, ARRAY_SIZE(wm8995_dai)); if (ret < 0) dev_err(&i2c->dev, "Failed to register CODEC: %d\n", ret); @@ -2283,12 +2274,6 @@ static int wm8995_i2c_probe(struct i2c_client *i2c, return ret; }
-static int wm8995_i2c_remove(struct i2c_client *client) -{ - snd_soc_unregister_codec(&client->dev); - return 0; -} - static const struct i2c_device_id wm8995_i2c_id[] = { {"wm8995", 0}, {} @@ -2301,7 +2286,6 @@ static int wm8995_i2c_remove(struct i2c_client *client) .name = "wm8995", }, .probe = wm8995_i2c_probe, - .remove = wm8995_i2c_remove, .id_table = wm8995_i2c_id }; #endif
From: Kuninori Morimoto kuninori.morimoto.gx@renesas.com
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 -> .pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com --- sound/soc/codecs/wm8961.c | 241 ++++++++++++++++++++++------------------------ 1 file changed, 117 insertions(+), 124 deletions(-)
diff --git a/sound/soc/codecs/wm8961.c b/sound/soc/codecs/wm8961.c index e23ceac..cab7d63 100644 --- a/sound/soc/codecs/wm8961.c +++ b/sound/soc/codecs/wm8961.c @@ -194,89 +194,89 @@ static bool wm8961_readable(struct device *dev, unsigned int reg) static int wm8961_hp_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); - u16 hp_reg = snd_soc_read(codec, WM8961_ANALOGUE_HP_0); - u16 cp_reg = snd_soc_read(codec, WM8961_CHARGE_PUMP_1); - u16 pwr_reg = snd_soc_read(codec, WM8961_PWR_MGMT_2); - u16 dcs_reg = snd_soc_read(codec, WM8961_DC_SERVO_1); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); + u16 hp_reg = snd_soc_component_read32(component, WM8961_ANALOGUE_HP_0); + u16 cp_reg = snd_soc_component_read32(component, WM8961_CHARGE_PUMP_1); + u16 pwr_reg = snd_soc_component_read32(component, WM8961_PWR_MGMT_2); + u16 dcs_reg = snd_soc_component_read32(component, WM8961_DC_SERVO_1); int timeout = 500;
if (event & SND_SOC_DAPM_POST_PMU) { /* Make sure the output is shorted */ hp_reg &= ~(WM8961_HPR_RMV_SHORT | WM8961_HPL_RMV_SHORT); - snd_soc_write(codec, WM8961_ANALOGUE_HP_0, hp_reg); + snd_soc_component_write(component, WM8961_ANALOGUE_HP_0, hp_reg);
/* Enable the charge pump */ cp_reg |= WM8961_CP_ENA; - snd_soc_write(codec, WM8961_CHARGE_PUMP_1, cp_reg); + snd_soc_component_write(component, WM8961_CHARGE_PUMP_1, cp_reg); mdelay(5);
/* Enable the PGA */ pwr_reg |= WM8961_LOUT1_PGA | WM8961_ROUT1_PGA; - snd_soc_write(codec, WM8961_PWR_MGMT_2, pwr_reg); + snd_soc_component_write(component, WM8961_PWR_MGMT_2, pwr_reg);
/* Enable the amplifier */ hp_reg |= WM8961_HPR_ENA | WM8961_HPL_ENA; - snd_soc_write(codec, WM8961_ANALOGUE_HP_0, hp_reg); + snd_soc_component_write(component, WM8961_ANALOGUE_HP_0, hp_reg);
/* Second stage enable */ hp_reg |= WM8961_HPR_ENA_DLY | WM8961_HPL_ENA_DLY; - snd_soc_write(codec, WM8961_ANALOGUE_HP_0, hp_reg); + snd_soc_component_write(component, WM8961_ANALOGUE_HP_0, hp_reg);
/* Enable the DC servo & trigger startup */ dcs_reg |= WM8961_DCS_ENA_CHAN_HPR | WM8961_DCS_TRIG_STARTUP_HPR | WM8961_DCS_ENA_CHAN_HPL | WM8961_DCS_TRIG_STARTUP_HPL; - dev_dbg(codec->dev, "Enabling DC servo\n"); + dev_dbg(component->dev, "Enabling DC servo\n");
- snd_soc_write(codec, WM8961_DC_SERVO_1, dcs_reg); + snd_soc_component_write(component, WM8961_DC_SERVO_1, dcs_reg); do { msleep(1); - dcs_reg = snd_soc_read(codec, WM8961_DC_SERVO_1); + dcs_reg = snd_soc_component_read32(component, WM8961_DC_SERVO_1); } while (--timeout && dcs_reg & (WM8961_DCS_TRIG_STARTUP_HPR | WM8961_DCS_TRIG_STARTUP_HPL)); if (dcs_reg & (WM8961_DCS_TRIG_STARTUP_HPR | WM8961_DCS_TRIG_STARTUP_HPL)) - dev_err(codec->dev, "DC servo timed out\n"); + dev_err(component->dev, "DC servo timed out\n"); else - dev_dbg(codec->dev, "DC servo startup complete\n"); + dev_dbg(component->dev, "DC servo startup complete\n");
/* Enable the output stage */ hp_reg |= WM8961_HPR_ENA_OUTP | WM8961_HPL_ENA_OUTP; - snd_soc_write(codec, WM8961_ANALOGUE_HP_0, hp_reg); + snd_soc_component_write(component, WM8961_ANALOGUE_HP_0, hp_reg);
/* Remove the short on the output stage */ hp_reg |= WM8961_HPR_RMV_SHORT | WM8961_HPL_RMV_SHORT; - snd_soc_write(codec, WM8961_ANALOGUE_HP_0, hp_reg); + snd_soc_component_write(component, WM8961_ANALOGUE_HP_0, hp_reg); }
if (event & SND_SOC_DAPM_PRE_PMD) { /* Short the output */ hp_reg &= ~(WM8961_HPR_RMV_SHORT | WM8961_HPL_RMV_SHORT); - snd_soc_write(codec, WM8961_ANALOGUE_HP_0, hp_reg); + snd_soc_component_write(component, WM8961_ANALOGUE_HP_0, hp_reg);
/* Disable the output stage */ hp_reg &= ~(WM8961_HPR_ENA_OUTP | WM8961_HPL_ENA_OUTP); - snd_soc_write(codec, WM8961_ANALOGUE_HP_0, hp_reg); + snd_soc_component_write(component, WM8961_ANALOGUE_HP_0, hp_reg);
/* Disable DC offset cancellation */ dcs_reg &= ~(WM8961_DCS_ENA_CHAN_HPR | WM8961_DCS_ENA_CHAN_HPL); - snd_soc_write(codec, WM8961_DC_SERVO_1, dcs_reg); + snd_soc_component_write(component, WM8961_DC_SERVO_1, dcs_reg);
/* Finish up */ hp_reg &= ~(WM8961_HPR_ENA_DLY | WM8961_HPR_ENA | WM8961_HPL_ENA_DLY | WM8961_HPL_ENA); - snd_soc_write(codec, WM8961_ANALOGUE_HP_0, hp_reg); + snd_soc_component_write(component, WM8961_ANALOGUE_HP_0, hp_reg);
/* Disable the PGA */ pwr_reg &= ~(WM8961_LOUT1_PGA | WM8961_ROUT1_PGA); - snd_soc_write(codec, WM8961_PWR_MGMT_2, pwr_reg); + snd_soc_component_write(component, WM8961_PWR_MGMT_2, pwr_reg);
/* Disable the charge pump */ - dev_dbg(codec->dev, "Disabling charge pump\n"); - snd_soc_write(codec, WM8961_CHARGE_PUMP_1, + dev_dbg(component->dev, "Disabling charge pump\n"); + snd_soc_component_write(component, WM8961_CHARGE_PUMP_1, cp_reg & ~WM8961_CP_ENA); }
@@ -286,28 +286,28 @@ static int wm8961_hp_event(struct snd_soc_dapm_widget *w, static int wm8961_spk_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); - u16 pwr_reg = snd_soc_read(codec, WM8961_PWR_MGMT_2); - u16 spk_reg = snd_soc_read(codec, WM8961_CLASS_D_CONTROL_1); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); + u16 pwr_reg = snd_soc_component_read32(component, WM8961_PWR_MGMT_2); + u16 spk_reg = snd_soc_component_read32(component, WM8961_CLASS_D_CONTROL_1);
if (event & SND_SOC_DAPM_POST_PMU) { /* Enable the PGA */ pwr_reg |= WM8961_SPKL_PGA | WM8961_SPKR_PGA; - snd_soc_write(codec, WM8961_PWR_MGMT_2, pwr_reg); + snd_soc_component_write(component, WM8961_PWR_MGMT_2, pwr_reg);
/* Enable the amplifier */ spk_reg |= WM8961_SPKL_ENA | WM8961_SPKR_ENA; - snd_soc_write(codec, WM8961_CLASS_D_CONTROL_1, spk_reg); + snd_soc_component_write(component, WM8961_CLASS_D_CONTROL_1, spk_reg); }
if (event & SND_SOC_DAPM_PRE_PMD) { /* Disable the amplifier */ spk_reg &= ~(WM8961_SPKL_ENA | WM8961_SPKR_ENA); - snd_soc_write(codec, WM8961_CLASS_D_CONTROL_1, spk_reg); + snd_soc_component_write(component, WM8961_CLASS_D_CONTROL_1, spk_reg);
/* Disable the PGA */ pwr_reg &= ~(WM8961_SPKL_PGA | WM8961_SPKR_PGA); - snd_soc_write(codec, WM8961_PWR_MGMT_2, pwr_reg); + snd_soc_component_write(component, WM8961_PWR_MGMT_2, pwr_reg); }
return 0; @@ -505,15 +505,15 @@ static int wm8961_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; - struct wm8961_priv *wm8961 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct wm8961_priv *wm8961 = snd_soc_component_get_drvdata(component); int i, best, target, fs; u16 reg;
fs = params_rate(params);
if (!wm8961->sysclk) { - dev_err(codec->dev, "MCLK has not been specified\n"); + dev_err(component->dev, "MCLK has not been specified\n"); return -EINVAL; }
@@ -524,23 +524,23 @@ static int wm8961_hw_params(struct snd_pcm_substream *substream, abs(wm8961_srate[best].rate - fs)) best = i; } - reg = snd_soc_read(codec, WM8961_ADDITIONAL_CONTROL_3); + reg = snd_soc_component_read32(component, WM8961_ADDITIONAL_CONTROL_3); reg &= ~WM8961_SAMPLE_RATE_MASK; reg |= wm8961_srate[best].val; - snd_soc_write(codec, WM8961_ADDITIONAL_CONTROL_3, reg); - dev_dbg(codec->dev, "Selected SRATE %dHz for %dHz\n", + snd_soc_component_write(component, WM8961_ADDITIONAL_CONTROL_3, reg); + dev_dbg(component->dev, "Selected SRATE %dHz for %dHz\n", wm8961_srate[best].rate, fs);
/* Select a CLK_SYS/fs ratio equal to or higher than required */ target = wm8961->sysclk / fs;
if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK && target < 64) { - dev_err(codec->dev, + dev_err(component->dev, "SYSCLK must be at least 64*fs for DAC\n"); return -EINVAL; } if (substream->stream == SNDRV_PCM_STREAM_CAPTURE && target < 256) { - dev_err(codec->dev, + dev_err(component->dev, "SYSCLK must be at least 256*fs for ADC\n"); return -EINVAL; } @@ -550,19 +550,19 @@ static int wm8961_hw_params(struct snd_pcm_substream *substream, break; } if (i == ARRAY_SIZE(wm8961_clk_sys_ratio)) { - dev_err(codec->dev, "Unable to generate CLK_SYS_RATE\n"); + dev_err(component->dev, "Unable to generate CLK_SYS_RATE\n"); return -EINVAL; } - dev_dbg(codec->dev, "Selected CLK_SYS_RATE of %d for %d/%d=%d\n", + dev_dbg(component->dev, "Selected CLK_SYS_RATE of %d for %d/%d=%d\n", wm8961_clk_sys_ratio[i].ratio, wm8961->sysclk, fs, wm8961->sysclk / fs);
- reg = snd_soc_read(codec, WM8961_CLOCKING_4); + reg = snd_soc_component_read32(component, WM8961_CLOCKING_4); reg &= ~WM8961_CLK_SYS_RATE_MASK; reg |= wm8961_clk_sys_ratio[i].val << WM8961_CLK_SYS_RATE_SHIFT; - snd_soc_write(codec, WM8961_CLOCKING_4, reg); + snd_soc_component_write(component, WM8961_CLOCKING_4, reg);
- reg = snd_soc_read(codec, WM8961_AUDIO_INTERFACE_0); + reg = snd_soc_component_read32(component, WM8961_AUDIO_INTERFACE_0); reg &= ~WM8961_WL_MASK; switch (params_width(params)) { case 16: @@ -579,15 +579,15 @@ static int wm8961_hw_params(struct snd_pcm_substream *substream, default: return -EINVAL; } - snd_soc_write(codec, WM8961_AUDIO_INTERFACE_0, reg); + snd_soc_component_write(component, WM8961_AUDIO_INTERFACE_0, reg);
/* Sloping stop-band filter is recommended for <= 24kHz */ - reg = snd_soc_read(codec, WM8961_ADC_DAC_CONTROL_2); + reg = snd_soc_component_read32(component, WM8961_ADC_DAC_CONTROL_2); if (fs <= 24000) reg |= WM8961_DACSLOPE; else reg &= ~WM8961_DACSLOPE; - snd_soc_write(codec, WM8961_ADC_DAC_CONTROL_2, reg); + snd_soc_component_write(component, WM8961_ADC_DAC_CONTROL_2, reg);
return 0; } @@ -596,25 +596,25 @@ static int wm8961_set_sysclk(struct snd_soc_dai *dai, int clk_id, unsigned int freq, int dir) { - struct snd_soc_codec *codec = dai->codec; - struct wm8961_priv *wm8961 = snd_soc_codec_get_drvdata(codec); - u16 reg = snd_soc_read(codec, WM8961_CLOCKING1); + struct snd_soc_component *component = dai->component; + struct wm8961_priv *wm8961 = snd_soc_component_get_drvdata(component); + u16 reg = snd_soc_component_read32(component, WM8961_CLOCKING1);
if (freq > 33000000) { - dev_err(codec->dev, "MCLK must be <33MHz\n"); + dev_err(component->dev, "MCLK must be <33MHz\n"); return -EINVAL; }
if (freq > 16500000) { - dev_dbg(codec->dev, "Using MCLK/2 for %dHz MCLK\n", freq); + dev_dbg(component->dev, "Using MCLK/2 for %dHz MCLK\n", freq); reg |= WM8961_MCLKDIV; freq /= 2; } else { - dev_dbg(codec->dev, "Using MCLK/1 for %dHz MCLK\n", freq); + dev_dbg(component->dev, "Using MCLK/1 for %dHz MCLK\n", freq); reg &= ~WM8961_MCLKDIV; }
- snd_soc_write(codec, WM8961_CLOCKING1, reg); + snd_soc_component_write(component, WM8961_CLOCKING1, reg);
wm8961->sysclk = freq;
@@ -623,8 +623,8 @@ static int wm8961_set_sysclk(struct snd_soc_dai *dai, int clk_id,
static int wm8961_set_fmt(struct snd_soc_dai *dai, unsigned int fmt) { - struct snd_soc_codec *codec = dai->codec; - u16 aif = snd_soc_read(codec, WM8961_AUDIO_INTERFACE_0); + struct snd_soc_component *component = dai->component; + u16 aif = snd_soc_component_read32(component, WM8961_AUDIO_INTERFACE_0);
aif &= ~(WM8961_BCLKINV | WM8961_LRP | WM8961_MS | WM8961_FORMAT_MASK); @@ -684,26 +684,26 @@ static int wm8961_set_fmt(struct snd_soc_dai *dai, unsigned int fmt) return -EINVAL; }
- return snd_soc_write(codec, WM8961_AUDIO_INTERFACE_0, aif); + return snd_soc_component_write(component, WM8961_AUDIO_INTERFACE_0, aif); }
static int wm8961_set_tristate(struct snd_soc_dai *dai, int tristate) { - struct snd_soc_codec *codec = dai->codec; - u16 reg = snd_soc_read(codec, WM8961_ADDITIONAL_CONTROL_2); + struct snd_soc_component *component = dai->component; + u16 reg = snd_soc_component_read32(component, WM8961_ADDITIONAL_CONTROL_2);
if (tristate) reg |= WM8961_TRIS; else reg &= ~WM8961_TRIS;
- return snd_soc_write(codec, WM8961_ADDITIONAL_CONTROL_2, reg); + return snd_soc_component_write(component, WM8961_ADDITIONAL_CONTROL_2, reg); }
static int wm8961_digital_mute(struct snd_soc_dai *dai, int mute) { - struct snd_soc_codec *codec = dai->codec; - u16 reg = snd_soc_read(codec, WM8961_ADC_DAC_CONTROL_1); + struct snd_soc_component *component = dai->component; + u16 reg = snd_soc_component_read32(component, WM8961_ADC_DAC_CONTROL_1);
if (mute) reg |= WM8961_DACMU; @@ -712,27 +712,27 @@ static int wm8961_digital_mute(struct snd_soc_dai *dai, int mute)
msleep(17);
- return snd_soc_write(codec, WM8961_ADC_DAC_CONTROL_1, reg); + return snd_soc_component_write(component, WM8961_ADC_DAC_CONTROL_1, reg); }
static int wm8961_set_clkdiv(struct snd_soc_dai *dai, int div_id, int div) { - struct snd_soc_codec *codec = dai->codec; + struct snd_soc_component *component = dai->component; u16 reg;
switch (div_id) { case WM8961_BCLK: - reg = snd_soc_read(codec, WM8961_CLOCKING2); + reg = snd_soc_component_read32(component, WM8961_CLOCKING2); reg &= ~WM8961_BCLKDIV_MASK; reg |= div; - snd_soc_write(codec, WM8961_CLOCKING2, reg); + snd_soc_component_write(component, WM8961_CLOCKING2, reg); break;
case WM8961_LRCLK: - reg = snd_soc_read(codec, WM8961_AUDIO_INTERFACE_2); + reg = snd_soc_component_read32(component, WM8961_AUDIO_INTERFACE_2); reg &= ~WM8961_LRCLK_RATE_MASK; reg |= div; - snd_soc_write(codec, WM8961_AUDIO_INTERFACE_2, reg); + snd_soc_component_write(component, WM8961_AUDIO_INTERFACE_2, reg); break;
default: @@ -742,7 +742,7 @@ static int wm8961_set_clkdiv(struct snd_soc_dai *dai, int div_id, int div) return 0; }
-static int wm8961_set_bias_level(struct snd_soc_codec *codec, +static int wm8961_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { u16 reg; @@ -757,36 +757,36 @@ static int wm8961_set_bias_level(struct snd_soc_codec *codec, break;
case SND_SOC_BIAS_PREPARE: - if (snd_soc_codec_get_bias_level(codec) == SND_SOC_BIAS_STANDBY) { + if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_STANDBY) { /* Enable bias generation */ - reg = snd_soc_read(codec, WM8961_ANTI_POP); + reg = snd_soc_component_read32(component, WM8961_ANTI_POP); reg |= WM8961_BUFIOEN | WM8961_BUFDCOPEN; - snd_soc_write(codec, WM8961_ANTI_POP, reg); + snd_soc_component_write(component, WM8961_ANTI_POP, reg);
/* VMID=2*50k, VREF */ - reg = snd_soc_read(codec, WM8961_PWR_MGMT_1); + reg = snd_soc_component_read32(component, WM8961_PWR_MGMT_1); reg &= ~WM8961_VMIDSEL_MASK; reg |= (1 << WM8961_VMIDSEL_SHIFT) | WM8961_VREF; - snd_soc_write(codec, WM8961_PWR_MGMT_1, reg); + snd_soc_component_write(component, WM8961_PWR_MGMT_1, reg); } break;
case SND_SOC_BIAS_STANDBY: - if (snd_soc_codec_get_bias_level(codec) == SND_SOC_BIAS_PREPARE) { + if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_PREPARE) { /* VREF off */ - reg = snd_soc_read(codec, WM8961_PWR_MGMT_1); + reg = snd_soc_component_read32(component, WM8961_PWR_MGMT_1); reg &= ~WM8961_VREF; - snd_soc_write(codec, WM8961_PWR_MGMT_1, reg); + snd_soc_component_write(component, WM8961_PWR_MGMT_1, reg);
/* Bias generation off */ - reg = snd_soc_read(codec, WM8961_ANTI_POP); + reg = snd_soc_component_read32(component, WM8961_ANTI_POP); reg &= ~(WM8961_BUFIOEN | WM8961_BUFDCOPEN); - snd_soc_write(codec, WM8961_ANTI_POP, reg); + snd_soc_component_write(component, WM8961_ANTI_POP, reg);
/* VMID off */ - reg = snd_soc_read(codec, WM8961_PWR_MGMT_1); + reg = snd_soc_component_read32(component, WM8961_PWR_MGMT_1); reg &= ~WM8961_VMIDSEL_MASK; - snd_soc_write(codec, WM8961_PWR_MGMT_1, reg); + snd_soc_component_write(component, WM8961_PWR_MGMT_1, reg); } break;
@@ -830,51 +830,51 @@ static int wm8961_set_bias_level(struct snd_soc_codec *codec, .ops = &wm8961_dai_ops, };
-static int wm8961_probe(struct snd_soc_codec *codec) +static int wm8961_probe(struct snd_soc_component *component) { u16 reg;
/* Enable class W */ - reg = snd_soc_read(codec, WM8961_CHARGE_PUMP_B); + reg = snd_soc_component_read32(component, WM8961_CHARGE_PUMP_B); reg |= WM8961_CP_DYN_PWR_MASK; - snd_soc_write(codec, WM8961_CHARGE_PUMP_B, reg); + snd_soc_component_write(component, WM8961_CHARGE_PUMP_B, reg);
/* Latch volume update bits (right channel only, we always * write both out) and default ZC on. */ - reg = snd_soc_read(codec, WM8961_ROUT1_VOLUME); - snd_soc_write(codec, WM8961_ROUT1_VOLUME, + reg = snd_soc_component_read32(component, WM8961_ROUT1_VOLUME); + snd_soc_component_write(component, WM8961_ROUT1_VOLUME, reg | WM8961_LO1ZC | WM8961_OUT1VU); - snd_soc_write(codec, WM8961_LOUT1_VOLUME, reg | WM8961_LO1ZC); - reg = snd_soc_read(codec, WM8961_ROUT2_VOLUME); - snd_soc_write(codec, WM8961_ROUT2_VOLUME, + snd_soc_component_write(component, WM8961_LOUT1_VOLUME, reg | WM8961_LO1ZC); + reg = snd_soc_component_read32(component, WM8961_ROUT2_VOLUME); + snd_soc_component_write(component, WM8961_ROUT2_VOLUME, reg | WM8961_SPKRZC | WM8961_SPKVU); - snd_soc_write(codec, WM8961_LOUT2_VOLUME, reg | WM8961_SPKLZC); + snd_soc_component_write(component, WM8961_LOUT2_VOLUME, reg | WM8961_SPKLZC);
- reg = snd_soc_read(codec, WM8961_RIGHT_ADC_VOLUME); - snd_soc_write(codec, WM8961_RIGHT_ADC_VOLUME, reg | WM8961_ADCVU); - reg = snd_soc_read(codec, WM8961_RIGHT_INPUT_VOLUME); - snd_soc_write(codec, WM8961_RIGHT_INPUT_VOLUME, reg | WM8961_IPVU); + reg = snd_soc_component_read32(component, WM8961_RIGHT_ADC_VOLUME); + snd_soc_component_write(component, WM8961_RIGHT_ADC_VOLUME, reg | WM8961_ADCVU); + reg = snd_soc_component_read32(component, WM8961_RIGHT_INPUT_VOLUME); + snd_soc_component_write(component, WM8961_RIGHT_INPUT_VOLUME, reg | WM8961_IPVU);
/* Use soft mute by default */ - reg = snd_soc_read(codec, WM8961_ADC_DAC_CONTROL_2); + reg = snd_soc_component_read32(component, WM8961_ADC_DAC_CONTROL_2); reg |= WM8961_DACSMM; - snd_soc_write(codec, WM8961_ADC_DAC_CONTROL_2, reg); + snd_soc_component_write(component, WM8961_ADC_DAC_CONTROL_2, reg);
/* Use automatic clocking mode by default; for now this is all * we support. */ - reg = snd_soc_read(codec, WM8961_CLOCKING_3); + reg = snd_soc_component_read32(component, WM8961_CLOCKING_3); reg &= ~WM8961_MANUAL_MODE; - snd_soc_write(codec, WM8961_CLOCKING_3, reg); + snd_soc_component_write(component, WM8961_CLOCKING_3, reg);
return 0; }
#ifdef CONFIG_PM
-static int wm8961_resume(struct snd_soc_codec *codec) +static int wm8961_resume(struct snd_soc_component *component) { - snd_soc_cache_sync(codec); + snd_soc_component_cache_sync(component);
return 0; } @@ -882,20 +882,21 @@ static int wm8961_resume(struct snd_soc_codec *codec) #define wm8961_resume NULL #endif
-static const struct snd_soc_codec_driver soc_codec_dev_wm8961 = { - .probe = wm8961_probe, - .resume = wm8961_resume, - .set_bias_level = wm8961_set_bias_level, - .suspend_bias_off = true, - - .component_driver = { - .controls = wm8961_snd_controls, - .num_controls = ARRAY_SIZE(wm8961_snd_controls), - .dapm_widgets = wm8961_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(wm8961_dapm_widgets), - .dapm_routes = audio_paths, - .num_dapm_routes = ARRAY_SIZE(audio_paths), - }, +static const struct snd_soc_component_driver soc_component_dev_wm8961 = { + .probe = wm8961_probe, + .resume = wm8961_resume, + .set_bias_level = wm8961_set_bias_level, + .controls = wm8961_snd_controls, + .num_controls = ARRAY_SIZE(wm8961_snd_controls), + .dapm_widgets = wm8961_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(wm8961_dapm_widgets), + .dapm_routes = audio_paths, + .num_dapm_routes = ARRAY_SIZE(audio_paths), + .suspend_bias_off = 1, + .idle_bias_on = 1, + .pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, };
static const struct regmap_config wm8961_regmap = { @@ -961,19 +962,12 @@ static int wm8961_i2c_probe(struct i2c_client *i2c,
i2c_set_clientdata(i2c, wm8961);
- ret = snd_soc_register_codec(&i2c->dev, - &soc_codec_dev_wm8961, &wm8961_dai, 1); + ret = devm_snd_soc_register_component(&i2c->dev, + &soc_component_dev_wm8961, &wm8961_dai, 1);
return ret; }
-static int wm8961_i2c_remove(struct i2c_client *client) -{ - snd_soc_unregister_codec(&client->dev); - - return 0; -} - static const struct i2c_device_id wm8961_i2c_id[] = { { "wm8961", 0 }, { } @@ -985,7 +979,6 @@ static int wm8961_i2c_remove(struct i2c_client *client) .name = "wm8961", }, .probe = wm8961_i2c_probe, - .remove = wm8961_i2c_remove, .id_table = wm8961_i2c_id, };
From: Kuninori Morimoto kuninori.morimoto.gx@renesas.com
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 -> .pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com --- sound/soc/codecs/wm8940.c | 159 ++++++++++++++++++++++------------------------ 1 file changed, 76 insertions(+), 83 deletions(-)
diff --git a/sound/soc/codecs/wm8940.c b/sound/soc/codecs/wm8940.c index b593562..e1fc6eb 100644 --- a/sound/soc/codecs/wm8940.c +++ b/sound/soc/codecs/wm8940.c @@ -334,14 +334,14 @@ static SOC_ENUM_SINGLE_DECL(wm8940_filter_mode_enum, {"ADC", NULL, "Boost Mixer"}, };
-#define wm8940_reset(c) snd_soc_write(c, WM8940_SOFTRESET, 0); +#define wm8940_reset(c) snd_soc_component_write(c, WM8940_SOFTRESET, 0);
static int wm8940_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt) { - struct snd_soc_codec *codec = codec_dai->codec; - u16 iface = snd_soc_read(codec, WM8940_IFACE) & 0xFE67; - u16 clk = snd_soc_read(codec, WM8940_CLOCK) & 0x1fe; + struct snd_soc_component *component = codec_dai->component; + u16 iface = snd_soc_component_read32(component, WM8940_IFACE) & 0xFE67; + u16 clk = snd_soc_component_read32(component, WM8940_CLOCK) & 0x1fe;
switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { case SND_SOC_DAIFMT_CBM_CFM: @@ -352,7 +352,7 @@ static int wm8940_set_dai_fmt(struct snd_soc_dai *codec_dai, default: return -EINVAL; } - snd_soc_write(codec, WM8940_CLOCK, clk); + snd_soc_component_write(component, WM8940_CLOCK, clk);
switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) { case SND_SOC_DAIFMT_I2S: @@ -385,7 +385,7 @@ static int wm8940_set_dai_fmt(struct snd_soc_dai *codec_dai, break; }
- snd_soc_write(codec, WM8940_IFACE, iface); + snd_soc_component_write(component, WM8940_IFACE, iface);
return 0; } @@ -394,10 +394,10 @@ static int wm8940_i2s_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; - u16 iface = snd_soc_read(codec, WM8940_IFACE) & 0xFD9F; - u16 addcntrl = snd_soc_read(codec, WM8940_ADDCNTRL) & 0xFFF1; - u16 companding = snd_soc_read(codec, + struct snd_soc_component *component = dai->component; + u16 iface = snd_soc_component_read32(component, WM8940_IFACE) & 0xFD9F; + u16 addcntrl = snd_soc_component_read32(component, WM8940_ADDCNTRL) & 0xFFF1; + u16 companding = snd_soc_component_read32(component, WM8940_COMPANDINGCTL) & 0xFFDF; int ret;
@@ -426,7 +426,7 @@ static int wm8940_i2s_hw_params(struct snd_pcm_substream *substream, case 48000: break; } - ret = snd_soc_write(codec, WM8940_ADDCNTRL, addcntrl); + ret = snd_soc_component_write(component, WM8940_ADDCNTRL, addcntrl); if (ret) goto error_ret;
@@ -446,10 +446,10 @@ static int wm8940_i2s_hw_params(struct snd_pcm_substream *substream, iface |= (3 << 5); break; } - ret = snd_soc_write(codec, WM8940_COMPANDINGCTL, companding); + ret = snd_soc_component_write(component, WM8940_COMPANDINGCTL, companding); if (ret) goto error_ret; - ret = snd_soc_write(codec, WM8940_IFACE, iface); + ret = snd_soc_component_write(component, WM8940_IFACE, iface);
error_ret: return ret; @@ -457,21 +457,21 @@ static int wm8940_i2s_hw_params(struct snd_pcm_substream *substream,
static int wm8940_mute(struct snd_soc_dai *dai, int mute) { - struct snd_soc_codec *codec = dai->codec; - u16 mute_reg = snd_soc_read(codec, WM8940_DAC) & 0xffbf; + struct snd_soc_component *component = dai->component; + u16 mute_reg = snd_soc_component_read32(component, WM8940_DAC) & 0xffbf;
if (mute) mute_reg |= 0x40;
- return snd_soc_write(codec, WM8940_DAC, mute_reg); + return snd_soc_component_write(component, WM8940_DAC, mute_reg); }
-static int wm8940_set_bias_level(struct snd_soc_codec *codec, +static int wm8940_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { - struct wm8940_priv *wm8940 = snd_soc_codec_get_drvdata(codec); + struct wm8940_priv *wm8940 = snd_soc_component_get_drvdata(component); u16 val; - u16 pwr_reg = snd_soc_read(codec, WM8940_POWER1) & 0x1F0; + u16 pwr_reg = snd_soc_component_read32(component, WM8940_POWER1) & 0x1F0; int ret = 0;
switch (level) { @@ -479,23 +479,23 @@ static int wm8940_set_bias_level(struct snd_soc_codec *codec, /* ensure bufioen and biasen */ pwr_reg |= (1 << 2) | (1 << 3); /* Enable thermal shutdown */ - val = snd_soc_read(codec, WM8940_OUTPUTCTL); - ret = snd_soc_write(codec, WM8940_OUTPUTCTL, val | 0x2); + val = snd_soc_component_read32(component, WM8940_OUTPUTCTL); + ret = snd_soc_component_write(component, WM8940_OUTPUTCTL, val | 0x2); if (ret) break; /* set vmid to 75k */ - ret = snd_soc_write(codec, WM8940_POWER1, pwr_reg | 0x1); + ret = snd_soc_component_write(component, WM8940_POWER1, pwr_reg | 0x1); break; case SND_SOC_BIAS_PREPARE: /* ensure bufioen and biasen */ pwr_reg |= (1 << 2) | (1 << 3); - ret = snd_soc_write(codec, WM8940_POWER1, pwr_reg | 0x1); + ret = snd_soc_component_write(component, WM8940_POWER1, pwr_reg | 0x1); break; case SND_SOC_BIAS_STANDBY: - if (snd_soc_codec_get_bias_level(codec) == SND_SOC_BIAS_OFF) { + if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_OFF) { ret = regcache_sync(wm8940->regmap); if (ret < 0) { - dev_err(codec->dev, "Failed to sync cache: %d\n", ret); + dev_err(component->dev, "Failed to sync cache: %d\n", ret); return ret; } } @@ -503,10 +503,10 @@ static int wm8940_set_bias_level(struct snd_soc_codec *codec, /* ensure bufioen and biasen */ pwr_reg |= (1 << 2) | (1 << 3); /* set vmid to 300k for standby */ - ret = snd_soc_write(codec, WM8940_POWER1, pwr_reg | 0x2); + ret = snd_soc_component_write(component, WM8940_POWER1, pwr_reg | 0x2); break; case SND_SOC_BIAS_OFF: - ret = snd_soc_write(codec, WM8940_POWER1, pwr_reg); + ret = snd_soc_component_write(component, WM8940_POWER1, pwr_reg); break; }
@@ -576,40 +576,40 @@ static void pll_factors(unsigned int target, unsigned int source) static int wm8940_set_dai_pll(struct snd_soc_dai *codec_dai, int pll_id, int source, unsigned int freq_in, unsigned int freq_out) { - struct snd_soc_codec *codec = codec_dai->codec; + struct snd_soc_component *component = codec_dai->component; u16 reg;
/* Turn off PLL */ - reg = snd_soc_read(codec, WM8940_POWER1); - snd_soc_write(codec, WM8940_POWER1, reg & 0x1df); + reg = snd_soc_component_read32(component, WM8940_POWER1); + snd_soc_component_write(component, WM8940_POWER1, reg & 0x1df);
if (freq_in == 0 || freq_out == 0) { /* Clock CODEC directly from MCLK */ - reg = snd_soc_read(codec, WM8940_CLOCK); - snd_soc_write(codec, WM8940_CLOCK, reg & 0x0ff); + reg = snd_soc_component_read32(component, WM8940_CLOCK); + snd_soc_component_write(component, WM8940_CLOCK, reg & 0x0ff); /* Pll power down */ - snd_soc_write(codec, WM8940_PLLN, (1 << 7)); + snd_soc_component_write(component, WM8940_PLLN, (1 << 7)); return 0; }
/* Pll is followed by a frequency divide by 4 */ pll_factors(freq_out*4, freq_in); if (pll_div.k) - snd_soc_write(codec, WM8940_PLLN, + snd_soc_component_write(component, WM8940_PLLN, (pll_div.pre_scale << 4) | pll_div.n | (1 << 6)); else /* No factional component */ - snd_soc_write(codec, WM8940_PLLN, + snd_soc_component_write(component, WM8940_PLLN, (pll_div.pre_scale << 4) | pll_div.n); - snd_soc_write(codec, WM8940_PLLK1, pll_div.k >> 18); - snd_soc_write(codec, WM8940_PLLK2, (pll_div.k >> 9) & 0x1ff); - snd_soc_write(codec, WM8940_PLLK3, pll_div.k & 0x1ff); + snd_soc_component_write(component, WM8940_PLLK1, pll_div.k >> 18); + snd_soc_component_write(component, WM8940_PLLK2, (pll_div.k >> 9) & 0x1ff); + snd_soc_component_write(component, WM8940_PLLK3, pll_div.k & 0x1ff); /* Enable the PLL */ - reg = snd_soc_read(codec, WM8940_POWER1); - snd_soc_write(codec, WM8940_POWER1, reg | 0x020); + reg = snd_soc_component_read32(component, WM8940_POWER1); + snd_soc_component_write(component, WM8940_POWER1, reg | 0x020);
/* Run CODEC from PLL instead of MCLK */ - reg = snd_soc_read(codec, WM8940_CLOCK); - snd_soc_write(codec, WM8940_CLOCK, reg | 0x100); + reg = snd_soc_component_read32(component, WM8940_CLOCK); + snd_soc_component_write(component, WM8940_CLOCK, reg | 0x100);
return 0; } @@ -617,8 +617,8 @@ static int wm8940_set_dai_pll(struct snd_soc_dai *codec_dai, int pll_id, static int wm8940_set_dai_sysclk(struct snd_soc_dai *codec_dai, int clk_id, unsigned int freq, int dir) { - struct snd_soc_codec *codec = codec_dai->codec; - struct wm8940_priv *wm8940 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = codec_dai->component; + struct wm8940_priv *wm8940 = snd_soc_component_get_drvdata(component);
switch (freq) { case 11289600: @@ -635,22 +635,22 @@ static int wm8940_set_dai_sysclk(struct snd_soc_dai *codec_dai, static int wm8940_set_dai_clkdiv(struct snd_soc_dai *codec_dai, int div_id, int div) { - struct snd_soc_codec *codec = codec_dai->codec; + struct snd_soc_component *component = codec_dai->component; u16 reg; int ret = 0;
switch (div_id) { case WM8940_BCLKDIV: - reg = snd_soc_read(codec, WM8940_CLOCK) & 0xFFE3; - ret = snd_soc_write(codec, WM8940_CLOCK, reg | (div << 2)); + reg = snd_soc_component_read32(component, WM8940_CLOCK) & 0xFFE3; + ret = snd_soc_component_write(component, WM8940_CLOCK, reg | (div << 2)); break; case WM8940_MCLKDIV: - reg = snd_soc_read(codec, WM8940_CLOCK) & 0xFF1F; - ret = snd_soc_write(codec, WM8940_CLOCK, reg | (div << 5)); + reg = snd_soc_component_read32(component, WM8940_CLOCK) & 0xFF1F; + ret = snd_soc_component_write(component, WM8940_CLOCK, reg | (div << 5)); break; case WM8940_OPCLKDIV: - reg = snd_soc_read(codec, WM8940_GPIO) & 0xFFCF; - ret = snd_soc_write(codec, WM8940_GPIO, reg | (div << 4)); + reg = snd_soc_component_read32(component, WM8940_GPIO) & 0xFFCF; + ret = snd_soc_component_write(component, WM8940_GPIO, reg | (div << 4)); break; } return ret; @@ -693,29 +693,29 @@ static int wm8940_set_dai_clkdiv(struct snd_soc_dai *codec_dai, .symmetric_rates = 1, };
-static int wm8940_probe(struct snd_soc_codec *codec) +static int wm8940_probe(struct snd_soc_component *component) { - struct wm8940_setup_data *pdata = codec->dev->platform_data; + struct wm8940_setup_data *pdata = component->dev->platform_data; int ret; u16 reg;
- ret = wm8940_reset(codec); + ret = wm8940_reset(component); if (ret < 0) { - dev_err(codec->dev, "Failed to issue reset\n"); + dev_err(component->dev, "Failed to issue reset\n"); return ret; }
- snd_soc_codec_force_bias_level(codec, SND_SOC_BIAS_STANDBY); + snd_soc_component_force_bias_level(component, SND_SOC_BIAS_STANDBY);
- ret = snd_soc_write(codec, WM8940_POWER1, 0x180); + ret = snd_soc_component_write(component, WM8940_POWER1, 0x180); if (ret < 0) return ret;
if (!pdata) - dev_warn(codec->dev, "No platform data supplied\n"); + dev_warn(component->dev, "No platform data supplied\n"); else { - reg = snd_soc_read(codec, WM8940_OUTPUTCTL); - ret = snd_soc_write(codec, WM8940_OUTPUTCTL, reg | pdata->vroi); + reg = snd_soc_component_read32(component, WM8940_OUTPUTCTL); + ret = snd_soc_component_write(component, WM8940_OUTPUTCTL, reg | pdata->vroi); if (ret < 0) return ret; } @@ -723,19 +723,20 @@ static int wm8940_probe(struct snd_soc_codec *codec) return ret; }
-static const struct snd_soc_codec_driver soc_codec_dev_wm8940 = { - .probe = wm8940_probe, - .set_bias_level = wm8940_set_bias_level, - .suspend_bias_off = true, - - .component_driver = { - .controls = wm8940_snd_controls, - .num_controls = ARRAY_SIZE(wm8940_snd_controls), - .dapm_widgets = wm8940_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(wm8940_dapm_widgets), - .dapm_routes = wm8940_dapm_routes, - .num_dapm_routes = ARRAY_SIZE(wm8940_dapm_routes), - }, +static const struct snd_soc_component_driver soc_component_dev_wm8940 = { + .probe = wm8940_probe, + .set_bias_level = wm8940_set_bias_level, + .controls = wm8940_snd_controls, + .num_controls = ARRAY_SIZE(wm8940_snd_controls), + .dapm_widgets = wm8940_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(wm8940_dapm_widgets), + .dapm_routes = wm8940_dapm_routes, + .num_dapm_routes = ARRAY_SIZE(wm8940_dapm_routes), + .suspend_bias_off = 1, + .idle_bias_on = 1, + .pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, };
static const struct regmap_config wm8940_regmap = { @@ -768,19 +769,12 @@ static int wm8940_i2c_probe(struct i2c_client *i2c,
i2c_set_clientdata(i2c, wm8940);
- ret = snd_soc_register_codec(&i2c->dev, - &soc_codec_dev_wm8940, &wm8940_dai, 1); + ret = devm_snd_soc_register_component(&i2c->dev, + &soc_component_dev_wm8940, &wm8940_dai, 1);
return ret; }
-static int wm8940_i2c_remove(struct i2c_client *client) -{ - snd_soc_unregister_codec(&client->dev); - - return 0; -} - static const struct i2c_device_id wm8940_i2c_id[] = { { "wm8940", 0 }, { } @@ -792,7 +786,6 @@ static int wm8940_i2c_remove(struct i2c_client *client) .name = "wm8940", }, .probe = wm8940_i2c_probe, - .remove = wm8940_i2c_remove, .id_table = wm8940_i2c_id, };
From: Kuninori Morimoto kuninori.morimoto.gx@renesas.com
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 -> .pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com --- sound/soc/codecs/wm8904.c | 355 +++++++++++++++++++++++----------------------- 1 file changed, 174 insertions(+), 181 deletions(-)
diff --git a/sound/soc/codecs/wm8904.c b/sound/soc/codecs/wm8904.c index 4fd350e8..182821e 100644 --- a/sound/soc/codecs/wm8904.c +++ b/sound/soc/codecs/wm8904.c @@ -316,31 +316,31 @@ static bool wm8904_readable_register(struct device *dev, unsigned int reg) } }
-static int wm8904_configure_clocking(struct snd_soc_codec *codec) +static int wm8904_configure_clocking(struct snd_soc_component *component) { - struct wm8904_priv *wm8904 = snd_soc_codec_get_drvdata(codec); + struct wm8904_priv *wm8904 = snd_soc_component_get_drvdata(component); unsigned int clock0, clock2, rate;
/* Gate the clock while we're updating to avoid misclocking */ - clock2 = snd_soc_read(codec, WM8904_CLOCK_RATES_2); - snd_soc_update_bits(codec, WM8904_CLOCK_RATES_2, + clock2 = snd_soc_component_read32(component, WM8904_CLOCK_RATES_2); + snd_soc_component_update_bits(component, WM8904_CLOCK_RATES_2, WM8904_SYSCLK_SRC, 0);
/* This should be done on init() for bypass paths */ switch (wm8904->sysclk_src) { case WM8904_CLK_MCLK: - dev_dbg(codec->dev, "Using %dHz MCLK\n", wm8904->mclk_rate); + dev_dbg(component->dev, "Using %dHz MCLK\n", wm8904->mclk_rate);
clock2 &= ~WM8904_SYSCLK_SRC; rate = wm8904->mclk_rate;
/* Ensure the FLL is stopped */ - snd_soc_update_bits(codec, WM8904_FLL_CONTROL_1, + snd_soc_component_update_bits(component, WM8904_FLL_CONTROL_1, WM8904_FLL_OSC_ENA | WM8904_FLL_ENA, 0); break;
case WM8904_CLK_FLL: - dev_dbg(codec->dev, "Using %dHz FLL clock\n", + dev_dbg(component->dev, "Using %dHz FLL clock\n", wm8904->fll_fout);
clock2 |= WM8904_SYSCLK_SRC; @@ -348,7 +348,7 @@ static int wm8904_configure_clocking(struct snd_soc_codec *codec) break;
default: - dev_err(codec->dev, "System clock not configured\n"); + dev_err(component->dev, "System clock not configured\n"); return -EINVAL; }
@@ -361,40 +361,40 @@ static int wm8904_configure_clocking(struct snd_soc_codec *codec) wm8904->sysclk_rate = rate; }
- snd_soc_update_bits(codec, WM8904_CLOCK_RATES_0, WM8904_MCLK_DIV, + snd_soc_component_update_bits(component, WM8904_CLOCK_RATES_0, WM8904_MCLK_DIV, clock0);
- snd_soc_update_bits(codec, WM8904_CLOCK_RATES_2, + snd_soc_component_update_bits(component, WM8904_CLOCK_RATES_2, WM8904_CLK_SYS_ENA | WM8904_SYSCLK_SRC, clock2);
- dev_dbg(codec->dev, "CLK_SYS is %dHz\n", wm8904->sysclk_rate); + dev_dbg(component->dev, "CLK_SYS is %dHz\n", wm8904->sysclk_rate);
return 0; }
-static void wm8904_set_drc(struct snd_soc_codec *codec) +static void wm8904_set_drc(struct snd_soc_component *component) { - struct wm8904_priv *wm8904 = snd_soc_codec_get_drvdata(codec); + struct wm8904_priv *wm8904 = snd_soc_component_get_drvdata(component); struct wm8904_pdata *pdata = wm8904->pdata; int save, i;
/* Save any enables; the configuration should clear them. */ - save = snd_soc_read(codec, WM8904_DRC_0); + save = snd_soc_component_read32(component, WM8904_DRC_0);
for (i = 0; i < WM8904_DRC_REGS; i++) - snd_soc_update_bits(codec, WM8904_DRC_0 + i, 0xffff, + snd_soc_component_update_bits(component, WM8904_DRC_0 + i, 0xffff, pdata->drc_cfgs[wm8904->drc_cfg].regs[i]);
/* Reenable the DRC */ - snd_soc_update_bits(codec, WM8904_DRC_0, + snd_soc_component_update_bits(component, WM8904_DRC_0, WM8904_DRC_ENA | WM8904_DRC_DAC_PATH, save); }
static int wm8904_put_drc_enum(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct wm8904_priv *wm8904 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct wm8904_priv *wm8904 = snd_soc_component_get_drvdata(component); struct wm8904_pdata *pdata = wm8904->pdata; int value = ucontrol->value.enumerated.item[0];
@@ -403,7 +403,7 @@ static int wm8904_put_drc_enum(struct snd_kcontrol *kcontrol,
wm8904->drc_cfg = value;
- wm8904_set_drc(codec); + wm8904_set_drc(component);
return 0; } @@ -411,17 +411,17 @@ static int wm8904_put_drc_enum(struct snd_kcontrol *kcontrol, static int wm8904_get_drc_enum(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct wm8904_priv *wm8904 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct wm8904_priv *wm8904 = snd_soc_component_get_drvdata(component);
ucontrol->value.enumerated.item[0] = wm8904->drc_cfg;
return 0; }
-static void wm8904_set_retune_mobile(struct snd_soc_codec *codec) +static void wm8904_set_retune_mobile(struct snd_soc_component *component) { - struct wm8904_priv *wm8904 = snd_soc_codec_get_drvdata(codec); + struct wm8904_priv *wm8904 = snd_soc_component_get_drvdata(component); struct wm8904_pdata *pdata = wm8904->pdata; int best, best_val, save, i, cfg;
@@ -444,7 +444,7 @@ static void wm8904_set_retune_mobile(struct snd_soc_codec *codec) } }
- dev_dbg(codec->dev, "ReTune Mobile %s/%dHz for %dHz sample rate\n", + dev_dbg(component->dev, "ReTune Mobile %s/%dHz for %dHz sample rate\n", pdata->retune_mobile_cfgs[best].name, pdata->retune_mobile_cfgs[best].rate, wm8904->fs); @@ -452,20 +452,20 @@ static void wm8904_set_retune_mobile(struct snd_soc_codec *codec) /* The EQ will be disabled while reconfiguring it, remember the * current configuration. */ - save = snd_soc_read(codec, WM8904_EQ1); + save = snd_soc_component_read32(component, WM8904_EQ1);
for (i = 0; i < WM8904_EQ_REGS; i++) - snd_soc_update_bits(codec, WM8904_EQ1 + i, 0xffff, + snd_soc_component_update_bits(component, WM8904_EQ1 + i, 0xffff, pdata->retune_mobile_cfgs[best].regs[i]);
- snd_soc_update_bits(codec, WM8904_EQ1, WM8904_EQ_ENA, save); + snd_soc_component_update_bits(component, WM8904_EQ1, WM8904_EQ_ENA, save); }
static int wm8904_put_retune_mobile_enum(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct wm8904_priv *wm8904 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct wm8904_priv *wm8904 = snd_soc_component_get_drvdata(component); struct wm8904_pdata *pdata = wm8904->pdata; int value = ucontrol->value.enumerated.item[0];
@@ -474,7 +474,7 @@ static int wm8904_put_retune_mobile_enum(struct snd_kcontrol *kcontrol,
wm8904->retune_mobile_cfg = value;
- wm8904_set_retune_mobile(codec); + wm8904_set_retune_mobile(component);
return 0; } @@ -482,8 +482,8 @@ static int wm8904_put_retune_mobile_enum(struct snd_kcontrol *kcontrol, static int wm8904_get_retune_mobile_enum(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct wm8904_priv *wm8904 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct wm8904_priv *wm8904 = snd_soc_component_get_drvdata(component);
ucontrol->value.enumerated.item[0] = wm8904->retune_mobile_cfg;
@@ -492,9 +492,9 @@ static int wm8904_get_retune_mobile_enum(struct snd_kcontrol *kcontrol,
static int deemph_settings[] = { 0, 32000, 44100, 48000 };
-static int wm8904_set_deemph(struct snd_soc_codec *codec) +static int wm8904_set_deemph(struct snd_soc_component *component) { - struct wm8904_priv *wm8904 = snd_soc_codec_get_drvdata(codec); + struct wm8904_priv *wm8904 = snd_soc_component_get_drvdata(component); int val, i, best;
/* If we're using deemphasis select the nearest available sample @@ -513,17 +513,17 @@ static int wm8904_set_deemph(struct snd_soc_codec *codec) val = 0; }
- dev_dbg(codec->dev, "Set deemphasis %d\n", val); + dev_dbg(component->dev, "Set deemphasis %d\n", val);
- return snd_soc_update_bits(codec, WM8904_DAC_DIGITAL_1, + return snd_soc_component_update_bits(component, WM8904_DAC_DIGITAL_1, WM8904_DEEMPH_MASK, val); }
static int wm8904_get_deemph(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct wm8904_priv *wm8904 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct wm8904_priv *wm8904 = snd_soc_component_get_drvdata(component);
ucontrol->value.integer.value[0] = wm8904->deemph; return 0; @@ -532,8 +532,8 @@ static int wm8904_get_deemph(struct snd_kcontrol *kcontrol, static int wm8904_put_deemph(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct wm8904_priv *wm8904 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct wm8904_priv *wm8904 = snd_soc_component_get_drvdata(component); unsigned int deemph = ucontrol->value.integer.value[0];
if (deemph > 1) @@ -541,7 +541,7 @@ static int wm8904_put_deemph(struct snd_kcontrol *kcontrol,
wm8904->deemph = deemph;
- return wm8904_set_deemph(codec); + return wm8904_set_deemph(component); }
static const DECLARE_TLV_DB_SCALE(dac_boost_tlv, 0, 600, 0); @@ -572,7 +572,7 @@ static SOC_ENUM_SINGLE_DECL(hpf_mode, WM8904_ADC_DIGITAL_0, 5, static int wm8904_adc_osr_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); unsigned int val; int ret;
@@ -585,7 +585,7 @@ static int wm8904_adc_osr_put(struct snd_kcontrol *kcontrol, else val = WM8904_ADC_128_OSR_TST_MODE | WM8904_ADC_BIASX1P5;
- snd_soc_update_bits(codec, WM8904_ADC_TEST_0, + snd_soc_component_update_bits(component, WM8904_ADC_TEST_0, WM8904_ADC_128_OSR_TST_MODE | WM8904_ADC_BIASX1P5, val);
@@ -673,8 +673,8 @@ static int cp_event(struct snd_soc_dapm_widget *w, static int sysclk_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); - struct wm8904_priv *wm8904 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); + struct wm8904_priv *wm8904 = snd_soc_component_get_drvdata(component);
switch (event) { case SND_SOC_DAPM_PRE_PMU: @@ -685,11 +685,11 @@ static int sysclk_event(struct snd_soc_dapm_widget *w, */ switch (wm8904->sysclk_src) { case WM8904_CLK_FLL: - snd_soc_update_bits(codec, WM8904_FLL_CONTROL_1, + snd_soc_component_update_bits(component, WM8904_FLL_CONTROL_1, WM8904_FLL_OSC_ENA, WM8904_FLL_OSC_ENA);
- snd_soc_update_bits(codec, WM8904_FLL_CONTROL_1, + snd_soc_component_update_bits(component, WM8904_FLL_CONTROL_1, WM8904_FLL_ENA, WM8904_FLL_ENA); break; @@ -700,7 +700,7 @@ static int sysclk_event(struct snd_soc_dapm_widget *w, break;
case SND_SOC_DAPM_POST_PMD: - snd_soc_update_bits(codec, WM8904_FLL_CONTROL_1, + snd_soc_component_update_bits(component, WM8904_FLL_CONTROL_1, WM8904_FLL_OSC_ENA | WM8904_FLL_ENA, 0); break; } @@ -711,8 +711,8 @@ static int sysclk_event(struct snd_soc_dapm_widget *w, static int out_pga_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); - struct wm8904_priv *wm8904 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); + struct wm8904_priv *wm8904 = snd_soc_component_get_drvdata(component); int reg, val; int dcs_mask; int dcs_l, dcs_r; @@ -751,43 +751,43 @@ static int out_pga_event(struct snd_soc_dapm_widget *w, switch (event) { case SND_SOC_DAPM_PRE_PMU: /* Power on the PGAs */ - snd_soc_update_bits(codec, pwr_reg, + snd_soc_component_update_bits(component, pwr_reg, WM8904_HPL_PGA_ENA | WM8904_HPR_PGA_ENA, WM8904_HPL_PGA_ENA | WM8904_HPR_PGA_ENA);
/* Power on the amplifier */ - snd_soc_update_bits(codec, reg, + snd_soc_component_update_bits(component, reg, WM8904_HPL_ENA | WM8904_HPR_ENA, WM8904_HPL_ENA | WM8904_HPR_ENA);
/* Enable the first stage */ - snd_soc_update_bits(codec, reg, + snd_soc_component_update_bits(component, reg, WM8904_HPL_ENA_DLY | WM8904_HPR_ENA_DLY, WM8904_HPL_ENA_DLY | WM8904_HPR_ENA_DLY);
/* Power up the DC servo */ - snd_soc_update_bits(codec, WM8904_DC_SERVO_0, + snd_soc_component_update_bits(component, WM8904_DC_SERVO_0, dcs_mask, dcs_mask);
/* Either calibrate the DC servo or restore cached state * if we have that. */ if (wm8904->dcs_state[dcs_l] || wm8904->dcs_state[dcs_r]) { - dev_dbg(codec->dev, "Restoring DC servo state\n"); + dev_dbg(component->dev, "Restoring DC servo state\n");
- snd_soc_write(codec, dcs_l_reg, + snd_soc_component_write(component, dcs_l_reg, wm8904->dcs_state[dcs_l]); - snd_soc_write(codec, dcs_r_reg, + snd_soc_component_write(component, dcs_r_reg, wm8904->dcs_state[dcs_r]);
- snd_soc_write(codec, WM8904_DC_SERVO_1, dcs_mask); + snd_soc_component_write(component, WM8904_DC_SERVO_1, dcs_mask);
timeout = 20; } else { - dev_dbg(codec->dev, "Calibrating DC servo\n"); + dev_dbg(component->dev, "Calibrating DC servo\n");
- snd_soc_write(codec, WM8904_DC_SERVO_1, + snd_soc_component_write(component, WM8904_DC_SERVO_1, dcs_mask << WM8904_DCS_TRIG_STARTUP_0_SHIFT);
timeout = 500; @@ -796,7 +796,7 @@ static int out_pga_event(struct snd_soc_dapm_widget *w, /* Wait for DC servo to complete */ dcs_mask <<= WM8904_DCS_CAL_COMPLETE_SHIFT; do { - val = snd_soc_read(codec, WM8904_DC_SERVO_READBACK_0); + val = snd_soc_component_read32(component, WM8904_DC_SERVO_READBACK_0); if ((val & dcs_mask) == dcs_mask) break;
@@ -804,19 +804,19 @@ static int out_pga_event(struct snd_soc_dapm_widget *w, } while (--timeout);
if ((val & dcs_mask) != dcs_mask) - dev_warn(codec->dev, "DC servo timed out\n"); + dev_warn(component->dev, "DC servo timed out\n"); else - dev_dbg(codec->dev, "DC servo ready\n"); + dev_dbg(component->dev, "DC servo ready\n");
/* Enable the output stage */ - snd_soc_update_bits(codec, reg, + snd_soc_component_update_bits(component, reg, WM8904_HPL_ENA_OUTP | WM8904_HPR_ENA_OUTP, WM8904_HPL_ENA_OUTP | WM8904_HPR_ENA_OUTP); break;
case SND_SOC_DAPM_POST_PMU: /* Unshort the output itself */ - snd_soc_update_bits(codec, reg, + snd_soc_component_update_bits(component, reg, WM8904_HPL_RMV_SHORT | WM8904_HPR_RMV_SHORT, WM8904_HPL_RMV_SHORT | @@ -826,7 +826,7 @@ static int out_pga_event(struct snd_soc_dapm_widget *w,
case SND_SOC_DAPM_PRE_PMD: /* Short the output */ - snd_soc_update_bits(codec, reg, + snd_soc_component_update_bits(component, reg, WM8904_HPL_RMV_SHORT | WM8904_HPR_RMV_SHORT, 0); break; @@ -834,21 +834,21 @@ static int out_pga_event(struct snd_soc_dapm_widget *w, case SND_SOC_DAPM_POST_PMD: /* Cache the DC servo configuration; this will be * invalidated if we change the configuration. */ - wm8904->dcs_state[dcs_l] = snd_soc_read(codec, dcs_l_reg); - wm8904->dcs_state[dcs_r] = snd_soc_read(codec, dcs_r_reg); + wm8904->dcs_state[dcs_l] = snd_soc_component_read32(component, dcs_l_reg); + wm8904->dcs_state[dcs_r] = snd_soc_component_read32(component, dcs_r_reg);
- snd_soc_update_bits(codec, WM8904_DC_SERVO_0, + snd_soc_component_update_bits(component, WM8904_DC_SERVO_0, dcs_mask, 0);
/* Disable the amplifier input and output stages */ - snd_soc_update_bits(codec, reg, + snd_soc_component_update_bits(component, reg, WM8904_HPL_ENA | WM8904_HPR_ENA | WM8904_HPL_ENA_DLY | WM8904_HPR_ENA_DLY | WM8904_HPL_ENA_OUTP | WM8904_HPR_ENA_OUTP, 0);
/* PGAs too */ - snd_soc_update_bits(codec, pwr_reg, + snd_soc_component_update_bits(component, pwr_reg, WM8904_HPL_PGA_ENA | WM8904_HPR_PGA_ENA, 0); break; @@ -1165,10 +1165,10 @@ static SOC_ENUM_SINGLE_DECL(dacr_sidetone_enum, WM8904_DAC_DIGITAL_0, 0, { "LINER PGA", NULL, "DACR" }, };
-static int wm8904_add_widgets(struct snd_soc_codec *codec) +static int wm8904_add_widgets(struct snd_soc_component *component) { - struct wm8904_priv *wm8904 = snd_soc_codec_get_drvdata(codec); - struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec); + struct wm8904_priv *wm8904 = snd_soc_component_get_drvdata(component); + struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component);
snd_soc_dapm_new_controls(dapm, wm8904_core_dapm_widgets, ARRAY_SIZE(wm8904_core_dapm_widgets)); @@ -1177,11 +1177,11 @@ static int wm8904_add_widgets(struct snd_soc_codec *codec)
switch (wm8904->devtype) { case WM8904: - snd_soc_add_codec_controls(codec, wm8904_adc_snd_controls, + snd_soc_add_component_controls(component, wm8904_adc_snd_controls, ARRAY_SIZE(wm8904_adc_snd_controls)); - snd_soc_add_codec_controls(codec, wm8904_dac_snd_controls, + snd_soc_add_component_controls(component, wm8904_dac_snd_controls, ARRAY_SIZE(wm8904_dac_snd_controls)); - snd_soc_add_codec_controls(codec, wm8904_snd_controls, + snd_soc_add_component_controls(component, wm8904_snd_controls, ARRAY_SIZE(wm8904_snd_controls));
snd_soc_dapm_new_controls(dapm, wm8904_adc_dapm_widgets, @@ -1200,7 +1200,7 @@ static int wm8904_add_widgets(struct snd_soc_codec *codec) break;
case WM8912: - snd_soc_add_codec_controls(codec, wm8904_dac_snd_controls, + snd_soc_add_component_controls(component, wm8904_dac_snd_controls, ARRAY_SIZE(wm8904_dac_snd_controls));
snd_soc_dapm_new_controls(dapm, wm8904_dac_dapm_widgets, @@ -1278,8 +1278,8 @@ static int wm8904_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; - struct wm8904_priv *wm8904 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct wm8904_priv *wm8904 = snd_soc_component_get_drvdata(component); int ret, i, best, best_val, cur_val; unsigned int aif1 = 0; unsigned int aif2 = 0; @@ -1290,7 +1290,7 @@ static int wm8904_hw_params(struct snd_pcm_substream *substream, /* What BCLK do we need? */ wm8904->fs = params_rate(params); if (wm8904->tdm_slots) { - dev_dbg(codec->dev, "Configuring for %d %d bit TDM slots\n", + dev_dbg(component->dev, "Configuring for %d %d bit TDM slots\n", wm8904->tdm_slots, wm8904->tdm_width); wm8904->bclk = snd_soc_calc_bclk(wm8904->fs, wm8904->tdm_width, 2, @@ -1316,9 +1316,9 @@ static int wm8904_hw_params(struct snd_pcm_substream *substream, }
- dev_dbg(codec->dev, "Target BCLK is %dHz\n", wm8904->bclk); + dev_dbg(component->dev, "Target BCLK is %dHz\n", wm8904->bclk);
- ret = wm8904_configure_clocking(codec); + ret = wm8904_configure_clocking(component); if (ret != 0) return ret;
@@ -1334,7 +1334,7 @@ static int wm8904_hw_params(struct snd_pcm_substream *substream, best_val = cur_val; } } - dev_dbg(codec->dev, "Selected CLK_SYS_RATIO of %d\n", + dev_dbg(component->dev, "Selected CLK_SYS_RATIO of %d\n", clk_sys_rates[best].ratio); clock1 |= (clk_sys_rates[best].clk_sys_rate << WM8904_CLK_SYS_RATE_SHIFT); @@ -1350,7 +1350,7 @@ static int wm8904_hw_params(struct snd_pcm_substream *substream, best_val = cur_val; } } - dev_dbg(codec->dev, "Selected SAMPLE_RATE of %dHz\n", + dev_dbg(component->dev, "Selected SAMPLE_RATE of %dHz\n", sample_rates[best].rate); clock1 |= (sample_rates[best].sample_rate << WM8904_SAMPLE_RATE_SHIFT); @@ -1373,30 +1373,30 @@ static int wm8904_hw_params(struct snd_pcm_substream *substream, } } wm8904->bclk = (wm8904->sysclk_rate * 10) / bclk_divs[best].div; - dev_dbg(codec->dev, "Selected BCLK_DIV of %d for %dHz BCLK\n", + dev_dbg(component->dev, "Selected BCLK_DIV of %d for %dHz BCLK\n", bclk_divs[best].div, wm8904->bclk); aif2 |= bclk_divs[best].bclk_div;
/* LRCLK is a simple fraction of BCLK */ - dev_dbg(codec->dev, "LRCLK_RATE is %d\n", wm8904->bclk / wm8904->fs); + dev_dbg(component->dev, "LRCLK_RATE is %d\n", wm8904->bclk / wm8904->fs); aif3 |= wm8904->bclk / wm8904->fs;
/* Apply the settings */ - snd_soc_update_bits(codec, WM8904_DAC_DIGITAL_1, + snd_soc_component_update_bits(component, WM8904_DAC_DIGITAL_1, WM8904_DAC_SB_FILT, dac_digital1); - snd_soc_update_bits(codec, WM8904_AUDIO_INTERFACE_1, + snd_soc_component_update_bits(component, WM8904_AUDIO_INTERFACE_1, WM8904_AIF_WL_MASK, aif1); - snd_soc_update_bits(codec, WM8904_AUDIO_INTERFACE_2, + snd_soc_component_update_bits(component, WM8904_AUDIO_INTERFACE_2, WM8904_BCLK_DIV_MASK, aif2); - snd_soc_update_bits(codec, WM8904_AUDIO_INTERFACE_3, + snd_soc_component_update_bits(component, WM8904_AUDIO_INTERFACE_3, WM8904_LRCLK_RATE_MASK, aif3); - snd_soc_update_bits(codec, WM8904_CLOCK_RATES_1, + snd_soc_component_update_bits(component, WM8904_CLOCK_RATES_1, WM8904_SAMPLE_RATE_MASK | WM8904_CLK_SYS_RATE_MASK, clock1);
/* Update filters for the new settings */ - wm8904_set_retune_mobile(codec); - wm8904_set_deemph(codec); + wm8904_set_retune_mobile(component); + wm8904_set_deemph(component);
return 0; } @@ -1405,8 +1405,8 @@ static int wm8904_hw_params(struct snd_pcm_substream *substream, static int wm8904_set_sysclk(struct snd_soc_dai *dai, int clk_id, unsigned int freq, int dir) { - struct snd_soc_codec *codec = dai->codec; - struct wm8904_priv *priv = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct wm8904_priv *priv = snd_soc_component_get_drvdata(component);
switch (clk_id) { case WM8904_CLK_MCLK: @@ -1424,14 +1424,14 @@ static int wm8904_set_sysclk(struct snd_soc_dai *dai, int clk_id,
dev_dbg(dai->dev, "Clock source is %d at %uHz\n", clk_id, freq);
- wm8904_configure_clocking(codec); + wm8904_configure_clocking(component);
return 0; }
static int wm8904_set_fmt(struct snd_soc_dai *dai, unsigned int fmt) { - struct snd_soc_codec *codec = dai->codec; + struct snd_soc_component *component = dai->component; unsigned int aif1 = 0; unsigned int aif3 = 0;
@@ -1508,10 +1508,10 @@ static int wm8904_set_fmt(struct snd_soc_dai *dai, unsigned int fmt) return -EINVAL; }
- snd_soc_update_bits(codec, WM8904_AUDIO_INTERFACE_1, + snd_soc_component_update_bits(component, WM8904_AUDIO_INTERFACE_1, WM8904_AIF_BCLK_INV | WM8904_AIF_LRCLK_INV | WM8904_AIF_FMT_MASK | WM8904_BCLK_DIR, aif1); - snd_soc_update_bits(codec, WM8904_AUDIO_INTERFACE_3, + snd_soc_component_update_bits(component, WM8904_AUDIO_INTERFACE_3, WM8904_LRCLK_DIR, aif3);
return 0; @@ -1521,8 +1521,8 @@ static int wm8904_set_fmt(struct snd_soc_dai *dai, unsigned int fmt) static int wm8904_set_tdm_slot(struct snd_soc_dai *dai, unsigned int tx_mask, unsigned int rx_mask, int slots, int slot_width) { - struct snd_soc_codec *codec = dai->codec; - struct wm8904_priv *wm8904 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct wm8904_priv *wm8904 = snd_soc_component_get_drvdata(component); int aif1 = 0;
/* Don't need to validate anything if we're turning off TDM */ @@ -1560,7 +1560,7 @@ static int wm8904_set_tdm_slot(struct snd_soc_dai *dai, unsigned int tx_mask, wm8904->tdm_width = slot_width; wm8904->tdm_slots = slots / 2;
- snd_soc_update_bits(codec, WM8904_AUDIO_INTERFACE_1, + snd_soc_component_update_bits(component, WM8904_AUDIO_INTERFACE_1, WM8904_AIFADC_TDM | WM8904_AIFADC_TDM_CHAN | WM8904_AIFDAC_TDM | WM8904_AIFDAC_TDM_CHAN, aif1);
@@ -1678,8 +1678,8 @@ static int fll_factors(struct _fll_div *fll_div, unsigned int Fref, static int wm8904_set_fll(struct snd_soc_dai *dai, int fll_id, int source, unsigned int Fref, unsigned int Fout) { - struct snd_soc_codec *codec = dai->codec; - struct wm8904_priv *wm8904 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct wm8904_priv *wm8904 = snd_soc_component_get_drvdata(component); struct _fll_div fll_div; int ret, val; int clock2, fll1; @@ -1689,19 +1689,19 @@ static int wm8904_set_fll(struct snd_soc_dai *dai, int fll_id, int source, Fout == wm8904->fll_fout) return 0;
- clock2 = snd_soc_read(codec, WM8904_CLOCK_RATES_2); + clock2 = snd_soc_component_read32(component, WM8904_CLOCK_RATES_2);
if (Fout == 0) { - dev_dbg(codec->dev, "FLL disabled\n"); + dev_dbg(component->dev, "FLL disabled\n");
wm8904->fll_fref = 0; wm8904->fll_fout = 0;
/* Gate SYSCLK to avoid glitches */ - snd_soc_update_bits(codec, WM8904_CLOCK_RATES_2, + snd_soc_component_update_bits(component, WM8904_CLOCK_RATES_2, WM8904_CLK_SYS_ENA, 0);
- snd_soc_update_bits(codec, WM8904_FLL_CONTROL_1, + snd_soc_component_update_bits(component, WM8904_FLL_CONTROL_1, WM8904_FLL_OSC_ENA | WM8904_FLL_ENA, 0);
goto out; @@ -1718,7 +1718,7 @@ static int wm8904_set_fll(struct snd_soc_dai *dai, int fll_id, int source, break;
case WM8904_FLL_FREE_RUNNING: - dev_dbg(codec->dev, "Using free running FLL\n"); + dev_dbg(component->dev, "Using free running FLL\n"); /* Force 12MHz and output/4 for now */ Fout = 12000000; Fref = 12000000; @@ -1728,20 +1728,20 @@ static int wm8904_set_fll(struct snd_soc_dai *dai, int fll_id, int source, break;
default: - dev_err(codec->dev, "Unknown FLL ID %d\n", fll_id); + dev_err(component->dev, "Unknown FLL ID %d\n", fll_id); return -EINVAL; }
/* Save current state then disable the FLL and SYSCLK to avoid * misclocking */ - fll1 = snd_soc_read(codec, WM8904_FLL_CONTROL_1); - snd_soc_update_bits(codec, WM8904_CLOCK_RATES_2, + fll1 = snd_soc_component_read32(component, WM8904_FLL_CONTROL_1); + snd_soc_component_update_bits(component, WM8904_CLOCK_RATES_2, WM8904_CLK_SYS_ENA, 0); - snd_soc_update_bits(codec, WM8904_FLL_CONTROL_1, + snd_soc_component_update_bits(component, WM8904_FLL_CONTROL_1, WM8904_FLL_OSC_ENA | WM8904_FLL_ENA, 0);
/* Unlock forced oscilator control to switch it on/off */ - snd_soc_update_bits(codec, WM8904_CONTROL_INTERFACE_TEST_1, + snd_soc_component_update_bits(component, WM8904_CONTROL_INTERFACE_TEST_1, WM8904_USER_KEY, WM8904_USER_KEY);
if (fll_id == WM8904_FLL_FREE_RUNNING) { @@ -1750,24 +1750,24 @@ static int wm8904_set_fll(struct snd_soc_dai *dai, int fll_id, int source, val = 0; }
- snd_soc_update_bits(codec, WM8904_FLL_NCO_TEST_1, WM8904_FLL_FRC_NCO, + snd_soc_component_update_bits(component, WM8904_FLL_NCO_TEST_1, WM8904_FLL_FRC_NCO, val); - snd_soc_update_bits(codec, WM8904_CONTROL_INTERFACE_TEST_1, + snd_soc_component_update_bits(component, WM8904_CONTROL_INTERFACE_TEST_1, WM8904_USER_KEY, 0);
switch (fll_id) { case WM8904_FLL_MCLK: - snd_soc_update_bits(codec, WM8904_FLL_CONTROL_5, + snd_soc_component_update_bits(component, WM8904_FLL_CONTROL_5, WM8904_FLL_CLK_REF_SRC_MASK, 0); break;
case WM8904_FLL_LRCLK: - snd_soc_update_bits(codec, WM8904_FLL_CONTROL_5, + snd_soc_component_update_bits(component, WM8904_FLL_CONTROL_5, WM8904_FLL_CLK_REF_SRC_MASK, 1); break;
case WM8904_FLL_BCLK: - snd_soc_update_bits(codec, WM8904_FLL_CONTROL_5, + snd_soc_component_update_bits(component, WM8904_FLL_CONTROL_5, WM8904_FLL_CLK_REF_SRC_MASK, 2); break; } @@ -1776,39 +1776,39 @@ static int wm8904_set_fll(struct snd_soc_dai *dai, int fll_id, int source, val = WM8904_FLL_FRACN_ENA; else val = 0; - snd_soc_update_bits(codec, WM8904_FLL_CONTROL_1, + snd_soc_component_update_bits(component, WM8904_FLL_CONTROL_1, WM8904_FLL_FRACN_ENA, val);
- snd_soc_update_bits(codec, WM8904_FLL_CONTROL_2, + snd_soc_component_update_bits(component, WM8904_FLL_CONTROL_2, WM8904_FLL_OUTDIV_MASK | WM8904_FLL_FRATIO_MASK, (fll_div.fll_outdiv << WM8904_FLL_OUTDIV_SHIFT) | (fll_div.fll_fratio << WM8904_FLL_FRATIO_SHIFT));
- snd_soc_write(codec, WM8904_FLL_CONTROL_3, fll_div.k); + snd_soc_component_write(component, WM8904_FLL_CONTROL_3, fll_div.k);
- snd_soc_update_bits(codec, WM8904_FLL_CONTROL_4, WM8904_FLL_N_MASK, + snd_soc_component_update_bits(component, WM8904_FLL_CONTROL_4, WM8904_FLL_N_MASK, fll_div.n << WM8904_FLL_N_SHIFT);
- snd_soc_update_bits(codec, WM8904_FLL_CONTROL_5, + snd_soc_component_update_bits(component, WM8904_FLL_CONTROL_5, WM8904_FLL_CLK_REF_DIV_MASK, fll_div.fll_clk_ref_div << WM8904_FLL_CLK_REF_DIV_SHIFT);
- dev_dbg(codec->dev, "FLL configured for %dHz->%dHz\n", Fref, Fout); + dev_dbg(component->dev, "FLL configured for %dHz->%dHz\n", Fref, Fout);
wm8904->fll_fref = Fref; wm8904->fll_fout = Fout; wm8904->fll_src = source;
/* Enable the FLL if it was previously active */ - snd_soc_update_bits(codec, WM8904_FLL_CONTROL_1, + snd_soc_component_update_bits(component, WM8904_FLL_CONTROL_1, WM8904_FLL_OSC_ENA, fll1); - snd_soc_update_bits(codec, WM8904_FLL_CONTROL_1, + snd_soc_component_update_bits(component, WM8904_FLL_CONTROL_1, WM8904_FLL_ENA, fll1);
out: /* Reenable SYSCLK if it was previously active */ - snd_soc_update_bits(codec, WM8904_CLOCK_RATES_2, + snd_soc_component_update_bits(component, WM8904_CLOCK_RATES_2, WM8904_CLK_SYS_ENA, clock2);
return 0; @@ -1816,7 +1816,7 @@ static int wm8904_set_fll(struct snd_soc_dai *dai, int fll_id, int source,
static int wm8904_digital_mute(struct snd_soc_dai *codec_dai, int mute) { - struct snd_soc_codec *codec = codec_dai->codec; + struct snd_soc_component *component = codec_dai->component; int val;
if (mute) @@ -1824,15 +1824,15 @@ static int wm8904_digital_mute(struct snd_soc_dai *codec_dai, int mute) else val = 0;
- snd_soc_update_bits(codec, WM8904_DAC_DIGITAL_1, WM8904_DAC_MUTE, val); + snd_soc_component_update_bits(component, WM8904_DAC_DIGITAL_1, WM8904_DAC_MUTE, val);
return 0; }
-static int wm8904_set_bias_level(struct snd_soc_codec *codec, +static int wm8904_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { - struct wm8904_priv *wm8904 = snd_soc_codec_get_drvdata(codec); + struct wm8904_priv *wm8904 = snd_soc_component_get_drvdata(component); int ret;
switch (level) { @@ -1844,21 +1844,21 @@ static int wm8904_set_bias_level(struct snd_soc_codec *codec,
case SND_SOC_BIAS_PREPARE: /* VMID resistance 2*50k */ - snd_soc_update_bits(codec, WM8904_VMID_CONTROL_0, + snd_soc_component_update_bits(component, WM8904_VMID_CONTROL_0, WM8904_VMID_RES_MASK, 0x1 << WM8904_VMID_RES_SHIFT);
/* Normal bias current */ - snd_soc_update_bits(codec, WM8904_BIAS_CONTROL_0, + snd_soc_component_update_bits(component, WM8904_BIAS_CONTROL_0, WM8904_ISEL_MASK, 2 << WM8904_ISEL_SHIFT); break;
case SND_SOC_BIAS_STANDBY: - if (snd_soc_codec_get_bias_level(codec) == SND_SOC_BIAS_OFF) { + if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_OFF) { ret = regulator_bulk_enable(ARRAY_SIZE(wm8904->supplies), wm8904->supplies); if (ret != 0) { - dev_err(codec->dev, + dev_err(component->dev, "Failed to enable supplies: %d\n", ret); return ret; @@ -1868,11 +1868,11 @@ static int wm8904_set_bias_level(struct snd_soc_codec *codec, regcache_sync(wm8904->regmap);
/* Enable bias */ - snd_soc_update_bits(codec, WM8904_BIAS_CONTROL_0, + snd_soc_component_update_bits(component, WM8904_BIAS_CONTROL_0, WM8904_BIAS_ENA, WM8904_BIAS_ENA);
/* Enable VMID, VMID buffering, 2*5k resistance */ - snd_soc_update_bits(codec, WM8904_VMID_CONTROL_0, + snd_soc_component_update_bits(component, WM8904_VMID_CONTROL_0, WM8904_VMID_ENA | WM8904_VMID_RES_MASK, WM8904_VMID_ENA | @@ -1883,22 +1883,22 @@ static int wm8904_set_bias_level(struct snd_soc_codec *codec, }
/* Maintain VMID with 2*250k */ - snd_soc_update_bits(codec, WM8904_VMID_CONTROL_0, + snd_soc_component_update_bits(component, WM8904_VMID_CONTROL_0, WM8904_VMID_RES_MASK, 0x2 << WM8904_VMID_RES_SHIFT);
/* Bias current *0.5 */ - snd_soc_update_bits(codec, WM8904_BIAS_CONTROL_0, + snd_soc_component_update_bits(component, WM8904_BIAS_CONTROL_0, WM8904_ISEL_MASK, 0); break;
case SND_SOC_BIAS_OFF: /* Turn off VMID */ - snd_soc_update_bits(codec, WM8904_VMID_CONTROL_0, + snd_soc_component_update_bits(component, WM8904_VMID_CONTROL_0, WM8904_VMID_RES_MASK | WM8904_VMID_ENA, 0);
/* Stop bias generation */ - snd_soc_update_bits(codec, WM8904_BIAS_CONTROL_0, + snd_soc_component_update_bits(component, WM8904_BIAS_CONTROL_0, WM8904_BIAS_ENA, 0);
regcache_cache_only(wm8904->regmap, true); @@ -1946,9 +1946,9 @@ static int wm8904_set_bias_level(struct snd_soc_codec *codec, .symmetric_rates = 1, };
-static void wm8904_handle_retune_mobile_pdata(struct snd_soc_codec *codec) +static void wm8904_handle_retune_mobile_pdata(struct snd_soc_component *component) { - struct wm8904_priv *wm8904 = snd_soc_codec_get_drvdata(codec); + struct wm8904_priv *wm8904 = snd_soc_component_get_drvdata(component); struct wm8904_pdata *pdata = wm8904->pdata; struct snd_kcontrol_new control = SOC_ENUM_EXT("EQ Mode", @@ -1991,31 +1991,31 @@ static void wm8904_handle_retune_mobile_pdata(struct snd_soc_codec *codec) wm8904->retune_mobile_texts = t; }
- dev_dbg(codec->dev, "Allocated %d unique ReTune Mobile names\n", + dev_dbg(component->dev, "Allocated %d unique ReTune Mobile names\n", wm8904->num_retune_mobile_texts);
wm8904->retune_mobile_enum.items = wm8904->num_retune_mobile_texts; wm8904->retune_mobile_enum.texts = wm8904->retune_mobile_texts;
- ret = snd_soc_add_codec_controls(codec, &control, 1); + ret = snd_soc_add_component_controls(component, &control, 1); if (ret != 0) - dev_err(codec->dev, + dev_err(component->dev, "Failed to add ReTune Mobile control: %d\n", ret); }
-static void wm8904_handle_pdata(struct snd_soc_codec *codec) +static void wm8904_handle_pdata(struct snd_soc_component *component) { - struct wm8904_priv *wm8904 = snd_soc_codec_get_drvdata(codec); + struct wm8904_priv *wm8904 = snd_soc_component_get_drvdata(component); struct wm8904_pdata *pdata = wm8904->pdata; int ret, i;
if (!pdata) { - snd_soc_add_codec_controls(codec, wm8904_eq_controls, + snd_soc_add_component_controls(component, wm8904_eq_controls, ARRAY_SIZE(wm8904_eq_controls)); return; }
- dev_dbg(codec->dev, "%d DRC configurations\n", pdata->num_drc_cfgs); + dev_dbg(component->dev, "%d DRC configurations\n", pdata->num_drc_cfgs);
if (pdata->num_drc_cfgs) { struct snd_kcontrol_new control = @@ -2034,28 +2034,28 @@ static void wm8904_handle_pdata(struct snd_soc_codec *codec) wm8904->drc_enum.items = pdata->num_drc_cfgs; wm8904->drc_enum.texts = wm8904->drc_texts;
- ret = snd_soc_add_codec_controls(codec, &control, 1); + ret = snd_soc_add_component_controls(component, &control, 1); if (ret != 0) - dev_err(codec->dev, + dev_err(component->dev, "Failed to add DRC mode control: %d\n", ret);
- wm8904_set_drc(codec); + wm8904_set_drc(component); }
- dev_dbg(codec->dev, "%d ReTune Mobile configurations\n", + dev_dbg(component->dev, "%d ReTune Mobile configurations\n", pdata->num_retune_mobile_cfgs);
if (pdata->num_retune_mobile_cfgs) - wm8904_handle_retune_mobile_pdata(codec); + wm8904_handle_retune_mobile_pdata(component); else - snd_soc_add_codec_controls(codec, wm8904_eq_controls, + snd_soc_add_component_controls(component, wm8904_eq_controls, ARRAY_SIZE(wm8904_eq_controls)); }
-static int wm8904_probe(struct snd_soc_codec *codec) +static int wm8904_probe(struct snd_soc_component *component) { - struct wm8904_priv *wm8904 = snd_soc_codec_get_drvdata(codec); + struct wm8904_priv *wm8904 = snd_soc_component_get_drvdata(component);
switch (wm8904->devtype) { case WM8904: @@ -2064,33 +2064,33 @@ static int wm8904_probe(struct snd_soc_codec *codec) memset(&wm8904_dai.capture, 0, sizeof(wm8904_dai.capture)); break; default: - dev_err(codec->dev, "Unknown device type %d\n", + dev_err(component->dev, "Unknown device type %d\n", wm8904->devtype); return -EINVAL; }
- wm8904_handle_pdata(codec); + wm8904_handle_pdata(component);
- wm8904_add_widgets(codec); + wm8904_add_widgets(component);
return 0; }
-static int wm8904_remove(struct snd_soc_codec *codec) +static void wm8904_remove(struct snd_soc_component *component) { - struct wm8904_priv *wm8904 = snd_soc_codec_get_drvdata(codec); + struct wm8904_priv *wm8904 = snd_soc_component_get_drvdata(component);
kfree(wm8904->retune_mobile_texts); kfree(wm8904->drc_texts); - - return 0; }
-static const struct snd_soc_codec_driver soc_codec_dev_wm8904 = { - .probe = wm8904_probe, - .remove = wm8904_remove, - .set_bias_level = wm8904_set_bias_level, - .idle_bias_off = true, +static const struct snd_soc_component_driver soc_component_dev_wm8904 = { + .probe = wm8904_probe, + .remove = wm8904_remove, + .set_bias_level = wm8904_set_bias_level, + .pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, };
static const struct regmap_config wm8904_regmap = { @@ -2265,8 +2265,8 @@ static int wm8904_i2c_probe(struct i2c_client *i2c, regcache_cache_only(wm8904->regmap, true); regulator_bulk_disable(ARRAY_SIZE(wm8904->supplies), wm8904->supplies);
- ret = snd_soc_register_codec(&i2c->dev, - &soc_codec_dev_wm8904, &wm8904_dai, 1); + ret = devm_snd_soc_register_component(&i2c->dev, + &soc_component_dev_wm8904, &wm8904_dai, 1); if (ret != 0) return ret;
@@ -2277,12 +2277,6 @@ static int wm8904_i2c_probe(struct i2c_client *i2c, return ret; }
-static int wm8904_i2c_remove(struct i2c_client *client) -{ - snd_soc_unregister_codec(&client->dev); - return 0; -} - static const struct i2c_device_id wm8904_i2c_id[] = { { "wm8904", WM8904 }, { "wm8912", WM8912 }, @@ -2297,7 +2291,6 @@ static int wm8904_i2c_remove(struct i2c_client *client) .of_match_table = of_match_ptr(wm8904_of_match), }, .probe = wm8904_i2c_probe, - .remove = wm8904_i2c_remove, .id_table = wm8904_i2c_id, };
From: Kuninori Morimoto kuninori.morimoto.gx@renesas.com
Now we can replace Codec to Component. Let's do it.
Note: xxx_codec_xxx() -> xxx_component_xxx() .idle_bias_off = true -> .idle_bias_on = 0 .ignore_pmdown_time = 0 -> .pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com --- sound/soc/codecs/wm9081.c | 228 +++++++++++++++++++++++----------------------- 1 file changed, 112 insertions(+), 116 deletions(-)
diff --git a/sound/soc/codecs/wm9081.c b/sound/soc/codecs/wm9081.c index 6febef3..cb34ed0 100644 --- a/sound/soc/codecs/wm9081.c +++ b/sound/soc/codecs/wm9081.c @@ -339,10 +339,10 @@ static SOC_ENUM_SINGLE_DECL(speaker_mode, WM9081_ANALOGUE_SPEAKER_2, 6, static int speaker_mode_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); unsigned int reg;
- reg = snd_soc_read(codec, WM9081_ANALOGUE_SPEAKER_2); + reg = snd_soc_component_read32(component, WM9081_ANALOGUE_SPEAKER_2); if (reg & WM9081_SPK_MODE) ucontrol->value.enumerated.item[0] = 1; else @@ -360,9 +360,9 @@ static int speaker_mode_get(struct snd_kcontrol *kcontrol, static int speaker_mode_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - unsigned int reg_pwr = snd_soc_read(codec, WM9081_POWER_MANAGEMENT); - unsigned int reg2 = snd_soc_read(codec, WM9081_ANALOGUE_SPEAKER_2); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + unsigned int reg_pwr = snd_soc_component_read32(component, WM9081_POWER_MANAGEMENT); + unsigned int reg2 = snd_soc_component_read32(component, WM9081_ANALOGUE_SPEAKER_2);
/* Are we changing anything? */ if (ucontrol->value.enumerated.item[0] == @@ -383,7 +383,7 @@ static int speaker_mode_put(struct snd_kcontrol *kcontrol, reg2 &= ~WM9081_SPK_MODE; }
- snd_soc_write(codec, WM9081_ANALOGUE_SPEAKER_2, reg2); + snd_soc_component_write(component, WM9081_ANALOGUE_SPEAKER_2, reg2);
return 0; } @@ -546,10 +546,10 @@ static int fll_factors(struct _fll_div *fll_div, unsigned int Fref, return 0; }
-static int wm9081_set_fll(struct snd_soc_codec *codec, int fll_id, +static int wm9081_set_fll(struct snd_soc_component *component, int fll_id, unsigned int Fref, unsigned int Fout) { - struct wm9081_priv *wm9081 = snd_soc_codec_get_drvdata(codec); + struct wm9081_priv *wm9081 = snd_soc_component_get_drvdata(component); u16 reg1, reg4, reg5; struct _fll_div fll_div; int ret; @@ -561,7 +561,7 @@ static int wm9081_set_fll(struct snd_soc_codec *codec, int fll_id,
/* Disable the FLL */ if (Fout == 0) { - dev_dbg(codec->dev, "FLL disabled\n"); + dev_dbg(component->dev, "FLL disabled\n"); wm9081->fll_fref = 0; wm9081->fll_fout = 0;
@@ -572,7 +572,7 @@ static int wm9081_set_fll(struct snd_soc_codec *codec, int fll_id, if (ret != 0) return ret;
- reg5 = snd_soc_read(codec, WM9081_FLL_CONTROL_5); + reg5 = snd_soc_component_read32(component, WM9081_FLL_CONTROL_5); reg5 &= ~WM9081_FLL_CLK_SRC_MASK;
switch (fll_id) { @@ -581,55 +581,55 @@ static int wm9081_set_fll(struct snd_soc_codec *codec, int fll_id, break;
default: - dev_err(codec->dev, "Unknown FLL ID %d\n", fll_id); + dev_err(component->dev, "Unknown FLL ID %d\n", fll_id); return -EINVAL; }
/* Disable CLK_SYS while we reconfigure */ - clk_sys_reg = snd_soc_read(codec, WM9081_CLOCK_CONTROL_3); + clk_sys_reg = snd_soc_component_read32(component, WM9081_CLOCK_CONTROL_3); if (clk_sys_reg & WM9081_CLK_SYS_ENA) - snd_soc_write(codec, WM9081_CLOCK_CONTROL_3, + snd_soc_component_write(component, WM9081_CLOCK_CONTROL_3, clk_sys_reg & ~WM9081_CLK_SYS_ENA);
/* Any FLL configuration change requires that the FLL be * disabled first. */ - reg1 = snd_soc_read(codec, WM9081_FLL_CONTROL_1); + reg1 = snd_soc_component_read32(component, WM9081_FLL_CONTROL_1); reg1 &= ~WM9081_FLL_ENA; - snd_soc_write(codec, WM9081_FLL_CONTROL_1, reg1); + snd_soc_component_write(component, WM9081_FLL_CONTROL_1, reg1);
/* Apply the configuration */ if (fll_div.k) reg1 |= WM9081_FLL_FRAC_MASK; else reg1 &= ~WM9081_FLL_FRAC_MASK; - snd_soc_write(codec, WM9081_FLL_CONTROL_1, reg1); + snd_soc_component_write(component, WM9081_FLL_CONTROL_1, reg1);
- snd_soc_write(codec, WM9081_FLL_CONTROL_2, + snd_soc_component_write(component, WM9081_FLL_CONTROL_2, (fll_div.fll_outdiv << WM9081_FLL_OUTDIV_SHIFT) | (fll_div.fll_fratio << WM9081_FLL_FRATIO_SHIFT)); - snd_soc_write(codec, WM9081_FLL_CONTROL_3, fll_div.k); + snd_soc_component_write(component, WM9081_FLL_CONTROL_3, fll_div.k);
- reg4 = snd_soc_read(codec, WM9081_FLL_CONTROL_4); + reg4 = snd_soc_component_read32(component, WM9081_FLL_CONTROL_4); reg4 &= ~WM9081_FLL_N_MASK; reg4 |= fll_div.n << WM9081_FLL_N_SHIFT; - snd_soc_write(codec, WM9081_FLL_CONTROL_4, reg4); + snd_soc_component_write(component, WM9081_FLL_CONTROL_4, reg4);
reg5 &= ~WM9081_FLL_CLK_REF_DIV_MASK; reg5 |= fll_div.fll_clk_ref_div << WM9081_FLL_CLK_REF_DIV_SHIFT; - snd_soc_write(codec, WM9081_FLL_CONTROL_5, reg5); + snd_soc_component_write(component, WM9081_FLL_CONTROL_5, reg5);
/* Set gain to the recommended value */ - snd_soc_update_bits(codec, WM9081_FLL_CONTROL_4, + snd_soc_component_update_bits(component, WM9081_FLL_CONTROL_4, WM9081_FLL_GAIN_MASK, 0);
/* Enable the FLL */ - snd_soc_write(codec, WM9081_FLL_CONTROL_1, reg1 | WM9081_FLL_ENA); + snd_soc_component_write(component, WM9081_FLL_CONTROL_1, reg1 | WM9081_FLL_ENA);
/* Then bring CLK_SYS up again if it was disabled */ if (clk_sys_reg & WM9081_CLK_SYS_ENA) - snd_soc_write(codec, WM9081_CLOCK_CONTROL_3, clk_sys_reg); + snd_soc_component_write(component, WM9081_CLOCK_CONTROL_3, clk_sys_reg);
- dev_dbg(codec->dev, "FLL enabled at %dHz->%dHz\n", Fref, Fout); + dev_dbg(component->dev, "FLL enabled at %dHz->%dHz\n", Fref, Fout);
wm9081->fll_fref = Fref; wm9081->fll_fout = Fout; @@ -637,9 +637,9 @@ static int wm9081_set_fll(struct snd_soc_codec *codec, int fll_id, return 0; }
-static int configure_clock(struct snd_soc_codec *codec) +static int configure_clock(struct snd_soc_component *component) { - struct wm9081_priv *wm9081 = snd_soc_codec_get_drvdata(codec); + struct wm9081_priv *wm9081 = snd_soc_component_get_drvdata(component); int new_sysclk, i, target; unsigned int reg; int ret = 0; @@ -654,7 +654,7 @@ static int configure_clock(struct snd_soc_codec *codec) } else { wm9081->sysclk_rate = wm9081->mclk_rate; } - wm9081_set_fll(codec, WM9081_SYSCLK_FLL_MCLK, 0, 0); + wm9081_set_fll(component, WM9081_SYSCLK_FLL_MCLK, 0, 0); break;
case WM9081_SYSCLK_FLL_MCLK: @@ -695,7 +695,7 @@ static int configure_clock(struct snd_soc_codec *codec) new_sysclk = 12288000; }
- ret = wm9081_set_fll(codec, WM9081_SYSCLK_FLL_MCLK, + ret = wm9081_set_fll(component, WM9081_SYSCLK_FLL_MCLK, wm9081->mclk_rate, new_sysclk); if (ret == 0) { wm9081->sysclk_rate = new_sysclk; @@ -711,21 +711,21 @@ static int configure_clock(struct snd_soc_codec *codec) return -EINVAL; }
- reg = snd_soc_read(codec, WM9081_CLOCK_CONTROL_1); + reg = snd_soc_component_read32(component, WM9081_CLOCK_CONTROL_1); if (mclkdiv) reg |= WM9081_MCLKDIV2; else reg &= ~WM9081_MCLKDIV2; - snd_soc_write(codec, WM9081_CLOCK_CONTROL_1, reg); + snd_soc_component_write(component, WM9081_CLOCK_CONTROL_1, reg);
- reg = snd_soc_read(codec, WM9081_CLOCK_CONTROL_3); + reg = snd_soc_component_read32(component, WM9081_CLOCK_CONTROL_3); if (fll) reg |= WM9081_CLK_SRC_SEL; else reg &= ~WM9081_CLK_SRC_SEL; - snd_soc_write(codec, WM9081_CLOCK_CONTROL_3, reg); + snd_soc_component_write(component, WM9081_CLOCK_CONTROL_3, reg);
- dev_dbg(codec->dev, "CLK_SYS is %dHz\n", wm9081->sysclk_rate); + dev_dbg(component->dev, "CLK_SYS is %dHz\n", wm9081->sysclk_rate);
return ret; } @@ -733,31 +733,31 @@ static int configure_clock(struct snd_soc_codec *codec) static int clk_sys_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); - struct wm9081_priv *wm9081 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); + struct wm9081_priv *wm9081 = snd_soc_component_get_drvdata(component);
/* This should be done on init() for bypass paths */ switch (wm9081->sysclk_source) { case WM9081_SYSCLK_MCLK: - dev_dbg(codec->dev, "Using %dHz MCLK\n", wm9081->mclk_rate); + dev_dbg(component->dev, "Using %dHz MCLK\n", wm9081->mclk_rate); break; case WM9081_SYSCLK_FLL_MCLK: - dev_dbg(codec->dev, "Using %dHz MCLK with FLL\n", + dev_dbg(component->dev, "Using %dHz MCLK with FLL\n", wm9081->mclk_rate); break; default: - dev_err(codec->dev, "System clock not configured\n"); + dev_err(component->dev, "System clock not configured\n"); return -EINVAL; }
switch (event) { case SND_SOC_DAPM_PRE_PMU: - configure_clock(codec); + configure_clock(component); break;
case SND_SOC_DAPM_POST_PMD: /* Disable the FLL if it's running */ - wm9081_set_fll(codec, 0, 0, 0); + wm9081_set_fll(component, 0, 0, 0); break; }
@@ -816,10 +816,10 @@ static int clk_sys_event(struct snd_soc_dapm_widget *w, { "SPKP", NULL, "Speaker" }, };
-static int wm9081_set_bias_level(struct snd_soc_codec *codec, +static int wm9081_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { - struct wm9081_priv *wm9081 = snd_soc_codec_get_drvdata(codec); + struct wm9081_priv *wm9081 = snd_soc_component_get_drvdata(component);
switch (level) { case SND_SOC_BIAS_ON: @@ -827,31 +827,31 @@ static int wm9081_set_bias_level(struct snd_soc_codec *codec,
case SND_SOC_BIAS_PREPARE: /* VMID=2*40k */ - snd_soc_update_bits(codec, WM9081_VMID_CONTROL, + snd_soc_component_update_bits(component, WM9081_VMID_CONTROL, WM9081_VMID_SEL_MASK, 0x2);
/* Normal bias current */ - snd_soc_update_bits(codec, WM9081_BIAS_CONTROL_1, + snd_soc_component_update_bits(component, WM9081_BIAS_CONTROL_1, WM9081_STBY_BIAS_ENA, 0); break;
case SND_SOC_BIAS_STANDBY: /* Initial cold start */ - if (snd_soc_codec_get_bias_level(codec) == SND_SOC_BIAS_OFF) { + if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_OFF) { regcache_cache_only(wm9081->regmap, false); regcache_sync(wm9081->regmap);
/* Disable LINEOUT discharge */ - snd_soc_update_bits(codec, WM9081_ANTI_POP_CONTROL, + snd_soc_component_update_bits(component, WM9081_ANTI_POP_CONTROL, WM9081_LINEOUT_DISCH, 0);
/* Select startup bias source */ - snd_soc_update_bits(codec, WM9081_BIAS_CONTROL_1, + snd_soc_component_update_bits(component, WM9081_BIAS_CONTROL_1, WM9081_BIAS_SRC | WM9081_BIAS_ENA, WM9081_BIAS_SRC | WM9081_BIAS_ENA);
/* VMID 2*4k; Soft VMID ramp enable */ - snd_soc_update_bits(codec, WM9081_VMID_CONTROL, + snd_soc_component_update_bits(component, WM9081_VMID_CONTROL, WM9081_VMID_RAMP | WM9081_VMID_SEL_MASK, WM9081_VMID_RAMP | 0x6); @@ -859,37 +859,37 @@ static int wm9081_set_bias_level(struct snd_soc_codec *codec, mdelay(100);
/* Normal bias enable & soft start off */ - snd_soc_update_bits(codec, WM9081_VMID_CONTROL, + snd_soc_component_update_bits(component, WM9081_VMID_CONTROL, WM9081_VMID_RAMP, 0);
/* Standard bias source */ - snd_soc_update_bits(codec, WM9081_BIAS_CONTROL_1, + snd_soc_component_update_bits(component, WM9081_BIAS_CONTROL_1, WM9081_BIAS_SRC, 0); }
/* VMID 2*240k */ - snd_soc_update_bits(codec, WM9081_VMID_CONTROL, + snd_soc_component_update_bits(component, WM9081_VMID_CONTROL, WM9081_VMID_SEL_MASK, 0x04);
/* Standby bias current on */ - snd_soc_update_bits(codec, WM9081_BIAS_CONTROL_1, + snd_soc_component_update_bits(component, WM9081_BIAS_CONTROL_1, WM9081_STBY_BIAS_ENA, WM9081_STBY_BIAS_ENA); break;
case SND_SOC_BIAS_OFF: /* Startup bias source and disable bias */ - snd_soc_update_bits(codec, WM9081_BIAS_CONTROL_1, + snd_soc_component_update_bits(component, WM9081_BIAS_CONTROL_1, WM9081_BIAS_SRC | WM9081_BIAS_ENA, WM9081_BIAS_SRC);
/* Disable VMID with soft ramping */ - snd_soc_update_bits(codec, WM9081_VMID_CONTROL, + snd_soc_component_update_bits(component, WM9081_VMID_CONTROL, WM9081_VMID_RAMP | WM9081_VMID_SEL_MASK, WM9081_VMID_RAMP);
/* Actively discharge LINEOUT */ - snd_soc_update_bits(codec, WM9081_ANTI_POP_CONTROL, + snd_soc_component_update_bits(component, WM9081_ANTI_POP_CONTROL, WM9081_LINEOUT_DISCH, WM9081_LINEOUT_DISCH);
@@ -903,9 +903,9 @@ static int wm9081_set_bias_level(struct snd_soc_codec *codec, static int wm9081_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt) { - struct snd_soc_codec *codec = dai->codec; - struct wm9081_priv *wm9081 = snd_soc_codec_get_drvdata(codec); - unsigned int aif2 = snd_soc_read(codec, WM9081_AUDIO_INTERFACE_2); + struct snd_soc_component *component = dai->component; + struct wm9081_priv *wm9081 = snd_soc_component_get_drvdata(component); + unsigned int aif2 = snd_soc_component_read32(component, WM9081_AUDIO_INTERFACE_2);
aif2 &= ~(WM9081_AIF_BCLK_INV | WM9081_AIF_LRCLK_INV | WM9081_BCLK_DIR | WM9081_LRCLK_DIR | WM9081_AIF_FMT_MASK); @@ -986,7 +986,7 @@ static int wm9081_set_dai_fmt(struct snd_soc_dai *dai, return -EINVAL; }
- snd_soc_write(codec, WM9081_AUDIO_INTERFACE_2, aif2); + snd_soc_component_write(component, WM9081_AUDIO_INTERFACE_2, aif2);
return 0; } @@ -995,23 +995,23 @@ static int wm9081_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; - struct wm9081_priv *wm9081 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct wm9081_priv *wm9081 = snd_soc_component_get_drvdata(component); int ret, i, best, best_val, cur_val; unsigned int clk_ctrl2, aif1, aif2, aif3, aif4;
- clk_ctrl2 = snd_soc_read(codec, WM9081_CLOCK_CONTROL_2); + clk_ctrl2 = snd_soc_component_read32(component, WM9081_CLOCK_CONTROL_2); clk_ctrl2 &= ~(WM9081_CLK_SYS_RATE_MASK | WM9081_SAMPLE_RATE_MASK);
- aif1 = snd_soc_read(codec, WM9081_AUDIO_INTERFACE_1); + aif1 = snd_soc_component_read32(component, WM9081_AUDIO_INTERFACE_1);
- aif2 = snd_soc_read(codec, WM9081_AUDIO_INTERFACE_2); + aif2 = snd_soc_component_read32(component, WM9081_AUDIO_INTERFACE_2); aif2 &= ~WM9081_AIF_WL_MASK;
- aif3 = snd_soc_read(codec, WM9081_AUDIO_INTERFACE_3); + aif3 = snd_soc_component_read32(component, WM9081_AUDIO_INTERFACE_3); aif3 &= ~WM9081_BCLK_DIV_MASK;
- aif4 = snd_soc_read(codec, WM9081_AUDIO_INTERFACE_4); + aif4 = snd_soc_component_read32(component, WM9081_AUDIO_INTERFACE_4); aif4 &= ~WM9081_LRCLK_RATE_MASK;
wm9081->fs = params_rate(params); @@ -1047,9 +1047,9 @@ static int wm9081_hw_params(struct snd_pcm_substream *substream, } }
- dev_dbg(codec->dev, "Target BCLK is %dHz\n", wm9081->bclk); + dev_dbg(component->dev, "Target BCLK is %dHz\n", wm9081->bclk);
- ret = configure_clock(codec); + ret = configure_clock(component); if (ret != 0) return ret;
@@ -1065,7 +1065,7 @@ static int wm9081_hw_params(struct snd_pcm_substream *substream, best_val = cur_val; } } - dev_dbg(codec->dev, "Selected CLK_SYS_RATIO of %d\n", + dev_dbg(component->dev, "Selected CLK_SYS_RATIO of %d\n", clk_sys_rates[best].ratio); clk_ctrl2 |= (clk_sys_rates[best].clk_sys_rate << WM9081_CLK_SYS_RATE_SHIFT); @@ -1081,7 +1081,7 @@ static int wm9081_hw_params(struct snd_pcm_substream *substream, best_val = cur_val; } } - dev_dbg(codec->dev, "Selected SAMPLE_RATE of %dHz\n", + dev_dbg(component->dev, "Selected SAMPLE_RATE of %dHz\n", sample_rates[best].rate); clk_ctrl2 |= (sample_rates[best].sample_rate << WM9081_SAMPLE_RATE_SHIFT); @@ -1100,12 +1100,12 @@ static int wm9081_hw_params(struct snd_pcm_substream *substream, } } wm9081->bclk = (wm9081->sysclk_rate * 10) / bclk_divs[best].div; - dev_dbg(codec->dev, "Selected BCLK_DIV of %d for %dHz BCLK\n", + dev_dbg(component->dev, "Selected BCLK_DIV of %d for %dHz BCLK\n", bclk_divs[best].div, wm9081->bclk); aif3 |= bclk_divs[best].bclk_div;
/* LRCLK is a simple fraction of BCLK */ - dev_dbg(codec->dev, "LRCLK_RATE is %d\n", wm9081->bclk / wm9081->fs); + dev_dbg(component->dev, "LRCLK_RATE is %d\n", wm9081->bclk / wm9081->fs); aif4 |= wm9081->bclk / wm9081->fs;
/* Apply a ReTune Mobile configuration if it's in use */ @@ -1126,51 +1126,51 @@ static int wm9081_hw_params(struct snd_pcm_substream *substream, } s = &pdata->retune_configs[best];
- dev_dbg(codec->dev, "ReTune Mobile %s tuned for %dHz\n", + dev_dbg(component->dev, "ReTune Mobile %s tuned for %dHz\n", s->name, s->rate);
/* If the EQ is enabled then disable it while we write out */ - eq1 = snd_soc_read(codec, WM9081_EQ_1) & WM9081_EQ_ENA; + eq1 = snd_soc_component_read32(component, WM9081_EQ_1) & WM9081_EQ_ENA; if (eq1 & WM9081_EQ_ENA) - snd_soc_write(codec, WM9081_EQ_1, 0); + snd_soc_component_write(component, WM9081_EQ_1, 0);
/* Write out the other values */ for (i = 1; i < ARRAY_SIZE(s->config); i++) - snd_soc_write(codec, WM9081_EQ_1 + i, s->config[i]); + snd_soc_component_write(component, WM9081_EQ_1 + i, s->config[i]);
eq1 |= (s->config[0] & ~WM9081_EQ_ENA); - snd_soc_write(codec, WM9081_EQ_1, eq1); + snd_soc_component_write(component, WM9081_EQ_1, eq1); }
- snd_soc_write(codec, WM9081_CLOCK_CONTROL_2, clk_ctrl2); - snd_soc_write(codec, WM9081_AUDIO_INTERFACE_2, aif2); - snd_soc_write(codec, WM9081_AUDIO_INTERFACE_3, aif3); - snd_soc_write(codec, WM9081_AUDIO_INTERFACE_4, aif4); + snd_soc_component_write(component, WM9081_CLOCK_CONTROL_2, clk_ctrl2); + snd_soc_component_write(component, WM9081_AUDIO_INTERFACE_2, aif2); + snd_soc_component_write(component, WM9081_AUDIO_INTERFACE_3, aif3); + snd_soc_component_write(component, WM9081_AUDIO_INTERFACE_4, aif4);
return 0; }
static int wm9081_digital_mute(struct snd_soc_dai *codec_dai, int mute) { - struct snd_soc_codec *codec = codec_dai->codec; + struct snd_soc_component *component = codec_dai->component; unsigned int reg;
- reg = snd_soc_read(codec, WM9081_DAC_DIGITAL_2); + snd_soc_component_read32(component, WM9081_DAC_DIGITAL_2);
if (mute) reg |= WM9081_DAC_MUTE; else reg &= ~WM9081_DAC_MUTE;
- snd_soc_write(codec, WM9081_DAC_DIGITAL_2, reg); + snd_soc_component_write(component, WM9081_DAC_DIGITAL_2, reg);
return 0; }
-static int wm9081_set_sysclk(struct snd_soc_codec *codec, int clk_id, +static int wm9081_set_sysclk(struct snd_soc_component *component, int clk_id, int source, unsigned int freq, int dir) { - struct wm9081_priv *wm9081 = snd_soc_codec_get_drvdata(codec); + struct wm9081_priv *wm9081 = snd_soc_component_get_drvdata(component);
switch (clk_id) { case WM9081_SYSCLK_MCLK: @@ -1189,9 +1189,9 @@ static int wm9081_set_sysclk(struct snd_soc_codec *codec, int clk_id, static int wm9081_set_tdm_slot(struct snd_soc_dai *dai, unsigned int tx_mask, unsigned int rx_mask, int slots, int slot_width) { - struct snd_soc_codec *codec = dai->codec; - struct wm9081_priv *wm9081 = snd_soc_codec_get_drvdata(codec); - unsigned int aif1 = snd_soc_read(codec, WM9081_AUDIO_INTERFACE_1); + struct snd_soc_component *component = dai->component; + struct wm9081_priv *wm9081 = snd_soc_component_get_drvdata(component); + unsigned int aif1 = snd_soc_component_read32(component, WM9081_AUDIO_INTERFACE_1);
aif1 &= ~(WM9081_AIFDAC_TDM_SLOT_MASK | WM9081_AIFDAC_TDM_MODE_MASK);
@@ -1221,7 +1221,7 @@ static int wm9081_set_tdm_slot(struct snd_soc_dai *dai, return -EINVAL; }
- snd_soc_write(codec, WM9081_AUDIO_INTERFACE_1, aif1); + snd_soc_component_write(component, WM9081_AUDIO_INTERFACE_1, aif1);
return 0; } @@ -1254,42 +1254,39 @@ static int wm9081_set_tdm_slot(struct snd_soc_dai *dai, .ops = &wm9081_dai_ops, };
-static int wm9081_probe(struct snd_soc_codec *codec) +static int wm9081_probe(struct snd_soc_component *component) { - struct wm9081_priv *wm9081 = snd_soc_codec_get_drvdata(codec); + struct wm9081_priv *wm9081 = snd_soc_component_get_drvdata(component);
/* Enable zero cross by default */ - snd_soc_update_bits(codec, WM9081_ANALOGUE_LINEOUT, + snd_soc_component_update_bits(component, WM9081_ANALOGUE_LINEOUT, WM9081_LINEOUTZC, WM9081_LINEOUTZC); - snd_soc_update_bits(codec, WM9081_ANALOGUE_SPEAKER_PGA, + snd_soc_component_update_bits(component, WM9081_ANALOGUE_SPEAKER_PGA, WM9081_SPKPGAZC, WM9081_SPKPGAZC);
if (!wm9081->pdata.num_retune_configs) { - dev_dbg(codec->dev, + dev_dbg(component->dev, "No ReTune Mobile data, using normal EQ\n"); - snd_soc_add_codec_controls(codec, wm9081_eq_controls, + snd_soc_add_component_controls(component, wm9081_eq_controls, ARRAY_SIZE(wm9081_eq_controls)); }
return 0; }
-static const struct snd_soc_codec_driver soc_codec_dev_wm9081 = { - .probe = wm9081_probe, - - .set_sysclk = wm9081_set_sysclk, - .set_bias_level = wm9081_set_bias_level, - - .idle_bias_off = true, - - .component_driver = { - .controls = wm9081_snd_controls, - .num_controls = ARRAY_SIZE(wm9081_snd_controls), - .dapm_widgets = wm9081_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(wm9081_dapm_widgets), - .dapm_routes = wm9081_audio_paths, - .num_dapm_routes = ARRAY_SIZE(wm9081_audio_paths), - }, +static const struct snd_soc_component_driver soc_component_dev_wm9081 = { + .probe = wm9081_probe, + .set_sysclk = wm9081_set_sysclk, + .set_bias_level = wm9081_set_bias_level, + .controls = wm9081_snd_controls, + .num_controls = ARRAY_SIZE(wm9081_snd_controls), + .dapm_widgets = wm9081_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(wm9081_dapm_widgets), + .dapm_routes = wm9081_audio_paths, + .num_dapm_routes = ARRAY_SIZE(wm9081_audio_paths), + .pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, };
static const struct regmap_config wm9081_regmap = { @@ -1355,8 +1352,8 @@ static int wm9081_i2c_probe(struct i2c_client *i2c,
regcache_cache_only(wm9081->regmap, true);
- ret = snd_soc_register_codec(&i2c->dev, - &soc_codec_dev_wm9081, &wm9081_dai, 1); + ret = devm_snd_soc_register_component(&i2c->dev, + &soc_component_dev_wm9081, &wm9081_dai, 1); if (ret < 0) return ret;
@@ -1365,7 +1362,6 @@ static int wm9081_i2c_probe(struct i2c_client *i2c,
static int wm9081_i2c_remove(struct i2c_client *client) { - snd_soc_unregister_codec(&client->dev); return 0; }
From: Kuninori Morimoto kuninori.morimoto.gx@renesas.com
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 -> .pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com --- sound/soc/codecs/wm9090.c | 109 ++++++++++++++++++++++------------------------ 1 file changed, 53 insertions(+), 56 deletions(-)
diff --git a/sound/soc/codecs/wm9090.c b/sound/soc/codecs/wm9090.c index 5a13138..9cd5f93 100644 --- a/sound/soc/codecs/wm9090.c +++ b/sound/soc/codecs/wm9090.c @@ -143,23 +143,23 @@ static bool wm9090_readable(struct device *dev, unsigned int reg) } }
-static void wait_for_dc_servo(struct snd_soc_codec *codec) +static void wait_for_dc_servo(struct snd_soc_component *component) { unsigned int reg; int count = 0;
- dev_dbg(codec->dev, "Waiting for DC servo...\n"); + dev_dbg(component->dev, "Waiting for DC servo...\n"); do { count++; msleep(1); - reg = snd_soc_read(codec, WM9090_DC_SERVO_READBACK_0); - dev_dbg(codec->dev, "DC servo status: %x\n", reg); + reg = snd_soc_component_read32(component, WM9090_DC_SERVO_READBACK_0); + dev_dbg(component->dev, "DC servo status: %x\n", reg); } while ((reg & WM9090_DCS_CAL_COMPLETE_MASK) != WM9090_DCS_CAL_COMPLETE_MASK && count < 1000);
if ((reg & WM9090_DCS_CAL_COMPLETE_MASK) != WM9090_DCS_CAL_COMPLETE_MASK) - dev_err(codec->dev, "Timed out waiting for DC Servo\n"); + dev_err(component->dev, "Timed out waiting for DC Servo\n"); }
static const DECLARE_TLV_DB_RANGE(in_tlv, @@ -251,22 +251,22 @@ static const DECLARE_TLV_DB_RANGE(spkboost_tlv, static int hp_ev(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); - unsigned int reg = snd_soc_read(codec, WM9090_ANALOGUE_HP_0); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); + unsigned int reg = snd_soc_component_read32(component, WM9090_ANALOGUE_HP_0);
switch (event) { case SND_SOC_DAPM_POST_PMU: - snd_soc_update_bits(codec, WM9090_CHARGE_PUMP_1, + snd_soc_component_update_bits(component, WM9090_CHARGE_PUMP_1, WM9090_CP_ENA, WM9090_CP_ENA);
msleep(5);
- snd_soc_update_bits(codec, WM9090_POWER_MANAGEMENT_1, + snd_soc_component_update_bits(component, WM9090_POWER_MANAGEMENT_1, WM9090_HPOUT1L_ENA | WM9090_HPOUT1R_ENA, WM9090_HPOUT1L_ENA | WM9090_HPOUT1R_ENA);
reg |= WM9090_HPOUT1L_DLY | WM9090_HPOUT1R_DLY; - snd_soc_write(codec, WM9090_ANALOGUE_HP_0, reg); + snd_soc_component_write(component, WM9090_ANALOGUE_HP_0, reg);
/* Start the DC servo. We don't currently use the * ability to save the state since we don't have full @@ -274,16 +274,16 @@ static int hp_ev(struct snd_soc_dapm_widget *w, * DC offsets; see the WM8904 driver for an example of * doing so. */ - snd_soc_write(codec, WM9090_DC_SERVO_0, + snd_soc_component_write(component, WM9090_DC_SERVO_0, WM9090_DCS_ENA_CHAN_0 | WM9090_DCS_ENA_CHAN_1 | WM9090_DCS_TRIG_STARTUP_1 | WM9090_DCS_TRIG_STARTUP_0); - wait_for_dc_servo(codec); + wait_for_dc_servo(component);
reg |= WM9090_HPOUT1R_OUTP | WM9090_HPOUT1R_RMV_SHORT | WM9090_HPOUT1L_OUTP | WM9090_HPOUT1L_RMV_SHORT; - snd_soc_write(codec, WM9090_ANALOGUE_HP_0, reg); + snd_soc_component_write(component, WM9090_ANALOGUE_HP_0, reg); break;
case SND_SOC_DAPM_PRE_PMD: @@ -294,15 +294,15 @@ static int hp_ev(struct snd_soc_dapm_widget *w, WM9090_HPOUT1R_DLY | WM9090_HPOUT1R_OUTP);
- snd_soc_write(codec, WM9090_ANALOGUE_HP_0, reg); + snd_soc_component_write(component, WM9090_ANALOGUE_HP_0, reg);
- snd_soc_write(codec, WM9090_DC_SERVO_0, 0); + snd_soc_component_write(component, WM9090_DC_SERVO_0, 0);
- snd_soc_update_bits(codec, WM9090_POWER_MANAGEMENT_1, + snd_soc_component_update_bits(component, WM9090_POWER_MANAGEMENT_1, WM9090_HPOUT1L_ENA | WM9090_HPOUT1R_ENA, 0);
- snd_soc_update_bits(codec, WM9090_CHARGE_PUMP_1, + snd_soc_component_update_bits(component, WM9090_CHARGE_PUMP_1, WM9090_CP_ENA, 0); break; } @@ -419,10 +419,10 @@ static int hp_ev(struct snd_soc_dapm_widget *w, { "IN2A PGA", NULL, "IN2-" }, };
-static int wm9090_add_controls(struct snd_soc_codec *codec) +static int wm9090_add_controls(struct snd_soc_component *component) { - struct wm9090_priv *wm9090 = snd_soc_codec_get_drvdata(codec); - struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec); + struct wm9090_priv *wm9090 = snd_soc_component_get_drvdata(component); + struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); int i;
snd_soc_dapm_new_controls(dapm, wm9090_dapm_widgets, @@ -430,7 +430,7 @@ static int wm9090_add_controls(struct snd_soc_codec *codec)
snd_soc_dapm_add_routes(dapm, audio_map, ARRAY_SIZE(audio_map));
- snd_soc_add_codec_controls(codec, wm9090_controls, + snd_soc_add_component_controls(component, wm9090_controls, ARRAY_SIZE(wm9090_controls));
if (wm9090->pdata.lin1_diff) { @@ -439,7 +439,7 @@ static int wm9090_add_controls(struct snd_soc_codec *codec) } else { snd_soc_dapm_add_routes(dapm, audio_map_in1_se, ARRAY_SIZE(audio_map_in1_se)); - snd_soc_add_codec_controls(codec, wm9090_in1_se_controls, + snd_soc_add_component_controls(component, wm9090_in1_se_controls, ARRAY_SIZE(wm9090_in1_se_controls)); }
@@ -449,18 +449,18 @@ static int wm9090_add_controls(struct snd_soc_codec *codec) } else { snd_soc_dapm_add_routes(dapm, audio_map_in2_se, ARRAY_SIZE(audio_map_in2_se)); - snd_soc_add_codec_controls(codec, wm9090_in2_se_controls, + snd_soc_add_component_controls(component, wm9090_in2_se_controls, ARRAY_SIZE(wm9090_in2_se_controls)); }
if (wm9090->pdata.agc_ena) { for (i = 0; i < ARRAY_SIZE(wm9090->pdata.agc); i++) - snd_soc_write(codec, WM9090_AGC_CONTROL_0 + i, + snd_soc_component_write(component, WM9090_AGC_CONTROL_0 + i, wm9090->pdata.agc[i]); - snd_soc_update_bits(codec, WM9090_POWER_MANAGEMENT_3, + snd_soc_component_update_bits(component, WM9090_POWER_MANAGEMENT_3, WM9090_AGC_ENA, WM9090_AGC_ENA); } else { - snd_soc_update_bits(codec, WM9090_POWER_MANAGEMENT_3, + snd_soc_component_update_bits(component, WM9090_POWER_MANAGEMENT_3, WM9090_AGC_ENA, 0); }
@@ -472,19 +472,19 @@ static int wm9090_add_controls(struct snd_soc_codec *codec) * The machine driver should call this from their set_bias_level; if there * isn't one then this can just be set as the set_bias_level function. */ -static int wm9090_set_bias_level(struct snd_soc_codec *codec, +static int wm9090_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { - struct wm9090_priv *wm9090 = snd_soc_codec_get_drvdata(codec); + struct wm9090_priv *wm9090 = snd_soc_component_get_drvdata(component);
switch (level) { case SND_SOC_BIAS_ON: break;
case SND_SOC_BIAS_PREPARE: - snd_soc_update_bits(codec, WM9090_ANTIPOP2, WM9090_VMID_ENA, + snd_soc_component_update_bits(component, WM9090_ANTIPOP2, WM9090_VMID_ENA, WM9090_VMID_ENA); - snd_soc_update_bits(codec, WM9090_POWER_MANAGEMENT_1, + snd_soc_component_update_bits(component, WM9090_POWER_MANAGEMENT_1, WM9090_BIAS_ENA | WM9090_VMID_RES_MASK, WM9090_BIAS_ENA | @@ -493,7 +493,7 @@ static int wm9090_set_bias_level(struct snd_soc_codec *codec, break;
case SND_SOC_BIAS_STANDBY: - if (snd_soc_codec_get_bias_level(codec) == SND_SOC_BIAS_OFF) { + if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_OFF) { /* Restore the register cache */ regcache_sync(wm9090->regmap); } @@ -502,9 +502,9 @@ static int wm9090_set_bias_level(struct snd_soc_codec *codec, * ground referenced outputs and class D speaker mean that * latency is not an issue. */ - snd_soc_update_bits(codec, WM9090_POWER_MANAGEMENT_1, + snd_soc_component_update_bits(component, WM9090_POWER_MANAGEMENT_1, WM9090_BIAS_ENA | WM9090_VMID_RES_MASK, 0); - snd_soc_update_bits(codec, WM9090_ANTIPOP2, + snd_soc_component_update_bits(component, WM9090_ANTIPOP2, WM9090_VMID_ENA, 0); break;
@@ -515,45 +515,49 @@ static int wm9090_set_bias_level(struct snd_soc_codec *codec, return 0; }
-static int wm9090_probe(struct snd_soc_codec *codec) +static int wm9090_probe(struct snd_soc_component *component) { /* Configure some defaults; they will be written out when we * bring the bias up. */ - snd_soc_update_bits(codec, WM9090_IN1_LINE_INPUT_A_VOLUME, + snd_soc_component_update_bits(component, WM9090_IN1_LINE_INPUT_A_VOLUME, WM9090_IN1_VU | WM9090_IN1A_ZC, WM9090_IN1_VU | WM9090_IN1A_ZC); - snd_soc_update_bits(codec, WM9090_IN1_LINE_INPUT_B_VOLUME, + snd_soc_component_update_bits(component, WM9090_IN1_LINE_INPUT_B_VOLUME, WM9090_IN1_VU | WM9090_IN1B_ZC, WM9090_IN1_VU | WM9090_IN1B_ZC); - snd_soc_update_bits(codec, WM9090_IN2_LINE_INPUT_A_VOLUME, + snd_soc_component_update_bits(component, WM9090_IN2_LINE_INPUT_A_VOLUME, WM9090_IN2_VU | WM9090_IN2A_ZC, WM9090_IN2_VU | WM9090_IN2A_ZC); - snd_soc_update_bits(codec, WM9090_IN2_LINE_INPUT_B_VOLUME, + snd_soc_component_update_bits(component, WM9090_IN2_LINE_INPUT_B_VOLUME, WM9090_IN2_VU | WM9090_IN2B_ZC, WM9090_IN2_VU | WM9090_IN2B_ZC); - snd_soc_update_bits(codec, WM9090_SPEAKER_VOLUME_LEFT, + snd_soc_component_update_bits(component, WM9090_SPEAKER_VOLUME_LEFT, WM9090_SPKOUT_VU | WM9090_SPKOUTL_ZC, WM9090_SPKOUT_VU | WM9090_SPKOUTL_ZC); - snd_soc_update_bits(codec, WM9090_LEFT_OUTPUT_VOLUME, + snd_soc_component_update_bits(component, WM9090_LEFT_OUTPUT_VOLUME, WM9090_HPOUT1_VU | WM9090_HPOUT1L_ZC, WM9090_HPOUT1_VU | WM9090_HPOUT1L_ZC); - snd_soc_update_bits(codec, WM9090_RIGHT_OUTPUT_VOLUME, + snd_soc_component_update_bits(component, WM9090_RIGHT_OUTPUT_VOLUME, WM9090_HPOUT1_VU | WM9090_HPOUT1R_ZC, WM9090_HPOUT1_VU | WM9090_HPOUT1R_ZC);
- snd_soc_update_bits(codec, WM9090_CLOCKING_1, + snd_soc_component_update_bits(component, WM9090_CLOCKING_1, WM9090_TOCLK_ENA, WM9090_TOCLK_ENA);
- wm9090_add_controls(codec); + wm9090_add_controls(component);
return 0; }
-static const struct snd_soc_codec_driver soc_codec_dev_wm9090 = { - .probe = wm9090_probe, - .set_bias_level = wm9090_set_bias_level, - .suspend_bias_off = true, +static const struct snd_soc_component_driver soc_component_dev_wm9090 = { + .probe = wm9090_probe, + .set_bias_level = wm9090_set_bias_level, + .suspend_bias_off = 1, + .idle_bias_on = 1, + .pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, };
static const struct regmap_config wm9090_regmap = { @@ -607,8 +611,8 @@ static int wm9090_i2c_probe(struct i2c_client *i2c,
i2c_set_clientdata(i2c, wm9090);
- ret = snd_soc_register_codec(&i2c->dev, - &soc_codec_dev_wm9090, NULL, 0); + ret = devm_snd_soc_register_component(&i2c->dev, + &soc_component_dev_wm9090, NULL, 0); if (ret != 0) { dev_err(&i2c->dev, "Failed to register CODEC: %d\n", ret); return ret; @@ -617,12 +621,6 @@ static int wm9090_i2c_probe(struct i2c_client *i2c, return 0; }
-static int wm9090_i2c_remove(struct i2c_client *i2c) -{ - snd_soc_unregister_codec(&i2c->dev); - return 0; -} - static const struct i2c_device_id wm9090_id[] = { { "wm9090", 0 }, { "wm9093", 0 }, @@ -635,7 +633,6 @@ static int wm9090_i2c_remove(struct i2c_client *i2c) .name = "wm9090", }, .probe = wm9090_i2c_probe, - .remove = wm9090_i2c_remove, .id_table = wm9090_id, };
From: Kuninori Morimoto kuninori.morimoto.gx@renesas.com
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 -> .pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com --- sound/soc/codecs/wm9705.c | 83 ++++++++++++++++++++++------------------------- 1 file changed, 38 insertions(+), 45 deletions(-)
diff --git a/sound/soc/codecs/wm9705.c b/sound/soc/codecs/wm9705.c index 2c09f71..09cfeba 100644 --- a/sound/soc/codecs/wm9705.c +++ b/sound/soc/codecs/wm9705.c @@ -235,17 +235,17 @@ static SOC_ENUM_SINGLE_DECL(wm9705_enum_rec_r, static int ac97_prepare(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; + struct snd_soc_component *component = dai->component; int reg;
- snd_soc_update_bits(codec, AC97_EXTENDED_STATUS, 0x1, 0x1); + snd_soc_component_update_bits(component, AC97_EXTENDED_STATUS, 0x1, 0x1);
if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) reg = AC97_PCM_FRONT_DAC_RATE; else reg = AC97_PCM_LR_ADC_RATE;
- return snd_soc_write(codec, reg, substream->runtime->rate); + return snd_soc_component_write(component, reg, substream->runtime->rate); }
#define WM9705_AC97_RATES (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 | \ @@ -289,18 +289,18 @@ static int ac97_prepare(struct snd_pcm_substream *substream, };
#ifdef CONFIG_PM -static int wm9705_soc_suspend(struct snd_soc_codec *codec) +static int wm9705_soc_suspend(struct snd_soc_component *component) { - regcache_cache_bypass(codec->component.regmap, true); - snd_soc_write(codec, AC97_POWERDOWN, 0xffff); - regcache_cache_bypass(codec->component.regmap, false); + regcache_cache_bypass(component->regmap, true); + snd_soc_component_write(component, AC97_POWERDOWN, 0xffff); + regcache_cache_bypass(component->regmap, false);
return 0; }
-static int wm9705_soc_resume(struct snd_soc_codec *codec) +static int wm9705_soc_resume(struct snd_soc_component *component) { - struct wm9705_priv *wm9705 = snd_soc_codec_get_drvdata(codec); + struct wm9705_priv *wm9705 = snd_soc_component_get_drvdata(component); int ret;
ret = snd_ac97_reset(wm9705->ac97, true, WM9705_VENDOR_ID, @@ -308,7 +308,7 @@ static int wm9705_soc_resume(struct snd_soc_codec *codec) if (ret < 0) return ret;
- regcache_sync(codec->component.regmap); + snd_soc_component_cache_sync(component);
return 0; } @@ -317,9 +317,9 @@ static int wm9705_soc_resume(struct snd_soc_codec *codec) #define wm9705_soc_resume NULL #endif
-static int wm9705_soc_probe(struct snd_soc_codec *codec) +static int wm9705_soc_probe(struct snd_soc_component *component) { - struct wm9705_priv *wm9705 = snd_soc_codec_get_drvdata(codec); + struct wm9705_priv *wm9705 = snd_soc_component_get_drvdata(component); struct regmap *regmap;
if (wm9705->mfd_pdata) { @@ -327,54 +327,54 @@ static int wm9705_soc_probe(struct snd_soc_codec *codec) regmap = wm9705->mfd_pdata->regmap; } else { #ifdef CONFIG_SND_SOC_AC97_BUS - wm9705->ac97 = snd_soc_new_ac97_codec(codec, WM9705_VENDOR_ID, + wm9705->ac97 = snd_soc_new_ac97_component(component, WM9705_VENDOR_ID, WM9705_VENDOR_ID_MASK); if (IS_ERR(wm9705->ac97)) { - dev_err(codec->dev, "Failed to register AC97 codec\n"); + dev_err(component->dev, "Failed to register AC97 codec\n"); return PTR_ERR(wm9705->ac97); }
regmap = regmap_init_ac97(wm9705->ac97, &wm9705_regmap_config); if (IS_ERR(regmap)) { - snd_soc_free_ac97_codec(wm9705->ac97); + snd_soc_free_ac97_component(wm9705->ac97); return PTR_ERR(regmap); } #endif }
- snd_soc_codec_set_drvdata(codec, wm9705->ac97); - snd_soc_codec_init_regmap(codec, regmap); + snd_soc_component_set_drvdata(component, wm9705->ac97); + snd_soc_component_init_regmap(component, regmap);
return 0; }
-static int wm9705_soc_remove(struct snd_soc_codec *codec) +static void wm9705_soc_remove(struct snd_soc_component *component) { #ifdef CONFIG_SND_SOC_AC97_BUS - struct wm9705_priv *wm9705 = snd_soc_codec_get_drvdata(codec); + struct wm9705_priv *wm9705 = snd_soc_component_get_drvdata(component);
if (!wm9705->mfd_pdata) { - snd_soc_codec_exit_regmap(codec); - snd_soc_free_ac97_codec(wm9705->ac97); + snd_soc_component_exit_regmap(component); + snd_soc_free_ac97_component(wm9705->ac97); } #endif - return 0; }
-static const struct snd_soc_codec_driver soc_codec_dev_wm9705 = { - .probe = wm9705_soc_probe, - .remove = wm9705_soc_remove, - .suspend = wm9705_soc_suspend, - .resume = wm9705_soc_resume, - - .component_driver = { - .controls = wm9705_snd_ac97_controls, - .num_controls = ARRAY_SIZE(wm9705_snd_ac97_controls), - .dapm_widgets = wm9705_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(wm9705_dapm_widgets), - .dapm_routes = wm9705_audio_map, - .num_dapm_routes = ARRAY_SIZE(wm9705_audio_map), - }, +static const struct snd_soc_component_driver soc_component_dev_wm9705 = { + .probe = wm9705_soc_probe, + .remove = wm9705_soc_remove, + .suspend = wm9705_soc_suspend, + .resume = wm9705_soc_resume, + .controls = wm9705_snd_ac97_controls, + .num_controls = ARRAY_SIZE(wm9705_snd_ac97_controls), + .dapm_widgets = wm9705_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(wm9705_dapm_widgets), + .dapm_routes = wm9705_audio_map, + .num_dapm_routes = ARRAY_SIZE(wm9705_audio_map), + .idle_bias_on = 1, + .pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, };
static int wm9705_probe(struct platform_device *pdev) @@ -388,14 +388,8 @@ static int wm9705_probe(struct platform_device *pdev) wm9705->mfd_pdata = dev_get_platdata(&pdev->dev); platform_set_drvdata(pdev, wm9705);
- return snd_soc_register_codec(&pdev->dev, - &soc_codec_dev_wm9705, wm9705_dai, ARRAY_SIZE(wm9705_dai)); -} - -static int wm9705_remove(struct platform_device *pdev) -{ - snd_soc_unregister_codec(&pdev->dev); - return 0; + return devm_snd_soc_register_component(&pdev->dev, + &soc_component_dev_wm9705, wm9705_dai, ARRAY_SIZE(wm9705_dai)); }
static struct platform_driver wm9705_codec_driver = { @@ -404,7 +398,6 @@ static int wm9705_remove(struct platform_device *pdev) },
.probe = wm9705_probe, - .remove = wm9705_remove, };
module_platform_driver(wm9705_codec_driver);
From: Kuninori Morimoto kuninori.morimoto.gx@renesas.com
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 -> .pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com --- sound/soc/codecs/wm9712.c | 109 ++++++++++++++++++++++------------------------ 1 file changed, 51 insertions(+), 58 deletions(-)
diff --git a/sound/soc/codecs/wm9712.c b/sound/soc/codecs/wm9712.c index 4f6d1a4..d5ae120 100644 --- a/sound/soc/codecs/wm9712.c +++ b/sound/soc/codecs/wm9712.c @@ -220,8 +220,8 @@ static int wm9712_hp_mixer_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { struct snd_soc_dapm_context *dapm = snd_soc_dapm_kcontrol_dapm(kcontrol); - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(dapm); - struct wm9712_priv *wm9712 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_dapm_to_component(dapm); + struct wm9712_priv *wm9712 = snd_soc_component_get_drvdata(component); unsigned int val = ucontrol->value.integer.value[0]; struct soc_mixer_control *mc = (struct soc_mixer_control *)kcontrol->private_value; @@ -264,8 +264,8 @@ static int wm9712_hp_mixer_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { struct snd_soc_dapm_context *dapm = snd_soc_dapm_kcontrol_dapm(kcontrol); - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(dapm); - struct wm9712_priv *wm9712 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_dapm_to_component(dapm); + struct wm9712_priv *wm9712 = snd_soc_component_get_drvdata(component); struct soc_mixer_control *mc = (struct soc_mixer_control *)kcontrol->private_value; unsigned int shift, mixer; @@ -527,33 +527,33 @@ static int wm9712_hp_mixer_get(struct snd_kcontrol *kcontrol, static int ac97_prepare(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; + struct snd_soc_component *component = dai->component; int reg; struct snd_pcm_runtime *runtime = substream->runtime;
- snd_soc_update_bits(codec, AC97_EXTENDED_STATUS, 0x1, 0x1); + snd_soc_component_update_bits(component, AC97_EXTENDED_STATUS, 0x1, 0x1);
if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) reg = AC97_PCM_FRONT_DAC_RATE; else reg = AC97_PCM_LR_ADC_RATE;
- return snd_soc_write(codec, reg, runtime->rate); + return snd_soc_component_write(component, reg, runtime->rate); }
static int ac97_aux_prepare(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; + struct snd_soc_component *component = dai->component; struct snd_pcm_runtime *runtime = substream->runtime;
- snd_soc_update_bits(codec, AC97_EXTENDED_STATUS, 0x1, 0x1); - snd_soc_update_bits(codec, AC97_PCI_SID, 0x8000, 0x8000); + snd_soc_component_update_bits(component, AC97_EXTENDED_STATUS, 0x1, 0x1); + snd_soc_component_update_bits(component, AC97_PCI_SID, 0x8000, 0x8000);
if (substream->stream != SNDRV_PCM_STREAM_PLAYBACK) return -ENODEV;
- return snd_soc_write(codec, AC97_PCM_SURR_DAC_RATE, runtime->rate); + return snd_soc_component_write(component, AC97_PCM_SURR_DAC_RATE, runtime->rate); }
#define WM9712_AC97_RATES (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |\ @@ -597,7 +597,7 @@ static int ac97_aux_prepare(struct snd_pcm_substream *substream, } };
-static int wm9712_set_bias_level(struct snd_soc_codec *codec, +static int wm9712_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { switch (level) { @@ -605,20 +605,20 @@ static int wm9712_set_bias_level(struct snd_soc_codec *codec, case SND_SOC_BIAS_PREPARE: break; case SND_SOC_BIAS_STANDBY: - snd_soc_write(codec, AC97_POWERDOWN, 0x0000); + snd_soc_component_write(component, AC97_POWERDOWN, 0x0000); break; case SND_SOC_BIAS_OFF: /* disable everything including AC link */ - snd_soc_write(codec, AC97_EXTENDED_MSTATUS, 0xffff); - snd_soc_write(codec, AC97_POWERDOWN, 0xffff); + snd_soc_component_write(component, AC97_EXTENDED_MSTATUS, 0xffff); + snd_soc_component_write(component, AC97_POWERDOWN, 0xffff); break; } return 0; }
-static int wm9712_soc_resume(struct snd_soc_codec *codec) +static int wm9712_soc_resume(struct snd_soc_component *component) { - struct wm9712_priv *wm9712 = snd_soc_codec_get_drvdata(codec); + struct wm9712_priv *wm9712 = snd_soc_component_get_drvdata(component); int ret;
ret = snd_ac97_reset(wm9712->ac97, true, WM9712_VENDOR_ID, @@ -626,17 +626,17 @@ static int wm9712_soc_resume(struct snd_soc_codec *codec) if (ret < 0) return ret;
- snd_soc_codec_force_bias_level(codec, SND_SOC_BIAS_STANDBY); + snd_soc_component_force_bias_level(component, SND_SOC_BIAS_STANDBY);
if (ret == 0) - regcache_sync(codec->component.regmap); + snd_soc_component_cache_sync(component);
return ret; }
-static int wm9712_soc_probe(struct snd_soc_codec *codec) +static int wm9712_soc_probe(struct snd_soc_component *component) { - struct wm9712_priv *wm9712 = snd_soc_codec_get_drvdata(codec); + struct wm9712_priv *wm9712 = snd_soc_component_get_drvdata(component); struct regmap *regmap; int ret;
@@ -645,59 +645,59 @@ static int wm9712_soc_probe(struct snd_soc_codec *codec) regmap = wm9712->mfd_pdata->regmap; } else { #ifdef CONFIG_SND_SOC_AC97_BUS - wm9712->ac97 = snd_soc_new_ac97_codec(codec, WM9712_VENDOR_ID, + wm9712->ac97 = snd_soc_new_ac97_component(component, WM9712_VENDOR_ID, WM9712_VENDOR_ID_MASK); if (IS_ERR(wm9712->ac97)) { ret = PTR_ERR(wm9712->ac97); - dev_err(codec->dev, + dev_err(component->dev, "Failed to register AC97 codec: %d\n", ret); return ret; }
regmap = regmap_init_ac97(wm9712->ac97, &wm9712_regmap_config); if (IS_ERR(regmap)) { - snd_soc_free_ac97_codec(wm9712->ac97); + snd_soc_free_ac97_component(wm9712->ac97); return PTR_ERR(regmap); } #endif }
- snd_soc_codec_init_regmap(codec, regmap); + snd_soc_component_init_regmap(component, regmap);
/* set alc mux to none */ - snd_soc_update_bits(codec, AC97_VIDEO, 0x3000, 0x3000); + snd_soc_component_update_bits(component, AC97_VIDEO, 0x3000, 0x3000);
return 0; }
-static int wm9712_soc_remove(struct snd_soc_codec *codec) +static void wm9712_soc_remove(struct snd_soc_component *component) { #ifdef CONFIG_SND_SOC_AC97_BUS - struct wm9712_priv *wm9712 = snd_soc_codec_get_drvdata(codec); + struct wm9712_priv *wm9712 = snd_soc_component_get_drvdata(component);
if (!wm9712->mfd_pdata) { - snd_soc_codec_exit_regmap(codec); - snd_soc_free_ac97_codec(wm9712->ac97); + snd_soc_component_exit_regmap(component); + snd_soc_free_ac97_component(wm9712->ac97); } #endif - return 0; }
-static const struct snd_soc_codec_driver soc_codec_dev_wm9712 = { - .probe = wm9712_soc_probe, - .remove = wm9712_soc_remove, - .resume = wm9712_soc_resume, - .set_bias_level = wm9712_set_bias_level, - .suspend_bias_off = true, - - .component_driver = { - .controls = wm9712_snd_ac97_controls, - .num_controls = ARRAY_SIZE(wm9712_snd_ac97_controls), - .dapm_widgets = wm9712_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(wm9712_dapm_widgets), - .dapm_routes = wm9712_audio_map, - .num_dapm_routes = ARRAY_SIZE(wm9712_audio_map), - }, +static const struct snd_soc_component_driver soc_component_dev_wm9712 = { + .probe = wm9712_soc_probe, + .remove = wm9712_soc_remove, + .resume = wm9712_soc_resume, + .set_bias_level = wm9712_set_bias_level, + .controls = wm9712_snd_ac97_controls, + .num_controls = ARRAY_SIZE(wm9712_snd_ac97_controls), + .dapm_widgets = wm9712_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(wm9712_dapm_widgets), + .dapm_routes = wm9712_audio_map, + .num_dapm_routes = ARRAY_SIZE(wm9712_audio_map), + .suspend_bias_off = 1, + .idle_bias_on = 1, + .pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, };
static int wm9712_probe(struct platform_device *pdev) @@ -713,26 +713,19 @@ static int wm9712_probe(struct platform_device *pdev) wm9712->mfd_pdata = dev_get_platdata(&pdev->dev); platform_set_drvdata(pdev, wm9712);
- return snd_soc_register_codec(&pdev->dev, - &soc_codec_dev_wm9712, wm9712_dai, ARRAY_SIZE(wm9712_dai)); -} - -static int wm9712_remove(struct platform_device *pdev) -{ - snd_soc_unregister_codec(&pdev->dev); - return 0; + return devm_snd_soc_register_component(&pdev->dev, + &soc_component_dev_wm9712, wm9712_dai, ARRAY_SIZE(wm9712_dai)); }
-static struct platform_driver wm9712_codec_driver = { +static struct platform_driver wm9712_component_driver = { .driver = { - .name = "wm9712-codec", + .name = "wm9712-component", },
.probe = wm9712_probe, - .remove = wm9712_remove, };
-module_platform_driver(wm9712_codec_driver); +module_platform_driver(wm9712_component_driver);
MODULE_DESCRIPTION("ASoC WM9711/WM9712 driver"); MODULE_AUTHOR("Liam Girdwood");
From: Kuninori Morimoto kuninori.morimoto.gx@renesas.com
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 -> .pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com --- sound/soc/codecs/wm9713.c | 201 ++++++++++++++++++++++------------------------ 1 file changed, 97 insertions(+), 104 deletions(-)
diff --git a/sound/soc/codecs/wm9713.c b/sound/soc/codecs/wm9713.c index df72206..04c93dd 100644 --- a/sound/soc/codecs/wm9713.c +++ b/sound/soc/codecs/wm9713.c @@ -196,16 +196,16 @@ static const DECLARE_TLV_DB_RANGE(mic_tlv, static int wm9713_voice_shutdown(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm);
if (WARN_ON(event != SND_SOC_DAPM_PRE_PMD)) return -EINVAL;
/* Gracefully shut down the voice interface. */ - snd_soc_update_bits(codec, AC97_HANDSET_RATE, 0x0f00, 0x0200); + snd_soc_component_update_bits(component, AC97_HANDSET_RATE, 0x0f00, 0x0200); schedule_timeout_interruptible(msecs_to_jiffies(1)); - snd_soc_update_bits(codec, AC97_HANDSET_RATE, 0x0f00, 0x0f00); - snd_soc_update_bits(codec, AC97_EXTENDED_MID, 0x1000, 0x1000); + snd_soc_component_update_bits(component, AC97_HANDSET_RATE, 0x0f00, 0x0f00); + snd_soc_component_update_bits(component, AC97_EXTENDED_MID, 0x1000, 0x1000);
return 0; } @@ -229,8 +229,8 @@ static int wm9713_hp_mixer_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { struct snd_soc_dapm_context *dapm = snd_soc_dapm_kcontrol_dapm(kcontrol); - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(dapm); - struct wm9713_priv *wm9713 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_dapm_to_component(dapm); + struct wm9713_priv *wm9713 = snd_soc_component_get_drvdata(component); unsigned int val = ucontrol->value.integer.value[0]; struct soc_mixer_control *mc = (struct soc_mixer_control *)kcontrol->private_value; @@ -273,8 +273,8 @@ static int wm9713_hp_mixer_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { struct snd_soc_dapm_context *dapm = snd_soc_dapm_kcontrol_dapm(kcontrol); - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(dapm); - struct wm9713_priv *wm9713 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_dapm_to_component(dapm); + struct wm9713_priv *wm9713 = snd_soc_component_get_drvdata(component); struct soc_mixer_control *mc = (struct soc_mixer_control *)kcontrol->private_value; unsigned int mixer, shift; @@ -753,7 +753,7 @@ struct _pll_div { * to allow rounding later */ #define FIXED_PLL_SIZE ((1 << 22) * 10)
-static void pll_factors(struct snd_soc_codec *codec, +static void pll_factors(struct snd_soc_component *component, struct _pll_div *pll_div, unsigned int source) { u64 Kpart; @@ -789,7 +789,7 @@ static void pll_factors(struct snd_soc_codec *codec,
Ndiv = target / source; if ((Ndiv < 5) || (Ndiv > 12)) - dev_warn(codec->dev, + dev_warn(component->dev, "WM9713 PLL N value %u out of recommended range!\n", Ndiv);
@@ -815,28 +815,28 @@ static void pll_factors(struct snd_soc_codec *codec, * Please note that changing the PLL input frequency may require * resynchronisation with the AC97 controller. */ -static int wm9713_set_pll(struct snd_soc_codec *codec, +static int wm9713_set_pll(struct snd_soc_component *component, int pll_id, unsigned int freq_in, unsigned int freq_out) { - struct wm9713_priv *wm9713 = snd_soc_codec_get_drvdata(codec); + struct wm9713_priv *wm9713 = snd_soc_component_get_drvdata(component); u16 reg, reg2; struct _pll_div pll_div;
/* turn PLL off ? */ if (freq_in == 0) { /* disable PLL power and select ext source */ - snd_soc_update_bits(codec, AC97_HANDSET_RATE, 0x0080, 0x0080); - snd_soc_update_bits(codec, AC97_EXTENDED_MID, 0x0200, 0x0200); + snd_soc_component_update_bits(component, AC97_HANDSET_RATE, 0x0080, 0x0080); + snd_soc_component_update_bits(component, AC97_EXTENDED_MID, 0x0200, 0x0200); wm9713->pll_in = 0; return 0; }
- pll_factors(codec, &pll_div, freq_in); + pll_factors(component, &pll_div, freq_in);
if (pll_div.k == 0) { reg = (pll_div.n << 12) | (pll_div.lf << 11) | (pll_div.divsel << 9) | (pll_div.divctl << 8); - snd_soc_write(codec, AC97_LINE1_LEVEL, reg); + snd_soc_component_write(component, AC97_LINE1_LEVEL, reg); } else { /* write the fractional k to the reg 0x46 pages */ reg2 = (pll_div.n << 12) | (pll_div.lf << 11) | (1 << 10) | @@ -844,31 +844,31 @@ static int wm9713_set_pll(struct snd_soc_codec *codec,
/* K [21:20] */ reg = reg2 | (0x5 << 4) | (pll_div.k >> 20); - snd_soc_write(codec, AC97_LINE1_LEVEL, reg); + snd_soc_component_write(component, AC97_LINE1_LEVEL, reg);
/* K [19:16] */ reg = reg2 | (0x4 << 4) | ((pll_div.k >> 16) & 0xf); - snd_soc_write(codec, AC97_LINE1_LEVEL, reg); + snd_soc_component_write(component, AC97_LINE1_LEVEL, reg);
/* K [15:12] */ reg = reg2 | (0x3 << 4) | ((pll_div.k >> 12) & 0xf); - snd_soc_write(codec, AC97_LINE1_LEVEL, reg); + snd_soc_component_write(component, AC97_LINE1_LEVEL, reg);
/* K [11:8] */ reg = reg2 | (0x2 << 4) | ((pll_div.k >> 8) & 0xf); - snd_soc_write(codec, AC97_LINE1_LEVEL, reg); + snd_soc_component_write(component, AC97_LINE1_LEVEL, reg);
/* K [7:4] */ reg = reg2 | (0x1 << 4) | ((pll_div.k >> 4) & 0xf); - snd_soc_write(codec, AC97_LINE1_LEVEL, reg); + snd_soc_component_write(component, AC97_LINE1_LEVEL, reg);
reg = reg2 | (0x0 << 4) | (pll_div.k & 0xf); /* K [3:0] */ - snd_soc_write(codec, AC97_LINE1_LEVEL, reg); + snd_soc_component_write(component, AC97_LINE1_LEVEL, reg); }
/* turn PLL on and select as source */ - snd_soc_update_bits(codec, AC97_EXTENDED_MID, 0x0200, 0x0000); - snd_soc_update_bits(codec, AC97_HANDSET_RATE, 0x0080, 0x0000); + snd_soc_component_update_bits(component, AC97_EXTENDED_MID, 0x0200, 0x0000); + snd_soc_component_update_bits(component, AC97_HANDSET_RATE, 0x0080, 0x0000); wm9713->pll_in = freq_in;
/* wait 10ms AC97 link frames for the link to stabilise */ @@ -879,8 +879,8 @@ static int wm9713_set_pll(struct snd_soc_codec *codec, static int wm9713_set_dai_pll(struct snd_soc_dai *codec_dai, int pll_id, int source, unsigned int freq_in, unsigned int freq_out) { - struct snd_soc_codec *codec = codec_dai->codec; - return wm9713_set_pll(codec, pll_id, freq_in, freq_out); + struct snd_soc_component *component = codec_dai->component; + return wm9713_set_pll(component, pll_id, freq_in, freq_out); }
/* @@ -890,10 +890,10 @@ static int wm9713_set_dai_pll(struct snd_soc_dai *codec_dai, int pll_id, static int wm9713_set_dai_tristate(struct snd_soc_dai *codec_dai, int tristate) { - struct snd_soc_codec *codec = codec_dai->codec; + struct snd_soc_component *component = codec_dai->component;
if (tristate) - snd_soc_update_bits(codec, AC97_CENTER_LFE_MASTER, + snd_soc_component_update_bits(component, AC97_CENTER_LFE_MASTER, 0x6000, 0x0000);
return 0; @@ -906,30 +906,30 @@ static int wm9713_set_dai_tristate(struct snd_soc_dai *codec_dai, static int wm9713_set_dai_clkdiv(struct snd_soc_dai *codec_dai, int div_id, int div) { - struct snd_soc_codec *codec = codec_dai->codec; + struct snd_soc_component *component = codec_dai->component;
switch (div_id) { case WM9713_PCMCLK_DIV: - snd_soc_update_bits(codec, AC97_HANDSET_RATE, 0x0f00, div); + snd_soc_component_update_bits(component, AC97_HANDSET_RATE, 0x0f00, div); break; case WM9713_CLKA_MULT: - snd_soc_update_bits(codec, AC97_HANDSET_RATE, 0x0002, div); + snd_soc_component_update_bits(component, AC97_HANDSET_RATE, 0x0002, div); break; case WM9713_CLKB_MULT: - snd_soc_update_bits(codec, AC97_HANDSET_RATE, 0x0004, div); + snd_soc_component_update_bits(component, AC97_HANDSET_RATE, 0x0004, div); break; case WM9713_HIFI_DIV: - snd_soc_update_bits(codec, AC97_HANDSET_RATE, 0x7000, div); + snd_soc_component_update_bits(component, AC97_HANDSET_RATE, 0x7000, div); break; case WM9713_PCMBCLK_DIV: - snd_soc_update_bits(codec, AC97_CENTER_LFE_MASTER, 0x0e00, div); + snd_soc_component_update_bits(component, AC97_CENTER_LFE_MASTER, 0x0e00, div); break; case WM9713_PCMCLK_PLL_DIV: - snd_soc_update_bits(codec, AC97_LINE1_LEVEL, + snd_soc_component_update_bits(component, AC97_LINE1_LEVEL, 0x007f, div | 0x60); break; case WM9713_HIFI_PLL_DIV: - snd_soc_update_bits(codec, AC97_LINE1_LEVEL, + snd_soc_component_update_bits(component, AC97_LINE1_LEVEL, 0x007f, div | 0x70); break; default: @@ -942,8 +942,8 @@ static int wm9713_set_dai_clkdiv(struct snd_soc_dai *codec_dai, static int wm9713_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt) { - struct snd_soc_codec *codec = codec_dai->codec; - u16 gpio = snd_soc_read(codec, AC97_GPIO_CFG) & 0xffc5; + struct snd_soc_component *component = codec_dai->component; + u16 gpio = snd_soc_component_read32(component, AC97_GPIO_CFG) & 0xffc5; u16 reg = 0x8000;
/* clock masters */ @@ -996,8 +996,8 @@ static int wm9713_set_dai_fmt(struct snd_soc_dai *codec_dai, break; }
- snd_soc_write(codec, AC97_GPIO_CFG, gpio); - snd_soc_write(codec, AC97_CENTER_LFE_MASTER, reg); + snd_soc_component_write(component, AC97_GPIO_CFG, gpio); + snd_soc_component_write(component, AC97_CENTER_LFE_MASTER, reg); return 0; }
@@ -1005,22 +1005,22 @@ static int wm9713_pcm_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; + struct snd_soc_component *component = dai->component;
/* enable PCM interface in master mode */ switch (params_width(params)) { case 16: break; case 20: - snd_soc_update_bits(codec, AC97_CENTER_LFE_MASTER, + snd_soc_component_update_bits(component, AC97_CENTER_LFE_MASTER, 0x000c, 0x0004); break; case 24: - snd_soc_update_bits(codec, AC97_CENTER_LFE_MASTER, + snd_soc_component_update_bits(component, AC97_CENTER_LFE_MASTER, 0x000c, 0x0008); break; case 32: - snd_soc_update_bits(codec, AC97_CENTER_LFE_MASTER, + snd_soc_component_update_bits(component, AC97_CENTER_LFE_MASTER, 0x000c, 0x000c); break; } @@ -1030,33 +1030,33 @@ static int wm9713_pcm_hw_params(struct snd_pcm_substream *substream, static int ac97_hifi_prepare(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; + struct snd_soc_component *component = dai->component; struct snd_pcm_runtime *runtime = substream->runtime; int reg;
- snd_soc_update_bits(codec, AC97_EXTENDED_STATUS, 0x0001, 0x0001); + snd_soc_component_update_bits(component, AC97_EXTENDED_STATUS, 0x0001, 0x0001);
if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) reg = AC97_PCM_FRONT_DAC_RATE; else reg = AC97_PCM_LR_ADC_RATE;
- return snd_soc_write(codec, reg, runtime->rate); + return snd_soc_component_write(component, reg, runtime->rate); }
static int ac97_aux_prepare(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; + struct snd_soc_component *component = dai->component; struct snd_pcm_runtime *runtime = substream->runtime;
- snd_soc_update_bits(codec, AC97_EXTENDED_STATUS, 0x0001, 0x0001); - snd_soc_update_bits(codec, AC97_PCI_SID, 0x8000, 0x8000); + snd_soc_component_update_bits(component, AC97_EXTENDED_STATUS, 0x0001, 0x0001); + snd_soc_component_update_bits(component, AC97_PCI_SID, 0x8000, 0x8000);
if (substream->stream != SNDRV_PCM_STREAM_PLAYBACK) return -ENODEV;
- return snd_soc_write(codec, AC97_PCM_SURR_DAC_RATE, runtime->rate); + return snd_soc_component_write(component, AC97_PCM_SURR_DAC_RATE, runtime->rate); }
#define WM9713_RATES (SNDRV_PCM_RATE_8000 | \ @@ -1142,48 +1142,48 @@ static int ac97_aux_prepare(struct snd_pcm_substream *substream, }, };
-static int wm9713_set_bias_level(struct snd_soc_codec *codec, +static int wm9713_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { switch (level) { case SND_SOC_BIAS_ON: /* enable thermal shutdown */ - snd_soc_update_bits(codec, AC97_EXTENDED_MID, 0xe400, 0x0000); + snd_soc_component_update_bits(component, AC97_EXTENDED_MID, 0xe400, 0x0000); break; case SND_SOC_BIAS_PREPARE: break; case SND_SOC_BIAS_STANDBY: /* enable master bias and vmid */ - snd_soc_update_bits(codec, AC97_EXTENDED_MID, 0xc400, 0x0000); - snd_soc_write(codec, AC97_POWERDOWN, 0x0000); + snd_soc_component_update_bits(component, AC97_EXTENDED_MID, 0xc400, 0x0000); + snd_soc_component_write(component, AC97_POWERDOWN, 0x0000); break; case SND_SOC_BIAS_OFF: /* disable everything including AC link */ - snd_soc_write(codec, AC97_EXTENDED_MID, 0xffff); - snd_soc_write(codec, AC97_EXTENDED_MSTATUS, 0xffff); - snd_soc_write(codec, AC97_POWERDOWN, 0xffff); + snd_soc_component_write(component, AC97_EXTENDED_MID, 0xffff); + snd_soc_component_write(component, AC97_EXTENDED_MSTATUS, 0xffff); + snd_soc_component_write(component, AC97_POWERDOWN, 0xffff); break; } return 0; }
-static int wm9713_soc_suspend(struct snd_soc_codec *codec) +static int wm9713_soc_suspend(struct snd_soc_component *component) { /* Disable everything except touchpanel - that will be handled * by the touch driver and left disabled if touch is not in * use. */ - snd_soc_update_bits(codec, AC97_EXTENDED_MID, 0x7fff, + snd_soc_component_update_bits(component, AC97_EXTENDED_MID, 0x7fff, 0x7fff); - snd_soc_write(codec, AC97_EXTENDED_MSTATUS, 0xffff); - snd_soc_write(codec, AC97_POWERDOWN, 0x6f00); - snd_soc_write(codec, AC97_POWERDOWN, 0xffff); + snd_soc_component_write(component, AC97_EXTENDED_MSTATUS, 0xffff); + snd_soc_component_write(component, AC97_POWERDOWN, 0x6f00); + snd_soc_component_write(component, AC97_POWERDOWN, 0xffff);
return 0; }
-static int wm9713_soc_resume(struct snd_soc_codec *codec) +static int wm9713_soc_resume(struct snd_soc_component *component) { - struct wm9713_priv *wm9713 = snd_soc_codec_get_drvdata(codec); + struct wm9713_priv *wm9713 = snd_soc_component_get_drvdata(component); int ret;
ret = snd_ac97_reset(wm9713->ac97, true, WM9713_VENDOR_ID, @@ -1191,24 +1191,24 @@ static int wm9713_soc_resume(struct snd_soc_codec *codec) if (ret < 0) return ret;
- snd_soc_codec_force_bias_level(codec, SND_SOC_BIAS_STANDBY); + snd_soc_component_force_bias_level(component, SND_SOC_BIAS_STANDBY);
/* do we need to re-start the PLL ? */ if (wm9713->pll_in) - wm9713_set_pll(codec, 0, wm9713->pll_in, 0); + wm9713_set_pll(component, 0, wm9713->pll_in, 0);
/* only synchronise the codec if warm reset failed */ if (ret == 0) { - regcache_mark_dirty(codec->component.regmap); - snd_soc_cache_sync(codec); + regcache_mark_dirty(component->regmap); + snd_soc_component_cache_sync(component); }
return ret; }
-static int wm9713_soc_probe(struct snd_soc_codec *codec) +static int wm9713_soc_probe(struct snd_soc_component *component) { - struct wm9713_priv *wm9713 = snd_soc_codec_get_drvdata(codec); + struct wm9713_priv *wm9713 = snd_soc_component_get_drvdata(component); struct regmap *regmap = NULL;
if (wm9713->mfd_pdata) { @@ -1216,54 +1216,54 @@ static int wm9713_soc_probe(struct snd_soc_codec *codec) regmap = wm9713->mfd_pdata->regmap; } else { #ifdef CONFIG_SND_SOC_AC97_BUS - wm9713->ac97 = snd_soc_new_ac97_codec(codec, WM9713_VENDOR_ID, + wm9713->ac97 = snd_soc_new_ac97_component(component, WM9713_VENDOR_ID, WM9713_VENDOR_ID_MASK); if (IS_ERR(wm9713->ac97)) return PTR_ERR(wm9713->ac97); regmap = regmap_init_ac97(wm9713->ac97, &wm9713_regmap_config); if (IS_ERR(regmap)) { - snd_soc_free_ac97_codec(wm9713->ac97); + snd_soc_free_ac97_component(wm9713->ac97); return PTR_ERR(regmap); } #endif }
- snd_soc_codec_init_regmap(codec, regmap); + snd_soc_component_init_regmap(component, regmap);
/* unmute the adc - move to kcontrol */ - snd_soc_update_bits(codec, AC97_CD, 0x7fff, 0x0000); + snd_soc_component_update_bits(component, AC97_CD, 0x7fff, 0x0000);
return 0; }
-static int wm9713_soc_remove(struct snd_soc_codec *codec) +static void wm9713_soc_remove(struct snd_soc_component *component) { #ifdef CONFIG_SND_SOC_AC97_BUS - struct wm9713_priv *wm9713 = snd_soc_codec_get_drvdata(codec); + struct wm9713_priv *wm9713 = snd_soc_component_get_drvdata(component);
if (!wm9713->mfd_pdata) { - snd_soc_codec_exit_regmap(codec); - snd_soc_free_ac97_codec(wm9713->ac97); + snd_soc_component_exit_regmap(component); + snd_soc_free_ac97_component(wm9713->ac97); } #endif - return 0; }
-static const struct snd_soc_codec_driver soc_codec_dev_wm9713 = { - .probe = wm9713_soc_probe, - .remove = wm9713_soc_remove, - .suspend = wm9713_soc_suspend, - .resume = wm9713_soc_resume, - .set_bias_level = wm9713_set_bias_level, - - .component_driver = { - .controls = wm9713_snd_ac97_controls, - .num_controls = ARRAY_SIZE(wm9713_snd_ac97_controls), - .dapm_widgets = wm9713_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(wm9713_dapm_widgets), - .dapm_routes = wm9713_audio_map, - .num_dapm_routes = ARRAY_SIZE(wm9713_audio_map), - }, +static const struct snd_soc_component_driver soc_component_dev_wm9713 = { + .probe = wm9713_soc_probe, + .remove = wm9713_soc_remove, + .suspend = wm9713_soc_suspend, + .resume = wm9713_soc_resume, + .set_bias_level = wm9713_set_bias_level, + .controls = wm9713_snd_ac97_controls, + .num_controls = ARRAY_SIZE(wm9713_snd_ac97_controls), + .dapm_widgets = wm9713_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(wm9713_dapm_widgets), + .dapm_routes = wm9713_audio_map, + .num_dapm_routes = ARRAY_SIZE(wm9713_audio_map), + .idle_bias_on = 1, + .pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, };
static int wm9713_probe(struct platform_device *pdev) @@ -1279,14 +1279,8 @@ static int wm9713_probe(struct platform_device *pdev) wm9713->mfd_pdata = dev_get_platdata(&pdev->dev); platform_set_drvdata(pdev, wm9713);
- return snd_soc_register_codec(&pdev->dev, - &soc_codec_dev_wm9713, wm9713_dai, ARRAY_SIZE(wm9713_dai)); -} - -static int wm9713_remove(struct platform_device *pdev) -{ - snd_soc_unregister_codec(&pdev->dev); - return 0; + return devm_snd_soc_register_component(&pdev->dev, + &soc_component_dev_wm9713, wm9713_dai, ARRAY_SIZE(wm9713_dai)); }
static struct platform_driver wm9713_codec_driver = { @@ -1295,7 +1289,6 @@ static int wm9713_remove(struct platform_device *pdev) },
.probe = wm9713_probe, - .remove = wm9713_remove, };
module_platform_driver(wm9713_codec_driver);
From: Kuninori Morimoto kuninori.morimoto.gx@renesas.com
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 -> .pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com --- sound/soc/codecs/max9867.c | 65 +++++++++++++++++++++------------------------- sound/soc/codecs/max9867.h | 2 +- 2 files changed, 31 insertions(+), 36 deletions(-)
diff --git a/sound/soc/codecs/max9867.c b/sound/soc/codecs/max9867.c index 2f60924..2b96ebc 100644 --- a/sound/soc/codecs/max9867.c +++ b/sound/soc/codecs/max9867.c @@ -179,8 +179,8 @@ static inline int get_ni_value(int mclk, int rate) static int max9867_dai_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; - struct max9867_priv *max9867 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct max9867_priv *max9867 = snd_soc_component_get_drvdata(component); unsigned int ni_h, ni_l; int value;
@@ -227,7 +227,7 @@ static int max9867_dai_hw_params(struct snd_pcm_substream *substream, bclk_value = MAX9867_IFC1B_PCLK_16; break; default: - dev_err(codec->dev, + dev_err(component->dev, "unsupported sampling rate\n"); return -EINVAL; } @@ -239,7 +239,7 @@ static int max9867_dai_hw_params(struct snd_pcm_substream *substream, bclk_value = MAX9867_IFC1B_32BIT; break; default: - dev_err(codec->dev, "unsupported sampling rate\n"); + dev_err(component->dev, "unsupported sampling rate\n"); return -EINVAL; } regmap_update_bits(max9867->regmap, MAX9867_IFC1B, @@ -251,8 +251,8 @@ static int max9867_dai_hw_params(struct snd_pcm_substream *substream, static int max9867_prepare(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; - struct max9867_priv *max9867 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct max9867_priv *max9867 = snd_soc_component_get_drvdata(component);
regmap_update_bits(max9867->regmap, MAX9867_PWRMAN, MAX9867_SHTDOWN_MASK, MAX9867_SHTDOWN_MASK); @@ -261,8 +261,8 @@ static int max9867_prepare(struct snd_pcm_substream *substream,
static int max9867_mute(struct snd_soc_dai *dai, int mute) { - struct snd_soc_codec *codec = dai->codec; - struct max9867_priv *max9867 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct max9867_priv *max9867 = snd_soc_component_get_drvdata(component);
if (mute) regmap_update_bits(max9867->regmap, MAX9867_DACLEVEL, @@ -276,8 +276,8 @@ static int max9867_mute(struct snd_soc_dai *dai, int mute) static int max9867_set_dai_sysclk(struct snd_soc_dai *codec_dai, int clk_id, unsigned int freq, int dir) { - struct snd_soc_codec *codec = codec_dai->codec; - struct max9867_priv *max9867 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = codec_dai->component; + struct max9867_priv *max9867 = snd_soc_component_get_drvdata(component); int value = 0;
/* Set the prescaler based on the master clock frequency*/ @@ -306,8 +306,8 @@ static int max9867_set_dai_sysclk(struct snd_soc_dai *codec_dai, static int max9867_dai_set_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt) { - struct snd_soc_codec *codec = codec_dai->codec; - struct max9867_priv *max9867 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = codec_dai->component; + struct max9867_priv *max9867 = snd_soc_component_get_drvdata(component); u8 iface1A = 0, iface1B = 0;
switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { @@ -404,25 +404,27 @@ static int max9867_resume(struct device *dev) } #endif
-static int max9867_probe(struct snd_soc_codec *codec) +static int max9867_probe(struct snd_soc_component *component) { - struct max9867_priv *max9867 = snd_soc_codec_get_drvdata(codec); + struct max9867_priv *max9867 = snd_soc_component_get_drvdata(component);
- dev_dbg(codec->dev, "max98090_probe\n"); - max9867->codec = codec; + dev_dbg(component->dev, "max98090_probe\n"); + max9867->component = component; return 0; }
-static const struct snd_soc_codec_driver max9867_codec = { - .probe = max9867_probe, - .component_driver = { - .controls = max9867_snd_controls, - .num_controls = ARRAY_SIZE(max9867_snd_controls), - .dapm_routes = max9867_audio_map, - .num_dapm_routes = ARRAY_SIZE(max9867_audio_map), - .dapm_widgets = max9867_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(max9867_dapm_widgets), - }, +static const struct snd_soc_component_driver max9867_component = { + .probe = max9867_probe, + .controls = max9867_snd_controls, + .num_controls = ARRAY_SIZE(max9867_snd_controls), + .dapm_routes = max9867_audio_map, + .num_dapm_routes = ARRAY_SIZE(max9867_audio_map), + .dapm_widgets = max9867_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(max9867_dapm_widgets), + .idle_bias_on = 1, + .pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, };
static bool max9867_volatile_register(struct device *dev, unsigned int reg) @@ -497,21 +499,15 @@ static int max9867_i2c_probe(struct i2c_client *i2c, return ret; } dev_info(&i2c->dev, "device revision: %x\n", reg); - ret = snd_soc_register_codec(&i2c->dev, &max9867_codec, + ret = devm_snd_soc_register_component(&i2c->dev, &max9867_component, max9867_dai, ARRAY_SIZE(max9867_dai)); if (ret < 0) { - dev_err(&i2c->dev, "Failed to register codec: %d\n", ret); + dev_err(&i2c->dev, "Failed to register component: %d\n", ret); return ret; } return ret; }
-static int max9867_i2c_remove(struct i2c_client *client) -{ - snd_soc_unregister_codec(&client->dev); - return 0; -} - static const struct i2c_device_id max9867_i2c_id[] = { { "max9867", 0 }, { } @@ -535,7 +531,6 @@ static int max9867_i2c_remove(struct i2c_client *client) .pm = &max9867_pm_ops, }, .probe = max9867_i2c_probe, - .remove = max9867_i2c_remove, .id_table = max9867_i2c_id, };
diff --git a/sound/soc/codecs/max9867.h b/sound/soc/codecs/max9867.h index 65590b4..c0aea3d 100644 --- a/sound/soc/codecs/max9867.h +++ b/sound/soc/codecs/max9867.h @@ -75,7 +75,7 @@ /* codec private data */ struct max9867_priv { struct regmap *regmap; - struct snd_soc_codec *codec; + struct snd_soc_component *component; unsigned int sysclk; unsigned int pclk; unsigned int master;
From: Kuninori Morimoto kuninori.morimoto.gx@renesas.com
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 -> .pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com --- sound/soc/codecs/wm1250-ev1.c | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-)
diff --git a/sound/soc/codecs/wm1250-ev1.c b/sound/soc/codecs/wm1250-ev1.c index cf5f058..ca826eb 100644 --- a/sound/soc/codecs/wm1250-ev1.c +++ b/sound/soc/codecs/wm1250-ev1.c @@ -32,10 +32,10 @@ struct wm1250_priv { struct gpio gpios[WM1250_EV1_NUM_GPIOS]; };
-static int wm1250_ev1_set_bias_level(struct snd_soc_codec *codec, +static int wm1250_ev1_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { - struct wm1250_priv *wm1250 = dev_get_drvdata(codec->dev); + struct wm1250_priv *wm1250 = dev_get_drvdata(component->dev); int ena;
if (wm1250) @@ -81,7 +81,7 @@ static int wm1250_ev1_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) { - struct wm1250_priv *wm1250 = snd_soc_codec_get_drvdata(dai->codec); + struct wm1250_priv *wm1250 = snd_soc_component_get_drvdata(dai->component);
switch (params_rate(params)) { case 8000: @@ -141,15 +141,15 @@ static int wm1250_ev1_hw_params(struct snd_pcm_substream *substream, .ops = &wm1250_ev1_ops, };
-static const struct snd_soc_codec_driver soc_codec_dev_wm1250_ev1 = { - .component_driver = { - .dapm_widgets = wm1250_ev1_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(wm1250_ev1_dapm_widgets), - .dapm_routes = wm1250_ev1_dapm_routes, - .num_dapm_routes = ARRAY_SIZE(wm1250_ev1_dapm_routes), - }, - .set_bias_level = wm1250_ev1_set_bias_level, - .idle_bias_off = true, +static const struct snd_soc_component_driver soc_component_dev_wm1250_ev1 = { + .dapm_widgets = wm1250_ev1_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(wm1250_ev1_dapm_widgets), + .dapm_routes = wm1250_ev1_dapm_routes, + .num_dapm_routes = ARRAY_SIZE(wm1250_ev1_dapm_routes), + .set_bias_level = wm1250_ev1_set_bias_level, + .pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, };
static int wm1250_ev1_pdata(struct i2c_client *i2c) @@ -224,7 +224,7 @@ static int wm1250_ev1_probe(struct i2c_client *i2c, if (ret != 0) return ret;
- ret = snd_soc_register_codec(&i2c->dev, &soc_codec_dev_wm1250_ev1, + ret = devm_snd_soc_register_component(&i2c->dev, &soc_component_dev_wm1250_ev1, &wm1250_ev1_dai, 1); if (ret != 0) { dev_err(&i2c->dev, "Failed to register CODEC: %d\n", ret); @@ -237,7 +237,6 @@ static int wm1250_ev1_probe(struct i2c_client *i2c,
static int wm1250_ev1_remove(struct i2c_client *i2c) { - snd_soc_unregister_codec(&i2c->dev); wm1250_ev1_free(i2c);
return 0;
From: Kuninori Morimoto kuninori.morimoto.gx@renesas.com
Now we can replace Codec to Component. Let's do it.
Becase wm8993/wm8994/wm8958 are using wm_hubs feature, we need to update these all related drivers in same time. Otherwise compile error/warning happen
wm8993: xxx_codec_xxx() -> xxx_component_xxx() .idle_bias_off = 0 -> .idle_bias_on = 1 .ignore_pmdown_time = 0 -> .pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1
wm8994: xxx_codec_xxx() -> xxx_component_xxx() .idle_bias_off = 0 -> .idle_bias_on = 1 .ignore_pmdown_time = 0 -> .pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com --- sound/soc/codecs/wm8958-dsp2.c | 278 +++++++------- sound/soc/codecs/wm8993.c | 237 ++++++------ sound/soc/codecs/wm8994.c | 810 +++++++++++++++++++++-------------------- sound/soc/codecs/wm8994.h | 8 +- sound/soc/codecs/wm_hubs.c | 254 ++++++------- sound/soc/codecs/wm_hubs.h | 18 +- sound/soc/samsung/littlemill.c | 8 +- 7 files changed, 809 insertions(+), 804 deletions(-)
diff --git a/sound/soc/codecs/wm8958-dsp2.c b/sound/soc/codecs/wm8958-dsp2.c index 6b864c0..8d49522 100644 --- a/sound/soc/codecs/wm8958-dsp2.c +++ b/sound/soc/codecs/wm8958-dsp2.c @@ -39,10 +39,10 @@ #define WM_FW_BLOCK_A 0x08 #define WM_FW_BLOCK_C 0x0c
-static int wm8958_dsp2_fw(struct snd_soc_codec *codec, const char *name, +static int wm8958_dsp2_fw(struct snd_soc_component *component, const char *name, const struct firmware *fw, bool check) { - struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec); + struct wm8994_priv *wm8994 = snd_soc_component_get_drvdata(component); u64 data64; u32 data32; const u8 *data; @@ -55,7 +55,7 @@ static int wm8958_dsp2_fw(struct snd_soc_codec *codec, const char *name, return 0;
if (fw->size < 32) { - dev_err(codec->dev, "%s: firmware too short (%zd bytes)\n", + dev_err(component->dev, "%s: firmware too short (%zd bytes)\n", name, fw->size); goto err; } @@ -63,7 +63,7 @@ static int wm8958_dsp2_fw(struct snd_soc_codec *codec, const char *name, if (memcmp(fw->data, "WMFW", 4) != 0) { memcpy(&data32, fw->data, sizeof(data32)); data32 = be32_to_cpu(data32); - dev_err(codec->dev, "%s: firmware has bad file magic %08x\n", + dev_err(component->dev, "%s: firmware has bad file magic %08x\n", name, data32); goto err; } @@ -74,35 +74,35 @@ static int wm8958_dsp2_fw(struct snd_soc_codec *codec, const char *name, memcpy(&data32, fw->data + 8, sizeof(data32)); data32 = be32_to_cpu(data32); if ((data32 >> 24) & 0xff) { - dev_err(codec->dev, "%s: unsupported firmware version %d\n", + dev_err(component->dev, "%s: unsupported firmware version %d\n", name, (data32 >> 24) & 0xff); goto err; } if ((data32 & 0xffff) != 8958) { - dev_err(codec->dev, "%s: unsupported target device %d\n", + dev_err(component->dev, "%s: unsupported target device %d\n", name, data32 & 0xffff); goto err; } if (((data32 >> 16) & 0xff) != 0xc) { - dev_err(codec->dev, "%s: unsupported target core %d\n", + dev_err(component->dev, "%s: unsupported target core %d\n", name, (data32 >> 16) & 0xff); goto err; }
if (check) { memcpy(&data64, fw->data + 24, sizeof(u64)); - dev_info(codec->dev, "%s timestamp %llx\n", + dev_info(component->dev, "%s timestamp %llx\n", name, be64_to_cpu(data64)); } else { - snd_soc_write(codec, 0x102, 0x2); - snd_soc_write(codec, 0x900, 0x2); + snd_soc_component_write(component, 0x102, 0x2); + snd_soc_component_write(component, 0x900, 0x2); }
data = fw->data + len; len = fw->size - len; while (len) { if (len < 12) { - dev_err(codec->dev, "%s short data block of %zd\n", + dev_err(component->dev, "%s short data block of %zd\n", name, len); goto err; } @@ -110,12 +110,12 @@ static int wm8958_dsp2_fw(struct snd_soc_codec *codec, const char *name, memcpy(&data32, data + 4, sizeof(data32)); block_len = be32_to_cpu(data32); if (block_len + 8 > len) { - dev_err(codec->dev, "%zd byte block longer than file\n", + dev_err(component->dev, "%zd byte block longer than file\n", block_len); goto err; } if (block_len == 0) { - dev_err(codec->dev, "Zero length block\n"); + dev_err(component->dev, "Zero length block\n"); goto err; }
@@ -131,10 +131,10 @@ static int wm8958_dsp2_fw(struct snd_soc_codec *codec, const char *name, str = kzalloc(block_len + 1, GFP_KERNEL); if (str) { memcpy(str, data + 8, block_len); - dev_info(codec->dev, "%s: %s\n", name, str); + dev_info(component->dev, "%s: %s\n", name, str); kfree(str); } else { - dev_err(codec->dev, "Out of memory\n"); + dev_err(component->dev, "Out of memory\n"); } break; case WM_FW_BLOCK_PM: @@ -144,7 +144,7 @@ static int wm8958_dsp2_fw(struct snd_soc_codec *codec, const char *name, case WM_FW_BLOCK_I: case WM_FW_BLOCK_A: case WM_FW_BLOCK_C: - dev_dbg(codec->dev, "%s: %zd bytes of %x@%x\n", name, + dev_dbg(component->dev, "%s: %zd bytes of %x@%x\n", name, block_len, (data32 >> 24) & 0xff, data32 & 0xffffff);
@@ -160,7 +160,7 @@ static int wm8958_dsp2_fw(struct snd_soc_codec *codec, const char *name,
break; default: - dev_warn(codec->dev, "%s: unknown block type %d\n", + dev_warn(component->dev, "%s: unknown block type %d\n", name, (data32 >> 24) & 0xff); break; } @@ -173,10 +173,10 @@ static int wm8958_dsp2_fw(struct snd_soc_codec *codec, const char *name, }
if (!check) { - dev_dbg(codec->dev, "%s: download done\n", name); + dev_dbg(component->dev, "%s: download done\n", name); wm8994->cur_fw = fw; } else { - dev_info(codec->dev, "%s: got firmware\n", name); + dev_info(component->dev, "%s: got firmware\n", name); }
goto ok; @@ -185,28 +185,28 @@ static int wm8958_dsp2_fw(struct snd_soc_codec *codec, const char *name, ret = -EINVAL; ok: if (!check) { - snd_soc_write(codec, 0x900, 0x0); - snd_soc_write(codec, 0x102, 0x0); + snd_soc_component_write(component, 0x900, 0x0); + snd_soc_component_write(component, 0x102, 0x0); }
return ret; }
-static void wm8958_dsp_start_mbc(struct snd_soc_codec *codec, int path) +static void wm8958_dsp_start_mbc(struct snd_soc_component *component, int path) { - struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec); + struct wm8994_priv *wm8994 = snd_soc_component_get_drvdata(component); struct wm8994 *control = wm8994->wm8994; int i;
/* If the DSP is already running then noop */ - if (snd_soc_read(codec, WM8958_DSP2_PROGRAM) & WM8958_DSP2_ENA) + if (snd_soc_component_read32(component, WM8958_DSP2_PROGRAM) & WM8958_DSP2_ENA) return;
/* If we have MBC firmware download it */ if (wm8994->mbc) - wm8958_dsp2_fw(codec, "MBC", wm8994->mbc, false); + wm8958_dsp2_fw(component, "MBC", wm8994->mbc, false);
- snd_soc_update_bits(codec, WM8958_DSP2_PROGRAM, + snd_soc_component_update_bits(component, WM8958_DSP2_PROGRAM, WM8958_DSP2_ENA, WM8958_DSP2_ENA);
/* If we've got user supplied MBC settings use them */ @@ -215,37 +215,37 @@ static void wm8958_dsp_start_mbc(struct snd_soc_codec *codec, int path) = &control->pdata.mbc_cfgs[wm8994->mbc_cfg];
for (i = 0; i < ARRAY_SIZE(cfg->coeff_regs); i++) - snd_soc_write(codec, i + WM8958_MBC_BAND_1_K_1, + snd_soc_component_write(component, i + WM8958_MBC_BAND_1_K_1, cfg->coeff_regs[i]);
for (i = 0; i < ARRAY_SIZE(cfg->cutoff_regs); i++) - snd_soc_write(codec, + snd_soc_component_write(component, i + WM8958_MBC_BAND_2_LOWER_CUTOFF_C1_1, cfg->cutoff_regs[i]); }
/* Run the DSP */ - snd_soc_write(codec, WM8958_DSP2_EXECCONTROL, + snd_soc_component_write(component, WM8958_DSP2_EXECCONTROL, WM8958_DSP2_RUNR);
/* And we're off! */ - snd_soc_update_bits(codec, WM8958_DSP2_CONFIG, + snd_soc_component_update_bits(component, WM8958_DSP2_CONFIG, WM8958_MBC_ENA | WM8958_MBC_SEL_MASK, path << WM8958_MBC_SEL_SHIFT | WM8958_MBC_ENA); }
-static void wm8958_dsp_start_vss(struct snd_soc_codec *codec, int path) +static void wm8958_dsp_start_vss(struct snd_soc_component *component, int path) { - struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec); + struct wm8994_priv *wm8994 = snd_soc_component_get_drvdata(component); struct wm8994 *control = wm8994->wm8994; int i, ena;
if (wm8994->mbc_vss) - wm8958_dsp2_fw(codec, "MBC+VSS", wm8994->mbc_vss, false); + wm8958_dsp2_fw(component, "MBC+VSS", wm8994->mbc_vss, false);
- snd_soc_update_bits(codec, WM8958_DSP2_PROGRAM, + snd_soc_component_update_bits(component, WM8958_DSP2_PROGRAM, WM8958_DSP2_ENA, WM8958_DSP2_ENA);
/* If we've got user supplied settings use them */ @@ -254,7 +254,7 @@ static void wm8958_dsp_start_vss(struct snd_soc_codec *codec, int path) = &control->pdata.mbc_cfgs[wm8994->mbc_cfg];
for (i = 0; i < ARRAY_SIZE(cfg->combined_regs); i++) - snd_soc_write(codec, i + 0x2800, + snd_soc_component_write(component, i + 0x2800, cfg->combined_regs[i]); }
@@ -263,7 +263,7 @@ static void wm8958_dsp_start_vss(struct snd_soc_codec *codec, int path) = &control->pdata.vss_cfgs[wm8994->vss_cfg];
for (i = 0; i < ARRAY_SIZE(cfg->regs); i++) - snd_soc_write(codec, i + 0x2600, cfg->regs[i]); + snd_soc_component_write(component, i + 0x2600, cfg->regs[i]); }
if (control->pdata.num_vss_hpf_cfgs) { @@ -271,11 +271,11 @@ static void wm8958_dsp_start_vss(struct snd_soc_codec *codec, int path) = &control->pdata.vss_hpf_cfgs[wm8994->vss_hpf_cfg];
for (i = 0; i < ARRAY_SIZE(cfg->regs); i++) - snd_soc_write(codec, i + 0x2400, cfg->regs[i]); + snd_soc_component_write(component, i + 0x2400, cfg->regs[i]); }
/* Run the DSP */ - snd_soc_write(codec, WM8958_DSP2_EXECCONTROL, + snd_soc_component_write(component, WM8958_DSP2_EXECCONTROL, WM8958_DSP2_RUNR);
/* Enable the algorithms we've selected */ @@ -289,23 +289,23 @@ static void wm8958_dsp_start_vss(struct snd_soc_codec *codec, int path) if (wm8994->vss_ena[path]) ena |= 0x1;
- snd_soc_write(codec, 0x2201, ena); + snd_soc_component_write(component, 0x2201, ena);
/* Switch the DSP into the data path */ - snd_soc_update_bits(codec, WM8958_DSP2_CONFIG, + snd_soc_component_update_bits(component, WM8958_DSP2_CONFIG, WM8958_MBC_SEL_MASK | WM8958_MBC_ENA, path << WM8958_MBC_SEL_SHIFT | WM8958_MBC_ENA); }
-static void wm8958_dsp_start_enh_eq(struct snd_soc_codec *codec, int path) +static void wm8958_dsp_start_enh_eq(struct snd_soc_component *component, int path) { - struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec); + struct wm8994_priv *wm8994 = snd_soc_component_get_drvdata(component); struct wm8994 *control = wm8994->wm8994; int i;
- wm8958_dsp2_fw(codec, "ENH_EQ", wm8994->enh_eq, false); + wm8958_dsp2_fw(component, "ENH_EQ", wm8994->enh_eq, false);
- snd_soc_update_bits(codec, WM8958_DSP2_PROGRAM, + snd_soc_component_update_bits(component, WM8958_DSP2_PROGRAM, WM8958_DSP2_ENA, WM8958_DSP2_ENA);
/* If we've got user supplied settings use them */ @@ -314,24 +314,24 @@ static void wm8958_dsp_start_enh_eq(struct snd_soc_codec *codec, int path) = &control->pdata.enh_eq_cfgs[wm8994->enh_eq_cfg];
for (i = 0; i < ARRAY_SIZE(cfg->regs); i++) - snd_soc_write(codec, i + 0x2200, + snd_soc_component_write(component, i + 0x2200, cfg->regs[i]); }
/* Run the DSP */ - snd_soc_write(codec, WM8958_DSP2_EXECCONTROL, + snd_soc_component_write(component, WM8958_DSP2_EXECCONTROL, WM8958_DSP2_RUNR);
/* Switch the DSP into the data path */ - snd_soc_update_bits(codec, WM8958_DSP2_CONFIG, + snd_soc_component_update_bits(component, WM8958_DSP2_CONFIG, WM8958_MBC_SEL_MASK | WM8958_MBC_ENA, path << WM8958_MBC_SEL_SHIFT | WM8958_MBC_ENA); }
-static void wm8958_dsp_apply(struct snd_soc_codec *codec, int path, int start) +static void wm8958_dsp_apply(struct snd_soc_component *component, int path, int start) { - struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec); - int pwr_reg = snd_soc_read(codec, WM8994_POWER_MANAGEMENT_5); + struct wm8994_priv *wm8994 = snd_soc_component_get_drvdata(component); + int pwr_reg = snd_soc_component_read32(component, WM8994_POWER_MANAGEMENT_5); int ena, reg, aif;
switch (path) { @@ -359,9 +359,9 @@ static void wm8958_dsp_apply(struct snd_soc_codec *codec, int path, int start) if (!pwr_reg) ena = 0;
- reg = snd_soc_read(codec, WM8958_DSP2_PROGRAM); + reg = snd_soc_component_read32(component, WM8958_DSP2_PROGRAM);
- dev_dbg(codec->dev, "DSP path %d %d startup: %d, power: %x, DSP: %x\n", + dev_dbg(component->dev, "DSP path %d %d startup: %d, power: %x, DSP: %x\n", path, wm8994->dsp_active, start, pwr_reg, reg);
if (start && ena) { @@ -370,29 +370,29 @@ static void wm8958_dsp_apply(struct snd_soc_codec *codec, int path, int start) return;
/* If either AIFnCLK is not yet enabled postpone */ - if (!(snd_soc_read(codec, WM8994_AIF1_CLOCKING_1) + if (!(snd_soc_component_read32(component, WM8994_AIF1_CLOCKING_1) & WM8994_AIF1CLK_ENA_MASK) && - !(snd_soc_read(codec, WM8994_AIF2_CLOCKING_1) + !(snd_soc_component_read32(component, WM8994_AIF2_CLOCKING_1) & WM8994_AIF2CLK_ENA_MASK)) return;
/* Switch the clock over to the appropriate AIF */ - snd_soc_update_bits(codec, WM8994_CLOCKING_1, + snd_soc_component_update_bits(component, WM8994_CLOCKING_1, WM8958_DSP2CLK_SRC | WM8958_DSP2CLK_ENA, aif << WM8958_DSP2CLK_SRC_SHIFT | WM8958_DSP2CLK_ENA);
if (wm8994->enh_eq_ena[path]) - wm8958_dsp_start_enh_eq(codec, path); + wm8958_dsp_start_enh_eq(component, path); else if (wm8994->vss_ena[path] || wm8994->hpf1_ena[path] || wm8994->hpf2_ena[path]) - wm8958_dsp_start_vss(codec, path); + wm8958_dsp_start_vss(component, path); else if (wm8994->mbc_ena[path]) - wm8958_dsp_start_mbc(codec, path); + wm8958_dsp_start_mbc(component, path);
wm8994->dsp_active = path;
- dev_dbg(codec->dev, "DSP running in path %d\n", path); + dev_dbg(component->dev, "DSP running in path %d\n", path); }
if (!start && wm8994->dsp_active == path) { @@ -400,37 +400,37 @@ static void wm8958_dsp_apply(struct snd_soc_codec *codec, int path, int start) if (!(reg & WM8958_DSP2_ENA)) return;
- snd_soc_update_bits(codec, WM8958_DSP2_CONFIG, + snd_soc_component_update_bits(component, WM8958_DSP2_CONFIG, WM8958_MBC_ENA, 0); - snd_soc_write(codec, WM8958_DSP2_EXECCONTROL, + snd_soc_component_write(component, WM8958_DSP2_EXECCONTROL, WM8958_DSP2_STOP); - snd_soc_update_bits(codec, WM8958_DSP2_PROGRAM, + snd_soc_component_update_bits(component, WM8958_DSP2_PROGRAM, WM8958_DSP2_ENA, 0); - snd_soc_update_bits(codec, WM8994_CLOCKING_1, + snd_soc_component_update_bits(component, WM8994_CLOCKING_1, WM8958_DSP2CLK_ENA, 0);
wm8994->dsp_active = -1;
- dev_dbg(codec->dev, "DSP stopped\n"); + dev_dbg(component->dev, "DSP stopped\n"); } }
int wm8958_aif_ev(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); int i;
switch (event) { case SND_SOC_DAPM_POST_PMU: case SND_SOC_DAPM_PRE_PMU: for (i = 0; i < 3; i++) - wm8958_dsp_apply(codec, i, 1); + wm8958_dsp_apply(component, i, 1); break; case SND_SOC_DAPM_POST_PMD: case SND_SOC_DAPM_PRE_PMD: for (i = 0; i < 3; i++) - wm8958_dsp_apply(codec, i, 0); + wm8958_dsp_apply(component, i, 0); break; }
@@ -456,14 +456,14 @@ static int wm8958_dsp2_busy(struct wm8994_priv *wm8994, int aif) static int wm8958_put_mbc_enum(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct wm8994_priv *wm8994 = snd_soc_component_get_drvdata(component); struct wm8994 *control = wm8994->wm8994; int value = ucontrol->value.enumerated.item[0]; int reg;
/* Don't allow on the fly reconfiguration */ - reg = snd_soc_read(codec, WM8994_CLOCKING_1); + reg = snd_soc_component_read32(component, WM8994_CLOCKING_1); if (reg < 0 || reg & WM8958_DSP2CLK_ENA) return -EBUSY;
@@ -478,8 +478,8 @@ static int wm8958_put_mbc_enum(struct snd_kcontrol *kcontrol, static int wm8958_get_mbc_enum(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct wm8994_priv *wm8994 = snd_soc_component_get_drvdata(component);
ucontrol->value.enumerated.item[0] = wm8994->mbc_cfg;
@@ -500,8 +500,8 @@ static int wm8958_mbc_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { int mbc = kcontrol->private_value; - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct wm8994_priv *wm8994 = snd_soc_component_get_drvdata(component);
ucontrol->value.integer.value[0] = wm8994->mbc_ena[mbc];
@@ -512,8 +512,8 @@ static int wm8958_mbc_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { int mbc = kcontrol->private_value; - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct wm8994_priv *wm8994 = snd_soc_component_get_drvdata(component);
if (wm8994->mbc_ena[mbc] == ucontrol->value.integer.value[0]) return 0; @@ -522,7 +522,7 @@ static int wm8958_mbc_put(struct snd_kcontrol *kcontrol, return -EINVAL;
if (wm8958_dsp2_busy(wm8994, mbc)) { - dev_dbg(codec->dev, "DSP2 active on %d already\n", mbc); + dev_dbg(component->dev, "DSP2 active on %d already\n", mbc); return -EBUSY; }
@@ -531,7 +531,7 @@ static int wm8958_mbc_put(struct snd_kcontrol *kcontrol,
wm8994->mbc_ena[mbc] = ucontrol->value.integer.value[0];
- wm8958_dsp_apply(codec, mbc, wm8994->mbc_ena[mbc]); + wm8958_dsp_apply(component, mbc, wm8994->mbc_ena[mbc]);
return 0; } @@ -546,14 +546,14 @@ static int wm8958_mbc_put(struct snd_kcontrol *kcontrol, static int wm8958_put_vss_enum(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct wm8994_priv *wm8994 = snd_soc_component_get_drvdata(component); struct wm8994 *control = wm8994->wm8994; int value = ucontrol->value.enumerated.item[0]; int reg;
/* Don't allow on the fly reconfiguration */ - reg = snd_soc_read(codec, WM8994_CLOCKING_1); + reg = snd_soc_component_read32(component, WM8994_CLOCKING_1); if (reg < 0 || reg & WM8958_DSP2CLK_ENA) return -EBUSY;
@@ -568,8 +568,8 @@ static int wm8958_put_vss_enum(struct snd_kcontrol *kcontrol, static int wm8958_get_vss_enum(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct wm8994_priv *wm8994 = snd_soc_component_get_drvdata(component);
ucontrol->value.enumerated.item[0] = wm8994->vss_cfg;
@@ -579,14 +579,14 @@ static int wm8958_get_vss_enum(struct snd_kcontrol *kcontrol, static int wm8958_put_vss_hpf_enum(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct wm8994_priv *wm8994 = snd_soc_component_get_drvdata(component); struct wm8994 *control = wm8994->wm8994; int value = ucontrol->value.enumerated.item[0]; int reg;
/* Don't allow on the fly reconfiguration */ - reg = snd_soc_read(codec, WM8994_CLOCKING_1); + reg = snd_soc_component_read32(component, WM8994_CLOCKING_1); if (reg < 0 || reg & WM8958_DSP2CLK_ENA) return -EBUSY;
@@ -601,8 +601,8 @@ static int wm8958_put_vss_hpf_enum(struct snd_kcontrol *kcontrol, static int wm8958_get_vss_hpf_enum(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct wm8994_priv *wm8994 = snd_soc_component_get_drvdata(component);
ucontrol->value.enumerated.item[0] = wm8994->vss_hpf_cfg;
@@ -623,8 +623,8 @@ static int wm8958_vss_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { int vss = kcontrol->private_value; - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct wm8994_priv *wm8994 = snd_soc_component_get_drvdata(component);
ucontrol->value.integer.value[0] = wm8994->vss_ena[vss];
@@ -635,8 +635,8 @@ static int wm8958_vss_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { int vss = kcontrol->private_value; - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct wm8994_priv *wm8994 = snd_soc_component_get_drvdata(component);
if (wm8994->vss_ena[vss] == ucontrol->value.integer.value[0]) return 0; @@ -648,7 +648,7 @@ s