Commit cb7e6225 authored by Helen Koike's avatar Helen Koike Committed by Mark Brown

ASoC: tpa6130a2: Register component

Add tpa6130a2 controls by the component API and update rx51 accordingly
Signed-off-by: default avatarLars-Peter Clausen <lars@metafoo.de>
[koike: port for upstream]
Signed-off-by: default avatarHelen Koike <helen.koike@collabora.co.uk>
Tested-By: default avatarSebastian Reichel <sre@kernel.org>
Reviewed-By: default avatarSebastian Reichel <sre@kernel.org>
Signed-off-by: default avatarMark Brown <broonie@kernel.org>
parent 1a695a90
...@@ -273,7 +273,7 @@ static const DECLARE_TLV_DB_RANGE(tpa6130_tlv, ...@@ -273,7 +273,7 @@ static const DECLARE_TLV_DB_RANGE(tpa6130_tlv,
); );
static const struct snd_kcontrol_new tpa6130a2_controls[] = { static const struct snd_kcontrol_new tpa6130a2_controls[] = {
SOC_SINGLE_EXT_TLV("TPA6130A2 Headphone Playback Volume", SOC_SINGLE_EXT_TLV("Headphone Playback Volume",
TPA6130A2_REG_VOL_MUTE, 0, 0x3f, 0, TPA6130A2_REG_VOL_MUTE, 0, 0x3f, 0,
tpa6130a2_get_volsw, tpa6130a2_put_volsw, tpa6130a2_get_volsw, tpa6130a2_put_volsw,
tpa6130_tlv), tpa6130_tlv),
...@@ -286,7 +286,7 @@ static const DECLARE_TLV_DB_RANGE(tpa6140_tlv, ...@@ -286,7 +286,7 @@ static const DECLARE_TLV_DB_RANGE(tpa6140_tlv,
); );
static const struct snd_kcontrol_new tpa6140a2_controls[] = { static const struct snd_kcontrol_new tpa6140a2_controls[] = {
SOC_SINGLE_EXT_TLV("TPA6140A2 Headphone Playback Volume", SOC_SINGLE_EXT_TLV("Headphone Playback Volume",
TPA6130A2_REG_VOL_MUTE, 1, 0x1f, 0, TPA6130A2_REG_VOL_MUTE, 1, 0x1f, 0,
tpa6130a2_get_volsw, tpa6130a2_put_volsw, tpa6130a2_get_volsw, tpa6130a2_put_volsw,
tpa6140_tlv), tpa6140_tlv),
...@@ -348,23 +348,22 @@ int tpa6130a2_stereo_enable(struct snd_soc_codec *codec, int enable) ...@@ -348,23 +348,22 @@ int tpa6130a2_stereo_enable(struct snd_soc_codec *codec, int enable)
} }
EXPORT_SYMBOL_GPL(tpa6130a2_stereo_enable); EXPORT_SYMBOL_GPL(tpa6130a2_stereo_enable);
int tpa6130a2_add_controls(struct snd_soc_codec *codec) static int tpa6130a2_component_probe(struct snd_soc_component *component)
{ {
struct tpa6130a2_data *data; struct tpa6130a2_data *data = snd_soc_component_get_drvdata(component);
if (tpa6130a2_client == NULL)
return -ENODEV;
data = i2c_get_clientdata(tpa6130a2_client);
if (data->id == TPA6140A2) if (data->id == TPA6140A2)
return snd_soc_add_codec_controls(codec, tpa6140a2_controls, return snd_soc_add_component_controls(component,
ARRAY_SIZE(tpa6140a2_controls)); tpa6140a2_controls, ARRAY_SIZE(tpa6140a2_controls));
else else
return snd_soc_add_codec_controls(codec, tpa6130a2_controls, return snd_soc_add_component_controls(component,
ARRAY_SIZE(tpa6130a2_controls)); tpa6130a2_controls, ARRAY_SIZE(tpa6130a2_controls));
} }
EXPORT_SYMBOL_GPL(tpa6130a2_add_controls);
struct snd_soc_component_driver tpa6130a2_component_driver = {
.name = "tpa6130a2",
.probe = tpa6130a2_component_probe,
};
static int tpa6130a2_probe(struct i2c_client *client, static int tpa6130a2_probe(struct i2c_client *client,
const struct i2c_device_id *id) const struct i2c_device_id *id)
...@@ -451,7 +450,8 @@ static int tpa6130a2_probe(struct i2c_client *client, ...@@ -451,7 +450,8 @@ static int tpa6130a2_probe(struct i2c_client *client,
if (ret != 0) if (ret != 0)
goto err_gpio; goto err_gpio;
return 0; return devm_snd_soc_register_component(&client->dev,
&tpa6130a2_component_driver, NULL, 0);
err_gpio: err_gpio:
tpa6130a2_client = NULL; tpa6130a2_client = NULL;
......
...@@ -56,7 +56,6 @@ ...@@ -56,7 +56,6 @@
/* TPA6130A2_REG_VERSION (0x04) */ /* TPA6130A2_REG_VERSION (0x04) */
#define TPA6130A2_VERSION_MASK (0x0f) #define TPA6130A2_VERSION_MASK (0x0f)
extern int tpa6130a2_add_controls(struct snd_soc_codec *codec);
extern int tpa6130a2_stereo_enable(struct snd_soc_codec *codec, int enable); extern int tpa6130a2_stereo_enable(struct snd_soc_codec *codec, int enable);
#endif /* __TPA6130A2_H__ */ #endif /* __TPA6130A2_H__ */
...@@ -286,16 +286,10 @@ static const struct snd_kcontrol_new aic34_rx51_controls[] = { ...@@ -286,16 +286,10 @@ static const struct snd_kcontrol_new aic34_rx51_controls[] = {
static int rx51_aic34_init(struct snd_soc_pcm_runtime *rtd) static int rx51_aic34_init(struct snd_soc_pcm_runtime *rtd)
{ {
struct snd_soc_codec *codec = rtd->codec;
struct snd_soc_card *card = rtd->card; struct snd_soc_card *card = rtd->card;
struct rx51_audio_pdata *pdata = snd_soc_card_get_drvdata(card); struct rx51_audio_pdata *pdata = snd_soc_card_get_drvdata(card);
int err; int err;
err = tpa6130a2_add_controls(codec);
if (err < 0) {
dev_err(card->dev, "Failed to add TPA6130A2 controls\n");
return err;
}
snd_soc_limit_volume(card, "TPA6130A2 Headphone Playback Volume", 42); snd_soc_limit_volume(card, "TPA6130A2 Headphone Playback Volume", 42);
err = omap_mcbsp_st_add_controls(rtd, 2); err = omap_mcbsp_st_add_controls(rtd, 2);
...@@ -357,6 +351,10 @@ static struct snd_soc_aux_dev rx51_aux_dev[] = { ...@@ -357,6 +351,10 @@ static struct snd_soc_aux_dev rx51_aux_dev[] = {
.name = "TLV320AIC34b", .name = "TLV320AIC34b",
.codec_name = "tlv320aic3x-codec.2-0019", .codec_name = "tlv320aic3x-codec.2-0019",
}, },
{
.name = "TPA61320A2",
.codec_name = "tpa6130a2.2-0060",
},
}; };
static struct snd_soc_codec_conf rx51_codec_conf[] = { static struct snd_soc_codec_conf rx51_codec_conf[] = {
...@@ -364,6 +362,10 @@ static struct snd_soc_codec_conf rx51_codec_conf[] = { ...@@ -364,6 +362,10 @@ static struct snd_soc_codec_conf rx51_codec_conf[] = {
.dev_name = "tlv320aic3x-codec.2-0019", .dev_name = "tlv320aic3x-codec.2-0019",
.name_prefix = "b", .name_prefix = "b",
}, },
{
.dev_name = "tpa6130a2.2-0060",
.name_prefix = "TPA6130A2",
},
}; };
/* Audio card */ /* Audio card */
...@@ -435,11 +437,10 @@ static int rx51_soc_probe(struct platform_device *pdev) ...@@ -435,11 +437,10 @@ static int rx51_soc_probe(struct platform_device *pdev)
dev_err(&pdev->dev, "Headphone amplifier node is not provided\n"); dev_err(&pdev->dev, "Headphone amplifier node is not provided\n");
return -EINVAL; return -EINVAL;
} }
rx51_aux_dev[1].codec_name = NULL;
/* TODO: tpa6130a2a driver supports only a single instance, so rx51_aux_dev[1].codec_of_node = dai_node;
* this driver ignores the headphone-amplifier node for now. rx51_codec_conf[1].dev_name = NULL;
* It's already mandatory in the DT binding to be future proof. rx51_codec_conf[1].of_node = dai_node;
*/
} }
pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL); pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL);
......
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