当前位置:网站首页>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 .
边栏推荐
- kali_ Change_ Domestic source
- Realease package appears – missing type parameter
- 1006 next spread
- Longest palindrome string
- The master programmer "plays" a C program that is not like C
- ShanMeng and Beijing Adoption Day start NFT digital collection public offering
- MySQL5.7.21 Build For ARM
- Design of a simple embedded web service application
- Three. JS import model demo analysis (with notes)
- Can‘t find a suitable configuration file in this directory or any parent. Error reporting and resolution
猜你喜欢

How to count the total length of roads in the region and draw data histogram

Spatial distribution data of national multi-year average precipitation 1951-2021, temperature distribution data, evapotranspiration data, evaporation data, solar radiation data, sunshine data and wind

Redis learning notes (continuously updating)

Simulation of array implementation stack

Longest palindrome string

BI 如何让SaaS产品具有 “安全感”和“敏锐感”(上)

How to generate provincial data from county-level data in ArcGIS?

Development of video preview for main interface of pupanvr-ui

How to deploy dolphin scheduler Apache dolphin scheduler 1.2.0 in cdh5.16.2
![[backtracking based on bit operation] queen n problem 2](/img/d3/25b2ba7c49ce0a9c1de26bc5c9497b.jpg)
[backtracking based on bit operation] queen n problem 2
随机推荐
Radiometric calibration and atmospheric correction of sentry 2 L1C multispectral data using sen2cor
Force/release learning and sorting in IC Verification (6) research on the influence of wire type signals
LabVIEW关于TDMS和Binary存储速度
kali_ Change_ Domestic source
ShanMeng and Beijing Adoption Day start NFT digital collection public offering
How to deploy PostgreSQL as a docker container
SQL injection upload one sentence Trojan horse (turn)
The emergence of new ides and the crisis of programmers?
Summary of common interview questions in redis
[GIS tutorial] land use transfer matrix
kali下安装pycharm并创建快捷访问
Musk promotes the development of fascinating new products partners remind important questions
Parallélisation de l'entraînement accéléré TF. Données. Générateur de données
IC验证中的force/release 学习整理(5)研究对 reg类型信号的影响
L1-065 "nonsense code" (5 points)
【cjson】根节点注意事项
When the build When gradle does not load the dependencies, and you need to add a download path in libraries, the path in gradle is not a direct downloadable path
1009 word search
Pupanvr- establishment of development environment and diary, addition of some basic tool functions (3)
How to generate provincial data from county-level data in ArcGIS?