aboutsummaryrefslogtreecommitdiffstats
path: root/sound/soc/codecs/tas2562.c
diff options
context:
space:
mode:
Diffstat (limited to 'sound/soc/codecs/tas2562.c')
-rw-r--r--sound/soc/codecs/tas2562.c121
1 files changed, 44 insertions, 77 deletions
diff --git a/sound/soc/codecs/tas2562.c b/sound/soc/codecs/tas2562.c
index 10302552195e..b486d0bd86c9 100644
--- a/sound/soc/codecs/tas2562.c
+++ b/sound/soc/codecs/tas2562.c
@@ -54,6 +54,8 @@ struct tas2562_data {
int i_sense_slot;
int volume_lvl;
int model_id;
+ bool dac_powered;
+ bool unmuted;
};
enum tas256x_model {
@@ -63,39 +65,6 @@ enum tas256x_model {
TAS2110,
};
-static int tas2562_set_bias_level(struct snd_soc_component *component,
- enum snd_soc_bias_level level)
-{
- struct tas2562_data *tas2562 =
- snd_soc_component_get_drvdata(component);
-
- switch (level) {
- case SND_SOC_BIAS_ON:
- snd_soc_component_update_bits(component,
- TAS2562_PWR_CTRL,
- TAS2562_MODE_MASK, TAS2562_ACTIVE);
- break;
- case SND_SOC_BIAS_STANDBY:
- case SND_SOC_BIAS_PREPARE:
- snd_soc_component_update_bits(component,
- TAS2562_PWR_CTRL,
- TAS2562_MODE_MASK, TAS2562_MUTE);
- break;
- case SND_SOC_BIAS_OFF:
- snd_soc_component_update_bits(component,
- TAS2562_PWR_CTRL,
- TAS2562_MODE_MASK, TAS2562_SHUTDOWN);
- break;
-
- default:
- dev_err(tas2562->dev,
- "wrong power level setting %d\n", level);
- return -EINVAL;
- }
-
- return 0;
-}
-
static int tas2562_set_samplerate(struct tas2562_data *tas2562, int samplerate)
{
int samp_rate;
@@ -384,30 +353,43 @@ static int tas2562_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt)
return 0;
}
+static int tas2562_update_pwr_ctrl(struct tas2562_data *tas2562)
+{
+ struct snd_soc_component *component = tas2562->component;
+ unsigned int val;
+ int ret;
+
+ if (tas2562->dac_powered)
+ val = tas2562->unmuted ?
+ TAS2562_ACTIVE : TAS2562_MUTE;
+ else
+ val = TAS2562_SHUTDOWN;
+
+ ret = snd_soc_component_update_bits(component, TAS2562_PWR_CTRL,
+ TAS2562_MODE_MASK, val);
+ if (ret < 0)
+ return ret;
+
+ return 0;
+}
+
static int tas2562_mute(struct snd_soc_dai *dai, int mute, int direction)
{
- struct snd_soc_component *component = dai->component;
+ struct tas2562_data *tas2562 = snd_soc_component_get_drvdata(dai->component);
- return snd_soc_component_update_bits(component, TAS2562_PWR_CTRL,
- TAS2562_MODE_MASK,
- mute ? TAS2562_MUTE : 0);
+ tas2562->unmuted = !mute;
+ return tas2562_update_pwr_ctrl(tas2562);
}
static int tas2562_codec_probe(struct snd_soc_component *component)
{
struct tas2562_data *tas2562 = snd_soc_component_get_drvdata(component);
- int ret;
tas2562->component = component;
if (tas2562->sdz_gpio)
gpiod_set_value_cansleep(tas2562->sdz_gpio, 1);
- ret = snd_soc_component_update_bits(component, TAS2562_PWR_CTRL,
- TAS2562_MODE_MASK, TAS2562_MUTE);
- if (ret < 0)
- return ret;
-
return 0;
}
@@ -457,35 +439,23 @@ static int tas2562_dac_event(struct snd_soc_dapm_widget *w,
struct snd_soc_component *component =
snd_soc_dapm_to_component(w->dapm);
struct tas2562_data *tas2562 = snd_soc_component_get_drvdata(component);
- int ret;
+ int ret = 0;
switch (event) {
case SND_SOC_DAPM_POST_PMU:
- ret = snd_soc_component_update_bits(component,
- TAS2562_PWR_CTRL,
- TAS2562_MODE_MASK,
- TAS2562_MUTE);
- if (ret)
- goto end;
+ tas2562->dac_powered = true;
+ ret = tas2562_update_pwr_ctrl(tas2562);
break;
case SND_SOC_DAPM_PRE_PMD:
- ret = snd_soc_component_update_bits(component,
- TAS2562_PWR_CTRL,
- TAS2562_MODE_MASK,
- TAS2562_SHUTDOWN);
- if (ret)
- goto end;
+ tas2562->dac_powered = false;
+ ret = tas2562_update_pwr_ctrl(tas2562);
break;
default:
dev_err(tas2562->dev, "Not supported evevt\n");
return -EINVAL;
}
-end:
- if (ret < 0)
- return ret;
-
- return 0;
+ return ret;
}
static int tas2562_volume_control_get(struct snd_kcontrol *kcontrol,
@@ -579,7 +549,6 @@ static const struct snd_soc_component_driver soc_component_dev_tas2110 = {
.probe = tas2562_codec_probe,
.suspend = tas2562_suspend,
.resume = tas2562_resume,
- .set_bias_level = tas2562_set_bias_level,
.controls = tas2562_snd_controls,
.num_controls = ARRAY_SIZE(tas2562_snd_controls),
.dapm_widgets = tas2110_dapm_widgets,
@@ -589,7 +558,6 @@ static const struct snd_soc_component_driver soc_component_dev_tas2110 = {
.idle_bias_on = 1,
.use_pmdown_time = 1,
.endianness = 1,
- .non_legacy_dai_naming = 1,
};
static const struct snd_soc_dapm_widget tas2562_dapm_widgets[] = {
@@ -619,7 +587,6 @@ static const struct snd_soc_component_driver soc_component_dev_tas2562 = {
.probe = tas2562_codec_probe,
.suspend = tas2562_suspend,
.resume = tas2562_resume,
- .set_bias_level = tas2562_set_bias_level,
.controls = tas2562_snd_controls,
.num_controls = ARRAY_SIZE(tas2562_snd_controls),
.dapm_widgets = tas2562_dapm_widgets,
@@ -629,7 +596,6 @@ static const struct snd_soc_component_driver soc_component_dev_tas2562 = {
.idle_bias_on = 1,
.use_pmdown_time = 1,
.endianness = 1,
- .non_legacy_dai_naming = 1,
};
static const struct snd_soc_dai_ops tas2562_speaker_dai_ops = {
@@ -754,17 +720,27 @@ static int tas2562_parse_dt(struct tas2562_data *tas2562)
return ret;
}
-static int tas2562_probe(struct i2c_client *client,
- const struct i2c_device_id *id)
+static const struct i2c_device_id tas2562_id[] = {
+ { "tas2562", TAS2562 },
+ { "tas2563", TAS2563 },
+ { "tas2564", TAS2564 },
+ { "tas2110", TAS2110 },
+ { }
+};
+MODULE_DEVICE_TABLE(i2c, tas2562_id);
+
+static int tas2562_probe(struct i2c_client *client)
{
struct device *dev = &client->dev;
struct tas2562_data *data;
int ret;
+ const struct i2c_device_id *id;
data = devm_kzalloc(dev, sizeof(*data), GFP_KERNEL);
if (!data)
return -ENOMEM;
+ id = i2c_match_id(tas2562_id, client);
data->client = client;
data->dev = &client->dev;
data->model_id = id->driver_data;
@@ -792,15 +768,6 @@ static int tas2562_probe(struct i2c_client *client,
}
-static const struct i2c_device_id tas2562_id[] = {
- { "tas2562", TAS2562 },
- { "tas2563", TAS2563 },
- { "tas2564", TAS2564 },
- { "tas2110", TAS2110 },
- { }
-};
-MODULE_DEVICE_TABLE(i2c, tas2562_id);
-
#ifdef CONFIG_OF
static const struct of_device_id tas2562_of_match[] = {
{ .compatible = "ti,tas2562", },
@@ -817,7 +784,7 @@ static struct i2c_driver tas2562_i2c_driver = {
.name = "tas2562",
.of_match_table = of_match_ptr(tas2562_of_match),
},
- .probe = tas2562_probe,
+ .probe_new = tas2562_probe,
.id_table = tas2562_id,
};