[RK3399][Android7.1] 调试笔记 --- 虚拟声卡驱动添加

Platform: RK3399
OS: Android 7.1
Kernel: v4.4.83

需求:

当前默认一个普通的codec已经无法满足需求了,如回声消除,降噪,唤醒等功能。
RK3399平台的I2S0通道提供最高8路通道录音支持。如果拿到一个麦克阵列,那么可以添加到此路通道上。
I2S1就接普通codec.


代码实现:

firefly平台也有对应的实现,可参考。
这部分代码是由rockchip罗工实现,感谢他,也让我对audio有了进一步了解。

/*
 * rk_pcm_codec.c  --  Rockchip PCM codecs driver
 *
 * Copyright (c) 2016, ROCKCHIP CORPORATION.  All rights reserved.
 * Author: Xiaotan Luo 
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 and
 * only version 2 as published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 */
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 

#if 1
#define DBG(x...) printk(KERN_INFO "rk_pcm_codec :"x)
#else
#define DBG(x...) do { } while (0)
#endif
#define FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S20_3LE |\
	SNDRV_PCM_FMTBIT_S24_LE| SNDRV_PCM_FMTBIT_S32_LE)
struct snd_soc_dai_driver sph0645lm4h_card_dai = {
	.name = "rockchip-sph0645lm4h-card-hifi",	
	.capture = {
		.stream_name = "HiFi Capture",
		.channels_min = 2,
		.channels_max = 8,
		.rates = (
			SNDRV_PCM_RATE_8000|
			SNDRV_PCM_RATE_16000|
			SNDRV_PCM_RATE_32000 |
			SNDRV_PCM_RATE_44100 |
			SNDRV_PCM_RATE_48000 |
			SNDRV_PCM_RATE_96000 |
			SNDRV_PCM_RATE_192000),
		.formats = FORMATS,
	},

};

static struct snd_soc_codec_driver soc_codec_dev_sph0645lm4h_card;

static int rockchip_sph0645lm4h_card_audio_probe(struct platform_device *pdev)
{
	int ret;

	//set dev name to driver->name for sound card register
	//printk("%s,%s\n",__FILE__,__FUNCTION__);
	dev_set_name(&pdev->dev, "%s", pdev->dev.driver->name);

	ret = snd_soc_register_codec(&pdev->dev,
		&soc_codec_dev_sph0645lm4h_card,
		&sph0645lm4h_card_dai, 1);

	if (ret)
		printk("%s() register card failed:%d\n", __FUNCTION__, ret);
	printk("---------------------rockchip_pcm_card_audio_probe111-------------------\n");
	return ret;
}

static int rockchip_sph0645lm4h_card_audio_remove(struct platform_device *pdev)
{
	snd_soc_unregister_codec(&pdev->dev);

	return 0;
}

#ifdef CONFIG_OF
static const struct of_device_id rockchip_sph0645lm4h_card_of_match[] = {
        { .compatible = "rockchip-sph0645lm4h-codec", },
        {},
};
MODULE_DEVICE_TABLE(of, rockchip_sph0645lm4h_card_of_match);
#endif /* CONFIG_OF */

static struct platform_driver rockchip_sph0645lm4h_card_audio_driver = {
        .driver         = {
                .name   = "rockchip-sph0645lm4h-codec",
                .owner  = THIS_MODULE,
                .of_match_table = of_match_ptr(rockchip_sph0645lm4h_card_of_match),
        },
        .probe          = rockchip_sph0645lm4h_card_audio_probe,
        .remove         = rockchip_sph0645lm4h_card_audio_remove,
};

module_platform_driver(rockchip_sph0645lm4h_card_audio_driver);

MODULE_DESCRIPTION("ASoC Rockchip PCM codec driver");
MODULE_AUTHOR("Xiaotan Luo ");
MODULE_LICENSE("GPL v2");

你可能感兴趣的:(RK3399,子类__Audio,mic,digital,codec,i2s)