Skip to content

Commit 3ecc379

Browse files
committed
Merge tag 'media/v6.1-4' of git://git.kernel.org/pub/scm/linux/kernel/git/mchehab/linux-media
Pull media fix from Mauro Carvalho Chehab: "A v4l-core fix related to validating DV timings related to video blanking values" * tag 'media/v6.1-4' of git://git.kernel.org/pub/scm/linux/kernel/git/mchehab/linux-media: media: v4l2-dv-timings.c: fix too strict blanking sanity checks
2 parents 9857feb + 5eef214 commit 3ecc379

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

drivers/media/v4l2-core/v4l2-dv-timings.c

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,8 @@ bool v4l2_valid_dv_timings(const struct v4l2_dv_timings *t,
145145
const struct v4l2_bt_timings *bt = &t->bt;
146146
const struct v4l2_bt_timings_cap *cap = &dvcap->bt;
147147
u32 caps = cap->capabilities;
148+
const u32 max_vert = 10240;
149+
u32 max_hor = 3 * bt->width;
148150

149151
if (t->type != V4L2_DV_BT_656_1120)
150152
return false;
@@ -166,14 +168,20 @@ bool v4l2_valid_dv_timings(const struct v4l2_dv_timings *t,
166168
if (!bt->interlaced &&
167169
(bt->il_vbackporch || bt->il_vsync || bt->il_vfrontporch))
168170
return false;
169-
if (bt->hfrontporch > 2 * bt->width ||
170-
bt->hsync > 1024 || bt->hbackporch > 1024)
171+
/*
172+
* Some video receivers cannot properly separate the frontporch,
173+
* backporch and sync values, and instead they only have the total
174+
* blanking. That can be assigned to any of these three fields.
175+
* So just check that none of these are way out of range.
176+
*/
177+
if (bt->hfrontporch > max_hor ||
178+
bt->hsync > max_hor || bt->hbackporch > max_hor)
171179
return false;
172-
if (bt->vfrontporch > 4096 ||
173-
bt->vsync > 128 || bt->vbackporch > 4096)
180+
if (bt->vfrontporch > max_vert ||
181+
bt->vsync > max_vert || bt->vbackporch > max_vert)
174182
return false;
175-
if (bt->interlaced && (bt->il_vfrontporch > 4096 ||
176-
bt->il_vsync > 128 || bt->il_vbackporch > 4096))
183+
if (bt->interlaced && (bt->il_vfrontporch > max_vert ||
184+
bt->il_vsync > max_vert || bt->il_vbackporch > max_vert))
177185
return false;
178186
return fnc == NULL || fnc(t, fnc_handle);
179187
}

0 commit comments

Comments
 (0)