Commit 7212b7b6 authored by Mark Brown's avatar Mark Brown

Merge remote-tracking branches 'asoc/topic/ak4554', 'asoc/topic/ak4613',...

Merge remote-tracking branches 'asoc/topic/ak4554', 'asoc/topic/ak4613', 'asoc/topic/ak4641', 'asoc/topic/ak4642' and 'asoc/topic/ak4671' into asoc-next
...@@ -64,28 +64,24 @@ static struct snd_soc_dai_driver ak4554_dai = { ...@@ -64,28 +64,24 @@ static struct snd_soc_dai_driver ak4554_dai = {
.symmetric_rates = 1, .symmetric_rates = 1,
}; };
static const struct snd_soc_codec_driver soc_codec_dev_ak4554 = { static const struct snd_soc_component_driver soc_component_dev_ak4554 = {
.component_driver = { .dapm_widgets = ak4554_dapm_widgets,
.dapm_widgets = ak4554_dapm_widgets, .num_dapm_widgets = ARRAY_SIZE(ak4554_dapm_widgets),
.num_dapm_widgets = ARRAY_SIZE(ak4554_dapm_widgets), .dapm_routes = ak4554_dapm_routes,
.dapm_routes = ak4554_dapm_routes, .num_dapm_routes = ARRAY_SIZE(ak4554_dapm_routes),
.num_dapm_routes = ARRAY_SIZE(ak4554_dapm_routes), .idle_bias_on = 1,
}, .use_pmdown_time = 1,
.endianness = 1,
.non_legacy_dai_naming = 1,
}; };
static int ak4554_soc_probe(struct platform_device *pdev) static int ak4554_soc_probe(struct platform_device *pdev)
{ {
return snd_soc_register_codec(&pdev->dev, return devm_snd_soc_register_component(&pdev->dev,
&soc_codec_dev_ak4554, &soc_component_dev_ak4554,
&ak4554_dai, 1); &ak4554_dai, 1);
} }
static int ak4554_soc_remove(struct platform_device *pdev)
{
snd_soc_unregister_codec(&pdev->dev);
return 0;
}
static const struct of_device_id ak4554_of_match[] = { static const struct of_device_id ak4554_of_match[] = {
{ .compatible = "asahi-kasei,ak4554" }, { .compatible = "asahi-kasei,ak4554" },
{}, {},
...@@ -98,7 +94,6 @@ static struct platform_driver ak4554_driver = { ...@@ -98,7 +94,6 @@ static struct platform_driver ak4554_driver = {
.of_match_table = ak4554_of_match, .of_match_table = ak4554_of_match,
}, },
.probe = ak4554_soc_probe, .probe = ak4554_soc_probe,
.remove = ak4554_soc_remove,
}; };
module_platform_driver(ak4554_driver); module_platform_driver(ak4554_driver);
......
...@@ -243,9 +243,9 @@ static const struct snd_soc_dapm_route ak4613_intercon[] = { ...@@ -243,9 +243,9 @@ static const struct snd_soc_dapm_route ak4613_intercon[] = {
static void ak4613_dai_shutdown(struct snd_pcm_substream *substream, static void ak4613_dai_shutdown(struct snd_pcm_substream *substream,
struct snd_soc_dai *dai) struct snd_soc_dai *dai)
{ {
struct snd_soc_codec *codec = dai->codec; struct snd_soc_component *component = dai->component;
struct ak4613_priv *priv = snd_soc_codec_get_drvdata(codec); struct ak4613_priv *priv = snd_soc_component_get_drvdata(component);
struct device *dev = codec->dev; struct device *dev = component->dev;
mutex_lock(&priv->lock); mutex_lock(&priv->lock);
priv->cnt--; priv->cnt--;
...@@ -305,8 +305,8 @@ static void ak4613_hw_constraints(struct ak4613_priv *priv, ...@@ -305,8 +305,8 @@ static void ak4613_hw_constraints(struct ak4613_priv *priv,
static int ak4613_dai_startup(struct snd_pcm_substream *substream, static int ak4613_dai_startup(struct snd_pcm_substream *substream,
struct snd_soc_dai *dai) struct snd_soc_dai *dai)
{ {
struct snd_soc_codec *codec = dai->codec; struct snd_soc_component *component = dai->component;
struct ak4613_priv *priv = snd_soc_codec_get_drvdata(codec); struct ak4613_priv *priv = snd_soc_component_get_drvdata(component);
priv->cnt++; priv->cnt++;
...@@ -318,8 +318,8 @@ static int ak4613_dai_startup(struct snd_pcm_substream *substream, ...@@ -318,8 +318,8 @@ static int ak4613_dai_startup(struct snd_pcm_substream *substream,
static int ak4613_dai_set_sysclk(struct snd_soc_dai *codec_dai, static int ak4613_dai_set_sysclk(struct snd_soc_dai *codec_dai,
int clk_id, unsigned int freq, int dir) int clk_id, unsigned int freq, int dir)
{ {
struct snd_soc_codec *codec = codec_dai->codec; struct snd_soc_component *component = codec_dai->component;
struct ak4613_priv *priv = snd_soc_codec_get_drvdata(codec); struct ak4613_priv *priv = snd_soc_component_get_drvdata(component);
priv->sysclk = freq; priv->sysclk = freq;
...@@ -328,8 +328,8 @@ static int ak4613_dai_set_sysclk(struct snd_soc_dai *codec_dai, ...@@ -328,8 +328,8 @@ static int ak4613_dai_set_sysclk(struct snd_soc_dai *codec_dai,
static int ak4613_dai_set_fmt(struct snd_soc_dai *dai, unsigned int fmt) static int ak4613_dai_set_fmt(struct snd_soc_dai *dai, unsigned int fmt)
{ {
struct snd_soc_codec *codec = dai->codec; struct snd_soc_component *component = dai->component;
struct ak4613_priv *priv = snd_soc_codec_get_drvdata(codec); struct ak4613_priv *priv = snd_soc_component_get_drvdata(component);
fmt &= SND_SOC_DAIFMT_FORMAT_MASK; fmt &= SND_SOC_DAIFMT_FORMAT_MASK;
...@@ -366,10 +366,10 @@ static int ak4613_dai_hw_params(struct snd_pcm_substream *substream, ...@@ -366,10 +366,10 @@ static int ak4613_dai_hw_params(struct snd_pcm_substream *substream,
struct snd_pcm_hw_params *params, struct snd_pcm_hw_params *params,
struct snd_soc_dai *dai) struct snd_soc_dai *dai)
{ {
struct snd_soc_codec *codec = dai->codec; struct snd_soc_component *component = dai->component;
struct ak4613_priv *priv = snd_soc_codec_get_drvdata(codec); struct ak4613_priv *priv = snd_soc_component_get_drvdata(component);
const struct ak4613_interface *iface; const struct ak4613_interface *iface;
struct device *dev = codec->dev; struct device *dev = component->dev;
unsigned int width = params_width(params); unsigned int width = params_width(params);
unsigned int fmt = priv->fmt; unsigned int fmt = priv->fmt;
unsigned int rate; unsigned int rate;
...@@ -434,11 +434,11 @@ static int ak4613_dai_hw_params(struct snd_pcm_substream *substream, ...@@ -434,11 +434,11 @@ static int ak4613_dai_hw_params(struct snd_pcm_substream *substream,
fmt_ctrl = AUDIO_IFACE_TO_VAL(iface); fmt_ctrl = AUDIO_IFACE_TO_VAL(iface);
snd_soc_update_bits(codec, CTRL1, FMT_MASK, fmt_ctrl); snd_soc_component_update_bits(component, CTRL1, FMT_MASK, fmt_ctrl);
snd_soc_update_bits(codec, CTRL2, DFS_MASK, ctrl2); snd_soc_component_update_bits(component, CTRL2, DFS_MASK, ctrl2);
snd_soc_update_bits(codec, ICTRL, ICTRL_MASK, priv->ic); snd_soc_component_update_bits(component, ICTRL, ICTRL_MASK, priv->ic);
snd_soc_update_bits(codec, OCTRL, OCTRL_MASK, priv->oc); snd_soc_component_update_bits(component, OCTRL, OCTRL_MASK, priv->oc);
hw_params_end: hw_params_end:
if (ret < 0) if (ret < 0)
...@@ -447,7 +447,7 @@ static int ak4613_dai_hw_params(struct snd_pcm_substream *substream, ...@@ -447,7 +447,7 @@ static int ak4613_dai_hw_params(struct snd_pcm_substream *substream,
return ret; return ret;
} }
static int ak4613_set_bias_level(struct snd_soc_codec *codec, static int ak4613_set_bias_level(struct snd_soc_component *component,
enum snd_soc_bias_level level) enum snd_soc_bias_level level)
{ {
u8 mgmt1 = 0; u8 mgmt1 = 0;
...@@ -467,7 +467,7 @@ static int ak4613_set_bias_level(struct snd_soc_codec *codec, ...@@ -467,7 +467,7 @@ static int ak4613_set_bias_level(struct snd_soc_codec *codec,
break; break;
} }
snd_soc_write(codec, PW_MGMT1, mgmt1); snd_soc_component_write(component, PW_MGMT1, mgmt1);
return 0; return 0;
} }
...@@ -504,8 +504,8 @@ static void ak4613_dummy_write(struct work_struct *work) ...@@ -504,8 +504,8 @@ static void ak4613_dummy_write(struct work_struct *work)
static int ak4613_dai_trigger(struct snd_pcm_substream *substream, int cmd, static int ak4613_dai_trigger(struct snd_pcm_substream *substream, int cmd,
struct snd_soc_dai *dai) struct snd_soc_dai *dai)
{ {
struct snd_soc_codec *codec = dai->codec; struct snd_soc_component *component = dai->component;
struct ak4613_priv *priv = snd_soc_codec_get_drvdata(codec); struct ak4613_priv *priv = snd_soc_component_get_drvdata(component);
/* /*
* FIXME * FIXME
...@@ -537,7 +537,7 @@ static int ak4613_dai_trigger(struct snd_pcm_substream *substream, int cmd, ...@@ -537,7 +537,7 @@ static int ak4613_dai_trigger(struct snd_pcm_substream *substream, int cmd,
if (substream->stream != SNDRV_PCM_STREAM_PLAYBACK) if (substream->stream != SNDRV_PCM_STREAM_PLAYBACK)
return 0; return 0;
priv->component = &codec->component; priv->component = component;
schedule_work(&priv->dummy_write_work); schedule_work(&priv->dummy_write_work);
return 0; return 0;
...@@ -582,35 +582,36 @@ static struct snd_soc_dai_driver ak4613_dai = { ...@@ -582,35 +582,36 @@ static struct snd_soc_dai_driver ak4613_dai = {
.symmetric_rates = 1, .symmetric_rates = 1,
}; };
static int ak4613_suspend(struct snd_soc_codec *codec) static int ak4613_suspend(struct snd_soc_component *component)
{ {
struct regmap *regmap = dev_get_regmap(codec->dev, NULL); struct regmap *regmap = dev_get_regmap(component->dev, NULL);
regcache_cache_only(regmap, true); regcache_cache_only(regmap, true);
regcache_mark_dirty(regmap); regcache_mark_dirty(regmap);
return 0; return 0;
} }
static int ak4613_resume(struct snd_soc_codec *codec) static int ak4613_resume(struct snd_soc_component *component)
{ {
struct regmap *regmap = dev_get_regmap(codec->dev, NULL); struct regmap *regmap = dev_get_regmap(component->dev, NULL);
regcache_cache_only(regmap, false); regcache_cache_only(regmap, false);
return regcache_sync(regmap); return regcache_sync(regmap);
} }
static const struct snd_soc_codec_driver soc_codec_dev_ak4613 = { static const struct snd_soc_component_driver soc_component_dev_ak4613 = {
.suspend = ak4613_suspend, .suspend = ak4613_suspend,
.resume = ak4613_resume, .resume = ak4613_resume,
.set_bias_level = ak4613_set_bias_level, .set_bias_level = ak4613_set_bias_level,
.component_driver = { .controls = ak4613_snd_controls,
.controls = ak4613_snd_controls, .num_controls = ARRAY_SIZE(ak4613_snd_controls),
.num_controls = ARRAY_SIZE(ak4613_snd_controls), .dapm_widgets = ak4613_dapm_widgets,
.dapm_widgets = ak4613_dapm_widgets, .num_dapm_widgets = ARRAY_SIZE(ak4613_dapm_widgets),
.num_dapm_widgets = ARRAY_SIZE(ak4613_dapm_widgets), .dapm_routes = ak4613_intercon,
.dapm_routes = ak4613_intercon, .num_dapm_routes = ARRAY_SIZE(ak4613_intercon),
.num_dapm_routes = ARRAY_SIZE(ak4613_intercon), .idle_bias_on = 1,
}, .endianness = 1,
.non_legacy_dai_naming = 1,
}; };
static void ak4613_parse_of(struct ak4613_priv *priv, static void ak4613_parse_of(struct ak4613_priv *priv,
...@@ -677,13 +678,12 @@ static int ak4613_i2c_probe(struct i2c_client *i2c, ...@@ -677,13 +678,12 @@ static int ak4613_i2c_probe(struct i2c_client *i2c,
if (IS_ERR(regmap)) if (IS_ERR(regmap))
return PTR_ERR(regmap); return PTR_ERR(regmap);
return snd_soc_register_codec(dev, &soc_codec_dev_ak4613, return devm_snd_soc_register_component(dev, &soc_component_dev_ak4613,
&ak4613_dai, 1); &ak4613_dai, 1);
} }
static int ak4613_i2c_remove(struct i2c_client *client) static int ak4613_i2c_remove(struct i2c_client *client)
{ {
snd_soc_unregister_codec(&client->dev);
return 0; return 0;
} }
......
...@@ -70,9 +70,9 @@ static const struct reg_default ak4641_reg_defaults[] = { ...@@ -70,9 +70,9 @@ static const struct reg_default ak4641_reg_defaults[] = {
static const int deemph_settings[] = {44100, 0, 48000, 32000}; static const int deemph_settings[] = {44100, 0, 48000, 32000};
static int ak4641_set_deemph(struct snd_soc_codec *codec) static int ak4641_set_deemph(struct snd_soc_component *component)
{ {
struct ak4641_priv *ak4641 = snd_soc_codec_get_drvdata(codec); struct ak4641_priv *ak4641 = snd_soc_component_get_drvdata(component);
int i, best = 0; int i, best = 0;
for (i = 0 ; i < ARRAY_SIZE(deemph_settings); i++) { for (i = 0 ; i < ARRAY_SIZE(deemph_settings); i++) {
...@@ -86,16 +86,16 @@ static int ak4641_set_deemph(struct snd_soc_codec *codec) ...@@ -86,16 +86,16 @@ static int ak4641_set_deemph(struct snd_soc_codec *codec)
best = i; best = i;
} }
dev_dbg(codec->dev, "Set deemphasis %d\n", best); dev_dbg(component->dev, "Set deemphasis %d\n", best);
return snd_soc_update_bits(codec, AK4641_DAC, 0x3, best); return snd_soc_component_update_bits(component, AK4641_DAC, 0x3, best);
} }
static int ak4641_put_deemph(struct snd_kcontrol *kcontrol, static int ak4641_put_deemph(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol) 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 ak4641_priv *ak4641 = snd_soc_codec_get_drvdata(codec); struct ak4641_priv *ak4641 = snd_soc_component_get_drvdata(component);
int deemph = ucontrol->value.integer.value[0]; int deemph = ucontrol->value.integer.value[0];
if (deemph > 1) if (deemph > 1)
...@@ -103,14 +103,14 @@ static int ak4641_put_deemph(struct snd_kcontrol *kcontrol, ...@@ -103,14 +103,14 @@ static int ak4641_put_deemph(struct snd_kcontrol *kcontrol,
ak4641->deemph = deemph; ak4641->deemph = deemph;
return ak4641_set_deemph(codec); return ak4641_set_deemph(component);
} }
static int ak4641_get_deemph(struct snd_kcontrol *kcontrol, static int ak4641_get_deemph(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol) 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 ak4641_priv *ak4641 = snd_soc_codec_get_drvdata(codec); struct ak4641_priv *ak4641 = snd_soc_component_get_drvdata(component);
ucontrol->value.integer.value[0] = ak4641->deemph; ucontrol->value.integer.value[0] = ak4641->deemph;
return 0; return 0;
...@@ -307,8 +307,8 @@ static const struct snd_soc_dapm_route ak4641_audio_map[] = { ...@@ -307,8 +307,8 @@ static const struct snd_soc_dapm_route ak4641_audio_map[] = {
static int ak4641_set_dai_sysclk(struct snd_soc_dai *codec_dai, static int ak4641_set_dai_sysclk(struct snd_soc_dai *codec_dai,
int clk_id, unsigned int freq, int dir) int clk_id, unsigned int freq, int dir)
{ {
struct snd_soc_codec *codec = codec_dai->codec; struct snd_soc_component *component = codec_dai->component;
struct ak4641_priv *ak4641 = snd_soc_codec_get_drvdata(codec); struct ak4641_priv *ak4641 = snd_soc_component_get_drvdata(component);
ak4641->sysclk = freq; ak4641->sysclk = freq;
return 0; return 0;
...@@ -318,8 +318,8 @@ static int ak4641_i2s_hw_params(struct snd_pcm_substream *substream, ...@@ -318,8 +318,8 @@ static int ak4641_i2s_hw_params(struct snd_pcm_substream *substream,
struct snd_pcm_hw_params *params, struct snd_pcm_hw_params *params,
struct snd_soc_dai *dai) struct snd_soc_dai *dai)
{ {
struct snd_soc_codec *codec = dai->codec; struct snd_soc_component *component = dai->component;
struct ak4641_priv *ak4641 = snd_soc_codec_get_drvdata(codec); struct ak4641_priv *ak4641 = snd_soc_component_get_drvdata(component);
int rate = params_rate(params), fs = 256; int rate = params_rate(params), fs = 256;
u8 mode2; u8 mode2;
...@@ -340,16 +340,16 @@ static int ak4641_i2s_hw_params(struct snd_pcm_substream *substream, ...@@ -340,16 +340,16 @@ static int ak4641_i2s_hw_params(struct snd_pcm_substream *substream,
mode2 = (0x0 << 5); mode2 = (0x0 << 5);
break; break;
default: default:
dev_err(codec->dev, "Error: unsupported fs=%d\n", fs); dev_err(component->dev, "Error: unsupported fs=%d\n", fs);
return -EINVAL; return -EINVAL;
} }
snd_soc_update_bits(codec, AK4641_MODE2, (0x3 << 5), mode2); snd_soc_component_update_bits(component, AK4641_MODE2, (0x3 << 5), mode2);
/* Update de-emphasis filter for the new rate */ /* Update de-emphasis filter for the new rate */
if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
ak4641->playback_fs = rate; ak4641->playback_fs = rate;
ak4641_set_deemph(codec); ak4641_set_deemph(component);
} }
return 0; return 0;
...@@ -358,7 +358,7 @@ static int ak4641_i2s_hw_params(struct snd_pcm_substream *substream, ...@@ -358,7 +358,7 @@ static int ak4641_i2s_hw_params(struct snd_pcm_substream *substream,
static int ak4641_pcm_set_dai_fmt(struct snd_soc_dai *codec_dai, static int ak4641_pcm_set_dai_fmt(struct snd_soc_dai *codec_dai,
unsigned int fmt) unsigned int fmt)
{ {
struct snd_soc_codec *codec = codec_dai->codec; struct snd_soc_component *component = codec_dai->component;
u8 btif; u8 btif;
int ret; int ret;
...@@ -380,7 +380,7 @@ static int ak4641_pcm_set_dai_fmt(struct snd_soc_dai *codec_dai, ...@@ -380,7 +380,7 @@ static int ak4641_pcm_set_dai_fmt(struct snd_soc_dai *codec_dai,
return -EINVAL; return -EINVAL;
} }
ret = snd_soc_update_bits(codec, AK4641_BTIF, (0x3 << 5), btif); ret = snd_soc_component_update_bits(component, AK4641_BTIF, (0x3 << 5), btif);
if (ret < 0) if (ret < 0)
return ret; return ret;
...@@ -390,7 +390,7 @@ static int ak4641_pcm_set_dai_fmt(struct snd_soc_dai *codec_dai, ...@@ -390,7 +390,7 @@ static int ak4641_pcm_set_dai_fmt(struct snd_soc_dai *codec_dai,
static int ak4641_i2s_set_dai_fmt(struct snd_soc_dai *codec_dai, static int ak4641_i2s_set_dai_fmt(struct snd_soc_dai *codec_dai,
unsigned int fmt) unsigned int fmt)
{ {
struct snd_soc_codec *codec = codec_dai->codec; struct snd_soc_component *component = codec_dai->component;
u8 mode1 = 0; u8 mode1 = 0;
/* interface format */ /* interface format */
...@@ -405,34 +405,34 @@ static int ak4641_i2s_set_dai_fmt(struct snd_soc_dai *codec_dai, ...@@ -405,34 +405,34 @@ static int ak4641_i2s_set_dai_fmt(struct snd_soc_dai *codec_dai,
return -EINVAL; return -EINVAL;
} }
return snd_soc_write(codec, AK4641_MODE1, mode1); return snd_soc_component_write(component, AK4641_MODE1, mode1);
} }
static int ak4641_mute(struct snd_soc_dai *dai, int mute) static int ak4641_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, AK4641_DAC, 0x20, mute ? 0x20 : 0); return snd_soc_component_update_bits(component, AK4641_DAC, 0x20, mute ? 0x20 : 0);
} }
static int ak4641_set_bias_level(struct snd_soc_codec *codec, static int ak4641_set_bias_level(struct snd_soc_component *component,
enum snd_soc_bias_level level) enum snd_soc_bias_level level)
{ {
struct ak4641_priv *ak4641 = snd_soc_codec_get_drvdata(codec); struct ak4641_priv *ak4641 = snd_soc_component_get_drvdata(component);
struct ak4641_platform_data *pdata = codec->dev->platform_data; struct ak4641_platform_data *pdata = component->dev->platform_data;
int ret; int ret;
switch (level) { switch (level) {
case SND_SOC_BIAS_ON: case SND_SOC_BIAS_ON:
/* unmute */ /* unmute */
snd_soc_update_bits(codec, AK4641_DAC, 0x20, 0); snd_soc_component_update_bits(component, AK4641_DAC, 0x20, 0);
break; break;
case SND_SOC_BIAS_PREPARE: case SND_SOC_BIAS_PREPARE:
/* mute */ /* mute */
snd_soc_update_bits(codec, AK4641_DAC, 0x20, 0x20); snd_soc_component_update_bits(component, AK4641_DAC, 0x20, 0x20);
break; break;
case SND_SOC_BIAS_STANDBY: 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) {
if (pdata && gpio_is_valid(pdata->gpio_power)) if (pdata && gpio_is_valid(pdata->gpio_power))
gpio_set_value(pdata->gpio_power, 1); gpio_set_value(pdata->gpio_power, 1);
mdelay(1); mdelay(1);
...@@ -442,16 +442,16 @@ static int ak4641_set_bias_level(struct snd_soc_codec *codec, ...@@ -442,16 +442,16 @@ static int ak4641_set_bias_level(struct snd_soc_codec *codec,
ret = regcache_sync(ak4641->regmap); ret = regcache_sync(ak4641->regmap);
if (ret) { if (ret) {
dev_err(codec->dev, dev_err(component->dev,
"Failed to sync cache: %d\n", ret); "Failed to sync cache: %d\n", ret);
return ret; return ret;
} }
} }
snd_soc_update_bits(codec, AK4641_PM1, 0x80, 0x80); snd_soc_component_update_bits(component, AK4641_PM1, 0x80, 0x80);
snd_soc_update_bits(codec, AK4641_PM2, 0x80, 0); snd_soc_component_update_bits(component, AK4641_PM2, 0x80, 0);
break; break;
case SND_SOC_BIAS_OFF: case SND_SOC_BIAS_OFF:
snd_soc_update_bits(codec, AK4641_PM1, 0x80, 0); snd_soc_component_update_bits(component, AK4641_PM1, 0x80, 0);
if (pdata && gpio_is_valid(pdata->gpio_npdn)) if (pdata && gpio_is_valid(pdata->gpio_npdn))
gpio_set_value(pdata->gpio_npdn, 0); gpio_set_value(pdata->gpio_npdn, 0);
if (pdata && gpio_is_valid(pdata->gpio_power)) if (pdata && gpio_is_valid(pdata->gpio_power))
...@@ -524,17 +524,19 @@ static struct snd_soc_dai_driver ak4641_dai[] = { ...@@ -524,17 +524,19 @@ static struct snd_soc_dai_driver ak4641_dai[] = {
}, },
}; };
static const struct snd_soc_codec_driver soc_codec_dev_ak4641 = { static const struct snd_soc_component_driver soc_component_dev_ak4641 = {
.component_driver = { .controls = ak4641_snd_controls,
.controls = ak4641_snd_controls, .num_controls = ARRAY_SIZE(ak4641_snd_controls),
.num_controls = ARRAY_SIZE(ak4641_snd_controls), .dapm_widgets = ak4641_dapm_widgets,
.dapm_widgets = ak4641_dapm_widgets, .num_dapm_widgets = ARRAY_SIZE(ak4641_dapm_widgets),
.num_dapm_widgets = ARRAY_SIZE(ak4641_dapm_widgets), .dapm_routes = ak4641_audio_map,
.dapm_routes = ak4641_audio_map, .num_dapm_routes = ARRAY_SIZE(ak4641_audio_map),
.num_dapm_routes = ARRAY_SIZE(ak4641_audio_map),
},
.set_bias_level = ak4641_set_bias_level, .set_bias_level = ak4641_set_bias_level,
.suspend_bias_off = true, .suspend_bias_off = 1,
.idle_bias_on = 1,
.use_pmdown_time = 1,
.endianness = 1,
.non_legacy_dai_naming = 1,
}; };
static const struct regmap_config ak4641_regmap = { static const struct regmap_config ak4641_regmap = {
...@@ -583,7 +585,8 @@ static int ak4641_i2c_probe(struct i2c_client *i2c, ...@@ -583,7 +585,8 @@ static int ak4641_i2c_probe(struct i2c_client *i2c,
i2c_set_clientdata(i2c, ak4641); i2c_set_clientdata(i2c, ak4641);
ret = snd_soc_register_codec(&i2c->dev, &soc_codec_dev_ak4641, ret = devm_snd_soc_register_component(&i2c->dev,
&soc_component_dev_ak4641,
ak4641_dai, ARRAY_SIZE(ak4641_dai)); ak4641_dai, ARRAY_SIZE(ak4641_dai));
if (ret != 0) if (ret != 0)
goto err_gpio2; goto err_gpio2;
...@@ -608,8 +611,6 @@ static int ak4641_i2c_remove(struct i2c_client *i2c) ...@@ -608,8 +611,6 @@ static int ak4641_i2c_remove(struct i2c_client *i2c)
{ {
struct ak4641_platform_data *pdata = i2c->dev.platform_data; struct ak4641_platform_data *pdata = i2c->dev.platform_data;
snd_soc_unregister_codec(&i2c->dev);
if (pdata) { if (pdata) {
if (gpio_is_valid(pdata->gpio_power)) { if (gpio_is_valid(pdata->gpio_power)) {
gpio_set_value(pdata->gpio_power, 0); gpio_set_value(pdata->gpio_power, 0);
......
...@@ -178,19 +178,19 @@ static const struct snd_kcontrol_new ak4642_lout_mixer_controls[] = { ...@@ -178,19 +178,19 @@ static const struct snd_kcontrol_new ak4642_lout_mixer_controls[] = {
static int ak4642_lout_event(struct snd_soc_dapm_widget *w, static int ak4642_lout_event(struct snd_soc_dapm_widget *w,
struct snd_kcontrol *kcontrol, int event) 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) { switch (event) {
case SND_SOC_DAPM_PRE_PMD: case SND_SOC_DAPM_PRE_PMD:
case SND_SOC_DAPM_PRE_PMU: case SND_SOC_DAPM_PRE_PMU:
/* Power save mode ON */ /* Power save mode ON */
snd_soc_update_bits(codec, SG_SL2, LOPS, LOPS); snd_soc_component_update_bits(component, SG_SL2, LOPS, LOPS);
break; break;
case SND_SOC_DAPM_POST_PMU: case SND_SOC_DAPM_POST_PMU:
case SND_SOC_DAPM_POST_PMD: case SND_SOC_DAPM_POST_PMD:
/* Power save mode OFF */ /* Power save mode OFF */
msleep(300); msleep(300);
snd_soc_update_bits(codec, SG_SL2, LOPS, 0); snd_soc_component_update_bits(component, SG_SL2, LOPS, 0);
break; break;
} }
...@@ -282,7 +282,7 @@ static int ak4642_dai_startup(struct snd_pcm_substream *substream, ...@@ -282,7 +282,7 @@ static int ak4642_dai_startup(struct snd_pcm_substream *substream,
struct snd_soc_dai *dai) struct snd_soc_dai *dai)
{ {
int is_play = substream->stream == SNDRV_PCM_STREAM_PLAYBACK; int is_play = substream->stream == SNDRV_PCM_STREAM_PLAYBACK;
struct snd_soc_codec *codec = dai->codec; struct snd_soc_component *component = dai->component;
if (is_play) { if (is_play) {
/* /*
...@@ -295,8 +295,8 @@ static int ak4642_dai_startup(struct snd_pcm_substream *substream, ...@@ -295,8 +295,8 @@ static int ak4642_dai_startup(struct snd_pcm_substream *substream,
* This operation came from example code of * This operation came from example code of
* "ASAHI KASEI AK4642" (japanese) manual p97. * "ASAHI KASEI AK4642" (japanese) manual p97.
*/ */
snd_soc_write(codec, L_IVC, 0x91); /* volume */ snd_soc_component_write(component, L_IVC, 0x91); /* volume */
snd_soc_write(codec, R_IVC, 0x91); /* volume */ snd_soc_component_write(component, R_IVC, 0x91); /* volume */
} else { } else {
/* /*
* start stereo input * start stereo input
...@@ -311,11 +311,11 @@ static int ak4642_dai_startup(struct snd_pcm_substream *substream, ...@@ -311,11 +311,11 @@ static int ak4642_dai_startup(struct snd_pcm_substream *substream,
* This operation came from example code of * This operation came from example code of
* "ASAHI KASEI AK4642" (japanese) manual p94. * "ASAHI KASEI AK4642" (japanese) manual p94.
*/ */
snd_soc_update_bits(codec, SG_SL1, PMMP | MGAIN0, PMMP | MGAIN0); snd_soc_component_update_bits(component, SG_SL1, PMMP | MGAIN0, PMMP | MGAIN0);
snd_soc_write(codec, TIMER, ZTM(0x3) | WTM(0x3)); snd_soc_component_write(component, TIMER, ZTM(0x3) | WTM(0x3));
snd_soc_write(codec, ALC_CTL1, ALC | LMTH0); snd_soc_component_write(component, ALC_CTL1, ALC | LMTH0);
snd_soc_update_bits(codec, PW_MGMT1, PMADL, PMADL); snd_soc_component_update_bits(component, PW_MGMT1, PMADL, PMADL);
snd_soc_update_bits(codec, PW_MGMT3, PMADR, PMADR); snd_soc_component_update_bits(component, PW_MGMT3, PMADR, PMADR);
} }
return 0; return 0;
...@@ -325,22 +325,22 @@ static void ak4642_dai_shutdown(struct snd_pcm_substream *substream, ...@@ -325,22 +325,22 @@ static void ak4642_dai_shutdown(struct snd_pcm_substream *substream,
struct snd_soc_dai *dai) struct snd_soc_dai *dai)
{ {
int is_play = substream->stream == SNDRV_PCM_STREAM_PLAYBACK; int is_play = substream->stream == SNDRV_PCM_STREAM_PLAYBACK;
struct snd_soc_codec *codec = dai->codec; struct snd_soc_component *component = dai->component;
if (is_play) { if (is_play) {
} else { } else {
/* stop stereo input */ /* stop stereo input */
snd_soc_update_bits(codec, PW_MGMT1, PMADL, 0); snd_soc_component_update_bits(component, PW_MGMT1, PMADL, 0);
snd_soc_update_bits(codec, PW_MGMT3, PMADR, 0); snd_soc_component_update_bits(component, PW_MGMT3, PMADR, 0);
snd_soc_update_bits(codec, ALC_CTL1, ALC, 0); snd_soc_component_update_bits(component, ALC_CTL1, ALC, 0);
} }
} }
static int ak4642_dai_set_sysclk(struct snd_soc_dai *codec_dai, static int ak4642_dai_set_sysclk(struct snd_soc_dai *codec_dai,
int clk_id, unsigned int freq, int dir) int clk_id, unsigned int freq, int dir)
{ {
struct snd_soc_codec *codec = codec_dai->codec; struct snd_soc_component *component = codec_dai->component;
struct ak4642_priv *priv = snd_soc_codec_get_drvdata(codec); struct ak4642_priv *priv = snd_soc_component_get_drvdata(component);
u8 pll; u8 pll;
int extended_freq = 0; int extended_freq = 0;
...@@ -382,14 +382,14 @@ static int ak4642_dai_set_sysclk(struct snd_soc_dai *codec_dai, ...@@ -382,14 +382,14 @@ static int ak4642_dai_set_sysclk(struct snd_soc_dai *codec_dai,
if (extended_freq && !priv->drvdata->extended_frequencies) if (extended_freq && !priv->drvdata->extended_frequencies)
return -EINVAL; return -EINVAL;
snd_soc_update_bits(codec, MD_CTL1, PLL_MASK, pll); snd_soc_component_update_bits(component, MD_CTL1, PLL_MASK, pll);
return 0; return 0;
} }
static int ak4642_dai_set_fmt(struct snd_soc_dai *dai, unsigned int fmt) static int ak4642_dai_set_fmt(struct snd_soc_dai *dai, unsigned int fmt)
{ {
struct snd_soc_codec *codec = dai->codec; struct snd_soc_component *component = dai->component;
u8 data; u8 data;
u8 bcko; u8 bcko;
...@@ -407,8 +407,8 @@ static int ak4642_dai_set_fmt(struct snd_soc_dai *dai, unsigned int fmt) ...@@ -407,8 +407,8 @@ static int ak4642_dai_set_fmt(struct snd_soc_dai *dai, unsigned int fmt)
default: default:
return -EINVAL; return -EINVAL;
} }
snd_soc_update_bits(codec, PW_MGMT2, MS | MCKO | PMPLL, data); snd_soc_component_update_bits(component, PW_MGMT2, MS | MCKO | PMPLL, data);
snd_soc_update_bits(codec, MD_CTL1, BCKO_MASK, bcko); snd_soc_component_update_bits(component, MD_CTL1, BCKO_MASK, bcko);
/* format type */ /* format type */
data = 0; data = 0;
...@@ -425,12 +425,12 @@ static int ak4642_dai_set_fmt(struct snd_soc_dai *dai, unsigned int fmt) ...@@ -425,12 +425,12 @@ static int ak4642_dai_set_fmt(struct snd_soc_dai *dai, unsigned int fmt)
default: default:
return -EINVAL; return -EINVAL;
} }
snd_soc_update_bits(codec, MD_CTL1, DIF_MASK, data); snd_soc_component_update_bits(component, MD_CTL1, DIF_MASK, data);
return 0; return 0;
} }
static int ak4642_set_mcko(struct snd_soc_codec *codec, static int ak4642_set_mcko(struct snd_soc_component *component,
u32 frequency) u32 frequency)
{ {
static const u32 fs_list[] = { static const u32 fs_list[] = {
...@@ -458,7 +458,7 @@ static int ak4642_set_mcko(struct snd_soc_codec *codec, ...@@ -458,7 +458,7 @@ static int ak4642_set_mcko(struct snd_soc_codec *codec,
for (ps = 0; ps < ARRAY_SIZE(ps_list); ps++) { for (ps = 0; ps < ARRAY_SIZE(ps_list); ps++) {
for (fs = 0; fs < ARRAY_SIZE(fs_list); fs++) { for (fs = 0; fs < ARRAY_SIZE(fs_list); fs++) {
if (frequency == ps_list[ps] * fs_list[fs]) { if (frequency == ps_list[ps] * fs_list[fs]) {
snd_soc_write(codec, MD_CTL2, snd_soc_component_write(component, MD_CTL2,
PSs(ps) | FSs(fs)); PSs(ps) | FSs(fs));
return 0; return 0;
} }
...@@ -472,25 +472,25 @@ static int ak4642_dai_hw_params(struct snd_pcm_substream *substream, ...@@ -472,25 +472,25 @@ static int ak4642_dai_hw_params(struct snd_pcm_substream *substream,
struct snd_pcm_hw_params *params, struct snd_pcm_hw_params *params,
struct snd_soc_dai *dai) struct snd_soc_dai *dai)
{ {
struct snd_soc_codec *codec = dai->codec; struct snd_soc_component *component = dai->component;
struct ak4642_priv *priv = snd_soc_codec_get_drvdata(codec); struct ak4642_priv *priv = snd_soc_component_get_drvdata(component);
u32 rate = clk_get_rate(priv->mcko); u32 rate = clk_get_rate(priv->mcko);
if (!rate) if (!rate)
rate = params_rate(params) * 256; rate = params_rate(params) * 256;
return ak4642_set_mcko(codec, rate); return ak4642_set_mcko(component, rate);
} }
static int ak4642_set_bias_level(struct snd_soc_codec *codec, static int ak4642_set_bias_level(struct snd_soc_component *component,
enum snd_soc_bias_level level) enum snd_soc_bias_level level)
{ {
switch (level) { switch (level) {
case SND_SOC_BIAS_OFF: case SND_SOC_BIAS_OFF:
snd_soc_write(codec, PW_MGMT1, 0x00); snd_soc_component_write(component, PW_MGMT1, 0x00);
break; break;
default: default:
snd_soc_update_bits(codec, PW_MGMT1, PMVCM, PMVCM); snd_soc_component_update_bits(component, PW_MGMT1, PMVCM, PMVCM);
break; break;
} }
...@@ -523,46 +523,47 @@ static struct snd_soc_dai_driver ak4642_dai = { ...@@ -523,46 +523,47 @@ static struct snd_soc_dai_driver ak4642_dai = {
.symmetric_rates = 1, .symmetric_rates = 1,
}; };
static int ak4642_suspend(struct snd_soc_codec *codec) static int ak4642_suspend(struct snd_soc_component *component)
{ {
struct regmap *regmap = dev_get_regmap(codec->dev, NULL); struct regmap *regmap = dev_get_regmap(component->dev, NULL);
regcache_cache_only(regmap, true); regcache_cache_only(regmap, true);
regcache_mark_dirty(regmap); regcache_mark_dirty(regmap);
return 0; return 0;
} }
static int ak4642_resume(struct snd_soc_codec *codec) static int ak4642_resume(struct snd_soc_component *component)
{ {
struct regmap *regmap = dev_get_regmap(codec->dev, NULL); struct regmap *regmap = dev_get_regmap(component->dev, NULL);
regcache_cache_only(regmap, false); regcache_cache_only(regmap, false);
regcache_sync(regmap); regcache_sync(regmap);
return 0; return 0;
} }
static int ak4642_probe(struct snd_soc_codec *codec) static int ak4642_probe(struct snd_soc_component *component)
{ {
struct ak4642_priv *priv = snd_soc_codec_get_drvdata(codec); struct ak4642_priv *priv = snd_soc_component_get_drvdata(component);
if (priv->mcko) if (priv->mcko)
ak4642_set_mcko(codec, clk_get_rate(priv->mcko)); ak4642_set_mcko(component, clk_get_rate(priv->mcko));
return 0; return 0;
} }
static const struct snd_soc_codec_driver soc_codec_dev_ak4642 = { static const struct snd_soc_component_driver soc_component_dev_ak4642 = {
.probe = ak4642_probe, .probe = ak4642_probe,
.suspend = ak4642_suspend, .suspend = ak4642_suspend,
.resume = ak4642_resume, .resume = ak4642_resume,
.set_bias_level = ak4642_set_bias_level, .set_bias_level = ak4642_set_bias_level,
.component_driver = { .controls = ak4642_snd_controls,
.controls = ak4642_snd_controls, .num_controls = ARRAY_SIZE(ak4642_snd_controls),
.num_controls = ARRAY_SIZE(ak4642_snd_controls), .dapm_widgets = ak4642_dapm_widgets,
.dapm_widgets = ak4642_dapm_widgets, .num_dapm_widgets = ARRAY_SIZE(ak4642_dapm_widgets),
.num_dapm_widgets = ARRAY_SIZE(ak4642_dapm_widgets), .dapm_routes = ak4642_intercon,
.dapm_routes = ak4642_intercon, .num_dapm_routes = ARRAY_SIZE(ak4642_intercon),
.num_dapm_routes = ARRAY_SIZE(ak4642_intercon), .idle_bias_on = 1,
}, .endianness = 1,
.non_legacy_dai_naming = 1,
}; };
static const struct regmap_config ak4642_regmap = { static const struct regmap_config ak4642_regmap = {
...@@ -675,14 +676,8 @@ static int ak4642_i2c_probe(struct i2c_client *i2c, ...@@ -675,14 +676,8 @@ static int ak4642_i2c_probe(struct i2c_client *i2c,
if (IS_ERR(regmap)) if (IS_ERR(regmap))
return PTR_ERR(regmap); return PTR_ERR(regmap);
return snd_soc_register_codec(dev, return devm_snd_soc_register_component(dev,
&soc_codec_dev_ak4642, &ak4642_dai, 1); &soc_component_dev_ak4642, &ak4642_dai, 1);
}
static int ak4642_i2c_remove(struct i2c_client *client)
{
snd_soc_unregister_codec(&client->dev);
return 0;
} }
static const struct of_device_id ak4642_of_match[] = { static const struct of_device_id ak4642_of_match[] = {
...@@ -707,7 +702,6 @@ static struct i2c_driver ak4642_i2c_driver = { ...@@ -707,7 +702,6 @@ static struct i2c_driver ak4642_i2c_driver = {
.of_match_table = ak4642_of_match, .of_match_table = ak4642_of_match,
}, },
.probe = ak4642_i2c_probe, .probe = ak4642_i2c_probe,
.remove = ak4642_i2c_remove,
.id_table = ak4642_i2c_id, .id_table = ak4642_i2c_id,
}; };
......
...@@ -163,15 +163,15 @@ static const struct snd_kcontrol_new ak4671_snd_controls[] = { ...@@ -163,15 +163,15 @@ static const struct snd_kcontrol_new ak4671_snd_controls[] = {
static int ak4671_out2_event(struct snd_soc_dapm_widget *w, static int ak4671_out2_event(struct snd_soc_dapm_widget *w,
struct snd_kcontrol *kcontrol, int event) 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) { switch (event) {
case SND_SOC_DAPM_POST_PMU: case SND_SOC_DAPM_POST_PMU:
snd_soc_update_bits(codec, AK4671_LOUT2_POWER_MANAGERMENT, snd_soc_component_update_bits(component, AK4671_LOUT2_POWER_MANAGERMENT,
AK4671_MUTEN, AK4671_MUTEN); AK4671_MUTEN, AK4671_MUTEN);
break; break;
case SND_SOC_DAPM_PRE_PMD: case SND_SOC_DAPM_PRE_PMD:
snd_soc_update_bits(codec, AK4671_LOUT2_POWER_MANAGERMENT, snd_soc_component_update_bits(component, AK4671_LOUT2_POWER_MANAGERMENT,
AK4671_MUTEN, 0); AK4671_MUTEN, 0);
break; break;
} }
...@@ -427,10 +427,10 @@ static int ak4671_hw_params(struct snd_pcm_substream *substream, ...@@ -427,10 +427,10 @@ static int ak4671_hw_params(struct snd_pcm_substream *substream,
struct snd_pcm_hw_params *params, struct snd_pcm_hw_params *params,
struct snd_soc_dai *dai) struct snd_soc_dai *dai)
{ {
struct snd_soc_codec *codec = dai->codec; struct snd_soc_component *component = dai->component;
u8 fs; u8 fs;
fs = snd_soc_read(codec, AK4671_PLL_MODE_SELECT0); fs = snd_soc_component_read32(component, AK4671_PLL_MODE_SELECT0);
fs &= ~AK4671_FS; fs &= ~AK4671_FS;
switch (params_rate(params)) { switch (params_rate(params)) {
...@@ -465,7 +465,7 @@ static int ak4671_hw_params(struct snd_pcm_substream *substream, ...@@ -465,7 +465,7 @@ static int ak4671_hw_params(struct snd_pcm_substream *substream,
return -EINVAL; return -EINVAL;
} }
snd_soc_write(codec, AK4671_PLL_MODE_SELECT0, fs); snd_soc_component_write(component, AK4671_PLL_MODE_SELECT0, fs);
return 0; return 0;
} }
...@@ -473,10 +473,10 @@ static int ak4671_hw_params(struct snd_pcm_substream *substream, ...@@ -473,10 +473,10 @@ static int ak4671_hw_params(struct snd_pcm_substream *substream,
static int ak4671_set_dai_sysclk(struct snd_soc_dai *dai, int clk_id, static int ak4671_set_dai_sysclk(struct snd_soc_dai *dai, int clk_id,
unsigned int freq, int dir) unsigned int freq, int dir)
{ {
struct snd_soc_codec *codec = dai->codec; struct snd_soc_component *component = dai->component;
u8 pll; u8 pll;
pll = snd_soc_read(codec, AK4671_PLL_MODE_SELECT0); pll = snd_soc_component_read32(component, AK4671_PLL_MODE_SELECT0);
pll &= ~AK4671_PLL; pll &= ~AK4671_PLL;
switch (freq) { switch (freq) {
...@@ -511,19 +511,19 @@ static int ak4671_set_dai_sysclk(struct snd_soc_dai *dai, int clk_id, ...@@ -511,19 +511,19 @@ static int ak4671_set_dai_sysclk(struct snd_soc_dai *dai, int clk_id,
return -EINVAL; return -EINVAL;
} }
snd_soc_write(codec, AK4671_PLL_MODE_SELECT0, pll); snd_soc_component_write(component, AK4671_PLL_MODE_SELECT0, pll);
return 0; return 0;
} }
static int ak4671_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt) static int ak4671_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;
u8 mode; u8 mode;
u8 format; u8 format;
/* set master/slave audio interface */ /* set master/slave audio interface */
mode = snd_soc_read(codec, AK4671_PLL_MODE_SELECT1); mode = snd_soc_component_read32(component, AK4671_PLL_MODE_SELECT1);
switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) {
case SND_SOC_DAIFMT_CBM_CFM: case SND_SOC_DAIFMT_CBM_CFM:
...@@ -537,7 +537,7 @@ static int ak4671_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt) ...@@ -537,7 +537,7 @@ static int ak4671_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt)
} }
/* interface format */ /* interface format */
format = snd_soc_read(codec, AK4671_FORMAT_SELECT); format = snd_soc_component_read32(component, AK4671_FORMAT_SELECT);
format &= ~AK4671_DIF; format &= ~AK4671_DIF;
switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) { switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) {
...@@ -557,24 +557,24 @@ static int ak4671_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt) ...@@ -557,24 +557,24 @@ static int ak4671_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt)
} }
/* set mode and format */ /* set mode and format */
snd_soc_write(codec, AK4671_PLL_MODE_SELECT1, mode); snd_soc_component_write(component, AK4671_PLL_MODE_SELECT1, mode);
snd_soc_write(codec, AK4671_FORMAT_SELECT, format); snd_soc_component_write(component, AK4671_FORMAT_SELECT, format);
return 0; return 0;
} }
static int ak4671_set_bias_level(struct snd_soc_codec *codec, static int ak4671_set_bias_level(struct snd_soc_component *component,
enum snd_soc_bias_level level) enum snd_soc_bias_level level)
{ {
switch (level) { switch (level) {
case SND_SOC_BIAS_ON: case SND_SOC_BIAS_ON:
case SND_SOC_BIAS_PREPARE: case SND_SOC_BIAS_PREPARE:
case SND_SOC_BIAS_STANDBY: case SND_SOC_BIAS_STANDBY:
snd_soc_update_bits(codec, AK4671_AD_DA_POWER_MANAGEMENT, snd_soc_component_update_bits(component, AK4671_AD_DA_POWER_MANAGEMENT,
AK4671_PMVCM, AK4671_PMVCM); AK4671_PMVCM, AK4671_PMVCM);
break; break;
case SND_SOC_BIAS_OFF: case SND_SOC_BIAS_OFF:
snd_soc_write(codec, AK4671_AD_DA_POWER_MANAGEMENT, 0x00); snd_soc_component_write(component, AK4671_AD_DA_POWER_MANAGEMENT, 0x00);
break; break;
} }
return 0; return 0;
...@@ -610,16 +610,18 @@ static struct snd_soc_dai_driver ak4671_dai = { ...@@ -610,16 +610,18 @@ static struct snd_soc_dai_driver ak4671_dai = {
.ops = &ak4671_dai_ops, .ops = &ak4671_dai_ops,
}; };
static const struct snd_soc_codec_driver soc_codec_dev_ak4671 = { static const struct snd_soc_component_driver soc_component_dev_ak4671 = {
.set_bias_level = ak4671_set_bias_level, .set_bias_level = ak4671_set_bias_level,
.component_driver = { .controls = ak4671_snd_controls,
.controls = ak4671_snd_controls, .num_controls = ARRAY_SIZE(ak4671_snd_controls),
.num_controls = ARRAY_SIZE(ak4671_snd_controls), .dapm_widgets = ak4671_dapm_widgets,
.dapm_widgets = ak4671_dapm_widgets, .num_dapm_widgets = ARRAY_SIZE(ak4671_dapm_widgets),
.num_dapm_widgets = ARRAY_SIZE(ak4671_dapm_widgets), .dapm_routes = ak4671_intercon,
.dapm_routes = ak4671_intercon, .num_dapm_routes = ARRAY_SIZE(ak4671_intercon),
.num_dapm_routes = ARRAY_SIZE(ak4671_intercon), .idle_bias_on = 1,
}, .use_pmdown_time = 1,
.endianness = 1,
.non_legacy_dai_naming = 1,
}; };
static const struct regmap_config ak4671_regmap = { static const struct regmap_config ak4671_regmap = {
...@@ -645,17 +647,11 @@ static int ak4671_i2c_probe(struct i2c_client *client, ...@@ -645,17 +647,11 @@ static int ak4671_i2c_probe(struct i2c_client *client,
return ret; return ret;
} }
ret = snd_soc_register_codec(&client->dev, ret = devm_snd_soc_register_component(&client->dev,
&soc_codec_dev_ak4671, &ak4671_dai, 1); &soc_component_dev_ak4671, &ak4671_dai, 1);
return ret; return ret;
} }
static int ak4671_i2c_remove(struct i2c_client *client)
{
snd_soc_unregister_codec(&client->dev);
return 0;
}
static const struct i2c_device_id ak4671_i2c_id[] = { static const struct i2c_device_id ak4671_i2c_id[] = {
{ "ak4671", 0 }, { "ak4671", 0 },
{ } { }
...@@ -667,7 +663,6 @@ static struct i2c_driver ak4671_i2c_driver = { ...@@ -667,7 +663,6 @@ static struct i2c_driver ak4671_i2c_driver = {
.name = "ak4671-codec", .name = "ak4671-codec",
}, },
.probe = ak4671_i2c_probe, .probe = ak4671_i2c_probe,
.remove = ak4671_i2c_remove,
.id_table = ak4671_i2c_id, .id_table = ak4671_i2c_id,
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment