ASoC: codec: add dummy codec for rockchip

Change-Id: I86cb74994d49178525e15b61b5056fd3995e904d
Signed-off-by: Sugar Zhang <sugar.zhang@rock-chips.com>
This commit is contained in:
Sugar Zhang
2018-03-23 14:59:51 +08:00
committed by Tao Huang
parent 4519e31162
commit ecf08a4208
4 changed files with 100 additions and 0 deletions

View File

@@ -0,0 +1,11 @@
* Rockchip Dummy Codec
Required properties:
- compatible: "rockchip,dummy-codec"
Example for rk3308 dummy codec:
dummy_codec: dummy-codec {
compatible = "rockchip,dummy-codec";
};

View File

@@ -471,6 +471,9 @@ config SND_SOC_DA732X
config SND_SOC_DA9055
tristate
config SND_SOC_DUMMY_CODEC
tristate "dummy codec"
config SND_SOC_DW_HDMI_AUDIO
tristate "dw hdmi audio"
depends on RK_HDMI

View File

@@ -55,6 +55,7 @@ snd-soc-da7213-objs := da7213.o
snd-soc-da7219-objs := da7219.o da7219-aad.o
snd-soc-da732x-objs := da732x.o
snd-soc-da9055-objs := da9055.o
snd-soc-dummy-codec-objs := dummy-codec.o
snd-soc-dw-hdmi-audio-objs := dw-hdmi-audio.o
snd-soc-bt-sco-objs := bt-sco.o
snd-soc-dmic-objs := dmic.o
@@ -267,6 +268,7 @@ obj-$(CONFIG_SND_SOC_DA7213) += snd-soc-da7213.o
obj-$(CONFIG_SND_SOC_DA7219) += snd-soc-da7219.o
obj-$(CONFIG_SND_SOC_DA732X) += snd-soc-da732x.o
obj-$(CONFIG_SND_SOC_DA9055) += snd-soc-da9055.o
obj-$(CONFIG_SND_SOC_DUMMY_CODEC) += snd-soc-dummy-codec.o
obj-$(CONFIG_SND_SOC_DW_HDMI_AUDIO) += snd-soc-dw-hdmi-audio.o
obj-$(CONFIG_SND_SOC_BT_SCO) += snd-soc-bt-sco.o
obj-$(CONFIG_SND_SOC_DMIC) += snd-soc-dmic.o

View File

@@ -0,0 +1,84 @@
/*
* dummy_codec.c -- dummy audio codec for rockchip
*
* Copyright (C) 2018 Fuzhou Rockchip Electronics Co., Ltd
*
* This software is licensed under the terms of the GNU General Public
* License version 2, as published by the Free Software Foundation, and
* may be copied, distributed, and modified under those terms.
*
* 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 <linux/module.h>
#include <linux/moduleparam.h>
#include <linux/slab.h>
#include <linux/of.h>
#include <linux/of_gpio.h>
#include <sound/soc.h>
#include <sound/pcm.h>
#include <sound/initval.h>
struct snd_soc_dai_driver dummy_dai = {
.name = "dummy_codec",
.playback = {
.stream_name = "Dummy Playback",
.channels_min = 2,
.channels_max = 8,
.rates = SNDRV_PCM_RATE_8000_192000,
.formats = (SNDRV_PCM_FMTBIT_S16_LE |
SNDRV_PCM_FMTBIT_S20_3LE |
SNDRV_PCM_FMTBIT_S24_LE |
SNDRV_PCM_FMTBIT_S32_LE),
},
.capture = {
.stream_name = "Dummy Capture",
.channels_min = 2,
.channels_max = 8,
.rates = SNDRV_PCM_RATE_8000_192000,
.formats = (SNDRV_PCM_FMTBIT_S16_LE |
SNDRV_PCM_FMTBIT_S20_3LE |
SNDRV_PCM_FMTBIT_S24_LE |
SNDRV_PCM_FMTBIT_S32_LE),
},
};
static struct snd_soc_codec_driver soc_dummy_codec;
static int rockchip_dummy_codec_probe(struct platform_device *pdev)
{
return snd_soc_register_codec(&pdev->dev, &soc_dummy_codec,
&dummy_dai, 1);
}
static int rockchip_dummy_codec_remove(struct platform_device *pdev)
{
snd_soc_unregister_codec(&pdev->dev);
return 0;
}
static const struct of_device_id rockchip_dummy_codec_of_match[] = {
{ .compatible = "rockchip,dummy-codec", },
{},
};
MODULE_DEVICE_TABLE(of, rockchip_dummy_codec_of_match);
static struct platform_driver rockchip_dummy_codec_driver = {
.driver = {
.name = "dummy_codec",
.of_match_table = of_match_ptr(rockchip_dummy_codec_of_match),
},
.probe = rockchip_dummy_codec_probe,
.remove = rockchip_dummy_codec_remove,
};
module_platform_driver(rockchip_dummy_codec_driver);
MODULE_AUTHOR("Sugar <sugar.zhang@rock-chips.com>");
MODULE_DESCRIPTION("Rockchip Dummy Codec Driver");
MODULE_LICENSE("GPL v2");