From: Yakir Yang <ykk@rock-chips.com>
To: Liam Girdwood <lgirdwood@gmail.com>,
djkurtz@chromium.org, dianders@chromium.org,
linux-rockchip@lists.infradead.org
Cc: David Airlie <airlied@linux.ie>,
Philipp Zabel <p.zabel@pengutronix.de>,
Russell King <rmk+kernel@arm.linux.org.uk>,
Yakir Yang <ykk@rock-chips.com>,
Andy Yan <andy.yan@rock-chips.com>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Fabio Estevam <fabio.estevam@freescale.com>,
dri-devel@lists.freedesktop.org, Mark Brown <broonie@kernel.org>,
Jaroslav Kysela <perex@perex.cz>, Takashi Iwai <tiwai@suse.de>,
Lars-Peter Clausen <lars@metafoo.de>,
Brian Austin <brian.austin@cirrus.com>,
Bard Liao <bardliao@realtek.com>,
Oder Chiou <oder_chiou@realtek.com>,
Max Filippov <jcmvbkbc@gmail.com>, Axel Lin <axel.lin@ingics.com>,
Arnd Bergmann <arnd@arndb.de>, Jyri Sarha <jsarha@ti.com>,
Sean Cross <xobs@kosagi.com>, Ben Zhang <benzh@chromium.org>,
linux-kernel@vger.kernel.org, alsa-devel@alsa-project.org,
mmind00@googlemail.com, marcheu@chromium.org,
mark.yao@rock-chips.com
Subject: [PATCH v4 14/15] ASoC: rockchip/rockchip-hdmi-audio: add sound driver for hdmi audio
Date: Sat, 28 Feb 2015 22:04:30 -0500 [thread overview]
Message-ID: <1425179070-2736-1-git-send-email-ykk@rock-chips.com> (raw)
In-Reply-To: <1425175834-24661-1-git-send-email-ykk@rock-chips.com>
Add a sound driver that combines rockchip-i2s cpu_dai and dw-hdmi-codec
as codec_dai to provide hdmi audio output on rk3288 platforms.
Signed-off-by: Yakir Yang <ykk@rock-chips.com>
---
Changes in v4:
- Add ".pm = &snd_soc_pm_ops,"
Changes in v3:
- Delete the operation of jack in rockchip-hdmi-audio driver,
get ready to switch to simple-audio-card driver.
Changes in v2:
- give "codec-name" & "codec-dai-name" an const name
sound/soc/rockchip/Kconfig | 9 ++
sound/soc/rockchip/Makefile | 2 +
sound/soc/rockchip/rockchip_hdmi_audio.c | 169 +++++++++++++++++++++++++++++++
3 files changed, 180 insertions(+)
create mode 100644 sound/soc/rockchip/rockchip_hdmi_audio.c
diff --git a/sound/soc/rockchip/Kconfig b/sound/soc/rockchip/Kconfig
index e181826..ed2b7f0 100644
--- a/sound/soc/rockchip/Kconfig
+++ b/sound/soc/rockchip/Kconfig
@@ -14,3 +14,12 @@ config SND_SOC_ROCKCHIP_I2S
Say Y or M if you want to add support for I2S driver for
Rockchip I2S device. The device supports upto maximum of
8 channels each for play and record.
+
+config SND_SOC_ROCKCHIP_HDMI_AUDIO
+ tristate "ASoC support for Rockchip HDMI audio"
+ depends on SND_SOC_ROCKCHIP
+ select SND_SOC_ROCKCHIP_I2S
+ select SND_SOC_DW_HDMI_AUDIO
+ help
+ Say Y or M here if you want to add support for SoC audio on Rockchip
+ HDMI, such as rk3288 hdmi.
diff --git a/sound/soc/rockchip/Makefile b/sound/soc/rockchip/Makefile
index b921909..b9185b3 100644
--- a/sound/soc/rockchip/Makefile
+++ b/sound/soc/rockchip/Makefile
@@ -1,4 +1,6 @@
# ROCKCHIP Platform Support
snd-soc-i2s-objs := rockchip_i2s.o
+snd-soc-rockchip-hdmi-audio-objs := rockchip_hdmi_audio.o
obj-$(CONFIG_SND_SOC_ROCKCHIP_I2S) += snd-soc-i2s.o
+obj-$(CONFIG_SND_SOC_ROCKCHIP_HDMI_AUDIO) += snd-soc-rockchip-hdmi-audio.o
diff --git a/sound/soc/rockchip/rockchip_hdmi_audio.c b/sound/soc/rockchip/rockchip_hdmi_audio.c
new file mode 100644
index 0000000..cf95037
--- /dev/null
+++ b/sound/soc/rockchip/rockchip_hdmi_audio.c
@@ -0,0 +1,169 @@
+/*
+ * rockchip-hdmi-card.c
+ *
+ * ROCKCHIP ALSA SoC DAI driver for HDMI audio on rockchip processors.
+ * Copyright (c) 2014, ROCKCHIP CORPORATION. All rights reserved.
+ * Authors: Yakir Yang <ykk@rock-chips.com>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU General Public License,
+ * version 2, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope 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.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.*
+ *
+ */
+#include <linux/module.h>
+#include <linux/platform_device.h>
+
+#include <sound/soc.h>
+#include <sound/pcm.h>
+#include <sound/core.h>
+#include <sound/pcm_params.h>
+
+#include "rockchip_i2s.h"
+
+#define DRV_NAME "rockchip-hdmi-audio"
+
+static int rockchip_hdmi_audio_hw_params(struct snd_pcm_substream *substream,
+ struct snd_pcm_hw_params *params)
+{
+ struct snd_soc_pcm_runtime *rtd = substream->private_data;
+ struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
+ unsigned int dai_fmt = rtd->dai_link->dai_fmt;
+ int mclk, ret;
+
+ switch (params_rate(params)) {
+ case 8000:
+ case 16000:
+ case 24000:
+ case 32000:
+ case 48000:
+ case 64000:
+ case 96000:
+ mclk = 12288000;
+ break;
+ case 11025:
+ case 22050:
+ case 44100:
+ case 88200:
+ mclk = 11289600;
+ break;
+ default:
+ return -EINVAL;
+ }
+
+ ret = snd_soc_dai_set_fmt(cpu_dai, dai_fmt);
+ if (ret < 0) {
+ dev_err(cpu_dai->dev, "failed to set cpu_dai fmt.\n");
+ return ret;
+ }
+
+ ret = snd_soc_dai_set_sysclk(cpu_dai, 0, mclk, SND_SOC_CLOCK_OUT);
+ if (ret < 0) {
+ dev_err(cpu_dai->dev, "failed to set cpu_dai sysclk.\n");
+ return ret;
+ }
+
+ return 0;
+}
+
+static struct snd_soc_ops hdmi_audio_dai_ops = {
+ .hw_params = rockchip_hdmi_audio_hw_params,
+};
+
+static struct snd_soc_dai_link hdmi_audio_dai = {
+ .name = "RockchipHDMI",
+ .stream_name = "RockchipHDMI",
+ .codec_name = "dw-hdmi-audio",
+ .codec_dai_name = "dw-hdmi-hifi",
+ .ops = &hdmi_audio_dai_ops,
+ .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
+ SND_SOC_DAIFMT_CBS_CFS,
+};
+
+static struct snd_soc_card rockchip_hdmi_audio_card = {
+ .name = "RockchipHDMI",
+ .owner = THIS_MODULE,
+ .dai_link = &hdmi_audio_dai,
+ .num_links = 1,
+};
+
+static int rockchip_hdmi_audio_probe(struct platform_device *pdev)
+{
+ struct snd_soc_card *card = &rockchip_hdmi_audio_card;
+ struct device_node *np = pdev->dev.of_node;
+ int ret;
+
+ card->dev = &pdev->dev;
+ platform_set_drvdata(pdev, card);
+
+ hdmi_audio_dai.cpu_of_node = of_parse_phandle(np, "i2s-controller", 0);
+ if (!hdmi_audio_dai.cpu_of_node) {
+ dev_err(&pdev->dev, "Property 'i2s-controller' missing !\n");
+ goto free_priv_data;
+ }
+
+ hdmi_audio_dai.platform_of_node = hdmi_audio_dai.cpu_of_node;
+
+ ret = snd_soc_register_card(card);
+ if (ret) {
+ dev_err(&pdev->dev, "register card failed (%d)\n", ret);
+ card->dev = NULL;
+ goto free_cpu_of_node;
+ }
+
+ dev_info(&pdev->dev, "hdmi audio init success.\n");
+
+ return 0;
+
+free_cpu_of_node:
+ hdmi_audio_dai.cpu_of_node = NULL;
+ hdmi_audio_dai.platform_of_node = NULL;
+free_priv_data:
+ snd_soc_card_set_drvdata(card, NULL);
+ platform_set_drvdata(pdev, NULL);
+ card->dev = NULL;
+
+ return ret;
+}
+
+static int rockchip_hdmi_audio_remove(struct platform_device *pdev)
+{
+ struct snd_soc_card *card = platform_get_drvdata(pdev);
+
+ snd_soc_unregister_card(card);
+ snd_soc_card_set_drvdata(card, NULL);
+ platform_set_drvdata(pdev, NULL);
+ card->dev = NULL;
+
+ return 0;
+}
+
+static const struct of_device_id rockchip_hdmi_audio_of_match[] = {
+ { .compatible = "rockchip,rk3288-hdmi-audio", },
+ {},
+};
+
+static struct platform_driver rockchip_hdmi_audio_driver = {
+ .driver = {
+ .name = DRV_NAME,
+ .owner = THIS_MODULE,
+ .pm = &snd_soc_pm_ops,
+ .of_match_table = rockchip_hdmi_audio_of_match,
+ },
+ .probe = rockchip_hdmi_audio_probe,
+ .remove = rockchip_hdmi_audio_remove,
+};
+module_platform_driver(rockchip_hdmi_audio_driver);
+
+MODULE_AUTHOR("Yakir Yang <ykk@rock-chips.com>");
+MODULE_DESCRIPTION("Rockchip HDMI Audio ASoC Interface");
+MODULE_LICENSE("GPL");
+MODULE_ALIAS("platform:" DRV_NAME);
+MODULE_DEVICE_TABLE(of, rockchip_hdmi_audio_of_match);
--
2.1.2
next prev parent reply other threads:[~2015-03-01 3:06 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-03-01 2:10 [PATCH v4 0/15] Those patches is used for dw_hdmi audio support Yakir Yang
2015-03-01 2:18 ` [PATCH v4 01/15] drm: bridge/dw_hdmi: add irq control to suspend/resume Yakir Yang
2015-03-01 2:28 ` [PATCH v4 02/15] drm: bridge/dw_hdmi: wrap irq control in fucntions Yakir Yang
2015-03-12 10:24 ` Philipp Zabel
2015-03-12 14:31 ` yakir
2015-03-12 14:41 ` Philipp Zabel
2015-03-01 2:32 ` [PATCH v4 03/15] drm: rockchip/dw_hdmi_rockchip: add resume/suspend support Yakir Yang
2015-03-12 10:24 ` Philipp Zabel
2015-03-12 14:32 ` yakir
2015-03-01 2:35 ` [PATCH v4 04/15] drm: bridge/dw_hdmi: add identification registers parse and record Yakir Yang
2015-03-12 10:29 ` Philipp Zabel
2015-03-01 2:38 ` [PATCH v4 05/15] drm: bridge/dw_hdmi: combine hdmi_set_clock_regenerator_n() and hdmi_regenerate_cts() Yakir Yang
2015-03-01 2:40 ` [PATCH v4 06/15] drm: bridge/dw_hdmi: adjust n/cts setting order Yakir Yang
2015-03-01 2:43 ` [PATCH v4 07/15] drm: bridge/dw_hdmi: set ncts_atomic_write & cts_manual Yakir Yang
2015-03-01 2:45 ` [PATCH v4 08/15] drm: bridge/dw_hdmi: add audio support for more display resolutions Yakir Yang
2015-03-01 2:47 ` [PATCH v4 09/15] drm: bridge/dw_hdmi: enable audio support for No-CEA " Yakir Yang
2015-03-01 2:49 ` [PATCH v4 10/15] drm: bridge/dw_hdmi: add audio sample channel status setting Yakir Yang
2015-03-01 2:52 ` [PATCH v4 11/15] drm: bridge/dw_hdmi: add enable/disable to dw_hdmi_audio callbacks Yakir Yang
2015-03-01 2:57 ` [PATCH v4 12/15] drm: bridge/dw_hdmi: creat dw-hdmi-audio platform device Yakir Yang
2015-03-01 2:59 ` [PATCH v4 13/15] ASoC: codec/dw-hdmi-audio: add codec driver for dw hdmi audio Yakir Yang
2015-03-02 9:15 ` Paul Bolle
2015-03-02 11:31 ` Yakir Yang
2015-03-26 18:11 ` Mark Brown
2015-03-01 3:04 ` Yakir Yang [this message]
2015-03-02 9:07 ` [PATCH v4 14/15] ASoC: rockchip/rockchip-hdmi-audio: add sound driver for " Paul Bolle
2015-03-02 11:32 ` Yakir Yang
2015-03-26 18:16 ` Mark Brown
2015-03-27 1:16 ` yakir
2015-03-27 1:19 ` Mark Brown
2015-03-01 3:07 ` [PATCH v4 15/15] dt-bindings: Add documentation for Rockchip dw-hdmi-audio Yakir Yang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1425179070-2736-1-git-send-email-ykk@rock-chips.com \
--to=ykk@rock-chips.com \
--cc=airlied@linux.ie \
--cc=alsa-devel@alsa-project.org \
--cc=andy.yan@rock-chips.com \
--cc=arnd@arndb.de \
--cc=axel.lin@ingics.com \
--cc=bardliao@realtek.com \
--cc=benzh@chromium.org \
--cc=brian.austin@cirrus.com \
--cc=broonie@kernel.org \
--cc=dianders@chromium.org \
--cc=djkurtz@chromium.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=fabio.estevam@freescale.com \
--cc=gregkh@linuxfoundation.org \
--cc=jcmvbkbc@gmail.com \
--cc=jsarha@ti.com \
--cc=lars@metafoo.de \
--cc=lgirdwood@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rockchip@lists.infradead.org \
--cc=marcheu@chromium.org \
--cc=mark.yao@rock-chips.com \
--cc=mmind00@googlemail.com \
--cc=oder_chiou@realtek.com \
--cc=p.zabel@pengutronix.de \
--cc=perex@perex.cz \
--cc=rmk+kernel@arm.linux.org.uk \
--cc=tiwai@suse.de \
--cc=xobs@kosagi.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®