[PATCH v2 1/2] drm: constify edid handling functions

Ville Syrjälä ville.syrjala at linux.intel.com
Wed Jan 16 08:44:32 PST 2013


On Wed, Jan 16, 2013 at 03:36:41PM +0100, Lucas Stach wrote:
> All those functions only scan a predefined EDID block and have no need
> to alter anything. Constify the passed in struct edid pointer to reflect
> this in the interface.
> 
> Signed-off-by: Lucas Stach <dev at lynxeye.de>
> ---
>  drivers/gpu/drm/drm_edid.c | 73 ++++++++++++++++++++++++----------------------
>  include/drm/drm_crtc.h     | 10 +++----
>  include/drm/drm_edid.h     |  2 +-
>  3 files changed, 44 insertions(+), 41 deletions(-)
> 
> diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c
> index 5a3770f..9564e15 100644
> --- a/drivers/gpu/drm/drm_edid.c
> +++ b/drivers/gpu/drm/drm_edid.c
> @@ -71,7 +71,7 @@
>  
>  struct detailed_mode_closure {
>  	struct drm_connector *connector;
> -	struct edid *edid;
> +	const struct edid *edid;
>  	bool preferred;
>  	u32 quirks;
>  	int modes;
> @@ -227,7 +227,7 @@ EXPORT_SYMBOL(drm_edid_block_valid);
>   *
>   * Sanity-check an entire EDID record (including extensions)
>   */
> -bool drm_edid_is_valid(struct edid *edid)
> +bool drm_edid_is_valid(const struct edid *edid)

This isn't quite right. This guy calls drm_edid_block_is_valid() which
can modify the EDID. Unfortunately the casts hide the problem, and you
don't get a warning :( I didn't check if that modification could be
elimnated.

Also there's a lot more in drm_edid.c that could be const. I've included
a very quick patch (on top of yours) which undoes a few of the consts
you added, and adds a bunch more. If I compile it w/ -Wcast-qual, the
only warnings I get are from the list.h macros, so it would seem to be
mostly OK.

I had to change the way EDID_QUIRK_135_CLOCK_TOO_HIGH and
EDID_QUIRK_DETAILED_SYNC_PP are applied. Previously they would modify
the EDID itself, but I just made them modify the mode directly. Since
user space can see the raw EDID, this will affect user space too. So
perhaps some other solution would be needed. Possibly the quirks could
be applied in a separate step before the EDID is otherwise parsed.


>From 8ffe8d0fa8d2bed71adb372f14d5bf34e6687947 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ville=20Syrj=C3=A4l=C3=A4?= <ville.syrjala at linux.intel.com>
Date: Wed, 16 Jan 2013 17:56:02 +0200
Subject: [PATCH] constify a lot more

---
 drivers/gpu/drm/drm_edid.c |  182 ++++++++++++++++++++++----------------------
 include/drm/drm_crtc.h     |    8 +-
 include/drm/drm_edid.h     |    4 +-
 3 files changed, 98 insertions(+), 96 deletions(-)

diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c
index 9564e15..902800c 100644
--- a/drivers/gpu/drm/drm_edid.c
+++ b/drivers/gpu/drm/drm_edid.c
@@ -227,7 +227,7 @@ EXPORT_SYMBOL(drm_edid_block_valid);
  *
  * Sanity-check an entire EDID record (including extensions)
  */
-bool drm_edid_is_valid(const struct edid *edid)
+bool drm_edid_is_valid(struct edid *edid)
 {
 	int i;
 	u8 *raw = (u8 *)edid;
@@ -559,38 +559,38 @@ struct drm_display_mode *drm_mode_find_dmt(struct drm_device *dev,
 }
 EXPORT_SYMBOL(drm_mode_find_dmt);
 
-typedef void detailed_cb(struct detailed_timing *timing, void *closure);
+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 = 0;
 	u8 d = ext[0x02];
-	u8 *det_base = ext + d;
+	const u8 *det_base = ext + d;
 
 	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 u8 *raw_edid, detailed_cb *cb, void *closure)
 {
 	int i;
-	struct edid *edid = (struct edid *)raw_edid;
+	const struct edid *edid = (const struct edid *)raw_edid;
 
 	if (edid == NULL)
 		return;
@@ -599,7 +599,7 @@ drm_for_each_detailed_block(u8 *raw_edid, detailed_cb *cb, void *closure)
 		cb(&(edid->detailed_timings[i]), closure);
 
 	for (i = 1; i <= raw_edid[0x7e]; i++) {
-		u8 *ext = raw_edid + (i * EDID_LENGTH);
+		const u8 *ext = raw_edid + (i * EDID_LENGTH);
 		switch (*ext) {
 		case CEA_EXT:
 			cea_for_each_detailed_block(ext, cb, closure);
@@ -614,9 +614,9 @@ drm_for_each_detailed_block(u8 *raw_edid, detailed_cb *cb, void *closure)
 }
 
 static void
-is_rb(struct detailed_timing *t, void *data)
+is_rb(const struct detailed_timing *t, void *data)
 {
-	u8 *r = (u8 *)t;
+	const u8 *r = (const u8 *)t;
 	if (r[3] == EDID_DETAIL_MONITOR_RANGE)
 		if (r[15] & 0x10)
 			*(bool *)data = true;
@@ -628,7 +628,7 @@ drm_monitor_supports_rb(const 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((const u8 *)edid, is_rb, &ret);
 		return ret;
 	}
 
@@ -636,51 +636,51 @@ drm_monitor_supports_rb(const struct edid *edid)
 }
 
 static void
-find_gtf2(struct detailed_timing *t, void *data)
+find_gtf2(const struct detailed_timing *t, void *data)
 {
-	u8 *r = (u8 *)t;
+	const u8 *r = (const u8 *)t;
 	if (r[3] == EDID_DETAIL_MONITOR_RANGE && r[10] == 0x02)
-		*(u8 **)data = r;
+		*(const u8 **)data = r;
 }
 
 /* Secondary GTF curve kicks in above some break frequency */
 static int
 drm_gtf2_hbreak(const struct edid *edid)
 {
-	u8 *r = NULL;
-	drm_for_each_detailed_block((u8 *)edid, find_gtf2, &r);
+	const u8 *r = NULL;
+	drm_for_each_detailed_block((const u8 *)edid, find_gtf2, &r);
 	return r ? (r[12] * 2) : 0;
 }
 
 static int
 drm_gtf2_2c(const struct edid *edid)
 {
-	u8 *r = NULL;
-	drm_for_each_detailed_block((u8 *)edid, find_gtf2, &r);
+	const u8 *r = NULL;
+	drm_for_each_detailed_block((const u8 *)edid, find_gtf2, &r);
 	return r ? r[13] : 0;
 }
 
 static int
 drm_gtf2_m(const struct edid *edid)
 {
-	u8 *r = NULL;
-	drm_for_each_detailed_block((u8 *)edid, find_gtf2, &r);
+	const u8 *r = NULL;
+	drm_for_each_detailed_block((const u8 *)edid, find_gtf2, &r);
 	return r ? (r[15] << 8) + r[14] : 0;
 }
 
 static int
 drm_gtf2_k(const struct edid *edid)
 {
-	u8 *r = NULL;
-	drm_for_each_detailed_block((u8 *)edid, find_gtf2, &r);
+	const u8 *r = NULL;
+	drm_for_each_detailed_block((const u8 *)edid, find_gtf2, &r);
 	return r ? r[16] : 0;
 }
 
 static int
 drm_gtf2_2j(const struct edid *edid)
 {
-	u8 *r = NULL;
-	drm_for_each_detailed_block((u8 *)edid, find_gtf2, &r);
+	const u8 *r = NULL;
+	drm_for_each_detailed_block((const u8 *)edid, find_gtf2, &r);
 	return r ? r[17] : 0;
 }
 
@@ -838,7 +838,7 @@ drm_mode_std(struct drm_connector *connector, const struct edid *edid,
  */
 static void
 drm_mode_do_interlace_quirk(struct drm_display_mode *mode,
-			    struct detailed_pixel_timing *pt)
+			    const struct detailed_pixel_timing *pt)
 {
 	int i;
 	static const struct {
@@ -882,11 +882,11 @@ drm_mode_do_interlace_quirk(struct drm_display_mode *mode,
  */
 static struct drm_display_mode *drm_mode_detailed(struct drm_device *dev,
 						  const struct edid *edid,
-						  struct detailed_timing *timing,
+						  const struct detailed_timing *timing,
 						  u32 quirks)
 {
 	struct drm_display_mode *mode;
-	struct detailed_pixel_timing *pt = &timing->data.pixel_data;
+	const struct detailed_pixel_timing *pt = &timing->data.pixel_data;
 	unsigned hactive = (pt->hactive_hblank_hi & 0xf0) << 4 | pt->hactive_lo;
 	unsigned vactive = (pt->vactive_vblank_hi & 0xf0) << 4 | pt->vactive_lo;
 	unsigned hblank = (pt->hactive_hblank_hi & 0xf) << 8 | pt->hblank_lo;
@@ -928,9 +928,9 @@ static struct drm_display_mode *drm_mode_detailed(struct drm_device *dev,
 		return NULL;
 
 	if (quirks & EDID_QUIRK_135_CLOCK_TOO_HIGH)
-		timing->pixel_clock = cpu_to_le16(1088);
-
-	mode->clock = le16_to_cpu(timing->pixel_clock) * 10;
+		mode->clock = 10880;
+	else
+		mode->clock = le16_to_cpu(timing->pixel_clock) * 10;
 
 	mode->hdisplay = hactive;
 	mode->hsync_start = mode->hdisplay + hsync_offset;
@@ -951,14 +951,14 @@ static struct drm_display_mode *drm_mode_detailed(struct drm_device *dev,
 	drm_mode_do_interlace_quirk(mode, pt);
 
 	if (quirks & EDID_QUIRK_DETAILED_SYNC_PP) {
-		pt->misc |= DRM_EDID_PT_HSYNC_POSITIVE | DRM_EDID_PT_VSYNC_POSITIVE;
+		mode->flags |= DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC;
+	} else {
+		mode->flags |= (pt->misc & DRM_EDID_PT_HSYNC_POSITIVE) ?
+			DRM_MODE_FLAG_PHSYNC : DRM_MODE_FLAG_NHSYNC;
+		mode->flags |= (pt->misc & DRM_EDID_PT_VSYNC_POSITIVE) ?
+			DRM_MODE_FLAG_PVSYNC : DRM_MODE_FLAG_NVSYNC;
 	}
 
-	mode->flags |= (pt->misc & DRM_EDID_PT_HSYNC_POSITIVE) ?
-		DRM_MODE_FLAG_PHSYNC : DRM_MODE_FLAG_NHSYNC;
-	mode->flags |= (pt->misc & DRM_EDID_PT_VSYNC_POSITIVE) ?
-		DRM_MODE_FLAG_PVSYNC : DRM_MODE_FLAG_NVSYNC;
-
 set_size:
 	mode->width_mm = pt->width_mm_lo | (pt->width_height_mm_hi & 0xf0) << 4;
 	mode->height_mm = pt->height_mm_lo | (pt->width_height_mm_hi & 0xf) << 8;
@@ -981,7 +981,7 @@ set_size:
 
 static bool
 mode_in_hsync_range(const struct drm_display_mode *mode,
-		    const struct edid *edid, u8 *t)
+		    const struct edid *edid, const u8 *t)
 {
 	int hsync, hmin, hmax;
 
@@ -998,7 +998,7 @@ mode_in_hsync_range(const struct drm_display_mode *mode,
 
 static bool
 mode_in_vsync_range(const struct drm_display_mode *mode,
-		    const struct edid *edid, u8 *t)
+		    const struct edid *edid, const u8 *t)
 {
 	int vsync, vmin, vmax;
 
@@ -1014,7 +1014,7 @@ mode_in_vsync_range(const struct drm_display_mode *mode,
 }
 
 static u32
-range_pixel_clock(const struct edid *edid, u8 *t)
+range_pixel_clock(const struct edid *edid, const u8 *t)
 {
 	/* unspecified */
 	if (t[9] == 0 || t[9] == 255)
@@ -1030,10 +1030,10 @@ range_pixel_clock(const struct edid *edid, u8 *t)
 
 static bool
 mode_in_range(const struct drm_display_mode *mode, const struct edid *edid,
-	      struct detailed_timing *timing)
+	      const struct detailed_timing *timing)
 {
 	u32 max_clock;
-	u8 *t = (u8 *)timing;
+	const u8 *t = (const u8 *)timing;
 
 	if (!mode_in_hsync_range(mode, edid, t))
 		return false;
@@ -1059,7 +1059,7 @@ mode_in_range(const struct drm_display_mode *mode, const struct edid *edid,
 static bool valid_inferred_mode(const struct drm_connector *connector,
 				const struct drm_display_mode *mode)
 {
-	struct drm_display_mode *m;
+	const struct drm_display_mode *m;
 	bool ok = false;
 
 	list_for_each_entry(m, &connector->probed_modes, head) {
@@ -1077,7 +1077,7 @@ static bool valid_inferred_mode(const struct drm_connector *connector,
 static int
 drm_dmt_modes_for_range(struct drm_connector *connector,
 			const struct edid *edid,
-			struct detailed_timing *timing)
+			const struct detailed_timing *timing)
 {
 	int i, modes = 0;
 	struct drm_display_mode *newmode;
@@ -1113,7 +1113,7 @@ static void fixup_mode_1366x768(struct drm_display_mode *mode)
 static int
 drm_gtf_modes_for_range(struct drm_connector *connector,
 			const struct edid *edid,
-			struct detailed_timing *timing)
+			const struct detailed_timing *timing)
 {
 	int i, modes = 0;
 	struct drm_display_mode *newmode;
@@ -1142,7 +1142,7 @@ drm_gtf_modes_for_range(struct drm_connector *connector,
 static int
 drm_cvt_modes_for_range(struct drm_connector *connector,
 			const struct edid *edid,
-			struct detailed_timing *timing)
+			const struct detailed_timing *timing)
 {
 	int i, modes = 0;
 	struct drm_display_mode *newmode;
@@ -1170,11 +1170,11 @@ drm_cvt_modes_for_range(struct drm_connector *connector,
 }
 
 static void
-do_inferred_modes(struct detailed_timing *timing, void *c)
+do_inferred_modes(const struct detailed_timing *timing, void *c)
 {
 	struct detailed_mode_closure *closure = c;
-	struct detailed_non_pixel *data = &timing->data.other_data;
-	struct detailed_data_monitor_range *range = &data->data.range;
+	const struct detailed_non_pixel *data = &timing->data.other_data;
+	const struct detailed_data_monitor_range *range = &data->data.range;
 
 	if (data->type != EDID_DETAIL_MONITOR_RANGE)
 		return;
@@ -1215,18 +1215,18 @@ add_inferred_modes(struct drm_connector *connector, const struct edid *edid)
 	};
 
 	if (version_greater(edid, 1, 0))
-		drm_for_each_detailed_block((u8 *)edid, do_inferred_modes,
+		drm_for_each_detailed_block((const u8 *)edid, do_inferred_modes,
 					    &closure);
 
 	return closure.modes;
 }
 
 static int
-drm_est3_modes(struct drm_connector *connector, struct detailed_timing *timing)
+drm_est3_modes(struct drm_connector *connector, const struct detailed_timing *timing)
 {
 	int i, j, m, modes = 0;
 	struct drm_display_mode *mode;
-	u8 *est = ((u8 *)timing) + 5;
+	const u8 *est = ((const u8 *)timing) + 5;
 
 	for (i = 0; i < 6; i++) {
 		for (j = 7; j > 0; j--) {
@@ -1251,10 +1251,10 @@ drm_est3_modes(struct drm_connector *connector, struct detailed_timing *timing)
 }
 
 static void
-do_established_modes(struct detailed_timing *timing, void *c)
+do_established_modes(const struct detailed_timing *timing, void *c)
 {
 	struct detailed_mode_closure *closure = c;
-	struct detailed_non_pixel *data = &timing->data.other_data;
+	const struct detailed_non_pixel *data = &timing->data.other_data;
 
 	if (data->type == EDID_DETAIL_EST_TIMINGS)
 		closure->modes += drm_est3_modes(closure->connector, timing);
@@ -1291,24 +1291,24 @@ add_established_modes(struct drm_connector *connector, const struct edid *edid)
 	}
 
 	if (version_greater(edid, 1, 0))
-		    drm_for_each_detailed_block((u8 *)edid,
+		    drm_for_each_detailed_block((const u8 *)edid,
 						do_established_modes, &closure);
 
 	return modes + closure.modes;
 }
 
 static void
-do_standard_modes(struct detailed_timing *timing, void *c)
+do_standard_modes(const struct detailed_timing *timing, void *c)
 {
 	struct detailed_mode_closure *closure = c;
-	struct detailed_non_pixel *data = &timing->data.other_data;
+	const struct detailed_non_pixel *data = &timing->data.other_data;
 	struct drm_connector *connector = closure->connector;
 	const struct edid *edid = closure->edid;
 
 	if (data->type == EDID_DETAIL_STD_MODES) {
 		int i;
 		for (i = 0; i < 6; i++) {
-			struct std_timing *std;
+			const struct std_timing *std;
 			struct drm_display_mode *newmode;
 
 			std = &data->data.timings[i];
@@ -1350,7 +1350,7 @@ add_standard_modes(struct drm_connector *connector, const struct edid *edid)
 	}
 
 	if (version_greater(edid, 1, 0))
-		drm_for_each_detailed_block((u8 *)edid, do_standard_modes,
+		drm_for_each_detailed_block((const u8 *)edid, do_standard_modes,
 					    &closure);
 
 	/* XXX should also look for standard codes in VTB blocks */
@@ -1359,12 +1359,12 @@ add_standard_modes(struct drm_connector *connector, const struct edid *edid)
 }
 
 static int drm_cvt_modes(struct drm_connector *connector,
-			 struct detailed_timing *timing)
+			 const struct detailed_timing *timing)
 {
 	int i, j, modes = 0;
 	struct drm_display_mode *newmode;
 	struct drm_device *dev = connector->dev;
-	struct cvt_timing *cvt;
+	const struct cvt_timing *cvt;
 	const int rates[] = { 60, 85, 75, 60, 50 };
 	const u8 empty[3] = { 0, 0, 0 };
 
@@ -1408,10 +1408,10 @@ static int drm_cvt_modes(struct drm_connector *connector,
 }
 
 static void
-do_cvt_mode(struct detailed_timing *timing, void *c)
+do_cvt_mode(const struct detailed_timing *timing, void *c)
 {
 	struct detailed_mode_closure *closure = c;
-	struct detailed_non_pixel *data = &timing->data.other_data;
+	const struct detailed_non_pixel *data = &timing->data.other_data;
 
 	if (data->type == EDID_DETAIL_CVT_3BYTE)
 		closure->modes += drm_cvt_modes(closure->connector, timing);
@@ -1425,7 +1425,7 @@ add_cvt_modes(struct drm_connector *connector, const 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((const u8 *)edid, do_cvt_mode, &closure);
 
 	/* XXX should also look for CVT codes in VTB blocks */
 
@@ -1433,7 +1433,7 @@ add_cvt_modes(struct drm_connector *connector, const struct edid *edid)
 }
 
 static void
-do_detailed_mode(struct detailed_timing *timing, void *c)
+do_detailed_mode(const struct detailed_timing *timing, void *c)
 {
 	struct detailed_mode_closure *closure = c;
 	struct drm_display_mode *newmode;
@@ -1476,7 +1476,7 @@ add_detailed_modes(struct drm_connector *connector, const 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((const u8 *)edid, do_detailed_mode, &closure);
 
 	return closure.modes;
 }
@@ -1493,9 +1493,9 @@ add_detailed_modes(struct drm_connector *connector, const struct edid *edid,
 /**
  * Search EDID for CEA extension block.
  */
-u8 *drm_find_cea_extension(const struct edid *edid)
+const u8 *drm_find_cea_extension(const struct edid *edid)
 {
-	u8 *edid_ext = NULL;
+	const u8 *edid_ext = NULL;
 	int i;
 
 	/* No EDID or EDID extensions */
@@ -1504,7 +1504,7 @@ u8 *drm_find_cea_extension(const struct edid *edid)
 
 	/* Find CEA extension */
 	for (i = 0; i < edid->extensions; i++) {
-		edid_ext = (u8 *)edid + EDID_LENGTH * (i + 1);
+		edid_ext = (const u8 *)edid + EDID_LENGTH * (i + 1);
 		if (edid_ext[0] == CEA_EXT)
 			break;
 	}
@@ -1520,13 +1520,13 @@ EXPORT_SYMBOL(drm_find_cea_extension);
  * Looks for a CEA mode matching given drm_display_mode.
  * Returns its CEA Video ID code, or 0 if not found.
  */
-u8 drm_match_cea_mode(struct drm_display_mode *to_match)
+u8 drm_match_cea_mode(const struct drm_display_mode *to_match)
 {
-	struct drm_display_mode *cea_mode;
+	const struct drm_display_mode *cea_mode;
 	u8 mode;
 
 	for (mode = 0; mode < drm_num_cea_modes; mode++) {
-		cea_mode = (struct drm_display_mode *)&edid_cea_modes[mode];
+		cea_mode = (const struct drm_display_mode *)&edid_cea_modes[mode];
 
 		if (drm_mode_equal(to_match, cea_mode))
 			return mode + 1;
@@ -1537,10 +1537,11 @@ EXPORT_SYMBOL(drm_match_cea_mode);
 
 
 static int
-do_cea_modes (struct drm_connector *connector, u8 *db, u8 len)
+do_cea_modes (struct drm_connector *connector, const u8 *db, u8 len)
 {
 	struct drm_device *dev = connector->dev;
-	u8 * mode, cea_mode;
+	const u8 * mode;
+	u8 cea_mode;
 	int modes = 0;
 
 	for (mode = db; mode < db + len; mode++) {
@@ -1596,8 +1597,9 @@ cea_db_offsets(const u8 *cea, int *start, int *end)
 static int
 add_cea_modes(struct drm_connector *connector, const struct edid *edid)
 {
-	u8 * cea = drm_find_cea_extension(edid);
-	u8 * db, dbl;
+	const u8 *cea = drm_find_cea_extension(edid);
+	const u8 *db;
+	u8 dbl;
 	int modes = 0;
 
 	if (cea && cea_revision(cea) >= 3) {
@@ -1658,10 +1660,10 @@ parse_hdmi_vsdb(struct drm_connector *connector, const u8 *db)
 }
 
 static void
-monitor_name(struct detailed_timing *t, void *data)
+monitor_name(const struct detailed_timing *t, void *data)
 {
 	if (t->data.other_data.type == EDID_DETAIL_MONITOR_NAME)
-		*(u8 **)data = t->data.other_data.data.str.str;
+		*(const u8 **)data = t->data.other_data.data.str.str;
 }
 
 static bool cea_db_is_hdmi_vsdb(const u8 *db)
@@ -1693,9 +1695,9 @@ static bool cea_db_is_hdmi_vsdb(const u8 *db)
 void drm_edid_to_eld(struct drm_connector *connector, const struct edid *edid)
 {
 	uint8_t *eld = connector->eld;
-	u8 *cea;
-	u8 *name;
-	u8 *db;
+	const u8 *cea;
+	const u8 *name;
+	const u8 *db;
 	int sad_count = 0;
 	int mnl;
 	int dbl;
@@ -1709,7 +1711,7 @@ void drm_edid_to_eld(struct drm_connector *connector, const struct edid *edid)
 	}
 
 	name = NULL;
-	drm_for_each_detailed_block((u8 *)edid, monitor_name, &name);
+	drm_for_each_detailed_block((const u8 *)edid, monitor_name, &name);
 	for (mnl = 0; name && mnl < 13; mnl++) {
 		if (name[mnl] == 0x0a)
 			break;
@@ -1771,8 +1773,8 @@ EXPORT_SYMBOL(drm_edid_to_eld);
  * @connector: connector associated with the HDMI/DP sink
  * @mode: the display mode
  */
-int drm_av_sync_delay(struct drm_connector *connector,
-		      struct drm_display_mode *mode)
+int drm_av_sync_delay(const struct drm_connector *connector,
+		      const struct drm_display_mode *mode)
 {
 	int i = !!(mode->flags & DRM_MODE_FLAG_INTERLACE);
 	int a, v;
@@ -1835,7 +1837,7 @@ EXPORT_SYMBOL(drm_select_eld);
  */
 bool drm_detect_hdmi_monitor(const struct edid *edid)
 {
-	u8 *edid_ext;
+	const u8 *edid_ext;
 	int i;
 	int start_offset, end_offset;
 
@@ -1871,7 +1873,7 @@ EXPORT_SYMBOL(drm_detect_hdmi_monitor);
  */
 bool drm_detect_monitor_audio(const struct edid *edid)
 {
-	u8 *edid_ext;
+	const u8 *edid_ext;
 	int i, j;
 	bool has_audio = false;
 	int start_offset, end_offset;
@@ -1916,7 +1918,7 @@ EXPORT_SYMBOL(drm_detect_monitor_audio);
 static void drm_add_display_info(const struct edid *edid,
 				 struct drm_display_info *info)
 {
-	u8 *edid_ext;
+	const u8 *edid_ext;
 
 	info->width_mm = edid->width_cm * 10;
 	info->height_mm = edid->height_cm * 10;
@@ -1989,7 +1991,7 @@ static void drm_add_display_info(const struct edid *edid,
  *
  * Return number of modes added or 0 if we couldn't find any.
  */
-int drm_add_edid_modes(struct drm_connector *connector, const struct edid *edid)
+int drm_add_edid_modes(struct drm_connector *connector, struct edid *edid)
 {
 	int num_modes = 0;
 	u32 quirks;
diff --git a/include/drm/drm_crtc.h b/include/drm/drm_crtc.h
index 9b2198b..50c17b9 100644
--- a/include/drm/drm_crtc.h
+++ b/include/drm/drm_crtc.h
@@ -882,7 +882,7 @@ extern int drm_mode_group_init_legacy_group(struct drm_device *dev, struct drm_m
 extern bool drm_probe_ddc(struct i2c_adapter *adapter);
 extern struct edid *drm_get_edid(struct drm_connector *connector,
 				 struct i2c_adapter *adapter);
-extern int drm_add_edid_modes(struct drm_connector *connector, const struct edid *edid);
+extern int drm_add_edid_modes(struct drm_connector *connector, struct edid *edid);
 extern void drm_mode_probed_add(struct drm_connector *connector, struct drm_display_mode *mode);
 extern void drm_mode_remove(struct drm_connector *connector, struct drm_display_mode *mode);
 extern void drm_mode_copy(struct drm_display_mode *dst, const struct drm_display_mode *src);
@@ -1029,8 +1029,8 @@ extern int drm_mode_gamma_get_ioctl(struct drm_device *dev,
 				    void *data, struct drm_file *file_priv);
 extern int drm_mode_gamma_set_ioctl(struct drm_device *dev,
 				    void *data, struct drm_file *file_priv);
-extern u8 *drm_find_cea_extension(const struct edid *edid);
-extern u8 drm_match_cea_mode(struct drm_display_mode *to_match);
+extern const u8 *drm_find_cea_extension(const struct edid *edid);
+extern u8 drm_match_cea_mode(const struct drm_display_mode *to_match);
 extern bool drm_detect_hdmi_monitor(const struct edid *edid);
 extern bool drm_detect_monitor_audio(const struct edid *edid);
 extern int drm_mode_page_flip_ioctl(struct drm_device *dev,
@@ -1051,7 +1051,7 @@ extern uint8_t drm_mode_cea_vic(const struct drm_display_mode *mode);
 
 extern int drm_edid_header_is_valid(const u8 *raw_edid);
 extern bool drm_edid_block_valid(u8 *raw_edid, int block, bool print_bad_edid);
-extern bool drm_edid_is_valid(const struct edid *edid);
+extern bool drm_edid_is_valid(struct edid *edid);
 struct drm_display_mode *drm_mode_find_dmt(struct drm_device *dev,
 					   int hsize, int vsize, int fresh,
 					   bool rb);
diff --git a/include/drm/drm_edid.h b/include/drm/drm_edid.h
index 464ae2b..1e0ab69 100644
--- a/include/drm/drm_edid.h
+++ b/include/drm/drm_edid.h
@@ -248,8 +248,8 @@ struct drm_encoder;
 struct drm_connector;
 struct drm_display_mode;
 void drm_edid_to_eld(struct drm_connector *connector, const struct edid *edid);
-int drm_av_sync_delay(struct drm_connector *connector,
-		      struct drm_display_mode *mode);
+int drm_av_sync_delay(const struct drm_connector *connector,
+		      const struct drm_display_mode *mode);
 struct drm_connector *drm_select_eld(struct drm_encoder *encoder,
 				     struct drm_display_mode *mode);
 int drm_load_edid_firmware(struct drm_connector *connector);
-- 
1.7.8.6

-- 
Ville Syrjälä
Intel OTC


More information about the dri-devel mailing list