mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-06 19:08:57 +09:00
ASoC: codecs: Adds support for dummy codec
Change-Id: I86cb74994d49178525e15b61b5056fd3995e904d Signed-off-by: Sugar Zhang <sugar.zhang@rock-chips.com>
This commit is contained in:
@@ -75,6 +75,7 @@ config SND_SOC_ALL_CODECS
|
||||
select SND_SOC_DA732X if I2C
|
||||
select SND_SOC_DA9055 if I2C
|
||||
select SND_SOC_DMIC if GPIOLIB
|
||||
select SND_SOC_DUMMY_CODEC
|
||||
select SND_SOC_ES8316 if I2C
|
||||
select SND_SOC_ES8328_SPI if SPI_MASTER
|
||||
select SND_SOC_ES8328_I2C if I2C
|
||||
@@ -583,6 +584,9 @@ config SND_SOC_DA9055
|
||||
config SND_SOC_DMIC
|
||||
tristate
|
||||
|
||||
config SND_SOC_DUMMY_CODEC
|
||||
tristate "Dummy CODEC"
|
||||
|
||||
config SND_SOC_HDMI_CODEC
|
||||
tristate
|
||||
select SND_PCM_ELD
|
||||
|
||||
@@ -70,6 +70,7 @@ snd-soc-da7219-objs := da7219.o da7219-aad.o
|
||||
snd-soc-da732x-objs := da732x.o
|
||||
snd-soc-da9055-objs := da9055.o
|
||||
snd-soc-dmic-objs := dmic.o
|
||||
snd-soc-dummy-codec-objs := dummy-codec.o
|
||||
snd-soc-es7134-objs := es7134.o
|
||||
snd-soc-es7241-objs := es7241.o
|
||||
snd-soc-es8316-objs := es8316.o
|
||||
@@ -336,6 +337,7 @@ 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_DMIC) += snd-soc-dmic.o
|
||||
obj-$(CONFIG_SND_SOC_DUMMY_CODEC) += snd-soc-dummy-codec.o
|
||||
obj-$(CONFIG_SND_SOC_ES7134) += snd-soc-es7134.o
|
||||
obj-$(CONFIG_SND_SOC_ES7241) += snd-soc-es7241.o
|
||||
obj-$(CONFIG_SND_SOC_ES8316) += snd-soc-es8316.o
|
||||
|
||||
@@ -1,18 +1,8 @@
|
||||
/*
|
||||
* 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.
|
||||
*
|
||||
*/
|
||||
// SPDX-License-Identifier: GPL-2.0
|
||||
//
|
||||
// dummy_codec.c -- dummy audio codec for rockchip
|
||||
//
|
||||
// Copyright (C) 2018 Fuzhou Rockchip Electronics Co., Ltd
|
||||
|
||||
#include <linux/clk.h>
|
||||
#include <linux/module.h>
|
||||
@@ -25,29 +15,28 @@
|
||||
#include <sound/initval.h>
|
||||
|
||||
struct dummy_codec_priv {
|
||||
struct snd_soc_codec *codec;
|
||||
struct snd_soc_component *component;
|
||||
struct clk *mclk;
|
||||
};
|
||||
|
||||
static int dummy_codec_startup(struct snd_pcm_substream *substream,
|
||||
struct snd_soc_dai *dai)
|
||||
{
|
||||
struct snd_soc_codec *codec = dai->codec;
|
||||
struct dummy_codec_priv *dummy_codec = snd_soc_codec_get_drvdata(codec);
|
||||
struct dummy_codec_priv *dcp = snd_soc_component_get_drvdata(dai->component);
|
||||
|
||||
if (!IS_ERR(dcp->mclk))
|
||||
clk_prepare_enable(dcp->mclk);
|
||||
|
||||
if (!IS_ERR(dummy_codec->mclk))
|
||||
clk_prepare_enable(dummy_codec->mclk);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void dummy_codec_shutdown(struct snd_pcm_substream *substream,
|
||||
struct snd_soc_dai *dai)
|
||||
{
|
||||
struct snd_soc_codec *codec = dai->codec;
|
||||
struct dummy_codec_priv *dummy_codec = snd_soc_codec_get_drvdata(codec);
|
||||
struct dummy_codec_priv *dcp = snd_soc_component_get_drvdata(dai->component);
|
||||
|
||||
if (!IS_ERR(dummy_codec->mclk))
|
||||
clk_disable_unprepare(dummy_codec->mclk);
|
||||
if (!IS_ERR(dcp->mclk))
|
||||
clk_disable_unprepare(dcp->mclk);
|
||||
}
|
||||
|
||||
static struct snd_soc_dai_ops dummy_codec_dai_ops = {
|
||||
@@ -80,39 +69,29 @@ struct snd_soc_dai_driver dummy_dai = {
|
||||
.ops = &dummy_codec_dai_ops,
|
||||
};
|
||||
|
||||
static struct snd_soc_codec_driver soc_dummy_codec;
|
||||
static const struct snd_soc_component_driver soc_dummy_codec;
|
||||
|
||||
static int rockchip_dummy_codec_probe(struct platform_device *pdev)
|
||||
{
|
||||
struct dummy_codec_priv *codec_priv;
|
||||
struct dummy_codec_priv *dcp;
|
||||
|
||||
codec_priv = devm_kzalloc(&pdev->dev, sizeof(*codec_priv),
|
||||
GFP_KERNEL);
|
||||
if (!codec_priv)
|
||||
dcp = devm_kzalloc(&pdev->dev, sizeof(*dcp), GFP_KERNEL);
|
||||
if (!dcp)
|
||||
return -ENOMEM;
|
||||
platform_set_drvdata(pdev, codec_priv);
|
||||
|
||||
codec_priv->mclk = devm_clk_get(&pdev->dev, "mclk");
|
||||
if (IS_ERR(codec_priv->mclk)) {
|
||||
/* some devices may not need mclk,so warnnig */
|
||||
dev_warn(&pdev->dev, "Unable to get mclk\n");
|
||||
if (PTR_ERR(codec_priv->mclk) == -EPROBE_DEFER)
|
||||
platform_set_drvdata(pdev, dcp);
|
||||
|
||||
/* optional mclk, if needs, assign mclk in dts node */
|
||||
dcp->mclk = devm_clk_get(&pdev->dev, "mclk");
|
||||
if (IS_ERR(dcp->mclk)) {
|
||||
if (PTR_ERR(dcp->mclk) == -EPROBE_DEFER)
|
||||
return -EPROBE_DEFER;
|
||||
else if (PTR_ERR(codec_priv->mclk) != -ENOENT)
|
||||
else if (PTR_ERR(dcp->mclk) != -ENOENT)
|
||||
return -EINVAL;
|
||||
} else {
|
||||
dev_info(&pdev->dev, "get mclk success\n");
|
||||
}
|
||||
|
||||
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;
|
||||
return devm_snd_soc_register_component(&pdev->dev, &soc_dummy_codec,
|
||||
&dummy_dai, 1);
|
||||
}
|
||||
|
||||
static const struct of_device_id rockchip_dummy_codec_of_match[] = {
|
||||
@@ -127,7 +106,6 @@ static struct platform_driver rockchip_dummy_codec_driver = {
|
||||
.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);
|
||||
|
||||
Reference in New Issue
Block a user