summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJernej Skrabec <jernej.skrabec@siol.net>2021-04-22 01:14:28 +0100
committerAnatolij Gustschin <agust@denx.de>2021-04-24 13:44:44 +0200
commit3daea8632cabeb2f9c850743e4920472f898c6f8 (patch)
tree2497e56a3505069b2fa3a6fae1988951f36d8371
parent4fb0c3c43fbb4d28c80dc4019cdcbf57bf153021 (diff)
downloadu-boot-3daea8632cabeb2f9c850743e4920472f898c6f8.tar.gz
u-boot-3daea8632cabeb2f9c850743e4920472f898c6f8.tar.bz2
u-boot-3daea8632cabeb2f9c850743e4920472f898c6f8.zip
common: edid: extract code for detailed timing search
Code which searches for valid detailed timing entry will be used in more places. Extract it. No functional change is made. However, descriptors are casted to edid_detailed_timing instead of edid_monitor_descriptor. Descriptor can be of either type, but since we're interested only in DTD, it is more fitting to cast to edid_detailed_timing. Reviewed-by: Andre Przywara <andre.przywara@arm.com> Signed-off-by: Jernej Skrabec <jernej.skrabec@siol.net> Signed-off-by: Andre Przywara <andre.przywara@arm.com>
-rw-r--r--common/edid.c49
1 files changed, 28 insertions, 21 deletions
diff --git a/common/edid.c b/common/edid.c
index 1cb7177742..a6c875d9c8 100644
--- a/common/edid.c
+++ b/common/edid.c
@@ -169,6 +169,29 @@ static bool cea_is_hdmi_vsdb_present(struct edid_cea861_info *info)
return false;
}
+static bool edid_find_valid_timing(void *buf, int count,
+ struct display_timing *timing,
+ bool (*mode_valid)(void *priv,
+ const struct display_timing *timing),
+ void *mode_valid_priv)
+{
+ struct edid_detailed_timing *t = buf;
+ bool found = false;
+ int i;
+
+ for (i = 0; i < count && !found; i++, t++)
+ if (EDID_DETAILED_TIMING_PIXEL_CLOCK(*t) != 0) {
+ decode_timing((u8 *)t, timing);
+ if (mode_valid)
+ found = mode_valid(mode_valid_priv,
+ timing);
+ else
+ found = true;
+ }
+
+ return found;
+}
+
int edid_get_timing_validate(u8 *buf, int buf_size,
struct display_timing *timing,
int *panel_bits_per_colourp,
@@ -177,8 +200,7 @@ int edid_get_timing_validate(u8 *buf, int buf_size,
void *mode_valid_priv)
{
struct edid1_info *edid = (struct edid1_info *)buf;
- bool timing_done;
- int i;
+ bool found;
if (buf_size < sizeof(*edid) || edid_check_info(edid)) {
debug("%s: Invalid buffer\n", __func__);
@@ -195,25 +217,10 @@ int edid_get_timing_validate(u8 *buf, int buf_size,
return -ENOENT;
}
- /* Look for detailed timing */
- timing_done = false;
- for (i = 0; i < 4; i++) {
- struct edid_monitor_descriptor *desc;
-
- desc = &edid->monitor_details.descriptor[i];
- if (desc->zero_flag_1 != 0) {
- decode_timing((u8 *)desc, timing);
- if (mode_valid)
- timing_done = mode_valid(mode_valid_priv,
- timing);
- else
- timing_done = true;
-
- if (timing_done)
- break;
- }
- }
- if (!timing_done)
+ /* Look for detailed timing in base EDID */
+ found = edid_find_valid_timing(edid->monitor_details.descriptor, 4,
+ timing, mode_valid, mode_valid_priv);
+ if (!found)
return -EINVAL;
if (edid->version != 1 || edid->revision < 4) {