mirror of
https://github.com/torvalds/linux
synced 2024-11-05 18:23:50 +00:00
a23d7f4a7c
Hi Mark Now, CPU/Codec DAI(s) were replaced by rtd->dais. Thus, We don't need rtd->cpu/codec_dai{s} anymore. This pathset replaces it by new macro. Kuninori Morimoto (36): ASoC: soc-core: add asoc_rtd_to_cpu/codec() macro ASoC: amd: use asoc_rtd_to_cpu() / asoc_rtd_to_codec() macro for DAI pointer ASoC: atmel: use asoc_rtd_to_cpu() / asoc_rtd_to_codec() macro for DAI pointer ASoC: au1x: use asoc_rtd_to_cpu() / asoc_rtd_to_codec() macro for DAI pointer ASoC: bcm: use asoc_rtd_to_cpu() / asoc_rtd_to_codec() macro for DAI pointer ASoC: cirrus: use asoc_rtd_to_cpu() / asoc_rtd_to_codec() macro for DAI pointer ASoC: dwc: use asoc_rtd_to_cpu() / asoc_rtd_to_codec() macro for DAI pointer ASoC: fsl: use asoc_rtd_to_cpu() / asoc_rtd_to_codec() macro for DAI pointer ASoC: generic: use asoc_rtd_to_cpu() / asoc_rtd_to_codec() macro for DAI pointer ASoC: img: use asoc_rtd_to_cpu() / asoc_rtd_to_codec() macro for DAI pointer ASoC: intel: use asoc_rtd_to_cpu() / asoc_rtd_to_codec() macro for DAI pointer ASoC: kirkwood: use asoc_rtd_to_cpu() / asoc_rtd_to_codec() macro for DAI pointer ASoC: mediatek: use asoc_rtd_to_cpu() / asoc_rtd_to_codec() macro for DAI pointer ASoC: meson: use asoc_rtd_to_cpu() / asoc_rtd_to_codec() macro for DAI pointer ASoC: mxs: use asoc_rtd_to_cpu() / asoc_rtd_to_codec() macro for DAI pointer ASoC: pxa: use asoc_rtd_to_cpu() / asoc_rtd_to_codec() macro for DAI pointer ASoC: qcom: use asoc_rtd_to_cpu() / asoc_rtd_to_codec() macro for DAI pointer ASoC: rockchip: use asoc_rtd_to_cpu() / asoc_rtd_to_codec() macro for DAI pointer ASoC: samsung: use asoc_rtd_to_cpu() / asoc_rtd_to_codec() macro for DAI pointer ASoC: sh: use asoc_rtd_to_cpu() / asoc_rtd_to_codec() macro for DAI pointer ASoC: sof: use asoc_rtd_to_cpu() / asoc_rtd_to_codec() macro for DAI pointer ASoC: sprd: use asoc_rtd_to_cpu() / asoc_rtd_to_codec() macro for DAI pointer ASoC: stm: use asoc_rtd_to_cpu() / asoc_rtd_to_codec() macro for DAI pointer ASoC: sunxi: use asoc_rtd_to_cpu() / asoc_rtd_to_codec() macro for DAI pointer ASoC: tegra: use asoc_rtd_to_cpu() / asoc_rtd_to_codec() macro for DAI pointer ASoC: ti: use asoc_rtd_to_cpu() / asoc_rtd_to_codec() macro for DAI pointer ASoC: txx9: use asoc_rtd_to_cpu() / asoc_rtd_to_codec() macro for DAI pointer ASoC: uniphier: use asoc_rtd_to_cpu() / asoc_rtd_to_codec() macro for DAI pointer ASoC: ux500: use asoc_rtd_to_cpu() / asoc_rtd_to_codec() macro for DAI pointer ASoC: xtensa: use asoc_rtd_to_cpu() / asoc_rtd_to_codec() macro for DAI pointer ASoC: arm: use asoc_rtd_to_cpu() / asoc_rtd_to_codec() macro for DAI pointer ASoC: codecs: use asoc_rtd_to_cpu() / asoc_rtd_to_codec() macro for DAI pointer ASoC: soc: use asoc_rtd_to_cpu() / asoc_rtd_to_codec() macro for DAI pointer ASoC: soc-core: set rtd->num_cpu/codec at soc_new_pcm_runtime() ASoC: soc-core: tidyup soc_new_pcm_runtime() rtd setups ASoC: soc-core: remove cpu_dai/codec_dai/cpu_dais/codec_dais include/sound/soc.h | 30 +++++++------ sound/arm/pxa2xx-pcm-lib.c | 8 ++-- sound/soc/amd/acp-da7219-max98357a.c | 2 +- sound/soc/amd/acp-rt5645.c | 4 +- sound/soc/amd/acp3x-rt5682-max9836.c | 6 +-- sound/soc/atmel/atmel-pcm-dma.c | 4 +- sound/soc/atmel/atmel-pcm-pdc.c | 2 +- sound/soc/atmel/atmel_wm8904.c | 2 +- sound/soc/atmel/mikroe-proto.c | 2 +- sound/soc/atmel/sam9g20_wm8731.c | 2 +- sound/soc/atmel/sam9x5_wm8731.c | 2 +- sound/soc/au1x/db1200.c | 2 +- sound/soc/au1x/dbdma2.c | 2 +- sound/soc/au1x/dma.c | 2 +- sound/soc/au1x/psc-ac97.c | 2 +- sound/soc/bcm/bcm63xx-pcm-whistler.c | 16 +++---- sound/soc/bcm/cygnus-pcm.c | 22 +++++----- sound/soc/cirrus/edb93xx.c | 4 +- sound/soc/cirrus/snappercl15.c | 4 +- sound/soc/codecs/cs47l15.c | 4 +- sound/soc/codecs/cs47l24.c | 6 +-- sound/soc/codecs/cs47l35.c | 6 +-- sound/soc/codecs/cs47l85.c | 6 +-- sound/soc/codecs/cs47l90.c | 6 +-- sound/soc/codecs/cs47l92.c | 4 +- sound/soc/codecs/wm5110.c | 6 +-- sound/soc/codecs/wm_adsp.c | 10 ++--- sound/soc/dwc/dwc-pcm.c | 2 +- sound/soc/fsl/eukrea-tlv320.c | 4 +- sound/soc/fsl/fsl-asoc-card.c | 10 ++--- sound/soc/fsl/fsl_asrc_dma.c | 6 +-- sound/soc/fsl/fsl_spdif.c | 10 ++--- sound/soc/fsl/fsl_ssi.c | 8 ++-- sound/soc/fsl/imx-audmix.c | 8 ++-- sound/soc/fsl/imx-mc13783.c | 4 +- sound/soc/fsl/imx-sgtl5000.c | 2 +- sound/soc/fsl/mpc5200_dma.c | 10 ++--- sound/soc/fsl/mpc5200_psc_i2s.c | 2 +- sound/soc/fsl/mpc8610_hpcd.c | 4 +- sound/soc/fsl/mx27vis-aic32x4.c | 4 +- sound/soc/fsl/p1022_ds.c | 4 +- sound/soc/fsl/p1022_rdk.c | 4 +- sound/soc/fsl/wm1133-ev1.c | 6 +-- sound/soc/generic/simple-card-utils.c | 12 +++--- sound/soc/img/img-i2s-in.c | 2 +- sound/soc/img/img-i2s-out.c | 2 +- sound/soc/intel/atom/sst-mfld-platform-pcm.c | 6 +-- sound/soc/intel/boards/bdw-rt5650.c | 6 +-- sound/soc/intel/boards/bdw-rt5677.c | 6 +-- sound/soc/intel/boards/broadwell.c | 4 +- sound/soc/intel/boards/bxt_da7219_max98357a.c | 8 ++-- sound/soc/intel/boards/bxt_rt298.c | 8 ++-- sound/soc/intel/boards/byt-max98090.c | 2 +- sound/soc/intel/boards/byt-rt5640.c | 4 +- sound/soc/intel/boards/bytcht_cx2072x.c | 10 ++--- sound/soc/intel/boards/bytcht_da7213.c | 8 ++-- sound/soc/intel/boards/bytcht_es8316.c | 8 ++-- sound/soc/intel/boards/bytcht_nocodec.c | 4 +- sound/soc/intel/boards/bytcr_rt5640.c | 8 ++-- sound/soc/intel/boards/bytcr_rt5651.c | 8 ++-- sound/soc/intel/boards/cht_bsw_max98090_ti.c | 6 +-- sound/soc/intel/boards/cht_bsw_nau8824.c | 4 +- sound/soc/intel/boards/cht_bsw_rt5645.c | 14 +++---- sound/soc/intel/boards/cht_bsw_rt5672.c | 8 ++-- sound/soc/intel/boards/cml_rt1011_rt5682.c | 6 +-- sound/soc/intel/boards/glk_rt5682_max98357a.c | 10 ++--- sound/soc/intel/boards/haswell.c | 2 +- sound/soc/intel/boards/kbl_da7219_max98357a.c | 8 ++-- sound/soc/intel/boards/kbl_da7219_max98927.c | 6 +-- sound/soc/intel/boards/kbl_rt5660.c | 6 +-- sound/soc/intel/boards/kbl_rt5663_max98927.c | 8 ++-- .../intel/boards/kbl_rt5663_rt5514_max98927.c | 8 ++-- .../soc/intel/boards/skl_nau88l25_max98357a.c | 12 +++--- sound/soc/intel/boards/skl_nau88l25_ssm4567.c | 16 +++---- sound/soc/intel/boards/skl_rt286.c | 8 ++-- sound/soc/intel/boards/sof_da7219_max98373.c | 8 ++-- sound/soc/intel/boards/sof_pcm512x.c | 8 ++-- sound/soc/intel/boards/sof_rt5682.c | 6 +-- sound/soc/intel/haswell/sst-haswell-pcm.c | 26 ++++++------ sound/soc/intel/skylake/skl-pcm.c | 10 ++--- sound/soc/kirkwood/armada-370-db.c | 2 +- sound/soc/kirkwood/kirkwood-dma.c | 2 +- sound/soc/mediatek/common/mtk-afe-fe-dai.c | 10 ++--- .../mediatek/common/mtk-afe-platform-driver.c | 2 +- sound/soc/mediatek/mt2701/mt2701-afe-pcm.c | 2 +- sound/soc/mediatek/mt2701/mt2701-cs42448.c | 4 +- sound/soc/mediatek/mt2701/mt2701-wm8960.c | 4 +- sound/soc/mediatek/mt6797/mt6797-afe-pcm.c | 2 +- sound/soc/mediatek/mt8173/mt8173-afe-pcm.c | 2 +- sound/soc/mediatek/mt8173/mt8173-max98090.c | 4 +- .../mediatek/mt8173/mt8173-rt5650-rt5514.c | 2 +- .../mediatek/mt8173/mt8173-rt5650-rt5676.c | 4 +- sound/soc/mediatek/mt8173/mt8173-rt5650.c | 6 +-- sound/soc/mediatek/mt8183/mt8183-afe-pcm.c | 2 +- .../mediatek/mt8183/mt8183-da7219-max98357.c | 4 +- .../mt8183/mt8183-mt6358-ts3a227-max98357.c | 2 +- sound/soc/meson/aiu-fifo.c | 2 +- sound/soc/meson/axg-card.c | 8 ++-- sound/soc/meson/axg-fifo.c | 2 +- sound/soc/meson/meson-card-utils.c | 2 +- sound/soc/mxs/mxs-sgtl5000.c | 4 +- sound/soc/pxa/brownstone.c | 4 +- sound/soc/pxa/corgi.c | 4 +- sound/soc/pxa/hx4700.c | 4 +- sound/soc/pxa/imote2.c | 4 +- sound/soc/pxa/magician.c | 8 ++-- sound/soc/pxa/mioa701_wm9713.c | 4 +- sound/soc/pxa/mmp-pcm.c | 2 +- sound/soc/pxa/mmp-sspa.c | 2 +- sound/soc/pxa/poodle.c | 4 +- sound/soc/pxa/pxa2xx-i2s.c | 2 +- sound/soc/pxa/spitz.c | 4 +- sound/soc/pxa/ttc-dkb.c | 2 +- sound/soc/pxa/z2.c | 4 +- sound/soc/pxa/zylonite.c | 6 +-- sound/soc/qcom/apq8016_sbc.c | 2 +- sound/soc/qcom/apq8096.c | 6 +-- sound/soc/qcom/lpass-platform.c | 2 +- sound/soc/qcom/qdsp6/q6asm-dai.c | 4 +- sound/soc/qcom/qdsp6/q6routing.c | 2 +- sound/soc/qcom/sdm845.c | 22 +++++----- sound/soc/qcom/storm.c | 2 +- sound/soc/rockchip/rk3288_hdmi_analog.c | 4 +- sound/soc/rockchip/rk3399_gru_sound.c | 16 +++---- sound/soc/rockchip/rockchip_max98090.c | 6 +-- sound/soc/rockchip/rockchip_rt5645.c | 6 +-- sound/soc/samsung/arndale.c | 6 +-- sound/soc/samsung/bells.c | 16 +++---- sound/soc/samsung/h1940_uda1380.c | 2 +- sound/soc/samsung/i2s.c | 2 +- sound/soc/samsung/jive_wm8750.c | 4 +- sound/soc/samsung/littlemill.c | 14 +++---- sound/soc/samsung/lowland.c | 4 +- sound/soc/samsung/neo1973_wm8753.c | 10 ++--- sound/soc/samsung/odroid.c | 2 +- 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 | 4 +- sound/soc/samsung/s3c24xx_uda134x.c | 6 +-- sound/soc/samsung/smartq_wm8987.c | 4 +- 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 | 4 +- sound/soc/samsung/snow.c | 4 +- sound/soc/samsung/spdif.c | 8 ++-- sound/soc/samsung/speyside.c | 8 ++-- sound/soc/samsung/tm2_wm5110.c | 16 +++---- sound/soc/samsung/tobermory.c | 8 ++-- sound/soc/sh/dma-sh7760.c | 16 +++---- sound/soc/sh/fsi.c | 2 +- sound/soc/sh/migor.c | 6 +-- sound/soc/sh/rcar/core.c | 2 +- sound/soc/soc-compress.c | 36 ++++++++-------- sound/soc/soc-core.c | 42 +++++++------------ sound/soc/soc-dapm.c | 4 +- sound/soc/soc-generic-dmaengine-pcm.c | 6 +-- sound/soc/soc-pcm.c | 30 ++++++------- sound/soc/sof/intel/hda-dai.c | 6 +-- sound/soc/sof/intel/hda-dsp.c | 2 +- sound/soc/sprd/sprd-pcm-compress.c | 4 +- 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-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 | 6 +-- sound/soc/tegra/trimslice.c | 2 +- sound/soc/ti/ams-delta.c | 4 +- sound/soc/ti/davinci-evm.c | 4 +- sound/soc/ti/davinci-vcif.c | 4 +- sound/soc/ti/n810.c | 2 +- sound/soc/ti/omap-abe-twl6040.c | 6 +-- sound/soc/ti/omap-mcbsp-st.c | 2 +- sound/soc/ti/omap-mcbsp.c | 4 +- sound/soc/ti/omap-mcpdm.c | 2 +- sound/soc/ti/omap3pandora.c | 4 +- sound/soc/ti/osk5912.c | 2 +- sound/soc/ti/rx51.c | 2 +- sound/soc/txx9/txx9aclc.c | 2 +- sound/soc/uniphier/aio-compress.c | 22 +++++----- sound/soc/uniphier/aio-dma.c | 6 +-- sound/soc/ux500/mop500_ab8500.c | 6 +-- sound/soc/ux500/ux500_pcm.c | 8 ++-- sound/soc/xtensa/xtfpga-i2s.c | 2 +- 191 files changed, 573 insertions(+), 577 deletions(-) -- 2.17.1
433 lines
11 KiB
C
433 lines
11 KiB
C
// SPDX-License-Identifier: GPL-2.0-or-later
|
|
/*
|
|
* SoC audio for HTC Magician
|
|
*
|
|
* Copyright (c) 2006 Philipp Zabel <philipp.zabel@gmail.com>
|
|
*
|
|
* based on spitz.c,
|
|
* Authors: Liam Girdwood <lrg@slimlogic.co.uk>
|
|
* Richard Purdie <richard@openedhand.com>
|
|
*/
|
|
|
|
#include <linux/module.h>
|
|
#include <linux/timer.h>
|
|
#include <linux/interrupt.h>
|
|
#include <linux/platform_device.h>
|
|
#include <linux/delay.h>
|
|
#include <linux/gpio.h>
|
|
#include <linux/i2c.h>
|
|
|
|
#include <sound/core.h>
|
|
#include <sound/pcm.h>
|
|
#include <sound/pcm_params.h>
|
|
#include <sound/soc.h>
|
|
#include <sound/uda1380.h>
|
|
|
|
#include <mach/magician.h>
|
|
#include <asm/mach-types.h>
|
|
#include "../codecs/uda1380.h"
|
|
#include "pxa2xx-i2s.h"
|
|
#include "pxa-ssp.h"
|
|
|
|
#define MAGICIAN_MIC 0
|
|
#define MAGICIAN_MIC_EXT 1
|
|
|
|
static int magician_hp_switch;
|
|
static int magician_spk_switch = 1;
|
|
static int magician_in_sel = MAGICIAN_MIC;
|
|
|
|
static void magician_ext_control(struct snd_soc_dapm_context *dapm)
|
|
{
|
|
|
|
snd_soc_dapm_mutex_lock(dapm);
|
|
|
|
if (magician_spk_switch)
|
|
snd_soc_dapm_enable_pin_unlocked(dapm, "Speaker");
|
|
else
|
|
snd_soc_dapm_disable_pin_unlocked(dapm, "Speaker");
|
|
if (magician_hp_switch)
|
|
snd_soc_dapm_enable_pin_unlocked(dapm, "Headphone Jack");
|
|
else
|
|
snd_soc_dapm_disable_pin_unlocked(dapm, "Headphone Jack");
|
|
|
|
switch (magician_in_sel) {
|
|
case MAGICIAN_MIC:
|
|
snd_soc_dapm_disable_pin_unlocked(dapm, "Headset Mic");
|
|
snd_soc_dapm_enable_pin_unlocked(dapm, "Call Mic");
|
|
break;
|
|
case MAGICIAN_MIC_EXT:
|
|
snd_soc_dapm_disable_pin_unlocked(dapm, "Call Mic");
|
|
snd_soc_dapm_enable_pin_unlocked(dapm, "Headset Mic");
|
|
break;
|
|
}
|
|
|
|
snd_soc_dapm_sync_unlocked(dapm);
|
|
|
|
snd_soc_dapm_mutex_unlock(dapm);
|
|
}
|
|
|
|
static int magician_startup(struct snd_pcm_substream *substream)
|
|
{
|
|
struct snd_soc_pcm_runtime *rtd = substream->private_data;
|
|
|
|
/* check the jack status at stream startup */
|
|
magician_ext_control(&rtd->card->dapm);
|
|
|
|
return 0;
|
|
}
|
|
|
|
/*
|
|
* Magician uses SSP port for playback.
|
|
*/
|
|
static int magician_playback_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 = asoc_rtd_to_codec(rtd, 0);
|
|
struct snd_soc_dai *cpu_dai = asoc_rtd_to_cpu(rtd, 0);
|
|
unsigned int width;
|
|
int ret = 0;
|
|
|
|
/* set codec DAI configuration */
|
|
ret = snd_soc_dai_set_fmt(codec_dai, SND_SOC_DAIFMT_MSB |
|
|
SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBS_CFS);
|
|
if (ret < 0)
|
|
return ret;
|
|
|
|
/* set cpu DAI configuration */
|
|
ret = snd_soc_dai_set_fmt(cpu_dai, SND_SOC_DAIFMT_DSP_A |
|
|
SND_SOC_DAIFMT_NB_IF | SND_SOC_DAIFMT_CBS_CFS);
|
|
if (ret < 0)
|
|
return ret;
|
|
|
|
width = snd_pcm_format_physical_width(params_format(params));
|
|
ret = snd_soc_dai_set_tdm_slot(cpu_dai, 1, 0, 1, width);
|
|
if (ret < 0)
|
|
return ret;
|
|
|
|
/* set audio clock as clock source */
|
|
ret = snd_soc_dai_set_sysclk(cpu_dai, PXA_SSP_CLK_AUDIO, 0,
|
|
SND_SOC_CLOCK_OUT);
|
|
if (ret < 0)
|
|
return ret;
|
|
|
|
return 0;
|
|
}
|
|
|
|
/*
|
|
* Magician uses I2S for capture.
|
|
*/
|
|
static int magician_capture_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 = asoc_rtd_to_codec(rtd, 0);
|
|
struct snd_soc_dai *cpu_dai = asoc_rtd_to_cpu(rtd, 0);
|
|
int ret = 0;
|
|
|
|
/* set codec DAI configuration */
|
|
ret = snd_soc_dai_set_fmt(codec_dai,
|
|
SND_SOC_DAIFMT_MSB | SND_SOC_DAIFMT_NB_NF |
|
|
SND_SOC_DAIFMT_CBS_CFS);
|
|
if (ret < 0)
|
|
return ret;
|
|
|
|
/* set cpu DAI configuration */
|
|
ret = snd_soc_dai_set_fmt(cpu_dai,
|
|
SND_SOC_DAIFMT_MSB | SND_SOC_DAIFMT_NB_NF |
|
|
SND_SOC_DAIFMT_CBS_CFS);
|
|
if (ret < 0)
|
|
return ret;
|
|
|
|
/* set the I2S system clock as output */
|
|
ret = snd_soc_dai_set_sysclk(cpu_dai, PXA2XX_I2S_SYSCLK, 0,
|
|
SND_SOC_CLOCK_OUT);
|
|
if (ret < 0)
|
|
return ret;
|
|
|
|
return 0;
|
|
}
|
|
|
|
static const struct snd_soc_ops magician_capture_ops = {
|
|
.startup = magician_startup,
|
|
.hw_params = magician_capture_hw_params,
|
|
};
|
|
|
|
static const struct snd_soc_ops magician_playback_ops = {
|
|
.startup = magician_startup,
|
|
.hw_params = magician_playback_hw_params,
|
|
};
|
|
|
|
static int magician_get_hp(struct snd_kcontrol *kcontrol,
|
|
struct snd_ctl_elem_value *ucontrol)
|
|
{
|
|
ucontrol->value.integer.value[0] = magician_hp_switch;
|
|
return 0;
|
|
}
|
|
|
|
static int magician_set_hp(struct snd_kcontrol *kcontrol,
|
|
struct snd_ctl_elem_value *ucontrol)
|
|
{
|
|
struct snd_soc_card *card = snd_kcontrol_chip(kcontrol);
|
|
|
|
if (magician_hp_switch == ucontrol->value.integer.value[0])
|
|
return 0;
|
|
|
|
magician_hp_switch = ucontrol->value.integer.value[0];
|
|
magician_ext_control(&card->dapm);
|
|
return 1;
|
|
}
|
|
|
|
static int magician_get_spk(struct snd_kcontrol *kcontrol,
|
|
struct snd_ctl_elem_value *ucontrol)
|
|
{
|
|
ucontrol->value.integer.value[0] = magician_spk_switch;
|
|
return 0;
|
|
}
|
|
|
|
static int magician_set_spk(struct snd_kcontrol *kcontrol,
|
|
struct snd_ctl_elem_value *ucontrol)
|
|
{
|
|
struct snd_soc_card *card = snd_kcontrol_chip(kcontrol);
|
|
|
|
if (magician_spk_switch == ucontrol->value.integer.value[0])
|
|
return 0;
|
|
|
|
magician_spk_switch = ucontrol->value.integer.value[0];
|
|
magician_ext_control(&card->dapm);
|
|
return 1;
|
|
}
|
|
|
|
static int magician_get_input(struct snd_kcontrol *kcontrol,
|
|
struct snd_ctl_elem_value *ucontrol)
|
|
{
|
|
ucontrol->value.enumerated.item[0] = magician_in_sel;
|
|
return 0;
|
|
}
|
|
|
|
static int magician_set_input(struct snd_kcontrol *kcontrol,
|
|
struct snd_ctl_elem_value *ucontrol)
|
|
{
|
|
if (magician_in_sel == ucontrol->value.enumerated.item[0])
|
|
return 0;
|
|
|
|
magician_in_sel = ucontrol->value.enumerated.item[0];
|
|
|
|
switch (magician_in_sel) {
|
|
case MAGICIAN_MIC:
|
|
gpio_set_value(EGPIO_MAGICIAN_IN_SEL1, 1);
|
|
break;
|
|
case MAGICIAN_MIC_EXT:
|
|
gpio_set_value(EGPIO_MAGICIAN_IN_SEL1, 0);
|
|
}
|
|
|
|
return 1;
|
|
}
|
|
|
|
static int magician_spk_power(struct snd_soc_dapm_widget *w,
|
|
struct snd_kcontrol *k, int event)
|
|
{
|
|
gpio_set_value(EGPIO_MAGICIAN_SPK_POWER, SND_SOC_DAPM_EVENT_ON(event));
|
|
return 0;
|
|
}
|
|
|
|
static int magician_hp_power(struct snd_soc_dapm_widget *w,
|
|
struct snd_kcontrol *k, int event)
|
|
{
|
|
gpio_set_value(EGPIO_MAGICIAN_EP_POWER, SND_SOC_DAPM_EVENT_ON(event));
|
|
return 0;
|
|
}
|
|
|
|
static int magician_mic_bias(struct snd_soc_dapm_widget *w,
|
|
struct snd_kcontrol *k, int event)
|
|
{
|
|
gpio_set_value(EGPIO_MAGICIAN_MIC_POWER, SND_SOC_DAPM_EVENT_ON(event));
|
|
return 0;
|
|
}
|
|
|
|
/* magician machine dapm widgets */
|
|
static const struct snd_soc_dapm_widget uda1380_dapm_widgets[] = {
|
|
SND_SOC_DAPM_HP("Headphone Jack", magician_hp_power),
|
|
SND_SOC_DAPM_SPK("Speaker", magician_spk_power),
|
|
SND_SOC_DAPM_MIC("Call Mic", magician_mic_bias),
|
|
SND_SOC_DAPM_MIC("Headset Mic", magician_mic_bias),
|
|
};
|
|
|
|
/* magician machine audio_map */
|
|
static const struct snd_soc_dapm_route audio_map[] = {
|
|
|
|
/* Headphone connected to VOUTL, VOUTR */
|
|
{"Headphone Jack", NULL, "VOUTL"},
|
|
{"Headphone Jack", NULL, "VOUTR"},
|
|
|
|
/* Speaker connected to VOUTL, VOUTR */
|
|
{"Speaker", NULL, "VOUTL"},
|
|
{"Speaker", NULL, "VOUTR"},
|
|
|
|
/* Mics are connected to VINM */
|
|
{"VINM", NULL, "Headset Mic"},
|
|
{"VINM", NULL, "Call Mic"},
|
|
};
|
|
|
|
static const char * const input_select[] = {"Call Mic", "Headset Mic"};
|
|
static const struct soc_enum magician_in_sel_enum =
|
|
SOC_ENUM_SINGLE_EXT(2, input_select);
|
|
|
|
static const struct snd_kcontrol_new uda1380_magician_controls[] = {
|
|
SOC_SINGLE_BOOL_EXT("Headphone Switch",
|
|
(unsigned long)&magician_hp_switch,
|
|
magician_get_hp, magician_set_hp),
|
|
SOC_SINGLE_BOOL_EXT("Speaker Switch",
|
|
(unsigned long)&magician_spk_switch,
|
|
magician_get_spk, magician_set_spk),
|
|
SOC_ENUM_EXT("Input Select", magician_in_sel_enum,
|
|
magician_get_input, magician_set_input),
|
|
};
|
|
|
|
/* magician digital audio interface glue - connects codec <--> CPU */
|
|
SND_SOC_DAILINK_DEFS(playback,
|
|
DAILINK_COMP_ARRAY(COMP_CPU("pxa-ssp-dai.0")),
|
|
DAILINK_COMP_ARRAY(COMP_CODEC("uda1380-codec.0-0018",
|
|
"uda1380-hifi-playback")),
|
|
DAILINK_COMP_ARRAY(COMP_PLATFORM("pxa-pcm-audio")));
|
|
|
|
SND_SOC_DAILINK_DEFS(capture,
|
|
DAILINK_COMP_ARRAY(COMP_CPU("pxa2xx-i2s")),
|
|
DAILINK_COMP_ARRAY(COMP_CODEC("uda1380-codec.0-0018",
|
|
"uda1380-hifi-capture")),
|
|
DAILINK_COMP_ARRAY(COMP_PLATFORM("pxa-pcm-audio")));
|
|
|
|
static struct snd_soc_dai_link magician_dai[] = {
|
|
{
|
|
.name = "uda1380",
|
|
.stream_name = "UDA1380 Playback",
|
|
.ops = &magician_playback_ops,
|
|
SND_SOC_DAILINK_REG(playback),
|
|
},
|
|
{
|
|
.name = "uda1380",
|
|
.stream_name = "UDA1380 Capture",
|
|
.ops = &magician_capture_ops,
|
|
SND_SOC_DAILINK_REG(capture),
|
|
}
|
|
};
|
|
|
|
/* magician audio machine driver */
|
|
static struct snd_soc_card snd_soc_card_magician = {
|
|
.name = "Magician",
|
|
.owner = THIS_MODULE,
|
|
.dai_link = magician_dai,
|
|
.num_links = ARRAY_SIZE(magician_dai),
|
|
|
|
.controls = uda1380_magician_controls,
|
|
.num_controls = ARRAY_SIZE(uda1380_magician_controls),
|
|
.dapm_widgets = uda1380_dapm_widgets,
|
|
.num_dapm_widgets = ARRAY_SIZE(uda1380_dapm_widgets),
|
|
.dapm_routes = audio_map,
|
|
.num_dapm_routes = ARRAY_SIZE(audio_map),
|
|
.fully_routed = true,
|
|
};
|
|
|
|
static struct platform_device *magician_snd_device;
|
|
|
|
/*
|
|
* FIXME: move into magician board file once merged into the pxa tree
|
|
*/
|
|
static struct uda1380_platform_data uda1380_info = {
|
|
.gpio_power = EGPIO_MAGICIAN_CODEC_POWER,
|
|
.gpio_reset = EGPIO_MAGICIAN_CODEC_RESET,
|
|
.dac_clk = UDA1380_DAC_CLK_WSPLL,
|
|
};
|
|
|
|
static struct i2c_board_info i2c_board_info[] = {
|
|
{
|
|
I2C_BOARD_INFO("uda1380", 0x18),
|
|
.platform_data = &uda1380_info,
|
|
},
|
|
};
|
|
|
|
static int __init magician_init(void)
|
|
{
|
|
int ret;
|
|
struct i2c_adapter *adapter;
|
|
struct i2c_client *client;
|
|
|
|
if (!machine_is_magician())
|
|
return -ENODEV;
|
|
|
|
adapter = i2c_get_adapter(0);
|
|
if (!adapter)
|
|
return -ENODEV;
|
|
client = i2c_new_client_device(adapter, i2c_board_info);
|
|
i2c_put_adapter(adapter);
|
|
if (IS_ERR(client))
|
|
return PTR_ERR(client);
|
|
|
|
ret = gpio_request(EGPIO_MAGICIAN_SPK_POWER, "SPK_POWER");
|
|
if (ret)
|
|
goto err_request_spk;
|
|
ret = gpio_request(EGPIO_MAGICIAN_EP_POWER, "EP_POWER");
|
|
if (ret)
|
|
goto err_request_ep;
|
|
ret = gpio_request(EGPIO_MAGICIAN_MIC_POWER, "MIC_POWER");
|
|
if (ret)
|
|
goto err_request_mic;
|
|
ret = gpio_request(EGPIO_MAGICIAN_IN_SEL0, "IN_SEL0");
|
|
if (ret)
|
|
goto err_request_in_sel0;
|
|
ret = gpio_request(EGPIO_MAGICIAN_IN_SEL1, "IN_SEL1");
|
|
if (ret)
|
|
goto err_request_in_sel1;
|
|
|
|
gpio_set_value(EGPIO_MAGICIAN_IN_SEL0, 0);
|
|
|
|
magician_snd_device = platform_device_alloc("soc-audio", -1);
|
|
if (!magician_snd_device) {
|
|
ret = -ENOMEM;
|
|
goto err_pdev;
|
|
}
|
|
|
|
platform_set_drvdata(magician_snd_device, &snd_soc_card_magician);
|
|
ret = platform_device_add(magician_snd_device);
|
|
if (ret) {
|
|
platform_device_put(magician_snd_device);
|
|
goto err_pdev;
|
|
}
|
|
|
|
return 0;
|
|
|
|
err_pdev:
|
|
gpio_free(EGPIO_MAGICIAN_IN_SEL1);
|
|
err_request_in_sel1:
|
|
gpio_free(EGPIO_MAGICIAN_IN_SEL0);
|
|
err_request_in_sel0:
|
|
gpio_free(EGPIO_MAGICIAN_MIC_POWER);
|
|
err_request_mic:
|
|
gpio_free(EGPIO_MAGICIAN_EP_POWER);
|
|
err_request_ep:
|
|
gpio_free(EGPIO_MAGICIAN_SPK_POWER);
|
|
err_request_spk:
|
|
return ret;
|
|
}
|
|
|
|
static void __exit magician_exit(void)
|
|
{
|
|
platform_device_unregister(magician_snd_device);
|
|
|
|
gpio_set_value(EGPIO_MAGICIAN_SPK_POWER, 0);
|
|
gpio_set_value(EGPIO_MAGICIAN_EP_POWER, 0);
|
|
gpio_set_value(EGPIO_MAGICIAN_MIC_POWER, 0);
|
|
|
|
gpio_free(EGPIO_MAGICIAN_IN_SEL1);
|
|
gpio_free(EGPIO_MAGICIAN_IN_SEL0);
|
|
gpio_free(EGPIO_MAGICIAN_MIC_POWER);
|
|
gpio_free(EGPIO_MAGICIAN_EP_POWER);
|
|
gpio_free(EGPIO_MAGICIAN_SPK_POWER);
|
|
}
|
|
|
|
module_init(magician_init);
|
|
module_exit(magician_exit);
|
|
|
|
MODULE_AUTHOR("Philipp Zabel");
|
|
MODULE_DESCRIPTION("ALSA SoC Magician");
|
|
MODULE_LICENSE("GPL");
|