Skip to content

Instantly share code, notes, and snippets.

@kangear
Last active November 13, 2018 11:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kangear/3ca98837e64d7768db11 to your computer and use it in GitHub Desktop.
Save kangear/3ca98837e64d7768db11 to your computer and use it in GitHub Desktop.
借此Machine驱动了解了ALSA on Soc的Machine驱动。这是一个简单版本的。
/*
* rk_dummy.c -- SoC audio for rockchip
*
* Driver for rockchip dummy audio
* based: 7aca69f9fe8f04ca37a01e2540960c53b24e3223 patch
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at your
* option) any later version.
*
*/
#include <linux/module.h>
#include <linux/device.h>
#include <sound/core.h>
#include <sound/pcm.h>
#include <sound/soc.h>
#include <sound/soc-dapm.h>
#include <asm/io.h>
#include <mach/hardware.h>
static struct snd_soc_dai_link rk_dai[] = {
{
.name = "RK616 I2S2",
.stream_name = "RK616 PCM",
.codec_name = "snd-soc-dummy.0",
.platform_name = "snd-soc-dummy",
.cpu_dai_name = "rk29_i2s.1",
.codec_dai_name = "snd-soc-dummy-dai",
},
};
static struct snd_soc_card snd_soc_card_rk = {
.name = "RK_RK616",
.dai_link = rk_dai,
.num_links = ARRAY_SIZE(rk_dai),
};
static struct platform_device *rk_snd_device;
static int __init audio_card_init(void)
{
int ret = 0;
printk("Enter::%s----%d\n",__FUNCTION__,__LINE__);
rk_snd_device = platform_device_alloc("soc-audio", -1);
if (!rk_snd_device) {
printk("platform device allocation failed\n");
return -ENOMEM;
}
platform_set_drvdata(rk_snd_device, &snd_soc_card_rk);
ret = platform_device_add(rk_snd_device);
if (ret) {
printk("platform device add failed\n");
platform_device_put(rk_snd_device);
return ret;
}
return ret;
}
static void __exit audio_card_exit(void)
{
platform_device_unregister(rk_snd_device);
}
module_init(audio_card_init);
module_exit(audio_card_exit);
/* Module information */
MODULE_AUTHOR("rockchip");
MODULE_DESCRIPTION("ROCKCHIP i2s ASoC Interface");
MODULE_LICENSE("GPL");
@MeekJeen
Copy link

MeekJeen commented Nov 13, 2018

报错如下:
<3>[ 834.123305] soc-audio soc-audio: ASoC: CPU DAI rk29_i2s.1 not registered

为什么rk29_i2s.1没有注册呢?大拿,能给个通过alsa驱动startup控制驱动demo吗?非常感谢!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment