Commit d0edd3c1 authored by Jani Nikula's avatar Jani Nikula

drm/edid: convert version_greater() to drm_edid

We'll need to propagate drm_edid everywhere. Also make version_greater()
a function for type safety.
Signed-off-by: default avatarJani Nikula <jani.nikula@intel.com>
Reviewed-by: default avatarAnkit Nautiyal <ankit.k.nautiyal@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/f1835a86294b392d075570001ed9009a48352670.1652097712.git.jani.nikula@intel.com
parent d9ba1b4c
...@@ -45,10 +45,6 @@ ...@@ -45,10 +45,6 @@
#include "drm_crtc_internal.h" #include "drm_crtc_internal.h"
#define version_greater(edid, maj, min) \
(((edid)->version > (maj)) || \
((edid)->version == (maj) && (edid)->revision > (min)))
static int oui(u8 first, u8 second, u8 third) static int oui(u8 first, u8 second, u8 third)
{ {
return (first << 16) | (second << 8) | third; return (first << 16) | (second << 8) | third;
...@@ -1576,6 +1572,15 @@ struct drm_edid { ...@@ -1576,6 +1572,15 @@ struct drm_edid {
const struct edid *edid; const struct edid *edid;
}; };
static bool version_greater(const struct drm_edid *drm_edid,
u8 version, u8 revision)
{
const struct edid *edid = drm_edid->edid;
return edid->version > version ||
(edid->version == version && edid->revision > revision);
}
static int edid_extension_block_count(const struct edid *edid) static int edid_extension_block_count(const struct edid *edid)
{ {
return edid->extensions; return edid->extensions;
...@@ -3232,7 +3237,7 @@ do_inferred_modes(const struct detailed_timing *timing, void *c) ...@@ -3232,7 +3237,7 @@ do_inferred_modes(const struct detailed_timing *timing, void *c)
closure->drm_edid, closure->drm_edid,
timing); timing);
if (!version_greater(closure->drm_edid->edid, 1, 1)) if (!version_greater(closure->drm_edid, 1, 1))
return; /* GTF not defined yet */ return; /* GTF not defined yet */
switch (range->flags) { switch (range->flags) {
...@@ -3243,7 +3248,7 @@ do_inferred_modes(const struct detailed_timing *timing, void *c) ...@@ -3243,7 +3248,7 @@ do_inferred_modes(const struct detailed_timing *timing, void *c)
timing); timing);
break; break;
case 0x04: /* cvt, only in 1.4+ */ case 0x04: /* cvt, only in 1.4+ */
if (!version_greater(closure->drm_edid->edid, 1, 3)) if (!version_greater(closure->drm_edid, 1, 3))
break; break;
closure->modes += drm_cvt_modes_for_range(closure->connector, closure->modes += drm_cvt_modes_for_range(closure->connector,
...@@ -3264,7 +3269,7 @@ static int add_inferred_modes(struct drm_connector *connector, ...@@ -3264,7 +3269,7 @@ static int add_inferred_modes(struct drm_connector *connector,
.drm_edid = drm_edid, .drm_edid = drm_edid,
}; };
if (version_greater(drm_edid->edid, 1, 0)) if (version_greater(drm_edid, 1, 0))
drm_for_each_detailed_block(drm_edid, do_inferred_modes, &closure); drm_for_each_detailed_block(drm_edid, do_inferred_modes, &closure);
return closure.modes; return closure.modes;
...@@ -3341,7 +3346,7 @@ static int add_established_modes(struct drm_connector *connector, ...@@ -3341,7 +3346,7 @@ static int add_established_modes(struct drm_connector *connector,
} }
} }
if (version_greater(edid, 1, 0)) if (version_greater(drm_edid, 1, 0))
drm_for_each_detailed_block(drm_edid, do_established_modes, drm_for_each_detailed_block(drm_edid, do_established_modes,
&closure); &closure);
...@@ -3396,7 +3401,7 @@ static int add_standard_modes(struct drm_connector *connector, ...@@ -3396,7 +3401,7 @@ static int add_standard_modes(struct drm_connector *connector,
} }
} }
if (version_greater(drm_edid->edid, 1, 0)) if (version_greater(drm_edid, 1, 0))
drm_for_each_detailed_block(drm_edid, do_standard_modes, drm_for_each_detailed_block(drm_edid, do_standard_modes,
&closure); &closure);
...@@ -3476,7 +3481,7 @@ add_cvt_modes(struct drm_connector *connector, const struct drm_edid *drm_edid) ...@@ -3476,7 +3481,7 @@ add_cvt_modes(struct drm_connector *connector, const struct drm_edid *drm_edid)
.drm_edid = drm_edid, .drm_edid = drm_edid,
}; };
if (version_greater(drm_edid->edid, 1, 2)) if (version_greater(drm_edid, 1, 2))
drm_for_each_detailed_block(drm_edid, do_cvt_mode, &closure); drm_for_each_detailed_block(drm_edid, do_cvt_mode, &closure);
/* XXX should also look for CVT codes in VTB blocks */ /* XXX should also look for CVT codes in VTB blocks */
...@@ -3532,7 +3537,7 @@ static int add_detailed_modes(struct drm_connector *connector, ...@@ -3532,7 +3537,7 @@ static int add_detailed_modes(struct drm_connector *connector,
.quirks = quirks, .quirks = quirks,
}; };
if (closure.preferred && !version_greater(drm_edid->edid, 1, 3)) if (closure.preferred && !version_greater(drm_edid, 1, 3))
closure.preferred = closure.preferred =
(drm_edid->edid->features & DRM_EDID_FEATURE_PREFERRED_TIMING); (drm_edid->edid->features & DRM_EDID_FEATURE_PREFERRED_TIMING);
...@@ -5591,7 +5596,7 @@ static void drm_get_monitor_range(struct drm_connector *connector, ...@@ -5591,7 +5596,7 @@ static void drm_get_monitor_range(struct drm_connector *connector,
{ {
struct drm_display_info *info = &connector->display_info; struct drm_display_info *info = &connector->display_info;
if (!version_greater(drm_edid->edid, 1, 1)) if (!version_greater(drm_edid, 1, 1))
return; return;
drm_for_each_detailed_block(drm_edid, get_monitor_range, drm_for_each_detailed_block(drm_edid, get_monitor_range,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment