media: staging: rkisp1: isp: do not set invalid mbus code for pad
authorHelen Koike <helen.koike@collabora.com>
Thu, 6 Feb 2020 22:07:12 +0000 (23:07 +0100)
committerMauro Carvalho Chehab <mchehab+huawei@kernel.org>
Mon, 24 Feb 2020 16:41:12 +0000 (17:41 +0100)
When setting source pad, check if the given mbus code is indeed valid
for source pad, if not, then set the default code.
Same for sink pad.

Fixes: d65dd85281fb ("media: staging: rkisp1: add Rockchip ISP1 base driver")
Reported-by: Wojciech Zabolotny <wzab01@gmail.com>
Signed-off-by: Helen Koike <helen.koike@collabora.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
drivers/staging/media/rkisp1/rkisp1-isp.c

index 7b1a590..c820a43 100644 (file)
@@ -683,7 +683,7 @@ static void rkisp1_isp_set_src_fmt(struct rkisp1_isp *isp,
 
        src_fmt->code = format->code;
        mbus_info = rkisp1_isp_mbus_info_get(src_fmt->code);
-       if (!mbus_info) {
+       if (!mbus_info || !(mbus_info->direction & RKISP1_DIR_SRC)) {
                src_fmt->code = RKISP1_DEF_SRC_PAD_FMT;
                mbus_info = rkisp1_isp_mbus_info_get(src_fmt->code);
        }
@@ -767,7 +767,7 @@ static void rkisp1_isp_set_sink_fmt(struct rkisp1_isp *isp,
                                          which);
        sink_fmt->code = format->code;
        mbus_info = rkisp1_isp_mbus_info_get(sink_fmt->code);
-       if (!mbus_info) {
+       if (!mbus_info || !(mbus_info->direction & RKISP1_DIR_SINK)) {
                sink_fmt->code = RKISP1_DEF_SINK_PAD_FMT;
                mbus_info = rkisp1_isp_mbus_info_get(sink_fmt->code);
        }