如何在一个声卡添加pa codec设备
android\kernel\msm-3.18\arch\arm\boot\dts\qcom\msm8909-pm8916-mtp.dtsi
&audio_codec_mtp {
qcom,model = "msm8909-pm8916-snd-card";
qcom,msm-gpios =
"pri_i2s",
"quat_i2s",
"amp_gpios";
qcom,pinctrl-names =
"all_off",
"pri_i2s_act",
"quat_i2s_act",
"pri_i2s_quat_i2s_act",
"amp_gpios_act",
"pri_i2s_amp_gpios_act",
"quat_i2s_amp_gpios_act",
"pri_i2s_quat_i2s_amp_act";
pinctrl-names =
"all_off",
"pri_i2s_act",
"quat_i2s_act",
"pri_i2s_quat_i2s_act",
"amp_gpios_act",
"pri_i2s_amp_gpios_act",
"quat_i2s_amp_gpios_act",
"pri_i2s_quat_i2s_amp_act";
pinctrl-0 = <&cdc_pdm_lines_sus &quat_mi2s_sleep &quat_mi2s_din_sleep &_gpios_sus>;
pinctrl-1 = <&cdc_pdm_lines_act &quat_mi2s_sleep &quat_mi2s_din_sleep &_gpios_sus>;
pinctrl-2 = <&cdc_pdm_lines_sus &quat_mi2s_active &quat_mi2s_din_active &_gpios_sus>;
pinctrl-3 = <&cdc_pdm_lines_sus &quat_mi2s_active &quat_mi2s_din_active &_gpios_act>;
pinctrl-4 = <&cdc_pdm_lines_sus &quat_mi2s_sleep &quat_mi2s_din_sleep &_gpios_act>;
pinctrl-5 = <&cdc_pdm_lines_act &quat_mi2s_sleep &quat_mi2s_din_sleep &_gpios_act>;
pinctrl-6 = <&cdc_pdm_lines_sus &quat_mi2s_active &quat_mi2s_din_active &_gpios_act>;
pinctrl-7 = <&cdc_pdm_lines_act &quat_mi2s_active &quat_mi2s_din_active &_gpios_act>;
asoc-codec = <&stub_codec>, <&pm8916_tombak_dig>,<&tas5751>,<&tas5782>; //添加tas5782,tas5782是一个DAC的codec设备,pm8916_tombak_dig是耳机孔,它是一个ADC codec设备,两个都是codec
asoc-codec-names = "msm-stub-codec.1", "cajon_codec","tas5751.4-002b","tas5782.4-0048"; //从下面命令中获取
};
//tas5782设备定义
tas5782: [email protected] {
compatible = "ti,tas5782";
reg = <0x48>;
amp-rst-gpio = <&msm_gpio 25 0>;/*rest*/
amp-pwr9v-gpio = <&msm_gpio 35 0>;/*9v en*/
amp-pwr3v3-gpio = <&msm_gpio 34 0>;/*3v3 en*/
amp-pdn-gpio = <&msm_gpio 72 0>;/*power down (mute)*/
};
查看/sys/kernel/debug/asoc $ cat codecs
msm8x16_wcd_codec-13
tas5782.4-0048 //上面节点中的asoc-codec-names的来源
soc:qcom,msm-stub-codec
snd-soc-dummy
//从下面命令中获取codec_dai_name
msm8909:/sys/kernel/debug/asoc $ cat dais
cajon_vifeedback
msm8x16_wcd_i2s_tx1
msm8x16_wcd_i2s_rx1
tas5782-i2s
android\kernel\msm-3.18\sound\soc\msm\msm8952.c
添加dailink用于cpu dai找到codec dai,用名字匹配设备资源dts
static struct snd_soc_dai_link msm8952_dai[] = {
******
{
.name = LPASS_BE_QUAT_MI2S_RX,
.stream_name = "Quaternary MI2S Playback",
.cpu_dai_name = "msm-dai-q6-mi2s.3",
.platform_name = "msm-pcm-routing",
.codec_dai_name = "snd-soc-dummy-dai",
.codec_name = "snd-soc-dummy",
.no_pcm = 1,
.dpcm_playback = 1,
.be_id = MSM_BACKEND_DAI_QUATERNARY_MI2S_RX,
.be_hw_params_fixup = msm_mi2s_rx_be_hw_params_fixup,
.ops = &msm8952_quat_mi2s_be_ops,
.ignore_pmdown_time = 1, /* dai link has playback support */
.ignore_suspend = 1,
},
原来codec dai codec_dai_name 名字是snd-soc-dummy-dai snd-soc-dummy代表没有设备,在此位置上添加pa的codec名字
如下:
{
.name = LPASS_BE_QUAT_MI2S_RX,
.stream_name = "Quaternary MI2S Playback",
.cpu_dai_name = "msm-dai-q6-mi2s.3",
.platform_name = "msm-pcm-routing",
.codec_dai_name = "tas5782-i2s",
.codec_name = "tas5782.4-0048",
.no_pcm = 1,
.dpcm_playback = 1,
.be_id = MSM_BACKEND_DAI_QUATERNARY_MI2S_RX,
.be_hw_params_fixup = quat_msm_mi2s_rx_be_hw_params_fixup,
.ops = &msm8952_quat_mi2s_be_ops,
.ignore_pmdown_time = 1, /* dai link has playback support */
.ignore_suspend = 1,
},
codec dai name 是从下面文件中得到
android\kernel\msm-3.18\sound\soc\codecs\tas5782.c
ret = snd_soc_register_codec(&client->dev, &priv->codec_driver, &tas5782_dai, 1);
//tas5782_dai
static struct snd_soc_dai_driver tas5782_dai = {
.name = “tas5782-i2s”,
.id = 0,
.playback = {
.stream_name = “Playback”,
.channels_min = 1,
.channels_max = 2,
.rates = SNDRV_PCM_RATE_8000_48000|SNDRV_PCM_RATE_96000,
.formats = SNDRV_PCM_FMTBIT_S32_LE |
SNDRV_PCM_FMTBIT_S24_LE |
SNDRV_PCM_FMTBIT_S16_LE,
},
.ops = &tas5782_dai_ops,
};
codec name 从dts中得到tas5782
tas5782: [email protected] {
compatible = “ti,tas5782”;
reg = <0x48>;
amp-rst-gpio = <&msm_gpio 25 0>;/rest/
amp-pwr9v-gpio = <&msm_gpio 35 0>;/9v en/
amp-pwr3v3-gpio = <&msm_gpio 34 0>;/3v3 en/
amp-pdn-gpio = <&msm_gpio 72 0>;/power down (mute)/
};
此外注意修改其他部件的i2s格式支持范围
alsa打开pcm设备时,执行顺序
soc_pcm_open****函数调用
/操作cpu dai的startup接口
cpu_dai->driver->ops->startup---->
msm-dai-q6-v2.c->msm_dai_q6_mi2s_startup
cpu_dai_name所在文件在msm-dai-fe.c(multimedia 无主机HOSTLESS相关的dai) msm-dai-q6-v2.c(具体i2s的soc dai)中的struct snd_soc_dai_driver注册
由于pa是96k的因此需要在cpu dai(soc dai) msm-dai-q6-v2.c中添加96K的支持
格式有些需要修改成支持96k
操作platform的open接口
platform->driver->ops->open
NULL
操作codec dai的startup接口
codec_dai->driver->ops->startup
tas5782.c
tas5782_startup
操作 dai link的startup接口
rtd->dai_link->ops->startup
sound/soc/msm/msm8952.c
msm_quat_mi2s_snd_startup
pcm部分也需要做相应的snd_pcm_hardware的playback /capture属性修改
msm-pcm-afe-v2.c中
playback :
capture:
支持的采样率
msm-pcm-q6-v2.c中平台驱动的snd_pcm_hardware属性: