Skip to contentSkip to conversation

dt-bindings: Document the dmas and dma-names properties for VC4 HDMI

PATCH Superseded Eric Anholt 3 participants 5 messages Feb 7, 2017 – Feb 24, 2017

Subsystems (6)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/3 dt-bindings: Document the dmas and dma-names properties for VC4 HDMI

From: Boris Brezillon <[email protected]>

These are optional, but necessary for HDMI audio support.

---
 Documentation/devicetree/bindings/display/brcm,bcm-vc4.txt | 3 +++
 1 file changed, 3 insertions(+)
Documentation/devicetree/bindings/display/brcm,bcm-vc4.txt +3 -0
index 34c7fddcea39..ca02d3e4db91 100644
@@ -34,6 +34,9 @@ Optional properties for HDMI:
 - hpd-gpios:	The GPIO pin for HDMI hotplug detect (if it doesn't appear
 		  as an interrupt/status bit in the HDMI controller
 		  itself).  See bindings/pinctrl/brcm,bcm2835-gpio.txt
+- dmas:		Should contain one entry pointing to the DMA channel used to
+		transfer audio data
+- dma-names:	Should contain "audio-rx"
 
 Required properties for DPI:
 - compatible:	Should be "brcm,bcm2835-dpi"
Signature · 1 line
2.11.0
#1 lore raw

PATCH 2/3 drm/vc4: Add HDMI audio support

The HDMI encoder IP embeds all needed blocks to output audio, with a custom DAI called MAI moving audio between the two parts of the HDMI core. This driver now exposes a sound card to let users stream audio to their display.

Using the hdmi-codec driver has been considered here, but MAI meant having to significantly rework hdmi-codec, and it would have left little shared code with the I2S mode anyway.

The encoder requires that the audio be SPDIF-formatted frames only, which alsalib will format-convert for us.

This patch is the combined work of Eric Anholt (initial register setup with a separate dmaengine driver and using simple-audio-card) and Boris Brezillon (moving it all into HDMI, massive debug to get it actually working), and which Eric has the permission to release.

---
 drivers/gpu/drm/vc4/Kconfig    |   4 +
 drivers/gpu/drm/vc4/vc4_hdmi.c | 494 ++++++++++++++++++++++++++++++++++++++++-
 drivers/gpu/drm/vc4/vc4_regs.h | 107 ++++++++-
 3 files changed, 603 insertions(+), 2 deletions(-)
drivers/gpu/drm/vc4/Kconfig +4 -0
index e1517d07cb7d..973b4203c0b2 100644
@@ -2,11 +2,15 @@ config DRM_VC4
 	tristate "Broadcom VC4 Graphics"
 	depends on ARCH_BCM2835 || COMPILE_TEST
 	depends on DRM
+	depends on SND && SND_SOC
 	depends on COMMON_CLK
 	select DRM_KMS_HELPER
 	select DRM_KMS_CMA_HELPER
 	select DRM_GEM_CMA_HELPER
 	select DRM_PANEL
+	select SND_PCM
+	select SND_PCM_ELD
+	select SND_SOC_GENERIC_DMAENGINE_PCM
 	select DRM_MIPI_DSI
 	help
 	  Choose this option if you have a system that has a Broadcom
drivers/gpu/drm/vc4/vc4_hdmi.c +493 -1

565 lines not on this page · raw message

drivers/gpu/drm/vc4/vc4_regs.h +106 -1

130 lines not on this page · raw message

Signature · 1 line
2.11.0
#2 lore raw

Re: [PATCH 2/3] drm/vc4: Add HDMI audio support

Hi Eric,

Quoted 47 lines · On Tue, 7 Feb 2017 13:07:02 -0800 Eric Anholt <[email protected]> wrote:
drivers/gpu/drm/vc4/vc4_hdmi.c +47 -0
+static int vc4_hdmi_audio_init(struct vc4_hdmi *hdmi)
+{
+	struct snd_soc_dai_link *dai_link = &hdmi->audio.link;
+	struct snd_soc_card *card = &hdmi->audio.card;
+	struct device *dev = &hdmi->pdev->dev;
+	const __be32 *addr;
+	int ret;
+
+	if (!of_find_property(dev->of_node, "dmas", NULL)) {
+		dev_warn(dev,
+			 "'dmas' DT property is missing, no HDMI audio\n");
+		return 0;
+	}
+
+	/*
+	 * Get the physical address of VC4_HD_MAI_DATA. We need to retrieve
+	 * the bus address specified in the DT, because the physical address
+	 * (the one returned by platform_get_resource()) is not appropriate
+	 * for DMA transfers.
+	 * This VC/MMU should probably be exposed to avoid this kind of hacks.
+	 */
+	addr = of_get_address(dev->of_node, 1, NULL, NULL);
+	hdmi->audio.dma_data.addr = be32_to_cpup(addr) + VC4_HD_MAI_DATA;
+	hdmi->audio.dma_data.addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES;
+	hdmi->audio.dma_data.maxburst = 2;
+
+	ret = devm_snd_dmaengine_pcm_register(dev, &pcm_conf, 0);
+	if (ret) {
+		dev_err(dev, "Could not register PCM component: %d\n", ret);
+		return ret;
+	}
+
+	ret = devm_snd_soc_register_component(dev, &vc4_hdmi_audio_cpu_dai_comp,
+					      &vc4_hdmi_audio_cpu_dai_drv, 1);
+	if (ret) {
+		dev_err(dev, "Could not register CPU DAI: %d\n", ret);
+		return ret;
+	}
+
+	/* register codec and codec dai */
+	ret = snd_soc_register_codec(dev, &vc4_hdmi_audio_codec_drv,
+				     &vc4_hdmi_audio_codec_dai_drv, 1);
+	if (ret) {
+		dev_err(dev, "Could not register codec: %d\n", ret);
+		return ret;
+	}
+

drivers/gpu/drm/vc4/vc4_hdmi.c static const struct drm_encoder_helper_funcs vc4_hdmi_encoder_helper_funcs = { · line 1041

Quoted 10 lines
drivers/gpu/drm/vc4/vc4_hdmi.c +10 -0
+	dai_link->name = "MAI";
+	dai_link->stream_name = "MAI PCM";
+	dai_link->codec_dai_name = vc4_hdmi_audio_codec_dai_drv.name;
+	dai_link->cpu_dai_name = dev_name(dev);
+	dai_link->codec_name = dev_name(dev);
+	dai_link->platform_name = dev_name(dev);
+
+	card->dai_link = dai_link;
+	card->num_links = 1;
+	card->name = "vc4-hdmi-audio";

I know I'm the one who chose this name, but maybe we should just change it for "vc4-hdmi", since audio is kind of implied here ;-).

#3 lore raw

PATCH 3/3 ARM: dts: bcm283x: Add HDMI audio related properties

In reply to Eric Anholt

From: Boris Brezillon <[email protected]>

Add the dmas and dma-names properties to support HDMI audio.

---
 arch/arm/boot/dts/bcm283x.dtsi | 2 ++
 1 file changed, 2 insertions(+)
arch/arm/boot/dts/bcm283x.dtsi +2 -0
index 9a44da190897..48a055d3f25e 100644
@@ -491,6 +491,8 @@
 			clocks = <&clocks BCM2835_PLLH_PIX>,
 				 <&clocks BCM2835_CLOCK_HSM>;
 			clock-names = "pixel", "hdmi";
+			dmas = <&dma 17>;
+			dma-names = "audio-rx";
 			status = "disabled";
 		};
 
Signature · 1 line
2.11.0
maintainer Acked-by on v1 1/3
#4 lore raw
In reply to Eric Anholt
Quoted 9 lines · Eric Anholt

From: Boris Brezillon <boris.brezillon-wi1+55ScJUtKEb57/[email protected]>

These are optional, but necessary for HDMI audio support.

---
 Documentation/devicetree/bindings/display/brcm,bcm-vc4.txt | 3 +++
 1 file changed, 3 insertions(+)

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html