Commit c95869e5 authored by Kuninori Morimoto's avatar Kuninori Morimoto Committed by Mark Brown

ASoC: ac97: replace codec to component

Now we can replace Codec to Component. Let's do it.

Note:
	xxx_codec_xxx()		->	xxx_component_xxx()
	.idle_bias_off = 0	->	.idle_bias_on = 1
	.ignore_pmdown_time = 0	->	.use_pmdown_time = 1
	-			->	.endianness = 1
	-			->	.non_legacy_dai_naming = 1

To keep compatibilty, this patch adds snd_soc_xxx_ac97_codec()
macro. These will be removed when all codec code was removed.
Signed-off-by: default avatarKuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: default avatarMark Brown <broonie@kernel.org>
parent 7928b2cb
...@@ -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,
......
...@@ -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,
.dapm_widgets = ac97_widgets,
.component_driver = { .num_dapm_widgets = ARRAY_SIZE(ac97_widgets),
.dapm_widgets = ac97_widgets, .dapm_routes = ac97_routes,
.num_dapm_widgets = ARRAY_SIZE(ac97_widgets), .num_dapm_routes = ARRAY_SIZE(ac97_routes),
.dapm_routes = ac97_routes, .idle_bias_on = 1,
.num_dapm_routes = ARRAY_SIZE(ac97_routes), .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;
} }
......
...@@ -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