Merge remote-tracking branches 'asoc/topic/isabelle', 'asoc/topic/jz4740', 'asoc/topic/lm49453', 'asoc/topic/max9759' and 'asoc/topic/max98088' into asoc-next
This commit is contained in:
commit
8d8084d859
|
@ -0,0 +1,18 @@
|
|||
Maxim MAX9759 Speaker Amplifier
|
||||
===============================
|
||||
|
||||
Required properties:
|
||||
- compatible : "maxim,max9759"
|
||||
- shutdown-gpios : the gpio connected to the shutdown pin
|
||||
- mute-gpios : the gpio connected to the mute pin
|
||||
- gain-gpios : the 2 gpios connected to the g1 and g2 pins
|
||||
|
||||
Example:
|
||||
|
||||
max9759: analog-amplifier {
|
||||
compatible = "maxim,max9759";
|
||||
shutdown-gpios = <&gpio3 20 GPIO_ACTIVE_LOW>;
|
||||
mute-gpios = <&gpio3 19 GPIO_ACTIVE_LOW>;
|
||||
gain-gpios = <&gpio3 23 GPIO_ACTIVE_LOW>,
|
||||
<&gpio3 25 GPIO_ACTIVE_LOW>;
|
||||
};
|
|
@ -101,6 +101,7 @@ config SND_SOC_ALL_CODECS
|
|||
select SND_SOC_MAX98373 if I2C
|
||||
select SND_SOC_MAX9850 if I2C
|
||||
select SND_SOC_MAX9860 if I2C
|
||||
select SND_SOC_MAX9759
|
||||
select SND_SOC_MAX9768 if I2C
|
||||
select SND_SOC_MAX9877 if I2C
|
||||
select SND_SOC_MC13783 if MFD_MC13XXX
|
||||
|
@ -1223,6 +1224,10 @@ config SND_SOC_ZX_AUD96P22
|
|||
config SND_SOC_LM4857
|
||||
tristate
|
||||
|
||||
config SND_SOC_MAX9759
|
||||
tristate "Maxim MAX9759 speaker Amplifier"
|
||||
select GPIOLIB
|
||||
|
||||
config SND_SOC_MAX9768
|
||||
tristate
|
||||
|
||||
|
|
|
@ -84,6 +84,7 @@ snd-soc-jz4740-codec-objs := jz4740.o
|
|||
snd-soc-l3-objs := l3.o
|
||||
snd-soc-lm4857-objs := lm4857.o
|
||||
snd-soc-lm49453-objs := lm49453.o
|
||||
snd-soc-max9759-objs := max9759.o
|
||||
snd-soc-max9768-objs := max9768.o
|
||||
snd-soc-max98088-objs := max98088.o
|
||||
snd-soc-max98090-objs := max98090.o
|
||||
|
@ -335,6 +336,7 @@ obj-$(CONFIG_SND_SOC_JZ4740_CODEC) += snd-soc-jz4740-codec.o
|
|||
obj-$(CONFIG_SND_SOC_L3) += snd-soc-l3.o
|
||||
obj-$(CONFIG_SND_SOC_LM4857) += snd-soc-lm4857.o
|
||||
obj-$(CONFIG_SND_SOC_LM49453) += snd-soc-lm49453.o
|
||||
obj-$(CONFIG_SND_SOC_MAX9759) += snd-soc-max9759.o
|
||||
obj-$(CONFIG_SND_SOC_MAX9768) += snd-soc-max9768.o
|
||||
obj-$(CONFIG_SND_SOC_MAX98088) += snd-soc-max98088.o
|
||||
obj-$(CONFIG_SND_SOC_MAX98090) += snd-soc-max98090.o
|
||||
|
|
|
@ -867,7 +867,7 @@ static const struct snd_soc_dapm_route isabelle_intercon[] = {
|
|||
|
||||
static int isabelle_hs_mute(struct snd_soc_dai *dai, int mute)
|
||||
{
|
||||
snd_soc_update_bits(dai->codec, ISABELLE_DAC1_SOFTRAMP_REG,
|
||||
snd_soc_component_update_bits(dai->component, ISABELLE_DAC1_SOFTRAMP_REG,
|
||||
BIT(4), (mute ? BIT(4) : 0));
|
||||
|
||||
return 0;
|
||||
|
@ -875,7 +875,7 @@ static int isabelle_hs_mute(struct snd_soc_dai *dai, int mute)
|
|||
|
||||
static int isabelle_hf_mute(struct snd_soc_dai *dai, int mute)
|
||||
{
|
||||
snd_soc_update_bits(dai->codec, ISABELLE_DAC2_SOFTRAMP_REG,
|
||||
snd_soc_component_update_bits(dai->component, ISABELLE_DAC2_SOFTRAMP_REG,
|
||||
BIT(4), (mute ? BIT(4) : 0));
|
||||
|
||||
return 0;
|
||||
|
@ -883,13 +883,13 @@ static int isabelle_hf_mute(struct snd_soc_dai *dai, int mute)
|
|||
|
||||
static int isabelle_line_mute(struct snd_soc_dai *dai, int mute)
|
||||
{
|
||||
snd_soc_update_bits(dai->codec, ISABELLE_DAC3_SOFTRAMP_REG,
|
||||
snd_soc_component_update_bits(dai->component, ISABELLE_DAC3_SOFTRAMP_REG,
|
||||
BIT(4), (mute ? BIT(4) : 0));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int isabelle_set_bias_level(struct snd_soc_codec *codec,
|
||||
static int isabelle_set_bias_level(struct snd_soc_component *component,
|
||||
enum snd_soc_bias_level level)
|
||||
{
|
||||
switch (level) {
|
||||
|
@ -899,12 +899,12 @@ static int isabelle_set_bias_level(struct snd_soc_codec *codec,
|
|||
break;
|
||||
|
||||
case SND_SOC_BIAS_STANDBY:
|
||||
snd_soc_update_bits(codec, ISABELLE_PWR_EN_REG,
|
||||
snd_soc_component_update_bits(component, ISABELLE_PWR_EN_REG,
|
||||
ISABELLE_CHIP_EN, BIT(0));
|
||||
break;
|
||||
|
||||
case SND_SOC_BIAS_OFF:
|
||||
snd_soc_update_bits(codec, ISABELLE_PWR_EN_REG,
|
||||
snd_soc_component_update_bits(component, ISABELLE_PWR_EN_REG,
|
||||
ISABELLE_CHIP_EN, 0);
|
||||
break;
|
||||
}
|
||||
|
@ -916,7 +916,7 @@ static int isabelle_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 snd_soc_component *component = dai->component;
|
||||
u16 aif = 0;
|
||||
unsigned int fs_val = 0;
|
||||
|
||||
|
@ -952,7 +952,7 @@ static int isabelle_hw_params(struct snd_pcm_substream *substream,
|
|||
return -EINVAL;
|
||||
}
|
||||
|
||||
snd_soc_update_bits(codec, ISABELLE_FS_RATE_CFG_REG,
|
||||
snd_soc_component_update_bits(component, ISABELLE_FS_RATE_CFG_REG,
|
||||
ISABELLE_FS_RATE_MASK, fs_val);
|
||||
|
||||
/* bit size */
|
||||
|
@ -967,7 +967,7 @@ static int isabelle_hw_params(struct snd_pcm_substream *substream,
|
|||
return -EINVAL;
|
||||
}
|
||||
|
||||
snd_soc_update_bits(codec, ISABELLE_INTF_CFG_REG,
|
||||
snd_soc_component_update_bits(component, ISABELLE_INTF_CFG_REG,
|
||||
ISABELLE_AIF_LENGTH_MASK, aif);
|
||||
|
||||
return 0;
|
||||
|
@ -975,7 +975,7 @@ static int isabelle_hw_params(struct snd_pcm_substream *substream,
|
|||
|
||||
static int isabelle_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;
|
||||
unsigned int aif_val = 0;
|
||||
|
||||
switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) {
|
||||
|
@ -1003,7 +1003,7 @@ static int isabelle_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt)
|
|||
return -EINVAL;
|
||||
}
|
||||
|
||||
snd_soc_update_bits(codec, ISABELLE_INTF_CFG_REG,
|
||||
snd_soc_component_update_bits(component, ISABELLE_INTF_CFG_REG,
|
||||
(ISABELLE_AIF_MS | ISABELLE_AIF_FMT_MASK), aif_val);
|
||||
|
||||
return 0;
|
||||
|
@ -1087,17 +1087,17 @@ static struct snd_soc_dai_driver isabelle_dai[] = {
|
|||
},
|
||||
};
|
||||
|
||||
static const struct snd_soc_codec_driver soc_codec_dev_isabelle = {
|
||||
.set_bias_level = isabelle_set_bias_level,
|
||||
.component_driver = {
|
||||
.controls = isabelle_snd_controls,
|
||||
.num_controls = ARRAY_SIZE(isabelle_snd_controls),
|
||||
.dapm_widgets = isabelle_dapm_widgets,
|
||||
.num_dapm_widgets = ARRAY_SIZE(isabelle_dapm_widgets),
|
||||
.dapm_routes = isabelle_intercon,
|
||||
.num_dapm_routes = ARRAY_SIZE(isabelle_intercon),
|
||||
},
|
||||
.idle_bias_off = true,
|
||||
static const struct snd_soc_component_driver soc_component_dev_isabelle = {
|
||||
.set_bias_level = isabelle_set_bias_level,
|
||||
.controls = isabelle_snd_controls,
|
||||
.num_controls = ARRAY_SIZE(isabelle_snd_controls),
|
||||
.dapm_widgets = isabelle_dapm_widgets,
|
||||
.num_dapm_widgets = ARRAY_SIZE(isabelle_dapm_widgets),
|
||||
.dapm_routes = isabelle_intercon,
|
||||
.num_dapm_routes = ARRAY_SIZE(isabelle_intercon),
|
||||
.use_pmdown_time = 1,
|
||||
.endianness = 1,
|
||||
.non_legacy_dai_naming = 1,
|
||||
};
|
||||
|
||||
static const struct regmap_config isabelle_regmap_config = {
|
||||
|
@ -1125,23 +1125,17 @@ static int isabelle_i2c_probe(struct i2c_client *i2c,
|
|||
}
|
||||
i2c_set_clientdata(i2c, isabelle_regmap);
|
||||
|
||||
ret = snd_soc_register_codec(&i2c->dev,
|
||||
&soc_codec_dev_isabelle, isabelle_dai,
|
||||
ret = devm_snd_soc_register_component(&i2c->dev,
|
||||
&soc_component_dev_isabelle, isabelle_dai,
|
||||
ARRAY_SIZE(isabelle_dai));
|
||||
if (ret < 0) {
|
||||
dev_err(&i2c->dev, "Failed to register codec: %d\n", ret);
|
||||
dev_err(&i2c->dev, "Failed to register component: %d\n", ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int isabelle_i2c_remove(struct i2c_client *client)
|
||||
{
|
||||
snd_soc_unregister_codec(&client->dev);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const struct i2c_device_id isabelle_i2c_id[] = {
|
||||
{ "isabelle", 0 },
|
||||
{ }
|
||||
|
@ -1153,7 +1147,6 @@ static struct i2c_driver isabelle_i2c_driver = {
|
|||
.name = "isabelle",
|
||||
},
|
||||
.probe = isabelle_i2c_probe,
|
||||
.remove = isabelle_i2c_remove,
|
||||
.id_table = isabelle_i2c_id,
|
||||
};
|
||||
|
||||
|
|
|
@ -157,7 +157,7 @@ static const struct snd_soc_dapm_route jz4740_codec_dapm_routes[] = {
|
|||
static int jz4740_codec_hw_params(struct snd_pcm_substream *substream,
|
||||
struct snd_pcm_hw_params *params, struct snd_soc_dai *dai)
|
||||
{
|
||||
struct jz4740_codec *jz4740_codec = snd_soc_codec_get_drvdata(dai->codec);
|
||||
struct jz4740_codec *jz4740_codec = snd_soc_component_get_drvdata(dai->component);
|
||||
uint32_t val;
|
||||
|
||||
switch (params_rate(params)) {
|
||||
|
@ -236,10 +236,10 @@ static void jz4740_codec_wakeup(struct regmap *regmap)
|
|||
regcache_sync(regmap);
|
||||
}
|
||||
|
||||
static int jz4740_codec_set_bias_level(struct snd_soc_codec *codec,
|
||||
static int jz4740_codec_set_bias_level(struct snd_soc_component *component,
|
||||
enum snd_soc_bias_level level)
|
||||
{
|
||||
struct jz4740_codec *jz4740_codec = snd_soc_codec_get_drvdata(codec);
|
||||
struct jz4740_codec *jz4740_codec = snd_soc_component_get_drvdata(component);
|
||||
struct regmap *regmap = jz4740_codec->regmap;
|
||||
unsigned int mask;
|
||||
unsigned int value;
|
||||
|
@ -257,7 +257,7 @@ static int jz4740_codec_set_bias_level(struct snd_soc_codec *codec,
|
|||
break;
|
||||
case SND_SOC_BIAS_STANDBY:
|
||||
/* The only way to clear the suspend flag is to reset the codec */
|
||||
if (snd_soc_codec_get_bias_level(codec) == SND_SOC_BIAS_OFF)
|
||||
if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_OFF)
|
||||
jz4740_codec_wakeup(regmap);
|
||||
|
||||
mask = JZ4740_CODEC_1_VREF_DISABLE |
|
||||
|
@ -283,9 +283,9 @@ static int jz4740_codec_set_bias_level(struct snd_soc_codec *codec,
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int jz4740_codec_dev_probe(struct snd_soc_codec *codec)
|
||||
static int jz4740_codec_dev_probe(struct snd_soc_component *component)
|
||||
{
|
||||
struct jz4740_codec *jz4740_codec = snd_soc_codec_get_drvdata(codec);
|
||||
struct jz4740_codec *jz4740_codec = snd_soc_component_get_drvdata(component);
|
||||
|
||||
regmap_update_bits(jz4740_codec->regmap, JZ4740_REG_CODEC_1,
|
||||
JZ4740_CODEC_1_SW2_ENABLE, JZ4740_CODEC_1_SW2_ENABLE);
|
||||
|
@ -293,19 +293,21 @@ static int jz4740_codec_dev_probe(struct snd_soc_codec *codec)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static const struct snd_soc_codec_driver soc_codec_dev_jz4740_codec = {
|
||||
.probe = jz4740_codec_dev_probe,
|
||||
.set_bias_level = jz4740_codec_set_bias_level,
|
||||
.suspend_bias_off = true,
|
||||
static const struct snd_soc_component_driver soc_codec_dev_jz4740_codec = {
|
||||
.probe = jz4740_codec_dev_probe,
|
||||
.set_bias_level = jz4740_codec_set_bias_level,
|
||||
.controls = jz4740_codec_controls,
|
||||
.num_controls = ARRAY_SIZE(jz4740_codec_controls),
|
||||
.dapm_widgets = jz4740_codec_dapm_widgets,
|
||||
.num_dapm_widgets = ARRAY_SIZE(jz4740_codec_dapm_widgets),
|
||||
.dapm_routes = jz4740_codec_dapm_routes,
|
||||
.num_dapm_routes = ARRAY_SIZE(jz4740_codec_dapm_routes),
|
||||
.suspend_bias_off = 1,
|
||||
.idle_bias_on = 1,
|
||||
.use_pmdown_time = 1,
|
||||
.endianness = 1,
|
||||
.non_legacy_dai_naming = 1,
|
||||
|
||||
.component_driver = {
|
||||
.controls = jz4740_codec_controls,
|
||||
.num_controls = ARRAY_SIZE(jz4740_codec_controls),
|
||||
.dapm_widgets = jz4740_codec_dapm_widgets,
|
||||
.num_dapm_widgets = ARRAY_SIZE(jz4740_codec_dapm_widgets),
|
||||
.dapm_routes = jz4740_codec_dapm_routes,
|
||||
.num_dapm_routes = ARRAY_SIZE(jz4740_codec_dapm_routes),
|
||||
},
|
||||
};
|
||||
|
||||
static const struct regmap_config jz4740_codec_regmap_config = {
|
||||
|
@ -343,7 +345,7 @@ static int jz4740_codec_probe(struct platform_device *pdev)
|
|||
|
||||
platform_set_drvdata(pdev, jz4740_codec);
|
||||
|
||||
ret = snd_soc_register_codec(&pdev->dev,
|
||||
ret = devm_snd_soc_register_component(&pdev->dev,
|
||||
&soc_codec_dev_jz4740_codec, &jz4740_codec_dai, 1);
|
||||
if (ret)
|
||||
dev_err(&pdev->dev, "Failed to register codec\n");
|
||||
|
@ -351,16 +353,8 @@ static int jz4740_codec_probe(struct platform_device *pdev)
|
|||
return ret;
|
||||
}
|
||||
|
||||
static int jz4740_codec_remove(struct platform_device *pdev)
|
||||
{
|
||||
snd_soc_unregister_codec(&pdev->dev);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static struct platform_driver jz4740_codec_driver = {
|
||||
.probe = jz4740_codec_probe,
|
||||
.remove = jz4740_codec_remove,
|
||||
.driver = {
|
||||
.name = "jz4740-codec",
|
||||
},
|
||||
|
|
|
@ -1110,7 +1110,7 @@ static int lm49453_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 snd_soc_component *component = dai->component;
|
||||
u16 clk_div = 0;
|
||||
|
||||
/* Setting DAC clock dividers based on substream sample rate. */
|
||||
|
@ -1134,15 +1134,15 @@ static int lm49453_hw_params(struct snd_pcm_substream *substream,
|
|||
return -EINVAL;
|
||||
}
|
||||
|
||||
snd_soc_write(codec, LM49453_P0_ADC_CLK_DIV_REG, clk_div);
|
||||
snd_soc_write(codec, LM49453_P0_DAC_HP_CLK_DIV_REG, clk_div);
|
||||
snd_soc_component_write(component, LM49453_P0_ADC_CLK_DIV_REG, clk_div);
|
||||
snd_soc_component_write(component, LM49453_P0_DAC_HP_CLK_DIV_REG, clk_div);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int lm49453_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 aif_val;
|
||||
int mode = 0;
|
||||
|
@ -1185,11 +1185,11 @@ static int lm49453_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt)
|
|||
return -EINVAL;
|
||||
}
|
||||
|
||||
snd_soc_update_bits(codec, LM49453_P0_AUDIO_PORT1_BASIC_REG,
|
||||
snd_soc_component_update_bits(component, LM49453_P0_AUDIO_PORT1_BASIC_REG,
|
||||
LM49453_AUDIO_PORT1_BASIC_FMT_MASK|BIT(0)|BIT(5),
|
||||
(aif_val | mode | clk_phase));
|
||||
|
||||
snd_soc_write(codec, LM49453_P0_AUDIO_PORT1_RX_MSB_REG, clk_shift);
|
||||
snd_soc_component_write(component, LM49453_P0_AUDIO_PORT1_RX_MSB_REG, clk_shift);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -1197,7 +1197,7 @@ static int lm49453_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt)
|
|||
static int lm49453_set_dai_sysclk(struct snd_soc_dai *dai, int clk_id,
|
||||
unsigned int freq, int dir)
|
||||
{
|
||||
struct snd_soc_codec *codec = dai->codec;
|
||||
struct snd_soc_component *component = dai->component;
|
||||
u16 pll_clk = 0;
|
||||
|
||||
switch (freq) {
|
||||
|
@ -1216,50 +1216,50 @@ static int lm49453_set_dai_sysclk(struct snd_soc_dai *dai, int clk_id,
|
|||
return -EINVAL;
|
||||
}
|
||||
|
||||
snd_soc_update_bits(codec, LM49453_P0_PMC_SETUP_REG, BIT(4), pll_clk);
|
||||
snd_soc_component_update_bits(component, LM49453_P0_PMC_SETUP_REG, BIT(4), pll_clk);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int lm49453_hp_mute(struct snd_soc_dai *dai, int mute)
|
||||
{
|
||||
snd_soc_update_bits(dai->codec, LM49453_P0_DAC_DSP_REG, BIT(1)|BIT(0),
|
||||
snd_soc_component_update_bits(dai->component, LM49453_P0_DAC_DSP_REG, BIT(1)|BIT(0),
|
||||
(mute ? (BIT(1)|BIT(0)) : 0));
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int lm49453_lo_mute(struct snd_soc_dai *dai, int mute)
|
||||
{
|
||||
snd_soc_update_bits(dai->codec, LM49453_P0_DAC_DSP_REG, BIT(3)|BIT(2),
|
||||
snd_soc_component_update_bits(dai->component, LM49453_P0_DAC_DSP_REG, BIT(3)|BIT(2),
|
||||
(mute ? (BIT(3)|BIT(2)) : 0));
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int lm49453_ls_mute(struct snd_soc_dai *dai, int mute)
|
||||
{
|
||||
snd_soc_update_bits(dai->codec, LM49453_P0_DAC_DSP_REG, BIT(5)|BIT(4),
|
||||
snd_soc_component_update_bits(dai->component, LM49453_P0_DAC_DSP_REG, BIT(5)|BIT(4),
|
||||
(mute ? (BIT(5)|BIT(4)) : 0));
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int lm49453_ep_mute(struct snd_soc_dai *dai, int mute)
|
||||
{
|
||||
snd_soc_update_bits(dai->codec, LM49453_P0_DAC_DSP_REG, BIT(4),
|
||||
snd_soc_component_update_bits(dai->component, LM49453_P0_DAC_DSP_REG, BIT(4),
|
||||
(mute ? BIT(4) : 0));
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int lm49453_ha_mute(struct snd_soc_dai *dai, int mute)
|
||||
{
|
||||
snd_soc_update_bits(dai->codec, LM49453_P0_DAC_DSP_REG, BIT(7)|BIT(6),
|
||||
snd_soc_component_update_bits(dai->component, LM49453_P0_DAC_DSP_REG, BIT(7)|BIT(6),
|
||||
(mute ? (BIT(7)|BIT(6)) : 0));
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int lm49453_set_bias_level(struct snd_soc_codec *codec,
|
||||
static int lm49453_set_bias_level(struct snd_soc_component *component,
|
||||
enum snd_soc_bias_level level)
|
||||
{
|
||||
struct lm49453_priv *lm49453 = snd_soc_codec_get_drvdata(codec);
|
||||
struct lm49453_priv *lm49453 = snd_soc_component_get_drvdata(component);
|
||||
|
||||
switch (level) {
|
||||
case SND_SOC_BIAS_ON:
|
||||
|
@ -1267,15 +1267,15 @@ static int lm49453_set_bias_level(struct snd_soc_codec *codec,
|
|||
break;
|
||||
|
||||
case SND_SOC_BIAS_STANDBY:
|
||||
if (snd_soc_codec_get_bias_level(codec) == SND_SOC_BIAS_OFF)
|
||||
if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_OFF)
|
||||
regcache_sync(lm49453->regmap);
|
||||
|
||||
snd_soc_update_bits(codec, LM49453_P0_PMC_SETUP_REG,
|
||||
snd_soc_component_update_bits(component, LM49453_P0_PMC_SETUP_REG,
|
||||
LM49453_PMC_SETUP_CHIP_EN, LM49453_CHIP_EN);
|
||||
break;
|
||||
|
||||
case SND_SOC_BIAS_OFF:
|
||||
snd_soc_update_bits(codec, LM49453_P0_PMC_SETUP_REG,
|
||||
snd_soc_component_update_bits(component, LM49453_P0_PMC_SETUP_REG,
|
||||
LM49453_PMC_SETUP_CHIP_EN, 0);
|
||||
break;
|
||||
}
|
||||
|
@ -1389,17 +1389,17 @@ static struct snd_soc_dai_driver lm49453_dai[] = {
|
|||
},
|
||||
};
|
||||
|
||||
static const struct snd_soc_codec_driver soc_codec_dev_lm49453 = {
|
||||
.set_bias_level = lm49453_set_bias_level,
|
||||
.component_driver = {
|
||||
.controls = lm49453_snd_controls,
|
||||
.num_controls = ARRAY_SIZE(lm49453_snd_controls),
|
||||
.dapm_widgets = lm49453_dapm_widgets,
|
||||
.num_dapm_widgets = ARRAY_SIZE(lm49453_dapm_widgets),
|
||||
.dapm_routes = lm49453_audio_map,
|
||||
.num_dapm_routes = ARRAY_SIZE(lm49453_audio_map),
|
||||
},
|
||||
.idle_bias_off = true,
|
||||
static const struct snd_soc_component_driver soc_component_dev_lm49453 = {
|
||||
.set_bias_level = lm49453_set_bias_level,
|
||||
.controls = lm49453_snd_controls,
|
||||
.num_controls = ARRAY_SIZE(lm49453_snd_controls),
|
||||
.dapm_widgets = lm49453_dapm_widgets,
|
||||
.num_dapm_widgets = ARRAY_SIZE(lm49453_dapm_widgets),
|
||||
.dapm_routes = lm49453_audio_map,
|
||||
.num_dapm_routes = ARRAY_SIZE(lm49453_audio_map),
|
||||
.use_pmdown_time = 1,
|
||||
.endianness = 1,
|
||||
.non_legacy_dai_naming = 1,
|
||||
};
|
||||
|
||||
static const struct regmap_config lm49453_regmap_config = {
|
||||
|
@ -1434,18 +1434,17 @@ static int lm49453_i2c_probe(struct i2c_client *i2c,
|
|||
return ret;
|
||||
}
|
||||
|
||||
ret = snd_soc_register_codec(&i2c->dev,
|
||||
&soc_codec_dev_lm49453,
|
||||
ret = devm_snd_soc_register_component(&i2c->dev,
|
||||
&soc_component_dev_lm49453,
|
||||
lm49453_dai, ARRAY_SIZE(lm49453_dai));
|
||||
if (ret < 0)
|
||||
dev_err(&i2c->dev, "Failed to register codec: %d\n", ret);
|
||||
dev_err(&i2c->dev, "Failed to register component: %d\n", ret);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int lm49453_i2c_remove(struct i2c_client *client)
|
||||
{
|
||||
snd_soc_unregister_codec(&client->dev);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,207 @@
|
|||
// SPDX-Licence-Identifier: GPL-2.0
|
||||
/*
|
||||
* MAX9759 Amplifier Driver
|
||||
*
|
||||
* Copyright (c) 2017 BayLibre, SAS.
|
||||
* Author: Neil Armstrong <narmstrong@baylibre.com>
|
||||
*/
|
||||
|
||||
#include <linux/gpio/consumer.h>
|
||||
#include <linux/module.h>
|
||||
#include <sound/soc.h>
|
||||
#include <sound/soc-dapm.h>
|
||||
#include <sound/tlv.h>
|
||||
|
||||
#define DRV_NAME "max9759"
|
||||
|
||||
struct max9759 {
|
||||
struct gpio_desc *gpiod_shutdown;
|
||||
struct gpio_desc *gpiod_mute;
|
||||
struct gpio_descs *gpiod_gain;
|
||||
bool is_mute;
|
||||
unsigned int gain;
|
||||
};
|
||||
|
||||
static int pga_event(struct snd_soc_dapm_widget *w,
|
||||
struct snd_kcontrol *control, int event)
|
||||
{
|
||||
struct snd_soc_component *c = snd_soc_dapm_to_component(w->dapm);
|
||||
struct max9759 *priv = snd_soc_component_get_drvdata(c);
|
||||
|
||||
if (SND_SOC_DAPM_EVENT_ON(event))
|
||||
gpiod_set_value_cansleep(priv->gpiod_shutdown, 0);
|
||||
else
|
||||
gpiod_set_value_cansleep(priv->gpiod_shutdown, 1);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* From 6dB to 24dB in steps of 6dB */
|
||||
static const DECLARE_TLV_DB_SCALE(speaker_gain_tlv, 600, 600, 0);
|
||||
|
||||
static int speaker_gain_control_get(struct snd_kcontrol *kcontrol,
|
||||
struct snd_ctl_elem_value *ucontrol)
|
||||
{
|
||||
struct snd_soc_component *c = snd_soc_kcontrol_component(kcontrol);
|
||||
struct max9759 *priv = snd_soc_component_get_drvdata(c);
|
||||
|
||||
ucontrol->value.integer.value[0] = priv->gain;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const bool speaker_gain_table[4][2] = {
|
||||
/* G1, G2 */
|
||||
{true, true}, /* +6dB */
|
||||
{false, true}, /* +12dB */
|
||||
{true, false}, /* +18dB */
|
||||
{false, false}, /* +24dB */
|
||||
};
|
||||
|
||||
static int speaker_gain_control_put(struct snd_kcontrol *kcontrol,
|
||||
struct snd_ctl_elem_value *ucontrol)
|
||||
{
|
||||
struct snd_soc_component *c = snd_soc_kcontrol_component(kcontrol);
|
||||
struct max9759 *priv = snd_soc_component_get_drvdata(c);
|
||||
|
||||
if (ucontrol->value.integer.value[0] > 3)
|
||||
return -EINVAL;
|
||||
|
||||
priv->gain = ucontrol->value.integer.value[0];
|
||||
|
||||
/* G1 */
|
||||
gpiod_set_value_cansleep(priv->gpiod_gain->desc[0],
|
||||
speaker_gain_table[priv->gain][0]);
|
||||
/* G2 */
|
||||
gpiod_set_value_cansleep(priv->gpiod_gain->desc[1],
|
||||
speaker_gain_table[priv->gain][1]);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int speaker_mute_get(struct snd_kcontrol *kcontrol,
|
||||
struct snd_ctl_elem_value *ucontrol)
|
||||
{
|
||||
struct snd_soc_component *c = snd_soc_kcontrol_component(kcontrol);
|
||||
struct max9759 *priv = snd_soc_component_get_drvdata(c);
|
||||
|
||||
ucontrol->value.integer.value[0] = !priv->is_mute;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int speaker_mute_put(struct snd_kcontrol *kcontrol,
|
||||
struct snd_ctl_elem_value *ucontrol)
|
||||
{
|
||||
struct snd_soc_component *c = snd_soc_kcontrol_component(kcontrol);
|
||||
struct max9759 *priv = snd_soc_component_get_drvdata(c);
|
||||
|
||||
priv->is_mute = !ucontrol->value.integer.value[0];
|
||||
|
||||
gpiod_set_value_cansleep(priv->gpiod_mute, priv->is_mute);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static const struct snd_kcontrol_new max9759_dapm_controls[] = {
|
||||
SOC_SINGLE_EXT_TLV("Speaker Gain Volume", 0, 0, 3, 0,
|
||||
speaker_gain_control_get, speaker_gain_control_put,
|
||||
speaker_gain_tlv),
|
||||
SOC_SINGLE_BOOL_EXT("Playback Switch", 0,
|
||||
speaker_mute_get, speaker_mute_put),
|
||||
};
|
||||
|
||||
static const struct snd_soc_dapm_widget max9759_dapm_widgets[] = {
|
||||
SND_SOC_DAPM_INPUT("INL"),
|
||||
SND_SOC_DAPM_INPUT("INR"),
|
||||
SND_SOC_DAPM_PGA_E("PGA", SND_SOC_NOPM, 0, 0, NULL, 0, pga_event,
|
||||
(SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD)),
|
||||
SND_SOC_DAPM_OUTPUT("OUTL"),
|
||||
SND_SOC_DAPM_OUTPUT("OUTR"),
|
||||
};
|
||||
|
||||
static const struct snd_soc_dapm_route max9759_dapm_routes[] = {
|
||||
{ "PGA", NULL, "INL" },
|
||||
{ "PGA", NULL, "INR" },
|
||||
{ "OUTL", NULL, "PGA" },
|
||||
{ "OUTR", NULL, "PGA" },
|
||||
};
|
||||
|
||||
static const struct snd_soc_component_driver max9759_component_driver = {
|
||||
.controls = max9759_dapm_controls,
|
||||
.num_controls = ARRAY_SIZE(max9759_dapm_controls),
|
||||
.dapm_widgets = max9759_dapm_widgets,
|
||||
.num_dapm_widgets = ARRAY_SIZE(max9759_dapm_widgets),
|
||||
.dapm_routes = max9759_dapm_routes,
|
||||
.num_dapm_routes = ARRAY_SIZE(max9759_dapm_routes),
|
||||
};
|
||||
|
||||
static int max9759_probe(struct platform_device *pdev)
|
||||
{
|
||||
struct device *dev = &pdev->dev;
|
||||
struct max9759 *priv;
|
||||
int err;
|
||||
|
||||
priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
|
||||
if (!priv)
|
||||
return -ENOMEM;
|
||||
|
||||
platform_set_drvdata(pdev, priv);
|
||||
|
||||
priv->gpiod_shutdown = devm_gpiod_get(dev, "shutdown", GPIOD_OUT_HIGH);
|
||||
if (IS_ERR(priv->gpiod_shutdown)) {
|
||||
err = PTR_ERR(priv->gpiod_shutdown);
|
||||
if (err != -EPROBE_DEFER)
|
||||
dev_err(dev, "Failed to get 'shutdown' gpio: %d", err);
|
||||
return err;
|
||||
}
|
||||
|
||||
priv->gpiod_mute = devm_gpiod_get(dev, "mute", GPIOD_OUT_HIGH);
|
||||
if (IS_ERR(priv->gpiod_mute)) {
|
||||
err = PTR_ERR(priv->gpiod_mute);
|
||||
if (err != -EPROBE_DEFER)
|
||||
dev_err(dev, "Failed to get 'mute' gpio: %d", err);
|
||||
return err;
|
||||
}
|
||||
priv->is_mute = true;
|
||||
|
||||
priv->gpiod_gain = devm_gpiod_get_array(dev, "gain", GPIOD_OUT_HIGH);
|
||||
if (IS_ERR(priv->gpiod_gain)) {
|
||||
err = PTR_ERR(priv->gpiod_gain);
|
||||
if (err != -EPROBE_DEFER)
|
||||
dev_err(dev, "Failed to get 'gain' gpios: %d", err);
|
||||
return err;
|
||||
}
|
||||
priv->gain = 0;
|
||||
|
||||
if (priv->gpiod_gain->ndescs != 2) {
|
||||
dev_err(dev, "Invalid 'gain' gpios count: %d",
|
||||
priv->gpiod_gain->ndescs);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
return devm_snd_soc_register_component(dev, &max9759_component_driver,
|
||||
NULL, 0);
|
||||
}
|
||||
|
||||
#ifdef CONFIG_OF
|
||||
static const struct of_device_id max9759_ids[] = {
|
||||
{ .compatible = "maxim,max9759", },
|
||||
{ }
|
||||
};
|
||||
MODULE_DEVICE_TABLE(of, max9759_ids);
|
||||
#endif
|
||||
|
||||
static struct platform_driver max9759_driver = {
|
||||
.driver = {
|
||||
.name = DRV_NAME,
|
||||
.of_match_table = of_match_ptr(max9759_ids),
|
||||
},
|
||||
.probe = max9759_probe,
|
||||
};
|
||||
|
||||
module_platform_driver(max9759_driver);
|
||||
|
||||
MODULE_DESCRIPTION("ASoC MAX9759 amplifier driver");
|
||||
MODULE_AUTHOR("Neil Armstrong <narmstrong@baylibre.com>");
|
||||
MODULE_LICENSE("GPL");
|
|
@ -307,7 +307,7 @@ static const struct regmap_config max98088_regmap = {
|
|||
/*
|
||||
* Load equalizer DSP coefficient configurations registers
|
||||
*/
|
||||
static void m98088_eq_band(struct snd_soc_codec *codec, unsigned int dai,
|
||||
static void m98088_eq_band(struct snd_soc_component *component, unsigned int dai,
|
||||
unsigned int band, u16 *coefs)
|
||||
{
|
||||
unsigned int eq_reg;
|
||||
|
@ -325,8 +325,8 @@ static void m98088_eq_band(struct snd_soc_codec *codec, unsigned int dai,
|
|||
|
||||
/* Step through the registers and coefs */
|
||||
for (i = 0; i < M98088_COEFS_PER_BAND; i++) {
|
||||
snd_soc_write(codec, eq_reg++, M98088_BYTE1(coefs[i]));
|
||||
snd_soc_write(codec, eq_reg++, M98088_BYTE0(coefs[i]));
|
||||
snd_soc_component_write(component, eq_reg++, M98088_BYTE1(coefs[i]));
|
||||
snd_soc_component_write(component, eq_reg++, M98088_BYTE0(coefs[i]));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -380,12 +380,12 @@ static SOC_ENUM_SINGLE_DECL(max98088_dai1_adc_filter_enum,
|
|||
static int max98088_mic1pre_set(struct snd_kcontrol *kcontrol,
|
||||
struct snd_ctl_elem_value *ucontrol)
|
||||
{
|
||||
struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
|
||||
struct max98088_priv *max98088 = snd_soc_codec_get_drvdata(codec);
|
||||
struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol);
|
||||
struct max98088_priv *max98088 = snd_soc_component_get_drvdata(component);
|
||||
unsigned int sel = ucontrol->value.integer.value[0];
|
||||
|
||||
max98088->mic1pre = sel;
|
||||
snd_soc_update_bits(codec, M98088_REG_35_LVL_MIC1, M98088_MICPRE_MASK,
|
||||
snd_soc_component_update_bits(component, M98088_REG_35_LVL_MIC1, M98088_MICPRE_MASK,
|
||||
(1+sel)<<M98088_MICPRE_SHIFT);
|
||||
|
||||
return 0;
|
||||
|
@ -394,8 +394,8 @@ static int max98088_mic1pre_set(struct snd_kcontrol *kcontrol,
|
|||
static int max98088_mic1pre_get(struct snd_kcontrol *kcontrol,
|
||||
struct snd_ctl_elem_value *ucontrol)
|
||||
{
|
||||
struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
|
||||
struct max98088_priv *max98088 = snd_soc_codec_get_drvdata(codec);
|
||||
struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol);
|
||||
struct max98088_priv *max98088 = snd_soc_component_get_drvdata(component);
|
||||
|
||||
ucontrol->value.integer.value[0] = max98088->mic1pre;
|
||||
return 0;
|
||||
|
@ -404,12 +404,12 @@ static int max98088_mic1pre_get(struct snd_kcontrol *kcontrol,
|
|||
static int max98088_mic2pre_set(struct snd_kcontrol *kcontrol,
|
||||
struct snd_ctl_elem_value *ucontrol)
|
||||
{
|
||||
struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
|
||||
struct max98088_priv *max98088 = snd_soc_codec_get_drvdata(codec);
|
||||
struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol);
|
||||
struct max98088_priv *max98088 = snd_soc_component_get_drvdata(component);
|
||||
unsigned int sel = ucontrol->value.integer.value[0];
|
||||
|
||||
max98088->mic2pre = sel;
|
||||
snd_soc_update_bits(codec, M98088_REG_36_LVL_MIC2, M98088_MICPRE_MASK,
|
||||
snd_soc_component_update_bits(component, M98088_REG_36_LVL_MIC2, M98088_MICPRE_MASK,
|
||||
(1+sel)<<M98088_MICPRE_SHIFT);
|
||||
|
||||
return 0;
|
||||
|
@ -418,8 +418,8 @@ static int max98088_mic2pre_set(struct snd_kcontrol *kcontrol,
|
|||
static int max98088_mic2pre_get(struct snd_kcontrol *kcontrol,
|
||||
struct snd_ctl_elem_value *ucontrol)
|
||||
{
|
||||
struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
|
||||
struct max98088_priv *max98088 = snd_soc_codec_get_drvdata(codec);
|
||||
struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol);
|
||||
struct max98088_priv *max98088 = snd_soc_component_get_drvdata(component);
|
||||
|
||||
ucontrol->value.integer.value[0] = max98088->mic2pre;
|
||||
return 0;
|
||||
|
@ -617,21 +617,21 @@ static const struct snd_kcontrol_new max98088_right_ADC_mixer_controls[] = {
|
|||
static int max98088_mic_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 max98088_priv *max98088 = snd_soc_codec_get_drvdata(codec);
|
||||
struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm);
|
||||
struct max98088_priv *max98088 = snd_soc_component_get_drvdata(component);
|
||||
|
||||
switch (event) {
|
||||
case SND_SOC_DAPM_POST_PMU:
|
||||
if (w->reg == M98088_REG_35_LVL_MIC1) {
|
||||
snd_soc_update_bits(codec, w->reg, M98088_MICPRE_MASK,
|
||||
snd_soc_component_update_bits(component, w->reg, M98088_MICPRE_MASK,
|
||||
(1+max98088->mic1pre)<<M98088_MICPRE_SHIFT);
|
||||
} else {
|
||||
snd_soc_update_bits(codec, w->reg, M98088_MICPRE_MASK,
|
||||
snd_soc_component_update_bits(component, w->reg, M98088_MICPRE_MASK,
|
||||
(1+max98088->mic2pre)<<M98088_MICPRE_SHIFT);
|
||||
}
|
||||
break;
|
||||
case SND_SOC_DAPM_POST_PMD:
|
||||
snd_soc_update_bits(codec, w->reg, M98088_MICPRE_MASK, 0);
|
||||
snd_soc_component_update_bits(component, w->reg, M98088_MICPRE_MASK, 0);
|
||||
break;
|
||||
default:
|
||||
return -EINVAL;
|
||||
|
@ -647,8 +647,8 @@ static int max98088_mic_event(struct snd_soc_dapm_widget *w,
|
|||
static int max98088_line_pga(struct snd_soc_dapm_widget *w,
|
||||
int event, int line, u8 channel)
|
||||
{
|
||||
struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
|
||||
struct max98088_priv *max98088 = snd_soc_codec_get_drvdata(codec);
|
||||
struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm);
|
||||
struct max98088_priv *max98088 = snd_soc_component_get_drvdata(component);
|
||||
u8 *state;
|
||||
|
||||
if (WARN_ON(!(channel == 1 || channel == 2)))
|
||||
|
@ -668,13 +668,13 @@ static int max98088_line_pga(struct snd_soc_dapm_widget *w,
|
|||
switch (event) {
|
||||
case SND_SOC_DAPM_POST_PMU:
|
||||
*state |= channel;
|
||||
snd_soc_update_bits(codec, w->reg,
|
||||
snd_soc_component_update_bits(component, w->reg,
|
||||
(1 << w->shift), (1 << w->shift));
|
||||
break;
|
||||
case SND_SOC_DAPM_POST_PMD:
|
||||
*state &= ~channel;
|
||||
if (*state == 0) {
|
||||
snd_soc_update_bits(codec, w->reg,
|
||||
snd_soc_component_update_bits(component, w->reg,
|
||||
(1 << w->shift), 0);
|
||||
}
|
||||
break;
|
||||
|
@ -963,8 +963,8 @@ static int max98088_dai1_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 max98088_priv *max98088 = snd_soc_codec_get_drvdata(codec);
|
||||
struct snd_soc_component *component = dai->component;
|
||||
struct max98088_priv *max98088 = snd_soc_component_get_drvdata(component);
|
||||
struct max98088_cdata *cdata;
|
||||
unsigned long long ni;
|
||||
unsigned int rate;
|
||||
|
@ -976,51 +976,51 @@ static int max98088_dai1_hw_params(struct snd_pcm_substream *substream,
|
|||
|
||||
switch (params_width(params)) {
|
||||
case 16:
|
||||
snd_soc_update_bits(codec, M98088_REG_14_DAI1_FORMAT,
|
||||
snd_soc_component_update_bits(component, M98088_REG_14_DAI1_FORMAT,
|
||||
M98088_DAI_WS, 0);
|
||||
break;
|
||||
case 24:
|
||||
snd_soc_update_bits(codec, M98088_REG_14_DAI1_FORMAT,
|
||||
snd_soc_component_update_bits(component, M98088_REG_14_DAI1_FORMAT,
|
||||
M98088_DAI_WS, M98088_DAI_WS);
|
||||
break;
|
||||
default:
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
snd_soc_update_bits(codec, M98088_REG_51_PWR_SYS, M98088_SHDNRUN, 0);
|
||||
snd_soc_component_update_bits(component, M98088_REG_51_PWR_SYS, M98088_SHDNRUN, 0);
|
||||
|
||||
if (rate_value(rate, ®val))
|
||||
return -EINVAL;
|
||||
|
||||
snd_soc_update_bits(codec, M98088_REG_11_DAI1_CLKMODE,
|
||||
snd_soc_component_update_bits(component, M98088_REG_11_DAI1_CLKMODE,
|
||||
M98088_CLKMODE_MASK, regval);
|
||||
cdata->rate = rate;
|
||||
|
||||
/* Configure NI when operating as master */
|
||||
if (snd_soc_read(codec, M98088_REG_14_DAI1_FORMAT)
|
||||
if (snd_soc_component_read32(component, M98088_REG_14_DAI1_FORMAT)
|
||||
& M98088_DAI_MAS) {
|
||||
if (max98088->sysclk == 0) {
|
||||
dev_err(codec->dev, "Invalid system clock frequency\n");
|
||||
dev_err(component->dev, "Invalid system clock frequency\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
ni = 65536ULL * (rate < 50000 ? 96ULL : 48ULL)
|
||||
* (unsigned long long int)rate;
|
||||
do_div(ni, (unsigned long long int)max98088->sysclk);
|
||||
snd_soc_write(codec, M98088_REG_12_DAI1_CLKCFG_HI,
|
||||
snd_soc_component_write(component, M98088_REG_12_DAI1_CLKCFG_HI,
|
||||
(ni >> 8) & 0x7F);
|
||||
snd_soc_write(codec, M98088_REG_13_DAI1_CLKCFG_LO,
|
||||
snd_soc_component_write(component, M98088_REG_13_DAI1_CLKCFG_LO,
|
||||
ni & 0xFF);
|
||||
}
|
||||
|
||||
/* Update sample rate mode */
|
||||
if (rate < 50000)
|
||||
snd_soc_update_bits(codec, M98088_REG_18_DAI1_FILTERS,
|
||||
snd_soc_component_update_bits(component, M98088_REG_18_DAI1_FILTERS,
|
||||
M98088_DAI_DHF, 0);
|
||||
else
|
||||
snd_soc_update_bits(codec, M98088_REG_18_DAI1_FILTERS,
|
||||
snd_soc_component_update_bits(component, M98088_REG_18_DAI1_FILTERS,
|
||||
M98088_DAI_DHF, M98088_DAI_DHF);
|
||||
|
||||
snd_soc_update_bits(codec, M98088_REG_51_PWR_SYS, M98088_SHDNRUN,
|
||||
snd_soc_component_update_bits(component, M98088_REG_51_PWR_SYS, M98088_SHDNRUN,
|
||||
M98088_SHDNRUN);
|
||||
|
||||
return 0;
|
||||
|
@ -1030,8 +1030,8 @@ static int max98088_dai2_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 max98088_priv *max98088 = snd_soc_codec_get_drvdata(codec);
|
||||
struct snd_soc_component *component = dai->component;
|
||||
struct max98088_priv *max98088 = snd_soc_component_get_drvdata(component);
|
||||
struct max98088_cdata *cdata;
|
||||
unsigned long long ni;
|
||||
unsigned int rate;
|
||||
|
@ -1043,51 +1043,51 @@ static int max98088_dai2_hw_params(struct snd_pcm_substream *substream,
|
|||
|
||||
switch (params_width(params)) {
|
||||
case 16:
|
||||
snd_soc_update_bits(codec, M98088_REG_1C_DAI2_FORMAT,
|
||||
snd_soc_component_update_bits(component, M98088_REG_1C_DAI2_FORMAT,
|
||||
M98088_DAI_WS, 0);
|
||||
break;
|
||||
case 24:
|
||||
snd_soc_update_bits(codec, M98088_REG_1C_DAI2_FORMAT,
|
||||
snd_soc_component_update_bits(component, M98088_REG_1C_DAI2_FORMAT,
|
||||
M98088_DAI_WS, M98088_DAI_WS);
|
||||
break;
|
||||
default:
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
snd_soc_update_bits(codec, M98088_REG_51_PWR_SYS, M98088_SHDNRUN, 0);
|
||||
snd_soc_component_update_bits(component, M98088_REG_51_PWR_SYS, M98088_SHDNRUN, 0);
|
||||
|
||||
if (rate_value(rate, ®val))
|
||||
return -EINVAL;
|
||||
|
||||
snd_soc_update_bits(codec, M98088_REG_19_DAI2_CLKMODE,
|
||||
snd_soc_component_update_bits(component, M98088_REG_19_DAI2_CLKMODE,
|
||||
M98088_CLKMODE_MASK, regval);
|
||||
cdata->rate = rate;
|
||||
|
||||
/* Configure NI when operating as master */
|
||||
if (snd_soc_read(codec, M98088_REG_1C_DAI2_FORMAT)
|
||||
if (snd_soc_component_read32(component, M98088_REG_1C_DAI2_FORMAT)
|
||||
& M98088_DAI_MAS) {
|
||||
if (max98088->sysclk == 0) {
|
||||
dev_err(codec->dev, "Invalid system clock frequency\n");
|
||||
dev_err(component->dev, "Invalid system clock frequency\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
ni = 65536ULL * (rate < 50000 ? 96ULL : 48ULL)
|
||||
* (unsigned long long int)rate;
|
||||
do_div(ni, (unsigned long long int)max98088->sysclk);
|
||||
snd_soc_write(codec, M98088_REG_1A_DAI2_CLKCFG_HI,
|
||||
snd_soc_component_write(component, M98088_REG_1A_DAI2_CLKCFG_HI,
|
||||
(ni >> 8) & 0x7F);
|
||||
snd_soc_write(codec, M98088_REG_1B_DAI2_CLKCFG_LO,
|
||||
snd_soc_component_write(component, M98088_REG_1B_DAI2_CLKCFG_LO,
|
||||
ni & 0xFF);
|
||||
}
|
||||
|
||||
/* Update sample rate mode */
|
||||
if (rate < 50000)
|
||||
snd_soc_update_bits(codec, M98088_REG_20_DAI2_FILTERS,
|
||||
snd_soc_component_update_bits(component, M98088_REG_20_DAI2_FILTERS,
|
||||
M98088_DAI_DHF, 0);
|
||||
else
|
||||
snd_soc_update_bits(codec, M98088_REG_20_DAI2_FILTERS,
|
||||
snd_soc_component_update_bits(component, M98088_REG_20_DAI2_FILTERS,
|
||||
M98088_DAI_DHF, M98088_DAI_DHF);
|
||||
|
||||
snd_soc_update_bits(codec, M98088_REG_51_PWR_SYS, M98088_SHDNRUN,
|
||||
snd_soc_component_update_bits(component, M98088_REG_51_PWR_SYS, M98088_SHDNRUN,
|
||||
M98088_SHDNRUN);
|
||||
|
||||
return 0;
|
||||
|
@ -1096,8 +1096,8 @@ static int max98088_dai2_hw_params(struct snd_pcm_substream *substream,
|
|||
static int max98088_dai_set_sysclk(struct snd_soc_dai *dai,
|
||||
int clk_id, unsigned int freq, int dir)
|
||||
{
|
||||
struct snd_soc_codec *codec = dai->codec;
|
||||
struct max98088_priv *max98088 = snd_soc_codec_get_drvdata(codec);
|
||||
struct snd_soc_component *component = dai->component;
|
||||
struct max98088_priv *max98088 = snd_soc_component_get_drvdata(component);
|
||||
|
||||
/* Requested clock frequency is already setup */
|
||||
if (freq == max98088->sysclk)
|
||||
|
@ -1108,18 +1108,18 @@ static int max98088_dai_set_sysclk(struct snd_soc_dai *dai,
|
|||
* 0x02 (when master clk is 20MHz to 30MHz)..
|
||||
*/
|
||||
if ((freq >= 10000000) && (freq < 20000000)) {
|
||||
snd_soc_write(codec, M98088_REG_10_SYS_CLK, 0x10);
|
||||
snd_soc_component_write(component, M98088_REG_10_SYS_CLK, 0x10);
|
||||
} else if ((freq >= 20000000) && (freq < 30000000)) {
|
||||
snd_soc_write(codec, M98088_REG_10_SYS_CLK, 0x20);
|
||||
snd_soc_component_write(component, M98088_REG_10_SYS_CLK, 0x20);
|
||||
} else {
|
||||
dev_err(codec->dev, "Invalid master clock frequency\n");
|
||||
dev_err(component->dev, "Invalid master clock frequency\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (snd_soc_read(codec, M98088_REG_51_PWR_SYS) & M98088_SHDNRUN) {
|
||||
snd_soc_update_bits(codec, M98088_REG_51_PWR_SYS,
|
||||
if (snd_soc_component_read32(component, M98088_REG_51_PWR_SYS) & M98088_SHDNRUN) {
|
||||
snd_soc_component_update_bits(component, M98088_REG_51_PWR_SYS,
|
||||
M98088_SHDNRUN, 0);
|
||||
snd_soc_update_bits(codec, M98088_REG_51_PWR_SYS,
|
||||
snd_soc_component_update_bits(component, M98088_REG_51_PWR_SYS,
|
||||
M98088_SHDNRUN, M98088_SHDNRUN);
|
||||
}
|
||||
|
||||
|
@ -1132,8 +1132,8 @@ static int max98088_dai_set_sysclk(struct snd_soc_dai *dai,
|
|||
static int max98088_dai1_set_fmt(struct snd_soc_dai *codec_dai,
|
||||
unsigned int fmt)
|
||||
{
|
||||
struct snd_soc_codec *codec = codec_dai->codec;
|
||||
struct max98088_priv *max98088 = snd_soc_codec_get_drvdata(codec);
|
||||
struct snd_soc_component *component = codec_dai->component;
|
||||
struct max98088_priv *max98088 = snd_soc_component_get_drvdata(component);
|
||||
struct max98088_cdata *cdata;
|
||||
u8 reg15val;
|
||||
u8 reg14val = 0;
|
||||
|
@ -1146,9 +1146,9 @@ static int max98088_dai1_set_fmt(struct snd_soc_dai *codec_dai,
|
|||
switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) {
|
||||
case SND_SOC_DAIFMT_CBS_CFS:
|
||||
/* Slave mode PLL */
|
||||
snd_soc_write(codec, M98088_REG_12_DAI1_CLKCFG_HI,
|
||||
snd_soc_component_write(component, M98088_REG_12_DAI1_CLKCFG_HI,
|
||||
0x80);
|
||||
snd_soc_write(codec, M98088_REG_13_DAI1_CLKCFG_LO,
|
||||
snd_soc_component_write(component, M98088_REG_13_DAI1_CLKCFG_LO,
|
||||
0x00);
|
||||
break;
|
||||
case SND_SOC_DAIFMT_CBM_CFM:
|
||||
|
@ -1158,7 +1158,7 @@ static int max98088_dai1_set_fmt(struct snd_soc_dai *codec_dai,
|
|||
case SND_SOC_DAIFMT_CBS_CFM:
|
||||
case SND_SOC_DAIFMT_CBM_CFS:
|
||||
default:
|
||||
dev_err(codec->dev, "Clock mode unsupported");
|
||||
dev_err(component->dev, "Clock mode unsupported");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
|
@ -1188,14 +1188,14 @@ static int max98088_dai1_set_fmt(struct snd_soc_dai *codec_dai,
|
|||
return -EINVAL;
|
||||
}
|
||||
|
||||
snd_soc_update_bits(codec, M98088_REG_14_DAI1_FORMAT,
|
||||
snd_soc_component_update_bits(component, M98088_REG_14_DAI1_FORMAT,
|
||||
M98088_DAI_MAS | M98088_DAI_DLY | M98088_DAI_BCI |
|
||||
M98088_DAI_WCI, reg14val);
|
||||
|
||||
reg15val = M98088_DAI_BSEL64;
|
||||
if (max98088->digmic)
|
||||
reg15val |= M98088_DAI_OSR64;
|
||||
snd_soc_write(codec, M98088_REG_15_DAI1_CLOCK, reg15val);
|
||||
snd_soc_component_write(component, M98088_REG_15_DAI1_CLOCK, reg15val);
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
@ -1204,8 +1204,8 @@ static int max98088_dai1_set_fmt(struct snd_soc_dai *codec_dai,
|
|||
static int max98088_dai2_set_fmt(struct snd_soc_dai *codec_dai,
|
||||
unsigned int fmt)
|
||||
{
|
||||
struct snd_soc_codec *codec = codec_dai->codec;
|
||||
struct max98088_priv *max98088 = snd_soc_codec_get_drvdata(codec);
|
||||
struct snd_soc_component *component = codec_dai->component;
|
||||
struct max98088_priv *max98088 = snd_soc_component_get_drvdata(component);
|
||||
struct max98088_cdata *cdata;
|
||||
u8 reg1Cval = 0;
|
||||
|
||||
|
@ -1217,9 +1217,9 @@ static int max98088_dai2_set_fmt(struct snd_soc_dai *codec_dai,
|
|||
switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) {
|
||||
case SND_SOC_DAIFMT_CBS_CFS:
|
||||
/* Slave mode PLL */
|
||||
snd_soc_write(codec, M98088_REG_1A_DAI2_CLKCFG_HI,
|
||||
snd_soc_component_write(component, M98088_REG_1A_DAI2_CLKCFG_HI,
|
||||
0x80);
|
||||
snd_soc_write(codec, M98088_REG_1B_DAI2_CLKCFG_LO,
|
||||
snd_soc_component_write(component, M98088_REG_1B_DAI2_CLKCFG_LO,
|
||||
0x00);
|
||||
break;
|
||||
case SND_SOC_DAIFMT_CBM_CFM:
|
||||
|
@ -1229,7 +1229,7 @@ static int max98088_dai2_set_fmt(struct snd_soc_dai *codec_dai,
|
|||
case SND_SOC_DAIFMT_CBS_CFM:
|
||||
case SND_SOC_DAIFMT_CBM_CFS:
|
||||
default:
|
||||
dev_err(codec->dev, "Clock mode unsupported");
|
||||
dev_err(component->dev, "Clock mode unsupported");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
|
@ -1259,11 +1259,11 @@ static int max98088_dai2_set_fmt(struct snd_soc_dai *codec_dai,
|
|||
return -EINVAL;
|
||||
}
|
||||
|
||||
snd_soc_update_bits(codec, M98088_REG_1C_DAI2_FORMAT,
|
||||
snd_soc_component_update_bits(component, M98088_REG_1C_DAI2_FORMAT,
|
||||
M98088_DAI_MAS | M98088_DAI_DLY | M98088_DAI_BCI |
|
||||
M98088_DAI_WCI, reg1Cval);
|
||||
|
||||
snd_soc_write(codec, M98088_REG_1D_DAI2_CLOCK,
|
||||
snd_soc_component_write(component, M98088_REG_1D_DAI2_CLOCK,
|
||||
M98088_DAI_BSEL64);
|
||||
}
|
||||
|
||||
|
@ -1272,7 +1272,7 @@ static int max98088_dai2_set_fmt(struct snd_soc_dai *codec_dai,
|
|||
|
||||
static int max98088_dai1_digital_mute(struct snd_soc_dai *codec_dai, int mute)
|
||||
{
|
||||
struct snd_soc_codec *codec = codec_dai->codec;
|
||||
struct snd_soc_component *component = codec_dai->component;
|
||||
int reg;
|
||||
|
||||
if (mute)
|
||||
|
@ -1280,14 +1280,14 @@ static int max98088_dai1_digital_mute(struct snd_soc_dai *codec_dai, int mute)
|
|||
else
|
||||
reg = 0;
|
||||
|
||||
snd_soc_update_bits(codec, M98088_REG_2F_LVL_DAI1_PLAY,
|
||||
snd_soc_component_update_bits(component, M98088_REG_2F_LVL_DAI1_PLAY,
|
||||
M98088_DAI_MUTE_MASK, reg);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int max98088_dai2_digital_mute(struct snd_soc_dai *codec_dai, int mute)
|
||||
{
|
||||
struct snd_soc_codec *codec = codec_dai->codec;
|
||||
struct snd_soc_component *component = codec_dai->component;
|
||||
int reg;
|
||||
|
||||
if (mute)
|
||||
|
@ -1295,15 +1295,15 @@ static int max98088_dai2_digital_mute(struct snd_soc_dai *codec_dai, int mute)
|
|||
else
|
||||
reg = 0;
|
||||
|
||||
snd_soc_update_bits(codec, M98088_REG_31_LVL_DAI2_PLAY,
|
||||
snd_soc_component_update_bits(component, M98088_REG_31_LVL_DAI2_PLAY,
|
||||
M98088_DAI_MUTE_MASK, reg);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int max98088_set_bias_level(struct snd_soc_codec *codec,
|
||||
static int max98088_set_bias_level(struct snd_soc_component *component,
|
||||
enum snd_soc_bias_level level)
|
||||
{
|
||||
struct max98088_priv *max98088 = snd_soc_codec_get_drvdata(codec);
|
||||
struct max98088_priv *max98088 = snd_soc_component_get_drvdata(component);
|
||||
|
||||
switch (level) {
|
||||
case SND_SOC_BIAS_ON:
|
||||
|
@ -1313,15 +1313,15 @@ static int max98088_set_bias_level(struct snd_soc_codec *codec,
|
|||
break;
|
||||
|
||||
case SND_SOC_BIAS_STANDBY:
|
||||
if (snd_soc_codec_get_bias_level(codec) == SND_SOC_BIAS_OFF)
|
||||
if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_OFF)
|
||||
regcache_sync(max98088->regmap);
|
||||
|
||||
snd_soc_update_bits(codec, M98088_REG_4C_PWR_EN_IN,
|
||||
snd_soc_component_update_bits(component, M98088_REG_4C_PWR_EN_IN,
|
||||
M98088_MBEN, M98088_MBEN);
|
||||
break;
|
||||
|
||||
case SND_SOC_BIAS_OFF:
|
||||
snd_soc_update_bits(codec, M98088_REG_4C_PWR_EN_IN,
|
||||
snd_soc_component_update_bits(component, M98088_REG_4C_PWR_EN_IN,
|
||||
M98088_MBEN, 0);
|
||||
regcache_mark_dirty(max98088->regmap);
|
||||
break;
|
||||
|
@ -1380,7 +1380,7 @@ static struct snd_soc_dai_driver max98088_dai[] = {
|
|||
|
||||
static const char *eq_mode_name[] = {"EQ1 Mode", "EQ2 Mode"};
|
||||
|
||||
static int max98088_get_channel(struct snd_soc_codec *codec, const char *name)
|
||||
static int max98088_get_channel(struct snd_soc_component *component, const char *name)
|
||||
{
|
||||
int i;
|
||||
|
||||
|
@ -1389,13 +1389,13 @@ static int max98088_get_channel(struct snd_soc_codec *codec, const char *name)
|
|||
return i;
|
||||
|
||||
/* Shouldn't happen */
|
||||
dev_err(codec->dev, "Bad EQ channel name '%s'\n", name);
|
||||
dev_err(component->dev, "Bad EQ channel name '%s'\n", name);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
static void max98088_setup_eq1(struct snd_soc_codec *codec)
|
||||
static void max98088_setup_eq1(struct snd_soc_component *component)
|
||||
{
|
||||
struct max98088_priv *max98088 = snd_soc_codec_get_drvdata(codec);
|
||||
struct max98088_priv *max98088 = snd_soc_component_get_drvdata(component);
|
||||
struct max98088_pdata *pdata = max98088->pdata;
|
||||
struct max98088_eq_cfg *coef_set;
|
||||
int best, best_val, save, i, sel, fs;
|
||||
|
@ -1420,29 +1420,29 @@ static void max98088_setup_eq1(struct snd_soc_codec *codec)
|
|||
}
|
||||
}
|
||||
|
||||
dev_dbg(codec->dev, "Selected %s/%dHz for %dHz sample rate\n",
|
||||
dev_dbg(component->dev, "Selected %s/%dHz for %dHz sample rate\n",
|
||||
pdata->eq_cfg[best].name,
|
||||
pdata->eq_cfg[best].rate, fs);
|
||||
|
||||
/* Disable EQ while configuring, and save current on/off state */
|
||||
save = snd_soc_read(codec, M98088_REG_49_CFG_LEVEL);
|
||||
snd_soc_update_bits(codec, M98088_REG_49_CFG_LEVEL, M98088_EQ1EN, 0);
|
||||
save = snd_soc_component_read32(component, M98088_REG_49_CFG_LEVEL);
|
||||
snd_soc_component_update_bits(component, M98088_REG_49_CFG_LEVEL, M98088_EQ1EN, 0);
|
||||
|
||||
coef_set = &pdata->eq_cfg[sel];
|
||||
|
||||
m98088_eq_band(codec, 0, 0, coef_set->band1);
|
||||
m98088_eq_band(codec, 0, 1, coef_set->band2);
|
||||
m98088_eq_band(codec, 0, 2, coef_set->band3);
|
||||
m98088_eq_band(codec, 0, 3, coef_set->band4);
|
||||
m98088_eq_band(codec, 0, 4, coef_set->band5);
|
||||
m98088_eq_band(component, 0, 0, coef_set->band1);
|
||||
m98088_eq_band(component, 0, 1, coef_set->band2);
|
||||
m98088_eq_band(component, 0, 2, coef_set->band3);
|
||||
m98088_eq_band(component, 0, 3, coef_set->band4);
|
||||
m98088_eq_band(component, 0, 4, coef_set->band5);
|
||||
|
||||
/* Restore the original on/off state */
|
||||
snd_soc_update_bits(codec, M98088_REG_49_CFG_LEVEL, M98088_EQ1EN, save);
|
||||
snd_soc_component_update_bits(component, M98088_REG_49_CFG_LEVEL, M98088_EQ1EN, save);
|
||||
}
|
||||
|
||||
static void max98088_setup_eq2(struct snd_soc_codec *codec)
|
||||
static void max98088_setup_eq2(struct snd_soc_component *component)
|
||||
{
|
||||
struct max98088_priv *max98088 = snd_soc_codec_get_drvdata(codec);
|
||||
struct max98088_priv *max98088 = snd_soc_component_get_drvdata(component);
|
||||
struct max98088_pdata *pdata = max98088->pdata;
|
||||
struct max98088_eq_cfg *coef_set;
|
||||
int best, best_val, save, i, sel, fs;
|
||||
|
@ -1467,34 +1467,34 @@ static void max98088_setup_eq2(struct snd_soc_codec *codec)
|
|||
}
|
||||
}
|
||||
|
||||
dev_dbg(codec->dev, "Selected %s/%dHz for %dHz sample rate\n",
|
||||
dev_dbg(component->dev, "Selected %s/%dHz for %dHz sample rate\n",
|
||||
pdata->eq_cfg[best].name,
|
||||
pdata->eq_cfg[best].rate, fs);
|
||||
|
||||
/* Disable EQ while configuring, and save current on/off state */
|
||||
save = snd_soc_read(codec, M98088_REG_49_CFG_LEVEL);
|
||||
snd_soc_update_bits(codec, M98088_REG_49_CFG_LEVEL, M98088_EQ2EN, 0);
|
||||
save = snd_soc_component_read32(component, M98088_REG_49_CFG_LEVEL);
|
||||
snd_soc_component_update_bits(component, M98088_REG_49_CFG_LEVEL, M98088_EQ2EN, 0);
|
||||
|
||||
coef_set = &pdata->eq_cfg[sel];
|
||||
|
||||
m98088_eq_band(codec, 1, 0, coef_set->band1);
|
||||
m98088_eq_band(codec, 1, 1, coef_set->band2);
|
||||
m98088_eq_band(codec, 1, 2, coef_set->band3);
|
||||
m98088_eq_band(codec, 1, 3, coef_set->band4);
|
||||
m98088_eq_band(codec, 1, 4, coef_set->band5);
|
||||
m98088_eq_band(component, 1, 0, coef_set->band1);
|
||||
m98088_eq_band(component, 1, 1, coef_set->band2);
|
||||
m98088_eq_band(component, 1, 2, coef_set->band3);
|
||||
m98088_eq_band(component, 1, 3, coef_set->band4);
|
||||
m98088_eq_band(component, 1, 4, coef_set->band5);
|
||||
|
||||
/* Restore the original on/off state */
|
||||
snd_soc_update_bits(codec, M98088_REG_49_CFG_LEVEL, M98088_EQ2EN,
|
||||
snd_soc_component_update_bits(component, M98088_REG_49_CFG_LEVEL, M98088_EQ2EN,
|
||||
save);
|
||||
}
|
||||
|
||||
static int max98088_put_eq_enum(struct snd_kcontrol *kcontrol,
|
||||
struct snd_ctl_elem_value *ucontrol)
|
||||
{
|
||||
struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
|
||||
struct max98088_priv *max98088 = snd_soc_codec_get_drvdata(codec);
|
||||
struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol);
|
||||
struct max98088_priv *max98088 = snd_soc_component_get_drvdata(component);
|
||||
struct max98088_pdata *pdata = max98088->pdata;
|
||||
int channel = max98088_get_channel(codec, kcontrol->id.name);
|
||||
int channel = max98088_get_channel(component, kcontrol->id.name);
|
||||
struct max98088_cdata *cdata;
|
||||
int sel = ucontrol->value.enumerated.item[0];
|
||||
|
||||
|
@ -1510,10 +1510,10 @@ static int max98088_put_eq_enum(struct snd_kcontrol *kcontrol,
|
|||
|
||||
switch (channel) {
|
||||
case 0:
|
||||
max98088_setup_eq1(codec);
|
||||
max98088_setup_eq1(component);
|
||||
break;
|
||||
case 1:
|
||||
max98088_setup_eq2(codec);
|
||||
max98088_setup_eq2(component);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -1523,9 +1523,9 @@ static int max98088_put_eq_enum(struct snd_kcontrol *kcontrol,
|
|||
static int max98088_get_eq_enum(struct snd_kcontrol *kcontrol,
|
||||
struct snd_ctl_elem_value *ucontrol)
|
||||
{
|
||||
struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
|
||||
struct max98088_priv *max98088 = snd_soc_codec_get_drvdata(codec);
|
||||
int channel = max98088_get_channel(codec, kcontrol->id.name);
|
||||
struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol);
|
||||
struct max98088_priv *max98088 = snd_soc_component_get_drvdata(component);
|
||||
int channel = max98088_get_channel(component, kcontrol->id.name);
|
||||
struct max98088_cdata *cdata;
|
||||
|
||||
if (channel < 0)
|
||||
|
@ -1536,9 +1536,9 @@ static int max98088_get_eq_enum(struct snd_kcontrol *kcontrol,
|
|||
return 0;
|
||||
}
|
||||
|
||||
static void max98088_handle_eq_pdata(struct snd_soc_codec *codec)
|
||||
static void max98088_handle_eq_pdata(struct snd_soc_component *component)
|
||||
{
|
||||
struct max98088_priv *max98088 = snd_soc_codec_get_drvdata(codec);
|
||||
struct max98088_priv *max98088 = snd_soc_component_get_drvdata(component);
|
||||
struct max98088_pdata *pdata = max98088->pdata;
|
||||
struct max98088_eq_cfg *cfg;
|
||||
unsigned int cfgcnt;
|
||||
|
@ -1591,19 +1591,19 @@ static void max98088_handle_eq_pdata(struct snd_soc_codec *codec)
|
|||
max98088->eq_enum.texts = max98088->eq_texts;
|
||||
max98088->eq_enum.items = max98088->eq_textcnt;
|
||||
|
||||
ret = snd_soc_add_codec_controls(codec, controls, ARRAY_SIZE(controls));
|
||||
ret = snd_soc_add_component_controls(component, controls, ARRAY_SIZE(controls));
|
||||
if (ret != 0)
|
||||
dev_err(codec->dev, "Failed to add EQ control: %d\n", ret);
|
||||
dev_err(component->dev, "Failed to add EQ control: %d\n", ret);
|
||||
}
|
||||
|
||||
static void max98088_handle_pdata(struct snd_soc_codec *codec)
|
||||
static void max98088_handle_pdata(struct snd_soc_component *component)
|
||||
{
|
||||
struct max98088_priv *max98088 = snd_soc_codec_get_drvdata(codec);
|
||||
struct max98088_priv *max98088 = snd_soc_component_get_drvdata(component);
|
||||
struct max98088_pdata *pdata = max98088->pdata;
|
||||
u8 regval = 0;
|
||||
|
||||
if (!pdata) {
|
||||
dev_dbg(codec->dev, "No platform data\n");
|
||||
dev_dbg(component->dev, "No platform data\n");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1616,21 +1616,21 @@ static void max98088_handle_pdata(struct snd_soc_codec *codec)
|
|||
|
||||
max98088->digmic = (regval ? 1 : 0);
|
||||
|
||||
snd_soc_write(codec, M98088_REG_48_CFG_MIC, regval);
|
||||
snd_soc_component_write(component, M98088_REG_48_CFG_MIC, regval);
|
||||
|
||||
/* Configure receiver output */
|
||||
regval = ((pdata->receiver_mode) ? M98088_REC_LINEMODE : 0);
|
||||
snd_soc_update_bits(codec, M98088_REG_2A_MIC_REC_CNTL,
|
||||
snd_soc_component_update_bits(component, M98088_REG_2A_MIC_REC_CNTL,
|
||||
M98088_REC_LINEMODE_MASK, regval);
|
||||
|
||||
/* Configure equalizers */
|
||||
if (pdata->eq_cfgcnt)
|
||||
max98088_handle_eq_pdata(codec);
|
||||
max98088_handle_eq_pdata(component);
|
||||
}
|
||||
|
||||
static int max98088_probe(struct snd_soc_codec *codec)
|
||||
static int max98088_probe(struct snd_soc_component *component)
|
||||
{
|
||||
struct max98088_priv *max98088 = snd_soc_codec_get_drvdata(codec);
|
||||
struct max98088_priv *max98088 = snd_soc_component_get_drvdata(component);
|
||||
struct max98088_cdata *cdata;
|
||||
int ret = 0;
|
||||
|
||||
|
@ -1658,60 +1658,59 @@ static int max98088_probe(struct snd_soc_codec *codec)
|
|||
max98088->mic1pre = 0;
|
||||
max98088->mic2pre = 0;
|
||||
|
||||
ret = snd_soc_read(codec, M98088_REG_FF_REV_ID);
|
||||
ret = snd_soc_component_read32(component, M98088_REG_FF_REV_ID);
|
||||
if (ret < 0) {
|
||||
dev_err(codec->dev, "Failed to read device revision: %d\n",
|
||||
dev_err(component->dev, "Failed to read device revision: %d\n",
|
||||
ret);
|
||||
goto err_access;
|
||||
}
|
||||
dev_info(codec->dev, "revision %c\n", ret - 0x40 + 'A');
|
||||
dev_info(component->dev, "revision %c\n", ret - 0x40 + 'A');
|
||||
|
||||
snd_soc_write(codec, M98088_REG_51_PWR_SYS, M98088_PWRSV);
|
||||
snd_soc_component_write(component, M98088_REG_51_PWR_SYS, M98088_PWRSV);
|
||||
|
||||
snd_soc_write(codec, M98088_REG_0F_IRQ_ENABLE, 0x00);
|
||||
snd_soc_component_write(component, M98088_REG_0F_IRQ_ENABLE, 0x00);
|
||||
|
||||
snd_soc_write(codec, M98088_REG_22_MIX_DAC,
|
||||
snd_soc_component_write(component, M98088_REG_22_MIX_DAC,
|
||||
M98088_DAI1L_TO_DACL|M98088_DAI2L_TO_DACL|
|
||||
M98088_DAI1R_TO_DACR|M98088_DAI2R_TO_DACR);
|
||||
|
||||
snd_soc_write(codec, M98088_REG_4E_BIAS_CNTL, 0xF0);
|
||||
snd_soc_write(codec, M98088_REG_50_DAC_BIAS2, 0x0F);
|
||||
snd_soc_component_write(component, M98088_REG_4E_BIAS_CNTL, 0xF0);
|
||||
snd_soc_component_write(component, M98088_REG_50_DAC_BIAS2, 0x0F);
|
||||
|
||||
snd_soc_write(codec, M98088_REG_16_DAI1_IOCFG,
|
||||
snd_soc_component_write(component, M98088_REG_16_DAI1_IOCFG,
|
||||
M98088_S1NORMAL|M98088_SDATA);
|
||||
|
||||
snd_soc_write(codec, M98088_REG_1E_DAI2_IOCFG,
|
||||
snd_soc_component_write(component, M98088_REG_1E_DAI2_IOCFG,
|
||||
M98088_S2NORMAL|M98088_SDATA);
|
||||
|
||||
max98088_handle_pdata(codec);
|
||||
max98088_handle_pdata(component);
|
||||
|
||||
err_access:
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int max98088_remove(struct snd_soc_codec *codec)
|
||||
static void max98088_remove(struct snd_soc_component *component)
|
||||
{
|
||||
struct max98088_priv *max98088 = snd_soc_codec_get_drvdata(codec);
|
||||
struct max98088_priv *max98088 = snd_soc_component_get_drvdata(component);
|
||||
|
||||
kfree(max98088->eq_texts);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const struct snd_soc_codec_driver soc_codec_dev_max98088 = {
|
||||
.probe = max98088_probe,
|
||||
.remove = max98088_remove,
|
||||
.set_bias_level = max98088_set_bias_level,
|
||||
.suspend_bias_off = true,
|
||||
|
||||
.component_driver = {
|
||||
.controls = max98088_snd_controls,
|
||||
.num_controls = ARRAY_SIZE(max98088_snd_controls),
|
||||
.dapm_widgets = max98088_dapm_widgets,
|
||||
.num_dapm_widgets = ARRAY_SIZE(max98088_dapm_widgets),
|
||||
.dapm_routes = max98088_audio_map,
|
||||
.num_dapm_routes = ARRAY_SIZE(max98088_audio_map),
|
||||
},
|
||||
static const struct snd_soc_component_driver soc_component_dev_max98088 = {
|
||||
.probe = max98088_probe,
|
||||
.remove = max98088_remove,
|
||||
.set_bias_level = max98088_set_bias_level,
|
||||
.controls = max98088_snd_controls,
|
||||
.num_controls = ARRAY_SIZE(max98088_snd_controls),
|
||||
.dapm_widgets = max98088_dapm_widgets,
|
||||
.num_dapm_widgets = ARRAY_SIZE(max98088_dapm_widgets),
|
||||
.dapm_routes = max98088_audio_map,
|
||||
.num_dapm_routes = ARRAY_SIZE(max98088_audio_map),
|
||||
.suspend_bias_off = 1,
|
||||
.idle_bias_on = 1,
|
||||
.use_pmdown_time = 1,
|
||||
.endianness = 1,
|
||||
.non_legacy_dai_naming = 1,
|
||||
};
|
||||
|
||||
static int max98088_i2c_probe(struct i2c_client *i2c,
|
||||
|
@ -1734,17 +1733,11 @@ static int max98088_i2c_probe(struct i2c_client *i2c,
|
|||
i2c_set_clientdata(i2c, max98088);
|
||||
max98088->pdata = i2c->dev.platform_data;
|
||||
|
||||
ret = snd_soc_register_codec(&i2c->dev,
|
||||
&soc_codec_dev_max98088, &max98088_dai[0], 2);
|
||||
ret = devm_snd_soc_register_component(&i2c->dev,
|
||||
&soc_component_dev_max98088, &max98088_dai[0], 2);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int max98088_i2c_remove(struct i2c_client *client)
|
||||
{
|
||||
snd_soc_unregister_codec(&client->dev);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const struct i2c_device_id max98088_i2c_id[] = {
|
||||
{ "max98088", MAX98088 },
|
||||
{ "max98089", MAX98089 },
|
||||
|
@ -1757,7 +1750,6 @@ static struct i2c_driver max98088_i2c_driver = {
|
|||
.name = "max98088",
|
||||
},
|
||||
.probe = max98088_i2c_probe,
|
||||
.remove = max98088_i2c_remove,
|
||||
.id_table = max98088_i2c_id,
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue