Commit 7cc64172 authored by Mark Brown's avatar Mark Brown

Merge remote-tracking branches 'asoc/topic/samsung', 'asoc/topic/sgtl5000',...

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
......@@ -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>;
......
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>;
};
* 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";
};
* 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>;
};
/* arch/arm/plat-samsung/include/plat/audio.h
*
/*
* Copyright (c) 2009 Samsung Electronics Co. Ltd
* Author: Jaswinder Singh <jassi.brar@samsung.com>
*
......
/* 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);
......
This diff is collapsed.
/*
* 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),
......
/*
* 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");
/*
* 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 (ssm2602 == NULL)
return -ENOMEM;
if (IS_ERR(regmap))
return PTR_ERR(regmap);
spi_set_drvdata(spi, ssm2602);
ssm2602->type = SSM2602;
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;
}
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);
ssm2602 = devm_kzalloc(dev, sizeof(*ssm2602), 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
dev_set_drvdata(dev, ssm2602);
ssm2602->type = SSM2602;
ssm2602->regmap = regmap;
#if IS_ENABLED(CONFIG_I2C)
i2c_del_driver(&ssm2602_i2c_driver);
#endif
return snd_soc_register_codec(dev, &soc_codec_dev_ssm2602,
&ssm2602_dai, 1);
}
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,
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 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_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);
......
This diff is collapsed.
......@@ -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;
......
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
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
/*
* 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");
/*
* 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*/
/*
* 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");
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment