ASoC: tda998x: add a codec to the HDMI transmitter
Subsystems (6)
v10 cover ASoC: tda998x: add a codec to the HDMI transmitter
Based on broonie/ASoC
v10:
- add the generic dt-card
- define the audio ports from a DT graph of ports (Russell King)
- reuse HDMI constants (Andrew Jackson - Jyri Sarha)
- alloc rate_constraints in codec (Jyri Sarha)
- fix bad number of channels (Jyri Sarha)
- correct codec generation from config (Russell King - Jyri Sarha)
- no module init/exit (Russell King)
v9:
- back to a TDA998x specific CODEC
- more comments
- change magic values to constants
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 (9):
ASoC: kirkwood: dynamically build the DAI array
ASoC: kirkwood: check the DAI type from the DAI name
ASoC: kirkwood: accept the DAI definitions from a graph of ports drm/i2c: tda998x: Add support of a DT graph of ports drm/i2c: tda998x: Change drvdata for audio extension
ASoC: tda998x: add a codec to the HDMI transmitter drm/i2c: tda998x: set cts_n according to the sample width
ASoC: core: export snd_soc_get_dai_name
ASoC: add generic dt-card support
.../devicetree/bindings/drm/i2c/tda998x.txt | 51 ++++ .../devicetree/bindings/sound/mvebu-audio.txt | 30 +++ drivers/gpu/drm/i2c/tda998x_drv.c | 237 +++++++++++++++++- include/sound/soc.h | 2 + include/sound/tda998x.h | 32 +++ sound/soc/codecs/Kconfig | 5 + sound/soc/codecs/Makefile | 2 + sound/soc/codecs/tda998x.c | 175 +++++++++++++ sound/soc/generic/Kconfig | 2 + sound/soc/generic/Makefile | 2 + sound/soc/generic/dt-card.c | 275 +++++++++++++++++++++ sound/soc/kirkwood/kirkwood-i2s.c | 141 ++++++----- sound/soc/kirkwood/kirkwood.h | 4 +- sound/soc/soc-core.c | 5 +- 14 files changed, 877 insertions(+), 86 deletions(-) create mode 100644 include/sound/tda998x.h create mode 100644 sound/soc/codecs/tda998x.c create mode 100644 sound/soc/generic/dt-card.c
Signature · 6 lines
2.1.4 _______________________________________________ dri-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH v10 1/9 ASoC: kirkwood: dynamically build the DAI array
This patch prepares the driver to the creation of the DAIs from a graph of ports.
--- sound/soc/kirkwood/kirkwood-i2s.c | 108 ++++++++++++++------------------------ sound/soc/kirkwood/kirkwood.h | 1 + 2 files changed, 40 insertions(+), 69 deletions(-)
sound/soc/kirkwood/kirkwood-i2s.c +39 -69
@@ -438,49 +438,8 @@ static const struct snd_soc_dai_ops kirkwood_i2s_dai_ops = { .set_fmt = kirkwood_i2s_set_fmt, }; -static struct snd_soc_dai_driver kirkwood_i2s_dai[2 ] = { - { - .name ="i2s" , - .id =0 , - .playback = { - .channels_min =1 , - .channels_max =2 , - .rates =SNDRV_PCM_RATE_44100 |SNDRV_PCM_RATE_48000 | -SNDRV_PCM_RATE_96000 , - .formats =KIRKWOOD_I2S_FORMATS , - }, - .capture = { - .channels_min =1 , - .channels_max =2 , - .rates =SNDRV_PCM_RATE_44100 |SNDRV_PCM_RATE_48000 | -SNDRV_PCM_RATE_96000 , - .formats =KIRKWOOD_I2S_FORMATS , - }, - .ops = &kirkwood_i2s_dai_ops, - }, - { - .name ="spdif" , - .id =1 , - .playback = { - .channels_min =1 , - .channels_max =2 , - .rates =SNDRV_PCM_RATE_44100 |SNDRV_PCM_RATE_48000 | -SNDRV_PCM_RATE_96000 , - .formats =KIRKWOOD_SPDIF_FORMATS , - }, - .capture = { - .channels_min =1 , - .channels_max =2 , - .rates =SNDRV_PCM_RATE_44100 |SNDRV_PCM_RATE_48000 | -SNDRV_PCM_RATE_96000 , - .formats =KIRKWOOD_SPDIF_FORMATS , - }, - .ops = &kirkwood_i2s_dai_ops, - }, -}; - -static struct snd_soc_dai_driver kirkwood_i2s_dai_extclk[2 ] = { - { +/* DAI sample for I2S and external clock */ +static struct snd_soc_dai_driver kirkwood_i2s_dai_i2s_ext = { .name ="i2s" , .id =0 , .playback = {
@@ -500,42 +459,52 @@ static struct snd_soc_dai_driver kirkwood_i2s_dai_extclk[2] = { .formats = KIRKWOOD_I2S_FORMATS, }, .ops = &kirkwood_i2s_dai_ops, - }, - { - .name = "spdif", - .id = 1, - .playback = { - .channels_min = 1, - .channels_max = 2, - .rates = SNDRV_PCM_RATE_CONTINUOUS, - .rate_min = 5512, - .rate_max = 192000, - .formats = KIRKWOOD_SPDIF_FORMATS, - }, - .capture = { - .channels_min = 1, - .channels_max = 2, - .rates = SNDRV_PCM_RATE_CONTINUOUS, - .rate_min = 5512, - .rate_max = 192000, - .formats = KIRKWOOD_SPDIF_FORMATS, - }, - .ops = &kirkwood_i2s_dai_ops, - }, };static const struct snd_soc_component_driver kirkwood_i2s_component = { .name =DRV_NAME , }; +/* create the DAIs */ +static int kirkwood_i2s_create_dais (struct kirkwood_dma_data *priv) +{ +int i, ndai, dai[2 ]; + + ndai =2 ; + dai[0 ] =0 ;/* i2s(0) - spdif(1) */ + dai[1 ] =1 ; +for (i =0 ; i < ndai; i++) { +memcpy (&priv->dais[i], &kirkwood_i2s_dai_i2s_ext, +sizeof (priv->dais[0 ])); + priv->dais[i].id = i; +if (dai[i] ==1 ) { + priv->dais[i].name ="spdif" ; + priv->dais[i].playback.formats = +KIRKWOOD_SPDIF_FORMATS ; + priv->dais[i].capture.formats = +KIRKWOOD_SPDIF_FORMATS ; + } +if (IS_ERR (priv->extclk)) { + priv->dais[i].playback.rates = +SNDRV_PCM_RATE_44100 | +SNDRV_PCM_RATE_48000 | +SNDRV_PCM_RATE_96000 ; + priv->dais[i].capture.rates = +SNDRV_PCM_RATE_44100 | +SNDRV_PCM_RATE_48000 | +SNDRV_PCM_RATE_96000 ; + } + } +return ndai; +} +static int kirkwood_i2s_dev_probe (struct platform_device *pdev) {struct kirkwood_asoc_platform_data *data = pdev->dev.platform_data; -struct snd_soc_dai_driver *soc_dai = kirkwood_i2s_dai;struct kirkwood_dma_data *priv;struct resource *mem;struct device_node *np = pdev->dev.of_node; -int err; +int err, ndais; priv =devm_kzalloc (&pdev->dev,sizeof (*priv),GFP_KERNEL );if (!priv) {
@@ -585,7 +554,6 @@ static int kirkwood_i2s_dev_probe(struct platform_device *pdev) }else {dev_info (&pdev->dev,"found external clock\n" );clk_prepare_enable (priv->extclk); - soc_dai = kirkwood_i2s_dai_extclk; } }
@@ -602,8 +570,10 @@ static int kirkwood_i2s_dev_probe(struct platform_device *pdev) priv->ctl_rec |=KIRKWOOD_RECCTL_BURST_128 ; } + ndais =kirkwood_i2s_create_dais (priv); + err =snd_soc_register_component (&pdev->dev, &kirkwood_i2s_component, - soc_dai,2 ); + priv->dais, ndais);if (err) {dev_err (&pdev->dev,"snd_soc_register_component failed\n" ); goto err_component;
sound/soc/kirkwood/kirkwood.h +1 -0
@@ -135,6 +135,7 @@ struct kirkwood_dma_data {void __iomem *io;struct clk *clk;struct clk *extclk; +struct snd_soc_dai_driver dais[2 ];uint32_t ctl_play;uint32_t ctl_rec;struct snd_pcm_substream *substream_play;
Signature · 6 lines
2.1.4 _______________________________________________ dri-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH v10 2/9 ASoC: kirkwood: check the DAI type from the DAI name
In reply to Jean-Francois MoineWhen the DAIs are created from a graph of ports, their types are not tied to their ID.
--- sound/soc/kirkwood/kirkwood-i2s.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
sound/soc/kirkwood/kirkwood-i2s.c +2 -2
@@ -263,7 +263,7 @@ static int kirkwood_i2s_play_trigger(struct snd_pcm_substream *substream,case SNDRV_PCM_TRIGGER_START :/* configure */ ctl = priv->ctl_play; -if (dai->id ==0 ) +if (dai->name[0 ] =='i' ) ctl &= ~KIRKWOOD_PLAYCTL_SPDIF_EN ;/* i2s */ else ctl &= ~KIRKWOOD_PLAYCTL_I2S_EN ;/* spdif */
@@ -331,7 +331,7 @@ static int kirkwood_i2s_rec_trigger(struct snd_pcm_substream *substream,case SNDRV_PCM_TRIGGER_START :/* configure */ ctl = priv->ctl_rec; -if (dai->id ==0 ) +if (dai->name[0 ] =='i' ) ctl &= ~KIRKWOOD_RECCTL_SPDIF_EN ;/* i2s */ else ctl &= ~KIRKWOOD_RECCTL_I2S_EN ;/* spdif */
Signature · 6 lines
2.1.4 _______________________________________________ dri-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH v10 3/9 ASoC: kirkwood: accept the DAI definitions from a graph of ports
In reply to Jean-Francois MoineBy default, both output ports 0 (I2S) and 1 (S/PDIF) are defined. A graph of port permits to define only the really connected ports of the board and to identify the remote ends.
--- .../devicetree/bindings/sound/mvebu-audio.txt | 30 ++++++++++++++++ sound/soc/kirkwood/kirkwood-i2s.c | 41 ++++++++++++++++++---- sound/soc/kirkwood/kirkwood.h | 3 +- 3 files changed, 67 insertions(+), 7 deletions(-)
Documentation/devicetree/bindings/sound/mvebu-audio.txt +30 -0
@@ -23,6 +23,19 @@ Required properties: "internal" for the internal clock "extclk" for the external clock +Optional nodes: + +- port: one or two ports. + Each port must contain the following property: + + - port-type: must be "i2s" or "spdif" + + and the following node: + + - endpoint: reference of the remote endpoint - see [1] + +[1] Documentation/devicetree/bindings/graph.txt + Example: i2s1: audio-controller@b4000 {
@@ -31,4 +44,21 @@ i2s1: audio-controller@b4000 { interrupts = <21>, <22>; clocks = <&gate_clk 13>; clock-names = "internal"; + + port@0 { + port-type = "spdif"; + audio1_spdif0: endpoint@0 { + remote-endpoint = <&spdif_out>; + }; + audio1_spdif1: endpoint@1 { + remote-endpoint = <&tda998x_spdif>; + }; + }; + port@1 { + port-type = "i2s"; + audio1_i2s: endpoint { + remote-endpoint = <&tda998x_i2s>; + }; + }; + };
sound/soc/kirkwood/kirkwood-i2s.c +35 -6
55 lines not on this page · raw message
sound/soc/kirkwood/kirkwood.h +2 -1
@@ -141,7 +141,8 @@ struct kirkwood_dma_data {struct snd_pcm_substream *substream_play;struct snd_pcm_substream *substream_rec;int irq; -int burst; +short burst; +short is_graph; };extern struct snd_soc_platform_driver kirkwood_soc_platform;
Signature · 6 lines
2.1.4 _______________________________________________ dri-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH v10 4/9 drm/i2c: tda998x: Add support of a DT graph of ports
In reply to Jean-Francois MoineTwo 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 | 88 +++++++++++++++++++--- include/sound/tda998x.h | 8 ++ 3 files changed, 138 insertions(+), 9 deletions(-) create mode 100644 include/sound/tda998x.h
Documentation/devicetree/bindings/drm/i2c/tda998x.txt +51 -0
@@ -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 +79 -9
115 lines not on this page · raw message
include/sound/tda998x.h new file +8 -0
@@ -0,0 +1,8 @@ +#ifndef SND_TDA998X_H +#define SND_TDA998X_H + +struct tda998x_audio_s { +u8 ports[2 ];/* AP value */ +u8 port_types[2 ];/* AFMT_xxx */ +}; +#endif
Signature · 6 lines
2.1.4 _______________________________________________ dri-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH v10 5/9 drm/i2c: tda998x: Change drvdata for audio extension
In reply to Jean-Francois MoineThe device drvdata is used for component bind, but points to the encoder/connector structure which is hidden from the slave encoder. For audio extension, the slave encoder private data must be accessible, so, this patch changes drvdata to the slave encoder private data and sets it in case of slave encoder use.
--- drivers/gpu/drm/i2c/tda998x_drv.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/gpu/drm/i2c/tda998x_drv.c +6 -2
@@ -1465,6 +1465,8 @@ static int tda998x_encoder_init(struct i2c_client *client, encoder_slave->slave_priv = priv; encoder_slave->slave_funcs = &tda998x_encoder_slave_funcs; +dev_set_drvdata (&client->dev, priv); +return 0 ; }
@@ -1591,7 +1593,7 @@ static int tda998x_bind(struct device *dev, struct device *master, void *data)if (!priv)return -ENOMEM ; -dev_set_drvdata (dev, priv); +dev_set_drvdata (dev, &priv->base); priv->base.encoder = &priv->encoder; priv->connector.interlace_allowed =1 ;
@@ -1641,7 +1643,9 @@ err_encoder:static void tda998x_unbind (struct device *dev,struct device *master,void *data) { -struct tda998x_priv2 *priv =dev_get_drvdata (dev); +struct tda998x_priv *priv_s =dev_get_drvdata (dev); +struct tda998x_priv2 *priv = + container_of(priv_s, struct tda998x_priv2, base);drm_connector_cleanup (&priv->connector);drm_encoder_cleanup (&priv->encoder);
Signature · 6 lines
2.1.4 _______________________________________________ dri-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH v10 6/9 ASoC: tda998x: add a codec to the HDMI transmitter
In reply to Jean-Francois MoineThe tda998x CODEC maintains the audio format and rate constraints according to the HDMI device parameters (EDID) and sets dynamically the input ports in the TDA998x I2C driver on start/stop audio streaming.
--- drivers/gpu/drm/i2c/tda998x_drv.c | 124 +++++++++++++++++++++++++++ include/sound/tda998x.h | 22 +++++ sound/soc/codecs/Kconfig | 5 ++ sound/soc/codecs/Makefile | 2 + sound/soc/codecs/tda998x.c | 174 ++++++++++++++++++++++++++++++++++++++ 5 files changed, 327 insertions(+) create mode 100644 sound/soc/codecs/tda998x.c
drivers/gpu/drm/i2c/tda998x_drv.c +124 -0
@@ -20,6 +20,7 @@#include <linux/module.h> #include <linux/irq.h> #include <sound/asoundef.h> +#include <linux/platform_device.h> #include <drm/drmP.h> #include <drm/drm_crtc_helper.h>
@@ -730,6 +731,104 @@ tda998x_configure_audio(struct tda998x_priv *priv,tda998x_write_aif (priv, p); } +#if IS_ENABLED (CONFIG_SND_SOC_TDA998X ) +/* tda998x audio codec interface */ + +/* return the audio parameters */ +static int tda998x_get_audio_var (struct device *dev, +struct tda998x_audio_s **tda998x_audio) +{ +struct tda998x_priv *priv =dev_get_drvdata (dev); + +if (!priv->encoder->crtc + || !priv->is_hdmi_sink) +return -ENODEV ; + + *tda998x_audio = &priv->audio; +return 0 ; +} + +/* switch the audio port and initialize the audio parameters for streaming */ +static int tda998x_set_audio_input (struct device *dev, +int port_index, +unsigned sample_rate) +{ +struct tda998x_priv *priv =dev_get_drvdata (dev); +struct tda998x_encoder_params *p = &priv->params; + +if (!priv->encoder->crtc) +return -ENODEV ; + +/* if no port, just disable the audio port */ +if (port_index ==PORT_NONE ) { +reg_write (priv,REG_ENA_AP ,0 ); +return 0 ; + } + +/* if same audio parameters, just enable the audio port */ +if (p->audio_cfg == priv->audio.ports[port_index] && + p->audio_sample_rate == sample_rate) { +reg_write (priv,REG_ENA_AP , p->audio_cfg); +return 0 ; + } + + p->audio_format = priv->audio.port_types[port_index]; + p->audio_clk_cfg = p->audio_format ==AFMT_SPDIF ?0 :1 ; + p->audio_cfg = priv->audio.ports[port_index]; + p->audio_sample_rate = sample_rate; +tda998x_configure_audio (priv, &priv->encoder->crtc->hwmode, p); +return 0 ; +} + +/* get the audio capabilities from the EDID */ +static void tda998x_get_audio_caps (struct tda998x_priv *priv, +struct drm_connector *connector) +{ +u8 *eld = connector->eld; +u8 *sad; +int sad_count; +unsigned eld_ver, mnl; +u8 max_channels, rate_mask, fmt; + +/* adjust the hw params from the ELD (EDID) */ + eld_ver = eld[DRM_ELD_VER ] >>DRM_ELD_VER_SHIFT ; +if (eld_ver !=2 && eld_ver !=31 ) +return ; + + mnl =drm_eld_mnl (eld); +if (mnl >16 ) +return ; + + sad_count =drm_eld_sad_count (eld); + sad = eld +DRM_ELD_CEA_SAD (mnl,0 ); + +/* Start from the basic audio settings */ + max_channels =1 ; + rate_mask =0 ; + fmt =0 ; +while (sad_count--) { +switch (sad[0 ] &0x78 ) { +case 0x08 :/* SAD uncompressed audio */ +if ((sad[0 ] &7 ) > max_channels) + max_channels = sad[0 ] &7 ; + rate_mask |= sad[1 ]; + fmt |= sad[2 ] &0x07 ; +break ; + } + sad +=3 ; + } + + priv->audio.cea_sad.channels = max_channels; + priv->audio.cea_sad.freq = rate_mask; + priv->audio.cea_sad.format = fmt; +} + +static struct tda998x_ops_s tda998x_codec_ops = { + .get_audio_var = tda998x_get_audio_var, + .set_audio_input = tda998x_set_audio_input, +}; +#endif /* SND_SOC */ +/* DRM encoder functions */ static void tda998x_encoder_set_config(struct tda998x_priv *priv,
@@ -749,6 +848,8 @@ static void tda998x_encoder_set_config(struct tda998x_priv *priv, (p->mirr_f ?VIP_CNTRL_2_MIRR_F :0 ); priv->params = *p; + priv->audio.port_types[0 ] = p->audio_format; + priv->audio.ports[0 ] = p->audio_cfg; }static void tda998x_encoder_dpms (struct tda998x_priv *priv,int mode)
@@ -1142,6 +1243,14 @@ tda998x_encoder_get_modes(struct tda998x_priv *priv,drm_mode_connector_update_edid_property (connector, edid); n =drm_add_edid_modes (connector, edid); priv->is_hdmi_sink =drm_detect_hdmi_monitor (edid); + +#if IS_ENABLED (CONFIG_SND_SOC_TDA998X ) +/* set the audio parameters from the EDID */ +if (priv->is_hdmi_sink) { +drm_edid_to_eld (connector, edid); +tda998x_get_audio_caps (priv, connector); + } +#endif kfree (edid); }
@@ -1176,6 +1285,11 @@ static void tda998x_destroy(struct tda998x_priv *priv)if (priv->hdmi->irq)free_irq (priv->hdmi->irq, priv); +#if IS_ENABLED (CONFIG_SND_SOC_TDA998X ) +if (priv->audio.ports[0 ]) +tda9998x_codec_unregister (&priv->hdmi->dev); +#endif +i2c_unregister_device (priv->cec); }
@@ -1311,6 +1425,9 @@ static int tda998x_create(struct i2c_client *client, struct tda998x_priv *priv) priv->vip_cntrl_1 =VIP_CNTRL_1_SWAP_C (0 ) |VIP_CNTRL_1_SWAP_D (1 ); priv->vip_cntrl_2 =VIP_CNTRL_2_SWAP_E (4 ) |VIP_CNTRL_2_SWAP_F (5 ); + priv->params.audio_frame[1 ] =1 ;/* channels - 1 */ + priv->params.audio_sample_rate =48000 ;/* 48kHz */ + priv->current_page =0xff ; priv->hdmi = client; priv->cec =i2c_new_dummy (client->adapter,0x34 );
@@ -1419,6 +1536,13 @@ static int tda998x_create(struct i2c_client *client, struct tda998x_priv *priv) priv->params.audio_clk_cfg = priv->params.audio_format ==AFMT_SPDIF ?0 :1 ; + +#if IS_ENABLED (CONFIG_SND_SOC_TDA998X ) +/* and create the audio CODEC */ +tda9998x_codec_register (&client->dev, + &priv->audio, + &tda998x_codec_ops); +#endif } }else {
include/sound/tda998x.h +22 -0
@@ -1,8 +1,30 @@#ifndef SND_TDA998X_H #define SND_TDA998X_H +#include <drm/drm_edid.h> + +/* port index for audio stream stop */ +#define PORT_NONE (-1) +struct tda998x_audio_s {u8 ports[2 ];/* AP value */ u8 port_types[2 ];/* AFMT_xxx */ +#if IS_ENABLED (CONFIG_SND_SOC_TDA998X ) +struct cea_sad cea_sad;/* Short Audio Descriptor */ +void *codec_priv; +#endif }; + +struct tda998x_ops_s { +int (*get_audio_var)(struct device *dev, +struct tda998x_audio_s **tda998x_audio); +int (*set_audio_input)(struct device *dev, +int port_index, +unsigned sample_rate); +}; + +int tda9998x_codec_register (struct device *dev, +struct tda998x_audio_s *tda998x_audio_i, +struct tda998x_ops_s *tda998x_ops); +void tda9998x_codec_unregister (struct device *dev);#endif
sound/soc/codecs/Kconfig +5 -0
@@ -102,6 +102,7 @@ config SND_SOC_ALL_CODECS select SND_SOC_STAC9766 if SND_SOC_AC97_BUS select SND_SOC_TAS2552 if I2C select SND_SOC_TAS5086 if I2C + select SND_SOC_TDA998X if DRM_I2C_NXP_TDA998X select SND_SOC_TFA9879 if I2C select SND_SOC_TLV320AIC23_I2C if I2C select SND_SOC_TLV320AIC23_SPI if SPI_MASTER
@@ -600,6 +601,10 @@ config SND_SOC_TAS5086 tristate "Texas Instruments TAS5086 speaker amplifier" depends on I2C +config SND_SOC_TDA998X + def_tristate y + depends on DRM_I2C_NXP_TDA998X + config SND_SOC_TFA9879 tristate "NXP Semiconductors TFA9879 amplifier" depends on I2C
sound/soc/codecs/Makefile +2 -0
@@ -104,6 +104,7 @@ snd-soc-sta350-objs := sta350.o snd-soc-sta529-objs := sta529.o snd-soc-stac9766-objs := stac9766.o snd-soc-tas5086-objs := tas5086.o +snd-soc-tda998x-objs := tda998x.o snd-soc-tfa9879-objs := tfa9879.o snd-soc-tlv320aic23-objs := tlv320aic23.o snd-soc-tlv320aic23-i2c-objs := tlv320aic23-i2c.o
@@ -282,6 +283,7 @@ obj-$(CONFIG_SND_SOC_STA529) += snd-soc-sta529.o obj-$(CONFIG_SND_SOC_STAC9766) += snd-soc-stac9766.o obj-$(CONFIG_SND_SOC_TAS2552) += snd-soc-tas2552.o obj-$(CONFIG_SND_SOC_TAS5086) += snd-soc-tas5086.o +obj-$(CONFIG_SND_SOC_TDA998X) += snd-soc-tda998x.o obj-$(CONFIG_SND_SOC_TFA9879) += snd-soc-tfa9879.o obj-$(CONFIG_SND_SOC_TLV320AIC23) += snd-soc-tlv320aic23.o obj-$(CONFIG_SND_SOC_TLV320AIC23_I2C) += snd-soc-tlv320aic23-i2c.o
sound/soc/codecs/tda998x.c new file +174 -0
174 lines not on this page · raw message
Signature · 6 lines
2.1.4 _______________________________________________ dri-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH v10 7/9 drm/i2c: tda998x: set cts_n according to the sample width
In reply to Jean-Francois MoineWith I2S input, the CTS_N predivider depends on the audio sample width.
--- drivers/gpu/drm/i2c/tda998x_drv.c | 21 ++++++++++++++++++--- include/sound/tda998x.h | 4 +++- sound/soc/codecs/tda998x.c | 5 +++-- 3 files changed, 24 insertions(+), 6 deletions(-)
drivers/gpu/drm/i2c/tda998x_drv.c +18 -3
@@ -28,6 +28,7 @@#include <drm/drm_edid.h> #include <drm/i2c/tda998x.h> #include <sound/tda998x.h> +#include <sound/pcm.h> #define DBG (fmt, ...) DRM_DEBUG(fmt"\n", ##__VA_ARGS__)
@@ -663,7 +664,17 @@ tda998x_configure_audio(struct tda998x_priv *priv,reg_write (priv,REG_MUX_AP ,MUX_AP_SELECT_I2S ); clksel_aip =AIP_CLKSEL_AIP_I2S ; clksel_fs =AIP_CLKSEL_FS_ACLK ; - cts_n =CTS_N_M (3 ) |CTS_N_K (3 ); + +/* with I2S input, the CTS_N predivider depends on +* the sample width */ +switch (priv->audio.sample_format) { +case SNDRV_PCM_FORMAT_S16_LE : + cts_n =CTS_N_M (3 ) |CTS_N_K (1 ); +break ; +default : + cts_n =CTS_N_M (3 ) |CTS_N_K (3 ); +break ; + }break ;default :
@@ -751,7 +762,8 @@ static int tda998x_get_audio_var(struct device *dev,/* switch the audio port and initialize the audio parameters for streaming */ static int tda998x_set_audio_input (struct device *dev,int port_index, -unsigned sample_rate) +unsigned sample_rate, +int sample_format) {struct tda998x_priv *priv =dev_get_drvdata (dev);struct tda998x_encoder_params *p = &priv->params;
@@ -767,7 +779,8 @@ static int tda998x_set_audio_input(struct device *dev,/* if same audio parameters, just enable the audio port */ if (p->audio_cfg == priv->audio.ports[port_index] && - p->audio_sample_rate == sample_rate) { + p->audio_sample_rate == sample_rate && + priv->audio.sample_format == sample_format) {reg_write (priv,REG_ENA_AP , p->audio_cfg);return 0 ; }
@@ -776,6 +789,7 @@ static int tda998x_set_audio_input(struct device *dev, p->audio_clk_cfg = p->audio_format ==AFMT_SPDIF ?0 :1 ; p->audio_cfg = priv->audio.ports[port_index]; p->audio_sample_rate = sample_rate; + priv->audio.sample_format = sample_format;tda998x_configure_audio (priv, &priv->encoder->crtc->hwmode, p);return 0 ; }
@@ -1427,6 +1441,7 @@ static int tda998x_create(struct i2c_client *client, struct tda998x_priv *priv) priv->params.audio_frame[1 ] =1 ;/* channels - 1 */ priv->params.audio_sample_rate =48000 ;/* 48kHz */ + priv->audio.sample_format =SNDRV_PCM_FORMAT_S24_LE ; priv->current_page =0xff ; priv->hdmi = client;
include/sound/tda998x.h +3 -1
@@ -9,6 +9,7 @@struct tda998x_audio_s {u8 ports[2 ];/* AP value */ u8 port_types[2 ];/* AFMT_xxx */ +int sample_format;#if IS_ENABLED (CONFIG_SND_SOC_TDA998X )struct cea_sad cea_sad;/* Short Audio Descriptor */ void *codec_priv;
@@ -20,7 +21,8 @@ struct tda998x_ops_s { struct tda998x_audio_s **tda998x_audio);int (*set_audio_input)(struct device *dev,int port_index, -unsigned sample_rate); +unsigned sample_rate, +int sample_format); }; int tda9998x_codec_register(struct device *dev,
sound/soc/codecs/tda998x.c +3 -2
@@ -73,13 +73,14 @@ static int tda998x_codec_hw_params(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) {return tda998x_ops->set_audio_input (dai->dev, dai->id, -params_rate (params)); +params_rate (params), +params_format (params)); }static void tda998x_codec_shutdown (struct snd_pcm_substream *substream,struct snd_soc_dai *dai) { - tda998x_ops->set_audio_input (dai->dev,PORT_NONE ,0 ); + tda998x_ops->set_audio_input (dai->dev,PORT_NONE ,0 ,0 ); }static const struct snd_soc_dai_ops tda998x_codec_ops = {
Signature · 6 lines
2.1.4 _______________________________________________ dri-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH v10 8/9 ASoC: core: export snd_soc_get_dai_name
In reply to Jean-Francois Moinesnd_soc_get_dai_name() may be used to define a sound card with a different syntax from the one of the simple-card.
--- include/sound/soc.h | 2 ++ sound/soc/soc-core.c | 5 +++-- 2 files changed, 5 insertions(+), 2 deletions(-)
include/sound/soc.h +2 -0
@@ -1502,6 +1502,8 @@ int snd_soc_of_get_dai_name(struct device_node *of_node,int snd_soc_of_get_dai_link_codecs (struct device *dev,struct device_node *of_node,struct snd_soc_dai_link *dai_link); +int snd_soc_get_dai_name (struct of_phandle_args *args, +const char **dai_name);#include <sound/soc-dai.h>
sound/soc/soc-core.c +3 -2
@@ -3418,8 +3418,8 @@ unsigned int snd_soc_of_parse_daifmt(struct device_node *np, }EXPORT_SYMBOL_GPL (snd_soc_of_parse_daifmt); -static int snd_soc_get_dai_name (struct of_phandle_args *args, -const char **dai_name) +int snd_soc_get_dai_name (struct of_phandle_args *args, +const char **dai_name) {struct snd_soc_component *pos;int ret = -EPROBE_DEFER ;
@@ -3465,6 +3465,7 @@ static int snd_soc_get_dai_name(struct of_phandle_args *args,mutex_unlock (&client_mutex);return ret; } +EXPORT_SYMBOL_GPL (snd_soc_get_dai_name);int snd_soc_of_get_dai_name (struct device_node *of_node,const char **dai_name)
Signature · 6 lines
2.1.4 _______________________________________________ dri-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH v10 9/9 ASoC: add generic dt-card support
In reply to Jean-Francois MoineTo create simple cards, the syntax of the simple-card does not follow the common binding of the device graphs (Documentation/devicetree/bindings/graph.txt).
dt-card devices are created by audio controllers with themselves as the root of the graph. The sound card is created according to the parameters found in the tree.
--- sound/soc/generic/Kconfig | 2 + sound/soc/generic/Makefile | 2 + sound/soc/generic/dt-card.c | 275 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 279 insertions(+) create mode 100644 sound/soc/generic/dt-card.c
sound/soc/generic/Kconfig +2 -0
@@ -2,3 +2,5 @@ config SND_SIMPLE_CARD tristate "ASoC Simple sound card support" help This option enables generic simple sound card support +config SND_DT_CARD + tristate
sound/soc/generic/Makefile +2 -0
@@ -1,3 +1,5 @@ snd-soc-simple-card-objs := simple-card.o +snd-soc-dt-card-objs := dt-card.o obj-$(CONFIG_SND_SIMPLE_CARD) += snd-soc-simple-card.o +obj-$(CONFIG_SND_DT_CARD) += snd-soc-dt-card.o
sound/soc/generic/dt-card.c new file +275 -0
275 lines not on this page · raw message
Signature · 6 lines
2.1.4 _______________________________________________ dri-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/dri-devel
Mark Brown
maintainerRe: [PATCH v10 9/9] ASoC: add generic dt-card support
Quoted 3 lines · Jean-Francois Moine
To create simple cards, the syntax of the simple-card does not follow the common binding of the device graphs (
Documentation/devicetree/bindings/graph.txt).
Please be more specific, I really can't tell what this is supposed to be doing from the above - in what way is the binding not common and why would anyone care? Please also address why this is done as a completely separate implementation rather than a new revision of simple-card and CC Morimoto-san so he can review (given that he did simple-card initially).
Quoted 5 lines
sound/soc/generic/Kconfig | 2 + sound/soc/generic/Makefile | 2 + sound/soc/generic/dt-card.c | 275 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 279 insertions(+) create mode 100644 sound/soc/generic/dt-card.c
As you know all device tree bindings require binding documents; you must supply a binding document. I'm not going to look at any DT patches that don't include binding documentation.
In general please pay attention to changelogs and documentation when submitting patches, the harder it is to understand what a patch is supposed to do or why the harder it is to review. I keep saying this, it's really important.
Hi,
Have you done anything about the tda998x audio support lately?
I was thinking of taking a shot at this now that I finally seem to have some time for it. However, if you are just about to send another series I'll wait for that first and see what makes the most sense after that.
My plan is to do something really simple first. No graph bindings or anything fancy like that. Just a minimal dt-binding to for audio pin configuration and use simple-card for the rest. I still try to make it possible to support spdif and i2s at the same time, but I can not test it as I do not have such HW.
I also try to make the ASoC part as generic as possible, so that it could be reused by other HDMI encoders with spdif or i2s interface.
Best regards,
Jyri
Quoted 70 lines · Jean-Francois Moine
Based on broonie/ASoC
v10:
- add the generic dt-card
- define the audio ports from a DT graph of ports (Russell King)
- reuse HDMI constants (Andrew Jackson - Jyri Sarha)
- allocrate_constraintsin codec (Jyri Sarha)
- fix bad number of channels (Jyri Sarha)
- correct codec generation from config (Russell King - Jyri Sarha)
- no module init/exit (Russell King)
v9:
- back to a TDA998x specific CODEC
- more comments
- change magic values to constants
v8:
- change some comments about the patches
v7:
- remove the change of the K predivider (Jyri Sarha)
- addS24_3LEandS32_LEas 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 uselessrequest_module(Russell King/Mark Brown)
- don't lock the HDMI module (Russell King)
- useplatform_device_unregisterto 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 tosound/soc(Mark Brown)
- update theaudio_sample_ratefrom the EDID (Andrew Jackson)
v3: fix bad rate (Andrew Jackson)
v2: check double stream start (Mark Brown)Jean-Francois Moine (9):
ASoC: kirkwood: dynamically build the DAI array
ASoC: kirkwood: check the DAI type from the DAI name
ASoC: kirkwood: accept the DAI definitions from a graph of ports drm/i2c: tda998x: Add support of a DT graph of ports drm/i2c: tda998x: Change drvdata for audio extension
ASoC: tda998x: add a codec to the HDMI transmitter drm/i2c: tda998x: setcts_naccording to the sample width
ASoC: core: exportsnd_soc_get_dai_name
ASoC: add generic dt-card support.../devicetree/bindings/drm/i2c/tda998x.txt | 51 ++++ .../devicetree/bindings/sound/mvebu-audio.txt | 30 +++ drivers/gpu/drm/i2c/tda998x_drv.c | 237 +++++++++++++++++- include/sound/soc.h | 2 + include/sound/tda998x.h | 32 +++ sound/soc/codecs/Kconfig | 5 + sound/soc/codecs/Makefile | 2 + sound/soc/codecs/tda998x.c | 175 +++++++++++++ sound/soc/generic/Kconfig | 2 + sound/soc/generic/Makefile | 2 + sound/soc/generic/dt-card.c | 275 +++++++++++++++++++++ sound/soc/kirkwood/kirkwood-i2s.c | 141 ++++++----- sound/soc/kirkwood/kirkwood.h | 4 +- sound/soc/soc-core.c | 5 +- 14 files changed, 877 insertions(+), 86 deletions(-)create mode 100644
include/sound/tda998x.h
create mode 100644sound/soc/codecs/tda998x.c
create mode 100644sound/soc/generic/dt-card.c
Quoted 6 lines · On Mon, 27 Apr 2015 14:33:45 +0300 Jyri Sarha <[email protected]> wrote:
Have you done anything about the tda998x audio support lately?
I was thinking of taking a shot at this now that I finally seem to have some time for it. However, if you are just about to send another series I'll wait for that first and see what makes the most sense after that.
Quoted 8 lines
My plan is to do something really simple first. No graph bindings or anything fancy like that. Just a minimal dt-binding to for audio pin configuration and use simple-card for the rest. I still try to make it possible to support spdif and i2s at the same time, but I can not test it as I do not have such HW.
I also try to make the ASoC part as generic as possible, so that it could be reused by other HDMI encoders with spdif or i2s interface.
Hi Jyri,
I was busy on an other work, so, I did not advance on the tda998x.
If you look at the patch series, it contains 3 independant parts:
- dynamic building of the DAIs in the kirkwood audio controller,
- audio CODEC of the tda998x
- DT card based on audio graph
It seems that only the last part raised a problem. Otherwise, the simple card works fine with the 2 first parts.
I am merging my patches in 4.1-rc1, and, as soon as I get an image on my screen :), I will resubmit a patch series but about the tda998x codec only.
Using i2s and s/pdif at the same time with the simple card asks for a patch as the one I submitted in february 2014 (ASoC: simple-card: DT fix and multi DAI links extension). As I am using my DT card, I will not resubmit it. Eventually, the kirkwood patches are not critical.
Signature · 6 lines
Ken ar c'hentañ | ** Breizh ha Linux atav! ** Jef | http://moinejf.free.fr/ _______________________________________________ dri-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/dri-devel
Quoted 3 lines · On Mon, 27 Apr 2015 20:25:02 +0200 Jean-Francois Moine <[email protected]> wrote:
Using i2s and s/pdif at the same time with the simple card asks for a patch as the one I submitted in february 2014 (ASoC: simple-card: DT fix and multi DAI links extension).
Sorry, the patch was "ASoC: simple-card: Add multi-CODEC support" submitted in january 2015:
http://mailman.alsa-project.org/pipermail/alsa-devel/2015-January/085855.html
Signature · 6 lines
Ken ar c'hentañ | ** Breizh ha Linux atav! ** Jef | http://moinejf.free.fr/ _______________________________________________ dri-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/dri-devel