Skip to content

Commit e09df07

Browse files
committed
codec : stream widget and widget event
1 parent 35e7c68 commit e09df07

File tree

2 files changed

+50
-2
lines changed

2 files changed

+50
-2
lines changed

debug/codec/README.md

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -345,6 +345,54 @@ connected回调则定义了自定义连接检查回调函数
345345

346346
"DMIC"连接到"dmic data at low level"
347347

348+
### widget的event回调函数
349+
350+
对于那些位于codec之外的widget,好像喇叭功放,外部的前置放大器等等,由于不是使用codec内部的寄存器进行电源控制,我们就必须利用dapm的事件机制,获得相应的上下电事件,从而可以定制widget自身的电源控制功能
351+
352+
在snd_soc_widget结构有一个event字段用于保存该widget的事件回调函数,同时event_flags字段用于保存该widget需要关心的dapm事件种类,只有event_flags字段中相应的事件位被设置了的事件才会发到event回调函数中进行处理
353+
354+
下面这些widget都是位于codec外部的器件,它们无法使用通用的寄存器操作来控制widget的电源状态,所以需要我们提供event回调函数
355+
356+
SND_SOC_DAPM_MIC
357+
SND_SOC_DAPM_HP
358+
SND_SOC_DAPM_SPK
359+
SND_SOC_DAPM_LINE
360+
361+
### stream widget
362+
363+
通常是指那些要处理音频流数据的widget
364+
365+
dai widget和stream widget是通过stream name进行匹配的
366+
367+
ES8316代码中的例子
368+
369+
定义I2S输入输出stream name为Capture和Playback的stream widget
370+
371+
SND_SOC_DAPM_AIF_OUT("I2S OUT", "Capture", 1, ES8316_SDP_ADCFMT_REG0A, 6, 0),
372+
SND_SOC_DAPM_AIF_IN("I2S IN", "Playback", 0, SND_SOC_NOPM, 0, 0),
373+
374+
对应的dai driver如下
375+
376+
static struct snd_soc_dai_driver es8316_dai = {
377+
.name = "ES8316 HiFi",
378+
.playback = {
379+
.stream_name = "Playback",
380+
.channels_min = 1,
381+
.channels_max = 2,
382+
.rates = es8316_RATES,
383+
.formats = es8316_FORMATS,
384+
},
385+
.capture = {
386+
.stream_name = "Capture",
387+
.channels_min = 1,
388+
.channels_max = 2,
389+
.rates = es8316_RATES,
390+
.formats = es8316_FORMATS,
391+
},
392+
.ops = &es8316_ops,
393+
.symmetric_rates = 1,
394+
};
395+
348396
### kcontrol 和 DAPM kcontrol
349397

350398
SOC_DAPM_SINGLE对应与普通控件的SOC_SINGLE

debug/codec/es8316.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -398,10 +398,10 @@ static const struct snd_soc_dapm_widget es8316_dapm_widgets[] = {
398398
&es8316_dmic_src_controls),
399399

400400
/* Digital Interface */
401-
SND_SOC_DAPM_AIF_OUT("I2S OUT", "I2S1 Capture", 1,
401+
SND_SOC_DAPM_AIF_OUT("I2S OUT", "Capture", 1,
402402
ES8316_SDP_ADCFMT_REG0A, 6, 0),
403403

404-
SND_SOC_DAPM_AIF_IN("I2S IN", "I2S1 Playback", 0,
404+
SND_SOC_DAPM_AIF_IN("I2S IN", "Playback", 0,
405405
SND_SOC_NOPM, 0, 0),
406406

407407
/* DACs DATA SRC MUX */

0 commit comments

Comments
 (0)