ASoC: tda998x: add a codec to the HDMI transmitter
Subsystems (5)
v8 cover ASoC: tda998x: add a codec to the HDMI transmitter
The NXP TDA998x HDMI transmitter may transmit audio to the HDMI link from 2 different sources, I2S and S/PDIF.
This patch set first adds an interface between a HDMI transmitter and the HDMI CODEC.
The interface is then used by the TDA998x driver to describe its audio capabilities (DAIs), to give the audio constraints of the HDMI device (EDID) to the audio subsystem, and to connect the chosen audio source to the HDMI link.
v8:
- change some comments about the patches
v7:
- remove the change of the K predivider (Jyri Sarha)
- add S24_3LE and S32_LE as possible audio formats (Jyri Sarha)
- don't move the struct priv2 definition and use the slave encoder private data as the device private data (Russell King)
- remove the useless request_module (Russell King/Mark Brown)
- don't lock the HDMI module (Russell King)
- use platform_device_unregister to remove the codec (Russell King)
v6:
- extend the HDMI CODEC instead of using a specific CODEC
v5:
- use the TDA998x private data instead of a specific area for the CODEC interface
- the CODEC is TDA998x specific (Mark Brown)
v4:
- remove all the TDA998x specific stuff from the CODEC
- move the EDID scan from the CODEC to the TDA998x
- move the CODEC to sound/soc (Mark Brown)
- update the audio_sample_rate from the EDID (Andrew Jackson)
v3: fix bad rate (Andrew Jackson)
v2: check double stream start (Mark Brown)
Jean-Francois Moine (2):
ASoC: hdmi: Add a transmitter interface to the HDMI CODEC drm/i2c: tda998x: Use the HDMI audio CODEC interface
.../devicetree/bindings/drm/i2c/tda998x.txt | 18 ++ drivers/gpu/drm/i2c/Kconfig | 1 + drivers/gpu/drm/i2c/tda998x_drv.c | 264 ++++++++++++++++++++- include/sound/hdmi.h | 20 ++ sound/soc/codecs/hdmi.c | 176 +++++++++++++- 5 files changed, 460 insertions(+), 19 deletions(-) create mode 100644 include/sound/hdmi.h
Signature · 1 line
2.1.1
PATCH v8 1/2 ASoC: hdmi: Add a transmitter interface to the HDMI CODEC
Audio in HDMI asks for:
- the audio constraints of the HDMI device to be known when choosing the audio routes in the audio subsystem, and
- the HDMI transmitter to know which of its audio inputs has been chosen when audio streaming starts.
This patch adds the interface between a HDMI transmitter and the HDMI CODEC.
At startup time, the HDMI transmitter device creates the HDMI device as a child device giving a description of its DAIs and 2 callback functions, these functions realizing the HDMI audio requirements.
--- include/sound/hdmi.h | 20 ++++++ sound/soc/codecs/hdmi.c | 176 ++++++++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 190 insertions(+), 6 deletions(-) create mode 100644 include/sound/hdmi.h
include/sound/hdmi.h new file +20 -0
@@ -0,0 +1,20 @@ +#ifndef SND_HDMI_H +#define SND_HDMI_H + +#include <sound/soc.h> + +/* platform_data */ +struct hdmi_data { +int (*get_audio)(struct device *dev, +int *max_channels, +int *rate_mask, +int *fmt); +void (*audio_switch)(struct device *dev, +int port_index, +unsigned sample_rate, +int sample_format); +int ndais; +struct snd_soc_dai_driver *dais; +struct snd_soc_codec_driver *driver; +}; +#endif
sound/soc/codecs/hdmi.c +170 -6
200 lines not on this page · raw message
Signature · 1 line
2.1.1
Mark Brown
maintainerRe: [PATCH v8 1/2] ASoC: hdmi: Add a transmitter interface to the HDMI CODEC
include/sound/hdmi.h line 15
Quoted 9 lines · Jean-Francois Moine
include/sound/hdmi.h new file +9
-0+struct hdmi_data { +int (*get_audio)(struct device *dev, +int *max_channels, +int *rate_mask, +int *fmt); +void (*audio_switch)(struct device *dev, +int port_index, +unsigned sample_rate, +int sample_format);
I can't really tell from these function names what these functions are supposed to do. I think get_audio() should be get_audio_caps() or similar since it reads the capabilities and audio_switch() is supposed to be set_audio_params() or similar to set the settings for the running stream.
sound/soc/codecs/hdmi.c line 96
Quoted 13 lines
sound/soc/codecs/hdmi.c +13
-0+snd_pcm_hw_constraint_list (runtime,0 , +SNDRV_PCM_HW_PARAM_RATE , + rate_constraints); + + formats =0 ; +if (fmt &1 ) + formats |=SNDRV_PCM_FMTBIT_S16_LE ; +if (fmt &2 ) + formats |=SNDRV_PCM_FMTBIT_S20_3LE ; +if (fmt &4 ) + formats |=SNDRV_PCM_FMTBIT_S24_LE | +SNDRV_PCM_FMTBIT_S24_3LE | +SNDRV_PCM_FMTBIT_S32_LE ;
Magic numbers here - can't we have some constants defined?
sound/soc/codecs/hdmi.c line 121
Quoted 3 lines
sound/soc/codecs/hdmi.c +3
-0+ priv->hdmi_data.audio_switch (dai->dev, dai->id, +params_rate (params), +params_format (params));
I'd be happier if this were able to return an error; even if the constraints are satisfied perhaps something changed or some operation fails for some reason.
sound/soc/codecs/hdmi.c line 137
Quoted 13 lines
sound/soc/codecs/hdmi.c +13
-0+static void hdmi_shutdown (struct snd_pcm_substream *substream, +struct snd_soc_dai *dai) +{ +struct device *cdev; +struct hdmi_priv *priv; + + cdev =hdmi_get_cdev (dai->dev); +if (!cdev) +return ; + priv =dev_get_drvdata (cdev); + + priv->hdmi_data.audio_switch (dai->dev,-1 ,0 ,0 );/* stop */ +}
So the set parameters operation has to support these magic values as being "off" - why not have an explicit shutdown operation here?
sound/soc/codecs/hdmi.c line 153
Quoted 9 lines
sound/soc/codecs/hdmi.c +9
-0+static int hdmi_codec_probe (struct snd_soc_codec *codec) +{ +struct hdmi_priv *priv; +struct device *dev = codec->dev;/* encoder device */ +struct device *cdev;/* codec device */ + + cdev =hdmi_get_cdev (dev); +if (!cdev) +return -ENODEV ;
This is (I think) only called for cases where the driver is being used from a parent device with ops but the name makes it sound like it should be called all the time so errors like that shouldn't happen. This should be clearer, or perhaps we should just have a separate device (perhaps rename the existing one to say that it's for a dumb device with no control?).
PATCH v8 2/2 drm/i2c: tda998x: Use the HDMI audio CODEC interface
In reply to Jean-Francois MoineThis patch adds the necessary functions to interface the HDMI audio CODEC.
--- .../devicetree/bindings/drm/i2c/tda998x.txt | 18 ++ drivers/gpu/drm/i2c/Kconfig | 1 + drivers/gpu/drm/i2c/tda998x_drv.c | 264 ++++++++++++++++++++- 3 files changed, 270 insertions(+), 13 deletions(-)
Documentation/devicetree/bindings/drm/i2c/tda998x.txt +18 -0
@@ -17,6 +17,20 @@ Optional properties: - video-ports: 24 bits value which defines how the video controller output is wired to the TDA998x input - default: <0x230145> + - audio-ports: must contain one or two values selecting the source + in the audio port. + The source type is given by the corresponding entry in + the audio-port-names property. + + - audio-port-names: must contain entries matching the entries in + the audio-ports property. + Each value may be "i2s" or "spdif", giving the type of + the audio source. + + - #sound-dai-cells: must be set to <1> for use with the simple-card. + The TDA998x audio CODEC always defines two DAIs. + The DAI 0 is the S/PDIF input and the DAI 1 is the I2S input. + Example: tda998x: hdmi-encoder {
@@ -26,4 +40,8 @@ Example: interrupts = <27 2>; /* falling edge */ pinctrl-0 = <&pmx_camera>; pinctrl-names = "default"; + + audio-ports = <0x04>, <0x03>; + audio-port-names = "spdif", "i2s"; + #sound-dai-cells = <1>; };
drivers/gpu/drm/i2c/Kconfig +1 -0
@@ -22,6 +22,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 help Support for NXP Semiconductors TDA998X HDMI encoders.
drivers/gpu/drm/i2c/tda998x_drv.c +251 -13
384 lines not on this page · raw message
Signature · 1 line
2.1.1
Mark Brown
maintainerQuoted 2 lines · Jean-Francois Moine
The NXP TDA998x HDMI transmitter may transmit audio to the HDMI link from 2 different sources, I2S and S/PDIF.
So, I'm not seeing *any* interest here from any other HDMI users. This is a continuing theme with HDMI patches and is really very concerning, everyone appears to be working in their own bubbles coming up with their own things and ignoring everyone else's work - what little review I'm seeing seems to be happening only after I explicitly prompt it. I'm following up to Jean-Francois' patches here but this isn't specific to them, it seems like a general thing with HDMI code.
This in turn makes me think there's some abstraction problems with what's going on and we're going to have to go through yet more refactorings to fix things up as we do manage to come up with better abstractions. What I'd really like to see as a bare minimum is some visible conversation about what we're doing and sign that people are at least keeping in mind generic solutions when working on HDMI code. Some commentary on the similarities and differences between hardware and which abstractions work with which devices would also be really helpful in working out if we're going in the right direction.
Basically at the minute I'm worried that we may be making the problems we've got here worse not better, I've not personally had the time to sit down and study the hardware sufficiently to form a firm impression myself which isn't helping.
Quoted 22 lines · Mark Brown
Quoted 2 lines · Jean-Francois Moine
The NXP TDA998x HDMI transmitter may transmit audio to the HDMI link from 2 different sources, I2S and S/PDIF.
So, I'm not seeing *any* interest here from any other HDMI users. This is a continuing theme with HDMI patches and is really very concerning, everyone appears to be working in their own bubbles coming up with their own things and ignoring everyone else's work - what little review I'm seeing seems to be happening only after I explicitly prompt it. I'm following up to Jean-Francois' patches here but this isn't specific to them, it seems like a general thing with HDMI code.
This in turn makes me think there's some abstraction problems with what's going on and we're going to have to go through yet more refactorings to fix things up as we do manage to come up with better abstractions. What I'd really like to see as a bare minimum is some visible conversation about what we're doing and sign that people are at least keeping in mind generic solutions when working on HDMI code. Some commentary on the similarities and differences between hardware and which abstractions work with which devices would also be really helpful in working out if we're going in the right direction.
Quoted 5 lines
Basically at the minute I'm worried that we may be making the problems we've got here worse not better, I've not personally had the time to sit down and study the hardware sufficiently to form a firm impression myself which isn't helping.
I have not seen any significant new development since v7 of these patches. My comments for v6 were mostly[1] addressed and I can live with these changes, even develop this approach further if it gets merged.
However, as a general note I see a need for a generic ASoC hdmi codec abstraction and I don't think this is generic enough. More of the audio specific implementation and HDMI standard specific things should be pushed away from the hdmi encoder driver (tda998x in this case) to the generic ASoC side hdmi codec driver (or library).
I am currently working on something that tries to be a generic solution that should be usable for different encoders and platforms, but unfortunately I have been busy with other things lately and have not been able to put anything working together yet. As soon as I have at least a bare bone API and and a proof of concept implementation working, I send RFC/POF patches out.
Best regards,
Jyri
[1] I personally do not like the hdmi_get_cdev() approach. I would rather go with only a library for registering from ASoC codec component under the HDMI encoder device or a completely separate device with only a reference to the HDMI encoder.
Mark Brown
maintainerQuoted 10 lines · Jyri Sarha
Quoted 4 lines · Mark Brown
So, I'm not seeing *any* interest here from any other HDMI users. This is a continuing theme with HDMI patches and is really very concerning, everyone appears to be working in their own bubbles coming up with their own things and ignoring everyone else's work - what little review I'm
I have not seen any significant new development since v7 of these patches. My comments for v6 were mostly[1] addressed and I can live with these changes, even develop this approach further if it gets merged.
OK, so this sort of feedback is really useful - even a qualified Reviwed-by is useful. Total silence could mean anything.
Quoted 5 lines
However, as a general note I see a need for a generic ASoC hdmi codec abstraction and I don't think this is generic enough. More of the audio specific implementation and HDMI standard specific things should be pushed away from the hdmi encoder driver (tda998x in this case) to the generic ASoC side hdmi codec driver (or library).
This is something I'm expecting, yes - what I don't have is a clear enough picture of how consistent the different hardware is in how it models these things.
Quoted 4 lines
[1] I personally do not like the
hdmi_get_cdev()approach. I would rather go with only a library for registering from ASoC codec component under the HDMI encoder device or a completely separate device with only a reference to the HDMI encoder.
It does seem somewhat complicated, yes. I don't know if matches idioms for DRM somehow?
Quoted 21 lines · Mark Brown
Quoted 10 lines · Jyri Sarha
Quoted 4 lines · Mark Brown
So, I'm not seeing *any* interest here from any other HDMI users. This is a continuing theme with HDMI patches and is really very concerning, everyone appears to be working in their own bubbles coming up with their own things and ignoring everyone else's work - what little review I'm
I have not seen any significant new development since v7 of these patches. My comments for v6 were mostly[1] addressed and I can live with these changes, even develop this approach further if it gets merged.
OK, so this sort of feedback is really useful - even a qualified Reviwed-by is useful. Total silence could mean anything.
Quoted 5 lines
However, as a general note I see a need for a generic ASoC hdmi codec abstraction and I don't think this is generic enough. More of the audio specific implementation and HDMI standard specific things should be pushed away from the hdmi encoder driver (tda998x in this case) to the generic ASoC side hdmi codec driver (or library).
Quoted 4 lines
This is something I'm expecting, yes - what I don't have is a clear enough picture of how consistent the different hardware is in how it models these things.
After taking another look the patchesthere is not much functionality that could be moved away from tda998x. It is just that the ASoC side (and tda998x) could do more in terms of HDMI standard, but that is fine because all that stuff can be added later if/when needed. However, instantiating snd_soc_dai_driver etc. in DRM side makes a nasty dependency between DRM and ASoC. All that stuff could be in ASoC side and simple enum/bitfield parameters defining i2s/spdif selection could be passed between DRM and ASoC side.
Quoted 8 lines
Quoted 4 lines
[1] I personally do not like the
hdmi_get_cdev()approach. I would rather go with only a library for registering from ASoC codec component under the HDMI encoder device or a completely separate device with only a reference to the HDMI encoder.It does seem somewhat complicated, yes. I don't know if matches idioms for DRM somehow?
Me neither. A more straight forward option would be adding an "audio header" to the beginning of hdmi encoders drvdata. However, it would be tempting to add a pointer for drvdata to snd_soc_dai_driver to add audio specific driver data to any device that provides a DAI in addition to other functionality. It could even simplify drivers for some audio only devices with multiple DAIs.
Best regards,
Jyri