mirror of
https://github.com/Fishwaldo/build.git
synced 2025-04-26 07:51:27 +00:00
* Attach Meson64 to mainline with a bunch of patches. Tested, but need further work. * Enable DVFS on N2 which sometimes works, sometime doesn't, cleanup * Enable beta targets for Meson64 kernel family * Bump with version
205 lines
6.2 KiB
Diff
205 lines
6.2 KiB
Diff
From a7e5bdf1590c1df69a87b19761c22319245492e4 Mon Sep 17 00:00:00 2001
|
|
From: Jerome Brunet <jbrunet@baylibre.com>
|
|
Date: Tue, 22 Oct 2019 18:11:42 +0200
|
|
Subject: [PATCH 55/94] WIP: ASoC: meson: add gx card support
|
|
|
|
Signed-off-by: Jerome Brunet <jbrunet@baylibre.com>
|
|
---
|
|
sound/soc/meson/Kconfig | 10 ++++
|
|
sound/soc/meson/Makefile | 2 +
|
|
sound/soc/meson/gx-card.c | 142 ++++++++++++++++++++++++++++++++++++++++++++++
|
|
3 files changed, 154 insertions(+)
|
|
create mode 100644 sound/soc/meson/gx-card.c
|
|
|
|
diff --git a/sound/soc/meson/Kconfig b/sound/soc/meson/Kconfig
|
|
index 2beea1f..2818c13 100644
|
|
--- a/sound/soc/meson/Kconfig
|
|
+++ b/sound/soc/meson/Kconfig
|
|
@@ -133,6 +133,16 @@ config SND_MESON_CARD_UTILS
|
|
config SND_MESON_CODEC_GLUE
|
|
tristate
|
|
|
|
+config SND_MESON_GX_SOUND_CARD
|
|
+ tristate "Amlogic GX Sound Card Support"
|
|
+ select SND_MESON_CARD_UTILS
|
|
+ imply SND_MESON_AIU_I2S_FIFO
|
|
+ imply SND_MESON_AIU_SPDIF_FIFO
|
|
+ imply SND_MESON_AIU_I2S_ENCODE
|
|
+ imply SND_MESON_AIU_SPDIF_ENCODE
|
|
+ help
|
|
+ Select Y or M to add support for the GXBB/GXL SoC sound card
|
|
+
|
|
config SND_MESON_G12A_TOACODEC
|
|
tristate "Amlogic G12A To Internal DAC Control Support"
|
|
select SND_MESON_CODEC_GLUE
|
|
diff --git a/sound/soc/meson/Makefile b/sound/soc/meson/Makefile
|
|
index cce27b2..ad62cc2 100644
|
|
--- a/sound/soc/meson/Makefile
|
|
+++ b/sound/soc/meson/Makefile
|
|
@@ -19,6 +19,7 @@ snd-soc-meson-axg-spdifout-objs := axg-spdifout.o
|
|
snd-soc-meson-axg-pdm-objs := axg-pdm.o
|
|
snd-soc-meson-card-utils-objs := meson-card-utils.o
|
|
snd-soc-meson-codec-glue-objs := meson-codec-glue.o
|
|
+snd-soc-meson-gx-sound-card-objs := gx-card.o
|
|
snd-soc-meson-g12a-toacodec-objs := g12a-toacodec.o
|
|
snd-soc-meson-g12a-tohdmitx-objs := g12a-tohdmitx.o
|
|
snd-soc-meson-t9015-objs := t9015.o
|
|
@@ -42,6 +43,7 @@ obj-$(CONFIG_SND_MESON_AXG_SPDIFOUT) += snd-soc-meson-axg-spdifout.o
|
|
obj-$(CONFIG_SND_MESON_AXG_PDM) += snd-soc-meson-axg-pdm.o
|
|
obj-$(CONFIG_SND_MESON_CARD_UTILS) += snd-soc-meson-card-utils.o
|
|
obj-$(CONFIG_SND_MESON_CODEC_GLUE) += snd-soc-meson-codec-glue.o
|
|
+obj-$(CONFIG_SND_MESON_GX_SOUND_CARD) += snd-soc-meson-gx-sound-card.o
|
|
obj-$(CONFIG_SND_MESON_G12A_TOACODEC) += snd-soc-meson-g12a-toacodec.o
|
|
obj-$(CONFIG_SND_MESON_G12A_TOHDMITX) += snd-soc-meson-g12a-tohdmitx.o
|
|
obj-$(CONFIG_SND_SOC_MESON_T9015) += snd-soc-meson-t9015.o
|
|
diff --git a/sound/soc/meson/gx-card.c b/sound/soc/meson/gx-card.c
|
|
new file mode 100644
|
|
index 0000000..b7a0e89
|
|
--- /dev/null
|
|
+++ b/sound/soc/meson/gx-card.c
|
|
@@ -0,0 +1,142 @@
|
|
+// SPDX-License-Identifier: (GPL-2.0 OR MIT)
|
|
+//
|
|
+// Copyright (c) 2019 BayLibre, SAS.
|
|
+// Author: Jerome Brunet <jbrunet@baylibre.com>
|
|
+
|
|
+#include <linux/module.h>
|
|
+#include <linux/of_platform.h>
|
|
+#include <sound/soc.h>
|
|
+#include <sound/soc-dai.h>
|
|
+
|
|
+#include "meson-card.h"
|
|
+
|
|
+struct gx_dai_link_i2s_data {
|
|
+ unsigned int mclk_fs;
|
|
+};
|
|
+
|
|
+/*
|
|
+ * Base params for the codec to codec links
|
|
+ * Those will be over-written by the CPU side of the link
|
|
+ */
|
|
+static const struct snd_soc_pcm_stream codec_params = {
|
|
+ .formats = SNDRV_PCM_FMTBIT_S24_LE,
|
|
+ .rate_min = 5525,
|
|
+ .rate_max = 192000,
|
|
+ .channels_min = 1,
|
|
+ .channels_max = 8,
|
|
+};
|
|
+
|
|
+static int gx_card_i2s_be_hw_params(struct snd_pcm_substream *substream,
|
|
+ struct snd_pcm_hw_params *params)
|
|
+{
|
|
+ struct snd_soc_pcm_runtime *rtd = substream->private_data;
|
|
+ struct meson_card *priv = snd_soc_card_get_drvdata(rtd->card);
|
|
+ struct gx_dai_link_i2s_data *be =
|
|
+ (struct gx_dai_link_i2s_data *)priv->link_data[rtd->num];
|
|
+
|
|
+ return meson_card_i2s_set_sysclk(substream, params, be->mclk_fs);
|
|
+}
|
|
+
|
|
+static const struct snd_soc_ops gx_card_i2s_be_ops = {
|
|
+ .hw_params = gx_card_i2s_be_hw_params,
|
|
+};
|
|
+
|
|
+static int gx_card_parse_i2s(struct snd_soc_card *card,
|
|
+ struct device_node *node,
|
|
+ int *index)
|
|
+{
|
|
+ struct meson_card *priv = snd_soc_card_get_drvdata(card);
|
|
+ struct snd_soc_dai_link *link = &card->dai_link[*index];
|
|
+ struct gx_dai_link_i2s_data *be;
|
|
+
|
|
+ /* Allocate i2s link parameters */
|
|
+ be = devm_kzalloc(card->dev, sizeof(*be), GFP_KERNEL);
|
|
+ if (!be)
|
|
+ return -ENOMEM;
|
|
+ priv->link_data[*index] = be;
|
|
+
|
|
+ /* Setup i2s link */
|
|
+ link->ops = &gx_card_i2s_be_ops;
|
|
+ link->dai_fmt = meson_card_parse_daifmt(node, link->cpus->of_node);
|
|
+
|
|
+ of_property_read_u32(node, "mclk-fs", &be->mclk_fs);
|
|
+
|
|
+ return 0;
|
|
+}
|
|
+
|
|
+static int gx_card_cpu_is_playback_fe(struct device_node *np)
|
|
+{
|
|
+ return of_device_is_compatible(np, DT_PREFIX "aiu-fifo");
|
|
+}
|
|
+
|
|
+static int gx_card_cpu_is_i2s_encoder(struct device_node *np)
|
|
+{
|
|
+ return of_device_is_compatible(np, DT_PREFIX "aiu-i2s-encode");
|
|
+}
|
|
+
|
|
+static int gx_card_cpu_is_codec(struct device_node *np)
|
|
+{
|
|
+ return of_device_is_compatible(np, DT_PREFIX "gx-tohdmitx") ||
|
|
+ of_device_is_compatible(np, DT_PREFIX "gxl-toacodec");
|
|
+}
|
|
+
|
|
+static int gx_card_add_link(struct snd_soc_card *card, struct device_node *np,
|
|
+ int *index)
|
|
+{
|
|
+ struct snd_soc_dai_link *dai_link = &card->dai_link[*index];
|
|
+ struct snd_soc_dai_link_component *cpu;
|
|
+ int ret;
|
|
+
|
|
+ cpu = devm_kzalloc(card->dev, sizeof(*cpu), GFP_KERNEL);
|
|
+ if (!cpu)
|
|
+ return -ENOMEM;
|
|
+
|
|
+ dai_link->cpus = cpu;
|
|
+ dai_link->num_cpus = 1;
|
|
+
|
|
+ ret = meson_card_parse_dai(card, np, &dai_link->cpus->of_node,
|
|
+ &dai_link->cpus->dai_name);
|
|
+ if (ret)
|
|
+ return ret;
|
|
+
|
|
+ if (gx_card_cpu_is_playback_fe(dai_link->cpus->of_node))
|
|
+ ret = meson_card_set_fe_link(card, dai_link, np, true);
|
|
+ else
|
|
+ ret = meson_card_set_be_link(card, dai_link, np);
|
|
+
|
|
+ if (ret)
|
|
+ return ret;
|
|
+
|
|
+ if (gx_card_cpu_is_i2s_encoder(dai_link->cpus->of_node))
|
|
+ ret = gx_card_parse_i2s(card, np, index);
|
|
+ else if (gx_card_cpu_is_codec(dai_link->cpus->of_node))
|
|
+ dai_link->params = &codec_params;
|
|
+
|
|
+ return ret;
|
|
+}
|
|
+
|
|
+static const struct meson_card_match_data gx_card_match_data = {
|
|
+ .add_link = gx_card_add_link,
|
|
+};
|
|
+
|
|
+static const struct of_device_id gx_card_of_match[] = {
|
|
+ {
|
|
+ .compatible = "amlogic,gx-sound-card",
|
|
+ .data = &gx_card_match_data,
|
|
+ }, {}
|
|
+};
|
|
+MODULE_DEVICE_TABLE(of, gx_card_of_match);
|
|
+
|
|
+static struct platform_driver gx_card_pdrv = {
|
|
+ .probe = meson_card_probe,
|
|
+ .remove = meson_card_remove,
|
|
+ .driver = {
|
|
+ .name = "gx-sound-card",
|
|
+ .of_match_table = gx_card_of_match,
|
|
+ },
|
|
+};
|
|
+module_platform_driver(gx_card_pdrv);
|
|
+
|
|
+MODULE_DESCRIPTION("Amlogic GX ALSA machine driver");
|
|
+MODULE_AUTHOR("Jerome Brunet <jbrunet@baylibre.com>");
|
|
+MODULE_LICENSE("GPL v2");
|
|
--
|
|
2.7.1
|
|
|