All of lore.kernel.org
 help / color / mirror / Atom feed
From: Takashi Iwai <tiwai@suse.de>
To: "Subhransu S. Prusty" <subhransu.s.prusty@intel.com>
Cc: patches.audio@intel.com, Vinod Koul <vinod.koul@intel.com>,
	alsa-devel@alsa-project.org, broonie@kernel.org,
	lgirdwood@gmail.com
Subject: Re: [PATCH 04/15] ALSA: hda - Add helper to read eld data
Date: Tue, 01 Dec 2015 13:39:19 +0100	[thread overview]
Message-ID: <s5hvb8ipclk.wl-tiwai@suse.de> (raw)
In-Reply-To: <1448992031-8271-4-git-send-email-subhransu.s.prusty@intel.com>

On Tue, 01 Dec 2015 18:47:00 +0100,
Subhransu S. Prusty wrote:
> 
> The eld reading APIs are required for ASoC skylake hdmi
> driver as well. So moving these definition to core. Once
> component ops for reading ELD is available will mark this
> as deprecated.
> 
> Signed-off-by: Subhransu S. Prusty <subhransu.s.prusty@intel.com>
> Signed-off-by: Vinod Koul <vinod.koul@intel.com>

I'd like rather to merge this from my tree, not from asoc tree.
Otherwise it makes hard to use this in the legacy HDA driver.

Or make this local in asoc, and clean up later as a common helper.


thanks,

Takashi


> ---
>  include/sound/hdaudio.h |  3 ++
>  sound/hda/Makefile      |  2 +-
>  sound/hda/hdac_eld.c    | 95 +++++++++++++++++++++++++++++++++++++++++++++++++
>  3 files changed, 99 insertions(+), 1 deletion(-)
>  create mode 100644 sound/hda/hdac_eld.c
> 
> diff --git a/include/sound/hdaudio.h b/include/sound/hdaudio.h
> index e2b712c..1170f21 100644
> --- a/include/sound/hdaudio.h
> +++ b/include/sound/hdaudio.h
> @@ -455,6 +455,9 @@ void snd_hdac_stream_sync(struct hdac_stream *azx_dev, bool start,
>  			  unsigned int streams);
>  void snd_hdac_stream_timecounter_init(struct hdac_stream *azx_dev,
>  				      unsigned int streams);
> +/* HDMI helpers to query eld from codec */
> +int snd_hdac_get_eld(struct hdac_device *codec, hda_nid_t nid,
> +		unsigned char *buf, int *eld_size);
>  /*
>   * macros for easy use
>   */
> diff --git a/sound/hda/Makefile b/sound/hda/Makefile
> index 7e999c9..e0a2b25 100644
> --- a/sound/hda/Makefile
> +++ b/sound/hda/Makefile
> @@ -1,5 +1,5 @@
>  snd-hda-core-objs := hda_bus_type.o hdac_bus.o hdac_device.o hdac_sysfs.o \
> -	hdac_regmap.o hdac_controller.o hdac_stream.o array.o
> +	hdac_regmap.o hdac_controller.o hdac_stream.o array.o hdac_eld.o
>  
>  snd-hda-core-objs += trace.o
>  CFLAGS_trace.o := -I$(src)
> diff --git a/sound/hda/hdac_eld.c b/sound/hda/hdac_eld.c
> new file mode 100644
> index 0000000..9126e0f
> --- /dev/null
> +++ b/sound/hda/hdac_eld.c
> @@ -0,0 +1,95 @@
> +/*
> + * HDMI Eld routines
> + */
> +
> +#include <sound/hdaudio.h>
> +
> +#define ELD_FIXED_BYTES	20
> +#define ELD_MAX_SIZE    256
> +
> +static unsigned int snd_hdac_get_eld_data(struct hdac_device *codec,
> +				hda_nid_t nid, int byte_index)
> +{
> +	unsigned int val;
> +
> +	val = snd_hdac_codec_read(codec, nid, 0,
> +					AC_VERB_GET_HDMI_ELDD, byte_index);
> +
> +	dev_dbg(&codec->dev, "HDMI: ELD data byte %d: 0x%x\n", byte_index, val);
> +
> +	return val;
> +}
> +
> +static int snd_hdac_get_eld_size(struct hdac_device *codec, hda_nid_t nid)
> +{
> +	return snd_hdac_codec_read(codec, nid, 0, AC_VERB_GET_HDMI_DIP_SIZE,
> +						 AC_DIPSIZE_ELD_BUF);
> +}
> +
> +/**
> + * snd_hdac_get_eld - Query eld from sink
> + * @codec - device to query
> + * @nid - codec node to query
> + * @buf - Buffer to fill eld data
> + * @eld_size - Size of eld queried
> + *
> + * Returns zero on success or a negative error code
> + *
> + * This function queries the eld size and eld data and fills in the buffer
> + * passed by user
> + */
> +int snd_hdac_get_eld(struct hdac_device *codec, hda_nid_t nid,
> +		     unsigned char *buf, int *eld_size)
> +{
> +	int i;
> +	int ret = 0;
> +	int size;
> +
> +	/*
> +	 * ELD size is initialized to zero in caller function. If no errors and
> +	 * ELD is valid, actual eld_size is assigned.
> +	 */
> +
> +	size = snd_hdac_get_eld_size(codec, nid);
> +	if (size == 0) {
> +		/* wfg: workaround for ASUS P5E-VM HDMI board */
> +		dev_info(&codec->dev, "HDMI: ELD buf size is 0, force 128\n");
> +		size = 128;
> +	}
> +	if (size < ELD_FIXED_BYTES || size > ELD_MAX_SIZE) {
> +		dev_info(&codec->dev, "HDMI: invalid ELD buf size %d\n", size);
> +		return -ERANGE;
> +	}
> +
> +	/* set ELD buffer */
> +	for (i = 0; i < size; i++) {
> +		unsigned int val = snd_hdac_get_eld_data(codec, nid, i);
> +		/*
> +		 * Graphics driver might be writing to ELD buffer right now.
> +		 * Just abort. The caller will repoll after a while.
> +		 */
> +		if (!(val & AC_ELDD_ELD_VALID)) {
> +			dev_info(&codec->dev, "HDMI: invalid ELD data byte %d\n", i);
> +			ret = -EINVAL;
> +			goto error;
> +		}
> +		val &= AC_ELDD_ELD_DATA;
> +		/*
> +		 * The first byte cannot be zero. This can happen on some DVI
> +		 * connections. Some Intel chips may also need some 250ms delay
> +		 * to return non-zero ELD data, even when the graphics driver
> +		 * correctly writes ELD content before setting ELD_valid bit.
> +		 */
> +		if (!val && !i) {
> +			dev_dbg(&codec->dev, "HDMI: 0 ELD data\n");
> +			ret = -EINVAL;
> +			goto error;
> +		}
> +		buf[i] = val;
> +	}
> +
> +	*eld_size = size;
> +error:
> +	return ret;
> +}
> +EXPORT_SYMBOL_GPL(snd_hdac_get_eld);
> -- 
> 1.9.1
> 

  reply	other threads:[~2015-12-01 12:39 UTC|newest]

Thread overview: 48+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-12-01 17:42 [PATCH 00/15] ASoC: hdac_hdmi: Add DP & notification support Subhransu S. Prusty
2015-12-01 17:46 ` [PATCH 01/15] ASoC: hdac_hdmi: Fix to check num nodes correctly Subhransu S. Prusty
2015-12-01 12:27   ` Takashi Iwai
2015-12-01 19:08     ` Subhransu S. Prusty
2015-12-01 17:46   ` [PATCH 02/15] ASoC: hdac_hdmi: Fix to warn instead of err for no connected nids Subhransu S. Prusty
2016-01-08 13:44     ` Applied "ASoC: hdac_hdmi: Fix to warn instead of err for no connected nids" to the asoc tree Mark Brown
2015-12-01 17:46   ` [PATCH 03/15] ASoC: hdac_hdmi - Use list to add pins and converters Subhransu S. Prusty
2015-12-01 12:47     ` Takashi Iwai
2015-12-01 22:50       ` Subhransu S. Prusty
2015-12-01 18:52         ` Takashi Iwai
2015-12-02  9:31           ` Takashi Iwai
2015-12-03 10:36             ` Subhransu S. Prusty
2015-12-01 17:47   ` [PATCH 04/15] ALSA: hda - Add helper to read eld data Subhransu S. Prusty
2015-12-01 12:39     ` Takashi Iwai [this message]
2015-12-01 19:12       ` Subhransu S. Prusty
2015-12-01 13:55         ` Takashi Iwai
2015-12-01 17:47   ` [PATCH 05/15] ASoC: hdac_hdmi: Add hotplug notification and read eld Subhransu S. Prusty
2015-12-01 12:37     ` Takashi Iwai
2015-12-01 20:14       ` Subhransu S. Prusty
2015-12-01 17:47   ` [PATCH 06/15] ALSA: pcm: Add DRM helper to set constraint for format Subhransu S. Prusty
2015-12-01 12:55     ` Takashi Iwai
2015-12-02 12:27       ` Subhransu S. Prusty
2015-12-02  9:23         ` Takashi Iwai
2015-12-01 17:47   ` [PATCH 07/15] ASoC: hdac_hdmi: Apply constraints based on ELD Subhransu S. Prusty
2015-12-01 17:47   ` [PATCH 08/15] ASoC: hdac_hdmi: Enable DP1.2 and all converters/pins Subhransu S. Prusty
2015-12-01 17:47   ` [PATCH 09/15] ASoC: hdac_hdmi - create dais based on number of streams Subhransu S. Prusty
2015-12-01 17:47   ` [PATCH 10/15] ASoC: hdac_hdmi: Create widget/route based on nodes enumerated Subhransu S. Prusty
2015-12-01 17:47   ` [PATCH 11/15] ASoC: hdac_hdmi: Assign pin for stream based on dapm connection Subhransu S. Prusty
2015-12-01 17:47   ` [PATCH 12/15] drm/edid: Add API to help find connection type Subhransu S. Prusty
2015-12-02  9:53     ` Jani Nikula
2015-12-02 17:07       ` Thierry Reding
2015-12-03 16:08         ` [alsa-devel] " Subhransu S. Prusty
2015-12-03 11:09           ` Jani Nikula
2015-12-03 11:21             ` Thierry Reding
2015-12-03 17:14               ` Subhransu S. Prusty
2015-12-02 17:16       ` Subhransu S. Prusty
2015-12-01 17:47   ` [PATCH 13/15] ASoC: hdac_hdmi: Add infoframe support for dp audio Subhransu S. Prusty
2015-12-01 17:47   ` [PATCH 14/15] ASoC: hdac_hdmi: Add codec suspend/resume handler Subhransu S. Prusty
2015-12-01 17:47   ` [PATCH 15/15] ASoC: hdac_hdmi: Keep display active while enumerating codec Subhransu S. Prusty
2015-12-01 12:57     ` Takashi Iwai
2015-12-01 21:48       ` Subhransu S. Prusty
2015-12-01 16:33         ` Takashi Iwai
2015-12-01 16:48           ` Babu, Ramesh
2015-12-01 17:08             ` Takashi Iwai
2015-12-02 15:37               ` Subhransu S. Prusty
2015-12-02 10:24                 ` Takashi Iwai
2015-12-02 10:31                   ` Takashi Iwai
2015-12-02 16:23                   ` Subhransu S. Prusty

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=s5hvb8ipclk.wl-tiwai@suse.de \
    --to=tiwai@suse.de \
    --cc=alsa-devel@alsa-project.org \
    --cc=broonie@kernel.org \
    --cc=lgirdwood@gmail.com \
    --cc=patches.audio@intel.com \
    --cc=subhransu.s.prusty@intel.com \
    --cc=vinod.koul@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.