[PATCH 3/3] ipu3-cio2: Only allow setting valid mbus codes

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Check the mbus code provided by the user is one of those the driver
supports. Ignore the code in set_fmt otherwise.

Fixes: c2a6a07afe4a ("media: intel-ipu3: cio2: add new MIPI-CSI2 driver")
Signed-off-by: Sakari Ailus <sakari.ailus@xxxxxxxxxxxxxxx>
---
 drivers/media/pci/intel/ipu3/ipu3-cio2.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/drivers/media/pci/intel/ipu3/ipu3-cio2.c b/drivers/media/pci/intel/ipu3/ipu3-cio2.c
index 9c7b527a8800..2ea6313e00b0 100644
--- a/drivers/media/pci/intel/ipu3/ipu3-cio2.c
+++ b/drivers/media/pci/intel/ipu3/ipu3-cio2.c
@@ -1270,10 +1270,17 @@ static int cio2_subdev_set_fmt(struct v4l2_subdev *sd,
 	if (fmt->which == V4L2_SUBDEV_FORMAT_TRY) {
 		*v4l2_subdev_get_try_format(sd, cfg, fmt->pad) = fmt->format;
 	} else {
+		unsigned int i;
+
 		/* It's the sink, allow changing frame size */
 		q->subdev_fmt.width = fmt->format.width;
 		q->subdev_fmt.height = fmt->format.height;
-		q->subdev_fmt.code = fmt->format.code;
+		for (i = 0; i < ARRAY_SIZE(formats); i++) {
+			if (formats[i].mbus_code == fmt->format.code) {
+				q->subdev_fmt.code = fmt->format.code;
+				break;
+			}
+		}
 		fmt->format = q->subdev_fmt;
 	}
 
-- 
2.27.0




[Index of Archives]     [Linux Input]     [Video for Linux]     [Gstreamer Embedded]     [Mplayer Users]     [Linux USB Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]

  Powered by Linux