Commit cce67af3 authored by Mark Brown's avatar Mark Brown

Merge remote-tracking branches 'asoc/topic/88pm860x', 'asoc/topic/ab8500',...

Merge remote-tracking branches 'asoc/topic/88pm860x', 'asoc/topic/ab8500', 'asoc/topic/ac97', 'asoc/topic/ad1836' and 'asoc/topic/ad193x' into asoc-next
...@@ -586,10 +586,17 @@ int snd_soc_test_bits(struct snd_soc_codec *codec, unsigned int reg, ...@@ -586,10 +586,17 @@ int snd_soc_test_bits(struct snd_soc_codec *codec, unsigned int reg,
unsigned int mask, unsigned int value); unsigned int mask, unsigned int value);
#ifdef CONFIG_SND_SOC_AC97_BUS #ifdef CONFIG_SND_SOC_AC97_BUS
struct snd_ac97 *snd_soc_alloc_ac97_codec(struct snd_soc_codec *codec); #define snd_soc_alloc_ac97_codec(codec) \
struct snd_ac97 *snd_soc_new_ac97_codec(struct snd_soc_codec *codec, snd_soc_alloc_ac97_component(&codec->component)
#define snd_soc_new_ac97_codec(codec, id, id_mask) \
snd_soc_new_ac97_component(&codec->component, id, id_mask)
#define snd_soc_free_ac97_codec(ac97) \
snd_soc_free_ac97_component(ac97)
struct snd_ac97 *snd_soc_alloc_ac97_component(struct snd_soc_component *component);
struct snd_ac97 *snd_soc_new_ac97_component(struct snd_soc_component *component,
unsigned int id, unsigned int id_mask); unsigned int id, unsigned int id_mask);
void snd_soc_free_ac97_codec(struct snd_ac97 *ac97); void snd_soc_free_ac97_component(struct snd_ac97 *ac97);
int snd_soc_set_ac97_ops(struct snd_ac97_bus_ops *ops); int snd_soc_set_ac97_ops(struct snd_ac97_bus_ops *ops);
int snd_soc_set_ac97_ops_of_reset(struct snd_ac97_bus_ops *ops, int snd_soc_set_ac97_ops_of_reset(struct snd_ac97_bus_ops *ops,
......
This diff is collapsed.
...@@ -88,9 +88,9 @@ ...@@ -88,9 +88,9 @@
#define PM860X_SHORT_LINEOUT (1 << 4) #define PM860X_SHORT_LINEOUT (1 << 4)
#define PM860X_DET_MASK 0x1F #define PM860X_DET_MASK 0x1F
extern int pm860x_hs_jack_detect(struct snd_soc_codec *, struct snd_soc_jack *, extern int pm860x_hs_jack_detect(struct snd_soc_component *, struct snd_soc_jack *,
int, int, int, int); int, int, int, int);
extern int pm860x_mic_jack_detect(struct snd_soc_codec *, struct snd_soc_jack *, extern int pm860x_mic_jack_detect(struct snd_soc_component *, struct snd_soc_jack *,
int); int);
#endif /* __88PM860X_H */ #endif /* __88PM860X_H */
This diff is collapsed.
...@@ -36,8 +36,8 @@ static const struct snd_soc_dapm_route ac97_routes[] = { ...@@ -36,8 +36,8 @@ static const struct snd_soc_dapm_route ac97_routes[] = {
static int ac97_prepare(struct snd_pcm_substream *substream, static int ac97_prepare(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 snd_ac97 *ac97 = snd_soc_codec_get_drvdata(codec); struct snd_ac97 *ac97 = snd_soc_component_get_drvdata(component);
int reg = (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) ? int reg = (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) ?
AC97_PCM_FRONT_DAC_RATE : AC97_PCM_LR_ADC_RATE; AC97_PCM_FRONT_DAC_RATE : AC97_PCM_LR_ADC_RATE;
...@@ -65,7 +65,7 @@ static struct snd_soc_dai_driver ac97_dai = { ...@@ -65,7 +65,7 @@ static struct snd_soc_dai_driver ac97_dai = {
.ops = &ac97_dai_ops, .ops = &ac97_dai_ops,
}; };
static int ac97_soc_probe(struct snd_soc_codec *codec) static int ac97_soc_probe(struct snd_soc_component *component)
{ {
struct snd_ac97 *ac97; struct snd_ac97 *ac97;
struct snd_ac97_bus *ac97_bus; struct snd_ac97_bus *ac97_bus;
...@@ -73,7 +73,7 @@ static int ac97_soc_probe(struct snd_soc_codec *codec) ...@@ -73,7 +73,7 @@ static int ac97_soc_probe(struct snd_soc_codec *codec)
int ret; int ret;
/* add codec as bus device for standard ac97 */ /* add codec as bus device for standard ac97 */
ret = snd_ac97_bus(codec->component.card->snd_card, 0, soc_ac97_ops, ret = snd_ac97_bus(component->card->snd_card, 0, soc_ac97_ops,
NULL, &ac97_bus); NULL, &ac97_bus);
if (ret < 0) if (ret < 0)
return ret; return ret;
...@@ -83,25 +83,25 @@ static int ac97_soc_probe(struct snd_soc_codec *codec) ...@@ -83,25 +83,25 @@ static int ac97_soc_probe(struct snd_soc_codec *codec)
if (ret < 0) if (ret < 0)
return ret; return ret;
snd_soc_codec_set_drvdata(codec, ac97); snd_soc_component_set_drvdata(component, ac97);
return 0; return 0;
} }
#ifdef CONFIG_PM #ifdef CONFIG_PM
static int ac97_soc_suspend(struct snd_soc_codec *codec) static int ac97_soc_suspend(struct snd_soc_component *component)
{ {
struct snd_ac97 *ac97 = snd_soc_codec_get_drvdata(codec); struct snd_ac97 *ac97 = snd_soc_component_get_drvdata(component);
snd_ac97_suspend(ac97); snd_ac97_suspend(ac97);
return 0; return 0;
} }
static int ac97_soc_resume(struct snd_soc_codec *codec) static int ac97_soc_resume(struct snd_soc_component *component)
{ {
struct snd_ac97 *ac97 = snd_soc_codec_get_drvdata(codec); struct snd_ac97 *ac97 = snd_soc_component_get_drvdata(component);
snd_ac97_resume(ac97); snd_ac97_resume(ac97);
...@@ -112,28 +112,28 @@ static int ac97_soc_resume(struct snd_soc_codec *codec) ...@@ -112,28 +112,28 @@ static int ac97_soc_resume(struct snd_soc_codec *codec)
#define ac97_soc_resume NULL #define ac97_soc_resume NULL
#endif #endif
static const struct snd_soc_codec_driver soc_codec_dev_ac97 = { static const struct snd_soc_component_driver soc_component_dev_ac97 = {
.probe = ac97_soc_probe, .probe = ac97_soc_probe,
.suspend = ac97_soc_suspend, .suspend = ac97_soc_suspend,
.resume = ac97_soc_resume, .resume = ac97_soc_resume,
.component_driver = {
.dapm_widgets = ac97_widgets, .dapm_widgets = ac97_widgets,
.num_dapm_widgets = ARRAY_SIZE(ac97_widgets), .num_dapm_widgets = ARRAY_SIZE(ac97_widgets),
.dapm_routes = ac97_routes, .dapm_routes = ac97_routes,
.num_dapm_routes = ARRAY_SIZE(ac97_routes), .num_dapm_routes = ARRAY_SIZE(ac97_routes),
}, .idle_bias_on = 1,
.use_pmdown_time = 1,
.endianness = 1,
.non_legacy_dai_naming = 1,
}; };
static int ac97_probe(struct platform_device *pdev) static int ac97_probe(struct platform_device *pdev)
{ {
return snd_soc_register_codec(&pdev->dev, return devm_snd_soc_register_component(&pdev->dev,
&soc_codec_dev_ac97, &ac97_dai, 1); &soc_component_dev_ac97, &ac97_dai, 1);
} }
static int ac97_remove(struct platform_device *pdev) static int ac97_remove(struct platform_device *pdev)
{ {
snd_soc_unregister_codec(&pdev->dev);
return 0; return 0;
} }
......
...@@ -164,7 +164,7 @@ static int ad1836_hw_params(struct snd_pcm_substream *substream, ...@@ -164,7 +164,7 @@ static int ad1836_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 ad1836_priv *ad1836 = snd_soc_codec_get_drvdata(dai->codec); struct ad1836_priv *ad1836 = snd_soc_component_get_drvdata(dai->component);
int word_len = 0; int word_len = 0;
/* bit size */ /* bit size */
...@@ -228,17 +228,17 @@ static struct snd_soc_dai_driver ad183x_dais[] = { ...@@ -228,17 +228,17 @@ static struct snd_soc_dai_driver ad183x_dais[] = {
}; };
#ifdef CONFIG_PM #ifdef CONFIG_PM
static int ad1836_suspend(struct snd_soc_codec *codec) static int ad1836_suspend(struct snd_soc_component *component)
{ {
struct ad1836_priv *ad1836 = snd_soc_codec_get_drvdata(codec); struct ad1836_priv *ad1836 = snd_soc_component_get_drvdata(component);
/* reset clock control mode */ /* reset clock control mode */
return regmap_update_bits(ad1836->regmap, AD1836_ADC_CTRL2, return regmap_update_bits(ad1836->regmap, AD1836_ADC_CTRL2,
AD1836_ADC_SERFMT_MASK, 0); AD1836_ADC_SERFMT_MASK, 0);
} }
static int ad1836_resume(struct snd_soc_codec *codec) static int ad1836_resume(struct snd_soc_component *component)
{ {
struct ad1836_priv *ad1836 = snd_soc_codec_get_drvdata(codec); struct ad1836_priv *ad1836 = snd_soc_component_get_drvdata(component);
/* restore clock control mode */ /* restore clock control mode */
return regmap_update_bits(ad1836->regmap, AD1836_ADC_CTRL2, return regmap_update_bits(ad1836->regmap, AD1836_ADC_CTRL2,
AD1836_ADC_SERFMT_MASK, AD1836_ADC_AUX); AD1836_ADC_SERFMT_MASK, AD1836_ADC_AUX);
...@@ -248,10 +248,10 @@ static int ad1836_resume(struct snd_soc_codec *codec) ...@@ -248,10 +248,10 @@ static int ad1836_resume(struct snd_soc_codec *codec)
#define ad1836_resume NULL #define ad1836_resume NULL
#endif #endif
static int ad1836_probe(struct snd_soc_codec *codec) static int ad1836_probe(struct snd_soc_component *component)
{ {
struct ad1836_priv *ad1836 = snd_soc_codec_get_drvdata(codec); struct ad1836_priv *ad1836 = snd_soc_component_get_drvdata(component);
struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec); struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component);
int num_dacs, num_adcs; int num_dacs, num_adcs;
int ret = 0; int ret = 0;
int i; int i;
...@@ -277,7 +277,7 @@ static int ad1836_probe(struct snd_soc_codec *codec) ...@@ -277,7 +277,7 @@ static int ad1836_probe(struct snd_soc_codec *codec)
if (ad1836->type == AD1836) { if (ad1836->type == AD1836) {
/* left/right diff:PGA/MUX */ /* left/right diff:PGA/MUX */
regmap_write(ad1836->regmap, AD1836_ADC_CTRL3, 0x3A); regmap_write(ad1836->regmap, AD1836_ADC_CTRL3, 0x3A);
ret = snd_soc_add_codec_controls(codec, ad1836_controls, ret = snd_soc_add_component_controls(component, ad1836_controls,
ARRAY_SIZE(ad1836_controls)); ARRAY_SIZE(ad1836_controls));
if (ret) if (ret)
return ret; return ret;
...@@ -285,11 +285,11 @@ static int ad1836_probe(struct snd_soc_codec *codec) ...@@ -285,11 +285,11 @@ static int ad1836_probe(struct snd_soc_codec *codec)
regmap_write(ad1836->regmap, AD1836_ADC_CTRL3, 0x00); regmap_write(ad1836->regmap, AD1836_ADC_CTRL3, 0x00);
} }
ret = snd_soc_add_codec_controls(codec, ad183x_dac_controls, num_dacs * 2); ret = snd_soc_add_component_controls(component, ad183x_dac_controls, num_dacs * 2);
if (ret) if (ret)
return ret; return ret;
ret = snd_soc_add_codec_controls(codec, ad183x_adc_controls, num_adcs); ret = snd_soc_add_component_controls(component, ad183x_adc_controls, num_adcs);
if (ret) if (ret)
return ret; return ret;
...@@ -313,28 +313,29 @@ static int ad1836_probe(struct snd_soc_codec *codec) ...@@ -313,28 +313,29 @@ static int ad1836_probe(struct snd_soc_codec *codec)
} }
/* power down chip */ /* power down chip */
static int ad1836_remove(struct snd_soc_codec *codec) static void ad1836_remove(struct snd_soc_component *component)
{ {
struct ad1836_priv *ad1836 = snd_soc_codec_get_drvdata(codec); struct ad1836_priv *ad1836 = snd_soc_component_get_drvdata(component);
/* reset clock control mode */ /* reset clock control mode */
return regmap_update_bits(ad1836->regmap, AD1836_ADC_CTRL2, regmap_update_bits(ad1836->regmap, AD1836_ADC_CTRL2,
AD1836_ADC_SERFMT_MASK, 0); AD1836_ADC_SERFMT_MASK, 0);
} }
static const struct snd_soc_codec_driver soc_codec_dev_ad1836 = { static const struct snd_soc_component_driver soc_component_dev_ad1836 = {
.probe = ad1836_probe, .probe = ad1836_probe,
.remove = ad1836_remove, .remove = ad1836_remove,
.suspend = ad1836_suspend, .suspend = ad1836_suspend,
.resume = ad1836_resume, .resume = ad1836_resume,
.component_driver = {
.controls = ad183x_controls, .controls = ad183x_controls,
.num_controls = ARRAY_SIZE(ad183x_controls), .num_controls = ARRAY_SIZE(ad183x_controls),
.dapm_widgets = ad183x_dapm_widgets, .dapm_widgets = ad183x_dapm_widgets,
.num_dapm_widgets = ARRAY_SIZE(ad183x_dapm_widgets), .num_dapm_widgets = ARRAY_SIZE(ad183x_dapm_widgets),
.dapm_routes = ad183x_dapm_routes, .dapm_routes = ad183x_dapm_routes,
.num_dapm_routes = ARRAY_SIZE(ad183x_dapm_routes), .num_dapm_routes = ARRAY_SIZE(ad183x_dapm_routes),
}, .idle_bias_on = 1,
.use_pmdown_time = 1,
.endianness = 1,
.non_legacy_dai_naming = 1,
}; };
static const struct reg_default ad1836_reg_defaults[] = { static const struct reg_default ad1836_reg_defaults[] = {
...@@ -382,17 +383,11 @@ static int ad1836_spi_probe(struct spi_device *spi) ...@@ -382,17 +383,11 @@ static int ad1836_spi_probe(struct spi_device *spi)
spi_set_drvdata(spi, ad1836); spi_set_drvdata(spi, ad1836);
ret = snd_soc_register_codec(&spi->dev, ret = devm_snd_soc_register_component(&spi->dev,
&soc_codec_dev_ad1836, &ad183x_dais[ad1836->type], 1); &soc_component_dev_ad1836, &ad183x_dais[ad1836->type], 1);
return ret; return ret;
} }
static int ad1836_spi_remove(struct spi_device *spi)
{
snd_soc_unregister_codec(&spi->dev);
return 0;
}
static const struct spi_device_id ad1836_ids[] = { static const struct spi_device_id ad1836_ids[] = {
{ "ad1835", AD1835 }, { "ad1835", AD1835 },
{ "ad1836", AD1836 }, { "ad1836", AD1836 },
...@@ -408,7 +403,6 @@ static struct spi_driver ad1836_spi_driver = { ...@@ -408,7 +403,6 @@ static struct spi_driver ad1836_spi_driver = {
.name = "ad1836", .name = "ad1836",
}, },
.probe = ad1836_spi_probe, .probe = ad1836_spi_probe,
.remove = ad1836_spi_remove,
.id_table = ad1836_ids, .id_table = ad1836_ids,
}; };
......
...@@ -35,18 +35,11 @@ static int ad193x_i2c_probe(struct i2c_client *client, ...@@ -35,18 +35,11 @@ static int ad193x_i2c_probe(struct i2c_client *client,
(enum ad193x_type)id->driver_data); (enum ad193x_type)id->driver_data);
} }
static int ad193x_i2c_remove(struct i2c_client *client)
{
snd_soc_unregister_codec(&client->dev);
return 0;
}
static struct i2c_driver ad193x_i2c_driver = { static struct i2c_driver ad193x_i2c_driver = {
.driver = { .driver = {
.name = "ad193x", .name = "ad193x",
}, },
.probe = ad193x_i2c_probe, .probe = ad193x_i2c_probe,
.remove = ad193x_i2c_remove,
.id_table = ad193x_id, .id_table = ad193x_id,
}; };
module_i2c_driver(ad193x_i2c_driver); module_i2c_driver(ad193x_i2c_driver);
......
...@@ -29,12 +29,6 @@ static int ad193x_spi_probe(struct spi_device *spi) ...@@ -29,12 +29,6 @@ static int ad193x_spi_probe(struct spi_device *spi)
(enum ad193x_type)id->driver_data); (enum ad193x_type)id->driver_data);
} }
static int ad193x_spi_remove(struct spi_device *spi)
{
snd_soc_unregister_codec(&spi->dev);
return 0;
}
static const struct spi_device_id ad193x_spi_id[] = { static const struct spi_device_id ad193x_spi_id[] = {
{ "ad193x", AD193X }, { "ad193x", AD193X },
{ "ad1933", AD1933 }, { "ad1933", AD1933 },
...@@ -51,7 +45,6 @@ static struct spi_driver ad193x_spi_driver = { ...@@ -51,7 +45,6 @@ static struct spi_driver ad193x_spi_driver = {
.name = "ad193x", .name = "ad193x",
}, },
.probe = ad193x_spi_probe, .probe = ad193x_spi_probe,
.remove = ad193x_spi_remove,
.id_table = ad193x_spi_id, .id_table = ad193x_spi_id,
}; };
module_spi_driver(ad193x_spi_driver); module_spi_driver(ad193x_spi_driver);
......
...@@ -130,7 +130,7 @@ static inline bool ad193x_has_adc(const struct ad193x_priv *ad193x) ...@@ -130,7 +130,7 @@ static inline bool ad193x_has_adc(const struct ad193x_priv *ad193x)
static int ad193x_mute(struct snd_soc_dai *dai, int mute) static int ad193x_mute(struct snd_soc_dai *dai, int mute)
{ {
struct ad193x_priv *ad193x = snd_soc_codec_get_drvdata(dai->codec); struct ad193x_priv *ad193x = snd_soc_component_get_drvdata(dai->component);
if (mute) if (mute)
regmap_update_bits(ad193x->regmap, AD193X_DAC_CTRL2, regmap_update_bits(ad193x->regmap, AD193X_DAC_CTRL2,
...@@ -146,7 +146,7 @@ static int ad193x_mute(struct snd_soc_dai *dai, int mute) ...@@ -146,7 +146,7 @@ static int ad193x_mute(struct snd_soc_dai *dai, int mute)
static int ad193x_set_tdm_slot(struct snd_soc_dai *dai, unsigned int tx_mask, static int ad193x_set_tdm_slot(struct snd_soc_dai *dai, unsigned int tx_mask,
unsigned int rx_mask, int slots, int width) unsigned int rx_mask, int slots, int width)
{ {
struct ad193x_priv *ad193x = snd_soc_codec_get_drvdata(dai->codec); struct ad193x_priv *ad193x = snd_soc_component_get_drvdata(dai->component);
unsigned int channels; unsigned int channels;
switch (slots) { switch (slots) {
...@@ -179,7 +179,7 @@ static int ad193x_set_tdm_slot(struct snd_soc_dai *dai, unsigned int tx_mask, ...@@ -179,7 +179,7 @@ static int ad193x_set_tdm_slot(struct snd_soc_dai *dai, unsigned int tx_mask,
static int ad193x_set_dai_fmt(struct snd_soc_dai *codec_dai, static int ad193x_set_dai_fmt(struct snd_soc_dai *codec_dai,
unsigned int fmt) unsigned int fmt)
{ {
struct ad193x_priv *ad193x = snd_soc_codec_get_drvdata(codec_dai->codec); struct ad193x_priv *ad193x = snd_soc_component_get_drvdata(codec_dai->component);
unsigned int adc_serfmt = 0; unsigned int adc_serfmt = 0;
unsigned int adc_fmt = 0; unsigned int adc_fmt = 0;
unsigned int dac_fmt = 0; unsigned int dac_fmt = 0;
...@@ -257,8 +257,8 @@ static int ad193x_set_dai_fmt(struct snd_soc_dai *codec_dai, ...@@ -257,8 +257,8 @@ static int ad193x_set_dai_fmt(struct snd_soc_dai *codec_dai,
static int ad193x_set_dai_sysclk(struct snd_soc_dai *codec_dai, static int ad193x_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 ad193x_priv *ad193x = snd_soc_codec_get_drvdata(codec); struct ad193x_priv *ad193x = snd_soc_component_get_drvdata(component);
switch (freq) { switch (freq) {
case 12288000: case 12288000:
case 18432000: case 18432000:
...@@ -275,8 +275,8 @@ static int ad193x_hw_params(struct snd_pcm_substream *substream, ...@@ -275,8 +275,8 @@ static int ad193x_hw_params(struct snd_pcm_substream *substream,
struct snd_soc_dai *dai) struct snd_soc_dai *dai)
{ {
int word_len = 0, master_rate = 0; int word_len = 0, master_rate = 0;
struct snd_soc_codec *codec = dai->codec; struct snd_soc_component *component = dai->component;
struct ad193x_priv *ad193x = snd_soc_codec_get_drvdata(codec); struct ad193x_priv *ad193x = snd_soc_component_get_drvdata(component);
/* bit size */ /* bit size */
switch (params_width(params)) { switch (params_width(params)) {
...@@ -351,10 +351,10 @@ static struct snd_soc_dai_driver ad193x_dai = { ...@@ -351,10 +351,10 @@ static struct snd_soc_dai_driver ad193x_dai = {
.ops = &ad193x_dai_ops, .ops = &ad193x_dai_ops,
}; };
static int ad193x_codec_probe(struct snd_soc_codec *codec) static int ad193x_component_probe(struct snd_soc_component *component)
{ {
struct ad193x_priv *ad193x = snd_soc_codec_get_drvdata(codec); struct ad193x_priv *ad193x = snd_soc_component_get_drvdata(component);
struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec); struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component);
int num, ret; int num, ret;
/* default setting for ad193x */ /* default setting for ad193x */
...@@ -382,7 +382,7 @@ static int ad193x_codec_probe(struct snd_soc_codec *codec) ...@@ -382,7 +382,7 @@ static int ad193x_codec_probe(struct snd_soc_codec *codec)
if (ad193x_has_adc(ad193x)) { if (ad193x_has_adc(ad193x)) {
/* add adc controls */ /* add adc controls */
num = ARRAY_SIZE(ad193x_adc_snd_controls); num = ARRAY_SIZE(ad193x_adc_snd_controls);
ret = snd_soc_add_codec_controls(codec, ret = snd_soc_add_component_controls(component,
ad193x_adc_snd_controls, ad193x_adc_snd_controls,
num); num);
if (ret) if (ret)
...@@ -408,16 +408,18 @@ static int ad193x_codec_probe(struct snd_soc_codec *codec) ...@@ -408,16 +408,18 @@ static int ad193x_codec_probe(struct snd_soc_codec *codec)
return 0; return 0;
} }
static const struct snd_soc_codec_driver soc_codec_dev_ad193x = { static const struct snd_soc_component_driver soc_component_dev_ad193x = {
.probe = ad193x_codec_probe, .probe = ad193x_component_probe,
.component_driver = {
.controls = ad193x_snd_controls, .controls = ad193x_snd_controls,
.num_controls = ARRAY_SIZE(ad193x_snd_controls), .num_controls = ARRAY_SIZE(ad193x_snd_controls),
.dapm_widgets = ad193x_dapm_widgets, .dapm_widgets = ad193x_dapm_widgets,
.num_dapm_widgets = ARRAY_SIZE(ad193x_dapm_widgets), .num_dapm_widgets = ARRAY_SIZE(ad193x_dapm_widgets),
.dapm_routes = audio_paths, .dapm_routes = audio_paths,
.num_dapm_routes = ARRAY_SIZE(audio_paths), .num_dapm_routes = ARRAY_SIZE(audio_paths),
}, .idle_bias_on = 1,
.use_pmdown_time = 1,
.endianness = 1,
.non_legacy_dai_naming = 1,
}; };
const struct regmap_config ad193x_regmap_config = { const struct regmap_config ad193x_regmap_config = {
...@@ -442,7 +444,7 @@ int ad193x_probe(struct device *dev, struct regmap *regmap, ...@@ -442,7 +444,7 @@ int ad193x_probe(struct device *dev, struct regmap *regmap,
dev_set_drvdata(dev, ad193x); dev_set_drvdata(dev, ad193x);
return snd_soc_register_codec(dev, &soc_codec_dev_ad193x, return devm_snd_soc_register_component(dev, &soc_component_dev_ad193x,
&ad193x_dai, 1); &ad193x_dai, 1);
} }
EXPORT_SYMBOL_GPL(ad193x_probe); EXPORT_SYMBOL_GPL(ad193x_probe);
......
...@@ -205,9 +205,9 @@ static struct snd_soc_dai_driver ad1980_dai = { ...@@ -205,9 +205,9 @@ static struct snd_soc_dai_driver ad1980_dai = {
#define AD1980_VENDOR_ID 0x41445300 #define AD1980_VENDOR_ID 0x41445300
#define AD1980_VENDOR_MASK 0xffffff00 #define AD1980_VENDOR_MASK 0xffffff00
static int ad1980_reset(struct snd_soc_codec *codec, int try_warm) static int ad1980_reset(struct snd_soc_component *component, int try_warm)
{ {
struct snd_ac97 *ac97 = snd_soc_codec_get_drvdata(codec); struct snd_ac97 *ac97 = snd_soc_component_get_drvdata(component);
unsigned int retry_cnt = 0; unsigned int retry_cnt = 0;
int ret; int ret;
...@@ -223,16 +223,16 @@ static int ad1980_reset(struct snd_soc_codec *codec, int try_warm) ...@@ -223,16 +223,16 @@ static int ad1980_reset(struct snd_soc_codec *codec, int try_warm)
* case the first nibble of data is eaten by the addr. (Tag is * case the first nibble of data is eaten by the addr. (Tag is
* always 16 bit) * always 16 bit)
*/ */
snd_soc_write(codec, AC97_AD_SERIAL_CFG, 0x9900); snd_soc_component_write(component, AC97_AD_SERIAL_CFG, 0x9900);
} while (retry_cnt++ < 10); } while (retry_cnt++ < 10);
dev_err(codec->dev, "Failed to reset: AC97 link error\n"); dev_err(component->dev, "Failed to reset: AC97 link error\n");
return -EIO; return -EIO;
} }
static int ad1980_soc_probe(struct snd_soc_codec *codec) static int ad1980_soc_probe(struct snd_soc_component *component)
{ {
struct snd_ac97 *ac97; struct snd_ac97 *ac97;
struct regmap *regmap; struct regmap *regmap;
...@@ -240,10 +240,10 @@ static int ad1980_soc_probe(struct snd_soc_codec *codec) ...@@ -240,10 +240,10 @@ static int ad1980_soc_probe(struct snd_soc_codec *codec)
u16 vendor_id2; u16 vendor_id2;
u16 ext_status; u16 ext_status;
ac97 = snd_soc_new_ac97_codec(codec, 0, 0); ac97 = snd_soc_new_ac97_component(component, 0, 0);
if (IS_ERR(ac97)) { if (IS_ERR(ac97)) {
ret = PTR_ERR(ac97); ret = PTR_ERR(ac97);
dev_err(codec->dev, "Failed to register AC97 codec: %d\n", ret); dev_err(component->dev, "Failed to register AC97 component: %d\n", ret);
return ret; return ret;
} }
...@@ -253,72 +253,66 @@ static int ad1980_soc_probe(struct snd_soc_codec *codec) ...@@ -253,72 +253,66 @@ static int ad1980_soc_probe(struct snd_soc_codec *codec)
goto err_free_ac97; goto err_free_ac97;
} }
snd_soc_codec_init_regmap(codec, regmap); snd_soc_component_init_regmap(component, regmap);
snd_soc_codec_set_drvdata(codec, ac97); snd_soc_component_set_drvdata(component, ac97);
ret = ad1980_reset(codec, 0); ret = ad1980_reset(component, 0);
if (ret < 0) if (ret < 0)
goto reset_err; goto reset_err;
vendor_id2 = snd_soc_read(codec, AC97_VENDOR_ID2); vendor_id2 = snd_soc_component_read32(component, AC97_VENDOR_ID2);
if (vendor_id2 == 0x5374) { if (vendor_id2 == 0x5374) {
dev_warn(codec->dev, dev_warn(component->dev,
"Found AD1981 - only 2/2 IN/OUT Channels supported\n"); "Found AD1981 - only 2/2 IN/OUT Channels supported\n");
} }
/* unmute captures and playbacks volume */ /* unmute captures and playbacks volume */
snd_soc_write(codec, AC97_MASTER, 0x0000); snd_soc_component_write(component, AC97_MASTER, 0x0000);
snd_soc_write(codec, AC97_PCM, 0x0000); snd_soc_component_write(component, AC97_PCM, 0x0000);
snd_soc_write(codec, AC97_REC_GAIN, 0x0000); snd_soc_component_write(component, AC97_REC_GAIN, 0x0000);
snd_soc_write(codec, AC97_CENTER_LFE_MASTER, 0x0000); snd_soc_component_write(component, AC97_CENTER_LFE_MASTER, 0x0000);
snd_soc_write(codec, AC97_SURROUND_MASTER, 0x0000); snd_soc_component_write(component, AC97_SURROUND_MASTER, 0x0000);
/*power on LFE/CENTER/Surround DACs*/ /*power on LFE/CENTER/Surround DACs*/
ext_status = snd_soc_read(codec, AC97_EXTENDED_STATUS); ext_status = snd_soc_component_read32(component, AC97_EXTENDED_STATUS);
snd_soc_write(codec, AC97_EXTENDED_STATUS, ext_status&~0x3800); snd_soc_component_write(component, AC97_EXTENDED_STATUS, ext_status&~0x3800);
return 0; return 0;
reset_err: reset_err:
snd_soc_codec_exit_regmap(codec); snd_soc_component_exit_regmap(component);
err_free_ac97: err_free_ac97:
snd_soc_free_ac97_codec(ac97); snd_soc_free_ac97_component(ac97);
return ret; return ret;
} }
static int ad1980_soc_remove(struct snd_soc_codec *codec) static void ad1980_soc_remove(struct snd_soc_component *component)
{ {
struct snd_ac97 *ac97 = snd_soc_codec_get_drvdata(codec); struct snd_ac97 *ac97 = snd_soc_component_get_drvdata(component);
snd_soc_codec_exit_regmap(codec); snd_soc_component_exit_regmap(component);
snd_soc_free_ac97_codec(ac97); snd_soc_free_ac97_component(ac97);
return 0;
} }
static const struct snd_soc_codec_driver soc_codec_dev_ad1980 = { static const struct snd_soc_component_driver soc_component_dev_ad1980 = {
.probe = ad1980_soc_probe, .probe = ad1980_soc_probe,
.remove = ad1980_soc_remove, .remove = ad1980_soc_remove,
.component_driver = {
.controls = ad1980_snd_ac97_controls, .controls = ad1980_snd_ac97_controls,
.num_controls = ARRAY_SIZE(ad1980_snd_ac97_controls), .num_controls = ARRAY_SIZE(ad1980_snd_ac97_controls),
.dapm_widgets = ad1980_dapm_widgets, .dapm_widgets = ad1980_dapm_widgets,
.num_dapm_widgets = ARRAY_SIZE(ad1980_dapm_widgets), .num_dapm_widgets = ARRAY_SIZE(ad1980_dapm_widgets),
.dapm_routes = ad1980_dapm_routes, .dapm_routes = ad1980_dapm_routes,
.num_dapm_routes = ARRAY_SIZE(ad1980_dapm_routes), .num_dapm_routes = ARRAY_SIZE(ad1980_dapm_routes),
}, .idle_bias_on = 1,
.use_pmdown_time = 1,
.endianness = 1,
.non_legacy_dai_naming = 1,
}; };
static int ad1980_probe(struct platform_device *pdev) static int ad1980_probe(struct platform_device *pdev)
{ {
return snd_soc_register_codec(&pdev->dev, return devm_snd_soc_register_component(&pdev->dev,
&soc_codec_dev_ad1980, &ad1980_dai, 1); &soc_component_dev_ad1980, &ad1980_dai, 1);
}
static int ad1980_remove(struct platform_device *pdev)
{
snd_soc_unregister_codec(&pdev->dev);
return 0;
} }
static struct platform_driver ad1980_codec_driver = { static struct platform_driver ad1980_codec_driver = {
...@@ -327,7 +321,6 @@ static struct platform_driver ad1980_codec_driver = { ...@@ -327,7 +321,6 @@ static struct platform_driver ad1980_codec_driver = {
}, },
.probe = ad1980_probe, .probe = ad1980_probe,
.remove = ad1980_remove,
}; };
module_platform_driver(ad1980_codec_driver); module_platform_driver(ad1980_codec_driver);
......
...@@ -54,25 +54,21 @@ static struct snd_soc_dai_driver ad73311_dai = { ...@@ -54,25 +54,21 @@ static struct snd_soc_dai_driver ad73311_dai = {
.formats = SNDRV_PCM_FMTBIT_S16_LE, }, .formats = SNDRV_PCM_FMTBIT_S16_LE, },
}; };
static const struct snd_soc_codec_driver soc_codec_dev_ad73311 = { static const struct snd_soc_component_driver soc_component_dev_ad73311 = {
.component_driver = {
.dapm_widgets = ad73311_dapm_widgets, .dapm_widgets = ad73311_dapm_widgets,
.num_dapm_widgets = ARRAY_SIZE(ad73311_dapm_widgets), .num_dapm_widgets = ARRAY_SIZE(ad73311_dapm_widgets),
.dapm_routes = ad73311_dapm_routes, .dapm_routes = ad73311_dapm_routes,
.num_dapm_routes = ARRAY_SIZE(ad73311_dapm_routes), .num_dapm_routes = ARRAY_SIZE(ad73311_dapm_routes),
}, .idle_bias_on = 1,
.use_pmdown_time = 1,
.endianness = 1,
.non_legacy_dai_naming = 1,
}; };
static int ad73311_probe(struct platform_device *pdev) static int ad73311_probe(struct platform_device *pdev)
{ {
return snd_soc_register_codec(&pdev->dev, return devm_snd_soc_register_component(&pdev->dev,
&soc_codec_dev_ad73311, &ad73311_dai, 1); &soc_component_dev_ad73311, &ad73311_dai, 1);
}
static int ad73311_remove(struct platform_device *pdev)
{
snd_soc_unregister_codec(&pdev->dev);
return 0;
} }
static struct platform_driver ad73311_codec_driver = { static struct platform_driver ad73311_codec_driver = {
...@@ -81,7 +77,6 @@ static struct platform_driver ad73311_codec_driver = { ...@@ -81,7 +77,6 @@ static struct platform_driver ad73311_codec_driver = {
}, },
.probe = ad73311_probe, .probe = ad73311_probe,
.remove = ad73311_remove,
}; };
module_platform_driver(ad73311_codec_driver); module_platform_driver(ad73311_codec_driver);
......
...@@ -168,58 +168,58 @@ static const struct snd_kcontrol_new stac9766_snd_ac97_controls[] = { ...@@ -168,58 +168,58 @@ static const struct snd_kcontrol_new stac9766_snd_ac97_controls[] = {
static int ac97_analog_prepare(struct snd_pcm_substream *substream, static int ac97_analog_prepare(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 snd_pcm_runtime *runtime = substream->runtime; struct snd_pcm_runtime *runtime = substream->runtime;
unsigned short reg; unsigned short reg;
/* enable variable rate audio, disable SPDIF output */ /* enable variable rate audio, disable SPDIF output */
snd_soc_update_bits(codec, AC97_EXTENDED_STATUS, 0x5, 0x1); snd_soc_component_update_bits(component, AC97_EXTENDED_STATUS, 0x5, 0x1);
if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
reg = AC97_PCM_FRONT_DAC_RATE; reg = AC97_PCM_FRONT_DAC_RATE;
else else
reg = AC97_PCM_LR_ADC_RATE; reg = AC97_PCM_LR_ADC_RATE;
return snd_soc_write(codec, reg, runtime->rate); return snd_soc_component_write(component, reg, runtime->rate);
} }
static int ac97_digital_prepare(struct snd_pcm_substream *substream, static int ac97_digital_prepare(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 snd_pcm_runtime *runtime = substream->runtime; struct snd_pcm_runtime *runtime = substream->runtime;
unsigned short reg; unsigned short reg;
snd_soc_write(codec, AC97_SPDIF, 0x2002); snd_soc_component_write(component, AC97_SPDIF, 0x2002);
/* Enable VRA and SPDIF out */ /* Enable VRA and SPDIF out */
snd_soc_update_bits(codec, AC97_EXTENDED_STATUS, 0x5, 0x5); snd_soc_component_update_bits(component, AC97_EXTENDED_STATUS, 0x5, 0x5);
reg = AC97_PCM_FRONT_DAC_RATE; reg = AC97_PCM_FRONT_DAC_RATE;
return snd_soc_write(codec, reg, runtime->rate); return snd_soc_component_write(component, reg, runtime->rate);
} }
static int stac9766_set_bias_level(struct snd_soc_codec *codec, static int stac9766_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: /* full On */ case SND_SOC_BIAS_ON: /* full On */
case SND_SOC_BIAS_PREPARE: /* partial On */ case SND_SOC_BIAS_PREPARE: /* partial On */
case SND_SOC_BIAS_STANDBY: /* Off, with power */ case SND_SOC_BIAS_STANDBY: /* Off, with power */
snd_soc_write(codec, AC97_POWERDOWN, 0x0000); snd_soc_component_write(component, AC97_POWERDOWN, 0x0000);
break; break;
case SND_SOC_BIAS_OFF: /* Off, without power */ case SND_SOC_BIAS_OFF: /* Off, without power */
/* disable everything including AC link */ /* disable everything including AC link */
snd_soc_write(codec, AC97_POWERDOWN, 0xffff); snd_soc_component_write(component, AC97_POWERDOWN, 0xffff);
break; break;
} }
return 0; return 0;
} }
static int stac9766_codec_resume(struct snd_soc_codec *codec) static int stac9766_component_resume(struct snd_soc_component *component)
{ {
struct snd_ac97 *ac97 = snd_soc_codec_get_drvdata(codec); struct snd_ac97 *ac97 = snd_soc_component_get_drvdata(component);
return snd_ac97_reset(ac97, true, STAC9766_VENDOR_ID, return snd_ac97_reset(ac97, true, STAC9766_VENDOR_ID,
STAC9766_VENDOR_ID_MASK); STAC9766_VENDOR_ID_MASK);
...@@ -272,13 +272,13 @@ static struct snd_soc_dai_driver stac9766_dai[] = { ...@@ -272,13 +272,13 @@ static struct snd_soc_dai_driver stac9766_dai[] = {
} }
}; };
static int stac9766_codec_probe(struct snd_soc_codec *codec) static int stac9766_component_probe(struct snd_soc_component *component)
{ {
struct snd_ac97 *ac97; struct snd_ac97 *ac97;
struct regmap *regmap; struct regmap *regmap;
int ret; int ret;
ac97 = snd_soc_new_ac97_codec(codec, STAC9766_VENDOR_ID, ac97 = snd_soc_new_ac97_component(component, STAC9766_VENDOR_ID,
STAC9766_VENDOR_ID_MASK); STAC9766_VENDOR_ID_MASK);
if (IS_ERR(ac97)) if (IS_ERR(ac97))
return PTR_ERR(ac97); return PTR_ERR(ac97);
...@@ -289,46 +289,42 @@ static int stac9766_codec_probe(struct snd_soc_codec *codec) ...@@ -289,46 +289,42 @@ static int stac9766_codec_probe(struct snd_soc_codec *codec)
goto err_free_ac97; goto err_free_ac97;
} }
snd_soc_codec_init_regmap(codec, regmap); snd_soc_component_init_regmap(component, regmap);
snd_soc_codec_set_drvdata(codec, ac97); snd_soc_component_set_drvdata(component, ac97);
return 0; return 0;
err_free_ac97: err_free_ac97:
snd_soc_free_ac97_codec(ac97); snd_soc_free_ac97_component(ac97);
return ret; return ret;
} }
static int stac9766_codec_remove(struct snd_soc_codec *codec) static void stac9766_component_remove(struct snd_soc_component *component)
{ {
struct snd_ac97 *ac97 = snd_soc_codec_get_drvdata(codec); struct snd_ac97 *ac97 = snd_soc_component_get_drvdata(component);
snd_soc_codec_exit_regmap(codec); snd_soc_component_exit_regmap(component);
snd_soc_free_ac97_codec(ac97); snd_soc_free_ac97_component(ac97);
return 0;
} }
static const struct snd_soc_codec_driver soc_codec_dev_stac9766 = { static const struct snd_soc_component_driver soc_component_dev_stac9766 = {
.component_driver = {
.controls = stac9766_snd_ac97_controls, .controls = stac9766_snd_ac97_controls,
.num_controls = ARRAY_SIZE(stac9766_snd_ac97_controls), .num_controls = ARRAY_SIZE(stac9766_snd_ac97_controls),
},
.set_bias_level = stac9766_set_bias_level, .set_bias_level = stac9766_set_bias_level,
.suspend_bias_off = true, .probe = stac9766_component_probe,
.probe = stac9766_codec_probe, .remove = stac9766_component_remove,
.remove = stac9766_codec_remove, .resume = stac9766_component_resume,
.resume = stac9766_codec_resume, .suspend_bias_off = 1,
.idle_bias_on = 1,
.use_pmdown_time = 1,
.endianness = 1,
.non_legacy_dai_naming = 1,
}; };
static int stac9766_probe(struct platform_device *pdev) static int stac9766_probe(struct platform_device *pdev)
{ {
return snd_soc_register_codec(&pdev->dev, return devm_snd_soc_register_component(&pdev->dev,
&soc_codec_dev_stac9766, stac9766_dai, ARRAY_SIZE(stac9766_dai)); &soc_component_dev_stac9766, stac9766_dai, ARRAY_SIZE(stac9766_dai));
}
static int stac9766_remove(struct platform_device *pdev)
{
snd_soc_unregister_codec(&pdev->dev);
return 0;
} }
static struct platform_driver stac9766_codec_driver = { static struct platform_driver stac9766_codec_driver = {
...@@ -337,7 +333,6 @@ static struct platform_driver stac9766_codec_driver = { ...@@ -337,7 +333,6 @@ static struct platform_driver stac9766_codec_driver = {
}, },
.probe = stac9766_probe, .probe = stac9766_probe,
.remove = stac9766_remove,
}; };
module_platform_driver(stac9766_codec_driver); module_platform_driver(stac9766_codec_driver);
......
...@@ -235,17 +235,17 @@ static const struct snd_soc_dapm_route wm9705_audio_map[] = { ...@@ -235,17 +235,17 @@ static const struct snd_soc_dapm_route wm9705_audio_map[] = {
static int ac97_prepare(struct snd_pcm_substream *substream, static int ac97_prepare(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;
int reg; int reg;
snd_soc_update_bits(codec, AC97_EXTENDED_STATUS, 0x1, 0x1); snd_soc_component_update_bits(component, AC97_EXTENDED_STATUS, 0x1, 0x1);
if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
reg = AC97_PCM_FRONT_DAC_RATE; reg = AC97_PCM_FRONT_DAC_RATE;
else else
reg = AC97_PCM_LR_ADC_RATE; reg = AC97_PCM_LR_ADC_RATE;
return snd_soc_write(codec, reg, substream->runtime->rate); return snd_soc_component_write(component, reg, substream->runtime->rate);
} }
#define WM9705_AC97_RATES (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 | \ #define WM9705_AC97_RATES (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 | \
...@@ -289,18 +289,18 @@ static struct snd_soc_dai_driver wm9705_dai[] = { ...@@ -289,18 +289,18 @@ static struct snd_soc_dai_driver wm9705_dai[] = {
}; };
#ifdef CONFIG_PM #ifdef CONFIG_PM
static int wm9705_soc_suspend(struct snd_soc_codec *codec) static int wm9705_soc_suspend(struct snd_soc_component *component)
{ {
regcache_cache_bypass(codec->component.regmap, true); regcache_cache_bypass(component->regmap, true);
snd_soc_write(codec, AC97_POWERDOWN, 0xffff); snd_soc_component_write(component, AC97_POWERDOWN, 0xffff);
regcache_cache_bypass(codec->component.regmap, false); regcache_cache_bypass(component->regmap, false);
return 0; return 0;
} }
static int wm9705_soc_resume(struct snd_soc_codec *codec) static int wm9705_soc_resume(struct snd_soc_component *component)
{ {
struct wm9705_priv *wm9705 = snd_soc_codec_get_drvdata(codec); struct wm9705_priv *wm9705 = snd_soc_component_get_drvdata(component);
int ret; int ret;
ret = snd_ac97_reset(wm9705->ac97, true, WM9705_VENDOR_ID, ret = snd_ac97_reset(wm9705->ac97, true, WM9705_VENDOR_ID,
...@@ -308,7 +308,7 @@ static int wm9705_soc_resume(struct snd_soc_codec *codec) ...@@ -308,7 +308,7 @@ static int wm9705_soc_resume(struct snd_soc_codec *codec)
if (ret < 0) if (ret < 0)
return ret; return ret;
regcache_sync(codec->component.regmap); snd_soc_component_cache_sync(component);
return 0; return 0;
} }
...@@ -317,9 +317,9 @@ static int wm9705_soc_resume(struct snd_soc_codec *codec) ...@@ -317,9 +317,9 @@ static int wm9705_soc_resume(struct snd_soc_codec *codec)
#define wm9705_soc_resume NULL #define wm9705_soc_resume NULL
#endif #endif
static int wm9705_soc_probe(struct snd_soc_codec *codec) static int wm9705_soc_probe(struct snd_soc_component *component)
{ {
struct wm9705_priv *wm9705 = snd_soc_codec_get_drvdata(codec); struct wm9705_priv *wm9705 = snd_soc_component_get_drvdata(component);
struct regmap *regmap; struct regmap *regmap;
if (wm9705->mfd_pdata) { if (wm9705->mfd_pdata) {
...@@ -327,54 +327,54 @@ static int wm9705_soc_probe(struct snd_soc_codec *codec) ...@@ -327,54 +327,54 @@ static int wm9705_soc_probe(struct snd_soc_codec *codec)
regmap = wm9705->mfd_pdata->regmap; regmap = wm9705->mfd_pdata->regmap;
} else { } else {
#ifdef CONFIG_SND_SOC_AC97_BUS #ifdef CONFIG_SND_SOC_AC97_BUS
wm9705->ac97 = snd_soc_new_ac97_codec(codec, WM9705_VENDOR_ID, wm9705->ac97 = snd_soc_new_ac97_component(component, WM9705_VENDOR_ID,
WM9705_VENDOR_ID_MASK); WM9705_VENDOR_ID_MASK);
if (IS_ERR(wm9705->ac97)) { if (IS_ERR(wm9705->ac97)) {
dev_err(codec->dev, "Failed to register AC97 codec\n"); dev_err(component->dev, "Failed to register AC97 codec\n");
return PTR_ERR(wm9705->ac97); return PTR_ERR(wm9705->ac97);
} }
regmap = regmap_init_ac97(wm9705->ac97, &wm9705_regmap_config); regmap = regmap_init_ac97(wm9705->ac97, &wm9705_regmap_config);
if (IS_ERR(regmap)) { if (IS_ERR(regmap)) {
snd_soc_free_ac97_codec(wm9705->ac97); snd_soc_free_ac97_component(wm9705->ac97);
return PTR_ERR(regmap); return PTR_ERR(regmap);
} }
#endif #endif
} }
snd_soc_codec_set_drvdata(codec, wm9705->ac97); snd_soc_component_set_drvdata(component, wm9705->ac97);
snd_soc_codec_init_regmap(codec, regmap); snd_soc_component_init_regmap(component, regmap);
return 0; return 0;
} }
static int wm9705_soc_remove(struct snd_soc_codec *codec) static void wm9705_soc_remove(struct snd_soc_component *component)
{ {
#ifdef CONFIG_SND_SOC_AC97_BUS #ifdef CONFIG_SND_SOC_AC97_BUS
struct wm9705_priv *wm9705 = snd_soc_codec_get_drvdata(codec); struct wm9705_priv *wm9705 = snd_soc_component_get_drvdata(component);
if (!wm9705->mfd_pdata) { if (!wm9705->mfd_pdata) {
snd_soc_codec_exit_regmap(codec); snd_soc_component_exit_regmap(component);
snd_soc_free_ac97_codec(wm9705->ac97); snd_soc_free_ac97_component(wm9705->ac97);
} }
#endif #endif
return 0;
} }
static const struct snd_soc_codec_driver soc_codec_dev_wm9705 = { static const struct snd_soc_component_driver soc_component_dev_wm9705 = {
.probe = wm9705_soc_probe, .probe = wm9705_soc_probe,
.remove = wm9705_soc_remove, .remove = wm9705_soc_remove,
.suspend = wm9705_soc_suspend, .suspend = wm9705_soc_suspend,
.resume = wm9705_soc_resume, .resume = wm9705_soc_resume,
.component_driver = {
.controls = wm9705_snd_ac97_controls, .controls = wm9705_snd_ac97_controls,
.num_controls = ARRAY_SIZE(wm9705_snd_ac97_controls), .num_controls = ARRAY_SIZE(wm9705_snd_ac97_controls),
.dapm_widgets = wm9705_dapm_widgets, .dapm_widgets = wm9705_dapm_widgets,
.num_dapm_widgets = ARRAY_SIZE(wm9705_dapm_widgets), .num_dapm_widgets = ARRAY_SIZE(wm9705_dapm_widgets),
.dapm_routes = wm9705_audio_map, .dapm_routes = wm9705_audio_map,
.num_dapm_routes = ARRAY_SIZE(wm9705_audio_map), .num_dapm_routes = ARRAY_SIZE(wm9705_audio_map),
}, .idle_bias_on = 1,
.use_pmdown_time = 1,
.endianness = 1,
.non_legacy_dai_naming = 1,
}; };
static int wm9705_probe(struct platform_device *pdev) static int wm9705_probe(struct platform_device *pdev)
...@@ -388,14 +388,8 @@ static int wm9705_probe(struct platform_device *pdev) ...@@ -388,14 +388,8 @@ static int wm9705_probe(struct platform_device *pdev)
wm9705->mfd_pdata = dev_get_platdata(&pdev->dev); wm9705->mfd_pdata = dev_get_platdata(&pdev->dev);
platform_set_drvdata(pdev, wm9705); platform_set_drvdata(pdev, wm9705);
return snd_soc_register_codec(&pdev->dev, return devm_snd_soc_register_component(&pdev->dev,
&soc_codec_dev_wm9705, wm9705_dai, ARRAY_SIZE(wm9705_dai)); &soc_component_dev_wm9705, wm9705_dai, ARRAY_SIZE(wm9705_dai));
}
static int wm9705_remove(struct platform_device *pdev)
{
snd_soc_unregister_codec(&pdev->dev);
return 0;
} }
static struct platform_driver wm9705_codec_driver = { static struct platform_driver wm9705_codec_driver = {
...@@ -404,7 +398,6 @@ static struct platform_driver wm9705_codec_driver = { ...@@ -404,7 +398,6 @@ static struct platform_driver wm9705_codec_driver = {
}, },
.probe = wm9705_probe, .probe = wm9705_probe,
.remove = wm9705_remove,
}; };
module_platform_driver(wm9705_codec_driver); module_platform_driver(wm9705_codec_driver);
......
...@@ -220,8 +220,8 @@ static int wm9712_hp_mixer_put(struct snd_kcontrol *kcontrol, ...@@ -220,8 +220,8 @@ static int wm9712_hp_mixer_put(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol) struct snd_ctl_elem_value *ucontrol)
{ {
struct snd_soc_dapm_context *dapm = snd_soc_dapm_kcontrol_dapm(kcontrol); struct snd_soc_dapm_context *dapm = snd_soc_dapm_kcontrol_dapm(kcontrol);
struct snd_soc_codec *codec = snd_soc_dapm_to_codec(dapm); struct snd_soc_component *component = snd_soc_dapm_to_component(dapm);
struct wm9712_priv *wm9712 = snd_soc_codec_get_drvdata(codec); struct wm9712_priv *wm9712 = snd_soc_component_get_drvdata(component);
unsigned int val = ucontrol->value.integer.value[0]; unsigned int val = ucontrol->value.integer.value[0];
struct soc_mixer_control *mc = struct soc_mixer_control *mc =
(struct soc_mixer_control *)kcontrol->private_value; (struct soc_mixer_control *)kcontrol->private_value;
...@@ -264,8 +264,8 @@ static int wm9712_hp_mixer_get(struct snd_kcontrol *kcontrol, ...@@ -264,8 +264,8 @@ static int wm9712_hp_mixer_get(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol) struct snd_ctl_elem_value *ucontrol)
{ {
struct snd_soc_dapm_context *dapm = snd_soc_dapm_kcontrol_dapm(kcontrol); struct snd_soc_dapm_context *dapm = snd_soc_dapm_kcontrol_dapm(kcontrol);
struct snd_soc_codec *codec = snd_soc_dapm_to_codec(dapm); struct snd_soc_component *component = snd_soc_dapm_to_component(dapm);
struct wm9712_priv *wm9712 = snd_soc_codec_get_drvdata(codec); struct wm9712_priv *wm9712 = snd_soc_component_get_drvdata(component);
struct soc_mixer_control *mc = struct soc_mixer_control *mc =
(struct soc_mixer_control *)kcontrol->private_value; (struct soc_mixer_control *)kcontrol->private_value;
unsigned int shift, mixer; unsigned int shift, mixer;
...@@ -527,33 +527,33 @@ static const struct snd_soc_dapm_route wm9712_audio_map[] = { ...@@ -527,33 +527,33 @@ static const struct snd_soc_dapm_route wm9712_audio_map[] = {
static int ac97_prepare(struct snd_pcm_substream *substream, static int ac97_prepare(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;
int reg; int reg;
struct snd_pcm_runtime *runtime = substream->runtime; struct snd_pcm_runtime *runtime = substream->runtime;
snd_soc_update_bits(codec, AC97_EXTENDED_STATUS, 0x1, 0x1); snd_soc_component_update_bits(component, AC97_EXTENDED_STATUS, 0x1, 0x1);
if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
reg = AC97_PCM_FRONT_DAC_RATE; reg = AC97_PCM_FRONT_DAC_RATE;
else else
reg = AC97_PCM_LR_ADC_RATE; reg = AC97_PCM_LR_ADC_RATE;
return snd_soc_write(codec, reg, runtime->rate); return snd_soc_component_write(component, reg, runtime->rate);
} }
static int ac97_aux_prepare(struct snd_pcm_substream *substream, static int ac97_aux_prepare(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 snd_pcm_runtime *runtime = substream->runtime; struct snd_pcm_runtime *runtime = substream->runtime;
snd_soc_update_bits(codec, AC97_EXTENDED_STATUS, 0x1, 0x1); snd_soc_component_update_bits(component, AC97_EXTENDED_STATUS, 0x1, 0x1);
snd_soc_update_bits(codec, AC97_PCI_SID, 0x8000, 0x8000); snd_soc_component_update_bits(component, AC97_PCI_SID, 0x8000, 0x8000);
if (substream->stream != SNDRV_PCM_STREAM_PLAYBACK) if (substream->stream != SNDRV_PCM_STREAM_PLAYBACK)
return -ENODEV; return -ENODEV;
return snd_soc_write(codec, AC97_PCM_SURR_DAC_RATE, runtime->rate); return snd_soc_component_write(component, AC97_PCM_SURR_DAC_RATE, runtime->rate);
} }
#define WM9712_AC97_RATES (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |\ #define WM9712_AC97_RATES (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |\
...@@ -597,7 +597,7 @@ static struct snd_soc_dai_driver wm9712_dai[] = { ...@@ -597,7 +597,7 @@ static struct snd_soc_dai_driver wm9712_dai[] = {
} }
}; };
static int wm9712_set_bias_level(struct snd_soc_codec *codec, static int wm9712_set_bias_level(struct snd_soc_component *component,
enum snd_soc_bias_level level) enum snd_soc_bias_level level)
{ {
switch (level) { switch (level) {
...@@ -605,20 +605,20 @@ static int wm9712_set_bias_level(struct snd_soc_codec *codec, ...@@ -605,20 +605,20 @@ static int wm9712_set_bias_level(struct snd_soc_codec *codec,
case SND_SOC_BIAS_PREPARE: case SND_SOC_BIAS_PREPARE:
break; break;
case SND_SOC_BIAS_STANDBY: case SND_SOC_BIAS_STANDBY:
snd_soc_write(codec, AC97_POWERDOWN, 0x0000); snd_soc_component_write(component, AC97_POWERDOWN, 0x0000);
break; break;
case SND_SOC_BIAS_OFF: case SND_SOC_BIAS_OFF:
/* disable everything including AC link */ /* disable everything including AC link */
snd_soc_write(codec, AC97_EXTENDED_MSTATUS, 0xffff); snd_soc_component_write(component, AC97_EXTENDED_MSTATUS, 0xffff);
snd_soc_write(codec, AC97_POWERDOWN, 0xffff); snd_soc_component_write(component, AC97_POWERDOWN, 0xffff);
break; break;
} }
return 0; return 0;
} }
static int wm9712_soc_resume(struct snd_soc_codec *codec) static int wm9712_soc_resume(struct snd_soc_component *component)
{ {
struct wm9712_priv *wm9712 = snd_soc_codec_get_drvdata(codec); struct wm9712_priv *wm9712 = snd_soc_component_get_drvdata(component);
int ret; int ret;
ret = snd_ac97_reset(wm9712->ac97, true, WM9712_VENDOR_ID, ret = snd_ac97_reset(wm9712->ac97, true, WM9712_VENDOR_ID,
...@@ -626,17 +626,17 @@ static int wm9712_soc_resume(struct snd_soc_codec *codec) ...@@ -626,17 +626,17 @@ static int wm9712_soc_resume(struct snd_soc_codec *codec)
if (ret < 0) if (ret < 0)
return ret; return ret;
snd_soc_codec_force_bias_level(codec, SND_SOC_BIAS_STANDBY); snd_soc_component_force_bias_level(component, SND_SOC_BIAS_STANDBY);
if (ret == 0) if (ret == 0)
regcache_sync(codec->component.regmap); snd_soc_component_cache_sync(component);
return ret; return ret;
} }
static int wm9712_soc_probe(struct snd_soc_codec *codec) static int wm9712_soc_probe(struct snd_soc_component *component)
{ {
struct wm9712_priv *wm9712 = snd_soc_codec_get_drvdata(codec); struct wm9712_priv *wm9712 = snd_soc_component_get_drvdata(component);
struct regmap *regmap; struct regmap *regmap;
int ret; int ret;
...@@ -645,59 +645,59 @@ static int wm9712_soc_probe(struct snd_soc_codec *codec) ...@@ -645,59 +645,59 @@ static int wm9712_soc_probe(struct snd_soc_codec *codec)
regmap = wm9712->mfd_pdata->regmap; regmap = wm9712->mfd_pdata->regmap;
} else { } else {
#ifdef CONFIG_SND_SOC_AC97_BUS #ifdef CONFIG_SND_SOC_AC97_BUS
wm9712->ac97 = snd_soc_new_ac97_codec(codec, WM9712_VENDOR_ID, wm9712->ac97 = snd_soc_new_ac97_component(component, WM9712_VENDOR_ID,
WM9712_VENDOR_ID_MASK); WM9712_VENDOR_ID_MASK);
if (IS_ERR(wm9712->ac97)) { if (IS_ERR(wm9712->ac97)) {
ret = PTR_ERR(wm9712->ac97); ret = PTR_ERR(wm9712->ac97);
dev_err(codec->dev, dev_err(component->dev,
"Failed to register AC97 codec: %d\n", ret); "Failed to register AC97 codec: %d\n", ret);
return ret; return ret;
} }
regmap = regmap_init_ac97(wm9712->ac97, &wm9712_regmap_config); regmap = regmap_init_ac97(wm9712->ac97, &wm9712_regmap_config);
if (IS_ERR(regmap)) { if (IS_ERR(regmap)) {
snd_soc_free_ac97_codec(wm9712->ac97); snd_soc_free_ac97_component(wm9712->ac97);
return PTR_ERR(regmap); return PTR_ERR(regmap);
} }
#endif #endif
} }
snd_soc_codec_init_regmap(codec, regmap); snd_soc_component_init_regmap(component, regmap);
/* set alc mux to none */ /* set alc mux to none */
snd_soc_update_bits(codec, AC97_VIDEO, 0x3000, 0x3000); snd_soc_component_update_bits(component, AC97_VIDEO, 0x3000, 0x3000);
return 0; return 0;
} }
static int wm9712_soc_remove(struct snd_soc_codec *codec) static void wm9712_soc_remove(struct snd_soc_component *component)
{ {
#ifdef CONFIG_SND_SOC_AC97_BUS #ifdef CONFIG_SND_SOC_AC97_BUS
struct wm9712_priv *wm9712 = snd_soc_codec_get_drvdata(codec); struct wm9712_priv *wm9712 = snd_soc_component_get_drvdata(component);
if (!wm9712->mfd_pdata) { if (!wm9712->mfd_pdata) {
snd_soc_codec_exit_regmap(codec); snd_soc_component_exit_regmap(component);
snd_soc_free_ac97_codec(wm9712->ac97); snd_soc_free_ac97_component(wm9712->ac97);
} }
#endif #endif
return 0;
} }
static const struct snd_soc_codec_driver soc_codec_dev_wm9712 = { static const struct snd_soc_component_driver soc_component_dev_wm9712 = {
.probe = wm9712_soc_probe, .probe = wm9712_soc_probe,
.remove = wm9712_soc_remove, .remove = wm9712_soc_remove,
.resume = wm9712_soc_resume, .resume = wm9712_soc_resume,
.set_bias_level = wm9712_set_bias_level, .set_bias_level = wm9712_set_bias_level,
.suspend_bias_off = true,
.component_driver = {
.controls = wm9712_snd_ac97_controls, .controls = wm9712_snd_ac97_controls,
.num_controls = ARRAY_SIZE(wm9712_snd_ac97_controls), .num_controls = ARRAY_SIZE(wm9712_snd_ac97_controls),
.dapm_widgets = wm9712_dapm_widgets, .dapm_widgets = wm9712_dapm_widgets,
.num_dapm_widgets = ARRAY_SIZE(wm9712_dapm_widgets), .num_dapm_widgets = ARRAY_SIZE(wm9712_dapm_widgets),
.dapm_routes = wm9712_audio_map, .dapm_routes = wm9712_audio_map,
.num_dapm_routes = ARRAY_SIZE(wm9712_audio_map), .num_dapm_routes = ARRAY_SIZE(wm9712_audio_map),
}, .suspend_bias_off = 1,
.idle_bias_on = 1,
.use_pmdown_time = 1,
.endianness = 1,
.non_legacy_dai_naming = 1,
}; };
static int wm9712_probe(struct platform_device *pdev) static int wm9712_probe(struct platform_device *pdev)
...@@ -713,26 +713,19 @@ static int wm9712_probe(struct platform_device *pdev) ...@@ -713,26 +713,19 @@ static int wm9712_probe(struct platform_device *pdev)
wm9712->mfd_pdata = dev_get_platdata(&pdev->dev); wm9712->mfd_pdata = dev_get_platdata(&pdev->dev);
platform_set_drvdata(pdev, wm9712); platform_set_drvdata(pdev, wm9712);
return snd_soc_register_codec(&pdev->dev, return devm_snd_soc_register_component(&pdev->dev,
&soc_codec_dev_wm9712, wm9712_dai, ARRAY_SIZE(wm9712_dai)); &soc_component_dev_wm9712, wm9712_dai, ARRAY_SIZE(wm9712_dai));
}
static int wm9712_remove(struct platform_device *pdev)
{
snd_soc_unregister_codec(&pdev->dev);
return 0;
} }
static struct platform_driver wm9712_codec_driver = { static struct platform_driver wm9712_component_driver = {
.driver = { .driver = {
.name = "wm9712-codec", .name = "wm9712-component",
}, },
.probe = wm9712_probe, .probe = wm9712_probe,
.remove = wm9712_remove,
}; };
module_platform_driver(wm9712_codec_driver); module_platform_driver(wm9712_component_driver);
MODULE_DESCRIPTION("ASoC WM9711/WM9712 driver"); MODULE_DESCRIPTION("ASoC WM9711/WM9712 driver");
MODULE_AUTHOR("Liam Girdwood"); MODULE_AUTHOR("Liam Girdwood");
......
This diff is collapsed.
...@@ -58,20 +58,20 @@ ...@@ -58,20 +58,20 @@
#define AC97_GPIO_PULL 0x58 #define AC97_GPIO_PULL 0x58
/* Use GPIO8 for rear speaker amplifier */ /* Use GPIO8 for rear speaker amplifier */
static int rear_amp_power(struct snd_soc_codec *codec, int power) static int rear_amp_power(struct snd_soc_component *component, int power)
{ {
unsigned short reg; unsigned short reg;
if (power) { if (power) {
reg = snd_soc_read(codec, AC97_GPIO_CFG); reg = snd_soc_component_read32(component, AC97_GPIO_CFG);
snd_soc_write(codec, AC97_GPIO_CFG, reg | 0x0100); snd_soc_component_write(component, AC97_GPIO_CFG, reg | 0x0100);
reg = snd_soc_read(codec, AC97_GPIO_PULL); reg = snd_soc_component_read32(component, AC97_GPIO_PULL);
snd_soc_write(codec, AC97_GPIO_PULL, reg | (1<<15)); snd_soc_component_write(component, AC97_GPIO_PULL, reg | (1<<15));
} else { } else {
reg = snd_soc_read(codec, AC97_GPIO_CFG); reg = snd_soc_component_read32(component, AC97_GPIO_CFG);
snd_soc_write(codec, AC97_GPIO_CFG, reg & ~0x0100); snd_soc_component_write(component, AC97_GPIO_CFG, reg & ~0x0100);
reg = snd_soc_read(codec, AC97_GPIO_PULL); reg = snd_soc_component_read32(component, AC97_GPIO_PULL);
snd_soc_write(codec, AC97_GPIO_PULL, reg & ~(1<<15)); snd_soc_component_write(component, AC97_GPIO_PULL, reg & ~(1<<15));
} }
return 0; return 0;
...@@ -82,11 +82,11 @@ static int rear_amp_event(struct snd_soc_dapm_widget *widget, ...@@ -82,11 +82,11 @@ static int rear_amp_event(struct snd_soc_dapm_widget *widget,
{ {
struct snd_soc_card *card = widget->dapm->card; struct snd_soc_card *card = widget->dapm->card;
struct snd_soc_pcm_runtime *rtd; struct snd_soc_pcm_runtime *rtd;
struct snd_soc_codec *codec; struct snd_soc_component *component;
rtd = snd_soc_get_pcm_runtime(card, card->dai_link[0].name); rtd = snd_soc_get_pcm_runtime(card, card->dai_link[0].name);
codec = rtd->codec; component = rtd->codec_dai->component;
return rear_amp_power(codec, SND_SOC_DAPM_EVENT_ON(event)); return rear_amp_power(component, SND_SOC_DAPM_EVENT_ON(event));
} }
/* mioa701 machine dapm widgets */ /* mioa701 machine dapm widgets */
...@@ -129,13 +129,13 @@ static const struct snd_soc_dapm_route audio_map[] = { ...@@ -129,13 +129,13 @@ static const struct snd_soc_dapm_route audio_map[] = {
static int mioa701_wm9713_init(struct snd_soc_pcm_runtime *rtd) static int mioa701_wm9713_init(struct snd_soc_pcm_runtime *rtd)
{ {
struct snd_soc_codec *codec = rtd->codec; struct snd_soc_component *component = rtd->codec_dai->component;
/* Prepare GPIO8 for rear speaker amplifier */ /* Prepare GPIO8 for rear speaker amplifier */
snd_soc_update_bits(codec, AC97_GPIO_CFG, 0x100, 0x100); snd_soc_component_update_bits(component, AC97_GPIO_CFG, 0x100, 0x100);
/* Prepare MIC input */ /* Prepare MIC input */
snd_soc_update_bits(codec, AC97_3D_CONTROL, 0xc000, 0xc000); snd_soc_component_update_bits(component, AC97_3D_CONTROL, 0xc000, 0xc000);
return 0; return 0;
} }
......
...@@ -75,7 +75,7 @@ static const struct snd_soc_dapm_route ttc_audio_map[] = { ...@@ -75,7 +75,7 @@ static const struct snd_soc_dapm_route ttc_audio_map[] = {
static int ttc_pm860x_init(struct snd_soc_pcm_runtime *rtd) static int ttc_pm860x_init(struct snd_soc_pcm_runtime *rtd)
{ {
struct snd_soc_codec *codec = rtd->codec; struct snd_soc_component *component = rtd->codec_dai->component;
/* Headset jack detection */ /* Headset jack detection */
snd_soc_card_jack_new(rtd->card, "Headphone Jack", SND_JACK_HEADPHONE | snd_soc_card_jack_new(rtd->card, "Headphone Jack", SND_JACK_HEADPHONE |
...@@ -86,9 +86,9 @@ static int ttc_pm860x_init(struct snd_soc_pcm_runtime *rtd) ...@@ -86,9 +86,9 @@ static int ttc_pm860x_init(struct snd_soc_pcm_runtime *rtd)
ARRAY_SIZE(mic_jack_pins)); ARRAY_SIZE(mic_jack_pins));
/* headphone, microphone detection & headset short detection */ /* headphone, microphone detection & headset short detection */
pm860x_hs_jack_detect(codec, &hs_jack, SND_JACK_HEADPHONE, pm860x_hs_jack_detect(component, &hs_jack, SND_JACK_HEADPHONE,
SND_JACK_BTN_0, SND_JACK_BTN_1, SND_JACK_BTN_2); SND_JACK_BTN_0, SND_JACK_BTN_1, SND_JACK_BTN_2);
pm860x_mic_jack_detect(codec, &hs_jack, SND_JACK_MICROPHONE); pm860x_mic_jack_detect(component, &hs_jack, SND_JACK_MICROPHONE);
return 0; return 0;
} }
......
...@@ -44,7 +44,7 @@ struct snd_ac97_gpio_priv { ...@@ -44,7 +44,7 @@ struct snd_ac97_gpio_priv {
struct gpio_chip gpio_chip; struct gpio_chip gpio_chip;
#endif #endif
unsigned int gpios_set; unsigned int gpios_set;
struct snd_soc_codec *codec; struct snd_soc_component *component;
}; };
static struct snd_ac97_bus soc_ac97_bus = { static struct snd_ac97_bus soc_ac97_bus = {
...@@ -57,11 +57,11 @@ static void soc_ac97_device_release(struct device *dev) ...@@ -57,11 +57,11 @@ static void soc_ac97_device_release(struct device *dev)
} }
#ifdef CONFIG_GPIOLIB #ifdef CONFIG_GPIOLIB
static inline struct snd_soc_codec *gpio_to_codec(struct gpio_chip *chip) static inline struct snd_soc_component *gpio_to_component(struct gpio_chip *chip)
{ {
struct snd_ac97_gpio_priv *gpio_priv = gpiochip_get_data(chip); struct snd_ac97_gpio_priv *gpio_priv = gpiochip_get_data(chip);
return gpio_priv->codec; return gpio_priv->component;
} }
static int snd_soc_ac97_gpio_request(struct gpio_chip *chip, unsigned offset) static int snd_soc_ac97_gpio_request(struct gpio_chip *chip, unsigned offset)
...@@ -75,20 +75,22 @@ static int snd_soc_ac97_gpio_request(struct gpio_chip *chip, unsigned offset) ...@@ -75,20 +75,22 @@ static int snd_soc_ac97_gpio_request(struct gpio_chip *chip, unsigned offset)
static int snd_soc_ac97_gpio_direction_in(struct gpio_chip *chip, static int snd_soc_ac97_gpio_direction_in(struct gpio_chip *chip,
unsigned offset) unsigned offset)
{ {
struct snd_soc_codec *codec = gpio_to_codec(chip); struct snd_soc_component *component = gpio_to_component(chip);
dev_dbg(codec->dev, "set gpio %d to output\n", offset); dev_dbg(component->dev, "set gpio %d to output\n", offset);
return snd_soc_update_bits(codec, AC97_GPIO_CFG, return snd_soc_component_update_bits(component, AC97_GPIO_CFG,
1 << offset, 1 << offset); 1 << offset, 1 << offset);
} }
static int snd_soc_ac97_gpio_get(struct gpio_chip *chip, unsigned offset) static int snd_soc_ac97_gpio_get(struct gpio_chip *chip, unsigned offset)
{ {
struct snd_soc_codec *codec = gpio_to_codec(chip); struct snd_soc_component *component = gpio_to_component(chip);
int ret; int ret;
ret = snd_soc_read(codec, AC97_GPIO_STATUS); if (snd_soc_component_read(component, AC97_GPIO_STATUS, &ret) < 0)
dev_dbg(codec->dev, "get gpio %d : %d\n", offset, ret = -1;
dev_dbg(component->dev, "get gpio %d : %d\n", offset,
ret < 0 ? ret : ret & (1 << offset)); ret < 0 ? ret : ret & (1 << offset));
return ret < 0 ? ret : !!(ret & (1 << offset)); return ret < 0 ? ret : !!(ret & (1 << offset));
...@@ -98,22 +100,24 @@ static void snd_soc_ac97_gpio_set(struct gpio_chip *chip, unsigned offset, ...@@ -98,22 +100,24 @@ static void snd_soc_ac97_gpio_set(struct gpio_chip *chip, unsigned offset,
int value) int value)
{ {
struct snd_ac97_gpio_priv *gpio_priv = gpiochip_get_data(chip); struct snd_ac97_gpio_priv *gpio_priv = gpiochip_get_data(chip);
struct snd_soc_codec *codec = gpio_to_codec(chip); struct snd_soc_component *component = gpio_to_component(chip);
gpio_priv->gpios_set &= ~(1 << offset); gpio_priv->gpios_set &= ~(1 << offset);
gpio_priv->gpios_set |= (!!value) << offset; gpio_priv->gpios_set |= (!!value) << offset;
snd_soc_write(codec, AC97_GPIO_STATUS, gpio_priv->gpios_set); snd_soc_component_write(component, AC97_GPIO_STATUS,
dev_dbg(codec->dev, "set gpio %d to %d\n", offset, !!value); gpio_priv->gpios_set);
dev_dbg(component->dev, "set gpio %d to %d\n", offset, !!value);
} }
static int snd_soc_ac97_gpio_direction_out(struct gpio_chip *chip, static int snd_soc_ac97_gpio_direction_out(struct gpio_chip *chip,
unsigned offset, int value) unsigned offset, int value)
{ {
struct snd_soc_codec *codec = gpio_to_codec(chip); struct snd_soc_component *component = gpio_to_component(chip);
dev_dbg(codec->dev, "set gpio %d to output\n", offset); dev_dbg(component->dev, "set gpio %d to output\n", offset);
snd_soc_ac97_gpio_set(chip, offset, value); snd_soc_ac97_gpio_set(chip, offset, value);
return snd_soc_update_bits(codec, AC97_GPIO_CFG, 1 << offset, 0); return snd_soc_component_update_bits(component, AC97_GPIO_CFG,
1 << offset, 0);
} }
static const struct gpio_chip snd_soc_ac97_gpio_chip = { static const struct gpio_chip snd_soc_ac97_gpio_chip = {
...@@ -128,24 +132,24 @@ static const struct gpio_chip snd_soc_ac97_gpio_chip = { ...@@ -128,24 +132,24 @@ static const struct gpio_chip snd_soc_ac97_gpio_chip = {
}; };
static int snd_soc_ac97_init_gpio(struct snd_ac97 *ac97, static int snd_soc_ac97_init_gpio(struct snd_ac97 *ac97,
struct snd_soc_codec *codec) struct snd_soc_component *component)
{ {
struct snd_ac97_gpio_priv *gpio_priv; struct snd_ac97_gpio_priv *gpio_priv;
int ret; int ret;
gpio_priv = devm_kzalloc(codec->dev, sizeof(*gpio_priv), GFP_KERNEL); gpio_priv = devm_kzalloc(component->dev, sizeof(*gpio_priv), GFP_KERNEL);
if (!gpio_priv) if (!gpio_priv)
return -ENOMEM; return -ENOMEM;
ac97->gpio_priv = gpio_priv; ac97->gpio_priv = gpio_priv;
gpio_priv->codec = codec; gpio_priv->component = component;
gpio_priv->gpio_chip = snd_soc_ac97_gpio_chip; gpio_priv->gpio_chip = snd_soc_ac97_gpio_chip;
gpio_priv->gpio_chip.ngpio = AC97_NUM_GPIOS; gpio_priv->gpio_chip.ngpio = AC97_NUM_GPIOS;
gpio_priv->gpio_chip.parent = codec->dev; gpio_priv->gpio_chip.parent = component->dev;
gpio_priv->gpio_chip.base = -1; gpio_priv->gpio_chip.base = -1;
ret = gpiochip_add_data(&gpio_priv->gpio_chip, gpio_priv); ret = gpiochip_add_data(&gpio_priv->gpio_chip, gpio_priv);
if (ret != 0) if (ret != 0)
dev_err(codec->dev, "Failed to add GPIOs: %d\n", ret); dev_err(component->dev, "Failed to add GPIOs: %d\n", ret);
return ret; return ret;
} }
...@@ -155,7 +159,7 @@ static void snd_soc_ac97_free_gpio(struct snd_ac97 *ac97) ...@@ -155,7 +159,7 @@ static void snd_soc_ac97_free_gpio(struct snd_ac97 *ac97)
} }
#else #else
static int snd_soc_ac97_init_gpio(struct snd_ac97 *ac97, static int snd_soc_ac97_init_gpio(struct snd_ac97 *ac97,
struct snd_soc_codec *codec) struct snd_soc_component *component)
{ {
return 0; return 0;
} }
...@@ -166,8 +170,8 @@ static void snd_soc_ac97_free_gpio(struct snd_ac97 *ac97) ...@@ -166,8 +170,8 @@ static void snd_soc_ac97_free_gpio(struct snd_ac97 *ac97)
#endif #endif
/** /**
* snd_soc_alloc_ac97_codec() - Allocate new a AC'97 device * snd_soc_alloc_ac97_component() - Allocate new a AC'97 device
* @codec: The CODEC for which to create the AC'97 device * @component: The COMPONENT for which to create the AC'97 device
* *
* Allocated a new snd_ac97 device and intializes it, but does not yet register * Allocated a new snd_ac97 device and intializes it, but does not yet register
* it. The caller is responsible to either call device_add(&ac97->dev) to * it. The caller is responsible to either call device_add(&ac97->dev) to
...@@ -175,7 +179,7 @@ static void snd_soc_ac97_free_gpio(struct snd_ac97 *ac97) ...@@ -175,7 +179,7 @@ static void snd_soc_ac97_free_gpio(struct snd_ac97 *ac97)
* *
* Returns: A snd_ac97 device or a PTR_ERR in case of an error. * Returns: A snd_ac97 device or a PTR_ERR in case of an error.
*/ */
struct snd_ac97 *snd_soc_alloc_ac97_codec(struct snd_soc_codec *codec) struct snd_ac97 *snd_soc_alloc_ac97_component(struct snd_soc_component *component)
{ {
struct snd_ac97 *ac97; struct snd_ac97 *ac97;
...@@ -187,26 +191,26 @@ struct snd_ac97 *snd_soc_alloc_ac97_codec(struct snd_soc_codec *codec) ...@@ -187,26 +191,26 @@ struct snd_ac97 *snd_soc_alloc_ac97_codec(struct snd_soc_codec *codec)
ac97->num = 0; ac97->num = 0;
ac97->dev.bus = &ac97_bus_type; ac97->dev.bus = &ac97_bus_type;
ac97->dev.parent = codec->component.card->dev; ac97->dev.parent = component->card->dev;
ac97->dev.release = soc_ac97_device_release; ac97->dev.release = soc_ac97_device_release;
dev_set_name(&ac97->dev, "%d-%d:%s", dev_set_name(&ac97->dev, "%d-%d:%s",
codec->component.card->snd_card->number, 0, component->card->snd_card->number, 0,
codec->component.name); component->name);
device_initialize(&ac97->dev); device_initialize(&ac97->dev);
return ac97; return ac97;
} }
EXPORT_SYMBOL(snd_soc_alloc_ac97_codec); EXPORT_SYMBOL(snd_soc_alloc_ac97_component);
/** /**
* snd_soc_new_ac97_codec - initailise AC97 device * snd_soc_new_ac97_component - initailise AC97 device
* @codec: audio codec * @component: audio component
* @id: The expected device ID * @id: The expected device ID
* @id_mask: Mask that is applied to the device ID before comparing with @id * @id_mask: Mask that is applied to the device ID before comparing with @id
* *
* Initialises AC97 codec resources for use by ad-hoc devices only. * Initialises AC97 component resources for use by ad-hoc devices only.
* *
* If @id is not 0 this function will reset the device, then read the ID from * If @id is not 0 this function will reset the device, then read the ID from
* the device and check if it matches the expected ID. If it doesn't match an * the device and check if it matches the expected ID. If it doesn't match an
...@@ -214,20 +218,20 @@ EXPORT_SYMBOL(snd_soc_alloc_ac97_codec); ...@@ -214,20 +218,20 @@ EXPORT_SYMBOL(snd_soc_alloc_ac97_codec);
* *
* Returns: A PTR_ERR() on failure or a valid snd_ac97 struct on success. * Returns: A PTR_ERR() on failure or a valid snd_ac97 struct on success.
*/ */
struct snd_ac97 *snd_soc_new_ac97_codec(struct snd_soc_codec *codec, struct snd_ac97 *snd_soc_new_ac97_component(struct snd_soc_component *component,
unsigned int id, unsigned int id_mask) unsigned int id, unsigned int id_mask)
{ {
struct snd_ac97 *ac97; struct snd_ac97 *ac97;
int ret; int ret;
ac97 = snd_soc_alloc_ac97_codec(codec); ac97 = snd_soc_alloc_ac97_component(component);
if (IS_ERR(ac97)) if (IS_ERR(ac97))
return ac97; return ac97;
if (id) { if (id) {
ret = snd_ac97_reset(ac97, false, id, id_mask); ret = snd_ac97_reset(ac97, false, id, id_mask);
if (ret < 0) { if (ret < 0) {
dev_err(codec->dev, "Failed to reset AC97 device: %d\n", dev_err(component->dev, "Failed to reset AC97 device: %d\n",
ret); ret);
goto err_put_device; goto err_put_device;
} }
...@@ -237,7 +241,7 @@ struct snd_ac97 *snd_soc_new_ac97_codec(struct snd_soc_codec *codec, ...@@ -237,7 +241,7 @@ struct snd_ac97 *snd_soc_new_ac97_codec(struct snd_soc_codec *codec,
if (ret) if (ret)
goto err_put_device; goto err_put_device;
ret = snd_soc_ac97_init_gpio(ac97, codec); ret = snd_soc_ac97_init_gpio(ac97, component);
if (ret) if (ret)
goto err_put_device; goto err_put_device;
...@@ -247,22 +251,22 @@ struct snd_ac97 *snd_soc_new_ac97_codec(struct snd_soc_codec *codec, ...@@ -247,22 +251,22 @@ struct snd_ac97 *snd_soc_new_ac97_codec(struct snd_soc_codec *codec,
put_device(&ac97->dev); put_device(&ac97->dev);
return ERR_PTR(ret); return ERR_PTR(ret);
} }
EXPORT_SYMBOL_GPL(snd_soc_new_ac97_codec); EXPORT_SYMBOL_GPL(snd_soc_new_ac97_component);
/** /**
* snd_soc_free_ac97_codec - free AC97 codec device * snd_soc_free_ac97_component - free AC97 component device
* @ac97: snd_ac97 device to be freed * @ac97: snd_ac97 device to be freed
* *
* Frees AC97 codec device resources. * Frees AC97 component device resources.
*/ */
void snd_soc_free_ac97_codec(struct snd_ac97 *ac97) void snd_soc_free_ac97_component(struct snd_ac97 *ac97)
{ {
snd_soc_ac97_free_gpio(ac97); snd_soc_ac97_free_gpio(ac97);
device_del(&ac97->dev); device_del(&ac97->dev);
ac97->bus = NULL; ac97->bus = NULL;
put_device(&ac97->dev); put_device(&ac97->dev);
} }
EXPORT_SYMBOL_GPL(snd_soc_free_ac97_codec); EXPORT_SYMBOL_GPL(snd_soc_free_ac97_component);
static struct snd_ac97_reset_cfg snd_ac97_rst_cfg; static struct snd_ac97_reset_cfg snd_ac97_rst_cfg;
......
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