Skip to content

Commit c231756

Browse files
Dingxian Wenrkhuangtao
authored andcommitted
media: rockchip: hdmirx: add timing validity judgment
Signed-off-by: Dingxian Wen <[email protected]> Change-Id: I11cfb328dc37c5239e2557460dd99f471d23a52b
1 parent ae854e6 commit c231756

File tree

1 file changed

+25
-6
lines changed

1 file changed

+25
-6
lines changed

drivers/media/platform/rockchip/hdmirx/rk_hdmirx.c

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -594,15 +594,36 @@ static void hdmirx_get_timings(struct rk_hdmirx_dev *hdmirx_dev,
594594

595595
v4l2_dbg(1, debug, v4l2_dev, "get timings from %s\n", from_dma ? "dma" : "ctrl");
596596
v4l2_dbg(1, debug, v4l2_dev,
597-
"act:%dx%d, total:%dx%d, fps:%d, pixclk:%llu\n",
597+
"act:%ux%u, total:%ux%u, fps:%u, pixclk:%llu\n",
598598
bt->width, bt->height, htotal, vtotal, fps, bt->pixelclock);
599599

600600
v4l2_dbg(2, debug, v4l2_dev,
601-
"hfp:%d, hs:%d, hbp:%d, vfp:%d, vs:%d, vbp:%d\n",
601+
"hfp:%u, hs:%u, hbp:%u, vfp:%u, vs:%u, vbp:%u\n",
602602
bt->hfrontporch, bt->hsync, bt->hbackporch,
603603
bt->vfrontporch, bt->vsync, bt->vbackporch);
604604
}
605605

606+
static bool hdmirx_check_timing_valid(struct v4l2_bt_timings *bt)
607+
{
608+
if (bt->width < 100 || bt->width > 5000 ||
609+
bt->height < 100 || bt->height > 5000)
610+
return false;
611+
612+
if (bt->hsync == 0 || bt->hsync > 200 ||
613+
bt->vsync == 0 || bt->vsync > 100)
614+
return false;
615+
616+
if (bt->hbackporch == 0 || bt->hbackporch > 2000 ||
617+
bt->vbackporch == 0 || bt->vbackporch > 2000)
618+
return false;
619+
620+
if (bt->hfrontporch == 0 || bt->hfrontporch > 2000 ||
621+
bt->vfrontporch == 0 || bt->vfrontporch > 2000)
622+
return false;
623+
624+
return true;
625+
}
626+
606627
static int hdmirx_get_detected_timings(struct rk_hdmirx_dev *hdmirx_dev,
607628
struct v4l2_dv_timings *timings, bool from_dma)
608629
{
@@ -639,16 +660,14 @@ static int hdmirx_get_detected_timings(struct rk_hdmirx_dev *hdmirx_dev,
639660
bt->il_vsync = bt->vsync + 1;
640661
}
641662

642-
v4l2_dbg(2, debug, v4l2_dev, "tmds_clk:%lld\n", tmds_clk);
663+
v4l2_dbg(2, debug, v4l2_dev, "tmds_clk:%llu\n", tmds_clk);
643664
v4l2_dbg(1, debug, v4l2_dev, "interlace:%d, fmt:%d, vic:%d, color:%d, mode:%s\n",
644665
bt->interlaced, hdmirx_dev->pix_fmt,
645666
hdmirx_dev->cur_vic, hdmirx_dev->color_depth,
646667
hdmirx_dev->is_dvi_mode ? "dvi" : "hdmi");
647668
v4l2_dbg(2, debug, v4l2_dev, "deframer_st:%#x\n", deframer_st);
648669

649-
if (bt->hsync > 200 || bt->vsync > 100 ||
650-
bt->hbackporch > 1000 || bt->vbackporch > 1000 ||
651-
bt->width < 100 || bt->height < 100)
670+
if (!hdmirx_check_timing_valid(bt))
652671
return -EINVAL;
653672

654673
return 0;

0 commit comments

Comments
 (0)