public inbox for intel-gfx@lists.freedesktop.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] [RFC v1 2/6] drm/displayid: add separate drm_displayid.c
Date: Wed, 10 Mar 2021 21:00:16 +0200	[thread overview]
Message-ID: <YEkXQHR596NZMQPH@intel.com> (raw)
In-Reply-To: <6c62c8b87ea14bc4dd4d9ecaf9d100afaab3478d.1615297748.git.jani.nikula@intel.com>

On Tue, Mar 09, 2021 at 03:54:10PM +0200, Jani Nikula wrote:
> We'll be adding more DisplayID specific functions going forward, so
> start off by splitting out a few functions to a separate file.
> 
> We don't bother with exporting the functions; at least for now they
> should be needed solely within drm.ko.
> 
> No functional changes.
> 
> Signed-off-by: Jani Nikula <jani.nikula@intel.com>

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

> ---
>  drivers/gpu/drm/Makefile        |  2 +-
>  drivers/gpu/drm/drm_displayid.c | 59 +++++++++++++++++++++++++++++++++
>  drivers/gpu/drm/drm_edid.c      | 58 ++------------------------------
>  include/drm/drm_displayid.h     |  8 +++++
>  include/drm/drm_edid.h          |  3 ++
>  5 files changed, 73 insertions(+), 57 deletions(-)
>  create mode 100644 drivers/gpu/drm/drm_displayid.c
> 
> diff --git a/drivers/gpu/drm/Makefile b/drivers/gpu/drm/Makefile
> index 5eb5bf7c16e3..78ef2fd14f10 100644
> --- a/drivers/gpu/drm/Makefile
> +++ b/drivers/gpu/drm/Makefile
> @@ -7,7 +7,7 @@ drm-y       :=	drm_auth.o drm_cache.o \
>  		drm_file.o drm_gem.o drm_ioctl.o drm_irq.o \
>  		drm_drv.o \
>  		drm_sysfs.o drm_hashtab.o drm_mm.o \
> -		drm_crtc.o drm_fourcc.o drm_modes.o drm_edid.o \
> +		drm_crtc.o drm_fourcc.o drm_modes.o drm_edid.o drm_displayid.o \
>  		drm_encoder_slave.o \
>  		drm_trace_points.o drm_prime.o \
>  		drm_rect.o drm_vma_manager.o drm_flip_work.o \
> diff --git a/drivers/gpu/drm/drm_displayid.c b/drivers/gpu/drm/drm_displayid.c
> new file mode 100644
> index 000000000000..908bbe6feb61
> --- /dev/null
> +++ b/drivers/gpu/drm/drm_displayid.c
> @@ -0,0 +1,59 @@
> +// SPDX-License-Identifier: MIT
> +/*
> + * Copyright © 2021 Intel Corporation
> + */
> +
> +#include <drm/drm_displayid.h>
> +#include <drm/drm_edid.h>
> +#include <drm/drm_print.h>
> +
> +static int validate_displayid(const u8 *displayid, int length, int idx)
> +{
> +	int i, dispid_length;
> +	u8 csum = 0;
> +	const struct displayid_hdr *base;
> +
> +	base = (const struct displayid_hdr *)&displayid[idx];
> +
> +	DRM_DEBUG_KMS("base revision 0x%x, length %d, %d %d\n",
> +		      base->rev, base->bytes, base->prod_id, base->ext_count);
> +
> +	/* +1 for DispID checksum */
> +	dispid_length = sizeof(*base) + base->bytes + 1;
> +	if (dispid_length > length - idx)
> +		return -EINVAL;
> +
> +	for (i = 0; i < dispid_length; i++)
> +		csum += displayid[idx + i];
> +	if (csum) {
> +		DRM_NOTE("DisplayID checksum invalid, remainder is %d\n", csum);
> +		return -EINVAL;
> +	}
> +
> +	return 0;
> +}
> +
> +const u8 *drm_find_displayid_extension(const struct edid *edid,
> +				       int *length, int *idx,
> +				       int *ext_index)
> +{
> +	const u8 *displayid = drm_find_edid_extension(edid, DISPLAYID_EXT, ext_index);
> +	const struct displayid_hdr *base;
> +	int ret;
> +
> +	if (!displayid)
> +		return NULL;
> +
> +	/* EDID extensions block checksum isn't for us */
> +	*length = EDID_LENGTH - 1;
> +	*idx = 1;
> +
> +	ret = validate_displayid(displayid, *length, *idx);
> +	if (ret)
> +		return NULL;
> +
> +	base = (const struct displayid_hdr *)&displayid[*idx];
> +	*length = *idx + sizeof(*base) + base->bytes;
> +
> +	return displayid;
> +}
> diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c
> index d510b827a1f8..58e61f792bc7 100644
> --- a/drivers/gpu/drm/drm_edid.c
> +++ b/drivers/gpu/drm/drm_edid.c
> @@ -1585,8 +1585,6 @@ module_param_named(edid_fixup, edid_fixup, int, 0400);
>  MODULE_PARM_DESC(edid_fixup,
>  		 "Minimum number of valid EDID header bytes (0-8, default 6)");
>  
> -static int validate_displayid(const u8 *displayid, int length, int idx);
> -
>  static int drm_edid_block_checksum(const u8 *raw_edid)
>  {
>  	int i;
> @@ -3241,8 +3239,8 @@ add_detailed_modes(struct drm_connector *connector, struct edid *edid,
>  /*
>   * Search EDID for CEA extension block.
>   */
> -static const u8 *drm_find_edid_extension(const struct edid *edid,
> -					 int ext_id, int *ext_index)
> +const u8 *drm_find_edid_extension(const struct edid *edid,
> +				  int ext_id, int *ext_index)
>  {
>  	const u8 *edid_ext = NULL;
>  	int i;
> @@ -3266,32 +3264,6 @@ static const u8 *drm_find_edid_extension(const struct edid *edid,
>  	return edid_ext;
>  }
>  
> -
> -static const u8 *drm_find_displayid_extension(const struct edid *edid,
> -					      int *length, int *idx,
> -					      int *ext_index)
> -{
> -	const u8 *displayid = drm_find_edid_extension(edid, DISPLAYID_EXT, ext_index);
> -	const struct displayid_hdr *base;
> -	int ret;
> -
> -	if (!displayid)
> -		return NULL;
> -
> -	/* EDID extensions block checksum isn't for us */
> -	*length = EDID_LENGTH - 1;
> -	*idx = 1;
> -
> -	ret = validate_displayid(displayid, *length, *idx);
> -	if (ret)
> -		return NULL;
> -
> -	base = (const struct displayid_hdr *)&displayid[*idx];
> -	*length = *idx + sizeof(*base) + base->bytes;
> -
> -	return displayid;
> -}
> -
>  static const u8 *drm_find_cea_extension(const struct edid *edid)
>  {
>  	int length, idx;
> @@ -5287,32 +5259,6 @@ u32 drm_add_display_info(struct drm_connector *connector, const struct edid *edi
>  	return quirks;
>  }
>  
> -static int validate_displayid(const u8 *displayid, int length, int idx)
> -{
> -	int i, dispid_length;
> -	u8 csum = 0;
> -	const struct displayid_hdr *base;
> -
> -	base = (const struct displayid_hdr *)&displayid[idx];
> -
> -	DRM_DEBUG_KMS("base revision 0x%x, length %d, %d %d\n",
> -		      base->rev, base->bytes, base->prod_id, base->ext_count);
> -
> -	/* +1 for DispID checksum */
> -	dispid_length = sizeof(*base) + base->bytes + 1;
> -	if (dispid_length > length - idx)
> -		return -EINVAL;
> -
> -	for (i = 0; i < dispid_length; i++)
> -		csum += displayid[idx + i];
> -	if (csum) {
> -		DRM_NOTE("DisplayID checksum invalid, remainder is %d\n", csum);
> -		return -EINVAL;
> -	}
> -
> -	return 0;
> -}
> -
>  static struct drm_display_mode *drm_mode_displayid_detailed(struct drm_device *dev,
>  							    struct displayid_detailed_timings_1 *timings)
>  {
> diff --git a/include/drm/drm_displayid.h b/include/drm/drm_displayid.h
> index f141c0eff083..3c6db22a518a 100644
> --- a/include/drm/drm_displayid.h
> +++ b/include/drm/drm_displayid.h
> @@ -22,6 +22,10 @@
>  #ifndef DRM_DISPLAYID_H
>  #define DRM_DISPLAYID_H
>  
> +#include <linux/types.h>
> +
> +struct edid;
> +
>  #define DATA_BLOCK_PRODUCT_ID 0x00
>  #define DATA_BLOCK_DISPLAY_PARAMETERS 0x01
>  #define DATA_BLOCK_COLOR_CHARACTERISTICS 0x02
> @@ -100,4 +104,8 @@ struct displayid_detailed_timing_block {
>  	     (idx) += sizeof(struct displayid_block) + (block)->num_bytes, \
>  	     (block) = (const struct displayid_block *)&(displayid)[idx])
>  
> +const u8 *drm_find_displayid_extension(const struct edid *edid,
> +				       int *length, int *idx,
> +				       int *ext_index);
> +
>  #endif
> diff --git a/include/drm/drm_edid.h b/include/drm/drm_edid.h
> index a158f585f658..759328a5eeb2 100644
> --- a/include/drm/drm_edid.h
> +++ b/include/drm/drm_edid.h
> @@ -543,5 +543,8 @@ struct drm_display_mode *drm_mode_find_dmt(struct drm_device *dev,
>  struct drm_display_mode *
>  drm_display_mode_from_cea_vic(struct drm_device *dev,
>  			      u8 video_code);
> +const u8 *drm_find_edid_extension(const struct edid *edid,
> +				  int ext_id, int *ext_index);
> +
>  
>  #endif /* __DRM_EDID_H__ */
> -- 
> 2.20.1
> 
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/intel-gfx

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

  reply	other threads:[~2021-03-10 19:00 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-09 13:54 [Intel-gfx] [RFC v1 0/6] drm/edid: overhaul displayid iterator Jani Nikula
2021-03-09 13:54 ` [Intel-gfx] [RFC v1 1/6] drm/edid: make a number of functions, parameters and variables const Jani Nikula
2021-03-10 18:54   ` Ville Syrjälä
2021-03-09 13:54 ` [Intel-gfx] [RFC v1 2/6] drm/displayid: add separate drm_displayid.c Jani Nikula
2021-03-10 19:00   ` Ville Syrjälä [this message]
2021-03-09 13:54 ` [Intel-gfx] [RFC v1 3/6] drm/displayid: add new displayid section/block iterators Jani Nikula
2021-03-10 19:10   ` Ville Syrjälä
2021-03-09 13:54 ` [Intel-gfx] [RFC v1 4/6] drm/edid: use the new displayid iterator for detailed modes Jani Nikula
2021-03-10 19:10   ` Ville Syrjälä
2021-03-09 13:54 ` [Intel-gfx] [RFC v1 5/6] drm/edid: use the new displayid iterator for finding CEA extension Jani Nikula
2021-03-10 19:12   ` Ville Syrjälä
2021-03-09 13:54 ` [Intel-gfx] [RFC v1 6/6] drm/edid: use the new displayid iterator for tile info Jani Nikula
2021-03-10 19:16   ` Ville Syrjälä
2021-03-10  8:27 ` [Intel-gfx] ✗ Fi.CI.CHECKPATCH: warning for drm/edid: overhaul displayid iterator Patchwork
2021-03-10  8:29 ` [Intel-gfx] ✗ Fi.CI.SPARSE: " Patchwork
2021-03-10  8:56 ` [Intel-gfx] ✗ Fi.CI.BAT: failure " Patchwork
2021-03-10  9:26 ` [Intel-gfx] ✗ Fi.CI.CHECKPATCH: warning for drm/edid: overhaul displayid iterator (rev2) Patchwork
2021-03-10  9:29 ` [Intel-gfx] ✗ Fi.CI.SPARSE: " Patchwork
2021-03-10  9:54 ` [Intel-gfx] ✓ Fi.CI.BAT: success " 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=YEkXQHR596NZMQPH@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox