Intel-GFX Archive on 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 v3 09/12] drm/edid: constify struct edid passed to detailed blocks
Date: Mon, 28 Mar 2022 20:39:28 +0300	[thread overview]
Message-ID: <YkHy0BNGPHL0kGCv@intel.com> (raw)
In-Reply-To: <ec7acb8a9ee0e2868bbb2afdfdd7db114ae180e1.1648477901.git.jani.nikula@intel.com>

On Mon, Mar 28, 2022 at 05:34:30PM +0300, Jani Nikula wrote:
> Constify the first level of struct edid in detailed timing parsing. Also
> switch to struct edid instead of u8.
> 
> 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 | 48 ++++++++++++++++++--------------------
>  1 file changed, 23 insertions(+), 25 deletions(-)
> 
> diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c
> index 47234cf211ca..dae394688e5b 100644
> --- a/drivers/gpu/drm/drm_edid.c
> +++ b/drivers/gpu/drm/drm_edid.c
> @@ -2352,38 +2352,37 @@ static bool is_detailed_timing_descriptor(const struct detailed_timing *descript
>  typedef void detailed_cb(const struct detailed_timing *timing, void *closure);
>  
>  static void
> -cea_for_each_detailed_block(u8 *ext, detailed_cb *cb, void *closure)
> +cea_for_each_detailed_block(const u8 *ext, detailed_cb *cb, void *closure)
>  {
>  	int i, n;
>  	u8 d = ext[0x02];
> -	u8 *det_base = ext + d;
> +	const u8 *det_base = ext + d;
>  
>  	if (d < 4 || d > 127)
>  		return;
>  
>  	n = (127 - d) / 18;
>  	for (i = 0; i < n; i++)
> -		cb((struct detailed_timing *)(det_base + 18 * i), closure);
> +		cb((const struct detailed_timing *)(det_base + 18 * i), closure);
>  }
>  
>  static void
> -vtb_for_each_detailed_block(u8 *ext, detailed_cb *cb, void *closure)
> +vtb_for_each_detailed_block(const u8 *ext, detailed_cb *cb, void *closure)
>  {
>  	unsigned int i, n = min((int)ext[0x02], 6);
> -	u8 *det_base = ext + 5;
> +	const u8 *det_base = ext + 5;
>  
>  	if (ext[0x01] != 1)
>  		return; /* unknown version */
>  
>  	for (i = 0; i < n; i++)
> -		cb((struct detailed_timing *)(det_base + 18 * i), closure);
> +		cb((const struct detailed_timing *)(det_base + 18 * i), closure);
>  }
>  
>  static void
> -drm_for_each_detailed_block(u8 *raw_edid, detailed_cb *cb, void *closure)
> +drm_for_each_detailed_block(const struct edid *edid, detailed_cb *cb, void *closure)
>  {
>  	int i;
> -	struct edid *edid = (struct edid *)raw_edid;
>  
>  	if (edid == NULL)
>  		return;
> @@ -2391,8 +2390,8 @@ drm_for_each_detailed_block(u8 *raw_edid, detailed_cb *cb, void *closure)
>  	for (i = 0; i < EDID_DETAILED_TIMINGS; i++)
>  		cb(&(edid->detailed_timings[i]), closure);
>  
> -	for (i = 1; i <= raw_edid[0x7e]; i++) {
> -		u8 *ext = raw_edid + (i * EDID_LENGTH);
> +	for (i = 1; i <= edid->extensions; i++) {
> +		const u8 *ext = (const u8 *)edid + (i * EDID_LENGTH);
>  
>  		switch (*ext) {
>  		case CEA_EXT:
> @@ -2430,7 +2429,7 @@ drm_monitor_supports_rb(struct edid *edid)
>  	if (edid->revision >= 4) {
>  		bool ret = false;
>  
> -		drm_for_each_detailed_block((u8 *)edid, is_rb, &ret);
> +		drm_for_each_detailed_block(edid, is_rb, &ret);
>  		return ret;
>  	}
>  
> @@ -2457,7 +2456,7 @@ drm_gtf2_hbreak(struct edid *edid)
>  {
>  	const struct detailed_timing *descriptor = NULL;
>  
> -	drm_for_each_detailed_block((u8 *)edid, find_gtf2, &descriptor);
> +	drm_for_each_detailed_block(edid, find_gtf2, &descriptor);
>  
>  	BUILD_BUG_ON(offsetof(typeof(*descriptor), data.other_data.data.range.formula.gtf2.hfreq_start_khz) != 12);
>  
> @@ -2469,7 +2468,7 @@ drm_gtf2_2c(struct edid *edid)
>  {
>  	const struct detailed_timing *descriptor = NULL;
>  
> -	drm_for_each_detailed_block((u8 *)edid, find_gtf2, &descriptor);
> +	drm_for_each_detailed_block(edid, find_gtf2, &descriptor);
>  
>  	BUILD_BUG_ON(offsetof(typeof(*descriptor), data.other_data.data.range.formula.gtf2.c) != 13);
>  
> @@ -2481,7 +2480,7 @@ drm_gtf2_m(struct edid *edid)
>  {
>  	const struct detailed_timing *descriptor = NULL;
>  
> -	drm_for_each_detailed_block((u8 *)edid, find_gtf2, &descriptor);
> +	drm_for_each_detailed_block(edid, find_gtf2, &descriptor);
>  
>  	BUILD_BUG_ON(offsetof(typeof(*descriptor), data.other_data.data.range.formula.gtf2.m) != 14);
>  
> @@ -2493,7 +2492,7 @@ drm_gtf2_k(struct edid *edid)
>  {
>  	const struct detailed_timing *descriptor = NULL;
>  
> -	drm_for_each_detailed_block((u8 *)edid, find_gtf2, &descriptor);
> +	drm_for_each_detailed_block(edid, find_gtf2, &descriptor);
>  
>  	BUILD_BUG_ON(offsetof(typeof(*descriptor), data.other_data.data.range.formula.gtf2.k) != 16);
>  
> @@ -2505,7 +2504,7 @@ drm_gtf2_2j(struct edid *edid)
>  {
>  	const struct detailed_timing *descriptor = NULL;
>  
> -	drm_for_each_detailed_block((u8 *)edid, find_gtf2, &descriptor);
> +	drm_for_each_detailed_block(edid, find_gtf2, &descriptor);
>  
>  	BUILD_BUG_ON(offsetof(typeof(*descriptor), data.other_data.data.range.formula.gtf2.j) != 17);
>  
> @@ -3055,8 +3054,7 @@ add_inferred_modes(struct drm_connector *connector, struct edid *edid)
>  	};
>  
>  	if (version_greater(edid, 1, 0))
> -		drm_for_each_detailed_block((u8 *)edid, do_inferred_modes,
> -					    &closure);
> +		drm_for_each_detailed_block(edid, do_inferred_modes, &closure);
>  
>  	return closure.modes;
>  }
> @@ -3135,8 +3133,8 @@ add_established_modes(struct drm_connector *connector, struct edid *edid)
>  	}
>  
>  	if (version_greater(edid, 1, 0))
> -		    drm_for_each_detailed_block((u8 *)edid,
> -						do_established_modes, &closure);
> +		drm_for_each_detailed_block(edid, do_established_modes,
> +					    &closure);
>  
>  	return modes + closure.modes;
>  }
> @@ -3194,7 +3192,7 @@ add_standard_modes(struct drm_connector *connector, struct edid *edid)
>  	}
>  
>  	if (version_greater(edid, 1, 0))
> -		drm_for_each_detailed_block((u8 *)edid, do_standard_modes,
> +		drm_for_each_detailed_block(edid, do_standard_modes,
>  					    &closure);
>  
>  	/* XXX should also look for standard codes in VTB blocks */
> @@ -3274,7 +3272,7 @@ add_cvt_modes(struct drm_connector *connector, struct edid *edid)
>  	};
>  
>  	if (version_greater(edid, 1, 2))
> -		drm_for_each_detailed_block((u8 *)edid, do_cvt_mode, &closure);
> +		drm_for_each_detailed_block(edid, do_cvt_mode, &closure);
>  
>  	/* XXX should also look for CVT codes in VTB blocks */
>  
> @@ -3334,7 +3332,7 @@ add_detailed_modes(struct drm_connector *connector, struct edid *edid,
>  		closure.preferred =
>  		    (edid->features & DRM_EDID_FEATURE_PREFERRED_TIMING);
>  
> -	drm_for_each_detailed_block((u8 *)edid, do_detailed_mode, &closure);
> +	drm_for_each_detailed_block(edid, do_detailed_mode, &closure);
>  
>  	return closure.modes;
>  }
> @@ -4535,7 +4533,7 @@ static int get_monitor_name(struct edid *edid, char name[13])
>  	if (!edid || !name)
>  		return 0;
>  
> -	drm_for_each_detailed_block((u8 *)edid, monitor_name, &edid_name);
> +	drm_for_each_detailed_block(edid, monitor_name, &edid_name);
>  	for (mnl = 0; edid_name && mnl < 13; mnl++) {
>  		if (edid_name[mnl] == 0x0a)
>  			break;
> @@ -5281,7 +5279,7 @@ void drm_get_monitor_range(struct drm_connector *connector,
>  	if (!version_greater(edid, 1, 1))
>  		return;
>  
> -	drm_for_each_detailed_block((u8 *)edid, get_monitor_range,
> +	drm_for_each_detailed_block(edid, get_monitor_range,
>  				    &info->monitor_range);
>  
>  	DRM_DEBUG_KMS("Supported Monitor Refresh rate range is %d Hz - %d Hz\n",
> -- 
> 2.30.2

-- 
Ville Syrjälä
Intel

  reply	other threads:[~2022-03-28 17:39 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-28 14:34 [Intel-gfx] [PATCH v3 00/12] drm/edid: constify EDID parsing, with fixes Jani Nikula
2022-03-28 14:34 ` [Intel-gfx] [PATCH v3 01/12] drm/edid: don't modify EDID while parsing Jani Nikula
2022-03-28 14:34 ` [Intel-gfx] [PATCH v3 02/12] drm/edid: fix reduced blanking support check Jani Nikula
2022-03-28 17:27   ` Ville Syrjälä
2022-03-28 14:34 ` [Intel-gfx] [PATCH v3 03/12] drm/edid: pass a timing pointer to is_display_descriptor() Jani Nikula
2022-03-28 17:28   ` Ville Syrjälä
2022-03-28 14:34 ` [Intel-gfx] [PATCH v3 04/12] drm/edid: pass a timing pointer to is_detailed_timing_descriptor() Jani Nikula
2022-03-28 17:29   ` Ville Syrjälä
2022-03-28 14:34 ` [Intel-gfx] [PATCH v3 05/12] drm/edid: use struct detailed_timing member access in is_rb() Jani Nikula
2022-03-28 17:29   ` Ville Syrjälä
2022-03-28 14:34 ` [Intel-gfx] [PATCH v3 06/12] drm/edid: use struct detailed_timing member access in gtf2 functions Jani Nikula
2022-03-28 17:34   ` Ville Syrjälä
2022-03-28 14:34 ` [Intel-gfx] [PATCH v3 07/12] drm/edid: constify struct detailed_timing in lower level parsing Jani Nikula
2022-03-28 17:35   ` Ville Syrjälä
2022-03-28 14:34 ` [Intel-gfx] [PATCH v3 08/12] drm/edid: constify struct detailed_timing in parsing callbacks Jani Nikula
2022-03-28 17:37   ` Ville Syrjälä
2022-03-28 14:34 ` [Intel-gfx] [PATCH v3 09/12] drm/edid: constify struct edid passed to detailed blocks Jani Nikula
2022-03-28 17:39   ` Ville Syrjälä [this message]
2022-03-28 14:34 ` [Intel-gfx] [PATCH v3 10/12] drm/edid: constify struct edid passed around in callbacks and closure Jani Nikula
2022-03-28 17:40   ` Ville Syrjälä
2022-03-28 14:34 ` [Intel-gfx] [PATCH v3 11/12] drm/edid: add more general struct edid constness in the interfaces Jani Nikula
2022-03-28 17:41   ` Ville Syrjälä
2022-03-28 14:34 ` [Intel-gfx] [PATCH v3 12/12] drm/edid: split drm_add_edid_modes() to two Jani Nikula
2022-03-28 17:48   ` Ville Syrjälä
2022-03-28 18:35     ` Jani Nikula
2022-03-28 18:00 ` [Intel-gfx] [PATCH v3 00/12] drm/edid: constify EDID parsing, with fixes Emil Velikov
2022-03-28 18:36   ` Jani Nikula
2022-03-29  1:28 ` [Intel-gfx] ✗ Fi.CI.CHECKPATCH: warning for drm/edid: constify EDID parsing, with fixes (rev2) Patchwork
2022-03-29  1:30 ` [Intel-gfx] ✗ Fi.CI.SPARSE: " Patchwork
2022-03-29  1:34 ` [Intel-gfx] ✗ Fi.CI.DOCS: " Patchwork
2022-03-29  1:59 ` [Intel-gfx] ✓ Fi.CI.BAT: success " Patchwork
2022-03-29  4:35 ` [Intel-gfx] ✓ Fi.CI.IGT: " Patchwork
2022-03-29  9:21 ` [Intel-gfx] ✗ Fi.CI.CHECKPATCH: warning for drm/edid: constify EDID parsing, with fixes (rev3) Patchwork
2022-03-29  9:23 ` [Intel-gfx] ✗ Fi.CI.SPARSE: " Patchwork
2022-03-29  9:27 ` [Intel-gfx] ✗ Fi.CI.DOCS: " Patchwork
2022-03-29  9:59 ` [Intel-gfx] ✓ Fi.CI.BAT: success " Patchwork
2022-03-29 12:55 ` [Intel-gfx] ✓ 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=YkHy0BNGPHL0kGCv@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