Skip to contentSkip to conversation

Implement generic ASoC HDMI codec and use it in tda998x

RFC PATCH Superseded Jyri Sarha 6 participants 21 messages Aug 14, 2015 – Aug 17, 2015 4 messages not in the archive

Subsystems (5)

v3 of 9 Superseded Latest is v9 →

lore
Share & tools
lore

Jyri Sarha

author
#0 lore raw

v3 cover Implement generic ASoC HDMI codec and use it in tda998x

This is my third RFC patch series on the subject. This time also the tda998x driver patches are a serious attempt to come up with an initial implementation for HDMI audio ASoC support.

Russell's "drm/edid: add function to help find SADs" is here just to produce a working patch-set on top of mainline. It should be getting in trough drm-next at some point.

The binding for tda998x is taken from Jean Francois' patch series[1] on the same subject. The implementation of the of-node parsing has some minor changes from my self.

Here is what I think at least could or should still be done, but non of that stuff does not sounds critical right now.

Missing from tda998x driver side
- hdmi_codec_ops audio_startup() implementation for audio abort support
- multi channel audio support (I would need specs and preferably some HW to test for this).

Missing from ASoC side generic implementation:
- channel_allocation handling is completely left for the video side driver, see if ASoC side could help in any way
- snd_soc_jack functionality to handle hdmi cable plug/unplug events

[1] http://mailman.alsa-project.org/pipermail/alsa-devel/2015-July/095596.html

Best regards,
Jyri

Jean-Francois Moine (1):
drm/i2c: tda998x: Add support of a DT graph of ports

Jyri Sarha (5):
ASoC: hdmi: Remove obsolete dummy HDMI codec
ASoC: hdmi-codec: Add hdmi-codec for external HDMI-encoders drm/i2c: tda998x: Remove include/sound/tda998x.h and fix graph parsing drm/i2c: tda998x: Register ASoC HDMI codec for audio functionality
ARM: dts: am335x-boneblack: Add HDMI audio support

Russell King - ARM Linux (1):
drm/edid: add function to help find SADs, DO NOT MERGE

 .../devicetree/bindings/drm/i2c/tda998x.txt        |  51 +++
 arch/arm/boot/dts/am335x-boneblack.dts             |  90 +++-
 drivers/gpu/drm/i2c/Kconfig                        |   1 +
 drivers/gpu/drm/i2c/tda998x_drv.c                  | 336 +++++++++++++--
 include/drm/drm_edid.h                             |  19 +
 include/sound/hdmi-codec.h                         |  99 +++++
 sound/soc/codecs/Kconfig                           |   3 +-
 sound/soc/codecs/Makefile                          |   4 +-
 sound/soc/codecs/hdmi-codec.c                      | 467 +++++++++++++++++++++
 sound/soc/codecs/hdmi.c                            | 109 -----
 10 files changed, 1026 insertions(+), 153 deletions(-)
 create mode 100644 include/sound/hdmi-codec.h
 create mode 100644 sound/soc/codecs/hdmi-codec.c
 delete mode 100644 sound/soc/codecs/hdmi.c
Signature · 1 line
1.9.1
author
#1 lore raw

RFC PATCH v3 1/7 drm/edid: add function to help find SADs, DO NOT MERGE

From: Russell King - ARM Linux <[email protected]>

Add a function to find the start of the SADs in the ELD. This complements the helper to retrieve the SAD count.

This should already be coming in from drm-next.

---
 include/drm/drm_edid.h | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)
include/drm/drm_edid.h +19 -0
index 7990501..53c53c4 100644
@@ -348,6 +348,25 @@ static inline int drm_eld_mnl(const uint8_t *eld)
 }
 
 /**
+ * drm_eld_sad - Get ELD SAD structures.
+ * @eld: pointer to an eld memory structure with sad_count set
+ */
+static inline const uint8_t *drm_eld_sad(const uint8_t *eld)
+{
+	unsigned int ver, mnl;
+
+	ver = (eld[DRM_ELD_VER] & DRM_ELD_VER_MASK) >> DRM_ELD_VER_SHIFT;
+	if (ver != 2 && ver != 31)
+		return NULL;
+
+	mnl = drm_eld_mnl(eld);
+	if (mnl > 16)
+		return NULL;
+
+	return eld + DRM_ELD_CEA_SAD(mnl, 0);
+}
+
+/**
  * drm_eld_sad_count - Get ELD SAD count.
  * @eld: pointer to an eld memory structure with sad_count set
  */
Signature · 1 line
1.9.1

A message that is not in the archive (sent off-list or not yet received): [email protected]

#3 lore raw

RFC PATCH v3 2/7 ASoC: hdmi: Remove obsolete dummy HDMI codec

The hdmi stub codec has not been used since refactoring of OMAP HDMI audio support.

---
 sound/soc/codecs/Kconfig  |   4 --
 sound/soc/codecs/Makefile |   2 -
 sound/soc/codecs/hdmi.c   | 109 ----------------------------------------------
 3 files changed, 115 deletions(-)
 delete mode 100644 sound/soc/codecs/hdmi.c
sound/soc/codecs/Kconfig +0 -4
index efaafce..fc8e729 100644
@@ -76,7 +76,6 @@ config SND_SOC_ALL_CODECS
 	select SND_SOC_MAX9877 if I2C
 	select SND_SOC_MC13783 if MFD_MC13XXX
 	select SND_SOC_ML26124 if I2C
-	select SND_SOC_HDMI_CODEC
 	select SND_SOC_PCM1681 if I2C
 	select SND_SOC_PCM1792A if SPI_MASTER
 	select SND_SOC_PCM3008
@@ -432,9 +431,6 @@ config SND_SOC_BT_SCO
 config SND_SOC_DMIC
 	tristate
 
-config SND_SOC_HDMI_CODEC
-       tristate "HDMI stub CODEC"
-
 config SND_SOC_ES8328
 	tristate "Everest Semi ES8328 CODEC"
 
sound/soc/codecs/Makefile +0 -2
index cf160d9..01b4601 100644
@@ -69,7 +69,6 @@ snd-soc-max98925-objs := max98925.o
 snd-soc-max9850-objs := max9850.o
 snd-soc-mc13783-objs := mc13783.o
 snd-soc-ml26124-objs := ml26124.o
-snd-soc-hdmi-codec-objs := hdmi.o
 snd-soc-pcm1681-objs := pcm1681.o
 snd-soc-pcm1792a-codec-objs := pcm1792a.o
 snd-soc-pcm3008-objs := pcm3008.o
@@ -256,7 +255,6 @@ obj-$(CONFIG_SND_SOC_MAX98925)	+= snd-soc-max98925.o
 obj-$(CONFIG_SND_SOC_MAX9850)	+= snd-soc-max9850.o
 obj-$(CONFIG_SND_SOC_MC13783)	+= snd-soc-mc13783.o
 obj-$(CONFIG_SND_SOC_ML26124)	+= snd-soc-ml26124.o
-obj-$(CONFIG_SND_SOC_HDMI_CODEC) += snd-soc-hdmi-codec.o
 obj-$(CONFIG_SND_SOC_PCM1681)	+= snd-soc-pcm1681.o
 obj-$(CONFIG_SND_SOC_PCM1792A)	+= snd-soc-pcm1792a-codec.o
 obj-$(CONFIG_SND_SOC_PCM3008)	+= snd-soc-pcm3008.o
sound/soc/codecs/hdmi.c deleted +0 -109

109 lines not on this page · raw message

Signature · 6 lines
1.9.1

--
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

A message that is not in the archive (sent off-list or not yet received): 360a38c83ae2a24620da85b8496b745326d995de.1439542916.git.jsarha-l0cyMroinI0@public.gmane.org

#5 lore raw

Re: [PATCH RFC v3 2/7] ASoC: hdmi: Remove obsolete dummy HDMI codec

Quoted 2 lines · Jyri Sarha

The hdmi stub codec has not been used since refactoring of OMAP HDMI audio support.

grep tells me that the OMAP HDMI4 and HDMI5 drivers are still registering this device in -next...

author
#6 lore raw

Re: [PATCH RFC v3 2/7] ASoC: hdmi: Remove obsolete dummy HDMI codec

Quoted 7 lines · Mark Brown
Quoted 2 lines · Jyri Sarha

The hdmi stub codec has not been used since refactoring of OMAP HDMI audio support.

grep tells me that the OMAP HDMI4 and HDMI5 drivers are still registering this device in -next...

Really? My source trees for mainline and linux-next look like this:

$ git grep "hdmi-audio-codec"
sound/soc/codecs/hdmi.c:#define DRV_NAME "hdmi-audio-codec"

Don't you mean "omap-hdmi-audio", that is implemented in sound/soc/omap/omap-hdmi-audio.c ?

That driver is bit different. It implements ASoC card and uses generic dummy codec. The "hdmi-audio-codec" has not been used for OMAP HDMI audio for several releases already.

Best regards,
Jyri

maintainer
#7 lore raw

Re: [PATCH RFC v3 2/7] ASoC: hdmi: Remove obsolete dummy HDMI codec

Quoted 8 lines · Jyri Sarha

On 08/14/15 19:10, Mark Brown wrote:

Don't you mean "omap-hdmi-audio", that is implemented in sound/soc/omap/omap-hdmi-audio.c ?

That driver is bit different. It implements ASoC card and uses generic dummy codec. The "hdmi-audio-codec" has not been used for OMAP HDMI audio for several releases already.

Possibly, yes, or I was on an old tree by mistake. It's definitely not used now like you say.

#8 lore raw

RFC PATCH v3 4/7 drm/i2c: tda998x: Add support of a DT graph of ports

In reply to a message not in the archive

From: Jean-Francois Moine <[email protected]>

Two kinds of ports may be declared in a DT graph of ports: video and audio. This patch accepts the port value from a video port as an alternative to the video-ports property.
It also accepts audio ports in the case the transmitter is not used as a slave encoder.
The new file include/sound/tda998x.h prepares to the definition of a tda998x CODEC.

---
 .../devicetree/bindings/drm/i2c/tda998x.txt        | 51 ++++++++++++
 drivers/gpu/drm/i2c/tda998x_drv.c                  | 90 +++++++++++++++++++---
 include/sound/tda998x.h                            |  8 ++
 3 files changed, 140 insertions(+), 9 deletions(-)
 create mode 100644 include/sound/tda998x.h
Documentation/devicetree/bindings/drm/i2c/tda998x.txt +51 -0
index e9e4bce..35f6a80 100644
@@ -16,6 +16,35 @@ Optional properties:
 
   - video-ports: 24 bits value which defines how the video controller
 	output is wired to the TDA998x input - default: <0x230145>
+	This property is not used when ports are defined.
+
+Optional nodes:
+
+  - port: up to three ports.
+	The ports are defined according to [1].
+
+    Video port.
+	There may be only one video port.
+	This one must contain the following property:
+
+	- port-type: must be "rgb"
+
+	and may contain the optional property:
+
+	- reg: 24 bits value which defines how the video controller
+		output is wired to the TDA998x input (video pins)
+		When absent, the default value is <0x230145>.
+
+    Audio ports.
+	There may be one or two audio ports.
+	These ones must contain the following properties:
+
+	- port-type: must be "i2s" or "spdif"
+
+	- reg: 8 bits value which defines how the audio controller
+		output is wired to the TDA998x input (audio pins)
+
+[1] Documentation/devicetree/bindings/graph.txt
 
 Example:
 
@@ -26,4 +55,26 @@ Example:
 		interrupts = <27 2>;		/* falling edge */
 		pinctrl-0 = <&pmx_camera>;
 		pinctrl-names = "default";
+
+		port@230145 {
+			port-type = "rgb";
+			reg = <0x230145>;
+			hdmi_0: endpoint {
+				remote-endpoint = <&lcd0_0>;
+			};
+		};
+		port@3 {			/* AP1 = I2S */
+			port-type = "i2s";
+			reg = <0x03>;
+			tda998x_i2s: endpoint {
+				remote-endpoint = <&audio1_i2s>;
+			};
+		};
+		port@4 {			 /* AP2 = S/PDIF */
+			port-type = "spdif";
+			reg = <0x04>;
+			tda998x_spdif: endpoint {
+				remote-endpoint = <&audio1_spdif1>;
+			};
+		};
 	};
drivers/gpu/drm/i2c/tda998x_drv.c +81 -9

123 lines not on this page · raw message

include/sound/tda998x.h new file +8 -0
new file mode 100644
index 0000000..bef1da7
@@ -0,0 +1,8 @@
+#ifndef SND_TDA998X_H
+#define SND_TDA998X_H
+
+struct tda998x_audio {
+	u8 ports[2];			/* AP value */
+	u8 port_types[2];		/* AFMT_xxx */
+};
+#endif
Signature · 6 lines
1.9.1

--
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
#9 lore raw

RFC PATCH v3 6/7 drm/i2c: tda998x: Register ASoC HDMI codec for audio functionality

In reply to a message not in the archive

Register ASoC HDMI codec for audio functionality. This is an initial ASoC audio implementation for tda998x driver and it does not use all the features provided by hdmi-codec.

HDMI audio info-frame and audio stream header is generated by the ASoC HDMI codec. The codec also applies constraints for available sample-rates.

Implementation of audio_startup for hdmi_codec_ops would enable tda998x driver to abort ongoing playback if the HDMI cable is unplugged or re-plugged to a device without audio capability.

---
 drivers/gpu/drm/i2c/Kconfig       |   1 +
 drivers/gpu/drm/i2c/tda998x_drv.c | 241 +++++++++++++++++++++++++++++++++-----
 2 files changed, 214 insertions(+), 28 deletions(-)
drivers/gpu/drm/i2c/Kconfig +1 -0
index 22c7ed6..088f278 100644
@@ -28,6 +28,7 @@ config DRM_I2C_SIL164
 config DRM_I2C_NXP_TDA998X
 	tristate "NXP Semiconductors TDA998X HDMI encoder"
 	default m if DRM_TILCDC
+	select SND_SOC_HDMI_CODEC if SND_SOC
 	help
 	  Support for NXP Semiconductors TDA998X HDMI encoders.
 
drivers/gpu/drm/i2c/tda998x_drv.c +213 -28

362 lines not on this page · raw message

Signature · 6 lines
1.9.1

--
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

A message that is not in the archive (sent off-list or not yet received): 1e8e3215caa932dab68de8576aee81f5e1008163.1439542916.git.jsarha-l0cyMroinI0@public.gmane.org

#11 lore raw

Re: [PATCH RFC v3 6/7] drm/i2c: tda998x: Register ASoC HDMI codec for audio functionality

Quoted 8 lines · Jyri Sarha
drivers/gpu/drm/i2c/tda998x_drv.c +8 -0
+static int tda998x_write_aif(struct tda998x_priv *priv,
+			     struct hdmi_audio_infoframe *cea)
+{
+	uint8_t buf[HDMI_INFOFRAME_SIZE(AUDIO)];
+	int len;
+
+	len = hdmi_audio_infoframe_pack(cea, buf, sizeof(buf));
+	if (len < 0) {

drivers/gpu/drm/i2c/tda998x_drv.c tda998x_write_aif(struct tda998x_priv *priv, struct tda998x_encoder_params *p) · line 661

Quoted 10 lines
drivers/gpu/drm/i2c/tda998x_drv.c +10 -0
+		dev_err(&priv->hdmi->dev,
+			"Failed to pack audio infoframe: %d\n", len);
+		return len;
+	}
+
+	/* Write the audio information packet */
+	tda998x_write_if(priv, DIP_IF_FLAGS_IF4, REG_IF4_HB0, buf, len);
+	return 0;
+}
+

I have such a function already queued up, but I can't push it out at the moment because of too many conflicts across all my DRM work. I'm waiting for after 4.3-rc1 before publishing anything from or accepting anything else into DRM branches.

Quoted 7 lines

static void
tda998x_write_avi(struct tda998x_priv *priv, struct drm_display_mode *mode) {

drivers/gpu/drm/i2c/tda998x_drv.c +0 -0
@@ -670,19 +691,24 @@ static void tda998x_audio_mute(struct tda998x_priv *priv, bool on)
 	}
 }
 

drivers/gpu/drm/i2c/tda998x_drv.c static void tda998x_audio_mute(struct tda998x_priv *priv, bool on) · line 701

Quoted 10 lines
drivers/gpu/drm/i2c/tda998x_drv.c +7 -2
-static void
+static int
 tda998x_configure_audio(struct tda998x_priv *priv,
-		struct drm_display_mode *mode, struct tda998x_encoder_params *p)
+			int mode_clock,
+			int ena_ap,
+			int dai_format,
+			int sample_width,
+			int sample_rate,
+			const u8 *status)

I don't think this is an improvement.

Quoted 6 lines
drivers/gpu/drm/i2c/tda998x_drv.c +6 -0
+static int tda998x_audio_get_eld(struct device *dev, uint8_t *buf, size_t len)
+{
+	struct tda998x_priv *priv = dev_get_drvdata(dev);
+	struct drm_mode_config *config = &priv->encoder->dev->mode_config;
+	struct drm_connector *connector;
+	int ret = -ENODEV;

drivers/gpu/drm/i2c/tda998x_drv.c static struct drm_encoder_slave_funcs tda998x_encoder_slave_funcs = { · line 1380

Quoted 10 lines
drivers/gpu/drm/i2c/tda998x_drv.c +10 -0
+
+	mutex_lock(&config.mutex);
+	list_for_each_entry(connector, &config->connector_list, head) {
+		if (priv->encoder == connector->encoder) {
+			memcpy(buf, connector->eld, 
+			       min(sizeof(connector->eld), len));
+			ret = 0;
+		}
+	}
+	mutex_unlock(&config.mutex);

Obviously untested. Should be config->mutex.

But in any case, when I kill the DRM slave encoder code in here, this becomes unnecessary.

Signature · 6 lines
FTTC broadband for 0.8mile line: currently at 10.5Mbps down 400kbps up
according to speedtest.net.
--
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
author
#12 lore raw

Re: [PATCH RFC v3 6/7] drm/i2c: tda998x: Register ASoC HDMI codec for audio functionality

Quoted 16 lines · Russell King - ARM Linux
Quoted 15 lines · Jyri Sarha
drivers/gpu/drm/i2c/tda998x_drv.c +15 -0
+static int tda998x_write_aif(struct tda998x_priv *priv,
+			     struct hdmi_audio_infoframe *cea)
+{
+	uint8_t buf[HDMI_INFOFRAME_SIZE(AUDIO)];
+	int len;
+
+	len = hdmi_audio_infoframe_pack(cea, buf, sizeof(buf));
+	if (len < 0) {
+		dev_err(&priv->hdmi->dev,
+			"Failed to pack audio infoframe: %d\n", len);
+		return len;
+	}
+
+	/* Write the audio information packet */
+	tda998x_write_if(priv, DIP_IF_FLAGS_IF4, REG_IF4_HB0, buf, len);
Quoted 9 lines

drivers/gpu/drm/i2c/tda998x_drv.c tda998x_write_aif(struct tda998x_priv *priv, struct tda998x_encoder_params *p) · line 661

Quoted 3 lines
drivers/gpu/drm/i2c/tda998x_drv.c +3 -0
+	return 0;
+}
+

I have such a function already queued up, but I can't push it out at the moment because of too many conflicts across all my DRM work. I'm waiting for after 4.3-rc1 before publishing anything from or accepting anything else into DRM branches.

Ok, is the code available some where? Could take a look so I can align my code to that.

Quoted 7 lines
Quoted 7 lines
  static void
  tda998x_write_avi(struct tda998x_priv *priv, struct drm_display_mode *mode)
  {
(quoted diff) +0 -0
@@ -670,19 +691,24 @@ static void tda998x_audio_mute(struct tda998x_priv *priv, bool on)
  	}
  }
 
Quoted 13 lines

drivers/gpu/drm/i2c/tda998x_drv.c static void tda998x_audio_mute(struct tda998x_priv *priv, bool on) · line 701

Quoted 10 lines
drivers/gpu/drm/i2c/tda998x_drv.c +7 -2
-static void
+static int
  tda998x_configure_audio(struct tda998x_priv *priv,
-		struct drm_display_mode *mode, struct tda998x_encoder_params *p)
+			int mode_clock,
+			int ena_ap,
+			int dai_format,
+			int sample_width,
+			int sample_rate,
+			const u8 *status)

I don't think this is an improvement.

Still it makes the function more generic and enables its usage in HDMI-codec API implementation. I'll try to make it look tidier.

Quoted 10 lines
Quoted 10 lines
drivers/gpu/drm/i2c/tda998x_drv.c +10 -0
+static int tda998x_audio_get_eld(struct device *dev, uint8_t *buf, size_t len)
+{
+	struct tda998x_priv *priv = dev_get_drvdata(dev);
+	struct drm_mode_config *config = &priv->encoder->dev->mode_config;
+	struct drm_connector *connector;
+	int ret = -ENODEV;
+
+	mutex_lock(&config.mutex);
+	list_for_each_entry(connector, &config->connector_list, head) {
+		if (priv->encoder == connector->encoder) {
Quoted 9 lines

drivers/gpu/drm/i2c/tda998x_drv.c static struct drm_encoder_slave_funcs tda998x_encoder_slave_funcs = { · line 1380

Quoted 6 lines
drivers/gpu/drm/i2c/tda998x_drv.c +6 -0
+			memcpy(buf, connector->eld,
+			       min(sizeof(connector->eld), len));
+			ret = 0;
+		}
+	}
+	mutex_unlock(&config.mutex);

Obviously untested. Should be config->mutex.

Sorry. Should never do these last minute changes. I must have been compiling and testing different code version. I first had this function using config->connection_mutex, but then - after reading the eld related code - found that mode_config mutex should be used instead.

Quoted 3 lines

But in any case, when I kill the DRM slave encoder code in here, this becomes unnecessary.

Ok, The information from ELD needs be passed to audio side constraints somehow. I'd love to see the code you have in queue.

Best regards,
Jyri

#13 lore raw

RFC PATCH v3 7/7 ARM: dts: am335x-boneblack: Add HDMI audio support

In reply to a message not in the archive

Add HDMI audio support. Adds mcasp0_pins, clk_mcasp0_fixed, clk_mcasp0, mcasp0, sound node, and updates the tda19988 node to follow the new binding.

---
 arch/arm/boot/dts/am335x-boneblack.dts | 90 ++++++++++++++++++++++++++++++++--
 1 file changed, 86 insertions(+), 4 deletions(-)
arch/arm/boot/dts/am335x-boneblack.dts +86 -4
index eadbba3..7d3e899 100644
@@ -64,6 +64,16 @@
 			0x1b0 0x03      /* xdma_event_intr0, OMAP_MUX_MODE3 | AM33XX_PIN_OUTPUT */
 		>;
 	};
+
+	mcasp0_pins: mcasp0_pins {
+		pinctrl-single,pins = <
+			0x1ac (PIN_INPUT_PULLUP | MUX_MODE0)	/* mcasp0_ahclkx.mcasp0_ahclkx */
+			0x19c (PIN_OUTPUT_PULLDOWN | MUX_MODE2) /* mcasp0_ahclkr.mcasp0_axr2 */
+			0x194 (PIN_OUTPUT_PULLUP | MUX_MODE0)	/* mcasp0_fsx.mcasp0_fsx */
+			0x190 (PIN_OUTPUT_PULLDOWN | MUX_MODE0)	/* mcasp0_aclkx.mcasp0_aclkx */
+			0x06c (PIN_OUTPUT_PULLDOWN | MUX_MODE7)	/* gpmc_a11.GPIO1_27 */
+		>;
+	};
 };
 
 &lcdc {
@@ -76,17 +86,89 @@
 };
 
 &i2c0 {
-	tda19988 {
+	tda19988: tda19988 {
 		compatible = "nxp,tda998x";
 		reg = <0x70>;
+
+		#sound-dai-cells = <0>;
+
 		pinctrl-names = "default", "off";
 		pinctrl-0 = <&nxp_hdmi_bonelt_pins>;
 		pinctrl-1 = <&nxp_hdmi_bonelt_off_pins>;
 
-		port {
-			hdmi_0: endpoint@0 {
-				remote-endpoint = <&lcdc_0>;
+		ports {
+			#address-cells = <1>; 
+			#size-cells = <0>;
+			port@0 {
+				port-type = "rgb";
+				reg = <0x230145>;
+				hdmi_0: endpoint@0 {
+					remote-endpoint = <&lcdc_0>;
+				};
 			};
+			port@1 {
+				port-type = "i2s";
+				reg = <0x03>;
+				tda19988_i2s: endpoint {
+					remote-endpoint = <&mcasp0_i2s>;
+				};
+			};
+		};
+	};
+};
+
+&rtc {
+	system-power-controller;
+};
+
+&mcasp0	{
+	#sound-dai-cells = <0>;
+	pinctrl-names = "default";
+	pinctrl-0 = <&mcasp0_pins>;
+	status = "okay";
+	op-mode = <0>;	/* MCASP_IIS_MODE */
+	tdm-slots = <2>;
+	serial-dir = <	/* 0: INACTIVE, 1: TX, 2: RX */
+			0 0 1 0
+		>;
+	tx-num-evt = <1>;
+	rx-num-evt = <1>;
+
+	port {
+		mcasp0_i2s: endpoint {
+			remote-endpoint = <&tda19988_i2s>;
+		};
+	};
+};
+
+/ {
+	clk_mcasp0_fixed: clk_mcasp0_fixed {
+		#clock-cells = <0>;
+		compatible = "fixed-clock";
+		clock-frequency = <24576000>;
+	};
+
+	clk_mcasp0: clk_mcasp0 {
+		#clock-cells = <0>;
+		compatible = "gpio-gate-clock";
+		clocks = <&clk_mcasp0_fixed>;
+		enable-gpios = <&gpio1 27 0>; /* BeagleBone Black Clk enable on GPIO1_27 */
+	};
+
+	sound {
+		compatible = "simple-audio-card";
+		simple-audio-card,name = "TI BeagleBone Black";
+		simple-audio-card,format = "i2s";
+		simple-audio-card,bitclock-master = <&dailink0_master>;
+		simple-audio-card,frame-master = <&dailink0_master>;
+
+		dailink0_master: simple-audio-card,cpu {
+			sound-dai = <&mcasp0>;
+			clocks = <&clk_mcasp0>;
+		};
+
+		simple-audio-card,codec {
+			sound-dai = <&tda19988>;
 		};
 	};
 };
Signature · 6 lines
1.9.1

--
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
author
#14 lore raw

RFC PATCH v3 3/7 ASoC: hdmi-codec: Add hdmi-codec for external HDMI-encoders

In reply to Jyri Sarha

The hdmi-codec is a platform device driver to be registered from drivers of external HDMI encoders with I2S and/or spdif interface. The driver in turn registers an ASoC codec for the HDMI encoder's audio functionality.

The structures and definitions in the API header are mostly redundant copies of similar structures in ASoC headers. This is on purpose to avoid direct dependencies to ASoC structures in video side driver.

---
 include/sound/hdmi-codec.h    |  99 +++++++++
 sound/soc/codecs/Kconfig      |   5 +
 sound/soc/codecs/Makefile     |   2 +
 sound/soc/codecs/hdmi-codec.c | 467 ++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 573 insertions(+)
 create mode 100644 include/sound/hdmi-codec.h
 create mode 100644 sound/soc/codecs/hdmi-codec.c
include/sound/hdmi-codec.h new file +99 -0
new file mode 100644
index 0000000..b8a90f7
@@ -0,0 +1,99 @@
+/*
+ * hdmi-codec.h - HDMI Codec driver API
+ *
+ * Copyright (C) 2014 Texas Instruments Incorporated - http://www.ti.com
+ *
+ * Author: Jyri Sarha <[email protected]>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * version 2 as published by the Free Software Foundation.
+ *
+ * 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.
+ */
+
+#ifndef __HDMI_CODEC_H__
+#define __HDMI_CODEC_H__
+
+#include <linux/hdmi.h>
+#include <drm/drm_edid.h>
+#include <sound/asoundef.h>
+#include <uapi/sound/asound.h>
+
+/*
+ * Protocol between ASoC cpu-dai and HDMI-encoder
+ */
+struct hdmi_codec_daifmt {
+	enum {
+		HDMI_I2S,
+		HDMI_RIGHT_J,
+		HDMI_LEFT_J,
+		HDMI_DSP_A,
+		HDMI_DSP_B,
+		HDMI_AC97,
+		HDMI_SPDIF,
+	} fmt;
+	int bit_clk_inv:1;
+	int frame_clk_inv:1;
+	int bit_clk_master:1;
+	int frame_clk_master:1;
+};
+
+/*
+ * HDMI audio parameters
+ */
+struct hdmi_codec_params {
+	struct hdmi_audio_infoframe cea;
+	struct snd_aes_iec958 iec;
+	int sample_rate;
+	int sample_width;
+	int channels;
+};
+
+struct hdmi_codec_ops {
+	/* For runtime clock configuration from ASoC machine driver.
+	 * A direct forward from set_sysclk in struct snd_soc_dai_ops.
+	 * Optional */
+	int (*set_clk)(struct device *dev, int clk_id, int freq);
+
+	/* Called when ASoC starts an audio stream setup. The call
+	 * provides an audio abort callback for stoping an ongoing
+	 * stream if the HDMI audio becomes unavailable.
+	 * Optional */
+	int (*audio_startup)(struct device *dev,
+			     void (*abort_cb)(struct device *dev));
+
+	/* Configures HDMI-encoder for audio stream.
+	 * Mandatory */
+	int (*hw_params)(struct device *dev,
+			 struct hdmi_codec_daifmt *fmt,
+			 struct hdmi_codec_params *hparms);
+
+	/* Shuts down the audio stream.
+	 * Mandatory */
+	void (*audio_shutdown)(struct device *dev);
+
+	/* Mute/unmute HDMI audio stream.
+	 * Optional */
+	int (*digital_mute)(struct device *dev, bool enable);
+
+	/* Provides EDID-Like-Data from connected HDMI device.
+	 * Optional */
+	int (*get_eld)(struct device *dev, uint8_t *buf, size_t len);
+};
+
+/* HDMI codec initalization data */
+struct hdmi_codec_pdata {
+	struct device *dev; /* The HDMI encoder registering the codec */
+	const struct hdmi_codec_ops *ops;
+	uint i2s:1;
+	uint spdif:1;
+	int max_i2s_channels;
+};
+
+#define HDMI_CODEC_DRV_NAME "hdmi-audio-codec"
+
+#endif /* __HDMI_CODEC_H__ */
sound/soc/codecs/Kconfig +5 -0
index fc8e729..a5cc574 100644
@@ -76,6 +76,7 @@ config SND_SOC_ALL_CODECS
 	select SND_SOC_MAX9877 if I2C
 	select SND_SOC_MC13783 if MFD_MC13XXX
 	select SND_SOC_ML26124 if I2C
+	select SND_SOC_HDMI_CODEC
 	select SND_SOC_PCM1681 if I2C
 	select SND_SOC_PCM1792A if SPI_MASTER
 	select SND_SOC_PCM3008
@@ -431,6 +432,10 @@ config SND_SOC_BT_SCO
 config SND_SOC_DMIC
 	tristate
 
+config SND_SOC_HDMI_CODEC
+       tristate
+       select SND_PCM_ELD
+
 config SND_SOC_ES8328
 	tristate "Everest Semi ES8328 CODEC"
 
sound/soc/codecs/Makefile +2 -0
index 01b4601..0245e67 100644
@@ -69,6 +69,7 @@ snd-soc-max98925-objs := max98925.o
 snd-soc-max9850-objs := max9850.o
 snd-soc-mc13783-objs := mc13783.o
 snd-soc-ml26124-objs := ml26124.o
+snd-soc-hdmi-codec-objs := hdmi-codec.o
 snd-soc-pcm1681-objs := pcm1681.o
 snd-soc-pcm1792a-codec-objs := pcm1792a.o
 snd-soc-pcm3008-objs := pcm3008.o
@@ -255,6 +256,7 @@ obj-$(CONFIG_SND_SOC_MAX98925)	+= snd-soc-max98925.o
 obj-$(CONFIG_SND_SOC_MAX9850)	+= snd-soc-max9850.o
 obj-$(CONFIG_SND_SOC_MC13783)	+= snd-soc-mc13783.o
 obj-$(CONFIG_SND_SOC_ML26124)	+= snd-soc-ml26124.o
+obj-$(CONFIG_SND_SOC_HDMI_CODEC)	+= snd-soc-hdmi-codec.o
 obj-$(CONFIG_SND_SOC_PCM1681)	+= snd-soc-pcm1681.o
 obj-$(CONFIG_SND_SOC_PCM1792A)	+= snd-soc-pcm1792a-codec.o
 obj-$(CONFIG_SND_SOC_PCM3008)	+= snd-soc-pcm3008.o
sound/soc/codecs/hdmi-codec.c new file +467 -0

467 lines not on this page · raw message

Signature · 1 line
1.9.1
#15 lore raw

Re: [PATCH RFC v3 3/7] ASoC: hdmi-codec: Add hdmi-codec for external HDMI-encoders

sound/soc/codecs/hdmi-codec.c line 142

Quoted 7 lines · Jyri Sarha
sound/soc/codecs/hdmi-codec.c new file +7 -0
+static int hdmi_codec_hw_params(struct snd_pcm_substream *substream,
+				struct snd_pcm_hw_params *params,
+				struct snd_soc_dai *dai)
+{
+	struct hdmi_codec_priv *hcp = snd_soc_dai_get_drvdata(dai);
+	struct hdmi_codec_params hp = {
+		.cea = { 0 },

Unnecessary initialisation - because you are initialising this structure, all unnamed fields will be zeroed.

Quoted 7 lines
sound/soc/codecs/hdmi-codec.c new file +7 -0
+		.iec = {
+			.status = {
+				IEC958_AES0_CON_NOT_COPYRIGHT,
+				IEC958_AES1_CON_GENERAL,
+				IEC958_AES2_CON_SOURCE_UNSPEC,
+				IEC958_AES3_CON_CLOCK_VARIABLE,
+			},

...

sound/soc/codecs/hdmi-codec.c line 164

Quoted 2 lines
sound/soc/codecs/hdmi-codec.c new file +2 -0
+	hdmi_audio_infoframe_init(&hp.cea);
+	hp.cea.coding_type = HDMI_AUDIO_CODING_TYPE_PCM;

Something tells me here that you haven't read the HDMI specification. HDMI says that the coding type will be zero (refer to stream header). The same goes for much of the CEA audio infoframe. Please see the Audio InfoFrame details in the HDMI specification.

Quoted 9 lines
sound/soc/codecs/hdmi-codec.c new file +9 -0
+	hp.cea.channels = params_channels(params);
+
+	switch (params_width(params)) {
+	case 16:
+		hp.iec.status[4] |= IEC958_AES4_CON_WORDLEN_20_16;
+		hp.cea.sample_size = HDMI_AUDIO_SAMPLE_SIZE_16;
+		break;
+	case 18:
+		hp.iec.status[4] |= IEC958_AES4_CON_WORDLEN_22_18;

sound/soc/codecs/hdmi-codec.c line 183

Quoted 10 lines
sound/soc/codecs/hdmi-codec.c new file +10 -0
+		hp.cea.sample_size = HDMI_AUDIO_SAMPLE_SIZE_20;
+		break;
+	case 20:
+		hp.iec.status[4] |= IEC958_AES4_CON_WORDLEN_24_20;
+		hp.cea.sample_size = HDMI_AUDIO_SAMPLE_SIZE_20;
+		break;
+	case 24:
+	case 32:
+		hp.iec.status[4] |= IEC958_AES4_CON_MAX_WORDLEN_24 |
+			IEC958_AES4_CON_WORDLEN_24_20;

Why not use the generic code to generate the AES channel status bits? See sound/core/pcm_iec958.c.

Signature · 6 lines
FTTC broadband for 0.8mile line: currently at 10.5Mbps down 400kbps up
according to speedtest.net.
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
author
#16 lore raw

Re: [PATCH RFC v3 3/7] ASoC: hdmi-codec: Add hdmi-codec for external HDMI-encoders

Quoted 12 lines · Russell King - ARM Linux

sound/soc/codecs/hdmi-codec.c line 142

Quoted 7 lines · Jyri Sarha
sound/soc/codecs/hdmi-codec.c new file +7 -0
+static int hdmi_codec_hw_params(struct snd_pcm_substream *substream,
+				struct snd_pcm_hw_params *params,
+				struct snd_soc_dai *dai)
+{
+	struct hdmi_codec_priv *hcp = snd_soc_dai_get_drvdata(dai);
+	struct hdmi_codec_params hp = {
+		.cea = { 0 },

Unnecessary initialisation - because you are initialising this structure, all unnamed fields will be zeroed.

True, I just tried to be explicit.

Quoted 10 lines
Quoted 7 lines
sound/soc/codecs/hdmi-codec.c new file +7 -0
+		.iec = {
+			.status = {
+				IEC958_AES0_CON_NOT_COPYRIGHT,
+				IEC958_AES1_CON_GENERAL,
+				IEC958_AES2_CON_SOURCE_UNSPEC,
+				IEC958_AES3_CON_CLOCK_VARIABLE,
+			},

...

Quoted 8 lines

sound/soc/codecs/hdmi-codec.c line 164

Quoted 2 lines
sound/soc/codecs/hdmi-codec.c new file +2 -0
+	hdmi_audio_infoframe_init(&hp.cea);
+	hp.cea.coding_type = HDMI_AUDIO_CODING_TYPE_PCM;

Something tells me here that you haven't read the HDMI specification. HDMI says that the coding type will be zero (refer to stream header). The same goes for much of the CEA audio infoframe. Please see the Audio InfoFrame details in the HDMI specification.

Must admit, that I have not read it end to end. Obviously I have missed a relevant piece of information here. I'll fix that and check the related items too.

Quoted 14 lines
Quoted 14 lines
sound/soc/codecs/hdmi-codec.c new file +14 -0
+	hp.cea.channels = params_channels(params);
+
+	switch (params_width(params)) {
+	case 16:
+		hp.iec.status[4] |= IEC958_AES4_CON_WORDLEN_20_16;
+		hp.cea.sample_size = HDMI_AUDIO_SAMPLE_SIZE_16;
+		break;
+	case 18:
+		hp.iec.status[4] |= IEC958_AES4_CON_WORDLEN_22_18;
+		hp.cea.sample_size = HDMI_AUDIO_SAMPLE_SIZE_20;
+		break;
+	case 20:
+		hp.iec.status[4] |= IEC958_AES4_CON_WORDLEN_24_20;
+		hp.cea.sample_size = HDMI_AUDIO_SAMPLE_SIZE_20;
Quoted 9 lines

sound/soc/codecs/hdmi-codec.c line 183

Quoted 5 lines
sound/soc/codecs/hdmi-codec.c new file +5 -0
+		break;
+	case 24:
+	case 32:
+		hp.iec.status[4] |= IEC958_AES4_CON_MAX_WORDLEN_24 |
+			IEC958_AES4_CON_WORDLEN_24_20;

Why not use the generic code to generate the AES channel status bits? See sound/core/pcm_iec958.c.

Thanks, I did not know that exist. I'll make use of that.

Best regards,
Jyri

A message that is not in the archive (sent off-list or not yet received): ed41a6c0b594866c05e695cc066371d0e3862c7e.1439542916.git.jsarha-l0cyMroinI0@public.gmane.org

#18 lore raw

Re: [PATCH RFC v3 3/7] ASoC: hdmi-codec: Add hdmi-codec for external HDMI-encoders

include/sound/hdmi-codec.h line 60

Quoted 5 lines · Jyri Sarha
include/sound/hdmi-codec.h new file +5 -0
+struct hdmi_codec_ops {
+	/* For runtime clock configuration from ASoC machine driver.
+	 * A direct forward from set_sysclk in struct snd_soc_dai_ops.
+	 * Optional */
+	int (*set_clk)(struct device *dev, int clk_id, int freq);

I'd be much happier if we were using the clock API as the external interface here, it's where we want to be internally too and it's going to be easier to not introduce any external dependencies on the ASoC internal stuff.

include/sound/hdmi-codec.h line 67

Quoted 6 lines
include/sound/hdmi-codec.h new file +6 -0
+	/* Called when ASoC starts an audio stream setup. The call
+	 * provides an audio abort callback for stoping an ongoing
+	 * stream if the HDMI audio becomes unavailable.
+	 * Optional */
+	int (*audio_startup)(struct device *dev,
+			     void (*abort_cb)(struct device *dev));

I'm a bit confused about what is going to use abort_cb() and why they wouldn't just call shutdown instead?

include/sound/hdmi-codec.h line 90

Quoted 3 lines
include/sound/hdmi-codec.h new file +3 -0
+/* HDMI codec initalization data */
+struct hdmi_codec_pdata {
+	struct device *dev; /* The HDMI encoder registering the codec */

Shouldn't this just be dev->parent?

sound/soc/codecs/hdmi-codec.c line 47

Quoted 4 lines
sound/soc/codecs/hdmi-codec.c new file +4 -0
+enum {
+	DAI_ID_I2C = 0,
+	DAI_ID_SPDIF,
+};

I2C? :P

author
#19 lore raw

Re: [PATCH RFC v3 3/7] ASoC: hdmi-codec: Add hdmi-codec for external HDMI-encoders

Quoted 13 lines · Mark Brown

include/sound/hdmi-codec.h line 60

Quoted 5 lines · Jyri Sarha
include/sound/hdmi-codec.h new file +5 -0
+struct hdmi_codec_ops {
+	/* For runtime clock configuration from ASoC machine driver.
+	 * A direct forward from set_sysclk in struct snd_soc_dai_ops.
+	 * Optional */
+	int (*set_clk)(struct device *dev, int clk_id, int freq);

I'd be much happier if we were using the clock API as the external interface here, it's where we want to be internally too and it's going to be easier to not introduce any external dependencies on the ASoC internal stuff.

Sounds better. I'll change that.

Quoted 10 lines

include/sound/hdmi-codec.h line 67

Quoted 6 lines
include/sound/hdmi-codec.h new file +6 -0
+	/* Called when ASoC starts an audio stream setup. The call
+	 * provides an audio abort callback for stoping an ongoing
+	 * stream if the HDMI audio becomes unavailable.
+	 * Optional */
+	int (*audio_startup)(struct device *dev,
+			     void (*abort_cb)(struct device *dev));

I'm a bit confused about what is going to use abort_cb() and why they wouldn't just call shutdown instead?

audio_shutdown() is for ASoC side to tell video side that audio playback has stopped.

The abort_cb() is for video side to inform ASoC that current audio stream can not continue anymore and it should be aborted. The similar mechanism is currently in use in sound/soc/omap/omap-hdmi-audio.c.

Quoted 6 lines

include/sound/hdmi-codec.h line 90

Quoted 3 lines
include/sound/hdmi-codec.h new file +3 -0
+/* HDMI codec initalization data */
+struct hdmi_codec_pdata {
+	struct device *dev; /* The HDMI encoder registering the codec */

Shouldn't this just be dev->parent?

Quoted 7 lines

sound/soc/codecs/hdmi-codec.c line 47

Quoted 4 lines
sound/soc/codecs/hdmi-codec.c new file +4 -0
+enum {
+	DAI_ID_I2C = 0,
+	DAI_ID_SPDIF,
+};

I2C? :P

Right, should be I2S. Thanks!

Best regards,
Jyri

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel

maintainer
#20 lore raw

Re: [PATCH RFC v3 3/7] ASoC: hdmi-codec: Add hdmi-codec for external HDMI-encoders

Quoted 13 lines · Jyri Sarha
Quoted 11 lines · Mark Brown

include/sound/hdmi-codec.h line 67

Quoted 6 lines · Jyri Sarha
include/sound/hdmi-codec.h new file +6 -0
+	/* Called when ASoC starts an audio stream setup. The call
+	 * provides an audio abort callback for stoping an ongoing
+	 * stream if the HDMI audio becomes unavailable.
+	 * Optional */
+	int (*audio_startup)(struct device *dev,
+			     void (*abort_cb)(struct device *dev));

I'm a bit confused about what is going to use abort_cb() and why they wouldn't just call shutdown instead?

Quoted 6 lines

audio_shutdown() is for ASoC side to tell video side that audio playback has stopped.

The abort_cb() is for video side to inform ASoC that current audio stream can not continue anymore and it should be aborted. The similar mechanism is currently in use in sound/soc/omap/omap-hdmi-audio.c.

Someone reading the code needs to be able to understand this.

author
#21 lore raw

Re: [PATCH RFC v3 3/7] ASoC: hdmi-codec: Add hdmi-codec for external HDMI-encoders

Quoted 14 lines · Mark Brown
Quoted 12 lines · Jyri Sarha
Quoted 11 lines · Mark Brown

include/sound/hdmi-codec.h line 67

Quoted 6 lines · Jyri Sarha
include/sound/hdmi-codec.h new file +6 -0
+	/* Called when ASoC starts an audio stream setup. The call
+	 * provides an audio abort callback for stoping an ongoing
+	 * stream if the HDMI audio becomes unavailable.
+	 * Optional */
+	int (*audio_startup)(struct device *dev,
+			     void (*abort_cb)(struct device *dev));

I'm a bit confused about what is going to use abort_cb() and why they wouldn't just call shutdown instead?

Quoted 9 lines
Quoted 6 lines

audio_shutdown() is for ASoC side to tell video side that audio playback has stopped.

The abort_cb() is for video side to inform ASoC that current audio stream can not continue anymore and it should be aborted. The similar mechanism is currently in use in sound/soc/omap/omap-hdmi-audio.c.

Someone reading the code needs to be able to understand this.

Ok, I'll improve the comment above.

Thanks,
Jyri

author
#22 lore raw

Re: [PATCH RFC v3 3/7] ASoC: hdmi-codec: Add hdmi-codec for external HDMI-encoders

In reply to Mark Brown

Missed one commet first time around...

Quoted 1 line · Mark Brown

On Fri, Aug 14, 2015 at 12:30:41PM +0300, Jyri Sarha wrote:

...

Quoted 6 lines

include/sound/hdmi-codec.h line 90

Quoted 3 lines
include/sound/hdmi-codec.h new file +3 -0
+/* HDMI codec initalization data */
+struct hdmi_codec_pdata {
+	struct device *dev; /* The HDMI encoder registering the codec */

Shouldn't this just be dev->parent?

No. The HDMI encoder device is the parent for HDMI-codec.

The patch you took in in the last round uses the ASoC component drivers parent's of-node if the component driver does not have one itself. In this case the phandle in the binding points to the HDMI encoder's node, which is the parent of the HDMI codec.

Best regards,
Jyri

author
#23 lore raw

Re: [PATCH RFC v3 3/7] ASoC: hdmi-codec: Add hdmi-codec for external HDMI-encoders

Quoted 12 lines · Jyri Sarha

Missed one commet first time around...

Quoted 1 line · Mark Brown

On Fri, Aug 14, 2015 at 12:30:41PM +0300, Jyri Sarha wrote:

...

Quoted 6 lines

include/sound/hdmi-codec.h line 90

Quoted 3 lines
include/sound/hdmi-codec.h new file +3 -0
+/* HDMI codec initalization data */
+struct hdmi_codec_pdata {
+    struct device *dev; /* The HDMI encoder registering the codec */

Shouldn't this just be dev->parent?

Quoted 7 lines

No. The HDMI encoder device is the parent for HDMI-codec.

The patch you took in in the last round uses the ASoC component drivers parent's of-node if the component driver does not have one itself. In this case the phandle in the binding points to the HDMI encoder's node, which is the parent of the HDMI codec.

After reading the comment again I see now what you meant.

Yes, I can extract the encoder device from the dev->parent pointer. No need to have it in pdata.

Thanks,
Jyri

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel

author
#24 lore raw

RFC PATCH v3 5/7 drm/i2c: tda998x: Remove include/sound/tda998x.h and fix graph parsing

In reply to Jyri Sarha

Move struct tda998x_audio definition to tda998x_drv.c and remove include/sound/tda998x.h. There is no external use for struct tda998x_audio.

Fix graph parsing to allow ports to be inside a separate "ports"-node as specified in Documentation/devicetree/bindings/graph.txt.

---
 drivers/gpu/drm/i2c/tda998x_drv.c | 59 +++++++++++++++++++++------------------
 include/sound/tda998x.h           |  8 ------
 2 files changed, 32 insertions(+), 35 deletions(-)
 delete mode 100644 include/sound/tda998x.h
drivers/gpu/drm/i2c/tda998x_drv.c +32 -27
index 0952eac..4dc2dc0 100644
@@ -27,10 +27,14 @@
 #include <drm/drm_edid.h>
 #include <drm/drm_of.h>
 #include <drm/i2c/tda998x.h>
-#include <sound/tda998x.h>
 
 #define DBG(fmt, ...) DRM_DEBUG(fmt"\n", ##__VA_ARGS__)
 
+struct tda998x_audio {
+	u8 ports[2];			/* AP value */
+	u8 port_types[2];		/* AFMT_xxx */
+};
+
 struct tda998x_priv {
 	struct i2c_client *cec;
 	struct i2c_client *hdmi;
@@ -1240,9 +1244,10 @@ static int tda998x_parse_ports(struct tda998x_priv *priv,
 {
 	struct device_node *of_port;
 	const char *port_type;
-	int ret, audio_index, reg, afmt;
+	int ret, audio_index, reg, afmt, rgb_initialized;
 
 	audio_index = 0;
+	rgb_initialized = 0;
 	for_each_child_of_node(np, of_port) {
 		if (!of_port->name
 		 || of_node_cmp(of_port->name, "port") != 0)
@@ -1252,11 +1257,17 @@ static int tda998x_parse_ports(struct tda998x_priv *priv,
 		if (ret < 0)
 			continue;
 		ret = of_property_read_u32(of_port, "reg", &reg);
+		if (ret < 0) {
+			dev_err(&priv->hdmi->dev, "missing reg for %s\n",
+				port_type);
+			return ret;
+		}
 		if (strcmp(port_type, "rgb") == 0) {
 			if (!ret) {		/* video reg is optional */
 				priv->vip_cntrl_0 = reg >> 16;
 				priv->vip_cntrl_1 = reg >> 8;
 				priv->vip_cntrl_2 = reg;
+				rgb_initialized = 1;
 			}
 			continue;
 		}
@@ -1266,11 +1277,6 @@ static int tda998x_parse_ports(struct tda998x_priv *priv,
 			afmt = AFMT_SPDIF;
 		else
 			continue;
-		if (ret < 0) {
-			dev_err(&priv->hdmi->dev, "missing reg for %s\n",
-				port_type);
-			return ret;
-		}
 		if (audio_index >= ARRAY_SIZE(priv->audio.ports)) {
 			dev_err(&priv->hdmi->dev, "too many audio ports\n");
 			break;
@@ -1279,13 +1285,13 @@ static int tda998x_parse_ports(struct tda998x_priv *priv,
 		priv->audio.port_types[audio_index] = afmt;
 		audio_index++;
 	}
-	return 0;
+	return rgb_initialized;
 }
 
 static int tda998x_create(struct i2c_client *client, struct tda998x_priv *priv)
 {
 	struct device_node *np = client->dev.of_node;
-	struct device_node *of_port;
+	struct device_node *ports;
 	u32 video;
 	int rev_lo, rev_hi, ret;
 	unsigned short cec_addr;
@@ -1392,24 +1398,15 @@ static int tda998x_create(struct i2c_client *client, struct tda998x_priv *priv)
 
 	/* get the device tree parameters */
 	if (np) {
-		of_port = of_get_child_by_name(np, "port");
-		if (of_port) {				/* graph of ports */
-			of_node_put(of_port);
-			ret = tda998x_parse_ports(priv, np);
-			if (ret < 0)
-				goto fail;
-
-			/* initialize the default audio configuration */
-			if (priv->audio.ports[0]) {
-				priv->params.audio_cfg = priv->audio.ports[0];
-				priv->params.audio_format =
-						priv->audio.port_types[0];
-				priv->params.audio_clk_cfg =
-					priv->params.audio_format ==
-							AFMT_SPDIF ? 0 : 1;
-			}
-		} else {
-
+		ports = of_get_child_by_name(np, "ports");
+		if (!ports)
+			ports = of_node_get(np);
+		/* graph of ports */
+		ret = tda998x_parse_ports(priv, ports);
+		of_node_put(ports);
+		if (ret < 0)
+			goto fail;
+		if (ret == 0) {
 			/* optional video properties */
 			ret = of_property_read_u32(np, "video-ports", &video);
 			if (ret == 0) {
@@ -1418,6 +1415,14 @@ static int tda998x_create(struct i2c_client *client, struct tda998x_priv *priv)
 				priv->vip_cntrl_2 = video;
 			}
 		}
+		if (priv->audio.ports[0]) {
+			priv->params.audio_cfg = priv->audio.ports[0];
+			priv->params.audio_format =
+				priv->audio.port_types[0];
+			priv->params.audio_clk_cfg =
+				priv->params.audio_format ==
+				AFMT_SPDIF ? 0 : 1;
+		}
 	}
 
 	return 0;
include/sound/tda998x.h deleted +0 -8
deleted file mode 100644
index bef1da7..0000000
@@ -1,8 +0,0 @@
-#ifndef SND_TDA998X_H
-#define SND_TDA998X_H
-
-struct tda998x_audio {
-	u8 ports[2];			/* AP value */
-	u8 port_types[2];		/* AFMT_xxx */
-};
-#endif
Signature · 6 lines
1.9.1

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel