tinymix调试音频i2s
2018年07月19日 20:30:31 康师傅的技术小站 阅读数:756
版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/u010481276/article/details/81122226
http://www.360doc.com/content/18/0314/12/32862269_736896674.shtml ./hardware/qcom/audio/configs/msm8909/mixer_paths_msm8909_pm8916.xml中查看 ,这个配置文件是根据平台声卡名得来的
hardware/qcom/audio/hal/msm8916/platform.c
msm8909:/dev/snd # cat /proc/asound/cards
0 [msm8909pm8916sn]: msm8909-pm8916- - msm8909-pm8916-snd-card
msm8909-pm8916-snd-card
} else if (!strncmp(snd_card_name, "msm8909-pm8916-snd-card",
sizeof("msm8909-pm8916-snd-card"))) {
strlcpy(mixer_xml_path, MIXER_XML_PATH_MSM8909_PM8916,
sizeof(MIXER_XML_PATH_MSM8909_PM8916));
msm_device_to_be_id = msm_device_to_be_id_internal_codec;
msm_be_id_array_len =
sizeof(msm_device_to_be_id_internal_codec) / sizeof(msm_device_to_be_id_internal_codec[0]);
}
msm8909:/dev/snd # cat /proc/asound/cards
0 [msm8909pm8916sn]: msm8909-pm8916- - msm8909-pm8916-snd-card
msm8909-pm8916-snd-card
xml包含codec切换path的配置,如下面配有切换至speaker所需要的参数设置(通过tinymix进行配置)
驱动代码放在如下位置, 里面包含audio path切换的"audio_map"表格,
 本平台为msm8909
注意,mixer_paths_msm8909_pm8916.xml中如下,只需要一个空格,否则无效
 //headset
<path name="handset">
<ctl name="RX1 MIX1 INP1" value="RX1" />
<ctl name="RDAC2 MUX" value="RX1" />
<ctl name="RX1 Digital Volume" value="84" />
<ctl name="EAR PA Gain" value="POS_6_DB" />
<ctl name="EAR_S" value="Switch" />
</path>
tinymix “PRI_MI2S_RX Audio Mixer MultiMedia1” “1” tinymix “RX1 MIX1 INP1” “RX1” tinymix “RDAC2 MUX” “RX1” tinymix “RX1 Digital Volume” “84” tinymix “EAR PA Gain” “POS_6_DB” tinymix “EAR_S” “Switch” tinyplay xxx.wav
tinymix ‘MI2S_RX Format’ ‘1’ 设置成24bit,i2s传输,设备也需要切到对应的i2s格式
//headphones
<path name="headphones">
<ctl name="MI2S_RX Channels" value="Two" />
<ctl name="RX1 MIX1 INP1" value="RX1" />
<ctl name="RX2 MIX1 INP1" value="RX2" />
<ctl name="RDAC2 MUX" value="RX2" />
<ctl name="HPHL" value="Switch" />
<ctl name="HPHR" value="Switch" />
</path>
tinymix “PRI_MI2S_RX Audio Mixer MultiMedia1” “1”
SND_SOC_DAPM_AIF_OUT("PRI_MI2S_RX", "Primary MI2S Playback",
0, 0, 0, 0),snd_soc_dapm_aif_out
实际为snd_soc_dapm_aif_out对应一个数字音频输出接口,比如I2S接口的输出端。如一组i2s的输出端
msm8909:/ # tinymix |grep "PRI_MI2S_RX Audio Mixer MultiMedia1"
1460 BOOL 1 PRI_MI2S_RX Audio Mixer MultiMedia1 Off
1468 BOOL 1 PRI_MI2S_RX Audio Mixer MultiMedia10 Off
1469 BOOL 1 PRI_MI2S_RX Audio Mixer MultiMedia11 Off
1470 BOOL 1 PRI_MI2S_RX Audio Mixer MultiMedia12 Off
1471 BOOL 1 PRI_MI2S_RX Audio Mixer MultiMedia13 Off
1472 BOOL 1 PRI_MI2S_RX Audio Mixer MultiMedia14 Off
1473 BOOL 1 PRI_MI2S_RX Audio Mixer MultiMedia15 Off
1474 BOOL 1 PRI_MI2S_RX Audio Mixer MultiMedia16 Off
tinymix “MI2S_RX Channels” “Two” tinymix “RX1 MIX1 INP1” “RX1” tinymix “RX2 MIX1 INP1” “RX2” tinymix “RDAC2 MUX” “RX2” tinymix “HPHL” “Switch” tinymix “HPHR” “Switch”
tinymix “RX2 Digital Volume” “84”
//mic adc1 如上面mic为adc1那路,那只找 adc1即可
<path name="adc1">
<ctl name="ADC1 Volume" value="6" />
<ctl name="DEC1 MUX" value="ADC1" />
</path>
tinymix “MultiMedia1 Mixer TERT_MI2S_TX” 1 tinymix “ADC1 Volume” 6 tinymix “DEC1 MUX” “ADC1” tinycap /data/mic1.wav
//speaker
<path name="speaker">
<ctl name="RX3 MIX1 INP1" value="RX1" />
<ctl name="SPK" value="Switch" />
</path>
tinymix ‘PRI_MI2S_RX Audio Mixer MultiMedia1’ 1 tinymix ‘RX3 MIX1 INP1’ ‘RX1’ tinymix “RX1 Digital Volume” “84” tinymix “RX1 Digital Volume” “60” tinymix “SPK” “Switch” tinyplay /data/01_1KHz_0dB.wav
以上的控制功能都是由kcontrol提供的如pm8916上的kcontrol
static const struct snd_kcontrol_new msm8x16_wcd_snd_controls[] = {
SOC_ENUM_EXT("RX HPH Mode", msm8x16_wcd_hph_mode_ctl_enum[0],
msm8x16_wcd_hph_mode_get, msm8x16_wcd_hph_mode_set),
SOC_ENUM_EXT("Boost Option", msm8x16_wcd_boost_option_ctl_enum[0],
msm8x16_wcd_boost_option_get, msm8x16_wcd_boost_option_set),
SOC_ENUM_EXT("EAR PA Boost", msm8x16_wcd_ear_pa_boost_ctl_enum[0],
msm8x16_wcd_ear_pa_boost_get, msm8x16_wcd_ear_pa_boost_set),
SOC_ENUM_EXT("EAR PA Gain", msm8x16_wcd_ear_pa_gain_enum[0],
msm8x16_wcd_pa_gain_get, msm8x16_wcd_pa_gain_put),
SOC_ENUM_EXT("Speaker Boost", msm8x16_wcd_spk_boost_ctl_enum[0],
msm8x16_wcd_spk_boost_get, msm8x16_wcd_spk_boost_set),
SOC_ENUM_EXT("Ext Spk Boost", msm8x16_wcd_ext_spk_boost_ctl_enum[0],
msm8x16_wcd_ext_spk_boost_get, msm8x16_wcd_ext_spk_boost_set),
SOC_ENUM_EXT("LOOPBACK Mode", msm8x16_wcd_loopback_mode_ctl_enum[0],
msm8x16_wcd_loopback_mode_get, msm8x16_wcd_loopback_mode_put),
SOC_SINGLE_TLV("ADC1 Volume", MSM8X16_WCD_A_ANALOG_TX_1_EN, 3,
8, 0, analog_gain),
SOC_SINGLE_TLV("ADC2 Volume", MSM8X16_WCD_A_ANALOG_TX_2_EN, 3,
8, 0, analog_gain),
SOC_SINGLE_TLV("ADC3 Volume", MSM8X16_WCD_A_ANALOG_TX_3_EN, 3,
8, 0, analog_gain),
SOC_ENUM_EXT("EAR PA Gain", msm8x16_wcd_ear_pa_gain_enum[0],
msm8x16_wcd_pa_gain_get, msm8x16_wcd_pa_gain_put),
如ear的增益 "EAR PA Gain"是暴露给tinymix的属性名字 msm8x16_wcd_ear_pa_gain_enum[0]是对应可供选择的值 “POS_1P5_DB”, “POS_6_DB” msm8x16_wcd_pa_gain_get, msm8x16_wcd_pa_gain_put是对应的操作函数
static const char * const msm8x16_wcd_ear_pa_gain_text[] = {
"POS_1P5_DB", "POS_6_DB"};
static const struct soc_enum msm8x16_wcd_ear_pa_gain_enum[] = {
SOC_ENUM_SINGLE_EXT(2, msm8x16_wcd_ear_pa_gain_text),
};
对应的操作接口set
static int msm8x16_wcd_pa_gain_put(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol)
{
u8 ear_pa_gain;
struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
dev_dbg(codec->dev, "%s: ucontrol->value.integer.value[0] = %ld\n",
__func__, ucontrol->value.integer.value[0]);
switch (ucontrol->value.integer.value[0]) {
case 0: //对应的枚举值
ear_pa_gain = 0x00;
break;
case 1:
ear_pa_gain = 0x20;
break;
default:
return -EINVAL;
}
snd_soc_update_bits(codec, MSM8X16_WCD_A_ANALOG_RX_EAR_CTL,
0x20, ear_pa_gain);
return 0;
}
ls -al /dev/snd/下面的文件 音频设备的命名规则为 [device type]C[card index]D[device index][capture/playback],即名字中含有4部分的信息: device type 设备类型,通常只有compr/hw/pcm这3种。从上图可以看到声卡会管理很多设备,PCM设备只是其中的一种设备。 card index 声卡的id,代表第几块声卡。通常都是0,代表第一块声卡。手机上通常都只有一块声卡。 device index 设备的id,代表这个设备是声卡上的第几个设备。设备的ID只和驱动中配置的DAI link的次序有关。如果驱动没有改变,那么这些ID就是固定的。
msm8909:/dev/snd # cat /sys/kernel/debug/asoc/dais
cajon_vifeedback
msm8x16_wcd_i2s_tx1
msm8x16_wcd_i2s_rx1
tas5751-i2s
MultiMedia29
MultiMedia28
MultiMedia21
MultiMedia20
MultiMedia19
MultiMedia18
MultiMedia17
VoiceMMode2
VoiceMMode1
MultiMedia16
MultiMedia15
MultiMedia14
MultiMedia13
MultiMedia12
MultiMedia11
MultiMedia10
VoWLAN
LSM8
LSM7
LSM6
LSM5
LSM4
LSM3
LSM2
LSM1
前面已经创建了control设备,现在soc_probe_link_dais调用soc_new_pcm创建pcm设备。 1)设置pcm native中要使用的pcm操作函数,这些函数用于操作音频物理设备,包括machine、codec_dai、cpu_dai、platform; 2)调用snd_pcm_new()创建pcm设备,回放子流实例和录制子流实例都在这里创建; 3)回调platform驱动的pcm_new(),完成音频dma设备初始化和dma buffer内存分配;
soc-core.c soc_probe platform_get_drvdata(pdev)//获取声卡 snd_soc_register_card snd_soc_instantiate_card soc_probe_link_dais soc-pcm.c soc_new_pcm
capture/playback 只有PCM设备才有这部分,只有c和p两种。c代表capture,说明这是一个提供录音的设备,p代表palyback,说明这是一个提供播放的设备。 系统会在/proc/asound/pcm文件中列出所有的音频设备的信息,如果是肉眼查看,/proc/asound/pcm中的信息会更直观一些
调用流程:
 tinyplay调用流程 从pcm的操作函数开始
const struct file_operations snd_pcm_f_ops[2] = {
{
.owner = THIS_MODULE,
.write = snd_pcm_write,
.aio_write = snd_pcm_aio_write,
.open = snd_pcm_playback_open,
.release = snd_pcm_release,
.llseek = no_llseek,
.poll = snd_pcm_playback_poll,
.unlocked_ioctl = snd_pcm_playback_ioctl,
.compat_ioctl = snd_pcm_ioctl_compat,
.mmap = snd_pcm_mmap,
.fasync = snd_pcm_fasync,
.get_unmapped_area = snd_pcm_get_unmapped_area,
},
{
.owner = THIS_MODULE,
.read = snd_pcm_read,
.aio_read = snd_pcm_aio_read,
.open = snd_pcm_capture_open,
.release = snd_pcm_release,
.llseek = no_llseek,
.poll = snd_pcm_capture_poll,
.unlocked_ioctl = snd_pcm_capture_ioctl,
.compat_ioctl = snd_pcm_ioctl_compat,
.mmap = snd_pcm_mmap,
.fasync = snd_pcm_fasync,
.get_unmapped_area = snd_pcm_get_unmapped_area,
}
};
snd_pcm_playback_open snd_pcm_open snd_pcm_open_file snd_pcm_open_substream-》substream->ops->open在
soc_new_pcm中注册回调的
/* ASoC PCM operations */
if (rtd->dai_link->dynamic) {
rtd->ops.open = dpcm_fe_dai_open;
rtd->ops.hw_params = dpcm_fe_dai_hw_params;
rtd->ops.prepare = dpcm_fe_dai_prepare;
rtd->ops.trigger = dpcm_fe_dai_trigger;
rtd->ops.hw_free = dpcm_fe_dai_hw_free;
rtd->ops.close = dpcm_fe_dai_close;
rtd->ops.pointer = soc_pcm_pointer;
rtd->ops.delay_blk = soc_pcm_delay_blk;
rtd->ops.ioctl = soc_pcm_ioctl;
rtd->ops.compat_ioctl = soc_pcm_compat_ioctl;
} else {
rtd->ops.open = soc_pcm_open;
rtd->ops.hw_params = soc_pcm_hw_params;
rtd->ops.prepare = soc_pcm_prepare;
rtd->ops.trigger = soc_pcm_trigger;
rtd->ops.hw_free = soc_pcm_hw_free;
rtd->ops.close = soc_pcm_close;
rtd->ops.pointer = soc_pcm_pointer;
rtd->ops.delay_blk = soc_pcm_delay_blk;
rtd->ops.ioctl = soc_pcm_ioctl;
rtd->ops.compat_ioctl = soc_pcm_compat_ioctl;
}
if (platform->driver->ops) {
rtd->ops.ack = platform->driver->ops->ack;
rtd->ops.copy = platform->driver->ops->copy;
rtd->ops.silence = platform->driver->ops->silence;
rtd->ops.page = platform->driver->ops->page;
rtd->ops.mmap = platform->driver->ops->mmap;
rtd->ops.restart = platform->driver->ops->restart;
}
soc_pcm_open
/*
* Called by ALSA when a PCM substream is opened, the runtime->hw record is
* then initialized and any private data can be allocated. This also calls
* startup for the cpu DAI, platform, machine and codec DAI.
*/
static int soc_pcm_open(struct snd_pcm_substream *substream)
{
struct snd_soc_pcm_runtime *rtd = substream->private_data;
struct snd_pcm_runtime *runtime = substream->runtime;
struct snd_soc_platform *platform = rtd->platform;
struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
struct snd_soc_dai *codec_dai;
const char *codec_dai_name = "multicodec";
int i, ret = 0;
pinctrl_pm_select_default_state(cpu_dai->dev);
for (i = 0; i < rtd->num_codecs; i++)
pinctrl_pm_select_default_state(rtd->codec_dais[i]->dev);
pm_runtime_get_sync(cpu_dai->dev);
for (i = 0; i < rtd->num_codecs; i++)
pm_runtime_get_sync(rtd->codec_dais[i]->dev);
pm_runtime_get_sync(platform->dev);
mutex_lock_nested(&rtd->pcm_mutex, rtd->pcm_subclass);
if (rtd->dai_link->no_host_mode == SND_SOC_DAI_LINK_NO_HOST)
snd_soc_set_runtime_hwparams(substream, &no_host_hardware);
/* startup the audio subsystem */操作cpu dai的startup接口
if (cpu_dai->driver->ops && cpu_dai->driver->ops->startup) {
ret = cpu_dai->driver->ops->startup(substream, cpu_dai);
if (ret < 0) {
dev_err(cpu_dai->dev, "ASoC: can't open interface"
" %s: %d\n", cpu_dai->name, ret);
goto out;
}
}
操作platform的open接口
if (platform->driver->ops && platform->driver->ops->open) {
ret = platform->driver->ops->open(substream);
if (ret < 0) {
dev_err(platform->dev, "ASoC: can't open platform"
" %s: %d\n", platform->component.name, ret);
goto platform_err;
}
}
操作codec dai的startup接口
for (i = 0; i < rtd->num_codecs; i++) {
codec_dai = rtd->codec_dais[i];
if (codec_dai->driver->ops && codec_dai->driver->ops->startup) {
ret = codec_dai->driver->ops->startup(substream,
codec_dai);
if (ret < 0) {
dev_err(codec_dai->dev,
"ASoC: can't open codec %s: %d\n",
codec_dai->name, ret);
goto codec_dai_err;
}
}
if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
codec_dai->tx_mask = 0;
else
codec_dai->rx_mask = 0;
}
操作 dai link的startup接口
if (rtd->dai_link->ops && rtd->dai_link->ops->startup) {
ret = rtd->dai_link->ops->startup(substream);
if (ret < 0) {
pr_err("ASoC: %s startup failed: %d\n",
rtd->dai_link->name, ret);
goto machine_err;
}
}
/* Dynamic PCM DAI links compat checks use dynamic capabilities */
if (rtd->dai_link->dynamic || rtd->dai_link->no_pcm)
goto dynamic;
/* Check that the codec and cpu DAIs are compatible */
soc_pcm_init_runtime_hw(substream);
if (rtd->num_codecs == 1)
codec_dai_name = rtd->codec_dai->name;
if (soc_pcm_has_symmetry(substream))
runtime->hw.info |= SNDRV_PCM_INFO_JOINT_DUPLEX;
ret = -EINVAL;
if (!runtime->hw.rates) {
printk(KERN_ERR "ASoC: %s <-> %s No matching rates\n",
codec_dai_name, cpu_dai->name);
goto config_err;
}
if (!runtime->hw.formats) {
printk(KERN_ERR "ASoC: %s <-> %s No matching formats\n",
codec_dai_name, cpu_dai->name);
goto config_err;
}
if (!runtime->hw.channels_min || !runtime->hw.channels_max ||
runtime->hw.channels_min > runtime->hw.channels_max) {
printk(KERN_ERR "ASoC: %s <-> %s No matching channels\n",
codec_dai_name, cpu_dai->name);
goto config_err;
}
soc_pcm_apply_msb(substream);
/* Symmetry only applies if we've already got an active stream. */
if (cpu_dai->active) {
ret = soc_pcm_apply_symmetry(substream, cpu_dai);
if (ret != 0)
goto config_err;
}
for (i = 0; i < rtd->num_codecs; i++) {
if (rtd->codec_dais[i]->active) {
ret = soc_pcm_apply_symmetry(substream,
rtd->codec_dais[i]);
if (ret != 0)
goto config_err;
}
}
pr_debug("ASoC: %s <-> %s info:\n",
codec_dai_name, cpu_dai->name);
pr_debug("ASoC: rate mask 0x%x\n", runtime->hw.rates);
pr_debug("ASoC: min ch %d max ch %d\n", runtime->hw.channels_min,
runtime->hw.channels_max);
pr_debug("ASoC: min rate %d max rate %d\n", runtime->hw.rate_min,
runtime->hw.rate_max);
dynamic:
snd_soc_runtime_activate(rtd, substream->stream);
mutex_unlock(&rtd->pcm_mutex);
return 0;
config_err://出错处理,shutdown dai link
if (rtd->dai_link->ops && rtd->dai_link->ops->shutdown)
rtd->dai_link->ops->shutdown(substream);
machine_err:
i = rtd->num_codecs;
codec_dai_err:
while (--i >= 0) {//出错处理,shutdown codec dai
codec_dai = rtd->codec_dais[i];
if (codec_dai->driver->ops->shutdown)
codec_dai->driver->ops->shutdown(substream, codec_dai);
}
//出错处理,close platform
if (platform->driver->ops && platform->driver->ops->close)
platform->driver->ops->close(substream);
platform_err://出错处理,shutdown cpu dai
if (cpu_dai->driver->ops && cpu_dai->driver->ops->shutdown)
cpu_dai->driver->ops->shutdown(substream, cpu_dai);
out:
mutex_unlock(&rtd->pcm_mutex);
pm_runtime_put(platform->dev);
for (i = 0; i < rtd->num_codecs; i++)
pm_runtime_put(rtd->codec_dais[i]->dev);
pm_runtime_put(cpu_dai->dev);
for (i = 0; i < rtd->num_codecs; i++) {
if (!rtd->codec_dais[i]->active)
pinctrl_pm_select_sleep_state(rtd->codec_dais[i]->dev);
}
if (!cpu_dai->active)
pinctrl_pm_select_sleep_state(cpu_dai->dev);
return ret;
}
.name = LPASS_BE_QUAT_MI2S_TX,
.stream_name = "Quaternary MI2S Capture",
.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_capture = 1,
.be_id = MSM_BACKEND_DAI_QUATERNARY_MI2S_TX,
.be_hw_params_fixup = msm_be_hw_params_fixup,
.ops = &msm8952_quat_mi2s_be_ops,
.ignore_suspend = 1,
cpu_dai_name = "msm-dai-q6-mi2s.3",
{
.playback = {
.stream_name = "Quaternary MI2S Playback",
.aif_name = "QUAT_MI2S_RX",
.rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_96000 |
SNDRV_PCM_RATE_192000,
.formats = SNDRV_PCM_FMTBIT_S16_LE,
.rate_min = 8000,
.rate_max = 192000,
},
.capture = {
.stream_name = "Quaternary MI2S Capture",
.aif_name = "QUAT_MI2S_TX",
.rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
SNDRV_PCM_RATE_16000,
.formats = SNDRV_PCM_FMTBIT_S16_LE,
.rate_min = 8000,
.rate_max = 48000,
},
.ops = &msm_dai_q6_mi2s_ops,
.id = MSM_QUAT_MI2S,
.probe = msm_dai_q6_dai_mi2s_probe,
.remove = msm_dai_q6_dai_mi2s_remove,
}
static struct snd_soc_dai_ops msm_dai_q6_mi2s_ops = {
.startup = msm_dai_q6_mi2s_startup,
.prepare = msm_dai_q6_mi2s_prepare,
.hw_params = msm_dai_q6_mi2s_hw_params,
.hw_free = msm_dai_q6_mi2s_hw_free,
.set_fmt = msm_dai_q6_mi2s_set_fmt,
.shutdown = msm_dai_q6_mi2s_shutdown,
};
msm-pcm-routing
static struct snd_soc_platform_driver msm_soc_routing_platform = {
.ops = &msm_routing_pcm_ops,
.probe = msm_routing_probe,
.pcm_new = msm_routing_pcm_new,
.pcm_free = msm_routing_pcm_free,
};
static struct snd_pcm_ops msm_routing_pcm_ops = {
.hw_params = msm_pcm_routing_hw_params,
.close = msm_pcm_routing_close,
.prepare = msm_pcm_routing_prepare,
};
snd-soc-dummy-dai
static struct snd_soc_dai_driver dummy_dai = {
.name = "snd-soc-dummy-dai",
.playback = {
.stream_name = "Playback",
.channels_min = 1,
.channels_max = 384,
.rates = STUB_RATES,
.formats = STUB_FORMATS,
},
.capture = {
.stream_name = "Capture",
.channels_min = 1,
.channels_max = 384,
.rates = STUB_RATES,
.formats = STUB_FORMATS,
},
};
static struct snd_pcm_ops dummy_dma_ops = {
.open = dummy_dma_open,
.ioctl = snd_pcm_lib_ioctl,
};
static struct snd_soc_platform_driver dummy_platform = {
.ops = &dummy_dma_ops,
};
int snd_soc_set_runtime_hwparams(struct snd_pcm_substream *substream,
const struct snd_pcm_hardware *hw)
{
struct snd_pcm_runtime *runtime = substream->runtime;
if (!runtime)
return 0;
runtime->hw.info = hw->info;
runtime->hw.formats = hw->formats;
runtime->hw.period_bytes_min = hw->period_bytes_min;
runtime->hw.period_bytes_max = hw->period_bytes_max;
runtime->hw.periods_min = hw->periods_min;
runtime->hw.periods_max = hw->periods_max;
runtime->hw.buffer_bytes_max = hw->buffer_bytes_max;
runtime->hw.fifo_size = hw->fifo_size;
return 0;
}
dai_link:
{
.name = LPASS_BE_QUAT_MI2S_TX,
.stream_name = "Quaternary MI2S Capture",
.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_capture = 1,
.be_id = MSM_BACKEND_DAI_QUATERNARY_MI2S_TX,
.be_hw_params_fixup = msm_be_hw_params_fixup,
.ops = &msm8952_quat_mi2s_be_ops,
.ignore_suspend = 1,
static struct snd_soc_ops msm8952_quat_mi2s_be_ops = {
.startup = msm_quat_mi2s_snd_startup,
.hw_params = msm_mi2s_snd_hw_params,
.shutdown = msm_quat_mi2s_snd_shutdown,
};
static int msm_quat_mi2s_snd_startup(struct snd_pcm_substream *substream)
{
struct snd_soc_pcm_runtime *rtd = substream->private_data;
struct snd_soc_card *card = rtd->card;
struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
struct msm8916_asoc_mach_data *pdata =
snd_soc_card_get_drvdata(card);
int ret = 0, val = 0;
pr_debug("%s(): substream = %s stream = %d\n", __func__,
substream->name, substream->stream);
if (!q6core_is_adsp_ready()) {
pr_err("%s(): adsp not ready\n", __func__);
return -EINVAL;
}
if (pdata->vaddr_gpio_mux_mic_ctl) {
val = ioread32(pdata->vaddr_gpio_mux_mic_ctl);
val = val | 0x02020002;
iowrite32(val, pdata->vaddr_gpio_mux_mic_ctl);
}
ret = msm_mi2s_sclk_ctl(substream, true);
if (ret < 0) {
pr_err("failed to enable sclk\n");
return ret;
}
ret = msm_gpioset_activate(CLIENT_WCD_INT, "quat_i2s");
if (ret < 0) {
pr_err("failed to enable codec gpios\n");
goto err;
}
if (atomic_inc_return(&quat_mi2s_clk_ref) == 1) {
ret = snd_soc_dai_set_fmt(cpu_dai, SND_SOC_DAIFMT_CBS_CFS);
if (ret < 0)
pr_err("%s: set fmt cpu dai failed\n", __func__);
}
return ret;
err:
ret = msm_mi2s_sclk_ctl(substream, false);
if (ret < 0)
pr_err("failed to disable sclk\n");
return ret;
}
tinymix ‘QUAT_MI2S_RX Audio Mixer MultiMedia1’ 1

根据打印,先执行get,获取到值,1,再执行put,将值用于设置连接 将snd_soc_dapm_widget与snd_kcontrol_new连接
inymix 'QUAT_MI2S_RX Audio Mixer MultiMedia1' 1 <
[ 340.617577] msm_routing_get_audio_mixer: reg 1e shift 0 val 0
[ 340.622612] msm_pcm_routing_process_audio: reg 1e val 0 set 1


msm_pcm_routing_process_audio |