#include <linux/init.h>
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/platform_device.h>
#include <linux/delay.h>
#include <linux/slab.h>
#include <linux/clk.h>
#include <linux/regmap.h>
#include <linux/reset.h>
#include <linux/gpio/consumer.h>
#include <sound/core.h>
#include <sound/pcm.h>
#include <sound/pcm_params.h>
#include <sound/soc.h>
#include <sound/tlv.h>
#include <sound/initval.h>
#include <sound/dmaengine_pcm.h>
#define SUN4I_CODEC_DAC_DPC …
#define SUN4I_CODEC_DAC_DPC_EN_DA …
#define SUN4I_CODEC_DAC_DPC_DVOL …
#define SUN4I_CODEC_DAC_FIFOC …
#define SUN4I_CODEC_DAC_FIFOC_DAC_FS …
#define SUN4I_CODEC_DAC_FIFOC_FIR_VERSION …
#define SUN4I_CODEC_DAC_FIFOC_SEND_LASAT …
#define SUN4I_CODEC_DAC_FIFOC_TX_FIFO_MODE …
#define SUN4I_CODEC_DAC_FIFOC_DRQ_CLR_CNT …
#define SUN4I_CODEC_DAC_FIFOC_TX_TRIG_LEVEL …
#define SUN4I_CODEC_DAC_FIFOC_MONO_EN …
#define SUN4I_CODEC_DAC_FIFOC_TX_SAMPLE_BITS …
#define SUN4I_CODEC_DAC_FIFOC_DAC_DRQ_EN …
#define SUN4I_CODEC_DAC_FIFOC_FIFO_FLUSH …
#define SUN4I_CODEC_DAC_FIFOS …
#define SUN4I_CODEC_DAC_TXDATA …
#define SUN4I_CODEC_DAC_ACTL …
#define SUN4I_CODEC_DAC_ACTL_DACAENR …
#define SUN4I_CODEC_DAC_ACTL_DACAENL …
#define SUN4I_CODEC_DAC_ACTL_MIXEN …
#define SUN4I_CODEC_DAC_ACTL_LNG …
#define SUN4I_CODEC_DAC_ACTL_FMG …
#define SUN4I_CODEC_DAC_ACTL_MICG …
#define SUN4I_CODEC_DAC_ACTL_LLNS …
#define SUN4I_CODEC_DAC_ACTL_RLNS …
#define SUN4I_CODEC_DAC_ACTL_LFMS …
#define SUN4I_CODEC_DAC_ACTL_RFMS …
#define SUN4I_CODEC_DAC_ACTL_LDACLMIXS …
#define SUN4I_CODEC_DAC_ACTL_RDACRMIXS …
#define SUN4I_CODEC_DAC_ACTL_LDACRMIXS …
#define SUN4I_CODEC_DAC_ACTL_MIC1LS …
#define SUN4I_CODEC_DAC_ACTL_MIC1RS …
#define SUN4I_CODEC_DAC_ACTL_MIC2LS …
#define SUN4I_CODEC_DAC_ACTL_MIC2RS …
#define SUN4I_CODEC_DAC_ACTL_DACPAS …
#define SUN4I_CODEC_DAC_ACTL_MIXPAS …
#define SUN4I_CODEC_DAC_ACTL_PA_MUTE …
#define SUN4I_CODEC_DAC_ACTL_PA_VOL …
#define SUN4I_CODEC_DAC_TUNE …
#define SUN4I_CODEC_DAC_DEBUG …
#define SUN4I_CODEC_ADC_FIFOC …
#define SUN4I_CODEC_ADC_FIFOC_ADC_FS …
#define SUN4I_CODEC_ADC_FIFOC_EN_AD …
#define SUN4I_CODEC_ADC_FIFOC_RX_FIFO_MODE …
#define SUN4I_CODEC_ADC_FIFOC_RX_TRIG_LEVEL …
#define SUN4I_CODEC_ADC_FIFOC_MONO_EN …
#define SUN4I_CODEC_ADC_FIFOC_RX_SAMPLE_BITS …
#define SUN4I_CODEC_ADC_FIFOC_ADC_DRQ_EN …
#define SUN4I_CODEC_ADC_FIFOC_FIFO_FLUSH …
#define SUN4I_CODEC_ADC_FIFOS …
#define SUN4I_CODEC_ADC_RXDATA …
#define SUN4I_CODEC_ADC_ACTL …
#define SUN4I_CODEC_ADC_ACTL_ADC_R_EN …
#define SUN4I_CODEC_ADC_ACTL_ADC_L_EN …
#define SUN4I_CODEC_ADC_ACTL_PREG1EN …
#define SUN4I_CODEC_ADC_ACTL_PREG2EN …
#define SUN4I_CODEC_ADC_ACTL_VMICEN …
#define SUN4I_CODEC_ADC_ACTL_PREG1 …
#define SUN4I_CODEC_ADC_ACTL_PREG2 …
#define SUN4I_CODEC_ADC_ACTL_VADCG …
#define SUN4I_CODEC_ADC_ACTL_ADCIS …
#define SUN4I_CODEC_ADC_ACTL_LNPREG …
#define SUN4I_CODEC_ADC_ACTL_PA_EN …
#define SUN4I_CODEC_ADC_ACTL_DDE …
#define SUN4I_CODEC_ADC_DEBUG …
#define SUN4I_CODEC_DAC_TXCNT …
#define SUN4I_CODEC_ADC_RXCNT …
#define SUN7I_CODEC_AC_DAC_CAL …
#define SUN7I_CODEC_AC_MIC_PHONE_CAL …
#define SUN7I_CODEC_AC_MIC_PHONE_CAL_PREG1 …
#define SUN7I_CODEC_AC_MIC_PHONE_CAL_PREG2 …
#define SUN6I_CODEC_ADC_FIFOC …
#define SUN6I_CODEC_ADC_FIFOC_EN_AD …
#define SUN6I_CODEC_ADC_FIFOS …
#define SUN6I_CODEC_ADC_RXDATA …
#define SUN6I_CODEC_OM_DACA_CTRL …
#define SUN6I_CODEC_OM_DACA_CTRL_DACAREN …
#define SUN6I_CODEC_OM_DACA_CTRL_DACALEN …
#define SUN6I_CODEC_OM_DACA_CTRL_RMIXEN …
#define SUN6I_CODEC_OM_DACA_CTRL_LMIXEN …
#define SUN6I_CODEC_OM_DACA_CTRL_RMIX_MIC1 …
#define SUN6I_CODEC_OM_DACA_CTRL_RMIX_MIC2 …
#define SUN6I_CODEC_OM_DACA_CTRL_RMIX_PHONE …
#define SUN6I_CODEC_OM_DACA_CTRL_RMIX_PHONEP …
#define SUN6I_CODEC_OM_DACA_CTRL_RMIX_LINEINR …
#define SUN6I_CODEC_OM_DACA_CTRL_RMIX_DACR …
#define SUN6I_CODEC_OM_DACA_CTRL_RMIX_DACL …
#define SUN6I_CODEC_OM_DACA_CTRL_LMIX_MIC1 …
#define SUN6I_CODEC_OM_DACA_CTRL_LMIX_MIC2 …
#define SUN6I_CODEC_OM_DACA_CTRL_LMIX_PHONE …
#define SUN6I_CODEC_OM_DACA_CTRL_LMIX_PHONEN …
#define SUN6I_CODEC_OM_DACA_CTRL_LMIX_LINEINL …
#define SUN6I_CODEC_OM_DACA_CTRL_LMIX_DACL …
#define SUN6I_CODEC_OM_DACA_CTRL_LMIX_DACR …
#define SUN6I_CODEC_OM_DACA_CTRL_RHPIS …
#define SUN6I_CODEC_OM_DACA_CTRL_LHPIS …
#define SUN6I_CODEC_OM_DACA_CTRL_RHPPAMUTE …
#define SUN6I_CODEC_OM_DACA_CTRL_LHPPAMUTE …
#define SUN6I_CODEC_OM_DACA_CTRL_HPVOL …
#define SUN6I_CODEC_OM_PA_CTRL …
#define SUN6I_CODEC_OM_PA_CTRL_HPPAEN …
#define SUN6I_CODEC_OM_PA_CTRL_HPCOM_CTL …
#define SUN6I_CODEC_OM_PA_CTRL_COMPTEN …
#define SUN6I_CODEC_OM_PA_CTRL_MIC1G …
#define SUN6I_CODEC_OM_PA_CTRL_MIC2G …
#define SUN6I_CODEC_OM_PA_CTRL_LINEING …
#define SUN6I_CODEC_OM_PA_CTRL_PHONEG …
#define SUN6I_CODEC_OM_PA_CTRL_PHONEPG …
#define SUN6I_CODEC_OM_PA_CTRL_PHONENG …
#define SUN6I_CODEC_MIC_CTRL …
#define SUN6I_CODEC_MIC_CTRL_HBIASEN …
#define SUN6I_CODEC_MIC_CTRL_MBIASEN …
#define SUN6I_CODEC_MIC_CTRL_MIC1AMPEN …
#define SUN6I_CODEC_MIC_CTRL_MIC1BOOST …
#define SUN6I_CODEC_MIC_CTRL_MIC2AMPEN …
#define SUN6I_CODEC_MIC_CTRL_MIC2BOOST …
#define SUN6I_CODEC_MIC_CTRL_MIC2SLT …
#define SUN6I_CODEC_MIC_CTRL_LINEOUTLEN …
#define SUN6I_CODEC_MIC_CTRL_LINEOUTREN …
#define SUN6I_CODEC_MIC_CTRL_LINEOUTLSRC …
#define SUN6I_CODEC_MIC_CTRL_LINEOUTRSRC …
#define SUN6I_CODEC_MIC_CTRL_LINEOUTVC …
#define SUN6I_CODEC_MIC_CTRL_PHONEPREG …
#define SUN6I_CODEC_ADC_ACTL …
#define SUN6I_CODEC_ADC_ACTL_ADCREN …
#define SUN6I_CODEC_ADC_ACTL_ADCLEN …
#define SUN6I_CODEC_ADC_ACTL_ADCRG …
#define SUN6I_CODEC_ADC_ACTL_ADCLG …
#define SUN6I_CODEC_ADC_ACTL_RADCMIX_MIC1 …
#define SUN6I_CODEC_ADC_ACTL_RADCMIX_MIC2 …
#define SUN6I_CODEC_ADC_ACTL_RADCMIX_PHONE …
#define SUN6I_CODEC_ADC_ACTL_RADCMIX_PHONEP …
#define SUN6I_CODEC_ADC_ACTL_RADCMIX_LINEINR …
#define SUN6I_CODEC_ADC_ACTL_RADCMIX_OMIXR …
#define SUN6I_CODEC_ADC_ACTL_RADCMIX_OMIXL …
#define SUN6I_CODEC_ADC_ACTL_LADCMIX_MIC1 …
#define SUN6I_CODEC_ADC_ACTL_LADCMIX_MIC2 …
#define SUN6I_CODEC_ADC_ACTL_LADCMIX_PHONE …
#define SUN6I_CODEC_ADC_ACTL_LADCMIX_PHONEN …
#define SUN6I_CODEC_ADC_ACTL_LADCMIX_LINEINL …
#define SUN6I_CODEC_ADC_ACTL_LADCMIX_OMIXL …
#define SUN6I_CODEC_ADC_ACTL_LADCMIX_OMIXR …
#define SUN6I_CODEC_ADDA_TUNE …
#define SUN6I_CODEC_CALIBRATION …
#define SUN6I_CODEC_DAC_TXCNT …
#define SUN6I_CODEC_ADC_RXCNT …
#define SUN6I_CODEC_HMIC_CTL …
#define SUN6I_CODEC_HMIC_DATA …
#define SUN8I_A23_CODEC_DAC_TXCNT …
#define SUN8I_A23_CODEC_ADC_RXCNT …
#define SUN8I_H3_CODEC_DAC_TXDATA …
#define SUN8I_H3_CODEC_DAC_DBG …
#define SUN8I_H3_CODEC_ADC_DBG …
struct sun4i_codec { … };
static void sun4i_codec_start_playback(struct sun4i_codec *scodec)
{ … }
static void sun4i_codec_stop_playback(struct sun4i_codec *scodec)
{ … }
static void sun4i_codec_start_capture(struct sun4i_codec *scodec)
{ … }
static void sun4i_codec_stop_capture(struct sun4i_codec *scodec)
{ … }
static int sun4i_codec_trigger(struct snd_pcm_substream *substream, int cmd,
struct snd_soc_dai *dai)
{ … }
static int sun4i_codec_prepare_capture(struct snd_pcm_substream *substream,
struct snd_soc_dai *dai)
{ … }
static int sun4i_codec_prepare_playback(struct snd_pcm_substream *substream,
struct snd_soc_dai *dai)
{
struct snd_soc_pcm_runtime *rtd = snd_soc_substream_to_rtd(substream);
struct sun4i_codec *scodec = snd_soc_card_get_drvdata(rtd->card);
u32 val;
regmap_set_bits(scodec->regmap, SUN4I_CODEC_DAC_FIFOC,
BIT(SUN4I_CODEC_DAC_FIFOC_FIFO_FLUSH));
regmap_update_bits(scodec->regmap, SUN4I_CODEC_DAC_FIFOC,
0x3f << SUN4I_CODEC_DAC_FIFOC_TX_TRIG_LEVEL,
0xf << SUN4I_CODEC_DAC_FIFOC_TX_TRIG_LEVEL);
if (substream->runtime->rate > 32000)
val = 0;
else
val = BIT(SUN4I_CODEC_DAC_FIFOC_FIR_VERSION);
regmap_update_bits(scodec->regmap, SUN4I_CODEC_DAC_FIFOC,
BIT(SUN4I_CODEC_DAC_FIFOC_FIR_VERSION),
val);
regmap_clear_bits(scodec->regmap, SUN4I_CODEC_DAC_FIFOC,
BIT(SUN4I_CODEC_DAC_FIFOC_SEND_LASAT));
return 0;
};
static int sun4i_codec_prepare(struct snd_pcm_substream *substream,
struct snd_soc_dai *dai)
{ … }
static unsigned long sun4i_codec_get_mod_freq(struct snd_pcm_hw_params *params)
{ … }
static int sun4i_codec_get_hw_rate(struct snd_pcm_hw_params *params)
{ … }
static int sun4i_codec_hw_params_capture(struct sun4i_codec *scodec,
struct snd_pcm_hw_params *params,
unsigned int hwrate)
{ … }
static int sun4i_codec_hw_params_playback(struct sun4i_codec *scodec,
struct snd_pcm_hw_params *params,
unsigned int hwrate)
{ … }
static int sun4i_codec_hw_params(struct snd_pcm_substream *substream,
struct snd_pcm_hw_params *params,
struct snd_soc_dai *dai)
{ … }
static unsigned int sun4i_codec_src_rates[] = …;
static struct snd_pcm_hw_constraint_list sun4i_codec_constraints = …;
static int sun4i_codec_startup(struct snd_pcm_substream *substream,
struct snd_soc_dai *dai)
{ … }
static void sun4i_codec_shutdown(struct snd_pcm_substream *substream,
struct snd_soc_dai *dai)
{ … }
static const struct snd_soc_dai_ops sun4i_codec_dai_ops = …;
static struct snd_soc_dai_driver sun4i_codec_dai = …;
static const struct snd_kcontrol_new sun4i_codec_pa_mute = …;
static DECLARE_TLV_DB_SCALE(sun4i_codec_pa_volume_scale, -6300, 100, 1);
static DECLARE_TLV_DB_SCALE(sun4i_codec_linein_loopback_gain_scale, -150, 150,
0);
static DECLARE_TLV_DB_SCALE(sun4i_codec_linein_preamp_gain_scale, -1200, 300,
0);
static DECLARE_TLV_DB_SCALE(sun4i_codec_fmin_loopback_gain_scale, -450, 150,
0);
static DECLARE_TLV_DB_SCALE(sun4i_codec_micin_loopback_gain_scale, -450, 150,
0);
static DECLARE_TLV_DB_RANGE(sun4i_codec_micin_preamp_gain_scale,
0, 0, TLV_DB_SCALE_ITEM(0, 0, 0),
1, 7, TLV_DB_SCALE_ITEM(3500, 300, 0));
static DECLARE_TLV_DB_RANGE(sun7i_codec_micin_preamp_gain_scale,
0, 0, TLV_DB_SCALE_ITEM(0, 0, 0),
1, 7, TLV_DB_SCALE_ITEM(2400, 300, 0));
static const struct snd_kcontrol_new sun4i_codec_controls[] = …;
static const struct snd_kcontrol_new sun7i_codec_controls[] = …;
static const struct snd_kcontrol_new sun4i_codec_mixer_controls[] = …;
static const struct snd_kcontrol_new sun4i_codec_pa_mixer_controls[] = …;
static const struct snd_soc_dapm_widget sun4i_codec_codec_dapm_widgets[] = …;
static const struct snd_soc_dapm_route sun4i_codec_codec_dapm_routes[] = …;
static const struct snd_soc_component_driver sun4i_codec_codec = …;
static const struct snd_soc_component_driver sun7i_codec_codec = …;
static const struct snd_kcontrol_new sun6i_codec_mixer_controls[] = …;
static const struct snd_kcontrol_new sun6i_codec_adc_mixer_controls[] = …;
static const char * const sun6i_codec_hp_src_enum_text[] = …;
static SOC_ENUM_DOUBLE_DECL(sun6i_codec_hp_src_enum,
SUN6I_CODEC_OM_DACA_CTRL,
SUN6I_CODEC_OM_DACA_CTRL_LHPIS,
SUN6I_CODEC_OM_DACA_CTRL_RHPIS,
sun6i_codec_hp_src_enum_text);
static const struct snd_kcontrol_new sun6i_codec_hp_src[] = …;
static const char * const sun6i_codec_mic2_src_enum_text[] = …;
static SOC_ENUM_SINGLE_DECL(sun6i_codec_mic2_src_enum,
SUN6I_CODEC_MIC_CTRL,
SUN6I_CODEC_MIC_CTRL_MIC2SLT,
sun6i_codec_mic2_src_enum_text);
static const struct snd_kcontrol_new sun6i_codec_mic2_src[] = …;
static const char * const sun6i_codec_lineout_src_enum_text[] = …;
static SOC_ENUM_DOUBLE_DECL(sun6i_codec_lineout_src_enum,
SUN6I_CODEC_MIC_CTRL,
SUN6I_CODEC_MIC_CTRL_LINEOUTLSRC,
SUN6I_CODEC_MIC_CTRL_LINEOUTRSRC,
sun6i_codec_lineout_src_enum_text);
static const struct snd_kcontrol_new sun6i_codec_lineout_src[] = …;
static const DECLARE_TLV_DB_SCALE(sun6i_codec_dvol_scale, -7308, 116, 0);
static const DECLARE_TLV_DB_SCALE(sun6i_codec_hp_vol_scale, -6300, 100, 1);
static const DECLARE_TLV_DB_SCALE(sun6i_codec_out_mixer_pregain_scale,
-450, 150, 0);
static const DECLARE_TLV_DB_RANGE(sun6i_codec_lineout_vol_scale,
0, 1, TLV_DB_SCALE_ITEM(TLV_DB_GAIN_MUTE, 0, 1),
2, 31, TLV_DB_SCALE_ITEM(-4350, 150, 0),
);
static const DECLARE_TLV_DB_RANGE(sun6i_codec_mic_gain_scale,
0, 0, TLV_DB_SCALE_ITEM(0, 0, 0),
1, 7, TLV_DB_SCALE_ITEM(2400, 300, 0),
);
static const struct snd_kcontrol_new sun6i_codec_codec_widgets[] = …;
static const struct snd_soc_dapm_widget sun6i_codec_codec_dapm_widgets[] = …;
static const struct snd_soc_dapm_route sun6i_codec_codec_dapm_routes[] = …;
static const struct snd_soc_component_driver sun6i_codec_codec = …;
static const struct snd_kcontrol_new sun8i_a23_codec_codec_controls[] = …;
static const struct snd_soc_dapm_widget sun8i_a23_codec_codec_widgets[] = …;
static const struct snd_soc_component_driver sun8i_a23_codec_codec = …;
static const struct snd_soc_component_driver sun4i_codec_component = …;
#define SUN4I_CODEC_RATES …
#define SUN4I_CODEC_FORMATS …
static int sun4i_codec_dai_probe(struct snd_soc_dai *dai)
{ … }
static const struct snd_soc_dai_ops dummy_dai_ops = …;
static struct snd_soc_dai_driver dummy_cpu_dai = …;
static struct snd_soc_dai_link *sun4i_codec_create_link(struct device *dev,
int *num_links)
{
struct snd_soc_dai_link *link = devm_kzalloc(dev, sizeof(*link),
GFP_KERNEL);
struct snd_soc_dai_link_component *dlc = devm_kzalloc(dev,
3 * sizeof(*dlc), GFP_KERNEL);
if (!link || !dlc)
return NULL;
link->cpus = &dlc[0];
link->codecs = &dlc[1];
link->platforms = &dlc[2];
link->num_cpus = 1;
link->num_codecs = 1;
link->num_platforms = 1;
link->name = "cdc";
link->stream_name = "CDC PCM";
link->codecs->dai_name = "Codec";
link->cpus->dai_name = dev_name(dev);
link->codecs->name = dev_name(dev);
link->platforms->name = dev_name(dev);
link->dai_fmt = SND_SOC_DAIFMT_I2S;
*num_links = 1;
return link;
};
static int sun4i_codec_spk_event(struct snd_soc_dapm_widget *w,
struct snd_kcontrol *k, int event)
{ … }
static const struct snd_soc_dapm_widget sun4i_codec_card_dapm_widgets[] = …;
static const struct snd_soc_dapm_route sun4i_codec_card_dapm_routes[] = …;
static struct snd_soc_card *sun4i_codec_create_card(struct device *dev)
{
struct snd_soc_card *card;
card = devm_kzalloc(dev, sizeof(*card), GFP_KERNEL);
if (!card)
return ERR_PTR(-ENOMEM);
card->dai_link = sun4i_codec_create_link(dev, &card->num_links);
if (!card->dai_link)
return ERR_PTR(-ENOMEM);
card->dev = dev;
card->owner = THIS_MODULE;
card->name = "sun4i-codec";
card->dapm_widgets = sun4i_codec_card_dapm_widgets;
card->num_dapm_widgets = ARRAY_SIZE(sun4i_codec_card_dapm_widgets);
card->dapm_routes = sun4i_codec_card_dapm_routes;
card->num_dapm_routes = ARRAY_SIZE(sun4i_codec_card_dapm_routes);
return card;
};
static const struct snd_soc_dapm_widget sun6i_codec_card_dapm_widgets[] = …;
static struct snd_soc_card *sun6i_codec_create_card(struct device *dev)
{
struct snd_soc_card *card;
int ret;
card = devm_kzalloc(dev, sizeof(*card), GFP_KERNEL);
if (!card)
return ERR_PTR(-ENOMEM);
card->dai_link = sun4i_codec_create_link(dev, &card->num_links);
if (!card->dai_link)
return ERR_PTR(-ENOMEM);
card->dev = dev;
card->owner = THIS_MODULE;
card->name = "A31 Audio Codec";
card->dapm_widgets = sun6i_codec_card_dapm_widgets;
card->num_dapm_widgets = ARRAY_SIZE(sun6i_codec_card_dapm_widgets);
card->fully_routed = true;
ret = snd_soc_of_parse_audio_routing(card, "allwinner,audio-routing");
if (ret)
dev_warn(dev, "failed to parse audio-routing: %d\n", ret);
return card;
};
static const struct snd_soc_dapm_route sun8i_codec_card_routes[] = …;
static struct snd_soc_aux_dev aux_dev = …;
static struct snd_soc_card *sun8i_a23_codec_create_card(struct device *dev)
{
struct snd_soc_card *card;
int ret;
card = devm_kzalloc(dev, sizeof(*card), GFP_KERNEL);
if (!card)
return ERR_PTR(-ENOMEM);
aux_dev.dlc.of_node = of_parse_phandle(dev->of_node,
"allwinner,codec-analog-controls",
0);
if (!aux_dev.dlc.of_node) {
dev_err(dev, "Can't find analog controls for codec.\n");
return ERR_PTR(-EINVAL);
}
card->dai_link = sun4i_codec_create_link(dev, &card->num_links);
if (!card->dai_link)
return ERR_PTR(-ENOMEM);
card->dev = dev;
card->owner = THIS_MODULE;
card->name = "A23 Audio Codec";
card->dapm_widgets = sun6i_codec_card_dapm_widgets;
card->num_dapm_widgets = ARRAY_SIZE(sun6i_codec_card_dapm_widgets);
card->dapm_routes = sun8i_codec_card_routes;
card->num_dapm_routes = ARRAY_SIZE(sun8i_codec_card_routes);
card->aux_dev = &aux_dev;
card->num_aux_devs = 1;
card->fully_routed = true;
ret = snd_soc_of_parse_audio_routing(card, "allwinner,audio-routing");
if (ret)
dev_warn(dev, "failed to parse audio-routing: %d\n", ret);
return card;
};
static struct snd_soc_card *sun8i_h3_codec_create_card(struct device *dev)
{
struct snd_soc_card *card;
int ret;
card = devm_kzalloc(dev, sizeof(*card), GFP_KERNEL);
if (!card)
return ERR_PTR(-ENOMEM);
aux_dev.dlc.of_node = of_parse_phandle(dev->of_node,
"allwinner,codec-analog-controls",
0);
if (!aux_dev.dlc.of_node) {
dev_err(dev, "Can't find analog controls for codec.\n");
return ERR_PTR(-EINVAL);
}
card->dai_link = sun4i_codec_create_link(dev, &card->num_links);
if (!card->dai_link)
return ERR_PTR(-ENOMEM);
card->dev = dev;
card->owner = THIS_MODULE;
card->name = "H3 Audio Codec";
card->dapm_widgets = sun6i_codec_card_dapm_widgets;
card->num_dapm_widgets = ARRAY_SIZE(sun6i_codec_card_dapm_widgets);
card->dapm_routes = sun8i_codec_card_routes;
card->num_dapm_routes = ARRAY_SIZE(sun8i_codec_card_routes);
card->aux_dev = &aux_dev;
card->num_aux_devs = 1;
card->fully_routed = true;
ret = snd_soc_of_parse_audio_routing(card, "allwinner,audio-routing");
if (ret)
dev_warn(dev, "failed to parse audio-routing: %d\n", ret);
return card;
};
static struct snd_soc_card *sun8i_v3s_codec_create_card(struct device *dev)
{
struct snd_soc_card *card;
int ret;
card = devm_kzalloc(dev, sizeof(*card), GFP_KERNEL);
if (!card)
return ERR_PTR(-ENOMEM);
aux_dev.dlc.of_node = of_parse_phandle(dev->of_node,
"allwinner,codec-analog-controls",
0);
if (!aux_dev.dlc.of_node) {
dev_err(dev, "Can't find analog controls for codec.\n");
return ERR_PTR(-EINVAL);
}
card->dai_link = sun4i_codec_create_link(dev, &card->num_links);
if (!card->dai_link)
return ERR_PTR(-ENOMEM);
card->dev = dev;
card->owner = THIS_MODULE;
card->name = "V3s Audio Codec";
card->dapm_widgets = sun6i_codec_card_dapm_widgets;
card->num_dapm_widgets = ARRAY_SIZE(sun6i_codec_card_dapm_widgets);
card->dapm_routes = sun8i_codec_card_routes;
card->num_dapm_routes = ARRAY_SIZE(sun8i_codec_card_routes);
card->aux_dev = &aux_dev;
card->num_aux_devs = 1;
card->fully_routed = true;
ret = snd_soc_of_parse_audio_routing(card, "allwinner,audio-routing");
if (ret)
dev_warn(dev, "failed to parse audio-routing: %d\n", ret);
return card;
};
static const struct regmap_config sun4i_codec_regmap_config = …;
static const struct regmap_config sun6i_codec_regmap_config = …;
static const struct regmap_config sun7i_codec_regmap_config = …;
static const struct regmap_config sun8i_a23_codec_regmap_config = …;
static const struct regmap_config sun8i_h3_codec_regmap_config = …;
static const struct regmap_config sun8i_v3s_codec_regmap_config = …;
struct sun4i_codec_quirks { … };
static const struct sun4i_codec_quirks sun4i_codec_quirks = …;
static const struct sun4i_codec_quirks sun6i_a31_codec_quirks = …;
static const struct sun4i_codec_quirks sun7i_codec_quirks = …;
static const struct sun4i_codec_quirks sun8i_a23_codec_quirks = …;
static const struct sun4i_codec_quirks sun8i_h3_codec_quirks = …;
static const struct sun4i_codec_quirks sun8i_v3s_codec_quirks = …;
static const struct of_device_id sun4i_codec_of_match[] = …;
MODULE_DEVICE_TABLE(of, sun4i_codec_of_match);
static int sun4i_codec_probe(struct platform_device *pdev)
{ … }
static void sun4i_codec_remove(struct platform_device *pdev)
{ … }
static struct platform_driver sun4i_codec_driver = …;
module_platform_driver(…) …;
MODULE_DESCRIPTION(…) …;
MODULE_AUTHOR(…) …;
MODULE_AUTHOR(…) …;
MODULE_AUTHOR(…) …;
MODULE_AUTHOR(…) …;
MODULE_LICENSE(…) …;