Commit 97e15b1f authored by Liam Girdwood's avatar Liam Girdwood

Merge remote branch 'broonie-asoc/for-2.6.37' into for-2.6.37

parents a8165e0e 38fec727
......@@ -789,13 +789,14 @@ static struct snd_soc_dai_driver atmel_ssc_dai[NUM_SSC_DEVICES] = {
static __devinit int asoc_ssc_probe(struct platform_device *pdev)
{
return snd_soc_register_dais(&pdev->dev, atmel_ssc_dai,
ARRAY_SIZE(atmel_ssc_dai));
BUG_ON(pdev->id < 0);
BUG_ON(pdev->id >= ARRAY_SIZE(atmel_ssc_dai));
return snd_soc_register_dai(&pdev->dev, &atmel_ssc_dai[pdev->id]);
}
static int __devexit asoc_ssc_remove(struct platform_device *pdev)
{
snd_soc_unregister_dais(&pdev->dev, ARRAY_SIZE(atmel_ssc_dai));
snd_soc_unregister_dai(&pdev->dev);
return 0;
}
......@@ -809,6 +810,56 @@ static struct platform_driver asoc_ssc_driver = {
.remove = __devexit_p(asoc_ssc_remove),
};
/**
* atmel_ssc_set_audio - Allocate the specified SSC for audio use.
*/
int atmel_ssc_set_audio(int ssc_id)
{
struct ssc_device *ssc;
static struct platform_device *dma_pdev;
struct platform_device *ssc_pdev;
int ret;
if (ssc_id < 0 || ssc_id >= ARRAY_SIZE(atmel_ssc_dai))
return -EINVAL;
/* Allocate a dummy device for DMA if we don't have one already */
if (!dma_pdev) {
dma_pdev = platform_device_alloc("atmel-pcm-audio", -1);
if (!dma_pdev)
return -ENOMEM;
ret = platform_device_add(dma_pdev);
if (ret < 0) {
platform_device_put(dma_pdev);
dma_pdev = NULL;
return ret;
}
}
ssc_pdev = platform_device_alloc("atmel-ssc-dai", ssc_id);
if (!ssc_pdev) {
ssc_free(ssc);
return -ENOMEM;
}
/* If we can grab the SSC briefly to parent the DAI device off it */
ssc = ssc_request(ssc_id);
if (IS_ERR(ssc))
pr_warn("Unable to parent ASoC SSC DAI on SSC: %ld\n",
PTR_ERR(ssc));
else
ssc_pdev->dev.parent = &(ssc->pdev->dev);
ssc_free(ssc);
ret = platform_device_add(ssc_pdev);
if (ret < 0)
platform_device_put(ssc_pdev);
return ret;
}
EXPORT_SYMBOL_GPL(atmel_ssc_set_audio);
static int __init snd_atmel_ssc_init(void)
{
return platform_driver_register(&asoc_ssc_driver);
......
......@@ -117,4 +117,6 @@ struct atmel_ssc_info {
struct atmel_ssc_state ssc_state;
};
int atmel_ssc_set_audio(int ssc);
#endif /* _AT91_SSC_DAI_H */
......@@ -146,7 +146,7 @@ static int at91sam9g20ek_wm8731_init(struct snd_soc_pcm_runtime *rtd)
"at91sam9g20ek_wm8731 "
": at91sam9g20ek_wm8731_init() called\n");
ret = snd_soc_dai_set_sysclk(codec_dai, WM8731_SYSCLK,
ret = snd_soc_dai_set_sysclk(codec_dai, WM8731_SYSCLK_XTAL,
MCLK_RATE, SND_SOC_CLOCK_IN);
if (ret < 0) {
printk(KERN_ERR "Failed to set WM8731 SYSCLK: %d\n", ret);
......@@ -183,8 +183,8 @@ static struct snd_soc_dai_link at91sam9g20ek_dai = {
.cpu_dai_name = "atmel-ssc-dai.0",
.codec_dai_name = "wm8731-hifi",
.init = at91sam9g20ek_wm8731_init,
.platform_name = "atmel_pcm-audio",
.codec_name = "wm8731-codec.0-001a",
.platform_name = "atmel-pcm-audio",
.codec_name = "wm8731-codec.0-001b",
.ops = &at91sam9g20ek_ops,
};
......@@ -205,6 +205,12 @@ static int __init at91sam9g20ek_init(void)
if (!(machine_is_at91sam9g20ek() || machine_is_at91sam9g20ek_2mmc()))
return -ENODEV;
ret = atmel_ssc_set_audio(0);
if (ret != 0) {
pr_err("Failed to set SSC 0 for audio: %d\n", ret);
return ret;
}
/*
* Codec MCLK is supplied by PCK0 - set it up.
*/
......
......@@ -49,7 +49,7 @@ static int db1200_i2s_startup(struct snd_pcm_substream *substream)
int ret;
/* WM8731 has its own 12MHz crystal */
snd_soc_dai_set_sysclk(codec_dai, WM8731_SYSCLK,
snd_soc_dai_set_sysclk(codec_dai, WM8731_SYSCLK_XTAL,
12000000, SND_SOC_CLOCK_IN);
/* codec is bitclock and lrclk master */
......
This diff is collapsed.
/*
* 88pm860x-codec.h -- 88PM860x ALSA SoC Audio Driver
*
* Copyright 2010 Marvell International Ltd.
* Haojian Zhuang <haojian.zhuang@marvell.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*/
#ifndef __88PM860X_H
#define __88PM860X_H
/* The offset of these registers are 0xb0 */
#define PM860X_PCM_IFACE_1 0x00
#define PM860X_PCM_IFACE_2 0x01
#define PM860X_PCM_IFACE_3 0x02
#define PM860X_PCM_RATE 0x03
#define PM860X_EC_PATH 0x04
#define PM860X_SIDETONE_L_GAIN 0x05
#define PM860X_SIDETONE_R_GAIN 0x06
#define PM860X_SIDETONE_SHIFT 0x07
#define PM860X_ADC_OFFSET_1 0x08
#define PM860X_ADC_OFFSET_2 0x09
#define PM860X_DMIC_DELAY 0x0a
#define PM860X_I2S_IFACE_1 0x0b
#define PM860X_I2S_IFACE_2 0x0c
#define PM860X_I2S_IFACE_3 0x0d
#define PM860X_I2S_IFACE_4 0x0e
#define PM860X_EQUALIZER_N0_1 0x0f
#define PM860X_EQUALIZER_N0_2 0x10
#define PM860X_EQUALIZER_N1_1 0x11
#define PM860X_EQUALIZER_N1_2 0x12
#define PM860X_EQUALIZER_D1_1 0x13
#define PM860X_EQUALIZER_D1_2 0x14
#define PM860X_LOFI_GAIN_LEFT 0x15
#define PM860X_LOFI_GAIN_RIGHT 0x16
#define PM860X_HIFIL_GAIN_LEFT 0x17
#define PM860X_HIFIL_GAIN_RIGHT 0x18
#define PM860X_HIFIR_GAIN_LEFT 0x19
#define PM860X_HIFIR_GAIN_RIGHT 0x1a
#define PM860X_DAC_OFFSET 0x1b
#define PM860X_OFFSET_LEFT_1 0x1c
#define PM860X_OFFSET_LEFT_2 0x1d
#define PM860X_OFFSET_RIGHT_1 0x1e
#define PM860X_OFFSET_RIGHT_2 0x1f
#define PM860X_ADC_ANA_1 0x20
#define PM860X_ADC_ANA_2 0x21
#define PM860X_ADC_ANA_3 0x22
#define PM860X_ADC_ANA_4 0x23
#define PM860X_ANA_TO_ANA 0x24
#define PM860X_HS1_CTRL 0x25
#define PM860X_HS2_CTRL 0x26
#define PM860X_LO1_CTRL 0x27
#define PM860X_LO2_CTRL 0x28
#define PM860X_EAR_CTRL_1 0x29
#define PM860X_EAR_CTRL_2 0x2a
#define PM860X_AUDIO_SUPPLIES_1 0x2b
#define PM860X_AUDIO_SUPPLIES_2 0x2c
#define PM860X_ADC_EN_1 0x2d
#define PM860X_ADC_EN_2 0x2e
#define PM860X_DAC_EN_1 0x2f
#define PM860X_DAC_EN_2 0x31
#define PM860X_AUDIO_CAL_1 0x32
#define PM860X_AUDIO_CAL_2 0x33
#define PM860X_AUDIO_CAL_3 0x34
#define PM860X_AUDIO_CAL_4 0x35
#define PM860X_AUDIO_CAL_5 0x36
#define PM860X_ANA_INPUT_SEL_1 0x37
#define PM860X_ANA_INPUT_SEL_2 0x38
#define PM860X_PCM_IFACE_4 0x39
#define PM860X_I2S_IFACE_5 0x3a
#define PM860X_SHORTS 0x3b
#define PM860X_PLL_ADJ_1 0x3c
#define PM860X_PLL_ADJ_2 0x3d
/* bits definition */
#define PM860X_CLK_DIR_IN 0
#define PM860X_CLK_DIR_OUT 1
#define PM860X_DET_HEADSET (1 << 0)
#define PM860X_DET_MIC (1 << 1)
#define PM860X_DET_HOOK (1 << 2)
#define PM860X_SHORT_HEADSET (1 << 3)
#define PM860X_SHORT_LINEOUT (1 << 4)
#define PM860X_DET_MASK 0x1F
extern int pm860x_hs_jack_detect(struct snd_soc_codec *, struct snd_soc_jack *,
int, int, int, int);
extern int pm860x_mic_jack_detect(struct snd_soc_codec *, struct snd_soc_jack *,
int);
#endif /* __88PM860X_H */
......@@ -10,6 +10,7 @@ config SND_SOC_I2C_AND_SPI
config SND_SOC_ALL_CODECS
tristate "Build all ASoC CODEC drivers"
select SND_SOC_88PM860X if MFD_88PM860X
select SND_SOC_L3
select SND_SOC_AC97_CODEC if SND_SOC_AC97_BUS
select SND_SOC_AD1836 if SPI_MASTER
......@@ -85,6 +86,9 @@ config SND_SOC_ALL_CODECS
If unsure select "N".
config SND_SOC_88PM860X
tristate
config SND_SOC_WM_HUBS
tristate
default y if SND_SOC_WM8993=y || SND_SOC_WM8994=y
......
snd-soc-88pm860x-objs := 88pm860x-codec.o
snd-soc-ac97-objs := ac97.o
snd-soc-ad1836-objs := ad1836.o
snd-soc-ad193x-objs := ad193x.o
......@@ -67,6 +68,7 @@ snd-soc-tpa6130a2-objs := tpa6130a2.o
snd-soc-wm2000-objs := wm2000.o
snd-soc-wm9090-objs := wm9090.o
obj-$(CONFIG_SND_SOC_88PM860X) += snd-soc-88pm860x.o
obj-$(CONFIG_SND_SOC_AC97_CODEC) += snd-soc-ac97.o
obj-$(CONFIG_SND_SOC_AD1836) += snd-soc-ad1836.o
obj-$(CONFIG_SND_SOC_AD193X) += snd-soc-ad193x.o
......
......@@ -318,7 +318,7 @@ EXPORT_SYMBOL_GPL(v253_ops);
*/
static struct snd_soc_dai_driver cx20442_dai = {
.name = "cx20442-hifi",
.name = "cx20442-voice",
.playback = {
.stream_name = "Playback",
.channels_min = 1,
......
......@@ -12,11 +12,11 @@
*
* Notes:
* The AIC3X is a driver for a low power stereo audio
* codecs aic31, aic32, aic33.
* codecs aic31, aic32, aic33, aic3007.
*
* It supports full aic33 codec functionality.
* The compatibility with aic32, aic31 is as follows:
* aic32 | aic31
* The compatibility with aic32, aic31 and aic3007 is as follows:
* aic32/aic3007 | aic31
* ---------------------------------------
* MONO_LOUT -> N/A | MONO_LOUT -> N/A
* | IN1L -> LINE1L
......@@ -70,6 +70,10 @@ struct aic3x_priv {
unsigned int sysclk;
int master;
int gpio_reset;
#define AIC3X_MODEL_3X 0
#define AIC3X_MODEL_33 1
#define AIC3X_MODEL_3007 2
u16 model;
};
/*
......@@ -361,6 +365,14 @@ static const struct snd_kcontrol_new aic3x_snd_controls[] = {
SOC_ENUM("ADC HPF Cut-off", aic3x_enum[ADC_HPF_ENUM]),
};
/*
* Class-D amplifier gain. From 0 to 18 dB in 6 dB steps
*/
static DECLARE_TLV_DB_SCALE(classd_amp_tlv, 0, 600, 0);
static const struct snd_kcontrol_new aic3x_classd_amp_gain_ctrl =
SOC_DOUBLE_TLV("Class-D Amplifier Gain", CLASSD_CTRL, 6, 4, 3, 0, classd_amp_tlv);
/* Left DAC Mux */
static const struct snd_kcontrol_new aic3x_left_dac_mux_controls =
SOC_DAPM_ENUM("Route", aic3x_enum[LDAC_ENUM]);
......@@ -589,6 +601,15 @@ static const struct snd_soc_dapm_widget aic3x_dapm_widgets[] = {
SND_SOC_DAPM_INPUT("LINE2R"),
};
static const struct snd_soc_dapm_widget aic3007_dapm_widgets[] = {
/* Class-D outputs */
SND_SOC_DAPM_PGA("Left Class-D Out", CLASSD_CTRL, 3, 0, NULL, 0),
SND_SOC_DAPM_PGA("Right Class-D Out", CLASSD_CTRL, 2, 0, NULL, 0),
SND_SOC_DAPM_OUTPUT("SPOP"),
SND_SOC_DAPM_OUTPUT("SPOM"),
};
static const struct snd_soc_dapm_route intercon[] = {
/* Left Output */
{"Left DAC Mux", "DAC_L1", "Left DAC"},
......@@ -759,14 +780,30 @@ static const struct snd_soc_dapm_route intercon[] = {
{"GPIO1 dmic modclk", NULL, "DMic Rate 32"},
};
static const struct snd_soc_dapm_route intercon_3007[] = {
/* Class-D outputs */
{"Left Class-D Out", NULL, "Left Line Out"},
{"Right Class-D Out", NULL, "Left Line Out"},
{"SPOP", NULL, "Left Class-D Out"},
{"SPOM", NULL, "Right Class-D Out"},
};
static int aic3x_add_widgets(struct snd_soc_codec *codec)
{
struct aic3x_priv *aic3x = snd_soc_codec_get_drvdata(codec);
snd_soc_dapm_new_controls(codec, aic3x_dapm_widgets,
ARRAY_SIZE(aic3x_dapm_widgets));
/* set up audio path interconnects */
snd_soc_dapm_add_routes(codec, intercon, ARRAY_SIZE(intercon));
if (aic3x->model == AIC3X_MODEL_3007) {
snd_soc_dapm_new_controls(codec, aic3007_dapm_widgets,
ARRAY_SIZE(aic3007_dapm_widgets));
snd_soc_dapm_add_routes(codec, intercon_3007, ARRAY_SIZE(intercon_3007));
}
return 0;
}
......@@ -1117,6 +1154,7 @@ static struct snd_soc_dai_driver aic3x_dai = {
.rates = AIC3X_RATES,
.formats = AIC3X_FORMATS,},
.ops = &aic3x_dai_ops,
.symmetric_rates = 1,
};
static int aic3x_suspend(struct snd_soc_codec *codec, pm_message_t state)
......@@ -1150,6 +1188,7 @@ static int aic3x_resume(struct snd_soc_codec *codec)
*/
static int aic3x_init(struct snd_soc_codec *codec)
{
struct aic3x_priv *aic3x = snd_soc_codec_get_drvdata(codec);
int reg;
aic3x_write(codec, AIC3X_PAGE_SELECT, PAGE0_SELECT);
......@@ -1218,6 +1257,17 @@ static int aic3x_init(struct snd_soc_codec *codec)
aic3x_write(codec, LINE2L_2_MONOLOPM_VOL, DEFAULT_VOL);
aic3x_write(codec, LINE2R_2_MONOLOPM_VOL, DEFAULT_VOL);
if (aic3x->model == AIC3X_MODEL_3007) {
/* Class-D speaker driver init; datasheet p. 46 */
aic3x_write(codec, AIC3X_PAGE_SELECT, 0x0D);
aic3x_write(codec, 0xD, 0x0D);
aic3x_write(codec, 0x8, 0x5C);
aic3x_write(codec, 0x8, 0x5D);
aic3x_write(codec, 0x8, 0x5C);
aic3x_write(codec, AIC3X_PAGE_SELECT, 0x00);
aic3x_write(codec, CLASSD_CTRL, 0);
}
/* off, with power on */
aic3x_set_bias_level(codec, SND_SOC_BIAS_STANDBY);
......@@ -1243,6 +1293,8 @@ static int aic3x_probe(struct snd_soc_codec *codec)
snd_soc_add_controls(codec, aic3x_snd_controls,
ARRAY_SIZE(aic3x_snd_controls));
if (aic3x->model == AIC3X_MODEL_3007)
snd_soc_add_controls(codec, &aic3x_classd_amp_gain_ctrl, 1);
aic3x_add_widgets(codec);
......@@ -1274,6 +1326,14 @@ static struct snd_soc_codec_driver soc_codec_dev_aic3x = {
* 0x18, 0x19, 0x1A, 0x1B
*/
static const struct i2c_device_id aic3x_i2c_id[] = {
[AIC3X_MODEL_3X] = { "tlv320aic3x", 0 },
[AIC3X_MODEL_33] = { "tlv320aic33", 0 },
[AIC3X_MODEL_3007] = { "tlv320aic3007", 0 },
{ }
};
MODULE_DEVICE_TABLE(i2c, aic3x_i2c_id);
/*
* If the i2c layer weren't so broken, we could pass this kind of data
* around
......@@ -1285,6 +1345,7 @@ static int aic3x_i2c_probe(struct i2c_client *i2c,
struct aic3x_setup_data *setup = pdata->setup;
struct aic3x_priv *aic3x;
int ret, i;
const struct i2c_device_id *tbl;
aic3x = kzalloc(sizeof(struct aic3x_priv), GFP_KERNEL);
if (aic3x == NULL) {
......@@ -1305,6 +1366,12 @@ static int aic3x_i2c_probe(struct i2c_client *i2c,
gpio_direction_output(aic3x->gpio_reset, 0);
}
for (tbl = aic3x_i2c_id; tbl->name[0]; tbl++) {
if (!strcmp(tbl->name, id->name))
break;
}
aic3x->model = tbl - aic3x_i2c_id;
for (i = 0; i < ARRAY_SIZE(aic3x->supplies); i++)
aic3x->supplies[i].supply = aic3x_supply_names[i];
......@@ -1359,13 +1426,6 @@ static int aic3x_i2c_remove(struct i2c_client *client)
return 0;
}
static const struct i2c_device_id aic3x_i2c_id[] = {
{ "tlv320aic3x", 0 },
{ "tlv320aic33", 0 },
{ }
};
MODULE_DEVICE_TABLE(i2c, aic3x_i2c_id);
/* machine i2c codec control layer */
static struct i2c_driver aic3x_i2c_driver = {
.driver = {
......
......@@ -111,6 +111,8 @@
#define DACL1_2_MONOLOPM_VOL 75
#define DACR1_2_MONOLOPM_VOL 78
#define MONOLOPM_CTRL 79
/* Class-D speaker driver on tlv320aic3007 */
#define CLASSD_CTRL 73
/* Line Output Plus/Minus control registers */
#define LINE2L_2_LLOPM_VOL 80
#define LINE2L_2_RLOPM_VOL 87
......
......@@ -46,6 +46,7 @@ struct wm8731_priv {
struct regulator_bulk_data supplies[WM8731_NUM_SUPPLIES];
u16 reg_cache[WM8731_CACHEREGNUM];
unsigned int sysclk;
int sysclk_type;
};
......@@ -110,6 +111,7 @@ static const struct snd_kcontrol_new wm8731_input_mux_controls =
SOC_DAPM_ENUM("Input Select", wm8731_enum[0]);
static const struct snd_soc_dapm_widget wm8731_dapm_widgets[] = {
SND_SOC_DAPM_SUPPLY("OSC", WM8731_PWR, 5, 1, NULL, 0),
SND_SOC_DAPM_MIXER("Output Mixer", WM8731_PWR, 4, 1,
&wm8731_output_mixer_controls[0],
ARRAY_SIZE(wm8731_output_mixer_controls)),
......@@ -127,7 +129,18 @@ SND_SOC_DAPM_INPUT("RLINEIN"),
SND_SOC_DAPM_INPUT("LLINEIN"),
};
static int wm8731_check_osc(struct snd_soc_dapm_widget *source,
struct snd_soc_dapm_widget *sink)
{
struct wm8731_priv *wm8731 = snd_soc_codec_get_drvdata(source->codec);
return wm8731->sysclk_type == WM8731_SYSCLK_MCLK;
}
static const struct snd_soc_dapm_route intercon[] = {
{"DAC", NULL, "OSC", wm8731_check_osc},
{"ADC", NULL, "OSC", wm8731_check_osc},
/* output mixer */
{"Output Mixer", "Line Bypass Switch", "Line Input"},
{"Output Mixer", "HiFi Playback Switch", "DAC"},
......@@ -285,6 +298,15 @@ static int wm8731_set_dai_sysclk(struct snd_soc_dai *codec_dai,
struct snd_soc_codec *codec = codec_dai->codec;
struct wm8731_priv *wm8731 = snd_soc_codec_get_drvdata(codec);
switch (clk_id) {
case WM8731_SYSCLK_XTAL:
case WM8731_SYSCLK_MCLK:
wm8731->sysclk_type = clk_id;
break;
default:
return -EINVAL;
}
switch (freq) {
case 11289600:
case 12000000:
......@@ -292,9 +314,14 @@ static int wm8731_set_dai_sysclk(struct snd_soc_dai *codec_dai,
case 16934400:
case 18432000:
wm8731->sysclk = freq;
return 0;
}
break;
default:
return -EINVAL;
}
snd_soc_dapm_sync(codec);
return 0;
}
......
......@@ -31,7 +31,9 @@
#define WM8731_CACHEREGNUM 10
#define WM8731_SYSCLK 0
#define WM8731_SYSCLK_XTAL 1
#define WM8731_SYSCLK_MCLK 2
#define WM8731_DAI 0
#endif
config SND_MPC52xx_DMA
tristate
# ASoC platform support for the Freescale MPC8610 SOC. This compiles drivers
# for the SSI and the Elo DMA controller. You will still need to select
# a platform driver and a codec driver.
config SND_SOC_MPC8610
# ASoC platform support for the Freescale PowerPC SOCs that have an SSI and
# an Elo DMA controller, such as the MPC8610 and P1022. You will still need to
# select a platform driver and a codec driver.
config SND_SOC_POWERPC_SSI
tristate
depends on MPC8610
depends on FSL_SOC
config SND_SOC_MPC8610_HPCD
tristate "ALSA SoC support for the Freescale MPC8610 HPCD board"
# I2C is necessary for the CS4270 driver
depends on MPC8610_HPCD && I2C
select SND_SOC_MPC8610
select SND_SOC_POWERPC_SSI
select SND_SOC_CS4270
select SND_SOC_CS4270_VD33_ERRATA
default y if MPC8610_HPCD
help
Say Y if you want to enable audio on the Freescale MPC8610 HPCD.
config SND_SOC_P1022_DS
tristate "ALSA SoC support for the Freescale P1022 DS board"
# I2C is necessary for the WM8776 driver
depends on P1022_DS && I2C
select SND_SOC_POWERPC_SSI
select SND_SOC_WM8776
default y if P1022_DS
help
Say Y if you want to enable audio on the Freescale P1022 DS board.
This will also include the Wolfson Microelectronics WM8776 codec
driver.
config SND_SOC_MPC5200_I2S
tristate "Freescale MPC5200 PSC in I2S mode driver"
depends on PPC_MPC52xx && PPC_BESTCOMM
......
......@@ -2,10 +2,14 @@
snd-soc-mpc8610-hpcd-objs := mpc8610_hpcd.o
obj-$(CONFIG_SND_SOC_MPC8610_HPCD) += snd-soc-mpc8610-hpcd.o
# MPC8610 Platform Support
# P1022 DS Machine Support
snd-soc-p1022-ds-objs := p1022_ds.o
obj-$(CONFIG_SND_SOC_P1022_DS) += snd-soc-p1022-ds.o
# Freescale PowerPC SSI/DMA Platform Support
snd-soc-fsl-ssi-objs := fsl_ssi.o
snd-soc-fsl-dma-objs := fsl_dma.o
obj-$(CONFIG_SND_SOC_MPC8610) += snd-soc-fsl-ssi.o snd-soc-fsl-dma.o
obj-$(CONFIG_SND_SOC_POWERPC_SSI) += snd-soc-fsl-ssi.o snd-soc-fsl-dma.o
# MPC5200 Platform Support
obj-$(CONFIG_SND_MPC52xx_DMA) += mpc5200_dma.o
......
......@@ -23,6 +23,7 @@
#include <linux/gfp.h>
#include <linux/of_platform.h>
#include <linux/list.h>
#include <linux/slab.h>
#include <sound/core.h>
#include <sound/pcm.h>
......@@ -305,22 +306,30 @@ static int fsl_dma_new(struct snd_card *card, struct snd_soc_dai *dai,
if (!card->dev->coherent_dma_mask)
card->dev->coherent_dma_mask = fsl_dma_dmamask;
/* Some codecs have separate DAIs for playback and capture, so we
* should allocate a DMA buffer only for the streams that are valid.
*/
if (dai->driver->playback.channels_min) {
ret = snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, card->dev,
fsl_dma_hardware.buffer_bytes_max,
&pcm->streams[0].substream->dma_buffer);
if (ret) {
dev_err(card->dev, "can't allocate playback dma buffer\n");
dev_err(card->dev, "can't alloc playback dma buffer\n");
return ret;
}
}
if (dai->driver->capture.channels_min) {
ret = snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, card->dev,
fsl_dma_hardware.buffer_bytes_max,
&pcm->streams[1].substream->dma_buffer);
if (ret) {
snd_dma_free_pages(&pcm->streams[0].substream->dma_buffer);
dev_err(card->dev, "can't allocate capture dma buffer\n");
dev_err(card->dev, "can't alloc capture dma buffer\n");
return ret;
}
}
return 0;
}
......@@ -887,11 +896,11 @@ static struct snd_pcm_ops fsl_dma_ops = {
.pointer = fsl_dma_pointer,
};
static int __devinit fsl_soc_dma_probe(struct of_device *of_dev,
static int __devinit fsl_soc_dma_probe(struct platform_device *pdev,
const struct of_device_id *match)
{
struct dma_object *dma;
struct device_node *np = of_dev->dev.of_node;
struct device_node *np = pdev->dev.of_node;
struct device_node *ssi_np;
struct resource res;
const uint32_t *iprop;
......@@ -900,13 +909,13 @@ static int __devinit fsl_soc_dma_probe(struct of_device *of_dev,
/* Find the SSI node that points to us. */
ssi_np = find_ssi_node(np);
if (!ssi_np) {
dev_err(&of_dev->dev, "cannot find parent SSI node\n");
dev_err(&pdev->dev, "cannot find parent SSI node\n");
return -ENODEV;
}
ret = of_address_to_resource(ssi_np, 0, &res);
if (ret) {
dev_err(&of_dev->dev, "could not determine resources for %s\n",
dev_err(&pdev->dev, "could not determine resources for %s\n",
ssi_np->full_name);
of_node_put(ssi_np);
return ret;
......@@ -914,7 +923,7 @@ static int __devinit fsl_soc_dma_probe(struct of_device *of_dev,
dma = kzalloc(sizeof(*dma) + strlen(np->full_name), GFP_KERNEL);
if (!dma) {
dev_err(&of_dev->dev, "could not allocate dma object\n");
dev_err(&pdev->dev, "could not allocate dma object\n");
of_node_put(ssi_np);
return -ENOMEM;
}
......@@ -937,9 +946,9 @@ static int __devinit fsl_soc_dma_probe(struct of_device *of_dev,
of_node_put(ssi_np);
ret = snd_soc_register_platform(&of_dev->dev, &dma->dai);
ret = snd_soc_register_platform(&pdev->dev, &dma->dai);
if (ret) {
dev_err(&of_dev->dev, "could not register platform\n");
dev_err(&pdev->dev, "could not register platform\n");
kfree(dma);
return ret;
}
......@@ -947,16 +956,16 @@ static int __devinit fsl_soc_dma_probe(struct of_device *of_dev,
dma->channel = of_iomap(np, 0);
dma->irq = irq_of_parse_and_map(np, 0);
dev_set_drvdata(&of_dev->dev, dma);
dev_set_drvdata(&pdev->dev, dma);
return 0;
}
static int __devexit fsl_soc_dma_remove(struct of_device *of_dev)
static int __devexit fsl_soc_dma_remove(struct platform_device *pdev)
{
struct dma_object *dma = dev_get_drvdata(&of_dev->dev);
struct dma_object *dma = dev_get_drvdata(&pdev->dev);
snd_soc_unregister_platform(&of_dev->dev);
snd_soc_unregister_platform(&pdev->dev);
iounmap(dma->channel);
irq_dispose_mapping(dma->irq);
kfree(dma);
......
......@@ -624,13 +624,13 @@ static void make_lowercase(char *s)
}
}
static int __devinit fsl_ssi_probe(struct of_device *of_dev,
static int __devinit fsl_ssi_probe(struct platform_device *pdev,
const struct of_device_id *match)
{
struct fsl_ssi_private *ssi_private;
int ret = 0;
struct device_attribute *dev_attr = NULL;
struct device_node *np = of_dev->dev.of_node;
struct device_node *np = pdev->dev.of_node;
const char *p, *sprop;
const uint32_t *iprop;
struct resource res;
......@@ -645,14 +645,14 @@ static int __devinit fsl_ssi_probe(struct of_device *of_dev,
/* Check for a codec-handle property. */
if (!of_get_property(np, "codec-handle", NULL)) {
dev_err(&of_dev->dev, "missing codec-handle property\n");
dev_err(&pdev->dev, "missing codec-handle property\n");
return -ENODEV;
}
/* We only support the SSI in "I2S Slave" mode */
sprop = of_get_property(np, "fsl,mode", NULL);
if (!sprop || strcmp(sprop, "i2s-slave")) {
dev_notice(&of_dev->dev, "mode %s is unsupported\n", sprop);
dev_notice(&pdev->dev, "mode %s is unsupported\n", sprop);
return -ENODEV;
}
......@@ -661,7 +661,7 @@ static int __devinit fsl_ssi_probe(struct of_device *of_dev,
ssi_private = kzalloc(sizeof(struct fsl_ssi_private) + strlen(p),
GFP_KERNEL);
if (!ssi_private) {
dev_err(&of_dev->dev, "could not allocate DAI object\n");
dev_err(&pdev->dev, "could not allocate DAI object\n");
return -ENOMEM;
}
......@@ -675,7 +675,7 @@ static int __devinit fsl_ssi_probe(struct of_device *of_dev,
/* Get the addresses and IRQ */
ret = of_address_to_resource(np, 0, &res);
if (ret) {
dev_err(&of_dev->dev, "could not determine device resources\n");
dev_err(&pdev->dev, "could not determine device resources\n");
kfree(ssi_private);
return ret;
}
......@@ -703,19 +703,19 @@ static int __devinit fsl_ssi_probe(struct of_device *of_dev,
dev_attr->attr.mode = S_IRUGO;
dev_attr->show = fsl_sysfs_ssi_show;
ret = device_create_file(&of_dev->dev, dev_attr);
ret = device_create_file(&pdev->dev, dev_attr);
if (ret) {
dev_err(&of_dev->dev, "could not create sysfs %s file\n",
dev_err(&pdev->dev, "could not create sysfs %s file\n",
ssi_private->dev_attr.attr.name);
goto error;
}
/* Register with ASoC */
dev_set_drvdata(&of_dev->dev, ssi_private);
dev_set_drvdata(&pdev->dev, ssi_private);
ret = snd_soc_register_dai(&of_dev->dev, &ssi_private->cpu_dai_drv);
ret = snd_soc_register_dai(&pdev->dev, &ssi_private->cpu_dai_drv);
if (ret) {
dev_err(&of_dev->dev, "failed to register DAI: %d\n", ret);
dev_err(&pdev->dev, "failed to register DAI: %d\n", ret);
goto error;
}
......@@ -733,20 +733,20 @@ static int __devinit fsl_ssi_probe(struct of_device *of_dev,
make_lowercase(name);
ssi_private->pdev =
platform_device_register_data(&of_dev->dev, name, 0, NULL, 0);
platform_device_register_data(&pdev->dev, name, 0, NULL, 0);
if (IS_ERR(ssi_private->pdev)) {
ret = PTR_ERR(ssi_private->pdev);
dev_err(&of_dev->dev, "failed to register platform: %d\n", ret);
dev_err(&pdev->dev, "failed to register platform: %d\n", ret);
goto error;
}
return 0;
error:
snd_soc_unregister_dai(&of_dev->dev);
dev_set_drvdata(&of_dev->dev, NULL);
snd_soc_unregister_dai(&pdev->dev);
dev_set_drvdata(&pdev->dev, NULL);
if (dev_attr)
device_remove_file(&of_dev->dev, dev_attr);
device_remove_file(&pdev->dev, dev_attr);
irq_dispose_mapping(ssi_private->irq);
iounmap(ssi_private->ssi);
kfree(ssi_private);
......@@ -754,16 +754,16 @@ static int __devinit fsl_ssi_probe(struct of_device *of_dev,
return ret;
}
static int fsl_ssi_remove(struct of_device *of_dev)
static int fsl_ssi_remove(struct platform_device *pdev)
{
struct fsl_ssi_private *ssi_private = dev_get_drvdata(&of_dev->dev);
struct fsl_ssi_private *ssi_private = dev_get_drvdata(&pdev->dev);
platform_device_unregister(ssi_private->pdev);
snd_soc_unregister_dai(&of_dev->dev);
device_remove_file(&of_dev->dev, &ssi_private->dev_attr);
snd_soc_unregister_dai(&pdev->dev);
device_remove_file(&pdev->dev, &ssi_private->dev_attr);
kfree(ssi_private);
dev_set_drvdata(&of_dev->dev, NULL);
dev_set_drvdata(&pdev->dev, NULL);
return 0;
}
......
......@@ -13,6 +13,7 @@
#include <linux/module.h>
#include <linux/interrupt.h>
#include <linux/of_device.h>
#include <linux/slab.h>
#include <sound/soc.h>
#include <asm/fsl_guts.h>
......@@ -323,9 +324,10 @@ static int get_dma_channel(struct device_node *ssi_np,
static int mpc8610_hpcd_probe(struct platform_device *pdev)
{
struct device *dev = pdev->dev.parent;
/* of_dev is the OF device for the SSI node that probed us */
struct of_device *of_dev = container_of(dev, struct of_device, dev);
struct device_node *np = of_dev->dev.of_node;
/* ssi_pdev is the platform device for the SSI node that probed us */
struct platform_device *ssi_pdev =
container_of(dev, struct platform_device, dev);
struct device_node *np = ssi_pdev->dev.of_node;
struct device_node *codec_np = NULL;
struct platform_device *sound_device = NULL;
struct mpc8610_hpcd_data *machine_data;
......@@ -348,7 +350,7 @@ static int mpc8610_hpcd_probe(struct platform_device *pdev)
if (!machine_data)
return -ENOMEM;
machine_data->dai[0].cpu_dai_name = dev_name(&of_dev->dev);
machine_data->dai[0].cpu_dai_name = dev_name(&ssi_pdev->dev);
machine_data->dai[0].ops = &mpc8610_hpcd_ops;
/* Determine the codec name, it will be used as the codec DAI name */
......
This diff is collapsed.
......@@ -584,7 +584,7 @@ static struct snd_soc_dai_link ams_delta_dai_link = {
.name = "CX20442",
.stream_name = "CX20442",
.cpu_dai_name ="omap-mcbsp-dai.0",
.codec_dai_name = "cx20442-hifi",
.codec_dai_name = "cx20442-voice",
.init = ams_delta_cx20442_init,
.platform_name = "omap-pcm-audio",
.codec_name = "cx20442-codec",
......
......@@ -117,6 +117,24 @@ config SND_PXA2XX_SOC_PALM27X
Say Y if you want to add support for SoC audio on
Palm T|X, T5, E2 or LifeDrive handheld computer.
config SND_SOC_SAARB
tristate "SoC Audio support for Marvell Saarb"
depends on SND_PXA2XX_SOC && MACH_SAARB
select SND_PXA_SOC_SSP
select SND_SOC_88PM860X
help
Say Y if you want to add support for SoC audio on the
Marvell Saarb reference platform.
config SND_SOC_TAVOREVB3
tristate "SoC Audio support for Marvell Tavor EVB3"
depends on SND_PXA2XX_SOC && MACH_TAVOREVB3
select SND_PXA_SOC_SSP
select SND_SOC_88PM860X
help
Say Y if you want to add support for SoC audio on the
Marvell Saarb reference platform.
config SND_SOC_ZYLONITE
tristate "SoC Audio support for Marvell Zylonite"
depends on SND_PXA2XX_SOC && MACH_ZYLONITE
......
......@@ -19,6 +19,8 @@ snd-soc-e800-objs := e800_wm9712.o
snd-soc-spitz-objs := spitz.o
snd-soc-em-x270-objs := em-x270.o
snd-soc-palm27x-objs := palm27x.o
snd-soc-saarb-objs := saarb.o
snd-soc-tavorevb3-objs := tavorevb3.o
snd-soc-zylonite-objs := zylonite.o
snd-soc-magician-objs := magician.o
snd-soc-mioa701-objs := mioa701_wm9713.o
......@@ -38,6 +40,8 @@ obj-$(CONFIG_SND_PXA2XX_SOC_PALM27X) += snd-soc-palm27x.o
obj-$(CONFIG_SND_PXA2XX_SOC_MAGICIAN) += snd-soc-magician.o
obj-$(CONFIG_SND_PXA2XX_SOC_MIOA701) += snd-soc-mioa701.o
obj-$(CONFIG_SND_PXA2XX_SOC_Z2) += snd-soc-z2.o
obj-$(CONFIG_SND_SOC_SAARB) += snd-soc-saarb.o
obj-$(CONFIG_SND_SOC_TAVOREVB3) += snd-soc-tavorevb3.o
obj-$(CONFIG_SND_SOC_ZYLONITE) += snd-soc-zylonite.o
obj-$(CONFIG_SND_PXA2XX_SOC_IMOTE2) += snd-soc-imote2.o
obj-$(CONFIG_SND_SOC_RAUMFELD) += snd-soc-raumfeld.o
......@@ -149,7 +149,7 @@ static int corgi_hw_params(struct snd_pcm_substream *substream,
return ret;
/* set the codec system clock for DAC and ADC */
ret = snd_soc_dai_set_sysclk(codec_dai, WM8731_SYSCLK, clk,
ret = snd_soc_dai_set_sysclk(codec_dai, WM8731_SYSCLK_XTAL, clk,
SND_SOC_CLOCK_IN);
if (ret < 0)
return ret;
......
......@@ -198,6 +198,9 @@ static int __init e740_init(void)
static void __exit e740_exit(void)
{
platform_device_unregister(e740_snd_device);
gpio_free(GPIO_E740_WM9705_nAVDD2);
gpio_free(GPIO_E740_AMP_ON);
gpio_free(GPIO_E740_MIC_ON);
}
module_init(e740_init);
......
......@@ -128,7 +128,7 @@ static int poodle_hw_params(struct snd_pcm_substream *substream,
return ret;
/* set the codec system clock for DAC and ADC */
ret = snd_soc_dai_set_sysclk(codec_dai, WM8731_SYSCLK, clk,
ret = snd_soc_dai_set_sysclk(codec_dai, WM8731_SYSCLK_XTAL, clk,
SND_SOC_CLOCK_IN);
if (ret < 0)
return ret;
......
......@@ -24,7 +24,6 @@
#include <mach/dma.h>
#include <mach/audio.h>
#include "pxa2xx-pcm.h"
#include "pxa2xx-ac97.h"
static void pxa2xx_ac97_warm_reset(struct snd_ac97 *ac97)
......
/*
* saarb.c -- SoC audio for saarb
*
* Copyright (C) 2010 Marvell International Ltd.
* Haojian Zhuang <haojian.zhuang@marvell.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*/
#include <linux/module.h>
#include <linux/moduleparam.h>
#include <linux/device.h>
#include <linux/clk.h>
#include <linux/i2c.h>
#include <sound/core.h>
#include <sound/pcm.h>
#include <sound/pcm_params.h>
#include <sound/soc.h>
#include <sound/soc-dapm.h>
#include <sound/jack.h>
#include <asm/mach-types.h>
#include "../codecs/88pm860x-codec.h"
#include "pxa-ssp.h"
static int saarb_pm860x_init(struct snd_soc_pcm_runtime *rtd);
static struct platform_device *saarb_snd_device;
static struct snd_soc_jack hs_jack, mic_jack;
static struct snd_soc_jack_pin hs_jack_pins[] = {
{ .pin = "Headset Stereophone", .mask = SND_JACK_HEADPHONE, },
};
static struct snd_soc_jack_pin mic_jack_pins[] = {
{ .pin = "Headset Mic 2", .mask = SND_JACK_MICROPHONE, },
};
/* saarb machine dapm widgets */
static const struct snd_soc_dapm_widget saarb_dapm_widgets[] = {
SND_SOC_DAPM_HP("Headphone Stereophone", NULL),
SND_SOC_DAPM_LINE("Lineout Out 1", NULL),
SND_SOC_DAPM_LINE("Lineout Out 2", NULL),
SND_SOC_DAPM_SPK("Ext Speaker", NULL),
SND_SOC_DAPM_MIC("Ext Mic 1", NULL),
SND_SOC_DAPM_MIC("Headset Mic", NULL),
SND_SOC_DAPM_MIC("Ext Mic 3", NULL),
};
/* saarb machine audio map */
static const struct snd_soc_dapm_route audio_map[] = {
{"Headset Stereophone", NULL, "HS1"},
{"Headset Stereophone", NULL, "HS2"},
{"Ext Speaker", NULL, "LSP"},
{"Ext Speaker", NULL, "LSN"},
{"Lineout Out 1", NULL, "LINEOUT1"},
{"Lineout Out 2", NULL, "LINEOUT2"},
{"MIC1P", NULL, "Mic1 Bias"},
{"MIC1N", NULL, "Mic1 Bias"},
{"Mic1 Bias", NULL, "Ext Mic 1"},
{"MIC2P", NULL, "Mic1 Bias"},
{"MIC2N", NULL, "Mic1 Bias"},
{"Mic1 Bias", NULL, "Headset Mic 2"},
{"MIC3P", NULL, "Mic3 Bias"},
{"MIC3N", NULL, "Mic3 Bias"},
{"Mic3 Bias", NULL, "Ext Mic 3"},
};
static int saarb_i2s_hw_params(struct snd_pcm_substream *substream,
struct snd_pcm_hw_params *params)
{
struct snd_soc_pcm_runtime *rtd = substream->private_data;
struct snd_soc_dai *codec_dai = rtd->codec_dai;
struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
int width = snd_pcm_format_physical_width(params_format(params));
int ret;
ret = snd_soc_dai_set_sysclk(cpu_dai, PXA_SSP_CLK_NET_PLL, 0,
PM860X_CLK_DIR_OUT);
if (ret < 0)
return ret;
ret = snd_soc_dai_set_sysclk(codec_dai, 0, 0, PM860X_CLK_DIR_OUT);
if (ret < 0)
return ret;
ret = snd_soc_dai_set_fmt(cpu_dai, SND_SOC_DAIFMT_I2S |
SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBM_CFM);
if (ret < 0)
return ret;
ret = snd_soc_dai_set_fmt(codec_dai, SND_SOC_DAIFMT_I2S |
SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBM_CFM);
if (ret < 0)
return ret;
ret = snd_soc_dai_set_tdm_slot(cpu_dai, 3, 3, 2, width);
return ret;
}
static struct snd_soc_ops saarb_i2s_ops = {
.hw_params = saarb_i2s_hw_params,
};
static struct snd_soc_dai_link saarb_dai[] = {
{
.name = "88PM860x I2S",
.stream_name = "I2S Audio",
.cpu_dai_name = "pxa-ssp-dai.1",
.codec_dai_name = "88pm860x-i2s",
.platform_name = "pxa-pcm-audio",
.codec_name = "88pm860x-codec",
.init = saarb_pm860x_init,
.ops = &saarb_i2s_ops,
},
};
static struct snd_soc_card snd_soc_card_saarb = {
.name = "Saarb",
.dai_link = saarb_dai,
.num_links = ARRAY_SIZE(saarb_dai),
};
static int saarb_pm860x_init(struct snd_soc_pcm_runtime *rtd)
{
struct snd_soc_codec *codec = rtd->codec;
int ret;
snd_soc_dapm_new_controls(codec, saarb_dapm_widgets,
ARRAY_SIZE(saarb_dapm_widgets));
snd_soc_dapm_add_routes(codec, audio_map, ARRAY_SIZE(audio_map));
/* connected pins */
snd_soc_dapm_enable_pin(codec, "Ext Speaker");
snd_soc_dapm_enable_pin(codec, "Ext Mic 1");
snd_soc_dapm_enable_pin(codec, "Ext Mic 3");
snd_soc_dapm_disable_pin(codec, "Headset Mic 2");
snd_soc_dapm_disable_pin(codec, "Headset Stereophone");
ret = snd_soc_dapm_sync(codec);
if (ret)
return ret;
/* Headset jack detection */
snd_soc_jack_new(codec, "Headphone Jack", SND_JACK_HEADPHONE
| SND_JACK_BTN_0 | SND_JACK_BTN_1 | SND_JACK_BTN_2,
&hs_jack);
snd_soc_jack_add_pins(&hs_jack, ARRAY_SIZE(hs_jack_pins),
hs_jack_pins);
snd_soc_jack_new(codec, "Microphone Jack", SND_JACK_MICROPHONE,
&mic_jack);
snd_soc_jack_add_pins(&mic_jack, ARRAY_SIZE(mic_jack_pins),
mic_jack_pins);
/* headphone, microphone detection & headset short detection */
pm860x_hs_jack_detect(codec, &hs_jack, SND_JACK_HEADPHONE,
SND_JACK_BTN_0, SND_JACK_BTN_1, SND_JACK_BTN_2);
pm860x_mic_jack_detect(codec, &hs_jack, SND_JACK_MICROPHONE);
return 0;
}
static int __init saarb_init(void)
{
int ret;
if (!machine_is_saarb())
return -ENODEV;
saarb_snd_device = platform_device_alloc("soc-audio", -1);
if (!saarb_snd_device)
return -ENOMEM;
platform_set_drvdata(saarb_snd_device, &snd_soc_card_saarb);
ret = platform_device_add(saarb_snd_device);
if (ret)
platform_device_put(saarb_snd_device);
return ret;
}
static void __exit saarb_exit(void)
{
platform_device_unregister(saarb_snd_device);
}
module_init(saarb_init);
module_exit(saarb_exit);
MODULE_AUTHOR("Haojian Zhuang <haojian.zhuang@marvell.com>");
MODULE_DESCRIPTION("ALSA SoC 88PM860x Saarb");
MODULE_LICENSE("GPL");
/*
* tavorevb3.c -- SoC audio for Tavor EVB3
*
* Copyright (C) 2010 Marvell International Ltd.
* Haojian Zhuang <haojian.zhuang@marvell.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*/
#include <linux/module.h>
#include <linux/moduleparam.h>
#include <linux/device.h>
#include <linux/clk.h>
#include <linux/i2c.h>
#include <sound/core.h>
#include <sound/pcm.h>
#include <sound/pcm_params.h>
#include <sound/soc.h>
#include <sound/soc-dapm.h>
#include <sound/jack.h>
#include <asm/mach-types.h>
#include "../codecs/88pm860x-codec.h"
#include "pxa-ssp.h"
static int evb3_pm860x_init(struct snd_soc_pcm_runtime *rtd);
static struct platform_device *evb3_snd_device;
static struct snd_soc_jack hs_jack, mic_jack;
static struct snd_soc_jack_pin hs_jack_pins[] = {
{ .pin = "Headset Stereophone", .mask = SND_JACK_HEADPHONE, },
};
static struct snd_soc_jack_pin mic_jack_pins[] = {
{ .pin = "Headset Mic 2", .mask = SND_JACK_MICROPHONE, },
};
/* tavorevb3 machine dapm widgets */
static const struct snd_soc_dapm_widget evb3_dapm_widgets[] = {
SND_SOC_DAPM_HP("Headset Stereophone", NULL),
SND_SOC_DAPM_LINE("Lineout Out 1", NULL),
SND_SOC_DAPM_LINE("Lineout Out 2", NULL),
SND_SOC_DAPM_SPK("Ext Speaker", NULL),
SND_SOC_DAPM_MIC("Ext Mic 1", NULL),
SND_SOC_DAPM_MIC("Headset Mic 2", NULL),
SND_SOC_DAPM_MIC("Ext Mic 3", NULL),
};
/* tavorevb3 machine audio map */
static const struct snd_soc_dapm_route audio_map[] = {
{"Headset Stereophone", NULL, "HS1"},
{"Headset Stereophone", NULL, "HS2"},
{"Ext Speaker", NULL, "LSP"},
{"Ext Speaker", NULL, "LSN"},
{"Lineout Out 1", NULL, "LINEOUT1"},
{"Lineout Out 2", NULL, "LINEOUT2"},
{"MIC1P", NULL, "Mic1 Bias"},
{"MIC1N", NULL, "Mic1 Bias"},
{"Mic1 Bias", NULL, "Ext Mic 1"},
{"MIC2P", NULL, "Mic1 Bias"},
{"MIC2N", NULL, "Mic1 Bias"},
{"Mic1 Bias", NULL, "Headset Mic 2"},
{"MIC3P", NULL, "Mic3 Bias"},
{"MIC3N", NULL, "Mic3 Bias"},
{"Mic3 Bias", NULL, "Ext Mic 3"},
};
static int evb3_i2s_hw_params(struct snd_pcm_substream *substream,
struct snd_pcm_hw_params *params)
{
struct snd_soc_pcm_runtime *rtd = substream->private_data;
struct snd_soc_dai *codec_dai = rtd->codec_dai;
struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
int width = snd_pcm_format_physical_width(params_format(params));
int ret;
ret = snd_soc_dai_set_sysclk(cpu_dai, PXA_SSP_CLK_NET_PLL, 0,
PM860X_CLK_DIR_OUT);
if (ret < 0)
return ret;
ret = snd_soc_dai_set_sysclk(codec_dai, 0, 0, PM860X_CLK_DIR_OUT);
if (ret < 0)
return ret;
ret = snd_soc_dai_set_fmt(cpu_dai, SND_SOC_DAIFMT_I2S |
SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBM_CFM);
if (ret < 0)
return ret;
ret = snd_soc_dai_set_fmt(codec_dai, SND_SOC_DAIFMT_I2S |
SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBM_CFM);
if (ret < 0)
return ret;
ret = snd_soc_dai_set_tdm_slot(cpu_dai, 3, 3, 2, width);
return ret;
}
static struct snd_soc_ops evb3_i2s_ops = {
.hw_params = evb3_i2s_hw_params,
};
static struct snd_soc_dai_link evb3_dai[] = {
{
.name = "88PM860x I2S",
.stream_name = "I2S Audio",
.cpu_dai_name = "pxa-ssp-dai.1",
.codec_dai_name = "88pm860x-i2s",
.platform_name = "pxa-pcm-audio",
.codec_name = "88pm860x-codec",
.init = evb3_pm860x_init,
.ops = &evb3_i2s_ops,
},
};
static struct snd_soc_card snd_soc_card_evb3 = {
.name = "Tavor EVB3",
.dai_link = evb3_dai,
.num_links = ARRAY_SIZE(evb3_dai),
};
static int evb3_pm860x_init(struct snd_soc_pcm_runtime *rtd)
{
struct snd_soc_codec *codec = rtd->codec;
int ret;
snd_soc_dapm_new_controls(codec, evb3_dapm_widgets,
ARRAY_SIZE(evb3_dapm_widgets));
snd_soc_dapm_add_routes(codec, audio_map, ARRAY_SIZE(audio_map));
/* connected pins */
snd_soc_dapm_enable_pin(codec, "Ext Speaker");
snd_soc_dapm_enable_pin(codec, "Ext Mic 1");
snd_soc_dapm_enable_pin(codec, "Ext Mic 3");
snd_soc_dapm_disable_pin(codec, "Headset Mic 2");
snd_soc_dapm_disable_pin(codec, "Headset Stereophone");
ret = snd_soc_dapm_sync(codec);
if (ret)
return ret;
/* Headset jack detection */
snd_soc_jack_new(codec, "Headphone Jack", SND_JACK_HEADPHONE
| SND_JACK_BTN_0 | SND_JACK_BTN_1 | SND_JACK_BTN_2,
&hs_jack);
snd_soc_jack_add_pins(&hs_jack, ARRAY_SIZE(hs_jack_pins),
hs_jack_pins);
snd_soc_jack_new(codec, "Microphone Jack", SND_JACK_MICROPHONE,
&mic_jack);
snd_soc_jack_add_pins(&mic_jack, ARRAY_SIZE(mic_jack_pins),
mic_jack_pins);
/* headphone, microphone detection & headset short detection */
pm860x_hs_jack_detect(codec, &hs_jack, SND_JACK_HEADPHONE,
SND_JACK_BTN_0, SND_JACK_BTN_1, SND_JACK_BTN_2);
pm860x_mic_jack_detect(codec, &hs_jack, SND_JACK_MICROPHONE);
return 0;
}
static int __init tavorevb3_init(void)
{
int ret;
if (!machine_is_tavorevb3())
return -ENODEV;
evb3_snd_device = platform_device_alloc("soc-audio", -1);
if (!evb3_snd_device)
return -ENOMEM;
platform_set_drvdata(evb3_snd_device, &snd_soc_card_evb3);
ret = platform_device_add(evb3_snd_device);
if (ret)
platform_device_put(evb3_snd_device);
return ret;
}
static void __exit tavorevb3_exit(void)
{
platform_device_unregister(evb3_snd_device);
}
module_init(tavorevb3_init);
module_exit(tavorevb3_exit);
MODULE_AUTHOR("Haojian Zhuang <haojian.zhuang@marvell.com>");
MODULE_DESCRIPTION("ALSA SoC 88PM860x Tavor EVB3");
MODULE_LICENSE("GPL");
......@@ -3122,10 +3122,12 @@ int snd_soc_register_codec(struct device *dev,
fixup_codec_formats(&dai_drv[i].capture);
}
/* register DAIs */
/* register any DAIs */
if (num_dai) {
ret = snd_soc_register_dais(dev, dai_drv, num_dai);
if (ret < 0)
goto error;
}
mutex_lock(&client_mutex);
list_add(&codec->list, &codec_list);
......@@ -3164,6 +3166,7 @@ void snd_soc_unregister_codec(struct device *dev)
return;
found:
if (codec->num_dai)
for (i = 0; i < codec->num_dai; i++)
snd_soc_unregister_dai(dev);
......
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