ASoC: tda998x: add a codec to the HDMI transmitter
Subsystems (3)
PATCH v3 1/1 ASoC: tda998x: add a codec to the HDMI transmitter
This patch adds a CODEC function to the NXP TDA998x HDMI transmitter.
The CODEC handles both I2S and S/PDIF input and does dynamic input switch in the TDA998x I2C driver on start/stop audio streaming.
---
v3: fix bad rate (Andrew Jackson)
v2: check double stream start (Mark Brown)
--- .../devicetree/bindings/drm/i2c/tda998x.txt | 13 ++ drivers/gpu/drm/i2c/Makefile | 2 +- drivers/gpu/drm/i2c/tda998x_codec.c | 247 +++++++++++++++++++++ drivers/gpu/drm/i2c/tda998x_drv.c | 74 ++++-- drivers/gpu/drm/i2c/tda998x_drv.h | 32 +++ include/drm/i2c/tda998x.h | 1 + 6 files changed, 348 insertions(+), 21 deletions(-) create mode 100644 drivers/gpu/drm/i2c/tda998x_codec.c create mode 100644 drivers/gpu/drm/i2c/tda998x_drv.h
Documentation/devicetree/bindings/drm/i2c/tda998x.txt +13 -0
@@ -15,6 +15,15 @@ Optional properties: - video-ports: 24 bits value which defines how the video controller output is wired to the TDA998x input - default: <0x230145> + - audio-ports: one or two values corresponding to entries in + the audio-port-names property. + + - audio-port-names: must contain "i2s", "spdif" entries + matching entries in the audio-ports property. + + - #sound-dai-cells: must be set to <1> for use with the simple-card. + The DAI 0 is the I2S input and the DAI 1 is the S/PDIF input. + Example: tda998x: hdmi-encoder {
@@ -24,4 +33,8 @@ Example: interrupts = <27 2>; /* falling edge */ pinctrl-0 = <&pmx_camera>; pinctrl-names = "default"; + + audio-ports = <0x03>, <0x04>; + audio-port-names = "i2s", "spdif"; + #sound-dai-cells = <1>; };
drivers/gpu/drm/i2c/Makefile +1 -1
@@ -6,5 +6,5 @@ obj-$(CONFIG_DRM_I2C_CH7006) += ch7006.o sil164-y := sil164_drv.o obj-$(CONFIG_DRM_I2C_SIL164) += sil164.o -tda998x-y := tda998x_drv.o +tda998x-y := tda998x_drv.o tda998x_codec.o obj-$(CONFIG_DRM_I2C_NXP_TDA998X) += tda998x.o
drivers/gpu/drm/i2c/tda998x_codec.c new file +247 -0
247 lines not on this page · raw message
drivers/gpu/drm/i2c/tda998x_drv.c +54 -20
149 lines not on this page · raw message
drivers/gpu/drm/i2c/tda998x_drv.h new file +32 -0
@@ -0,0 +1,32 @@ +/* tda998x private data */ + +struct tda998x_priv { +struct i2c_client *cec; +struct i2c_client *hdmi; +uint16_t rev; +uint8_t current_page; +int dpms; +bool is_hdmi_sink; +u8 vip_cntrl_0; +u8 vip_cntrl_1; +u8 vip_cntrl_2; +struct tda998x_encoder_params params; + +wait_queue_head_t wq_edid; +volatile int wq_edid_wait; +struct drm_encoder *encoder; + +u8 audio_ports[2 ]; +int audio_sample_format; +int dai_id;/* DAI ID when streaming active */ + +u8 *eld; + +struct snd_pcm_hw_constraint_list rate_constraints; +}; + +int tda998x_codec_register (struct device *dev); +void tda998x_codec_unregister (struct device *dev); + +void tda998x_audio_start (struct tda998x_priv *priv,int full); +void tda998x_audio_stop (struct tda998x_priv *priv);
include/drm/i2c/tda998x.h +1 -0
@@ -20,6 +20,7 @@ struct tda998x_encoder_params {u8 audio_frame[6 ];enum { +AFMT_NO_AUDIO =0 ,AFMT_SPDIF ,AFMT_I2S } audio_format;
Signature · 1 line
2.0.1
Quoted 7 lines · Jean-Francois Moine
This patch adds a CODEC function to the NXP TDA998x HDMI transmitter.
The CODEC handles both I2S and S/PDIF input and does dynamic input switch in the TDA998x I2C driver on start/stop audio streaming.
Signed-off-by Jean-Francois Moine <[email protected]>---
Shouldn't the patch also capture the current audio rate in tda998x_codec.c:tda_hw_params? Otherwise, when tda998x_drv.c:tda998x_audio_start invokes tda998x_drv.c:tda998x_configure_audio, the value of 'N' will be calculated incorrectly.
So something similar to:
drivers/gpu/drm/i2c/tda998x_codec.c +1 -0
@@ -111,6 +111,7 @@ static int tda_hw_params(struct snd_pcm_substream *substream,tda998x_audio_start (priv,0 );return 0 ; } + priv->params.audio_sample_rate =params_rate (params); priv->params.audio_format = dai->id; priv->audio_sample_format =params_format (params); params.audio_cfg =
Andrew
Quoted 6 lines · Jean-Francois Moine
.../devicetree/bindings/drm/i2c/tda998x.txt | 13 ++ drivers/gpu/drm/i2c/Makefile | 2 +- drivers/gpu/drm/i2c/tda998x_codec.c | 247 +++++++++++++++++++++ drivers/gpu/drm/i2c/tda998x_drv.c | 74 ++++-- drivers/gpu/drm/i2c/tda998x_drv.h | 32 +++ include/drm/i2c/tda998x.h | 1 +
I'd expect to see the ASoC parts of this appear under sound/soc (even if just a library that the DRM driver links against rather than as a MFD). This should help avoid cross tree issues and surprises when people do API changes.
Documentation/devicetree/bindings/drm/i2c/tda998x.txt Optional properties: · line 19
Quoted 2 lines
Documentation/devicetree/bindings/drm/i2c/tda998x.txt +2
-0+ - audio-ports: one or two values corresponding to entries in + the audio-port-names property.
What are these values?
Documentation/devicetree/bindings/drm/i2c/tda998x.txt Optional properties: · line 22
Quoted 2 lines
Documentation/devicetree/bindings/drm/i2c/tda998x.txt +2
-0+ - audio-port-names: must contain "i2s", "spdif" entries + matching entries in the audio-ports property.
So it's mandatory that both I2S and S/PDIF be specified?
The code looks broadly sensible in so far as it