All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Ville Syrjälä" <ville.syrjala@linux.intel.com>
To: Jani Nikula <jani.nikula@intel.com>
Cc: intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org
Subject: Re: [Intel-gfx] [PATCH 06/19] drm/edid: clean up cea_db_is_*() functions
Date: Tue, 26 Apr 2022 22:10:24 +0300	[thread overview]
Message-ID: <YmhDoHpmVlue4+5J@intel.com> (raw)
In-Reply-To: <da6e3a1f1b5f1038d37e82bdbd9244f999b72d96.1649948562.git.jani.nikula@intel.com>

On Thu, Apr 14, 2022 at 06:06:49PM +0300, Jani Nikula wrote:
> Abstract helpers for matching vendor data blocks and extended tags, and
> use them to simplify all the cea_db_is_*() functions.
> 
> Take void pointer as parameter to allow transitional use for both u8 *
> and struct cea_db *.
> 
> v2: Remove superfluous parens (Ville)
> 
> Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
> Signed-off-by: Jani Nikula <jani.nikula@intel.com>

Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com>

> ---
>  drivers/gpu/drm/drm_edid.c | 127 ++++++++++++-------------------------
>  1 file changed, 40 insertions(+), 87 deletions(-)
> 
> diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c
> index 43d9e04f8fb9..34897b1417a5 100644
> --- a/drivers/gpu/drm/drm_edid.c
> +++ b/drivers/gpu/drm/drm_edid.c
> @@ -4360,12 +4360,6 @@ do_hdmi_vsdb_modes(struct drm_connector *connector, const u8 *db, u8 len,
>  	return modes;
>  }
>  
> -static int
> -cea_db_extended_tag(const u8 *db)
> -{
> -	return db[1];
> -}
> -
>  static int
>  cea_revision(const u8 *cea)
>  {
> @@ -4477,6 +4471,22 @@ static const void *cea_db_data(const struct cea_db *db)
>  	return db->data;
>  }
>  
> +static bool cea_db_is_extended_tag(const struct cea_db *db, int tag)
> +{
> +	return cea_db_tag(db) == CTA_DB_EXTENDED_TAG &&
> +		cea_db_payload_len(db) >= 1 &&
> +		db->data[0] == tag;
> +}
> +
> +static bool cea_db_is_vendor(const struct cea_db *db, int vendor_oui)
> +{
> +	const u8 *data = cea_db_data(db);
> +
> +	return cea_db_tag(db) == CTA_DB_VENDOR &&
> +		cea_db_payload_len(db) >= 3 &&
> +		oui(data[2], data[1], data[0]) == vendor_oui;
> +}
> +
>  static void cea_db_iter_edid_begin(const struct edid *edid, struct cea_db_iter *iter)
>  {
>  	memset(iter, 0, sizeof(*iter));
> @@ -4611,93 +4621,50 @@ static void cea_db_iter_end(struct cea_db_iter *iter)
>  	memset(iter, 0, sizeof(*iter));
>  }
>  
> -static bool cea_db_is_hdmi_vsdb(const u8 *db)
> +static bool cea_db_is_hdmi_vsdb(const void *db)
>  {
> -	if (cea_db_tag(db) != CTA_DB_VENDOR)
> -		return false;
> -
> -	if (cea_db_payload_len(db) < 5)
> -		return false;
> -
> -	return oui(db[3], db[2], db[1]) == HDMI_IEEE_OUI;
> +	return cea_db_is_vendor(db, HDMI_IEEE_OUI) &&
> +		cea_db_payload_len(db) >= 5;
>  }
>  
> -static bool cea_db_is_hdmi_forum_vsdb(const u8 *db)
> +static bool cea_db_is_hdmi_forum_vsdb(const void *db)
>  {
> -	if (cea_db_tag(db) != CTA_DB_VENDOR)
> -		return false;
> -
> -	if (cea_db_payload_len(db) < 7)
> -		return false;
> -
> -	return oui(db[3], db[2], db[1]) == HDMI_FORUM_IEEE_OUI;
> +	return cea_db_is_vendor(db, HDMI_FORUM_IEEE_OUI) &&
> +		cea_db_payload_len(db) >= 7;
>  }
>  
> -static bool cea_db_is_microsoft_vsdb(const u8 *db)
> +static bool cea_db_is_microsoft_vsdb(const void *db)
>  {
> -	if (cea_db_tag(db) != CTA_DB_VENDOR)
> -		return false;
> -
> -	if (cea_db_payload_len(db) != 21)
> -		return false;
> -
> -	return oui(db[3], db[2], db[1]) == MICROSOFT_IEEE_OUI;
> +	return cea_db_is_vendor(db, MICROSOFT_IEEE_OUI) &&
> +		cea_db_payload_len(db) == 21;
>  }
>  
> -static bool cea_db_is_vcdb(const u8 *db)
> +static bool cea_db_is_vcdb(const void *db)
>  {
> -	if (cea_db_tag(db) != CTA_DB_EXTENDED_TAG)
> -		return false;
> -
> -	if (cea_db_payload_len(db) != 2)
> -		return false;
> -
> -	if (cea_db_extended_tag(db) != CTA_EXT_DB_VIDEO_CAP)
> -		return false;
> -
> -	return true;
> +	return cea_db_is_extended_tag(db, CTA_EXT_DB_VIDEO_CAP) &&
> +		cea_db_payload_len(db) == 2;
>  }
>  
> -static bool cea_db_is_hdmi_forum_scdb(const u8 *db)
> +static bool cea_db_is_hdmi_forum_scdb(const void *db)
>  {
> -	if (cea_db_tag(db) != CTA_DB_EXTENDED_TAG)
> -		return false;
> -
> -	if (cea_db_payload_len(db) < 7)
> -		return false;
> -
> -	if (cea_db_extended_tag(db) != CTA_EXT_DB_HF_SCDB)
> -		return false;
> -
> -	return true;
> +	return cea_db_is_extended_tag(db, CTA_EXT_DB_HF_SCDB) &&
> +		cea_db_payload_len(db) >= 7;
>  }
>  
> -static bool cea_db_is_y420cmdb(const u8 *db)
> +static bool cea_db_is_y420cmdb(const void *db)
>  {
> -	if (cea_db_tag(db) != CTA_DB_EXTENDED_TAG)
> -		return false;
> -
> -	if (!cea_db_payload_len(db))
> -		return false;
> -
> -	if (cea_db_extended_tag(db) != CTA_EXT_DB_420_VIDEO_CAP_MAP)
> -		return false;
> -
> -	return true;
> +	return cea_db_is_extended_tag(db, CTA_EXT_DB_420_VIDEO_CAP_MAP);
>  }
>  
> -static bool cea_db_is_y420vdb(const u8 *db)
> +static bool cea_db_is_y420vdb(const void *db)
>  {
> -	if (cea_db_tag(db) != CTA_DB_EXTENDED_TAG)
> -		return false;
> -
> -	if (!cea_db_payload_len(db))
> -		return false;
> -
> -	if (cea_db_extended_tag(db) != CTA_EXT_DB_420_VIDEO_DATA)
> -		return false;
> +	return cea_db_is_extended_tag(db, CTA_EXT_DB_420_VIDEO_DATA);
> +}
>  
> -	return true;
> +static bool cea_db_is_hdmi_hdr_metadata_block(const void *db)
> +{
> +	return cea_db_is_extended_tag(db, CTA_EXT_DB_HDR_STATIC_METADATA) &&
> +		cea_db_payload_len(db) >= 3;
>  }
>  
>  #define for_each_cea_db(cea, i, start, end) \
> @@ -4833,20 +4800,6 @@ static void fixup_detailed_cea_mode_clock(struct drm_display_mode *mode)
>  	mode->clock = clock;
>  }
>  
> -static bool cea_db_is_hdmi_hdr_metadata_block(const u8 *db)
> -{
> -	if (cea_db_tag(db) != CTA_DB_EXTENDED_TAG)
> -		return false;
> -
> -	if (db[1] != CTA_EXT_DB_HDR_STATIC_METADATA)
> -		return false;
> -
> -	if (cea_db_payload_len(db) < 3)
> -		return false;
> -
> -	return true;
> -}
> -
>  static uint8_t eotf_supported(const u8 *edid_ext)
>  {
>  	return edid_ext[2] &
> -- 
> 2.30.2

-- 
Ville Syrjälä
Intel

WARNING: multiple messages have this Message-ID (diff)
From: "Ville Syrjälä" <ville.syrjala@linux.intel.com>
To: Jani Nikula <jani.nikula@intel.com>
Cc: intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org
Subject: Re: [PATCH 06/19] drm/edid: clean up cea_db_is_*() functions
Date: Tue, 26 Apr 2022 22:10:24 +0300	[thread overview]
Message-ID: <YmhDoHpmVlue4+5J@intel.com> (raw)
In-Reply-To: <da6e3a1f1b5f1038d37e82bdbd9244f999b72d96.1649948562.git.jani.nikula@intel.com>

On Thu, Apr 14, 2022 at 06:06:49PM +0300, Jani Nikula wrote:
> Abstract helpers for matching vendor data blocks and extended tags, and
> use them to simplify all the cea_db_is_*() functions.
> 
> Take void pointer as parameter to allow transitional use for both u8 *
> and struct cea_db *.
> 
> v2: Remove superfluous parens (Ville)
> 
> Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
> Signed-off-by: Jani Nikula <jani.nikula@intel.com>

Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com>

> ---
>  drivers/gpu/drm/drm_edid.c | 127 ++++++++++++-------------------------
>  1 file changed, 40 insertions(+), 87 deletions(-)
> 
> diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c
> index 43d9e04f8fb9..34897b1417a5 100644
> --- a/drivers/gpu/drm/drm_edid.c
> +++ b/drivers/gpu/drm/drm_edid.c
> @@ -4360,12 +4360,6 @@ do_hdmi_vsdb_modes(struct drm_connector *connector, const u8 *db, u8 len,
>  	return modes;
>  }
>  
> -static int
> -cea_db_extended_tag(const u8 *db)
> -{
> -	return db[1];
> -}
> -
>  static int
>  cea_revision(const u8 *cea)
>  {
> @@ -4477,6 +4471,22 @@ static const void *cea_db_data(const struct cea_db *db)
>  	return db->data;
>  }
>  
> +static bool cea_db_is_extended_tag(const struct cea_db *db, int tag)
> +{
> +	return cea_db_tag(db) == CTA_DB_EXTENDED_TAG &&
> +		cea_db_payload_len(db) >= 1 &&
> +		db->data[0] == tag;
> +}
> +
> +static bool cea_db_is_vendor(const struct cea_db *db, int vendor_oui)
> +{
> +	const u8 *data = cea_db_data(db);
> +
> +	return cea_db_tag(db) == CTA_DB_VENDOR &&
> +		cea_db_payload_len(db) >= 3 &&
> +		oui(data[2], data[1], data[0]) == vendor_oui;
> +}
> +
>  static void cea_db_iter_edid_begin(const struct edid *edid, struct cea_db_iter *iter)
>  {
>  	memset(iter, 0, sizeof(*iter));
> @@ -4611,93 +4621,50 @@ static void cea_db_iter_end(struct cea_db_iter *iter)
>  	memset(iter, 0, sizeof(*iter));
>  }
>  
> -static bool cea_db_is_hdmi_vsdb(const u8 *db)
> +static bool cea_db_is_hdmi_vsdb(const void *db)
>  {
> -	if (cea_db_tag(db) != CTA_DB_VENDOR)
> -		return false;
> -
> -	if (cea_db_payload_len(db) < 5)
> -		return false;
> -
> -	return oui(db[3], db[2], db[1]) == HDMI_IEEE_OUI;
> +	return cea_db_is_vendor(db, HDMI_IEEE_OUI) &&
> +		cea_db_payload_len(db) >= 5;
>  }
>  
> -static bool cea_db_is_hdmi_forum_vsdb(const u8 *db)
> +static bool cea_db_is_hdmi_forum_vsdb(const void *db)
>  {
> -	if (cea_db_tag(db) != CTA_DB_VENDOR)
> -		return false;
> -
> -	if (cea_db_payload_len(db) < 7)
> -		return false;
> -
> -	return oui(db[3], db[2], db[1]) == HDMI_FORUM_IEEE_OUI;
> +	return cea_db_is_vendor(db, HDMI_FORUM_IEEE_OUI) &&
> +		cea_db_payload_len(db) >= 7;
>  }
>  
> -static bool cea_db_is_microsoft_vsdb(const u8 *db)
> +static bool cea_db_is_microsoft_vsdb(const void *db)
>  {
> -	if (cea_db_tag(db) != CTA_DB_VENDOR)
> -		return false;
> -
> -	if (cea_db_payload_len(db) != 21)
> -		return false;
> -
> -	return oui(db[3], db[2], db[1]) == MICROSOFT_IEEE_OUI;
> +	return cea_db_is_vendor(db, MICROSOFT_IEEE_OUI) &&
> +		cea_db_payload_len(db) == 21;
>  }
>  
> -static bool cea_db_is_vcdb(const u8 *db)
> +static bool cea_db_is_vcdb(const void *db)
>  {
> -	if (cea_db_tag(db) != CTA_DB_EXTENDED_TAG)
> -		return false;
> -
> -	if (cea_db_payload_len(db) != 2)
> -		return false;
> -
> -	if (cea_db_extended_tag(db) != CTA_EXT_DB_VIDEO_CAP)
> -		return false;
> -
> -	return true;
> +	return cea_db_is_extended_tag(db, CTA_EXT_DB_VIDEO_CAP) &&
> +		cea_db_payload_len(db) == 2;
>  }
>  
> -static bool cea_db_is_hdmi_forum_scdb(const u8 *db)
> +static bool cea_db_is_hdmi_forum_scdb(const void *db)
>  {
> -	if (cea_db_tag(db) != CTA_DB_EXTENDED_TAG)
> -		return false;
> -
> -	if (cea_db_payload_len(db) < 7)
> -		return false;
> -
> -	if (cea_db_extended_tag(db) != CTA_EXT_DB_HF_SCDB)
> -		return false;
> -
> -	return true;
> +	return cea_db_is_extended_tag(db, CTA_EXT_DB_HF_SCDB) &&
> +		cea_db_payload_len(db) >= 7;
>  }
>  
> -static bool cea_db_is_y420cmdb(const u8 *db)
> +static bool cea_db_is_y420cmdb(const void *db)
>  {
> -	if (cea_db_tag(db) != CTA_DB_EXTENDED_TAG)
> -		return false;
> -
> -	if (!cea_db_payload_len(db))
> -		return false;
> -
> -	if (cea_db_extended_tag(db) != CTA_EXT_DB_420_VIDEO_CAP_MAP)
> -		return false;
> -
> -	return true;
> +	return cea_db_is_extended_tag(db, CTA_EXT_DB_420_VIDEO_CAP_MAP);
>  }
>  
> -static bool cea_db_is_y420vdb(const u8 *db)
> +static bool cea_db_is_y420vdb(const void *db)
>  {
> -	if (cea_db_tag(db) != CTA_DB_EXTENDED_TAG)
> -		return false;
> -
> -	if (!cea_db_payload_len(db))
> -		return false;
> -
> -	if (cea_db_extended_tag(db) != CTA_EXT_DB_420_VIDEO_DATA)
> -		return false;
> +	return cea_db_is_extended_tag(db, CTA_EXT_DB_420_VIDEO_DATA);
> +}
>  
> -	return true;
> +static bool cea_db_is_hdmi_hdr_metadata_block(const void *db)
> +{
> +	return cea_db_is_extended_tag(db, CTA_EXT_DB_HDR_STATIC_METADATA) &&
> +		cea_db_payload_len(db) >= 3;
>  }
>  
>  #define for_each_cea_db(cea, i, start, end) \
> @@ -4833,20 +4800,6 @@ static void fixup_detailed_cea_mode_clock(struct drm_display_mode *mode)
>  	mode->clock = clock;
>  }
>  
> -static bool cea_db_is_hdmi_hdr_metadata_block(const u8 *db)
> -{
> -	if (cea_db_tag(db) != CTA_DB_EXTENDED_TAG)
> -		return false;
> -
> -	if (db[1] != CTA_EXT_DB_HDR_STATIC_METADATA)
> -		return false;
> -
> -	if (cea_db_payload_len(db) < 3)
> -		return false;
> -
> -	return true;
> -}
> -
>  static uint8_t eotf_supported(const u8 *edid_ext)
>  {
>  	return edid_ext[2] &
> -- 
> 2.30.2

-- 
Ville Syrjälä
Intel

  reply	other threads:[~2022-04-26 19:11 UTC|newest]

Thread overview: 51+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-14 15:06 [Intel-gfx] [PATCH 00/19] drm/edid: CEA data block iterators, and more Jani Nikula
2022-04-14 15:06 ` Jani Nikula
2022-04-14 15:06 ` [Intel-gfx] [PATCH 01/19] drm/edid: reset display info in drm_add_edid_modes() for NULL edid Jani Nikula
2022-04-14 15:06   ` Jani Nikula
2022-04-26 18:52   ` [Intel-gfx] " Ville Syrjälä
2022-04-26 18:52     ` Ville Syrjälä
2022-04-14 15:06 ` [Intel-gfx] [PATCH 02/19] drm/edid: check for HF-SCDB block Jani Nikula
2022-04-14 15:06   ` Jani Nikula
2022-04-26 19:07   ` [Intel-gfx] " Ville Syrjälä
2022-04-26 19:07     ` Ville Syrjälä
2022-04-14 15:06 ` [Intel-gfx] [PATCH 03/19] drm/edid: clean up CTA data block tag definitions Jani Nikula
2022-04-14 15:06   ` Jani Nikula
2022-04-14 15:06 ` [Intel-gfx] [PATCH 04/19] drm/edid: add iterator for EDID base and extension blocks Jani Nikula
2022-04-14 15:06   ` Jani Nikula
2022-04-14 15:06 ` [Intel-gfx] [PATCH 05/19] drm/edid: add iterator for CTA data blocks Jani Nikula
2022-04-14 15:06   ` Jani Nikula
2022-04-14 15:06 ` [Intel-gfx] [PATCH 06/19] drm/edid: clean up cea_db_is_*() functions Jani Nikula
2022-04-14 15:06   ` Jani Nikula
2022-04-26 19:10   ` Ville Syrjälä [this message]
2022-04-26 19:10     ` Ville Syrjälä
2022-04-14 15:06 ` [Intel-gfx] [PATCH 07/19] drm/edid: convert add_cea_modes() to use cea db iter Jani Nikula
2022-04-14 15:06   ` Jani Nikula
2022-04-14 15:06 ` [Intel-gfx] [PATCH 08/19] drm/edid: convert drm_edid_to_speaker_allocation() " Jani Nikula
2022-04-14 15:06   ` Jani Nikula
2022-04-14 15:06 ` [Intel-gfx] [PATCH 09/19] drm/edid: convert drm_edid_to_sad() " Jani Nikula
2022-04-14 15:06   ` Jani Nikula
2022-04-14 15:06 ` [Intel-gfx] [PATCH 10/19] drm/edid: convert drm_detect_hdmi_monitor() " Jani Nikula
2022-04-14 15:06   ` Jani Nikula
2022-04-14 15:06 ` [Intel-gfx] [PATCH 11/19] drm/edid: convert drm_detect_monitor_audio() " Jani Nikula
2022-04-14 15:06   ` Jani Nikula
2022-04-14 15:06 ` [Intel-gfx] [PATCH 12/19] drm/edid: convert drm_parse_cea_ext() " Jani Nikula
2022-04-14 15:06   ` Jani Nikula
2022-04-14 15:06 ` [Intel-gfx] [PATCH 13/19] drm/edid: convert drm_edid_to_eld() " Jani Nikula
2022-04-14 15:06   ` Jani Nikula
2022-04-14 15:06 ` [Intel-gfx] [PATCH 14/19] drm/edid: sunset the old unused cea data block iterators Jani Nikula
2022-04-14 15:06   ` Jani Nikula
2022-04-14 15:06 ` [Intel-gfx] [PATCH 15/19] drm/edid: restore some type safety to cea_db_*() functions Jani Nikula
2022-04-14 15:06   ` Jani Nikula
2022-04-14 15:06 ` [Intel-gfx] [PATCH 16/19] drm/edid: detect basic audio in all CEA extensions Jani Nikula
2022-04-14 15:06   ` Jani Nikula
2022-04-14 15:07 ` [Intel-gfx] [PATCH 17/19] drm/edid: detect color formats and CTA revision in all CTA extensions Jani Nikula
2022-04-14 15:07   ` Jani Nikula
2022-04-14 15:07 ` [Intel-gfx] [PATCH 18/19] drm/edid: skip CTA extension scan in drm_edid_to_eld() just for CTA rev Jani Nikula
2022-04-14 15:07   ` Jani Nikula
2022-04-14 15:07 ` [Intel-gfx] [PATCH 19/19] drm/edid: sunset drm_find_cea_extension() Jani Nikula
2022-04-14 15:07   ` Jani Nikula
2022-04-14 15:33 ` [Intel-gfx] ✗ Fi.CI.CHECKPATCH: warning for drm/edid: CEA data block iterators, and more Patchwork
2022-04-14 15:57 ` [Intel-gfx] ✗ Fi.CI.BAT: failure " Patchwork
2022-04-14 17:10 ` [Intel-gfx] ✗ Fi.CI.CHECKPATCH: warning for drm/edid: CEA data block iterators, and more (rev2) Patchwork
2022-04-14 17:35 ` [Intel-gfx] ✓ Fi.CI.BAT: success " Patchwork
2022-04-14 20:55 ` [Intel-gfx] ✗ Fi.CI.IGT: failure " 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=YmhDoHpmVlue4+5J@intel.com \
    --to=ville.syrjala@linux.intel.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=jani.nikula@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.