600 lines
15 KiB
C
Executable File
600 lines
15 KiB
C
Executable File
/*
|
|
* sound\soc\sunxi\sunxi_snddaudio0.c
|
|
* (C) Copyright 2014-2016
|
|
* Reuuimlla Technology Co., Ltd. <www.reuuimllatech.com>
|
|
* huangxin <huangxin@Reuuimllatech.com>
|
|
*
|
|
* some simple description for this code
|
|
*
|
|
* This program is free software; you can redistribute it and/or
|
|
* modify it under the terms of the GNU General Public License as
|
|
* published by the Free Software Foundation; either version 2 of
|
|
* the License, or (at your option) any later version.
|
|
*
|
|
*/#include <linux/module.h>
|
|
#include <linux/clk.h>
|
|
#include <linux/mutex.h>
|
|
#include <sound/pcm.h>
|
|
#include <sound/soc.h>
|
|
#include <sound/pcm_params.h>
|
|
#include <sound/soc-dapm.h>
|
|
#include <linux/io.h>
|
|
#include <linux/of.h>
|
|
#include "../../codecs/ac100.h"
|
|
|
|
static int daudio_pcm_select;
|
|
static int daudio_master;
|
|
static int audio_format;
|
|
static int signal_inversion;
|
|
static int analog_bb;
|
|
static int digital_bb;
|
|
|
|
struct val_str {
|
|
int *val;
|
|
char *str;
|
|
};
|
|
|
|
static struct val_str properties[] = {
|
|
{&daudio_pcm_select, "daudio_select"},
|
|
{&daudio_master, "daudio_master"},
|
|
{&audio_format, "audio_format"},
|
|
{&signal_inversion, "signal_inversion"},
|
|
{&analog_bb, "analog_bb"},
|
|
{&digital_bb, "digital_bb"}
|
|
};
|
|
|
|
static int sunxi_snddaudio0_hw_params(struct snd_pcm_substream *substream,
|
|
struct snd_pcm_hw_params *params)
|
|
{
|
|
struct snd_soc_pcm_runtime *rtd = substream->private_data;
|
|
struct snd_soc_dai *codec_dai = rtd->codec_dai;
|
|
struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
|
|
unsigned int freq, clk_div;
|
|
int ret;
|
|
|
|
switch (params_rate(params)) {
|
|
case 8000:
|
|
case 16000:
|
|
case 32000:
|
|
case 64000:
|
|
case 128000:
|
|
case 12000:
|
|
case 24000:
|
|
case 48000:
|
|
case 96000:
|
|
case 192000:
|
|
freq = 24576000;
|
|
break;
|
|
case 11025:
|
|
case 22050:
|
|
case 44100:
|
|
case 88200:
|
|
case 176400:
|
|
freq = 22579200;
|
|
break;
|
|
default:
|
|
pr_err("unsupport params rate\n");
|
|
return -EINVAL;
|
|
}
|
|
|
|
/* set the codec FLL */
|
|
#if defined (CONFIG_SND_SOC_AD82584F)
|
|
ret = snd_soc_dai_set_pll(codec_dai, AC100_BCLK1, 0, 3072000, freq);
|
|
#else
|
|
ret = snd_soc_dai_set_pll(codec_dai, AC100_BCLK1, 0, 1024000, freq);
|
|
#endif
|
|
if (ret < 0) {
|
|
pr_warn("[daudio0],the codec_dai set_pll failed.\n");
|
|
return ret;
|
|
}
|
|
/*set cpu_dai clk*/
|
|
ret = snd_soc_dai_set_sysclk(cpu_dai, 0, freq, daudio_pcm_select);
|
|
if (ret < 0) {
|
|
pr_warn("[daudio0],the cpu_dai set_sysclk failed.\n");
|
|
return ret;
|
|
}
|
|
/*set codec_dai clk*/
|
|
ret = snd_soc_dai_set_sysclk(codec_dai, AIF1_CLK,
|
|
freq, daudio_pcm_select);
|
|
if (ret < 0) {
|
|
pr_warn("[daudio0],the codec_dai set_sysclk failed.\n");
|
|
return ret;
|
|
}
|
|
/*
|
|
* ac100: master. AP: slave
|
|
*/
|
|
ret = snd_soc_dai_set_fmt(codec_dai,
|
|
SND_SOC_DAIFMT_I2S |
|
|
SND_SOC_DAIFMT_NB_NF |
|
|
SND_SOC_DAIFMT_CBS_CFS);
|
|
if (ret < 0) {
|
|
pr_warn("[daudio0],the codec_dai set_fmt failed.\n");
|
|
return ret;
|
|
}
|
|
|
|
ret = snd_soc_dai_set_fmt(cpu_dai,
|
|
(audio_format |
|
|
(signal_inversion<<8) | SND_SOC_DAIFMT_CBS_CFS));
|
|
if (ret < 0) {
|
|
pr_warn("[daudio0],the cpu_dai set_format failed.\n");
|
|
return ret;
|
|
}
|
|
|
|
clk_div = freq / params_rate(params);
|
|
ret = snd_soc_dai_set_clkdiv(cpu_dai, 0, clk_div);
|
|
if (ret < 0) {
|
|
pr_warn("[daudio0],the cpu_dai set_clkdiv failed.\n");
|
|
return ret;
|
|
}
|
|
ret = snd_soc_dai_set_clkdiv(codec_dai, 0, clk_div);
|
|
if (ret < 0) {
|
|
pr_warn("[daudio0],the codec_dai set set_clkdiv failed.\n");
|
|
return ret;
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
|
|
static int bt_net_hw_params(struct snd_pcm_substream *substream,
|
|
struct snd_pcm_hw_params *params)
|
|
{
|
|
struct snd_soc_pcm_runtime *rtd = substream->private_data;
|
|
struct snd_soc_dai *codec_dai = rtd->codec_dai;
|
|
int ret = 0;
|
|
int freq_in = 24576000;
|
|
|
|
if (params_rate(params) != 8000)
|
|
return -EINVAL;
|
|
|
|
/* set the codec FLL */
|
|
ret = snd_soc_dai_set_pll(codec_dai, AC100_MCLK1, 0, freq_in, freq_in);
|
|
if (ret < 0)
|
|
return ret;
|
|
/*set codec system clock source aif2*/
|
|
ret = snd_soc_dai_set_sysclk(codec_dai, AIF2_CLK, 0, 0);
|
|
if (ret < 0)
|
|
return ret;
|
|
/* set codec DAI configuration */
|
|
ret = snd_soc_dai_set_fmt(codec_dai,
|
|
SND_SOC_DAIFMT_DSP_A |
|
|
SND_SOC_DAIFMT_IB_NF |
|
|
SND_SOC_DAIFMT_CBM_CFM);
|
|
if (ret < 0)
|
|
return ret;
|
|
|
|
return 0;
|
|
}
|
|
|
|
static int bb_voice_hw_params(struct snd_pcm_substream *substream,
|
|
struct snd_pcm_hw_params *params)
|
|
{
|
|
struct snd_soc_pcm_runtime *rtd = substream->private_data;
|
|
struct snd_soc_dai *codec_dai = rtd->codec_dai;
|
|
int ret = 0;
|
|
int freq_in = 24576000;
|
|
|
|
if (analog_bb) {
|
|
/* set the codec FLL */
|
|
ret = snd_soc_dai_set_pll(codec_dai, AC100_MCLK1,
|
|
0, freq_in, freq_in);
|
|
if (ret < 0)
|
|
return ret;
|
|
/*set codec system clock source aif2*/
|
|
ret = snd_soc_dai_set_sysclk(codec_dai, AIF2_CLK, 0, 0);
|
|
if (ret < 0)
|
|
return ret;
|
|
/* set codec DAI configuration */
|
|
ret = snd_soc_dai_set_fmt(codec_dai,
|
|
SND_SOC_DAIFMT_DSP_A |
|
|
SND_SOC_DAIFMT_IB_NF |
|
|
SND_SOC_DAIFMT_CBM_CFM);
|
|
if (ret < 0)
|
|
return ret;
|
|
} else if (digital_bb) {
|
|
/* set the codec FLL */
|
|
ret = snd_soc_dai_set_pll(codec_dai, AC100_BCLK2,
|
|
0, 2048000, freq_in);
|
|
if (ret < 0)
|
|
return ret;
|
|
/*set system clock source aif2*/
|
|
ret = snd_soc_dai_set_sysclk(codec_dai, AIF2_CLK, 0, 0);
|
|
if (ret < 0)
|
|
return ret;
|
|
/* set codec DAI configuration */
|
|
ret = snd_soc_dai_set_fmt(codec_dai,
|
|
SND_SOC_DAIFMT_DSP_A |
|
|
SND_SOC_DAIFMT_IB_NF |
|
|
SND_SOC_DAIFMT_CBS_CFS);
|
|
if (ret < 0)
|
|
return ret;
|
|
} else {
|
|
/* set codec DAI configuration */
|
|
ret = snd_soc_dai_set_fmt(codec_dai,
|
|
SND_SOC_DAIFMT_I2S |
|
|
SND_SOC_DAIFMT_NB_NF |
|
|
SND_SOC_DAIFMT_CBM_CFM);
|
|
if (ret < 0)
|
|
return ret;
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
|
|
static int phone_system_voice_hw_params(struct snd_pcm_substream *substream,
|
|
struct snd_pcm_hw_params *params)
|
|
{
|
|
struct snd_soc_pcm_runtime *rtd = substream->private_data;
|
|
struct snd_soc_dai *codec_dai = rtd->codec_dai;
|
|
struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
|
|
int ret = 0;
|
|
u32 freq_in = 22579200;
|
|
unsigned long sample_rate = params_rate(params);
|
|
|
|
switch (sample_rate) {
|
|
case 8000:
|
|
case 16000:
|
|
case 32000:
|
|
case 64000:
|
|
case 128000:
|
|
case 12000:
|
|
case 24000:
|
|
case 48000:
|
|
case 96000:
|
|
case 192000:
|
|
freq_in = 24576000;
|
|
break;
|
|
}
|
|
if (analog_bb) {
|
|
/* set the codec FLL */
|
|
ret = snd_soc_dai_set_pll(codec_dai, AC100_MCLK1,
|
|
0, freq_in, freq_in);
|
|
if (ret < 0)
|
|
return ret;
|
|
/*set cpu clk*/
|
|
ret = snd_soc_dai_set_sysclk(cpu_dai, 0,
|
|
freq_in, daudio_pcm_select);
|
|
if (ret < 0)
|
|
return ret;
|
|
/*set codec clk*/
|
|
ret = snd_soc_dai_set_sysclk(codec_dai, AIF1_CLK,
|
|
freq_in, daudio_pcm_select);
|
|
if (ret < 0)
|
|
return ret;
|
|
/*ac100: master. AP: slave*/
|
|
ret = snd_soc_dai_set_fmt(codec_dai,
|
|
SND_SOC_DAIFMT_I2S |
|
|
SND_SOC_DAIFMT_NB_NF |
|
|
SND_SOC_DAIFMT_CBS_CFS);
|
|
if (ret < 0)
|
|
return ret;
|
|
ret = snd_soc_dai_set_fmt(cpu_dai,
|
|
(audio_format | (signal_inversion<<8) |
|
|
SND_SOC_DAIFMT_CBS_CFS));
|
|
if (ret < 0)
|
|
return ret;
|
|
ret = snd_soc_dai_set_clkdiv(cpu_dai, 0, sample_rate);
|
|
if (ret < 0)
|
|
return ret;
|
|
} else if (digital_bb) {
|
|
/*set cpu clk*/
|
|
ret = snd_soc_dai_set_sysclk(cpu_dai, 0,
|
|
freq_in, daudio_pcm_select);
|
|
if (ret < 0)
|
|
return ret;
|
|
/* ac100: master. AP: slave*/
|
|
ret = snd_soc_dai_set_fmt(codec_dai,
|
|
SND_SOC_DAIFMT_I2S |
|
|
SND_SOC_DAIFMT_NB_NF |
|
|
SND_SOC_DAIFMT_CBS_CFS);
|
|
if (ret < 0)
|
|
return ret;
|
|
ret = snd_soc_dai_set_fmt(cpu_dai,
|
|
(audio_format | (signal_inversion<<8) |
|
|
SND_SOC_DAIFMT_CBS_CFS));
|
|
if (ret < 0)
|
|
return ret;
|
|
ret = snd_soc_dai_set_clkdiv(cpu_dai, 0, sample_rate);
|
|
if (ret < 0)
|
|
return ret;
|
|
} else {
|
|
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
static int bt_hw_params(struct snd_pcm_substream *substream,
|
|
struct snd_pcm_hw_params *params)
|
|
{
|
|
struct snd_soc_pcm_runtime *rtd = substream->private_data;
|
|
struct snd_soc_dai *codec_dai = rtd->codec_dai;
|
|
int ret = 0;
|
|
|
|
if (params_rate(params) != 8000)
|
|
return -EINVAL;
|
|
/* set codec aif3 configuration */
|
|
ret = snd_soc_dai_set_fmt(codec_dai, SND_SOC_DAIFMT_IB_NF);
|
|
if (ret < 0)
|
|
return ret;
|
|
return 0;
|
|
}
|
|
|
|
|
|
/*
|
|
* Card initialization
|
|
*/
|
|
static int sunxi_daudio_init(struct snd_soc_pcm_runtime *rtd)
|
|
{
|
|
struct snd_soc_codec *codec = rtd->codec;
|
|
struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec);
|
|
|
|
pr_debug("%s,line:%d\n", __func__, __LINE__);
|
|
snd_soc_dapm_disable_pin(dapm, "HPOUTR");
|
|
snd_soc_dapm_disable_pin(dapm, "HPOUTL");
|
|
snd_soc_dapm_disable_pin(dapm, "EAROUTP");
|
|
snd_soc_dapm_disable_pin(dapm, "EAROUTN");
|
|
snd_soc_dapm_disable_pin(dapm, "SPK1P");
|
|
snd_soc_dapm_disable_pin(dapm, "SPK2P");
|
|
snd_soc_dapm_disable_pin(dapm, "SPK1N");
|
|
snd_soc_dapm_disable_pin(dapm, "SPK2N");
|
|
snd_soc_dapm_disable_pin(dapm, "LINEOUTP");
|
|
snd_soc_dapm_disable_pin(dapm, "LINEOUTN");
|
|
snd_soc_dapm_disable_pin(dapm, "MIC1P");
|
|
snd_soc_dapm_disable_pin(dapm, "MIC1N");
|
|
snd_soc_dapm_disable_pin(dapm, "MIC2");
|
|
snd_soc_dapm_disable_pin(dapm, "MIC3");
|
|
snd_soc_dapm_disable_pin(dapm, "D_MIC");
|
|
|
|
snd_soc_dapm_disable_pin(&rtd->card->dapm, "External Speaker");
|
|
snd_soc_dapm_disable_pin(&rtd->card->dapm, "Headphone");
|
|
snd_soc_dapm_disable_pin(&rtd->card->dapm, "Earpiece");
|
|
snd_soc_dapm_disable_pin(&rtd->card->dapm, "Lineout");
|
|
|
|
snd_soc_dapm_sync(dapm);
|
|
return 0;
|
|
}
|
|
|
|
static struct snd_soc_ops sunxi_snddaudio_ops = {
|
|
.hw_params = sunxi_snddaudio0_hw_params,
|
|
};
|
|
|
|
static struct snd_soc_ops bt_net_ops = {
|
|
.hw_params = bt_net_hw_params,
|
|
};
|
|
|
|
static struct snd_soc_ops bb_voice_ops = {
|
|
.hw_params = bb_voice_hw_params,
|
|
};
|
|
|
|
static struct snd_soc_ops phone_system_voice_ops = {
|
|
.hw_params = phone_system_voice_hw_params,
|
|
};
|
|
|
|
static struct snd_soc_ops bt_voice_ops = {
|
|
.hw_params = bt_hw_params,
|
|
};
|
|
|
|
|
|
static const struct snd_kcontrol_new ac100_pin_controls[] = {
|
|
SOC_DAPM_PIN_SWITCH("External Speaker"),
|
|
SOC_DAPM_PIN_SWITCH("Headphone"),
|
|
SOC_DAPM_PIN_SWITCH("Earpiece"),
|
|
SOC_DAPM_PIN_SWITCH("Lineout"),
|
|
};
|
|
static const struct snd_soc_dapm_widget a80_ac100_dapm_widgets[] = {
|
|
SND_SOC_DAPM_MIC("External MainMic", NULL),
|
|
SND_SOC_DAPM_MIC("HeadphoneMic", NULL),
|
|
SND_SOC_DAPM_MIC("DigitalMic", NULL),
|
|
};
|
|
|
|
static const struct snd_soc_dapm_route audio_map[] = {
|
|
{"MainMic Bias", NULL, "External MainMic"},
|
|
{"MIC1P", NULL, "MainMic Bias"},
|
|
{"MIC1N", NULL, "MainMic Bias"},
|
|
|
|
{"MIC2", NULL, "HMic Bias"},
|
|
{"MIC3", NULL, "MainMic Bias"},
|
|
{"HMic Bias", NULL, "HeadphoneMic"},
|
|
|
|
/*d-mic*/
|
|
{"MainMic Bias", NULL, "DigitalMic"},
|
|
{"D_MIC", NULL, "MainMic Bias"},
|
|
};
|
|
|
|
static struct snd_soc_dai_link sunxi_snddaudio_dai_link[] = {
|
|
{
|
|
.name = "s_i2s1",
|
|
.cpu_dai_name = "sunxi-tdm",
|
|
.stream_name = "SUNXI-CODEC",
|
|
.codec_dai_name = "ac100-aif1",
|
|
.codec_name = "ac100-codec",
|
|
.init = sunxi_daudio_init,
|
|
.ops = &sunxi_snddaudio_ops,
|
|
},
|
|
|
|
{/* Second DAI i/f */
|
|
.name = "ac100 Voice",
|
|
.stream_name = "Voice",
|
|
.cpu_dai_name = "bb-voice-dai",
|
|
.codec_dai_name = "ac100-aif2",
|
|
.codec_name = "ac100-codec",
|
|
.ops = &bb_voice_ops,
|
|
},
|
|
{/*phone cap and keytone*/
|
|
.name = "VIR",
|
|
.cpu_dai_name = "sec_dai",
|
|
.stream_name = "vir-dai",
|
|
.codec_dai_name = "ac100-aif1",
|
|
.codec_name = "ac100-codec",
|
|
.ops = &phone_system_voice_ops,
|
|
},
|
|
{
|
|
/*bt*/
|
|
.name = "BT",
|
|
.cpu_dai_name = "bb-voice-dai",
|
|
.stream_name = "bt-dai",
|
|
.codec_dai_name = "ac100-aif3",
|
|
.codec_name = "ac100-codec",
|
|
.ops = &bt_voice_ops,
|
|
},
|
|
{
|
|
/*bt-network*/
|
|
.name = "BT-NET",
|
|
.cpu_dai_name = "bb-voice-dai",
|
|
.stream_name = "aif2-bt-net",
|
|
.codec_dai_name = "ac100-aif2",
|
|
.codec_name = "ac100-codec",
|
|
.ops = &bt_net_ops,
|
|
#if defined (CONFIG_SND_SOC_AD82584F)
|
|
},
|
|
{
|
|
.name = "digital PA",
|
|
.cpu_dai_name = "sunxi-tdm",
|
|
.stream_name = "digital-codec",
|
|
.codec_dai_name = "ad82584f",
|
|
.codec_name = "ad82584f.1-0031",
|
|
#endif
|
|
}
|
|
};
|
|
|
|
static struct snd_soc_card snd_soc_sunxi_snddaudio = {
|
|
.name = "snddaudio0",
|
|
.owner = THIS_MODULE,
|
|
.dai_link = sunxi_snddaudio_dai_link,
|
|
.num_links = ARRAY_SIZE(sunxi_snddaudio_dai_link),
|
|
|
|
.dapm_widgets = a80_ac100_dapm_widgets,
|
|
.num_dapm_widgets = ARRAY_SIZE(a80_ac100_dapm_widgets),
|
|
.dapm_routes = audio_map,
|
|
.num_dapm_routes = ARRAY_SIZE(audio_map),
|
|
.controls = ac100_pin_controls,
|
|
.num_controls = ARRAY_SIZE(ac100_pin_controls),
|
|
};
|
|
|
|
static int sunxi_snddaudio0_dev_probe(struct platform_device *pdev)
|
|
{
|
|
int ret = 0;
|
|
struct device_node *np = pdev->dev.of_node;
|
|
struct snd_soc_card *card = &snd_soc_sunxi_snddaudio;
|
|
unsigned int val;
|
|
unsigned int i;
|
|
|
|
card->dev = &pdev->dev;
|
|
dev_warn(&pdev->dev, "%s,line:%d\n", __func__, __LINE__);
|
|
|
|
for (i = 0; i < ARRAY_SIZE(properties); i++) {
|
|
ret = of_property_read_u32(np, properties[i].str, &val);
|
|
if (ret < 0) {
|
|
dev_warn(&pdev->dev, "%s config missing or invalid\n",
|
|
properties[i].str);
|
|
*(properties[i].val) = 0;
|
|
} else {
|
|
*(properties[i].val) = val;
|
|
pr_debug("%s=%d\n", properties[i].str,
|
|
*(properties[i].val));
|
|
}
|
|
}
|
|
|
|
dev_warn(&pdev->dev, "%s,line:%d\n", __func__, __LINE__);
|
|
sunxi_snddaudio_dai_link[0].cpu_dai_name = NULL;
|
|
sunxi_snddaudio_dai_link[0].cpu_of_node = of_parse_phandle(np,
|
|
"sunxi,daudio0-controller", 0);
|
|
if (!sunxi_snddaudio_dai_link[0].cpu_of_node) {
|
|
dev_err(&pdev->dev,
|
|
"Property 'sunxi,daudio0-controller' missing\n");
|
|
ret = -EINVAL;
|
|
}
|
|
sunxi_snddaudio_dai_link[0].platform_name = NULL;
|
|
sunxi_snddaudio_dai_link[0].platform_of_node =
|
|
sunxi_snddaudio_dai_link[0].cpu_of_node;
|
|
#if defined(CONFIG_SND_SOC_AD82584F)
|
|
sunxi_snddaudio_dai_link[5].cpu_dai_name = NULL;
|
|
sunxi_snddaudio_dai_link[5].cpu_of_node = of_parse_phandle(np,
|
|
"sunxi,daudio0-controller", 0);
|
|
if (!sunxi_snddaudio_dai_link[5].cpu_of_node) {
|
|
dev_err(&pdev->dev,
|
|
"Property 'sunxi,daudio0-controller' missing\n");
|
|
ret = -EINVAL;
|
|
}
|
|
sunxi_snddaudio_dai_link[5].platform_name = NULL;
|
|
sunxi_snddaudio_dai_link[5].platform_of_node =
|
|
sunxi_snddaudio_dai_link[5].cpu_of_node;
|
|
#endif
|
|
#if 1
|
|
sunxi_snddaudio_dai_link[1].cpu_dai_name = NULL;
|
|
sunxi_snddaudio_dai_link[1].cpu_of_node = of_parse_phandle(np,
|
|
"sunxi,bbdai-controller", 0);
|
|
if (!sunxi_snddaudio_dai_link[1].cpu_of_node) {
|
|
dev_err(&pdev->dev,
|
|
"Property 'sunxi,bbdai-controller' missing\n");
|
|
// ret = -EINVAL;
|
|
}
|
|
sunxi_snddaudio_dai_link[2].cpu_dai_name = NULL;
|
|
sunxi_snddaudio_dai_link[2].cpu_of_node =
|
|
sunxi_snddaudio_dai_link[1].cpu_of_node;
|
|
sunxi_snddaudio_dai_link[3].cpu_dai_name = NULL;
|
|
sunxi_snddaudio_dai_link[3].cpu_of_node =
|
|
sunxi_snddaudio_dai_link[1].cpu_of_node;
|
|
sunxi_snddaudio_dai_link[4].cpu_dai_name = NULL;
|
|
sunxi_snddaudio_dai_link[4].cpu_of_node =
|
|
sunxi_snddaudio_dai_link[1].cpu_of_node;
|
|
#endif
|
|
/* codec_of_node */
|
|
/*
|
|
sunxi_snddaudio_dai_link[0].codec_name = NULL;
|
|
sunxi_snddaudio_dai_link[0].codec_of_node =
|
|
of_find_compatible_node(NULL, NULL,
|
|
"allwinner,sunxi-ac100-codec");
|
|
if (!sunxi_snddaudio_dai_link[0].codec_of_node) {
|
|
dev_err(&pdev->dev, "codec_of_node missing or invalid\n");
|
|
ret = -EINVAL;
|
|
}
|
|
*/
|
|
#if 0
|
|
for (i = 1; i < ARRAY_SIZE(sunxi_snddaudio_dai_link); i++) {
|
|
sunxi_snddaudio_dai_link[i].codec_name = NULL;
|
|
sunxi_snddaudio_dai_link[i].codec_of_node =
|
|
sunxi_snddaudio_dai_link[0].codec_of_node;
|
|
}
|
|
#endif
|
|
dev_warn(&pdev->dev, "%s,line:%d\n", __func__, __LINE__);
|
|
ret = snd_soc_register_card(card);
|
|
if (ret) {
|
|
dev_err(&pdev->dev,
|
|
"snd_soc_register_card() failed: %d\n", ret);
|
|
}
|
|
dev_warn(&pdev->dev, "%s,line:%d\n", __func__, __LINE__);
|
|
|
|
return ret;
|
|
}
|
|
|
|
static int __exit sunxi_snddaudio0_dev_remove(struct platform_device *pdev)
|
|
{
|
|
struct snd_soc_card *card = platform_get_drvdata(pdev);
|
|
|
|
snd_soc_unregister_card(card);
|
|
return 0;
|
|
}
|
|
|
|
static const struct of_device_id sunxi_daudio0_of_match[] = {
|
|
{ .compatible = "allwinner,sunxi-daudio0-machine", },
|
|
{},
|
|
};
|
|
|
|
/*method relating*/
|
|
static struct platform_driver sunxi_daudio_driver = {
|
|
.driver = {
|
|
.name = "snddaudio0",
|
|
.owner = THIS_MODULE,
|
|
.pm = &snd_soc_pm_ops,
|
|
.of_match_table = sunxi_daudio0_of_match,
|
|
},
|
|
.probe = sunxi_snddaudio0_dev_probe,
|
|
.remove = __exit_p(sunxi_snddaudio0_dev_remove),
|
|
};
|
|
|
|
module_platform_driver(sunxi_daudio_driver);
|
|
|
|
MODULE_AUTHOR("huangxin");
|
|
MODULE_DESCRIPTION("SUNXI_snddaudio ALSA SoC audio driver");
|
|
MODULE_LICENSE("GPL");
|