public inbox for intel-gfx@lists.freedesktop.org
 help / color / mirror / Atom feed
From: "Ville Syrjälä" <ville.syrjala@linux.intel.com>
To: Uma Shankar <uma.shankar@intel.com>
Cc: dcastagna@chromium.org, jonas@kwiboo.se,
	intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org,
	seanpaul@chromium.org, ville.syrjala@intel.com,
	maarten.lankhorst@intel.com
Subject: Re: [v9 12/13] video/hdmi: Add Unpack function for DRM infoframe
Date: Mon, 13 May 2019 22:49:35 +0300	[thread overview]
Message-ID: <20190513194935.GV24299@intel.com> (raw)
In-Reply-To: <1557340733-9629-13-git-send-email-uma.shankar@intel.com>

On Thu, May 09, 2019 at 12:08:52AM +0530, Uma Shankar wrote:
> Added unpack function for DRM infoframe for dynamic
> range and mastering infoframe readout.
> 
> Suggested-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
> Signed-off-by: Uma Shankar <uma.shankar@intel.com>
> ---
>  drivers/video/hdmi.c | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++
>  include/linux/hdmi.h |  1 +
>  2 files changed, 55 insertions(+)
> 
> diff --git a/drivers/video/hdmi.c b/drivers/video/hdmi.c
> index 717ed7fb..110d405 100644
> --- a/drivers/video/hdmi.c
> +++ b/drivers/video/hdmi.c
> @@ -1801,6 +1801,57 @@ static int hdmi_audio_infoframe_unpack(struct hdmi_audio_infoframe *frame,
>  }
>  
>  /**
> + * hdmi_drm_infoframe_unpack() - unpack binary buffer to a HDMI DRM infoframe
> + * @frame: HDMI DRM infoframe
> + * @buffer: source buffer
> + * @size: size of buffer
> + *
> + * Unpacks the information contained in binary @buffer into a structured
> + * @frame of the HDMI Dynamic Range and Mastering (DRM) information frame.
> + * Also verifies the checksum as required by section 5.3.5 of the HDMI 1.4
> + * specification.
> + *
> + * Returns 0 on success or a negative error code on failure.
> + */
> +static int hdmi_drm_infoframe_unpack(struct hdmi_drm_infoframe *frame,
> +				     const void *buffer, size_t size)
> +{
> +	const u8 *ptr = buffer;
> +	int ret;
> +
> +	if (size < HDMI_INFOFRAME_SIZE(DRM))
> +		return -EINVAL;
> +
> +	if (ptr[0] != HDMI_INFOFRAME_TYPE_DRM ||
> +	    ptr[1] != 1 ||
> +	    ptr[2] != HDMI_DRM_INFOFRAME_SIZE)
> +		return -EINVAL;
> +
> +	if (hdmi_infoframe_checksum(buffer, HDMI_INFOFRAME_SIZE(DRM)) != 0)
> +		return -EINVAL;
> +
> +	ret = hdmi_drm_infoframe_init(frame);
> +	if (ret)
> +		return ret;
> +
> +	frame->length = ptr[2];

The length handling is inconsistnet between the compute and readout
sides. I would suggest for now just put the length initialization
into hdmi_drm_infoframe_init() (and remove it from the drm code),
and check it in the check_only(). We can revisit it if/when other
metadata formats become relevant.

> +	ptr += HDMI_INFOFRAME_HEADER_SIZE;
> +
> +	frame->eotf = ptr[0] & 0x7;
> +	frame->metadata_type = ptr[1] & 0x7;
> +
> +	memcpy(&frame->display_primaries, &ptr[2], 12);
> +	memcpy(&frame->white_point, &ptr[14], 4);

Endianness fail.

> +
> +	frame->max_display_mastering_luminance = (ptr[19] << 8) | ptr[18];
> +	frame->min_display_mastering_luminance = (ptr[21] << 8) | ptr[20];
> +	frame->max_cll = (ptr[23] << 8) | ptr[22];
> +	frame->max_fall = (ptr[25] << 8) | ptr[24];
> +
> +	return 0;
> +}
> +
> +/**
>   * hdmi_infoframe_unpack() - unpack binary buffer to a HDMI infoframe
>   * @frame: HDMI infoframe
>   * @buffer: source buffer
> @@ -1826,6 +1877,9 @@ int hdmi_infoframe_unpack(union hdmi_infoframe *frame,
>  	case HDMI_INFOFRAME_TYPE_AVI:
>  		ret = hdmi_avi_infoframe_unpack(&frame->avi, buffer, size);
>  		break;
> +	case HDMI_INFOFRAME_TYPE_DRM:
> +		ret = hdmi_drm_infoframe_unpack(&frame->drm, buffer, size);
> +		break;
>  	case HDMI_INFOFRAME_TYPE_SPD:
>  		ret = hdmi_spd_infoframe_unpack(&frame->spd, buffer, size);
>  		break;
> diff --git a/include/linux/hdmi.h b/include/linux/hdmi.h
> index 3d7f10f..ee55ba5 100644
> --- a/include/linux/hdmi.h
> +++ b/include/linux/hdmi.h
> @@ -56,6 +56,7 @@ enum hdmi_infoframe_type {
>  #define HDMI_AVI_INFOFRAME_SIZE    13
>  #define HDMI_SPD_INFOFRAME_SIZE    25
>  #define HDMI_AUDIO_INFOFRAME_SIZE  10
> +#define HDMI_DRM_INFOFRAME_SIZE    26
>  
>  #define HDMI_INFOFRAME_SIZE(type)	\
>  	(HDMI_INFOFRAME_HEADER_SIZE + HDMI_ ## type ## _INFOFRAME_SIZE)
> -- 
> 1.9.1
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel

-- 
Ville Syrjälä
Intel
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

  reply	other threads:[~2019-05-13 19:49 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-08 18:38 [v9 00/13] Add HDR Metadata Parsing and handling in DRM layer Uma Shankar
2019-05-08 18:34 ` ✗ Fi.CI.CHECKPATCH: warning for Add HDR Metadata Parsing and handling in DRM layer (rev9) Patchwork
2019-05-08 18:38 ` [v9 01/13] drm: Add HDR source metadata property Uma Shankar
2019-05-08 18:38 ` [v9 02/13] drm: Add reference counting on HDR metadata blob Uma Shankar
2019-05-08 18:38 ` [v9 03/13] drm: Parse HDR metadata info from EDID Uma Shankar
2019-05-13 19:19   ` Ville Syrjälä
2019-05-14  9:49     ` Shankar, Uma
2019-05-14 12:40       ` Ville Syrjälä
2019-05-14 13:26         ` Shankar, Uma
2019-05-08 18:38 ` [v9 04/13] drm: Enable HDR infoframe support Uma Shankar
2019-05-14 12:36   ` Kazlauskas, Nicholas
2019-05-14 12:39     ` Shankar, Uma
2019-05-14 12:44     ` Ville Syrjälä
2019-05-08 18:38 ` [v9 05/13] drm/i915: Attach HDR metadata property to connector Uma Shankar
2019-05-08 18:38 ` [v9 06/13] drm/i915: Write HDR infoframe and send to panel Uma Shankar
2019-05-13 19:35   ` Ville Syrjälä
2019-05-14 10:22     ` Shankar, Uma
2019-05-08 18:38 ` [v9 07/13] drm: Add HLG EOTF Uma Shankar
2019-05-08 18:38 ` [v9 08/13] drm/i915: Enable infoframes on GLK+ for HDR Uma Shankar
2019-05-13 19:37   ` Ville Syrjälä
2019-05-08 18:38 ` [v9 09/13] drm/i915:Enabled Modeset when HDR Infoframe changes Uma Shankar
2019-05-08 18:38 ` [v9 10/13] drm/i915: Set Infoframe for non modeset case for HDR Uma Shankar
2019-05-13 19:39   ` Ville Syrjälä
2019-05-14 16:22     ` Shankar, Uma
2019-05-08 18:38 ` [v9 11/13] drm/i915: Added DRM Infoframe handling for BYT/CHT Uma Shankar
2019-05-08 18:38 ` [v9 12/13] video/hdmi: Add Unpack function for DRM infoframe Uma Shankar
2019-05-13 19:49   ` Ville Syrjälä [this message]
2019-05-14 16:18     ` Shankar, Uma
2019-05-08 18:38 ` [v9 13/13] drm/i915: Add state readout " Uma Shankar
2019-05-13 19:50   ` Ville Syrjälä
2019-05-08 18:54 ` ✓ Fi.CI.BAT: success for Add HDR Metadata Parsing and handling in DRM layer (rev9) Patchwork
2019-05-08 22:13 ` ✓ Fi.CI.IGT: " Patchwork
2019-05-12 20:12 ` [v9 00/13] Add HDR Metadata Parsing and handling in DRM layer Jonas Karlman
2019-05-13 15:48   ` Shankar, Uma

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=20190513194935.GV24299@intel.com \
    --to=ville.syrjala@linux.intel.com \
    --cc=dcastagna@chromium.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=jonas@kwiboo.se \
    --cc=maarten.lankhorst@intel.com \
    --cc=seanpaul@chromium.org \
    --cc=uma.shankar@intel.com \
    --cc=ville.syrjala@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