mirror of
https://github.com/torvalds/linux.git
synced 2024-11-26 14:12:06 +00:00
d1e2a97b36
Hi Mark Many ASoC drivers are getting rtd from substream by rtd = substream->private_data OTOH, we have snd_pcm_substream_chip() macro for it. #define snd_pcm_substream_chip(substream) ((substream)->private_data) But, both are not understandable for reader. This patch adds new asoc_substream_to_rtd() which is easy to understand. These are not important, but for readable code. Kuninori Morimoto (29): ASoC: soc-xxx: add asoc_substream_to_rtd() ASoC: ux500: use asoc_substream_to_rtd() ASoC: ti: use asoc_substream_to_rtd() ASoC: tegra: use asoc_substream_to_rtd() ASoC: sunxi: use asoc_substream_to_rtd() ASoC: stm: use asoc_substream_to_rtd() ASoC: sof: use asoc_substream_to_rtd() ASoC: sh: use asoc_substream_to_rtd() ASoC: samsung: use asoc_substream_to_rtd() ASoC: pxa: use asoc_substream_to_rtd() ASoC: cirrus: use asoc_substream_to_rtd() ASoC: rockchip: use asoc_substream_to_rtd() ASoC: amd: use asoc_substream_to_rtd() ASoC: fsl: use asoc_substream_to_rtd() ASoC: mediatek: use asoc_substream_to_rtd() ASoC: atmel: use asoc_substream_to_rtd() ASoC: qcom: use asoc_substream_to_rtd() ASoC: dwc: use asoc_substream_to_rtd() ASoC: intel: use asoc_substream_to_rtd() ASoC: meson: use asoc_substream_to_rtd() ASoC: au1x: use asoc_substream_to_rtd() ASoC: bcm: use asoc_substream_to_rtd() ASoC: codecs: use asoc_substream_to_rtd() ASoC: generic: use asoc_substream_to_rtd() ASoC: sprd: use asoc_substream_to_rtd() ASoC: kirkwood: use asoc_substream_to_rtd() ASoC: xtensa: use asoc_substream_to_rtd() ASoC: mxs: use asoc_substream_to_rtd() ASoC: uniphier: use asoc_substream_to_rtd() include/sound/soc.h | 2 + sound/soc/amd/acp-da7219-max98357a.c | 12 ++-- sound/soc/amd/acp-pcm-dma.c | 2 +- sound/soc/amd/acp-rt5645.c | 2 +- sound/soc/amd/acp3x-rt5682-max9836.c | 8 +-- sound/soc/amd/raven/acp3x-i2s.c | 2 +- sound/soc/amd/raven/acp3x-pcm-dma.c | 6 +- sound/soc/atmel/atmel-classd.c | 8 +-- sound/soc/atmel/atmel-pcm-dma.c | 4 +- sound/soc/atmel/atmel-pcm-pdc.c | 2 +- sound/soc/atmel/atmel-pdmic.c | 10 +-- sound/soc/atmel/atmel_wm8904.c | 2 +- sound/soc/au1x/db1200.c | 2 +- sound/soc/au1x/dbdma2.c | 2 +- sound/soc/au1x/dma.c | 2 +- sound/soc/bcm/bcm63xx-pcm-whistler.c | 12 ++-- sound/soc/bcm/cygnus-pcm.c | 16 ++--- sound/soc/cirrus/edb93xx.c | 2 +- sound/soc/cirrus/snappercl15.c | 2 +- sound/soc/codecs/rt5677-spi.c | 4 +- sound/soc/dwc/dwc-pcm.c | 2 +- sound/soc/fsl/eukrea-tlv320.c | 2 +- sound/soc/fsl/fsl-asoc-card.c | 2 +- sound/soc/fsl/fsl_asrc_dma.c | 4 +- sound/soc/fsl/fsl_dma.c | 2 +- sound/soc/fsl/fsl_spdif.c | 10 +-- sound/soc/fsl/fsl_ssi.c | 8 +-- sound/soc/fsl/imx-audmix.c | 6 +- sound/soc/fsl/imx-mc13783.c | 2 +- sound/soc/fsl/mpc5200_dma.c | 8 +-- sound/soc/fsl/mpc5200_psc_i2s.c | 2 +- sound/soc/fsl/mpc8610_hpcd.c | 2 +- sound/soc/fsl/mx27vis-aic32x4.c | 2 +- sound/soc/fsl/p1022_ds.c | 2 +- sound/soc/fsl/p1022_rdk.c | 2 +- sound/soc/fsl/wm1133-ev1.c | 2 +- sound/soc/generic/simple-card-utils.c | 6 +- sound/soc/intel/atom/sst-mfld-platform-pcm.c | 6 +- sound/soc/intel/baytrail/sst-baytrail-pcm.c | 16 ++--- sound/soc/intel/boards/bdw-rt5650.c | 2 +- sound/soc/intel/boards/bdw-rt5677.c | 4 +- sound/soc/intel/boards/broadwell.c | 2 +- sound/soc/intel/boards/bxt_rt298.c | 2 +- sound/soc/intel/boards/byt-rt5640.c | 2 +- sound/soc/intel/boards/bytcht_da7213.c | 4 +- sound/soc/intel/boards/bytcr_rt5640.c | 2 +- sound/soc/intel/boards/bytcr_rt5651.c | 2 +- sound/soc/intel/boards/cht_bsw_max98090_ti.c | 2 +- sound/soc/intel/boards/cht_bsw_nau8824.c | 2 +- sound/soc/intel/boards/cht_bsw_rt5645.c | 2 +- sound/soc/intel/boards/cht_bsw_rt5672.c | 2 +- sound/soc/intel/boards/cml_rt1011_rt5682.c | 4 +- sound/soc/intel/boards/ehl_rt5660.c | 2 +- sound/soc/intel/boards/glk_rt5682_max98357a.c | 2 +- sound/soc/intel/boards/haswell.c | 2 +- sound/soc/intel/boards/kbl_da7219_max98927.c | 8 +-- sound/soc/intel/boards/kbl_rt5660.c | 2 +- sound/soc/intel/boards/kbl_rt5663_max98927.c | 4 +- .../intel/boards/kbl_rt5663_rt5514_max98927.c | 4 +- .../soc/intel/boards/skl_nau88l25_max98357a.c | 2 +- sound/soc/intel/boards/skl_nau88l25_ssm4567.c | 2 +- sound/soc/intel/boards/skl_rt286.c | 2 +- sound/soc/intel/boards/sof_da7219_max98373.c | 2 +- sound/soc/intel/boards/sof_maxim_common.c | 4 +- sound/soc/intel/boards/sof_pcm512x.c | 4 +- sound/soc/intel/boards/sof_rt5682.c | 4 +- sound/soc/intel/boards/sof_sdw_rt1308.c | 2 +- sound/soc/intel/boards/sof_wm8804.c | 2 +- sound/soc/intel/haswell/sst-haswell-pcm.c | 12 ++-- sound/soc/intel/keembay/kmb_platform.c | 2 +- sound/soc/intel/skylake/skl-pcm.c | 8 +-- sound/soc/kirkwood/armada-370-db.c | 2 +- sound/soc/mediatek/common/mtk-afe-fe-dai.c | 12 ++-- .../mediatek/common/mtk-afe-platform-driver.c | 2 +- sound/soc/mediatek/mt2701/mt2701-afe-pcm.c | 2 +- sound/soc/mediatek/mt2701/mt2701-cs42448.c | 2 +- sound/soc/mediatek/mt2701/mt2701-wm8960.c | 2 +- sound/soc/mediatek/mt6797/mt6797-afe-pcm.c | 4 +- sound/soc/mediatek/mt8173/mt8173-afe-pcm.c | 2 +- sound/soc/mediatek/mt8173/mt8173-max98090.c | 2 +- .../mediatek/mt8173/mt8173-rt5650-rt5514.c | 2 +- .../mediatek/mt8173/mt8173-rt5650-rt5676.c | 2 +- sound/soc/mediatek/mt8173/mt8173-rt5650.c | 2 +- sound/soc/mediatek/mt8183/mt8183-afe-pcm.c | 4 +- .../mediatek/mt8183/mt8183-da7219-max98357.c | 8 +-- .../mt8183/mt8183-mt6358-ts3a227-max98357.c | 12 ++-- sound/soc/meson/axg-card.c | 2 +- sound/soc/meson/gx-card.c | 2 +- sound/soc/meson/meson-card-utils.c | 2 +- sound/soc/meson/meson-codec-glue.c | 2 +- sound/soc/mxs/mxs-sgtl5000.c | 2 +- sound/soc/pxa/brownstone.c | 2 +- sound/soc/pxa/corgi.c | 4 +- sound/soc/pxa/hx4700.c | 2 +- sound/soc/pxa/imote2.c | 2 +- sound/soc/pxa/magician.c | 6 +- sound/soc/pxa/mmp-pcm.c | 2 +- sound/soc/pxa/poodle.c | 4 +- sound/soc/pxa/pxa2xx-i2s.c | 2 +- sound/soc/pxa/spitz.c | 4 +- sound/soc/pxa/tosa.c | 2 +- sound/soc/pxa/z2.c | 2 +- sound/soc/pxa/zylonite.c | 2 +- sound/soc/qcom/apq8096.c | 2 +- sound/soc/qcom/lpass-platform.c | 14 ++--- sound/soc/qcom/qdsp6/q6asm-dai.c | 6 +- sound/soc/qcom/qdsp6/q6routing.c | 2 +- sound/soc/qcom/sdm845.c | 14 ++--- sound/soc/qcom/storm.c | 2 +- sound/soc/rockchip/rk3288_hdmi_analog.c | 2 +- sound/soc/rockchip/rk3399_gru_sound.c | 8 +-- sound/soc/rockchip/rockchip_i2s.c | 2 +- sound/soc/rockchip/rockchip_max98090.c | 2 +- sound/soc/rockchip/rockchip_rt5645.c | 2 +- sound/soc/samsung/aries_wm8994.c | 4 +- sound/soc/samsung/arndale.c | 4 +- sound/soc/samsung/h1940_uda1380.c | 2 +- sound/soc/samsung/i2s.c | 2 +- sound/soc/samsung/jive_wm8750.c | 2 +- sound/soc/samsung/littlemill.c | 2 +- sound/soc/samsung/neo1973_wm8753.c | 8 +-- sound/soc/samsung/odroid.c | 6 +- sound/soc/samsung/pcm.c | 4 +- sound/soc/samsung/rx1950_uda1380.c | 2 +- sound/soc/samsung/s3c-i2s-v2.c | 2 +- sound/soc/samsung/s3c24xx_simtec.c | 2 +- sound/soc/samsung/s3c24xx_uda134x.c | 6 +- sound/soc/samsung/smartq_wm8987.c | 2 +- sound/soc/samsung/smdk_spdif.c | 2 +- sound/soc/samsung/smdk_wm8580.c | 2 +- sound/soc/samsung/smdk_wm8994.c | 2 +- sound/soc/samsung/smdk_wm8994pcm.c | 2 +- sound/soc/samsung/snow.c | 2 +- sound/soc/samsung/spdif.c | 6 +- sound/soc/samsung/tm2_wm5110.c | 8 +-- sound/soc/sh/dma-sh7760.c | 12 ++-- sound/soc/sh/fsi.c | 2 +- sound/soc/sh/migor.c | 4 +- sound/soc/sh/rcar/core.c | 4 +- sound/soc/soc-component.c | 20 +++--- sound/soc/soc-dai.c | 8 +-- sound/soc/soc-dapm.c | 6 +- sound/soc/soc-generic-dmaengine-pcm.c | 4 +- sound/soc/soc-link.c | 12 ++-- sound/soc/soc-pcm.c | 62 +++++++++---------- sound/soc/soc-utils.c | 2 +- sound/soc/sof/intel/hda-dai.c | 10 +-- sound/soc/sof/intel/hda-dsp.c | 2 +- sound/soc/sof/intel/hda-pcm.c | 2 +- sound/soc/sof/pcm.c | 18 +++--- sound/soc/sprd/sprd-pcm-dma.c | 2 +- sound/soc/stm/stm32_adfsdm.c | 12 ++-- sound/soc/stm/stm32_sai_sub.c | 2 +- sound/soc/sunxi/sun4i-codec.c | 12 ++-- sound/soc/sunxi/sun4i-spdif.c | 2 +- sound/soc/tegra/tegra_alc5632.c | 2 +- sound/soc/tegra/tegra_max98090.c | 2 +- sound/soc/tegra/tegra_rt5640.c | 2 +- sound/soc/tegra/tegra_rt5677.c | 2 +- sound/soc/tegra/tegra_sgtl5000.c | 2 +- sound/soc/tegra/tegra_wm8753.c | 2 +- sound/soc/tegra/tegra_wm8903.c | 2 +- sound/soc/tegra/trimslice.c | 2 +- sound/soc/ti/davinci-evm.c | 6 +- sound/soc/ti/davinci-vcif.c | 4 +- sound/soc/ti/j721e-evm.c | 6 +- sound/soc/ti/n810.c | 4 +- sound/soc/ti/omap-abe-twl6040.c | 4 +- sound/soc/ti/omap-mcbsp.c | 4 +- sound/soc/ti/omap-twl4030.c | 2 +- sound/soc/ti/omap3pandora.c | 2 +- sound/soc/ti/osk5912.c | 2 +- sound/soc/ti/rx51.c | 4 +- sound/soc/uniphier/aio-dma.c | 6 +- sound/soc/ux500/mop500_ab8500.c | 8 +-- sound/soc/ux500/ux500_pcm.c | 2 +- sound/soc/xtensa/xtfpga-i2s.c | 2 +- 177 files changed, 397 insertions(+), 395 deletions(-) -- 2.25.1
344 lines
9.6 KiB
C
344 lines
9.6 KiB
C
// SPDX-License-Identifier: GPL-2.0-only
|
|
/*
|
|
* omap-twl4030.c -- SoC audio for TI SoC based boards with twl4030 codec
|
|
*
|
|
* Copyright (C) 2012 Texas Instruments Incorporated - https://www.ti.com
|
|
* All rights reserved.
|
|
*
|
|
* Author: Peter Ujfalusi <peter.ujfalusi@ti.com>
|
|
*
|
|
* This driver replaces the following machine drivers:
|
|
* omap3beagle (Author: Steve Sakoman <steve@sakoman.com>)
|
|
* omap3evm (Author: Anuj Aggarwal <anuj.aggarwal@ti.com>)
|
|
* overo (Author: Steve Sakoman <steve@sakoman.com>)
|
|
* igep0020 (Author: Enric Balletbo i Serra <eballetbo@iseebcn.com>)
|
|
* zoom2 (Author: Misael Lopez Cruz <misael.lopez@ti.com>)
|
|
* sdp3430 (Author: Misael Lopez Cruz <misael.lopez@ti.com>)
|
|
*/
|
|
|
|
#include <linux/platform_device.h>
|
|
#include <linux/platform_data/omap-twl4030.h>
|
|
#include <linux/module.h>
|
|
#include <linux/of.h>
|
|
#include <linux/gpio.h>
|
|
#include <linux/of_gpio.h>
|
|
|
|
#include <sound/core.h>
|
|
#include <sound/pcm.h>
|
|
#include <sound/soc.h>
|
|
#include <sound/jack.h>
|
|
|
|
#include "omap-mcbsp.h"
|
|
|
|
struct omap_twl4030 {
|
|
int jack_detect; /* board can detect jack events */
|
|
struct snd_soc_jack hs_jack;
|
|
};
|
|
|
|
static int omap_twl4030_hw_params(struct snd_pcm_substream *substream,
|
|
struct snd_pcm_hw_params *params)
|
|
{
|
|
struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
|
|
unsigned int fmt;
|
|
|
|
switch (params_channels(params)) {
|
|
case 2: /* Stereo I2S mode */
|
|
fmt = SND_SOC_DAIFMT_I2S |
|
|
SND_SOC_DAIFMT_NB_NF |
|
|
SND_SOC_DAIFMT_CBM_CFM;
|
|
break;
|
|
case 4: /* Four channel TDM mode */
|
|
fmt = SND_SOC_DAIFMT_DSP_A |
|
|
SND_SOC_DAIFMT_IB_NF |
|
|
SND_SOC_DAIFMT_CBM_CFM;
|
|
break;
|
|
default:
|
|
return -EINVAL;
|
|
}
|
|
|
|
return snd_soc_runtime_set_dai_fmt(rtd, fmt);
|
|
}
|
|
|
|
static const struct snd_soc_ops omap_twl4030_ops = {
|
|
.hw_params = omap_twl4030_hw_params,
|
|
};
|
|
|
|
static const struct snd_soc_dapm_widget dapm_widgets[] = {
|
|
SND_SOC_DAPM_SPK("Earpiece Spk", NULL),
|
|
SND_SOC_DAPM_SPK("Handsfree Spk", NULL),
|
|
SND_SOC_DAPM_HP("Headset Stereophone", NULL),
|
|
SND_SOC_DAPM_SPK("Ext Spk", NULL),
|
|
SND_SOC_DAPM_SPK("Carkit Spk", NULL),
|
|
|
|
SND_SOC_DAPM_MIC("Main Mic", NULL),
|
|
SND_SOC_DAPM_MIC("Sub Mic", NULL),
|
|
SND_SOC_DAPM_MIC("Headset Mic", NULL),
|
|
SND_SOC_DAPM_MIC("Carkit Mic", NULL),
|
|
SND_SOC_DAPM_MIC("Digital0 Mic", NULL),
|
|
SND_SOC_DAPM_MIC("Digital1 Mic", NULL),
|
|
SND_SOC_DAPM_LINE("Line In", NULL),
|
|
};
|
|
|
|
static const struct snd_soc_dapm_route audio_map[] = {
|
|
/* Headset Stereophone: HSOL, HSOR */
|
|
{"Headset Stereophone", NULL, "HSOL"},
|
|
{"Headset Stereophone", NULL, "HSOR"},
|
|
/* External Speakers: HFL, HFR */
|
|
{"Handsfree Spk", NULL, "HFL"},
|
|
{"Handsfree Spk", NULL, "HFR"},
|
|
/* External Speakers: PredrivL, PredrivR */
|
|
{"Ext Spk", NULL, "PREDRIVEL"},
|
|
{"Ext Spk", NULL, "PREDRIVER"},
|
|
/* Carkit speakers: CARKITL, CARKITR */
|
|
{"Carkit Spk", NULL, "CARKITL"},
|
|
{"Carkit Spk", NULL, "CARKITR"},
|
|
/* Earpiece */
|
|
{"Earpiece Spk", NULL, "EARPIECE"},
|
|
|
|
/* External Mics: MAINMIC, SUBMIC with bias */
|
|
{"MAINMIC", NULL, "Main Mic"},
|
|
{"Main Mic", NULL, "Mic Bias 1"},
|
|
{"SUBMIC", NULL, "Sub Mic"},
|
|
{"Sub Mic", NULL, "Mic Bias 2"},
|
|
/* Headset Mic: HSMIC with bias */
|
|
{"HSMIC", NULL, "Headset Mic"},
|
|
{"Headset Mic", NULL, "Headset Mic Bias"},
|
|
/* Digital Mics: DIGIMIC0, DIGIMIC1 with bias */
|
|
{"DIGIMIC0", NULL, "Digital0 Mic"},
|
|
{"Digital0 Mic", NULL, "Mic Bias 1"},
|
|
{"DIGIMIC1", NULL, "Digital1 Mic"},
|
|
{"Digital1 Mic", NULL, "Mic Bias 2"},
|
|
/* Carkit In: CARKITMIC */
|
|
{"CARKITMIC", NULL, "Carkit Mic"},
|
|
/* Aux In: AUXL, AUXR */
|
|
{"AUXL", NULL, "Line In"},
|
|
{"AUXR", NULL, "Line In"},
|
|
};
|
|
|
|
/* Headset jack detection DAPM pins */
|
|
static struct snd_soc_jack_pin hs_jack_pins[] = {
|
|
{
|
|
.pin = "Headset Mic",
|
|
.mask = SND_JACK_MICROPHONE,
|
|
},
|
|
{
|
|
.pin = "Headset Stereophone",
|
|
.mask = SND_JACK_HEADPHONE,
|
|
},
|
|
};
|
|
|
|
/* Headset jack detection gpios */
|
|
static struct snd_soc_jack_gpio hs_jack_gpios[] = {
|
|
{
|
|
.name = "hsdet-gpio",
|
|
.report = SND_JACK_HEADSET,
|
|
.debounce_time = 200,
|
|
},
|
|
};
|
|
|
|
static inline void twl4030_disconnect_pin(struct snd_soc_dapm_context *dapm,
|
|
int connected, char *pin)
|
|
{
|
|
if (!connected)
|
|
snd_soc_dapm_disable_pin(dapm, pin);
|
|
}
|
|
|
|
static int omap_twl4030_init(struct snd_soc_pcm_runtime *rtd)
|
|
{
|
|
struct snd_soc_card *card = rtd->card;
|
|
struct snd_soc_dapm_context *dapm = &card->dapm;
|
|
struct omap_tw4030_pdata *pdata = dev_get_platdata(card->dev);
|
|
struct omap_twl4030 *priv = snd_soc_card_get_drvdata(card);
|
|
int ret = 0;
|
|
|
|
/* Headset jack detection only if it is supported */
|
|
if (priv->jack_detect > 0) {
|
|
hs_jack_gpios[0].gpio = priv->jack_detect;
|
|
|
|
ret = snd_soc_card_jack_new(rtd->card, "Headset Jack",
|
|
SND_JACK_HEADSET, &priv->hs_jack,
|
|
hs_jack_pins,
|
|
ARRAY_SIZE(hs_jack_pins));
|
|
if (ret)
|
|
return ret;
|
|
|
|
ret = snd_soc_jack_add_gpios(&priv->hs_jack,
|
|
ARRAY_SIZE(hs_jack_gpios),
|
|
hs_jack_gpios);
|
|
if (ret)
|
|
return ret;
|
|
}
|
|
|
|
/*
|
|
* NULL pdata means we booted with DT. In this case the routing is
|
|
* provided and the card is fully routed, no need to mark pins.
|
|
*/
|
|
if (!pdata || !pdata->custom_routing)
|
|
return ret;
|
|
|
|
/* Disable not connected paths if not used */
|
|
twl4030_disconnect_pin(dapm, pdata->has_ear, "Earpiece Spk");
|
|
twl4030_disconnect_pin(dapm, pdata->has_hf, "Handsfree Spk");
|
|
twl4030_disconnect_pin(dapm, pdata->has_hs, "Headset Stereophone");
|
|
twl4030_disconnect_pin(dapm, pdata->has_predriv, "Ext Spk");
|
|
twl4030_disconnect_pin(dapm, pdata->has_carkit, "Carkit Spk");
|
|
|
|
twl4030_disconnect_pin(dapm, pdata->has_mainmic, "Main Mic");
|
|
twl4030_disconnect_pin(dapm, pdata->has_submic, "Sub Mic");
|
|
twl4030_disconnect_pin(dapm, pdata->has_hsmic, "Headset Mic");
|
|
twl4030_disconnect_pin(dapm, pdata->has_carkitmic, "Carkit Mic");
|
|
twl4030_disconnect_pin(dapm, pdata->has_digimic0, "Digital0 Mic");
|
|
twl4030_disconnect_pin(dapm, pdata->has_digimic1, "Digital1 Mic");
|
|
twl4030_disconnect_pin(dapm, pdata->has_linein, "Line In");
|
|
|
|
return ret;
|
|
}
|
|
|
|
/* Digital audio interface glue - connects codec <--> CPU */
|
|
SND_SOC_DAILINK_DEFS(hifi,
|
|
DAILINK_COMP_ARRAY(COMP_CPU("omap-mcbsp.2")),
|
|
DAILINK_COMP_ARRAY(COMP_CODEC("twl4030-codec", "twl4030-hifi")),
|
|
DAILINK_COMP_ARRAY(COMP_PLATFORM("omap-mcbsp.2")));
|
|
|
|
SND_SOC_DAILINK_DEFS(voice,
|
|
DAILINK_COMP_ARRAY(COMP_CPU("omap-mcbsp.3")),
|
|
DAILINK_COMP_ARRAY(COMP_CODEC("twl4030-codec", "twl4030-voice")),
|
|
DAILINK_COMP_ARRAY(COMP_PLATFORM("omap-mcbsp.3")));
|
|
|
|
static struct snd_soc_dai_link omap_twl4030_dai_links[] = {
|
|
{
|
|
.name = "TWL4030 HiFi",
|
|
.stream_name = "TWL4030 HiFi",
|
|
.init = omap_twl4030_init,
|
|
.ops = &omap_twl4030_ops,
|
|
SND_SOC_DAILINK_REG(hifi),
|
|
},
|
|
{
|
|
.name = "TWL4030 Voice",
|
|
.stream_name = "TWL4030 Voice",
|
|
.dai_fmt = SND_SOC_DAIFMT_DSP_A | SND_SOC_DAIFMT_IB_NF |
|
|
SND_SOC_DAIFMT_CBM_CFM,
|
|
SND_SOC_DAILINK_REG(voice),
|
|
},
|
|
};
|
|
|
|
/* Audio machine driver */
|
|
static struct snd_soc_card omap_twl4030_card = {
|
|
.owner = THIS_MODULE,
|
|
.dai_link = omap_twl4030_dai_links,
|
|
.num_links = ARRAY_SIZE(omap_twl4030_dai_links),
|
|
|
|
.dapm_widgets = dapm_widgets,
|
|
.num_dapm_widgets = ARRAY_SIZE(dapm_widgets),
|
|
.dapm_routes = audio_map,
|
|
.num_dapm_routes = ARRAY_SIZE(audio_map),
|
|
};
|
|
|
|
static int omap_twl4030_probe(struct platform_device *pdev)
|
|
{
|
|
struct omap_tw4030_pdata *pdata = dev_get_platdata(&pdev->dev);
|
|
struct device_node *node = pdev->dev.of_node;
|
|
struct snd_soc_card *card = &omap_twl4030_card;
|
|
struct omap_twl4030 *priv;
|
|
int ret = 0;
|
|
|
|
card->dev = &pdev->dev;
|
|
|
|
priv = devm_kzalloc(&pdev->dev, sizeof(struct omap_twl4030), GFP_KERNEL);
|
|
if (priv == NULL)
|
|
return -ENOMEM;
|
|
|
|
if (node) {
|
|
struct device_node *dai_node;
|
|
struct property *prop;
|
|
|
|
if (snd_soc_of_parse_card_name(card, "ti,model")) {
|
|
dev_err(&pdev->dev, "Card name is not provided\n");
|
|
return -ENODEV;
|
|
}
|
|
|
|
dai_node = of_parse_phandle(node, "ti,mcbsp", 0);
|
|
if (!dai_node) {
|
|
dev_err(&pdev->dev, "McBSP node is not provided\n");
|
|
return -EINVAL;
|
|
}
|
|
omap_twl4030_dai_links[0].cpus->dai_name = NULL;
|
|
omap_twl4030_dai_links[0].cpus->of_node = dai_node;
|
|
|
|
omap_twl4030_dai_links[0].platforms->name = NULL;
|
|
omap_twl4030_dai_links[0].platforms->of_node = dai_node;
|
|
|
|
dai_node = of_parse_phandle(node, "ti,mcbsp-voice", 0);
|
|
if (!dai_node) {
|
|
card->num_links = 1;
|
|
} else {
|
|
omap_twl4030_dai_links[1].cpus->dai_name = NULL;
|
|
omap_twl4030_dai_links[1].cpus->of_node = dai_node;
|
|
|
|
omap_twl4030_dai_links[1].platforms->name = NULL;
|
|
omap_twl4030_dai_links[1].platforms->of_node = dai_node;
|
|
}
|
|
|
|
priv->jack_detect = of_get_named_gpio(node,
|
|
"ti,jack-det-gpio", 0);
|
|
|
|
/* Optional: audio routing can be provided */
|
|
prop = of_find_property(node, "ti,audio-routing", NULL);
|
|
if (prop) {
|
|
ret = snd_soc_of_parse_audio_routing(card,
|
|
"ti,audio-routing");
|
|
if (ret)
|
|
return ret;
|
|
|
|
card->fully_routed = 1;
|
|
}
|
|
} else if (pdata) {
|
|
if (pdata->card_name) {
|
|
card->name = pdata->card_name;
|
|
} else {
|
|
dev_err(&pdev->dev, "Card name is not provided\n");
|
|
return -ENODEV;
|
|
}
|
|
|
|
if (!pdata->voice_connected)
|
|
card->num_links = 1;
|
|
|
|
priv->jack_detect = pdata->jack_detect;
|
|
} else {
|
|
dev_err(&pdev->dev, "Missing pdata\n");
|
|
return -ENODEV;
|
|
}
|
|
|
|
snd_soc_card_set_drvdata(card, priv);
|
|
ret = devm_snd_soc_register_card(&pdev->dev, card);
|
|
if (ret) {
|
|
dev_err(&pdev->dev, "devm_snd_soc_register_card() failed: %d\n",
|
|
ret);
|
|
return ret;
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
|
|
static const struct of_device_id omap_twl4030_of_match[] = {
|
|
{.compatible = "ti,omap-twl4030", },
|
|
{ },
|
|
};
|
|
MODULE_DEVICE_TABLE(of, omap_twl4030_of_match);
|
|
|
|
static struct platform_driver omap_twl4030_driver = {
|
|
.driver = {
|
|
.name = "omap-twl4030",
|
|
.pm = &snd_soc_pm_ops,
|
|
.of_match_table = omap_twl4030_of_match,
|
|
},
|
|
.probe = omap_twl4030_probe,
|
|
};
|
|
|
|
module_platform_driver(omap_twl4030_driver);
|
|
|
|
MODULE_AUTHOR("Peter Ujfalusi <peter.ujfalusi@ti.com>");
|
|
MODULE_DESCRIPTION("ALSA SoC for TI SoC based boards with twl4030 codec");
|
|
MODULE_LICENSE("GPL");
|
|
MODULE_ALIAS("platform:omap-twl4030");
|