当前位置:网站首页>Codec of ASoC framework driven by alsa
Codec of ASoC framework driven by alsa
2022-06-12 05:02:00 【Facing the sea 0902】
One 、Nau8810 Chip system frame diagram

As can be seen from the system framework diagram , The input is differential MIC Input , The output can be MOUT or Speaker.Codec The external hardware interface passes through Audio I/O and Digital I/O, among Audio I/O Generally, the audio signal transmitted is I2S or PCM,Digital I/O The control signal is generally I2C.
The chip pin distribution is as follows :
Two 、Codec register
static struct i2c_driver nau8810_i2c_driver = {
.driver = {
.name = "nau8810",
.of_match_table = of_match_ptr(nau8810_of_match),
},
.probe = nau8810_i2c_probe,
.remove = nau8810_i2c_remove,
.id_table = nau8810_i2c_id,
};
We talked about it earlier nau8810 The control signal is I2C The bus is connected to the main chip of the platform , After the main system is started, it will detect I2C Whether the device registered on the bus exists , If the device exists and matches the corresponding drive , Then drive probe function Called , as follows :
static int nau8810_i2c_probe(struct i2c_client *i2c,
const struct i2c_device_id *id)
{
struct device *dev = &i2c->dev;
struct nau8810 *nau8810 = dev_get_platdata(dev);
if (!nau8810) {
nau8810 = devm_kzalloc(dev, sizeof(*nau8810), GFP_KERNEL);
if (!nau8810)
return -ENOMEM;
}
i2c_set_clientdata(i2c, nau8810);
nau8810->dev = dev;
nau8810->control_data = i2c;
return snd_soc_register_codec(dev,
&nau8810_codec_driver, &nau8810_dai, 1);
}
Probe function :
1、 adopt dev_get_platdata obtain dev->platform_data;
2、 Call standard snd_soc_register_codec register Codec.
3、 ... and 、 initialization Codec And dai
The focus here is on the registration above Codec Of snd_soc_register_codec(dev, &nau8810_codec_driver, &nau8810_dai, 1) Medium snd_soc_codec_driver and snd_soc_dai_driver Structure .
snd_soc_codec_driver nau8810_codec_driver as follows :
static struct snd_soc_codec_driver nau8810_codec_driver = {
.probe = nau8810_codec_probe,
.remove = nau8810_codec_remove,
.set_bias_level = nau8810_set_bias_level,
.read = nau8810_read,
.write = nau8810_write,
.reg_cache_size = ARRAY_SIZE(nau8810_reg_defaults),
.reg_word_size = sizeof(u16),
.reg_cache_default = nau8810_reg_defaults,
.reg_cache_step = 1,
.controls = nau8810_snd_controls,
.num_controls = ARRAY_SIZE(nau8810_snd_controls),
.dapm_widgets = nau8810_dapm_widgets,
.num_dapm_widgets = ARRAY_SIZE(nau8810_dapm_widgets),
.dapm_routes = nau8810_dapm_routes,
.num_dapm_routes = ARRAY_SIZE(nau8810_dapm_routes),
};
Such as ALSA drive asoc Framework machine( One ) As described in : adopt 3 A global linked list , Match by name , Match the codec,dai and platform The instance is assigned to each pair of sound cards dai Of snd_soc_pcm_runtime variable . Once the binding is successful , Will make codec and dai Driven probe Callback called ,codec The initialization of is completed in this callback .
stay nau8810_codec_driver In the structure .read/write It's reading and writing Codec Register interface ,probe The main function is to initialize Codec,set_bias_level Function is used to change the working state of the chip ,dapm_widgets and dapm_routes involves DAPM It's very complicated. I'll talk about it separately later .
snd_soc_dai_driver nau8810_dai, as follows :
static struct snd_soc_dai_driver nau8810_dai = {
.name = "nau8810-hifi",
.playback = {
.stream_name = "Playback",
.channels_min = 1,
.channels_max = 2, /* Only 1 channel of data */
.rates = NAU8810_RATES,
.formats = NAU8810_FORMATS,
},
.capture = {
.stream_name = "Capture",
.channels_min = 1,
.channels_max = 2, /* Only 1 channel of data */
.rates = NAU8810_RATES,
.formats = NAU8810_FORMATS,
},
.ops = &nau8810_ops,
.symmetric_rates = 1,
};
snd_soc_dai_driver The name structure corresponds to snd_soc_card Inside the structure dai_link The name of the member in , It has the function of recording and playing , One more operation Structure , That is to say .ops Field , It points to codec_dai The set of operation functions of , Defined dai The clock configuration of 、 Format configuration 、 Hardware parameter configuration and other callbacks , as follows :
static const struct snd_soc_dai_ops nau8810_ops = {
.hw_params = nau8810_pcm_hw_params,
.set_fmt = nau8810_set_dai_fmt,
.set_sysclk = nau8810_set_sysclk,
.set_pll = nau8810_set_pll,
};
On the whole Codec The driver is almost finished , But more specifically, for example kcontrol 、widget、path And further study Codec The driver will find
snd_soc_dapm_widget,snd_soc_dapm_path,snd_soc_dapm_route, What are these and how to use them , Later we will say .
边栏推荐
- Google reinforcement learning framework seed RL environment deployment
- Token based authentication
- Ubunt 20.04 uses CDROM or ISO as the installation source
- Pupanvr- establishment of development environment and diary, addition of some basic tool functions (3)
- Day18 creation and restoration of sparse array
- 2022 electrician (elementary) operation certificate examination question bank and online simulation examination
- How to clear floating, and how does it work?
- Some problems of Qinglong panel
- Classes and objects, methods and encapsulation
- Bearpi IOT serial port transceiver 1- normal mode
猜你喜欢

Microsoft announces that it will discontinue support for older versions of visual studio

Interview must ask: summary of ten classic sorting algorithms

Soil type, soil texture, soil nutrient and change data, soil organic matter, soil pH, soil nitrogen, phosphorus and potassium

A complete set of installation procedures (for learning and communication only)

Can‘t find a suitable configuration file in this directory or any parent. Error reporting and resolution

Ten trends of Internet Security in 2022 industry released

Image processing 13- calculation of integral diagram

Map coordinate conversion of Baidu map API

Simple Tetris

2022“高考记忆” 已打包完成,请查收!
随机推荐
Operation of simulated examination platform for theoretical question bank of G2 utility boiler stoker in 2022
Summary of problems in rv1109/rv1126 product development
2022“高考记忆” 已打包完成,请查收!
February 19, 2022 [Nolan] Nolan resurrected? Change · Nolan [soul orchid] can be connected to XDD / silly girl
Operation of simulated examination platform for 2022 safety officer-b certificate examination questions
JS disable mobile sharing
one billion one hundred and eleven million one hundred and eleven thousand one hundred and eleven
Asp. Net core EF value conversion
leetcode 263. Ugly number
Pupanvr- an open source embedded NVR system (1)
JWT learning and use
LabVIEW关于TDMS和Binary存储速度
How to clear floating, and how does it work?
Font conversion optimization
Day18 creation and restoration of sparse array
Yolo opencv scale identification scale reading identification water gauge identification water level identification source code
加速訓練之並行化 tf.data.Dataset 生成器
Bearpi IOT serial port transceiver 1- normal mode
Layer sublayer assigns values to the page elements of the parent layer to achieve the effect of transferring values to the page of the parent layer
1007- stair climbing