ASoC: alc5623: 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: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> Signed-off-by: Mark Brown <broonie@kernel.org>
This commit is contained in:
Родитель
7928b2cbe5
Коммит
fd7c728de8
|
@ -47,28 +47,28 @@ struct alc5623_priv {
|
|||
unsigned int jack_det_ctrl;
|
||||
};
|
||||
|
||||
static inline int alc5623_reset(struct snd_soc_codec *codec)
|
||||
static inline int alc5623_reset(struct snd_soc_component *component)
|
||||
{
|
||||
return snd_soc_write(codec, ALC5623_RESET, 0);
|
||||
return snd_soc_component_write(component, ALC5623_RESET, 0);
|
||||
}
|
||||
|
||||
static int amp_mixer_event(struct snd_soc_dapm_widget *w,
|
||||
struct snd_kcontrol *kcontrol, int event)
|
||||
{
|
||||
struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
|
||||
struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm);
|
||||
|
||||
/* to power-on/off class-d amp generators/speaker */
|
||||
/* need to write to 'index-46h' register : */
|
||||
/* so write index num (here 0x46) to reg 0x6a */
|
||||
/* and then 0xffff/0 to reg 0x6c */
|
||||
snd_soc_write(codec, ALC5623_HID_CTRL_INDEX, 0x46);
|
||||
snd_soc_component_write(component, ALC5623_HID_CTRL_INDEX, 0x46);
|
||||
|
||||
switch (event) {
|
||||
case SND_SOC_DAPM_PRE_PMU:
|
||||
snd_soc_write(codec, ALC5623_HID_CTRL_DATA, 0xFFFF);
|
||||
snd_soc_component_write(component, ALC5623_HID_CTRL_DATA, 0xFFFF);
|
||||
break;
|
||||
case SND_SOC_DAPM_POST_PMD:
|
||||
snd_soc_write(codec, ALC5623_HID_CTRL_DATA, 0);
|
||||
snd_soc_component_write(component, ALC5623_HID_CTRL_DATA, 0);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -526,7 +526,7 @@ static int alc5623_set_dai_pll(struct snd_soc_dai *codec_dai, int pll_id,
|
|||
int source, unsigned int freq_in, unsigned int freq_out)
|
||||
{
|
||||
int i;
|
||||
struct snd_soc_codec *codec = codec_dai->codec;
|
||||
struct snd_soc_component *component = codec_dai->component;
|
||||
int gbl_clk = 0, pll_div = 0;
|
||||
u16 reg;
|
||||
|
||||
|
@ -534,12 +534,12 @@ static int alc5623_set_dai_pll(struct snd_soc_dai *codec_dai, int pll_id,
|
|||
return -ENODEV;
|
||||
|
||||
/* Disable PLL power */
|
||||
snd_soc_update_bits(codec, ALC5623_PWR_MANAG_ADD2,
|
||||
snd_soc_component_update_bits(component, ALC5623_PWR_MANAG_ADD2,
|
||||
ALC5623_PWR_ADD2_PLL,
|
||||
0);
|
||||
|
||||
/* pll is not used in slave mode */
|
||||
reg = snd_soc_read(codec, ALC5623_DAI_CONTROL);
|
||||
reg = snd_soc_component_read32(component, ALC5623_DAI_CONTROL);
|
||||
if (reg & ALC5623_DAI_SDP_SLAVE_MODE)
|
||||
return 0;
|
||||
|
||||
|
@ -575,13 +575,13 @@ static int alc5623_set_dai_pll(struct snd_soc_dai *codec_dai, int pll_id,
|
|||
if (!pll_div)
|
||||
return -EINVAL;
|
||||
|
||||
snd_soc_write(codec, ALC5623_GLOBAL_CLK_CTRL_REG, gbl_clk);
|
||||
snd_soc_write(codec, ALC5623_PLL_CTRL, pll_div);
|
||||
snd_soc_update_bits(codec, ALC5623_PWR_MANAG_ADD2,
|
||||
snd_soc_component_write(component, ALC5623_GLOBAL_CLK_CTRL_REG, gbl_clk);
|
||||
snd_soc_component_write(component, ALC5623_PLL_CTRL, pll_div);
|
||||
snd_soc_component_update_bits(component, ALC5623_PWR_MANAG_ADD2,
|
||||
ALC5623_PWR_ADD2_PLL,
|
||||
ALC5623_PWR_ADD2_PLL);
|
||||
gbl_clk |= ALC5623_GBL_CLK_SYS_SOUR_SEL_PLL;
|
||||
snd_soc_write(codec, ALC5623_GLOBAL_CLK_CTRL_REG, gbl_clk);
|
||||
snd_soc_component_write(component, ALC5623_GLOBAL_CLK_CTRL_REG, gbl_clk);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -604,9 +604,9 @@ static const struct _coeff_div coeff_div[] = {
|
|||
{384*1, 0x0c6b},
|
||||
};
|
||||
|
||||
static int get_coeff(struct snd_soc_codec *codec, int rate)
|
||||
static int get_coeff(struct snd_soc_component *component, int rate)
|
||||
{
|
||||
struct alc5623_priv *alc5623 = snd_soc_codec_get_drvdata(codec);
|
||||
struct alc5623_priv *alc5623 = snd_soc_component_get_drvdata(component);
|
||||
int i;
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE(coeff_div); i++) {
|
||||
|
@ -622,8 +622,8 @@ static int get_coeff(struct snd_soc_codec *codec, int rate)
|
|||
static int alc5623_set_dai_sysclk(struct snd_soc_dai *codec_dai,
|
||||
int clk_id, unsigned int freq, int dir)
|
||||
{
|
||||
struct snd_soc_codec *codec = codec_dai->codec;
|
||||
struct alc5623_priv *alc5623 = snd_soc_codec_get_drvdata(codec);
|
||||
struct snd_soc_component *component = codec_dai->component;
|
||||
struct alc5623_priv *alc5623 = snd_soc_component_get_drvdata(component);
|
||||
|
||||
switch (freq) {
|
||||
case 8192000:
|
||||
|
@ -643,7 +643,7 @@ static int alc5623_set_dai_sysclk(struct snd_soc_dai *codec_dai,
|
|||
static int alc5623_set_dai_fmt(struct snd_soc_dai *codec_dai,
|
||||
unsigned int fmt)
|
||||
{
|
||||
struct snd_soc_codec *codec = codec_dai->codec;
|
||||
struct snd_soc_component *component = codec_dai->component;
|
||||
u16 iface = 0;
|
||||
|
||||
/* set master/slave audio interface */
|
||||
|
@ -695,18 +695,18 @@ static int alc5623_set_dai_fmt(struct snd_soc_dai *codec_dai,
|
|||
return -EINVAL;
|
||||
}
|
||||
|
||||
return snd_soc_write(codec, ALC5623_DAI_CONTROL, iface);
|
||||
return snd_soc_component_write(component, ALC5623_DAI_CONTROL, iface);
|
||||
}
|
||||
|
||||
static int alc5623_pcm_hw_params(struct snd_pcm_substream *substream,
|
||||
struct snd_pcm_hw_params *params, struct snd_soc_dai *dai)
|
||||
{
|
||||
struct snd_soc_codec *codec = dai->codec;
|
||||
struct alc5623_priv *alc5623 = snd_soc_codec_get_drvdata(codec);
|
||||
struct snd_soc_component *component = dai->component;
|
||||
struct alc5623_priv *alc5623 = snd_soc_component_get_drvdata(component);
|
||||
int coeff, rate;
|
||||
u16 iface;
|
||||
|
||||
iface = snd_soc_read(codec, ALC5623_DAI_CONTROL);
|
||||
iface = snd_soc_component_read32(component, ALC5623_DAI_CONTROL);
|
||||
iface &= ~ALC5623_DAI_I2S_DL_MASK;
|
||||
|
||||
/* bit size */
|
||||
|
@ -728,30 +728,30 @@ static int alc5623_pcm_hw_params(struct snd_pcm_substream *substream,
|
|||
}
|
||||
|
||||
/* set iface & srate */
|
||||
snd_soc_write(codec, ALC5623_DAI_CONTROL, iface);
|
||||
snd_soc_component_write(component, ALC5623_DAI_CONTROL, iface);
|
||||
rate = params_rate(params);
|
||||
coeff = get_coeff(codec, rate);
|
||||
coeff = get_coeff(component, rate);
|
||||
if (coeff < 0)
|
||||
return -EINVAL;
|
||||
|
||||
coeff = coeff_div[coeff].regvalue;
|
||||
dev_dbg(codec->dev, "%s: sysclk=%d,rate=%d,coeff=0x%04x\n",
|
||||
dev_dbg(component->dev, "%s: sysclk=%d,rate=%d,coeff=0x%04x\n",
|
||||
__func__, alc5623->sysclk, rate, coeff);
|
||||
snd_soc_write(codec, ALC5623_STEREO_AD_DA_CLK_CTRL, coeff);
|
||||
snd_soc_component_write(component, ALC5623_STEREO_AD_DA_CLK_CTRL, coeff);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int alc5623_mute(struct snd_soc_dai *dai, int mute)
|
||||
{
|
||||
struct snd_soc_codec *codec = dai->codec;
|
||||
struct snd_soc_component *component = dai->component;
|
||||
u16 hp_mute = ALC5623_MISC_M_DAC_L_INPUT | ALC5623_MISC_M_DAC_R_INPUT;
|
||||
u16 mute_reg = snd_soc_read(codec, ALC5623_MISC_CTRL) & ~hp_mute;
|
||||
u16 mute_reg = snd_soc_component_read32(component, ALC5623_MISC_CTRL) & ~hp_mute;
|
||||
|
||||
if (mute)
|
||||
mute_reg |= hp_mute;
|
||||
|
||||
return snd_soc_write(codec, ALC5623_MISC_CTRL, mute_reg);
|
||||
return snd_soc_component_write(component, ALC5623_MISC_CTRL, mute_reg);
|
||||
}
|
||||
|
||||
#define ALC5623_ADD2_POWER_EN (ALC5623_PWR_ADD2_VREF \
|
||||
|
@ -769,60 +769,60 @@ static int alc5623_mute(struct snd_soc_dai *dai, int mute)
|
|||
(ALC5623_PWR_ADD1_SHORT_CURR_DET_EN \
|
||||
| ALC5623_PWR_ADD1_HP_OUT_AMP)
|
||||
|
||||
static void enable_power_depop(struct snd_soc_codec *codec)
|
||||
static void enable_power_depop(struct snd_soc_component *component)
|
||||
{
|
||||
struct alc5623_priv *alc5623 = snd_soc_codec_get_drvdata(codec);
|
||||
struct alc5623_priv *alc5623 = snd_soc_component_get_drvdata(component);
|
||||
|
||||
snd_soc_update_bits(codec, ALC5623_PWR_MANAG_ADD1,
|
||||
snd_soc_component_update_bits(component, ALC5623_PWR_MANAG_ADD1,
|
||||
ALC5623_PWR_ADD1_SOFTGEN_EN,
|
||||
ALC5623_PWR_ADD1_SOFTGEN_EN);
|
||||
|
||||
snd_soc_write(codec, ALC5623_PWR_MANAG_ADD3, ALC5623_ADD3_POWER_EN);
|
||||
snd_soc_component_write(component, ALC5623_PWR_MANAG_ADD3, ALC5623_ADD3_POWER_EN);
|
||||
|
||||
snd_soc_update_bits(codec, ALC5623_MISC_CTRL,
|
||||
snd_soc_component_update_bits(component, ALC5623_MISC_CTRL,
|
||||
ALC5623_MISC_HP_DEPOP_MODE2_EN,
|
||||
ALC5623_MISC_HP_DEPOP_MODE2_EN);
|
||||
|
||||
msleep(500);
|
||||
|
||||
snd_soc_write(codec, ALC5623_PWR_MANAG_ADD2, ALC5623_ADD2_POWER_EN);
|
||||
snd_soc_component_write(component, ALC5623_PWR_MANAG_ADD2, ALC5623_ADD2_POWER_EN);
|
||||
|
||||
/* avoid writing '1' into 5622 reserved bits */
|
||||
if (alc5623->id == 0x22)
|
||||
snd_soc_write(codec, ALC5623_PWR_MANAG_ADD1,
|
||||
snd_soc_component_write(component, ALC5623_PWR_MANAG_ADD1,
|
||||
ALC5623_ADD1_POWER_EN_5622);
|
||||
else
|
||||
snd_soc_write(codec, ALC5623_PWR_MANAG_ADD1,
|
||||
snd_soc_component_write(component, ALC5623_PWR_MANAG_ADD1,
|
||||
ALC5623_ADD1_POWER_EN);
|
||||
|
||||
/* disable HP Depop2 */
|
||||
snd_soc_update_bits(codec, ALC5623_MISC_CTRL,
|
||||
snd_soc_component_update_bits(component, ALC5623_MISC_CTRL,
|
||||
ALC5623_MISC_HP_DEPOP_MODE2_EN,
|
||||
0);
|
||||
|
||||
}
|
||||
|
||||
static int alc5623_set_bias_level(struct snd_soc_codec *codec,
|
||||
static int alc5623_set_bias_level(struct snd_soc_component *component,
|
||||
enum snd_soc_bias_level level)
|
||||
{
|
||||
switch (level) {
|
||||
case SND_SOC_BIAS_ON:
|
||||
enable_power_depop(codec);
|
||||
enable_power_depop(component);
|
||||
break;
|
||||
case SND_SOC_BIAS_PREPARE:
|
||||
break;
|
||||
case SND_SOC_BIAS_STANDBY:
|
||||
/* everything off except vref/vmid, */
|
||||
snd_soc_write(codec, ALC5623_PWR_MANAG_ADD2,
|
||||
snd_soc_component_write(component, ALC5623_PWR_MANAG_ADD2,
|
||||
ALC5623_PWR_ADD2_VREF);
|
||||
snd_soc_write(codec, ALC5623_PWR_MANAG_ADD3,
|
||||
snd_soc_component_write(component, ALC5623_PWR_MANAG_ADD3,
|
||||
ALC5623_PWR_ADD3_MAIN_BIAS);
|
||||
break;
|
||||
case SND_SOC_BIAS_OFF:
|
||||
/* everything off, dac mute, inactive */
|
||||
snd_soc_write(codec, ALC5623_PWR_MANAG_ADD2, 0);
|
||||
snd_soc_write(codec, ALC5623_PWR_MANAG_ADD3, 0);
|
||||
snd_soc_write(codec, ALC5623_PWR_MANAG_ADD1, 0);
|
||||
snd_soc_component_write(component, ALC5623_PWR_MANAG_ADD2, 0);
|
||||
snd_soc_component_write(component, ALC5623_PWR_MANAG_ADD3, 0);
|
||||
snd_soc_component_write(component, ALC5623_PWR_MANAG_ADD1, 0);
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
|
@ -862,25 +862,25 @@ static struct snd_soc_dai_driver alc5623_dai = {
|
|||
.ops = &alc5623_dai_ops,
|
||||
};
|
||||
|
||||
static int alc5623_suspend(struct snd_soc_codec *codec)
|
||||
static int alc5623_suspend(struct snd_soc_component *component)
|
||||
{
|
||||
struct alc5623_priv *alc5623 = snd_soc_codec_get_drvdata(codec);
|
||||
struct alc5623_priv *alc5623 = snd_soc_component_get_drvdata(component);
|
||||
|
||||
regcache_cache_only(alc5623->regmap, true);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int alc5623_resume(struct snd_soc_codec *codec)
|
||||
static int alc5623_resume(struct snd_soc_component *component)
|
||||
{
|
||||
struct alc5623_priv *alc5623 = snd_soc_codec_get_drvdata(codec);
|
||||
struct alc5623_priv *alc5623 = snd_soc_component_get_drvdata(component);
|
||||
int ret;
|
||||
|
||||
/* Sync reg_cache with the hardware */
|
||||
regcache_cache_only(alc5623->regmap, false);
|
||||
ret = regcache_sync(alc5623->regmap);
|
||||
if (ret != 0) {
|
||||
dev_err(codec->dev, "Failed to sync register cache: %d\n",
|
||||
dev_err(component->dev, "Failed to sync register cache: %d\n",
|
||||
ret);
|
||||
regcache_cache_only(alc5623->regmap, true);
|
||||
return ret;
|
||||
|
@ -889,41 +889,41 @@ static int alc5623_resume(struct snd_soc_codec *codec)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int alc5623_probe(struct snd_soc_codec *codec)
|
||||
static int alc5623_probe(struct snd_soc_component *component)
|
||||
{
|
||||
struct alc5623_priv *alc5623 = snd_soc_codec_get_drvdata(codec);
|
||||
struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec);
|
||||
struct alc5623_priv *alc5623 = snd_soc_component_get_drvdata(component);
|
||||
struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component);
|
||||
|
||||
alc5623_reset(codec);
|
||||
alc5623_reset(component);
|
||||
|
||||
if (alc5623->add_ctrl) {
|
||||
snd_soc_write(codec, ALC5623_ADD_CTRL_REG,
|
||||
snd_soc_component_write(component, ALC5623_ADD_CTRL_REG,
|
||||
alc5623->add_ctrl);
|
||||
}
|
||||
|
||||
if (alc5623->jack_det_ctrl) {
|
||||
snd_soc_write(codec, ALC5623_JACK_DET_CTRL,
|
||||
snd_soc_component_write(component, ALC5623_JACK_DET_CTRL,
|
||||
alc5623->jack_det_ctrl);
|
||||
}
|
||||
|
||||
switch (alc5623->id) {
|
||||
case 0x21:
|
||||
snd_soc_add_codec_controls(codec, alc5621_vol_snd_controls,
|
||||
snd_soc_add_component_controls(component, alc5621_vol_snd_controls,
|
||||
ARRAY_SIZE(alc5621_vol_snd_controls));
|
||||
break;
|
||||
case 0x22:
|
||||
snd_soc_add_codec_controls(codec, alc5622_vol_snd_controls,
|
||||
snd_soc_add_component_controls(component, alc5622_vol_snd_controls,
|
||||
ARRAY_SIZE(alc5622_vol_snd_controls));
|
||||
break;
|
||||
case 0x23:
|
||||
snd_soc_add_codec_controls(codec, alc5623_vol_snd_controls,
|
||||
snd_soc_add_component_controls(component, alc5623_vol_snd_controls,
|
||||
ARRAY_SIZE(alc5623_vol_snd_controls));
|
||||
break;
|
||||
default:
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
snd_soc_add_codec_controls(codec, alc5623_snd_controls,
|
||||
snd_soc_add_component_controls(component, alc5623_snd_controls,
|
||||
ARRAY_SIZE(alc5623_snd_controls));
|
||||
|
||||
snd_soc_dapm_new_controls(dapm, alc5623_dapm_widgets,
|
||||
|
@ -951,12 +951,16 @@ static int alc5623_probe(struct snd_soc_codec *codec)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static const struct snd_soc_codec_driver soc_codec_device_alc5623 = {
|
||||
.probe = alc5623_probe,
|
||||
.suspend = alc5623_suspend,
|
||||
.resume = alc5623_resume,
|
||||
.set_bias_level = alc5623_set_bias_level,
|
||||
.suspend_bias_off = true,
|
||||
static const struct snd_soc_component_driver soc_component_device_alc5623 = {
|
||||
.probe = alc5623_probe,
|
||||
.suspend = alc5623_suspend,
|
||||
.resume = alc5623_resume,
|
||||
.set_bias_level = alc5623_set_bias_level,
|
||||
.suspend_bias_off = 1,
|
||||
.idle_bias_on = 1,
|
||||
.use_pmdown_time = 1,
|
||||
.endianness = 1,
|
||||
.non_legacy_dai_naming = 1,
|
||||
};
|
||||
|
||||
static const struct regmap_config alc5623_regmap = {
|
||||
|
@ -1052,20 +1056,14 @@ static int alc5623_i2c_probe(struct i2c_client *client,
|
|||
|
||||
i2c_set_clientdata(client, alc5623);
|
||||
|
||||
ret = snd_soc_register_codec(&client->dev,
|
||||
&soc_codec_device_alc5623, &alc5623_dai, 1);
|
||||
ret = devm_snd_soc_register_component(&client->dev,
|
||||
&soc_component_device_alc5623, &alc5623_dai, 1);
|
||||
if (ret != 0)
|
||||
dev_err(&client->dev, "Failed to register codec: %d\n", ret);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int alc5623_i2c_remove(struct i2c_client *client)
|
||||
{
|
||||
snd_soc_unregister_codec(&client->dev);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const struct i2c_device_id alc5623_i2c_table[] = {
|
||||
{"alc5621", 0x21},
|
||||
{"alc5622", 0x22},
|
||||
|
@ -1087,7 +1085,6 @@ static struct i2c_driver alc5623_i2c_driver = {
|
|||
.of_match_table = of_match_ptr(alc5623_of_match),
|
||||
},
|
||||
.probe = alc5623_i2c_probe,
|
||||
.remove = alc5623_i2c_remove,
|
||||
.id_table = alc5623_i2c_table,
|
||||
};
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче