Merge remote-tracking branches 'asoc/topic/wm8753', 'asoc/topic/wm8770', 'asoc/topic/wm8776', 'asoc/topic/wm8782' and 'asoc/topic/wm8804' into asoc-next

This commit is contained in:
Mark Brown 2018-03-28 10:31:34 +08:00
No known key found for this signature in database
GPG Key ID: 24D68B725D5487D0
5 changed files with 308 additions and 344 deletions

View File

@ -55,9 +55,9 @@ static int caps_charge = 2000;
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 @@ SOC_ENUM_SINGLE(WM8753_OUTCTL, 2, 2, wm8753_rout2_phase),
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 struct snd_soc_dai_driver wm8753_dai[] = {
},
};
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 = {
static const struct snd_soc_component_driver soc_component_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),
},
.suspend_bias_off = 1,
.idle_bias_on = 1,
.use_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 struct i2c_driver wm8753_i2c_driver = {
.of_match_table = wm8753_of_match,
},
.probe = wm8753_i2c_probe,
.remove = wm8753_i2c_remove,
.id_table = wm8753_i2c_id,
};
#endif

View File

@ -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 const struct snd_soc_dapm_route wm8770_intercon[] = {
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 struct snd_soc_dai_driver wm8770_dai = {
.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 = {
static const struct snd_soc_component_driver soc_component_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),
},
.use_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;
}

View File

@ -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 const struct snd_soc_dapm_route routes[] = {
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 struct snd_soc_dai_driver wm8776_dai[] = {
},
};
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 = {
static const struct snd_soc_component_driver soc_component_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),
},
.suspend_bias_off = 1,
.idle_bias_on = 1,
.use_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 struct i2c_driver wm8776_i2c_driver = {
.of_match_table = wm8776_of_match,
},
.probe = wm8776_i2c_probe,
.remove = wm8776_i2c_remove,
.id_table = wm8776_i2c_id,
};
#endif

View File

@ -50,25 +50,21 @@ static struct snd_soc_dai_driver wm8782_dai = {
},
};
static const struct snd_soc_codec_driver soc_codec_dev_wm8782 = {
.component_driver = {
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,
.use_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 struct platform_driver wm8782_codec_driver = {
.name = "wm8782",
},
.probe = wm8782_probe,
.remove = wm8782_remove,
};
module_platform_driver(wm8782_codec_driver);

View File

@ -137,21 +137,21 @@ static const struct snd_soc_dapm_route wm8804_dapm_routes[] = {
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 struct snd_soc_dai_driver wm8804_dai = {
.symmetric_rates = 1
};
static const struct snd_soc_codec_driver soc_codec_dev_wm8804 = {
.idle_bias_off = true,
.component_driver = {
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),
},
.use_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 @@ EXPORT_SYMBOL_GPL(wm8804_probe);
void wm8804_remove(struct device *dev)
{
pm_runtime_disable(dev);
snd_soc_unregister_codec(dev);
}
EXPORT_SYMBOL_GPL(wm8804_remove);