Merge remote-tracking branches 'asoc/topic/samsung', 'asoc/topic/sgtl5000', 'asoc/topic/sh', 'asoc/topic/simple', 'asoc/topic/sirf', 'asoc/topic/sn95031', 'asoc/topic/ssm2602' and 'asoc/topic/stac9766' into asoc-next
This commit is contained in:
parent
a4b12990b6
8b621d0fae
c8ed650421
23a735cc02
12ffa6fc19
af12a31f05
f3c1196e16
b38fbe3073
3cd7ca5882
commit
7cc6417208
33 changed files with 1566 additions and 435 deletions
|
@ -8,13 +8,18 @@ Required properties:
|
|||
|
||||
Optional properties:
|
||||
|
||||
- simple-audio-card,name : User specified audio sound card name, one string
|
||||
property.
|
||||
- simple-audio-card,format : CPU/CODEC common audio format.
|
||||
"i2s", "right_j", "left_j" , "dsp_a"
|
||||
"dsp_b", "ac97", "pdm", "msb", "lsb"
|
||||
- simple-audio-card,widgets : Please refer to widgets.txt.
|
||||
- simple-audio-card,routing : A list of the connections between audio components.
|
||||
Each entry is a pair of strings, the first being the
|
||||
connection's sink, the second being the connection's
|
||||
source.
|
||||
- dai-tdm-slot-num : Please refer to tdm-slot.txt.
|
||||
- dai-tdm-slot-width : Please refer to tdm-slot.txt.
|
||||
|
||||
Required subnodes:
|
||||
|
||||
|
@ -42,11 +47,19 @@ Example:
|
|||
|
||||
sound {
|
||||
compatible = "simple-audio-card";
|
||||
simple-audio-card,name = "VF610-Tower-Sound-Card";
|
||||
simple-audio-card,format = "left_j";
|
||||
simple-audio-card,widgets =
|
||||
"Microphone", "Microphone Jack",
|
||||
"Headphone", "Headphone Jack",
|
||||
"Speaker", "External Speaker";
|
||||
simple-audio-card,routing =
|
||||
"MIC_IN", "Mic Jack",
|
||||
"MIC_IN", "Microphone Jack",
|
||||
"Headphone Jack", "HP_OUT",
|
||||
"Ext Spk", "LINE_OUT";
|
||||
"External Speaker", "LINE_OUT";
|
||||
|
||||
dai-tdm-slot-num = <2>;
|
||||
dai-tdm-slot-width = <8>;
|
||||
|
||||
simple-audio-card,cpu {
|
||||
sound-dai = <&sh_fsi2 0>;
|
||||
|
|
17
Documentation/devicetree/bindings/sound/sirf-audio-codec.txt
Normal file
17
Documentation/devicetree/bindings/sound/sirf-audio-codec.txt
Normal file
|
@ -0,0 +1,17 @@
|
|||
SiRF internal audio CODEC
|
||||
|
||||
Required properties:
|
||||
|
||||
- compatible : "sirf,atlas6-audio-codec" or "sirf,prima2-audio-codec"
|
||||
|
||||
- reg : the register address of the device.
|
||||
|
||||
- clocks: the clock of SiRF internal audio codec
|
||||
|
||||
Example:
|
||||
|
||||
audiocodec: audiocodec@b0040000 {
|
||||
compatible = "sirf,atlas6-audio-codec";
|
||||
reg = <0xb0040000 0x10000>;
|
||||
clocks = <&clks 27>;
|
||||
};
|
20
Documentation/devicetree/bindings/sound/sirf-audio-port.txt
Normal file
20
Documentation/devicetree/bindings/sound/sirf-audio-port.txt
Normal file
|
@ -0,0 +1,20 @@
|
|||
* SiRF SoC audio port
|
||||
|
||||
Required properties:
|
||||
- compatible: "sirf,audio-port"
|
||||
- reg: Base address and size entries:
|
||||
- dmas: List of DMA controller phandle and DMA request line ordered pairs.
|
||||
- dma-names: Identifier string for each DMA request line in the dmas property.
|
||||
These strings correspond 1:1 with the ordered pairs in dmas.
|
||||
|
||||
One of the DMA channels will be responsible for transmission (should be
|
||||
named "tx") and one for reception (should be named "rx").
|
||||
|
||||
Example:
|
||||
|
||||
audioport: audioport@b0040000 {
|
||||
compatible = "sirf,audio-port";
|
||||
reg = <0xb0040000 0x10000>;
|
||||
dmas = <&dmac1 3>, <&dmac1 8>;
|
||||
dma-names = "rx", "tx";
|
||||
};
|
41
Documentation/devicetree/bindings/sound/sirf-audio.txt
Normal file
41
Documentation/devicetree/bindings/sound/sirf-audio.txt
Normal file
|
@ -0,0 +1,41 @@
|
|||
* SiRF atlas6 and prima2 internal audio codec and port based audio setups
|
||||
|
||||
Required properties:
|
||||
- compatible: "sirf,sirf-audio-card"
|
||||
- sirf,audio-platform: phandle for the platform node
|
||||
- sirf,audio-codec: phandle for the SiRF internal codec node
|
||||
|
||||
Optional properties:
|
||||
- hp-pa-gpios: Need to be present if the board need control external
|
||||
headphone amplifier.
|
||||
- spk-pa-gpios: Need to be present if the board need control external
|
||||
speaker amplifier.
|
||||
- hp-switch-gpios: Need to be present if the board capable to detect jack
|
||||
insertion, removal.
|
||||
|
||||
Available audio endpoints for the audio-routing table:
|
||||
|
||||
Board connectors:
|
||||
* Headset Stereophone
|
||||
* Ext Spk
|
||||
* Line In
|
||||
* Mic
|
||||
|
||||
SiRF internal audio codec pins:
|
||||
* HPOUTL
|
||||
* HPOUTR
|
||||
* SPKOUT
|
||||
* Ext Mic
|
||||
* Mic Bias
|
||||
|
||||
Example:
|
||||
|
||||
sound {
|
||||
compatible = "sirf,sirf-audio-card";
|
||||
sirf,audio-codec = <&audiocodec>;
|
||||
sirf,audio-platform = <&audioport>;
|
||||
hp-pa-gpios = <&gpio 44 0>;
|
||||
spk-pa-gpios = <&gpio 46 0>;
|
||||
hp-switch-gpios = <&gpio 45 0>;
|
||||
};
|
||||
|
|
@ -1,5 +1,4 @@
|
|||
/* arch/arm/plat-samsung/include/plat/audio.h
|
||||
*
|
||||
/*
|
||||
* Copyright (c) 2009 Samsung Electronics Co. Ltd
|
||||
* Author: Jaswinder Singh <jassi.brar@samsung.com>
|
||||
*
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
/* arch/arm/plat-samsung/include/plat/audio-simtec.h
|
||||
*
|
||||
/*
|
||||
* Copyright 2008 Simtec Electronics
|
||||
* http://armlinux.simtec.co.uk/
|
||||
* Ben Dooks <ben@simtec.co.uk>
|
||||
|
|
|
@ -18,6 +18,8 @@ struct asoc_simple_dai {
|
|||
const char *name;
|
||||
unsigned int fmt;
|
||||
unsigned int sysclk;
|
||||
int slots;
|
||||
int slot_width;
|
||||
};
|
||||
|
||||
struct asoc_simple_card_info {
|
||||
|
@ -29,10 +31,6 @@ struct asoc_simple_card_info {
|
|||
unsigned int daifmt;
|
||||
struct asoc_simple_dai cpu_dai;
|
||||
struct asoc_simple_dai codec_dai;
|
||||
|
||||
/* used in simple-card.c */
|
||||
struct snd_soc_dai_link snd_link;
|
||||
struct snd_soc_card snd_card;
|
||||
};
|
||||
|
||||
#endif /* __SIMPLE_CARD_H */
|
||||
|
|
|
@ -50,6 +50,7 @@ source "sound/soc/pxa/Kconfig"
|
|||
source "sound/soc/samsung/Kconfig"
|
||||
source "sound/soc/s6000/Kconfig"
|
||||
source "sound/soc/sh/Kconfig"
|
||||
source "sound/soc/sirf/Kconfig"
|
||||
source "sound/soc/spear/Kconfig"
|
||||
source "sound/soc/tegra/Kconfig"
|
||||
source "sound/soc/txx9/Kconfig"
|
||||
|
|
|
@ -27,6 +27,7 @@ obj-$(CONFIG_SND_SOC) += pxa/
|
|||
obj-$(CONFIG_SND_SOC) += samsung/
|
||||
obj-$(CONFIG_SND_SOC) += s6000/
|
||||
obj-$(CONFIG_SND_SOC) += sh/
|
||||
obj-$(CONFIG_SND_SOC) += sirf/
|
||||
obj-$(CONFIG_SND_SOC) += spear/
|
||||
obj-$(CONFIG_SND_SOC) += tegra/
|
||||
obj-$(CONFIG_SND_SOC) += txx9/
|
||||
|
|
|
@ -14,7 +14,8 @@ config SND_BF5XX_SOC_SSM2602
|
|||
depends on SND_BF5XX_I2S && SND_SOC_I2C_AND_SPI
|
||||
select SND_BF5XX_SOC_I2S if !BF60x
|
||||
select SND_BF6XX_SOC_I2S if BF60x
|
||||
select SND_SOC_SSM2602
|
||||
select SND_SOC_SSM2602_SPI if SPI_MASTER
|
||||
select SND_SOC_SSM2602_I2C if I2C
|
||||
help
|
||||
Say Y if you want to add support for the Analog Devices
|
||||
SSM2602 Audio Codec Add-On Card.
|
||||
|
|
|
@ -72,10 +72,12 @@ config SND_SOC_ALL_CODECS
|
|||
select SND_SOC_RT5640 if I2C
|
||||
select SND_SOC_SGTL5000 if I2C
|
||||
select SND_SOC_SI476X if MFD_SI476X_CORE
|
||||
select SND_SOC_SIRF_AUDIO_CODEC
|
||||
select SND_SOC_SN95031 if INTEL_SCU_IPC
|
||||
select SND_SOC_SPDIF
|
||||
select SND_SOC_SSM2518 if I2C
|
||||
select SND_SOC_SSM2602 if SND_SOC_I2C_AND_SPI
|
||||
select SND_SOC_SSM2602_SPI if SPI_MASTER
|
||||
select SND_SOC_SSM2602_I2C if I2C
|
||||
select SND_SOC_STA32X if I2C
|
||||
select SND_SOC_STA529 if I2C
|
||||
select SND_SOC_STAC9766 if SND_SOC_AC97_BUS
|
||||
|
@ -395,6 +397,10 @@ config SND_SOC_SIGMADSP
|
|||
tristate
|
||||
select CRC32
|
||||
|
||||
config SND_SOC_SIRF_AUDIO_CODEC
|
||||
tristate "SiRF SoC internal audio codec"
|
||||
select REGMAP_MMIO
|
||||
|
||||
config SND_SOC_SN95031
|
||||
tristate
|
||||
|
||||
|
@ -407,6 +413,14 @@ config SND_SOC_SSM2518
|
|||
config SND_SOC_SSM2602
|
||||
tristate
|
||||
|
||||
config SND_SOC_SSM2602_SPI
|
||||
select SND_SOC_SSM2602
|
||||
tristate
|
||||
|
||||
config SND_SOC_SSM2602_I2C
|
||||
select SND_SOC_SSM2602
|
||||
tristate
|
||||
|
||||
config SND_SOC_STA32X
|
||||
tristate
|
||||
|
||||
|
|
|
@ -63,11 +63,14 @@ snd-soc-alc5623-objs := alc5623.o
|
|||
snd-soc-alc5632-objs := alc5632.o
|
||||
snd-soc-sigmadsp-objs := sigmadsp.o
|
||||
snd-soc-si476x-objs := si476x.o
|
||||
snd-soc-sirf-audio-codec-objs := sirf-audio-codec.o
|
||||
snd-soc-sn95031-objs := sn95031.o
|
||||
snd-soc-spdif-tx-objs := spdif_transmitter.o
|
||||
snd-soc-spdif-rx-objs := spdif_receiver.o
|
||||
snd-soc-ssm2518-objs := ssm2518.o
|
||||
snd-soc-ssm2602-objs := ssm2602.o
|
||||
snd-soc-ssm2602-spi-objs := ssm2602-spi.o
|
||||
snd-soc-ssm2602-i2c-objs := ssm2602-i2c.o
|
||||
snd-soc-sta32x-objs := sta32x.o
|
||||
snd-soc-sta529-objs := sta529.o
|
||||
snd-soc-stac9766-objs := stac9766.o
|
||||
|
@ -210,6 +213,8 @@ obj-$(CONFIG_SND_SOC_SN95031) +=snd-soc-sn95031.o
|
|||
obj-$(CONFIG_SND_SOC_SPDIF) += snd-soc-spdif-rx.o snd-soc-spdif-tx.o
|
||||
obj-$(CONFIG_SND_SOC_SSM2518) += snd-soc-ssm2518.o
|
||||
obj-$(CONFIG_SND_SOC_SSM2602) += snd-soc-ssm2602.o
|
||||
obj-$(CONFIG_SND_SOC_SSM2602_SPI) += snd-soc-ssm2602-spi.o
|
||||
obj-$(CONFIG_SND_SOC_SSM2602_I2C) += snd-soc-ssm2602-i2c.o
|
||||
obj-$(CONFIG_SND_SOC_STA32X) += snd-soc-sta32x.o
|
||||
obj-$(CONFIG_SND_SOC_STA529) += snd-soc-sta529.o
|
||||
obj-$(CONFIG_SND_SOC_STAC9766) += snd-soc-stac9766.o
|
||||
|
|
|
@ -187,8 +187,9 @@ static const char *adc_mux_text[] = {
|
|||
"MIC_IN", "LINE_IN"
|
||||
};
|
||||
|
||||
static const struct soc_enum adc_enum =
|
||||
SOC_ENUM_SINGLE(SGTL5000_CHIP_ANA_CTRL, 2, 2, adc_mux_text);
|
||||
static SOC_ENUM_SINGLE_DECL(adc_enum,
|
||||
SGTL5000_CHIP_ANA_CTRL, 2,
|
||||
adc_mux_text);
|
||||
|
||||
static const struct snd_kcontrol_new adc_mux =
|
||||
SOC_DAPM_ENUM("Capture Mux", adc_enum);
|
||||
|
@ -198,8 +199,9 @@ static const char *dac_mux_text[] = {
|
|||
"DAC", "LINE_IN"
|
||||
};
|
||||
|
||||
static const struct soc_enum dac_enum =
|
||||
SOC_ENUM_SINGLE(SGTL5000_CHIP_ANA_CTRL, 6, 2, dac_mux_text);
|
||||
static SOC_ENUM_SINGLE_DECL(dac_enum,
|
||||
SGTL5000_CHIP_ANA_CTRL, 6,
|
||||
dac_mux_text);
|
||||
|
||||
static const struct snd_kcontrol_new dac_mux =
|
||||
SOC_DAPM_ENUM("Headphone Mux", dac_enum);
|
||||
|
|
533
sound/soc/codecs/sirf-audio-codec.c
Normal file
533
sound/soc/codecs/sirf-audio-codec.c
Normal file
|
@ -0,0 +1,533 @@
|
|||
/*
|
||||
* SiRF audio codec driver
|
||||
*
|
||||
* Copyright (c) 2011 Cambridge Silicon Radio Limited, a CSR plc group company.
|
||||
*
|
||||
* Licensed under GPLv2 or later.
|
||||
*/
|
||||
|
||||
#include <linux/module.h>
|
||||
#include <linux/platform_device.h>
|
||||
#include <linux/pm_runtime.h>
|
||||
#include <linux/of.h>
|
||||
#include <linux/of_device.h>
|
||||
#include <linux/clk.h>
|
||||
#include <linux/delay.h>
|
||||
#include <linux/io.h>
|
||||
#include <linux/regmap.h>
|
||||
#include <sound/core.h>
|
||||
#include <sound/pcm.h>
|
||||
#include <sound/pcm_params.h>
|
||||
#include <sound/initval.h>
|
||||
#include <sound/tlv.h>
|
||||
#include <sound/soc.h>
|
||||
#include <sound/dmaengine_pcm.h>
|
||||
|
||||
#include "sirf-audio-codec.h"
|
||||
|
||||
struct sirf_audio_codec {
|
||||
struct clk *clk;
|
||||
struct regmap *regmap;
|
||||
u32 reg_ctrl0, reg_ctrl1;
|
||||
};
|
||||
|
||||
static const char * const input_mode_mux[] = {"Single-ended",
|
||||
"Differential"};
|
||||
|
||||
static const struct soc_enum input_mode_mux_enum =
|
||||
SOC_ENUM_SINGLE(AUDIO_IC_CODEC_CTRL1, 4, 2, input_mode_mux);
|
||||
|
||||
static const struct snd_kcontrol_new sirf_audio_codec_input_mode_control =
|
||||
SOC_DAPM_ENUM("Route", input_mode_mux_enum);
|
||||
|
||||
static const DECLARE_TLV_DB_SCALE(playback_vol_tlv, -12400, 100, 0);
|
||||
static const DECLARE_TLV_DB_SCALE(capture_vol_tlv_prima2, 500, 100, 0);
|
||||
static const DECLARE_TLV_DB_RANGE(capture_vol_tlv_atlas6,
|
||||
0, 7, TLV_DB_SCALE_ITEM(-100, 100, 0),
|
||||
0x22, 0x3F, TLV_DB_SCALE_ITEM(700, 100, 0),
|
||||
);
|
||||
|
||||
static struct snd_kcontrol_new volume_controls_atlas6[] = {
|
||||
SOC_DOUBLE_TLV("Playback Volume", AUDIO_IC_CODEC_CTRL0, 21, 14,
|
||||
0x7F, 0, playback_vol_tlv),
|
||||
SOC_DOUBLE_TLV("Capture Volume", AUDIO_IC_CODEC_CTRL1, 16, 10,
|
||||
0x3F, 0, capture_vol_tlv_atlas6),
|
||||
};
|
||||
|
||||
static struct snd_kcontrol_new volume_controls_prima2[] = {
|
||||
SOC_DOUBLE_TLV("Speaker Volume", AUDIO_IC_CODEC_CTRL0, 21, 14,
|
||||
0x7F, 0, playback_vol_tlv),
|
||||
SOC_DOUBLE_TLV("Capture Volume", AUDIO_IC_CODEC_CTRL1, 15, 10,
|
||||
0x1F, 0, capture_vol_tlv_prima2),
|
||||
};
|
||||
|
||||
static struct snd_kcontrol_new left_input_path_controls[] = {
|
||||
SOC_DAPM_SINGLE("Line Left Switch", AUDIO_IC_CODEC_CTRL1, 6, 1, 0),
|
||||
SOC_DAPM_SINGLE("Mic Left Switch", AUDIO_IC_CODEC_CTRL1, 3, 1, 0),
|
||||
};
|
||||
|
||||
static struct snd_kcontrol_new right_input_path_controls[] = {
|
||||
SOC_DAPM_SINGLE("Line Right Switch", AUDIO_IC_CODEC_CTRL1, 5, 1, 0),
|
||||
SOC_DAPM_SINGLE("Mic Right Switch", AUDIO_IC_CODEC_CTRL1, 2, 1, 0),
|
||||
};
|
||||
|
||||
static struct snd_kcontrol_new left_dac_to_hp_left_amp_switch_control =
|
||||
SOC_DAPM_SINGLE("Switch", AUDIO_IC_CODEC_CTRL0, 9, 1, 0);
|
||||
|
||||
static struct snd_kcontrol_new left_dac_to_hp_right_amp_switch_control =
|
||||
SOC_DAPM_SINGLE("Switch", AUDIO_IC_CODEC_CTRL0, 8, 1, 0);
|
||||
|
||||
static struct snd_kcontrol_new right_dac_to_hp_left_amp_switch_control =
|
||||
SOC_DAPM_SINGLE("Switch", AUDIO_IC_CODEC_CTRL0, 7, 1, 0);
|
||||
|
||||
static struct snd_kcontrol_new right_dac_to_hp_right_amp_switch_control =
|
||||
SOC_DAPM_SINGLE("Switch", AUDIO_IC_CODEC_CTRL0, 6, 1, 0);
|
||||
|
||||
static struct snd_kcontrol_new left_dac_to_speaker_lineout_switch_control =
|
||||
SOC_DAPM_SINGLE("Switch", AUDIO_IC_CODEC_CTRL0, 11, 1, 0);
|
||||
|
||||
static struct snd_kcontrol_new right_dac_to_speaker_lineout_switch_control =
|
||||
SOC_DAPM_SINGLE("Switch", AUDIO_IC_CODEC_CTRL0, 10, 1, 0);
|
||||
|
||||
/* After enable adc, Delay 200ms to avoid pop noise */
|
||||
static int adc_enable_delay_event(struct snd_soc_dapm_widget *w,
|
||||
struct snd_kcontrol *kcontrol, int event)
|
||||
{
|
||||
switch (event) {
|
||||
case SND_SOC_DAPM_POST_PMU:
|
||||
msleep(200);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void enable_and_reset_codec(struct regmap *regmap,
|
||||
u32 codec_enable_bits, u32 codec_reset_bits)
|
||||
{
|
||||
regmap_update_bits(regmap, AUDIO_IC_CODEC_CTRL1,
|
||||
codec_enable_bits | codec_reset_bits,
|
||||
codec_enable_bits | ~codec_reset_bits);
|
||||
msleep(20);
|
||||
regmap_update_bits(regmap, AUDIO_IC_CODEC_CTRL1,
|
||||
codec_reset_bits, codec_reset_bits);
|
||||
}
|
||||
|
||||
static int atlas6_codec_enable_and_reset_event(struct snd_soc_dapm_widget *w,
|
||||
struct snd_kcontrol *kcontrol, int event)
|
||||
{
|
||||
#define ATLAS6_CODEC_ENABLE_BITS (1 << 29)
|
||||
#define ATLAS6_CODEC_RESET_BITS (1 << 28)
|
||||
struct sirf_audio_codec *sirf_audio_codec = dev_get_drvdata(w->codec->dev);
|
||||
switch (event) {
|
||||
case SND_SOC_DAPM_PRE_PMU:
|
||||
enable_and_reset_codec(sirf_audio_codec->regmap,
|
||||
ATLAS6_CODEC_ENABLE_BITS, ATLAS6_CODEC_RESET_BITS);
|
||||
break;
|
||||
case SND_SOC_DAPM_POST_PMD:
|
||||
regmap_update_bits(sirf_audio_codec->regmap,
|
||||
AUDIO_IC_CODEC_CTRL1, ATLAS6_CODEC_ENABLE_BITS,
|
||||
~ATLAS6_CODEC_ENABLE_BITS);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int prima2_codec_enable_and_reset_event(struct snd_soc_dapm_widget *w,
|
||||
struct snd_kcontrol *kcontrol, int event)
|
||||
{
|
||||
#define PRIMA2_CODEC_ENABLE_BITS (1 << 27)
|
||||
#define PRIMA2_CODEC_RESET_BITS (1 << 26)
|
||||
struct sirf_audio_codec *sirf_audio_codec = dev_get_drvdata(w->codec->dev);
|
||||
switch (event) {
|
||||
case SND_SOC_DAPM_POST_PMU:
|
||||
enable_and_reset_codec(sirf_audio_codec->regmap,
|
||||
PRIMA2_CODEC_ENABLE_BITS, PRIMA2_CODEC_RESET_BITS);
|
||||
break;
|
||||
case SND_SOC_DAPM_POST_PMD:
|
||||
regmap_update_bits(sirf_audio_codec->regmap,
|
||||
AUDIO_IC_CODEC_CTRL1, PRIMA2_CODEC_ENABLE_BITS,
|
||||
~PRIMA2_CODEC_ENABLE_BITS);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const struct snd_soc_dapm_widget atlas6_output_driver_dapm_widgets[] = {
|
||||
SND_SOC_DAPM_OUT_DRV("HP Left Driver", AUDIO_IC_CODEC_CTRL1,
|
||||
25, 0, NULL, 0),
|
||||
SND_SOC_DAPM_OUT_DRV("HP Right Driver", AUDIO_IC_CODEC_CTRL1,
|
||||
26, 0, NULL, 0),
|
||||
SND_SOC_DAPM_OUT_DRV("Speaker Driver", AUDIO_IC_CODEC_CTRL1,
|
||||
27, 0, NULL, 0),
|
||||
};
|
||||
|
||||
static const struct snd_soc_dapm_widget prima2_output_driver_dapm_widgets[] = {
|
||||
SND_SOC_DAPM_OUT_DRV("HP Left Driver", AUDIO_IC_CODEC_CTRL1,
|
||||
23, 0, NULL, 0),
|
||||
SND_SOC_DAPM_OUT_DRV("HP Right Driver", AUDIO_IC_CODEC_CTRL1,
|
||||
24, 0, NULL, 0),
|
||||
SND_SOC_DAPM_OUT_DRV("Speaker Driver", AUDIO_IC_CODEC_CTRL1,
|
||||
25, 0, NULL, 0),
|
||||
};
|
||||
|
||||
static const struct snd_soc_dapm_widget atlas6_codec_clock_dapm_widget =
|
||||
SND_SOC_DAPM_SUPPLY("codecclk", SND_SOC_NOPM, 0, 0,
|
||||
atlas6_codec_enable_and_reset_event,
|
||||
SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD);
|
||||
|
||||
static const struct snd_soc_dapm_widget prima2_codec_clock_dapm_widget =
|
||||
SND_SOC_DAPM_SUPPLY("codecclk", SND_SOC_NOPM, 0, 0,
|
||||
prima2_codec_enable_and_reset_event,
|
||||
SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD);
|
||||
|
||||
static const struct snd_soc_dapm_widget sirf_audio_codec_dapm_widgets[] = {
|
||||
SND_SOC_DAPM_DAC("DAC left", NULL, AUDIO_IC_CODEC_CTRL0, 1, 0),
|
||||
SND_SOC_DAPM_DAC("DAC right", NULL, AUDIO_IC_CODEC_CTRL0, 0, 0),
|
||||
SND_SOC_DAPM_SWITCH("Left dac to hp left amp", SND_SOC_NOPM, 0, 0,
|
||||
&left_dac_to_hp_left_amp_switch_control),
|
||||
SND_SOC_DAPM_SWITCH("Left dac to hp right amp", SND_SOC_NOPM, 0, 0,
|
||||
&left_dac_to_hp_right_amp_switch_control),
|
||||
SND_SOC_DAPM_SWITCH("Right dac to hp left amp", SND_SOC_NOPM, 0, 0,
|
||||
&right_dac_to_hp_left_amp_switch_control),
|
||||
SND_SOC_DAPM_SWITCH("Right dac to hp right amp", SND_SOC_NOPM, 0, 0,
|
||||
&right_dac_to_hp_right_amp_switch_control),
|
||||
SND_SOC_DAPM_OUT_DRV("HP amp left driver", AUDIO_IC_CODEC_CTRL0, 3, 0,
|
||||
NULL, 0),
|
||||
SND_SOC_DAPM_OUT_DRV("HP amp right driver", AUDIO_IC_CODEC_CTRL0, 3, 0,
|
||||
NULL, 0),
|
||||
|
||||
SND_SOC_DAPM_SWITCH("Left dac to speaker lineout", SND_SOC_NOPM, 0, 0,
|
||||
&left_dac_to_speaker_lineout_switch_control),
|
||||
SND_SOC_DAPM_SWITCH("Right dac to speaker lineout", SND_SOC_NOPM, 0, 0,
|
||||
&right_dac_to_speaker_lineout_switch_control),
|
||||
SND_SOC_DAPM_OUT_DRV("Speaker amp driver", AUDIO_IC_CODEC_CTRL0, 4, 0,
|
||||
NULL, 0),
|
||||
|
||||
SND_SOC_DAPM_OUTPUT("HPOUTL"),
|
||||
SND_SOC_DAPM_OUTPUT("HPOUTR"),
|
||||
SND_SOC_DAPM_OUTPUT("SPKOUT"),
|
||||
|
||||
SND_SOC_DAPM_ADC_E("ADC left", NULL, AUDIO_IC_CODEC_CTRL1, 8, 0,
|
||||
adc_enable_delay_event, SND_SOC_DAPM_POST_PMU),
|
||||
SND_SOC_DAPM_ADC_E("ADC right", NULL, AUDIO_IC_CODEC_CTRL1, 7, 0,
|
||||
adc_enable_delay_event, SND_SOC_DAPM_POST_PMU),
|
||||
SND_SOC_DAPM_MIXER("Left PGA mixer", AUDIO_IC_CODEC_CTRL1, 1, 0,
|
||||
&left_input_path_controls[0],
|
||||
ARRAY_SIZE(left_input_path_controls)),
|
||||
SND_SOC_DAPM_MIXER("Right PGA mixer", AUDIO_IC_CODEC_CTRL1, 0, 0,
|
||||
&right_input_path_controls[0],
|
||||
ARRAY_SIZE(right_input_path_controls)),
|
||||
|
||||
SND_SOC_DAPM_MUX("Mic input mode mux", SND_SOC_NOPM, 0, 0,
|
||||
&sirf_audio_codec_input_mode_control),
|
||||
SND_SOC_DAPM_MICBIAS("Mic Bias", AUDIO_IC_CODEC_PWR, 3, 0),
|
||||
SND_SOC_DAPM_INPUT("MICIN1"),
|
||||
SND_SOC_DAPM_INPUT("MICIN2"),
|
||||
SND_SOC_DAPM_INPUT("LINEIN1"),
|
||||
SND_SOC_DAPM_INPUT("LINEIN2"),
|
||||
|
||||
SND_SOC_DAPM_SUPPLY("HSL Phase Opposite", AUDIO_IC_CODEC_CTRL0,
|
||||
30, 0, NULL, 0),
|
||||
};
|
||||
|
||||
static const struct snd_soc_dapm_route sirf_audio_codec_map[] = {
|
||||
{"SPKOUT", NULL, "Speaker Driver"},
|
||||
{"Speaker Driver", NULL, "Speaker amp driver"},
|
||||
{"Speaker amp driver", NULL, "Left dac to speaker lineout"},
|
||||
{"Speaker amp driver", NULL, "Right dac to speaker lineout"},
|
||||
{"Left dac to speaker lineout", "Switch", "DAC left"},
|
||||
{"Right dac to speaker lineout", "Switch", "DAC right"},
|
||||
{"HPOUTL", NULL, "HP Left Driver"},
|
||||
{"HPOUTR", NULL, "HP Right Driver"},
|
||||
{"HP Left Driver", NULL, "HP amp left driver"},
|
||||
{"HP Right Driver", NULL, "HP amp right driver"},
|
||||
{"HP amp left driver", NULL, "Right dac to hp left amp"},
|
||||
{"HP amp right driver", NULL , "Right dac to hp right amp"},
|
||||
{"HP amp left driver", NULL, "Left dac to hp left amp"},
|
||||
{"HP amp right driver", NULL , "Right dac to hp right amp"},
|
||||
{"Right dac to hp left amp", "Switch", "DAC left"},
|
||||
{"Right dac to hp right amp", "Switch", "DAC right"},
|
||||
{"Left dac to hp left amp", "Switch", "DAC left"},
|
||||
{"Left dac to hp right amp", "Switch", "DAC right"},
|
||||
{"DAC left", NULL, "codecclk"},
|
||||
{"DAC right", NULL, "codecclk"},
|
||||
{"DAC left", NULL, "Playback"},
|
||||
{"DAC right", NULL, "Playback"},
|
||||
{"DAC left", NULL, "HSL Phase Opposite"},
|
||||
{"DAC right", NULL, "HSL Phase Opposite"},
|
||||
|
||||
{"Capture", NULL, "ADC left"},
|
||||
{"Capture", NULL, "ADC right"},
|
||||
{"ADC left", NULL, "codecclk"},
|
||||
{"ADC right", NULL, "codecclk"},
|
||||
{"ADC left", NULL, "Left PGA mixer"},
|
||||
{"ADC right", NULL, "Right PGA mixer"},
|
||||
{"Left PGA mixer", "Line Left Switch", "LINEIN2"},
|
||||
{"Right PGA mixer", "Line Right Switch", "LINEIN1"},
|
||||
{"Left PGA mixer", "Mic Left Switch", "MICIN2"},
|
||||
{"Right PGA mixer", "Mic Right Switch", "Mic input mode mux"},
|
||||
{"Mic input mode mux", "Single-ended", "MICIN1"},
|
||||
{"Mic input mode mux", "Differential", "MICIN1"},
|
||||
};
|
||||
|
||||
static int sirf_audio_codec_trigger(struct snd_pcm_substream *substream,
|
||||
int cmd,
|
||||
struct snd_soc_dai *dai)
|
||||
{
|
||||
int playback = substream->stream == SNDRV_PCM_STREAM_PLAYBACK;
|
||||
struct snd_soc_codec *codec = dai->codec;
|
||||
u32 val = 0;
|
||||
|
||||
/*
|
||||
* This is a workaround, When stop playback,
|
||||
* need disable HP amp, avoid the current noise.
|
||||
*/
|
||||
switch (cmd) {
|
||||
case SNDRV_PCM_TRIGGER_STOP:
|
||||
case SNDRV_PCM_TRIGGER_SUSPEND:
|
||||
case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
|
||||
break;
|
||||
case SNDRV_PCM_TRIGGER_START:
|
||||
case SNDRV_PCM_TRIGGER_RESUME:
|
||||
case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
|
||||
if (playback)
|
||||
val = IC_HSLEN | IC_HSREN;
|
||||
break;
|
||||
default:
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (playback)
|
||||
snd_soc_update_bits(codec, AUDIO_IC_CODEC_CTRL0,
|
||||
IC_HSLEN | IC_HSREN, val);
|
||||
return 0;
|
||||
}
|
||||
|
||||
struct snd_soc_dai_ops sirf_audio_codec_dai_ops = {
|
||||
.trigger = sirf_audio_codec_trigger,
|
||||
};
|
||||
|
||||
struct snd_soc_dai_driver sirf_audio_codec_dai = {
|
||||
.name = "sirf-audio-codec",
|
||||
.playback = {
|
||||
.stream_name = "Playback",
|
||||
.channels_min = 2,
|
||||
.channels_max = 2,
|
||||
.rates = SNDRV_PCM_RATE_48000,
|
||||
.formats = SNDRV_PCM_FMTBIT_S16_LE,
|
||||
},
|
||||
.capture = {
|
||||
.stream_name = "Capture",
|
||||
.channels_min = 1,
|
||||
.channels_max = 2,
|
||||
.rates = SNDRV_PCM_RATE_48000,
|
||||
.formats = SNDRV_PCM_FMTBIT_S16_LE,
|
||||
},
|
||||
.ops = &sirf_audio_codec_dai_ops,
|
||||
};
|
||||
|
||||
static int sirf_audio_codec_probe(struct snd_soc_codec *codec)
|
||||
{
|
||||
int ret;
|
||||
struct snd_soc_dapm_context *dapm = &codec->dapm;
|
||||
struct sirf_audio_codec *sirf_audio_codec = snd_soc_codec_get_drvdata(codec);
|
||||
|
||||
pm_runtime_enable(codec->dev);
|
||||
codec->control_data = sirf_audio_codec->regmap;
|
||||
|
||||
ret = snd_soc_codec_set_cache_io(codec, 0, 0, SND_SOC_REGMAP);
|
||||
if (ret != 0) {
|
||||
dev_err(codec->dev, "Failed to set cache I/O: %d\n", ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
if (of_device_is_compatible(codec->dev->of_node, "sirf,prima2-audio-codec")) {
|
||||
snd_soc_dapm_new_controls(dapm,
|
||||
prima2_output_driver_dapm_widgets,
|
||||
ARRAY_SIZE(prima2_output_driver_dapm_widgets));
|
||||
snd_soc_dapm_new_controls(dapm,
|
||||
&prima2_codec_clock_dapm_widget, 1);
|
||||
return snd_soc_add_codec_controls(codec,
|
||||
volume_controls_prima2,
|
||||
ARRAY_SIZE(volume_controls_prima2));
|
||||
}
|
||||
if (of_device_is_compatible(codec->dev->of_node, "sirf,atlas6-audio-codec")) {
|
||||
snd_soc_dapm_new_controls(dapm,
|
||||
atlas6_output_driver_dapm_widgets,
|
||||
ARRAY_SIZE(atlas6_output_driver_dapm_widgets));
|
||||
snd_soc_dapm_new_controls(dapm,
|
||||
&atlas6_codec_clock_dapm_widget, 1);
|
||||
return snd_soc_add_codec_controls(codec,
|
||||
volume_controls_atlas6,
|
||||
ARRAY_SIZE(volume_controls_atlas6));
|
||||
}
|
||||
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
static int sirf_audio_codec_remove(struct snd_soc_codec *codec)
|
||||
{
|
||||
pm_runtime_disable(codec->dev);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static struct snd_soc_codec_driver soc_codec_device_sirf_audio_codec = {
|
||||
.probe = sirf_audio_codec_probe,
|
||||
.remove = sirf_audio_codec_remove,
|
||||
.dapm_widgets = sirf_audio_codec_dapm_widgets,
|
||||
.num_dapm_widgets = ARRAY_SIZE(sirf_audio_codec_dapm_widgets),
|
||||
.dapm_routes = sirf_audio_codec_map,
|
||||
.num_dapm_routes = ARRAY_SIZE(sirf_audio_codec_map),
|
||||
.idle_bias_off = true,
|
||||
};
|
||||
|
||||
static const struct of_device_id sirf_audio_codec_of_match[] = {
|
||||
{ .compatible = "sirf,prima2-audio-codec" },
|
||||
{ .compatible = "sirf,atlas6-audio-codec" },
|
||||
{}
|
||||
};
|
||||
MODULE_DEVICE_TABLE(of, sirf_audio_codec_of_match);
|
||||
|
||||
static const struct regmap_config sirf_audio_codec_regmap_config = {
|
||||
.reg_bits = 32,
|
||||
.reg_stride = 4,
|
||||
.val_bits = 32,
|
||||
.max_register = AUDIO_IC_CODEC_CTRL3,
|
||||
.cache_type = REGCACHE_NONE,
|
||||
};
|
||||
|
||||
static int sirf_audio_codec_driver_probe(struct platform_device *pdev)
|
||||
{
|
||||
int ret;
|
||||
struct sirf_audio_codec *sirf_audio_codec;
|
||||
void __iomem *base;
|
||||
struct resource *mem_res;
|
||||
const struct of_device_id *match;
|
||||
|
||||
match = of_match_node(sirf_audio_codec_of_match, pdev->dev.of_node);
|
||||
|
||||
sirf_audio_codec = devm_kzalloc(&pdev->dev,
|
||||
sizeof(struct sirf_audio_codec), GFP_KERNEL);
|
||||
if (!sirf_audio_codec)
|
||||
return -ENOMEM;
|
||||
|
||||
platform_set_drvdata(pdev, sirf_audio_codec);
|
||||
|
||||
mem_res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
|
||||
base = devm_ioremap_resource(&pdev->dev, mem_res);
|
||||
if (base == NULL)
|
||||
return -ENOMEM;
|
||||
|
||||
sirf_audio_codec->regmap = devm_regmap_init_mmio(&pdev->dev, base,
|
||||
&sirf_audio_codec_regmap_config);
|
||||
if (IS_ERR(sirf_audio_codec->regmap))
|
||||
return PTR_ERR(sirf_audio_codec->regmap);
|
||||
|
||||
sirf_audio_codec->clk = devm_clk_get(&pdev->dev, NULL);
|
||||
if (IS_ERR(sirf_audio_codec->clk)) {
|
||||
dev_err(&pdev->dev, "Get clock failed.\n");
|
||||
return PTR_ERR(sirf_audio_codec->clk);
|
||||
}
|
||||
|
||||
ret = clk_prepare_enable(sirf_audio_codec->clk);
|
||||
if (ret) {
|
||||
dev_err(&pdev->dev, "Enable clock failed.\n");
|
||||
return ret;
|
||||
}
|
||||
|
||||
ret = snd_soc_register_codec(&(pdev->dev),
|
||||
&soc_codec_device_sirf_audio_codec,
|
||||
&sirf_audio_codec_dai, 1);
|
||||
if (ret) {
|
||||
dev_err(&pdev->dev, "Register Audio Codec dai failed.\n");
|
||||
goto err_clk_put;
|
||||
}
|
||||
|
||||
/*
|
||||
* Always open charge pump, if not, when the charge pump closed the
|
||||
* adc will not stable
|
||||
*/
|
||||
regmap_update_bits(sirf_audio_codec->regmap, AUDIO_IC_CODEC_CTRL0,
|
||||
IC_CPFREQ, IC_CPFREQ);
|
||||
|
||||
if (of_device_is_compatible(pdev->dev.of_node, "sirf,atlas6-audio-codec"))
|
||||
regmap_update_bits(sirf_audio_codec->regmap,
|
||||
AUDIO_IC_CODEC_CTRL0, IC_CPEN, IC_CPEN);
|
||||
return 0;
|
||||
|
||||
err_clk_put:
|
||||
clk_disable_unprepare(sirf_audio_codec->clk);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int sirf_audio_codec_driver_remove(struct platform_device *pdev)
|
||||
{
|
||||
struct sirf_audio_codec *sirf_audio_codec = platform_get_drvdata(pdev);
|
||||
|
||||
clk_disable_unprepare(sirf_audio_codec->clk);
|
||||
snd_soc_unregister_codec(&(pdev->dev));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_PM_SLEEP
|
||||
static int sirf_audio_codec_suspend(struct device *dev)
|
||||
{
|
||||
struct sirf_audio_codec *sirf_audio_codec = dev_get_drvdata(dev);
|
||||
|
||||
regmap_read(sirf_audio_codec->regmap, AUDIO_IC_CODEC_CTRL0,
|
||||
&sirf_audio_codec->reg_ctrl0);
|
||||
regmap_read(sirf_audio_codec->regmap, AUDIO_IC_CODEC_CTRL1,
|
||||
&sirf_audio_codec->reg_ctrl1);
|
||||
clk_disable_unprepare(sirf_audio_codec->clk);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int sirf_audio_codec_resume(struct device *dev)
|
||||
{
|
||||
struct sirf_audio_codec *sirf_audio_codec = dev_get_drvdata(dev);
|
||||
int ret;
|
||||
|
||||
ret = clk_prepare_enable(sirf_audio_codec->clk);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
regmap_write(sirf_audio_codec->regmap, AUDIO_IC_CODEC_CTRL0,
|
||||
sirf_audio_codec->reg_ctrl0);
|
||||
regmap_write(sirf_audio_codec->regmap, AUDIO_IC_CODEC_CTRL1,
|
||||
sirf_audio_codec->reg_ctrl1);
|
||||
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
static const struct dev_pm_ops sirf_audio_codec_pm_ops = {
|
||||
SET_SYSTEM_SLEEP_PM_OPS(sirf_audio_codec_suspend, sirf_audio_codec_resume)
|
||||
};
|
||||
|
||||
static struct platform_driver sirf_audio_codec_driver = {
|
||||
.driver = {
|
||||
.name = "sirf-audio-codec",
|
||||
.owner = THIS_MODULE,
|
||||
.of_match_table = sirf_audio_codec_of_match,
|
||||
.pm = &sirf_audio_codec_pm_ops,
|
||||
},
|
||||
.probe = sirf_audio_codec_driver_probe,
|
||||
.remove = sirf_audio_codec_driver_remove,
|
||||
};
|
||||
|
||||
module_platform_driver(sirf_audio_codec_driver);
|
||||
|
||||
MODULE_DESCRIPTION("SiRF audio codec driver");
|
||||
MODULE_AUTHOR("RongJun Ying <Rongjun.Ying@csr.com>");
|
||||
MODULE_LICENSE("GPL v2");
|
75
sound/soc/codecs/sirf-audio-codec.h
Normal file
75
sound/soc/codecs/sirf-audio-codec.h
Normal file
|
@ -0,0 +1,75 @@
|
|||
/*
|
||||
* SiRF inner codec controllers define
|
||||
*
|
||||
* Copyright (c) 2011 Cambridge Silicon Radio Limited, a CSR plc group company.
|
||||
*
|
||||
* Licensed under GPLv2 or later.
|
||||
*/
|
||||
|
||||
#ifndef _SIRF_AUDIO_CODEC_H
|
||||
#define _SIRF_AUDIO_CODEC_H
|
||||
|
||||
|
||||
#define AUDIO_IC_CODEC_PWR (0x00E0)
|
||||
#define AUDIO_IC_CODEC_CTRL0 (0x00E4)
|
||||
#define AUDIO_IC_CODEC_CTRL1 (0x00E8)
|
||||
#define AUDIO_IC_CODEC_CTRL2 (0x00EC)
|
||||
#define AUDIO_IC_CODEC_CTRL3 (0x00F0)
|
||||
|
||||
#define MICBIASEN (1 << 3)
|
||||
|
||||
#define IC_RDACEN (1 << 0)
|
||||
#define IC_LDACEN (1 << 1)
|
||||
#define IC_HSREN (1 << 2)
|
||||
#define IC_HSLEN (1 << 3)
|
||||
#define IC_SPEN (1 << 4)
|
||||
#define IC_CPEN (1 << 5)
|
||||
|
||||
#define IC_HPRSELR (1 << 6)
|
||||
#define IC_HPLSELR (1 << 7)
|
||||
#define IC_HPRSELL (1 << 8)
|
||||
#define IC_HPLSELL (1 << 9)
|
||||
#define IC_SPSELR (1 << 10)
|
||||
#define IC_SPSELL (1 << 11)
|
||||
|
||||
#define IC_MONOR (1 << 12)
|
||||
#define IC_MONOL (1 << 13)
|
||||
|
||||
#define IC_RXOSRSEL (1 << 28)
|
||||
#define IC_CPFREQ (1 << 29)
|
||||
#define IC_HSINVEN (1 << 30)
|
||||
|
||||
#define IC_MICINREN (1 << 0)
|
||||
#define IC_MICINLEN (1 << 1)
|
||||
#define IC_MICIN1SEL (1 << 2)
|
||||
#define IC_MICIN2SEL (1 << 3)
|
||||
#define IC_MICDIFSEL (1 << 4)
|
||||
#define IC_LINEIN1SEL (1 << 5)
|
||||
#define IC_LINEIN2SEL (1 << 6)
|
||||
#define IC_RADCEN (1 << 7)
|
||||
#define IC_LADCEN (1 << 8)
|
||||
#define IC_ALM (1 << 9)
|
||||
|
||||
#define IC_DIGMICEN (1 << 22)
|
||||
#define IC_DIGMICFREQ (1 << 23)
|
||||
#define IC_ADC14B_12 (1 << 24)
|
||||
#define IC_FIRDAC_HSL_EN (1 << 25)
|
||||
#define IC_FIRDAC_HSR_EN (1 << 26)
|
||||
#define IC_FIRDAC_LOUT_EN (1 << 27)
|
||||
#define IC_POR (1 << 28)
|
||||
#define IC_CODEC_CLK_EN (1 << 29)
|
||||
#define IC_HP_3DB_BOOST (1 << 30)
|
||||
|
||||
#define IC_ADC_LEFT_GAIN_SHIFT 16
|
||||
#define IC_ADC_RIGHT_GAIN_SHIFT 10
|
||||
#define IC_ADC_GAIN_MASK 0x3F
|
||||
#define IC_MIC_MAX_GAIN 0x39
|
||||
|
||||
#define IC_RXPGAR_MASK 0x3F
|
||||
#define IC_RXPGAR_SHIFT 14
|
||||
#define IC_RXPGAL_MASK 0x3F
|
||||
#define IC_RXPGAL_SHIFT 21
|
||||
#define IC_RXPGAR 0x7B
|
||||
#define IC_RXPGAL 0x7B
|
||||
|
||||
#endif /*__SIRF_AUDIO_CODEC_H*/
|
|
@ -312,14 +312,14 @@ static int sn95031_dmic56_event(struct snd_soc_dapm_widget *w,
|
|||
/* mux controls */
|
||||
static const char *sn95031_mic_texts[] = { "AMIC", "LineIn" };
|
||||
|
||||
static const struct soc_enum sn95031_micl_enum =
|
||||
SOC_ENUM_SINGLE(SN95031_ADCCONFIG, 1, 2, sn95031_mic_texts);
|
||||
static SOC_ENUM_SINGLE_DECL(sn95031_micl_enum,
|
||||
SN95031_ADCCONFIG, 1, sn95031_mic_texts);
|
||||
|
||||
static const struct snd_kcontrol_new sn95031_micl_mux_control =
|
||||
SOC_DAPM_ENUM("Route", sn95031_micl_enum);
|
||||
|
||||
static const struct soc_enum sn95031_micr_enum =
|
||||
SOC_ENUM_SINGLE(SN95031_ADCCONFIG, 3, 2, sn95031_mic_texts);
|
||||
static SOC_ENUM_SINGLE_DECL(sn95031_micr_enum,
|
||||
SN95031_ADCCONFIG, 3, sn95031_mic_texts);
|
||||
|
||||
static const struct snd_kcontrol_new sn95031_micr_mux_control =
|
||||
SOC_DAPM_ENUM("Route", sn95031_micr_enum);
|
||||
|
@ -328,26 +328,26 @@ static const char *sn95031_input_texts[] = { "DMIC1", "DMIC2", "DMIC3",
|
|||
"DMIC4", "DMIC5", "DMIC6",
|
||||
"ADC Left", "ADC Right" };
|
||||
|
||||
static const struct soc_enum sn95031_input1_enum =
|
||||
SOC_ENUM_SINGLE(SN95031_AUDIOMUX12, 0, 8, sn95031_input_texts);
|
||||
static SOC_ENUM_SINGLE_DECL(sn95031_input1_enum,
|
||||
SN95031_AUDIOMUX12, 0, sn95031_input_texts);
|
||||
|
||||
static const struct snd_kcontrol_new sn95031_input1_mux_control =
|
||||
SOC_DAPM_ENUM("Route", sn95031_input1_enum);
|
||||
|
||||
static const struct soc_enum sn95031_input2_enum =
|
||||
SOC_ENUM_SINGLE(SN95031_AUDIOMUX12, 4, 8, sn95031_input_texts);
|
||||
static SOC_ENUM_SINGLE_DECL(sn95031_input2_enum,
|
||||
SN95031_AUDIOMUX12, 4, sn95031_input_texts);
|
||||
|
||||
static const struct snd_kcontrol_new sn95031_input2_mux_control =
|
||||
SOC_DAPM_ENUM("Route", sn95031_input2_enum);
|
||||
|
||||
static const struct soc_enum sn95031_input3_enum =
|
||||
SOC_ENUM_SINGLE(SN95031_AUDIOMUX34, 0, 8, sn95031_input_texts);
|
||||
static SOC_ENUM_SINGLE_DECL(sn95031_input3_enum,
|
||||
SN95031_AUDIOMUX34, 0, sn95031_input_texts);
|
||||
|
||||
static const struct snd_kcontrol_new sn95031_input3_mux_control =
|
||||
SOC_DAPM_ENUM("Route", sn95031_input3_enum);
|
||||
|
||||
static const struct soc_enum sn95031_input4_enum =
|
||||
SOC_ENUM_SINGLE(SN95031_AUDIOMUX34, 4, 8, sn95031_input_texts);
|
||||
static SOC_ENUM_SINGLE_DECL(sn95031_input4_enum,
|
||||
SN95031_AUDIOMUX34, 4, sn95031_input_texts);
|
||||
|
||||
static const struct snd_kcontrol_new sn95031_input4_mux_control =
|
||||
SOC_DAPM_ENUM("Route", sn95031_input4_enum);
|
||||
|
@ -359,19 +359,19 @@ static const char *sn95031_micmode_text[] = {"Single Ended", "Differential"};
|
|||
/* 0dB to 30dB in 10dB steps */
|
||||
static const DECLARE_TLV_DB_SCALE(mic_tlv, 0, 10, 0);
|
||||
|
||||
static const struct soc_enum sn95031_micmode1_enum =
|
||||
SOC_ENUM_SINGLE(SN95031_MICAMP1, 1, 2, sn95031_micmode_text);
|
||||
static const struct soc_enum sn95031_micmode2_enum =
|
||||
SOC_ENUM_SINGLE(SN95031_MICAMP2, 1, 2, sn95031_micmode_text);
|
||||
static SOC_ENUM_SINGLE_DECL(sn95031_micmode1_enum,
|
||||
SN95031_MICAMP1, 1, sn95031_micmode_text);
|
||||
static SOC_ENUM_SINGLE_DECL(sn95031_micmode2_enum,
|
||||
SN95031_MICAMP2, 1, sn95031_micmode_text);
|
||||
|
||||
static const char *sn95031_dmic_cfg_text[] = {"GPO", "DMIC"};
|
||||
|
||||
static const struct soc_enum sn95031_dmic12_cfg_enum =
|
||||
SOC_ENUM_SINGLE(SN95031_DMICMUX, 0, 2, sn95031_dmic_cfg_text);
|
||||
static const struct soc_enum sn95031_dmic34_cfg_enum =
|
||||
SOC_ENUM_SINGLE(SN95031_DMICMUX, 1, 2, sn95031_dmic_cfg_text);
|
||||
static const struct soc_enum sn95031_dmic56_cfg_enum =
|
||||
SOC_ENUM_SINGLE(SN95031_DMICMUX, 2, 2, sn95031_dmic_cfg_text);
|
||||
static SOC_ENUM_SINGLE_DECL(sn95031_dmic12_cfg_enum,
|
||||
SN95031_DMICMUX, 0, sn95031_dmic_cfg_text);
|
||||
static SOC_ENUM_SINGLE_DECL(sn95031_dmic34_cfg_enum,
|
||||
SN95031_DMICMUX, 1, sn95031_dmic_cfg_text);
|
||||
static SOC_ENUM_SINGLE_DECL(sn95031_dmic56_cfg_enum,
|
||||
SN95031_DMICMUX, 2, sn95031_dmic_cfg_text);
|
||||
|
||||
static const struct snd_kcontrol_new sn95031_snd_controls[] = {
|
||||
SOC_ENUM("Mic1Mode Capture Route", sn95031_micmode1_enum),
|
||||
|
|
57
sound/soc/codecs/ssm2602-i2c.c
Normal file
57
sound/soc/codecs/ssm2602-i2c.c
Normal file
|
@ -0,0 +1,57 @@
|
|||
/*
|
||||
* SSM2602/SSM2603/SSM2604 I2C audio driver
|
||||
*
|
||||
* Copyright 2014 Analog Devices Inc.
|
||||
*
|
||||
* Licensed under the GPL-2.
|
||||
*/
|
||||
|
||||
#include <linux/module.h>
|
||||
#include <linux/i2c.h>
|
||||
#include <linux/regmap.h>
|
||||
|
||||
#include <sound/soc.h>
|
||||
|
||||
#include "ssm2602.h"
|
||||
|
||||
/*
|
||||
* ssm2602 2 wire address is determined by GPIO5
|
||||
* state during powerup.
|
||||
* low = 0x1a
|
||||
* high = 0x1b
|
||||
*/
|
||||
static int ssm2602_i2c_probe(struct i2c_client *client,
|
||||
const struct i2c_device_id *id)
|
||||
{
|
||||
return ssm2602_probe(&client->dev, id->driver_data,
|
||||
devm_regmap_init_i2c(client, &ssm2602_regmap_config));
|
||||
}
|
||||
|
||||
static int ssm2602_i2c_remove(struct i2c_client *client)
|
||||
{
|
||||
snd_soc_unregister_codec(&client->dev);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const struct i2c_device_id ssm2602_i2c_id[] = {
|
||||
{ "ssm2602", SSM2602 },
|
||||
{ "ssm2603", SSM2602 },
|
||||
{ "ssm2604", SSM2604 },
|
||||
{ }
|
||||
};
|
||||
MODULE_DEVICE_TABLE(i2c, ssm2602_i2c_id);
|
||||
|
||||
static struct i2c_driver ssm2602_i2c_driver = {
|
||||
.driver = {
|
||||
.name = "ssm2602",
|
||||
.owner = THIS_MODULE,
|
||||
},
|
||||
.probe = ssm2602_i2c_probe,
|
||||
.remove = ssm2602_i2c_remove,
|
||||
.id_table = ssm2602_i2c_id,
|
||||
};
|
||||
module_i2c_driver(ssm2602_i2c_driver);
|
||||
|
||||
MODULE_DESCRIPTION("ASoC SSM2602/SSM2603/SSM2604 I2C driver");
|
||||
MODULE_AUTHOR("Cliff Cai");
|
||||
MODULE_LICENSE("GPL");
|
41
sound/soc/codecs/ssm2602-spi.c
Normal file
41
sound/soc/codecs/ssm2602-spi.c
Normal file
|
@ -0,0 +1,41 @@
|
|||
/*
|
||||
* SSM2602 SPI audio driver
|
||||
*
|
||||
* Copyright 2014 Analog Devices Inc.
|
||||
*
|
||||
* Licensed under the GPL-2.
|
||||
*/
|
||||
|
||||
#include <linux/module.h>
|
||||
#include <linux/spi/spi.h>
|
||||
#include <linux/regmap.h>
|
||||
|
||||
#include <sound/soc.h>
|
||||
|
||||
#include "ssm2602.h"
|
||||
|
||||
static int ssm2602_spi_probe(struct spi_device *spi)
|
||||
{
|
||||
return ssm2602_probe(&spi->dev, SSM2602,
|
||||
devm_regmap_init_spi(spi, &ssm2602_regmap_config));
|
||||
}
|
||||
|
||||
static int ssm2602_spi_remove(struct spi_device *spi)
|
||||
{
|
||||
snd_soc_unregister_codec(&spi->dev);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static struct spi_driver ssm2602_spi_driver = {
|
||||
.driver = {
|
||||
.name = "ssm2602",
|
||||
.owner = THIS_MODULE,
|
||||
},
|
||||
.probe = ssm2602_spi_probe,
|
||||
.remove = ssm2602_spi_remove,
|
||||
};
|
||||
module_spi_driver(ssm2602_spi_driver);
|
||||
|
||||
MODULE_DESCRIPTION("ASoC SSM2602 SPI driver");
|
||||
MODULE_AUTHOR("Cliff Cai");
|
||||
MODULE_LICENSE("GPL");
|
|
@ -27,32 +27,20 @@
|
|||
*/
|
||||
|
||||
#include <linux/module.h>
|
||||
#include <linux/moduleparam.h>
|
||||
#include <linux/init.h>
|
||||
#include <linux/delay.h>
|
||||
#include <linux/pm.h>
|
||||
#include <linux/i2c.h>
|
||||
#include <linux/spi/spi.h>
|
||||
#include <linux/regmap.h>
|
||||
#include <linux/slab.h>
|
||||
#include <sound/core.h>
|
||||
|
||||
#include <sound/pcm.h>
|
||||
#include <sound/pcm_params.h>
|
||||
#include <sound/soc.h>
|
||||
#include <sound/initval.h>
|
||||
#include <sound/tlv.h>
|
||||
|
||||
#include "ssm2602.h"
|
||||
|
||||
enum ssm2602_type {
|
||||
SSM2602,
|
||||
SSM2604,
|
||||
};
|
||||
|
||||
/* codec private data */
|
||||
struct ssm2602_priv {
|
||||
unsigned int sysclk;
|
||||
struct snd_pcm_hw_constraint_list *sysclk_constraints;
|
||||
const struct snd_pcm_hw_constraint_list *sysclk_constraints;
|
||||
|
||||
struct regmap *regmap;
|
||||
|
||||
|
@ -75,15 +63,16 @@ static const u16 ssm2602_reg[SSM2602_CACHEREGNUM] = {
|
|||
|
||||
/*Appending several "None"s just for OSS mixer use*/
|
||||
static const char *ssm2602_input_select[] = {
|
||||
"Line", "Mic", "None", "None", "None",
|
||||
"None", "None", "None",
|
||||
"Line", "Mic",
|
||||
};
|
||||
|
||||
static const char *ssm2602_deemph[] = {"None", "32Khz", "44.1Khz", "48Khz"};
|
||||
|
||||
static const struct soc_enum ssm2602_enum[] = {
|
||||
SOC_ENUM_SINGLE(SSM2602_APANA, 2, 2, ssm2602_input_select),
|
||||
SOC_ENUM_SINGLE(SSM2602_APDIGI, 1, 4, ssm2602_deemph),
|
||||
SOC_ENUM_SINGLE(SSM2602_APANA, 2, ARRAY_SIZE(ssm2602_input_select),
|
||||
ssm2602_input_select),
|
||||
SOC_ENUM_SINGLE(SSM2602_APDIGI, 1, ARRAY_SIZE(ssm2602_deemph),
|
||||
ssm2602_deemph),
|
||||
};
|
||||
|
||||
static const unsigned int ssm260x_outmix_tlv[] = {
|
||||
|
@ -197,7 +186,7 @@ static const unsigned int ssm2602_rates_12288000[] = {
|
|||
8000, 16000, 32000, 48000, 96000,
|
||||
};
|
||||
|
||||
static struct snd_pcm_hw_constraint_list ssm2602_constraints_12288000 = {
|
||||
static const struct snd_pcm_hw_constraint_list ssm2602_constraints_12288000 = {
|
||||
.list = ssm2602_rates_12288000,
|
||||
.count = ARRAY_SIZE(ssm2602_rates_12288000),
|
||||
};
|
||||
|
@ -206,7 +195,7 @@ static const unsigned int ssm2602_rates_11289600[] = {
|
|||
8000, 44100, 88200,
|
||||
};
|
||||
|
||||
static struct snd_pcm_hw_constraint_list ssm2602_constraints_11289600 = {
|
||||
static const struct snd_pcm_hw_constraint_list ssm2602_constraints_11289600 = {
|
||||
.list = ssm2602_rates_11289600,
|
||||
.count = ARRAY_SIZE(ssm2602_rates_11289600),
|
||||
};
|
||||
|
@ -529,7 +518,7 @@ static int ssm2602_resume(struct snd_soc_codec *codec)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int ssm2602_probe(struct snd_soc_codec *codec)
|
||||
static int ssm2602_codec_probe(struct snd_soc_codec *codec)
|
||||
{
|
||||
struct ssm2602_priv *ssm2602 = snd_soc_codec_get_drvdata(codec);
|
||||
struct snd_soc_dapm_context *dapm = &codec->dapm;
|
||||
|
@ -554,7 +543,7 @@ static int ssm2602_probe(struct snd_soc_codec *codec)
|
|||
ARRAY_SIZE(ssm2602_routes));
|
||||
}
|
||||
|
||||
static int ssm2604_probe(struct snd_soc_codec *codec)
|
||||
static int ssm2604_codec_probe(struct snd_soc_codec *codec)
|
||||
{
|
||||
struct snd_soc_dapm_context *dapm = &codec->dapm;
|
||||
int ret;
|
||||
|
@ -568,7 +557,7 @@ static int ssm2604_probe(struct snd_soc_codec *codec)
|
|||
ARRAY_SIZE(ssm2604_routes));
|
||||
}
|
||||
|
||||
static int ssm260x_probe(struct snd_soc_codec *codec)
|
||||
static int ssm260x_codec_probe(struct snd_soc_codec *codec)
|
||||
{
|
||||
struct ssm2602_priv *ssm2602 = snd_soc_codec_get_drvdata(codec);
|
||||
int ret;
|
||||
|
@ -597,10 +586,10 @@ static int ssm260x_probe(struct snd_soc_codec *codec)
|
|||
|
||||
switch (ssm2602->type) {
|
||||
case SSM2602:
|
||||
ret = ssm2602_probe(codec);
|
||||
ret = ssm2602_codec_probe(codec);
|
||||
break;
|
||||
case SSM2604:
|
||||
ret = ssm2604_probe(codec);
|
||||
ret = ssm2604_codec_probe(codec);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -620,7 +609,7 @@ static int ssm2602_remove(struct snd_soc_codec *codec)
|
|||
}
|
||||
|
||||
static struct snd_soc_codec_driver soc_codec_dev_ssm2602 = {
|
||||
.probe = ssm260x_probe,
|
||||
.probe = ssm260x_codec_probe,
|
||||
.remove = ssm2602_remove,
|
||||
.suspend = ssm2602_suspend,
|
||||
.resume = ssm2602_resume,
|
||||
|
@ -639,7 +628,7 @@ static bool ssm2602_register_volatile(struct device *dev, unsigned int reg)
|
|||
return reg == SSM2602_RESET;
|
||||
}
|
||||
|
||||
static const struct regmap_config ssm2602_regmap_config = {
|
||||
const struct regmap_config ssm2602_regmap_config = {
|
||||
.val_bits = 9,
|
||||
.reg_bits = 7,
|
||||
|
||||
|
@ -650,134 +639,28 @@ static const struct regmap_config ssm2602_regmap_config = {
|
|||
.reg_defaults_raw = ssm2602_reg,
|
||||
.num_reg_defaults_raw = ARRAY_SIZE(ssm2602_reg),
|
||||
};
|
||||
EXPORT_SYMBOL_GPL(ssm2602_regmap_config);
|
||||
|
||||
#if defined(CONFIG_SPI_MASTER)
|
||||
static int ssm2602_spi_probe(struct spi_device *spi)
|
||||
int ssm2602_probe(struct device *dev, enum ssm2602_type type,
|
||||
struct regmap *regmap)
|
||||
{
|
||||
struct ssm2602_priv *ssm2602;
|
||||
int ret;
|
||||
|
||||
ssm2602 = devm_kzalloc(&spi->dev, sizeof(struct ssm2602_priv),
|
||||
GFP_KERNEL);
|
||||
if (IS_ERR(regmap))
|
||||
return PTR_ERR(regmap);
|
||||
|
||||
ssm2602 = devm_kzalloc(dev, sizeof(*ssm2602), GFP_KERNEL);
|
||||
if (ssm2602 == NULL)
|
||||
return -ENOMEM;
|
||||
|
||||
spi_set_drvdata(spi, ssm2602);
|
||||
dev_set_drvdata(dev, ssm2602);
|
||||
ssm2602->type = SSM2602;
|
||||
ssm2602->regmap = regmap;
|
||||
|
||||
ssm2602->regmap = devm_regmap_init_spi(spi, &ssm2602_regmap_config);
|
||||
if (IS_ERR(ssm2602->regmap))
|
||||
return PTR_ERR(ssm2602->regmap);
|
||||
|
||||
ret = snd_soc_register_codec(&spi->dev,
|
||||
&soc_codec_dev_ssm2602, &ssm2602_dai, 1);
|
||||
return ret;
|
||||
return snd_soc_register_codec(dev, &soc_codec_dev_ssm2602,
|
||||
&ssm2602_dai, 1);
|
||||
}
|
||||
|
||||
static int ssm2602_spi_remove(struct spi_device *spi)
|
||||
{
|
||||
snd_soc_unregister_codec(&spi->dev);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static struct spi_driver ssm2602_spi_driver = {
|
||||
.driver = {
|
||||
.name = "ssm2602",
|
||||
.owner = THIS_MODULE,
|
||||
},
|
||||
.probe = ssm2602_spi_probe,
|
||||
.remove = ssm2602_spi_remove,
|
||||
};
|
||||
#endif
|
||||
|
||||
#if IS_ENABLED(CONFIG_I2C)
|
||||
/*
|
||||
* ssm2602 2 wire address is determined by GPIO5
|
||||
* state during powerup.
|
||||
* low = 0x1a
|
||||
* high = 0x1b
|
||||
*/
|
||||
static int ssm2602_i2c_probe(struct i2c_client *i2c,
|
||||
const struct i2c_device_id *id)
|
||||
{
|
||||
struct ssm2602_priv *ssm2602;
|
||||
int ret;
|
||||
|
||||
ssm2602 = devm_kzalloc(&i2c->dev, sizeof(struct ssm2602_priv),
|
||||
GFP_KERNEL);
|
||||
if (ssm2602 == NULL)
|
||||
return -ENOMEM;
|
||||
|
||||
i2c_set_clientdata(i2c, ssm2602);
|
||||
ssm2602->type = id->driver_data;
|
||||
|
||||
ssm2602->regmap = devm_regmap_init_i2c(i2c, &ssm2602_regmap_config);
|
||||
if (IS_ERR(ssm2602->regmap))
|
||||
return PTR_ERR(ssm2602->regmap);
|
||||
|
||||
ret = snd_soc_register_codec(&i2c->dev,
|
||||
&soc_codec_dev_ssm2602, &ssm2602_dai, 1);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int ssm2602_i2c_remove(struct i2c_client *client)
|
||||
{
|
||||
snd_soc_unregister_codec(&client->dev);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const struct i2c_device_id ssm2602_i2c_id[] = {
|
||||
{ "ssm2602", SSM2602 },
|
||||
{ "ssm2603", SSM2602 },
|
||||
{ "ssm2604", SSM2604 },
|
||||
{ }
|
||||
};
|
||||
MODULE_DEVICE_TABLE(i2c, ssm2602_i2c_id);
|
||||
|
||||
/* corgi i2c codec control layer */
|
||||
static struct i2c_driver ssm2602_i2c_driver = {
|
||||
.driver = {
|
||||
.name = "ssm2602",
|
||||
.owner = THIS_MODULE,
|
||||
},
|
||||
.probe = ssm2602_i2c_probe,
|
||||
.remove = ssm2602_i2c_remove,
|
||||
.id_table = ssm2602_i2c_id,
|
||||
};
|
||||
#endif
|
||||
|
||||
|
||||
static int __init ssm2602_modinit(void)
|
||||
{
|
||||
int ret = 0;
|
||||
|
||||
#if defined(CONFIG_SPI_MASTER)
|
||||
ret = spi_register_driver(&ssm2602_spi_driver);
|
||||
if (ret)
|
||||
return ret;
|
||||
#endif
|
||||
|
||||
#if IS_ENABLED(CONFIG_I2C)
|
||||
ret = i2c_add_driver(&ssm2602_i2c_driver);
|
||||
if (ret)
|
||||
return ret;
|
||||
#endif
|
||||
|
||||
return ret;
|
||||
}
|
||||
module_init(ssm2602_modinit);
|
||||
|
||||
static void __exit ssm2602_exit(void)
|
||||
{
|
||||
#if defined(CONFIG_SPI_MASTER)
|
||||
spi_unregister_driver(&ssm2602_spi_driver);
|
||||
#endif
|
||||
|
||||
#if IS_ENABLED(CONFIG_I2C)
|
||||
i2c_del_driver(&ssm2602_i2c_driver);
|
||||
#endif
|
||||
}
|
||||
module_exit(ssm2602_exit);
|
||||
EXPORT_SYMBOL_GPL(ssm2602_probe);
|
||||
|
||||
MODULE_DESCRIPTION("ASoC SSM2602/SSM2603/SSM2604 driver");
|
||||
MODULE_AUTHOR("Cliff Cai");
|
||||
|
|
|
@ -28,6 +28,20 @@
|
|||
#ifndef _SSM2602_H
|
||||
#define _SSM2602_H
|
||||
|
||||
#include <linux/regmap.h>
|
||||
|
||||
struct device;
|
||||
|
||||
enum ssm2602_type {
|
||||
SSM2602,
|
||||
SSM2604,
|
||||
};
|
||||
|
||||
extern const struct regmap_config ssm2602_regmap_config;
|
||||
|
||||
int ssm2602_probe(struct device *dev, enum ssm2602_type type,
|
||||
struct regmap *regmap);
|
||||
|
||||
/* SSM2602 Codec Register definitions */
|
||||
|
||||
#define SSM2602_LINVOL 0x00
|
||||
|
|
|
@ -62,25 +62,25 @@ static const char *stac9766_boost1[] = {"0dB", "10dB"};
|
|||
static const char *stac9766_boost2[] = {"0dB", "20dB"};
|
||||
static const char *stac9766_stereo_mic[] = {"Off", "On"};
|
||||
|
||||
static const struct soc_enum stac9766_record_enum =
|
||||
SOC_ENUM_DOUBLE(AC97_REC_SEL, 8, 0, 8, stac9766_record_mux);
|
||||
static const struct soc_enum stac9766_mono_enum =
|
||||
SOC_ENUM_SINGLE(AC97_GENERAL_PURPOSE, 9, 2, stac9766_mono_mux);
|
||||
static const struct soc_enum stac9766_mic_enum =
|
||||
SOC_ENUM_SINGLE(AC97_GENERAL_PURPOSE, 8, 2, stac9766_mic_mux);
|
||||
static const struct soc_enum stac9766_SPDIF_enum =
|
||||
SOC_ENUM_SINGLE(AC97_STAC_DA_CONTROL, 1, 2, stac9766_SPDIF_mux);
|
||||
static const struct soc_enum stac9766_popbypass_enum =
|
||||
SOC_ENUM_SINGLE(AC97_GENERAL_PURPOSE, 15, 2, stac9766_popbypass_mux);
|
||||
static const struct soc_enum stac9766_record_all_enum =
|
||||
SOC_ENUM_SINGLE(AC97_STAC_ANALOG_SPECIAL, 12, 2,
|
||||
stac9766_record_all_mux);
|
||||
static const struct soc_enum stac9766_boost1_enum =
|
||||
SOC_ENUM_SINGLE(AC97_MIC, 6, 2, stac9766_boost1); /* 0/10dB */
|
||||
static const struct soc_enum stac9766_boost2_enum =
|
||||
SOC_ENUM_SINGLE(AC97_STAC_ANALOG_SPECIAL, 2, 2, stac9766_boost2); /* 0/20dB */
|
||||
static const struct soc_enum stac9766_stereo_mic_enum =
|
||||
SOC_ENUM_SINGLE(AC97_STAC_STEREO_MIC, 2, 1, stac9766_stereo_mic);
|
||||
static SOC_ENUM_DOUBLE_DECL(stac9766_record_enum,
|
||||
AC97_REC_SEL, 8, 0, stac9766_record_mux);
|
||||
static SOC_ENUM_SINGLE_DECL(stac9766_mono_enum,
|
||||
AC97_GENERAL_PURPOSE, 9, stac9766_mono_mux);
|
||||
static SOC_ENUM_SINGLE_DECL(stac9766_mic_enum,
|
||||
AC97_GENERAL_PURPOSE, 8, stac9766_mic_mux);
|
||||
static SOC_ENUM_SINGLE_DECL(stac9766_SPDIF_enum,
|
||||
AC97_STAC_DA_CONTROL, 1, stac9766_SPDIF_mux);
|
||||
static SOC_ENUM_SINGLE_DECL(stac9766_popbypass_enum,
|
||||
AC97_GENERAL_PURPOSE, 15, stac9766_popbypass_mux);
|
||||
static SOC_ENUM_SINGLE_DECL(stac9766_record_all_enum,
|
||||
AC97_STAC_ANALOG_SPECIAL, 12,
|
||||
stac9766_record_all_mux);
|
||||
static SOC_ENUM_SINGLE_DECL(stac9766_boost1_enum,
|
||||
AC97_MIC, 6, stac9766_boost1); /* 0/10dB */
|
||||
static SOC_ENUM_SINGLE_DECL(stac9766_boost2_enum,
|
||||
AC97_STAC_ANALOG_SPECIAL, 2, stac9766_boost2); /* 0/20dB */
|
||||
static SOC_ENUM_SINGLE_DECL(stac9766_stereo_mic_enum,
|
||||
AC97_STAC_STEREO_MIC, 2, stac9766_stereo_mic);
|
||||
|
||||
static const DECLARE_TLV_DB_LINEAR(master_tlv, -4600, 0);
|
||||
static const DECLARE_TLV_DB_LINEAR(record_tlv, 0, 2250);
|
||||
|
|
|
@ -9,48 +9,73 @@
|
|||
* published by the Free Software Foundation.
|
||||
*/
|
||||
#include <linux/clk.h>
|
||||
#include <linux/device.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/of.h>
|
||||
#include <linux/platform_device.h>
|
||||
#include <linux/string.h>
|
||||
#include <sound/simple_card.h>
|
||||
#include <sound/soc-dai.h>
|
||||
#include <sound/soc.h>
|
||||
|
||||
struct simple_card_data {
|
||||
struct snd_soc_card snd_card;
|
||||
unsigned int daifmt;
|
||||
struct asoc_simple_dai cpu_dai;
|
||||
struct asoc_simple_dai codec_dai;
|
||||
struct snd_soc_dai_link snd_link;
|
||||
};
|
||||
|
||||
static int __asoc_simple_card_dai_init(struct snd_soc_dai *dai,
|
||||
struct asoc_simple_dai *set,
|
||||
unsigned int daifmt)
|
||||
struct asoc_simple_dai *set)
|
||||
{
|
||||
int ret = 0;
|
||||
int ret;
|
||||
|
||||
daifmt |= set->fmt;
|
||||
|
||||
if (daifmt)
|
||||
ret = snd_soc_dai_set_fmt(dai, daifmt);
|
||||
|
||||
if (ret == -ENOTSUPP) {
|
||||
dev_dbg(dai->dev, "ASoC: set_fmt is not supported\n");
|
||||
ret = 0;
|
||||
if (set->fmt) {
|
||||
ret = snd_soc_dai_set_fmt(dai, set->fmt);
|
||||
if (ret && ret != -ENOTSUPP) {
|
||||
dev_err(dai->dev, "simple-card: set_fmt error\n");
|
||||
goto err;
|
||||
}
|
||||
}
|
||||
|
||||
if (!ret && set->sysclk)
|
||||
if (set->sysclk) {
|
||||
ret = snd_soc_dai_set_sysclk(dai, 0, set->sysclk, 0);
|
||||
if (ret && ret != -ENOTSUPP) {
|
||||
dev_err(dai->dev, "simple-card: set_sysclk error\n");
|
||||
goto err;
|
||||
}
|
||||
}
|
||||
|
||||
if (set->slots) {
|
||||
ret = snd_soc_dai_set_tdm_slot(dai, 0, 0,
|
||||
set->slots,
|
||||
set->slot_width);
|
||||
if (ret && ret != -ENOTSUPP) {
|
||||
dev_err(dai->dev, "simple-card: set_tdm_slot error\n");
|
||||
goto err;
|
||||
}
|
||||
}
|
||||
|
||||
ret = 0;
|
||||
|
||||
err:
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int asoc_simple_card_dai_init(struct snd_soc_pcm_runtime *rtd)
|
||||
{
|
||||
struct asoc_simple_card_info *info =
|
||||
struct simple_card_data *priv =
|
||||
snd_soc_card_get_drvdata(rtd->card);
|
||||
struct snd_soc_dai *codec = rtd->codec_dai;
|
||||
struct snd_soc_dai *cpu = rtd->cpu_dai;
|
||||
unsigned int daifmt = info->daifmt;
|
||||
int ret;
|
||||
|
||||
ret = __asoc_simple_card_dai_init(codec, &info->codec_dai, daifmt);
|
||||
ret = __asoc_simple_card_dai_init(codec, &priv->codec_dai);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
ret = __asoc_simple_card_dai_init(cpu, &info->cpu_dai, daifmt);
|
||||
ret = __asoc_simple_card_dai_init(cpu, &priv->cpu_dai);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
|
@ -59,9 +84,12 @@ static int asoc_simple_card_dai_init(struct snd_soc_pcm_runtime *rtd)
|
|||
|
||||
static int
|
||||
asoc_simple_card_sub_parse_of(struct device_node *np,
|
||||
unsigned int daifmt,
|
||||
struct asoc_simple_dai *dai,
|
||||
struct device_node **node)
|
||||
const struct device_node **p_node,
|
||||
const char **name)
|
||||
{
|
||||
struct device_node *node;
|
||||
struct clk *clk;
|
||||
int ret;
|
||||
|
||||
|
@ -69,21 +97,28 @@ asoc_simple_card_sub_parse_of(struct device_node *np,
|
|||
* get node via "sound-dai = <&phandle port>"
|
||||
* it will be used as xxx_of_node on soc_bind_dai_link()
|
||||
*/
|
||||
*node = of_parse_phandle(np, "sound-dai", 0);
|
||||
if (!*node)
|
||||
node = of_parse_phandle(np, "sound-dai", 0);
|
||||
if (!node)
|
||||
return -ENODEV;
|
||||
*p_node = node;
|
||||
|
||||
/* get dai->name */
|
||||
ret = snd_soc_of_get_dai_name(np, &dai->name);
|
||||
ret = snd_soc_of_get_dai_name(np, name);
|
||||
if (ret < 0)
|
||||
goto parse_error;
|
||||
|
||||
/* parse TDM slot */
|
||||
ret = snd_soc_of_parse_tdm_slot(np, &dai->slots, &dai->slot_width);
|
||||
if (ret)
|
||||
goto parse_error;
|
||||
|
||||
/*
|
||||
* bitclock-inversion, frame-inversion
|
||||
* bitclock-master, frame-master
|
||||
* and specific "format" if it has
|
||||
*/
|
||||
dai->fmt = snd_soc_of_parse_daifmt(np, NULL);
|
||||
dai->fmt |= daifmt;
|
||||
|
||||
/*
|
||||
* dai->sysclk come from
|
||||
|
@ -104,7 +139,7 @@ asoc_simple_card_sub_parse_of(struct device_node *np,
|
|||
"system-clock-frequency",
|
||||
&dai->sysclk);
|
||||
} else {
|
||||
clk = of_clk_get(*node, 0);
|
||||
clk = of_clk_get(node, 0);
|
||||
if (!IS_ERR(clk))
|
||||
dai->sysclk = clk_get_rate(clk);
|
||||
}
|
||||
|
@ -112,29 +147,38 @@ asoc_simple_card_sub_parse_of(struct device_node *np,
|
|||
ret = 0;
|
||||
|
||||
parse_error:
|
||||
of_node_put(*node);
|
||||
of_node_put(node);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int asoc_simple_card_parse_of(struct device_node *node,
|
||||
struct asoc_simple_card_info *info,
|
||||
struct device *dev,
|
||||
struct device_node **of_cpu,
|
||||
struct device_node **of_codec,
|
||||
struct device_node **of_platform)
|
||||
struct simple_card_data *priv,
|
||||
struct device *dev)
|
||||
{
|
||||
struct snd_soc_dai_link *dai_link = priv->snd_card.dai_link;
|
||||
struct device_node *np;
|
||||
char *name;
|
||||
int ret;
|
||||
|
||||
/* parsing the card name from DT */
|
||||
snd_soc_of_parse_card_name(&priv->snd_card, "simple-audio-card,name");
|
||||
|
||||
/* get CPU/CODEC common format via simple-audio-card,format */
|
||||
info->daifmt = snd_soc_of_parse_daifmt(node, "simple-audio-card,") &
|
||||
priv->daifmt = snd_soc_of_parse_daifmt(node, "simple-audio-card,") &
|
||||
(SND_SOC_DAIFMT_FORMAT_MASK | SND_SOC_DAIFMT_INV_MASK);
|
||||
|
||||
/* off-codec widgets */
|
||||
if (of_property_read_bool(node, "simple-audio-card,widgets")) {
|
||||
ret = snd_soc_of_parse_audio_simple_widgets(&priv->snd_card,
|
||||
"simple-audio-card,widgets");
|
||||
if (ret)
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* DAPM routes */
|
||||
if (of_property_read_bool(node, "simple-audio-card,routing")) {
|
||||
ret = snd_soc_of_parse_audio_routing(&info->snd_card,
|
||||
ret = snd_soc_of_parse_audio_routing(&priv->snd_card,
|
||||
"simple-audio-card,routing");
|
||||
if (ret)
|
||||
return ret;
|
||||
|
@ -144,9 +188,10 @@ static int asoc_simple_card_parse_of(struct device_node *node,
|
|||
ret = -EINVAL;
|
||||
np = of_get_child_by_name(node, "simple-audio-card,cpu");
|
||||
if (np)
|
||||
ret = asoc_simple_card_sub_parse_of(np,
|
||||
&info->cpu_dai,
|
||||
of_cpu);
|
||||
ret = asoc_simple_card_sub_parse_of(np, priv->daifmt,
|
||||
&priv->cpu_dai,
|
||||
&dai_link->cpu_of_node,
|
||||
&dai_link->cpu_dai_name);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
|
@ -154,114 +199,126 @@ static int asoc_simple_card_parse_of(struct device_node *node,
|
|||
ret = -EINVAL;
|
||||
np = of_get_child_by_name(node, "simple-audio-card,codec");
|
||||
if (np)
|
||||
ret = asoc_simple_card_sub_parse_of(np,
|
||||
&info->codec_dai,
|
||||
of_codec);
|
||||
ret = asoc_simple_card_sub_parse_of(np, priv->daifmt,
|
||||
&priv->codec_dai,
|
||||
&dai_link->codec_of_node,
|
||||
&dai_link->codec_dai_name);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
if (!info->cpu_dai.name || !info->codec_dai.name)
|
||||
if (!dai_link->cpu_dai_name || !dai_link->codec_dai_name)
|
||||
return -EINVAL;
|
||||
|
||||
/* card name is created from CPU/CODEC dai name */
|
||||
name = devm_kzalloc(dev,
|
||||
strlen(info->cpu_dai.name) +
|
||||
strlen(info->codec_dai.name) + 2,
|
||||
strlen(dai_link->cpu_dai_name) +
|
||||
strlen(dai_link->codec_dai_name) + 2,
|
||||
GFP_KERNEL);
|
||||
sprintf(name, "%s-%s", info->cpu_dai.name, info->codec_dai.name);
|
||||
info->name = info->card = name;
|
||||
sprintf(name, "%s-%s", dai_link->cpu_dai_name,
|
||||
dai_link->codec_dai_name);
|
||||
if (!priv->snd_card.name)
|
||||
priv->snd_card.name = name;
|
||||
dai_link->name = dai_link->stream_name = name;
|
||||
|
||||
/* simple-card assumes platform == cpu */
|
||||
*of_platform = *of_cpu;
|
||||
dai_link->platform_of_node = dai_link->cpu_of_node;
|
||||
|
||||
dev_dbg(dev, "card-name : %s\n", info->card);
|
||||
dev_dbg(dev, "platform : %04x\n", info->daifmt);
|
||||
dev_dbg(dev, "card-name : %s\n", name);
|
||||
dev_dbg(dev, "platform : %04x\n", priv->daifmt);
|
||||
dev_dbg(dev, "cpu : %s / %04x / %d\n",
|
||||
info->cpu_dai.name,
|
||||
info->cpu_dai.fmt,
|
||||
info->cpu_dai.sysclk);
|
||||
dai_link->cpu_dai_name,
|
||||
priv->cpu_dai.fmt,
|
||||
priv->cpu_dai.sysclk);
|
||||
dev_dbg(dev, "codec : %s / %04x / %d\n",
|
||||
info->codec_dai.name,
|
||||
info->codec_dai.fmt,
|
||||
info->codec_dai.sysclk);
|
||||
dai_link->codec_dai_name,
|
||||
priv->codec_dai.fmt,
|
||||
priv->codec_dai.sysclk);
|
||||
|
||||
/*
|
||||
* soc_bind_dai_link() will check cpu name
|
||||
* after of_node matching if dai_link has cpu_dai_name.
|
||||
* but, it will never match if name was created by fmt_single_name()
|
||||
* remove cpu_dai_name to escape name matching.
|
||||
* see
|
||||
* fmt_single_name()
|
||||
* fmt_multiple_name()
|
||||
*/
|
||||
dai_link->cpu_dai_name = NULL;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int asoc_simple_card_probe(struct platform_device *pdev)
|
||||
{
|
||||
struct asoc_simple_card_info *cinfo;
|
||||
struct simple_card_data *priv;
|
||||
struct snd_soc_dai_link *dai_link;
|
||||
struct device_node *np = pdev->dev.of_node;
|
||||
struct device_node *of_cpu, *of_codec, *of_platform;
|
||||
struct device *dev = &pdev->dev;
|
||||
int ret;
|
||||
|
||||
cinfo = NULL;
|
||||
of_cpu = NULL;
|
||||
of_codec = NULL;
|
||||
of_platform = NULL;
|
||||
|
||||
cinfo = devm_kzalloc(dev, sizeof(*cinfo), GFP_KERNEL);
|
||||
if (!cinfo)
|
||||
priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
|
||||
if (!priv)
|
||||
return -ENOMEM;
|
||||
|
||||
if (np && of_device_is_available(np)) {
|
||||
cinfo->snd_card.dev = dev;
|
||||
/*
|
||||
* init snd_soc_card
|
||||
*/
|
||||
priv->snd_card.owner = THIS_MODULE;
|
||||
priv->snd_card.dev = dev;
|
||||
dai_link = &priv->snd_link;
|
||||
priv->snd_card.dai_link = dai_link;
|
||||
priv->snd_card.num_links = 1;
|
||||
|
||||
ret = asoc_simple_card_parse_of(np, cinfo, dev,
|
||||
&of_cpu,
|
||||
&of_codec,
|
||||
&of_platform);
|
||||
if (np && of_device_is_available(np)) {
|
||||
|
||||
ret = asoc_simple_card_parse_of(np, priv, dev);
|
||||
if (ret < 0) {
|
||||
if (ret != -EPROBE_DEFER)
|
||||
dev_err(dev, "parse error %d\n", ret);
|
||||
return ret;
|
||||
}
|
||||
} else {
|
||||
if (!dev->platform_data) {
|
||||
struct asoc_simple_card_info *cinfo;
|
||||
|
||||
cinfo = dev->platform_data;
|
||||
if (!cinfo) {
|
||||
dev_err(dev, "no info for asoc-simple-card\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
memcpy(cinfo, dev->platform_data, sizeof(*cinfo));
|
||||
cinfo->snd_card.dev = dev;
|
||||
}
|
||||
if (!cinfo->name ||
|
||||
!cinfo->codec_dai.name ||
|
||||
!cinfo->codec ||
|
||||
!cinfo->platform ||
|
||||
!cinfo->cpu_dai.name) {
|
||||
dev_err(dev, "insufficient asoc_simple_card_info settings\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (!cinfo->name ||
|
||||
!cinfo->card ||
|
||||
!cinfo->codec_dai.name ||
|
||||
!(cinfo->codec || of_codec) ||
|
||||
!(cinfo->platform || of_platform) ||
|
||||
!(cinfo->cpu_dai.name || of_cpu)) {
|
||||
dev_err(dev, "insufficient asoc_simple_card_info settings\n");
|
||||
return -EINVAL;
|
||||
priv->snd_card.name = (cinfo->card) ? cinfo->card : cinfo->name;
|
||||
dai_link->name = cinfo->name;
|
||||
dai_link->stream_name = cinfo->name;
|
||||
dai_link->platform_name = cinfo->platform;
|
||||
dai_link->codec_name = cinfo->codec;
|
||||
dai_link->cpu_dai_name = cinfo->cpu_dai.name;
|
||||
dai_link->codec_dai_name = cinfo->codec_dai.name;
|
||||
memcpy(&priv->cpu_dai, &cinfo->cpu_dai,
|
||||
sizeof(priv->cpu_dai));
|
||||
memcpy(&priv->codec_dai, &cinfo->codec_dai,
|
||||
sizeof(priv->codec_dai));
|
||||
|
||||
priv->cpu_dai.fmt |= cinfo->daifmt;
|
||||
priv->codec_dai.fmt |= cinfo->daifmt;
|
||||
}
|
||||
|
||||
/*
|
||||
* init snd_soc_dai_link
|
||||
*/
|
||||
cinfo->snd_link.name = cinfo->name;
|
||||
cinfo->snd_link.stream_name = cinfo->name;
|
||||
cinfo->snd_link.cpu_dai_name = cinfo->cpu_dai.name;
|
||||
cinfo->snd_link.platform_name = cinfo->platform;
|
||||
cinfo->snd_link.codec_name = cinfo->codec;
|
||||
cinfo->snd_link.codec_dai_name = cinfo->codec_dai.name;
|
||||
cinfo->snd_link.cpu_of_node = of_cpu;
|
||||
cinfo->snd_link.codec_of_node = of_codec;
|
||||
cinfo->snd_link.platform_of_node = of_platform;
|
||||
cinfo->snd_link.init = asoc_simple_card_dai_init;
|
||||
dai_link->init = asoc_simple_card_dai_init;
|
||||
|
||||
/*
|
||||
* init snd_soc_card
|
||||
*/
|
||||
cinfo->snd_card.name = cinfo->card;
|
||||
cinfo->snd_card.owner = THIS_MODULE;
|
||||
cinfo->snd_card.dai_link = &cinfo->snd_link;
|
||||
cinfo->snd_card.num_links = 1;
|
||||
snd_soc_card_set_drvdata(&priv->snd_card, priv);
|
||||
|
||||
snd_soc_card_set_drvdata(&cinfo->snd_card, cinfo);
|
||||
|
||||
return devm_snd_soc_register_card(&pdev->dev, &cinfo->snd_card);
|
||||
return devm_snd_soc_register_card(&pdev->dev, &priv->snd_card);
|
||||
}
|
||||
|
||||
static const struct of_device_id asoc_simple_of_match[] = {
|
||||
|
|
|
@ -66,10 +66,6 @@ static int h1940_startup(struct snd_pcm_substream *substream)
|
|||
{
|
||||
struct snd_pcm_runtime *runtime = substream->runtime;
|
||||
|
||||
runtime->hw.rate_min = hw_rates.list[0];
|
||||
runtime->hw.rate_max = hw_rates.list[hw_rates.count - 1];
|
||||
runtime->hw.rates = SNDRV_PCM_RATE_KNOT;
|
||||
|
||||
return snd_pcm_hw_constraint_list(runtime, 0,
|
||||
SNDRV_PCM_HW_PARAM_RATE,
|
||||
&hw_rates);
|
||||
|
@ -94,7 +90,7 @@ static int h1940_hw_params(struct snd_pcm_substream *substream,
|
|||
div++;
|
||||
break;
|
||||
default:
|
||||
dev_err(&rtd->dev, "%s: rate %d is not supported\n",
|
||||
dev_err(rtd->dev, "%s: rate %d is not supported\n",
|
||||
__func__, rate);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
@ -181,7 +177,6 @@ static int h1940_uda1380_init(struct snd_soc_pcm_runtime *rtd)
|
|||
{
|
||||
struct snd_soc_codec *codec = rtd->codec;
|
||||
struct snd_soc_dapm_context *dapm = &codec->dapm;
|
||||
int err;
|
||||
|
||||
snd_soc_dapm_enable_pin(dapm, "Headphone Jack");
|
||||
snd_soc_dapm_enable_pin(dapm, "Speaker");
|
||||
|
|
|
@ -192,44 +192,6 @@ static struct snd_soc_ops neo1973_voice_ops = {
|
|||
.hw_free = neo1973_voice_hw_free,
|
||||
};
|
||||
|
||||
/* Shared routes and controls */
|
||||
|
||||
static const struct snd_soc_dapm_widget neo1973_wm8753_dapm_widgets[] = {
|
||||
SND_SOC_DAPM_LINE("GSM Line Out", NULL),
|
||||
SND_SOC_DAPM_LINE("GSM Line In", NULL),
|
||||
SND_SOC_DAPM_MIC("Headset Mic", NULL),
|
||||
SND_SOC_DAPM_MIC("Handset Mic", NULL),
|
||||
};
|
||||
|
||||
static const struct snd_soc_dapm_route neo1973_wm8753_routes[] = {
|
||||
/* Connections to the GSM Module */
|
||||
{"GSM Line Out", NULL, "MONO1"},
|
||||
{"GSM Line Out", NULL, "MONO2"},
|
||||
{"RXP", NULL, "GSM Line In"},
|
||||
{"RXN", NULL, "GSM Line In"},
|
||||
|
||||
/* Connections to Headset */
|
||||
{"MIC1", NULL, "Mic Bias"},
|
||||
{"Mic Bias", NULL, "Headset Mic"},
|
||||
|
||||
/* Call Mic */
|
||||
{"MIC2", NULL, "Mic Bias"},
|
||||
{"MIC2N", NULL, "Mic Bias"},
|
||||
{"Mic Bias", NULL, "Handset Mic"},
|
||||
|
||||
/* Connect the ALC pins */
|
||||
{"ACIN", NULL, "ACOP"},
|
||||
};
|
||||
|
||||
static const struct snd_kcontrol_new neo1973_wm8753_controls[] = {
|
||||
SOC_DAPM_PIN_SWITCH("GSM Line Out"),
|
||||
SOC_DAPM_PIN_SWITCH("GSM Line In"),
|
||||
SOC_DAPM_PIN_SWITCH("Headset Mic"),
|
||||
SOC_DAPM_PIN_SWITCH("Handset Mic"),
|
||||
};
|
||||
|
||||
/* GTA02 specific routes and controls */
|
||||
|
||||
static int gta02_speaker_enabled;
|
||||
|
||||
static int lm4853_set_spk(struct snd_kcontrol *kcontrol,
|
||||
|
@ -257,7 +219,34 @@ static int lm4853_event(struct snd_soc_dapm_widget *w,
|
|||
return 0;
|
||||
}
|
||||
|
||||
static const struct snd_soc_dapm_route neo1973_gta02_routes[] = {
|
||||
static const struct snd_soc_dapm_widget neo1973_wm8753_dapm_widgets[] = {
|
||||
SND_SOC_DAPM_LINE("GSM Line Out", NULL),
|
||||
SND_SOC_DAPM_LINE("GSM Line In", NULL),
|
||||
SND_SOC_DAPM_MIC("Headset Mic", NULL),
|
||||
SND_SOC_DAPM_MIC("Handset Mic", NULL),
|
||||
SND_SOC_DAPM_SPK("Handset Spk", NULL),
|
||||
SND_SOC_DAPM_SPK("Stereo Out", lm4853_event),
|
||||
};
|
||||
|
||||
static const struct snd_soc_dapm_route neo1973_wm8753_routes[] = {
|
||||
/* Connections to the GSM Module */
|
||||
{"GSM Line Out", NULL, "MONO1"},
|
||||
{"GSM Line Out", NULL, "MONO2"},
|
||||
{"RXP", NULL, "GSM Line In"},
|
||||
{"RXN", NULL, "GSM Line In"},
|
||||
|
||||
/* Connections to Headset */
|
||||
{"MIC1", NULL, "Mic Bias"},
|
||||
{"Mic Bias", NULL, "Headset Mic"},
|
||||
|
||||
/* Call Mic */
|
||||
{"MIC2", NULL, "Mic Bias"},
|
||||
{"MIC2N", NULL, "Mic Bias"},
|
||||
{"Mic Bias", NULL, "Handset Mic"},
|
||||
|
||||
/* Connect the ALC pins */
|
||||
{"ACIN", NULL, "ACOP"},
|
||||
|
||||
/* Connections to the amp */
|
||||
{"Stereo Out", NULL, "LOUT1"},
|
||||
{"Stereo Out", NULL, "ROUT1"},
|
||||
|
@ -267,7 +256,11 @@ static const struct snd_soc_dapm_route neo1973_gta02_routes[] = {
|
|||
{"Handset Spk", NULL, "ROUT2"},
|
||||
};
|
||||
|
||||
static const struct snd_kcontrol_new neo1973_gta02_wm8753_controls[] = {
|
||||
static const struct snd_kcontrol_new neo1973_wm8753_controls[] = {
|
||||
SOC_DAPM_PIN_SWITCH("GSM Line Out"),
|
||||
SOC_DAPM_PIN_SWITCH("GSM Line In"),
|
||||
SOC_DAPM_PIN_SWITCH("Headset Mic"),
|
||||
SOC_DAPM_PIN_SWITCH("Handset Mic"),
|
||||
SOC_DAPM_PIN_SWITCH("Handset Spk"),
|
||||
SOC_DAPM_PIN_SWITCH("Stereo Out"),
|
||||
|
||||
|
@ -276,86 +269,32 @@ static const struct snd_kcontrol_new neo1973_gta02_wm8753_controls[] = {
|
|||
lm4853_set_spk),
|
||||
};
|
||||
|
||||
static const struct snd_soc_dapm_widget neo1973_gta02_wm8753_dapm_widgets[] = {
|
||||
SND_SOC_DAPM_SPK("Handset Spk", NULL),
|
||||
SND_SOC_DAPM_SPK("Stereo Out", lm4853_event),
|
||||
};
|
||||
|
||||
static int neo1973_gta02_wm8753_init(struct snd_soc_codec *codec)
|
||||
{
|
||||
struct snd_soc_dapm_context *dapm = &codec->dapm;
|
||||
int ret;
|
||||
|
||||
ret = snd_soc_dapm_new_controls(dapm, neo1973_gta02_wm8753_dapm_widgets,
|
||||
ARRAY_SIZE(neo1973_gta02_wm8753_dapm_widgets));
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
ret = snd_soc_dapm_add_routes(dapm, neo1973_gta02_routes,
|
||||
ARRAY_SIZE(neo1973_gta02_routes));
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
ret = snd_soc_add_card_controls(codec->card, neo1973_gta02_wm8753_controls,
|
||||
ARRAY_SIZE(neo1973_gta02_wm8753_controls));
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
snd_soc_dapm_disable_pin(dapm, "Stereo Out");
|
||||
snd_soc_dapm_disable_pin(dapm, "Handset Spk");
|
||||
snd_soc_dapm_ignore_suspend(dapm, "Stereo Out");
|
||||
snd_soc_dapm_ignore_suspend(dapm, "Handset Spk");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int neo1973_wm8753_init(struct snd_soc_pcm_runtime *rtd)
|
||||
{
|
||||
struct snd_soc_codec *codec = rtd->codec;
|
||||
struct snd_soc_dapm_context *dapm = &codec->dapm;
|
||||
int ret;
|
||||
struct snd_soc_card *card = rtd->card;
|
||||
|
||||
/* set up NC codec pins */
|
||||
snd_soc_dapm_nc_pin(dapm, "OUT3");
|
||||
snd_soc_dapm_nc_pin(dapm, "OUT4");
|
||||
snd_soc_dapm_nc_pin(dapm, "LINE1");
|
||||
snd_soc_dapm_nc_pin(dapm, "LINE2");
|
||||
|
||||
/* Add neo1973 specific widgets */
|
||||
ret = snd_soc_dapm_new_controls(dapm, neo1973_wm8753_dapm_widgets,
|
||||
ARRAY_SIZE(neo1973_wm8753_dapm_widgets));
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
/* add neo1973 specific controls */
|
||||
ret = snd_soc_add_card_controls(rtd->card, neo1973_wm8753_controls,
|
||||
ARRAY_SIZE(neo1973_wm8753_controls));
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
/* set up neo1973 specific audio routes */
|
||||
ret = snd_soc_dapm_add_routes(dapm, neo1973_wm8753_routes,
|
||||
ARRAY_SIZE(neo1973_wm8753_routes));
|
||||
if (ret)
|
||||
return ret;
|
||||
snd_soc_dapm_nc_pin(&codec->dapm, "OUT3");
|
||||
snd_soc_dapm_nc_pin(&codec->dapm, "OUT4");
|
||||
snd_soc_dapm_nc_pin(&codec->dapm, "LINE1");
|
||||
snd_soc_dapm_nc_pin(&codec->dapm, "LINE2");
|
||||
|
||||
/* set endpoints to default off mode */
|
||||
snd_soc_dapm_disable_pin(dapm, "GSM Line Out");
|
||||
snd_soc_dapm_disable_pin(dapm, "GSM Line In");
|
||||
snd_soc_dapm_disable_pin(dapm, "Headset Mic");
|
||||
snd_soc_dapm_disable_pin(dapm, "Handset Mic");
|
||||
snd_soc_dapm_disable_pin(&card->dapm, "GSM Line Out");
|
||||
snd_soc_dapm_disable_pin(&card->dapm, "GSM Line In");
|
||||
snd_soc_dapm_disable_pin(&card->dapm, "Headset Mic");
|
||||
snd_soc_dapm_disable_pin(&card->dapm, "Handset Mic");
|
||||
snd_soc_dapm_disable_pin(&card->dapm, "Stereo Out");
|
||||
snd_soc_dapm_disable_pin(&card->dapm, "Handset Spk");
|
||||
|
||||
/* allow audio paths from the GSM modem to run during suspend */
|
||||
snd_soc_dapm_ignore_suspend(dapm, "GSM Line Out");
|
||||
snd_soc_dapm_ignore_suspend(dapm, "GSM Line In");
|
||||
snd_soc_dapm_ignore_suspend(dapm, "Headset Mic");
|
||||
snd_soc_dapm_ignore_suspend(dapm, "Handset Mic");
|
||||
|
||||
if (machine_is_neo1973_gta02()) {
|
||||
ret = neo1973_gta02_wm8753_init(codec);
|
||||
if (ret)
|
||||
return ret;
|
||||
}
|
||||
snd_soc_dapm_ignore_suspend(&card->dapm, "GSM Line Out");
|
||||
snd_soc_dapm_ignore_suspend(&card->dapm, "GSM Line In");
|
||||
snd_soc_dapm_ignore_suspend(&card->dapm, "Headset Mic");
|
||||
snd_soc_dapm_ignore_suspend(&card->dapm, "Handset Mic");
|
||||
snd_soc_dapm_ignore_suspend(&card->dapm, "Stereo Out");
|
||||
snd_soc_dapm_ignore_suspend(&card->dapm, "Handset Spk");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -409,6 +348,13 @@ static struct snd_soc_card neo1973 = {
|
|||
.num_aux_devs = ARRAY_SIZE(neo1973_aux_devs),
|
||||
.codec_conf = neo1973_codec_conf,
|
||||
.num_configs = ARRAY_SIZE(neo1973_codec_conf),
|
||||
|
||||
.controls = neo1973_wm8753_controls,
|
||||
.num_controls = ARRAY_SIZE(neo1973_wm8753_controls),
|
||||
.dapm_widgets = neo1973_wm8753_dapm_widgets,
|
||||
.num_dapm_widgets = ARRAY_SIZE(neo1973_wm8753_dapm_widgets),
|
||||
.dapm_routes = neo1973_wm8753_routes,
|
||||
.num_dapm_routes = ARRAY_SIZE(neo1973_wm8753_routes),
|
||||
};
|
||||
|
||||
static struct platform_device *neo1973_snd_device;
|
||||
|
|
|
@ -131,10 +131,6 @@ static int rx1950_startup(struct snd_pcm_substream *substream)
|
|||
{
|
||||
struct snd_pcm_runtime *runtime = substream->runtime;
|
||||
|
||||
runtime->hw.rate_min = hw_rates.list[0];
|
||||
runtime->hw.rate_max = hw_rates.list[hw_rates.count - 1];
|
||||
runtime->hw.rates = SNDRV_PCM_RATE_KNOT;
|
||||
|
||||
return snd_pcm_hw_constraint_list(runtime, 0,
|
||||
SNDRV_PCM_HW_PARAM_RATE,
|
||||
&hw_rates);
|
||||
|
@ -226,7 +222,6 @@ static int rx1950_uda1380_init(struct snd_soc_pcm_runtime *rtd)
|
|||
{
|
||||
struct snd_soc_codec *codec = rtd->codec;
|
||||
struct snd_soc_dapm_context *dapm = &codec->dapm;
|
||||
int err;
|
||||
|
||||
snd_soc_dapm_enable_pin(dapm, "Headphone Jack");
|
||||
snd_soc_dapm_enable_pin(dapm, "Speaker");
|
||||
|
|
|
@ -202,7 +202,7 @@ static int smdk_audio_probe(struct platform_device *pdev)
|
|||
|
||||
static struct platform_driver smdk_audio_driver = {
|
||||
.driver = {
|
||||
.name = "smdk-audio-wm8894",
|
||||
.name = "smdk-audio-wm8994",
|
||||
.owner = THIS_MODULE,
|
||||
.of_match_table = of_match_ptr(samsung_wm8994_of_match),
|
||||
.pm = &snd_soc_pm_ops,
|
||||
|
|
|
@ -44,6 +44,8 @@ static int tobermory_set_bias_level(struct snd_soc_card *card,
|
|||
SND_SOC_CLOCK_IN);
|
||||
if (ret < 0) {
|
||||
pr_err("Failed to set SYSCLK: %d\n", ret);
|
||||
snd_soc_dai_set_pll(codec_dai, WM8962_FLL,
|
||||
0, 0, 0);
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -136,19 +136,6 @@ static const struct snd_soc_dapm_route audio_map[] = {
|
|||
{ "Mic Bias", NULL, "External Microphone" },
|
||||
};
|
||||
|
||||
static int migor_dai_init(struct snd_soc_pcm_runtime *rtd)
|
||||
{
|
||||
struct snd_soc_codec *codec = rtd->codec;
|
||||
struct snd_soc_dapm_context *dapm = &codec->dapm;
|
||||
|
||||
snd_soc_dapm_new_controls(dapm, migor_dapm_widgets,
|
||||
ARRAY_SIZE(migor_dapm_widgets));
|
||||
|
||||
snd_soc_dapm_add_routes(dapm, audio_map, ARRAY_SIZE(audio_map));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* migor digital audio interface glue - connects codec <--> CPU */
|
||||
static struct snd_soc_dai_link migor_dai = {
|
||||
.name = "wm8978",
|
||||
|
@ -158,7 +145,6 @@ static struct snd_soc_dai_link migor_dai = {
|
|||
.platform_name = "siu-pcm-audio",
|
||||
.codec_name = "wm8978.0-001a",
|
||||
.ops = &migor_dai_ops,
|
||||
.init = migor_dai_init,
|
||||
};
|
||||
|
||||
/* migor audio machine driver */
|
||||
|
@ -167,6 +153,11 @@ static struct snd_soc_card snd_soc_migor = {
|
|||
.owner = THIS_MODULE,
|
||||
.dai_link = &migor_dai,
|
||||
.num_links = 1,
|
||||
|
||||
.dapm_widgets = migor_dapm_widgets,
|
||||
.num_dapm_widgets = ARRAY_SIZE(migor_dapm_widgets),
|
||||
.dapm_routes = audio_map,
|
||||
.num_dapm_routes = ARRAY_SIZE(audio_map),
|
||||
};
|
||||
|
||||
static struct platform_device *migor_snd_device;
|
||||
|
|
14
sound/soc/sirf/Kconfig
Normal file
14
sound/soc/sirf/Kconfig
Normal file
|
@ -0,0 +1,14 @@
|
|||
config SND_SOC_SIRF
|
||||
tristate "SoC Audio for the SiRF SoC chips"
|
||||
depends on ARCH_SIRF || COMPILE_TEST
|
||||
select SND_SOC_GENERIC_DMAENGINE_PCM
|
||||
|
||||
config SND_SOC_SIRF_AUDIO
|
||||
tristate "SoC Audio support for SiRF internal audio codec"
|
||||
depends on SND_SOC_SIRF
|
||||
select SND_SOC_SIRF_AUDIO_CODEC
|
||||
select SND_SOC_SIRF_AUDIO_PORT
|
||||
|
||||
config SND_SOC_SIRF_AUDIO_PORT
|
||||
select REGMAP_MMIO
|
||||
tristate
|
5
sound/soc/sirf/Makefile
Normal file
5
sound/soc/sirf/Makefile
Normal file
|
@ -0,0 +1,5 @@
|
|||
snd-soc-sirf-audio-objs := sirf-audio.o
|
||||
snd-soc-sirf-audio-port-objs := sirf-audio-port.o
|
||||
|
||||
obj-$(CONFIG_SND_SOC_SIRF_AUDIO) += snd-soc-sirf-audio.o
|
||||
obj-$(CONFIG_SND_SOC_SIRF_AUDIO_PORT) += snd-soc-sirf-audio-port.o
|
194
sound/soc/sirf/sirf-audio-port.c
Normal file
194
sound/soc/sirf/sirf-audio-port.c
Normal file
|
@ -0,0 +1,194 @@
|
|||
/*
|
||||
* SiRF Audio port driver
|
||||
*
|
||||
* Copyright (c) 2011 Cambridge Silicon Radio Limited, a CSR plc group company.
|
||||
*
|
||||
* Licensed under GPLv2 or later.
|
||||
*/
|
||||
#include <linux/module.h>
|
||||
#include <linux/io.h>
|
||||
#include <linux/regmap.h>
|
||||
#include <sound/soc.h>
|
||||
#include <sound/dmaengine_pcm.h>
|
||||
|
||||
#include "sirf-audio-port.h"
|
||||
|
||||
struct sirf_audio_port {
|
||||
struct regmap *regmap;
|
||||
struct snd_dmaengine_dai_dma_data playback_dma_data;
|
||||
struct snd_dmaengine_dai_dma_data capture_dma_data;
|
||||
};
|
||||
|
||||
static void sirf_audio_port_tx_enable(struct sirf_audio_port *port)
|
||||
{
|
||||
regmap_update_bits(port->regmap, AUDIO_PORT_IC_TXFIFO_OP,
|
||||
AUDIO_FIFO_RESET, AUDIO_FIFO_RESET);
|
||||
regmap_write(port->regmap, AUDIO_PORT_IC_TXFIFO_INT_MSK, 0);
|
||||
regmap_write(port->regmap, AUDIO_PORT_IC_TXFIFO_OP, 0);
|
||||
regmap_update_bits(port->regmap, AUDIO_PORT_IC_TXFIFO_OP,
|
||||
AUDIO_FIFO_START, AUDIO_FIFO_START);
|
||||
regmap_update_bits(port->regmap, AUDIO_PORT_IC_CODEC_TX_CTRL,
|
||||
IC_TX_ENABLE, IC_TX_ENABLE);
|
||||
}
|
||||
|
||||
static void sirf_audio_port_tx_disable(struct sirf_audio_port *port)
|
||||
{
|
||||
regmap_write(port->regmap, AUDIO_PORT_IC_TXFIFO_OP, 0);
|
||||
regmap_update_bits(port->regmap, AUDIO_PORT_IC_CODEC_TX_CTRL,
|
||||
IC_TX_ENABLE, ~IC_TX_ENABLE);
|
||||
}
|
||||
|
||||
static void sirf_audio_port_rx_enable(struct sirf_audio_port *port,
|
||||
int channels)
|
||||
{
|
||||
regmap_update_bits(port->regmap, AUDIO_PORT_IC_RXFIFO_OP,
|
||||
AUDIO_FIFO_RESET, AUDIO_FIFO_RESET);
|
||||
regmap_write(port->regmap, AUDIO_PORT_IC_RXFIFO_INT_MSK, 0);
|
||||
regmap_write(port->regmap, AUDIO_PORT_IC_RXFIFO_OP, 0);
|
||||
regmap_update_bits(port->regmap, AUDIO_PORT_IC_RXFIFO_OP,
|
||||
AUDIO_FIFO_START, AUDIO_FIFO_START);
|
||||
if (channels == 1)
|
||||
regmap_update_bits(port->regmap, AUDIO_PORT_IC_CODEC_RX_CTRL,
|
||||
IC_RX_ENABLE_MONO, IC_RX_ENABLE_MONO);
|
||||
else
|
||||
regmap_update_bits(port->regmap, AUDIO_PORT_IC_CODEC_RX_CTRL,
|
||||
IC_RX_ENABLE_STEREO, IC_RX_ENABLE_STEREO);
|
||||
}
|
||||
|
||||
static void sirf_audio_port_rx_disable(struct sirf_audio_port *port)
|
||||
{
|
||||
regmap_update_bits(port->regmap, AUDIO_PORT_IC_CODEC_RX_CTRL,
|
||||
IC_RX_ENABLE_STEREO, ~IC_RX_ENABLE_STEREO);
|
||||
}
|
||||
|
||||
static int sirf_audio_port_dai_probe(struct snd_soc_dai *dai)
|
||||
{
|
||||
struct sirf_audio_port *port = snd_soc_dai_get_drvdata(dai);
|
||||
snd_soc_dai_init_dma_data(dai, &port->playback_dma_data,
|
||||
&port->capture_dma_data);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int sirf_audio_port_trigger(struct snd_pcm_substream *substream, int cmd,
|
||||
struct snd_soc_dai *dai)
|
||||
{
|
||||
struct sirf_audio_port *port = snd_soc_dai_get_drvdata(dai);
|
||||
int playback = substream->stream == SNDRV_PCM_STREAM_PLAYBACK;
|
||||
|
||||
switch (cmd) {
|
||||
case SNDRV_PCM_TRIGGER_STOP:
|
||||
case SNDRV_PCM_TRIGGER_SUSPEND:
|
||||
case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
|
||||
if (playback)
|
||||
sirf_audio_port_tx_disable(port);
|
||||
else
|
||||
sirf_audio_port_rx_disable(port);
|
||||
break;
|
||||
case SNDRV_PCM_TRIGGER_START:
|
||||
case SNDRV_PCM_TRIGGER_RESUME:
|
||||
case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
|
||||
if (playback)
|
||||
sirf_audio_port_tx_enable(port);
|
||||
else
|
||||
sirf_audio_port_rx_enable(port,
|
||||
substream->runtime->channels);
|
||||
break;
|
||||
default:
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const struct snd_soc_dai_ops sirf_audio_port_dai_ops = {
|
||||
.trigger = sirf_audio_port_trigger,
|
||||
};
|
||||
|
||||
static struct snd_soc_dai_driver sirf_audio_port_dai = {
|
||||
.probe = sirf_audio_port_dai_probe,
|
||||
.name = "sirf-audio-port",
|
||||
.id = 0,
|
||||
.playback = {
|
||||
.channels_min = 2,
|
||||
.channels_max = 2,
|
||||
.rates = SNDRV_PCM_RATE_48000,
|
||||
.formats = SNDRV_PCM_FMTBIT_S16_LE,
|
||||
},
|
||||
.capture = {
|
||||
.channels_min = 1,
|
||||
.channels_max = 2,
|
||||
.rates = SNDRV_PCM_RATE_48000,
|
||||
.formats = SNDRV_PCM_FMTBIT_S16_LE,
|
||||
},
|
||||
.ops = &sirf_audio_port_dai_ops,
|
||||
};
|
||||
|
||||
static const struct snd_soc_component_driver sirf_audio_port_component = {
|
||||
.name = "sirf-audio-port",
|
||||
};
|
||||
|
||||
static const struct regmap_config sirf_audio_port_regmap_config = {
|
||||
.reg_bits = 32,
|
||||
.reg_stride = 4,
|
||||
.val_bits = 32,
|
||||
.max_register = AUDIO_PORT_IC_RXFIFO_INT_MSK,
|
||||
.cache_type = REGCACHE_NONE,
|
||||
};
|
||||
|
||||
static int sirf_audio_port_probe(struct platform_device *pdev)
|
||||
{
|
||||
int ret;
|
||||
struct sirf_audio_port *port;
|
||||
void __iomem *base;
|
||||
struct resource *mem_res;
|
||||
|
||||
port = devm_kzalloc(&pdev->dev,
|
||||
sizeof(struct sirf_audio_port), GFP_KERNEL);
|
||||
if (!port)
|
||||
return -ENOMEM;
|
||||
|
||||
mem_res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
|
||||
if (!mem_res) {
|
||||
dev_err(&pdev->dev, "no mem resource?\n");
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
base = devm_ioremap(&pdev->dev, mem_res->start,
|
||||
resource_size(mem_res));
|
||||
if (base == NULL)
|
||||
return -ENOMEM;
|
||||
|
||||
port->regmap = devm_regmap_init_mmio(&pdev->dev, base,
|
||||
&sirf_audio_port_regmap_config);
|
||||
if (IS_ERR(port->regmap))
|
||||
return PTR_ERR(port->regmap);
|
||||
|
||||
ret = devm_snd_soc_register_component(&pdev->dev,
|
||||
&sirf_audio_port_component, &sirf_audio_port_dai, 1);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
platform_set_drvdata(pdev, port);
|
||||
return devm_snd_dmaengine_pcm_register(&pdev->dev, NULL, 0);
|
||||
}
|
||||
|
||||
static const struct of_device_id sirf_audio_port_of_match[] = {
|
||||
{ .compatible = "sirf,audio-port", },
|
||||
{}
|
||||
};
|
||||
MODULE_DEVICE_TABLE(of, sirf_audio_port_of_match);
|
||||
|
||||
static struct platform_driver sirf_audio_port_driver = {
|
||||
.driver = {
|
||||
.name = "sirf-audio-port",
|
||||
.owner = THIS_MODULE,
|
||||
.of_match_table = sirf_audio_port_of_match,
|
||||
},
|
||||
.probe = sirf_audio_port_probe,
|
||||
};
|
||||
|
||||
module_platform_driver(sirf_audio_port_driver);
|
||||
|
||||
MODULE_DESCRIPTION("SiRF Audio Port driver");
|
||||
MODULE_AUTHOR("RongJun Ying <Rongjun.Ying@csr.com>");
|
||||
MODULE_LICENSE("GPL v2");
|
62
sound/soc/sirf/sirf-audio-port.h
Normal file
62
sound/soc/sirf/sirf-audio-port.h
Normal file
|
@ -0,0 +1,62 @@
|
|||
/*
|
||||
* SiRF Audio port controllers define
|
||||
*
|
||||
* Copyright (c) 2011 Cambridge Silicon Radio Limited, a CSR plc group company.
|
||||
*
|
||||
* Licensed under GPLv2 or later.
|
||||
*/
|
||||
|
||||
#ifndef _SIRF_AUDIO_PORT_H
|
||||
#define _SIRF_AUDIO_PORT_H
|
||||
|
||||
#define AUDIO_PORT_TX_FIFO_LEVEL_CHECK_MASK 0x3F
|
||||
#define AUDIO_PORT_TX_FIFO_SC_OFFSET 0
|
||||
#define AUDIO_PORT_TX_FIFO_LC_OFFSET 10
|
||||
#define AUDIO_PORT_TX_FIFO_HC_OFFSET 20
|
||||
|
||||
#define TX_FIFO_SC(x) (((x) & AUDIO_PORT_TX_FIFO_LEVEL_CHECK_MASK) \
|
||||
<< AUDIO_PORT_TX_FIFO_SC_OFFSET)
|
||||
#define TX_FIFO_LC(x) (((x) & AUDIO_PORT_TX_FIFO_LEVEL_CHECK_MASK) \
|
||||
<< AUDIO_PORT_TX_FIFO_LC_OFFSET)
|
||||
#define TX_FIFO_HC(x) (((x) & AUDIO_PORT_TX_FIFO_LEVEL_CHECK_MASK) \
|
||||
<< AUDIO_PORT_TX_FIFO_HC_OFFSET)
|
||||
|
||||
#define AUDIO_PORT_RX_FIFO_LEVEL_CHECK_MASK 0x0F
|
||||
#define AUDIO_PORT_RX_FIFO_SC_OFFSET 0
|
||||
#define AUDIO_PORT_RX_FIFO_LC_OFFSET 10
|
||||
#define AUDIO_PORT_RX_FIFO_HC_OFFSET 20
|
||||
|
||||
#define RX_FIFO_SC(x) (((x) & AUDIO_PORT_RX_FIFO_LEVEL_CHECK_MASK) \
|
||||
<< AUDIO_PORT_RX_FIFO_SC_OFFSET)
|
||||
#define RX_FIFO_LC(x) (((x) & AUDIO_PORT_RX_FIFO_LEVEL_CHECK_MASK) \
|
||||
<< AUDIO_PORT_RX_FIFO_LC_OFFSET)
|
||||
#define RX_FIFO_HC(x) (((x) & AUDIO_PORT_RX_FIFO_LEVEL_CHECK_MASK) \
|
||||
<< AUDIO_PORT_RX_FIFO_HC_OFFSET)
|
||||
#define AUDIO_PORT_IC_CODEC_TX_CTRL (0x00F4)
|
||||
#define AUDIO_PORT_IC_CODEC_RX_CTRL (0x00F8)
|
||||
|
||||
#define AUDIO_PORT_IC_TXFIFO_OP (0x00FC)
|
||||
#define AUDIO_PORT_IC_TXFIFO_LEV_CHK (0x0100)
|
||||
#define AUDIO_PORT_IC_TXFIFO_STS (0x0104)
|
||||
#define AUDIO_PORT_IC_TXFIFO_INT (0x0108)
|
||||
#define AUDIO_PORT_IC_TXFIFO_INT_MSK (0x010C)
|
||||
|
||||
#define AUDIO_PORT_IC_RXFIFO_OP (0x0110)
|
||||
#define AUDIO_PORT_IC_RXFIFO_LEV_CHK (0x0114)
|
||||
#define AUDIO_PORT_IC_RXFIFO_STS (0x0118)
|
||||
#define AUDIO_PORT_IC_RXFIFO_INT (0x011C)
|
||||
#define AUDIO_PORT_IC_RXFIFO_INT_MSK (0x0120)
|
||||
|
||||
#define AUDIO_FIFO_START (1 << 0)
|
||||
#define AUDIO_FIFO_RESET (1 << 1)
|
||||
|
||||
#define AUDIO_FIFO_FULL (1 << 0)
|
||||
#define AUDIO_FIFO_EMPTY (1 << 1)
|
||||
#define AUDIO_FIFO_OFLOW (1 << 2)
|
||||
#define AUDIO_FIFO_UFLOW (1 << 3)
|
||||
|
||||
#define IC_TX_ENABLE (0x03)
|
||||
#define IC_RX_ENABLE_MONO (0x01)
|
||||
#define IC_RX_ENABLE_STEREO (0x03)
|
||||
|
||||
#endif /*__SIRF_AUDIO_PORT_H*/
|
156
sound/soc/sirf/sirf-audio.c
Normal file
156
sound/soc/sirf/sirf-audio.c
Normal file
|
@ -0,0 +1,156 @@
|
|||
/*
|
||||
* SiRF audio card driver
|
||||
*
|
||||
* Copyright (c) 2011 Cambridge Silicon Radio Limited, a CSR plc group company.
|
||||
*
|
||||
* Licensed under GPLv2 or later.
|
||||
*/
|
||||
|
||||
#include <linux/platform_device.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>
|
||||
|
||||
struct sirf_audio_card {
|
||||
unsigned int gpio_hp_pa;
|
||||
unsigned int gpio_spk_pa;
|
||||
};
|
||||
|
||||
static int sirf_audio_hp_event(struct snd_soc_dapm_widget *w,
|
||||
struct snd_kcontrol *ctrl, int event)
|
||||
{
|
||||
struct snd_soc_dapm_context *dapm = w->dapm;
|
||||
struct snd_soc_card *card = dapm->card;
|
||||
struct sirf_audio_card *sirf_audio_card = snd_soc_card_get_drvdata(card);
|
||||
int on = !SND_SOC_DAPM_EVENT_OFF(event);
|
||||
if (gpio_is_valid(sirf_audio_card->gpio_hp_pa))
|
||||
gpio_set_value(sirf_audio_card->gpio_hp_pa, on);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int sirf_audio_spk_event(struct snd_soc_dapm_widget *w,
|
||||
struct snd_kcontrol *ctrl, int event)
|
||||
{
|
||||
struct snd_soc_dapm_context *dapm = w->dapm;
|
||||
struct snd_soc_card *card = dapm->card;
|
||||
struct sirf_audio_card *sirf_audio_card = snd_soc_card_get_drvdata(card);
|
||||
int on = !SND_SOC_DAPM_EVENT_OFF(event);
|
||||
|
||||
if (gpio_is_valid(sirf_audio_card->gpio_spk_pa))
|
||||
gpio_set_value(sirf_audio_card->gpio_spk_pa, on);
|
||||
|
||||
return 0;
|
||||
}
|
||||
static const struct snd_soc_dapm_widget sirf_audio_dapm_widgets[] = {
|
||||
SND_SOC_DAPM_HP("Hp", sirf_audio_hp_event),
|
||||
SND_SOC_DAPM_SPK("Ext Spk", sirf_audio_spk_event),
|
||||
SND_SOC_DAPM_MIC("Ext Mic", NULL),
|
||||
};
|
||||
|
||||
static const struct snd_soc_dapm_route intercon[] = {
|
||||
{"Hp", NULL, "HPOUTL"},
|
||||
{"Hp", NULL, "HPOUTR"},
|
||||
{"Ext Spk", NULL, "SPKOUT"},
|
||||
{"MICIN1", NULL, "Mic Bias"},
|
||||
{"Mic Bias", NULL, "Ext Mic"},
|
||||
};
|
||||
|
||||
/* Digital audio interface glue - connects codec <--> CPU */
|
||||
static struct snd_soc_dai_link sirf_audio_dai_link[] = {
|
||||
{
|
||||
.name = "SiRF audio card",
|
||||
.stream_name = "SiRF audio HiFi",
|
||||
.codec_dai_name = "sirf-audio-codec",
|
||||
},
|
||||
};
|
||||
|
||||
/* Audio machine driver */
|
||||
static struct snd_soc_card snd_soc_sirf_audio_card = {
|
||||
.name = "SiRF audio card",
|
||||
.owner = THIS_MODULE,
|
||||
.dai_link = sirf_audio_dai_link,
|
||||
.num_links = ARRAY_SIZE(sirf_audio_dai_link),
|
||||
.dapm_widgets = sirf_audio_dapm_widgets,
|
||||
.num_dapm_widgets = ARRAY_SIZE(sirf_audio_dapm_widgets),
|
||||
.dapm_routes = intercon,
|
||||
.num_dapm_routes = ARRAY_SIZE(intercon),
|
||||
};
|
||||
|
||||
static int sirf_audio_probe(struct platform_device *pdev)
|
||||
{
|
||||
struct snd_soc_card *card = &snd_soc_sirf_audio_card;
|
||||
struct sirf_audio_card *sirf_audio_card;
|
||||
int ret;
|
||||
|
||||
sirf_audio_card = devm_kzalloc(&pdev->dev, sizeof(struct sirf_audio_card),
|
||||
GFP_KERNEL);
|
||||
if (sirf_audio_card == NULL)
|
||||
return -ENOMEM;
|
||||
|
||||
sirf_audio_dai_link[0].cpu_of_node =
|
||||
of_parse_phandle(pdev->dev.of_node, "sirf,audio-platform", 0);
|
||||
sirf_audio_dai_link[0].platform_of_node =
|
||||
of_parse_phandle(pdev->dev.of_node, "sirf,audio-platform", 0);
|
||||
sirf_audio_dai_link[0].codec_of_node =
|
||||
of_parse_phandle(pdev->dev.of_node, "sirf,audio-codec", 0);
|
||||
sirf_audio_card->gpio_spk_pa = of_get_named_gpio(pdev->dev.of_node,
|
||||
"spk-pa-gpios", 0);
|
||||
sirf_audio_card->gpio_hp_pa = of_get_named_gpio(pdev->dev.of_node,
|
||||
"hp-pa-gpios", 0);
|
||||
if (gpio_is_valid(sirf_audio_card->gpio_spk_pa)) {
|
||||
ret = devm_gpio_request_one(&pdev->dev,
|
||||
sirf_audio_card->gpio_spk_pa,
|
||||
GPIOF_OUT_INIT_LOW, "SPA_PA_SD");
|
||||
if (ret) {
|
||||
dev_err(&pdev->dev,
|
||||
"Failed to request GPIO_%d for reset: %d\n",
|
||||
sirf_audio_card->gpio_spk_pa, ret);
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
if (gpio_is_valid(sirf_audio_card->gpio_hp_pa)) {
|
||||
ret = devm_gpio_request_one(&pdev->dev,
|
||||
sirf_audio_card->gpio_hp_pa,
|
||||
GPIOF_OUT_INIT_LOW, "HP_PA_SD");
|
||||
if (ret) {
|
||||
dev_err(&pdev->dev,
|
||||
"Failed to request GPIO_%d for reset: %d\n",
|
||||
sirf_audio_card->gpio_hp_pa, ret);
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
card->dev = &pdev->dev;
|
||||
snd_soc_card_set_drvdata(card, sirf_audio_card);
|
||||
|
||||
ret = devm_snd_soc_register_card(&pdev->dev, card);
|
||||
if (ret)
|
||||
dev_err(&pdev->dev, "snd_soc_register_card() failed:%d\n", ret);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static const struct of_device_id sirf_audio_of_match[] = {
|
||||
{.compatible = "sirf,sirf-audio-card", },
|
||||
{ },
|
||||
};
|
||||
MODULE_DEVICE_TABLE(of, sirf_audio_of_match);
|
||||
|
||||
static struct platform_driver sirf_audio_driver = {
|
||||
.driver = {
|
||||
.name = "sirf-audio-card",
|
||||
.owner = THIS_MODULE,
|
||||
.pm = &snd_soc_pm_ops,
|
||||
.of_match_table = sirf_audio_of_match,
|
||||
},
|
||||
.probe = sirf_audio_probe,
|
||||
};
|
||||
module_platform_driver(sirf_audio_driver);
|
||||
|
||||
MODULE_AUTHOR("RongJun Ying <RongJun.Ying@csr.com>");
|
||||
MODULE_DESCRIPTION("ALSA SoC SIRF audio card driver");
|
||||
MODULE_LICENSE("GPL v2");
|
Loading…
Reference in a new issue