linux 声卡 添加GPIO PA开关,如何在一个声卡添加pa codec设备

如何在一个声卡添加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 = ;

pinctrl-1 = ;

pinctrl-2 = ;

pinctrl-3 = ;

pinctrl-4 = ;

pinctrl-5 = ;

pinctrl-6 = ;

pinctrl-7 = ;

asoc-codec = , ,,; //添加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: tas5782@48 {

compatible = "ti,tas5782";

reg = <0x48>;

amp-rst-gpio = ;/*rest*/

amp-pwr9v-gpio = ;/*9v en*/

amp-pwr3v3-gpio = ;/*3v3 en*/

amp-pdn-gpio = ;/*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: tas5782@48 {

compatible = “ti,tas5782”;

reg = <0x48>;

amp-rst-gpio = ;/rest/

amp-pwr9v-gpio = ;/9v en/

amp-pwr3v3-gpio = ;/3v3 en/

amp-pdn-gpio = ;/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

6fe840e0f6c1ac8d81880df5401dfef8.png

操作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 :371e4d515eae651e1ea9bd5e2127c5ee.png

capture:

3552acc4b2ee4e3044a50998c43d7aa2.png

支持的采样率

c3ba0c60a173a16b3188b04c1ae8a7c3.png

msm-pcm-q6-v2.c中平台驱动的snd_pcm_hardware属性:

3bee4a469b3346d33a1db531c126e59c.png

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值