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

2015-08-17 Thread Jyri Sarha

On 08/17/15 10:57, Jyri Sarha wrote:

Missed one commet first time around...

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

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

...

+/* 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.



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


--
To unsubscribe from this list: send the line unsubscribe linux-omap in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


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

2015-08-17 Thread Mark Brown
On Mon, Aug 17, 2015 at 10:07:55AM +0300, Jyri Sarha wrote:
 On 08/14/15 19:18, Mark Brown wrote:
 On Fri, Aug 14, 2015 at 12:30:41PM +0300, Jyri Sarha wrote:

 +   /* 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.

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


signature.asc
Description: Digital signature


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

2015-08-17 Thread Jyri Sarha

Missed one commet first time around...

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

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

...

+/* 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
--
To unsubscribe from this list: send the line unsubscribe linux-omap in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


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

2015-08-17 Thread Jyri Sarha

On 08/17/15 21:41, Mark Brown wrote:

On Mon, Aug 17, 2015 at 10:07:55AM +0300, Jyri Sarha wrote:

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

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



+   /* 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.


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



Ok, I'll improve the comment above.

Thanks,
Jyri
--
To unsubscribe from this list: send the line unsubscribe linux-omap in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


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

2015-08-17 Thread Jyri Sarha

On 08/14/15 12:57, Russell King - ARM Linux wrote:

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

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


+   .iec = {
+   .status = {
+   IEC958_AES0_CON_NOT_COPYRIGHT,
+   IEC958_AES1_CON_GENERAL,
+   IEC958_AES2_CON_SOURCE_UNSPEC,
+   IEC958_AES3_CON_CLOCK_VARIABLE,
+   },


...


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



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

--
To unsubscribe from this list: send the line unsubscribe linux-omap in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


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

2015-08-17 Thread Jyri Sarha

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

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


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


+   /* 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.



+/* HDMI codec initalization data */
+struct hdmi_codec_pdata {
+   struct device *dev; /* The HDMI encoder registering the codec */


Shouldn't this just be dev-parent?


+enum {
+   DAI_ID_I2C = 0,
+   DAI_ID_SPDIF,
+};


I2C?  :P



Right, should be I2S. Thanks!

Best regards,
Jyri

--
To unsubscribe from this list: send the line unsubscribe linux-omap in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


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

2015-08-14 Thread Mark Brown
On Fri, Aug 14, 2015 at 12:30:41PM +0300, Jyri Sarha wrote:

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

 + /* 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?

 +/* HDMI codec initalization data */
 +struct hdmi_codec_pdata {
 + struct device *dev; /* The HDMI encoder registering the codec */

Shouldn't this just be dev-parent?

 +enum {
 + DAI_ID_I2C = 0,
 + DAI_ID_SPDIF,
 +};

I2C?  :P


signature.asc
Description: Digital signature


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

2015-08-14 Thread 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.

Signed-off-by: Jyri Sarha jsa...@ti.com
---
 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

diff --git a/include/sound/hdmi-codec.h b/include/sound/hdmi-codec.h
new file mode 100644
index 000..b8a90f7
--- /dev/null
+++ b/include/sound/hdmi-codec.h
@@ -0,0 +1,99 @@
+/*
+ * hdmi-codec.h - HDMI Codec driver API
+ *
+ * Copyright (C) 2014 Texas Instruments Incorporated - http://www.ti.com
+ *
+ * Author: Jyri Sarha jsa...@ti.com
+ *
+ * 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__ */
diff --git a/sound/soc/codecs/Kconfig b/sound/soc/codecs/Kconfig
index fc8e729..a5cc574 100644
--- a/sound/soc/codecs/Kconfig
+++ b/sound/soc/codecs/Kconfig
@@ -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
 
diff --git a/sound/soc/codecs/Makefile b/sound/soc/codecs/Makefile
index 01b4601..0245e67 100644
--- a/sound/soc/codecs/Makefile
+++ b/sound/soc/codecs/Makefile
@@ -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 

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

2015-08-14 Thread Russell King - ARM Linux
On Fri, Aug 14, 2015 at 12:30:41PM +0300, Jyri Sarha wrote:
 +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.

 + .iec = {
 + .status = {
 + IEC958_AES0_CON_NOT_COPYRIGHT,
 + IEC958_AES1_CON_GENERAL,
 + IEC958_AES2_CON_SOURCE_UNSPEC,
 + IEC958_AES3_CON_CLOCK_VARIABLE,
 + },

...

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

 + 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;
 + 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.

-- 
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 linux-omap in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html