aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDave Airlie <airlied@redhat.com>2016-05-03 01:38:37 -0400
committerDave Airlie <airlied@redhat.com>2016-05-22 21:35:00 -0400
commitc97291774c1b867b56c3d439ddaec9a965cf559e (patch)
tree9c8bcda3d6f0f4a290846e8d77e7d90450a5e01a
parent3a4a2ea39f86c581054794c0a727597745f1084b (diff)
drm/edid: move displayid validation to it's own function.
We need to use this for validating modeline additions. Signed-off-by: Dave Airlie <airlied@redhat.com>
-rw-r--r--drivers/gpu/drm/drm_edid.c44
1 files changed, 26 insertions, 18 deletions
diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c
index 0b95a7f2db03..fac4efc7dfe2 100644
--- a/drivers/gpu/drm/drm_edid.c
+++ b/drivers/gpu/drm/drm_edid.c
@@ -3901,6 +3901,29 @@ static void drm_add_display_info(struct edid *edid,
3901 info->color_formats |= DRM_COLOR_FORMAT_YCRCB422; 3901 info->color_formats |= DRM_COLOR_FORMAT_YCRCB422;
3902} 3902}
3903 3903
3904static int validate_displayid(u8 *displayid, int length, int idx)
3905{
3906 int i;
3907 u8 csum = 0;
3908 struct displayid_hdr *base;
3909
3910 base = (struct displayid_hdr *)&displayid[idx];
3911
3912 DRM_DEBUG_KMS("base revision 0x%x, length %d, %d %d\n",
3913 base->rev, base->bytes, base->prod_id, base->ext_count);
3914
3915 if (base->bytes + 5 > length - idx)
3916 return -EINVAL;
3917 for (i = idx; i <= base->bytes + 5; i++) {
3918 csum += displayid[i];
3919 }
3920 if (csum) {
3921 DRM_ERROR("DisplayID checksum invalid, remainder is %d\n", csum);
3922 return -EINVAL;
3923 }
3924 return 0;
3925}
3926
3904/** 3927/**
3905 * drm_add_edid_modes - add modes from EDID data, if available 3928 * drm_add_edid_modes - add modes from EDID data, if available
3906 * @connector: connector we're probing 3929 * @connector: connector we're probing
@@ -4212,30 +4235,15 @@ static int drm_parse_display_id(struct drm_connector *connector,
4212{ 4235{
4213 /* if this is an EDID extension the first byte will be 0x70 */ 4236 /* if this is an EDID extension the first byte will be 0x70 */
4214 int idx = 0; 4237 int idx = 0;
4215 struct displayid_hdr *base;
4216 struct displayid_block *block; 4238 struct displayid_block *block;
4217 u8 csum = 0;
4218 int i;
4219 int ret; 4239 int ret;
4220 4240
4221 if (is_edid_extension) 4241 if (is_edid_extension)
4222 idx = 1; 4242 idx = 1;
4223 4243
4224 base = (struct displayid_hdr *)&displayid[idx]; 4244 ret = validate_displayid(displayid, length, idx);
4225 4245 if (ret)
4226 DRM_DEBUG_KMS("base revision 0x%x, length %d, %d %d\n", 4246 return ret;
4227 base->rev, base->bytes, base->prod_id, base->ext_count);
4228
4229 if (base->bytes + 5 > length - idx)
4230 return -EINVAL;
4231
4232 for (i = idx; i <= base->bytes + 5; i++) {
4233 csum += displayid[i];
4234 }
4235 if (csum) {
4236 DRM_ERROR("DisplayID checksum invalid, remainder is %d\n", csum);
4237 return -EINVAL;
4238 }
4239 4247
4240 idx += sizeof(struct displayid_hdr); 4248 idx += sizeof(struct displayid_hdr);
4241 while (block = (struct displayid_block *)&displayid[idx], 4249 while (block = (struct displayid_block *)&displayid[idx],