Commit 97e15d9a authored by Mark Brown's avatar Mark Brown

Merge remote-tracking branches 'asoc/topic/ak4613', 'asoc/topic/ak4642',...

Merge remote-tracking branches 'asoc/topic/ak4613', 'asoc/topic/ak4642', 'asoc/topic/arizona', 'asoc/topic/atmel' and 'asoc/topic/au1x' into asoc-next
AK4613 I2C transmitter
This device supports I2C mode only.
Required properties:
- compatible : "asahi-kasei,ak4613"
- reg : The chip select number on the I2C bus
Example:
&i2c {
ak4613: ak4613@0x10 {
compatible = "asahi-kasei,ak4613";
reg = <0x10>;
};
};
...@@ -7,7 +7,14 @@ Required properties: ...@@ -7,7 +7,14 @@ Required properties:
- compatible : "asahi-kasei,ak4642" or "asahi-kasei,ak4643" or "asahi-kasei,ak4648" - compatible : "asahi-kasei,ak4642" or "asahi-kasei,ak4643" or "asahi-kasei,ak4648"
- reg : The chip select number on the I2C bus - reg : The chip select number on the I2C bus
Example: Optional properties:
- #clock-cells : common clock binding; shall be set to 0
- clocks : common clock binding; MCKI clock
- clock-frequency : common clock binding; frequency of MCKO
- clock-output-names : common clock binding; MCKO clock name
Example 1:
&i2c { &i2c {
ak4648: ak4648@0x12 { ak4648: ak4648@0x12 {
...@@ -15,3 +22,16 @@ Example: ...@@ -15,3 +22,16 @@ Example:
reg = <0x12>; reg = <0x12>;
}; };
}; };
Example 2:
&i2c {
ak4643: codec@12 {
compatible = "asahi-kasei,ak4643";
reg = <0x12>;
#clock-cells = <0>;
clocks = <&audio_clock>;
clock-frequency = <12288000>;
clock-output-names = "ak4643_mcko";
};
};
...@@ -871,14 +871,7 @@ static int atmel_spi_set_xfer_speed(struct atmel_spi *as, ...@@ -871,14 +871,7 @@ static int atmel_spi_set_xfer_speed(struct atmel_spi *as,
* Calculate the lowest divider that satisfies the * Calculate the lowest divider that satisfies the
* constraint, assuming div32/fdiv/mbz == 0. * constraint, assuming div32/fdiv/mbz == 0.
*/ */
if (xfer->speed_hz)
scbr = DIV_ROUND_UP(bus_hz, xfer->speed_hz); scbr = DIV_ROUND_UP(bus_hz, xfer->speed_hz);
else
/*
* This can happend if max_speed is null.
* In this case, we set the lowest possible speed
*/
scbr = 0xff;
/* /*
* If the resulting divider doesn't fit into the * If the resulting divider doesn't fit into the
...@@ -1300,7 +1293,6 @@ static int atmel_spi_one_transfer(struct spi_master *master, ...@@ -1300,7 +1293,6 @@ static int atmel_spi_one_transfer(struct spi_master *master,
return -EINVAL; return -EINVAL;
} }
if (xfer->bits_per_word) {
asd = spi->controller_state; asd = spi->controller_state;
bits = (asd->csr >> 4) & 0xf; bits = (asd->csr >> 4) & 0xf;
if (bits != xfer->bits_per_word - 8) { if (bits != xfer->bits_per_word - 8) {
...@@ -1308,7 +1300,6 @@ static int atmel_spi_one_transfer(struct spi_master *master, ...@@ -1308,7 +1300,6 @@ static int atmel_spi_one_transfer(struct spi_master *master,
"you can't yet change bits_per_word in transfers\n"); "you can't yet change bits_per_word in transfers\n");
return -ENOPROTOOPT; return -ENOPROTOOPT;
} }
}
/* /*
* DMA map early, for performance (empties dcache ASAP) and * DMA map early, for performance (empties dcache ASAP) and
......
...@@ -226,6 +226,18 @@ ...@@ -226,6 +226,18 @@
.info = snd_soc_info_volsw, \ .info = snd_soc_info_volsw, \
.get = xhandler_get, .put = xhandler_put, \ .get = xhandler_get, .put = xhandler_put, \
.private_value = SOC_SINGLE_VALUE(xreg, xshift, xmax, xinvert, 0) } .private_value = SOC_SINGLE_VALUE(xreg, xshift, xmax, xinvert, 0) }
#define SOC_SINGLE_RANGE_EXT_TLV(xname, xreg, xshift, xmin, xmax, xinvert, \
xhandler_get, xhandler_put, tlv_array) \
{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname),\
.access = SNDRV_CTL_ELEM_ACCESS_TLV_READ |\
SNDRV_CTL_ELEM_ACCESS_READWRITE,\
.tlv.p = (tlv_array), \
.info = snd_soc_info_volsw_range, \
.get = xhandler_get, .put = xhandler_put, \
.private_value = (unsigned long)&(struct soc_mixer_control) \
{.reg = xreg, .rreg = xreg, .shift = xshift, \
.rshift = xshift, .min = xmin, .max = xmax, \
.platform_max = xmax, .invert = xinvert} }
#define SOC_DOUBLE_EXT_TLV(xname, xreg, shift_left, shift_right, xmax, xinvert,\ #define SOC_DOUBLE_EXT_TLV(xname, xreg, shift_left, shift_right, xmax, xinvert,\
xhandler_get, xhandler_put, tlv_array) \ xhandler_get, xhandler_put, tlv_array) \
{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname), \ { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname), \
......
...@@ -176,6 +176,7 @@ static const struct of_device_id atmel_asoc_wm8904_dt_ids[] = { ...@@ -176,6 +176,7 @@ static const struct of_device_id atmel_asoc_wm8904_dt_ids[] = {
{ .compatible = "atmel,asoc-wm8904", }, { .compatible = "atmel,asoc-wm8904", },
{ } { }
}; };
MODULE_DEVICE_TABLE(of, atmel_asoc_wm8904_dt_ids);
#endif #endif
static struct platform_driver atmel_asoc_wm8904_driver = { static struct platform_driver atmel_asoc_wm8904_driver = {
......
...@@ -38,14 +38,7 @@ static int db1000_audio_probe(struct platform_device *pdev) ...@@ -38,14 +38,7 @@ static int db1000_audio_probe(struct platform_device *pdev)
{ {
struct snd_soc_card *card = &db1000_ac97; struct snd_soc_card *card = &db1000_ac97;
card->dev = &pdev->dev; card->dev = &pdev->dev;
return snd_soc_register_card(card); return devm_snd_soc_register_card(&pdev->dev, card);
}
static int db1000_audio_remove(struct platform_device *pdev)
{
struct snd_soc_card *card = platform_get_drvdata(pdev);
snd_soc_unregister_card(card);
return 0;
} }
static struct platform_driver db1000_audio_driver = { static struct platform_driver db1000_audio_driver = {
...@@ -54,7 +47,6 @@ static struct platform_driver db1000_audio_driver = { ...@@ -54,7 +47,6 @@ static struct platform_driver db1000_audio_driver = {
.pm = &snd_soc_pm_ops, .pm = &snd_soc_pm_ops,
}, },
.probe = db1000_audio_probe, .probe = db1000_audio_probe,
.remove = db1000_audio_remove,
}; };
module_platform_driver(db1000_audio_driver); module_platform_driver(db1000_audio_driver);
......
...@@ -174,14 +174,7 @@ static int db1200_audio_probe(struct platform_device *pdev) ...@@ -174,14 +174,7 @@ static int db1200_audio_probe(struct platform_device *pdev)
card = db1200_cards[pid->driver_data]; card = db1200_cards[pid->driver_data];
card->dev = &pdev->dev; card->dev = &pdev->dev;
return snd_soc_register_card(card); return devm_snd_soc_register_card(&pdev->dev, card);
}
static int db1200_audio_remove(struct platform_device *pdev)
{
struct snd_soc_card *card = platform_get_drvdata(pdev);
snd_soc_unregister_card(card);
return 0;
} }
static struct platform_driver db1200_audio_driver = { static struct platform_driver db1200_audio_driver = {
...@@ -191,7 +184,6 @@ static struct platform_driver db1200_audio_driver = { ...@@ -191,7 +184,6 @@ static struct platform_driver db1200_audio_driver = {
}, },
.id_table = db1200_pids, .id_table = db1200_pids,
.probe = db1200_audio_probe, .probe = db1200_audio_probe,
.remove = db1200_audio_remove,
}; };
module_platform_driver(db1200_audio_driver); module_platform_driver(db1200_audio_driver);
......
...@@ -36,6 +36,7 @@ config SND_SOC_ALL_CODECS ...@@ -36,6 +36,7 @@ config SND_SOC_ALL_CODECS
select SND_SOC_AK4104 if SPI_MASTER select SND_SOC_AK4104 if SPI_MASTER
select SND_SOC_AK4535 if I2C select SND_SOC_AK4535 if I2C
select SND_SOC_AK4554 select SND_SOC_AK4554
select SND_SOC_AK4613 if I2C
select SND_SOC_AK4641 if I2C select SND_SOC_AK4641 if I2C
select SND_SOC_AK4642 if I2C select SND_SOC_AK4642 if I2C
select SND_SOC_AK4671 if I2C select SND_SOC_AK4671 if I2C
...@@ -319,6 +320,10 @@ config SND_SOC_AK4535 ...@@ -319,6 +320,10 @@ config SND_SOC_AK4535
config SND_SOC_AK4554 config SND_SOC_AK4554
tristate "AKM AK4554 CODEC" tristate "AKM AK4554 CODEC"
config SND_SOC_AK4613
tristate "AKM AK4613 CODEC"
depends on I2C
config SND_SOC_AK4641 config SND_SOC_AK4641
tristate tristate
......
...@@ -26,6 +26,7 @@ snd-soc-ads117x-objs := ads117x.o ...@@ -26,6 +26,7 @@ snd-soc-ads117x-objs := ads117x.o
snd-soc-ak4104-objs := ak4104.o snd-soc-ak4104-objs := ak4104.o
snd-soc-ak4535-objs := ak4535.o snd-soc-ak4535-objs := ak4535.o
snd-soc-ak4554-objs := ak4554.o snd-soc-ak4554-objs := ak4554.o
snd-soc-ak4613-objs := ak4613.o
snd-soc-ak4641-objs := ak4641.o snd-soc-ak4641-objs := ak4641.o
snd-soc-ak4642-objs := ak4642.o snd-soc-ak4642-objs := ak4642.o
snd-soc-ak4671-objs := ak4671.o snd-soc-ak4671-objs := ak4671.o
...@@ -216,6 +217,7 @@ obj-$(CONFIG_SND_SOC_ADS117X) += snd-soc-ads117x.o ...@@ -216,6 +217,7 @@ obj-$(CONFIG_SND_SOC_ADS117X) += snd-soc-ads117x.o
obj-$(CONFIG_SND_SOC_AK4104) += snd-soc-ak4104.o obj-$(CONFIG_SND_SOC_AK4104) += snd-soc-ak4104.o
obj-$(CONFIG_SND_SOC_AK4535) += snd-soc-ak4535.o obj-$(CONFIG_SND_SOC_AK4535) += snd-soc-ak4535.o
obj-$(CONFIG_SND_SOC_AK4554) += snd-soc-ak4554.o obj-$(CONFIG_SND_SOC_AK4554) += snd-soc-ak4554.o
obj-$(CONFIG_SND_SOC_AK4613) += snd-soc-ak4613.o
obj-$(CONFIG_SND_SOC_AK4641) += snd-soc-ak4641.o obj-$(CONFIG_SND_SOC_AK4641) += snd-soc-ak4641.o
obj-$(CONFIG_SND_SOC_AK4642) += snd-soc-ak4642.o obj-$(CONFIG_SND_SOC_AK4642) += snd-soc-ak4642.o
obj-$(CONFIG_SND_SOC_AK4671) += snd-soc-ak4671.o obj-$(CONFIG_SND_SOC_AK4671) += snd-soc-ak4671.o
......
This diff is collapsed.
...@@ -23,6 +23,8 @@ ...@@ -23,6 +23,8 @@
* AK4648 is tested. * AK4648 is tested.
*/ */
#include <linux/clk.h>
#include <linux/clk-provider.h>
#include <linux/delay.h> #include <linux/delay.h>
#include <linux/i2c.h> #include <linux/i2c.h>
#include <linux/slab.h> #include <linux/slab.h>
...@@ -128,11 +130,8 @@ ...@@ -128,11 +130,8 @@
#define I2S (3 << 0) #define I2S (3 << 0)
/* MD_CTL2 */ /* MD_CTL2 */
#define FS0 (1 << 0) #define FSs(val) (((val & 0x7) << 0) | ((val & 0x8) << 2))
#define FS1 (1 << 1) #define PSs(val) ((val & 0x3) << 6)
#define FS2 (1 << 2)
#define FS3 (1 << 5)
#define FS_MASK (FS0 | FS1 | FS2 | FS3)
/* MD_CTL3 */ /* MD_CTL3 */
#define BST1 (1 << 3) #define BST1 (1 << 3)
...@@ -147,6 +146,7 @@ struct ak4642_drvdata { ...@@ -147,6 +146,7 @@ struct ak4642_drvdata {
struct ak4642_priv { struct ak4642_priv {
const struct ak4642_drvdata *drvdata; const struct ak4642_drvdata *drvdata;
struct clk *mcko;
}; };
/* /*
...@@ -430,56 +430,56 @@ static int ak4642_dai_set_fmt(struct snd_soc_dai *dai, unsigned int fmt) ...@@ -430,56 +430,56 @@ static int ak4642_dai_set_fmt(struct snd_soc_dai *dai, unsigned int fmt)
return 0; return 0;
} }
static int ak4642_set_mcko(struct snd_soc_codec *codec,
u32 frequency)
{
u32 fs_list[] = {
[0] = 8000,
[1] = 12000,
[2] = 16000,
[3] = 24000,
[4] = 7350,
[5] = 11025,
[6] = 14700,
[7] = 22050,
[10] = 32000,
[11] = 48000,
[14] = 29400,
[15] = 44100,
};
u32 ps_list[] = {
[0] = 256,
[1] = 128,
[2] = 64,
[3] = 32
};
int ps, fs;
for (ps = 0; ps < ARRAY_SIZE(ps_list); ps++) {
for (fs = 0; fs < ARRAY_SIZE(fs_list); fs++) {
if (frequency == ps_list[ps] * fs_list[fs]) {
snd_soc_write(codec, MD_CTL2,
PSs(ps) | FSs(fs));
return 0;
}
}
}
return 0;
}
static int ak4642_dai_hw_params(struct snd_pcm_substream *substream, static int ak4642_dai_hw_params(struct snd_pcm_substream *substream,
struct snd_pcm_hw_params *params, struct snd_pcm_hw_params *params,
struct snd_soc_dai *dai) struct snd_soc_dai *dai)
{ {
struct snd_soc_codec *codec = dai->codec; struct snd_soc_codec *codec = dai->codec;
u8 rate; struct ak4642_priv *priv = snd_soc_codec_get_drvdata(codec);
u32 rate = clk_get_rate(priv->mcko);
switch (params_rate(params)) { if (!rate)
case 7350: rate = params_rate(params) * 256;
rate = FS2;
break;
case 8000:
rate = 0;
break;
case 11025:
rate = FS2 | FS0;
break;
case 12000:
rate = FS0;
break;
case 14700:
rate = FS2 | FS1;
break;
case 16000:
rate = FS1;
break;
case 22050:
rate = FS2 | FS1 | FS0;
break;
case 24000:
rate = FS1 | FS0;
break;
case 29400:
rate = FS3 | FS2 | FS1;
break;
case 32000:
rate = FS3 | FS1;
break;
case 44100:
rate = FS3 | FS2 | FS1 | FS0;
break;
case 48000:
rate = FS3 | FS1 | FS0;
break;
default:
return -EINVAL;
}
snd_soc_update_bits(codec, MD_CTL2, FS_MASK, rate);
return 0; return ak4642_set_mcko(codec, rate);
} }
static int ak4642_set_bias_level(struct snd_soc_codec *codec, static int ak4642_set_bias_level(struct snd_soc_codec *codec,
...@@ -532,7 +532,18 @@ static int ak4642_resume(struct snd_soc_codec *codec) ...@@ -532,7 +532,18 @@ static int ak4642_resume(struct snd_soc_codec *codec)
return 0; return 0;
} }
static int ak4642_probe(struct snd_soc_codec *codec)
{
struct ak4642_priv *priv = snd_soc_codec_get_drvdata(codec);
if (priv->mcko)
ak4642_set_mcko(codec, clk_get_rate(priv->mcko));
return 0;
}
static struct snd_soc_codec_driver soc_codec_dev_ak4642 = { static struct snd_soc_codec_driver soc_codec_dev_ak4642 = {
.probe = ak4642_probe,
.resume = ak4642_resume, .resume = ak4642_resume,
.set_bias_level = ak4642_set_bias_level, .set_bias_level = ak4642_set_bias_level,
.controls = ak4642_snd_controls, .controls = ak4642_snd_controls,
...@@ -580,19 +591,54 @@ static const struct ak4642_drvdata ak4648_drvdata = { ...@@ -580,19 +591,54 @@ static const struct ak4642_drvdata ak4648_drvdata = {
.extended_frequencies = 1, .extended_frequencies = 1,
}; };
#ifdef CONFIG_COMMON_CLK
static struct clk *ak4642_of_parse_mcko(struct device *dev)
{
struct device_node *np = dev->of_node;
struct clk *clk;
const char *clk_name = np->name;
const char *parent_clk_name = NULL;
u32 rate;
if (of_property_read_u32(np, "clock-frequency", &rate))
return NULL;
if (of_property_read_bool(np, "clocks"))
parent_clk_name = of_clk_get_parent_name(np, 0);
of_property_read_string(np, "clock-output-names", &clk_name);
clk = clk_register_fixed_rate(dev, clk_name, parent_clk_name,
(parent_clk_name) ? 0 : CLK_IS_ROOT,
rate);
if (!IS_ERR(clk))
of_clk_add_provider(np, of_clk_src_simple_get, clk);
return clk;
}
#else
#define ak4642_of_parse_mcko(d) 0
#endif
static const struct of_device_id ak4642_of_match[]; static const struct of_device_id ak4642_of_match[];
static int ak4642_i2c_probe(struct i2c_client *i2c, static int ak4642_i2c_probe(struct i2c_client *i2c,
const struct i2c_device_id *id) const struct i2c_device_id *id)
{ {
struct device_node *np = i2c->dev.of_node; struct device *dev = &i2c->dev;
struct device_node *np = dev->of_node;
const struct ak4642_drvdata *drvdata = NULL; const struct ak4642_drvdata *drvdata = NULL;
struct regmap *regmap; struct regmap *regmap;
struct ak4642_priv *priv; struct ak4642_priv *priv;
struct clk *mcko = NULL;
if (np) { if (np) {
const struct of_device_id *of_id; const struct of_device_id *of_id;
of_id = of_match_device(ak4642_of_match, &i2c->dev); mcko = ak4642_of_parse_mcko(dev);
if (IS_ERR(mcko))
mcko = NULL;
of_id = of_match_device(ak4642_of_match, dev);
if (of_id) if (of_id)
drvdata = of_id->data; drvdata = of_id->data;
} else { } else {
...@@ -600,15 +646,16 @@ static int ak4642_i2c_probe(struct i2c_client *i2c, ...@@ -600,15 +646,16 @@ static int ak4642_i2c_probe(struct i2c_client *i2c,
} }
if (!drvdata) { if (!drvdata) {
dev_err(&i2c->dev, "Unknown device type\n"); dev_err(dev, "Unknown device type\n");
return -EINVAL; return -EINVAL;
} }
priv = devm_kzalloc(&i2c->dev, sizeof(*priv), GFP_KERNEL); priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
if (!priv) if (!priv)
return -ENOMEM; return -ENOMEM;
priv->drvdata = drvdata; priv->drvdata = drvdata;
priv->mcko = mcko;
i2c_set_clientdata(i2c, priv); i2c_set_clientdata(i2c, priv);
...@@ -616,7 +663,7 @@ static int ak4642_i2c_probe(struct i2c_client *i2c, ...@@ -616,7 +663,7 @@ static int ak4642_i2c_probe(struct i2c_client *i2c,
if (IS_ERR(regmap)) if (IS_ERR(regmap))
return PTR_ERR(regmap); return PTR_ERR(regmap);
return snd_soc_register_codec(&i2c->dev, return snd_soc_register_codec(dev,
&soc_codec_dev_ak4642, &ak4642_dai, 1); &soc_codec_dev_ak4642, &ak4642_dai, 1);
} }
......
...@@ -147,6 +147,8 @@ static int arizona_spk_ev(struct snd_soc_dapm_widget *w, ...@@ -147,6 +147,8 @@ static int arizona_spk_ev(struct snd_soc_dapm_widget *w,
0x4f5, 0x0da); 0x4f5, 0x0da);
} }
break; break;
default:
break;
} }
return 0; return 0;
...@@ -689,6 +691,15 @@ static void arizona_in_set_vu(struct snd_soc_codec *codec, int ena) ...@@ -689,6 +691,15 @@ static void arizona_in_set_vu(struct snd_soc_codec *codec, int ena)
ARIZONA_IN_VU, val); ARIZONA_IN_VU, val);
} }
bool arizona_input_analog(struct snd_soc_codec *codec, int shift)
{
unsigned int reg = ARIZONA_IN1L_CONTROL + ((shift / 2) * 8);
unsigned int val = snd_soc_read(codec, reg);
return !(val & ARIZONA_IN1_MODE_MASK);
}
EXPORT_SYMBOL_GPL(arizona_input_analog);
int arizona_in_ev(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int arizona_in_ev(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol,
int event) int event)
{ {
...@@ -725,6 +736,9 @@ int arizona_in_ev(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, ...@@ -725,6 +736,9 @@ int arizona_in_ev(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol,
reg = snd_soc_read(codec, ARIZONA_INPUT_ENABLES); reg = snd_soc_read(codec, ARIZONA_INPUT_ENABLES);
if (reg == 0) if (reg == 0)
arizona_in_set_vu(codec, 0); arizona_in_set_vu(codec, 0);
break;
default:
break;
} }
return 0; return 0;
...@@ -806,6 +820,8 @@ int arizona_out_ev(struct snd_soc_dapm_widget *w, ...@@ -806,6 +820,8 @@ int arizona_out_ev(struct snd_soc_dapm_widget *w,
break; break;
} }
break; break;
default:
break;
} }
return 0; return 0;
......
...@@ -294,4 +294,6 @@ extern int arizona_init_dai(struct arizona_priv *priv, int dai); ...@@ -294,4 +294,6 @@ extern int arizona_init_dai(struct arizona_priv *priv, int dai);
int arizona_set_output_mode(struct snd_soc_codec *codec, int output, int arizona_set_output_mode(struct snd_soc_codec *codec, int output,
bool diff); bool diff);
extern bool arizona_input_analog(struct snd_soc_codec *codec, int shift);
#endif #endif
...@@ -38,6 +38,12 @@ ...@@ -38,6 +38,12 @@
struct wm5110_priv { struct wm5110_priv {
struct arizona_priv core; struct arizona_priv core;
struct arizona_fll fll[2]; struct arizona_fll fll[2];
unsigned int in_value;
int in_pre_pending;
int in_post_pending;
unsigned int in_pga_cache[6];
}; };
static const struct wm_adsp_region wm5110_dsp1_regions[] = { static const struct wm_adsp_region wm5110_dsp1_regions[] = {
...@@ -428,6 +434,127 @@ static int wm5110_put_dre(struct snd_kcontrol *kcontrol, ...@@ -428,6 +434,127 @@ static int wm5110_put_dre(struct snd_kcontrol *kcontrol,
return ret; return ret;
} }
static int wm5110_in_pga_get(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol)
{
struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec);
struct snd_soc_card *card = dapm->card;
int ret;
/*
* PGA Volume is also used as part of the enable sequence, so
* usage of it should be avoided whilst that is running.
*/
mutex_lock_nested(&card->dapm_mutex, SND_SOC_DAPM_CLASS_RUNTIME);
ret = snd_soc_get_volsw_range(kcontrol, ucontrol);
mutex_unlock(&card->dapm_mutex);
return ret;
}
static int wm5110_in_pga_put(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol)
{
struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec);
struct snd_soc_card *card = dapm->card;
int ret;
/*
* PGA Volume is also used as part of the enable sequence, so
* usage of it should be avoided whilst that is running.
*/
mutex_lock_nested(&card->dapm_mutex, SND_SOC_DAPM_CLASS_RUNTIME);
ret = snd_soc_put_volsw_range(kcontrol, ucontrol);
mutex_unlock(&card->dapm_mutex);
return ret;
}
static int wm5110_in_analog_ev(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 arizona_priv *priv = snd_soc_codec_get_drvdata(codec);
struct wm5110_priv *wm5110 = snd_soc_codec_get_drvdata(codec);
struct arizona *arizona = priv->arizona;
unsigned int reg, mask;
struct reg_sequence analog_seq[] = {
{ 0x80, 0x3 },
{ 0x35d, 0 },
{ 0x80, 0x0 },
};
reg = ARIZONA_IN1L_CONTROL + ((w->shift ^ 0x1) * 4);
mask = ARIZONA_IN1L_PGA_VOL_MASK;
switch (event) {
case SND_SOC_DAPM_WILL_PMU:
wm5110->in_value |= 0x3 << ((w->shift ^ 0x1) * 2);
wm5110->in_pre_pending++;
wm5110->in_post_pending++;
return 0;
case SND_SOC_DAPM_PRE_PMU:
wm5110->in_pga_cache[w->shift] = snd_soc_read(codec, reg);
snd_soc_update_bits(codec, reg, mask,
0x40 << ARIZONA_IN1L_PGA_VOL_SHIFT);
wm5110->in_pre_pending--;
if (wm5110->in_pre_pending == 0) {
analog_seq[1].def = wm5110->in_value;
regmap_multi_reg_write_bypassed(arizona->regmap,
analog_seq,
ARRAY_SIZE(analog_seq));
msleep(55);
wm5110->in_value = 0;
}
break;
case SND_SOC_DAPM_POST_PMU:
snd_soc_update_bits(codec, reg, mask,
wm5110->in_pga_cache[w->shift]);
wm5110->in_post_pending--;
if (wm5110->in_post_pending == 0)
regmap_multi_reg_write_bypassed(arizona->regmap,
analog_seq,
ARRAY_SIZE(analog_seq));
break;
default:
break;
}
return 0;
}
static int wm5110_in_ev(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 arizona_priv *priv = snd_soc_codec_get_drvdata(codec);
struct arizona *arizona = priv->arizona;
switch (arizona->rev) {
case 0 ... 4:
if (arizona_input_analog(codec, w->shift))
wm5110_in_analog_ev(w, kcontrol, event);
break;
default:
break;
}
return arizona_in_ev(w, kcontrol, event);
}
static DECLARE_TLV_DB_SCALE(ana_tlv, 0, 100, 0); static DECLARE_TLV_DB_SCALE(ana_tlv, 0, 100, 0);
static DECLARE_TLV_DB_SCALE(eq_tlv, -1200, 100, 0); static DECLARE_TLV_DB_SCALE(eq_tlv, -1200, 100, 0);
static DECLARE_TLV_DB_SCALE(digital_tlv, -6400, 50, 0); static DECLARE_TLV_DB_SCALE(digital_tlv, -6400, 50, 0);
...@@ -454,18 +581,24 @@ SOC_ENUM("IN2 OSR", arizona_in_dmic_osr[1]), ...@@ -454,18 +581,24 @@ SOC_ENUM("IN2 OSR", arizona_in_dmic_osr[1]),
SOC_ENUM("IN3 OSR", arizona_in_dmic_osr[2]), SOC_ENUM("IN3 OSR", arizona_in_dmic_osr[2]),
SOC_ENUM("IN4 OSR", arizona_in_dmic_osr[3]), SOC_ENUM("IN4 OSR", arizona_in_dmic_osr[3]),
SOC_SINGLE_RANGE_TLV("IN1L Volume", ARIZONA_IN1L_CONTROL, SOC_SINGLE_RANGE_EXT_TLV("IN1L Volume", ARIZONA_IN1L_CONTROL,
ARIZONA_IN1L_PGA_VOL_SHIFT, 0x40, 0x5f, 0, ana_tlv), ARIZONA_IN1L_PGA_VOL_SHIFT, 0x40, 0x5f, 0,
SOC_SINGLE_RANGE_TLV("IN1R Volume", ARIZONA_IN1R_CONTROL, wm5110_in_pga_get, wm5110_in_pga_put, ana_tlv),
ARIZONA_IN1R_PGA_VOL_SHIFT, 0x40, 0x5f, 0, ana_tlv), SOC_SINGLE_RANGE_EXT_TLV("IN1R Volume", ARIZONA_IN1R_CONTROL,
SOC_SINGLE_RANGE_TLV("IN2L Volume", ARIZONA_IN2L_CONTROL, ARIZONA_IN1R_PGA_VOL_SHIFT, 0x40, 0x5f, 0,
ARIZONA_IN2L_PGA_VOL_SHIFT, 0x40, 0x5f, 0, ana_tlv), wm5110_in_pga_get, wm5110_in_pga_put, ana_tlv),
SOC_SINGLE_RANGE_TLV("IN2R Volume", ARIZONA_IN2R_CONTROL, SOC_SINGLE_RANGE_EXT_TLV("IN2L Volume", ARIZONA_IN2L_CONTROL,
ARIZONA_IN2R_PGA_VOL_SHIFT, 0x40, 0x5f, 0, ana_tlv), ARIZONA_IN2L_PGA_VOL_SHIFT, 0x40, 0x5f, 0,
SOC_SINGLE_RANGE_TLV("IN3L Volume", ARIZONA_IN3L_CONTROL, wm5110_in_pga_get, wm5110_in_pga_put, ana_tlv),
ARIZONA_IN3L_PGA_VOL_SHIFT, 0x40, 0x5f, 0, ana_tlv), SOC_SINGLE_RANGE_EXT_TLV("IN2R Volume", ARIZONA_IN2R_CONTROL,
SOC_SINGLE_RANGE_TLV("IN3R Volume", ARIZONA_IN3R_CONTROL, ARIZONA_IN2R_PGA_VOL_SHIFT, 0x40, 0x5f, 0,
ARIZONA_IN3R_PGA_VOL_SHIFT, 0x40, 0x5f, 0, ana_tlv), wm5110_in_pga_get, wm5110_in_pga_put, ana_tlv),
SOC_SINGLE_RANGE_EXT_TLV("IN3L Volume", ARIZONA_IN3L_CONTROL,
ARIZONA_IN3L_PGA_VOL_SHIFT, 0x40, 0x5f, 0,
wm5110_in_pga_get, wm5110_in_pga_put, ana_tlv),
SOC_SINGLE_RANGE_EXT_TLV("IN3R Volume", ARIZONA_IN3R_CONTROL,
ARIZONA_IN3R_PGA_VOL_SHIFT, 0x40, 0x5f, 0,
wm5110_in_pga_get, wm5110_in_pga_put, ana_tlv),
SOC_ENUM("IN HPF Cutoff Frequency", arizona_in_hpf_cut_enum), SOC_ENUM("IN HPF Cutoff Frequency", arizona_in_hpf_cut_enum),
...@@ -896,29 +1029,35 @@ SND_SOC_DAPM_OUTPUT("DRC1 Signal Activity"), ...@@ -896,29 +1029,35 @@ SND_SOC_DAPM_OUTPUT("DRC1 Signal Activity"),
SND_SOC_DAPM_OUTPUT("DRC2 Signal Activity"), SND_SOC_DAPM_OUTPUT("DRC2 Signal Activity"),
SND_SOC_DAPM_PGA_E("IN1L PGA", ARIZONA_INPUT_ENABLES, ARIZONA_IN1L_ENA_SHIFT, SND_SOC_DAPM_PGA_E("IN1L PGA", ARIZONA_INPUT_ENABLES, ARIZONA_IN1L_ENA_SHIFT,
0, NULL, 0, arizona_in_ev, 0, NULL, 0, wm5110_in_ev,
SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD | SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD |
SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU), SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
SND_SOC_DAPM_WILL_PMU),
SND_SOC_DAPM_PGA_E("IN1R PGA", ARIZONA_INPUT_ENABLES, ARIZONA_IN1R_ENA_SHIFT, SND_SOC_DAPM_PGA_E("IN1R PGA", ARIZONA_INPUT_ENABLES, ARIZONA_IN1R_ENA_SHIFT,
0, NULL, 0, arizona_in_ev, 0, NULL, 0, wm5110_in_ev,
SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD | SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD |
SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU), SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
SND_SOC_DAPM_WILL_PMU),
SND_SOC_DAPM_PGA_E("IN2L PGA", ARIZONA_INPUT_ENABLES, ARIZONA_IN2L_ENA_SHIFT, SND_SOC_DAPM_PGA_E("IN2L PGA", ARIZONA_INPUT_ENABLES, ARIZONA_IN2L_ENA_SHIFT,
0, NULL, 0, arizona_in_ev, 0, NULL, 0, wm5110_in_ev,
SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD | SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD |
SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU), SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
SND_SOC_DAPM_WILL_PMU),
SND_SOC_DAPM_PGA_E("IN2R PGA", ARIZONA_INPUT_ENABLES, ARIZONA_IN2R_ENA_SHIFT, SND_SOC_DAPM_PGA_E("IN2R PGA", ARIZONA_INPUT_ENABLES, ARIZONA_IN2R_ENA_SHIFT,
0, NULL, 0, arizona_in_ev, 0, NULL, 0, wm5110_in_ev,
SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD | SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD |
SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU), SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
SND_SOC_DAPM_WILL_PMU),
SND_SOC_DAPM_PGA_E("IN3L PGA", ARIZONA_INPUT_ENABLES, ARIZONA_IN3L_ENA_SHIFT, SND_SOC_DAPM_PGA_E("IN3L PGA", ARIZONA_INPUT_ENABLES, ARIZONA_IN3L_ENA_SHIFT,
0, NULL, 0, arizona_in_ev, 0, NULL, 0, wm5110_in_ev,
SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD | SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD |
SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU), SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
SND_SOC_DAPM_WILL_PMU),
SND_SOC_DAPM_PGA_E("IN3R PGA", ARIZONA_INPUT_ENABLES, ARIZONA_IN3R_ENA_SHIFT, SND_SOC_DAPM_PGA_E("IN3R PGA", ARIZONA_INPUT_ENABLES, ARIZONA_IN3R_ENA_SHIFT,
0, NULL, 0, arizona_in_ev, 0, NULL, 0, wm5110_in_ev,
SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD | SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD |
SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU), SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
SND_SOC_DAPM_WILL_PMU),
SND_SOC_DAPM_PGA_E("IN4L PGA", ARIZONA_INPUT_ENABLES, ARIZONA_IN4L_ENA_SHIFT, SND_SOC_DAPM_PGA_E("IN4L PGA", ARIZONA_INPUT_ENABLES, ARIZONA_IN4L_ENA_SHIFT,
0, NULL, 0, arizona_in_ev, 0, NULL, 0, arizona_in_ev,
SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD | SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD |
......
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