public inbox for intel-gfx@lists.freedesktop.org
 help / color / mirror / Atom feed
From: Daniel Vetter <daniel@ffwll.ch>
To: Ville Syrjala <ville.syrjala@linux.intel.com>
Cc: intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org
Subject: Re: [Intel-gfx] [PATCH 16/18] drm/i915/sdvo: Read out HDMI infoframes
Date: Mon, 24 Sep 2018 18:10:14 +0200	[thread overview]
Message-ID: <20180924161014.GB11082@phenom.ffwll.local> (raw)
In-Reply-To: <20180920185145.1912-17-ville.syrjala@linux.intel.com>

On Thu, Sep 20, 2018 at 09:51:43PM +0300, Ville Syrjala wrote:
> From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> 
> Read the HDMI infoframes from the hbuf and unpack them into
> the crtc state.
> 
> Well, actually just AVI infoframe for now but let's write the
> infoframe readout code in a more generic fashion in case we
> expand this later.
> 
> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>

Hm, caring about sdvo seems a bit overkill. And afaik we don't have any
sdvo (much less hdmi) in CI. I'm leaning towards just adding a
PIPE_CONFIG_QUIRK_INFOFRAMES for sdvo, and short-circuiting the checks if
that's set. Except if you can somehow convince CI folks to add an sdvo
hdmi card to CI :-)

> ---
>  drivers/gpu/drm/i915/intel_sdvo.c | 92 +++++++++++++++++++++++++++++++++++++--
>  1 file changed, 89 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/intel_sdvo.c b/drivers/gpu/drm/i915/intel_sdvo.c
> index d8c78aebaf01..4d787c86df6d 100644
> --- a/drivers/gpu/drm/i915/intel_sdvo.c
> +++ b/drivers/gpu/drm/i915/intel_sdvo.c
> @@ -981,6 +981,58 @@ static bool intel_sdvo_write_infoframe(struct intel_sdvo *intel_sdvo,
>  				    &tx_rate, 1);
>  }
>  
> +static ssize_t intel_sdvo_read_infoframe(struct intel_sdvo *intel_sdvo,
> +					 unsigned int if_index,
> +					 u8 *data, unsigned int length)
> +{
> +	u8 set_buf_index[2] = { if_index, 0 };
> +	u8 hbuf_size, tx_rate, av_split;
> +	int i;
> +
> +	if (!intel_sdvo_get_value(intel_sdvo,
> +				  SDVO_CMD_GET_HBUF_AV_SPLIT,
> +				  &av_split, 1))
> +		return -ENXIO;
> +
> +	if (av_split < if_index)
> +		return 0;
> +
> +	if (!intel_sdvo_get_value(intel_sdvo,
> +				  SDVO_CMD_GET_HBUF_TXRATE,
> +				  &tx_rate, 1))
> +		return -ENXIO;
> +
> +	if (tx_rate == SDVO_HBUF_TX_DISABLED)
> +		return 0;
> +
> +	if (!intel_sdvo_set_value(intel_sdvo,
> +				  SDVO_CMD_SET_HBUF_INDEX,
> +				  set_buf_index, 2))
> +		return -ENXIO;
> +
> +	if (!intel_sdvo_get_value(intel_sdvo, SDVO_CMD_GET_HBUF_INFO,
> +				  &hbuf_size, 1))
> +		return -ENXIO;
> +
> +	/* Buffer size is 0 based, hooray! */
> +	hbuf_size++;
> +
> +	DRM_DEBUG_KMS("reading sdvo hbuf: %i, hbuf_size %i, hbuf_size: %i\n",
> +		      if_index, length, hbuf_size);
> +
> +	hbuf_size = min_t(unsigned int, length, hbuf_size);
> +
> +	for (i = 0; i < hbuf_size; i += 8) {
> +		if (!intel_sdvo_write_cmd(intel_sdvo, SDVO_CMD_GET_HBUF_DATA, NULL, 0))
> +			return -ENXIO;
> +		if (!intel_sdvo_read_response(intel_sdvo, &data[i],
> +					      min_t(unsigned int, 8, hbuf_size - i)))
> +			return -ENXIO;
> +	}
> +
> +	return hbuf_size;
> +}
> +
>  static bool intel_sdvo_compute_avi_infoframe(struct intel_sdvo *intel_sdvo,
>  					     struct intel_crtc_state *crtc_state,
>  					     struct drm_connector_state *conn_state)
> @@ -1039,6 +1091,37 @@ static bool intel_sdvo_set_avi_infoframe(struct intel_sdvo *intel_sdvo,
>  					  sdvo_data, sizeof(sdvo_data));
>  }
>  
> +static bool intel_sdvo_get_avi_infoframe(struct intel_sdvo *intel_sdvo,
> +					 struct intel_crtc_state *crtc_state)
> +{
> +	u8 sdvo_data[HDMI_INFOFRAME_SIZE(AVI)];
> +	union hdmi_infoframe *frame = &crtc_state->infoframes.avi;
> +	ssize_t len;
> +	int ret;
> +
> +	if (!crtc_state->has_hdmi_sink)
> +		return true;
> +
> +	len = intel_sdvo_read_infoframe(intel_sdvo, SDVO_HBUF_INDEX_AVI_IF,
> +					sdvo_data, sizeof(sdvo_data));
> +	if (len < 0)
> +		return false;
> +	else if (len == 0)
> +		return true;
> +
> +	crtc_state->infoframes.enable |=
> +		intel_hdmi_infoframe_enable(HDMI_INFOFRAME_TYPE_AVI);
> +
> +	ret = hdmi_infoframe_unpack(frame, sdvo_data, sizeof(sdvo_data));
> +	if (ret)
> +		return false;
> +
> +	if (frame->any.type != HDMI_INFOFRAME_TYPE_AVI)
> +		return false;
> +
> +	return true;
> +}
> +
>  static bool intel_sdvo_set_tv_format(struct intel_sdvo *intel_sdvo,
>  				     const struct drm_connector_state *conn_state)
>  {
> @@ -1535,6 +1618,10 @@ static void intel_sdvo_get_config(struct intel_encoder *encoder,
>  		}
>  	}
>  
> +	WARN(encoder_pixel_multiplier != pipe_config->pixel_multiplier,
> +	     "SDVO pixel multiplier mismatch, port: %i, encoder: %i\n",
> +	     pipe_config->pixel_multiplier, encoder_pixel_multiplier);
> +
>  	if (sdvox & HDMI_COLOR_RANGE_16_235)
>  		pipe_config->limited_color_range = true;
>  
> @@ -1547,9 +1634,8 @@ static void intel_sdvo_get_config(struct intel_encoder *encoder,
>  			pipe_config->has_hdmi_sink = true;
>  	}
>  
> -	WARN(encoder_pixel_multiplier != pipe_config->pixel_multiplier,
> -	     "SDVO pixel multiplier mismatch, port: %i, encoder: %i\n",
> -	     pipe_config->pixel_multiplier, encoder_pixel_multiplier);
> +	if (!intel_sdvo_get_avi_infoframe(intel_sdvo, pipe_config))
> +		DRM_ERROR("failed to read AVI infoframe\n");
>  }
>  
>  static void intel_disable_sdvo(struct intel_encoder *encoder,
> -- 
> 2.16.4
> 
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/intel-gfx

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

  reply	other threads:[~2018-09-24 16:10 UTC|newest]

Thread overview: 69+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-09-20 18:51 [PATCH 00/18] drm/i915: Infoframe precompute/check Ville Syrjala
2018-09-20 18:51 ` [PATCH 01/18] video/hdmi: Constify 'buffer' to the unpack functions Ville Syrjala
2018-09-21  8:03   ` Hans Verkuil
2018-09-20 18:51 ` [PATCH 02/18] video/hdmi: Pass buffer size to infoframe " Ville Syrjala
2018-09-21  8:06   ` Hans Verkuil
2018-09-20 18:51 ` [PATCH 03/18] video/hdmi: Constify infoframe passed to the log functions Ville Syrjala
2018-09-21  8:06   ` Hans Verkuil
2018-09-20 18:51 ` [PATCH 04/18] video/hdmi: Constify infoframe passed to the pack functions Ville Syrjala
2018-09-21  8:24   ` Hans Verkuil
2018-09-21 14:30     ` Ville Syrjälä
2018-09-21 14:33   ` [PATCH v3 " Ville Syrjala
2018-10-01 19:10     ` Ville Syrjälä
2018-10-02  6:37       ` Hans Verkuil
2018-09-20 18:51 ` [PATCH 05/18] video/hdmi: Add an enum for HDMI packet types Ville Syrjala
2018-09-21  8:41   ` Hans Verkuil
2018-09-21 14:01     ` Ville Syrjälä
2018-09-21 14:12       ` Hans Verkuil
2018-09-21 15:07         ` Ville Syrjälä
2018-12-20 11:27   ` Sharma, Shashank
2018-09-20 18:51 ` [PATCH 06/18] video/hdmi: Handle the MPEG Source infoframe Ville Syrjala
2018-09-21  8:28   ` Hans Verkuil
2018-09-21 13:53     ` Ville Syrjälä
2018-09-21 15:09   ` [PATCH v2 " Ville Syrjala
2018-09-20 18:51 ` [PATCH 07/18] video/hdmi: Handle the NTSC VBI infoframe Ville Syrjala
2018-09-21  8:30   ` Hans Verkuil
2018-09-21 13:54     ` Ville Syrjälä
2018-09-21 15:10   ` [PATCH v2 " Ville Syrjala
2018-09-20 18:51 ` [PATCH 08/18] drm/i915: Use memmove() for punching the hole into infoframes Ville Syrjala
2018-09-21 13:52   ` Daniel Vetter
2018-09-20 18:51 ` [PATCH 09/18] drm/i915: Pass intel_encoder to infoframe functions Ville Syrjala
2018-09-21 13:59   ` Daniel Vetter
2018-09-21 15:03     ` Ville Syrjälä
2018-09-20 18:51 ` [PATCH 10/18] drm/i915: Add the missing HDMI gamut metadata packet stuff Ville Syrjala
2018-09-21 14:15   ` [Intel-gfx] " Daniel Vetter
2018-09-20 18:51 ` [PATCH 11/18] drm/i915: Return the mask of enabled infoframes from ->inforame_enabled() Ville Syrjala
2018-09-24 15:51   ` Daniel Vetter
2018-09-24 16:36     ` [Intel-gfx] " Ville Syrjälä
2018-10-01  6:55       ` Daniel Vetter
2018-10-01 19:29         ` Ville Syrjälä
2018-09-20 18:51 ` [PATCH 12/18] drm/i915: Store mask of enabled infoframes in the crtc state Ville Syrjala
2018-09-24 15:51   ` [Intel-gfx] " Daniel Vetter
2018-09-20 18:51 ` [PATCH 13/18] drm/i915: Precompute HDMI infoframes Ville Syrjala
2018-09-24 15:58   ` Daniel Vetter
2018-09-24 16:42     ` Ville Syrjälä
2018-09-20 18:51 ` [PATCH 14/18] drm/i915: Read out " Ville Syrjala
2018-09-24 16:08   ` Daniel Vetter
2018-09-24 16:52     ` Ville Syrjälä
2018-09-20 18:51 ` [PATCH 15/18] drm/i915/sdvo: Precompute " Ville Syrjala
2018-09-20 18:51 ` [PATCH 16/18] drm/i915/sdvo: Read out " Ville Syrjala
2018-09-24 16:10   ` Daniel Vetter [this message]
2018-09-24 17:13     ` Ville Syrjälä
2018-10-01  6:59       ` Daniel Vetter
2018-10-01 13:35         ` Ville Syrjälä
2018-10-01 16:48           ` Daniel Vetter
2018-09-20 18:51 ` [PATCH 17/18] drm/i915: Check infoframe state in intel_pipe_config_compare() Ville Syrjala
2018-09-24 16:12   ` Daniel Vetter
2018-10-01 20:35     ` [Intel-gfx] " Ville Syrjälä
2018-10-02  8:16       ` Daniel Vetter
2018-09-20 18:51 ` [PATCH 18/18] drm/i915: Include infoframes in the crtc state dump Ville Syrjala
2018-09-24 16:14   ` [Intel-gfx] " Daniel Vetter
2018-09-20 19:02 ` ✗ Fi.CI.CHECKPATCH: warning for drm/i915: Infoframe precompute/check Patchwork
2018-09-20 19:12 ` ✗ Fi.CI.SPARSE: " Patchwork
2018-09-20 19:26 ` ✓ Fi.CI.BAT: success " Patchwork
2018-09-20 22:30 ` ✓ Fi.CI.IGT: " Patchwork
2018-09-21 14:40 ` ✗ Fi.CI.BAT: failure for drm/i915: Infoframe precompute/check (rev2) Patchwork
2018-09-21 15:25 ` ✗ Fi.CI.CHECKPATCH: warning for drm/i915: Infoframe precompute/check (rev4) Patchwork
2018-09-21 15:35 ` ✗ Fi.CI.SPARSE: " Patchwork
2018-09-21 15:46 ` ✓ Fi.CI.BAT: success " Patchwork
2018-09-21 17:04 ` ✓ Fi.CI.IGT: " Patchwork

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=20180924161014.GB11082@phenom.ffwll.local \
    --to=daniel@ffwll.ch \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=ville.syrjala@linux.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox