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

ASoC: cx20442: 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
Signed-off-by: default avatarKuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: default avatarMark Brown <broonie@kernel.org>
parent 7928b2cb
...@@ -89,10 +89,10 @@ static const struct snd_soc_dapm_route cx20442_audio_map[] = { ...@@ -89,10 +89,10 @@ static const struct snd_soc_dapm_route cx20442_audio_map[] = {
{"ADC", NULL, "Input Mixer"}, {"ADC", NULL, "Input Mixer"},
}; };
static unsigned int cx20442_read_reg_cache(struct snd_soc_codec *codec, static unsigned int cx20442_read_reg_cache(struct snd_soc_component *component,
unsigned int reg) unsigned int reg)
{ {
struct cx20442_priv *cx20442 = snd_soc_codec_get_drvdata(codec); struct cx20442_priv *cx20442 = snd_soc_component_get_drvdata(component);
if (reg >= 1) if (reg >= 1)
return -EINVAL; return -EINVAL;
...@@ -153,10 +153,10 @@ static int cx20442_pm_to_v253_vsp(u8 value) ...@@ -153,10 +153,10 @@ static int cx20442_pm_to_v253_vsp(u8 value)
return (value & (1 << CX20442_AGC)) ? -EINVAL : 0; return (value & (1 << CX20442_AGC)) ? -EINVAL : 0;
} }
static int cx20442_write(struct snd_soc_codec *codec, unsigned int reg, static int cx20442_write(struct snd_soc_component *component, unsigned int reg,
unsigned int value) unsigned int value)
{ {
struct cx20442_priv *cx20442 = snd_soc_codec_get_drvdata(codec); struct cx20442_priv *cx20442 = snd_soc_component_get_drvdata(component);
int vls, vsp, old, len; int vls, vsp, old, len;
char buf[18]; char buf[18];
...@@ -193,7 +193,7 @@ static int cx20442_write(struct snd_soc_codec *codec, unsigned int reg, ...@@ -193,7 +193,7 @@ static int cx20442_write(struct snd_soc_codec *codec, unsigned int reg,
if (unlikely(len > (ARRAY_SIZE(buf) - 1))) if (unlikely(len > (ARRAY_SIZE(buf) - 1)))
return -ENOMEM; return -ENOMEM;
dev_dbg(codec->dev, "%s: %s\n", __func__, buf); dev_dbg(component->dev, "%s: %s\n", __func__, buf);
if (cx20442->tty->ops->write(cx20442->tty, buf, len) != len) if (cx20442->tty->ops->write(cx20442->tty, buf, len) != len)
return -EIO; return -EIO;
...@@ -240,19 +240,19 @@ static int v253_open(struct tty_struct *tty) ...@@ -240,19 +240,19 @@ static int v253_open(struct tty_struct *tty)
/* Line discipline .close() */ /* Line discipline .close() */
static void v253_close(struct tty_struct *tty) static void v253_close(struct tty_struct *tty)
{ {
struct snd_soc_codec *codec = tty->disc_data; struct snd_soc_component *component = tty->disc_data;
struct cx20442_priv *cx20442; struct cx20442_priv *cx20442;
tty->disc_data = NULL; tty->disc_data = NULL;
if (!codec) if (!component)
return; return;
cx20442 = snd_soc_codec_get_drvdata(codec); cx20442 = snd_soc_component_get_drvdata(component);
/* Prevent the codec driver from further accessing the modem */ /* Prevent the codec driver from further accessing the modem */
cx20442->tty = NULL; cx20442->tty = NULL;
codec->component.card->pop_time = 0; component->card->pop_time = 0;
} }
/* Line discipline .hangup() */ /* Line discipline .hangup() */
...@@ -266,20 +266,20 @@ static int v253_hangup(struct tty_struct *tty) ...@@ -266,20 +266,20 @@ static int v253_hangup(struct tty_struct *tty)
static void v253_receive(struct tty_struct *tty, static void v253_receive(struct tty_struct *tty,
const unsigned char *cp, char *fp, int count) const unsigned char *cp, char *fp, int count)
{ {
struct snd_soc_codec *codec = tty->disc_data; struct snd_soc_component *component = tty->disc_data;
struct cx20442_priv *cx20442; struct cx20442_priv *cx20442;
if (!codec) if (!component)
return; return;
cx20442 = snd_soc_codec_get_drvdata(codec); cx20442 = snd_soc_component_get_drvdata(component);
if (!cx20442->tty) { if (!cx20442->tty) {
/* First modem response, complete setup procedure */ /* First modem response, complete setup procedure */
/* Set up codec driver access to modem controls */ /* Set up codec driver access to modem controls */
cx20442->tty = tty; cx20442->tty = tty;
codec->component.card->pop_time = 1; component->card->pop_time = 1;
} }
} }
...@@ -323,15 +323,15 @@ static struct snd_soc_dai_driver cx20442_dai = { ...@@ -323,15 +323,15 @@ static struct snd_soc_dai_driver cx20442_dai = {
}, },
}; };
static int cx20442_set_bias_level(struct snd_soc_codec *codec, static int cx20442_set_bias_level(struct snd_soc_component *component,
enum snd_soc_bias_level level) enum snd_soc_bias_level level)
{ {
struct cx20442_priv *cx20442 = snd_soc_codec_get_drvdata(codec); struct cx20442_priv *cx20442 = snd_soc_component_get_drvdata(component);
int err = 0; int err = 0;
switch (level) { switch (level) {
case SND_SOC_BIAS_PREPARE: case SND_SOC_BIAS_PREPARE:
if (snd_soc_codec_get_bias_level(codec) != SND_SOC_BIAS_STANDBY) if (snd_soc_component_get_bias_level(component) != SND_SOC_BIAS_STANDBY)
break; break;
if (IS_ERR(cx20442->por)) if (IS_ERR(cx20442->por))
err = PTR_ERR(cx20442->por); err = PTR_ERR(cx20442->por);
...@@ -339,7 +339,7 @@ static int cx20442_set_bias_level(struct snd_soc_codec *codec, ...@@ -339,7 +339,7 @@ static int cx20442_set_bias_level(struct snd_soc_codec *codec,
err = regulator_enable(cx20442->por); err = regulator_enable(cx20442->por);
break; break;
case SND_SOC_BIAS_STANDBY: case SND_SOC_BIAS_STANDBY:
if (snd_soc_codec_get_bias_level(codec) != SND_SOC_BIAS_PREPARE) if (snd_soc_component_get_bias_level(component) != SND_SOC_BIAS_PREPARE)
break; break;
if (IS_ERR(cx20442->por)) if (IS_ERR(cx20442->por))
err = PTR_ERR(cx20442->por); err = PTR_ERR(cx20442->por);
...@@ -353,7 +353,7 @@ static int cx20442_set_bias_level(struct snd_soc_codec *codec, ...@@ -353,7 +353,7 @@ static int cx20442_set_bias_level(struct snd_soc_codec *codec,
return err; return err;
} }
static int cx20442_codec_probe(struct snd_soc_codec *codec) static int cx20442_component_probe(struct snd_soc_component *component)
{ {
struct cx20442_priv *cx20442; struct cx20442_priv *cx20442;
...@@ -361,21 +361,21 @@ static int cx20442_codec_probe(struct snd_soc_codec *codec) ...@@ -361,21 +361,21 @@ static int cx20442_codec_probe(struct snd_soc_codec *codec)
if (cx20442 == NULL) if (cx20442 == NULL)
return -ENOMEM; return -ENOMEM;
cx20442->por = regulator_get(codec->dev, "POR"); cx20442->por = regulator_get(component->dev, "POR");
if (IS_ERR(cx20442->por)) if (IS_ERR(cx20442->por))
dev_warn(codec->dev, "failed to get the regulator"); dev_warn(component->dev, "failed to get the regulator");
cx20442->tty = NULL; cx20442->tty = NULL;
snd_soc_codec_set_drvdata(codec, cx20442); snd_soc_component_set_drvdata(component, cx20442);
codec->component.card->pop_time = 0; component->card->pop_time = 0;
return 0; return 0;
} }
/* power down chip */ /* power down chip */
static int cx20442_codec_remove(struct snd_soc_codec *codec) static void cx20442_component_remove(struct snd_soc_component *component)
{ {
struct cx20442_priv *cx20442 = snd_soc_codec_get_drvdata(codec); struct cx20442_priv *cx20442 = snd_soc_component_get_drvdata(component);
if (cx20442->tty) { if (cx20442->tty) {
struct tty_struct *tty = cx20442->tty; struct tty_struct *tty = cx20442->tty;
...@@ -387,36 +387,30 @@ static int cx20442_codec_remove(struct snd_soc_codec *codec) ...@@ -387,36 +387,30 @@ static int cx20442_codec_remove(struct snd_soc_codec *codec)
regulator_put(cx20442->por); regulator_put(cx20442->por);
} }
snd_soc_codec_set_drvdata(codec, NULL); snd_soc_component_set_drvdata(component, NULL);
kfree(cx20442); kfree(cx20442);
return 0;
} }
static const struct snd_soc_codec_driver cx20442_codec_dev = { static const struct snd_soc_component_driver cx20442_component_dev = {
.probe = cx20442_codec_probe, .probe = cx20442_component_probe,
.remove = cx20442_codec_remove, .remove = cx20442_component_remove,
.set_bias_level = cx20442_set_bias_level, .set_bias_level = cx20442_set_bias_level,
.read = cx20442_read_reg_cache, .read = cx20442_read_reg_cache,
.write = cx20442_write, .write = cx20442_write,
.dapm_widgets = cx20442_dapm_widgets,
.component_driver = { .num_dapm_widgets = ARRAY_SIZE(cx20442_dapm_widgets),
.dapm_widgets = cx20442_dapm_widgets, .dapm_routes = cx20442_audio_map,
.num_dapm_widgets = ARRAY_SIZE(cx20442_dapm_widgets), .num_dapm_routes = ARRAY_SIZE(cx20442_audio_map),
.dapm_routes = cx20442_audio_map, .idle_bias_on = 1,
.num_dapm_routes = ARRAY_SIZE(cx20442_audio_map), .use_pmdown_time = 1,
}, .endianness = 1,
.non_legacy_dai_naming = 1,
}; };
static int cx20442_platform_probe(struct platform_device *pdev) static int cx20442_platform_probe(struct platform_device *pdev)
{ {
return snd_soc_register_codec(&pdev->dev, return devm_snd_soc_register_component(&pdev->dev,
&cx20442_codec_dev, &cx20442_dai, 1); &cx20442_component_dev, &cx20442_dai, 1);
}
static int cx20442_platform_remove(struct platform_device *pdev)
{
snd_soc_unregister_codec(&pdev->dev);
return 0;
} }
static struct platform_driver cx20442_platform_driver = { static struct platform_driver cx20442_platform_driver = {
...@@ -424,7 +418,6 @@ static struct platform_driver cx20442_platform_driver = { ...@@ -424,7 +418,6 @@ static struct platform_driver cx20442_platform_driver = {
.name = "cx20442-codec", .name = "cx20442-codec",
}, },
.probe = cx20442_platform_probe, .probe = cx20442_platform_probe,
.remove = cx20442_platform_remove,
}; };
module_platform_driver(cx20442_platform_driver); module_platform_driver(cx20442_platform_driver);
......
...@@ -93,7 +93,7 @@ static unsigned short ams_delta_audio_agc; ...@@ -93,7 +93,7 @@ static unsigned short ams_delta_audio_agc;
* Used for passing a codec structure pointer * Used for passing a codec structure pointer
* from the board initialization code to the tty line discipline. * from the board initialization code to the tty line discipline.
*/ */
static struct snd_soc_codec *cx20442_codec; static struct snd_soc_component *cx20442_codec;
static int ams_delta_set_audio_mode(struct snd_kcontrol *kcontrol, static int ams_delta_set_audio_mode(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol) struct snd_ctl_elem_value *ucontrol)
...@@ -105,7 +105,7 @@ static int ams_delta_set_audio_mode(struct snd_kcontrol *kcontrol, ...@@ -105,7 +105,7 @@ static int ams_delta_set_audio_mode(struct snd_kcontrol *kcontrol,
int pin, changed = 0; int pin, changed = 0;
/* Refuse any mode changes if we are not able to control the codec. */ /* Refuse any mode changes if we are not able to control the codec. */
if (!cx20442_codec->component.card->pop_time) if (!cx20442_codec->card->pop_time)
return -EUNATCH; return -EUNATCH;
if (ucontrol->value.enumerated.item[0] >= control->items) if (ucontrol->value.enumerated.item[0] >= control->items)
...@@ -300,15 +300,15 @@ static int cx81801_open(struct tty_struct *tty) ...@@ -300,15 +300,15 @@ static int cx81801_open(struct tty_struct *tty)
/* Line discipline .close() */ /* Line discipline .close() */
static void cx81801_close(struct tty_struct *tty) static void cx81801_close(struct tty_struct *tty)
{ {
struct snd_soc_codec *codec = tty->disc_data; struct snd_soc_component *component = tty->disc_data;
struct snd_soc_dapm_context *dapm = &codec->component.card->dapm; struct snd_soc_dapm_context *dapm = &component->card->dapm;
del_timer_sync(&cx81801_timer); del_timer_sync(&cx81801_timer);
/* Prevent the hook switch from further changing the DAPM pins */ /* Prevent the hook switch from further changing the DAPM pins */
INIT_LIST_HEAD(&ams_delta_hook_switch.pins); INIT_LIST_HEAD(&ams_delta_hook_switch.pins);
if (!codec) if (!component)
return; return;
v253_ops.close(tty); v253_ops.close(tty);
...@@ -338,14 +338,14 @@ static int cx81801_hangup(struct tty_struct *tty) ...@@ -338,14 +338,14 @@ static int cx81801_hangup(struct tty_struct *tty)
static void cx81801_receive(struct tty_struct *tty, static void cx81801_receive(struct tty_struct *tty,
const unsigned char *cp, char *fp, int count) const unsigned char *cp, char *fp, int count)
{ {
struct snd_soc_codec *codec = tty->disc_data; struct snd_soc_component *component = tty->disc_data;
const unsigned char *c; const unsigned char *c;
int apply, ret; int apply, ret;
if (!codec) if (!component)
return; return;
if (!codec->component.card->pop_time) { if (!component->card->pop_time) {
/* First modem response, complete setup procedure */ /* First modem response, complete setup procedure */
/* Initialize timer used for config pulse generation */ /* Initialize timer used for config pulse generation */
...@@ -358,7 +358,7 @@ static void cx81801_receive(struct tty_struct *tty, ...@@ -358,7 +358,7 @@ static void cx81801_receive(struct tty_struct *tty,
ARRAY_SIZE(ams_delta_hook_switch_pins), ARRAY_SIZE(ams_delta_hook_switch_pins),
ams_delta_hook_switch_pins); ams_delta_hook_switch_pins);
if (ret) if (ret)
dev_warn(codec->dev, dev_warn(component->dev,
"Failed to link hook switch to DAPM pins, " "Failed to link hook switch to DAPM pins, "
"will continue with hook switch unlinked.\n"); "will continue with hook switch unlinked.\n");
...@@ -467,7 +467,7 @@ static int ams_delta_cx20442_init(struct snd_soc_pcm_runtime *rtd) ...@@ -467,7 +467,7 @@ static int ams_delta_cx20442_init(struct snd_soc_pcm_runtime *rtd)
/* Codec is ready, now add/activate board specific controls */ /* Codec is ready, now add/activate board specific controls */
/* Store a pointer to the codec structure for tty ldisc use */ /* Store a pointer to the codec structure for tty ldisc use */
cx20442_codec = rtd->codec; cx20442_codec = rtd->codec_dai->component;
/* Set up digital mute if not provided by the codec */ /* Set up digital mute if not provided by the codec */
if (!codec_dai->driver->ops) { if (!codec_dai->driver->ops) {
......
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