]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
ENGR00277299-5 ASoC: fsl: Add hdmi audio machine driver
authorNicolin Chen <b42378@freescale.com>
Mon, 2 Sep 2013 03:09:54 +0000 (11:09 +0800)
committerLothar Waßmann <LW@KARO-electronics.de>
Wed, 20 Aug 2014 08:06:25 +0000 (10:06 +0200)
Add hdmi audio machine dirver

Signed-off-by: Nicolin Chen <b42378@freescale.com>
sound/soc/fsl/Kconfig
sound/soc/fsl/Makefile
sound/soc/fsl/imx-hdmi.c [new file with mode: 0644]

index c8729814e337241ca97d19b09b2a095f01d802e7..daa77e6b5997f8448b7cf299b5ae22c3bce0e1e3 100644 (file)
@@ -269,6 +269,17 @@ config SND_SOC_IMX_MC13783
        select SND_SOC_MC13783
        select SND_SOC_IMX_PCM_DMA
 
+config SND_SOC_IMX_HDMI
+       tristate "SoC Audio support for i.MX boards with HDMI port"
+       depends on MFD_MXC_HDMI
+       select SND_SOC_IMX_HDMI_DMA
+       select SND_SOC_FSL_HDMI
+       select SND_SOC_OMAP_HDMI_CODEC
+       help
+         SoC Audio support for i.MX boards with HDMI audio
+         Say Y if you want to add support for SoC audio on an i.MX board with
+         IMX HDMI.
+
 config SND_SOC_IMX_SI476X
        tristate "SoC Audio support for i.MX boards with si476x"
        select SND_SOC_IMX_PCM_DMA
index a5dd4c2588382cb05d0a894cf7c42fdd34d08e46..44ec6ef7f9616fb6578872030d52bbe44dc584c3 100644 (file)
@@ -53,6 +53,7 @@ snd-soc-imx-sgtl5000-objs := imx-sgtl5000.o
 snd-soc-imx-wm8962-objs := imx-wm8962.o
 snd-soc-imx-spdif-objs := imx-spdif.o
 snd-soc-imx-mc13783-objs := imx-mc13783.o
+snd-soc-imx-hdmi-objs := imx-hdmi.o
 snd-soc-imx-si476x-objs := imx-si476x.o
 
 obj-$(CONFIG_SND_SOC_EUKREA_TLV320) += snd-soc-eukrea-tlv320.o
@@ -64,4 +65,5 @@ obj-$(CONFIG_SND_SOC_IMX_SGTL5000) += snd-soc-imx-sgtl5000.o
 obj-$(CONFIG_SND_SOC_IMX_WM8962) += snd-soc-imx-wm8962.o
 obj-$(CONFIG_SND_SOC_IMX_SPDIF) += snd-soc-imx-spdif.o
 obj-$(CONFIG_SND_SOC_IMX_MC13783) += snd-soc-imx-mc13783.o
+obj-$(CONFIG_SND_SOC_IMX_HDMI) += snd-soc-imx-hdmi.o
 obj-$(CONFIG_SND_SOC_IMX_SI476X) += snd-soc-imx-si476x.o
diff --git a/sound/soc/fsl/imx-hdmi.c b/sound/soc/fsl/imx-hdmi.c
new file mode 100644 (file)
index 0000000..04fcff8
--- /dev/null
@@ -0,0 +1,126 @@
+/*
+ * ASoC HDMI Transmitter driver for IMX development boards
+ *
+ * Copyright (C) 2011-2013 Freescale Semiconductor, Inc.
+ *
+ * based on stmp3780_devb_hdmi.c
+ *
+ * Vladimir Barinov <vbarinov@embeddedalley.com>
+ *
+ * Copyright 2008 SigmaTel, Inc
+ * Copyright 2008 Embedded Alley Solutions, Inc
+ *
+ * This file is licensed under the terms of the GNU General Public License
+ * version 2.  This program  is licensed "as is" without any warranty of any
+ * kind, whether express or implied.
+ */
+
+#include <linux/module.h>
+#include <linux/of_platform.h>
+#include <linux/mfd/mxc-hdmi-core.h>
+#include <sound/soc.h>
+
+#include "imx-hdmi.h"
+
+/* imx digital audio interface glue - connects codec <--> CPU */
+static struct snd_soc_dai_link imx_hdmi_dai_link = {
+       .name = "i.MX HDMI Audio Tx",
+       .stream_name = "i.MX HDMI Audio Tx",
+       .codec_dai_name = "hdmi-hifi",
+       .codec_name = "hdmi-audio-codec",
+       .platform_name = "imx-hdmi-audio",
+};
+
+static struct snd_soc_card snd_soc_card_imx_hdmi = {
+       .name = "imx-hdmi-soc",
+       .dai_link = &imx_hdmi_dai_link,
+       .num_links = 1,
+};
+
+static struct platform_device *codec_dev;
+
+static int imx_hdmi_audio_probe(struct platform_device *pdev)
+{
+       struct device_node *hdmi_np, *np = pdev->dev.of_node;
+       struct snd_soc_card *card = &snd_soc_card_imx_hdmi;
+       struct platform_device *hdmi_pdev;
+       int ret = 0;
+
+       if (!hdmi_get_registered()) {
+               dev_err(&pdev->dev, "initialize HDMI-audio failed. load HDMI-video first!\n");
+               return -ENODEV;
+       }
+
+       hdmi_np = of_parse_phandle(np, "hdmi-controller", 0);
+       if (!hdmi_np) {
+               dev_err(&pdev->dev, "failed to find hdmi-audio cpudai\n");
+               ret = -EINVAL;
+               goto end;
+       }
+
+       hdmi_pdev = of_find_device_by_node(hdmi_np);
+       if (!hdmi_pdev) {
+               dev_err(&pdev->dev, "failed to find SSI platform device\n");
+               ret = -EINVAL;
+               goto end;
+       }
+
+       codec_dev = platform_device_register_simple("hdmi-audio-codec", -1, NULL, 0);
+       if (IS_ERR(codec_dev)) {
+               dev_err(&pdev->dev, "failed to register HDMI audio codec\n");
+               ret = PTR_ERR(codec_dev);
+               goto end;
+       }
+
+       card->dev = &pdev->dev;
+       card->dai_link->cpu_dai_name = dev_name(&hdmi_pdev->dev);
+
+       ret = snd_soc_register_card(card);
+       if (ret) {
+               dev_err(&pdev->dev, "failed to register card: %d\n", ret);
+               goto err_card;
+       }
+
+       goto end;
+
+err_card:
+       platform_device_unregister(codec_dev);
+end:
+       if (hdmi_np)
+               of_node_put(hdmi_np);
+
+       return ret;
+}
+
+static int imx_hdmi_audio_remove(struct platform_device *pdev)
+{
+       struct snd_soc_card *card = &snd_soc_card_imx_hdmi;
+
+       platform_device_unregister(codec_dev);
+       snd_soc_unregister_card(card);
+
+       return 0;
+}
+
+static const struct of_device_id imx_hdmi_dt_ids[] = {
+       { .compatible = "fsl,imx-audio-hdmi", },
+       { /* sentinel */ }
+};
+MODULE_DEVICE_TABLE(of, imx_hdmi_dt_ids);
+
+static struct platform_driver imx_hdmi_audio_driver = {
+       .probe = imx_hdmi_audio_probe,
+       .remove = imx_hdmi_audio_remove,
+       .driver = {
+               .of_match_table = imx_hdmi_dt_ids,
+               .name = "imx-audio-hdmi",
+               .owner = THIS_MODULE,
+       },
+};
+
+module_platform_driver(imx_hdmi_audio_driver);
+
+MODULE_AUTHOR("Freescale Semiconductor, Inc.");
+MODULE_DESCRIPTION("IMX HDMI TX ASoC driver");
+MODULE_LICENSE("GPL");
+MODULE_ALIAS("platform:imx-audio-hdmi");